@prisma-next/framework-components 0.13.0-dev.20 → 0.13.0-dev.21
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/{codec-types-7Qng7VFc.d.mts → codec-types-29q8imKF.d.mts} +20 -3
- package/dist/{codec-types-7Qng7VFc.d.mts.map → codec-types-29q8imKF.d.mts.map} +1 -1
- package/dist/codec.d.mts +23 -2
- package/dist/codec.d.mts.map +1 -1
- package/dist/codec.mjs +2 -1
- package/dist/codec.mjs.map +1 -1
- package/dist/components.d.mts +1 -1
- package/dist/control.d.mts +6 -6
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +10 -0
- package/dist/control.mjs.map +1 -1
- package/dist/execution.d.mts +1 -1
- package/dist/{framework-authoring-qyokbMY7.d.mts → framework-authoring-BXiebZGn.d.mts} +2 -2
- package/dist/{framework-authoring-qyokbMY7.d.mts.map → framework-authoring-BXiebZGn.d.mts.map} +1 -1
- package/dist/{framework-components-BLiwDP1D.d.mts → framework-components-B-ABhSOs.d.mts} +3 -3
- package/dist/{framework-components-BLiwDP1D.d.mts.map → framework-components-B-ABhSOs.d.mts.map} +1 -1
- package/dist/{psl-ast-DjFPjnlM.d.mts → psl-ast-CHgjnZ3h.d.mts} +3 -3
- package/dist/{psl-ast-DjFPjnlM.d.mts.map → psl-ast-CHgjnZ3h.d.mts.map} +1 -1
- package/dist/psl-ast.d.mts +3 -3
- package/dist/resolve-codec-DR7uyr_c.mjs +47 -0
- package/dist/resolve-codec-DR7uyr_c.mjs.map +1 -0
- package/dist/runtime-error-B2gWOtgH.mjs +37 -0
- package/dist/runtime-error-B2gWOtgH.mjs.map +1 -0
- package/dist/runtime.d.mts +12 -10
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +1 -33
- package/dist/runtime.mjs.map +1 -1
- package/package.json +7 -7
- package/src/control/control-stack.ts +20 -3
- package/src/execution/runtime-error.ts +5 -55
- package/src/exports/codec.ts +2 -0
- package/src/shared/codec-types.ts +19 -1
- package/src/shared/resolve-codec.ts +64 -0
- package/src/shared/runtime-error.ts +50 -0
|
@@ -0,0 +1,50 @@
|
|
|
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
|
+
/**
|
|
9
|
+
* Type guard for the runtime-error envelope produced by `runtimeError`.
|
|
10
|
+
*
|
|
11
|
+
* Prefer this over duck-typing on `error.code` directly so consumers stay
|
|
12
|
+
* insulated from the envelope's internal shape.
|
|
13
|
+
*/
|
|
14
|
+
export function isRuntimeError(error: unknown): error is RuntimeErrorEnvelope {
|
|
15
|
+
return (
|
|
16
|
+
error instanceof Error &&
|
|
17
|
+
'code' in error &&
|
|
18
|
+
typeof (error as { code?: unknown }).code === 'string' &&
|
|
19
|
+
'category' in error &&
|
|
20
|
+
'severity' in error
|
|
21
|
+
);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export function runtimeError(
|
|
25
|
+
code: string,
|
|
26
|
+
message: string,
|
|
27
|
+
details?: Record<string, unknown>,
|
|
28
|
+
): RuntimeErrorEnvelope {
|
|
29
|
+
const error = Object.assign(new Error(message), {
|
|
30
|
+
code,
|
|
31
|
+
category: resolveCategory(code),
|
|
32
|
+
severity: 'error' as const,
|
|
33
|
+
...(details !== undefined ? { details } : {}),
|
|
34
|
+
});
|
|
35
|
+
Object.defineProperty(error, 'name', { value: 'RuntimeError', configurable: true });
|
|
36
|
+
return error;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function resolveCategory(code: string): RuntimeErrorEnvelope['category'] {
|
|
40
|
+
const prefix = code.split('.')[0] ?? 'RUNTIME';
|
|
41
|
+
switch (prefix) {
|
|
42
|
+
case 'PLAN':
|
|
43
|
+
case 'CONTRACT':
|
|
44
|
+
case 'LINT':
|
|
45
|
+
case 'BUDGET':
|
|
46
|
+
return prefix;
|
|
47
|
+
default:
|
|
48
|
+
return 'RUNTIME';
|
|
49
|
+
}
|
|
50
|
+
}
|