@prisma/orm-target-postgres 8.0.0-rc.11-dev.16 → 8.0.0-rc.11-dev.17
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/{adapter-DDfZMW0M-Cqq4b6_G.mjs → adapter-bTD1EPrl-DQ66tQwz.mjs} +3 -3
- package/dist/{adapter-DDfZMW0M-Cqq4b6_G.mjs.map → adapter-bTD1EPrl-DQ66tQwz.mjs.map} +1 -1
- package/dist/adapter.d.mts +2 -2
- package/dist/adapter.mjs +3 -3
- package/dist/adapter__adapter.mjs +1 -1
- package/dist/adapter__control.d.mts +2 -2
- package/dist/adapter__control.mjs +5 -4
- package/dist/adapter__control.mjs.map +1 -1
- package/dist/adapter__runtime.mjs +8 -3
- package/dist/adapter__runtime.mjs.map +1 -1
- package/dist/{authoring-DgeWf8RC-C-jQzf_w.mjs → authoring-Beq66XGy-D-GgvlBG.mjs} +63 -20
- package/dist/authoring-Beq66XGy-D-GgvlBG.mjs.map +1 -0
- package/dist/authoring-xyQRYoem-DWCGb5Py.d.mts +36 -0
- package/dist/authoring-xyQRYoem-DWCGb5Py.d.mts.map +1 -0
- package/dist/control-206OMpyA.mjs +470 -0
- package/dist/control-206OMpyA.mjs.map +1 -0
- package/dist/{control--T7XaMS8.d.mts → control-BvK2pHHh.d.mts} +2 -2
- package/dist/{control--T7XaMS8.d.mts.map → control-BvK2pHHh.d.mts.map} +1 -1
- package/dist/{control-xdW1bgaP.d.mts → control-DmVutloY.d.mts} +2 -2
- package/dist/{control-xdW1bgaP.d.mts.map → control-DmVutloY.d.mts.map} +1 -1
- package/dist/{control-adapter-5et6pVM9-B5CKg-5B.mjs → control-adapter-Bdz-Xa1p-rKiOVhsh.mjs} +96 -28
- package/dist/control-adapter-Bdz-Xa1p-rKiOVhsh.mjs.map +1 -0
- package/dist/{control-policy-BKgU_M65-BWedWA-f.mjs → control-policy-B8x7UxGf-BjTez7am.mjs} +24 -17
- package/dist/control-policy-B8x7UxGf-BjTez7am.mjs.map +1 -0
- package/dist/{default-normalizer-Ba5ZebHM-isV86rjy.mjs → default-normalizer-Bjtm2F4f-uV5vvkVt.mjs} +160 -33
- package/dist/default-normalizer-Bjtm2F4f-uV5vvkVt.mjs.map +1 -0
- package/dist/{default-normalizer-B36TOul4.d.mts → default-normalizer-D9WbKo20.d.mts} +2 -2
- package/dist/{default-normalizer-B36TOul4.d.mts.map → default-normalizer-D9WbKo20.d.mts.map} +1 -1
- package/dist/{descriptor-meta-C4i4pLQn-CmdN74uG.mjs → descriptor-meta-BhJOswpM-CqvnQMC0.mjs} +3 -3
- package/dist/{descriptor-meta-C4i4pLQn-CmdN74uG.mjs.map → descriptor-meta-BhJOswpM-CqvnQMC0.mjs.map} +1 -1
- package/dist/{diff-database-schema-BaSP2z4y-Ch42uw-j.mjs → diff-database-schema-BFX0ZWWK-KVfAPOLF.mjs} +4 -4
- package/dist/{diff-database-schema-BaSP2z4y-Ch42uw-j.mjs.map → diff-database-schema-BFX0ZWWK-KVfAPOLF.mjs.map} +1 -1
- package/dist/{control-BC3oXXIK.mjs → infer-psl-contract-BaZaJAD9-DTVu5Zab.mjs} +110 -488
- package/dist/infer-psl-contract-BaZaJAD9-DTVu5Zab.mjs.map +1 -0
- package/dist/migration-PTHAY9Cv.mjs.map +1 -1
- package/dist/{op-factory-call-6Jg-ycA--4AC_11Od.mjs → op-factory-call-B3-CevCo-CSV5SL9W.mjs} +3 -3
- package/dist/{op-factory-call-6Jg-ycA--4AC_11Od.mjs.map → op-factory-call-B3-CevCo-CSV5SL9W.mjs.map} +1 -1
- package/dist/{pack-D8V-43m8.d.mts → pack-CRA_2QjF.d.mts} +8 -38
- package/dist/pack-CRA_2QjF.d.mts.map +1 -0
- package/dist/plain-date-time-now-generator-DJ3icyVr-B-rdIVd3.d.mts +23 -0
- package/dist/plain-date-time-now-generator-DJ3icyVr-B-rdIVd3.d.mts.map +1 -0
- package/dist/{planner-C70Loeo_-qHTNBO3Q.mjs → planner-D_VBDqX0-C2jCXuIt.mjs} +6 -6
- package/dist/{planner-C70Loeo_-qHTNBO3Q.mjs.map → planner-D_VBDqX0-C2jCXuIt.mjs.map} +1 -1
- package/dist/{planner-ddl-builders-Cf6-fTvi-CKp-yZkB.mjs → planner-ddl-builders-CpXQ-J0X-CL5gNUSG.mjs} +14 -5
- package/dist/{planner-ddl-builders-Cf6-fTvi-CKp-yZkB.mjs.map → planner-ddl-builders-CpXQ-J0X-CL5gNUSG.mjs.map} +1 -1
- package/dist/{planner-ddl-builders-ijp60-JO.d.mts → planner-ddl-builders-bBCUsq_0.d.mts} +2 -2
- package/dist/planner-ddl-builders-bBCUsq_0.d.mts.map +1 -0
- package/dist/{planner-produced-postgres-migration-ButAgK7L-CZXweEva.mjs → planner-produced-postgres-migration-DwcW5RrQ-D0DPBmoS.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-ButAgK7L-CZXweEva.mjs.map → planner-produced-postgres-migration-DwcW5RrQ-D0DPBmoS.mjs.map} +1 -1
- package/dist/{postgres-contract-view-C22aDeL9-BWJIOpCz.mjs → postgres-contract-view-D7tYWHwD-DJNOh9Qo.mjs} +3 -3
- package/dist/{postgres-contract-view-C22aDeL9-BWJIOpCz.mjs.map → postgres-contract-view-D7tYWHwD-DJNOh9Qo.mjs.map} +1 -1
- package/dist/{postgres-migration-Cj-DvDY8-CIrWHp9I.mjs → postgres-migration-DXHNRgZA-HzAql-Bj.mjs} +4 -4
- package/dist/{postgres-migration-Cj-DvDY8-CIrWHp9I.mjs.map → postgres-migration-DXHNRgZA-HzAql-Bj.mjs.map} +1 -1
- package/dist/prisma7-binding-C38o_ABR.d.mts +1012 -0
- package/dist/prisma7-binding-C38o_ABR.d.mts.map +1 -0
- package/dist/prisma7-binding-DjpSw5G6.mjs +331 -0
- package/dist/prisma7-binding-DjpSw5G6.mjs.map +1 -0
- package/dist/{runtime-CpeP58Y6.d.mts → runtime-BRbiY5Vj.d.mts} +2 -2
- package/dist/{runtime-CpeP58Y6.d.mts.map → runtime-BRbiY5Vj.d.mts.map} +1 -1
- package/dist/target.d.mts +8 -7
- package/dist/target.mjs +13 -12
- package/dist/target__control.d.mts +3 -3
- package/dist/target__control.mjs +3 -3
- package/dist/target__default-normalizer.d.mts +1 -1
- package/dist/target__default-normalizer.mjs +1 -1
- package/dist/target__diff-database-schema.mjs +1 -1
- package/dist/target__issue-planner.mjs +1 -1
- package/dist/target__migration.mjs +2 -2
- package/dist/target__op-factory-call.mjs +1 -1
- package/dist/target__pack.d.mts +1 -1
- package/dist/target__pack.mjs +1 -1
- package/dist/target__planner-ddl-builders.d.mts +1 -1
- package/dist/target__planner-ddl-builders.mjs +1 -1
- package/dist/target__planner-produced-postgres-migration.mjs +1 -1
- package/dist/target__planner.mjs +2 -2
- package/dist/target__prisma7-binding.d.mts +2 -0
- package/dist/target__prisma7-binding.mjs +2 -0
- package/dist/target__runtime.d.mts +3 -3
- package/dist/target__runtime.mjs +3 -3
- package/dist/target__runtime.mjs.map +1 -1
- package/package.json +10 -9
- package/dist/authoring-DgeWf8RC-C-jQzf_w.mjs.map +0 -1
- package/dist/control-BC3oXXIK.mjs.map +0 -1
- package/dist/control-adapter-5et6pVM9-B5CKg-5B.mjs.map +0 -1
- package/dist/control-policy-BKgU_M65-BWedWA-f.mjs.map +0 -1
- package/dist/default-normalizer-Ba5ZebHM-isV86rjy.mjs.map +0 -1
- package/dist/list-decoder-8mZBUNe0-C9dPXUP0.d.mts +0 -13
- package/dist/list-decoder-8mZBUNe0-C9dPXUP0.d.mts.map +0 -1
- package/dist/pack-D8V-43m8.d.mts.map +0 -1
- package/dist/planner-ddl-builders-ijp60-JO.d.mts.map +0 -1
|
@@ -0,0 +1,470 @@
|
|
|
1
|
+
import { s as postgresError } from "./errors-DYyzTYzE-39CV_aMo.mjs";
|
|
2
|
+
import { n as postgresResolveDefault } from "./default-normalizer-Bjtm2F4f-uV5vvkVt.mjs";
|
|
3
|
+
import { t as postgresTargetDescriptorMeta } from "./descriptor-meta-BhJOswpM-CqvnQMC0.mjs";
|
|
4
|
+
import { a as postgresDiffSubjectGranularity, i as postgresDiffSubjectEntityKind } from "./postgres-table-schema-node-BBkitBQh-DT1T5VWU.mjs";
|
|
5
|
+
import { t as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs";
|
|
6
|
+
import { r as renderDefaultLiteral } from "./planner-ddl-builders-CpXQ-J0X-CL5gNUSG.mjs";
|
|
7
|
+
import { n as contractToPostgresDatabaseSchemaNode, r as diffPostgresSchema } from "./diff-database-schema-BFX0ZWWK-KVfAPOLF.mjs";
|
|
8
|
+
import { t as PostgresContractSerializer } from "./postgres-contract-view-D7tYWHwD-DJNOh9Qo.mjs";
|
|
9
|
+
import { t as createPostgresMigrationPlanner } from "./planner-D_VBDqX0-C2jCXuIt.mjs";
|
|
10
|
+
import { i as inferPostgresPslContract } from "./infer-psl-contract-BaZaJAD9-DTVu5Zab.mjs";
|
|
11
|
+
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
12
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
13
|
+
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
14
|
+
import { APP_SPACE_ID } from "@prisma/orm-framework/components/control";
|
|
15
|
+
import { buildNativeTypeExpander, runnerFailure, runnerSuccess } from "@prisma/orm-family-sql/family/control";
|
|
16
|
+
import { InternalError } from "@prisma/orm-framework/utils/internal-error";
|
|
17
|
+
import { notOk, ok, okVoid } from "@prisma/orm-framework/utils/result";
|
|
18
|
+
import { SqlSchemaVerifierBase } from "@prisma/orm-family-sql/family/ir";
|
|
19
|
+
import { SqlQueryError } from "@prisma/orm-family-sql/errors";
|
|
20
|
+
//#region ../../../3-targets/3-targets/postgres/dist/control.mjs
|
|
21
|
+
const LOCK_DOMAIN = "prisma_8.contract.marker";
|
|
22
|
+
/**
|
|
23
|
+
* Deep clones and freezes a record object to prevent mutation.
|
|
24
|
+
* Recursively clones nested objects and arrays to ensure complete isolation.
|
|
25
|
+
*/
|
|
26
|
+
function cloneAndFreezeRecord(value) {
|
|
27
|
+
const cloned = {};
|
|
28
|
+
for (const [key, val] of Object.entries(value)) if (val === null || val === void 0) cloned[key] = val;
|
|
29
|
+
else if (Array.isArray(val)) cloned[key] = Object.freeze([...val]);
|
|
30
|
+
else if (typeof val === "object") cloned[key] = cloneAndFreezeRecord(val);
|
|
31
|
+
else cloned[key] = val;
|
|
32
|
+
return Object.freeze(cloned);
|
|
33
|
+
}
|
|
34
|
+
function createPostgresMigrationRunner(family) {
|
|
35
|
+
return new PostgresMigrationRunner(family);
|
|
36
|
+
}
|
|
37
|
+
var PostgresMigrationRunner = class {
|
|
38
|
+
family;
|
|
39
|
+
constructor(family) {
|
|
40
|
+
this.family = family;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Body of the migration runner without transaction management. The
|
|
44
|
+
* caller ({@link PostgresMigrationRunner.execute}) owns the
|
|
45
|
+
* `BEGIN`/`COMMIT`/`ROLLBACK` lifecycle.
|
|
46
|
+
*/
|
|
47
|
+
async executeOnConnection(options) {
|
|
48
|
+
const schema = options.schemaName ?? Object.keys(options.destinationContract.storage.namespaces).find((id) => id !== UNBOUND_NAMESPACE_ID) ?? UNBOUND_NAMESPACE_ID;
|
|
49
|
+
const driver = options.driver;
|
|
50
|
+
if (options.space !== void 0 && options.space !== options.plan.spaceId) throw postgresError("MIGRATION.CONTRACT_SPACE_VIOLATION", `SqlMigrationRunner: options.space (${options.space}) does not match plan.spaceId (${options.plan.spaceId})`, { meta: {
|
|
51
|
+
space: options.space,
|
|
52
|
+
planSpaceId: options.plan.spaceId
|
|
53
|
+
} });
|
|
54
|
+
const space = options.plan.spaceId;
|
|
55
|
+
const lockKey = `${LOCK_DOMAIN}:${schema}:${space}`;
|
|
56
|
+
const planOps = blindCast(await Promise.all(options.plan.operations));
|
|
57
|
+
const destinationCheck = this.ensurePlanMatchesDestinationContract(options.plan.destination, options.destinationContract);
|
|
58
|
+
if (!destinationCheck.ok) return destinationCheck;
|
|
59
|
+
const policyCheck = this.enforcePolicyCompatibility(options.policy, planOps);
|
|
60
|
+
if (!policyCheck.ok) return policyCheck;
|
|
61
|
+
await this.acquireLock(driver, lockKey);
|
|
62
|
+
const ensureResult = await this.ensureControlTables(driver, options.destinationContract);
|
|
63
|
+
if (!ensureResult.ok) return ensureResult;
|
|
64
|
+
const existingMarker = await this.family.readMarker({
|
|
65
|
+
driver,
|
|
66
|
+
space
|
|
67
|
+
});
|
|
68
|
+
const markerCheck = this.ensureMarkerCompatibility(existingMarker, options.plan);
|
|
69
|
+
if (!markerCheck.ok) return markerCheck;
|
|
70
|
+
const markerAtDestination = this.markerMatchesDestination(existingMarker, options.plan);
|
|
71
|
+
const isSelfEdge = options.plan.origin?.storageHash === options.plan.destination.storageHash;
|
|
72
|
+
const skipOperations = markerAtDestination && options.plan.origin != null && !isSelfEdge;
|
|
73
|
+
let applyValue;
|
|
74
|
+
if (skipOperations) applyValue = {
|
|
75
|
+
operationsExecuted: 0,
|
|
76
|
+
executedOperations: []
|
|
77
|
+
};
|
|
78
|
+
else {
|
|
79
|
+
const applyResult = await this.applyPlan(driver, options, planOps);
|
|
80
|
+
if (!applyResult.ok) return applyResult;
|
|
81
|
+
applyValue = applyResult.value;
|
|
82
|
+
}
|
|
83
|
+
if (space === APP_SPACE_ID) {
|
|
84
|
+
const schemaNode = await this.family.introspect({
|
|
85
|
+
driver,
|
|
86
|
+
contract: options.destinationContract
|
|
87
|
+
});
|
|
88
|
+
const schemaVerifyResult = this.family.verifySchema({
|
|
89
|
+
contract: options.destinationContract,
|
|
90
|
+
schema: schemaNode,
|
|
91
|
+
strict: options.strictVerification ?? true,
|
|
92
|
+
frameworkComponents: options.frameworkComponents
|
|
93
|
+
});
|
|
94
|
+
if (!schemaVerifyResult.ok) return runnerFailure("MIGRATION.SCHEMA_VERIFY_FAILED", schemaVerifyResult.summary, {
|
|
95
|
+
why: "The resulting database schema does not satisfy the destination contract.",
|
|
96
|
+
meta: { issues: schemaVerifyResult.schema.issues }
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
const incomingInvariants = options.plan.providedInvariants ?? [];
|
|
100
|
+
const existingInvariants = new Set(existingMarker?.invariants ?? []);
|
|
101
|
+
const incomingIsSubsetOfExisting = incomingInvariants.every((id) => existingInvariants.has(id));
|
|
102
|
+
if (!(isSelfEdge && applyValue.operationsExecuted === 0 && incomingIsSubsetOfExisting)) {
|
|
103
|
+
const markerResult = await this.upsertMarker(driver, options, existingMarker, space);
|
|
104
|
+
if (!markerResult.ok) return markerResult;
|
|
105
|
+
await this.recordLedgerEntries(driver, options, applyValue.executedOperations, planOps.length);
|
|
106
|
+
}
|
|
107
|
+
return runnerSuccess({
|
|
108
|
+
operationsPlanned: planOps.length,
|
|
109
|
+
operationsExecuted: applyValue.operationsExecuted
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
async execute(options) {
|
|
113
|
+
const driver = options.driver;
|
|
114
|
+
const perSpaceOptions = options.perSpaceOptions;
|
|
115
|
+
if (perSpaceOptions.length === 0) return ok({ perSpaceResults: [] });
|
|
116
|
+
await this.beginTransaction(driver);
|
|
117
|
+
let committed = false;
|
|
118
|
+
try {
|
|
119
|
+
const perSpaceResults = [];
|
|
120
|
+
for (const spaceOptions of perSpaceOptions) {
|
|
121
|
+
const space = spaceOptions.space ?? spaceOptions.plan.spaceId;
|
|
122
|
+
const result = await this.executeOnConnection({
|
|
123
|
+
...spaceOptions,
|
|
124
|
+
driver,
|
|
125
|
+
space
|
|
126
|
+
});
|
|
127
|
+
if (!result.ok) return notOk({
|
|
128
|
+
...result.failure,
|
|
129
|
+
failingSpace: space
|
|
130
|
+
});
|
|
131
|
+
perSpaceResults.push({
|
|
132
|
+
space,
|
|
133
|
+
value: result.value
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
await this.commitTransaction(driver);
|
|
137
|
+
committed = true;
|
|
138
|
+
return ok({ perSpaceResults });
|
|
139
|
+
} finally {
|
|
140
|
+
if (!committed) await this.rollbackTransaction(driver);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
async applyPlan(driver, options, ops) {
|
|
144
|
+
const checks = options.executionChecks;
|
|
145
|
+
const runPrechecks = checks?.prechecks !== false;
|
|
146
|
+
const runPostchecks = checks?.postchecks !== false;
|
|
147
|
+
const runIdempotency = checks?.idempotencyChecks !== false;
|
|
148
|
+
let operationsExecuted = 0;
|
|
149
|
+
const executedOperations = [];
|
|
150
|
+
for (const operation of ops) {
|
|
151
|
+
options.callbacks?.onOperationStart?.(operation);
|
|
152
|
+
try {
|
|
153
|
+
if (runPostchecks && runIdempotency) {
|
|
154
|
+
if (await this.expectationsAreSatisfied(driver, operation.postcheck)) {
|
|
155
|
+
executedOperations.push(this.createPostcheckPreSatisfiedSkipRecord(operation));
|
|
156
|
+
continue;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (runPrechecks) {
|
|
160
|
+
const precheckResult = await this.runExpectationSteps(driver, operation.precheck, operation, "precheck");
|
|
161
|
+
if (!precheckResult.ok) return precheckResult;
|
|
162
|
+
}
|
|
163
|
+
const executeResult = await this.runExecuteSteps(driver, operation.execute, operation);
|
|
164
|
+
if (!executeResult.ok) return executeResult;
|
|
165
|
+
if (runPostchecks) {
|
|
166
|
+
const postcheckResult = await this.runExpectationSteps(driver, operation.postcheck, operation, "postcheck");
|
|
167
|
+
if (!postcheckResult.ok) return postcheckResult;
|
|
168
|
+
}
|
|
169
|
+
executedOperations.push(operation);
|
|
170
|
+
operationsExecuted += 1;
|
|
171
|
+
} finally {
|
|
172
|
+
options.callbacks?.onOperationComplete?.(operation);
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
return ok({
|
|
176
|
+
operationsExecuted,
|
|
177
|
+
executedOperations
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
async ensureControlTables(driver, contract) {
|
|
181
|
+
const lowererContext = { contract };
|
|
182
|
+
const [schemaQuery, ...tableQueries] = this.family.bootstrapControlTableQueries();
|
|
183
|
+
if (schemaQuery === void 0) throw new InternalError("Postgres control-table bootstrap must include CREATE SCHEMA");
|
|
184
|
+
await this.executeStatement(driver, await this.family.lowerAst(schemaQuery, lowererContext));
|
|
185
|
+
const legacyDetection = await this.detectLegacyMarkerShape(driver);
|
|
186
|
+
if (!legacyDetection.ok) return legacyDetection;
|
|
187
|
+
for (const query of tableQueries) await this.executeStatement(driver, await this.family.lowerAst(query, lowererContext));
|
|
188
|
+
return okVoid();
|
|
189
|
+
}
|
|
190
|
+
async detectLegacyMarkerShape(driver) {
|
|
191
|
+
const result = await driver.query(`select column_name
|
|
192
|
+
from information_schema.columns
|
|
193
|
+
where table_schema = 'prisma_contract'
|
|
194
|
+
and table_name = 'marker'`);
|
|
195
|
+
if (result.rows.length === 0) return okVoid();
|
|
196
|
+
const columns = new Set(result.rows.map((row) => row.column_name));
|
|
197
|
+
if (columns.has("space")) return okVoid();
|
|
198
|
+
return runnerFailure("MIGRATION.LEGACY_MARKER_SHAPE", "Legacy marker-table shape detected on prisma_contract.marker (no `space` column). Prisma 8 is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. Drop `prisma_contract.marker` and re-run `dbInit` to reinitialise from a clean baseline.", { meta: {
|
|
199
|
+
table: "prisma_contract.marker",
|
|
200
|
+
columns: [...columns].sort()
|
|
201
|
+
} });
|
|
202
|
+
}
|
|
203
|
+
async runExpectationSteps(driver, steps, operation, phase) {
|
|
204
|
+
for (const step of steps) {
|
|
205
|
+
const result = await driver.query(step.sql, step.params ?? []);
|
|
206
|
+
if (!this.stepResultIsTrue(result.rows)) return runnerFailure(phase === "precheck" ? "MIGRATION.PRECHECK_FAILED" : "MIGRATION.POSTCHECK_FAILED", `Operation ${operation.id} failed during ${phase}: ${step.description}`, { meta: {
|
|
207
|
+
operationId: operation.id,
|
|
208
|
+
phase,
|
|
209
|
+
stepDescription: step.description
|
|
210
|
+
} });
|
|
211
|
+
}
|
|
212
|
+
return okVoid();
|
|
213
|
+
}
|
|
214
|
+
async runExecuteSteps(driver, steps, operation) {
|
|
215
|
+
for (const step of steps) try {
|
|
216
|
+
await driver.query(step.sql, step.params ?? []);
|
|
217
|
+
} catch (error) {
|
|
218
|
+
if (SqlQueryError.is(error)) return runnerFailure("MIGRATION.EXECUTION_FAILED", `Operation ${operation.id} failed during execution: ${step.description}`, {
|
|
219
|
+
why: error.message,
|
|
220
|
+
meta: {
|
|
221
|
+
operationId: operation.id,
|
|
222
|
+
stepDescription: step.description,
|
|
223
|
+
sql: step.sql,
|
|
224
|
+
sqlState: error.sqlState,
|
|
225
|
+
constraint: error.constraint,
|
|
226
|
+
table: error.table,
|
|
227
|
+
column: error.column,
|
|
228
|
+
detail: error.detail
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
throw error;
|
|
232
|
+
}
|
|
233
|
+
return okVoid();
|
|
234
|
+
}
|
|
235
|
+
stepResultIsTrue(rows) {
|
|
236
|
+
if (!rows || rows.length === 0) return false;
|
|
237
|
+
const firstRow = rows[0];
|
|
238
|
+
const firstValue = firstRow ? Object.values(firstRow)[0] : void 0;
|
|
239
|
+
if (typeof firstValue === "boolean") return firstValue;
|
|
240
|
+
if (typeof firstValue === "number") return firstValue !== 0;
|
|
241
|
+
if (typeof firstValue === "string") {
|
|
242
|
+
const lower = firstValue.toLowerCase();
|
|
243
|
+
if (lower === "t" || lower === "true" || lower === "1") return true;
|
|
244
|
+
if (lower === "f" || lower === "false" || lower === "0") return false;
|
|
245
|
+
return firstValue.length > 0;
|
|
246
|
+
}
|
|
247
|
+
return Boolean(firstValue);
|
|
248
|
+
}
|
|
249
|
+
async expectationsAreSatisfied(driver, steps) {
|
|
250
|
+
if (steps.length === 0) return false;
|
|
251
|
+
for (const step of steps) {
|
|
252
|
+
const result = await driver.query(step.sql, step.params ?? []);
|
|
253
|
+
if (!this.stepResultIsTrue(result.rows)) return false;
|
|
254
|
+
}
|
|
255
|
+
return true;
|
|
256
|
+
}
|
|
257
|
+
createPostcheckPreSatisfiedSkipRecord(operation) {
|
|
258
|
+
const clonedMeta = operation.meta ? cloneAndFreezeRecord(operation.meta) : void 0;
|
|
259
|
+
const runnerMeta = Object.freeze({
|
|
260
|
+
skipped: true,
|
|
261
|
+
reason: "postcheck_pre_satisfied"
|
|
262
|
+
});
|
|
263
|
+
const mergedMeta = Object.freeze({
|
|
264
|
+
...clonedMeta ?? {},
|
|
265
|
+
runner: runnerMeta
|
|
266
|
+
});
|
|
267
|
+
const frozenPostcheck = Object.freeze([...operation.postcheck]);
|
|
268
|
+
return Object.freeze({
|
|
269
|
+
id: operation.id,
|
|
270
|
+
label: operation.label,
|
|
271
|
+
...ifDefined("summary", operation.summary),
|
|
272
|
+
operationClass: operation.operationClass,
|
|
273
|
+
target: operation.target,
|
|
274
|
+
precheck: Object.freeze([]),
|
|
275
|
+
execute: Object.freeze([]),
|
|
276
|
+
postcheck: frozenPostcheck,
|
|
277
|
+
...ifDefined("meta", operation.meta || mergedMeta ? mergedMeta : void 0)
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
markerMatchesDestination(marker, plan) {
|
|
281
|
+
if (!marker) return false;
|
|
282
|
+
if (marker.storageHash !== plan.destination.storageHash) return false;
|
|
283
|
+
if (plan.destination.profileHash && marker.profileHash !== plan.destination.profileHash) return false;
|
|
284
|
+
return true;
|
|
285
|
+
}
|
|
286
|
+
enforcePolicyCompatibility(policy, operations) {
|
|
287
|
+
const allowedClasses = new Set(policy.allowedOperationClasses);
|
|
288
|
+
for (const operation of operations) if (!allowedClasses.has(operation.operationClass)) return runnerFailure("MIGRATION.POLICY_VIOLATION", `Operation ${operation.id} has class "${operation.operationClass}" which is not allowed by policy.`, {
|
|
289
|
+
why: `Policy only allows: ${policy.allowedOperationClasses.join(", ")}.`,
|
|
290
|
+
meta: {
|
|
291
|
+
operationId: operation.id,
|
|
292
|
+
operationClass: operation.operationClass,
|
|
293
|
+
allowedClasses: policy.allowedOperationClasses
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
return okVoid();
|
|
297
|
+
}
|
|
298
|
+
ensureMarkerCompatibility(marker, plan) {
|
|
299
|
+
const origin = plan.origin ?? null;
|
|
300
|
+
if (!origin) return okVoid();
|
|
301
|
+
if (!marker) return runnerFailure("MIGRATION.MARKER_ORIGIN_MISMATCH", `Missing contract marker: expected origin storage hash ${origin.storageHash}.`, { meta: { expectedOriginStorageHash: origin.storageHash } });
|
|
302
|
+
if (marker.storageHash !== origin.storageHash) return runnerFailure("MIGRATION.MARKER_ORIGIN_MISMATCH", `Existing contract marker (${marker.storageHash}) does not match plan origin (${origin.storageHash}).`, { meta: {
|
|
303
|
+
markerStorageHash: marker.storageHash,
|
|
304
|
+
expectedOriginStorageHash: origin.storageHash
|
|
305
|
+
} });
|
|
306
|
+
if (origin.profileHash && marker.profileHash !== origin.profileHash) return runnerFailure("MIGRATION.MARKER_ORIGIN_MISMATCH", `Existing contract marker profile hash (${marker.profileHash}) does not match plan origin profile hash (${origin.profileHash}).`, { meta: {
|
|
307
|
+
markerProfileHash: marker.profileHash,
|
|
308
|
+
expectedOriginProfileHash: origin.profileHash
|
|
309
|
+
} });
|
|
310
|
+
return okVoid();
|
|
311
|
+
}
|
|
312
|
+
ensurePlanMatchesDestinationContract(destination, contract) {
|
|
313
|
+
if (destination.storageHash !== contract.storage.storageHash) return runnerFailure("MIGRATION.DESTINATION_CONTRACT_MISMATCH", `Plan destination storage hash (${destination.storageHash}) does not match provided contract storage hash (${contract.storage.storageHash}).`, { meta: {
|
|
314
|
+
planStorageHash: destination.storageHash,
|
|
315
|
+
contractStorageHash: contract.storage.storageHash
|
|
316
|
+
} });
|
|
317
|
+
if (destination.profileHash && contract.profileHash && destination.profileHash !== contract.profileHash) return runnerFailure("MIGRATION.DESTINATION_CONTRACT_MISMATCH", `Plan destination profile hash (${destination.profileHash}) does not match provided contract profile hash (${contract.profileHash}).`, { meta: {
|
|
318
|
+
planProfileHash: destination.profileHash,
|
|
319
|
+
contractProfileHash: contract.profileHash
|
|
320
|
+
} });
|
|
321
|
+
return okVoid();
|
|
322
|
+
}
|
|
323
|
+
async upsertMarker(driver, options, existingMarker, space) {
|
|
324
|
+
const destination = {
|
|
325
|
+
storageHash: options.plan.destination.storageHash,
|
|
326
|
+
profileHash: options.plan.destination.profileHash ?? options.destinationContract.profileHash ?? options.plan.destination.storageHash,
|
|
327
|
+
invariants: options.plan.providedInvariants ?? []
|
|
328
|
+
};
|
|
329
|
+
if (!existingMarker) {
|
|
330
|
+
await this.family.initMarker({
|
|
331
|
+
driver,
|
|
332
|
+
space,
|
|
333
|
+
destination
|
|
334
|
+
});
|
|
335
|
+
return okVoid();
|
|
336
|
+
}
|
|
337
|
+
if (!await this.family.updateMarker({
|
|
338
|
+
driver,
|
|
339
|
+
space,
|
|
340
|
+
expectedFrom: existingMarker.storageHash,
|
|
341
|
+
destination
|
|
342
|
+
})) return runnerFailure("MIGRATION.MARKER_CAS_FAILURE", "Marker was modified by another process during migration execution.", { meta: {
|
|
343
|
+
space,
|
|
344
|
+
expectedStorageHash: existingMarker.storageHash,
|
|
345
|
+
destinationStorageHash: options.plan.destination.storageHash
|
|
346
|
+
} });
|
|
347
|
+
return okVoid();
|
|
348
|
+
}
|
|
349
|
+
async recordLedgerEntries(driver, options, executedOperations, planOpsLength) {
|
|
350
|
+
const space = options.plan.spaceId;
|
|
351
|
+
const edges = options.migrationEdges;
|
|
352
|
+
const totalEdgeOps = edges.reduce((sum, edge) => sum + edge.operationCount, 0);
|
|
353
|
+
if (totalEdgeOps !== planOpsLength) throw new InternalError(`Ledger write: plan.operations length (${planOpsLength}) does not match sum of migrationEdges operationCount (${totalEdgeOps})`);
|
|
354
|
+
let offset = 0;
|
|
355
|
+
for (const edge of edges) {
|
|
356
|
+
const edgeOps = executedOperations.slice(offset, offset + edge.operationCount);
|
|
357
|
+
offset += edge.operationCount;
|
|
358
|
+
await this.family.writeLedgerEntry({
|
|
359
|
+
driver,
|
|
360
|
+
space,
|
|
361
|
+
entry: {
|
|
362
|
+
edgeId: `${edge.from}->${edge.to}`,
|
|
363
|
+
from: edge.from,
|
|
364
|
+
to: edge.to,
|
|
365
|
+
migrationName: edge.dirName,
|
|
366
|
+
migrationHash: edge.migrationHash,
|
|
367
|
+
operations: edgeOps,
|
|
368
|
+
...ifDefined("destinationContractJson", edge.destinationContractJson)
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
async acquireLock(driver, key) {
|
|
374
|
+
await driver.query("select pg_advisory_xact_lock(hashtext($1))", [key]);
|
|
375
|
+
}
|
|
376
|
+
async beginTransaction(driver) {
|
|
377
|
+
await driver.query("BEGIN");
|
|
378
|
+
}
|
|
379
|
+
async commitTransaction(driver) {
|
|
380
|
+
await driver.query("COMMIT");
|
|
381
|
+
}
|
|
382
|
+
async rollbackTransaction(driver) {
|
|
383
|
+
await driver.query("ROLLBACK");
|
|
384
|
+
}
|
|
385
|
+
async executeStatement(driver, statement) {
|
|
386
|
+
await driver.query(statement.sql, statement.params);
|
|
387
|
+
}
|
|
388
|
+
};
|
|
389
|
+
/**
|
|
390
|
+
* Postgres target `SchemaVerifier` concretion. Plugs into the
|
|
391
|
+
* SQL-shared verification surface; production verification today still
|
|
392
|
+
* routes through the family verify verdict (`verifySqlSchemaByDiff` over
|
|
393
|
+
* `diffPostgresSchema`), which carries options (codec hooks,
|
|
394
|
+
* normalizers, framework components) that the framework-level
|
|
395
|
+
* `SchemaVerifyOptions` shape does not yet surface.
|
|
396
|
+
*
|
|
397
|
+
* The hooks return the empty list pending the call-site migration that
|
|
398
|
+
* routes the existing verifier behaviour through the SPI — at that
|
|
399
|
+
* point `verifyCommonSqlSchema` will likely lift onto the family base
|
|
400
|
+
* (mirroring `verifyCommonMongoSchema`) and `verifyTargetExtensions`
|
|
401
|
+
* will house Postgres-only kinds (functions, RLS policies in a future
|
|
402
|
+
* project).
|
|
403
|
+
*/
|
|
404
|
+
var PostgresSchemaVerifier = class extends SqlSchemaVerifierBase {
|
|
405
|
+
verifyCommonSqlSchema(_options) {
|
|
406
|
+
return [];
|
|
407
|
+
}
|
|
408
|
+
verifyTargetExtensions(_options) {
|
|
409
|
+
return [];
|
|
410
|
+
}
|
|
411
|
+
};
|
|
412
|
+
function postgresRenderDefault(def, column) {
|
|
413
|
+
if (def.kind === "function") return def.expression;
|
|
414
|
+
return renderDefaultLiteral(def.value, column);
|
|
415
|
+
}
|
|
416
|
+
const postgresTargetDescriptor = {
|
|
417
|
+
...postgresTargetDescriptorMeta,
|
|
418
|
+
contractSerializer: new PostgresContractSerializer(),
|
|
419
|
+
schemaVerifier: new PostgresSchemaVerifier(),
|
|
420
|
+
inferPslContract(schema, describedContracts) {
|
|
421
|
+
PostgresDatabaseSchemaNode.assert(schema);
|
|
422
|
+
return inferPostgresPslContract(schema, describedContracts);
|
|
423
|
+
},
|
|
424
|
+
diffSchema(input) {
|
|
425
|
+
return diffPostgresSchema(input);
|
|
426
|
+
},
|
|
427
|
+
classifySubjectGranularity: postgresDiffSubjectGranularity,
|
|
428
|
+
classifyEntityKind: postgresDiffSubjectEntityKind,
|
|
429
|
+
migrations: {
|
|
430
|
+
createPlanner(adapter) {
|
|
431
|
+
return createPostgresMigrationPlanner(adapter);
|
|
432
|
+
},
|
|
433
|
+
createRunner(family) {
|
|
434
|
+
return createPostgresMigrationRunner(family);
|
|
435
|
+
},
|
|
436
|
+
contractToSchema(contract, frameworkComponents) {
|
|
437
|
+
const expander = buildNativeTypeExpander(frameworkComponents);
|
|
438
|
+
return contractToPostgresDatabaseSchemaNode(blindCast(contract), {
|
|
439
|
+
annotationNamespace: "pg",
|
|
440
|
+
...ifDefined("expandNativeType", expander),
|
|
441
|
+
renderDefault: postgresRenderDefault,
|
|
442
|
+
resolveDefault: postgresResolveDefault
|
|
443
|
+
});
|
|
444
|
+
}
|
|
445
|
+
},
|
|
446
|
+
create() {
|
|
447
|
+
return {
|
|
448
|
+
familyId: "sql",
|
|
449
|
+
targetId: "postgres"
|
|
450
|
+
};
|
|
451
|
+
},
|
|
452
|
+
/**
|
|
453
|
+
* Direct method for SQL-specific usage.
|
|
454
|
+
* @deprecated Use migrations.createPlanner() for CLI compatibility.
|
|
455
|
+
*/
|
|
456
|
+
createPlanner(adapter) {
|
|
457
|
+
return createPostgresMigrationPlanner(adapter);
|
|
458
|
+
},
|
|
459
|
+
/**
|
|
460
|
+
* Direct method for SQL-specific usage.
|
|
461
|
+
* @deprecated Use migrations.createRunner() for CLI compatibility.
|
|
462
|
+
*/
|
|
463
|
+
createRunner(family) {
|
|
464
|
+
return createPostgresMigrationRunner(family);
|
|
465
|
+
}
|
|
466
|
+
};
|
|
467
|
+
//#endregion
|
|
468
|
+
export { postgresTargetDescriptor as n, postgresRenderDefault as t };
|
|
469
|
+
|
|
470
|
+
//# sourceMappingURL=control-206OMpyA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"control-206OMpyA.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/control.mjs"],"sourcesContent":["import { s as postgresError } from \"./errors-DYyzTYzE.mjs\";\nimport { n as postgresResolveDefault } from \"./default-normalizer-Bjtm2F4f.mjs\";\nimport { c as PLAIN_DATE_TIME_NOW_GENERATOR_ID, d as INSTANT_NOW_GENERATOR_ID, p as instantNowControlDescriptor, u as plainDateTimeNowControlDescriptor } from \"./authoring-Beq66XGy.mjs\";\nimport { t as postgresTargetDescriptorMeta } from \"./descriptor-meta-BhJOswpM.mjs\";\nimport { a as postgresDiffSubjectGranularity, i as postgresDiffSubjectEntityKind } from \"./postgres-table-schema-node-BBkitBQh.mjs\";\nimport { i as PostgresDatabaseSchemaNode } from \"./postgres-role-schema-node-B8Z5i5D-.mjs\";\nimport { n as diffPostgresSchema, r as contractToPostgresDatabaseSchemaNode } from \"./diff-database-schema-BFX0ZWWK.mjs\";\nimport { r as renderDefaultLiteral } from \"./planner-ddl-builders-CpXQ-J0X.mjs\";\nimport { n as PostgresContractSerializer } from \"./postgres-contract-view-D7tYWHwD.mjs\";\nimport { t as createPostgresMigrationPlanner } from \"./planner-D_VBDqX0.mjs\";\nimport { n as inferPostgresPslContract } from \"./infer-psl-contract-BaZaJAD9.mjs\";\nimport { n as parsePostgresListText, t as decodePostgresListText } from \"./list-decoder-DXee1orj.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { buildNativeTypeExpander, runnerFailure, runnerSuccess } from \"@internal/family-sql/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { APP_SPACE_ID } from \"@internal/framework-components/control\";\nimport { notOk, ok, okVoid } from \"@internal/utils/result\";\nimport { InternalError } from \"@internal/utils/internal-error\";\nimport { SqlSchemaVerifierBase } from \"@internal/family-sql/ir\";\nimport { SqlQueryError } from \"@internal/sql-errors\";\n//#region src/core/migrations/runner.ts\nconst LOCK_DOMAIN = \"prisma_8.contract.marker\";\n/**\n* Deep clones and freezes a record object to prevent mutation.\n* Recursively clones nested objects and arrays to ensure complete isolation.\n*/\nfunction cloneAndFreezeRecord(value) {\n\tconst cloned = {};\n\tfor (const [key, val] of Object.entries(value)) if (val === null || val === void 0) cloned[key] = val;\n\telse if (Array.isArray(val)) cloned[key] = Object.freeze([...val]);\n\telse if (typeof val === \"object\") cloned[key] = cloneAndFreezeRecord(val);\n\telse cloned[key] = val;\n\treturn Object.freeze(cloned);\n}\nfunction createPostgresMigrationRunner(family) {\n\treturn new PostgresMigrationRunner(family);\n}\nvar PostgresMigrationRunner = class {\n\tfamily;\n\tconstructor(family) {\n\t\tthis.family = family;\n\t}\n\t/**\n\t* Body of the migration runner without transaction management. The\n\t* caller ({@link PostgresMigrationRunner.execute}) owns the\n\t* `BEGIN`/`COMMIT`/`ROLLBACK` lifecycle.\n\t*/\n\tasync executeOnConnection(options) {\n\t\tconst schema = options.schemaName ?? Object.keys(options.destinationContract.storage.namespaces).find((id) => id !== UNBOUND_NAMESPACE_ID) ?? UNBOUND_NAMESPACE_ID;\n\t\tconst driver = options.driver;\n\t\tif (options.space !== void 0 && options.space !== options.plan.spaceId) throw postgresError(\"MIGRATION.CONTRACT_SPACE_VIOLATION\", `SqlMigrationRunner: options.space (${options.space}) does not match plan.spaceId (${options.plan.spaceId})`, { meta: {\n\t\t\tspace: options.space,\n\t\t\tplanSpaceId: options.plan.spaceId\n\t\t} });\n\t\tconst space = options.plan.spaceId;\n\t\tconst lockKey = `${LOCK_DOMAIN}:${schema}:${space}`;\n\t\tconst planOps = blindCast(await Promise.all(options.plan.operations));\n\t\tconst destinationCheck = this.ensurePlanMatchesDestinationContract(options.plan.destination, options.destinationContract);\n\t\tif (!destinationCheck.ok) return destinationCheck;\n\t\tconst policyCheck = this.enforcePolicyCompatibility(options.policy, planOps);\n\t\tif (!policyCheck.ok) return policyCheck;\n\t\tawait this.acquireLock(driver, lockKey);\n\t\tconst ensureResult = await this.ensureControlTables(driver, options.destinationContract);\n\t\tif (!ensureResult.ok) return ensureResult;\n\t\tconst existingMarker = await this.family.readMarker({\n\t\t\tdriver,\n\t\t\tspace\n\t\t});\n\t\tconst markerCheck = this.ensureMarkerCompatibility(existingMarker, options.plan);\n\t\tif (!markerCheck.ok) return markerCheck;\n\t\tconst markerAtDestination = this.markerMatchesDestination(existingMarker, options.plan);\n\t\tconst isSelfEdge = options.plan.origin?.storageHash === options.plan.destination.storageHash;\n\t\tconst skipOperations = markerAtDestination && options.plan.origin != null && !isSelfEdge;\n\t\tlet applyValue;\n\t\tif (skipOperations) applyValue = {\n\t\t\toperationsExecuted: 0,\n\t\t\texecutedOperations: []\n\t\t};\n\t\telse {\n\t\t\tconst applyResult = await this.applyPlan(driver, options, planOps);\n\t\t\tif (!applyResult.ok) return applyResult;\n\t\t\tapplyValue = applyResult.value;\n\t\t}\n\t\tif (space === APP_SPACE_ID) {\n\t\t\tconst schemaNode = await this.family.introspect({\n\t\t\t\tdriver,\n\t\t\t\tcontract: options.destinationContract\n\t\t\t});\n\t\t\tconst schemaVerifyResult = this.family.verifySchema({\n\t\t\t\tcontract: options.destinationContract,\n\t\t\t\tschema: schemaNode,\n\t\t\t\tstrict: options.strictVerification ?? true,\n\t\t\t\tframeworkComponents: options.frameworkComponents\n\t\t\t});\n\t\t\tif (!schemaVerifyResult.ok) return runnerFailure(\"MIGRATION.SCHEMA_VERIFY_FAILED\", schemaVerifyResult.summary, {\n\t\t\t\twhy: \"The resulting database schema does not satisfy the destination contract.\",\n\t\t\t\tmeta: { issues: schemaVerifyResult.schema.issues }\n\t\t\t});\n\t\t}\n\t\tconst incomingInvariants = options.plan.providedInvariants ?? [];\n\t\tconst existingInvariants = new Set(existingMarker?.invariants ?? []);\n\t\tconst incomingIsSubsetOfExisting = incomingInvariants.every((id) => existingInvariants.has(id));\n\t\tif (!(isSelfEdge && applyValue.operationsExecuted === 0 && incomingIsSubsetOfExisting)) {\n\t\t\tconst markerResult = await this.upsertMarker(driver, options, existingMarker, space);\n\t\t\tif (!markerResult.ok) return markerResult;\n\t\t\tawait this.recordLedgerEntries(driver, options, applyValue.executedOperations, planOps.length);\n\t\t}\n\t\treturn runnerSuccess({\n\t\t\toperationsPlanned: planOps.length,\n\t\t\toperationsExecuted: applyValue.operationsExecuted\n\t\t});\n\t}\n\tasync execute(options) {\n\t\tconst driver = options.driver;\n\t\tconst perSpaceOptions = options.perSpaceOptions;\n\t\tif (perSpaceOptions.length === 0) return ok({ perSpaceResults: [] });\n\t\tawait this.beginTransaction(driver);\n\t\tlet committed = false;\n\t\ttry {\n\t\t\tconst perSpaceResults = [];\n\t\t\tfor (const spaceOptions of perSpaceOptions) {\n\t\t\t\tconst space = spaceOptions.space ?? spaceOptions.plan.spaceId;\n\t\t\t\tconst result = await this.executeOnConnection({\n\t\t\t\t\t...spaceOptions,\n\t\t\t\t\tdriver,\n\t\t\t\t\tspace\n\t\t\t\t});\n\t\t\t\tif (!result.ok) return notOk({\n\t\t\t\t\t...result.failure,\n\t\t\t\t\tfailingSpace: space\n\t\t\t\t});\n\t\t\t\tperSpaceResults.push({\n\t\t\t\t\tspace,\n\t\t\t\t\tvalue: result.value\n\t\t\t\t});\n\t\t\t}\n\t\t\tawait this.commitTransaction(driver);\n\t\t\tcommitted = true;\n\t\t\treturn ok({ perSpaceResults });\n\t\t} finally {\n\t\t\tif (!committed) await this.rollbackTransaction(driver);\n\t\t}\n\t}\n\tasync applyPlan(driver, options, ops) {\n\t\tconst checks = options.executionChecks;\n\t\tconst runPrechecks = checks?.prechecks !== false;\n\t\tconst runPostchecks = checks?.postchecks !== false;\n\t\tconst runIdempotency = checks?.idempotencyChecks !== false;\n\t\tlet operationsExecuted = 0;\n\t\tconst executedOperations = [];\n\t\tfor (const operation of ops) {\n\t\t\toptions.callbacks?.onOperationStart?.(operation);\n\t\t\ttry {\n\t\t\t\tif (runPostchecks && runIdempotency) {\n\t\t\t\t\tif (await this.expectationsAreSatisfied(driver, operation.postcheck)) {\n\t\t\t\t\t\texecutedOperations.push(this.createPostcheckPreSatisfiedSkipRecord(operation));\n\t\t\t\t\t\tcontinue;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (runPrechecks) {\n\t\t\t\t\tconst precheckResult = await this.runExpectationSteps(driver, operation.precheck, operation, \"precheck\");\n\t\t\t\t\tif (!precheckResult.ok) return precheckResult;\n\t\t\t\t}\n\t\t\t\tconst executeResult = await this.runExecuteSteps(driver, operation.execute, operation);\n\t\t\t\tif (!executeResult.ok) return executeResult;\n\t\t\t\tif (runPostchecks) {\n\t\t\t\t\tconst postcheckResult = await this.runExpectationSteps(driver, operation.postcheck, operation, \"postcheck\");\n\t\t\t\t\tif (!postcheckResult.ok) return postcheckResult;\n\t\t\t\t}\n\t\t\t\texecutedOperations.push(operation);\n\t\t\t\toperationsExecuted += 1;\n\t\t\t} finally {\n\t\t\t\toptions.callbacks?.onOperationComplete?.(operation);\n\t\t\t}\n\t\t}\n\t\treturn ok({\n\t\t\toperationsExecuted,\n\t\t\texecutedOperations\n\t\t});\n\t}\n\tasync ensureControlTables(driver, contract) {\n\t\tconst lowererContext = { contract };\n\t\tconst [schemaQuery, ...tableQueries] = this.family.bootstrapControlTableQueries();\n\t\tif (schemaQuery === void 0) throw new InternalError(\"Postgres control-table bootstrap must include CREATE SCHEMA\");\n\t\tawait this.executeStatement(driver, await this.family.lowerAst(schemaQuery, lowererContext));\n\t\tconst legacyDetection = await this.detectLegacyMarkerShape(driver);\n\t\tif (!legacyDetection.ok) return legacyDetection;\n\t\tfor (const query of tableQueries) await this.executeStatement(driver, await this.family.lowerAst(query, lowererContext));\n\t\treturn okVoid();\n\t}\n\tasync detectLegacyMarkerShape(driver) {\n\t\tconst result = await driver.query(`select column_name\n from information_schema.columns\n where table_schema = 'prisma_contract'\n and table_name = 'marker'`);\n\t\tif (result.rows.length === 0) return okVoid();\n\t\tconst columns = new Set(result.rows.map((row) => row.column_name));\n\t\tif (columns.has(\"space\")) return okVoid();\n\t\treturn runnerFailure(\"MIGRATION.LEGACY_MARKER_SHAPE\", \"Legacy marker-table shape detected on prisma_contract.marker (no `space` column). Prisma 8 is in pre-1.0; the previous transitional auto-migration to the per-space-row schema has been removed. Drop `prisma_contract.marker` and re-run `dbInit` to reinitialise from a clean baseline.\", { meta: {\n\t\t\ttable: \"prisma_contract.marker\",\n\t\t\tcolumns: [...columns].sort()\n\t\t} });\n\t}\n\tasync runExpectationSteps(driver, steps, operation, phase) {\n\t\tfor (const step of steps) {\n\t\t\tconst result = await driver.query(step.sql, step.params ?? []);\n\t\t\tif (!this.stepResultIsTrue(result.rows)) return runnerFailure(phase === \"precheck\" ? \"MIGRATION.PRECHECK_FAILED\" : \"MIGRATION.POSTCHECK_FAILED\", `Operation ${operation.id} failed during ${phase}: ${step.description}`, { meta: {\n\t\t\t\toperationId: operation.id,\n\t\t\t\tphase,\n\t\t\t\tstepDescription: step.description\n\t\t\t} });\n\t\t}\n\t\treturn okVoid();\n\t}\n\tasync runExecuteSteps(driver, steps, operation) {\n\t\tfor (const step of steps) try {\n\t\t\tawait driver.query(step.sql, step.params ?? []);\n\t\t} catch (error) {\n\t\t\tif (SqlQueryError.is(error)) return runnerFailure(\"MIGRATION.EXECUTION_FAILED\", `Operation ${operation.id} failed during execution: ${step.description}`, {\n\t\t\t\twhy: error.message,\n\t\t\t\tmeta: {\n\t\t\t\t\toperationId: operation.id,\n\t\t\t\t\tstepDescription: step.description,\n\t\t\t\t\tsql: step.sql,\n\t\t\t\t\tsqlState: error.sqlState,\n\t\t\t\t\tconstraint: error.constraint,\n\t\t\t\t\ttable: error.table,\n\t\t\t\t\tcolumn: error.column,\n\t\t\t\t\tdetail: error.detail\n\t\t\t\t}\n\t\t\t});\n\t\t\tthrow error;\n\t\t}\n\t\treturn okVoid();\n\t}\n\tstepResultIsTrue(rows) {\n\t\tif (!rows || rows.length === 0) return false;\n\t\tconst firstRow = rows[0];\n\t\tconst firstValue = firstRow ? Object.values(firstRow)[0] : void 0;\n\t\tif (typeof firstValue === \"boolean\") return firstValue;\n\t\tif (typeof firstValue === \"number\") return firstValue !== 0;\n\t\tif (typeof firstValue === \"string\") {\n\t\t\tconst lower = firstValue.toLowerCase();\n\t\t\tif (lower === \"t\" || lower === \"true\" || lower === \"1\") return true;\n\t\t\tif (lower === \"f\" || lower === \"false\" || lower === \"0\") return false;\n\t\t\treturn firstValue.length > 0;\n\t\t}\n\t\treturn Boolean(firstValue);\n\t}\n\tasync expectationsAreSatisfied(driver, steps) {\n\t\tif (steps.length === 0) return false;\n\t\tfor (const step of steps) {\n\t\t\tconst result = await driver.query(step.sql, step.params ?? []);\n\t\t\tif (!this.stepResultIsTrue(result.rows)) return false;\n\t\t}\n\t\treturn true;\n\t}\n\tcreatePostcheckPreSatisfiedSkipRecord(operation) {\n\t\tconst clonedMeta = operation.meta ? cloneAndFreezeRecord(operation.meta) : void 0;\n\t\tconst runnerMeta = Object.freeze({\n\t\t\tskipped: true,\n\t\t\treason: \"postcheck_pre_satisfied\"\n\t\t});\n\t\tconst mergedMeta = Object.freeze({\n\t\t\t...clonedMeta ?? {},\n\t\t\trunner: runnerMeta\n\t\t});\n\t\tconst frozenPostcheck = Object.freeze([...operation.postcheck]);\n\t\treturn Object.freeze({\n\t\t\tid: operation.id,\n\t\t\tlabel: operation.label,\n\t\t\t...ifDefined(\"summary\", operation.summary),\n\t\t\toperationClass: operation.operationClass,\n\t\t\ttarget: operation.target,\n\t\t\tprecheck: Object.freeze([]),\n\t\t\texecute: Object.freeze([]),\n\t\t\tpostcheck: frozenPostcheck,\n\t\t\t...ifDefined(\"meta\", operation.meta || mergedMeta ? mergedMeta : void 0)\n\t\t});\n\t}\n\tmarkerMatchesDestination(marker, plan) {\n\t\tif (!marker) return false;\n\t\tif (marker.storageHash !== plan.destination.storageHash) return false;\n\t\tif (plan.destination.profileHash && marker.profileHash !== plan.destination.profileHash) return false;\n\t\treturn true;\n\t}\n\tenforcePolicyCompatibility(policy, operations) {\n\t\tconst allowedClasses = new Set(policy.allowedOperationClasses);\n\t\tfor (const operation of operations) if (!allowedClasses.has(operation.operationClass)) return runnerFailure(\"MIGRATION.POLICY_VIOLATION\", `Operation ${operation.id} has class \"${operation.operationClass}\" which is not allowed by policy.`, {\n\t\t\twhy: `Policy only allows: ${policy.allowedOperationClasses.join(\", \")}.`,\n\t\t\tmeta: {\n\t\t\t\toperationId: operation.id,\n\t\t\t\toperationClass: operation.operationClass,\n\t\t\t\tallowedClasses: policy.allowedOperationClasses\n\t\t\t}\n\t\t});\n\t\treturn okVoid();\n\t}\n\tensureMarkerCompatibility(marker, plan) {\n\t\tconst origin = plan.origin ?? null;\n\t\tif (!origin) return okVoid();\n\t\tif (!marker) return runnerFailure(\"MIGRATION.MARKER_ORIGIN_MISMATCH\", `Missing contract marker: expected origin storage hash ${origin.storageHash}.`, { meta: { expectedOriginStorageHash: origin.storageHash } });\n\t\tif (marker.storageHash !== origin.storageHash) return runnerFailure(\"MIGRATION.MARKER_ORIGIN_MISMATCH\", `Existing contract marker (${marker.storageHash}) does not match plan origin (${origin.storageHash}).`, { meta: {\n\t\t\tmarkerStorageHash: marker.storageHash,\n\t\t\texpectedOriginStorageHash: origin.storageHash\n\t\t} });\n\t\tif (origin.profileHash && marker.profileHash !== origin.profileHash) return runnerFailure(\"MIGRATION.MARKER_ORIGIN_MISMATCH\", `Existing contract marker profile hash (${marker.profileHash}) does not match plan origin profile hash (${origin.profileHash}).`, { meta: {\n\t\t\tmarkerProfileHash: marker.profileHash,\n\t\t\texpectedOriginProfileHash: origin.profileHash\n\t\t} });\n\t\treturn okVoid();\n\t}\n\tensurePlanMatchesDestinationContract(destination, contract) {\n\t\tif (destination.storageHash !== contract.storage.storageHash) return runnerFailure(\"MIGRATION.DESTINATION_CONTRACT_MISMATCH\", `Plan destination storage hash (${destination.storageHash}) does not match provided contract storage hash (${contract.storage.storageHash}).`, { meta: {\n\t\t\tplanStorageHash: destination.storageHash,\n\t\t\tcontractStorageHash: contract.storage.storageHash\n\t\t} });\n\t\tif (destination.profileHash && contract.profileHash && destination.profileHash !== contract.profileHash) return runnerFailure(\"MIGRATION.DESTINATION_CONTRACT_MISMATCH\", `Plan destination profile hash (${destination.profileHash}) does not match provided contract profile hash (${contract.profileHash}).`, { meta: {\n\t\t\tplanProfileHash: destination.profileHash,\n\t\t\tcontractProfileHash: contract.profileHash\n\t\t} });\n\t\treturn okVoid();\n\t}\n\tasync upsertMarker(driver, options, existingMarker, space) {\n\t\tconst destination = {\n\t\t\tstorageHash: options.plan.destination.storageHash,\n\t\t\tprofileHash: options.plan.destination.profileHash ?? options.destinationContract.profileHash ?? options.plan.destination.storageHash,\n\t\t\tinvariants: options.plan.providedInvariants ?? []\n\t\t};\n\t\tif (!existingMarker) {\n\t\t\tawait this.family.initMarker({\n\t\t\t\tdriver,\n\t\t\t\tspace,\n\t\t\t\tdestination\n\t\t\t});\n\t\t\treturn okVoid();\n\t\t}\n\t\tif (!await this.family.updateMarker({\n\t\t\tdriver,\n\t\t\tspace,\n\t\t\texpectedFrom: existingMarker.storageHash,\n\t\t\tdestination\n\t\t})) return runnerFailure(\"MIGRATION.MARKER_CAS_FAILURE\", \"Marker was modified by another process during migration execution.\", { meta: {\n\t\t\tspace,\n\t\t\texpectedStorageHash: existingMarker.storageHash,\n\t\t\tdestinationStorageHash: options.plan.destination.storageHash\n\t\t} });\n\t\treturn okVoid();\n\t}\n\tasync recordLedgerEntries(driver, options, executedOperations, planOpsLength) {\n\t\tconst space = options.plan.spaceId;\n\t\tconst edges = options.migrationEdges;\n\t\tconst totalEdgeOps = edges.reduce((sum, edge) => sum + edge.operationCount, 0);\n\t\tif (totalEdgeOps !== planOpsLength) throw new InternalError(`Ledger write: plan.operations length (${planOpsLength}) does not match sum of migrationEdges operationCount (${totalEdgeOps})`);\n\t\tlet offset = 0;\n\t\tfor (const edge of edges) {\n\t\t\tconst edgeOps = executedOperations.slice(offset, offset + edge.operationCount);\n\t\t\toffset += edge.operationCount;\n\t\t\tawait this.family.writeLedgerEntry({\n\t\t\t\tdriver,\n\t\t\t\tspace,\n\t\t\t\tentry: {\n\t\t\t\t\tedgeId: `${edge.from}->${edge.to}`,\n\t\t\t\t\tfrom: edge.from,\n\t\t\t\t\tto: edge.to,\n\t\t\t\t\tmigrationName: edge.dirName,\n\t\t\t\t\tmigrationHash: edge.migrationHash,\n\t\t\t\t\toperations: edgeOps,\n\t\t\t\t\t...ifDefined(\"destinationContractJson\", edge.destinationContractJson)\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t}\n\tasync acquireLock(driver, key) {\n\t\tawait driver.query(\"select pg_advisory_xact_lock(hashtext($1))\", [key]);\n\t}\n\tasync beginTransaction(driver) {\n\t\tawait driver.query(\"BEGIN\");\n\t}\n\tasync commitTransaction(driver) {\n\t\tawait driver.query(\"COMMIT\");\n\t}\n\tasync rollbackTransaction(driver) {\n\t\tawait driver.query(\"ROLLBACK\");\n\t}\n\tasync executeStatement(driver, statement) {\n\t\tawait driver.query(statement.sql, statement.params);\n\t}\n};\n//#endregion\n//#region src/core/postgres-schema-verifier.ts\n/**\n* Postgres target `SchemaVerifier` concretion. Plugs into the\n* SQL-shared verification surface; production verification today still\n* routes through the family verify verdict (`verifySqlSchemaByDiff` over\n* `diffPostgresSchema`), which carries options (codec hooks,\n* normalizers, framework components) that the framework-level\n* `SchemaVerifyOptions` shape does not yet surface.\n*\n* The hooks return the empty list pending the call-site migration that\n* routes the existing verifier behaviour through the SPI — at that\n* point `verifyCommonSqlSchema` will likely lift onto the family base\n* (mirroring `verifyCommonMongoSchema`) and `verifyTargetExtensions`\n* will house Postgres-only kinds (functions, RLS policies in a future\n* project).\n*/\nvar PostgresSchemaVerifier = class extends SqlSchemaVerifierBase {\n\tverifyCommonSqlSchema(_options) {\n\t\treturn [];\n\t}\n\tverifyTargetExtensions(_options) {\n\t\treturn [];\n\t}\n};\n//#endregion\n//#region src/exports/control.ts\nfunction postgresRenderDefault(def, column) {\n\tif (def.kind === \"function\") return def.expression;\n\treturn renderDefaultLiteral(def.value, column);\n}\nconst postgresTargetDescriptor = {\n\t...postgresTargetDescriptorMeta,\n\tcontractSerializer: new PostgresContractSerializer(),\n\tschemaVerifier: new PostgresSchemaVerifier(),\n\tinferPslContract(schema, describedContracts) {\n\t\tPostgresDatabaseSchemaNode.assert(schema);\n\t\treturn inferPostgresPslContract(schema, describedContracts);\n\t},\n\tdiffSchema(input) {\n\t\treturn diffPostgresSchema(input);\n\t},\n\tclassifySubjectGranularity: postgresDiffSubjectGranularity,\n\tclassifyEntityKind: postgresDiffSubjectEntityKind,\n\tmigrations: {\n\t\tcreatePlanner(adapter) {\n\t\t\treturn createPostgresMigrationPlanner(adapter);\n\t\t},\n\t\tcreateRunner(family) {\n\t\t\treturn createPostgresMigrationRunner(family);\n\t\t},\n\t\tcontractToSchema(contract, frameworkComponents) {\n\t\t\tconst expander = buildNativeTypeExpander(frameworkComponents);\n\t\t\treturn contractToPostgresDatabaseSchemaNode(blindCast(contract), {\n\t\t\t\tannotationNamespace: \"pg\",\n\t\t\t\t...ifDefined(\"expandNativeType\", expander),\n\t\t\t\trenderDefault: postgresRenderDefault,\n\t\t\t\tresolveDefault: postgresResolveDefault\n\t\t\t});\n\t\t}\n\t},\n\tcreate() {\n\t\treturn {\n\t\t\tfamilyId: \"sql\",\n\t\t\ttargetId: \"postgres\"\n\t\t};\n\t},\n\t/**\n\t* Direct method for SQL-specific usage.\n\t* @deprecated Use migrations.createPlanner() for CLI compatibility.\n\t*/\n\tcreatePlanner(adapter) {\n\t\treturn createPostgresMigrationPlanner(adapter);\n\t},\n\t/**\n\t* Direct method for SQL-specific usage.\n\t* @deprecated Use migrations.createRunner() for CLI compatibility.\n\t*/\n\tcreateRunner(family) {\n\t\treturn createPostgresMigrationRunner(family);\n\t}\n};\n//#endregion\nexport { INSTANT_NOW_GENERATOR_ID, PLAIN_DATE_TIME_NOW_GENERATOR_ID, decodePostgresListText, postgresTargetDescriptor as default, instantNowControlDescriptor, parsePostgresListText, plainDateTimeNowControlDescriptor, postgresRenderDefault };\n\n//# sourceMappingURL=control.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,cAAc;;;;;AAKpB,SAAS,qBAAqB,OAAO;CACpC,MAAM,SAAS,CAAC;CAChB,KAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,KAAK,GAAG,IAAI,QAAQ,QAAQ,QAAQ,KAAK,GAAG,OAAO,OAAO;MAC7F,IAAI,MAAM,QAAQ,GAAG,GAAG,OAAO,OAAO,OAAO,OAAO,CAAC,GAAG,GAAG,CAAC;MAC5D,IAAI,OAAO,QAAQ,UAAU,OAAO,OAAO,qBAAqB,GAAG;MACnE,OAAO,OAAO;CACnB,OAAO,OAAO,OAAO,MAAM;AAC5B;AACA,SAAS,8BAA8B,QAAQ;CAC9C,OAAO,IAAI,wBAAwB,MAAM;AAC1C;AACA,IAAI,0BAA0B,MAAM;CACnC;CACA,YAAY,QAAQ;EACnB,KAAK,SAAS;CACf;;;;;;CAMA,MAAM,oBAAoB,SAAS;EAClC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O,8BAA8B,MAAM;CAC5C;AACD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO-_xPQVPF0.mjs";
|
|
2
|
-
import "./
|
|
2
|
+
import "./plain-date-time-now-generator-DJ3icyVr-B-rdIVd3.mjs";
|
|
3
3
|
import { StorageColumn } from "@prisma/orm-family-sql/contract/types";
|
|
4
4
|
import { SqlControlTargetDescriptor } from "@prisma/orm-family-sql/family/control";
|
|
5
5
|
import { ColumnDefault } from "@prisma/orm-framework/contract/types";
|
|
@@ -9,4 +9,4 @@ declare function postgresRenderDefault(def: ColumnDefault, column: StorageColumn
|
|
|
9
9
|
declare const postgresTargetDescriptor: SqlControlTargetDescriptor<'postgres', PostgresPlanTargetDetails>;
|
|
10
10
|
//#endregion
|
|
11
11
|
export { postgresTargetDescriptor as n, postgresRenderDefault as t };
|
|
12
|
-
//# sourceMappingURL=control
|
|
12
|
+
//# sourceMappingURL=control-BvK2pHHh.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control
|
|
1
|
+
{"version":3,"file":"control-BvK2pHHh.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/control.d.mts"],"mappings":";;;;;;;iBAMiB,sBAAsB,KAAK,eAAe,QAAQ;cACrD,0BAA0B,uCAAuC"}
|
|
@@ -5,7 +5,7 @@ import "./types-B4IkFolc.mjs";
|
|
|
5
5
|
import { c as PostgresCodecRegistry } from "./types-CkryN1AS-CZtzRJFZ.mjs";
|
|
6
6
|
import { h as PostgresDdlNode } from "./nodes-BU-V-aZA-RqwPH68u.mjs";
|
|
7
7
|
import "./ddl-B4Rh8ntj.mjs";
|
|
8
|
-
import { t as parsePostgresDefault } from "./default-normalizer-
|
|
8
|
+
import { t as parsePostgresDefault } from "./default-normalizer-D9WbKo20.mjs";
|
|
9
9
|
import { t as normalizeSchemaNativeType } from "./native-type-normalizer-DqJlOTeX.mjs";
|
|
10
10
|
import { AnyQueryAst, DdlNode, LoweredStatement, LowererContext, MarkerReadResult, SqlExecuteRequest } from "@prisma/orm-family-sql/relational-core/ast";
|
|
11
11
|
import { SqlControlDriverInstance } from "@prisma/orm-family-sql/contract/types";
|
|
@@ -196,4 +196,4 @@ declare class PostgresControlAdapter implements SqlControlAdapter<'postgres'> {
|
|
|
196
196
|
declare const postgresAdapterDescriptor: SqlControlAdapterDescriptor<'postgres'>;
|
|
197
197
|
//#endregion
|
|
198
198
|
export { postgresAdapterDescriptor as i, createPostgresBuiltinCodecLookup as n, createPostgresCodecRegistryWithBuiltins as r, PostgresControlAdapter as t };
|
|
199
|
-
//# sourceMappingURL=control-
|
|
199
|
+
//# sourceMappingURL=control-DmVutloY.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"control-
|
|
1
|
+
{"version":3,"file":"control-DmVutloY.d.mts","names":[],"sources":["../../../../3-targets/6-adapters/postgres/dist/control.d.mts"],"mappings":";;;;;;;;;;;;;;;;;iBAciB,wCAAwC,4BAA4B,+BAA+B;;;;;;iBAMnG,oCAAoC;;;;;;;cAOvC,kCAAkC;mBAC7B;WACR;WACA;EACT,YAAY,eAAe;;;;;WAKlB,yBAAyB;;;;;;WAMzB,4BAA4B;EACrC,yCAAyC;EACzC,uCAAuC;;;;;;;;;EASvC,MAAM,KAAK,cAAc,iBAAiB,SAAS,0BAA0B;;;;;;;;EAQ7E,sBAAsB,KAAK,cAAc,iBAAiB,UAAU,0BAA0B,QAAQ;;;;;;;;;EAStG,WAAW,QAAQ,sCAAsC,gBAAgB,QAAQ;EACjF,wBAAwB,QAAQ,sCAAsC,gBAAgB,QAAQ;;;;;;;EAO9F,eAAe,QAAQ,uCAAuC,QAAQ,oBAAoB;UAClF;;;;;;;EAOR,WAAW,QAAQ,sCAAsC,iBAAiB,iBAAiB;UACnF;;;;;;EAMR,aAAa,QAAQ,sCAAsC,eAAe;aAC/D;aACA;aACA;MACP;EACJ,WAAW,QAAQ,sCAAsC,eAAe;aAC7D;aACA;aACA;MACP;;;;;EAKJ,aAAa,QAAQ,sCAAsC,eAAe,sBAAsB;aACrF;aACA;aACA;MACP;;;;;;;;;EASJ,iBAAiB,QAAQ,sCAAsC,eAAe;aACnE;aACA;aACA;aACA;aACA;aACA;aACA;MACP;UACI;UACA;;;;;;;;;;;;;;;;;;;;;;;;;EAyBR,WAAW,QAAQ,sCAAsC,oBAAoB,kBAAkB,QAAQ;;;;;UAK/F;;;;;;;;;UASA;;;;;;;;UAQA;;;;;;;UAOA;;;;UAIA;;;;cAII,2BAA2B"}
|