@happyvertical/smrt-core 0.54.1 → 0.54.3

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 (138) hide show
  1. package/AGENTS.md +6 -1
  2. package/README.md +8 -0
  3. package/agents/change-feed.md +7 -12
  4. package/agents/generators.md +13 -0
  5. package/agents/object-runtime.md +8 -0
  6. package/agents/schema-paths.md +14 -0
  7. package/dist/audit-context.d.ts +4 -0
  8. package/dist/audit-context.d.ts.map +1 -0
  9. package/dist/audit-context.js +16 -0
  10. package/dist/audit-context.js.map +1 -0
  11. package/dist/audit.d.ts +34 -0
  12. package/dist/audit.d.ts.map +1 -0
  13. package/dist/audit.js +63 -0
  14. package/dist/audit.js.map +1 -0
  15. package/dist/browser.d.ts +2 -1
  16. package/dist/browser.d.ts.map +1 -1
  17. package/dist/browser.js +4 -3
  18. package/dist/cascade.d.ts +1 -1
  19. package/dist/cascade.d.ts.map +1 -1
  20. package/dist/cascade.js +10 -7
  21. package/dist/cascade.js.map +1 -1
  22. package/dist/change-feed.js +1 -1
  23. package/dist/collection.d.ts +9 -2
  24. package/dist/collection.d.ts.map +1 -1
  25. package/dist/collection.js +59 -4
  26. package/dist/collection.js.map +1 -1
  27. package/dist/embedded-write-queue.d.ts +2 -0
  28. package/dist/embedded-write-queue.d.ts.map +1 -1
  29. package/dist/embedded-write-queue.js +12 -5
  30. package/dist/embedded-write-queue.js.map +1 -1
  31. package/dist/generators/changes-route.js +1 -1
  32. package/dist/generators/mcp-runtime-template.d.ts +2 -0
  33. package/dist/generators/mcp-runtime-template.d.ts.map +1 -1
  34. package/dist/generators/mcp-runtime-template.js +18 -16
  35. package/dist/generators/mcp-runtime-template.js.map +1 -1
  36. package/dist/generators/mcp-tool-name.d.ts +6 -0
  37. package/dist/generators/mcp-tool-name.d.ts.map +1 -1
  38. package/dist/generators/mcp-tool-name.js.map +1 -1
  39. package/dist/generators/mcp.d.ts +34 -1
  40. package/dist/generators/mcp.d.ts.map +1 -1
  41. package/dist/generators/mcp.js +148 -110
  42. package/dist/generators/mcp.js.map +1 -1
  43. package/dist/generators/rest.d.ts.map +1 -1
  44. package/dist/generators/rest.js +16 -7
  45. package/dist/generators/rest.js.map +1 -1
  46. package/dist/index.d.ts +3 -1
  47. package/dist/index.d.ts.map +1 -1
  48. package/dist/index.js +9 -7
  49. package/dist/junction.d.ts +29 -10
  50. package/dist/junction.d.ts.map +1 -1
  51. package/dist/junction.js +31 -12
  52. package/dist/junction.js.map +1 -1
  53. package/dist/knowledge.js +1 -1
  54. package/dist/knowledge.js.map +1 -1
  55. package/dist/manifest/manifest-loader.d.ts.map +1 -1
  56. package/dist/manifest/manifest-loader.js +1 -1
  57. package/dist/manifest/manifest-loader.js.map +1 -1
  58. package/dist/manifest/static-manifest.d.ts.map +1 -1
  59. package/dist/manifest/static-manifest.js +106 -9
  60. package/dist/manifest/static-manifest.js.map +1 -1
  61. package/dist/manifest/store.d.ts +8 -0
  62. package/dist/manifest/store.d.ts.map +1 -1
  63. package/dist/manifest/store.js +12 -2
  64. package/dist/manifest/store.js.map +1 -1
  65. package/dist/manifest.json +119 -9
  66. package/dist/migrations/differ.d.ts +3 -3
  67. package/dist/migrations/differ.d.ts.map +1 -1
  68. package/dist/migrations/differ.js +8 -4
  69. package/dist/migrations/differ.js.map +1 -1
  70. package/dist/object.d.ts +1 -0
  71. package/dist/object.d.ts.map +1 -1
  72. package/dist/object.js +19 -7
  73. package/dist/object.js.map +1 -1
  74. package/dist/registry/class-registration.d.ts.map +1 -1
  75. package/dist/registry/class-registration.js +75 -10
  76. package/dist/registry/class-registration.js.map +1 -1
  77. package/dist/registry/collection-resolution.d.ts +2 -2
  78. package/dist/registry/collection-resolution.d.ts.map +1 -1
  79. package/dist/registry/collection-resolution.js +2 -1
  80. package/dist/registry/collection-resolution.js.map +1 -1
  81. package/dist/registry/collision-policy.d.ts +8 -0
  82. package/dist/registry/collision-policy.d.ts.map +1 -1
  83. package/dist/registry/collision-policy.js +2 -2
  84. package/dist/registry/collision-policy.js.map +1 -1
  85. package/dist/registry/framework-base-classes.d.ts.map +1 -1
  86. package/dist/registry/framework-base-classes.js +2 -1
  87. package/dist/registry/framework-base-classes.js.map +1 -1
  88. package/dist/registry/schema-builder.d.ts.map +1 -1
  89. package/dist/registry/schema-builder.js +33 -4
  90. package/dist/registry/schema-builder.js.map +1 -1
  91. package/dist/registry/shared-state.d.ts +6 -0
  92. package/dist/registry/shared-state.d.ts.map +1 -1
  93. package/dist/registry/shared-state.js +12 -1
  94. package/dist/registry/shared-state.js.map +1 -1
  95. package/dist/registry/types.d.ts +7 -1
  96. package/dist/registry/types.d.ts.map +1 -1
  97. package/dist/registry.d.ts +7 -1
  98. package/dist/registry.d.ts.map +1 -1
  99. package/dist/registry.js +25 -3
  100. package/dist/registry.js.map +1 -1
  101. package/dist/scanner/manifest-generator.d.ts.map +1 -1
  102. package/dist/scanner/manifest-generator.js +5 -1
  103. package/dist/scanner/manifest-generator.js.map +1 -1
  104. package/dist/scanner/types.d.ts +8 -0
  105. package/dist/scanner/types.d.ts.map +1 -1
  106. package/dist/scanner/types.js.map +1 -1
  107. package/dist/schema/ddl/duckdb-strategy.d.ts.map +1 -1
  108. package/dist/schema/ddl/duckdb-strategy.js +1 -0
  109. package/dist/schema/ddl/duckdb-strategy.js.map +1 -1
  110. package/dist/schema/ddl/null-equal-index.d.ts.map +1 -1
  111. package/dist/schema/ddl/null-equal-index.js +4 -2
  112. package/dist/schema/ddl/null-equal-index.js.map +1 -1
  113. package/dist/schema/generator.d.ts +3 -0
  114. package/dist/schema/generator.d.ts.map +1 -1
  115. package/dist/schema/generator.js +38 -0
  116. package/dist/schema/generator.js.map +1 -1
  117. package/dist/smrt-knowledge.json +74 -20
  118. package/dist/sync/apply.d.ts +2 -0
  119. package/dist/sync/apply.d.ts.map +1 -1
  120. package/dist/sync/apply.js +7 -3
  121. package/dist/sync/apply.js.map +1 -1
  122. package/dist/utils/scanner-module.d.ts +9 -0
  123. package/dist/utils/scanner-module.d.ts.map +1 -1
  124. package/dist/vite-plugin/index.d.ts +14 -0
  125. package/dist/vite-plugin/index.d.ts.map +1 -1
  126. package/dist/vite-plugin/index.js +58 -18
  127. package/dist/vite-plugin/index.js.map +1 -1
  128. package/dist/vite-plugin/package-stamp.d.ts +41 -0
  129. package/dist/vite-plugin/package-stamp.d.ts.map +1 -0
  130. package/dist/vite-plugin/package-stamp.js +33 -0
  131. package/dist/vite-plugin/package-stamp.js.map +1 -0
  132. package/dist/vite-plugin/sveltekit-generator.js +5 -3
  133. package/dist/vite-plugin/sveltekit-generator.js.map +1 -1
  134. package/dist/vite-plugin/sync-apply-route.d.ts.map +1 -1
  135. package/dist/vite-plugin/sync-apply-route.js +10 -0
  136. package/dist/vite-plugin/sync-apply-route.js.map +1 -1
  137. package/dist/vite-plugin.js +2 -2
  138. package/package.json +10 -10
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Constructor-bound package identity for library builds (#3490).
3
+ *
4
+ * A consumer that bundles a dependency (a SvelteKit server build inlines
5
+ * Svelte libraries) evaluates the dependency's classes inside the consumer's
6
+ * own output, where the decorator's stack walk can only name the consumer's
7
+ * package, and the bundler may order a class's chunk before the package's
8
+ * `__smrt-register__`. Guessing ownership from a simple name and a table then
9
+ * confuses a dependency's class with a consumer class that happens to share
10
+ * both. Instead the package's own library build stamps each decorated class
11
+ * it declares with `static __smrtPackage__ = '<package>'`: a static field is
12
+ * initialized when the class is defined, before its decorators run, so the
13
+ * registry reads the identity from the exact constructor at decoration time,
14
+ * in any bundle and in any registration order.
15
+ *
16
+ * Positions come from the parser's class node (`bodyStart`), never from
17
+ * rescanning the text: a string, template, comment or regex literal that
18
+ * looks like `class X {` cannot receive the stamp.
19
+ */
20
+ /** A decorated class the scanner found in a module. */
21
+ export interface PackageStampTarget {
22
+ /** Class name as declared in source. */
23
+ className: string;
24
+ /** Parser offset of the class body's opening `{`. */
25
+ bodyStart?: number;
26
+ }
27
+ /** The static property the registry reads (`getStampedPackageName`). */
28
+ export declare const PACKAGE_STAMP_PROPERTY = "__smrtPackage__";
29
+ /** The text inserted right after a stamped class body's `{`. */
30
+ export declare function packageStampText(packageName: string): string;
31
+ /**
32
+ * Stamp each target class's body with its package. Returns the new source,
33
+ * or null when there is nothing to stamp.
34
+ *
35
+ * @throws Error when a target has no parser body offset or the offset is not
36
+ * a class body's `{`: an unstamped class of a stamping package would lose
37
+ * its identity in consumer bundles, so the library build fails rather than
38
+ * shipping it.
39
+ */
40
+ export declare function injectPackageStamps(code: string, targets: readonly PackageStampTarget[], packageName: string, moduleId?: string): string | null;
41
+ //# sourceMappingURL=package-stamp.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-stamp.d.ts","sourceRoot":"","sources":["../../src/vite-plugin/package-stamp.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,uDAAuD;AACvD,MAAM,WAAW,kBAAkB;IACjC,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wEAAwE;AACxE,eAAO,MAAM,sBAAsB,oBAAoB,CAAC;AAExD,gEAAgE;AAChE,wBAAgB,gBAAgB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE5D;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,SAAS,kBAAkB,EAAE,EACtC,WAAW,EAAE,MAAM,EACnB,QAAQ,SAAa,GACpB,MAAM,GAAG,IAAI,CAkBf"}
@@ -0,0 +1,33 @@
1
+ //#region src/vite-plugin/package-stamp.ts
2
+ /** The static property the registry reads (`getStampedPackageName`). */
3
+ var PACKAGE_STAMP_PROPERTY = "__smrtPackage__";
4
+ /** The text inserted right after a stamped class body's `{`. */
5
+ function packageStampText(packageName) {
6
+ return ` static ${PACKAGE_STAMP_PROPERTY} = ${JSON.stringify(packageName)};`;
7
+ }
8
+ /**
9
+ * Stamp each target class's body with its package. Returns the new source,
10
+ * or null when there is nothing to stamp.
11
+ *
12
+ * @throws Error when a target has no parser body offset or the offset is not
13
+ * a class body's `{`: an unstamped class of a stamping package would lose
14
+ * its identity in consumer bundles, so the library build fails rather than
15
+ * shipping it.
16
+ */
17
+ function injectPackageStamps(code, targets, packageName, moduleId = "<module>") {
18
+ const insertions = /* @__PURE__ */ new Set();
19
+ for (const target of targets) {
20
+ const at = target.bodyStart;
21
+ if (typeof at !== "number" || code[at] !== "{") throw new Error(`[smrt] Could not locate the body of class ${target.className} in ${moduleId} to stamp its package (#3490).`);
22
+ insertions.add(at + 1);
23
+ }
24
+ if (insertions.size === 0) return null;
25
+ const stamp = packageStampText(packageName);
26
+ let result = code;
27
+ for (const at of [...insertions].sort((a, b) => b - a)) result = result.slice(0, at) + stamp + result.slice(at);
28
+ return result;
29
+ }
30
+ //#endregion
31
+ export { PACKAGE_STAMP_PROPERTY, injectPackageStamps, packageStampText };
32
+
33
+ //# sourceMappingURL=package-stamp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package-stamp.js","names":[],"sources":["../../src/vite-plugin/package-stamp.ts"],"sourcesContent":["/**\n * Constructor-bound package identity for library builds (#3490).\n *\n * A consumer that bundles a dependency (a SvelteKit server build inlines\n * Svelte libraries) evaluates the dependency's classes inside the consumer's\n * own output, where the decorator's stack walk can only name the consumer's\n * package, and the bundler may order a class's chunk before the package's\n * `__smrt-register__`. Guessing ownership from a simple name and a table then\n * confuses a dependency's class with a consumer class that happens to share\n * both. Instead the package's own library build stamps each decorated class\n * it declares with `static __smrtPackage__ = '<package>'`: a static field is\n * initialized when the class is defined, before its decorators run, so the\n * registry reads the identity from the exact constructor at decoration time,\n * in any bundle and in any registration order.\n *\n * Positions come from the parser's class node (`bodyStart`), never from\n * rescanning the text: a string, template, comment or regex literal that\n * looks like `class X {` cannot receive the stamp.\n */\n\n/** A decorated class the scanner found in a module. */\nexport interface PackageStampTarget {\n /** Class name as declared in source. */\n className: string;\n /** Parser offset of the class body's opening `{`. */\n bodyStart?: number;\n}\n\n/** The static property the registry reads (`getStampedPackageName`). */\nexport const PACKAGE_STAMP_PROPERTY = '__smrtPackage__';\n\n/** The text inserted right after a stamped class body's `{`. */\nexport function packageStampText(packageName: string): string {\n return ` static ${PACKAGE_STAMP_PROPERTY} = ${JSON.stringify(packageName)};`;\n}\n\n/**\n * Stamp each target class's body with its package. Returns the new source,\n * or null when there is nothing to stamp.\n *\n * @throws Error when a target has no parser body offset or the offset is not\n * a class body's `{`: an unstamped class of a stamping package would lose\n * its identity in consumer bundles, so the library build fails rather than\n * shipping it.\n */\nexport function injectPackageStamps(\n code: string,\n targets: readonly PackageStampTarget[],\n packageName: string,\n moduleId = '<module>',\n): string | null {\n const insertions = new Set<number>();\n for (const target of targets) {\n const at = target.bodyStart;\n if (typeof at !== 'number' || code[at] !== '{') {\n throw new Error(\n `[smrt] Could not locate the body of class ${target.className} in ${moduleId} to stamp its package (#3490).`,\n );\n }\n insertions.add(at + 1);\n }\n if (insertions.size === 0) return null;\n const stamp = packageStampText(packageName);\n let result = code;\n for (const at of [...insertions].sort((a, b) => b - a)) {\n result = result.slice(0, at) + stamp + result.slice(at);\n }\n return result;\n}\n"],"mappings":";;AA6BA,IAAa,yBAAyB;;AAGtC,SAAgB,iBAAiB,aAA6B;CAC5D,OAAO,WAAW,uBAAuB,KAAK,KAAK,UAAU,WAAW,EAAE;AAC5E;;;;;;;;;;AAWA,SAAgB,oBACd,MACA,SACA,aACA,WAAW,YACI;CACf,MAAM,6BAAa,IAAI,IAAY;CACnC,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,KAAK,OAAO;EAClB,IAAI,OAAO,OAAO,YAAY,KAAK,QAAQ,KACzC,MAAM,IAAI,MACR,6CAA6C,OAAO,UAAU,MAAM,SAAS,+BAC/E;EAEF,WAAW,IAAI,KAAK,CAAC;CACvB;CACA,IAAI,WAAW,SAAS,GAAG,OAAO;CAClC,MAAM,QAAQ,iBAAiB,WAAW;CAC1C,IAAI,SAAS;CACb,KAAK,MAAM,MAAM,CAAC,GAAG,UAAU,CAAC,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,GACnD,SAAS,OAAO,MAAM,GAAG,EAAE,IAAI,QAAQ,OAAO,MAAM,EAAE;CAExD,OAAO;AACT"}
@@ -1928,9 +1928,11 @@ ${generateNotFoundError(className)}
1928
1928
 
1929
1929
  const body: unknown = await request.json();
1930
1930
  const data = applyWritablePolicy(body);
1931
- Object.assign(item, data);
1932
1931
  try {
1933
- await item.save();
1932
+ await collection.withAuditMutation(item, 'updated', async (bound) => {
1933
+ Object.assign(bound, data);
1934
+ await bound.save();
1935
+ });
1934
1936
  } catch (cause) {
1935
1937
  return smrtRouteErrorResponse(cause);
1936
1938
  }
@@ -1950,7 +1952,7 @@ ${generateCollectionLoad(className, { typeName: modelType.typeName })}
1950
1952
  ${generateNotFoundError(className)}
1951
1953
 
1952
1954
  try {
1953
- await item.delete();
1955
+ await collection.delete(params.id);
1954
1956
  } catch (cause) {
1955
1957
  return smrtRouteErrorResponse(cause);
1956
1958
  }