@graphql-codegen/typescript 3.0.3 → 3.0.4-alpha-20230404095953-c13d5890d
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/cjs/visitor.js +11 -1
- package/esm/visitor.js +10 -0
- package/package.json +2 -2
- package/typings/visitor.d.cts +4 -0
- package/typings/visitor.d.ts +4 -0
package/cjs/visitor.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TsVisitor = exports.MAKE_MAYBE_SIGNATURE = exports.MAKE_OPTIONAL_SIGNATURE = exports.EXACT_SIGNATURE = void 0;
|
|
3
|
+
exports.TsVisitor = exports.MAKE_INCREMENTAL_SIGNATURE = exports.MAKE_EMPTY_SIGNATURE = exports.MAKE_MAYBE_SIGNATURE = exports.MAKE_OPTIONAL_SIGNATURE = exports.EXACT_SIGNATURE = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const visitor_plugin_common_1 = require("@graphql-codegen/visitor-plugin-common");
|
|
6
6
|
const auto_bind_1 = tslib_1.__importDefault(require("auto-bind"));
|
|
@@ -9,6 +9,8 @@ const typescript_variables_to_object_js_1 = require("./typescript-variables-to-o
|
|
|
9
9
|
exports.EXACT_SIGNATURE = `type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };`;
|
|
10
10
|
exports.MAKE_OPTIONAL_SIGNATURE = `type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };`;
|
|
11
11
|
exports.MAKE_MAYBE_SIGNATURE = `type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };`;
|
|
12
|
+
exports.MAKE_EMPTY_SIGNATURE = `type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };`;
|
|
13
|
+
exports.MAKE_INCREMENTAL_SIGNATURE = `type Incremental<T> = T | { [P in keyof T]?: never };`;
|
|
12
14
|
class TsVisitor extends visitor_plugin_common_1.BaseTypesVisitor {
|
|
13
15
|
constructor(schema, pluginConfig, additionalConfig = {}) {
|
|
14
16
|
super(schema, pluginConfig, {
|
|
@@ -85,6 +87,8 @@ class TsVisitor extends visitor_plugin_common_1.BaseTypesVisitor {
|
|
|
85
87
|
this.getExactDefinition(),
|
|
86
88
|
this.getMakeOptionalDefinition(),
|
|
87
89
|
this.getMakeMaybeDefinition(),
|
|
90
|
+
this.getMakeEmptyDefinition(),
|
|
91
|
+
this.getIncrementalDefinition(),
|
|
88
92
|
];
|
|
89
93
|
if (this.config.wrapFieldDefinitions) {
|
|
90
94
|
definitions.push(this.getFieldWrapperValue());
|
|
@@ -107,6 +111,12 @@ class TsVisitor extends visitor_plugin_common_1.BaseTypesVisitor {
|
|
|
107
111
|
return '';
|
|
108
112
|
return `${this.getExportPrefix()}${exports.MAKE_MAYBE_SIGNATURE}`;
|
|
109
113
|
}
|
|
114
|
+
getMakeEmptyDefinition() {
|
|
115
|
+
return `${this.getExportPrefix()}${exports.MAKE_EMPTY_SIGNATURE}`;
|
|
116
|
+
}
|
|
117
|
+
getIncrementalDefinition() {
|
|
118
|
+
return `${this.getExportPrefix()}${exports.MAKE_INCREMENTAL_SIGNATURE}`;
|
|
119
|
+
}
|
|
110
120
|
getMaybeValue() {
|
|
111
121
|
return `${this.getExportPrefix()}type Maybe<T> = ${this.config.maybeValue};`;
|
|
112
122
|
}
|
package/esm/visitor.js
CHANGED
|
@@ -5,6 +5,8 @@ import { TypeScriptOperationVariablesToObject } from './typescript-variables-to-
|
|
|
5
5
|
export const EXACT_SIGNATURE = `type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };`;
|
|
6
6
|
export const MAKE_OPTIONAL_SIGNATURE = `type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };`;
|
|
7
7
|
export const MAKE_MAYBE_SIGNATURE = `type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };`;
|
|
8
|
+
export const MAKE_EMPTY_SIGNATURE = `type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };`;
|
|
9
|
+
export const MAKE_INCREMENTAL_SIGNATURE = `type Incremental<T> = T | { [P in keyof T]?: never };`;
|
|
8
10
|
export class TsVisitor extends BaseTypesVisitor {
|
|
9
11
|
constructor(schema, pluginConfig, additionalConfig = {}) {
|
|
10
12
|
super(schema, pluginConfig, {
|
|
@@ -81,6 +83,8 @@ export class TsVisitor extends BaseTypesVisitor {
|
|
|
81
83
|
this.getExactDefinition(),
|
|
82
84
|
this.getMakeOptionalDefinition(),
|
|
83
85
|
this.getMakeMaybeDefinition(),
|
|
86
|
+
this.getMakeEmptyDefinition(),
|
|
87
|
+
this.getIncrementalDefinition(),
|
|
84
88
|
];
|
|
85
89
|
if (this.config.wrapFieldDefinitions) {
|
|
86
90
|
definitions.push(this.getFieldWrapperValue());
|
|
@@ -103,6 +107,12 @@ export class TsVisitor extends BaseTypesVisitor {
|
|
|
103
107
|
return '';
|
|
104
108
|
return `${this.getExportPrefix()}${MAKE_MAYBE_SIGNATURE}`;
|
|
105
109
|
}
|
|
110
|
+
getMakeEmptyDefinition() {
|
|
111
|
+
return `${this.getExportPrefix()}${MAKE_EMPTY_SIGNATURE}`;
|
|
112
|
+
}
|
|
113
|
+
getIncrementalDefinition() {
|
|
114
|
+
return `${this.getExportPrefix()}${MAKE_INCREMENTAL_SIGNATURE}`;
|
|
115
|
+
}
|
|
106
116
|
getMaybeValue() {
|
|
107
117
|
return `${this.getExportPrefix()}type Maybe<T> = ${this.config.maybeValue};`;
|
|
108
118
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@graphql-codegen/typescript",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.4-alpha-20230404095953-c13d5890d",
|
|
4
4
|
"description": "GraphQL Code Generator plugin for generating TypeScript types",
|
|
5
5
|
"peerDependencies": {
|
|
6
6
|
"graphql": "^0.12.0 || ^0.13.0 || ^14.0.0 || ^15.0.0 || ^16.0.0"
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dependencies": {
|
|
9
9
|
"@graphql-codegen/plugin-helpers": "^4.2.0",
|
|
10
10
|
"@graphql-codegen/schema-ast": "^3.0.1",
|
|
11
|
-
"@graphql-codegen/visitor-plugin-common": "3.
|
|
11
|
+
"@graphql-codegen/visitor-plugin-common": "3.2.0-alpha-20230404095953-c13d5890d",
|
|
12
12
|
"auto-bind": "~4.0.0",
|
|
13
13
|
"tslib": "~2.5.0"
|
|
14
14
|
},
|
package/typings/visitor.d.cts
CHANGED
|
@@ -20,6 +20,8 @@ export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
|
|
|
20
20
|
export declare const EXACT_SIGNATURE = "type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };";
|
|
21
21
|
export declare const MAKE_OPTIONAL_SIGNATURE = "type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };";
|
|
22
22
|
export declare const MAKE_MAYBE_SIGNATURE = "type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };";
|
|
23
|
+
export declare const MAKE_EMPTY_SIGNATURE = "type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };";
|
|
24
|
+
export declare const MAKE_INCREMENTAL_SIGNATURE = "type Incremental<T> = T | { [P in keyof T]?: never };";
|
|
23
25
|
export declare class TsVisitor<TRawConfig extends TypeScriptPluginConfig = TypeScriptPluginConfig, TParsedConfig extends TypeScriptPluginParsedConfig = TypeScriptPluginParsedConfig> extends BaseTypesVisitor<TRawConfig, TParsedConfig> {
|
|
24
26
|
constructor(schema: GraphQLSchema, pluginConfig: TRawConfig, additionalConfig?: Partial<TParsedConfig>);
|
|
25
27
|
protected _getTypeForNode(node: NamedTypeNode): string;
|
|
@@ -27,6 +29,8 @@ export declare class TsVisitor<TRawConfig extends TypeScriptPluginConfig = TypeS
|
|
|
27
29
|
getExactDefinition(): string;
|
|
28
30
|
getMakeOptionalDefinition(): string;
|
|
29
31
|
getMakeMaybeDefinition(): string;
|
|
32
|
+
getMakeEmptyDefinition(): string;
|
|
33
|
+
getIncrementalDefinition(): string;
|
|
30
34
|
getMaybeValue(): string;
|
|
31
35
|
getInputMaybeValue(): string;
|
|
32
36
|
protected clearOptional(str: string): string;
|
package/typings/visitor.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export interface TypeScriptPluginParsedConfig extends ParsedTypesConfig {
|
|
|
20
20
|
export declare const EXACT_SIGNATURE = "type Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };";
|
|
21
21
|
export declare const MAKE_OPTIONAL_SIGNATURE = "type MakeOptional<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]?: Maybe<T[SubKey]> };";
|
|
22
22
|
export declare const MAKE_MAYBE_SIGNATURE = "type MakeMaybe<T, K extends keyof T> = Omit<T, K> & { [SubKey in K]: Maybe<T[SubKey]> };";
|
|
23
|
+
export declare const MAKE_EMPTY_SIGNATURE = "type MakeEmpty<T extends { [key: string]: unknown }, K extends keyof T> = { [_ in K]?: never };";
|
|
24
|
+
export declare const MAKE_INCREMENTAL_SIGNATURE = "type Incremental<T> = T | { [P in keyof T]?: never };";
|
|
23
25
|
export declare class TsVisitor<TRawConfig extends TypeScriptPluginConfig = TypeScriptPluginConfig, TParsedConfig extends TypeScriptPluginParsedConfig = TypeScriptPluginParsedConfig> extends BaseTypesVisitor<TRawConfig, TParsedConfig> {
|
|
24
26
|
constructor(schema: GraphQLSchema, pluginConfig: TRawConfig, additionalConfig?: Partial<TParsedConfig>);
|
|
25
27
|
protected _getTypeForNode(node: NamedTypeNode): string;
|
|
@@ -27,6 +29,8 @@ export declare class TsVisitor<TRawConfig extends TypeScriptPluginConfig = TypeS
|
|
|
27
29
|
getExactDefinition(): string;
|
|
28
30
|
getMakeOptionalDefinition(): string;
|
|
29
31
|
getMakeMaybeDefinition(): string;
|
|
32
|
+
getMakeEmptyDefinition(): string;
|
|
33
|
+
getIncrementalDefinition(): string;
|
|
30
34
|
getMaybeValue(): string;
|
|
31
35
|
getInputMaybeValue(): string;
|
|
32
36
|
protected clearOptional(str: string): string;
|