@happyvertical/smrt-core 0.30.0

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 (631) hide show
  1. package/AGENTS.md +124 -0
  2. package/CLAUDE.md +1 -0
  3. package/LICENSE +7 -0
  4. package/README.md +265 -0
  5. package/bin/smrt-prebuild.js +26 -0
  6. package/dist/__tests__/fixtures/advisor-test-classes.d.ts +28 -0
  7. package/dist/__tests__/fixtures/advisor-test-classes.d.ts.map +1 -0
  8. package/dist/__tests__/fixtures/collection-coverage-fixtures.d.ts +12 -0
  9. package/dist/__tests__/fixtures/collection-coverage-fixtures.d.ts.map +1 -0
  10. package/dist/__tests__/fixtures/inheritance-resolver-fixtures.d.ts +28 -0
  11. package/dist/__tests__/fixtures/inheritance-resolver-fixtures.d.ts.map +1 -0
  12. package/dist/__tests__/fixtures/inheritance-test-classes.d.ts +43 -0
  13. package/dist/__tests__/fixtures/inheritance-test-classes.d.ts.map +1 -0
  14. package/dist/__tests__/fixtures/mcp-integration-test-classes.d.ts +18 -0
  15. package/dist/__tests__/fixtures/mcp-integration-test-classes.d.ts.map +1 -0
  16. package/dist/__tests__/fixtures/object-ai-memory-fixtures.d.ts +15 -0
  17. package/dist/__tests__/fixtures/object-ai-memory-fixtures.d.ts.map +1 -0
  18. package/dist/__tests__/fixtures/object-spec-test-classes.d.ts +13 -0
  19. package/dist/__tests__/fixtures/object-spec-test-classes.d.ts.map +1 -0
  20. package/dist/__tests__/fixtures/registry-test-classes.d.ts +23 -0
  21. package/dist/__tests__/fixtures/registry-test-classes.d.ts.map +1 -0
  22. package/dist/adapters/ai-usage.d.ts +23 -0
  23. package/dist/adapters/ai-usage.d.ts.map +1 -0
  24. package/dist/adapters/ai-usage.js +105 -0
  25. package/dist/adapters/ai-usage.js.map +1 -0
  26. package/dist/adapters/cost-rates.d.ts +20 -0
  27. package/dist/adapters/cost-rates.d.ts.map +1 -0
  28. package/dist/adapters/cost-rates.js +40 -0
  29. package/dist/adapters/cost-rates.js.map +1 -0
  30. package/dist/adapters/index.d.ts +19 -0
  31. package/dist/adapters/index.d.ts.map +1 -0
  32. package/dist/adapters/metrics.d.ts +111 -0
  33. package/dist/adapters/metrics.d.ts.map +1 -0
  34. package/dist/adapters/metrics.js +169 -0
  35. package/dist/adapters/metrics.js.map +1 -0
  36. package/dist/adapters/pubsub.d.ts +124 -0
  37. package/dist/adapters/pubsub.d.ts.map +1 -0
  38. package/dist/adapters/pubsub.js +121 -0
  39. package/dist/adapters/pubsub.js.map +1 -0
  40. package/dist/browser.d.ts +32 -0
  41. package/dist/browser.d.ts.map +1 -0
  42. package/dist/browser.js +68 -0
  43. package/dist/browser.js.map +1 -0
  44. package/dist/child-accessors.d.ts +27 -0
  45. package/dist/child-accessors.d.ts.map +1 -0
  46. package/dist/child-accessors.js +35 -0
  47. package/dist/child-accessors.js.map +1 -0
  48. package/dist/class.d.ts +313 -0
  49. package/dist/class.d.ts.map +1 -0
  50. package/dist/class.js +896 -0
  51. package/dist/class.js.map +1 -0
  52. package/dist/collection-cache.d.ts +110 -0
  53. package/dist/collection-cache.d.ts.map +1 -0
  54. package/dist/collection-cache.js +187 -0
  55. package/dist/collection-cache.js.map +1 -0
  56. package/dist/collection.d.ts +894 -0
  57. package/dist/collection.d.ts.map +1 -0
  58. package/dist/collection.js +1987 -0
  59. package/dist/collection.js.map +1 -0
  60. package/dist/config/global-config.d.ts +3 -0
  61. package/dist/config/global-config.d.ts.map +1 -0
  62. package/dist/config/global-config.js +19 -0
  63. package/dist/config/global-config.js.map +1 -0
  64. package/dist/config.d.ts +145 -0
  65. package/dist/config.d.ts.map +1 -0
  66. package/dist/config.js +57 -0
  67. package/dist/config.js.map +1 -0
  68. package/dist/consumer-plugin/index.d.ts +22 -0
  69. package/dist/consumer-plugin/index.d.ts.map +1 -0
  70. package/dist/consumer-plugin/index.js +452 -0
  71. package/dist/consumer-plugin/index.js.map +1 -0
  72. package/dist/consumer-plugin.d.ts +8 -0
  73. package/dist/consumer-plugin.d.ts.map +1 -0
  74. package/dist/consumer-plugin.js +5 -0
  75. package/dist/consumer-plugin.js.map +1 -0
  76. package/dist/database.d.ts +95 -0
  77. package/dist/database.d.ts.map +1 -0
  78. package/dist/database.js +32 -0
  79. package/dist/database.js.map +1 -0
  80. package/dist/decorators/compatibility.d.ts +14 -0
  81. package/dist/decorators/compatibility.d.ts.map +1 -0
  82. package/dist/decorators/compatibility.js +111 -0
  83. package/dist/decorators/compatibility.js.map +1 -0
  84. package/dist/decorators/index.d.ts +381 -0
  85. package/dist/decorators/index.d.ts.map +1 -0
  86. package/dist/decorators/index.js +104 -0
  87. package/dist/decorators/index.js.map +1 -0
  88. package/dist/dispatch/bus.d.ts +306 -0
  89. package/dist/dispatch/bus.d.ts.map +1 -0
  90. package/dist/dispatch/bus.js +583 -0
  91. package/dist/dispatch/bus.js.map +1 -0
  92. package/dist/dispatch/collections/DispatchSubscriptions.d.ts +79 -0
  93. package/dist/dispatch/collections/DispatchSubscriptions.d.ts.map +1 -0
  94. package/dist/dispatch/collections/DispatchSubscriptions.js +243 -0
  95. package/dist/dispatch/collections/DispatchSubscriptions.js.map +1 -0
  96. package/dist/dispatch/collections/Dispatches.d.ts +98 -0
  97. package/dist/dispatch/collections/Dispatches.d.ts.map +1 -0
  98. package/dist/dispatch/collections/Dispatches.js +358 -0
  99. package/dist/dispatch/collections/Dispatches.js.map +1 -0
  100. package/dist/dispatch/index.d.ts +47 -0
  101. package/dist/dispatch/index.d.ts.map +1 -0
  102. package/dist/dispatch/models/Dispatch.d.ts +101 -0
  103. package/dist/dispatch/models/Dispatch.d.ts.map +1 -0
  104. package/dist/dispatch/models/Dispatch.js +162 -0
  105. package/dist/dispatch/models/Dispatch.js.map +1 -0
  106. package/dist/dispatch/models/DispatchSubscription.d.ts +83 -0
  107. package/dist/dispatch/models/DispatchSubscription.d.ts.map +1 -0
  108. package/dist/dispatch/models/DispatchSubscription.js +112 -0
  109. package/dist/dispatch/models/DispatchSubscription.js.map +1 -0
  110. package/dist/dispatch/tenant-resolver.d.ts +98 -0
  111. package/dist/dispatch/tenant-resolver.d.ts.map +1 -0
  112. package/dist/dispatch/tenant-resolver.js +32 -0
  113. package/dist/dispatch/tenant-resolver.js.map +1 -0
  114. package/dist/dispatch/types.d.ts +149 -0
  115. package/dist/dispatch/types.d.ts.map +1 -0
  116. package/dist/embeddings/hash.d.ts +33 -0
  117. package/dist/embeddings/hash.d.ts.map +1 -0
  118. package/dist/embeddings/hash.js +37 -0
  119. package/dist/embeddings/hash.js.map +1 -0
  120. package/dist/embeddings/index.d.ts +36 -0
  121. package/dist/embeddings/index.d.ts.map +1 -0
  122. package/dist/embeddings/provider.d.ts +75 -0
  123. package/dist/embeddings/provider.d.ts.map +1 -0
  124. package/dist/embeddings/provider.js +170 -0
  125. package/dist/embeddings/provider.js.map +1 -0
  126. package/dist/embeddings/similarity.d.ts +47 -0
  127. package/dist/embeddings/similarity.d.ts.map +1 -0
  128. package/dist/embeddings/similarity.js +64 -0
  129. package/dist/embeddings/similarity.js.map +1 -0
  130. package/dist/embeddings/storage.d.ts +125 -0
  131. package/dist/embeddings/storage.d.ts.map +1 -0
  132. package/dist/embeddings/storage.js +283 -0
  133. package/dist/embeddings/storage.js.map +1 -0
  134. package/dist/embeddings/types.d.ts +250 -0
  135. package/dist/embeddings/types.d.ts.map +1 -0
  136. package/dist/errors.d.ts +363 -0
  137. package/dist/errors.d.ts.map +1 -0
  138. package/dist/errors.js +669 -0
  139. package/dist/errors.js.map +1 -0
  140. package/dist/generators/cli.d.ts +162 -0
  141. package/dist/generators/cli.d.ts.map +1 -0
  142. package/dist/generators/cli.js +462 -0
  143. package/dist/generators/cli.js.map +1 -0
  144. package/dist/generators/index.d.ts +13 -0
  145. package/dist/generators/index.d.ts.map +1 -0
  146. package/dist/generators/mcp-runtime-template.d.ts +60 -0
  147. package/dist/generators/mcp-runtime-template.d.ts.map +1 -0
  148. package/dist/generators/mcp-runtime-template.js +509 -0
  149. package/dist/generators/mcp-runtime-template.js.map +1 -0
  150. package/dist/generators/mcp.d.ts +231 -0
  151. package/dist/generators/mcp.d.ts.map +1 -0
  152. package/dist/generators/mcp.js +1220 -0
  153. package/dist/generators/mcp.js.map +1 -0
  154. package/dist/generators/rest.d.ts +171 -0
  155. package/dist/generators/rest.d.ts.map +1 -0
  156. package/dist/generators/rest.js +591 -0
  157. package/dist/generators/rest.js.map +1 -0
  158. package/dist/generators/swagger.d.ts +21 -0
  159. package/dist/generators/swagger.d.ts.map +1 -0
  160. package/dist/generators/swagger.js +307 -0
  161. package/dist/generators/swagger.js.map +1 -0
  162. package/dist/generators/tenant-gate.d.ts +74 -0
  163. package/dist/generators/tenant-gate.d.ts.map +1 -0
  164. package/dist/generators/tenant-gate.js +15 -0
  165. package/dist/generators/tenant-gate.js.map +1 -0
  166. package/dist/generators.d.ts +8 -0
  167. package/dist/generators.d.ts.map +1 -0
  168. package/dist/generators.js +19 -0
  169. package/dist/generators.js.map +1 -0
  170. package/dist/hierarchical.d.ts +103 -0
  171. package/dist/hierarchical.d.ts.map +1 -0
  172. package/dist/hierarchical.js +184 -0
  173. package/dist/hierarchical.js.map +1 -0
  174. package/dist/index.d.ts +57 -0
  175. package/dist/index.d.ts.map +1 -0
  176. package/dist/index.js +202 -0
  177. package/dist/index.js.map +1 -0
  178. package/dist/interceptors.d.ts +251 -0
  179. package/dist/interceptors.d.ts.map +1 -0
  180. package/dist/interceptors.js +259 -0
  181. package/dist/interceptors.js.map +1 -0
  182. package/dist/junction.d.ts +99 -0
  183. package/dist/junction.d.ts.map +1 -0
  184. package/dist/junction.js +136 -0
  185. package/dist/junction.js.map +1 -0
  186. package/dist/knowledge.d.ts +11 -0
  187. package/dist/knowledge.d.ts.map +1 -0
  188. package/dist/knowledge.js +310 -0
  189. package/dist/knowledge.js.map +1 -0
  190. package/dist/lazy-config.d.ts +160 -0
  191. package/dist/lazy-config.d.ts.map +1 -0
  192. package/dist/lazy-config.js +146 -0
  193. package/dist/lazy-config.js.map +1 -0
  194. package/dist/manifest/discover-base-classes.d.ts +78 -0
  195. package/dist/manifest/discover-base-classes.d.ts.map +1 -0
  196. package/dist/manifest/discover-base-classes.js +85 -0
  197. package/dist/manifest/discover-base-classes.js.map +1 -0
  198. package/dist/manifest/discover-smrt-packages.d.ts +48 -0
  199. package/dist/manifest/discover-smrt-packages.d.ts.map +1 -0
  200. package/dist/manifest/discover-smrt-packages.js +361 -0
  201. package/dist/manifest/discover-smrt-packages.js.map +1 -0
  202. package/dist/manifest/generator.d.ts +93 -0
  203. package/dist/manifest/generator.d.ts.map +1 -0
  204. package/dist/manifest/generator.js +380 -0
  205. package/dist/manifest/generator.js.map +1 -0
  206. package/dist/manifest/index.d.ts +16 -0
  207. package/dist/manifest/index.d.ts.map +1 -0
  208. package/dist/manifest/index.js +51 -0
  209. package/dist/manifest/index.js.map +1 -0
  210. package/dist/manifest/manager.d.ts +51 -0
  211. package/dist/manifest/manager.d.ts.map +1 -0
  212. package/dist/manifest/manager.js +89 -0
  213. package/dist/manifest/manager.js.map +1 -0
  214. package/dist/manifest/manifest-loader.d.ts +187 -0
  215. package/dist/manifest/manifest-loader.d.ts.map +1 -0
  216. package/dist/manifest/manifest-loader.js +847 -0
  217. package/dist/manifest/manifest-loader.js.map +1 -0
  218. package/dist/manifest/sources/composite.d.ts +22 -0
  219. package/dist/manifest/sources/composite.d.ts.map +1 -0
  220. package/dist/manifest/sources/composite.js +60 -0
  221. package/dist/manifest/sources/composite.js.map +1 -0
  222. package/dist/manifest/sources/embedded.d.ts +7 -0
  223. package/dist/manifest/sources/embedded.d.ts.map +1 -0
  224. package/dist/manifest/sources/embedded.js +30 -0
  225. package/dist/manifest/sources/embedded.js.map +1 -0
  226. package/dist/manifest/sources/explicit-paths.d.ts +17 -0
  227. package/dist/manifest/sources/explicit-paths.d.ts.map +1 -0
  228. package/dist/manifest/sources/explicit-paths.js +35 -0
  229. package/dist/manifest/sources/explicit-paths.js.map +1 -0
  230. package/dist/manifest/sources/fallback.d.ts +25 -0
  231. package/dist/manifest/sources/fallback.d.ts.map +1 -0
  232. package/dist/manifest/sources/fallback.js +63 -0
  233. package/dist/manifest/sources/fallback.js.map +1 -0
  234. package/dist/manifest/sources/index.d.ts +17 -0
  235. package/dist/manifest/sources/index.d.ts.map +1 -0
  236. package/dist/manifest/sources/local-test.d.ts +7 -0
  237. package/dist/manifest/sources/local-test.d.ts.map +1 -0
  238. package/dist/manifest/sources/local-test.js +21 -0
  239. package/dist/manifest/sources/local-test.js.map +1 -0
  240. package/dist/manifest/sources/static.d.ts +7 -0
  241. package/dist/manifest/sources/static.d.ts.map +1 -0
  242. package/dist/manifest/sources/static.js +19 -0
  243. package/dist/manifest/sources/static.js.map +1 -0
  244. package/dist/manifest/sources/test.d.ts +7 -0
  245. package/dist/manifest/sources/test.d.ts.map +1 -0
  246. package/dist/manifest/sources/test.js +21 -0
  247. package/dist/manifest/sources/test.js.map +1 -0
  248. package/dist/manifest/sources/types.d.ts +79 -0
  249. package/dist/manifest/sources/types.d.ts.map +1 -0
  250. package/dist/manifest/sources/types.js +61 -0
  251. package/dist/manifest/sources/types.js.map +1 -0
  252. package/dist/manifest/static-manifest.d.ts +4 -0
  253. package/dist/manifest/static-manifest.d.ts.map +1 -0
  254. package/dist/manifest/static-manifest.js +1535 -0
  255. package/dist/manifest/static-manifest.js.map +1 -0
  256. package/dist/manifest/store.d.ts +111 -0
  257. package/dist/manifest/store.d.ts.map +1 -0
  258. package/dist/manifest/store.js +431 -0
  259. package/dist/manifest/store.js.map +1 -0
  260. package/dist/manifest/test-manifest-loader.d.ts +3 -0
  261. package/dist/manifest/test-manifest-loader.d.ts.map +1 -0
  262. package/dist/manifest/test-manifest-stub.d.ts +4 -0
  263. package/dist/manifest/test-manifest-stub.d.ts.map +1 -0
  264. package/dist/manifest/test-manifest-stub.js +80013 -0
  265. package/dist/manifest/test-manifest-stub.js.map +1 -0
  266. package/dist/manifest.d.ts +8 -0
  267. package/dist/manifest.d.ts.map +1 -0
  268. package/dist/manifest.js +20 -0
  269. package/dist/manifest.js.map +1 -0
  270. package/dist/manifest.json +1489 -0
  271. package/dist/mcp-advisor/index.d.ts +499 -0
  272. package/dist/mcp-advisor/index.d.ts.map +1 -0
  273. package/dist/mcp-advisor/tools/add-ai-methods.d.ts +6 -0
  274. package/dist/mcp-advisor/tools/add-ai-methods.d.ts.map +1 -0
  275. package/dist/mcp-advisor/tools/configure-decorators.d.ts +6 -0
  276. package/dist/mcp-advisor/tools/configure-decorators.d.ts.map +1 -0
  277. package/dist/mcp-advisor/tools/generate-collection.d.ts +6 -0
  278. package/dist/mcp-advisor/tools/generate-collection.d.ts.map +1 -0
  279. package/dist/mcp-advisor/tools/generate-field-definitions.d.ts +6 -0
  280. package/dist/mcp-advisor/tools/generate-field-definitions.d.ts.map +1 -0
  281. package/dist/mcp-advisor/tools/generate-smrt-class.d.ts +6 -0
  282. package/dist/mcp-advisor/tools/generate-smrt-class.d.ts.map +1 -0
  283. package/dist/mcp-advisor/tools/get-object-config.d.ts +6 -0
  284. package/dist/mcp-advisor/tools/get-object-config.d.ts.map +1 -0
  285. package/dist/mcp-advisor/tools/get-object-schema.d.ts +10 -0
  286. package/dist/mcp-advisor/tools/get-object-schema.d.ts.map +1 -0
  287. package/dist/mcp-advisor/tools/list-registered-objects.d.ts +9 -0
  288. package/dist/mcp-advisor/tools/list-registered-objects.d.ts.map +1 -0
  289. package/dist/mcp-advisor/tools/preview-api-endpoints.d.ts +9 -0
  290. package/dist/mcp-advisor/tools/preview-api-endpoints.d.ts.map +1 -0
  291. package/dist/mcp-advisor/tools/preview-mcp-tools.d.ts +9 -0
  292. package/dist/mcp-advisor/tools/preview-mcp-tools.d.ts.map +1 -0
  293. package/dist/mcp-advisor/tools/validate-smrt-object.d.ts +6 -0
  294. package/dist/mcp-advisor/tools/validate-smrt-object.d.ts.map +1 -0
  295. package/dist/mcp-advisor/types.d.ts +209 -0
  296. package/dist/mcp-advisor/types.d.ts.map +1 -0
  297. package/dist/migrations/backfill-tracker.d.ts +84 -0
  298. package/dist/migrations/backfill-tracker.d.ts.map +1 -0
  299. package/dist/migrations/backfill-tracker.js +118 -0
  300. package/dist/migrations/backfill-tracker.js.map +1 -0
  301. package/dist/migrations/checksum.d.ts +43 -0
  302. package/dist/migrations/checksum.d.ts.map +1 -0
  303. package/dist/migrations/checksum.js +32 -0
  304. package/dist/migrations/checksum.js.map +1 -0
  305. package/dist/migrations/differ.d.ts +186 -0
  306. package/dist/migrations/differ.d.ts.map +1 -0
  307. package/dist/migrations/differ.js +601 -0
  308. package/dist/migrations/differ.js.map +1 -0
  309. package/dist/migrations/generator.d.ts +133 -0
  310. package/dist/migrations/generator.d.ts.map +1 -0
  311. package/dist/migrations/generator.js +328 -0
  312. package/dist/migrations/generator.js.map +1 -0
  313. package/dist/migrations/index.d.ts +20 -0
  314. package/dist/migrations/index.d.ts.map +1 -0
  315. package/dist/migrations/orchestrate.d.ts +148 -0
  316. package/dist/migrations/orchestrate.d.ts.map +1 -0
  317. package/dist/migrations/orchestrate.js +118 -0
  318. package/dist/migrations/orchestrate.js.map +1 -0
  319. package/dist/migrations/tracker.d.ts +134 -0
  320. package/dist/migrations/tracker.d.ts.map +1 -0
  321. package/dist/migrations/tracker.js +624 -0
  322. package/dist/migrations/tracker.js.map +1 -0
  323. package/dist/migrations/types.d.ts +221 -0
  324. package/dist/migrations/types.d.ts.map +1 -0
  325. package/dist/migrations.d.ts +7 -0
  326. package/dist/migrations.d.ts.map +1 -0
  327. package/dist/migrations.js +26 -0
  328. package/dist/migrations.js.map +1 -0
  329. package/dist/node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js +56 -0
  330. package/dist/node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js.map +1 -0
  331. package/dist/node_modules/.pnpm/brace-expansion@5.0.5/node_modules/brace-expansion/dist/esm/index.js +163 -0
  332. package/dist/node_modules/.pnpm/brace-expansion@5.0.5/node_modules/brace-expansion/dist/esm/index.js.map +1 -0
  333. package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/assert-valid-pattern.js +13 -0
  334. package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -0
  335. package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/ast.js +654 -0
  336. package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/ast.js.map +1 -0
  337. package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/brace-expressions.js +111 -0
  338. package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -0
  339. package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/escape.js +10 -0
  340. package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/escape.js.map +1 -0
  341. package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/index.js +824 -0
  342. package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/index.js.map +1 -0
  343. package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/unescape.js +10 -0
  344. package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/unescape.js.map +1 -0
  345. package/dist/object.d.ts +1202 -0
  346. package/dist/object.d.ts.map +1 -0
  347. package/dist/object.js +2731 -0
  348. package/dist/object.js.map +1 -0
  349. package/dist/polymorphic-association.d.ts +69 -0
  350. package/dist/polymorphic-association.d.ts.map +1 -0
  351. package/dist/polymorphic-association.js +96 -0
  352. package/dist/polymorphic-association.js.map +1 -0
  353. package/dist/prebuild/cli.d.ts +7 -0
  354. package/dist/prebuild/cli.d.ts.map +1 -0
  355. package/dist/prebuild/cli.js +29 -0
  356. package/dist/prebuild/cli.js.map +1 -0
  357. package/dist/prebuild/index.d.ts +22 -0
  358. package/dist/prebuild/index.d.ts.map +1 -0
  359. package/dist/prebuild/index.js +239 -0
  360. package/dist/prebuild/index.js.map +1 -0
  361. package/dist/prebuild.d.ts +8 -0
  362. package/dist/prebuild.d.ts.map +1 -0
  363. package/dist/prebuild.js +6 -0
  364. package/dist/prebuild.js.map +1 -0
  365. package/dist/registry/cache-config.d.ts +13 -0
  366. package/dist/registry/cache-config.d.ts.map +1 -0
  367. package/dist/registry/cache-config.js +17 -0
  368. package/dist/registry/cache-config.js.map +1 -0
  369. package/dist/registry/class-registration.d.ts +31 -0
  370. package/dist/registry/class-registration.d.ts.map +1 -0
  371. package/dist/registry/class-registration.js +1074 -0
  372. package/dist/registry/class-registration.js.map +1 -0
  373. package/dist/registry/collection-resolution.d.ts +45 -0
  374. package/dist/registry/collection-resolution.d.ts.map +1 -0
  375. package/dist/registry/collection-resolution.js +121 -0
  376. package/dist/registry/collection-resolution.js.map +1 -0
  377. package/dist/registry/collision-policy.d.ts +179 -0
  378. package/dist/registry/collision-policy.d.ts.map +1 -0
  379. package/dist/registry/collision-policy.js +153 -0
  380. package/dist/registry/collision-policy.js.map +1 -0
  381. package/dist/registry/diagnostics.d.ts +58 -0
  382. package/dist/registry/diagnostics.d.ts.map +1 -0
  383. package/dist/registry/diagnostics.js +54 -0
  384. package/dist/registry/diagnostics.js.map +1 -0
  385. package/dist/registry/embedding-manager.d.ts +23 -0
  386. package/dist/registry/embedding-manager.d.ts.map +1 -0
  387. package/dist/registry/embedding-manager.js +62 -0
  388. package/dist/registry/embedding-manager.js.map +1 -0
  389. package/dist/registry/index.d.ts +13 -0
  390. package/dist/registry/index.d.ts.map +1 -0
  391. package/dist/registry/inheritance-resolver.d.ts +13 -0
  392. package/dist/registry/inheritance-resolver.d.ts.map +1 -0
  393. package/dist/registry/inheritance-resolver.js +244 -0
  394. package/dist/registry/inheritance-resolver.js.map +1 -0
  395. package/dist/registry/manifest-field-merge.d.ts +4 -0
  396. package/dist/registry/manifest-field-merge.d.ts.map +1 -0
  397. package/dist/registry/manifest-field-merge.js +82 -0
  398. package/dist/registry/manifest-field-merge.js.map +1 -0
  399. package/dist/registry/name-resolver.d.ts +102 -0
  400. package/dist/registry/name-resolver.d.ts.map +1 -0
  401. package/dist/registry/name-resolver.js +241 -0
  402. package/dist/registry/name-resolver.js.map +1 -0
  403. package/dist/registry/relationship-graph.d.ts +16 -0
  404. package/dist/registry/relationship-graph.d.ts.map +1 -0
  405. package/dist/registry/relationship-graph.js +79 -0
  406. package/dist/registry/relationship-graph.js.map +1 -0
  407. package/dist/registry/schema-builder.d.ts +113 -0
  408. package/dist/registry/schema-builder.d.ts.map +1 -0
  409. package/dist/registry/schema-builder.js +474 -0
  410. package/dist/registry/schema-builder.js.map +1 -0
  411. package/dist/registry/shared-state.d.ts +62 -0
  412. package/dist/registry/shared-state.d.ts.map +1 -0
  413. package/dist/registry/shared-state.js +135 -0
  414. package/dist/registry/shared-state.js.map +1 -0
  415. package/dist/registry/types.d.ts +667 -0
  416. package/dist/registry/types.d.ts.map +1 -0
  417. package/dist/registry/validator.d.ts +13 -0
  418. package/dist/registry/validator.d.ts.map +1 -0
  419. package/dist/registry/validator.js +138 -0
  420. package/dist/registry/validator.js.map +1 -0
  421. package/dist/registry.d.ts +1358 -0
  422. package/dist/registry.d.ts.map +1 -0
  423. package/dist/registry.js +2301 -0
  424. package/dist/registry.js.map +1 -0
  425. package/dist/runtime/client.d.ts +34 -0
  426. package/dist/runtime/client.d.ts.map +1 -0
  427. package/dist/runtime/client.js +104 -0
  428. package/dist/runtime/client.js.map +1 -0
  429. package/dist/runtime/index.d.ts +10 -0
  430. package/dist/runtime/index.d.ts.map +1 -0
  431. package/dist/runtime/mcp.d.ts +47 -0
  432. package/dist/runtime/mcp.d.ts.map +1 -0
  433. package/dist/runtime/mcp.js +72 -0
  434. package/dist/runtime/mcp.js.map +1 -0
  435. package/dist/runtime/server.d.ts +92 -0
  436. package/dist/runtime/server.d.ts.map +1 -0
  437. package/dist/runtime/server.js +390 -0
  438. package/dist/runtime/server.js.map +1 -0
  439. package/dist/runtime/types.d.ts +58 -0
  440. package/dist/runtime/types.d.ts.map +1 -0
  441. package/dist/runtime.d.ts +8 -0
  442. package/dist/runtime.d.ts.map +1 -0
  443. package/dist/runtime.js +10 -0
  444. package/dist/runtime.js.map +1 -0
  445. package/dist/scanner/import-scanner.d.ts +7 -0
  446. package/dist/scanner/import-scanner.d.ts.map +1 -0
  447. package/dist/scanner/index.d.ts +12 -0
  448. package/dist/scanner/index.d.ts.map +1 -0
  449. package/dist/scanner/manifest-generator.d.ts +304 -0
  450. package/dist/scanner/manifest-generator.d.ts.map +1 -0
  451. package/dist/scanner/manifest-generator.js +1707 -0
  452. package/dist/scanner/manifest-generator.js.map +1 -0
  453. package/dist/scanner/test-file-patterns.d.ts +18 -0
  454. package/dist/scanner/test-file-patterns.d.ts.map +1 -0
  455. package/dist/scanner/test-file-patterns.js +16 -0
  456. package/dist/scanner/test-file-patterns.js.map +1 -0
  457. package/dist/scanner/types.d.ts +313 -0
  458. package/dist/scanner/types.d.ts.map +1 -0
  459. package/dist/scanner/types.js +2 -0
  460. package/dist/scanner/types.js.map +1 -0
  461. package/dist/scanner.d.ts +6 -0
  462. package/dist/scanner.d.ts.map +1 -0
  463. package/dist/scanner.js +6 -0
  464. package/dist/scanner.js.map +1 -0
  465. package/dist/schema/code-generator.d.ts +53 -0
  466. package/dist/schema/code-generator.d.ts.map +1 -0
  467. package/dist/schema/ddl/base-strategy.d.ts +80 -0
  468. package/dist/schema/ddl/base-strategy.d.ts.map +1 -0
  469. package/dist/schema/ddl/base-strategy.js +240 -0
  470. package/dist/schema/ddl/base-strategy.js.map +1 -0
  471. package/dist/schema/ddl/duckdb-strategy.d.ts +33 -0
  472. package/dist/schema/ddl/duckdb-strategy.d.ts.map +1 -0
  473. package/dist/schema/ddl/duckdb-strategy.js +74 -0
  474. package/dist/schema/ddl/duckdb-strategy.js.map +1 -0
  475. package/dist/schema/ddl/index.d.ts +53 -0
  476. package/dist/schema/ddl/index.d.ts.map +1 -0
  477. package/dist/schema/ddl/index.js +80 -0
  478. package/dist/schema/ddl/index.js.map +1 -0
  479. package/dist/schema/ddl/json-duckdb-strategy.d.ts +8 -0
  480. package/dist/schema/ddl/json-duckdb-strategy.d.ts.map +1 -0
  481. package/dist/schema/ddl/json-duckdb-strategy.js +14 -0
  482. package/dist/schema/ddl/json-duckdb-strategy.js.map +1 -0
  483. package/dist/schema/ddl/postgres-strategy.d.ts +29 -0
  484. package/dist/schema/ddl/postgres-strategy.d.ts.map +1 -0
  485. package/dist/schema/ddl/postgres-strategy.js +102 -0
  486. package/dist/schema/ddl/postgres-strategy.js.map +1 -0
  487. package/dist/schema/ddl/sqlite-strategy.d.ts +38 -0
  488. package/dist/schema/ddl/sqlite-strategy.d.ts.map +1 -0
  489. package/dist/schema/ddl/sqlite-strategy.js +74 -0
  490. package/dist/schema/ddl/sqlite-strategy.js.map +1 -0
  491. package/dist/schema/ddl/types.d.ts +114 -0
  492. package/dist/schema/ddl/types.d.ts.map +1 -0
  493. package/dist/schema/generator.d.ts +176 -0
  494. package/dist/schema/generator.d.ts.map +1 -0
  495. package/dist/schema/generator.js +1076 -0
  496. package/dist/schema/generator.js.map +1 -0
  497. package/dist/schema/index-utils.d.ts +19 -0
  498. package/dist/schema/index-utils.d.ts.map +1 -0
  499. package/dist/schema/index-utils.js +32 -0
  500. package/dist/schema/index-utils.js.map +1 -0
  501. package/dist/schema/index.d.ts +13 -0
  502. package/dist/schema/index.d.ts.map +1 -0
  503. package/dist/schema/override-system.d.ts +43 -0
  504. package/dist/schema/override-system.d.ts.map +1 -0
  505. package/dist/schema/schema-aggregator.d.ts +112 -0
  506. package/dist/schema/schema-aggregator.d.ts.map +1 -0
  507. package/dist/schema/schema-manager.d.ts +95 -0
  508. package/dist/schema/schema-manager.d.ts.map +1 -0
  509. package/dist/schema/schema-manager.js +283 -0
  510. package/dist/schema/schema-manager.js.map +1 -0
  511. package/dist/schema/sql-identifiers.d.ts +107 -0
  512. package/dist/schema/sql-identifiers.d.ts.map +1 -0
  513. package/dist/schema/sql-identifiers.js +190 -0
  514. package/dist/schema/sql-identifiers.js.map +1 -0
  515. package/dist/schema/table-verifier.d.ts +10 -0
  516. package/dist/schema/table-verifier.d.ts.map +1 -0
  517. package/dist/schema/table-verifier.js +37 -0
  518. package/dist/schema/table-verifier.js.map +1 -0
  519. package/dist/schema/types.d.ts +241 -0
  520. package/dist/schema/types.d.ts.map +1 -0
  521. package/dist/schema/utils.d.ts +32 -0
  522. package/dist/schema/utils.d.ts.map +1 -0
  523. package/dist/schema/utils.js +134 -0
  524. package/dist/schema/utils.js.map +1 -0
  525. package/dist/scripts/create-wrappers.js +89 -0
  526. package/dist/scripts/generate-manifest.js +155 -0
  527. package/dist/scripts/generate-test-manifest.js +77 -0
  528. package/dist/scripts/migrate-datetime-to-timestamp.ts +310 -0
  529. package/dist/scripts/prepack.js +49 -0
  530. package/dist/signals/bus.d.ts +64 -0
  531. package/dist/signals/bus.d.ts.map +1 -0
  532. package/dist/signals/bus.js +102 -0
  533. package/dist/signals/bus.js.map +1 -0
  534. package/dist/signals/index.d.ts +11 -0
  535. package/dist/signals/index.d.ts.map +1 -0
  536. package/dist/signals/sanitizer.d.ts +54 -0
  537. package/dist/signals/sanitizer.d.ts.map +1 -0
  538. package/dist/signals/sanitizer.js +111 -0
  539. package/dist/signals/sanitizer.js.map +1 -0
  540. package/dist/smrt-knowledge.json +335 -0
  541. package/dist/system/compatibility.d.ts +8 -0
  542. package/dist/system/compatibility.d.ts.map +1 -0
  543. package/dist/system/compatibility.js +409 -0
  544. package/dist/system/compatibility.js.map +1 -0
  545. package/dist/system/index.d.ts +9 -0
  546. package/dist/system/index.d.ts.map +1 -0
  547. package/dist/system/schema.d.ts +69 -0
  548. package/dist/system/schema.d.ts.map +1 -0
  549. package/dist/system/schema.js +271 -0
  550. package/dist/system/schema.js.map +1 -0
  551. package/dist/system/types.d.ts +135 -0
  552. package/dist/system/types.d.ts.map +1 -0
  553. package/dist/system-fields.d.ts +44 -0
  554. package/dist/system-fields.d.ts.map +1 -0
  555. package/dist/system-fields.js +55 -0
  556. package/dist/system-fields.js.map +1 -0
  557. package/dist/table-cache.d.ts +28 -0
  558. package/dist/table-cache.d.ts.map +1 -0
  559. package/dist/table-cache.js +21 -0
  560. package/dist/table-cache.js.map +1 -0
  561. package/dist/test-utils.d.ts +140 -0
  562. package/dist/test-utils.d.ts.map +1 -0
  563. package/dist/testing/database.d.ts +73 -0
  564. package/dist/testing/database.d.ts.map +1 -0
  565. package/dist/testing/database.js +204 -0
  566. package/dist/testing/database.js.map +1 -0
  567. package/dist/testing/index.d.ts +21 -0
  568. package/dist/testing/index.d.ts.map +1 -0
  569. package/dist/testing.d.ts +6 -0
  570. package/dist/testing.d.ts.map +1 -0
  571. package/dist/testing.js +5 -0
  572. package/dist/testing.js.map +1 -0
  573. package/dist/tools/index.d.ts +8 -0
  574. package/dist/tools/index.d.ts.map +1 -0
  575. package/dist/tools/tool-executor.d.ts +101 -0
  576. package/dist/tools/tool-executor.d.ts.map +1 -0
  577. package/dist/tools/tool-executor.js +142 -0
  578. package/dist/tools/tool-executor.js.map +1 -0
  579. package/dist/tools/tool-generator.d.ts +54 -0
  580. package/dist/tools/tool-generator.d.ts.map +1 -0
  581. package/dist/tools/tool-generator.js +121 -0
  582. package/dist/tools/tool-generator.js.map +1 -0
  583. package/dist/utils/chunk.d.ts +32 -0
  584. package/dist/utils/chunk.d.ts.map +1 -0
  585. package/dist/utils/chunk.js +14 -0
  586. package/dist/utils/chunk.js.map +1 -0
  587. package/dist/utils/import-workspace-module.d.ts +8 -0
  588. package/dist/utils/import-workspace-module.d.ts.map +1 -0
  589. package/dist/utils/import-workspace-module.js +81 -0
  590. package/dist/utils/import-workspace-module.js.map +1 -0
  591. package/dist/utils/json.d.ts +102 -0
  592. package/dist/utils/json.d.ts.map +1 -0
  593. package/dist/utils/json.js +43 -0
  594. package/dist/utils/json.js.map +1 -0
  595. package/dist/utils/lru-cache.d.ts +69 -0
  596. package/dist/utils/lru-cache.d.ts.map +1 -0
  597. package/dist/utils/lru-cache.js +100 -0
  598. package/dist/utils/lru-cache.js.map +1 -0
  599. package/dist/utils/naming.d.ts +16 -0
  600. package/dist/utils/naming.d.ts.map +1 -0
  601. package/dist/utils/naming.js +23 -0
  602. package/dist/utils/naming.js.map +1 -0
  603. package/dist/utils/qualified-names.d.ts +122 -0
  604. package/dist/utils/qualified-names.d.ts.map +1 -0
  605. package/dist/utils/qualified-names.js +82 -0
  606. package/dist/utils/qualified-names.js.map +1 -0
  607. package/dist/utils/scanner-module.d.ts +37 -0
  608. package/dist/utils/scanner-module.d.ts.map +1 -0
  609. package/dist/utils.d.ts +177 -0
  610. package/dist/utils.d.ts.map +1 -0
  611. package/dist/utils.js +185 -0
  612. package/dist/utils.js.map +1 -0
  613. package/dist/vite-plugin/import-build-aware.d.ts +68 -0
  614. package/dist/vite-plugin/import-build-aware.d.ts.map +1 -0
  615. package/dist/vite-plugin/import-build-aware.js +72 -0
  616. package/dist/vite-plugin/import-build-aware.js.map +1 -0
  617. package/dist/vite-plugin/index.d.ts +59 -0
  618. package/dist/vite-plugin/index.d.ts.map +1 -0
  619. package/dist/vite-plugin/index.js +1400 -0
  620. package/dist/vite-plugin/index.js.map +1 -0
  621. package/dist/vite-plugin/sveltekit-generator.d.ts +66 -0
  622. package/dist/vite-plugin/sveltekit-generator.d.ts.map +1 -0
  623. package/dist/vite-plugin/sveltekit-generator.js +1375 -0
  624. package/dist/vite-plugin/sveltekit-generator.js.map +1 -0
  625. package/dist/vite-plugin/templates/default-ui.ts +432 -0
  626. package/dist/vite-plugin/templates/default.html +206 -0
  627. package/dist/vite-plugin.d.ts +8 -0
  628. package/dist/vite-plugin.d.ts.map +1 -0
  629. package/dist/vite-plugin.js +11 -0
  630. package/dist/vite-plugin.js.map +1 -0
  631. package/package.json +208 -0
@@ -0,0 +1,184 @@
1
+ import { SmrtObject } from "./object.js";
2
+ import { ObjectRegistry } from "./registry.js";
3
+ import { chunkArray, IN_LIST_CHUNK_SIZE } from "./utils/chunk.js";
4
+ class SmrtHierarchical extends SmrtObject {
5
+ /**
6
+ * Internal marker so the scanner can recognize this framework abstract base
7
+ * even when consumers haven't built its package. Mirrors
8
+ * `SmrtJunction._isJunctionBase`. Don't rename without also updating the
9
+ * scanner's `FRAMEWORK_BASE_CLASSES` set in
10
+ * `packages/scanner/src/inheritance-resolver.ts`.
11
+ */
12
+ static _isHierarchicalBase = true;
13
+ /** Self-referencing parent. `null` means top-level (no parent). */
14
+ parentId = null;
15
+ /**
16
+ * Resolve the collection used to load siblings/ancestors/descendants.
17
+ *
18
+ * Goes through `ObjectRegistry.getCollection` so subclasses don't have to
19
+ * hard-code a dynamic import of their own collection module. Also acts as
20
+ * the abstract-base guard — `new SmrtHierarchical()` followed by any
21
+ * traversal method throws a clear error rather than producing garbage.
22
+ *
23
+ * For STI subclasses, queries are issued against the STI base collection
24
+ * so the table/discriminator are correct.
25
+ *
26
+ * Lookup uses the constructor's qualified name when available — set by
27
+ * the registry on every registered class as `_smrtQualifiedName` (R5-
28
+ * canon prep). Then `ObjectRegistry.getSTIBase(...)` returns the
29
+ * qualified name of the STI base directly (R5-canon main), so the
30
+ * `getCollection` lookup never collapses to a simple-name ambiguity
31
+ * even when two packages ship a hierarchical class with the same
32
+ * simple name. Falls back through `getClassByConstructor` → simple
33
+ * `this.constructor.name` when the static / WeakMap aren't populated
34
+ * (rare; `getCollection` then surfaces the existing "not found in
35
+ * ObjectRegistry" error).
36
+ *
37
+ * The constructor prototype-chain walk that lived here from PR #1269
38
+ * is gone — the registry now returns qualified names directly so the
39
+ * walk became dead code.
40
+ */
41
+ async _hierarchyCollection() {
42
+ if (this.constructor === SmrtHierarchical) {
43
+ throw new Error(
44
+ "SmrtHierarchical is abstract — extend it from a concrete @smrt() class before calling hierarchy methods."
45
+ );
46
+ }
47
+ const ctor = this.constructor;
48
+ const tagged = ctor._smrtQualifiedName;
49
+ const registered = tagged ? void 0 : ObjectRegistry.getClassByConstructor(ctor);
50
+ const className = tagged ?? registered?.qualifiedName ?? registered?.name ?? ctor.name;
51
+ const stiBase = ObjectRegistry.getSTIBase(className);
52
+ const collectionClass = stiBase ?? className;
53
+ return await ObjectRegistry.getCollection(
54
+ collectionClass,
55
+ this.options
56
+ );
57
+ }
58
+ /**
59
+ * The parent row, or `null` when this row is top-level.
60
+ *
61
+ * Single query. Returns the hydrated row (STI dispatch applies, so an
62
+ * Article-extends-Document subclass comes back as `Article`).
63
+ */
64
+ async getParent() {
65
+ if (!this.parentId) return null;
66
+ const collection = await this._hierarchyCollection();
67
+ const parent = await collection.get({ id: this.parentId });
68
+ return parent;
69
+ }
70
+ /**
71
+ * Immediate children. Single query: `WHERE parent_id = this.id`.
72
+ */
73
+ async getChildren() {
74
+ if (!this.id) return [];
75
+ const collection = await this._hierarchyCollection();
76
+ const children = await collection.list({
77
+ where: { parentId: this.id }
78
+ });
79
+ return children;
80
+ }
81
+ /**
82
+ * All ancestors, root-first (immediate parent last). Does not include self.
83
+ *
84
+ * Intrinsically O(depth) queries — each step needs the previous level's
85
+ * `parentId` before it can fetch the next. Includes cycle protection: if
86
+ * a row's ancestor chain loops back on itself (data corruption), the walk
87
+ * stops cleanly instead of looping forever.
88
+ */
89
+ async getAncestors() {
90
+ const ancestors = [];
91
+ const visited = /* @__PURE__ */ new Set();
92
+ if (this.id) visited.add(this.id);
93
+ let current = this;
94
+ while (current.parentId) {
95
+ if (visited.has(current.parentId)) break;
96
+ visited.add(current.parentId);
97
+ const parent = await current.getParent();
98
+ if (!parent) break;
99
+ ancestors.unshift(parent);
100
+ current = parent;
101
+ }
102
+ return ancestors;
103
+ }
104
+ /**
105
+ * All descendants in BFS order. One query per level of depth using `IN`
106
+ * on the previous level's IDs — eliminates the recursive-per-child N+1
107
+ * pattern the duplicated implementations used.
108
+ *
109
+ * Each level's frontier is chunked at `IN_LIST_CHUNK_SIZE` before being
110
+ * expanded into a `parent_id IN (?, ?, …)` clause: the generic
111
+ * `collection.list()` does NOT chunk array-valued WHERE clauses, so a level
112
+ * wider than the backend's `SQLITE_MAX_VARIABLE_NUMBER` (999 on legacy
113
+ * SQLite, 32766 on modern builds) would otherwise throw before traversal
114
+ * completes. Mirrors the chunking the relationship/junction loaders in
115
+ * `collection.ts` already do.
116
+ *
117
+ * Cycle-safe via a visited Set keyed on row id.
118
+ */
119
+ async getDescendants() {
120
+ if (!this.id) return [];
121
+ const collection = await this._hierarchyCollection();
122
+ const descendants = [];
123
+ const visited = /* @__PURE__ */ new Set([this.id]);
124
+ let frontier = [this.id];
125
+ while (frontier.length > 0) {
126
+ const next = [];
127
+ for (const idChunk of chunkArray(frontier, IN_LIST_CHUNK_SIZE)) {
128
+ const children = await collection.list({
129
+ where: { parentId: idChunk }
130
+ });
131
+ for (const child of children) {
132
+ if (!child.id || visited.has(child.id)) continue;
133
+ visited.add(child.id);
134
+ descendants.push(child);
135
+ next.push(child.id);
136
+ }
137
+ }
138
+ frontier = next;
139
+ }
140
+ return descendants;
141
+ }
142
+ /**
143
+ * Full hierarchy view: ancestors, self, descendants. Issued concurrently.
144
+ */
145
+ async getHierarchy() {
146
+ const [ancestors, descendants] = await Promise.all([
147
+ this.getAncestors(),
148
+ this.getDescendants()
149
+ ]);
150
+ return { ancestors, current: this, descendants };
151
+ }
152
+ /**
153
+ * Reparent this row. Pass `null` to make it a root, an id string, or the
154
+ * target row itself. Refuses to:
155
+ *
156
+ * - move a row to itself (self-loop)
157
+ * - move a row under one of its own descendants (would create a cycle)
158
+ *
159
+ * Persists via `save()`. Caller is responsible for any out-of-band
160
+ * denormalization (e.g. depth caches on subclasses like Tag.level).
161
+ */
162
+ async moveTo(newParent) {
163
+ const newParentId = newParent === null ? null : typeof newParent === "string" ? newParent : newParent.id ?? null;
164
+ if (newParentId !== null && newParentId === this.id) {
165
+ throw new Error(
166
+ `Cannot move ${this.constructor.name} ${this.id} to itself.`
167
+ );
168
+ }
169
+ if (newParentId !== null) {
170
+ const descendants = await this.getDescendants();
171
+ if (descendants.some((d) => d.id === newParentId)) {
172
+ throw new Error(
173
+ `Cannot move ${this.constructor.name} ${this.id} under one of its own descendants (${newParentId}) — would create a cycle.`
174
+ );
175
+ }
176
+ }
177
+ this.parentId = newParentId;
178
+ await this.save();
179
+ }
180
+ }
181
+ export {
182
+ SmrtHierarchical
183
+ };
184
+ //# sourceMappingURL=hierarchical.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hierarchical.js","sources":["../src/hierarchical.ts"],"sourcesContent":["/**\n * SmrtHierarchical — base class for self-referencing tree hierarchies.\n *\n * Provides batched parent/children/ancestors/descendants/hierarchy traversal\n * and a cycle-safe `moveTo`. Replaces five copies of the same logic across\n * Place, Event, Tag, Account, and Zone.\n *\n * Examples in the monorepo:\n *\n * | Subclass | Domain |\n * |----------|------------------------------------------------|\n * | Place | hierarchical geographic places |\n * | Event | nestable event hierarchy (game → period → …) |\n * | Tag | tag taxonomies and category trees |\n * | Account | chart of accounts |\n * | Zone | placement zones inside a digital property |\n *\n * Convention: every subclass uses `parentId: string | null` referencing\n * another row in the same table (or STI base table) by UUID. Classes whose\n * self-reference has different semantics — e.g. `Fact.previousFactId` (an\n * evolution chain) or `Asset.sourceAssetId` (a derivation DAG) — should\n * NOT extend SmrtHierarchical. Use descriptive names and class-specific\n * methods instead.\n *\n * @example\n * ```typescript\n * @smrt({ tableStrategy: 'sti', api: true })\n * export class Place extends SmrtHierarchical {\n * name = '';\n * }\n *\n * const ancestors = await place.getAncestors();\n * const descendants = await place.getDescendants(); // BFS, one query per level\n * await place.moveTo(newParent); // cycle-checked\n * ```\n */\n\nimport type { SmrtCollection } from './collection';\nimport { SmrtObject } from './object';\nimport { ObjectRegistry } from './registry';\nimport { chunkArray, IN_LIST_CHUNK_SIZE } from './utils/chunk';\n\n/**\n * Aggregate hierarchy view: ancestors (root-first), self, and all descendants\n * (BFS order). Generic on the concrete subclass so `getHierarchy()` preserves\n * the caller's type — `place.getHierarchy()` yields `HierarchyView<Place>`.\n */\nexport interface HierarchyView<T extends SmrtHierarchical> {\n ancestors: T[];\n current: T;\n descendants: T[];\n}\n\nexport class SmrtHierarchical extends SmrtObject {\n /**\n * Internal marker so the scanner can recognize this framework abstract base\n * even when consumers haven't built its package. Mirrors\n * `SmrtJunction._isJunctionBase`. Don't rename without also updating the\n * scanner's `FRAMEWORK_BASE_CLASSES` set in\n * `packages/scanner/src/inheritance-resolver.ts`.\n */\n static readonly _isHierarchicalBase = true as const;\n\n /** Self-referencing parent. `null` means top-level (no parent). */\n parentId: string | null = null;\n\n /**\n * Resolve the collection used to load siblings/ancestors/descendants.\n *\n * Goes through `ObjectRegistry.getCollection` so subclasses don't have to\n * hard-code a dynamic import of their own collection module. Also acts as\n * the abstract-base guard — `new SmrtHierarchical()` followed by any\n * traversal method throws a clear error rather than producing garbage.\n *\n * For STI subclasses, queries are issued against the STI base collection\n * so the table/discriminator are correct.\n *\n * Lookup uses the constructor's qualified name when available — set by\n * the registry on every registered class as `_smrtQualifiedName` (R5-\n * canon prep). Then `ObjectRegistry.getSTIBase(...)` returns the\n * qualified name of the STI base directly (R5-canon main), so the\n * `getCollection` lookup never collapses to a simple-name ambiguity\n * even when two packages ship a hierarchical class with the same\n * simple name. Falls back through `getClassByConstructor` → simple\n * `this.constructor.name` when the static / WeakMap aren't populated\n * (rare; `getCollection` then surfaces the existing \"not found in\n * ObjectRegistry\" error).\n *\n * The constructor prototype-chain walk that lived here from PR #1269\n * is gone — the registry now returns qualified names directly so the\n * walk became dead code.\n */\n protected async _hierarchyCollection(): Promise<SmrtCollection<this>> {\n if (this.constructor === SmrtHierarchical) {\n throw new Error(\n 'SmrtHierarchical is abstract — extend it from a concrete @smrt() class before calling hierarchy methods.',\n );\n }\n\n // Identity priority:\n // 1. The constructor's `_smrtQualifiedName` static (set at\n // registration, survives HMR / federated-module duplication).\n // 2. The registry's WeakMap (`getClassByConstructor`) — same value\n // as the static when both are populated, but the WeakMap is\n // where simple-name fallback lives.\n // 3. The simple constructor name as a last-ditch fallback.\n const ctor = this.constructor as typeof SmrtHierarchical & {\n _smrtQualifiedName?: string;\n };\n const tagged = ctor._smrtQualifiedName;\n const registered = tagged\n ? undefined\n : ObjectRegistry.getClassByConstructor(ctor as any);\n const className =\n tagged ?? registered?.qualifiedName ?? registered?.name ?? ctor.name;\n\n const stiBase = ObjectRegistry.getSTIBase(className);\n const collectionClass = stiBase ?? className;\n return await ObjectRegistry.getCollection<this>(\n collectionClass,\n this.options,\n );\n }\n\n /**\n * The parent row, or `null` when this row is top-level.\n *\n * Single query. Returns the hydrated row (STI dispatch applies, so an\n * Article-extends-Document subclass comes back as `Article`).\n */\n async getParent(): Promise<this | null> {\n if (!this.parentId) return null;\n const collection = await this._hierarchyCollection();\n const parent = await collection.get({ id: this.parentId });\n return parent as this | null;\n }\n\n /**\n * Immediate children. Single query: `WHERE parent_id = this.id`.\n */\n async getChildren(): Promise<this[]> {\n if (!this.id) return [];\n const collection = await this._hierarchyCollection();\n const children = await collection.list({\n where: { parentId: this.id },\n });\n return children as this[];\n }\n\n /**\n * All ancestors, root-first (immediate parent last). Does not include self.\n *\n * Intrinsically O(depth) queries — each step needs the previous level's\n * `parentId` before it can fetch the next. Includes cycle protection: if\n * a row's ancestor chain loops back on itself (data corruption), the walk\n * stops cleanly instead of looping forever.\n */\n async getAncestors(): Promise<this[]> {\n const ancestors: this[] = [];\n const visited = new Set<string>();\n if (this.id) visited.add(this.id);\n let current: this = this;\n\n while (current.parentId) {\n if (visited.has(current.parentId)) break;\n visited.add(current.parentId);\n\n const parent = (await current.getParent()) as this | null;\n if (!parent) break;\n ancestors.unshift(parent);\n current = parent;\n }\n\n return ancestors;\n }\n\n /**\n * All descendants in BFS order. One query per level of depth using `IN`\n * on the previous level's IDs — eliminates the recursive-per-child N+1\n * pattern the duplicated implementations used.\n *\n * Each level's frontier is chunked at `IN_LIST_CHUNK_SIZE` before being\n * expanded into a `parent_id IN (?, ?, …)` clause: the generic\n * `collection.list()` does NOT chunk array-valued WHERE clauses, so a level\n * wider than the backend's `SQLITE_MAX_VARIABLE_NUMBER` (999 on legacy\n * SQLite, 32766 on modern builds) would otherwise throw before traversal\n * completes. Mirrors the chunking the relationship/junction loaders in\n * `collection.ts` already do.\n *\n * Cycle-safe via a visited Set keyed on row id.\n */\n async getDescendants(): Promise<this[]> {\n if (!this.id) return [];\n const collection = await this._hierarchyCollection();\n const descendants: this[] = [];\n const visited = new Set<string>([this.id]);\n let frontier: string[] = [this.id];\n\n while (frontier.length > 0) {\n const next: string[] = [];\n\n // Chunk the frontier so each query stays under the bind-variable cap.\n // Children are merged into the same BFS level in chunk order, so the\n // overall ordering remains breadth-first.\n for (const idChunk of chunkArray(frontier, IN_LIST_CHUNK_SIZE)) {\n const children = (await collection.list({\n where: { parentId: idChunk },\n })) as this[];\n\n for (const child of children) {\n if (!child.id || visited.has(child.id)) continue;\n visited.add(child.id);\n descendants.push(child);\n next.push(child.id);\n }\n }\n\n frontier = next;\n }\n\n return descendants;\n }\n\n /**\n * Full hierarchy view: ancestors, self, descendants. Issued concurrently.\n */\n async getHierarchy(): Promise<HierarchyView<this>> {\n const [ancestors, descendants] = await Promise.all([\n this.getAncestors(),\n this.getDescendants(),\n ]);\n return { ancestors, current: this, descendants };\n }\n\n /**\n * Reparent this row. Pass `null` to make it a root, an id string, or the\n * target row itself. Refuses to:\n *\n * - move a row to itself (self-loop)\n * - move a row under one of its own descendants (would create a cycle)\n *\n * Persists via `save()`. Caller is responsible for any out-of-band\n * denormalization (e.g. depth caches on subclasses like Tag.level).\n */\n async moveTo(newParent: this | string | null): Promise<void> {\n const newParentId =\n newParent === null\n ? null\n : typeof newParent === 'string'\n ? newParent\n : (newParent.id ?? null);\n\n if (newParentId !== null && newParentId === this.id) {\n throw new Error(\n `Cannot move ${this.constructor.name} ${this.id} to itself.`,\n );\n }\n\n if (newParentId !== null) {\n const descendants = await this.getDescendants();\n if (descendants.some((d) => d.id === newParentId)) {\n throw new Error(\n `Cannot move ${this.constructor.name} ${this.id} under one of its own descendants (${newParentId}) — would create a cycle.`,\n );\n }\n }\n\n this.parentId = newParentId;\n await this.save();\n }\n}\n"],"names":[],"mappings":"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"}
@@ -0,0 +1,57 @@
1
+ /**
2
+ * @smrt/core - Core AI agent framework with standardized collections and code generators
3
+ *
4
+ * This package provides the foundational framework for building vertical AI agents.
5
+ * It provides core abstractions and integrates with other HAVE SDK packages
6
+ * (ai, files, sql) to provide a unified interface.
7
+ *
8
+ * Key components:
9
+ * - SmrtClass: Foundation class providing access to database, filesystem, and AI
10
+ * - SmrtObject: Persistent object with unique identifiers and database storage
11
+ * - SmrtCollection: Collection interface for managing sets of SmrtObjects
12
+ *
13
+ * Generators:
14
+ * - CLIGenerator: Create admin CLI tools from SMRT objects
15
+ * - APIGenerator: Generate REST APIs for SMRT objects
16
+ * - MCPGenerator: Create MCP servers for AI model integration
17
+ */
18
+ export * from './adapters/index';
19
+ export { applyOneToManyChildAccessors, childAccessorName, } from './child-accessors';
20
+ export * from './class';
21
+ export * from './collection';
22
+ export { broadcastCacheInvalidation, CACHE_INVALIDATION_CHANNEL, type CollectionCacheConfig, ensureCacheInvalidationListener, getCacheGeneration, invalidateCollectionCache, resetCollectionCache, resolveDbCacheKey, stopCacheInvalidationListeners, } from './collection-cache';
23
+ export type { AiUsageConfig, GlobalSignalConfig, MetricsConfig, PubSubConfig, } from './config';
24
+ export { config } from './config';
25
+ export { type DatabaseConfig, isDatabaseInterface, type ResolveDatabaseOptions, resolveDatabase, } from './database';
26
+ export { applyPendingDecoratorRegistrations, type CompatiblePropertyDecorator, type CompatiblePropertyDecoratorContext, type LegacyPropertyDecoratorTarget, registerCompatibleFieldDecorator, } from './decorators/compatibility';
27
+ export { type CrossPackageRefOptions, crossPackageRef, type FieldOptions, field, foreignKey, type Meta, manyToMany, meta, type NumericFieldOptions, oneToMany, type RelationshipFieldOptions, type TextFieldOptions, } from './decorators/index';
28
+ export * from './dispatch/index';
29
+ export * from './embeddings/index';
30
+ export * from './errors';
31
+ export * from './generators/index';
32
+ export { type HierarchyView, SmrtHierarchical } from './hierarchical';
33
+ export * from './interceptors';
34
+ export { type JunctionAttachOptions, type JunctionFilterOptions, SmrtJunction, } from './junction';
35
+ export * from './knowledge';
36
+ export type { ConfigResolver, LazyConfigSentinel, ResolveLazyConfigOptions, } from './lazy-config';
37
+ export { getClassConfigResolvers, getConfigResolver, isLazyConfigSentinel, listConfigResolvers, registerConfigResolver, resetConfigResolvers, resolveLazyConfig, unregisterConfigResolver, } from './lazy-config';
38
+ export * from './manifest/index';
39
+ export type { DiffOptions } from './migrations/differ';
40
+ export { generateSchemaDiff, getSQLFromDiff, hasActionableChanges, SchemaComparer, } from './migrations/differ';
41
+ export * from './object';
42
+ export { SmrtPolymorphicAssociation, type SmrtPolymorphicAssociationOptions, } from './polymorphic-association';
43
+ export * from './registry';
44
+ export { smrt as smrtRegistry } from './registry';
45
+ export * from './runtime/index';
46
+ export { detectEngine, generateDDLForEngine } from './schema/ddl';
47
+ export type { SchemaDefinition } from './schema/types';
48
+ export * from './signals/index';
49
+ export * from './system/index';
50
+ export type { DiscoveryStrategy, ForgetOptions, ForgetScopeOptions, NoteMetadata, NoteOptions, RecallAllOptions, RecallOptions, SystemTableConfig, } from './system/types';
51
+ export { resetVerifiedTables } from './table-cache';
52
+ export { getTestDatabase, type TestDatabaseOptions, } from './testing/database';
53
+ export * from './tools/index';
54
+ export { clone, getAdapterInfo, isValid, type JSONAdapter, type ParseError, parse, type Result, type StringifyError, safeParse, safeStringify, stringify, } from './utils/json';
55
+ export { createQualifiedName, getClassName, getPackageFromQualifiedName, isFromPackage, isQualifiedName, isType, type ParsedQualifiedName, parseQualifiedName, qualifiedNamesEqual, } from './utils/qualified-names';
56
+ export { smrtPlugin } from './vite-plugin/index';
57
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"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"}
package/dist/index.js ADDED
@@ -0,0 +1,202 @@
1
+ import { AiUsageCollector, AiUsagePersistenceHandler } from "./adapters/ai-usage.js";
2
+ import { DEFAULT_AI_COST_RATES, estimateAiUsageCost } from "./adapters/cost-rates.js";
3
+ import { MetricsAdapter } from "./adapters/metrics.js";
4
+ import { PubSubAdapter } from "./adapters/pubsub.js";
5
+ import { applyOneToManyChildAccessors, childAccessorName } from "./child-accessors.js";
6
+ import { SmrtClass } from "./class.js";
7
+ import { SmrtCollection } from "./collection.js";
8
+ import { CACHE_INVALIDATION_CHANNEL, broadcastCacheInvalidation, ensureCacheInvalidationListener, getCacheGeneration, invalidateCollectionCache, resetCollectionCache, resolveDbCacheKey, stopCacheInvalidationListeners } from "./collection-cache.js";
9
+ import { config } from "./config.js";
10
+ import { isDatabaseInterface, resolveDatabase } from "./database.js";
11
+ import { applyPendingDecoratorRegistrations, registerCompatibleFieldDecorator } from "./decorators/compatibility.js";
12
+ import { crossPackageRef, field, foreignKey, manyToMany, meta, oneToMany } from "./decorators/index.js";
13
+ import { DispatchBus, createDispatchBus } from "./dispatch/bus.js";
14
+ import { DispatchCollection } from "./dispatch/collections/Dispatches.js";
15
+ import { DispatchSubscriptionCollection } from "./dispatch/collections/DispatchSubscriptions.js";
16
+ import { Dispatch } from "./dispatch/models/Dispatch.js";
17
+ import { DispatchSubscription } from "./dispatch/models/DispatchSubscription.js";
18
+ import { resolveDispatchTenantId, resolveDispatchTenantScope, setDispatchTenantResolver } from "./dispatch/tenant-resolver.js";
19
+ import { ContentHasher } from "./embeddings/hash.js";
20
+ import { DEFAULT_EMBEDDING_CONFIG, EmbeddingProvider } from "./embeddings/provider.js";
21
+ import { CosineSimilarity } from "./embeddings/similarity.js";
22
+ import { EmbeddingStorage } from "./embeddings/storage.js";
23
+ import { AIError, ConfigurationError, DatabaseError, ErrorUtils, FilesystemError, NetworkError, RuntimeError, SmrtError, TenantIsolationError, ValidationError, ValidationReport, ValidationUtils } from "./errors.js";
24
+ import { CLIGenerator, getCLIHandler, setupCLI } from "./generators/cli.js";
25
+ import { MCPGenerator } from "./generators/mcp.js";
26
+ import { APIGenerator, createRestServer, startRestServer } from "./generators/rest.js";
27
+ import { generateOpenAPISpec, setupSwaggerUI } from "./generators/swagger.js";
28
+ import { runWithTenantGate, setTenantEntryPointRunner } from "./generators/tenant-gate.js";
29
+ import { SmrtHierarchical } from "./hierarchical.js";
30
+ import { GlobalInterceptors, createInterceptorContext } from "./interceptors.js";
31
+ import { SmrtJunction } from "./junction.js";
32
+ import { buildDomainKnowledgeManifest } from "./knowledge.js";
33
+ import { getClassConfigResolvers, getConfigResolver, isLazyConfigSentinel, listConfigResolvers, registerConfigResolver, resetConfigResolvers, resolveLazyConfig, unregisterConfigResolver } from "./lazy-config.js";
34
+ import { getManifest, manifest, staticManifest } from "./manifest/index.js";
35
+ import { SchemaComparer, generateSchemaDiff, getSQLFromDiff, hasActionableChanges } from "./migrations/differ.js";
36
+ import { SmrtObject } from "./object.js";
37
+ import { SmrtPolymorphicAssociation } from "./polymorphic-association.js";
38
+ import { ObjectRegistry, smrt, smrt as smrt2 } from "./registry.js";
39
+ import { createSmrtClient } from "./runtime/client.js";
40
+ import { SmrtMCPServer, createMCPServer } from "./runtime/mcp.js";
41
+ import { createSmrtServer } from "./runtime/server.js";
42
+ import { detectEngine, generateDDLForEngine } from "./schema/ddl/index.js";
43
+ import { SignalBus } from "./signals/bus.js";
44
+ import { SignalSanitizer } from "./signals/sanitizer.js";
45
+ import { ensureDispatchSubscriptionsSystemTableCompatibility, ensureDispatchSystemTableCompatibility, ensureJobEventsSystemTableCompatibility, ensureJobsSystemTableCompatibility, ensureLegacySystemTableCompatibility, tableExists } from "./system/compatibility.js";
46
+ import { resetVerifiedTables } from "./table-cache.js";
47
+ import { getTestDatabase } from "./testing/database.js";
48
+ import { executeToolCall, executeToolCalls, formatToolResults, validateToolCall } from "./tools/tool-executor.js";
49
+ import { convertTypeToJsonSchema, generateToolFromMethod, generateToolManifest, shouldIncludeMethod } from "./tools/tool-generator.js";
50
+ import { clone, getAdapterInfo, isValid, parse, safeParse, safeStringify, stringify } from "./utils/json.js";
51
+ import { createQualifiedName, getClassName, getPackageFromQualifiedName, isFromPackage, isQualifiedName, isType, parseQualifiedName, qualifiedNamesEqual } from "./utils/qualified-names.js";
52
+ import { smrtPlugin } from "./vite-plugin/index.js";
53
+ import { ManifestBuilder } from "./manifest/generator.js";
54
+ import { ManifestGenerator } from "./scanner/manifest-generator.js";
55
+ import { ManifestManager } from "./manifest/manager.js";
56
+ import { SMRT_COLLECTION_BASE_NAMES, isSmrtCollectionExtendsName } from "./registry/collection-resolution.js";
57
+ import { discoverManifestEntry, findManifestEntryByQualifiedName, loadExternalManifest, loadExternalManifestSync, loadLocalTestManifestSync, loadManifestFromPathSync } from "./manifest/manifest-loader.js";
58
+ export {
59
+ AIError,
60
+ APIGenerator,
61
+ AiUsageCollector,
62
+ AiUsagePersistenceHandler,
63
+ CACHE_INVALIDATION_CHANNEL,
64
+ CLIGenerator,
65
+ ConfigurationError,
66
+ ContentHasher,
67
+ CosineSimilarity,
68
+ DEFAULT_AI_COST_RATES,
69
+ DEFAULT_EMBEDDING_CONFIG,
70
+ DatabaseError,
71
+ Dispatch,
72
+ DispatchBus,
73
+ DispatchCollection,
74
+ DispatchSubscription,
75
+ DispatchSubscriptionCollection,
76
+ EmbeddingProvider,
77
+ EmbeddingStorage,
78
+ ErrorUtils,
79
+ FilesystemError,
80
+ GlobalInterceptors,
81
+ MCPGenerator,
82
+ ManifestBuilder,
83
+ ManifestGenerator,
84
+ ManifestManager,
85
+ MetricsAdapter,
86
+ NetworkError,
87
+ ObjectRegistry,
88
+ PubSubAdapter,
89
+ RuntimeError,
90
+ SMRT_COLLECTION_BASE_NAMES,
91
+ SchemaComparer,
92
+ SignalBus,
93
+ SignalSanitizer,
94
+ SmrtClass,
95
+ SmrtCollection,
96
+ SmrtError,
97
+ SmrtHierarchical,
98
+ SmrtJunction,
99
+ SmrtMCPServer,
100
+ SmrtObject,
101
+ SmrtPolymorphicAssociation,
102
+ TenantIsolationError,
103
+ ValidationError,
104
+ ValidationReport,
105
+ ValidationUtils,
106
+ applyOneToManyChildAccessors,
107
+ applyPendingDecoratorRegistrations,
108
+ broadcastCacheInvalidation,
109
+ buildDomainKnowledgeManifest,
110
+ childAccessorName,
111
+ clone,
112
+ config,
113
+ convertTypeToJsonSchema,
114
+ createDispatchBus,
115
+ createInterceptorContext,
116
+ createMCPServer,
117
+ createQualifiedName,
118
+ createRestServer,
119
+ createSmrtClient,
120
+ createSmrtServer,
121
+ crossPackageRef,
122
+ detectEngine,
123
+ discoverManifestEntry,
124
+ ensureCacheInvalidationListener,
125
+ ensureDispatchSubscriptionsSystemTableCompatibility,
126
+ ensureDispatchSystemTableCompatibility,
127
+ ensureJobEventsSystemTableCompatibility,
128
+ ensureJobsSystemTableCompatibility,
129
+ ensureLegacySystemTableCompatibility,
130
+ estimateAiUsageCost,
131
+ executeToolCall,
132
+ executeToolCalls,
133
+ field,
134
+ findManifestEntryByQualifiedName,
135
+ foreignKey,
136
+ formatToolResults,
137
+ generateDDLForEngine,
138
+ generateOpenAPISpec,
139
+ generateSchemaDiff,
140
+ generateToolFromMethod,
141
+ generateToolManifest,
142
+ getAdapterInfo,
143
+ getCLIHandler,
144
+ getCacheGeneration,
145
+ getClassConfigResolvers,
146
+ getClassName,
147
+ getConfigResolver,
148
+ getManifest,
149
+ getPackageFromQualifiedName,
150
+ getSQLFromDiff,
151
+ getTestDatabase,
152
+ hasActionableChanges,
153
+ invalidateCollectionCache,
154
+ isDatabaseInterface,
155
+ isFromPackage,
156
+ isLazyConfigSentinel,
157
+ isQualifiedName,
158
+ isSmrtCollectionExtendsName,
159
+ isType,
160
+ isValid,
161
+ listConfigResolvers,
162
+ loadExternalManifest,
163
+ loadExternalManifestSync,
164
+ loadLocalTestManifestSync,
165
+ loadManifestFromPathSync,
166
+ manifest,
167
+ manyToMany,
168
+ meta,
169
+ oneToMany,
170
+ parse,
171
+ parseQualifiedName,
172
+ qualifiedNamesEqual,
173
+ registerCompatibleFieldDecorator,
174
+ registerConfigResolver,
175
+ resetCollectionCache,
176
+ resetConfigResolvers,
177
+ resetVerifiedTables,
178
+ resolveDatabase,
179
+ resolveDbCacheKey,
180
+ resolveDispatchTenantId,
181
+ resolveDispatchTenantScope,
182
+ resolveLazyConfig,
183
+ runWithTenantGate,
184
+ safeParse,
185
+ safeStringify,
186
+ setDispatchTenantResolver,
187
+ setTenantEntryPointRunner,
188
+ setupCLI,
189
+ setupSwaggerUI,
190
+ shouldIncludeMethod,
191
+ smrt,
192
+ smrtPlugin,
193
+ smrt2 as smrtRegistry,
194
+ startRestServer,
195
+ staticManifest,
196
+ stopCacheInvalidationListeners,
197
+ stringify,
198
+ tableExists,
199
+ unregisterConfigResolver,
200
+ validateToolCall
201
+ };
202
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}