MCPcopy
hub / github.com/hcengineering/platform / tx

Method tx

plugins/process-resources/src/middleware.ts:59–80  ·  view source on GitHub ↗
(tx: Tx)

Source from the content-addressed store, hash-verified

57 private readonly txFactory = new TxOperations(this.client, getCurrentAccount().primarySocialId).txFactory
58
59 async tx (tx: Tx): Promise<TxResult> {
60 const preTx: Array<TxCUD<Doc>> = []
61 const postTx: Array<TxCUD<Doc>> = []
62 await this.handleTx(preTx, postTx, tx)
63
64 if (preTx.length > 0 || postTx.length > 0) {
65 if (TxProcessor.isExtendsCUD(tx._class)) {
66 const applyIf = this.txFactory.createTxApplyIf(
67 core.space.Tx,
68 generateId(),
69 [],
70 [],
71 [...preTx, tx as TxCUD<Doc>, ...postTx],
72 'process',
73 true
74 )
75 return await this.provideTx(applyIf)
76 }
77 }
78
79 return await this.provideTx(tx)
80 }
81
82 private async handleTx (preTx: Array<TxCUD<Doc>>, postTx: Array<TxCUD<Doc>>, ...txes: Tx[]): Promise<void> {
83 for (const etx of txes) {

Callers 4

addAttributeFunction · 0.45
addAttributeFunction · 0.45

Calls 3

handleTxMethod · 0.95
generateIdFunction · 0.90
createTxApplyIfMethod · 0.80

Tested by 2

addAttributeFunction · 0.36
addAttributeFunction · 0.36