@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
|
@@ -775,6 +775,7 @@ var GraphQlOperationSchema = z2.object({
|
|
|
775
775
|
operationType: GraphQlOperationTypeSchema,
|
|
776
776
|
name: z2.string(),
|
|
777
777
|
displayName: z2.string().nullish(),
|
|
778
|
+
fieldPath: z2.array(z2.string()).nullish(),
|
|
778
779
|
arguments: z2.array(GraphQlArgumentSchema).nullish(),
|
|
779
780
|
returnType: TypeReferenceSchema,
|
|
780
781
|
examples: z2.array(GraphQlExampleSchema).nullish(),
|
|
@@ -2187,11 +2188,8 @@ var ApiDefinitionPruner = class {
|
|
|
2187
2188
|
if (node.type !== "graphql" || graphqlOperations == null) {
|
|
2188
2189
|
return [];
|
|
2189
2190
|
}
|
|
2190
|
-
const
|
|
2191
|
-
|
|
2192
|
-
(graphqlOperation) => ApiDefinitionHolder.createGraphQlOperationId(graphqlOperation) === graphqlOperationId
|
|
2193
|
-
);
|
|
2194
|
-
return found ? [found] : [];
|
|
2191
|
+
const idsToInclude = new Set(node.graphqlOperationIds ?? [node.graphqlOperationId]);
|
|
2192
|
+
return graphqlOperations.filter((op) => idsToInclude.has(ApiDefinitionHolder.createGraphQlOperationId(op)));
|
|
2195
2193
|
}
|
|
2196
2194
|
};
|
|
2197
2195
|
|
|
@@ -3100,6 +3098,7 @@ var LatestGraphQlOperationSchema = z4.object({
|
|
|
3100
3098
|
description: z4.string().nullish(),
|
|
3101
3099
|
availability: AvailabilitySchema.nullish(),
|
|
3102
3100
|
namespace: z4.array(z4.string()).nullish(),
|
|
3101
|
+
fieldPath: z4.array(z4.string()).nullish(),
|
|
3103
3102
|
id: GraphQlOperationIdSchema,
|
|
3104
3103
|
operationType: LatestGraphQlOperationTypeSchema,
|
|
3105
3104
|
name: z4.string(),
|
|
@@ -4001,10 +4000,13 @@ var ApiDefinitionPruner2 = class _ApiDefinitionPruner {
|
|
|
4001
4000
|
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
4002
4001
|
}
|
|
4003
4002
|
} else if (node.type === "graphql") {
|
|
4004
|
-
const
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
found
|
|
4003
|
+
const idsToInclude = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
4004
|
+
for (const opId of idsToInclude) {
|
|
4005
|
+
const found = this.api.graphqlOperations[opId];
|
|
4006
|
+
if (found) {
|
|
4007
|
+
toRet.graphqlOperations[opId] = found;
|
|
4008
|
+
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
4009
|
+
}
|
|
4008
4010
|
}
|
|
4009
4011
|
}
|
|
4010
4012
|
}
|
|
@@ -4306,9 +4308,21 @@ function createGraphqlContext(node, apiDefinition) {
|
|
|
4306
4308
|
);
|
|
4307
4309
|
return void 0;
|
|
4308
4310
|
}
|
|
4311
|
+
const allIds = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
4312
|
+
const operations = [];
|
|
4313
|
+
for (const id of allIds) {
|
|
4314
|
+
const op = api2.graphqlOperations[id];
|
|
4315
|
+
if (op) {
|
|
4316
|
+
operations.push(op);
|
|
4317
|
+
}
|
|
4318
|
+
}
|
|
4319
|
+
if (operations.length === 0) {
|
|
4320
|
+
operations.push(operation);
|
|
4321
|
+
}
|
|
4309
4322
|
return {
|
|
4310
4323
|
node,
|
|
4311
4324
|
operation,
|
|
4325
|
+
operations,
|
|
4312
4326
|
types: api2.types
|
|
4313
4327
|
};
|
|
4314
4328
|
}
|
|
@@ -5917,6 +5931,7 @@ var ApiDefinitionV1ToLatest = class _ApiDefinitionV1ToLatest {
|
|
|
5917
5931
|
description: v1?.description,
|
|
5918
5932
|
availability: v1?.availability,
|
|
5919
5933
|
namespace,
|
|
5934
|
+
fieldPath: v1?.fieldPath,
|
|
5920
5935
|
arguments: v1?.arguments?.map((arg) => this.migrateGraphQlArgument(arg)),
|
|
5921
5936
|
returnType: {
|
|
5922
5937
|
type: "alias",
|
|
@@ -6213,7 +6228,10 @@ function generateGraphQlSnippet(context) {
|
|
|
6213
6228
|
return `$${arg.name}: ${graphqlType}`;
|
|
6214
6229
|
});
|
|
6215
6230
|
const argumentUsage = args.map((arg) => `${arg.name}: $${arg.name}`);
|
|
6216
|
-
const
|
|
6231
|
+
const fieldPath = operation.fieldPath;
|
|
6232
|
+
const hasFieldPath = fieldPath != null && fieldPath.length > 0;
|
|
6233
|
+
const selectionSetIndent = hasFieldPath ? 2 + fieldPath.length : 2;
|
|
6234
|
+
const selectionSet = generateSelectionSet(operation.returnType, types, 2, /* @__PURE__ */ new Set(), selectionSetIndent);
|
|
6217
6235
|
let query = operationKeyword;
|
|
6218
6236
|
if (operationName || variableDefinitions.length > 0) {
|
|
6219
6237
|
query += ` ${operationName}`;
|
|
@@ -6222,15 +6240,32 @@ function generateGraphQlSnippet(context) {
|
|
|
6222
6240
|
}
|
|
6223
6241
|
}
|
|
6224
6242
|
query += " {\n";
|
|
6225
|
-
|
|
6243
|
+
const baseIndent = 2;
|
|
6244
|
+
if (hasFieldPath) {
|
|
6245
|
+
for (let i = 0; i < fieldPath.length; i++) {
|
|
6246
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
6247
|
+
query += `${indent}${fieldPath[i]} {
|
|
6248
|
+
`;
|
|
6249
|
+
}
|
|
6250
|
+
}
|
|
6251
|
+
const operationIndent = hasFieldPath ? " ".repeat(baseIndent + fieldPath.length * 2) : " ";
|
|
6252
|
+
query += `${operationIndent}${operation.name}`;
|
|
6226
6253
|
if (argumentUsage.length > 0) {
|
|
6227
6254
|
query += `(${argumentUsage.join(", ")})`;
|
|
6228
6255
|
}
|
|
6229
6256
|
if (selectionSet) {
|
|
6230
6257
|
query += ` ${selectionSet}`;
|
|
6231
6258
|
}
|
|
6232
|
-
query += "\n
|
|
6233
|
-
|
|
6259
|
+
query += "\n";
|
|
6260
|
+
if (hasFieldPath) {
|
|
6261
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
6262
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
6263
|
+
query += `${indent}}
|
|
6264
|
+
`;
|
|
6265
|
+
}
|
|
6266
|
+
}
|
|
6267
|
+
query += "}";
|
|
6268
|
+
const response = generateResponseExample(operation.name, operation.returnType, types, fieldPath);
|
|
6234
6269
|
const result = { query, variables, response };
|
|
6235
6270
|
snippetCache.set(operation, result);
|
|
6236
6271
|
return result;
|
|
@@ -6514,13 +6549,18 @@ function generateSelectionSetFromReference(ref, types, depth, visited, indentLev
|
|
|
6514
6549
|
return "";
|
|
6515
6550
|
}
|
|
6516
6551
|
}
|
|
6517
|
-
function generateResponseExample(operationName, returnType, types) {
|
|
6552
|
+
function generateResponseExample(operationName, returnType, types, fieldPath) {
|
|
6518
6553
|
const data = generateResponseData(returnType, types, 3, /* @__PURE__ */ new Set());
|
|
6519
|
-
|
|
6520
|
-
|
|
6521
|
-
|
|
6554
|
+
let responseData = { [operationName]: data };
|
|
6555
|
+
if (fieldPath != null && fieldPath.length > 0) {
|
|
6556
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
6557
|
+
const key = fieldPath[i];
|
|
6558
|
+
if (key != null) {
|
|
6559
|
+
responseData = { [key]: responseData };
|
|
6560
|
+
}
|
|
6522
6561
|
}
|
|
6523
|
-
}
|
|
6562
|
+
}
|
|
6563
|
+
return { data: responseData };
|
|
6524
6564
|
}
|
|
6525
6565
|
function generateResponseData(shape, types, depth, visited) {
|
|
6526
6566
|
if (depth <= 0) {
|
|
@@ -11932,12 +11972,15 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
11932
11972
|
}));
|
|
11933
11973
|
}
|
|
11934
11974
|
convertGraphQlNode(graphqlOperationId, graphqlOperation, parentSlug) {
|
|
11975
|
+
const fieldPath = graphqlOperation.fieldPath;
|
|
11976
|
+
const urlSlug = fieldPath != null && fieldPath.length > 0 ? [...fieldPath, graphqlOperation.name].join("-") : graphqlOperation.name;
|
|
11935
11977
|
return this.#idgen.with(graphqlOperationId, (id) => ({
|
|
11936
11978
|
id,
|
|
11937
11979
|
type: "graphql",
|
|
11938
11980
|
title: graphqlOperation.displayName ?? graphqlOperation.name,
|
|
11939
11981
|
graphqlOperationId,
|
|
11940
|
-
|
|
11982
|
+
graphqlOperationIds: void 0,
|
|
11983
|
+
slug: parentSlug.apply({ urlSlug }).get(),
|
|
11941
11984
|
icon: void 0,
|
|
11942
11985
|
hidden: void 0,
|
|
11943
11986
|
operationType: graphqlOperation.operationType,
|
|
@@ -11951,6 +11994,86 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
11951
11994
|
featureFlags: void 0
|
|
11952
11995
|
}));
|
|
11953
11996
|
}
|
|
11997
|
+
convertGraphQlOperationsToChildren(graphqlOperations, parentSlug) {
|
|
11998
|
+
const groupedByParent = /* @__PURE__ */ new Map();
|
|
11999
|
+
const insertionOrder = [];
|
|
12000
|
+
for (const op of graphqlOperations) {
|
|
12001
|
+
const graphqlOperationId = ApiDefinitionHolder.createGraphQlOperationId(op);
|
|
12002
|
+
if (this.#visitedGraphqlOperations.has(graphqlOperationId)) {
|
|
12003
|
+
continue;
|
|
12004
|
+
}
|
|
12005
|
+
this.#visitedGraphqlOperations.add(graphqlOperationId);
|
|
12006
|
+
const parentField = op.fieldPath?.[0];
|
|
12007
|
+
if (parentField != null && op.operationType === "QUERY") {
|
|
12008
|
+
const group = groupedByParent.get(parentField);
|
|
12009
|
+
if (group != null) {
|
|
12010
|
+
group.push(op);
|
|
12011
|
+
} else {
|
|
12012
|
+
groupedByParent.set(parentField, [op]);
|
|
12013
|
+
insertionOrder.push({ type: "group", parentField });
|
|
12014
|
+
}
|
|
12015
|
+
} else {
|
|
12016
|
+
insertionOrder.push({ type: "flat", op });
|
|
12017
|
+
}
|
|
12018
|
+
}
|
|
12019
|
+
const children = [];
|
|
12020
|
+
const allSlugs = /* @__PURE__ */ new Set();
|
|
12021
|
+
for (const entry of insertionOrder) {
|
|
12022
|
+
if (entry.type === "flat") {
|
|
12023
|
+
const fp = entry.op.fieldPath;
|
|
12024
|
+
allSlugs.add(fp != null && fp.length > 0 ? [...fp, entry.op.name].join("-") : entry.op.name);
|
|
12025
|
+
} else {
|
|
12026
|
+
allSlugs.add(entry.parentField);
|
|
12027
|
+
}
|
|
12028
|
+
}
|
|
12029
|
+
for (const entry of insertionOrder) {
|
|
12030
|
+
if (entry.type === "flat") {
|
|
12031
|
+
const opId = ApiDefinitionHolder.createGraphQlOperationId(entry.op);
|
|
12032
|
+
children.push(this.convertGraphQlNode(opId, entry.op, parentSlug));
|
|
12033
|
+
} else {
|
|
12034
|
+
const operations = groupedByParent.get(entry.parentField);
|
|
12035
|
+
if (operations == null) {
|
|
12036
|
+
continue;
|
|
12037
|
+
}
|
|
12038
|
+
const firstOp = operations[0];
|
|
12039
|
+
const opId = ApiDefinitionHolder.createGraphQlOperationId(firstOp);
|
|
12040
|
+
const allOpIds = operations.map((op) => ApiDefinitionHolder.createGraphQlOperationId(op));
|
|
12041
|
+
let slugSegment = entry.parentField;
|
|
12042
|
+
const flatHasSameSlug = insertionOrder.some(
|
|
12043
|
+
(e) => e.type === "flat" && (() => {
|
|
12044
|
+
const fp = e.op.fieldPath;
|
|
12045
|
+
const s = fp != null && fp.length > 0 ? [...fp, e.op.name].join("-") : e.op.name;
|
|
12046
|
+
return s === slugSegment;
|
|
12047
|
+
})()
|
|
12048
|
+
);
|
|
12049
|
+
if (flatHasSameSlug) {
|
|
12050
|
+
slugSegment = `${entry.parentField}-fields`;
|
|
12051
|
+
}
|
|
12052
|
+
children.push(
|
|
12053
|
+
this.#idgen.with(opId, (id) => ({
|
|
12054
|
+
id,
|
|
12055
|
+
type: "graphql",
|
|
12056
|
+
title: entry.parentField,
|
|
12057
|
+
graphqlOperationId: opId,
|
|
12058
|
+
graphqlOperationIds: allOpIds.length > 1 ? allOpIds : void 0,
|
|
12059
|
+
slug: parentSlug.apply({ urlSlug: slugSegment }).get(),
|
|
12060
|
+
icon: void 0,
|
|
12061
|
+
hidden: void 0,
|
|
12062
|
+
operationType: firstOp.operationType,
|
|
12063
|
+
apiDefinitionId: this.apiDefinitionId,
|
|
12064
|
+
availability: navigation_exports.V1.convertAvailability(firstOp.availability),
|
|
12065
|
+
playground: void 0,
|
|
12066
|
+
authed: void 0,
|
|
12067
|
+
collapsed: void 0,
|
|
12068
|
+
viewers: void 0,
|
|
12069
|
+
orphaned: void 0,
|
|
12070
|
+
featureFlags: void 0
|
|
12071
|
+
}))
|
|
12072
|
+
);
|
|
12073
|
+
}
|
|
12074
|
+
}
|
|
12075
|
+
return children;
|
|
12076
|
+
}
|
|
11954
12077
|
convertPackageToChildren(package_, parentSlug) {
|
|
11955
12078
|
const children = [];
|
|
11956
12079
|
let subpackageId = isSubpackage(package_) ? package_.subpackageId : "__package__";
|
|
@@ -11998,14 +12121,7 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
11998
12121
|
children.push(this.convertWebhookNode(webhookId, webhook, parentSlug));
|
|
11999
12122
|
this.#visitedWebhooks.add(webhookId);
|
|
12000
12123
|
});
|
|
12001
|
-
(package_.graphqlOperations ?? [])
|
|
12002
|
-
const graphqlOperationId = ApiDefinitionHolder.createGraphQlOperationId(graphqlOperation);
|
|
12003
|
-
if (this.#visitedGraphqlOperations.has(graphqlOperationId)) {
|
|
12004
|
-
return;
|
|
12005
|
-
}
|
|
12006
|
-
children.push(this.convertGraphQlNode(graphqlOperationId, graphqlOperation, parentSlug));
|
|
12007
|
-
this.#visitedGraphqlOperations.add(graphqlOperationId);
|
|
12008
|
-
});
|
|
12124
|
+
children.push(...this.convertGraphQlOperationsToChildren(package_.graphqlOperations ?? [], parentSlug));
|
|
12009
12125
|
(package_.subpackages ?? []).forEach((subpackageId2) => {
|
|
12010
12126
|
const subpackage = this.api.subpackages[subpackageId2];
|
|
12011
12127
|
if (subpackage == null) {
|
|
@@ -13948,6 +14064,7 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
|
|
|
13948
14064
|
collapsed: node.collapsed,
|
|
13949
14065
|
apiDefinitionId: node.apiDefinitionId,
|
|
13950
14066
|
graphqlOperationId: node.graphqlOperationId,
|
|
14067
|
+
graphqlOperationIds: node.graphqlOperationIds,
|
|
13951
14068
|
operationType: node.operationType,
|
|
13952
14069
|
playground: node.playground,
|
|
13953
14070
|
availability: this.#availability(node.availability),
|