@prisma-next/framework-components 0.5.0-dev.26 → 0.5.0-dev.28
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/authoring.d.mts +1 -1
- package/dist/authoring.mjs +1 -1
- package/dist/authoring.mjs.map +1 -1
- package/dist/{codec-types-DQ1Agjom.d.mts → codec-types-Csp_4QDg.d.mts} +2 -2
- package/dist/codec-types-Csp_4QDg.d.mts.map +1 -0
- package/dist/codec.d.mts +1 -1
- package/dist/codec.mjs +1 -1
- package/dist/codec.mjs.map +1 -1
- package/dist/components.d.mts +1 -1
- package/dist/components.mjs +1 -1
- package/dist/control.d.mts +63 -21
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +11 -5
- package/dist/control.mjs.map +1 -1
- package/dist/{emission-types-BPAALJbF.d.mts → emission-types-D234HxUz.d.mts} +3 -3
- package/dist/emission-types-D234HxUz.d.mts.map +1 -0
- package/dist/emission.d.mts +2 -2
- package/dist/execution.d.mts +5 -5
- package/dist/execution.d.mts.map +1 -1
- package/dist/execution.mjs +3 -3
- package/dist/execution.mjs.map +1 -1
- package/dist/{framework-authoring-D1-JZ37B.d.mts → framework-authoring-BdrFDx4x.d.mts} +2 -2
- package/dist/framework-authoring-BdrFDx4x.d.mts.map +1 -0
- package/dist/{framework-components-C8ZhSwXe.mjs → framework-components-BsWST1Rn.mjs} +2 -2
- package/dist/framework-components-BsWST1Rn.mjs.map +1 -0
- package/dist/{framework-components-DFZMi2h7.d.mts → framework-components-XYjBYPoB.d.mts} +6 -6
- package/dist/framework-components-XYjBYPoB.d.mts.map +1 -0
- package/dist/psl-ast-9X5rwo98.d.mts +159 -0
- package/dist/psl-ast-9X5rwo98.d.mts.map +1 -0
- package/dist/psl-ast.d.mts +2 -0
- package/dist/psl-ast.mjs +1 -0
- package/dist/runtime.d.mts +6 -6
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +5 -5
- package/dist/runtime.mjs.map +1 -1
- package/dist/{types-import-spec-C4sc7wbb.d.mts → types-import-spec-D-O6GotH.d.mts} +2 -2
- package/dist/types-import-spec-D-O6GotH.d.mts.map +1 -0
- package/package.json +5 -4
- package/src/control/control-capabilities.ts +71 -0
- package/src/{control-descriptors.ts → control/control-descriptors.ts} +7 -7
- package/src/{control-instances.ts → control/control-instances.ts} +6 -6
- package/src/{control-migration-types.ts → control/control-migration-types.ts} +10 -9
- package/src/control/control-operation-preview.ts +23 -0
- package/src/{control-stack.ts → control/control-stack.ts} +13 -13
- package/src/{emission-types.ts → control/emission-types.ts} +1 -1
- package/src/control/psl-ast.ts +193 -0
- package/src/{execution-descriptors.ts → execution/execution-descriptors.ts} +7 -7
- package/src/{execution-instances.ts → execution/execution-instances.ts} +1 -1
- package/src/{execution-requirements.ts → execution/execution-requirements.ts} +1 -1
- package/src/exports/authoring.ts +2 -2
- package/src/exports/codec.ts +2 -2
- package/src/exports/components.ts +2 -2
- package/src/exports/control.ts +26 -12
- package/src/exports/emission.ts +2 -2
- package/src/exports/execution.ts +5 -5
- package/src/exports/psl-ast.ts +1 -0
- package/src/exports/runtime.ts +9 -9
- package/dist/codec-types-DQ1Agjom.d.mts.map +0 -1
- package/dist/emission-types-BPAALJbF.d.mts.map +0 -1
- package/dist/framework-authoring-D1-JZ37B.d.mts.map +0 -1
- package/dist/framework-components-C8ZhSwXe.mjs.map +0 -1
- package/dist/framework-components-DFZMi2h7.d.mts.map +0 -1
- package/dist/types-import-spec-C4sc7wbb.d.mts.map +0 -1
- package/src/control-capabilities.ts +0 -34
- /package/src/{control-result-types.ts → control/control-result-types.ts} +0 -0
- /package/src/{control-schema-view.ts → control/control-schema-view.ts} +0 -0
- /package/src/{async-iterable-result.ts → execution/async-iterable-result.ts} +0 -0
- /package/src/{execution-stack.ts → execution/execution-stack.ts} +0 -0
- /package/src/{query-plan.ts → execution/query-plan.ts} +0 -0
- /package/src/{run-with-middleware.ts → execution/run-with-middleware.ts} +0 -0
- /package/src/{runtime-core.ts → execution/runtime-core.ts} +0 -0
- /package/src/{runtime-error.ts → execution/runtime-error.ts} +0 -0
- /package/src/{runtime-middleware.ts → execution/runtime-middleware.ts} +0 -0
- /package/src/{codec-types.ts → shared/codec-types.ts} +0 -0
- /package/src/{framework-authoring.ts → shared/framework-authoring.ts} +0 -0
- /package/src/{framework-components.ts → shared/framework-components.ts} +0 -0
- /package/src/{mutation-default-types.ts → shared/mutation-default-types.ts} +0 -0
- /package/src/{types-import-spec.ts → shared/types-import-spec.ts} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
//#region src/types-import-spec.d.ts
|
|
1
|
+
//#region src/shared/types-import-spec.d.ts
|
|
2
2
|
/**
|
|
3
3
|
* Specifies how to import TypeScript types from a package.
|
|
4
4
|
* Used in extension pack manifests to declare codec and operation type imports.
|
|
@@ -10,4 +10,4 @@ interface TypesImportSpec {
|
|
|
10
10
|
}
|
|
11
11
|
//#endregion
|
|
12
12
|
export { TypesImportSpec as t };
|
|
13
|
-
//# sourceMappingURL=types-import-spec-
|
|
13
|
+
//# sourceMappingURL=types-import-spec-D-O6GotH.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-import-spec-D-O6GotH.d.mts","names":[],"sources":["../src/shared/types-import-spec.ts"],"sourcesContent":[],"mappings":";;AAIA;;;UAAiB,eAAA"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/framework-components",
|
|
3
|
-
"version": "0.5.0-dev.
|
|
3
|
+
"version": "0.5.0-dev.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"description": "Framework component types, assembly logic, and stack creation for Prisma Next",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@prisma-next/
|
|
9
|
-
"@prisma-next/
|
|
10
|
-
"@prisma-next/
|
|
8
|
+
"@prisma-next/operations": "0.5.0-dev.28",
|
|
9
|
+
"@prisma-next/utils": "0.5.0-dev.28",
|
|
10
|
+
"@prisma-next/contract": "0.5.0-dev.28"
|
|
11
11
|
},
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"tsdown": "0.18.4",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"./control": "./dist/control.mjs",
|
|
28
28
|
"./emission": "./dist/emission.mjs",
|
|
29
29
|
"./execution": "./dist/execution.mjs",
|
|
30
|
+
"./psl-ast": "./dist/psl-ast.mjs",
|
|
30
31
|
"./runtime": "./dist/runtime.mjs",
|
|
31
32
|
"./package.json": "./package.json"
|
|
32
33
|
},
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import type { ControlTargetDescriptor } from './control-descriptors';
|
|
2
|
+
import type { ControlFamilyInstance } from './control-instances';
|
|
3
|
+
import type { MigrationPlanOperation, TargetMigrationsCapability } from './control-migration-types';
|
|
4
|
+
import type { OperationPreview } from './control-operation-preview';
|
|
5
|
+
import type { CoreSchemaView } from './control-schema-view';
|
|
6
|
+
import type { PslDocumentAst } from './psl-ast';
|
|
7
|
+
|
|
8
|
+
export interface MigratableTargetDescriptor<
|
|
9
|
+
TFamilyId extends string,
|
|
10
|
+
TTargetId extends string,
|
|
11
|
+
TFamilyInstance extends ControlFamilyInstance<TFamilyId, unknown> = ControlFamilyInstance<
|
|
12
|
+
TFamilyId,
|
|
13
|
+
unknown
|
|
14
|
+
>,
|
|
15
|
+
> extends ControlTargetDescriptor<TFamilyId, TTargetId> {
|
|
16
|
+
readonly migrations: TargetMigrationsCapability<TFamilyId, TTargetId, TFamilyInstance>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function hasMigrations<TFamilyId extends string, TTargetId extends string>(
|
|
20
|
+
target: ControlTargetDescriptor<TFamilyId, TTargetId>,
|
|
21
|
+
): target is MigratableTargetDescriptor<TFamilyId, TTargetId> {
|
|
22
|
+
return 'migrations' in target && !!(target as Record<string, unknown>)['migrations'];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface SchemaViewCapable<TSchemaIR = unknown> {
|
|
26
|
+
toSchemaView(schema: TSchemaIR): CoreSchemaView;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export function hasSchemaView<TFamilyId extends string, TSchemaIR>(
|
|
30
|
+
instance: ControlFamilyInstance<TFamilyId, TSchemaIR>,
|
|
31
|
+
): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & SchemaViewCapable<TSchemaIR> {
|
|
32
|
+
return (
|
|
33
|
+
'toSchemaView' in instance &&
|
|
34
|
+
typeof (instance as Record<string, unknown>)['toSchemaView'] === 'function'
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Capability declaring that a family can infer a PSL contract AST from its
|
|
40
|
+
* opaque introspected schema IR. Consumed by `prisma-next contract infer`.
|
|
41
|
+
*/
|
|
42
|
+
export interface PslContractInferCapable<TSchemaIR = unknown> {
|
|
43
|
+
inferPslContract(schemaIR: TSchemaIR): PslDocumentAst;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export function hasPslContractInfer<TFamilyId extends string, TSchemaIR>(
|
|
47
|
+
instance: ControlFamilyInstance<TFamilyId, TSchemaIR>,
|
|
48
|
+
): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & PslContractInferCapable<TSchemaIR> {
|
|
49
|
+
return (
|
|
50
|
+
'inferPslContract' in instance &&
|
|
51
|
+
typeof (instance as Record<string, unknown>)['inferPslContract'] === 'function'
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Capability declaring that a family can render a textual preview of migration
|
|
57
|
+
* operations for the CLI's "DDL preview" output. SQL families emit
|
|
58
|
+
* `language: 'sql'` statements; Mongo families emit `language: 'mongodb-shell'`.
|
|
59
|
+
*/
|
|
60
|
+
export interface OperationPreviewCapable {
|
|
61
|
+
toOperationPreview(operations: readonly MigrationPlanOperation[]): OperationPreview;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export function hasOperationPreview<TFamilyId extends string, TSchemaIR>(
|
|
65
|
+
instance: ControlFamilyInstance<TFamilyId, TSchemaIR>,
|
|
66
|
+
): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & OperationPreviewCapable {
|
|
67
|
+
return (
|
|
68
|
+
'toOperationPreview' in instance &&
|
|
69
|
+
typeof (instance as Record<string, unknown>)['toOperationPreview'] === 'function'
|
|
70
|
+
);
|
|
71
|
+
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AdapterDescriptor,
|
|
3
|
+
DriverDescriptor,
|
|
4
|
+
ExtensionDescriptor,
|
|
5
|
+
FamilyDescriptor,
|
|
6
|
+
TargetDescriptor,
|
|
7
|
+
} from '../shared/framework-components';
|
|
1
8
|
import type {
|
|
2
9
|
ControlAdapterInstance,
|
|
3
10
|
ControlDriverInstance,
|
|
@@ -7,13 +14,6 @@ import type {
|
|
|
7
14
|
} from './control-instances';
|
|
8
15
|
import type { ControlStack } from './control-stack';
|
|
9
16
|
import type { EmissionSpi } from './emission-types';
|
|
10
|
-
import type {
|
|
11
|
-
AdapterDescriptor,
|
|
12
|
-
DriverDescriptor,
|
|
13
|
-
ExtensionDescriptor,
|
|
14
|
-
FamilyDescriptor,
|
|
15
|
-
TargetDescriptor,
|
|
16
|
-
} from './framework-components';
|
|
17
17
|
|
|
18
18
|
export interface ControlFamilyDescriptor<
|
|
19
19
|
TFamilyId extends string,
|
|
@@ -1,9 +1,4 @@
|
|
|
1
1
|
import type { Contract, ContractMarkerRecord } from '@prisma-next/contract/types';
|
|
2
|
-
import type {
|
|
3
|
-
SignDatabaseResult,
|
|
4
|
-
VerifyDatabaseResult,
|
|
5
|
-
VerifyDatabaseSchemaResult,
|
|
6
|
-
} from './control-result-types';
|
|
7
2
|
import type {
|
|
8
3
|
AdapterInstance,
|
|
9
4
|
DriverInstance,
|
|
@@ -11,7 +6,12 @@ import type {
|
|
|
11
6
|
FamilyInstance,
|
|
12
7
|
TargetBoundComponentDescriptor,
|
|
13
8
|
TargetInstance,
|
|
14
|
-
} from '
|
|
9
|
+
} from '../shared/framework-components';
|
|
10
|
+
import type {
|
|
11
|
+
SignDatabaseResult,
|
|
12
|
+
VerifyDatabaseResult,
|
|
13
|
+
VerifyDatabaseSchemaResult,
|
|
14
|
+
} from './control-result-types';
|
|
15
15
|
|
|
16
16
|
export interface ControlFamilyInstance<TFamilyId extends string, TSchemaIR>
|
|
17
17
|
extends FamilyInstance<TFamilyId> {
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
|
|
12
12
|
import type { Contract } from '@prisma-next/contract/types';
|
|
13
13
|
import type { Result } from '@prisma-next/utils/result';
|
|
14
|
+
import type { TargetBoundComponentDescriptor } from '../shared/framework-components';
|
|
14
15
|
import type { ControlDriverInstance, ControlFamilyInstance } from './control-instances';
|
|
15
|
-
import type { TargetBoundComponentDescriptor } from './framework-components';
|
|
16
16
|
|
|
17
17
|
// ============================================================================
|
|
18
18
|
// Operation Classes and Policy
|
|
@@ -292,11 +292,11 @@ export interface MigrationPlanner<
|
|
|
292
292
|
readonly policy: MigrationOperationPolicy;
|
|
293
293
|
/**
|
|
294
294
|
* Storage hash of the "from" contract (the state the planner assumes the
|
|
295
|
-
* database starts at)
|
|
296
|
-
*
|
|
297
|
-
* metadata.
|
|
295
|
+
* database starts at), or `null` for a baseline plan with no prior state.
|
|
296
|
+
* Planners use this to populate `describe()` on the produced plan so the
|
|
297
|
+
* rendered `migration.ts` has correct `from`/`to` metadata.
|
|
298
298
|
*/
|
|
299
|
-
readonly fromHash: string;
|
|
299
|
+
readonly fromHash: string | null;
|
|
300
300
|
/**
|
|
301
301
|
* The "from" contract (the state the planner assumes the database starts
|
|
302
302
|
* at). Planners pass this to data-safety strategies so they can compare
|
|
@@ -425,11 +425,12 @@ export interface MigrationScaffoldContext {
|
|
|
425
425
|
/** Absolute path to the contract.json file, if one exists. Used by targets that emit typed-contract imports. */
|
|
426
426
|
readonly contractJsonPath?: string;
|
|
427
427
|
/**
|
|
428
|
-
* Storage hash of the "from" contract
|
|
429
|
-
* `describe()` on the
|
|
430
|
-
* is correctly
|
|
428
|
+
* Storage hash of the "from" contract, or `null` for a baseline scaffold
|
|
429
|
+
* with no prior state. Targets use this to populate `describe()` on the
|
|
430
|
+
* rendered empty migration so that identity metadata is correctly
|
|
431
|
+
* populated.
|
|
431
432
|
*/
|
|
432
|
-
readonly fromHash: string;
|
|
433
|
+
readonly fromHash: string | null;
|
|
433
434
|
/**
|
|
434
435
|
* Storage hash of the "to" contract. Same purpose as `fromHash` — threaded
|
|
435
436
|
* through so the rendered class's `describe()` declares the correct
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Family-agnostic textual preview of a migration plan, used by the CLI to
|
|
3
|
+
* render a "DDL preview" section for `db init` / `db update` / `migration plan`
|
|
4
|
+
* / `migration show`. Each statement carries a free-form `language` tag so
|
|
5
|
+
* formatters can suffix `;` for SQL but render Mongo shell lines verbatim.
|
|
6
|
+
*
|
|
7
|
+
* Producers are family-specific: SQL emits `language: 'sql'` (existing DDL
|
|
8
|
+
* extraction); Mongo emits `language: 'mongodb-shell'` via the
|
|
9
|
+
* `MongoDdlCommandFormatter` visitor.
|
|
10
|
+
*
|
|
11
|
+
* The capability `OperationPreviewCapable` (declared in
|
|
12
|
+
* `./control-capabilities`) is how a family announces it can produce these.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export interface OperationPreviewStatement {
|
|
16
|
+
readonly text: string;
|
|
17
|
+
/** Dialect identifier, e.g. `'sql'`, `'mongodb-shell'`. Free-form by design (OQ-3). */
|
|
18
|
+
readonly language: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface OperationPreview {
|
|
22
|
+
readonly statements: readonly OperationPreviewStatement[];
|
|
23
|
+
}
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import type { CodecLookup } from '
|
|
2
|
-
import type {
|
|
3
|
-
ControlAdapterDescriptor,
|
|
4
|
-
ControlDriverDescriptor,
|
|
5
|
-
ControlExtensionDescriptor,
|
|
6
|
-
ControlFamilyDescriptor,
|
|
7
|
-
ControlTargetDescriptor,
|
|
8
|
-
} from './control-descriptors';
|
|
1
|
+
import type { CodecLookup } from '../shared/codec-types';
|
|
9
2
|
import type {
|
|
10
3
|
AuthoringContributions,
|
|
11
4
|
AuthoringFieldNamespace,
|
|
12
5
|
AuthoringFieldPresetDescriptor,
|
|
13
6
|
AuthoringTypeConstructorDescriptor,
|
|
14
7
|
AuthoringTypeNamespace,
|
|
15
|
-
} from '
|
|
16
|
-
import type { ComponentMetadata } from '
|
|
8
|
+
} from '../shared/framework-authoring';
|
|
9
|
+
import type { ComponentMetadata } from '../shared/framework-components';
|
|
17
10
|
import type {
|
|
18
11
|
ControlMutationDefaultEntry,
|
|
19
12
|
ControlMutationDefaults,
|
|
20
13
|
MutationDefaultGeneratorDescriptor,
|
|
21
|
-
} from '
|
|
22
|
-
import type { TypesImportSpec } from '
|
|
14
|
+
} from '../shared/mutation-default-types';
|
|
15
|
+
import type { TypesImportSpec } from '../shared/types-import-spec';
|
|
16
|
+
import type {
|
|
17
|
+
ControlAdapterDescriptor,
|
|
18
|
+
ControlDriverDescriptor,
|
|
19
|
+
ControlExtensionDescriptor,
|
|
20
|
+
ControlFamilyDescriptor,
|
|
21
|
+
ControlTargetDescriptor,
|
|
22
|
+
} from './control-descriptors';
|
|
23
23
|
|
|
24
24
|
export interface AssembledAuthoringContributions {
|
|
25
25
|
readonly field: AuthoringFieldNamespace;
|
|
@@ -328,7 +328,7 @@ export function assembleControlMutationDefaults(
|
|
|
328
328
|
export function extractCodecLookup(
|
|
329
329
|
descriptors: ReadonlyArray<Pick<ComponentMetadata & { id?: string }, 'types' | 'id'>>,
|
|
330
330
|
): CodecLookup {
|
|
331
|
-
const byId = new Map<string, import('
|
|
331
|
+
const byId = new Map<string, import('../shared/codec-types').Codec>();
|
|
332
332
|
const owners = new Map<string, string>();
|
|
333
333
|
for (const descriptor of descriptors) {
|
|
334
334
|
const codecInstances = descriptor.types?.codecTypes?.codecInstances;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Contract, ContractModel } from '@prisma-next/contract/types';
|
|
2
|
-
import type { TypesImportSpec } from '
|
|
2
|
+
import type { TypesImportSpec } from '../shared/types-import-spec';
|
|
3
3
|
|
|
4
4
|
export interface GenerateContractTypesOptions {
|
|
5
5
|
readonly queryOperationTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
export interface PslPosition {
|
|
2
|
+
readonly offset: number;
|
|
3
|
+
readonly line: number;
|
|
4
|
+
readonly column: number;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export interface PslSpan {
|
|
8
|
+
readonly start: PslPosition;
|
|
9
|
+
readonly end: PslPosition;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export type PslDiagnosticCode =
|
|
13
|
+
| 'PSL_UNTERMINATED_BLOCK'
|
|
14
|
+
| 'PSL_UNSUPPORTED_TOP_LEVEL_BLOCK'
|
|
15
|
+
| 'PSL_INVALID_ATTRIBUTE_SYNTAX'
|
|
16
|
+
| 'PSL_INVALID_MODEL_MEMBER'
|
|
17
|
+
| 'PSL_UNSUPPORTED_MODEL_ATTRIBUTE'
|
|
18
|
+
| 'PSL_UNSUPPORTED_FIELD_ATTRIBUTE'
|
|
19
|
+
| 'PSL_INVALID_RELATION_ATTRIBUTE'
|
|
20
|
+
| 'PSL_INVALID_REFERENTIAL_ACTION'
|
|
21
|
+
| 'PSL_INVALID_DEFAULT_VALUE'
|
|
22
|
+
| 'PSL_INVALID_ENUM_MEMBER'
|
|
23
|
+
| 'PSL_INVALID_TYPES_MEMBER';
|
|
24
|
+
|
|
25
|
+
export interface PslDiagnostic {
|
|
26
|
+
readonly code: PslDiagnosticCode;
|
|
27
|
+
readonly message: string;
|
|
28
|
+
readonly sourceId: string;
|
|
29
|
+
readonly span: PslSpan;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface PslDefaultFunctionValue {
|
|
33
|
+
readonly kind: 'function';
|
|
34
|
+
readonly name: 'autoincrement' | 'now';
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface PslDefaultLiteralValue {
|
|
38
|
+
readonly kind: 'literal';
|
|
39
|
+
readonly value: string | number | boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type PslDefaultValue = PslDefaultFunctionValue | PslDefaultLiteralValue;
|
|
43
|
+
|
|
44
|
+
export type PslAttributeTarget = 'field' | 'model' | 'enum' | 'namedType';
|
|
45
|
+
|
|
46
|
+
export interface PslAttributePositionalArgument {
|
|
47
|
+
readonly kind: 'positional';
|
|
48
|
+
readonly value: string;
|
|
49
|
+
readonly span: PslSpan;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface PslAttributeNamedArgument {
|
|
53
|
+
readonly kind: 'named';
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly value: string;
|
|
56
|
+
readonly span: PslSpan;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export type PslAttributeArgument = PslAttributePositionalArgument | PslAttributeNamedArgument;
|
|
60
|
+
|
|
61
|
+
export interface PslTypeConstructorCall {
|
|
62
|
+
readonly kind: 'typeConstructor';
|
|
63
|
+
readonly path: readonly string[];
|
|
64
|
+
readonly args: readonly PslAttributeArgument[];
|
|
65
|
+
readonly span: PslSpan;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface PslAttribute {
|
|
69
|
+
readonly kind: 'attribute';
|
|
70
|
+
readonly target: PslAttributeTarget;
|
|
71
|
+
readonly name: string;
|
|
72
|
+
readonly args: readonly PslAttributeArgument[];
|
|
73
|
+
readonly span: PslSpan;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export type PslReferentialAction = string;
|
|
77
|
+
|
|
78
|
+
export type PslFieldAttribute = PslAttribute;
|
|
79
|
+
|
|
80
|
+
export interface PslField {
|
|
81
|
+
readonly kind: 'field';
|
|
82
|
+
readonly name: string;
|
|
83
|
+
readonly typeName: string;
|
|
84
|
+
readonly typeConstructor?: PslTypeConstructorCall;
|
|
85
|
+
readonly optional: boolean;
|
|
86
|
+
readonly list: boolean;
|
|
87
|
+
readonly typeRef?: string;
|
|
88
|
+
readonly attributes: readonly PslFieldAttribute[];
|
|
89
|
+
readonly span: PslSpan;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface PslUniqueConstraint {
|
|
93
|
+
readonly kind: 'unique';
|
|
94
|
+
readonly fields: readonly string[];
|
|
95
|
+
readonly span: PslSpan;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface PslIndexConstraint {
|
|
99
|
+
readonly kind: 'index';
|
|
100
|
+
readonly fields: readonly string[];
|
|
101
|
+
readonly span: PslSpan;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export type PslModelAttribute = PslAttribute;
|
|
105
|
+
|
|
106
|
+
export interface PslModel {
|
|
107
|
+
readonly kind: 'model';
|
|
108
|
+
readonly name: string;
|
|
109
|
+
readonly fields: readonly PslField[];
|
|
110
|
+
readonly attributes: readonly PslModelAttribute[];
|
|
111
|
+
readonly span: PslSpan;
|
|
112
|
+
/**
|
|
113
|
+
* Optional leading comment line emitted above the `model` keyword by the
|
|
114
|
+
* printer. Producers (e.g. `sqlSchemaIrToPslAst`) attach introspection
|
|
115
|
+
* advisories such as "// WARNING: This table has no primary key in the
|
|
116
|
+
* database" here. The parser leaves this field unset; round-tripping a
|
|
117
|
+
* parsed schema does not re-attach comments.
|
|
118
|
+
*/
|
|
119
|
+
readonly comment?: string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface PslEnumValue {
|
|
123
|
+
readonly kind: 'enumValue';
|
|
124
|
+
readonly name: string;
|
|
125
|
+
/**
|
|
126
|
+
* Optional storage label for the enum member, captured from a trailing
|
|
127
|
+
* `@map("...")` attribute on the member line. The parser populates this
|
|
128
|
+
* when the source PSL carries an explicit `@map`. Producers (e.g.
|
|
129
|
+
* `sqlSchemaIrToPslAst`) leave it unset; the printer emits `@map(...)`
|
|
130
|
+
* automatically when normalisation would change the printed member name
|
|
131
|
+
* (so an enum value `'in-progress'` becomes `inProgress @map("in-progress")`
|
|
132
|
+
* in PSL, preserving the round-trip).
|
|
133
|
+
*/
|
|
134
|
+
readonly mapName?: string;
|
|
135
|
+
readonly span: PslSpan;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export interface PslEnum {
|
|
139
|
+
readonly kind: 'enum';
|
|
140
|
+
readonly name: string;
|
|
141
|
+
readonly values: readonly PslEnumValue[];
|
|
142
|
+
readonly attributes: readonly PslAttribute[];
|
|
143
|
+
readonly span: PslSpan;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface PslCompositeType {
|
|
147
|
+
readonly kind: 'compositeType';
|
|
148
|
+
readonly name: string;
|
|
149
|
+
readonly fields: readonly PslField[];
|
|
150
|
+
readonly attributes: readonly PslAttribute[];
|
|
151
|
+
readonly span: PslSpan;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export interface PslNamedTypeDeclaration {
|
|
155
|
+
readonly kind: 'namedType';
|
|
156
|
+
readonly name: string;
|
|
157
|
+
/**
|
|
158
|
+
* Parser invariant: exactly one of `baseType` and `typeConstructor` is set.
|
|
159
|
+
* Expressing this as a discriminated union trips TypeScript narrowing when
|
|
160
|
+
* the declaration flows through helpers that accept the full union.
|
|
161
|
+
*/
|
|
162
|
+
readonly baseType?: string;
|
|
163
|
+
readonly typeConstructor?: PslTypeConstructorCall;
|
|
164
|
+
readonly attributes: readonly PslAttribute[];
|
|
165
|
+
readonly span: PslSpan;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface PslTypesBlock {
|
|
169
|
+
readonly kind: 'types';
|
|
170
|
+
readonly declarations: readonly PslNamedTypeDeclaration[];
|
|
171
|
+
readonly span: PslSpan;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
export interface PslDocumentAst {
|
|
175
|
+
readonly kind: 'document';
|
|
176
|
+
readonly sourceId: string;
|
|
177
|
+
readonly models: readonly PslModel[];
|
|
178
|
+
readonly enums: readonly PslEnum[];
|
|
179
|
+
readonly compositeTypes: readonly PslCompositeType[];
|
|
180
|
+
readonly types?: PslTypesBlock;
|
|
181
|
+
readonly span: PslSpan;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export interface ParsePslDocumentInput {
|
|
185
|
+
readonly schema: string;
|
|
186
|
+
readonly sourceId: string;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export interface ParsePslDocumentResult {
|
|
190
|
+
readonly ast: PslDocumentAst;
|
|
191
|
+
readonly diagnostics: readonly PslDiagnostic[];
|
|
192
|
+
readonly ok: boolean;
|
|
193
|
+
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AdapterDescriptor,
|
|
3
|
+
DriverDescriptor,
|
|
4
|
+
ExtensionDescriptor,
|
|
5
|
+
FamilyDescriptor,
|
|
6
|
+
TargetDescriptor,
|
|
7
|
+
} from '../shared/framework-components';
|
|
1
8
|
import type {
|
|
2
9
|
RuntimeAdapterInstance,
|
|
3
10
|
RuntimeDriverInstance,
|
|
@@ -6,13 +13,6 @@ import type {
|
|
|
6
13
|
RuntimeTargetInstance,
|
|
7
14
|
} from './execution-instances';
|
|
8
15
|
import type { ExecutionStack } from './execution-stack';
|
|
9
|
-
import type {
|
|
10
|
-
AdapterDescriptor,
|
|
11
|
-
DriverDescriptor,
|
|
12
|
-
ExtensionDescriptor,
|
|
13
|
-
FamilyDescriptor,
|
|
14
|
-
TargetDescriptor,
|
|
15
|
-
} from './framework-components';
|
|
16
16
|
|
|
17
17
|
export interface RuntimeFamilyDescriptor<
|
|
18
18
|
TFamilyId extends string,
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import { checkContractComponentRequirements } from '../shared/framework-components';
|
|
1
2
|
import type {
|
|
2
3
|
RuntimeAdapterDescriptor,
|
|
3
4
|
RuntimeExtensionDescriptor,
|
|
4
5
|
RuntimeFamilyDescriptor,
|
|
5
6
|
RuntimeTargetDescriptor,
|
|
6
7
|
} from './execution-descriptors';
|
|
7
|
-
import { checkContractComponentRequirements } from './framework-components';
|
|
8
8
|
|
|
9
9
|
export function assertRuntimeContractRequirementsSatisfied<
|
|
10
10
|
TFamilyId extends string,
|
package/src/exports/authoring.ts
CHANGED
|
@@ -10,7 +10,7 @@ export type {
|
|
|
10
10
|
AuthoringTemplateValue,
|
|
11
11
|
AuthoringTypeConstructorDescriptor,
|
|
12
12
|
AuthoringTypeNamespace,
|
|
13
|
-
} from '../framework-authoring';
|
|
13
|
+
} from '../shared/framework-authoring';
|
|
14
14
|
export {
|
|
15
15
|
instantiateAuthoringFieldPreset,
|
|
16
16
|
instantiateAuthoringTypeConstructor,
|
|
@@ -19,4 +19,4 @@ export {
|
|
|
19
19
|
isAuthoringTypeConstructorDescriptor,
|
|
20
20
|
resolveAuthoringTemplateValue,
|
|
21
21
|
validateAuthoringHelperArguments,
|
|
22
|
-
} from '../framework-authoring';
|
|
22
|
+
} from '../shared/framework-authoring';
|
package/src/exports/codec.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export type { Codec, CodecLookup, CodecTrait } from '../codec-types';
|
|
2
|
-
export { emptyCodecLookup } from '../codec-types';
|
|
1
|
+
export type { Codec, CodecLookup, CodecTrait } from '../shared/codec-types';
|
|
2
|
+
export { emptyCodecLookup } from '../shared/codec-types';
|
|
@@ -20,5 +20,5 @@ export type {
|
|
|
20
20
|
TargetDescriptor,
|
|
21
21
|
TargetInstance,
|
|
22
22
|
TargetPackRef,
|
|
23
|
-
} from '../framework-components';
|
|
24
|
-
export { checkContractComponentRequirements } from '../framework-components';
|
|
23
|
+
} from '../shared/framework-components';
|
|
24
|
+
export { checkContractComponentRequirements } from '../shared/framework-components';
|
package/src/exports/control.ts
CHANGED
|
@@ -1,19 +1,29 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
|
|
1
|
+
export type {
|
|
2
|
+
MigratableTargetDescriptor,
|
|
3
|
+
OperationPreviewCapable,
|
|
4
|
+
PslContractInferCapable,
|
|
5
|
+
SchemaViewCapable,
|
|
6
|
+
} from '../control/control-capabilities';
|
|
7
|
+
export {
|
|
8
|
+
hasMigrations,
|
|
9
|
+
hasOperationPreview,
|
|
10
|
+
hasPslContractInfer,
|
|
11
|
+
hasSchemaView,
|
|
12
|
+
} from '../control/control-capabilities';
|
|
3
13
|
export type {
|
|
4
14
|
ControlAdapterDescriptor,
|
|
5
15
|
ControlDriverDescriptor,
|
|
6
16
|
ControlExtensionDescriptor,
|
|
7
17
|
ControlFamilyDescriptor,
|
|
8
18
|
ControlTargetDescriptor,
|
|
9
|
-
} from '../control-descriptors';
|
|
19
|
+
} from '../control/control-descriptors';
|
|
10
20
|
export type {
|
|
11
21
|
ControlAdapterInstance,
|
|
12
22
|
ControlDriverInstance,
|
|
13
23
|
ControlExtensionInstance,
|
|
14
24
|
ControlFamilyInstance,
|
|
15
25
|
ControlTargetInstance,
|
|
16
|
-
} from '../control-instances';
|
|
26
|
+
} from '../control/control-instances';
|
|
17
27
|
export type {
|
|
18
28
|
DataTransformOperation,
|
|
19
29
|
MigrationOperationClass,
|
|
@@ -35,7 +45,11 @@ export type {
|
|
|
35
45
|
OpFactoryCall,
|
|
36
46
|
SerializedQueryPlan,
|
|
37
47
|
TargetMigrationsCapability,
|
|
38
|
-
} from '../control-migration-types';
|
|
48
|
+
} from '../control/control-migration-types';
|
|
49
|
+
export type {
|
|
50
|
+
OperationPreview,
|
|
51
|
+
OperationPreviewStatement,
|
|
52
|
+
} from '../control/control-operation-preview';
|
|
39
53
|
export type {
|
|
40
54
|
BaseSchemaIssue,
|
|
41
55
|
EmitContractResult,
|
|
@@ -47,25 +61,25 @@ export type {
|
|
|
47
61
|
SignDatabaseResult,
|
|
48
62
|
VerifyDatabaseResult,
|
|
49
63
|
VerifyDatabaseSchemaResult,
|
|
50
|
-
} from '../control-result-types';
|
|
64
|
+
} from '../control/control-result-types';
|
|
51
65
|
export {
|
|
52
66
|
VERIFY_CODE_HASH_MISMATCH,
|
|
53
67
|
VERIFY_CODE_MARKER_MISSING,
|
|
54
68
|
VERIFY_CODE_SCHEMA_FAILURE,
|
|
55
69
|
VERIFY_CODE_TARGET_MISMATCH,
|
|
56
|
-
} from '../control-result-types';
|
|
70
|
+
} from '../control/control-result-types';
|
|
57
71
|
export type {
|
|
58
72
|
CoreSchemaView,
|
|
59
73
|
SchemaNodeKind,
|
|
60
74
|
SchemaTreeNodeOptions,
|
|
61
75
|
SchemaTreeVisitor,
|
|
62
|
-
} from '../control-schema-view';
|
|
63
|
-
export { SchemaTreeNode } from '../control-schema-view';
|
|
76
|
+
} from '../control/control-schema-view';
|
|
77
|
+
export { SchemaTreeNode } from '../control/control-schema-view';
|
|
64
78
|
export type {
|
|
65
79
|
AssembledAuthoringContributions,
|
|
66
80
|
ControlStack,
|
|
67
81
|
CreateControlStackInput,
|
|
68
|
-
} from '../control-stack';
|
|
82
|
+
} from '../control/control-stack';
|
|
69
83
|
export {
|
|
70
84
|
assembleAuthoringContributions,
|
|
71
85
|
assembleControlMutationDefaults,
|
|
@@ -77,7 +91,7 @@ export {
|
|
|
77
91
|
extractComponentIds,
|
|
78
92
|
extractOperationTypeImports,
|
|
79
93
|
extractQueryOperationTypeImports,
|
|
80
|
-
} from '../control-stack';
|
|
94
|
+
} from '../control/control-stack';
|
|
81
95
|
export type {
|
|
82
96
|
ControlMutationDefaultEntry,
|
|
83
97
|
ControlMutationDefaultRegistry,
|
|
@@ -92,4 +106,4 @@ export type {
|
|
|
92
106
|
ParsedDefaultFunctionCall,
|
|
93
107
|
SourceDiagnostic,
|
|
94
108
|
SourceSpan,
|
|
95
|
-
} from '../mutation-default-types';
|
|
109
|
+
} from '../shared/mutation-default-types';
|
package/src/exports/emission.ts
CHANGED
|
@@ -2,5 +2,5 @@ export type {
|
|
|
2
2
|
EmissionSpi,
|
|
3
3
|
GenerateContractTypesOptions,
|
|
4
4
|
ValidationContext,
|
|
5
|
-
} from '../emission-types';
|
|
6
|
-
export type { TypesImportSpec } from '../types-import-spec';
|
|
5
|
+
} from '../control/emission-types';
|
|
6
|
+
export type { TypesImportSpec } from '../shared/types-import-spec';
|