@fern-api/fdr-sdk 1.2.33-9d7e001fd0 → 1.2.33-e73a4c8a93
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 +170 -54
- package/dist/js/api-definition/index.js.map +1 -1
- package/dist/js/api-definition/index.mjs +169 -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 +17 -9
- package/dist/js/client/FdrClient.js.map +1 -1
- package/dist/js/client/FdrClient.mjs +17 -9
- package/dist/js/client/FdrClient.mjs.map +1 -1
- package/dist/js/client/types.js +22 -9
- package/dist/js/client/types.js.map +1 -1
- package/dist/js/client/types.mjs +22 -9
- package/dist/js/client/types.mjs.map +1 -1
- package/dist/js/converters/index.js +276 -71
- package/dist/js/converters/index.js.map +1 -1
- package/dist/js/converters/index.mjs +276 -71
- package/dist/js/converters/index.mjs.map +1 -1
- package/dist/js/index.js +276 -71
- package/dist/js/index.js.map +1 -1
- package/dist/js/index.mjs +276 -71
- package/dist/js/index.mjs.map +1 -1
- package/dist/js/navigation/index.js +273 -70
- package/dist/js/navigation/index.js.map +1 -1
- package/dist/js/navigation/index.mjs +273 -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 +20 -9
- package/dist/js/orpc-client.js.map +1 -1
- package/dist/js/orpc-client.mjs +19 -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 +17 -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/__test__/subtitle-round-trip.test.d.ts +2 -0
- package/dist/types/converters/__test__/subtitle-round-trip.test.d.ts.map +1 -0
- package/dist/types/converters/db/convertAPIDefinitionToDb.d.ts.map +1 -1
- package/dist/types/converters/read/convertDbAPIDefinitionToRead.d.ts +48 -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 +3 -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 +1880 -216
- package/dist/types/orpc-client/api/contract-db.d.ts.map +1 -1
- package/dist/types/orpc-client/api/contract-latest.d.ts +37 -10
- package/dist/types/orpc-client/api/contract-latest.d.ts.map +1 -1
- package/dist/types/orpc-client/api/contract-read.d.ts +1727 -216
- package/dist/types/orpc-client/api/contract-read.d.ts.map +1 -1
- package/dist/types/orpc-client/api/contract-register.d.ts +1905 -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 +3 -3
|
@@ -832,6 +832,7 @@ var GraphQlOperationIdSchema = z2.string();
|
|
|
832
832
|
function GraphQlOperationId(value) {
|
|
833
833
|
return value;
|
|
834
834
|
}
|
|
835
|
+
var GraphQlTypeCategorySchema = z2.enum(["object", "input", "enum", "scalar", "interface", "union"]);
|
|
835
836
|
var EnvironmentIdSchema = z2.string();
|
|
836
837
|
function EnvironmentId(value) {
|
|
837
838
|
return value;
|
|
@@ -1066,12 +1067,20 @@ var TypeReferenceSchema = z2.lazy(
|
|
|
1066
1067
|
})
|
|
1067
1068
|
])
|
|
1068
1069
|
);
|
|
1070
|
+
var GraphQlArgumentSchema = z2.object({
|
|
1071
|
+
description: z2.string().nullish(),
|
|
1072
|
+
availability: AvailabilitySchema.nullish(),
|
|
1073
|
+
name: z2.string(),
|
|
1074
|
+
type: TypeReferenceSchema,
|
|
1075
|
+
defaultValue: z2.unknown().nullish()
|
|
1076
|
+
});
|
|
1069
1077
|
var ObjectPropertySchema = z2.object({
|
|
1070
1078
|
description: z2.string().nullish(),
|
|
1071
1079
|
availability: AvailabilitySchema.nullish(),
|
|
1072
1080
|
key: PropertyKeySchema,
|
|
1073
1081
|
valueType: TypeReferenceSchema,
|
|
1074
|
-
propertyAccess: ObjectPropertyAccessSchema.nullish()
|
|
1082
|
+
propertyAccess: ObjectPropertyAccessSchema.nullish(),
|
|
1083
|
+
arguments: z2.array(GraphQlArgumentSchema).nullish()
|
|
1075
1084
|
});
|
|
1076
1085
|
var ObjectTypeSchema = z2.object({
|
|
1077
1086
|
extends: z2.array(TypeIdSchema),
|
|
@@ -1219,13 +1228,6 @@ var ErrorExampleSchema = z2.object({
|
|
|
1219
1228
|
responseBody: ExampleErrorResponseSchema
|
|
1220
1229
|
});
|
|
1221
1230
|
var GraphQlOperationTypeSchema = z2.enum(["QUERY", "MUTATION", "SUBSCRIPTION"]);
|
|
1222
|
-
var GraphQlArgumentSchema = z2.object({
|
|
1223
|
-
description: z2.string().nullish(),
|
|
1224
|
-
availability: AvailabilitySchema.nullish(),
|
|
1225
|
-
name: z2.string(),
|
|
1226
|
-
type: TypeReferenceSchema,
|
|
1227
|
-
defaultValue: z2.unknown().nullish()
|
|
1228
|
-
});
|
|
1229
1231
|
var GraphQlExampleSchema = z2.object({
|
|
1230
1232
|
description: z2.string().nullish(),
|
|
1231
1233
|
name: z2.string().nullish(),
|
|
@@ -1248,6 +1250,7 @@ var GraphQlOperationSchema = z2.object({
|
|
|
1248
1250
|
operationType: GraphQlOperationTypeSchema,
|
|
1249
1251
|
name: z2.string(),
|
|
1250
1252
|
displayName: z2.string().nullish(),
|
|
1253
|
+
fieldPath: z2.array(z2.string()).nullish(),
|
|
1251
1254
|
arguments: z2.array(GraphQlArgumentSchema).nullish(),
|
|
1252
1255
|
returnType: TypeReferenceSchema,
|
|
1253
1256
|
examples: z2.array(GraphQlExampleSchema).nullish(),
|
|
@@ -1479,6 +1482,7 @@ var RegisterErrorDeclarationV2Schema = z3.object({
|
|
|
1479
1482
|
});
|
|
1480
1483
|
var RegisterEndpointDefinitionSchema = z3.object({
|
|
1481
1484
|
description: z3.string().nullish(),
|
|
1485
|
+
subtitle: z3.string().nullish(),
|
|
1482
1486
|
availability: AvailabilitySchema.nullish(),
|
|
1483
1487
|
slug: z3.string().nullish(),
|
|
1484
1488
|
auth: z3.boolean().nullish(),
|
|
@@ -1694,7 +1698,8 @@ var LatestObjectPropertySchema = z4.lazy(
|
|
|
1694
1698
|
availability: AvailabilitySchema.nullish(),
|
|
1695
1699
|
key: PropertyKeySchema,
|
|
1696
1700
|
valueShape: LatestTypeShapeSchema,
|
|
1697
|
-
propertyAccess: LatestObjectPropertyAccessSchema.nullish()
|
|
1701
|
+
propertyAccess: LatestObjectPropertyAccessSchema.nullish(),
|
|
1702
|
+
arguments: z4.array(LatestGraphQlArgumentSchema).nullish()
|
|
1698
1703
|
})
|
|
1699
1704
|
);
|
|
1700
1705
|
var LatestParameterPropertySchema = z4.lazy(
|
|
@@ -2003,6 +2008,7 @@ var LatestExampleEndpointCallSchema = z4.object({
|
|
|
2003
2008
|
});
|
|
2004
2009
|
var LatestEndpointDefinitionSchema = z4.object({
|
|
2005
2010
|
description: z4.string().nullish(),
|
|
2011
|
+
subtitle: z4.string().nullish(),
|
|
2006
2012
|
availability: AvailabilitySchema.nullish(),
|
|
2007
2013
|
namespace: z4.array(z4.string()).nullish(),
|
|
2008
2014
|
id: EndpointIdSchema,
|
|
@@ -2045,6 +2051,7 @@ var LatestGraphQlOperationSchema = z4.object({
|
|
|
2045
2051
|
description: z4.string().nullish(),
|
|
2046
2052
|
availability: AvailabilitySchema.nullish(),
|
|
2047
2053
|
namespace: z4.array(z4.string()).nullish(),
|
|
2054
|
+
fieldPath: z4.array(z4.string()).nullish(),
|
|
2048
2055
|
id: GraphQlOperationIdSchema,
|
|
2049
2056
|
operationType: LatestGraphQlOperationTypeSchema,
|
|
2050
2057
|
name: z4.string(),
|
|
@@ -2460,6 +2467,15 @@ function collectReferencedTypeIds(type, types, { maxDepth = 10 } = {}) {
|
|
|
2460
2467
|
visitedTypeIds,
|
|
2461
2468
|
depth: depth + 1
|
|
2462
2469
|
});
|
|
2470
|
+
if (property.arguments) {
|
|
2471
|
+
for (const arg of property.arguments) {
|
|
2472
|
+
stack.push({
|
|
2473
|
+
shape: arg.type,
|
|
2474
|
+
visitedTypeIds,
|
|
2475
|
+
depth: depth + 1
|
|
2476
|
+
});
|
|
2477
|
+
}
|
|
2478
|
+
}
|
|
2463
2479
|
}
|
|
2464
2480
|
if (obj.extraProperties) {
|
|
2465
2481
|
stack.push({
|
|
@@ -2570,6 +2586,27 @@ function collectTypeDefinitionTree(type, types, { availability: rootAvailability
|
|
|
2570
2586
|
visitedTypeIds,
|
|
2571
2587
|
availability
|
|
2572
2588
|
});
|
|
2589
|
+
property.arguments?.forEach((arg) => {
|
|
2590
|
+
stack.push({
|
|
2591
|
+
type: arg.type,
|
|
2592
|
+
path: [
|
|
2593
|
+
...parentpath,
|
|
2594
|
+
{
|
|
2595
|
+
type: "objectProperty",
|
|
2596
|
+
key: property.key,
|
|
2597
|
+
optional: unwrapReference(property.valueShape, types).isOptional
|
|
2598
|
+
},
|
|
2599
|
+
{
|
|
2600
|
+
type: "graphqlArgument",
|
|
2601
|
+
name: arg.name,
|
|
2602
|
+
optional: unwrapReference(arg.type, types).isOptional
|
|
2603
|
+
}
|
|
2604
|
+
],
|
|
2605
|
+
descriptions: arg.description ? [arg.description] : [],
|
|
2606
|
+
visitedTypeIds,
|
|
2607
|
+
availability: coalesceAvailability([availability, property.availability, arg.availability])
|
|
2608
|
+
});
|
|
2609
|
+
});
|
|
2573
2610
|
});
|
|
2574
2611
|
if (obj.extraProperties) {
|
|
2575
2612
|
stack.push({
|
|
@@ -2677,7 +2714,43 @@ function collectTypeDefinitionTreeForObjectProperty(property, types, rootPath =
|
|
|
2677
2714
|
optional: unwrapReference(property.valueShape, types).isOptional
|
|
2678
2715
|
}
|
|
2679
2716
|
]
|
|
2680
|
-
})
|
|
2717
|
+
}),
|
|
2718
|
+
...(property.arguments ?? []).flatMap((arg) => [
|
|
2719
|
+
{
|
|
2720
|
+
path: [
|
|
2721
|
+
...rootPath,
|
|
2722
|
+
{
|
|
2723
|
+
type: "objectProperty",
|
|
2724
|
+
key: property.key,
|
|
2725
|
+
optional: unwrapReference(property.valueShape, types).isOptional
|
|
2726
|
+
},
|
|
2727
|
+
{
|
|
2728
|
+
type: "graphqlArgument",
|
|
2729
|
+
name: arg.name,
|
|
2730
|
+
optional: unwrapReference(arg.type, types).isOptional
|
|
2731
|
+
}
|
|
2732
|
+
],
|
|
2733
|
+
descriptions: arg.description ? [arg.description] : [],
|
|
2734
|
+
availability: coalesceAvailability([property.availability, arg.availability])
|
|
2735
|
+
},
|
|
2736
|
+
...collectTypeDefinitionTree(arg.type, types, {
|
|
2737
|
+
maxDepth: maxDepth - 1,
|
|
2738
|
+
availability: coalesceAvailability([property.availability, arg.availability]),
|
|
2739
|
+
path: [
|
|
2740
|
+
...rootPath,
|
|
2741
|
+
{
|
|
2742
|
+
type: "objectProperty",
|
|
2743
|
+
key: property.key,
|
|
2744
|
+
optional: unwrapReference(property.valueShape, types).isOptional
|
|
2745
|
+
},
|
|
2746
|
+
{
|
|
2747
|
+
type: "graphqlArgument",
|
|
2748
|
+
name: arg.name,
|
|
2749
|
+
optional: unwrapReference(arg.type, types).isOptional
|
|
2750
|
+
}
|
|
2751
|
+
]
|
|
2752
|
+
})
|
|
2753
|
+
])
|
|
2681
2754
|
];
|
|
2682
2755
|
}
|
|
2683
2756
|
|
|
@@ -2796,6 +2869,9 @@ var ApiTypeIdVisitor = class _ApiTypeIdVisitor {
|
|
|
2796
2869
|
typeShape.extends.forEach(visit);
|
|
2797
2870
|
typeShape.properties.forEach((property) => {
|
|
2798
2871
|
_ApiTypeIdVisitor.visitTypeShape(property.valueShape, visit);
|
|
2872
|
+
property.arguments?.forEach((arg) => {
|
|
2873
|
+
_ApiTypeIdVisitor.visitTypeShape(arg.type, visit);
|
|
2874
|
+
});
|
|
2799
2875
|
});
|
|
2800
2876
|
}
|
|
2801
2877
|
static visitTypeReference(typeReference, visit) {
|
|
@@ -2876,10 +2952,13 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
|
|
|
2876
2952
|
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
2877
2953
|
}
|
|
2878
2954
|
} else if (node.type === "graphql") {
|
|
2879
|
-
const
|
|
2880
|
-
|
|
2881
|
-
|
|
2882
|
-
found
|
|
2955
|
+
const idsToInclude = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
2956
|
+
for (const opId of idsToInclude) {
|
|
2957
|
+
const found = this.api.graphqlOperations[opId];
|
|
2958
|
+
if (found) {
|
|
2959
|
+
toRet.graphqlOperations[opId] = found;
|
|
2960
|
+
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
2961
|
+
}
|
|
2883
2962
|
}
|
|
2884
2963
|
}
|
|
2885
2964
|
}
|
|
@@ -3181,9 +3260,21 @@ function createGraphqlContext(node, apiDefinition) {
|
|
|
3181
3260
|
);
|
|
3182
3261
|
return void 0;
|
|
3183
3262
|
}
|
|
3263
|
+
const allIds = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
3264
|
+
const operations = [];
|
|
3265
|
+
for (const id of allIds) {
|
|
3266
|
+
const op = api.graphqlOperations[id];
|
|
3267
|
+
if (op) {
|
|
3268
|
+
operations.push(op);
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3271
|
+
if (operations.length === 0) {
|
|
3272
|
+
operations.push(operation);
|
|
3273
|
+
}
|
|
3184
3274
|
return {
|
|
3185
3275
|
node,
|
|
3186
3276
|
operation,
|
|
3277
|
+
operations,
|
|
3187
3278
|
types: api.types
|
|
3188
3279
|
};
|
|
3189
3280
|
}
|
|
@@ -4111,6 +4202,7 @@ var ApiDefinitionV1ToLatest = class _ApiDefinitionV1ToLatest {
|
|
|
4111
4202
|
displayName: v1?.name,
|
|
4112
4203
|
operationId: v1?.urlSlug?.split("/")?.pop(),
|
|
4113
4204
|
description: v1?.description,
|
|
4205
|
+
subtitle: v1?.subtitle,
|
|
4114
4206
|
availability: v1?.availability,
|
|
4115
4207
|
method: v1?.method,
|
|
4116
4208
|
path: v1?.path?.parts?.filter((part) => part?.value !== "") ?? [],
|
|
@@ -4352,7 +4444,8 @@ var ApiDefinitionV1ToLatest = class _ApiDefinitionV1ToLatest {
|
|
|
4352
4444
|
},
|
|
4353
4445
|
propertyAccess: value?.propertyAccess ?? void 0,
|
|
4354
4446
|
description: value?.description ?? void 0,
|
|
4355
|
-
availability: value?.availability ?? void 0
|
|
4447
|
+
availability: value?.availability ?? void 0,
|
|
4448
|
+
arguments: value?.arguments?.map((arg) => this.migrateGraphQlArgument(arg))
|
|
4356
4449
|
}));
|
|
4357
4450
|
},
|
|
4358
4451
|
[],
|
|
@@ -4793,6 +4886,7 @@ var ApiDefinitionV1ToLatest = class _ApiDefinitionV1ToLatest {
|
|
|
4793
4886
|
description: v1?.description,
|
|
4794
4887
|
availability: v1?.availability,
|
|
4795
4888
|
namespace,
|
|
4889
|
+
fieldPath: v1?.fieldPath,
|
|
4796
4890
|
arguments: v1?.arguments?.map((arg) => this.migrateGraphQlArgument(arg)),
|
|
4797
4891
|
returnType: {
|
|
4798
4892
|
type: "alias",
|
|
@@ -5089,7 +5183,10 @@ function generateGraphQlSnippet(context) {
|
|
|
5089
5183
|
return `$${arg.name}: ${graphqlType}`;
|
|
5090
5184
|
});
|
|
5091
5185
|
const argumentUsage = args.map((arg) => `${arg.name}: $${arg.name}`);
|
|
5092
|
-
const
|
|
5186
|
+
const fieldPath = operation.fieldPath;
|
|
5187
|
+
const hasFieldPath = fieldPath != null && fieldPath.length > 0;
|
|
5188
|
+
const selectionSetIndent = hasFieldPath ? 2 + fieldPath.length : 2;
|
|
5189
|
+
const selectionSet = generateSelectionSet(operation.returnType, types, 2, /* @__PURE__ */ new Set(), selectionSetIndent);
|
|
5093
5190
|
let query = operationKeyword;
|
|
5094
5191
|
if (operationName || variableDefinitions.length > 0) {
|
|
5095
5192
|
query += ` ${operationName}`;
|
|
@@ -5098,15 +5195,32 @@ function generateGraphQlSnippet(context) {
|
|
|
5098
5195
|
}
|
|
5099
5196
|
}
|
|
5100
5197
|
query += " {\n";
|
|
5101
|
-
|
|
5198
|
+
const baseIndent = 2;
|
|
5199
|
+
if (hasFieldPath) {
|
|
5200
|
+
for (let i = 0; i < fieldPath.length; i++) {
|
|
5201
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
5202
|
+
query += `${indent}${fieldPath[i]} {
|
|
5203
|
+
`;
|
|
5204
|
+
}
|
|
5205
|
+
}
|
|
5206
|
+
const operationIndent = hasFieldPath ? " ".repeat(baseIndent + fieldPath.length * 2) : " ";
|
|
5207
|
+
query += `${operationIndent}${operation.name}`;
|
|
5102
5208
|
if (argumentUsage.length > 0) {
|
|
5103
5209
|
query += `(${argumentUsage.join(", ")})`;
|
|
5104
5210
|
}
|
|
5105
5211
|
if (selectionSet) {
|
|
5106
5212
|
query += ` ${selectionSet}`;
|
|
5107
5213
|
}
|
|
5108
|
-
query += "\n
|
|
5109
|
-
|
|
5214
|
+
query += "\n";
|
|
5215
|
+
if (hasFieldPath) {
|
|
5216
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
5217
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
5218
|
+
query += `${indent}}
|
|
5219
|
+
`;
|
|
5220
|
+
}
|
|
5221
|
+
}
|
|
5222
|
+
query += "}";
|
|
5223
|
+
const response = generateResponseExample(operation.name, operation.returnType, types, fieldPath);
|
|
5110
5224
|
const result = { query, variables, response };
|
|
5111
5225
|
snippetCache.set(operation, result);
|
|
5112
5226
|
return result;
|
|
@@ -5135,49 +5249,44 @@ function getExampleOperationName(operationType) {
|
|
|
5135
5249
|
return "ExampleQuery";
|
|
5136
5250
|
}
|
|
5137
5251
|
}
|
|
5138
|
-
function typeShapeToGraphQlType(shape, types) {
|
|
5252
|
+
function typeShapeToGraphQlType(shape, types, nonNull = true) {
|
|
5139
5253
|
if (shape.type === "alias") {
|
|
5140
|
-
return typeReferenceToGraphQlType(shape.value, types);
|
|
5141
|
-
}
|
|
5142
|
-
if (shape.type === "enum") {
|
|
5143
|
-
return "String";
|
|
5254
|
+
return typeReferenceToGraphQlType(shape.value, types, nonNull);
|
|
5144
5255
|
}
|
|
5145
|
-
|
|
5146
|
-
|
|
5147
|
-
}
|
|
5148
|
-
if (shape.type === "undiscriminatedUnion" || shape.type === "discriminatedUnion") {
|
|
5149
|
-
return "Object";
|
|
5150
|
-
}
|
|
5151
|
-
return "String";
|
|
5256
|
+
const base = shape.type === "enum" ? "String" : shape.type === "object" || shape.type === "undiscriminatedUnion" || shape.type === "discriminatedUnion" ? "Object" : "String";
|
|
5257
|
+
return nonNull ? `${base}!` : base;
|
|
5152
5258
|
}
|
|
5153
|
-
function typeReferenceToGraphQlType(ref, types) {
|
|
5259
|
+
function typeReferenceToGraphQlType(ref, types, nonNull = true) {
|
|
5154
5260
|
switch (ref.type) {
|
|
5155
|
-
case "primitive":
|
|
5156
|
-
|
|
5261
|
+
case "primitive": {
|
|
5262
|
+
const base = primitiveToGraphQlType(ref.value);
|
|
5263
|
+
return nonNull ? `${base}!` : base;
|
|
5264
|
+
}
|
|
5157
5265
|
case "id": {
|
|
5158
5266
|
const typeDef = types[ref.id];
|
|
5159
|
-
|
|
5160
|
-
|
|
5161
|
-
}
|
|
5162
|
-
return "Object";
|
|
5267
|
+
const base = typeDef ? typeDef.displayName ?? unnamespacedName(typeDef.name) ?? "Object" : "Object";
|
|
5268
|
+
return nonNull ? `${base}!` : base;
|
|
5163
5269
|
}
|
|
5164
5270
|
case "optional":
|
|
5165
|
-
return typeShapeToGraphQlType(ref.shape, types);
|
|
5271
|
+
return typeShapeToGraphQlType(ref.shape, types, false);
|
|
5166
5272
|
case "nullable":
|
|
5167
|
-
return typeShapeToGraphQlType(ref.shape, types);
|
|
5168
|
-
case "list":
|
|
5169
|
-
|
|
5170
|
-
|
|
5171
|
-
|
|
5273
|
+
return typeShapeToGraphQlType(ref.shape, types, false);
|
|
5274
|
+
case "list": {
|
|
5275
|
+
const inner = typeShapeToGraphQlType(ref.itemShape, types);
|
|
5276
|
+
return nonNull ? `[${inner}]!` : `[${inner}]`;
|
|
5277
|
+
}
|
|
5278
|
+
case "set": {
|
|
5279
|
+
const inner = typeShapeToGraphQlType(ref.itemShape, types);
|
|
5280
|
+
return nonNull ? `[${inner}]!` : `[${inner}]`;
|
|
5281
|
+
}
|
|
5172
5282
|
case "map":
|
|
5173
|
-
return "Object";
|
|
5174
|
-
// Maps don't have direct GraphQL equivalent
|
|
5283
|
+
return nonNull ? "Object!" : "Object";
|
|
5175
5284
|
case "literal":
|
|
5176
|
-
return "String";
|
|
5285
|
+
return nonNull ? "String!" : "String";
|
|
5177
5286
|
case "unknown":
|
|
5178
|
-
return "Object";
|
|
5287
|
+
return nonNull ? "Object!" : "Object";
|
|
5179
5288
|
default:
|
|
5180
|
-
return "String";
|
|
5289
|
+
return nonNull ? "String!" : "String";
|
|
5181
5290
|
}
|
|
5182
5291
|
}
|
|
5183
5292
|
function unnamespacedName(name) {
|
|
@@ -5395,13 +5504,18 @@ function generateSelectionSetFromReference(ref, types, depth, visited, indentLev
|
|
|
5395
5504
|
return "";
|
|
5396
5505
|
}
|
|
5397
5506
|
}
|
|
5398
|
-
function generateResponseExample(operationName, returnType, types) {
|
|
5507
|
+
function generateResponseExample(operationName, returnType, types, fieldPath) {
|
|
5399
5508
|
const data = generateResponseData(returnType, types, 3, /* @__PURE__ */ new Set());
|
|
5400
|
-
|
|
5401
|
-
|
|
5402
|
-
|
|
5509
|
+
let responseData = { [operationName]: data };
|
|
5510
|
+
if (fieldPath != null && fieldPath.length > 0) {
|
|
5511
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
5512
|
+
const key = fieldPath[i];
|
|
5513
|
+
if (key != null) {
|
|
5514
|
+
responseData = { [key]: responseData };
|
|
5515
|
+
}
|
|
5403
5516
|
}
|
|
5404
|
-
}
|
|
5517
|
+
}
|
|
5518
|
+
return { data: responseData };
|
|
5405
5519
|
}
|
|
5406
5520
|
function generateResponseData(shape, types, depth, visited) {
|
|
5407
5521
|
if (depth <= 0) {
|
|
@@ -6361,6 +6475,7 @@ export {
|
|
|
6361
6475
|
GraphQlOperationIdSchema,
|
|
6362
6476
|
LatestGraphQlOperationSchema as GraphQlOperationSchema,
|
|
6363
6477
|
LatestGraphQlOperationTypeSchema as GraphQlOperationTypeSchema,
|
|
6478
|
+
GraphQlTypeCategorySchema,
|
|
6364
6479
|
GrpcId,
|
|
6365
6480
|
GrpcIdSchema,
|
|
6366
6481
|
GrpcMethod,
|