@prisma-next/family-sql 0.5.0-dev.9 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +2 -2
  2. package/dist/{authoring-type-constructors-BAR65pSK.mjs → authoring-type-constructors-F4JpCJl7.mjs} +14 -15
  3. package/dist/authoring-type-constructors-F4JpCJl7.mjs.map +1 -0
  4. package/dist/control-adapter.d.mts +26 -2
  5. package/dist/control-adapter.d.mts.map +1 -1
  6. package/dist/control-adapter.mjs +1 -1
  7. package/dist/control.d.mts +122 -40
  8. package/dist/control.d.mts.map +1 -1
  9. package/dist/control.mjs +1169 -24
  10. package/dist/control.mjs.map +1 -1
  11. package/dist/migration.d.mts +22 -24
  12. package/dist/migration.d.mts.map +1 -1
  13. package/dist/migration.mjs +25 -24
  14. package/dist/migration.mjs.map +1 -1
  15. package/dist/pack.d.mts +35 -23
  16. package/dist/pack.d.mts.map +1 -1
  17. package/dist/pack.mjs +3 -5
  18. package/dist/pack.mjs.map +1 -1
  19. package/dist/runtime.d.mts +19 -2
  20. package/dist/runtime.d.mts.map +1 -1
  21. package/dist/runtime.mjs +26 -4
  22. package/dist/runtime.mjs.map +1 -1
  23. package/dist/schema-verify.d.mts +2 -4
  24. package/dist/schema-verify.d.mts.map +1 -1
  25. package/dist/schema-verify.mjs +2 -3
  26. package/dist/test-utils.d.mts +2 -2
  27. package/dist/test-utils.mjs +2 -3
  28. package/dist/timestamp-now-generator-BWp8S2sa.mjs +86 -0
  29. package/dist/timestamp-now-generator-BWp8S2sa.mjs.map +1 -0
  30. package/dist/{types-C6K4mxDM.d.mts → types-BQBbcXg3.d.mts} +206 -28
  31. package/dist/types-BQBbcXg3.d.mts.map +1 -0
  32. package/dist/verify-pRYxnpiG.mjs +81 -0
  33. package/dist/verify-pRYxnpiG.mjs.map +1 -0
  34. package/dist/{verify-sql-schema-BBhkqEDo.d.mts → verify-sql-schema-CPHiuYHR.d.mts} +2 -3
  35. package/dist/verify-sql-schema-CPHiuYHR.d.mts.map +1 -0
  36. package/dist/{verify-sql-schema-Ovz7RXR5.mjs → verify-sql-schema-r1-2apHI.mjs} +18 -9
  37. package/dist/verify-sql-schema-r1-2apHI.mjs.map +1 -0
  38. package/dist/verify.d.mts +16 -21
  39. package/dist/verify.d.mts.map +1 -1
  40. package/dist/verify.mjs +2 -3
  41. package/package.json +23 -21
  42. package/src/core/authoring-field-presets.ts +35 -23
  43. package/src/core/control-adapter.ts +32 -0
  44. package/src/core/control-descriptor.ts +2 -1
  45. package/src/core/control-instance.ts +116 -18
  46. package/src/core/migrations/field-event-planner.ts +192 -0
  47. package/src/core/migrations/plan-helpers.ts +4 -0
  48. package/src/core/migrations/types.ts +200 -25
  49. package/src/core/operation-preview.ts +62 -0
  50. package/src/core/psl-contract-infer/default-mapping.ts +56 -0
  51. package/src/core/psl-contract-infer/name-transforms.ts +178 -0
  52. package/src/core/psl-contract-infer/postgres-default-mapping.ts +16 -0
  53. package/src/core/psl-contract-infer/postgres-type-map.ts +165 -0
  54. package/src/core/psl-contract-infer/printer-config.ts +55 -0
  55. package/src/core/psl-contract-infer/raw-default-parser.ts +91 -0
  56. package/src/core/psl-contract-infer/relation-inference.ts +196 -0
  57. package/src/core/psl-contract-infer/sql-schema-ir-to-psl-ast.ts +832 -0
  58. package/src/core/schema-verify/verify-helpers.ts +46 -6
  59. package/src/core/sql-migration.ts +25 -23
  60. package/src/core/timestamp-now-generator.ts +74 -0
  61. package/src/core/timestamp-now-runtime-generator.ts +24 -0
  62. package/src/core/verify.ts +46 -108
  63. package/src/exports/control.ts +11 -1
  64. package/src/exports/runtime.ts +2 -0
  65. package/src/exports/test-utils.ts +0 -1
  66. package/src/exports/verify.ts +1 -1
  67. package/dist/authoring-type-constructors-BAR65pSK.mjs.map +0 -1
  68. package/dist/types-C6K4mxDM.d.mts.map +0 -1
  69. package/dist/verify-4GshvY4p.mjs +0 -122
  70. package/dist/verify-4GshvY4p.mjs.map +0 -1
  71. package/dist/verify-sql-schema-BBhkqEDo.d.mts.map +0 -1
  72. package/dist/verify-sql-schema-Ovz7RXR5.mjs.map +0 -1
@@ -21,6 +21,39 @@ import type {
21
21
  } from '@prisma-next/sql-schema-ir/types';
22
22
  import type { ComponentDatabaseDependency } from '../migrations/types';
23
23
 
24
+ function indexOptionsLooselyEqual(
25
+ a: Record<string, unknown> | undefined,
26
+ b: Record<string, unknown> | undefined,
27
+ ): boolean {
28
+ const aKeys = a ? Object.keys(a).sort() : [];
29
+ const bKeys = b ? Object.keys(b).sort() : [];
30
+ if (aKeys.length !== bKeys.length) return false;
31
+ for (let i = 0; i < aKeys.length; i += 1) {
32
+ if (aKeys[i] !== bKeys[i]) return false;
33
+ }
34
+ if (aKeys.length === 0) return true;
35
+ for (const key of aKeys) {
36
+ // Postgres introspection returns reloptions values as raw strings (e.g.
37
+ // `'70'`, `'false'`), while contract option leaves are typed (number,
38
+ // boolean, string). Compare via String() so a contract `fillfactor: 70`
39
+ // matches an introspected `fillfactor: '70'` without a spurious mismatch.
40
+ if (
41
+ String((a as Record<string, unknown>)[key]) !== String((b as Record<string, unknown>)[key])
42
+ ) {
43
+ return false;
44
+ }
45
+ }
46
+ return true;
47
+ }
48
+
49
+ function indexExtrasMatch(
50
+ contractIndex: Index,
51
+ schemaIndex: { readonly type?: string; readonly options?: Record<string, unknown> },
52
+ ): boolean {
53
+ if ((contractIndex.type ?? null) !== (schemaIndex.type ?? null)) return false;
54
+ return indexOptionsLooselyEqual(contractIndex.options, schemaIndex.options);
55
+ }
56
+
24
57
  /**
25
58
  * Compares two arrays of strings for equality (order-sensitive).
26
59
  */
@@ -391,13 +424,19 @@ export function verifyIndexes(
391
424
 
392
425
  // Check for any matching index (unique or non-unique)
393
426
  // A unique index can satisfy a non-unique index requirement (stronger satisfies weaker)
394
- const matchingIndex = schemaIndexes.find((idx) =>
395
- arraysEqual(idx.columns, contractIndex.columns),
427
+ const matchingIndex = schemaIndexes.find(
428
+ (idx) =>
429
+ arraysEqual(idx.columns, contractIndex.columns) && indexExtrasMatch(contractIndex, idx),
396
430
  );
397
431
 
398
- // Also check if a unique constraint satisfies the index requirement
432
+ // Also check if a unique constraint satisfies the index requirement.
433
+ // Unique constraints carry no type/options of their own, so they can only
434
+ // satisfy a contract index that doesn't request a specific type/options.
399
435
  const matchingUniqueConstraint =
400
- !matchingIndex && schemaUniques.find((u) => arraysEqual(u.columns, contractIndex.columns));
436
+ !matchingIndex &&
437
+ contractIndex.type === undefined &&
438
+ contractIndex.options === undefined &&
439
+ schemaUniques.find((u) => arraysEqual(u.columns, contractIndex.columns));
401
440
 
402
441
  if (!matchingIndex && !matchingUniqueConstraint) {
403
442
  issues.push({
@@ -442,8 +481,9 @@ export function verifyIndexes(
442
481
  continue;
443
482
  }
444
483
 
445
- const matchingIndex = contractIndexes.find((idx) =>
446
- arraysEqual(idx.columns, schemaIndex.columns),
484
+ const matchingIndex = contractIndexes.find(
485
+ (idx) =>
486
+ arraysEqual(idx.columns, schemaIndex.columns) && indexExtrasMatch(idx, schemaIndex),
447
487
  );
448
488
 
449
489
  if (!matchingIndex) {
@@ -1,34 +1,36 @@
1
+ import { deriveProvidedInvariants } from '@prisma-next/migration-tools/invariants';
1
2
  import { Migration } from '@prisma-next/migration-tools/migration';
2
- import type { AnySqlMigrationOperation, SqlPlanTargetDetails } from './migrations/types';
3
+ import type { SqlMigrationPlanOperation, SqlPlanTargetDetails } from './migrations/types';
3
4
 
4
5
  /**
5
6
  * Family-owned base class for SQL migrations.
6
7
  *
7
- * Parameterized on the target-details shape because SQL-family targets
8
- * (Postgres, MySQL, SQLite, …) each carry their own `target.details` payload
9
- * on `SqlMigrationPlanOperation`. The type parameter is narrowed to
10
- * `SqlPlanTargetDetails` so every target-specific shape must at minimum
11
- * identify the object being targeted (schema + name); concrete targets
12
- * extend the shape with their own fields.
8
+ * Generic in `TDetails` (family plan target details, e.g. Postgres vs SQLite)
9
+ * and in `TTargetId` (the literal target identifier, e.g. `'postgres'`).
13
10
  *
14
- * Each concrete target-side subclass (e.g. Postgres's
15
- * `TypeScriptRenderablePostgresMigration`) fixes `targetId` to its own
16
- * target-id string literal, since SQL can't hardcode a single `targetId`:
17
- * `targetId` is a target-level identity, not a family-level one, and
18
- * belongs on the subclass.
11
+ * Adapters (Postgres, SQLite, …) extend this with a concrete `TDetails` and
12
+ * a fixed `TTargetId` literal, so the public `Migration<TOp>` base sees the
13
+ * fully concrete operation shape. Target-free code in SQL family / tooling
14
+ * parameterises over `TDetails` (and usually `TTargetId = string`).
19
15
  *
20
- * `familyId` is intentionally not declared here. The SQL family has no
21
- * family-scoped runtime identity today — consumers reach the family via
22
- * target descriptors rather than by family-id lookup, so adding one would
23
- * be purely decorative. Introducing it later is a non-breaking superset.
24
- *
25
- * The operation type parameter is `AnySqlMigrationOperation<TDetails>` — the
26
- * union of DDL-shaped `SqlMigrationPlanOperation` and `DataTransformOperation`
27
- * — so subclasses can return a mix of schema operations (e.g. `setNotNull`,
28
- * `addColumn`) and data-transform operations (e.g. `dataTransform`). Mirrors
29
- * `MongoMigration`'s parameterization on `AnyMongoMigrationOperation`.
16
+ * Keeps target-free contract/runtime features in the family layer while
17
+ * letting adapters own target shape.
30
18
  */
31
19
  export abstract class SqlMigration<
32
20
  TDetails extends SqlPlanTargetDetails,
33
21
  TTargetId extends string = string,
34
- > extends Migration<AnySqlMigrationOperation<TDetails>, 'sql', TTargetId> {}
22
+ > extends Migration<SqlMigrationPlanOperation<TDetails>, 'sql', TTargetId> {
23
+ /**
24
+ * Sorted, deduplicated invariant ids declared by this migration's
25
+ * data-transform ops. Derived from `this.operations` so the field remains
26
+ * consistent with the operation list — planner-built plans (`db init`,
27
+ * `db update`) yield `[]` because they emit no data-transform ops.
28
+ *
29
+ * Required by `SqlMigrationPlan.providedInvariants` (tightened from
30
+ * optional at the SQL-family layer); the framework-level
31
+ * `MigrationPlan.providedInvariants?` stays optional.
32
+ */
33
+ get providedInvariants(): readonly string[] {
34
+ return deriveProvidedInvariants(this.operations);
35
+ }
36
+ }
@@ -0,0 +1,74 @@
1
+ import type { AuthoringFieldPresetDescriptor } from '@prisma-next/framework-components/authoring';
2
+ import type { MutationDefaultGeneratorDescriptor } from '@prisma-next/framework-components/control';
3
+
4
+ /**
5
+ * Canonical id for the wall-clock-now mutation default generator.
6
+ *
7
+ * Owned by `family-sql` because that's where the generator lives. The
8
+ * id flows out from here to (1) the control-plane descriptor and the
9
+ * temporal field-preset pair below, (2) the runtime-plane sibling
10
+ * `timestamp-now-runtime-generator.ts`, and (3) authoring surfaces
11
+ * (PSL `temporal.updatedAt()`, TS `field.temporal.updatedAt()`) via
12
+ * the descriptor flow. Co-locating the constant with its only owner
13
+ * keeps the framework layer free of concrete generator ids.
14
+ */
15
+ export const TIMESTAMP_NOW_GENERATOR_ID = 'timestampNow' as const;
16
+
17
+ /**
18
+ * Builds the canonical control-plane descriptor for the wall-clock-now
19
+ * mutation default generator. The descriptor's `id` and `buildPhases`
20
+ * are target-agnostic so PSL `temporal.updatedAt()` and TS
21
+ * `field.temporal.updatedAt()` lower to byte-identical contracts.
22
+ *
23
+ * `applicableCodecIds` is omitted: `timestampNow` is preset-only (not
24
+ * reachable via `@default(timestampNow())` lowering), and the codec is
25
+ * co-registered by the preset descriptor itself, so the
26
+ * `@default(...)` compatibility check has no role to play here.
27
+ */
28
+ export function timestampNowControlDescriptor(): MutationDefaultGeneratorDescriptor {
29
+ return {
30
+ id: TIMESTAMP_NOW_GENERATOR_ID,
31
+ buildPhases: () => ({
32
+ onCreate: { kind: 'generator', id: TIMESTAMP_NOW_GENERATOR_ID },
33
+ onUpdate: { kind: 'generator', id: TIMESTAMP_NOW_GENERATOR_ID },
34
+ }),
35
+ };
36
+ }
37
+
38
+ /**
39
+ * Builds the canonical `temporal.{createdAt,updatedAt}` field-preset pair
40
+ * for a SQL target. `createdAt` lowers to a `now()` storage default;
41
+ * `updatedAt` lowers to the `timestampNow` execution generator on both
42
+ * `onCreate` and `onUpdate` (RD: "last modified time", non-null). Targets
43
+ * supply the codec/native-type pair that matches their timestamp column;
44
+ * everything else is shared so PSL `temporal.updatedAt()` and TS
45
+ * `field.temporal.updatedAt()` lower to byte-identical contracts across
46
+ * targets by construction.
47
+ */
48
+ export function temporalAuthoringPresets<
49
+ const CodecId extends string,
50
+ const NativeType extends string,
51
+ >(input: { readonly codecId: CodecId; readonly nativeType: NativeType }) {
52
+ const { codecId, nativeType } = input;
53
+ return {
54
+ createdAt: {
55
+ kind: 'fieldPreset',
56
+ output: {
57
+ codecId,
58
+ nativeType,
59
+ default: { kind: 'function', expression: 'now()' },
60
+ },
61
+ },
62
+ updatedAt: {
63
+ kind: 'fieldPreset',
64
+ output: {
65
+ codecId,
66
+ nativeType,
67
+ executionDefaults: {
68
+ onCreate: { kind: 'generator', id: TIMESTAMP_NOW_GENERATOR_ID },
69
+ onUpdate: { kind: 'generator', id: TIMESTAMP_NOW_GENERATOR_ID },
70
+ },
71
+ },
72
+ },
73
+ } as const satisfies Record<string, AuthoringFieldPresetDescriptor>;
74
+ }
@@ -0,0 +1,24 @@
1
+ import type { RuntimeMutationDefaultGenerator } from '@prisma-next/sql-runtime';
2
+ import { TIMESTAMP_NOW_GENERATOR_ID } from './timestamp-now-generator';
3
+
4
+ /**
5
+ * Builds the canonical runtime-plane generator for the wall-clock-now
6
+ * mutation default. Returns `new Date()`; semantics are target-agnostic
7
+ * so all SQL targets share this single implementation.
8
+ *
9
+ * Declares `stability: 'query'` so a single ORM bulk operation
10
+ * (e.g. `createAll([...])`) shares one timestamp across every row and
11
+ * every timestamp-defaulted column. Matches Prisma 6's `@updatedAt`
12
+ * semantics: one `new Date()` per lowered mutation, not per row.
13
+ *
14
+ * Lives in a runtime-plane-only module so the control-plane
15
+ * `timestamp-now-generator.ts` (descriptor + authoring presets) stays
16
+ * free of `@prisma-next/sql-runtime` imports.
17
+ */
18
+ export function timestampNowRuntimeGenerator(): RuntimeMutationDefaultGenerator {
19
+ return {
20
+ id: TIMESTAMP_NOW_GENERATOR_ID,
21
+ generate: () => new Date(),
22
+ stability: 'query',
23
+ };
24
+ }
@@ -1,5 +1,4 @@
1
1
  import type { ContractMarkerRecord } from '@prisma-next/contract/types';
2
- import type { ControlDriverInstance } from '@prisma-next/framework-components/control';
3
2
  import { type } from 'arktype';
4
3
 
5
4
  const MetaSchema = type({ '[string]': 'unknown' });
@@ -28,6 +27,40 @@ function parseMeta(meta: unknown): Record<string, unknown> {
28
27
  return result as Record<string, unknown>;
29
28
  }
30
29
 
30
+ /**
31
+ * SQLite stores `contract_json` as TEXT, so the wire shape is a JSON string;
32
+ * Postgres uses `jsonb` and returns an already-parsed value. Normalize both
33
+ * here so `ContractMarkerRecord.contractJson` is always the structured form.
34
+ */
35
+ function parseContractJson(value: unknown): unknown {
36
+ if (value === null || value === undefined) return null;
37
+ if (typeof value !== 'string') return value;
38
+ try {
39
+ return JSON.parse(value);
40
+ } catch {
41
+ return null;
42
+ }
43
+ }
44
+
45
+ /**
46
+ * Wire shape of a `prisma_contract.marker` row as it comes out of a SQL
47
+ * driver. Snake-cased to match the on-disk column names. Shared by every
48
+ * SQL target's `readMarker` so each runner doesn't redeclare it inline.
49
+ */
50
+ export type ContractMarkerRow = {
51
+ core_hash: string;
52
+ profile_hash: string;
53
+ contract_json: unknown | null;
54
+ canonical_version: number | null;
55
+ updated_at: Date | string;
56
+ app_tag: string | null;
57
+ meta: unknown | null;
58
+ // SQLite stores arrays as JSON-TEXT, so this is `string` on the wire from
59
+ // a SQLite driver and `string[]` from a Postgres driver. Targets normalize
60
+ // before passing to `parseContractMarkerRow`.
61
+ invariants: unknown;
62
+ };
63
+
31
64
  const ContractMarkerRowSchema = type({
32
65
  core_hash: 'string',
33
66
  profile_hash: 'string',
@@ -36,6 +69,7 @@ const ContractMarkerRowSchema = type({
36
69
  'updated_at?': 'Date | string',
37
70
  'app_tag?': 'string | null',
38
71
  'meta?': 'unknown | null',
72
+ invariants: type('string').array(),
39
73
  });
40
74
 
41
75
  /**
@@ -49,120 +83,24 @@ export function parseContractMarkerRow(row: unknown): ContractMarkerRecord {
49
83
  throw new Error(`Invalid contract marker row: ${messages}`);
50
84
  }
51
85
 
52
- const validatedRow = result as {
53
- core_hash: string;
54
- profile_hash: string;
55
- contract_json?: unknown | null;
56
- canonical_version?: number | null;
57
- updated_at?: Date | string;
58
- app_tag?: string | null;
59
- meta?: unknown | null;
60
- };
61
-
62
- const updatedAt = validatedRow.updated_at
63
- ? validatedRow.updated_at instanceof Date
64
- ? validatedRow.updated_at
65
- : new Date(validatedRow.updated_at)
86
+ const updatedAt = result.updated_at
87
+ ? result.updated_at instanceof Date
88
+ ? result.updated_at
89
+ : new Date(result.updated_at)
66
90
  : new Date();
67
91
 
68
92
  return {
69
- storageHash: validatedRow.core_hash,
70
- profileHash: validatedRow.profile_hash,
71
- contractJson: validatedRow.contract_json ?? null,
72
- canonicalVersion: validatedRow.canonical_version ?? null,
93
+ storageHash: result.core_hash,
94
+ profileHash: result.profile_hash,
95
+ contractJson: parseContractJson(result.contract_json),
96
+ canonicalVersion: result.canonical_version ?? null,
73
97
  updatedAt,
74
- appTag: validatedRow.app_tag ?? null,
75
- meta: parseMeta(validatedRow.meta),
98
+ appTag: result.app_tag ?? null,
99
+ meta: parseMeta(result.meta),
100
+ invariants: result.invariants,
76
101
  };
77
102
  }
78
103
 
79
- /**
80
- * Returns the SQL statement to read the contract marker.
81
- * This is a migration-plane helper (no runtime imports).
82
- * @internal - Used internally by readMarker(). Prefer readMarker() for Control Plane usage.
83
- */
84
- export function readMarkerSql(): { readonly sql: string; readonly params: readonly unknown[] } {
85
- return {
86
- sql: `select
87
- core_hash,
88
- profile_hash,
89
- contract_json,
90
- canonical_version,
91
- updated_at,
92
- app_tag,
93
- meta
94
- from prisma_contract.marker
95
- where id = $1`,
96
- params: [1],
97
- };
98
- }
99
-
100
- /**
101
- * Returns the SQL statement that probes for the existence of the marker table.
102
- * Uses the SQL-standard `information_schema.tables` view so the query succeeds
103
- * (returning zero rows) when the table has not been created yet — avoiding a
104
- * `relation does not exist` error. Some Postgres wire-protocol implementations
105
- * (e.g. PGlite's TCP proxy) do not fully recover from an extended-protocol
106
- * parse error, so we probe first instead of relying on an error signal.
107
- * @internal - Used internally by readMarker().
108
- */
109
- export function markerTableExistsSql(): {
110
- readonly sql: string;
111
- readonly params: readonly unknown[];
112
- } {
113
- return {
114
- sql: `select 1
115
- from information_schema.tables
116
- where table_schema = $1 and table_name = $2`,
117
- params: ['prisma_contract', 'marker'],
118
- };
119
- }
120
-
121
- /**
122
- * Reads the contract marker from the database using the provided driver.
123
- * Returns the parsed marker record or null if no marker is found.
124
- * This abstracts SQL-specific details from the Control Plane.
125
- *
126
- * @param driver - ControlDriverInstance instance for executing queries
127
- * @returns Promise resolving to ContractMarkerRecord or null if marker not found
128
- */
129
- export async function readMarker(
130
- driver: ControlDriverInstance<'sql', string>,
131
- ): Promise<ContractMarkerRecord | null> {
132
- // Probe for the marker table first so that a fresh database (no
133
- // `prisma_contract` schema) returns null cleanly instead of surfacing a
134
- // `relation does not exist` error. This keeps the control connection in a
135
- // predictable state for driver implementations that are sensitive to
136
- // extended-protocol parse errors.
137
- const existsStatement = markerTableExistsSql();
138
- const existsResult = await driver.query(existsStatement.sql, existsStatement.params);
139
- if (existsResult.rows.length === 0) {
140
- return null;
141
- }
142
-
143
- const markerStatement = readMarkerSql();
144
- const queryResult = await driver.query<{
145
- core_hash: string;
146
- profile_hash: string;
147
- contract_json: unknown | null;
148
- canonical_version: number | null;
149
- updated_at: Date | string;
150
- app_tag: string | null;
151
- meta: unknown | null;
152
- }>(markerStatement.sql, markerStatement.params);
153
-
154
- if (queryResult.rows.length === 0) {
155
- return null;
156
- }
157
-
158
- const markerRow = queryResult.rows[0];
159
- if (!markerRow) {
160
- throw new Error('Database query returned unexpected result structure');
161
- }
162
-
163
- return parseContractMarkerRow(markerRow);
164
- }
165
-
166
104
  /**
167
105
  * Collects supported codec type IDs from adapter and extension manifests.
168
106
  * Returns a sorted, unique array of type IDs that are declared in the manifests.
@@ -24,6 +24,8 @@ export {
24
24
  contractToSchemaIR,
25
25
  detectDestructiveChanges,
26
26
  } from '../core/migrations/contract-to-schema-ir';
27
+ export type { PlanFieldEventOperationsOptions } from '../core/migrations/field-event-planner';
28
+ export { planFieldEventOperations } from '../core/migrations/field-event-planner';
27
29
  export {
28
30
  createMigrationPlan,
29
31
  plannerFailure,
@@ -33,12 +35,16 @@ export {
33
35
  } from '../core/migrations/plan-helpers';
34
36
  export { INIT_ADDITIVE_POLICY } from '../core/migrations/policies';
35
37
  export type {
36
- AnySqlMigrationOperation,
37
38
  CodecControlHooks,
38
39
  ComponentDatabaseDependencies,
39
40
  ComponentDatabaseDependency,
40
41
  CreateSqlMigrationPlanOptions,
41
42
  ExpandNativeTypeInput,
43
+ FieldEvent,
44
+ FieldEventContext,
45
+ MultiSpaceRunnerFailure,
46
+ MultiSpaceRunnerResult,
47
+ MultiSpaceRunnerSuccessValue,
42
48
  ResolveIdentityValueInput,
43
49
  SqlControlAdapterDescriptor,
44
50
  SqlControlExtensionDescriptor,
@@ -67,5 +73,9 @@ export type {
67
73
  StorageTypePlanResult,
68
74
  } from '../core/migrations/types';
69
75
  export { collectInitDependencies, isDatabaseDependencyProvider } from '../core/migrations/types';
76
+ export {
77
+ temporalAuthoringPresets,
78
+ timestampNowControlDescriptor,
79
+ } from '../core/timestamp-now-generator';
70
80
 
71
81
  export default new SqlFamilyDescriptor();
@@ -1,3 +1,5 @@
1
1
  import { sqlRuntimeFamilyDescriptor } from '../core/runtime-descriptor';
2
2
 
3
+ export { timestampNowRuntimeGenerator } from '../core/timestamp-now-runtime-generator';
4
+
3
5
  export default sqlRuntimeFamilyDescriptor;
@@ -5,6 +5,5 @@
5
5
  export {
6
6
  extractCodecTypeImports,
7
7
  extractComponentIds,
8
- extractOperationTypeImports,
9
8
  extractQueryOperationTypeImports,
10
9
  } from '@prisma-next/framework-components/control';
@@ -1 +1 @@
1
- export { parseContractMarkerRow, readMarker, readMarkerSql } from '../core/verify';
1
+ export { type ContractMarkerRow, parseContractMarkerRow } from '../core/verify';
@@ -1 +0,0 @@
1
- {"version":3,"file":"authoring-type-constructors-BAR65pSK.mjs","names":[],"sources":["../src/core/authoring-field-presets.ts","../src/core/authoring-type-constructors.ts"],"sourcesContent":["import type { AuthoringFieldNamespace } from '@prisma-next/framework-components/authoring';\n\n/**\n * Family-level SQL authoring field presets.\n *\n * Only presets whose codec IDs align with the ID generator metadata live here\n * (see `@prisma-next/ids`). These presets are target-agnostic because the\n * generator metadata fixes their codec/native-type to `sql/char@1`\n * (`character`) regardless of target, and the PSL interpreter lets the\n * generator override the scalar descriptor.\n *\n * Scalar presets that map to target-specific codecs (e.g. `text`, `int`,\n * `boolean`, `dateTime`) are contributed by the target pack (see\n * `postgresAuthoringFieldPresets` in `@prisma-next/target-postgres`) so the\n * TS callback surface and the PSL scalar surface lower to byte-identical\n * contracts for the active target.\n */\n\nconst CHARACTER_CODEC_ID = 'sql/char@1';\nconst CHARACTER_NATIVE_TYPE = 'character';\n\nconst nanoidOptionsArgument = {\n kind: 'object',\n optional: true,\n properties: {\n size: {\n kind: 'number',\n optional: true,\n integer: true,\n minimum: 2,\n maximum: 255,\n },\n },\n} as const;\n\nexport const sqlFamilyAuthoringFieldPresets = {\n uuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n },\n },\n id: {\n uuidv4: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefault: {\n kind: 'generator',\n id: 'uuidv4',\n },\n id: true,\n },\n },\n uuidv7: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 36,\n },\n executionDefault: {\n kind: 'generator',\n id: 'uuidv7',\n },\n id: true,\n },\n },\n ulid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 26,\n },\n executionDefault: {\n kind: 'generator',\n id: 'ulid',\n },\n id: true,\n },\n },\n nanoid: {\n kind: 'fieldPreset',\n args: [nanoidOptionsArgument],\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n default: 21,\n },\n },\n executionDefault: {\n kind: 'generator',\n id: 'nanoid',\n params: {\n size: {\n kind: 'arg',\n index: 0,\n path: ['size'],\n },\n },\n },\n id: true,\n },\n },\n cuid2: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 24,\n },\n executionDefault: {\n kind: 'generator',\n id: 'cuid2',\n },\n id: true,\n },\n },\n ksuid: {\n kind: 'fieldPreset',\n output: {\n codecId: CHARACTER_CODEC_ID,\n nativeType: CHARACTER_NATIVE_TYPE,\n typeParams: {\n length: 27,\n },\n executionDefault: {\n kind: 'generator',\n id: 'ksuid',\n },\n id: true,\n },\n },\n },\n} as const satisfies AuthoringFieldNamespace;\n","import type { AuthoringTypeNamespace } from '@prisma-next/framework-components/authoring';\n\nexport const sqlFamilyAuthoringTypes = {\n sql: {\n String: {\n kind: 'typeConstructor',\n args: [{ kind: 'number', name: 'length', integer: true, minimum: 1, maximum: 10485760 }],\n output: {\n codecId: 'sql/varchar@1',\n nativeType: 'character varying',\n typeParams: {\n length: { kind: 'arg', index: 0 },\n },\n },\n },\n },\n} as const satisfies AuthoringTypeNamespace;\n"],"mappings":";;;;;;;;;;;;;;;;AAkBA,MAAM,qBAAqB;AAC3B,MAAM,wBAAwB;AAE9B,MAAM,wBAAwB;CAC5B,MAAM;CACN,UAAU;CACV,YAAY,EACV,MAAM;EACJ,MAAM;EACN,UAAU;EACV,SAAS;EACT,SAAS;EACT,SAAS;EACV,EACF;CACF;AAED,MAAa,iCAAiC;CAC5C,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,IACT;GACF;EACF;CACD,MAAM;EACJ,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,IACT;GACF;EACF;CACD,QAAQ;EACN,MAAM;EACN,MAAM,CAAC,sBAAsB;EAC7B,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ;IACN,MAAM;IACN,OAAO;IACP,MAAM,CAAC,OAAO;IACd,SAAS;IACV,EACF;GACF;EACF;CACD,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,IACT;GACF;EACF;CACD,OAAO;EACL,MAAM;EACN,QAAQ;GACN,SAAS;GACT,YAAY;GACZ,YAAY,EACV,QAAQ,IACT;GACF;EACF;CACD,IAAI;EACF,QAAQ;GACN,MAAM;GACN,QAAQ;IACN,SAAS;IACT,YAAY;IACZ,Y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ClC;EACF;CACF,EACF,EACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-C6K4mxDM.d.mts","names":[],"sources":["../src/core/control-instance.ts","../src/core/migrations/types.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;UAyJU,eAAA;;;;;AAzHsE;AAyHvD,KAOpB,uBAAA,GAA0B,GAAH,CAAA,MAAA,EAAe,eAAA,CAAZ;AAAG,UAExB,sBAAA,CAAsB;EACW,SAAA,gBAAA,EAAd,aAAc,CAAA,eAAA,CAAA;EAAd,SAAA,oBAAA,EACI,aADJ,CACkB,eADlB,CAAA;EACkB,SAAA,YAAA,EACtB,aADsB,CAAA,MAAA,CAAA;EAAd,SAAA,oBAAA,EAEA,uBAFA;;AAEA,UAGhB,mBAAA,CAHgB;EAAuB,SAAA,MAAA,EAIrC,qBAJqC,CAAA,KAAA,EAAA,MAAA,CAAA;EAGvC,SAAA,QAAA,EAAA,OAAmB;EACjB,SAAA,MAAA,EAAA,OAAA;EAGE,SAAA,OAAA,CAAA,EAAA,gBAAA;EAKyB;;;AAG9C;EACuC,SAAA,mBAAA,EAJP,aAIO,CAJO,8BAIP,CAAA,KAAA,EAAA,MAAA,CAAA,CAAA;;AAGI,UAJ1B,wBAAA,SACP,qBAGiC,CAAA,KAAA,EAHJ,WAGI,CAAA,EAFvC,iBAEuC,CAFrB,WAEqB,CAAA,EADvC,sBACuC,CAAA;EAGtB,gBAAA,CAAA,YAAA,EAAA,OAAA,CAAA,EAHsB,QAGtB;EAKP,MAAA,CAAA,OAAA,EAAA;IAAR,SAAA,MAAA,EALe,qBAKf,CAAA,KAAA,EAAA,MAAA,CAAA;IAEkB,SAAA,QAAA,EAAA,OAAA;IAA8B,SAAA,gBAAA,EAAA,MAAA;IAAR,SAAA,YAAA,EAAA,MAAA;IAGzB,SAAA,UAAA,CAAA,EAAA,MAAA;EAIP,CAAA,CAAA,EATR,OASQ,CATA,oBASA,CAAA;EAAR,YAAA,CAAA,OAAA,EAPkB,mBAOlB,CAA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CACpB,cAAc;wBACzB,2BAA2B,oBAAoB;uBAChD,2BAA2B,mBAAmB;;UAGpD;;oBAEG;wBACI;gCACQ,0BAA0B;kBACxC"}
@@ -1,122 +0,0 @@
1
- import { type } from "arktype";
2
-
3
- //#region src/core/verify.ts
4
- const MetaSchema = type({ "[string]": "unknown" });
5
- function parseMeta(meta) {
6
- if (meta === null || meta === void 0) return {};
7
- let parsed;
8
- if (typeof meta === "string") try {
9
- parsed = JSON.parse(meta);
10
- } catch {
11
- return {};
12
- }
13
- else parsed = meta;
14
- const result = MetaSchema(parsed);
15
- if (result instanceof type.errors) return {};
16
- return result;
17
- }
18
- const ContractMarkerRowSchema = type({
19
- core_hash: "string",
20
- profile_hash: "string",
21
- "contract_json?": "unknown | null",
22
- "canonical_version?": "number | null",
23
- "updated_at?": "Date | string",
24
- "app_tag?": "string | null",
25
- "meta?": "unknown | null"
26
- });
27
- /**
28
- * Parses a contract marker row from database query result.
29
- * This is SQL-specific parsing logic (handles SQL row structure with snake_case columns).
30
- */
31
- function parseContractMarkerRow(row) {
32
- const result = ContractMarkerRowSchema(row);
33
- if (result instanceof type.errors) {
34
- const messages = result.map((p) => p.message).join("; ");
35
- throw new Error(`Invalid contract marker row: ${messages}`);
36
- }
37
- const validatedRow = result;
38
- const updatedAt = validatedRow.updated_at ? validatedRow.updated_at instanceof Date ? validatedRow.updated_at : new Date(validatedRow.updated_at) : /* @__PURE__ */ new Date();
39
- return {
40
- storageHash: validatedRow.core_hash,
41
- profileHash: validatedRow.profile_hash,
42
- contractJson: validatedRow.contract_json ?? null,
43
- canonicalVersion: validatedRow.canonical_version ?? null,
44
- updatedAt,
45
- appTag: validatedRow.app_tag ?? null,
46
- meta: parseMeta(validatedRow.meta)
47
- };
48
- }
49
- /**
50
- * Returns the SQL statement to read the contract marker.
51
- * This is a migration-plane helper (no runtime imports).
52
- * @internal - Used internally by readMarker(). Prefer readMarker() for Control Plane usage.
53
- */
54
- function readMarkerSql() {
55
- return {
56
- sql: `select
57
- core_hash,
58
- profile_hash,
59
- contract_json,
60
- canonical_version,
61
- updated_at,
62
- app_tag,
63
- meta
64
- from prisma_contract.marker
65
- where id = $1`,
66
- params: [1]
67
- };
68
- }
69
- /**
70
- * Returns the SQL statement that probes for the existence of the marker table.
71
- * Uses the SQL-standard `information_schema.tables` view so the query succeeds
72
- * (returning zero rows) when the table has not been created yet — avoiding a
73
- * `relation does not exist` error. Some Postgres wire-protocol implementations
74
- * (e.g. PGlite's TCP proxy) do not fully recover from an extended-protocol
75
- * parse error, so we probe first instead of relying on an error signal.
76
- * @internal - Used internally by readMarker().
77
- */
78
- function markerTableExistsSql() {
79
- return {
80
- sql: `select 1
81
- from information_schema.tables
82
- where table_schema = $1 and table_name = $2`,
83
- params: ["prisma_contract", "marker"]
84
- };
85
- }
86
- /**
87
- * Reads the contract marker from the database using the provided driver.
88
- * Returns the parsed marker record or null if no marker is found.
89
- * This abstracts SQL-specific details from the Control Plane.
90
- *
91
- * @param driver - ControlDriverInstance instance for executing queries
92
- * @returns Promise resolving to ContractMarkerRecord or null if marker not found
93
- */
94
- async function readMarker(driver) {
95
- const existsStatement = markerTableExistsSql();
96
- if ((await driver.query(existsStatement.sql, existsStatement.params)).rows.length === 0) return null;
97
- const markerStatement = readMarkerSql();
98
- const queryResult = await driver.query(markerStatement.sql, markerStatement.params);
99
- if (queryResult.rows.length === 0) return null;
100
- const markerRow = queryResult.rows[0];
101
- if (!markerRow) throw new Error("Database query returned unexpected result structure");
102
- return parseContractMarkerRow(markerRow);
103
- }
104
- /**
105
- * Collects supported codec type IDs from adapter and extension manifests.
106
- * Returns a sorted, unique array of type IDs that are declared in the manifests.
107
- * This enables coverage checks by comparing contract column types against supported types.
108
- *
109
- * Note: This extracts type IDs from manifest type imports, not from runtime codec registries.
110
- * The manifests declare which codec types are available, but the actual type IDs
111
- * are defined in the codec-types TypeScript modules that are imported.
112
- *
113
- * For MVP, we return an empty array since extracting type IDs from TypeScript modules
114
- * would require runtime evaluation or static analysis. This can be enhanced later.
115
- */
116
- function collectSupportedCodecTypeIds(descriptors) {
117
- return [];
118
- }
119
-
120
- //#endregion
121
- export { readMarkerSql as i, parseContractMarkerRow as n, readMarker as r, collectSupportedCodecTypeIds as t };
122
- //# sourceMappingURL=verify-4GshvY4p.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify-4GshvY4p.mjs","names":["parsed: unknown"],"sources":["../src/core/verify.ts"],"sourcesContent":["import type { ContractMarkerRecord } from '@prisma-next/contract/types';\nimport type { ControlDriverInstance } from '@prisma-next/framework-components/control';\nimport { type } from 'arktype';\n\nconst MetaSchema = type({ '[string]': 'unknown' });\n\nfunction parseMeta(meta: unknown): Record<string, unknown> {\n if (meta === null || meta === undefined) {\n return {};\n }\n\n let parsed: unknown;\n if (typeof meta === 'string') {\n try {\n parsed = JSON.parse(meta);\n } catch {\n return {};\n }\n } else {\n parsed = meta;\n }\n\n const result = MetaSchema(parsed);\n if (result instanceof type.errors) {\n return {};\n }\n\n return result as Record<string, unknown>;\n}\n\nconst ContractMarkerRowSchema = type({\n core_hash: 'string',\n profile_hash: 'string',\n 'contract_json?': 'unknown | null',\n 'canonical_version?': 'number | null',\n 'updated_at?': 'Date | string',\n 'app_tag?': 'string | null',\n 'meta?': 'unknown | null',\n});\n\n/**\n * Parses a contract marker row from database query result.\n * This is SQL-specific parsing logic (handles SQL row structure with snake_case columns).\n */\nexport function parseContractMarkerRow(row: unknown): ContractMarkerRecord {\n const result = ContractMarkerRowSchema(row);\n if (result instanceof type.errors) {\n const messages = result.map((p: { message: string }) => p.message).join('; ');\n throw new Error(`Invalid contract marker row: ${messages}`);\n }\n\n const validatedRow = result as {\n core_hash: string;\n profile_hash: string;\n contract_json?: unknown | null;\n canonical_version?: number | null;\n updated_at?: Date | string;\n app_tag?: string | null;\n meta?: unknown | null;\n };\n\n const updatedAt = validatedRow.updated_at\n ? validatedRow.updated_at instanceof Date\n ? validatedRow.updated_at\n : new Date(validatedRow.updated_at)\n : new Date();\n\n return {\n storageHash: validatedRow.core_hash,\n profileHash: validatedRow.profile_hash,\n contractJson: validatedRow.contract_json ?? null,\n canonicalVersion: validatedRow.canonical_version ?? null,\n updatedAt,\n appTag: validatedRow.app_tag ?? null,\n meta: parseMeta(validatedRow.meta),\n };\n}\n\n/**\n * Returns the SQL statement to read the contract marker.\n * This is a migration-plane helper (no runtime imports).\n * @internal - Used internally by readMarker(). Prefer readMarker() for Control Plane usage.\n */\nexport function readMarkerSql(): { readonly sql: string; readonly params: readonly unknown[] } {\n return {\n sql: `select\n core_hash,\n profile_hash,\n contract_json,\n canonical_version,\n updated_at,\n app_tag,\n meta\n from prisma_contract.marker\n where id = $1`,\n params: [1],\n };\n}\n\n/**\n * Returns the SQL statement that probes for the existence of the marker table.\n * Uses the SQL-standard `information_schema.tables` view so the query succeeds\n * (returning zero rows) when the table has not been created yet — avoiding a\n * `relation does not exist` error. Some Postgres wire-protocol implementations\n * (e.g. PGlite's TCP proxy) do not fully recover from an extended-protocol\n * parse error, so we probe first instead of relying on an error signal.\n * @internal - Used internally by readMarker().\n */\nexport function markerTableExistsSql(): {\n readonly sql: string;\n readonly params: readonly unknown[];\n} {\n return {\n sql: `select 1\n from information_schema.tables\n where table_schema = $1 and table_name = $2`,\n params: ['prisma_contract', 'marker'],\n };\n}\n\n/**\n * Reads the contract marker from the database using the provided driver.\n * Returns the parsed marker record or null if no marker is found.\n * This abstracts SQL-specific details from the Control Plane.\n *\n * @param driver - ControlDriverInstance instance for executing queries\n * @returns Promise resolving to ContractMarkerRecord or null if marker not found\n */\nexport async function readMarker(\n driver: ControlDriverInstance<'sql', string>,\n): Promise<ContractMarkerRecord | null> {\n // Probe for the marker table first so that a fresh database (no\n // `prisma_contract` schema) returns null cleanly instead of surfacing a\n // `relation does not exist` error. This keeps the control connection in a\n // predictable state for driver implementations that are sensitive to\n // extended-protocol parse errors.\n const existsStatement = markerTableExistsSql();\n const existsResult = await driver.query(existsStatement.sql, existsStatement.params);\n if (existsResult.rows.length === 0) {\n return null;\n }\n\n const markerStatement = readMarkerSql();\n const queryResult = await driver.query<{\n core_hash: string;\n profile_hash: string;\n contract_json: unknown | null;\n canonical_version: number | null;\n updated_at: Date | string;\n app_tag: string | null;\n meta: unknown | null;\n }>(markerStatement.sql, markerStatement.params);\n\n if (queryResult.rows.length === 0) {\n return null;\n }\n\n const markerRow = queryResult.rows[0];\n if (!markerRow) {\n throw new Error('Database query returned unexpected result structure');\n }\n\n return parseContractMarkerRow(markerRow);\n}\n\n/**\n * Collects supported codec type IDs from adapter and extension manifests.\n * Returns a sorted, unique array of type IDs that are declared in the manifests.\n * This enables coverage checks by comparing contract column types against supported types.\n *\n * Note: This extracts type IDs from manifest type imports, not from runtime codec registries.\n * The manifests declare which codec types are available, but the actual type IDs\n * are defined in the codec-types TypeScript modules that are imported.\n *\n * For MVP, we return an empty array since extracting type IDs from TypeScript modules\n * would require runtime evaluation or static analysis. This can be enhanced later.\n */\nexport function collectSupportedCodecTypeIds(\n descriptors: ReadonlyArray<{ readonly id: string }>,\n): readonly string[] {\n // For MVP, return empty array\n // Future enhancement: Extract type IDs from codec-types modules via static analysis\n // or require manifests to explicitly list supported type IDs\n void descriptors;\n return [];\n}\n"],"mappings":";;;AAIA,MAAM,aAAa,KAAK,EAAE,YAAY,WAAW,CAAC;AAElD,SAAS,UAAU,MAAwC;AACzD,KAAI,SAAS,QAAQ,SAAS,OAC5B,QAAO,EAAE;CAGX,IAAIA;AACJ,KAAI,OAAO,SAAS,SAClB,KAAI;AACF,WAAS,KAAK,MAAM,KAAK;SACnB;AACN,SAAO,EAAE;;KAGX,UAAS;CAGX,MAAM,SAAS,WAAW,OAAO;AACjC,KAAI,kBAAkB,KAAK,OACzB,QAAO,EAAE;AAGX,QAAO;;AAGT,MAAM,0BAA0B,KAAK;CACnC,WAAW;CACX,cAAc;CACd,kBAAkB;CAClB,sBAAsB;CACtB,eAAe;CACf,YAAY;CACZ,SAAS;CACV,CAAC;;;;;AAMF,SAAgB,uBAAuB,K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