@spscommerce/asst-api 5.3.0 → 5.3.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.cjs CHANGED
@@ -1,9 +1,7 @@
1
1
  "use strict";
2
- var __create = Object.create;
3
2
  var __defProp = Object.defineProperty;
4
3
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
5
  var __hasOwnProp = Object.prototype.hasOwnProperty;
8
6
  var __export = (target, all) => {
9
7
  for (var name in all)
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
17
15
  }
18
16
  return to;
19
17
  };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
19
 
30
20
  // lib/index.ts
@@ -56,8 +46,829 @@ __export(lib_exports, {
56
46
  });
57
47
  module.exports = __toCommonJS(lib_exports);
58
48
 
59
- // lib/asstClient.ts
60
- var import_ky = __toESM(require("ky"), 1);
49
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/errors/HTTPError.js
50
+ var HTTPError = class extends Error {
51
+ response;
52
+ request;
53
+ options;
54
+ constructor(response, request, options) {
55
+ const code = response.status || response.status === 0 ? response.status : "";
56
+ const title = response.statusText ?? "";
57
+ const status = `${code} ${title}`.trim();
58
+ const reason = status ? `status code ${status}` : "an unknown error";
59
+ super(`Request failed with ${reason}: ${request.method} ${request.url}`);
60
+ this.name = "HTTPError";
61
+ this.response = response;
62
+ this.request = request;
63
+ this.options = options;
64
+ }
65
+ };
66
+
67
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/errors/NonError.js
68
+ var NonError = class extends Error {
69
+ name = "NonError";
70
+ value;
71
+ constructor(value) {
72
+ let message = "Non-error value was thrown";
73
+ try {
74
+ if (typeof value === "string") {
75
+ message = value;
76
+ } else if (value && typeof value === "object" && "message" in value && typeof value.message === "string") {
77
+ message = value.message;
78
+ }
79
+ } catch {
80
+ }
81
+ super(message);
82
+ this.value = value;
83
+ }
84
+ };
85
+
86
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/errors/ForceRetryError.js
87
+ var ForceRetryError = class extends Error {
88
+ name = "ForceRetryError";
89
+ customDelay;
90
+ code;
91
+ customRequest;
92
+ constructor(options) {
93
+ const cause = options?.cause ? options.cause instanceof Error ? options.cause : new NonError(options.cause) : void 0;
94
+ super(options?.code ? `Forced retry: ${options.code}` : "Forced retry", cause ? { cause } : void 0);
95
+ this.customDelay = options?.delay;
96
+ this.code = options?.code;
97
+ this.customRequest = options?.request;
98
+ }
99
+ };
100
+
101
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/core/constants.js
102
+ var supportsRequestStreams = (() => {
103
+ let duplexAccessed = false;
104
+ let hasContentType = false;
105
+ const supportsReadableStream = typeof globalThis.ReadableStream === "function";
106
+ const supportsRequest = typeof globalThis.Request === "function";
107
+ if (supportsReadableStream && supportsRequest) {
108
+ try {
109
+ hasContentType = new globalThis.Request("https://empty.invalid", {
110
+ body: new globalThis.ReadableStream(),
111
+ method: "POST",
112
+ // @ts-expect-error - Types are outdated.
113
+ get duplex() {
114
+ duplexAccessed = true;
115
+ return "half";
116
+ }
117
+ }).headers.has("Content-Type");
118
+ } catch (error) {
119
+ if (error instanceof Error && error.message === "unsupported BodyInit type") {
120
+ return false;
121
+ }
122
+ throw error;
123
+ }
124
+ }
125
+ return duplexAccessed && !hasContentType;
126
+ })();
127
+ var supportsAbortController = typeof globalThis.AbortController === "function";
128
+ var supportsAbortSignal = typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortSignal.any === "function";
129
+ var supportsResponseStreams = typeof globalThis.ReadableStream === "function";
130
+ var supportsFormData = typeof globalThis.FormData === "function";
131
+ var requestMethods = ["get", "post", "put", "patch", "head", "delete"];
132
+ var validate = () => void 0;
133
+ validate();
134
+ var responseTypes = {
135
+ json: "application/json",
136
+ text: "text/*",
137
+ formData: "multipart/form-data",
138
+ arrayBuffer: "*/*",
139
+ blob: "*/*",
140
+ // Supported in modern Fetch implementations (for example, browsers and recent Node.js/undici).
141
+ // We still feature-check at runtime before exposing the shortcut.
142
+ bytes: "*/*"
143
+ };
144
+ var maxSafeTimeout = 2147483647;
145
+ var usualFormBoundarySize = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length;
146
+ var stop = /* @__PURE__ */ Symbol("stop");
147
+ var RetryMarker = class {
148
+ options;
149
+ constructor(options) {
150
+ this.options = options;
151
+ }
152
+ };
153
+ var retry = (options) => new RetryMarker(options);
154
+ var kyOptionKeys = {
155
+ json: true,
156
+ parseJson: true,
157
+ stringifyJson: true,
158
+ searchParams: true,
159
+ prefixUrl: true,
160
+ retry: true,
161
+ timeout: true,
162
+ hooks: true,
163
+ throwHttpErrors: true,
164
+ onDownloadProgress: true,
165
+ onUploadProgress: true,
166
+ fetch: true,
167
+ context: true
168
+ };
169
+ var vendorSpecificOptions = {
170
+ next: true
171
+ // Next.js cache revalidation (revalidate, tags)
172
+ };
173
+ var requestOptionsRegistry = {
174
+ method: true,
175
+ headers: true,
176
+ body: true,
177
+ mode: true,
178
+ credentials: true,
179
+ cache: true,
180
+ redirect: true,
181
+ referrer: true,
182
+ referrerPolicy: true,
183
+ integrity: true,
184
+ keepalive: true,
185
+ signal: true,
186
+ window: true,
187
+ duplex: true
188
+ };
189
+
190
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/body.js
191
+ var getBodySize = (body) => {
192
+ if (!body) {
193
+ return 0;
194
+ }
195
+ if (body instanceof FormData) {
196
+ let size = 0;
197
+ for (const [key, value] of body) {
198
+ size += usualFormBoundarySize;
199
+ size += new TextEncoder().encode(`Content-Disposition: form-data; name="${key}"`).length;
200
+ size += typeof value === "string" ? new TextEncoder().encode(value).length : value.size;
201
+ }
202
+ return size;
203
+ }
204
+ if (body instanceof Blob) {
205
+ return body.size;
206
+ }
207
+ if (body instanceof ArrayBuffer) {
208
+ return body.byteLength;
209
+ }
210
+ if (typeof body === "string") {
211
+ return new TextEncoder().encode(body).length;
212
+ }
213
+ if (body instanceof URLSearchParams) {
214
+ return new TextEncoder().encode(body.toString()).length;
215
+ }
216
+ if ("byteLength" in body) {
217
+ return body.byteLength;
218
+ }
219
+ if (typeof body === "object" && body !== null) {
220
+ try {
221
+ const jsonString = JSON.stringify(body);
222
+ return new TextEncoder().encode(jsonString).length;
223
+ } catch {
224
+ return 0;
225
+ }
226
+ }
227
+ return 0;
228
+ };
229
+ var withProgress = (stream, totalBytes, onProgress) => {
230
+ let previousChunk;
231
+ let transferredBytes = 0;
232
+ return stream.pipeThrough(new TransformStream({
233
+ transform(currentChunk, controller) {
234
+ controller.enqueue(currentChunk);
235
+ if (previousChunk) {
236
+ transferredBytes += previousChunk.byteLength;
237
+ let percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
238
+ if (percent >= 1) {
239
+ percent = 1 - Number.EPSILON;
240
+ }
241
+ onProgress?.({ percent, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
242
+ }
243
+ previousChunk = currentChunk;
244
+ },
245
+ flush() {
246
+ if (previousChunk) {
247
+ transferredBytes += previousChunk.byteLength;
248
+ onProgress?.({ percent: 1, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
249
+ }
250
+ }
251
+ }));
252
+ };
253
+ var streamResponse = (response, onDownloadProgress) => {
254
+ if (!response.body) {
255
+ return response;
256
+ }
257
+ if (response.status === 204) {
258
+ return new Response(null, {
259
+ status: response.status,
260
+ statusText: response.statusText,
261
+ headers: response.headers
262
+ });
263
+ }
264
+ const totalBytes = Math.max(0, Number(response.headers.get("content-length")) || 0);
265
+ return new Response(withProgress(response.body, totalBytes, onDownloadProgress), {
266
+ status: response.status,
267
+ statusText: response.statusText,
268
+ headers: response.headers
269
+ });
270
+ };
271
+ var streamRequest = (request, onUploadProgress, originalBody) => {
272
+ if (!request.body) {
273
+ return request;
274
+ }
275
+ const totalBytes = getBodySize(originalBody ?? request.body);
276
+ return new Request(request, {
277
+ // @ts-expect-error - Types are outdated.
278
+ duplex: "half",
279
+ body: withProgress(request.body, totalBytes, onUploadProgress)
280
+ });
281
+ };
282
+
283
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/is.js
284
+ var isObject = (value) => value !== null && typeof value === "object";
285
+
286
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/merge.js
287
+ var validateAndMerge = (...sources) => {
288
+ for (const source of sources) {
289
+ if ((!isObject(source) || Array.isArray(source)) && source !== void 0) {
290
+ throw new TypeError("The `options` argument must be an object");
291
+ }
292
+ }
293
+ return deepMerge({}, ...sources);
294
+ };
295
+ var mergeHeaders = (source1 = {}, source2 = {}) => {
296
+ const result = new globalThis.Headers(source1);
297
+ const isHeadersInstance = source2 instanceof globalThis.Headers;
298
+ const source = new globalThis.Headers(source2);
299
+ for (const [key, value] of source.entries()) {
300
+ if (isHeadersInstance && value === "undefined" || value === void 0) {
301
+ result.delete(key);
302
+ } else {
303
+ result.set(key, value);
304
+ }
305
+ }
306
+ return result;
307
+ };
308
+ function newHookValue(original, incoming, property) {
309
+ return Object.hasOwn(incoming, property) && incoming[property] === void 0 ? [] : deepMerge(original[property] ?? [], incoming[property] ?? []);
310
+ }
311
+ var mergeHooks = (original = {}, incoming = {}) => ({
312
+ beforeRequest: newHookValue(original, incoming, "beforeRequest"),
313
+ beforeRetry: newHookValue(original, incoming, "beforeRetry"),
314
+ afterResponse: newHookValue(original, incoming, "afterResponse"),
315
+ beforeError: newHookValue(original, incoming, "beforeError")
316
+ });
317
+ var appendSearchParameters = (target, source) => {
318
+ const result = new URLSearchParams();
319
+ for (const input of [target, source]) {
320
+ if (input === void 0) {
321
+ continue;
322
+ }
323
+ if (input instanceof URLSearchParams) {
324
+ for (const [key, value] of input.entries()) {
325
+ result.append(key, value);
326
+ }
327
+ } else if (Array.isArray(input)) {
328
+ for (const pair of input) {
329
+ if (!Array.isArray(pair) || pair.length !== 2) {
330
+ throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
331
+ }
332
+ result.append(String(pair[0]), String(pair[1]));
333
+ }
334
+ } else if (isObject(input)) {
335
+ for (const [key, value] of Object.entries(input)) {
336
+ if (value !== void 0) {
337
+ result.append(key, String(value));
338
+ }
339
+ }
340
+ } else {
341
+ const parameters = new URLSearchParams(input);
342
+ for (const [key, value] of parameters.entries()) {
343
+ result.append(key, value);
344
+ }
345
+ }
346
+ }
347
+ return result;
348
+ };
349
+ var deepMerge = (...sources) => {
350
+ let returnValue = {};
351
+ let headers = {};
352
+ let hooks = {};
353
+ let searchParameters;
354
+ const signals = [];
355
+ for (const source of sources) {
356
+ if (Array.isArray(source)) {
357
+ if (!Array.isArray(returnValue)) {
358
+ returnValue = [];
359
+ }
360
+ returnValue = [...returnValue, ...source];
361
+ } else if (isObject(source)) {
362
+ for (let [key, value] of Object.entries(source)) {
363
+ if (key === "signal" && value instanceof globalThis.AbortSignal) {
364
+ signals.push(value);
365
+ continue;
366
+ }
367
+ if (key === "context") {
368
+ if (value !== void 0 && value !== null && (!isObject(value) || Array.isArray(value))) {
369
+ throw new TypeError("The `context` option must be an object");
370
+ }
371
+ returnValue = {
372
+ ...returnValue,
373
+ context: value === void 0 || value === null ? {} : { ...returnValue.context, ...value }
374
+ };
375
+ continue;
376
+ }
377
+ if (key === "searchParams") {
378
+ if (value === void 0 || value === null) {
379
+ searchParameters = void 0;
380
+ } else {
381
+ searchParameters = searchParameters === void 0 ? value : appendSearchParameters(searchParameters, value);
382
+ }
383
+ continue;
384
+ }
385
+ if (isObject(value) && key in returnValue) {
386
+ value = deepMerge(returnValue[key], value);
387
+ }
388
+ returnValue = { ...returnValue, [key]: value };
389
+ }
390
+ if (isObject(source.hooks)) {
391
+ hooks = mergeHooks(hooks, source.hooks);
392
+ returnValue.hooks = hooks;
393
+ }
394
+ if (isObject(source.headers)) {
395
+ headers = mergeHeaders(headers, source.headers);
396
+ returnValue.headers = headers;
397
+ }
398
+ }
399
+ }
400
+ if (searchParameters !== void 0) {
401
+ returnValue.searchParams = searchParameters;
402
+ }
403
+ if (signals.length > 0) {
404
+ if (signals.length === 1) {
405
+ returnValue.signal = signals[0];
406
+ } else if (supportsAbortSignal) {
407
+ returnValue.signal = AbortSignal.any(signals);
408
+ } else {
409
+ returnValue.signal = signals.at(-1);
410
+ }
411
+ }
412
+ return returnValue;
413
+ };
414
+
415
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/normalize.js
416
+ var normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
417
+ var retryMethods = ["get", "put", "head", "delete", "options", "trace"];
418
+ var retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
419
+ var retryAfterStatusCodes = [413, 429, 503];
420
+ var defaultRetryOptions = {
421
+ limit: 2,
422
+ methods: retryMethods,
423
+ statusCodes: retryStatusCodes,
424
+ afterStatusCodes: retryAfterStatusCodes,
425
+ maxRetryAfter: Number.POSITIVE_INFINITY,
426
+ backoffLimit: Number.POSITIVE_INFINITY,
427
+ delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1e3,
428
+ jitter: void 0,
429
+ retryOnTimeout: false
430
+ };
431
+ var normalizeRetryOptions = (retry2 = {}) => {
432
+ if (typeof retry2 === "number") {
433
+ return {
434
+ ...defaultRetryOptions,
435
+ limit: retry2
436
+ };
437
+ }
438
+ if (retry2.methods && !Array.isArray(retry2.methods)) {
439
+ throw new Error("retry.methods must be an array");
440
+ }
441
+ retry2.methods &&= retry2.methods.map((method) => method.toLowerCase());
442
+ if (retry2.statusCodes && !Array.isArray(retry2.statusCodes)) {
443
+ throw new Error("retry.statusCodes must be an array");
444
+ }
445
+ const normalizedRetry = Object.fromEntries(Object.entries(retry2).filter(([, value]) => value !== void 0));
446
+ return {
447
+ ...defaultRetryOptions,
448
+ ...normalizedRetry
449
+ };
450
+ };
451
+
452
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/errors/TimeoutError.js
453
+ var TimeoutError = class extends Error {
454
+ request;
455
+ constructor(request) {
456
+ super(`Request timed out: ${request.method} ${request.url}`);
457
+ this.name = "TimeoutError";
458
+ this.request = request;
459
+ }
460
+ };
461
+
462
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/timeout.js
463
+ async function timeout(request, init, abortController, options) {
464
+ return new Promise((resolve, reject) => {
465
+ const timeoutId = setTimeout(() => {
466
+ if (abortController) {
467
+ abortController.abort();
468
+ }
469
+ reject(new TimeoutError(request));
470
+ }, options.timeout);
471
+ void options.fetch(request, init).then(resolve).catch(reject).then(() => {
472
+ clearTimeout(timeoutId);
473
+ });
474
+ });
475
+ }
476
+
477
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/delay.js
478
+ async function delay(ms, { signal }) {
479
+ return new Promise((resolve, reject) => {
480
+ if (signal) {
481
+ signal.throwIfAborted();
482
+ signal.addEventListener("abort", abortHandler, { once: true });
483
+ }
484
+ function abortHandler() {
485
+ clearTimeout(timeoutId);
486
+ reject(signal.reason);
487
+ }
488
+ const timeoutId = setTimeout(() => {
489
+ signal?.removeEventListener("abort", abortHandler);
490
+ resolve();
491
+ }, ms);
492
+ });
493
+ }
494
+
495
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/options.js
496
+ var findUnknownOptions = (request, options) => {
497
+ const unknownOptions = {};
498
+ for (const key in options) {
499
+ if (!Object.hasOwn(options, key)) {
500
+ continue;
501
+ }
502
+ if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && (!(key in request) || key in vendorSpecificOptions)) {
503
+ unknownOptions[key] = options[key];
504
+ }
505
+ }
506
+ return unknownOptions;
507
+ };
508
+ var hasSearchParameters = (search) => {
509
+ if (search === void 0) {
510
+ return false;
511
+ }
512
+ if (Array.isArray(search)) {
513
+ return search.length > 0;
514
+ }
515
+ if (search instanceof URLSearchParams) {
516
+ return search.size > 0;
517
+ }
518
+ if (typeof search === "object") {
519
+ return Object.keys(search).length > 0;
520
+ }
521
+ if (typeof search === "string") {
522
+ return search.trim().length > 0;
523
+ }
524
+ return Boolean(search);
525
+ };
526
+
527
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/utils/type-guards.js
528
+ function isHTTPError(error) {
529
+ return error instanceof HTTPError || error?.name === HTTPError.name;
530
+ }
531
+ function isTimeoutError(error) {
532
+ return error instanceof TimeoutError || error?.name === TimeoutError.name;
533
+ }
534
+
535
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/core/Ky.js
536
+ var Ky = class _Ky {
537
+ static create(input, options) {
538
+ const ky2 = new _Ky(input, options);
539
+ const function_ = async () => {
540
+ if (typeof ky2.#options.timeout === "number" && ky2.#options.timeout > maxSafeTimeout) {
541
+ throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
542
+ }
543
+ await Promise.resolve();
544
+ let response = await ky2.#fetch();
545
+ for (const hook of ky2.#options.hooks.afterResponse) {
546
+ const clonedResponse = ky2.#decorateResponse(response.clone());
547
+ let modifiedResponse;
548
+ try {
549
+ modifiedResponse = await hook(ky2.request, ky2.#getNormalizedOptions(), clonedResponse, { retryCount: ky2.#retryCount });
550
+ } catch (error) {
551
+ ky2.#cancelResponseBody(clonedResponse);
552
+ ky2.#cancelResponseBody(response);
553
+ throw error;
554
+ }
555
+ if (modifiedResponse instanceof RetryMarker) {
556
+ ky2.#cancelResponseBody(clonedResponse);
557
+ ky2.#cancelResponseBody(response);
558
+ throw new ForceRetryError(modifiedResponse.options);
559
+ }
560
+ const nextResponse = modifiedResponse instanceof globalThis.Response ? modifiedResponse : response;
561
+ if (clonedResponse !== nextResponse) {
562
+ ky2.#cancelResponseBody(clonedResponse);
563
+ }
564
+ if (response !== nextResponse) {
565
+ ky2.#cancelResponseBody(response);
566
+ }
567
+ response = nextResponse;
568
+ }
569
+ ky2.#decorateResponse(response);
570
+ if (!response.ok && (typeof ky2.#options.throwHttpErrors === "function" ? ky2.#options.throwHttpErrors(response.status) : ky2.#options.throwHttpErrors)) {
571
+ let error = new HTTPError(response, ky2.request, ky2.#getNormalizedOptions());
572
+ for (const hook of ky2.#options.hooks.beforeError) {
573
+ error = await hook(error, { retryCount: ky2.#retryCount });
574
+ }
575
+ throw error;
576
+ }
577
+ if (ky2.#options.onDownloadProgress) {
578
+ if (typeof ky2.#options.onDownloadProgress !== "function") {
579
+ throw new TypeError("The `onDownloadProgress` option must be a function");
580
+ }
581
+ if (!supportsResponseStreams) {
582
+ throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
583
+ }
584
+ const progressResponse = response.clone();
585
+ ky2.#cancelResponseBody(response);
586
+ return streamResponse(progressResponse, ky2.#options.onDownloadProgress);
587
+ }
588
+ return response;
589
+ };
590
+ const result = ky2.#retry(function_).finally(() => {
591
+ const originalRequest = ky2.#originalRequest;
592
+ ky2.#cancelBody(originalRequest?.body ?? void 0);
593
+ ky2.#cancelBody(ky2.request.body ?? void 0);
594
+ });
595
+ for (const [type, mimeType] of Object.entries(responseTypes)) {
596
+ if (type === "bytes" && typeof globalThis.Response?.prototype?.bytes !== "function") {
597
+ continue;
598
+ }
599
+ result[type] = async () => {
600
+ ky2.request.headers.set("accept", ky2.request.headers.get("accept") || mimeType);
601
+ const response = await result;
602
+ if (type === "json") {
603
+ if (response.status === 204) {
604
+ return "";
605
+ }
606
+ const text = await response.text();
607
+ if (text === "") {
608
+ return "";
609
+ }
610
+ if (options.parseJson) {
611
+ return options.parseJson(text);
612
+ }
613
+ return JSON.parse(text);
614
+ }
615
+ return response[type]();
616
+ };
617
+ }
618
+ return result;
619
+ }
620
+ // eslint-disable-next-line unicorn/prevent-abbreviations
621
+ static #normalizeSearchParams(searchParams) {
622
+ if (searchParams && typeof searchParams === "object" && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) {
623
+ return Object.fromEntries(Object.entries(searchParams).filter(([, value]) => value !== void 0));
624
+ }
625
+ return searchParams;
626
+ }
627
+ request;
628
+ #abortController;
629
+ #retryCount = 0;
630
+ // eslint-disable-next-line @typescript-eslint/prefer-readonly -- False positive: #input is reassigned on line 202
631
+ #input;
632
+ #options;
633
+ #originalRequest;
634
+ #userProvidedAbortSignal;
635
+ #cachedNormalizedOptions;
636
+ // eslint-disable-next-line complexity
637
+ constructor(input, options = {}) {
638
+ this.#input = input;
639
+ this.#options = {
640
+ ...options,
641
+ headers: mergeHeaders(this.#input.headers, options.headers),
642
+ hooks: mergeHooks({
643
+ beforeRequest: [],
644
+ beforeRetry: [],
645
+ beforeError: [],
646
+ afterResponse: []
647
+ }, options.hooks),
648
+ method: normalizeRequestMethod(options.method ?? this.#input.method ?? "GET"),
649
+ // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
650
+ prefixUrl: String(options.prefixUrl || ""),
651
+ retry: normalizeRetryOptions(options.retry),
652
+ throwHttpErrors: options.throwHttpErrors ?? true,
653
+ timeout: options.timeout ?? 1e4,
654
+ fetch: options.fetch ?? globalThis.fetch.bind(globalThis),
655
+ context: options.context ?? {}
656
+ };
657
+ if (typeof this.#input !== "string" && !(this.#input instanceof URL || this.#input instanceof globalThis.Request)) {
658
+ throw new TypeError("`input` must be a string, URL, or Request");
659
+ }
660
+ if (this.#options.prefixUrl && typeof this.#input === "string") {
661
+ if (this.#input.startsWith("/")) {
662
+ throw new Error("`input` must not begin with a slash when using `prefixUrl`");
663
+ }
664
+ if (!this.#options.prefixUrl.endsWith("/")) {
665
+ this.#options.prefixUrl += "/";
666
+ }
667
+ this.#input = this.#options.prefixUrl + this.#input;
668
+ }
669
+ if (supportsAbortController && supportsAbortSignal) {
670
+ this.#userProvidedAbortSignal = this.#options.signal ?? this.#input.signal;
671
+ this.#abortController = new globalThis.AbortController();
672
+ this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
673
+ }
674
+ if (supportsRequestStreams) {
675
+ this.#options.duplex = "half";
676
+ }
677
+ if (this.#options.json !== void 0) {
678
+ this.#options.body = this.#options.stringifyJson?.(this.#options.json) ?? JSON.stringify(this.#options.json);
679
+ this.#options.headers.set("content-type", this.#options.headers.get("content-type") ?? "application/json");
680
+ }
681
+ const userProvidedContentType = options.headers && new globalThis.Headers(options.headers).has("content-type");
682
+ if (this.#input instanceof globalThis.Request && (supportsFormData && this.#options.body instanceof globalThis.FormData || this.#options.body instanceof URLSearchParams) && !userProvidedContentType) {
683
+ this.#options.headers.delete("content-type");
684
+ }
685
+ this.request = new globalThis.Request(this.#input, this.#options);
686
+ if (hasSearchParameters(this.#options.searchParams)) {
687
+ const textSearchParams = typeof this.#options.searchParams === "string" ? this.#options.searchParams.replace(/^\?/, "") : new URLSearchParams(_Ky.#normalizeSearchParams(this.#options.searchParams)).toString();
688
+ const searchParams = "?" + textSearchParams;
689
+ const url = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
690
+ this.request = new globalThis.Request(url, this.#options);
691
+ }
692
+ if (this.#options.onUploadProgress) {
693
+ if (typeof this.#options.onUploadProgress !== "function") {
694
+ throw new TypeError("The `onUploadProgress` option must be a function");
695
+ }
696
+ if (!supportsRequestStreams) {
697
+ throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
698
+ }
699
+ this.request = this.#wrapRequestWithUploadProgress(this.request, this.#options.body ?? void 0);
700
+ }
701
+ }
702
+ #calculateDelay() {
703
+ const retryDelay = this.#options.retry.delay(this.#retryCount);
704
+ let jitteredDelay = retryDelay;
705
+ if (this.#options.retry.jitter === true) {
706
+ jitteredDelay = Math.random() * retryDelay;
707
+ } else if (typeof this.#options.retry.jitter === "function") {
708
+ jitteredDelay = this.#options.retry.jitter(retryDelay);
709
+ if (!Number.isFinite(jitteredDelay) || jitteredDelay < 0) {
710
+ jitteredDelay = retryDelay;
711
+ }
712
+ }
713
+ const backoffLimit = this.#options.retry.backoffLimit ?? Number.POSITIVE_INFINITY;
714
+ return Math.min(backoffLimit, jitteredDelay);
715
+ }
716
+ async #calculateRetryDelay(error) {
717
+ this.#retryCount++;
718
+ if (this.#retryCount > this.#options.retry.limit) {
719
+ throw error;
720
+ }
721
+ const errorObject = error instanceof Error ? error : new NonError(error);
722
+ if (errorObject instanceof ForceRetryError) {
723
+ return errorObject.customDelay ?? this.#calculateDelay();
724
+ }
725
+ if (!this.#options.retry.methods.includes(this.request.method.toLowerCase())) {
726
+ throw error;
727
+ }
728
+ if (this.#options.retry.shouldRetry !== void 0) {
729
+ const result = await this.#options.retry.shouldRetry({ error: errorObject, retryCount: this.#retryCount });
730
+ if (result === false) {
731
+ throw error;
732
+ }
733
+ if (result === true) {
734
+ return this.#calculateDelay();
735
+ }
736
+ }
737
+ if (isTimeoutError(error) && !this.#options.retry.retryOnTimeout) {
738
+ throw error;
739
+ }
740
+ if (isHTTPError(error)) {
741
+ if (!this.#options.retry.statusCodes.includes(error.response.status)) {
742
+ throw error;
743
+ }
744
+ const retryAfter = error.response.headers.get("Retry-After") ?? error.response.headers.get("RateLimit-Reset") ?? error.response.headers.get("X-RateLimit-Retry-After") ?? error.response.headers.get("X-RateLimit-Reset") ?? error.response.headers.get("X-Rate-Limit-Reset");
745
+ if (retryAfter && this.#options.retry.afterStatusCodes.includes(error.response.status)) {
746
+ let after = Number(retryAfter) * 1e3;
747
+ if (Number.isNaN(after)) {
748
+ after = Date.parse(retryAfter) - Date.now();
749
+ } else if (after >= Date.parse("2024-01-01")) {
750
+ after -= Date.now();
751
+ }
752
+ const max = this.#options.retry.maxRetryAfter ?? after;
753
+ return after < max ? after : max;
754
+ }
755
+ if (error.response.status === 413) {
756
+ throw error;
757
+ }
758
+ }
759
+ return this.#calculateDelay();
760
+ }
761
+ #decorateResponse(response) {
762
+ if (this.#options.parseJson) {
763
+ response.json = async () => this.#options.parseJson(await response.text());
764
+ }
765
+ return response;
766
+ }
767
+ #cancelBody(body) {
768
+ if (!body) {
769
+ return;
770
+ }
771
+ void body.cancel().catch(() => void 0);
772
+ }
773
+ #cancelResponseBody(response) {
774
+ this.#cancelBody(response.body ?? void 0);
775
+ }
776
+ async #retry(function_) {
777
+ try {
778
+ return await function_();
779
+ } catch (error) {
780
+ const ms = Math.min(await this.#calculateRetryDelay(error), maxSafeTimeout);
781
+ if (this.#retryCount < 1) {
782
+ throw error;
783
+ }
784
+ await delay(ms, this.#userProvidedAbortSignal ? { signal: this.#userProvidedAbortSignal } : {});
785
+ if (error instanceof ForceRetryError && error.customRequest) {
786
+ const managedRequest = this.#options.signal ? new globalThis.Request(error.customRequest, { signal: this.#options.signal }) : new globalThis.Request(error.customRequest);
787
+ this.#assignRequest(managedRequest);
788
+ }
789
+ for (const hook of this.#options.hooks.beforeRetry) {
790
+ const hookResult = await hook({
791
+ request: this.request,
792
+ options: this.#getNormalizedOptions(),
793
+ error,
794
+ retryCount: this.#retryCount
795
+ });
796
+ if (hookResult instanceof globalThis.Request) {
797
+ this.#assignRequest(hookResult);
798
+ break;
799
+ }
800
+ if (hookResult instanceof globalThis.Response) {
801
+ return hookResult;
802
+ }
803
+ if (hookResult === stop) {
804
+ return;
805
+ }
806
+ }
807
+ return this.#retry(function_);
808
+ }
809
+ }
810
+ async #fetch() {
811
+ if (this.#abortController?.signal.aborted) {
812
+ this.#abortController = new globalThis.AbortController();
813
+ this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
814
+ this.request = new globalThis.Request(this.request, { signal: this.#options.signal });
815
+ }
816
+ for (const hook of this.#options.hooks.beforeRequest) {
817
+ const result = await hook(this.request, this.#getNormalizedOptions(), { retryCount: this.#retryCount });
818
+ if (result instanceof Response) {
819
+ return result;
820
+ }
821
+ if (result instanceof globalThis.Request) {
822
+ this.#assignRequest(result);
823
+ break;
824
+ }
825
+ }
826
+ const nonRequestOptions = findUnknownOptions(this.request, this.#options);
827
+ this.#originalRequest = this.request;
828
+ this.request = this.#originalRequest.clone();
829
+ if (this.#options.timeout === false) {
830
+ return this.#options.fetch(this.#originalRequest, nonRequestOptions);
831
+ }
832
+ return timeout(this.#originalRequest, nonRequestOptions, this.#abortController, this.#options);
833
+ }
834
+ #getNormalizedOptions() {
835
+ if (!this.#cachedNormalizedOptions) {
836
+ const { hooks, ...normalizedOptions } = this.#options;
837
+ this.#cachedNormalizedOptions = Object.freeze(normalizedOptions);
838
+ }
839
+ return this.#cachedNormalizedOptions;
840
+ }
841
+ #assignRequest(request) {
842
+ this.#cachedNormalizedOptions = void 0;
843
+ this.request = this.#wrapRequestWithUploadProgress(request);
844
+ }
845
+ #wrapRequestWithUploadProgress(request, originalBody) {
846
+ if (!this.#options.onUploadProgress || !request.body) {
847
+ return request;
848
+ }
849
+ return streamRequest(request, this.#options.onUploadProgress, originalBody ?? this.#options.body ?? void 0);
850
+ }
851
+ };
852
+
853
+ // ../../node_modules/.pnpm/ky@1.14.3/node_modules/ky/distribution/index.js
854
+ var createInstance = (defaults) => {
855
+ const ky2 = (input, options) => Ky.create(input, validateAndMerge(defaults, options));
856
+ for (const method of requestMethods) {
857
+ ky2[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));
858
+ }
859
+ ky2.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));
860
+ ky2.extend = (newDefaults) => {
861
+ if (typeof newDefaults === "function") {
862
+ newDefaults = newDefaults(defaults ?? {});
863
+ }
864
+ return createInstance(validateAndMerge(defaults, newDefaults));
865
+ };
866
+ ky2.stop = stop;
867
+ ky2.retry = retry;
868
+ return ky2;
869
+ };
870
+ var ky = createInstance();
871
+ var distribution_default = ky;
61
872
 
62
873
  // ../../node_modules/.pnpm/zod@3.25.76/node_modules/zod/v3/external.js
63
874
  var external_exports = {};
@@ -4119,7 +4930,7 @@ var initialConfig = {
4119
4930
  retry: 0
4120
4931
  };
4121
4932
  var AsstClient = class {
4122
- #client = import_ky.default.create(initialConfig);
4933
+ #client = distribution_default.create(initialConfig);
4123
4934
  #baseUrl = BASE_URLS["test"];
4124
4935
  #listeners = /* @__PURE__ */ new Set();
4125
4936
  #currentConfig = initialConfig;
@@ -5769,3 +6580,8 @@ function createRulesManagementApi(client) {
5769
6580
  createWhoAmIApi,
5770
6581
  envSchema
5771
6582
  });
6583
+ /*! Bundled license information:
6584
+
6585
+ ky/distribution/index.js:
6586
+ (*! MIT License © Sindre Sorhus *)
6587
+ */