@kodexa-ai/document-wasm-ts 8.0.0-develop-21051116449 → 8.0.0-develop-21102181279

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/dist/ContentNode.d.ts +3 -2
  2. package/dist/ContentNode.d.ts.map +1 -1
  3. package/dist/ContentNode.js +8 -6
  4. package/dist/ContentNode.js.map +1 -1
  5. package/dist/DataAttributeAccessor.d.ts +11 -22
  6. package/dist/DataAttributeAccessor.d.ts.map +1 -1
  7. package/dist/DataAttributeAccessor.js +17 -49
  8. package/dist/DataAttributeAccessor.js.map +1 -1
  9. package/dist/DataObjectAccessor.d.ts +8 -8
  10. package/dist/DataObjectAccessor.d.ts.map +1 -1
  11. package/dist/DataObjectAccessor.js +15 -15
  12. package/dist/DataObjectAccessor.js.map +1 -1
  13. package/dist/ExtractionEngine.d.ts +3 -3
  14. package/dist/ExtractionEngine.d.ts.map +1 -1
  15. package/dist/KddbDocument.d.ts +36 -8
  16. package/dist/KddbDocument.d.ts.map +1 -1
  17. package/dist/KddbDocument.js +92 -47
  18. package/dist/KddbDocument.js.map +1 -1
  19. package/dist/NoteAccessor.d.ts +6 -7
  20. package/dist/NoteAccessor.d.ts.map +1 -1
  21. package/dist/NoteAccessor.js +11 -11
  22. package/dist/NoteAccessor.js.map +1 -1
  23. package/dist/TransactionContext.d.ts +55 -0
  24. package/dist/TransactionContext.d.ts.map +1 -0
  25. package/dist/TransactionContext.js +64 -0
  26. package/dist/TransactionContext.js.map +1 -0
  27. package/dist/TransactionDataAttributeAccessor.d.ts +53 -0
  28. package/dist/TransactionDataAttributeAccessor.d.ts.map +1 -0
  29. package/dist/TransactionDataAttributeAccessor.js +105 -0
  30. package/dist/TransactionDataAttributeAccessor.js.map +1 -0
  31. package/dist/TransactionDataObjectAccessor.d.ts +38 -0
  32. package/dist/TransactionDataObjectAccessor.d.ts.map +1 -0
  33. package/dist/TransactionDataObjectAccessor.js +62 -0
  34. package/dist/TransactionDataObjectAccessor.js.map +1 -0
  35. package/dist/__tests__/TransactionContext.test.d.ts +2 -0
  36. package/dist/__tests__/TransactionContext.test.d.ts.map +1 -0
  37. package/dist/__tests__/TransactionContext.test.js +72 -0
  38. package/dist/__tests__/TransactionContext.test.js.map +1 -0
  39. package/dist/__tests__/transaction.integration.test.d.ts +13 -0
  40. package/dist/__tests__/transaction.integration.test.d.ts.map +1 -0
  41. package/dist/__tests__/transaction.integration.test.js +380 -0
  42. package/dist/__tests__/transaction.integration.test.js.map +1 -0
  43. package/dist/index.d.ts +4 -1
  44. package/dist/index.d.ts.map +1 -1
  45. package/dist/index.js +4 -0
  46. package/dist/index.js.map +1 -1
  47. package/dist/kodexa.wasm +0 -0
  48. package/dist/types/formula.d.ts +4 -4
  49. package/dist/types/formula.d.ts.map +1 -1
  50. package/dist/wasm/types.d.ts +40 -27
  51. package/dist/wasm/types.d.ts.map +1 -1
  52. package/dist/worker/KodexaWorkerDocument.d.ts +37 -50
  53. package/dist/worker/KodexaWorkerDocument.d.ts.map +1 -1
  54. package/dist/worker/KodexaWorkerDocument.js +61 -89
  55. package/dist/worker/KodexaWorkerDocument.js.map +1 -1
  56. package/dist/worker/KodexaWorkerNode.d.ts +5 -5
  57. package/dist/worker/KodexaWorkerNode.d.ts.map +1 -1
  58. package/dist/worker/KodexaWorkerNode.js +8 -7
  59. package/dist/worker/KodexaWorkerNode.js.map +1 -1
  60. package/dist/worker/types.d.ts +61 -0
  61. package/dist/worker/types.d.ts.map +1 -1
  62. package/package.json +1 -1
@@ -0,0 +1,64 @@
1
+ /**
2
+ * TransactionContext - Holds queued operations for a transaction
3
+ *
4
+ * A TransactionContext collects multiple data object and data attribute operations
5
+ * that are executed atomically when committed. This provides:
6
+ *
7
+ * 1. Atomicity: All operations succeed or none do (rollback on failure)
8
+ * 2. Performance: Batch execution reduces round-trips to the WASM layer
9
+ * 3. Temporary ID resolution: Create a data object and immediately add attributes to it
10
+ *
11
+ * Usage:
12
+ * ```typescript
13
+ * await document.withTransaction(async (tx) => {
14
+ * const obj = await tx.dataObjects.create({ taxonomyRef: 'invoice', path: 'Invoice' });
15
+ * await tx.dataAttributes.create(obj.id, { tag: 'Amount', decimalValue: 100 });
16
+ * });
17
+ * ```
18
+ */
19
+ import { TransactionDataObjectAccessor } from './TransactionDataObjectAccessor';
20
+ import { TransactionDataAttributeAccessor } from './TransactionDataAttributeAccessor';
21
+ /**
22
+ * TransactionContext - context for batching document operations
23
+ *
24
+ * Operations are queued locally and executed atomically on commit.
25
+ */
26
+ export class TransactionContext {
27
+ constructor() {
28
+ this._operations = [];
29
+ this._tempIdCounter = -1; // Negative IDs for temp refs
30
+ const nextTempId = () => this._tempIdCounter--;
31
+ this._dataObjects = new TransactionDataObjectAccessor(this._operations, nextTempId);
32
+ this._dataAttributes = new TransactionDataAttributeAccessor(this._operations, nextTempId);
33
+ }
34
+ /**
35
+ * Access data objects (queued operations)
36
+ *
37
+ * Operations performed through this accessor are queued until commit.
38
+ */
39
+ get dataObjects() {
40
+ return this._dataObjects;
41
+ }
42
+ /**
43
+ * Access data attributes (queued operations)
44
+ *
45
+ * Operations performed through this accessor are queued until commit.
46
+ */
47
+ get dataAttributes() {
48
+ return this._dataAttributes;
49
+ }
50
+ /**
51
+ * Get the number of queued operations
52
+ */
53
+ get operationCount() {
54
+ return this._operations.length;
55
+ }
56
+ /**
57
+ * Get all queued operations (internal use for commit)
58
+ * @internal
59
+ */
60
+ getOperations() {
61
+ return this._operations;
62
+ }
63
+ }
64
+ //# sourceMappingURL=TransactionContext.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionContext.js","sourceRoot":"","sources":["../src/TransactionContext.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EAAE,gCAAgC,EAAE,MAAM,oCAAoC,CAAC;AAEtF;;;;GAIG;AACH,MAAM,OAAO,kBAAkB;IAM7B;QALQ,gBAAW,GAA2B,EAAE,CAAC;QACzC,mBAAc,GAAG,CAAC,CAAC,CAAC,CAAC,6BAA6B;QAKxD,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,EAAE,CAAC;QAC/C,IAAI,CAAC,YAAY,GAAG,IAAI,6BAA6B,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACpF,IAAI,CAAC,eAAe,GAAG,IAAI,gCAAgC,CAAC,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;IAC5F,CAAC;IAED;;;;OAIG;IACH,IAAI,WAAW;QACb,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAED;;;;OAIG;IACH,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC;IAED;;OAEG;IACH,IAAI,cAAc;QAChB,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;IACjC,CAAC;IAED;;;OAGG;IACH,aAAa;QACX,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;CACF"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * TransactionDataAttributeAccessor - Queued version of DataAttributeAccessor for transactions
3
+ *
4
+ * This accessor queues data attribute operations locally instead of executing them immediately.
5
+ * Operations are collected and executed atomically when the transaction is committed.
6
+ *
7
+ * Usage: Within a transaction callback via document.withTransaction()
8
+ */
9
+ import type { DataAttribute } from './wasm/types';
10
+ import type { DataAttributeInput } from './DataAttributeAccessor';
11
+ import type { TransactionOperation } from './worker/types';
12
+ /**
13
+ * TransactionDataAttributeAccessor - queue data attribute operations for batch execution
14
+ *
15
+ * This is an internal accessor class used within transaction contexts.
16
+ */
17
+ export declare class TransactionDataAttributeAccessor {
18
+ private operations;
19
+ private nextTempId;
20
+ constructor(operations: TransactionOperation[], nextTempId: () => number);
21
+ /**
22
+ * Queue creation of a new data attribute on a data object
23
+ *
24
+ * dataObjectId can be:
25
+ * - A real ID (positive number) for existing data objects
26
+ * - A temp ID (negative number) from a newly-created object in this transaction
27
+ *
28
+ * The temp ID reference is automatically resolved when the transaction commits.
29
+ */
30
+ create(dataObjectId: number, input: DataAttributeInput): Promise<DataAttribute>;
31
+ /**
32
+ * Queue update of an existing data attribute by ID
33
+ */
34
+ updateByID(id: number, updates: Partial<DataAttribute>): Promise<DataAttribute>;
35
+ /**
36
+ * Queue update of an existing data attribute by ID
37
+ * Alias for updateByID for API consistency
38
+ */
39
+ update(id: number, updates: Partial<DataAttribute>): Promise<DataAttribute>;
40
+ /**
41
+ * Queue deletion of a data attribute by ID
42
+ */
43
+ delete(id: number): Promise<boolean>;
44
+ /**
45
+ * Queue setting value with automatic type detection
46
+ */
47
+ setValue(id: number, value: unknown): Promise<DataAttribute>;
48
+ /**
49
+ * Queue setting confidence on an attribute
50
+ */
51
+ setConfidence(id: number, confidence: number): Promise<DataAttribute>;
52
+ }
53
+ //# sourceMappingURL=TransactionDataAttributeAccessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionDataAttributeAccessor.d.ts","sourceRoot":"","sources":["../src/TransactionDataAttributeAccessor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,KAAK,EAAE,oBAAoB,EAAW,MAAM,gBAAgB,CAAC;AAEpE;;;;GAIG;AACH,qBAAa,gCAAgC;IAC3C,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,UAAU,CAAe;gBAErB,UAAU,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,MAAM,MAAM;IAKxE;;;;;;;;OAQG;IACG,MAAM,CAAC,YAAY,EAAE,MAAM,EAAE,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,aAAa,CAAC;IAuBrF;;OAEG;IACG,UAAU,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAUrF;;;OAGG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,OAAO,CAAC,aAAa,CAAC;IAIjF;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ1C;;OAEG;IACG,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC;IAmBlE;;OAEG;IACG,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;CAG5E"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * TransactionDataAttributeAccessor - Queued version of DataAttributeAccessor for transactions
3
+ *
4
+ * This accessor queues data attribute operations locally instead of executing them immediately.
5
+ * Operations are collected and executed atomically when the transaction is committed.
6
+ *
7
+ * Usage: Within a transaction callback via document.withTransaction()
8
+ */
9
+ /**
10
+ * TransactionDataAttributeAccessor - queue data attribute operations for batch execution
11
+ *
12
+ * This is an internal accessor class used within transaction contexts.
13
+ */
14
+ export class TransactionDataAttributeAccessor {
15
+ constructor(operations, nextTempId) {
16
+ this.operations = operations;
17
+ this.nextTempId = nextTempId;
18
+ }
19
+ /**
20
+ * Queue creation of a new data attribute on a data object
21
+ *
22
+ * dataObjectId can be:
23
+ * - A real ID (positive number) for existing data objects
24
+ * - A temp ID (negative number) from a newly-created object in this transaction
25
+ *
26
+ * The temp ID reference is automatically resolved when the transaction commits.
27
+ */
28
+ async create(dataObjectId, input) {
29
+ const tempId = this.nextTempId();
30
+ // If dataObjectId is negative, it's a temp ref that needs resolution
31
+ const resolvedId = dataObjectId < 0
32
+ ? { $tempId: dataObjectId }
33
+ : dataObjectId;
34
+ this.operations.push({
35
+ type: 'createDataAttribute',
36
+ dataObjectId: resolvedId,
37
+ input: input,
38
+ tempId,
39
+ });
40
+ // Return provisional object with temp ID
41
+ return {
42
+ id: tempId,
43
+ dataObjectId: dataObjectId, // Preserves temp ID reference for chaining
44
+ ...input,
45
+ };
46
+ }
47
+ /**
48
+ * Queue update of an existing data attribute by ID
49
+ */
50
+ async updateByID(id, updates) {
51
+ this.operations.push({
52
+ type: 'updateDataAttribute',
53
+ id,
54
+ updates: updates,
55
+ });
56
+ return { id, ...updates };
57
+ }
58
+ /**
59
+ * Queue update of an existing data attribute by ID
60
+ * Alias for updateByID for API consistency
61
+ */
62
+ async update(id, updates) {
63
+ return this.updateByID(id, updates);
64
+ }
65
+ /**
66
+ * Queue deletion of a data attribute by ID
67
+ */
68
+ async delete(id) {
69
+ this.operations.push({
70
+ type: 'deleteDataAttribute',
71
+ id,
72
+ });
73
+ return true;
74
+ }
75
+ /**
76
+ * Queue setting value with automatic type detection
77
+ */
78
+ async setValue(id, value) {
79
+ const updates = {};
80
+ if (typeof value === 'string') {
81
+ updates.stringValue = value;
82
+ }
83
+ else if (typeof value === 'number') {
84
+ updates.decimalValue = value;
85
+ }
86
+ else if (typeof value === 'boolean') {
87
+ updates.booleanValue = value;
88
+ }
89
+ else if (value instanceof Date) {
90
+ updates.dateValue = value.toISOString();
91
+ }
92
+ else if (value !== null && value !== undefined) {
93
+ // Fallback: serialize to JSON string for complex types
94
+ updates.stringValue = JSON.stringify(value);
95
+ }
96
+ return this.updateByID(id, updates);
97
+ }
98
+ /**
99
+ * Queue setting confidence on an attribute
100
+ */
101
+ async setConfidence(id, confidence) {
102
+ return this.updateByID(id, { confidence });
103
+ }
104
+ }
105
+ //# sourceMappingURL=TransactionDataAttributeAccessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionDataAttributeAccessor.js","sourceRoot":"","sources":["../src/TransactionDataAttributeAccessor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAM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;SACH,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAU,EAAE,KAAc;QACvC,MAAM,OAAO,GAA2B,EAAE,CAAC;QAE3C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,OAAO,CAAC,WAAW,GAAG,KAAK,CAAC;QAC9B,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACrC,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC;QAC/B,CAAC;aAAM,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YACtC,OAAO,CAAC,YAAY,GAAG,KAAK,CAAC;QAC/B,CAAC;aAAM,IAAI,KAAK,YAAY,IAAI,EAAE,CAAC;YACjC,OAAO,CAAC,SAAS,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC;QAC1C,CAAC;aAAM,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;YACjD,uDAAuD;YACvD,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,aAAa,CAAC,EAAU,EAAE,UAAkB;QAChD,OAAO,IAAI,CAAC,UAAU,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;IAC7C,CAAC;CACF"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * TransactionDataObjectAccessor - Queued version of DataObjectAccessor for transactions
3
+ *
4
+ * This accessor queues data object operations locally instead of executing them immediately.
5
+ * Operations are collected and executed atomically when the transaction is committed.
6
+ *
7
+ * Usage: Within a transaction callback via document.withTransaction()
8
+ */
9
+ import type { DataObject } from './wasm/types';
10
+ import type { DataObjectInput } from './DataObjectAccessor';
11
+ import type { TransactionOperation } from './worker/types';
12
+ /**
13
+ * TransactionDataObjectAccessor - queue data object operations for batch execution
14
+ *
15
+ * This is an internal accessor class used within transaction contexts.
16
+ */
17
+ export declare class TransactionDataObjectAccessor {
18
+ private operations;
19
+ private nextTempId;
20
+ constructor(operations: TransactionOperation[], nextTempId: () => number);
21
+ /**
22
+ * Queue creation of a new data object
23
+ * Returns a provisional object with a temporary ID (negative number)
24
+ *
25
+ * The temporary ID can be used to create related data attributes
26
+ * in the same transaction. The real ID is assigned on commit.
27
+ */
28
+ create(input: DataObjectInput): Promise<DataObject>;
29
+ /**
30
+ * Queue update of an existing data object by ID
31
+ */
32
+ update(id: number, updates: Partial<DataObject>): Promise<DataObject>;
33
+ /**
34
+ * Queue deletion of a data object by ID
35
+ */
36
+ delete(id: number): Promise<boolean>;
37
+ }
38
+ //# sourceMappingURL=TransactionDataObjectAccessor.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionDataObjectAccessor.d.ts","sourceRoot":"","sources":["../src/TransactionDataObjectAccessor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE3D;;;;GAIG;AACH,qBAAa,6BAA6B;IACxC,OAAO,CAAC,UAAU,CAAyB;IAC3C,OAAO,CAAC,UAAU,CAAe;gBAErB,UAAU,EAAE,oBAAoB,EAAE,EAAE,UAAU,EAAE,MAAM,MAAM;IAKxE;;;;;;OAMG;IACG,MAAM,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC;IAezD;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;IAW3E;;OAEG;IACG,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;CAO3C"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * TransactionDataObjectAccessor - Queued version of DataObjectAccessor for transactions
3
+ *
4
+ * This accessor queues data object operations locally instead of executing them immediately.
5
+ * Operations are collected and executed atomically when the transaction is committed.
6
+ *
7
+ * Usage: Within a transaction callback via document.withTransaction()
8
+ */
9
+ /**
10
+ * TransactionDataObjectAccessor - queue data object operations for batch execution
11
+ *
12
+ * This is an internal accessor class used within transaction contexts.
13
+ */
14
+ export class TransactionDataObjectAccessor {
15
+ constructor(operations, nextTempId) {
16
+ this.operations = operations;
17
+ this.nextTempId = nextTempId;
18
+ }
19
+ /**
20
+ * Queue creation of a new data object
21
+ * Returns a provisional object with a temporary ID (negative number)
22
+ *
23
+ * The temporary ID can be used to create related data attributes
24
+ * in the same transaction. The real ID is assigned on commit.
25
+ */
26
+ async create(input) {
27
+ const tempId = this.nextTempId();
28
+ this.operations.push({
29
+ type: 'createDataObject',
30
+ input: input,
31
+ tempId,
32
+ });
33
+ // Return provisional object with temp ID
34
+ return {
35
+ id: tempId,
36
+ ...input,
37
+ };
38
+ }
39
+ /**
40
+ * Queue update of an existing data object by ID
41
+ */
42
+ async update(id, updates) {
43
+ this.operations.push({
44
+ type: 'updateDataObject',
45
+ id,
46
+ updates: updates,
47
+ });
48
+ // Return updated object (provisional)
49
+ return { id, ...updates };
50
+ }
51
+ /**
52
+ * Queue deletion of a data object by ID
53
+ */
54
+ async delete(id) {
55
+ this.operations.push({
56
+ type: 'deleteDataObject',
57
+ id,
58
+ });
59
+ return true;
60
+ }
61
+ }
62
+ //# sourceMappingURL=TransactionDataObjectAccessor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionDataObjectAccessor.js","sourceRoot":"","sources":["../src/TransactionDataObjectAccessor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH;;;;GAIG;AACH,MAAM,OAAO,6BAA6B;IAIxC,YAAY,UAAkC,EAAE,UAAwB;QACtE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAC,KAAsB;QACjC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAU,EAAE,CAAC;QACjC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACnB,IAAI,EAAE,kBAAkB;YACxB,KAAK,EAAE,KAAgC;YACvC,MAAM;SACP,CAAC,CAAC;QAEH,yCAAyC;QACzC,OAAO;YACL,EAAE,EAAE,MAAM;YACV,GAAG,KAAK;SACK,CAAC;IAClB,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU,EAAE,OAA4B;QACnD,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACnB,IAAI,EAAE,kBAAkB;YACxB,EAAE;YACF,OAAO,EAAE,OAAkC;SAC5C,CAAC,CAAC;QAEH,sCAAsC;QACtC,OAAO,EAAE,EAAE,EAAE,GAAG,OAAO,EAAgB,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC;YACnB,IAAI,EAAE,kBAAkB;YACxB,EAAE;SACH,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=TransactionContext.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionContext.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/TransactionContext.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,72 @@
1
+ import { TransactionContext } from '../TransactionContext';
2
+ describe('TransactionContext', () => {
3
+ describe('operation queuing', () => {
4
+ it('should start with zero operations', () => {
5
+ const tx = new TransactionContext();
6
+ expect(tx.operationCount).toBe(0);
7
+ });
8
+ it('should queue createDataObject operations', async () => {
9
+ const tx = new TransactionContext();
10
+ const result = await tx.dataObjects.create({ path: '/invoice' });
11
+ expect(tx.operationCount).toBe(1);
12
+ expect(result.id).toBeLessThan(0); // Temp ID is negative
13
+ const ops = tx.getOperations();
14
+ expect(ops[0].type).toBe('createDataObject');
15
+ expect(ops[0].tempId).toBe(result.id);
16
+ });
17
+ it('should queue updateDataObject operations', async () => {
18
+ const tx = new TransactionContext();
19
+ await tx.dataObjects.update(42, { path: '/updated' });
20
+ expect(tx.operationCount).toBe(1);
21
+ const ops = tx.getOperations();
22
+ expect(ops[0].type).toBe('updateDataObject');
23
+ expect(ops[0].id).toBe(42);
24
+ });
25
+ it('should queue deleteDataObject operations', async () => {
26
+ const tx = new TransactionContext();
27
+ await tx.dataObjects.delete(42);
28
+ expect(tx.operationCount).toBe(1);
29
+ const ops = tx.getOperations();
30
+ expect(ops[0].type).toBe('deleteDataObject');
31
+ expect(ops[0].id).toBe(42);
32
+ });
33
+ });
34
+ describe('data attribute operations', () => {
35
+ it('should queue createDataAttribute with real ID', async () => {
36
+ const tx = new TransactionContext();
37
+ await tx.dataAttributes.create(42, { tag: 'amount', decimalValue: 100 });
38
+ const ops = tx.getOperations();
39
+ expect(ops[0].type).toBe('createDataAttribute');
40
+ expect(ops[0].dataObjectId).toBe(42);
41
+ });
42
+ it('should queue createDataAttribute with temp ref', async () => {
43
+ const tx = new TransactionContext();
44
+ const obj = await tx.dataObjects.create({ path: '/invoice' });
45
+ await tx.dataAttributes.create(obj.id, { tag: 'amount' });
46
+ const ops = tx.getOperations();
47
+ expect(ops[1].type).toBe('createDataAttribute');
48
+ expect(ops[1].dataObjectId).toEqual({ $tempId: obj.id });
49
+ });
50
+ it('should queue updateDataAttribute operations', async () => {
51
+ const tx = new TransactionContext();
52
+ await tx.dataAttributes.updateByID(99, { decimalValue: 200 });
53
+ const ops = tx.getOperations();
54
+ expect(ops[0].type).toBe('updateDataAttribute');
55
+ expect(ops[0].id).toBe(99);
56
+ });
57
+ });
58
+ describe('temp ID generation', () => {
59
+ it('should generate unique negative temp IDs', async () => {
60
+ const tx = new TransactionContext();
61
+ const obj1 = await tx.dataObjects.create({ path: '/a' });
62
+ const obj2 = await tx.dataObjects.create({ path: '/b' });
63
+ const attr1 = await tx.dataAttributes.create(obj1.id, { tag: 'x' });
64
+ expect(obj1.id).toBeLessThan(0);
65
+ expect(obj2.id).toBeLessThan(0);
66
+ expect(attr1.id).toBeLessThan(0);
67
+ expect(obj1.id).not.toBe(obj2.id);
68
+ expect(obj1.id).not.toBe(attr1.id);
69
+ });
70
+ });
71
+ });
72
+ //# sourceMappingURL=TransactionContext.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TransactionContext.test.js","sourceRoot":"","sources":["../../src/__tests__/TransactionContext.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAE3D,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;QACjC,EAAE,CAAC,mCAAmC,EAAE,GAAG,EAAE;YAC3C,MAAM,EAAE,GAAG,IAAI,kBAAkB,EAAE,CAAC;YACpC,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,0CAA0C,EAAE,KAAK,IAAI,EAAE;YACxD,MAAM,EAAE,GAAG,IAAI,kBAAkB,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,CAAC,CAAC;YAEjE,MAAM,CAAC,EAAE,CAAC,cAAc,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;YAClC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,C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C,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YAChC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACjC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;YAClC,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACrC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Integration tests for KddbDocument.transaction() API
3
+ *
4
+ * These tests verify the full transaction workflow through the TypeScript -> WASM -> Go stack.
5
+ * They use mocks for the WASM layer to test the TypeScript transaction logic.
6
+ *
7
+ * The transaction() method provides:
8
+ * 1. Atomicity: All operations succeed or all are rolled back
9
+ * 2. Batching: Multiple operations are sent to WASM in a single call
10
+ * 3. Temp ID resolution: Objects created in a transaction can reference each other via temp IDs
11
+ */
12
+ export {};
13
+ //# sourceMappingURL=transaction.integration.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.integration.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/transaction.integration.test.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG"}