@prisma-next/framework-components 0.5.0-dev.4 → 0.5.0-dev.41

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/README.md +61 -0
  2. package/dist/authoring.d.mts +1 -1
  3. package/dist/authoring.mjs +1 -1
  4. package/dist/authoring.mjs.map +1 -1
  5. package/dist/codec-types-CB0jWeHU.d.mts +207 -0
  6. package/dist/codec-types-CB0jWeHU.d.mts.map +1 -0
  7. package/dist/codec.d.mts +2 -2
  8. package/dist/codec.mjs +38 -2
  9. package/dist/codec.mjs.map +1 -1
  10. package/dist/components.d.mts +1 -1
  11. package/dist/components.mjs +1 -1
  12. package/dist/control.d.mts +101 -35
  13. package/dist/control.d.mts.map +1 -1
  14. package/dist/control.mjs +11 -5
  15. package/dist/control.mjs.map +1 -1
  16. package/dist/emission-types-D6t3_a0x.d.mts +39 -0
  17. package/dist/emission-types-D6t3_a0x.d.mts.map +1 -0
  18. package/dist/emission.d.mts +2 -2
  19. package/dist/execution.d.mts +5 -5
  20. package/dist/execution.d.mts.map +1 -1
  21. package/dist/execution.mjs +3 -3
  22. package/dist/execution.mjs.map +1 -1
  23. package/dist/{framework-authoring-D1-JZ37B.d.mts → framework-authoring-BdrFDx4x.d.mts} +2 -2
  24. package/dist/framework-authoring-BdrFDx4x.d.mts.map +1 -0
  25. package/dist/{framework-components-EJXe-pum.d.mts → framework-components-AHI6V96G.d.mts} +6 -6
  26. package/dist/framework-components-AHI6V96G.d.mts.map +1 -0
  27. package/dist/{framework-components-C8ZhSwXe.mjs → framework-components-BsWST1Rn.mjs} +2 -2
  28. package/dist/framework-components-BsWST1Rn.mjs.map +1 -0
  29. package/dist/psl-ast-9X5rwo98.d.mts +159 -0
  30. package/dist/psl-ast-9X5rwo98.d.mts.map +1 -0
  31. package/dist/psl-ast.d.mts +2 -0
  32. package/dist/psl-ast.mjs +1 -0
  33. package/dist/runtime.d.mts +251 -19
  34. package/dist/runtime.d.mts.map +1 -1
  35. package/dist/runtime.mjs +215 -4
  36. package/dist/runtime.mjs.map +1 -1
  37. package/dist/{types-import-spec-C4sc7wbb.d.mts → types-import-spec-D-O6GotH.d.mts} +2 -2
  38. package/dist/types-import-spec-D-O6GotH.d.mts.map +1 -0
  39. package/package.json +8 -6
  40. package/src/control/control-capabilities.ts +71 -0
  41. package/src/{control-descriptors.ts → control/control-descriptors.ts} +7 -7
  42. package/src/{control-instances.ts → control/control-instances.ts} +6 -6
  43. package/src/{control-migration-types.ts → control/control-migration-types.ts} +48 -23
  44. package/src/control/control-operation-preview.ts +23 -0
  45. package/src/{control-stack.ts → control/control-stack.ts} +13 -13
  46. package/src/control/emission-types.ts +49 -0
  47. package/src/control/psl-ast.ts +193 -0
  48. package/src/{execution-descriptors.ts → execution/execution-descriptors.ts} +7 -7
  49. package/src/{execution-instances.ts → execution/execution-instances.ts} +1 -1
  50. package/src/{execution-requirements.ts → execution/execution-requirements.ts} +1 -1
  51. package/src/execution/query-plan.ts +53 -0
  52. package/src/execution/race-against-abort.ts +85 -0
  53. package/src/execution/run-with-middleware.ts +77 -0
  54. package/src/execution/runtime-core.ts +133 -0
  55. package/src/execution/runtime-error.ts +83 -0
  56. package/src/{runtime-middleware.ts → execution/runtime-middleware.ts} +32 -12
  57. package/src/exports/authoring.ts +2 -2
  58. package/src/exports/codec.ts +14 -2
  59. package/src/exports/components.ts +2 -2
  60. package/src/exports/control.ts +26 -12
  61. package/src/exports/emission.ts +2 -2
  62. package/src/exports/execution.ts +5 -5
  63. package/src/exports/psl-ast.ts +1 -0
  64. package/src/exports/runtime.ts +16 -5
  65. package/src/shared/codec-types.ts +261 -0
  66. package/dist/codec-types-B58nCJiu.d.mts +0 -40
  67. package/dist/codec-types-B58nCJiu.d.mts.map +0 -1
  68. package/dist/emission-types-BPAALJbF.d.mts +0 -24
  69. package/dist/emission-types-BPAALJbF.d.mts.map +0 -1
  70. package/dist/framework-authoring-D1-JZ37B.d.mts.map +0 -1
  71. package/dist/framework-components-C8ZhSwXe.mjs.map +0 -1
  72. package/dist/framework-components-EJXe-pum.d.mts.map +0 -1
  73. package/dist/types-import-spec-C4sc7wbb.d.mts.map +0 -1
  74. package/src/codec-types.ts +0 -46
  75. package/src/control-capabilities.ts +0 -34
  76. package/src/emission-types.ts +0 -28
  77. package/src/runtime-error.ts +0 -39
  78. /package/src/{control-result-types.ts → control/control-result-types.ts} +0 -0
  79. /package/src/{control-schema-view.ts → control/control-schema-view.ts} +0 -0
  80. /package/src/{async-iterable-result.ts → execution/async-iterable-result.ts} +0 -0
  81. /package/src/{execution-stack.ts → execution/execution-stack.ts} +0 -0
  82. /package/src/{framework-authoring.ts → shared/framework-authoring.ts} +0 -0
  83. /package/src/{framework-components.ts → shared/framework-components.ts} +0 -0
  84. /package/src/{mutation-default-types.ts → shared/mutation-default-types.ts} +0 -0
  85. /package/src/{types-import-spec.ts → shared/types-import-spec.ts} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"file":"framework-components-EJXe-pum.d.mts","names":[],"sources":["../src/mutation-default-types.ts","../src/framework-components.ts"],"sourcesContent":[],"mappings":";;;;;;UAEU,cAAA;;;;;AAAA,UAMO,UAAA,CANO;EAMP,SAAA,KAAU,EACT,cAAA;EAID,SAAA,GAAA,EAHD,cAGiB;;AAKN,UALV,gBAAA,CAKU;EAAT,SAAA,IAAA,EAAA,MAAA;EAAQ,SAAA,OAAA,EAAA,MAAA;EAGhB,SAAA,QAAA,CAAA,EAAA,MAAuB;EAKhB,SAAA,IAAA,CAAA,EATC,UASD;EAOA,SAAA,IAAA,CAAA,EAfC,QAeD,CAfU,MAeV,CAAA,MAA8B,EAAA,OAAA,CAAA,CAAA;AAO/C;AAIA,UAvBU,uBAAA,CAuBsB;EAIpB,SAAA,GAAA,EAAA,MAAA;EACK,SAAA,IAAA,EA1BA,UA0BA;;AAEX,UAzBW,yBAAA,CAyBX;EAAoB,SAAA,IAAA,EAAA,MAAA;EAET,SAAA,GAAA,EAAA,M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D;;qBAE/C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BJ,6EACP;;qBAEW;;qBAGA;;;;;;UAOJ,mEACP;iBACO;;qBAEI;;uBAEE;;KAGX,mDAAmD,sBAAsB;KAEzE,sFAGR,sBAAsB;qBACL;;KAGT,uFAGR,uBAAuB;qBACN;;KAGT,yFAGR,yBAAyB;qBACR;;KAGT,sFAGR,sBAAsB;qBACL;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA+BJ,8EACP;;qBAEW;;qBAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiCJ,6EACP;;qBAEW;;qBAGA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UA8BJ,gFACP;;qBAEW;;qBAGA;;;KAIT,qFACR,iBAAiB,WAAW,aAC5B,kBAAkB,WAAW,aAC7B,iBAAiB,WAAW,aAC5B,oBAAoB,WAAW;UAElB;qBACI;;UAGJ;qBACI;qBACA;;UAGJ;qBACI;qBACA;;UAGJ;qBACI;qBACA;;UAGJ;qBACI;qBACA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"types-import-spec-C4sc7wbb.d.mts","names":[],"sources":["../src/types-import-spec.ts"],"sourcesContent":[],"mappings":";;AAIA;;;UAAiB,eAAA"}
@@ -1,46 +0,0 @@
1
- import type { JsonValue } from '@prisma-next/contract/types';
2
-
3
- export type CodecTrait = 'equality' | 'order' | 'boolean' | 'numeric' | 'textual';
4
-
5
- /**
6
- * Base codec interface for all target families.
7
- *
8
- * A codec maps between three representations of a value:
9
- * - **JS** (`TJs`): the JavaScript type used in application code
10
- * - **Wire** (`TWire`): the format sent to/from the database driver
11
- * - **JSON** (`JsonValue`): the JSON-safe form stored in contract artifacts
12
- *
13
- * Family-specific codec interfaces (SQL `Codec`, Mongo `MongoCodec`) extend
14
- * this base to add family-specific metadata.
15
- */
16
- export interface Codec<
17
- Id extends string = string,
18
- TTraits extends readonly CodecTrait[] = readonly CodecTrait[],
19
- TWire = unknown,
20
- TJs = unknown,
21
- > {
22
- /** Unique codec identifier in `namespace/name@version` format (e.g. `pg/timestamptz@1`). */
23
- readonly id: Id;
24
- /** Database-native type names this codec handles (e.g. `['timestamptz']`). */
25
- readonly targetTypes: readonly string[];
26
- /** Semantic traits for operator gating (e.g. equality, order, numeric). */
27
- readonly traits?: TTraits;
28
- /** Converts a JS value to the wire format expected by the database driver. Optional when the driver accepts the JS type directly. */
29
- encode?(value: TJs): TWire;
30
- /** Converts a wire value from the database driver into the JS type. */
31
- decode(wire: TWire): TJs;
32
- /** Converts a JS value to a JSON-safe representation for contract serialization. Called during contract emission. */
33
- encodeJson(value: TJs): JsonValue;
34
- /** Converts a JSON representation back to the JS type. Called during contract loading via `validateContract`. */
35
- decodeJson(json: JsonValue): TJs;
36
- /** Produces the TypeScript output type expression for a field given its `typeParams`. Used during contract.d.ts emission. */
37
- renderOutputType?(typeParams: Record<string, unknown>): string | undefined;
38
- }
39
-
40
- export interface CodecLookup {
41
- get(id: string): Codec | undefined;
42
- }
43
-
44
- export const emptyCodecLookup: CodecLookup = {
45
- get: () => undefined,
46
- };
@@ -1,34 +0,0 @@
1
- import type { ControlTargetDescriptor } from './control-descriptors';
2
- import type { ControlFamilyInstance } from './control-instances';
3
- import type { TargetMigrationsCapability } from './control-migration-types';
4
- import type { CoreSchemaView } from './control-schema-view';
5
-
6
- export interface MigratableTargetDescriptor<
7
- TFamilyId extends string,
8
- TTargetId extends string,
9
- TFamilyInstance extends ControlFamilyInstance<TFamilyId, unknown> = ControlFamilyInstance<
10
- TFamilyId,
11
- unknown
12
- >,
13
- > extends ControlTargetDescriptor<TFamilyId, TTargetId> {
14
- readonly migrations: TargetMigrationsCapability<TFamilyId, TTargetId, TFamilyInstance>;
15
- }
16
-
17
- export function hasMigrations<TFamilyId extends string, TTargetId extends string>(
18
- target: ControlTargetDescriptor<TFamilyId, TTargetId>,
19
- ): target is MigratableTargetDescriptor<TFamilyId, TTargetId> {
20
- return 'migrations' in target && !!(target as Record<string, unknown>)['migrations'];
21
- }
22
-
23
- export interface SchemaViewCapable<TSchemaIR = unknown> {
24
- toSchemaView(schema: TSchemaIR): CoreSchemaView;
25
- }
26
-
27
- export function hasSchemaView<TFamilyId extends string, TSchemaIR>(
28
- instance: ControlFamilyInstance<TFamilyId, TSchemaIR>,
29
- ): instance is ControlFamilyInstance<TFamilyId, TSchemaIR> & SchemaViewCapable<TSchemaIR> {
30
- return (
31
- 'toSchemaView' in instance &&
32
- typeof (instance as Record<string, unknown>)['toSchemaView'] === 'function'
33
- );
34
- }
@@ -1,28 +0,0 @@
1
- import type { Contract, ContractModel } from '@prisma-next/contract/types';
2
- import type { TypesImportSpec } from './types-import-spec';
3
-
4
- export interface GenerateContractTypesOptions {
5
- readonly queryOperationTypeImports?: ReadonlyArray<TypesImportSpec>;
6
- }
7
-
8
- export interface ValidationContext {
9
- readonly codecTypeImports?: ReadonlyArray<TypesImportSpec>;
10
- readonly operationTypeImports?: ReadonlyArray<TypesImportSpec>;
11
- readonly extensionIds?: ReadonlyArray<string>;
12
- }
13
-
14
- export interface EmissionSpi {
15
- readonly id: string;
16
-
17
- generateStorageType(contract: Contract, storageHashTypeName: string): string;
18
-
19
- generateModelStorageType(modelName: string, model: ContractModel): string;
20
-
21
- getFamilyImports(): string[];
22
-
23
- getFamilyTypeAliases(options?: GenerateContractTypesOptions): string;
24
-
25
- getTypeMapsExpression(): string;
26
-
27
- getContractWrapper(contractBaseName: string, typeMapsName: string): string;
28
- }
@@ -1,39 +0,0 @@
1
- export interface RuntimeErrorEnvelope extends Error {
2
- readonly code: string;
3
- readonly category: 'PLAN' | 'CONTRACT' | 'LINT' | 'BUDGET' | 'RUNTIME';
4
- readonly severity: 'error';
5
- readonly details?: Record<string, unknown>;
6
- }
7
-
8
- export function runtimeError(
9
- code: string,
10
- message: string,
11
- details?: Record<string, unknown>,
12
- ): RuntimeErrorEnvelope {
13
- const error = new Error(message) as RuntimeErrorEnvelope;
14
- Object.defineProperty(error, 'name', {
15
- value: 'RuntimeError',
16
- configurable: true,
17
- });
18
-
19
- return Object.assign(error, {
20
- code,
21
- category: resolveCategory(code),
22
- severity: 'error' as const,
23
- message,
24
- details,
25
- });
26
- }
27
-
28
- function resolveCategory(code: string): RuntimeErrorEnvelope['category'] {
29
- const prefix = code.split('.')[0] ?? 'RUNTIME';
30
- switch (prefix) {
31
- case 'PLAN':
32
- case 'CONTRACT':
33
- case 'LINT':
34
- case 'BUDGET':
35
- return prefix;
36
- default:
37
- return 'RUNTIME';
38
- }
39
- }