@schema-hub/zod-graphql-client 0.0.14 → 0.0.16

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.
Files changed (51) hide show
  1. package/package.json +26 -8
  2. package/readme.md +127 -45
  3. package/sbom.cdx.json +101 -0
  4. package/zod-graphql-client/client.d.ts +13 -26
  5. package/zod-graphql-client/client.d.ts.map +1 -1
  6. package/zod-graphql-client/client.js +130 -106
  7. package/zod-graphql-client/client.js.map +1 -1
  8. package/zod-graphql-client/define-variables.d.ts +29 -0
  9. package/zod-graphql-client/define-variables.d.ts.map +1 -0
  10. package/zod-graphql-client/define-variables.js +39 -0
  11. package/zod-graphql-client/define-variables.js.map +1 -0
  12. package/zod-graphql-client/entry-point.d.ts +16 -7
  13. package/zod-graphql-client/entry-point.d.ts.map +1 -1
  14. package/zod-graphql-client/entry-point.js +6 -3
  15. package/zod-graphql-client/entry-point.js.map +1 -1
  16. package/zod-graphql-client/graphql-error.d.ts +12 -0
  17. package/zod-graphql-client/graphql-error.d.ts.map +1 -0
  18. package/zod-graphql-client/graphql-error.js +2 -36
  19. package/zod-graphql-client/graphql-error.js.map +1 -1
  20. package/zod-graphql-client/graphql-response.js +5 -5
  21. package/zod-graphql-client/graphql-response.js.map +1 -1
  22. package/zod-graphql-client/infer-graphql-type.d.ts +5 -0
  23. package/zod-graphql-client/infer-graphql-type.d.ts.map +1 -0
  24. package/zod-graphql-client/infer-graphql-type.js +68 -0
  25. package/zod-graphql-client/infer-graphql-type.js.map +1 -0
  26. package/zod-graphql-client/operation-error.d.ts +14 -10
  27. package/zod-graphql-client/operation-error.d.ts.map +1 -1
  28. package/zod-graphql-client/operation-error.js +12 -3
  29. package/zod-graphql-client/operation-error.js.map +1 -1
  30. package/zod-graphql-client/operation-handle.d.ts +22 -0
  31. package/zod-graphql-client/operation-handle.d.ts.map +1 -0
  32. package/zod-graphql-client/operation-handle.js +20 -0
  33. package/zod-graphql-client/operation-handle.js.map +1 -0
  34. package/zod-graphql-client/operation-payload.d.ts +24 -0
  35. package/zod-graphql-client/operation-payload.d.ts.map +1 -0
  36. package/zod-graphql-client/operation-payload.js +70 -0
  37. package/zod-graphql-client/operation-payload.js.map +1 -0
  38. package/zod-graphql-client/operation-result.d.ts +8 -8
  39. package/zod-graphql-client/operation-result.d.ts.map +1 -1
  40. package/zod-graphql-client/persisted-query.d.ts +9 -0
  41. package/zod-graphql-client/persisted-query.d.ts.map +1 -0
  42. package/zod-graphql-client/persisted-query.js +50 -0
  43. package/zod-graphql-client/persisted-query.js.map +1 -0
  44. package/zod-graphql-client/variable-entry.d.ts +12 -0
  45. package/zod-graphql-client/variable-entry.d.ts.map +1 -0
  46. package/zod-graphql-client/variable-entry.js +11 -0
  47. package/zod-graphql-client/variable-entry.js.map +1 -0
  48. package/zod-graphql-client/variables.d.ts +0 -9
  49. package/zod-graphql-client/variables.d.ts.map +0 -1
  50. package/zod-graphql-client/variables.js +0 -15
  51. package/zod-graphql-client/variables.js.map +0 -1
@@ -0,0 +1,68 @@
1
+ /* eslint-disable no-underscore-dangle -- we need to access _zod */
2
+ /* eslint-disable functional/prefer-immutable-types -- parameters are third-party zod schema types that are only read */
3
+ import { $ZodArray, $ZodBoolean, $ZodNullable, $ZodNumber, $ZodOptional, $ZodString } from 'zod/v4/core';
4
+ export class GraphqlTypeInferenceError extends Error {
5
+ constructor(message, options) {
6
+ super(message, options);
7
+ this.name = 'GraphqlTypeInferenceError';
8
+ }
9
+ }
10
+ const integerNumberFormats = new Set(['safeint', 'int32', 'int64', 'uint32', 'uint64']);
11
+ function hasIntegerFormat(schema) {
12
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- reads the number schema's internal def shape, which zod doesn't expose with precise types
13
+ const def = schema._zod.def;
14
+ if (def.format !== undefined && integerNumberFormats.has(def.format)) {
15
+ return true;
16
+ }
17
+ const { checks = [] } = def;
18
+ return checks.some(function (check) {
19
+ const checkFormat = check._zod.def.format;
20
+ return checkFormat !== undefined && integerNumberFormats.has(checkFormat);
21
+ });
22
+ }
23
+ function unwrapNullable(schema) {
24
+ let current = schema;
25
+ let isNullable = false;
26
+ while (current instanceof $ZodNullable || current instanceof $ZodOptional) {
27
+ current = current._zod.def.innerType;
28
+ isNullable = true;
29
+ }
30
+ return { innerSchema: current, isNullable };
31
+ }
32
+ export function inferGraphqlType(schema) {
33
+ const { innerSchema, isNullable } = unwrapNullable(schema);
34
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define -- mutual recursion via arrays
35
+ const nonNullType = inferNonNullType(innerSchema);
36
+ return isNullable ? nonNullType : `${nonNullType}!`;
37
+ }
38
+ function inferPrimitiveType(schema) {
39
+ if (schema instanceof $ZodString) {
40
+ return 'String';
41
+ }
42
+ if (schema instanceof $ZodBoolean) {
43
+ return 'Boolean';
44
+ }
45
+ if (schema instanceof $ZodNumber) {
46
+ return hasIntegerFormat(schema) ? 'Int' : 'Float';
47
+ }
48
+ return null;
49
+ }
50
+ function inferNonNullType(schema) {
51
+ if (schema instanceof $ZodArray) {
52
+ return `[${inferGraphqlType(schema._zod.def.element)}]`;
53
+ }
54
+ const primitiveType = inferPrimitiveType(schema);
55
+ if (primitiveType !== null) {
56
+ return primitiveType;
57
+ }
58
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define -- thrown only after the early-return paths are exhausted
59
+ throw new GraphqlTypeInferenceError(buildInferenceErrorMessage(schema._zod.def.type));
60
+ }
61
+ function buildInferenceErrorMessage(kind) {
62
+ return [
63
+ `Cannot infer a GraphQL type for Zod schema of kind "${kind}".`,
64
+ 'Use variable(type, schema) to declare the GraphQL type explicitly.'
65
+ ]
66
+ .join(' ');
67
+ }
68
+ //# sourceMappingURL=infer-graphql-type.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"infer-graphql-type.js","sourceRoot":"","sources":["../../../../source/zod-graphql-client/infer-graphql-type.ts"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,wHAAwH;AACxH,OAAO,EACH,SAAS,EAC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,IAAI;QAC/D,oEAAoE;KACvE;SACI,IAAI,CAAC,GAAG,CAAC,CAAC;AACnB,CAAC"}
@@ -1,24 +1,28 @@
1
- import type { NonEmptyArray } from '@schema-hub/zod-error-formatter/tuple/non-empty-array.js';
1
+ import type { NonEmptyArray } from '@schema-hub/zod-error-formatter/tuple/non-empty-array.d.ts';
2
+ import type { GraphqlError } from './graphql-error.ts';
2
3
  type BaseError = {
3
- message: string;
4
+ readonly message: string;
4
5
  };
5
6
  type GraphqlResponseError = BaseError & {
6
- type: 'graphql';
7
- errors: NonEmptyArray<string>;
7
+ readonly type: 'graphql';
8
+ readonly errors: NonEmptyArray<GraphqlError>;
8
9
  };
9
10
  type ServerError = BaseError & {
10
- type: 'server';
11
- statusCode: number;
11
+ readonly type: 'server';
12
+ readonly statusCode: number;
13
+ readonly cause?: unknown;
12
14
  };
13
15
  type ValidationError = BaseError & {
14
- type: 'validation';
15
- issues: NonEmptyArray<string>;
16
+ readonly type: 'validation';
17
+ readonly issues: NonEmptyArray<string>;
16
18
  };
17
19
  type NetworkError = BaseError & {
18
- type: 'network';
20
+ readonly type: 'network';
21
+ readonly cause?: unknown;
19
22
  };
20
23
  type UnknownError = BaseError & {
21
- type: 'unknown';
24
+ readonly type: 'unknown';
25
+ readonly cause?: unknown;
22
26
  };
23
27
  export type OperationErrorDetails = GraphqlResponseError | NetworkError | ServerError | UnknownError | ValidationError;
24
28
  export declare class GraphqlOperationError extends Error {
@@ -1 +1 @@
1
- {"version":3,"file":"operation-error.d.ts","sourceRoot":"","sources":["../../../../source/zod-graphql-client/operation-error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAEjE,KAAK,SAAS,GAAG;IACb,OAAO,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,KAAK,oBAAoB,GAAG,SAAS,GAAG;IACpC,IAAI,EAAE,SAAS,CAAC;IAChB,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,C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C,KAAK,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,KAAK,eAAe,GAAG,SAAS,GAAG;IAC/B,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;IAC5B,QAAQ,CAAC,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CAC1C,CAAC;AAEF,KAAK,YAAY,GAAG,SAAS,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,KAAK,YAAY,GAAG,SAAS,GAAG;IAC5B,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,qBAAqB,GAAG,oBAAoB,GAAG,YAAY,GAAG,WAAW,GAAG,YAAY,GAAG,eAAe,CAAC;AAUvH,qBAAa,qBAAsB,SAAQ,KAAK;IAE5C,SAAgB,OAAO,EAAE,IAAI,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAC;gBAG7C,OAAO,EAAE,qBAAqB;CAQpD"}
@@ -1,10 +1,19 @@
1
+ function causeOf(details) {
2
+ // eslint-disable-next-line unicorn/prefer-includes-over-repeated-comparisons -- literal comparisons narrow the discriminated union so `cause` is accessible
3
+ if (details.type === 'network' || details.type === 'server' || details.type === 'unknown') {
4
+ return details.cause;
5
+ }
6
+ return undefined;
7
+ }
1
8
  export class GraphqlOperationError extends Error {
2
- // eslint-disable-next-line @typescript-eslint/no-restricted-types -- no type-fest installed
9
+ // eslint-disable-next-line @typescript-eslint/no-restricted-types, restricted-syntax-typescript/no-public-class-property -- no type-fest installed; details is part of the error's public API
3
10
  details;
11
+ // eslint-disable-next-line unicorn/custom-error-definition -- constructor takes a domain details object rather than message + options
4
12
  constructor(details) {
13
+ const cause = causeOf(details);
5
14
  const { message, ...remainingDetails } = details;
6
- super(message);
7
- // eslint-disable-next-line functional/no-this-expressions -- sub-classing errors is ok
15
+ super(message, cause === undefined ? undefined : { cause });
16
+ this.name = 'GraphqlOperationError';
8
17
  this.details = remainingDetails;
9
18
  }
10
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"operation-error.js","sourceRoot":"","sources":["../../../../source/zod-graphql-client/operation-error.ts"],"names":[],"mappings":"AA+BA,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC5C,4FAA4F;IAC5E,OAAO,CAAyC;IAEhE,YAAY,OAA8B;QACtC,MAAM,EAAE,OAAO,EAAE,GAAG,gBAAgB,EAAE,GAAG,OAAO,CAAC;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,uFAAuF;QACvF,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC;IACpC,CAAC;CACJ"}
1
+ {"version":3,"file":"operation-error.js","sourceRoot":"","sources":["../../../../source/zod-graphql-client/operation-error.ts"],"names":[],"mappings":"AAmCA,SAAS,OAAO,CAAC,OAA8B;IAC3C,4JAA4J;IAC5J,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,IAAI,OAAO,CAAC,IAAI,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACxF,OAAO,OAAO,CAAC,KAAK,CAAC;IACzB,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAC5C,8LAA8L;IAC9K,OAAO,CAAyC;IAEhE,sIAAsI;IACtI,YAAmB,OAA8B;QAC7C,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;QAC/B,MAAM,EAAE,OAAO,EAAE,GAAG,gBAAgB,EAAE,GAAG,OAAO,CAAC;QACjD,KAAK,CAAC,OAAO,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;QAE5D,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;QACpC,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC;IACpC,CAAC;CACJ"}
@@ -0,0 +1,22 @@
1
+ import type { QuerySchema } from '@schema-hub/zod-graphql-query-builder';
2
+ import type { AnyVariableMapHandle, ValuesOfVariableMapHandle } from './define-variables.ts';
3
+ export type OperationKind = 'mutation' | 'query';
4
+ declare const operationHandleTag: unique symbol;
5
+ export type OperationHandle<Schema extends QuerySchema, Variables extends AnyVariableMapHandle | undefined> = {
6
+ readonly [operationHandleTag]: true;
7
+ readonly kind: OperationKind;
8
+ readonly schema: Schema;
9
+ readonly variables?: Variables;
10
+ readonly operationName?: string;
11
+ };
12
+ type ResolveOperationHandleValues<Variables> = Variables extends AnyVariableMapHandle ? ValuesOfVariableMapHandle<Variables> : never;
13
+ export type ValuesOfOperationHandle<Handle> = Handle extends OperationHandle<QuerySchema, infer Variables> ? ResolveOperationHandleValues<Variables> : never;
14
+ type OperationHandleConfig<Schema extends QuerySchema, Variables extends AnyVariableMapHandle | undefined> = {
15
+ readonly schema: Schema;
16
+ readonly variables?: Variables;
17
+ readonly operationName?: string;
18
+ };
19
+ export declare function defineQuery<Schema extends QuerySchema, Variables extends AnyVariableMapHandle | undefined = undefined>(config: OperationHandleConfig<Schema, Variables>): OperationHandle<Schema, Variables>;
20
+ export declare function defineMutation<Schema extends QuerySchema, Variables extends AnyVariableMapHandle | undefined = undefined>(config: OperationHandleConfig<Schema, Variables>): OperationHandle<Schema, Variables>;
21
+ export {};
22
+ //# sourceMappingURL=operation-handle.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-handle.d.ts","sourceRoot":"","sources":["../../../../source/zod-graphql-client/operation-handle.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM;AACjC,IAD8E,CAAC,EACxE,KAAK,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,MAAM,uBAAuB;AAE5F,MAAM,MAAM,aAAa,GAAG,UAAU,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,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC"}
@@ -0,0 +1,20 @@
1
+ const operationHandleTag = Symbol('operation-handle');
2
+ function createOperationHandle(kind, config) {
3
+ const base = {
4
+ [operationHandleTag]: true,
5
+ kind,
6
+ schema: config.schema
7
+ };
8
+ const withVariables = config.variables === undefined ? base : { ...base, variables: config.variables };
9
+ return config.operationName === undefined
10
+ ? withVariables
11
+ : { ...withVariables, operationName: config.operationName };
12
+ }
13
+ export function defineQuery(config) {
14
+ return createOperationHandle('query', config);
15
+ }
16
+ export function defineMutation(config) {
17
+ return createOperationHandle('mutation', config);
18
+ }
19
+
20
+ //# sourceMappingURL=operation-handle.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-handle.js","sourceRoot":"","sources":["../../../../source/zod-graphql-client/operation-handle.ts"],"names":[],"mappings":"AAKA,MAAM,kBAAkB,GAAG,MAAM,CAAC,kBAAkB,CAAC;AA2BrD,SAAS,qBAAqB,CAG5B,IAAmB,EAAE,MAAgD;IACnE,MAAM,IAAI,GAAuC;QAC7C,CAAC,kBAAkB,CAAC,EAAE,IAAI;QAC1B,IAAI;QACJ,MAAM,EAAE,MAAM,CAAC,MAAM;KACxB,CAAC;IACF,MAAM,aAAa,GAAG,MAAM,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,SAAS,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC;IACvG,OAAO,MAAM,CAAC,aAAa,KAAK,SAAS;QACrC,CAAC,CAAC,aAAa;QACf,CAAC,CAAC,EAAE,GAAG,aAAa,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,CAAC;AACpE;AAEA,MAAM,UAAU,WAAW,CAGzB,MAAgD;IAC9C,OAAO,qBAAqB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;AAClD;AAEA,MAAM,UAAU,cAAc,CAG5B,MAAgD;IAC9C,OAAO,qBAAqB,CAAC,UAAU,EAAE,MAAM,CAAC,CAAC;AACrD"}
@@ -0,0 +1,24 @@
1
+ import { type QuerySchema } from '@schema-hub/zod-graphql-query-builder';
2
+ import { type AnyVariableMapHandle, type MaybeVariables, type ValuesOfVariableMapHandle } from './define-variables.ts';
3
+ import type { OperationHandle } from './operation-handle.ts';
4
+ import type { OperationFailureResult } from './operation-result.ts';
5
+ import { type PersistedQueryExtensions } from './persisted-query.ts';
6
+ export type OperationType = 'mutation' | 'query';
7
+ export type OperationOptions = {
8
+ readonly timeout?: number;
9
+ readonly headers?: Readonly<Record<string, string | undefined>>;
10
+ };
11
+ export type GraphqlOverHttpOperationRequestPayload = {
12
+ readonly query?: string;
13
+ readonly variables: Readonly<Record<string, unknown>>;
14
+ readonly operationName?: string | undefined;
15
+ readonly extensions?: PersistedQueryExtensions;
16
+ };
17
+ type WithVariables<Variables extends AnyVariableMapHandle> = readonly [
18
+ values: ValuesOfVariableMapHandle<Variables>,
19
+ options?: OperationOptions
20
+ ];
21
+ type WithoutVariables = readonly [options?: OperationOptions];
22
+ export type OperationCallArgs<V extends MaybeVariables> = V extends AnyVariableMapHandle ? WithVariables<V> : WithoutVariables;
23
+ export {};
24
+ //# sourceMappingURL=operation-payload.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-payload.d.ts","sourceRoot":"","sources":["../../../../source/zod-graphql-client/operation-payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,KAAK,WAAW,EAAE,MAAM;AAC1E,IADuH,CAAC,EACjH,EACH,KAAK,oBAAoB,EAEzB,KAAK,cAAc,EACnB,KAAK,yBAAyB,EACjC,MAAM,uBAAuB;AAC9B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB;AAC5D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB;AACnE,OAAO,EAAiC,KAAK,wBAAwB,EAAE,MAAM,sBAAsB;AAEnG,MAAM,MAAM,aAAa,GAAG,UAAU,GAAG,OAAO;AAEhD,MAAM,MAAM,gBAAgB,GAAG;IAC3B,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,OAAO,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;CACnE;AAED,MAAM,MAAM,sCAAsC,GAAG;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IACtD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5C,QAAQ,CAAC,UAAU,CAAC,EAAE,wBAAwB,CAAC;CAClD;AAiCD,KAAK,aAAa,CAAC,SAAS,SAAS,oBAAoB,IAAI,SAAS;IAClE,MAAM,EAAE,yBAAyB,CAAC,SAAS,CAAC;IAC5C,OAAO,CAAC,EAAE,gBAAgB;CAC7B;AACD,KAAK,gBAAgB,GAAG,SAAS,CAAC,OAAO,CAAC,EAAE,gBAAgB,CAAC;AAE7D,MAAM,MAAM,iBAAiB,CAAC,CAAC,SAAS,cAAc,IAAI,CAAC,SAAS,oBAAoB,GAAG,aAAa,CAAC,CAAC,CAAC,GACrG,gBAAgB"}
@@ -0,0 +1,70 @@
1
+ import { buildGraphqlMutation, buildGraphqlQuery } from "@schema-hub/zod-graphql-query-builder";
2
+ import { getVariableMapMetadata } from "./define-variables.js";
3
+ import { buildPersistedQueryExtensions } from "./persisted-query.js";
4
+ export function buildOperationPayload(input) {
5
+ const builderOptions = {
6
+ operationName: input.operationName,
7
+ variableDefinitions: input.variableDefinitions
8
+ };
9
+ const build = input.operationType === 'query' ? buildGraphqlQuery : buildGraphqlMutation;
10
+ const serializedQuery = build(input.schema, builderOptions);
11
+ return {
12
+ query: serializedQuery,
13
+ variables: input.variableValues,
14
+ operationName: input.operationName
15
+ };
16
+ }
17
+ export function resolveOperationInputs(handle, valuesOrOptions, maybeOptions) {
18
+ if (handle.variables === undefined) {
19
+ return {
20
+ success: true,
21
+ data: {
22
+ schema: handle.schema,
23
+ operationName: handle.operationName,
24
+ variableDefinitions: {},
25
+ variableValues: {},
26
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion -- for variable-less operations the first call argument is the options object
27
+ options: valuesOrOptions ?? {}
28
+ }
29
+ };
30
+ }
31
+ const metadata = getVariableMapMetadata(handle.variables);
32
+ const parsed = metadata.parse(valuesOrOptions);
33
+ if (!parsed.success) {
34
+ return {
35
+ success: false,
36
+ errorDetails: {
37
+ type: 'validation',
38
+ message: 'GraphQL variable values don’t match the expected schema',
39
+ issues: parsed.error.issues
40
+ }
41
+ };
42
+ }
43
+ return {
44
+ success: true,
45
+ data: {
46
+ schema: handle.schema,
47
+ operationName: handle.operationName,
48
+ variableDefinitions: { ...metadata.definitions },
49
+ variableValues: parsed.data,
50
+ options: maybeOptions ?? {}
51
+ }
52
+ };
53
+ }
54
+ export function toPersistedQueryPayload(payload, mode) {
55
+ const extensions = buildPersistedQueryExtensions(payload.query);
56
+ if (mode === 'hash-only') {
57
+ return {
58
+ variables: payload.variables,
59
+ operationName: payload.operationName,
60
+ extensions
61
+ };
62
+ }
63
+ return {
64
+ query: payload.query,
65
+ variables: payload.variables,
66
+ operationName: payload.operationName,
67
+ extensions
68
+ };
69
+ }
70
+ //# sourceMappingURL=operation-payload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"operation-payload.js","sourceRoot":"","sources":["../../../../source/zod-graphql-client/operation-payload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAoB,MAAM,6CAA6C,CAAC;AACxH,OAAO,EAEH,sBAAsB,EAGzB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,6BAA6B,EAAiC,MAAM,sBAAsB,CAAC;AA8BpG,MAAM,UAAU,qBAAqB,CAAC,KAAiC;IAC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,EAAE;YACF,MAAM,EAAE,MAAM,CAAC,MAAM;YACrB,aAAa,EAAE,MAAM,CAAC,aAAa;YACnC,mBAAmB,EAAE,EAAE,GAAG,QAAQ,CAAC,WAAW,EAAE;YAChD,cAAc,EAAE,MAAM,CAAC,IAAI;YAC3B,OAAO,EAAE,YAAY,IAAI,EAAE;SAC9B;KACJ,CAAC;AACN,CAAC;AAID,MAAM,UAAU,uBAAuB,CACnC,OAA8B,EAC9B,IAA+B;IAE/B,MAAM,UAAU,GAAG,6BAA6B,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAChE,IAAI,IAAI,KAAK,WAAW,EAAE,CAAC;QACvB,OAAO;YACH,SAAS,EAAE,OAAO,CAAC,SAAS;YAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,UAAU;SACb,CAAC;IACN,CAAC;IACD,OAAO;QACH,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,UAAU;KACb,CAAC;AACN,CAAC"}
@@ -1,15 +1,15 @@
1
1
  import type { output as TypeOf } from 'zod/v4/core';
2
- import type { QuerySchema } from '@schema-hub/zod-graphql-query-builder/zod-graphql-query-builder/entry-point.js';
3
- import type { OperationErrorDetails } from './operation-error.js';
2
+ import type { QuerySchema } from '@schema-hub/zod-graphql-query-builder';
3
+ import type { OperationErrorDetails } from './operation-error.ts';
4
4
  export type OperationFailureResult = {
5
- data?: undefined;
6
- success: false;
7
- errorDetails: OperationErrorDetails;
5
+ readonly data?: undefined;
6
+ readonly success: false;
7
+ readonly errorDetails: OperationErrorDetails;
8
8
  };
9
9
  type OperationSuccessResult<Data> = {
10
- errorDetails?: undefined;
11
- success: true;
12
- data: Data;
10
+ readonly errorDetails?: undefined;
11
+ readonly success: true;
12
+ readonly data: Data;
13
13
  };
14
14
  export type OperationResultForType<Data> = OperationFailureResult | OperationSuccessResult<Data>;
15
15
  export type OperationResult<Schema extends QuerySchema> = OperationResultForType<TypeOf<Schema>>;
@@ -1 +1 @@
1
- {"version":3,"file":"operation-result.d.ts","sourceRoot":"","sources":["../../../../source/zod-graphql-client/operation-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE,MAAM,MAAM,sBAAsB,GAAG;IACjC,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB,OAAO,EAAE,KAAK,CAAC;IACf,YAAY,EAAE,qBAAqB,CAAC;CACvC,CAAC;AAEF,KAAK,sBAAsB,CAAC,IAAI,IAAI;IAChC,YAAY,CAAC,EAAE,SAAS,CAAC;IACzB,OAAO,EAAE,IAAI,CAAC;IACd,IAAI,EAAE,IAAI,CAAC;CACd,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,IAAI,IAAI,sBAAsB,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;AAEjG,MAAM,MAAM,eAAe,CAAC,MAAM,SAAS,WAAW,IAAI,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC"}
1
+ {"version":3,"file":"operation-result.d.ts","sourceRoot":"","sources":["../../../../source/zod-graphql-client/operation-result.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,6CAA6C,CAAC;AAC/E,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAElE,MAAM,MAAM,sBAAsB,GAAG;IACjC,QAAQ,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC;IAC1B,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC;IACxB,QAAQ,CAAC,YAAY,EAAE,qBAAqB,CAAC;CAChD,CAAC;AAEF,KAAK,sBAAsB,CAAC,IAAI,IAAI;IAChC,QAAQ,CAAC,YAAY,CAAC,EAAE,SAAS,CAAC;IAClC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,sBAAsB,CAAC,IAAI,IAAI,sBAAsB,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAC;AAEjG,MAAM,MAAM,eAAe,CAAC,MAAM,SAAS,WAAW,IAAI,sBAAsB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ declare const persistedQueryVersion = 1;
2
+ export type PersistedQueryExtensions = {
3
+ readonly persistedQuery: {
4
+ readonly version: typeof persistedQueryVersion;
5
+ readonly sha256Hash: string;
6
+ };
7
+ };
8
+ export {};
9
+ //# sourceMappingURL=persisted-query.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persisted-query.d.ts","sourceRoot":"","sources":["../../../../source/zod-graphql-client/persisted-query.ts"],"names":[],"mappings":"AAGA,QAAA,MAAM,qBAAqB,IAAI;AAE/B,MAAM,MAAM,wBAAwB,GAAG;IACnC,QAAQ,CAAC,cAAc,EAAE;QACrB,QAAQ,CAAC,OAAO,EAAE,OAAO,qBAAqB,CAAC;QAC/C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;KAC/B,CAAC;CACL"}
@@ -0,0 +1,50 @@
1
+ import { createHash } from 'node:crypto';
2
+ import { z } from 'zod/v4-mini';
3
+ const persistedQueryVersion = 1;
4
+ export function computePersistedQueryHash(query) {
5
+ return createHash('sha256').update(query).digest('hex');
6
+ }
7
+ export function buildPersistedQueryExtensions(query) {
8
+ return {
9
+ persistedQuery: {
10
+ version: persistedQueryVersion,
11
+ sha256Hash: computePersistedQueryHash(query)
12
+ }
13
+ };
14
+ }
15
+ const persistedQueryNotFoundMessage = 'PersistedQueryNotFound';
16
+ const persistedQueryNotFoundCode = 'PERSISTED_QUERY_NOT_FOUND';
17
+ const persistedQueryNotSupportedMessage = 'PersistedQueryNotSupported';
18
+ const persistedQueryNotSupportedCode = 'PERSISTED_QUERY_NOT_SUPPORTED';
19
+ const persistedQueryErrorDetectionSchema = z.object({
20
+ errors: z.optional(z.array(z.object({
21
+ message: z.optional(z.string()),
22
+ extensions: z.optional(z.object({
23
+ code: z.optional(z.string())
24
+ }))
25
+ })))
26
+ });
27
+ function classifyPersistedQueryError(error) {
28
+ const code = error.extensions?.code;
29
+ if (error.message === persistedQueryNotFoundMessage || code === persistedQueryNotFoundCode) {
30
+ return 'not-found';
31
+ }
32
+ if (error.message === persistedQueryNotSupportedMessage || code === persistedQueryNotSupportedCode) {
33
+ return 'not-supported';
34
+ }
35
+ return undefined;
36
+ }
37
+ export function detectPersistedQueryRetryReason(rawResponse) {
38
+ const parsed = persistedQueryErrorDetectionSchema.safeParse(rawResponse);
39
+ if (!parsed.success || parsed.data.errors === undefined) {
40
+ return undefined;
41
+ }
42
+ for (const error of parsed.data.errors) {
43
+ const reason = classifyPersistedQueryError(error);
44
+ if (reason !== undefined) {
45
+ return reason;
46
+ }
47
+ }
48
+ return undefined;
49
+ }
50
+ //# sourceMappingURL=persisted-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"persisted-query.js","sourceRoot":"","sources":["../../../../source/zod-graphql-client/persisted-query.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,CAAC,EAAE,MAAM,aAAa,CAAC;AAEhC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAShC,MAAM,UAAU,yBAAyB,CAAC,KAAa;IACnD,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,6BAA6B,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AAO,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACtD,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC;QACrC,MAAM,MAAM,GAAG,2BAA2B,CAAC,KAAK,CAAC,CAAC;QAClD,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC;QAClB,CAAC;IACL,CAAC;IACD,OAAO,SAAS,CAAC;AACrB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { $ZodType, type output as TypeOf } from 'zod/v4/core';
2
+ export type ExplicitVariableEntry<Schema extends $ZodType = $ZodType> = {
3
+ readonly type: string;
4
+ readonly schema: Schema;
5
+ };
6
+ export type VariableEntry = $ZodType | ExplicitVariableEntry;
7
+ type SchemaFromZodType<Entry> = Entry extends $ZodType ? Entry : never;
8
+ export type EntrySchema<Entry extends VariableEntry> = Entry extends ExplicitVariableEntry<infer Schema> ? Schema : SchemaFromZodType<Entry>;
9
+ export type EntryValueType<Entry extends VariableEntry> = TypeOf<EntrySchema<Entry>>;
10
+ export declare function variable<Schema extends $ZodType>(type: string, schema: Schema): ExplicitVariableEntry<Schema>;
11
+ export {};
12
+ //# sourceMappingURL=variable-entry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable-entry.d.ts","sourceRoot":"","sources":["../../../../source/zod-graphql-client/variable-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,KAAK,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa;AAE7D,MAAM,MAAM,qBAAqB,CAAC,MAAM,SAAS,QAAQ,GAAG,QAAQ,IAAI;IACpE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;CAC3B;AAGD,MAAM,MAAM,aAAa,GAAG,QAAQ,GAAG,qBAAqB;AAE5D,KAAK,iBAAiB,CAAC,KAAK,IAAI,KAAK,SAAS,QAAQ,GAAG,KAAK,GAAG,KAAK;AAEtE,MAAM,MAAM,WAAW,CAAC,KAAK,SAAS,aAAa,IAAI,KAAK,SAAS,qBAAqB,CAAC,MAAM,MAAM,CAAC,GAAG,MAAM,GAC3G,iBAAiB,CAAC,KAAK,CAAC;AAE9B,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,aAAa,IAAI,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;AAUpF,wBAAgB,QAAQ,CAAC,MAAM,SAAS,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,qBAAqB,CAAC,MAAM,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { $ZodType } from 'zod/v4/core';
2
+ export function isExplicitVariableEntry(entry) {
3
+ return !(entry instanceof $ZodType);
4
+ }
5
+ export function getEntrySchema(entry) {
6
+ return isExplicitVariableEntry(entry) ? entry.schema : entry;
7
+ }
8
+ export function variable(type, schema) {
9
+ return { type, schema };
10
+ }
11
+ //# sourceMappingURL=variable-entry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variable-entry.js","sourceRoot":"","sources":["../../../../source/zod-graphql-client/variable-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAyB,MAAM,aAAa,CAAC;AAiB9D,MAAM,UAAU,uBAAuB,CAAC,KAAoB;IACxD,OAAO,CAAC,CAAC,KAAK,YAAY,QAAQ,CAAC,CAAC;AACxC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,KAAoB;IAC/C,OAAO,uBAAuB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,KAAK,CAAC;AACjE,CAAC;AAED,MAAM,UAAU,QAAQ,CAA0B,IAAY,EAAE,MAAc;IAC1E,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;AAC5B,CAAC"}
@@ -1,9 +0,0 @@
1
- type Variable = {
2
- type: string;
3
- value: unknown;
4
- };
5
- export type Variables = Record<string, Variable>;
6
- export declare function extractVariableDefinitions(variables: Variables): Record<string, string>;
7
- export declare function extractVariableValues(variables: Variables): Record<string, unknown>;
8
- export {};
9
- //# sourceMappingURL=variables.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"variables.d.ts","sourceRoot":"","sources":["../../../../source/zod-graphql-client/variables.ts"],"names":[],"mappings":"AAAA,KAAK,QAAQ,GAAG;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAEjD,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAMvF;AAED,wBAAgB,qBAAqB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAMnF"}
@@ -1,15 +0,0 @@
1
- export function extractVariableDefinitions(variables) {
2
- const entries = Object.entries(variables);
3
- const entriesWithTypeOnly = entries.map(([name, variable]) => {
4
- return [`$${name}`, variable.type];
5
- });
6
- return Object.fromEntries(entriesWithTypeOnly);
7
- }
8
- export function extractVariableValues(variables) {
9
- const entries = Object.entries(variables);
10
- const entriesWithTypeOnly = entries.map(([name, variable]) => {
11
- return [name, variable.value];
12
- });
13
- return Object.fromEntries(entriesWithTypeOnly);
14
- }
15
- //# sourceMappingURL=variables.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"variables.js","sourceRoot":"","sources":["../../../../source/zod-graphql-client/variables.ts"],"names":[],"mappings":"AAOA,MAAM,UAAU,0BAA0B,CAAC,SAAoB;IAC3D,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAoB,EAAE;QAC3E,OAAO,CAAC,IAAI,IAAI,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;AACnD,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,SAAoB;IACtD,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC1C,MAAM,mBAAmB,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAqB,EAAE;QAC5E,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC;IAClC,CAAC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,WAAW,CAAC,mBAAmB,CAAC,CAAC;AACnD,CAAC"}