@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
package/dist/js/index.mjs
CHANGED
|
@@ -1474,6 +1474,7 @@ var GraphQlOperationSchema = z2.object({
|
|
|
1474
1474
|
operationType: GraphQlOperationTypeSchema,
|
|
1475
1475
|
name: z2.string(),
|
|
1476
1476
|
displayName: z2.string().nullish(),
|
|
1477
|
+
fieldPath: z2.array(z2.string()).nullish(),
|
|
1477
1478
|
arguments: z2.array(GraphQlArgumentSchema).nullish(),
|
|
1478
1479
|
returnType: TypeReferenceSchema,
|
|
1479
1480
|
examples: z2.array(GraphQlExampleSchema).nullish(),
|
|
@@ -2277,6 +2278,7 @@ var LatestGraphQlOperationSchema = z4.object({
|
|
|
2277
2278
|
description: z4.string().nullish(),
|
|
2278
2279
|
availability: AvailabilitySchema.nullish(),
|
|
2279
2280
|
namespace: z4.array(z4.string()).nullish(),
|
|
2281
|
+
fieldPath: z4.array(z4.string()).nullish(),
|
|
2280
2282
|
id: GraphQlOperationIdSchema,
|
|
2281
2283
|
operationType: LatestGraphQlOperationTypeSchema,
|
|
2282
2284
|
name: z4.string(),
|
|
@@ -3178,10 +3180,13 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
|
|
|
3178
3180
|
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
3179
3181
|
}
|
|
3180
3182
|
} else if (node.type === "graphql") {
|
|
3181
|
-
const
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
found
|
|
3183
|
+
const idsToInclude = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
3184
|
+
for (const opId of idsToInclude) {
|
|
3185
|
+
const found = this.api.graphqlOperations[opId];
|
|
3186
|
+
if (found) {
|
|
3187
|
+
toRet.graphqlOperations[opId] = found;
|
|
3188
|
+
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
3189
|
+
}
|
|
3185
3190
|
}
|
|
3186
3191
|
}
|
|
3187
3192
|
}
|
|
@@ -3483,9 +3488,21 @@ function createGraphqlContext(node, apiDefinition) {
|
|
|
3483
3488
|
);
|
|
3484
3489
|
return void 0;
|
|
3485
3490
|
}
|
|
3491
|
+
const allIds = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
3492
|
+
const operations = [];
|
|
3493
|
+
for (const id of allIds) {
|
|
3494
|
+
const op = api2.graphqlOperations[id];
|
|
3495
|
+
if (op) {
|
|
3496
|
+
operations.push(op);
|
|
3497
|
+
}
|
|
3498
|
+
}
|
|
3499
|
+
if (operations.length === 0) {
|
|
3500
|
+
operations.push(operation);
|
|
3501
|
+
}
|
|
3486
3502
|
return {
|
|
3487
3503
|
node,
|
|
3488
3504
|
operation,
|
|
3505
|
+
operations,
|
|
3489
3506
|
types: api2.types
|
|
3490
3507
|
};
|
|
3491
3508
|
}
|
|
@@ -5097,6 +5114,7 @@ var ApiDefinitionV1ToLatest = class _ApiDefinitionV1ToLatest {
|
|
|
5097
5114
|
description: v1?.description,
|
|
5098
5115
|
availability: v1?.availability,
|
|
5099
5116
|
namespace,
|
|
5117
|
+
fieldPath: v1?.fieldPath,
|
|
5100
5118
|
arguments: v1?.arguments?.map((arg) => this.migrateGraphQlArgument(arg)),
|
|
5101
5119
|
returnType: {
|
|
5102
5120
|
type: "alias",
|
|
@@ -5393,7 +5411,10 @@ function generateGraphQlSnippet(context) {
|
|
|
5393
5411
|
return `$${arg.name}: ${graphqlType}`;
|
|
5394
5412
|
});
|
|
5395
5413
|
const argumentUsage = args.map((arg) => `${arg.name}: $${arg.name}`);
|
|
5396
|
-
const
|
|
5414
|
+
const fieldPath = operation.fieldPath;
|
|
5415
|
+
const hasFieldPath = fieldPath != null && fieldPath.length > 0;
|
|
5416
|
+
const selectionSetIndent = hasFieldPath ? 2 + fieldPath.length : 2;
|
|
5417
|
+
const selectionSet = generateSelectionSet(operation.returnType, types, 2, /* @__PURE__ */ new Set(), selectionSetIndent);
|
|
5397
5418
|
let query = operationKeyword;
|
|
5398
5419
|
if (operationName || variableDefinitions.length > 0) {
|
|
5399
5420
|
query += ` ${operationName}`;
|
|
@@ -5402,15 +5423,32 @@ function generateGraphQlSnippet(context) {
|
|
|
5402
5423
|
}
|
|
5403
5424
|
}
|
|
5404
5425
|
query += " {\n";
|
|
5405
|
-
|
|
5426
|
+
const baseIndent = 2;
|
|
5427
|
+
if (hasFieldPath) {
|
|
5428
|
+
for (let i = 0; i < fieldPath.length; i++) {
|
|
5429
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
5430
|
+
query += `${indent}${fieldPath[i]} {
|
|
5431
|
+
`;
|
|
5432
|
+
}
|
|
5433
|
+
}
|
|
5434
|
+
const operationIndent = hasFieldPath ? " ".repeat(baseIndent + fieldPath.length * 2) : " ";
|
|
5435
|
+
query += `${operationIndent}${operation.name}`;
|
|
5406
5436
|
if (argumentUsage.length > 0) {
|
|
5407
5437
|
query += `(${argumentUsage.join(", ")})`;
|
|
5408
5438
|
}
|
|
5409
5439
|
if (selectionSet) {
|
|
5410
5440
|
query += ` ${selectionSet}`;
|
|
5411
5441
|
}
|
|
5412
|
-
query += "\n
|
|
5413
|
-
|
|
5442
|
+
query += "\n";
|
|
5443
|
+
if (hasFieldPath) {
|
|
5444
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
5445
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
5446
|
+
query += `${indent}}
|
|
5447
|
+
`;
|
|
5448
|
+
}
|
|
5449
|
+
}
|
|
5450
|
+
query += "}";
|
|
5451
|
+
const response = generateResponseExample(operation.name, operation.returnType, types, fieldPath);
|
|
5414
5452
|
const result = { query, variables, response };
|
|
5415
5453
|
snippetCache.set(operation, result);
|
|
5416
5454
|
return result;
|
|
@@ -5694,13 +5732,18 @@ function generateSelectionSetFromReference(ref, types, depth, visited, indentLev
|
|
|
5694
5732
|
return "";
|
|
5695
5733
|
}
|
|
5696
5734
|
}
|
|
5697
|
-
function generateResponseExample(operationName, returnType, types) {
|
|
5735
|
+
function generateResponseExample(operationName, returnType, types, fieldPath) {
|
|
5698
5736
|
const data = generateResponseData(returnType, types, 3, /* @__PURE__ */ new Set());
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5737
|
+
let responseData = { [operationName]: data };
|
|
5738
|
+
if (fieldPath != null && fieldPath.length > 0) {
|
|
5739
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
5740
|
+
const key = fieldPath[i];
|
|
5741
|
+
if (key != null) {
|
|
5742
|
+
responseData = { [key]: responseData };
|
|
5743
|
+
}
|
|
5702
5744
|
}
|
|
5703
|
-
}
|
|
5745
|
+
}
|
|
5746
|
+
return { data: responseData };
|
|
5704
5747
|
}
|
|
5705
5748
|
function generateResponseData(shape, types, depth, visited) {
|
|
5706
5749
|
if (depth <= 0) {
|
|
@@ -15943,11 +15986,8 @@ var ApiDefinitionPruner2 = class {
|
|
|
15943
15986
|
if (node.type !== "graphql" || graphqlOperations == null) {
|
|
15944
15987
|
return [];
|
|
15945
15988
|
}
|
|
15946
|
-
const
|
|
15947
|
-
|
|
15948
|
-
(graphqlOperation) => ApiDefinitionHolder.createGraphQlOperationId(graphqlOperation) === graphqlOperationId
|
|
15949
|
-
);
|
|
15950
|
-
return found ? [found] : [];
|
|
15989
|
+
const idsToInclude = new Set(node.graphqlOperationIds ?? [node.graphqlOperationId]);
|
|
15990
|
+
return graphqlOperations.filter((op) => idsToInclude.has(ApiDefinitionHolder.createGraphQlOperationId(op)));
|
|
15951
15991
|
}
|
|
15952
15992
|
};
|
|
15953
15993
|
|
|
@@ -16671,12 +16711,15 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
16671
16711
|
}));
|
|
16672
16712
|
}
|
|
16673
16713
|
convertGraphQlNode(graphqlOperationId, graphqlOperation, parentSlug) {
|
|
16714
|
+
const fieldPath = graphqlOperation.fieldPath;
|
|
16715
|
+
const urlSlug = fieldPath != null && fieldPath.length > 0 ? [...fieldPath, graphqlOperation.name].join("-") : graphqlOperation.name;
|
|
16674
16716
|
return this.#idgen.with(graphqlOperationId, (id) => ({
|
|
16675
16717
|
id,
|
|
16676
16718
|
type: "graphql",
|
|
16677
16719
|
title: graphqlOperation.displayName ?? graphqlOperation.name,
|
|
16678
16720
|
graphqlOperationId,
|
|
16679
|
-
|
|
16721
|
+
graphqlOperationIds: void 0,
|
|
16722
|
+
slug: parentSlug.apply({ urlSlug }).get(),
|
|
16680
16723
|
icon: void 0,
|
|
16681
16724
|
hidden: void 0,
|
|
16682
16725
|
operationType: graphqlOperation.operationType,
|
|
@@ -16690,6 +16733,86 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
16690
16733
|
featureFlags: void 0
|
|
16691
16734
|
}));
|
|
16692
16735
|
}
|
|
16736
|
+
convertGraphQlOperationsToChildren(graphqlOperations, parentSlug) {
|
|
16737
|
+
const groupedByParent = /* @__PURE__ */ new Map();
|
|
16738
|
+
const insertionOrder = [];
|
|
16739
|
+
for (const op of graphqlOperations) {
|
|
16740
|
+
const graphqlOperationId = ApiDefinitionHolder.createGraphQlOperationId(op);
|
|
16741
|
+
if (this.#visitedGraphqlOperations.has(graphqlOperationId)) {
|
|
16742
|
+
continue;
|
|
16743
|
+
}
|
|
16744
|
+
this.#visitedGraphqlOperations.add(graphqlOperationId);
|
|
16745
|
+
const parentField = op.fieldPath?.[0];
|
|
16746
|
+
if (parentField != null && op.operationType === "QUERY") {
|
|
16747
|
+
const group = groupedByParent.get(parentField);
|
|
16748
|
+
if (group != null) {
|
|
16749
|
+
group.push(op);
|
|
16750
|
+
} else {
|
|
16751
|
+
groupedByParent.set(parentField, [op]);
|
|
16752
|
+
insertionOrder.push({ type: "group", parentField });
|
|
16753
|
+
}
|
|
16754
|
+
} else {
|
|
16755
|
+
insertionOrder.push({ type: "flat", op });
|
|
16756
|
+
}
|
|
16757
|
+
}
|
|
16758
|
+
const children = [];
|
|
16759
|
+
const allSlugs = /* @__PURE__ */ new Set();
|
|
16760
|
+
for (const entry of insertionOrder) {
|
|
16761
|
+
if (entry.type === "flat") {
|
|
16762
|
+
const fp = entry.op.fieldPath;
|
|
16763
|
+
allSlugs.add(fp != null && fp.length > 0 ? [...fp, entry.op.name].join("-") : entry.op.name);
|
|
16764
|
+
} else {
|
|
16765
|
+
allSlugs.add(entry.parentField);
|
|
16766
|
+
}
|
|
16767
|
+
}
|
|
16768
|
+
for (const entry of insertionOrder) {
|
|
16769
|
+
if (entry.type === "flat") {
|
|
16770
|
+
const opId = ApiDefinitionHolder.createGraphQlOperationId(entry.op);
|
|
16771
|
+
children.push(this.convertGraphQlNode(opId, entry.op, parentSlug));
|
|
16772
|
+
} else {
|
|
16773
|
+
const operations = groupedByParent.get(entry.parentField);
|
|
16774
|
+
if (operations == null) {
|
|
16775
|
+
continue;
|
|
16776
|
+
}
|
|
16777
|
+
const firstOp = operations[0];
|
|
16778
|
+
const opId = ApiDefinitionHolder.createGraphQlOperationId(firstOp);
|
|
16779
|
+
const allOpIds = operations.map((op) => ApiDefinitionHolder.createGraphQlOperationId(op));
|
|
16780
|
+
let slugSegment = entry.parentField;
|
|
16781
|
+
const flatHasSameSlug = insertionOrder.some(
|
|
16782
|
+
(e) => e.type === "flat" && (() => {
|
|
16783
|
+
const fp = e.op.fieldPath;
|
|
16784
|
+
const s = fp != null && fp.length > 0 ? [...fp, e.op.name].join("-") : e.op.name;
|
|
16785
|
+
return s === slugSegment;
|
|
16786
|
+
})()
|
|
16787
|
+
);
|
|
16788
|
+
if (flatHasSameSlug) {
|
|
16789
|
+
slugSegment = `${entry.parentField}-fields`;
|
|
16790
|
+
}
|
|
16791
|
+
children.push(
|
|
16792
|
+
this.#idgen.with(opId, (id) => ({
|
|
16793
|
+
id,
|
|
16794
|
+
type: "graphql",
|
|
16795
|
+
title: entry.parentField,
|
|
16796
|
+
graphqlOperationId: opId,
|
|
16797
|
+
graphqlOperationIds: allOpIds.length > 1 ? allOpIds : void 0,
|
|
16798
|
+
slug: parentSlug.apply({ urlSlug: slugSegment }).get(),
|
|
16799
|
+
icon: void 0,
|
|
16800
|
+
hidden: void 0,
|
|
16801
|
+
operationType: firstOp.operationType,
|
|
16802
|
+
apiDefinitionId: this.apiDefinitionId,
|
|
16803
|
+
availability: navigation_exports.V1.convertAvailability(firstOp.availability),
|
|
16804
|
+
playground: void 0,
|
|
16805
|
+
authed: void 0,
|
|
16806
|
+
collapsed: void 0,
|
|
16807
|
+
viewers: void 0,
|
|
16808
|
+
orphaned: void 0,
|
|
16809
|
+
featureFlags: void 0
|
|
16810
|
+
}))
|
|
16811
|
+
);
|
|
16812
|
+
}
|
|
16813
|
+
}
|
|
16814
|
+
return children;
|
|
16815
|
+
}
|
|
16693
16816
|
convertPackageToChildren(package_, parentSlug) {
|
|
16694
16817
|
const children = [];
|
|
16695
16818
|
let subpackageId = isSubpackage2(package_) ? package_.subpackageId : "__package__";
|
|
@@ -16737,14 +16860,7 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
16737
16860
|
children.push(this.convertWebhookNode(webhookId, webhook, parentSlug));
|
|
16738
16861
|
this.#visitedWebhooks.add(webhookId);
|
|
16739
16862
|
});
|
|
16740
|
-
(package_.graphqlOperations ?? [])
|
|
16741
|
-
const graphqlOperationId = ApiDefinitionHolder.createGraphQlOperationId(graphqlOperation);
|
|
16742
|
-
if (this.#visitedGraphqlOperations.has(graphqlOperationId)) {
|
|
16743
|
-
return;
|
|
16744
|
-
}
|
|
16745
|
-
children.push(this.convertGraphQlNode(graphqlOperationId, graphqlOperation, parentSlug));
|
|
16746
|
-
this.#visitedGraphqlOperations.add(graphqlOperationId);
|
|
16747
|
-
});
|
|
16863
|
+
children.push(...this.convertGraphQlOperationsToChildren(package_.graphqlOperations ?? [], parentSlug));
|
|
16748
16864
|
(package_.subpackages ?? []).forEach((subpackageId2) => {
|
|
16749
16865
|
const subpackage = this.api.subpackages[subpackageId2];
|
|
16750
16866
|
if (subpackage == null) {
|
|
@@ -18687,6 +18803,7 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
|
|
|
18687
18803
|
collapsed: node.collapsed,
|
|
18688
18804
|
apiDefinitionId: node.apiDefinitionId,
|
|
18689
18805
|
graphqlOperationId: node.graphqlOperationId,
|
|
18806
|
+
graphqlOperationIds: node.graphqlOperationIds,
|
|
18690
18807
|
operationType: node.operationType,
|
|
18691
18808
|
playground: node.playground,
|
|
18692
18809
|
availability: this.#availability(node.availability),
|