@prisma-next/contract 0.3.0-dev.9 → 0.3.0-dev.90
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/LICENSE +201 -0
- package/README.md +42 -6
- package/dist/framework-components.d.mts +529 -0
- package/dist/framework-components.d.mts.map +1 -0
- package/dist/framework-components.mjs +70 -0
- package/dist/framework-components.mjs.map +1 -0
- package/dist/ir-C9rRU5WS.d.mts +84 -0
- package/dist/ir-C9rRU5WS.d.mts.map +1 -0
- package/dist/ir.d.mts +2 -0
- package/dist/ir.mjs +51 -0
- package/dist/ir.mjs.map +1 -0
- package/dist/types-54JRJq9p.d.mts +395 -0
- package/dist/types-54JRJq9p.d.mts.map +1 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +30 -0
- package/dist/types.mjs.map +1 -0
- package/package.json +24 -28
- package/schemas/data-contract-document-v1.json +9 -4
- package/src/exports/framework-components.ts +10 -1
- package/src/exports/types.ts +31 -7
- package/src/framework-components.ts +179 -46
- package/src/ir.ts +28 -12
- package/src/types.ts +274 -37
- package/dist/exports/framework-components.d.ts +0 -3
- package/dist/exports/framework-components.d.ts.map +0 -1
- package/dist/exports/framework-components.js +0 -24
- package/dist/exports/framework-components.js.map +0 -1
- package/dist/exports/ir.d.ts +0 -2
- package/dist/exports/ir.d.ts.map +0 -1
- package/dist/exports/ir.js +0 -35
- package/dist/exports/ir.js.map +0 -1
- package/dist/exports/pack-manifest-types.d.ts +0 -2
- package/dist/exports/pack-manifest-types.d.ts.map +0 -1
- package/dist/exports/pack-manifest-types.js +0 -1
- package/dist/exports/pack-manifest-types.js.map +0 -1
- package/dist/exports/types.d.ts +0 -3
- package/dist/exports/types.d.ts.map +0 -1
- package/dist/exports/types.js +0 -8
- package/dist/exports/types.js.map +0 -1
- package/dist/framework-components.d.ts +0 -408
- package/dist/framework-components.d.ts.map +0 -1
- package/dist/ir.d.ts +0 -76
- package/dist/ir.d.ts.map +0 -1
- package/dist/types.d.ts +0 -222
- package/dist/types.d.ts.map +0 -1
- package/src/exports/pack-manifest-types.ts +0 -6
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
//#region src/ir.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* ContractIR types and factories for building contract intermediate representation.
|
|
4
|
+
* ContractIR is family-agnostic and used by authoring, emitter, and no-emit runtime.
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* ContractIR represents the intermediate representation of a contract.
|
|
8
|
+
* It is family-agnostic and contains generic storage, models, and relations.
|
|
9
|
+
* Note: storageHash/executionHash and profileHash are computed by the emitter, not part of the IR.
|
|
10
|
+
*/
|
|
11
|
+
interface ContractIR<TStorage extends Record<string, unknown> = Record<string, unknown>, TModels extends Record<string, unknown> = Record<string, unknown>, TRelations extends Record<string, unknown> = Record<string, unknown>, TExecution extends Record<string, unknown> = Record<string, unknown>> {
|
|
12
|
+
readonly schemaVersion: string;
|
|
13
|
+
readonly targetFamily: string;
|
|
14
|
+
readonly target: string;
|
|
15
|
+
readonly models: TModels;
|
|
16
|
+
readonly relations: TRelations;
|
|
17
|
+
readonly storage: TStorage;
|
|
18
|
+
readonly execution?: TExecution;
|
|
19
|
+
readonly extensionPacks: Record<string, unknown>;
|
|
20
|
+
readonly capabilities: Record<string, Record<string, boolean>>;
|
|
21
|
+
readonly meta: Record<string, unknown>;
|
|
22
|
+
readonly sources: Record<string, unknown>;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Creates the header portion of a ContractIR.
|
|
26
|
+
* Contains schema version, target, target family, storage hash, and optional profile hash.
|
|
27
|
+
*/
|
|
28
|
+
declare function irHeader(opts: {
|
|
29
|
+
target: string;
|
|
30
|
+
targetFamily: string;
|
|
31
|
+
storageHash: string;
|
|
32
|
+
executionHash?: string | undefined;
|
|
33
|
+
profileHash?: string | undefined;
|
|
34
|
+
}): {
|
|
35
|
+
readonly schemaVersion: string;
|
|
36
|
+
readonly target: string;
|
|
37
|
+
readonly targetFamily: string;
|
|
38
|
+
readonly storageHash: string;
|
|
39
|
+
readonly executionHash?: string | undefined;
|
|
40
|
+
readonly profileHash?: string | undefined;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Creates the meta portion of a ContractIR.
|
|
44
|
+
* Contains capabilities, extensionPacks, meta, and sources with empty object defaults.
|
|
45
|
+
* If a field is explicitly `undefined`, it will be omitted (for testing validation).
|
|
46
|
+
*/
|
|
47
|
+
declare function irMeta(opts?: {
|
|
48
|
+
capabilities?: Record<string, Record<string, boolean>> | undefined;
|
|
49
|
+
extensionPacks?: Record<string, unknown> | undefined;
|
|
50
|
+
meta?: Record<string, unknown> | undefined;
|
|
51
|
+
sources?: Record<string, unknown> | undefined;
|
|
52
|
+
}): {
|
|
53
|
+
readonly capabilities: Record<string, Record<string, boolean>>;
|
|
54
|
+
readonly extensionPacks: Record<string, unknown>;
|
|
55
|
+
readonly meta: Record<string, unknown>;
|
|
56
|
+
readonly sources: Record<string, unknown>;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Creates a complete ContractIR by combining header, meta, and family-specific sections.
|
|
60
|
+
* This is a family-agnostic factory that accepts generic storage, models, and relations.
|
|
61
|
+
*/
|
|
62
|
+
declare function contractIR<TStorage extends Record<string, unknown>, TModels extends Record<string, unknown>, TRelations extends Record<string, unknown>, TExecution extends Record<string, unknown>>(opts: {
|
|
63
|
+
header: {
|
|
64
|
+
readonly schemaVersion: string;
|
|
65
|
+
readonly target: string;
|
|
66
|
+
readonly targetFamily: string;
|
|
67
|
+
readonly storageHash: string;
|
|
68
|
+
readonly executionHash?: string | undefined;
|
|
69
|
+
readonly profileHash?: string | undefined;
|
|
70
|
+
};
|
|
71
|
+
meta: {
|
|
72
|
+
readonly capabilities: Record<string, Record<string, boolean>>;
|
|
73
|
+
readonly extensionPacks: Record<string, unknown>;
|
|
74
|
+
readonly meta: Record<string, unknown>;
|
|
75
|
+
readonly sources: Record<string, unknown>;
|
|
76
|
+
};
|
|
77
|
+
storage: TStorage;
|
|
78
|
+
models: TModels;
|
|
79
|
+
relations: TRelations;
|
|
80
|
+
execution?: TExecution;
|
|
81
|
+
}): ContractIR<TStorage, TModels, TRelations, TExecution>;
|
|
82
|
+
//#endregion
|
|
83
|
+
export { irMeta as i, contractIR as n, irHeader as r, ContractIR as t };
|
|
84
|
+
//# sourceMappingURL=ir-C9rRU5WS.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir-C9rRU5WS.d.mts","names":[],"sources":["../src/ir.ts"],"sourcesContent":[],"mappings":";;AAiBA;;;;;;;;AAI+C,UAJ9B,UAI8B,CAAA,iBAH5B,MAG4B,CAAA,MAAA,EAAA,OAAA,CAAA,GAHF,MAGE,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,gBAF7B,MAE6B,CAAA,MAAA,EAAA,OAAA,CAAA,GAFH,MAEG,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,mBAD1B,MAC0B,CAAA,MAAA,EAAA,OAAA,CAAA,GADA,MACA,CAAA,MAAA,EAAA,OAAA,CAAA,EAAA,mBAA1B,MAA0B,CAAA,MAAA,EAAA,OAAA,CAAA,GAAA,MAAA,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA,CAAA;EAK5B,SAAA,aAAA,EAAA,MAAA;EACG,SAAA,YAAA,EAAA,MAAA;EACF,SAAA,MAAA,EAAA,MAAA;EACG,SAAA,MAAA,EAHJ,OAGI;EACI,SAAA,SAAA,EAHL,UAGK;EACa,SAAA,OAAA,EAHpB,QAGoB;EAAf,SAAA,SAAA,CAAA,EAFF,UAEE;EACR,SAAA,cAAA,EAFU,MAEV,CAAA,MAAA,EAAA,OAAA,CAAA;EACG,SAAA,YAAA,EAFK,MAEL,CAAA,MAAA,EAFoB,MAEpB,CAAA,MAAA,EAAA,OAAA,CAAA,CAAA;EAAM,SAAA,IAAA,EADT,MACS,CAAA,MAAA,EAAA,OAAA,CAAA;EAOV,SAAA,OAAQ,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
package/dist/ir.mjs
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
//#region src/ir.ts
|
|
2
|
+
function ifDefined(key, value) {
|
|
3
|
+
return value !== void 0 ? { [key]: value } : {};
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Creates the header portion of a ContractIR.
|
|
7
|
+
* Contains schema version, target, target family, storage hash, and optional profile hash.
|
|
8
|
+
*/
|
|
9
|
+
function irHeader(opts) {
|
|
10
|
+
return {
|
|
11
|
+
schemaVersion: "1",
|
|
12
|
+
target: opts.target,
|
|
13
|
+
targetFamily: opts.targetFamily,
|
|
14
|
+
storageHash: opts.storageHash,
|
|
15
|
+
...ifDefined("executionHash", opts.executionHash),
|
|
16
|
+
...ifDefined("profileHash", opts.profileHash)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates the meta portion of a ContractIR.
|
|
21
|
+
* Contains capabilities, extensionPacks, meta, and sources with empty object defaults.
|
|
22
|
+
* If a field is explicitly `undefined`, it will be omitted (for testing validation).
|
|
23
|
+
*/
|
|
24
|
+
function irMeta(opts) {
|
|
25
|
+
return {
|
|
26
|
+
capabilities: opts?.capabilities ?? {},
|
|
27
|
+
extensionPacks: opts?.extensionPacks ?? {},
|
|
28
|
+
meta: opts?.meta ?? {},
|
|
29
|
+
sources: opts?.sources ?? {}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Creates a complete ContractIR by combining header, meta, and family-specific sections.
|
|
34
|
+
* This is a family-agnostic factory that accepts generic storage, models, and relations.
|
|
35
|
+
*/
|
|
36
|
+
function contractIR(opts) {
|
|
37
|
+
return {
|
|
38
|
+
schemaVersion: opts.header.schemaVersion,
|
|
39
|
+
target: opts.header.target,
|
|
40
|
+
targetFamily: opts.header.targetFamily,
|
|
41
|
+
...opts.meta,
|
|
42
|
+
storage: opts.storage,
|
|
43
|
+
models: opts.models,
|
|
44
|
+
relations: opts.relations,
|
|
45
|
+
...ifDefined("execution", opts.execution)
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
//#endregion
|
|
50
|
+
export { contractIR, irHeader, irMeta };
|
|
51
|
+
//# sourceMappingURL=ir.mjs.map
|
package/dist/ir.mjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ir.mjs","names":[],"sources":["../src/ir.ts"],"sourcesContent":["function ifDefined<K extends string, V>(\n key: K,\n value: V | undefined,\n): Record<never, never> | { [P in K]: V } {\n return value !== undefined ? ({ [key]: value } as { [P in K]: V }) : {};\n}\n\n/**\n * ContractIR types and factories for building contract intermediate representation.\n * ContractIR is family-agnostic and used by authoring, emitter, and no-emit runtime.\n */\n\n/**\n * ContractIR represents the intermediate representation of a contract.\n * It is family-agnostic and contains generic storage, models, and relations.\n * Note: storageHash/executionHash and profileHash are computed by the emitter, not part of the IR.\n */\nexport interface ContractIR<\n TStorage extends Record<string, unknown> = Record<string, unknown>,\n TModels extends Record<string, unknown> = Record<string, unknown>,\n TRelations extends Record<string, unknown> = Record<string, unknown>,\n TExecution extends Record<string, unknown> = Record<string, unknown>,\n> {\n readonly schemaVersion: string;\n readonly targetFamily: string;\n readonly target: string;\n readonly models: TModels;\n readonly relations: TRelations;\n readonly storage: TStorage;\n readonly execution?: TExecution;\n readonly extensionPacks: Record<string, unknown>;\n readonly capabilities: Record<string, Record<string, boolean>>;\n readonly meta: Record<string, unknown>;\n readonly sources: Record<string, unknown>;\n}\n\n/**\n * Creates the header portion of a ContractIR.\n * Contains schema version, target, target family, storage hash, and optional profile hash.\n */\nexport function irHeader(opts: {\n target: string;\n targetFamily: string;\n storageHash: string;\n executionHash?: string | undefined;\n profileHash?: string | undefined;\n}): {\n readonly schemaVersion: string;\n readonly target: string;\n readonly targetFamily: string;\n readonly storageHash: string;\n readonly executionHash?: string | undefined;\n readonly profileHash?: string | undefined;\n} {\n return {\n schemaVersion: '1',\n target: opts.target,\n targetFamily: opts.targetFamily,\n storageHash: opts.storageHash,\n ...ifDefined('executionHash', opts.executionHash),\n ...ifDefined('profileHash', opts.profileHash),\n };\n}\n\n/**\n * Creates the meta portion of a ContractIR.\n * Contains capabilities, extensionPacks, meta, and sources with empty object defaults.\n * If a field is explicitly `undefined`, it will be omitted (for testing validation).\n */\nexport function irMeta(opts?: {\n capabilities?: Record<string, Record<string, boolean>> | undefined;\n extensionPacks?: Record<string, unknown> | undefined;\n meta?: Record<string, unknown> | undefined;\n sources?: Record<string, unknown> | undefined;\n}): {\n readonly capabilities: Record<string, Record<string, boolean>>;\n readonly extensionPacks: Record<string, unknown>;\n readonly meta: Record<string, unknown>;\n readonly sources: Record<string, unknown>;\n} {\n return {\n capabilities: opts?.capabilities ?? {},\n extensionPacks: opts?.extensionPacks ?? {},\n meta: opts?.meta ?? {},\n sources: opts?.sources ?? {},\n };\n}\n\n/**\n * Creates a complete ContractIR by combining header, meta, and family-specific sections.\n * This is a family-agnostic factory that accepts generic storage, models, and relations.\n */\nexport function contractIR<\n TStorage extends Record<string, unknown>,\n TModels extends Record<string, unknown>,\n TRelations extends Record<string, unknown>,\n TExecution extends Record<string, unknown>,\n>(opts: {\n header: {\n readonly schemaVersion: string;\n readonly target: string;\n readonly targetFamily: string;\n readonly storageHash: string;\n readonly executionHash?: string | undefined;\n readonly profileHash?: string | undefined;\n };\n meta: {\n readonly capabilities: Record<string, Record<string, boolean>>;\n readonly extensionPacks: Record<string, unknown>;\n readonly meta: Record<string, unknown>;\n readonly sources: Record<string, unknown>;\n };\n storage: TStorage;\n models: TModels;\n relations: TRelations;\n execution?: TExecution;\n}): ContractIR<TStorage, TModels, TRelations, TExecution> {\n // ContractIR doesn't include storageHash/executionHash or profileHash (those are computed by emitter)\n return {\n schemaVersion: opts.header.schemaVersion,\n target: opts.header.target,\n targetFamily: opts.header.targetFamily,\n ...opts.meta,\n storage: opts.storage,\n models: opts.models,\n relations: opts.relations,\n ...ifDefined('execution', opts.execution),\n };\n}\n"],"mappings":";AAAA,SAAS,UACP,KACA,OACwC;AACxC,QAAO,UAAU,SAAa,GAAG,MAAM,OAAO,GAAuB,EAAE;;;;;;AAoCzE,SAAgB,SAAS,MAavB;AACA,QAAO;EACL,eAAe;EACf,QAAQ,KAAK;EACb,cAAc,KAAK;EACnB,aAAa,KAAK;EAClB,GAAG,UAAU,iBAAiB,KAAK,cAAc;EACjD,GAAG,UAAU,eAAe,KAAK,YAAY;EAC9C;;;;;;;AAQH,SAAgB,OAAO,MAUrB;AACA,QAAO;EACL,cAAc,MAAM,gBAAgB,EAAE;EACtC,gBAAgB,MAAM,kBAAkB,EAAE;EAC1C,MAAM,MAAM,QAAQ,EAAE;EACtB,SAAS,MAAM,WAAW,EAAE;EAC7B;;;;;;AAOH,SAAgB,WAKd,MAmBwD;AAExD,QAAO;EACL,eAAe,KAAK,OAAO;EAC3B,QAAQ,KAAK,OAAO;EACpB,cAAc,KAAK,OAAO;EAC1B,GAAG,KAAK;EACR,SAAS,KAAK;EACd,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,GAAG,UAAU,aAAa,KAAK,UAAU;EAC1C"}
|
|
@@ -0,0 +1,395 @@
|
|
|
1
|
+
import { t as ContractIR } from "./ir-C9rRU5WS.mjs";
|
|
2
|
+
import { OperationRegistry } from "@prisma-next/operations";
|
|
3
|
+
|
|
4
|
+
//#region src/types.d.ts
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Unique symbol used as the key for branding types.
|
|
8
|
+
*/
|
|
9
|
+
declare const $: unique symbol;
|
|
10
|
+
/**
|
|
11
|
+
* A helper type to brand a given type with a unique identifier.
|
|
12
|
+
*
|
|
13
|
+
* @template TKey Text used as the brand key.
|
|
14
|
+
* @template TValue Optional value associated with the brand key. Defaults to `true`.
|
|
15
|
+
*/
|
|
16
|
+
type Brand<TKey extends string | number | symbol, TValue = true> = {
|
|
17
|
+
[$]: { [K in TKey]: TValue };
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Context passed to type renderers during contract.d.ts generation.
|
|
21
|
+
*/
|
|
22
|
+
interface RenderTypeContext {
|
|
23
|
+
/** The name of the CodecTypes type alias (typically 'CodecTypes') */
|
|
24
|
+
readonly codecTypesName: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Base type for storage contract hashes.
|
|
28
|
+
* Emitted contract.d.ts files use this with the hash value as a type parameter:
|
|
29
|
+
* `type StorageHash = StorageHashBase<'sha256:abc123...'>`
|
|
30
|
+
*/
|
|
31
|
+
type StorageHashBase<THash extends string> = THash & Brand<'StorageHash'>;
|
|
32
|
+
/**
|
|
33
|
+
* Base type for execution contract hashes.
|
|
34
|
+
* Emitted contract.d.ts files use this with the hash value as a type parameter:
|
|
35
|
+
* `type ExecutionHash = ExecutionHashBase<'sha256:def456...'>`
|
|
36
|
+
*/
|
|
37
|
+
type ExecutionHashBase<THash extends string> = THash & Brand<'ExecutionHash'>;
|
|
38
|
+
declare function coreHash<const T extends string>(value: T): StorageHashBase<T>;
|
|
39
|
+
/**
|
|
40
|
+
* Base type for profile contract hashes.
|
|
41
|
+
* Emitted contract.d.ts files use this with the hash value as a type parameter:
|
|
42
|
+
* `type ProfileHash = ProfileHashBase<'sha256:def456...'>`
|
|
43
|
+
*/
|
|
44
|
+
type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;
|
|
45
|
+
declare function profileHash<const T extends string>(value: T): ProfileHashBase<T>;
|
|
46
|
+
interface ContractBase<TStorageHash extends StorageHashBase<string> = StorageHashBase<string>, TExecutionHash extends ExecutionHashBase<string> = ExecutionHashBase<string>, TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>> {
|
|
47
|
+
readonly schemaVersion: string;
|
|
48
|
+
readonly target: string;
|
|
49
|
+
readonly targetFamily: string;
|
|
50
|
+
readonly storageHash: TStorageHash;
|
|
51
|
+
readonly executionHash?: TExecutionHash | undefined;
|
|
52
|
+
readonly profileHash?: TProfileHash | undefined;
|
|
53
|
+
readonly capabilities: Record<string, Record<string, boolean>>;
|
|
54
|
+
readonly extensionPacks: Record<string, unknown>;
|
|
55
|
+
readonly meta: Record<string, unknown>;
|
|
56
|
+
readonly sources: Record<string, Source>;
|
|
57
|
+
readonly execution?: ExecutionSection;
|
|
58
|
+
}
|
|
59
|
+
interface FieldType {
|
|
60
|
+
readonly type: string;
|
|
61
|
+
readonly nullable: boolean;
|
|
62
|
+
readonly items?: FieldType;
|
|
63
|
+
readonly properties?: Record<string, FieldType>;
|
|
64
|
+
}
|
|
65
|
+
type GeneratedValueSpec = {
|
|
66
|
+
readonly id: string;
|
|
67
|
+
readonly params?: Record<string, unknown>;
|
|
68
|
+
};
|
|
69
|
+
type JsonPrimitive = string | number | boolean | null;
|
|
70
|
+
type JsonValue = JsonPrimitive | {
|
|
71
|
+
readonly [key: string]: JsonValue;
|
|
72
|
+
} | readonly JsonValue[];
|
|
73
|
+
type TaggedBigInt = {
|
|
74
|
+
readonly $type: 'bigint';
|
|
75
|
+
readonly value: string;
|
|
76
|
+
};
|
|
77
|
+
declare function isTaggedBigInt(value: unknown): value is TaggedBigInt;
|
|
78
|
+
declare function bigintJsonReplacer(_key: string, value: unknown): unknown;
|
|
79
|
+
type TaggedRaw = {
|
|
80
|
+
readonly $type: 'raw';
|
|
81
|
+
readonly value: JsonValue;
|
|
82
|
+
};
|
|
83
|
+
declare function isTaggedRaw(value: unknown): value is TaggedRaw;
|
|
84
|
+
type TaggedLiteralValue = TaggedBigInt | TaggedRaw;
|
|
85
|
+
type ColumnDefaultLiteralValue = JsonValue | TaggedLiteralValue;
|
|
86
|
+
type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | bigint | Date;
|
|
87
|
+
type ColumnDefault = {
|
|
88
|
+
readonly kind: 'literal';
|
|
89
|
+
readonly value: ColumnDefaultLiteralInputValue;
|
|
90
|
+
} | {
|
|
91
|
+
readonly kind: 'function';
|
|
92
|
+
readonly expression: string;
|
|
93
|
+
};
|
|
94
|
+
type ExecutionMutationDefaultValue = {
|
|
95
|
+
readonly kind: 'generator';
|
|
96
|
+
readonly id: GeneratedValueSpec['id'];
|
|
97
|
+
readonly params?: Record<string, unknown>;
|
|
98
|
+
};
|
|
99
|
+
type ExecutionMutationDefault = {
|
|
100
|
+
readonly ref: {
|
|
101
|
+
readonly table: string;
|
|
102
|
+
readonly column: string;
|
|
103
|
+
};
|
|
104
|
+
readonly onCreate?: ExecutionMutationDefaultValue;
|
|
105
|
+
readonly onUpdate?: ExecutionMutationDefaultValue;
|
|
106
|
+
};
|
|
107
|
+
type ExecutionSection = {
|
|
108
|
+
readonly mutations: {
|
|
109
|
+
readonly defaults: ReadonlyArray<ExecutionMutationDefault>;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
interface Source {
|
|
113
|
+
readonly readOnly: boolean;
|
|
114
|
+
readonly projection: Record<string, FieldType>;
|
|
115
|
+
readonly origin?: Record<string, unknown>;
|
|
116
|
+
readonly capabilities?: Record<string, boolean>;
|
|
117
|
+
}
|
|
118
|
+
interface DocIndex {
|
|
119
|
+
readonly name: string;
|
|
120
|
+
readonly keys: Record<string, 'asc' | 'desc'>;
|
|
121
|
+
readonly unique?: boolean;
|
|
122
|
+
readonly where?: Expr;
|
|
123
|
+
}
|
|
124
|
+
type Expr = {
|
|
125
|
+
readonly kind: 'eq';
|
|
126
|
+
readonly path: ReadonlyArray<string>;
|
|
127
|
+
readonly value: unknown;
|
|
128
|
+
} | {
|
|
129
|
+
readonly kind: 'exists';
|
|
130
|
+
readonly path: ReadonlyArray<string>;
|
|
131
|
+
};
|
|
132
|
+
interface DocCollection {
|
|
133
|
+
readonly name: string;
|
|
134
|
+
readonly id?: {
|
|
135
|
+
readonly strategy: 'auto' | 'client' | 'uuid' | 'objectId';
|
|
136
|
+
};
|
|
137
|
+
readonly fields: Record<string, FieldType>;
|
|
138
|
+
readonly indexes?: ReadonlyArray<DocIndex>;
|
|
139
|
+
readonly readOnly?: boolean;
|
|
140
|
+
}
|
|
141
|
+
interface DocumentStorage {
|
|
142
|
+
readonly document: {
|
|
143
|
+
readonly collections: Record<string, DocCollection>;
|
|
144
|
+
};
|
|
145
|
+
}
|
|
146
|
+
interface DocumentContract<TStorageHash extends StorageHashBase<string> = StorageHashBase<string>, TExecutionHash extends ExecutionHashBase<string> = ExecutionHashBase<string>, TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>> extends ContractBase<TStorageHash, TExecutionHash, TProfileHash> {
|
|
147
|
+
readonly targetFamily: string;
|
|
148
|
+
readonly storage: DocumentStorage;
|
|
149
|
+
}
|
|
150
|
+
interface ParamDescriptor {
|
|
151
|
+
readonly index?: number;
|
|
152
|
+
readonly name?: string;
|
|
153
|
+
readonly codecId?: string;
|
|
154
|
+
readonly nativeType?: string;
|
|
155
|
+
readonly nullable?: boolean;
|
|
156
|
+
readonly source: 'dsl' | 'raw' | 'lane';
|
|
157
|
+
readonly refs?: {
|
|
158
|
+
table: string;
|
|
159
|
+
column: string;
|
|
160
|
+
};
|
|
161
|
+
}
|
|
162
|
+
interface PlanRefs {
|
|
163
|
+
readonly tables?: readonly string[];
|
|
164
|
+
readonly columns?: ReadonlyArray<{
|
|
165
|
+
table: string;
|
|
166
|
+
column: string;
|
|
167
|
+
}>;
|
|
168
|
+
readonly indexes?: ReadonlyArray<{
|
|
169
|
+
readonly table: string;
|
|
170
|
+
readonly columns: ReadonlyArray<string>;
|
|
171
|
+
readonly name?: string;
|
|
172
|
+
}>;
|
|
173
|
+
}
|
|
174
|
+
interface PlanMeta {
|
|
175
|
+
readonly target: string;
|
|
176
|
+
readonly targetFamily?: string;
|
|
177
|
+
readonly storageHash: string;
|
|
178
|
+
readonly profileHash?: string;
|
|
179
|
+
readonly lane: string;
|
|
180
|
+
readonly annotations?: {
|
|
181
|
+
codecs?: Record<string, string>;
|
|
182
|
+
[key: string]: unknown;
|
|
183
|
+
};
|
|
184
|
+
readonly paramDescriptors: ReadonlyArray<ParamDescriptor>;
|
|
185
|
+
readonly refs?: PlanRefs;
|
|
186
|
+
readonly projection?: Record<string, string> | ReadonlyArray<string>;
|
|
187
|
+
/**
|
|
188
|
+
* Optional mapping of projection alias → column type ID (fully qualified ns/name@version).
|
|
189
|
+
* Used for codec resolution when AST+refs don't provide enough type info.
|
|
190
|
+
*/
|
|
191
|
+
readonly projectionTypes?: Record<string, string>;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Canonical execution plan shape used by runtimes.
|
|
195
|
+
*
|
|
196
|
+
* - Row is the inferred result row type (TypeScript-only).
|
|
197
|
+
* - Ast is the optional, family-specific AST type (e.g. SQL QueryAst).
|
|
198
|
+
*
|
|
199
|
+
* The payload executed by the runtime is represented by the sql + params pair
|
|
200
|
+
* for now; future families can specialize this via Ast or additional metadata.
|
|
201
|
+
*/
|
|
202
|
+
interface ExecutionPlan<Row = unknown, Ast = unknown> {
|
|
203
|
+
readonly sql: string;
|
|
204
|
+
readonly params: readonly unknown[];
|
|
205
|
+
readonly ast?: Ast;
|
|
206
|
+
readonly meta: PlanMeta;
|
|
207
|
+
/**
|
|
208
|
+
* Phantom property to carry the Row generic for type-level utilities.
|
|
209
|
+
* Not set at runtime; used only for ResultType extraction.
|
|
210
|
+
*/
|
|
211
|
+
readonly _row?: Row;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Utility type to extract the Row type from an ExecutionPlan.
|
|
215
|
+
* Example: `type Row = ResultType<typeof plan>`
|
|
216
|
+
*
|
|
217
|
+
* Works with both ExecutionPlan and SqlQueryPlan (SQL query plans before lowering).
|
|
218
|
+
* SqlQueryPlan includes a phantom `_Row` property to preserve the generic parameter
|
|
219
|
+
* for type extraction.
|
|
220
|
+
*/
|
|
221
|
+
type ResultType<P> = P extends ExecutionPlan<infer R, unknown> ? R : P extends {
|
|
222
|
+
readonly _Row?: infer R;
|
|
223
|
+
} ? R : never;
|
|
224
|
+
/**
|
|
225
|
+
* Type guard to check if a contract is a Document contract
|
|
226
|
+
*/
|
|
227
|
+
declare function isDocumentContract(contract: unknown): contract is DocumentContract;
|
|
228
|
+
/**
|
|
229
|
+
* Contract marker record stored in the database.
|
|
230
|
+
* Represents the current contract identity for a database.
|
|
231
|
+
*/
|
|
232
|
+
interface ContractMarkerRecord {
|
|
233
|
+
readonly storageHash: string;
|
|
234
|
+
readonly profileHash: string;
|
|
235
|
+
readonly contractJson: unknown | null;
|
|
236
|
+
readonly canonicalVersion: number | null;
|
|
237
|
+
readonly updatedAt: Date;
|
|
238
|
+
readonly appTag: string | null;
|
|
239
|
+
readonly meta: Record<string, unknown>;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Specifies how to import TypeScript types from a package.
|
|
243
|
+
* Used in extension pack manifests to declare codec and operation type imports.
|
|
244
|
+
*/
|
|
245
|
+
interface TypesImportSpec {
|
|
246
|
+
readonly package: string;
|
|
247
|
+
readonly named: string;
|
|
248
|
+
readonly alias: string;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Validation context passed to TargetFamilyHook.validateTypes().
|
|
252
|
+
* Contains pre-assembled operation registry, type imports, and extension IDs.
|
|
253
|
+
*/
|
|
254
|
+
interface ValidationContext {
|
|
255
|
+
readonly operationRegistry?: OperationRegistry;
|
|
256
|
+
readonly codecTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
257
|
+
readonly operationTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
258
|
+
readonly extensionIds?: ReadonlyArray<string>;
|
|
259
|
+
/**
|
|
260
|
+
* Parameterized codec descriptors collected from adapters and extensions.
|
|
261
|
+
* Map of codecId → descriptor for quick lookup during type generation.
|
|
262
|
+
*/
|
|
263
|
+
readonly parameterizedCodecs?: Map<string, ParameterizedCodecDescriptor>;
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Context for rendering parameterized types during contract.d.ts generation.
|
|
267
|
+
* Passed to type renderers so they can reference CodecTypes by name.
|
|
268
|
+
*/
|
|
269
|
+
interface TypeRenderContext {
|
|
270
|
+
readonly codecTypesName: string;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* A normalized type renderer for parameterized codecs.
|
|
274
|
+
* This is the interface expected by TargetFamilyHook.generateContractTypes.
|
|
275
|
+
*/
|
|
276
|
+
interface TypeRenderEntry {
|
|
277
|
+
readonly codecId: string;
|
|
278
|
+
readonly render: (params: Record<string, unknown>, ctx: TypeRenderContext) => string;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Additional options for generateContractTypes.
|
|
282
|
+
*/
|
|
283
|
+
interface GenerateContractTypesOptions {
|
|
284
|
+
/**
|
|
285
|
+
* Normalized parameterized type renderers, keyed by codecId.
|
|
286
|
+
* When a column has typeParams and a renderer exists for its codecId,
|
|
287
|
+
* the renderer is called to produce the TypeScript type expression.
|
|
288
|
+
*/
|
|
289
|
+
readonly parameterizedRenderers?: Map<string, TypeRenderEntry>;
|
|
290
|
+
/**
|
|
291
|
+
* Type imports for parameterized codecs.
|
|
292
|
+
* These are merged with codec and operation type imports in contract.d.ts.
|
|
293
|
+
*/
|
|
294
|
+
readonly parameterizedTypeImports?: ReadonlyArray<TypesImportSpec>;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* SPI interface for target family hooks that extend emission behavior.
|
|
298
|
+
* Implemented by family-specific emitter hooks (e.g., SQL family).
|
|
299
|
+
*/
|
|
300
|
+
interface TargetFamilyHook {
|
|
301
|
+
readonly id: string;
|
|
302
|
+
/**
|
|
303
|
+
* Validates that all type IDs in the contract come from referenced extension packs.
|
|
304
|
+
* @param ir - Contract IR to validate
|
|
305
|
+
* @param ctx - Validation context with operation registry and extension IDs
|
|
306
|
+
*/
|
|
307
|
+
validateTypes(ir: ContractIR, ctx: ValidationContext): void;
|
|
308
|
+
/**
|
|
309
|
+
* Validates family-specific contract structure.
|
|
310
|
+
* @param ir - Contract IR to validate
|
|
311
|
+
*/
|
|
312
|
+
validateStructure(ir: ContractIR): void;
|
|
313
|
+
/**
|
|
314
|
+
* Generates contract.d.ts file content.
|
|
315
|
+
* @param ir - Contract IR
|
|
316
|
+
* @param codecTypeImports - Array of codec type import specs
|
|
317
|
+
* @param operationTypeImports - Array of operation type import specs
|
|
318
|
+
* @param hashes - Contract hash values (storageHash, executionHash, profileHash)
|
|
319
|
+
* @param options - Additional options including parameterized type renderers
|
|
320
|
+
* @returns Generated TypeScript type definitions as string
|
|
321
|
+
*/
|
|
322
|
+
generateContractTypes(ir: ContractIR, codecTypeImports: ReadonlyArray<TypesImportSpec>, operationTypeImports: ReadonlyArray<TypesImportSpec>, hashes: {
|
|
323
|
+
readonly storageHash: string;
|
|
324
|
+
readonly executionHash?: string;
|
|
325
|
+
readonly profileHash: string;
|
|
326
|
+
}, options?: GenerateContractTypesOptions): string;
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* Declarative type renderer that produces a TypeScript type expression.
|
|
330
|
+
*
|
|
331
|
+
* Renderers can be:
|
|
332
|
+
* - A template string with `{{paramName}}` placeholders (e.g., `Vector<{{length}}>`)
|
|
333
|
+
* - A function that receives typeParams and context and returns a type expression
|
|
334
|
+
*
|
|
335
|
+
* **Prefer template strings** for most cases:
|
|
336
|
+
* - Templates are JSON-serializable (safe for pack-ref metadata)
|
|
337
|
+
* - Templates can be statically analyzed by tooling
|
|
338
|
+
*
|
|
339
|
+
* Function renderers are allowed but have tradeoffs:
|
|
340
|
+
* - Require runtime execution during emission (the emitter runs code)
|
|
341
|
+
* - Not JSON-serializable (can't be stored in contract.json)
|
|
342
|
+
* - The emitted artifacts (contract.json, contract.d.ts) still contain no
|
|
343
|
+
* executable code - this constraint applies to outputs, not the emission process
|
|
344
|
+
*/
|
|
345
|
+
type TypeRenderer = string | ((params: Record<string, unknown>, ctx: RenderTypeContext) => string);
|
|
346
|
+
/**
|
|
347
|
+
* Descriptor for a codec that supports type parameters.
|
|
348
|
+
*
|
|
349
|
+
* Parameterized codecs allow columns to carry additional metadata (typeParams)
|
|
350
|
+
* that affects the generated TypeScript types. For example:
|
|
351
|
+
* - A vector codec can use `{ length: 1536 }` to generate `Vector<1536>`
|
|
352
|
+
* - A decimal codec can use `{ precision: 10, scale: 2 }` to generate `Decimal<10, 2>`
|
|
353
|
+
*
|
|
354
|
+
* The SQL family emitter uses these descriptors to generate precise types
|
|
355
|
+
* without hard-coding knowledge of specific codec IDs.
|
|
356
|
+
*
|
|
357
|
+
* @example
|
|
358
|
+
* ```typescript
|
|
359
|
+
* const vectorCodecDescriptor: ParameterizedCodecDescriptor = {
|
|
360
|
+
* codecId: 'pg/vector@1',
|
|
361
|
+
* outputTypeRenderer: 'Vector<{{length}}>',
|
|
362
|
+
* // Optional: paramsSchema for runtime validation
|
|
363
|
+
* };
|
|
364
|
+
* ```
|
|
365
|
+
*/
|
|
366
|
+
interface ParameterizedCodecDescriptor {
|
|
367
|
+
/** The codec ID this descriptor applies to (e.g., 'pg/vector@1') */
|
|
368
|
+
readonly codecId: string;
|
|
369
|
+
/**
|
|
370
|
+
* Renderer for the output (read) type.
|
|
371
|
+
* Can be a template string or function.
|
|
372
|
+
*
|
|
373
|
+
* This is the primary renderer used by SQL emission to generate
|
|
374
|
+
* model field types in contract.d.ts.
|
|
375
|
+
*/
|
|
376
|
+
readonly outputTypeRenderer: TypeRenderer;
|
|
377
|
+
/**
|
|
378
|
+
* Optional renderer for the input (write) type.
|
|
379
|
+
* If not provided, outputTypeRenderer is used for both.
|
|
380
|
+
*
|
|
381
|
+
* **Reserved for future use**: Currently, SQL emission only uses
|
|
382
|
+
* outputTypeRenderer. This field is defined for future support of
|
|
383
|
+
* asymmetric codecs where input and output types differ (e.g., a
|
|
384
|
+
* codec that accepts `string | number` but always returns `number`).
|
|
385
|
+
*/
|
|
386
|
+
readonly inputTypeRenderer?: TypeRenderer;
|
|
387
|
+
/**
|
|
388
|
+
* Optional import spec for types used by this codec's renderers.
|
|
389
|
+
* The emitter will add this import to contract.d.ts.
|
|
390
|
+
*/
|
|
391
|
+
readonly typesImport?: TypesImportSpec;
|
|
392
|
+
}
|
|
393
|
+
//#endregion
|
|
394
|
+
export { Source as A, ValidationContext as B, ParamDescriptor as C, ProfileHashBase as D, PlanRefs as E, TargetFamilyHook as F, isTaggedRaw as G, coreHash as H, TypeRenderContext as I, profileHash as K, TypeRenderEntry as L, TaggedBigInt as M, TaggedLiteralValue as N, RenderTypeContext as O, TaggedRaw as P, TypeRenderer as R, JsonValue as S, PlanMeta as T, isDocumentContract as U, bigintJsonReplacer as V, isTaggedBigInt as W, Expr as _, ColumnDefaultLiteralValue as a, GeneratedValueSpec as b, DocCollection as c, DocumentStorage as d, ExecutionHashBase as f, ExecutionSection as g, ExecutionPlan as h, ColumnDefaultLiteralInputValue as i, StorageHashBase as j, ResultType as k, DocIndex as l, ExecutionMutationDefaultValue as m, Brand as n, ContractBase as o, ExecutionMutationDefault as p, ColumnDefault as r, ContractMarkerRecord as s, $ as t, DocumentContract as u, FieldType as v, ParameterizedCodecDescriptor as w, JsonPrimitive as x, GenerateContractTypesOptions as y, TypesImportSpec as z };
|
|
395
|
+
//# sourceMappingURL=types-54JRJq9p.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types-54JRJq9p.d.mts","names":[],"sources":["../src/types.ts"],"sourcesContent":[],"mappings":";;;;;;;AAMA;AAQY,cARC,CAQI,EAAA,OAAA,MAAA;;;;;AASjB;AAUA;AAOY,KA1BA,KA0BA,CAAA,aAAiB,MAAA,GAAA,MAAyB,GAAQ,MAAK,EAAA,SAAA,IAAA,CAAA,GAAA;EAEnD,CA3Bb,CAAA,CA2Ba,EAAA,QA1BN,IA0B8C,GA1BvC,MA0BuC,EAAoB;CAAhB;;AAS5D;AAEA;AAA2D,UA9B1C,iBAAA,CA8B0C;EAAoB;EAAhB,SAAA,cAAA,EAAA,MAAA;;AAI/D;;;;;AAGuB,KA3BX,eA2BW,CAAA,cAAA,MAAA,CAAA,GA3B6B,KA2B7B,GA3BqC,KA2BrC,CAAA,aAAA,CAAA;;;;;;AAQE,KA5Bb,iBA4Ba,CAAA,cAAA,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AAA,KAAA,GAAA,KAAA,GAAA,MAAA;EAMN,SAAA,IAAA,CAAA,EAAA;IAAe,KAAA,EAAA,MAAA;;;;UA9QvB,QAAA;;qBAEI;;;;qBACA;;sBAEC;;;;UAKL,QAAA;;;;;;;aAOJ;;;6BAGgB,cAAc;kBACzB;wBACM,yBAAyB;;;;;6BAKpB;;;;;;;;;;;UAYZ;;;iBAGA;iBACA;;;;;kBAKC;;;;;;;;;;KAWN,gBACV,UAAU,sCAAsC;;;;;;iBAKlC,kBAAA,iCAAmD;;;;;UAalD,oBAAA;;;;;sBAKK;;iBAEL;;;;;;UAQA,eAAA;;;;;;;;;UAUA,iBAAA;+BACc;8BACD,cAAc;kCACV,cAAc;0BACtB;;;;;iCAKO,YAAY;;;;;;UAO5B,iBAAA;;;;;;;UAQA,eAAA;;4BAEW,8BAA8B;;;;;UAMzC,4BAAA;;;;;;oCAMmB,YAAY;;;;;sCAKV,cAAc;;;;;;UAOnC,gBAAA;;;;;;;oBAQG,iBAAiB;;;;;wBAMb;;;;;;;;;;4BAYhB,8BACc,cAAc,wCACV,cAAc;;;;eAM1B;;;;;;;;;;;;;;;;;;;KA+BF,YAAA,sBAEE,8BAA8B;;;;;;;;;;;;;;;;;;;;;UAsB3B,4BAAA;;;;;;;;;;+BAWc;;;;;;;;;;+BAWA;;;;;yBAMN"}
|
package/dist/types.d.mts
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as Source, B as ValidationContext, C as ParamDescriptor, D as ProfileHashBase, E as PlanRefs, F as TargetFamilyHook, G as isTaggedRaw, H as coreHash, I as TypeRenderContext, K as profileHash, L as TypeRenderEntry, M as TaggedBigInt, N as TaggedLiteralValue, O as RenderTypeContext, P as TaggedRaw, R as TypeRenderer, S as JsonValue, T as PlanMeta, U as isDocumentContract, V as bigintJsonReplacer, W as isTaggedBigInt, _ as Expr, a as ColumnDefaultLiteralValue, b as GeneratedValueSpec, c as DocCollection, d as DocumentStorage, f as ExecutionHashBase, g as ExecutionSection, h as ExecutionPlan, i as ColumnDefaultLiteralInputValue, j as StorageHashBase, k as ResultType, l as DocIndex, m as ExecutionMutationDefaultValue, n as Brand, o as ContractBase, p as ExecutionMutationDefault, r as ColumnDefault, s as ContractMarkerRecord, t as $, u as DocumentContract, v as FieldType, w as ParameterizedCodecDescriptor, x as JsonPrimitive, y as GenerateContractTypesOptions, z as TypesImportSpec } from "./types-54JRJq9p.mjs";
|
|
2
|
+
export { type $, type Brand, type ColumnDefault, type ColumnDefaultLiteralInputValue, type ColumnDefaultLiteralValue, type ContractBase, type ContractMarkerRecord, type DocCollection, type DocIndex, type DocumentContract, type DocumentStorage, type ExecutionHashBase, type ExecutionMutationDefault, type ExecutionMutationDefaultValue, type ExecutionPlan, type ExecutionSection, type Expr, type FieldType, type GenerateContractTypesOptions, type GeneratedValueSpec, type JsonPrimitive, type JsonValue, type ParamDescriptor, type ParameterizedCodecDescriptor, type PlanMeta, type PlanRefs, type ProfileHashBase, type RenderTypeContext, type ResultType, type Source, type StorageHashBase, type TaggedBigInt, type TaggedLiteralValue, type TaggedRaw, type TargetFamilyHook, type TypeRenderContext, type TypeRenderEntry, type TypeRenderer, type TypesImportSpec, type ValidationContext, bigintJsonReplacer, coreHash, isDocumentContract, isTaggedBigInt, isTaggedRaw, profileHash };
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
//#region src/types.ts
|
|
2
|
+
function coreHash(value) {
|
|
3
|
+
return value;
|
|
4
|
+
}
|
|
5
|
+
function profileHash(value) {
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
function isTaggedBigInt(value) {
|
|
9
|
+
return typeof value === "object" && value !== null && value.$type === "bigint" && typeof value.value === "string";
|
|
10
|
+
}
|
|
11
|
+
function bigintJsonReplacer(_key, value) {
|
|
12
|
+
if (typeof value === "bigint") return {
|
|
13
|
+
$type: "bigint",
|
|
14
|
+
value: value.toString()
|
|
15
|
+
};
|
|
16
|
+
return value;
|
|
17
|
+
}
|
|
18
|
+
function isTaggedRaw(value) {
|
|
19
|
+
return typeof value === "object" && value !== null && value.$type === "raw" && "value" in value;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Type guard to check if a contract is a Document contract
|
|
23
|
+
*/
|
|
24
|
+
function isDocumentContract(contract) {
|
|
25
|
+
return typeof contract === "object" && contract !== null && "targetFamily" in contract && contract.targetFamily === "document";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
//#endregion
|
|
29
|
+
export { bigintJsonReplacer, coreHash, isDocumentContract, isTaggedBigInt, isTaggedRaw, profileHash };
|
|
30
|
+
//# sourceMappingURL=types.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type { OperationRegistry } from '@prisma-next/operations';\nimport type { ContractIR } from './ir';\n\n/**\n * Unique symbol used as the key for branding types.\n */\nexport const $: unique symbol = Symbol('__prisma_next_brand__');\n\n/**\n * A helper type to brand a given type with a unique identifier.\n *\n * @template TKey Text used as the brand key.\n * @template TValue Optional value associated with the brand key. Defaults to `true`.\n */\nexport type Brand<TKey extends string | number | symbol, TValue = true> = {\n [$]: {\n [K in TKey]: TValue;\n };\n};\n\n/**\n * Context passed to type renderers during contract.d.ts generation.\n */\nexport interface RenderTypeContext {\n /** The name of the CodecTypes type alias (typically 'CodecTypes') */\n readonly codecTypesName: string;\n}\n\n/**\n * Base type for storage contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type StorageHash = StorageHashBase<'sha256:abc123...'>`\n */\nexport type StorageHashBase<THash extends string> = THash & Brand<'StorageHash'>;\n\n/**\n * Base type for execution contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ExecutionHash = ExecutionHashBase<'sha256:def456...'>`\n */\nexport type ExecutionHashBase<THash extends string> = THash & Brand<'ExecutionHash'>;\n\nexport function coreHash<const T extends string>(value: T): StorageHashBase<T> {\n return value as StorageHashBase<T>;\n}\n\n/**\n * Base type for profile contract hashes.\n * Emitted contract.d.ts files use this with the hash value as a type parameter:\n * `type ProfileHash = ProfileHashBase<'sha256:def456...'>`\n */\nexport type ProfileHashBase<THash extends string> = THash & Brand<'ProfileHash'>;\n\nexport function profileHash<const T extends string>(value: T): ProfileHashBase<T> {\n return value as ProfileHashBase<T>;\n}\n\nexport interface ContractBase<\n TStorageHash extends StorageHashBase<string> = StorageHashBase<string>,\n TExecutionHash extends ExecutionHashBase<string> = ExecutionHashBase<string>,\n TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>,\n> {\n readonly schemaVersion: string;\n readonly target: string;\n readonly targetFamily: string;\n readonly storageHash: TStorageHash;\n readonly executionHash?: TExecutionHash | undefined;\n readonly profileHash?: TProfileHash | undefined;\n readonly capabilities: Record<string, Record<string, boolean>>;\n readonly extensionPacks: Record<string, unknown>;\n readonly meta: Record<string, unknown>;\n readonly sources: Record<string, Source>;\n readonly execution?: ExecutionSection;\n}\n\nexport interface FieldType {\n readonly type: string;\n readonly nullable: boolean;\n readonly items?: FieldType;\n readonly properties?: Record<string, FieldType>;\n}\n\nexport type GeneratedValueSpec = {\n readonly id: string;\n readonly params?: Record<string, unknown>;\n};\n\nexport type JsonPrimitive = string | number | boolean | null;\n\nexport type JsonValue =\n | JsonPrimitive\n | { readonly [key: string]: JsonValue }\n | readonly JsonValue[];\n\nexport type TaggedBigInt = { readonly $type: 'bigint'; readonly value: string };\n\nexport function isTaggedBigInt(value: unknown): value is TaggedBigInt {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { $type?: unknown }).$type === 'bigint' &&\n typeof (value as { value?: unknown }).value === 'string'\n );\n}\n\nexport function bigintJsonReplacer(_key: string, value: unknown): unknown {\n if (typeof value === 'bigint') {\n return { $type: 'bigint', value: value.toString() } satisfies TaggedBigInt;\n }\n return value;\n}\n\nexport type TaggedRaw = { readonly $type: 'raw'; readonly value: JsonValue };\n\nexport function isTaggedRaw(value: unknown): value is TaggedRaw {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { $type?: unknown }).$type === 'raw' &&\n 'value' in (value as object)\n );\n}\n\nexport type TaggedLiteralValue = TaggedBigInt | TaggedRaw;\n\nexport type ColumnDefaultLiteralValue = JsonValue | TaggedLiteralValue;\n\nexport type ColumnDefaultLiteralInputValue = ColumnDefaultLiteralValue | bigint | Date;\n\nexport type ColumnDefault =\n | {\n readonly kind: 'literal';\n readonly value: ColumnDefaultLiteralInputValue;\n }\n | { readonly kind: 'function'; readonly expression: string };\n\nexport type ExecutionMutationDefaultValue = {\n readonly kind: 'generator';\n readonly id: GeneratedValueSpec['id'];\n readonly params?: Record<string, unknown>;\n};\n\nexport type ExecutionMutationDefault = {\n readonly ref: { readonly table: string; readonly column: string };\n readonly onCreate?: ExecutionMutationDefaultValue;\n readonly onUpdate?: ExecutionMutationDefaultValue;\n};\n\nexport type ExecutionSection = {\n readonly mutations: {\n readonly defaults: ReadonlyArray<ExecutionMutationDefault>;\n };\n};\n\nexport interface Source {\n readonly readOnly: boolean;\n readonly projection: Record<string, FieldType>;\n readonly origin?: Record<string, unknown>;\n readonly capabilities?: Record<string, boolean>;\n}\n\n// Document family types\nexport interface DocIndex {\n readonly name: string;\n readonly keys: Record<string, 'asc' | 'desc'>;\n readonly unique?: boolean;\n readonly where?: Expr;\n}\n\nexport type Expr =\n | { readonly kind: 'eq'; readonly path: ReadonlyArray<string>; readonly value: unknown }\n | { readonly kind: 'exists'; readonly path: ReadonlyArray<string> };\n\nexport interface DocCollection {\n readonly name: string;\n readonly id?: {\n readonly strategy: 'auto' | 'client' | 'uuid' | 'objectId';\n };\n readonly fields: Record<string, FieldType>;\n readonly indexes?: ReadonlyArray<DocIndex>;\n readonly readOnly?: boolean;\n}\n\nexport interface DocumentStorage {\n readonly document: {\n readonly collections: Record<string, DocCollection>;\n };\n}\n\nexport interface DocumentContract<\n TStorageHash extends StorageHashBase<string> = StorageHashBase<string>,\n TExecutionHash extends ExecutionHashBase<string> = ExecutionHashBase<string>,\n TProfileHash extends ProfileHashBase<string> = ProfileHashBase<string>,\n> extends ContractBase<TStorageHash, TExecutionHash, TProfileHash> {\n // Accept string to work with JSON imports; runtime validation ensures 'document'\n readonly targetFamily: string;\n readonly storage: DocumentStorage;\n}\n\n// Plan types - target-family agnostic execution types\nexport interface ParamDescriptor {\n readonly index?: number;\n readonly name?: string;\n readonly codecId?: string;\n readonly nativeType?: string;\n readonly nullable?: boolean;\n readonly source: 'dsl' | 'raw' | 'lane';\n readonly refs?: { table: string; column: string };\n}\n\nexport interface PlanRefs {\n readonly tables?: readonly string[];\n readonly columns?: ReadonlyArray<{ table: string; column: string }>;\n readonly indexes?: ReadonlyArray<{\n readonly table: string;\n readonly columns: ReadonlyArray<string>;\n readonly name?: string;\n }>;\n}\n\nexport interface PlanMeta {\n readonly target: string;\n readonly targetFamily?: string;\n readonly storageHash: string;\n readonly profileHash?: string;\n readonly lane: string;\n readonly annotations?: {\n codecs?: Record<string, string>; // alias/param → codec id ('ns/name@v')\n [key: string]: unknown;\n };\n readonly paramDescriptors: ReadonlyArray<ParamDescriptor>;\n readonly refs?: PlanRefs;\n readonly projection?: Record<string, string> | ReadonlyArray<string>;\n /**\n * Optional mapping of projection alias → column type ID (fully qualified ns/name@version).\n * Used for codec resolution when AST+refs don't provide enough type info.\n */\n readonly projectionTypes?: Record<string, string>;\n}\n\n/**\n * Canonical execution plan shape used by runtimes.\n *\n * - Row is the inferred result row type (TypeScript-only).\n * - Ast is the optional, family-specific AST type (e.g. SQL QueryAst).\n *\n * The payload executed by the runtime is represented by the sql + params pair\n * for now; future families can specialize this via Ast or additional metadata.\n */\nexport interface ExecutionPlan<Row = unknown, Ast = unknown> {\n readonly sql: string;\n readonly params: readonly unknown[];\n readonly ast?: Ast;\n readonly meta: PlanMeta;\n /**\n * Phantom property to carry the Row generic for type-level utilities.\n * Not set at runtime; used only for ResultType extraction.\n */\n readonly _row?: Row;\n}\n\n/**\n * Utility type to extract the Row type from an ExecutionPlan.\n * Example: `type Row = ResultType<typeof plan>`\n *\n * Works with both ExecutionPlan and SqlQueryPlan (SQL query plans before lowering).\n * SqlQueryPlan includes a phantom `_Row` property to preserve the generic parameter\n * for type extraction.\n */\nexport type ResultType<P> =\n P extends ExecutionPlan<infer R, unknown> ? R : P extends { readonly _Row?: infer R } ? R : never;\n\n/**\n * Type guard to check if a contract is a Document contract\n */\nexport function isDocumentContract(contract: unknown): contract is DocumentContract {\n return (\n typeof contract === 'object' &&\n contract !== null &&\n 'targetFamily' in contract &&\n contract.targetFamily === 'document'\n );\n}\n\n/**\n * Contract marker record stored in the database.\n * Represents the current contract identity for a database.\n */\nexport interface ContractMarkerRecord {\n readonly storageHash: string;\n readonly profileHash: string;\n readonly contractJson: unknown | null;\n readonly canonicalVersion: number | null;\n readonly updatedAt: Date;\n readonly appTag: string | null;\n readonly meta: Record<string, unknown>;\n}\n\n// Emitter types - moved from @prisma-next/emitter to shared location\n/**\n * Specifies how to import TypeScript types from a package.\n * Used in extension pack manifests to declare codec and operation type imports.\n */\nexport interface TypesImportSpec {\n readonly package: string;\n readonly named: string;\n readonly alias: string;\n}\n\n/**\n * Validation context passed to TargetFamilyHook.validateTypes().\n * Contains pre-assembled operation registry, type imports, and extension IDs.\n */\nexport interface ValidationContext {\n readonly operationRegistry?: OperationRegistry;\n readonly codecTypeImports?: ReadonlyArray<TypesImportSpec>;\n readonly operationTypeImports?: ReadonlyArray<TypesImportSpec>;\n readonly extensionIds?: ReadonlyArray<string>;\n /**\n * Parameterized codec descriptors collected from adapters and extensions.\n * Map of codecId → descriptor for quick lookup during type generation.\n */\n readonly parameterizedCodecs?: Map<string, ParameterizedCodecDescriptor>;\n}\n\n/**\n * Context for rendering parameterized types during contract.d.ts generation.\n * Passed to type renderers so they can reference CodecTypes by name.\n */\nexport interface TypeRenderContext {\n readonly codecTypesName: string;\n}\n\n/**\n * A normalized type renderer for parameterized codecs.\n * This is the interface expected by TargetFamilyHook.generateContractTypes.\n */\nexport interface TypeRenderEntry {\n readonly codecId: string;\n readonly render: (params: Record<string, unknown>, ctx: TypeRenderContext) => string;\n}\n\n/**\n * Additional options for generateContractTypes.\n */\nexport interface GenerateContractTypesOptions {\n /**\n * Normalized parameterized type renderers, keyed by codecId.\n * When a column has typeParams and a renderer exists for its codecId,\n * the renderer is called to produce the TypeScript type expression.\n */\n readonly parameterizedRenderers?: Map<string, TypeRenderEntry>;\n /**\n * Type imports for parameterized codecs.\n * These are merged with codec and operation type imports in contract.d.ts.\n */\n readonly parameterizedTypeImports?: ReadonlyArray<TypesImportSpec>;\n}\n\n/**\n * SPI interface for target family hooks that extend emission behavior.\n * Implemented by family-specific emitter hooks (e.g., SQL family).\n */\nexport interface TargetFamilyHook {\n readonly id: string;\n\n /**\n * Validates that all type IDs in the contract come from referenced extension packs.\n * @param ir - Contract IR to validate\n * @param ctx - Validation context with operation registry and extension IDs\n */\n validateTypes(ir: ContractIR, ctx: ValidationContext): void;\n\n /**\n * Validates family-specific contract structure.\n * @param ir - Contract IR to validate\n */\n validateStructure(ir: ContractIR): void;\n\n /**\n * Generates contract.d.ts file content.\n * @param ir - Contract IR\n * @param codecTypeImports - Array of codec type import specs\n * @param operationTypeImports - Array of operation type import specs\n * @param hashes - Contract hash values (storageHash, executionHash, profileHash)\n * @param options - Additional options including parameterized type renderers\n * @returns Generated TypeScript type definitions as string\n */\n generateContractTypes(\n ir: ContractIR,\n codecTypeImports: ReadonlyArray<TypesImportSpec>,\n operationTypeImports: ReadonlyArray<TypesImportSpec>,\n hashes: {\n readonly storageHash: string;\n readonly executionHash?: string;\n readonly profileHash: string;\n },\n options?: GenerateContractTypesOptions,\n ): string;\n}\n\n// ============================================================================\n// Parameterized Codec Descriptor Types\n// ============================================================================\n//\n// Types for codecs that support type parameters (e.g., Vector<1536>, Decimal<2>).\n// These enable precise TypeScript types for parameterized columns without\n// coupling the SQL family emitter to specific adapter codec IDs.\n//\n// ============================================================================\n\n/**\n * Declarative type renderer that produces a TypeScript type expression.\n *\n * Renderers can be:\n * - A template string with `{{paramName}}` placeholders (e.g., `Vector<{{length}}>`)\n * - A function that receives typeParams and context and returns a type expression\n *\n * **Prefer template strings** for most cases:\n * - Templates are JSON-serializable (safe for pack-ref metadata)\n * - Templates can be statically analyzed by tooling\n *\n * Function renderers are allowed but have tradeoffs:\n * - Require runtime execution during emission (the emitter runs code)\n * - Not JSON-serializable (can't be stored in contract.json)\n * - The emitted artifacts (contract.json, contract.d.ts) still contain no\n * executable code - this constraint applies to outputs, not the emission process\n */\nexport type TypeRenderer =\n | string\n | ((params: Record<string, unknown>, ctx: RenderTypeContext) => string);\n\n/**\n * Descriptor for a codec that supports type parameters.\n *\n * Parameterized codecs allow columns to carry additional metadata (typeParams)\n * that affects the generated TypeScript types. For example:\n * - A vector codec can use `{ length: 1536 }` to generate `Vector<1536>`\n * - A decimal codec can use `{ precision: 10, scale: 2 }` to generate `Decimal<10, 2>`\n *\n * The SQL family emitter uses these descriptors to generate precise types\n * without hard-coding knowledge of specific codec IDs.\n *\n * @example\n * ```typescript\n * const vectorCodecDescriptor: ParameterizedCodecDescriptor = {\n * codecId: 'pg/vector@1',\n * outputTypeRenderer: 'Vector<{{length}}>',\n * // Optional: paramsSchema for runtime validation\n * };\n * ```\n */\nexport interface ParameterizedCodecDescriptor {\n /** The codec ID this descriptor applies to (e.g., 'pg/vector@1') */\n readonly codecId: string;\n\n /**\n * Renderer for the output (read) type.\n * Can be a template string or function.\n *\n * This is the primary renderer used by SQL emission to generate\n * model field types in contract.d.ts.\n */\n readonly outputTypeRenderer: TypeRenderer;\n\n /**\n * Optional renderer for the input (write) type.\n * If not provided, outputTypeRenderer is used for both.\n *\n * **Reserved for future use**: Currently, SQL emission only uses\n * outputTypeRenderer. This field is defined for future support of\n * asymmetric codecs where input and output types differ (e.g., a\n * codec that accepts `string | number` but always returns `number`).\n */\n readonly inputTypeRenderer?: TypeRenderer;\n\n /**\n * Optional import spec for types used by this codec's renderers.\n * The emitter will add this import to contract.d.ts.\n */\n readonly typesImport?: TypesImportSpec;\n}\n"],"mappings":";AA0CA,SAAgB,SAAiC,OAA8B;AAC7E,QAAO;;AAUT,SAAgB,YAAoC,OAA8B;AAChF,QAAO;;AA0CT,SAAgB,eAAe,OAAuC;AACpE,QACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA8B,UAAU,YACzC,OAAQ,MAA8B,UAAU;;AAIpD,SAAgB,mBAAmB,MAAc,OAAyB;AACxE,KAAI,OAAO,UAAU,SACnB,QAAO;EAAE,OAAO;EAAU,OAAO,MAAM,UAAU;EAAE;AAErD,QAAO;;AAKT,SAAgB,YAAY,OAAoC;AAC9D,QACE,OAAO,UAAU,YACjB,UAAU,QACT,MAA8B,UAAU,SACzC,WAAY;;;;;AA4JhB,SAAgB,mBAAmB,UAAiD;AAClF,QACE,OAAO,aAAa,YACpB,aAAa,QACb,kBAAkB,YAClB,SAAS,iBAAiB"}
|