@prisma-next/family-sql 0.14.0 → 0.15.0-dev.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/{authoring-type-constructors-CjFfO6LM.mjs → authoring-type-constructors-CXd-8ydc.mjs} +7 -30
  2. package/dist/authoring-type-constructors-CXd-8ydc.mjs.map +1 -0
  3. package/dist/{control-adapter-Cmw9LvEP.d.mts → control-adapter-BQgad8Zc.d.mts} +30 -8
  4. package/dist/control-adapter-BQgad8Zc.d.mts.map +1 -0
  5. package/dist/control-adapter.d.mts +1 -1
  6. package/dist/control.d.mts +279 -34
  7. package/dist/control.d.mts.map +1 -1
  8. package/dist/control.mjs +364 -1005
  9. package/dist/control.mjs.map +1 -1
  10. package/dist/diff.d.mts +102 -0
  11. package/dist/diff.d.mts.map +1 -0
  12. package/dist/diff.mjs +14 -0
  13. package/dist/diff.mjs.map +1 -0
  14. package/dist/ir.d.mts +26 -9
  15. package/dist/ir.d.mts.map +1 -1
  16. package/dist/ir.mjs +2 -2
  17. package/dist/ir.mjs.map +1 -1
  18. package/dist/migration.d.mts +11 -2
  19. package/dist/migration.d.mts.map +1 -1
  20. package/dist/migration.mjs +7 -0
  21. package/dist/migration.mjs.map +1 -1
  22. package/dist/pack.mjs +1 -1
  23. package/dist/psl-infer.d.mts +119 -0
  24. package/dist/psl-infer.d.mts.map +1 -0
  25. package/dist/psl-infer.mjs +366 -0
  26. package/dist/psl-infer.mjs.map +1 -0
  27. package/dist/schema-differ-DnoopSXm.d.mts +45 -0
  28. package/dist/schema-differ-DnoopSXm.d.mts.map +1 -0
  29. package/dist/schema-verify-W3r631Jh.mjs +226 -0
  30. package/dist/schema-verify-W3r631Jh.mjs.map +1 -0
  31. package/dist/{sql-contract-serializer-BR2vC7Z-.mjs → sql-contract-serializer-C75cfMSS.mjs} +46 -20
  32. package/dist/sql-contract-serializer-C75cfMSS.mjs.map +1 -0
  33. package/dist/{types-kgstZ_Zd.d.mts → types-BPv_y7iS.d.mts} +36 -142
  34. package/dist/types-BPv_y7iS.d.mts.map +1 -0
  35. package/package.json +26 -26
  36. package/src/core/authoring-entity-types.ts +12 -37
  37. package/src/core/control-adapter.ts +11 -5
  38. package/src/core/control-instance.ts +212 -42
  39. package/src/core/control-target-descriptor.ts +98 -0
  40. package/src/core/diff/schema-verify.ts +324 -0
  41. package/src/core/diff/sql-schema-diff.ts +41 -0
  42. package/src/core/diff/verifier-disposition.ts +30 -0
  43. package/src/core/ir/sql-contract-serializer-base.ts +70 -56
  44. package/src/core/ir/sql-contract-serializer.ts +5 -7
  45. package/src/core/ir/sql-schema-verifier-base.ts +5 -5
  46. package/src/core/migrations/contract-to-schema-ir.ts +137 -51
  47. package/src/core/migrations/control-policy.ts +66 -115
  48. package/src/core/migrations/field-event-planner.ts +2 -2
  49. package/src/core/migrations/native-type-expander.ts +28 -0
  50. package/src/core/migrations/schema-differ.ts +41 -0
  51. package/src/core/migrations/types.ts +33 -37
  52. package/src/core/psl-contract-infer/name-transforms.ts +15 -0
  53. package/src/core/psl-contract-infer/printer-config.ts +14 -6
  54. package/src/core/psl-contract-infer/relation-inference.ts +30 -1
  55. package/src/core/sql-migration.ts +12 -1
  56. package/src/exports/control.ts +12 -2
  57. package/src/exports/diff.ts +25 -0
  58. package/src/exports/psl-infer.ts +40 -0
  59. package/dist/authoring-type-constructors-CjFfO6LM.mjs.map +0 -1
  60. package/dist/control-adapter-Cmw9LvEP.d.mts.map +0 -1
  61. package/dist/schema-verify.d.mts +0 -39
  62. package/dist/schema-verify.d.mts.map +0 -1
  63. package/dist/schema-verify.mjs +0 -2
  64. package/dist/sql-contract-serializer-BR2vC7Z-.mjs.map +0 -1
  65. package/dist/test-utils.d.mts +0 -2
  66. package/dist/test-utils.mjs +0 -2
  67. package/dist/types-kgstZ_Zd.d.mts.map +0 -1
  68. package/dist/verify-sql-schema-thU-jKpf.d.mts +0 -66
  69. package/dist/verify-sql-schema-thU-jKpf.d.mts.map +0 -1
  70. package/dist/verify-sql-schema-xT4udQLQ.mjs +0 -1501
  71. package/dist/verify-sql-schema-xT4udQLQ.mjs.map +0 -1
  72. package/src/core/psl-contract-infer/postgres-default-mapping.ts +0 -16
  73. package/src/core/psl-contract-infer/postgres-type-map.ts +0 -157
  74. package/src/core/psl-contract-infer/sql-schema-ir-to-psl-ast.ts +0 -795
  75. package/src/core/schema-verify/control-verify-emit.ts +0 -46
  76. package/src/core/schema-verify/verifier-disposition.ts +0 -58
  77. package/src/core/schema-verify/verify-helpers.ts +0 -820
  78. package/src/core/schema-verify/verify-sql-schema.ts +0 -1311
  79. package/src/exports/schema-verify.ts +0 -18
  80. package/src/exports/test-utils.ts +0 -9
@@ -0,0 +1,102 @@
1
+ import { a as NativeTypeNormalizer, o as arraysEqual } from "./control-adapter-BQgad8Zc.mjs";
2
+ import { n as CodecControlHooks } from "./types-BPv_y7iS.mjs";
3
+ import { t as SqlSchemaDiffFn } from "./schema-differ-DnoopSXm.mjs";
4
+ import { DiffSubjectGranularity, SchemaDiffIssue, VerifierIssueCategory, VerifyDatabaseSchemaResult } from "@prisma-next/framework-components/control";
5
+ import { Contract, ControlPolicy } from "@prisma-next/contract/types";
6
+ import { SqlStorage } from "@prisma-next/sql-contract/types";
7
+ import { SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
8
+ import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
9
+
10
+ //#region src/core/diff/schema-verify.d.ts
11
+ /**
12
+ * Resolves an issue's framework-neutral {@link DiffSubjectGranularity} on
13
+ * demand, from the issue's node's `nodeKind` via the target-provided
14
+ * `granularityOf` map. The node carries only its `nodeKind` identity, never a
15
+ * classification, and nothing is stamped onto the issue — every consumer
16
+ * (the family verdict below, the framework aggregate's unclaimed-elements
17
+ * sweep via {@link import('@prisma-next/framework-components/control').SchemaSubjectClassifierCapable})
18
+ * calls this the same way, resolved by the family/target that owns the node
19
+ * vocabulary. `undefined` for an issue with no node.
20
+ */
21
+ declare function classifyDiffSubjectGranularity(issue: SchemaDiffIssue, granularityOf: (nodeKind: string) => DiffSubjectGranularity): DiffSubjectGranularity | undefined;
22
+ /**
23
+ * Re-keys the legacy `classifySqlVerifierIssueKind` category mapping on the
24
+ * issue's {@link DiffSubjectGranularity} (resolved via `granularityOf`) + the
25
+ * issue reason. The vocabulary maps one-to-one: an undeclared live entity or
26
+ * namespace is `extraTopLevelObject`, an undeclared live field
27
+ * `extraNestedElement`, undeclared auxiliaries (constraints, indexes,
28
+ * defaults) and structural leaves (policies) `extraAuxiliary`; a value-set
29
+ * drift on a check node is `valueDrift`; every other paired divergence is
30
+ * `declaredIncompatible`; anything the database lacks is `declaredMissing`.
31
+ * `granularityOf` is the target's classifier, so target and extension node
32
+ * kinds classify without the family importing them.
33
+ */
34
+ declare function classifySqlDiffIssue(issue: SchemaDiffIssue, granularityOf: (nodeKind: string) => DiffSubjectGranularity): VerifierIssueCategory;
35
+ interface SqlDiffVerdictInput {
36
+ /** The full, ownership-scoped diff issue list from the target's differ. */
37
+ readonly issues: readonly SchemaDiffIssue[];
38
+ /** Resolves a diff issue's subject table's declared control policy directly from the contract. */
39
+ readonly resolveControlPolicy: (issue: SchemaDiffIssue) => ControlPolicy | undefined;
40
+ readonly strict: boolean;
41
+ readonly defaultControlPolicy: ControlPolicy | undefined;
42
+ /** The target's classifier: a diff issue node's `nodeKind` → its subject granularity. */
43
+ readonly granularityOf: (nodeKind: string) => DiffSubjectGranularity;
44
+ }
45
+ interface SqlDiffVerdict {
46
+ readonly failures: readonly SchemaDiffIssue[];
47
+ readonly warnings: readonly SchemaDiffIssue[];
48
+ }
49
+ /**
50
+ * Applies the two consumer filters to a diff issue list: strict gating
51
+ * (relational `not-expected` findings drop in lenient mode) and
52
+ * control-policy disposition (each surviving issue grades against its
53
+ * subject table's effective policy; suppressed issues drop, `observed`
54
+ * subjects warn). The verify verdict is `failures.length === 0`.
55
+ */
56
+ declare function computeSqlDiffVerdict(input: SqlDiffVerdictInput): SqlDiffVerdict;
57
+ interface StorageTypeVerdictInput {
58
+ readonly contract: Contract<SqlStorage>;
59
+ /**
60
+ * Expected/actual namespace-node pairs the target's differ input produced:
61
+ * for a namespaced tree, one entry per expected namespace with a
62
+ * non-empty table set, paired by DDL schema name (absent actual side for
63
+ * a schema the database lacks); a flat tree is the sole pair.
64
+ */
65
+ readonly namespacePairs: ReadonlyArray<{
66
+ readonly actual: SqlSchemaIRNode | undefined;
67
+ }>;
68
+ readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;
69
+ }
70
+ /**
71
+ * Runs the codec `verifyType` hooks the way the legacy walk did: once per
72
+ * contract namespace with tables, against that namespace's paired actual
73
+ * node (the hook reads namespace-scoped state such as `enums` off it).
74
+ * Issue dispositions grade against the contract default policy, matching
75
+ * the legacy `pushTypeNode` semantics.
76
+ */
77
+ interface StorageTypeVerdict {
78
+ readonly failures: readonly SchemaDiffIssue[];
79
+ readonly warnings: readonly SchemaDiffIssue[];
80
+ }
81
+ declare function computeStorageTypeVerdict(input: StorageTypeVerdictInput): StorageTypeVerdict;
82
+ interface VerifySqlSchemaByDiffInput {
83
+ readonly contract: Contract<SqlStorage>;
84
+ readonly schema: SqlSchemaIRNode;
85
+ readonly strict: boolean;
86
+ readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
87
+ /** The target's full-tree node diff (`diffSchema` descriptor hook). */
88
+ readonly diffSchema: SqlSchemaDiffFn;
89
+ /** The target's classifier: a diff issue node's `nodeKind` → its subject granularity. */
90
+ readonly granularityOf: (nodeKind: string) => DiffSubjectGranularity;
91
+ }
92
+ /**
93
+ * THE SQL schema verify: runs the target's full-tree node diff, grades it
94
+ * through the family's post-diff filters (strict gating + control-policy
95
+ * disposition) plus the codec `verifyType` hook findings, and wraps the
96
+ * verdict in the issue-based result envelope. `ok` holds exactly when both
97
+ * issue lists are empty — the lists carry the verdict's failures.
98
+ */
99
+ declare function verifySqlSchemaByDiff(input: VerifySqlSchemaByDiffInput): VerifyDatabaseSchemaResult;
100
+ //#endregion
101
+ export { type NativeTypeNormalizer, type SqlDiffVerdict, type SqlDiffVerdictInput, type StorageTypeVerdict, type StorageTypeVerdictInput, type VerifySqlSchemaByDiffInput, arraysEqual, classifyDiffSubjectGranularity, classifySqlDiffIssue, computeSqlDiffVerdict, computeStorageTypeVerdict, verifySqlSchemaByDiff };
102
+ //# sourceMappingURL=diff.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.d.mts","names":[],"sources":["../src/core/diff/schema-verify.ts"],"mappings":";;;;;;;;;;;;;;AA6DyB;AAsCzB;;;;;iBAzCgB,8BAAA,CACd,KAAA,EAAO,eAAA,EACP,aAAA,GAAgB,QAAA,aAAqB,sBAAA,GACpC,sBAAA;AAqFH;;;;;;;;;;;;AAAA,iBA/CgB,oBAAA,CACd,KAAA,EAAO,eAAA,EACP,aAAA,GAAgB,QAAA,aAAqB,sBAAA,GACpC,qBAAA;AAAA,UA4Cc,mBAAA;EAIiB;EAAA,SAFvB,MAAA,WAAiB,eAAA;EAGjB;EAAA,SADA,oBAAA,GAAuB,KAAA,EAAO,eAAA,KAAoB,aAAA;EAAA,SAClD,MAAA;EAAA,SACA,oBAAA,EAAsB,aAAA;EAEN;EAAA,SAAhB,aAAA,GAAgB,QAAA,aAAqB,sBAAA;AAAA;AAAA,UAG/B,cAAA;EAAA,SACN,QAAA,WAAmB,eAAA;EAAA,SACnB,QAAA,WAAmB,eAAe;AAAA;;;;;;;AAAA;iBAU7B,qBAAA,CAAsB,KAAA,EAAO,mBAAA,GAAsB,cAAc;AAAA,UA+BhE,uBAAA;EAAA,SACN,QAAA,EAAU,QAAA,CAAS,UAAA;EAhCmD;;;;;AAAA;EAAA,SAuCtE,cAAA,EAAgB,aAAA;IAAA,SACd,MAAA,EAAQ,eAAA;EAAA;EAAA,SAEV,UAAA,EAAY,WAAA,SAAoB,iBAAA;AAAA;;;;;;;;UAU1B,kBAAA;EAAA,SACN,QAAA,WAAmB,eAAA;EAAA,SACnB,QAAA,WAAmB,eAAe;AAAA;AAAA,iBAG7B,yBAAA,CAA0B,KAAA,EAAO,uBAAA,GAA0B,kBAAkB;AAAA,UA6B5E,0BAAA;EAAA,SACN,QAAA,EAAU,QAAA,CAAS,UAAA;EAAA,SACnB,MAAA,EAAQ,eAAA;EAAA,SACR,MAAA;EAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;EAhDc;EAAA,SAkDjD,UAAA,EAAY,eAAA;EAxCY;EAAA,SA0CxB,aAAA,GAAgB,QAAA,aAAqB,sBAAA;AAAA;;;;;;AAxCH;AAG7C;iBA+CgB,qBAAA,CACd,KAAA,EAAO,0BAAA,GACN,0BAA0B"}
package/dist/diff.mjs ADDED
@@ -0,0 +1,14 @@
1
+ import { a as computeStorageTypeVerdict, i as computeSqlDiffVerdict, n as classifyDiffSubjectGranularity, o as verifySqlSchemaByDiff, r as classifySqlDiffIssue } from "./schema-verify-W3r631Jh.mjs";
2
+ //#region src/core/diff/sql-schema-diff.ts
3
+ /**
4
+ * Compares two arrays of strings for equality (order-sensitive).
5
+ */
6
+ function arraysEqual(a, b) {
7
+ if (a.length !== b.length) return false;
8
+ for (let i = 0; i < a.length; i++) if (a[i] !== b[i]) return false;
9
+ return true;
10
+ }
11
+ //#endregion
12
+ export { arraysEqual, classifyDiffSubjectGranularity, classifySqlDiffIssue, computeSqlDiffVerdict, computeStorageTypeVerdict, verifySqlSchemaByDiff };
13
+
14
+ //# sourceMappingURL=diff.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff.mjs","names":[],"sources":["../src/core/diff/sql-schema-diff.ts"],"sourcesContent":["/**\n * Shared relational-diff types and helpers. The coordinate-based issue diff\n * this module used to house (`collectSqlSchemaIssues` /\n * `collectSqlSchemaIssuesPerNamespace`) retired once the migration planner\n * took `plan(start, end)` over the one differ (`buildPostgresPlanDiff` /\n * `buildSqlitePlanDiff`); what remains here is consumed by the surviving\n * verify verdict (`schema-verify.ts`) and the control adapters.\n */\n\nimport type { ColumnDefault } from '@prisma-next/contract/types';\n\n/**\n * Function type for normalizing raw database default expressions into ColumnDefault.\n * Target-specific implementations handle database dialect differences.\n */\nexport type DefaultNormalizer = (\n rawDefault: string,\n nativeType: string,\n) => ColumnDefault | undefined;\n\n/**\n * Function type for normalizing schema native types to canonical form for comparison.\n * Target-specific implementations handle dialect-specific type name variations\n * (e.g., Postgres 'varchar' → 'character varying', 'timestamptz' normalization).\n */\nexport type NativeTypeNormalizer = (nativeType: string) => string;\n\n/**\n * Compares two arrays of strings for equality (order-sensitive).\n */\nexport function arraysEqual(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) {\n return false;\n }\n for (let i = 0; i < a.length; i++) {\n if (a[i] !== b[i]) {\n return false;\n }\n }\n return true;\n}\n"],"mappings":";;;;;AA8BA,SAAgB,YAAY,GAAsB,GAA+B;CAC/E,IAAI,EAAE,WAAW,EAAE,QACjB,OAAO;CAET,KAAK,IAAI,IAAI,GAAG,IAAI,EAAE,QAAQ,KAC5B,IAAI,EAAE,OAAO,EAAE,IACb,OAAO;CAGX,OAAO;AACT"}
package/dist/ir.d.mts CHANGED
@@ -1,7 +1,7 @@
1
- import { ContractSerializer, SchemaIssue, SchemaVerifier, SchemaVerifyOptions, SchemaVerifyResult } from "@prisma-next/framework-components/control";
1
+ import { ContractSerializer, SchemaDiffIssue, SchemaVerifier, SchemaVerifyOptions, SchemaVerifyResult } from "@prisma-next/framework-components/control";
2
2
  import { AnyEntityKindDescriptor, Namespace } from "@prisma-next/framework-components/ir";
3
- import { SqlNamespaceTablesInput, SqlStorage, SqlStorageTypeEntry } from "@prisma-next/sql-contract/types";
4
3
  import { Contract } from "@prisma-next/contract/types";
4
+ import { SqlNamespaceInput, SqlStorage, SqlStorageTypeEntry } from "@prisma-next/sql-contract/types";
5
5
  import { JsonObject } from "@prisma-next/utils/json";
6
6
 
7
7
  //#region src/core/ir/sql-contract-serializer-base.d.ts
@@ -41,11 +41,24 @@ declare abstract class SqlContractSerializerBase<TContract extends Contract<SqlS
41
41
  sortStorage: import("@prisma-next/contract/hashing").StorageSort;
42
42
  protected parseSqlContractStructure(json: unknown): Contract<SqlStorage>;
43
43
  protected hydrateSqlStorage(validated: Contract<SqlStorage>): Contract<SqlStorage>;
44
- protected abstract get defaultNamespaceId(): string;
45
- protected hydrateSqlNamespaceMap(namespaces: Readonly<Record<string, Namespace | Record<string, unknown>>>): Readonly<Record<string, Namespace>>;
46
- protected hydrateSqlNamespaceEntry(nsId: string, raw: Namespace | Record<string, unknown>): Namespace | SqlNamespaceTablesInput;
44
+ protected hydrateSqlNamespaceMap(namespaces: Readonly<Record<string, Record<string, unknown>>>): Readonly<Record<string, Namespace>>;
45
+ protected hydrateSqlNamespaceEntry(nsId: string, raw: Record<string, unknown>): Namespace | SqlNamespaceInput;
47
46
  protected hydrateStorageTypeEntry(entry: SqlStorageTypeEntry): SqlStorageTypeEntry;
48
47
  protected constructTargetContract(hydrated: Contract<SqlStorage>): TContract;
48
+ /**
49
+ * Serializes a namespace's `entries` dict by walking every enumerable
50
+ * kind — no kind is named here, mirroring the generic hydrate walk in
51
+ * `hydrateSqlNamespaceEntry` above. `table` is the SQL family's one
52
+ * universal base kind (every namespace carries it), so it is always
53
+ * emitted, even when empty; every other kind — target- or
54
+ * pack-contributed — is emitted only when it holds at least one entry.
55
+ * A kind carried non-enumerable on `entries` is excluded here for free,
56
+ * since `Object.entries` honors enumerability.
57
+ */
58
+ protected serializeNamespaceEntries(entries: Readonly<Record<string, Readonly<Record<string, unknown>>>>): Record<string, Record<string, JsonObject>>;
59
+ private serializeEntries;
60
+ protected serializeJsonObject(value: unknown): JsonObject;
61
+ private serializeJsonValue;
49
62
  }
50
63
  //#endregion
51
64
  //#region src/core/ir/sql-contract-serializer.d.ts
@@ -57,10 +70,14 @@ declare abstract class SqlContractSerializerBase<TContract extends Contract<SqlS
57
70
  * codec-typed envelope wire a target-specific subclass with a populated
58
71
  * registry (see Postgres). Family-level call sites instantiate this
59
72
  * default directly when no target serializer is supplied.
73
+ *
74
+ * Because this serializer has no target concretion, deserialization of
75
+ * contracts that include namespace entries from JSON will throw unless
76
+ * the caller provides pre-hydrated `NamespaceBase` instances. Production
77
+ * paths always supply a target-specific serializer.
60
78
  */
61
79
  declare class SqlContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {
62
80
  constructor();
63
- protected get defaultNamespaceId(): string;
64
81
  }
65
82
  //#endregion
66
83
  //#region src/core/ir/sql-schema-verifier-base.d.ts
@@ -68,7 +85,7 @@ declare class SqlContractSerializer extends SqlContractSerializerBase<Contract<S
68
85
  * SQL family `SchemaVerifier` abstract base. Centralises the SQL-shared
69
86
  * walk (table-by-table + column-by-column matching keyed by
70
87
  * `(namespace.id, name)`, FK / unique / index comparisons via the
71
- * existing helpers in `verify-helpers.ts`) and exposes a protected hook
88
+ * shared satisfaction helpers in `sql-schema-diff.ts`) and exposes a protected hook
72
89
  * for target extensions (Postgres functions, RLS policies, future
73
90
  * target-only kinds).
74
91
  *
@@ -92,13 +109,13 @@ declare abstract class SqlSchemaVerifierBase<TContract, TSchema> implements Sche
92
109
  * family-shared implementation today; a future iteration will lift
93
110
  * the shared walk into this base.
94
111
  */
95
- protected abstract verifyCommonSqlSchema(options: SchemaVerifyOptions<TContract, TSchema>): readonly SchemaIssue[];
112
+ protected abstract verifyCommonSqlSchema(options: SchemaVerifyOptions<TContract, TSchema>): readonly SchemaDiffIssue[];
96
113
  /**
97
114
  * Target-specific extensions — e.g. Postgres functions, future RLS
98
115
  * policies, namespace-mismatch issues. Returns the empty list when the
99
116
  * target ships no extensions over the SQL family alphabet.
100
117
  */
101
- protected abstract verifyTargetExtensions(options: SchemaVerifyOptions<TContract, TSchema>): readonly SchemaIssue[];
118
+ protected abstract verifyTargetExtensions(options: SchemaVerifyOptions<TContract, TSchema>): readonly SchemaDiffIssue[];
102
119
  }
103
120
  //#endregion
104
121
  export { SqlContractSerializer, SqlContractSerializerBase, type SqlEntityHydrationFactory, SqlSchemaVerifierBase };
package/dist/ir.d.mts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ir.d.mts","names":[],"sources":["../src/core/ir/sql-contract-serializer-base.ts","../src/core/ir/sql-contract-serializer.ts","../src/core/ir/sql-schema-verifier-base.ts"],"mappings":";;;;;;;KAsCY,yBAAA,IAA6B,KAAc;;AAAvD;;;;AAAuD;AA0BvD;;;;;;;;;;;;;;;;;;uBAAsB,yBAAA,mBAA4C,QAAA,CAAS,UAAA,cAC9D,kBAAA,CAAmB,SAAA;EAAA,mBAMT,uBAAA,EAAyB,WAAA,SAE1C,yBAAA;EAAA,iBANa,cAAA;EAAA,iBACA,UAAA;cAGI,uBAAA,GAAyB,WAAA,SAE1C,yBAAA,GAEF,eAAA,YAA0B,uBAAA;EAO5B,mBAAA,WAA8B,SAAA,GAAY,SAAA,EAAW,IAAA,YAAgB,CAAA;EAMrE,iBAAA,CAAkB,QAAA,EAAU,SAAA,GAAY,UAAA;EAIxC,mBAAA,0CAAmB,sBAAA;EAEnB,WAAA,0CAAW,WAAA;EAAA,UAED,yBAAA,CAA0B,IAAA,YAAgB,QAAA,CAAS,UAAA;EAAA,UAOnD,iBAAA,CAAkB,SAAA,EAAW,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA;EAAA,uBAyDhD,kBAAA;EAAA,UAEb,sBAAA,CACR,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,SAAA,GAAY,MAAA,sBAC/C,QAAA,CAAS,MAAA,SAAe,SAAA;EAAA,UAmBjB,wBAAA,CACR,IAAA,UACA,GAAA,EAAK,SAAA,GAAY,MAAA,oBAChB,SAAA,GAAY,uBAAA;EAAA,UAmCL,uBAAA,CAAwB,KAAA,EAAO,mBAAA,GAAsB,mBAAA;EAAA,UAkBrD,uBAAA,CAAwB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,SAAA;AAAA;;;;;;;AAzMrE;;;;AAAuD;cCxB1C,qBAAA,SAA8B,yBAAA,CAA0B,QAAA,CAAS,UAAA;;gBAOrD,kBAAA;AAAA;;;;;;;;;ADiBzB;;;;AAAuD;AA0BvD;;;;;;;;;uBErCsB,qBAAA,gCACT,cAAA,CAAe,SAAA,EAAW,OAAA;EAErC,YAAA,CAAa,OAAA,EAAS,mBAAA,CAAoB,SAAA,EAAW,OAAA,IAAW,kBAAA;EFoDlC;;;;;;EAAA,mBEvCX,qBAAA,CACjB,OAAA,EAAS,mBAAA,CAAoB,SAAA,EAAW,OAAA,aAC9B,WAAA;EF0DoC;;;;;EAAA,mBEnD7B,sBAAA,CACjB,OAAA,EAAS,mBAAA,CAAoB,SAAA,EAAW,OAAA,aAC9B,WAAA;AAAA"}
1
+ {"version":3,"file":"ir.d.mts","names":[],"sources":["../src/core/ir/sql-contract-serializer-base.ts","../src/core/ir/sql-contract-serializer.ts","../src/core/ir/sql-schema-verifier-base.ts"],"mappings":";;;;;;;KAmCY,yBAAA,IAA6B,KAAc;;AAAvD;;;;AAAuD;AA0BvD;;;;;;;;;;;;;;;;;;uBAAsB,yBAAA,mBAA4C,QAAA,CAAS,UAAA,cAC9D,kBAAA,CAAmB,SAAA;EAAA,mBAMT,uBAAA,EAAyB,WAAA,SAE1C,yBAAA;EAAA,iBANa,cAAA;EAAA,iBACA,UAAA;cAGI,uBAAA,GAAyB,WAAA,SAE1C,yBAAA,GAEF,eAAA,YAA0B,uBAAA;EAO5B,mBAAA,WAA8B,SAAA,GAAY,SAAA,EAAW,IAAA,YAAgB,CAAA;EAMrE,iBAAA,CAAkB,QAAA,EAAU,SAAA,GAAY,UAAA;EAIxC,mBAAA,0CAAmB,sBAAA;EAEnB,WAAA,0CAAW,WAAA;EAAA,UAED,yBAAA,CAA0B,IAAA,YAAgB,QAAA,CAAS,UAAA;EAAA,UAOnD,iBAAA,CAAkB,SAAA,EAAW,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA;EAAA,UAuC7D,sBAAA,CACR,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,MAAA,sBACnC,QAAA,CAAS,MAAA,SAAe,SAAA;EAAA,UAcjB,wBAAA,CACR,IAAA,UACA,GAAA,EAAK,MAAA,oBACJ,SAAA,GAAY,iBAAA;EAAA,UA+BL,uBAAA,CAAwB,KAAA,EAAO,mBAAA,GAAsB,mBAAA;EAAA,UAkBrD,uBAAA,CAAwB,QAAA,EAAU,QAAA,CAAS,UAAA,IAAc,SAAA;EAAd;;;;;;;;;;EAAA,UAc3C,yBAAA,CACR,OAAA,EAAS,QAAA,CAAS,MAAA,SAAe,QAAA,CAAS,MAAA,uBACzC,MAAA,SAAe,MAAA,SAAe,UAAA;EAAA,QAazB,gBAAA;EAAA,UAQE,mBAAA,CAAoB,KAAA,YAAiB,UAAA;EAAA,QAOvC,kBAAA;AAAA;;;;;;;AAxNV;;;;AAAuD;AA0BvD;;;;;cC3Ca,qBAAA,SAA8B,yBAAA,CAA0B,QAAA,CAAS,UAAA;;;;;;;;;;;ADiB9E;;;;AAAuD;AA0BvD;;;;;;;;;uBElCsB,qBAAA,gCACT,cAAA,CAAe,SAAA,EAAW,OAAA;EAErC,YAAA,CAAa,OAAA,EAAS,mBAAA,CAAoB,SAAA,EAAW,OAAA,IAAW,kBAAA;EFiDlC;;;;;;EAAA,mBEpCX,qBAAA,CACjB,OAAA,EAAS,mBAAA,CAAoB,SAAA,EAAW,OAAA,aAC9B,eAAA;EFuDoC;;;;;EAAA,mBEhD7B,sBAAA,CACjB,OAAA,EAAS,mBAAA,CAAoB,SAAA,EAAW,OAAA,aAC9B,eAAA;AAAA"}
package/dist/ir.mjs CHANGED
@@ -1,10 +1,10 @@
1
- import { n as SqlContractSerializerBase, t as SqlContractSerializer } from "./sql-contract-serializer-BR2vC7Z-.mjs";
1
+ import { n as SqlContractSerializerBase, t as SqlContractSerializer } from "./sql-contract-serializer-C75cfMSS.mjs";
2
2
  //#region src/core/ir/sql-schema-verifier-base.ts
3
3
  /**
4
4
  * SQL family `SchemaVerifier` abstract base. Centralises the SQL-shared
5
5
  * walk (table-by-table + column-by-column matching keyed by
6
6
  * `(namespace.id, name)`, FK / unique / index comparisons via the
7
- * existing helpers in `verify-helpers.ts`) and exposes a protected hook
7
+ * shared satisfaction helpers in `sql-schema-diff.ts`) and exposes a protected hook
8
8
  * for target extensions (Postgres functions, RLS policies, future
9
9
  * target-only kinds).
10
10
  *
package/dist/ir.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"ir.mjs","names":[],"sources":["../src/core/ir/sql-schema-verifier-base.ts"],"sourcesContent":["import type {\n SchemaIssue,\n SchemaVerifier,\n SchemaVerifyOptions,\n SchemaVerifyResult,\n} from '@prisma-next/framework-components/control';\n\n/**\n * SQL family `SchemaVerifier` abstract base. Centralises the SQL-shared\n * walk (table-by-table + column-by-column matching keyed by\n * `(namespace.id, name)`, FK / unique / index comparisons via the\n * existing helpers in `verify-helpers.ts`) and exposes a protected hook\n * for target extensions (Postgres functions, RLS policies, future\n * target-only kinds).\n *\n * The base accumulates issues in a single buffer and returns the\n * combined result; the per-SPI family abstract handles the result\n * envelope shape so concrete subclasses focus on target-specific\n * verification logic.\n *\n * The protected hooks (`verifyCommonSqlSchema`,\n * `verifyTargetExtensions`) carry the stable base API that target\n * subclasses (`PostgresSchemaVerifier`, `SqliteSchemaVerifier`)\n * compile against; the SQL-shared walk implementation will be lifted\n * into this base when the verifier behaviour migrates off the\n * legacy adapter shells.\n */\nexport abstract class SqlSchemaVerifierBase<TContract, TSchema>\n implements SchemaVerifier<TContract, TSchema>\n{\n verifySchema(options: SchemaVerifyOptions<TContract, TSchema>): SchemaVerifyResult {\n const issues: SchemaIssue[] = [];\n issues.push(...this.verifyCommonSqlSchema(options));\n issues.push(...this.verifyTargetExtensions(options));\n return { ok: issues.length === 0, issues };\n }\n\n /**\n * SQL-shared verification — table/column/FK/unique/index walks keyed\n * by `(namespace.id, name)`. Concrete subclasses provide the\n * family-shared implementation today; a future iteration will lift\n * the shared walk into this base.\n */\n protected abstract verifyCommonSqlSchema(\n options: SchemaVerifyOptions<TContract, TSchema>,\n ): readonly SchemaIssue[];\n\n /**\n * Target-specific extensions — e.g. Postgres functions, future RLS\n * policies, namespace-mismatch issues. Returns the empty list when the\n * target ships no extensions over the SQL family alphabet.\n */\n protected abstract verifyTargetExtensions(\n options: SchemaVerifyOptions<TContract, TSchema>,\n ): readonly SchemaIssue[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAsB,wBAAtB,MAEA;CACE,aAAa,SAAsE;EACjF,MAAM,SAAwB,CAAC;EAC/B,OAAO,KAAK,GAAG,KAAK,sBAAsB,OAAO,CAAC;EAClD,OAAO,KAAK,GAAG,KAAK,uBAAuB,OAAO,CAAC;EACnD,OAAO;GAAE,IAAI,OAAO,WAAW;GAAG;EAAO;CAC3C;AAoBF"}
1
+ {"version":3,"file":"ir.mjs","names":[],"sources":["../src/core/ir/sql-schema-verifier-base.ts"],"sourcesContent":["import type {\n SchemaDiffIssue,\n SchemaVerifier,\n SchemaVerifyOptions,\n SchemaVerifyResult,\n} from '@prisma-next/framework-components/control';\n\n/**\n * SQL family `SchemaVerifier` abstract base. Centralises the SQL-shared\n * walk (table-by-table + column-by-column matching keyed by\n * `(namespace.id, name)`, FK / unique / index comparisons via the\n * shared satisfaction helpers in `sql-schema-diff.ts`) and exposes a protected hook\n * for target extensions (Postgres functions, RLS policies, future\n * target-only kinds).\n *\n * The base accumulates issues in a single buffer and returns the\n * combined result; the per-SPI family abstract handles the result\n * envelope shape so concrete subclasses focus on target-specific\n * verification logic.\n *\n * The protected hooks (`verifyCommonSqlSchema`,\n * `verifyTargetExtensions`) carry the stable base API that target\n * subclasses (`PostgresSchemaVerifier`, `SqliteSchemaVerifier`)\n * compile against; the SQL-shared walk implementation will be lifted\n * into this base when the verifier behaviour migrates off the\n * legacy adapter shells.\n */\nexport abstract class SqlSchemaVerifierBase<TContract, TSchema>\n implements SchemaVerifier<TContract, TSchema>\n{\n verifySchema(options: SchemaVerifyOptions<TContract, TSchema>): SchemaVerifyResult {\n const issues: SchemaDiffIssue[] = [];\n issues.push(...this.verifyCommonSqlSchema(options));\n issues.push(...this.verifyTargetExtensions(options));\n return { ok: issues.length === 0, issues };\n }\n\n /**\n * SQL-shared verification — table/column/FK/unique/index walks keyed\n * by `(namespace.id, name)`. Concrete subclasses provide the\n * family-shared implementation today; a future iteration will lift\n * the shared walk into this base.\n */\n protected abstract verifyCommonSqlSchema(\n options: SchemaVerifyOptions<TContract, TSchema>,\n ): readonly SchemaDiffIssue[];\n\n /**\n * Target-specific extensions — e.g. Postgres functions, future RLS\n * policies, namespace-mismatch issues. Returns the empty list when the\n * target ships no extensions over the SQL family alphabet.\n */\n protected abstract verifyTargetExtensions(\n options: SchemaVerifyOptions<TContract, TSchema>,\n ): readonly SchemaDiffIssue[];\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2BA,IAAsB,wBAAtB,MAEA;CACE,aAAa,SAAsE;EACjF,MAAM,SAA4B,CAAC;EACnC,OAAO,KAAK,GAAG,KAAK,sBAAsB,OAAO,CAAC;EAClD,OAAO,KAAK,GAAG,KAAK,uBAAuB,OAAO,CAAC;EACnD,OAAO;GAAE,IAAI,OAAO,WAAW;GAAG;EAAO;CAC3C;AAoBF"}
@@ -1,4 +1,6 @@
1
- import { T as SqlPlanTargetDetails, p as SqlMigrationPlanOperation } from "./types-kgstZ_Zd.mjs";
1
+ import { f as SqlMigrationPlanOperation, w as SqlPlanTargetDetails } from "./types-BPv_y7iS.mjs";
2
+ import { Contract } from "@prisma-next/contract/types";
3
+ import { SqlStorage } from "@prisma-next/sql-contract/types";
2
4
  import { Migration } from "@prisma-next/migration-tools/migration";
3
5
 
4
6
  //#region src/core/sql-migration.d.ts
@@ -13,10 +15,17 @@ import { Migration } from "@prisma-next/migration-tools/migration";
13
15
  * fully concrete operation shape. Target-free code in SQL family / tooling
14
16
  * parameterises over `TDetails` (and usually `TTargetId = string`).
15
17
  *
18
+ * The `Start` / `End` contract generics are forwarded to the framework
19
+ * `Migration` base so the derived `describe()` and the per-target view getters
20
+ * (`PostgresMigration` / `SqliteMigration`) carry each migration's precise
21
+ * contract types. The view getters themselves live on the per-target bases
22
+ * because the SQL ContractView shapes differ per target (SQLite unwraps its
23
+ * sole namespace to the root; Postgres is schema-qualified).
24
+ *
16
25
  * Keeps target-free contract/runtime features in the family layer while
17
26
  * letting adapters own target shape.
18
27
  */
19
- declare abstract class SqlMigration<TDetails extends SqlPlanTargetDetails, TTargetId extends string = string> extends Migration<SqlMigrationPlanOperation<TDetails>, 'sql', TTargetId> {
28
+ declare abstract class SqlMigration<TDetails extends SqlPlanTargetDetails, TTargetId extends string = string, Start extends Contract<SqlStorage> = Contract<SqlStorage>, End extends Contract<SqlStorage> = Contract<SqlStorage>> extends Migration<SqlMigrationPlanOperation<TDetails>, 'sql', TTargetId, Start, End> {
20
29
  /**
21
30
  * Sorted, deduplicated invariant ids declared by this migration's
22
31
  * data-transform ops. Derived from `this.operations` so the field remains
@@ -1 +1 @@
1
- {"version":3,"file":"migration.d.mts","names":[],"sources":["../src/core/sql-migration.ts"],"mappings":";;;;;;AAmBA;;;;;;;;;;;;uBAAsB,YAAA,kBACH,oBAAA,6CAET,SAAA,CAAU,yBAAA,CAA0B,QAAA,UAAkB,SAAA;EAAtD;;;;;;AAWc;;;;EAXd,IAWJ,kBAAA;AAAA"}
1
+ {"version":3,"file":"migration.d.mts","names":[],"sources":["../src/core/sql-migration.ts"],"mappings":";;;;;;;;AA4BA;;;;;;;;;;;;;;;;;;;uBAAsB,YAAA,kBACH,oBAAA,mDAEH,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,eAClC,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,WACpC,SAAA,CAAU,yBAAA,CAA0B,QAAA,UAAkB,SAAA,EAAW,KAAA,EAAO,GAAA;EAJhF;;;;;;;;;;EAAA,IAeI,kBAAA;AAAA"}
@@ -13,6 +13,13 @@ import { isThenable } from "@prisma-next/utils/promise";
13
13
  * fully concrete operation shape. Target-free code in SQL family / tooling
14
14
  * parameterises over `TDetails` (and usually `TTargetId = string`).
15
15
  *
16
+ * The `Start` / `End` contract generics are forwarded to the framework
17
+ * `Migration` base so the derived `describe()` and the per-target view getters
18
+ * (`PostgresMigration` / `SqliteMigration`) carry each migration's precise
19
+ * contract types. The view getters themselves live on the per-target bases
20
+ * because the SQL ContractView shapes differ per target (SQLite unwraps its
21
+ * sole namespace to the root; Postgres is schema-qualified).
22
+ *
16
23
  * Keeps target-free contract/runtime features in the family layer while
17
24
  * letting adapters own target shape.
18
25
  */
@@ -1 +1 @@
1
- {"version":3,"file":"migration.mjs","names":[],"sources":["../src/core/sql-migration.ts"],"sourcesContent":["import { deriveProvidedInvariants } from '@prisma-next/migration-tools/invariants';\nimport { Migration } from '@prisma-next/migration-tools/migration';\nimport { isThenable } from '@prisma-next/utils/promise';\nimport type { SqlMigrationPlanOperation, SqlPlanTargetDetails } from './migrations/types';\n\n/**\n * Family-owned base class for SQL migrations.\n *\n * Generic in `TDetails` (family plan target details, e.g. Postgres vs SQLite)\n * and in `TTargetId` (the literal target identifier, e.g. `'postgres'`).\n *\n * Adapters (Postgres, SQLite, …) extend this with a concrete `TDetails` and\n * a fixed `TTargetId` literal, so the public `Migration<TOp>` base sees the\n * fully concrete operation shape. Target-free code in SQL family / tooling\n * parameterises over `TDetails` (and usually `TTargetId = string`).\n *\n * Keeps target-free contract/runtime features in the family layer while\n * letting adapters own target shape.\n */\nexport abstract class SqlMigration<\n TDetails extends SqlPlanTargetDetails,\n TTargetId extends string = string,\n> extends Migration<SqlMigrationPlanOperation<TDetails>, 'sql', TTargetId> {\n /**\n * Sorted, deduplicated invariant ids declared by this migration's\n * data-transform ops. Derived from `this.operations` so the field remains\n * consistent with the operation list — planner-built plans (`db init`,\n * `db update`) yield `[]` because they emit no data-transform ops.\n *\n * Required by `SqlMigrationPlan.providedInvariants` (tightened from\n * optional at the SQL-family layer); the framework-level\n * `MigrationPlan.providedInvariants?` stays optional.\n */\n get providedInvariants(): readonly string[] {\n const ops = this.operations.filter(\n (op): op is SqlMigrationPlanOperation<TDetails> => !isThenable(op),\n );\n return deriveProvidedInvariants(ops);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmBA,IAAsB,eAAtB,cAGU,UAAiE;;;;;;;;;;;CAWzE,IAAI,qBAAwC;EAI1C,OAAO,yBAHK,KAAK,WAAW,QACzB,OAAkD,CAAC,WAAW,EAAE,CAEjC,CAAC;CACrC;AACF"}
1
+ {"version":3,"file":"migration.mjs","names":[],"sources":["../src/core/sql-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport { deriveProvidedInvariants } from '@prisma-next/migration-tools/invariants';\nimport { Migration } from '@prisma-next/migration-tools/migration';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport { isThenable } from '@prisma-next/utils/promise';\nimport type { SqlMigrationPlanOperation, SqlPlanTargetDetails } from './migrations/types';\n\n/**\n * Family-owned base class for SQL migrations.\n *\n * Generic in `TDetails` (family plan target details, e.g. Postgres vs SQLite)\n * and in `TTargetId` (the literal target identifier, e.g. `'postgres'`).\n *\n * Adapters (Postgres, SQLite, …) extend this with a concrete `TDetails` and\n * a fixed `TTargetId` literal, so the public `Migration<TOp>` base sees the\n * fully concrete operation shape. Target-free code in SQL family / tooling\n * parameterises over `TDetails` (and usually `TTargetId = string`).\n *\n * The `Start` / `End` contract generics are forwarded to the framework\n * `Migration` base so the derived `describe()` and the per-target view getters\n * (`PostgresMigration` / `SqliteMigration`) carry each migration's precise\n * contract types. The view getters themselves live on the per-target bases\n * because the SQL ContractView shapes differ per target (SQLite unwraps its\n * sole namespace to the root; Postgres is schema-qualified).\n *\n * Keeps target-free contract/runtime features in the family layer while\n * letting adapters own target shape.\n */\nexport abstract class SqlMigration<\n TDetails extends SqlPlanTargetDetails,\n TTargetId extends string = string,\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends Migration<SqlMigrationPlanOperation<TDetails>, 'sql', TTargetId, Start, End> {\n /**\n * Sorted, deduplicated invariant ids declared by this migration's\n * data-transform ops. Derived from `this.operations` so the field remains\n * consistent with the operation list — planner-built plans (`db init`,\n * `db update`) yield `[]` because they emit no data-transform ops.\n *\n * Required by `SqlMigrationPlan.providedInvariants` (tightened from\n * optional at the SQL-family layer); the framework-level\n * `MigrationPlan.providedInvariants?` stays optional.\n */\n get providedInvariants(): readonly string[] {\n const ops = this.operations.filter(\n (op): op is SqlMigrationPlanOperation<TDetails> => !isThenable(op),\n );\n return deriveProvidedInvariants(ops);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,IAAsB,eAAtB,cAKU,UAA6E;;;;;;;;;;;CAWrF,IAAI,qBAAwC;EAI1C,OAAO,yBAHK,KAAK,WAAW,QACzB,OAAkD,CAAC,WAAW,EAAE,CAEjC,CAAC;CACrC;AACF"}
package/dist/pack.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { i as sqlFamilyPslBlockDescriptors, n as sqlFamilyAuthoringFieldPresets, r as sqlFamilyEntityTypes, t as sqlFamilyAuthoringTypes } from "./authoring-type-constructors-CjFfO6LM.mjs";
1
+ import { i as sqlFamilyPslBlockDescriptors, n as sqlFamilyAuthoringFieldPresets, r as sqlFamilyEntityTypes, t as sqlFamilyAuthoringTypes } from "./authoring-type-constructors-CXd-8ydc.mjs";
2
2
  //#region src/exports/pack.ts
3
3
  const sqlFamilyPack = {
4
4
  kind: "family",
@@ -0,0 +1,119 @@
1
+ import { ColumnDefault } from "@prisma-next/contract/types";
2
+ import { SqlForeignKeyIR, SqlTableIR } from "@prisma-next/sql-schema-ir/types";
3
+
4
+ //#region src/core/psl-contract-infer/default-mapping.d.ts
5
+ interface DefaultMappingOptions {
6
+ readonly functionAttributes?: Readonly<Record<string, string>>;
7
+ readonly fallbackFunctionAttribute?: ((expression: string) => string | undefined) | undefined;
8
+ }
9
+ type DefaultMappingResult = {
10
+ readonly attribute: string;
11
+ } | {
12
+ readonly comment: string;
13
+ };
14
+ declare function mapDefault(columnDefault: ColumnDefault, options?: DefaultMappingOptions): DefaultMappingResult;
15
+ //#endregion
16
+ //#region src/core/psl-contract-infer/name-transforms.d.ts
17
+ type NameResult = {
18
+ readonly name: string;
19
+ readonly map?: string;
20
+ };
21
+ declare function toModelName(tableName: string): NameResult;
22
+ declare function toFieldName(columnName: string): NameResult;
23
+ declare function toEnumName(pgTypeName: string): NameResult;
24
+ /**
25
+ * PSL member name for a native-enum value. The value itself always prints
26
+ * explicitly (`member = "value"`), so the returned name never needs a map:
27
+ * a value that already is a valid, non-reserved identifier is kept verbatim
28
+ * (case included); anything else is camelCased/escaped like a field name.
29
+ */
30
+ declare function toEnumMemberName(value: string): string;
31
+ declare function pluralize(word: string): string;
32
+ declare function deriveRelationFieldName(fkColumns: readonly string[], referencedTableName: string): string;
33
+ declare function deriveBackRelationFieldName(childModelName: string, isOneToOne: boolean): string;
34
+ declare function toNamedTypeName(columnName: string): string;
35
+ //#endregion
36
+ //#region src/core/psl-contract-infer/printer-config.d.ts
37
+ type PslNativeTypeAttribute = {
38
+ readonly name: string;
39
+ readonly args?: readonly string[];
40
+ };
41
+ type PslTypeResolution = {
42
+ readonly pslType: string;
43
+ readonly nativeType: string;
44
+ readonly typeParams?: Record<string, unknown>;
45
+ readonly nativeTypeAttribute?: PslNativeTypeAttribute;
46
+ } | {
47
+ readonly unsupported: true;
48
+ readonly nativeType: string;
49
+ };
50
+ interface PslTypeMap {
51
+ resolve(nativeType: string, annotations?: Record<string, unknown>): PslTypeResolution;
52
+ }
53
+ interface EnumInfo {
54
+ readonly typeNames: ReadonlySet<string>;
55
+ readonly definitions: ReadonlyMap<string, readonly string[]>;
56
+ }
57
+ interface PslPrinterOptions {
58
+ readonly typeMap: PslTypeMap;
59
+ readonly defaultMapping?: DefaultMappingOptions;
60
+ readonly enumInfo?: EnumInfo;
61
+ readonly parseRawDefault?: (rawDefault: string, nativeType?: string) => ColumnDefault | undefined;
62
+ }
63
+ type RelationField = {
64
+ readonly fieldName: string;
65
+ readonly typeName: string;
66
+ /**
67
+ * Namespace qualifier for a cross-space relation (e.g. `"auth"` for a
68
+ * relation into `supabase:auth.AuthUser`). Absent for a same-namespace
69
+ * relation.
70
+ */
71
+ readonly typeNamespaceId?: string | undefined;
72
+ /**
73
+ * Contract-space qualifier for a relation into another stack extension
74
+ * pack's contract space (e.g. `"supabase"`). Absent for a same-space
75
+ * relation.
76
+ */
77
+ readonly typeContractSpaceId?: string | undefined;
78
+ readonly referencedTableName?: string | undefined;
79
+ readonly optional: boolean;
80
+ readonly list: boolean;
81
+ readonly relationName?: string | undefined;
82
+ readonly fkName?: string | undefined;
83
+ readonly fields?: readonly string[] | undefined;
84
+ readonly references?: readonly string[] | undefined;
85
+ readonly onDelete?: string | undefined;
86
+ readonly onUpdate?: string | undefined; /** `false` when the FK's source columns have no live backing index; omitted (the default) otherwise. */
87
+ readonly index?: boolean | undefined;
88
+ };
89
+ //#endregion
90
+ //#region src/core/psl-contract-infer/raw-default-parser.d.ts
91
+ declare function parseRawDefault(rawDefault: string, nativeType?: string): ColumnDefault | undefined;
92
+ //#endregion
93
+ //#region src/core/psl-contract-infer/relation-inference.d.ts
94
+ type InferredRelations = {
95
+ readonly relationsByTable: ReadonlyMap<string, readonly RelationField[]>;
96
+ };
97
+ declare function inferRelations(tables: Record<string, SqlTableIR>, modelNameMap: ReadonlyMap<string, string>): InferredRelations;
98
+ /**
99
+ * Builds the child-side {@link RelationField} for a single foreign key:
100
+ * `typeName` is the parent model name, `fields`/`references` are the FK's raw
101
+ * columns, and `onDelete`/`onUpdate` are normalized to their PSL spelling.
102
+ * Exported so a caller resolving a foreign key against a model outside
103
+ * `tables` (e.g. a cross-space reference into another contract) can reuse the
104
+ * same normalization instead of duplicating it.
105
+ *
106
+ * `hostTable` is the table the FK is declared on (i.e. `table`, not the
107
+ * referenced parent) — its own indexes/uniques/primary key are what a
108
+ * backing index for this FK would be. When none of them exactly match the
109
+ * FK's source columns (in order), `index: false` is stamped so the emitted
110
+ * `@relation` opts out of the framework's default derived backing-index
111
+ * expectation, matching what `db verify` will find live. Passing the table
112
+ * is optional so existing single-FK callers (e.g. cross-space resolution
113
+ * before a host table reference is threaded through) can omit it and keep
114
+ * the framework default.
115
+ */
116
+ declare function buildChildRelationField(fieldName: string, parentModelName: string, fk: SqlForeignKeyIR, optional: boolean, relationName?: string, hostTable?: SqlTableIR): RelationField;
117
+ //#endregion
118
+ export { type DefaultMappingOptions, type DefaultMappingResult, type EnumInfo, type InferredRelations, type PslNativeTypeAttribute, type PslPrinterOptions, type PslTypeMap, type PslTypeResolution, type RelationField, buildChildRelationField, deriveBackRelationFieldName, deriveRelationFieldName, inferRelations, mapDefault, parseRawDefault, pluralize, toEnumMemberName, toEnumName, toFieldName, toModelName, toNamedTypeName };
119
+ //# sourceMappingURL=psl-infer.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"psl-infer.d.mts","names":[],"sources":["../src/core/psl-contract-infer/default-mapping.ts","../src/core/psl-contract-infer/name-transforms.ts","../src/core/psl-contract-infer/printer-config.ts","../src/core/psl-contract-infer/raw-default-parser.ts","../src/core/psl-contract-infer/relation-inference.ts"],"mappings":";;;;UAOiB,qBAAA;EAAA,SACN,kBAAA,GAAqB,QAAQ,CAAC,MAAA;EAAA,SAC9B,yBAAA,KAA8B,UAAA;AAAA;AAAA,KAG7B,oBAAA;EAAA,SAAkC,SAAA;AAAA;EAAA,SAAiC,OAAO;AAAA;AAAA,iBAEtE,UAAA,CACd,aAAA,EAAe,aAAA,EACf,OAAA,GAAU,qBAAA,GACT,oBAAA;;;KCbE,UAAA;EAAA,SACM,IAAA;EAAA,SACA,GAAG;AAAA;AAAA,iBA4DE,WAAA,CAAY,SAAA,WAAoB,UAAU;AAAA,iBAqB1C,WAAA,CAAY,UAAA,WAAqB,UAAU;AAAA,iBAqB3C,UAAA,CAAW,UAAA,WAAqB,UAAU;;;;;;;iBA6B1C,gBAAA,CAAiB,KAAa;AAAA,iBAO9B,SAAA,CAAU,IAAY;AAAA,iBAgBtB,uBAAA,CACd,SAAA,qBACA,mBAA2B;AAAA,iBAeb,2BAAA,CAA4B,cAAA,UAAwB,UAAmB;AAAA,iBAKvE,eAAA,CAAgB,UAAkB;;;KCnLtC,sBAAA;EAAA,SACD,IAAA;EAAA,SACA,IAAI;AAAA;AAAA,KAGH,iBAAA;EAAA,SAEG,OAAA;EAAA,SACA,UAAA;EAAA,SACA,UAAA,GAAa,MAAA;EAAA,SACb,mBAAA,GAAsB,sBAAsB;AAAA;EAAA,SAG5C,WAAA;EAAA,SACA,UAAA;AAAA;AAAA,UAGE,UAAA;EACf,OAAA,CAAQ,UAAA,UAAoB,WAAA,GAAc,MAAA,oBAA0B,iBAAiB;AAAA;AAAA,UAGtE,QAAA;EAAA,SACN,SAAA,EAAW,WAAA;EAAA,SACX,WAAA,EAAa,WAAW;AAAA;AAAA,UAGlB,iBAAA;EAAA,SACN,OAAA,EAAS,UAAA;EAAA,SACT,cAAA,GAAiB,qBAAA;EAAA,SACjB,QAAA,GAAW,QAAA;EAAA,SACX,eAAA,IAAmB,UAAA,UAAoB,UAAA,cAAwB,aAAA;AAAA;AAAA,KAG9D,aAAA;EAAA,SACD,SAAA;EAAA,SACA,QAAA;EFtBT;;;AACqB;;EADrB,SE4BS,eAAA;;;;;;WAMA,mBAAA;EAAA,SACA,mBAAA;EAAA,SACA,QAAA;EAAA,SACA,IAAA;EAAA,SACA,YAAA;EAAA,SACA,MAAA;EAAA,SACA,MAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;EAAA,SACA,QAAA,uBD4BgD;EAAA,SC1BhD,KAAA;AAAA;;;iBCxBK,eAAA,CACd,UAAA,UACA,UAAA,YACC,aAAa;;;KCrBJ,iBAAA;EAAA,SACD,gBAAA,EAAkB,WAAW,kBAAkB,aAAA;AAAA;AAAA,iBAG1C,cAAA,CACd,MAAA,EAAQ,MAAA,SAAe,UAAA,GACvB,YAAA,EAAc,WAAA,mBACb,iBAAA;;;;;;;;;AJjBwD;AAG3D;;;;AAAsF;AAEtF;;;;iBImJgB,uBAAA,CACd,SAAA,UACA,eAAA,UACA,EAAA,EAAI,eAAA,EACJ,QAAA,WACA,YAAA,WACA,SAAA,GAAY,UAAA,GACX,aAAA"}