@soda-gql/core 0.9.0 → 0.9.1
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 +67 -0
- package/dist/adapter.cjs +50 -3
- package/dist/adapter.cjs.map +1 -1
- package/dist/adapter.d.cts +52 -5
- package/dist/adapter.d.cts.map +1 -1
- package/dist/adapter.d.ts +52 -5
- package/dist/adapter.d.ts.map +1 -1
- package/dist/adapter.js +50 -3
- package/dist/adapter.js.map +1 -1
- package/dist/{index-Ib9pb2Si.d.cts → index-B_TU5U2U.d.ts} +11 -4
- package/dist/{index-wkJ6KSwK.d.ts.map → index-B_TU5U2U.d.ts.map} +1 -1
- package/dist/{schema-2qqtKss4.d.ts → index-BlVgxrXb.d.ts} +371 -300
- package/dist/index-BlVgxrXb.d.ts.map +1 -0
- package/dist/{index-wkJ6KSwK.d.ts → index-_6fYTfcA.d.cts} +11 -4
- package/dist/{index-Ib9pb2Si.d.cts.map → index-_6fYTfcA.d.cts.map} +1 -1
- package/dist/{schema-CPTxQbTv.d.cts → index-zCOsREx0.d.cts} +371 -300
- package/dist/index-zCOsREx0.d.cts.map +1 -0
- package/dist/index.cjs +47 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +47 -15
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.cts +2 -2
- package/dist/runtime.d.ts +2 -2
- package/dist/{schema-builder-BYJd50o2.d.cts → schema-builder-BI5PQkH7.d.cts} +2 -2
- package/dist/{schema-builder-BYJd50o2.d.cts.map → schema-builder-BI5PQkH7.d.cts.map} +1 -1
- package/dist/{schema-builder-Dhss2O1I.d.ts → schema-builder-CF_AwsOM.d.ts} +2 -2
- package/dist/{schema-builder-Dhss2O1I.d.ts.map → schema-builder-CF_AwsOM.d.ts.map} +1 -1
- package/package.json +1 -1
- package/dist/schema-2qqtKss4.d.ts.map +0 -1
- package/dist/schema-CPTxQbTv.d.cts.map +0 -1
|
@@ -76,6 +76,55 @@ type ConstValues = {
|
|
|
76
76
|
readonly [key: string]: ConstValue;
|
|
77
77
|
};
|
|
78
78
|
//#endregion
|
|
79
|
+
//#region packages/core/src/types/type-foundation/depth-counter.d.ts
|
|
80
|
+
/**
|
|
81
|
+
* Depth counter utilities for limiting type inference recursion.
|
|
82
|
+
*
|
|
83
|
+
* Used primarily to prevent infinite recursion in recursive input types
|
|
84
|
+
* like Hasura's `bool_exp` pattern where types reference themselves.
|
|
85
|
+
*/
|
|
86
|
+
/**
|
|
87
|
+
* A depth counter represented as a tuple.
|
|
88
|
+
* The length of the tuple represents the remaining depth.
|
|
89
|
+
*/
|
|
90
|
+
type DepthCounter = readonly unknown[];
|
|
91
|
+
/**
|
|
92
|
+
* Default depth limit for input type inference.
|
|
93
|
+
* Depth 3 allows:
|
|
94
|
+
* - Level 0: Top-level fields
|
|
95
|
+
* - Level 1: First-level nested objects
|
|
96
|
+
* - Level 2: Second-level nested objects
|
|
97
|
+
* - Level 3: Third-level nested objects (then stops)
|
|
98
|
+
*/
|
|
99
|
+
type DefaultDepth = [unknown, unknown, unknown];
|
|
100
|
+
/**
|
|
101
|
+
* Decrement depth by removing one element from the tuple.
|
|
102
|
+
* Returns empty tuple when depth is already exhausted.
|
|
103
|
+
*/
|
|
104
|
+
type DecrementDepth<D extends DepthCounter> = D extends readonly [unknown, ...infer Rest] ? Rest : [];
|
|
105
|
+
/**
|
|
106
|
+
* Check if depth counter is exhausted (empty tuple).
|
|
107
|
+
*/
|
|
108
|
+
type IsDepthExhausted<D extends DepthCounter> = D extends readonly [] ? true : false;
|
|
109
|
+
/**
|
|
110
|
+
* Convert a number literal to a depth counter tuple.
|
|
111
|
+
* Supports depths 0-10 (sufficient for most use cases).
|
|
112
|
+
*/
|
|
113
|
+
type NumberToDepth<N extends number> = N extends 0 ? [] : N extends 1 ? [unknown] : N extends 2 ? [unknown, unknown] : N extends 3 ? [unknown, unknown, unknown] : N extends 4 ? [unknown, unknown, unknown, unknown] : N extends 5 ? [unknown, unknown, unknown, unknown, unknown] : N extends 6 ? [unknown, unknown, unknown, unknown, unknown, unknown] : N extends 7 ? [unknown, unknown, unknown, unknown, unknown, unknown, unknown] : N extends 8 ? [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown] : N extends 9 ? [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown] : N extends 10 ? [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown] : DefaultDepth;
|
|
114
|
+
/**
|
|
115
|
+
* Type for per-input-type depth overrides (number-based, as stored in schema).
|
|
116
|
+
*/
|
|
117
|
+
type InputDepthOverrides = Readonly<Record<string, number>>;
|
|
118
|
+
/**
|
|
119
|
+
* Get depth for a specific input type from schema overrides.
|
|
120
|
+
* Priority: per-type override > schema default > hardcoded DefaultDepth (3).
|
|
121
|
+
*
|
|
122
|
+
* @typeParam TOverrides - The input depth overrides from schema
|
|
123
|
+
* @typeParam TTypeName - The input type name to look up
|
|
124
|
+
* @typeParam TDefaultDepth - Optional schema-level default depth
|
|
125
|
+
*/
|
|
126
|
+
type GetInputTypeDepth<TOverrides extends InputDepthOverrides | undefined, TTypeName$1 extends string, TDefaultDepth extends number | undefined = undefined> = TOverrides extends InputDepthOverrides ? TTypeName$1 extends keyof TOverrides ? NumberToDepth<TOverrides[TTypeName$1]> : TDefaultDepth extends number ? NumberToDepth<TDefaultDepth> : DefaultDepth : TDefaultDepth extends number ? NumberToDepth<TDefaultDepth> : DefaultDepth;
|
|
127
|
+
//#endregion
|
|
79
128
|
//#region packages/core/src/types/type-foundation/type-modifier-core.generated.d.ts
|
|
80
129
|
type TypeModifier = string;
|
|
81
130
|
type ValidTypeModifier = "!" | "?" | "![]!" | "![]?" | "?[]!" | "?[]?" | "![]![]!" | "![]![]?" | "![]?[]!" | "![]?[]?" | "?[]![]!" | "?[]![]?" | "?[]?[]!" | "?[]?[]?" | "![]![]![]!" | "![]![]![]?" | "![]![]?[]!" | "![]![]?[]?" | "![]?[]![]!" | "![]?[]![]?" | "![]?[]?[]!" | "![]?[]?[]?" | "?[]![]![]!" | "?[]![]![]?" | "?[]![]?[]!" | "?[]![]?[]?" | "?[]?[]![]!" | "?[]?[]![]?" | "?[]?[]?[]!" | "?[]?[]?[]?";
|
|
@@ -144,6 +193,61 @@ type Signature_OptionalList_OptionalList_OptionalList_Required = Op_0<Signature_
|
|
|
144
193
|
type Signature_OptionalList_OptionalList_OptionalList_Optional = Op_1<Signature_OptionalList_OptionalList_Optional>;
|
|
145
194
|
type GetSignature<M extends TypeModifier> = M extends "!" ? Signature_Required : M extends "?" ? Signature_Optional : M extends "![]!" ? Signature_RequiredList_Required : M extends "![]?" ? Signature_RequiredList_Optional : M extends "?[]!" ? Signature_OptionalList_Required : M extends "?[]?" ? Signature_OptionalList_Optional : M extends "![]![]!" ? Signature_RequiredList_RequiredList_Required : M extends "![]![]?" ? Signature_RequiredList_RequiredList_Optional : M extends "![]?[]!" ? Signature_RequiredList_OptionalList_Required : M extends "![]?[]?" ? Signature_RequiredList_OptionalList_Optional : M extends "?[]![]!" ? Signature_OptionalList_RequiredList_Required : M extends "?[]![]?" ? Signature_OptionalList_RequiredList_Optional : M extends "?[]?[]!" ? Signature_OptionalList_OptionalList_Required : M extends "?[]?[]?" ? Signature_OptionalList_OptionalList_Optional : M extends "![]![]![]!" ? Signature_RequiredList_RequiredList_RequiredList_Required : M extends "![]![]![]?" ? Signature_RequiredList_RequiredList_RequiredList_Optional : M extends "![]![]?[]!" ? Signature_RequiredList_RequiredList_OptionalList_Required : M extends "![]![]?[]?" ? Signature_RequiredList_RequiredList_OptionalList_Optional : M extends "![]?[]![]!" ? Signature_RequiredList_OptionalList_RequiredList_Required : M extends "![]?[]![]?" ? Signature_RequiredList_OptionalList_RequiredList_Optional : M extends "![]?[]?[]!" ? Signature_RequiredList_OptionalList_OptionalList_Required : M extends "![]?[]?[]?" ? Signature_RequiredList_OptionalList_OptionalList_Optional : M extends "?[]![]![]!" ? Signature_OptionalList_RequiredList_RequiredList_Required : M extends "?[]![]![]?" ? Signature_OptionalList_RequiredList_RequiredList_Optional : M extends "?[]![]?[]!" ? Signature_OptionalList_RequiredList_OptionalList_Required : M extends "?[]![]?[]?" ? Signature_OptionalList_RequiredList_OptionalList_Optional : M extends "?[]?[]![]!" ? Signature_OptionalList_OptionalList_RequiredList_Required : M extends "?[]?[]![]?" ? Signature_OptionalList_OptionalList_RequiredList_Optional : M extends "?[]?[]?[]!" ? Signature_OptionalList_OptionalList_OptionalList_Required : M extends "?[]?[]?[]?" ? Signature_OptionalList_OptionalList_OptionalList_Optional : never;
|
|
146
195
|
//#endregion
|
|
196
|
+
//#region packages/core/src/types/type-foundation/type-profile.d.ts
|
|
197
|
+
interface PrimitiveTypeProfile {
|
|
198
|
+
readonly kind: "scalar" | "enum";
|
|
199
|
+
readonly name: string;
|
|
200
|
+
readonly value: any;
|
|
201
|
+
}
|
|
202
|
+
interface ObjectTypeProfile {
|
|
203
|
+
readonly kind: "input";
|
|
204
|
+
readonly name: string;
|
|
205
|
+
readonly fields: {
|
|
206
|
+
readonly [key: string]: TypeProfile.WithMeta;
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
type TypeProfile = PrimitiveTypeProfile | ObjectTypeProfile;
|
|
210
|
+
declare namespace TypeProfile {
|
|
211
|
+
type WITH_DEFAULT_INPUT = "with_default_input";
|
|
212
|
+
type WithMeta = [TypeProfile, TypeModifier, WITH_DEFAULT_INPUT?];
|
|
213
|
+
type IsOptionalProfile<TField extends WithMeta> = TField[1] extends `${string}?` ? true : TField[2] extends WITH_DEFAULT_INPUT ? true : false;
|
|
214
|
+
type OptionalProfileKeys<TProfileObject extends {
|
|
215
|
+
readonly [key: string]: WithMeta;
|
|
216
|
+
}> = { [K in keyof TProfileObject]: IsOptionalProfile<TProfileObject[K]> extends true ? K : never }[keyof TProfileObject];
|
|
217
|
+
type RequiredProfileKeys<TProfileObject extends {
|
|
218
|
+
readonly [key: string]: WithMeta;
|
|
219
|
+
}> = { [K in keyof TProfileObject]: IsOptionalProfile<TProfileObject[K]> extends false ? K : never }[keyof TProfileObject];
|
|
220
|
+
type Simplify<T> = { [K in keyof T]: T[K] } & {};
|
|
221
|
+
type ConstObjectType<TProfileObject extends {
|
|
222
|
+
readonly [key: string]: WithMeta;
|
|
223
|
+
}> = Simplify<{ readonly [K in OptionalProfileKeys<TProfileObject>]+?: TProfileObject[K] extends WithMeta ? Type<TProfileObject[K]> : never } & { readonly [K in RequiredProfileKeys<TProfileObject>]-?: TProfileObject[K] extends WithMeta ? Type<TProfileObject[K]> : never }>;
|
|
224
|
+
type Type<TProfile extends TypeProfile.WithMeta> = ApplyTypeModifier<TProfile[0] extends PrimitiveTypeProfile ? TProfile[0]["value"] : TProfile[0] extends ObjectTypeProfile ? ConstObjectType<TProfile[0]["fields"]> : never, TProfile[1]> | (TProfile[2] extends WITH_DEFAULT_INPUT ? undefined : never);
|
|
225
|
+
/**
|
|
226
|
+
* Expected variable type derived from TypeProfile.
|
|
227
|
+
* Extracts typeName and kind from the profile, takes pre-computed signature.
|
|
228
|
+
* Used by generated Assignable types for efficient type checking.
|
|
229
|
+
* This name appears in TypeScript error messages when VarRef types don't match.
|
|
230
|
+
*/
|
|
231
|
+
type ExpectedVariableType<T extends TypeProfile, TSignature> = {
|
|
232
|
+
typeName: T["name"];
|
|
233
|
+
kind: T["kind"];
|
|
234
|
+
signature: TSignature;
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Declared variable type derived from WithMeta.
|
|
238
|
+
* Used by DeclaredVariables to type variable references.
|
|
239
|
+
* Derives typeName, kind, and signature from the profile.
|
|
240
|
+
* This name appears in TypeScript error messages when VarRef types don't match.
|
|
241
|
+
*/
|
|
242
|
+
type DeclaredVariableType<T extends WithMeta> = {
|
|
243
|
+
typeName: T[0]["name"];
|
|
244
|
+
kind: T[0]["kind"];
|
|
245
|
+
signature: GetSignature<T[1]>;
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
type GetModifiedType<TProfile extends TypeProfile, TModifier extends TypeModifier> = TypeProfile.Type<[TProfile, TModifier]>;
|
|
249
|
+
type GetConstAssignableType<TProfile extends TypeProfile.WithMeta> = TypeProfile.Type<TProfile>;
|
|
250
|
+
//#endregion
|
|
147
251
|
//#region packages/core/src/types/type-foundation/type-specifier.d.ts
|
|
148
252
|
type AnyDefaultValue = {
|
|
149
253
|
default: ConstValue;
|
|
@@ -237,50 +341,207 @@ declare function createVarRefFromVariable(name: string): AnyVarRef;
|
|
|
237
341
|
*/
|
|
238
342
|
declare function createVarRefFromNestedValue(value: NestedValue): AnyVarRef;
|
|
239
343
|
//#endregion
|
|
240
|
-
//#region packages/core/src/
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
type
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
readonly
|
|
344
|
+
//#region packages/core/src/utils/type-meta.d.ts
|
|
345
|
+
interface WithTypeMeta<T extends object> {
|
|
346
|
+
readonly $type: T;
|
|
347
|
+
}
|
|
348
|
+
//#endregion
|
|
349
|
+
//#region packages/core/src/types/schema/schema.d.ts
|
|
350
|
+
type OperationType = keyof OperationRoots;
|
|
351
|
+
type AnyTypeName = string;
|
|
352
|
+
type AnyFieldName = string;
|
|
353
|
+
type AnyGraphqlSchema = {
|
|
354
|
+
readonly label: string;
|
|
355
|
+
readonly operations: OperationRoots;
|
|
356
|
+
readonly scalar: {
|
|
357
|
+
readonly [name: string]: ScalarDefinition<any>;
|
|
358
|
+
};
|
|
359
|
+
readonly enum: {
|
|
360
|
+
readonly [name: string]: EnumDefinition<any>;
|
|
361
|
+
};
|
|
362
|
+
readonly input: {
|
|
363
|
+
readonly [name: string]: InputDefinition;
|
|
364
|
+
};
|
|
365
|
+
readonly object: {
|
|
366
|
+
readonly [name: string]: ObjectDefinition;
|
|
367
|
+
};
|
|
368
|
+
readonly union: {
|
|
369
|
+
readonly [name: string]: UnionDefinition;
|
|
370
|
+
};
|
|
371
|
+
/**
|
|
372
|
+
* Optional default depth for input type inference.
|
|
373
|
+
* Used when no per-type override is specified.
|
|
374
|
+
* Generated by codegen when defaultInputDepth is specified in config.
|
|
375
|
+
*/
|
|
376
|
+
readonly __defaultInputDepth?: number;
|
|
377
|
+
/**
|
|
378
|
+
* Optional depth overrides for input type inference.
|
|
379
|
+
* Maps input type names to their maximum inference depth.
|
|
380
|
+
* Generated by codegen when inputDepthOverrides is specified in config.
|
|
381
|
+
*/
|
|
382
|
+
readonly __inputDepthOverrides?: InputDepthOverrides;
|
|
251
383
|
};
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
384
|
+
type OperationRoots = {
|
|
385
|
+
readonly query: string | null;
|
|
386
|
+
readonly mutation: string | null;
|
|
387
|
+
readonly subscription: string | null;
|
|
388
|
+
};
|
|
389
|
+
interface ScalarDefinition<T extends {
|
|
390
|
+
name: string;
|
|
391
|
+
input: unknown;
|
|
392
|
+
output: unknown;
|
|
393
|
+
}> extends WithTypeMeta<{
|
|
394
|
+
input: T["input"];
|
|
395
|
+
inputProfile: {
|
|
396
|
+
kind: "scalar";
|
|
397
|
+
name: T["name"];
|
|
398
|
+
value: T["input"];
|
|
399
|
+
};
|
|
400
|
+
output: T["output"];
|
|
401
|
+
outputProfile: {
|
|
402
|
+
kind: "scalar";
|
|
403
|
+
name: T["name"];
|
|
404
|
+
value: T["output"];
|
|
405
|
+
};
|
|
406
|
+
}> {
|
|
407
|
+
readonly name: T["name"];
|
|
408
|
+
}
|
|
409
|
+
interface EnumDefinition<T extends {
|
|
410
|
+
name: string;
|
|
411
|
+
values: string;
|
|
412
|
+
}> extends WithTypeMeta<{
|
|
413
|
+
name: T["name"];
|
|
414
|
+
inputProfile: {
|
|
415
|
+
kind: "enum";
|
|
416
|
+
name: T["name"];
|
|
417
|
+
value: T["values"];
|
|
418
|
+
};
|
|
419
|
+
outputProfile: {
|
|
420
|
+
kind: "enum";
|
|
421
|
+
name: T["name"];
|
|
422
|
+
value: T["values"];
|
|
423
|
+
};
|
|
424
|
+
}> {
|
|
425
|
+
readonly name: T["name"];
|
|
426
|
+
readonly values: { readonly [_ in T["values"]]: true };
|
|
427
|
+
}
|
|
428
|
+
interface InputDefinition {
|
|
429
|
+
readonly name: string;
|
|
430
|
+
readonly fields: InputTypeSpecifiers;
|
|
431
|
+
}
|
|
432
|
+
type ObjectDefinition = {
|
|
433
|
+
readonly name: string;
|
|
434
|
+
readonly fields: OutputTypeSpecifiers;
|
|
435
|
+
};
|
|
436
|
+
type UnionDefinition = {
|
|
437
|
+
readonly name: string;
|
|
438
|
+
readonly types: {
|
|
439
|
+
[typename: string]: true;
|
|
440
|
+
};
|
|
269
441
|
};
|
|
270
442
|
/**
|
|
271
|
-
*
|
|
272
|
-
* Allows metadata to reference operation variables.
|
|
443
|
+
* Infers a TypeProfile from an input type specifier.
|
|
273
444
|
*
|
|
274
|
-
* @
|
|
275
|
-
* @
|
|
276
|
-
* @
|
|
277
|
-
*
|
|
445
|
+
* @typeParam TSchema - The GraphQL schema
|
|
446
|
+
* @typeParam TSpecifier - The input type specifier to infer from
|
|
447
|
+
* @typeParam TDepth - Depth counter to limit recursion (default from schema overrides or schema default or 3 levels)
|
|
448
|
+
*
|
|
449
|
+
* When depth is exhausted, returns `never` to cause a type error.
|
|
450
|
+
* This prevents infinite recursion in self-referential types like `bool_exp`.
|
|
278
451
|
*/
|
|
279
|
-
type
|
|
452
|
+
type InferInputProfile<TSchema extends AnyGraphqlSchema, TSpecifier extends InputTypeSpecifier, TDepth extends DepthCounter = GetInputTypeDepth<TSchema["__inputDepthOverrides"], TSpecifier["name"], TSchema["__defaultInputDepth"]>> = { [_ in TSchema["label"]]: IsDepthExhausted<TDepth> extends true ? never : [TSpecifier extends InputScalarSpecifier ? TSchema["scalar"][TSpecifier["name"]]["$type"]["inputProfile"] : TSpecifier extends InputEnumSpecifier ? TSchema["enum"][TSpecifier["name"]]["$type"]["inputProfile"] : TSchema["input"][TSpecifier["name"]]["fields"] extends infer TFields ? {
|
|
453
|
+
kind: "input";
|
|
454
|
+
name: TSpecifier["name"];
|
|
455
|
+
fields: { [K in keyof TFields]: TFields[K] extends InputTypeSpecifier ? InferInputProfile<TSchema, TFields[K], DecrementDepth<TDepth>> : never };
|
|
456
|
+
} : never, TSpecifier["modifier"], TSpecifier["defaultValue"] extends AnyDefaultValue ? TypeProfile.WITH_DEFAULT_INPUT : undefined] }[TSchema["label"]];
|
|
457
|
+
type InferOutputProfile<TSchema extends AnyGraphqlSchema, TSpecifier extends OutputInferrableTypeSpecifier> = { [_ in TSchema["label"]]: (TSpecifier extends OutputScalarSpecifier ? TSchema["scalar"][TSpecifier["name"]] : TSchema["enum"][TSpecifier["name"]])["$type"]["outputProfile"] }[TSchema["label"]];
|
|
458
|
+
type PickTypeSpecifierByFieldName<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"], TFieldName$1 extends keyof TSchema["object"][TTypeName$1]["fields"]> = TSchema["object"][TTypeName$1]["fields"][TFieldName$1];
|
|
459
|
+
type InputFieldRecord<TSchema extends AnyGraphqlSchema, TSpecifier extends InputTypeSpecifier> = TSchema["input"][TSpecifier["name"]]["fields"];
|
|
460
|
+
type ObjectFieldRecord<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"]> = { readonly [TFieldName in keyof TSchema["object"][TTypeName$1]["fields"]]: TSchema["object"][TTypeName$1]["fields"][TFieldName] };
|
|
461
|
+
type UnionTypeRecord<TSchema extends AnyGraphqlSchema, TSpecifier extends OutputUnionSpecifier> = { readonly [TTypeName in UnionMemberName<TSchema, TSpecifier>]: TSchema["object"][TTypeName] };
|
|
462
|
+
type UnionMemberName<TSchema extends AnyGraphqlSchema, TSpecifier extends OutputUnionSpecifier> = Extract<keyof TSchema["object"], keyof TSchema["union"][TSpecifier["name"]]["types"]> & string;
|
|
280
463
|
/**
|
|
281
|
-
*
|
|
464
|
+
* Union of all input type names in a schema (scalars, enums, and input objects).
|
|
282
465
|
*/
|
|
283
|
-
type
|
|
466
|
+
type AllInputTypeNames<TSchema extends AnyGraphqlSchema> = (keyof TSchema["scalar"] & string) | (keyof TSchema["enum"] & string) | (keyof TSchema["input"] & string);
|
|
467
|
+
/**
|
|
468
|
+
* Infers the input type kind from a type name.
|
|
469
|
+
*/
|
|
470
|
+
type InferInputKind<TSchema extends AnyGraphqlSchema, TName extends AllInputTypeNames<TSchema>> = TName extends keyof TSchema["scalar"] ? "scalar" : TName extends keyof TSchema["enum"] ? "enum" : TName extends keyof TSchema["input"] ? "input" : never;
|
|
471
|
+
/**
|
|
472
|
+
* Resolves a TypeProfile from VarRefMetaV2 parameters (typeName + kind).
|
|
473
|
+
* This is used by schema-aware functions like getValueAt to resolve type structure
|
|
474
|
+
* from the schema at call site, rather than storing full profile in VarRef.
|
|
475
|
+
*
|
|
476
|
+
* @typeParam TSchema - The GraphQL schema
|
|
477
|
+
* @typeParam TTypeName - The GraphQL type name (e.g., "String", "UserInput")
|
|
478
|
+
* @typeParam TKind - The type kind ("scalar" | "enum" | "input")
|
|
479
|
+
* @typeParam TModifier - The type modifier (e.g., "!", "?", "![]!")
|
|
480
|
+
*/
|
|
481
|
+
type ResolveInputProfileFromMeta<TSchema extends AnyGraphqlSchema, TTypeName$1 extends string, TKind extends "scalar" | "enum" | "input", TModifier extends TypeModifier> = TKind extends "scalar" ? InferInputProfile<TSchema, {
|
|
482
|
+
kind: "scalar";
|
|
483
|
+
name: TTypeName$1;
|
|
484
|
+
modifier: TModifier;
|
|
485
|
+
defaultValue: null;
|
|
486
|
+
directives: {};
|
|
487
|
+
}> : TKind extends "enum" ? InferInputProfile<TSchema, {
|
|
488
|
+
kind: "enum";
|
|
489
|
+
name: TTypeName$1;
|
|
490
|
+
modifier: TModifier;
|
|
491
|
+
defaultValue: null;
|
|
492
|
+
directives: {};
|
|
493
|
+
}> : InferInputProfile<TSchema, {
|
|
494
|
+
kind: "input";
|
|
495
|
+
name: TTypeName$1;
|
|
496
|
+
modifier: TModifier;
|
|
497
|
+
defaultValue: null;
|
|
498
|
+
directives: {};
|
|
499
|
+
}>;
|
|
500
|
+
//#endregion
|
|
501
|
+
//#region packages/core/src/types/metadata/metadata.d.ts
|
|
502
|
+
/**
|
|
503
|
+
* Base metadata types that can be attached to operations.
|
|
504
|
+
* These are consumed at runtime by GraphQL clients for HTTP headers
|
|
505
|
+
* and custom application-specific values.
|
|
506
|
+
*/
|
|
507
|
+
type OperationMetadata = {
|
|
508
|
+
/** HTTP headers to include with the GraphQL request */
|
|
509
|
+
readonly headers?: Record<string, string>;
|
|
510
|
+
/** Custom arbitrary metadata values for application-specific use */
|
|
511
|
+
readonly custom?: Record<string, unknown>;
|
|
512
|
+
};
|
|
513
|
+
/**
|
|
514
|
+
* Tools available inside metadata builder callbacks.
|
|
515
|
+
* Access utilities via $var.getName(), $var.getValue(), $var.getInner().
|
|
516
|
+
*
|
|
517
|
+
* @template TVarRefs - Variable references from the operation
|
|
518
|
+
* @template TAggregatedFragmentMetadata - The aggregated fragment metadata type from the adapter
|
|
519
|
+
* @template TSchemaLevel - The schema-level configuration type from the adapter
|
|
520
|
+
*/
|
|
521
|
+
type MetadataBuilderTools<TVarRefs extends Record<string, AnyVarRef>, TAggregatedFragmentMetadata = readonly (OperationMetadata | undefined)[], TSchemaLevel$1 = unknown> = {
|
|
522
|
+
/** Variable references created from the operation's variable definitions */
|
|
523
|
+
readonly $: TVarRefs;
|
|
524
|
+
/** The GraphQL DocumentNode (AST) for this operation */
|
|
525
|
+
readonly document: DocumentNode;
|
|
526
|
+
/** Aggregated metadata from spread fragments, evaluated before operation metadata */
|
|
527
|
+
readonly fragmentMetadata?: TAggregatedFragmentMetadata;
|
|
528
|
+
/** Schema-level fixed values from the adapter */
|
|
529
|
+
readonly schemaLevel?: TSchemaLevel$1;
|
|
530
|
+
};
|
|
531
|
+
/**
|
|
532
|
+
* Metadata builder callback that receives variable tools.
|
|
533
|
+
* Allows metadata to reference operation variables.
|
|
534
|
+
*
|
|
535
|
+
* @template TVarRefs - Variable references from the operation
|
|
536
|
+
* @template TMetadata - The metadata type returned by this builder
|
|
537
|
+
* @template TAggregatedFragmentMetadata - The aggregated fragment metadata type from the adapter
|
|
538
|
+
* @template TSchemaLevel - The schema-level configuration type from the adapter
|
|
539
|
+
*/
|
|
540
|
+
type MetadataBuilder<TVarRefs extends Record<string, AnyVarRef>, TMetadata, TAggregatedFragmentMetadata = readonly (OperationMetadata | undefined)[], TSchemaLevel$1 = unknown> = (tools: MetadataBuilderTools<TVarRefs, TAggregatedFragmentMetadata, TSchemaLevel$1>) => TMetadata | Promise<TMetadata>;
|
|
541
|
+
/**
|
|
542
|
+
* Utility type to extract the metadata type from an operation.
|
|
543
|
+
*/
|
|
544
|
+
type ExtractMetadata<T> = T extends {
|
|
284
545
|
metadata: infer M;
|
|
285
546
|
} ? M : OperationMetadata;
|
|
286
547
|
/**
|
|
@@ -348,6 +609,75 @@ type ExtractAdapterTypes<T> = T extends MetadataAdapter<infer TFragment, infer T
|
|
|
348
609
|
* Generic type for any metadata adapter.
|
|
349
610
|
*/
|
|
350
611
|
type AnyMetadataAdapter = MetadataAdapter<any, any, any>;
|
|
612
|
+
/**
|
|
613
|
+
* Arguments passed to document transformer function.
|
|
614
|
+
* Destructurable for convenient access.
|
|
615
|
+
*
|
|
616
|
+
* @template TSchemaLevel - Schema-level configuration type
|
|
617
|
+
* @template TAggregatedFragmentMetadata - Aggregated fragment metadata type
|
|
618
|
+
*/
|
|
619
|
+
type DocumentTransformArgs<TSchemaLevel$1 = unknown, TAggregatedFragmentMetadata = unknown> = {
|
|
620
|
+
/** The GraphQL document to transform */
|
|
621
|
+
readonly document: DocumentNode;
|
|
622
|
+
/** The operation name */
|
|
623
|
+
readonly operationName: string;
|
|
624
|
+
/** The operation type (query, mutation, subscription) */
|
|
625
|
+
readonly operationType: OperationType;
|
|
626
|
+
/** Variable names defined for this operation */
|
|
627
|
+
readonly variableNames: readonly string[];
|
|
628
|
+
/** Schema-level configuration from adapter */
|
|
629
|
+
readonly schemaLevel: TSchemaLevel$1 | undefined;
|
|
630
|
+
/** Aggregated fragment metadata */
|
|
631
|
+
readonly fragmentMetadata: TAggregatedFragmentMetadata | undefined;
|
|
632
|
+
};
|
|
633
|
+
/**
|
|
634
|
+
* Document transformer function.
|
|
635
|
+
* Receives the built DocumentNode and returns a transformed DocumentNode.
|
|
636
|
+
*
|
|
637
|
+
* @template TSchemaLevel - Schema-level configuration type
|
|
638
|
+
* @template TAggregatedFragmentMetadata - Aggregated fragment metadata type
|
|
639
|
+
*/
|
|
640
|
+
type DocumentTransformer<TSchemaLevel$1 = unknown, TAggregatedFragmentMetadata = unknown> = (args: DocumentTransformArgs<TSchemaLevel$1, TAggregatedFragmentMetadata>) => DocumentNode;
|
|
641
|
+
/**
|
|
642
|
+
* Arguments passed to operation-level document transformer.
|
|
643
|
+
* Receives typed operation metadata.
|
|
644
|
+
*
|
|
645
|
+
* @template TOperationMetadata - The operation's metadata type
|
|
646
|
+
*/
|
|
647
|
+
type OperationDocumentTransformArgs<TOperationMetadata = unknown> = {
|
|
648
|
+
/** The GraphQL document to transform */
|
|
649
|
+
readonly document: DocumentNode;
|
|
650
|
+
/** The operation metadata (typed per-operation) */
|
|
651
|
+
readonly metadata: TOperationMetadata | undefined;
|
|
652
|
+
};
|
|
653
|
+
/**
|
|
654
|
+
* Operation-level document transformer function.
|
|
655
|
+
* Applied before the adapter-level transform.
|
|
656
|
+
*
|
|
657
|
+
* **Best Practice:** Define transform logic in adapter helpers for reusability,
|
|
658
|
+
* then reference the helper in the operation's `transformDocument` option.
|
|
659
|
+
*
|
|
660
|
+
* @example
|
|
661
|
+
* ```typescript
|
|
662
|
+
* // Define in adapter helpers
|
|
663
|
+
* const adapter = defineAdapter({
|
|
664
|
+
* helpers: {
|
|
665
|
+
* transform: {
|
|
666
|
+
* addCache: (ttl: number) => ({ document }) => visit(document, { ... }),
|
|
667
|
+
* },
|
|
668
|
+
* },
|
|
669
|
+
* });
|
|
670
|
+
*
|
|
671
|
+
* // Use in operation
|
|
672
|
+
* query.operation({
|
|
673
|
+
* transformDocument: transform.addCache(300),
|
|
674
|
+
* ...
|
|
675
|
+
* });
|
|
676
|
+
* ```
|
|
677
|
+
*
|
|
678
|
+
* @template TOperationMetadata - The operation's metadata type
|
|
679
|
+
*/
|
|
680
|
+
type OperationDocumentTransformer<TOperationMetadata = unknown> = (args: OperationDocumentTransformArgs<TOperationMetadata>) => DocumentNode;
|
|
351
681
|
/**
|
|
352
682
|
* Unified adapter that combines helpers and metadata configuration.
|
|
353
683
|
*
|
|
@@ -376,6 +706,8 @@ type Adapter<THelpers$1 extends object = object, TFragmentMetadata = unknown, TA
|
|
|
376
706
|
readonly helpers?: THelpers$1;
|
|
377
707
|
/** Metadata configuration for fragments and operations */
|
|
378
708
|
readonly metadata?: MetadataAdapter<TFragmentMetadata, TAggregatedFragmentMetadata, TSchemaLevel$1>;
|
|
709
|
+
/** Optional document transformer called after document building */
|
|
710
|
+
readonly transformDocument?: DocumentTransformer<TSchemaLevel$1, TAggregatedFragmentMetadata>;
|
|
379
711
|
};
|
|
380
712
|
/**
|
|
381
713
|
* Generic type for any unified adapter.
|
|
@@ -409,266 +741,5 @@ declare const createDefaultAdapter: () => DefaultMetadataAdapter;
|
|
|
409
741
|
*/
|
|
410
742
|
declare const defaultMetadataAdapter: DefaultMetadataAdapter;
|
|
411
743
|
//#endregion
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
* Depth counter utilities for limiting type inference recursion.
|
|
415
|
-
*
|
|
416
|
-
* Used primarily to prevent infinite recursion in recursive input types
|
|
417
|
-
* like Hasura's `bool_exp` pattern where types reference themselves.
|
|
418
|
-
*/
|
|
419
|
-
/**
|
|
420
|
-
* A depth counter represented as a tuple.
|
|
421
|
-
* The length of the tuple represents the remaining depth.
|
|
422
|
-
*/
|
|
423
|
-
type DepthCounter = readonly unknown[];
|
|
424
|
-
/**
|
|
425
|
-
* Default depth limit for input type inference.
|
|
426
|
-
* Depth 3 allows:
|
|
427
|
-
* - Level 0: Top-level fields
|
|
428
|
-
* - Level 1: First-level nested objects
|
|
429
|
-
* - Level 2: Second-level nested objects
|
|
430
|
-
* - Level 3: Third-level nested objects (then stops)
|
|
431
|
-
*/
|
|
432
|
-
type DefaultDepth = [unknown, unknown, unknown];
|
|
433
|
-
/**
|
|
434
|
-
* Decrement depth by removing one element from the tuple.
|
|
435
|
-
* Returns empty tuple when depth is already exhausted.
|
|
436
|
-
*/
|
|
437
|
-
type DecrementDepth<D extends DepthCounter> = D extends readonly [unknown, ...infer Rest] ? Rest : [];
|
|
438
|
-
/**
|
|
439
|
-
* Check if depth counter is exhausted (empty tuple).
|
|
440
|
-
*/
|
|
441
|
-
type IsDepthExhausted<D extends DepthCounter> = D extends readonly [] ? true : false;
|
|
442
|
-
/**
|
|
443
|
-
* Convert a number literal to a depth counter tuple.
|
|
444
|
-
* Supports depths 0-10 (sufficient for most use cases).
|
|
445
|
-
*/
|
|
446
|
-
type NumberToDepth<N extends number> = N extends 0 ? [] : N extends 1 ? [unknown] : N extends 2 ? [unknown, unknown] : N extends 3 ? [unknown, unknown, unknown] : N extends 4 ? [unknown, unknown, unknown, unknown] : N extends 5 ? [unknown, unknown, unknown, unknown, unknown] : N extends 6 ? [unknown, unknown, unknown, unknown, unknown, unknown] : N extends 7 ? [unknown, unknown, unknown, unknown, unknown, unknown, unknown] : N extends 8 ? [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown] : N extends 9 ? [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown] : N extends 10 ? [unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown, unknown] : DefaultDepth;
|
|
447
|
-
/**
|
|
448
|
-
* Type for per-input-type depth overrides (number-based, as stored in schema).
|
|
449
|
-
*/
|
|
450
|
-
type InputDepthOverrides = Readonly<Record<string, number>>;
|
|
451
|
-
/**
|
|
452
|
-
* Get depth for a specific input type from schema overrides.
|
|
453
|
-
* Priority: per-type override > schema default > hardcoded DefaultDepth (3).
|
|
454
|
-
*
|
|
455
|
-
* @typeParam TOverrides - The input depth overrides from schema
|
|
456
|
-
* @typeParam TTypeName - The input type name to look up
|
|
457
|
-
* @typeParam TDefaultDepth - Optional schema-level default depth
|
|
458
|
-
*/
|
|
459
|
-
type GetInputTypeDepth<TOverrides extends InputDepthOverrides | undefined, TTypeName$1 extends string, TDefaultDepth extends number | undefined = undefined> = TOverrides extends InputDepthOverrides ? TTypeName$1 extends keyof TOverrides ? NumberToDepth<TOverrides[TTypeName$1]> : TDefaultDepth extends number ? NumberToDepth<TDefaultDepth> : DefaultDepth : TDefaultDepth extends number ? NumberToDepth<TDefaultDepth> : DefaultDepth;
|
|
460
|
-
//#endregion
|
|
461
|
-
//#region packages/core/src/types/type-foundation/type-profile.d.ts
|
|
462
|
-
interface PrimitiveTypeProfile {
|
|
463
|
-
readonly kind: "scalar" | "enum";
|
|
464
|
-
readonly name: string;
|
|
465
|
-
readonly value: any;
|
|
466
|
-
}
|
|
467
|
-
interface ObjectTypeProfile {
|
|
468
|
-
readonly kind: "input";
|
|
469
|
-
readonly name: string;
|
|
470
|
-
readonly fields: {
|
|
471
|
-
readonly [key: string]: TypeProfile.WithMeta;
|
|
472
|
-
};
|
|
473
|
-
}
|
|
474
|
-
type TypeProfile = PrimitiveTypeProfile | ObjectTypeProfile;
|
|
475
|
-
declare namespace TypeProfile {
|
|
476
|
-
type WITH_DEFAULT_INPUT = "with_default_input";
|
|
477
|
-
type WithMeta = [TypeProfile, TypeModifier, WITH_DEFAULT_INPUT?];
|
|
478
|
-
type IsOptionalProfile<TField extends WithMeta> = TField[1] extends `${string}?` ? true : TField[2] extends WITH_DEFAULT_INPUT ? true : false;
|
|
479
|
-
type OptionalProfileKeys<TProfileObject extends {
|
|
480
|
-
readonly [key: string]: WithMeta;
|
|
481
|
-
}> = { [K in keyof TProfileObject]: IsOptionalProfile<TProfileObject[K]> extends true ? K : never }[keyof TProfileObject];
|
|
482
|
-
type RequiredProfileKeys<TProfileObject extends {
|
|
483
|
-
readonly [key: string]: WithMeta;
|
|
484
|
-
}> = { [K in keyof TProfileObject]: IsOptionalProfile<TProfileObject[K]> extends false ? K : never }[keyof TProfileObject];
|
|
485
|
-
type Simplify<T> = { [K in keyof T]: T[K] } & {};
|
|
486
|
-
type ConstObjectType<TProfileObject extends {
|
|
487
|
-
readonly [key: string]: WithMeta;
|
|
488
|
-
}> = Simplify<{ readonly [K in OptionalProfileKeys<TProfileObject>]+?: TProfileObject[K] extends WithMeta ? Type<TProfileObject[K]> : never } & { readonly [K in RequiredProfileKeys<TProfileObject>]-?: TProfileObject[K] extends WithMeta ? Type<TProfileObject[K]> : never }>;
|
|
489
|
-
type Type<TProfile extends TypeProfile.WithMeta> = ApplyTypeModifier<TProfile[0] extends PrimitiveTypeProfile ? TProfile[0]["value"] : TProfile[0] extends ObjectTypeProfile ? ConstObjectType<TProfile[0]["fields"]> : never, TProfile[1]> | (TProfile[2] extends WITH_DEFAULT_INPUT ? undefined : never);
|
|
490
|
-
/**
|
|
491
|
-
* Expected variable type derived from TypeProfile.
|
|
492
|
-
* Extracts typeName and kind from the profile, takes pre-computed signature.
|
|
493
|
-
* Used by generated Assignable types for efficient type checking.
|
|
494
|
-
* This name appears in TypeScript error messages when VarRef types don't match.
|
|
495
|
-
*/
|
|
496
|
-
type ExpectedVariableType<T extends TypeProfile, TSignature> = {
|
|
497
|
-
typeName: T["name"];
|
|
498
|
-
kind: T["kind"];
|
|
499
|
-
signature: TSignature;
|
|
500
|
-
};
|
|
501
|
-
/**
|
|
502
|
-
* Declared variable type derived from WithMeta.
|
|
503
|
-
* Used by DeclaredVariables to type variable references.
|
|
504
|
-
* Derives typeName, kind, and signature from the profile.
|
|
505
|
-
* This name appears in TypeScript error messages when VarRef types don't match.
|
|
506
|
-
*/
|
|
507
|
-
type DeclaredVariableType<T extends WithMeta> = {
|
|
508
|
-
typeName: T[0]["name"];
|
|
509
|
-
kind: T[0]["kind"];
|
|
510
|
-
signature: GetSignature<T[1]>;
|
|
511
|
-
};
|
|
512
|
-
}
|
|
513
|
-
type GetModifiedType<TProfile extends TypeProfile, TModifier extends TypeModifier> = TypeProfile.Type<[TProfile, TModifier]>;
|
|
514
|
-
type GetConstAssignableType<TProfile extends TypeProfile.WithMeta> = TypeProfile.Type<TProfile>;
|
|
515
|
-
//#endregion
|
|
516
|
-
//#region packages/core/src/utils/type-meta.d.ts
|
|
517
|
-
interface WithTypeMeta<T extends object> {
|
|
518
|
-
readonly $type: T;
|
|
519
|
-
}
|
|
520
|
-
//#endregion
|
|
521
|
-
//#region packages/core/src/types/schema/schema.d.ts
|
|
522
|
-
type OperationType = keyof OperationRoots;
|
|
523
|
-
type AnyTypeName = string;
|
|
524
|
-
type AnyFieldName = string;
|
|
525
|
-
type AnyGraphqlSchema = {
|
|
526
|
-
readonly label: string;
|
|
527
|
-
readonly operations: OperationRoots;
|
|
528
|
-
readonly scalar: {
|
|
529
|
-
readonly [name: string]: ScalarDefinition<any>;
|
|
530
|
-
};
|
|
531
|
-
readonly enum: {
|
|
532
|
-
readonly [name: string]: EnumDefinition<any>;
|
|
533
|
-
};
|
|
534
|
-
readonly input: {
|
|
535
|
-
readonly [name: string]: InputDefinition;
|
|
536
|
-
};
|
|
537
|
-
readonly object: {
|
|
538
|
-
readonly [name: string]: ObjectDefinition;
|
|
539
|
-
};
|
|
540
|
-
readonly union: {
|
|
541
|
-
readonly [name: string]: UnionDefinition;
|
|
542
|
-
};
|
|
543
|
-
/**
|
|
544
|
-
* Optional default depth for input type inference.
|
|
545
|
-
* Used when no per-type override is specified.
|
|
546
|
-
* Generated by codegen when defaultInputDepth is specified in config.
|
|
547
|
-
*/
|
|
548
|
-
readonly __defaultInputDepth?: number;
|
|
549
|
-
/**
|
|
550
|
-
* Optional depth overrides for input type inference.
|
|
551
|
-
* Maps input type names to their maximum inference depth.
|
|
552
|
-
* Generated by codegen when inputDepthOverrides is specified in config.
|
|
553
|
-
*/
|
|
554
|
-
readonly __inputDepthOverrides?: InputDepthOverrides;
|
|
555
|
-
};
|
|
556
|
-
type OperationRoots = {
|
|
557
|
-
readonly query: string | null;
|
|
558
|
-
readonly mutation: string | null;
|
|
559
|
-
readonly subscription: string | null;
|
|
560
|
-
};
|
|
561
|
-
interface ScalarDefinition<T extends {
|
|
562
|
-
name: string;
|
|
563
|
-
input: unknown;
|
|
564
|
-
output: unknown;
|
|
565
|
-
}> extends WithTypeMeta<{
|
|
566
|
-
input: T["input"];
|
|
567
|
-
inputProfile: {
|
|
568
|
-
kind: "scalar";
|
|
569
|
-
name: T["name"];
|
|
570
|
-
value: T["input"];
|
|
571
|
-
};
|
|
572
|
-
output: T["output"];
|
|
573
|
-
outputProfile: {
|
|
574
|
-
kind: "scalar";
|
|
575
|
-
name: T["name"];
|
|
576
|
-
value: T["output"];
|
|
577
|
-
};
|
|
578
|
-
}> {
|
|
579
|
-
readonly name: T["name"];
|
|
580
|
-
}
|
|
581
|
-
interface EnumDefinition<T extends {
|
|
582
|
-
name: string;
|
|
583
|
-
values: string;
|
|
584
|
-
}> extends WithTypeMeta<{
|
|
585
|
-
name: T["name"];
|
|
586
|
-
inputProfile: {
|
|
587
|
-
kind: "enum";
|
|
588
|
-
name: T["name"];
|
|
589
|
-
value: T["values"];
|
|
590
|
-
};
|
|
591
|
-
outputProfile: {
|
|
592
|
-
kind: "enum";
|
|
593
|
-
name: T["name"];
|
|
594
|
-
value: T["values"];
|
|
595
|
-
};
|
|
596
|
-
}> {
|
|
597
|
-
readonly name: T["name"];
|
|
598
|
-
readonly values: { readonly [_ in T["values"]]: true };
|
|
599
|
-
}
|
|
600
|
-
interface InputDefinition {
|
|
601
|
-
readonly name: string;
|
|
602
|
-
readonly fields: InputTypeSpecifiers;
|
|
603
|
-
}
|
|
604
|
-
type ObjectDefinition = {
|
|
605
|
-
readonly name: string;
|
|
606
|
-
readonly fields: OutputTypeSpecifiers;
|
|
607
|
-
};
|
|
608
|
-
type UnionDefinition = {
|
|
609
|
-
readonly name: string;
|
|
610
|
-
readonly types: {
|
|
611
|
-
[typename: string]: true;
|
|
612
|
-
};
|
|
613
|
-
};
|
|
614
|
-
/**
|
|
615
|
-
* Infers a TypeProfile from an input type specifier.
|
|
616
|
-
*
|
|
617
|
-
* @typeParam TSchema - The GraphQL schema
|
|
618
|
-
* @typeParam TSpecifier - The input type specifier to infer from
|
|
619
|
-
* @typeParam TDepth - Depth counter to limit recursion (default from schema overrides or schema default or 3 levels)
|
|
620
|
-
*
|
|
621
|
-
* When depth is exhausted, returns `never` to cause a type error.
|
|
622
|
-
* This prevents infinite recursion in self-referential types like `bool_exp`.
|
|
623
|
-
*/
|
|
624
|
-
type InferInputProfile<TSchema extends AnyGraphqlSchema, TSpecifier extends InputTypeSpecifier, TDepth extends DepthCounter = GetInputTypeDepth<TSchema["__inputDepthOverrides"], TSpecifier["name"], TSchema["__defaultInputDepth"]>> = { [_ in TSchema["label"]]: IsDepthExhausted<TDepth> extends true ? never : [TSpecifier extends InputScalarSpecifier ? TSchema["scalar"][TSpecifier["name"]]["$type"]["inputProfile"] : TSpecifier extends InputEnumSpecifier ? TSchema["enum"][TSpecifier["name"]]["$type"]["inputProfile"] : TSchema["input"][TSpecifier["name"]]["fields"] extends infer TFields ? {
|
|
625
|
-
kind: "input";
|
|
626
|
-
name: TSpecifier["name"];
|
|
627
|
-
fields: { [K in keyof TFields]: TFields[K] extends InputTypeSpecifier ? InferInputProfile<TSchema, TFields[K], DecrementDepth<TDepth>> : never };
|
|
628
|
-
} : never, TSpecifier["modifier"], TSpecifier["defaultValue"] extends AnyDefaultValue ? TypeProfile.WITH_DEFAULT_INPUT : undefined] }[TSchema["label"]];
|
|
629
|
-
type InferOutputProfile<TSchema extends AnyGraphqlSchema, TSpecifier extends OutputInferrableTypeSpecifier> = { [_ in TSchema["label"]]: (TSpecifier extends OutputScalarSpecifier ? TSchema["scalar"][TSpecifier["name"]] : TSchema["enum"][TSpecifier["name"]])["$type"]["outputProfile"] }[TSchema["label"]];
|
|
630
|
-
type PickTypeSpecifierByFieldName<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"], TFieldName$1 extends keyof TSchema["object"][TTypeName$1]["fields"]> = TSchema["object"][TTypeName$1]["fields"][TFieldName$1];
|
|
631
|
-
type InputFieldRecord<TSchema extends AnyGraphqlSchema, TSpecifier extends InputTypeSpecifier> = TSchema["input"][TSpecifier["name"]]["fields"];
|
|
632
|
-
type ObjectFieldRecord<TSchema extends AnyGraphqlSchema, TTypeName$1 extends keyof TSchema["object"]> = { readonly [TFieldName in keyof TSchema["object"][TTypeName$1]["fields"]]: TSchema["object"][TTypeName$1]["fields"][TFieldName] };
|
|
633
|
-
type UnionTypeRecord<TSchema extends AnyGraphqlSchema, TSpecifier extends OutputUnionSpecifier> = { readonly [TTypeName in UnionMemberName<TSchema, TSpecifier>]: TSchema["object"][TTypeName] };
|
|
634
|
-
type UnionMemberName<TSchema extends AnyGraphqlSchema, TSpecifier extends OutputUnionSpecifier> = Extract<keyof TSchema["object"], keyof TSchema["union"][TSpecifier["name"]]["types"]> & string;
|
|
635
|
-
/**
|
|
636
|
-
* Union of all input type names in a schema (scalars, enums, and input objects).
|
|
637
|
-
*/
|
|
638
|
-
type AllInputTypeNames<TSchema extends AnyGraphqlSchema> = (keyof TSchema["scalar"] & string) | (keyof TSchema["enum"] & string) | (keyof TSchema["input"] & string);
|
|
639
|
-
/**
|
|
640
|
-
* Infers the input type kind from a type name.
|
|
641
|
-
*/
|
|
642
|
-
type InferInputKind<TSchema extends AnyGraphqlSchema, TName extends AllInputTypeNames<TSchema>> = TName extends keyof TSchema["scalar"] ? "scalar" : TName extends keyof TSchema["enum"] ? "enum" : TName extends keyof TSchema["input"] ? "input" : never;
|
|
643
|
-
/**
|
|
644
|
-
* Resolves a TypeProfile from VarRefMetaV2 parameters (typeName + kind).
|
|
645
|
-
* This is used by schema-aware functions like getValueAt to resolve type structure
|
|
646
|
-
* from the schema at call site, rather than storing full profile in VarRef.
|
|
647
|
-
*
|
|
648
|
-
* @typeParam TSchema - The GraphQL schema
|
|
649
|
-
* @typeParam TTypeName - The GraphQL type name (e.g., "String", "UserInput")
|
|
650
|
-
* @typeParam TKind - The type kind ("scalar" | "enum" | "input")
|
|
651
|
-
* @typeParam TModifier - The type modifier (e.g., "!", "?", "![]!")
|
|
652
|
-
*/
|
|
653
|
-
type ResolveInputProfileFromMeta<TSchema extends AnyGraphqlSchema, TTypeName$1 extends string, TKind extends "scalar" | "enum" | "input", TModifier extends TypeModifier> = TKind extends "scalar" ? InferInputProfile<TSchema, {
|
|
654
|
-
kind: "scalar";
|
|
655
|
-
name: TTypeName$1;
|
|
656
|
-
modifier: TModifier;
|
|
657
|
-
defaultValue: null;
|
|
658
|
-
directives: {};
|
|
659
|
-
}> : TKind extends "enum" ? InferInputProfile<TSchema, {
|
|
660
|
-
kind: "enum";
|
|
661
|
-
name: TTypeName$1;
|
|
662
|
-
modifier: TModifier;
|
|
663
|
-
defaultValue: null;
|
|
664
|
-
directives: {};
|
|
665
|
-
}> : InferInputProfile<TSchema, {
|
|
666
|
-
kind: "input";
|
|
667
|
-
name: TTypeName$1;
|
|
668
|
-
modifier: TModifier;
|
|
669
|
-
defaultValue: null;
|
|
670
|
-
directives: {};
|
|
671
|
-
}>;
|
|
672
|
-
//#endregion
|
|
673
|
-
export { NestedValueElement as $, InputDepthOverrides as A, appendToPath as At, FragmentMetaInfo as B, ObjectTypeProfile as C, GetSignature as Ct, DefaultDepth as D, ConstValues as Dt, DecrementDepth as E, ConstValue as Et, AnyMetadataAdapter as F, FragmentMetadataBuilder as G, createDefaultAdapter as H, DefaultAdapter as I, MetadataBuilderTools as J, FragmentMetadataBuilderTools as K, DefaultMetadataAdapter as L, NumberToDepth as M, isListType as Mt, Adapter as N, withFieldPath as Nt, DepthCounter as O, FieldPath as Ot, AnyAdapter as P, NestedValue as Q, ExtractAdapterTypes as R, GetModifiedType as S, ApplyTypeModifier as St, TypeProfile as T, ValidTypeModifier as Tt, defaultMetadataAdapter as U, MetadataAdapter as V, ExtractMetadata as W, AnyVarRef as X, OperationMetadata as Y, AnyVarRefBrand as Z, ScalarDefinition as _, OutputTypeKind as _t, EnumDefinition as a, AnyTypeSpecifier as at, UnionTypeRecord as b, OutputTypenameSpecifier as bt, InferOutputProfile as c, InputInputObjectSpecifier as ct, ObjectDefinition as d, InputTypeSpecifier as dt, VarRef as et, ObjectFieldRecord as f, InputTypeSpecifiers as ft, ResolveInputProfileFromMeta as g, OutputScalarSpecifier as gt, PickTypeSpecifierByFieldName as h, OutputObjectSpecifier as ht, AnyTypeName as i, AnyDefaultValue as it, IsDepthExhausted as j, getCurrentFieldPath as jt, GetInputTypeDepth as k, FieldPathSegment as kt, InputDefinition as l, InputScalarSpecifier as lt, OperationType as m, OutputInferrableTypeSpecifier as mt, AnyFieldName as n, createVarRefFromNestedValue as nt, InferInputKind as o, InputEnumSpecifier as ot, OperationRoots as p, OutputEnumSpecifier as pt, MetadataBuilder as q, AnyGraphqlSchema as r, createVarRefFromVariable as rt, InferInputProfile as s, InputInferrableTypeSpecifier as st, AllInputTypeNames as t, VarRefInner as tt, InputFieldRecord as u, InputTypeKind as ut, UnionDefinition as v, OutputTypeSpecifier as vt, PrimitiveTypeProfile as w, TypeModifier as wt, GetConstAssignableType as x, OutputUnionSpecifier as xt, UnionMemberName as y, OutputTypeSpecifiers as yt, ExtractUnifiedAdapterTypes as z };
|
|
674
|
-
//# sourceMappingURL=schema-CPTxQbTv.d.cts.map
|
|
744
|
+
export { InputInferrableTypeSpecifier as $, InputDefinition as A, ConstValue as At, UnionMemberName as B, AnyFieldName as C, DecrementDepth as Ct, InferInputKind as D, InputDepthOverrides as Dt, EnumDefinition as E, GetInputTypeDepth as Et, OperationType as F, getCurrentFieldPath as Ft, NestedValueElement as G, AnyVarRef as H, PickTypeSpecifierByFieldName as I, isListType as It, createVarRefFromNestedValue as J, VarRef as K, ResolveInputProfileFromMeta as L, withFieldPath as Lt, ObjectDefinition as M, FieldPath as Mt, ObjectFieldRecord as N, FieldPathSegment as Nt, InferInputProfile as O, IsDepthExhausted as Ot, OperationRoots as P, appendToPath as Pt, InputEnumSpecifier as Q, ScalarDefinition as R, AllInputTypeNames as S, ValidTypeModifier as St, AnyTypeName as T, DepthCounter as Tt, AnyVarRefBrand as U, UnionTypeRecord as V, NestedValue as W, AnyDefaultValue as X, createVarRefFromVariable as Y, AnyTypeSpecifier as Z, FragmentMetadataBuilder as _, PrimitiveTypeProfile as _t, DefaultMetadataAdapter as a, OutputEnumSpecifier as at, MetadataBuilderTools as b, GetSignature as bt, ExtractAdapterTypes as c, OutputScalarSpecifier as ct, MetadataAdapter as d, OutputTypeSpecifiers as dt, InputInputObjectSpecifier as et, OperationDocumentTransformArgs as f, OutputTypenameSpecifier as ft, ExtractMetadata as g, ObjectTypeProfile as gt, defaultMetadataAdapter as h, GetModifiedType as ht, DefaultAdapter as i, InputTypeSpecifiers as it, InputFieldRecord as j, ConstValues as jt, InferOutputProfile as k, NumberToDepth as kt, ExtractUnifiedAdapterTypes as l, OutputTypeKind as lt, createDefaultAdapter as m, GetConstAssignableType as mt, AnyAdapter as n, InputTypeKind as nt, DocumentTransformArgs as o, OutputInferrableTypeSpecifier as ot, OperationDocumentTransformer as p, OutputUnionSpecifier as pt, VarRefInner as q, AnyMetadataAdapter as r, InputTypeSpecifier as rt, DocumentTransformer as s, OutputObjectSpecifier as st, Adapter as t, InputScalarSpecifier as tt, FragmentMetaInfo as u, OutputTypeSpecifier as ut, FragmentMetadataBuilderTools as v, TypeProfile as vt, AnyGraphqlSchema as w, DefaultDepth as wt, OperationMetadata as x, TypeModifier as xt, MetadataBuilder as y, ApplyTypeModifier as yt, UnionDefinition as z };
|
|
745
|
+
//# sourceMappingURL=index-zCOsREx0.d.cts.map
|