@kodexa-ai/document-wasm-ts 2026.2.0 → 2026.3.0-develop-22148967065
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.
- package/dist/KddbDocument.d.ts.map +1 -1
- package/dist/KddbDocument.js +17 -0
- package/dist/KddbDocument.js.map +1 -1
- package/dist/kodexa-shared-worker.js +1 -1
- package/dist/kodexa-shared-worker.js.map +2 -2
- package/dist/kodexa-worker.js +1 -1
- package/dist/kodexa-worker.js.map +2 -2
- package/dist/kodexa.wasm +0 -0
- package/dist/sqljs-bridge.bundle.js +1 -1
- package/dist/wasm/loader.d.ts.map +1 -1
- package/dist/wasm/loader.js +5 -1
- package/dist/wasm/loader.js.map +1 -1
- package/dist/wasm/sqljs-bridge.d.ts.map +1 -1
- package/dist/wasm/sqljs-bridge.js +5 -2
- package/dist/wasm/sqljs-bridge.js.map +1 -1
- package/dist/wasm/sqljs-core.js +1 -1
- package/dist/wasm/sqljs-core.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KddbDocument.d.ts","sourceRoot":"","sources":["../src/KddbDocument.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"KddbDocument.d.ts","sourceRoot":"","sources":["../src/KddbDocument.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAIH,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,YAAY,EACZ,WAAW,EACX,KAAK,EACL,YAAY,EACZ,WAAW,EACX,YAAY,EACZ,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,s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
|
|
5
5
|
* No pointer-based memory management is needed.
|
|
6
6
|
*/
|
|
7
7
|
import { getWasmHelper, getWasmInstance } from './wasm/loader';
|
|
8
|
+
import { checkWasmError, clearWasmError, WasmError } from './wasm/error-handler';
|
|
8
9
|
import { ContentNode } from './ContentNode';
|
|
9
10
|
import { DataObjectAccessor } from './DataObjectAccessor';
|
|
10
11
|
import { DataAttributeAccessor } from './DataAttributeAccessor';
|
|
@@ -709,7 +710,23 @@ export class KddbDocument {
|
|
|
709
710
|
throw new Error('documentExecuteRawQuery not available in WASM module');
|
|
710
711
|
}
|
|
711
712
|
const paramsJson = params ? JSON.stringify(params) : '[]';
|
|
713
|
+
await clearWasmError(); // Clear any stale errors from previous calls
|
|
712
714
|
const resultJson = g.documentExecuteRawQuery(this.documentRef, sql, paramsJson);
|
|
715
|
+
// Check for error encoded in return value (more reliable than setLastError in WASM)
|
|
716
|
+
if (typeof resultJson === 'string' && resultJson.startsWith('{"error":')) {
|
|
717
|
+
try {
|
|
718
|
+
const errObj = JSON.parse(resultJson);
|
|
719
|
+
if (errObj.error) {
|
|
720
|
+
throw new WasmError(errObj.error);
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
catch (e) {
|
|
724
|
+
if (e instanceof WasmError)
|
|
725
|
+
throw e;
|
|
726
|
+
// If JSON parse fails, fall through to checkWasmError
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
await checkWasmError(); // Keep as fallback
|
|
713
730
|
const helper = await getWasmHelper();
|
|
714
731
|
const results = helper.parseJsonResult(resultJson);
|
|
715
732
|
return Array.isArray(results) ? results : [];
|
package/dist/KddbDocument.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KddbDocument.js","sourceRoot":"","sources":["../src/KddbDocument.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAY/D,OAAO,EAAE,WAAW,EAAE,MA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AE,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACK,aAAa;QACnB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;;AA12BD,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACI,yBAAY,GAAG;CAKrB,AALkB,CAKjB","sourcesContent":["/**\n * KddbDocument - TypeScript wrapper for Go WASM Document functionality\n *\n * NOTE: Go WASM with syscall/js passes strings directly between JS and Go.\n * No pointer-based memory management is needed.\n */\n\nimport { getWasmHelper, getWasmInstance } from './wasm/loader';\nimport {\n ContentException,\n DocumentMetadata,\n DeltaSession,\n DeltaStatus,\n Delta,\n DeltaPreview,\n ApplyResult,\n ApplyOptions,\n RefreshResult,\n} from './wasm/types';\nimport { ContentNode } from './ContentNode';\nimport { DataObjectAccessor } from './DataObjectAccessor';\nimport { DataAttributeAccessor } from './DataAttributeAccessor';\nimport { AuditAccessor } from './AuditAccessor';\nimport { NativeDocumentAccessor } from './NativeDocumentAccessor';\nimport { NoteAccessor } from './NoteAccessor';\nimport { TaxonomyAccessor } from './TaxonomyAccessor';\nimport { TransactionContext } from './TransactionContext';\nimport type { TransactionResponse } from './worker/types';\n\nexport class KddbDocument {\n private documentRef: number;\n private disposed = false;\n private _dataObjects?: DataObjectAccessor;\n private _dataAttributes?: DataAttributeAccessor;\n private _audit?: AuditAccessor;\n private _nativeDocuments?: NativeDocumentAccessor;\n private _notes?: NoteAccessor;\n private _taxonomies?: TaxonomyAccessor;\n\n constructor(documentRef: number) {\n this.documentRef = documentRef;\n }\n\n /**\n * Access data objects in this document\n * Usage: document.dataObjects.getAll(), document.dataObjects.getByUUID(uuid), etc.\n */\n get dataObjects(): DataObjectAccessor {\n this.checkDisposed();\n if (!this._dataObjects) {\n this._dataObjects = new DataObjectAccessor(this.documentRef);\n }\n return this._dataObjects;\n }\n\n /**\n * Access data attributes in this document\n * Usage: document.dataAttributes.getAll(), document.dataAttributes.getByUUID(uuid), etc.\n */\n get dataAttributes(): DataAttributeAccessor {\n this.checkDisposed();\n if (!this._dataAttributes) {\n this._dataAttributes = new DataAttributeAccessor(this.documentRef);\n }\n return this._dataAttributes;\n }\n\n /**\n * Access audit data in this document\n * Usage: document.audit.listRevisions(), document.audit.getDataObjectHistory(id), etc.\n */\n get audit(): AuditAccessor {\n this.checkDisposed();\n if (!this._audit) {\n this._audit = new AuditAccessor(this.documentRef);\n }\n return this._audit;\n }\n\n /**\n * Access native documents in this document (embedded files like PDFs, images)\n * Usage: document.nativeDocuments.getAll(), document.nativeDocuments.getData(id), etc.\n */\n get nativeDocuments(): NativeDocumentAccessor {\n this.checkDisposed();\n if (!this._nativeDocuments) {\n this._nativeDocuments = new NativeDocumentAccessor(this.documentRef);\n }\n return this._nativeDocuments;\n }\n\n /**\n * Access notes in this document\n * Usage: document.notes.getAll(), document.notes.create({content: \"...\"}), etc.\n */\n get notes(): NoteAccessor {\n this.checkDisposed();\n if (!this._notes) {\n this._notes = new NoteAccessor(this.documentRef);\n }\n return this._notes;\n }\n\n /**\n * Access taxonomies stored in this document\n *\n * Taxonomies define the structure and types of data that can be extracted.\n * Store taxonomies to enable automatic taxon resolution when creating data attributes.\n *\n * Usage:\n * - document.taxonomies.store(taxonomy) - Store a taxonomy\n * - document.taxonomies.getByRef(ref) - Get taxonomy by reference\n * - document.taxonomies.getAll() - List all taxonomies\n * - document.taxonomies.getTaxonByPath(ref, path) - Get specific taxon\n */\n get taxonomies(): TaxonomyAccessor {\n this.checkDisposed();\n if (!this._taxonomies) {\n this._taxonomies = new TaxonomyAccessor(this.documentRef);\n }\n return this._taxonomies;\n }\n\n /**\n * Execute a set of operations atomically within a transaction.\n *\n * All operations performed through the transaction context are batched\n * and sent to the database in a single atomic operation. If any operation\n * fails or the callback throws an error, all changes are rolled back.\n *\n * @example\n * ```typescript\n * await document.transaction(async (tx) => {\n * const invoice = await tx.dataObjects.create({\n * path: '/invoice',\n * taxonomyRef: 'acme/invoice/1.0'\n * });\n *\n * await tx.dataAttributes.create(invoice.id, {\n * tag: 'amount',\n * decimalValue: 1500.00\n * });\n *\n * if (validationFailed) {\n * throw new Error('Validation failed'); // Rolls back everything\n * }\n * });\n * ```\n */\n async transaction(callback: (tx: TransactionContext) => Promise<void>): Promise<void> {\n this.checkDisposed();\n await getWasmInstance();\n\n const tx = new TransactionContext();\n\n // Execute callback to collect operations\n await callback(tx);\n\n // If no operations, nothing to do\n if (tx.operationCount === 0) {\n return;\n }\n\n // Execute transaction via WASM\n const g = globalThis as any;\n if (typeof g.executeTransaction !== 'function') {\n throw new Error('executeTransaction not available in WASM module');\n }\n\n const resultJson = g.executeTransaction(\n this.documentRef,\n JSON.stringify(tx.getOperations())\n );\n\n if (!resultJson) {\n throw new Error('executeTransaction returned no response');\n }\n\n let result: TransactionResponse;\n try {\n result = JSON.parse(resultJson);\n } catch (e) {\n throw new Error(`Failed to parse transaction response: ${e instanceof Error ? e.message : String(e)}`);\n }\n\n if (!result.success) {\n throw new Error(`Transaction failed: ${result.error ?? 'Unknown error'}`);\n }\n\n // Transaction succeeded - idMappings contains temp ID -> real ID mappings\n // (These could be used to update provisional objects if needed)\n }\n\n /**\n * Create a new empty document\n */\n static async create(): Promise<KddbDocument> {\n await getWasmInstance(); // Ensure WASM is loaded\n const docRef = createDocument();\n return new KddbDocument(docRef);\n }\n\n /**\n * Create a document from text\n */\n static async fromText(text: string): Promise<KddbDocument> {\n await getWasmInstance(); // Ensure WASM is loaded\n const docRef = createDocumentFromText(text);\n return new KddbDocument(docRef);\n }\n\n /**\n * Create a document from JSON string\n */\n static async fromJson(json: string): Promise<KddbDocument> {\n await getWasmInstance(); // Ensure WASM is loaded\n const docRef = createDocumentFromJson(json);\n return new KddbDocument(docRef);\n }\n\n /**\n * Create a document from KDDB blob (SQLite binary)\n */\n static async fromBlob(blob: Blob): Promise<KddbDocument> {\n await getWasmInstance(); // Ensure WASM is loaded\n const bytes = new Uint8Array(await blob.arrayBuffer());\n const g = globalThis as any;\n // Use optimized path that loads directly into sql.js (avoids base64 round-trip)\n const docRef = g.loadDocument(bytes);\n if (docRef === 0) {\n throw new Error('Failed to load document from KDDB bytes');\n }\n return new KddbDocument(docRef);\n }\n\n /**\n * Alias for dispose() to match KddbDocument API\n */\n destroy(): void {\n this.dispose();\n }\n\n /**\n * Get the document reference (for internal use)\n */\n getDocumentRef(): number {\n this.checkDisposed();\n return this.documentRef;\n }\n\n /**\n * Convert document to JSON string\n */\n async toJson(): Promise<string> {\n this.checkDisposed();\n await getWasmInstance();\n return documentToJson(this.documentRef);\n }\n\n /**\n * Get the root content node\n */\n async getRoot(): Promise<ContentNode | null> {\n this.checkDisposed();\n await getWasmInstance();\n const resultJson = documentGetRoot(this.documentRef);\n if (!resultJson || resultJson === 'null') return null;\n const helper = await getWasmHelper();\n const parsed = typeof resultJson === 'string' ? helper.parseJsonResult(resultJson) : resultJson;\n if (!parsed) return null;\n if (typeof parsed === 'number') {\n return new ContentNode({\n nodeRef: parsed,\n id: parsed,\n type: 'root',\n content: '',\n });\n }\n return new ContentNode(parsed);\n }\n\n /**\n * Create a new node (requires extended WASM exports)\n */\n async createNode(nodeType: string): Promise<ContentNode> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.createNode !== 'function') {\n throw new Error('createNode not available in WASM module');\n }\n const resultJson = g.createNode(this.documentRef, nodeType);\n if (!resultJson || resultJson === 'null') {\n throw new Error('Failed to create node');\n }\n const helper = await getWasmHelper();\n const data = helper.parseJsonResult(resultJson);\n if (!data) {\n throw new Error('Failed to parse created node data');\n }\n return new ContentNode(data);\n }\n\n /**\n * Select nodes using a selector (requires extended WASM exports)\n */\n async select(selector: string): Promise<ContentNode[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSelect !== 'function') {\n throw new Error('documentSelect not available in WASM module');\n }\n const resultJson = g.documentSelect(this.documentRef, selector);\n const helper = await getWasmHelper();\n const results = helper.parseJsonResult(resultJson);\n\n if (!results || !Array.isArray(results)) {\n return [];\n }\n\n return ContentNode.fromDataArray(results);\n }\n\n /**\n * Select first node using a selector (requires extended WASM exports)\n */\n async selectFirst(selector: string): Promise<ContentNode | null> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSelectFirst !== 'function') {\n throw new Error('documentSelectFirst not available in WASM module');\n }\n const resultJson = g.documentSelectFirst(this.documentRef, selector);\n if (!resultJson || resultJson === 'null') return null;\n const helper = await getWasmHelper();\n const data = helper.parseJsonResult(resultJson);\n if (!data) return null;\n return new ContentNode(data);\n }\n\n // Exception management (requires extended WASM exports)\n\n /**\n * Add an exception to the document\n */\n async addException(exception: ContentException): Promise<void> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentAddException !== 'function') {\n throw new Error('documentAddException not available in WASM module');\n }\n g.documentAddException(this.documentRef, JSON.stringify(exception));\n }\n\n /**\n * Get all exceptions from the document\n */\n async getExceptions(): Promise<ContentException[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetExceptions !== 'function') {\n throw new Error('documentGetExceptions not available in WASM module');\n }\n const resultJson = g.documentGetExceptions(this.documentRef);\n const helper = await getWasmHelper();\n const exceptions = helper.parseJsonResult(resultJson);\n return Array.isArray(exceptions) ? exceptions : [];\n }\n\n // Metadata management (requires extended WASM exports)\n\n /**\n * Set a metadata value\n */\n async setMetadataValue(key: string, value: any): Promise<void> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSetMetadataValue !== 'function') {\n throw new Error('documentSetMetadataValue not available in WASM module');\n }\n g.documentSetMetadataValue(this.documentRef, key, JSON.stringify(value));\n }\n\n /**\n * Get a metadata value\n */\n async getMetadataValue(key: string): Promise<any> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetMetadataValue !== 'function') {\n throw new Error('documentGetMetadataValue not available in WASM module');\n }\n const resultJson = g.documentGetMetadataValue(this.documentRef, key);\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Set metadata from object\n */\n async setMetadata(metadata: DocumentMetadata): Promise<void> {\n for (const [key, value] of Object.entries(metadata)) {\n await this.setMetadataValue(key, value);\n }\n }\n\n /**\n * Get all metadata as object\n */\n async getMetadata(): Promise<DocumentMetadata> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetMetadata !== 'function') {\n return {};\n }\n const metadataJson = g.documentGetMetadata(this.documentRef);\n const helper = await getWasmHelper();\n return helper.parseJsonResult(metadataJson) || {};\n }\n\n /**\n * Set the actor URI for audit tracking.\n * The actor URI identifies who is making changes to the document.\n * Format: \"user://email@domain.com\" or \"module://module-id\"\n * If no actor URI is set, audit events will not include actor information.\n *\n * @param uri - The actor URI string, or null to clear\n * @returns true on success, false on failure\n */\n async setActorUri(uri: string | null): Promise<boolean> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSetActorURI !== 'function') {\n throw new Error('documentSetActorURI not available in WASM module');\n }\n const result = g.documentSetActorURI(this.documentRef, uri ?? '');\n return result === 1;\n }\n\n // ============================================================================\n // Document Cloning\n // ============================================================================\n\n /**\n * Options for cloning a document\n */\n static CloneOptions = class {\n /** Copy ContentNode tree with features, tags, bboxes (default: true) */\n includeContent?: boolean;\n /** Copy DataObjects and DataAttributes (default: true) */\n includeData?: boolean;\n };\n\n /**\n * Create a copy of this document.\n *\n * The clone always gets a new UUID and always includes metadata and native documents.\n * ContentNodes and DataObjects/DataAttributes can be optionally excluded.\n * When includeContent is false, an empty root node is created.\n *\n * @param options - Clone options\n * @returns New KddbDocument instance that is a copy of this document\n *\n * @example\n * // Full clone\n * const fullClone = await doc.clone();\n *\n * // Clone without content nodes (just metadata)\n * const metadataOnly = await doc.clone({ includeContent: false, includeData: false });\n */\n async clone(options?: {\n includeContent?: boolean;\n includeData?: boolean;\n }): Promise<KddbDocument> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.cloneDocument !== 'function') {\n throw new Error('cloneDocument not available in WASM module');\n }\n\n const opts = {\n includeContentNodes: options?.includeContent ?? true,\n includeDataObjects: options?.includeData ?? true,\n };\n\n const newRef = g.cloneDocument(this.documentRef, JSON.stringify(opts));\n if (newRef === 0) {\n throw new Error('Failed to clone document');\n }\n\n return new KddbDocument(newRef);\n }\n\n // ============================================================================\n // Document Query Methods (KddbDocument API compatibility)\n // ============================================================================\n\n /**\n * Get the number of pages in the document\n */\n async getNumPages(): Promise<number> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetNodeCountByType !== 'function') {\n throw new Error('documentGetNodeCountByType not available in WASM module');\n }\n return g.documentGetNodeCountByType(this.documentRef, 'page');\n }\n\n /**\n * Get all nodes in hierarchical order with their level, type, and content.\n */\n async getAllNodesHierarchical(): Promise<Array<{ content: string; uuid: string }>> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetAllNodesHierarchical !== 'function') {\n throw new Error('documentGetAllNodesHierarchical not available in WASM module');\n }\n const linesJson = g.documentGetAllNodesHierarchical(this.documentRef);\n const helper = await getWasmHelper();\n const lines = helper.parseJsonResult(linesJson);\n return Array.isArray(lines) ? lines : [];\n }\n\n /**\n * Get the root content node (alias for getRoot for KddbDocument compatibility)\n * Note: This is async because it needs to fetch node data from Go WASM\n */\n async getRootNode(): Promise<ContentNode | null> {\n return this.getRoot();\n }\n\n /**\n * Find a node by its ID\n */\n async findNodeByID(id: number): Promise<ContentNode | null> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetNodeByID !== 'function') {\n throw new Error('documentGetNodeByID not available in WASM module');\n }\n const resultJson = g.documentGetNodeByID(this.documentRef, id);\n if (!resultJson || resultJson === 'null') return null;\n const helper = await getWasmHelper();\n const data = helper.parseJsonResult(resultJson);\n if (!data) return null;\n return new ContentNode(data);\n }\n\n /**\n * Get node by ID\n */\n async getNodeById(nodeId: number): Promise<ContentNode | null> {\n return this.findNodeByID(nodeId);\n }\n\n /**\n * Find nodes by tag ID\n */\n async findNodesByTagID(tagID: number): Promise<ContentNode[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n\n // Use dedicated WASM function\n if (typeof g.documentFindNodesByTagID !== 'function') {\n throw new Error('documentFindNodesByTagID not available in WASM module');\n }\n const resultJson = g.documentFindNodesByTagID(this.documentRef, tagID);\n const helper = await getWasmHelper();\n const nodeDataArray = helper.parseJsonResult(resultJson);\n\n if (!Array.isArray(nodeDataArray)) return [];\n\n const matchingNodes: ContentNode[] = [];\n for (const entry of nodeDataArray) {\n // NodeData uses 'nodeRef' field (from makeNodeData)\n if (entry.nodeRef) {\n const node = await ContentNode.fromRef(entry.nodeRef);\n if (node) matchingNodes.push(node);\n }\n }\n return matchingNodes;\n }\n\n /**\n * Get all tagged nodes\n */\n async getTaggedNodes(tagPrefix: string[] = []): Promise<ContentNode[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetAllTaggedNodes !== 'function') {\n throw new Error('documentGetAllTaggedNodes not available in WASM module');\n }\n const resultJson = g.documentGetAllTaggedNodes(this.documentRef);\n const helper = await getWasmHelper();\n const nodeDataArray = helper.parseJsonResult(resultJson);\n if (!Array.isArray(nodeDataArray)) return [];\n return ContentNode.fromDataArray(nodeDataArray);\n }\n\n /**\n * Get nodes by tag IDs for given prefixes (bulk operation)\n */\n async getNodesByTagIDsForPrefixes(tagPrefixes: string[]): Promise<Map<number, { tagName: string; tagData: any; nodes: ContentNode[] }>> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n const result = new Map<number, { tagName: string; tagData: any; nodes: ContentNode[] }>();\n\n if (!tagPrefixes || tagPrefixes.length === 0) {\n return result;\n }\n\n if (typeof g.documentGetTagsByPrefix !== 'function') {\n return result;\n }\n\n for (const prefix of tagPrefixes) {\n const resultJson = g.documentGetTagsByPrefix(this.documentRef, prefix);\n const helper = await getWasmHelper();\n const tagData = helper.parseJsonResult(resultJson);\n\n if (Array.isArray(tagData)) {\n for (const entry of tagData) {\n const tagID = entry.tagId;\n if (!result.has(tagID)) {\n result.set(tagID, {\n tagName: entry.tagName,\n tagData: entry.tagData,\n nodes: []\n });\n }\n if (entry.nodeRef) {\n const node = await ContentNode.fromRef(entry.nodeRef);\n if (node) result.get(tagID)!.nodes.push(node);\n }\n }\n }\n }\n\n return result;\n }\n\n /**\n * Sort nodes spatially (by Y then X coordinate)\n */\n async getSpatiallySortedNodes(nodes: ContentNode[]): Promise<ContentNode[]> {\n // Get bboxes for all nodes\n const nodesWithBbox = await Promise.all(\n nodes.map(async (node) => ({\n node,\n bbox: await node.getBBox()\n }))\n );\n\n return nodesWithBbox\n .sort((a, b) => {\n if (!a.bbox) return 1;\n if (!b.bbox) return -1;\n // Sort by Y first, then X (with 5 pixel tolerance for same line)\n const yDiff = (a.bbox.y1 ?? 0) - (b.bbox.y1 ?? 0);\n if (Math.abs(yDiff) > 5) {\n return yDiff;\n }\n return (a.bbox.x1 ?? 0) - (b.bbox.x1 ?? 0);\n })\n .map(item => item.node);\n }\n\n /**\n * Get concatenated text from nodes\n */\n async getNodeText(nodes: ContentNode[]): Promise<string> {\n const sortedNodes = await this.getSpatiallySortedNodes(nodes);\n const texts = sortedNodes.map(node => node.content);\n return texts.join(' ');\n }\n\n // ============================================================================\n // Document Data Methods\n // ============================================================================\n\n /**\n * Get model insights from the document\n */\n async getModelInsights(): Promise<Array<{ name: string }>> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetStatistics !== 'function') {\n return [];\n }\n const statsJson = g.documentGetStatistics(this.documentRef);\n const helper = await getWasmHelper();\n const stats = helper.parseJsonResult(statsJson);\n return stats?.modelInsights || [];\n }\n\n /**\n * Get content exceptions from the document\n */\n async getContentExceptions(): Promise<ContentException[]> {\n return this.getExceptions();\n }\n\n /**\n * Get external data by key\n */\n async getExternalData(key: string = 'default'): Promise<any> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetExternalData !== 'function') {\n throw new Error('documentGetExternalData not available in WASM module');\n }\n const resultJson = g.documentGetExternalData(this.documentRef, key);\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson) || {};\n }\n\n /**\n * Set external data for a key\n */\n async setExternalData(data: any, key: string = 'default'): Promise<void> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSetExternalData !== 'function') {\n throw new Error('documentSetExternalData not available in WASM module');\n }\n g.documentSetExternalData(this.documentRef, key, JSON.stringify(data));\n }\n\n /**\n * Get all external data keys\n */\n async getExternalDataKeys(): Promise<string[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetExternalDataKeys !== 'function') {\n return [];\n }\n const keysJson = g.documentGetExternalDataKeys(this.documentRef);\n const helper = await getWasmHelper();\n const keys = helper.parseJsonResult(keysJson);\n return Array.isArray(keys) ? keys : [];\n }\n\n // ============================================================================\n // Raw Query Methods\n // ============================================================================\n\n /**\n * Execute a raw SQL query against the document's SQLite database.\n *\n * This provides direct database access for advanced queries not covered by existing APIs.\n * Results are returned as an array of objects, where each object represents a row\n * with column names as keys.\n *\n * IMPORTANT: This is intended for read-only SELECT queries. Modifying data directly\n * may bypass validation, auditing, and other document management features.\n *\n * @param sql - The SQL query to execute\n * @param params - Optional array of parameters for parameterized queries\n * @returns Array of result rows as objects\n *\n * @example\n * ```typescript\n * // Simple query\n * const nodes = await doc.executeRawQuery(\n * 'SELECT * FROM kddb_content_nodes WHERE node_type_id = ?',\n * [1]\n * );\n *\n * // Query with multiple conditions\n * const tags = await doc.executeRawQuery(\n * 'SELECT * FROM kddb_content_node_tags WHERE name LIKE ?',\n * ['%Invoice%']\n * );\n *\n * // Join query\n * const results = await doc.executeRawQuery(`\n * SELECT n.id, n.content, t.name as tag_name\n * FROM kddb_content_nodes n\n * LEFT JOIN kddb_content_node_tags t ON n.id = t.content_node_id\n * WHERE t.name IS NOT NULL\n * `);\n * ```\n */\n async executeRawQuery(sql: string, params?: any[]): Promise<Record<string, any>[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentExecuteRawQuery !== 'function') {\n throw new Error('documentExecuteRawQuery not available in WASM module');\n }\n const paramsJson = params ? JSON.stringify(params) : '[]';\n const resultJson = g.documentExecuteRawQuery(this.documentRef, sql, paramsJson);\n const helper = await getWasmHelper();\n const results = helper.parseJsonResult(resultJson);\n return Array.isArray(results) ? results : [];\n }\n\n /**\n * Get document validations\n */\n async getValidations(): Promise<any[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetValidations !== 'function') {\n return [];\n }\n const validationsJson = g.documentGetValidations(this.documentRef);\n const helper = await getWasmHelper();\n const validations = helper.parseJsonResult(validationsJson);\n return Array.isArray(validations) ? validations : [];\n }\n\n /**\n * Set document validations\n */\n async setValidations(validations: any[]): Promise<void> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSetValidations !== 'function') {\n throw new Error('documentSetValidations not available in WASM module');\n }\n g.documentSetValidations(this.documentRef, JSON.stringify(validations));\n }\n\n /**\n * Get document processing steps\n */\n async getSteps(): Promise<any[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetSteps !== 'function') {\n return [];\n }\n const stepsJson = g.documentGetSteps(this.documentRef);\n const helper = await getWasmHelper();\n const steps = helper.parseJsonResult(stepsJson);\n return Array.isArray(steps) ? steps : [];\n }\n\n /**\n * Set document processing steps\n */\n async setSteps(steps: any[]): Promise<void> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSetSteps !== 'function') {\n throw new Error('documentSetSteps not available in WASM module');\n }\n g.documentSetSteps(this.documentRef, JSON.stringify(steps));\n }\n\n /**\n * Get children of a processing step (lazy loading)\n * @param stepId - The ID of the parent step\n * @returns Array of child processing steps\n */\n async getStepChildren(stepId: number): Promise<any[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetStepChildren !== 'function') {\n return [];\n }\n const childrenJson = g.documentGetStepChildren(this.documentRef, stepId);\n const helper = await getWasmHelper();\n const children = helper.parseJsonResult(childrenJson);\n return Array.isArray(children) ? children : [];\n }\n\n /**\n * Get parents of a processing step (lazy loading)\n * @param stepId - The ID of the child step\n * @returns Array of parent processing steps\n */\n async getStepParents(stepId: number): Promise<any[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetStepParents !== 'function') {\n return [];\n }\n const parentsJson = g.documentGetStepParents(this.documentRef, stepId);\n const helper = await getWasmHelper();\n const parents = helper.parseJsonResult(parentsJson);\n return Array.isArray(parents) ? parents : [];\n }\n\n /**\n * Export document to KDDB bytes\n */\n async toBlob(): Promise<Blob> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentToKddbBytes !== 'function') {\n throw new Error('documentToKddbBytes not available in WASM module');\n }\n const bytes = g.documentToKddbBytes(this.documentRef);\n return new Blob([bytes], { type: 'octet/stream' });\n }\n\n /**\n * Get a pretty representation of a page with spatial layout preserved.\n * @param page - The page ContentNode (must be a page type node)\n * @param maxWidth - Optional max width (not currently used in Go implementation)\n * @param excludePadding - If false (default), preserves spatial layout. If true, uses single spaces.\n * @returns Pretty formatted page text\n */\n async getPrettyPage(page: ContentNode, maxWidth?: number, excludePadding: boolean = false): Promise<string> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetPrettyPage !== 'function') {\n throw new Error('documentGetPrettyPage not available in WASM module');\n }\n // Get page index from the node\n if (page.index === null) {\n return '';\n }\n return g.documentGetPrettyPage(this.documentRef, page.index, excludePadding);\n }\n\n /**\n * Get a pretty representation of all pages in the document.\n * @param maxWidth - Optional max width (not currently used in Go implementation)\n * @param excludePadding - If false (default), preserves spatial layout. If true, uses single spaces.\n * @returns Pretty formatted text for all pages with page headers\n */\n async getPrettyPages(maxWidth?: number, excludePadding: boolean = false): Promise<string> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetPrettyPages !== 'function') {\n throw new Error('documentGetPrettyPages not available in WASM module');\n }\n return g.documentGetPrettyPages(this.documentRef, excludePadding);\n }\n\n // ============================================================================\n // Delta Engine Methods\n // ============================================================================\n\n /**\n * Start tracking changes to this document.\n *\n * All modifications (ADD, MOD, DEL) to the document after this call\n * will be captured until stopDeltaTracking() or cancelDeltaTracking() is called.\n *\n * @param username - Optional username for the tracking session\n * @param comment - Optional comment describing the purpose of tracking\n * @returns The newly created delta session\n *\n * @example\n * ```typescript\n * const session = await doc.startDeltaTracking('user@example.com', 'Bulk update');\n * // ... make changes ...\n * await doc.stopDeltaTracking();\n * ```\n */\n async startDeltaTracking(username?: string, comment?: string): Promise<DeltaSession> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentStartDeltaTracking !== 'function') {\n throw new Error('documentStartDeltaTracking not available in WASM module');\n }\n const resultJson = g.documentStartDeltaTracking(this.documentRef, username, comment);\n if (!resultJson) {\n throw new Error('Failed to start delta tracking');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Stop tracking changes and complete the delta session.\n *\n * After stopping, the tracked changes can be exported using exportDelta() or exportDeltaBytes().\n *\n * @returns The completed delta session with end revision info\n */\n async stopDeltaTracking(): Promise<DeltaSession> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentStopDeltaTracking !== 'function') {\n throw new Error('documentStopDeltaTracking not available in WASM module');\n }\n const resultJson = g.documentStopDeltaTracking(this.documentRef);\n if (!resultJson) {\n throw new Error('Failed to stop delta tracking');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Cancel the current tracking session and discard all tracked changes.\n *\n * @returns true if cancellation was successful\n */\n async cancelDeltaTracking(): Promise<boolean> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentCancelDeltaTracking !== 'function') {\n throw new Error('documentCancelDeltaTracking not available in WASM module');\n }\n return g.documentCancelDeltaTracking(this.documentRef);\n }\n\n /**\n * Get the currently active delta session, if any.\n *\n * @returns The active session or null if no tracking is in progress\n */\n async getActiveDeltaSession(): Promise<DeltaSession | null> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetActiveDeltaSession !== 'function') {\n return null;\n }\n const resultJson = g.documentGetActiveDeltaSession(this.documentRef);\n if (!resultJson || resultJson === 'null') {\n return null;\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Get the current delta tracking status.\n *\n * @returns Status including whether tracking is active and session details\n */\n async getDeltaStatus(): Promise<DeltaStatus> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetDeltaStatus !== 'function') {\n return { active: false };\n }\n const resultJson = g.documentGetDeltaStatus(this.documentRef);\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson) || { active: false };\n }\n\n /**\n * List all delta sessions for this document.\n *\n * @param statusFilter - Optional filter by status ('active', 'completed', 'cancelled')\n * @returns Array of delta sessions\n */\n async listDeltaSessions(statusFilter?: string): Promise<DeltaSession[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentListDeltaSessions !== 'function') {\n return [];\n }\n const resultJson = g.documentListDeltaSessions(this.documentRef, statusFilter);\n const helper = await getWasmHelper();\n const sessions = helper.parseJsonResult(resultJson);\n return Array.isArray(sessions) ? sessions : [];\n }\n\n /**\n * Export the most recent completed delta as metadata.\n *\n * This returns delta information without the full binary data.\n * Use exportDeltaBytes() to get the full serialized delta for transfer.\n *\n * @returns Delta metadata including operation count and revision info\n */\n async exportDelta(): Promise<Delta> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentExportDelta !== 'function') {\n throw new Error('documentExportDelta not available in WASM module');\n }\n const resultJson = g.documentExportDelta(this.documentRef);\n if (!resultJson) {\n throw new Error('Failed to export delta');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Export the most recent completed delta as binary data.\n *\n * Returns the delta in KDDB binary format (magic number: 0x4B444442).\n * This can be transferred and imported to another document.\n *\n * @returns Uint8Array containing the serialized delta\n */\n async exportDeltaBytes(): Promise<Uint8Array> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentExportDeltaBytes !== 'function') {\n throw new Error('documentExportDeltaBytes not available in WASM module');\n }\n const base64 = g.documentExportDeltaBytes(this.documentRef);\n if (!base64) {\n throw new Error('Failed to export delta bytes');\n }\n // Decode base64 to Uint8Array\n const binaryString = atob(base64);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return bytes;\n }\n\n /**\n * Import a delta from binary data.\n *\n * This parses and validates the delta but does not apply it.\n * Use applyDelta() to apply the imported delta to the document.\n *\n * @param data - Uint8Array containing serialized delta (from exportDeltaBytes)\n * @returns Imported delta metadata\n */\n async importDelta(data: Uint8Array): Promise<Delta> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentImportDelta !== 'function') {\n throw new Error('documentImportDelta not available in WASM module');\n }\n // Encode to base64 for transfer\n let binary = '';\n for (let i = 0; i < data.length; i++) {\n binary += String.fromCharCode(data[i]);\n }\n const base64 = btoa(binary);\n const resultJson = g.documentImportDelta(this.documentRef, base64);\n if (!resultJson) {\n throw new Error('Failed to import delta');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Preview what applying a delta would do without actually applying it.\n *\n * Shows counts of ADD, MOD, DEL operations and any potential conflicts.\n *\n * @param data - Uint8Array containing serialized delta\n * @returns Preview with operation counts and conflict information\n */\n async previewDelta(data: Uint8Array): Promise<DeltaPreview> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentPreviewDelta !== 'function') {\n throw new Error('documentPreviewDelta not available in WASM module');\n }\n // Encode to base64\n let binary = '';\n for (let i = 0; i < data.length; i++) {\n binary += String.fromCharCode(data[i]);\n }\n const base64 = btoa(binary);\n const resultJson = g.documentPreviewDelta(this.documentRef, base64);\n if (!resultJson) {\n throw new Error('Failed to preview delta');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Apply a delta to this document.\n *\n * Imports and applies all operations from the delta to the document.\n * Can optionally create audit trail entries and handle conflicts.\n *\n * @param data - Uint8Array containing serialized delta\n * @param options - Options controlling conflict handling and audit trail\n * @returns Result with counts of applied/skipped operations and conflicts\n *\n * @example\n * ```typescript\n * // Apply with default options\n * const result = await targetDoc.applyDelta(deltaBytes);\n *\n * // Apply with audit trail\n * const result = await targetDoc.applyDelta(deltaBytes, {\n * createAuditTrail: true,\n * username: 'import-user',\n * comment: 'Imported changes from source'\n * });\n *\n * if (result.hasConflicts) {\n * console.log('Conflicts:', result.conflicts);\n * }\n * ```\n */\n async applyDelta(data: Uint8Array, options?: ApplyOptions): Promise<ApplyResult> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentApplyDelta !== 'function') {\n throw new Error('documentApplyDelta not available in WASM module');\n }\n // Encode to base64\n let binary = '';\n for (let i = 0; i < data.length; i++) {\n binary += String.fromCharCode(data[i]);\n }\n const base64 = btoa(binary);\n const optionsJson = options ? JSON.stringify(options) : undefined;\n const resultJson = g.documentApplyDelta(this.documentRef, base64, optionsJson);\n if (!resultJson) {\n throw new Error('Failed to apply delta');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n // ============================================================================\n // Document Refresh Methods\n // ============================================================================\n\n /**\n * Refresh the document by recalculating all formulas, running all validations,\n * and reconciling data exceptions.\n *\n * This performs a full document recalculation in dependency order:\n * 1. Recalculates all formulas based on the dependency graph\n * 2. Runs all validation rules\n * 3. Reconciles exceptions (creates new, closes resolved, reopens recurrent)\n *\n * @returns Result with counts of operations performed and any errors\n *\n * @example\n * ```typescript\n * // After making changes to data attributes\n * const result = await doc.refresh();\n *\n * if (!result.success) {\n * console.error('Refresh errors:', result.errors);\n * }\n *\n * console.log(`Recalculated ${result.formulasRecalculated} formulas`);\n * console.log(`Ran ${result.validationsRun} validations`);\n * console.log(`Created ${result.exceptionsCreated} new exceptions`);\n * ```\n */\n async refresh(): Promise<RefreshResult> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentRefresh !== 'function') {\n throw new Error('documentRefresh not available in WASM module');\n }\n const resultJson = g.documentRefresh(this.documentRef);\n if (!resultJson) {\n throw new Error('Failed to refresh document');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n // Resource management\n\n /**\n * Dispose of the document and free WASM resources\n */\n dispose(): void {\n if (!this.disposed && this.documentRef !== 0) {\n try {\n if (typeof freeDocument === 'function') {\n freeDocument(this.documentRef);\n }\n this.disposed = true;\n this.documentRef = 0;\n } catch (e) {\n console.warn('Error disposing KddbDocument:', e);\n }\n }\n }\n\n /**\n * Check if this document has been disposed\n */\n private checkDisposed(): void {\n if (this.disposed) {\n throw new Error('GoDocument has been disposed');\n }\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"KddbDocument.js","sourceRoot":"","sources":["../src/KddbDocument.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,EAAE,cAAc,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UAAU,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,aAAa,EAAE,CAAC;QACrC,OAAO,MAAM,CAAC,eAAe,CAAC,UAAU,CAAC,CAAC;IAC5C,CAAC;IAED,sBAAsB;IAEtB;;OAEG;IACH,OAAO;QACL,IAAI,CAAC,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,WAAW,KAAK,CAAC,EAAE,CAAC;YAC7C,IAAI,CAAC;gBACH,IAAI,OAAO,YAAY,KAAK,UAAU,EAAE,CAAC;oBACvC,YAAY,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;gBACjC,CAAC;gBACD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC;gBACrB,IAAI,CAAC,WAAW,GAAG,CAAC,CAAC;YACvB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,IAAI,CAAC,+BAA+B,EAAE,CAAC,CAAC,CAAC;YACnD,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACK,aAAa;QACnB,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;;AA13BD,+EAA+E;AAC/E,mBAAmB;AACnB,+EAA+E;AAE/E;;GAEG;AACI,yBAAY,GAAG;CAKrB,AALkB,CAKjB","sourcesContent":["/**\n * KddbDocument - TypeScript wrapper for Go WASM Document functionality\n *\n * NOTE: Go WASM with syscall/js passes strings directly between JS and Go.\n * No pointer-based memory management is needed.\n */\n\nimport { getWasmHelper, getWasmInstance } from './wasm/loader';\nimport { checkWasmError, clearWasmError, WasmError } from './wasm/error-handler';\nimport {\n ContentException,\n DocumentMetadata,\n DeltaSession,\n DeltaStatus,\n Delta,\n DeltaPreview,\n ApplyResult,\n ApplyOptions,\n RefreshResult,\n} from './wasm/types';\nimport { ContentNode } from './ContentNode';\nimport { DataObjectAccessor } from './DataObjectAccessor';\nimport { DataAttributeAccessor } from './DataAttributeAccessor';\nimport { AuditAccessor } from './AuditAccessor';\nimport { NativeDocumentAccessor } from './NativeDocumentAccessor';\nimport { NoteAccessor } from './NoteAccessor';\nimport { TaxonomyAccessor } from './TaxonomyAccessor';\nimport { TransactionContext } from './TransactionContext';\nimport type { TransactionResponse } from './worker/types';\n\nexport class KddbDocument {\n private documentRef: number;\n private disposed = false;\n private _dataObjects?: DataObjectAccessor;\n private _dataAttributes?: DataAttributeAccessor;\n private _audit?: AuditAccessor;\n private _nativeDocuments?: NativeDocumentAccessor;\n private _notes?: NoteAccessor;\n private _taxonomies?: TaxonomyAccessor;\n\n constructor(documentRef: number) {\n this.documentRef = documentRef;\n }\n\n /**\n * Access data objects in this document\n * Usage: document.dataObjects.getAll(), document.dataObjects.getByUUID(uuid), etc.\n */\n get dataObjects(): DataObjectAccessor {\n this.checkDisposed();\n if (!this._dataObjects) {\n this._dataObjects = new DataObjectAccessor(this.documentRef);\n }\n return this._dataObjects;\n }\n\n /**\n * Access data attributes in this document\n * Usage: document.dataAttributes.getAll(), document.dataAttributes.getByUUID(uuid), etc.\n */\n get dataAttributes(): DataAttributeAccessor {\n this.checkDisposed();\n if (!this._dataAttributes) {\n this._dataAttributes = new DataAttributeAccessor(this.documentRef);\n }\n return this._dataAttributes;\n }\n\n /**\n * Access audit data in this document\n * Usage: document.audit.listRevisions(), document.audit.getDataObjectHistory(id), etc.\n */\n get audit(): AuditAccessor {\n this.checkDisposed();\n if (!this._audit) {\n this._audit = new AuditAccessor(this.documentRef);\n }\n return this._audit;\n }\n\n /**\n * Access native documents in this document (embedded files like PDFs, images)\n * Usage: document.nativeDocuments.getAll(), document.nativeDocuments.getData(id), etc.\n */\n get nativeDocuments(): NativeDocumentAccessor {\n this.checkDisposed();\n if (!this._nativeDocuments) {\n this._nativeDocuments = new NativeDocumentAccessor(this.documentRef);\n }\n return this._nativeDocuments;\n }\n\n /**\n * Access notes in this document\n * Usage: document.notes.getAll(), document.notes.create({content: \"...\"}), etc.\n */\n get notes(): NoteAccessor {\n this.checkDisposed();\n if (!this._notes) {\n this._notes = new NoteAccessor(this.documentRef);\n }\n return this._notes;\n }\n\n /**\n * Access taxonomies stored in this document\n *\n * Taxonomies define the structure and types of data that can be extracted.\n * Store taxonomies to enable automatic taxon resolution when creating data attributes.\n *\n * Usage:\n * - document.taxonomies.store(taxonomy) - Store a taxonomy\n * - document.taxonomies.getByRef(ref) - Get taxonomy by reference\n * - document.taxonomies.getAll() - List all taxonomies\n * - document.taxonomies.getTaxonByPath(ref, path) - Get specific taxon\n */\n get taxonomies(): TaxonomyAccessor {\n this.checkDisposed();\n if (!this._taxonomies) {\n this._taxonomies = new TaxonomyAccessor(this.documentRef);\n }\n return this._taxonomies;\n }\n\n /**\n * Execute a set of operations atomically within a transaction.\n *\n * All operations performed through the transaction context are batched\n * and sent to the database in a single atomic operation. If any operation\n * fails or the callback throws an error, all changes are rolled back.\n *\n * @example\n * ```typescript\n * await document.transaction(async (tx) => {\n * const invoice = await tx.dataObjects.create({\n * path: '/invoice',\n * taxonomyRef: 'acme/invoice/1.0'\n * });\n *\n * await tx.dataAttributes.create(invoice.id, {\n * tag: 'amount',\n * decimalValue: 1500.00\n * });\n *\n * if (validationFailed) {\n * throw new Error('Validation failed'); // Rolls back everything\n * }\n * });\n * ```\n */\n async transaction(callback: (tx: TransactionContext) => Promise<void>): Promise<void> {\n this.checkDisposed();\n await getWasmInstance();\n\n const tx = new TransactionContext();\n\n // Execute callback to collect operations\n await callback(tx);\n\n // If no operations, nothing to do\n if (tx.operationCount === 0) {\n return;\n }\n\n // Execute transaction via WASM\n const g = globalThis as any;\n if (typeof g.executeTransaction !== 'function') {\n throw new Error('executeTransaction not available in WASM module');\n }\n\n const resultJson = g.executeTransaction(\n this.documentRef,\n JSON.stringify(tx.getOperations())\n );\n\n if (!resultJson) {\n throw new Error('executeTransaction returned no response');\n }\n\n let result: TransactionResponse;\n try {\n result = JSON.parse(resultJson);\n } catch (e) {\n throw new Error(`Failed to parse transaction response: ${e instanceof Error ? e.message : String(e)}`);\n }\n\n if (!result.success) {\n throw new Error(`Transaction failed: ${result.error ?? 'Unknown error'}`);\n }\n\n // Transaction succeeded - idMappings contains temp ID -> real ID mappings\n // (These could be used to update provisional objects if needed)\n }\n\n /**\n * Create a new empty document\n */\n static async create(): Promise<KddbDocument> {\n await getWasmInstance(); // Ensure WASM is loaded\n const docRef = createDocument();\n return new KddbDocument(docRef);\n }\n\n /**\n * Create a document from text\n */\n static async fromText(text: string): Promise<KddbDocument> {\n await getWasmInstance(); // Ensure WASM is loaded\n const docRef = createDocumentFromText(text);\n return new KddbDocument(docRef);\n }\n\n /**\n * Create a document from JSON string\n */\n static async fromJson(json: string): Promise<KddbDocument> {\n await getWasmInstance(); // Ensure WASM is loaded\n const docRef = createDocumentFromJson(json);\n return new KddbDocument(docRef);\n }\n\n /**\n * Create a document from KDDB blob (SQLite binary)\n */\n static async fromBlob(blob: Blob): Promise<KddbDocument> {\n await getWasmInstance(); // Ensure WASM is loaded\n const bytes = new Uint8Array(await blob.arrayBuffer());\n const g = globalThis as any;\n // Use optimized path that loads directly into sql.js (avoids base64 round-trip)\n const docRef = g.loadDocument(bytes);\n if (docRef === 0) {\n throw new Error('Failed to load document from KDDB bytes');\n }\n return new KddbDocument(docRef);\n }\n\n /**\n * Alias for dispose() to match KddbDocument API\n */\n destroy(): void {\n this.dispose();\n }\n\n /**\n * Get the document reference (for internal use)\n */\n getDocumentRef(): number {\n this.checkDisposed();\n return this.documentRef;\n }\n\n /**\n * Convert document to JSON string\n */\n async toJson(): Promise<string> {\n this.checkDisposed();\n await getWasmInstance();\n return documentToJson(this.documentRef);\n }\n\n /**\n * Get the root content node\n */\n async getRoot(): Promise<ContentNode | null> {\n this.checkDisposed();\n await getWasmInstance();\n const resultJson = documentGetRoot(this.documentRef);\n if (!resultJson || resultJson === 'null') return null;\n const helper = await getWasmHelper();\n const parsed = typeof resultJson === 'string' ? helper.parseJsonResult(resultJson) : resultJson;\n if (!parsed) return null;\n if (typeof parsed === 'number') {\n return new ContentNode({\n nodeRef: parsed,\n id: parsed,\n type: 'root',\n content: '',\n });\n }\n return new ContentNode(parsed);\n }\n\n /**\n * Create a new node (requires extended WASM exports)\n */\n async createNode(nodeType: string): Promise<ContentNode> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.createNode !== 'function') {\n throw new Error('createNode not available in WASM module');\n }\n const resultJson = g.createNode(this.documentRef, nodeType);\n if (!resultJson || resultJson === 'null') {\n throw new Error('Failed to create node');\n }\n const helper = await getWasmHelper();\n const data = helper.parseJsonResult(resultJson);\n if (!data) {\n throw new Error('Failed to parse created node data');\n }\n return new ContentNode(data);\n }\n\n /**\n * Select nodes using a selector (requires extended WASM exports)\n */\n async select(selector: string): Promise<ContentNode[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSelect !== 'function') {\n throw new Error('documentSelect not available in WASM module');\n }\n const resultJson = g.documentSelect(this.documentRef, selector);\n const helper = await getWasmHelper();\n const results = helper.parseJsonResult(resultJson);\n\n if (!results || !Array.isArray(results)) {\n return [];\n }\n\n return ContentNode.fromDataArray(results);\n }\n\n /**\n * Select first node using a selector (requires extended WASM exports)\n */\n async selectFirst(selector: string): Promise<ContentNode | null> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSelectFirst !== 'function') {\n throw new Error('documentSelectFirst not available in WASM module');\n }\n const resultJson = g.documentSelectFirst(this.documentRef, selector);\n if (!resultJson || resultJson === 'null') return null;\n const helper = await getWasmHelper();\n const data = helper.parseJsonResult(resultJson);\n if (!data) return null;\n return new ContentNode(data);\n }\n\n // Exception management (requires extended WASM exports)\n\n /**\n * Add an exception to the document\n */\n async addException(exception: ContentException): Promise<void> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentAddException !== 'function') {\n throw new Error('documentAddException not available in WASM module');\n }\n g.documentAddException(this.documentRef, JSON.stringify(exception));\n }\n\n /**\n * Get all exceptions from the document\n */\n async getExceptions(): Promise<ContentException[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetExceptions !== 'function') {\n throw new Error('documentGetExceptions not available in WASM module');\n }\n const resultJson = g.documentGetExceptions(this.documentRef);\n const helper = await getWasmHelper();\n const exceptions = helper.parseJsonResult(resultJson);\n return Array.isArray(exceptions) ? exceptions : [];\n }\n\n // Metadata management (requires extended WASM exports)\n\n /**\n * Set a metadata value\n */\n async setMetadataValue(key: string, value: any): Promise<void> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSetMetadataValue !== 'function') {\n throw new Error('documentSetMetadataValue not available in WASM module');\n }\n g.documentSetMetadataValue(this.documentRef, key, JSON.stringify(value));\n }\n\n /**\n * Get a metadata value\n */\n async getMetadataValue(key: string): Promise<any> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetMetadataValue !== 'function') {\n throw new Error('documentGetMetadataValue not available in WASM module');\n }\n const resultJson = g.documentGetMetadataValue(this.documentRef, key);\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Set metadata from object\n */\n async setMetadata(metadata: DocumentMetadata): Promise<void> {\n for (const [key, value] of Object.entries(metadata)) {\n await this.setMetadataValue(key, value);\n }\n }\n\n /**\n * Get all metadata as object\n */\n async getMetadata(): Promise<DocumentMetadata> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetMetadata !== 'function') {\n return {};\n }\n const metadataJson = g.documentGetMetadata(this.documentRef);\n const helper = await getWasmHelper();\n return helper.parseJsonResult(metadataJson) || {};\n }\n\n /**\n * Set the actor URI for audit tracking.\n * The actor URI identifies who is making changes to the document.\n * Format: \"user://email@domain.com\" or \"module://module-id\"\n * If no actor URI is set, audit events will not include actor information.\n *\n * @param uri - The actor URI string, or null to clear\n * @returns true on success, false on failure\n */\n async setActorUri(uri: string | null): Promise<boolean> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSetActorURI !== 'function') {\n throw new Error('documentSetActorURI not available in WASM module');\n }\n const result = g.documentSetActorURI(this.documentRef, uri ?? '');\n return result === 1;\n }\n\n // ============================================================================\n // Document Cloning\n // ============================================================================\n\n /**\n * Options for cloning a document\n */\n static CloneOptions = class {\n /** Copy ContentNode tree with features, tags, bboxes (default: true) */\n includeContent?: boolean;\n /** Copy DataObjects and DataAttributes (default: true) */\n includeData?: boolean;\n };\n\n /**\n * Create a copy of this document.\n *\n * The clone always gets a new UUID and always includes metadata and native documents.\n * ContentNodes and DataObjects/DataAttributes can be optionally excluded.\n * When includeContent is false, an empty root node is created.\n *\n * @param options - Clone options\n * @returns New KddbDocument instance that is a copy of this document\n *\n * @example\n * // Full clone\n * const fullClone = await doc.clone();\n *\n * // Clone without content nodes (just metadata)\n * const metadataOnly = await doc.clone({ includeContent: false, includeData: false });\n */\n async clone(options?: {\n includeContent?: boolean;\n includeData?: boolean;\n }): Promise<KddbDocument> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.cloneDocument !== 'function') {\n throw new Error('cloneDocument not available in WASM module');\n }\n\n const opts = {\n includeContentNodes: options?.includeContent ?? true,\n includeDataObjects: options?.includeData ?? true,\n };\n\n const newRef = g.cloneDocument(this.documentRef, JSON.stringify(opts));\n if (newRef === 0) {\n throw new Error('Failed to clone document');\n }\n\n return new KddbDocument(newRef);\n }\n\n // ============================================================================\n // Document Query Methods (KddbDocument API compatibility)\n // ============================================================================\n\n /**\n * Get the number of pages in the document\n */\n async getNumPages(): Promise<number> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetNodeCountByType !== 'function') {\n throw new Error('documentGetNodeCountByType not available in WASM module');\n }\n return g.documentGetNodeCountByType(this.documentRef, 'page');\n }\n\n /**\n * Get all nodes in hierarchical order with their level, type, and content.\n */\n async getAllNodesHierarchical(): Promise<Array<{ content: string; uuid: string }>> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetAllNodesHierarchical !== 'function') {\n throw new Error('documentGetAllNodesHierarchical not available in WASM module');\n }\n const linesJson = g.documentGetAllNodesHierarchical(this.documentRef);\n const helper = await getWasmHelper();\n const lines = helper.parseJsonResult(linesJson);\n return Array.isArray(lines) ? lines : [];\n }\n\n /**\n * Get the root content node (alias for getRoot for KddbDocument compatibility)\n * Note: This is async because it needs to fetch node data from Go WASM\n */\n async getRootNode(): Promise<ContentNode | null> {\n return this.getRoot();\n }\n\n /**\n * Find a node by its ID\n */\n async findNodeByID(id: number): Promise<ContentNode | null> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetNodeByID !== 'function') {\n throw new Error('documentGetNodeByID not available in WASM module');\n }\n const resultJson = g.documentGetNodeByID(this.documentRef, id);\n if (!resultJson || resultJson === 'null') return null;\n const helper = await getWasmHelper();\n const data = helper.parseJsonResult(resultJson);\n if (!data) return null;\n return new ContentNode(data);\n }\n\n /**\n * Get node by ID\n */\n async getNodeById(nodeId: number): Promise<ContentNode | null> {\n return this.findNodeByID(nodeId);\n }\n\n /**\n * Find nodes by tag ID\n */\n async findNodesByTagID(tagID: number): Promise<ContentNode[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n\n // Use dedicated WASM function\n if (typeof g.documentFindNodesByTagID !== 'function') {\n throw new Error('documentFindNodesByTagID not available in WASM module');\n }\n const resultJson = g.documentFindNodesByTagID(this.documentRef, tagID);\n const helper = await getWasmHelper();\n const nodeDataArray = helper.parseJsonResult(resultJson);\n\n if (!Array.isArray(nodeDataArray)) return [];\n\n const matchingNodes: ContentNode[] = [];\n for (const entry of nodeDataArray) {\n // NodeData uses 'nodeRef' field (from makeNodeData)\n if (entry.nodeRef) {\n const node = await ContentNode.fromRef(entry.nodeRef);\n if (node) matchingNodes.push(node);\n }\n }\n return matchingNodes;\n }\n\n /**\n * Get all tagged nodes\n */\n async getTaggedNodes(tagPrefix: string[] = []): Promise<ContentNode[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetAllTaggedNodes !== 'function') {\n throw new Error('documentGetAllTaggedNodes not available in WASM module');\n }\n const resultJson = g.documentGetAllTaggedNodes(this.documentRef);\n const helper = await getWasmHelper();\n const nodeDataArray = helper.parseJsonResult(resultJson);\n if (!Array.isArray(nodeDataArray)) return [];\n return ContentNode.fromDataArray(nodeDataArray);\n }\n\n /**\n * Get nodes by tag IDs for given prefixes (bulk operation)\n */\n async getNodesByTagIDsForPrefixes(tagPrefixes: string[]): Promise<Map<number, { tagName: string; tagData: any; nodes: ContentNode[] }>> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n const result = new Map<number, { tagName: string; tagData: any; nodes: ContentNode[] }>();\n\n if (!tagPrefixes || tagPrefixes.length === 0) {\n return result;\n }\n\n if (typeof g.documentGetTagsByPrefix !== 'function') {\n return result;\n }\n\n for (const prefix of tagPrefixes) {\n const resultJson = g.documentGetTagsByPrefix(this.documentRef, prefix);\n const helper = await getWasmHelper();\n const tagData = helper.parseJsonResult(resultJson);\n\n if (Array.isArray(tagData)) {\n for (const entry of tagData) {\n const tagID = entry.tagId;\n if (!result.has(tagID)) {\n result.set(tagID, {\n tagName: entry.tagName,\n tagData: entry.tagData,\n nodes: []\n });\n }\n if (entry.nodeRef) {\n const node = await ContentNode.fromRef(entry.nodeRef);\n if (node) result.get(tagID)!.nodes.push(node);\n }\n }\n }\n }\n\n return result;\n }\n\n /**\n * Sort nodes spatially (by Y then X coordinate)\n */\n async getSpatiallySortedNodes(nodes: ContentNode[]): Promise<ContentNode[]> {\n // Get bboxes for all nodes\n const nodesWithBbox = await Promise.all(\n nodes.map(async (node) => ({\n node,\n bbox: await node.getBBox()\n }))\n );\n\n return nodesWithBbox\n .sort((a, b) => {\n if (!a.bbox) return 1;\n if (!b.bbox) return -1;\n // Sort by Y first, then X (with 5 pixel tolerance for same line)\n const yDiff = (a.bbox.y1 ?? 0) - (b.bbox.y1 ?? 0);\n if (Math.abs(yDiff) > 5) {\n return yDiff;\n }\n return (a.bbox.x1 ?? 0) - (b.bbox.x1 ?? 0);\n })\n .map(item => item.node);\n }\n\n /**\n * Get concatenated text from nodes\n */\n async getNodeText(nodes: ContentNode[]): Promise<string> {\n const sortedNodes = await this.getSpatiallySortedNodes(nodes);\n const texts = sortedNodes.map(node => node.content);\n return texts.join(' ');\n }\n\n // ============================================================================\n // Document Data Methods\n // ============================================================================\n\n /**\n * Get model insights from the document\n */\n async getModelInsights(): Promise<Array<{ name: string }>> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetStatistics !== 'function') {\n return [];\n }\n const statsJson = g.documentGetStatistics(this.documentRef);\n const helper = await getWasmHelper();\n const stats = helper.parseJsonResult(statsJson);\n return stats?.modelInsights || [];\n }\n\n /**\n * Get content exceptions from the document\n */\n async getContentExceptions(): Promise<ContentException[]> {\n return this.getExceptions();\n }\n\n /**\n * Get external data by key\n */\n async getExternalData(key: string = 'default'): Promise<any> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetExternalData !== 'function') {\n throw new Error('documentGetExternalData not available in WASM module');\n }\n const resultJson = g.documentGetExternalData(this.documentRef, key);\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson) || {};\n }\n\n /**\n * Set external data for a key\n */\n async setExternalData(data: any, key: string = 'default'): Promise<void> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSetExternalData !== 'function') {\n throw new Error('documentSetExternalData not available in WASM module');\n }\n g.documentSetExternalData(this.documentRef, key, JSON.stringify(data));\n }\n\n /**\n * Get all external data keys\n */\n async getExternalDataKeys(): Promise<string[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetExternalDataKeys !== 'function') {\n return [];\n }\n const keysJson = g.documentGetExternalDataKeys(this.documentRef);\n const helper = await getWasmHelper();\n const keys = helper.parseJsonResult(keysJson);\n return Array.isArray(keys) ? keys : [];\n }\n\n // ============================================================================\n // Raw Query Methods\n // ============================================================================\n\n /**\n * Execute a raw SQL query against the document's SQLite database.\n *\n * This provides direct database access for advanced queries not covered by existing APIs.\n * Results are returned as an array of objects, where each object represents a row\n * with column names as keys.\n *\n * IMPORTANT: This is intended for read-only SELECT queries. Modifying data directly\n * may bypass validation, auditing, and other document management features.\n *\n * @param sql - The SQL query to execute\n * @param params - Optional array of parameters for parameterized queries\n * @returns Array of result rows as objects\n *\n * @example\n * ```typescript\n * // Simple query\n * const nodes = await doc.executeRawQuery(\n * 'SELECT * FROM kddb_content_nodes WHERE node_type_id = ?',\n * [1]\n * );\n *\n * // Query with multiple conditions\n * const tags = await doc.executeRawQuery(\n * 'SELECT * FROM kddb_content_node_tags WHERE name LIKE ?',\n * ['%Invoice%']\n * );\n *\n * // Join query\n * const results = await doc.executeRawQuery(`\n * SELECT n.id, n.content, t.name as tag_name\n * FROM kddb_content_nodes n\n * LEFT JOIN kddb_content_node_tags t ON n.id = t.content_node_id\n * WHERE t.name IS NOT NULL\n * `);\n * ```\n */\n async executeRawQuery(sql: string, params?: any[]): Promise<Record<string, any>[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentExecuteRawQuery !== 'function') {\n throw new Error('documentExecuteRawQuery not available in WASM module');\n }\n const paramsJson = params ? JSON.stringify(params) : '[]';\n await clearWasmError(); // Clear any stale errors from previous calls\n const resultJson = g.documentExecuteRawQuery(this.documentRef, sql, paramsJson);\n\n // Check for error encoded in return value (more reliable than setLastError in WASM)\n if (typeof resultJson === 'string' && resultJson.startsWith('{\"error\":')) {\n try {\n const errObj = JSON.parse(resultJson);\n if (errObj.error) {\n throw new WasmError(errObj.error);\n }\n } catch (e) {\n if (e instanceof WasmError) throw e;\n // If JSON parse fails, fall through to checkWasmError\n }\n }\n\n await checkWasmError(); // Keep as fallback\n const helper = await getWasmHelper();\n const results = helper.parseJsonResult(resultJson);\n return Array.isArray(results) ? results : [];\n }\n\n /**\n * Get document validations\n */\n async getValidations(): Promise<any[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetValidations !== 'function') {\n return [];\n }\n const validationsJson = g.documentGetValidations(this.documentRef);\n const helper = await getWasmHelper();\n const validations = helper.parseJsonResult(validationsJson);\n return Array.isArray(validations) ? validations : [];\n }\n\n /**\n * Set document validations\n */\n async setValidations(validations: any[]): Promise<void> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSetValidations !== 'function') {\n throw new Error('documentSetValidations not available in WASM module');\n }\n g.documentSetValidations(this.documentRef, JSON.stringify(validations));\n }\n\n /**\n * Get document processing steps\n */\n async getSteps(): Promise<any[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetSteps !== 'function') {\n return [];\n }\n const stepsJson = g.documentGetSteps(this.documentRef);\n const helper = await getWasmHelper();\n const steps = helper.parseJsonResult(stepsJson);\n return Array.isArray(steps) ? steps : [];\n }\n\n /**\n * Set document processing steps\n */\n async setSteps(steps: any[]): Promise<void> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentSetSteps !== 'function') {\n throw new Error('documentSetSteps not available in WASM module');\n }\n g.documentSetSteps(this.documentRef, JSON.stringify(steps));\n }\n\n /**\n * Get children of a processing step (lazy loading)\n * @param stepId - The ID of the parent step\n * @returns Array of child processing steps\n */\n async getStepChildren(stepId: number): Promise<any[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetStepChildren !== 'function') {\n return [];\n }\n const childrenJson = g.documentGetStepChildren(this.documentRef, stepId);\n const helper = await getWasmHelper();\n const children = helper.parseJsonResult(childrenJson);\n return Array.isArray(children) ? children : [];\n }\n\n /**\n * Get parents of a processing step (lazy loading)\n * @param stepId - The ID of the child step\n * @returns Array of parent processing steps\n */\n async getStepParents(stepId: number): Promise<any[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetStepParents !== 'function') {\n return [];\n }\n const parentsJson = g.documentGetStepParents(this.documentRef, stepId);\n const helper = await getWasmHelper();\n const parents = helper.parseJsonResult(parentsJson);\n return Array.isArray(parents) ? parents : [];\n }\n\n /**\n * Export document to KDDB bytes\n */\n async toBlob(): Promise<Blob> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentToKddbBytes !== 'function') {\n throw new Error('documentToKddbBytes not available in WASM module');\n }\n const bytes = g.documentToKddbBytes(this.documentRef);\n return new Blob([bytes], { type: 'octet/stream' });\n }\n\n /**\n * Get a pretty representation of a page with spatial layout preserved.\n * @param page - The page ContentNode (must be a page type node)\n * @param maxWidth - Optional max width (not currently used in Go implementation)\n * @param excludePadding - If false (default), preserves spatial layout. If true, uses single spaces.\n * @returns Pretty formatted page text\n */\n async getPrettyPage(page: ContentNode, maxWidth?: number, excludePadding: boolean = false): Promise<string> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetPrettyPage !== 'function') {\n throw new Error('documentGetPrettyPage not available in WASM module');\n }\n // Get page index from the node\n if (page.index === null) {\n return '';\n }\n return g.documentGetPrettyPage(this.documentRef, page.index, excludePadding);\n }\n\n /**\n * Get a pretty representation of all pages in the document.\n * @param maxWidth - Optional max width (not currently used in Go implementation)\n * @param excludePadding - If false (default), preserves spatial layout. If true, uses single spaces.\n * @returns Pretty formatted text for all pages with page headers\n */\n async getPrettyPages(maxWidth?: number, excludePadding: boolean = false): Promise<string> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetPrettyPages !== 'function') {\n throw new Error('documentGetPrettyPages not available in WASM module');\n }\n return g.documentGetPrettyPages(this.documentRef, excludePadding);\n }\n\n // ============================================================================\n // Delta Engine Methods\n // ============================================================================\n\n /**\n * Start tracking changes to this document.\n *\n * All modifications (ADD, MOD, DEL) to the document after this call\n * will be captured until stopDeltaTracking() or cancelDeltaTracking() is called.\n *\n * @param username - Optional username for the tracking session\n * @param comment - Optional comment describing the purpose of tracking\n * @returns The newly created delta session\n *\n * @example\n * ```typescript\n * const session = await doc.startDeltaTracking('user@example.com', 'Bulk update');\n * // ... make changes ...\n * await doc.stopDeltaTracking();\n * ```\n */\n async startDeltaTracking(username?: string, comment?: string): Promise<DeltaSession> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentStartDeltaTracking !== 'function') {\n throw new Error('documentStartDeltaTracking not available in WASM module');\n }\n const resultJson = g.documentStartDeltaTracking(this.documentRef, username, comment);\n if (!resultJson) {\n throw new Error('Failed to start delta tracking');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Stop tracking changes and complete the delta session.\n *\n * After stopping, the tracked changes can be exported using exportDelta() or exportDeltaBytes().\n *\n * @returns The completed delta session with end revision info\n */\n async stopDeltaTracking(): Promise<DeltaSession> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentStopDeltaTracking !== 'function') {\n throw new Error('documentStopDeltaTracking not available in WASM module');\n }\n const resultJson = g.documentStopDeltaTracking(this.documentRef);\n if (!resultJson) {\n throw new Error('Failed to stop delta tracking');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Cancel the current tracking session and discard all tracked changes.\n *\n * @returns true if cancellation was successful\n */\n async cancelDeltaTracking(): Promise<boolean> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentCancelDeltaTracking !== 'function') {\n throw new Error('documentCancelDeltaTracking not available in WASM module');\n }\n return g.documentCancelDeltaTracking(this.documentRef);\n }\n\n /**\n * Get the currently active delta session, if any.\n *\n * @returns The active session or null if no tracking is in progress\n */\n async getActiveDeltaSession(): Promise<DeltaSession | null> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetActiveDeltaSession !== 'function') {\n return null;\n }\n const resultJson = g.documentGetActiveDeltaSession(this.documentRef);\n if (!resultJson || resultJson === 'null') {\n return null;\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Get the current delta tracking status.\n *\n * @returns Status including whether tracking is active and session details\n */\n async getDeltaStatus(): Promise<DeltaStatus> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentGetDeltaStatus !== 'function') {\n return { active: false };\n }\n const resultJson = g.documentGetDeltaStatus(this.documentRef);\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson) || { active: false };\n }\n\n /**\n * List all delta sessions for this document.\n *\n * @param statusFilter - Optional filter by status ('active', 'completed', 'cancelled')\n * @returns Array of delta sessions\n */\n async listDeltaSessions(statusFilter?: string): Promise<DeltaSession[]> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentListDeltaSessions !== 'function') {\n return [];\n }\n const resultJson = g.documentListDeltaSessions(this.documentRef, statusFilter);\n const helper = await getWasmHelper();\n const sessions = helper.parseJsonResult(resultJson);\n return Array.isArray(sessions) ? sessions : [];\n }\n\n /**\n * Export the most recent completed delta as metadata.\n *\n * This returns delta information without the full binary data.\n * Use exportDeltaBytes() to get the full serialized delta for transfer.\n *\n * @returns Delta metadata including operation count and revision info\n */\n async exportDelta(): Promise<Delta> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentExportDelta !== 'function') {\n throw new Error('documentExportDelta not available in WASM module');\n }\n const resultJson = g.documentExportDelta(this.documentRef);\n if (!resultJson) {\n throw new Error('Failed to export delta');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Export the most recent completed delta as binary data.\n *\n * Returns the delta in KDDB binary format (magic number: 0x4B444442).\n * This can be transferred and imported to another document.\n *\n * @returns Uint8Array containing the serialized delta\n */\n async exportDeltaBytes(): Promise<Uint8Array> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentExportDeltaBytes !== 'function') {\n throw new Error('documentExportDeltaBytes not available in WASM module');\n }\n const base64 = g.documentExportDeltaBytes(this.documentRef);\n if (!base64) {\n throw new Error('Failed to export delta bytes');\n }\n // Decode base64 to Uint8Array\n const binaryString = atob(base64);\n const bytes = new Uint8Array(binaryString.length);\n for (let i = 0; i < binaryString.length; i++) {\n bytes[i] = binaryString.charCodeAt(i);\n }\n return bytes;\n }\n\n /**\n * Import a delta from binary data.\n *\n * This parses and validates the delta but does not apply it.\n * Use applyDelta() to apply the imported delta to the document.\n *\n * @param data - Uint8Array containing serialized delta (from exportDeltaBytes)\n * @returns Imported delta metadata\n */\n async importDelta(data: Uint8Array): Promise<Delta> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentImportDelta !== 'function') {\n throw new Error('documentImportDelta not available in WASM module');\n }\n // Encode to base64 for transfer\n let binary = '';\n for (let i = 0; i < data.length; i++) {\n binary += String.fromCharCode(data[i]);\n }\n const base64 = btoa(binary);\n const resultJson = g.documentImportDelta(this.documentRef, base64);\n if (!resultJson) {\n throw new Error('Failed to import delta');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Preview what applying a delta would do without actually applying it.\n *\n * Shows counts of ADD, MOD, DEL operations and any potential conflicts.\n *\n * @param data - Uint8Array containing serialized delta\n * @returns Preview with operation counts and conflict information\n */\n async previewDelta(data: Uint8Array): Promise<DeltaPreview> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentPreviewDelta !== 'function') {\n throw new Error('documentPreviewDelta not available in WASM module');\n }\n // Encode to base64\n let binary = '';\n for (let i = 0; i < data.length; i++) {\n binary += String.fromCharCode(data[i]);\n }\n const base64 = btoa(binary);\n const resultJson = g.documentPreviewDelta(this.documentRef, base64);\n if (!resultJson) {\n throw new Error('Failed to preview delta');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n /**\n * Apply a delta to this document.\n *\n * Imports and applies all operations from the delta to the document.\n * Can optionally create audit trail entries and handle conflicts.\n *\n * @param data - Uint8Array containing serialized delta\n * @param options - Options controlling conflict handling and audit trail\n * @returns Result with counts of applied/skipped operations and conflicts\n *\n * @example\n * ```typescript\n * // Apply with default options\n * const result = await targetDoc.applyDelta(deltaBytes);\n *\n * // Apply with audit trail\n * const result = await targetDoc.applyDelta(deltaBytes, {\n * createAuditTrail: true,\n * username: 'import-user',\n * comment: 'Imported changes from source'\n * });\n *\n * if (result.hasConflicts) {\n * console.log('Conflicts:', result.conflicts);\n * }\n * ```\n */\n async applyDelta(data: Uint8Array, options?: ApplyOptions): Promise<ApplyResult> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentApplyDelta !== 'function') {\n throw new Error('documentApplyDelta not available in WASM module');\n }\n // Encode to base64\n let binary = '';\n for (let i = 0; i < data.length; i++) {\n binary += String.fromCharCode(data[i]);\n }\n const base64 = btoa(binary);\n const optionsJson = options ? JSON.stringify(options) : undefined;\n const resultJson = g.documentApplyDelta(this.documentRef, base64, optionsJson);\n if (!resultJson) {\n throw new Error('Failed to apply delta');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n // ============================================================================\n // Document Refresh Methods\n // ============================================================================\n\n /**\n * Refresh the document by recalculating all formulas, running all validations,\n * and reconciling data exceptions.\n *\n * This performs a full document recalculation in dependency order:\n * 1. Recalculates all formulas based on the dependency graph\n * 2. Runs all validation rules\n * 3. Reconciles exceptions (creates new, closes resolved, reopens recurrent)\n *\n * @returns Result with counts of operations performed and any errors\n *\n * @example\n * ```typescript\n * // After making changes to data attributes\n * const result = await doc.refresh();\n *\n * if (!result.success) {\n * console.error('Refresh errors:', result.errors);\n * }\n *\n * console.log(`Recalculated ${result.formulasRecalculated} formulas`);\n * console.log(`Ran ${result.validationsRun} validations`);\n * console.log(`Created ${result.exceptionsCreated} new exceptions`);\n * ```\n */\n async refresh(): Promise<RefreshResult> {\n this.checkDisposed();\n await getWasmInstance();\n const g = globalThis as any;\n if (typeof g.documentRefresh !== 'function') {\n throw new Error('documentRefresh not available in WASM module');\n }\n const resultJson = g.documentRefresh(this.documentRef);\n if (!resultJson) {\n throw new Error('Failed to refresh document');\n }\n const helper = await getWasmHelper();\n return helper.parseJsonResult(resultJson);\n }\n\n // Resource management\n\n /**\n * Dispose of the document and free WASM resources\n */\n dispose(): void {\n if (!this.disposed && this.documentRef !== 0) {\n try {\n if (typeof freeDocument === 'function') {\n freeDocument(this.documentRef);\n }\n this.disposed = true;\n this.documentRef = 0;\n } catch (e) {\n console.warn('Error disposing KddbDocument:', e);\n }\n }\n }\n\n /**\n * Check if this document has been disposed\n */\n private checkDisposed(): void {\n if (this.disposed) {\n throw new Error('GoDocument has been disposed');\n }\n }\n}\n"]}
|
|
@@ -104,7 +104,7 @@ function queryOp(handle, sql, paramsJson) {
|
|
|
104
104
|
} catch (err) {
|
|
105
105
|
error = String(err);
|
|
106
106
|
console.error("[sql.js] Query failed:", sql, err);
|
|
107
|
-
|
|
107
|
+
throw err;
|
|
108
108
|
} finally {
|
|
109
109
|
perfTracer.recordQuery(sql, paramsJson, startTime, performance.now(), rowCount, error);
|
|
110
110
|
}
|