@neat-pdf/mcp 0.1.1 → 0.1.2
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/index.js +3442 -1
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/dist/index.js
CHANGED
|
@@ -3,8 +3,163 @@ import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
|
3
3
|
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
4
|
import { NeatPdf } from "@neat-pdf/sdk";
|
|
5
5
|
import { z } from "@hono/zod-openapi";
|
|
6
|
-
import
|
|
6
|
+
import * as z$130 from "zod/v3";
|
|
7
|
+
import * as z$129 from "zod/v3";
|
|
8
|
+
import * as z$128 from "zod/v3";
|
|
9
|
+
import * as z$127 from "zod/v3";
|
|
10
|
+
import * as z$126 from "zod/v3";
|
|
11
|
+
import * as z$125 from "zod/v3";
|
|
12
|
+
import * as z$124 from "zod/v3";
|
|
13
|
+
import * as z$123 from "zod/v3";
|
|
14
|
+
import * as z$122 from "zod/v3";
|
|
15
|
+
import * as z$121 from "zod/v3";
|
|
16
|
+
import * as z$120 from "zod/v3";
|
|
17
|
+
import * as z$119 from "zod/v3";
|
|
18
|
+
import * as z$118 from "zod/v3";
|
|
19
|
+
import * as z$117 from "zod/v3";
|
|
20
|
+
import * as z$116 from "zod/v3";
|
|
21
|
+
import * as z$115 from "zod/v3";
|
|
22
|
+
import * as z$114 from "zod/v3";
|
|
23
|
+
import * as z$113 from "zod/v3";
|
|
24
|
+
import * as z$112 from "zod/v3";
|
|
25
|
+
import * as z$111 from "zod/v3";
|
|
26
|
+
import * as z$110 from "zod/v3";
|
|
27
|
+
import * as z$109 from "zod/v3";
|
|
28
|
+
import * as z$108 from "zod/v3";
|
|
29
|
+
import * as z$107 from "zod/v3";
|
|
30
|
+
import * as z$106 from "zod/v3";
|
|
31
|
+
import * as z$105 from "zod/v3";
|
|
32
|
+
import * as z$104 from "zod/v3";
|
|
33
|
+
import * as z$103 from "zod/v3";
|
|
34
|
+
import * as z$102 from "zod/v3";
|
|
35
|
+
import * as z$101 from "zod/v3";
|
|
36
|
+
import * as z$100 from "zod/v3";
|
|
37
|
+
import * as z$99 from "zod/v3";
|
|
38
|
+
import * as z$98 from "zod/v3";
|
|
39
|
+
import * as z$97 from "zod/v3";
|
|
40
|
+
import * as z$96 from "zod/v3";
|
|
41
|
+
import * as z$95 from "zod/v3";
|
|
42
|
+
import * as z$94 from "zod/v3";
|
|
43
|
+
import * as z$93 from "zod/v3";
|
|
44
|
+
import * as z$92 from "zod/v3";
|
|
45
|
+
import * as z$91 from "zod/v3";
|
|
46
|
+
import * as z$90 from "zod/v3";
|
|
47
|
+
import * as z$89 from "zod/v3";
|
|
48
|
+
import * as z$88 from "zod/v3";
|
|
49
|
+
import * as z$87 from "zod/v3";
|
|
50
|
+
import * as z$86 from "zod/v3";
|
|
51
|
+
import * as z$85 from "zod/v3";
|
|
52
|
+
import * as z$84 from "zod/v3";
|
|
53
|
+
import * as z$83 from "zod/v3";
|
|
54
|
+
import * as z$82 from "zod/v3";
|
|
55
|
+
import * as z$81 from "zod/v3";
|
|
56
|
+
import * as z$80 from "zod/v3";
|
|
57
|
+
import * as z$79 from "zod/v3";
|
|
58
|
+
import * as z$78 from "zod/v3";
|
|
59
|
+
import * as z$77 from "zod/v3";
|
|
60
|
+
import * as z$76 from "zod/v3";
|
|
61
|
+
import * as z$75 from "zod/v3";
|
|
62
|
+
import * as z$74 from "zod/v3";
|
|
63
|
+
import * as z$73 from "zod/v3";
|
|
64
|
+
import * as z$72 from "zod/v3";
|
|
65
|
+
import * as z$71 from "zod/v3";
|
|
66
|
+
import * as z$70 from "zod/v3";
|
|
67
|
+
import * as z$69 from "zod/v3";
|
|
68
|
+
import * as z$68 from "zod/v3";
|
|
69
|
+
import * as z$67 from "zod/v3";
|
|
70
|
+
import * as z$66 from "zod/v3";
|
|
71
|
+
import * as z$65 from "zod/v3";
|
|
72
|
+
import * as z$64 from "zod/v3";
|
|
73
|
+
import * as z$63 from "zod/v3";
|
|
74
|
+
import * as z$62 from "zod/v3";
|
|
75
|
+
import * as z$61 from "zod/v3";
|
|
76
|
+
import * as z$60 from "zod/v3";
|
|
77
|
+
import * as z$59 from "zod/v3";
|
|
78
|
+
import * as z$58 from "zod/v3";
|
|
79
|
+
import * as z$57 from "zod/v3";
|
|
80
|
+
import * as z$56 from "zod/v3";
|
|
81
|
+
import * as z$55 from "zod/v3";
|
|
82
|
+
import * as z$54 from "zod/v3";
|
|
83
|
+
import * as z$53 from "zod/v3";
|
|
84
|
+
import * as z$52 from "zod/v3";
|
|
85
|
+
import * as z$51 from "zod/v3";
|
|
86
|
+
import * as z$50 from "zod/v3";
|
|
87
|
+
import * as z$49 from "zod/v3";
|
|
88
|
+
import * as z$48 from "zod/v3";
|
|
89
|
+
import * as z$47 from "zod/v3";
|
|
90
|
+
import * as z$46 from "zod/v3";
|
|
91
|
+
import * as z$45 from "zod/v3";
|
|
92
|
+
import * as z$44 from "zod/v3";
|
|
93
|
+
import * as z$43 from "zod/v3";
|
|
94
|
+
import * as z$42 from "zod/v3";
|
|
95
|
+
import * as z$41 from "zod/v3";
|
|
96
|
+
import * as z$40 from "zod/v3";
|
|
97
|
+
import * as z$39 from "zod/v3";
|
|
98
|
+
import * as z$38 from "zod/v3";
|
|
99
|
+
import * as z$37 from "zod/v3";
|
|
100
|
+
import * as z$36 from "zod/v3";
|
|
101
|
+
import * as z$35 from "zod/v3";
|
|
102
|
+
import * as z$34 from "zod/v3";
|
|
103
|
+
import * as z$33 from "zod/v3";
|
|
104
|
+
import * as z$32 from "zod/v3";
|
|
105
|
+
import * as z$31 from "zod/v3";
|
|
106
|
+
import * as z$30 from "zod/v3";
|
|
107
|
+
import * as z$29 from "zod/v3";
|
|
108
|
+
import * as z$28 from "zod/v3";
|
|
109
|
+
import * as z$27 from "zod/v3";
|
|
110
|
+
import * as z$26 from "zod/v3";
|
|
111
|
+
import * as z$25 from "zod/v3";
|
|
112
|
+
import * as z$24 from "zod/v3";
|
|
113
|
+
import * as z$23 from "zod/v3";
|
|
114
|
+
import * as z$22 from "zod/v3";
|
|
115
|
+
import * as z$21 from "zod/v3";
|
|
116
|
+
import * as z$20 from "zod/v3";
|
|
117
|
+
import * as z$19 from "zod/v3";
|
|
118
|
+
import * as z$18 from "zod/v3";
|
|
119
|
+
import * as z$17 from "zod/v3";
|
|
120
|
+
import * as z$16 from "zod/v3";
|
|
121
|
+
import * as z$15 from "zod/v3";
|
|
122
|
+
import * as z$14 from "zod/v3";
|
|
123
|
+
import * as z$13 from "zod/v3";
|
|
124
|
+
import * as z$12 from "zod/v3";
|
|
125
|
+
import * as z$11 from "zod/v3";
|
|
126
|
+
import * as z$10 from "zod/v3";
|
|
127
|
+
import * as z$9 from "zod/v3";
|
|
128
|
+
import * as z$8 from "zod/v3";
|
|
129
|
+
import * as z$7 from "zod/v3";
|
|
130
|
+
import * as z$6 from "zod/v3";
|
|
131
|
+
import * as z$5 from "zod/v3";
|
|
132
|
+
import * as z$4 from "zod/v3";
|
|
133
|
+
import * as z$3 from "zod/v3";
|
|
134
|
+
import * as z$2 from "zod/v3";
|
|
135
|
+
import { z as z$1 } from "zod";
|
|
7
136
|
|
|
137
|
+
//#region rolldown:runtime
|
|
138
|
+
var __create = Object.create;
|
|
139
|
+
var __defProp = Object.defineProperty;
|
|
140
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
141
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
142
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
143
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
144
|
+
var __commonJS = (cb, mod) => function() {
|
|
145
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
146
|
+
};
|
|
147
|
+
var __copyProps = (to, from, except, desc) => {
|
|
148
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
149
|
+
key = keys[i];
|
|
150
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
151
|
+
get: ((k) => from[k]).bind(null, key),
|
|
152
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return to;
|
|
156
|
+
};
|
|
157
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
158
|
+
value: mod,
|
|
159
|
+
enumerable: true
|
|
160
|
+
}) : target, mod));
|
|
161
|
+
|
|
162
|
+
//#endregion
|
|
8
163
|
//#region src/constants.ts
|
|
9
164
|
const INVALID_API_KEYS = ["${NEAT_PDF_API_KEY}", "your-api-key"];
|
|
10
165
|
const SIGNUP_MESSAGE = `
|
|
@@ -27,6 +182,3292 @@ if (!apiKey || INVALID_API_KEYS.includes(apiKey)) {
|
|
|
27
182
|
}
|
|
28
183
|
const client = new NeatPdf({ apiKey });
|
|
29
184
|
|
|
185
|
+
//#endregion
|
|
186
|
+
//#region ../shared/dist/constants/files.js
|
|
187
|
+
const MAX_FILE_SIZE_BYTES = 2 * 1024 * 1024;
|
|
188
|
+
|
|
189
|
+
//#endregion
|
|
190
|
+
//#region ../shared/dist/constants/plans.js
|
|
191
|
+
const PlanTier = {
|
|
192
|
+
FREE: "free",
|
|
193
|
+
HOBBY: "hobby",
|
|
194
|
+
PRO: "pro",
|
|
195
|
+
BUSINESS: "business"
|
|
196
|
+
};
|
|
197
|
+
const PLAN_CONFIG = {
|
|
198
|
+
[PlanTier.FREE]: {
|
|
199
|
+
tier: PlanTier.FREE,
|
|
200
|
+
name: "Free",
|
|
201
|
+
priceMonthly: 0,
|
|
202
|
+
credits: 100,
|
|
203
|
+
rateLimit: 3,
|
|
204
|
+
maxFileSizeMb: 2,
|
|
205
|
+
timeoutSeconds: 15
|
|
206
|
+
},
|
|
207
|
+
[PlanTier.HOBBY]: {
|
|
208
|
+
tier: PlanTier.HOBBY,
|
|
209
|
+
name: "Hobby",
|
|
210
|
+
priceMonthly: 9,
|
|
211
|
+
credits: 500,
|
|
212
|
+
rateLimit: 10,
|
|
213
|
+
maxFileSizeMb: 5,
|
|
214
|
+
timeoutSeconds: 20
|
|
215
|
+
},
|
|
216
|
+
[PlanTier.PRO]: {
|
|
217
|
+
tier: PlanTier.PRO,
|
|
218
|
+
name: "Pro",
|
|
219
|
+
priceMonthly: 19,
|
|
220
|
+
credits: 2e3,
|
|
221
|
+
rateLimit: 60,
|
|
222
|
+
maxFileSizeMb: 20,
|
|
223
|
+
timeoutSeconds: 30
|
|
224
|
+
},
|
|
225
|
+
[PlanTier.BUSINESS]: {
|
|
226
|
+
tier: PlanTier.BUSINESS,
|
|
227
|
+
name: "Business",
|
|
228
|
+
priceMonthly: 49,
|
|
229
|
+
credits: 1e4,
|
|
230
|
+
rateLimit: 200,
|
|
231
|
+
maxFileSizeMb: 100,
|
|
232
|
+
timeoutSeconds: 60
|
|
233
|
+
}
|
|
234
|
+
};
|
|
235
|
+
const PLAN_TIERS = Object.values(PlanTier);
|
|
236
|
+
const BYTES_PER_MB = 1024 * 1024;
|
|
237
|
+
|
|
238
|
+
//#endregion
|
|
239
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/lib/http.js
|
|
240
|
+
const codeRangeRE$1 = new RegExp("^[0-9]xx$", "i");
|
|
241
|
+
|
|
242
|
+
//#endregion
|
|
243
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/lib/base64.js
|
|
244
|
+
function bytesToBase64(u8arr) {
|
|
245
|
+
return btoa(String.fromCodePoint(...u8arr));
|
|
246
|
+
}
|
|
247
|
+
function bytesFromBase64(encoded) {
|
|
248
|
+
return Uint8Array.from(atob(encoded), (c) => c.charCodeAt(0));
|
|
249
|
+
}
|
|
250
|
+
function stringToBytes(str) {
|
|
251
|
+
return new TextEncoder().encode(str);
|
|
252
|
+
}
|
|
253
|
+
const zodOutbound = z$130.instanceof(Uint8Array).or(z$130.string().transform(stringToBytes));
|
|
254
|
+
const zodInbound = z$130.instanceof(Uint8Array).or(z$130.string().transform(bytesFromBase64));
|
|
255
|
+
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/lib/is-plain-object.js
|
|
258
|
+
function isPlainObject(value) {
|
|
259
|
+
if (typeof value !== "object" || value === null) return false;
|
|
260
|
+
const prototype = Object.getPrototypeOf(value);
|
|
261
|
+
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in value) && !(Symbol.iterator in value);
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
//#endregion
|
|
265
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/lib/encodings.js
|
|
266
|
+
var EncodingError = class extends Error {
|
|
267
|
+
constructor(message) {
|
|
268
|
+
super(message);
|
|
269
|
+
this.name = "EncodingError";
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
function formEncoder(sep) {
|
|
273
|
+
return (key, value, options) => {
|
|
274
|
+
let out = "";
|
|
275
|
+
const pairs = options?.explode ? explode(key, value) : [[key, value]];
|
|
276
|
+
if (pairs.every(([_, v]) => v == null)) return;
|
|
277
|
+
const encodeString = (v) => {
|
|
278
|
+
return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
|
|
279
|
+
};
|
|
280
|
+
const encodeValue = (v) => encodeString(serializeValue(v));
|
|
281
|
+
const encodedSep = encodeString(sep);
|
|
282
|
+
pairs.forEach(([pk, pv]) => {
|
|
283
|
+
let tmp = "";
|
|
284
|
+
let encValue = null;
|
|
285
|
+
if (pv == null) return;
|
|
286
|
+
else if (Array.isArray(pv)) encValue = mapDefined(pv, (v) => `${encodeValue(v)}`)?.join(encodedSep);
|
|
287
|
+
else if (isPlainObject(pv)) encValue = mapDefinedEntries(Object.entries(pv), ([k, v]) => {
|
|
288
|
+
return `${encodeString(k)}${encodedSep}${encodeValue(v)}`;
|
|
289
|
+
})?.join(encodedSep);
|
|
290
|
+
else encValue = `${encodeValue(pv)}`;
|
|
291
|
+
if (encValue == null) return;
|
|
292
|
+
tmp = `${encodeString(pk)}=${encValue}`;
|
|
293
|
+
if (!tmp || tmp === "=") return;
|
|
294
|
+
out += `&${tmp}`;
|
|
295
|
+
});
|
|
296
|
+
return out.slice(1);
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
const encodeForm = formEncoder(",");
|
|
300
|
+
const encodeSpaceDelimited = formEncoder(" ");
|
|
301
|
+
const encodePipeDelimited = formEncoder("|");
|
|
302
|
+
function encodeDeepObject(key, value, options) {
|
|
303
|
+
if (value == null) return;
|
|
304
|
+
if (!isPlainObject(value)) throw new EncodingError(`Value of parameter '${key}' which uses deepObject encoding must be an object or null`);
|
|
305
|
+
return encodeDeepObjectObject(key, value, options);
|
|
306
|
+
}
|
|
307
|
+
function encodeDeepObjectObject(key, value, options) {
|
|
308
|
+
if (value == null) return;
|
|
309
|
+
let out = "";
|
|
310
|
+
const encodeString = (v) => {
|
|
311
|
+
return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
|
|
312
|
+
};
|
|
313
|
+
if (!isPlainObject(value)) throw new EncodingError(`Expected parameter '${key}' to be an object.`);
|
|
314
|
+
Object.entries(value).forEach(([ck, cv]) => {
|
|
315
|
+
if (cv == null) return;
|
|
316
|
+
const pk = `${key}[${ck}]`;
|
|
317
|
+
if (isPlainObject(cv)) {
|
|
318
|
+
const objOut = encodeDeepObjectObject(pk, cv, options);
|
|
319
|
+
out += objOut == null ? "" : `&${objOut}`;
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const pairs = Array.isArray(cv) ? cv : [cv];
|
|
323
|
+
const encoded = mapDefined(pairs, (v) => {
|
|
324
|
+
return `${encodeString(pk)}=${encodeString(serializeValue(v))}`;
|
|
325
|
+
})?.join("&");
|
|
326
|
+
out += encoded == null ? "" : `&${encoded}`;
|
|
327
|
+
});
|
|
328
|
+
return out.slice(1);
|
|
329
|
+
}
|
|
330
|
+
function encodeJSON(key, value, options) {
|
|
331
|
+
if (typeof value === "undefined") return;
|
|
332
|
+
const encodeString = (v) => {
|
|
333
|
+
return options?.charEncoding === "percent" ? encodeURIComponent(v) : v;
|
|
334
|
+
};
|
|
335
|
+
const encVal = encodeString(JSON.stringify(value, jsonReplacer));
|
|
336
|
+
return options?.explode ? encVal : `${encodeString(key)}=${encVal}`;
|
|
337
|
+
}
|
|
338
|
+
function explode(key, value) {
|
|
339
|
+
if (Array.isArray(value)) return value.map((v) => [key, v]);
|
|
340
|
+
else if (isPlainObject(value)) {
|
|
341
|
+
const o = value ?? {};
|
|
342
|
+
return Object.entries(o).map(([k, v]) => [k, v]);
|
|
343
|
+
} else return [[key, value]];
|
|
344
|
+
}
|
|
345
|
+
function serializeValue(value) {
|
|
346
|
+
if (value == null) return "";
|
|
347
|
+
else if (value instanceof Date) return value.toISOString();
|
|
348
|
+
else if (value instanceof Uint8Array) return bytesToBase64(value);
|
|
349
|
+
else if (typeof value === "object") return JSON.stringify(value, jsonReplacer);
|
|
350
|
+
return `${value}`;
|
|
351
|
+
}
|
|
352
|
+
function jsonReplacer(_, value) {
|
|
353
|
+
if (value instanceof Uint8Array) return bytesToBase64(value);
|
|
354
|
+
else return value;
|
|
355
|
+
}
|
|
356
|
+
function mapDefined(inp, mapper) {
|
|
357
|
+
const res = inp.reduce((acc, v) => {
|
|
358
|
+
if (v == null) return acc;
|
|
359
|
+
const m = mapper(v);
|
|
360
|
+
if (m == null) return acc;
|
|
361
|
+
acc.push(m);
|
|
362
|
+
return acc;
|
|
363
|
+
}, []);
|
|
364
|
+
return res.length ? res : null;
|
|
365
|
+
}
|
|
366
|
+
function mapDefinedEntries(inp, mapper) {
|
|
367
|
+
const acc = [];
|
|
368
|
+
for (const [k, v] of inp) {
|
|
369
|
+
if (v == null) continue;
|
|
370
|
+
const m = mapper([k, v]);
|
|
371
|
+
if (m == null) continue;
|
|
372
|
+
acc.push(m);
|
|
373
|
+
}
|
|
374
|
+
return acc.length ? acc : null;
|
|
375
|
+
}
|
|
376
|
+
function queryJoin(...args) {
|
|
377
|
+
return args.filter(Boolean).join("&");
|
|
378
|
+
}
|
|
379
|
+
function queryEncoder(f) {
|
|
380
|
+
const bulkEncode = function(values, options) {
|
|
381
|
+
const opts = {
|
|
382
|
+
...options,
|
|
383
|
+
explode: options?.explode ?? true,
|
|
384
|
+
charEncoding: options?.charEncoding ?? "percent"
|
|
385
|
+
};
|
|
386
|
+
const allowEmptySet = new Set(options?.allowEmptyValue ?? []);
|
|
387
|
+
const encoded = Object.entries(values).map(([key, value]) => {
|
|
388
|
+
if (allowEmptySet.has(key)) {
|
|
389
|
+
if (value === void 0 || value === null || value === "" || Array.isArray(value) && value.length === 0) return `${encodeURIComponent(key)}=`;
|
|
390
|
+
}
|
|
391
|
+
return f(key, value, opts);
|
|
392
|
+
});
|
|
393
|
+
return queryJoin(...encoded);
|
|
394
|
+
};
|
|
395
|
+
return bulkEncode;
|
|
396
|
+
}
|
|
397
|
+
const encodeJSONQuery = queryEncoder(encodeJSON);
|
|
398
|
+
const encodeFormQuery = queryEncoder(encodeForm);
|
|
399
|
+
const encodeSpaceDelimitedQuery = queryEncoder(encodeSpaceDelimited);
|
|
400
|
+
const encodePipeDelimitedQuery = queryEncoder(encodePipeDelimited);
|
|
401
|
+
const encodeDeepObjectQuery = queryEncoder(encodeDeepObject);
|
|
402
|
+
|
|
403
|
+
//#endregion
|
|
404
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/lib/env.js
|
|
405
|
+
const envSchema = z$129.object({
|
|
406
|
+
UNKEY_ROOT_KEY: z$129.string().optional(),
|
|
407
|
+
UNKEY_DEBUG: z$129.coerce.boolean().optional()
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
//#endregion
|
|
411
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/lib/retries.js
|
|
412
|
+
const codeRangeRE = new RegExp("^[0-9]xx$", "i");
|
|
413
|
+
|
|
414
|
+
//#endregion
|
|
415
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/lib/sdks.js
|
|
416
|
+
var __classPrivateFieldSet$1 = void 0 && (void 0).__classPrivateFieldSet || function(receiver, state, value, kind, f) {
|
|
417
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
418
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
419
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
420
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
421
|
+
};
|
|
422
|
+
var __classPrivateFieldGet$1 = void 0 && (void 0).__classPrivateFieldGet || function(receiver, state, kind, f) {
|
|
423
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
424
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
425
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
426
|
+
};
|
|
427
|
+
var _ClientSDK_httpClient, _ClientSDK_hooks, _ClientSDK_logger;
|
|
428
|
+
const gt = typeof globalThis === "undefined" ? null : globalThis;
|
|
429
|
+
const webWorkerLike = typeof gt === "object" && gt != null && "importScripts" in gt && typeof gt["importScripts"] === "function";
|
|
430
|
+
const isBrowserLike = webWorkerLike || typeof navigator !== "undefined" && "serviceWorker" in navigator || typeof window === "object" && typeof window.document !== "undefined";
|
|
431
|
+
_ClientSDK_httpClient = new WeakMap(), _ClientSDK_hooks = new WeakMap(), _ClientSDK_logger = new WeakMap();
|
|
432
|
+
|
|
433
|
+
//#endregion
|
|
434
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/unkeyerror.js
|
|
435
|
+
/** The base class for all HTTP error responses */
|
|
436
|
+
var UnkeyError = class extends Error {
|
|
437
|
+
constructor(message, httpMeta) {
|
|
438
|
+
super(message);
|
|
439
|
+
this.statusCode = httpMeta.response.status;
|
|
440
|
+
this.body = httpMeta.body;
|
|
441
|
+
this.headers = httpMeta.response.headers;
|
|
442
|
+
this.contentType = httpMeta.response.headers.get("content-type") || "";
|
|
443
|
+
this.rawResponse = httpMeta.response;
|
|
444
|
+
this.name = "UnkeyError";
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
|
|
448
|
+
//#endregion
|
|
449
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/sdkvalidationerror.js
|
|
450
|
+
var SDKValidationError = class extends Error {
|
|
451
|
+
static [Symbol.hasInstance](instance) {
|
|
452
|
+
if (!(instance instanceof Error)) return false;
|
|
453
|
+
if (!("rawValue" in instance)) return false;
|
|
454
|
+
if (!("rawMessage" in instance)) return false;
|
|
455
|
+
if (!("pretty" in instance)) return false;
|
|
456
|
+
if (typeof instance.pretty !== "function") return false;
|
|
457
|
+
return true;
|
|
458
|
+
}
|
|
459
|
+
constructor(message, cause, rawValue) {
|
|
460
|
+
super(`${message}: ${cause}`);
|
|
461
|
+
this.name = "SDKValidationError";
|
|
462
|
+
this.cause = cause;
|
|
463
|
+
this.rawValue = rawValue;
|
|
464
|
+
this.rawMessage = message;
|
|
465
|
+
}
|
|
466
|
+
/**
|
|
467
|
+
* Return a pretty-formatted error message if the underlying validation error
|
|
468
|
+
* is a ZodError or some other recognized error type, otherwise return the
|
|
469
|
+
* default error message.
|
|
470
|
+
*/
|
|
471
|
+
pretty() {
|
|
472
|
+
if (this.cause instanceof z$128.ZodError) return `${this.rawMessage}\n${formatZodError(this.cause)}`;
|
|
473
|
+
else return this.toString();
|
|
474
|
+
}
|
|
475
|
+
};
|
|
476
|
+
function formatZodError(err, level = 0) {
|
|
477
|
+
let pre = " ".repeat(level);
|
|
478
|
+
pre = level > 0 ? `│${pre}` : pre;
|
|
479
|
+
pre += " ".repeat(level);
|
|
480
|
+
let message = "";
|
|
481
|
+
const append = (str) => message += `\n${pre}${str}`;
|
|
482
|
+
const len = err.issues.length;
|
|
483
|
+
const headline = len === 1 ? `${len} issue found` : `${len} issues found`;
|
|
484
|
+
if (len) append(`┌ ${headline}:`);
|
|
485
|
+
for (const issue of err.issues) {
|
|
486
|
+
let path = issue.path.join(".");
|
|
487
|
+
path = path ? `<root>.${path}` : "<root>";
|
|
488
|
+
append(`│ • [${path}]: ${issue.message} (${issue.code})`);
|
|
489
|
+
switch (issue.code) {
|
|
490
|
+
case "invalid_literal":
|
|
491
|
+
case "invalid_type": {
|
|
492
|
+
append(`│ Want: ${issue.expected}`);
|
|
493
|
+
append(`│ Got: ${issue.received}`);
|
|
494
|
+
break;
|
|
495
|
+
}
|
|
496
|
+
case "unrecognized_keys": {
|
|
497
|
+
append(`│ Keys: ${issue.keys.join(", ")}`);
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
case "invalid_enum_value": {
|
|
501
|
+
append(`│ Allowed: ${issue.options.join(", ")}`);
|
|
502
|
+
append(`│ Got: ${issue.received}`);
|
|
503
|
+
break;
|
|
504
|
+
}
|
|
505
|
+
case "invalid_union_discriminator": {
|
|
506
|
+
append(`│ Allowed: ${issue.options.join(", ")}`);
|
|
507
|
+
break;
|
|
508
|
+
}
|
|
509
|
+
case "invalid_union": {
|
|
510
|
+
const len$1 = issue.unionErrors.length;
|
|
511
|
+
append(`│ ✖︎ Attemped to deserialize into one of ${len$1} union members:`);
|
|
512
|
+
issue.unionErrors.forEach((err$1, i) => {
|
|
513
|
+
append(`│ ✖︎ Member ${i + 1} of ${len$1}`);
|
|
514
|
+
append(`${formatZodError(err$1, level + 1)}`);
|
|
515
|
+
});
|
|
516
|
+
}
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
if (err.issues.length) append(`└─*`);
|
|
520
|
+
return message.slice(1);
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/lib/primitives.js
|
|
525
|
+
/**
|
|
526
|
+
* Converts or omits an object's keys according to a mapping.
|
|
527
|
+
*
|
|
528
|
+
* @param inp An object whose keys will be remapped
|
|
529
|
+
* @param mappings A mapping of original keys to new keys. If a key is not present in the mapping, it will be left as is. If a key is mapped to `null`, it will be removed in the resulting object.
|
|
530
|
+
* @returns A new object with keys remapped or omitted according to the mappings
|
|
531
|
+
*/
|
|
532
|
+
function remap(inp, mappings) {
|
|
533
|
+
let out = {};
|
|
534
|
+
if (!Object.keys(mappings).length) {
|
|
535
|
+
out = inp;
|
|
536
|
+
return out;
|
|
537
|
+
}
|
|
538
|
+
for (const [k, v] of Object.entries(inp)) {
|
|
539
|
+
const j = mappings[k];
|
|
540
|
+
if (j === null) continue;
|
|
541
|
+
out[j ?? k] = v;
|
|
542
|
+
}
|
|
543
|
+
return out;
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
//#endregion
|
|
547
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/lib/security.js
|
|
548
|
+
var SecurityErrorCode;
|
|
549
|
+
(function(SecurityErrorCode$1) {
|
|
550
|
+
SecurityErrorCode$1["Incomplete"] = "incomplete";
|
|
551
|
+
SecurityErrorCode$1["UnrecognisedSecurityType"] = "unrecognized_security_type";
|
|
552
|
+
})(SecurityErrorCode || (SecurityErrorCode = {}));
|
|
553
|
+
|
|
554
|
+
//#endregion
|
|
555
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/validationerror.js
|
|
556
|
+
/** @internal */
|
|
557
|
+
const ValidationError$inboundSchema = z$127.object({
|
|
558
|
+
location: z$127.string(),
|
|
559
|
+
message: z$127.string(),
|
|
560
|
+
fix: z$127.string().optional()
|
|
561
|
+
});
|
|
562
|
+
|
|
563
|
+
//#endregion
|
|
564
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/badrequesterrordetails.js
|
|
565
|
+
/** @internal */
|
|
566
|
+
const BadRequestErrorDetails$inboundSchema = z$126.object({
|
|
567
|
+
detail: z$126.string(),
|
|
568
|
+
status: z$126.number().int(),
|
|
569
|
+
title: z$126.string(),
|
|
570
|
+
type: z$126.string(),
|
|
571
|
+
errors: z$126.array(ValidationError$inboundSchema)
|
|
572
|
+
});
|
|
573
|
+
|
|
574
|
+
//#endregion
|
|
575
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/baseerror.js
|
|
576
|
+
/** @internal */
|
|
577
|
+
const BaseError$inboundSchema = z$125.object({
|
|
578
|
+
detail: z$125.string(),
|
|
579
|
+
status: z$125.number().int(),
|
|
580
|
+
title: z$125.string(),
|
|
581
|
+
type: z$125.string()
|
|
582
|
+
});
|
|
583
|
+
|
|
584
|
+
//#endregion
|
|
585
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/emptyresponse.js
|
|
586
|
+
/** @internal */
|
|
587
|
+
const EmptyResponse$inboundSchema = z$124.object({});
|
|
588
|
+
|
|
589
|
+
//#endregion
|
|
590
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/ratelimitresponse.js
|
|
591
|
+
/** @internal */
|
|
592
|
+
const RatelimitResponse$inboundSchema = z$123.object({
|
|
593
|
+
id: z$123.string(),
|
|
594
|
+
name: z$123.string(),
|
|
595
|
+
limit: z$123.number().int(),
|
|
596
|
+
duration: z$123.number().int(),
|
|
597
|
+
autoApply: z$123.boolean()
|
|
598
|
+
});
|
|
599
|
+
|
|
600
|
+
//#endregion
|
|
601
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/identity.js
|
|
602
|
+
/** @internal */
|
|
603
|
+
const Identity$inboundSchema = z$122.object({
|
|
604
|
+
id: z$122.string(),
|
|
605
|
+
externalId: z$122.string(),
|
|
606
|
+
meta: z$122.record(z$122.any()).optional(),
|
|
607
|
+
ratelimits: z$122.array(RatelimitResponse$inboundSchema).optional()
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
//#endregion
|
|
611
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/keycreditsrefill.js
|
|
612
|
+
/**
|
|
613
|
+
* How often credits are automatically refilled.
|
|
614
|
+
*/
|
|
615
|
+
const KeyCreditsRefillInterval = {
|
|
616
|
+
Daily: "daily",
|
|
617
|
+
Monthly: "monthly"
|
|
618
|
+
};
|
|
619
|
+
/** @internal */
|
|
620
|
+
const KeyCreditsRefillInterval$inboundSchema = z$121.nativeEnum(KeyCreditsRefillInterval);
|
|
621
|
+
/** @internal */
|
|
622
|
+
const KeyCreditsRefillInterval$outboundSchema = KeyCreditsRefillInterval$inboundSchema;
|
|
623
|
+
/** @internal */
|
|
624
|
+
const KeyCreditsRefill$inboundSchema = z$121.object({
|
|
625
|
+
interval: KeyCreditsRefillInterval$inboundSchema,
|
|
626
|
+
amount: z$121.number().int(),
|
|
627
|
+
refillDay: z$121.number().int().optional()
|
|
628
|
+
});
|
|
629
|
+
/** @internal */
|
|
630
|
+
const KeyCreditsRefill$outboundSchema = z$121.object({
|
|
631
|
+
interval: KeyCreditsRefillInterval$outboundSchema,
|
|
632
|
+
amount: z$121.number().int(),
|
|
633
|
+
refillDay: z$121.number().int().optional()
|
|
634
|
+
});
|
|
635
|
+
|
|
636
|
+
//#endregion
|
|
637
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/keycreditsdata.js
|
|
638
|
+
/** @internal */
|
|
639
|
+
const KeyCreditsData$inboundSchema = z$120.object({
|
|
640
|
+
remaining: z$120.nullable(z$120.number().int()),
|
|
641
|
+
refill: KeyCreditsRefill$inboundSchema.optional()
|
|
642
|
+
});
|
|
643
|
+
/** @internal */
|
|
644
|
+
const KeyCreditsData$outboundSchema = z$120.object({
|
|
645
|
+
remaining: z$120.nullable(z$120.number().int()),
|
|
646
|
+
refill: KeyCreditsRefill$outboundSchema.optional()
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
//#endregion
|
|
650
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/keyresponsedata.js
|
|
651
|
+
/** @internal */
|
|
652
|
+
const KeyResponseData$inboundSchema = z$119.object({
|
|
653
|
+
keyId: z$119.string(),
|
|
654
|
+
start: z$119.string(),
|
|
655
|
+
enabled: z$119.boolean(),
|
|
656
|
+
name: z$119.string().optional(),
|
|
657
|
+
meta: z$119.record(z$119.any()).optional(),
|
|
658
|
+
createdAt: z$119.number().int(),
|
|
659
|
+
updatedAt: z$119.number().int().optional(),
|
|
660
|
+
expires: z$119.number().int().optional(),
|
|
661
|
+
permissions: z$119.array(z$119.string()).optional(),
|
|
662
|
+
roles: z$119.array(z$119.string()).optional(),
|
|
663
|
+
credits: KeyCreditsData$inboundSchema.optional(),
|
|
664
|
+
identity: Identity$inboundSchema.optional(),
|
|
665
|
+
plaintext: z$119.string().optional(),
|
|
666
|
+
ratelimits: z$119.array(RatelimitResponse$inboundSchema).optional()
|
|
667
|
+
});
|
|
668
|
+
|
|
669
|
+
//#endregion
|
|
670
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/keysverifykeycredits.js
|
|
671
|
+
/** @internal */
|
|
672
|
+
const KeysVerifyKeyCredits$outboundSchema = z$118.object({ cost: z$118.number().int() });
|
|
673
|
+
|
|
674
|
+
//#endregion
|
|
675
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/keysverifykeyratelimit.js
|
|
676
|
+
/** @internal */
|
|
677
|
+
const KeysVerifyKeyRatelimit$outboundSchema = z$117.object({
|
|
678
|
+
name: z$117.string(),
|
|
679
|
+
cost: z$117.number().int().default(1),
|
|
680
|
+
limit: z$117.number().int().optional(),
|
|
681
|
+
duration: z$117.number().int().optional()
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/meta.js
|
|
686
|
+
/** @internal */
|
|
687
|
+
const Meta$inboundSchema = z$116.object({ requestId: z$116.string() });
|
|
688
|
+
|
|
689
|
+
//#endregion
|
|
690
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/pagination.js
|
|
691
|
+
/** @internal */
|
|
692
|
+
const Pagination$inboundSchema = z$115.object({
|
|
693
|
+
cursor: z$115.string().optional(),
|
|
694
|
+
hasMore: z$115.boolean()
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
//#endregion
|
|
698
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/permission.js
|
|
699
|
+
/** @internal */
|
|
700
|
+
const Permission$inboundSchema = z$114.object({
|
|
701
|
+
id: z$114.string(),
|
|
702
|
+
name: z$114.string(),
|
|
703
|
+
slug: z$114.string(),
|
|
704
|
+
description: z$114.string().optional()
|
|
705
|
+
});
|
|
706
|
+
|
|
707
|
+
//#endregion
|
|
708
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/ratelimitoverride.js
|
|
709
|
+
/** @internal */
|
|
710
|
+
const RatelimitOverride$inboundSchema = z$113.object({
|
|
711
|
+
overrideId: z$113.string(),
|
|
712
|
+
duration: z$113.number().int(),
|
|
713
|
+
identifier: z$113.string(),
|
|
714
|
+
limit: z$113.number().int()
|
|
715
|
+
});
|
|
716
|
+
|
|
717
|
+
//#endregion
|
|
718
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/ratelimitrequest.js
|
|
719
|
+
/** @internal */
|
|
720
|
+
const RatelimitRequest$outboundSchema = z$112.object({
|
|
721
|
+
name: z$112.string(),
|
|
722
|
+
limit: z$112.number().int(),
|
|
723
|
+
duration: z$112.number().int(),
|
|
724
|
+
autoApply: z$112.boolean().default(false)
|
|
725
|
+
});
|
|
726
|
+
|
|
727
|
+
//#endregion
|
|
728
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/role.js
|
|
729
|
+
/** @internal */
|
|
730
|
+
const Role$inboundSchema = z$111.object({
|
|
731
|
+
id: z$111.string(),
|
|
732
|
+
name: z$111.string(),
|
|
733
|
+
description: z$111.string().optional(),
|
|
734
|
+
permissions: z$111.array(Permission$inboundSchema).optional()
|
|
735
|
+
});
|
|
736
|
+
|
|
737
|
+
//#endregion
|
|
738
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/security.js
|
|
739
|
+
/** @internal */
|
|
740
|
+
const Security$outboundSchema = z$110.object({ rootKey: z$110.string().optional() });
|
|
741
|
+
|
|
742
|
+
//#endregion
|
|
743
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/updatekeycreditsrefill.js
|
|
744
|
+
/**
|
|
745
|
+
* How often credits are automatically refilled.
|
|
746
|
+
*/
|
|
747
|
+
const UpdateKeyCreditsRefillInterval = {
|
|
748
|
+
Daily: "daily",
|
|
749
|
+
Monthly: "monthly"
|
|
750
|
+
};
|
|
751
|
+
/** @internal */
|
|
752
|
+
const UpdateKeyCreditsRefillInterval$outboundSchema = z$109.nativeEnum(UpdateKeyCreditsRefillInterval);
|
|
753
|
+
/** @internal */
|
|
754
|
+
const UpdateKeyCreditsRefill$outboundSchema = z$109.object({
|
|
755
|
+
interval: UpdateKeyCreditsRefillInterval$outboundSchema,
|
|
756
|
+
amount: z$109.number().int(),
|
|
757
|
+
refillDay: z$109.number().int().optional()
|
|
758
|
+
});
|
|
759
|
+
|
|
760
|
+
//#endregion
|
|
761
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/updatekeycreditsdata.js
|
|
762
|
+
/** @internal */
|
|
763
|
+
const UpdateKeyCreditsData$outboundSchema = z$108.object({
|
|
764
|
+
remaining: z$108.nullable(z$108.number().int()).optional(),
|
|
765
|
+
refill: z$108.nullable(UpdateKeyCreditsRefill$outboundSchema).optional()
|
|
766
|
+
});
|
|
767
|
+
|
|
768
|
+
//#endregion
|
|
769
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2analyticsgetverificationsrequestbody.js
|
|
770
|
+
/** @internal */
|
|
771
|
+
const V2AnalyticsGetVerificationsRequestBody$outboundSchema = z$107.object({ query: z$107.string() });
|
|
772
|
+
|
|
773
|
+
//#endregion
|
|
774
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2analyticsgetverificationsresponsebody.js
|
|
775
|
+
/** @internal */
|
|
776
|
+
const V2AnalyticsGetVerificationsResponseBody$inboundSchema = z$106.object({
|
|
777
|
+
meta: Meta$inboundSchema,
|
|
778
|
+
data: z$106.array(z$106.record(z$106.any()))
|
|
779
|
+
});
|
|
780
|
+
|
|
781
|
+
//#endregion
|
|
782
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2apiscreateapirequestbody.js
|
|
783
|
+
/** @internal */
|
|
784
|
+
const V2ApisCreateApiRequestBody$outboundSchema = z$105.object({ name: z$105.string() });
|
|
785
|
+
|
|
786
|
+
//#endregion
|
|
787
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2apiscreateapiresponsedata.js
|
|
788
|
+
/** @internal */
|
|
789
|
+
const V2ApisCreateApiResponseData$inboundSchema = z$104.object({ apiId: z$104.string() });
|
|
790
|
+
|
|
791
|
+
//#endregion
|
|
792
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2apiscreateapiresponsebody.js
|
|
793
|
+
/** @internal */
|
|
794
|
+
const V2ApisCreateApiResponseBody$inboundSchema = z$103.object({
|
|
795
|
+
meta: Meta$inboundSchema,
|
|
796
|
+
data: V2ApisCreateApiResponseData$inboundSchema
|
|
797
|
+
});
|
|
798
|
+
|
|
799
|
+
//#endregion
|
|
800
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2apisdeleteapirequestbody.js
|
|
801
|
+
/** @internal */
|
|
802
|
+
const V2ApisDeleteApiRequestBody$outboundSchema = z$102.object({ apiId: z$102.string() });
|
|
803
|
+
|
|
804
|
+
//#endregion
|
|
805
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2apisdeleteapiresponsebody.js
|
|
806
|
+
/** @internal */
|
|
807
|
+
const V2ApisDeleteApiResponseBody$inboundSchema = z$101.object({
|
|
808
|
+
meta: Meta$inboundSchema,
|
|
809
|
+
data: EmptyResponse$inboundSchema
|
|
810
|
+
});
|
|
811
|
+
|
|
812
|
+
//#endregion
|
|
813
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2apisgetapirequestbody.js
|
|
814
|
+
/** @internal */
|
|
815
|
+
const V2ApisGetApiRequestBody$outboundSchema = z$100.object({ apiId: z$100.string() });
|
|
816
|
+
|
|
817
|
+
//#endregion
|
|
818
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2apisgetapiresponsedata.js
|
|
819
|
+
/** @internal */
|
|
820
|
+
const V2ApisGetApiResponseData$inboundSchema = z$99.object({
|
|
821
|
+
id: z$99.string(),
|
|
822
|
+
name: z$99.string()
|
|
823
|
+
});
|
|
824
|
+
|
|
825
|
+
//#endregion
|
|
826
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2apisgetapiresponsebody.js
|
|
827
|
+
/** @internal */
|
|
828
|
+
const V2ApisGetApiResponseBody$inboundSchema = z$98.object({
|
|
829
|
+
meta: Meta$inboundSchema,
|
|
830
|
+
data: V2ApisGetApiResponseData$inboundSchema
|
|
831
|
+
});
|
|
832
|
+
|
|
833
|
+
//#endregion
|
|
834
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2apislistkeysrequestbody.js
|
|
835
|
+
/** @internal */
|
|
836
|
+
const V2ApisListKeysRequestBody$outboundSchema = z$97.object({
|
|
837
|
+
apiId: z$97.string(),
|
|
838
|
+
limit: z$97.number().int().default(100),
|
|
839
|
+
cursor: z$97.string().optional(),
|
|
840
|
+
externalId: z$97.string().optional(),
|
|
841
|
+
decrypt: z$97.boolean().default(false),
|
|
842
|
+
revalidateKeysCache: z$97.boolean().default(false)
|
|
843
|
+
});
|
|
844
|
+
|
|
845
|
+
//#endregion
|
|
846
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2apislistkeysresponsebody.js
|
|
847
|
+
/** @internal */
|
|
848
|
+
const V2ApisListKeysResponseBody$inboundSchema = z$96.object({
|
|
849
|
+
meta: Meta$inboundSchema,
|
|
850
|
+
data: z$96.array(KeyResponseData$inboundSchema),
|
|
851
|
+
pagination: Pagination$inboundSchema.optional()
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
//#endregion
|
|
855
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2identitiescreateidentityrequestbody.js
|
|
856
|
+
/** @internal */
|
|
857
|
+
const V2IdentitiesCreateIdentityRequestBody$outboundSchema = z$95.object({
|
|
858
|
+
externalId: z$95.string(),
|
|
859
|
+
meta: z$95.record(z$95.any()).optional(),
|
|
860
|
+
ratelimits: z$95.array(RatelimitRequest$outboundSchema).optional()
|
|
861
|
+
});
|
|
862
|
+
|
|
863
|
+
//#endregion
|
|
864
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2identitiescreateidentityresponsedata.js
|
|
865
|
+
/** @internal */
|
|
866
|
+
const V2IdentitiesCreateIdentityResponseData$inboundSchema = z$94.object({ identityId: z$94.string() });
|
|
867
|
+
|
|
868
|
+
//#endregion
|
|
869
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2identitiescreateidentityresponsebody.js
|
|
870
|
+
/** @internal */
|
|
871
|
+
const V2IdentitiesCreateIdentityResponseBody$inboundSchema = z$93.object({
|
|
872
|
+
meta: Meta$inboundSchema,
|
|
873
|
+
data: V2IdentitiesCreateIdentityResponseData$inboundSchema
|
|
874
|
+
});
|
|
875
|
+
|
|
876
|
+
//#endregion
|
|
877
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2identitiesdeleteidentityrequestbody.js
|
|
878
|
+
/** @internal */
|
|
879
|
+
const V2IdentitiesDeleteIdentityRequestBody$outboundSchema = z$92.object({ identity: z$92.string() });
|
|
880
|
+
|
|
881
|
+
//#endregion
|
|
882
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2identitiesdeleteidentityresponsebody.js
|
|
883
|
+
/** @internal */
|
|
884
|
+
const V2IdentitiesDeleteIdentityResponseBody$inboundSchema = z$91.object({ meta: Meta$inboundSchema });
|
|
885
|
+
|
|
886
|
+
//#endregion
|
|
887
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2identitiesgetidentityrequestbody.js
|
|
888
|
+
/** @internal */
|
|
889
|
+
const V2IdentitiesGetIdentityRequestBody$outboundSchema = z$90.object({ identity: z$90.string() });
|
|
890
|
+
|
|
891
|
+
//#endregion
|
|
892
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2identitiesgetidentityresponsebody.js
|
|
893
|
+
/** @internal */
|
|
894
|
+
const V2IdentitiesGetIdentityResponseBody$inboundSchema = z$89.object({
|
|
895
|
+
meta: Meta$inboundSchema,
|
|
896
|
+
data: Identity$inboundSchema
|
|
897
|
+
});
|
|
898
|
+
|
|
899
|
+
//#endregion
|
|
900
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2identitieslistidentitiesrequestbody.js
|
|
901
|
+
/** @internal */
|
|
902
|
+
const V2IdentitiesListIdentitiesRequestBody$outboundSchema = z$88.object({
|
|
903
|
+
limit: z$88.number().int().default(100),
|
|
904
|
+
cursor: z$88.string().optional()
|
|
905
|
+
});
|
|
906
|
+
|
|
907
|
+
//#endregion
|
|
908
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2identitieslistidentitiesresponsebody.js
|
|
909
|
+
/** @internal */
|
|
910
|
+
const V2IdentitiesListIdentitiesResponseBody$inboundSchema = z$87.object({
|
|
911
|
+
meta: Meta$inboundSchema,
|
|
912
|
+
data: z$87.array(Identity$inboundSchema),
|
|
913
|
+
pagination: Pagination$inboundSchema
|
|
914
|
+
});
|
|
915
|
+
|
|
916
|
+
//#endregion
|
|
917
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2identitiesupdateidentityrequestbody.js
|
|
918
|
+
/** @internal */
|
|
919
|
+
const V2IdentitiesUpdateIdentityRequestBody$outboundSchema = z$86.object({
|
|
920
|
+
identity: z$86.string(),
|
|
921
|
+
meta: z$86.record(z$86.any()).optional(),
|
|
922
|
+
ratelimits: z$86.array(RatelimitRequest$outboundSchema).optional()
|
|
923
|
+
});
|
|
924
|
+
|
|
925
|
+
//#endregion
|
|
926
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2identitiesupdateidentityresponsebody.js
|
|
927
|
+
/** @internal */
|
|
928
|
+
const V2IdentitiesUpdateIdentityResponseBody$inboundSchema = z$85.object({
|
|
929
|
+
data: Identity$inboundSchema,
|
|
930
|
+
meta: Meta$inboundSchema
|
|
931
|
+
});
|
|
932
|
+
|
|
933
|
+
//#endregion
|
|
934
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysaddpermissionsrequestbody.js
|
|
935
|
+
/** @internal */
|
|
936
|
+
const V2KeysAddPermissionsRequestBody$outboundSchema = z$84.object({
|
|
937
|
+
keyId: z$84.string(),
|
|
938
|
+
permissions: z$84.array(z$84.string())
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
//#endregion
|
|
942
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysaddpermissionsresponsebody.js
|
|
943
|
+
/** @internal */
|
|
944
|
+
const V2KeysAddPermissionsResponseBody$inboundSchema = z$83.object({
|
|
945
|
+
meta: Meta$inboundSchema,
|
|
946
|
+
data: z$83.array(Permission$inboundSchema)
|
|
947
|
+
});
|
|
948
|
+
|
|
949
|
+
//#endregion
|
|
950
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysaddrolesrequestbody.js
|
|
951
|
+
/** @internal */
|
|
952
|
+
const V2KeysAddRolesRequestBody$outboundSchema = z$82.object({
|
|
953
|
+
keyId: z$82.string(),
|
|
954
|
+
roles: z$82.array(z$82.string())
|
|
955
|
+
});
|
|
956
|
+
|
|
957
|
+
//#endregion
|
|
958
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysaddrolesresponsebody.js
|
|
959
|
+
/** @internal */
|
|
960
|
+
const V2KeysAddRolesResponseBody$inboundSchema = z$81.object({
|
|
961
|
+
meta: Meta$inboundSchema,
|
|
962
|
+
data: z$81.array(Role$inboundSchema)
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
//#endregion
|
|
966
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keyscreatekeyrequestbody.js
|
|
967
|
+
/** @internal */
|
|
968
|
+
const V2KeysCreateKeyRequestBody$outboundSchema = z$80.object({
|
|
969
|
+
apiId: z$80.string(),
|
|
970
|
+
prefix: z$80.string().optional(),
|
|
971
|
+
name: z$80.string().optional(),
|
|
972
|
+
byteLength: z$80.number().int().default(16),
|
|
973
|
+
externalId: z$80.string().optional(),
|
|
974
|
+
meta: z$80.record(z$80.any()).optional(),
|
|
975
|
+
roles: z$80.array(z$80.string()).optional(),
|
|
976
|
+
permissions: z$80.array(z$80.string()).optional(),
|
|
977
|
+
expires: z$80.number().int().optional(),
|
|
978
|
+
credits: KeyCreditsData$outboundSchema.optional(),
|
|
979
|
+
ratelimits: z$80.array(RatelimitRequest$outboundSchema).optional(),
|
|
980
|
+
enabled: z$80.boolean().default(true),
|
|
981
|
+
recoverable: z$80.boolean().default(false)
|
|
982
|
+
});
|
|
983
|
+
|
|
984
|
+
//#endregion
|
|
985
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keyscreatekeyresponsedata.js
|
|
986
|
+
/** @internal */
|
|
987
|
+
const V2KeysCreateKeyResponseData$inboundSchema = z$79.object({
|
|
988
|
+
keyId: z$79.string(),
|
|
989
|
+
key: z$79.string()
|
|
990
|
+
});
|
|
991
|
+
|
|
992
|
+
//#endregion
|
|
993
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keyscreatekeyresponsebody.js
|
|
994
|
+
/** @internal */
|
|
995
|
+
const V2KeysCreateKeyResponseBody$inboundSchema = z$78.object({
|
|
996
|
+
meta: Meta$inboundSchema,
|
|
997
|
+
data: V2KeysCreateKeyResponseData$inboundSchema
|
|
998
|
+
});
|
|
999
|
+
|
|
1000
|
+
//#endregion
|
|
1001
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysdeletekeyrequestbody.js
|
|
1002
|
+
/** @internal */
|
|
1003
|
+
const V2KeysDeleteKeyRequestBody$outboundSchema = z$77.object({
|
|
1004
|
+
keyId: z$77.string(),
|
|
1005
|
+
permanent: z$77.boolean().default(false)
|
|
1006
|
+
});
|
|
1007
|
+
|
|
1008
|
+
//#endregion
|
|
1009
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysdeletekeyresponsebody.js
|
|
1010
|
+
/** @internal */
|
|
1011
|
+
const V2KeysDeleteKeyResponseBody$inboundSchema = z$76.object({
|
|
1012
|
+
meta: Meta$inboundSchema,
|
|
1013
|
+
data: EmptyResponse$inboundSchema
|
|
1014
|
+
});
|
|
1015
|
+
|
|
1016
|
+
//#endregion
|
|
1017
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysgetkeyrequestbody.js
|
|
1018
|
+
/** @internal */
|
|
1019
|
+
const V2KeysGetKeyRequestBody$outboundSchema = z$75.object({
|
|
1020
|
+
keyId: z$75.string(),
|
|
1021
|
+
decrypt: z$75.boolean().default(false)
|
|
1022
|
+
});
|
|
1023
|
+
|
|
1024
|
+
//#endregion
|
|
1025
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysgetkeyresponsebody.js
|
|
1026
|
+
/** @internal */
|
|
1027
|
+
const V2KeysGetKeyResponseBody$inboundSchema = z$74.object({
|
|
1028
|
+
meta: Meta$inboundSchema,
|
|
1029
|
+
data: KeyResponseData$inboundSchema
|
|
1030
|
+
});
|
|
1031
|
+
|
|
1032
|
+
//#endregion
|
|
1033
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysmigratekeydata.js
|
|
1034
|
+
/** @internal */
|
|
1035
|
+
const V2KeysMigrateKeyData$outboundSchema = z$73.object({
|
|
1036
|
+
hash: z$73.string(),
|
|
1037
|
+
name: z$73.string().optional(),
|
|
1038
|
+
externalId: z$73.string().optional(),
|
|
1039
|
+
meta: z$73.record(z$73.any()).optional(),
|
|
1040
|
+
roles: z$73.array(z$73.string()).optional(),
|
|
1041
|
+
permissions: z$73.array(z$73.string()).optional(),
|
|
1042
|
+
expires: z$73.number().int().optional(),
|
|
1043
|
+
enabled: z$73.boolean().default(true),
|
|
1044
|
+
credits: KeyCreditsData$outboundSchema.optional(),
|
|
1045
|
+
ratelimits: z$73.array(RatelimitRequest$outboundSchema).optional()
|
|
1046
|
+
});
|
|
1047
|
+
|
|
1048
|
+
//#endregion
|
|
1049
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysmigratekeysmigration.js
|
|
1050
|
+
/** @internal */
|
|
1051
|
+
const V2KeysMigrateKeysMigration$inboundSchema = z$72.object({
|
|
1052
|
+
hash: z$72.string(),
|
|
1053
|
+
keyId: z$72.string()
|
|
1054
|
+
});
|
|
1055
|
+
|
|
1056
|
+
//#endregion
|
|
1057
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysmigratekeysrequestbody.js
|
|
1058
|
+
/** @internal */
|
|
1059
|
+
const V2KeysMigrateKeysRequestBody$outboundSchema = z$71.object({
|
|
1060
|
+
migrationId: z$71.string(),
|
|
1061
|
+
apiId: z$71.string(),
|
|
1062
|
+
keys: z$71.array(V2KeysMigrateKeyData$outboundSchema)
|
|
1063
|
+
});
|
|
1064
|
+
|
|
1065
|
+
//#endregion
|
|
1066
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysmigratekeysresponsedata.js
|
|
1067
|
+
/** @internal */
|
|
1068
|
+
const V2KeysMigrateKeysResponseData$inboundSchema = z$70.object({
|
|
1069
|
+
migrated: z$70.array(V2KeysMigrateKeysMigration$inboundSchema),
|
|
1070
|
+
failed: z$70.array(z$70.string())
|
|
1071
|
+
});
|
|
1072
|
+
|
|
1073
|
+
//#endregion
|
|
1074
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysmigratekeysresponsebody.js
|
|
1075
|
+
/** @internal */
|
|
1076
|
+
const V2KeysMigrateKeysResponseBody$inboundSchema = z$69.object({
|
|
1077
|
+
meta: Meta$inboundSchema,
|
|
1078
|
+
data: V2KeysMigrateKeysResponseData$inboundSchema
|
|
1079
|
+
});
|
|
1080
|
+
|
|
1081
|
+
//#endregion
|
|
1082
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysremovepermissionsrequestbody.js
|
|
1083
|
+
/** @internal */
|
|
1084
|
+
const V2KeysRemovePermissionsRequestBody$outboundSchema = z$68.object({
|
|
1085
|
+
keyId: z$68.string(),
|
|
1086
|
+
permissions: z$68.array(z$68.string())
|
|
1087
|
+
});
|
|
1088
|
+
|
|
1089
|
+
//#endregion
|
|
1090
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysremovepermissionsresponsebody.js
|
|
1091
|
+
/** @internal */
|
|
1092
|
+
const V2KeysRemovePermissionsResponseBody$inboundSchema = z$67.object({
|
|
1093
|
+
meta: Meta$inboundSchema,
|
|
1094
|
+
data: z$67.array(Permission$inboundSchema)
|
|
1095
|
+
});
|
|
1096
|
+
|
|
1097
|
+
//#endregion
|
|
1098
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysremoverolesrequestbody.js
|
|
1099
|
+
/** @internal */
|
|
1100
|
+
const V2KeysRemoveRolesRequestBody$outboundSchema = z$66.object({
|
|
1101
|
+
keyId: z$66.string(),
|
|
1102
|
+
roles: z$66.array(z$66.string())
|
|
1103
|
+
});
|
|
1104
|
+
|
|
1105
|
+
//#endregion
|
|
1106
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysremoverolesresponsebody.js
|
|
1107
|
+
/** @internal */
|
|
1108
|
+
const V2KeysRemoveRolesResponseBody$inboundSchema = z$65.object({
|
|
1109
|
+
meta: Meta$inboundSchema,
|
|
1110
|
+
data: z$65.array(Role$inboundSchema)
|
|
1111
|
+
});
|
|
1112
|
+
|
|
1113
|
+
//#endregion
|
|
1114
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysrerollkeyrequestbody.js
|
|
1115
|
+
/** @internal */
|
|
1116
|
+
const V2KeysRerollKeyRequestBody$outboundSchema = z$64.object({
|
|
1117
|
+
keyId: z$64.string(),
|
|
1118
|
+
expiration: z$64.number().int()
|
|
1119
|
+
});
|
|
1120
|
+
|
|
1121
|
+
//#endregion
|
|
1122
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysrerollkeyresponsedata.js
|
|
1123
|
+
/** @internal */
|
|
1124
|
+
const V2KeysRerollKeyResponseData$inboundSchema = z$63.object({
|
|
1125
|
+
keyId: z$63.string(),
|
|
1126
|
+
key: z$63.string()
|
|
1127
|
+
});
|
|
1128
|
+
|
|
1129
|
+
//#endregion
|
|
1130
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysrerollkeyresponsebody.js
|
|
1131
|
+
/** @internal */
|
|
1132
|
+
const V2KeysRerollKeyResponseBody$inboundSchema = z$62.object({
|
|
1133
|
+
meta: Meta$inboundSchema,
|
|
1134
|
+
data: V2KeysRerollKeyResponseData$inboundSchema
|
|
1135
|
+
});
|
|
1136
|
+
|
|
1137
|
+
//#endregion
|
|
1138
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keyssetpermissionsrequestbody.js
|
|
1139
|
+
/** @internal */
|
|
1140
|
+
const V2KeysSetPermissionsRequestBody$outboundSchema = z$61.object({
|
|
1141
|
+
keyId: z$61.string(),
|
|
1142
|
+
permissions: z$61.array(z$61.string())
|
|
1143
|
+
});
|
|
1144
|
+
|
|
1145
|
+
//#endregion
|
|
1146
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keyssetpermissionsresponsebody.js
|
|
1147
|
+
/** @internal */
|
|
1148
|
+
const V2KeysSetPermissionsResponseBody$inboundSchema = z$60.object({
|
|
1149
|
+
meta: Meta$inboundSchema,
|
|
1150
|
+
data: z$60.array(Permission$inboundSchema)
|
|
1151
|
+
});
|
|
1152
|
+
|
|
1153
|
+
//#endregion
|
|
1154
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keyssetrolesrequestbody.js
|
|
1155
|
+
/** @internal */
|
|
1156
|
+
const V2KeysSetRolesRequestBody$outboundSchema = z$59.object({
|
|
1157
|
+
keyId: z$59.string(),
|
|
1158
|
+
roles: z$59.array(z$59.string())
|
|
1159
|
+
});
|
|
1160
|
+
|
|
1161
|
+
//#endregion
|
|
1162
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keyssetrolesresponsebody.js
|
|
1163
|
+
/** @internal */
|
|
1164
|
+
const V2KeysSetRolesResponseBody$inboundSchema = z$58.object({
|
|
1165
|
+
meta: Meta$inboundSchema,
|
|
1166
|
+
data: z$58.array(Role$inboundSchema)
|
|
1167
|
+
});
|
|
1168
|
+
|
|
1169
|
+
//#endregion
|
|
1170
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysupdatecreditsrequestbody.js
|
|
1171
|
+
/**
|
|
1172
|
+
* Defines how to modify the key's remaining credits. Use 'set' to replace current credits with a specific value or unlimited usage, 'increment' to add credits for plan upgrades or credit purchases, and 'decrement' to reduce credits for refunds or policy violations.
|
|
1173
|
+
*
|
|
1174
|
+
* @remarks
|
|
1175
|
+
*/
|
|
1176
|
+
const Operation = {
|
|
1177
|
+
Set: "set",
|
|
1178
|
+
Increment: "increment",
|
|
1179
|
+
Decrement: "decrement"
|
|
1180
|
+
};
|
|
1181
|
+
/** @internal */
|
|
1182
|
+
const Operation$outboundSchema = z$57.nativeEnum(Operation);
|
|
1183
|
+
/** @internal */
|
|
1184
|
+
const V2KeysUpdateCreditsRequestBody$outboundSchema = z$57.object({
|
|
1185
|
+
keyId: z$57.string(),
|
|
1186
|
+
value: z$57.nullable(z$57.number().int()).optional(),
|
|
1187
|
+
operation: Operation$outboundSchema
|
|
1188
|
+
});
|
|
1189
|
+
|
|
1190
|
+
//#endregion
|
|
1191
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysupdatecreditsresponsebody.js
|
|
1192
|
+
/** @internal */
|
|
1193
|
+
const V2KeysUpdateCreditsResponseBody$inboundSchema = z$56.object({
|
|
1194
|
+
meta: Meta$inboundSchema,
|
|
1195
|
+
data: KeyCreditsData$inboundSchema
|
|
1196
|
+
});
|
|
1197
|
+
|
|
1198
|
+
//#endregion
|
|
1199
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysupdatekeyrequestbody.js
|
|
1200
|
+
/** @internal */
|
|
1201
|
+
const V2KeysUpdateKeyRequestBody$outboundSchema = z$55.object({
|
|
1202
|
+
keyId: z$55.string(),
|
|
1203
|
+
name: z$55.nullable(z$55.string()).optional(),
|
|
1204
|
+
externalId: z$55.nullable(z$55.string()).optional(),
|
|
1205
|
+
meta: z$55.nullable(z$55.record(z$55.any())).optional(),
|
|
1206
|
+
expires: z$55.nullable(z$55.number().int()).optional(),
|
|
1207
|
+
credits: z$55.nullable(UpdateKeyCreditsData$outboundSchema).optional(),
|
|
1208
|
+
ratelimits: z$55.array(RatelimitRequest$outboundSchema).optional(),
|
|
1209
|
+
enabled: z$55.boolean().optional(),
|
|
1210
|
+
roles: z$55.array(z$55.string()).optional(),
|
|
1211
|
+
permissions: z$55.array(z$55.string()).optional()
|
|
1212
|
+
});
|
|
1213
|
+
|
|
1214
|
+
//#endregion
|
|
1215
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysupdatekeyresponsebody.js
|
|
1216
|
+
/** @internal */
|
|
1217
|
+
const V2KeysUpdateKeyResponseBody$inboundSchema = z$54.object({
|
|
1218
|
+
meta: Meta$inboundSchema,
|
|
1219
|
+
data: EmptyResponse$inboundSchema
|
|
1220
|
+
});
|
|
1221
|
+
|
|
1222
|
+
//#endregion
|
|
1223
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysverifykeyrequestbody.js
|
|
1224
|
+
/** @internal */
|
|
1225
|
+
const V2KeysVerifyKeyRequestBody$outboundSchema = z$53.object({
|
|
1226
|
+
key: z$53.string(),
|
|
1227
|
+
tags: z$53.array(z$53.string()).optional(),
|
|
1228
|
+
permissions: z$53.string().optional(),
|
|
1229
|
+
credits: KeysVerifyKeyCredits$outboundSchema.optional(),
|
|
1230
|
+
ratelimits: z$53.array(KeysVerifyKeyRatelimit$outboundSchema).optional(),
|
|
1231
|
+
migrationId: z$53.string().optional()
|
|
1232
|
+
});
|
|
1233
|
+
|
|
1234
|
+
//#endregion
|
|
1235
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/verifykeyratelimitdata.js
|
|
1236
|
+
/** @internal */
|
|
1237
|
+
const VerifyKeyRatelimitData$inboundSchema = z$52.object({
|
|
1238
|
+
exceeded: z$52.boolean(),
|
|
1239
|
+
id: z$52.string(),
|
|
1240
|
+
name: z$52.string(),
|
|
1241
|
+
limit: z$52.number().int(),
|
|
1242
|
+
duration: z$52.number().int(),
|
|
1243
|
+
reset: z$52.number().int(),
|
|
1244
|
+
remaining: z$52.number().int(),
|
|
1245
|
+
autoApply: z$52.boolean()
|
|
1246
|
+
});
|
|
1247
|
+
|
|
1248
|
+
//#endregion
|
|
1249
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysverifykeyresponsedata.js
|
|
1250
|
+
/**
|
|
1251
|
+
* A machine-readable code indicating the verification status
|
|
1252
|
+
*
|
|
1253
|
+
* @remarks
|
|
1254
|
+
* or failure reason. Values: `VALID` (key is valid and passed all checks), `NOT_FOUND` (key doesn't
|
|
1255
|
+
* exist or belongs to wrong API), `FORBIDDEN` (key lacks required permissions), `INSUFFICIENT_PERMISSIONS`
|
|
1256
|
+
* (key lacks specific required permissions for this request), `INSUFFICIENT_CREDITS`
|
|
1257
|
+
* (key has no remaining credits), `USAGE_EXCEEDED` (key exceeded usage limits), `RATE_LIMITED` (key exceeded rate limits), `DISABLED` (key was explicitly disabled),
|
|
1258
|
+
* `EXPIRED` (key has passed its expiration date).
|
|
1259
|
+
*/
|
|
1260
|
+
const Code = {
|
|
1261
|
+
Valid: "VALID",
|
|
1262
|
+
NotFound: "NOT_FOUND",
|
|
1263
|
+
Forbidden: "FORBIDDEN",
|
|
1264
|
+
InsufficientPermissions: "INSUFFICIENT_PERMISSIONS",
|
|
1265
|
+
InsufficientCredits: "INSUFFICIENT_CREDITS",
|
|
1266
|
+
UsageExceeded: "USAGE_EXCEEDED",
|
|
1267
|
+
RateLimited: "RATE_LIMITED",
|
|
1268
|
+
Disabled: "DISABLED",
|
|
1269
|
+
Expired: "EXPIRED"
|
|
1270
|
+
};
|
|
1271
|
+
/** @internal */
|
|
1272
|
+
const Code$inboundSchema = z$51.nativeEnum(Code);
|
|
1273
|
+
/** @internal */
|
|
1274
|
+
const V2KeysVerifyKeyResponseData$inboundSchema = z$51.object({
|
|
1275
|
+
valid: z$51.boolean(),
|
|
1276
|
+
code: Code$inboundSchema,
|
|
1277
|
+
keyId: z$51.string().optional(),
|
|
1278
|
+
name: z$51.string().optional(),
|
|
1279
|
+
meta: z$51.record(z$51.any()).optional(),
|
|
1280
|
+
expires: z$51.number().int().optional(),
|
|
1281
|
+
credits: z$51.number().int().optional(),
|
|
1282
|
+
enabled: z$51.boolean().optional(),
|
|
1283
|
+
permissions: z$51.array(z$51.string()).optional(),
|
|
1284
|
+
roles: z$51.array(z$51.string()).optional(),
|
|
1285
|
+
identity: Identity$inboundSchema.optional(),
|
|
1286
|
+
ratelimits: z$51.array(VerifyKeyRatelimitData$inboundSchema).optional()
|
|
1287
|
+
});
|
|
1288
|
+
|
|
1289
|
+
//#endregion
|
|
1290
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keysverifykeyresponsebody.js
|
|
1291
|
+
/** @internal */
|
|
1292
|
+
const V2KeysVerifyKeyResponseBody$inboundSchema = z$50.object({
|
|
1293
|
+
meta: Meta$inboundSchema,
|
|
1294
|
+
data: V2KeysVerifyKeyResponseData$inboundSchema
|
|
1295
|
+
});
|
|
1296
|
+
|
|
1297
|
+
//#endregion
|
|
1298
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keyswhoamirequestbody.js
|
|
1299
|
+
/** @internal */
|
|
1300
|
+
const V2KeysWhoamiRequestBody$outboundSchema = z$49.object({ key: z$49.string() });
|
|
1301
|
+
|
|
1302
|
+
//#endregion
|
|
1303
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2keyswhoamiresponsebody.js
|
|
1304
|
+
/** @internal */
|
|
1305
|
+
const V2KeysWhoamiResponseBody$inboundSchema = z$48.object({
|
|
1306
|
+
meta: Meta$inboundSchema,
|
|
1307
|
+
data: KeyResponseData$inboundSchema
|
|
1308
|
+
});
|
|
1309
|
+
|
|
1310
|
+
//#endregion
|
|
1311
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionscreatepermissionrequestbody.js
|
|
1312
|
+
/** @internal */
|
|
1313
|
+
const V2PermissionsCreatePermissionRequestBody$outboundSchema = z$47.object({
|
|
1314
|
+
name: z$47.string(),
|
|
1315
|
+
slug: z$47.string(),
|
|
1316
|
+
description: z$47.string().optional()
|
|
1317
|
+
});
|
|
1318
|
+
|
|
1319
|
+
//#endregion
|
|
1320
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionscreatepermissionresponsedata.js
|
|
1321
|
+
/** @internal */
|
|
1322
|
+
const V2PermissionsCreatePermissionResponseData$inboundSchema = z$46.object({ permissionId: z$46.string() });
|
|
1323
|
+
|
|
1324
|
+
//#endregion
|
|
1325
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionscreatepermissionresponsebody.js
|
|
1326
|
+
/** @internal */
|
|
1327
|
+
const V2PermissionsCreatePermissionResponseBody$inboundSchema = z$45.object({
|
|
1328
|
+
meta: Meta$inboundSchema,
|
|
1329
|
+
data: V2PermissionsCreatePermissionResponseData$inboundSchema
|
|
1330
|
+
});
|
|
1331
|
+
|
|
1332
|
+
//#endregion
|
|
1333
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionscreaterolerequestbody.js
|
|
1334
|
+
/** @internal */
|
|
1335
|
+
const V2PermissionsCreateRoleRequestBody$outboundSchema = z$44.object({
|
|
1336
|
+
name: z$44.string(),
|
|
1337
|
+
description: z$44.string().optional()
|
|
1338
|
+
});
|
|
1339
|
+
|
|
1340
|
+
//#endregion
|
|
1341
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionscreateroleresponsedata.js
|
|
1342
|
+
/** @internal */
|
|
1343
|
+
const V2PermissionsCreateRoleResponseData$inboundSchema = z$43.object({ roleId: z$43.string() });
|
|
1344
|
+
|
|
1345
|
+
//#endregion
|
|
1346
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionscreateroleresponsebody.js
|
|
1347
|
+
/** @internal */
|
|
1348
|
+
const V2PermissionsCreateRoleResponseBody$inboundSchema = z$42.object({
|
|
1349
|
+
meta: Meta$inboundSchema,
|
|
1350
|
+
data: V2PermissionsCreateRoleResponseData$inboundSchema
|
|
1351
|
+
});
|
|
1352
|
+
|
|
1353
|
+
//#endregion
|
|
1354
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionsdeletepermissionrequestbody.js
|
|
1355
|
+
/** @internal */
|
|
1356
|
+
const V2PermissionsDeletePermissionRequestBody$outboundSchema = z$41.object({ permission: z$41.string() });
|
|
1357
|
+
|
|
1358
|
+
//#endregion
|
|
1359
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionsdeletepermissionresponsebody.js
|
|
1360
|
+
/** @internal */
|
|
1361
|
+
const V2PermissionsDeletePermissionResponseBody$inboundSchema = z$40.object({
|
|
1362
|
+
meta: Meta$inboundSchema,
|
|
1363
|
+
data: EmptyResponse$inboundSchema
|
|
1364
|
+
});
|
|
1365
|
+
|
|
1366
|
+
//#endregion
|
|
1367
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionsdeleterolerequestbody.js
|
|
1368
|
+
/** @internal */
|
|
1369
|
+
const V2PermissionsDeleteRoleRequestBody$outboundSchema = z$39.object({ role: z$39.string() });
|
|
1370
|
+
|
|
1371
|
+
//#endregion
|
|
1372
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionsdeleteroleresponsebody.js
|
|
1373
|
+
/** @internal */
|
|
1374
|
+
const V2PermissionsDeleteRoleResponseBody$inboundSchema = z$38.object({
|
|
1375
|
+
meta: Meta$inboundSchema,
|
|
1376
|
+
data: EmptyResponse$inboundSchema
|
|
1377
|
+
});
|
|
1378
|
+
|
|
1379
|
+
//#endregion
|
|
1380
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionsgetpermissionrequestbody.js
|
|
1381
|
+
/** @internal */
|
|
1382
|
+
const V2PermissionsGetPermissionRequestBody$outboundSchema = z$37.object({ permission: z$37.string() });
|
|
1383
|
+
|
|
1384
|
+
//#endregion
|
|
1385
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionsgetpermissionresponsebody.js
|
|
1386
|
+
/** @internal */
|
|
1387
|
+
const V2PermissionsGetPermissionResponseBody$inboundSchema = z$36.object({
|
|
1388
|
+
meta: Meta$inboundSchema,
|
|
1389
|
+
data: Permission$inboundSchema
|
|
1390
|
+
});
|
|
1391
|
+
|
|
1392
|
+
//#endregion
|
|
1393
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionsgetrolerequestbody.js
|
|
1394
|
+
/** @internal */
|
|
1395
|
+
const V2PermissionsGetRoleRequestBody$outboundSchema = z$35.object({ role: z$35.string() });
|
|
1396
|
+
|
|
1397
|
+
//#endregion
|
|
1398
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionsgetroleresponsebody.js
|
|
1399
|
+
/** @internal */
|
|
1400
|
+
const V2PermissionsGetRoleResponseBody$inboundSchema = z$34.object({
|
|
1401
|
+
meta: Meta$inboundSchema,
|
|
1402
|
+
data: Role$inboundSchema
|
|
1403
|
+
});
|
|
1404
|
+
|
|
1405
|
+
//#endregion
|
|
1406
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionslistpermissionsrequestbody.js
|
|
1407
|
+
/** @internal */
|
|
1408
|
+
const V2PermissionsListPermissionsRequestBody$outboundSchema = z$33.object({
|
|
1409
|
+
cursor: z$33.string().optional(),
|
|
1410
|
+
limit: z$33.number().int().default(100)
|
|
1411
|
+
});
|
|
1412
|
+
|
|
1413
|
+
//#endregion
|
|
1414
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionslistpermissionsresponsebody.js
|
|
1415
|
+
/** @internal */
|
|
1416
|
+
const V2PermissionsListPermissionsResponseBody$inboundSchema = z$32.object({
|
|
1417
|
+
meta: Meta$inboundSchema,
|
|
1418
|
+
data: z$32.array(Permission$inboundSchema),
|
|
1419
|
+
pagination: Pagination$inboundSchema.optional()
|
|
1420
|
+
});
|
|
1421
|
+
|
|
1422
|
+
//#endregion
|
|
1423
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionslistrolesrequestbody.js
|
|
1424
|
+
/** @internal */
|
|
1425
|
+
const V2PermissionsListRolesRequestBody$outboundSchema = z$31.object({
|
|
1426
|
+
limit: z$31.number().int().default(100),
|
|
1427
|
+
cursor: z$31.string().optional()
|
|
1428
|
+
});
|
|
1429
|
+
|
|
1430
|
+
//#endregion
|
|
1431
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2permissionslistrolesresponsebody.js
|
|
1432
|
+
/** @internal */
|
|
1433
|
+
const V2PermissionsListRolesResponseBody$inboundSchema = z$30.object({
|
|
1434
|
+
meta: Meta$inboundSchema,
|
|
1435
|
+
data: z$30.array(Role$inboundSchema),
|
|
1436
|
+
pagination: Pagination$inboundSchema.optional()
|
|
1437
|
+
});
|
|
1438
|
+
|
|
1439
|
+
//#endregion
|
|
1440
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitdeleteoverriderequestbody.js
|
|
1441
|
+
/** @internal */
|
|
1442
|
+
const V2RatelimitDeleteOverrideRequestBody$outboundSchema = z$29.object({
|
|
1443
|
+
namespace: z$29.string(),
|
|
1444
|
+
identifier: z$29.string()
|
|
1445
|
+
});
|
|
1446
|
+
|
|
1447
|
+
//#endregion
|
|
1448
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitdeleteoverrideresponsedata.js
|
|
1449
|
+
/** @internal */
|
|
1450
|
+
const V2RatelimitDeleteOverrideResponseData$inboundSchema = z$28.object({});
|
|
1451
|
+
|
|
1452
|
+
//#endregion
|
|
1453
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitdeleteoverrideresponsebody.js
|
|
1454
|
+
/** @internal */
|
|
1455
|
+
const V2RatelimitDeleteOverrideResponseBody$inboundSchema = z$27.object({
|
|
1456
|
+
meta: Meta$inboundSchema,
|
|
1457
|
+
data: V2RatelimitDeleteOverrideResponseData$inboundSchema
|
|
1458
|
+
});
|
|
1459
|
+
|
|
1460
|
+
//#endregion
|
|
1461
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitgetoverriderequestbody.js
|
|
1462
|
+
/** @internal */
|
|
1463
|
+
const V2RatelimitGetOverrideRequestBody$outboundSchema = z$26.object({
|
|
1464
|
+
namespace: z$26.string(),
|
|
1465
|
+
identifier: z$26.string()
|
|
1466
|
+
});
|
|
1467
|
+
|
|
1468
|
+
//#endregion
|
|
1469
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitgetoverrideresponsebody.js
|
|
1470
|
+
/** @internal */
|
|
1471
|
+
const V2RatelimitGetOverrideResponseBody$inboundSchema = z$25.object({
|
|
1472
|
+
meta: Meta$inboundSchema,
|
|
1473
|
+
data: RatelimitOverride$inboundSchema
|
|
1474
|
+
});
|
|
1475
|
+
|
|
1476
|
+
//#endregion
|
|
1477
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitlimitrequestbody.js
|
|
1478
|
+
/** @internal */
|
|
1479
|
+
const V2RatelimitLimitRequestBody$outboundSchema = z$24.object({
|
|
1480
|
+
namespace: z$24.string(),
|
|
1481
|
+
cost: z$24.number().int().default(1),
|
|
1482
|
+
duration: z$24.number().int(),
|
|
1483
|
+
identifier: z$24.string(),
|
|
1484
|
+
limit: z$24.number().int()
|
|
1485
|
+
});
|
|
1486
|
+
|
|
1487
|
+
//#endregion
|
|
1488
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitlimitresponsedata.js
|
|
1489
|
+
/** @internal */
|
|
1490
|
+
const V2RatelimitLimitResponseData$inboundSchema = z$23.object({
|
|
1491
|
+
limit: z$23.number().int(),
|
|
1492
|
+
remaining: z$23.number().int(),
|
|
1493
|
+
reset: z$23.number().int(),
|
|
1494
|
+
success: z$23.boolean(),
|
|
1495
|
+
overrideId: z$23.string().optional()
|
|
1496
|
+
});
|
|
1497
|
+
|
|
1498
|
+
//#endregion
|
|
1499
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitlimitresponsebody.js
|
|
1500
|
+
/** @internal */
|
|
1501
|
+
const V2RatelimitLimitResponseBody$inboundSchema = z$22.object({
|
|
1502
|
+
meta: Meta$inboundSchema,
|
|
1503
|
+
data: V2RatelimitLimitResponseData$inboundSchema
|
|
1504
|
+
});
|
|
1505
|
+
|
|
1506
|
+
//#endregion
|
|
1507
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitlistoverridesrequestbody.js
|
|
1508
|
+
/** @internal */
|
|
1509
|
+
const V2RatelimitListOverridesRequestBody$outboundSchema = z$21.object({
|
|
1510
|
+
namespace: z$21.string(),
|
|
1511
|
+
cursor: z$21.string().optional(),
|
|
1512
|
+
limit: z$21.number().int().default(10)
|
|
1513
|
+
});
|
|
1514
|
+
|
|
1515
|
+
//#endregion
|
|
1516
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitlistoverridesresponsebody.js
|
|
1517
|
+
/** @internal */
|
|
1518
|
+
const V2RatelimitListOverridesResponseBody$inboundSchema = z$20.object({
|
|
1519
|
+
meta: Meta$inboundSchema,
|
|
1520
|
+
data: z$20.array(RatelimitOverride$inboundSchema),
|
|
1521
|
+
pagination: Pagination$inboundSchema.optional()
|
|
1522
|
+
});
|
|
1523
|
+
|
|
1524
|
+
//#endregion
|
|
1525
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitmultilimitcheck.js
|
|
1526
|
+
/** @internal */
|
|
1527
|
+
const V2RatelimitMultiLimitCheck$inboundSchema = z$19.object({
|
|
1528
|
+
namespace: z$19.string(),
|
|
1529
|
+
identifier: z$19.string(),
|
|
1530
|
+
limit: z$19.number().int(),
|
|
1531
|
+
remaining: z$19.number().int(),
|
|
1532
|
+
reset: z$19.number().int(),
|
|
1533
|
+
passed: z$19.boolean(),
|
|
1534
|
+
overrideId: z$19.string().optional()
|
|
1535
|
+
});
|
|
1536
|
+
|
|
1537
|
+
//#endregion
|
|
1538
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitmultilimitresponsedata.js
|
|
1539
|
+
/** @internal */
|
|
1540
|
+
const V2RatelimitMultiLimitResponseData$inboundSchema = z$18.object({
|
|
1541
|
+
passed: z$18.boolean(),
|
|
1542
|
+
limits: z$18.array(V2RatelimitMultiLimitCheck$inboundSchema)
|
|
1543
|
+
});
|
|
1544
|
+
|
|
1545
|
+
//#endregion
|
|
1546
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitmultilimitresponsebody.js
|
|
1547
|
+
/** @internal */
|
|
1548
|
+
const V2RatelimitMultiLimitResponseBody$inboundSchema = z$17.object({
|
|
1549
|
+
meta: Meta$inboundSchema,
|
|
1550
|
+
data: V2RatelimitMultiLimitResponseData$inboundSchema
|
|
1551
|
+
});
|
|
1552
|
+
|
|
1553
|
+
//#endregion
|
|
1554
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitsetoverriderequestbody.js
|
|
1555
|
+
/** @internal */
|
|
1556
|
+
const V2RatelimitSetOverrideRequestBody$outboundSchema = z$16.object({
|
|
1557
|
+
namespace: z$16.string(),
|
|
1558
|
+
duration: z$16.number().int(),
|
|
1559
|
+
identifier: z$16.string(),
|
|
1560
|
+
limit: z$16.number().int()
|
|
1561
|
+
});
|
|
1562
|
+
|
|
1563
|
+
//#endregion
|
|
1564
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitsetoverrideresponsedata.js
|
|
1565
|
+
/** @internal */
|
|
1566
|
+
const V2RatelimitSetOverrideResponseData$inboundSchema = z$15.object({ overrideId: z$15.string() });
|
|
1567
|
+
|
|
1568
|
+
//#endregion
|
|
1569
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/components/v2ratelimitsetoverrideresponsebody.js
|
|
1570
|
+
/** @internal */
|
|
1571
|
+
const V2RatelimitSetOverrideResponseBody$inboundSchema = z$14.object({
|
|
1572
|
+
meta: Meta$inboundSchema,
|
|
1573
|
+
data: V2RatelimitSetOverrideResponseData$inboundSchema
|
|
1574
|
+
});
|
|
1575
|
+
|
|
1576
|
+
//#endregion
|
|
1577
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/badrequesterrorresponse.js
|
|
1578
|
+
/**
|
|
1579
|
+
* Error response for invalid requests that cannot be processed due to client-side errors. This typically occurs when request parameters are missing, malformed, or fail validation rules. The response includes detailed information about the specific errors in the request, including the location of each error and suggestions for fixing it. When receiving this error, check the 'errors' array in the response for specific validation issues that need to be addressed before retrying.
|
|
1580
|
+
*/
|
|
1581
|
+
var BadRequestErrorResponse = class extends UnkeyError {
|
|
1582
|
+
constructor(err, httpMeta) {
|
|
1583
|
+
const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`;
|
|
1584
|
+
super(message, httpMeta);
|
|
1585
|
+
this.data$ = err;
|
|
1586
|
+
this.meta = err.meta;
|
|
1587
|
+
this.error = err.error;
|
|
1588
|
+
this.name = "BadRequestErrorResponse";
|
|
1589
|
+
}
|
|
1590
|
+
};
|
|
1591
|
+
/** @internal */
|
|
1592
|
+
const BadRequestErrorResponse$inboundSchema = z$13.object({
|
|
1593
|
+
meta: Meta$inboundSchema,
|
|
1594
|
+
error: BadRequestErrorDetails$inboundSchema,
|
|
1595
|
+
request$: z$13.instanceof(Request),
|
|
1596
|
+
response$: z$13.instanceof(Response),
|
|
1597
|
+
body$: z$13.string()
|
|
1598
|
+
}).transform((v) => {
|
|
1599
|
+
return new BadRequestErrorResponse(v, {
|
|
1600
|
+
request: v.request$,
|
|
1601
|
+
response: v.response$,
|
|
1602
|
+
body: v.body$
|
|
1603
|
+
});
|
|
1604
|
+
});
|
|
1605
|
+
|
|
1606
|
+
//#endregion
|
|
1607
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/conflicterrorresponse.js
|
|
1608
|
+
/**
|
|
1609
|
+
* Error response when the request conflicts with the current state of the resource. This occurs when:
|
|
1610
|
+
*
|
|
1611
|
+
* @remarks
|
|
1612
|
+
* - Attempting to create a resource that already exists
|
|
1613
|
+
* - Modifying a resource that has been changed by another operation
|
|
1614
|
+
* - Violating unique constraints or business rules
|
|
1615
|
+
*
|
|
1616
|
+
* To resolve this error, check the current state of the resource and adjust your request accordingly.
|
|
1617
|
+
*/
|
|
1618
|
+
var ConflictErrorResponse = class extends UnkeyError {
|
|
1619
|
+
constructor(err, httpMeta) {
|
|
1620
|
+
const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`;
|
|
1621
|
+
super(message, httpMeta);
|
|
1622
|
+
this.data$ = err;
|
|
1623
|
+
this.meta = err.meta;
|
|
1624
|
+
this.error = err.error;
|
|
1625
|
+
this.name = "ConflictErrorResponse";
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
/** @internal */
|
|
1629
|
+
const ConflictErrorResponse$inboundSchema = z$12.object({
|
|
1630
|
+
meta: Meta$inboundSchema,
|
|
1631
|
+
error: BaseError$inboundSchema,
|
|
1632
|
+
request$: z$12.instanceof(Request),
|
|
1633
|
+
response$: z$12.instanceof(Response),
|
|
1634
|
+
body$: z$12.string()
|
|
1635
|
+
}).transform((v) => {
|
|
1636
|
+
return new ConflictErrorResponse(v, {
|
|
1637
|
+
request: v.request$,
|
|
1638
|
+
response: v.response$,
|
|
1639
|
+
body: v.body$
|
|
1640
|
+
});
|
|
1641
|
+
});
|
|
1642
|
+
|
|
1643
|
+
//#endregion
|
|
1644
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/forbiddenerrorresponse.js
|
|
1645
|
+
/**
|
|
1646
|
+
* Error response when the provided credentials are valid but lack sufficient permissions for the requested operation. This occurs when:
|
|
1647
|
+
*
|
|
1648
|
+
* @remarks
|
|
1649
|
+
* - The root key doesn't have the required permissions for this endpoint
|
|
1650
|
+
* - The operation requires elevated privileges that the current key lacks
|
|
1651
|
+
* - Access to the requested resource is restricted based on workspace settings
|
|
1652
|
+
*
|
|
1653
|
+
* To resolve this error, ensure your root key has the necessary permissions or contact your workspace administrator.
|
|
1654
|
+
*/
|
|
1655
|
+
var ForbiddenErrorResponse = class extends UnkeyError {
|
|
1656
|
+
constructor(err, httpMeta) {
|
|
1657
|
+
const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`;
|
|
1658
|
+
super(message, httpMeta);
|
|
1659
|
+
this.data$ = err;
|
|
1660
|
+
this.meta = err.meta;
|
|
1661
|
+
this.error = err.error;
|
|
1662
|
+
this.name = "ForbiddenErrorResponse";
|
|
1663
|
+
}
|
|
1664
|
+
};
|
|
1665
|
+
/** @internal */
|
|
1666
|
+
const ForbiddenErrorResponse$inboundSchema = z$11.object({
|
|
1667
|
+
meta: Meta$inboundSchema,
|
|
1668
|
+
error: BaseError$inboundSchema,
|
|
1669
|
+
request$: z$11.instanceof(Request),
|
|
1670
|
+
response$: z$11.instanceof(Response),
|
|
1671
|
+
body$: z$11.string()
|
|
1672
|
+
}).transform((v) => {
|
|
1673
|
+
return new ForbiddenErrorResponse(v, {
|
|
1674
|
+
request: v.request$,
|
|
1675
|
+
response: v.response$,
|
|
1676
|
+
body: v.body$
|
|
1677
|
+
});
|
|
1678
|
+
});
|
|
1679
|
+
|
|
1680
|
+
//#endregion
|
|
1681
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/goneerrorresponse.js
|
|
1682
|
+
/**
|
|
1683
|
+
* Error response when the requested resource has been soft-deleted and is no longer available. This occurs when:
|
|
1684
|
+
*
|
|
1685
|
+
* @remarks
|
|
1686
|
+
* - The resource has been marked as deleted but still exists in the database
|
|
1687
|
+
* - The resource is intentionally unavailable but could potentially be restored
|
|
1688
|
+
* - The resource cannot be restored through the API or dashboard
|
|
1689
|
+
*
|
|
1690
|
+
* To resolve this error, contact support if you need the resource restored.
|
|
1691
|
+
*/
|
|
1692
|
+
var GoneErrorResponse = class extends UnkeyError {
|
|
1693
|
+
constructor(err, httpMeta) {
|
|
1694
|
+
const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`;
|
|
1695
|
+
super(message, httpMeta);
|
|
1696
|
+
this.data$ = err;
|
|
1697
|
+
this.meta = err.meta;
|
|
1698
|
+
this.error = err.error;
|
|
1699
|
+
this.name = "GoneErrorResponse";
|
|
1700
|
+
}
|
|
1701
|
+
};
|
|
1702
|
+
/** @internal */
|
|
1703
|
+
const GoneErrorResponse$inboundSchema = z$10.object({
|
|
1704
|
+
meta: Meta$inboundSchema,
|
|
1705
|
+
error: BaseError$inboundSchema,
|
|
1706
|
+
request$: z$10.instanceof(Request),
|
|
1707
|
+
response$: z$10.instanceof(Response),
|
|
1708
|
+
body$: z$10.string()
|
|
1709
|
+
}).transform((v) => {
|
|
1710
|
+
return new GoneErrorResponse(v, {
|
|
1711
|
+
request: v.request$,
|
|
1712
|
+
response: v.response$,
|
|
1713
|
+
body: v.body$
|
|
1714
|
+
});
|
|
1715
|
+
});
|
|
1716
|
+
|
|
1717
|
+
//#endregion
|
|
1718
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/internalservererrorresponse.js
|
|
1719
|
+
/**
|
|
1720
|
+
* Error response when an unexpected error occurs on the server. This indicates a problem with Unkey's systems rather than your request.
|
|
1721
|
+
*
|
|
1722
|
+
* @remarks
|
|
1723
|
+
*
|
|
1724
|
+
* When you encounter this error:
|
|
1725
|
+
* - The request ID in the response can help Unkey support investigate the issue
|
|
1726
|
+
* - The error is likely temporary and retrying may succeed
|
|
1727
|
+
* - If the error persists, contact Unkey support with the request ID
|
|
1728
|
+
*/
|
|
1729
|
+
var InternalServerErrorResponse = class extends UnkeyError {
|
|
1730
|
+
constructor(err, httpMeta) {
|
|
1731
|
+
const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`;
|
|
1732
|
+
super(message, httpMeta);
|
|
1733
|
+
this.data$ = err;
|
|
1734
|
+
this.meta = err.meta;
|
|
1735
|
+
this.error = err.error;
|
|
1736
|
+
this.name = "InternalServerErrorResponse";
|
|
1737
|
+
}
|
|
1738
|
+
};
|
|
1739
|
+
/** @internal */
|
|
1740
|
+
const InternalServerErrorResponse$inboundSchema = z$9.object({
|
|
1741
|
+
meta: Meta$inboundSchema,
|
|
1742
|
+
error: BaseError$inboundSchema,
|
|
1743
|
+
request$: z$9.instanceof(Request),
|
|
1744
|
+
response$: z$9.instanceof(Response),
|
|
1745
|
+
body$: z$9.string()
|
|
1746
|
+
}).transform((v) => {
|
|
1747
|
+
return new InternalServerErrorResponse(v, {
|
|
1748
|
+
request: v.request$,
|
|
1749
|
+
response: v.response$,
|
|
1750
|
+
body: v.body$
|
|
1751
|
+
});
|
|
1752
|
+
});
|
|
1753
|
+
|
|
1754
|
+
//#endregion
|
|
1755
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/notfounderrorresponse.js
|
|
1756
|
+
/**
|
|
1757
|
+
* Error response when the requested resource cannot be found. This occurs when:
|
|
1758
|
+
*
|
|
1759
|
+
* @remarks
|
|
1760
|
+
* - The specified resource ID doesn't exist in your workspace
|
|
1761
|
+
* - The resource has been deleted or moved
|
|
1762
|
+
* - The resource exists but is not accessible with current permissions
|
|
1763
|
+
*
|
|
1764
|
+
* To resolve this error, verify the resource ID is correct and that you have access to it.
|
|
1765
|
+
*/
|
|
1766
|
+
var NotFoundErrorResponse = class extends UnkeyError {
|
|
1767
|
+
constructor(err, httpMeta) {
|
|
1768
|
+
const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`;
|
|
1769
|
+
super(message, httpMeta);
|
|
1770
|
+
this.data$ = err;
|
|
1771
|
+
this.meta = err.meta;
|
|
1772
|
+
this.error = err.error;
|
|
1773
|
+
this.name = "NotFoundErrorResponse";
|
|
1774
|
+
}
|
|
1775
|
+
};
|
|
1776
|
+
/** @internal */
|
|
1777
|
+
const NotFoundErrorResponse$inboundSchema = z$8.object({
|
|
1778
|
+
meta: Meta$inboundSchema,
|
|
1779
|
+
error: BaseError$inboundSchema,
|
|
1780
|
+
request$: z$8.instanceof(Request),
|
|
1781
|
+
response$: z$8.instanceof(Response),
|
|
1782
|
+
body$: z$8.string()
|
|
1783
|
+
}).transform((v) => {
|
|
1784
|
+
return new NotFoundErrorResponse(v, {
|
|
1785
|
+
request: v.request$,
|
|
1786
|
+
response: v.response$,
|
|
1787
|
+
body: v.body$
|
|
1788
|
+
});
|
|
1789
|
+
});
|
|
1790
|
+
|
|
1791
|
+
//#endregion
|
|
1792
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/preconditionfailederrorresponse.js
|
|
1793
|
+
/**
|
|
1794
|
+
* Error response when one or more conditions specified in the request headers are not met. This typically occurs when:
|
|
1795
|
+
*
|
|
1796
|
+
* @remarks
|
|
1797
|
+
* - Using conditional requests with If-Match or If-None-Match headers
|
|
1798
|
+
* - The resource version doesn't match the expected value
|
|
1799
|
+
* - Optimistic concurrency control detects a conflict
|
|
1800
|
+
*
|
|
1801
|
+
* To resolve this error, fetch the latest version of the resource and retry with updated conditions.
|
|
1802
|
+
*/
|
|
1803
|
+
var PreconditionFailedErrorResponse = class extends UnkeyError {
|
|
1804
|
+
constructor(err, httpMeta) {
|
|
1805
|
+
const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`;
|
|
1806
|
+
super(message, httpMeta);
|
|
1807
|
+
this.data$ = err;
|
|
1808
|
+
this.meta = err.meta;
|
|
1809
|
+
this.error = err.error;
|
|
1810
|
+
this.name = "PreconditionFailedErrorResponse";
|
|
1811
|
+
}
|
|
1812
|
+
};
|
|
1813
|
+
/** @internal */
|
|
1814
|
+
const PreconditionFailedErrorResponse$inboundSchema = z$7.object({
|
|
1815
|
+
meta: Meta$inboundSchema,
|
|
1816
|
+
error: BaseError$inboundSchema,
|
|
1817
|
+
request$: z$7.instanceof(Request),
|
|
1818
|
+
response$: z$7.instanceof(Response),
|
|
1819
|
+
body$: z$7.string()
|
|
1820
|
+
}).transform((v) => {
|
|
1821
|
+
return new PreconditionFailedErrorResponse(v, {
|
|
1822
|
+
request: v.request$,
|
|
1823
|
+
response: v.response$,
|
|
1824
|
+
body: v.body$
|
|
1825
|
+
});
|
|
1826
|
+
});
|
|
1827
|
+
|
|
1828
|
+
//#endregion
|
|
1829
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/serviceunavailableerrorresponse.js
|
|
1830
|
+
/**
|
|
1831
|
+
* Error response when a required service is temporarily unavailable. This indicates that the service exists but cannot be reached or is not responding.
|
|
1832
|
+
*
|
|
1833
|
+
* @remarks
|
|
1834
|
+
*
|
|
1835
|
+
* When you encounter this error:
|
|
1836
|
+
* - The service is likely experiencing temporary issues
|
|
1837
|
+
* - Retrying the request after a short delay may succeed
|
|
1838
|
+
* - If the error persists, the service may be undergoing maintenance
|
|
1839
|
+
* - Contact Unkey support if the issue continues
|
|
1840
|
+
*/
|
|
1841
|
+
var ServiceUnavailableErrorResponse = class extends UnkeyError {
|
|
1842
|
+
constructor(err, httpMeta) {
|
|
1843
|
+
const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`;
|
|
1844
|
+
super(message, httpMeta);
|
|
1845
|
+
this.data$ = err;
|
|
1846
|
+
this.meta = err.meta;
|
|
1847
|
+
this.error = err.error;
|
|
1848
|
+
this.name = "ServiceUnavailableErrorResponse";
|
|
1849
|
+
}
|
|
1850
|
+
};
|
|
1851
|
+
/** @internal */
|
|
1852
|
+
const ServiceUnavailableErrorResponse$inboundSchema = z$6.object({
|
|
1853
|
+
meta: Meta$inboundSchema,
|
|
1854
|
+
error: BaseError$inboundSchema,
|
|
1855
|
+
request$: z$6.instanceof(Request),
|
|
1856
|
+
response$: z$6.instanceof(Response),
|
|
1857
|
+
body$: z$6.string()
|
|
1858
|
+
}).transform((v) => {
|
|
1859
|
+
return new ServiceUnavailableErrorResponse(v, {
|
|
1860
|
+
request: v.request$,
|
|
1861
|
+
response: v.response$,
|
|
1862
|
+
body: v.body$
|
|
1863
|
+
});
|
|
1864
|
+
});
|
|
1865
|
+
|
|
1866
|
+
//#endregion
|
|
1867
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/toomanyrequestserrorresponse.js
|
|
1868
|
+
/**
|
|
1869
|
+
* Error response when the client has sent too many requests in a given time period. This occurs when you've exceeded a rate limit or quota for the resource you're accessing.
|
|
1870
|
+
*
|
|
1871
|
+
* @remarks
|
|
1872
|
+
*
|
|
1873
|
+
* The rate limit resets automatically after the time window expires. To avoid this error:
|
|
1874
|
+
* - Implement exponential backoff when retrying requests
|
|
1875
|
+
* - Cache results where appropriate to reduce request frequency
|
|
1876
|
+
* - Check the error detail message for specific quota information
|
|
1877
|
+
* - Contact support if you need a higher quota for your use case
|
|
1878
|
+
*/
|
|
1879
|
+
var TooManyRequestsErrorResponse = class extends UnkeyError {
|
|
1880
|
+
constructor(err, httpMeta) {
|
|
1881
|
+
const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`;
|
|
1882
|
+
super(message, httpMeta);
|
|
1883
|
+
this.data$ = err;
|
|
1884
|
+
this.meta = err.meta;
|
|
1885
|
+
this.error = err.error;
|
|
1886
|
+
this.name = "TooManyRequestsErrorResponse";
|
|
1887
|
+
}
|
|
1888
|
+
};
|
|
1889
|
+
/** @internal */
|
|
1890
|
+
const TooManyRequestsErrorResponse$inboundSchema = z$5.object({
|
|
1891
|
+
meta: Meta$inboundSchema,
|
|
1892
|
+
error: BaseError$inboundSchema,
|
|
1893
|
+
request$: z$5.instanceof(Request),
|
|
1894
|
+
response$: z$5.instanceof(Response),
|
|
1895
|
+
body$: z$5.string()
|
|
1896
|
+
}).transform((v) => {
|
|
1897
|
+
return new TooManyRequestsErrorResponse(v, {
|
|
1898
|
+
request: v.request$,
|
|
1899
|
+
response: v.response$,
|
|
1900
|
+
body: v.body$
|
|
1901
|
+
});
|
|
1902
|
+
});
|
|
1903
|
+
|
|
1904
|
+
//#endregion
|
|
1905
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/unauthorizederrorresponse.js
|
|
1906
|
+
/**
|
|
1907
|
+
* Error response when authentication has failed or credentials are missing. This occurs when:
|
|
1908
|
+
*
|
|
1909
|
+
* @remarks
|
|
1910
|
+
* - No authentication token is provided in the request
|
|
1911
|
+
* - The provided token is invalid, expired, or malformed
|
|
1912
|
+
* - The token format doesn't match expected patterns
|
|
1913
|
+
*
|
|
1914
|
+
* To resolve this error, ensure you're including a valid root key in the Authorization header.
|
|
1915
|
+
*/
|
|
1916
|
+
var UnauthorizedErrorResponse = class extends UnkeyError {
|
|
1917
|
+
constructor(err, httpMeta) {
|
|
1918
|
+
const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`;
|
|
1919
|
+
super(message, httpMeta);
|
|
1920
|
+
this.data$ = err;
|
|
1921
|
+
this.meta = err.meta;
|
|
1922
|
+
this.error = err.error;
|
|
1923
|
+
this.name = "UnauthorizedErrorResponse";
|
|
1924
|
+
}
|
|
1925
|
+
};
|
|
1926
|
+
/** @internal */
|
|
1927
|
+
const UnauthorizedErrorResponse$inboundSchema = z$4.object({
|
|
1928
|
+
meta: Meta$inboundSchema,
|
|
1929
|
+
error: BaseError$inboundSchema,
|
|
1930
|
+
request$: z$4.instanceof(Request),
|
|
1931
|
+
response$: z$4.instanceof(Response),
|
|
1932
|
+
body$: z$4.string()
|
|
1933
|
+
}).transform((v) => {
|
|
1934
|
+
return new UnauthorizedErrorResponse(v, {
|
|
1935
|
+
request: v.request$,
|
|
1936
|
+
response: v.response$,
|
|
1937
|
+
body: v.body$
|
|
1938
|
+
});
|
|
1939
|
+
});
|
|
1940
|
+
|
|
1941
|
+
//#endregion
|
|
1942
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/errors/unprocessableentityerrorresponse.js
|
|
1943
|
+
/**
|
|
1944
|
+
* Error response when the request is syntactically valid but cannot be processed due to semantic constraints or resource limitations. This occurs when:
|
|
1945
|
+
*
|
|
1946
|
+
* @remarks
|
|
1947
|
+
* - A query exceeds execution time limits
|
|
1948
|
+
* - A query uses more memory than allowed
|
|
1949
|
+
* - A query scans too many rows
|
|
1950
|
+
* - A query result exceeds size limits
|
|
1951
|
+
*
|
|
1952
|
+
* The request syntax is correct, but the operation cannot be completed due to business rules or resource constraints. Review the error details for specific limitations and adjust your request accordingly.
|
|
1953
|
+
*/
|
|
1954
|
+
var UnprocessableEntityErrorResponse = class extends UnkeyError {
|
|
1955
|
+
constructor(err, httpMeta) {
|
|
1956
|
+
const message = "message" in err && typeof err.message === "string" ? err.message : `API error occurred: ${JSON.stringify(err)}`;
|
|
1957
|
+
super(message, httpMeta);
|
|
1958
|
+
this.data$ = err;
|
|
1959
|
+
this.meta = err.meta;
|
|
1960
|
+
this.error = err.error;
|
|
1961
|
+
this.name = "UnprocessableEntityErrorResponse";
|
|
1962
|
+
}
|
|
1963
|
+
};
|
|
1964
|
+
/** @internal */
|
|
1965
|
+
const UnprocessableEntityErrorResponse$inboundSchema = z$3.object({
|
|
1966
|
+
meta: Meta$inboundSchema,
|
|
1967
|
+
error: BaseError$inboundSchema,
|
|
1968
|
+
request$: z$3.instanceof(Request),
|
|
1969
|
+
response$: z$3.instanceof(Response),
|
|
1970
|
+
body$: z$3.string()
|
|
1971
|
+
}).transform((v) => {
|
|
1972
|
+
return new UnprocessableEntityErrorResponse(v, {
|
|
1973
|
+
request: v.request$,
|
|
1974
|
+
response: v.response$,
|
|
1975
|
+
body: v.body$
|
|
1976
|
+
});
|
|
1977
|
+
});
|
|
1978
|
+
|
|
1979
|
+
//#endregion
|
|
1980
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/types/async.js
|
|
1981
|
+
var __classPrivateFieldSet = void 0 && (void 0).__classPrivateFieldSet || function(receiver, state, value, kind, f) {
|
|
1982
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
1983
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
1984
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
1985
|
+
return kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value), value;
|
|
1986
|
+
};
|
|
1987
|
+
var __classPrivateFieldGet = void 0 && (void 0).__classPrivateFieldGet || function(receiver, state, kind, f) {
|
|
1988
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
1989
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
1990
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
1991
|
+
};
|
|
1992
|
+
var _APIPromise_promise, _APIPromise_unwrapped, _a;
|
|
1993
|
+
_APIPromise_promise = new WeakMap(), _APIPromise_unwrapped = new WeakMap(), _a = Symbol.toStringTag;
|
|
1994
|
+
|
|
1995
|
+
//#endregion
|
|
1996
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/models/operations/identitieslistidentities.js
|
|
1997
|
+
/** @internal */
|
|
1998
|
+
const IdentitiesListIdentitiesResponse$inboundSchema = z$2.object({ Result: V2IdentitiesListIdentitiesResponseBody$inboundSchema }).transform((v) => {
|
|
1999
|
+
return remap(v, { "Result": "result" });
|
|
2000
|
+
});
|
|
2001
|
+
|
|
2002
|
+
//#endregion
|
|
2003
|
+
//#region ../../node_modules/.pnpm/@unkey+api@2.2.1/node_modules/@unkey/api/dist/esm/types/operations.js
|
|
2004
|
+
const URL_OVERRIDE = Symbol("URL_OVERRIDE");
|
|
2005
|
+
|
|
2006
|
+
//#endregion
|
|
2007
|
+
//#region ../../node_modules/.pnpm/@asteasolutions+zod-to-openapi@8.4.0_zod@4.1.13/node_modules/@asteasolutions/zod-to-openapi/dist/index.cjs
|
|
2008
|
+
var require_dist = __commonJS({ "../../node_modules/.pnpm/@asteasolutions+zod-to-openapi@8.4.0_zod@4.1.13/node_modules/@asteasolutions/zod-to-openapi/dist/index.cjs"(exports) {
|
|
2009
|
+
/******************************************************************************
|
|
2010
|
+
|
|
2011
|
+
Copyright (c) Microsoft Corporation.
|
|
2012
|
+
|
|
2013
|
+
|
|
2014
|
+
|
|
2015
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
2016
|
+
|
|
2017
|
+
purpose with or without fee is hereby granted.
|
|
2018
|
+
|
|
2019
|
+
|
|
2020
|
+
|
|
2021
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
2022
|
+
|
|
2023
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
2024
|
+
|
|
2025
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
2026
|
+
|
|
2027
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
2028
|
+
|
|
2029
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
2030
|
+
|
|
2031
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
2032
|
+
|
|
2033
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
2034
|
+
|
|
2035
|
+
***************************************************************************** */
|
|
2036
|
+
function __rest(s, e) {
|
|
2037
|
+
var t = {};
|
|
2038
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p];
|
|
2039
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function") {
|
|
2040
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]];
|
|
2041
|
+
}
|
|
2042
|
+
return t;
|
|
2043
|
+
}
|
|
2044
|
+
const ZodTypeKeys = {
|
|
2045
|
+
ZodAny: "any",
|
|
2046
|
+
ZodArray: "array",
|
|
2047
|
+
ZodBigInt: "bigint",
|
|
2048
|
+
ZodBoolean: "boolean",
|
|
2049
|
+
ZodDefault: "default",
|
|
2050
|
+
ZodPrefault: "prefault",
|
|
2051
|
+
ZodTransform: "transform",
|
|
2052
|
+
ZodEnum: "enum",
|
|
2053
|
+
ZodIntersection: "intersection",
|
|
2054
|
+
ZodLazy: "lazy",
|
|
2055
|
+
ZodLiteral: "literal",
|
|
2056
|
+
ZodNever: "never",
|
|
2057
|
+
ZodNull: "null",
|
|
2058
|
+
ZodNullable: "nullable",
|
|
2059
|
+
ZodNumber: "number",
|
|
2060
|
+
ZodNonOptional: "nonoptional",
|
|
2061
|
+
ZodObject: "object",
|
|
2062
|
+
ZodOptional: "optional",
|
|
2063
|
+
ZodPipe: "pipe",
|
|
2064
|
+
ZodReadonly: "readonly",
|
|
2065
|
+
ZodRecord: "record",
|
|
2066
|
+
ZodString: "string",
|
|
2067
|
+
ZodTuple: "tuple",
|
|
2068
|
+
ZodType: "type",
|
|
2069
|
+
ZodUnion: "union",
|
|
2070
|
+
ZodDiscriminatedUnion: "union",
|
|
2071
|
+
ZodUnknown: "unknown",
|
|
2072
|
+
ZodVoid: "void",
|
|
2073
|
+
ZodDate: "date",
|
|
2074
|
+
ZodTemplateLiteral: "template_literal"
|
|
2075
|
+
};
|
|
2076
|
+
function isZodType(schema, typeNames) {
|
|
2077
|
+
const typeNamesArray = Array.isArray(typeNames) ? typeNames : [typeNames];
|
|
2078
|
+
return typeNamesArray.some((typeName) => {
|
|
2079
|
+
var _a$1;
|
|
2080
|
+
const typeNameMatch = ((_a$1 = schema === null || schema === void 0 ? void 0 : schema.def) === null || _a$1 === void 0 ? void 0 : _a$1.type) === ZodTypeKeys[typeName];
|
|
2081
|
+
if (typeName === "ZodDiscriminatedUnion") return typeNameMatch && "discriminator" in schema.def;
|
|
2082
|
+
return typeNameMatch;
|
|
2083
|
+
});
|
|
2084
|
+
}
|
|
2085
|
+
function isAnyZodType(schema) {
|
|
2086
|
+
return schema && "def" in schema;
|
|
2087
|
+
}
|
|
2088
|
+
/**
|
|
2089
|
+
* The schema.isNullable() is deprecated. This is the suggested replacement
|
|
2090
|
+
* as this was how isNullable operated beforehand.
|
|
2091
|
+
*/
|
|
2092
|
+
function isNullableSchema(schema) {
|
|
2093
|
+
return schema.safeParse(null).success;
|
|
2094
|
+
}
|
|
2095
|
+
/**
|
|
2096
|
+
* The schema.isOptional() is deprecated. This is the suggested replacement
|
|
2097
|
+
* as this was how isOptional operated beforehand.
|
|
2098
|
+
*/
|
|
2099
|
+
function isOptionalSchema(schema) {
|
|
2100
|
+
return schema.safeParse(void 0).success;
|
|
2101
|
+
}
|
|
2102
|
+
var $ZodRegistry = class {
|
|
2103
|
+
constructor() {
|
|
2104
|
+
this._map = new Map();
|
|
2105
|
+
this._idmap = new Map();
|
|
2106
|
+
}
|
|
2107
|
+
add(schema, ..._meta) {
|
|
2108
|
+
const meta = _meta[0];
|
|
2109
|
+
this._map.set(schema, meta);
|
|
2110
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
2111
|
+
if (this._idmap.has(meta.id)) throw new Error(`ID ${meta.id} already exists in the registry`);
|
|
2112
|
+
this._idmap.set(meta.id, schema);
|
|
2113
|
+
}
|
|
2114
|
+
return this;
|
|
2115
|
+
}
|
|
2116
|
+
clear() {
|
|
2117
|
+
this._map = new Map();
|
|
2118
|
+
this._idmap = new Map();
|
|
2119
|
+
return this;
|
|
2120
|
+
}
|
|
2121
|
+
remove(schema) {
|
|
2122
|
+
const meta = this._map.get(schema);
|
|
2123
|
+
if (meta && typeof meta === "object" && "id" in meta) this._idmap.delete(meta.id);
|
|
2124
|
+
this._map.delete(schema);
|
|
2125
|
+
return this;
|
|
2126
|
+
}
|
|
2127
|
+
get(schema) {
|
|
2128
|
+
const p = schema._zod.parent;
|
|
2129
|
+
if (p) {
|
|
2130
|
+
const pm = { ...this.get(p) ?? {} };
|
|
2131
|
+
delete pm.id;
|
|
2132
|
+
return {
|
|
2133
|
+
...pm,
|
|
2134
|
+
...this._map.get(schema)
|
|
2135
|
+
};
|
|
2136
|
+
}
|
|
2137
|
+
return this._map.get(schema);
|
|
2138
|
+
}
|
|
2139
|
+
has(schema) {
|
|
2140
|
+
return this._map.has(schema);
|
|
2141
|
+
}
|
|
2142
|
+
};
|
|
2143
|
+
function registry() {
|
|
2144
|
+
return new $ZodRegistry();
|
|
2145
|
+
}
|
|
2146
|
+
function isEqual(x, y) {
|
|
2147
|
+
if (x === null || x === void 0 || y === null || y === void 0) return x === y;
|
|
2148
|
+
if (x === y || x.valueOf() === y.valueOf()) return true;
|
|
2149
|
+
if (Array.isArray(x)) {
|
|
2150
|
+
if (!Array.isArray(y)) return false;
|
|
2151
|
+
if (x.length !== y.length) return false;
|
|
2152
|
+
}
|
|
2153
|
+
if (!(x instanceof Object) || !(y instanceof Object)) return false;
|
|
2154
|
+
const keysX = Object.keys(x);
|
|
2155
|
+
return Object.keys(y).every((keyY) => keysX.indexOf(keyY) !== -1) && keysX.every((key) => isEqual(x[key], y[key]));
|
|
2156
|
+
}
|
|
2157
|
+
var ObjectSet = class {
|
|
2158
|
+
constructor() {
|
|
2159
|
+
this.buckets = new Map();
|
|
2160
|
+
}
|
|
2161
|
+
put(value) {
|
|
2162
|
+
const hashCode = this.hashCodeOf(value);
|
|
2163
|
+
const itemsByCode = this.buckets.get(hashCode);
|
|
2164
|
+
if (!itemsByCode) {
|
|
2165
|
+
this.buckets.set(hashCode, [value]);
|
|
2166
|
+
return;
|
|
2167
|
+
}
|
|
2168
|
+
const alreadyHasItem = itemsByCode.some((_) => isEqual(_, value));
|
|
2169
|
+
if (!alreadyHasItem) itemsByCode.push(value);
|
|
2170
|
+
}
|
|
2171
|
+
contains(value) {
|
|
2172
|
+
const hashCode = this.hashCodeOf(value);
|
|
2173
|
+
const itemsByCode = this.buckets.get(hashCode);
|
|
2174
|
+
if (!itemsByCode) return false;
|
|
2175
|
+
return itemsByCode.some((_) => isEqual(_, value));
|
|
2176
|
+
}
|
|
2177
|
+
values() {
|
|
2178
|
+
return [...this.buckets.values()].flat();
|
|
2179
|
+
}
|
|
2180
|
+
stats() {
|
|
2181
|
+
let totalBuckets = 0;
|
|
2182
|
+
let totalValues = 0;
|
|
2183
|
+
let collisions = 0;
|
|
2184
|
+
for (const bucket of this.buckets.values()) {
|
|
2185
|
+
totalBuckets += 1;
|
|
2186
|
+
totalValues += bucket.length;
|
|
2187
|
+
if (bucket.length > 1) collisions += 1;
|
|
2188
|
+
}
|
|
2189
|
+
const hashEffectiveness = totalBuckets / totalValues;
|
|
2190
|
+
return {
|
|
2191
|
+
totalBuckets,
|
|
2192
|
+
collisions,
|
|
2193
|
+
totalValues,
|
|
2194
|
+
hashEffectiveness
|
|
2195
|
+
};
|
|
2196
|
+
}
|
|
2197
|
+
hashCodeOf(object) {
|
|
2198
|
+
let hashCode = 0;
|
|
2199
|
+
if (Array.isArray(object)) {
|
|
2200
|
+
for (let i = 0; i < object.length; i++) hashCode ^= this.hashCodeOf(object[i]) * i;
|
|
2201
|
+
return hashCode;
|
|
2202
|
+
}
|
|
2203
|
+
if (typeof object === "string") {
|
|
2204
|
+
for (let i = 0; i < object.length; i++) hashCode ^= object.charCodeAt(i) * i;
|
|
2205
|
+
return hashCode;
|
|
2206
|
+
}
|
|
2207
|
+
if (typeof object === "number") return object;
|
|
2208
|
+
if (typeof object === "object") for (const [key, value] of Object.entries(object)) hashCode ^= this.hashCodeOf(key) + this.hashCodeOf(value !== null && value !== void 0 ? value : "");
|
|
2209
|
+
return hashCode;
|
|
2210
|
+
}
|
|
2211
|
+
};
|
|
2212
|
+
function isUndefined(value) {
|
|
2213
|
+
return value === void 0;
|
|
2214
|
+
}
|
|
2215
|
+
function mapValues(object, mapper) {
|
|
2216
|
+
const result = {};
|
|
2217
|
+
Object.entries(object).forEach(([key, value]) => {
|
|
2218
|
+
result[key] = mapper(value);
|
|
2219
|
+
});
|
|
2220
|
+
return result;
|
|
2221
|
+
}
|
|
2222
|
+
function omit(object, keys) {
|
|
2223
|
+
const result = {};
|
|
2224
|
+
Object.entries(object).forEach(([key, value]) => {
|
|
2225
|
+
if (!keys.some((keyToOmit) => keyToOmit === key)) result[key] = value;
|
|
2226
|
+
});
|
|
2227
|
+
return result;
|
|
2228
|
+
}
|
|
2229
|
+
function omitBy(object, predicate) {
|
|
2230
|
+
const result = {};
|
|
2231
|
+
Object.entries(object).forEach(([key, value]) => {
|
|
2232
|
+
if (!predicate(value, key)) result[key] = value;
|
|
2233
|
+
});
|
|
2234
|
+
return result;
|
|
2235
|
+
}
|
|
2236
|
+
function compact(arr) {
|
|
2237
|
+
return arr.filter((elem) => !isUndefined(elem));
|
|
2238
|
+
}
|
|
2239
|
+
const objectEquals = isEqual;
|
|
2240
|
+
function uniq(values) {
|
|
2241
|
+
const set = new ObjectSet();
|
|
2242
|
+
values.forEach((value) => set.put(value));
|
|
2243
|
+
return [...set.values()];
|
|
2244
|
+
}
|
|
2245
|
+
function isString(val) {
|
|
2246
|
+
return typeof val === "string";
|
|
2247
|
+
}
|
|
2248
|
+
function sortObjectByKeys(obj) {
|
|
2249
|
+
return Object.fromEntries(Object.entries(obj).sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)));
|
|
2250
|
+
}
|
|
2251
|
+
/**
|
|
2252
|
+
* @deprecated This is not really deprecated but this should always be used with
|
|
2253
|
+
* caution. Using it may alter the behavior of the library and the generated schemas.
|
|
2254
|
+
*/
|
|
2255
|
+
const zodToOpenAPIRegistry = registry();
|
|
2256
|
+
var Metadata = class {
|
|
2257
|
+
static collectMetadata(schema, metadata) {
|
|
2258
|
+
const currentMetadata = this.getMetadataFromRegistry(schema);
|
|
2259
|
+
const _internal = Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata._internal), metadata === null || metadata === void 0 ? void 0 : metadata._internal);
|
|
2260
|
+
const param = Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param), metadata === null || metadata === void 0 ? void 0 : metadata.param);
|
|
2261
|
+
const totalMetadata = Object.assign(Object.assign(Object.assign(Object.assign({}, Object.keys(_internal).length > 0 ? { _internal } : {}), currentMetadata), metadata), Object.keys(param).length > 0 ? { param } : {});
|
|
2262
|
+
if (isZodType(schema, [
|
|
2263
|
+
"ZodOptional",
|
|
2264
|
+
"ZodNullable",
|
|
2265
|
+
"ZodDefault",
|
|
2266
|
+
"ZodPrefault",
|
|
2267
|
+
"ZodReadonly",
|
|
2268
|
+
"ZodNonOptional"
|
|
2269
|
+
]) && isAnyZodType(schema._zod.def.innerType)) return this.collectMetadata(schema._zod.def.innerType, totalMetadata);
|
|
2270
|
+
if (isZodType(schema, "ZodPipe")) {
|
|
2271
|
+
const inSchema = schema._zod.def.in;
|
|
2272
|
+
const outSchema = schema._zod.def.out;
|
|
2273
|
+
if (isZodType(inSchema, "ZodTransform") && isAnyZodType(outSchema)) return this.collectMetadata(outSchema, totalMetadata);
|
|
2274
|
+
if (isAnyZodType(inSchema)) return this.collectMetadata(inSchema, totalMetadata);
|
|
2275
|
+
}
|
|
2276
|
+
return totalMetadata;
|
|
2277
|
+
}
|
|
2278
|
+
/**
|
|
2279
|
+
* @deprecated Use one of `getOpenApiMetadata` or `getInternalMetadata` instead
|
|
2280
|
+
*/
|
|
2281
|
+
static getMetadata(zodSchema) {
|
|
2282
|
+
return this.collectMetadata(zodSchema);
|
|
2283
|
+
}
|
|
2284
|
+
static getOpenApiMetadata(zodSchema) {
|
|
2285
|
+
const metadata = this.collectMetadata(zodSchema);
|
|
2286
|
+
const _a$1 = metadata !== null && metadata !== void 0 ? metadata : {}, rest = __rest(_a$1, ["_internal"]);
|
|
2287
|
+
return rest;
|
|
2288
|
+
}
|
|
2289
|
+
static getInternalMetadata(zodSchema) {
|
|
2290
|
+
var _a$1;
|
|
2291
|
+
return (_a$1 = this.collectMetadata(zodSchema)) === null || _a$1 === void 0 ? void 0 : _a$1._internal;
|
|
2292
|
+
}
|
|
2293
|
+
static getParamMetadata(zodSchema) {
|
|
2294
|
+
const metadata = this.collectMetadata(zodSchema);
|
|
2295
|
+
return Object.assign(Object.assign({}, metadata), { param: Object.assign(Object.assign({}, (metadata === null || metadata === void 0 ? void 0 : metadata.description) ? { description: metadata.description } : {}), metadata === null || metadata === void 0 ? void 0 : metadata.param) });
|
|
2296
|
+
}
|
|
2297
|
+
/**
|
|
2298
|
+
* A method that omits all custom keys added to the regular OpenAPI
|
|
2299
|
+
* metadata properties
|
|
2300
|
+
*/
|
|
2301
|
+
static buildSchemaMetadata(metadata) {
|
|
2302
|
+
return omitBy(omit(metadata, ["param", "_internal"]), isUndefined);
|
|
2303
|
+
}
|
|
2304
|
+
static buildParameterMetadata(metadata) {
|
|
2305
|
+
return omitBy(metadata, isUndefined);
|
|
2306
|
+
}
|
|
2307
|
+
static applySchemaMetadata(initialData, metadata) {
|
|
2308
|
+
return omitBy(Object.assign(Object.assign({}, initialData), this.buildSchemaMetadata(metadata)), isUndefined);
|
|
2309
|
+
}
|
|
2310
|
+
static getRefId(zodSchema) {
|
|
2311
|
+
var _a$1;
|
|
2312
|
+
return (_a$1 = this.getInternalMetadata(zodSchema)) === null || _a$1 === void 0 ? void 0 : _a$1.refId;
|
|
2313
|
+
}
|
|
2314
|
+
static unwrapChained(schema) {
|
|
2315
|
+
return this.unwrapUntil(schema);
|
|
2316
|
+
}
|
|
2317
|
+
static getDefaultValue(zodSchema) {
|
|
2318
|
+
var _a$1;
|
|
2319
|
+
const unwrapped = (_a$1 = this.unwrapUntil(zodSchema, "ZodDefault")) !== null && _a$1 !== void 0 ? _a$1 : this.unwrapUntil(zodSchema, "ZodPrefault");
|
|
2320
|
+
return unwrapped === null || unwrapped === void 0 ? void 0 : unwrapped._zod.def.defaultValue;
|
|
2321
|
+
}
|
|
2322
|
+
static unwrapUntil(schema, typeName) {
|
|
2323
|
+
if (typeName && isZodType(schema, typeName)) return schema;
|
|
2324
|
+
if (isZodType(schema, [
|
|
2325
|
+
"ZodOptional",
|
|
2326
|
+
"ZodNullable",
|
|
2327
|
+
"ZodDefault",
|
|
2328
|
+
"ZodPrefault",
|
|
2329
|
+
"ZodReadonly",
|
|
2330
|
+
"ZodNonOptional"
|
|
2331
|
+
]) && isAnyZodType(schema._zod.def.innerType)) return this.unwrapUntil(schema._zod.def.innerType, typeName);
|
|
2332
|
+
if (isZodType(schema, "ZodPipe")) {
|
|
2333
|
+
const inSchema = schema._zod.def.in;
|
|
2334
|
+
const outSchema = schema._zod.def.out;
|
|
2335
|
+
if (isZodType(inSchema, "ZodTransform") && isAnyZodType(outSchema)) return this.unwrapUntil(outSchema, typeName);
|
|
2336
|
+
if (isAnyZodType(inSchema)) return this.unwrapUntil(inSchema, typeName);
|
|
2337
|
+
}
|
|
2338
|
+
return typeName ? void 0 : schema;
|
|
2339
|
+
}
|
|
2340
|
+
static getMetadataFromInternalRegistry(zodSchema) {
|
|
2341
|
+
return zodToOpenAPIRegistry.get(zodSchema);
|
|
2342
|
+
}
|
|
2343
|
+
static getMetadataFromRegistry(zodSchema) {
|
|
2344
|
+
const internal = this.getMetadataFromInternalRegistry(zodSchema);
|
|
2345
|
+
const general = zodSchema.meta();
|
|
2346
|
+
if (!internal) return general;
|
|
2347
|
+
const { _internal } = internal, rest = __rest(internal, ["_internal"]);
|
|
2348
|
+
const _a$1 = general !== null && general !== void 0 ? general : {}, { id, title } = _a$1, restGeneral = __rest(_a$1, ["id", "title"]);
|
|
2349
|
+
return Object.assign(Object.assign(Object.assign({ _internal: Object.assign(Object.assign({}, id ? { refId: id } : {}), _internal) }, rest), title ? { description: title } : {}), restGeneral);
|
|
2350
|
+
}
|
|
2351
|
+
static setMetadataInRegistry(zodSchema, metadata) {
|
|
2352
|
+
zodToOpenAPIRegistry.add(zodSchema, metadata);
|
|
2353
|
+
}
|
|
2354
|
+
};
|
|
2355
|
+
function preserveMetadataFromModifier(zodSchema, modifier) {
|
|
2356
|
+
const zodModifier = zodSchema[modifier];
|
|
2357
|
+
if (typeof zodModifier !== "function") return;
|
|
2358
|
+
zodSchema[modifier] = function(...args) {
|
|
2359
|
+
const result = zodModifier.apply(this, args);
|
|
2360
|
+
const meta = Metadata.getMetadataFromRegistry(this);
|
|
2361
|
+
if (meta) Metadata.setMetadataInRegistry(result, meta);
|
|
2362
|
+
return result;
|
|
2363
|
+
};
|
|
2364
|
+
}
|
|
2365
|
+
function extendZodWithOpenApi(zod) {
|
|
2366
|
+
if (typeof zod.ZodType.prototype.openapi !== "undefined") return;
|
|
2367
|
+
zod.ZodType.prototype.openapi = function(...args) {
|
|
2368
|
+
const { refId, metadata, options } = getOpenApiConfiguration(...args);
|
|
2369
|
+
const _a$1 = metadata !== null && metadata !== void 0 ? metadata : {}, { param } = _a$1, restOfOpenApi = __rest(_a$1, ["param"]);
|
|
2370
|
+
const allMetadata = Metadata.getMetadataFromRegistry(this);
|
|
2371
|
+
const _b = allMetadata !== null && allMetadata !== void 0 ? allMetadata : {}, { _internal: internalMetadata } = _b, currentMetadata = __rest(_b, ["_internal"]);
|
|
2372
|
+
const _internal = Object.assign(Object.assign(Object.assign({}, internalMetadata), options), refId ? { refId } : void 0);
|
|
2373
|
+
const resultMetadata = Object.assign(Object.assign(Object.assign({}, currentMetadata), restOfOpenApi), (currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param) || param ? { param: Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param), param) } : void 0);
|
|
2374
|
+
const result = new this.constructor(this._def);
|
|
2375
|
+
function setMetadata(schema) {
|
|
2376
|
+
Metadata.setMetadataInRegistry(schema, Object.assign(Object.assign({}, Object.keys(_internal).length > 0 ? { _internal } : void 0), resultMetadata));
|
|
2377
|
+
}
|
|
2378
|
+
setMetadata(result);
|
|
2379
|
+
/**
|
|
2380
|
+
* In order to handle z.json() which is implemented as:
|
|
2381
|
+
*
|
|
2382
|
+
* const jsonSchema = lazy(() => { return union([ ... ]) });
|
|
2383
|
+
* return jsonSchema;
|
|
2384
|
+
*
|
|
2385
|
+
* We need to not only set the metadata to the resulting schema (which would be different
|
|
2386
|
+
* from `jsonSchema`), but also to the original lazy schema so that the _internal metadata (refId)
|
|
2387
|
+
* is also present in the internally used `jsonSchema`.
|
|
2388
|
+
*/
|
|
2389
|
+
if (isZodType(result, "ZodLazy")) setMetadata(this);
|
|
2390
|
+
if (isZodType(result, "ZodObject")) {
|
|
2391
|
+
const currentMetadata$1 = Metadata.getMetadataFromRegistry(result);
|
|
2392
|
+
const originalExtend = result.extend;
|
|
2393
|
+
result.extend = function(...args$1) {
|
|
2394
|
+
const extendedResult = originalExtend.apply(result, args$1);
|
|
2395
|
+
const _a$2 = currentMetadata$1 !== null && currentMetadata$1 !== void 0 ? currentMetadata$1 : {}, { _internal: _internal$1 } = _a$2, rest = __rest(_a$2, ["_internal"]);
|
|
2396
|
+
Metadata.setMetadataInRegistry(extendedResult, { _internal: { extendedFrom: (_internal$1 === null || _internal$1 === void 0 ? void 0 : _internal$1.refId) ? {
|
|
2397
|
+
refId: _internal$1.refId,
|
|
2398
|
+
schema: result
|
|
2399
|
+
} : _internal$1 === null || _internal$1 === void 0 ? void 0 : _internal$1.extendedFrom } });
|
|
2400
|
+
return extendedResult.openapi(rest);
|
|
2401
|
+
};
|
|
2402
|
+
preserveMetadataFromModifier(result, "catchall");
|
|
2403
|
+
}
|
|
2404
|
+
preserveMetadataFromModifier(result, "optional");
|
|
2405
|
+
preserveMetadataFromModifier(result, "nullable");
|
|
2406
|
+
preserveMetadataFromModifier(result, "default");
|
|
2407
|
+
preserveMetadataFromModifier(result, "transform");
|
|
2408
|
+
preserveMetadataFromModifier(result, "refine");
|
|
2409
|
+
preserveMetadataFromModifier(result, "length");
|
|
2410
|
+
preserveMetadataFromModifier(result, "min");
|
|
2411
|
+
preserveMetadataFromModifier(result, "max");
|
|
2412
|
+
const originalMeta = result.meta;
|
|
2413
|
+
result.meta = function(...args$1) {
|
|
2414
|
+
const result$1 = originalMeta.apply(this, args$1);
|
|
2415
|
+
if (args$1[0]) {
|
|
2416
|
+
const meta = Metadata.getMetadataFromInternalRegistry(this);
|
|
2417
|
+
if (meta) Metadata.setMetadataInRegistry(result$1, Object.assign(Object.assign({}, meta), args$1[0]));
|
|
2418
|
+
}
|
|
2419
|
+
return result$1;
|
|
2420
|
+
};
|
|
2421
|
+
return result;
|
|
2422
|
+
};
|
|
2423
|
+
}
|
|
2424
|
+
function getOpenApiConfiguration(refOrOpenapi, metadataOrOptions, options) {
|
|
2425
|
+
if (typeof refOrOpenapi === "string") return {
|
|
2426
|
+
refId: refOrOpenapi,
|
|
2427
|
+
metadata: metadataOrOptions,
|
|
2428
|
+
options
|
|
2429
|
+
};
|
|
2430
|
+
return {
|
|
2431
|
+
refId: void 0,
|
|
2432
|
+
metadata: refOrOpenapi,
|
|
2433
|
+
options: metadataOrOptions
|
|
2434
|
+
};
|
|
2435
|
+
}
|
|
2436
|
+
function getOpenApiMetadata(zodSchema) {
|
|
2437
|
+
var _a$1;
|
|
2438
|
+
return omitBy((_a$1 = Metadata.getOpenApiMetadata(zodSchema)) !== null && _a$1 !== void 0 ? _a$1 : {}, isUndefined);
|
|
2439
|
+
}
|
|
2440
|
+
function getRefId(zodSchema) {
|
|
2441
|
+
return Metadata.getRefId(zodSchema);
|
|
2442
|
+
}
|
|
2443
|
+
var OpenAPIRegistry = class {
|
|
2444
|
+
constructor(parents) {
|
|
2445
|
+
this.parents = parents;
|
|
2446
|
+
this._definitions = [];
|
|
2447
|
+
}
|
|
2448
|
+
get definitions() {
|
|
2449
|
+
var _a$1, _b;
|
|
2450
|
+
const parentDefinitions = (_b = (_a$1 = this.parents) === null || _a$1 === void 0 ? void 0 : _a$1.flatMap((par) => par._definitions)) !== null && _b !== void 0 ? _b : [];
|
|
2451
|
+
return [...parentDefinitions, ...this._definitions];
|
|
2452
|
+
}
|
|
2453
|
+
/**
|
|
2454
|
+
* Registers a new component schema under /components/schemas/${name}
|
|
2455
|
+
*/
|
|
2456
|
+
register(refId, zodSchema) {
|
|
2457
|
+
const schemaWithRefId = this.schemaWithRefId(refId, zodSchema);
|
|
2458
|
+
this._definitions.push({
|
|
2459
|
+
type: "schema",
|
|
2460
|
+
schema: schemaWithRefId
|
|
2461
|
+
});
|
|
2462
|
+
return schemaWithRefId;
|
|
2463
|
+
}
|
|
2464
|
+
/**
|
|
2465
|
+
* Registers a new parameter schema under /components/parameters/${name}
|
|
2466
|
+
*/
|
|
2467
|
+
registerParameter(refId, zodSchema) {
|
|
2468
|
+
var _a$1, _b, _c;
|
|
2469
|
+
const schemaWithRefId = this.schemaWithRefId(refId, zodSchema);
|
|
2470
|
+
const currentMetadata = (_a$1 = Metadata.getOpenApiMetadata(schemaWithRefId)) !== null && _a$1 !== void 0 ? _a$1 : {};
|
|
2471
|
+
const schemaWithMetadata = schemaWithRefId.openapi(Object.assign(Object.assign({}, currentMetadata), { param: Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param), { name: (_c = (_b = currentMetadata === null || currentMetadata === void 0 ? void 0 : currentMetadata.param) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : refId }) }));
|
|
2472
|
+
this._definitions.push({
|
|
2473
|
+
type: "parameter",
|
|
2474
|
+
schema: schemaWithMetadata
|
|
2475
|
+
});
|
|
2476
|
+
return schemaWithMetadata;
|
|
2477
|
+
}
|
|
2478
|
+
/**
|
|
2479
|
+
* Registers a new path that would be generated under paths:
|
|
2480
|
+
*/
|
|
2481
|
+
registerPath(route) {
|
|
2482
|
+
this._definitions.push({
|
|
2483
|
+
type: "route",
|
|
2484
|
+
route
|
|
2485
|
+
});
|
|
2486
|
+
}
|
|
2487
|
+
/**
|
|
2488
|
+
* Registers a new webhook that would be generated under webhooks:
|
|
2489
|
+
*/
|
|
2490
|
+
registerWebhook(webhook) {
|
|
2491
|
+
this._definitions.push({
|
|
2492
|
+
type: "webhook",
|
|
2493
|
+
webhook
|
|
2494
|
+
});
|
|
2495
|
+
}
|
|
2496
|
+
/**
|
|
2497
|
+
* Registers a raw OpenAPI component. Use this if you have a simple object instead of a Zod schema.
|
|
2498
|
+
*
|
|
2499
|
+
* @param type The component type, e.g. `schemas`, `responses`, `securitySchemes`, etc.
|
|
2500
|
+
* @param name The name of the object, it is the key under the component
|
|
2501
|
+
* type in the resulting OpenAPI document
|
|
2502
|
+
* @param component The actual object to put there
|
|
2503
|
+
*/
|
|
2504
|
+
registerComponent(type, name, component) {
|
|
2505
|
+
this._definitions.push({
|
|
2506
|
+
type: "component",
|
|
2507
|
+
componentType: type,
|
|
2508
|
+
name,
|
|
2509
|
+
component
|
|
2510
|
+
});
|
|
2511
|
+
return {
|
|
2512
|
+
name,
|
|
2513
|
+
ref: { $ref: `#/components/${type}/${name}` }
|
|
2514
|
+
};
|
|
2515
|
+
}
|
|
2516
|
+
schemaWithRefId(refId, zodSchema) {
|
|
2517
|
+
return zodSchema.openapi(refId);
|
|
2518
|
+
}
|
|
2519
|
+
};
|
|
2520
|
+
var ZodToOpenAPIError = class {
|
|
2521
|
+
constructor(message) {
|
|
2522
|
+
this.message = message;
|
|
2523
|
+
}
|
|
2524
|
+
};
|
|
2525
|
+
var ConflictError = class extends ZodToOpenAPIError {
|
|
2526
|
+
constructor(message, data) {
|
|
2527
|
+
super(message);
|
|
2528
|
+
this.data = data;
|
|
2529
|
+
}
|
|
2530
|
+
};
|
|
2531
|
+
var MissingParameterDataError = class extends ZodToOpenAPIError {
|
|
2532
|
+
constructor(data) {
|
|
2533
|
+
super(`Missing parameter data, please specify \`${data.missingField}\` and other OpenAPI parameter props using the \`param\` field of \`schema.openapi\``);
|
|
2534
|
+
this.data = data;
|
|
2535
|
+
}
|
|
2536
|
+
};
|
|
2537
|
+
function enhanceMissingParametersError(action, paramsToAdd) {
|
|
2538
|
+
try {
|
|
2539
|
+
return action();
|
|
2540
|
+
} catch (error) {
|
|
2541
|
+
if (error instanceof MissingParameterDataError) throw new MissingParameterDataError(Object.assign(Object.assign({}, error.data), paramsToAdd));
|
|
2542
|
+
throw error;
|
|
2543
|
+
}
|
|
2544
|
+
}
|
|
2545
|
+
var UnknownZodTypeError = class extends ZodToOpenAPIError {
|
|
2546
|
+
constructor(data) {
|
|
2547
|
+
super(`Unknown zod object type, please specify \`type\` and other OpenAPI props using \`schema.openapi\`.`);
|
|
2548
|
+
this.data = data;
|
|
2549
|
+
}
|
|
2550
|
+
};
|
|
2551
|
+
var ArrayTransformer = class {
|
|
2552
|
+
transform(zodSchema, mapNullableType, mapItems) {
|
|
2553
|
+
var _a$1, _b, _c, _d;
|
|
2554
|
+
const itemType = zodSchema.def.element;
|
|
2555
|
+
const minItems = (_b = (_a$1 = zodSchema.def.checks) === null || _a$1 === void 0 ? void 0 : _a$1.find((check) => check._zod.def.check === "min_length")) === null || _b === void 0 ? void 0 : _b._zod.def.minimum;
|
|
2556
|
+
const maxItems = (_d = (_c = zodSchema.def.checks) === null || _c === void 0 ? void 0 : _c.find((check) => check._zod.def.check === "max_length")) === null || _d === void 0 ? void 0 : _d._zod.def.maximum;
|
|
2557
|
+
return Object.assign(Object.assign({}, mapNullableType("array")), {
|
|
2558
|
+
items: isAnyZodType(itemType) ? mapItems(itemType) : {},
|
|
2559
|
+
minItems,
|
|
2560
|
+
maxItems
|
|
2561
|
+
});
|
|
2562
|
+
}
|
|
2563
|
+
};
|
|
2564
|
+
var BigIntTransformer = class {
|
|
2565
|
+
transform(mapNullableType) {
|
|
2566
|
+
return Object.assign(Object.assign({}, mapNullableType("string")), { pattern: `^\d+$` });
|
|
2567
|
+
}
|
|
2568
|
+
};
|
|
2569
|
+
var DiscriminatedUnionTransformer = class {
|
|
2570
|
+
transform(zodSchema, isNullable, mapNullableOfArray, mapItem, generateSchemaRef) {
|
|
2571
|
+
const options = [...zodSchema.def.options];
|
|
2572
|
+
const optionSchema = options.map(mapItem);
|
|
2573
|
+
if (isNullable) return { oneOf: mapNullableOfArray(optionSchema, isNullable) };
|
|
2574
|
+
const discriminator = zodSchema._zod.def.discriminator;
|
|
2575
|
+
if (!discriminator) {
|
|
2576
|
+
console.error("No discriminator found for discriminated union", zodSchema);
|
|
2577
|
+
return { oneOf: optionSchema };
|
|
2578
|
+
}
|
|
2579
|
+
return {
|
|
2580
|
+
oneOf: optionSchema,
|
|
2581
|
+
discriminator: this.mapDiscriminator(options, discriminator, generateSchemaRef)
|
|
2582
|
+
};
|
|
2583
|
+
}
|
|
2584
|
+
mapDiscriminator(zodObjects, discriminator, generateSchemaRef) {
|
|
2585
|
+
if (zodObjects.some((obj) => Metadata.getRefId(obj) === void 0)) return void 0;
|
|
2586
|
+
const mapping = {};
|
|
2587
|
+
zodObjects.forEach((obj) => {
|
|
2588
|
+
var _a$1;
|
|
2589
|
+
const refId = Metadata.getRefId(obj);
|
|
2590
|
+
const value = (_a$1 = obj.def.shape) === null || _a$1 === void 0 ? void 0 : _a$1[discriminator];
|
|
2591
|
+
if (isZodType(value, "ZodEnum")) {
|
|
2592
|
+
const keys = Object.values(value._zod.def.entries).filter(isString);
|
|
2593
|
+
keys.forEach((enumValue) => {
|
|
2594
|
+
mapping[enumValue] = generateSchemaRef(refId);
|
|
2595
|
+
});
|
|
2596
|
+
return;
|
|
2597
|
+
}
|
|
2598
|
+
const literalValue = value === null || value === void 0 ? void 0 : value.def.values[0];
|
|
2599
|
+
if (typeof literalValue !== "string") throw new Error(`Discriminator ${discriminator} could not be found in one of the values of a discriminated union`);
|
|
2600
|
+
mapping[literalValue] = generateSchemaRef(refId);
|
|
2601
|
+
});
|
|
2602
|
+
return {
|
|
2603
|
+
propertyName: discriminator,
|
|
2604
|
+
mapping
|
|
2605
|
+
};
|
|
2606
|
+
}
|
|
2607
|
+
};
|
|
2608
|
+
/**
|
|
2609
|
+
* Numeric enums have a reverse mapping https://www.typescriptlang.org/docs/handbook/enums.html#reverse-mappings
|
|
2610
|
+
* whereas string ones don't.
|
|
2611
|
+
*
|
|
2612
|
+
* This function checks if an enum is fully numeric - i.e all values are numbers or not.
|
|
2613
|
+
* And filters out only the actual enum values when a reverse mapping is apparent.
|
|
2614
|
+
*/
|
|
2615
|
+
function enumInfo(enumObject) {
|
|
2616
|
+
const keysExceptReverseMappings = Object.keys(enumObject).filter((key) => typeof enumObject[enumObject[key]] !== "number");
|
|
2617
|
+
const values = keysExceptReverseMappings.map((key) => enumObject[key]);
|
|
2618
|
+
const numericCount = values.filter((_) => typeof _ === "number").length;
|
|
2619
|
+
const type = numericCount === 0 ? "string" : numericCount === values.length ? "numeric" : "mixed";
|
|
2620
|
+
return {
|
|
2621
|
+
values,
|
|
2622
|
+
type
|
|
2623
|
+
};
|
|
2624
|
+
}
|
|
2625
|
+
var EnumTransformer = class {
|
|
2626
|
+
transform(zodSchema, isNullable, mapNullableType) {
|
|
2627
|
+
const { type, values } = enumInfo(zodSchema._zod.def.entries);
|
|
2628
|
+
if (type === "mixed") throw new ZodToOpenAPIError("Enum has mixed string and number values, please specify the OpenAPI type manually");
|
|
2629
|
+
return Object.assign(Object.assign({}, mapNullableType(type === "numeric" ? "integer" : "string")), { enum: isNullable ? [...values, null] : values });
|
|
2630
|
+
}
|
|
2631
|
+
};
|
|
2632
|
+
var IntersectionTransformer = class {
|
|
2633
|
+
transform(zodSchema, isNullable, mapNullableOfArray, mapItem) {
|
|
2634
|
+
const subtypes = this.flattenIntersectionTypes(zodSchema);
|
|
2635
|
+
const allOfSchema = { allOf: subtypes.map(mapItem) };
|
|
2636
|
+
if (isNullable) return { anyOf: mapNullableOfArray([allOfSchema], isNullable) };
|
|
2637
|
+
return allOfSchema;
|
|
2638
|
+
}
|
|
2639
|
+
flattenIntersectionTypes(schema) {
|
|
2640
|
+
if (!isZodType(schema, "ZodIntersection")) return [schema];
|
|
2641
|
+
const leftSubTypes = isAnyZodType(schema._zod.def.left) ? this.flattenIntersectionTypes(schema._zod.def.left) : [];
|
|
2642
|
+
const rightSubTypes = isAnyZodType(schema._zod.def.right) ? this.flattenIntersectionTypes(schema._zod.def.right) : [];
|
|
2643
|
+
return [...leftSubTypes, ...rightSubTypes];
|
|
2644
|
+
}
|
|
2645
|
+
};
|
|
2646
|
+
var LiteralTransformer = class {
|
|
2647
|
+
constructor() {
|
|
2648
|
+
this.bigIntTransformer = new BigIntTransformer();
|
|
2649
|
+
}
|
|
2650
|
+
transform(zodSchema, mapNullableType) {
|
|
2651
|
+
const type = typeof zodSchema.def.values[0];
|
|
2652
|
+
if (type === "boolean" || type === "number" || type === "string" || type === "object") return Object.assign(Object.assign({}, mapNullableType(type)), { enum: [zodSchema.def.values[0]] });
|
|
2653
|
+
if (type === "bigint") return this.bigIntTransformer.transform(mapNullableType);
|
|
2654
|
+
return mapNullableType("null");
|
|
2655
|
+
}
|
|
2656
|
+
};
|
|
2657
|
+
var NumberTransformer = class {
|
|
2658
|
+
transform(zodSchema, mapNullableType, getNumberChecks) {
|
|
2659
|
+
var _a$1;
|
|
2660
|
+
return Object.assign(Object.assign(Object.assign({}, mapNullableType("number")), mapNullableType(zodSchema.format === "safeint" ? "integer" : "number")), getNumberChecks((_a$1 = zodSchema.def.checks) !== null && _a$1 !== void 0 ? _a$1 : []));
|
|
2661
|
+
}
|
|
2662
|
+
};
|
|
2663
|
+
var ObjectTransformer = class {
|
|
2664
|
+
transform(zodSchema, defaultValue, mapNullableType, mapItem) {
|
|
2665
|
+
var _a$1;
|
|
2666
|
+
const extendedFrom = (_a$1 = Metadata.getInternalMetadata(zodSchema)) === null || _a$1 === void 0 ? void 0 : _a$1.extendedFrom;
|
|
2667
|
+
const required = this.requiredKeysOf(zodSchema);
|
|
2668
|
+
const properties = mapValues(zodSchema.def.shape, mapItem);
|
|
2669
|
+
if (!extendedFrom) return Object.assign(Object.assign(Object.assign(Object.assign({}, mapNullableType("object")), {
|
|
2670
|
+
properties,
|
|
2671
|
+
default: defaultValue
|
|
2672
|
+
}), required.length > 0 ? { required } : {}), this.generateAdditionalProperties(zodSchema, mapItem));
|
|
2673
|
+
const parent = extendedFrom.schema;
|
|
2674
|
+
mapItem(parent);
|
|
2675
|
+
const keysRequiredByParent = this.requiredKeysOf(parent);
|
|
2676
|
+
const propsOfParent = mapValues(parent === null || parent === void 0 ? void 0 : parent.def.shape, mapItem);
|
|
2677
|
+
const propertiesToAdd = Object.fromEntries(Object.entries(properties).filter(([key, type]) => {
|
|
2678
|
+
return !objectEquals(propsOfParent[key], type);
|
|
2679
|
+
}));
|
|
2680
|
+
const additionallyRequired = required.filter((prop) => !keysRequiredByParent.includes(prop));
|
|
2681
|
+
const objectData = Object.assign(Object.assign(Object.assign(Object.assign({}, mapNullableType("object")), {
|
|
2682
|
+
default: defaultValue,
|
|
2683
|
+
properties: propertiesToAdd
|
|
2684
|
+
}), additionallyRequired.length > 0 ? { required: additionallyRequired } : {}), this.generateAdditionalProperties(zodSchema, mapItem));
|
|
2685
|
+
return { allOf: [{ $ref: `#/components/schemas/${extendedFrom.refId}` }, objectData] };
|
|
2686
|
+
}
|
|
2687
|
+
generateAdditionalProperties(zodSchema, mapItem) {
|
|
2688
|
+
const catchallSchema = zodSchema.def.catchall;
|
|
2689
|
+
if (!catchallSchema) return {};
|
|
2690
|
+
if (isZodType(catchallSchema, "ZodNever")) return { additionalProperties: false };
|
|
2691
|
+
if (isAnyZodType(catchallSchema)) return { additionalProperties: mapItem(catchallSchema) };
|
|
2692
|
+
return {};
|
|
2693
|
+
}
|
|
2694
|
+
requiredKeysOf(objectSchema) {
|
|
2695
|
+
return Object.entries(objectSchema.def.shape).filter(([_key, type]) => !isOptionalSchema(type)).map(([key, _type]) => key);
|
|
2696
|
+
}
|
|
2697
|
+
};
|
|
2698
|
+
var RecordTransformer = class {
|
|
2699
|
+
transform(zodSchema, mapNullableType, mapItem) {
|
|
2700
|
+
const propertiesType = zodSchema.valueType;
|
|
2701
|
+
const keyType = zodSchema.keyType;
|
|
2702
|
+
const propertiesSchema = isAnyZodType(propertiesType) ? mapItem(propertiesType) : {};
|
|
2703
|
+
if (isZodType(keyType, "ZodEnum")) {
|
|
2704
|
+
const keys = Object.values(keyType._zod.def.entries).filter(isString);
|
|
2705
|
+
const properties = keys.reduce((acc, curr) => Object.assign(Object.assign({}, acc), { [curr]: propertiesSchema }), {});
|
|
2706
|
+
return Object.assign(Object.assign({}, mapNullableType("object")), { properties });
|
|
2707
|
+
}
|
|
2708
|
+
return Object.assign(Object.assign({}, mapNullableType("object")), { additionalProperties: propertiesSchema });
|
|
2709
|
+
}
|
|
2710
|
+
};
|
|
2711
|
+
function isZodCheckLengthEquals(check) {
|
|
2712
|
+
return check._zod.def.check === "length_equals";
|
|
2713
|
+
}
|
|
2714
|
+
function isZodCheckRegex(check) {
|
|
2715
|
+
return check._zod.def.check === "string_format" && check._zod.def.format === "regex";
|
|
2716
|
+
}
|
|
2717
|
+
var StringTransformer = class {
|
|
2718
|
+
transform(zodSchema, mapNullableType) {
|
|
2719
|
+
var _a$1, _b, _c, _d;
|
|
2720
|
+
const regexCheck = (_a$1 = zodSchema.def.checks) === null || _a$1 === void 0 ? void 0 : _a$1.find(isZodCheckRegex);
|
|
2721
|
+
const pattern = regexCheck === null || regexCheck === void 0 ? void 0 : regexCheck._zod.def.pattern.toString().replace(/^\/|\/$/g, "");
|
|
2722
|
+
const check = (_b = zodSchema.def.checks) === null || _b === void 0 ? void 0 : _b.find(isZodCheckLengthEquals);
|
|
2723
|
+
const length = check === null || check === void 0 ? void 0 : check._zod.def.length;
|
|
2724
|
+
const maxLength = Number.isFinite(zodSchema.minLength) ? (_c = zodSchema.minLength) !== null && _c !== void 0 ? _c : void 0 : void 0;
|
|
2725
|
+
const minLength = Number.isFinite(zodSchema.maxLength) ? (_d = zodSchema.maxLength) !== null && _d !== void 0 ? _d : void 0 : void 0;
|
|
2726
|
+
return Object.assign(Object.assign({}, mapNullableType("string")), {
|
|
2727
|
+
minLength: length !== null && length !== void 0 ? length : maxLength,
|
|
2728
|
+
maxLength: length !== null && length !== void 0 ? length : minLength,
|
|
2729
|
+
format: this.mapStringFormat(zodSchema),
|
|
2730
|
+
pattern
|
|
2731
|
+
});
|
|
2732
|
+
}
|
|
2733
|
+
/**
|
|
2734
|
+
* Attempts to map Zod strings to known formats
|
|
2735
|
+
* https://json-schema.org/understanding-json-schema/reference/string.html#built-in-formats
|
|
2736
|
+
*/
|
|
2737
|
+
mapStringFormat(zodString) {
|
|
2738
|
+
if (zodString.format === "uuid") return "uuid";
|
|
2739
|
+
if (zodString.format === "email") return "email";
|
|
2740
|
+
if (zodString.format === "url") return "uri";
|
|
2741
|
+
if (zodString.format === "date") return "date";
|
|
2742
|
+
if (zodString.format === "datetime") return "date-time";
|
|
2743
|
+
if (zodString.format === "cuid") return "cuid";
|
|
2744
|
+
if (zodString.format === "cuid2") return "cuid2";
|
|
2745
|
+
if (zodString.format === "ulid") return "ulid";
|
|
2746
|
+
if (zodString.format === "ipv4") return "ip";
|
|
2747
|
+
if (zodString.format === "ipv6") return "ip";
|
|
2748
|
+
if (zodString.format === "emoji") return "emoji";
|
|
2749
|
+
return void 0;
|
|
2750
|
+
}
|
|
2751
|
+
};
|
|
2752
|
+
var TupleTransformer = class {
|
|
2753
|
+
constructor(versionSpecifics) {
|
|
2754
|
+
this.versionSpecifics = versionSpecifics;
|
|
2755
|
+
}
|
|
2756
|
+
transform(zodSchema, mapNullableType, mapItem) {
|
|
2757
|
+
const items = zodSchema._zod.def.items;
|
|
2758
|
+
const schemas = items.map((item) => isAnyZodType(item) ? mapItem(item) : {});
|
|
2759
|
+
return Object.assign(Object.assign({}, mapNullableType("array")), this.versionSpecifics.mapTupleItems(schemas));
|
|
2760
|
+
}
|
|
2761
|
+
};
|
|
2762
|
+
var UnionTransformer = class {
|
|
2763
|
+
constructor(options) {
|
|
2764
|
+
this.options = options;
|
|
2765
|
+
}
|
|
2766
|
+
transform(zodSchema, mapNullableOfArray, mapItem) {
|
|
2767
|
+
var _a$1, _b, _c;
|
|
2768
|
+
const internalMetadata = Metadata.getInternalMetadata(zodSchema);
|
|
2769
|
+
const preferredType = (_c = (_a$1 = internalMetadata === null || internalMetadata === void 0 ? void 0 : internalMetadata.unionPreferredType) !== null && _a$1 !== void 0 ? _a$1 : (_b = this.options) === null || _b === void 0 ? void 0 : _b.unionPreferredType) !== null && _c !== void 0 ? _c : "anyOf";
|
|
2770
|
+
const options = this.flattenUnionTypes(zodSchema);
|
|
2771
|
+
const schemas = options.map((schema) => {
|
|
2772
|
+
const optionToGenerate = this.unwrapNullable(schema);
|
|
2773
|
+
return mapItem(optionToGenerate);
|
|
2774
|
+
});
|
|
2775
|
+
return { [preferredType]: mapNullableOfArray(schemas) };
|
|
2776
|
+
}
|
|
2777
|
+
flattenUnionTypes(schema) {
|
|
2778
|
+
if (!isZodType(schema, "ZodUnion")) return [schema];
|
|
2779
|
+
const options = schema.def.options;
|
|
2780
|
+
return options.flatMap((option) => isAnyZodType(option) ? this.flattenUnionTypes(option) : []);
|
|
2781
|
+
}
|
|
2782
|
+
unwrapNullable(schema) {
|
|
2783
|
+
if (isZodType(schema, "ZodNullable")) {
|
|
2784
|
+
const unwrapped = schema.unwrap();
|
|
2785
|
+
if (isAnyZodType(unwrapped)) return this.unwrapNullable(unwrapped);
|
|
2786
|
+
}
|
|
2787
|
+
return schema;
|
|
2788
|
+
}
|
|
2789
|
+
};
|
|
2790
|
+
var DateTransformer = class {
|
|
2791
|
+
transform(mapNullableType) {
|
|
2792
|
+
return Object.assign(Object.assign({}, mapNullableType("string")), { format: "date-time" });
|
|
2793
|
+
}
|
|
2794
|
+
};
|
|
2795
|
+
var LazyTransformer = class LazyTransformer {
|
|
2796
|
+
transform(zodSchema, mapItem, mapNullableType, mapNullableRef) {
|
|
2797
|
+
const result = mapItem(zodSchema._zod.def.getter());
|
|
2798
|
+
return LazyTransformer.mapRecursive(result, mapNullableType, mapNullableRef);
|
|
2799
|
+
}
|
|
2800
|
+
static mapRecursive(schema, mapNullableType, mapNullableRef) {
|
|
2801
|
+
if ("$ref" in schema) return mapNullableRef(schema);
|
|
2802
|
+
if (schema.type) return Object.assign(Object.assign({}, schema), mapNullableType(schema.type));
|
|
2803
|
+
return schema;
|
|
2804
|
+
}
|
|
2805
|
+
};
|
|
2806
|
+
var TemplateLiteralTransformer = class {
|
|
2807
|
+
transform(zodSchema, mapNullableType) {
|
|
2808
|
+
const parts = zodSchema.def.parts;
|
|
2809
|
+
const contentPattern = parts.map((part) => this.generatePattern(part)).join("");
|
|
2810
|
+
return Object.assign(Object.assign({}, mapNullableType("string")), { pattern: `^${contentPattern}$` });
|
|
2811
|
+
}
|
|
2812
|
+
generatePattern(part) {
|
|
2813
|
+
if (typeof part === "string" || typeof part === "number" || typeof part === "boolean" || typeof part === "bigint" || part === null || part === void 0) return this.escapeRegex(String(part));
|
|
2814
|
+
if (isZodType(part, "ZodLiteral")) {
|
|
2815
|
+
const value = part.def.values[0];
|
|
2816
|
+
return this.escapeRegex(String(value));
|
|
2817
|
+
}
|
|
2818
|
+
if (isZodType(part, "ZodNumber")) return "[+-]?\\d+(\\.\\d+)?";
|
|
2819
|
+
if (isZodType(part, "ZodBoolean")) return "(true|false)";
|
|
2820
|
+
if (isZodType(part, "ZodEnum")) {
|
|
2821
|
+
const { values } = enumInfo(part.def.entries);
|
|
2822
|
+
return `(${values.map((v) => this.escapeRegex(String(v))).join("|")})`;
|
|
2823
|
+
}
|
|
2824
|
+
return ".*";
|
|
2825
|
+
}
|
|
2826
|
+
escapeRegex(str) {
|
|
2827
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2828
|
+
}
|
|
2829
|
+
};
|
|
2830
|
+
var OpenApiTransformer = class {
|
|
2831
|
+
constructor(versionSpecifics, options) {
|
|
2832
|
+
this.versionSpecifics = versionSpecifics;
|
|
2833
|
+
this.objectTransformer = new ObjectTransformer();
|
|
2834
|
+
this.stringTransformer = new StringTransformer();
|
|
2835
|
+
this.numberTransformer = new NumberTransformer();
|
|
2836
|
+
this.bigIntTransformer = new BigIntTransformer();
|
|
2837
|
+
this.dateTransformer = new DateTransformer();
|
|
2838
|
+
this.lazyTransformer = new LazyTransformer();
|
|
2839
|
+
this.literalTransformer = new LiteralTransformer();
|
|
2840
|
+
this.templateLiteralTransformer = new TemplateLiteralTransformer();
|
|
2841
|
+
this.enumTransformer = new EnumTransformer();
|
|
2842
|
+
this.arrayTransformer = new ArrayTransformer();
|
|
2843
|
+
this.discriminatedUnionTransformer = new DiscriminatedUnionTransformer();
|
|
2844
|
+
this.intersectionTransformer = new IntersectionTransformer();
|
|
2845
|
+
this.recordTransformer = new RecordTransformer();
|
|
2846
|
+
this.tupleTransformer = new TupleTransformer(versionSpecifics);
|
|
2847
|
+
this.unionTransformer = new UnionTransformer(options);
|
|
2848
|
+
}
|
|
2849
|
+
transform(zodSchema, isNullable, mapItem, generateSchemaRef, defaultValue) {
|
|
2850
|
+
if (isZodType(zodSchema, "ZodNull")) return this.versionSpecifics.nullType;
|
|
2851
|
+
if (isZodType(zodSchema, "ZodUnknown") || isZodType(zodSchema, "ZodAny")) return this.versionSpecifics.mapNullableType(void 0, isNullable);
|
|
2852
|
+
if (isZodType(zodSchema, "ZodObject")) return this.objectTransformer.transform(
|
|
2853
|
+
zodSchema,
|
|
2854
|
+
defaultValue,
|
|
2855
|
+
// verified on TS level from input
|
|
2856
|
+
(_) => this.versionSpecifics.mapNullableType(_, isNullable),
|
|
2857
|
+
mapItem
|
|
2858
|
+
);
|
|
2859
|
+
const schema = this.transformSchemaWithoutDefault(zodSchema, isNullable, mapItem, generateSchemaRef);
|
|
2860
|
+
return Object.assign(Object.assign({}, schema), { default: defaultValue });
|
|
2861
|
+
}
|
|
2862
|
+
transformSchemaWithoutDefault(zodSchema, isNullable, mapItem, generateSchemaRef) {
|
|
2863
|
+
if (isZodType(zodSchema, "ZodUnknown") || isZodType(zodSchema, "ZodAny")) return this.versionSpecifics.mapNullableType(void 0, isNullable);
|
|
2864
|
+
if (isZodType(zodSchema, "ZodString")) return this.stringTransformer.transform(zodSchema, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
|
|
2865
|
+
if (isZodType(zodSchema, "ZodNumber")) return this.numberTransformer.transform(zodSchema, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable), (_) => this.versionSpecifics.getNumberChecks(_));
|
|
2866
|
+
if (isZodType(zodSchema, "ZodBigInt")) return this.bigIntTransformer.transform((schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
|
|
2867
|
+
if (isZodType(zodSchema, "ZodBoolean")) return this.versionSpecifics.mapNullableType("boolean", isNullable);
|
|
2868
|
+
if (isZodType(zodSchema, "ZodLazy")) return this.lazyTransformer.transform(zodSchema, mapItem, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable), (schema) => this.versionSpecifics.mapNullableOfRef(schema, isNullable));
|
|
2869
|
+
if (isZodType(zodSchema, "ZodLiteral")) return this.literalTransformer.transform(zodSchema, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
|
|
2870
|
+
if (isZodType(zodSchema, "ZodTemplateLiteral")) return this.templateLiteralTransformer.transform(zodSchema, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
|
|
2871
|
+
if (isZodType(zodSchema, "ZodEnum")) return this.enumTransformer.transform(zodSchema, isNullable, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
|
|
2872
|
+
if (isZodType(zodSchema, "ZodArray")) return this.arrayTransformer.transform(zodSchema, (_) => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);
|
|
2873
|
+
if (isZodType(zodSchema, "ZodTuple")) return this.tupleTransformer.transform(zodSchema, (_) => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);
|
|
2874
|
+
if (isZodType(zodSchema, "ZodDiscriminatedUnion")) return this.discriminatedUnionTransformer.transform(zodSchema, isNullable, (_) => this.versionSpecifics.mapNullableOfArray(_, isNullable), mapItem, generateSchemaRef);
|
|
2875
|
+
if (isZodType(zodSchema, "ZodUnion")) return this.unionTransformer.transform(zodSchema, (_) => this.versionSpecifics.mapNullableOfArray(_, isNullable), mapItem);
|
|
2876
|
+
if (isZodType(zodSchema, "ZodIntersection")) return this.intersectionTransformer.transform(zodSchema, isNullable, (_) => this.versionSpecifics.mapNullableOfArray(_, isNullable), mapItem);
|
|
2877
|
+
if (isZodType(zodSchema, "ZodRecord")) return this.recordTransformer.transform(zodSchema, (_) => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);
|
|
2878
|
+
if (isZodType(zodSchema, "ZodDate")) return this.dateTransformer.transform((_) => this.versionSpecifics.mapNullableType(_, isNullable));
|
|
2879
|
+
const refId = Metadata.getRefId(zodSchema);
|
|
2880
|
+
throw new UnknownZodTypeError({
|
|
2881
|
+
currentSchema: zodSchema.def,
|
|
2882
|
+
schemaName: refId
|
|
2883
|
+
});
|
|
2884
|
+
}
|
|
2885
|
+
};
|
|
2886
|
+
var OpenAPIGenerator = class {
|
|
2887
|
+
constructor(definitions, versionSpecifics, options) {
|
|
2888
|
+
this.definitions = definitions;
|
|
2889
|
+
this.versionSpecifics = versionSpecifics;
|
|
2890
|
+
this.options = options;
|
|
2891
|
+
this.schemaRefs = {};
|
|
2892
|
+
this.paramRefs = {};
|
|
2893
|
+
this.pathRefs = {};
|
|
2894
|
+
this.rawComponents = [];
|
|
2895
|
+
this.openApiTransformer = new OpenApiTransformer(versionSpecifics, options);
|
|
2896
|
+
this.sortDefinitions();
|
|
2897
|
+
}
|
|
2898
|
+
generateDocumentData() {
|
|
2899
|
+
this.definitions.forEach((definition) => this.generateSingle(definition));
|
|
2900
|
+
return {
|
|
2901
|
+
components: this.buildComponents(),
|
|
2902
|
+
paths: this.pathRefs
|
|
2903
|
+
};
|
|
2904
|
+
}
|
|
2905
|
+
generateComponents() {
|
|
2906
|
+
this.definitions.forEach((definition) => this.generateSingle(definition));
|
|
2907
|
+
return { components: this.buildComponents() };
|
|
2908
|
+
}
|
|
2909
|
+
buildComponents() {
|
|
2910
|
+
var _a$1, _b, _c, _d;
|
|
2911
|
+
const rawComponents = {};
|
|
2912
|
+
this.rawComponents.forEach(({ componentType, name, component }) => {
|
|
2913
|
+
var _a$2;
|
|
2914
|
+
(_a$2 = rawComponents[componentType]) !== null && _a$2 !== void 0 || (rawComponents[componentType] = {});
|
|
2915
|
+
rawComponents[componentType][name] = component;
|
|
2916
|
+
});
|
|
2917
|
+
const allSchemas = Object.assign(Object.assign({}, (_a$1 = rawComponents.schemas) !== null && _a$1 !== void 0 ? _a$1 : {}), this.filteredSchemaRefs);
|
|
2918
|
+
const schemas = ((_b = this.options) === null || _b === void 0 ? void 0 : _b.sortComponents) === "alphabetically" ? sortObjectByKeys(allSchemas) : allSchemas;
|
|
2919
|
+
const allParameters = Object.assign(Object.assign({}, (_c = rawComponents.parameters) !== null && _c !== void 0 ? _c : {}), this.paramRefs);
|
|
2920
|
+
const parameters = ((_d = this.options) === null || _d === void 0 ? void 0 : _d.sortComponents) === "alphabetically" ? sortObjectByKeys(allParameters) : allParameters;
|
|
2921
|
+
return Object.assign(Object.assign({}, rawComponents), {
|
|
2922
|
+
schemas,
|
|
2923
|
+
parameters
|
|
2924
|
+
});
|
|
2925
|
+
}
|
|
2926
|
+
isNotPendingRefEntry(entry) {
|
|
2927
|
+
return entry[1] !== "pending";
|
|
2928
|
+
}
|
|
2929
|
+
get filteredSchemaRefs() {
|
|
2930
|
+
const filtered = Object.entries(this.schemaRefs).filter(this.isNotPendingRefEntry);
|
|
2931
|
+
return Object.fromEntries(filtered);
|
|
2932
|
+
}
|
|
2933
|
+
sortDefinitions() {
|
|
2934
|
+
const generationOrder = [
|
|
2935
|
+
"schema",
|
|
2936
|
+
"parameter",
|
|
2937
|
+
"component",
|
|
2938
|
+
"route"
|
|
2939
|
+
];
|
|
2940
|
+
this.definitions.sort((left, right) => {
|
|
2941
|
+
if (!("type" in left)) {
|
|
2942
|
+
if (!("type" in right)) return 0;
|
|
2943
|
+
return -1;
|
|
2944
|
+
}
|
|
2945
|
+
if (!("type" in right)) return 1;
|
|
2946
|
+
const leftIndex = generationOrder.findIndex((type) => type === left.type);
|
|
2947
|
+
const rightIndex = generationOrder.findIndex((type) => type === right.type);
|
|
2948
|
+
return leftIndex - rightIndex;
|
|
2949
|
+
});
|
|
2950
|
+
}
|
|
2951
|
+
generateSingle(definition) {
|
|
2952
|
+
if (!("type" in definition)) {
|
|
2953
|
+
this.generateSchemaWithRef(definition);
|
|
2954
|
+
return;
|
|
2955
|
+
}
|
|
2956
|
+
switch (definition.type) {
|
|
2957
|
+
case "parameter":
|
|
2958
|
+
this.generateParameterDefinition(definition.schema);
|
|
2959
|
+
return;
|
|
2960
|
+
case "schema":
|
|
2961
|
+
this.generateSchemaWithRef(definition.schema);
|
|
2962
|
+
return;
|
|
2963
|
+
case "route":
|
|
2964
|
+
this.generateSingleRoute(definition.route);
|
|
2965
|
+
return;
|
|
2966
|
+
case "component":
|
|
2967
|
+
this.rawComponents.push(definition);
|
|
2968
|
+
return;
|
|
2969
|
+
}
|
|
2970
|
+
}
|
|
2971
|
+
generateParameterDefinition(zodSchema) {
|
|
2972
|
+
const refId = Metadata.getRefId(zodSchema);
|
|
2973
|
+
const result = this.generateParameter(zodSchema);
|
|
2974
|
+
if (refId) this.paramRefs[refId] = result;
|
|
2975
|
+
return result;
|
|
2976
|
+
}
|
|
2977
|
+
getParameterRef(schema, external) {
|
|
2978
|
+
const metadata = Metadata.getOpenApiMetadata(schema);
|
|
2979
|
+
const internalMetadata = Metadata.getInternalMetadata(schema);
|
|
2980
|
+
const parameterMetadata = metadata === null || metadata === void 0 ? void 0 : metadata.param;
|
|
2981
|
+
const existingRef = (internalMetadata === null || internalMetadata === void 0 ? void 0 : internalMetadata.refId) ? this.paramRefs[internalMetadata.refId] : void 0;
|
|
2982
|
+
if (!(internalMetadata === null || internalMetadata === void 0 ? void 0 : internalMetadata.refId) || !existingRef) return void 0;
|
|
2983
|
+
if (parameterMetadata && existingRef.in !== parameterMetadata.in || (external === null || external === void 0 ? void 0 : external.in) && existingRef.in !== external.in) throw new ConflictError(`Conflicting location for parameter ${existingRef.name}`, {
|
|
2984
|
+
key: "in",
|
|
2985
|
+
values: compact([
|
|
2986
|
+
existingRef.in,
|
|
2987
|
+
external === null || external === void 0 ? void 0 : external.in,
|
|
2988
|
+
parameterMetadata === null || parameterMetadata === void 0 ? void 0 : parameterMetadata.in
|
|
2989
|
+
])
|
|
2990
|
+
});
|
|
2991
|
+
if (parameterMetadata && existingRef.name !== parameterMetadata.name || (external === null || external === void 0 ? void 0 : external.name) && existingRef.name !== (external === null || external === void 0 ? void 0 : external.name)) throw new ConflictError(`Conflicting names for parameter`, {
|
|
2992
|
+
key: "name",
|
|
2993
|
+
values: compact([
|
|
2994
|
+
existingRef.name,
|
|
2995
|
+
external === null || external === void 0 ? void 0 : external.name,
|
|
2996
|
+
parameterMetadata === null || parameterMetadata === void 0 ? void 0 : parameterMetadata.name
|
|
2997
|
+
])
|
|
2998
|
+
});
|
|
2999
|
+
return { $ref: `#/components/parameters/${internalMetadata.refId}` };
|
|
3000
|
+
}
|
|
3001
|
+
generateInlineParameters(zodSchema, location) {
|
|
3002
|
+
const metadata = Metadata.getOpenApiMetadata(zodSchema);
|
|
3003
|
+
const parameterMetadata = metadata === null || metadata === void 0 ? void 0 : metadata.param;
|
|
3004
|
+
const referencedSchema = this.getParameterRef(zodSchema, { in: location });
|
|
3005
|
+
if (referencedSchema) return [referencedSchema];
|
|
3006
|
+
if (isZodType(zodSchema, "ZodObject")) {
|
|
3007
|
+
const propTypes = zodSchema.def.shape;
|
|
3008
|
+
const parameters = Object.entries(propTypes).map(([key, schema]) => {
|
|
3009
|
+
var _a$1;
|
|
3010
|
+
const innerMetadata = Metadata.getOpenApiMetadata(schema);
|
|
3011
|
+
const referencedSchema$1 = this.getParameterRef(schema, {
|
|
3012
|
+
in: location,
|
|
3013
|
+
name: key
|
|
3014
|
+
});
|
|
3015
|
+
if (referencedSchema$1) return referencedSchema$1;
|
|
3016
|
+
const innerParameterMetadata = innerMetadata === null || innerMetadata === void 0 ? void 0 : innerMetadata.param;
|
|
3017
|
+
if ((innerParameterMetadata === null || innerParameterMetadata === void 0 ? void 0 : innerParameterMetadata.name) && innerParameterMetadata.name !== key) throw new ConflictError(`Conflicting names for parameter`, {
|
|
3018
|
+
key: "name",
|
|
3019
|
+
values: [key, innerParameterMetadata.name]
|
|
3020
|
+
});
|
|
3021
|
+
if ((innerParameterMetadata === null || innerParameterMetadata === void 0 ? void 0 : innerParameterMetadata.in) && innerParameterMetadata.in !== location) throw new ConflictError(`Conflicting location for parameter ${(_a$1 = innerParameterMetadata.name) !== null && _a$1 !== void 0 ? _a$1 : key}`, {
|
|
3022
|
+
key: "in",
|
|
3023
|
+
values: [location, innerParameterMetadata.in]
|
|
3024
|
+
});
|
|
3025
|
+
return this.generateParameter(schema.openapi({ param: {
|
|
3026
|
+
name: key,
|
|
3027
|
+
in: location
|
|
3028
|
+
} }));
|
|
3029
|
+
});
|
|
3030
|
+
return parameters;
|
|
3031
|
+
}
|
|
3032
|
+
if ((parameterMetadata === null || parameterMetadata === void 0 ? void 0 : parameterMetadata.in) && parameterMetadata.in !== location) throw new ConflictError(`Conflicting location for parameter ${parameterMetadata.name}`, {
|
|
3033
|
+
key: "in",
|
|
3034
|
+
values: [location, parameterMetadata.in]
|
|
3035
|
+
});
|
|
3036
|
+
return [this.generateParameter(zodSchema.openapi({ param: { in: location } }))];
|
|
3037
|
+
}
|
|
3038
|
+
generateSimpleParameter(zodSchema) {
|
|
3039
|
+
const metadata = Metadata.getParamMetadata(zodSchema);
|
|
3040
|
+
const paramMetadata = metadata === null || metadata === void 0 ? void 0 : metadata.param;
|
|
3041
|
+
const required = !isOptionalSchema(zodSchema) && !isNullableSchema(zodSchema);
|
|
3042
|
+
const schema = this.generateSchemaWithRef(zodSchema);
|
|
3043
|
+
return Object.assign({
|
|
3044
|
+
schema,
|
|
3045
|
+
required
|
|
3046
|
+
}, paramMetadata ? Metadata.buildParameterMetadata(paramMetadata) : {});
|
|
3047
|
+
}
|
|
3048
|
+
generateParameter(zodSchema) {
|
|
3049
|
+
const metadata = Metadata.getOpenApiMetadata(zodSchema);
|
|
3050
|
+
const paramMetadata = metadata === null || metadata === void 0 ? void 0 : metadata.param;
|
|
3051
|
+
const paramName = paramMetadata === null || paramMetadata === void 0 ? void 0 : paramMetadata.name;
|
|
3052
|
+
const paramLocation = paramMetadata === null || paramMetadata === void 0 ? void 0 : paramMetadata.in;
|
|
3053
|
+
if (!paramName) throw new MissingParameterDataError({ missingField: "name" });
|
|
3054
|
+
if (!paramLocation) throw new MissingParameterDataError({
|
|
3055
|
+
missingField: "in",
|
|
3056
|
+
paramName
|
|
3057
|
+
});
|
|
3058
|
+
const baseParameter = this.generateSimpleParameter(zodSchema);
|
|
3059
|
+
return Object.assign(Object.assign({}, baseParameter), {
|
|
3060
|
+
in: paramLocation,
|
|
3061
|
+
name: paramName
|
|
3062
|
+
});
|
|
3063
|
+
}
|
|
3064
|
+
generateSchemaWithMetadata(zodSchema) {
|
|
3065
|
+
const innerSchema = Metadata.unwrapChained(zodSchema);
|
|
3066
|
+
const metadata = Metadata.getOpenApiMetadata(zodSchema);
|
|
3067
|
+
const defaultValue = Metadata.getDefaultValue(zodSchema);
|
|
3068
|
+
const refId = Metadata.getRefId(zodSchema);
|
|
3069
|
+
if (refId && typeof this.schemaRefs[refId] === "object") return this.schemaRefs[refId];
|
|
3070
|
+
if (refId && this.schemaRefs[refId] === "pending") {
|
|
3071
|
+
const refSchema = { $ref: this.generateSchemaRef(refId) };
|
|
3072
|
+
return this.versionSpecifics.mapNullableOfRef(refSchema, isNullableSchema(zodSchema));
|
|
3073
|
+
}
|
|
3074
|
+
if (refId && !this.schemaRefs[refId]) this.schemaRefs[refId] = "pending";
|
|
3075
|
+
const result = (metadata === null || metadata === void 0 ? void 0 : metadata.type) ? { type: metadata.type } : this.toOpenAPISchema(innerSchema, isNullableSchema(zodSchema), defaultValue);
|
|
3076
|
+
return metadata ? Metadata.applySchemaMetadata(result, metadata) : omitBy(result, isUndefined);
|
|
3077
|
+
}
|
|
3078
|
+
/**
|
|
3079
|
+
* Same as above but applies nullable
|
|
3080
|
+
*/
|
|
3081
|
+
constructReferencedOpenAPISchema(zodSchema) {
|
|
3082
|
+
const metadata = Metadata.getOpenApiMetadata(zodSchema);
|
|
3083
|
+
const innerSchema = Metadata.unwrapChained(zodSchema);
|
|
3084
|
+
const defaultValue = Metadata.getDefaultValue(zodSchema);
|
|
3085
|
+
const isNullable = isNullableSchema(zodSchema);
|
|
3086
|
+
if (metadata === null || metadata === void 0 ? void 0 : metadata.type) return this.versionSpecifics.mapNullableType(metadata.type, isNullable);
|
|
3087
|
+
const refId = Metadata.getRefId(zodSchema);
|
|
3088
|
+
if (refId && typeof this.schemaRefs[refId] === "object") return LazyTransformer.mapRecursive(this.schemaRefs[refId], (schema) => this.versionSpecifics.mapNullableType(schema, isNullable), (schema) => this.versionSpecifics.mapNullableOfRef(schema, isNullable));
|
|
3089
|
+
if (refId && this.schemaRefs[refId] === "pending") {
|
|
3090
|
+
const refSchema = { $ref: this.generateSchemaRef(refId) };
|
|
3091
|
+
return this.versionSpecifics.mapNullableOfRef(refSchema, isNullable);
|
|
3092
|
+
}
|
|
3093
|
+
if (refId && !this.schemaRefs[refId]) this.schemaRefs[refId] = "pending";
|
|
3094
|
+
return this.toOpenAPISchema(innerSchema, isNullable, defaultValue);
|
|
3095
|
+
}
|
|
3096
|
+
/**
|
|
3097
|
+
* Generates an OpenAPI SchemaObject or a ReferenceObject with all the provided metadata applied
|
|
3098
|
+
*/
|
|
3099
|
+
generateSimpleSchema(zodSchema) {
|
|
3100
|
+
const metadata = Metadata.getOpenApiMetadata(zodSchema);
|
|
3101
|
+
const refId = Metadata.getRefId(zodSchema);
|
|
3102
|
+
if (!refId || !this.schemaRefs[refId]) return this.generateSchemaWithMetadata(zodSchema);
|
|
3103
|
+
const schemaRef = this.schemaRefs[refId];
|
|
3104
|
+
const referenceObject = { $ref: this.generateSchemaRef(refId) };
|
|
3105
|
+
if (this.schemaRefs[refId] === "pending") return this.versionSpecifics.mapNullableOfRef(referenceObject, isNullableSchema(zodSchema));
|
|
3106
|
+
const newMetadata = omitBy(Metadata.buildSchemaMetadata(metadata !== null && metadata !== void 0 ? metadata : {}), (value, key) => value === void 0 || objectEquals(value, schemaRef[key]));
|
|
3107
|
+
if (newMetadata.type) return { allOf: [referenceObject, newMetadata] };
|
|
3108
|
+
const newSchemaMetadata = omitBy(this.constructReferencedOpenAPISchema(zodSchema), (value, key) => value === void 0 || objectEquals(value, schemaRef[key]));
|
|
3109
|
+
const appliedMetadata = Metadata.applySchemaMetadata(newSchemaMetadata, newMetadata);
|
|
3110
|
+
if (Object.keys(appliedMetadata).length > 0) return { allOf: [referenceObject, appliedMetadata] };
|
|
3111
|
+
return referenceObject;
|
|
3112
|
+
}
|
|
3113
|
+
/**
|
|
3114
|
+
* Same as `generateSchema` but if the new schema is added into the
|
|
3115
|
+
* referenced schemas, it would return a ReferenceObject and not the
|
|
3116
|
+
* whole result.
|
|
3117
|
+
*
|
|
3118
|
+
* Should be used for nested objects, arrays, etc.
|
|
3119
|
+
*/
|
|
3120
|
+
generateSchemaWithRef(zodSchema) {
|
|
3121
|
+
const refId = Metadata.getRefId(zodSchema);
|
|
3122
|
+
if (refId && !this.schemaRefs[refId]) {
|
|
3123
|
+
this.schemaRefs[refId] = this.generateSimpleSchema(zodSchema);
|
|
3124
|
+
return { $ref: this.generateSchemaRef(refId) };
|
|
3125
|
+
}
|
|
3126
|
+
return this.generateSimpleSchema(zodSchema);
|
|
3127
|
+
}
|
|
3128
|
+
generateSchemaRef(refId) {
|
|
3129
|
+
return `#/components/schemas/${refId}`;
|
|
3130
|
+
}
|
|
3131
|
+
getRequestBody(requestBody) {
|
|
3132
|
+
if (!requestBody) return;
|
|
3133
|
+
const { content } = requestBody, rest = __rest(requestBody, ["content"]);
|
|
3134
|
+
const requestBodyContent = this.getBodyContent(content);
|
|
3135
|
+
return Object.assign(Object.assign({}, rest), { content: requestBodyContent });
|
|
3136
|
+
}
|
|
3137
|
+
getParameters(request) {
|
|
3138
|
+
if (!request) return [];
|
|
3139
|
+
const { headers } = request;
|
|
3140
|
+
const query = this.cleanParameter(request.query);
|
|
3141
|
+
const params = this.cleanParameter(request.params);
|
|
3142
|
+
const cookies = this.cleanParameter(request.cookies);
|
|
3143
|
+
const queryParameters = enhanceMissingParametersError(() => query ? this.generateInlineParameters(query, "query") : [], { location: "query" });
|
|
3144
|
+
const pathParameters = enhanceMissingParametersError(() => params ? this.generateInlineParameters(params, "path") : [], { location: "path" });
|
|
3145
|
+
const cookieParameters = enhanceMissingParametersError(() => cookies ? this.generateInlineParameters(cookies, "cookie") : [], { location: "cookie" });
|
|
3146
|
+
const headerParameters = enhanceMissingParametersError(() => {
|
|
3147
|
+
if (Array.isArray(headers)) return headers.flatMap((header) => this.generateInlineParameters(header, "header"));
|
|
3148
|
+
const cleanHeaders = this.cleanParameter(headers);
|
|
3149
|
+
return cleanHeaders ? this.generateInlineParameters(cleanHeaders, "header") : [];
|
|
3150
|
+
}, { location: "header" });
|
|
3151
|
+
return [
|
|
3152
|
+
...pathParameters,
|
|
3153
|
+
...queryParameters,
|
|
3154
|
+
...headerParameters,
|
|
3155
|
+
...cookieParameters
|
|
3156
|
+
];
|
|
3157
|
+
}
|
|
3158
|
+
cleanParameter(schema) {
|
|
3159
|
+
if (!schema) return void 0;
|
|
3160
|
+
if (isZodType(schema, "ZodPipe")) {
|
|
3161
|
+
const inSchema = schema._zod.def.in;
|
|
3162
|
+
const outSchema = schema._zod.def.out;
|
|
3163
|
+
if (isZodType(inSchema, "ZodObject")) return this.cleanParameter(inSchema);
|
|
3164
|
+
if (isZodType(outSchema, "ZodObject")) return this.cleanParameter(outSchema);
|
|
3165
|
+
return void 0;
|
|
3166
|
+
}
|
|
3167
|
+
return schema;
|
|
3168
|
+
}
|
|
3169
|
+
generatePath(route) {
|
|
3170
|
+
const { method, path, request, responses } = route, pathItemConfig = __rest(route, [
|
|
3171
|
+
"method",
|
|
3172
|
+
"path",
|
|
3173
|
+
"request",
|
|
3174
|
+
"responses"
|
|
3175
|
+
]);
|
|
3176
|
+
const generatedResponses = mapValues(responses, (response) => {
|
|
3177
|
+
return this.getResponse(response);
|
|
3178
|
+
});
|
|
3179
|
+
const parameters = enhanceMissingParametersError(() => this.getParameters(request), { route: `${method} ${path}` });
|
|
3180
|
+
const requestBody = this.getRequestBody(request === null || request === void 0 ? void 0 : request.body);
|
|
3181
|
+
const routeDoc = { [method]: Object.assign(Object.assign(Object.assign(Object.assign({}, pathItemConfig), parameters.length > 0 ? { parameters: [...pathItemConfig.parameters || [], ...parameters] } : {}), requestBody ? { requestBody } : {}), { responses: generatedResponses }) };
|
|
3182
|
+
return routeDoc;
|
|
3183
|
+
}
|
|
3184
|
+
generateSingleRoute(route) {
|
|
3185
|
+
const routeDoc = this.generatePath(route);
|
|
3186
|
+
this.pathRefs[route.path] = Object.assign(Object.assign({}, this.pathRefs[route.path]), routeDoc);
|
|
3187
|
+
return routeDoc;
|
|
3188
|
+
}
|
|
3189
|
+
getResponse(response) {
|
|
3190
|
+
if (this.isReferenceObject(response)) return response;
|
|
3191
|
+
const { content, headers } = response, rest = __rest(response, ["content", "headers"]);
|
|
3192
|
+
const responseContent = content ? { content: this.getBodyContent(content) } : {};
|
|
3193
|
+
if (!headers) return Object.assign(Object.assign({}, rest), responseContent);
|
|
3194
|
+
const responseHeaders = isZodType(headers, "ZodObject") ? this.getResponseHeaders(headers) : headers;
|
|
3195
|
+
return Object.assign(Object.assign(Object.assign({}, rest), { headers: responseHeaders }), responseContent);
|
|
3196
|
+
}
|
|
3197
|
+
isReferenceObject(schema) {
|
|
3198
|
+
return "$ref" in schema;
|
|
3199
|
+
}
|
|
3200
|
+
getResponseHeaders(headers) {
|
|
3201
|
+
const schemaShape = headers.def.shape;
|
|
3202
|
+
const responseHeaders = mapValues(schemaShape, (_) => this.generateSimpleParameter(_));
|
|
3203
|
+
return responseHeaders;
|
|
3204
|
+
}
|
|
3205
|
+
getBodyContent(content) {
|
|
3206
|
+
return mapValues(content, (config) => {
|
|
3207
|
+
if (!config || !isAnyZodType(config.schema)) return config;
|
|
3208
|
+
const { schema: configSchema } = config, rest = __rest(config, ["schema"]);
|
|
3209
|
+
const schema = this.generateSchemaWithRef(configSchema);
|
|
3210
|
+
return Object.assign({ schema }, rest);
|
|
3211
|
+
});
|
|
3212
|
+
}
|
|
3213
|
+
toOpenAPISchema(zodSchema, isNullable, defaultValue) {
|
|
3214
|
+
const result = this.openApiTransformer.transform(zodSchema, isNullable, (_) => this.generateSchemaWithRef(_), (_) => this.generateSchemaRef(_), defaultValue);
|
|
3215
|
+
return result;
|
|
3216
|
+
}
|
|
3217
|
+
};
|
|
3218
|
+
var OpenApiGeneratorV30Specifics = class {
|
|
3219
|
+
get nullType() {
|
|
3220
|
+
return { nullable: true };
|
|
3221
|
+
}
|
|
3222
|
+
mapNullableOfArray(objects, isNullable) {
|
|
3223
|
+
if (isNullable && !objects.some((object) => objectEquals(object, this.nullType))) return [...objects, this.nullType];
|
|
3224
|
+
return objects;
|
|
3225
|
+
}
|
|
3226
|
+
mapNullableType(type, isNullable) {
|
|
3227
|
+
return Object.assign(Object.assign({}, type ? { type } : void 0), isNullable ? this.nullType : void 0);
|
|
3228
|
+
}
|
|
3229
|
+
mapNullableOfRef(ref, isNullable) {
|
|
3230
|
+
if (isNullable) return { allOf: [ref, this.nullType] };
|
|
3231
|
+
return ref;
|
|
3232
|
+
}
|
|
3233
|
+
mapTupleItems(schemas) {
|
|
3234
|
+
const uniqueSchemas = uniq(schemas);
|
|
3235
|
+
return {
|
|
3236
|
+
items: uniqueSchemas.length === 1 ? uniqueSchemas[0] : { anyOf: uniqueSchemas },
|
|
3237
|
+
minItems: schemas.length,
|
|
3238
|
+
maxItems: schemas.length
|
|
3239
|
+
};
|
|
3240
|
+
}
|
|
3241
|
+
getNumberChecks(checks) {
|
|
3242
|
+
return Object.assign({}, ...checks.map((check) => {
|
|
3243
|
+
switch (check._zod.def.check) {
|
|
3244
|
+
case "greater_than": {
|
|
3245
|
+
const greaterThanCheck = check;
|
|
3246
|
+
return greaterThanCheck._zod.def.inclusive ? { minimum: Number(greaterThanCheck._zod.def.value) } : {
|
|
3247
|
+
minimum: Number(greaterThanCheck._zod.def.value),
|
|
3248
|
+
exclusiveMinimum: true
|
|
3249
|
+
};
|
|
3250
|
+
}
|
|
3251
|
+
case "less_than": {
|
|
3252
|
+
const lessThanCheck = check;
|
|
3253
|
+
return lessThanCheck._zod.def.inclusive ? { maximum: Number(lessThanCheck._zod.def.value) } : {
|
|
3254
|
+
maximum: Number(lessThanCheck._zod.def.value),
|
|
3255
|
+
exclusiveMaximum: !lessThanCheck._zod.def.inclusive
|
|
3256
|
+
};
|
|
3257
|
+
}
|
|
3258
|
+
default: return {};
|
|
3259
|
+
}
|
|
3260
|
+
}));
|
|
3261
|
+
}
|
|
3262
|
+
};
|
|
3263
|
+
var OpenApiGeneratorV3 = class {
|
|
3264
|
+
constructor(definitions, options) {
|
|
3265
|
+
const specifics = new OpenApiGeneratorV30Specifics();
|
|
3266
|
+
this.generator = new OpenAPIGenerator(definitions, specifics, options);
|
|
3267
|
+
}
|
|
3268
|
+
generateDocument(config) {
|
|
3269
|
+
const baseData = this.generator.generateDocumentData();
|
|
3270
|
+
return Object.assign(Object.assign({}, config), baseData);
|
|
3271
|
+
}
|
|
3272
|
+
generateComponents() {
|
|
3273
|
+
return this.generator.generateComponents();
|
|
3274
|
+
}
|
|
3275
|
+
};
|
|
3276
|
+
var OpenApiGeneratorV31Specifics = class {
|
|
3277
|
+
get nullType() {
|
|
3278
|
+
return { type: "null" };
|
|
3279
|
+
}
|
|
3280
|
+
mapNullableOfArray(objects, isNullable) {
|
|
3281
|
+
if (isNullable && !objects.some((object) => objectEquals(object, this.nullType))) return [...objects, this.nullType];
|
|
3282
|
+
return objects;
|
|
3283
|
+
}
|
|
3284
|
+
mapNullableType(type, isNullable) {
|
|
3285
|
+
if (!type) return {};
|
|
3286
|
+
if (isNullable) {
|
|
3287
|
+
const typeArray = Array.isArray(type) ? type : [type];
|
|
3288
|
+
const nullableType = uniq([...typeArray, "null"]);
|
|
3289
|
+
return { type: nullableType };
|
|
3290
|
+
}
|
|
3291
|
+
return { type };
|
|
3292
|
+
}
|
|
3293
|
+
mapNullableOfRef(ref, isNullable) {
|
|
3294
|
+
if (isNullable) return { oneOf: [ref, this.nullType] };
|
|
3295
|
+
return ref;
|
|
3296
|
+
}
|
|
3297
|
+
mapTupleItems(schemas) {
|
|
3298
|
+
return { prefixItems: schemas };
|
|
3299
|
+
}
|
|
3300
|
+
getNumberChecks(checks) {
|
|
3301
|
+
return Object.assign({}, ...checks.map((check) => {
|
|
3302
|
+
switch (check._zod.def.check) {
|
|
3303
|
+
case "greater_than": {
|
|
3304
|
+
const greaterThanCheck = check;
|
|
3305
|
+
return greaterThanCheck._zod.def.inclusive ? { minimum: Number(greaterThanCheck._zod.def.value) } : { exclusiveMinimum: Number(greaterThanCheck._zod.def.value) };
|
|
3306
|
+
}
|
|
3307
|
+
case "less_than": {
|
|
3308
|
+
const lessThanCheck = check;
|
|
3309
|
+
return lessThanCheck._zod.def.inclusive ? { maximum: Number(lessThanCheck._zod.def.value) } : { exclusiveMaximum: Number(lessThanCheck._zod.def.value) };
|
|
3310
|
+
}
|
|
3311
|
+
default: return {};
|
|
3312
|
+
}
|
|
3313
|
+
}));
|
|
3314
|
+
}
|
|
3315
|
+
};
|
|
3316
|
+
function isWebhookDefinition(definition) {
|
|
3317
|
+
return "type" in definition && definition.type === "webhook";
|
|
3318
|
+
}
|
|
3319
|
+
var OpenApiGeneratorV31 = class {
|
|
3320
|
+
constructor(definitions, options) {
|
|
3321
|
+
this.definitions = definitions;
|
|
3322
|
+
this.webhookRefs = {};
|
|
3323
|
+
const specifics = new OpenApiGeneratorV31Specifics();
|
|
3324
|
+
this.generator = new OpenAPIGenerator(this.definitions, specifics, options);
|
|
3325
|
+
}
|
|
3326
|
+
generateDocument(config) {
|
|
3327
|
+
const baseDocument = this.generator.generateDocumentData();
|
|
3328
|
+
this.definitions.filter(isWebhookDefinition).forEach((definition) => this.generateSingleWebhook(definition.webhook));
|
|
3329
|
+
return Object.assign(Object.assign(Object.assign({}, config), baseDocument), { webhooks: this.webhookRefs });
|
|
3330
|
+
}
|
|
3331
|
+
generateComponents() {
|
|
3332
|
+
return this.generator.generateComponents();
|
|
3333
|
+
}
|
|
3334
|
+
generateSingleWebhook(route) {
|
|
3335
|
+
const routeDoc = this.generator.generatePath(route);
|
|
3336
|
+
this.webhookRefs[route.path] = Object.assign(Object.assign({}, this.webhookRefs[route.path]), routeDoc);
|
|
3337
|
+
return routeDoc;
|
|
3338
|
+
}
|
|
3339
|
+
};
|
|
3340
|
+
exports.OpenAPIRegistry = OpenAPIRegistry;
|
|
3341
|
+
exports.OpenApiGeneratorV3 = OpenApiGeneratorV3;
|
|
3342
|
+
exports.OpenApiGeneratorV31 = OpenApiGeneratorV31;
|
|
3343
|
+
exports.extendZodWithOpenApi = extendZodWithOpenApi;
|
|
3344
|
+
exports.getOpenApiMetadata = getOpenApiMetadata;
|
|
3345
|
+
exports.getRefId = getRefId;
|
|
3346
|
+
exports.zodToOpenAPIRegistry = zodToOpenAPIRegistry;
|
|
3347
|
+
} });
|
|
3348
|
+
var import_dist = __toESM(require_dist(), 1);
|
|
3349
|
+
|
|
3350
|
+
//#endregion
|
|
3351
|
+
//#region ../shared/dist/schemas/zod.js
|
|
3352
|
+
(0, import_dist.extendZodWithOpenApi)(z$1);
|
|
3353
|
+
|
|
3354
|
+
//#endregion
|
|
3355
|
+
//#region ../shared/dist/schemas/options/page-elements.js
|
|
3356
|
+
const pageElementConfigSchema = z$1.object({
|
|
3357
|
+
position: z$1.enum(["header", "footer"]).openapi({
|
|
3358
|
+
description: "Position of the element (header or footer)",
|
|
3359
|
+
example: "footer"
|
|
3360
|
+
}),
|
|
3361
|
+
alignment: z$1.enum([
|
|
3362
|
+
"left",
|
|
3363
|
+
"center",
|
|
3364
|
+
"right"
|
|
3365
|
+
]).openapi({
|
|
3366
|
+
description: "Text alignment within the header/footer",
|
|
3367
|
+
example: "center"
|
|
3368
|
+
}),
|
|
3369
|
+
fontSize: z$1.number().min(6).max(36).optional().openapi({
|
|
3370
|
+
description: "Font size in pixels (6-36)",
|
|
3371
|
+
example: 10
|
|
3372
|
+
}),
|
|
3373
|
+
fontFamily: z$1.string().optional().openapi({
|
|
3374
|
+
description: "Font family name",
|
|
3375
|
+
example: "Arial"
|
|
3376
|
+
}),
|
|
3377
|
+
fontColor: z$1.string().regex(/^#[0-9A-Fa-f]{6}$/).optional().openapi({
|
|
3378
|
+
description: "Text color as hex code",
|
|
3379
|
+
example: "#000000"
|
|
3380
|
+
})
|
|
3381
|
+
}).openapi("PageElementConfig");
|
|
3382
|
+
const titleConfigSchema = pageElementConfigSchema.extend({ value: z$1.string().optional().openapi({
|
|
3383
|
+
description: "Custom title text to display",
|
|
3384
|
+
example: "My Document"
|
|
3385
|
+
}) }).openapi("TitleConfig");
|
|
3386
|
+
const dateConfigSchema = pageElementConfigSchema.extend({ value: z$1.string().optional().openapi({
|
|
3387
|
+
description: "Custom date string to display (e.g. '2024-01-15' or 'January 15, 2024')",
|
|
3388
|
+
example: "2024-01-15"
|
|
3389
|
+
}) }).openapi("DateConfig");
|
|
3390
|
+
const pageNumberConfigSchema = pageElementConfigSchema.extend({ includeTotal: z$1.boolean().optional().openapi({
|
|
3391
|
+
description: "Include total page count (shows X / Y format)",
|
|
3392
|
+
example: false
|
|
3393
|
+
}) }).openapi("PageNumberConfig");
|
|
3394
|
+
const pageElementsSchema = z$1.object({
|
|
3395
|
+
date: dateConfigSchema.optional().openapi({ description: "Display a date. If value is not provided, uses the document generation date." }),
|
|
3396
|
+
title: titleConfigSchema.optional().openapi({ description: "Display a title. If value is not provided, uses the document title." }),
|
|
3397
|
+
pageNumber: pageNumberConfigSchema.optional().openapi({ description: "Display the current page number. Enable includeTotal for X / Y format." })
|
|
3398
|
+
}).openapi("PageElements");
|
|
3399
|
+
|
|
3400
|
+
//#endregion
|
|
3401
|
+
//#region ../shared/dist/schemas/options/pdf-formatting.js
|
|
3402
|
+
const pdfFormattingOptionsSchema = z$1.object({
|
|
3403
|
+
paperWidth: z$1.string().optional().openapi({ description: "Paper width (e.g., '8.5in', '210mm')" }),
|
|
3404
|
+
paperHeight: z$1.string().optional().openapi({ description: "Paper height (e.g., '11in', '297mm')" }),
|
|
3405
|
+
marginTop: z$1.string().optional().openapi({ description: "Top margin" }),
|
|
3406
|
+
marginBottom: z$1.string().optional().openapi({ description: "Bottom margin" }),
|
|
3407
|
+
marginLeft: z$1.string().optional().openapi({ description: "Left margin" }),
|
|
3408
|
+
marginRight: z$1.string().optional().openapi({ description: "Right margin" }),
|
|
3409
|
+
landscape: z$1.boolean().optional().openapi({ description: "Landscape orientation" }),
|
|
3410
|
+
scale: z$1.number().min(.1).max(2).optional().openapi({ description: "Page scale (0.1-2.0)" }),
|
|
3411
|
+
singlePage: z$1.boolean().optional().openapi({ description: "Print entire content on one page" }),
|
|
3412
|
+
preferCssPageSize: z$1.boolean().optional().openapi({ description: "Prefer CSS-defined page dimensions" }),
|
|
3413
|
+
generateDocumentOutline: z$1.boolean().optional().openapi({ description: "Embed document outline in PDF" }),
|
|
3414
|
+
generateTaggedPdf: z$1.boolean().optional().openapi({ description: "Generate accessible/tagged PDF" }),
|
|
3415
|
+
printBackground: z$1.boolean().optional().openapi({ description: "Include background graphics" }),
|
|
3416
|
+
omitBackground: z$1.boolean().optional().openapi({ description: "Transparent background (no white default)" }),
|
|
3417
|
+
nativePageRanges: z$1.string().optional().openapi({ description: "Pages to print (e.g., '1-5, 8, 11-13')" }),
|
|
3418
|
+
pageElements: pageElementsSchema.optional().openapi({ description: "Configure header/footer elements (date, title, page numbers)" })
|
|
3419
|
+
});
|
|
3420
|
+
|
|
3421
|
+
//#endregion
|
|
3422
|
+
//#region ../shared/dist/schemas/options/compress-pdf.js
|
|
3423
|
+
const compressPdfOptionsSchema = z$1.object({
|
|
3424
|
+
losslessImageCompression: z$1.boolean().optional().openapi({ description: "Use lossless compression (PNG) instead of lossy (JPEG)" }),
|
|
3425
|
+
quality: z$1.number().min(1).max(100).optional().openapi({ description: "JPEG compression quality (1-100)" }),
|
|
3426
|
+
reduceImageResolution: z$1.boolean().optional().openapi({ description: "Enable DPI reduction" }),
|
|
3427
|
+
maxImageResolution: z$1.enum([
|
|
3428
|
+
"75",
|
|
3429
|
+
"150",
|
|
3430
|
+
"300",
|
|
3431
|
+
"600",
|
|
3432
|
+
"1200"
|
|
3433
|
+
]).optional().openapi({ description: "Maximum image resolution in DPI" })
|
|
3434
|
+
}).openapi("CompressPdfOptions");
|
|
3435
|
+
|
|
3436
|
+
//#endregion
|
|
3437
|
+
//#region ../shared/dist/schemas/options/office-to-pdf.js
|
|
3438
|
+
const officeToPdfOptionsSchema = z$1.object({ landscape: z$1.boolean().optional().openapi({ description: "Landscape orientation" }) }).openapi("OfficeToPdfOptions");
|
|
3439
|
+
|
|
3440
|
+
//#endregion
|
|
3441
|
+
//#region ../shared/dist/schemas/options/merge-pdf.js
|
|
3442
|
+
const mergePdfOptionsSchema = z$1.object({}).openapi("MergePdfOptions");
|
|
3443
|
+
|
|
3444
|
+
//#endregion
|
|
3445
|
+
//#region ../shared/dist/schemas/requests/html-to-pdf.js
|
|
3446
|
+
const htmlToPdfRequestSchema = z$1.object({
|
|
3447
|
+
html: z$1.string().min(1).openapi({
|
|
3448
|
+
description: "HTML content to convert to PDF",
|
|
3449
|
+
example: "<html><body><h1>Hello World</h1></body></html>"
|
|
3450
|
+
}),
|
|
3451
|
+
...pdfFormattingOptionsSchema.shape
|
|
3452
|
+
}).openapi("HtmlToPdfRequest");
|
|
3453
|
+
|
|
3454
|
+
//#endregion
|
|
3455
|
+
//#region ../shared/dist/schemas/requests/url-to-pdf.js
|
|
3456
|
+
const urlToPdfRequestSchema = z$1.object({
|
|
3457
|
+
url: z$1.string().url().openapi({
|
|
3458
|
+
description: "URL to convert to PDF",
|
|
3459
|
+
example: "https://example.com"
|
|
3460
|
+
}),
|
|
3461
|
+
...pdfFormattingOptionsSchema.shape
|
|
3462
|
+
}).openapi("UrlToPdfRequest");
|
|
3463
|
+
|
|
3464
|
+
//#endregion
|
|
3465
|
+
//#region ../shared/dist/schemas/error.js
|
|
3466
|
+
const errorResponseSchema = z$1.object({
|
|
3467
|
+
error: z$1.string().openapi({ description: "Error message" }),
|
|
3468
|
+
details: z$1.string().optional().openapi({ description: "Error details" })
|
|
3469
|
+
}).openapi("ErrorResponse");
|
|
3470
|
+
|
|
30
3471
|
//#endregion
|
|
31
3472
|
//#region src/utils/encoding.ts
|
|
32
3473
|
async function blobToBase64(blob) {
|