@soda-gql/typegen 0.10.1 → 0.11.0
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/index.cjs +269 -154
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +87 -71
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +87 -71
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +269 -154
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -5
package/dist/index.d.mts
CHANGED
|
@@ -4,6 +4,71 @@ import { DocumentNode } from "graphql";
|
|
|
4
4
|
import { Result } from "neverthrow";
|
|
5
5
|
import { ResolvedSodaGqlConfig } from "@soda-gql/config";
|
|
6
6
|
|
|
7
|
+
//#region packages/typegen/src/errors.d.ts
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Error codes specific to typegen operations.
|
|
11
|
+
*/
|
|
12
|
+
type TypegenErrorCode = "TYPEGEN_CODEGEN_REQUIRED" | "TYPEGEN_SCHEMA_LOAD_FAILED" | "TYPEGEN_BUILD_FAILED" | "TYPEGEN_EMIT_FAILED" | "TYPEGEN_BUNDLE_FAILED" | "TYPEGEN_FRAGMENT_MISSING_KEY";
|
|
13
|
+
/**
|
|
14
|
+
* Typegen-specific error type.
|
|
15
|
+
*/
|
|
16
|
+
type TypegenSpecificError = {
|
|
17
|
+
readonly code: "TYPEGEN_CODEGEN_REQUIRED";
|
|
18
|
+
readonly message: string;
|
|
19
|
+
readonly outdir: string;
|
|
20
|
+
} | {
|
|
21
|
+
readonly code: "TYPEGEN_SCHEMA_LOAD_FAILED";
|
|
22
|
+
readonly message: string;
|
|
23
|
+
readonly schemaNames: readonly string[];
|
|
24
|
+
readonly cause?: unknown;
|
|
25
|
+
} | {
|
|
26
|
+
readonly code: "TYPEGEN_BUILD_FAILED";
|
|
27
|
+
readonly message: string;
|
|
28
|
+
readonly cause?: unknown;
|
|
29
|
+
} | {
|
|
30
|
+
readonly code: "TYPEGEN_EMIT_FAILED";
|
|
31
|
+
readonly message: string;
|
|
32
|
+
readonly path: string;
|
|
33
|
+
readonly cause?: unknown;
|
|
34
|
+
} | {
|
|
35
|
+
readonly code: "TYPEGEN_BUNDLE_FAILED";
|
|
36
|
+
readonly message: string;
|
|
37
|
+
readonly path: string;
|
|
38
|
+
readonly cause?: unknown;
|
|
39
|
+
} | {
|
|
40
|
+
readonly code: "TYPEGEN_FRAGMENT_MISSING_KEY";
|
|
41
|
+
readonly message: string;
|
|
42
|
+
readonly fragments: readonly {
|
|
43
|
+
readonly canonicalId: string;
|
|
44
|
+
readonly typename: string;
|
|
45
|
+
readonly schemaLabel: string;
|
|
46
|
+
}[];
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Union of all typegen errors (specific + builder errors).
|
|
50
|
+
*/
|
|
51
|
+
type TypegenError = TypegenSpecificError | BuilderError;
|
|
52
|
+
/**
|
|
53
|
+
* Error constructor helpers for concise error creation.
|
|
54
|
+
*/
|
|
55
|
+
declare const typegenErrors: {
|
|
56
|
+
readonly codegenRequired: (outdir: string) => TypegenSpecificError;
|
|
57
|
+
readonly schemaLoadFailed: (schemaNames: readonly string[], cause?: unknown) => TypegenSpecificError;
|
|
58
|
+
readonly buildFailed: (message: string, cause?: unknown) => TypegenSpecificError;
|
|
59
|
+
readonly emitFailed: (path: string, message: string, cause?: unknown) => TypegenSpecificError;
|
|
60
|
+
readonly bundleFailed: (path: string, message: string, cause?: unknown) => TypegenSpecificError;
|
|
61
|
+
readonly fragmentMissingKey: (fragments: readonly {
|
|
62
|
+
canonicalId: string;
|
|
63
|
+
typename: string;
|
|
64
|
+
schemaLabel: string;
|
|
65
|
+
}[]) => TypegenSpecificError;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* Format TypegenError for console output (human-readable).
|
|
69
|
+
*/
|
|
70
|
+
declare const formatTypegenError: (error: TypegenError) => string;
|
|
71
|
+
//#endregion
|
|
7
72
|
//#region packages/typegen/src/emitter.d.ts
|
|
8
73
|
|
|
9
74
|
/**
|
|
@@ -25,12 +90,10 @@ type PrebuiltTypesEmitterOptions = {
|
|
|
25
90
|
*/
|
|
26
91
|
readonly outdir: string;
|
|
27
92
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
93
|
+
* Relative import path to _internal-injects.ts from types.prebuilt.ts.
|
|
94
|
+
* Example: "./_internal-injects"
|
|
30
95
|
*/
|
|
31
|
-
readonly
|
|
32
|
-
readonly scalars: string;
|
|
33
|
-
}>;
|
|
96
|
+
readonly injectsModulePath: string;
|
|
34
97
|
};
|
|
35
98
|
/**
|
|
36
99
|
* Result of emitting prebuilt types.
|
|
@@ -68,85 +131,38 @@ type PrebuiltTypesEmitResult = {
|
|
|
68
131
|
* }
|
|
69
132
|
* ```
|
|
70
133
|
*/
|
|
71
|
-
declare const emitPrebuiltTypes: (options: PrebuiltTypesEmitterOptions) => Promise<Result<PrebuiltTypesEmitResult, BuilderError>>;
|
|
72
|
-
//#endregion
|
|
73
|
-
//#region packages/typegen/src/errors.d.ts
|
|
74
|
-
/**
|
|
75
|
-
* Error codes specific to typegen operations.
|
|
76
|
-
*/
|
|
77
|
-
type TypegenErrorCode = "TYPEGEN_CODEGEN_REQUIRED" | "TYPEGEN_SCHEMA_LOAD_FAILED" | "TYPEGEN_BUILD_FAILED" | "TYPEGEN_EMIT_FAILED" | "TYPEGEN_BUNDLE_FAILED";
|
|
78
|
-
/**
|
|
79
|
-
* Typegen-specific error type.
|
|
80
|
-
*/
|
|
81
|
-
type TypegenSpecificError = {
|
|
82
|
-
readonly code: "TYPEGEN_CODEGEN_REQUIRED";
|
|
83
|
-
readonly message: string;
|
|
84
|
-
readonly outdir: string;
|
|
85
|
-
} | {
|
|
86
|
-
readonly code: "TYPEGEN_SCHEMA_LOAD_FAILED";
|
|
87
|
-
readonly message: string;
|
|
88
|
-
readonly schemaNames: readonly string[];
|
|
89
|
-
readonly cause?: unknown;
|
|
90
|
-
} | {
|
|
91
|
-
readonly code: "TYPEGEN_BUILD_FAILED";
|
|
92
|
-
readonly message: string;
|
|
93
|
-
readonly cause?: unknown;
|
|
94
|
-
} | {
|
|
95
|
-
readonly code: "TYPEGEN_EMIT_FAILED";
|
|
96
|
-
readonly message: string;
|
|
97
|
-
readonly path: string;
|
|
98
|
-
readonly cause?: unknown;
|
|
99
|
-
} | {
|
|
100
|
-
readonly code: "TYPEGEN_BUNDLE_FAILED";
|
|
101
|
-
readonly message: string;
|
|
102
|
-
readonly path: string;
|
|
103
|
-
readonly cause?: unknown;
|
|
104
|
-
};
|
|
105
|
-
/**
|
|
106
|
-
* Union of all typegen errors (specific + builder errors).
|
|
107
|
-
*/
|
|
108
|
-
type TypegenError = TypegenSpecificError | BuilderError;
|
|
109
|
-
/**
|
|
110
|
-
* Error constructor helpers for concise error creation.
|
|
111
|
-
*/
|
|
112
|
-
declare const typegenErrors: {
|
|
113
|
-
readonly codegenRequired: (outdir: string) => TypegenSpecificError;
|
|
114
|
-
readonly schemaLoadFailed: (schemaNames: readonly string[], cause?: unknown) => TypegenSpecificError;
|
|
115
|
-
readonly buildFailed: (message: string, cause?: unknown) => TypegenSpecificError;
|
|
116
|
-
readonly emitFailed: (path: string, message: string, cause?: unknown) => TypegenSpecificError;
|
|
117
|
-
readonly bundleFailed: (path: string, message: string, cause?: unknown) => TypegenSpecificError;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Format TypegenError for console output (human-readable).
|
|
121
|
-
*/
|
|
122
|
-
declare const formatTypegenError: (error: TypegenError) => string;
|
|
134
|
+
declare const emitPrebuiltTypes: (options: PrebuiltTypesEmitterOptions) => Promise<Result<PrebuiltTypesEmitResult, BuilderError | TypegenError>>;
|
|
123
135
|
//#endregion
|
|
124
136
|
//#region packages/typegen/src/prebuilt-generator.d.ts
|
|
125
137
|
type PrebuiltGeneratorOptions = {
|
|
126
138
|
/**
|
|
127
|
-
* Relative import path to the
|
|
128
|
-
* Example: "
|
|
139
|
+
* Relative import path to the internal module.
|
|
140
|
+
* Example: "./_internal" (from index.prebuilt.ts to _internal.ts)
|
|
141
|
+
*/
|
|
142
|
+
readonly internalModulePath: string;
|
|
143
|
+
/**
|
|
144
|
+
* Relative import path to the injects module.
|
|
145
|
+
* Example: "./_internal-injects" (from index.prebuilt.ts to _internal-injects.ts)
|
|
129
146
|
*/
|
|
130
|
-
readonly
|
|
147
|
+
readonly injectsModulePath: string;
|
|
131
148
|
/**
|
|
132
|
-
* Per-schema injection config
|
|
149
|
+
* Per-schema injection config.
|
|
150
|
+
* Maps schema name to whether it has an adapter.
|
|
133
151
|
*/
|
|
134
152
|
readonly injection?: Map<string, {
|
|
135
|
-
readonly
|
|
153
|
+
readonly hasAdapter?: boolean;
|
|
136
154
|
}>;
|
|
137
155
|
};
|
|
138
156
|
type PrebuiltGeneratedModule = {
|
|
139
|
-
/** The generated code for
|
|
157
|
+
/** The generated code for index.prebuilt.ts */
|
|
140
158
|
readonly indexCode: string;
|
|
141
|
-
/** The generated code for prebuilt/types.ts (placeholder) */
|
|
142
|
-
readonly typesCode: string;
|
|
143
159
|
};
|
|
144
160
|
/**
|
|
145
|
-
* Generate the prebuilt module code.
|
|
161
|
+
* Generate the prebuilt index module code.
|
|
146
162
|
*
|
|
147
|
-
*
|
|
148
|
-
*
|
|
149
|
-
*
|
|
163
|
+
* Generates index.prebuilt.ts with builder-level type resolution.
|
|
164
|
+
* Types are resolved at the fragment/operation builder level using TKey/TName,
|
|
165
|
+
* eliminating the need for ResolvePrebuiltElement at the composer level.
|
|
150
166
|
*/
|
|
151
167
|
declare const generatePrebuiltModule: (schemas: Map<string, DocumentNode>, options: PrebuiltGeneratorOptions) => PrebuiltGeneratedModule;
|
|
152
168
|
//#endregion
|
|
@@ -221,10 +237,10 @@ type RunTypegenOptions = {
|
|
|
221
237
|
*
|
|
222
238
|
* This function:
|
|
223
239
|
* 1. Loads schemas from the generated CJS bundle
|
|
224
|
-
* 2. Generates
|
|
240
|
+
* 2. Generates index.prebuilt.ts using generatePrebuiltModule
|
|
225
241
|
* 3. Creates a BuilderService and builds the artifact
|
|
226
242
|
* 4. Extracts field selections from the artifact
|
|
227
|
-
* 5. Emits
|
|
243
|
+
* 5. Emits types.prebuilt.ts using emitPrebuiltTypes
|
|
228
244
|
* 6. Bundles the prebuilt module
|
|
229
245
|
*
|
|
230
246
|
* @param options - Typegen options including config
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/errors.ts","../src/emitter.ts","../src/prebuilt-generator.ts","../src/types.ts","../src/runner.ts"],"sourcesContent":[],"mappings":";;;;;;;;;AAWA;AAWA;AA0CY,KArDA,gBAAA,GAqDe,0BAAuB,GAAA,4BAAY,GAAA,sBAAA,GAAA,qBAAA,GAAA,uBAAA,GAAA,8BAAA;AAK9D;;;AAcmD,KA7DvC,oBAAA,GA6DuC;EAMa,SAAA,IAAA,EAAA,0BAAA;EAOE,SAAA,OAAA,EAAA,MAAA;EAS7D,SAAA,MAAA,EAAA,MAAA;CAAoB,GAAA;EAUZ,SAAA,IAAA,EAAA,4BAA6B;;;;AC9E1C,CAAA,GAAY;EAKuB,SAAA,IAAA,EAAA,sBAAA;EAAf,SAAA,OAAA,EAAA,MAAA;EAIQ,SAAA,KAAA,CAAA,EAAA,OAAA;CAAkB,GAAA;EAqWlC,SAAA,IAAA,EAAA,qBAAuB;EAkCtB,SAAA,OAAA,EAAA,MA8BZ;EA7BU,SAAA,IAAA,EAAA,MAAA;EACO,SAAA,KAAA,CAAA,EAAA,OAAA;CAAyB,GAAA;EAAe,SAAA,IAAA,EAAA,uBAAA;EAA/C,SAAA,OAAA,EAAA,MAAA;EAAR,SAAA,IAAA,EAAA,MAAA;EAAO,SAAA,KAAA,CAAA,EAAA,OAAA;;;;EClaE,SAAA,SAAA,EAAA,SAAwB;IAuBxB,SAAA,WAAA,EAAuB,MAAA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