@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.js
CHANGED
|
@@ -1537,6 +1537,7 @@ var GraphQlOperationSchema = z2.object({
|
|
|
1537
1537
|
operationType: GraphQlOperationTypeSchema,
|
|
1538
1538
|
name: z2.string(),
|
|
1539
1539
|
displayName: z2.string().nullish(),
|
|
1540
|
+
fieldPath: z2.array(z2.string()).nullish(),
|
|
1540
1541
|
arguments: z2.array(GraphQlArgumentSchema).nullish(),
|
|
1541
1542
|
returnType: TypeReferenceSchema,
|
|
1542
1543
|
examples: z2.array(GraphQlExampleSchema).nullish(),
|
|
@@ -2340,6 +2341,7 @@ var LatestGraphQlOperationSchema = z4.object({
|
|
|
2340
2341
|
description: z4.string().nullish(),
|
|
2341
2342
|
availability: AvailabilitySchema.nullish(),
|
|
2342
2343
|
namespace: z4.array(z4.string()).nullish(),
|
|
2344
|
+
fieldPath: z4.array(z4.string()).nullish(),
|
|
2343
2345
|
id: GraphQlOperationIdSchema,
|
|
2344
2346
|
operationType: LatestGraphQlOperationTypeSchema,
|
|
2345
2347
|
name: z4.string(),
|
|
@@ -3241,10 +3243,13 @@ var ApiDefinitionPruner = class _ApiDefinitionPruner {
|
|
|
3241
3243
|
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
3242
3244
|
}
|
|
3243
3245
|
} else if (node.type === "graphql") {
|
|
3244
|
-
const
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
found
|
|
3246
|
+
const idsToInclude = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
3247
|
+
for (const opId of idsToInclude) {
|
|
3248
|
+
const found = this.api.graphqlOperations[opId];
|
|
3249
|
+
if (found) {
|
|
3250
|
+
toRet.graphqlOperations[opId] = found;
|
|
3251
|
+
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
3252
|
+
}
|
|
3248
3253
|
}
|
|
3249
3254
|
}
|
|
3250
3255
|
}
|
|
@@ -3546,9 +3551,21 @@ function createGraphqlContext(node, apiDefinition) {
|
|
|
3546
3551
|
);
|
|
3547
3552
|
return void 0;
|
|
3548
3553
|
}
|
|
3554
|
+
const allIds = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
3555
|
+
const operations = [];
|
|
3556
|
+
for (const id of allIds) {
|
|
3557
|
+
const op = api2.graphqlOperations[id];
|
|
3558
|
+
if (op) {
|
|
3559
|
+
operations.push(op);
|
|
3560
|
+
}
|
|
3561
|
+
}
|
|
3562
|
+
if (operations.length === 0) {
|
|
3563
|
+
operations.push(operation);
|
|
3564
|
+
}
|
|
3549
3565
|
return {
|
|
3550
3566
|
node,
|
|
3551
3567
|
operation,
|
|
3568
|
+
operations,
|
|
3552
3569
|
types: api2.types
|
|
3553
3570
|
};
|
|
3554
3571
|
}
|
|
@@ -5160,6 +5177,7 @@ var ApiDefinitionV1ToLatest = class _ApiDefinitionV1ToLatest {
|
|
|
5160
5177
|
description: v1?.description,
|
|
5161
5178
|
availability: v1?.availability,
|
|
5162
5179
|
namespace,
|
|
5180
|
+
fieldPath: v1?.fieldPath,
|
|
5163
5181
|
arguments: v1?.arguments?.map((arg) => this.migrateGraphQlArgument(arg)),
|
|
5164
5182
|
returnType: {
|
|
5165
5183
|
type: "alias",
|
|
@@ -5456,7 +5474,10 @@ function generateGraphQlSnippet(context) {
|
|
|
5456
5474
|
return `$${arg.name}: ${graphqlType}`;
|
|
5457
5475
|
});
|
|
5458
5476
|
const argumentUsage = args.map((arg) => `${arg.name}: $${arg.name}`);
|
|
5459
|
-
const
|
|
5477
|
+
const fieldPath = operation.fieldPath;
|
|
5478
|
+
const hasFieldPath = fieldPath != null && fieldPath.length > 0;
|
|
5479
|
+
const selectionSetIndent = hasFieldPath ? 2 + fieldPath.length : 2;
|
|
5480
|
+
const selectionSet = generateSelectionSet(operation.returnType, types, 2, /* @__PURE__ */ new Set(), selectionSetIndent);
|
|
5460
5481
|
let query = operationKeyword;
|
|
5461
5482
|
if (operationName || variableDefinitions.length > 0) {
|
|
5462
5483
|
query += ` ${operationName}`;
|
|
@@ -5465,15 +5486,32 @@ function generateGraphQlSnippet(context) {
|
|
|
5465
5486
|
}
|
|
5466
5487
|
}
|
|
5467
5488
|
query += " {\n";
|
|
5468
|
-
|
|
5489
|
+
const baseIndent = 2;
|
|
5490
|
+
if (hasFieldPath) {
|
|
5491
|
+
for (let i = 0; i < fieldPath.length; i++) {
|
|
5492
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
5493
|
+
query += `${indent}${fieldPath[i]} {
|
|
5494
|
+
`;
|
|
5495
|
+
}
|
|
5496
|
+
}
|
|
5497
|
+
const operationIndent = hasFieldPath ? " ".repeat(baseIndent + fieldPath.length * 2) : " ";
|
|
5498
|
+
query += `${operationIndent}${operation.name}`;
|
|
5469
5499
|
if (argumentUsage.length > 0) {
|
|
5470
5500
|
query += `(${argumentUsage.join(", ")})`;
|
|
5471
5501
|
}
|
|
5472
5502
|
if (selectionSet) {
|
|
5473
5503
|
query += ` ${selectionSet}`;
|
|
5474
5504
|
}
|
|
5475
|
-
query += "\n
|
|
5476
|
-
|
|
5505
|
+
query += "\n";
|
|
5506
|
+
if (hasFieldPath) {
|
|
5507
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
5508
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
5509
|
+
query += `${indent}}
|
|
5510
|
+
`;
|
|
5511
|
+
}
|
|
5512
|
+
}
|
|
5513
|
+
query += "}";
|
|
5514
|
+
const response = generateResponseExample(operation.name, operation.returnType, types, fieldPath);
|
|
5477
5515
|
const result = { query, variables, response };
|
|
5478
5516
|
snippetCache.set(operation, result);
|
|
5479
5517
|
return result;
|
|
@@ -5757,13 +5795,18 @@ function generateSelectionSetFromReference(ref, types, depth, visited, indentLev
|
|
|
5757
5795
|
return "";
|
|
5758
5796
|
}
|
|
5759
5797
|
}
|
|
5760
|
-
function generateResponseExample(operationName, returnType, types) {
|
|
5798
|
+
function generateResponseExample(operationName, returnType, types, fieldPath) {
|
|
5761
5799
|
const data = generateResponseData(returnType, types, 3, /* @__PURE__ */ new Set());
|
|
5762
|
-
|
|
5763
|
-
|
|
5764
|
-
|
|
5800
|
+
let responseData = { [operationName]: data };
|
|
5801
|
+
if (fieldPath != null && fieldPath.length > 0) {
|
|
5802
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
5803
|
+
const key = fieldPath[i];
|
|
5804
|
+
if (key != null) {
|
|
5805
|
+
responseData = { [key]: responseData };
|
|
5806
|
+
}
|
|
5765
5807
|
}
|
|
5766
|
-
}
|
|
5808
|
+
}
|
|
5809
|
+
return { data: responseData };
|
|
5767
5810
|
}
|
|
5768
5811
|
function generateResponseData(shape, types, depth, visited) {
|
|
5769
5812
|
if (depth <= 0) {
|
|
@@ -16006,11 +16049,8 @@ var ApiDefinitionPruner2 = class {
|
|
|
16006
16049
|
if (node.type !== "graphql" || graphqlOperations == null) {
|
|
16007
16050
|
return [];
|
|
16008
16051
|
}
|
|
16009
|
-
const
|
|
16010
|
-
|
|
16011
|
-
(graphqlOperation) => ApiDefinitionHolder.createGraphQlOperationId(graphqlOperation) === graphqlOperationId
|
|
16012
|
-
);
|
|
16013
|
-
return found ? [found] : [];
|
|
16052
|
+
const idsToInclude = new Set(node.graphqlOperationIds ?? [node.graphqlOperationId]);
|
|
16053
|
+
return graphqlOperations.filter((op) => idsToInclude.has(ApiDefinitionHolder.createGraphQlOperationId(op)));
|
|
16014
16054
|
}
|
|
16015
16055
|
};
|
|
16016
16056
|
|
|
@@ -16734,12 +16774,15 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
16734
16774
|
}));
|
|
16735
16775
|
}
|
|
16736
16776
|
convertGraphQlNode(graphqlOperationId, graphqlOperation, parentSlug) {
|
|
16777
|
+
const fieldPath = graphqlOperation.fieldPath;
|
|
16778
|
+
const urlSlug = fieldPath != null && fieldPath.length > 0 ? [...fieldPath, graphqlOperation.name].join("-") : graphqlOperation.name;
|
|
16737
16779
|
return this.#idgen.with(graphqlOperationId, (id) => ({
|
|
16738
16780
|
id,
|
|
16739
16781
|
type: "graphql",
|
|
16740
16782
|
title: graphqlOperation.displayName ?? graphqlOperation.name,
|
|
16741
16783
|
graphqlOperationId,
|
|
16742
|
-
|
|
16784
|
+
graphqlOperationIds: void 0,
|
|
16785
|
+
slug: parentSlug.apply({ urlSlug }).get(),
|
|
16743
16786
|
icon: void 0,
|
|
16744
16787
|
hidden: void 0,
|
|
16745
16788
|
operationType: graphqlOperation.operationType,
|
|
@@ -16753,6 +16796,86 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
16753
16796
|
featureFlags: void 0
|
|
16754
16797
|
}));
|
|
16755
16798
|
}
|
|
16799
|
+
convertGraphQlOperationsToChildren(graphqlOperations, parentSlug) {
|
|
16800
|
+
const groupedByParent = /* @__PURE__ */ new Map();
|
|
16801
|
+
const insertionOrder = [];
|
|
16802
|
+
for (const op of graphqlOperations) {
|
|
16803
|
+
const graphqlOperationId = ApiDefinitionHolder.createGraphQlOperationId(op);
|
|
16804
|
+
if (this.#visitedGraphqlOperations.has(graphqlOperationId)) {
|
|
16805
|
+
continue;
|
|
16806
|
+
}
|
|
16807
|
+
this.#visitedGraphqlOperations.add(graphqlOperationId);
|
|
16808
|
+
const parentField = op.fieldPath?.[0];
|
|
16809
|
+
if (parentField != null && op.operationType === "QUERY") {
|
|
16810
|
+
const group = groupedByParent.get(parentField);
|
|
16811
|
+
if (group != null) {
|
|
16812
|
+
group.push(op);
|
|
16813
|
+
} else {
|
|
16814
|
+
groupedByParent.set(parentField, [op]);
|
|
16815
|
+
insertionOrder.push({ type: "group", parentField });
|
|
16816
|
+
}
|
|
16817
|
+
} else {
|
|
16818
|
+
insertionOrder.push({ type: "flat", op });
|
|
16819
|
+
}
|
|
16820
|
+
}
|
|
16821
|
+
const children = [];
|
|
16822
|
+
const allSlugs = /* @__PURE__ */ new Set();
|
|
16823
|
+
for (const entry of insertionOrder) {
|
|
16824
|
+
if (entry.type === "flat") {
|
|
16825
|
+
const fp = entry.op.fieldPath;
|
|
16826
|
+
allSlugs.add(fp != null && fp.length > 0 ? [...fp, entry.op.name].join("-") : entry.op.name);
|
|
16827
|
+
} else {
|
|
16828
|
+
allSlugs.add(entry.parentField);
|
|
16829
|
+
}
|
|
16830
|
+
}
|
|
16831
|
+
for (const entry of insertionOrder) {
|
|
16832
|
+
if (entry.type === "flat") {
|
|
16833
|
+
const opId = ApiDefinitionHolder.createGraphQlOperationId(entry.op);
|
|
16834
|
+
children.push(this.convertGraphQlNode(opId, entry.op, parentSlug));
|
|
16835
|
+
} else {
|
|
16836
|
+
const operations = groupedByParent.get(entry.parentField);
|
|
16837
|
+
if (operations == null) {
|
|
16838
|
+
continue;
|
|
16839
|
+
}
|
|
16840
|
+
const firstOp = operations[0];
|
|
16841
|
+
const opId = ApiDefinitionHolder.createGraphQlOperationId(firstOp);
|
|
16842
|
+
const allOpIds = operations.map((op) => ApiDefinitionHolder.createGraphQlOperationId(op));
|
|
16843
|
+
let slugSegment = entry.parentField;
|
|
16844
|
+
const flatHasSameSlug = insertionOrder.some(
|
|
16845
|
+
(e) => e.type === "flat" && (() => {
|
|
16846
|
+
const fp = e.op.fieldPath;
|
|
16847
|
+
const s = fp != null && fp.length > 0 ? [...fp, e.op.name].join("-") : e.op.name;
|
|
16848
|
+
return s === slugSegment;
|
|
16849
|
+
})()
|
|
16850
|
+
);
|
|
16851
|
+
if (flatHasSameSlug) {
|
|
16852
|
+
slugSegment = `${entry.parentField}-fields`;
|
|
16853
|
+
}
|
|
16854
|
+
children.push(
|
|
16855
|
+
this.#idgen.with(opId, (id) => ({
|
|
16856
|
+
id,
|
|
16857
|
+
type: "graphql",
|
|
16858
|
+
title: entry.parentField,
|
|
16859
|
+
graphqlOperationId: opId,
|
|
16860
|
+
graphqlOperationIds: allOpIds.length > 1 ? allOpIds : void 0,
|
|
16861
|
+
slug: parentSlug.apply({ urlSlug: slugSegment }).get(),
|
|
16862
|
+
icon: void 0,
|
|
16863
|
+
hidden: void 0,
|
|
16864
|
+
operationType: firstOp.operationType,
|
|
16865
|
+
apiDefinitionId: this.apiDefinitionId,
|
|
16866
|
+
availability: navigation_exports.V1.convertAvailability(firstOp.availability),
|
|
16867
|
+
playground: void 0,
|
|
16868
|
+
authed: void 0,
|
|
16869
|
+
collapsed: void 0,
|
|
16870
|
+
viewers: void 0,
|
|
16871
|
+
orphaned: void 0,
|
|
16872
|
+
featureFlags: void 0
|
|
16873
|
+
}))
|
|
16874
|
+
);
|
|
16875
|
+
}
|
|
16876
|
+
}
|
|
16877
|
+
return children;
|
|
16878
|
+
}
|
|
16756
16879
|
convertPackageToChildren(package_, parentSlug) {
|
|
16757
16880
|
const children = [];
|
|
16758
16881
|
let subpackageId = isSubpackage2(package_) ? package_.subpackageId : "__package__";
|
|
@@ -16800,14 +16923,7 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
16800
16923
|
children.push(this.convertWebhookNode(webhookId, webhook, parentSlug));
|
|
16801
16924
|
this.#visitedWebhooks.add(webhookId);
|
|
16802
16925
|
});
|
|
16803
|
-
(package_.graphqlOperations ?? [])
|
|
16804
|
-
const graphqlOperationId = ApiDefinitionHolder.createGraphQlOperationId(graphqlOperation);
|
|
16805
|
-
if (this.#visitedGraphqlOperations.has(graphqlOperationId)) {
|
|
16806
|
-
return;
|
|
16807
|
-
}
|
|
16808
|
-
children.push(this.convertGraphQlNode(graphqlOperationId, graphqlOperation, parentSlug));
|
|
16809
|
-
this.#visitedGraphqlOperations.add(graphqlOperationId);
|
|
16810
|
-
});
|
|
16926
|
+
children.push(...this.convertGraphQlOperationsToChildren(package_.graphqlOperations ?? [], parentSlug));
|
|
16811
16927
|
(package_.subpackages ?? []).forEach((subpackageId2) => {
|
|
16812
16928
|
const subpackage = this.api.subpackages[subpackageId2];
|
|
16813
16929
|
if (subpackage == null) {
|
|
@@ -18750,6 +18866,7 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
|
|
|
18750
18866
|
collapsed: node.collapsed,
|
|
18751
18867
|
apiDefinitionId: node.apiDefinitionId,
|
|
18752
18868
|
graphqlOperationId: node.graphqlOperationId,
|
|
18869
|
+
graphqlOperationIds: node.graphqlOperationIds,
|
|
18753
18870
|
operationType: node.operationType,
|
|
18754
18871
|
playground: node.playground,
|
|
18755
18872
|
availability: this.#availability(node.availability),
|