@prisma-next/family-sql 0.3.0-pr.93.5 → 0.3.0-pr.94.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. package/dist/control-adapter.d.mts +47 -0
  2. package/dist/control-adapter.d.mts.map +1 -0
  3. package/dist/control-adapter.mjs +1 -0
  4. package/dist/control.d.mts +65 -0
  5. package/dist/control.d.mts.map +1 -0
  6. package/dist/control.mjs +136 -0
  7. package/dist/control.mjs.map +1 -0
  8. package/dist/instance-B_PdDN4y.mjs +525 -0
  9. package/dist/instance-B_PdDN4y.mjs.map +1 -0
  10. package/dist/instance-wm4TrZN0.d.mts +130 -0
  11. package/dist/instance-wm4TrZN0.d.mts.map +1 -0
  12. package/dist/runtime.d.mts +70 -0
  13. package/dist/runtime.d.mts.map +1 -0
  14. package/dist/runtime.mjs +74 -0
  15. package/dist/runtime.mjs.map +1 -0
  16. package/dist/schema-verify.d.mts +85 -0
  17. package/dist/schema-verify.d.mts.map +1 -0
  18. package/dist/schema-verify.mjs +3 -0
  19. package/dist/test-utils.d.mts +31 -0
  20. package/dist/test-utils.d.mts.map +1 -0
  21. package/dist/test-utils.mjs +5 -0
  22. package/dist/types-D5CPT9N4.d.mts +270 -0
  23. package/dist/types-D5CPT9N4.d.mts.map +1 -0
  24. package/dist/verify-DhFytkFC.mjs +108 -0
  25. package/dist/verify-DhFytkFC.mjs.map +1 -0
  26. package/dist/verify-sql-schema-BnLVoeWI.mjs +686 -0
  27. package/dist/verify-sql-schema-BnLVoeWI.mjs.map +1 -0
  28. package/dist/verify.d.mts +31 -0
  29. package/dist/verify.d.mts.map +1 -0
  30. package/dist/verify.mjs +3 -0
  31. package/package.json +30 -43
  32. package/dist/chunk-F27CR6XZ.js +0 -589
  33. package/dist/chunk-F27CR6XZ.js.map +0 -1
  34. package/dist/chunk-SU7LN2UH.js +0 -96
  35. package/dist/chunk-SU7LN2UH.js.map +0 -1
  36. package/dist/chunk-XH2Y5NTD.js +0 -715
  37. package/dist/chunk-XH2Y5NTD.js.map +0 -1
  38. package/dist/core/assembly.d.ts +0 -25
  39. package/dist/core/assembly.d.ts.map +0 -1
  40. package/dist/core/control-adapter.d.ts +0 -42
  41. package/dist/core/control-adapter.d.ts.map +0 -1
  42. package/dist/core/descriptor.d.ts +0 -24
  43. package/dist/core/descriptor.d.ts.map +0 -1
  44. package/dist/core/instance.d.ts +0 -140
  45. package/dist/core/instance.d.ts.map +0 -1
  46. package/dist/core/migrations/plan-helpers.d.ts +0 -20
  47. package/dist/core/migrations/plan-helpers.d.ts.map +0 -1
  48. package/dist/core/migrations/policies.d.ts +0 -6
  49. package/dist/core/migrations/policies.d.ts.map +0 -1
  50. package/dist/core/migrations/types.d.ts +0 -280
  51. package/dist/core/migrations/types.d.ts.map +0 -1
  52. package/dist/core/runtime-descriptor.d.ts +0 -19
  53. package/dist/core/runtime-descriptor.d.ts.map +0 -1
  54. package/dist/core/runtime-instance.d.ts +0 -54
  55. package/dist/core/runtime-instance.d.ts.map +0 -1
  56. package/dist/core/schema-verify/verify-helpers.d.ts +0 -96
  57. package/dist/core/schema-verify/verify-helpers.d.ts.map +0 -1
  58. package/dist/core/schema-verify/verify-sql-schema.d.ts +0 -45
  59. package/dist/core/schema-verify/verify-sql-schema.d.ts.map +0 -1
  60. package/dist/core/verify.d.ts +0 -39
  61. package/dist/core/verify.d.ts.map +0 -1
  62. package/dist/exports/control-adapter.d.ts +0 -2
  63. package/dist/exports/control-adapter.d.ts.map +0 -1
  64. package/dist/exports/control-adapter.js +0 -1
  65. package/dist/exports/control-adapter.js.map +0 -1
  66. package/dist/exports/control.d.ts +0 -13
  67. package/dist/exports/control.d.ts.map +0 -1
  68. package/dist/exports/control.js +0 -149
  69. package/dist/exports/control.js.map +0 -1
  70. package/dist/exports/runtime.d.ts +0 -8
  71. package/dist/exports/runtime.d.ts.map +0 -1
  72. package/dist/exports/runtime.js +0 -64
  73. package/dist/exports/runtime.js.map +0 -1
  74. package/dist/exports/schema-verify.d.ts +0 -11
  75. package/dist/exports/schema-verify.d.ts.map +0 -1
  76. package/dist/exports/schema-verify.js +0 -15
  77. package/dist/exports/schema-verify.js.map +0 -1
  78. package/dist/exports/test-utils.d.ts +0 -7
  79. package/dist/exports/test-utils.d.ts.map +0 -1
  80. package/dist/exports/test-utils.js +0 -17
  81. package/dist/exports/test-utils.js.map +0 -1
  82. package/dist/exports/verify.d.ts +0 -2
  83. package/dist/exports/verify.d.ts.map +0 -1
  84. package/dist/exports/verify.js +0 -11
  85. package/dist/exports/verify.js.map +0 -1
@@ -1,589 +0,0 @@
1
- import {
2
- collectSupportedCodecTypeIds,
3
- readMarker
4
- } from "./chunk-SU7LN2UH.js";
5
- import {
6
- verifySqlSchema
7
- } from "./chunk-XH2Y5NTD.js";
8
-
9
- // src/core/assembly.ts
10
- import { createOperationRegistry } from "@prisma-next/operations";
11
- function assembleOperationRegistry(descriptors, convertOperationManifest2) {
12
- const registry = createOperationRegistry();
13
- for (const descriptor of descriptors) {
14
- const operations = descriptor.operations ?? [];
15
- for (const operationManifest of operations) {
16
- const signature = convertOperationManifest2(operationManifest);
17
- registry.register(signature);
18
- }
19
- }
20
- return registry;
21
- }
22
- function extractCodecTypeImports(descriptors) {
23
- const imports = [];
24
- for (const descriptor of descriptors) {
25
- const types = descriptor.types;
26
- const codecTypes = types?.codecTypes;
27
- if (codecTypes?.import) {
28
- imports.push(codecTypes.import);
29
- }
30
- }
31
- return imports;
32
- }
33
- function extractOperationTypeImports(descriptors) {
34
- const imports = [];
35
- for (const descriptor of descriptors) {
36
- const types = descriptor.types;
37
- const operationTypes = types?.operationTypes;
38
- if (operationTypes?.import) {
39
- imports.push(operationTypes.import);
40
- }
41
- }
42
- return imports;
43
- }
44
- function extractExtensionIds(adapter, target, extensions) {
45
- const ids = [];
46
- const seen = /* @__PURE__ */ new Set();
47
- if (!seen.has(adapter.id)) {
48
- ids.push(adapter.id);
49
- seen.add(adapter.id);
50
- }
51
- if (!seen.has(target.id)) {
52
- ids.push(target.id);
53
- seen.add(target.id);
54
- }
55
- for (const ext of extensions) {
56
- if (!seen.has(ext.id)) {
57
- ids.push(ext.id);
58
- seen.add(ext.id);
59
- }
60
- }
61
- return ids;
62
- }
63
-
64
- // src/core/instance.ts
65
- import { emit } from "@prisma-next/core-control-plane/emission";
66
- import { sqlTargetFamilyHook } from "@prisma-next/sql-contract-emitter";
67
- import { validateContract } from "@prisma-next/sql-contract-ts/contract";
68
- import {
69
- ensureSchemaStatement,
70
- ensureTableStatement,
71
- writeContractMarker
72
- } from "@prisma-next/sql-runtime";
73
- import { ifDefined } from "@prisma-next/utils/defined";
74
- function convertOperationManifest(manifest) {
75
- return {
76
- forTypeId: manifest.for,
77
- method: manifest.method,
78
- args: manifest.args.map((arg) => {
79
- if (arg.kind === "typeId") {
80
- if (!arg.type) {
81
- throw new Error("typeId arg must have type property");
82
- }
83
- return { kind: "typeId", type: arg.type };
84
- }
85
- if (arg.kind === "param") {
86
- return { kind: "param" };
87
- }
88
- if (arg.kind === "literal") {
89
- return { kind: "literal" };
90
- }
91
- throw new Error(`Invalid arg kind: ${arg.kind}`);
92
- }),
93
- returns: (() => {
94
- if (manifest.returns.kind === "typeId") {
95
- return { kind: "typeId", type: manifest.returns.type };
96
- }
97
- if (manifest.returns.kind === "builtin") {
98
- return {
99
- kind: "builtin",
100
- type: manifest.returns.type
101
- };
102
- }
103
- throw new Error(`Invalid return kind: ${manifest.returns.kind}`);
104
- })(),
105
- lowering: {
106
- targetFamily: "sql",
107
- strategy: manifest.lowering.strategy,
108
- template: manifest.lowering.template
109
- },
110
- ...manifest.capabilities ? { capabilities: manifest.capabilities } : {}
111
- };
112
- }
113
- function extractCodecTypeIdsFromContract(contract) {
114
- const typeIds = /* @__PURE__ */ new Set();
115
- if (typeof contract === "object" && contract !== null && "storage" in contract && typeof contract.storage === "object" && contract.storage !== null && "tables" in contract.storage) {
116
- const storage = contract.storage;
117
- if (storage.tables && typeof storage.tables === "object") {
118
- for (const table of Object.values(storage.tables)) {
119
- if (typeof table === "object" && table !== null && "columns" in table && typeof table.columns === "object" && table.columns !== null) {
120
- const columns = table.columns;
121
- for (const column of Object.values(columns)) {
122
- if (column && typeof column === "object" && "codecId" in column && typeof column.codecId === "string") {
123
- typeIds.add(column.codecId);
124
- }
125
- }
126
- }
127
- }
128
- }
129
- }
130
- return Array.from(typeIds).sort();
131
- }
132
- function createVerifyResult(options) {
133
- const contract = {
134
- coreHash: options.contractCoreHash
135
- };
136
- if (options.contractProfileHash) {
137
- contract.profileHash = options.contractProfileHash;
138
- }
139
- const target = {
140
- expected: options.expectedTargetId
141
- };
142
- if (options.actualTargetId) {
143
- target.actual = options.actualTargetId;
144
- }
145
- const meta = {
146
- contractPath: options.contractPath
147
- };
148
- if (options.configPath) {
149
- meta.configPath = options.configPath;
150
- }
151
- const result = {
152
- ok: options.ok,
153
- summary: options.summary,
154
- contract,
155
- target,
156
- meta,
157
- timings: {
158
- total: options.totalTime
159
- }
160
- };
161
- if (options.code) {
162
- result.code = options.code;
163
- }
164
- if (options.marker) {
165
- result.marker = {
166
- coreHash: options.marker.coreHash,
167
- profileHash: options.marker.profileHash
168
- };
169
- }
170
- if (options.missingCodecs) {
171
- result.missingCodecs = options.missingCodecs;
172
- }
173
- if (options.codecCoverageSkipped) {
174
- result.codecCoverageSkipped = options.codecCoverageSkipped;
175
- }
176
- return result;
177
- }
178
- function isSqlControlAdapter(value) {
179
- return typeof value === "object" && value !== null && "introspect" in value && typeof value.introspect === "function";
180
- }
181
- function buildSqlTypeMetadataRegistry(options) {
182
- const { target, adapter, extensionPacks: extensions } = options;
183
- const registry = /* @__PURE__ */ new Map();
184
- const targetId = adapter.targetId;
185
- const descriptors = [target, adapter, ...extensions];
186
- for (const descriptor of descriptors) {
187
- const types = descriptor.types;
188
- const storageTypes = types?.storage;
189
- if (!storageTypes) {
190
- continue;
191
- }
192
- for (const storageType of storageTypes) {
193
- if (storageType.familyId === "sql" && storageType.targetId === targetId) {
194
- registry.set(storageType.typeId, {
195
- typeId: storageType.typeId,
196
- familyId: "sql",
197
- targetId: storageType.targetId,
198
- ...storageType.nativeType !== void 0 ? { nativeType: storageType.nativeType } : {}
199
- });
200
- }
201
- }
202
- }
203
- return registry;
204
- }
205
- function createSqlFamilyInstance(options) {
206
- const { target, adapter, extensionPacks: extensions = [] } = options;
207
- const descriptors = [target, adapter, ...extensions];
208
- const operationRegistry = assembleOperationRegistry(descriptors, convertOperationManifest);
209
- const codecTypeImports = extractCodecTypeImports(descriptors);
210
- const operationTypeImports = extractOperationTypeImports(descriptors);
211
- const extensionIds = extractExtensionIds(adapter, target, extensions);
212
- const typeMetadataRegistry = buildSqlTypeMetadataRegistry({
213
- target,
214
- adapter,
215
- extensionPacks: extensions
216
- });
217
- function stripMappings(contract) {
218
- if (typeof contract === "object" && contract !== null && "mappings" in contract) {
219
- const { mappings: _mappings, ...contractIR } = contract;
220
- return contractIR;
221
- }
222
- return contract;
223
- }
224
- return {
225
- familyId: "sql",
226
- operationRegistry,
227
- codecTypeImports,
228
- operationTypeImports,
229
- extensionIds,
230
- typeMetadataRegistry,
231
- validateContractIR(contractJson) {
232
- const validated = validateContract(contractJson);
233
- const { mappings: _mappings, ...contractIR } = validated;
234
- return contractIR;
235
- },
236
- async verify(verifyOptions) {
237
- const { driver, contractIR, expectedTargetId, contractPath, configPath } = verifyOptions;
238
- const startTime = Date.now();
239
- if (typeof contractIR !== "object" || contractIR === null || !("coreHash" in contractIR) || !("target" in contractIR) || typeof contractIR.coreHash !== "string" || typeof contractIR.target !== "string") {
240
- throw new Error("Contract is missing required fields: coreHash or target");
241
- }
242
- const contractCoreHash = contractIR.coreHash;
243
- const contractProfileHash = "profileHash" in contractIR && typeof contractIR.profileHash === "string" ? contractIR.profileHash : void 0;
244
- const contractTarget = contractIR.target;
245
- const marker = await readMarker(driver);
246
- let missingCodecs;
247
- let codecCoverageSkipped = false;
248
- const supportedTypeIds = collectSupportedCodecTypeIds([
249
- adapter,
250
- target,
251
- ...extensions
252
- ]);
253
- if (supportedTypeIds.length === 0) {
254
- codecCoverageSkipped = true;
255
- } else {
256
- const supportedSet = new Set(supportedTypeIds);
257
- const usedTypeIds = extractCodecTypeIdsFromContract(contractIR);
258
- const missing = usedTypeIds.filter((id) => !supportedSet.has(id));
259
- if (missing.length > 0) {
260
- missingCodecs = missing;
261
- }
262
- }
263
- if (!marker) {
264
- const totalTime2 = Date.now() - startTime;
265
- return createVerifyResult({
266
- ok: false,
267
- code: "PN-RTM-3001",
268
- summary: "Marker missing",
269
- contractCoreHash,
270
- expectedTargetId,
271
- contractPath,
272
- totalTime: totalTime2,
273
- ...contractProfileHash ? { contractProfileHash } : {},
274
- ...missingCodecs ? { missingCodecs } : {},
275
- ...codecCoverageSkipped ? { codecCoverageSkipped } : {},
276
- ...configPath ? { configPath } : {}
277
- });
278
- }
279
- if (contractTarget !== expectedTargetId) {
280
- const totalTime2 = Date.now() - startTime;
281
- return createVerifyResult({
282
- ok: false,
283
- code: "PN-RTM-3003",
284
- summary: "Target mismatch",
285
- contractCoreHash,
286
- marker,
287
- expectedTargetId,
288
- actualTargetId: contractTarget,
289
- contractPath,
290
- totalTime: totalTime2,
291
- ...contractProfileHash ? { contractProfileHash } : {},
292
- ...missingCodecs ? { missingCodecs } : {},
293
- ...codecCoverageSkipped ? { codecCoverageSkipped } : {},
294
- ...configPath ? { configPath } : {}
295
- });
296
- }
297
- if (marker.coreHash !== contractCoreHash) {
298
- const totalTime2 = Date.now() - startTime;
299
- return createVerifyResult({
300
- ok: false,
301
- code: "PN-RTM-3002",
302
- summary: "Hash mismatch",
303
- contractCoreHash,
304
- marker,
305
- expectedTargetId,
306
- contractPath,
307
- totalTime: totalTime2,
308
- ...contractProfileHash ? { contractProfileHash } : {},
309
- ...missingCodecs ? { missingCodecs } : {},
310
- ...codecCoverageSkipped ? { codecCoverageSkipped } : {},
311
- ...configPath ? { configPath } : {}
312
- });
313
- }
314
- if (contractProfileHash && marker.profileHash !== contractProfileHash) {
315
- const totalTime2 = Date.now() - startTime;
316
- return createVerifyResult({
317
- ok: false,
318
- code: "PN-RTM-3002",
319
- summary: "Hash mismatch",
320
- contractCoreHash,
321
- contractProfileHash,
322
- marker,
323
- expectedTargetId,
324
- contractPath,
325
- totalTime: totalTime2,
326
- ...missingCodecs ? { missingCodecs } : {},
327
- ...codecCoverageSkipped ? { codecCoverageSkipped } : {},
328
- ...configPath ? { configPath } : {}
329
- });
330
- }
331
- const totalTime = Date.now() - startTime;
332
- return createVerifyResult({
333
- ok: true,
334
- summary: "Database matches contract",
335
- contractCoreHash,
336
- marker,
337
- expectedTargetId,
338
- contractPath,
339
- totalTime,
340
- ...contractProfileHash ? { contractProfileHash } : {},
341
- ...missingCodecs ? { missingCodecs } : {},
342
- ...codecCoverageSkipped ? { codecCoverageSkipped } : {},
343
- ...configPath ? { configPath } : {}
344
- });
345
- },
346
- async schemaVerify(options2) {
347
- const { driver, contractIR, strict, context, frameworkComponents } = options2;
348
- const contract = validateContract(contractIR);
349
- const controlAdapter = adapter.create();
350
- if (!isSqlControlAdapter(controlAdapter)) {
351
- throw new Error("Adapter does not implement SqlControlAdapter.introspect()");
352
- }
353
- const schemaIR = await controlAdapter.introspect(driver, contractIR);
354
- return verifySqlSchema({
355
- contract,
356
- schema: schemaIR,
357
- strict,
358
- ...ifDefined("context", context),
359
- typeMetadataRegistry,
360
- frameworkComponents
361
- });
362
- },
363
- async sign(options2) {
364
- const { driver, contractIR, contractPath, configPath } = options2;
365
- const startTime = Date.now();
366
- const contract = validateContract(contractIR);
367
- const contractCoreHash = contract.coreHash;
368
- const contractProfileHash = "profileHash" in contract && typeof contract.profileHash === "string" ? contract.profileHash : contractCoreHash;
369
- const contractTarget = contract.target;
370
- await driver.query(ensureSchemaStatement.sql, ensureSchemaStatement.params);
371
- await driver.query(ensureTableStatement.sql, ensureTableStatement.params);
372
- const existingMarker = await readMarker(driver);
373
- let markerCreated = false;
374
- let markerUpdated = false;
375
- let previousHashes;
376
- if (!existingMarker) {
377
- const write = writeContractMarker({
378
- coreHash: contractCoreHash,
379
- profileHash: contractProfileHash,
380
- contractJson: contractIR,
381
- canonicalVersion: 1
382
- });
383
- await driver.query(write.insert.sql, write.insert.params);
384
- markerCreated = true;
385
- } else {
386
- const existingCoreHash = existingMarker.coreHash;
387
- const existingProfileHash = existingMarker.profileHash;
388
- const coreHashMatches = existingCoreHash === contractCoreHash;
389
- const profileHashMatches = existingProfileHash === contractProfileHash;
390
- if (!coreHashMatches || !profileHashMatches) {
391
- previousHashes = {
392
- coreHash: existingCoreHash,
393
- profileHash: existingProfileHash
394
- };
395
- const write = writeContractMarker({
396
- coreHash: contractCoreHash,
397
- profileHash: contractProfileHash,
398
- contractJson: contractIR,
399
- canonicalVersion: existingMarker.canonicalVersion ?? 1
400
- });
401
- await driver.query(write.update.sql, write.update.params);
402
- markerUpdated = true;
403
- }
404
- }
405
- let summary;
406
- if (markerCreated) {
407
- summary = "Database signed (marker created)";
408
- } else if (markerUpdated) {
409
- summary = `Database signed (marker updated from ${previousHashes?.coreHash ?? "unknown"})`;
410
- } else {
411
- summary = "Database already signed with this contract";
412
- }
413
- const totalTime = Date.now() - startTime;
414
- return {
415
- ok: true,
416
- summary,
417
- contract: {
418
- coreHash: contractCoreHash,
419
- profileHash: contractProfileHash
420
- },
421
- target: {
422
- expected: contractTarget,
423
- actual: contractTarget
424
- },
425
- marker: {
426
- created: markerCreated,
427
- updated: markerUpdated,
428
- ...previousHashes ? { previous: previousHashes } : {}
429
- },
430
- meta: {
431
- contractPath,
432
- ...configPath ? { configPath } : {}
433
- },
434
- timings: {
435
- total: totalTime
436
- }
437
- };
438
- },
439
- async readMarker(options2) {
440
- return readMarker(options2.driver);
441
- },
442
- async introspect(options2) {
443
- const { driver, contractIR } = options2;
444
- const controlAdapter = adapter.create();
445
- if (!isSqlControlAdapter(controlAdapter)) {
446
- throw new Error("Adapter does not implement SqlControlAdapter.introspect()");
447
- }
448
- return controlAdapter.introspect(driver, contractIR);
449
- },
450
- toSchemaView(schema) {
451
- const rootLabel = "contract";
452
- const tableNodes = Object.entries(schema.tables).map(
453
- ([tableName, table]) => {
454
- const children = [];
455
- const columnNodes = [];
456
- for (const [columnName, column] of Object.entries(table.columns)) {
457
- const nullableText = column.nullable ? "(nullable)" : "(not nullable)";
458
- const typeDisplay = column.nativeType;
459
- const label = `${columnName}: ${typeDisplay} ${nullableText}`;
460
- columnNodes.push({
461
- kind: "field",
462
- id: `column-${tableName}-${columnName}`,
463
- label,
464
- meta: {
465
- nativeType: column.nativeType,
466
- nullable: column.nullable
467
- }
468
- });
469
- }
470
- if (columnNodes.length > 0) {
471
- children.push({
472
- kind: "collection",
473
- id: `columns-${tableName}`,
474
- label: "columns",
475
- children: columnNodes
476
- });
477
- }
478
- if (table.primaryKey) {
479
- const pkColumns = table.primaryKey.columns.join(", ");
480
- children.push({
481
- kind: "index",
482
- id: `primary-key-${tableName}`,
483
- label: `primary key: ${pkColumns}`,
484
- meta: {
485
- columns: table.primaryKey.columns,
486
- ...table.primaryKey.name ? { name: table.primaryKey.name } : {}
487
- }
488
- });
489
- }
490
- for (const unique of table.uniques) {
491
- const name = unique.name ?? `${tableName}_${unique.columns.join("_")}_unique`;
492
- const label = `unique ${name}`;
493
- children.push({
494
- kind: "index",
495
- id: `unique-${tableName}-${name}`,
496
- label,
497
- meta: {
498
- columns: unique.columns,
499
- unique: true
500
- }
501
- });
502
- }
503
- for (const index of table.indexes) {
504
- const name = index.name ?? `${tableName}_${index.columns.join("_")}_idx`;
505
- const label = index.unique ? `unique index ${name}` : `index ${name}`;
506
- children.push({
507
- kind: "index",
508
- id: `index-${tableName}-${name}`,
509
- label,
510
- meta: {
511
- columns: index.columns,
512
- unique: index.unique
513
- }
514
- });
515
- }
516
- const tableMeta = {};
517
- if (table.primaryKey) {
518
- tableMeta["primaryKey"] = table.primaryKey.columns;
519
- if (table.primaryKey.name) {
520
- tableMeta["primaryKeyName"] = table.primaryKey.name;
521
- }
522
- }
523
- if (table.foreignKeys.length > 0) {
524
- tableMeta["foreignKeys"] = table.foreignKeys.map((fk) => ({
525
- columns: fk.columns,
526
- referencedTable: fk.referencedTable,
527
- referencedColumns: fk.referencedColumns,
528
- ...fk.name ? { name: fk.name } : {}
529
- }));
530
- }
531
- const node = {
532
- kind: "entity",
533
- id: `table-${tableName}`,
534
- label: `table ${tableName}`,
535
- ...Object.keys(tableMeta).length > 0 ? { meta: tableMeta } : {},
536
- ...children.length > 0 ? { children } : {}
537
- };
538
- return node;
539
- }
540
- );
541
- const extensionNodes = schema.extensions.map((extName) => ({
542
- kind: "extension",
543
- id: `extension-${extName}`,
544
- label: `${extName} extension is enabled`
545
- }));
546
- const rootChildren = [...tableNodes, ...extensionNodes];
547
- const rootNode = {
548
- kind: "root",
549
- id: "sql-schema",
550
- label: rootLabel,
551
- ...rootChildren.length > 0 ? { children: rootChildren } : {}
552
- };
553
- return {
554
- root: rootNode
555
- };
556
- },
557
- async emitContract({ contractIR }) {
558
- const contractWithoutMappings = stripMappings(contractIR);
559
- const validatedIR = this.validateContractIR(contractWithoutMappings);
560
- const result = await emit(
561
- validatedIR,
562
- {
563
- outputDir: "",
564
- operationRegistry,
565
- codecTypeImports,
566
- operationTypeImports,
567
- extensionIds
568
- },
569
- sqlTargetFamilyHook
570
- );
571
- return {
572
- contractJson: result.contractJson,
573
- contractDts: result.contractDts,
574
- coreHash: result.coreHash,
575
- profileHash: result.profileHash
576
- };
577
- }
578
- };
579
- }
580
-
581
- export {
582
- assembleOperationRegistry,
583
- extractCodecTypeImports,
584
- extractOperationTypeImports,
585
- extractExtensionIds,
586
- convertOperationManifest,
587
- createSqlFamilyInstance
588
- };
589
- //# sourceMappingURL=chunk-F27CR6XZ.js.map