@prisma-next/family-sql 0.15.0 → 0.16.0-dev.2
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/dist/{control-adapter-BQgad8Zc.d.mts → control-adapter-CW7FdxeS.d.mts} +1 -2
- package/dist/control-adapter-CW7FdxeS.d.mts.map +1 -0
- package/dist/control-adapter.d.mts +1 -1
- package/dist/control.d.mts +127 -5
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +71 -33
- package/dist/control.mjs.map +1 -1
- package/dist/diff.d.mts +3 -4
- package/dist/diff.d.mts.map +1 -1
- package/dist/diff.mjs +1 -1
- package/dist/ir.d.mts +0 -1
- package/dist/ir.d.mts.map +1 -1
- package/dist/migration.d.mts +1 -2
- package/dist/migration.d.mts.map +1 -1
- package/dist/pack.d.mts.map +1 -1
- package/dist/psl-infer.d.mts +2 -2
- package/dist/psl-infer.d.mts.map +1 -1
- package/dist/psl-infer.mjs +3 -4
- package/dist/psl-infer.mjs.map +1 -1
- package/dist/runtime.d.mts +0 -1
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +1 -1
- package/dist/{schema-differ-DnoopSXm.d.mts → schema-differ-C8OHo1V5.d.mts} +1 -2
- package/dist/schema-differ-C8OHo1V5.d.mts.map +1 -0
- package/dist/{schema-verify-W3r631Jh.mjs → schema-verify-DY21bMwy.mjs} +8 -8
- package/dist/schema-verify-DY21bMwy.mjs.map +1 -0
- package/dist/{timestamp-now-generator-CloimujU.mjs → timestamp-now-generator-DRXygu32.mjs} +88 -2
- package/dist/timestamp-now-generator-DRXygu32.mjs.map +1 -0
- package/dist/{types-BPv_y7iS.d.mts → types-6JMCRorL.d.mts} +3 -4
- package/dist/types-6JMCRorL.d.mts.map +1 -0
- package/dist/verify.d.mts +0 -1
- package/dist/verify.d.mts.map +1 -1
- package/package.json +25 -23
- package/src/core/diff/schema-verify.ts +5 -5
- package/src/core/diff/verifier-disposition.ts +3 -3
- package/src/core/migrations/contract-to-schema-ir.ts +96 -29
- package/src/core/migrations/types.ts +10 -10
- package/src/core/psl-contract-infer/name-transforms.ts +3 -13
- package/src/core/psl-contract-infer/relation-inference.ts +4 -1
- package/src/core/timestamp-now-generator.ts +88 -0
- package/src/exports/control.ts +3 -0
- package/dist/control-adapter-BQgad8Zc.d.mts.map +0 -1
- package/dist/foreign-key-index-backing-BP71iI-Q.mjs +0 -32
- package/dist/foreign-key-index-backing-BP71iI-Q.mjs.map +0 -1
- package/dist/schema-differ-DnoopSXm.d.mts.map +0 -1
- package/dist/schema-verify-W3r631Jh.mjs.map +0 -1
- package/dist/timestamp-now-generator-CloimujU.mjs.map +0 -1
- package/dist/types-BPv_y7iS.d.mts.map +0 -1
- package/src/core/foreign-key-index-backing.ts +0 -37
|
@@ -3,7 +3,6 @@ import { ColumnDefault, ContractMarkerRecord, LedgerEntryRecord } from "@prisma-
|
|
|
3
3
|
import { SqlControlDriverInstance } from "@prisma-next/sql-contract/types";
|
|
4
4
|
import { SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
|
|
5
5
|
import { AnyQueryAst, DdlNode, LoweredStatement, LowererContext, SqlExecuteRequest } from "@prisma-next/sql-relational-core/ast";
|
|
6
|
-
|
|
7
6
|
//#region src/core/diff/sql-schema-diff.d.ts
|
|
8
7
|
/**
|
|
9
8
|
* Function type for normalizing raw database default expressions into ColumnDefault.
|
|
@@ -184,4 +183,4 @@ interface SqlControlAdapterDescriptor<TTarget extends string = string> {
|
|
|
184
183
|
}
|
|
185
184
|
//#endregion
|
|
186
185
|
export { NativeTypeNormalizer as a, SqlControlAdapterDescriptor as i, Lowerer as n, arraysEqual as o, SqlControlAdapter as r, ExecuteRequestLowerer as t };
|
|
187
|
-
//# sourceMappingURL=control-adapter-
|
|
186
|
+
//# sourceMappingURL=control-adapter-CW7FdxeS.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-adapter-CW7FdxeS.d.mts","names":[],"sources":["../src/core/diff/sql-schema-diff.ts","../src/core/control-adapter.ts"],"mappings":";;;;;;;;;;KAeY,qBACV,oBACA,uBACG;;;;;;KAOO,wBAAwB;;;;iBAKpB,YAAY,sBAAsB;;;;;;;;;;UCPjC;EACf,MAAM,KAAK,cAAc,SAAS,SAAS,0BAA0B;;;;;;;;UAStD,8BAA8B;EAC7C,sBACE,KAAK,cAAc,SACnB,UAAU,0BACT,QAAQ;;;;;;;;UASI,kBAAkB,yCACzB,8BAA8B,UACpC;;;;;;;;;;;;;;;;EAgBF,WACE,QAAQ,yBAAyB,UACjC,gBACC,QAAQ;;;;;;;;EASX,eACE,QAAQ,yBAAyB,WAChC,QAAQ,oBAAoB;;;;;EAM/B,WACE,QAAQ,yBAAyB,UACjC,iBACC,iBAAiB;;;;;;;EAQpB,aACE,QAAQ,yBAAyB,UACjC,eACA;aACW;aACA;aACA;MAEV;;;;;;;EAQH,WACE,QAAQ,yBAAyB,UACjC,eACA;aACW;aACA;aACA;MAEV;;;;;;;;EASH,aACE,QAAQ,yBAAyB,UACjC,eACA,sBACA;aACW;aACA;aACA;MAEV;;;;;;;EAQH,iBACE,QAAQ,yBAAyB,UACjC,eACA;aACW;aACA;aACA;aACA;aACA;aACA;aACA;MAEV;;;;;;;;;;;;;;;;;;EAmBH,WACE,QAAQ,yBAAyB,UACjC,oBACA,kBACC,QAAQ;;;;;;WAOF,mBAAmB;;;;;;WAOnB,sBAAsB;;;;;EAM/B,yCAAyC;;;;;EAMzC,uCAAuC;;;;;;;;UASxB,4BAA4B;;;;;;;EAO3C,OAAO,OAAO,oBAAoB,WAAW,kBAAkB"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { i as SqlControlAdapterDescriptor, n as Lowerer, r as SqlControlAdapter, t as ExecuteRequestLowerer } from "./control-adapter-
|
|
1
|
+
import { i as SqlControlAdapterDescriptor, n as Lowerer, r as SqlControlAdapter, t as ExecuteRequestLowerer } from "./control-adapter-CW7FdxeS.mjs";
|
|
2
2
|
export type { ExecuteRequestLowerer, Lowerer, SqlControlAdapter, SqlControlAdapterDescriptor };
|
package/dist/control.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { r as SqlControlAdapter } from "./control-adapter-
|
|
2
|
-
import { A as SqlPlannerSuccessResult, C as SqlMigrationRunnerSuccessValue, D as SqlPlannerConflictLocation, E as SqlPlannerConflictKind, O as SqlPlannerFailureResult, S as SqlMigrationRunnerResult, T as SqlPlannerConflict, _ as SqlMigrationRunner, a as FieldEvent, b as SqlMigrationRunnerExecuteOptions, c as SqlControlAdapterDescriptor, d as SqlMigrationPlanContractInfo, f as SqlMigrationPlanOperation, g as SqlMigrationPlannerPlanOptions, h as SqlMigrationPlanner, i as ExpandNativeTypeInput, j as StorageTypePlanResult, k as SqlPlannerResult, l as SqlControlExtensionDescriptor, m as SqlMigrationPlanOperationTarget, n as CodecControlHooks, o as FieldEventContext, p as SqlMigrationPlanOperationStep, r as CreateSqlMigrationPlanOptions, s as ResolveIdentityValueInput, t as AnyRecord, u as SqlMigrationPlan, v as SqlMigrationRunnerErrorCode, w as SqlPlanTargetDetails, x as SqlMigrationRunnerFailure, y as SqlMigrationRunnerExecuteCallbacks } from "./types-
|
|
3
|
-
import { n as SqlSchemaDiffInput, r as SqlSchemaDiffResult, t as SqlSchemaDiffFn } from "./schema-differ-
|
|
1
|
+
import { r as SqlControlAdapter } from "./control-adapter-CW7FdxeS.mjs";
|
|
2
|
+
import { A as SqlPlannerSuccessResult, C as SqlMigrationRunnerSuccessValue, D as SqlPlannerConflictLocation, E as SqlPlannerConflictKind, O as SqlPlannerFailureResult, S as SqlMigrationRunnerResult, T as SqlPlannerConflict, _ as SqlMigrationRunner, a as FieldEvent, b as SqlMigrationRunnerExecuteOptions, c as SqlControlAdapterDescriptor, d as SqlMigrationPlanContractInfo, f as SqlMigrationPlanOperation, g as SqlMigrationPlannerPlanOptions, h as SqlMigrationPlanner, i as ExpandNativeTypeInput, j as StorageTypePlanResult, k as SqlPlannerResult, l as SqlControlExtensionDescriptor, m as SqlMigrationPlanOperationTarget, n as CodecControlHooks, o as FieldEventContext, p as SqlMigrationPlanOperationStep, r as CreateSqlMigrationPlanOptions, s as ResolveIdentityValueInput, t as AnyRecord, u as SqlMigrationPlan, v as SqlMigrationRunnerErrorCode, w as SqlPlanTargetDetails, x as SqlMigrationRunnerFailure, y as SqlMigrationRunnerExecuteCallbacks } from "./types-6JMCRorL.mjs";
|
|
3
|
+
import { n as SqlSchemaDiffInput, r as SqlSchemaDiffResult, t as SqlSchemaDiffFn } from "./schema-differ-C8OHo1V5.mjs";
|
|
4
4
|
import { ContractSerializer, ControlFamilyDescriptor, ControlFamilyInstance, ControlStack, DiffSubjectGranularity, MigratableTargetDescriptor, MigrationOperationClass, MigrationOperationPolicy, MigrationOperationPolicy as MigrationOperationPolicy$1, MigrationPlan, MigrationPlanOperation, MigrationPlanOperation as MigrationPlanOperation$1, MigrationPlanner, MigrationPlannerConflict, MigrationPlannerConflict as MigrationPlannerConflict$1, MigrationPlannerResult, MutationDefaultGeneratorDescriptor, OpFactoryCall, OperationPreview, OperationPreviewCapable, PslContractInferCapable, SchemaDiffIssue, SchemaVerifier, SchemaViewCapable, SignDatabaseResult, TargetMigrationsCapability, VerifyDatabaseResult, VerifyDatabaseSchemaResult, assembleAuthoringContributions } from "@prisma-next/framework-components/control";
|
|
5
5
|
import { ColumnDefault, Contract, ControlPolicy } from "@prisma-next/contract/types";
|
|
6
6
|
import { SqlControlDriverInstance, SqlStorage, StorageColumn } from "@prisma-next/sql-contract/types";
|
|
@@ -11,7 +11,6 @@ import { EmissionSpi, TypesImportSpec } from "@prisma-next/framework-components/
|
|
|
11
11
|
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
12
12
|
import { PslDocumentAst } from "@prisma-next/framework-components/psl-ast";
|
|
13
13
|
import { SqlOperationDescriptors } from "@prisma-next/sql-operations";
|
|
14
|
-
|
|
15
14
|
//#region src/core/control-instance.d.ts
|
|
16
15
|
interface SqlTypeMetadata {
|
|
17
16
|
readonly typeId: string;
|
|
@@ -489,6 +488,16 @@ type NativeTypeExpander = (input: {
|
|
|
489
488
|
* `contractToSchemaIR`, keeping the family layer target-agnostic.
|
|
490
489
|
*/
|
|
491
490
|
type DefaultRenderer = (def: ColumnDefault, column: StorageColumn) => string;
|
|
491
|
+
/**
|
|
492
|
+
* Target-supplied hook (same IoC seam as `NativeTypeExpander`/`DefaultRenderer`)
|
|
493
|
+
* that normalizes a contract-declared `ColumnDefault` into the resolved shape
|
|
494
|
+
* the target's introspection parses from the live database — e.g. a
|
|
495
|
+
* `dbgenerated("'{}'::jsonb")` function call and the literal Postgres reports
|
|
496
|
+
* are the same value in different shapes, and `resolvedDefaultsEqual`
|
|
497
|
+
* compares `kind` before content. When omitted, the contract's raw default
|
|
498
|
+
* is the resolved default unchanged.
|
|
499
|
+
*/
|
|
500
|
+
type DefaultResolver = (def: ColumnDefault, resolvedNativeType: string) => ColumnDefault;
|
|
492
501
|
/**
|
|
493
502
|
* Target-supplied callback that resolves a contract namespace to the live
|
|
494
503
|
* database schema its enums are stored under.
|
|
@@ -521,6 +530,7 @@ interface ContractToSchemaIROptions {
|
|
|
521
530
|
readonly annotationNamespace: string;
|
|
522
531
|
readonly expandNativeType?: NativeTypeExpander;
|
|
523
532
|
readonly renderDefault?: DefaultRenderer;
|
|
533
|
+
readonly resolveDefault?: DefaultResolver;
|
|
524
534
|
/**
|
|
525
535
|
* Target-supplied resolver mapping a namespace to the live database schema
|
|
526
536
|
* its enums are stored under. When provided (Postgres), namespace-scoped
|
|
@@ -805,9 +815,121 @@ declare function temporalAuthoringPresets<const CodecId extends string, const Na
|
|
|
805
815
|
};
|
|
806
816
|
};
|
|
807
817
|
};
|
|
818
|
+
/**
|
|
819
|
+
* Builds a `temporal.<codec>` field preset for a codec that takes a precision
|
|
820
|
+
* parameter (`pg/timestamp@1`, `pg/timestamptz@1`). Arguments change field
|
|
821
|
+
* properties only — never the codec, which the caller fixes here.
|
|
822
|
+
*
|
|
823
|
+
* All three arguments are optional: omitting `precision` omits `typeParams`
|
|
824
|
+
* entirely, and omitting a phase omits that phase (both omitted omits
|
|
825
|
+
* `executionDefaults`).
|
|
826
|
+
*/
|
|
827
|
+
declare function temporalCodecPresetWithPrecision<const CodecId extends string, const NativeType extends string>(input: {
|
|
828
|
+
readonly codecId: CodecId;
|
|
829
|
+
readonly nativeType: NativeType;
|
|
830
|
+
}): {
|
|
831
|
+
readonly kind: "fieldPreset";
|
|
832
|
+
readonly args: readonly [{
|
|
833
|
+
readonly name: "precision";
|
|
834
|
+
readonly kind: "number";
|
|
835
|
+
readonly optional: true;
|
|
836
|
+
readonly integer: true;
|
|
837
|
+
readonly minimum: 0;
|
|
838
|
+
}, {
|
|
839
|
+
readonly name: "onCreate";
|
|
840
|
+
readonly kind: "option";
|
|
841
|
+
readonly values: readonly ["now"];
|
|
842
|
+
readonly optional: true;
|
|
843
|
+
}, {
|
|
844
|
+
readonly name: "onUpdate";
|
|
845
|
+
readonly kind: "option";
|
|
846
|
+
readonly values: readonly ["now"];
|
|
847
|
+
readonly optional: true;
|
|
848
|
+
}];
|
|
849
|
+
readonly output: {
|
|
850
|
+
readonly codecId: CodecId;
|
|
851
|
+
readonly nativeType: NativeType;
|
|
852
|
+
readonly typeParams: {
|
|
853
|
+
readonly precision: {
|
|
854
|
+
readonly kind: "arg";
|
|
855
|
+
readonly index: 0;
|
|
856
|
+
};
|
|
857
|
+
};
|
|
858
|
+
readonly executionDefaults: {
|
|
859
|
+
readonly onCreate: {
|
|
860
|
+
readonly kind: "select";
|
|
861
|
+
readonly index: 1;
|
|
862
|
+
readonly cases: {
|
|
863
|
+
readonly now: {
|
|
864
|
+
readonly kind: "generator";
|
|
865
|
+
readonly id: "timestampNow";
|
|
866
|
+
};
|
|
867
|
+
};
|
|
868
|
+
};
|
|
869
|
+
readonly onUpdate: {
|
|
870
|
+
readonly kind: "select";
|
|
871
|
+
readonly index: 2;
|
|
872
|
+
readonly cases: {
|
|
873
|
+
readonly now: {
|
|
874
|
+
readonly kind: "generator";
|
|
875
|
+
readonly id: "timestampNow";
|
|
876
|
+
};
|
|
877
|
+
};
|
|
878
|
+
};
|
|
879
|
+
};
|
|
880
|
+
};
|
|
881
|
+
};
|
|
882
|
+
/**
|
|
883
|
+
* Builds a `temporal.<codec>` field preset for a codec with no type
|
|
884
|
+
* parameters (`sqlite/datetime@1`). As with the precision-bearing variant,
|
|
885
|
+
* both phase arguments are optional and omitting one omits that phase.
|
|
886
|
+
*/
|
|
887
|
+
declare function temporalCodecPreset<const CodecId extends string, const NativeType extends string>(input: {
|
|
888
|
+
readonly codecId: CodecId;
|
|
889
|
+
readonly nativeType: NativeType;
|
|
890
|
+
}): {
|
|
891
|
+
readonly kind: "fieldPreset";
|
|
892
|
+
readonly args: readonly [{
|
|
893
|
+
readonly name: "onCreate";
|
|
894
|
+
readonly kind: "option";
|
|
895
|
+
readonly values: readonly ["now"];
|
|
896
|
+
readonly optional: true;
|
|
897
|
+
}, {
|
|
898
|
+
readonly name: "onUpdate";
|
|
899
|
+
readonly kind: "option";
|
|
900
|
+
readonly values: readonly ["now"];
|
|
901
|
+
readonly optional: true;
|
|
902
|
+
}];
|
|
903
|
+
readonly output: {
|
|
904
|
+
readonly codecId: CodecId;
|
|
905
|
+
readonly nativeType: NativeType;
|
|
906
|
+
readonly executionDefaults: {
|
|
907
|
+
readonly onCreate: {
|
|
908
|
+
readonly kind: "select";
|
|
909
|
+
readonly index: 0;
|
|
910
|
+
readonly cases: {
|
|
911
|
+
readonly now: {
|
|
912
|
+
readonly kind: "generator";
|
|
913
|
+
readonly id: "timestampNow";
|
|
914
|
+
};
|
|
915
|
+
};
|
|
916
|
+
};
|
|
917
|
+
readonly onUpdate: {
|
|
918
|
+
readonly kind: "select";
|
|
919
|
+
readonly index: 1;
|
|
920
|
+
readonly cases: {
|
|
921
|
+
readonly now: {
|
|
922
|
+
readonly kind: "generator";
|
|
923
|
+
readonly id: "timestampNow";
|
|
924
|
+
};
|
|
925
|
+
};
|
|
926
|
+
};
|
|
927
|
+
};
|
|
928
|
+
};
|
|
929
|
+
};
|
|
808
930
|
//#endregion
|
|
809
931
|
//#region src/exports/control.d.ts
|
|
810
932
|
declare const _default: SqlFamilyDescriptor;
|
|
811
933
|
//#endregion
|
|
812
|
-
export { type CodecControlHooks, type ContractToSchemaIROptions, type ControlPolicySubject, type CreateSqlMigrationPlanOptions, type DefaultRenderer, type EnumNamespaceSchemaResolver, type ExpandNativeTypeInput, type FieldEvent, type FieldEventContext, INIT_ADDITIVE_POLICY, type MigrationOperationClass, type MigrationOperationPolicy, type MigrationPlan, type MigrationPlanOperation, type MigrationPlanner, type MigrationPlannerConflict, type MigrationPlannerResult, type NativeTypeExpander, type PlanFieldEventOperationsOptions, type ResolveIdentityValueInput, type SqlControlAdapterDescriptor, type SqlControlExtensionDescriptor, type SqlControlFamilyInstance, type SqlControlTargetDescriptor, type SqlDescribedContractSpace, type SqlMigrationPlan, type SqlMigrationPlanContractInfo, type SqlMigrationPlanOperation, type SqlMigrationPlanOperationStep, type SqlMigrationPlanOperationTarget, type SqlMigrationPlanner, type SqlMigrationPlannerPlanOptions, type SqlMigrationRunner, type SqlMigrationRunnerErrorCode, type SqlMigrationRunnerExecuteCallbacks, type SqlMigrationRunnerExecuteOptions, type SqlMigrationRunnerFailure, type SqlMigrationRunnerResult, type SqlMigrationRunnerSuccessValue, type SqlPlanTargetDetails, type SqlPlannerConflict, type SqlPlannerConflictKind, type SqlPlannerConflictLocation, type SqlPlannerFailureResult, type SqlPlannerResult, type SqlPlannerSuccessResult, type SqlSchemaDiffFn, type SqlSchemaDiffInput, type SqlSchemaDiffResult, type StorageTypePlanResult, type SuppressionRecord, type TargetMigrationsCapability, assembleAuthoringContributions, buildNativeTypeExpander, contractNamespaceToSchemaIR, contractToSchemaIR, controlPolicyForCall, createMigrationPlan, _default as default, detectDestructiveChanges, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, resolveValueSetValues, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
|
|
934
|
+
export { type CodecControlHooks, type ContractToSchemaIROptions, type ControlPolicySubject, type CreateSqlMigrationPlanOptions, type DefaultRenderer, type DefaultResolver, type EnumNamespaceSchemaResolver, type ExpandNativeTypeInput, type FieldEvent, type FieldEventContext, INIT_ADDITIVE_POLICY, type MigrationOperationClass, type MigrationOperationPolicy, type MigrationPlan, type MigrationPlanOperation, type MigrationPlanner, type MigrationPlannerConflict, type MigrationPlannerResult, type NativeTypeExpander, type PlanFieldEventOperationsOptions, type ResolveIdentityValueInput, type SqlControlAdapterDescriptor, type SqlControlExtensionDescriptor, type SqlControlFamilyInstance, type SqlControlTargetDescriptor, type SqlDescribedContractSpace, type SqlMigrationPlan, type SqlMigrationPlanContractInfo, type SqlMigrationPlanOperation, type SqlMigrationPlanOperationStep, type SqlMigrationPlanOperationTarget, type SqlMigrationPlanner, type SqlMigrationPlannerPlanOptions, type SqlMigrationRunner, type SqlMigrationRunnerErrorCode, type SqlMigrationRunnerExecuteCallbacks, type SqlMigrationRunnerExecuteOptions, type SqlMigrationRunnerFailure, type SqlMigrationRunnerResult, type SqlMigrationRunnerSuccessValue, type SqlPlanTargetDetails, type SqlPlannerConflict, type SqlPlannerConflictKind, type SqlPlannerConflictLocation, type SqlPlannerFailureResult, type SqlPlannerResult, type SqlPlannerSuccessResult, type SqlSchemaDiffFn, type SqlSchemaDiffInput, type SqlSchemaDiffResult, type StorageTypePlanResult, type SuppressionRecord, type TargetMigrationsCapability, assembleAuthoringContributions, buildNativeTypeExpander, contractNamespaceToSchemaIR, contractToSchemaIR, controlPolicyForCall, createMigrationPlan, _default as default, detectDestructiveChanges, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, resolveValueSetValues, runnerFailure, runnerSuccess, temporalAuthoringPresets, temporalCodecPreset, temporalCodecPresetWithPrecision, timestampNowControlDescriptor };
|
|
813
935
|
//# sourceMappingURL=control.d.mts.map
|
package/dist/control.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-instance.ts","../src/core/control-descriptor.ts","../src/core/assembly.ts","../src/core/control-target-descriptor.ts","../src/core/migrations/contract-to-schema-ir.ts","../src/core/migrations/control-policy.ts","../src/core/migrations/field-event-planner.ts","../src/core/migrations/native-type-expander.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-instance.ts","../src/core/control-descriptor.ts","../src/core/assembly.ts","../src/core/control-target-descriptor.ts","../src/core/migrations/contract-to-schema-ir.ts","../src/core/migrations/control-policy.ts","../src/core/migrations/field-event-planner.ts","../src/core/migrations/native-type-expander.ts","../src/core/migrations/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control.ts"],"mappings":";;;;;;;;;;;;;;UAwLU;WACC;WACA;WACA;WACA;;KAGN,0BAA0B,YAAY;UAEjC;WACC,kBAAkB,cAAc;WAChC,cAAc;WACd,sBAAsB;;UAGhB,iCACP,6BAA6B,kBACnC,kBAAkB,kBAClB,wBAAwB,kBACxB,yBACA;;;;;;;;;EASF,oBAAoB,wBAAwB;EAE5C,OAAO;aACI,QAAQ;aACR;aACA;aACA;aACA;MACP,QAAQ;;;;;;;;;;EAWZ,aAAa;aACF;aACA,QAAQ;aACR;aACA,qBAAqB,cAAc;MAC1C;;;;;;;;;;EAWJ,2BAA2B,OAAO,kBAAkB;;;;;;;;EASpD,mBAAmB,OAAO;EAE1B,KAAK;aACM,QAAQ;aACR;aACA;aACA;MACP,QAAQ;EAEZ,WAAW;aACA,QAAQ;aACR;MACP,QAAQ;EAEZ,iBAAiB,UAAU,kB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B,uBACnB,wBAAwB;iBAsBX,eAAe,oBAAoB,uBAAuB;;;;iBAoB1D,cAAc;EAC5B;EACA;IACE,GAAG;;;;iBAYS,cACd,MAAM,6BACN,iBACA;EAAY;EAAc,OAAO;IAChC,MAAM;;;;;;cC1KI,sBAAsB;;;;;;;;;;;;;;iBCsBnB,iCAAiC;;;;;;;;;;;iBAqBjC,+BACR,8BACA,2BACN;WAAkB,SAAS;WAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsE3C,uCACR,8BACA,2BACN;WAAkB,SAAS;WAAkB,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsB3C,0BACR,8BACA,2BACN;WAAkB,SAAS;WAAkB,YAAY"}
|
package/dist/control.mjs
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { i as sqlFamilyPslBlockDescriptors, n as sqlFamilyAuthoringFieldPresets, r as sqlFamilyEntityTypes, t as sqlFamilyAuthoringTypes } from "./authoring-type-constructors-CXd-8ydc.mjs";
|
|
2
|
-
import { n as classifyDiffSubjectGranularity, o as verifySqlSchemaByDiff, s as extractCodecControlHooks, t as classifyDiffEntityKind } from "./schema-verify-
|
|
2
|
+
import { n as classifyDiffSubjectGranularity, o as verifySqlSchemaByDiff, s as extractCodecControlHooks, t as classifyDiffEntityKind } from "./schema-verify-DY21bMwy.mjs";
|
|
3
3
|
import { t as SqlContractSerializer } from "./sql-contract-serializer-C75cfMSS.mjs";
|
|
4
4
|
import { t as collectSupportedCodecTypeIds } from "./verify-C-G0obRm.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { n as temporalAuthoringPresets, r as timestampNowControlDescriptor } from "./timestamp-now-generator-CloimujU.mjs";
|
|
5
|
+
import { a as timestampNowControlDescriptor, i as temporalCodecPresetWithPrecision, n as temporalAuthoringPresets, r as temporalCodecPreset } from "./timestamp-now-generator-DRXygu32.mjs";
|
|
7
6
|
import { sqlEmission } from "@prisma-next/sql-contract-emitter";
|
|
8
7
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
9
8
|
import { APP_SPACE_ID, SchemaTreeNode, VERIFY_CODE_HASH_MISMATCH, VERIFY_CODE_MARKER_MISSING, VERIFY_CODE_TARGET_MISMATCH, assembleAuthoringContributions } from "@prisma-next/framework-components/control";
|
|
@@ -14,7 +13,7 @@ import { defaultIndexName } from "@prisma-next/sql-schema-ir/naming";
|
|
|
14
13
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
15
14
|
import { effectiveControlPolicy } from "@prisma-next/contract/types";
|
|
16
15
|
import { StorageTable, isStorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
17
|
-
import { SqlSchemaIR, SqlTableIR } from "@prisma-next/sql-schema-ir/types";
|
|
16
|
+
import { RelationalSchemaNodeKind, SqlSchemaIR, SqlTableIR } from "@prisma-next/sql-schema-ir/types";
|
|
18
17
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
19
18
|
//#region src/core/operation-preview.ts
|
|
20
19
|
function isDdlStatement(sqlStatement) {
|
|
@@ -576,7 +575,7 @@ var SqlFamilyDescriptor = class {
|
|
|
576
575
|
};
|
|
577
576
|
//#endregion
|
|
578
577
|
//#region src/core/migrations/contract-to-schema-ir.ts
|
|
579
|
-
function convertColumn(name, column, storageTypes, expandNativeType, renderDefault) {
|
|
578
|
+
function convertColumn(name, column, storageTypes, expandNativeType, renderDefault, resolveDefault) {
|
|
580
579
|
const resolved = resolveColumnTypeMetadata(column, storageTypes);
|
|
581
580
|
const baseNativeType = expandNativeType ? expandNativeType({
|
|
582
581
|
nativeType: resolved.nativeType,
|
|
@@ -585,6 +584,8 @@ function convertColumn(name, column, storageTypes, expandNativeType, renderDefau
|
|
|
585
584
|
}) : resolved.nativeType;
|
|
586
585
|
const nativeType = baseNativeType;
|
|
587
586
|
const resolvedNativeType = column.many ? `${baseNativeType}[]` : baseNativeType;
|
|
587
|
+
const rawColumnDefault = column.default ?? void 0;
|
|
588
|
+
const resolvedColumnDefault = rawColumnDefault !== void 0 && resolveDefault ? resolveDefault(rawColumnDefault, resolvedNativeType) : rawColumnDefault;
|
|
588
589
|
return {
|
|
589
590
|
name,
|
|
590
591
|
nativeType,
|
|
@@ -592,7 +593,7 @@ function convertColumn(name, column, storageTypes, expandNativeType, renderDefau
|
|
|
592
593
|
...ifDefined("many", column.many),
|
|
593
594
|
...ifDefined("default", column.default != null && renderDefault ? renderDefault(column.default, column) : void 0),
|
|
594
595
|
resolvedNativeType,
|
|
595
|
-
...ifDefined("resolvedDefault",
|
|
596
|
+
...ifDefined("resolvedDefault", resolvedColumnDefault),
|
|
596
597
|
codecRef: buildColumnCodecRef(resolved, column.many),
|
|
597
598
|
codecBaseNativeType: resolved.nativeType,
|
|
598
599
|
...column.typeRef !== void 0 ? { codecNamedType: true } : {}
|
|
@@ -664,22 +665,63 @@ function convertCheck(check, storage) {
|
|
|
664
665
|
permittedValues
|
|
665
666
|
};
|
|
666
667
|
}
|
|
667
|
-
function convertUnique(unique) {
|
|
668
|
+
function convertUnique(unique, tableName) {
|
|
668
669
|
return {
|
|
669
670
|
columns: unique.columns,
|
|
670
|
-
...ifDefined("name", unique.name)
|
|
671
|
+
...ifDefined("name", unique.name),
|
|
672
|
+
dependsOn: flatColumnDependsOn(tableName, unique.columns)
|
|
671
673
|
};
|
|
672
674
|
}
|
|
673
|
-
function convertIndex(index) {
|
|
675
|
+
function convertIndex(index, tableName) {
|
|
674
676
|
return {
|
|
675
677
|
columns: index.columns,
|
|
676
678
|
unique: false,
|
|
677
679
|
...ifDefined("name", index.name),
|
|
678
680
|
...ifDefined("type", index.type),
|
|
679
|
-
...ifDefined("options", index.options)
|
|
681
|
+
...ifDefined("options", index.options),
|
|
682
|
+
dependsOn: flatColumnDependsOn(tableName, index.columns)
|
|
680
683
|
};
|
|
681
684
|
}
|
|
682
685
|
/**
|
|
686
|
+
* The referenced table's chain in the flat (single-schema) tree
|
|
687
|
+
* `contractToSchemaIR`/`contractNamespaceToSchemaIR` build: the root
|
|
688
|
+
* (`SqlSchemaIR`, fixed `'database'` id) followed by the table's own id.
|
|
689
|
+
* Postgres discards this when it re-derives the FK against its own
|
|
690
|
+
* multi-schema tree shape (`contractToPostgresDatabaseSchemaNode`); SQLite's
|
|
691
|
+
* flat tree uses it as-is.
|
|
692
|
+
*/
|
|
693
|
+
function flatSchemaDependsOn(tableName) {
|
|
694
|
+
return [{
|
|
695
|
+
nodeKind: RelationalSchemaNodeKind.schema,
|
|
696
|
+
id: "database"
|
|
697
|
+
}, {
|
|
698
|
+
nodeKind: RelationalSchemaNodeKind.table,
|
|
699
|
+
id: tableName
|
|
700
|
+
}];
|
|
701
|
+
}
|
|
702
|
+
/**
|
|
703
|
+
* The chains from a table-child object (foreign key, index, unique, primary
|
|
704
|
+
* key) to each of the own columns it is built on, in the flat tree. Dropping
|
|
705
|
+
* a covered column auto-drops the object, so the object's drop must precede
|
|
706
|
+
* the column's; the graph derives that direction from these edges.
|
|
707
|
+
*/
|
|
708
|
+
function flatColumnDependsOn(tableName, columns) {
|
|
709
|
+
return columns.map((column) => [
|
|
710
|
+
{
|
|
711
|
+
nodeKind: RelationalSchemaNodeKind.schema,
|
|
712
|
+
id: "database"
|
|
713
|
+
},
|
|
714
|
+
{
|
|
715
|
+
nodeKind: RelationalSchemaNodeKind.table,
|
|
716
|
+
id: tableName
|
|
717
|
+
},
|
|
718
|
+
{
|
|
719
|
+
nodeKind: RelationalSchemaNodeKind.column,
|
|
720
|
+
id: `column:${column}`
|
|
721
|
+
}
|
|
722
|
+
]);
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
683
725
|
* The FK's referenced-namespace identity comes from the target's namespace
|
|
684
726
|
* node, not the raw namespace-id string. An unbound target namespace stamps
|
|
685
727
|
* no `referencedSchema` at all — the FK node's id renders the absence as the
|
|
@@ -688,6 +730,10 @@ function convertIndex(index) {
|
|
|
688
730
|
* cross-space target whose namespace lives in another contract's storage)
|
|
689
731
|
* stamps its coordinate verbatim; namespaced targets (Postgres) resolve the
|
|
690
732
|
* real DDL schema downstream.
|
|
733
|
+
*
|
|
734
|
+
* `dependsOn` carries the referenced table (created before the FK, dropped
|
|
735
|
+
* after it) plus the FK's own columns (dropped after the FK, since dropping a
|
|
736
|
+
* column auto-drops the FK built on it).
|
|
691
737
|
*/
|
|
692
738
|
function convertForeignKey(fk, storage) {
|
|
693
739
|
const targetIsUnbound = storage.namespaces[fk.target.namespaceId]?.isUnbound === true;
|
|
@@ -698,33 +744,25 @@ function convertForeignKey(fk, storage) {
|
|
|
698
744
|
referencedColumns: fk.target.columns,
|
|
699
745
|
...ifDefined("name", fk.name),
|
|
700
746
|
...ifDefined("onDelete", fk.onDelete),
|
|
701
|
-
...ifDefined("onUpdate", fk.onUpdate)
|
|
747
|
+
...ifDefined("onUpdate", fk.onUpdate),
|
|
748
|
+
dependsOn: [flatSchemaDependsOn(fk.target.tableName), ...flatColumnDependsOn(fk.source.tableName, fk.source.columns)]
|
|
702
749
|
};
|
|
703
750
|
}
|
|
704
|
-
function convertTable(name, table, storageTypes, expandNativeType, renderDefault, storage) {
|
|
751
|
+
function convertTable(name, table, storageTypes, expandNativeType, renderDefault, resolveDefault, storage) {
|
|
705
752
|
const columns = {};
|
|
706
|
-
for (const [colName, colDef] of Object.entries(table.columns)) columns[colName] = convertColumn(colName, colDef, storageTypes, expandNativeType, renderDefault);
|
|
707
|
-
const satisfiedIndexColumns = new Set(backingIndexColumnKeys(table));
|
|
708
|
-
const fkBackingIndexes = [];
|
|
709
|
-
for (const fk of table.foreignKeys) {
|
|
710
|
-
if (fk.index === false) continue;
|
|
711
|
-
const key = fk.source.columns.join(",");
|
|
712
|
-
if (satisfiedIndexColumns.has(key)) continue;
|
|
713
|
-
fkBackingIndexes.push({
|
|
714
|
-
columns: fk.source.columns,
|
|
715
|
-
unique: false,
|
|
716
|
-
name: defaultIndexName(name, fk.source.columns)
|
|
717
|
-
});
|
|
718
|
-
satisfiedIndexColumns.add(key);
|
|
719
|
-
}
|
|
753
|
+
for (const [colName, colDef] of Object.entries(table.columns)) columns[colName] = convertColumn(colName, colDef, storageTypes, expandNativeType, renderDefault, resolveDefault);
|
|
720
754
|
const checks = table.checks && table.checks.length > 0 ? table.checks.map((c) => convertCheck(c, storage)) : void 0;
|
|
721
755
|
return new SqlTableIR({
|
|
722
756
|
name,
|
|
723
757
|
columns,
|
|
724
|
-
...ifDefined("primaryKey", table.primaryKey
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
758
|
+
...ifDefined("primaryKey", table.primaryKey !== void 0 ? {
|
|
759
|
+
columns: table.primaryKey.columns,
|
|
760
|
+
...ifDefined("name", table.primaryKey.name),
|
|
761
|
+
dependsOn: flatColumnDependsOn(name, table.primaryKey.columns)
|
|
762
|
+
} : void 0),
|
|
763
|
+
foreignKeys: table.foreignKeys.map((fk) => convertForeignKey(fk, storage)),
|
|
764
|
+
uniques: table.uniques.map((u) => convertUnique(u, name)),
|
|
765
|
+
indexes: table.indexes.map((i) => convertIndex(i, name)),
|
|
728
766
|
...ifDefined("checks", checks)
|
|
729
767
|
});
|
|
730
768
|
}
|
|
@@ -804,7 +842,7 @@ function contractNamespaceToSchemaIR(storage, namespaceId, options) {
|
|
|
804
842
|
const tables = {};
|
|
805
843
|
for (const [tableName, tableDefRaw] of Object.entries(namespace.entries.table ?? {})) {
|
|
806
844
|
StorageTable.assert(tableDefRaw, `namespaces.${namespaceId}.entries.table.${tableName}`);
|
|
807
|
-
tables[tableName] = convertTable(tableName, tableDefRaw, storageTypes, options.expandNativeType, options.renderDefault, storage);
|
|
845
|
+
tables[tableName] = convertTable(tableName, tableDefRaw, storageTypes, options.expandNativeType, options.renderDefault, options.resolveDefault, storage);
|
|
808
846
|
}
|
|
809
847
|
return new SqlSchemaIR({ tables });
|
|
810
848
|
}
|
|
@@ -818,7 +856,7 @@ function contractToSchemaIR(contract, options) {
|
|
|
818
856
|
StorageTable.assert(tableDefRaw, `namespaces.${ns.id}.entries.table.${tableName}`);
|
|
819
857
|
const tableDef = tableDefRaw;
|
|
820
858
|
if (tables[tableName] !== void 0) throw new Error(`contractToSchemaIR: duplicate SQL table name "${tableName}" across namespaces (ambiguous for flat SqlSchemaIR.tables).`);
|
|
821
|
-
tables[tableName] = convertTable(tableName, tableDef, storageTypes, options.expandNativeType, options.renderDefault, storage);
|
|
859
|
+
tables[tableName] = convertTable(tableName, tableDef, storageTypes, options.expandNativeType, options.renderDefault, options.resolveDefault, storage);
|
|
822
860
|
}
|
|
823
861
|
return new SqlSchemaIR({
|
|
824
862
|
tables,
|
|
@@ -1226,6 +1264,6 @@ const INIT_ADDITIVE_POLICY = Object.freeze({ allowedOperationClasses: Object.fre
|
|
|
1226
1264
|
//#region src/exports/control.ts
|
|
1227
1265
|
var control_default = new SqlFamilyDescriptor();
|
|
1228
1266
|
//#endregion
|
|
1229
|
-
export { INIT_ADDITIVE_POLICY, assembleAuthoringContributions, buildNativeTypeExpander, contractNamespaceToSchemaIR, contractToSchemaIR, controlPolicyForCall, createMigrationPlan, control_default as default, detectDestructiveChanges, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, resolveValueSetValues, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
|
|
1267
|
+
export { INIT_ADDITIVE_POLICY, assembleAuthoringContributions, buildNativeTypeExpander, contractNamespaceToSchemaIR, contractToSchemaIR, controlPolicyForCall, createMigrationPlan, control_default as default, detectDestructiveChanges, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, resolveValueSetValues, runnerFailure, runnerSuccess, temporalAuthoringPresets, temporalCodecPreset, temporalCodecPresetWithPrecision, timestampNowControlDescriptor };
|
|
1230
1268
|
|
|
1231
1269
|
//# sourceMappingURL=control.mjs.map
|