@vladimirdev635/gql-codegen 0.0.113 → 0.0.116

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.
@@ -11,7 +11,24 @@ export declare const inputTypeSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
11
11
  name: z.ZodString;
12
12
  $ref: z.ZodString;
13
13
  }, z.core.$strip>], "_type">;
14
- export declare const literalSchema: z.ZodUnion<readonly [z.ZodString, z.ZodInt, z.ZodFloat32, z.ZodBoolean]>;
14
+ export declare const literalSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
15
+ _type: z.ZodLiteral<"string">;
16
+ value: z.ZodString;
17
+ }, z.core.$strip>, z.ZodObject<{
18
+ _type: z.ZodLiteral<"enum-value">;
19
+ value: z.ZodString;
20
+ }, z.core.$strip>, z.ZodObject<{
21
+ _type: z.ZodLiteral<"null">;
22
+ }, z.core.$strip>, z.ZodObject<{
23
+ _type: z.ZodLiteral<"int">;
24
+ value: z.ZodNumber;
25
+ }, z.core.$strip>, z.ZodObject<{
26
+ _type: z.ZodLiteral<"float">;
27
+ value: z.ZodNumber;
28
+ }, z.core.$strip>, z.ZodObject<{
29
+ _type: z.ZodLiteral<"boolean">;
30
+ value: z.ZodBoolean;
31
+ }, z.core.$strip>], "_type">;
15
32
  export declare const arrayLiteralSchema: z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodArray<z.ZodInt>, z.ZodArray<z.ZodFloat32>, z.ZodArray<z.ZodBoolean>]>;
16
33
  export declare const inputLiteralSpecSchema: z.ZodObject<{
17
34
  _type: z.ZodLiteral<"literal">;
@@ -27,12 +44,29 @@ export declare const inputLiteralSpecSchema: z.ZodObject<{
27
44
  name: z.ZodString;
28
45
  $ref: z.ZodString;
29
46
  }, z.core.$strip>], "_type">;
30
- defaultValue: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt, z.ZodFloat32, z.ZodBoolean]>>>;
47
+ defaultValue: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
48
+ _type: z.ZodLiteral<"string">;
49
+ value: z.ZodString;
50
+ }, z.core.$strip>, z.ZodObject<{
51
+ _type: z.ZodLiteral<"enum-value">;
52
+ value: z.ZodString;
53
+ }, z.core.$strip>, z.ZodObject<{
54
+ _type: z.ZodLiteral<"null">;
55
+ }, z.core.$strip>, z.ZodObject<{
56
+ _type: z.ZodLiteral<"int">;
57
+ value: z.ZodNumber;
58
+ }, z.core.$strip>, z.ZodObject<{
59
+ _type: z.ZodLiteral<"float">;
60
+ value: z.ZodNumber;
61
+ }, z.core.$strip>, z.ZodObject<{
62
+ _type: z.ZodLiteral<"boolean">;
63
+ value: z.ZodBoolean;
64
+ }, z.core.$strip>], "_type">>;
31
65
  }, z.core.$strip>;
32
66
  export declare const inputArraySpecSchema: z.ZodObject<{
33
67
  _type: z.ZodLiteral<"array">;
34
68
  nullable: z.ZodBoolean;
35
- defaultValue: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodArray<z.ZodInt>, z.ZodArray<z.ZodFloat32>, z.ZodArray<z.ZodBoolean>]>>>;
69
+ defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodArray<z.ZodInt>, z.ZodArray<z.ZodFloat32>, z.ZodArray<z.ZodBoolean>]>>;
36
70
  type: z.ZodDiscriminatedUnion<[typeof inputLiteralSpecSchema, typeof inputArraySpecSchema]>;
37
71
  }, z.core.$strip>;
38
72
  export declare const inputFieldSpecSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
@@ -49,11 +83,28 @@ export declare const inputFieldSpecSchema: z.ZodDiscriminatedUnion<[z.ZodObject<
49
83
  name: z.ZodString;
50
84
  $ref: z.ZodString;
51
85
  }, z.core.$strip>], "_type">;
52
- defaultValue: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt, z.ZodFloat32, z.ZodBoolean]>>>;
86
+ defaultValue: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
87
+ _type: z.ZodLiteral<"string">;
88
+ value: z.ZodString;
89
+ }, z.core.$strip>, z.ZodObject<{
90
+ _type: z.ZodLiteral<"enum-value">;
91
+ value: z.ZodString;
92
+ }, z.core.$strip>, z.ZodObject<{
93
+ _type: z.ZodLiteral<"null">;
94
+ }, z.core.$strip>, z.ZodObject<{
95
+ _type: z.ZodLiteral<"int">;
96
+ value: z.ZodNumber;
97
+ }, z.core.$strip>, z.ZodObject<{
98
+ _type: z.ZodLiteral<"float">;
99
+ value: z.ZodNumber;
100
+ }, z.core.$strip>, z.ZodObject<{
101
+ _type: z.ZodLiteral<"boolean">;
102
+ value: z.ZodBoolean;
103
+ }, z.core.$strip>], "_type">>;
53
104
  }, z.core.$strip>, z.ZodObject<{
54
105
  _type: z.ZodLiteral<"array">;
55
106
  nullable: z.ZodBoolean;
56
- defaultValue: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodArray<z.ZodInt>, z.ZodArray<z.ZodFloat32>, z.ZodArray<z.ZodBoolean>]>>>;
107
+ defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodArray<z.ZodInt>, z.ZodArray<z.ZodFloat32>, z.ZodArray<z.ZodBoolean>]>>;
57
108
  type: z.ZodDiscriminatedUnion<[typeof inputLiteralSpecSchema, typeof inputArraySpecSchema]>;
58
109
  }, z.core.$strip>], "_type">;
59
110
  export declare const inputFieldSchema: z.ZodObject<{
@@ -72,11 +123,28 @@ export declare const inputFieldSchema: z.ZodObject<{
72
123
  name: z.ZodString;
73
124
  $ref: z.ZodString;
74
125
  }, z.core.$strip>], "_type">;
75
- defaultValue: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodString, z.ZodInt, z.ZodFloat32, z.ZodBoolean]>>>;
126
+ defaultValue: z.ZodOptional<z.ZodDiscriminatedUnion<[z.ZodObject<{
127
+ _type: z.ZodLiteral<"string">;
128
+ value: z.ZodString;
129
+ }, z.core.$strip>, z.ZodObject<{
130
+ _type: z.ZodLiteral<"enum-value">;
131
+ value: z.ZodString;
132
+ }, z.core.$strip>, z.ZodObject<{
133
+ _type: z.ZodLiteral<"null">;
134
+ }, z.core.$strip>, z.ZodObject<{
135
+ _type: z.ZodLiteral<"int">;
136
+ value: z.ZodNumber;
137
+ }, z.core.$strip>, z.ZodObject<{
138
+ _type: z.ZodLiteral<"float">;
139
+ value: z.ZodNumber;
140
+ }, z.core.$strip>, z.ZodObject<{
141
+ _type: z.ZodLiteral<"boolean">;
142
+ value: z.ZodBoolean;
143
+ }, z.core.$strip>], "_type">>;
76
144
  }, z.core.$strip>, z.ZodObject<{
77
145
  _type: z.ZodLiteral<"array">;
78
146
  nullable: z.ZodBoolean;
79
- defaultValue: z.ZodNullable<z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodArray<z.ZodInt>, z.ZodArray<z.ZodFloat32>, z.ZodArray<z.ZodBoolean>]>>>;
147
+ defaultValue: z.ZodOptional<z.ZodUnion<readonly [z.ZodArray<z.ZodString>, z.ZodArray<z.ZodInt>, z.ZodArray<z.ZodFloat32>, z.ZodArray<z.ZodBoolean>]>>;
80
148
  type: z.ZodDiscriminatedUnion<[typeof inputLiteralSpecSchema, typeof inputArraySpecSchema]>;
81
149
  }, z.core.$strip>], "_type">;
82
150
  }, z.core.$strip>;
package/schema/shared.js CHANGED
@@ -15,11 +15,30 @@ export const inputTypeSchema = z.discriminatedUnion('_type', [
15
15
  $ref: z.string(),
16
16
  }),
17
17
  ]);
18
- export const literalSchema = z.union([
19
- z.string(),
20
- z.int(),
21
- z.float32(),
22
- z.boolean(),
18
+ export const literalSchema = z.discriminatedUnion('_type', [
19
+ z.object({
20
+ _type: z.literal('string'),
21
+ value: z.string(),
22
+ }),
23
+ z.object({
24
+ _type: z.literal('enum-value'),
25
+ value: z.string(),
26
+ }),
27
+ z.object({
28
+ _type: z.literal('null'),
29
+ }),
30
+ z.object({
31
+ _type: z.literal('int'),
32
+ value: z.number(),
33
+ }),
34
+ z.object({
35
+ _type: z.literal('float'),
36
+ value: z.number(),
37
+ }),
38
+ z.object({
39
+ _type: z.literal('boolean'),
40
+ value: z.boolean(),
41
+ }),
23
42
  ]);
24
43
  export const arrayLiteralSchema = z.union([
25
44
  z.array(z.string()),
@@ -30,12 +49,12 @@ export const arrayLiteralSchema = z.union([
30
49
  export const inputLiteralSpecSchema = z.object({
31
50
  _type: z.literal('literal'),
32
51
  type: inputTypeSchema,
33
- defaultValue: literalSchema.optional().nullable(),
52
+ defaultValue: literalSchema.optional(),
34
53
  });
35
54
  export const inputArraySpecSchema = z.object({
36
55
  _type: z.literal('array'),
37
56
  nullable: z.boolean(),
38
- defaultValue: arrayLiteralSchema.optional().nullable(),
57
+ defaultValue: arrayLiteralSchema.optional(),
39
58
  get type() {
40
59
  // eslint-disable-next-line no-use-before-define
41
60
  return inputFieldSpecSchema;
@@ -1 +0,0 @@
1
- export {};
@@ -1,17 +0,0 @@
1
- import { describe, it, expect } from 'vitest';
2
- import testServerJSON from './test-server.json' with { type: 'json' };
3
- import testClientJSON from './test-client.json' with { type: 'json' };
4
- import { serverSchema } from './server.js';
5
- import { clientSchema } from './client/root.js';
6
- describe('Server schema', () => {
7
- it('Should parse ok', () => {
8
- const result = serverSchema.safeParse(testServerJSON);
9
- expect(result.success, result.error?.message || '').toBe(true);
10
- });
11
- });
12
- describe('Client schema', () => {
13
- it('Should parse ok', () => {
14
- const result = clientSchema.safeParse(testClientJSON);
15
- expect(result.success, result.error?.message || '').toBe(true);
16
- });
17
- });