@fern-api/fdr-sdk 1.1.26-aaa1152cda → 1.1.28-306b323376
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-lite/index.js +680 -0
- package/dist/js/api-definition-lite/index.js.map +1 -0
- package/dist/js/api-definition-lite/index.mjs +634 -0
- package/dist/js/api-definition-lite/index.mjs.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/api-definition-lite/index.d.ts +17 -0
- package/dist/types/api-definition-lite/index.d.ts.map +1 -0
- package/package.json +7 -1
|
@@ -0,0 +1,680 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __export = (target, all) => {
|
|
9
|
+
for (var name in all)
|
|
10
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
11
|
+
};
|
|
12
|
+
var __copyProps = (to, from, except, desc) => {
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (let key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
16
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
28
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
|
+
|
|
30
|
+
// src/api-definition-lite/index.ts
|
|
31
|
+
var api_definition_lite_exports = {};
|
|
32
|
+
__export(api_definition_lite_exports, {
|
|
33
|
+
STATUS_CODE_MESSAGES: () => STATUS_CODE_MESSAGES,
|
|
34
|
+
buildEndpointUrl: () => buildEndpointUrl,
|
|
35
|
+
buildRequestUrl: () => buildRequestUrl,
|
|
36
|
+
getMessageForStatus: () => getMessageForStatus,
|
|
37
|
+
preprocessQueryParameters: () => preprocessQueryParameters,
|
|
38
|
+
toColonEndpointPathLiteral: () => toColonEndpointPathLiteral,
|
|
39
|
+
toCurlyBraceEndpointPathLiteral: () => toCurlyBraceEndpointPathLiteral,
|
|
40
|
+
unwrapDiscriminatedUnionVariant: () => unwrapDiscriminatedUnionVariant,
|
|
41
|
+
unwrapObjectType: () => unwrapObjectType,
|
|
42
|
+
unwrapReference: () => unwrapReference
|
|
43
|
+
});
|
|
44
|
+
module.exports = __toCommonJS(api_definition_lite_exports);
|
|
45
|
+
|
|
46
|
+
// src/orpc-client/shared.ts
|
|
47
|
+
var z = __toESM(require("zod"), 1);
|
|
48
|
+
var OrgIdSchema = z.string();
|
|
49
|
+
var ApiIdSchema = z.string();
|
|
50
|
+
var ApiDefinitionIdSchema = z.string().uuid();
|
|
51
|
+
var HttpMethodSchema = z.enum(["GET", "POST", "PUT", "PATCH", "DELETE", "HEAD"]);
|
|
52
|
+
var UrlSchema = z.string();
|
|
53
|
+
var EndpointPathLiteralSchema = z.string();
|
|
54
|
+
function EndpointPathLiteral(value) {
|
|
55
|
+
return value;
|
|
56
|
+
}
|
|
57
|
+
var EndpointIdentifierSchema = z.object({
|
|
58
|
+
path: z.string(),
|
|
59
|
+
method: HttpMethodSchema,
|
|
60
|
+
identifierOverride: z.string().nullish()
|
|
61
|
+
});
|
|
62
|
+
var SdkRequestSchema = z.discriminatedUnion("type", [
|
|
63
|
+
z.object({ type: z.literal("typescript"), package: z.string(), version: z.string().nullish() }),
|
|
64
|
+
z.object({ type: z.literal("python"), package: z.string(), version: z.string().nullish() }),
|
|
65
|
+
z.object({ type: z.literal("go"), githubRepo: z.string(), version: z.string().nullish() }),
|
|
66
|
+
z.object({ type: z.literal("ruby"), gem: z.string(), version: z.string().nullish() }),
|
|
67
|
+
z.object({
|
|
68
|
+
type: z.literal("java"),
|
|
69
|
+
group: z.string(),
|
|
70
|
+
artifact: z.string(),
|
|
71
|
+
version: z.string().nullish()
|
|
72
|
+
}),
|
|
73
|
+
z.object({ type: z.literal("csharp"), package: z.string(), version: z.string().nullish() })
|
|
74
|
+
]);
|
|
75
|
+
var DocsConfigIdSchema = z.string();
|
|
76
|
+
var GrpcIdSchema = z.string();
|
|
77
|
+
var PageIdSchema = z.string();
|
|
78
|
+
var RoleIdSchema = z.string();
|
|
79
|
+
var TokenIdSchema = z.string();
|
|
80
|
+
var VersionIdSchema = z.string();
|
|
81
|
+
var Availability = {
|
|
82
|
+
Stable: "Stable",
|
|
83
|
+
GenerallyAvailable: "GenerallyAvailable",
|
|
84
|
+
InDevelopment: "InDevelopment",
|
|
85
|
+
PreRelease: "PreRelease",
|
|
86
|
+
Deprecated: "Deprecated",
|
|
87
|
+
Beta: "Beta"
|
|
88
|
+
};
|
|
89
|
+
var SnippetsByEndpointMethodSchema = z.record(
|
|
90
|
+
HttpMethodSchema,
|
|
91
|
+
z.array(z.unknown())
|
|
92
|
+
);
|
|
93
|
+
var SdkSchema = z.discriminatedUnion("type", [
|
|
94
|
+
z.object({ type: z.literal("typescript"), package: z.string(), version: z.string() }),
|
|
95
|
+
z.object({ type: z.literal("python"), package: z.string(), version: z.string() }),
|
|
96
|
+
z.object({ type: z.literal("go"), githubRepo: z.string(), version: z.string() }),
|
|
97
|
+
z.object({ type: z.literal("ruby"), gem: z.string(), version: z.string() }),
|
|
98
|
+
z.object({
|
|
99
|
+
type: z.literal("java"),
|
|
100
|
+
group: z.string(),
|
|
101
|
+
artifact: z.string(),
|
|
102
|
+
version: z.string()
|
|
103
|
+
}),
|
|
104
|
+
z.object({ type: z.literal("csharp"), package: z.string(), version: z.string() })
|
|
105
|
+
]);
|
|
106
|
+
|
|
107
|
+
// src/api-definition/endpoint-path-literal.ts
|
|
108
|
+
function toColonEndpointPathLiteral(pathParts) {
|
|
109
|
+
return EndpointPathLiteral(
|
|
110
|
+
pathParts.map((part) => part.type === "literal" ? part.value : `:${part.value}`).join("")
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
function toCurlyBraceEndpointPathLiteral(pathParts) {
|
|
114
|
+
return EndpointPathLiteral(
|
|
115
|
+
pathParts.map((part) => part.type === "literal" ? part.value : `{${part.value}}`).join("")
|
|
116
|
+
);
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// src/api-definition/status-message.ts
|
|
120
|
+
var STATUS_CODE_MESSAGES = {
|
|
121
|
+
100: "Continue",
|
|
122
|
+
101: "Switching Protocols",
|
|
123
|
+
102: "Processing",
|
|
124
|
+
103: "Early Hints",
|
|
125
|
+
200: "OK",
|
|
126
|
+
201: "Created",
|
|
127
|
+
202: "Accepted",
|
|
128
|
+
203: "Non-Authoritative Information",
|
|
129
|
+
204: "No Content",
|
|
130
|
+
205: "Reset Content",
|
|
131
|
+
206: "Partial Content",
|
|
132
|
+
207: "Multi-Status",
|
|
133
|
+
208: "Already Reported",
|
|
134
|
+
226: "IM Used",
|
|
135
|
+
300: "Multiple Choices",
|
|
136
|
+
301: "Moved Permanently",
|
|
137
|
+
302: "Found",
|
|
138
|
+
303: "See Other",
|
|
139
|
+
304: "Not Modified",
|
|
140
|
+
305: "Use Proxy",
|
|
141
|
+
306: "Switch Proxy",
|
|
142
|
+
307: "Temporary Redirect",
|
|
143
|
+
308: "Permanent Redirect",
|
|
144
|
+
400: "Bad Request",
|
|
145
|
+
401: "Unauthorized",
|
|
146
|
+
402: "Payment Required",
|
|
147
|
+
403: "Forbidden",
|
|
148
|
+
404: "Not Found",
|
|
149
|
+
405: "Method Not Allowed",
|
|
150
|
+
406: "Not Acceptable",
|
|
151
|
+
407: "Proxy Authentication Required",
|
|
152
|
+
408: "Request Timeout",
|
|
153
|
+
409: "Conflict",
|
|
154
|
+
410: "Gone",
|
|
155
|
+
411: "Length Required",
|
|
156
|
+
412: "Precondition Failed",
|
|
157
|
+
413: "Payload Too Large",
|
|
158
|
+
414: "URI Too Long",
|
|
159
|
+
415: "Unsupported Media Type",
|
|
160
|
+
416: "Range Not Satisfiable",
|
|
161
|
+
417: "Expectation Failed",
|
|
162
|
+
418: "I'm a teapot",
|
|
163
|
+
421: "Misdirected Request",
|
|
164
|
+
422: "Unprocessable Entity",
|
|
165
|
+
423: "Locked",
|
|
166
|
+
424: "Failed Dependency",
|
|
167
|
+
425: "Too Early",
|
|
168
|
+
426: "Upgrade Required",
|
|
169
|
+
428: "Precondition Required",
|
|
170
|
+
429: "Too Many Requests",
|
|
171
|
+
431: "Request Header Fields Too Large",
|
|
172
|
+
451: "Unavailable For Legal Reasons",
|
|
173
|
+
500: "Internal Server Error",
|
|
174
|
+
501: "Not Implemented",
|
|
175
|
+
502: "Bad Gateway",
|
|
176
|
+
503: "Service Unavailable",
|
|
177
|
+
504: "Gateway Timeout",
|
|
178
|
+
505: "HTTP Version Not Supported",
|
|
179
|
+
506: "Variant Also Negotiates",
|
|
180
|
+
507: "Insufficient Storage",
|
|
181
|
+
508: "Loop Detected",
|
|
182
|
+
510: "Not Extended",
|
|
183
|
+
511: "Network Authentication Required"
|
|
184
|
+
};
|
|
185
|
+
var STATUS_CODE_MESSAGES_METHOD_OVERRIDES = {
|
|
186
|
+
200: {
|
|
187
|
+
GET: "Retrieved",
|
|
188
|
+
POST: "Successful",
|
|
189
|
+
// more accurate than "Created" for POST
|
|
190
|
+
PUT: "Updated",
|
|
191
|
+
PATCH: "Updated",
|
|
192
|
+
DELETE: "Deleted"
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
function getMessageForStatus(statusCode, method) {
|
|
196
|
+
if (method != null) {
|
|
197
|
+
const methodOverrides = STATUS_CODE_MESSAGES_METHOD_OVERRIDES[statusCode];
|
|
198
|
+
if (methodOverrides != null) {
|
|
199
|
+
const message2 = methodOverrides[method];
|
|
200
|
+
if (message2 != null) {
|
|
201
|
+
return message2;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
const message = STATUS_CODE_MESSAGES[statusCode];
|
|
206
|
+
if (message != null) {
|
|
207
|
+
return message;
|
|
208
|
+
}
|
|
209
|
+
if (statusCode >= 100 && statusCode < 200) {
|
|
210
|
+
return "Informational";
|
|
211
|
+
} else if (statusCode >= 200 && statusCode < 300) {
|
|
212
|
+
return "Success";
|
|
213
|
+
} else if (statusCode >= 300 && statusCode < 400) {
|
|
214
|
+
return "Redirection";
|
|
215
|
+
} else if (statusCode >= 400 && statusCode < 500) {
|
|
216
|
+
return "Client Error";
|
|
217
|
+
} else if (statusCode >= 500 && statusCode < 600) {
|
|
218
|
+
return "Server Error";
|
|
219
|
+
} else {
|
|
220
|
+
return "Unknown Status";
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// ../commons/core-utils/dist/assertNever.js
|
|
225
|
+
function assertNever(x) {
|
|
226
|
+
throw new Error("Unexpected value: " + JSON.stringify(x));
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
// ../commons/core-utils/dist/objects/isPlainObject.js
|
|
230
|
+
function isPlainObject(value) {
|
|
231
|
+
if (!isObjectLike(value) || String(value) !== "[object Object]") {
|
|
232
|
+
return false;
|
|
233
|
+
}
|
|
234
|
+
if (Object.getPrototypeOf(value) == null) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
let proto = value;
|
|
238
|
+
while (Object.getPrototypeOf(proto) != null) {
|
|
239
|
+
proto = Object.getPrototypeOf(proto);
|
|
240
|
+
}
|
|
241
|
+
return Object.getPrototypeOf(value) === proto;
|
|
242
|
+
}
|
|
243
|
+
function isObjectLike(value) {
|
|
244
|
+
return typeof value === "object" && value != null;
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
// ../commons/core-utils/dist/sanitizeUrl.js
|
|
248
|
+
function sanitizeUrl(url) {
|
|
249
|
+
if (!url) {
|
|
250
|
+
return void 0;
|
|
251
|
+
}
|
|
252
|
+
if (url.startsWith("//")) {
|
|
253
|
+
try {
|
|
254
|
+
const parsedUrl = new URL(`https:${url}`);
|
|
255
|
+
return parsedUrl.toString();
|
|
256
|
+
} catch {
|
|
257
|
+
return void 0;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
if (!url.startsWith("http://") && !url.startsWith("https://") && !url.startsWith("wss://") && !url.startsWith("ws://") && !url.startsWith("mailto:") && !url.startsWith("tel:")) {
|
|
261
|
+
try {
|
|
262
|
+
const parsedUrl = new URL(`https://${url}`);
|
|
263
|
+
return parsedUrl.toString();
|
|
264
|
+
} catch {
|
|
265
|
+
return void 0;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
try {
|
|
269
|
+
const parsedUrl = new URL(url);
|
|
270
|
+
return parsedUrl.toString();
|
|
271
|
+
} catch {
|
|
272
|
+
return void 0;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// ../commons/core-utils/dist/unknownToString.js
|
|
277
|
+
function unknownToString(value, { renderNull = false } = {}) {
|
|
278
|
+
if (value == null || typeof value === "function") {
|
|
279
|
+
return renderNull ? "null" : "";
|
|
280
|
+
} else if (typeof value === "string") {
|
|
281
|
+
return value;
|
|
282
|
+
}
|
|
283
|
+
return JSON.stringify(value);
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
// ../commons/core-utils/dist/visitDiscriminatedUnion.js
|
|
287
|
+
function visitDiscriminatedUnion(item, discriminant = "type") {
|
|
288
|
+
return {
|
|
289
|
+
_visit: (visitor) => {
|
|
290
|
+
const visit = visitor[item[discriminant]];
|
|
291
|
+
if (visit != null) {
|
|
292
|
+
return visit(item);
|
|
293
|
+
} else {
|
|
294
|
+
if (visitor._other == null) {
|
|
295
|
+
assertNever(item);
|
|
296
|
+
}
|
|
297
|
+
return visitor._other(item);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
var visitDiscriminatedUnion_default = visitDiscriminatedUnion;
|
|
303
|
+
|
|
304
|
+
// src/api-definition/unwrap.ts
|
|
305
|
+
var import_array = require("es-toolkit/array");
|
|
306
|
+
|
|
307
|
+
// src/api-definition/availability.ts
|
|
308
|
+
var AvailabilityOrder = [
|
|
309
|
+
Availability.Stable,
|
|
310
|
+
Availability.GenerallyAvailable,
|
|
311
|
+
Availability.Beta,
|
|
312
|
+
Availability.PreRelease,
|
|
313
|
+
Availability.InDevelopment,
|
|
314
|
+
Availability.Deprecated
|
|
315
|
+
];
|
|
316
|
+
function coalesceAvailability(availabilities) {
|
|
317
|
+
for (const availability of [...AvailabilityOrder].reverse()) {
|
|
318
|
+
if (availabilities.includes(availability)) {
|
|
319
|
+
return availability;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
return void 0;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
// src/api-definition/const.ts
|
|
326
|
+
var LOOP_TOLERANCE = 100;
|
|
327
|
+
var LARGE_LOOP_TOLERANCE = 100 ** 2;
|
|
328
|
+
|
|
329
|
+
// src/api-definition/unwrap.ts
|
|
330
|
+
var UnwrapReferenceCache = /* @__PURE__ */ new WeakMap();
|
|
331
|
+
function unwrapReference(typeRef, types) {
|
|
332
|
+
if (typeRef == null) {
|
|
333
|
+
return void 0;
|
|
334
|
+
}
|
|
335
|
+
const cached = UnwrapReferenceCache.get(typeRef);
|
|
336
|
+
if (cached != null) {
|
|
337
|
+
return cached;
|
|
338
|
+
}
|
|
339
|
+
let isOptional = false;
|
|
340
|
+
let isNullable = false;
|
|
341
|
+
const defaults = [];
|
|
342
|
+
const descriptions = [];
|
|
343
|
+
const availabilities = [];
|
|
344
|
+
const visitedTypeIds = /* @__PURE__ */ new Set();
|
|
345
|
+
let internalTypeRef = typeRef;
|
|
346
|
+
let loop = 0;
|
|
347
|
+
let circularReference = false;
|
|
348
|
+
while (internalTypeRef != null) {
|
|
349
|
+
if (loop > LOOP_TOLERANCE) {
|
|
350
|
+
internalTypeRef = void 0;
|
|
351
|
+
break;
|
|
352
|
+
}
|
|
353
|
+
if (internalTypeRef.type === "nullable") {
|
|
354
|
+
isNullable = true;
|
|
355
|
+
internalTypeRef = internalTypeRef.shape;
|
|
356
|
+
} else if (internalTypeRef.type === "optional") {
|
|
357
|
+
isOptional = true;
|
|
358
|
+
if (internalTypeRef.default != null) {
|
|
359
|
+
defaults.push({
|
|
360
|
+
type: "unknown",
|
|
361
|
+
value: internalTypeRef.default
|
|
362
|
+
});
|
|
363
|
+
}
|
|
364
|
+
internalTypeRef = internalTypeRef.shape;
|
|
365
|
+
} else if (internalTypeRef.type === "alias") {
|
|
366
|
+
internalTypeRef = internalTypeRef.value;
|
|
367
|
+
} else if (internalTypeRef.type === "id") {
|
|
368
|
+
if (visitedTypeIds.has(internalTypeRef.id)) {
|
|
369
|
+
internalTypeRef = void 0;
|
|
370
|
+
circularReference = true;
|
|
371
|
+
break;
|
|
372
|
+
}
|
|
373
|
+
if (internalTypeRef.default != null) {
|
|
374
|
+
defaults.push({
|
|
375
|
+
type: "typeReferenceId",
|
|
376
|
+
value: internalTypeRef.default
|
|
377
|
+
});
|
|
378
|
+
}
|
|
379
|
+
const typeDef = types[internalTypeRef.id];
|
|
380
|
+
visitedTypeIds.add(internalTypeRef.id);
|
|
381
|
+
internalTypeRef = typeDef?.shape;
|
|
382
|
+
if (typeDef != null) {
|
|
383
|
+
if (typeDef.availability) {
|
|
384
|
+
availabilities.push(typeDef.availability);
|
|
385
|
+
}
|
|
386
|
+
if (typeDef.description != null) {
|
|
387
|
+
descriptions.push(typeDef.description);
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
} else {
|
|
391
|
+
break;
|
|
392
|
+
}
|
|
393
|
+
loop++;
|
|
394
|
+
}
|
|
395
|
+
if (internalTypeRef == null) {
|
|
396
|
+
if (circularReference) {
|
|
397
|
+
console.error(
|
|
398
|
+
`Circular reference detected. Falling back to unknown type. types=[${[...visitedTypeIds].join(", ")}]`
|
|
399
|
+
);
|
|
400
|
+
} else {
|
|
401
|
+
console.error(
|
|
402
|
+
`Type reference is invalid. Falling back to unknown type. types=[${[...visitedTypeIds].join(", ")}]`
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
}
|
|
406
|
+
const toRet = {
|
|
407
|
+
shape: internalTypeRef ?? { type: "unknown", displayName: void 0 },
|
|
408
|
+
availability: coalesceAvailability(availabilities),
|
|
409
|
+
visitedTypeIds,
|
|
410
|
+
isOptional,
|
|
411
|
+
isNullable,
|
|
412
|
+
default: selectDefaultValue(internalTypeRef, defaults),
|
|
413
|
+
descriptions
|
|
414
|
+
};
|
|
415
|
+
UnwrapReferenceCache.set(typeRef, toRet);
|
|
416
|
+
return toRet;
|
|
417
|
+
}
|
|
418
|
+
function selectDefaultValue(shape, defaults) {
|
|
419
|
+
const defaultValue = defaults.find((d) => {
|
|
420
|
+
if (shape == null) {
|
|
421
|
+
return true;
|
|
422
|
+
} else if (d.type === "typeReferenceId") {
|
|
423
|
+
return visitDiscriminatedUnion_default(d.value)._visit({
|
|
424
|
+
enum: () => shape?.type === "enum"
|
|
425
|
+
});
|
|
426
|
+
} else {
|
|
427
|
+
return true;
|
|
428
|
+
}
|
|
429
|
+
});
|
|
430
|
+
if (defaultValue?.type === "unknown") {
|
|
431
|
+
return defaultValue.value;
|
|
432
|
+
} else if (defaultValue?.type === "typeReferenceId") {
|
|
433
|
+
return defaultValue.value.value;
|
|
434
|
+
} else if (shape?.type === "primitive") {
|
|
435
|
+
return primitiveToDefault(shape.value);
|
|
436
|
+
} else if (shape?.type === "enum") {
|
|
437
|
+
return shape.default;
|
|
438
|
+
} else {
|
|
439
|
+
return void 0;
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
var UnwrapObjectTypeCache = /* @__PURE__ */ new WeakMap();
|
|
443
|
+
function unwrapObjectType(object2, types, parentVisitedTypeIds) {
|
|
444
|
+
const cached = UnwrapObjectTypeCache.get(object2);
|
|
445
|
+
if (cached != null) {
|
|
446
|
+
return cached;
|
|
447
|
+
}
|
|
448
|
+
const directProperties = object2.properties;
|
|
449
|
+
const extraProperties = object2.extraProperties;
|
|
450
|
+
const descriptions = [];
|
|
451
|
+
const visitedTypeIds = /* @__PURE__ */ new Set();
|
|
452
|
+
const extendedProperties = object2.extends.flatMap((typeId) => {
|
|
453
|
+
if (parentVisitedTypeIds?.has(typeId)) {
|
|
454
|
+
console.error(`Circular reference detected. Cannot extend type=${typeId}`);
|
|
455
|
+
return [];
|
|
456
|
+
}
|
|
457
|
+
const typeDef = types[typeId];
|
|
458
|
+
visitedTypeIds.add(typeId);
|
|
459
|
+
if (typeDef?.description) {
|
|
460
|
+
descriptions.push(typeDef.description);
|
|
461
|
+
}
|
|
462
|
+
const unwrapped = unwrapReference(typeDef?.shape, types);
|
|
463
|
+
unwrapped?.descriptions.forEach((description) => descriptions.push(description));
|
|
464
|
+
unwrapped?.visitedTypeIds.forEach((typeId2) => visitedTypeIds.add(typeId2));
|
|
465
|
+
if (unwrapped?.shape.type !== "object") {
|
|
466
|
+
console.warn("Object extends non-object", typeId);
|
|
467
|
+
return [];
|
|
468
|
+
}
|
|
469
|
+
const extended = unwrapObjectType(unwrapped.shape, types, visitedTypeIds);
|
|
470
|
+
extended.visitedTypeIds.forEach((typeId2) => visitedTypeIds.add(typeId2));
|
|
471
|
+
const extendedPropsWithAvailability = extended.properties.map((property) => {
|
|
472
|
+
return {
|
|
473
|
+
...property,
|
|
474
|
+
availability: coalesceAvailability(
|
|
475
|
+
(0, import_array.compact)([typeDef?.availability, unwrapped.availability, property.availability])
|
|
476
|
+
)
|
|
477
|
+
};
|
|
478
|
+
});
|
|
479
|
+
descriptions.push(...extended.descriptions);
|
|
480
|
+
if (!unwrapped.isOptional) {
|
|
481
|
+
return extendedPropsWithAvailability;
|
|
482
|
+
}
|
|
483
|
+
return extendedPropsWithAvailability.map((property) => {
|
|
484
|
+
const defaultProperty = isPlainObject(unwrapped.default) ? unwrapped.default[property.key] : void 0;
|
|
485
|
+
const valueShape = property.valueShape.type === "alias" && property.valueShape.value.type === "optional" ? {
|
|
486
|
+
...property.valueShape.value,
|
|
487
|
+
default: defaultProperty ?? property.valueShape.value.default
|
|
488
|
+
} : {
|
|
489
|
+
type: "optional",
|
|
490
|
+
shape: property.valueShape,
|
|
491
|
+
default: defaultProperty
|
|
492
|
+
};
|
|
493
|
+
return {
|
|
494
|
+
...property,
|
|
495
|
+
valueShape: { type: "alias", value: valueShape }
|
|
496
|
+
};
|
|
497
|
+
});
|
|
498
|
+
});
|
|
499
|
+
if (extendedProperties.length === 0) {
|
|
500
|
+
const properties2 = (0, import_array.sortBy)(
|
|
501
|
+
[...directProperties],
|
|
502
|
+
[
|
|
503
|
+
(property) => unwrapReference(property.valueShape, types)?.isOptional,
|
|
504
|
+
(property) => AvailabilityOrder.indexOf(property.availability ?? Availability.Stable)
|
|
505
|
+
]
|
|
506
|
+
);
|
|
507
|
+
const toRet2 = {
|
|
508
|
+
properties: properties2,
|
|
509
|
+
descriptions,
|
|
510
|
+
extraProperties,
|
|
511
|
+
visitedTypeIds
|
|
512
|
+
};
|
|
513
|
+
UnwrapObjectTypeCache.set(object2, toRet2);
|
|
514
|
+
return toRet2;
|
|
515
|
+
}
|
|
516
|
+
const propertyKeys = new Set(object2.properties.map((property) => property.key));
|
|
517
|
+
const seenExtendedKeys = /* @__PURE__ */ new Set();
|
|
518
|
+
const filteredExtendedProperties = extendedProperties.filter((extendedProperty) => {
|
|
519
|
+
if (propertyKeys.has(extendedProperty.key) || seenExtendedKeys.has(extendedProperty.key)) {
|
|
520
|
+
return false;
|
|
521
|
+
}
|
|
522
|
+
seenExtendedKeys.add(extendedProperty.key);
|
|
523
|
+
return true;
|
|
524
|
+
});
|
|
525
|
+
const properties = (0, import_array.sortBy)(
|
|
526
|
+
[...directProperties, ...filteredExtendedProperties],
|
|
527
|
+
[
|
|
528
|
+
(property) => unwrapReference(property.valueShape, types)?.isOptional,
|
|
529
|
+
(property) => AvailabilityOrder.indexOf(property.availability ?? Availability.Stable),
|
|
530
|
+
(property) => property.key
|
|
531
|
+
]
|
|
532
|
+
);
|
|
533
|
+
const toRet = { properties, descriptions, extraProperties, visitedTypeIds };
|
|
534
|
+
UnwrapObjectTypeCache.set(object2, toRet);
|
|
535
|
+
return toRet;
|
|
536
|
+
}
|
|
537
|
+
function unwrapDiscriminatedUnionVariant(union, variant, types) {
|
|
538
|
+
const { properties, descriptions, visitedTypeIds } = unwrapObjectType(variant, types);
|
|
539
|
+
return {
|
|
540
|
+
properties: [
|
|
541
|
+
{
|
|
542
|
+
key: union.discriminant,
|
|
543
|
+
valueShape: {
|
|
544
|
+
type: "alias",
|
|
545
|
+
value: {
|
|
546
|
+
type: "literal",
|
|
547
|
+
value: {
|
|
548
|
+
type: "stringLiteral",
|
|
549
|
+
value: variant.discriminantValue
|
|
550
|
+
}
|
|
551
|
+
}
|
|
552
|
+
},
|
|
553
|
+
propertyAccess: void 0,
|
|
554
|
+
// the description and availability of the discriminant should not be included here
|
|
555
|
+
// because they are already included in the union variant itself
|
|
556
|
+
description: void 0,
|
|
557
|
+
availability: void 0
|
|
558
|
+
},
|
|
559
|
+
...properties
|
|
560
|
+
],
|
|
561
|
+
extraProperties: void 0,
|
|
562
|
+
descriptions,
|
|
563
|
+
visitedTypeIds
|
|
564
|
+
};
|
|
565
|
+
}
|
|
566
|
+
function primitiveToDefault(shape) {
|
|
567
|
+
return visitDiscriminatedUnion_default(shape, "type")._visit({
|
|
568
|
+
string: (value) => value.default,
|
|
569
|
+
integer: (value) => value.default,
|
|
570
|
+
double: (value) => value.default,
|
|
571
|
+
uint: () => void 0,
|
|
572
|
+
uint64: () => void 0,
|
|
573
|
+
boolean: (value) => value.default,
|
|
574
|
+
long: (value) => value.default,
|
|
575
|
+
datetime: (datetime) => datetime.default,
|
|
576
|
+
uuid: (uuid) => uuid.default,
|
|
577
|
+
base64: (base64) => base64.default,
|
|
578
|
+
date: (value) => value.default,
|
|
579
|
+
bigInteger: (value) => value.default,
|
|
580
|
+
scalar: (value) => value.default
|
|
581
|
+
});
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
// src/api-definition/url.ts
|
|
585
|
+
var import_qs = __toESM(require("qs"), 1);
|
|
586
|
+
function preprocessQueryParameters(queryParameters, parameterMetadata) {
|
|
587
|
+
if (queryParameters == null) {
|
|
588
|
+
return void 0;
|
|
589
|
+
}
|
|
590
|
+
if (parameterMetadata == null || parameterMetadata.length === 0) {
|
|
591
|
+
return queryParameters;
|
|
592
|
+
}
|
|
593
|
+
const explodeMap = /* @__PURE__ */ new Map();
|
|
594
|
+
for (const param of parameterMetadata) {
|
|
595
|
+
explodeMap.set(param.key, param.explode ?? void 0);
|
|
596
|
+
}
|
|
597
|
+
const result = {};
|
|
598
|
+
for (const [key, value] of Object.entries(queryParameters)) {
|
|
599
|
+
const explode = explodeMap.get(key);
|
|
600
|
+
if (explode === false && Array.isArray(value)) {
|
|
601
|
+
result[key] = value.map((v) => unknownToString(v)).join(",");
|
|
602
|
+
} else {
|
|
603
|
+
result[key] = value;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
return result;
|
|
607
|
+
}
|
|
608
|
+
function buildQueryParams(queryParameters) {
|
|
609
|
+
if (queryParameters == null) {
|
|
610
|
+
return "";
|
|
611
|
+
}
|
|
612
|
+
const filteredParams = Object.entries(queryParameters).reduce((acc, [key, value]) => {
|
|
613
|
+
if (value != null) {
|
|
614
|
+
acc[key] = value;
|
|
615
|
+
}
|
|
616
|
+
return acc;
|
|
617
|
+
}, {});
|
|
618
|
+
if (Object.keys(filteredParams).length === 0) {
|
|
619
|
+
return "";
|
|
620
|
+
}
|
|
621
|
+
const queryString = import_qs.default.stringify(filteredParams, {
|
|
622
|
+
encode: false,
|
|
623
|
+
arrayFormat: "repeat",
|
|
624
|
+
skipNulls: true,
|
|
625
|
+
serializeDate: (date) => date.toISOString()
|
|
626
|
+
});
|
|
627
|
+
return queryString ? "?" + queryString : "";
|
|
628
|
+
}
|
|
629
|
+
function buildPath(path = [], pathParameters) {
|
|
630
|
+
return path.map((part) => {
|
|
631
|
+
if (part.type === "pathParameter") {
|
|
632
|
+
const key = part.value;
|
|
633
|
+
const stateValue = unknownToString(pathParameters?.[key]);
|
|
634
|
+
return stateValue.length > 0 ? encodeURIComponent(stateValue) : ":" + key;
|
|
635
|
+
}
|
|
636
|
+
return part.value;
|
|
637
|
+
}).join("");
|
|
638
|
+
}
|
|
639
|
+
function buildRequestUrl({
|
|
640
|
+
baseUrl = "",
|
|
641
|
+
path,
|
|
642
|
+
pathParameters,
|
|
643
|
+
queryParameters
|
|
644
|
+
}) {
|
|
645
|
+
const sanitizedBaseUrl = sanitizeUrl(baseUrl) || "";
|
|
646
|
+
if (sanitizedBaseUrl.endsWith("/")) {
|
|
647
|
+
return sanitizedBaseUrl.slice(0, -1) + buildPath(path, pathParameters) + buildQueryParams(queryParameters);
|
|
648
|
+
}
|
|
649
|
+
return sanitizedBaseUrl + buildPath(path, pathParameters) + buildQueryParams(queryParameters);
|
|
650
|
+
}
|
|
651
|
+
function buildEndpointUrl({
|
|
652
|
+
endpoint,
|
|
653
|
+
pathParameters,
|
|
654
|
+
queryParameters,
|
|
655
|
+
baseUrl
|
|
656
|
+
}) {
|
|
657
|
+
const environmentBaseUrl = baseUrl ?? (endpoint?.environments?.find((env) => env.id === endpoint.defaultEnvironment) ?? endpoint?.environments?.[0])?.baseUrl;
|
|
658
|
+
const sanitizedBaseUrl = sanitizeUrl(environmentBaseUrl);
|
|
659
|
+
const processedQueryParameters = preprocessQueryParameters(queryParameters, endpoint?.queryParameters ?? void 0);
|
|
660
|
+
return buildRequestUrl({
|
|
661
|
+
baseUrl: sanitizedBaseUrl || "",
|
|
662
|
+
path: endpoint?.path,
|
|
663
|
+
pathParameters,
|
|
664
|
+
queryParameters: processedQueryParameters
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
668
|
+
0 && (module.exports = {
|
|
669
|
+
STATUS_CODE_MESSAGES,
|
|
670
|
+
buildEndpointUrl,
|
|
671
|
+
buildRequestUrl,
|
|
672
|
+
getMessageForStatus,
|
|
673
|
+
preprocessQueryParameters,
|
|
674
|
+
toColonEndpointPathLiteral,
|
|
675
|
+
toCurlyBraceEndpointPathLiteral,
|
|
676
|
+
unwrapDiscriminatedUnionVariant,
|
|
677
|
+
unwrapObjectType,
|
|
678
|
+
unwrapReference
|
|
679
|
+
});
|
|
680
|
+
//# sourceMappingURL=index.js.map
|