@fern-api/fdr-sdk 1.2.33-fc1095cfbc → 1.2.34-2195dafce8
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/dist/js/api-definition/index.js +169 -54
- package/dist/js/api-definition/index.js.map +1 -1
- package/dist/js/api-definition/index.mjs +168 -54
- package/dist/js/api-definition/index.mjs.map +1 -1
- package/dist/js/api-definition-lite/index.js.map +1 -1
- package/dist/js/client/FdrClient.js +14 -9
- package/dist/js/client/FdrClient.js.map +1 -1
- package/dist/js/client/FdrClient.mjs +14 -9
- package/dist/js/client/FdrClient.mjs.map +1 -1
- package/dist/js/client/types.js +18 -9
- package/dist/js/client/types.js.map +1 -1
- package/dist/js/client/types.mjs +18 -9
- package/dist/js/client/types.mjs.map +1 -1
- package/dist/js/converters/index.js +296 -71
- package/dist/js/converters/index.js.map +1 -1
- package/dist/js/converters/index.mjs +296 -71
- package/dist/js/converters/index.mjs.map +1 -1
- package/dist/js/index.js +296 -71
- package/dist/js/index.js.map +1 -1
- package/dist/js/index.mjs +296 -71
- package/dist/js/index.mjs.map +1 -1
- package/dist/js/navigation/index.js +295 -70
- package/dist/js/navigation/index.js.map +1 -1
- package/dist/js/navigation/index.mjs +295 -70
- package/dist/js/navigation/index.mjs.map +1 -1
- package/dist/js/navigation/ledger-root-builder.js +12 -8
- package/dist/js/navigation/ledger-root-builder.js.map +1 -1
- package/dist/js/navigation/ledger-root-builder.mjs +12 -8
- package/dist/js/navigation/ledger-root-builder.mjs.map +1 -1
- package/dist/js/navigation/types/latest.js.map +1 -1
- package/dist/js/navigation/types/latest.mjs.map +1 -1
- package/dist/js/navigation/types/v1.js.map +1 -1
- package/dist/js/navigation/types/v1.mjs.map +1 -1
- package/dist/js/orpc-client.js +16 -9
- package/dist/js/orpc-client.js.map +1 -1
- package/dist/js/orpc-client.mjs +15 -9
- package/dist/js/orpc-client.mjs.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/api-definition/__test__/collect-type-tree.test.d.ts +2 -0
- package/dist/types/api-definition/__test__/collect-type-tree.test.d.ts.map +1 -0
- package/dist/types/api-definition/collect-referenced-types.d.ts.map +1 -1
- package/dist/types/api-definition/collect-type-tree.d.ts +4 -0
- package/dist/types/api-definition/collect-type-tree.d.ts.map +1 -1
- package/dist/types/api-definition/endpoint-context.d.ts +3 -0
- package/dist/types/api-definition/endpoint-context.d.ts.map +1 -1
- package/dist/types/api-definition/migrators/v1ToV2.d.ts +16 -7
- package/dist/types/api-definition/migrators/v1ToV2.d.ts.map +1 -1
- package/dist/types/api-definition/prune.d.ts +1 -0
- package/dist/types/api-definition/prune.d.ts.map +1 -1
- package/dist/types/api-definition/snippets/graphql-snippets.d.ts.map +1 -1
- package/dist/types/api-definition/typeid-visitor.d.ts.map +1 -1
- package/dist/types/api-definition-lite/index.d.ts +1 -1
- package/dist/types/api-definition-lite/index.d.ts.map +1 -1
- package/dist/types/converters/read/convertDbAPIDefinitionToRead.d.ts +46 -14
- package/dist/types/converters/read/convertDbAPIDefinitionToRead.d.ts.map +1 -1
- package/dist/types/navigation/ApiDefinitionPruner.d.ts.map +1 -1
- package/dist/types/navigation/ApiTypeIdVisitor.d.ts.map +1 -1
- package/dist/types/navigation/ledger-root-builder.d.ts.map +1 -1
- package/dist/types/navigation/migrators/v1ToV2.d.ts.map +1 -1
- package/dist/types/navigation/types/latest.d.ts +18 -2
- package/dist/types/navigation/types/latest.d.ts.map +1 -1
- package/dist/types/navigation/types/v1.d.ts +2 -0
- package/dist/types/navigation/types/v1.d.ts.map +1 -1
- package/dist/types/navigation/utils/getApiReferenceId.d.ts.map +1 -1
- package/dist/types/navigation/utils/toApis.d.ts +2 -1
- package/dist/types/navigation/utils/toApis.d.ts.map +1 -1
- package/dist/types/navigation/versions/latest/NavigationNode.d.ts +1 -1
- package/dist/types/navigation/versions/latest/NavigationNode.d.ts.map +1 -1
- package/dist/types/navigation/versions/latest/NavigationNodeApiLeaf.d.ts +2 -2
- package/dist/types/navigation/versions/latest/NavigationNodeApiLeaf.d.ts.map +1 -1
- package/dist/types/navigation/versions/latest/__test__/GraphQlTypeNode.test.d.ts +2 -0
- package/dist/types/navigation/versions/latest/__test__/GraphQlTypeNode.test.d.ts.map +1 -0
- package/dist/types/navigation/versions/latest/getPageId.d.ts.map +1 -1
- package/dist/types/navigation/versions/v1/converters/ApiReferenceNavigationConverter.d.ts +1 -0
- package/dist/types/navigation/versions/v1/converters/ApiReferenceNavigationConverter.d.ts.map +1 -1
- package/dist/types/navigation/versions/v1/converters/__test__/ApiReferenceNavigationConverter.graphql.test.d.ts +2 -0
- package/dist/types/navigation/versions/v1/converters/__test__/ApiReferenceNavigationConverter.graphql.test.d.ts.map +1 -0
- package/dist/types/orpc-client/api/contract-db.d.ts +1848 -216
- package/dist/types/orpc-client/api/contract-db.d.ts.map +1 -1
- package/dist/types/orpc-client/api/contract-latest.d.ts +24 -10
- package/dist/types/orpc-client/api/contract-latest.d.ts.map +1 -1
- package/dist/types/orpc-client/api/contract-read.d.ts +1700 -216
- package/dist/types/orpc-client/api/contract-read.d.ts.map +1 -1
- package/dist/types/orpc-client/api/contract-register.d.ts +1878 -216
- package/dist/types/orpc-client/api/contract-register.d.ts.map +1 -1
- package/dist/types/orpc-client/api/shared.d.ts +99 -53
- package/dist/types/orpc-client/api/shared.d.ts.map +1 -1
- package/dist/types/orpc-client/files/contract.d.ts +5 -1
- package/dist/types/orpc-client/files/contract.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -96,6 +96,7 @@ __export(api_definition_exports, {
|
|
|
96
96
|
GraphQlOperationIdSchema: () => GraphQlOperationIdSchema,
|
|
97
97
|
GraphQlOperationSchema: () => LatestGraphQlOperationSchema,
|
|
98
98
|
GraphQlOperationTypeSchema: () => LatestGraphQlOperationTypeSchema,
|
|
99
|
+
GraphQlTypeCategorySchema: () => GraphQlTypeCategorySchema,
|
|
99
100
|
GrpcId: () => GrpcId,
|
|
100
101
|
GrpcIdSchema: () => GrpcIdSchema,
|
|
101
102
|
GrpcMethod: () => GrpcMethod,
|
|
@@ -1049,6 +1050,7 @@ var GraphQlOperationIdSchema = z2.string();
|
|
|
1049
1050
|
function GraphQlOperationId(value) {
|
|
1050
1051
|
return value;
|
|
1051
1052
|
}
|
|
1053
|
+
var GraphQlTypeCategorySchema = z2.enum(["object", "input", "enum", "scalar", "interface", "union"]);
|
|
1052
1054
|
var EnvironmentIdSchema = z2.string();
|
|
1053
1055
|
function EnvironmentId(value) {
|
|
1054
1056
|
return value;
|
|
@@ -1283,12 +1285,20 @@ var TypeReferenceSchema = z2.lazy(
|
|
|
1283
1285
|
})
|
|
1284
1286
|
])
|
|
1285
1287
|
);
|
|
1288
|
+
var GraphQlArgumentSchema = z2.object({
|
|
1289
|
+
description: z2.string().nullish(),
|
|
1290
|
+
availability: AvailabilitySchema.nullish(),
|
|
1291
|
+
name: z2.string(),
|
|
1292
|
+
type: TypeReferenceSchema,
|
|
1293
|
+
defaultValue: z2.unknown().nullish()
|
|
1294
|
+
});
|
|
1286
1295
|
var ObjectPropertySchema = z2.object({
|
|
1287
1296
|
description: z2.string().nullish(),
|
|
1288
1297
|
availability: AvailabilitySchema.nullish(),
|
|
1289
1298
|
key: PropertyKeySchema,
|
|
1290
1299
|
valueType: TypeReferenceSchema,
|
|
1291
|
-
propertyAccess: ObjectPropertyAccessSchema.nullish()
|
|
1300
|
+
propertyAccess: ObjectPropertyAccessSchema.nullish(),
|
|
1301
|
+
arguments: z2.array(GraphQlArgumentSchema).nullish()
|
|
1292
1302
|
});
|
|
1293
1303
|
var ObjectTypeSchema = z2.object({
|
|
1294
1304
|
extends: z2.array(TypeIdSchema),
|
|
@@ -1436,13 +1446,6 @@ var ErrorExampleSchema = z2.object({
|
|
|
1436
1446
|
responseBody: ExampleErrorResponseSchema
|
|
1437
1447
|
});
|
|
1438
1448
|
var GraphQlOperationTypeSchema = z2.enum(["QUERY", "MUTATION", "SUBSCRIPTION"]);
|
|
1439
|
-
var GraphQlArgumentSchema = z2.object({
|
|
1440
|
-
description: z2.string().nullish(),
|
|
1441
|
-
availability: AvailabilitySchema.nullish(),
|
|
1442
|
-
name: z2.string(),
|
|
1443
|
-
type: TypeReferenceSchema,
|
|
1444
|
-
defaultValue: z2.unknown().nullish()
|
|
1445
|
-
});
|
|
1446
1449
|
var GraphQlExampleSchema = z2.object({
|
|
1447
1450
|
description: z2.string().nullish(),
|
|
1448
1451
|
name: z2.string().nullish(),
|
|
@@ -1465,6 +1468,7 @@ var GraphQlOperationSchema = z2.object({
|
|
|
1465
1468
|
operationType: GraphQlOperationTypeSchema,
|
|
1466
1469
|
name: z2.string(),
|
|
1467
1470
|
displayName: z2.string().nullish(),
|
|
1471
|
+
fieldPath: z2.array(z2.string()).nullish(),
|
|
1468
1472
|
arguments: z2.array(GraphQlArgumentSchema).nullish(),
|
|
1469
1473
|
returnType: TypeReferenceSchema,
|
|
1470
1474
|
examples: z2.array(GraphQlExampleSchema).nullish(),
|
|
@@ -1912,7 +1916,8 @@ var LatestObjectPropertySchema = z4.lazy(
|
|
|
1912
1916
|
availability: AvailabilitySchema.nullish(),
|
|
1913
1917
|
key: PropertyKeySchema,
|
|
1914
1918
|
valueShape: LatestTypeShapeSchema,
|
|
1915
|
-
propertyAccess: LatestObjectPropertyAccessSchema.nullish()
|
|
1919
|
+
propertyAccess: LatestObjectPropertyAccessSchema.nullish(),
|
|
1920
|
+
arguments: z4.array(LatestGraphQlArgumentSchema).nullish()
|
|
1916
1921
|
})
|
|
1917
1922
|
);
|
|
1918
1923
|
var LatestParameterPropertySchema = z4.lazy(
|
|
@@ -2264,6 +2269,7 @@ var LatestGraphQlOperationSchema = z4.object({
|
|
|
2264
2269
|
description: z4.string().nullish(),
|
|
2265
2270
|
availability: AvailabilitySchema.nullish(),
|
|
2266
2271
|
namespace: z4.array(z4.string()).nullish(),
|
|
2272
|
+
fieldPath: z4.array(z4.string()).nullish(),
|
|
2267
2273
|
id: GraphQlOperationIdSchema,
|
|
2268
2274
|
operationType: LatestGraphQlOperationTypeSchema,
|
|
2269
2275
|
name: z4.string(),
|
|
@@ -2679,6 +2685,15 @@ function collectReferencedTypeIds(type, types, { maxDepth = 10 } = {}) {
|
|
|
2679
2685
|
visitedTypeIds,
|
|
2680
2686
|
depth: depth + 1
|
|
2681
2687
|
});
|
|
2688
|
+
if (property.arguments) {
|
|
2689
|
+
for (const arg of property.arguments) {
|
|
2690
|
+
stack.push({
|
|
2691
|
+
shape: arg.type,
|
|
2692
|
+
visitedTypeIds,
|
|
2693
|
+
depth: depth + 1
|
|
2694
|
+
});
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2682
2697
|
}
|
|
2683
2698
|
if (obj.extraProperties) {
|
|
2684
2699
|
stack.push({
|
|
@@ -2789,6 +2804,27 @@ function collectTypeDefinitionTree(type, types, { availability: rootAvailability
|
|
|
2789
2804
|
visitedTypeIds,
|
|
2790
2805
|
availability
|
|
2791
2806
|
});
|
|
2807
|
+
property.arguments?.forEach((arg) => {
|
|
2808
|
+
stack.push({
|
|
2809
|
+
type: arg.type,
|
|
2810
|
+
path: [
|
|
2811
|
+
...parentpath,
|
|
2812
|
+
{
|
|
2813
|
+
type: "objectProperty",
|
|
2814
|
+
key: property.key,
|
|
2815
|
+
optional: unwrapReference(property.valueShape, types).isOptional
|
|
2816
|
+
},
|
|
2817
|
+
{
|
|
2818
|
+
type: "graphqlArgument",
|
|
2819
|
+
name: arg.name,
|
|
2820
|
+
optional: unwrapReference(arg.type, types).isOptional
|
|
2821
|
+
}
|
|
2822
|
+
],
|
|
2823
|
+
descriptions: arg.description ? [arg.description] : [],
|
|
2824
|
+
visitedTypeIds,
|
|
2825
|
+
availability: coalesceAvailability([availability, property.availability, arg.availability])
|
|
2826
|
+
});
|
|
2827
|
+
});
|
|
2792
2828
|
});
|
|
2793
2829
|
if (obj.extraProperties) {
|
|
2794
2830
|
stack.push({
|
|
@@ -2896,7 +2932,43 @@ function collectTypeDefinitionTreeForObjectProperty(property, types, rootPath =
|
|
|
2896
2932
|
optional: unwrapReference(property.valueShape, types).isOptional
|
|
2897
2933
|
}
|
|
2898
2934
|
]
|
|
2899
|
-
})
|
|
2935
|
+
}),
|
|
2936
|
+
...(property.arguments ?? []).flatMap((arg) => [
|
|
2937
|
+
{
|
|
2938
|
+
path: [
|
|
2939
|
+
...rootPath,
|
|
2940
|
+
{
|
|
2941
|
+
type: "objectProperty",
|
|
2942
|
+
key: property.key,
|
|
2943
|
+
optional: unwrapReference(property.valueShape, types).isOptional
|
|
2944
|
+
},
|
|
2945
|
+
{
|
|
2946
|
+
type: "graphqlArgument",
|
|
2947
|
+
name: arg.name,
|
|
2948
|
+
optional: unwrapReference(arg.type, types).isOptional
|
|
2949
|
+
}
|
|
2950
|
+
],
|
|
2951
|
+
descriptions: arg.description ? [arg.description] : [],
|
|
2952
|
+
availability: coalesceAvailability([property.availability, arg.availability])
|
|
2953
|
+
},
|
|
2954
|
+
...collectTypeDefinitionTree(arg.type, types, {
|
|
2955
|
+
maxDepth: maxDepth - 1,
|
|
2956
|
+
availability: coalesceAvailability([property.availability, arg.availability]),
|
|
2957
|
+
path: [
|
|
2958
|
+
...rootPath,
|
|
2959
|
+
{
|
|
2960
|
+
type: "objectProperty",
|
|
2961
|
+
key: property.key,
|
|
2962
|
+
optional: unwrapReference(property.valueShape, types).isOptional
|
|
2963
|
+
},
|
|
2964
|
+
{
|
|
2965
|
+
type: "graphqlArgument",
|
|
2966
|
+
name: arg.name,
|
|
2967
|
+
optional: unwrapReference(arg.type, types).isOptional
|
|
2968
|
+
}
|
|
2969
|
+
]
|
|
2970
|
+
})
|
|
2971
|
+
])
|
|
2900
2972
|
];
|
|
2901
2973
|
}
|
|
2902
2974
|
|
|
@@ -3015,6 +3087,9 @@ var ApiTypeIdVisitor = class _ApiTypeIdVisitor {
|
|
|
3015
3087
|
typeShape.extends.forEach(visit);
|
|
3016
3088
|
typeShape.properties.forEach((property) => {
|
|
3017
3089
|
_ApiTypeIdVisitor.visitTypeShape(property.valueShape, visit);
|
|
3090
|
+
property.arguments?.forEach((arg) => {
|
|
3091
|
+
_ApiTypeIdVisitor.visitTypeShape(arg.type, visit);
|
|
3092
|
+
});
|
|
3018
3093
|
});
|
|
3019
3094
|
}
|
|
3020
3095
|
static visitTypeReference(typeReference, visit) {
|
|
@@ -3040,6 +3115,7 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
|
|
|
3040
3115
|
constructor(api) {
|
|
3041
3116
|
this.api = api;
|
|
3042
3117
|
}
|
|
3118
|
+
api;
|
|
3043
3119
|
static instances = /* @__PURE__ */ new WeakMap();
|
|
3044
3120
|
static from(api) {
|
|
3045
3121
|
const toRet = _ApiDefinitionPruner.instances.get(api) ?? new _ApiDefinitionPruner(api);
|
|
@@ -3095,10 +3171,13 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
|
|
|
3095
3171
|
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
3096
3172
|
}
|
|
3097
3173
|
} else if (node.type === "graphql") {
|
|
3098
|
-
const
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
found
|
|
3174
|
+
const idsToInclude = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
3175
|
+
for (const opId of idsToInclude) {
|
|
3176
|
+
const found = this.api.graphqlOperations[opId];
|
|
3177
|
+
if (found) {
|
|
3178
|
+
toRet.graphqlOperations[opId] = found;
|
|
3179
|
+
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
3180
|
+
}
|
|
3102
3181
|
}
|
|
3103
3182
|
}
|
|
3104
3183
|
}
|
|
@@ -3400,9 +3479,21 @@ function createGraphqlContext(node, apiDefinition) {
|
|
|
3400
3479
|
);
|
|
3401
3480
|
return void 0;
|
|
3402
3481
|
}
|
|
3482
|
+
const allIds = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
3483
|
+
const operations = [];
|
|
3484
|
+
for (const id of allIds) {
|
|
3485
|
+
const op = api.graphqlOperations[id];
|
|
3486
|
+
if (op) {
|
|
3487
|
+
operations.push(op);
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
if (operations.length === 0) {
|
|
3491
|
+
operations.push(operation);
|
|
3492
|
+
}
|
|
3403
3493
|
return {
|
|
3404
3494
|
node,
|
|
3405
3495
|
operation,
|
|
3496
|
+
operations,
|
|
3406
3497
|
types: api.types
|
|
3407
3498
|
};
|
|
3408
3499
|
}
|
|
@@ -4211,6 +4302,7 @@ var ApiDefinitionV1ToLatest = class _ApiDefinitionV1ToLatest {
|
|
|
4211
4302
|
this.v1 = v1;
|
|
4212
4303
|
this.auth = v1.auth ?? void 0;
|
|
4213
4304
|
}
|
|
4305
|
+
v1;
|
|
4214
4306
|
static from(v1) {
|
|
4215
4307
|
return new _ApiDefinitionV1ToLatest(v1);
|
|
4216
4308
|
}
|
|
@@ -4572,7 +4664,8 @@ var ApiDefinitionV1ToLatest = class _ApiDefinitionV1ToLatest {
|
|
|
4572
4664
|
},
|
|
4573
4665
|
propertyAccess: value?.propertyAccess ?? void 0,
|
|
4574
4666
|
description: value?.description ?? void 0,
|
|
4575
|
-
availability: value?.availability ?? void 0
|
|
4667
|
+
availability: value?.availability ?? void 0,
|
|
4668
|
+
arguments: value?.arguments?.map((arg) => this.migrateGraphQlArgument(arg))
|
|
4576
4669
|
}));
|
|
4577
4670
|
},
|
|
4578
4671
|
[],
|
|
@@ -5013,6 +5106,7 @@ var ApiDefinitionV1ToLatest = class _ApiDefinitionV1ToLatest {
|
|
|
5013
5106
|
description: v1?.description,
|
|
5014
5107
|
availability: v1?.availability,
|
|
5015
5108
|
namespace,
|
|
5109
|
+
fieldPath: v1?.fieldPath,
|
|
5016
5110
|
arguments: v1?.arguments?.map((arg) => this.migrateGraphQlArgument(arg)),
|
|
5017
5111
|
returnType: {
|
|
5018
5112
|
type: "alias",
|
|
@@ -5309,7 +5403,10 @@ function generateGraphQlSnippet(context) {
|
|
|
5309
5403
|
return `$${arg.name}: ${graphqlType}`;
|
|
5310
5404
|
});
|
|
5311
5405
|
const argumentUsage = args.map((arg) => `${arg.name}: $${arg.name}`);
|
|
5312
|
-
const
|
|
5406
|
+
const fieldPath = operation.fieldPath;
|
|
5407
|
+
const hasFieldPath = fieldPath != null && fieldPath.length > 0;
|
|
5408
|
+
const selectionSetIndent = hasFieldPath ? 2 + fieldPath.length : 2;
|
|
5409
|
+
const selectionSet = generateSelectionSet(operation.returnType, types, 2, /* @__PURE__ */ new Set(), selectionSetIndent);
|
|
5313
5410
|
let query = operationKeyword;
|
|
5314
5411
|
if (operationName || variableDefinitions.length > 0) {
|
|
5315
5412
|
query += ` ${operationName}`;
|
|
@@ -5318,15 +5415,32 @@ function generateGraphQlSnippet(context) {
|
|
|
5318
5415
|
}
|
|
5319
5416
|
}
|
|
5320
5417
|
query += " {\n";
|
|
5321
|
-
|
|
5418
|
+
const baseIndent = 2;
|
|
5419
|
+
if (hasFieldPath) {
|
|
5420
|
+
for (let i = 0; i < fieldPath.length; i++) {
|
|
5421
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
5422
|
+
query += `${indent}${fieldPath[i]} {
|
|
5423
|
+
`;
|
|
5424
|
+
}
|
|
5425
|
+
}
|
|
5426
|
+
const operationIndent = hasFieldPath ? " ".repeat(baseIndent + fieldPath.length * 2) : " ";
|
|
5427
|
+
query += `${operationIndent}${operation.name}`;
|
|
5322
5428
|
if (argumentUsage.length > 0) {
|
|
5323
5429
|
query += `(${argumentUsage.join(", ")})`;
|
|
5324
5430
|
}
|
|
5325
5431
|
if (selectionSet) {
|
|
5326
5432
|
query += ` ${selectionSet}`;
|
|
5327
5433
|
}
|
|
5328
|
-
query += "\n
|
|
5329
|
-
|
|
5434
|
+
query += "\n";
|
|
5435
|
+
if (hasFieldPath) {
|
|
5436
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
5437
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
5438
|
+
query += `${indent}}
|
|
5439
|
+
`;
|
|
5440
|
+
}
|
|
5441
|
+
}
|
|
5442
|
+
query += "}";
|
|
5443
|
+
const response = generateResponseExample(operation.name, operation.returnType, types, fieldPath);
|
|
5330
5444
|
const result = { query, variables, response };
|
|
5331
5445
|
snippetCache.set(operation, result);
|
|
5332
5446
|
return result;
|
|
@@ -5355,49 +5469,44 @@ function getExampleOperationName(operationType) {
|
|
|
5355
5469
|
return "ExampleQuery";
|
|
5356
5470
|
}
|
|
5357
5471
|
}
|
|
5358
|
-
function typeShapeToGraphQlType(shape, types) {
|
|
5472
|
+
function typeShapeToGraphQlType(shape, types, nonNull = true) {
|
|
5359
5473
|
if (shape.type === "alias") {
|
|
5360
|
-
return typeReferenceToGraphQlType(shape.value, types);
|
|
5361
|
-
}
|
|
5362
|
-
if (shape.type === "enum") {
|
|
5363
|
-
return "String";
|
|
5474
|
+
return typeReferenceToGraphQlType(shape.value, types, nonNull);
|
|
5364
5475
|
}
|
|
5365
|
-
|
|
5366
|
-
|
|
5367
|
-
}
|
|
5368
|
-
if (shape.type === "undiscriminatedUnion" || shape.type === "discriminatedUnion") {
|
|
5369
|
-
return "Object";
|
|
5370
|
-
}
|
|
5371
|
-
return "String";
|
|
5476
|
+
const base = shape.type === "enum" ? "String" : shape.type === "object" || shape.type === "undiscriminatedUnion" || shape.type === "discriminatedUnion" ? "Object" : "String";
|
|
5477
|
+
return nonNull ? `${base}!` : base;
|
|
5372
5478
|
}
|
|
5373
|
-
function typeReferenceToGraphQlType(ref, types) {
|
|
5479
|
+
function typeReferenceToGraphQlType(ref, types, nonNull = true) {
|
|
5374
5480
|
switch (ref.type) {
|
|
5375
|
-
case "primitive":
|
|
5376
|
-
|
|
5481
|
+
case "primitive": {
|
|
5482
|
+
const base = primitiveToGraphQlType(ref.value);
|
|
5483
|
+
return nonNull ? `${base}!` : base;
|
|
5484
|
+
}
|
|
5377
5485
|
case "id": {
|
|
5378
5486
|
const typeDef = types[ref.id];
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
}
|
|
5382
|
-
return "Object";
|
|
5487
|
+
const base = typeDef ? typeDef.displayName ?? unnamespacedName(typeDef.name) ?? "Object" : "Object";
|
|
5488
|
+
return nonNull ? `${base}!` : base;
|
|
5383
5489
|
}
|
|
5384
5490
|
case "optional":
|
|
5385
|
-
return typeShapeToGraphQlType(ref.shape, types);
|
|
5491
|
+
return typeShapeToGraphQlType(ref.shape, types, false);
|
|
5386
5492
|
case "nullable":
|
|
5387
|
-
return typeShapeToGraphQlType(ref.shape, types);
|
|
5388
|
-
case "list":
|
|
5389
|
-
|
|
5390
|
-
|
|
5391
|
-
|
|
5493
|
+
return typeShapeToGraphQlType(ref.shape, types, false);
|
|
5494
|
+
case "list": {
|
|
5495
|
+
const inner = typeShapeToGraphQlType(ref.itemShape, types);
|
|
5496
|
+
return nonNull ? `[${inner}]!` : `[${inner}]`;
|
|
5497
|
+
}
|
|
5498
|
+
case "set": {
|
|
5499
|
+
const inner = typeShapeToGraphQlType(ref.itemShape, types);
|
|
5500
|
+
return nonNull ? `[${inner}]!` : `[${inner}]`;
|
|
5501
|
+
}
|
|
5392
5502
|
case "map":
|
|
5393
|
-
return "Object";
|
|
5394
|
-
// Maps don't have direct GraphQL equivalent
|
|
5503
|
+
return nonNull ? "Object!" : "Object";
|
|
5395
5504
|
case "literal":
|
|
5396
|
-
return "String";
|
|
5505
|
+
return nonNull ? "String!" : "String";
|
|
5397
5506
|
case "unknown":
|
|
5398
|
-
return "Object";
|
|
5507
|
+
return nonNull ? "Object!" : "Object";
|
|
5399
5508
|
default:
|
|
5400
|
-
return "String";
|
|
5509
|
+
return nonNull ? "String!" : "String";
|
|
5401
5510
|
}
|
|
5402
5511
|
}
|
|
5403
5512
|
function unnamespacedName(name) {
|
|
@@ -5615,13 +5724,18 @@ function generateSelectionSetFromReference(ref, types, depth, visited, indentLev
|
|
|
5615
5724
|
return "";
|
|
5616
5725
|
}
|
|
5617
5726
|
}
|
|
5618
|
-
function generateResponseExample(operationName, returnType, types) {
|
|
5727
|
+
function generateResponseExample(operationName, returnType, types, fieldPath) {
|
|
5619
5728
|
const data = generateResponseData(returnType, types, 3, /* @__PURE__ */ new Set());
|
|
5620
|
-
|
|
5621
|
-
|
|
5622
|
-
|
|
5729
|
+
let responseData = { [operationName]: data };
|
|
5730
|
+
if (fieldPath != null && fieldPath.length > 0) {
|
|
5731
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
5732
|
+
const key = fieldPath[i];
|
|
5733
|
+
if (key != null) {
|
|
5734
|
+
responseData = { [key]: responseData };
|
|
5735
|
+
}
|
|
5623
5736
|
}
|
|
5624
|
-
}
|
|
5737
|
+
}
|
|
5738
|
+
return { data: responseData };
|
|
5625
5739
|
}
|
|
5626
5740
|
function generateResponseData(shape, types, depth, visited) {
|
|
5627
5741
|
if (depth <= 0) {
|
|
@@ -6582,6 +6696,7 @@ var Transformer = class _Transformer {
|
|
|
6582
6696
|
GraphQlOperationIdSchema,
|
|
6583
6697
|
GraphQlOperationSchema,
|
|
6584
6698
|
GraphQlOperationTypeSchema,
|
|
6699
|
+
GraphQlTypeCategorySchema,
|
|
6585
6700
|
GrpcId,
|
|
6586
6701
|
GrpcIdSchema,
|
|
6587
6702
|
GrpcMethod,
|