@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
|
@@ -799,6 +799,7 @@ var GraphQlOperationSchema = z2.object({
|
|
|
799
799
|
operationType: GraphQlOperationTypeSchema,
|
|
800
800
|
name: z2.string(),
|
|
801
801
|
displayName: z2.string().nullish(),
|
|
802
|
+
fieldPath: z2.array(z2.string()).nullish(),
|
|
802
803
|
arguments: z2.array(GraphQlArgumentSchema).nullish(),
|
|
803
804
|
returnType: TypeReferenceSchema,
|
|
804
805
|
examples: z2.array(GraphQlExampleSchema).nullish(),
|
|
@@ -2211,11 +2212,8 @@ var ApiDefinitionPruner = class {
|
|
|
2211
2212
|
if (node.type !== "graphql" || graphqlOperations == null) {
|
|
2212
2213
|
return [];
|
|
2213
2214
|
}
|
|
2214
|
-
const
|
|
2215
|
-
|
|
2216
|
-
(graphqlOperation) => ApiDefinitionHolder.createGraphQlOperationId(graphqlOperation) === graphqlOperationId
|
|
2217
|
-
);
|
|
2218
|
-
return found ? [found] : [];
|
|
2215
|
+
const idsToInclude = new Set(node.graphqlOperationIds ?? [node.graphqlOperationId]);
|
|
2216
|
+
return graphqlOperations.filter((op) => idsToInclude.has(ApiDefinitionHolder.createGraphQlOperationId(op)));
|
|
2219
2217
|
}
|
|
2220
2218
|
};
|
|
2221
2219
|
|
|
@@ -3124,6 +3122,7 @@ var LatestGraphQlOperationSchema = z4.object({
|
|
|
3124
3122
|
description: z4.string().nullish(),
|
|
3125
3123
|
availability: AvailabilitySchema.nullish(),
|
|
3126
3124
|
namespace: z4.array(z4.string()).nullish(),
|
|
3125
|
+
fieldPath: z4.array(z4.string()).nullish(),
|
|
3127
3126
|
id: GraphQlOperationIdSchema,
|
|
3128
3127
|
operationType: LatestGraphQlOperationTypeSchema,
|
|
3129
3128
|
name: z4.string(),
|
|
@@ -4025,10 +4024,13 @@ var ApiDefinitionPruner2 = class _ApiDefinitionPruner {
|
|
|
4025
4024
|
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
4026
4025
|
}
|
|
4027
4026
|
} else if (node.type === "graphql") {
|
|
4028
|
-
const
|
|
4029
|
-
|
|
4030
|
-
|
|
4031
|
-
found
|
|
4027
|
+
const idsToInclude = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
4028
|
+
for (const opId of idsToInclude) {
|
|
4029
|
+
const found = this.api.graphqlOperations[opId];
|
|
4030
|
+
if (found) {
|
|
4031
|
+
toRet.graphqlOperations[opId] = found;
|
|
4032
|
+
found.namespace?.forEach((subpackageId) => namespaces.add(subpackageId));
|
|
4033
|
+
}
|
|
4032
4034
|
}
|
|
4033
4035
|
}
|
|
4034
4036
|
}
|
|
@@ -4330,9 +4332,21 @@ function createGraphqlContext(node, apiDefinition) {
|
|
|
4330
4332
|
);
|
|
4331
4333
|
return void 0;
|
|
4332
4334
|
}
|
|
4335
|
+
const allIds = node.graphqlOperationIds ?? [node.graphqlOperationId];
|
|
4336
|
+
const operations = [];
|
|
4337
|
+
for (const id of allIds) {
|
|
4338
|
+
const op = api2.graphqlOperations[id];
|
|
4339
|
+
if (op) {
|
|
4340
|
+
operations.push(op);
|
|
4341
|
+
}
|
|
4342
|
+
}
|
|
4343
|
+
if (operations.length === 0) {
|
|
4344
|
+
operations.push(operation);
|
|
4345
|
+
}
|
|
4333
4346
|
return {
|
|
4334
4347
|
node,
|
|
4335
4348
|
operation,
|
|
4349
|
+
operations,
|
|
4336
4350
|
types: api2.types
|
|
4337
4351
|
};
|
|
4338
4352
|
}
|
|
@@ -5941,6 +5955,7 @@ var ApiDefinitionV1ToLatest = class _ApiDefinitionV1ToLatest {
|
|
|
5941
5955
|
description: v1?.description,
|
|
5942
5956
|
availability: v1?.availability,
|
|
5943
5957
|
namespace,
|
|
5958
|
+
fieldPath: v1?.fieldPath,
|
|
5944
5959
|
arguments: v1?.arguments?.map((arg) => this.migrateGraphQlArgument(arg)),
|
|
5945
5960
|
returnType: {
|
|
5946
5961
|
type: "alias",
|
|
@@ -6237,7 +6252,10 @@ function generateGraphQlSnippet(context) {
|
|
|
6237
6252
|
return `$${arg.name}: ${graphqlType}`;
|
|
6238
6253
|
});
|
|
6239
6254
|
const argumentUsage = args.map((arg) => `${arg.name}: $${arg.name}`);
|
|
6240
|
-
const
|
|
6255
|
+
const fieldPath = operation.fieldPath;
|
|
6256
|
+
const hasFieldPath = fieldPath != null && fieldPath.length > 0;
|
|
6257
|
+
const selectionSetIndent = hasFieldPath ? 2 + fieldPath.length : 2;
|
|
6258
|
+
const selectionSet = generateSelectionSet(operation.returnType, types, 2, /* @__PURE__ */ new Set(), selectionSetIndent);
|
|
6241
6259
|
let query = operationKeyword;
|
|
6242
6260
|
if (operationName || variableDefinitions.length > 0) {
|
|
6243
6261
|
query += ` ${operationName}`;
|
|
@@ -6246,15 +6264,32 @@ function generateGraphQlSnippet(context) {
|
|
|
6246
6264
|
}
|
|
6247
6265
|
}
|
|
6248
6266
|
query += " {\n";
|
|
6249
|
-
|
|
6267
|
+
const baseIndent = 2;
|
|
6268
|
+
if (hasFieldPath) {
|
|
6269
|
+
for (let i = 0; i < fieldPath.length; i++) {
|
|
6270
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
6271
|
+
query += `${indent}${fieldPath[i]} {
|
|
6272
|
+
`;
|
|
6273
|
+
}
|
|
6274
|
+
}
|
|
6275
|
+
const operationIndent = hasFieldPath ? " ".repeat(baseIndent + fieldPath.length * 2) : " ";
|
|
6276
|
+
query += `${operationIndent}${operation.name}`;
|
|
6250
6277
|
if (argumentUsage.length > 0) {
|
|
6251
6278
|
query += `(${argumentUsage.join(", ")})`;
|
|
6252
6279
|
}
|
|
6253
6280
|
if (selectionSet) {
|
|
6254
6281
|
query += ` ${selectionSet}`;
|
|
6255
6282
|
}
|
|
6256
|
-
query += "\n
|
|
6257
|
-
|
|
6283
|
+
query += "\n";
|
|
6284
|
+
if (hasFieldPath) {
|
|
6285
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
6286
|
+
const indent = " ".repeat(baseIndent + i * 2);
|
|
6287
|
+
query += `${indent}}
|
|
6288
|
+
`;
|
|
6289
|
+
}
|
|
6290
|
+
}
|
|
6291
|
+
query += "}";
|
|
6292
|
+
const response = generateResponseExample(operation.name, operation.returnType, types, fieldPath);
|
|
6258
6293
|
const result = { query, variables, response };
|
|
6259
6294
|
snippetCache.set(operation, result);
|
|
6260
6295
|
return result;
|
|
@@ -6538,13 +6573,18 @@ function generateSelectionSetFromReference(ref, types, depth, visited, indentLev
|
|
|
6538
6573
|
return "";
|
|
6539
6574
|
}
|
|
6540
6575
|
}
|
|
6541
|
-
function generateResponseExample(operationName, returnType, types) {
|
|
6576
|
+
function generateResponseExample(operationName, returnType, types, fieldPath) {
|
|
6542
6577
|
const data = generateResponseData(returnType, types, 3, /* @__PURE__ */ new Set());
|
|
6543
|
-
|
|
6544
|
-
|
|
6545
|
-
|
|
6578
|
+
let responseData = { [operationName]: data };
|
|
6579
|
+
if (fieldPath != null && fieldPath.length > 0) {
|
|
6580
|
+
for (let i = fieldPath.length - 1; i >= 0; i--) {
|
|
6581
|
+
const key = fieldPath[i];
|
|
6582
|
+
if (key != null) {
|
|
6583
|
+
responseData = { [key]: responseData };
|
|
6584
|
+
}
|
|
6546
6585
|
}
|
|
6547
|
-
}
|
|
6586
|
+
}
|
|
6587
|
+
return { data: responseData };
|
|
6548
6588
|
}
|
|
6549
6589
|
function generateResponseData(shape, types, depth, visited) {
|
|
6550
6590
|
if (depth <= 0) {
|
|
@@ -11956,12 +11996,15 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
11956
11996
|
}));
|
|
11957
11997
|
}
|
|
11958
11998
|
convertGraphQlNode(graphqlOperationId, graphqlOperation, parentSlug) {
|
|
11999
|
+
const fieldPath = graphqlOperation.fieldPath;
|
|
12000
|
+
const urlSlug = fieldPath != null && fieldPath.length > 0 ? [...fieldPath, graphqlOperation.name].join("-") : graphqlOperation.name;
|
|
11959
12001
|
return this.#idgen.with(graphqlOperationId, (id) => ({
|
|
11960
12002
|
id,
|
|
11961
12003
|
type: "graphql",
|
|
11962
12004
|
title: graphqlOperation.displayName ?? graphqlOperation.name,
|
|
11963
12005
|
graphqlOperationId,
|
|
11964
|
-
|
|
12006
|
+
graphqlOperationIds: void 0,
|
|
12007
|
+
slug: parentSlug.apply({ urlSlug }).get(),
|
|
11965
12008
|
icon: void 0,
|
|
11966
12009
|
hidden: void 0,
|
|
11967
12010
|
operationType: graphqlOperation.operationType,
|
|
@@ -11975,6 +12018,86 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
11975
12018
|
featureFlags: void 0
|
|
11976
12019
|
}));
|
|
11977
12020
|
}
|
|
12021
|
+
convertGraphQlOperationsToChildren(graphqlOperations, parentSlug) {
|
|
12022
|
+
const groupedByParent = /* @__PURE__ */ new Map();
|
|
12023
|
+
const insertionOrder = [];
|
|
12024
|
+
for (const op of graphqlOperations) {
|
|
12025
|
+
const graphqlOperationId = ApiDefinitionHolder.createGraphQlOperationId(op);
|
|
12026
|
+
if (this.#visitedGraphqlOperations.has(graphqlOperationId)) {
|
|
12027
|
+
continue;
|
|
12028
|
+
}
|
|
12029
|
+
this.#visitedGraphqlOperations.add(graphqlOperationId);
|
|
12030
|
+
const parentField = op.fieldPath?.[0];
|
|
12031
|
+
if (parentField != null && op.operationType === "QUERY") {
|
|
12032
|
+
const group = groupedByParent.get(parentField);
|
|
12033
|
+
if (group != null) {
|
|
12034
|
+
group.push(op);
|
|
12035
|
+
} else {
|
|
12036
|
+
groupedByParent.set(parentField, [op]);
|
|
12037
|
+
insertionOrder.push({ type: "group", parentField });
|
|
12038
|
+
}
|
|
12039
|
+
} else {
|
|
12040
|
+
insertionOrder.push({ type: "flat", op });
|
|
12041
|
+
}
|
|
12042
|
+
}
|
|
12043
|
+
const children = [];
|
|
12044
|
+
const allSlugs = /* @__PURE__ */ new Set();
|
|
12045
|
+
for (const entry of insertionOrder) {
|
|
12046
|
+
if (entry.type === "flat") {
|
|
12047
|
+
const fp = entry.op.fieldPath;
|
|
12048
|
+
allSlugs.add(fp != null && fp.length > 0 ? [...fp, entry.op.name].join("-") : entry.op.name);
|
|
12049
|
+
} else {
|
|
12050
|
+
allSlugs.add(entry.parentField);
|
|
12051
|
+
}
|
|
12052
|
+
}
|
|
12053
|
+
for (const entry of insertionOrder) {
|
|
12054
|
+
if (entry.type === "flat") {
|
|
12055
|
+
const opId = ApiDefinitionHolder.createGraphQlOperationId(entry.op);
|
|
12056
|
+
children.push(this.convertGraphQlNode(opId, entry.op, parentSlug));
|
|
12057
|
+
} else {
|
|
12058
|
+
const operations = groupedByParent.get(entry.parentField);
|
|
12059
|
+
if (operations == null) {
|
|
12060
|
+
continue;
|
|
12061
|
+
}
|
|
12062
|
+
const firstOp = operations[0];
|
|
12063
|
+
const opId = ApiDefinitionHolder.createGraphQlOperationId(firstOp);
|
|
12064
|
+
const allOpIds = operations.map((op) => ApiDefinitionHolder.createGraphQlOperationId(op));
|
|
12065
|
+
let slugSegment = entry.parentField;
|
|
12066
|
+
const flatHasSameSlug = insertionOrder.some(
|
|
12067
|
+
(e) => e.type === "flat" && (() => {
|
|
12068
|
+
const fp = e.op.fieldPath;
|
|
12069
|
+
const s = fp != null && fp.length > 0 ? [...fp, e.op.name].join("-") : e.op.name;
|
|
12070
|
+
return s === slugSegment;
|
|
12071
|
+
})()
|
|
12072
|
+
);
|
|
12073
|
+
if (flatHasSameSlug) {
|
|
12074
|
+
slugSegment = `${entry.parentField}-fields`;
|
|
12075
|
+
}
|
|
12076
|
+
children.push(
|
|
12077
|
+
this.#idgen.with(opId, (id) => ({
|
|
12078
|
+
id,
|
|
12079
|
+
type: "graphql",
|
|
12080
|
+
title: entry.parentField,
|
|
12081
|
+
graphqlOperationId: opId,
|
|
12082
|
+
graphqlOperationIds: allOpIds.length > 1 ? allOpIds : void 0,
|
|
12083
|
+
slug: parentSlug.apply({ urlSlug: slugSegment }).get(),
|
|
12084
|
+
icon: void 0,
|
|
12085
|
+
hidden: void 0,
|
|
12086
|
+
operationType: firstOp.operationType,
|
|
12087
|
+
apiDefinitionId: this.apiDefinitionId,
|
|
12088
|
+
availability: navigation_exports.V1.convertAvailability(firstOp.availability),
|
|
12089
|
+
playground: void 0,
|
|
12090
|
+
authed: void 0,
|
|
12091
|
+
collapsed: void 0,
|
|
12092
|
+
viewers: void 0,
|
|
12093
|
+
orphaned: void 0,
|
|
12094
|
+
featureFlags: void 0
|
|
12095
|
+
}))
|
|
12096
|
+
);
|
|
12097
|
+
}
|
|
12098
|
+
}
|
|
12099
|
+
return children;
|
|
12100
|
+
}
|
|
11978
12101
|
convertPackageToChildren(package_, parentSlug) {
|
|
11979
12102
|
const children = [];
|
|
11980
12103
|
let subpackageId = isSubpackage(package_) ? package_.subpackageId : "__package__";
|
|
@@ -12022,14 +12145,7 @@ var ApiReferenceNavigationConverter = class _ApiReferenceNavigationConverter {
|
|
|
12022
12145
|
children.push(this.convertWebhookNode(webhookId, webhook, parentSlug));
|
|
12023
12146
|
this.#visitedWebhooks.add(webhookId);
|
|
12024
12147
|
});
|
|
12025
|
-
(package_.graphqlOperations ?? [])
|
|
12026
|
-
const graphqlOperationId = ApiDefinitionHolder.createGraphQlOperationId(graphqlOperation);
|
|
12027
|
-
if (this.#visitedGraphqlOperations.has(graphqlOperationId)) {
|
|
12028
|
-
return;
|
|
12029
|
-
}
|
|
12030
|
-
children.push(this.convertGraphQlNode(graphqlOperationId, graphqlOperation, parentSlug));
|
|
12031
|
-
this.#visitedGraphqlOperations.add(graphqlOperationId);
|
|
12032
|
-
});
|
|
12148
|
+
children.push(...this.convertGraphQlOperationsToChildren(package_.graphqlOperations ?? [], parentSlug));
|
|
12033
12149
|
(package_.subpackages ?? []).forEach((subpackageId2) => {
|
|
12034
12150
|
const subpackage = this.api.subpackages[subpackageId2];
|
|
12035
12151
|
if (subpackage == null) {
|
|
@@ -13972,6 +14088,7 @@ var FernNavigationV1ToLatest = class _FernNavigationV1ToLatest {
|
|
|
13972
14088
|
collapsed: node.collapsed,
|
|
13973
14089
|
apiDefinitionId: node.apiDefinitionId,
|
|
13974
14090
|
graphqlOperationId: node.graphqlOperationId,
|
|
14091
|
+
graphqlOperationIds: node.graphqlOperationIds,
|
|
13975
14092
|
operationType: node.operationType,
|
|
13976
14093
|
playground: node.playground,
|
|
13977
14094
|
availability: this.#availability(node.availability),
|