@happyvertical/smrt-core 0.37.6 → 0.37.8

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 (71) hide show
  1. package/AGENTS.md +17 -6
  2. package/dist/collection.d.ts +7 -0
  3. package/dist/collection.d.ts.map +1 -1
  4. package/dist/collection.js +2 -0
  5. package/dist/collection.js.map +1 -1
  6. package/dist/consumer-plugin/index.js +26 -3
  7. package/dist/consumer-plugin/index.js.map +1 -1
  8. package/dist/dispatch/index.d.ts +1 -1
  9. package/dist/dispatch/index.d.ts.map +1 -1
  10. package/dist/dispatch/index.js +2 -2
  11. package/dist/dispatch/tenant-resolver.d.ts +23 -0
  12. package/dist/dispatch/tenant-resolver.d.ts.map +1 -1
  13. package/dist/dispatch/tenant-resolver.js +33 -1
  14. package/dist/dispatch/tenant-resolver.js.map +1 -1
  15. package/dist/generators/conditional-get.d.ts +120 -0
  16. package/dist/generators/conditional-get.d.ts.map +1 -0
  17. package/dist/generators/conditional-get.js +217 -0
  18. package/dist/generators/conditional-get.js.map +1 -0
  19. package/dist/generators/index.d.ts +1 -0
  20. package/dist/generators/index.d.ts.map +1 -1
  21. package/dist/generators/index.js +2 -1
  22. package/dist/generators/rest.d.ts +52 -0
  23. package/dist/generators/rest.d.ts.map +1 -1
  24. package/dist/generators/rest.js +146 -10
  25. package/dist/generators/rest.js.map +1 -1
  26. package/dist/generators.js +2 -1
  27. package/dist/index.d.ts +1 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +4 -2
  30. package/dist/manifest/manifest-loader.d.ts +10 -1
  31. package/dist/manifest/manifest-loader.d.ts.map +1 -1
  32. package/dist/manifest/manifest-loader.js +18 -5
  33. package/dist/manifest/manifest-loader.js.map +1 -1
  34. package/dist/manifest/static-manifest.d.ts.map +1 -1
  35. package/dist/manifest/static-manifest.js +10 -2
  36. package/dist/manifest/static-manifest.js.map +1 -1
  37. package/dist/manifest/store.js +1 -1
  38. package/dist/manifest/store.js.map +1 -1
  39. package/dist/manifest/test-manifest-stub.d.ts.map +1 -1
  40. package/dist/manifest/test-manifest-stub.js +2108 -223
  41. package/dist/manifest/test-manifest-stub.js.map +1 -1
  42. package/dist/manifest.json +10 -2
  43. package/dist/object.d.ts +19 -0
  44. package/dist/object.d.ts.map +1 -1
  45. package/dist/object.js +24 -2
  46. package/dist/object.js.map +1 -1
  47. package/dist/registry/index.d.ts +1 -1
  48. package/dist/registry/index.d.ts.map +1 -1
  49. package/dist/registry/shared-state.d.ts +8 -1
  50. package/dist/registry/shared-state.d.ts.map +1 -1
  51. package/dist/registry/shared-state.js +11 -3
  52. package/dist/registry/shared-state.js.map +1 -1
  53. package/dist/registry/types.d.ts +34 -0
  54. package/dist/registry/types.d.ts.map +1 -1
  55. package/dist/smrt-knowledge.json +7 -6
  56. package/dist/sync/apply.d.ts +234 -0
  57. package/dist/sync/apply.d.ts.map +1 -0
  58. package/dist/sync/apply.js +378 -0
  59. package/dist/sync/apply.js.map +1 -0
  60. package/dist/utils/stack-frames.d.ts +50 -0
  61. package/dist/utils/stack-frames.d.ts.map +1 -0
  62. package/dist/utils/stack-frames.js +64 -0
  63. package/dist/utils/stack-frames.js.map +1 -0
  64. package/dist/vite-plugin/sveltekit-generator.d.ts.map +1 -1
  65. package/dist/vite-plugin/sveltekit-generator.js +60 -27
  66. package/dist/vite-plugin/sveltekit-generator.js.map +1 -1
  67. package/dist/vite-plugin/sync-apply-route.d.ts +40 -0
  68. package/dist/vite-plugin/sync-apply-route.d.ts.map +1 -0
  69. package/dist/vite-plugin/sync-apply-route.js +240 -0
  70. package/dist/vite-plugin/sync-apply-route.js.map +1 -0
  71. package/package.json +4 -4
@@ -8,6 +8,6 @@ export { getEmbeddingClasses, getEmbeddingConfig, getProjectEmbeddingConfig, has
8
8
  export { findClass, findClassesByName, findClassStrict, getAllClasses, getCanonicalClassName, getClass, getClassByConstructor, getClassByQualifiedName, getClassesByPackage, getClassesByVisibility, getClassInPackage, getClassNames, getPublicClasses, getQualifiedClassNames, hasClass, hasClassCaseInsensitive, qualifyExtendsName, resolveType, } from './name-resolver';
9
9
  export { getDependencyGraph, getRelationshipMap } from './relationship-graph';
10
10
  export { getClasses, getCollectionCache, getCollections, getCollectionTableNames, getConstructorIndex, getDbInstanceIds, getDiscoveryAttemptCache, getFieldDecorators, getInheritanceCache, getInheritanceConfig, getNextDbId, getSchemasInitialized, getSourceFileFromStack, getStiSiblingsLoaded, setNextDbId, VERBOSE_ENABLED, verboseLog, } from './shared-state';
11
- export type { ApiConfig, RegisteredClass, RelationshipMetadata, RelationshipType, SmartObjectConfig, SmrtObjectConstructor, ValidatorFunction, } from './types';
11
+ export type { ApiConfig, ApiHttpCacheConfig, RegisteredClass, RelationshipMetadata, RelationshipType, SmartObjectConfig, SmrtObjectConstructor, ValidatorFunction, } from './types';
12
12
  export { compileValidators } from './validator';
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EACzB,aAAa,EACb,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,QAAQ,EACR,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,QAAQ,EACR,uBAAuB,EACvB,kBAAkB,EAClB,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,UAAU,GACX,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,SAAS,EACT,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/registry/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,EACzB,aAAa,EACb,sBAAsB,GACvB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,SAAS,EACT,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,qBAAqB,EACrB,QAAQ,EACR,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,EACnB,sBAAsB,EACtB,iBAAiB,EACjB,aAAa,EACb,gBAAgB,EAChB,sBAAsB,EACtB,QAAQ,EACR,uBAAuB,EACvB,kBAAkB,EAClB,WAAW,GACZ,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE9E,OAAO,EACL,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,uBAAuB,EACvB,mBAAmB,EACnB,gBAAgB,EAChB,wBAAwB,EACxB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,UAAU,GACX,MAAM,gBAAgB,CAAC;AAExB,YAAY,EACV,SAAS,EACT,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,gBAAgB,EAChB,iBAAiB,EACjB,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC"}
@@ -43,9 +43,16 @@ export declare function getInheritanceConfig(): {
43
43
  * This allows the same class to be re-registered when modules are re-evaluated
44
44
  * (e.g., during vitest test file collection with isolation enabled).
45
45
  *
46
+ * Frames from decorator-lowering runtime helpers (`@oxc-project/runtime` under
47
+ * Vite 8, `tslib`/`@swc/helpers`/`@babel/runtime` elsewhere) are skipped too, so
48
+ * the lowered `@smrt()` application resolves to the consumer module that declares
49
+ * the class rather than the helper frame the compiler inserted (#1785).
50
+ *
51
+ * @param stackOverride - Optional stack string to parse instead of a fresh
52
+ * `Error().stack`. Used by tests to simulate a lowered call pattern.
46
53
  * @returns The file path where the @smrt() decorator was called, or undefined
47
54
  */
48
- export declare function getSourceFileFromStack(): string | undefined;
55
+ export declare function getSourceFileFromStack(stackOverride?: string): string | undefined;
49
56
  export declare function getClasses(): Map<string, RegisteredClass>;
50
57
  export declare function getCollections(): Map<string, typeof SmrtCollection>;
51
58
  export declare function getCollectionTableNames(): Map<string, string>;
@@ -1 +1 @@
1
- {"version":3,"file":"shared-state.d.ts","sourceRoot":"","sources":["../../src/registry/shared-state.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAMpD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAGtE,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,qBAAqB,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,GAAG,SAAS,CAAC;IAEpE,IAAI,yBAAyB,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,cAAc,CAAC,GAAG,SAAS,CAAC;IAO9E,IAAI,6BAA6B,EAE7B,QAAQ,C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AAC,MAAM,EAAE,eAAe,CAAC,CAKzD;AAED,wBAAgB,cAAc,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,cAAc,CAAC,CAQnE;AAED,wBAAgB,uBAAuB,IAAI,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAK7D;AAGD,wBAAgB,kBAAkB,IAAI,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,CAAC,CAAC,CAS1E;AAED,wBAAgB,gBAAgB,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAK1D;AAED,wBAAgB,WAAW,IAAI,MAAM,CAKpC;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAE/C;AAED,wBAAgB,kBAAkB,IAAI,GAAG,CACvC,MAAM,EACN,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CACrC,CAQA;AAED,wBAAgB,oBAAoB,IAAI,GAAG,CAAC,MAAM,CAAC,CAKlD;AAQD,wBAAgB,qBAAqB,IAAI,OAAO,CAAC,MAAM,CAAC,CAKvD;AAED,wBAAgB,mBAAmB,IAAI,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAQ5E;AAED,wBAAgB,mBAAmB,IAAI,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAShE;AAED,wBAAgB,wBAAwB,IAAI,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAK/D"}
@@ -1,5 +1,6 @@
1
1
  import { getSmrtModuleConfig } from "../config/global-config.js";
2
2
  import { LRUCache } from "../utils/lru-cache.js";
3
+ import { isDecoratorRuntimeFramePath } from "../utils/stack-frames.js";
3
4
  import { createLogger } from "@happyvertical/logger";
4
5
  //#region src/registry/shared-state.ts
5
6
  /**
@@ -49,16 +50,23 @@ function getInheritanceConfig() {
49
50
  * This allows the same class to be re-registered when modules are re-evaluated
50
51
  * (e.g., during vitest test file collection with isolation enabled).
51
52
  *
53
+ * Frames from decorator-lowering runtime helpers (`@oxc-project/runtime` under
54
+ * Vite 8, `tslib`/`@swc/helpers`/`@babel/runtime` elsewhere) are skipped too, so
55
+ * the lowered `@smrt()` application resolves to the consumer module that declares
56
+ * the class rather than the helper frame the compiler inserted (#1785).
57
+ *
58
+ * @param stackOverride - Optional stack string to parse instead of a fresh
59
+ * `Error().stack`. Used by tests to simulate a lowered call pattern.
52
60
  * @returns The file path where the @smrt() decorator was called, or undefined
53
61
  */
54
- function getSourceFileFromStack() {
55
- const stackLines = ((/* @__PURE__ */ new Error()).stack || "").split("\n");
62
+ function getSourceFileFromStack(stackOverride) {
63
+ const stackLines = (stackOverride ?? (/* @__PURE__ */ new Error()).stack ?? "").split("\n");
56
64
  for (const line of stackLines) {
57
65
  const fileMatch = line.match(/(?:file:\/\/)?([^)\s]+\.(?:js|ts|mjs|mts|jsx|tsx|cjs|cts))(?::\d+:\d+)?/);
58
66
  if (fileMatch) {
59
67
  const normalizedPath = fileMatch[1].replace(/^file:\/+/, "").replace(/\\/g, "/");
60
68
  const lowerPath = normalizedPath.toLowerCase();
61
- if (lowerPath.includes("/node_modules/@happyvertical/smrt-core/") || lowerPath.includes("/packages/core/src/") && !lowerPath.includes("__tests__") || lowerPath.includes("/manifest/manifest-loader")) continue;
69
+ if (lowerPath.includes("/node_modules/@happyvertical/smrt-core/") || lowerPath.includes("/packages/core/src/") && !lowerPath.includes("__tests__") || lowerPath.includes("/manifest/manifest-loader") || isDecoratorRuntimeFramePath(normalizedPath)) continue;
62
70
  return normalizedPath;
63
71
  }
64
72
  }
@@ -1 +1 @@
1
- {"version":3,"file":"shared-state.js","names":[],"sources":["../../src/registry/shared-state.ts"],"sourcesContent":["/**\n * Shared state accessors for the SMRT ObjectRegistry.\n *\n * All registry sub-modules share state via globalThis to ensure\n * cross-module consistency in monorepo environments.\n *\n * Extracted from registry.ts as part of issue #1006.\n * @see https://github.com/happyvertical/smrt/issues/1006\n * @see https://github.com/happyvertical/smrt/issues/543\n */\n\nimport { createLogger } from '@happyvertical/logger';\nimport type { SmrtCollection } from '../collection';\nimport {\n getSmrtModuleConfig,\n type SmrtGlobalConfig,\n} from '../config/global-config.js';\nimport type { SmrtObject } from '../object';\nimport { LRUCache } from '../utils/lru-cache';\nimport type { RegisteredClass, SmrtObjectConstructor } from './types';\n\n// Re-export the globalThis augmentation so it's visible everywhere\ndeclare global {\n // eslint-disable-next-line no-var\n var __smrtRegistryClasses: Map<string, RegisteredClass> | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryCollections: Map<string, typeof SmrtCollection> | undefined;\n // eslint-disable-next-line no-var\n // Heterogeneous cache: stores collections of many different item types keyed\n // by class name. `SmrtCollection` is invariant in its item type (it has\n // `create(options: SmrtCreateInput<ModelType>)`), so this cannot be narrowed\n // to `SmrtCollection<SmrtObject>` — the type argument stays `any` (read sites\n // cast back to the concrete collection type).\n var __smrtRegistryCollectionCache:\n // biome-ignore lint/suspicious/noExplicitAny: heterogeneous cache keyed by class name; `SmrtCollection` is invariant in `ModelType` so the type arg cannot narrow to `SmrtObject` (read sites cast back). S4 #1579.\n | LRUCache<string, SmrtCollection<any>>\n | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryDbInstanceIds: WeakMap<object, number> | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryNextDbId: number | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryInheritanceChainCache:\n | LRUCache<string, string[]>\n | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryFieldDecorators:\n | Map<string, Map<string, Record<string, unknown>>>\n | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryStiSiblingsLoaded: Set<string> | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryCollectionTableNames: Map<string, string> | undefined;\n // Release B (#1133) removed __smrtRegistryClassNameMap — case-insensitive\n // lookups now iterate the `classes` Map directly. The globalThis slot is\n // left undeclared so any leftover code that reaches for it gets a clean\n // TS error instead of silently stale data.\n // eslint-disable-next-line no-var\n var __smrtRegistrySchemasInitialized: WeakSet<object> | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryConstructorIndex:\n | WeakMap<SmrtObjectConstructor, string>\n | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryDiscoveryAttemptCache: Map<string, boolean> | undefined;\n}\n\n/**\n * Cached verbose flag evaluated once at module load time.\n * Checks SMRT_VERBOSE=true or DEBUG containing 'smrt'.\n * Avoids repeated env var parsing on every log statement.\n * @see https://github.com/happyvertical/smrt/issues/782\n */\nexport const VERBOSE_ENABLED =\n process.env.SMRT_VERBOSE === 'true' ||\n (process.env.DEBUG?.includes('smrt') ?? false);\n\n// verboseLog() is gated by VERBOSE_ENABLED, so the level must allow debug when\n// it's set (a fixed 'info' would filter the trace out and break SMRT_VERBOSE).\nconst logger = createLogger({ level: VERBOSE_ENABLED ? 'debug' : 'info' });\n\n/**\n * Log a message only when verbose mode is enabled.\n * Used throughout registry modules to reduce noise during normal operation.\n * @param args - Arguments to pass to console.log\n */\nexport function verboseLog(...args: unknown[]): void {\n if (VERBOSE_ENABLED) {\n const [message, ...rest] = args;\n logger.debug(\n typeof message === 'string' ? message : String(message),\n rest.length > 0 ? { args: rest } : undefined,\n );\n }\n}\n\n/**\n * Get inheritance config synchronously.\n * Uses the config package's sync accessor which returns already-loaded config.\n */\nexport function getInheritanceConfig() {\n const config = getSmrtModuleConfig<SmrtGlobalConfig>('smrt', {});\n return {\n cacheSize: config.inheritance?.cacheSize ?? 200,\n onMissingAncestor:\n config.inheritance?.onMissingAncestor ?? ('warn' as 'warn' | 'error'),\n };\n}\n\n/**\n * Extract the source file path from the call stack.\n *\n * Used to identify where a class was defined for collision detection.\n * This allows the same class to be re-registered when modules are re-evaluated\n * (e.g., during vitest test file collection with isolation enabled).\n *\n * @returns The file path where the @smrt() decorator was called, or undefined\n */\nexport function getSourceFileFromStack(): string | undefined {\n const error = new Error();\n const stack = error.stack || '';\n const stackLines = stack.split('\\n');\n\n // Look for the first file path that's NOT from smrt-core internal files\n // Stack trace format: \" at FunctionName (file:///path/to/file.ts:line:col)\"\n // or \" at file:///path/to/file.ts:line:col\"\n for (const line of stackLines) {\n // Match file paths in stack trace (include all JS/TS file extensions)\n const fileMatch = line.match(\n /(?:file:\\/\\/)?([^)\\s]+\\.(?:js|ts|mjs|mts|jsx|tsx|cjs|cts))(?::\\d+:\\d+)?/,\n );\n if (fileMatch) {\n const rawPath = fileMatch[1];\n // Normalize the path:\n // - remove any leading file:// or file:/// prefix\n // - convert Windows backslashes to POSIX-style forward slashes\n const normalizedPath = rawPath\n .replace(/^file:\\/+/, '')\n .replace(/\\\\/g, '/');\n const lowerPath = normalizedPath.toLowerCase();\n\n // Skip smrt-core internal files using specific path patterns\n // to avoid false positives with user files containing \"registry\" in name\n if (\n // Installed package form: node_modules/@happyvertical/smrt-core/...\n lowerPath.includes('/node_modules/@happyvertical/smrt-core/') ||\n // Monorepo/workspace form: packages/core/src/...\n (lowerPath.includes('/packages/core/src/') &&\n !lowerPath.includes('__tests__')) ||\n // Specific manifest loader internals\n lowerPath.includes('/manifest/manifest-loader')\n ) {\n continue;\n }\n return normalizedPath;\n }\n }\n return undefined;\n}\n\n// ── Shared state accessor functions ──────────────────────────────────────\n\nexport function getClasses(): Map<string, RegisteredClass> {\n if (!globalThis.__smrtRegistryClasses) {\n globalThis.__smrtRegistryClasses = new Map<string, RegisteredClass>();\n }\n return globalThis.__smrtRegistryClasses;\n}\n\nexport function getCollections(): Map<string, typeof SmrtCollection> {\n if (!globalThis.__smrtRegistryCollections) {\n globalThis.__smrtRegistryCollections = new Map<\n string,\n typeof SmrtCollection\n >();\n }\n return globalThis.__smrtRegistryCollections;\n}\n\nexport function getCollectionTableNames(): Map<string, string> {\n if (!globalThis.__smrtRegistryCollectionTableNames) {\n globalThis.__smrtRegistryCollectionTableNames = new Map<string, string>();\n }\n return globalThis.__smrtRegistryCollectionTableNames;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: heterogeneous cache; `SmrtCollection` is invariant in `ModelType` so the type arg cannot narrow to `SmrtObject` (read sites cast back). S4 #1579.\nexport function getCollectionCache(): LRUCache<string, SmrtCollection<any>> {\n if (!globalThis.__smrtRegistryCollectionCache) {\n globalThis.__smrtRegistryCollectionCache = new LRUCache<\n string,\n // biome-ignore lint/suspicious/noExplicitAny: same heterogeneous-cache invariance as the return type above. S4 #1579.\n SmrtCollection<any>\n >(100);\n }\n return globalThis.__smrtRegistryCollectionCache;\n}\n\nexport function getDbInstanceIds(): WeakMap<object, number> {\n if (!globalThis.__smrtRegistryDbInstanceIds) {\n globalThis.__smrtRegistryDbInstanceIds = new WeakMap<object, number>();\n }\n return globalThis.__smrtRegistryDbInstanceIds;\n}\n\nexport function getNextDbId(): number {\n if (globalThis.__smrtRegistryNextDbId === undefined) {\n globalThis.__smrtRegistryNextDbId = 1;\n }\n return globalThis.__smrtRegistryNextDbId;\n}\n\nexport function setNextDbId(value: number): void {\n globalThis.__smrtRegistryNextDbId = value;\n}\n\nexport function getFieldDecorators(): Map<\n string,\n Map<string, Record<string, unknown>>\n> {\n if (!globalThis.__smrtRegistryFieldDecorators) {\n globalThis.__smrtRegistryFieldDecorators = new Map<\n string,\n Map<string, Record<string, unknown>>\n >();\n }\n return globalThis.__smrtRegistryFieldDecorators;\n}\n\nexport function getStiSiblingsLoaded(): Set<string> {\n if (!globalThis.__smrtRegistryStiSiblingsLoaded) {\n globalThis.__smrtRegistryStiSiblingsLoaded = new Set<string>();\n }\n return globalThis.__smrtRegistryStiSiblingsLoaded;\n}\n\n// getClassNameMap removed in Release B (#1133). The eagerly-maintained\n// lowercase-simple-name → qualified-key[] index was replaced by on-demand\n// iteration over the `classes` Map in name-resolver.ts. Any remaining\n// consumer should switch to `findClassesByName`, `getCanonicalClassName`,\n// or `findClass`.\n\nexport function getSchemasInitialized(): WeakSet<object> {\n if (!globalThis.__smrtRegistrySchemasInitialized) {\n globalThis.__smrtRegistrySchemasInitialized = new WeakSet<object>();\n }\n return globalThis.__smrtRegistrySchemasInitialized;\n}\n\nexport function getConstructorIndex(): WeakMap<SmrtObjectConstructor, string> {\n if (!globalThis.__smrtRegistryConstructorIndex) {\n globalThis.__smrtRegistryConstructorIndex = new WeakMap<\n SmrtObjectConstructor,\n string\n >();\n }\n return globalThis.__smrtRegistryConstructorIndex;\n}\n\nexport function getInheritanceCache(): LRUCache<string, string[]> {\n if (!globalThis.__smrtRegistryInheritanceChainCache) {\n const config = getInheritanceConfig();\n globalThis.__smrtRegistryInheritanceChainCache = new LRUCache<\n string,\n string[]\n >(config.cacheSize);\n }\n return globalThis.__smrtRegistryInheritanceChainCache;\n}\n\nexport function getDiscoveryAttemptCache(): Map<string, boolean> {\n if (!globalThis.__smrtRegistryDiscoveryAttemptCache) {\n globalThis.__smrtRegistryDiscoveryAttemptCache = new Map<string, boolean>();\n }\n return globalThis.__smrtRegistryDiscoveryAttemptCache;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAyEA,IAAa,kBACX,QAAQ,IAAI,iBAAiB,WAC5B,QAAQ,IAAI,OAAO,SAAS,MAAM,KAAK;AAI1C,IAAM,SAAS,aAAa,EAAE,OAAO,kBAAkB,UAAU,OAAO,CAAC;;;;;;AAOzE,SAAgB,WAAW,GAAG,MAAuB;CACnD,IAAI,iBAAiB;EACnB,MAAM,CAAC,SAAS,GAAG,QAAQ;EAC3B,OAAO,MACL,OAAO,YAAY,WAAW,UAAU,OAAO,OAAO,GACtD,KAAK,SAAS,IAAI,EAAE,MAAM,KAAK,IAAI,KAAA,CACrC;CACF;AACF;;;;;AAMA,SAAgB,uBAAuB;CACrC,MAAM,SAAS,oBAAsC,QAAQ,CAAC,CAAC;CAC/D,OAAO;EACL,WAAW,OAAO,aAAa,aAAa;EAC5C,mBACE,OAAO,aAAa,qBAAsB;CAC9C;AACF;;;;;;;;;;AAWA,SAAgB,yBAA6C;CAG3D,MAAM,+BADQ,IADI,MACJ,EAAA,CAAM,SAAS,GAAA,CACJ,MAAM,IAAI;CAKnC,KAAK,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B;AAeA,SAAgB,sBAA8D;CAC5E,IAAI,CAAC,WAAW,gCACd,WAAW,iDAAiC,IAAI,QAG9C;CAEJ,OAAO,WAAW;AACpB;AAEA,SAAgB,sBAAkD;CAChE,IAAI,CAAC,WAAW,qCAAqC;EACnD,MAAM,SAAS,qBAAqB;EACpC,WAAW,sCAAsC,IAAI,SAGnD,OAAO,SAAS;CACpB;CACA,OAAO,WAAW;AACpB;AAEA,SAAgB,2BAAiD;CAC/D,IAAI,CAAC,WAAW,qCACd,WAAW,sDAAsC,IAAI,IAAqB;CAE5E,OAAO,WAAW;AACpB"}
1
+ {"version":3,"file":"shared-state.js","names":[],"sources":["../../src/registry/shared-state.ts"],"sourcesContent":["/**\n * Shared state accessors for the SMRT ObjectRegistry.\n *\n * All registry sub-modules share state via globalThis to ensure\n * cross-module consistency in monorepo environments.\n *\n * Extracted from registry.ts as part of issue #1006.\n * @see https://github.com/happyvertical/smrt/issues/1006\n * @see https://github.com/happyvertical/smrt/issues/543\n */\n\nimport { createLogger } from '@happyvertical/logger';\nimport type { SmrtCollection } from '../collection';\nimport {\n getSmrtModuleConfig,\n type SmrtGlobalConfig,\n} from '../config/global-config.js';\nimport type { SmrtObject } from '../object';\nimport { LRUCache } from '../utils/lru-cache';\nimport { isDecoratorRuntimeFramePath } from '../utils/stack-frames';\nimport type { RegisteredClass, SmrtObjectConstructor } from './types';\n\n// Re-export the globalThis augmentation so it's visible everywhere\ndeclare global {\n // eslint-disable-next-line no-var\n var __smrtRegistryClasses: Map<string, RegisteredClass> | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryCollections: Map<string, typeof SmrtCollection> | undefined;\n // eslint-disable-next-line no-var\n // Heterogeneous cache: stores collections of many different item types keyed\n // by class name. `SmrtCollection` is invariant in its item type (it has\n // `create(options: SmrtCreateInput<ModelType>)`), so this cannot be narrowed\n // to `SmrtCollection<SmrtObject>` — the type argument stays `any` (read sites\n // cast back to the concrete collection type).\n var __smrtRegistryCollectionCache:\n // biome-ignore lint/suspicious/noExplicitAny: heterogeneous cache keyed by class name; `SmrtCollection` is invariant in `ModelType` so the type arg cannot narrow to `SmrtObject` (read sites cast back). S4 #1579.\n | LRUCache<string, SmrtCollection<any>>\n | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryDbInstanceIds: WeakMap<object, number> | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryNextDbId: number | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryInheritanceChainCache:\n | LRUCache<string, string[]>\n | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryFieldDecorators:\n | Map<string, Map<string, Record<string, unknown>>>\n | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryStiSiblingsLoaded: Set<string> | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryCollectionTableNames: Map<string, string> | undefined;\n // Release B (#1133) removed __smrtRegistryClassNameMap — case-insensitive\n // lookups now iterate the `classes` Map directly. The globalThis slot is\n // left undeclared so any leftover code that reaches for it gets a clean\n // TS error instead of silently stale data.\n // eslint-disable-next-line no-var\n var __smrtRegistrySchemasInitialized: WeakSet<object> | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryConstructorIndex:\n | WeakMap<SmrtObjectConstructor, string>\n | undefined;\n // eslint-disable-next-line no-var\n var __smrtRegistryDiscoveryAttemptCache: Map<string, boolean> | undefined;\n}\n\n/**\n * Cached verbose flag evaluated once at module load time.\n * Checks SMRT_VERBOSE=true or DEBUG containing 'smrt'.\n * Avoids repeated env var parsing on every log statement.\n * @see https://github.com/happyvertical/smrt/issues/782\n */\nexport const VERBOSE_ENABLED =\n process.env.SMRT_VERBOSE === 'true' ||\n (process.env.DEBUG?.includes('smrt') ?? false);\n\n// verboseLog() is gated by VERBOSE_ENABLED, so the level must allow debug when\n// it's set (a fixed 'info' would filter the trace out and break SMRT_VERBOSE).\nconst logger = createLogger({ level: VERBOSE_ENABLED ? 'debug' : 'info' });\n\n/**\n * Log a message only when verbose mode is enabled.\n * Used throughout registry modules to reduce noise during normal operation.\n * @param args - Arguments to pass to console.log\n */\nexport function verboseLog(...args: unknown[]): void {\n if (VERBOSE_ENABLED) {\n const [message, ...rest] = args;\n logger.debug(\n typeof message === 'string' ? message : String(message),\n rest.length > 0 ? { args: rest } : undefined,\n );\n }\n}\n\n/**\n * Get inheritance config synchronously.\n * Uses the config package's sync accessor which returns already-loaded config.\n */\nexport function getInheritanceConfig() {\n const config = getSmrtModuleConfig<SmrtGlobalConfig>('smrt', {});\n return {\n cacheSize: config.inheritance?.cacheSize ?? 200,\n onMissingAncestor:\n config.inheritance?.onMissingAncestor ?? ('warn' as 'warn' | 'error'),\n };\n}\n\n/**\n * Extract the source file path from the call stack.\n *\n * Used to identify where a class was defined for collision detection.\n * This allows the same class to be re-registered when modules are re-evaluated\n * (e.g., during vitest test file collection with isolation enabled).\n *\n * Frames from decorator-lowering runtime helpers (`@oxc-project/runtime` under\n * Vite 8, `tslib`/`@swc/helpers`/`@babel/runtime` elsewhere) are skipped too, so\n * the lowered `@smrt()` application resolves to the consumer module that declares\n * the class rather than the helper frame the compiler inserted (#1785).\n *\n * @param stackOverride - Optional stack string to parse instead of a fresh\n * `Error().stack`. Used by tests to simulate a lowered call pattern.\n * @returns The file path where the @smrt() decorator was called, or undefined\n */\nexport function getSourceFileFromStack(\n stackOverride?: string,\n): string | undefined {\n const stack = stackOverride ?? new Error().stack ?? '';\n const stackLines = stack.split('\\n');\n\n // Look for the first file path that's NOT from smrt-core internal files\n // Stack trace format: \" at FunctionName (file:///path/to/file.ts:line:col)\"\n // or \" at file:///path/to/file.ts:line:col\"\n for (const line of stackLines) {\n // Match file paths in stack trace (include all JS/TS file extensions)\n const fileMatch = line.match(\n /(?:file:\\/\\/)?([^)\\s]+\\.(?:js|ts|mjs|mts|jsx|tsx|cjs|cts))(?::\\d+:\\d+)?/,\n );\n if (fileMatch) {\n const rawPath = fileMatch[1];\n // Normalize the path:\n // - remove any leading file:// or file:/// prefix\n // - convert Windows backslashes to POSIX-style forward slashes\n const normalizedPath = rawPath\n .replace(/^file:\\/+/, '')\n .replace(/\\\\/g, '/');\n const lowerPath = normalizedPath.toLowerCase();\n\n // Skip smrt-core internal files using specific path patterns\n // to avoid false positives with user files containing \"registry\" in name\n if (\n // Installed package form: node_modules/@happyvertical/smrt-core/...\n lowerPath.includes('/node_modules/@happyvertical/smrt-core/') ||\n // Monorepo/workspace form: packages/core/src/...\n (lowerPath.includes('/packages/core/src/') &&\n !lowerPath.includes('__tests__')) ||\n // Specific manifest loader internals\n lowerPath.includes('/manifest/manifest-loader') ||\n // Decorator-lowering runtime helper (oxc/tslib/swc/babel) — the frame\n // the compiler inserts between @smrt() and the declaring module (#1785)\n isDecoratorRuntimeFramePath(normalizedPath)\n ) {\n continue;\n }\n return normalizedPath;\n }\n }\n return undefined;\n}\n\n// ── Shared state accessor functions ──────────────────────────────────────\n\nexport function getClasses(): Map<string, RegisteredClass> {\n if (!globalThis.__smrtRegistryClasses) {\n globalThis.__smrtRegistryClasses = new Map<string, RegisteredClass>();\n }\n return globalThis.__smrtRegistryClasses;\n}\n\nexport function getCollections(): Map<string, typeof SmrtCollection> {\n if (!globalThis.__smrtRegistryCollections) {\n globalThis.__smrtRegistryCollections = new Map<\n string,\n typeof SmrtCollection\n >();\n }\n return globalThis.__smrtRegistryCollections;\n}\n\nexport function getCollectionTableNames(): Map<string, string> {\n if (!globalThis.__smrtRegistryCollectionTableNames) {\n globalThis.__smrtRegistryCollectionTableNames = new Map<string, string>();\n }\n return globalThis.__smrtRegistryCollectionTableNames;\n}\n\n// biome-ignore lint/suspicious/noExplicitAny: heterogeneous cache; `SmrtCollection` is invariant in `ModelType` so the type arg cannot narrow to `SmrtObject` (read sites cast back). S4 #1579.\nexport function getCollectionCache(): LRUCache<string, SmrtCollection<any>> {\n if (!globalThis.__smrtRegistryCollectionCache) {\n globalThis.__smrtRegistryCollectionCache = new LRUCache<\n string,\n // biome-ignore lint/suspicious/noExplicitAny: same heterogeneous-cache invariance as the return type above. S4 #1579.\n SmrtCollection<any>\n >(100);\n }\n return globalThis.__smrtRegistryCollectionCache;\n}\n\nexport function getDbInstanceIds(): WeakMap<object, number> {\n if (!globalThis.__smrtRegistryDbInstanceIds) {\n globalThis.__smrtRegistryDbInstanceIds = new WeakMap<object, number>();\n }\n return globalThis.__smrtRegistryDbInstanceIds;\n}\n\nexport function getNextDbId(): number {\n if (globalThis.__smrtRegistryNextDbId === undefined) {\n globalThis.__smrtRegistryNextDbId = 1;\n }\n return globalThis.__smrtRegistryNextDbId;\n}\n\nexport function setNextDbId(value: number): void {\n globalThis.__smrtRegistryNextDbId = value;\n}\n\nexport function getFieldDecorators(): Map<\n string,\n Map<string, Record<string, unknown>>\n> {\n if (!globalThis.__smrtRegistryFieldDecorators) {\n globalThis.__smrtRegistryFieldDecorators = new Map<\n string,\n Map<string, Record<string, unknown>>\n >();\n }\n return globalThis.__smrtRegistryFieldDecorators;\n}\n\nexport function getStiSiblingsLoaded(): Set<string> {\n if (!globalThis.__smrtRegistryStiSiblingsLoaded) {\n globalThis.__smrtRegistryStiSiblingsLoaded = new Set<string>();\n }\n return globalThis.__smrtRegistryStiSiblingsLoaded;\n}\n\n// getClassNameMap removed in Release B (#1133). The eagerly-maintained\n// lowercase-simple-name → qualified-key[] index was replaced by on-demand\n// iteration over the `classes` Map in name-resolver.ts. Any remaining\n// consumer should switch to `findClassesByName`, `getCanonicalClassName`,\n// or `findClass`.\n\nexport function getSchemasInitialized(): WeakSet<object> {\n if (!globalThis.__smrtRegistrySchemasInitialized) {\n globalThis.__smrtRegistrySchemasInitialized = new WeakSet<object>();\n }\n return globalThis.__smrtRegistrySchemasInitialized;\n}\n\nexport function getConstructorIndex(): WeakMap<SmrtObjectConstructor, string> {\n if (!globalThis.__smrtRegistryConstructorIndex) {\n globalThis.__smrtRegistryConstructorIndex = new WeakMap<\n SmrtObjectConstructor,\n string\n >();\n }\n return globalThis.__smrtRegistryConstructorIndex;\n}\n\nexport function getInheritanceCache(): LRUCache<string, string[]> {\n if (!globalThis.__smrtRegistryInheritanceChainCache) {\n const config = getInheritanceConfig();\n globalThis.__smrtRegistryInheritanceChainCache = new LRUCache<\n string,\n string[]\n >(config.cacheSize);\n }\n return globalThis.__smrtRegistryInheritanceChainCache;\n}\n\nexport function getDiscoveryAttemptCache(): Map<string, boolean> {\n if (!globalThis.__smrtRegistryDiscoveryAttemptCache) {\n globalThis.__smrtRegistryDiscoveryAttemptCache = new Map<string, boolean>();\n }\n return globalThis.__smrtRegistryDiscoveryAttemptCache;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA0EA,IAAa,kBACX,QAAQ,IAAI,iBAAiB,WAC5B,QAAQ,IAAI,OAAO,SAAS,MAAM,KAAK;AAI1C,IAAM,SAAS,aAAa,EAAE,OAAO,kBAAkB,UAAU,OAAO,CAAC;;;;;;AAOzE,SAAgB,WAAW,GAAG,MAAuB;CACnD,IAAI,iBAAiB;EACnB,MAAM,CAAC,SAAS,GAAG,QAAQ;EAC3B,OAAO,MACL,OAAO,YAAY,WAAW,UAAU,OAAO,OAAO,GACtD,KAAK,SAAS,IAAI,EAAE,MAAM,KAAK,IAAI,KAAA,CACrC;CACF;AACF;;;;;AAMA,SAAgB,uBAAuB;CACrC,MAAM,SAAS,oBAAsC,QAAQ,CAAC,CAAC;CAC/D,OAAO;EACL,WAAW,OAAO,aAAa,aAAa;EAC5C,mBACE,OAAO,aAAa,qBAAsB;CAC9C;AACF;;;;;;;;;;;;;;;;;AAkBA,SAAgB,uBACd,eACoB;CAEpB,MAAM,cADQ,kCAAiB,IAAI,MAAM,EAAA,CAAE,SAAS,GAAA,CAC3B,MAAM,IAAI;CAKnC,KAAK,MAAM,QAAQ,YAAY;EAE7B,MAAM,YAAY,KAAK,MACrB,yEACF;EACA,IAAI,WAAW;GAKb,MAAM,iBAJU,UAAU,EAIH,CACpB,QAAQ,aAAa,EAAE,CAAC,CACxB,QAAQ,OAAO,GAAG;GACrB,MAAM,YAAY,eAAe,YAAY;GAI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,SAAS,qBAAqB;EACpC,WAAW,sCAAsC,IAAI,SAGnD,OAAO,SAAS;CACpB;CACA,OAAO,WAAW;AACpB;AAEA,SAAgB,2BAAiD;CAC/D,IAAI,CAAC,WAAW,qCACd,WAAW,sDAAsC,IAAI,IAAqB;CAE5E,OAAO,WAAW;AACpB"}
@@ -128,6 +128,40 @@ export interface ApiConfig {
128
128
  * fields are always stripped to prevent mass-assignment.
129
129
  */
130
130
  writable?: string[];
131
+ /**
132
+ * HTTP cache policy for generated read (`list`/`get`) responses (#1757).
133
+ *
134
+ * Generated reads always carry a strong body-hash ETag and honor
135
+ * `If-None-Match` with `304 Not Modified`. By default they are served
136
+ * `Cache-Control: private, no-cache` — browsers may store them but must
137
+ * revalidate, and shared caches never store them.
138
+ *
139
+ * Distinct from the top-level `@smrt({ cache })` knob, which configures the
140
+ * server-side collection read-through cache (#1499).
141
+ */
142
+ cache?: ApiHttpCacheConfig;
143
+ }
144
+ /**
145
+ * HTTP caching knob for generated read routes (#1757).
146
+ */
147
+ export interface ApiHttpCacheConfig {
148
+ /**
149
+ * Opt-in shared-cache TTL, in seconds, for generated read responses:
150
+ * emits `Cache-Control: public, max-age=0, s-maxage=<n>` so CDNs/shared
151
+ * caches may serve reads for `n` seconds while browsers still revalidate.
152
+ *
153
+ * Only honored when the model's reads are public (`public: true` or
154
+ * `public: 'read'`); non-public models never emit shared-cache headers.
155
+ * Values that are not positive finite numbers are ignored.
156
+ *
157
+ * Tenant-scoped models (`@smrt({ tenantScoped })` or `@TenantScoped()`,
158
+ * ANY mode including `'optional'`) never emit shared-cache headers either:
159
+ * their response bodies vary with the session-cookie tenant context, which
160
+ * URL-keyed shared caches cannot see, so honoring `sMaxage` would serve one
161
+ * tenant's rows to other tenants or anonymous visitors. The knob is
162
+ * neutralized to `private, no-cache` with a one-time warning.
163
+ */
164
+ sMaxage?: number;
131
165
  }
132
166
  export interface ReportConfig {
133
167
  source: string | Function;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.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AAC;IAC5B,mFAAmF;IACnF,eAAe,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,eAAe,CAAC,CAAC;IAC/C,qFAAqF;IACrF,gBAAgB,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC,CAAC;IACjD,2DAA2D;IAC3D,kBAAkB,CAAC,EAAE;QACnB,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;QAC9B,KAAK,EAAE,MAAM,CAAC;QACd,UAAU,EAAE,OAAO,CAAC;QACpB,YAAY,EAAE,OAAO,CAAC;QACtB,qBAAqB,EAAE,OAAO,CAAC;KAChC,CAAC;IACF;;;;;OAKG;IACH,UAAU,CAAC,EAAE,cAAc,CAAC;CAC7B"}
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "schemaVersion": 1,
3
- "generatedAt": "2026-07-02T02:37:12.299Z",
3
+ "generatedAt": "2026-07-03T06:22:21.290Z",
4
4
  "packageName": "@happyvertical/smrt-core",
5
- "packageVersion": "0.37.6",
5
+ "packageVersion": "0.37.8",
6
6
  "sourceManifestPath": "dist/manifest.json",
7
7
  "agentDocPath": "AGENTS.md",
8
8
  "sourceHashes": {
9
- "manifest": "a248a5d611e1ce8c545863aa4b518ac797017c1c7fcc9a0f2fc374763f14d466",
10
- "packageJson": "e76b922f1df5d6d04e6b0601db5d1319ab0b60bb6dcde1ed38957178f0aad213",
11
- "agents": "0fa157a078aa44a0bc104540bd27f0b1e52e66549b7994cba751438a8d44c827"
9
+ "manifest": "6eb936bc13c04bf302820a0f448401920e94bc0c83d202cf938c1cc995dfb031",
10
+ "packageJson": "d9ca665cf6cd288680ab2375245af2978934a8456dbc55ac6cc82dec15309882",
11
+ "agents": "30b544c7ce9bfc7680b4c6ac001076f245816b2a5c379afc88e6c6c218a82ac9"
12
12
  },
13
13
  "exports": [
14
14
  ".",
@@ -252,6 +252,7 @@
252
252
  "recall",
253
253
  "recallAll",
254
254
  "remember",
255
+ "requireInsertOnSave",
255
256
  "save",
256
257
  "toJSON",
257
258
  "toPlainObject",
@@ -322,5 +323,5 @@
322
323
  "polymorphicAssociations": 1,
323
324
  "uuidColumns": 3
324
325
  },
325
- "agentDoc": "# @happyvertical/smrt-core\n\nORM, code generation, AI integration, and the DispatchBus. Everything else builds on this.\n\n## Key Classes\n\n| Class | File | Purpose |\n|-------|------|---------|\n| SmrtObject | `src/object.ts` | Base persistent object — save, delete, is(), do(), loadFromId/Slug |\n| SmrtCollection | `src/collection.ts` | CRUD collection — list, get, create, delete, getOrUpsert |\n| ObjectRegistry | `src/registry.ts` | Global singleton (globalThis) — class metadata, fields, STI chains, manifests |\n| DispatchBus | `src/dispatch/bus.ts` | Inter-agent messaging — emit, subscribe (persistent), process |\n| GlobalInterceptors | `src/interceptors.ts` | Plugin system — beforeList/Get/Save/Delete hooks (used by tenancy) |\n\n## SmrtObject Lifecycle\n\n`constructor(options)` → `initialize()` → ready for `save()`/`delete()`/`loadFromId()`\n\n- `initialize()`: loads field initializers, applies option values (options override initializers), loads from DB if id/slug provided\n- `save()`: upsert with STI validation, interceptor execution, auto-embeddings. Persisted objects (`isPersisted` — set by DB hydration and successful saves) upsert on `['id']` so natural-key edits (e.g. slug renames) update in place; new objects upsert on the natural-key conflict columns for ingestion-style dedup (#1472)\n- `is(criteria)` / `do(instructions)` / `describe()`: AI operations via function calling. They inject the object's own `toPublicJSON()` (sensitive fields stripped) as a \"content body\" so the model reasons over the instance. Options: `includeData: false` skips injection (for callers that already curate the relevant fields into the instruction); `maxDataLength` overrides the truncation budget. Neither key is forwarded to `ai.message()`. (#1567)\n- `getSlug()`: auto-generates from name → title → label → id\n- `loadRelated(fieldName)`: lazy-loads relationships (cached in `_loadedRelationships` Map)\n\n## SmrtCollection Query\n\n```typescript\nawait collection.list({\n where: { status: 'active', price: { op: '>', value: 10 } },\n limit: 50, offset: 0, orderBy: 'created_at DESC'\n});\n```\n\n**WHERE operators**: `=`, `>`, `<`, `>=`, `<=`, `!=`, `in`, `not in`, `like`, `is null`, `is not null`. Arrays auto-detect `IN`. Dot notation for JSON paths: `metadata.userId`.\n\nSTI child collections auto-filter by `_meta_type`.\n\n## @smrt() Decorator Options\n\nKey options: `tableName`, `tableStrategy` ('cti'|'sti'), `conflictColumns`, `api`/`mcp`/`cli` (generation config), `ai` (callable methods), `hooks` (beforeSave/afterSave/beforeDelete/afterDelete), `embeddings` (auto-generate), `tenantScoped`, `agent`.\n\nRegistration sets `SMRT_TABLE_NAME` static property (survives minification).\n\n## Domain Knowledge Artifacts\n\n`smrtPlugin()` writes runtime manifests and agent/developer knowledge artifacts:\n\n- local dev/build: `.smrt/manifest.json` and `.smrt/smrt-knowledge.json`\n- package build: `dist/manifest.json` and `dist/smrt-knowledge.json`\n\nKeep `manifest.json` runtime-focused. `smrt-knowledge.json` is the deterministic\nagent contract for downstream review and architecture tools.\n\nConfig precedence for knowledge is defaults → top-level `knowledge` in\n`smrt.config.ts` → `packages[packageName].knowledge` → plugin option →\nobject-level `@smrt({ knowledge })`.\n\nObject-level `knowledge: false` excludes an object from authored context only;\nit must not change runtime manifest registration. Use\n`knowledge: { tags, summary, risks }` for review-sensitive domain objects.\n\nHTTP knowledge routes are disabled by default. If `knowledge.api.enabled` is\ntrue, generated SvelteKit routes must stay GET-only and guarded by dev mode or\nadmin auth.\n\n## DispatchBus\n\n- `emit(signalType, payload, metadata)` → creates persistent Dispatch record\n- `on(pattern, handler)` → in-memory handler (immediate)\n- `subscribe({ signalType, subscriber })` → persistent subscription (survives restarts)\n- `process(subscriberName, handler)` → process pending dispatches\n- Wildcards: `campaign.*` matches `campaign.completed` (single segment only)\n- Tables: `_smrt_dispatch`, `_smrt_dispatch_subscriptions`\n- Status: `pending → processing → completed` (or `failed`)\n\n## Single Table Inheritance (STI)\n\n- Base: `@smrt({ tableStrategy: 'sti' })` — children inherit, share one table\n- Discriminator: `_meta_type` column with qualified names (`@happyvertical/smrt-content:Article`)\n- Child fields: `@meta()` decorator → stored in `_meta_data` JSONB (not as columns)\n- Polymorphic queries: collection loads `_meta_type`, creates correct subclass dynamically\n- Validation: fail-fast on save if `_meta_type` missing or mismatched\n\n## Code Generators\n\n| Generator | Location | Output |\n|-----------|----------|--------|\n| REST API | `src/generators/rest.ts` | OpenAPI-compliant CRUD endpoints |\n| CLI | `src/generators/cli.ts` | `objectname:action` admin commands — writable allowlist, exhaustive-include, `--from-file`, fail-closed tenant context |\n| MCP Server | `src/generators/mcp.ts` | Model Context Protocol tools |\n\n## Child Accessors (R10)\n\n`src/child-accessors.ts` installs a consistent `get<FieldName>()` instance method for every `@oneToMany` field at `@smrt()` registration time (e.g. `@oneToMany('OrderItem') items` → `order.getItems()`), delegating to `loadRelatedMany`. Two invariants:\n\n- **Additive** — never overwrites a hand-rolled method of the same name (checks the whole prototype chain). `Profile.getMetadata()` (key-value) and `ProfileRelationship.getTerms()` are preserved.\n- **Runtime-only** — attached to the prototype, invisible to the build-time manifest, so it never leaks into the REST/CLI/MCP surface.\n\nWhen the target declares multiple FKs back to the parent, annotate `@oneToMany(Target, { foreignKey: '<inverseField>' })`; `loadRelatedMany` and the eager `include:` loader both honor it (else first-match).\n\n## Vite Plugin\n\n```typescript\n// vite.config.ts — required for @smrt() decorators\nexport default defineConfig({\n esbuild: {\n tsconfigRaw: {\n compilerOptions: { experimentalDecorators: true, emitDecoratorMetadata: true }\n }\n }\n});\n```\n\n## Gotchas\n\n- **Never override toJSON()** — handles STI discriminator + meta field extraction. Use `transformJSON()`\n- **Property init order**: TypeScript initializers run first, then `initialize()` applies option values (options win)\n- **No runtime schema creation**: application tables must be prepared explicitly via migrations/tooling; runtime only verifies and fails clearly\n- **Retry logic**: `db.get()` (3 retries, 250ms) and `db.upsert()` (3 retries, 500ms) have built-in retry\n- **Field caching**: `_cachedFields` populated during `Collection.create()` — eliminates async `getFields()` per query\n- **Smart cloning**: arrays/objects shallow-cloned in property init to prevent aliasing (Issue #22)\n- **Table verification cache**: `isTableVerified(dbUrl, tableName)` avoids redundant `tableExists()` calls\n- **Manifest required**: build-time AST scanning creates manifest. Without vitest plugin → \"No field metadata\"\n- **Vite plugin loads scanner from `dist/` first**: `src/vite-plugin/import-build-aware.ts` prefers `dist/` when it exists on disk; it only falls back to `src/` on fresh clones. So if you edit `src/scanner/*.ts` or `src/schema/generator.ts` and want those edits reflected in consumer manifest generation, you must rebuild (`pnpm build` or have `pnpm dev` / `pnpm build:watch` running in core). This is intentional — sniffing `.ts` vs `.js` via `import.meta.url` was non-deterministic under tsx and broke 12–13 publishes (#1139).\n"
326
+ "agentDoc": "# @happyvertical/smrt-core\n\nORM, code generation, AI integration, and the DispatchBus. Everything else builds on this.\n\n## Key Classes\n\n| Class | File | Purpose |\n|-------|------|---------|\n| SmrtObject | `src/object.ts` | Base persistent object — save, delete, is(), do(), loadFromId/Slug |\n| SmrtCollection | `src/collection.ts` | CRUD collection — list, get, create, delete, getOrUpsert |\n| ObjectRegistry | `src/registry.ts` | Global singleton (globalThis) — class metadata, fields, STI chains, manifests |\n| DispatchBus | `src/dispatch/bus.ts` | Inter-agent messaging — emit, subscribe (persistent), process |\n| GlobalInterceptors | `src/interceptors.ts` | Plugin system — beforeList/Get/Save/Delete hooks (used by tenancy) |\n\n## SmrtObject Lifecycle\n\n`constructor(options)` → `initialize()` → ready for `save()`/`delete()`/`loadFromId()`\n\n- `initialize()`: loads field initializers, applies option values (options override initializers), loads from DB if id/slug provided\n- `save()`: upsert with STI validation, interceptor execution, auto-embeddings. Persisted objects (`isPersisted` — set by DB hydration and successful saves) upsert on `['id']` so natural-key edits (e.g. slug renames) update in place; new objects upsert on the natural-key conflict columns for ingestion-style dedup (#1472)\n- `is(criteria)` / `do(instructions)` / `describe()`: AI operations via function calling. They inject the object's own `toPublicJSON()` (sensitive fields stripped) as a \"content body\" so the model reasons over the instance. Options: `includeData: false` skips injection (for callers that already curate the relevant fields into the instruction); `maxDataLength` overrides the truncation budget. Neither key is forwarded to `ai.message()`. (#1567)\n- `getSlug()`: auto-generates from name → title → label → id\n- `loadRelated(fieldName)`: lazy-loads relationships (cached in `_loadedRelationships` Map)\n\n## SmrtCollection Query\n\n```typescript\nawait collection.list({\n where: { status: 'active', price: { op: '>', value: 10 } },\n limit: 50, offset: 0, orderBy: 'created_at DESC'\n});\n```\n\n**WHERE operators**: `=`, `>`, `<`, `>=`, `<=`, `!=`, `in`, `not in`, `like`, `is null`, `is not null`. Arrays auto-detect `IN`. Dot notation for JSON paths: `metadata.userId`.\n\nSTI child collections auto-filter by `_meta_type`.\n\n## @smrt() Decorator Options\n\nKey options: `tableName`, `tableStrategy` ('cti'|'sti'), `conflictColumns`, `api`/`mcp`/`cli` (generation config), `ai` (callable methods), `hooks` (beforeSave/afterSave/beforeDelete/afterDelete), `embeddings` (auto-generate), `tenantScoped`, `agent`.\n\nRegistration sets `SMRT_TABLE_NAME` static property (survives minification).\n\n## Domain Knowledge Artifacts\n\n`smrtPlugin()` writes runtime manifests and agent/developer knowledge artifacts:\n\n- local dev/build: `.smrt/manifest.json` and `.smrt/smrt-knowledge.json`\n- package build: `dist/manifest.json` and `dist/smrt-knowledge.json`\n\nKeep `manifest.json` runtime-focused. `smrt-knowledge.json` is the deterministic\nagent contract for downstream review and architecture tools.\n\nConfig precedence for knowledge is defaults → top-level `knowledge` in\n`smrt.config.ts` → `packages[packageName].knowledge` → plugin option →\nobject-level `@smrt({ knowledge })`.\n\nObject-level `knowledge: false` excludes an object from authored context only;\nit must not change runtime manifest registration. Use\n`knowledge: { tags, summary, risks }` for review-sensitive domain objects.\n\nHTTP knowledge routes are disabled by default. If `knowledge.api.enabled` is\ntrue, generated SvelteKit routes must stay GET-only and guarded by dev mode or\nadmin auth.\n\n## DispatchBus\n\n- `emit(signalType, payload, metadata)` → creates persistent Dispatch record\n- `on(pattern, handler)` → in-memory handler (immediate)\n- `subscribe({ signalType, subscriber })` → persistent subscription (survives restarts)\n- `process(subscriberName, handler)` → process pending dispatches\n- Wildcards: `campaign.*` matches `campaign.completed` (single segment only)\n- Tables: `_smrt_dispatch`, `_smrt_dispatch_subscriptions`\n- Status: `pending → processing → completed` (or `failed`)\n\n## Single Table Inheritance (STI)\n\n- Base: `@smrt({ tableStrategy: 'sti' })` — children inherit, share one table\n- Discriminator: `_meta_type` column with qualified names (`@happyvertical/smrt-content:Article`)\n- Child fields: `@meta()` decorator → stored in `_meta_data` JSONB (not as columns)\n- Polymorphic queries: collection loads `_meta_type`, creates correct subclass dynamically\n- Validation: fail-fast on save if `_meta_type` missing or mismatched\n\n## Code Generators\n\n| Generator | Location | Output |\n|-----------|----------|--------|\n| REST API | `src/generators/rest.ts` | OpenAPI-compliant CRUD endpoints |\n| CLI | `src/generators/cli.ts` | `objectname:action` admin commands — writable allowlist, exhaustive-include, `--from-file`, fail-closed tenant context |\n| MCP Server | `src/generators/mcp.ts` | Model Context Protocol tools |\n\nGenerated reads (`list`/`get`) on the REST and SvelteKit generators support conditional GET (#1757, helpers in `src/generators/conditional-get.ts`): strong body-hash ETag, `If-None-Match` → 304 with an empty body, `private, no-cache` by default. Public models may opt into shared caching via `@smrt({ api: { public: true | 'read', cache: { sMaxage } } })` → `public, max-age=0, s-maxage=<n>`; non-public models never emit shared-cache headers. Tenant-scoped models (any mode) never emit them either — bodies vary with session-cookie tenant context that URL-keyed shared caches cannot see; `sMaxage` is neutralized to `private, no-cache` with a one-time warning.\n\n## Child Accessors (R10)\n\n`src/child-accessors.ts` installs a consistent `get<FieldName>()` instance method for every `@oneToMany` field at `@smrt()` registration time (e.g. `@oneToMany('OrderItem') items` → `order.getItems()`), delegating to `loadRelatedMany`. Two invariants:\n\n- **Additive** — never overwrites a hand-rolled method of the same name (checks the whole prototype chain). `Profile.getMetadata()` (key-value) and `ProfileRelationship.getTerms()` are preserved.\n- **Runtime-only** — attached to the prototype, invisible to the build-time manifest, so it never leaks into the REST/CLI/MCP surface.\n\nWhen the target declares multiple FKs back to the parent, annotate `@oneToMany(Target, { foreignKey: '<inverseField>' })`; `loadRelatedMany` and the eager `include:` loader both honor it (else first-match).\n\n## Vite Plugin\n\n```typescript\n// vite.config.ts — required for @smrt() decorators (Vite 8+, oxc transform)\nexport default defineConfig({\n oxc: {\n decorator: {\n legacy: true,\n emitDecoratorMetadata: true,\n },\n },\n});\n```\n\nUnder Vite 8 the oxc transform does not honor the pre-Vite-8 `esbuild.tsconfigRaw`\nrecipe (or tsconfig `experimentalDecorators` reached through SvelteKit's\n`extends \"./.svelte-kit/tsconfig.json\"` chain), so that recipe throws\n`SyntaxError: Invalid or unexpected token` on the first SSR request. Configure\ndecorators through `oxc.decorator` instead. Consumers still pinned on vite<8 need\nthe legacy `esbuild.tsconfigRaw` form with `experimentalDecorators: true,\nemitDecoratorMetadata: true`.\n\n## Gotchas\n\n- **Never override toJSON()** — handles STI discriminator + meta field extraction. Use `transformJSON()`\n- **Property init order**: TypeScript initializers run first, then `initialize()` applies option values (options win)\n- **No runtime schema creation**: application tables must be prepared explicitly via migrations/tooling; runtime only verifies and fails clearly\n- **Retry logic**: `db.get()` (3 retries, 250ms) and `db.upsert()` (3 retries, 500ms) have built-in retry\n- **Field caching**: `_cachedFields` populated during `Collection.create()` — eliminates async `getFields()` per query\n- **Smart cloning**: arrays/objects shallow-cloned in property init to prevent aliasing (Issue #22)\n- **Table verification cache**: `isTableVerified(dbUrl, tableName)` avoids redundant `tableExists()` calls\n- **Manifest required**: build-time AST scanning creates manifest. Without vitest plugin → \"No field metadata\"\n- **Vite plugin loads scanner from `dist/` first**: `src/vite-plugin/import-build-aware.ts` prefers `dist/` when it exists on disk; it only falls back to `src/` on fresh clones. So if you edit `src/scanner/*.ts` or `src/schema/generator.ts` and want those edits reflected in consumer manifest generation, you must rebuild (`pnpm build` or have `pnpm dev` / `pnpm build:watch` running in core). This is intentional — sniffing `.ts` vs `.js` via `import.meta.url` was non-deterministic under tsx and broke 12–13 publishes (#1139).\n"
326
327
  }
@@ -0,0 +1,234 @@
1
+ /**
2
+ * Idempotent sync-apply batch processing (#1759).
3
+ *
4
+ * The single shared write contract for the web offline outbox (#1762) and the
5
+ * KMP mobile write queue (#1739): an ordered batch of client-authored
6
+ * mutations carrying client-generated row UUIDs, applied FIFO through the
7
+ * host's full stack (authentication, tenant isolation, interceptors, writable
8
+ * policy), returning per-item results (`applied` / `conflict` / `rejected`).
9
+ *
10
+ * This module is transport-agnostic: the runtime REST generator
11
+ * (`generators/rest.ts`) and the generated SvelteKit route
12
+ * (`vite-plugin/sync-apply-route.ts`) both delegate here, supplying a
13
+ * {@link SyncApplyHost} that adapts their own collection resolution,
14
+ * authorization, and writable-policy machinery. Keeping the logic here keeps
15
+ * the two generators byte-minimal and the contract single-sourced.
16
+ *
17
+ * Contract documentation: docs/content/architecture/sync-apply-contract.md
18
+ *
19
+ * ## Why replay is idempotent
20
+ *
21
+ * - Row identity is the client-generated UUID (validated server-side), and
22
+ * ONLY that UUID: creates persist via a strict INSERT
23
+ * (`_insertOnly`, never natural-key dedup-upsert), so a create can never
24
+ * adopt or overwrite a different row, and a re-delivered create finds its
25
+ * own row via the id pre-check instead of duplicating it.
26
+ * - Before writing, each create/update is compared against the current row;
27
+ * when the row already reflects the item's payload the write is skipped and
28
+ * reported `applied` (a no-op re-apply). This is what makes N replays of an
29
+ * identical batch yield byte-identical database state (no `updated_at`
30
+ * churn) AND identical per-item results, without a server-side idempotency
31
+ * ledger.
32
+ * - Deletes of rows that are already gone report `applied` consistently.
33
+ *
34
+ * ## Conflict policy v1 (server-authoritative LWW, updated-at guard)
35
+ *
36
+ * The stale guard applies to mutations that would actually change server
37
+ * state: an update/delete whose `baseUpdatedAt` is older than the server
38
+ * row's `updated_at` AND whose effect is not already present is the LOSING
39
+ * write — it is **skipped** (the newer server state wins) and the item is
40
+ * reported `conflict` with the server's current `updatedAt` so the client can
41
+ * rebase. Two deliberate precedences soften "stale ⇒ conflict":
42
+ * no-op detection runs first (a stale update whose payload already matches
43
+ * the row is an idempotent replay of an applied write → `applied`), and a
44
+ * delete of a row that is already gone is a no-op → `applied`. Skipping
45
+ * (rather than clobbering) was chosen because it never destroys newer data,
46
+ * and it is replay-stable: a replayed conflicting item reports `conflict`
47
+ * again against unchanged state. Field-level merge is explicitly out of
48
+ * scope for v1.
49
+ */
50
+ /**
51
+ * URL segments of the generated batch apply endpoint, relative to the API
52
+ * base path: `POST {basePath}/sync/apply`. The `sync` segment is reserved —
53
+ * a collection named `sync` cannot expose an item route named `apply`.
54
+ */
55
+ export declare const SYNC_APPLY_ROUTE_SEGMENTS: readonly ["sync", "apply"];
56
+ /** Maximum items accepted in one batch; larger batches are rejected (400). */
57
+ export declare const MAX_SYNC_APPLY_BATCH_SIZE = 1000;
58
+ /**
59
+ * Client-generated row ids must be well-formed UUIDs. Same shape the ORM
60
+ * accepts as an id filter in `SmrtCollection.get()`.
61
+ */
62
+ export declare const SYNC_APPLY_UUID_PATTERN: RegExp;
63
+ /** Mutation kinds accepted by the batch apply endpoint. */
64
+ export type SyncApplyOp = 'create' | 'update' | 'delete';
65
+ /** Per-item outcome status. */
66
+ export type SyncApplyStatus = 'applied' | 'conflict' | 'rejected';
67
+ /** Machine-readable reasons for `rejected` items. */
68
+ export type SyncApplyRejectionReason = 'invalid_item' | 'invalid_id' | 'invalid_payload' | 'unknown_object' | 'op_not_allowed' | 'auth_required' | 'forbidden' | 'not_found' | 'id_conflict' | 'write_failed';
69
+ /** Machine-readable reasons for `conflict` items. */
70
+ export type SyncApplyConflictReason = 'stale_write' | 'create_conflict';
71
+ export type SyncApplyReason = SyncApplyRejectionReason | SyncApplyConflictReason;
72
+ /**
73
+ * One client-authored mutation in a batch. See the contract doc for field
74
+ * semantics; briefly:
75
+ *
76
+ * - `itemId` — the client's idempotency/correlation handle (the durable queue
77
+ * row id). Echoed back verbatim; results are also positional.
78
+ * - `object` — the collection route segment the model's CRUD routes use
79
+ * (e.g. `products`).
80
+ * - `id` — the client-generated row UUID. This is the ONLY channel for a
81
+ * client-supplied id; payload `id` fields are stripped by the writable
82
+ * policy exactly as on plain CRUD routes (#1540).
83
+ * - `baseUpdatedAt` — the server `updated_at` the client last saw for this
84
+ * row; drives the conflict guard on update/delete. Omit to opt out.
85
+ */
86
+ export interface SyncApplyItem {
87
+ itemId: string;
88
+ object: string;
89
+ op: SyncApplyOp;
90
+ id: string;
91
+ payload?: Record<string, unknown>;
92
+ baseUpdatedAt?: string;
93
+ }
94
+ /** Request body of `POST …/sync/apply`. */
95
+ export interface SyncApplyBatchRequest {
96
+ items: SyncApplyItem[];
97
+ }
98
+ /**
99
+ * Per-item result. `results[i]` always corresponds to `items[i]` (positional);
100
+ * `itemId` is echoed for convenience (`null` when the incoming item was too
101
+ * malformed to carry one). `updatedAt` is the server row's `updated_at` after
102
+ * processing — present on applied creates/updates and on conflicts (so clients
103
+ * can rebase), absent on deletes and rejections.
104
+ */
105
+ export interface SyncApplyItemResult {
106
+ itemId: string | null;
107
+ id: string | null;
108
+ status: SyncApplyStatus;
109
+ reason?: SyncApplyReason;
110
+ updatedAt?: string;
111
+ }
112
+ /** Response body of `POST …/sync/apply` (HTTP 200). */
113
+ export interface SyncApplyBatchResponse {
114
+ results: SyncApplyItemResult[];
115
+ }
116
+ /** Batch-level error body (HTTP 400). */
117
+ export interface SyncApplyBatchError {
118
+ error: {
119
+ code: 'invalid_batch' | 'batch_too_large';
120
+ message: string;
121
+ };
122
+ }
123
+ /** Outcome of {@link processSyncApplyBatch}: HTTP status + JSON body. */
124
+ export type SyncApplyOutcome = {
125
+ status: 200;
126
+ body: SyncApplyBatchResponse;
127
+ } | {
128
+ status: 400;
129
+ body: SyncApplyBatchError;
130
+ };
131
+ /**
132
+ * Minimal structural view of a persisted row as the processor needs it.
133
+ * Matches `SmrtObject` structurally; kept structural so hosts and tests can
134
+ * exercise the processor without importing ORM classes.
135
+ */
136
+ export interface SyncApplyRowLike {
137
+ id?: string | null;
138
+ updated_at?: Date | string | null;
139
+ save(): Promise<unknown>;
140
+ delete(): Promise<unknown>;
141
+ }
142
+ /**
143
+ * Minimal structural view of a collection (matches `SmrtCollection`).
144
+ * `create()` must honor the `_insertOnly` option (strict INSERT — see
145
+ * `SmrtCreateInput`), which the processor sets on every sync create.
146
+ */
147
+ export interface SyncApplyCollectionLike {
148
+ get(id: string): Promise<SyncApplyRowLike | null>;
149
+ create(options: Record<string, unknown>): Promise<SyncApplyRowLike>;
150
+ }
151
+ /** Per-item authorization decision from the host. */
152
+ export type SyncApplyAuthzDecision = 'ok' | 'auth_required' | 'forbidden';
153
+ /**
154
+ * A resolved mutation target: everything the processor needs to apply one
155
+ * item through the host's full stack. Hosts build these from their existing
156
+ * machinery so sync items follow the exact same authorization, action-gating,
157
+ * and mass-assignment rules as the host's plain CRUD routes.
158
+ */
159
+ export interface SyncApplyTarget {
160
+ /** Registry/class name, for diagnostics. */
161
+ objectName: string;
162
+ /** Collection whose get/create/save/delete run the full interceptor stack. */
163
+ collection: SyncApplyCollectionLike;
164
+ /** Whether the object's API config exposes this op (mirrors CRUD gating). */
165
+ isOpAllowed(op: SyncApplyOp): boolean;
166
+ /** Per-item authorization (mutating semantics, fail-closed). */
167
+ authorize(op: SyncApplyOp): Promise<SyncApplyAuthzDecision> | SyncApplyAuthzDecision;
168
+ /**
169
+ * Mass-assignment guard (#1540): strip server-managed/readonly/disallowed
170
+ * fields from the item payload. The row UUID is injected from the validated
171
+ * envelope `id` AFTER this runs — never from the body.
172
+ */
173
+ prepare(payload: Record<string, unknown>): Record<string, unknown>;
174
+ }
175
+ /** Host adapter handed to {@link processSyncApplyBatch}. */
176
+ export interface SyncApplyHost {
177
+ /**
178
+ * Resolve an item's `object` segment to a target, or `null` when unknown.
179
+ * Called once per item so per-item auth context stays accurate.
180
+ */
181
+ resolveTarget(objectSegment: string): Promise<SyncApplyTarget | null> | SyncApplyTarget | null;
182
+ }
183
+ /**
184
+ * Writable-policy helper shared with the generated SvelteKit sync route: the
185
+ * same stripping rules as the generated CRUD handlers (#1540) — server-managed
186
+ * fields, `_`-prefixed keys, `@field({ readonly: true })` fields, and (when
187
+ * configured) intersection with the `api.writable` allowlist.
188
+ */
189
+ export declare function applySyncWritablePolicy(data: unknown, policy?: {
190
+ readonlyFields?: readonly string[];
191
+ writableAllowlist?: readonly string[] | null;
192
+ }): Record<string, unknown>;
193
+ /**
194
+ * Batch-level validation. Returns the raw items array or a 400-shaped error.
195
+ */
196
+ export declare function parseSyncApplyBatch(body: unknown): {
197
+ items: unknown[];
198
+ } | SyncApplyBatchError;
199
+ interface ValidatedItem {
200
+ ok: true;
201
+ item: SyncApplyItem;
202
+ }
203
+ interface InvalidItem {
204
+ ok: false;
205
+ result: SyncApplyItemResult;
206
+ }
207
+ /**
208
+ * Per-item shape validation. Never throws; malformed items become `rejected`
209
+ * results so one bad item cannot fail the batch.
210
+ */
211
+ export declare function validateSyncApplyItem(raw: unknown): ValidatedItem | InvalidItem;
212
+ /**
213
+ * Updated-at conflict guard: true when the client's base is strictly older
214
+ * than the server row's `updated_at`. No base (client opted out) or no
215
+ * comparable server timestamp → not stale.
216
+ */
217
+ export declare function isStaleWrite(baseUpdatedAt: string | undefined, serverUpdatedAt: Date | string | null | undefined): boolean;
218
+ /**
219
+ * No-op detection: true when the row already reflects every (policy-stripped)
220
+ * payload field. Payload keys that are not properties of the hydrated row are
221
+ * ignored — they would never persist, so they must not defeat idempotent
222
+ * replay. This check is what keeps replayed batches from churning
223
+ * `updated_at` (and keeps their per-item results identical).
224
+ */
225
+ export declare function payloadMatchesRow(payload: Record<string, unknown>, row: SyncApplyRowLike): boolean;
226
+ /**
227
+ * Process a sync-apply batch: validate the envelope, then apply items FIFO
228
+ * (strictly in order, awaiting each — items may depend on earlier items in
229
+ * the same batch). Always resolves; item-level failures surface as `rejected`
230
+ * results and only envelope-level problems produce a 400.
231
+ */
232
+ export declare function processSyncApplyBatch(body: unknown, host: SyncApplyHost): Promise<SyncApplyOutcome>;
233
+ export {};
234
+ //# sourceMappingURL=apply.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"apply.d.ts","sourceRoot":"","sources":["../../src/sync/apply.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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