@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
package/dist/errors.js
ADDED
|
@@ -0,0 +1,669 @@
|
|
|
1
|
+
import { createLogger } from "@happyvertical/logger";
|
|
2
|
+
const logger = createLogger({ level: "info" });
|
|
3
|
+
class SmrtError extends Error {
|
|
4
|
+
code;
|
|
5
|
+
category;
|
|
6
|
+
details;
|
|
7
|
+
cause;
|
|
8
|
+
constructor(message, code, category, details, cause) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = this.constructor.name;
|
|
11
|
+
this.code = code;
|
|
12
|
+
this.category = category;
|
|
13
|
+
this.details = details;
|
|
14
|
+
this.cause = cause;
|
|
15
|
+
if (Error.captureStackTrace) {
|
|
16
|
+
Error.captureStackTrace(this, this.constructor);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Converts error to a serializable object for logging/debugging
|
|
21
|
+
*/
|
|
22
|
+
toJSON() {
|
|
23
|
+
return {
|
|
24
|
+
name: this.name,
|
|
25
|
+
message: this.message,
|
|
26
|
+
code: this.code,
|
|
27
|
+
category: this.category,
|
|
28
|
+
details: this.details,
|
|
29
|
+
stack: this.stack,
|
|
30
|
+
cause: this.cause ? {
|
|
31
|
+
name: this.cause.name,
|
|
32
|
+
message: this.cause.message,
|
|
33
|
+
stack: this.cause.stack
|
|
34
|
+
} : void 0
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function collectErrorMessages(value, messages, visited, depth = 0) {
|
|
39
|
+
if (!value || visited.has(value) || depth > 10) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
visited.add(value);
|
|
43
|
+
if (typeof value === "string") {
|
|
44
|
+
const trimmed = value.trim();
|
|
45
|
+
if (trimmed) {
|
|
46
|
+
messages.push(trimmed);
|
|
47
|
+
}
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
if (!(value instanceof Error)) {
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
const message = value.message?.trim();
|
|
54
|
+
if (message) {
|
|
55
|
+
messages.push(message);
|
|
56
|
+
}
|
|
57
|
+
const errorWithContext = value;
|
|
58
|
+
collectErrorMessages(
|
|
59
|
+
errorWithContext.context?.originalError,
|
|
60
|
+
messages,
|
|
61
|
+
visited,
|
|
62
|
+
depth + 1
|
|
63
|
+
);
|
|
64
|
+
collectErrorMessages(errorWithContext.cause, messages, visited, depth + 1);
|
|
65
|
+
}
|
|
66
|
+
function getPrimaryCauseMessage(cause) {
|
|
67
|
+
if (!cause) {
|
|
68
|
+
return {};
|
|
69
|
+
}
|
|
70
|
+
const collected = [];
|
|
71
|
+
collectErrorMessages(cause, collected, /* @__PURE__ */ new Set());
|
|
72
|
+
const uniqueMessages = [...new Set(collected.filter(Boolean))];
|
|
73
|
+
if (uniqueMessages.length === 0) {
|
|
74
|
+
return {};
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
message: uniqueMessages[uniqueMessages.length - 1],
|
|
78
|
+
messages: uniqueMessages
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
class DatabaseError extends SmrtError {
|
|
82
|
+
constructor(message, code, details, cause) {
|
|
83
|
+
super(message, code, "database", details, cause);
|
|
84
|
+
}
|
|
85
|
+
static connectionFailed(dbUrl, cause) {
|
|
86
|
+
return new DatabaseError(
|
|
87
|
+
`Failed to connect to database: ${dbUrl}`,
|
|
88
|
+
"DB_CONNECTION_FAILED",
|
|
89
|
+
{ dbUrl },
|
|
90
|
+
cause
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
static queryFailed(query, cause) {
|
|
94
|
+
const causeInfo = getPrimaryCauseMessage(cause);
|
|
95
|
+
const causeMsg = causeInfo.message ? `
|
|
96
|
+
Cause: ${causeInfo.message}` : "";
|
|
97
|
+
return new DatabaseError(
|
|
98
|
+
`Database query failed: ${query.substring(0, 100)}${query.length > 100 ? "..." : ""}${causeMsg}`,
|
|
99
|
+
"DB_QUERY_FAILED",
|
|
100
|
+
{
|
|
101
|
+
query,
|
|
102
|
+
causeMessage: causeInfo.message,
|
|
103
|
+
causeMessages: causeInfo.messages
|
|
104
|
+
},
|
|
105
|
+
cause
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
static schemaError(tableName, operation, cause) {
|
|
109
|
+
return new DatabaseError(
|
|
110
|
+
`Schema operation failed for table '${tableName}': ${operation}`,
|
|
111
|
+
"DB_SCHEMA_ERROR",
|
|
112
|
+
{ tableName, operation },
|
|
113
|
+
cause
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
static constraintViolation(constraint, value, cause) {
|
|
117
|
+
return new DatabaseError(
|
|
118
|
+
`Database constraint violation: ${constraint}`,
|
|
119
|
+
"DB_CONSTRAINT_VIOLATION",
|
|
120
|
+
{ constraint, value },
|
|
121
|
+
cause
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
static corruptedData(fieldName, className, cause) {
|
|
125
|
+
return new DatabaseError(
|
|
126
|
+
`Corrupted data in field '${fieldName}' for ${className}. The data cannot be parsed or is malformed. This may indicate database corruption or incompatible schema changes.`,
|
|
127
|
+
"DB_CORRUPTED_DATA",
|
|
128
|
+
{ fieldName, className },
|
|
129
|
+
cause
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
static missingDiscriminator(className, rowId) {
|
|
133
|
+
return new DatabaseError(
|
|
134
|
+
`Missing discriminator (_meta_type) for STI class ${className}${rowId ? ` (row id: ${rowId})` : ""}. STI classes require a discriminator column to determine the correct subclass. This may indicate a schema mismatch or manual database modification.`,
|
|
135
|
+
"DB_MISSING_DISCRIMINATOR",
|
|
136
|
+
{ className, rowId }
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
static stiDiscriminatorConflict(details) {
|
|
140
|
+
const identityText = Object.entries(details.conflictIdentity).map(([key, value]) => `${key} '${String(value)}'`).join(", ");
|
|
141
|
+
return new DatabaseError(
|
|
142
|
+
`Legacy STI discriminator collision for ${details.className} (${details.tableName}). Row '${details.id}' would upgrade _meta_type from '${details.legacyMetaType}' to '${details.qualifiedMetaType}', but row '${details.duplicateId}' already uses the qualified discriminator for ${identityText || "the same conflict identity"}. Merge or remove the duplicate legacy/qualified rows before saving.`,
|
|
143
|
+
"DB_STI_DISCRIMINATOR_CONFLICT",
|
|
144
|
+
details
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
static schemaMissing(tableName, className) {
|
|
148
|
+
return new DatabaseError(
|
|
149
|
+
`Table '${tableName}' does not exist for class '${className}'. Run 'smrt db:migrate' to create database schema.`,
|
|
150
|
+
"DB_SCHEMA_MISSING",
|
|
151
|
+
{ tableName, className }
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
class AIError extends SmrtError {
|
|
156
|
+
constructor(message, code, details, cause) {
|
|
157
|
+
super(message, code, "ai", details, cause);
|
|
158
|
+
}
|
|
159
|
+
static providerError(provider, operation, cause) {
|
|
160
|
+
return new AIError(
|
|
161
|
+
`AI provider '${provider}' failed during ${operation}`,
|
|
162
|
+
"AI_PROVIDER_ERROR",
|
|
163
|
+
{ provider, operation },
|
|
164
|
+
cause
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
static rateLimitExceeded(provider, retryAfter) {
|
|
168
|
+
return new AIError(
|
|
169
|
+
`AI provider '${provider}' rate limit exceeded`,
|
|
170
|
+
"AI_RATE_LIMIT",
|
|
171
|
+
{ provider, retryAfter }
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
static invalidResponse(provider, response) {
|
|
175
|
+
return new AIError(
|
|
176
|
+
`AI provider '${provider}' returned invalid response`,
|
|
177
|
+
"AI_INVALID_RESPONSE",
|
|
178
|
+
{ provider, response }
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
static authenticationFailed(provider) {
|
|
182
|
+
return new AIError(
|
|
183
|
+
`AI provider '${provider}' authentication failed`,
|
|
184
|
+
"AI_AUTH_FAILED",
|
|
185
|
+
{ provider }
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
class FilesystemError extends SmrtError {
|
|
190
|
+
constructor(message, code, details, cause) {
|
|
191
|
+
super(message, code, "filesystem", details, cause);
|
|
192
|
+
}
|
|
193
|
+
static fileNotFound(path) {
|
|
194
|
+
return new FilesystemError(`File not found: ${path}`, "FS_FILE_NOT_FOUND", {
|
|
195
|
+
path
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
static permissionDenied(path, operation) {
|
|
199
|
+
return new FilesystemError(
|
|
200
|
+
`Permission denied for ${operation} on: ${path}`,
|
|
201
|
+
"FS_PERMISSION_DENIED",
|
|
202
|
+
{ path, operation }
|
|
203
|
+
);
|
|
204
|
+
}
|
|
205
|
+
static diskSpaceExceeded(path, requiredBytes) {
|
|
206
|
+
return new FilesystemError(
|
|
207
|
+
`Insufficient disk space for operation on: ${path}`,
|
|
208
|
+
"FS_DISK_SPACE_EXCEEDED",
|
|
209
|
+
{ path, requiredBytes }
|
|
210
|
+
);
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
class ValidationError extends SmrtError {
|
|
214
|
+
constructor(message, code, details, cause) {
|
|
215
|
+
super(message, code, "validation", details, cause);
|
|
216
|
+
}
|
|
217
|
+
static requiredField(fieldName, objectType) {
|
|
218
|
+
return new ValidationError(
|
|
219
|
+
`Required field '${fieldName}' is missing for ${objectType}`,
|
|
220
|
+
"VALIDATION_REQUIRED_FIELD",
|
|
221
|
+
{ fieldName, objectType }
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
static invalidValue(fieldName, value, expectedType) {
|
|
225
|
+
return new ValidationError(
|
|
226
|
+
`Invalid value for field '${fieldName}': expected ${expectedType}, got ${typeof value}`,
|
|
227
|
+
"VALIDATION_INVALID_VALUE",
|
|
228
|
+
{ fieldName, value, expectedType }
|
|
229
|
+
);
|
|
230
|
+
}
|
|
231
|
+
static uniqueConstraint(fieldName, value) {
|
|
232
|
+
return new ValidationError(
|
|
233
|
+
`Unique constraint violation for field '${fieldName}' with value: ${value}`,
|
|
234
|
+
"VALIDATION_UNIQUE_CONSTRAINT",
|
|
235
|
+
{ fieldName, value }
|
|
236
|
+
);
|
|
237
|
+
}
|
|
238
|
+
static rangeError(fieldName, value, min, max) {
|
|
239
|
+
const range = min !== void 0 && max !== void 0 ? `between ${min} and ${max}` : min !== void 0 ? `>= ${min}` : `<= ${max}`;
|
|
240
|
+
return new ValidationError(
|
|
241
|
+
`Value for field '${fieldName}' must be ${range}, got: ${value}`,
|
|
242
|
+
"VALIDATION_RANGE_ERROR",
|
|
243
|
+
{ fieldName, value, min, max }
|
|
244
|
+
);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
class NetworkError extends SmrtError {
|
|
248
|
+
constructor(message, code, details, cause) {
|
|
249
|
+
super(message, code, "network", details, cause);
|
|
250
|
+
}
|
|
251
|
+
static requestFailed(url, status, responseBody) {
|
|
252
|
+
const cause = responseBody instanceof Error ? responseBody : void 0;
|
|
253
|
+
const body = typeof responseBody === "string" ? responseBody : void 0;
|
|
254
|
+
return new NetworkError(
|
|
255
|
+
`Network request failed: ${url}${status ? ` (Status: ${status})` : ""}${body ? ` - ${body.substring(0, 200)}` : ""}`,
|
|
256
|
+
"NETWORK_REQUEST_FAILED",
|
|
257
|
+
{ url, status, responseBody: body },
|
|
258
|
+
cause
|
|
259
|
+
);
|
|
260
|
+
}
|
|
261
|
+
static timeout(url, timeoutMs) {
|
|
262
|
+
return new NetworkError(
|
|
263
|
+
`Network request timed out after ${timeoutMs}ms: ${url}`,
|
|
264
|
+
"NETWORK_TIMEOUT",
|
|
265
|
+
{ url, timeoutMs }
|
|
266
|
+
);
|
|
267
|
+
}
|
|
268
|
+
static serviceUnavailable(service, reason) {
|
|
269
|
+
return new NetworkError(
|
|
270
|
+
reason ? `External service unavailable: ${service} - ${reason}` : `External service unavailable: ${service}`,
|
|
271
|
+
"NETWORK_SERVICE_UNAVAILABLE",
|
|
272
|
+
{ service, reason }
|
|
273
|
+
);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
class ConfigurationError extends SmrtError {
|
|
277
|
+
constructor(message, code, details, cause) {
|
|
278
|
+
super(message, code, "configuration", details, cause);
|
|
279
|
+
}
|
|
280
|
+
static missingConfiguration(configKey, context) {
|
|
281
|
+
return new ConfigurationError(
|
|
282
|
+
`Missing required configuration: ${configKey}${context ? ` in ${context}` : ""}`,
|
|
283
|
+
"CONFIG_MISSING",
|
|
284
|
+
{ configKey, context }
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
static invalidConfiguration(configKey, value, expected) {
|
|
288
|
+
return new ConfigurationError(
|
|
289
|
+
`Invalid configuration for ${configKey}: expected ${expected}, got ${typeof value}`,
|
|
290
|
+
"CONFIG_INVALID",
|
|
291
|
+
{ configKey, value, expected }
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
static initializationFailed(component, cause) {
|
|
295
|
+
return new ConfigurationError(
|
|
296
|
+
`Failed to initialize component: ${component}`,
|
|
297
|
+
"CONFIG_INIT_FAILED",
|
|
298
|
+
{ component },
|
|
299
|
+
cause
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
static circularInheritance(className, inheritanceChain) {
|
|
303
|
+
return new ConfigurationError(
|
|
304
|
+
`Circular inheritance detected for class '${className}'. Inheritance chain: ${inheritanceChain.join(" → ")} → ${className}. Classes cannot inherit from themselves directly or indirectly.`,
|
|
305
|
+
"CONFIG_CIRCULAR_INHERITANCE",
|
|
306
|
+
{ className, inheritanceChain }
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
static incompatibleStrategy(className, classStrategy, parentClass, parentStrategy) {
|
|
310
|
+
return new ConfigurationError(
|
|
311
|
+
`Incompatible table strategy for class '${className}' (${classStrategy}). Parent class '${parentClass}' uses ${parentStrategy} strategy. Child classes must use the same table strategy as their parent. Either change ${className} to use ${parentStrategy}, or remove the inheritance.`,
|
|
312
|
+
"CONFIG_INCOMPATIBLE_STRATEGY",
|
|
313
|
+
{ className, classStrategy, parentClass, parentStrategy }
|
|
314
|
+
);
|
|
315
|
+
}
|
|
316
|
+
static unregisteredBaseClass(childClass, baseClass) {
|
|
317
|
+
return new ConfigurationError(
|
|
318
|
+
`STI base class '${baseClass}' is not registered for child class '${childClass}'. When using Single Table Inheritance, the base class must be registered before any child classes. Ensure ${baseClass} is decorated with @smrt({ tableStrategy: 'sti' }) and imported before ${childClass}.`,
|
|
319
|
+
"CONFIG_UNREGISTERED_BASE",
|
|
320
|
+
{ childClass, baseClass }
|
|
321
|
+
);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
class RuntimeError extends SmrtError {
|
|
325
|
+
constructor(message, code, details, cause) {
|
|
326
|
+
super(message, code, "runtime", details, cause);
|
|
327
|
+
}
|
|
328
|
+
static operationFailed(operation, context, cause) {
|
|
329
|
+
return new RuntimeError(
|
|
330
|
+
`Operation failed: ${operation}${context ? ` in ${context}` : ""}`,
|
|
331
|
+
"RUNTIME_OPERATION_FAILED",
|
|
332
|
+
{ operation, context },
|
|
333
|
+
cause
|
|
334
|
+
);
|
|
335
|
+
}
|
|
336
|
+
static invalidState(message, context) {
|
|
337
|
+
return new RuntimeError(message, "RUNTIME_INVALID_STATE", context);
|
|
338
|
+
}
|
|
339
|
+
static resourceExhausted(resource, limit) {
|
|
340
|
+
return new RuntimeError(
|
|
341
|
+
`Resource exhausted: ${resource} exceeded limit of ${limit}`,
|
|
342
|
+
"RUNTIME_RESOURCE_EXHAUSTED",
|
|
343
|
+
{ resource, limit }
|
|
344
|
+
);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
class TenantIsolationError extends SmrtError {
|
|
348
|
+
/** The tenant ID of the object that owns the relationship. */
|
|
349
|
+
tenantId;
|
|
350
|
+
/** The tenant ID of the related object that was reached (and rejected). */
|
|
351
|
+
attemptedTenantId;
|
|
352
|
+
constructor(message, details, cause) {
|
|
353
|
+
super(message, "TENANT_ISOLATION_VIOLATION", "validation", details, cause);
|
|
354
|
+
this.tenantId = details?.tenantId;
|
|
355
|
+
this.attemptedTenantId = details?.attemptedTenantId;
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Builds a {@link TenantIsolationError} for a blocked cross-tenant
|
|
359
|
+
* relationship resolution, with a descriptive message and structured details.
|
|
360
|
+
*/
|
|
361
|
+
static crossTenantReference(details) {
|
|
362
|
+
const target = details.targetClass ? `${details.targetClass} (tenant '${details.targetTenantId}')` : `tenant '${details.targetTenantId}'`;
|
|
363
|
+
return new TenantIsolationError(
|
|
364
|
+
`Cross-tenant relationship access blocked on ${details.sourceClass}.${details.fieldName}: owning tenant '${details.sourceTenantId}' does not match ${target}. Pass { allowCrossTenant: true } to loadRelated()/loadRelatedMany()/getRelated() to override.`,
|
|
365
|
+
{
|
|
366
|
+
tenantId: details.sourceTenantId,
|
|
367
|
+
attemptedTenantId: details.targetTenantId,
|
|
368
|
+
sourceClass: details.sourceClass,
|
|
369
|
+
fieldName: details.fieldName,
|
|
370
|
+
targetClass: details.targetClass
|
|
371
|
+
}
|
|
372
|
+
);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
class ErrorUtils {
|
|
376
|
+
/**
|
|
377
|
+
* Wraps a function with error handling and automatic retry logic
|
|
378
|
+
*/
|
|
379
|
+
static async withRetry(operation, maxRetries = 3, delay = 1e3, backoffMultiplier = 2) {
|
|
380
|
+
let lastError = new Error("Operation failed without error details");
|
|
381
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
382
|
+
try {
|
|
383
|
+
return await operation();
|
|
384
|
+
} catch (error) {
|
|
385
|
+
lastError = error instanceof Error ? error : new Error(String(error));
|
|
386
|
+
if (attempt === maxRetries) {
|
|
387
|
+
throw lastError;
|
|
388
|
+
}
|
|
389
|
+
if (error instanceof ValidationError || error instanceof ConfigurationError || error instanceof TenantIsolationError) {
|
|
390
|
+
throw error;
|
|
391
|
+
}
|
|
392
|
+
try {
|
|
393
|
+
await new Promise((resolve) => {
|
|
394
|
+
setTimeout(() => resolve(), delay * backoffMultiplier ** attempt);
|
|
395
|
+
});
|
|
396
|
+
} catch (timerError) {
|
|
397
|
+
logger.error("Timer error during retry", { error: timerError });
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
throw lastError;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Checks if an error is retryable
|
|
405
|
+
*/
|
|
406
|
+
static isRetryable(error) {
|
|
407
|
+
if (error instanceof SmrtError) {
|
|
408
|
+
return error.category === "network" || error.category === "ai";
|
|
409
|
+
}
|
|
410
|
+
const retryablePatterns = [
|
|
411
|
+
/ECONNRESET/,
|
|
412
|
+
/ETIMEDOUT/,
|
|
413
|
+
/ENOTFOUND/,
|
|
414
|
+
/rate.?limit/i,
|
|
415
|
+
/timeout/i,
|
|
416
|
+
/503/,
|
|
417
|
+
/502/,
|
|
418
|
+
/500/
|
|
419
|
+
];
|
|
420
|
+
return retryablePatterns.some((pattern) => pattern.test(error.message));
|
|
421
|
+
}
|
|
422
|
+
/**
|
|
423
|
+
* Sanitizes an error for safe logging (removes sensitive information)
|
|
424
|
+
*/
|
|
425
|
+
static sanitizeError(error) {
|
|
426
|
+
const sanitized = {
|
|
427
|
+
name: error.name,
|
|
428
|
+
message: error.message,
|
|
429
|
+
stack: error.stack
|
|
430
|
+
};
|
|
431
|
+
if (error instanceof SmrtError) {
|
|
432
|
+
sanitized.code = error.code;
|
|
433
|
+
sanitized.category = error.category;
|
|
434
|
+
if (error.details) {
|
|
435
|
+
sanitized.details = { ...error.details };
|
|
436
|
+
const sensitiveFields = [
|
|
437
|
+
"password",
|
|
438
|
+
"token",
|
|
439
|
+
"key",
|
|
440
|
+
"secret",
|
|
441
|
+
"apiKey"
|
|
442
|
+
];
|
|
443
|
+
for (const field of sensitiveFields) {
|
|
444
|
+
if (sanitized.details[field]) {
|
|
445
|
+
sanitized.details[field] = "[REDACTED]";
|
|
446
|
+
}
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
}
|
|
450
|
+
return sanitized;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
class ValidationReport {
|
|
454
|
+
errors = [];
|
|
455
|
+
objectType;
|
|
456
|
+
constructor(objectType) {
|
|
457
|
+
this.objectType = objectType;
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Add a validation error to the report
|
|
461
|
+
*/
|
|
462
|
+
addError(error) {
|
|
463
|
+
this.errors.push(error);
|
|
464
|
+
}
|
|
465
|
+
/**
|
|
466
|
+
* Check if there are any validation errors
|
|
467
|
+
*/
|
|
468
|
+
hasErrors() {
|
|
469
|
+
return this.errors.length > 0;
|
|
470
|
+
}
|
|
471
|
+
/**
|
|
472
|
+
* Get all validation errors
|
|
473
|
+
*/
|
|
474
|
+
getErrors() {
|
|
475
|
+
return [...this.errors];
|
|
476
|
+
}
|
|
477
|
+
/**
|
|
478
|
+
* Get the number of validation errors
|
|
479
|
+
*/
|
|
480
|
+
getErrorCount() {
|
|
481
|
+
return this.errors.length;
|
|
482
|
+
}
|
|
483
|
+
/**
|
|
484
|
+
* Convert to a human-readable string
|
|
485
|
+
*/
|
|
486
|
+
toString() {
|
|
487
|
+
if (this.errors.length === 0) {
|
|
488
|
+
return `Validation passed for ${this.objectType}`;
|
|
489
|
+
}
|
|
490
|
+
const errorList = this.errors.map((err, idx) => ` ${idx + 1}. ${err.message}`).join("\n");
|
|
491
|
+
return `Validation failed for ${this.objectType} with ${this.errors.length} error(s):
|
|
492
|
+
${errorList}`;
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Convert to JSON format
|
|
496
|
+
*/
|
|
497
|
+
toJSON() {
|
|
498
|
+
return {
|
|
499
|
+
objectType: this.objectType,
|
|
500
|
+
errorCount: this.errors.length,
|
|
501
|
+
errors: this.errors.map((err) => err.toJSON())
|
|
502
|
+
};
|
|
503
|
+
}
|
|
504
|
+
/**
|
|
505
|
+
* Throw the first error if there are any errors
|
|
506
|
+
*/
|
|
507
|
+
throwIfErrors() {
|
|
508
|
+
if (this.errors.length > 0) {
|
|
509
|
+
throw this.errors[0];
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
/**
|
|
513
|
+
* Clear all errors
|
|
514
|
+
*/
|
|
515
|
+
clear() {
|
|
516
|
+
this.errors = [];
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
class ValidationUtils {
|
|
520
|
+
/**
|
|
521
|
+
* Validate a single field value
|
|
522
|
+
*
|
|
523
|
+
* @param fieldName - Name of the field
|
|
524
|
+
* @param value - Value to validate
|
|
525
|
+
* @param options - Validation options (required, min, max, etc.)
|
|
526
|
+
* @returns ValidationError if validation fails, null otherwise
|
|
527
|
+
*/
|
|
528
|
+
static async validateField(fieldName, value, options, objectType = "Object") {
|
|
529
|
+
if (options.required && (value === null || value === void 0 || value === "")) {
|
|
530
|
+
return ValidationError.requiredField(fieldName, objectType);
|
|
531
|
+
}
|
|
532
|
+
if (value === null || value === void 0) {
|
|
533
|
+
return null;
|
|
534
|
+
}
|
|
535
|
+
if (typeof value === "number") {
|
|
536
|
+
if (options.min !== void 0 && value < options.min) {
|
|
537
|
+
return ValidationError.rangeError(
|
|
538
|
+
fieldName,
|
|
539
|
+
value,
|
|
540
|
+
options.min,
|
|
541
|
+
options.max
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
if (options.max !== void 0 && value > options.max) {
|
|
545
|
+
return ValidationError.rangeError(
|
|
546
|
+
fieldName,
|
|
547
|
+
value,
|
|
548
|
+
options.min,
|
|
549
|
+
options.max
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
if (typeof value === "string") {
|
|
554
|
+
if (options.minLength !== void 0 && value.length < options.minLength) {
|
|
555
|
+
return ValidationError.invalidValue(
|
|
556
|
+
fieldName,
|
|
557
|
+
value,
|
|
558
|
+
`string with minimum length ${options.minLength}`
|
|
559
|
+
);
|
|
560
|
+
}
|
|
561
|
+
if (options.maxLength !== void 0 && value.length > options.maxLength) {
|
|
562
|
+
return ValidationError.invalidValue(
|
|
563
|
+
fieldName,
|
|
564
|
+
value,
|
|
565
|
+
`string with maximum length ${options.maxLength}`
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
if (options.pattern) {
|
|
569
|
+
const regex = typeof options.pattern === "string" ? new RegExp(options.pattern) : options.pattern;
|
|
570
|
+
if (!regex.test(value)) {
|
|
571
|
+
return ValidationError.invalidValue(
|
|
572
|
+
fieldName,
|
|
573
|
+
value,
|
|
574
|
+
`string matching pattern ${options.pattern}`
|
|
575
|
+
);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
if (options.customValidator) {
|
|
580
|
+
try {
|
|
581
|
+
const isValid = await options.customValidator(value);
|
|
582
|
+
if (!isValid) {
|
|
583
|
+
return ValidationError.invalidValue(
|
|
584
|
+
fieldName,
|
|
585
|
+
value,
|
|
586
|
+
options.customMessage || "custom validation failed"
|
|
587
|
+
);
|
|
588
|
+
}
|
|
589
|
+
} catch (error) {
|
|
590
|
+
return ValidationError.invalidValue(
|
|
591
|
+
fieldName,
|
|
592
|
+
value,
|
|
593
|
+
`custom validation error: ${error instanceof Error ? error.message : String(error)}`
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
}
|
|
597
|
+
return null;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* Validate required field
|
|
601
|
+
*/
|
|
602
|
+
static validateRequired(fieldName, value, objectType = "Object") {
|
|
603
|
+
if (value === null || value === void 0 || value === "") {
|
|
604
|
+
return ValidationError.requiredField(fieldName, objectType);
|
|
605
|
+
}
|
|
606
|
+
return null;
|
|
607
|
+
}
|
|
608
|
+
/**
|
|
609
|
+
* Validate numeric range
|
|
610
|
+
*/
|
|
611
|
+
static validateRange(fieldName, value, min, max) {
|
|
612
|
+
if (min !== void 0 && value < min) {
|
|
613
|
+
return ValidationError.rangeError(fieldName, value, min, max);
|
|
614
|
+
}
|
|
615
|
+
if (max !== void 0 && value > max) {
|
|
616
|
+
return ValidationError.rangeError(fieldName, value, min, max);
|
|
617
|
+
}
|
|
618
|
+
return null;
|
|
619
|
+
}
|
|
620
|
+
/**
|
|
621
|
+
* Validate string length
|
|
622
|
+
*/
|
|
623
|
+
static validateLength(fieldName, value, minLength, maxLength) {
|
|
624
|
+
if (minLength !== void 0 && value.length < minLength) {
|
|
625
|
+
return ValidationError.invalidValue(
|
|
626
|
+
fieldName,
|
|
627
|
+
value,
|
|
628
|
+
`string with minimum length ${minLength}`
|
|
629
|
+
);
|
|
630
|
+
}
|
|
631
|
+
if (maxLength !== void 0 && value.length > maxLength) {
|
|
632
|
+
return ValidationError.invalidValue(
|
|
633
|
+
fieldName,
|
|
634
|
+
value,
|
|
635
|
+
`string with maximum length ${maxLength}`
|
|
636
|
+
);
|
|
637
|
+
}
|
|
638
|
+
return null;
|
|
639
|
+
}
|
|
640
|
+
/**
|
|
641
|
+
* Validate string pattern
|
|
642
|
+
*/
|
|
643
|
+
static validatePattern(fieldName, value, pattern) {
|
|
644
|
+
const regex = typeof pattern === "string" ? new RegExp(pattern) : pattern;
|
|
645
|
+
if (!regex.test(value)) {
|
|
646
|
+
return ValidationError.invalidValue(
|
|
647
|
+
fieldName,
|
|
648
|
+
value,
|
|
649
|
+
`string matching pattern ${pattern}`
|
|
650
|
+
);
|
|
651
|
+
}
|
|
652
|
+
return null;
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
export {
|
|
656
|
+
AIError,
|
|
657
|
+
ConfigurationError,
|
|
658
|
+
DatabaseError,
|
|
659
|
+
ErrorUtils,
|
|
660
|
+
FilesystemError,
|
|
661
|
+
NetworkError,
|
|
662
|
+
RuntimeError,
|
|
663
|
+
SmrtError,
|
|
664
|
+
TenantIsolationError,
|
|
665
|
+
ValidationError,
|
|
666
|
+
ValidationReport,
|
|
667
|
+
ValidationUtils
|
|
668
|
+
};
|
|
669
|
+
//# sourceMappingURL=errors.js.map
|