@happyvertical/smrt-core 0.60.9 → 0.60.10

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 (67) hide show
  1. package/agents/browser-entry.md +10 -0
  2. package/agents/change-feed.md +33 -0
  3. package/agents/object-runtime.md +8 -0
  4. package/agents/schema-paths.md +6 -0
  5. package/dist/browser.d.ts +2 -1
  6. package/dist/browser.d.ts.map +1 -1
  7. package/dist/browser.js +3 -2
  8. package/dist/cascade.d.ts +17 -3
  9. package/dist/cascade.d.ts.map +1 -1
  10. package/dist/cascade.js +30 -15
  11. package/dist/cascade.js.map +1 -1
  12. package/dist/collection.d.ts.map +1 -1
  13. package/dist/collection.js +8 -4
  14. package/dist/collection.js.map +1 -1
  15. package/dist/embedded-write-queue.d.ts +18 -7
  16. package/dist/embedded-write-queue.d.ts.map +1 -1
  17. package/dist/embedded-write-queue.js +40 -10
  18. package/dist/embedded-write-queue.js.map +1 -1
  19. package/dist/index.d.ts +2 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js +3 -2
  22. package/dist/manifest/static-manifest.d.ts.map +1 -1
  23. package/dist/manifest/static-manifest.js +25 -7
  24. package/dist/manifest/static-manifest.js.map +1 -1
  25. package/dist/manifest/store.js +1 -1
  26. package/dist/manifest/store.js.map +1 -1
  27. package/dist/manifest.json +39 -7
  28. package/dist/migrations/differ.d.ts +4 -0
  29. package/dist/migrations/differ.d.ts.map +1 -1
  30. package/dist/migrations/differ.js +25 -9
  31. package/dist/migrations/differ.js.map +1 -1
  32. package/dist/migrations/orchestrate.d.ts +1 -1
  33. package/dist/migrations/orchestrate.d.ts.map +1 -1
  34. package/dist/migrations/orchestrate.js +5 -14
  35. package/dist/migrations/orchestrate.js.map +1 -1
  36. package/dist/native-duckdb.d.ts.map +1 -1
  37. package/dist/native-duckdb.js +5 -1
  38. package/dist/native-duckdb.js.map +1 -1
  39. package/dist/object.d.ts +26 -0
  40. package/dist/object.d.ts.map +1 -1
  41. package/dist/object.js +215 -55
  42. package/dist/object.js.map +1 -1
  43. package/dist/schema/generator.d.ts.map +1 -1
  44. package/dist/schema/generator.js +8 -4
  45. package/dist/schema/generator.js.map +1 -1
  46. package/dist/scripts/browser-entry-evaluation.mjs +63 -8
  47. package/dist/scripts/browser-unbundled-dev.mjs +5 -2
  48. package/dist/scripts/fixtures/browser-pglite-cascade.ts +107 -0
  49. package/dist/scripts/fixtures/pglite-peer/package.json +9 -0
  50. package/dist/scripts/fixtures/pglite-peer/peer.js +1 -0
  51. package/dist/scripts/fixtures/pglite-peer/pnpm-lock.yaml +22 -0
  52. package/dist/scripts/fixtures/pglite-peer/pnpm-workspace.yaml +1 -0
  53. package/dist/smrt-knowledge.json +19 -11
  54. package/dist/smrt-knowledge.okf.md +181 -0
  55. package/dist/sync-device.d.ts +6 -0
  56. package/dist/sync-device.d.ts.map +1 -0
  57. package/dist/sync-device.js +18 -0
  58. package/dist/sync-device.js.map +1 -0
  59. package/dist/sync-tombstones.d.ts +30 -0
  60. package/dist/sync-tombstones.d.ts.map +1 -0
  61. package/dist/sync-tombstones.js +112 -0
  62. package/dist/sync-tombstones.js.map +1 -0
  63. package/dist/system/schema.d.ts +5 -1
  64. package/dist/system/schema.d.ts.map +1 -1
  65. package/dist/system/schema.js +21 -4
  66. package/dist/system/schema.js.map +1 -1
  67. package/package.json +11 -11
@@ -1,24 +1,35 @@
1
1
  import type { DatabaseInterface } from '@happyvertical/sql';
2
2
  /** Whether this exact handle belongs to a currently active framework transaction. */
3
3
  export declare function isFrameworkTransactionHandle(db: DatabaseInterface): boolean;
4
+ /**
5
+ * Pass the exact bound handle of a transaction the caller already opened.
6
+ * Never pass a root executor. Embedded guarded writes can reuse this scope.
7
+ * The caller owns commit and rollback.
8
+ */
9
+ export declare function withCallerOwnedDatabaseTransaction<T>(db: DatabaseInterface, operation: () => Promise<T>): Promise<T>;
10
+ export declare function isKnownDatabaseTransaction(db: DatabaseInterface): boolean;
4
11
  interface QueueableDatabase {
5
12
  url?: string;
13
+ client?: unknown;
6
14
  }
7
15
  /**
8
- * Whether `db` is an embedded engine (SQLite/DuckDB/JSON — anything that is
16
+ * Whether `db` is an embedded engine (SQLite/DuckDB/JSON/PGlite — anything that is
9
17
  * not PostgreSQL). Handles without a URL are treated as embedded: serializing
10
18
  * them is at worst a throughput cost, while not serializing an embedded
11
19
  * handle reintroduces the livelock.
12
20
  */
13
21
  export declare function isEmbeddedDatabase(db: QueueableDatabase): boolean;
22
+ /** Whether `db` connects to a PostgreSQL server. */
23
+ export declare function isPostgresDatabase(db: QueueableDatabase): boolean;
14
24
  /**
15
- * Whether `db` is a PostgreSQL handle.
16
- *
17
- * The revision compare-and-swap predicate is dialect-specific (#2620): only
18
- * PostgreSQL needs the millisecond-truncating, timezone-tolerant guard, and
19
- * only PostgreSQL can evaluate `date_trunc`.
25
+ * Whether raw SQL should use PostgreSQL syntax. The SDK's PGlite root
26
+ * exposes the PGlite client, while its bound handles expose a wrapper with
27
+ * same `query` and `exec` pair, which the SQLite, DuckDB and JSON adapters
28
+ * do not expose together. The URL is just a data directory on both
29
+ * PGlite handles. PGlite remains embedded for concurrency and revision
30
+ * fallback decisions.
20
31
  */
21
- export declare function isPostgresDatabase(db: QueueableDatabase): boolean;
32
+ export declare function usesPostgresDialect(db: QueueableDatabase): boolean;
22
33
  /**
23
34
  * Whether revision compare-and-swap needs the process-local read/upsert path.
24
35
  *
@@ -1 +1 @@
1
- {"version":3,"file":"embedded-write-queue.d.ts","sourceRoot":"","sources":["../src/embedded-write-queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AA+C5D,qFAAqF;AACrF,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAE3E;AAED,UAAU,iBAAiB;IACzB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EAAE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EAAE,iBAAiB,GAAG,OAAO,CAEjE;AAED,oDAAoD;AACpD,wBAAgB,kBAAkB,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAEjE;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAMlE;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAAC,EAAE,EAAE,iBAAiB,GAAG,OAAO,CAO3E;AA0BD;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,CAAC,EAC5C,EAAE,EAAE,iBAAiB,EACrB,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAC1B,OAAO,CAAC,CAAC,CAAC,CA6BZ;AAED;;;;;GAKG;AACH,wBAAsB,4BAA4B,CAAC,CAAC,EAClD,EAAE,EAAE,iBAAiB,EACrB,SAAS,EAAE,OAAO,EAClB,SAAS,EAAE,CAAC,WAAW,EAAE,iBAAiB,KAAK,OAAO,CAAC,CAAC,CAAC,EACzD,sBAAsB,UAAQ,GAC7B,OAAO,CAAC,CAAC,CAAC,CA2CZ"}
@@ -1,5 +1,6 @@
1
1
  import { NestedTransactionError } from "./host.js";
2
2
  import { noteNativeDuckDbHandle } from "./native-duckdb.js";
3
+ import { inheritDatabaseSyncDeviceId } from "./sync-device.js";
3
4
  import { createAsyncContext } from "./utils/async-context.js";
4
5
  //#region src/embedded-write-queue.ts
5
6
  /**
@@ -39,14 +40,34 @@ import { createAsyncContext } from "./utils/async-context.js";
39
40
  /** Queue tail per database identity (URL string, or the handle itself). */
40
41
  var urlQueues = /* @__PURE__ */ new Map();
41
42
  var handleQueues = /* @__PURE__ */ new WeakMap();
43
+ var remoteLibSqlHandles = /* @__PURE__ */ new WeakSet();
42
44
  var activeQueueKeys = createAsyncContext();
43
45
  var frameworkTransactions = createAsyncContext();
44
46
  /** Whether this exact handle belongs to a currently active framework transaction. */
45
47
  function isFrameworkTransactionHandle(db) {
46
48
  return frameworkTransactions.getStore()?.has(db) === true;
47
49
  }
50
+ var callerTransactions = /* @__PURE__ */ new WeakMap();
48
51
  /**
49
- * Whether `db` is an embedded engine (SQLite/DuckDB/JSON — anything that is
52
+ * Pass the exact bound handle of a transaction the caller already opened.
53
+ * Never pass a root executor. Embedded guarded writes can reuse this scope.
54
+ * The caller owns commit and rollback.
55
+ */
56
+ async function withCallerOwnedDatabaseTransaction(db, operation) {
57
+ callerTransactions.set(db, (callerTransactions.get(db) ?? 0) + 1);
58
+ try {
59
+ return await operation();
60
+ } finally {
61
+ const remaining = (callerTransactions.get(db) ?? 1) - 1;
62
+ if (remaining) callerTransactions.set(db, remaining);
63
+ else callerTransactions.delete(db);
64
+ }
65
+ }
66
+ function isKnownDatabaseTransaction(db) {
67
+ return isFrameworkTransactionHandle(db) || callerTransactions.has(db);
68
+ }
69
+ /**
70
+ * Whether `db` is an embedded engine (SQLite/DuckDB/JSON/PGlite — anything that is
50
71
  * not PostgreSQL). Handles without a URL are treated as embedded: serializing
51
72
  * them is at worst a throughput cost, while not serializing an embedded
52
73
  * handle reintroduces the livelock.
@@ -54,17 +75,24 @@ function isFrameworkTransactionHandle(db) {
54
75
  function isEmbeddedDatabase(db) {
55
76
  return !isPostgresDatabase(db);
56
77
  }
57
- /**
58
- * Whether `db` is a PostgreSQL handle.
59
- *
60
- * The revision compare-and-swap predicate is dialect-specific (#2620): only
61
- * PostgreSQL needs the millisecond-truncating, timezone-tolerant guard, and
62
- * only PostgreSQL can evaluate `date_trunc`.
63
- */
78
+ /** Whether `db` connects to a PostgreSQL server. */
64
79
  function isPostgresDatabase(db) {
65
80
  return /^postgres(?:ql)?:/iu.test(db?.url ?? "");
66
81
  }
67
82
  /**
83
+ * Whether raw SQL should use PostgreSQL syntax. The SDK's PGlite root
84
+ * exposes the PGlite client, while its bound handles expose a wrapper with
85
+ * same `query` and `exec` pair, which the SQLite, DuckDB and JSON adapters
86
+ * do not expose together. The URL is just a data directory on both
87
+ * PGlite handles. PGlite remains embedded for concurrency and revision
88
+ * fallback decisions.
89
+ */
90
+ function usesPostgresDialect(db) {
91
+ if (isPostgresDatabase(db)) return true;
92
+ const client = db?.client;
93
+ return typeof client?.query === "function" && typeof client.exec === "function";
94
+ }
95
+ /**
68
96
  * Whether revision compare-and-swap needs the process-local read/upsert path.
69
97
  *
70
98
  * DuckDB/JSON cannot express the timestamp predicate through the generic
@@ -74,7 +102,7 @@ function isPostgresDatabase(db) {
74
102
  */
75
103
  function usesEmbeddedRevisionFallback(db) {
76
104
  const url = db?.url ?? "";
77
- return isEmbeddedDatabase(db) && !/^(?:https?|libsql):\/\//iu.test(url);
105
+ return isEmbeddedDatabase(db) && !remoteLibSqlHandles.has(db) && !/^(?:https?|libsql):\/\//iu.test(url);
78
106
  }
79
107
  /**
80
108
  * Whether `url` identifies a SQLite/DuckDB in-memory database that is
@@ -134,6 +162,8 @@ async function withEmbeddedWriteTransaction(db, serialize, operation, reuseUnsup
134
162
  try {
135
163
  return await transaction((bound) => {
136
164
  entered = true;
165
+ inheritDatabaseSyncDeviceId(db, bound);
166
+ if (isEmbeddedDatabase(db) && !usesEmbeddedRevisionFallback(db)) remoteLibSqlHandles.add(bound);
137
167
  return frameworkTransactions.run(/* @__PURE__ */ new Set([...frameworkTransactions.getStore() ?? [], bound]), () => {
138
168
  if (!serialize) return operation(bound);
139
169
  const active = activeQueueKeys.getStore();
@@ -147,6 +177,6 @@ async function withEmbeddedWriteTransaction(db, serialize, operation, reuseUnsup
147
177
  });
148
178
  }
149
179
  //#endregion
150
- export { isEmbeddedDatabase, isFrameworkTransactionHandle, isPostgresDatabase, usesEmbeddedRevisionFallback, withEmbeddedWriteQueue, withEmbeddedWriteTransaction };
180
+ export { isEmbeddedDatabase, isFrameworkTransactionHandle, isKnownDatabaseTransaction, isPostgresDatabase, usesEmbeddedRevisionFallback, usesPostgresDialect, withCallerOwnedDatabaseTransaction, withEmbeddedWriteQueue, withEmbeddedWriteTransaction };
151
181
 
152
182
  //# sourceMappingURL=embedded-write-queue.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"embedded-write-queue.js","names":[],"sources":["../src/embedded-write-queue.ts"],"sourcesContent":["import type { DatabaseInterface } from '@happyvertical/sql';\nimport { NestedTransactionError } from './host.js';\nimport { noteNativeDuckDbHandle } from './native-duckdb.js';\nimport { createAsyncContext } from './utils/async-context.js';\n\n/**\n * In-process write serialization for embedded database engines (#2360).\n *\n * File-backed SQLite (libsql) allows one writer at a time and the SDK opens a\n * NEW connection for every null-aware upsert attempt (`transaction(\"write\")`),\n * with no busy timeout on either connection. Any other write on the root\n * connection while such a transaction is open — most commonly the change-feed\n * append that follows every model save — collides as `SQLITE_BUSY`, and under\n * sustained concurrency (a `Promise.all` of creates) the two sides livelock\n * through every retry tier. Before the tenant-led conflict target (#2360) the\n * null-aware path was rare (custom conflict keys with NULL values, #1246);\n * with `tenant_id` leading every tenant-scoped default key, EVERY NULL-tenant\n * (global) create takes it, so the collision became the steady state.\n *\n * The queue makes the process a single writer per embedded database for:\n *\n * - a `save()` whose upsert conflict values contain NULL (the only shape the\n * SDK routes through a second-connection transaction), and\n * - the change-feed append (a root-connection write that follows every save).\n * - every model save and delete, so the embedded revision-CAS compare/upsert\n * fallback cannot race an ordinary save, natural-key create, or delete.\n * - a complete root `SmrtObject.withTransaction()` callback, with writes on\n * its bound handle re-entering the same hold instead of self-deadlocking.\n *\n * Ordinary save/delete holds contain database calls only — never an\n * interceptor or hook. Explicit transaction callbacks are caller-controlled,\n * so their bound model writes re-enter the existing hold. PostgreSQL is never\n * serialized here:\n * its null-aware upsert already arbitrates through advisory locks\n * server-side, and cross-process writers exist that an in-process queue could\n * not order anyway (which is also why this queue is a mitigation for embedded\n * engines' in-process writers, not a cross-process guarantee — embedded\n * engines have no cross-process writers in supported deployments).\n */\n\n/** Queue tail per database identity (URL string, or the handle itself). */\nconst urlQueues = new Map<string, Promise<unknown>>();\nconst handleQueues = new WeakMap<object, Promise<unknown>>();\nconst activeQueueKeys = createAsyncContext<ReadonlySet<string | object>>();\nconst frameworkTransactions =\n createAsyncContext<ReadonlySet<DatabaseInterface>>();\n\n/** Whether this exact handle belongs to a currently active framework transaction. */\nexport function isFrameworkTransactionHandle(db: DatabaseInterface): boolean {\n return frameworkTransactions.getStore()?.has(db) === true;\n}\n\ninterface QueueableDatabase {\n url?: string;\n}\n\n/**\n * Whether `db` is an embedded engine (SQLite/DuckDB/JSON — anything that is\n * not PostgreSQL). Handles without a URL are treated as embedded: serializing\n * them is at worst a throughput cost, while not serializing an embedded\n * handle reintroduces the livelock.\n */\nexport function isEmbeddedDatabase(db: QueueableDatabase): boolean {\n return !isPostgresDatabase(db);\n}\n\n/**\n * Whether `db` is a PostgreSQL handle.\n *\n * The revision compare-and-swap predicate is dialect-specific (#2620): only\n * PostgreSQL needs the millisecond-truncating, timezone-tolerant guard, and\n * only PostgreSQL can evaluate `date_trunc`.\n */\nexport function isPostgresDatabase(db: QueueableDatabase): boolean {\n return /^postgres(?:ql)?:/iu.test(db?.url ?? '');\n}\n\n/**\n * Whether revision compare-and-swap needs the process-local read/upsert path.\n *\n * DuckDB/JSON cannot express the timestamp predicate through the generic\n * update API, and local SQLite has only the process's writers in supported\n * deployments. Remote LibSQL/Turso is different: other processes may write\n * the same database, so it must use one conditional UPDATE at the server.\n */\nexport function usesEmbeddedRevisionFallback(db: QueueableDatabase): boolean {\n const url = db?.url ?? '';\n return isEmbeddedDatabase(db) && !/^(?:https?|libsql):\\/\\//iu.test(url);\n}\n\n/**\n * Whether `url` identifies a SQLite/DuckDB in-memory database that is\n * private to its own connection, as opposed to shared state.\n *\n * Bare `:memory:` and `file::memory:` (no query string) each mint a fresh,\n * connection-private database -- `resolveDuckDBUrl(':memory:')` returns it\n * unchanged, with no per-instance suffix -- so two independent handles that\n * both happen to carry this literal string are NOT the same database and\n * must not share a write-queue identity (#2707). A `cache=shared` query\n * parameter (e.g. `file::memory:?cache=shared`) is the opposite case: it is\n * SQLite's own mechanism for making an in-memory database genuinely shared\n * across connections in the process, so a URL carrying it must keep the\n * ordinary string-keyed (shared) behavior.\n */\nfunction isPerConnectionMemoryUrl(url: string): boolean {\n if (url.includes('cache=shared')) return false;\n return url === ':memory:' || url === 'file::memory:';\n}\n\nfunction queueKey(db: QueueableDatabase): string | object {\n if (typeof db?.url !== 'string' || db.url.length === 0) return db;\n return isPerConnectionMemoryUrl(db.url) ? db : db.url;\n}\n\n/**\n * Run `operation` after every previously queued write on the same database\n * has settled. When `serialize` is false the operation runs immediately.\n */\nexport async function withEmbeddedWriteQueue<T>(\n db: QueueableDatabase,\n serialize: boolean,\n operation: () => Promise<T>,\n): Promise<T> {\n // Re-entry into a held queue is recognized through async-local state. A host\n // without it (a browser) cannot tell a nested write from an independent one,\n // and queueing the nested write behind its own parent would deadlock, so it\n // runs unqueued there; its only database is PGlite, which serializes\n // statements itself.\n if (!serialize || !activeQueueKeys.propagatesAcrossAwait) return operation();\n\n const key = queueKey(db);\n const active = activeQueueKeys.getStore();\n if (active?.has(key)) return operation();\n const previous =\n (typeof key === 'string' ? urlQueues.get(key) : handleQueues.get(key)) ??\n Promise.resolve();\n const run = () =>\n activeQueueKeys.run(new Set([...(active ?? []), key]), operation);\n const next = previous.then(run, run);\n // The stored tail must never reject, or one failed write would poison the\n // queue for every later writer.\n const tail = next.catch(() => undefined);\n if (typeof key === 'string') {\n urlQueues.set(key, tail);\n void tail.finally(() => {\n if (urlQueues.get(key) === tail) urlQueues.delete(key);\n });\n } else {\n handleQueues.set(key, tail);\n }\n return next;\n}\n\n/**\n * Serialize a complete embedded root transaction with ordinary model writes.\n * The transaction handle is registered as a reentrant alias so saves and\n * change-feed appends inside the callback do not queue behind their own root\n * transaction.\n */\nexport async function withEmbeddedWriteTransaction<T>(\n db: DatabaseInterface,\n serialize: boolean,\n operation: (transaction: DatabaseInterface) => Promise<T>,\n reuseUnsupportedNested = false,\n): Promise<T> {\n const transaction = db.transaction?.bind(db);\n if (!transaction) {\n throw new Error('Database transaction support is required');\n }\n // The transaction handle carries no adapter markers: identify the root.\n noteNativeDuckDbHandle(db);\n return withEmbeddedWriteQueue(db, serialize, async () => {\n let entered = false;\n try {\n return await transaction((bound) => {\n entered = true;\n return frameworkTransactions.run(\n new Set([...(frameworkTransactions.getStore() ?? []), bound]),\n () => {\n if (!serialize) return operation(bound);\n const active = activeQueueKeys.getStore();\n return activeQueueKeys.run(\n new Set([...(active ?? []), queueKey(bound)]),\n () => operation(bound),\n );\n },\n );\n });\n } catch (error) {\n // The SDK explicitly refuses no-savepoint nesting before invoking the\n // callback or touching the enclosing transaction. A helper that needs\n // the caller's atomic scope can use that existing handle directly. Never\n // replay work when the callback ran, even if it threw the same error.\n if (\n reuseUnsupportedNested &&\n !entered &&\n error instanceof NestedTransactionError\n ) {\n return operation(db);\n }\n throw error;\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyCA,IAAM,4BAAY,IAAI,IAA8B;AACpD,IAAM,+BAAe,IAAI,QAAkC;AAC3D,IAAM,kBAAkB,mBAAiD;AACzE,IAAM,wBACJ,mBAAmD;;AAGrD,SAAgB,6BAA6B,IAAgC;CAC3E,OAAO,sBAAsB,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM;AACvD;;;;;;;AAYA,SAAgB,mBAAmB,IAAgC;CACjE,OAAO,CAAC,mBAAmB,EAAE;AAC/B;;;;;;;;AASA,SAAgB,mBAAmB,IAAgC;CACjE,OAAO,sBAAsB,KAAK,IAAI,OAAO,EAAE;AACjD;;;;;;;;;AAUA,SAAgB,6BAA6B,IAAgC;CAC3E,MAAM,MAAM,IAAI,OAAO;CACvB,OAAO,mBAAmB,EAAE,KAAK,CAAC,4BAA4B,KAAK,GAAG;AACxE;;;;;;;;;;;;;;;AAgBA,SAAS,yBAAyB,KAAsB;CACtD,IAAI,IAAI,SAAS,cAAc,GAAG,OAAO;CACzC,OAAO,QAAQ,cAAc,QAAQ;AACvC;AAEA,SAAS,SAAS,IAAwC;C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AO,UAAU,KAAK;KACtC,MAAM,SAAS,gBAAgB,SAAS;KACxC,OAAO,gBAAgB,oBACrB,IAAI,IAAI,CAAC,GAAI,UAAU,CAAC,GAAI,SAAS,KAAK,CAAC,CAAC,SACtC,UAAU,KAAK,CACvB;IACF,CACF;GACF,CAAC;EACH,SAAS,OAAO;GAKd,IACE,0BACA,CAAC,WACD,iBAAiB,wBAEjB,OAAO,UAAU,EAAE;GAErB,MAAM;EACR;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"embedded-write-queue.js","names":[],"sources":["../src/embedded-write-queue.ts"],"sourcesContent":["import type { DatabaseInterface } from '@happyvertical/sql';\nimport { NestedTransactionError } from './host.js';\nimport { noteNativeDuckDbHandle } from './native-duckdb.js';\nimport { inheritDatabaseSyncDeviceId } from './sync-device.js';\nimport { createAsyncContext } from './utils/async-context.js';\n\n/**\n * In-process write serialization for embedded database engines (#2360).\n *\n * File-backed SQLite (libsql) allows one writer at a time and the SDK opens a\n * NEW connection for every null-aware upsert attempt (`transaction(\"write\")`),\n * with no busy timeout on either connection. Any other write on the root\n * connection while such a transaction is open — most commonly the change-feed\n * append that follows every model save — collides as `SQLITE_BUSY`, and under\n * sustained concurrency (a `Promise.all` of creates) the two sides livelock\n * through every retry tier. Before the tenant-led conflict target (#2360) the\n * null-aware path was rare (custom conflict keys with NULL values, #1246);\n * with `tenant_id` leading every tenant-scoped default key, EVERY NULL-tenant\n * (global) create takes it, so the collision became the steady state.\n *\n * The queue makes the process a single writer per embedded database for:\n *\n * - a `save()` whose upsert conflict values contain NULL (the only shape the\n * SDK routes through a second-connection transaction), and\n * - the change-feed append (a root-connection write that follows every save).\n * - every model save and delete, so the embedded revision-CAS compare/upsert\n * fallback cannot race an ordinary save, natural-key create, or delete.\n * - a complete root `SmrtObject.withTransaction()` callback, with writes on\n * its bound handle re-entering the same hold instead of self-deadlocking.\n *\n * Ordinary save/delete holds contain database calls only — never an\n * interceptor or hook. Explicit transaction callbacks are caller-controlled,\n * so their bound model writes re-enter the existing hold. PostgreSQL is never\n * serialized here:\n * its null-aware upsert already arbitrates through advisory locks\n * server-side, and cross-process writers exist that an in-process queue could\n * not order anyway (which is also why this queue is a mitigation for embedded\n * engines' in-process writers, not a cross-process guarantee — embedded\n * engines have no cross-process writers in supported deployments).\n */\n\n/** Queue tail per database identity (URL string, or the handle itself). */\nconst urlQueues = new Map<string, Promise<unknown>>();\nconst handleQueues = new WeakMap<object, Promise<unknown>>();\nconst remoteLibSqlHandles = new WeakSet<object>();\nconst activeQueueKeys = createAsyncContext<ReadonlySet<string | object>>();\nconst frameworkTransactions =\n createAsyncContext<ReadonlySet<DatabaseInterface>>();\n\n/** Whether this exact handle belongs to a currently active framework transaction. */\nexport function isFrameworkTransactionHandle(db: DatabaseInterface): boolean {\n return frameworkTransactions.getStore()?.has(db) === true;\n}\n\nconst callerTransactions = new WeakMap<DatabaseInterface, number>();\n\n/**\n * Pass the exact bound handle of a transaction the caller already opened.\n * Never pass a root executor. Embedded guarded writes can reuse this scope.\n * The caller owns commit and rollback.\n */\nexport async function withCallerOwnedDatabaseTransaction<T>(\n db: DatabaseInterface,\n operation: () => Promise<T>,\n): Promise<T> {\n // The exact handle is bound to the caller's transaction, independent of\n // which promise uses it. Count overlapping scopes and release on rejection.\n callerTransactions.set(db, (callerTransactions.get(db) ?? 0) + 1);\n try {\n return await operation();\n } finally {\n const remaining = (callerTransactions.get(db) ?? 1) - 1;\n if (remaining) callerTransactions.set(db, remaining);\n else callerTransactions.delete(db);\n }\n}\n\nexport function isKnownDatabaseTransaction(db: DatabaseInterface): boolean {\n return isFrameworkTransactionHandle(db) || callerTransactions.has(db);\n}\n\ninterface QueueableDatabase {\n url?: string;\n client?: unknown;\n}\n\n/**\n * Whether `db` is an embedded engine (SQLite/DuckDB/JSON/PGlite — anything that is\n * not PostgreSQL). Handles without a URL are treated as embedded: serializing\n * them is at worst a throughput cost, while not serializing an embedded\n * handle reintroduces the livelock.\n */\nexport function isEmbeddedDatabase(db: QueueableDatabase): boolean {\n return !isPostgresDatabase(db);\n}\n\n/** Whether `db` connects to a PostgreSQL server. */\nexport function isPostgresDatabase(db: QueueableDatabase): boolean {\n return /^postgres(?:ql)?:/iu.test(db?.url ?? '');\n}\n\n/**\n * Whether raw SQL should use PostgreSQL syntax. The SDK's PGlite root\n * exposes the PGlite client, while its bound handles expose a wrapper with\n * same `query` and `exec` pair, which the SQLite, DuckDB and JSON adapters\n * do not expose together. The URL is just a data directory on both\n * PGlite handles. PGlite remains embedded for concurrency and revision\n * fallback decisions.\n */\nexport function usesPostgresDialect(db: QueueableDatabase): boolean {\n if (isPostgresDatabase(db)) return true;\n const client = db?.client as { query?: unknown; exec?: unknown } | undefined;\n return (\n typeof client?.query === 'function' && typeof client.exec === 'function'\n );\n}\n\n/**\n * Whether revision compare-and-swap needs the process-local read/upsert path.\n *\n * DuckDB/JSON cannot express the timestamp predicate through the generic\n * update API, and local SQLite has only the process's writers in supported\n * deployments. Remote LibSQL/Turso is different: other processes may write\n * the same database, so it must use one conditional UPDATE at the server.\n */\nexport function usesEmbeddedRevisionFallback(db: QueueableDatabase): boolean {\n const url = db?.url ?? '';\n return (\n isEmbeddedDatabase(db) &&\n !remoteLibSqlHandles.has(db) &&\n !/^(?:https?|libsql):\\/\\//iu.test(url)\n );\n}\n\n/**\n * Whether `url` identifies a SQLite/DuckDB in-memory database that is\n * private to its own connection, as opposed to shared state.\n *\n * Bare `:memory:` and `file::memory:` (no query string) each mint a fresh,\n * connection-private database -- `resolveDuckDBUrl(':memory:')` returns it\n * unchanged, with no per-instance suffix -- so two independent handles that\n * both happen to carry this literal string are NOT the same database and\n * must not share a write-queue identity (#2707). A `cache=shared` query\n * parameter (e.g. `file::memory:?cache=shared`) is the opposite case: it is\n * SQLite's own mechanism for making an in-memory database genuinely shared\n * across connections in the process, so a URL carrying it must keep the\n * ordinary string-keyed (shared) behavior.\n */\nfunction isPerConnectionMemoryUrl(url: string): boolean {\n if (url.includes('cache=shared')) return false;\n return url === ':memory:' || url === 'file::memory:';\n}\n\nfunction queueKey(db: QueueableDatabase): string | object {\n if (typeof db?.url !== 'string' || db.url.length === 0) return db;\n return isPerConnectionMemoryUrl(db.url) ? db : db.url;\n}\n\n/**\n * Run `operation` after every previously queued write on the same database\n * has settled. When `serialize` is false the operation runs immediately.\n */\nexport async function withEmbeddedWriteQueue<T>(\n db: QueueableDatabase,\n serialize: boolean,\n operation: () => Promise<T>,\n): Promise<T> {\n // Re-entry into a held queue is recognized through async-local state. A host\n // without it (a browser) cannot tell a nested write from an independent one,\n // and queueing the nested write behind its own parent would deadlock, so it\n // runs unqueued there; its only database is PGlite, which serializes\n // statements itself.\n if (!serialize || !activeQueueKeys.propagatesAcrossAwait) return operation();\n\n const key = queueKey(db);\n const active = activeQueueKeys.getStore();\n if (active?.has(key)) return operation();\n const previous =\n (typeof key === 'string' ? urlQueues.get(key) : handleQueues.get(key)) ??\n Promise.resolve();\n const run = () =>\n activeQueueKeys.run(new Set([...(active ?? []), key]), operation);\n const next = previous.then(run, run);\n // The stored tail must never reject, or one failed write would poison the\n // queue for every later writer.\n const tail = next.catch(() => undefined);\n if (typeof key === 'string') {\n urlQueues.set(key, tail);\n void tail.finally(() => {\n if (urlQueues.get(key) === tail) urlQueues.delete(key);\n });\n } else {\n handleQueues.set(key, tail);\n }\n return next;\n}\n\n/**\n * Serialize a complete embedded root transaction with ordinary model writes.\n * The transaction handle is registered as a reentrant alias so saves and\n * change-feed appends inside the callback do not queue behind their own root\n * transaction.\n */\nexport async function withEmbeddedWriteTransaction<T>(\n db: DatabaseInterface,\n serialize: boolean,\n operation: (transaction: DatabaseInterface) => Promise<T>,\n reuseUnsupportedNested = false,\n): Promise<T> {\n const transaction = db.transaction?.bind(db);\n if (!transaction) {\n throw new Error('Database transaction support is required');\n }\n // The transaction handle carries no adapter markers: identify the root.\n noteNativeDuckDbHandle(db);\n return withEmbeddedWriteQueue(db, serialize, async () => {\n let entered = false;\n try {\n return await transaction((bound) => {\n entered = true;\n inheritDatabaseSyncDeviceId(db, bound);\n if (isEmbeddedDatabase(db) && !usesEmbeddedRevisionFallback(db)) {\n remoteLibSqlHandles.add(bound);\n }\n return frameworkTransactions.run(\n new Set([...(frameworkTransactions.getStore() ?? []), bound]),\n () => {\n if (!serialize) return operation(bound);\n const active = activeQueueKeys.getStore();\n return activeQueueKeys.run(\n new Set([...(active ?? []), queueKey(bound)]),\n () => operation(bound),\n );\n },\n );\n });\n } catch (error) {\n // The SDK explicitly refuses no-savepoint nesting before invoking the\n // callback or touching the enclosing transaction. A helper that needs\n // the caller's atomic scope can use that existing handle directly. Never\n // replay work when the callback ran, even if it threw the same error.\n if (\n reuseUnsupportedNested &&\n !entered &&\n error instanceof NestedTransactionError\n ) {\n return operation(db);\n }\n throw error;\n }\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0CA,IAAM,4BAAY,IAAI,IAA8B;AACpD,IAAM,+BAAe,IAAI,QAAkC;AAC3D,IAAM,sCAAsB,IAAI,QAAgB;AAChD,IAAM,kBAAkB,mBAAiD;AACzE,IAAM,wBACJ,mBAAmD;;AAGrD,SAAgB,6BAA6B,IAAgC;CAC3E,OAAO,sBAAsB,SAAS,CAAC,EAAE,IAAI,EAAE,MAAM;AACvD;AAEA,IAAM,qCAAqB,IAAI,QAAmC;;;;;;AAOlE,eAAsB,mCACpB,IACA,WACY;CAGZ,mBAAmB,IAAI,KAAK,mBAAmB,IAAI,EAAE,KAAK,KAAK,CAAC;CAChE,IAAI;EACF,OAAO,MAAM,UAAU;CACzB,UAAU;EACR,MAAM,aAAa,mBAAmB,IAAI,EAAE,KAAK,KAAK;EACtD,IAAI,WAAW,mBAAmB,IAAI,IAAI,SAAS;OAC9C,mBAAmB,OAAO,EAAE;CACnC;AACF;AAEA,SAAgB,2BAA2B,IAAgC;CACzE,OAAO,6BAA6B,EAAE,KAAK,mBAAmB,IAAI,EAAE;AACtE;;;;;;;AAaA,SAAgB,mBAAmB,IAAg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IAAI,OAAO,QAAQ,UAAU;EAC3B,UAAU,IAAI,KAAK,IAAI;EACvB,KAAU,cAAc;GACtB,IAAI,UAAU,IAAI,GAAG,MAAM,MAAM,UAAU,OAAO,GAAG;EACvD,CAAC;CACH,OACE,aAAa,IAAI,KAAK,IAAI;CAE5B,OAAO;AACT;;;;;;;AAQA,eAAsB,6BACpB,IACA,WACA,WACA,yBAAyB,OACb;CACZ,MAAM,cAAc,GAAG,aAAa,KAAK,EAAE;CAC3C,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,0CAA0C;CAG5D,uBAAuB,EAAE;CACzB,OAAO,uBAAuB,IAAI,WAAW,YAAY;EACvD,IAAI,UAAU;EACd,IAAI;GACF,OAAO,MAAM,aAAa,UAAU;IAClC,UAAU;IACV,4BAA4B,IAAI,KAAK;IACrC,IAAI,mBAAmB,EAAE,KAAK,CAAC,6BAA6B,EAAE,GAC5D,oBAAoB,IAAI,KAAK;IAE/B,OAAO,sBAAsB,oBAC3B,IAAI,IAAI,CAAC,GAAI,sBAAsB,SAAS,KAAK,CAAC,GAAI,KAAK,CAAC,SACtD;KACJ,IAAI,CAAC,WAAW,OAAO,UAAU,KAAK;KACtC,MAAM,SAAS,gBAAgB,SAAS;KACxC,OAAO,gBAAgB,oBACrB,IAAI,IAAI,CAAC,GAAI,UAAU,CAAC,GAAI,SAAS,KAAK,CAAC,CAAC,SACtC,UAAU,KAAK,CACvB;IACF,CACF;GACF,CAAC;EACH,SAAS,OAAO;GAKd,IACE,0BACA,CAAC,WACD,iBAAiB,wBAEjB,OAAO,UAAU,EAAE;GAErB,MAAM;EACR;CACF,CAAC;AACH"}
package/dist/index.d.ts CHANGED
@@ -39,7 +39,7 @@ export { executeDecision } from "./decisions.js";
39
39
  export { applyPendingDecoratorRegistrations, type CompatibleMethodDecorator, type CompatibleMethodDecoratorContext, type CompatiblePropertyDecorator, type CompatiblePropertyDecoratorContext, type LegacyPropertyDecoratorTarget, registerCompatibleFieldDecorator, registerCompatibleMethodDecorator, } from "./decorators/compatibility.js";
40
40
  export { type CrossPackageRefOptions, crossPackageRef, type FieldOptions, type FieldUIHints, field, foreignKey, type Meta, type MethodOptions, manyToMany, meta, method, type NumericFieldOptions, oneToMany, type RelationshipFieldOptions, type TextFieldOptions, } from "./decorators/index.js";
41
41
  export * from "./dispatch/index.js";
42
- export { isEmbeddedDatabase, isPostgresDatabase, usesEmbeddedRevisionFallback, withEmbeddedWriteQueue, withEmbeddedWriteTransaction, } from "./embedded-write-queue.js";
42
+ export { isEmbeddedDatabase, isPostgresDatabase, usesEmbeddedRevisionFallback, withCallerOwnedDatabaseTransaction, withEmbeddedWriteQueue, withEmbeddedWriteTransaction, } from "./embedded-write-queue.js";
43
43
  export * from "./embeddings/index.js";
44
44
  export * from "./errors.js";
45
45
  export * from './external-agent-usage.js';
@@ -82,6 +82,7 @@ export { getSystemTableShapes, SYSTEM_TABLE_NAMES, type SystemTableShape, } from
82
82
  export type { SchemaDefinition } from "./schema/types.js";
83
83
  export * from "./signals/index.js";
84
84
  export * from "./sync/apply.js";
85
+ export { setDatabaseSyncDeviceId } from './sync-device.js';
85
86
  export * from "./system/index.js";
86
87
  export type { DiscoveryStrategy, ForgetOptions, ForgetScopeOptions, NoteMetadata, NoteOptions, RecallAllOptions, RecallOptions, SystemTableConfig, } from "./system/types.js";
87
88
  export { resetVerifiedTables } from "./table-cache.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,cAAc,qBAAkB,CAAC;AACjC,cAAc,YAAY,CAAC;AAC3B,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EACL,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,2BAA2B,EAChC,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,mBAAmB,EACnB,iBAAiB,EACjB,KAAK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,aAAa,EACb,iBAAiB,GAClB,MAAM,mBAAgB,CAAC;AAExB,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAe,CAAC;AAEpD,OAAO,EACL,eAAe,EACf,KAAK,mBAAmB,GACzB,MAAM,uBAAoB,CAAC;AAE5B,cAAc,kBAAe,CAAC;AAE9B,cAAc,kBAAkB,CAAC;AAGjC,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,kBAAe,CAAC;AAG/D,OAAO,EACL,0BAA0B,EAC1B,iBAAiB,EACjB,wBAAwB,GACzB,MAAM,yBAAsB,CAAC;AAE9B,OAAO,EACL,KAAK,EACL,cAAc,EACd,OAAO,EACP,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,EACL,KAAK,MAAM,EACX,KAAK,cAAc,EACnB,SAAS,EACT,aAAa,EACb,SAAS,GACV,MAAM,iBAAc,CAAC;AAGtB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAgB,CAAC;AAE7C,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,YAAY,EACZ,2BAA2B,EAC3B,aAAa,EACb,eAAe,EACf,mBAAmB,EACnB,MAAM,EACN,KAAK,mBAAmB,EACxB,kBAAkB,EAClB,mBAAmB,GACpB,MAAM,4BAAyB,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,wBAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -4,7 +4,8 @@ import { MetricsAdapter } from "./adapters/metrics.js";
4
4
  import { PubSubAdapter } from "./adapters/pubsub.js";
5
5
  import "./adapters/index.js";
6
6
  import { classifyDatabaseError, classifyDialectMessage, isAbortedTransactionError, isDeterministicDatabaseError, isNotNullViolationError, isTransientConnectionError, isTransientDatabaseError, isUniqueViolationError } from "./db-errors.js";
7
- import { isEmbeddedDatabase, isPostgresDatabase, usesEmbeddedRevisionFallback, withEmbeddedWriteQueue, withEmbeddedWriteTransaction } from "./embedded-write-queue.js";
7
+ import { setDatabaseSyncDeviceId } from "./sync-device.js";
8
+ import { isEmbeddedDatabase, isPostgresDatabase, usesEmbeddedRevisionFallback, withCallerOwnedDatabaseTransaction, withEmbeddedWriteQueue, withEmbeddedWriteTransaction } from "./embedded-write-queue.js";
8
9
  import { SmrtError } from "./smrt-error.js";
9
10
  import { isSensitiveConnectionParam, redactDatabaseUrl, redactDatabaseUrlsInText } from "./utils/database-url.js";
10
11
  import { AIError, ConfigurationError, DatabaseError, ErrorUtils, FilesystemError, NetworkError, RunOnceClaimError, RuntimeError, TenantIsolationError, ValidationError, ValidationReport, ValidationUtils } from "./errors.js";
@@ -117,4 +118,4 @@ import "./system/index.js";
117
118
  import { getTestDatabase } from "./testing/database.js";
118
119
  import "./tools/index.js";
119
120
  import { smrtPlugin } from "./vite-plugin/index.js";
120
- export { AGENT_SURFACE_HASH_PREFIX, AIError, APIGenerator, AiUsageCollector, AiUsagePersistenceHandler, BOOTED_PROVENANCE, CACHE_INVALIDATION_CHANNEL, CHANGE_FEED_CREDENTIAL_TABLES, CHANGE_FEED_INTERCEPTOR_NAME, CHANGE_FEED_TABLE, CHANGE_SIGNAL_CHANNEL, CRUD_OPERATIONS, ConfigurationError, ContentHasher, CosineSimilarity, DEFAULT_AI_COST_RATES, DEFAULT_CHANGES_LIMIT, DEFAULT_DATA_QUERY_PAGE_LIMIT, DEFAULT_DATA_QUERY_RESULT_BYTES, DEFAULT_DISPLAY_LABEL_FIELDS, DEFAULT_EMBEDDING_CONFIG, DEFAULT_EVENTS_HEARTBEAT_MS, DEFAULT_EVENTS_MAX_SUBSCRIBERS, DEFAULT_EVENTS_RETRY_AFTER_SECONDS, DEFAULT_FACET_LIMIT, DEFAULT_LEARNING_CONFIG, DEFAULT_LIST_LIMIT, DEFAULT_LIST_ORDER_BY, DEFAULT_POSTGRES_TIMEOUTS, DEFAULT_RETENTION_POLICY, DIAGNOSTICS_DEFAULT_LIMIT, DataQueryValidationError, DatabaseError, Dispatch, DispatchBus, DispatchCollection, DispatchSubscription, DispatchSubscriptionCollection, EXTERNAL_AGENT_COUNTERS, EXTERNAL_AGENT_USAGE_OPERATION, EmbeddingProvider, EmbeddingStorage, EmbeddingUnavailableError, ErrorUtils, ExternalAgentUsageError, ExternalAgentUsageRecorder, FIELD_UI_FORMATS, FIELD_UI_FORMAT_TYPES, FIELD_UI_WIDGETS, FIELD_UI_WIDGET_TYPES, FilesystemError, GlobalInterceptors, IN_LIST_CHUNK_SIZE, LearningMemory, LiveSchemaParityError, MAX_CHANGES_LIMIT, MAX_DATA_QUERY_CURSOR_LENGTH, MAX_DATA_QUERY_FACETS, MAX_DATA_QUERY_FIELD_VALUES, MAX_DATA_QUERY_FIELD_VALUE_DESCRIPTION_LENGTH, MAX_DATA_QUERY_FIELD_VALUE_LABEL_LENGTH, MAX_DATA_QUERY_FIELD_VALUE_LENGTH, MAX_DATA_QUERY_FILTERS, MAX_DATA_QUERY_FILTER_DEPTH, MAX_DATA_QUERY_IN_VALUES, MAX_DATA_QUERY_OFFSET, MAX_DATA_QUERY_PAGE_LIMIT, MAX_DATA_QUERY_REQUEST_BYTES, MAX_DATA_QUERY_RESULT_BYTES, MAX_DATA_QUERY_WARNINGS, MAX_FACET_FIELDS, MAX_FACET_LIMIT, MAX_LIST_LIMIT, MAX_STI_READ_SCOPE_TYPES, MAX_SYNC_APPLY_BATCH_SIZE, MCPGenerator, MCP_STABLE_CATALOG_TTL_MS, MOCK_PROVIDER_OPTION, MODULE_DOC_HASH_PREFIX, ManifestBuilder, ManifestGenerator, ManifestManager, MetricsAdapter, NetworkError, ObjectRegistry, PLAYBOOK_PREFLIGHT_CAPABILITY, PLAYBOOK_PREFLIGHT_ROUTE_SEGMENT, POSTGRES_REVISION_GUARD_EXPRESSION, POSTGRES_TIMEOUT_ENV_VARS, PRIVATE_READ_CACHE_CONTROL, PubSubAdapter, QueryBoundsError, QueryOrderByError, RECIPE_DEMO_MODES, RELATIONSHIP_ROLES, RUN_ONCE_CLAIMS_TABLE, RunOnceClaimError, RuntimeError, SMRT_COLLECTION_BASE_NAMES, SMRT_CUSTOM_ACTION_ERROR_METADATA_KEY, SMRT_SCHEMA_VERSION, SMRT_TEST_MANIFEST_PATHS_ENV_KEY, SYNC_APPLY_ROUTE_SEGMENTS, SYNC_APPLY_UUID_PATTERN, SYSTEM_DIAGNOSTICS_TABLES, SYSTEM_TABLE_NAMES, SchemaComparer, SignalBus, SignalSanitizer, SmrtClass, SmrtCollection, SmrtError, SmrtHierarchical, SmrtJunction, SmrtJunctionBase, SmrtMCPServer, SmrtObject, SmrtPolymorphicAssociation, SmrtRecipe, TenantIsolationError, ValidationError, ValidationReport, ValidationUtils, appendChange, appendChanges, applyOneToManyChildAccessors, applyPendingDecoratorRegistrations, applyPostgresPermissions, applyPostgresRuntimeTimeouts, applySyncWritablePolicy, assertPlainJson, assertPostgresSystemTimestampsCurrent, assertScopedPackageName, auditChanges, auditSnapshot, broadcastCacheInvalidation, buildCascadePlan, buildChangeEventStream, buildConnectSection, buildCustomActionInputSchema, buildCustomActionInvocationArgs, buildDefaultListOrderBy, buildDomainKnowledgeManifest, buildGlossary, buildKnowledgeGraph, bumpChangeFeed, canonicalReadRepresentation, canonicalizeDataQuery, cascadeReferencesTo, changeEventSubscribersAtCapacity, checkKnowledgeGraphFreshness, checkLiveSchemaParity, childAccessorName, chunkArray, classifyDatabaseError, classifyDialectMessage, classifyMethodWireability, classifyParameterWireability, clearRetentionTasks, clone, coerceCustomActionArgument, collectForeignKeyOrphanCounts, computeBodyEtag, computeRuntimeWebManifestHash, computeTableVersionEtag, conditionalJsonResponse, config, convertTypeToJsonSchema, createClassNamePredicate, createConfigResolverContext, createDataQueryFingerprint, createDispatchBus, createFilesystemAdapter, createGeneratedCollectionAccess, createInterceptorContext, createMCPServer, createManifestClassNamePredicate, createQualifiedName, createRecipeHelp, createRestServer, createSmrtClient, createSmrtServer, crossPackageRef, customActionParameterInputName, declareChangeFeedSensitiveTable, declaredTypeAcceptsDate, declaresRuntimeRestRoute, declaresRuntimeRestRouteShape, deriveRecipeDemo, deriveRunOnceClaimKey, describeDisplayLabel, detectEngine, digestRunOnceContent, discoverKnowledgeArtifactPaths, discoverManifestEntry, discoverScopedPackageDirectories, displayLabelFieldProblem, drainChangeFeed, effectiveRecipeDemo, ensureBootstrapSystemTableCompatibility, ensureCacheInvalidationListener, ensureChangeFeedTable, ensureDeferredSystemTableCompatibility, ensureDispatchSubscriptionsSystemTableCompatibility, ensureDispatchSystemTableCompatibility, ensureJobEventsSystemTableCompatibility, ensureJobsSystemTableCompatibility, ensureLegacySystemTableCompatibility, ensureSystemTables, estimateAiUsageCost, eventStreamCapacityExceededResponse, executeCollectionReadPlan, executeDecision, executeToolCall, executeToolCalls, exposedCrudVerbs, extractFieldRefs, field, fieldTypeToJsonSchema, filterVisibleChangeFeedEntries, findCollectionWriteEscalations, findField, findManifestEntryByQualifiedName, findSelectorFor, findSubclassExposureEscalations, foreignKey, formatToolResults, generateDDLForEngine, generateOpenAPISpec, generateSchemaDiff, generateToolFromMethod, generateToolManifest, getActiveAuditOptions, getAdapterInfo, getAuthorizedChangesSince, getAuthorizedTenantScopedChangesSince, getCacheGeneration, getChangeFeedSensitiveTables, getChangesSince, getClassConfigResolvers, getClassName, getConfigResolver, getDatabaseEngine, getManifest, getPackageFromQualifiedName, getRetentionTasks, getSQLFromDiff, getSystemTableShapes, getTableVersion, getTenantScopedChangesSince, getTestDatabase, handlePlaybookPreflightRoute, hasActionableChanges, hasBrowserOption, hasChangeFeedEntryVisibilityHook, hasChangeFeedTableAuthorizerHook, helpToMarkdown, ifNoneMatchHasConcreteMatch, ifNoneMatchSatisfied, importOptionalDependency, inheritCollectionExposure, inheritSubclassExposure, inheritedCollectionSurface, invalidateCollectionCache, isAbortedTransactionError, isActiveTestManifestPath, isAdvisoryOnlyChange, isApiActionEnabledForObject, isAudited, isChangeFeedDenyAll, isChangeFeedEntryVisible, isChangeFeedSensitiveTable, isCrudOperation, isCrudToolAction, isDatabaseInterface, isDeterministicDatabaseError, isEmbeddedDatabase, isFieldUIFormat, isFieldUIWidget, isFrameworkBaseClass, isFromPackage, isLazyConfigSentinel, isManualOrAdvisoryChange, isMockableProvider, isNotNullViolationError, isPostgresDatabase, isQualifiedName, isRefusedTestArtifact, isRelationshipRole, isRestActionRoutable, isRestRoutePublic, isScopedPackageName, isSensitiveConnectionParam, isServerProvider, isSmrtCollectionExtendsName, isStaleWrite, isTenantScopedClassResolved, isTestArtifactManifest, isTransientConnectionError, isTransientDatabaseError, isType, isUniqueViolationError, isValid, listConfigResolvers, loadExternalManifest, loadExternalManifestSync, loadLocalTestManifestSync, loadManifestFromPathSync, manifest, manyToMany, meta, method, migratePostgresSystemTimestamps, normalizeCustomActionFailure, normalizeDataQueryFieldValues, normalizeDataQueryRequest, normalizeDataQueryResult, normalizeDataQuerySchema, normalizeEventsMaxSubscribers, normalizeExternalAgentUsageReport, normalizeOnDelete, normalizeTypedHttpError, oneToMany, parse, parseHelp, parseQualifiedName, parseSyncApplyBatch, payloadMatchesRow, planForeignKeyCreation, planPostgresPermissions, planPostgresSystemTimestampMigrations, postgresRevisionCandidates, postgresRevisionCondition, preferPersisted, processSyncApplyBatch, pruneAiUsage, pruneChangeFeed, pruneExpiredContexts, pruneRunOnceClaims, publishArtifactFiles, publishAtomicArtifact, qualifiedNamesEqual, queryStringDecoderFor, readAgentModuleDocs, readDispatchHealth, readJobHealth, readMethodDecoratorConfig, readMigrationStatus, readPackageAgentDoc, readRecentChanges, readRegistryDrift, readScheduleHealth, readSystemDiagnostics, redactDatabaseUrl, redactDatabaseUrlsInText, registerActiveTestManifestPath, registerChangeFeedWriter, registerCompatibleFieldDecorator, registerCompatibleMethodDecorator, registerConfigResolver, registerFilesystemAdapterFactory, registerOptionalDependency, registerRetentionTask, renderHelp, requireAuditOptions, resetChangeFeedWarnings, resetChangeSignals, resetCollectionCache, resetConfigResolvers, resetVerifiedTables, resolveActiveTestManifestPath, resolveAgentModuleDocPaths, resolveApiMethodExposure, resolveAuthorizedChangeFeedTables, resolveCustomActionMetadata, resolveDatabase, resolveDbCacheKey, resolveDeclaredScopeMismatch, resolveDispatchTenantId, resolveDispatchTenantScope, resolveDisplayLabelField, resolveEffectiveActionMetadata, resolveExistingRunOnceClaim, resolveFileKnowledgeConfig, resolveGetStringFilter, resolveHelp, resolveLazyConfig, resolveListLimit, resolveListOffset, resolveMCPToolListCacheHint, resolveOperationPermissionAlias, resolvePostgresTimeouts, resolveReadCacheControl, resolveRegisteredObjectName, resolveTenantEtagDiscriminator, restFieldReadPermissions, restMethodForApiAction, runCascadeDelete, runOnce, runRetentionSweep, runWithTenantGate, safeParse, safeStringify, sanitizeMessagePaths, setChangeFeedAuthorizer, setChangeFeedEntryVisibility, setDispatchTenantResolver, setTenantEntryPointRunner, setTenantScopedClassResolver, setupSwaggerUI, shouldIncludeMethod, signalVisibleToTenant, smrt, smrtPlugin, smrt as smrtRegistry, snapshotRegistry, sortMCPTools, stableStringify, startRestServer, staticManifest, stopCacheInvalidationListeners, stopChangeSignalListeners, stringify, subscribeToChangeSignals, summarizeExternalAgentUsage, surfaceOpensOperation, tableExists, toCustomActionBoolean, toCustomActionDate, toCustomActionNumber, toSnakeCase, tryReserveChangeEventSubscriberSlot, unregisterChangeFeedWriter, unregisterConfigResolver, unregisterRetentionTask, usesEmbeddedRevisionFallback, validateHelp, validatePostgresPermissionContract, validateSyncApplyItem, validateToolCall, versionConditionalResponse, warnIfSharedCacheNeutralized, withAuditContext, withEmbeddedWriteQueue, withEmbeddedWriteTransaction, writeAudit };
121
+ export { AGENT_SURFACE_HASH_PREFIX, AIError, APIGenerator, AiUsageCollector, AiUsagePersistenceHandler, BOOTED_PROVENANCE, CACHE_INVALIDATION_CHANNEL, CHANGE_FEED_CREDENTIAL_TABLES, CHANGE_FEED_INTERCEPTOR_NAME, CHANGE_FEED_TABLE, CHANGE_SIGNAL_CHANNEL, CRUD_OPERATIONS, ConfigurationError, ContentHasher, CosineSimilarity, DEFAULT_AI_COST_RATES, DEFAULT_CHANGES_LIMIT, DEFAULT_DATA_QUERY_PAGE_LIMIT, DEFAULT_DATA_QUERY_RESULT_BYTES, DEFAULT_DISPLAY_LABEL_FIELDS, DEFAULT_EMBEDDING_CONFIG, DEFAULT_EVENTS_HEARTBEAT_MS, DEFAULT_EVENTS_MAX_SUBSCRIBERS, DEFAULT_EVENTS_RETRY_AFTER_SECONDS, DEFAULT_FACET_LIMIT, DEFAULT_LEARNING_CONFIG, DEFAULT_LIST_LIMIT, DEFAULT_LIST_ORDER_BY, DEFAULT_POSTGRES_TIMEOUTS, DEFAULT_RETENTION_POLICY, DIAGNOSTICS_DEFAULT_LIMIT, DataQueryValidationError, DatabaseError, Dispatch, DispatchBus, DispatchCollection, DispatchSubscription, DispatchSubscriptionCollection, EXTERNAL_AGENT_COUNTERS, EXTERNAL_AGENT_USAGE_OPERATION, EmbeddingProvider, EmbeddingStorage, EmbeddingUnavailableError, ErrorUtils, ExternalAgentUsageError, ExternalAgentUsageRecorder, FIELD_UI_FORMATS, FIELD_UI_FORMAT_TYPES, FIELD_UI_WIDGETS, FIELD_UI_WIDGET_TYPES, FilesystemError, GlobalInterceptors, IN_LIST_CHUNK_SIZE, LearningMemory, LiveSchemaParityError, MAX_CHANGES_LIMIT, MAX_DATA_QUERY_CURSOR_LENGTH, MAX_DATA_QUERY_FACETS, MAX_DATA_QUERY_FIELD_VALUES, MAX_DATA_QUERY_FIELD_VALUE_DESCRIPTION_LENGTH, MAX_DATA_QUERY_FIELD_VALUE_LABEL_LENGTH, MAX_DATA_QUERY_FIELD_VALUE_LENGTH, MAX_DATA_QUERY_FILTERS, MAX_DATA_QUERY_FILTER_DEPTH, MAX_DATA_QUERY_IN_VALUES, MAX_DATA_QUERY_OFFSET, MAX_DATA_QUERY_PAGE_LIMIT, MAX_DATA_QUERY_REQUEST_BYTES, MAX_DATA_QUERY_RESULT_BYTES, MAX_DATA_QUERY_WARNINGS, MAX_FACET_FIELDS, MAX_FACET_LIMIT, MAX_LIST_LIMIT, MAX_STI_READ_SCOPE_TYPES, MAX_SYNC_APPLY_BATCH_SIZE, MCPGenerator, MCP_STABLE_CATALOG_TTL_MS, MOCK_PROVIDER_OPTION, MODULE_DOC_HASH_PREFIX, ManifestBuilder, ManifestGenerator, ManifestManager, MetricsAdapter, NetworkError, ObjectRegistry, PLAYBOOK_PREFLIGHT_CAPABILITY, PLAYBOOK_PREFLIGHT_ROUTE_SEGMENT, POSTGRES_REVISION_GUARD_EXPRESSION, POSTGRES_TIMEOUT_ENV_VARS, PRIVATE_READ_CACHE_CONTROL, PubSubAdapter, QueryBoundsError, QueryOrderByError, RECIPE_DEMO_MODES, RELATIONSHIP_ROLES, RUN_ONCE_CLAIMS_TABLE, RunOnceClaimError, RuntimeError, SMRT_COLLECTION_BASE_NAMES, SMRT_CUSTOM_ACTION_ERROR_METADATA_KEY, SMRT_SCHEMA_VERSION, SMRT_TEST_MANIFEST_PATHS_ENV_KEY, SYNC_APPLY_ROUTE_SEGMENTS, SYNC_APPLY_UUID_PATTERN, SYSTEM_DIAGNOSTICS_TABLES, SYSTEM_TABLE_NAMES, SchemaComparer, SignalBus, SignalSanitizer, SmrtClass, SmrtCollection, SmrtError, SmrtHierarchical, SmrtJunction, SmrtJunctionBase, SmrtMCPServer, SmrtObject, SmrtPolymorphicAssociation, SmrtRecipe, TenantIsolationError, ValidationError, ValidationReport, ValidationUtils, appendChange, appendChanges, applyOneToManyChildAccessors, applyPendingDecoratorRegistrations, applyPostgresPermissions, applyPostgresRuntimeTimeouts, applySyncWritablePolicy, assertPlainJson, assertPostgresSystemTimestampsCurrent, assertScopedPackageName, auditChanges, auditSnapshot, broadcastCacheInvalidation, buildCascadePlan, buildChangeEventStream, buildConnectSection, buildCustomActionInputSchema, buildCustomActionInvocationArgs, buildDefaultListOrderBy, buildDomainKnowledgeManifest, buildGlossary, buildKnowledgeGraph, bumpChangeFeed, canonicalReadRepresentation, canonicalizeDataQuery, cascadeReferencesTo, changeEventSubscribersAtCapacity, checkKnowledgeGraphFreshness, checkLiveSchemaParity, childAccessorName, chunkArray, classifyDatabaseError, classifyDialectMessage, classifyMethodWireability, classifyParameterWireability, clearRetentionTasks, clone, coerceCustomActionArgument, collectForeignKeyOrphanCounts, computeBodyEtag, computeRuntimeWebManifestHash, computeTableVersionEtag, conditionalJsonResponse, config, convertTypeToJsonSchema, createClassNamePredicate, createConfigResolverContext, createDataQueryFingerprint, createDispatchBus, createFilesystemAdapter, createGeneratedCollectionAccess, createInterceptorContext, createMCPServer, createManifestClassNamePredicate, createQualifiedName, createRecipeHelp, createRestServer, createSmrtClient, createSmrtServer, crossPackageRef, customActionParameterInputName, declareChangeFeedSensitiveTable, declaredTypeAcceptsDate, declaresRuntimeRestRoute, declaresRuntimeRestRouteShape, deriveRecipeDemo, deriveRunOnceClaimKey, describeDisplayLabel, detectEngine, digestRunOnceContent, discoverKnowledgeArtifactPaths, discoverManifestEntry, discoverScopedPackageDirectories, displayLabelFieldProblem, drainChangeFeed, effectiveRecipeDemo, ensureBootstrapSystemTableCompatibility, ensureCacheInvalidationListener, ensureChangeFeedTable, ensureDeferredSystemTableCompatibility, ensureDispatchSubscriptionsSystemTableCompatibility, ensureDispatchSystemTableCompatibility, ensureJobEventsSystemTableCompatibility, ensureJobsSystemTableCompatibility, ensureLegacySystemTableCompatibility, ensureSystemTables, estimateAiUsageCost, eventStreamCapacityExceededResponse, executeCollectionReadPlan, executeDecision, executeToolCall, executeToolCalls, exposedCrudVerbs, extractFieldRefs, field, fieldTypeToJsonSchema, filterVisibleChangeFeedEntries, findCollectionWriteEscalations, findField, findManifestEntryByQualifiedName, findSelectorFor, findSubclassExposureEscalations, foreignKey, formatToolResults, generateDDLForEngine, generateOpenAPISpec, generateSchemaDiff, generateToolFromMethod, generateToolManifest, getActiveAuditOptions, getAdapterInfo, getAuthorizedChangesSince, getAuthorizedTenantScopedChangesSince, getCacheGeneration, getChangeFeedSensitiveTables, getChangesSince, getClassConfigResolvers, getClassName, getConfigResolver, getDatabaseEngine, getManifest, getPackageFromQualifiedName, getRetentionTasks, getSQLFromDiff, getSystemTableShapes, getTableVersion, getTenantScopedChangesSince, getTestDatabase, handlePlaybookPreflightRoute, hasActionableChanges, hasBrowserOption, hasChangeFeedEntryVisibilityHook, hasChangeFeedTableAuthorizerHook, helpToMarkdown, ifNoneMatchHasConcreteMatch, ifNoneMatchSatisfied, importOptionalDependency, inheritCollectionExposure, inheritSubclassExposure, inheritedCollectionSurface, invalidateCollectionCache, isAbortedTransactionError, isActiveTestManifestPath, isAdvisoryOnlyChange, isApiActionEnabledForObject, isAudited, isChangeFeedDenyAll, isChangeFeedEntryVisible, isChangeFeedSensitiveTable, isCrudOperation, isCrudToolAction, isDatabaseInterface, isDeterministicDatabaseError, isEmbeddedDatabase, isFieldUIFormat, isFieldUIWidget, isFrameworkBaseClass, isFromPackage, isLazyConfigSentinel, isManualOrAdvisoryChange, isMockableProvider, isNotNullViolationError, isPostgresDatabase, isQualifiedName, isRefusedTestArtifact, isRelationshipRole, isRestActionRoutable, isRestRoutePublic, isScopedPackageName, isSensitiveConnectionParam, isServerProvider, isSmrtCollectionExtendsName, isStaleWrite, isTenantScopedClassResolved, isTestArtifactManifest, isTransientConnectionError, isTransientDatabaseError, isType, isUniqueViolationError, isValid, listConfigResolvers, loadExternalManifest, loadExternalManifestSync, loadLocalTestManifestSync, loadManifestFromPathSync, manifest, manyToMany, meta, method, migratePostgresSystemTimestamps, normalizeCustomActionFailure, normalizeDataQueryFieldValues, normalizeDataQueryRequest, normalizeDataQueryResult, normalizeDataQuerySchema, normalizeEventsMaxSubscribers, normalizeExternalAgentUsageReport, normalizeOnDelete, normalizeTypedHttpError, oneToMany, parse, parseHelp, parseQualifiedName, parseSyncApplyBatch, payloadMatchesRow, planForeignKeyCreation, planPostgresPermissions, planPostgresSystemTimestampMigrations, postgresRevisionCandidates, postgresRevisionCondition, preferPersisted, processSyncApplyBatch, pruneAiUsage, pruneChangeFeed, pruneExpiredContexts, pruneRunOnceClaims, publishArtifactFiles, publishAtomicArtifact, qualifiedNamesEqual, queryStringDecoderFor, readAgentModuleDocs, readDispatchHealth, readJobHealth, readMethodDecoratorConfig, readMigrationStatus, readPackageAgentDoc, readRecentChanges, readRegistryDrift, readScheduleHealth, readSystemDiagnostics, redactDatabaseUrl, redactDatabaseUrlsInText, registerActiveTestManifestPath, registerChangeFeedWriter, registerCompatibleFieldDecorator, registerCompatibleMethodDecorator, registerConfigResolver, registerFilesystemAdapterFactory, registerOptionalDependency, registerRetentionTask, renderHelp, requireAuditOptions, resetChangeFeedWarnings, resetChangeSignals, resetCollectionCache, resetConfigResolvers, resetVerifiedTables, resolveActiveTestManifestPath, resolveAgentModuleDocPaths, resolveApiMethodExposure, resolveAuthorizedChangeFeedTables, resolveCustomActionMetadata, resolveDatabase, resolveDbCacheKey, resolveDeclaredScopeMismatch, resolveDispatchTenantId, resolveDispatchTenantScope, resolveDisplayLabelField, resolveEffectiveActionMetadata, resolveExistingRunOnceClaim, resolveFileKnowledgeConfig, resolveGetStringFilter, resolveHelp, resolveLazyConfig, resolveListLimit, resolveListOffset, resolveMCPToolListCacheHint, resolveOperationPermissionAlias, resolvePostgresTimeouts, resolveReadCacheControl, resolveRegisteredObjectName, resolveTenantEtagDiscriminator, restFieldReadPermissions, restMethodForApiAction, runCascadeDelete, runOnce, runRetentionSweep, runWithTenantGate, safeParse, safeStringify, sanitizeMessagePaths, setChangeFeedAuthorizer, setChangeFeedEntryVisibility, setDatabaseSyncDeviceId, setDispatchTenantResolver, setTenantEntryPointRunner, setTenantScopedClassResolver, setupSwaggerUI, shouldIncludeMethod, signalVisibleToTenant, smrt, smrtPlugin, smrt as smrtRegistry, snapshotRegistry, sortMCPTools, stableStringify, startRestServer, staticManifest, stopCacheInvalidationListeners, stopChangeSignalListeners, stringify, subscribeToChangeSignals, summarizeExternalAgentUsage, surfaceOpensOperation, tableExists, toCustomActionBoolean, toCustomActionDate, toCustomActionNumber, toSnakeCase, tryReserveChangeEventSubscriberSlot, unregisterChangeFeedWriter, unregisterConfigResolver, unregisterRetentionTask, usesEmbeddedRevisionFallback, validateHelp, validatePostgresPermissionContract, validateSyncApplyItem, validateToolCall, versionConditionalResponse, warnIfSharedCacheNeutralized, withAuditContext, withCallerOwnedDatabaseTransaction, withEmbeddedWriteQueue, withEmbeddedWriteTransaction, writeAudit };
@@ -1 +1 @@
1
- {"version":3,"file":"static-manifest.d.ts","sourceRoot":"","sources":["../../src/manifest/static-manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,eAAO,MAAM,cAAc,EAAE,mBAq1DnB,CAAC;AAEX,eAAe,cAAc,CAAC"}
1
+ {"version":3,"file":"static-manifest.d.ts","sourceRoot":"","sources":["../../src/manifest/static-manifest.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE/D,eAAO,MAAM,cAAc,EAAE,mBAq3DnB,CAAC;AAEX,eAAe,cAAc,CAAC"}
@@ -3,7 +3,7 @@ var staticManifest = {
3
3
  "version": "1.0.0",
4
4
  "timestamp": 0,
5
5
  "packageName": "@happyvertical/smrt-core",
6
- "packageVersion": "0.60.9",
6
+ "packageVersion": "0.60.10",
7
7
  "objects": {
8
8
  "@happyvertical/smrt-core:SmrtClass": {
9
9
  "name": "smrtclass",
@@ -85,8 +85,10 @@ var staticManifest = {
85
85
  "collectionExportName": "SmrtClassCollection",
86
86
  "schema": {
87
87
  "tableName": "smrt_classes",
88
- "ddl": "CREATE TABLE IF NOT EXISTS \"smrt_classes\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
88
+ "ddl": "CREATE TABLE IF NOT EXISTS \"smrt_classes\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
89
89
  "columns": {
90
+ "_sync_origin_device_id": { "type": "TEXT" },
91
+ "_sync_revision": { "type": "INTEGER" },
90
92
  "id": {
91
93
  "type": "UUID",
92
94
  "primaryKey": true,
@@ -121,7 +123,7 @@ var staticManifest = {
121
123
  "name": "smrt_classes_created_at_idx",
122
124
  "columns": ["created_at"]
123
125
  }],
124
- "version": "234a72b0"
126
+ "version": "62a87e8a"
125
127
  },
126
128
  "importPath": "@happyvertical/smrt-core"
127
129
  },
@@ -714,8 +716,10 @@ var staticManifest = {
714
716
  "collectionExportName": "SmrtCollectionCollection",
715
717
  "schema": {
716
718
  "tableName": "smrt_collections",
717
- "ddl": "CREATE TABLE IF NOT EXISTS \"smrt_collections\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
719
+ "ddl": "CREATE TABLE IF NOT EXISTS \"smrt_collections\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
718
720
  "columns": {
721
+ "_sync_origin_device_id": { "type": "TEXT" },
722
+ "_sync_revision": { "type": "INTEGER" },
719
723
  "id": {
720
724
  "type": "UUID",
721
725
  "primaryKey": true,
@@ -750,7 +754,7 @@ var staticManifest = {
750
754
  "name": "smrt_collections_created_at_idx",
751
755
  "columns": ["created_at"]
752
756
  }],
753
- "version": "295b0a80"
757
+ "version": "a4380e3d"
754
758
  },
755
759
  "importPath": "@happyvertical/smrt-core"
756
760
  },
@@ -1005,6 +1009,18 @@ var staticManifest = {
1005
1009
  }
1006
1010
  },
1007
1011
  "methods": {
1012
+ "hydrateSyncMetadata": {
1013
+ "name": "hydrateSyncMetadata",
1014
+ "async": false,
1015
+ "parameters": [{
1016
+ "name": "row",
1017
+ "type": "Record<string, unknown>",
1018
+ "optional": false
1019
+ }],
1020
+ "returnType": "void",
1021
+ "isStatic": false,
1022
+ "isPublic": true
1023
+ },
1008
1024
  "markAsPersisted": {
1009
1025
  "name": "markAsPersisted",
1010
1026
  "async": false,
@@ -1521,8 +1537,10 @@ var staticManifest = {
1521
1537
  "collectionExportName": "SmrtObjectCollection",
1522
1538
  "schema": {
1523
1539
  "tableName": "smrt_objects",
1524
- "ddl": "CREATE TABLE IF NOT EXISTS \"smrt_objects\" (\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
1540
+ "ddl": "CREATE TABLE IF NOT EXISTS \"smrt_objects\" (\n \"_sync_origin_device_id\" TEXT,\n \"_sync_revision\" INTEGER,\n \"id\" UUID PRIMARY KEY NOT NULL,\n \"slug\" TEXT NOT NULL,\n \"context\" TEXT NOT NULL DEFAULT '',\n \"created_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp,\n \"updated_at\" TIMESTAMP NOT NULL DEFAULT current_timestamp\n);",
1525
1541
  "columns": {
1542
+ "_sync_origin_device_id": { "type": "TEXT" },
1543
+ "_sync_revision": { "type": "INTEGER" },
1526
1544
  "id": {
1527
1545
  "type": "UUID",
1528
1546
  "primaryKey": true,
@@ -1557,7 +1575,7 @@ var staticManifest = {
1557
1575
  "name": "smrt_objects_created_at_idx",
1558
1576
  "columns": ["created_at"]
1559
1577
  }],
1560
- "version": "204bf3c4"
1578
+ "version": "cd6fde3e"
1561
1579
  },
1562
1580
  "importPath": "@happyvertical/smrt-core"
1563
1581
  },