@fern-api/fdr-sdk 1.2.33-830bfae69e → 1.2.33-83d745d750
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 +56 -13
- package/dist/js/api-definition/index.js.map +1 -1
- package/dist/js/api-definition/index.mjs +56 -13
- package/dist/js/api-definition/index.mjs.map +1 -1
- package/dist/js/client/FdrClient.js +2 -0
- package/dist/js/client/FdrClient.js.map +1 -1
- package/dist/js/client/FdrClient.mjs +2 -0
- package/dist/js/client/FdrClient.mjs.map +1 -1
- package/dist/js/client/types.js +2 -0
- package/dist/js/client/types.js.map +1 -1
- package/dist/js/client/types.mjs +2 -0
- package/dist/js/client/types.mjs.map +1 -1
- package/dist/js/converters/index.js +144 -27
- package/dist/js/converters/index.js.map +1 -1
- package/dist/js/converters/index.mjs +144 -27
- package/dist/js/converters/index.mjs.map +1 -1
- package/dist/js/index.js +144 -27
- package/dist/js/index.js.map +1 -1
- package/dist/js/index.mjs +144 -27
- package/dist/js/index.mjs.map +1 -1
- package/dist/js/navigation/index.js +144 -27
- package/dist/js/navigation/index.js.map +1 -1
- package/dist/js/navigation/index.mjs +144 -27
- package/dist/js/navigation/index.mjs.map +1 -1
- package/dist/js/navigation/ledger-root-builder.js +2 -0
- package/dist/js/navigation/ledger-root-builder.js.map +1 -1
- package/dist/js/navigation/ledger-root-builder.mjs +2 -0
- 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 +2 -0
- package/dist/js/orpc-client.js.map +1 -1
- package/dist/js/orpc-client.mjs +2 -0
- package/dist/js/orpc-client.mjs.map +1 -1
- package/dist/tsconfig.tsbuildinfo +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.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/converters/read/convertDbAPIDefinitionToRead.d.ts +2 -0
- 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/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 +2 -0
- 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/toApis.d.ts +1 -0
- package/dist/types/navigation/utils/toApis.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 +24 -0
- package/dist/types/orpc-client/api/contract-db.d.ts.map +1 -1
- package/dist/types/orpc-client/api/contract-latest.d.ts +13 -0
- package/dist/types/orpc-client/api/contract-latest.d.ts.map +1 -1
- package/dist/types/orpc-client/api/contract-read.d.ts +24 -0
- package/dist/types/orpc-client/api/contract-read.d.ts.map +1 -1
- package/dist/types/orpc-client/api/contract-register.d.ts +24 -0
- package/dist/types/orpc-client/api/contract-register.d.ts.map +1 -1
- package/dist/types/orpc-client/api/shared.d.ts +3 -0
- package/dist/types/orpc-client/api/shared.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1232,6 +1232,7 @@ var GraphQlOperationSchema = z2.object({
|
|
|
1232
1232
|
operationType: GraphQlOperationTypeSchema,
|
|
1233
1233
|
name: z2.string(),
|
|
1234
1234
|
displayName: z2.string().nullish(),
|
|
1235
|
+
fieldPath: z2.array(z2.string()).nullish(),
|
|
1235
1236
|
arguments: z2.array(GraphQlArgumentSchema).nullish(),
|
|
1236
1237
|
returnType: TypeReferenceSchema,
|
|
1237
1238
|
examples: z2.array(GraphQlExampleSchema).nullish(),
|
|
@@ -2035,6 +2036,7 @@ var LatestGraphQlOperationSchema = z4.object({
|
|
|
2035
2036
|
description: z4.string().nullish(),
|
|
2036
2037
|
availability: AvailabilitySchema.nullish(),
|
|
2037
2038
|
namespace: z4.array(z4.string()).nullish(),
|
|
2039
|
+
fieldPath: z4.array(z4.string()).nullish(),
|
|
2038
2040
|
id: GraphQlOperationIdSchema,
|
|
2039
2041
|
operationType: LatestGraphQlOperationTypeSchema,
|
|
2040
2042
|
name: z4.string(),
|
|
@@ -8340,10 +8342,13 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
|
|
|
8340
8342
|
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
8341
8343
|
}
|
|
8342
8344
|
} else if (node.type === "graphql") {
|
|
8343
|
-
const
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
found
|
|
8345
|
+
const idsToInclude = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
8346
|
+
for (const opId of idsToInclude) {
|
|
8347
|
+
const found = this.api.graphqlOperations[opId];
|
|
8348
|
+
if (found) {
|
|
8349
|
+
toRet.graphqlOperations[opId] = found;
|
|
8350
|
+
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
8351
|
+
}
|
|
8347
8352
|
}
|
|
8348
8353
|
}
|
|
8349
8354
|
}
|
|
@@ -8645,9 +8650,21 @@ function createGraphqlContext(node, apiDefinition) {
|
|
|
8645
8650
|
);
|
|
8646
8651
|
return void 0;
|
|
8647
8652
|
}
|
|
8653
|
+
const allIds = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
8654
|
+
const operations = [];
|
|
8655
|
+
for (const id of allIds) {
|
|
8656
|
+
const op = api2.graphqlOperations[id];
|
|
8657
|
+
if (op) {
|
|
8658
|
+
operations.push(op);
|
|
8659
|
+
}
|
|
8660
|
+
}
|
|
8661
|
+
if (operations.length === 0) {
|
|
8662
|
+
operations.push(operation);
|
|
8663
|
+
}
|
|
8648
8664
|
return {
|
|
8649
8665
|
node,
|
|
8650
8666
|
operation,
|
|
8667
|
+
operations,
|
|
8651
8668
|
types: api2.types
|
|
8652
8669
|
};
|
|
8653
8670
|
}
|
|
@@ -10259,6 +10276,7 @@ var ApiDefinitionV1ToLatest = class _ApiDefinitionV1ToLatest {
|
|
|
10259
10276
|
description: v1?.description,
|
|
10260
10277
|
availability: v1?.availability,
|
|
10261
10278
|
namespace,
|
|
10279
|
+
fieldPath: v1?.fieldPath,
|
|
10262
10280
|
arguments: v1?.arguments?.map((arg) => this.migrateGraphQlArgument(arg)),
|
|
10263
10281
|
returnType: {
|
|
10264
10282
|
type: "alias",
|
|
@@ -10555,7 +10573,10 @@ function generateGraphQlSnippet(context) {
|
|
|
10555
10573
|
return `$${arg.name}: ${graphqlType}`;
|
|
10556
10574
|
});
|
|
10557
10575
|
const argumentUsage = args.map((arg) => `${arg.name}: $${arg.name}`);
|
|
10558
|
-
const
|
|
10576
|
+
const fieldPath = operation.fieldPath;
|
|
10577
|
+
const hasFieldPath = fieldPath != null && fieldPath.length > 0;
|
|
10578
|
+
const selectionSetIndent = hasFieldPath ? 2 + fieldPath.length : 2;
|
|
10579
|
+
const selectionSet = generateSelectionSet(operation.returnType, types, 2, /* @__PURE__ */ new Set(), selectionSetIndent);
|
|
10559
10580
|
let query = operationKeyword;
|
|
10560
10581
|
if (operationName || variableDefinitions.length > 0) {
|
|
10561
10582
|
query += ` ${operationName}`;
|
|
@@ -10564,15 +10585,32 @@ function generateGraphQlSnippet(context) {
|
|
|
10564
10585
|
}
|
|
10565
10586
|
}
|
|
10566
10587
|
query += " {\n";
|
|
10567
|
-
|
|
10588
|
+
const baseIndent = 2;
|
|
10589
|
+
if (hasFieldPath) {
|
|
10590
|
+
for (let i = 0; i < fieldPath.length; i++) {
|
|
10591
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
10592
|
+
query += `${indent}${fieldPath[i]} {
|
|
10593
|
+
`;
|
|
10594
|
+
}
|
|
10595
|
+
}
|
|
10596
|
+
const operationIndent = hasFieldPath ? " ".repeat(baseIndent + fieldPath.length * 2) : " ";
|
|
10597
|
+
query += `${operationIndent}${operation.name}`;
|
|
10568
10598
|
if (argumentUsage.length > 0) {
|
|
10569
10599
|
query += `(${argumentUsage.join(", ")})`;
|
|
10570
10600
|
}
|
|
10571
10601
|
if (selectionSet) {
|
|
10572
10602
|
query += ` ${selectionSet}`;
|
|
10573
10603
|
}
|
|
10574
|
-
query += "\n
|
|
10575
|
-
|
|
10604
|
+
query += "\n";
|
|
10605
|
+
if (hasFieldPath) {
|
|
10606
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
10607
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
10608
|
+
query += `${indent}}
|
|
10609
|
+
`;
|
|
10610
|
+
}
|
|
10611
|
+
}
|
|
10612
|
+
query += "}";
|
|
10613
|
+
const response = generateResponseExample(operation.name, operation.returnType, types, fieldPath);
|
|
10576
10614
|
const result = { query, variables, response };
|
|
10577
10615
|
snippetCache.set(operation, result);
|
|
10578
10616
|
return result;
|
|
@@ -10856,13 +10894,18 @@ function generateSelectionSetFromReference(ref, types, depth, visited, indentLev
|
|
|
10856
10894
|
return "";
|
|
10857
10895
|
}
|
|
10858
10896
|
}
|
|
10859
|
-
function generateResponseExample(operationName, returnType, types) {
|
|
10897
|
+
function generateResponseExample(operationName, returnType, types, fieldPath) {
|
|
10860
10898
|
const data = generateResponseData(returnType, types, 3, /* @__PURE__ */ new Set());
|
|
10861
|
-
|
|
10862
|
-
|
|
10863
|
-
|
|
10899
|
+
let responseData = { [operationName]: data };
|
|
10900
|
+
if (fieldPath != null && fieldPath.length > 0) {
|
|
10901
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
10902
|
+
const key = fieldPath[i];
|
|
10903
|
+
if (key != null) {
|
|
10904
|
+
responseData = { [key]: responseData };
|
|
10905
|
+
}
|
|
10864
10906
|
}
|
|
10865
|
-
}
|
|
10907
|
+
}
|
|
10908
|
+
return { data: responseData };
|
|
10866
10909
|
}
|
|
10867
10910
|
function generateResponseData(shape, types, depth, visited) {
|
|
10868
10911
|
if (depth <= 0) {
|
|
@@ -12540,11 +12583,8 @@ var ApiDefinitionPruner2 = class {
|
|
|
12540
12583
|
if (node.type !== "graphql" || graphqlOperations == null) {
|
|
12541
12584
|
return [];
|
|
12542
12585
|
}
|
|
12543
|
-
const
|
|
12544
|
-
|
|
12545
|
-
(graphqlOperation) => ApiDefinitionHolder.createGraphQlOperationId(graphqlOperation) === graphqlOperationId
|
|
12546
|
-
);
|
|
12547
|
-
return found ? [found] : [];
|
|
12586
|
+
const idsToInclude = new Set(node.graphqlOperationIds ?? [node.graphqlOperationId]);
|
|
12587
|
+
return graphqlOperations.filter((op) => idsToInclude.has(ApiDefinitionHolder.createGraphQlOperationId(op)));
|
|
12548
12588
|
}
|
|
12549
12589
|
};
|
|
12550
12590
|
|
|
@@ -13268,12 +13308,15 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
13268
13308
|
}));
|
|
13269
13309
|
}
|
|
13270
13310
|
convertGraphQlNode(graphqlOperationId, graphqlOperation, parentSlug) {
|
|
13311
|
+
const fieldPath = graphqlOperation.fieldPath;
|
|
13312
|
+
const urlSlug = fieldPath != null && fieldPath.length > 0 ? [...fieldPath, graphqlOperation.name].join("-") : graphqlOperation.name;
|
|
13271
13313
|
return this.#idgen.with(graphqlOperationId, (id) => ({
|
|
13272
13314
|
id,
|
|
13273
13315
|
type: "graphql",
|
|
13274
13316
|
title: graphqlOperation.displayName ?? graphqlOperation.name,
|
|
13275
13317
|
graphqlOperationId,
|
|
13276
|
-
|
|
13318
|
+
graphqlOperationIds: void 0,
|
|
13319
|
+
slug: parentSlug.apply({ urlSlug }).get(),
|
|
13277
13320
|
icon: void 0,
|
|
13278
13321
|
hidden: void 0,
|
|
13279
13322
|
operationType: graphqlOperation.operationType,
|
|
@@ -13287,6 +13330,86 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
13287
13330
|
featureFlags: void 0
|
|
13288
13331
|
}));
|
|
13289
13332
|
}
|
|
13333
|
+
convertGraphQlOperationsToChildren(graphqlOperations, parentSlug) {
|
|
13334
|
+
const groupedByParent = /* @__PURE__ */ new Map();
|
|
13335
|
+
const insertionOrder = [];
|
|
13336
|
+
for (const op of graphqlOperations) {
|
|
13337
|
+
const graphqlOperationId = ApiDefinitionHolder.createGraphQlOperationId(op);
|
|
13338
|
+
if (this.#visitedGraphqlOperations.has(graphqlOperationId)) {
|
|
13339
|
+
continue;
|
|
13340
|
+
}
|
|
13341
|
+
this.#visitedGraphqlOperations.add(graphqlOperationId);
|
|
13342
|
+
const parentField = op.fieldPath?.[0];
|
|
13343
|
+
if (parentField != null && op.operationType === "QUERY") {
|
|
13344
|
+
const group = groupedByParent.get(parentField);
|
|
13345
|
+
if (group != null) {
|
|
13346
|
+
group.push(op);
|
|
13347
|
+
} else {
|
|
13348
|
+
groupedByParent.set(parentField, [op]);
|
|
13349
|
+
insertionOrder.push({ type: "group", parentField });
|
|
13350
|
+
}
|
|
13351
|
+
} else {
|
|
13352
|
+
insertionOrder.push({ type: "flat", op });
|
|
13353
|
+
}
|
|
13354
|
+
}
|
|
13355
|
+
const children = [];
|
|
13356
|
+
const allSlugs = /* @__PURE__ */ new Set();
|
|
13357
|
+
for (const entry of insertionOrder) {
|
|
13358
|
+
if (entry.type === "flat") {
|
|
13359
|
+
const fp = entry.op.fieldPath;
|
|
13360
|
+
allSlugs.add(fp != null && fp.length > 0 ? [...fp, entry.op.name].join("-") : entry.op.name);
|
|
13361
|
+
} else {
|
|
13362
|
+
allSlugs.add(entry.parentField);
|
|
13363
|
+
}
|
|
13364
|
+
}
|
|
13365
|
+
for (const entry of insertionOrder) {
|
|
13366
|
+
if (entry.type === "flat") {
|
|
13367
|
+
const opId = ApiDefinitionHolder.createGraphQlOperationId(entry.op);
|
|
13368
|
+
children.push(this.convertGraphQlNode(opId, entry.op, parentSlug));
|
|
13369
|
+
} else {
|
|
13370
|
+
const operations = groupedByParent.get(entry.parentField);
|
|
13371
|
+
if (operations == null) {
|
|
13372
|
+
continue;
|
|
13373
|
+
}
|
|
13374
|
+
const firstOp = operations[0];
|
|
13375
|
+
const opId = ApiDefinitionHolder.createGraphQlOperationId(firstOp);
|
|
13376
|
+
const allOpIds = operations.map((op) => ApiDefinitionHolder.createGraphQlOperationId(op));
|
|
13377
|
+
let slugSegment = entry.parentField;
|
|
13378
|
+
const flatHasSameSlug = insertionOrder.some(
|
|
13379
|
+
(e) => e.type === "flat" && (() => {
|
|
13380
|
+
const fp = e.op.fieldPath;
|
|
13381
|
+
const s = fp != null && fp.length > 0 ? [...fp, e.op.name].join("-") : e.op.name;
|
|
13382
|
+
return s === slugSegment;
|
|
13383
|
+
})()
|
|
13384
|
+
);
|
|
13385
|
+
if (flatHasSameSlug) {
|
|
13386
|
+
slugSegment = `${entry.parentField}-fields`;
|
|
13387
|
+
}
|
|
13388
|
+
children.push(
|
|
13389
|
+
this.#idgen.with(opId, (id) => ({
|
|
13390
|
+
id,
|
|
13391
|
+
type: "graphql",
|
|
13392
|
+
title: entry.parentField,
|
|
13393
|
+
graphqlOperationId: opId,
|
|
13394
|
+
graphqlOperationIds: allOpIds.length > 1 ? allOpIds : void 0,
|
|
13395
|
+
slug: parentSlug.apply({ urlSlug: slugSegment }).get(),
|
|
13396
|
+
icon: void 0,
|
|
13397
|
+
hidden: void 0,
|
|
13398
|
+
operationType: firstOp.operationType,
|
|
13399
|
+
apiDefinitionId: this.apiDefinitionId,
|
|
13400
|
+
availability: navigation_exports.V1.convertAvailability(firstOp.availability),
|
|
13401
|
+
playground: void 0,
|
|
13402
|
+
authed: void 0,
|
|
13403
|
+
collapsed: void 0,
|
|
13404
|
+
viewers: void 0,
|
|
13405
|
+
orphaned: void 0,
|
|
13406
|
+
featureFlags: void 0
|
|
13407
|
+
}))
|
|
13408
|
+
);
|
|
13409
|
+
}
|
|
13410
|
+
}
|
|
13411
|
+
return children;
|
|
13412
|
+
}
|
|
13290
13413
|
convertPackageToChildren(package_, parentSlug) {
|
|
13291
13414
|
const children = [];
|
|
13292
13415
|
let subpackageId = isSubpackage2(package_) ? package_.subpackageId : "__package__";
|
|
@@ -13334,14 +13457,7 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
13334
13457
|
children.push(this.convertWebhookNode(webhookId, webhook, parentSlug));
|
|
13335
13458
|
this.#visitedWebhooks.add(webhookId);
|
|
13336
13459
|
});
|
|
13337
|
-
(package_.graphqlOperations ?? [])
|
|
13338
|
-
const graphqlOperationId = ApiDefinitionHolder.createGraphQlOperationId(graphqlOperation);
|
|
13339
|
-
if (this.#visitedGraphqlOperations.has(graphqlOperationId)) {
|
|
13340
|
-
return;
|
|
13341
|
-
}
|
|
13342
|
-
children.push(this.convertGraphQlNode(graphqlOperationId, graphqlOperation, parentSlug));
|
|
13343
|
-
this.#visitedGraphqlOperations.add(graphqlOperationId);
|
|
13344
|
-
});
|
|
13460
|
+
children.push(...this.convertGraphQlOperationsToChildren(package_.graphqlOperations ?? [], parentSlug));
|
|
13345
13461
|
(package_.subpackages ?? []).forEach((subpackageId2) => {
|
|
13346
13462
|
const subpackage = this.api.subpackages[subpackageId2];
|
|
13347
13463
|
if (subpackage == null) {
|
|
@@ -15284,6 +15400,7 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
|
|
|
15284
15400
|
collapsed: node.collapsed,
|
|
15285
15401
|
apiDefinitionId: node.apiDefinitionId,
|
|
15286
15402
|
graphqlOperationId: node.graphqlOperationId,
|
|
15403
|
+
graphqlOperationIds: node.graphqlOperationIds,
|
|
15287
15404
|
operationType: node.operationType,
|
|
15288
15405
|
playground: node.playground,
|
|
15289
15406
|
availability: this.#availability(node.availability),
|