@prisma-next/framework-components 0.0.1 → 0.3.0-dev.146
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 +2 -0
- package/dist/authoring.mjs +122 -0
- package/dist/authoring.mjs.map +1 -0
- package/dist/codec-types-D9ixsdxw.d.mts +40 -0
- package/dist/codec-types-D9ixsdxw.d.mts.map +1 -0
- package/dist/codec.d.mts +2 -0
- package/dist/codec.mjs +6 -0
- package/dist/codec.mjs.map +1 -0
- package/dist/components.d.mts +2 -0
- package/dist/components.mjs +3 -0
- package/dist/control.d.mts +550 -0
- package/dist/control.d.mts.map +1 -0
- package/dist/control.mjs +140 -0
- package/dist/control.mjs.map +1 -0
- package/dist/emission-types-Dt9_NXRb.d.mts +24 -0
- package/dist/emission-types-Dt9_NXRb.d.mts.map +1 -0
- package/dist/emission.d.mts +3 -0
- package/dist/emission.mjs +1 -0
- package/dist/execution.d.mts +78 -0
- package/dist/execution.d.mts.map +1 -0
- package/dist/execution.mjs +43 -0
- package/dist/execution.mjs.map +1 -0
- package/dist/framework-authoring-BybjSfF5.d.mts +99 -0
- package/dist/framework-authoring-BybjSfF5.d.mts.map +1 -0
- package/dist/framework-components-Bl3SLyGG.mjs +27 -0
- package/dist/framework-components-Bl3SLyGG.mjs.map +1 -0
- package/dist/framework-components-W-TA8p5-.d.mts +333 -0
- package/dist/framework-components-W-TA8p5-.d.mts.map +1 -0
- package/dist/types-import-spec-BupmVNbx.d.mts +13 -0
- package/dist/types-import-spec-BupmVNbx.d.mts.map +1 -0
- package/package.json +4 -4
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { _ as resolveAuthoringTemplateValue, a as AuthoringFieldNamespace, c as AuthoringStorageTypeTemplate, d as AuthoringTypeNamespace, f as instantiateAuthoringFieldPreset, g as isAuthoringTypeConstructorDescriptor, h as isAuthoringFieldPresetDescriptor, i as AuthoringContributions, l as AuthoringTemplateValue, m as isAuthoringArgRef, n as AuthoringArgumentDescriptor, o as AuthoringFieldPresetDescriptor, p as instantiateAuthoringTypeConstructor, r as AuthoringColumnDefaultTemplate, s as AuthoringFieldPresetOutput, t as AuthoringArgRef, u as AuthoringTypeConstructorDescriptor, v as validateAuthoringHelperArguments } from "./framework-authoring-BybjSfF5.mjs";
|
|
2
|
+
export { type AuthoringArgRef, type AuthoringArgumentDescriptor, type AuthoringColumnDefaultTemplate, type AuthoringContributions, type AuthoringFieldNamespace, type AuthoringFieldPresetDescriptor, type AuthoringFieldPresetOutput, type AuthoringStorageTypeTemplate, type AuthoringTemplateValue, type AuthoringTypeConstructorDescriptor, type AuthoringTypeNamespace, instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringArgRef, isAuthoringFieldPresetDescriptor, isAuthoringTypeConstructorDescriptor, resolveAuthoringTemplateValue, validateAuthoringHelperArguments };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { ifDefined } from "@prisma-next/utils/defined";
|
|
2
|
+
|
|
3
|
+
//#region src/framework-authoring.ts
|
|
4
|
+
function isAuthoringArgRef(value) {
|
|
5
|
+
if (typeof value !== "object" || value === null || value.kind !== "arg") return false;
|
|
6
|
+
const { index, path } = value;
|
|
7
|
+
if (typeof index !== "number" || !Number.isInteger(index) || index < 0) return false;
|
|
8
|
+
if (path !== void 0 && (!Array.isArray(path) || path.some((s) => typeof s !== "string"))) return false;
|
|
9
|
+
return true;
|
|
10
|
+
}
|
|
11
|
+
function isAuthoringTemplateRecord(value) {
|
|
12
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
13
|
+
}
|
|
14
|
+
function isAuthoringTypeConstructorDescriptor(value) {
|
|
15
|
+
return typeof value === "object" && value !== null && value.kind === "typeConstructor" && typeof value.output === "object" && value.output !== null;
|
|
16
|
+
}
|
|
17
|
+
function isAuthoringFieldPresetDescriptor(value) {
|
|
18
|
+
return typeof value === "object" && value !== null && value.kind === "fieldPreset" && typeof value.output === "object" && value.output !== null;
|
|
19
|
+
}
|
|
20
|
+
function resolveAuthoringTemplateValue(template, args) {
|
|
21
|
+
if (isAuthoringArgRef(template)) {
|
|
22
|
+
let value = args[template.index];
|
|
23
|
+
for (const segment of template.path ?? []) {
|
|
24
|
+
if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) {
|
|
25
|
+
value = void 0;
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
value = value[segment];
|
|
29
|
+
}
|
|
30
|
+
if (value === void 0 && template.default !== void 0) return resolveAuthoringTemplateValue(template.default, args);
|
|
31
|
+
return value;
|
|
32
|
+
}
|
|
33
|
+
if (Array.isArray(template)) return template.map((value) => resolveAuthoringTemplateValue(value, args));
|
|
34
|
+
if (typeof template === "object" && template !== null) {
|
|
35
|
+
const resolved = {};
|
|
36
|
+
for (const [key, value] of Object.entries(template)) {
|
|
37
|
+
const resolvedValue = resolveAuthoringTemplateValue(value, args);
|
|
38
|
+
if (resolvedValue !== void 0) resolved[key] = resolvedValue;
|
|
39
|
+
}
|
|
40
|
+
return resolved;
|
|
41
|
+
}
|
|
42
|
+
return template;
|
|
43
|
+
}
|
|
44
|
+
function validateAuthoringArgument(descriptor, value, path) {
|
|
45
|
+
if (value === void 0) {
|
|
46
|
+
if (descriptor.optional) return;
|
|
47
|
+
throw new Error(`Missing required authoring helper argument at ${path}`);
|
|
48
|
+
}
|
|
49
|
+
if (descriptor.kind === "string") {
|
|
50
|
+
if (typeof value !== "string") throw new Error(`Authoring helper argument at ${path} must be a string`);
|
|
51
|
+
return;
|
|
52
|
+
}
|
|
53
|
+
if (descriptor.kind === "stringArray") {
|
|
54
|
+
if (!Array.isArray(value)) throw new Error(`Authoring helper argument at ${path} must be an array of strings`);
|
|
55
|
+
for (const entry of value) if (typeof entry !== "string") throw new Error(`Authoring helper argument at ${path} must be an array of strings`);
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
if (descriptor.kind === "object") {
|
|
59
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) throw new Error(`Authoring helper argument at ${path} must be an object`);
|
|
60
|
+
const input = value;
|
|
61
|
+
const expectedKeys = new Set(Object.keys(descriptor.properties));
|
|
62
|
+
for (const key of Object.keys(input)) if (!expectedKeys.has(key)) throw new Error(`Authoring helper argument at ${path} contains unknown property "${key}"`);
|
|
63
|
+
for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
if (typeof value !== "number" || Number.isNaN(value)) throw new Error(`Authoring helper argument at ${path} must be a number`);
|
|
67
|
+
if (descriptor.integer && !Number.isInteger(value)) throw new Error(`Authoring helper argument at ${path} must be an integer`);
|
|
68
|
+
if (descriptor.minimum !== void 0 && value < descriptor.minimum) throw new Error(`Authoring helper argument at ${path} must be >= ${descriptor.minimum}, received ${value}`);
|
|
69
|
+
if (descriptor.maximum !== void 0 && value > descriptor.maximum) throw new Error(`Authoring helper argument at ${path} must be <= ${descriptor.maximum}, received ${value}`);
|
|
70
|
+
}
|
|
71
|
+
function validateAuthoringHelperArguments(helperPath, descriptors, args) {
|
|
72
|
+
const expected = descriptors ?? [];
|
|
73
|
+
const minimumArgs = expected.reduce((count, descriptor, index) => descriptor.optional ? count : index + 1, 0);
|
|
74
|
+
if (args.length < minimumArgs || args.length > expected.length) throw new Error(`${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`);
|
|
75
|
+
expected.forEach((descriptor, index) => {
|
|
76
|
+
validateAuthoringArgument(descriptor, args[index], `${helperPath}[${index}]`);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function resolveAuthoringStorageTypeTemplate(template, args) {
|
|
80
|
+
const nativeType = resolveAuthoringTemplateValue(template.nativeType, args);
|
|
81
|
+
if (typeof nativeType !== "string") throw new Error(`Resolved authoring nativeType must be a string for codec "${template.codecId}", received ${String(nativeType)}`);
|
|
82
|
+
const typeParams = template.typeParams === void 0 ? void 0 : resolveAuthoringTemplateValue(template.typeParams, args);
|
|
83
|
+
if (typeParams !== void 0 && !isAuthoringTemplateRecord(typeParams)) throw new Error(`Resolved authoring typeParams must be an object for codec "${template.codecId}", received ${String(typeParams)}`);
|
|
84
|
+
return {
|
|
85
|
+
codecId: template.codecId,
|
|
86
|
+
nativeType,
|
|
87
|
+
...typeParams === void 0 ? {} : { typeParams }
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
function resolveAuthoringColumnDefaultTemplate(template, args) {
|
|
91
|
+
if (template.kind === "literal") {
|
|
92
|
+
const value = resolveAuthoringTemplateValue(template.value, args);
|
|
93
|
+
if (value === void 0) throw new Error("Resolved authoring literal default must not be undefined");
|
|
94
|
+
return {
|
|
95
|
+
kind: "literal",
|
|
96
|
+
value
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
const expression = resolveAuthoringTemplateValue(template.expression, args);
|
|
100
|
+
if (expression === void 0 || typeof expression === "object" && expression !== null) throw new Error(`Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`);
|
|
101
|
+
return {
|
|
102
|
+
kind: "function",
|
|
103
|
+
expression: String(expression)
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
function instantiateAuthoringTypeConstructor(descriptor, args) {
|
|
107
|
+
return resolveAuthoringStorageTypeTemplate(descriptor.output, args);
|
|
108
|
+
}
|
|
109
|
+
function instantiateAuthoringFieldPreset(descriptor, args) {
|
|
110
|
+
return {
|
|
111
|
+
descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args),
|
|
112
|
+
nullable: descriptor.output.nullable ?? false,
|
|
113
|
+
...ifDefined("default", descriptor.output.default !== void 0 ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args) : void 0),
|
|
114
|
+
...ifDefined("executionDefault", descriptor.output.executionDefault !== void 0 ? resolveAuthoringTemplateValue(descriptor.output.executionDefault, args) : void 0),
|
|
115
|
+
id: descriptor.output.id ?? false,
|
|
116
|
+
unique: descriptor.output.unique ?? false
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
//#endregion
|
|
121
|
+
export { instantiateAuthoringFieldPreset, instantiateAuthoringTypeConstructor, isAuthoringArgRef, isAuthoringFieldPresetDescriptor, isAuthoringTypeConstructorDescriptor, resolveAuthoringTemplateValue, validateAuthoringHelperArguments };
|
|
122
|
+
//# sourceMappingURL=authoring.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authoring.mjs","names":["resolved: Record<string, unknown>"],"sources":["../src/framework-authoring.ts"],"sourcesContent":["import { ifDefined } from '@prisma-next/utils/defined';\n\nexport type AuthoringArgRef = {\n readonly kind: 'arg';\n readonly index: number;\n readonly path?: readonly string[];\n readonly default?: AuthoringTemplateValue;\n};\n\nexport type AuthoringTemplateValue =\n | string\n | number\n | boolean\n | null\n | AuthoringArgRef\n | readonly AuthoringTemplateValue[]\n | { readonly [key: string]: AuthoringTemplateValue };\n\nexport type AuthoringArgumentDescriptor =\n | {\n readonly kind: 'string';\n readonly optional?: boolean;\n }\n | {\n readonly kind: 'number';\n readonly optional?: boolean;\n readonly integer?: boolean;\n readonly minimum?: number;\n readonly maximum?: number;\n }\n | {\n readonly kind: 'stringArray';\n readonly optional?: boolean;\n }\n | {\n readonly kind: 'object';\n readonly optional?: boolean;\n readonly properties: Record<string, AuthoringArgumentDescriptor>;\n };\n\nexport interface AuthoringStorageTypeTemplate {\n readonly codecId: string;\n readonly nativeType: AuthoringTemplateValue;\n readonly typeParams?: Record<string, AuthoringTemplateValue>;\n}\n\nexport interface AuthoringTypeConstructorDescriptor {\n readonly kind: 'typeConstructor';\n readonly args?: readonly AuthoringArgumentDescriptor[];\n readonly output: AuthoringStorageTypeTemplate;\n}\n\nexport interface AuthoringColumnDefaultTemplateLiteral {\n readonly kind: 'literal';\n readonly value: AuthoringTemplateValue;\n}\n\nexport interface AuthoringColumnDefaultTemplateFunction {\n readonly kind: 'function';\n readonly expression: AuthoringTemplateValue;\n}\n\nexport type AuthoringColumnDefaultTemplate =\n | AuthoringColumnDefaultTemplateLiteral\n | AuthoringColumnDefaultTemplateFunction;\n\nexport interface AuthoringFieldPresetOutput extends AuthoringStorageTypeTemplate {\n readonly nullable?: boolean;\n readonly default?: AuthoringColumnDefaultTemplate;\n readonly executionDefault?: AuthoringTemplateValue;\n readonly id?: boolean;\n readonly unique?: boolean;\n}\n\nexport interface AuthoringFieldPresetDescriptor {\n readonly kind: 'fieldPreset';\n readonly args?: readonly AuthoringArgumentDescriptor[];\n readonly output: AuthoringFieldPresetOutput;\n}\n\nexport type AuthoringTypeNamespace = {\n readonly [name: string]: AuthoringTypeConstructorDescriptor | AuthoringTypeNamespace;\n};\n\nexport type AuthoringFieldNamespace = {\n readonly [name: string]: AuthoringFieldPresetDescriptor | AuthoringFieldNamespace;\n};\n\nexport interface AuthoringContributions {\n readonly type?: AuthoringTypeNamespace;\n readonly field?: AuthoringFieldNamespace;\n}\n\nexport function isAuthoringArgRef(value: unknown): value is AuthoringArgRef {\n if (typeof value !== 'object' || value === null || (value as { kind?: unknown }).kind !== 'arg') {\n return false;\n }\n const { index, path } = value as { index?: unknown; path?: unknown };\n if (typeof index !== 'number' || !Number.isInteger(index) || index < 0) {\n return false;\n }\n if (path !== undefined && (!Array.isArray(path) || path.some((s) => typeof s !== 'string'))) {\n return false;\n }\n return true;\n}\n\nfunction isAuthoringTemplateRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nexport function isAuthoringTypeConstructorDescriptor(\n value: unknown,\n): value is AuthoringTypeConstructorDescriptor {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { kind?: unknown }).kind === 'typeConstructor' &&\n typeof (value as { output?: unknown }).output === 'object' &&\n (value as { output?: unknown }).output !== null\n );\n}\n\nexport function isAuthoringFieldPresetDescriptor(\n value: unknown,\n): value is AuthoringFieldPresetDescriptor {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { kind?: unknown }).kind === 'fieldPreset' &&\n typeof (value as { output?: unknown }).output === 'object' &&\n (value as { output?: unknown }).output !== null\n );\n}\n\nexport function resolveAuthoringTemplateValue(\n template: AuthoringTemplateValue,\n args: readonly unknown[],\n): unknown {\n if (isAuthoringArgRef(template)) {\n let value = args[template.index];\n\n for (const segment of template.path ?? []) {\n if (!isAuthoringTemplateRecord(value) || !Object.hasOwn(value, segment)) {\n value = undefined;\n break;\n }\n value = (value as Record<string, unknown>)[segment];\n }\n\n if (value === undefined && template.default !== undefined) {\n return resolveAuthoringTemplateValue(template.default, args);\n }\n\n return value;\n }\n if (Array.isArray(template)) {\n return template.map((value) => resolveAuthoringTemplateValue(value, args));\n }\n if (typeof template === 'object' && template !== null) {\n const resolved: Record<string, unknown> = {};\n for (const [key, value] of Object.entries(template)) {\n const resolvedValue = resolveAuthoringTemplateValue(value, args);\n if (resolvedValue !== undefined) {\n resolved[key] = resolvedValue;\n }\n }\n return resolved;\n }\n return template;\n}\n\nfunction validateAuthoringArgument(\n descriptor: AuthoringArgumentDescriptor,\n value: unknown,\n path: string,\n): void {\n if (value === undefined) {\n if (descriptor.optional) {\n return;\n }\n throw new Error(`Missing required authoring helper argument at ${path}`);\n }\n\n if (descriptor.kind === 'string') {\n if (typeof value !== 'string') {\n throw new Error(`Authoring helper argument at ${path} must be a string`);\n }\n return;\n }\n\n if (descriptor.kind === 'stringArray') {\n if (!Array.isArray(value)) {\n throw new Error(`Authoring helper argument at ${path} must be an array of strings`);\n }\n for (const entry of value) {\n if (typeof entry !== 'string') {\n throw new Error(`Authoring helper argument at ${path} must be an array of strings`);\n }\n }\n return;\n }\n\n if (descriptor.kind === 'object') {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new Error(`Authoring helper argument at ${path} must be an object`);\n }\n\n const input = value as Record<string, unknown>;\n const expectedKeys = new Set(Object.keys(descriptor.properties));\n\n for (const key of Object.keys(input)) {\n if (!expectedKeys.has(key)) {\n throw new Error(`Authoring helper argument at ${path} contains unknown property \"${key}\"`);\n }\n }\n\n for (const [key, propertyDescriptor] of Object.entries(descriptor.properties)) {\n validateAuthoringArgument(propertyDescriptor, input[key], `${path}.${key}`);\n }\n\n return;\n }\n\n if (typeof value !== 'number' || Number.isNaN(value)) {\n throw new Error(`Authoring helper argument at ${path} must be a number`);\n }\n\n if (descriptor.integer && !Number.isInteger(value)) {\n throw new Error(`Authoring helper argument at ${path} must be an integer`);\n }\n if (descriptor.minimum !== undefined && value < descriptor.minimum) {\n throw new Error(\n `Authoring helper argument at ${path} must be >= ${descriptor.minimum}, received ${value}`,\n );\n }\n if (descriptor.maximum !== undefined && value > descriptor.maximum) {\n throw new Error(\n `Authoring helper argument at ${path} must be <= ${descriptor.maximum}, received ${value}`,\n );\n }\n}\n\nexport function validateAuthoringHelperArguments(\n helperPath: string,\n descriptors: readonly AuthoringArgumentDescriptor[] | undefined,\n args: readonly unknown[],\n): void {\n const expected = descriptors ?? [];\n const minimumArgs = expected.reduce(\n (count, descriptor, index) => (descriptor.optional ? count : index + 1),\n 0,\n );\n if (args.length < minimumArgs || args.length > expected.length) {\n throw new Error(\n `${helperPath} expects ${minimumArgs === expected.length ? expected.length : `${minimumArgs}-${expected.length}`} argument(s), received ${args.length}`,\n );\n }\n\n expected.forEach((descriptor, index) => {\n validateAuthoringArgument(descriptor, args[index], `${helperPath}[${index}]`);\n });\n}\n\nfunction resolveAuthoringStorageTypeTemplate(\n template: AuthoringStorageTypeTemplate,\n args: readonly unknown[],\n): {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n} {\n const nativeType = resolveAuthoringTemplateValue(template.nativeType, args);\n if (typeof nativeType !== 'string') {\n throw new Error(\n `Resolved authoring nativeType must be a string for codec \"${template.codecId}\", received ${String(nativeType)}`,\n );\n }\n const typeParams =\n template.typeParams === undefined\n ? undefined\n : resolveAuthoringTemplateValue(template.typeParams, args);\n if (typeParams !== undefined && !isAuthoringTemplateRecord(typeParams)) {\n throw new Error(\n `Resolved authoring typeParams must be an object for codec \"${template.codecId}\", received ${String(typeParams)}`,\n );\n }\n\n return {\n codecId: template.codecId,\n nativeType,\n ...(typeParams === undefined ? {} : { typeParams }),\n };\n}\n\nfunction resolveAuthoringColumnDefaultTemplate(\n template: AuthoringColumnDefaultTemplate,\n args: readonly unknown[],\n):\n | {\n readonly kind: 'literal';\n readonly value: unknown;\n }\n | {\n readonly kind: 'function';\n readonly expression: string;\n } {\n if (template.kind === 'literal') {\n const value = resolveAuthoringTemplateValue(template.value, args);\n if (value === undefined) {\n throw new Error('Resolved authoring literal default must not be undefined');\n }\n return {\n kind: 'literal',\n value,\n };\n }\n\n const expression = resolveAuthoringTemplateValue(template.expression, args);\n if (expression === undefined || (typeof expression === 'object' && expression !== null)) {\n throw new Error(\n `Resolved authoring function default expression must resolve to a primitive, received ${String(expression)}`,\n );\n }\n return {\n kind: 'function',\n expression: String(expression),\n };\n}\n\nexport function instantiateAuthoringTypeConstructor(\n descriptor: AuthoringTypeConstructorDescriptor,\n args: readonly unknown[],\n): {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n} {\n return resolveAuthoringStorageTypeTemplate(descriptor.output, args);\n}\n\nexport function instantiateAuthoringFieldPreset(\n descriptor: AuthoringFieldPresetDescriptor,\n args: readonly unknown[],\n): {\n readonly descriptor: {\n readonly codecId: string;\n readonly nativeType: string;\n readonly typeParams?: Record<string, unknown>;\n };\n readonly nullable: boolean;\n readonly default?:\n | {\n readonly kind: 'literal';\n readonly value: unknown;\n }\n | {\n readonly kind: 'function';\n readonly expression: string;\n };\n readonly executionDefault?: unknown;\n readonly id: boolean;\n readonly unique: boolean;\n} {\n return {\n descriptor: resolveAuthoringStorageTypeTemplate(descriptor.output, args),\n nullable: descriptor.output.nullable ?? false,\n ...ifDefined(\n 'default',\n descriptor.output.default !== undefined\n ? resolveAuthoringColumnDefaultTemplate(descriptor.output.default, args)\n : undefined,\n ),\n ...ifDefined(\n 'executionDefault',\n descriptor.output.executionDefault !== undefined\n ? resolveAuthoringTemplateValue(descriptor.output.executionDefault, args)\n : undefined,\n ),\n id: descriptor.output.id ?? false,\n unique: descriptor.output.unique ?? false,\n };\n}\n"],"mappings":";;;AA6FA,SAAgB,kBAAkB,OAA0C;AAC1E,KAAI,OAAO,UAAU,YAAY,UAAU,QAAS,MAA6B,SAAS,MACxF,QAAO;CAET,MAAM,EAAE,OAAO,SAAS;AACxB,KAAI,OAAO,UAAU,YAAY,CAAC,OAAO,UAAU,MAAM,IAAI,QAAQ,EACnE,QAAO;AAET,KAAI,SAAS,WAAc,CAAC,MAAM,QAAQ,KAAK,IAAI,KAAK,MAAM,MAAM,OAAO,MAAM,SAAS,EACxF,QAAO;AAET,QAAO;;AAGT,SAAS,0BAA0B,OAAkD;AACnF,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;AAG7E,SAAgB,qCACd,OAC6C;AAC7C,QACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAS,qBACvC,OAAQ,MAA+B,WAAW,YACjD,MAA+B,WAAW;;AAI/C,SAAgB,iCACd,OACyC;AACzC,QACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA6B,SAAS,iBACvC,OAAQ,MAA+B,WAAW,YACjD,MAA+B,WAAW;;AAI/C,SAAgB,8BACd,UACA,MACS;AACT,KAAI,kBAAkB,SAAS,EAAE;EAC/B,IAAI,QAAQ,KAAK,SAAS;AAE1B,OAAK,MAAM,WAAW,SAAS,QAAQ,EAAE,EAAE;AACzC,OAAI,CAAC,0BAA0B,MAAM,IAAI,CAAC,OAAO,OAAO,OAAO,QAAQ,EAAE;AACvE,YAAQ;AACR;;AAEF,WAAS,MAAkC;;AAG7C,MAAI,UAAU,UAAa,SAAS,YAAY,OAC9C,QAAO,8BAA8B,SAAS,SAAS,KAAK;AAG9D,SAAO;;AAET,KAAI,MAAM,QAAQ,SA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ACA,GAAI,eAAe,SAAY,EAAE,GAAG,EAAE,YAAY;EACnD;;AAGH,SAAS,sCACP,UACA,MASI;AACJ,KAAI,SAAS,SAAS,WAAW;EAC/B,MAAM,QAAQ,8BAA8B,SAAS,OAAO,KAAK;AACjE,MAAI,UAAU,OACZ,OAAM,IAAI,MAAM,2DAA2D;AAE7E,SAAO;GACL,MAAM;GACN;GACD;;CAGH,MAAM,aAAa,8BAA8B,SAAS,YAAY,KAAK;AAC3E,KAAI,eAAe,UAAc,OAAO,eAAe,YAAY,eAAe,KAChF,OAAM,IAAI,MACR,wFAAwF,OAAO,WAAW,GAC3G;AAEH,QAAO;EACL,MAAM;EACN,YAAY,OAAO,WAAW;EAC/B;;AAGH,SAAgB,oCACd,YACA,MAKA;AACA,QAAO,oCAAoC,WAAW,QAAQ,KAAK;;AAGrE,SAAgB,gCACd,YACA,MAoBA;AACA,QAAO;EACL,YAAY,oCAAoC,WAAW,QAAQ,KAAK;EACxE,UAAU,WAAW,OAAO,YAAY;EACxC,GAAG,UACD,WACA,WAAW,OAAO,YAAY,SAC1B,sCAAsC,WAAW,OAAO,SAAS,KAAK,GACtE,OACL;EACD,GAAG,UACD,oBACA,WAAW,OAAO,qBAAqB,SACnC,8BAA8B,WAAW,OAAO,kBAAkB,KAAK,GACvE,OACL;EACD,IAAI,WAAW,OAAO,MAAM;EAC5B,QAAQ,WAAW,OAAO,UAAU;EACrC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { JsonValue } from "@prisma-next/contract/types";
|
|
2
|
+
|
|
3
|
+
//#region src/codec-types.d.ts
|
|
4
|
+
type CodecTrait = 'equality' | 'order' | 'boolean' | 'numeric' | 'textual';
|
|
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
|
+
interface Codec<Id extends string = string, TTraits extends readonly CodecTrait[] = readonly CodecTrait[], TWire = unknown, TJs = unknown> {
|
|
17
|
+
/** Unique codec identifier in `namespace/name@version` format (e.g. `pg/timestamptz@1`). */
|
|
18
|
+
readonly id: Id;
|
|
19
|
+
/** Database-native type names this codec handles (e.g. `['timestamptz']`). */
|
|
20
|
+
readonly targetTypes: readonly string[];
|
|
21
|
+
/** Semantic traits for operator gating (e.g. equality, order, numeric). */
|
|
22
|
+
readonly traits?: TTraits;
|
|
23
|
+
/** Converts a JS value to the wire format expected by the database driver. Optional when the driver accepts the JS type directly. */
|
|
24
|
+
encode?(value: TJs): TWire;
|
|
25
|
+
/** Converts a wire value from the database driver into the JS type. */
|
|
26
|
+
decode(wire: TWire): TJs;
|
|
27
|
+
/** Converts a JS value to a JSON-safe representation for contract serialization. Called during contract emission. */
|
|
28
|
+
encodeJson(value: TJs): JsonValue;
|
|
29
|
+
/** Converts a JSON representation back to the JS type. Called during contract loading via `validateContract`. */
|
|
30
|
+
decodeJson(json: JsonValue): TJs;
|
|
31
|
+
/** Produces the TypeScript output type expression for a field given its `typeParams`. Used during contract.d.ts emission. */
|
|
32
|
+
renderOutputType?(typeParams: Record<string, unknown>): string | undefined;
|
|
33
|
+
}
|
|
34
|
+
interface CodecLookup {
|
|
35
|
+
get(id: string): Codec | undefined;
|
|
36
|
+
}
|
|
37
|
+
declare const emptyCodecLookup: CodecLookup;
|
|
38
|
+
//#endregion
|
|
39
|
+
export { emptyCodecLookup as i, CodecLookup as n, CodecTrait as r, Codec as t };
|
|
40
|
+
//# sourceMappingURL=codec-types-D9ixsdxw.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec-types-D9ixsdxw.d.mts","names":[],"sources":["../src/codec-types.ts"],"sourcesContent":[],"mappings":";;;KAEY,UAAA;;AAAZ;AAaA;;;;;;;;;AAiBoB,UAjBH,KAiBG,CAAA,WAAA,MAAA,GAAA,MAAA,EAAA,gBAAA,SAfO,UAeP,EAAA,GAAA,SAf+B,UAe/B,EAAA,EAAA,QAAA,OAAA,EAAA,MAAA,OAAA,CAAA,CAAA;EAAM;EAEP,SAAA,EAAA,EAZJ,EAYI;EAAY;EAEC,SAAA,WAAA,EAAA,SAAA,MAAA,EAAA;EAAM;EAGrB,SAAA,MAAW,CAAA,EAbR,OAaQ;EAIf;iBAfI,MAAM;;eAER,QAAQ;;oBAEH,MAAM;;mBAEP,YAAY;;gCAEC;;UAGf,WAAA;mBACE;;cAGN,kBAAkB"}
|
package/dist/codec.d.mts
ADDED
package/dist/codec.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codec.mjs","names":["emptyCodecLookup: CodecLookup"],"sources":["../src/codec-types.ts"],"sourcesContent":["import type { JsonValue } from '@prisma-next/contract/types';\n\nexport type CodecTrait = 'equality' | 'order' | 'boolean' | 'numeric' | 'textual';\n\n/**\n * Base codec interface for all target families.\n *\n * A codec maps between three representations of a value:\n * - **JS** (`TJs`): the JavaScript type used in application code\n * - **Wire** (`TWire`): the format sent to/from the database driver\n * - **JSON** (`JsonValue`): the JSON-safe form stored in contract artifacts\n *\n * Family-specific codec interfaces (SQL `Codec`, Mongo `MongoCodec`) extend\n * this base to add family-specific metadata.\n */\nexport interface Codec<\n Id extends string = string,\n TTraits extends readonly CodecTrait[] = readonly CodecTrait[],\n TWire = unknown,\n TJs = unknown,\n> {\n /** Unique codec identifier in `namespace/name@version` format (e.g. `pg/timestamptz@1`). */\n readonly id: Id;\n /** Database-native type names this codec handles (e.g. `['timestamptz']`). */\n readonly targetTypes: readonly string[];\n /** Semantic traits for operator gating (e.g. equality, order, numeric). */\n readonly traits?: TTraits;\n /** Converts a JS value to the wire format expected by the database driver. Optional when the driver accepts the JS type directly. */\n encode?(value: TJs): TWire;\n /** Converts a wire value from the database driver into the JS type. */\n decode(wire: TWire): TJs;\n /** Converts a JS value to a JSON-safe representation for contract serialization. Called during contract emission. */\n encodeJson(value: TJs): JsonValue;\n /** Converts a JSON representation back to the JS type. Called during contract loading via `validateContract`. */\n decodeJson(json: JsonValue): TJs;\n /** Produces the TypeScript output type expression for a field given its `typeParams`. Used during contract.d.ts emission. */\n renderOutputType?(typeParams: Record<string, unknown>): string | undefined;\n}\n\nexport interface CodecLookup {\n get(id: string): Codec | undefined;\n}\n\nexport const emptyCodecLookup: CodecLookup = {\n get: () => undefined,\n};\n"],"mappings":";AA2CA,MAAaA,mBAAgC,EAC3C,WAAW,QACZ"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { S as checkContractComponentRequirements, _ as PackRefBase, a as ComponentMetadata, b as TargetInstance, c as DriverDescriptor, d as ExtensionDescriptor, f as ExtensionInstance, g as FamilyPackRef, h as FamilyInstance, i as ComponentDescriptor, l as DriverInstance, m as FamilyDescriptor, n as AdapterInstance, o as ContractComponentRequirementsCheckInput, p as ExtensionPackRef, r as AdapterPackRef, s as ContractComponentRequirementsCheckResult, t as AdapterDescriptor, u as DriverPackRef, v as TargetBoundComponentDescriptor, x as TargetPackRef, y as TargetDescriptor } from "./framework-components-W-TA8p5-.mjs";
|
|
2
|
+
export { type AdapterDescriptor, type AdapterInstance, type AdapterPackRef, type ComponentDescriptor, type ComponentMetadata, type ContractComponentRequirementsCheckInput, type ContractComponentRequirementsCheckResult, type DriverDescriptor, type DriverInstance, type DriverPackRef, type ExtensionDescriptor, type ExtensionInstance, type ExtensionPackRef, type FamilyDescriptor, type FamilyInstance, type FamilyPackRef, type PackRefBase, type TargetBoundComponentDescriptor, type TargetDescriptor, type TargetInstance, type TargetPackRef, checkContractComponentRequirements };
|