@newmo/graphql-fake-core 0.3.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/LICENSE +23 -0
- package/README.md +97 -0
- package/dist/esm/code-generator.d.ts +12 -0
- package/dist/esm/code-generator.d.ts.map +1 -0
- package/dist/esm/code-generator.js +98 -0
- package/dist/esm/code-generator.js.map +1 -0
- package/dist/esm/config.d.ts +49 -0
- package/dist/esm/config.d.ts.map +1 -0
- package/dist/esm/config.js +71 -0
- package/dist/esm/config.js.map +1 -0
- package/dist/esm/extend-schema.d.ts +3 -0
- package/dist/esm/extend-schema.d.ts.map +1 -0
- package/dist/esm/extend-schema.js +62 -0
- package/dist/esm/extend-schema.js.map +1 -0
- package/dist/esm/index.d.ts +8 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +5 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/schema-scanner.d.ts +32 -0
- package/dist/esm/schema-scanner.d.ts.map +1 -0
- package/dist/esm/schema-scanner.js +306 -0
- package/dist/esm/schema-scanner.js.map +1 -0
- package/package.json +69 -0
- package/src/code-generator.ts +119 -0
- package/src/config.ts +117 -0
- package/src/extend-schema.ts +61 -0
- package/src/index.ts +14 -0
- package/src/schema-scanner.ts +454 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 newmo, Inc.
|
|
4
|
+
Copyright (c) 2023 mizdra
|
|
5
|
+
Copyright (c) 2022 Yosuke Kurami
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
9
|
+
in the Software without restriction, including without limitation the rights
|
|
10
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
11
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
12
|
+
furnished to do so, subject to the following conditions:
|
|
13
|
+
|
|
14
|
+
The above copyright notice and this permission notice shall be included in all
|
|
15
|
+
copies or substantial portions of the Software.
|
|
16
|
+
|
|
17
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
18
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
19
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
20
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
21
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
22
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
23
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# @newmo/graphql-fake-server
|
|
2
|
+
|
|
3
|
+
GraphQL Fake Server.
|
|
4
|
+
|
|
5
|
+
## Motivation
|
|
6
|
+
|
|
7
|
+
- Static Path
|
|
8
|
+
- Support Declarative Fake via `@example` directive.
|
|
9
|
+
- [ ] Dynamic Path
|
|
10
|
+
- Support Framework-Agnostic Fake for testing via HTTP
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
1. Add `@exampleID`, `@exampleString`, `@exampleInt`, `@exampleFloat`, `@exampleBoolean` directive to your schema.
|
|
15
|
+
|
|
16
|
+
```graphql
|
|
17
|
+
"""
|
|
18
|
+
@exampleID directive specifies an example value for a ID field.
|
|
19
|
+
This example value is used in the fake data.
|
|
20
|
+
ID value will be unique between all ID fake data.
|
|
21
|
+
"""
|
|
22
|
+
directive @exampleID(
|
|
23
|
+
"""
|
|
24
|
+
The value of the ID field.
|
|
25
|
+
@exampleID(value: "id")
|
|
26
|
+
"""
|
|
27
|
+
value: ID!
|
|
28
|
+
) on FIELD_DEFINITION
|
|
29
|
+
"""
|
|
30
|
+
@exampleString directive specifies an example value for a String field.
|
|
31
|
+
This example value is used in the fake data.
|
|
32
|
+
"""
|
|
33
|
+
directive @exampleString(
|
|
34
|
+
"""
|
|
35
|
+
The value of the String field.
|
|
36
|
+
@exampleString(value: "example")
|
|
37
|
+
"""
|
|
38
|
+
value: String!
|
|
39
|
+
) on FIELD_DEFINITION
|
|
40
|
+
"""
|
|
41
|
+
@exampleInt directive specifies an example value for a Inf field.
|
|
42
|
+
This example value is used in the fake data.
|
|
43
|
+
"""
|
|
44
|
+
directive @exampleInt(
|
|
45
|
+
"""
|
|
46
|
+
The value of the Int field.
|
|
47
|
+
@exampleInt(value: 1)
|
|
48
|
+
"""
|
|
49
|
+
value: Int!
|
|
50
|
+
) on FIELD_DEFINITION
|
|
51
|
+
"""
|
|
52
|
+
@exampleFloat directive specifies an example value for a Float field.
|
|
53
|
+
This example value is used in the fake data.
|
|
54
|
+
"""
|
|
55
|
+
directive @exampleFloat(
|
|
56
|
+
"""
|
|
57
|
+
The value of the Float field.
|
|
58
|
+
@exampleFloat(value: 1.0)
|
|
59
|
+
"""
|
|
60
|
+
value: Float!
|
|
61
|
+
) on FIELD_DEFINITION
|
|
62
|
+
"""
|
|
63
|
+
@exampleBoolean directive specifies an example value for a Boolean field.
|
|
64
|
+
This example value is used in the fake data.
|
|
65
|
+
"""
|
|
66
|
+
directive @exampleBoolean(
|
|
67
|
+
"""
|
|
68
|
+
The value of the Boolean field.
|
|
69
|
+
@exampleBoolean(value: true)
|
|
70
|
+
"""
|
|
71
|
+
value: Boolean!
|
|
72
|
+
) on FIELD_DEFINITION
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Usage
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
## Tests
|
|
79
|
+
|
|
80
|
+
- [ ] Write How to Tests
|
|
81
|
+
|
|
82
|
+
## Contributing
|
|
83
|
+
|
|
84
|
+
1. Fork it!
|
|
85
|
+
2. Create your feature branch: `git checkout -b my-new-feature`
|
|
86
|
+
3. Commit your changes: `git commit -am 'Add some feature'`
|
|
87
|
+
4. Push to the branch: `git push origin my-new-feature`
|
|
88
|
+
5. Submit a pull request :D
|
|
89
|
+
|
|
90
|
+
## License
|
|
91
|
+
|
|
92
|
+
MIT
|
|
93
|
+
|
|
94
|
+
## Credits
|
|
95
|
+
|
|
96
|
+
- [mizdra/graphql-codegen-typescript-fabbrica: GraphQL Code Generator Plugin to define fake data factory.](https://github.com/mizdra/graphql-codegen-typescript-fabbrica)
|
|
97
|
+
- [graphql-kit/graphql-faker: 🎲 Mock or extend your GraphQL API with faked data. No coding required.](https://github.com/graphql-kit/graphql-faker)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Config } from "./config.js";
|
|
2
|
+
import type { TypeInfo } from "./schema-scanner.js";
|
|
3
|
+
export type ConfigWithOutput = {
|
|
4
|
+
outputType: "typescript" | "javascript" | "commonjs";
|
|
5
|
+
} & Config;
|
|
6
|
+
export declare const generateCreateReferenceCode: ({ fieldName, typeName, config, }: {
|
|
7
|
+
fieldName: string;
|
|
8
|
+
typeName: string;
|
|
9
|
+
config: Config;
|
|
10
|
+
}) => string;
|
|
11
|
+
export declare function generateCode(config: ConfigWithOutput, typeInfos: TypeInfo[]): string;
|
|
12
|
+
//# sourceMappingURL=code-generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-generator.d.ts","sourceRoot":"","sources":["../../src/code-generator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,EAAoC,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAEtF,MAAM,MAAM,gBAAgB,GAAG;IAC3B,UAAU,EAAE,YAAY,GAAG,YAAY,GAAG,UAAU,CAAC;CACxD,GAAG,MAAM,CAAC;AAUX,eAAO,MAAM,2BAA2B,qCAIrC;IACC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;CAClB,KAAG,MASH,CAAC;AAqEF,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,QAAQ,EAAE,GAAG,MAAM,CAiBpF"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const handleExample = (exampleDirective) => {
|
|
2
|
+
if ("value" in exampleDirective) {
|
|
3
|
+
return JSON.stringify(exampleDirective.value);
|
|
4
|
+
}
|
|
5
|
+
if ("expression" in exampleDirective) {
|
|
6
|
+
return exampleDirective.expression;
|
|
7
|
+
}
|
|
8
|
+
throw new Error(`Invalid example directive${JSON.stringify(exampleDirective)}`);
|
|
9
|
+
};
|
|
10
|
+
export const generateCreateReferenceCode = ({ fieldName, typeName, config, }) => {
|
|
11
|
+
/**
|
|
12
|
+
* function createAuthor({ defaultFields, depth = 0 }: { defaultFields?: Partial<Author>, depth?: number } = {}): Author {
|
|
13
|
+
* return {
|
|
14
|
+
* foo: depth < 1 ? createAuthor({ defaultFields: defaultFields?.foo, depth: depth + 1 }) : undefined,
|
|
15
|
+
* }
|
|
16
|
+
*}
|
|
17
|
+
*/
|
|
18
|
+
return `(depth < ${config.maxFieldRecursionDepth} ? create${typeName}({ defaultFields: defaultFields?.${fieldName} ?? {}, depth: depth + 1 }) : undefined)`;
|
|
19
|
+
};
|
|
20
|
+
function generateExampleCode(config, typeInfo) {
|
|
21
|
+
const { name } = typeInfo;
|
|
22
|
+
const indent = " ";
|
|
23
|
+
const isTypescript = config.outputType === "typescript";
|
|
24
|
+
const functionBodyCode = `
|
|
25
|
+
${indent}return {
|
|
26
|
+
${typeInfo.fields
|
|
27
|
+
.map((field) => {
|
|
28
|
+
const example = field.example ? handleExample(field.example) : "undefined";
|
|
29
|
+
return `${indent}${indent}${field.name}: ${example},`;
|
|
30
|
+
})
|
|
31
|
+
.join("\n")}
|
|
32
|
+
${indent}};
|
|
33
|
+
`.trim();
|
|
34
|
+
if (config.outputType === "commonjs") {
|
|
35
|
+
return `
|
|
36
|
+
function create${name}({ defaultFields, depth = 0 } = {}) {
|
|
37
|
+
${functionBodyCode}
|
|
38
|
+
}
|
|
39
|
+
exports.create${name} = create${name};
|
|
40
|
+
`.trim();
|
|
41
|
+
}
|
|
42
|
+
return `
|
|
43
|
+
export function create${name}({ defaultFields, depth = 0 }${isTypescript ? `: { defaultFields?: Partial<${name}>, depth?: number }` : ""} = {})${isTypescript ? `: ${name}Type` : ""} {
|
|
44
|
+
${functionBodyCode}
|
|
45
|
+
}
|
|
46
|
+
`.trimStart();
|
|
47
|
+
}
|
|
48
|
+
function generateDefaultCode(config, typeInfo) {
|
|
49
|
+
const { name } = typeInfo;
|
|
50
|
+
if (config.outputType === "commonjs") {
|
|
51
|
+
return `const ${name} = create${name}();
|
|
52
|
+
exports.${name} = ${name};`;
|
|
53
|
+
}
|
|
54
|
+
return `export const ${name} = create${name}();`;
|
|
55
|
+
}
|
|
56
|
+
function generateImportTypeCode(config, typeInfos) {
|
|
57
|
+
const isTypescript = config.outputType === "typescript";
|
|
58
|
+
if (!isTypescript)
|
|
59
|
+
return "";
|
|
60
|
+
const indent = " ";
|
|
61
|
+
const joinedTypeNames = typeInfos
|
|
62
|
+
.filter(({ type }) => type === "object")
|
|
63
|
+
.map(({ name }) => `${indent}${name}`)
|
|
64
|
+
.join(",\n");
|
|
65
|
+
return `import type {
|
|
66
|
+
${joinedTypeNames}
|
|
67
|
+
} from '${config.typesFile}';`;
|
|
68
|
+
}
|
|
69
|
+
function idGeneratorCode(config) {
|
|
70
|
+
// __id("name);
|
|
71
|
+
const isTypescript = config.outputType === "typescript";
|
|
72
|
+
return `
|
|
73
|
+
const __idCountMap = new Map${isTypescript ? "<string, number>" : ""}()
|
|
74
|
+
function __id({ name, key, depth }${isTypescript ? "{ name: string; key: string; depth: number; }" : ""})${isTypescript ? ": string" : ""} {
|
|
75
|
+
const count = __idCountMap.get(key) ?? 0;
|
|
76
|
+
__idCountMap.set(key, count + 1);
|
|
77
|
+
return name + String(depth) + String(count);
|
|
78
|
+
}`;
|
|
79
|
+
}
|
|
80
|
+
export function generateCode(config, typeInfos) {
|
|
81
|
+
let code = "";
|
|
82
|
+
if (config.outputType === "typescript") {
|
|
83
|
+
code += generateImportTypeCode(config, typeInfos);
|
|
84
|
+
code += "\n";
|
|
85
|
+
}
|
|
86
|
+
code += idGeneratorCode(config);
|
|
87
|
+
code += "\n";
|
|
88
|
+
for (const typeInfo of typeInfos) {
|
|
89
|
+
if (typeInfo.type === "object") {
|
|
90
|
+
code += generateExampleCode(config, typeInfo);
|
|
91
|
+
code += "\n";
|
|
92
|
+
code += generateDefaultCode(config, typeInfo);
|
|
93
|
+
code += "\n";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return code;
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=code-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-generator.js","sourceRoot":"","sources":["../../src/code-generator.ts"],"names":[],"mappings":"AAMA,MAAM,aAAa,GAAG,CAAC,gBAAkC,EAAU,EAAE;IACjE,IAAI,OAAO,IAAI,gBAAgB,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAClD,CAAC;IACD,IAAI,YAAY,IAAI,gBAAgB,EAAE,CAAC;QACnC,OAAO,gBAAgB,CAAC,UAAU,CAAC;IACvC,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,4BAA4B,IAAI,CAAC,SAAS,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;AACpF,CAAC,CAAC;AACF,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,EACxC,SAAS,EACT,QAAQ,EACR,MAAM,GAKT,EAAU,EAAE;IACT;;;;;;OAMG;IACH,OAAO,YAAY,MAAM,CAAC,sBAAsB,YAAY,QAAQ,oCAAoC,SAAS,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I,IAAI,IAAI,CAAC;IACb,KAAK,MAAM,QAAQ,IAAI,SAAS,EAAE,CAAC;QAC/B,IAAI,QAAQ,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC7B,IAAI,IAAI,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAC9C,IAAI,IAAI,IAAI,CAAC;YACb,IAAI,IAAI,mBAAmB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;YAC9C,IAAI,IAAI,IAAI,CAAC;QACjB,CAAC;IACL,CAAC;IACD,OAAO,IAAI,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { RawTypesConfig } from "@graphql-codegen/visitor-plugin-common";
|
|
2
|
+
export type RawConfig = {
|
|
3
|
+
/**
|
|
4
|
+
* path to type definitions file
|
|
5
|
+
* this is generated by client preset
|
|
6
|
+
* e.g. ) "typeFile: "./graphql"
|
|
7
|
+
*/
|
|
8
|
+
typesFile?: string;
|
|
9
|
+
skipTypename?: RawTypesConfig["skipTypename"];
|
|
10
|
+
namingConvention?: RawTypesConfig["namingConvention"];
|
|
11
|
+
typesPrefix?: RawTypesConfig["typesPrefix"];
|
|
12
|
+
typesSuffix?: RawTypesConfig["typesSuffix"];
|
|
13
|
+
maxFieldRecursionDepth?: number;
|
|
14
|
+
defaultValues?: {
|
|
15
|
+
String?: string;
|
|
16
|
+
Int?: number;
|
|
17
|
+
Float?: number;
|
|
18
|
+
Boolean?: boolean;
|
|
19
|
+
ID?: string;
|
|
20
|
+
listLength?: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
export declare const DefaultValues: {
|
|
24
|
+
String: string;
|
|
25
|
+
Int: number;
|
|
26
|
+
Float: number;
|
|
27
|
+
Boolean: boolean;
|
|
28
|
+
ID: string;
|
|
29
|
+
listLength: number;
|
|
30
|
+
};
|
|
31
|
+
export type Config = {
|
|
32
|
+
typesFile: string;
|
|
33
|
+
skipTypename: Exclude<RawTypesConfig["skipTypename"], undefined>;
|
|
34
|
+
typesPrefix: Exclude<RawTypesConfig["typesPrefix"], undefined>;
|
|
35
|
+
typesSuffix: Exclude<RawTypesConfig["typesSuffix"], undefined>;
|
|
36
|
+
namingConvention: Exclude<RawTypesConfig["namingConvention"], undefined>;
|
|
37
|
+
maxFieldRecursionDepth: number;
|
|
38
|
+
defaultValues: {
|
|
39
|
+
String: string;
|
|
40
|
+
Int: number;
|
|
41
|
+
Float: number;
|
|
42
|
+
Boolean: boolean;
|
|
43
|
+
ID: string;
|
|
44
|
+
listLength: number;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
export declare function validateConfig(rawConfig: unknown, outputType?: "typescript" | "javascript"): asserts rawConfig is RawConfig;
|
|
48
|
+
export declare function normalizeConfig(rawConfig: RawConfig): Config;
|
|
49
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAE7E,MAAM,MAAM,SAAS,GAAG;IACpB;;;;OAIG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,cAAc,CAAC,cAAc,CAAC,CAAC;IAC9C,gBAAgB,CAAC,EAAE,cAAc,CAAC,kBAAkB,CAAC,CAAC;IACtD,WAAW,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;IAC5C,WAAW,CAAC,EAAE,cAAc,CAAC,aAAa,CAAC,CAAC;IAC5C,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE;QACZ,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,GAAG,CAAC,EAAE,MAAM,CAAC;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,OAAO,CAAC;QAClB,EAAE,CAAC,EAAE,MAAM,CAAC;QACZ,UAAU,CAAC,EAAE,MAAM,CAAC;KACvB,CAAC;CACL,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;CAOzB,CAAC;AACF,MAAM,MAAM,MAAM,GAAG;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,OAAO,CAAC,cAAc,CAAC,cAAc,CAAC,EAAE,SAAS,CAAC,CAAC;IACjE,WAAW,EAAE,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,CAAC;IAC/D,WAAW,EAAE,OAAO,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,SAAS,CAAC,CAAC;IAC/D,gBAAgB,EAAE,OAAO,CAAC,cAAc,CAAC,kBAAkB,CAAC,EAAE,SAAS,CAAC,CAAC;IACzE,sBAAsB,EAAE,MAAM,CAAC;IAC/B,aAAa,EAAE;QACX,MAAM,EAAE,MAAM,CAAC;QACf,GAAG,EAAE,MAAM,CAAC;QACZ,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,OAAO,CAAC;QACjB,EAAE,EAAE,MAAM,CAAC;QACX,UAAU,EAAE,MAAM,CAAC;KACtB,CAAC;CACL,CAAC;AAEF,wBAAgB,cAAc,CAC1B,SAAS,EAAE,OAAO,EAClB,UAAU,GAAE,YAAY,GAAG,YAA2B,GACvD,OAAO,CAAC,SAAS,IAAI,SAAS,CA6ChC;AAED,wBAAgB,eAAe,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAiB5D"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
export const DefaultValues = {
|
|
2
|
+
String: "string",
|
|
3
|
+
Int: 12,
|
|
4
|
+
Float: 12.3,
|
|
5
|
+
Boolean: true,
|
|
6
|
+
ID: "xxxx-xxxx-xxxx-xxxx",
|
|
7
|
+
listLength: 3,
|
|
8
|
+
};
|
|
9
|
+
export function validateConfig(rawConfig, outputType = "javascript") {
|
|
10
|
+
// defaultValues type validations
|
|
11
|
+
if (rawConfig === null || rawConfig === undefined) {
|
|
12
|
+
throw new Error("config.defaultValues must be an object");
|
|
13
|
+
}
|
|
14
|
+
if (typeof rawConfig !== "object") {
|
|
15
|
+
throw new Error("config.defaultValues must be an object");
|
|
16
|
+
}
|
|
17
|
+
if ("maxFieldRecursionDepth" in rawConfig) {
|
|
18
|
+
if (typeof rawConfig.maxFieldRecursionDepth !== "number") {
|
|
19
|
+
throw new Error("config.maxFieldRecursionDepth must be a number");
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
if (outputType === "typescript") {
|
|
23
|
+
if (!("typesFile" in rawConfig)) {
|
|
24
|
+
throw new Error("config.typesFile is required");
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if ("defaultValues" in rawConfig) {
|
|
28
|
+
if (typeof rawConfig.defaultValues !== "object") {
|
|
29
|
+
throw new Error("config.defaultValues must be an object");
|
|
30
|
+
}
|
|
31
|
+
const defaultValues = rawConfig.defaultValues;
|
|
32
|
+
if (defaultValues.String !== undefined && typeof defaultValues.String !== "string") {
|
|
33
|
+
throw new Error("config.defaultValues.String must be a string");
|
|
34
|
+
}
|
|
35
|
+
if (defaultValues.Int !== undefined && typeof defaultValues.Int !== "number") {
|
|
36
|
+
throw new Error("config.defaultValues.Int must be a number");
|
|
37
|
+
}
|
|
38
|
+
if (defaultValues.Float !== undefined && typeof defaultValues.Float !== "number") {
|
|
39
|
+
throw new Error("config.defaultValues.Float must be a number");
|
|
40
|
+
}
|
|
41
|
+
if (defaultValues.Boolean !== undefined && typeof defaultValues.Boolean !== "boolean") {
|
|
42
|
+
throw new Error("config.defaultValues.Boolean must be a boolean");
|
|
43
|
+
}
|
|
44
|
+
if (defaultValues.ID !== undefined && typeof defaultValues.ID !== "string") {
|
|
45
|
+
throw new Error("config.defaultValues.ID must be a string");
|
|
46
|
+
}
|
|
47
|
+
if (defaultValues.listLength !== undefined &&
|
|
48
|
+
typeof defaultValues.listLength !== "number") {
|
|
49
|
+
throw new Error("config.defaultValues.listLength must be a number");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function normalizeConfig(rawConfig) {
|
|
54
|
+
return {
|
|
55
|
+
typesFile: rawConfig.typesFile ?? "",
|
|
56
|
+
skipTypename: rawConfig.skipTypename ?? false,
|
|
57
|
+
typesPrefix: rawConfig.typesPrefix ?? "",
|
|
58
|
+
typesSuffix: rawConfig.typesSuffix ?? "",
|
|
59
|
+
namingConvention: rawConfig.namingConvention ?? "",
|
|
60
|
+
maxFieldRecursionDepth: rawConfig.maxFieldRecursionDepth ?? 3,
|
|
61
|
+
defaultValues: {
|
|
62
|
+
String: rawConfig.defaultValues?.String ?? DefaultValues.String,
|
|
63
|
+
Int: rawConfig.defaultValues?.Int ?? DefaultValues.Int,
|
|
64
|
+
Float: rawConfig.defaultValues?.Float ?? DefaultValues.Float,
|
|
65
|
+
Boolean: rawConfig.defaultValues?.Boolean ?? DefaultValues.Boolean,
|
|
66
|
+
ID: rawConfig.defaultValues?.ID ?? DefaultValues.ID,
|
|
67
|
+
listLength: rawConfig.defaultValues?.listLength ?? DefaultValues.listLength,
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/config.ts"],"names":[],"mappings":"AAwBA,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,EAAE;IACP,KAAK,EAAE,IAAI;IACX,OAAO,EAAE,IAAI;IACb,EAAE,EAAE,qBAAqB;IACzB,UAAU,EAAE,CAAC;CAChB,CAAC;AAkBF,MAAM,UAAU,cAAc,CAC1B,SAAkB,EAClB,aAA0C,YAAY;IAEtD,iCAAiC;IACjC,IAAI,SAAS,KAAK,IAAI,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;QAChD,MAAM,IAAI,KAAK,CAAC,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,UAAU,IAAI,aAAa,CAAC,UAAU;SAC9E;KACJ,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export declare const EXAMPLE_DIRECTIVE = "\n\"\"\"\n@exampleID directive specifies an example value for a ID field.\nThis example value is used in the fake data.\nID value will be unique between all ID fake data.\n\"\"\"\ndirective @exampleID(\n \"\"\"\n The value of the ID field.\n @exampleID(value: \"id\")\n \"\"\"\n value: ID!\n) on FIELD_DEFINITION\n\"\"\"\n@exampleString directive specifies an example value for a String field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleString(\n \"\"\"\n The value of the String field.\n @exampleString(value: \"example\")\n \"\"\"\n value: String!\n) on FIELD_DEFINITION\n\"\"\"\n@exampleInt directive specifies an example value for a Inf field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleInt(\n \"\"\"\n The value of the Int field.\n @exampleInt(value: 1)\n \"\"\"\n value: Int!\n) on FIELD_DEFINITION\n\"\"\"\n@exampleFloat directive specifies an example value for a Float field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleFloat(\n \"\"\"\n The value of the Float field.\n @exampleFloat(value: 1.0)\n \"\"\"\n value: Float!\n) on FIELD_DEFINITION\n\"\"\"\n@exampleBoolean directive specifies an example value for a Boolean field.\nThis example value is used in the fake data.\n\"\"\"\ndirective @exampleBoolean(\n \"\"\"\n The value of the Boolean field.\n @exampleBoolean(value: true)\n \"\"\"\n value: Boolean!\n) on FIELD_DEFINITION\n";
|
|
2
|
+
export declare const extendSchema: (schema: string) => string;
|
|
3
|
+
//# sourceMappingURL=extend-schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extend-schema.d.ts","sourceRoot":"","sources":["../../src/extend-schema.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,q7CAyD7B,CAAC;AACF,eAAO,MAAM,YAAY,WAAY,MAAM,WAE1C,CAAC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export const EXAMPLE_DIRECTIVE = `
|
|
2
|
+
"""
|
|
3
|
+
@exampleID directive specifies an example value for a ID field.
|
|
4
|
+
This example value is used in the fake data.
|
|
5
|
+
ID value will be unique between all ID fake data.
|
|
6
|
+
"""
|
|
7
|
+
directive @exampleID(
|
|
8
|
+
"""
|
|
9
|
+
The value of the ID field.
|
|
10
|
+
@exampleID(value: "id")
|
|
11
|
+
"""
|
|
12
|
+
value: ID!
|
|
13
|
+
) on FIELD_DEFINITION
|
|
14
|
+
"""
|
|
15
|
+
@exampleString directive specifies an example value for a String field.
|
|
16
|
+
This example value is used in the fake data.
|
|
17
|
+
"""
|
|
18
|
+
directive @exampleString(
|
|
19
|
+
"""
|
|
20
|
+
The value of the String field.
|
|
21
|
+
@exampleString(value: "example")
|
|
22
|
+
"""
|
|
23
|
+
value: String!
|
|
24
|
+
) on FIELD_DEFINITION
|
|
25
|
+
"""
|
|
26
|
+
@exampleInt directive specifies an example value for a Inf field.
|
|
27
|
+
This example value is used in the fake data.
|
|
28
|
+
"""
|
|
29
|
+
directive @exampleInt(
|
|
30
|
+
"""
|
|
31
|
+
The value of the Int field.
|
|
32
|
+
@exampleInt(value: 1)
|
|
33
|
+
"""
|
|
34
|
+
value: Int!
|
|
35
|
+
) on FIELD_DEFINITION
|
|
36
|
+
"""
|
|
37
|
+
@exampleFloat directive specifies an example value for a Float field.
|
|
38
|
+
This example value is used in the fake data.
|
|
39
|
+
"""
|
|
40
|
+
directive @exampleFloat(
|
|
41
|
+
"""
|
|
42
|
+
The value of the Float field.
|
|
43
|
+
@exampleFloat(value: 1.0)
|
|
44
|
+
"""
|
|
45
|
+
value: Float!
|
|
46
|
+
) on FIELD_DEFINITION
|
|
47
|
+
"""
|
|
48
|
+
@exampleBoolean directive specifies an example value for a Boolean field.
|
|
49
|
+
This example value is used in the fake data.
|
|
50
|
+
"""
|
|
51
|
+
directive @exampleBoolean(
|
|
52
|
+
"""
|
|
53
|
+
The value of the Boolean field.
|
|
54
|
+
@exampleBoolean(value: true)
|
|
55
|
+
"""
|
|
56
|
+
value: Boolean!
|
|
57
|
+
) on FIELD_DEFINITION
|
|
58
|
+
`;
|
|
59
|
+
export const extendSchema = (schema) => {
|
|
60
|
+
return EXAMPLE_DIRECTIVE + schema;
|
|
61
|
+
};
|
|
62
|
+
//# sourceMappingURL=extend-schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extend-schema.js","sourceRoot":"","sources":["../../src/extend-schema.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,iBAAiB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyDhC,CAAC;AACF,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,MAAc,EAAE,EAAE;IAC3C,OAAO,iBAAiB,GAAG,MAAM,CAAC;AACtC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { generateCode } from "./code-generator.js";
|
|
2
|
+
export type { ConfigWithOutput } from "./code-generator.js";
|
|
3
|
+
export { normalizeConfig, validateConfig } from "./config.js";
|
|
4
|
+
export type { Config, RawConfig } from "./config.js";
|
|
5
|
+
export { extendSchema, EXAMPLE_DIRECTIVE } from "./extend-schema.js";
|
|
6
|
+
export { getTypeInfos } from "./schema-scanner.js";
|
|
7
|
+
export type { TypeInfo, AbstractTypeInfo, ObjectTypeInfo, ExampleDirective, ExampleDirectiveValue, ExampleDirectionExpression, } from "./schema-scanner.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC9D,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,YAAY,EACR,QAAQ,EACR,gBAAgB,EAChB,cAAc,EACd,gBAAgB,EAChB,qBAAqB,EACrB,0BAA0B,GAC7B,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { generateCode } from "./code-generator.js";
|
|
2
|
+
export { normalizeConfig, validateConfig } from "./config.js";
|
|
3
|
+
export { extendSchema, EXAMPLE_DIRECTIVE } from "./extend-schema.js";
|
|
4
|
+
export { getTypeInfos } from "./schema-scanner.js";
|
|
5
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAE9D,OAAO,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { type GraphQLSchema } from "graphql";
|
|
2
|
+
import type { Config } from "./config.js";
|
|
3
|
+
type ValuePrimitive = string | number | boolean | null;
|
|
4
|
+
type ValueArray = ValuePrimitive[];
|
|
5
|
+
type ValueObject = Record<string, ValuePrimitive | ValueArray>;
|
|
6
|
+
export type ExampleDirectiveValue = {
|
|
7
|
+
value: ValuePrimitive | ValueArray | ValueObject;
|
|
8
|
+
};
|
|
9
|
+
export type ExampleDirectionExpression = {
|
|
10
|
+
expression: string;
|
|
11
|
+
};
|
|
12
|
+
export type ExampleDirective = ExampleDirectiveValue | ExampleDirectionExpression;
|
|
13
|
+
type FieldInfo = {
|
|
14
|
+
name: string;
|
|
15
|
+
example?: ExampleDirective | undefined;
|
|
16
|
+
};
|
|
17
|
+
export type ObjectTypeInfo = {
|
|
18
|
+
type: "object";
|
|
19
|
+
name: string;
|
|
20
|
+
fields: FieldInfo[];
|
|
21
|
+
};
|
|
22
|
+
export type AbstractTypeInfo = {
|
|
23
|
+
type: "abstract";
|
|
24
|
+
name: string;
|
|
25
|
+
possibleTypes: string[];
|
|
26
|
+
comment?: string | undefined;
|
|
27
|
+
example?: ExampleDirective | undefined;
|
|
28
|
+
};
|
|
29
|
+
export type TypeInfo = ObjectTypeInfo | AbstractTypeInfo;
|
|
30
|
+
export declare function getTypeInfos(config: Config, schema: GraphQLSchema): TypeInfo[];
|
|
31
|
+
export {};
|
|
32
|
+
//# sourceMappingURL=schema-scanner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-scanner.d.ts","sourceRoot":"","sources":["../../src/schema-scanner.ts"],"names":[],"mappings":"AACA,OAAO,EAIH,KAAK,aAAa,EAWrB,MAAM,SAAS,CAAC;AAEjB,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AA4C1C,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,CAAC;AACvD,KAAK,UAAU,GAAG,cAAc,EAAE,CAAC;AACnC,KAAK,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU,CAAC,CAAC;AAC/D,MAAM,MAAM,qBAAqB,GAAG;IAEhC,KAAK,EAAE,cAAc,GAAG,UAAU,GAAG,WAAW,CAAC;CACpD,CAAC;AACF,MAAM,MAAM,0BAA0B,GAAG;IACrC,UAAU,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG,qBAAqB,GAAG,0BAA0B,CAAC;AA0R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