@happyvertical/smrt-core 0.49.3 → 0.49.5
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/README.md +20 -0
- package/agents/change-feed.md +19 -0
- package/agents/collection-reads.md +21 -0
- package/agents/generators.md +5 -0
- package/agents/memory.md +23 -3
- package/agents/null-equal-indexes.md +88 -0
- package/agents/object-runtime.md +85 -0
- package/agents/schema-paths.md +7 -7
- package/dist/browser.js +2 -2
- package/dist/cascade.d.ts.map +1 -1
- package/dist/cascade.js +13 -10
- package/dist/cascade.js.map +1 -1
- package/dist/change-feed.d.ts +22 -0
- package/dist/change-feed.d.ts.map +1 -1
- package/dist/change-feed.js +147 -6
- package/dist/change-feed.js.map +1 -1
- package/dist/class.js +1 -1
- package/dist/collection-cache.d.ts +10 -1
- package/dist/collection-cache.d.ts.map +1 -1
- package/dist/collection-cache.js +65 -10
- package/dist/collection-cache.js.map +1 -1
- package/dist/collection.d.ts +69 -2
- package/dist/collection.d.ts.map +1 -1
- package/dist/collection.js +142 -9
- package/dist/collection.js.map +1 -1
- package/dist/consumer-plugin/artifact-publication.d.ts +27 -0
- package/dist/consumer-plugin/artifact-publication.d.ts.map +1 -0
- package/dist/consumer-plugin/artifact-publication.js +80 -0
- package/dist/consumer-plugin/artifact-publication.js.map +1 -0
- package/dist/consumer-plugin/index.d.ts.map +1 -1
- package/dist/consumer-plugin/index.js +44 -6
- package/dist/consumer-plugin/index.js.map +1 -1
- package/dist/db-errors.js +1 -1
- package/dist/db-errors.js.map +1 -1
- package/dist/embedded-write-queue.d.ts +1 -1
- package/dist/embedded-write-queue.d.ts.map +1 -1
- package/dist/embedded-write-queue.js +16 -6
- package/dist/embedded-write-queue.js.map +1 -1
- package/dist/embeddings/storage.d.ts +16 -0
- package/dist/embeddings/storage.d.ts.map +1 -1
- package/dist/embeddings/storage.js +40 -0
- package/dist/embeddings/storage.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/interceptors.d.ts +22 -0
- package/dist/interceptors.d.ts.map +1 -1
- package/dist/interceptors.js +12 -0
- package/dist/interceptors.js.map +1 -1
- package/dist/junction.d.ts +12 -3
- package/dist/junction.d.ts.map +1 -1
- package/dist/junction.js +34 -4
- package/dist/junction.js.map +1 -1
- package/dist/knowledge-config.d.ts +6 -0
- package/dist/knowledge-config.d.ts.map +1 -0
- package/dist/knowledge-config.js +48 -0
- package/dist/knowledge-config.js.map +1 -0
- package/dist/manifest/static-manifest.d.ts.map +1 -1
- package/dist/manifest/static-manifest.js +91 -1
- package/dist/manifest/static-manifest.js.map +1 -1
- package/dist/manifest/store.js +1 -1
- package/dist/manifest/store.js.map +1 -1
- package/dist/manifest.json +104 -1
- package/dist/migrations/differ.d.ts.map +1 -1
- package/dist/migrations/differ.js +2 -0
- package/dist/migrations/differ.js.map +1 -1
- package/dist/migrations/generator.d.ts.map +1 -1
- package/dist/migrations/generator.js +2 -0
- package/dist/migrations/generator.js.map +1 -1
- package/dist/migrations/index.d.ts +1 -0
- package/dist/migrations/index.d.ts.map +1 -1
- package/dist/migrations/index.js +2 -1
- package/dist/migrations/null-equal-indexes.d.ts +37 -0
- package/dist/migrations/null-equal-indexes.d.ts.map +1 -0
- package/dist/migrations/null-equal-indexes.js +133 -0
- package/dist/migrations/null-equal-indexes.js.map +1 -0
- package/dist/migrations/tracker.d.ts.map +1 -1
- package/dist/migrations/tracker.js +6 -0
- package/dist/migrations/tracker.js.map +1 -1
- package/dist/migrations.js +2 -1
- package/dist/object.d.ts +33 -0
- package/dist/object.d.ts.map +1 -1
- package/dist/object.js +316 -46
- package/dist/object.js.map +1 -1
- package/dist/plain-json.d.ts +6 -0
- package/dist/plain-json.d.ts.map +1 -0
- package/dist/plain-json.js +41 -0
- package/dist/plain-json.js.map +1 -0
- package/dist/postgres-permissions.d.ts.map +1 -1
- package/dist/postgres-permissions.js +6 -2
- package/dist/postgres-permissions.js.map +1 -1
- package/dist/prebuild/index.d.ts.map +1 -1
- package/dist/prebuild/index.js +3 -3
- package/dist/prebuild/index.js.map +1 -1
- package/dist/registry/class-registration.d.ts.map +1 -1
- package/dist/registry/class-registration.js +4 -1
- package/dist/registry/class-registration.js.map +1 -1
- package/dist/registry/schema-builder.d.ts.map +1 -1
- package/dist/registry/schema-builder.js +4 -3
- package/dist/registry/schema-builder.js.map +1 -1
- package/dist/registry/validator.d.ts +1 -0
- package/dist/registry/validator.d.ts.map +1 -1
- package/dist/registry/validator.js +8 -1
- package/dist/registry/validator.js.map +1 -1
- package/dist/registry.js +1 -1
- package/dist/scanner/manifest-generator.d.ts.map +1 -1
- package/dist/scanner/manifest-generator.js +21 -0
- package/dist/scanner/manifest-generator.js.map +1 -1
- package/dist/scanner/types.d.ts +2 -0
- package/dist/scanner/types.d.ts.map +1 -1
- package/dist/scanner/types.js.map +1 -1
- package/dist/schema/conflict-target.d.ts +8 -2
- package/dist/schema/conflict-target.d.ts.map +1 -1
- package/dist/schema/conflict-target.js +11 -3
- package/dist/schema/conflict-target.js.map +1 -1
- package/dist/schema/ddl/null-equal-index.d.ts +5 -0
- package/dist/schema/ddl/null-equal-index.d.ts.map +1 -0
- package/dist/schema/ddl/null-equal-index.js +17 -0
- package/dist/schema/ddl/null-equal-index.js.map +1 -0
- package/dist/schema/ddl/postgres-strategy.d.ts +2 -1
- package/dist/schema/ddl/postgres-strategy.d.ts.map +1 -1
- package/dist/schema/ddl/postgres-strategy.js +7 -0
- package/dist/schema/ddl/postgres-strategy.js.map +1 -1
- package/dist/schema/generator.d.ts.map +1 -1
- package/dist/schema/generator.js +8 -3
- package/dist/schema/generator.js.map +1 -1
- package/dist/schema/manifest-schema.d.ts +2 -1
- package/dist/schema/manifest-schema.d.ts.map +1 -1
- package/dist/schema/manifest-schema.js +12 -4
- package/dist/schema/manifest-schema.js.map +1 -1
- package/dist/schema/schema-manager.d.ts.map +1 -1
- package/dist/schema/schema-manager.js +1 -1
- package/dist/schema/schema-manager.js.map +1 -1
- package/dist/schema/types.d.ts +2 -0
- package/dist/schema/types.d.ts.map +1 -1
- package/dist/scripts/browser-plain-json-regression.mjs +85 -0
- package/dist/smrt-knowledge.json +73 -15
- package/dist/system/schema.d.ts +14 -3
- package/dist/system/schema.d.ts.map +1 -1
- package/dist/system/schema.js +120 -2
- package/dist/system/schema.js.map +1 -1
- package/dist/vite-plugin/api-client-entries.d.ts.map +1 -1
- package/dist/vite-plugin/api-client-entries.js +9 -7
- package/dist/vite-plugin/api-client-entries.js.map +1 -1
- package/dist/vite-plugin/index.d.ts +24 -0
- package/dist/vite-plugin/index.d.ts.map +1 -1
- package/dist/vite-plugin/index.js +48 -115
- package/dist/vite-plugin/index.js.map +1 -1
- package/dist/vite-plugin/sveltekit-generator.d.ts.map +1 -1
- package/dist/vite-plugin/sveltekit-generator.js +2 -2
- package/dist/vite-plugin/sveltekit-generator.js.map +1 -1
- package/dist/vite-plugin/web-collections.d.ts +18 -0
- package/dist/vite-plugin/web-collections.d.ts.map +1 -1
- package/dist/vite-plugin/web-collections.js +55 -2
- package/dist/vite-plugin/web-collections.js.map +1 -1
- package/package.json +5 -4
package/dist/scanner/types.d.ts
CHANGED
|
@@ -226,6 +226,8 @@ export interface ManifestIndexDefinition {
|
|
|
226
226
|
name: string;
|
|
227
227
|
columns: string[];
|
|
228
228
|
unique?: boolean;
|
|
229
|
+
/** SMRT-owned nullable upsert identity; PostgreSQL 15+ uses NULLS NOT DISTINCT. */
|
|
230
|
+
nullsNotDistinct?: boolean;
|
|
229
231
|
where?: string;
|
|
230
232
|
/**
|
|
231
233
|
* Expression-based index target — when set, the DDL strategy renders the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/scanner/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC;AAExD;;;GAGG;AACH,MAAM,MAAM,kBAAkB,G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,MAAM,WAAW,WAAW;IAC1B,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;CACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","names":[],"sources":["../../src/scanner/types.ts"],"sourcesContent":["/**\n * Type definitions for AST scanning and manifest generation\n */\n\nimport type { SmartObjectConfig } from '../registry.js';\n\n/**\n * Qualified class name in format \"@package/name:ClassName\"\n * Example: \"@happyvertical/smrt-core:Product\"\n */\nexport type QualifiedClassName = `${string}:${string}`;\n\n/**\n * Static per-field UI hints authored via `@field({ ui })` (#2046).\n *\n * A pure presentation seed for the field-policy rail (epic #2045): it rides the\n * manifest under the field's `_meta.ui` (never promoted to a top-level\n * `FieldDefinition` key), reaches runtime at `field._meta.ui` via\n * `ObjectRegistry.getAllFields()`, and is emitted to the browser in generated\n * web-collection definitions. It has NO schema, persistence, or security\n * effect — `sensitive`/`readPermission` remain the security rail.\n */\nexport interface FieldUIHints {\n /**\n * Seed the field into the \"basic\" visibility tier (shown before the\n * advanced disclosure). Unmarked fields default per the cold-start rule:\n * an object with no basic markers renders everything basic; once any field\n * is marked, unmarked fields default to advanced.\n */\n basic?: boolean;\n /** Grouping key for form section/grouping (consumer-defined label). */\n group?: string;\n /** Relative sort order within the form/group (ascending). */\n order?: number;\n /**\n * Seed the field's policy as locked: org/user policy tiers may not\n * override it unless an org admin explicitly unlocks it.\n */\n locked?: boolean;\n}\n\n/**\n * Structured metadata attached to a field definition under `_meta`.\n *\n * Captures the field-helper options the scanner and schema/manifest\n * generators read off a field (`sqlType`, `nullable`, `__tenancy`, …). The\n * index signature keeps the bag open for forward-compatible keys without\n * forcing every consumer through `any`.\n */\nexport interface FieldMeta {\n /** Explicit SQL type override (e.g. 'UUID') applied during schema generation. */\n sqlType?: string;\n /** Storage type for cross-package reference ids ('text' forces TEXT). */\n idType?: 'uuid' | 'text';\n /** When true, the column is nullable regardless of `required`. */\n nullable?: boolean;\n /** Mirror of the field's required flag captured at registration. */\n required?: boolean;\n /** Default value carried in metadata for runtime-registry generation. */\n default?: unknown;\n /** Marks the field as the primary key column. */\n primaryKey?: boolean;\n /** Marks the column as unique. */\n unique?: boolean;\n /** Column description carried into generated schema. */\n description?: string;\n /** Static per-field UI hints authored via `@field({ ui })` (#2046). */\n ui?: FieldUIHints;\n /** Opt-in column/JSON-path indexing flag. */\n indexed?: boolean;\n /** Foreign-key delete action carried in metadata. */\n onDelete?: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION';\n /** Configures physical DDL while retaining FK relationship metadata. */\n constraint?:\n | boolean\n | { engines: Array<'postgres' | 'sqlite' | 'duckdb' | 'json'> };\n /** Excludes the field from persistence when true. */\n transient?: boolean;\n /** Numeric/length validation bounds and pattern. */\n min?: number;\n max?: number;\n minLength?: number;\n maxLength?: number;\n /**\n * Validation regex. A string source, a `RegExp`, or — when a manifest was\n * JSON-serialized and a `RegExp` collapsed to `{}` — an opaque object. Read\n * sites must narrow before accessing `.source`.\n */\n pattern?: unknown;\n /** Tenancy metadata injected for tenant-scoped models. */\n __tenancy?: {\n isTenantIdField?: boolean;\n /** Populated by the tenancy beforeSave interceptor when enabled. */\n autoPopulate?: boolean;\n [key: string]: unknown;\n };\n /** Report-aggregate metadata injected by the report normalizer. */\n __report?: {\n kind?: string;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}\n\n/**\n * Controls how a class is exposed in manifests and across packages\n */\nexport type SmrtVisibility =\n | 'public' // Included in published manifest, available to all consumers\n | 'internal' // Package-only, excluded from published manifest\n | 'test'; // Test-only, never in any published manifest\n\nexport interface FieldDefinition {\n type:\n | 'text'\n | 'decimal'\n | 'boolean'\n | 'integer'\n | 'datetime'\n | 'json'\n | 'foreignKey'\n | 'crossPackageRef' // Cross-package reference — UUID id column by default, no DDL FK\n | 'oneToMany'\n | 'manyToMany'\n | 'meta'; // STI meta fields (_meta_type, _meta_data)\n required?: boolean;\n default?: unknown;\n min?: number;\n max?: number;\n maxLength?: number;\n minLength?: number;\n related?: string; // For foreignKey, crossPackageRef, oneToMany, manyToMany\n description?: string;\n _meta?: FieldMeta;\n transient?: boolean; // Field not persisted to database\n /**\n * Sensitive value (API secrets, credentials, tax IDs). Still persisted, but\n * excluded from `toPublicJSON()` (generated REST/MCP/SvelteKit responses) and\n * rejected as a `where` filter key.\n */\n sensitive?: boolean;\n /**\n * Read-only over generated write surfaces. Stripped from create/update\n * request bodies so callers cannot mass-assign it.\n */\n readonly?: boolean;\n /**\n * Permission slug required to include this field in public/read responses.\n * Omitted unless the serializer is given a resolved permission set that\n * includes this slug. `sensitive` still wins and hides the field for all\n * callers.\n */\n readPermission?: string;\n /**\n * Controls whether the field is included in JSON exports.\n * - `true`: Always exported (unless site explicitly excludes it)\n * - `false`: Never exported (cannot be overridden by site config)\n * - `undefined`: Uses site's fieldExportDefault setting\n */\n exported?: boolean;\n}\n\nexport interface MethodParameterDefinition {\n name: string;\n type: string;\n optional: boolean;\n default?: unknown;\n /**\n * The declared annotation -- or a member of an inline object literal inside\n * it -- was syntax the scanner could not express as a string (intersection,\n * tuple, conditional, mapped, `typeof`, indexed access).\n *\n * `type` still reads `'any'` for compatibility, so this flag is the ONLY\n * thing separating \"the author wrote `any`\" from \"the scanner gave up\".\n * Anything that must fail closed on an uncertain type -- notably the API\n * wire-ability gate in `generators/custom-action.ts` -- reads this (#2686).\n */\n typeUnresolved?: boolean;\n /**\n * Resolved member types of an INLINE object-literal annotation, flattened\n * across nested literals, arrays, unions, and type arguments.\n *\n * The manifest records an inline literal as the single string `'object'`,\n * which hides exactly the members that decide whether the bag can cross a\n * wire (a callback, a model instance). NAMED bags -- an interface, type\n * alias, `Partial<>`/`Pick<>` -- are deliberately absent here and accepted\n * heuristically instead; expanding them needs cross-file type resolution the\n * AST scanner does not perform (#2686).\n */\n memberTypes?: string[];\n /**\n * For a top-level UNION, each branch with the inline members IT declared.\n *\n * `memberTypes` above flattens across branches, which lets one branch veto\n * another: `{ callback: () => void } | string` is wire-able through its\n * string branch, but the flattened `Function` rejected the whole parameter.\n * A consumer that understands this field MUST prefer it over `memberTypes`\n * for unions. Absent on a non-union parameter and on manifests generated\n * before #2686.\n */\n unionBranches?: ParameterTypeBranch[];\n}\n\n/** One branch of a top-level union parameter type (#2686). */\nexport interface ParameterTypeBranch {\n /** The branch's own type name, e.g. `string` or `object`. */\n type: string;\n /** Inline object members declared by THIS branch only. */\n memberTypes?: string[];\n}\n\nexport interface MethodDefinition {\n name: string;\n async: boolean;\n parameters: MethodParameterDefinition[];\n returnType: string;\n description?: string;\n isStatic: boolean;\n isPublic: boolean;\n /**\n * Config object of an `@method()` decorator declared on this method.\n *\n * `{}` for a bare `@method()`; absent when the method carries no `@method()`\n * at all. Typed loosely on purpose: this is SCANNED config that reached the\n * manifest as JSON, so consumers narrow it defensively through\n * `readMethodDecoratorConfig` in `generators/custom-action.ts` rather than\n * trusting a compile-time shape. The authoring type is `MethodOptions` in\n * `decorators/index.ts` (#2686).\n */\n decoratorConfig?: Record<string, unknown>;\n}\n\n/**\n * Pre-generated schema column definition for manifest\n */\nexport interface ManifestColumnDefinition {\n type: string; // SQL type: TEXT, INTEGER, DECIMAL, BOOLEAN, DATETIME, JSON\n primaryKey?: boolean;\n /**\n * Non-DDL marker for SMRT-owned identifier/reference columns.\n */\n referenceKind?: 'id' | 'foreignKey' | 'crossPackageRef' | 'tenantId';\n notNull?: boolean;\n unique?: boolean;\n default?: unknown;\n /** Same-package FK only. Cross-package references never populate this. */\n foreignKey?: import('../schema/types.js').ColumnDefinition['foreignKey'];\n}\n\n/**\n * Pre-generated schema index definition for manifest\n */\nexport interface ManifestIndexDefinition {\n name: string;\n columns: string[];\n unique?: boolean;\n where?: string;\n /**\n * Expression-based index target — when set, the DDL strategy renders the\n * index over a JSON path inside `column` (dialect-specific syntax).\n */\n jsonPath?: {\n column: string;\n path: string;\n };\n}\n\n/**\n * Pre-generated schema for efficient external package consumption\n * Generated at build time by ManifestGenerator, stored in manifest.json\n */\nexport interface ManifestSchema {\n tableName: string;\n /**\n * Engine-neutral CREATE TABLE preview. Not executable as-is: no indexes,\n * abstract SQL types. Consumers render `columns` + `indexes` through the\n * engine DDL strategy (see `schema/manifest-schema.ts`, #2358).\n */\n ddl: string;\n columns: Record<string, ManifestColumnDefinition>;\n indexes: ManifestIndexDefinition[];\n version: string; // Hash of schema definition for migration tracking\n}\n\n/**\n * Validation rule type for pre-computed validators\n * These are serializable rules extracted from field definitions at build time,\n * eliminating the need to compile validator closures at runtime.\n */\nexport type ValidationRuleType =\n | 'required'\n | 'min'\n | 'max'\n | 'minLength'\n | 'maxLength'\n | 'pattern';\n\n/**\n * Pre-computed validation rule for a field\n * Generated at build time by ManifestGenerator, stored in manifest.json\n *\n * These rules are evaluated at runtime without creating closure functions,\n * significantly reducing CLI startup time for projects with many SMRT objects.\n */\nexport interface ValidationRule {\n /** Field name to validate */\n field: string;\n /** Type of validation rule */\n rule: ValidationRuleType;\n /** Value for the rule (number for min/max/minLength/maxLength, string for pattern) */\n value?: number | string;\n /** Field type for context (text, integer, decimal, etc.) */\n fieldType?: string;\n}\n\n// ── Agent manifest types ────────────────────────────────────────────────\n\n/**\n * Permission declared by an agent\n * Generated from uiSlots (manage:*) and CLI/MCP methods (execute:*)\n */\nexport interface AgentPermission {\n id: string;\n label: string;\n category: 'slot' | 'method';\n defaultGranted?: boolean;\n}\n\n/**\n * Feature declared by an agent\n */\nexport interface AgentFeature {\n id: string;\n label: string;\n description?: string;\n type: 'slot' | 'method';\n}\n\n/**\n * Menu item derived from agent uiSlots\n */\nexport interface AgentMenuItem {\n id: string;\n label: string;\n icon?: string;\n order: number;\n path: string;\n requiredPermission?: string;\n}\n\n/**\n * Component export declaration derived from package.json exports\n */\nexport interface AgentComponentDeclaration {\n exportPath: string;\n type: string;\n}\n\n/**\n * UI slot definition captured from static uiSlots on Agent subclasses\n */\nexport interface AgentUISlotManifest {\n id: string;\n label: string;\n description?: string;\n icon?: string;\n order?: number;\n disabled?: boolean;\n /** Durable owner for settings written through this slot. */\n scope?: 'agent' | 'persona';\n /** Optional fallback form contract for host applications. */\n settingsSchema?: {\n version: number;\n fields: Array<{\n id: string;\n label: string;\n type: 'string' | 'number' | 'boolean' | 'select' | 'textarea' | 'json';\n description?: string;\n required?: boolean;\n default?: unknown;\n placeholder?: string;\n options?: Array<{ value: string; label: string }>;\n min?: number;\n max?: number;\n }>;\n };\n}\n\n/**\n * Admin route declared by an agent via static adminRoutes\n * Consumed by vitePluginAgentRoutes to register admin routes with SvelteKit\n */\nexport interface AgentAdminRouteManifest {\n /** Route path relative to agent root (e.g., 'sources/[sourceId]') */\n path: string;\n /** Component export name from the agent's admin entry point */\n component: string;\n /** Optional: export name for server load function */\n load?: string;\n}\n\n/**\n * Auto-generated agent manifest section\n * Produced by the manifest build pipeline for any class with `agent` decorator config\n */\nexport interface AgentManifest {\n name: string;\n slug: string;\n icon?: string;\n tier: 'free' | 'standard' | 'premium';\n description?: string;\n uiSlots: Record<string, AgentUISlotManifest>;\n adminRoutes?: AgentAdminRouteManifest[];\n /** Default signal subscriptions declared by this agent */\n signalSubscriptions?: string[];\n permissions: AgentPermission[];\n features: AgentFeature[];\n menuItems: AgentMenuItem[];\n components: AgentComponentDeclaration[];\n}\n\n// ── Core manifest types ─────────────────────────────────────────────────\n\nexport interface SmartObjectDefinition {\n /**\n * Qualified name in format \"@package/name:ClassName\"\n * This is the PRIMARY KEY for manifest lookups.\n * Example: \"@happyvertical/smrt-core:Product\"\n *\n * Optional during transition - will be required in future versions.\n */\n qualifiedName?: QualifiedClassName;\n\n /**\n * Simple class name (PascalCase)\n * Example: \"Product\"\n */\n className: string;\n\n /**\n * Package name where this class is defined.\n * Example: \"@happyvertical/smrt-core\"\n *\n * Optional during transition - will be required in future versions.\n */\n packageName?: string;\n\n /**\n * Visibility control for manifest inclusion\n * - 'public': Included in published manifest (default)\n * - 'internal': Package-only, excluded from published manifest\n * - 'test': Test-only, never in any published manifest\n *\n * Defaults to 'public' if not specified.\n */\n visibility?: SmrtVisibility;\n\n /**\n * @deprecated Use qualifiedName instead. Kept for transition period.\n * Lowercase class name, formerly used as manifest key.\n */\n name: string;\n\n collection: string; // Pluralized name for endpoints\n filePath: string;\n packageVersion?: string; // Package version for external manifest loading\n importPath?: string; // Import path for dynamic loading (e.g., \"@pkg/objects\")\n modulePath?: string; // Relative module path within package\n exportName?: string; // Named export to use (defaults to className)\n collectionExportName?: string; // Collection class export name\n fields: Record<string, FieldDefinition>;\n methods: Record<string, MethodDefinition>;\n decoratorConfig: SmartObjectConfig;\n extends?: string; // Base class name (simple name, not qualified)\n extendsQualified?: string; // Base class qualified name\n extendsTypeArg?: string; // Generic type argument (e.g., \"Meeting\" from \"SmrtCollection<Meeting>\")\n tools?: Array<{\n type: 'function';\n function: {\n name: string;\n description?: string;\n parameters?: Record<string, unknown>;\n };\n }>;\n /**\n * Pre-generated schema for efficient external package consumption\n * Generated at build time by ManifestGenerator (smrt scan)\n *\n * When present, consumers can use this pre-computed schema directly\n * without calling generateSchema() at runtime, eliminating latency.\n */\n schema?: ManifestSchema;\n\n /**\n * Pre-computed validation rules for efficient runtime validation\n * Generated at build time by ManifestGenerator (smrt scan)\n *\n * When present, the registry uses these rules instead of compiling\n * validator closures at runtime, significantly reducing startup time.\n *\n * @see ValidationRule\n */\n validationRules?: ValidationRule[];\n\n /**\n * Static properties captured from the class definition\n * Currently used for `static uiSlots` on Agent subclasses\n */\n staticProperties?: Record<string, unknown>;\n\n /**\n * Auto-generated agent manifest\n * Only present for classes with `agent` in their decorator config\n * Generated at build time by ManifestGenerator fifth pass\n */\n agent?: AgentManifest;\n}\n\n/**\n * Fixed `timestamp` for every manifest that can reach build output.\n *\n * Manifests are inlined into bundles (`registerPackageManifest(JSON.parse(...))`),\n * so a wall-clock value changes the emitted bytes on every build. That changes\n * Vite's content hash, which changes `dist/`, which invalidates every\n * downstream package through `dependsOn: ['^build']` — one rebuilt package\n * churned 202 of 245 task hashes, and `typecheck` never reused a cache entry\n * across runs (#2223).\n *\n * Nothing reads the field: `getManifestTimestampsHash` invalidates on\n * filesystem mtimes, and `normalizeManifestForHash` deletes it before\n * comparing. A fixed value therefore costs no information.\n *\n * Genuine runtime caches that expire on elapsed time — the discovery cache in\n * `manifest/discover-smrt-packages.ts` — keep using the clock; they never\n * reach build output.\n */\nexport const MANIFEST_TIMESTAMP = 0;\n\n/**\n * Fixed `generatedAt` for knowledge artifacts emitted into `dist/`.\n *\n * Same reasoning as {@link MANIFEST_TIMESTAMP}: build output is compared\n * byte-for-byte, so it cannot carry the clock. The Unix epoch is used rather\n * than `0` because the field is an ISO-8601 string, and a parseable value\n * keeps any consumer that formats it working.\n *\n * The working copy under `.smrt/` keeps a real timestamp — it is useful to a\n * human there, and `preserveKnowledgeGeneratedAt` already stops it churning\n * across incremental rebuilds.\n */\nexport const DETERMINISTIC_GENERATED_AT = '1970-01-01T00:00:00.000Z';\n\nexport interface SmartObjectManifest {\n version: string;\n /** Always {@link MANIFEST_TIMESTAMP} for build-output manifests. */\n timestamp: number;\n packageName?: string; // Root package name (should be set for all new manifests)\n packageVersion?: string; // Root package version\n /**\n * Objects keyed by qualified name (e.g., \"@happyvertical/smrt-core:Product\")\n * Key is string for backward compatibility, but should be QualifiedClassName format.\n */\n objects: Record<string, SmartObjectDefinition>;\n moduleType?: string; // Module type identifier (e.g., \"smrt\") for package discovery\n smrtDependencies?: string[]; // Discovered SMRT packages from dependency tree\n}\n\nexport interface ScanResult {\n filePath: string;\n objects: SmartObjectDefinition[];\n errors: Array<{\n message: string;\n line?: number;\n column?: number;\n }>;\n}\n\nexport interface ScanOptions {\n includePrivateMethods?: boolean;\n includeStaticMethods?: boolean;\n followImports?: boolean;\n baseClasses?: string[]; // Classes to consider as SMRT base classes\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAwhBA,IAAa,qBAAqB;;;;;;;;;;;;;AAclC,IAAa,6BAA6B"}
|
|
1
|
+
{"version":3,"file":"types.js","names":[],"sources":["../../src/scanner/types.ts"],"sourcesContent":["/**\n * Type definitions for AST scanning and manifest generation\n */\n\nimport type { SmartObjectConfig } from '../registry.js';\n\n/**\n * Qualified class name in format \"@package/name:ClassName\"\n * Example: \"@happyvertical/smrt-core:Product\"\n */\nexport type QualifiedClassName = `${string}:${string}`;\n\n/**\n * Static per-field UI hints authored via `@field({ ui })` (#2046).\n *\n * A pure presentation seed for the field-policy rail (epic #2045): it rides the\n * manifest under the field's `_meta.ui` (never promoted to a top-level\n * `FieldDefinition` key), reaches runtime at `field._meta.ui` via\n * `ObjectRegistry.getAllFields()`, and is emitted to the browser in generated\n * web-collection definitions. It has NO schema, persistence, or security\n * effect — `sensitive`/`readPermission` remain the security rail.\n */\nexport interface FieldUIHints {\n /**\n * Seed the field into the \"basic\" visibility tier (shown before the\n * advanced disclosure). Unmarked fields default per the cold-start rule:\n * an object with no basic markers renders everything basic; once any field\n * is marked, unmarked fields default to advanced.\n */\n basic?: boolean;\n /** Grouping key for form section/grouping (consumer-defined label). */\n group?: string;\n /** Relative sort order within the form/group (ascending). */\n order?: number;\n /**\n * Seed the field's policy as locked: org/user policy tiers may not\n * override it unless an org admin explicitly unlocks it.\n */\n locked?: boolean;\n}\n\n/**\n * Structured metadata attached to a field definition under `_meta`.\n *\n * Captures the field-helper options the scanner and schema/manifest\n * generators read off a field (`sqlType`, `nullable`, `__tenancy`, …). The\n * index signature keeps the bag open for forward-compatible keys without\n * forcing every consumer through `any`.\n */\nexport interface FieldMeta {\n /** Explicit SQL type override (e.g. 'UUID') applied during schema generation. */\n sqlType?: string;\n /** Storage type for cross-package reference ids ('text' forces TEXT). */\n idType?: 'uuid' | 'text';\n /** When true, the column is nullable regardless of `required`. */\n nullable?: boolean;\n /** Mirror of the field's required flag captured at registration. */\n required?: boolean;\n /** Default value carried in metadata for runtime-registry generation. */\n default?: unknown;\n /** Marks the field as the primary key column. */\n primaryKey?: boolean;\n /** Marks the column as unique. */\n unique?: boolean;\n /** Column description carried into generated schema. */\n description?: string;\n /** Static per-field UI hints authored via `@field({ ui })` (#2046). */\n ui?: FieldUIHints;\n /** Opt-in column/JSON-path indexing flag. */\n indexed?: boolean;\n /** Foreign-key delete action carried in metadata. */\n onDelete?: 'CASCADE' | 'SET NULL' | 'RESTRICT' | 'NO ACTION';\n /** Configures physical DDL while retaining FK relationship metadata. */\n constraint?:\n | boolean\n | { engines: Array<'postgres' | 'sqlite' | 'duckdb' | 'json'> };\n /** Excludes the field from persistence when true. */\n transient?: boolean;\n /** Numeric/length validation bounds and pattern. */\n min?: number;\n max?: number;\n minLength?: number;\n maxLength?: number;\n /**\n * Validation regex. A string source, a `RegExp`, or — when a manifest was\n * JSON-serialized and a `RegExp` collapsed to `{}` — an opaque object. Read\n * sites must narrow before accessing `.source`.\n */\n pattern?: unknown;\n /** Tenancy metadata injected for tenant-scoped models. */\n __tenancy?: {\n isTenantIdField?: boolean;\n /** Populated by the tenancy beforeSave interceptor when enabled. */\n autoPopulate?: boolean;\n [key: string]: unknown;\n };\n /** Report-aggregate metadata injected by the report normalizer. */\n __report?: {\n kind?: string;\n [key: string]: unknown;\n };\n [key: string]: unknown;\n}\n\n/**\n * Controls how a class is exposed in manifests and across packages\n */\nexport type SmrtVisibility =\n | 'public' // Included in published manifest, available to all consumers\n | 'internal' // Package-only, excluded from published manifest\n | 'test'; // Test-only, never in any published manifest\n\nexport interface FieldDefinition {\n type:\n | 'text'\n | 'decimal'\n | 'boolean'\n | 'integer'\n | 'datetime'\n | 'json'\n | 'foreignKey'\n | 'crossPackageRef' // Cross-package reference — UUID id column by default, no DDL FK\n | 'oneToMany'\n | 'manyToMany'\n | 'meta'; // STI meta fields (_meta_type, _meta_data)\n required?: boolean;\n default?: unknown;\n min?: number;\n max?: number;\n maxLength?: number;\n minLength?: number;\n related?: string; // For foreignKey, crossPackageRef, oneToMany, manyToMany\n description?: string;\n _meta?: FieldMeta;\n transient?: boolean; // Field not persisted to database\n /**\n * Sensitive value (API secrets, credentials, tax IDs). Still persisted, but\n * excluded from `toPublicJSON()` (generated REST/MCP/SvelteKit responses) and\n * rejected as a `where` filter key.\n */\n sensitive?: boolean;\n /**\n * Read-only over generated write surfaces. Stripped from create/update\n * request bodies so callers cannot mass-assign it.\n */\n readonly?: boolean;\n /**\n * Permission slug required to include this field in public/read responses.\n * Omitted unless the serializer is given a resolved permission set that\n * includes this slug. `sensitive` still wins and hides the field for all\n * callers.\n */\n readPermission?: string;\n /**\n * Controls whether the field is included in JSON exports.\n * - `true`: Always exported (unless site explicitly excludes it)\n * - `false`: Never exported (cannot be overridden by site config)\n * - `undefined`: Uses site's fieldExportDefault setting\n */\n exported?: boolean;\n}\n\nexport interface MethodParameterDefinition {\n name: string;\n type: string;\n optional: boolean;\n default?: unknown;\n /**\n * The declared annotation -- or a member of an inline object literal inside\n * it -- was syntax the scanner could not express as a string (intersection,\n * tuple, conditional, mapped, `typeof`, indexed access).\n *\n * `type` still reads `'any'` for compatibility, so this flag is the ONLY\n * thing separating \"the author wrote `any`\" from \"the scanner gave up\".\n * Anything that must fail closed on an uncertain type -- notably the API\n * wire-ability gate in `generators/custom-action.ts` -- reads this (#2686).\n */\n typeUnresolved?: boolean;\n /**\n * Resolved member types of an INLINE object-literal annotation, flattened\n * across nested literals, arrays, unions, and type arguments.\n *\n * The manifest records an inline literal as the single string `'object'`,\n * which hides exactly the members that decide whether the bag can cross a\n * wire (a callback, a model instance). NAMED bags -- an interface, type\n * alias, `Partial<>`/`Pick<>` -- are deliberately absent here and accepted\n * heuristically instead; expanding them needs cross-file type resolution the\n * AST scanner does not perform (#2686).\n */\n memberTypes?: string[];\n /**\n * For a top-level UNION, each branch with the inline members IT declared.\n *\n * `memberTypes` above flattens across branches, which lets one branch veto\n * another: `{ callback: () => void } | string` is wire-able through its\n * string branch, but the flattened `Function` rejected the whole parameter.\n * A consumer that understands this field MUST prefer it over `memberTypes`\n * for unions. Absent on a non-union parameter and on manifests generated\n * before #2686.\n */\n unionBranches?: ParameterTypeBranch[];\n}\n\n/** One branch of a top-level union parameter type (#2686). */\nexport interface ParameterTypeBranch {\n /** The branch's own type name, e.g. `string` or `object`. */\n type: string;\n /** Inline object members declared by THIS branch only. */\n memberTypes?: string[];\n}\n\nexport interface MethodDefinition {\n name: string;\n async: boolean;\n parameters: MethodParameterDefinition[];\n returnType: string;\n description?: string;\n isStatic: boolean;\n isPublic: boolean;\n /**\n * Config object of an `@method()` decorator declared on this method.\n *\n * `{}` for a bare `@method()`; absent when the method carries no `@method()`\n * at all. Typed loosely on purpose: this is SCANNED config that reached the\n * manifest as JSON, so consumers narrow it defensively through\n * `readMethodDecoratorConfig` in `generators/custom-action.ts` rather than\n * trusting a compile-time shape. The authoring type is `MethodOptions` in\n * `decorators/index.ts` (#2686).\n */\n decoratorConfig?: Record<string, unknown>;\n}\n\n/**\n * Pre-generated schema column definition for manifest\n */\nexport interface ManifestColumnDefinition {\n type: string; // SQL type: TEXT, INTEGER, DECIMAL, BOOLEAN, DATETIME, JSON\n primaryKey?: boolean;\n /**\n * Non-DDL marker for SMRT-owned identifier/reference columns.\n */\n referenceKind?: 'id' | 'foreignKey' | 'crossPackageRef' | 'tenantId';\n notNull?: boolean;\n unique?: boolean;\n default?: unknown;\n /** Same-package FK only. Cross-package references never populate this. */\n foreignKey?: import('../schema/types.js').ColumnDefinition['foreignKey'];\n}\n\n/**\n * Pre-generated schema index definition for manifest\n */\nexport interface ManifestIndexDefinition {\n name: string;\n columns: string[];\n unique?: boolean;\n /** SMRT-owned nullable upsert identity; PostgreSQL 15+ uses NULLS NOT DISTINCT. */\n nullsNotDistinct?: boolean;\n where?: string;\n /**\n * Expression-based index target — when set, the DDL strategy renders the\n * index over a JSON path inside `column` (dialect-specific syntax).\n */\n jsonPath?: {\n column: string;\n path: string;\n };\n}\n\n/**\n * Pre-generated schema for efficient external package consumption\n * Generated at build time by ManifestGenerator, stored in manifest.json\n */\nexport interface ManifestSchema {\n tableName: string;\n /**\n * Engine-neutral CREATE TABLE preview. Not executable as-is: no indexes,\n * abstract SQL types. Consumers render `columns` + `indexes` through the\n * engine DDL strategy (see `schema/manifest-schema.ts`, #2358).\n */\n ddl: string;\n columns: Record<string, ManifestColumnDefinition>;\n indexes: ManifestIndexDefinition[];\n version: string; // Hash of schema definition for migration tracking\n}\n\n/**\n * Validation rule type for pre-computed validators\n * These are serializable rules extracted from field definitions at build time,\n * eliminating the need to compile validator closures at runtime.\n */\nexport type ValidationRuleType =\n | 'required'\n | 'min'\n | 'max'\n | 'minLength'\n | 'maxLength'\n | 'pattern';\n\n/**\n * Pre-computed validation rule for a field\n * Generated at build time by ManifestGenerator, stored in manifest.json\n *\n * These rules are evaluated at runtime without creating closure functions,\n * significantly reducing CLI startup time for projects with many SMRT objects.\n */\nexport interface ValidationRule {\n /** Field name to validate */\n field: string;\n /** Type of validation rule */\n rule: ValidationRuleType;\n /** Value for the rule (number for min/max/minLength/maxLength, string for pattern) */\n value?: number | string;\n /** Field type for context (text, integer, decimal, etc.) */\n fieldType?: string;\n}\n\n// ── Agent manifest types ────────────────────────────────────────────────\n\n/**\n * Permission declared by an agent\n * Generated from uiSlots (manage:*) and CLI/MCP methods (execute:*)\n */\nexport interface AgentPermission {\n id: string;\n label: string;\n category: 'slot' | 'method';\n defaultGranted?: boolean;\n}\n\n/**\n * Feature declared by an agent\n */\nexport interface AgentFeature {\n id: string;\n label: string;\n description?: string;\n type: 'slot' | 'method';\n}\n\n/**\n * Menu item derived from agent uiSlots\n */\nexport interface AgentMenuItem {\n id: string;\n label: string;\n icon?: string;\n order: number;\n path: string;\n requiredPermission?: string;\n}\n\n/**\n * Component export declaration derived from package.json exports\n */\nexport interface AgentComponentDeclaration {\n exportPath: string;\n type: string;\n}\n\n/**\n * UI slot definition captured from static uiSlots on Agent subclasses\n */\nexport interface AgentUISlotManifest {\n id: string;\n label: string;\n description?: string;\n icon?: string;\n order?: number;\n disabled?: boolean;\n /** Durable owner for settings written through this slot. */\n scope?: 'agent' | 'persona';\n /** Optional fallback form contract for host applications. */\n settingsSchema?: {\n version: number;\n fields: Array<{\n id: string;\n label: string;\n type: 'string' | 'number' | 'boolean' | 'select' | 'textarea' | 'json';\n description?: string;\n required?: boolean;\n default?: unknown;\n placeholder?: string;\n options?: Array<{ value: string; label: string }>;\n min?: number;\n max?: number;\n }>;\n };\n}\n\n/**\n * Admin route declared by an agent via static adminRoutes\n * Consumed by vitePluginAgentRoutes to register admin routes with SvelteKit\n */\nexport interface AgentAdminRouteManifest {\n /** Route path relative to agent root (e.g., 'sources/[sourceId]') */\n path: string;\n /** Component export name from the agent's admin entry point */\n component: string;\n /** Optional: export name for server load function */\n load?: string;\n}\n\n/**\n * Auto-generated agent manifest section\n * Produced by the manifest build pipeline for any class with `agent` decorator config\n */\nexport interface AgentManifest {\n name: string;\n slug: string;\n icon?: string;\n tier: 'free' | 'standard' | 'premium';\n description?: string;\n uiSlots: Record<string, AgentUISlotManifest>;\n adminRoutes?: AgentAdminRouteManifest[];\n /** Default signal subscriptions declared by this agent */\n signalSubscriptions?: string[];\n permissions: AgentPermission[];\n features: AgentFeature[];\n menuItems: AgentMenuItem[];\n components: AgentComponentDeclaration[];\n}\n\n// ── Core manifest types ─────────────────────────────────────────────────\n\nexport interface SmartObjectDefinition {\n /**\n * Qualified name in format \"@package/name:ClassName\"\n * This is the PRIMARY KEY for manifest lookups.\n * Example: \"@happyvertical/smrt-core:Product\"\n *\n * Optional during transition - will be required in future versions.\n */\n qualifiedName?: QualifiedClassName;\n\n /**\n * Simple class name (PascalCase)\n * Example: \"Product\"\n */\n className: string;\n\n /**\n * Package name where this class is defined.\n * Example: \"@happyvertical/smrt-core\"\n *\n * Optional during transition - will be required in future versions.\n */\n packageName?: string;\n\n /**\n * Visibility control for manifest inclusion\n * - 'public': Included in published manifest (default)\n * - 'internal': Package-only, excluded from published manifest\n * - 'test': Test-only, never in any published manifest\n *\n * Defaults to 'public' if not specified.\n */\n visibility?: SmrtVisibility;\n\n /**\n * @deprecated Use qualifiedName instead. Kept for transition period.\n * Lowercase class name, formerly used as manifest key.\n */\n name: string;\n\n collection: string; // Pluralized name for endpoints\n filePath: string;\n packageVersion?: string; // Package version for external manifest loading\n importPath?: string; // Import path for dynamic loading (e.g., \"@pkg/objects\")\n modulePath?: string; // Relative module path within package\n exportName?: string; // Named export to use (defaults to className)\n collectionExportName?: string; // Collection class export name\n fields: Record<string, FieldDefinition>;\n methods: Record<string, MethodDefinition>;\n decoratorConfig: SmartObjectConfig;\n extends?: string; // Base class name (simple name, not qualified)\n extendsQualified?: string; // Base class qualified name\n extendsTypeArg?: string; // Generic type argument (e.g., \"Meeting\" from \"SmrtCollection<Meeting>\")\n tools?: Array<{\n type: 'function';\n function: {\n name: string;\n description?: string;\n parameters?: Record<string, unknown>;\n };\n }>;\n /**\n * Pre-generated schema for efficient external package consumption\n * Generated at build time by ManifestGenerator (smrt scan)\n *\n * When present, consumers can use this pre-computed schema directly\n * without calling generateSchema() at runtime, eliminating latency.\n */\n schema?: ManifestSchema;\n\n /**\n * Pre-computed validation rules for efficient runtime validation\n * Generated at build time by ManifestGenerator (smrt scan)\n *\n * When present, the registry uses these rules instead of compiling\n * validator closures at runtime, significantly reducing startup time.\n *\n * @see ValidationRule\n */\n validationRules?: ValidationRule[];\n\n /**\n * Static properties captured from the class definition\n * Currently used for `static uiSlots` on Agent subclasses\n */\n staticProperties?: Record<string, unknown>;\n\n /**\n * Auto-generated agent manifest\n * Only present for classes with `agent` in their decorator config\n * Generated at build time by ManifestGenerator fifth pass\n */\n agent?: AgentManifest;\n}\n\n/**\n * Fixed `timestamp` for every manifest that can reach build output.\n *\n * Manifests are inlined into bundles (`registerPackageManifest(JSON.parse(...))`),\n * so a wall-clock value changes the emitted bytes on every build. That changes\n * Vite's content hash, which changes `dist/`, which invalidates every\n * downstream package through `dependsOn: ['^build']` — one rebuilt package\n * churned 202 of 245 task hashes, and `typecheck` never reused a cache entry\n * across runs (#2223).\n *\n * Nothing reads the field: `getManifestTimestampsHash` invalidates on\n * filesystem mtimes, and `normalizeManifestForHash` deletes it before\n * comparing. A fixed value therefore costs no information.\n *\n * Genuine runtime caches that expire on elapsed time — the discovery cache in\n * `manifest/discover-smrt-packages.ts` — keep using the clock; they never\n * reach build output.\n */\nexport const MANIFEST_TIMESTAMP = 0;\n\n/**\n * Fixed `generatedAt` for knowledge artifacts emitted into `dist/`.\n *\n * Same reasoning as {@link MANIFEST_TIMESTAMP}: build output is compared\n * byte-for-byte, so it cannot carry the clock. The Unix epoch is used rather\n * than `0` because the field is an ISO-8601 string, and a parseable value\n * keeps any consumer that formats it working.\n *\n * The working copy under `.smrt/` keeps a real timestamp — it is useful to a\n * human there, and `preserveKnowledgeGeneratedAt` already stops it churning\n * across incremental rebuilds.\n */\nexport const DETERMINISTIC_GENERATED_AT = '1970-01-01T00:00:00.000Z';\n\nexport interface SmartObjectManifest {\n version: string;\n /** Always {@link MANIFEST_TIMESTAMP} for build-output manifests. */\n timestamp: number;\n packageName?: string; // Root package name (should be set for all new manifests)\n packageVersion?: string; // Root package version\n /**\n * Objects keyed by qualified name (e.g., \"@happyvertical/smrt-core:Product\")\n * Key is string for backward compatibility, but should be QualifiedClassName format.\n */\n objects: Record<string, SmartObjectDefinition>;\n moduleType?: string; // Module type identifier (e.g., \"smrt\") for package discovery\n smrtDependencies?: string[]; // Discovered SMRT packages from dependency tree\n}\n\nexport interface ScanResult {\n filePath: string;\n objects: SmartObjectDefinition[];\n errors: Array<{\n message: string;\n line?: number;\n column?: number;\n }>;\n}\n\nexport interface ScanOptions {\n includePrivateMethods?: boolean;\n includeStaticMethods?: boolean;\n followImports?: boolean;\n baseClasses?: string[]; // Classes to consider as SMRT base classes\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA0hBA,IAAa,qBAAqB;;;;;;;;;;;;;AAclC,IAAa,6BAA6B"}
|
|
@@ -22,8 +22,9 @@
|
|
|
22
22
|
* NULL-tenant rows (`mode: 'optional'` outside a tenant context) keep the
|
|
23
23
|
* SDK's null-aware upsert semantics: `@happyvertical/sql` matches conflict
|
|
24
24
|
* columns with `IS NOT DISTINCT FROM`, so `(NULL, 'widget', '')` updates the
|
|
25
|
-
* existing `(NULL, 'widget', '')` row through the model layer
|
|
26
|
-
*
|
|
25
|
+
* existing `(NULL, 'widget', '')` row through the model layer. PostgreSQL 15+
|
|
26
|
+
* framework indexes additionally enforce this with NULLS NOT DISTINCT (#2834);
|
|
27
|
+
* older engines and unmigrated indexes retain the fallback. Global rows dedup among
|
|
27
28
|
* themselves exactly as every row did before, and per-tenant rows dedup per
|
|
28
29
|
* tenant.
|
|
29
30
|
*
|
|
@@ -101,4 +102,9 @@ export declare function servesSlugLookup(indexColumns: readonly string[], tenant
|
|
|
101
102
|
* @param toColumn - field-name → column-name conversion (`toSnakeCase`)
|
|
102
103
|
*/
|
|
103
104
|
export declare function resolveTenantColumn(tenantField: string | undefined | null, hasField: (fieldName: string) => boolean, toColumn: (fieldName: string) => string): string | undefined;
|
|
105
|
+
/** Only the framework conflict identity opts into NULL-equal uniqueness. */
|
|
106
|
+
export declare function nullableConflictIdentity(conflictColumns: readonly string[], columns: Record<string, {
|
|
107
|
+
notNull?: boolean;
|
|
108
|
+
primaryKey?: boolean;
|
|
109
|
+
} | undefined>): boolean;
|
|
104
110
|
//# sourceMappingURL=conflict-target.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conflict-target.d.ts","sourceRoot":"","sources":["../../src/schema/conflict-target.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"conflict-target.d.ts","sourceRoot":"","sources":["../../src/schema/conflict-target.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,6DAA6D;AAC7D,eAAO,MAAM,4BAA4B,EAAE,SAAS,MAAM,EAGzD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,4BAA4B,EAAE,SAAS,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E,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,UAAU,CAAC,EAAE,OAAO,CAAA;CAAE,GAAG,SAAS,CACxD,GACA,OAAO,CAKT"}
|
|
@@ -23,8 +23,9 @@
|
|
|
23
23
|
* NULL-tenant rows (`mode: 'optional'` outside a tenant context) keep the
|
|
24
24
|
* SDK's null-aware upsert semantics: `@happyvertical/sql` matches conflict
|
|
25
25
|
* columns with `IS NOT DISTINCT FROM`, so `(NULL, 'widget', '')` updates the
|
|
26
|
-
* existing `(NULL, 'widget', '')` row through the model layer
|
|
27
|
-
*
|
|
26
|
+
* existing `(NULL, 'widget', '')` row through the model layer. PostgreSQL 15+
|
|
27
|
+
* framework indexes additionally enforce this with NULLS NOT DISTINCT (#2834);
|
|
28
|
+
* older engines and unmigrated indexes retain the fallback. Global rows dedup among
|
|
28
29
|
* themselves exactly as every row did before, and per-tenant rows dedup per
|
|
29
30
|
* tenant.
|
|
30
31
|
*
|
|
@@ -123,7 +124,14 @@ function resolveTenantColumn(tenantField, hasField, toColumn) {
|
|
|
123
124
|
if (!tenantField || !hasField(tenantField)) return void 0;
|
|
124
125
|
return toColumn(tenantField);
|
|
125
126
|
}
|
|
127
|
+
/** Only the framework conflict identity opts into NULL-equal uniqueness. */
|
|
128
|
+
function nullableConflictIdentity(conflictColumns, columns) {
|
|
129
|
+
return conflictColumns.some((name) => {
|
|
130
|
+
const column = columns[name];
|
|
131
|
+
return column !== void 0 && !column.notNull && !column.primaryKey;
|
|
132
|
+
});
|
|
133
|
+
}
|
|
126
134
|
//#endregion
|
|
127
|
-
export { DEFAULT_CTI_CONFLICT_COLUMNS, DEFAULT_STI_CONFLICT_COLUMNS, conflictIndexName, defaultConflictColumns, isDefaultNaturalKey, resolveConflictColumns, resolveTenantColumn, servesSlugLookup };
|
|
135
|
+
export { DEFAULT_CTI_CONFLICT_COLUMNS, DEFAULT_STI_CONFLICT_COLUMNS, conflictIndexName, defaultConflictColumns, isDefaultNaturalKey, nullableConflictIdentity, resolveConflictColumns, resolveTenantColumn, servesSlugLookup };
|
|
128
136
|
|
|
129
137
|
//# sourceMappingURL=conflict-target.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conflict-target.js","names":[],"sources":["../../src/schema/conflict-target.ts"],"sourcesContent":["/**\n * Conflict target (upsert natural key) resolution shared by every schema path\n * and by the runtime (#2360, epic #2382 finding B1/A4).\n *\n * `SmrtObject.save()` upserts a NEW object on\n * `ObjectRegistry.getConflictColumns()`; the schema generator emits ONE unique\n * index over the same columns so `INSERT … ON CONFLICT (…)` binds on every\n * engine. Before #2360 the tenancy interceptor populated `tenant_id` on save\n * but neither the conflict target nor the unique index carried it, so a\n * second tenant creating the same natural key (`slug`, `context`) matched the\n * first tenant's row and `DO UPDATE SET` rewrote its `id` and `tenant_id`\n * (probed: tenant A's row was silently adopted by tenant B).\n *\n * The rule now: **a tenant-scoped class's default conflict target is\n * `[tenantColumn, ...naturalKey]`** on the build path (manifest\n * `decoratorConfig.conflictColumns`, materialized by\n * `ManifestGenerator.normalizeConflictColumns()`) and on the runtime path\n * (`ObjectRegistry.getConflictColumns()`), so schema and upsert agree by\n * construction. Explicit `@smrt({ conflictColumns })` always wins and is\n * never rewritten — a class that declares its own natural key owns it.\n *\n * NULL-tenant rows (`mode: 'optional'` outside a tenant context) keep the\n * SDK's null-aware upsert semantics: `@happyvertical/sql` matches conflict\n * columns with `IS NOT DISTINCT FROM`, so `(NULL, 'widget', '')` updates the\n * existing `(NULL, 'widget', '')` row through the model layer
|
|
1
|
+
{"version":3,"file":"conflict-target.js","names":[],"sources":["../../src/schema/conflict-target.ts"],"sourcesContent":["/**\n * Conflict target (upsert natural key) resolution shared by every schema path\n * and by the runtime (#2360, epic #2382 finding B1/A4).\n *\n * `SmrtObject.save()` upserts a NEW object on\n * `ObjectRegistry.getConflictColumns()`; the schema generator emits ONE unique\n * index over the same columns so `INSERT … ON CONFLICT (…)` binds on every\n * engine. Before #2360 the tenancy interceptor populated `tenant_id` on save\n * but neither the conflict target nor the unique index carried it, so a\n * second tenant creating the same natural key (`slug`, `context`) matched the\n * first tenant's row and `DO UPDATE SET` rewrote its `id` and `tenant_id`\n * (probed: tenant A's row was silently adopted by tenant B).\n *\n * The rule now: **a tenant-scoped class's default conflict target is\n * `[tenantColumn, ...naturalKey]`** on the build path (manifest\n * `decoratorConfig.conflictColumns`, materialized by\n * `ManifestGenerator.normalizeConflictColumns()`) and on the runtime path\n * (`ObjectRegistry.getConflictColumns()`), so schema and upsert agree by\n * construction. Explicit `@smrt({ conflictColumns })` always wins and is\n * never rewritten — a class that declares its own natural key owns it.\n *\n * NULL-tenant rows (`mode: 'optional'` outside a tenant context) keep the\n * SDK's null-aware upsert semantics: `@happyvertical/sql` matches conflict\n * columns with `IS NOT DISTINCT FROM`, so `(NULL, 'widget', '')` updates the\n * existing `(NULL, 'widget', '')` row through the model layer. PostgreSQL 15+\n * framework indexes additionally enforce this with NULLS NOT DISTINCT (#2834);\n * older engines and unmigrated indexes retain the fallback. Global rows dedup among\n * themselves exactly as every row did before, and per-tenant rows dedup per\n * tenant.\n *\n * Index NAMES stay stable across this change — the tenant-led default key\n * keeps `<table>_slug_context_idx` (CTI) / `<table>_slug_context_meta_type_idx`\n * (STI) — so `SchemaComparer`'s same-name shape-drift repair swaps the columns\n * in place (`DROP INDEX` + `CREATE UNIQUE INDEX`) instead of leaving the old\n * global unique index behind to keep blocking cross-tenant duplicates. The new\n * key is a superset of the old one, so creating it cannot fail on existing\n * data.\n */\n\n/** Default natural key of a class-per-table (CTI) object. */\nexport const DEFAULT_CTI_CONFLICT_COLUMNS: readonly string[] = [\n 'slug',\n 'context',\n];\n\n/**\n * Default natural key of a single-table-inheritance (STI) hierarchy: the\n * discriminator participates in identity so two subtypes may share a slug.\n */\nexport const DEFAULT_STI_CONFLICT_COLUMNS: readonly string[] = [\n 'slug',\n 'context',\n '_meta_type',\n];\n\nexport type ConflictTableStrategy = 'cti' | 'sti';\n\n/**\n * The default conflict target for a table with the given strategy, led by the\n * tenant column when the schema-owning class is tenant-scoped.\n */\nexport function defaultConflictColumns(\n strategy: ConflictTableStrategy,\n tenantColumn?: string | null,\n): string[] {\n const naturalKey =\n strategy === 'sti'\n ? [...DEFAULT_STI_CONFLICT_COLUMNS]\n : [...DEFAULT_CTI_CONFLICT_COLUMNS];\n return tenantColumn ? [tenantColumn, ...naturalKey] : naturalKey;\n}\n\n/**\n * Resolve the conflict target of a table.\n *\n * `explicit` (a declared `@smrt({ conflictColumns })`) always wins; otherwise\n * the strategy default, tenant-led when `tenantColumn` is given.\n */\nexport function resolveConflictColumns(options: {\n explicit?: readonly string[] | null;\n strategy: ConflictTableStrategy;\n tenantColumn?: string | null;\n}): string[] {\n if (options.explicit && options.explicit.length > 0) {\n return [...options.explicit];\n }\n return defaultConflictColumns(options.strategy, options.tenantColumn);\n}\n\nfunction sameColumns(a: readonly string[], b: readonly string[]): boolean {\n return a.length === b.length && a.every((column, i) => column === b[i]);\n}\n\n/**\n * Whether `conflictColumns` is exactly a default natural key (CTI or STI),\n * optionally led by `tenantColumn`. Used to keep the default index names\n * stable when the tenant column is prepended.\n */\nexport function isDefaultNaturalKey(\n conflictColumns: readonly string[],\n tenantColumn?: string | null,\n): boolean {\n const key =\n tenantColumn && conflictColumns[0] === tenantColumn\n ? conflictColumns.slice(1)\n : conflictColumns;\n return (\n sameColumns(key, DEFAULT_CTI_CONFLICT_COLUMNS) ||\n sameColumns(key, DEFAULT_STI_CONFLICT_COLUMNS)\n );\n}\n\n/**\n * The stable name of the unique conflict index for `conflictColumns`.\n *\n * - default CTI key `(slug, context)` → `<table>_slug_context_idx`\n * - default STI key `(slug, context, _meta_type)` →\n * `<table>_slug_context_meta_type_idx`\n * - either default led by the tenant column → the SAME name as without it\n * (#2360: the differ swaps the columns in place by name)\n * - any custom key → `<table>_<first two columns>_idx` (the historical rule;\n * a longer key keeps the two-column name so existing databases are not\n * renamed)\n *\n * @param tenantColumn - the table's tenant column, when the schema owner is\n * tenant-scoped; only consulted to recognize a tenant-led default key\n */\nexport function conflictIndexName(\n tableName: string,\n conflictColumns: readonly string[],\n tenantColumn?: string | null,\n): string {\n const key =\n tenantColumn &&\n conflictColumns[0] === tenantColumn &&\n isDefaultNaturalKey(conflictColumns, tenantColumn)\n ? conflictColumns.slice(1)\n : conflictColumns;\n if (sameColumns(key, DEFAULT_STI_CONFLICT_COLUMNS)) {\n return `${tableName}_slug_context_meta_type_idx`;\n }\n const nameColumns = key.length > 2 ? key.slice(0, 2) : key;\n return `${tableName}_${nameColumns.join('_')}_idx`;\n}\n\n/**\n * Whether an unqualified index over `indexColumns` serves slug lookups\n * (`loadFromSlug()` / `getId()` / `getSavedId()` filter on `slug`, `context`):\n * it leads with `slug`, or it is the tenant-led default key — a tenant-scoped\n * lookup carries the tenant predicate (#2365) and is served by the prefix.\n */\nexport function servesSlugLookup(\n indexColumns: readonly string[],\n tenantColumn?: string | null,\n): boolean {\n if (indexColumns[0] === 'slug') return true;\n return Boolean(\n tenantColumn &&\n indexColumns[0] === tenantColumn &&\n indexColumns[1] === 'slug' &&\n indexColumns[2] === 'context',\n );\n}\n\n/**\n * The tenant column of a table, from the schema-owning class's normalized\n * tenant-scoped configuration. Returns `undefined` when the class is not\n * tenant-scoped or the configured field is not among its fields (the field is\n * always injected for tenant-scoped classes; the guard keeps the runtime and\n * build paths honest about the column actually existing).\n *\n * @param tenantField - the configured tenant field name (`tenantScoped.field`,\n * default `tenantId`), or `undefined` when the class is not tenant-scoped\n * @param hasField - whether the schema owner declares that field\n * @param toColumn - field-name → column-name conversion (`toSnakeCase`)\n */\nexport function resolveTenantColumn(\n tenantField: string | undefined | null,\n hasField: (fieldName: string) => boolean,\n toColumn: (fieldName: string) => string,\n): string | undefined {\n if (!tenantField || !hasField(tenantField)) return undefined;\n return toColumn(tenantField);\n}\n\n/** Only the framework conflict identity opts into NULL-equal uniqueness. */\nexport function nullableConflictIdentity(\n conflictColumns: readonly string[],\n columns: Record<\n string,\n { notNull?: boolean; primaryKey?: boolean } | undefined\n >,\n): boolean {\n return conflictColumns.some((name) => {\n const column = columns[name];\n return column !== undefined && !column.notNull && !column.primaryKey;\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAa,+BAAkD,CAC7D,QACA,SACF;;;;;AAMA,IAAa,+BAAkD;CAC7D;CACA;CACA;AACF;;;;;AAQA,SAAgB,uBACd,UACA,cACU;CACV,MAAM,aACJ,aAAa,QACT,CAAC,GAAG,4BAA4B,IAChC,CAAC,GAAG,4BAA4B;CACtC,OAAO,eAAe,CAAC,cAAc,GAAG,UAAU,IAAI;AACxD;;;;;;;AAQA,SAAgB,uBAAuB,SAI1B;CACX,IAAI,QAAQ,YAAY,QAAQ,SAAS,SAAS,GAChD,OAAO,CAAC,GAAG,QAAQ,QAAQ;CAE7B,OAAO,uBAAuB,QAAQ,UAAU,QAAQ,YAAY;AACtE;AAEA,SAAS,YAAY,GAAsB,GAA+B;CACxE,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,QAAQ,MAAM,WAAW,EAAE,EAAE;AACxE;;;;;;AAOA,SAAgB,oBACd,iBACA,cACS;CACT,MAAM,MACJ,gBAAgB,gBAAgB,OAAO,eACnC,gBAAgB,MAAM,CAAC,IACvB;CACN,OACE,YAAY,KAAK,4BAA4B,KAC7C,YAAY,KAAK,4BAA4B;AAEjD;;;;;;;;;;;;;;;;AAiBA,SAAgB,kBACd,WACA,iBACA,cACQ;CACR,MAAM,MACJ,gBACA,gBAAgB,OAAO,gBACvB,oBAAoB,iBAAiB,YAAY,IAC7C,gBAAgB,MAAM,CAAC,IACvB;CACN,IAAI,YAAY,KAAK,4BAA4B,GAC/C,OAAO,GAAG,UAAU;CAGtB,OAAO,GAAG,UAAU,IADA,IAAI,SAAS,IAAI,IAAI,MAAM,GAAG,CAAC,IAAI,IAAA,CACpB,KAAK,GAAG,EAAE;AAC/C;;;;;;;AAQA,SAAgB,iBACd,cACA,cACS;CACT,IAAI,aAAa,OAAO,QAAQ,OAAO;CACvC,OAAO,QACL,gBACE,aAAa,OAAO,gBACpB,aAAa,OAAO,UACpB,aAAa,OAAO,SACxB;AACF;;;;;;;;;;;;;AAcA,SAAgB,oBACd,aACA,UACA,UACoB;CACpB,IAAI,CAAC,eAAe,CAAC,SAAS,WAAW,GAAG,OAAO,KAAA;CACnD,OAAO,SAAS,WAAW;AAC7B;;AAGA,SAAgB,yBACd,iBACA,SAIS;CACT,OAAO,gBAAgB,MAAM,SAAS;EACpC,MAAM,SAAS,QAAQ;EACvB,OAAO,WAAW,KAAA,KAAa,CAAC,OAAO,WAAW,CAAC,OAAO;CAC5D,CAAC;AACH"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IndexDefinition } from '../types.js';
|
|
2
|
+
/** Identifies version-gated, transaction-only framework index DDL to the planner. */
|
|
3
|
+
export declare const NULL_EQUAL_INDEX_MARKER = "-- smrt:null-equal-conflict-index";
|
|
4
|
+
export declare function renderNullEqualConflictIndex(tableName: string, index: IndexDefinition): string;
|
|
5
|
+
//# sourceMappingURL=null-equal-index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"null-equal-index.d.ts","sourceRoot":"","sources":["../../../src/schema/ddl/null-equal-index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,qFAAqF;AACrF,eAAO,MAAM,uBAAuB,sCAAsC,CAAC;AAE3E,wBAAgB,4BAA4B,CAC1C,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,eAAe,GACrB,MAAM,CAmBR"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { quoteIdentifier, quoteStringLiteral } from "../sql-identifiers.js";
|
|
2
|
+
//#region src/schema/ddl/null-equal-index.ts
|
|
3
|
+
/** Identifies version-gated, transaction-only framework index DDL to the planner. */
|
|
4
|
+
var NULL_EQUAL_INDEX_MARKER = "-- smrt:null-equal-conflict-index";
|
|
5
|
+
function renderNullEqualConflictIndex(tableName, index) {
|
|
6
|
+
if (!index.nullsNotDistinct || !index.unique || index.where || index.jsonPath || !index.columns.length) throw new Error(`Invalid NULL-equal conflict index ${index.name}: requires a full unique column index.`);
|
|
7
|
+
const create = `CREATE UNIQUE INDEX IF NOT EXISTS ${quoteIdentifier(index.name)} ON ${quoteIdentifier(tableName)} (${index.columns.map(quoteIdentifier).join(", ")})`;
|
|
8
|
+
const body = `BEGIN\n IF current_setting('server_version_num')::integer >= 150000 THEN\n EXECUTE ${quoteStringLiteral(`${create} NULLS NOT DISTINCT`)};\n ELSE\n EXECUTE ${quoteStringLiteral(create)};\n END IF;\nEND;`;
|
|
9
|
+
let suffix = 0;
|
|
10
|
+
let delimiter = "$smrt_null_equal$";
|
|
11
|
+
while (body.includes(delimiter)) delimiter = `$smrt_null_equal_${++suffix}$`;
|
|
12
|
+
return `${NULL_EQUAL_INDEX_MARKER}\nDO ${delimiter}\n${body}\n${delimiter};`;
|
|
13
|
+
}
|
|
14
|
+
//#endregion
|
|
15
|
+
export { NULL_EQUAL_INDEX_MARKER, renderNullEqualConflictIndex };
|
|
16
|
+
|
|
17
|
+
//# sourceMappingURL=null-equal-index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"null-equal-index.js","names":[],"sources":["../../../src/schema/ddl/null-equal-index.ts"],"sourcesContent":["import { quoteIdentifier, quoteStringLiteral } from '../sql-identifiers.js';\nimport type { IndexDefinition } from '../types.js';\n\n/** Identifies version-gated, transaction-only framework index DDL to the planner. */\nexport const NULL_EQUAL_INDEX_MARKER = '-- smrt:null-equal-conflict-index';\n\nexport function renderNullEqualConflictIndex(\n tableName: string,\n index: IndexDefinition,\n): string {\n if (\n !index.nullsNotDistinct ||\n !index.unique ||\n index.where ||\n index.jsonPath ||\n !index.columns.length\n ) {\n throw new Error(\n `Invalid NULL-equal conflict index ${index.name}: requires a full unique column index.`,\n );\n }\n const create = `CREATE UNIQUE INDEX IF NOT EXISTS ${quoteIdentifier(index.name)} ON ${quoteIdentifier(tableName)} (${index.columns.map(quoteIdentifier).join(', ')})`;\n // Dynamic SQL ensures PostgreSQL <15 never parses the unsupported clause.\n const body = `BEGIN\\n IF current_setting('server_version_num')::integer >= 150000 THEN\\n EXECUTE ${quoteStringLiteral(`${create} NULLS NOT DISTINCT`)};\\n ELSE\\n EXECUTE ${quoteStringLiteral(create)};\\n END IF;\\nEND;`;\n let suffix = 0;\n let delimiter = '$smrt_null_equal$';\n while (body.includes(delimiter)) delimiter = `$smrt_null_equal_${++suffix}$`;\n return `${NULL_EQUAL_INDEX_MARKER}\\nDO ${delimiter}\\n${body}\\n${delimiter};`;\n}\n"],"mappings":";;;AAIA,IAAa,0BAA0B;AAEvC,SAAgB,6BACd,WACA,OACQ;CACR,IACE,CAAC,MAAM,oBACP,CAAC,MAAM,UACP,MAAM,SACN,MAAM,YACN,CAAC,MAAM,QAAQ,QAEf,MAAM,IAAI,MACR,qCAAqC,MAAM,KAAK,uCAClD;CAEF,MAAM,SAAS,qCAAqC,gBAAgB,MAAM,IAAI,EAAE,MAAM,gBAAgB,SAAS,EAAE,IAAI,MAAM,QAAQ,IAAI,eAAe,CAAC,CAAC,KAAK,IAAI,EAAE;CAEnK,MAAM,OAAO,0FAA0F,mBAAmB,GAAG,OAAO,oBAAoB,EAAE,yBAAyB,mBAAmB,MAAM,EAAE;CAC9M,IAAI,SAAS;CACb,IAAI,YAAY;CAChB,OAAO,KAAK,SAAS,SAAS,GAAG,YAAY,oBAAoB,EAAE,OAAO;CAC1E,OAAO,GAAG,wBAAwB,OAAO,UAAU,IAAI,KAAK,IAAI,UAAU;AAC5E"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { SQLDataType, TriggerDefinition } from '../types.js';
|
|
1
|
+
import { SchemaDefinition, SQLDataType, TriggerDefinition } from '../types.js';
|
|
2
2
|
import { BaseDDLStrategy } from './base-strategy.js';
|
|
3
3
|
import { DatabaseEngine } from './types.js';
|
|
4
4
|
export declare class PostgresStrategy extends BaseDDLStrategy {
|
|
5
5
|
readonly engine: DatabaseEngine;
|
|
6
|
+
generateIndexes(schema: SchemaDefinition): string[];
|
|
6
7
|
/**
|
|
7
8
|
* Map types for PostgreSQL
|
|
8
9
|
* - JSON → JSONB (more efficient, supports indexing)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-strategy.d.ts","sourceRoot":"","sources":["../../../src/schema/ddl/postgres-strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"postgres-strategy.d.ts","sourceRoot":"","sources":["../../../src/schema/ddl/postgres-strategy.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAGH,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAErD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,qBAAa,gBAAiB,SAAQ,eAAe;IACnD,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAc;IAE7C,eAAe,CAAC,MAAM,EAAE,gBAAgB,GAAG,MAAM,EAAE;IAQnD;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,WAAW,GAAG,MAAM;IAsBlC;;;;;OAKG;IACH,SAAS,CAAC,wBAAwB,CAChC,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,iBAAiB,GACzB,MAAM;IAsDT;;OAEG;IACH,gBAAgB,IAAI,OAAO;IAI3B;;;OAGG;IACH,oBAAoB,IAAI,OAAO;CAGhC"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { shortenIdentifier } from "../index-utils.js";
|
|
2
2
|
import { BaseDDLStrategy } from "./base-strategy.js";
|
|
3
|
+
import { renderNullEqualConflictIndex } from "./null-equal-index.js";
|
|
3
4
|
//#region src/schema/ddl/postgres-strategy.ts
|
|
4
5
|
/**
|
|
5
6
|
* PostgreSQL DDL Strategy
|
|
@@ -13,6 +14,12 @@ import { BaseDDLStrategy } from "./base-strategy.js";
|
|
|
13
14
|
*/
|
|
14
15
|
var PostgresStrategy = class extends BaseDDLStrategy {
|
|
15
16
|
engine = "postgres";
|
|
17
|
+
generateIndexes(schema) {
|
|
18
|
+
return (schema.indexes ?? []).flatMap((index) => index.nullsNotDistinct ? [renderNullEqualConflictIndex(schema.tableName, index)] : super.generateIndexes({
|
|
19
|
+
...schema,
|
|
20
|
+
indexes: [index]
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
16
23
|
/**
|
|
17
24
|
* Map types for PostgreSQL
|
|
18
25
|
* - JSON → JSONB (more efficient, supports indexing)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-strategy.js","names":[],"sources":["../../../src/schema/ddl/postgres-strategy.ts"],"sourcesContent":["/**\n * PostgreSQL DDL Strategy\n *\n * PostgreSQL-specific DDL generation with the following characteristics:\n * - JSONB type for JSON columns (more efficient than JSON)\n * - Native BOOLEAN type\n * - Full trigger support with PL/pgSQL functions\n * - UNIQUE can be inline or separate indexes\n * - Supports CAST in DEFAULT values\n */\n\nimport { shortenIdentifier } from '../index-utils.js';\nimport type {
|
|
1
|
+
{"version":3,"file":"postgres-strategy.js","names":[],"sources":["../../../src/schema/ddl/postgres-strategy.ts"],"sourcesContent":["/**\n * PostgreSQL DDL Strategy\n *\n * PostgreSQL-specific DDL generation with the following characteristics:\n * - JSONB type for JSON columns (more efficient than JSON)\n * - Native BOOLEAN type\n * - Full trigger support with PL/pgSQL functions\n * - UNIQUE can be inline or separate indexes\n * - Supports CAST in DEFAULT values\n */\n\nimport { shortenIdentifier } from '../index-utils.js';\nimport type {\n SchemaDefinition,\n SQLDataType,\n TriggerDefinition,\n} from '../types.js';\nimport { BaseDDLStrategy } from './base-strategy.js';\nimport { renderNullEqualConflictIndex } from './null-equal-index.js';\nimport type { DatabaseEngine } from './types.js';\n\nexport class PostgresStrategy extends BaseDDLStrategy {\n readonly engine: DatabaseEngine = 'postgres';\n\n generateIndexes(schema: SchemaDefinition): string[] {\n return (schema.indexes ?? []).flatMap((index) =>\n index.nullsNotDistinct\n ? [renderNullEqualConflictIndex(schema.tableName, index)]\n : super.generateIndexes({ ...schema, indexes: [index] }),\n );\n }\n\n /**\n * Map types for PostgreSQL\n * - JSON → JSONB (more efficient, supports indexing)\n * - TIMESTAMP → TIMESTAMP WITH TIME ZONE (best practice)\n */\n mapType(type: SQLDataType): string {\n switch (type) {\n case 'INTEGER':\n return 'BIGINT';\n case 'BLOB':\n return 'BYTEA';\n case 'JSON':\n return 'JSONB'; // PostgreSQL JSONB is more efficient\n case 'TIMESTAMP':\n // JavaScript Date represents an instant. Preserve that contract in\n // PostgreSQL instead of discarding the ISO offset in a timezone-naive\n // TIMESTAMP column and reinterpreting the wall time at hydration.\n return 'TIMESTAMPTZ';\n case 'REAL':\n return 'DOUBLE PRECISION'; // PostgreSQL convention\n case 'UUID':\n return 'uuid'; // Native 16-byte uuid (R11) — vs 37-byte text\n default:\n return super.mapType(type);\n }\n }\n\n /**\n * Generate trigger for PostgreSQL\n *\n * PostgreSQL triggers require a separate function, then the trigger.\n * For updated_at timestamps, we generate both.\n */\n protected generateTriggerStatement(\n tableName: string,\n trigger: TriggerDefinition,\n ): string {\n // For simple triggers, we need to create a function first\n // This is PostgreSQL's two-step trigger process\n\n // Check if this is an updated_at trigger\n if (trigger.name.includes('updated_at')) {\n // Generate the function and trigger for updated_at. The function name is\n // a PostgreSQL identifier like any other, so it is subject to the same\n // 63-byte limit — and unlike an index it is *referenced* by the trigger\n // below, so a truncation that CREATE FUNCTION accepts would leave\n // EXECUTE FUNCTION pointing at a name PostgreSQL never stored (#2374).\n const functionName = shortenIdentifier(`update_${tableName}_updated_at`);\n\n let sql = `-- Function for ${trigger.name}\\n`;\n sql += `CREATE OR REPLACE FUNCTION ${functionName}()\\n`;\n sql += `RETURNS TRIGGER AS $$\\n`;\n sql += `BEGIN\\n`;\n sql += ` NEW.updated_at = CURRENT_TIMESTAMP;\\n`;\n sql += ` RETURN NEW;\\n`;\n sql += `END;\\n`;\n sql += `$$ LANGUAGE plpgsql;\\n\\n`;\n\n sql += `-- Trigger\\n`;\n sql += `DROP TRIGGER IF EXISTS \"${trigger.name}\" ON \"${tableName}\";\\n`;\n sql += `CREATE TRIGGER \"${trigger.name}\"\\n`;\n sql += `${trigger.when} ${trigger.event} ON \"${tableName}\"\\n`;\n sql += `FOR EACH ROW\\n`;\n sql += `EXECUTE FUNCTION ${functionName}();`;\n\n return sql;\n }\n\n // For custom triggers, use the provided body\n let sql = `DROP TRIGGER IF EXISTS \"${trigger.name}\" ON \"${tableName}\";\\n`;\n sql += `CREATE TRIGGER \"${trigger.name}\"\\n`;\n sql += `${trigger.when} ${trigger.event} ON \"${tableName}\"\\n`;\n sql += `FOR EACH ROW\\n`;\n\n if (trigger.condition) {\n sql += `WHEN (${trigger.condition})\\n`;\n }\n\n // PostgreSQL triggers need EXECUTE FUNCTION or EXECUTE PROCEDURE\n // If body contains a function call, use it directly\n if (trigger.body.includes('EXECUTE')) {\n sql += trigger.body;\n } else {\n // Wrap in anonymous DO block or assume it's a function name\n sql += `EXECUTE FUNCTION ${trigger.body}`;\n }\n\n return `${sql};`;\n }\n\n /**\n * PostgreSQL supports triggers\n */\n supportsTriggers(): boolean {\n return true;\n }\n\n /**\n * PostgreSQL doesn't require inline UNIQUE for UPSERT\n * Both inline and separate indexes work with ON CONFLICT\n */\n requiresInlineUnique(): boolean {\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,IAAa,mBAAb,cAAsC,gBAAgB;CACpD,SAAkC;CAElC,gBAAgB,QAAoC;EAClD,QAAQ,OAAO,WAAW,CAAC,EAAA,CAAG,SAAS,UACrC,MAAM,mBACF,CAAC,6BAA6B,OAAO,WAAW,KAAK,CAAC,IACtD,MAAM,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":["../../src/schema/generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,SAAS,EAGT,cAAc,EACd,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"generator.d.ts","sourceRoot":"","sources":["../../src/schema/generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EACV,eAAe,EACf,SAAS,EAGT,cAAc,EACd,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAW7B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAWrD,OAAO,KAAK,EAEV,uBAAuB,EAGvB,gBAAgB,EAEjB,MAAM,YAAY,CAAC;AAEpB;;;;;;;;;;GAUG;AACH,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,SAAS,CAAC,WAAW,CAAC,CAAC;IACnC,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AASD,KAAK,qBAAqB,GAAG;IAC3B;;;;;;OAMG;IACH,eAAe,CAAC,EAAE,MAAM,EAAE,CAAC;IAC3B;;;;OAIG;IACH,YAAY,CAAC,EAAE,OAAO,GAAG;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC5C,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACzB;;;;;;;OAOG;IACH,OAAO,CAAC,EAAE,uBAAuB,EAAE,CAAC;IACpC,QAAQ,CAAC,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AAW,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EAC5C,QAAQ,EAAE,mBAAmB,EAC7B,MAAM,CAAC,EAAE,qBAAqB,GAC7B,cAAc;IAoQjB;;;;;;;OAOG;IACH,6BAA6B,CAC3B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,EACvC,MAAM,CAAC,EAAE,qBAAqB,GAC7B,cAAc;IAsMjB;;;;;OAKG;IACH,OAAO,CAAC,uBAAuB;IAgB/B;;;;;;;;OAQG;IACH,OAAO,CAAC,yBAAyB;IAyCjC;;OAEG;IACH,OAAO,CAAC,qCAAqC;IAoB7C;;OAEG;IACH,OAAO,CAAC,WAAW;IAOnB;;;;;;;;;;;;;;OAcG;IACH,WAAW,CAAC,MAAM,EAAE,gBAAgB,EAAE,MAAM,CAAC,EAAE,cAAc,GAAG,MAAM;IAsCtE;;;;;;;;;OASG;IACH,OAAO,CAAC,kBAAkB;CAW3B"}
|
package/dist/schema/generator.js
CHANGED
|
@@ -3,7 +3,7 @@ import { classnameToTablename } from "../utils/naming.js";
|
|
|
3
3
|
import { formatDefaultValue, quoteIdentifier, quoteStringLiteral } from "./sql-identifiers.js";
|
|
4
4
|
import { assertIdentifierFits, enforceIdentifierLimits } from "./index-utils.js";
|
|
5
5
|
import { getDDLStrategy } from "./ddl/index.js";
|
|
6
|
-
import { conflictIndexName, resolveConflictColumns, resolveTenantColumn, servesSlugLookup } from "./conflict-target.js";
|
|
6
|
+
import { conflictIndexName, nullableConflictIdentity, resolveConflictColumns, resolveTenantColumn, servesSlugLookup } from "./conflict-target.js";
|
|
7
7
|
import { createHash } from "node:crypto";
|
|
8
8
|
//#region src/schema/generator.ts
|
|
9
9
|
/**
|
|
@@ -472,7 +472,8 @@ var SchemaGenerator = class {
|
|
|
472
472
|
indexes.push({
|
|
473
473
|
name: conflictIndexName(tableName, conflictColumns, tenantColumn),
|
|
474
474
|
columns: conflictColumns,
|
|
475
|
-
unique: true
|
|
475
|
+
unique: true,
|
|
476
|
+
...nullableConflictIdentity(conflictColumns, columns) ? { nullsNotDistinct: true } : {}
|
|
476
477
|
});
|
|
477
478
|
}
|
|
478
479
|
/**
|
|
@@ -658,6 +659,7 @@ var SchemaGenerator = class {
|
|
|
658
659
|
name: conflictIndexName(tableName, conflictColumns, tenantColumn),
|
|
659
660
|
columns: conflictColumns,
|
|
660
661
|
unique: true,
|
|
662
|
+
...nullableConflictIdentity(conflictColumns, columns) ? { nullsNotDistinct: true } : {},
|
|
661
663
|
description: `Unique conflict index for ${className}`
|
|
662
664
|
});
|
|
663
665
|
}
|
|
@@ -1003,6 +1005,7 @@ var SchemaGenerator = class {
|
|
|
1003
1005
|
name: idx.name,
|
|
1004
1006
|
columns: idx.columns,
|
|
1005
1007
|
unique: idx.unique,
|
|
1008
|
+
...idx.nullsNotDistinct ? { nullsNotDistinct: true } : {},
|
|
1006
1009
|
where: idx.where,
|
|
1007
1010
|
jsonPath: idx.jsonPath
|
|
1008
1011
|
})),
|
|
@@ -1081,7 +1084,8 @@ var SchemaGenerator = class {
|
|
|
1081
1084
|
if (!this.conflictColumnsArePrimaryKey(conflictColumns, columns)) indexes.push({
|
|
1082
1085
|
name: conflictIndexName(tableName, conflictColumns, tenantColumn),
|
|
1083
1086
|
columns: conflictColumns,
|
|
1084
|
-
unique: true
|
|
1087
|
+
unique: true,
|
|
1088
|
+
...nullableConflictIdentity(conflictColumns, columns) ? { nullsNotDistinct: true } : {}
|
|
1085
1089
|
});
|
|
1086
1090
|
this.ensureSlugLookupIndex(indexes, columns, tableName);
|
|
1087
1091
|
for (const colName of indexedColumns) indexes.push({
|
|
@@ -1100,6 +1104,7 @@ var SchemaGenerator = class {
|
|
|
1100
1104
|
name: idx.name,
|
|
1101
1105
|
columns: idx.columns,
|
|
1102
1106
|
unique: idx.unique,
|
|
1107
|
+
...idx.nullsNotDistinct ? { nullsNotDistinct: true } : {},
|
|
1103
1108
|
where: idx.where,
|
|
1104
1109
|
jsonPath: idx.jsonPath
|
|
1105
1110
|
})),
|