@fern-api/fdr-sdk 1.2.104-0f39130935 → 1.2.105-a08ab1884d
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 +251 -34
- package/dist/js/api-definition/index.js.map +1 -1
- package/dist/js/api-definition/index.mjs +244 -33
- package/dist/js/api-definition/index.mjs.map +1 -1
- package/dist/js/api-definition-lite/index.js +10 -10
- package/dist/js/api-definition-lite/index.js.map +1 -1
- package/dist/js/api-definition-lite/index.mjs +10 -10
- package/dist/js/api-definition-lite/index.mjs.map +1 -1
- package/dist/js/client/FdrClient.js +52 -24
- package/dist/js/client/FdrClient.js.map +1 -1
- package/dist/js/client/FdrClient.mjs +52 -24
- package/dist/js/client/FdrClient.mjs.map +1 -1
- package/dist/js/converters/index.js +302 -53
- package/dist/js/converters/index.js.map +1 -1
- package/dist/js/converters/index.mjs +302 -53
- package/dist/js/converters/index.mjs.map +1 -1
- package/dist/js/index.js +354 -77
- package/dist/js/index.js.map +1 -1
- package/dist/js/index.mjs +354 -77
- package/dist/js/index.mjs.map +1 -1
- package/dist/js/navigation/index.js +302 -53
- package/dist/js/navigation/index.js.map +1 -1
- package/dist/js/navigation/index.mjs +302 -53
- package/dist/js/navigation/index.mjs.map +1 -1
- package/dist/js/orpc-client.js +64 -26
- package/dist/js/orpc-client.js.map +1 -1
- package/dist/js/orpc-client.mjs +58 -25
- package/dist/js/orpc-client.mjs.map +1 -1
- package/dist/types/api-definition/__test__/graphql-type-context.test.d.ts +2 -0
- package/dist/types/api-definition/__test__/graphql-type-context.test.d.ts.map +1 -0
- package/dist/types/api-definition/__test__/graphql-type-references.test.d.ts +2 -0
- package/dist/types/api-definition/__test__/graphql-type-references.test.d.ts.map +1 -0
- package/dist/types/api-definition/__test__/unwrap-property-set-invariant.test.d.ts +2 -0
- package/dist/types/api-definition/__test__/unwrap-property-set-invariant.test.d.ts.map +1 -0
- package/dist/types/api-definition/__test__/unwrap-shadowed-extends.test.d.ts +2 -0
- package/dist/types/api-definition/__test__/unwrap-shadowed-extends.test.d.ts.map +1 -0
- package/dist/types/api-definition/endpoint-context.d.ts +17 -1
- package/dist/types/api-definition/endpoint-context.d.ts.map +1 -1
- package/dist/types/api-definition/graphql-type-references.d.ts +62 -0
- package/dist/types/api-definition/graphql-type-references.d.ts.map +1 -0
- package/dist/types/api-definition/index.d.ts +1 -1
- package/dist/types/api-definition/index.d.ts.map +1 -1
- package/dist/types/api-definition/prune.d.ts +6 -0
- package/dist/types/api-definition/prune.d.ts.map +1 -1
- package/dist/types/api-definition/snippets/graphql-snippets.d.ts +14 -1
- package/dist/types/api-definition/snippets/graphql-snippets.d.ts.map +1 -1
- package/dist/types/api-definition/snippets/graphql-type-sdl.test.d.ts +2 -0
- package/dist/types/api-definition/snippets/graphql-type-sdl.test.d.ts.map +1 -0
- package/dist/types/navigation/NodeCollector.d.ts +47 -18
- package/dist/types/navigation/NodeCollector.d.ts.map +1 -1
- package/dist/types/navigation/__test__/NodeCollector.graphqlOperationIndex.test.d.ts +2 -0
- package/dist/types/navigation/__test__/NodeCollector.graphqlOperationIndex.test.d.ts.map +1 -0
- package/dist/types/orpc-client/dashboard-agent/contract.d.ts +92 -29
- package/dist/types/orpc-client/dashboard-agent/contract.d.ts.map +1 -1
- package/dist/types/orpc-client/docs-ledger/contract.d.ts +143 -422
- package/dist/types/orpc-client/docs-ledger/contract.d.ts.map +1 -1
- package/dist/types/orpc-client/docs-ledger/ledger-manifest.d.ts +0 -56
- package/dist/types/orpc-client/docs-ledger/ledger-manifest.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/types/api-definition/__test__/type-back-references.test.d.ts +0 -2
- package/dist/types/api-definition/__test__/type-back-references.test.d.ts.map +0 -1
- package/dist/types/api-definition/type-back-references.d.ts +0 -23
- package/dist/types/api-definition/type-back-references.d.ts.map +0 -1
|
@@ -184,24 +184,28 @@ __export(api_definition_exports, {
|
|
|
184
184
|
buildRequestUrl: () => buildRequestUrl,
|
|
185
185
|
buildSdkSnippetRequest: () => buildSdkSnippetRequest,
|
|
186
186
|
cleanLanguage: () => cleanLanguage,
|
|
187
|
+
collectGraphqlTypeReferrers: () => collectGraphqlTypeReferrers,
|
|
187
188
|
collectReferencedTypeIds: () => collectReferencedTypeIds,
|
|
188
|
-
|
|
189
|
+
collectReferencingTypeIds: () => collectReferencingTypeIds,
|
|
189
190
|
collectTypeDefinitionTree: () => collectTypeDefinitionTree,
|
|
190
191
|
collectTypeDefinitionTreeForObjectProperty: () => collectTypeDefinitionTreeForObjectProperty,
|
|
191
192
|
convertToCurl: () => convertToCurl,
|
|
192
193
|
createEndpointContext: () => createEndpointContext,
|
|
193
194
|
createGraphqlContext: () => createGraphqlContext,
|
|
195
|
+
createGraphqlTypeContext: () => createGraphqlTypeContext,
|
|
194
196
|
createGrpcContext: () => createGrpcContext,
|
|
195
197
|
createWebSocketContext: () => createWebSocketContext,
|
|
196
198
|
createWebhookContext: () => createWebhookContext,
|
|
197
199
|
filterReferencedTypes: () => filterReferencedTypes,
|
|
198
200
|
generateCurlSnippet: () => generateCurlSnippet,
|
|
199
201
|
generateGraphQlSnippet: () => generateGraphQlSnippet,
|
|
202
|
+
generateGraphQlTypeSdl: () => generateGraphQlTypeSdl,
|
|
200
203
|
generateHttpSnippets: () => generateHttpSnippets,
|
|
201
204
|
generateSdkSnippetForLanguage: () => generateSdkSnippetForLanguage,
|
|
202
205
|
generateSdkSnippets: () => generateSdkSnippets,
|
|
203
206
|
getGraphqlOperationIds: () => getGraphqlOperationIds,
|
|
204
207
|
getHarRequest: () => getHarRequest,
|
|
208
|
+
getImplementorTypeIds: () => getImplementorTypeIds,
|
|
205
209
|
getMessageForStatus: () => getMessageForStatus,
|
|
206
210
|
joiner: () => joiner,
|
|
207
211
|
preprocessQueryParameters: () => preprocessQueryParameters,
|
|
@@ -212,6 +216,8 @@ __export(api_definition_exports, {
|
|
|
212
216
|
toColonEndpointPathLiteral: () => toColonEndpointPathLiteral,
|
|
213
217
|
toCurlyBraceEndpointPathLiteral: () => toCurlyBraceEndpointPathLiteral,
|
|
214
218
|
toSnippetHttpRequest: () => toSnippetHttpRequest,
|
|
219
|
+
trimGraphQlOperationToReferences: () => trimGraphQlOperationToReferences,
|
|
220
|
+
trimTypeDefinitionToReferences: () => trimTypeDefinitionToReferences,
|
|
215
221
|
unwrapDiscriminatedUnionVariant: () => unwrapDiscriminatedUnionVariant,
|
|
216
222
|
unwrapObjectType: () => unwrapObjectType,
|
|
217
223
|
unwrapReference: () => unwrapReference,
|
|
@@ -2575,7 +2581,16 @@ function unwrapObjectType(object5, types, parentVisitedTypeIds) {
|
|
|
2575
2581
|
};
|
|
2576
2582
|
});
|
|
2577
2583
|
});
|
|
2578
|
-
|
|
2584
|
+
const propertyKeys = new Set(object5.properties.map((property) => property.key));
|
|
2585
|
+
const seenExtendedKeys = /* @__PURE__ */ new Set();
|
|
2586
|
+
const filteredExtendedProperties = extendedProperties.filter((extendedProperty) => {
|
|
2587
|
+
if (propertyKeys.has(extendedProperty.key) || seenExtendedKeys.has(extendedProperty.key)) {
|
|
2588
|
+
return false;
|
|
2589
|
+
}
|
|
2590
|
+
seenExtendedKeys.add(extendedProperty.key);
|
|
2591
|
+
return true;
|
|
2592
|
+
});
|
|
2593
|
+
if (filteredExtendedProperties.length === 0) {
|
|
2579
2594
|
const properties2 = (0, import_array.sortBy)(
|
|
2580
2595
|
[...directProperties],
|
|
2581
2596
|
[
|
|
@@ -2592,15 +2607,6 @@ function unwrapObjectType(object5, types, parentVisitedTypeIds) {
|
|
|
2592
2607
|
UnwrapObjectTypeCache.set(object5, toRet2);
|
|
2593
2608
|
return toRet2;
|
|
2594
2609
|
}
|
|
2595
|
-
const propertyKeys = new Set(object5.properties.map((property) => property.key));
|
|
2596
|
-
const seenExtendedKeys = /* @__PURE__ */ new Set();
|
|
2597
|
-
const filteredExtendedProperties = extendedProperties.filter((extendedProperty) => {
|
|
2598
|
-
if (propertyKeys.has(extendedProperty.key) || seenExtendedKeys.has(extendedProperty.key)) {
|
|
2599
|
-
return false;
|
|
2600
|
-
}
|
|
2601
|
-
seenExtendedKeys.add(extendedProperty.key);
|
|
2602
|
-
return true;
|
|
2603
|
-
});
|
|
2604
2610
|
const properties = (0, import_array.sortBy)(
|
|
2605
2611
|
[...directProperties, ...filteredExtendedProperties],
|
|
2606
2612
|
[
|
|
@@ -3124,6 +3130,115 @@ var ApiTypeIdVisitor = class _ApiTypeIdVisitor {
|
|
|
3124
3130
|
}
|
|
3125
3131
|
};
|
|
3126
3132
|
|
|
3133
|
+
// src/api-definition/graphql-type-references.ts
|
|
3134
|
+
function shapeReferences(shape, typeIds) {
|
|
3135
|
+
let found = false;
|
|
3136
|
+
ApiTypeIdVisitor.visitTypeShape(shape, (typeId) => {
|
|
3137
|
+
if (typeIds.has(typeId)) {
|
|
3138
|
+
found = true;
|
|
3139
|
+
}
|
|
3140
|
+
});
|
|
3141
|
+
return found;
|
|
3142
|
+
}
|
|
3143
|
+
function definitionReferences(definition, typeIds) {
|
|
3144
|
+
return shapeReferences(definition.shape, typeIds);
|
|
3145
|
+
}
|
|
3146
|
+
function trimTypeDefinitionToReferences(definition, typeIds) {
|
|
3147
|
+
if (definition.shape.type !== "object") {
|
|
3148
|
+
return definition;
|
|
3149
|
+
}
|
|
3150
|
+
const properties = definition.shape.properties.filter(
|
|
3151
|
+
(property) => shapeReferences(property.valueShape, typeIds) || (property.arguments?.some((argument) => shapeReferences(argument.type, typeIds)) ?? false)
|
|
3152
|
+
);
|
|
3153
|
+
return {
|
|
3154
|
+
...definition,
|
|
3155
|
+
shape: {
|
|
3156
|
+
...definition.shape,
|
|
3157
|
+
properties,
|
|
3158
|
+
extraProperties: void 0
|
|
3159
|
+
}
|
|
3160
|
+
};
|
|
3161
|
+
}
|
|
3162
|
+
function trimGraphQlOperationToReferences(operation, typeIds) {
|
|
3163
|
+
const args = (operation.arguments ?? []).filter((argument) => shapeReferences(argument.type, typeIds));
|
|
3164
|
+
const isReturnType = shapeReferences(operation.returnType, typeIds);
|
|
3165
|
+
if (args.length === 0 && !isReturnType) {
|
|
3166
|
+
return void 0;
|
|
3167
|
+
}
|
|
3168
|
+
return {
|
|
3169
|
+
...operation,
|
|
3170
|
+
arguments: args.length > 0 ? args : void 0,
|
|
3171
|
+
examples: void 0,
|
|
3172
|
+
snippets: void 0
|
|
3173
|
+
};
|
|
3174
|
+
}
|
|
3175
|
+
function collectReferencingTypeIds(types, typeIds) {
|
|
3176
|
+
const referencing = [];
|
|
3177
|
+
for (const [rawId, definition] of Object.entries(types)) {
|
|
3178
|
+
const candidateId = rawId;
|
|
3179
|
+
if (typeIds.has(candidateId)) {
|
|
3180
|
+
continue;
|
|
3181
|
+
}
|
|
3182
|
+
if (definitionReferences(definition, typeIds)) {
|
|
3183
|
+
referencing.push(candidateId);
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
return referencing;
|
|
3187
|
+
}
|
|
3188
|
+
function collectGraphqlTypeReferrers(api, typeId) {
|
|
3189
|
+
const target = /* @__PURE__ */ new Set([typeId]);
|
|
3190
|
+
const referrers = [];
|
|
3191
|
+
for (const [rawId, definition] of Object.entries(api.types)) {
|
|
3192
|
+
const candidateId = rawId;
|
|
3193
|
+
if (candidateId === typeId) {
|
|
3194
|
+
continue;
|
|
3195
|
+
}
|
|
3196
|
+
const fields = [];
|
|
3197
|
+
const fieldArguments = [];
|
|
3198
|
+
if (definition.shape.type === "object") {
|
|
3199
|
+
for (const property of definition.shape.properties) {
|
|
3200
|
+
if (shapeReferences(property.valueShape, target)) {
|
|
3201
|
+
fields.push(property.key);
|
|
3202
|
+
}
|
|
3203
|
+
for (const argument of property.arguments ?? []) {
|
|
3204
|
+
if (shapeReferences(argument.type, target)) {
|
|
3205
|
+
fieldArguments.push({ field: property.key, argument: argument.name });
|
|
3206
|
+
}
|
|
3207
|
+
}
|
|
3208
|
+
}
|
|
3209
|
+
if (fields.length === 0 && fieldArguments.length === 0) {
|
|
3210
|
+
continue;
|
|
3211
|
+
}
|
|
3212
|
+
} else if (!definitionReferences(definition, target)) {
|
|
3213
|
+
continue;
|
|
3214
|
+
}
|
|
3215
|
+
referrers.push({
|
|
3216
|
+
type: "type",
|
|
3217
|
+
typeId: candidateId,
|
|
3218
|
+
name: definition.displayName ?? definition.name ?? candidateId,
|
|
3219
|
+
fields,
|
|
3220
|
+
fieldArguments,
|
|
3221
|
+
isVariant: fields.length === 0 && fieldArguments.length === 0
|
|
3222
|
+
});
|
|
3223
|
+
}
|
|
3224
|
+
for (const operation of Object.values(api.graphqlOperations)) {
|
|
3225
|
+
const args = (operation.arguments ?? []).filter((argument) => shapeReferences(argument.type, target)).map((argument) => argument.name);
|
|
3226
|
+
const isReturnType = shapeReferences(operation.returnType, target);
|
|
3227
|
+
if (args.length === 0 && !isReturnType) {
|
|
3228
|
+
continue;
|
|
3229
|
+
}
|
|
3230
|
+
referrers.push({
|
|
3231
|
+
type: "operation",
|
|
3232
|
+
operationId: operation.id,
|
|
3233
|
+
name: operation.displayName ?? operation.name,
|
|
3234
|
+
operationType: operation.operationType,
|
|
3235
|
+
arguments: args,
|
|
3236
|
+
isReturnType
|
|
3237
|
+
});
|
|
3238
|
+
}
|
|
3239
|
+
return referrers;
|
|
3240
|
+
}
|
|
3241
|
+
|
|
3127
3242
|
// src/api-definition/prune.ts
|
|
3128
3243
|
var ApiDefinitionPruner = class _ApiDefinitionPruner {
|
|
3129
3244
|
constructor(api) {
|
|
@@ -3157,6 +3272,7 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
|
|
|
3157
3272
|
const namespaces = /* @__PURE__ */ new Set();
|
|
3158
3273
|
const authSchemes = /* @__PURE__ */ new Set();
|
|
3159
3274
|
const seedTypeIds = /* @__PURE__ */ new Set();
|
|
3275
|
+
const graphqlTypePageIds = /* @__PURE__ */ new Set();
|
|
3160
3276
|
for (const node of nodes) {
|
|
3161
3277
|
if (node.type === "endpoint") {
|
|
3162
3278
|
const found = this.api.endpoints[node.endpointId];
|
|
@@ -3197,10 +3313,17 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
|
|
|
3197
3313
|
const found = this.api.types[node.typeId];
|
|
3198
3314
|
if (found) {
|
|
3199
3315
|
seedTypeIds.add(node.typeId);
|
|
3316
|
+
graphqlTypePageIds.add(node.typeId);
|
|
3317
|
+
for (const implementorId of this.getImplementorTypeIds(node.typeId)) {
|
|
3318
|
+
seedTypeIds.add(implementorId);
|
|
3319
|
+
}
|
|
3200
3320
|
}
|
|
3201
3321
|
}
|
|
3202
3322
|
}
|
|
3203
3323
|
toRet.types = this.pruneTypes(toRet, seedTypeIds);
|
|
3324
|
+
if (graphqlTypePageIds.size > 0) {
|
|
3325
|
+
this.addBackReferences(toRet, graphqlTypePageIds);
|
|
3326
|
+
}
|
|
3204
3327
|
namespaces.forEach((subpackageId) => {
|
|
3205
3328
|
const subpackage = this.api.subpackages[subpackageId];
|
|
3206
3329
|
if (subpackage) {
|
|
@@ -3215,6 +3338,36 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
|
|
|
3215
3338
|
});
|
|
3216
3339
|
return toRet;
|
|
3217
3340
|
}
|
|
3341
|
+
/**
|
|
3342
|
+
* Add what *references* the type a page documents. The closure above walks references
|
|
3343
|
+
* forward, so "what incorporates this type" is absent from a type page's payload unless it
|
|
3344
|
+
* is seeded here; the referring entries are trimmed to the referencing fields and
|
|
3345
|
+
* arguments only, and are deliberately added after `pruneTypes` so their own closures are
|
|
3346
|
+
* not pulled in with them.
|
|
3347
|
+
*/
|
|
3348
|
+
addBackReferences(toRet, pageTypeIds) {
|
|
3349
|
+
for (const referencingId of collectReferencingTypeIds(this.api.types, pageTypeIds)) {
|
|
3350
|
+
if (toRet.types[referencingId] != null) {
|
|
3351
|
+
continue;
|
|
3352
|
+
}
|
|
3353
|
+
const definition = this.api.types[referencingId];
|
|
3354
|
+
if (definition != null) {
|
|
3355
|
+
toRet.types[referencingId] = trimTypeDefinitionToReferences(definition, pageTypeIds);
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
for (const [operationId, operation] of Object.entries(this.api.graphqlOperations)) {
|
|
3359
|
+
if (toRet.graphqlOperations[operationId] != null) {
|
|
3360
|
+
continue;
|
|
3361
|
+
}
|
|
3362
|
+
const trimmed = trimGraphQlOperationToReferences(operation, pageTypeIds);
|
|
3363
|
+
if (trimmed != null) {
|
|
3364
|
+
toRet.graphqlOperations[operationId] = trimmed;
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
}
|
|
3368
|
+
getImplementorTypeIds(typeId) {
|
|
3369
|
+
return getImplementorTypeIds(this.api.types, typeId);
|
|
3370
|
+
}
|
|
3218
3371
|
pruneTypes(partiallyPrunedApi, seedTypeIds = /* @__PURE__ */ new Set()) {
|
|
3219
3372
|
let typeIds = new Set(seedTypeIds);
|
|
3220
3373
|
partiallyPrunedApi.globalHeaders?.forEach((header) => {
|
|
@@ -3269,6 +3422,14 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
|
|
|
3269
3422
|
return visitedTypeIds;
|
|
3270
3423
|
}
|
|
3271
3424
|
};
|
|
3425
|
+
function getImplementorTypeIds(types, typeId) {
|
|
3426
|
+
return Object.entries(types).filter(
|
|
3427
|
+
([candidateId, candidate]) => candidateId !== typeId && candidate.shape.type === "object" && candidate.shape.extends.includes(typeId)
|
|
3428
|
+
).sort(([, a], [, b]) => displayNameOf(a).localeCompare(displayNameOf(b))).map(([candidateId]) => TypeId(candidateId));
|
|
3429
|
+
}
|
|
3430
|
+
function displayNameOf(type) {
|
|
3431
|
+
return type.displayName ?? type.name;
|
|
3432
|
+
}
|
|
3272
3433
|
function prune(api, ...nodes) {
|
|
3273
3434
|
return ApiDefinitionPruner.from(api).prune(...nodes);
|
|
3274
3435
|
}
|
|
@@ -3520,6 +3681,34 @@ function createGraphqlContext(node, apiDefinition) {
|
|
|
3520
3681
|
types: api.types
|
|
3521
3682
|
};
|
|
3522
3683
|
}
|
|
3684
|
+
function createGraphqlTypeContext(node, apiDefinition) {
|
|
3685
|
+
if (!node) {
|
|
3686
|
+
console.warn("[createGraphqlTypeContext] node is undefined");
|
|
3687
|
+
return void 0;
|
|
3688
|
+
}
|
|
3689
|
+
if (apiDefinition == null) {
|
|
3690
|
+
console.warn(
|
|
3691
|
+
`[createGraphqlTypeContext] apiDefinition is undefined for node id=${node.id}, typeId=${node.typeId}`
|
|
3692
|
+
);
|
|
3693
|
+
return void 0;
|
|
3694
|
+
}
|
|
3695
|
+
const api = prune(apiDefinition, node);
|
|
3696
|
+
const type = api.types[node.typeId];
|
|
3697
|
+
if (!type) {
|
|
3698
|
+
const availableTypeIds = Object.keys(api.types);
|
|
3699
|
+
console.warn(
|
|
3700
|
+
`[createGraphqlTypeContext] type not found after pruning. typeId=${node.typeId}, apiDefinitionId=${node.apiDefinitionId}, availableTypeIds=[${availableTypeIds.join(", ")}]`
|
|
3701
|
+
);
|
|
3702
|
+
return void 0;
|
|
3703
|
+
}
|
|
3704
|
+
return {
|
|
3705
|
+
node,
|
|
3706
|
+
type,
|
|
3707
|
+
types: api.types,
|
|
3708
|
+
implementors: getImplementorTypeIds(api.types, node.typeId),
|
|
3709
|
+
referencedBy: collectGraphqlTypeReferrers(api, node.typeId)
|
|
3710
|
+
};
|
|
3711
|
+
}
|
|
3523
3712
|
|
|
3524
3713
|
// src/api-definition/endpoint-path-literal.ts
|
|
3525
3714
|
function toColonEndpointPathLiteral(pathParts) {
|
|
@@ -5534,6 +5723,50 @@ function generateGraphQlSnippet(context) {
|
|
|
5534
5723
|
snippetCache.set(operation, result);
|
|
5535
5724
|
return result;
|
|
5536
5725
|
}
|
|
5726
|
+
var SDL_KEYWORD = {
|
|
5727
|
+
object: "type",
|
|
5728
|
+
input: "input",
|
|
5729
|
+
interface: "interface",
|
|
5730
|
+
enum: "enum",
|
|
5731
|
+
union: "union",
|
|
5732
|
+
scalar: "scalar"
|
|
5733
|
+
};
|
|
5734
|
+
function generateGraphQlTypeSdl({
|
|
5735
|
+
name,
|
|
5736
|
+
category,
|
|
5737
|
+
type,
|
|
5738
|
+
types
|
|
5739
|
+
}) {
|
|
5740
|
+
const keyword = SDL_KEYWORD[category];
|
|
5741
|
+
const shape = type.shape;
|
|
5742
|
+
if (category === "scalar") {
|
|
5743
|
+
return `scalar ${name}`;
|
|
5744
|
+
}
|
|
5745
|
+
if (category === "union") {
|
|
5746
|
+
const members = shape.type === "undiscriminatedUnion" ? shape.variants.map((variant) => typeShapeToGraphQlType(variant.shape, types, false)) : shape.type === "discriminatedUnion" ? shape.variants.map((variant) => variant.displayName ?? variant.discriminantValue) : [];
|
|
5747
|
+
return members.length > 0 ? `union ${name} = ${members.join(" | ")}` : `union ${name}`;
|
|
5748
|
+
}
|
|
5749
|
+
if (shape.type === "enum") {
|
|
5750
|
+
const values = shape.values.map((value) => ` ${value.value}`);
|
|
5751
|
+
return `enum ${name} {
|
|
5752
|
+
${values.join("\n")}
|
|
5753
|
+
}`;
|
|
5754
|
+
}
|
|
5755
|
+
if (shape.type === "object") {
|
|
5756
|
+
const implemented = shape.extends.map((typeId) => types[typeId]).filter((implementedType) => implementedType != null).map((implementedType) => implementedType.displayName ?? unnamespacedName(implementedType.name));
|
|
5757
|
+
const heading = implemented.length > 0 ? `${keyword} ${name} implements ${implemented.join(" & ")}` : `${keyword} ${name}`;
|
|
5758
|
+
const fields = shape.properties.map((property) => ` ${objectPropertyToSdlField(property, types)}`);
|
|
5759
|
+
return fields.length > 0 ? `${heading} {
|
|
5760
|
+
${fields.join("\n")}
|
|
5761
|
+
}` : heading;
|
|
5762
|
+
}
|
|
5763
|
+
return `${keyword} ${name}`;
|
|
5764
|
+
}
|
|
5765
|
+
function objectPropertyToSdlField(property, types) {
|
|
5766
|
+
const args = property.arguments ?? [];
|
|
5767
|
+
const argList = args.length > 0 ? `(${args.map((arg) => `${arg.name}: ${typeShapeToGraphQlType(arg.type, types)}`).join(", ")})` : "";
|
|
5768
|
+
return `${property.key}${argList}: ${typeShapeToGraphQlType(property.valueShape, types)}`;
|
|
5769
|
+
}
|
|
5537
5770
|
function getOperationKeyword(operationType) {
|
|
5538
5771
|
switch (operationType) {
|
|
5539
5772
|
case "QUERY":
|
|
@@ -6730,28 +6963,6 @@ var Transformer = class _Transformer {
|
|
|
6730
6963
|
};
|
|
6731
6964
|
};
|
|
6732
6965
|
};
|
|
6733
|
-
|
|
6734
|
-
// src/api-definition/type-back-references.ts
|
|
6735
|
-
function collectReferencingTypeIdsByTypeId(api) {
|
|
6736
|
-
const byTypeId = /* @__PURE__ */ new Map();
|
|
6737
|
-
for (const [rawId, definition] of Object.entries(api.types)) {
|
|
6738
|
-
const from = rawId;
|
|
6739
|
-
const seen = /* @__PURE__ */ new Set();
|
|
6740
|
-
ApiTypeIdVisitor.visitTypeDefinition(definition, (to) => {
|
|
6741
|
-
if (to === from || seen.has(to) || api.types[to] == null) {
|
|
6742
|
-
return;
|
|
6743
|
-
}
|
|
6744
|
-
seen.add(to);
|
|
6745
|
-
const existing = byTypeId.get(to);
|
|
6746
|
-
if (existing == null) {
|
|
6747
|
-
byTypeId.set(to, [from]);
|
|
6748
|
-
} else {
|
|
6749
|
-
existing.push(from);
|
|
6750
|
-
}
|
|
6751
|
-
});
|
|
6752
|
-
}
|
|
6753
|
-
return byTypeId;
|
|
6754
|
-
}
|
|
6755
6966
|
// Annotate the CommonJS export names for ESM import in node:
|
|
6756
6967
|
0 && (module.exports = {
|
|
6757
6968
|
ApiAuthSchema,
|
|
@@ -6908,24 +7119,28 @@ function collectReferencingTypeIdsByTypeId(api) {
|
|
|
6908
7119
|
buildRequestUrl,
|
|
6909
7120
|
buildSdkSnippetRequest,
|
|
6910
7121
|
cleanLanguage,
|
|
7122
|
+
collectGraphqlTypeReferrers,
|
|
6911
7123
|
collectReferencedTypeIds,
|
|
6912
|
-
|
|
7124
|
+
collectReferencingTypeIds,
|
|
6913
7125
|
collectTypeDefinitionTree,
|
|
6914
7126
|
collectTypeDefinitionTreeForObjectProperty,
|
|
6915
7127
|
convertToCurl,
|
|
6916
7128
|
createEndpointContext,
|
|
6917
7129
|
createGraphqlContext,
|
|
7130
|
+
createGraphqlTypeContext,
|
|
6918
7131
|
createGrpcContext,
|
|
6919
7132
|
createWebSocketContext,
|
|
6920
7133
|
createWebhookContext,
|
|
6921
7134
|
filterReferencedTypes,
|
|
6922
7135
|
generateCurlSnippet,
|
|
6923
7136
|
generateGraphQlSnippet,
|
|
7137
|
+
generateGraphQlTypeSdl,
|
|
6924
7138
|
generateHttpSnippets,
|
|
6925
7139
|
generateSdkSnippetForLanguage,
|
|
6926
7140
|
generateSdkSnippets,
|
|
6927
7141
|
getGraphqlOperationIds,
|
|
6928
7142
|
getHarRequest,
|
|
7143
|
+
getImplementorTypeIds,
|
|
6929
7144
|
getMessageForStatus,
|
|
6930
7145
|
joiner,
|
|
6931
7146
|
preprocessQueryParameters,
|
|
@@ -6936,6 +7151,8 @@ function collectReferencingTypeIdsByTypeId(api) {
|
|
|
6936
7151
|
toColonEndpointPathLiteral,
|
|
6937
7152
|
toCurlyBraceEndpointPathLiteral,
|
|
6938
7153
|
toSnippetHttpRequest,
|
|
7154
|
+
trimGraphQlOperationToReferences,
|
|
7155
|
+
trimTypeDefinitionToReferences,
|
|
6939
7156
|
unwrapDiscriminatedUnionVariant,
|
|
6940
7157
|
unwrapObjectType,
|
|
6941
7158
|
unwrapReference,
|