@prisma-next/family-sql 0.13.0-dev.6 → 0.13.0-dev.8
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.d.mts +18 -19
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +7 -6
- package/dist/control.mjs.map +1 -1
- package/dist/schema-verify.mjs +1 -1
- package/dist/{verify-sql-schema-DlAgBiT_.mjs → verify-sql-schema-DSjiDPmO.mjs} +18 -9
- package/dist/verify-sql-schema-DSjiDPmO.mjs.map +1 -0
- package/package.json +21 -21
- package/src/core/migrations/contract-to-schema-ir.ts +43 -42
- package/src/core/psl-contract-infer/postgres-type-map.ts +18 -9
- package/src/exports/control.ts +1 -1
- package/dist/verify-sql-schema-DlAgBiT_.mjs.map +0 -1
package/dist/control.d.mts
CHANGED
|
@@ -272,20 +272,19 @@ type NativeTypeExpander = (input: {
|
|
|
272
272
|
*/
|
|
273
273
|
type DefaultRenderer = (def: ColumnDefault, column: StorageColumn) => string;
|
|
274
274
|
/**
|
|
275
|
-
* Target-supplied callback that
|
|
276
|
-
*
|
|
275
|
+
* Target-supplied callback that resolves a contract namespace to the live
|
|
276
|
+
* database schema its enums are stored under.
|
|
277
277
|
*
|
|
278
|
-
*
|
|
279
|
-
* namespaces holding an enum with
|
|
280
|
-
* native type
|
|
281
|
-
*
|
|
282
|
-
*
|
|
283
|
-
*
|
|
284
|
-
*
|
|
285
|
-
* target
|
|
286
|
-
* still emits keys that match the target's read side exactly.
|
|
278
|
+
* The projected enum annotations are nested by schema
|
|
279
|
+
* (`storageTypes[schema][nativeType]`) so two namespaces holding an enum with
|
|
280
|
+
* the same native type resolve to distinct live-database types. Mapping a
|
|
281
|
+
* namespace to its DDL schema is target-specific (Postgres schemas;
|
|
282
|
+
* SQLite/MySQL differ), so the target injects it here rather than the family
|
|
283
|
+
* importing a concrete `ddlSchemaName`. This keeps the family layer
|
|
284
|
+
* target-agnostic while the projection nests under the same schema the
|
|
285
|
+
* target's read side (`readExistingEnumValues`) looks up.
|
|
287
286
|
*/
|
|
288
|
-
type
|
|
287
|
+
type EnumNamespaceSchemaResolver = (storage: SqlStorage, namespaceId: string) => string;
|
|
289
288
|
/**
|
|
290
289
|
* Resolves a `ValueSetRef` to its permitted values from the contract storage.
|
|
291
290
|
*
|
|
@@ -315,13 +314,13 @@ interface ContractToSchemaIROptions {
|
|
|
315
314
|
readonly expandNativeType?: NativeTypeExpander;
|
|
316
315
|
readonly renderDefault?: DefaultRenderer;
|
|
317
316
|
/**
|
|
318
|
-
* Target-supplied resolver
|
|
319
|
-
*
|
|
320
|
-
*
|
|
321
|
-
* `readExistingEnumValues` lookup. Targets without
|
|
322
|
-
* storage (SQLite) omit it; enums are absent there.
|
|
317
|
+
* Target-supplied resolver mapping a namespace to the live database schema
|
|
318
|
+
* its enums are stored under. When provided (Postgres), namespace-scoped
|
|
319
|
+
* enums are nested by that schema in `enumTypes` so the projection matches
|
|
320
|
+
* the target's `readExistingEnumValues` lookup. Targets without
|
|
321
|
+
* schema-scoped enum storage (SQLite) omit it; enums are absent there.
|
|
323
322
|
*/
|
|
324
|
-
readonly
|
|
323
|
+
readonly resolveEnumNamespaceSchema?: EnumNamespaceSchemaResolver;
|
|
325
324
|
}
|
|
326
325
|
/**
|
|
327
326
|
* Converts a `Contract` to `SqlSchemaIR`.
|
|
@@ -562,5 +561,5 @@ declare function temporalAuthoringPresets<const CodecId extends string, const Na
|
|
|
562
561
|
//#region src/exports/control.d.ts
|
|
563
562
|
declare const _default: SqlFamilyDescriptor;
|
|
564
563
|
//#endregion
|
|
565
|
-
export { type CodecControlHooks, type ContractToSchemaIROptions, type ControlPolicySubject, type CreateSqlMigrationPlanOptions, type DefaultRenderer, type
|
|
564
|
+
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 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 StorageTypePlanResult, type TargetMigrationsCapability, assembleAuthoringContributions, contractToSchemaIR, controlPolicyForCall, createMigrationPlan, _default as default, detectDestructiveChanges, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure, plannerSuccess, resolveValueSetValues, runnerFailure, runnerSuccess, temporalAuthoringPresets, timestampNowControlDescriptor };
|
|
566
565
|
//# 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-descriptor.ts","../src/core/assembly.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/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control.ts"],"mappings":";;;;;;;;;;cAUa,mBAAA,YACA,uBAAA,QAA+B,wBAAA;EAAA,SAEjC,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA,EAAU,WAAA;EAAA,SACV,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAKT,MAAA,2BACE,KAAA,EAAO,YAAA,QAAoB,SAAA,IAC1B,wBAAA;AAAA;;;iBCHW,wBAAA,CACd,WAAA,EAAa,aAAA,CAAc,8BAAA,mBAC1B,GAAA,SAAY,iBAAA;;;;;;;;;ADdf;;;;KE+BY,kBAAA,IAAsB,KAAA;EAAA,SACvB,UAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA,GAAa,MAAM;AAAA;;;;;;;;;;KAYlB,eAAA,IAAmB,GAAA,EAAK,aAAA,EAAe,MAAA,EAAQ,aAAa
|
|
1
|
+
{"version":3,"file":"control.d.mts","names":[],"sources":["../src/core/control-descriptor.ts","../src/core/assembly.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/plan-helpers.ts","../src/core/migrations/policies.ts","../src/core/timestamp-now-generator.ts","../src/exports/control.ts"],"mappings":";;;;;;;;;;cAUa,mBAAA,YACA,uBAAA,QAA+B,wBAAA;EAAA,SAEjC,IAAA;EAAA,SACA,EAAA;EAAA,SACA,QAAA;EAAA,SACA,OAAA;EAAA,SACA,QAAA,EAAU,WAAA;EAAA,SACV,SAAA;IAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AA,CAAwB,cAAA;AAAA,iBAsBX,cAAA,CAAe,SAAA,WAAoB,kBAAA,KAAuB,uBAAuB;;;;iBAoBjF,aAAA,CAAc,KAAA;EAC5B,iBAAA;EACA,kBAAA;AAAA,IACE,EAAE,CAAC,8BAAA;;;;iBAYS,aAAA,CACd,IAAA,EAAM,2BAAA,EACN,OAAA,UACA,OAAA;EAAY,GAAA;EAAc,IAAA,GAAO,SAAA;AAAA,IAChC,KAAA,CAAM,yBAAA;;;;;;cC1KI,oBAAA,EAAsB,0BAEjC;;;;;;;;;;;;;;iBCoBc,6BAAA,IAAiC,kCAAkC;;;;;;;;;;;iBAqBnE,wBAAA,gEAGd,KAAA;EAAA,SAAkB,OAAA,EAAS,OAAA;EAAA,SAAkB,UAAA,EAAY,UAAA;AAAA;EAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cC6BlB,QAAA"}
|
package/dist/control.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as sqlFamilyAuthoringFieldPresets, t as sqlFamilyAuthoringTypes } from "./authoring-type-constructors-D4lQ-qpj.mjs";
|
|
2
2
|
import { t as SqlContractSerializer } from "./sql-contract-serializer-CY7qnms7.mjs";
|
|
3
|
-
import { a as contractToSchemaIR, c as extractCodecControlHooks, o as detectDestructiveChanges, s as resolveValueSetValues, t as verifySqlSchema } from "./verify-sql-schema-
|
|
3
|
+
import { a as contractToSchemaIR, c as extractCodecControlHooks, o as detectDestructiveChanges, s as resolveValueSetValues, t as verifySqlSchema } from "./verify-sql-schema-DSjiDPmO.mjs";
|
|
4
4
|
import { t as collectSupportedCodecTypeIds } from "./verify-C-G0obRm.mjs";
|
|
5
5
|
import { n as temporalAuthoringPresets, r as timestampNowControlDescriptor } from "./timestamp-now-generator-CloimujU.mjs";
|
|
6
6
|
import { sqlEmission } from "@prisma-next/sql-contract-emitter";
|
|
@@ -387,14 +387,15 @@ function createPostgresTypeMap(enumTypeNames) {
|
|
|
387
387
|
} };
|
|
388
388
|
}
|
|
389
389
|
function extractEnumInfo(annotations) {
|
|
390
|
-
const
|
|
390
|
+
const enumTypes = (annotations?.["pg"])?.["enumTypes"];
|
|
391
391
|
const typeNames = /* @__PURE__ */ new Set();
|
|
392
392
|
const definitions = /* @__PURE__ */ new Map();
|
|
393
|
-
if (
|
|
394
|
-
for (const
|
|
395
|
-
|
|
393
|
+
if (enumTypes) {
|
|
394
|
+
for (const bySchema of Object.values(enumTypes)) for (const typeInstance of Object.values(bySchema)) if (typeInstance.codecId === ENUM_CODEC_ID) {
|
|
395
|
+
const nativeType = typeInstance.nativeType;
|
|
396
|
+
typeNames.add(nativeType);
|
|
396
397
|
const values = typeInstance.typeParams?.["values"];
|
|
397
|
-
if (Array.isArray(values)) definitions.set(
|
|
398
|
+
if (Array.isArray(values) && values.every((v) => typeof v === "string")) definitions.set(nativeType, values);
|
|
398
399
|
}
|
|
399
400
|
}
|
|
400
401
|
return {
|