@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 @@
1
+ {"version":3,"file":"database.js","sources":["../src/database.ts"],"sourcesContent":["/**\n * Database configuration and resolution utilities\n *\n * This module provides a unified type for database configuration options\n * and a utility function to resolve any config format to a DatabaseInterface.\n *\n * @module\n */\n\nimport type { DatabaseInterface } from '@happyvertical/sql';\nimport { getDatabase } from '@happyvertical/sql';\n\n/**\n * Unified type for all database configuration formats\n *\n * Supports three formats:\n * - **String**: Connection URL (e.g., 'products.db', ':memory:', 'postgres://...')\n * - **Config object**: Full configuration with type, url, and options\n * - **DatabaseInterface**: Pre-initialized database instance\n *\n * @example\n * ```typescript\n * // String shortcut\n * const config: DatabaseConfig = 'products.db';\n *\n * // Config object\n * const config: DatabaseConfig = {\n * type: 'sqlite',\n * url: 'products.db',\n * authToken: 'token'\n * };\n *\n * // Pre-initialized instance\n * const db = await getDatabase({ type: 'sqlite', url: ':memory:' });\n * const config: DatabaseConfig = db;\n * ```\n */\nexport type DatabaseConfig =\n | string\n | {\n url?: string;\n type?: 'sqlite' | 'postgres' | 'duckdb' | 'json';\n authToken?: string;\n [key: string]: any;\n }\n | DatabaseInterface;\n\n/**\n * Type guard to check if a value is a DatabaseInterface instance\n *\n * @param value - Value to check\n * @returns True if value has query() and close() methods\n *\n * @example\n * ```typescript\n * if (isDatabaseInterface(config)) {\n * // config is DatabaseInterface\n * await config.query('SELECT 1');\n * }\n * ```\n */\nexport function isDatabaseInterface(\n value: unknown,\n): value is DatabaseInterface {\n return (\n value !== null &&\n typeof value === 'object' &&\n 'query' in value &&\n typeof (value as any).query === 'function'\n );\n}\n\n/**\n * Options for resolving a database configuration\n */\nexport interface ResolveDatabaseOptions {\n /**\n * Cache key for connection pooling.\n * If provided, the same dbid returns the same cached connection.\n */\n dbid?: string;\n\n /**\n * Optional pre-generated schemas to pass to the database adapter.\n *\n * Intended for explicit tooling and test utilities that bootstrap schema\n * ahead of runtime. Core runtime no longer passes these automatically.\n */\n schemas?: Record<string, any>;\n}\n\n/**\n * Resolve any DatabaseConfig format to a DatabaseInterface instance\n *\n * This utility function normalizes the three config formats:\n * 1. **String URL**: Passed to getDatabase() with auto-detected type\n * 2. **Config object**: Passed to getDatabase() directly\n * 3. **DatabaseInterface**: Returned as-is\n *\n * @param config - Database configuration in any supported format\n * @param options - Resolution options (dbid for caching, optional explicit schemas)\n * @returns Promise resolving to a DatabaseInterface instance\n *\n * @example\n * ```typescript\n * // String URL\n * const db = await resolveDatabase('products.db');\n *\n * // Config object\n * const db = await resolveDatabase({\n * type: 'postgres',\n * url: 'postgres://localhost/mydb'\n * });\n *\n * // Pre-initialized instance (returned as-is)\n * const existingDb = await getDatabase({ url: ':memory:' });\n * const db = await resolveDatabase(existingDb);\n * console.log(db === existingDb); // true\n * ```\n */\nexport async function resolveDatabase(\n config: DatabaseConfig,\n options: ResolveDatabaseOptions = {},\n): Promise<DatabaseInterface> {\n const { dbid, schemas } = options;\n\n // Already a DatabaseInterface instance - return as-is\n if (isDatabaseInterface(config)) {\n return config;\n }\n\n // String URL shortcut\n if (typeof config === 'string') {\n const isMemoryDb = config === ':memory:';\n return getDatabase({\n url: config,\n schemas,\n ...(isMemoryDb ? {} : { dbid: dbid ?? `smrt:${config}` }),\n });\n }\n\n // Config object\n // Only default to :memory: for SQLite (or unspecified type which defaults to SQLite)\n // Other adapters (json, postgres, duckdb) require explicit URLs\n const canUseMemory = !config.type || config.type === 'sqlite';\n const dbUrl = config.url || (canUseMemory ? ':memory:' : '');\n const isMemoryDb = dbUrl === ':memory:';\n return getDatabase({\n ...config,\n url: dbUrl,\n schemas,\n ...(isMemoryDb ? {} : { dbid: dbid ?? `smrt:${dbUrl}` }),\n } as any);\n}\n"],"names":["isMemoryDb"],"mappings":";AA6DO,SAAS,oBACd,OAC4B;AAC5B,SACE,UAAU,QACV,OAAO,UAAU,YACjB,WAAW,SACX,OAAQ,MAAc,UAAU;AAEpC;AAkDA,eAAsB,gBACpB,QACA,UAAkC,IACN;AAC5B,QAAM,EAAE,MAAM,QAAA,IAAY;AAG1B,MAAI,oBAAoB,MAAM,GAAG;AAC/B,WAAO;AAAA,EACT;AAGA,MAAI,OAAO,WAAW,UAAU;AAC9B,UAAMA,cAAa,WAAW;AAC9B,WAAO,YAAY;AAAA,MACjB,KAAK;AAAA,MACL;AAAA,MACA,GAAIA,cAAa,CAAA,IAAK,EAAE,MAAM,QAAQ,QAAQ,MAAM,GAAA;AAAA,IAAG,CACxD;AAAA,EACH;AAKA,QAAM,eAAe,CAAC,OAAO,QAAQ,OAAO,SAAS;AACrD,QAAM,QAAQ,OAAO,QAAQ,eAAe,aAAa;AACzD,QAAM,aAAa,UAAU;AAC7B,SAAO,YAAY;AAAA,IACjB,GAAG;AAAA,IACH,KAAK;AAAA,IACL;AAAA,IACA,GAAI,aAAa,CAAA,IAAK,EAAE,MAAM,QAAQ,QAAQ,KAAK,GAAA;AAAA,EAAG,CAChD;AACV;"}
@@ -0,0 +1,14 @@
1
+ export type LegacyPropertyDecoratorTarget = {
2
+ constructor?: Function & {
3
+ name?: string;
4
+ };
5
+ };
6
+ export type CompatiblePropertyDecoratorContext<This, Value> = string | symbol | ClassFieldDecoratorContext<This, Value>;
7
+ export interface CompatiblePropertyDecorator<This = any, Value = any> {
8
+ (target: object, propertyKey: string | symbol): void;
9
+ (value: undefined, context: ClassFieldDecoratorContext<This, Value>): void;
10
+ }
11
+ export declare function resolveDecoratorClassName(target: unknown): string | undefined;
12
+ export declare function applyPendingDecoratorRegistrations(target: Function, decoratorContext?: ClassDecoratorContext): void;
13
+ export declare function registerCompatibleFieldDecorator<This, Value>(targetOrValue: LegacyPropertyDecoratorTarget | undefined, propertyKeyOrContext: CompatiblePropertyDecoratorContext<This, Value>, registerFieldDecorator: (className: string, propertyKey: string) => void): void;
14
+ //# sourceMappingURL=compatibility.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compatibility.d.ts","sourceRoot":"","sources":["../../src/decorators/compatibility.ts"],"names":[],"mappings":"AAcA,MAAM,MAAM,6BAA6B,GAAG;IAC1C,WAAW,CAAC,EAAE,QAAQ,GAAG;QACvB,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,kCAAkC,CAAC,IAAI,EAAE,KAAK,IACtD,MAAM,GACN,MAAM,GACN,0BAA0B,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;AAE5C,MAAM,WAAW,2BAA2B,CAAC,IAAI,GAAG,GAAG,EAAE,KAAK,GAAG,GAAG;IAClE,CAAC,MAAM,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;IACrD,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,0BAA0B,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,IAAI,CAAC;CAC5E;AA2FD,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAU7E;AAED,wBAAgB,kCAAkC,CAChD,MAAM,EAAE,QAAQ,EAChB,gBAAgB,CAAC,EAAE,qBAAqB,GACvC,IAAI,CAsBN;AAED,wBAAgB,gCAAgC,CAAC,IAAI,EAAE,KAAK,EAC1D,aAAa,EAAE,6BAA6B,GAAG,SAAS,EACxD,oBAAoB,EAAE,kCAAkC,CAAC,IAAI,EAAE,KAAK,CAAC,EACrE,sBAAsB,EAAE,CAAC,SAAS,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,KAAK,IAAI,GACvE,IAAI,CAiCN"}
@@ -0,0 +1,111 @@
1
+ const PENDING_FIELD_DECORATORS_KEY = /* @__PURE__ */ Symbol.for(
2
+ "@happyvertical/smrt-core/pending-field-decorators"
3
+ );
4
+ const standardDecoratorRegistrations = /* @__PURE__ */ new WeakMap();
5
+ function getDecoratorConstructor(target) {
6
+ if (typeof target === "function") {
7
+ return target;
8
+ }
9
+ if (target && typeof target === "object") {
10
+ return target.constructor;
11
+ }
12
+ return void 0;
13
+ }
14
+ function markStandardDecoratorRegistration(target, register) {
15
+ const ctor = getDecoratorConstructor(target);
16
+ if (!ctor) {
17
+ return false;
18
+ }
19
+ const registeredCallbacks = standardDecoratorRegistrations.get(ctor) ?? /* @__PURE__ */ new WeakSet();
20
+ if (registeredCallbacks.has(register)) {
21
+ return false;
22
+ }
23
+ registeredCallbacks.add(register);
24
+ standardDecoratorRegistrations.set(ctor, registeredCallbacks);
25
+ return true;
26
+ }
27
+ function getDecoratorMetadata(contextOrMetadata) {
28
+ if (!contextOrMetadata || typeof contextOrMetadata !== "object") {
29
+ return void 0;
30
+ }
31
+ if ("metadata" in contextOrMetadata) {
32
+ const { metadata } = contextOrMetadata;
33
+ return metadata && typeof metadata === "object" ? metadata : void 0;
34
+ }
35
+ return contextOrMetadata;
36
+ }
37
+ function getClassDecoratorMetadata(target, decoratorContext) {
38
+ const metadataFromContext = getDecoratorMetadata(decoratorContext);
39
+ if (metadataFromContext) {
40
+ return metadataFromContext;
41
+ }
42
+ const metadataSymbol = Symbol.metadata;
43
+ if (!metadataSymbol) {
44
+ return void 0;
45
+ }
46
+ const metadata = target[metadataSymbol];
47
+ return metadata && typeof metadata === "object" ? metadata : void 0;
48
+ }
49
+ function queuePendingFieldDecorator(metadata, register) {
50
+ const pendingDecorators = metadata[PENDING_FIELD_DECORATORS_KEY] ?? [];
51
+ pendingDecorators.push({ register });
52
+ metadata[PENDING_FIELD_DECORATORS_KEY] = pendingDecorators;
53
+ }
54
+ function resolveDecoratorClassName(target) {
55
+ if (typeof target === "function") {
56
+ return target.name;
57
+ }
58
+ if (target && typeof target === "object") {
59
+ return target.constructor?.name;
60
+ }
61
+ return void 0;
62
+ }
63
+ function applyPendingDecoratorRegistrations(target, decoratorContext) {
64
+ const metadata = getClassDecoratorMetadata(target, decoratorContext);
65
+ if (!metadata) {
66
+ return;
67
+ }
68
+ const pendingDecorators = metadata[PENDING_FIELD_DECORATORS_KEY];
69
+ if (!pendingDecorators || pendingDecorators.length === 0) {
70
+ return;
71
+ }
72
+ for (const { register } of pendingDecorators) {
73
+ if (!markStandardDecoratorRegistration(target, register)) {
74
+ continue;
75
+ }
76
+ register(target.name);
77
+ }
78
+ Reflect.deleteProperty(metadata, PENDING_FIELD_DECORATORS_KEY);
79
+ }
80
+ function registerCompatibleFieldDecorator(targetOrValue, propertyKeyOrContext, registerFieldDecorator) {
81
+ if (typeof propertyKeyOrContext === "string" || typeof propertyKeyOrContext === "symbol") {
82
+ const className = resolveDecoratorClassName(targetOrValue);
83
+ if (className) {
84
+ registerFieldDecorator(className, String(propertyKeyOrContext));
85
+ }
86
+ return;
87
+ }
88
+ const context = propertyKeyOrContext;
89
+ const propertyKey = String(context.name);
90
+ const register = (className) => registerFieldDecorator(className, propertyKey);
91
+ const metadata = getDecoratorMetadata(context);
92
+ if (metadata) {
93
+ queuePendingFieldDecorator(metadata, register);
94
+ return;
95
+ }
96
+ context.addInitializer?.(function registerSmrtDecorator() {
97
+ if (!markStandardDecoratorRegistration(this, register)) {
98
+ return;
99
+ }
100
+ const className = resolveDecoratorClassName(this);
101
+ if (className) {
102
+ register(className);
103
+ }
104
+ });
105
+ }
106
+ export {
107
+ applyPendingDecoratorRegistrations,
108
+ registerCompatibleFieldDecorator,
109
+ resolveDecoratorClassName
110
+ };
111
+ //# sourceMappingURL=compatibility.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"compatibility.js","sources":["../../src/decorators/compatibility.ts"],"sourcesContent":["type DecoratorMetadataStore = Record<PropertyKey, unknown>;\n\nconst PENDING_FIELD_DECORATORS_KEY = Symbol.for(\n '@happyvertical/smrt-core/pending-field-decorators',\n);\nconst standardDecoratorRegistrations = new WeakMap<\n Function,\n WeakSet<(className: string) => void>\n>();\n\ntype PendingDecoratorRegistration = {\n register: (className: string) => void;\n};\n\nexport type LegacyPropertyDecoratorTarget = {\n constructor?: Function & {\n name?: string;\n };\n};\n\nexport type CompatiblePropertyDecoratorContext<This, Value> =\n | string\n | symbol\n | ClassFieldDecoratorContext<This, Value>;\n\nexport interface CompatiblePropertyDecorator<This = any, Value = any> {\n (target: object, propertyKey: string | symbol): void;\n (value: undefined, context: ClassFieldDecoratorContext<This, Value>): void;\n}\n\nfunction getDecoratorConstructor(target: unknown): Function | undefined {\n if (typeof target === 'function') {\n return target;\n }\n\n if (target && typeof target === 'object') {\n return (target as LegacyPropertyDecoratorTarget).constructor;\n }\n\n return undefined;\n}\n\nfunction markStandardDecoratorRegistration(\n target: unknown,\n register: (className: string) => void,\n): boolean {\n const ctor = getDecoratorConstructor(target);\n if (!ctor) {\n return false;\n }\n\n const registeredCallbacks =\n standardDecoratorRegistrations.get(ctor) ?? new WeakSet();\n if (registeredCallbacks.has(register)) {\n return false;\n }\n\n registeredCallbacks.add(register);\n standardDecoratorRegistrations.set(ctor, registeredCallbacks);\n return true;\n}\n\nfunction getDecoratorMetadata(\n contextOrMetadata:\n | ClassFieldDecoratorContext<any, any>\n | ClassDecoratorContext\n | DecoratorMetadataStore\n | undefined,\n): DecoratorMetadataStore | undefined {\n if (!contextOrMetadata || typeof contextOrMetadata !== 'object') {\n return undefined;\n }\n\n if ('metadata' in contextOrMetadata) {\n const { metadata } = contextOrMetadata as {\n metadata?: DecoratorMetadataStore;\n };\n return metadata && typeof metadata === 'object' ? metadata : undefined;\n }\n\n return contextOrMetadata;\n}\n\nfunction getClassDecoratorMetadata(\n target: Function,\n decoratorContext?: ClassDecoratorContext,\n): DecoratorMetadataStore | undefined {\n const metadataFromContext = getDecoratorMetadata(decoratorContext);\n if (metadataFromContext) {\n return metadataFromContext;\n }\n\n const metadataSymbol = (Symbol as typeof Symbol & { metadata?: symbol })\n .metadata;\n if (!metadataSymbol) {\n return undefined;\n }\n\n const metadata = (target as unknown as Record<PropertyKey, unknown>)[\n metadataSymbol\n ];\n return metadata && typeof metadata === 'object'\n ? (metadata as DecoratorMetadataStore)\n : undefined;\n}\n\nfunction queuePendingFieldDecorator(\n metadata: DecoratorMetadataStore,\n register: (className: string) => void,\n): void {\n const pendingDecorators =\n (metadata[PENDING_FIELD_DECORATORS_KEY] as\n | PendingDecoratorRegistration[]\n | undefined) ?? [];\n\n pendingDecorators.push({ register });\n metadata[PENDING_FIELD_DECORATORS_KEY] = pendingDecorators;\n}\n\nexport function resolveDecoratorClassName(target: unknown): string | undefined {\n if (typeof target === 'function') {\n return target.name;\n }\n\n if (target && typeof target === 'object') {\n return (target as LegacyPropertyDecoratorTarget).constructor?.name;\n }\n\n return undefined;\n}\n\nexport function applyPendingDecoratorRegistrations(\n target: Function,\n decoratorContext?: ClassDecoratorContext,\n): void {\n const metadata = getClassDecoratorMetadata(target, decoratorContext);\n if (!metadata) {\n return;\n }\n\n const pendingDecorators = metadata[PENDING_FIELD_DECORATORS_KEY] as\n | PendingDecoratorRegistration[]\n | undefined;\n if (!pendingDecorators || pendingDecorators.length === 0) {\n return;\n }\n\n for (const { register } of pendingDecorators) {\n if (!markStandardDecoratorRegistration(target, register)) {\n continue;\n }\n\n register(target.name);\n }\n\n Reflect.deleteProperty(metadata, PENDING_FIELD_DECORATORS_KEY);\n}\n\nexport function registerCompatibleFieldDecorator<This, Value>(\n targetOrValue: LegacyPropertyDecoratorTarget | undefined,\n propertyKeyOrContext: CompatiblePropertyDecoratorContext<This, Value>,\n registerFieldDecorator: (className: string, propertyKey: string) => void,\n): void {\n if (\n typeof propertyKeyOrContext === 'string' ||\n typeof propertyKeyOrContext === 'symbol'\n ) {\n const className = resolveDecoratorClassName(targetOrValue);\n if (className) {\n registerFieldDecorator(className, String(propertyKeyOrContext));\n }\n return;\n }\n\n const context = propertyKeyOrContext;\n const propertyKey = String(context.name);\n const register = (className: string) =>\n registerFieldDecorator(className, propertyKey);\n const metadata = getDecoratorMetadata(context);\n\n if (metadata) {\n queuePendingFieldDecorator(metadata, register);\n return;\n }\n\n context.addInitializer?.(function registerSmrtDecorator() {\n if (!markStandardDecoratorRegistration(this, register)) {\n return;\n }\n\n const className = resolveDecoratorClassName(this);\n if (className) {\n register(className);\n }\n });\n}\n"],"names":[],"mappings":"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"}
@@ -0,0 +1,381 @@
1
+ import { SQLDataType } from '../schema/types.js';
2
+ import { CompatiblePropertyDecorator } from './compatibility.js';
3
+ /**
4
+ * Meta type wrapper for STI (Single Table Inheritance) meta fields
5
+ *
6
+ * Fields typed as Meta<T> are stored in the _meta_data JSONB column
7
+ * rather than as direct table columns. Used for child-specific fields
8
+ * in STI hierarchies.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * @smrt({ tableStrategy: 'sti' })
13
+ * class Event extends SmrtObject {
14
+ * title: string = '';
15
+ * }
16
+ *
17
+ * @smrt()
18
+ * class Meeting extends Event {
19
+ * // Stored in _meta_data JSONB column
20
+ * roomNumber: Meta<string> = '';
21
+ * attendees: Meta<string[]> = [];
22
+ * }
23
+ * ```
24
+ */
25
+ export type Meta<T> = T;
26
+ /**
27
+ * Base field options
28
+ */
29
+ export type PrimitiveFieldType = 'text' | 'integer' | 'decimal' | 'boolean' | 'datetime' | 'json';
30
+ export type FieldType = PrimitiveFieldType | 'meta' | 'foreignKey' | 'crossPackageRef' | 'oneToMany' | 'manyToMany';
31
+ export interface FieldOptions {
32
+ /** Explicit field type for runtime-only registration paths */
33
+ type?: FieldType;
34
+ /** Explicit SQL storage type when runtime and persistence contracts differ */
35
+ sqlType?: SQLDataType;
36
+ /** Whether the field is required */
37
+ required?: boolean;
38
+ /** Default value for the field */
39
+ default?: any;
40
+ /** Whether the field is unique */
41
+ unique?: boolean;
42
+ /**
43
+ * When `true`, the schema emits a database index targeting this field.
44
+ *
45
+ * For regular (column-backed) fields the index is a plain column index.
46
+ * For `@meta()` fields stored inside `_meta_data` JSONB, the index targets
47
+ * the JSON path — `json_extract(_meta_data, '$.fieldName')` on SQLite,
48
+ * `(_meta_data->>'fieldName')` on Postgres — giving WHERE clauses on that
49
+ * meta key the same performance as a real column.
50
+ */
51
+ indexed?: boolean;
52
+ /** Whether the field is nullable */
53
+ nullable?: boolean;
54
+ /** Whether the field should be excluded from database */
55
+ transient?: boolean;
56
+ /**
57
+ * Marks the field as sensitive (e.g. API secrets, credentials, tax IDs).
58
+ *
59
+ * Sensitive fields are still persisted to the database, but the framework:
60
+ * - excludes them from `toPublicJSON()` (the serializer used by generated
61
+ * REST/MCP/SvelteKit routes), so they never appear in API responses; and
62
+ * - rejects them as `where`-clause filter keys, closing the
63
+ * `?secret[like]=...` value-probing oracle.
64
+ *
65
+ * Use this for any column that holds a secret value that must never be
66
+ * read back over a generated network surface.
67
+ */
68
+ sensitive?: boolean;
69
+ /**
70
+ * Marks the field as read-only over generated write surfaces.
71
+ *
72
+ * Read-only fields are stripped from the request body before
73
+ * `create`/`update` in generated REST/MCP/SvelteKit routes, so callers
74
+ * cannot mass-assign them. Server-side code can still set them directly.
75
+ */
76
+ readonly?: boolean;
77
+ /** Field description */
78
+ description?: string;
79
+ /**
80
+ * Controls whether the field is included in JSON exports.
81
+ * - `true`: Always exported (unless site explicitly excludes it)
82
+ * - `false`: Never exported (cannot be overridden by site config)
83
+ * - `undefined`: Uses site's fieldExportDefault setting
84
+ */
85
+ exported?: boolean;
86
+ }
87
+ /**
88
+ * Options for text fields
89
+ */
90
+ export interface TextFieldOptions extends FieldOptions {
91
+ /** Minimum length for text fields */
92
+ minLength?: number;
93
+ /** Maximum length for text fields */
94
+ maxLength?: number;
95
+ /** Regex pattern for validation */
96
+ pattern?: RegExp | string;
97
+ }
98
+ /**
99
+ * Options for numeric fields
100
+ */
101
+ export interface NumericFieldOptions extends FieldOptions {
102
+ /** Minimum value */
103
+ min?: number;
104
+ /** Maximum value */
105
+ max?: number;
106
+ }
107
+ /**
108
+ * Options for relationship fields
109
+ */
110
+ export interface RelationshipFieldOptions extends FieldOptions {
111
+ /** Related class name */
112
+ related?: string;
113
+ /** Foreign key field name */
114
+ foreignKey?: string;
115
+ /** Through table for many-to-many */
116
+ through?: string;
117
+ /** Relationship type */
118
+ type?: 'foreignKey' | 'crossPackageRef' | 'oneToMany' | 'manyToMany';
119
+ }
120
+ /**
121
+ * Options specific to cross-package references.
122
+ */
123
+ export interface CrossPackageRefOptions extends Omit<RelationshipFieldOptions, 'related' | 'type'> {
124
+ /**
125
+ * Storage type for the referenced target id. Defaults to 'uuid'.
126
+ *
127
+ * Use 'text' only when the external target model declares
128
+ * `@smrt({ idType: 'text' })`.
129
+ */
130
+ idType?: 'uuid' | 'text';
131
+ /**
132
+ * When `true`, the framework verifies the referenced object exists at save time.
133
+ * Validation uses the target package's manifest (loaded on demand via
134
+ * `ObjectRegistry.ensureManifestLoaded()`), so this requires the target manifest
135
+ * to be discoverable at runtime.
136
+ *
137
+ * Empty/null values are always allowed (treated as "no reference set").
138
+ *
139
+ * Defaults to `false` — same behavior as a plain string field today.
140
+ */
141
+ validate?: boolean;
142
+ }
143
+ /**
144
+ * Marks a class property with validation constraints and metadata options.
145
+ *
146
+ * Use `@field()` when you need options beyond what plain TypeScript initializers
147
+ * express — required validation, numeric ranges, string length limits, uniqueness,
148
+ * or transient (non-persisted) computed properties.
149
+ *
150
+ * For plain persisted fields with no constraints, no decorator is needed: just
151
+ * declare the property with a TypeScript initializer and the framework will infer
152
+ * the column type from the default value (`0` → INTEGER, `0.0` → DECIMAL, `''` → TEXT).
153
+ *
154
+ * @param options - Field configuration options
155
+ * @param options.required - If `true`, `save()` throws `ValidationError` when empty/null
156
+ * @param options.unique - Enforces a UNIQUE database constraint
157
+ * @param options.nullable - If `true`, the column accepts NULL (default depends on type)
158
+ * @param options.transient - If `true`, the property is not persisted to the database
159
+ * @param options.default - Default value applied at the database level
160
+ * @param options.description - Human-readable description used in generated API docs
161
+ * @param options.exported - Controls JSON export visibility (see `FieldOptions`)
162
+ * @returns A TypeScript property decorator
163
+ *
164
+ * @example
165
+ * ```typescript
166
+ * @smrt()
167
+ * class Product extends SmrtObject {
168
+ * @field({ required: true, maxLength: 100 })
169
+ * name: string = '';
170
+ *
171
+ * @field({ min: 0 })
172
+ * stock: number = 0;
173
+ *
174
+ * @field({ transient: true })
175
+ * get displayPrice(): string { return `$${this.price.toFixed(2)}`; }
176
+ * }
177
+ * ```
178
+ *
179
+ * @see {@link meta} for STI child-specific fields stored in `_meta_data` JSON
180
+ * @see {@link foreignKey} for typed relationship fields
181
+ */
182
+ export declare function field(options?: FieldOptions | NumericFieldOptions | TextFieldOptions): CompatiblePropertyDecorator;
183
+ /**
184
+ * Declares a many-to-one (foreign key) relationship to another `SmrtObject` class.
185
+ *
186
+ * The decorated property stores the UUID of the related object. At runtime, call
187
+ * `instance.loadRelated('fieldName')` to lazy-load (and cache) the related object,
188
+ * or pass `include: ['fieldName']` to `collection.list()` for batch eager loading.
189
+ *
190
+ * Cross-package rule: Use `@foreignKey()` only for same-package references.
191
+ * For cross-package foreign keys, use a plain `string` property instead to avoid
192
+ * circular dependencies between packages.
193
+ *
194
+ * @param relatedClass - The target class constructor (or class name string)
195
+ * @param options - Optional field constraints (required, nullable, etc.)
196
+ * @returns A TypeScript property decorator
197
+ *
198
+ * @example
199
+ * ```typescript
200
+ * @smrt()
201
+ * class Order extends SmrtObject {
202
+ * // Same-package FK — enables loadRelated() and eager loading
203
+ * @foreignKey(Customer)
204
+ * customerId: string = '';
205
+ * }
206
+ *
207
+ * // Cross-package: use a plain string instead
208
+ * @smrt()
209
+ * class Post extends SmrtObject {
210
+ * authorId: string = ''; // plain string — no circular dep
211
+ * }
212
+ * ```
213
+ *
214
+ * @see {@link oneToMany} for the inverse (parent) side of the relationship
215
+ * @see SmrtObject.loadRelated for lazy-loading the related object at runtime
216
+ */
217
+ export declare function foreignKey(relatedClass: string | Function | any, options?: Omit<RelationshipFieldOptions, 'related'>): CompatiblePropertyDecorator;
218
+ /**
219
+ * Declares a cross-package foreign key reference.
220
+ *
221
+ * Use this for relationships that point to a `SmrtObject` in a *different* package
222
+ * (e.g. `Customer.profileId` pointing at `@happyvertical/smrt-profiles:Profile`).
223
+ * Unlike `@foreignKey()`, this decorator does **not** emit a DDL `FOREIGN KEY`
224
+ * constraint — cross-package classes are not visible at schema-generation time and
225
+ * adding a constraint would force a circular package dependency. The decorated
226
+ * property remains a plain `TEXT` column at the database level.
227
+ *
228
+ * What you get over a plain string field:
229
+ * - The relationship is registered with the `ObjectRegistry`, so `loadRelated()`
230
+ * and `Collection.list({ include })` can resolve it once the target package's
231
+ * manifest is loaded.
232
+ * - Optional save-time validation (`validate: true`) confirms the referenced
233
+ * object exists, catching typos and stale IDs before they hit the database.
234
+ *
235
+ * The `qualifiedName` is a fully-qualified class identifier in the form
236
+ * `@package/scope:ClassName` — for example `@happyvertical/smrt-profiles:Profile`.
237
+ *
238
+ * @param qualifiedName - Qualified name of the target class
239
+ * @param options - Optional field constraints and `validate` flag
240
+ * @returns A TypeScript property decorator
241
+ *
242
+ * @example
243
+ * ```typescript
244
+ * @smrt()
245
+ * class Customer extends SmrtObject {
246
+ * @crossPackageRef('@happyvertical/smrt-profiles:Profile')
247
+ * profileId: string = '';
248
+ *
249
+ * // With save-time validation
250
+ * @crossPackageRef('@happyvertical/smrt-profiles:Profile', { validate: true })
251
+ * primaryContactId: string = '';
252
+ * }
253
+ * ```
254
+ *
255
+ * @see {@link foreignKey} for same-package relationships (emits FK constraint)
256
+ * @see SmrtObject.loadRelated for runtime resolution
257
+ */
258
+ export declare function crossPackageRef(qualifiedName: string, options?: CrossPackageRefOptions): CompatiblePropertyDecorator;
259
+ /**
260
+ * Declares a one-to-many relationship from this object to a collection of related objects.
261
+ *
262
+ * The decorated property is `transient` — it is not persisted as a database column.
263
+ * At runtime, call `instance.loadRelatedMany('fieldName')` to load the related objects,
264
+ * or pass `include: ['fieldName']` to `collection.list()` for batch eager loading (issues
265
+ * a single batched query for all instances instead of N individual queries).
266
+ *
267
+ * The inverse side (`@foreignKey`) must exist on the `relatedClass` pointing back to this
268
+ * class. The framework discovers it automatically via `ObjectRegistry.getInverseRelationships()`.
269
+ *
270
+ * **Generated accessor (R10):** registering the class installs a consistent
271
+ * `get<FieldName>()` instance method (e.g. `items` → `order.getItems()`) that
272
+ * delegates to `loadRelatedMany('items')`. Generation is additive — a
273
+ * hand-rolled method of the same name is never overwritten.
274
+ *
275
+ * **Disambiguation:** when `relatedClass` declares more than one `@foreignKey`
276
+ * back to this class, pass `{ foreignKey: '<inverseFieldName>' }` so both
277
+ * `loadRelatedMany` and the generated accessor resolve the intended inverse
278
+ * side. Without it the first matching foreign key is used.
279
+ *
280
+ * @param relatedClass - The class constructor of the child/related objects
281
+ * @param options - Optional relationship options. `foreignKey` selects the
282
+ * inverse foreign-key field on `relatedClass` when it has more than one.
283
+ * @returns A TypeScript property decorator (sets `transient: true` automatically)
284
+ *
285
+ * @example
286
+ * ```typescript
287
+ * @smrt()
288
+ * class Order extends SmrtObject {
289
+ * @oneToMany(OrderItem)
290
+ * items: OrderItem[] = [];
291
+ * }
292
+ *
293
+ * @smrt()
294
+ * class OrderItem extends SmrtObject {
295
+ * @foreignKey(Order)
296
+ * orderId: string = '';
297
+ * }
298
+ *
299
+ * const order = await orders.get({ id });
300
+ * const items = await order.getItems(); // generated; === loadRelatedMany('items')
301
+ * ```
302
+ *
303
+ * @example
304
+ * ```typescript
305
+ * // Multiple inverse foreign keys → disambiguate explicitly.
306
+ * @smrt()
307
+ * class Profile extends SmrtObject {
308
+ * @oneToMany(ProfileRelationship, { foreignKey: 'fromProfileId' })
309
+ * relationshipsFrom: ProfileRelationship[] = [];
310
+ * @oneToMany(ProfileRelationship, { foreignKey: 'toProfileId' })
311
+ * relationshipsTo: ProfileRelationship[] = [];
312
+ * }
313
+ * ```
314
+ *
315
+ * @see {@link foreignKey} for the many-to-one (child) side of the relationship
316
+ * @see SmrtObject.loadRelatedMany for lazy-loading at runtime
317
+ */
318
+ export declare function oneToMany(relatedClass: string | Function | any, options?: Omit<RelationshipFieldOptions, 'related'>): CompatiblePropertyDecorator;
319
+ /**
320
+ * Declares a many-to-many relationship between two `SmrtObject` classes via a join table.
321
+ *
322
+ * The decorated property is `transient` — it is not persisted as a database column.
323
+ * The `through` option specifies the junction table name. The join table model must
324
+ * be decorated with `@smrt({ conflictColumns: ['...', '...'] })` to use the natural
325
+ * key columns for upsert operations.
326
+ *
327
+ * Runtime loading: call `instance.loadRelatedMany('field')` to lazy-load, or
328
+ * pass `include: ['field']` to `collection.list()` for batched eager loading.
329
+ *
330
+ * @param relatedClass - The class constructor of the related objects
331
+ * @param options - Relationship options; `through` specifies the junction table name
332
+ * @returns A TypeScript property decorator (sets `transient: true` automatically)
333
+ *
334
+ * @example
335
+ * ```typescript
336
+ * @smrt()
337
+ * class Product extends SmrtObject {
338
+ * @manyToMany(Tag, { through: 'product_tags' })
339
+ * tags: Tag[] = [];
340
+ * }
341
+ * ```
342
+ *
343
+ * @see {@link oneToMany} for one-to-many relationships
344
+ */
345
+ export declare function manyToMany(relatedClass: string | Function | any, options?: Omit<RelationshipFieldOptions, 'related'>): CompatiblePropertyDecorator;
346
+ /**
347
+ * Marks a field as a Single Table Inheritance (STI) meta field.
348
+ *
349
+ * Meta fields are stored in the `_meta_data` JSONB column on the shared STI
350
+ * table rather than as dedicated table columns. Use this decorator for fields
351
+ * that are specific to an STI child class and should not pollute the shared
352
+ * table schema with child-specific columns.
353
+ *
354
+ * The `@smrt({ tableStrategy: 'sti' })` decorator must be set on the base class.
355
+ * All child-specific fields should use `@meta()` (or the `Meta<T>` type alias).
356
+ *
357
+ * @param options - Standard field options (required, nullable, description, etc.)
358
+ * @returns A TypeScript property decorator (registers field with `type: 'meta'`)
359
+ *
360
+ * @example
361
+ * ```typescript
362
+ * @smrt({ tableStrategy: 'sti' })
363
+ * class Event extends SmrtObject {
364
+ * title: string = ''; // shared column on events table
365
+ * }
366
+ *
367
+ * @smrt()
368
+ * class Meeting extends Event {
369
+ * @meta()
370
+ * roomNumber: string = ''; // stored in _meta_data JSON, not a column
371
+ *
372
+ * @meta({ required: true })
373
+ * durationMinutes: number = 60;
374
+ * }
375
+ * ```
376
+ *
377
+ * @see {@link Meta} for the equivalent type alias approach
378
+ * @see {@link field} for regular (non-STI) field declarations
379
+ */
380
+ export declare function meta(options?: FieldOptions): CompatiblePropertyDecorator;
381
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/decorators/index.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,104 @@
1
+ import { ObjectRegistry } from "../registry.js";
2
+ import { registerCompatibleFieldDecorator } from "./compatibility.js";
3
+ function field(options = {}) {
4
+ return ((targetOrValue, propertyKeyOrContext) => {
5
+ registerCompatibleFieldDecorator(
6
+ targetOrValue,
7
+ propertyKeyOrContext,
8
+ (className, propertyKey) => {
9
+ ObjectRegistry.registerFieldDecorator(className, propertyKey, options);
10
+ }
11
+ );
12
+ });
13
+ }
14
+ function foreignKey(relatedClass, options = {}) {
15
+ return ((targetOrValue, propertyKeyOrContext) => {
16
+ const relatedClassName = typeof relatedClass === "string" ? relatedClass : relatedClass.name;
17
+ registerCompatibleFieldDecorator(
18
+ targetOrValue,
19
+ propertyKeyOrContext,
20
+ (className, propertyKey) => {
21
+ ObjectRegistry.registerFieldDecorator(className, propertyKey, {
22
+ ...options,
23
+ type: "foreignKey",
24
+ related: relatedClassName
25
+ });
26
+ }
27
+ );
28
+ });
29
+ }
30
+ function crossPackageRef(qualifiedName, options = {}) {
31
+ return ((targetOrValue, propertyKeyOrContext) => {
32
+ registerCompatibleFieldDecorator(
33
+ targetOrValue,
34
+ propertyKeyOrContext,
35
+ (className, propertyKey) => {
36
+ ObjectRegistry.registerFieldDecorator(className, propertyKey, {
37
+ ...options,
38
+ type: "crossPackageRef",
39
+ related: qualifiedName
40
+ });
41
+ }
42
+ );
43
+ });
44
+ }
45
+ function oneToMany(relatedClass, options = {}) {
46
+ return ((targetOrValue, propertyKeyOrContext) => {
47
+ const relatedClassName = typeof relatedClass === "string" ? relatedClass : relatedClass.name;
48
+ registerCompatibleFieldDecorator(
49
+ targetOrValue,
50
+ propertyKeyOrContext,
51
+ (className, propertyKey) => {
52
+ ObjectRegistry.registerFieldDecorator(className, propertyKey, {
53
+ ...options,
54
+ type: "oneToMany",
55
+ related: relatedClassName,
56
+ transient: true
57
+ // Relationship fields are not database columns
58
+ });
59
+ }
60
+ );
61
+ });
62
+ }
63
+ function manyToMany(relatedClass, options = {}) {
64
+ return ((targetOrValue, propertyKeyOrContext) => {
65
+ const relatedClassName = typeof relatedClass === "string" ? relatedClass : relatedClass.name;
66
+ registerCompatibleFieldDecorator(
67
+ targetOrValue,
68
+ propertyKeyOrContext,
69
+ (className, propertyKey) => {
70
+ ObjectRegistry.registerFieldDecorator(className, propertyKey, {
71
+ ...options,
72
+ type: "manyToMany",
73
+ related: relatedClassName,
74
+ transient: true
75
+ // Relationship fields are not database columns
76
+ });
77
+ }
78
+ );
79
+ });
80
+ }
81
+ function meta(options = {}) {
82
+ return ((targetOrValue, propertyKeyOrContext) => {
83
+ registerCompatibleFieldDecorator(
84
+ targetOrValue,
85
+ propertyKeyOrContext,
86
+ (className, propertyKey) => {
87
+ ObjectRegistry.registerFieldDecorator(className, propertyKey, {
88
+ ...options,
89
+ type: "meta"
90
+ // Mark this field as a meta field for STI
91
+ });
92
+ }
93
+ );
94
+ });
95
+ }
96
+ export {
97
+ crossPackageRef,
98
+ field,
99
+ foreignKey,
100
+ manyToMany,
101
+ meta,
102
+ oneToMany
103
+ };
104
+ //# sourceMappingURL=index.js.map