@ptdgrp/typedgql 1.0.0-beta.16 → 1.0.0-beta.20
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/README.md +55 -2
- package/README.zh-CN.md +57 -4
- package/dist/cli.cjs +47 -0
- package/dist/cli.d.cts +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +49 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/{schema-loader-BIP51DZO.cjs → config-loader-Bxj44SGD.cjs} +348 -41
- package/dist/{schema-loader-CsabdnfI.mjs → config-loader-DZ7d_CWR.mjs} +342 -47
- package/dist/config-loader-DZ7d_CWR.mjs.map +1 -0
- package/dist/cyrb53-B2tdX6NT.mjs +921 -0
- package/dist/cyrb53-B2tdX6NT.mjs.map +1 -0
- package/dist/cyrb53-BTzxwvXR.cjs +1010 -0
- package/dist/cyrb53-DWYFRdWZ.d.mts +333 -0
- package/dist/cyrb53-DWYFRdWZ.d.mts.map +1 -0
- package/dist/cyrb53-FbY3n_2r.d.cts +333 -0
- package/dist/cyrb53-FbY3n_2r.d.cts.map +1 -0
- package/dist/index.cjs +18 -935
- package/dist/index.d.cts +2 -333
- package/dist/index.d.mts +2 -333
- package/dist/index.mjs +3 -920
- package/dist/node.cjs +6 -4
- package/dist/node.d.cts +63 -2
- package/dist/node.d.cts.map +1 -1
- package/dist/node.d.mts +63 -2
- package/dist/node.d.mts.map +1 -1
- package/dist/node.mjs +2 -2
- package/dist/{options-CgrZ2der.d.cts → options-B6mcYDIz.d.cts} +10 -1
- package/dist/options-B6mcYDIz.d.cts.map +1 -0
- package/dist/{options-BWcHrC-1.d.mts → options-T07dJfbz.d.mts} +10 -1
- package/dist/options-T07dJfbz.d.mts.map +1 -0
- package/dist/runtime.cjs +18 -0
- package/dist/runtime.d.cts +2 -0
- package/dist/runtime.d.mts +2 -0
- package/dist/runtime.mjs +3 -0
- package/dist/vite.cjs +48 -29
- package/dist/vite.d.cts +13 -3
- package/dist/vite.d.cts.map +1 -1
- package/dist/vite.d.mts +13 -3
- package/dist/vite.d.mts.map +1 -1
- package/dist/vite.mjs +46 -27
- package/dist/vite.mjs.map +1 -1
- package/package.json +23 -4
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
- package/dist/options-BWcHrC-1.d.mts.map +0 -1
- package/dist/options-CgrZ2der.d.cts.map +0 -1
- package/dist/schema-loader-CsabdnfI.mjs.map +0 -1
package/dist/node.cjs
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_config_loader = require('./config-loader-Bxj44SGD.cjs');
|
|
3
3
|
|
|
4
|
-
exports.Generator =
|
|
5
|
-
exports.
|
|
6
|
-
exports.
|
|
4
|
+
exports.Generator = require_config_loader.Generator;
|
|
5
|
+
exports.loadConfig = require_config_loader.loadConfig;
|
|
6
|
+
exports.loadLocalSchema = require_config_loader.loadLocalSchema;
|
|
7
|
+
exports.loadRemoteSchema = require_config_loader.loadRemoteSchema;
|
|
8
|
+
exports.mergeConfig = require_config_loader.mergeConfig;
|
package/dist/node.d.cts
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
|
-
import { t as CodegenOptions } from "./options-
|
|
1
|
+
import { t as CodegenOptions } from "./options-B6mcYDIz.cjs";
|
|
2
2
|
import { GraphQLSchema } from "graphql";
|
|
3
3
|
|
|
4
4
|
//#region src/codegen/generator.d.ts
|
|
5
5
|
declare class Generator {
|
|
6
6
|
protected options: CodegenOptions;
|
|
7
|
+
private usePrettier;
|
|
8
|
+
private isCustomOutputDir;
|
|
9
|
+
private bufferedStreams;
|
|
7
10
|
constructor(options: CodegenOptions);
|
|
8
11
|
/** Resolved output directory (uses default if not configured) */
|
|
9
12
|
private get targetDir();
|
|
13
|
+
/**
|
|
14
|
+
* Check if we should use prettier formatting.
|
|
15
|
+
* Only enabled when using custom outputDir (not in node_modules).
|
|
16
|
+
*/
|
|
17
|
+
private initializePrettier;
|
|
18
|
+
/**
|
|
19
|
+
* Create a stream for writing generated code.
|
|
20
|
+
* Uses BufferedStream when prettier formatting is enabled.
|
|
21
|
+
*/
|
|
22
|
+
private createCodeStream;
|
|
23
|
+
private get rootRuntimeImportSource();
|
|
24
|
+
private get nestedRuntimeImportSource();
|
|
25
|
+
private get usesPackageInternalRuntimeImports();
|
|
26
|
+
private get generatedImportSourceMap();
|
|
27
|
+
/**
|
|
28
|
+
* Flush all buffered streams with prettier formatting.
|
|
29
|
+
*/
|
|
30
|
+
private flushBufferedStreams;
|
|
10
31
|
generate(): Promise<void>;
|
|
11
32
|
private createSelectionWriter;
|
|
12
33
|
private additionalExportedTypeNamesForSelection;
|
|
@@ -41,5 +62,45 @@ declare function loadRemoteSchema(endpoint: string, headers?: {
|
|
|
41
62
|
}): Promise<GraphQLSchema>;
|
|
42
63
|
declare function loadLocalSchema(location: string): Promise<GraphQLSchema>;
|
|
43
64
|
//#endregion
|
|
44
|
-
|
|
65
|
+
//#region src/codegen/config-loader.d.ts
|
|
66
|
+
/**
|
|
67
|
+
* Configuration file format for .typedgqlrc.toml
|
|
68
|
+
* Matches CodegenOptions but with schema-related fields for file-based config.
|
|
69
|
+
*/
|
|
70
|
+
interface TypedGqlConfig extends Omit<CodegenOptions, "schemaLoader"> {
|
|
71
|
+
/**
|
|
72
|
+
* GraphQL schema source.
|
|
73
|
+
* - Local file path: `"./schema.graphql"`
|
|
74
|
+
* - Remote endpoint: `"http://localhost:4000/graphql"`
|
|
75
|
+
*/
|
|
76
|
+
schema?: string;
|
|
77
|
+
/**
|
|
78
|
+
* HTTP headers forwarded when fetching a remote schema.
|
|
79
|
+
* Only used when `schema` is a URL.
|
|
80
|
+
*/
|
|
81
|
+
schemaHeaders?: Record<string, string>;
|
|
82
|
+
/**
|
|
83
|
+
* Output directory for generated files.
|
|
84
|
+
* Alias for `targetDir` for better clarity.
|
|
85
|
+
*/
|
|
86
|
+
outputDir?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Load configuration from .typedgqlrc.toml file.
|
|
90
|
+
*
|
|
91
|
+
* @param configPath - Path to the config file (defaults to .typedgqlrc.toml in cwd)
|
|
92
|
+
* @returns Parsed configuration object or undefined if file doesn't exist
|
|
93
|
+
*/
|
|
94
|
+
declare function loadConfig(configPath?: string): Promise<TypedGqlConfig | undefined>;
|
|
95
|
+
/**
|
|
96
|
+
* Merge configuration from file with programmatic options.
|
|
97
|
+
* Programmatic options take precedence over file config.
|
|
98
|
+
*
|
|
99
|
+
* @param fileConfig - Configuration loaded from .typedgqlrc.toml
|
|
100
|
+
* @param programmaticConfig - Configuration passed programmatically
|
|
101
|
+
* @returns Merged configuration
|
|
102
|
+
*/
|
|
103
|
+
declare function mergeConfig(fileConfig: TypedGqlConfig | undefined, programmaticConfig: Partial<TypedGqlConfig>): TypedGqlConfig;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { type CodegenOptions, Generator, type TypedGqlConfig, loadConfig, loadLocalSchema, loadRemoteSchema, mergeConfig };
|
|
45
106
|
//# sourceMappingURL=node.d.cts.map
|
package/dist/node.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.cts","names":[],"sources":["../src/codegen/generator.ts","../src/codegen/schema-loader.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"node.d.cts","names":[],"sources":["../src/codegen/generator.ts","../src/codegen/schema-loader.ts","../src/codegen/config-loader.ts"],"mappings":";;;;cAgEa,SAAA;EAAA,UAKW,OAAA,EAAS,cAAA;EAAA,QAJvB,WAAA;EAAA,QACA,iBAAA;EAAA,QACA,eAAA;cAEc,OAAA,EAAS,cAAA;EAAA;EAAA,YAGnB,SAAA,CAAA;EA4FE;;;;EAAA,QApFA,kBAAA;EAdN;;;;EAAA,QAyCA,gBAAA;EAAA,YAaI,uBAAA,CAAA;EAAA,YAMA,yBAAA,CAAA;EAAA,YAMA,iCAAA,CAAA;EAAA,YAIA,wBAAA,CAAA;EAVA;;;EAAA,QAoBE,oBAAA;EAkBR,QAAA,CAAA,GAAQ,OAAA;EAAA,QAwJN,qBAAA;EAAA,QAeA,uCAAA;EAAA,QAOM,sBAAA;EAAA,QAqEA,kBAAA;EAAA,QAYA,iBAAA;EAAA,QAeA,qBAAA;EAAA,QAgBA,yBAAA;EAAA,QAaA,gBAAA;EAAA,QAeA,oBAAA;EAAA,QAUA,mBAAA;EAAA,QA8BN,qBAAA;EAAA,QAeM,UAAA;EAAA;;;;;EAAA,QAyFA,sBAAA;EAAA,QAcA,sCAAA;EAAA,QAuCN,qBAAA;EAAA,QAgFA,iBAAA;EAAA,QAeA,kBAAA;EAAA,QAiBA,cAAA;EAAA,QAqFA,8BAAA;EAAA,QAWA,cAAA;AAAA;;;iBC/2BY,gBAAA,CACpB,QAAA,UACA,OAAA;EAAA,CAAa,GAAA;AAAA,IACZ,OAAA,CAAQ,aAAA;AAAA,iBAuBW,eAAA,CACpB,QAAA,WACC,OAAA,CAAQ,aAAA;;;;;;ADgCX;UExCiB,cAAA,SACP,IAAA,CAAK,cAAA;;;;;;EAMb,MAAA;EFsCsB;;;;EEjCtB,aAAA,GAAgB,MAAA;;;;;EAKhB,SAAA;AAAA;;;;;;;iBASoB,UAAA,CACpB,UAAA,YACC,OAAA,CAAQ,cAAA;;;;;;;;;iBAqCK,WAAA,CACd,UAAA,EAAY,cAAA,cACZ,kBAAA,EAAoB,OAAA,CAAQ,cAAA,IAC3B,cAAA"}
|
package/dist/node.d.mts
CHANGED
|
@@ -1,12 +1,33 @@
|
|
|
1
|
-
import { t as CodegenOptions } from "./options-
|
|
1
|
+
import { t as CodegenOptions } from "./options-T07dJfbz.mjs";
|
|
2
2
|
import { GraphQLSchema } from "graphql";
|
|
3
3
|
|
|
4
4
|
//#region src/codegen/generator.d.ts
|
|
5
5
|
declare class Generator {
|
|
6
6
|
protected options: CodegenOptions;
|
|
7
|
+
private usePrettier;
|
|
8
|
+
private isCustomOutputDir;
|
|
9
|
+
private bufferedStreams;
|
|
7
10
|
constructor(options: CodegenOptions);
|
|
8
11
|
/** Resolved output directory (uses default if not configured) */
|
|
9
12
|
private get targetDir();
|
|
13
|
+
/**
|
|
14
|
+
* Check if we should use prettier formatting.
|
|
15
|
+
* Only enabled when using custom outputDir (not in node_modules).
|
|
16
|
+
*/
|
|
17
|
+
private initializePrettier;
|
|
18
|
+
/**
|
|
19
|
+
* Create a stream for writing generated code.
|
|
20
|
+
* Uses BufferedStream when prettier formatting is enabled.
|
|
21
|
+
*/
|
|
22
|
+
private createCodeStream;
|
|
23
|
+
private get rootRuntimeImportSource();
|
|
24
|
+
private get nestedRuntimeImportSource();
|
|
25
|
+
private get usesPackageInternalRuntimeImports();
|
|
26
|
+
private get generatedImportSourceMap();
|
|
27
|
+
/**
|
|
28
|
+
* Flush all buffered streams with prettier formatting.
|
|
29
|
+
*/
|
|
30
|
+
private flushBufferedStreams;
|
|
10
31
|
generate(): Promise<void>;
|
|
11
32
|
private createSelectionWriter;
|
|
12
33
|
private additionalExportedTypeNamesForSelection;
|
|
@@ -41,5 +62,45 @@ declare function loadRemoteSchema(endpoint: string, headers?: {
|
|
|
41
62
|
}): Promise<GraphQLSchema>;
|
|
42
63
|
declare function loadLocalSchema(location: string): Promise<GraphQLSchema>;
|
|
43
64
|
//#endregion
|
|
44
|
-
|
|
65
|
+
//#region src/codegen/config-loader.d.ts
|
|
66
|
+
/**
|
|
67
|
+
* Configuration file format for .typedgqlrc.toml
|
|
68
|
+
* Matches CodegenOptions but with schema-related fields for file-based config.
|
|
69
|
+
*/
|
|
70
|
+
interface TypedGqlConfig extends Omit<CodegenOptions, "schemaLoader"> {
|
|
71
|
+
/**
|
|
72
|
+
* GraphQL schema source.
|
|
73
|
+
* - Local file path: `"./schema.graphql"`
|
|
74
|
+
* - Remote endpoint: `"http://localhost:4000/graphql"`
|
|
75
|
+
*/
|
|
76
|
+
schema?: string;
|
|
77
|
+
/**
|
|
78
|
+
* HTTP headers forwarded when fetching a remote schema.
|
|
79
|
+
* Only used when `schema` is a URL.
|
|
80
|
+
*/
|
|
81
|
+
schemaHeaders?: Record<string, string>;
|
|
82
|
+
/**
|
|
83
|
+
* Output directory for generated files.
|
|
84
|
+
* Alias for `targetDir` for better clarity.
|
|
85
|
+
*/
|
|
86
|
+
outputDir?: string;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Load configuration from .typedgqlrc.toml file.
|
|
90
|
+
*
|
|
91
|
+
* @param configPath - Path to the config file (defaults to .typedgqlrc.toml in cwd)
|
|
92
|
+
* @returns Parsed configuration object or undefined if file doesn't exist
|
|
93
|
+
*/
|
|
94
|
+
declare function loadConfig(configPath?: string): Promise<TypedGqlConfig | undefined>;
|
|
95
|
+
/**
|
|
96
|
+
* Merge configuration from file with programmatic options.
|
|
97
|
+
* Programmatic options take precedence over file config.
|
|
98
|
+
*
|
|
99
|
+
* @param fileConfig - Configuration loaded from .typedgqlrc.toml
|
|
100
|
+
* @param programmaticConfig - Configuration passed programmatically
|
|
101
|
+
* @returns Merged configuration
|
|
102
|
+
*/
|
|
103
|
+
declare function mergeConfig(fileConfig: TypedGqlConfig | undefined, programmaticConfig: Partial<TypedGqlConfig>): TypedGqlConfig;
|
|
104
|
+
//#endregion
|
|
105
|
+
export { type CodegenOptions, Generator, type TypedGqlConfig, loadConfig, loadLocalSchema, loadRemoteSchema, mergeConfig };
|
|
45
106
|
//# sourceMappingURL=node.d.mts.map
|
package/dist/node.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.d.mts","names":[],"sources":["../src/codegen/generator.ts","../src/codegen/schema-loader.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"node.d.mts","names":[],"sources":["../src/codegen/generator.ts","../src/codegen/schema-loader.ts","../src/codegen/config-loader.ts"],"mappings":";;;;cAgEa,SAAA;EAAA,UAKW,OAAA,EAAS,cAAA;EAAA,QAJvB,WAAA;EAAA,QACA,iBAAA;EAAA,QACA,eAAA;cAEc,OAAA,EAAS,cAAA;EAAA;EAAA,YAGnB,SAAA,CAAA;EA4FE;;;;EAAA,QApFA,kBAAA;EAdN;;;;EAAA,QAyCA,gBAAA;EAAA,YAaI,uBAAA,CAAA;EAAA,YAMA,yBAAA,CAAA;EAAA,YAMA,iCAAA,CAAA;EAAA,YAIA,wBAAA,CAAA;EAVA;;;EAAA,QAoBE,oBAAA;EAkBR,QAAA,CAAA,GAAQ,OAAA;EAAA,QAwJN,qBAAA;EAAA,QAeA,uCAAA;EAAA,QAOM,sBAAA;EAAA,QAqEA,kBAAA;EAAA,QAYA,iBAAA;EAAA,QAeA,qBAAA;EAAA,QAgBA,yBAAA;EAAA,QAaA,gBAAA;EAAA,QAeA,oBAAA;EAAA,QAUA,mBAAA;EAAA,QA8BN,qBAAA;EAAA,QAeM,UAAA;EAAA;;;;;EAAA,QAyFA,sBAAA;EAAA,QAcA,sCAAA;EAAA,QAuCN,qBAAA;EAAA,QAgFA,iBAAA;EAAA,QAeA,kBAAA;EAAA,QAiBA,cAAA;EAAA,QAqFA,8BAAA;EAAA,QAWA,cAAA;AAAA;;;iBC/2BY,gBAAA,CACpB,QAAA,UACA,OAAA;EAAA,CAAa,GAAA;AAAA,IACZ,OAAA,CAAQ,aAAA;AAAA,iBAuBW,eAAA,CACpB,QAAA,WACC,OAAA,CAAQ,aAAA;;;;;;ADgCX;UExCiB,cAAA,SACP,IAAA,CAAK,cAAA;;;;;;EAMb,MAAA;EFsCsB;;;;EEjCtB,aAAA,GAAgB,MAAA;;;;;EAKhB,SAAA;AAAA;;;;;;;iBASoB,UAAA,CACpB,UAAA,YACC,OAAA,CAAQ,cAAA;;;;;;;;;iBAqCK,WAAA,CACd,UAAA,EAAY,cAAA,cACZ,kBAAA,EAAoB,OAAA,CAAQ,cAAA,IAC3B,cAAA"}
|
package/dist/node.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as Generator, i as loadRemoteSchema, n as mergeConfig, r as loadLocalSchema, t as loadConfig } from "./config-loader-DZ7d_CWR.mjs";
|
|
2
2
|
|
|
3
|
-
export { Generator, loadLocalSchema, loadRemoteSchema };
|
|
3
|
+
export { Generator, loadConfig, loadLocalSchema, loadRemoteSchema, mergeConfig };
|
|
@@ -19,8 +19,17 @@ interface CodegenOptions {
|
|
|
19
19
|
* Output directory for generated files.
|
|
20
20
|
*
|
|
21
21
|
* If omitted, generator default path is used by caller.
|
|
22
|
+
* @alias outputDir - Can also be specified as `outputDir` in config files
|
|
22
23
|
*/
|
|
23
24
|
readonly targetDir?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to format generated files with Prettier.
|
|
27
|
+
*
|
|
28
|
+
* - `undefined`: auto-detect Prettier for custom output directories.
|
|
29
|
+
* - `true`: format when Prettier is available.
|
|
30
|
+
* - `false`: never format generated files.
|
|
31
|
+
*/
|
|
32
|
+
readonly prettier?: boolean;
|
|
24
33
|
/**
|
|
25
34
|
* Indentation string used in generated files.
|
|
26
35
|
*
|
|
@@ -102,4 +111,4 @@ interface CodegenOptions {
|
|
|
102
111
|
}
|
|
103
112
|
//#endregion
|
|
104
113
|
export { CodegenOptions as t };
|
|
105
|
-
//# sourceMappingURL=options-
|
|
114
|
+
//# sourceMappingURL=options-B6mcYDIz.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-B6mcYDIz.d.cts","names":[],"sources":["../src/codegen/options.ts"],"mappings":";;;;;AAQA;;;;UAAiB,cAAA;EAsDU;;;;;;EAAA,SA/ChB,YAAA,QAAoB,OAAA,CAAQ,aAAA;EAe5B;;;;;;EAAA,SARA,SAAA;EAmDA;;;;;;;EAAA,SA3CA,QAAA;EA0EM;;;;;EAAA,SApEN,MAAA;;;;;;;WAOA,cAAA;;;;;;;WAOA,aAAA;;;;;;;;WAQA,eAAA;;;;WAIA,aAAA,GAAgB,aAAA;;;;;;;;;;;WAWhB,aAAA;IAAA,UACG,GAAA;EAAA;;;;;;;;WASH,sBAAA;;;;;;WAMA,UAAA;IAAA,UAAyB,GAAA;EAAA;;;;;;WAMzB,0BAAA;IAAA,UAAyC,GAAA;EAAA;;;;;;;;;WASzC,MAAA;AAAA"}
|
|
@@ -19,8 +19,17 @@ interface CodegenOptions {
|
|
|
19
19
|
* Output directory for generated files.
|
|
20
20
|
*
|
|
21
21
|
* If omitted, generator default path is used by caller.
|
|
22
|
+
* @alias outputDir - Can also be specified as `outputDir` in config files
|
|
22
23
|
*/
|
|
23
24
|
readonly targetDir?: string;
|
|
25
|
+
/**
|
|
26
|
+
* Whether to format generated files with Prettier.
|
|
27
|
+
*
|
|
28
|
+
* - `undefined`: auto-detect Prettier for custom output directories.
|
|
29
|
+
* - `true`: format when Prettier is available.
|
|
30
|
+
* - `false`: never format generated files.
|
|
31
|
+
*/
|
|
32
|
+
readonly prettier?: boolean;
|
|
24
33
|
/**
|
|
25
34
|
* Indentation string used in generated files.
|
|
26
35
|
*
|
|
@@ -102,4 +111,4 @@ interface CodegenOptions {
|
|
|
102
111
|
}
|
|
103
112
|
//#endregion
|
|
104
113
|
export { CodegenOptions as t };
|
|
105
|
-
//# sourceMappingURL=options-
|
|
114
|
+
//# sourceMappingURL=options-T07dJfbz.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options-T07dJfbz.d.mts","names":[],"sources":["../src/codegen/options.ts"],"mappings":";;;;;AAQA;;;;UAAiB,cAAA;EAsDU;;;;;;EAAA,SA/ChB,YAAA,QAAoB,OAAA,CAAQ,aAAA;EAe5B;;;;;;EAAA,SARA,SAAA;EAmDA;;;;;;;EAAA,SA3CA,QAAA;EA0EM;;;;;EAAA,SApEN,MAAA;;;;;;;WAOA,cAAA;;;;;;;WAOA,aAAA;;;;;;;;WAQA,eAAA;;;;WAIA,aAAA,GAAgB,aAAA;;;;;;;;;;;WAWhB,aAAA;IAAA,UACG,GAAA;EAAA;;;;;;;;WASH,sBAAA;;;;;;WAMA,UAAA;IAAA,UAAyB,GAAA;EAAA;;;;;;WAMzB,0BAAA;IAAA,UAAyC,GAAA;EAAA;;;;;;;;;WASzC,MAAA;AAAA"}
|
package/dist/runtime.cjs
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_cyrb53 = require('./cyrb53-BTzxwvXR.cjs');
|
|
3
|
+
|
|
4
|
+
exports.EnumInputMetadataBuilder = require_cyrb53.EnumInputMetadataBuilder;
|
|
5
|
+
exports.FragmentRef = require_cyrb53.FragmentRef;
|
|
6
|
+
exports.FragmentSpread = require_cyrb53.FragmentSpread;
|
|
7
|
+
exports.ParameterRef = require_cyrb53.ParameterRef;
|
|
8
|
+
exports.SelectionNode = require_cyrb53.SelectionImpl;
|
|
9
|
+
exports.StringValue = require_cyrb53.StringValue;
|
|
10
|
+
exports.TextBuilder = require_cyrb53.TextBuilder;
|
|
11
|
+
exports.__parameterRefMarker = require_cyrb53.__marker;
|
|
12
|
+
exports.createSchemaType = require_cyrb53.createSchemaType;
|
|
13
|
+
exports.createSelection = require_cyrb53.createSelection;
|
|
14
|
+
exports.cyrb53 = require_cyrb53.cyrb53;
|
|
15
|
+
exports.registerSchemaTypeFactory = require_cyrb53.registerSchemaTypeFactory;
|
|
16
|
+
exports.resolveRegisteredSchemaType = require_cyrb53.resolveRegisteredSchemaType;
|
|
17
|
+
exports.runtimeOf = require_cyrb53.runtimeOf;
|
|
18
|
+
exports.withOperationName = require_cyrb53.withOperationName;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as createSchemaType, C as ParameterRef, D as SchemaFieldCategory, E as SchemaField, M as resolveRegisteredSchemaType, O as SchemaType, S as AcceptableVariables, T as __marker, _ as StringValue, a as withOperationName, b as runtimeOf, c as EnumInputMetadataBuilder, d as Expand, f as FieldSelection, g as ShapeOf, h as Selection, i as SelectionImpl, j as registerSchemaTypeFactory, k as SchemaTypeCategory, l as DirectiveArgs, m as FragmentSpread, n as TextBuilder, o as EnumInputMetaType, p as FragmentRef, r as createSelection, s as EnumInputMetadata, t as cyrb53, u as ExecutableSelection, v as ValueOrThunk, w as UnresolvedVariables, x as FieldOptions, y as VariablesOf } from "./cyrb53-FbY3n_2r.cjs";
|
|
2
|
+
export { type AcceptableVariables, type DirectiveArgs, type EnumInputMetaType, type EnumInputMetadata, EnumInputMetadataBuilder, type ExecutableSelection, type Expand, type FieldOptions, type FieldSelection, FragmentRef, FragmentSpread, ParameterRef, type SchemaField, type SchemaFieldCategory, type SchemaType, type SchemaTypeCategory, type Selection, SelectionImpl as SelectionNode, type ShapeOf, StringValue, TextBuilder, type UnresolvedVariables, type ValueOrThunk, type VariablesOf, __marker as __parameterRefMarker, createSchemaType, createSelection, cyrb53, registerSchemaTypeFactory, resolveRegisteredSchemaType, runtimeOf, withOperationName };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { A as createSchemaType, C as ParameterRef, D as SchemaFieldCategory, E as SchemaField, M as resolveRegisteredSchemaType, O as SchemaType, S as AcceptableVariables, T as __marker, _ as StringValue, a as withOperationName, b as runtimeOf, c as EnumInputMetadataBuilder, d as Expand, f as FieldSelection, g as ShapeOf, h as Selection, i as SelectionImpl, j as registerSchemaTypeFactory, k as SchemaTypeCategory, l as DirectiveArgs, m as FragmentSpread, n as TextBuilder, o as EnumInputMetaType, p as FragmentRef, r as createSelection, s as EnumInputMetadata, t as cyrb53, u as ExecutableSelection, v as ValueOrThunk, w as UnresolvedVariables, x as FieldOptions, y as VariablesOf } from "./cyrb53-DWYFRdWZ.mjs";
|
|
2
|
+
export { type AcceptableVariables, type DirectiveArgs, type EnumInputMetaType, type EnumInputMetadata, EnumInputMetadataBuilder, type ExecutableSelection, type Expand, type FieldOptions, type FieldSelection, FragmentRef, FragmentSpread, ParameterRef, type SchemaField, type SchemaFieldCategory, type SchemaType, type SchemaTypeCategory, type Selection, SelectionImpl as SelectionNode, type ShapeOf, StringValue, TextBuilder, type UnresolvedVariables, type ValueOrThunk, type VariablesOf, __marker as __parameterRefMarker, createSchemaType, createSelection, cyrb53, registerSchemaTypeFactory, resolveRegisteredSchemaType, runtimeOf, withOperationName };
|
package/dist/runtime.mjs
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { a as withOperationName, c as __marker, d as resolveRegisteredSchemaType, f as FragmentRef, h as runtimeOf, i as SelectionImpl, l as createSchemaType, m as StringValue, n as createSelection, o as TextBuilder, p as FragmentSpread, r as EnumInputMetadataBuilder, s as ParameterRef, t as cyrb53, u as registerSchemaTypeFactory } from "./cyrb53-B2tdX6NT.mjs";
|
|
2
|
+
|
|
3
|
+
export { EnumInputMetadataBuilder, FragmentRef, FragmentSpread, ParameterRef, SelectionImpl as SelectionNode, StringValue, TextBuilder, __marker as __parameterRefMarker, createSchemaType, createSelection, cyrb53, registerSchemaTypeFactory, resolveRegisteredSchemaType, runtimeOf, withOperationName };
|
package/dist/vite.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
-
const
|
|
2
|
+
const require_config_loader = require('./config-loader-Bxj44SGD.cjs');
|
|
3
3
|
let node_fs_promises = require("node:fs/promises");
|
|
4
4
|
let node_crypto = require("node:crypto");
|
|
5
5
|
let node_path = require("node:path");
|
|
@@ -13,7 +13,7 @@ const isRemote = (schema) => {
|
|
|
13
13
|
return /^https?:\/\//.test(schema);
|
|
14
14
|
};
|
|
15
15
|
const makeSchemaLoader = (schema, headers) => {
|
|
16
|
-
return isRemote(schema) ? () =>
|
|
16
|
+
return isRemote(schema) ? () => require_config_loader.loadRemoteSchema(schema, headers) : () => require_config_loader.loadLocalSchema(schema);
|
|
17
17
|
};
|
|
18
18
|
const buildNegatedWatchPattern = (packageName) => {
|
|
19
19
|
return `!**/node_modules/${packageName}/**`;
|
|
@@ -33,6 +33,7 @@ const hashFile = async (path) => {
|
|
|
33
33
|
*
|
|
34
34
|
* - **Local schema** — runs once on startup, then watches for file changes.
|
|
35
35
|
* - **Remote schema** — runs on every `vite dev` / `vite build` invocation.
|
|
36
|
+
* - **Config file** — if no schema is provided, loads from .typedgqlrc.toml
|
|
36
37
|
*
|
|
37
38
|
* @example
|
|
38
39
|
* ```ts
|
|
@@ -45,29 +46,44 @@ const hashFile = async (path) => {
|
|
|
45
46
|
* typedgql({ schema: "./schema.graphql" }),
|
|
46
47
|
* // or remote endpoint
|
|
47
48
|
* typedgql({ schema: "http://localhost:4000/graphql" }),
|
|
49
|
+
* // or use .typedgqlrc.toml config file
|
|
50
|
+
* typedgql(),
|
|
48
51
|
* ],
|
|
49
52
|
* });
|
|
50
53
|
* ```
|
|
51
54
|
*/
|
|
52
55
|
function typedgql(options) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
};
|
|
56
|
+
let resolvedOptions;
|
|
57
|
+
let schema;
|
|
58
|
+
let remote;
|
|
59
|
+
let codegenOptions;
|
|
60
|
+
let initialized = false;
|
|
59
61
|
let isRunning = false;
|
|
60
62
|
let isDependencyRefreshRunning = false;
|
|
61
63
|
let lastSchemaHash;
|
|
62
64
|
let initSchemaHashPromise;
|
|
63
65
|
let resolvedConfig;
|
|
64
66
|
let logger;
|
|
67
|
+
async function initializeOptions() {
|
|
68
|
+
if (initialized) return;
|
|
69
|
+
resolvedOptions = require_config_loader.mergeConfig(await require_config_loader.loadConfig(), options ?? {});
|
|
70
|
+
if (resolvedOptions.outputDir && !resolvedOptions.targetDir) resolvedOptions.targetDir = resolvedOptions.outputDir;
|
|
71
|
+
if (!resolvedOptions.schema) throw new Error("typedgql: 'schema' option is required. Provide it in plugin options or in .typedgqlrc.toml config file.");
|
|
72
|
+
schema = resolvedOptions.schema;
|
|
73
|
+
remote = isRemote(schema);
|
|
74
|
+
const { schema: _, schemaHeaders, outputDir: __, ...generatorOptions } = resolvedOptions;
|
|
75
|
+
codegenOptions = {
|
|
76
|
+
...generatorOptions,
|
|
77
|
+
schemaLoader: makeSchemaLoader(schema, schemaHeaders)
|
|
78
|
+
};
|
|
79
|
+
initialized = true;
|
|
80
|
+
}
|
|
65
81
|
async function runCodegen(trigger) {
|
|
66
82
|
if (isRunning) return;
|
|
67
83
|
isRunning = true;
|
|
68
84
|
const label = `\x1b[36m[typedgql:${trigger}]\x1b[0m`;
|
|
69
85
|
try {
|
|
70
|
-
await new
|
|
86
|
+
await new require_config_loader.Generator(codegenOptions).generate();
|
|
71
87
|
} catch (err) {
|
|
72
88
|
logger.error(`${label} failed: ${err}`);
|
|
73
89
|
} finally {
|
|
@@ -92,6 +108,7 @@ function typedgql(options) {
|
|
|
92
108
|
logger = cfg.logger;
|
|
93
109
|
},
|
|
94
110
|
async buildStart() {
|
|
111
|
+
await initializeOptions();
|
|
95
112
|
await runCodegen(resolvedConfig?.command === "build" ? "build" : "start");
|
|
96
113
|
},
|
|
97
114
|
configureServer(server) {
|
|
@@ -109,26 +126,28 @@ function typedgql(options) {
|
|
|
109
126
|
isDependencyRefreshRunning = false;
|
|
110
127
|
}
|
|
111
128
|
});
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
129
|
+
initializeOptions().then(() => {
|
|
130
|
+
if (!schema || remote) return;
|
|
131
|
+
const root = server.config.root;
|
|
132
|
+
const schemaPath = (0, vite.normalizePath)((0, node_path.resolve)(root, schema));
|
|
133
|
+
let realSchemaPath = schemaPath;
|
|
134
|
+
(0, node_fs_promises.realpath)(schemaPath).then((actualPath) => {
|
|
135
|
+
realSchemaPath = (0, vite.normalizePath)(actualPath);
|
|
136
|
+
}).catch(() => {});
|
|
137
|
+
server.watcher.add(schemaPath);
|
|
138
|
+
initSchemaHashPromise = hashFile(schemaPath).then((hash) => {
|
|
139
|
+
lastSchemaHash = hash;
|
|
140
|
+
});
|
|
141
|
+
server.watcher.on("change", async (file) => {
|
|
142
|
+
const changedPath = (0, vite.normalizePath)(file);
|
|
143
|
+
if (changedPath !== schemaPath && changedPath !== realSchemaPath) return;
|
|
144
|
+
await initSchemaHashPromise;
|
|
145
|
+
const nextHash = await hashFile(schemaPath);
|
|
146
|
+
if (nextHash && nextHash === lastSchemaHash) return;
|
|
147
|
+
await runCodegen("watch");
|
|
148
|
+
if (nextHash) lastSchemaHash = nextHash;
|
|
149
|
+
await server.restart(true);
|
|
150
|
+
});
|
|
132
151
|
});
|
|
133
152
|
}
|
|
134
153
|
};
|
package/dist/vite.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CodegenOptions } from "./options-
|
|
1
|
+
import { t as CodegenOptions } from "./options-B6mcYDIz.cjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/vite-plugin.d.ts
|
|
@@ -10,19 +10,27 @@ interface TypedGqlPluginOptions extends Omit<CodegenOptions, "schemaLoader"> {
|
|
|
10
10
|
*
|
|
11
11
|
* Local file → codegen runs on startup, then re-runs on every file change.
|
|
12
12
|
* Remote URL → codegen runs on every `vite dev` / `vite build` invocation.
|
|
13
|
+
*
|
|
14
|
+
* If omitted, will attempt to load from .typedgqlrc.toml config file.
|
|
13
15
|
*/
|
|
14
|
-
schema
|
|
16
|
+
schema?: string;
|
|
15
17
|
/**
|
|
16
18
|
* HTTP headers forwarded when fetching a remote schema.
|
|
17
19
|
* Only used when `schema` is a URL.
|
|
18
20
|
*/
|
|
19
21
|
schemaHeaders?: Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* Output directory for generated files.
|
|
24
|
+
* Alias for `targetDir` for better clarity.
|
|
25
|
+
*/
|
|
26
|
+
outputDir?: string;
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
29
|
* Vite plugin that runs typedgql codegen automatically.
|
|
23
30
|
*
|
|
24
31
|
* - **Local schema** — runs once on startup, then watches for file changes.
|
|
25
32
|
* - **Remote schema** — runs on every `vite dev` / `vite build` invocation.
|
|
33
|
+
* - **Config file** — if no schema is provided, loads from .typedgqlrc.toml
|
|
26
34
|
*
|
|
27
35
|
* @example
|
|
28
36
|
* ```ts
|
|
@@ -35,11 +43,13 @@ interface TypedGqlPluginOptions extends Omit<CodegenOptions, "schemaLoader"> {
|
|
|
35
43
|
* typedgql({ schema: "./schema.graphql" }),
|
|
36
44
|
* // or remote endpoint
|
|
37
45
|
* typedgql({ schema: "http://localhost:4000/graphql" }),
|
|
46
|
+
* // or use .typedgqlrc.toml config file
|
|
47
|
+
* typedgql(),
|
|
38
48
|
* ],
|
|
39
49
|
* });
|
|
40
50
|
* ```
|
|
41
51
|
*/
|
|
42
|
-
declare function typedgql(options
|
|
52
|
+
declare function typedgql(options?: TypedGqlPluginOptions): Plugin;
|
|
43
53
|
//#endregion
|
|
44
54
|
export { type TypedGqlPluginOptions, typedgql };
|
|
45
55
|
//# sourceMappingURL=vite.d.cts.map
|
package/dist/vite.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.cts","names":[],"sources":["../src/vite-plugin.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"vite.d.cts","names":[],"sources":["../src/vite-plugin.ts"],"mappings":";;;;UAeiB,qBAAA,SAA8B,IAAA,CAC7C,cAAA;;;;;;;;;;;EAaA,MAAA;EAUA;;;AAwDF;EA7DE,aAAA,GAAgB,MAAA;;;;;EAKhB,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;iBAwDc,QAAA,CAAS,OAAA,GAAU,qBAAA,GAAwB,MAAA"}
|
package/dist/vite.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as CodegenOptions } from "./options-
|
|
1
|
+
import { t as CodegenOptions } from "./options-T07dJfbz.mjs";
|
|
2
2
|
import { Plugin } from "vite";
|
|
3
3
|
|
|
4
4
|
//#region src/vite-plugin.d.ts
|
|
@@ -10,19 +10,27 @@ interface TypedGqlPluginOptions extends Omit<CodegenOptions, "schemaLoader"> {
|
|
|
10
10
|
*
|
|
11
11
|
* Local file → codegen runs on startup, then re-runs on every file change.
|
|
12
12
|
* Remote URL → codegen runs on every `vite dev` / `vite build` invocation.
|
|
13
|
+
*
|
|
14
|
+
* If omitted, will attempt to load from .typedgqlrc.toml config file.
|
|
13
15
|
*/
|
|
14
|
-
schema
|
|
16
|
+
schema?: string;
|
|
15
17
|
/**
|
|
16
18
|
* HTTP headers forwarded when fetching a remote schema.
|
|
17
19
|
* Only used when `schema` is a URL.
|
|
18
20
|
*/
|
|
19
21
|
schemaHeaders?: Record<string, string>;
|
|
22
|
+
/**
|
|
23
|
+
* Output directory for generated files.
|
|
24
|
+
* Alias for `targetDir` for better clarity.
|
|
25
|
+
*/
|
|
26
|
+
outputDir?: string;
|
|
20
27
|
}
|
|
21
28
|
/**
|
|
22
29
|
* Vite plugin that runs typedgql codegen automatically.
|
|
23
30
|
*
|
|
24
31
|
* - **Local schema** — runs once on startup, then watches for file changes.
|
|
25
32
|
* - **Remote schema** — runs on every `vite dev` / `vite build` invocation.
|
|
33
|
+
* - **Config file** — if no schema is provided, loads from .typedgqlrc.toml
|
|
26
34
|
*
|
|
27
35
|
* @example
|
|
28
36
|
* ```ts
|
|
@@ -35,11 +43,13 @@ interface TypedGqlPluginOptions extends Omit<CodegenOptions, "schemaLoader"> {
|
|
|
35
43
|
* typedgql({ schema: "./schema.graphql" }),
|
|
36
44
|
* // or remote endpoint
|
|
37
45
|
* typedgql({ schema: "http://localhost:4000/graphql" }),
|
|
46
|
+
* // or use .typedgqlrc.toml config file
|
|
47
|
+
* typedgql(),
|
|
38
48
|
* ],
|
|
39
49
|
* });
|
|
40
50
|
* ```
|
|
41
51
|
*/
|
|
42
|
-
declare function typedgql(options
|
|
52
|
+
declare function typedgql(options?: TypedGqlPluginOptions): Plugin;
|
|
43
53
|
//#endregion
|
|
44
54
|
export { type TypedGqlPluginOptions, typedgql };
|
|
45
55
|
//# sourceMappingURL=vite.d.mts.map
|
package/dist/vite.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.mts","names":[],"sources":["../src/vite-plugin.ts"],"mappings":";;;;
|
|
1
|
+
{"version":3,"file":"vite.d.mts","names":[],"sources":["../src/vite-plugin.ts"],"mappings":";;;;UAeiB,qBAAA,SAA8B,IAAA,CAC7C,cAAA;;;;;;;;;;;EAaA,MAAA;EAUA;;;AAwDF;EA7DE,aAAA,GAAgB,MAAA;;;;;EAKhB,SAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;iBAwDc,QAAA,CAAS,OAAA,GAAU,qBAAA,GAAwB,MAAA"}
|