@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.
- package/AGENTS.md +124 -0
- package/CLAUDE.md +1 -0
- package/LICENSE +7 -0
- package/README.md +265 -0
- package/bin/smrt-prebuild.js +26 -0
- package/dist/__tests__/fixtures/advisor-test-classes.d.ts +28 -0
- package/dist/__tests__/fixtures/advisor-test-classes.d.ts.map +1 -0
- package/dist/__tests__/fixtures/collection-coverage-fixtures.d.ts +12 -0
- package/dist/__tests__/fixtures/collection-coverage-fixtures.d.ts.map +1 -0
- package/dist/__tests__/fixtures/inheritance-resolver-fixtures.d.ts +28 -0
- package/dist/__tests__/fixtures/inheritance-resolver-fixtures.d.ts.map +1 -0
- package/dist/__tests__/fixtures/inheritance-test-classes.d.ts +43 -0
- package/dist/__tests__/fixtures/inheritance-test-classes.d.ts.map +1 -0
- package/dist/__tests__/fixtures/mcp-integration-test-classes.d.ts +18 -0
- package/dist/__tests__/fixtures/mcp-integration-test-classes.d.ts.map +1 -0
- package/dist/__tests__/fixtures/object-ai-memory-fixtures.d.ts +15 -0
- package/dist/__tests__/fixtures/object-ai-memory-fixtures.d.ts.map +1 -0
- package/dist/__tests__/fixtures/object-spec-test-classes.d.ts +13 -0
- package/dist/__tests__/fixtures/object-spec-test-classes.d.ts.map +1 -0
- package/dist/__tests__/fixtures/registry-test-classes.d.ts +23 -0
- package/dist/__tests__/fixtures/registry-test-classes.d.ts.map +1 -0
- package/dist/adapters/ai-usage.d.ts +23 -0
- package/dist/adapters/ai-usage.d.ts.map +1 -0
- package/dist/adapters/ai-usage.js +105 -0
- package/dist/adapters/ai-usage.js.map +1 -0
- package/dist/adapters/cost-rates.d.ts +20 -0
- package/dist/adapters/cost-rates.d.ts.map +1 -0
- package/dist/adapters/cost-rates.js +40 -0
- package/dist/adapters/cost-rates.js.map +1 -0
- package/dist/adapters/index.d.ts +19 -0
- package/dist/adapters/index.d.ts.map +1 -0
- package/dist/adapters/metrics.d.ts +111 -0
- package/dist/adapters/metrics.d.ts.map +1 -0
- package/dist/adapters/metrics.js +169 -0
- package/dist/adapters/metrics.js.map +1 -0
- package/dist/adapters/pubsub.d.ts +124 -0
- package/dist/adapters/pubsub.d.ts.map +1 -0
- package/dist/adapters/pubsub.js +121 -0
- package/dist/adapters/pubsub.js.map +1 -0
- package/dist/browser.d.ts +32 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +68 -0
- package/dist/browser.js.map +1 -0
- package/dist/child-accessors.d.ts +27 -0
- package/dist/child-accessors.d.ts.map +1 -0
- package/dist/child-accessors.js +35 -0
- package/dist/child-accessors.js.map +1 -0
- package/dist/class.d.ts +313 -0
- package/dist/class.d.ts.map +1 -0
- package/dist/class.js +896 -0
- package/dist/class.js.map +1 -0
- package/dist/collection-cache.d.ts +110 -0
- package/dist/collection-cache.d.ts.map +1 -0
- package/dist/collection-cache.js +187 -0
- package/dist/collection-cache.js.map +1 -0
- package/dist/collection.d.ts +894 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/collection.js +1987 -0
- package/dist/collection.js.map +1 -0
- package/dist/config/global-config.d.ts +3 -0
- package/dist/config/global-config.d.ts.map +1 -0
- package/dist/config/global-config.js +19 -0
- package/dist/config/global-config.js.map +1 -0
- package/dist/config.d.ts +145 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +57 -0
- package/dist/config.js.map +1 -0
- package/dist/consumer-plugin/index.d.ts +22 -0
- package/dist/consumer-plugin/index.d.ts.map +1 -0
- package/dist/consumer-plugin/index.js +452 -0
- package/dist/consumer-plugin/index.js.map +1 -0
- package/dist/consumer-plugin.d.ts +8 -0
- package/dist/consumer-plugin.d.ts.map +1 -0
- package/dist/consumer-plugin.js +5 -0
- package/dist/consumer-plugin.js.map +1 -0
- package/dist/database.d.ts +95 -0
- package/dist/database.d.ts.map +1 -0
- package/dist/database.js +32 -0
- package/dist/database.js.map +1 -0
- package/dist/decorators/compatibility.d.ts +14 -0
- package/dist/decorators/compatibility.d.ts.map +1 -0
- package/dist/decorators/compatibility.js +111 -0
- package/dist/decorators/compatibility.js.map +1 -0
- package/dist/decorators/index.d.ts +381 -0
- package/dist/decorators/index.d.ts.map +1 -0
- package/dist/decorators/index.js +104 -0
- package/dist/decorators/index.js.map +1 -0
- package/dist/dispatch/bus.d.ts +306 -0
- package/dist/dispatch/bus.d.ts.map +1 -0
- package/dist/dispatch/bus.js +583 -0
- package/dist/dispatch/bus.js.map +1 -0
- package/dist/dispatch/collections/DispatchSubscriptions.d.ts +79 -0
- package/dist/dispatch/collections/DispatchSubscriptions.d.ts.map +1 -0
- package/dist/dispatch/collections/DispatchSubscriptions.js +243 -0
- package/dist/dispatch/collections/DispatchSubscriptions.js.map +1 -0
- package/dist/dispatch/collections/Dispatches.d.ts +98 -0
- package/dist/dispatch/collections/Dispatches.d.ts.map +1 -0
- package/dist/dispatch/collections/Dispatches.js +358 -0
- package/dist/dispatch/collections/Dispatches.js.map +1 -0
- package/dist/dispatch/index.d.ts +47 -0
- package/dist/dispatch/index.d.ts.map +1 -0
- package/dist/dispatch/models/Dispatch.d.ts +101 -0
- package/dist/dispatch/models/Dispatch.d.ts.map +1 -0
- package/dist/dispatch/models/Dispatch.js +162 -0
- package/dist/dispatch/models/Dispatch.js.map +1 -0
- package/dist/dispatch/models/DispatchSubscription.d.ts +83 -0
- package/dist/dispatch/models/DispatchSubscription.d.ts.map +1 -0
- package/dist/dispatch/models/DispatchSubscription.js +112 -0
- package/dist/dispatch/models/DispatchSubscription.js.map +1 -0
- package/dist/dispatch/tenant-resolver.d.ts +98 -0
- package/dist/dispatch/tenant-resolver.d.ts.map +1 -0
- package/dist/dispatch/tenant-resolver.js +32 -0
- package/dist/dispatch/tenant-resolver.js.map +1 -0
- package/dist/dispatch/types.d.ts +149 -0
- package/dist/dispatch/types.d.ts.map +1 -0
- package/dist/embeddings/hash.d.ts +33 -0
- package/dist/embeddings/hash.d.ts.map +1 -0
- package/dist/embeddings/hash.js +37 -0
- package/dist/embeddings/hash.js.map +1 -0
- package/dist/embeddings/index.d.ts +36 -0
- package/dist/embeddings/index.d.ts.map +1 -0
- package/dist/embeddings/provider.d.ts +75 -0
- package/dist/embeddings/provider.d.ts.map +1 -0
- package/dist/embeddings/provider.js +170 -0
- package/dist/embeddings/provider.js.map +1 -0
- package/dist/embeddings/similarity.d.ts +47 -0
- package/dist/embeddings/similarity.d.ts.map +1 -0
- package/dist/embeddings/similarity.js +64 -0
- package/dist/embeddings/similarity.js.map +1 -0
- package/dist/embeddings/storage.d.ts +125 -0
- package/dist/embeddings/storage.d.ts.map +1 -0
- package/dist/embeddings/storage.js +283 -0
- package/dist/embeddings/storage.js.map +1 -0
- package/dist/embeddings/types.d.ts +250 -0
- package/dist/embeddings/types.d.ts.map +1 -0
- package/dist/errors.d.ts +363 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +669 -0
- package/dist/errors.js.map +1 -0
- package/dist/generators/cli.d.ts +162 -0
- package/dist/generators/cli.d.ts.map +1 -0
- package/dist/generators/cli.js +462 -0
- package/dist/generators/cli.js.map +1 -0
- package/dist/generators/index.d.ts +13 -0
- package/dist/generators/index.d.ts.map +1 -0
- package/dist/generators/mcp-runtime-template.d.ts +60 -0
- package/dist/generators/mcp-runtime-template.d.ts.map +1 -0
- package/dist/generators/mcp-runtime-template.js +509 -0
- package/dist/generators/mcp-runtime-template.js.map +1 -0
- package/dist/generators/mcp.d.ts +231 -0
- package/dist/generators/mcp.d.ts.map +1 -0
- package/dist/generators/mcp.js +1220 -0
- package/dist/generators/mcp.js.map +1 -0
- package/dist/generators/rest.d.ts +171 -0
- package/dist/generators/rest.d.ts.map +1 -0
- package/dist/generators/rest.js +591 -0
- package/dist/generators/rest.js.map +1 -0
- package/dist/generators/swagger.d.ts +21 -0
- package/dist/generators/swagger.d.ts.map +1 -0
- package/dist/generators/swagger.js +307 -0
- package/dist/generators/swagger.js.map +1 -0
- package/dist/generators/tenant-gate.d.ts +74 -0
- package/dist/generators/tenant-gate.d.ts.map +1 -0
- package/dist/generators/tenant-gate.js +15 -0
- package/dist/generators/tenant-gate.js.map +1 -0
- package/dist/generators.d.ts +8 -0
- package/dist/generators.d.ts.map +1 -0
- package/dist/generators.js +19 -0
- package/dist/generators.js.map +1 -0
- package/dist/hierarchical.d.ts +103 -0
- package/dist/hierarchical.d.ts.map +1 -0
- package/dist/hierarchical.js +184 -0
- package/dist/hierarchical.js.map +1 -0
- package/dist/index.d.ts +57 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +202 -0
- package/dist/index.js.map +1 -0
- package/dist/interceptors.d.ts +251 -0
- package/dist/interceptors.d.ts.map +1 -0
- package/dist/interceptors.js +259 -0
- package/dist/interceptors.js.map +1 -0
- package/dist/junction.d.ts +99 -0
- package/dist/junction.d.ts.map +1 -0
- package/dist/junction.js +136 -0
- package/dist/junction.js.map +1 -0
- package/dist/knowledge.d.ts +11 -0
- package/dist/knowledge.d.ts.map +1 -0
- package/dist/knowledge.js +310 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/lazy-config.d.ts +160 -0
- package/dist/lazy-config.d.ts.map +1 -0
- package/dist/lazy-config.js +146 -0
- package/dist/lazy-config.js.map +1 -0
- package/dist/manifest/discover-base-classes.d.ts +78 -0
- package/dist/manifest/discover-base-classes.d.ts.map +1 -0
- package/dist/manifest/discover-base-classes.js +85 -0
- package/dist/manifest/discover-base-classes.js.map +1 -0
- package/dist/manifest/discover-smrt-packages.d.ts +48 -0
- package/dist/manifest/discover-smrt-packages.d.ts.map +1 -0
- package/dist/manifest/discover-smrt-packages.js +361 -0
- package/dist/manifest/discover-smrt-packages.js.map +1 -0
- package/dist/manifest/generator.d.ts +93 -0
- package/dist/manifest/generator.d.ts.map +1 -0
- package/dist/manifest/generator.js +380 -0
- package/dist/manifest/generator.js.map +1 -0
- package/dist/manifest/index.d.ts +16 -0
- package/dist/manifest/index.d.ts.map +1 -0
- package/dist/manifest/index.js +51 -0
- package/dist/manifest/index.js.map +1 -0
- package/dist/manifest/manager.d.ts +51 -0
- package/dist/manifest/manager.d.ts.map +1 -0
- package/dist/manifest/manager.js +89 -0
- package/dist/manifest/manager.js.map +1 -0
- package/dist/manifest/manifest-loader.d.ts +187 -0
- package/dist/manifest/manifest-loader.d.ts.map +1 -0
- package/dist/manifest/manifest-loader.js +847 -0
- package/dist/manifest/manifest-loader.js.map +1 -0
- package/dist/manifest/sources/composite.d.ts +22 -0
- package/dist/manifest/sources/composite.d.ts.map +1 -0
- package/dist/manifest/sources/composite.js +60 -0
- package/dist/manifest/sources/composite.js.map +1 -0
- package/dist/manifest/sources/embedded.d.ts +7 -0
- package/dist/manifest/sources/embedded.d.ts.map +1 -0
- package/dist/manifest/sources/embedded.js +30 -0
- package/dist/manifest/sources/embedded.js.map +1 -0
- package/dist/manifest/sources/explicit-paths.d.ts +17 -0
- package/dist/manifest/sources/explicit-paths.d.ts.map +1 -0
- package/dist/manifest/sources/explicit-paths.js +35 -0
- package/dist/manifest/sources/explicit-paths.js.map +1 -0
- package/dist/manifest/sources/fallback.d.ts +25 -0
- package/dist/manifest/sources/fallback.d.ts.map +1 -0
- package/dist/manifest/sources/fallback.js +63 -0
- package/dist/manifest/sources/fallback.js.map +1 -0
- package/dist/manifest/sources/index.d.ts +17 -0
- package/dist/manifest/sources/index.d.ts.map +1 -0
- package/dist/manifest/sources/local-test.d.ts +7 -0
- package/dist/manifest/sources/local-test.d.ts.map +1 -0
- package/dist/manifest/sources/local-test.js +21 -0
- package/dist/manifest/sources/local-test.js.map +1 -0
- package/dist/manifest/sources/static.d.ts +7 -0
- package/dist/manifest/sources/static.d.ts.map +1 -0
- package/dist/manifest/sources/static.js +19 -0
- package/dist/manifest/sources/static.js.map +1 -0
- package/dist/manifest/sources/test.d.ts +7 -0
- package/dist/manifest/sources/test.d.ts.map +1 -0
- package/dist/manifest/sources/test.js +21 -0
- package/dist/manifest/sources/test.js.map +1 -0
- package/dist/manifest/sources/types.d.ts +79 -0
- package/dist/manifest/sources/types.d.ts.map +1 -0
- package/dist/manifest/sources/types.js +61 -0
- package/dist/manifest/sources/types.js.map +1 -0
- package/dist/manifest/static-manifest.d.ts +4 -0
- package/dist/manifest/static-manifest.d.ts.map +1 -0
- package/dist/manifest/static-manifest.js +1535 -0
- package/dist/manifest/static-manifest.js.map +1 -0
- package/dist/manifest/store.d.ts +111 -0
- package/dist/manifest/store.d.ts.map +1 -0
- package/dist/manifest/store.js +431 -0
- package/dist/manifest/store.js.map +1 -0
- package/dist/manifest/test-manifest-loader.d.ts +3 -0
- package/dist/manifest/test-manifest-loader.d.ts.map +1 -0
- package/dist/manifest/test-manifest-stub.d.ts +4 -0
- package/dist/manifest/test-manifest-stub.d.ts.map +1 -0
- package/dist/manifest/test-manifest-stub.js +80013 -0
- package/dist/manifest/test-manifest-stub.js.map +1 -0
- package/dist/manifest.d.ts +8 -0
- package/dist/manifest.d.ts.map +1 -0
- package/dist/manifest.js +20 -0
- package/dist/manifest.js.map +1 -0
- package/dist/manifest.json +1489 -0
- package/dist/mcp-advisor/index.d.ts +499 -0
- package/dist/mcp-advisor/index.d.ts.map +1 -0
- package/dist/mcp-advisor/tools/add-ai-methods.d.ts +6 -0
- package/dist/mcp-advisor/tools/add-ai-methods.d.ts.map +1 -0
- package/dist/mcp-advisor/tools/configure-decorators.d.ts +6 -0
- package/dist/mcp-advisor/tools/configure-decorators.d.ts.map +1 -0
- package/dist/mcp-advisor/tools/generate-collection.d.ts +6 -0
- package/dist/mcp-advisor/tools/generate-collection.d.ts.map +1 -0
- package/dist/mcp-advisor/tools/generate-field-definitions.d.ts +6 -0
- package/dist/mcp-advisor/tools/generate-field-definitions.d.ts.map +1 -0
- package/dist/mcp-advisor/tools/generate-smrt-class.d.ts +6 -0
- package/dist/mcp-advisor/tools/generate-smrt-class.d.ts.map +1 -0
- package/dist/mcp-advisor/tools/get-object-config.d.ts +6 -0
- package/dist/mcp-advisor/tools/get-object-config.d.ts.map +1 -0
- package/dist/mcp-advisor/tools/get-object-schema.d.ts +10 -0
- package/dist/mcp-advisor/tools/get-object-schema.d.ts.map +1 -0
- package/dist/mcp-advisor/tools/list-registered-objects.d.ts +9 -0
- package/dist/mcp-advisor/tools/list-registered-objects.d.ts.map +1 -0
- package/dist/mcp-advisor/tools/preview-api-endpoints.d.ts +9 -0
- package/dist/mcp-advisor/tools/preview-api-endpoints.d.ts.map +1 -0
- package/dist/mcp-advisor/tools/preview-mcp-tools.d.ts +9 -0
- package/dist/mcp-advisor/tools/preview-mcp-tools.d.ts.map +1 -0
- package/dist/mcp-advisor/tools/validate-smrt-object.d.ts +6 -0
- package/dist/mcp-advisor/tools/validate-smrt-object.d.ts.map +1 -0
- package/dist/mcp-advisor/types.d.ts +209 -0
- package/dist/mcp-advisor/types.d.ts.map +1 -0
- package/dist/migrations/backfill-tracker.d.ts +84 -0
- package/dist/migrations/backfill-tracker.d.ts.map +1 -0
- package/dist/migrations/backfill-tracker.js +118 -0
- package/dist/migrations/backfill-tracker.js.map +1 -0
- package/dist/migrations/checksum.d.ts +43 -0
- package/dist/migrations/checksum.d.ts.map +1 -0
- package/dist/migrations/checksum.js +32 -0
- package/dist/migrations/checksum.js.map +1 -0
- package/dist/migrations/differ.d.ts +186 -0
- package/dist/migrations/differ.d.ts.map +1 -0
- package/dist/migrations/differ.js +601 -0
- package/dist/migrations/differ.js.map +1 -0
- package/dist/migrations/generator.d.ts +133 -0
- package/dist/migrations/generator.d.ts.map +1 -0
- package/dist/migrations/generator.js +328 -0
- package/dist/migrations/generator.js.map +1 -0
- package/dist/migrations/index.d.ts +20 -0
- package/dist/migrations/index.d.ts.map +1 -0
- package/dist/migrations/orchestrate.d.ts +148 -0
- package/dist/migrations/orchestrate.d.ts.map +1 -0
- package/dist/migrations/orchestrate.js +118 -0
- package/dist/migrations/orchestrate.js.map +1 -0
- package/dist/migrations/tracker.d.ts +134 -0
- package/dist/migrations/tracker.d.ts.map +1 -0
- package/dist/migrations/tracker.js +624 -0
- package/dist/migrations/tracker.js.map +1 -0
- package/dist/migrations/types.d.ts +221 -0
- package/dist/migrations/types.d.ts.map +1 -0
- package/dist/migrations.d.ts +7 -0
- package/dist/migrations.d.ts.map +1 -0
- package/dist/migrations.js +26 -0
- package/dist/migrations.js.map +1 -0
- package/dist/node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js +56 -0
- package/dist/node_modules/.pnpm/balanced-match@4.0.4/node_modules/balanced-match/dist/esm/index.js.map +1 -0
- package/dist/node_modules/.pnpm/brace-expansion@5.0.5/node_modules/brace-expansion/dist/esm/index.js +163 -0
- package/dist/node_modules/.pnpm/brace-expansion@5.0.5/node_modules/brace-expansion/dist/esm/index.js.map +1 -0
- package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/assert-valid-pattern.js +13 -0
- package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -0
- package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/ast.js +654 -0
- package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/ast.js.map +1 -0
- package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/brace-expressions.js +111 -0
- package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -0
- package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/escape.js +10 -0
- package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/escape.js.map +1 -0
- package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/index.js +824 -0
- package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/index.js.map +1 -0
- package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/unescape.js +10 -0
- package/dist/node_modules/.pnpm/minimatch@10.2.3/node_modules/minimatch/dist/esm/unescape.js.map +1 -0
- package/dist/object.d.ts +1202 -0
- package/dist/object.d.ts.map +1 -0
- package/dist/object.js +2731 -0
- package/dist/object.js.map +1 -0
- package/dist/polymorphic-association.d.ts +69 -0
- package/dist/polymorphic-association.d.ts.map +1 -0
- package/dist/polymorphic-association.js +96 -0
- package/dist/polymorphic-association.js.map +1 -0
- package/dist/prebuild/cli.d.ts +7 -0
- package/dist/prebuild/cli.d.ts.map +1 -0
- package/dist/prebuild/cli.js +29 -0
- package/dist/prebuild/cli.js.map +1 -0
- package/dist/prebuild/index.d.ts +22 -0
- package/dist/prebuild/index.d.ts.map +1 -0
- package/dist/prebuild/index.js +239 -0
- package/dist/prebuild/index.js.map +1 -0
- package/dist/prebuild.d.ts +8 -0
- package/dist/prebuild.d.ts.map +1 -0
- package/dist/prebuild.js +6 -0
- package/dist/prebuild.js.map +1 -0
- package/dist/registry/cache-config.d.ts +13 -0
- package/dist/registry/cache-config.d.ts.map +1 -0
- package/dist/registry/cache-config.js +17 -0
- package/dist/registry/cache-config.js.map +1 -0
- package/dist/registry/class-registration.d.ts +31 -0
- package/dist/registry/class-registration.d.ts.map +1 -0
- package/dist/registry/class-registration.js +1074 -0
- package/dist/registry/class-registration.js.map +1 -0
- package/dist/registry/collection-resolution.d.ts +45 -0
- package/dist/registry/collection-resolution.d.ts.map +1 -0
- package/dist/registry/collection-resolution.js +121 -0
- package/dist/registry/collection-resolution.js.map +1 -0
- package/dist/registry/collision-policy.d.ts +179 -0
- package/dist/registry/collision-policy.d.ts.map +1 -0
- package/dist/registry/collision-policy.js +153 -0
- package/dist/registry/collision-policy.js.map +1 -0
- package/dist/registry/diagnostics.d.ts +58 -0
- package/dist/registry/diagnostics.d.ts.map +1 -0
- package/dist/registry/diagnostics.js +54 -0
- package/dist/registry/diagnostics.js.map +1 -0
- package/dist/registry/embedding-manager.d.ts +23 -0
- package/dist/registry/embedding-manager.d.ts.map +1 -0
- package/dist/registry/embedding-manager.js +62 -0
- package/dist/registry/embedding-manager.js.map +1 -0
- package/dist/registry/index.d.ts +13 -0
- package/dist/registry/index.d.ts.map +1 -0
- package/dist/registry/inheritance-resolver.d.ts +13 -0
- package/dist/registry/inheritance-resolver.d.ts.map +1 -0
- package/dist/registry/inheritance-resolver.js +244 -0
- package/dist/registry/inheritance-resolver.js.map +1 -0
- package/dist/registry/manifest-field-merge.d.ts +4 -0
- package/dist/registry/manifest-field-merge.d.ts.map +1 -0
- package/dist/registry/manifest-field-merge.js +82 -0
- package/dist/registry/manifest-field-merge.js.map +1 -0
- package/dist/registry/name-resolver.d.ts +102 -0
- package/dist/registry/name-resolver.d.ts.map +1 -0
- package/dist/registry/name-resolver.js +241 -0
- package/dist/registry/name-resolver.js.map +1 -0
- package/dist/registry/relationship-graph.d.ts +16 -0
- package/dist/registry/relationship-graph.d.ts.map +1 -0
- package/dist/registry/relationship-graph.js +79 -0
- package/dist/registry/relationship-graph.js.map +1 -0
- package/dist/registry/schema-builder.d.ts +113 -0
- package/dist/registry/schema-builder.d.ts.map +1 -0
- package/dist/registry/schema-builder.js +474 -0
- package/dist/registry/schema-builder.js.map +1 -0
- package/dist/registry/shared-state.d.ts +62 -0
- package/dist/registry/shared-state.d.ts.map +1 -0
- package/dist/registry/shared-state.js +135 -0
- package/dist/registry/shared-state.js.map +1 -0
- package/dist/registry/types.d.ts +667 -0
- package/dist/registry/types.d.ts.map +1 -0
- package/dist/registry/validator.d.ts +13 -0
- package/dist/registry/validator.d.ts.map +1 -0
- package/dist/registry/validator.js +138 -0
- package/dist/registry/validator.js.map +1 -0
- package/dist/registry.d.ts +1358 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +2301 -0
- package/dist/registry.js.map +1 -0
- package/dist/runtime/client.d.ts +34 -0
- package/dist/runtime/client.d.ts.map +1 -0
- package/dist/runtime/client.js +104 -0
- package/dist/runtime/client.js.map +1 -0
- package/dist/runtime/index.d.ts +10 -0
- package/dist/runtime/index.d.ts.map +1 -0
- package/dist/runtime/mcp.d.ts +47 -0
- package/dist/runtime/mcp.d.ts.map +1 -0
- package/dist/runtime/mcp.js +72 -0
- package/dist/runtime/mcp.js.map +1 -0
- package/dist/runtime/server.d.ts +92 -0
- package/dist/runtime/server.d.ts.map +1 -0
- package/dist/runtime/server.js +390 -0
- package/dist/runtime/server.js.map +1 -0
- package/dist/runtime/types.d.ts +58 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime.d.ts +8 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +10 -0
- package/dist/runtime.js.map +1 -0
- package/dist/scanner/import-scanner.d.ts +7 -0
- package/dist/scanner/import-scanner.d.ts.map +1 -0
- package/dist/scanner/index.d.ts +12 -0
- package/dist/scanner/index.d.ts.map +1 -0
- package/dist/scanner/manifest-generator.d.ts +304 -0
- package/dist/scanner/manifest-generator.d.ts.map +1 -0
- package/dist/scanner/manifest-generator.js +1707 -0
- package/dist/scanner/manifest-generator.js.map +1 -0
- package/dist/scanner/test-file-patterns.d.ts +18 -0
- package/dist/scanner/test-file-patterns.d.ts.map +1 -0
- package/dist/scanner/test-file-patterns.js +16 -0
- package/dist/scanner/test-file-patterns.js.map +1 -0
- package/dist/scanner/types.d.ts +313 -0
- package/dist/scanner/types.d.ts.map +1 -0
- package/dist/scanner/types.js +2 -0
- package/dist/scanner/types.js.map +1 -0
- package/dist/scanner.d.ts +6 -0
- package/dist/scanner.d.ts.map +1 -0
- package/dist/scanner.js +6 -0
- package/dist/scanner.js.map +1 -0
- package/dist/schema/code-generator.d.ts +53 -0
- package/dist/schema/code-generator.d.ts.map +1 -0
- package/dist/schema/ddl/base-strategy.d.ts +80 -0
- package/dist/schema/ddl/base-strategy.d.ts.map +1 -0
- package/dist/schema/ddl/base-strategy.js +240 -0
- package/dist/schema/ddl/base-strategy.js.map +1 -0
- package/dist/schema/ddl/duckdb-strategy.d.ts +33 -0
- package/dist/schema/ddl/duckdb-strategy.d.ts.map +1 -0
- package/dist/schema/ddl/duckdb-strategy.js +74 -0
- package/dist/schema/ddl/duckdb-strategy.js.map +1 -0
- package/dist/schema/ddl/index.d.ts +53 -0
- package/dist/schema/ddl/index.d.ts.map +1 -0
- package/dist/schema/ddl/index.js +80 -0
- package/dist/schema/ddl/index.js.map +1 -0
- package/dist/schema/ddl/json-duckdb-strategy.d.ts +8 -0
- package/dist/schema/ddl/json-duckdb-strategy.d.ts.map +1 -0
- package/dist/schema/ddl/json-duckdb-strategy.js +14 -0
- package/dist/schema/ddl/json-duckdb-strategy.js.map +1 -0
- package/dist/schema/ddl/postgres-strategy.d.ts +29 -0
- package/dist/schema/ddl/postgres-strategy.d.ts.map +1 -0
- package/dist/schema/ddl/postgres-strategy.js +102 -0
- package/dist/schema/ddl/postgres-strategy.js.map +1 -0
- package/dist/schema/ddl/sqlite-strategy.d.ts +38 -0
- package/dist/schema/ddl/sqlite-strategy.d.ts.map +1 -0
- package/dist/schema/ddl/sqlite-strategy.js +74 -0
- package/dist/schema/ddl/sqlite-strategy.js.map +1 -0
- package/dist/schema/ddl/types.d.ts +114 -0
- package/dist/schema/ddl/types.d.ts.map +1 -0
- package/dist/schema/generator.d.ts +176 -0
- package/dist/schema/generator.d.ts.map +1 -0
- package/dist/schema/generator.js +1076 -0
- package/dist/schema/generator.js.map +1 -0
- package/dist/schema/index-utils.d.ts +19 -0
- package/dist/schema/index-utils.d.ts.map +1 -0
- package/dist/schema/index-utils.js +32 -0
- package/dist/schema/index-utils.js.map +1 -0
- package/dist/schema/index.d.ts +13 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema/override-system.d.ts +43 -0
- package/dist/schema/override-system.d.ts.map +1 -0
- package/dist/schema/schema-aggregator.d.ts +112 -0
- package/dist/schema/schema-aggregator.d.ts.map +1 -0
- package/dist/schema/schema-manager.d.ts +95 -0
- package/dist/schema/schema-manager.d.ts.map +1 -0
- package/dist/schema/schema-manager.js +283 -0
- package/dist/schema/schema-manager.js.map +1 -0
- package/dist/schema/sql-identifiers.d.ts +107 -0
- package/dist/schema/sql-identifiers.d.ts.map +1 -0
- package/dist/schema/sql-identifiers.js +190 -0
- package/dist/schema/sql-identifiers.js.map +1 -0
- package/dist/schema/table-verifier.d.ts +10 -0
- package/dist/schema/table-verifier.d.ts.map +1 -0
- package/dist/schema/table-verifier.js +37 -0
- package/dist/schema/table-verifier.js.map +1 -0
- package/dist/schema/types.d.ts +241 -0
- package/dist/schema/types.d.ts.map +1 -0
- package/dist/schema/utils.d.ts +32 -0
- package/dist/schema/utils.d.ts.map +1 -0
- package/dist/schema/utils.js +134 -0
- package/dist/schema/utils.js.map +1 -0
- package/dist/scripts/create-wrappers.js +89 -0
- package/dist/scripts/generate-manifest.js +155 -0
- package/dist/scripts/generate-test-manifest.js +77 -0
- package/dist/scripts/migrate-datetime-to-timestamp.ts +310 -0
- package/dist/scripts/prepack.js +49 -0
- package/dist/signals/bus.d.ts +64 -0
- package/dist/signals/bus.d.ts.map +1 -0
- package/dist/signals/bus.js +102 -0
- package/dist/signals/bus.js.map +1 -0
- package/dist/signals/index.d.ts +11 -0
- package/dist/signals/index.d.ts.map +1 -0
- package/dist/signals/sanitizer.d.ts +54 -0
- package/dist/signals/sanitizer.d.ts.map +1 -0
- package/dist/signals/sanitizer.js +111 -0
- package/dist/signals/sanitizer.js.map +1 -0
- package/dist/smrt-knowledge.json +335 -0
- package/dist/system/compatibility.d.ts +8 -0
- package/dist/system/compatibility.d.ts.map +1 -0
- package/dist/system/compatibility.js +409 -0
- package/dist/system/compatibility.js.map +1 -0
- package/dist/system/index.d.ts +9 -0
- package/dist/system/index.d.ts.map +1 -0
- package/dist/system/schema.d.ts +69 -0
- package/dist/system/schema.d.ts.map +1 -0
- package/dist/system/schema.js +271 -0
- package/dist/system/schema.js.map +1 -0
- package/dist/system/types.d.ts +135 -0
- package/dist/system/types.d.ts.map +1 -0
- package/dist/system-fields.d.ts +44 -0
- package/dist/system-fields.d.ts.map +1 -0
- package/dist/system-fields.js +55 -0
- package/dist/system-fields.js.map +1 -0
- package/dist/table-cache.d.ts +28 -0
- package/dist/table-cache.d.ts.map +1 -0
- package/dist/table-cache.js +21 -0
- package/dist/table-cache.js.map +1 -0
- package/dist/test-utils.d.ts +140 -0
- package/dist/test-utils.d.ts.map +1 -0
- package/dist/testing/database.d.ts +73 -0
- package/dist/testing/database.d.ts.map +1 -0
- package/dist/testing/database.js +204 -0
- package/dist/testing/database.js.map +1 -0
- package/dist/testing/index.d.ts +21 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing.d.ts +6 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +5 -0
- package/dist/testing.js.map +1 -0
- package/dist/tools/index.d.ts +8 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/tool-executor.d.ts +101 -0
- package/dist/tools/tool-executor.d.ts.map +1 -0
- package/dist/tools/tool-executor.js +142 -0
- package/dist/tools/tool-executor.js.map +1 -0
- package/dist/tools/tool-generator.d.ts +54 -0
- package/dist/tools/tool-generator.d.ts.map +1 -0
- package/dist/tools/tool-generator.js +121 -0
- package/dist/tools/tool-generator.js.map +1 -0
- package/dist/utils/chunk.d.ts +32 -0
- package/dist/utils/chunk.d.ts.map +1 -0
- package/dist/utils/chunk.js +14 -0
- package/dist/utils/chunk.js.map +1 -0
- package/dist/utils/import-workspace-module.d.ts +8 -0
- package/dist/utils/import-workspace-module.d.ts.map +1 -0
- package/dist/utils/import-workspace-module.js +81 -0
- package/dist/utils/import-workspace-module.js.map +1 -0
- package/dist/utils/json.d.ts +102 -0
- package/dist/utils/json.d.ts.map +1 -0
- package/dist/utils/json.js +43 -0
- package/dist/utils/json.js.map +1 -0
- package/dist/utils/lru-cache.d.ts +69 -0
- package/dist/utils/lru-cache.d.ts.map +1 -0
- package/dist/utils/lru-cache.js +100 -0
- package/dist/utils/lru-cache.js.map +1 -0
- package/dist/utils/naming.d.ts +16 -0
- package/dist/utils/naming.d.ts.map +1 -0
- package/dist/utils/naming.js +23 -0
- package/dist/utils/naming.js.map +1 -0
- package/dist/utils/qualified-names.d.ts +122 -0
- package/dist/utils/qualified-names.d.ts.map +1 -0
- package/dist/utils/qualified-names.js +82 -0
- package/dist/utils/qualified-names.js.map +1 -0
- package/dist/utils/scanner-module.d.ts +37 -0
- package/dist/utils/scanner-module.d.ts.map +1 -0
- package/dist/utils.d.ts +177 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +185 -0
- package/dist/utils.js.map +1 -0
- package/dist/vite-plugin/import-build-aware.d.ts +68 -0
- package/dist/vite-plugin/import-build-aware.d.ts.map +1 -0
- package/dist/vite-plugin/import-build-aware.js +72 -0
- package/dist/vite-plugin/import-build-aware.js.map +1 -0
- package/dist/vite-plugin/index.d.ts +59 -0
- package/dist/vite-plugin/index.d.ts.map +1 -0
- package/dist/vite-plugin/index.js +1400 -0
- package/dist/vite-plugin/index.js.map +1 -0
- package/dist/vite-plugin/sveltekit-generator.d.ts +66 -0
- package/dist/vite-plugin/sveltekit-generator.d.ts.map +1 -0
- package/dist/vite-plugin/sveltekit-generator.js +1375 -0
- package/dist/vite-plugin/sveltekit-generator.js.map +1 -0
- package/dist/vite-plugin/templates/default-ui.ts +432 -0
- package/dist/vite-plugin/templates/default.html +206 -0
- package/dist/vite-plugin.d.ts +8 -0
- package/dist/vite-plugin.d.ts.map +1 -0
- package/dist/vite-plugin.js +11 -0
- package/dist/vite-plugin.js.map +1 -0
- package/package.json +208 -0
|
@@ -0,0 +1,1358 @@
|
|
|
1
|
+
import { SmrtCollection } from './collection';
|
|
2
|
+
import { CollectionCacheConfig } from './collection-cache';
|
|
3
|
+
import { ClassEmbeddingConfig, ProjectEmbeddingConfig, ResolvedEmbeddingConfig } from './embeddings/types';
|
|
4
|
+
import { SmrtObject } from './object';
|
|
5
|
+
import { RegistryDiagnostic } from './registry/diagnostics';
|
|
6
|
+
import { RegisteredClass, RelationshipMetadata, SmartObjectConfig, SmrtObjectConstructor, ValidatorFunction } from './registry/types';
|
|
7
|
+
import { QualifiedClassName, SmrtVisibility, ValidationRule } from './scanner/types.js';
|
|
8
|
+
import { SchemaDefinition } from './schema/types.js';
|
|
9
|
+
export { isSmrtCollectionExtendsName, SMRT_COLLECTION_BASE_NAMES, } from './registry/collection-resolution';
|
|
10
|
+
export type { RelationshipMetadata, RelationshipType, SmartObjectConfig, } from './registry/types';
|
|
11
|
+
/**
|
|
12
|
+
* Central registry for all SMRT objects
|
|
13
|
+
*
|
|
14
|
+
* Uses globalThis for cross-module state sharing, ensuring all module instances
|
|
15
|
+
* (even from different package resolution paths) share the same registry state.
|
|
16
|
+
*/
|
|
17
|
+
export declare class ObjectRegistry {
|
|
18
|
+
/**
|
|
19
|
+
* Get the classes map from globalThis, initializing if needed
|
|
20
|
+
*/
|
|
21
|
+
private static get classes();
|
|
22
|
+
/**
|
|
23
|
+
* Get the collections map from globalThis, initializing if needed
|
|
24
|
+
*/
|
|
25
|
+
private static get collections();
|
|
26
|
+
/**
|
|
27
|
+
* Get the collection table names map from globalThis, initializing if needed
|
|
28
|
+
* Maps collection class name -> tableName for getTableName lookups
|
|
29
|
+
*/
|
|
30
|
+
private static get collectionTableNames();
|
|
31
|
+
/**
|
|
32
|
+
* Set the table name for a collection class
|
|
33
|
+
* Used by @smrt() decorator to enable getTableName lookups for collections
|
|
34
|
+
*/
|
|
35
|
+
static setCollectionTableName(collectionName: string, tableName: string): void;
|
|
36
|
+
/**
|
|
37
|
+
* Get the collection cache from globalThis, initializing if needed
|
|
38
|
+
*/
|
|
39
|
+
private static get collectionCache();
|
|
40
|
+
/**
|
|
41
|
+
* Configure the collection cache size (for testing purposes)
|
|
42
|
+
*
|
|
43
|
+
* Resets the collection cache with a new maximum size.
|
|
44
|
+
* Use this in tests to avoid creating many database files.
|
|
45
|
+
*
|
|
46
|
+
* @param maxSize - Maximum number of collections to cache (system default is 100)
|
|
47
|
+
* @throws Error if maxSize is not a positive finite number
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* // In test setup, use a small cache to test LRU eviction with fewer DBs
|
|
51
|
+
* ObjectRegistry.configureCollectionCache(5);
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
static configureCollectionCache(maxSize: number): void;
|
|
55
|
+
/**
|
|
56
|
+
* WeakMap to assign unique IDs to database instances for cache keys
|
|
57
|
+
* Prevents cache key collisions when different db instances are used
|
|
58
|
+
*/
|
|
59
|
+
private static get dbInstanceIds();
|
|
60
|
+
/**
|
|
61
|
+
* Get/set the next database ID counter
|
|
62
|
+
*/
|
|
63
|
+
private static get nextDbId();
|
|
64
|
+
private static set nextDbId(value);
|
|
65
|
+
/**
|
|
66
|
+
* Storage for field decorator metadata (decorator pattern)
|
|
67
|
+
* Maps className → Map<propertyKey, FieldOptions>
|
|
68
|
+
* Used by @field(), @foreignKey(), @oneToMany(), @manyToMany() decorators
|
|
69
|
+
*/
|
|
70
|
+
private static get fieldDecorators();
|
|
71
|
+
/**
|
|
72
|
+
* Track collections that have been processed for STI siblings
|
|
73
|
+
* Prevents infinite recursion when loading siblings
|
|
74
|
+
*/
|
|
75
|
+
private static get stiSiblingsLoaded();
|
|
76
|
+
/**
|
|
77
|
+
* Check if a class is already registered (case-insensitive)
|
|
78
|
+
* Returns the canonical name if found, undefined otherwise.
|
|
79
|
+
*
|
|
80
|
+
* Release B (#1133): iteration over `classes` replaces the old eagerly-
|
|
81
|
+
* maintained classNameMap index. Negligible cost at production scale and
|
|
82
|
+
* removes an entire class of cache-sync bugs.
|
|
83
|
+
*/
|
|
84
|
+
static getCanonicalClassName(name: string): string | undefined;
|
|
85
|
+
/**
|
|
86
|
+
* Check if a class exists by name (case-insensitive)
|
|
87
|
+
*/
|
|
88
|
+
static hasClassCaseInsensitive(name: string): boolean;
|
|
89
|
+
/**
|
|
90
|
+
* Global cache for inheritance chains (shared across all instances)
|
|
91
|
+
* Maps className → full inheritance chain (base to child)
|
|
92
|
+
* Performance optimization: ~100x faster than re-walking prototype chain
|
|
93
|
+
* Cache size is configurable via smrt.inheritance.cacheSize (default: 200)
|
|
94
|
+
*/
|
|
95
|
+
private static getInheritanceCache;
|
|
96
|
+
/**
|
|
97
|
+
* Global cache for manifest discovery attempts (Issue #735 optimization)
|
|
98
|
+
* Maps className → boolean (true = found and registered, false = not found)
|
|
99
|
+
* Prevents repeated discoverManifestSync calls for the same class name
|
|
100
|
+
*/
|
|
101
|
+
private static getDiscoveryAttemptCache;
|
|
102
|
+
/**
|
|
103
|
+
* Register field decorator metadata
|
|
104
|
+
*
|
|
105
|
+
* Called by property decorators (@field, @foreignKey, etc.) to store
|
|
106
|
+
* field configuration metadata. This enables the decorator pattern
|
|
107
|
+
* where field metadata is attached at class definition time.
|
|
108
|
+
*
|
|
109
|
+
* @param className - Name of the class containing the field
|
|
110
|
+
* @param propertyKey - Name of the property being decorated
|
|
111
|
+
* @param options - Field options (type, constraints, etc.)
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* // Called internally by decorators
|
|
115
|
+
* ObjectRegistry.registerFieldDecorator('Product', 'name', {
|
|
116
|
+
* type: 'text',
|
|
117
|
+
* required: true
|
|
118
|
+
* });
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
static registerFieldDecorator(className: string, propertyKey: string, options: any): void;
|
|
122
|
+
/**
|
|
123
|
+
* Get field decorator metadata for a specific field
|
|
124
|
+
*
|
|
125
|
+
* @param className - Name of the class
|
|
126
|
+
* @param propertyKey - Name of the property
|
|
127
|
+
* @returns Field options or undefined if not decorated
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* const options = ObjectRegistry.getFieldDecorator('Product', 'name');
|
|
131
|
+
* // { type: 'text', required: true }
|
|
132
|
+
* ```
|
|
133
|
+
*/
|
|
134
|
+
static getFieldDecorator(className: string, propertyKey: string): any | undefined;
|
|
135
|
+
/**
|
|
136
|
+
* Get all field decorator metadata for a class
|
|
137
|
+
*
|
|
138
|
+
* @param className - Name of the class
|
|
139
|
+
* @returns Map of property names to field options
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* const fields = ObjectRegistry.getFieldDecorators('Product');
|
|
143
|
+
* // Map { 'name' => { type: 'text', required: true }, ... }
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
static getFieldDecorators(className: string): Map<string, any>;
|
|
147
|
+
/**
|
|
148
|
+
* Check if a class has any field decorators registered
|
|
149
|
+
*
|
|
150
|
+
* @param className - Name of the class
|
|
151
|
+
* @returns True if the class has field decorators, false otherwise
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* if (ObjectRegistry.hasFieldDecorators('Product')) {
|
|
155
|
+
* // Class uses decorators - skip legacy field initialization
|
|
156
|
+
* }
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
159
|
+
static hasFieldDecorators(className: string): boolean;
|
|
160
|
+
/**
|
|
161
|
+
* Register a new SMRT object class with the global registry
|
|
162
|
+
*
|
|
163
|
+
* @param constructor - The class constructor extending SmrtObject
|
|
164
|
+
* @param config - Configuration options for API/CLI/MCP generation
|
|
165
|
+
* @throws {Error} If the class cannot be introspected for field definitions
|
|
166
|
+
* @example
|
|
167
|
+
* ```typescript
|
|
168
|
+
* ObjectRegistry.register(Product, {
|
|
169
|
+
* api: { exclude: ['delete'] },
|
|
170
|
+
* cli: true,
|
|
171
|
+
* mcp: { include: ['list', 'get'] }
|
|
172
|
+
* });
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
static register(ctor: typeof SmrtObject, config?: SmartObjectConfig): void;
|
|
176
|
+
/**
|
|
177
|
+
* Register a collection class for an object
|
|
178
|
+
*
|
|
179
|
+
* @param objectName - Name of the object class this collection manages
|
|
180
|
+
* @param collectionConstructor - The collection class constructor
|
|
181
|
+
* @example
|
|
182
|
+
* ```typescript
|
|
183
|
+
* ObjectRegistry.registerCollection('Product', ProductCollection);
|
|
184
|
+
* ```
|
|
185
|
+
*/
|
|
186
|
+
static registerCollection(objectName: string, collectionConstructor: new (options: any) => SmrtCollection<any>): void;
|
|
187
|
+
static registerFromManifest(name: string, objectDef: any, packageName?: string): void;
|
|
188
|
+
/**
|
|
189
|
+
* Helper method for class lookup with qualified name support.
|
|
190
|
+
*
|
|
191
|
+
* Lookup priority:
|
|
192
|
+
* 1. Direct hit on classes map (works for qualified names as keys)
|
|
193
|
+
* 2. If input contains ':', treat as qualified name — direct only, no fallback
|
|
194
|
+
* 3. classNameMap lookup by simple name (lowercase)
|
|
195
|
+
* - Unambiguous (1 entry) → return it
|
|
196
|
+
* - Ambiguous (>1 entry) → throw descriptive error
|
|
197
|
+
* 4. Case-insensitive iteration fallback (backward compat)
|
|
198
|
+
*
|
|
199
|
+
* @param name - Name of the class to find (simple or qualified)
|
|
200
|
+
* @returns Registered class information or undefined if not found
|
|
201
|
+
* @remarks When a simple name is ambiguous (multiple packages define it),
|
|
202
|
+
* logs a warning and returns the first match. Use qualified names
|
|
203
|
+
* or resolveType() for strict disambiguation.
|
|
204
|
+
* @private
|
|
205
|
+
*/
|
|
206
|
+
private static findClass;
|
|
207
|
+
/**
|
|
208
|
+
* Get a registered class by name (case-insensitive)
|
|
209
|
+
*
|
|
210
|
+
* @param name - Name of the registered class
|
|
211
|
+
* @returns Registered class information or undefined if not found
|
|
212
|
+
* @example
|
|
213
|
+
* ```typescript
|
|
214
|
+
* const productInfo = ObjectRegistry.getClass('Product');
|
|
215
|
+
* // Also works with: 'product', 'PRODUCT', etc.
|
|
216
|
+
* if (productInfo) {
|
|
217
|
+
* console.log(productInfo.config.api?.exclude);
|
|
218
|
+
* }
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
static getClass(name: string): RegisteredClass | undefined;
|
|
222
|
+
/**
|
|
223
|
+
* Get a registered class by its constructor reference.
|
|
224
|
+
* This is the most reliable lookup method as it avoids name collision issues
|
|
225
|
+
* that can occur when multiple packages define classes with the same name.
|
|
226
|
+
*
|
|
227
|
+
* Uses a WeakMap index for O(1) lookups.
|
|
228
|
+
*
|
|
229
|
+
* @param ctor - The class constructor to look up
|
|
230
|
+
* @returns Registered class information or undefined if not found
|
|
231
|
+
* @example
|
|
232
|
+
* ```typescript
|
|
233
|
+
* import { Meeting } from '@happyvertical/praeco';
|
|
234
|
+
*
|
|
235
|
+
* const info = ObjectRegistry.getClassByConstructor(Meeting);
|
|
236
|
+
* if (info) {
|
|
237
|
+
* console.log(info.qualifiedName); // '@happyvertical/praeco:Meeting'
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
static getClassByConstructor(ctor: SmrtObjectConstructor): RegisteredClass | undefined;
|
|
242
|
+
/**
|
|
243
|
+
* Get a registered class by its qualified name.
|
|
244
|
+
* Qualified names are in format "@package/name:ClassName".
|
|
245
|
+
*
|
|
246
|
+
* @param qualifiedName - The fully qualified class name
|
|
247
|
+
* @returns Registered class information or undefined if not found
|
|
248
|
+
* @example
|
|
249
|
+
* ```typescript
|
|
250
|
+
* const product = ObjectRegistry.getClassByQualifiedName('@happyvertical/smrt-products:Product');
|
|
251
|
+
* if (product) {
|
|
252
|
+
* console.log(`Found: ${product.name} from ${product.packageName}`);
|
|
253
|
+
* }
|
|
254
|
+
* ```
|
|
255
|
+
*/
|
|
256
|
+
static getClassByQualifiedName(qualifiedName: string): RegisteredClass | undefined;
|
|
257
|
+
/**
|
|
258
|
+
* Get a registered class by package name and class name.
|
|
259
|
+
* This is a convenience method for looking up classes by their namespace components.
|
|
260
|
+
*
|
|
261
|
+
* @param packageName - The package name (e.g., "@happyvertical/smrt-products")
|
|
262
|
+
* @param className - The class name (e.g., "Product")
|
|
263
|
+
* @returns Registered class information or undefined if not found
|
|
264
|
+
* @example
|
|
265
|
+
* ```typescript
|
|
266
|
+
* const product = ObjectRegistry.getClassInPackage('@happyvertical/smrt-products', 'Product');
|
|
267
|
+
* ```
|
|
268
|
+
*/
|
|
269
|
+
static getClassInPackage(packageName: string, className: string): RegisteredClass | undefined;
|
|
270
|
+
/**
|
|
271
|
+
* Find all registered classes with a given simple class name.
|
|
272
|
+
* Useful for detecting collisions or when multiple packages have the same class name.
|
|
273
|
+
*
|
|
274
|
+
* @param className - The simple class name to search for
|
|
275
|
+
* @returns Array of registered classes with matching name
|
|
276
|
+
* @example
|
|
277
|
+
* ```typescript
|
|
278
|
+
* const products = ObjectRegistry.findClassesByName('Product');
|
|
279
|
+
* if (products.length > 1) {
|
|
280
|
+
* console.log(`Found ${products.length} classes named "Product":`);
|
|
281
|
+
* for (const p of products) {
|
|
282
|
+
* console.log(` - ${p.qualifiedName} from ${p.packageName}`);
|
|
283
|
+
* }
|
|
284
|
+
* }
|
|
285
|
+
* ```
|
|
286
|
+
*/
|
|
287
|
+
static findClassesByName(className: string): RegisteredClass[];
|
|
288
|
+
/**
|
|
289
|
+
* Resolve a short class name to its qualified name.
|
|
290
|
+
* Throws an error if the name is ambiguous (multiple packages define the same class name).
|
|
291
|
+
*
|
|
292
|
+
* @param shortName - The simple class name to resolve (e.g., 'MeetingRecap')
|
|
293
|
+
* @returns The qualified class name (e.g., '@happyvertical/praeco:MeetingRecap')
|
|
294
|
+
* @throws {Error} If no class with that name is registered
|
|
295
|
+
* @throws {Error} If multiple classes with that name exist (ambiguous)
|
|
296
|
+
*
|
|
297
|
+
* @example
|
|
298
|
+
* ```typescript
|
|
299
|
+
* // Unambiguous resolution
|
|
300
|
+
* const qualified = ObjectRegistry.resolveType('MeetingRecap');
|
|
301
|
+
* // Returns: '@happyvertical/praeco:MeetingRecap'
|
|
302
|
+
*
|
|
303
|
+
* // Already qualified names pass through
|
|
304
|
+
* const same = ObjectRegistry.resolveType('@happyvertical/praeco:MeetingRecap');
|
|
305
|
+
* // Returns: '@happyvertical/praeco:MeetingRecap'
|
|
306
|
+
*
|
|
307
|
+
* // Ambiguous names throw
|
|
308
|
+
* ObjectRegistry.resolveType('Event');
|
|
309
|
+
* // Error: "Event" is ambiguous. Found in multiple packages:
|
|
310
|
+
* // - @happyvertical/smrt-events:Event
|
|
311
|
+
* // - @happyvertical/calendar:Event
|
|
312
|
+
* // Use the fully qualified name instead.
|
|
313
|
+
* ```
|
|
314
|
+
*/
|
|
315
|
+
static resolveType(shortName: string): QualifiedClassName;
|
|
316
|
+
/**
|
|
317
|
+
* Get all registered classes from a specific package.
|
|
318
|
+
*
|
|
319
|
+
* @param packageName - The package name to filter by
|
|
320
|
+
* @returns Map of class names to registered class information
|
|
321
|
+
* @example
|
|
322
|
+
* ```typescript
|
|
323
|
+
* const coreClasses = ObjectRegistry.getClassesByPackage('@happyvertical/smrt-core');
|
|
324
|
+
* for (const [name, info] of coreClasses) {
|
|
325
|
+
* console.log(` ${name}: ${info.qualifiedName}`);
|
|
326
|
+
* }
|
|
327
|
+
* ```
|
|
328
|
+
*/
|
|
329
|
+
static getClassesByPackage(packageName: string): Map<string, RegisteredClass>;
|
|
330
|
+
/**
|
|
331
|
+
* Get all registered classes with a specific visibility level.
|
|
332
|
+
*
|
|
333
|
+
* @param visibility - The visibility level to filter by
|
|
334
|
+
* @returns Map of class names to registered class information
|
|
335
|
+
* @example
|
|
336
|
+
* ```typescript
|
|
337
|
+
* const publicClasses = ObjectRegistry.getClassesByVisibility('public');
|
|
338
|
+
* console.log(`Found ${publicClasses.size} public classes`);
|
|
339
|
+
* ```
|
|
340
|
+
*/
|
|
341
|
+
static getClassesByVisibility(visibility: SmrtVisibility): Map<string, RegisteredClass>;
|
|
342
|
+
/**
|
|
343
|
+
* Get all public registered classes (excludes 'internal' and 'test' visibility).
|
|
344
|
+
* Useful for generating published manifests or public APIs.
|
|
345
|
+
*
|
|
346
|
+
* @returns Map of class names to registered class information
|
|
347
|
+
* @example
|
|
348
|
+
* ```typescript
|
|
349
|
+
* const publicClasses = ObjectRegistry.getPublicClasses();
|
|
350
|
+
* console.log(`Publishing ${publicClasses.size} public classes to manifest`);
|
|
351
|
+
* ```
|
|
352
|
+
*/
|
|
353
|
+
static getPublicClasses(): Map<string, RegisteredClass>;
|
|
354
|
+
/**
|
|
355
|
+
* Get all registered classes
|
|
356
|
+
*
|
|
357
|
+
* @returns Map of class names to registered class information
|
|
358
|
+
* @example
|
|
359
|
+
* ```typescript
|
|
360
|
+
* const allClasses = ObjectRegistry.getAllClasses();
|
|
361
|
+
* for (const [name, info] of allClasses) {
|
|
362
|
+
* console.log(`Class: ${name}, Fields: ${info.fields.size}`);
|
|
363
|
+
* }
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
static getAllClasses(): Map<string, RegisteredClass>;
|
|
367
|
+
/**
|
|
368
|
+
* Get class names, deduplicated by simple class name.
|
|
369
|
+
*
|
|
370
|
+
* This is useful for display and backwards compatibility. Use
|
|
371
|
+
* `getQualifiedClassNames()` for schema/bootstrap loops that must preserve
|
|
372
|
+
* cross-package collisions.
|
|
373
|
+
*/
|
|
374
|
+
static getClassNames(): string[];
|
|
375
|
+
/**
|
|
376
|
+
* Get one lookup name per registered class, preserving cross-package
|
|
377
|
+
* collisions by preferring qualified class names where available.
|
|
378
|
+
*/
|
|
379
|
+
static getQualifiedClassNames(): string[];
|
|
380
|
+
/**
|
|
381
|
+
* Try to load and register a class from external SMRT packages
|
|
382
|
+
*
|
|
383
|
+
* This method attempts to auto-discover classes from @happyvertical/smrt-* packages
|
|
384
|
+
* when they're referenced but not yet registered. Solves issue #343 where STI classes
|
|
385
|
+
* from external packages (e.g., Person from smrt-profiles) weren't loading correctly.
|
|
386
|
+
*
|
|
387
|
+
* @param className - Name of the class to load
|
|
388
|
+
* @returns Promise<boolean> - True if successfully loaded and registered, false otherwise
|
|
389
|
+
* @private
|
|
390
|
+
*/
|
|
391
|
+
static tryLoadFromExternalPackage(className: string): Promise<boolean>;
|
|
392
|
+
/**
|
|
393
|
+
* Load all manifests upfront so inheritance queries are pure lookups.
|
|
394
|
+
*
|
|
395
|
+
* After this method completes, every class across all packages is
|
|
396
|
+
* registered and `getInheritanceChain()` will never need to mutate
|
|
397
|
+
* registry state.
|
|
398
|
+
*
|
|
399
|
+
* @param options - Optional configuration
|
|
400
|
+
* @param options.manifestPaths - Explicit list of manifest.json file paths to load.
|
|
401
|
+
* When omitted the method discovers packages via `loadExternalManifestSync()`
|
|
402
|
+
* for every `@happyvertical` package found in `node_modules`.
|
|
403
|
+
* @returns Summary statistics about the load operation
|
|
404
|
+
*
|
|
405
|
+
* @example
|
|
406
|
+
* ```typescript
|
|
407
|
+
* // At CLI / server startup
|
|
408
|
+
* ObjectRegistry.loadAllManifests();
|
|
409
|
+
* // All classes are now registered — inheritance lookups are side-effect free
|
|
410
|
+
* ```
|
|
411
|
+
*
|
|
412
|
+
* @see https://github.com/happyvertical/smrt/issues/1007
|
|
413
|
+
*/
|
|
414
|
+
static loadAllManifests(options?: {
|
|
415
|
+
manifestPaths?: string[];
|
|
416
|
+
}): {
|
|
417
|
+
packagesLoaded: number;
|
|
418
|
+
objectsRegistered: number;
|
|
419
|
+
};
|
|
420
|
+
/**
|
|
421
|
+
* Register a package's own bundled manifest, called by the package itself at
|
|
422
|
+
* import time to eliminate the consumer-runtime field-drop bug (issue #1132).
|
|
423
|
+
*
|
|
424
|
+
* Packages ship a `dist/manifest.json` next to their compiled entry. A small
|
|
425
|
+
* `__smrt-register__.js` side-effect module imports that file URL and calls
|
|
426
|
+
* this method *before* any `@smrt()` decorator in the package fires, so the
|
|
427
|
+
* decorator's synchronous manifest lookup hits a populated cache instead of
|
|
428
|
+
* registering classes with zero fields.
|
|
429
|
+
*
|
|
430
|
+
* Silently no-ops if the URL can't be read — in dev/test the vitest plugin
|
|
431
|
+
* populates manifests through a different path, and this fallback is expected
|
|
432
|
+
* to miss in those contexts.
|
|
433
|
+
*
|
|
434
|
+
* @param manifestUrl - File URL (or string) pointing to the package's
|
|
435
|
+
* manifest.json. Typical call site:
|
|
436
|
+
* `new URL('./manifest.json', import.meta.url)`
|
|
437
|
+
* @returns Summary with loaded status, package name, and object count
|
|
438
|
+
*
|
|
439
|
+
* @example
|
|
440
|
+
* ```typescript
|
|
441
|
+
* // packages/smrt-places/src/__smrt-register__.ts
|
|
442
|
+
* import { ObjectRegistry } from '@happyvertical/smrt-core';
|
|
443
|
+
* ObjectRegistry.registerPackageManifest(
|
|
444
|
+
* new URL('./manifest.json', import.meta.url),
|
|
445
|
+
* );
|
|
446
|
+
* ```
|
|
447
|
+
*
|
|
448
|
+
* @see https://github.com/happyvertical/smrt/issues/1132
|
|
449
|
+
*/
|
|
450
|
+
static registerPackageManifest(manifestUrl: string | URL): {
|
|
451
|
+
loaded: boolean;
|
|
452
|
+
packageName?: string;
|
|
453
|
+
objectsRegistered: number;
|
|
454
|
+
};
|
|
455
|
+
/**
|
|
456
|
+
* Snapshot of diagnostics collected from registry load paths.
|
|
457
|
+
*
|
|
458
|
+
* Registry paths that previously `console.warn(...); return null` also
|
|
459
|
+
* record a structured diagnostic. Apps can inspect this buffer at startup
|
|
460
|
+
* or from an error route to surface failures that would otherwise be silent.
|
|
461
|
+
*
|
|
462
|
+
* Strict mode is **on by default** since Release C (#1134): severity
|
|
463
|
+
* `'error'` diagnostics throw at record time. Set
|
|
464
|
+
* `SMRT_STRICT_REGISTRY=false` to restore the pre-Release-C permissive
|
|
465
|
+
* behavior where only the diagnostic is recorded and nothing throws.
|
|
466
|
+
*
|
|
467
|
+
* @see https://github.com/happyvertical/smrt/issues/1132
|
|
468
|
+
* @see https://github.com/happyvertical/smrt/issues/1134
|
|
469
|
+
*/
|
|
470
|
+
static getDiagnostics(): readonly RegistryDiagnostic[];
|
|
471
|
+
/** Clear the diagnostic buffer. Primarily for tests. */
|
|
472
|
+
static clearDiagnostics(): void;
|
|
473
|
+
/**
|
|
474
|
+
* Pretty-print the diagnostic buffer via `console.warn` / `console.error`.
|
|
475
|
+
* No-op when the buffer is empty.
|
|
476
|
+
*/
|
|
477
|
+
static flushDiagnostics(): void;
|
|
478
|
+
/**
|
|
479
|
+
* Check if a class is registered (case-insensitive)
|
|
480
|
+
*/
|
|
481
|
+
static hasClass(name: string): boolean;
|
|
482
|
+
/**
|
|
483
|
+
* Clear all registered classes (mainly for testing)
|
|
484
|
+
*/
|
|
485
|
+
static clear(): void;
|
|
486
|
+
/**
|
|
487
|
+
* Invalidate inheritance cache for a specific class
|
|
488
|
+
*
|
|
489
|
+
* Clears cached inheritance chain and merged fields/methods for the given class.
|
|
490
|
+
* Call this when a class definition changes at runtime (e.g., hot module reload).
|
|
491
|
+
*
|
|
492
|
+
* @param className - The class name to invalidate cache for
|
|
493
|
+
* @example
|
|
494
|
+
* ```typescript
|
|
495
|
+
* // After hot module reload of a parent class
|
|
496
|
+
* ObjectRegistry.invalidateInheritanceCache('BentleyContent');
|
|
497
|
+
* ```
|
|
498
|
+
*/
|
|
499
|
+
static invalidateInheritanceCache(className: string): void;
|
|
500
|
+
/**
|
|
501
|
+
* Invalidate all inheritance caches
|
|
502
|
+
*
|
|
503
|
+
* Clears all cached inheritance chains and merged fields/methods.
|
|
504
|
+
* Call this when multiple classes change at runtime.
|
|
505
|
+
*
|
|
506
|
+
* @example
|
|
507
|
+
* ```typescript
|
|
508
|
+
* // After hot module reload of multiple classes
|
|
509
|
+
* ObjectRegistry.invalidateAllInheritanceCaches();
|
|
510
|
+
* ```
|
|
511
|
+
*/
|
|
512
|
+
static invalidateAllInheritanceCaches(): void;
|
|
513
|
+
/**
|
|
514
|
+
* Resolve a collection lookup name to the registered object metadata and
|
|
515
|
+
* collection constructor that should back it.
|
|
516
|
+
*
|
|
517
|
+
* Accepts any supported collection identifier:
|
|
518
|
+
* - simple class name (`FactRecord`)
|
|
519
|
+
* - qualified class name (`@pkg:FactRecord`)
|
|
520
|
+
* - explicit collection alias (`fact_records`) when registered
|
|
521
|
+
*
|
|
522
|
+
* Returns a canonical class identity so cache keys remain stable across
|
|
523
|
+
* aliases that refer to the same underlying collection.
|
|
524
|
+
*/
|
|
525
|
+
private static resolveCollectionRegistration;
|
|
526
|
+
/**
|
|
527
|
+
* Get or create a cached collection instance (Singleton pattern - Phase 4 optimization)
|
|
528
|
+
*
|
|
529
|
+
* Returns a cached collection if one exists for the given class and options,
|
|
530
|
+
* otherwise creates, initializes, and caches a new instance. This significantly
|
|
531
|
+
* improves performance by avoiding repeated collection initialization.
|
|
532
|
+
*
|
|
533
|
+
* **Performance Impact**: 60-80% reduction in collection initialization overhead
|
|
534
|
+
*
|
|
535
|
+
* **Cache Key Strategy**: Collections are cached based on:
|
|
536
|
+
* - className
|
|
537
|
+
* - persistence configuration (type, url, baseUrl)
|
|
538
|
+
* - db presence (not full config)
|
|
539
|
+
* - ai presence (not full config)
|
|
540
|
+
*
|
|
541
|
+
* Different persistence configurations create separate cached instances.
|
|
542
|
+
*
|
|
543
|
+
* @param className - Name of the object class
|
|
544
|
+
* @param options - Configuration options for the collection
|
|
545
|
+
* @returns Cached or newly created collection instance
|
|
546
|
+
* @throws {Error} If the class is not registered or has no collection
|
|
547
|
+
*
|
|
548
|
+
* @example
|
|
549
|
+
* ```typescript
|
|
550
|
+
* // First call creates and caches the collection
|
|
551
|
+
* const orders1 = await ObjectRegistry.getCollection('Order', {
|
|
552
|
+
* persistence: { type: 'sql', url: 'orders.db' }
|
|
553
|
+
* });
|
|
554
|
+
*
|
|
555
|
+
* // Subsequent calls return the cached instance (much faster)
|
|
556
|
+
* const orders2 = await ObjectRegistry.getCollection('Order', {
|
|
557
|
+
* persistence: { type: 'sql', url: 'orders.db' }
|
|
558
|
+
* });
|
|
559
|
+
* console.log(orders1 === orders2); // true (same instance)
|
|
560
|
+
*
|
|
561
|
+
* // Different configuration creates new instance
|
|
562
|
+
* const orders3 = await ObjectRegistry.getCollection('Order', {
|
|
563
|
+
* persistence: { type: 'sql', url: 'orders-copy.db' }
|
|
564
|
+
* });
|
|
565
|
+
* console.log(orders1 === orders3); // false (different config)
|
|
566
|
+
* ```
|
|
567
|
+
*
|
|
568
|
+
* @see {@link https://github.com/happyvertical/sdk/blob/main/packages/core/CLAUDE.md#singleton-collection-management-phase-4|Phase 4 Documentation}
|
|
569
|
+
*/
|
|
570
|
+
static getCollection<T extends SmrtObject>(className: string, options?: any): Promise<SmrtCollection<T>>;
|
|
571
|
+
/**
|
|
572
|
+
* Get field definitions for a registered class.
|
|
573
|
+
* Supports both qualified names and simple class names.
|
|
574
|
+
*/
|
|
575
|
+
static getFields(name: string): Map<string, any>;
|
|
576
|
+
/**
|
|
577
|
+
* Get method definitions for a registered class
|
|
578
|
+
*
|
|
579
|
+
* Returns method metadata extracted from the manifest during AST scanning.
|
|
580
|
+
* This enables code generators (CLI, API, MCP) to discover custom methods
|
|
581
|
+
* and automatically generate corresponding commands/endpoints/tools.
|
|
582
|
+
*
|
|
583
|
+
* @param name - Name of the registered class
|
|
584
|
+
* @returns Map of method names to MethodDefinition objects
|
|
585
|
+
* @example
|
|
586
|
+
* ```typescript
|
|
587
|
+
* const methods = ObjectRegistry.getMethods('Agent');
|
|
588
|
+
* for (const [name, methodDef] of methods) {
|
|
589
|
+
* console.log(`Method: ${name}`);
|
|
590
|
+
* console.log(` Async: ${methodDef.async}`);
|
|
591
|
+
* console.log(` Public: ${methodDef.isPublic}`);
|
|
592
|
+
* console.log(` Params: ${methodDef.parameters.map(p => p.name).join(', ')}`);
|
|
593
|
+
* }
|
|
594
|
+
* ```
|
|
595
|
+
*/
|
|
596
|
+
static getMethods(name: string): Map<string, any>;
|
|
597
|
+
static compileValidators(className: string, fields: Map<string, any>): ValidatorFunction[];
|
|
598
|
+
/**
|
|
599
|
+
* Ensure manifest is loaded for external package classes
|
|
600
|
+
*
|
|
601
|
+
* For classes from external packages, the manifest may not be loaded during
|
|
602
|
+
* initial registration (which must be synchronous for decorator support).
|
|
603
|
+
* This method loads the manifest asynchronously when needed.
|
|
604
|
+
*
|
|
605
|
+
* @param className - Name of the class to ensure manifest is loaded for
|
|
606
|
+
* @returns Promise that resolves when manifest is loaded (or already loaded)
|
|
607
|
+
* @throws {Error} If manifest cannot be found
|
|
608
|
+
*
|
|
609
|
+
* @example
|
|
610
|
+
* ```typescript
|
|
611
|
+
* // Before using fields from external package
|
|
612
|
+
* await ObjectRegistry.ensureManifestLoaded('Place');
|
|
613
|
+
* const fields = ObjectRegistry.getFields('Place'); // Now has fields
|
|
614
|
+
* ```
|
|
615
|
+
*/
|
|
616
|
+
static ensureManifestLoaded(className: string): Promise<void>;
|
|
617
|
+
/**
|
|
618
|
+
* Get configuration for a registered class
|
|
619
|
+
*/
|
|
620
|
+
static getConfig(name: string): SmartObjectConfig;
|
|
621
|
+
/**
|
|
622
|
+
* Get cached schema definition for a registered class
|
|
623
|
+
*/
|
|
624
|
+
static getSchema(name: string): SchemaDefinition | undefined;
|
|
625
|
+
/**
|
|
626
|
+
* Get SQL DDL statement for a registered class
|
|
627
|
+
*/
|
|
628
|
+
static getSchemaDDL(name: string): string | undefined;
|
|
629
|
+
/**
|
|
630
|
+
* Get table name for a registered class
|
|
631
|
+
*/
|
|
632
|
+
static getTableName(name: string): string | undefined;
|
|
633
|
+
/**
|
|
634
|
+
* Get all pre-generated schemas for passing to database adapters
|
|
635
|
+
*/
|
|
636
|
+
static getAllSchemas(): Record<string, {
|
|
637
|
+
tableName: string;
|
|
638
|
+
ddl: string;
|
|
639
|
+
indexes?: string[];
|
|
640
|
+
}>;
|
|
641
|
+
/**
|
|
642
|
+
* Get all registered schemas as SchemaDefinition objects
|
|
643
|
+
*/
|
|
644
|
+
static getAllSchemasAsDefinitions(): Record<string, SchemaDefinition>;
|
|
645
|
+
/**
|
|
646
|
+
* Get compiled validation functions for a registered class
|
|
647
|
+
*
|
|
648
|
+
* Returns pre-compiled validation functions that can be executed
|
|
649
|
+
* at runtime for efficient validation without repeated setup.
|
|
650
|
+
*
|
|
651
|
+
* @param name - Name of the registered class
|
|
652
|
+
* @returns Array of validation functions or undefined if not found
|
|
653
|
+
* @example
|
|
654
|
+
* ```typescript
|
|
655
|
+
* const validators = ObjectRegistry.getValidators('Product');
|
|
656
|
+
* for (const validator of validators || []) {
|
|
657
|
+
* const error = await validator(productInstance);
|
|
658
|
+
* if (error) console.error(error);
|
|
659
|
+
* }
|
|
660
|
+
* ```
|
|
661
|
+
*/
|
|
662
|
+
static getValidators(name: string): ValidatorFunction[] | undefined;
|
|
663
|
+
/**
|
|
664
|
+
* Get pre-computed validation rules for a registered class
|
|
665
|
+
*
|
|
666
|
+
* Returns serializable validation rules that can be evaluated at runtime
|
|
667
|
+
* without needing pre-compiled validator closures. This significantly
|
|
668
|
+
* reduces CLI startup time for projects with many SMRT objects.
|
|
669
|
+
*
|
|
670
|
+
* @param name - Name of the registered class
|
|
671
|
+
* @returns Array of validation rules or undefined if not found
|
|
672
|
+
* @see https://github.com/happyvertical/smrt/issues/782
|
|
673
|
+
*/
|
|
674
|
+
static getValidationRules(name: string): ValidationRule[] | undefined;
|
|
675
|
+
/**
|
|
676
|
+
* Validate an instance using pre-computed validation rules
|
|
677
|
+
*
|
|
678
|
+
* This method evaluates validation rules without creating closures,
|
|
679
|
+
* providing faster validation than compiled validator functions.
|
|
680
|
+
*
|
|
681
|
+
* @param instance - The object instance to validate
|
|
682
|
+
* @param rules - Array of validation rules to apply
|
|
683
|
+
* @param className - Name of the class for error messages
|
|
684
|
+
* @returns Array of validation errors (empty if valid)
|
|
685
|
+
* @see https://github.com/happyvertical/smrt/issues/782
|
|
686
|
+
*/
|
|
687
|
+
static validateWithRules(instance: any, rules: ValidationRule[], className: string): Promise<any[]>;
|
|
688
|
+
/**
|
|
689
|
+
* Build dependency graph from foreignKey relationships
|
|
690
|
+
*
|
|
691
|
+
* Returns a map where keys are class names and values are arrays
|
|
692
|
+
* of class names that the key depends on (via foreignKey fields).
|
|
693
|
+
*
|
|
694
|
+
* @returns Map of class name to array of dependency class names
|
|
695
|
+
* @example
|
|
696
|
+
* ```typescript
|
|
697
|
+
* const deps = ObjectRegistry.getDependencyGraph();
|
|
698
|
+
* // { 'Order': ['Customer', 'Product'], 'Customer': [], 'Product': ['Category'] }
|
|
699
|
+
* ```
|
|
700
|
+
*/
|
|
701
|
+
static getDependencyGraph(): Map<string, string[]>;
|
|
702
|
+
/**
|
|
703
|
+
* Get initialization order for classes based on dependency graph
|
|
704
|
+
*
|
|
705
|
+
* Uses topological sort to ensure that classes are initialized in
|
|
706
|
+
* an order that respects foreignKey dependencies (dependencies first).
|
|
707
|
+
*
|
|
708
|
+
* Foreign-key cycles (e.g. smrt-chat's ChatMessage.threadId -> ChatThread
|
|
709
|
+
* and ChatThread.rootMessageId -> ChatMessage) are BROKEN rather than
|
|
710
|
+
* treated as a fatal error: when a back-edge is encountered the recursion
|
|
711
|
+
* stops there, so every class still appears in the returned order. SMRT does
|
|
712
|
+
* not emit real DB `FOREIGN KEY` constraints in its generated CREATE TABLE
|
|
713
|
+
* DDL, so a table can be created before its cyclic reference target exists —
|
|
714
|
+
* the reference is satisfied once both tables are present. This mirrors the
|
|
715
|
+
* standard RDBMS approach (create tables first, wire cyclic references
|
|
716
|
+
* afterward) and matches SchemaManager.sortByDependencies, which already
|
|
717
|
+
* tolerates cycles. See issue #1333.
|
|
718
|
+
*
|
|
719
|
+
* @returns Array of class names in initialization order. Every registered
|
|
720
|
+
* class appears exactly once; cycle back-edges are dropped from the
|
|
721
|
+
* ordering constraints.
|
|
722
|
+
* @example
|
|
723
|
+
* ```typescript
|
|
724
|
+
* const order = ObjectRegistry.getInitializationOrder();
|
|
725
|
+
* // ['Category', 'Product', 'Customer', 'Order']
|
|
726
|
+
* // Tables are created in this order to avoid foreign key errors
|
|
727
|
+
* ```
|
|
728
|
+
*/
|
|
729
|
+
static getInitializationOrder(): string[];
|
|
730
|
+
/**
|
|
731
|
+
* Build comprehensive relationship map from all field types
|
|
732
|
+
*
|
|
733
|
+
* Returns a map containing all relationships (foreignKey, oneToMany, manyToMany)
|
|
734
|
+
* discovered in registered classes. This enables runtime relationship traversal
|
|
735
|
+
* and eager/lazy loading of related objects.
|
|
736
|
+
*
|
|
737
|
+
* @returns Map of class name to array of relationship metadata
|
|
738
|
+
* @example
|
|
739
|
+
* ```typescript
|
|
740
|
+
* const relationships = ObjectRegistry.getRelationshipMap();
|
|
741
|
+
* // {
|
|
742
|
+
* // 'Order': [
|
|
743
|
+
* // { sourceClass: 'Order', fieldName: 'customerId', targetClass: 'Customer',
|
|
744
|
+
* // type: 'foreignKey', options: { onDelete: 'restrict' } }
|
|
745
|
+
* // ],
|
|
746
|
+
* // 'Customer': [
|
|
747
|
+
* // { sourceClass: 'Customer', fieldName: 'orders', targetClass: 'Order',
|
|
748
|
+
* // type: 'oneToMany', options: {} }
|
|
749
|
+
* // ]
|
|
750
|
+
* // }
|
|
751
|
+
* ```
|
|
752
|
+
*/
|
|
753
|
+
static getRelationshipMap(): Map<string, RelationshipMetadata[]>;
|
|
754
|
+
/**
|
|
755
|
+
* Get relationships for a specific class
|
|
756
|
+
*
|
|
757
|
+
* @param className - Name of the class to get relationships for
|
|
758
|
+
* @returns Array of relationship metadata for the class
|
|
759
|
+
* @example
|
|
760
|
+
* ```typescript
|
|
761
|
+
* const orderRelationships = ObjectRegistry.getRelationships('Order');
|
|
762
|
+
* // [{ sourceClass: 'Order', fieldName: 'customerId', ... }]
|
|
763
|
+
* ```
|
|
764
|
+
*/
|
|
765
|
+
static getRelationships(className: string): RelationshipMetadata[];
|
|
766
|
+
/**
|
|
767
|
+
* Get full inheritance chain for a class
|
|
768
|
+
*
|
|
769
|
+
* Returns array of registered ancestor class names from the oldest
|
|
770
|
+
* registered ancestor down to the input class. Framework base classes
|
|
771
|
+
* (`SmrtObject`, `SmrtClass`, `SmrtCollection`) are **NOT** included
|
|
772
|
+
* because they are never registered — the walk terminates one step
|
|
773
|
+
* before them.
|
|
774
|
+
*
|
|
775
|
+
* Chain entries are **qualified names** (`@package/name:ClassName`)
|
|
776
|
+
* whenever the corresponding registration has one — i.e. for every
|
|
777
|
+
* class loaded via a manifest or `@smrt()` decorator with a package
|
|
778
|
+
* context. Classes registered without a package (some tests) fall
|
|
779
|
+
* back to their simple name.
|
|
780
|
+
*
|
|
781
|
+
* Results are cached globally for performance (~100x faster than re-walking).
|
|
782
|
+
*
|
|
783
|
+
* @param className - Name of the registered class (simple or qualified)
|
|
784
|
+
* @returns Array of class names from oldest registered ancestor to
|
|
785
|
+
* the input class, or empty array if not found
|
|
786
|
+
* @example
|
|
787
|
+
* ```typescript
|
|
788
|
+
* const chain = ObjectRegistry.getInheritanceChain(
|
|
789
|
+
* '@happyvertical/smrt-content:BentleyContent',
|
|
790
|
+
* );
|
|
791
|
+
* // [
|
|
792
|
+
* // '@happyvertical/smrt-content:Content',
|
|
793
|
+
* // '@happyvertical/smrt-content:PraecoContent',
|
|
794
|
+
* // '@happyvertical/smrt-content:BentleyContent',
|
|
795
|
+
* // ]
|
|
796
|
+
* ```
|
|
797
|
+
*/
|
|
798
|
+
static getInheritanceChain(className: string): string[];
|
|
799
|
+
/**
|
|
800
|
+
* Get all fields including inherited ones from parent classes
|
|
801
|
+
*
|
|
802
|
+
* **Hybrid approach (v0.17+):**
|
|
803
|
+
* - External packages: Use build-time merged fields from manifests
|
|
804
|
+
* - Local classes: Use runtime merging by walking inheritance chain
|
|
805
|
+
*
|
|
806
|
+
* @param className - Name of the registered class
|
|
807
|
+
* @returns Map of all fields (including inherited)
|
|
808
|
+
*/
|
|
809
|
+
static getAllFields(className: string): Promise<Map<string, any>>;
|
|
810
|
+
/**
|
|
811
|
+
* Merge field configurations from parent and child.
|
|
812
|
+
*
|
|
813
|
+
* Thin wrapper around the single shared implementation in
|
|
814
|
+
* registry/inheritance-resolver (#1378). The previous inline copy here had
|
|
815
|
+
* drifted from the module; both paths now run the same code. Kept as a
|
|
816
|
+
* private static so existing reach-in tests (issue #841 field-merge coverage)
|
|
817
|
+
* still resolve it.
|
|
818
|
+
*
|
|
819
|
+
* @param parentField - Field config from parent class
|
|
820
|
+
* @param childField - Field config from child class
|
|
821
|
+
* @param fieldName - Name of the field (for warning messages)
|
|
822
|
+
* @returns Merged field configuration
|
|
823
|
+
*/
|
|
824
|
+
private static mergeFieldConfigs;
|
|
825
|
+
/**
|
|
826
|
+
* Get all methods including inherited ones from parent classes
|
|
827
|
+
*
|
|
828
|
+
* Walks the full inheritance chain and merges methods:
|
|
829
|
+
* - Parent methods are added first
|
|
830
|
+
* - Child methods override parent methods (no config merging for methods)
|
|
831
|
+
*
|
|
832
|
+
* Results are cached per-class for performance.
|
|
833
|
+
*
|
|
834
|
+
* **Note:** This is an async method that ensures manifests are loaded for external package classes.
|
|
835
|
+
*
|
|
836
|
+
* @param className - Name of the registered class
|
|
837
|
+
* @returns Promise resolving to Map of all methods (own + inherited)
|
|
838
|
+
* @example
|
|
839
|
+
* ```typescript
|
|
840
|
+
* // Given: Content → PraecoContent → BentleyContent
|
|
841
|
+
* const allMethods = await ObjectRegistry.getAllMethods('BentleyContent');
|
|
842
|
+
* // Includes: generateSummary() (from PraecoContent) + analyzeLocal() (from BentleyContent)
|
|
843
|
+
* ```
|
|
844
|
+
*/
|
|
845
|
+
static getAllMethods(className: string): Promise<Map<string, any>>;
|
|
846
|
+
/**
|
|
847
|
+
* Get complete metadata for a single object (convenience method)
|
|
848
|
+
*
|
|
849
|
+
* Returns all available metadata for an object in a single call, including:
|
|
850
|
+
* - Class information
|
|
851
|
+
* - Field definitions
|
|
852
|
+
* - Configuration
|
|
853
|
+
* - Schema definition
|
|
854
|
+
* - Validators
|
|
855
|
+
* - Relationships
|
|
856
|
+
* - Tools (AI-callable methods)
|
|
857
|
+
*
|
|
858
|
+
* This is a convenience method that aggregates multiple registry queries
|
|
859
|
+
* into a single comprehensive metadata object.
|
|
860
|
+
*
|
|
861
|
+
* @param className - Name of the class to get metadata for
|
|
862
|
+
* @returns Complete metadata object or null if class not found
|
|
863
|
+
* @example
|
|
864
|
+
* ```typescript
|
|
865
|
+
* const productMeta = ObjectRegistry.getObjectMetadata('Product');
|
|
866
|
+
* if (productMeta) {
|
|
867
|
+
* console.log('Name:', productMeta.name);
|
|
868
|
+
* console.log('Table:', productMeta.schema.tableName);
|
|
869
|
+
* console.log('Fields:', productMeta.fields.size);
|
|
870
|
+
* console.log('API config:', productMeta.config.api);
|
|
871
|
+
* console.log('Relationships:', productMeta.relationships.length);
|
|
872
|
+
* }
|
|
873
|
+
* ```
|
|
874
|
+
*/
|
|
875
|
+
static getObjectMetadata(className: string): {
|
|
876
|
+
name: string;
|
|
877
|
+
constructor: typeof SmrtObject;
|
|
878
|
+
collectionConstructor?: new (options: any) => SmrtCollection<any>;
|
|
879
|
+
config: SmartObjectConfig;
|
|
880
|
+
fields: Map<string, any>;
|
|
881
|
+
methods: Map<string, any>;
|
|
882
|
+
schema: SchemaDefinition | undefined;
|
|
883
|
+
validators: ValidatorFunction[];
|
|
884
|
+
relationships: RelationshipMetadata[];
|
|
885
|
+
inverseRelationships: RelationshipMetadata[];
|
|
886
|
+
tools?: Array<{
|
|
887
|
+
type: 'function';
|
|
888
|
+
function: {
|
|
889
|
+
name: string;
|
|
890
|
+
description?: string;
|
|
891
|
+
parameters?: Record<string, any>;
|
|
892
|
+
};
|
|
893
|
+
}>;
|
|
894
|
+
} | null;
|
|
895
|
+
/**
|
|
896
|
+
* Get metadata for all registered objects (convenience method)
|
|
897
|
+
*
|
|
898
|
+
* Returns comprehensive metadata for every registered object, combining
|
|
899
|
+
* multiple registry queries into a single convenient data structure.
|
|
900
|
+
*
|
|
901
|
+
* This is particularly useful for:
|
|
902
|
+
* - Admin dashboards showing all objects
|
|
903
|
+
* - Documentation generation
|
|
904
|
+
* - Schema visualization
|
|
905
|
+
* - Debugging and introspection
|
|
906
|
+
*
|
|
907
|
+
* @returns Array of complete metadata objects for all registered classes
|
|
908
|
+
* @example
|
|
909
|
+
* ```typescript
|
|
910
|
+
* const allMetadata = ObjectRegistry.getAllObjectMetadata();
|
|
911
|
+
*
|
|
912
|
+
* // Generate admin dashboard
|
|
913
|
+
* for (const meta of allMetadata) {
|
|
914
|
+
* console.log(`${meta.name}:`);
|
|
915
|
+
* console.log(` Table: ${meta.schema?.tableName}`);
|
|
916
|
+
* console.log(` Fields: ${meta.fields.size}`);
|
|
917
|
+
* console.log(` API: ${meta.config.api ? 'enabled' : 'disabled'}`);
|
|
918
|
+
* console.log(` Relationships: ${meta.relationships.length}`);
|
|
919
|
+
* }
|
|
920
|
+
*
|
|
921
|
+
* // Generate schema documentation
|
|
922
|
+
* const schemaDoc = allMetadata.map(meta => ({
|
|
923
|
+
* name: meta.name,
|
|
924
|
+
* table: meta.schema?.tableName,
|
|
925
|
+
* fields: Array.from(meta.fields.entries()).map(([name, field]) => ({
|
|
926
|
+
* name,
|
|
927
|
+
* type: field.type,
|
|
928
|
+
* required: field._meta?.required || false
|
|
929
|
+
* })),
|
|
930
|
+
* relationships: meta.relationships.map(rel => ({
|
|
931
|
+
* field: rel.fieldName,
|
|
932
|
+
* target: rel.targetClass,
|
|
933
|
+
* type: rel.type
|
|
934
|
+
* }))
|
|
935
|
+
* }));
|
|
936
|
+
* ```
|
|
937
|
+
*/
|
|
938
|
+
static getAllObjectMetadata(): Array<{
|
|
939
|
+
name: string;
|
|
940
|
+
constructor: typeof SmrtObject;
|
|
941
|
+
collectionConstructor?: new (options: any) => SmrtCollection<any>;
|
|
942
|
+
config: SmartObjectConfig;
|
|
943
|
+
fields: Map<string, any>;
|
|
944
|
+
methods: Map<string, any>;
|
|
945
|
+
schema: SchemaDefinition | undefined;
|
|
946
|
+
validators: ValidatorFunction[];
|
|
947
|
+
relationships: RelationshipMetadata[];
|
|
948
|
+
inverseRelationships: RelationshipMetadata[];
|
|
949
|
+
tools?: Array<{
|
|
950
|
+
type: 'function';
|
|
951
|
+
function: {
|
|
952
|
+
name: string;
|
|
953
|
+
description?: string;
|
|
954
|
+
parameters?: Record<string, any>;
|
|
955
|
+
};
|
|
956
|
+
}>;
|
|
957
|
+
}>;
|
|
958
|
+
/**
|
|
959
|
+
* Get inverse relationships (relationships where this class is the target)
|
|
960
|
+
*
|
|
961
|
+
* @param className - Name of the class to find inverse relationships for
|
|
962
|
+
* @returns Array of relationship metadata where this class is the target
|
|
963
|
+
* @example
|
|
964
|
+
* ```typescript
|
|
965
|
+
* const customerInverseRels = ObjectRegistry.getInverseRelationships('Customer');
|
|
966
|
+
* // [{ sourceClass: 'Order', fieldName: 'customerId', targetClass: 'Customer', ... }]
|
|
967
|
+
* ```
|
|
968
|
+
*/
|
|
969
|
+
static getInverseRelationships(className: string): RelationshipMetadata[];
|
|
970
|
+
/**
|
|
971
|
+
* Names by which an instance of `className` can be referenced by an inverse
|
|
972
|
+
* foreign key: its own (simple) class name plus every registered ancestor in
|
|
973
|
+
* its inheritance chain.
|
|
974
|
+
*
|
|
975
|
+
* Used by oneToMany resolution so an STI subclass can resolve a relationship
|
|
976
|
+
* declared on its base — the inverse `@foreignKey` is declared against the
|
|
977
|
+
* base class name, while the runtime instance may be a subclass.
|
|
978
|
+
*
|
|
979
|
+
* @param className - Simple or qualified class name
|
|
980
|
+
* @returns Set of names (simple and, where available, qualified) the
|
|
981
|
+
* instance is assignable to
|
|
982
|
+
*/
|
|
983
|
+
static getSelfReferableNames(className: string): Set<string>;
|
|
984
|
+
/**
|
|
985
|
+
* Inverse relationships targeting `className` OR any (STI) ancestor it
|
|
986
|
+
* inherits from.
|
|
987
|
+
*
|
|
988
|
+
* `getInverseRelationships` matches the target class name exactly. This
|
|
989
|
+
* variant also matches inverse foreign keys declared against an ancestor,
|
|
990
|
+
* so an STI subclass instance can resolve a `@oneToMany` declared on its
|
|
991
|
+
* base — whose inverse `@foreignKey` points at the base class name.
|
|
992
|
+
*
|
|
993
|
+
* @param className - Name of the class to find inverse relationships for
|
|
994
|
+
* @returns Relationship metadata whose target is the class or one of its
|
|
995
|
+
* registered ancestors
|
|
996
|
+
*/
|
|
997
|
+
static getInverseRelationshipsForSelf(className: string): RelationshipMetadata[];
|
|
998
|
+
/**
|
|
999
|
+
* Get table inheritance strategy for a class
|
|
1000
|
+
*
|
|
1001
|
+
* Returns the table strategy (CTI or STI) for a class, with automatic
|
|
1002
|
+
* inheritance from parent classes. If not explicitly configured,
|
|
1003
|
+
* walks up the inheritance chain to find the strategy.
|
|
1004
|
+
*
|
|
1005
|
+
* **Strategy Inheritance:**
|
|
1006
|
+
* - Set once on base class, children inherit automatically
|
|
1007
|
+
* - Children can explicitly override (not recommended)
|
|
1008
|
+
* - Default is 'cti' if not found in hierarchy
|
|
1009
|
+
*
|
|
1010
|
+
* @param className - Name of the class to get strategy for
|
|
1011
|
+
* @returns 'cti' (Class Table Inheritance) or 'sti' (Single Table Inheritance)
|
|
1012
|
+
* @example
|
|
1013
|
+
* ```typescript
|
|
1014
|
+
* @smrt({ tableStrategy: 'sti' })
|
|
1015
|
+
* class Event extends SmrtObject { }
|
|
1016
|
+
*
|
|
1017
|
+
* @smrt() // Inherits 'sti'
|
|
1018
|
+
* class Meeting extends Event { }
|
|
1019
|
+
*
|
|
1020
|
+
* ObjectRegistry.getTableStrategy('Meeting'); // 'sti'
|
|
1021
|
+
* ObjectRegistry.getTableStrategy('Event'); // 'sti'
|
|
1022
|
+
* ```
|
|
1023
|
+
*/
|
|
1024
|
+
static getTableStrategy(className: string): 'cti' | 'sti';
|
|
1025
|
+
/**
|
|
1026
|
+
* Get the conflict columns for UPSERT operations on a class
|
|
1027
|
+
*
|
|
1028
|
+
* Returns custom conflict columns if specified, otherwise defaults based on
|
|
1029
|
+
* table strategy:
|
|
1030
|
+
* - CTI: ['slug', 'context']
|
|
1031
|
+
* - STI: ['slug', 'context', '_meta_type']
|
|
1032
|
+
*
|
|
1033
|
+
* STI subclasses share a table, so the discriminator participates in
|
|
1034
|
+
* identity — two subtypes can coexist with the same (slug, context). The
|
|
1035
|
+
* matching unique constraint on `(slug, context, _meta_type)` must exist
|
|
1036
|
+
* in the live schema; if a deployment carries a stale 2-column unique
|
|
1037
|
+
* instead, run `smrt db:migrate` to repair it (see issue #1165).
|
|
1038
|
+
*
|
|
1039
|
+
* @param className - Name of the class to get conflict columns for
|
|
1040
|
+
* @returns Array of column names to use for conflict detection
|
|
1041
|
+
*
|
|
1042
|
+
* @example
|
|
1043
|
+
* ```typescript
|
|
1044
|
+
* // Junction table with custom conflict columns
|
|
1045
|
+
* @smrt({ conflictColumns: ['event_id', 'profile_id'] })
|
|
1046
|
+
* class EventParticipant extends SmrtObject {}
|
|
1047
|
+
*
|
|
1048
|
+
* ObjectRegistry.getConflictColumns('EventParticipant');
|
|
1049
|
+
* // Returns: ['event_id', 'profile_id']
|
|
1050
|
+
* ```
|
|
1051
|
+
*/
|
|
1052
|
+
static getConflictColumns(className: string): string[];
|
|
1053
|
+
/**
|
|
1054
|
+
* Get the tenant scoping configuration for a class (Issue #688)
|
|
1055
|
+
*
|
|
1056
|
+
* Returns the normalized tenant scoping configuration if the class
|
|
1057
|
+
* was registered with `tenantScoped: true` or a tenantScoped config object.
|
|
1058
|
+
*
|
|
1059
|
+
* @param className - Name of the class to check
|
|
1060
|
+
* @returns Tenant scoping config or undefined if not tenant-scoped
|
|
1061
|
+
*
|
|
1062
|
+
* @example
|
|
1063
|
+
* ```typescript
|
|
1064
|
+
* @smrt({ tenantScoped: true })
|
|
1065
|
+
* class Document extends SmrtObject { }
|
|
1066
|
+
*
|
|
1067
|
+
* const config = ObjectRegistry.getTenantScopedConfig('Document');
|
|
1068
|
+
* // { mode: 'required', field: 'tenantId', autoFilter: true, autoPopulate: true, allowSuperAdminBypass: false }
|
|
1069
|
+
* ```
|
|
1070
|
+
*/
|
|
1071
|
+
static getTenantScopedConfig(className: string): RegisteredClass['tenantScopedConfig'] | undefined;
|
|
1072
|
+
/**
|
|
1073
|
+
* Check if a class is tenant-scoped (Issue #688)
|
|
1074
|
+
*
|
|
1075
|
+
* @param className - Name of the class to check
|
|
1076
|
+
* @returns true if the class has tenantScoped configuration
|
|
1077
|
+
*/
|
|
1078
|
+
static isTenantScoped(className: string): boolean;
|
|
1079
|
+
/**
|
|
1080
|
+
* Get the base class for an STI hierarchy
|
|
1081
|
+
*
|
|
1082
|
+
* Walks up the inheritance chain to find the first class configured
|
|
1083
|
+
* with `tableStrategy: 'sti'`. This is the class that owns the shared table.
|
|
1084
|
+
*
|
|
1085
|
+
* **Returns:**
|
|
1086
|
+
* - The base class's **qualified name** (`@package/name:ClassName`) when
|
|
1087
|
+
* the registration has one — same convention as
|
|
1088
|
+
* `getInheritanceChain`. Falls back to the simple name only for
|
|
1089
|
+
* registrations without a package context (some test classes).
|
|
1090
|
+
* - `null` if the class uses CTI strategy.
|
|
1091
|
+
*
|
|
1092
|
+
* Accepts either a simple or a qualified name on input.
|
|
1093
|
+
*
|
|
1094
|
+
* @param className - Name of the class to find STI base for
|
|
1095
|
+
* @returns Qualified base class name or null if CTI
|
|
1096
|
+
* @example
|
|
1097
|
+
* ```typescript
|
|
1098
|
+
* @smrt({ tableStrategy: 'sti' })
|
|
1099
|
+
* class Event extends SmrtObject { }
|
|
1100
|
+
*
|
|
1101
|
+
* @smrt()
|
|
1102
|
+
* class Meeting extends Event { }
|
|
1103
|
+
*
|
|
1104
|
+
* ObjectRegistry.getSTIBase('@happyvertical/smrt-events:Meeting');
|
|
1105
|
+
* // '@happyvertical/smrt-events:Event'
|
|
1106
|
+
* ObjectRegistry.getSTIBase('@happyvertical/smrt-events:Event');
|
|
1107
|
+
* // '@happyvertical/smrt-events:Event'
|
|
1108
|
+
* ```
|
|
1109
|
+
*/
|
|
1110
|
+
static getSTIBase(className: string): string | null;
|
|
1111
|
+
/**
|
|
1112
|
+
* Get all descendant classes of a base class
|
|
1113
|
+
*
|
|
1114
|
+
* Returns all registered classes that inherit from the specified base class.
|
|
1115
|
+
* Uses the `extends` field from manifest to build the descendant tree.
|
|
1116
|
+
*
|
|
1117
|
+
* **Use cases:**
|
|
1118
|
+
* - Schema generation: Aggregate fields from all children for STI table
|
|
1119
|
+
* - Polymorphic queries: Find all types to instantiate
|
|
1120
|
+
* - Documentation: Show class hierarchy
|
|
1121
|
+
*
|
|
1122
|
+
* Accepts either a simple or a qualified name on input. The returned
|
|
1123
|
+
* descendant names are **qualified** (`@package/name:ClassName`) when
|
|
1124
|
+
* the registration has one — same convention as `getInheritanceChain`
|
|
1125
|
+
* and `getSTIBase`.
|
|
1126
|
+
*
|
|
1127
|
+
* @param className - Name of the base class (simple or qualified)
|
|
1128
|
+
* @returns Array of qualified descendant class names (direct and indirect)
|
|
1129
|
+
* @example
|
|
1130
|
+
* ```typescript
|
|
1131
|
+
* @smrt({ tableStrategy: 'sti' })
|
|
1132
|
+
* class Event extends SmrtObject { }
|
|
1133
|
+
*
|
|
1134
|
+
* @smrt()
|
|
1135
|
+
* class Meeting extends Event { }
|
|
1136
|
+
*
|
|
1137
|
+
* @smrt()
|
|
1138
|
+
* class HockeyGame extends Event { }
|
|
1139
|
+
*
|
|
1140
|
+
* ObjectRegistry.getDescendants('@happyvertical/smrt-events:Event');
|
|
1141
|
+
* // [
|
|
1142
|
+
* // '@happyvertical/smrt-events:Meeting',
|
|
1143
|
+
* // '@happyvertical/smrt-events:HockeyGame',
|
|
1144
|
+
* // ]
|
|
1145
|
+
* ```
|
|
1146
|
+
*/
|
|
1147
|
+
static getDescendants(className: string): string[];
|
|
1148
|
+
/**
|
|
1149
|
+
* Persist registry state to system tables
|
|
1150
|
+
*
|
|
1151
|
+
* Saves all registered class metadata to the _smrt_registry system table
|
|
1152
|
+
* for runtime introspection and debugging. This enables applications to
|
|
1153
|
+
* query what SMRT objects exist and their configurations.
|
|
1154
|
+
*
|
|
1155
|
+
* @param db - Database interface to persist to
|
|
1156
|
+
* @returns Promise that resolves when persistence is complete
|
|
1157
|
+
* @example
|
|
1158
|
+
* ```typescript
|
|
1159
|
+
* // After registering all classes
|
|
1160
|
+
* await ObjectRegistry.persistToDatabase(db);
|
|
1161
|
+
*
|
|
1162
|
+
* // Later, query the system table
|
|
1163
|
+
* const rows = await db.all('SELECT * FROM _smrt_registry');
|
|
1164
|
+
* console.log('Registered classes:', rows.map(r => r.class_name));
|
|
1165
|
+
* ```
|
|
1166
|
+
*/
|
|
1167
|
+
static persistToDatabase(db: import('@happyvertical/sql').DatabaseInterface): Promise<void>;
|
|
1168
|
+
/**
|
|
1169
|
+
* Load registry metadata from system tables
|
|
1170
|
+
*
|
|
1171
|
+
* Reads the _smrt_registry system table to inspect what classes
|
|
1172
|
+
* have been registered. This is primarily for introspection and
|
|
1173
|
+
* debugging - actual class registration happens via @smrt() decorator.
|
|
1174
|
+
*
|
|
1175
|
+
* @param db - Database interface to load from
|
|
1176
|
+
* @returns Promise resolving to array of class metadata
|
|
1177
|
+
* @example
|
|
1178
|
+
* ```typescript
|
|
1179
|
+
* const metadata = await ObjectRegistry.loadFromDatabase(db);
|
|
1180
|
+
* for (const meta of metadata) {
|
|
1181
|
+
* console.log(`Class: ${meta.class_name}`);
|
|
1182
|
+
* console.log(`Table: ${JSON.parse(meta.manifest).tableName}`);
|
|
1183
|
+
* }
|
|
1184
|
+
* ```
|
|
1185
|
+
*/
|
|
1186
|
+
static loadFromDatabase(db: import('@happyvertical/sql').DatabaseInterface): Promise<any[]>;
|
|
1187
|
+
/**
|
|
1188
|
+
* Get embedding configuration for a class
|
|
1189
|
+
*
|
|
1190
|
+
* Returns the class-specific embedding config if embeddings are enabled.
|
|
1191
|
+
* This includes the fields to embed, provider override, and generation options.
|
|
1192
|
+
*
|
|
1193
|
+
* @param className - Name of the class to get embedding config for
|
|
1194
|
+
* @returns Class embedding config or undefined if not configured
|
|
1195
|
+
* @example
|
|
1196
|
+
* ```typescript
|
|
1197
|
+
* @smrt({
|
|
1198
|
+
* embeddings: {
|
|
1199
|
+
* fields: ['title', 'body'],
|
|
1200
|
+
* autoGenerate: true
|
|
1201
|
+
* }
|
|
1202
|
+
* })
|
|
1203
|
+
* class Article extends SmrtObject { }
|
|
1204
|
+
*
|
|
1205
|
+
* const config = ObjectRegistry.getEmbeddingConfig('Article');
|
|
1206
|
+
* // { fields: ['title', 'body'], autoGenerate: true }
|
|
1207
|
+
* ```
|
|
1208
|
+
*/
|
|
1209
|
+
static getEmbeddingConfig(className: string): ClassEmbeddingConfig | undefined;
|
|
1210
|
+
/**
|
|
1211
|
+
* Check if a class has embeddings enabled
|
|
1212
|
+
*
|
|
1213
|
+
* @param className - Name of the class to check
|
|
1214
|
+
* @returns True if the class has embedding configuration
|
|
1215
|
+
* @example
|
|
1216
|
+
* ```typescript
|
|
1217
|
+
* if (ObjectRegistry.hasEmbeddings('Article')) {
|
|
1218
|
+
* await article.generateEmbeddings();
|
|
1219
|
+
* }
|
|
1220
|
+
* ```
|
|
1221
|
+
*/
|
|
1222
|
+
static hasEmbeddings(className: string): boolean;
|
|
1223
|
+
/**
|
|
1224
|
+
* Get all registered classes that have embeddings enabled
|
|
1225
|
+
*
|
|
1226
|
+
* @returns Array of class names with embedding configuration
|
|
1227
|
+
* @example
|
|
1228
|
+
* ```typescript
|
|
1229
|
+
* const embeddableClasses = ObjectRegistry.getEmbeddingClasses();
|
|
1230
|
+
* // ['Article', 'Profile', 'Event']
|
|
1231
|
+
* ```
|
|
1232
|
+
*/
|
|
1233
|
+
static getEmbeddingClasses(): string[];
|
|
1234
|
+
/**
|
|
1235
|
+
* Get project-level embedding configuration
|
|
1236
|
+
*
|
|
1237
|
+
* Returns the global embedding settings from smrt.config (or defaults).
|
|
1238
|
+
* These settings apply to all classes unless overridden at the class level.
|
|
1239
|
+
*
|
|
1240
|
+
* @returns Project embedding configuration with defaults applied
|
|
1241
|
+
* @example
|
|
1242
|
+
* ```typescript
|
|
1243
|
+
* const projectConfig = ObjectRegistry.getProjectEmbeddingConfig();
|
|
1244
|
+
* // {
|
|
1245
|
+
* // dimensions: 768,
|
|
1246
|
+
* // provider: 'local',
|
|
1247
|
+
* // localModel: 'Xenova/bge-base-en-v1.5',
|
|
1248
|
+
* // aiModel: 'text-embedding-3-small',
|
|
1249
|
+
* // fallbackToAI: false
|
|
1250
|
+
* // }
|
|
1251
|
+
* ```
|
|
1252
|
+
*/
|
|
1253
|
+
static getProjectEmbeddingConfig(): ProjectEmbeddingConfig;
|
|
1254
|
+
/**
|
|
1255
|
+
* Resolve complete embedding configuration for a class
|
|
1256
|
+
*
|
|
1257
|
+
* Merges project-level config with class-level overrides.
|
|
1258
|
+
* Returns undefined if the class doesn't have embeddings enabled.
|
|
1259
|
+
*
|
|
1260
|
+
* @param className - Name of the class to resolve config for
|
|
1261
|
+
* @returns Fully resolved embedding config or undefined
|
|
1262
|
+
* @example
|
|
1263
|
+
* ```typescript
|
|
1264
|
+
* const config = ObjectRegistry.resolveEmbeddingConfig('Article');
|
|
1265
|
+
* // Merges project defaults with class-specific settings
|
|
1266
|
+
* // {
|
|
1267
|
+
* // fields: ['title', 'body'],
|
|
1268
|
+
* // dimensions: 768,
|
|
1269
|
+
* // provider: 'local',
|
|
1270
|
+
* // localModel: 'Xenova/bge-base-en-v1.5',
|
|
1271
|
+
* // autoGenerate: true,
|
|
1272
|
+
* // regenerateOnChange: true,
|
|
1273
|
+
* // ...
|
|
1274
|
+
* // }
|
|
1275
|
+
* ```
|
|
1276
|
+
*/
|
|
1277
|
+
static resolveEmbeddingConfig(className: string): ResolvedEmbeddingConfig | undefined;
|
|
1278
|
+
/**
|
|
1279
|
+
* Resolve the effective collection read-cache config for a class (issue #1498)
|
|
1280
|
+
*
|
|
1281
|
+
* Walks the inheritance chain nearest-first so an STI base class opt-in
|
|
1282
|
+
* covers its children, while a child can opt back out with `cache: false`.
|
|
1283
|
+
*
|
|
1284
|
+
* @param className - Simple or qualified class name
|
|
1285
|
+
* @returns Effective cache config, or undefined when caching is not opted in
|
|
1286
|
+
*/
|
|
1287
|
+
static resolveCollectionCacheConfig(className: string): CollectionCacheConfig | undefined;
|
|
1288
|
+
}
|
|
1289
|
+
/**
|
|
1290
|
+
* Registers a `SmrtObject` or `SmrtCollection` subclass with the global `ObjectRegistry`.
|
|
1291
|
+
*
|
|
1292
|
+
* This decorator is the primary entry point for the SMRT framework. Applying it to a class:
|
|
1293
|
+
*
|
|
1294
|
+
* 1. Captures the original class name before minification and stores it as the
|
|
1295
|
+
* `SMRT_TABLE_NAME` static property — ensuring table names are stable in production builds.
|
|
1296
|
+
* 2. Registers class metadata (fields, schema, config) in the singleton `ObjectRegistry`.
|
|
1297
|
+
* 3. Enables automatic code generation: REST API endpoints (`api`), CLI commands (`cli`),
|
|
1298
|
+
* and MCP server tools (`mcp`) are generated at build time from the registered config.
|
|
1299
|
+
* 4. Activates lifecycle hooks (`hooks.beforeSave`, `hooks.afterDelete`, etc.).
|
|
1300
|
+
* 5. Configures AI-callable methods exposed to `is()` / `do()` via function calling (`ai`).
|
|
1301
|
+
* 6. Enables automatic vector embedding generation (`embeddings`).
|
|
1302
|
+
*
|
|
1303
|
+
* Apply to `SmrtCollection` subclasses as well — the decorator uses `_itemClass` to
|
|
1304
|
+
* register the collection under the correct table name and creates a collection-to-table
|
|
1305
|
+
* lookup used by the CLI and introspection tools.
|
|
1306
|
+
*
|
|
1307
|
+
* For Single Table Inheritance (STI), set `tableStrategy: 'sti'` on the base class only.
|
|
1308
|
+
* Child classes inherit the strategy automatically.
|
|
1309
|
+
*
|
|
1310
|
+
* @param config - Optional configuration for the class. All fields are optional; defaults
|
|
1311
|
+
* are derived from the class name and framework conventions.
|
|
1312
|
+
* @returns A class decorator that registers the class and returns the original constructor
|
|
1313
|
+
*
|
|
1314
|
+
* @example
|
|
1315
|
+
* ```typescript
|
|
1316
|
+
* // Basic usage — convention-based defaults
|
|
1317
|
+
* @smrt()
|
|
1318
|
+
* class Product extends SmrtObject {
|
|
1319
|
+
* @field({ required: true })
|
|
1320
|
+
* name: string = '';
|
|
1321
|
+
* price: number = 0.0; // 0.0 → DECIMAL column
|
|
1322
|
+
* }
|
|
1323
|
+
*
|
|
1324
|
+
* // Paired collection (required for collection.create())
|
|
1325
|
+
* @smrt()
|
|
1326
|
+
* class Products extends SmrtCollection<Product> {
|
|
1327
|
+
* static readonly _itemClass = Product;
|
|
1328
|
+
* }
|
|
1329
|
+
*
|
|
1330
|
+
* // STI base class
|
|
1331
|
+
* @smrt({ tableStrategy: 'sti' })
|
|
1332
|
+
* class Content extends SmrtObject {
|
|
1333
|
+
* title: string = '';
|
|
1334
|
+
* }
|
|
1335
|
+
*
|
|
1336
|
+
* // STI child — inherits strategy, adds @meta() fields stored in _meta_data JSON
|
|
1337
|
+
* @smrt()
|
|
1338
|
+
* class Article extends Content {
|
|
1339
|
+
* @meta() wordCount: number = 0;
|
|
1340
|
+
* }
|
|
1341
|
+
*
|
|
1342
|
+
* // Restrict generated API surface
|
|
1343
|
+
* @smrt({ api: { exclude: ['delete'] }, mcp: true, cli: false })
|
|
1344
|
+
* class Invoice extends SmrtObject {}
|
|
1345
|
+
*
|
|
1346
|
+
* // Junction/upsert table with natural key
|
|
1347
|
+
* @smrt({ conflictColumns: ['event_id', 'profile_id'] })
|
|
1348
|
+
* class EventParticipant extends SmrtObject {
|
|
1349
|
+
* eventId: string = '';
|
|
1350
|
+
* profileId: string = '';
|
|
1351
|
+
* }
|
|
1352
|
+
* ```
|
|
1353
|
+
*
|
|
1354
|
+
* @see {@link SmartObjectConfig} for all available configuration options
|
|
1355
|
+
* @see {@link field} / {@link meta} / {@link foreignKey} for field decorators
|
|
1356
|
+
*/
|
|
1357
|
+
export declare function smrt(config?: SmartObjectConfig): <T extends abstract new (...args: any[]) => any>(ctor: T, decoratorContext?: ClassDecoratorContext<T>) => T;
|
|
1358
|
+
//# sourceMappingURL=registry.d.ts.map
|