@prisma-next/emitter 0.3.0-dev.45 → 0.3.0-dev.47
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/package.json +5 -5
- package/test/canonicalization.test.ts +5 -4
- package/test/emitter.test.ts +56 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/emitter",
|
|
3
|
-
"version": "0.3.0-dev.
|
|
3
|
+
"version": "0.3.0-dev.47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"files": [
|
|
@@ -10,17 +10,17 @@
|
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"arktype": "^2.0.0",
|
|
13
|
-
"@prisma-next/
|
|
14
|
-
"@prisma-next/
|
|
13
|
+
"@prisma-next/contract": "0.3.0-dev.47",
|
|
14
|
+
"@prisma-next/core-control-plane": "0.3.0-dev.47"
|
|
15
15
|
},
|
|
16
16
|
"devDependencies": {
|
|
17
17
|
"@types/node": "24.10.4",
|
|
18
18
|
"tsdown": "0.18.4",
|
|
19
19
|
"typescript": "5.9.3",
|
|
20
20
|
"vitest": "4.0.17",
|
|
21
|
-
"@prisma-next/operations": "0.3.0-dev.
|
|
22
|
-
"@prisma-next/tsconfig": "0.0.0",
|
|
21
|
+
"@prisma-next/operations": "0.3.0-dev.47",
|
|
23
22
|
"@prisma-next/test-utils": "0.0.1",
|
|
23
|
+
"@prisma-next/tsconfig": "0.0.0",
|
|
24
24
|
"@prisma-next/tsdown": "0.0.0"
|
|
25
25
|
},
|
|
26
26
|
"exports": {
|
|
@@ -6,7 +6,7 @@ describe('canonicalization', () => {
|
|
|
6
6
|
it('orders top-level sections correctly', () => {
|
|
7
7
|
const ir = createContractIR({
|
|
8
8
|
capabilities: { postgres: { jsonAgg: true } },
|
|
9
|
-
meta: {
|
|
9
|
+
meta: { emitterVersion: 'test' },
|
|
10
10
|
});
|
|
11
11
|
|
|
12
12
|
const result = canonicalizeContract(ir);
|
|
@@ -17,6 +17,7 @@ describe('canonicalization', () => {
|
|
|
17
17
|
const targetFamilyIndex = keys.indexOf('targetFamily');
|
|
18
18
|
const targetIndex = keys.indexOf('target');
|
|
19
19
|
const modelsIndex = keys.indexOf('models');
|
|
20
|
+
const relationsIndex = keys.indexOf('relations');
|
|
20
21
|
const storageIndex = keys.indexOf('storage');
|
|
21
22
|
const capabilitiesIndex = keys.indexOf('capabilities');
|
|
22
23
|
const metaIndex = keys.indexOf('meta');
|
|
@@ -24,6 +25,8 @@ describe('canonicalization', () => {
|
|
|
24
25
|
expect(schemaVersionIndex).toBeLessThan(targetFamilyIndex);
|
|
25
26
|
expect(targetFamilyIndex).toBeLessThan(targetIndex);
|
|
26
27
|
expect(targetIndex).toBeLessThan(modelsIndex);
|
|
28
|
+
expect(modelsIndex).toBeLessThan(relationsIndex);
|
|
29
|
+
expect(relationsIndex).toBeLessThan(storageIndex);
|
|
27
30
|
expect(modelsIndex).toBeLessThan(storageIndex);
|
|
28
31
|
expect(storageIndex).toBeLessThan(capabilitiesIndex);
|
|
29
32
|
expect(capabilitiesIndex).toBeLessThan(metaIndex);
|
|
@@ -133,14 +136,12 @@ describe('canonicalization', () => {
|
|
|
133
136
|
tables: expect.anything(),
|
|
134
137
|
},
|
|
135
138
|
});
|
|
136
|
-
// Required top-level fields (capabilities, extensionPacks, meta, relations
|
|
137
|
-
// because they are required by ContractIR and needed for round-trip tests
|
|
139
|
+
// Required top-level fields (capabilities, extensionPacks, meta, relations) are preserved even when empty.
|
|
138
140
|
expect(parsed).toMatchObject({
|
|
139
141
|
capabilities: expect.anything(),
|
|
140
142
|
extensionPacks: expect.anything(),
|
|
141
143
|
meta: expect.anything(),
|
|
142
144
|
relations: expect.anything(),
|
|
143
|
-
sources: expect.anything(),
|
|
144
145
|
});
|
|
145
146
|
});
|
|
146
147
|
|
package/test/emitter.test.ts
CHANGED
|
@@ -572,10 +572,12 @@ describe('emitter', () => {
|
|
|
572
572
|
await expect(emit(ir, options, mockSqlHook)).rejects.toThrow('ContractIR must have meta');
|
|
573
573
|
});
|
|
574
574
|
|
|
575
|
-
it('
|
|
575
|
+
it('omits sources from emitted contract artifact', async () => {
|
|
576
576
|
const ir = createContractIR({
|
|
577
|
-
sources:
|
|
578
|
-
|
|
577
|
+
sources: {
|
|
578
|
+
schema: { sourceId: 'schema.prisma' },
|
|
579
|
+
},
|
|
580
|
+
});
|
|
579
581
|
|
|
580
582
|
const operationRegistry = createOperationRegistry();
|
|
581
583
|
const options: EmitOptions = {
|
|
@@ -586,24 +588,68 @@ describe('emitter', () => {
|
|
|
586
588
|
extensionIds: [],
|
|
587
589
|
};
|
|
588
590
|
|
|
589
|
-
await
|
|
591
|
+
const result = await emit(ir, options, mockSqlHook);
|
|
592
|
+
const contractJson = JSON.parse(result.contractJson) as Record<string, unknown>;
|
|
593
|
+
expect(contractJson).not.toHaveProperty('sources');
|
|
590
594
|
});
|
|
591
595
|
|
|
592
|
-
it('
|
|
596
|
+
it('accepts meta keys when family validation allows them', async () => {
|
|
593
597
|
const ir = createContractIR({
|
|
594
|
-
|
|
595
|
-
|
|
598
|
+
meta: {
|
|
599
|
+
sourceId: 'schema.prisma',
|
|
600
|
+
schemaPath: '/tmp/schema.prisma',
|
|
601
|
+
source: 'psl',
|
|
602
|
+
},
|
|
603
|
+
});
|
|
596
604
|
|
|
597
|
-
const operationRegistry = createOperationRegistry();
|
|
598
605
|
const options: EmitOptions = {
|
|
599
606
|
outputDir: '',
|
|
600
|
-
operationRegistry,
|
|
607
|
+
operationRegistry: createOperationRegistry(),
|
|
601
608
|
codecTypeImports: [],
|
|
602
609
|
operationTypeImports: [],
|
|
603
610
|
extensionIds: [],
|
|
604
611
|
};
|
|
605
612
|
|
|
606
|
-
await expect(emit(ir, options, mockSqlHook)).
|
|
613
|
+
await expect(emit(ir, options, mockSqlHook)).resolves.toMatchObject({
|
|
614
|
+
contractJson: expect.any(String),
|
|
615
|
+
contractDts: expect.any(String),
|
|
616
|
+
});
|
|
617
|
+
});
|
|
618
|
+
|
|
619
|
+
it('accepts canonical section keys when family validation allows them', async () => {
|
|
620
|
+
const ir = createContractIR({
|
|
621
|
+
storage: {
|
|
622
|
+
tables: {
|
|
623
|
+
user: {
|
|
624
|
+
columns: {
|
|
625
|
+
id: {
|
|
626
|
+
codecId: 'pg/int4@1',
|
|
627
|
+
nativeType: 'int4',
|
|
628
|
+
nullable: false,
|
|
629
|
+
sourceId: 'schema.prisma',
|
|
630
|
+
},
|
|
631
|
+
},
|
|
632
|
+
primaryKey: { columns: ['id'] },
|
|
633
|
+
uniques: [],
|
|
634
|
+
indexes: [],
|
|
635
|
+
foreignKeys: [],
|
|
636
|
+
},
|
|
637
|
+
},
|
|
638
|
+
} as unknown as Record<string, unknown>,
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
const options: EmitOptions = {
|
|
642
|
+
outputDir: '',
|
|
643
|
+
operationRegistry: createOperationRegistry(),
|
|
644
|
+
codecTypeImports: [],
|
|
645
|
+
operationTypeImports: [],
|
|
646
|
+
extensionIds: [],
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
await expect(emit(ir, options, mockSqlHook)).resolves.toMatchObject({
|
|
650
|
+
contractJson: expect.any(String),
|
|
651
|
+
contractDts: expect.any(String),
|
|
652
|
+
});
|
|
607
653
|
});
|
|
608
654
|
|
|
609
655
|
it('emits contract even when extensionIds are not in contract.extensionPacks', async () => {
|