@base44-preview/cli 0.0.49-pr.450.5fc8bec → 0.0.49-pr.453.20f6e7b

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/cli/index.js CHANGED
@@ -220132,6 +220132,825 @@ class TimeoutError extends Error {
220132
220132
  }
220133
220133
  }
220134
220134
 
220135
+ // ../../node_modules/ky/distribution/errors/HTTPError.js
220136
+ class HTTPError extends Error {
220137
+ response;
220138
+ request;
220139
+ options;
220140
+ constructor(response, request, options) {
220141
+ const code = response.status || response.status === 0 ? response.status : "";
220142
+ const title = response.statusText ?? "";
220143
+ const status = `${code} ${title}`.trim();
220144
+ const reason = status ? `status code ${status}` : "an unknown error";
220145
+ super(`Request failed with ${reason}: ${request.method} ${request.url}`);
220146
+ this.name = "HTTPError";
220147
+ this.response = response;
220148
+ this.request = request;
220149
+ this.options = options;
220150
+ }
220151
+ }
220152
+
220153
+ // ../../node_modules/ky/distribution/errors/NonError.js
220154
+ class NonError extends Error {
220155
+ name = "NonError";
220156
+ value;
220157
+ constructor(value) {
220158
+ let message = "Non-error value was thrown";
220159
+ try {
220160
+ if (typeof value === "string") {
220161
+ message = value;
220162
+ } else if (value && typeof value === "object" && "message" in value && typeof value.message === "string") {
220163
+ message = value.message;
220164
+ }
220165
+ } catch {}
220166
+ super(message);
220167
+ this.value = value;
220168
+ }
220169
+ }
220170
+
220171
+ // ../../node_modules/ky/distribution/errors/ForceRetryError.js
220172
+ class ForceRetryError extends Error {
220173
+ name = "ForceRetryError";
220174
+ customDelay;
220175
+ code;
220176
+ customRequest;
220177
+ constructor(options) {
220178
+ const cause = options?.cause ? options.cause instanceof Error ? options.cause : new NonError(options.cause) : undefined;
220179
+ super(options?.code ? `Forced retry: ${options.code}` : "Forced retry", cause ? { cause } : undefined);
220180
+ this.customDelay = options?.delay;
220181
+ this.code = options?.code;
220182
+ this.customRequest = options?.request;
220183
+ }
220184
+ }
220185
+
220186
+ // ../../node_modules/ky/distribution/core/constants.js
220187
+ var supportsRequestStreams = (() => {
220188
+ let duplexAccessed = false;
220189
+ let hasContentType = false;
220190
+ const supportsReadableStream = typeof globalThis.ReadableStream === "function";
220191
+ const supportsRequest = typeof globalThis.Request === "function";
220192
+ if (supportsReadableStream && supportsRequest) {
220193
+ try {
220194
+ hasContentType = new globalThis.Request("https://empty.invalid", {
220195
+ body: new globalThis.ReadableStream,
220196
+ method: "POST",
220197
+ get duplex() {
220198
+ duplexAccessed = true;
220199
+ return "half";
220200
+ }
220201
+ }).headers.has("Content-Type");
220202
+ } catch (error) {
220203
+ if (error instanceof Error && error.message === "unsupported BodyInit type") {
220204
+ return false;
220205
+ }
220206
+ throw error;
220207
+ }
220208
+ }
220209
+ return duplexAccessed && !hasContentType;
220210
+ })();
220211
+ var supportsAbortController = typeof globalThis.AbortController === "function";
220212
+ var supportsAbortSignal = typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortSignal.any === "function";
220213
+ var supportsResponseStreams = typeof globalThis.ReadableStream === "function";
220214
+ var supportsFormData = typeof globalThis.FormData === "function";
220215
+ var requestMethods = ["get", "post", "put", "patch", "head", "delete"];
220216
+ var validate = () => {
220217
+ return;
220218
+ };
220219
+ validate();
220220
+ var responseTypes = {
220221
+ json: "application/json",
220222
+ text: "text/*",
220223
+ formData: "multipart/form-data",
220224
+ arrayBuffer: "*/*",
220225
+ blob: "*/*",
220226
+ bytes: "*/*"
220227
+ };
220228
+ var maxSafeTimeout = 2147483647;
220229
+ var usualFormBoundarySize = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length;
220230
+ var stop = Symbol("stop");
220231
+
220232
+ class RetryMarker {
220233
+ options;
220234
+ constructor(options) {
220235
+ this.options = options;
220236
+ }
220237
+ }
220238
+ var retry = (options) => new RetryMarker(options);
220239
+ var kyOptionKeys = {
220240
+ json: true,
220241
+ parseJson: true,
220242
+ stringifyJson: true,
220243
+ searchParams: true,
220244
+ prefixUrl: true,
220245
+ retry: true,
220246
+ timeout: true,
220247
+ hooks: true,
220248
+ throwHttpErrors: true,
220249
+ onDownloadProgress: true,
220250
+ onUploadProgress: true,
220251
+ fetch: true,
220252
+ context: true
220253
+ };
220254
+ var vendorSpecificOptions = {
220255
+ next: true
220256
+ };
220257
+ var requestOptionsRegistry = {
220258
+ method: true,
220259
+ headers: true,
220260
+ body: true,
220261
+ mode: true,
220262
+ credentials: true,
220263
+ cache: true,
220264
+ redirect: true,
220265
+ referrer: true,
220266
+ referrerPolicy: true,
220267
+ integrity: true,
220268
+ keepalive: true,
220269
+ signal: true,
220270
+ window: true,
220271
+ duplex: true
220272
+ };
220273
+
220274
+ // ../../node_modules/ky/distribution/utils/body.js
220275
+ var getBodySize = (body) => {
220276
+ if (!body) {
220277
+ return 0;
220278
+ }
220279
+ if (body instanceof FormData) {
220280
+ let size = 0;
220281
+ for (const [key, value] of body) {
220282
+ size += usualFormBoundarySize;
220283
+ size += new TextEncoder().encode(`Content-Disposition: form-data; name="${key}"`).length;
220284
+ size += typeof value === "string" ? new TextEncoder().encode(value).length : value.size;
220285
+ }
220286
+ return size;
220287
+ }
220288
+ if (body instanceof Blob) {
220289
+ return body.size;
220290
+ }
220291
+ if (body instanceof ArrayBuffer) {
220292
+ return body.byteLength;
220293
+ }
220294
+ if (typeof body === "string") {
220295
+ return new TextEncoder().encode(body).length;
220296
+ }
220297
+ if (body instanceof URLSearchParams) {
220298
+ return new TextEncoder().encode(body.toString()).length;
220299
+ }
220300
+ if ("byteLength" in body) {
220301
+ return body.byteLength;
220302
+ }
220303
+ if (typeof body === "object" && body !== null) {
220304
+ try {
220305
+ const jsonString = JSON.stringify(body);
220306
+ return new TextEncoder().encode(jsonString).length;
220307
+ } catch {
220308
+ return 0;
220309
+ }
220310
+ }
220311
+ return 0;
220312
+ };
220313
+ var withProgress = (stream, totalBytes, onProgress) => {
220314
+ let previousChunk;
220315
+ let transferredBytes = 0;
220316
+ return stream.pipeThrough(new TransformStream({
220317
+ transform(currentChunk, controller) {
220318
+ controller.enqueue(currentChunk);
220319
+ if (previousChunk) {
220320
+ transferredBytes += previousChunk.byteLength;
220321
+ let percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
220322
+ if (percent >= 1) {
220323
+ percent = 1 - Number.EPSILON;
220324
+ }
220325
+ onProgress?.({ percent, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
220326
+ }
220327
+ previousChunk = currentChunk;
220328
+ },
220329
+ flush() {
220330
+ if (previousChunk) {
220331
+ transferredBytes += previousChunk.byteLength;
220332
+ onProgress?.({ percent: 1, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
220333
+ }
220334
+ }
220335
+ }));
220336
+ };
220337
+ var streamResponse = (response, onDownloadProgress) => {
220338
+ if (!response.body) {
220339
+ return response;
220340
+ }
220341
+ if (response.status === 204) {
220342
+ return new Response(null, {
220343
+ status: response.status,
220344
+ statusText: response.statusText,
220345
+ headers: response.headers
220346
+ });
220347
+ }
220348
+ const totalBytes = Math.max(0, Number(response.headers.get("content-length")) || 0);
220349
+ return new Response(withProgress(response.body, totalBytes, onDownloadProgress), {
220350
+ status: response.status,
220351
+ statusText: response.statusText,
220352
+ headers: response.headers
220353
+ });
220354
+ };
220355
+ var streamRequest = (request, onUploadProgress, originalBody) => {
220356
+ if (!request.body) {
220357
+ return request;
220358
+ }
220359
+ const totalBytes = getBodySize(originalBody ?? request.body);
220360
+ return new Request(request, {
220361
+ duplex: "half",
220362
+ body: withProgress(request.body, totalBytes, onUploadProgress)
220363
+ });
220364
+ };
220365
+
220366
+ // ../../node_modules/ky/distribution/utils/is.js
220367
+ var isObject = (value) => value !== null && typeof value === "object";
220368
+
220369
+ // ../../node_modules/ky/distribution/utils/merge.js
220370
+ var validateAndMerge = (...sources) => {
220371
+ for (const source of sources) {
220372
+ if ((!isObject(source) || Array.isArray(source)) && source !== undefined) {
220373
+ throw new TypeError("The `options` argument must be an object");
220374
+ }
220375
+ }
220376
+ return deepMerge({}, ...sources);
220377
+ };
220378
+ var mergeHeaders = (source1 = {}, source2 = {}) => {
220379
+ const result = new globalThis.Headers(source1);
220380
+ const isHeadersInstance = source2 instanceof globalThis.Headers;
220381
+ const source = new globalThis.Headers(source2);
220382
+ for (const [key, value] of source.entries()) {
220383
+ if (isHeadersInstance && value === "undefined" || value === undefined) {
220384
+ result.delete(key);
220385
+ } else {
220386
+ result.set(key, value);
220387
+ }
220388
+ }
220389
+ return result;
220390
+ };
220391
+ function newHookValue(original, incoming, property) {
220392
+ return Object.hasOwn(incoming, property) && incoming[property] === undefined ? [] : deepMerge(original[property] ?? [], incoming[property] ?? []);
220393
+ }
220394
+ var mergeHooks = (original = {}, incoming = {}) => ({
220395
+ beforeRequest: newHookValue(original, incoming, "beforeRequest"),
220396
+ beforeRetry: newHookValue(original, incoming, "beforeRetry"),
220397
+ afterResponse: newHookValue(original, incoming, "afterResponse"),
220398
+ beforeError: newHookValue(original, incoming, "beforeError")
220399
+ });
220400
+ var appendSearchParameters = (target, source) => {
220401
+ const result = new URLSearchParams;
220402
+ for (const input of [target, source]) {
220403
+ if (input === undefined) {
220404
+ continue;
220405
+ }
220406
+ if (input instanceof URLSearchParams) {
220407
+ for (const [key, value] of input.entries()) {
220408
+ result.append(key, value);
220409
+ }
220410
+ } else if (Array.isArray(input)) {
220411
+ for (const pair of input) {
220412
+ if (!Array.isArray(pair) || pair.length !== 2) {
220413
+ throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
220414
+ }
220415
+ result.append(String(pair[0]), String(pair[1]));
220416
+ }
220417
+ } else if (isObject(input)) {
220418
+ for (const [key, value] of Object.entries(input)) {
220419
+ if (value !== undefined) {
220420
+ result.append(key, String(value));
220421
+ }
220422
+ }
220423
+ } else {
220424
+ const parameters = new URLSearchParams(input);
220425
+ for (const [key, value] of parameters.entries()) {
220426
+ result.append(key, value);
220427
+ }
220428
+ }
220429
+ }
220430
+ return result;
220431
+ };
220432
+ var deepMerge = (...sources) => {
220433
+ let returnValue = {};
220434
+ let headers = {};
220435
+ let hooks = {};
220436
+ let searchParameters;
220437
+ const signals = [];
220438
+ for (const source of sources) {
220439
+ if (Array.isArray(source)) {
220440
+ if (!Array.isArray(returnValue)) {
220441
+ returnValue = [];
220442
+ }
220443
+ returnValue = [...returnValue, ...source];
220444
+ } else if (isObject(source)) {
220445
+ for (let [key, value] of Object.entries(source)) {
220446
+ if (key === "signal" && value instanceof globalThis.AbortSignal) {
220447
+ signals.push(value);
220448
+ continue;
220449
+ }
220450
+ if (key === "context") {
220451
+ if (value !== undefined && value !== null && (!isObject(value) || Array.isArray(value))) {
220452
+ throw new TypeError("The `context` option must be an object");
220453
+ }
220454
+ returnValue = {
220455
+ ...returnValue,
220456
+ context: value === undefined || value === null ? {} : { ...returnValue.context, ...value }
220457
+ };
220458
+ continue;
220459
+ }
220460
+ if (key === "searchParams") {
220461
+ if (value === undefined || value === null) {
220462
+ searchParameters = undefined;
220463
+ } else {
220464
+ searchParameters = searchParameters === undefined ? value : appendSearchParameters(searchParameters, value);
220465
+ }
220466
+ continue;
220467
+ }
220468
+ if (isObject(value) && key in returnValue) {
220469
+ value = deepMerge(returnValue[key], value);
220470
+ }
220471
+ returnValue = { ...returnValue, [key]: value };
220472
+ }
220473
+ if (isObject(source.hooks)) {
220474
+ hooks = mergeHooks(hooks, source.hooks);
220475
+ returnValue.hooks = hooks;
220476
+ }
220477
+ if (isObject(source.headers)) {
220478
+ headers = mergeHeaders(headers, source.headers);
220479
+ returnValue.headers = headers;
220480
+ }
220481
+ }
220482
+ }
220483
+ if (searchParameters !== undefined) {
220484
+ returnValue.searchParams = searchParameters;
220485
+ }
220486
+ if (signals.length > 0) {
220487
+ if (signals.length === 1) {
220488
+ returnValue.signal = signals[0];
220489
+ } else if (supportsAbortSignal) {
220490
+ returnValue.signal = AbortSignal.any(signals);
220491
+ } else {
220492
+ returnValue.signal = signals.at(-1);
220493
+ }
220494
+ }
220495
+ return returnValue;
220496
+ };
220497
+
220498
+ // ../../node_modules/ky/distribution/utils/normalize.js
220499
+ var normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
220500
+ var retryMethods = ["get", "put", "head", "delete", "options", "trace"];
220501
+ var retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
220502
+ var retryAfterStatusCodes = [413, 429, 503];
220503
+ var defaultRetryOptions = {
220504
+ limit: 2,
220505
+ methods: retryMethods,
220506
+ statusCodes: retryStatusCodes,
220507
+ afterStatusCodes: retryAfterStatusCodes,
220508
+ maxRetryAfter: Number.POSITIVE_INFINITY,
220509
+ backoffLimit: Number.POSITIVE_INFINITY,
220510
+ delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1000,
220511
+ jitter: undefined,
220512
+ retryOnTimeout: false
220513
+ };
220514
+ var normalizeRetryOptions = (retry2 = {}) => {
220515
+ if (typeof retry2 === "number") {
220516
+ return {
220517
+ ...defaultRetryOptions,
220518
+ limit: retry2
220519
+ };
220520
+ }
220521
+ if (retry2.methods && !Array.isArray(retry2.methods)) {
220522
+ throw new Error("retry.methods must be an array");
220523
+ }
220524
+ retry2.methods &&= retry2.methods.map((method) => method.toLowerCase());
220525
+ if (retry2.statusCodes && !Array.isArray(retry2.statusCodes)) {
220526
+ throw new Error("retry.statusCodes must be an array");
220527
+ }
220528
+ const normalizedRetry = Object.fromEntries(Object.entries(retry2).filter(([, value]) => value !== undefined));
220529
+ return {
220530
+ ...defaultRetryOptions,
220531
+ ...normalizedRetry
220532
+ };
220533
+ };
220534
+
220535
+ // ../../node_modules/ky/distribution/errors/TimeoutError.js
220536
+ class TimeoutError2 extends Error {
220537
+ request;
220538
+ constructor(request) {
220539
+ super(`Request timed out: ${request.method} ${request.url}`);
220540
+ this.name = "TimeoutError";
220541
+ this.request = request;
220542
+ }
220543
+ }
220544
+
220545
+ // ../../node_modules/ky/distribution/utils/timeout.js
220546
+ async function timeout(request, init, abortController, options) {
220547
+ return new Promise((resolve, reject) => {
220548
+ const timeoutId = setTimeout(() => {
220549
+ if (abortController) {
220550
+ abortController.abort();
220551
+ }
220552
+ reject(new TimeoutError2(request));
220553
+ }, options.timeout);
220554
+ options.fetch(request, init).then(resolve).catch(reject).then(() => {
220555
+ clearTimeout(timeoutId);
220556
+ });
220557
+ });
220558
+ }
220559
+
220560
+ // ../../node_modules/ky/distribution/utils/delay.js
220561
+ async function delay(ms, { signal }) {
220562
+ return new Promise((resolve, reject) => {
220563
+ if (signal) {
220564
+ signal.throwIfAborted();
220565
+ signal.addEventListener("abort", abortHandler, { once: true });
220566
+ }
220567
+ function abortHandler() {
220568
+ clearTimeout(timeoutId);
220569
+ reject(signal.reason);
220570
+ }
220571
+ const timeoutId = setTimeout(() => {
220572
+ signal?.removeEventListener("abort", abortHandler);
220573
+ resolve();
220574
+ }, ms);
220575
+ });
220576
+ }
220577
+
220578
+ // ../../node_modules/ky/distribution/utils/options.js
220579
+ var findUnknownOptions = (request, options) => {
220580
+ const unknownOptions = {};
220581
+ for (const key in options) {
220582
+ if (!Object.hasOwn(options, key)) {
220583
+ continue;
220584
+ }
220585
+ if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && (!(key in request) || (key in vendorSpecificOptions))) {
220586
+ unknownOptions[key] = options[key];
220587
+ }
220588
+ }
220589
+ return unknownOptions;
220590
+ };
220591
+ var hasSearchParameters = (search) => {
220592
+ if (search === undefined) {
220593
+ return false;
220594
+ }
220595
+ if (Array.isArray(search)) {
220596
+ return search.length > 0;
220597
+ }
220598
+ if (search instanceof URLSearchParams) {
220599
+ return search.size > 0;
220600
+ }
220601
+ if (typeof search === "object") {
220602
+ return Object.keys(search).length > 0;
220603
+ }
220604
+ if (typeof search === "string") {
220605
+ return search.trim().length > 0;
220606
+ }
220607
+ return Boolean(search);
220608
+ };
220609
+
220610
+ // ../../node_modules/ky/distribution/utils/type-guards.js
220611
+ function isHTTPError(error) {
220612
+ return error instanceof HTTPError || error?.name === HTTPError.name;
220613
+ }
220614
+ function isTimeoutError(error) {
220615
+ return error instanceof TimeoutError2 || error?.name === TimeoutError2.name;
220616
+ }
220617
+
220618
+ // ../../node_modules/ky/distribution/core/Ky.js
220619
+ class Ky {
220620
+ static create(input, options) {
220621
+ const ky = new Ky(input, options);
220622
+ const function_ = async () => {
220623
+ if (typeof ky.#options.timeout === "number" && ky.#options.timeout > maxSafeTimeout) {
220624
+ throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
220625
+ }
220626
+ await Promise.resolve();
220627
+ let response = await ky.#fetch();
220628
+ for (const hook of ky.#options.hooks.afterResponse) {
220629
+ const clonedResponse = ky.#decorateResponse(response.clone());
220630
+ let modifiedResponse;
220631
+ try {
220632
+ modifiedResponse = await hook(ky.request, ky.#getNormalizedOptions(), clonedResponse, { retryCount: ky.#retryCount });
220633
+ } catch (error) {
220634
+ ky.#cancelResponseBody(clonedResponse);
220635
+ ky.#cancelResponseBody(response);
220636
+ throw error;
220637
+ }
220638
+ if (modifiedResponse instanceof RetryMarker) {
220639
+ ky.#cancelResponseBody(clonedResponse);
220640
+ ky.#cancelResponseBody(response);
220641
+ throw new ForceRetryError(modifiedResponse.options);
220642
+ }
220643
+ const nextResponse = modifiedResponse instanceof globalThis.Response ? modifiedResponse : response;
220644
+ if (clonedResponse !== nextResponse) {
220645
+ ky.#cancelResponseBody(clonedResponse);
220646
+ }
220647
+ if (response !== nextResponse) {
220648
+ ky.#cancelResponseBody(response);
220649
+ }
220650
+ response = nextResponse;
220651
+ }
220652
+ ky.#decorateResponse(response);
220653
+ if (!response.ok && (typeof ky.#options.throwHttpErrors === "function" ? ky.#options.throwHttpErrors(response.status) : ky.#options.throwHttpErrors)) {
220654
+ let error = new HTTPError(response, ky.request, ky.#getNormalizedOptions());
220655
+ for (const hook of ky.#options.hooks.beforeError) {
220656
+ error = await hook(error, { retryCount: ky.#retryCount });
220657
+ }
220658
+ throw error;
220659
+ }
220660
+ if (ky.#options.onDownloadProgress) {
220661
+ if (typeof ky.#options.onDownloadProgress !== "function") {
220662
+ throw new TypeError("The `onDownloadProgress` option must be a function");
220663
+ }
220664
+ if (!supportsResponseStreams) {
220665
+ throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
220666
+ }
220667
+ const progressResponse = response.clone();
220668
+ ky.#cancelResponseBody(response);
220669
+ return streamResponse(progressResponse, ky.#options.onDownloadProgress);
220670
+ }
220671
+ return response;
220672
+ };
220673
+ const result = ky.#retry(function_).finally(() => {
220674
+ const originalRequest = ky.#originalRequest;
220675
+ ky.#cancelBody(originalRequest?.body ?? undefined);
220676
+ ky.#cancelBody(ky.request.body ?? undefined);
220677
+ });
220678
+ for (const [type, mimeType] of Object.entries(responseTypes)) {
220679
+ if (type === "bytes" && typeof globalThis.Response?.prototype?.bytes !== "function") {
220680
+ continue;
220681
+ }
220682
+ result[type] = async () => {
220683
+ ky.request.headers.set("accept", ky.request.headers.get("accept") || mimeType);
220684
+ const response = await result;
220685
+ if (type === "json") {
220686
+ if (response.status === 204) {
220687
+ return "";
220688
+ }
220689
+ const text = await response.text();
220690
+ if (text === "") {
220691
+ return "";
220692
+ }
220693
+ if (options.parseJson) {
220694
+ return options.parseJson(text);
220695
+ }
220696
+ return JSON.parse(text);
220697
+ }
220698
+ return response[type]();
220699
+ };
220700
+ }
220701
+ return result;
220702
+ }
220703
+ static #normalizeSearchParams(searchParams) {
220704
+ if (searchParams && typeof searchParams === "object" && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) {
220705
+ return Object.fromEntries(Object.entries(searchParams).filter(([, value]) => value !== undefined));
220706
+ }
220707
+ return searchParams;
220708
+ }
220709
+ request;
220710
+ #abortController;
220711
+ #retryCount = 0;
220712
+ #input;
220713
+ #options;
220714
+ #originalRequest;
220715
+ #userProvidedAbortSignal;
220716
+ #cachedNormalizedOptions;
220717
+ constructor(input, options = {}) {
220718
+ this.#input = input;
220719
+ this.#options = {
220720
+ ...options,
220721
+ headers: mergeHeaders(this.#input.headers, options.headers),
220722
+ hooks: mergeHooks({
220723
+ beforeRequest: [],
220724
+ beforeRetry: [],
220725
+ beforeError: [],
220726
+ afterResponse: []
220727
+ }, options.hooks),
220728
+ method: normalizeRequestMethod(options.method ?? this.#input.method ?? "GET"),
220729
+ prefixUrl: String(options.prefixUrl || ""),
220730
+ retry: normalizeRetryOptions(options.retry),
220731
+ throwHttpErrors: options.throwHttpErrors ?? true,
220732
+ timeout: options.timeout ?? 1e4,
220733
+ fetch: options.fetch ?? globalThis.fetch.bind(globalThis),
220734
+ context: options.context ?? {}
220735
+ };
220736
+ if (typeof this.#input !== "string" && !(this.#input instanceof URL || this.#input instanceof globalThis.Request)) {
220737
+ throw new TypeError("`input` must be a string, URL, or Request");
220738
+ }
220739
+ if (this.#options.prefixUrl && typeof this.#input === "string") {
220740
+ if (this.#input.startsWith("/")) {
220741
+ throw new Error("`input` must not begin with a slash when using `prefixUrl`");
220742
+ }
220743
+ if (!this.#options.prefixUrl.endsWith("/")) {
220744
+ this.#options.prefixUrl += "/";
220745
+ }
220746
+ this.#input = this.#options.prefixUrl + this.#input;
220747
+ }
220748
+ if (supportsAbortController && supportsAbortSignal) {
220749
+ this.#userProvidedAbortSignal = this.#options.signal ?? this.#input.signal;
220750
+ this.#abortController = new globalThis.AbortController;
220751
+ this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
220752
+ }
220753
+ if (supportsRequestStreams) {
220754
+ this.#options.duplex = "half";
220755
+ }
220756
+ if (this.#options.json !== undefined) {
220757
+ this.#options.body = this.#options.stringifyJson?.(this.#options.json) ?? JSON.stringify(this.#options.json);
220758
+ this.#options.headers.set("content-type", this.#options.headers.get("content-type") ?? "application/json");
220759
+ }
220760
+ const userProvidedContentType = options.headers && new globalThis.Headers(options.headers).has("content-type");
220761
+ if (this.#input instanceof globalThis.Request && (supportsFormData && this.#options.body instanceof globalThis.FormData || this.#options.body instanceof URLSearchParams) && !userProvidedContentType) {
220762
+ this.#options.headers.delete("content-type");
220763
+ }
220764
+ this.request = new globalThis.Request(this.#input, this.#options);
220765
+ if (hasSearchParameters(this.#options.searchParams)) {
220766
+ const textSearchParams = typeof this.#options.searchParams === "string" ? this.#options.searchParams.replace(/^\?/, "") : new URLSearchParams(Ky.#normalizeSearchParams(this.#options.searchParams)).toString();
220767
+ const searchParams = "?" + textSearchParams;
220768
+ const url = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
220769
+ this.request = new globalThis.Request(url, this.#options);
220770
+ }
220771
+ if (this.#options.onUploadProgress) {
220772
+ if (typeof this.#options.onUploadProgress !== "function") {
220773
+ throw new TypeError("The `onUploadProgress` option must be a function");
220774
+ }
220775
+ if (!supportsRequestStreams) {
220776
+ throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
220777
+ }
220778
+ this.request = this.#wrapRequestWithUploadProgress(this.request, this.#options.body ?? undefined);
220779
+ }
220780
+ }
220781
+ #calculateDelay() {
220782
+ const retryDelay = this.#options.retry.delay(this.#retryCount);
220783
+ let jitteredDelay = retryDelay;
220784
+ if (this.#options.retry.jitter === true) {
220785
+ jitteredDelay = Math.random() * retryDelay;
220786
+ } else if (typeof this.#options.retry.jitter === "function") {
220787
+ jitteredDelay = this.#options.retry.jitter(retryDelay);
220788
+ if (!Number.isFinite(jitteredDelay) || jitteredDelay < 0) {
220789
+ jitteredDelay = retryDelay;
220790
+ }
220791
+ }
220792
+ const backoffLimit = this.#options.retry.backoffLimit ?? Number.POSITIVE_INFINITY;
220793
+ return Math.min(backoffLimit, jitteredDelay);
220794
+ }
220795
+ async#calculateRetryDelay(error) {
220796
+ this.#retryCount++;
220797
+ if (this.#retryCount > this.#options.retry.limit) {
220798
+ throw error;
220799
+ }
220800
+ const errorObject = error instanceof Error ? error : new NonError(error);
220801
+ if (errorObject instanceof ForceRetryError) {
220802
+ return errorObject.customDelay ?? this.#calculateDelay();
220803
+ }
220804
+ if (!this.#options.retry.methods.includes(this.request.method.toLowerCase())) {
220805
+ throw error;
220806
+ }
220807
+ if (this.#options.retry.shouldRetry !== undefined) {
220808
+ const result = await this.#options.retry.shouldRetry({ error: errorObject, retryCount: this.#retryCount });
220809
+ if (result === false) {
220810
+ throw error;
220811
+ }
220812
+ if (result === true) {
220813
+ return this.#calculateDelay();
220814
+ }
220815
+ }
220816
+ if (isTimeoutError(error) && !this.#options.retry.retryOnTimeout) {
220817
+ throw error;
220818
+ }
220819
+ if (isHTTPError(error)) {
220820
+ if (!this.#options.retry.statusCodes.includes(error.response.status)) {
220821
+ throw error;
220822
+ }
220823
+ 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");
220824
+ if (retryAfter && this.#options.retry.afterStatusCodes.includes(error.response.status)) {
220825
+ let after = Number(retryAfter) * 1000;
220826
+ if (Number.isNaN(after)) {
220827
+ after = Date.parse(retryAfter) - Date.now();
220828
+ } else if (after >= Date.parse("2024-01-01")) {
220829
+ after -= Date.now();
220830
+ }
220831
+ const max = this.#options.retry.maxRetryAfter ?? after;
220832
+ return after < max ? after : max;
220833
+ }
220834
+ if (error.response.status === 413) {
220835
+ throw error;
220836
+ }
220837
+ }
220838
+ return this.#calculateDelay();
220839
+ }
220840
+ #decorateResponse(response) {
220841
+ if (this.#options.parseJson) {
220842
+ response.json = async () => this.#options.parseJson(await response.text());
220843
+ }
220844
+ return response;
220845
+ }
220846
+ #cancelBody(body) {
220847
+ if (!body) {
220848
+ return;
220849
+ }
220850
+ body.cancel().catch(() => {
220851
+ return;
220852
+ });
220853
+ }
220854
+ #cancelResponseBody(response) {
220855
+ this.#cancelBody(response.body ?? undefined);
220856
+ }
220857
+ async#retry(function_) {
220858
+ try {
220859
+ return await function_();
220860
+ } catch (error) {
220861
+ const ms = Math.min(await this.#calculateRetryDelay(error), maxSafeTimeout);
220862
+ if (this.#retryCount < 1) {
220863
+ throw error;
220864
+ }
220865
+ await delay(ms, this.#userProvidedAbortSignal ? { signal: this.#userProvidedAbortSignal } : {});
220866
+ if (error instanceof ForceRetryError && error.customRequest) {
220867
+ const managedRequest = this.#options.signal ? new globalThis.Request(error.customRequest, { signal: this.#options.signal }) : new globalThis.Request(error.customRequest);
220868
+ this.#assignRequest(managedRequest);
220869
+ }
220870
+ for (const hook of this.#options.hooks.beforeRetry) {
220871
+ const hookResult = await hook({
220872
+ request: this.request,
220873
+ options: this.#getNormalizedOptions(),
220874
+ error,
220875
+ retryCount: this.#retryCount
220876
+ });
220877
+ if (hookResult instanceof globalThis.Request) {
220878
+ this.#assignRequest(hookResult);
220879
+ break;
220880
+ }
220881
+ if (hookResult instanceof globalThis.Response) {
220882
+ return hookResult;
220883
+ }
220884
+ if (hookResult === stop) {
220885
+ return;
220886
+ }
220887
+ }
220888
+ return this.#retry(function_);
220889
+ }
220890
+ }
220891
+ async#fetch() {
220892
+ if (this.#abortController?.signal.aborted) {
220893
+ this.#abortController = new globalThis.AbortController;
220894
+ this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
220895
+ this.request = new globalThis.Request(this.request, { signal: this.#options.signal });
220896
+ }
220897
+ for (const hook of this.#options.hooks.beforeRequest) {
220898
+ const result = await hook(this.request, this.#getNormalizedOptions(), { retryCount: this.#retryCount });
220899
+ if (result instanceof Response) {
220900
+ return result;
220901
+ }
220902
+ if (result instanceof globalThis.Request) {
220903
+ this.#assignRequest(result);
220904
+ break;
220905
+ }
220906
+ }
220907
+ const nonRequestOptions = findUnknownOptions(this.request, this.#options);
220908
+ this.#originalRequest = this.request;
220909
+ this.request = this.#originalRequest.clone();
220910
+ if (this.#options.timeout === false) {
220911
+ return this.#options.fetch(this.#originalRequest, nonRequestOptions);
220912
+ }
220913
+ return timeout(this.#originalRequest, nonRequestOptions, this.#abortController, this.#options);
220914
+ }
220915
+ #getNormalizedOptions() {
220916
+ if (!this.#cachedNormalizedOptions) {
220917
+ const { hooks, ...normalizedOptions } = this.#options;
220918
+ this.#cachedNormalizedOptions = Object.freeze(normalizedOptions);
220919
+ }
220920
+ return this.#cachedNormalizedOptions;
220921
+ }
220922
+ #assignRequest(request) {
220923
+ this.#cachedNormalizedOptions = undefined;
220924
+ this.request = this.#wrapRequestWithUploadProgress(request);
220925
+ }
220926
+ #wrapRequestWithUploadProgress(request, originalBody) {
220927
+ if (!this.#options.onUploadProgress || !request.body) {
220928
+ return request;
220929
+ }
220930
+ return streamRequest(request, this.#options.onUploadProgress, originalBody ?? this.#options.body ?? undefined);
220931
+ }
220932
+ }
220933
+ // ../../node_modules/ky/distribution/index.js
220934
+ /*! MIT License © Sindre Sorhus */
220935
+ var createInstance = (defaults) => {
220936
+ const ky = (input, options) => Ky.create(input, validateAndMerge(defaults, options));
220937
+ for (const method of requestMethods) {
220938
+ ky[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));
220939
+ }
220940
+ ky.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));
220941
+ ky.extend = (newDefaults) => {
220942
+ if (typeof newDefaults === "function") {
220943
+ newDefaults = newDefaults(defaults ?? {});
220944
+ }
220945
+ return createInstance(validateAndMerge(defaults, newDefaults));
220946
+ };
220947
+ ky.stop = stop;
220948
+ ky.retry = retry;
220949
+ return ky;
220950
+ };
220951
+ var ky = createInstance();
220952
+ var distribution_default = ky;
220953
+
220135
220954
  // ../../node_modules/zod/v4/classic/external.js
220136
220955
  var exports_external = {};
220137
220956
  __export(exports_external, {
@@ -220759,7 +221578,7 @@ __export(exports_util, {
220759
221578
  joinValues: () => joinValues,
220760
221579
  issue: () => issue,
220761
221580
  isPlainObject: () => isPlainObject,
220762
- isObject: () => isObject,
221581
+ isObject: () => isObject2,
220763
221582
  hexToUint8Array: () => hexToUint8Array,
220764
221583
  getSizableOrigin: () => getSizableOrigin,
220765
221584
  getParsedType: () => getParsedType,
@@ -220928,7 +221747,7 @@ function slugify(input) {
220928
221747
  return input.toLowerCase().trim().replace(/[^\w\s-]/g, "").replace(/[\s_-]+/g, "-").replace(/^-+|-+$/g, "");
220929
221748
  }
220930
221749
  var captureStackTrace = "captureStackTrace" in Error ? Error.captureStackTrace : (..._args) => {};
220931
- function isObject(data) {
221750
+ function isObject2(data) {
220932
221751
  return typeof data === "object" && data !== null && !Array.isArray(data);
220933
221752
  }
220934
221753
  var allowsEval = cached(() => {
@@ -220944,7 +221763,7 @@ var allowsEval = cached(() => {
220944
221763
  }
220945
221764
  });
220946
221765
  function isPlainObject(o) {
220947
- if (isObject(o) === false)
221766
+ if (isObject2(o) === false)
220948
221767
  return false;
220949
221768
  const ctor = o.constructor;
220950
221769
  if (ctor === undefined)
@@ -220952,7 +221771,7 @@ function isPlainObject(o) {
220952
221771
  if (typeof ctor !== "function")
220953
221772
  return true;
220954
221773
  const prot = ctor.prototype;
220955
- if (isObject(prot) === false)
221774
+ if (isObject2(prot) === false)
220956
221775
  return false;
220957
221776
  if (Object.prototype.hasOwnProperty.call(prot, "isPrototypeOf") === false) {
220958
221777
  return false;
@@ -223105,13 +223924,13 @@ var $ZodObject = /* @__PURE__ */ $constructor("$ZodObject", (inst, def) => {
223105
223924
  }
223106
223925
  return propValues;
223107
223926
  });
223108
- const isObject2 = isObject;
223927
+ const isObject3 = isObject2;
223109
223928
  const catchall = def.catchall;
223110
223929
  let value;
223111
223930
  inst._zod.parse = (payload, ctx) => {
223112
223931
  value ?? (value = _normalized.value);
223113
223932
  const input = payload.value;
223114
- if (!isObject2(input)) {
223933
+ if (!isObject3(input)) {
223115
223934
  payload.issues.push({
223116
223935
  expected: "object",
223117
223936
  code: "invalid_type",
@@ -223209,7 +224028,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
223209
224028
  return (payload, ctx) => fn(shape, payload, ctx);
223210
224029
  };
223211
224030
  let fastpass;
223212
- const isObject2 = isObject;
224031
+ const isObject3 = isObject2;
223213
224032
  const jit = !globalConfig.jitless;
223214
224033
  const allowsEval2 = allowsEval;
223215
224034
  const fastEnabled = jit && allowsEval2.value;
@@ -223218,7 +224037,7 @@ var $ZodObjectJIT = /* @__PURE__ */ $constructor("$ZodObjectJIT", (inst, def) =>
223218
224037
  inst._zod.parse = (payload, ctx) => {
223219
224038
  value ?? (value = _normalized.value);
223220
224039
  const input = payload.value;
223221
- if (!isObject2(input)) {
224040
+ if (!isObject3(input)) {
223222
224041
  payload.issues.push({
223223
224042
  expected: "object",
223224
224043
  code: "invalid_type",
@@ -223396,7 +224215,7 @@ var $ZodDiscriminatedUnion = /* @__PURE__ */ $constructor("$ZodDiscriminatedUnio
223396
224215
  });
223397
224216
  inst._zod.parse = (payload, ctx) => {
223398
224217
  const input = payload.value;
223399
- if (!isObject(input)) {
224218
+ if (!isObject2(input)) {
223400
224219
  payload.issues.push({
223401
224220
  code: "invalid_type",
223402
224221
  expected: "object",
@@ -233243,1291 +234062,783 @@ var RECOGNIZED_KEYS = new Set([
233243
234062
  ]);
233244
234063
  function detectVersion(schema, defaultTarget) {
233245
234064
  const $schema = schema.$schema;
233246
- if ($schema === "https://json-schema.org/draft/2020-12/schema") {
233247
- return "draft-2020-12";
233248
- }
233249
- if ($schema === "http://json-schema.org/draft-07/schema#") {
233250
- return "draft-7";
233251
- }
233252
- if ($schema === "http://json-schema.org/draft-04/schema#") {
233253
- return "draft-4";
233254
- }
233255
- return defaultTarget ?? "draft-2020-12";
233256
- }
233257
- function resolveRef(ref, ctx) {
233258
- if (!ref.startsWith("#")) {
233259
- throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
233260
- }
233261
- const path = ref.slice(1).split("/").filter(Boolean);
233262
- if (path.length === 0) {
233263
- return ctx.rootSchema;
233264
- }
233265
- const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
233266
- if (path[0] === defsKey) {
233267
- const key = path[1];
233268
- if (!key || !ctx.defs[key]) {
233269
- throw new Error(`Reference not found: ${ref}`);
233270
- }
233271
- return ctx.defs[key];
233272
- }
233273
- throw new Error(`Reference not found: ${ref}`);
233274
- }
233275
- function convertBaseSchema(schema, ctx) {
233276
- if (schema.not !== undefined) {
233277
- if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
233278
- return z2.never();
233279
- }
233280
- throw new Error("not is not supported in Zod (except { not: {} } for never)");
233281
- }
233282
- if (schema.unevaluatedItems !== undefined) {
233283
- throw new Error("unevaluatedItems is not supported");
233284
- }
233285
- if (schema.unevaluatedProperties !== undefined) {
233286
- throw new Error("unevaluatedProperties is not supported");
233287
- }
233288
- if (schema.if !== undefined || schema.then !== undefined || schema.else !== undefined) {
233289
- throw new Error("Conditional schemas (if/then/else) are not supported");
233290
- }
233291
- if (schema.dependentSchemas !== undefined || schema.dependentRequired !== undefined) {
233292
- throw new Error("dependentSchemas and dependentRequired are not supported");
233293
- }
233294
- if (schema.$ref) {
233295
- const refPath = schema.$ref;
233296
- if (ctx.refs.has(refPath)) {
233297
- return ctx.refs.get(refPath);
233298
- }
233299
- if (ctx.processing.has(refPath)) {
233300
- return z2.lazy(() => {
233301
- if (!ctx.refs.has(refPath)) {
233302
- throw new Error(`Circular reference not resolved: ${refPath}`);
233303
- }
233304
- return ctx.refs.get(refPath);
233305
- });
233306
- }
233307
- ctx.processing.add(refPath);
233308
- const resolved = resolveRef(refPath, ctx);
233309
- const zodSchema2 = convertSchema(resolved, ctx);
233310
- ctx.refs.set(refPath, zodSchema2);
233311
- ctx.processing.delete(refPath);
233312
- return zodSchema2;
233313
- }
233314
- if (schema.enum !== undefined) {
233315
- const enumValues = schema.enum;
233316
- if (ctx.version === "openapi-3.0" && schema.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
233317
- return z2.null();
233318
- }
233319
- if (enumValues.length === 0) {
233320
- return z2.never();
233321
- }
233322
- if (enumValues.length === 1) {
233323
- return z2.literal(enumValues[0]);
233324
- }
233325
- if (enumValues.every((v) => typeof v === "string")) {
233326
- return z2.enum(enumValues);
233327
- }
233328
- const literalSchemas = enumValues.map((v) => z2.literal(v));
233329
- if (literalSchemas.length < 2) {
233330
- return literalSchemas[0];
233331
- }
233332
- return z2.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
233333
- }
233334
- if (schema.const !== undefined) {
233335
- return z2.literal(schema.const);
233336
- }
233337
- const type = schema.type;
233338
- if (Array.isArray(type)) {
233339
- const typeSchemas = type.map((t) => {
233340
- const typeSchema = { ...schema, type: t };
233341
- return convertBaseSchema(typeSchema, ctx);
233342
- });
233343
- if (typeSchemas.length === 0) {
233344
- return z2.never();
233345
- }
233346
- if (typeSchemas.length === 1) {
233347
- return typeSchemas[0];
233348
- }
233349
- return z2.union(typeSchemas);
233350
- }
233351
- if (!type) {
233352
- return z2.any();
233353
- }
233354
- let zodSchema;
233355
- switch (type) {
233356
- case "string": {
233357
- let stringSchema = z2.string();
233358
- if (schema.format) {
233359
- const format = schema.format;
233360
- if (format === "email") {
233361
- stringSchema = stringSchema.check(z2.email());
233362
- } else if (format === "uri" || format === "uri-reference") {
233363
- stringSchema = stringSchema.check(z2.url());
233364
- } else if (format === "uuid" || format === "guid") {
233365
- stringSchema = stringSchema.check(z2.uuid());
233366
- } else if (format === "date-time") {
233367
- stringSchema = stringSchema.check(z2.iso.datetime());
233368
- } else if (format === "date") {
233369
- stringSchema = stringSchema.check(z2.iso.date());
233370
- } else if (format === "time") {
233371
- stringSchema = stringSchema.check(z2.iso.time());
233372
- } else if (format === "duration") {
233373
- stringSchema = stringSchema.check(z2.iso.duration());
233374
- } else if (format === "ipv4") {
233375
- stringSchema = stringSchema.check(z2.ipv4());
233376
- } else if (format === "ipv6") {
233377
- stringSchema = stringSchema.check(z2.ipv6());
233378
- } else if (format === "mac") {
233379
- stringSchema = stringSchema.check(z2.mac());
233380
- } else if (format === "cidr") {
233381
- stringSchema = stringSchema.check(z2.cidrv4());
233382
- } else if (format === "cidr-v6") {
233383
- stringSchema = stringSchema.check(z2.cidrv6());
233384
- } else if (format === "base64") {
233385
- stringSchema = stringSchema.check(z2.base64());
233386
- } else if (format === "base64url") {
233387
- stringSchema = stringSchema.check(z2.base64url());
233388
- } else if (format === "e164") {
233389
- stringSchema = stringSchema.check(z2.e164());
233390
- } else if (format === "jwt") {
233391
- stringSchema = stringSchema.check(z2.jwt());
233392
- } else if (format === "emoji") {
233393
- stringSchema = stringSchema.check(z2.emoji());
233394
- } else if (format === "nanoid") {
233395
- stringSchema = stringSchema.check(z2.nanoid());
233396
- } else if (format === "cuid") {
233397
- stringSchema = stringSchema.check(z2.cuid());
233398
- } else if (format === "cuid2") {
233399
- stringSchema = stringSchema.check(z2.cuid2());
233400
- } else if (format === "ulid") {
233401
- stringSchema = stringSchema.check(z2.ulid());
233402
- } else if (format === "xid") {
233403
- stringSchema = stringSchema.check(z2.xid());
233404
- } else if (format === "ksuid") {
233405
- stringSchema = stringSchema.check(z2.ksuid());
233406
- }
233407
- }
233408
- if (typeof schema.minLength === "number") {
233409
- stringSchema = stringSchema.min(schema.minLength);
233410
- }
233411
- if (typeof schema.maxLength === "number") {
233412
- stringSchema = stringSchema.max(schema.maxLength);
233413
- }
233414
- if (schema.pattern) {
233415
- stringSchema = stringSchema.regex(new RegExp(schema.pattern));
233416
- }
233417
- zodSchema = stringSchema;
233418
- break;
233419
- }
233420
- case "number":
233421
- case "integer": {
233422
- let numberSchema = type === "integer" ? z2.number().int() : z2.number();
233423
- if (typeof schema.minimum === "number") {
233424
- numberSchema = numberSchema.min(schema.minimum);
233425
- }
233426
- if (typeof schema.maximum === "number") {
233427
- numberSchema = numberSchema.max(schema.maximum);
233428
- }
233429
- if (typeof schema.exclusiveMinimum === "number") {
233430
- numberSchema = numberSchema.gt(schema.exclusiveMinimum);
233431
- } else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
233432
- numberSchema = numberSchema.gt(schema.minimum);
233433
- }
233434
- if (typeof schema.exclusiveMaximum === "number") {
233435
- numberSchema = numberSchema.lt(schema.exclusiveMaximum);
233436
- } else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
233437
- numberSchema = numberSchema.lt(schema.maximum);
233438
- }
233439
- if (typeof schema.multipleOf === "number") {
233440
- numberSchema = numberSchema.multipleOf(schema.multipleOf);
233441
- }
233442
- zodSchema = numberSchema;
233443
- break;
233444
- }
233445
- case "boolean": {
233446
- zodSchema = z2.boolean();
233447
- break;
233448
- }
233449
- case "null": {
233450
- zodSchema = z2.null();
233451
- break;
233452
- }
233453
- case "object": {
233454
- const shape = {};
233455
- const properties = schema.properties || {};
233456
- const requiredSet = new Set(schema.required || []);
233457
- for (const [key, propSchema] of Object.entries(properties)) {
233458
- const propZodSchema = convertSchema(propSchema, ctx);
233459
- shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
233460
- }
233461
- if (schema.propertyNames) {
233462
- const keySchema = convertSchema(schema.propertyNames, ctx);
233463
- const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z2.any();
233464
- if (Object.keys(shape).length === 0) {
233465
- zodSchema = z2.record(keySchema, valueSchema);
233466
- break;
233467
- }
233468
- const objectSchema2 = z2.object(shape).passthrough();
233469
- const recordSchema = z2.looseRecord(keySchema, valueSchema);
233470
- zodSchema = z2.intersection(objectSchema2, recordSchema);
233471
- break;
233472
- }
233473
- if (schema.patternProperties) {
233474
- const patternProps = schema.patternProperties;
233475
- const patternKeys = Object.keys(patternProps);
233476
- const looseRecords = [];
233477
- for (const pattern of patternKeys) {
233478
- const patternValue = convertSchema(patternProps[pattern], ctx);
233479
- const keySchema = z2.string().regex(new RegExp(pattern));
233480
- looseRecords.push(z2.looseRecord(keySchema, patternValue));
233481
- }
233482
- const schemasToIntersect = [];
233483
- if (Object.keys(shape).length > 0) {
233484
- schemasToIntersect.push(z2.object(shape).passthrough());
233485
- }
233486
- schemasToIntersect.push(...looseRecords);
233487
- if (schemasToIntersect.length === 0) {
233488
- zodSchema = z2.object({}).passthrough();
233489
- } else if (schemasToIntersect.length === 1) {
233490
- zodSchema = schemasToIntersect[0];
233491
- } else {
233492
- let result = z2.intersection(schemasToIntersect[0], schemasToIntersect[1]);
233493
- for (let i = 2;i < schemasToIntersect.length; i++) {
233494
- result = z2.intersection(result, schemasToIntersect[i]);
233495
- }
233496
- zodSchema = result;
233497
- }
233498
- break;
233499
- }
233500
- const objectSchema = z2.object(shape);
233501
- if (schema.additionalProperties === false) {
233502
- zodSchema = objectSchema.strict();
233503
- } else if (typeof schema.additionalProperties === "object") {
233504
- zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
233505
- } else {
233506
- zodSchema = objectSchema.passthrough();
233507
- }
233508
- break;
233509
- }
233510
- case "array": {
233511
- const prefixItems = schema.prefixItems;
233512
- const items = schema.items;
233513
- if (prefixItems && Array.isArray(prefixItems)) {
233514
- const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
233515
- const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : undefined;
233516
- if (rest) {
233517
- zodSchema = z2.tuple(tupleItems).rest(rest);
233518
- } else {
233519
- zodSchema = z2.tuple(tupleItems);
233520
- }
233521
- if (typeof schema.minItems === "number") {
233522
- zodSchema = zodSchema.check(z2.minLength(schema.minItems));
233523
- }
233524
- if (typeof schema.maxItems === "number") {
233525
- zodSchema = zodSchema.check(z2.maxLength(schema.maxItems));
233526
- }
233527
- } else if (Array.isArray(items)) {
233528
- const tupleItems = items.map((item) => convertSchema(item, ctx));
233529
- const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : undefined;
233530
- if (rest) {
233531
- zodSchema = z2.tuple(tupleItems).rest(rest);
233532
- } else {
233533
- zodSchema = z2.tuple(tupleItems);
233534
- }
233535
- if (typeof schema.minItems === "number") {
233536
- zodSchema = zodSchema.check(z2.minLength(schema.minItems));
233537
- }
233538
- if (typeof schema.maxItems === "number") {
233539
- zodSchema = zodSchema.check(z2.maxLength(schema.maxItems));
233540
- }
233541
- } else if (items !== undefined) {
233542
- const element = convertSchema(items, ctx);
233543
- let arraySchema = z2.array(element);
233544
- if (typeof schema.minItems === "number") {
233545
- arraySchema = arraySchema.min(schema.minItems);
233546
- }
233547
- if (typeof schema.maxItems === "number") {
233548
- arraySchema = arraySchema.max(schema.maxItems);
233549
- }
233550
- zodSchema = arraySchema;
233551
- } else {
233552
- zodSchema = z2.array(z2.any());
233553
- }
233554
- break;
233555
- }
233556
- default:
233557
- throw new Error(`Unsupported type: ${type}`);
234065
+ if ($schema === "https://json-schema.org/draft/2020-12/schema") {
234066
+ return "draft-2020-12";
233558
234067
  }
233559
- if (schema.description) {
233560
- zodSchema = zodSchema.describe(schema.description);
234068
+ if ($schema === "http://json-schema.org/draft-07/schema#") {
234069
+ return "draft-7";
233561
234070
  }
233562
- if (schema.default !== undefined) {
233563
- zodSchema = zodSchema.default(schema.default);
234071
+ if ($schema === "http://json-schema.org/draft-04/schema#") {
234072
+ return "draft-4";
233564
234073
  }
233565
- return zodSchema;
234074
+ return defaultTarget ?? "draft-2020-12";
233566
234075
  }
233567
- function convertSchema(schema, ctx) {
233568
- if (typeof schema === "boolean") {
233569
- return schema ? z2.any() : z2.never();
233570
- }
233571
- let baseSchema = convertBaseSchema(schema, ctx);
233572
- const hasExplicitType = schema.type || schema.enum !== undefined || schema.const !== undefined;
233573
- if (schema.anyOf && Array.isArray(schema.anyOf)) {
233574
- const options = schema.anyOf.map((s) => convertSchema(s, ctx));
233575
- const anyOfUnion = z2.union(options);
233576
- baseSchema = hasExplicitType ? z2.intersection(baseSchema, anyOfUnion) : anyOfUnion;
233577
- }
233578
- if (schema.oneOf && Array.isArray(schema.oneOf)) {
233579
- const options = schema.oneOf.map((s) => convertSchema(s, ctx));
233580
- const oneOfUnion = z2.xor(options);
233581
- baseSchema = hasExplicitType ? z2.intersection(baseSchema, oneOfUnion) : oneOfUnion;
233582
- }
233583
- if (schema.allOf && Array.isArray(schema.allOf)) {
233584
- if (schema.allOf.length === 0) {
233585
- baseSchema = hasExplicitType ? baseSchema : z2.any();
233586
- } else {
233587
- let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
233588
- const startIdx = hasExplicitType ? 0 : 1;
233589
- for (let i = startIdx;i < schema.allOf.length; i++) {
233590
- result = z2.intersection(result, convertSchema(schema.allOf[i], ctx));
233591
- }
233592
- baseSchema = result;
233593
- }
233594
- }
233595
- if (schema.nullable === true && ctx.version === "openapi-3.0") {
233596
- baseSchema = z2.nullable(baseSchema);
233597
- }
233598
- if (schema.readOnly === true) {
233599
- baseSchema = z2.readonly(baseSchema);
234076
+ function resolveRef(ref, ctx) {
234077
+ if (!ref.startsWith("#")) {
234078
+ throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
233600
234079
  }
233601
- const extraMeta = {};
233602
- const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
233603
- for (const key of coreMetadataKeys) {
233604
- if (key in schema) {
233605
- extraMeta[key] = schema[key];
233606
- }
234080
+ const path = ref.slice(1).split("/").filter(Boolean);
234081
+ if (path.length === 0) {
234082
+ return ctx.rootSchema;
233607
234083
  }
233608
- const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
233609
- for (const key of contentMetadataKeys) {
233610
- if (key in schema) {
233611
- extraMeta[key] = schema[key];
234084
+ const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
234085
+ if (path[0] === defsKey) {
234086
+ const key = path[1];
234087
+ if (!key || !ctx.defs[key]) {
234088
+ throw new Error(`Reference not found: ${ref}`);
233612
234089
  }
234090
+ return ctx.defs[key];
233613
234091
  }
233614
- for (const key of Object.keys(schema)) {
233615
- if (!RECOGNIZED_KEYS.has(key)) {
233616
- extraMeta[key] = schema[key];
234092
+ throw new Error(`Reference not found: ${ref}`);
234093
+ }
234094
+ function convertBaseSchema(schema, ctx) {
234095
+ if (schema.not !== undefined) {
234096
+ if (typeof schema.not === "object" && Object.keys(schema.not).length === 0) {
234097
+ return z2.never();
233617
234098
  }
234099
+ throw new Error("not is not supported in Zod (except { not: {} } for never)");
233618
234100
  }
233619
- if (Object.keys(extraMeta).length > 0) {
233620
- ctx.registry.add(baseSchema, extraMeta);
233621
- }
233622
- return baseSchema;
233623
- }
233624
- function fromJSONSchema(schema, params) {
233625
- if (typeof schema === "boolean") {
233626
- return schema ? z2.any() : z2.never();
234101
+ if (schema.unevaluatedItems !== undefined) {
234102
+ throw new Error("unevaluatedItems is not supported");
233627
234103
  }
233628
- const version2 = detectVersion(schema, params?.defaultTarget);
233629
- const defs = schema.$defs || schema.definitions || {};
233630
- const ctx = {
233631
- version: version2,
233632
- defs,
233633
- refs: new Map,
233634
- processing: new Set,
233635
- rootSchema: schema,
233636
- registry: params?.registry ?? globalRegistry
233637
- };
233638
- return convertSchema(schema, ctx);
233639
- }
233640
- // ../../node_modules/zod/v4/classic/coerce.js
233641
- var exports_coerce = {};
233642
- __export(exports_coerce, {
233643
- string: () => string3,
233644
- number: () => number3,
233645
- date: () => date4,
233646
- boolean: () => boolean3,
233647
- bigint: () => bigint3
233648
- });
233649
- function string3(params) {
233650
- return _coercedString(ZodString, params);
233651
- }
233652
- function number3(params) {
233653
- return _coercedNumber(ZodNumber, params);
233654
- }
233655
- function boolean3(params) {
233656
- return _coercedBoolean(ZodBoolean, params);
233657
- }
233658
- function bigint3(params) {
233659
- return _coercedBigint(ZodBigInt, params);
233660
- }
233661
- function date4(params) {
233662
- return _coercedDate(ZodDate, params);
233663
- }
233664
-
233665
- // ../../node_modules/zod/v4/classic/external.js
233666
- config(en_default());
233667
- // src/core/auth/schema.ts
233668
- var AuthDataSchema = exports_external.object({
233669
- accessToken: exports_external.string().min(1, "Token cannot be empty"),
233670
- refreshToken: exports_external.string().min(1, "Refresh token cannot be empty"),
233671
- expiresAt: exports_external.number().int().positive("Expires at must be a positive integer"),
233672
- email: exports_external.email(),
233673
- name: exports_external.string().min(1, "Name cannot be empty")
233674
- });
233675
- var DeviceCodeResponseSchema = exports_external.object({
233676
- device_code: exports_external.string().min(1, "Device code cannot be empty"),
233677
- user_code: exports_external.string().min(1, "User code cannot be empty"),
233678
- verification_uri: exports_external.url("Invalid verification URL"),
233679
- expires_in: exports_external.number().int().positive("Expires in must be a positive integer"),
233680
- interval: exports_external.number().int().positive("Interval in must be a positive integer")
233681
- }).transform((data) => ({
233682
- deviceCode: data.device_code,
233683
- userCode: data.user_code,
233684
- verificationUri: data.verification_uri,
233685
- expiresIn: data.expires_in,
233686
- interval: data.interval
233687
- }));
233688
- var TokenResponseSchema = exports_external.object({
233689
- access_token: exports_external.string().min(1, "Token cannot be empty"),
233690
- token_type: exports_external.string().min(1, "Token type cannot be empty"),
233691
- expires_in: exports_external.number().int().positive("Expires in must be a positive integer"),
233692
- refresh_token: exports_external.string().min(1, "Refresh token cannot be empty"),
233693
- scope: exports_external.string().optional()
233694
- }).transform((data) => ({
233695
- accessToken: data.access_token,
233696
- tokenType: data.token_type,
233697
- expiresIn: data.expires_in,
233698
- refreshToken: data.refresh_token,
233699
- scope: data.scope
233700
- }));
233701
- var OAuthErrorSchema = exports_external.object({
233702
- error: exports_external.string(),
233703
- error_description: exports_external.string().optional()
233704
- });
233705
- var UserInfoSchema = exports_external.object({
233706
- email: exports_external.email(),
233707
- name: exports_external.string()
233708
- });
233709
-
233710
- // src/core/clients/base44-client.ts
233711
- import { randomUUID as randomUUID2 } from "node:crypto";
233712
-
233713
- // ../../node_modules/ky/distribution/errors/HTTPError.js
233714
- class HTTPError extends Error {
233715
- response;
233716
- request;
233717
- options;
233718
- constructor(response, request, options) {
233719
- const code = response.status || response.status === 0 ? response.status : "";
233720
- const title = response.statusText ?? "";
233721
- const status = `${code} ${title}`.trim();
233722
- const reason = status ? `status code ${status}` : "an unknown error";
233723
- super(`Request failed with ${reason}: ${request.method} ${request.url}`);
233724
- this.name = "HTTPError";
233725
- this.response = response;
233726
- this.request = request;
233727
- this.options = options;
234104
+ if (schema.unevaluatedProperties !== undefined) {
234105
+ throw new Error("unevaluatedProperties is not supported");
233728
234106
  }
233729
- }
233730
-
233731
- // ../../node_modules/ky/distribution/errors/NonError.js
233732
- class NonError extends Error {
233733
- name = "NonError";
233734
- value;
233735
- constructor(value) {
233736
- let message = "Non-error value was thrown";
233737
- try {
233738
- if (typeof value === "string") {
233739
- message = value;
233740
- } else if (value && typeof value === "object" && "message" in value && typeof value.message === "string") {
233741
- message = value.message;
233742
- }
233743
- } catch {}
233744
- super(message);
233745
- this.value = value;
234107
+ if (schema.if !== undefined || schema.then !== undefined || schema.else !== undefined) {
234108
+ throw new Error("Conditional schemas (if/then/else) are not supported");
233746
234109
  }
233747
- }
233748
-
233749
- // ../../node_modules/ky/distribution/errors/ForceRetryError.js
233750
- class ForceRetryError extends Error {
233751
- name = "ForceRetryError";
233752
- customDelay;
233753
- code;
233754
- customRequest;
233755
- constructor(options) {
233756
- const cause = options?.cause ? options.cause instanceof Error ? options.cause : new NonError(options.cause) : undefined;
233757
- super(options?.code ? `Forced retry: ${options.code}` : "Forced retry", cause ? { cause } : undefined);
233758
- this.customDelay = options?.delay;
233759
- this.code = options?.code;
233760
- this.customRequest = options?.request;
234110
+ if (schema.dependentSchemas !== undefined || schema.dependentRequired !== undefined) {
234111
+ throw new Error("dependentSchemas and dependentRequired are not supported");
233761
234112
  }
233762
- }
233763
-
233764
- // ../../node_modules/ky/distribution/core/constants.js
233765
- var supportsRequestStreams = (() => {
233766
- let duplexAccessed = false;
233767
- let hasContentType = false;
233768
- const supportsReadableStream = typeof globalThis.ReadableStream === "function";
233769
- const supportsRequest = typeof globalThis.Request === "function";
233770
- if (supportsReadableStream && supportsRequest) {
233771
- try {
233772
- hasContentType = new globalThis.Request("https://empty.invalid", {
233773
- body: new globalThis.ReadableStream,
233774
- method: "POST",
233775
- get duplex() {
233776
- duplexAccessed = true;
233777
- return "half";
234113
+ if (schema.$ref) {
234114
+ const refPath = schema.$ref;
234115
+ if (ctx.refs.has(refPath)) {
234116
+ return ctx.refs.get(refPath);
234117
+ }
234118
+ if (ctx.processing.has(refPath)) {
234119
+ return z2.lazy(() => {
234120
+ if (!ctx.refs.has(refPath)) {
234121
+ throw new Error(`Circular reference not resolved: ${refPath}`);
233778
234122
  }
233779
- }).headers.has("Content-Type");
233780
- } catch (error48) {
233781
- if (error48 instanceof Error && error48.message === "unsupported BodyInit type") {
233782
- return false;
233783
- }
233784
- throw error48;
234123
+ return ctx.refs.get(refPath);
234124
+ });
233785
234125
  }
234126
+ ctx.processing.add(refPath);
234127
+ const resolved = resolveRef(refPath, ctx);
234128
+ const zodSchema2 = convertSchema(resolved, ctx);
234129
+ ctx.refs.set(refPath, zodSchema2);
234130
+ ctx.processing.delete(refPath);
234131
+ return zodSchema2;
233786
234132
  }
233787
- return duplexAccessed && !hasContentType;
233788
- })();
233789
- var supportsAbortController = typeof globalThis.AbortController === "function";
233790
- var supportsAbortSignal = typeof globalThis.AbortSignal === "function" && typeof globalThis.AbortSignal.any === "function";
233791
- var supportsResponseStreams = typeof globalThis.ReadableStream === "function";
233792
- var supportsFormData = typeof globalThis.FormData === "function";
233793
- var requestMethods = ["get", "post", "put", "patch", "head", "delete"];
233794
- var validate = () => {
233795
- return;
233796
- };
233797
- validate();
233798
- var responseTypes = {
233799
- json: "application/json",
233800
- text: "text/*",
233801
- formData: "multipart/form-data",
233802
- arrayBuffer: "*/*",
233803
- blob: "*/*",
233804
- bytes: "*/*"
233805
- };
233806
- var maxSafeTimeout = 2147483647;
233807
- var usualFormBoundarySize = new TextEncoder().encode("------WebKitFormBoundaryaxpyiPgbbPti10Rw").length;
233808
- var stop = Symbol("stop");
233809
-
233810
- class RetryMarker {
233811
- options;
233812
- constructor(options) {
233813
- this.options = options;
233814
- }
233815
- }
233816
- var retry = (options) => new RetryMarker(options);
233817
- var kyOptionKeys = {
233818
- json: true,
233819
- parseJson: true,
233820
- stringifyJson: true,
233821
- searchParams: true,
233822
- prefixUrl: true,
233823
- retry: true,
233824
- timeout: true,
233825
- hooks: true,
233826
- throwHttpErrors: true,
233827
- onDownloadProgress: true,
233828
- onUploadProgress: true,
233829
- fetch: true,
233830
- context: true
233831
- };
233832
- var vendorSpecificOptions = {
233833
- next: true
233834
- };
233835
- var requestOptionsRegistry = {
233836
- method: true,
233837
- headers: true,
233838
- body: true,
233839
- mode: true,
233840
- credentials: true,
233841
- cache: true,
233842
- redirect: true,
233843
- referrer: true,
233844
- referrerPolicy: true,
233845
- integrity: true,
233846
- keepalive: true,
233847
- signal: true,
233848
- window: true,
233849
- duplex: true
233850
- };
233851
-
233852
- // ../../node_modules/ky/distribution/utils/body.js
233853
- var getBodySize = (body) => {
233854
- if (!body) {
233855
- return 0;
233856
- }
233857
- if (body instanceof FormData) {
233858
- let size = 0;
233859
- for (const [key, value] of body) {
233860
- size += usualFormBoundarySize;
233861
- size += new TextEncoder().encode(`Content-Disposition: form-data; name="${key}"`).length;
233862
- size += typeof value === "string" ? new TextEncoder().encode(value).length : value.size;
234133
+ if (schema.enum !== undefined) {
234134
+ const enumValues = schema.enum;
234135
+ if (ctx.version === "openapi-3.0" && schema.nullable === true && enumValues.length === 1 && enumValues[0] === null) {
234136
+ return z2.null();
233863
234137
  }
233864
- return size;
233865
- }
233866
- if (body instanceof Blob) {
233867
- return body.size;
233868
- }
233869
- if (body instanceof ArrayBuffer) {
233870
- return body.byteLength;
233871
- }
233872
- if (typeof body === "string") {
233873
- return new TextEncoder().encode(body).length;
233874
- }
233875
- if (body instanceof URLSearchParams) {
233876
- return new TextEncoder().encode(body.toString()).length;
234138
+ if (enumValues.length === 0) {
234139
+ return z2.never();
234140
+ }
234141
+ if (enumValues.length === 1) {
234142
+ return z2.literal(enumValues[0]);
234143
+ }
234144
+ if (enumValues.every((v) => typeof v === "string")) {
234145
+ return z2.enum(enumValues);
234146
+ }
234147
+ const literalSchemas = enumValues.map((v) => z2.literal(v));
234148
+ if (literalSchemas.length < 2) {
234149
+ return literalSchemas[0];
234150
+ }
234151
+ return z2.union([literalSchemas[0], literalSchemas[1], ...literalSchemas.slice(2)]);
233877
234152
  }
233878
- if ("byteLength" in body) {
233879
- return body.byteLength;
234153
+ if (schema.const !== undefined) {
234154
+ return z2.literal(schema.const);
233880
234155
  }
233881
- if (typeof body === "object" && body !== null) {
233882
- try {
233883
- const jsonString = JSON.stringify(body);
233884
- return new TextEncoder().encode(jsonString).length;
233885
- } catch {
233886
- return 0;
234156
+ const type = schema.type;
234157
+ if (Array.isArray(type)) {
234158
+ const typeSchemas = type.map((t) => {
234159
+ const typeSchema = { ...schema, type: t };
234160
+ return convertBaseSchema(typeSchema, ctx);
234161
+ });
234162
+ if (typeSchemas.length === 0) {
234163
+ return z2.never();
234164
+ }
234165
+ if (typeSchemas.length === 1) {
234166
+ return typeSchemas[0];
233887
234167
  }
234168
+ return z2.union(typeSchemas);
233888
234169
  }
233889
- return 0;
233890
- };
233891
- var withProgress = (stream, totalBytes, onProgress) => {
233892
- let previousChunk;
233893
- let transferredBytes = 0;
233894
- return stream.pipeThrough(new TransformStream({
233895
- transform(currentChunk, controller) {
233896
- controller.enqueue(currentChunk);
233897
- if (previousChunk) {
233898
- transferredBytes += previousChunk.byteLength;
233899
- let percent = totalBytes === 0 ? 0 : transferredBytes / totalBytes;
233900
- if (percent >= 1) {
233901
- percent = 1 - Number.EPSILON;
234170
+ if (!type) {
234171
+ return z2.any();
234172
+ }
234173
+ let zodSchema;
234174
+ switch (type) {
234175
+ case "string": {
234176
+ let stringSchema = z2.string();
234177
+ if (schema.format) {
234178
+ const format = schema.format;
234179
+ if (format === "email") {
234180
+ stringSchema = stringSchema.check(z2.email());
234181
+ } else if (format === "uri" || format === "uri-reference") {
234182
+ stringSchema = stringSchema.check(z2.url());
234183
+ } else if (format === "uuid" || format === "guid") {
234184
+ stringSchema = stringSchema.check(z2.uuid());
234185
+ } else if (format === "date-time") {
234186
+ stringSchema = stringSchema.check(z2.iso.datetime());
234187
+ } else if (format === "date") {
234188
+ stringSchema = stringSchema.check(z2.iso.date());
234189
+ } else if (format === "time") {
234190
+ stringSchema = stringSchema.check(z2.iso.time());
234191
+ } else if (format === "duration") {
234192
+ stringSchema = stringSchema.check(z2.iso.duration());
234193
+ } else if (format === "ipv4") {
234194
+ stringSchema = stringSchema.check(z2.ipv4());
234195
+ } else if (format === "ipv6") {
234196
+ stringSchema = stringSchema.check(z2.ipv6());
234197
+ } else if (format === "mac") {
234198
+ stringSchema = stringSchema.check(z2.mac());
234199
+ } else if (format === "cidr") {
234200
+ stringSchema = stringSchema.check(z2.cidrv4());
234201
+ } else if (format === "cidr-v6") {
234202
+ stringSchema = stringSchema.check(z2.cidrv6());
234203
+ } else if (format === "base64") {
234204
+ stringSchema = stringSchema.check(z2.base64());
234205
+ } else if (format === "base64url") {
234206
+ stringSchema = stringSchema.check(z2.base64url());
234207
+ } else if (format === "e164") {
234208
+ stringSchema = stringSchema.check(z2.e164());
234209
+ } else if (format === "jwt") {
234210
+ stringSchema = stringSchema.check(z2.jwt());
234211
+ } else if (format === "emoji") {
234212
+ stringSchema = stringSchema.check(z2.emoji());
234213
+ } else if (format === "nanoid") {
234214
+ stringSchema = stringSchema.check(z2.nanoid());
234215
+ } else if (format === "cuid") {
234216
+ stringSchema = stringSchema.check(z2.cuid());
234217
+ } else if (format === "cuid2") {
234218
+ stringSchema = stringSchema.check(z2.cuid2());
234219
+ } else if (format === "ulid") {
234220
+ stringSchema = stringSchema.check(z2.ulid());
234221
+ } else if (format === "xid") {
234222
+ stringSchema = stringSchema.check(z2.xid());
234223
+ } else if (format === "ksuid") {
234224
+ stringSchema = stringSchema.check(z2.ksuid());
233902
234225
  }
233903
- onProgress?.({ percent, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
233904
234226
  }
233905
- previousChunk = currentChunk;
233906
- },
233907
- flush() {
233908
- if (previousChunk) {
233909
- transferredBytes += previousChunk.byteLength;
233910
- onProgress?.({ percent: 1, totalBytes: Math.max(totalBytes, transferredBytes), transferredBytes }, previousChunk);
234227
+ if (typeof schema.minLength === "number") {
234228
+ stringSchema = stringSchema.min(schema.minLength);
233911
234229
  }
234230
+ if (typeof schema.maxLength === "number") {
234231
+ stringSchema = stringSchema.max(schema.maxLength);
234232
+ }
234233
+ if (schema.pattern) {
234234
+ stringSchema = stringSchema.regex(new RegExp(schema.pattern));
234235
+ }
234236
+ zodSchema = stringSchema;
234237
+ break;
233912
234238
  }
233913
- }));
233914
- };
233915
- var streamResponse = (response, onDownloadProgress) => {
233916
- if (!response.body) {
233917
- return response;
233918
- }
233919
- if (response.status === 204) {
233920
- return new Response(null, {
233921
- status: response.status,
233922
- statusText: response.statusText,
233923
- headers: response.headers
233924
- });
233925
- }
233926
- const totalBytes = Math.max(0, Number(response.headers.get("content-length")) || 0);
233927
- return new Response(withProgress(response.body, totalBytes, onDownloadProgress), {
233928
- status: response.status,
233929
- statusText: response.statusText,
233930
- headers: response.headers
233931
- });
233932
- };
233933
- var streamRequest = (request, onUploadProgress, originalBody) => {
233934
- if (!request.body) {
233935
- return request;
233936
- }
233937
- const totalBytes = getBodySize(originalBody ?? request.body);
233938
- return new Request(request, {
233939
- duplex: "half",
233940
- body: withProgress(request.body, totalBytes, onUploadProgress)
233941
- });
233942
- };
233943
-
233944
- // ../../node_modules/ky/distribution/utils/is.js
233945
- var isObject2 = (value) => value !== null && typeof value === "object";
233946
-
233947
- // ../../node_modules/ky/distribution/utils/merge.js
233948
- var validateAndMerge = (...sources) => {
233949
- for (const source of sources) {
233950
- if ((!isObject2(source) || Array.isArray(source)) && source !== undefined) {
233951
- throw new TypeError("The `options` argument must be an object");
233952
- }
233953
- }
233954
- return deepMerge({}, ...sources);
233955
- };
233956
- var mergeHeaders = (source1 = {}, source2 = {}) => {
233957
- const result = new globalThis.Headers(source1);
233958
- const isHeadersInstance = source2 instanceof globalThis.Headers;
233959
- const source = new globalThis.Headers(source2);
233960
- for (const [key, value] of source.entries()) {
233961
- if (isHeadersInstance && value === "undefined" || value === undefined) {
233962
- result.delete(key);
233963
- } else {
233964
- result.set(key, value);
234239
+ case "number":
234240
+ case "integer": {
234241
+ let numberSchema = type === "integer" ? z2.number().int() : z2.number();
234242
+ if (typeof schema.minimum === "number") {
234243
+ numberSchema = numberSchema.min(schema.minimum);
234244
+ }
234245
+ if (typeof schema.maximum === "number") {
234246
+ numberSchema = numberSchema.max(schema.maximum);
234247
+ }
234248
+ if (typeof schema.exclusiveMinimum === "number") {
234249
+ numberSchema = numberSchema.gt(schema.exclusiveMinimum);
234250
+ } else if (schema.exclusiveMinimum === true && typeof schema.minimum === "number") {
234251
+ numberSchema = numberSchema.gt(schema.minimum);
234252
+ }
234253
+ if (typeof schema.exclusiveMaximum === "number") {
234254
+ numberSchema = numberSchema.lt(schema.exclusiveMaximum);
234255
+ } else if (schema.exclusiveMaximum === true && typeof schema.maximum === "number") {
234256
+ numberSchema = numberSchema.lt(schema.maximum);
234257
+ }
234258
+ if (typeof schema.multipleOf === "number") {
234259
+ numberSchema = numberSchema.multipleOf(schema.multipleOf);
234260
+ }
234261
+ zodSchema = numberSchema;
234262
+ break;
233965
234263
  }
233966
- }
233967
- return result;
233968
- };
233969
- function newHookValue(original, incoming, property) {
233970
- return Object.hasOwn(incoming, property) && incoming[property] === undefined ? [] : deepMerge(original[property] ?? [], incoming[property] ?? []);
233971
- }
233972
- var mergeHooks = (original = {}, incoming = {}) => ({
233973
- beforeRequest: newHookValue(original, incoming, "beforeRequest"),
233974
- beforeRetry: newHookValue(original, incoming, "beforeRetry"),
233975
- afterResponse: newHookValue(original, incoming, "afterResponse"),
233976
- beforeError: newHookValue(original, incoming, "beforeError")
233977
- });
233978
- var appendSearchParameters = (target, source) => {
233979
- const result = new URLSearchParams;
233980
- for (const input of [target, source]) {
233981
- if (input === undefined) {
233982
- continue;
234264
+ case "boolean": {
234265
+ zodSchema = z2.boolean();
234266
+ break;
233983
234267
  }
233984
- if (input instanceof URLSearchParams) {
233985
- for (const [key, value] of input.entries()) {
233986
- result.append(key, value);
234268
+ case "null": {
234269
+ zodSchema = z2.null();
234270
+ break;
234271
+ }
234272
+ case "object": {
234273
+ const shape = {};
234274
+ const properties = schema.properties || {};
234275
+ const requiredSet = new Set(schema.required || []);
234276
+ for (const [key, propSchema] of Object.entries(properties)) {
234277
+ const propZodSchema = convertSchema(propSchema, ctx);
234278
+ shape[key] = requiredSet.has(key) ? propZodSchema : propZodSchema.optional();
233987
234279
  }
233988
- } else if (Array.isArray(input)) {
233989
- for (const pair of input) {
233990
- if (!Array.isArray(pair) || pair.length !== 2) {
233991
- throw new TypeError("Array search parameters must be provided in [[key, value], ...] format");
234280
+ if (schema.propertyNames) {
234281
+ const keySchema = convertSchema(schema.propertyNames, ctx);
234282
+ const valueSchema = schema.additionalProperties && typeof schema.additionalProperties === "object" ? convertSchema(schema.additionalProperties, ctx) : z2.any();
234283
+ if (Object.keys(shape).length === 0) {
234284
+ zodSchema = z2.record(keySchema, valueSchema);
234285
+ break;
233992
234286
  }
233993
- result.append(String(pair[0]), String(pair[1]));
234287
+ const objectSchema2 = z2.object(shape).passthrough();
234288
+ const recordSchema = z2.looseRecord(keySchema, valueSchema);
234289
+ zodSchema = z2.intersection(objectSchema2, recordSchema);
234290
+ break;
233994
234291
  }
233995
- } else if (isObject2(input)) {
233996
- for (const [key, value] of Object.entries(input)) {
233997
- if (value !== undefined) {
233998
- result.append(key, String(value));
234292
+ if (schema.patternProperties) {
234293
+ const patternProps = schema.patternProperties;
234294
+ const patternKeys = Object.keys(patternProps);
234295
+ const looseRecords = [];
234296
+ for (const pattern of patternKeys) {
234297
+ const patternValue = convertSchema(patternProps[pattern], ctx);
234298
+ const keySchema = z2.string().regex(new RegExp(pattern));
234299
+ looseRecords.push(z2.looseRecord(keySchema, patternValue));
234300
+ }
234301
+ const schemasToIntersect = [];
234302
+ if (Object.keys(shape).length > 0) {
234303
+ schemasToIntersect.push(z2.object(shape).passthrough());
234304
+ }
234305
+ schemasToIntersect.push(...looseRecords);
234306
+ if (schemasToIntersect.length === 0) {
234307
+ zodSchema = z2.object({}).passthrough();
234308
+ } else if (schemasToIntersect.length === 1) {
234309
+ zodSchema = schemasToIntersect[0];
234310
+ } else {
234311
+ let result = z2.intersection(schemasToIntersect[0], schemasToIntersect[1]);
234312
+ for (let i = 2;i < schemasToIntersect.length; i++) {
234313
+ result = z2.intersection(result, schemasToIntersect[i]);
234314
+ }
234315
+ zodSchema = result;
233999
234316
  }
234317
+ break;
234000
234318
  }
234001
- } else {
234002
- const parameters = new URLSearchParams(input);
234003
- for (const [key, value] of parameters.entries()) {
234004
- result.append(key, value);
234319
+ const objectSchema = z2.object(shape);
234320
+ if (schema.additionalProperties === false) {
234321
+ zodSchema = objectSchema.strict();
234322
+ } else if (typeof schema.additionalProperties === "object") {
234323
+ zodSchema = objectSchema.catchall(convertSchema(schema.additionalProperties, ctx));
234324
+ } else {
234325
+ zodSchema = objectSchema.passthrough();
234005
234326
  }
234327
+ break;
234006
234328
  }
234007
- }
234008
- return result;
234009
- };
234010
- var deepMerge = (...sources) => {
234011
- let returnValue = {};
234012
- let headers = {};
234013
- let hooks = {};
234014
- let searchParameters;
234015
- const signals = [];
234016
- for (const source of sources) {
234017
- if (Array.isArray(source)) {
234018
- if (!Array.isArray(returnValue)) {
234019
- returnValue = [];
234020
- }
234021
- returnValue = [...returnValue, ...source];
234022
- } else if (isObject2(source)) {
234023
- for (let [key, value] of Object.entries(source)) {
234024
- if (key === "signal" && value instanceof globalThis.AbortSignal) {
234025
- signals.push(value);
234026
- continue;
234329
+ case "array": {
234330
+ const prefixItems = schema.prefixItems;
234331
+ const items = schema.items;
234332
+ if (prefixItems && Array.isArray(prefixItems)) {
234333
+ const tupleItems = prefixItems.map((item) => convertSchema(item, ctx));
234334
+ const rest = items && typeof items === "object" && !Array.isArray(items) ? convertSchema(items, ctx) : undefined;
234335
+ if (rest) {
234336
+ zodSchema = z2.tuple(tupleItems).rest(rest);
234337
+ } else {
234338
+ zodSchema = z2.tuple(tupleItems);
234027
234339
  }
234028
- if (key === "context") {
234029
- if (value !== undefined && value !== null && (!isObject2(value) || Array.isArray(value))) {
234030
- throw new TypeError("The `context` option must be an object");
234031
- }
234032
- returnValue = {
234033
- ...returnValue,
234034
- context: value === undefined || value === null ? {} : { ...returnValue.context, ...value }
234035
- };
234036
- continue;
234340
+ if (typeof schema.minItems === "number") {
234341
+ zodSchema = zodSchema.check(z2.minLength(schema.minItems));
234037
234342
  }
234038
- if (key === "searchParams") {
234039
- if (value === undefined || value === null) {
234040
- searchParameters = undefined;
234041
- } else {
234042
- searchParameters = searchParameters === undefined ? value : appendSearchParameters(searchParameters, value);
234043
- }
234044
- continue;
234343
+ if (typeof schema.maxItems === "number") {
234344
+ zodSchema = zodSchema.check(z2.maxLength(schema.maxItems));
234045
234345
  }
234046
- if (isObject2(value) && key in returnValue) {
234047
- value = deepMerge(returnValue[key], value);
234346
+ } else if (Array.isArray(items)) {
234347
+ const tupleItems = items.map((item) => convertSchema(item, ctx));
234348
+ const rest = schema.additionalItems && typeof schema.additionalItems === "object" ? convertSchema(schema.additionalItems, ctx) : undefined;
234349
+ if (rest) {
234350
+ zodSchema = z2.tuple(tupleItems).rest(rest);
234351
+ } else {
234352
+ zodSchema = z2.tuple(tupleItems);
234048
234353
  }
234049
- returnValue = { ...returnValue, [key]: value };
234050
- }
234051
- if (isObject2(source.hooks)) {
234052
- hooks = mergeHooks(hooks, source.hooks);
234053
- returnValue.hooks = hooks;
234054
- }
234055
- if (isObject2(source.headers)) {
234056
- headers = mergeHeaders(headers, source.headers);
234057
- returnValue.headers = headers;
234354
+ if (typeof schema.minItems === "number") {
234355
+ zodSchema = zodSchema.check(z2.minLength(schema.minItems));
234356
+ }
234357
+ if (typeof schema.maxItems === "number") {
234358
+ zodSchema = zodSchema.check(z2.maxLength(schema.maxItems));
234359
+ }
234360
+ } else if (items !== undefined) {
234361
+ const element = convertSchema(items, ctx);
234362
+ let arraySchema = z2.array(element);
234363
+ if (typeof schema.minItems === "number") {
234364
+ arraySchema = arraySchema.min(schema.minItems);
234365
+ }
234366
+ if (typeof schema.maxItems === "number") {
234367
+ arraySchema = arraySchema.max(schema.maxItems);
234368
+ }
234369
+ zodSchema = arraySchema;
234370
+ } else {
234371
+ zodSchema = z2.array(z2.any());
234058
234372
  }
234373
+ break;
234059
234374
  }
234375
+ default:
234376
+ throw new Error(`Unsupported type: ${type}`);
234060
234377
  }
234061
- if (searchParameters !== undefined) {
234062
- returnValue.searchParams = searchParameters;
234378
+ if (schema.description) {
234379
+ zodSchema = zodSchema.describe(schema.description);
234063
234380
  }
234064
- if (signals.length > 0) {
234065
- if (signals.length === 1) {
234066
- returnValue.signal = signals[0];
234067
- } else if (supportsAbortSignal) {
234068
- returnValue.signal = AbortSignal.any(signals);
234381
+ if (schema.default !== undefined) {
234382
+ zodSchema = zodSchema.default(schema.default);
234383
+ }
234384
+ return zodSchema;
234385
+ }
234386
+ function convertSchema(schema, ctx) {
234387
+ if (typeof schema === "boolean") {
234388
+ return schema ? z2.any() : z2.never();
234389
+ }
234390
+ let baseSchema = convertBaseSchema(schema, ctx);
234391
+ const hasExplicitType = schema.type || schema.enum !== undefined || schema.const !== undefined;
234392
+ if (schema.anyOf && Array.isArray(schema.anyOf)) {
234393
+ const options = schema.anyOf.map((s) => convertSchema(s, ctx));
234394
+ const anyOfUnion = z2.union(options);
234395
+ baseSchema = hasExplicitType ? z2.intersection(baseSchema, anyOfUnion) : anyOfUnion;
234396
+ }
234397
+ if (schema.oneOf && Array.isArray(schema.oneOf)) {
234398
+ const options = schema.oneOf.map((s) => convertSchema(s, ctx));
234399
+ const oneOfUnion = z2.xor(options);
234400
+ baseSchema = hasExplicitType ? z2.intersection(baseSchema, oneOfUnion) : oneOfUnion;
234401
+ }
234402
+ if (schema.allOf && Array.isArray(schema.allOf)) {
234403
+ if (schema.allOf.length === 0) {
234404
+ baseSchema = hasExplicitType ? baseSchema : z2.any();
234069
234405
  } else {
234070
- returnValue.signal = signals.at(-1);
234406
+ let result = hasExplicitType ? baseSchema : convertSchema(schema.allOf[0], ctx);
234407
+ const startIdx = hasExplicitType ? 0 : 1;
234408
+ for (let i = startIdx;i < schema.allOf.length; i++) {
234409
+ result = z2.intersection(result, convertSchema(schema.allOf[i], ctx));
234410
+ }
234411
+ baseSchema = result;
234071
234412
  }
234072
234413
  }
234073
- return returnValue;
234074
- };
234075
-
234076
- // ../../node_modules/ky/distribution/utils/normalize.js
234077
- var normalizeRequestMethod = (input) => requestMethods.includes(input) ? input.toUpperCase() : input;
234078
- var retryMethods = ["get", "put", "head", "delete", "options", "trace"];
234079
- var retryStatusCodes = [408, 413, 429, 500, 502, 503, 504];
234080
- var retryAfterStatusCodes = [413, 429, 503];
234081
- var defaultRetryOptions = {
234082
- limit: 2,
234083
- methods: retryMethods,
234084
- statusCodes: retryStatusCodes,
234085
- afterStatusCodes: retryAfterStatusCodes,
234086
- maxRetryAfter: Number.POSITIVE_INFINITY,
234087
- backoffLimit: Number.POSITIVE_INFINITY,
234088
- delay: (attemptCount) => 0.3 * 2 ** (attemptCount - 1) * 1000,
234089
- jitter: undefined,
234090
- retryOnTimeout: false
234091
- };
234092
- var normalizeRetryOptions = (retry2 = {}) => {
234093
- if (typeof retry2 === "number") {
234094
- return {
234095
- ...defaultRetryOptions,
234096
- limit: retry2
234097
- };
234414
+ if (schema.nullable === true && ctx.version === "openapi-3.0") {
234415
+ baseSchema = z2.nullable(baseSchema);
234098
234416
  }
234099
- if (retry2.methods && !Array.isArray(retry2.methods)) {
234100
- throw new Error("retry.methods must be an array");
234417
+ if (schema.readOnly === true) {
234418
+ baseSchema = z2.readonly(baseSchema);
234101
234419
  }
234102
- retry2.methods &&= retry2.methods.map((method) => method.toLowerCase());
234103
- if (retry2.statusCodes && !Array.isArray(retry2.statusCodes)) {
234104
- throw new Error("retry.statusCodes must be an array");
234420
+ const extraMeta = {};
234421
+ const coreMetadataKeys = ["$id", "id", "$comment", "$anchor", "$vocabulary", "$dynamicRef", "$dynamicAnchor"];
234422
+ for (const key of coreMetadataKeys) {
234423
+ if (key in schema) {
234424
+ extraMeta[key] = schema[key];
234425
+ }
234105
234426
  }
234106
- const normalizedRetry = Object.fromEntries(Object.entries(retry2).filter(([, value]) => value !== undefined));
234107
- return {
234108
- ...defaultRetryOptions,
234109
- ...normalizedRetry
234427
+ const contentMetadataKeys = ["contentEncoding", "contentMediaType", "contentSchema"];
234428
+ for (const key of contentMetadataKeys) {
234429
+ if (key in schema) {
234430
+ extraMeta[key] = schema[key];
234431
+ }
234432
+ }
234433
+ for (const key of Object.keys(schema)) {
234434
+ if (!RECOGNIZED_KEYS.has(key)) {
234435
+ extraMeta[key] = schema[key];
234436
+ }
234437
+ }
234438
+ if (Object.keys(extraMeta).length > 0) {
234439
+ ctx.registry.add(baseSchema, extraMeta);
234440
+ }
234441
+ return baseSchema;
234442
+ }
234443
+ function fromJSONSchema(schema, params) {
234444
+ if (typeof schema === "boolean") {
234445
+ return schema ? z2.any() : z2.never();
234446
+ }
234447
+ const version2 = detectVersion(schema, params?.defaultTarget);
234448
+ const defs = schema.$defs || schema.definitions || {};
234449
+ const ctx = {
234450
+ version: version2,
234451
+ defs,
234452
+ refs: new Map,
234453
+ processing: new Set,
234454
+ rootSchema: schema,
234455
+ registry: params?.registry ?? globalRegistry
234110
234456
  };
234111
- };
234457
+ return convertSchema(schema, ctx);
234458
+ }
234459
+ // ../../node_modules/zod/v4/classic/coerce.js
234460
+ var exports_coerce = {};
234461
+ __export(exports_coerce, {
234462
+ string: () => string3,
234463
+ number: () => number3,
234464
+ date: () => date4,
234465
+ boolean: () => boolean3,
234466
+ bigint: () => bigint3
234467
+ });
234468
+ function string3(params) {
234469
+ return _coercedString(ZodString, params);
234470
+ }
234471
+ function number3(params) {
234472
+ return _coercedNumber(ZodNumber, params);
234473
+ }
234474
+ function boolean3(params) {
234475
+ return _coercedBoolean(ZodBoolean, params);
234476
+ }
234477
+ function bigint3(params) {
234478
+ return _coercedBigint(ZodBigInt, params);
234479
+ }
234480
+ function date4(params) {
234481
+ return _coercedDate(ZodDate, params);
234482
+ }
234112
234483
 
234113
- // ../../node_modules/ky/distribution/errors/TimeoutError.js
234114
- class TimeoutError2 extends Error {
234115
- request;
234116
- constructor(request) {
234117
- super(`Request timed out: ${request.method} ${request.url}`);
234118
- this.name = "TimeoutError";
234119
- this.request = request;
234484
+ // ../../node_modules/zod/v4/classic/external.js
234485
+ config(en_default());
234486
+ // src/core/clients/schemas.ts
234487
+ var ApiErrorResponseSchema = exports_external.looseObject({
234488
+ message: exports_external.unknown().optional(),
234489
+ detail: exports_external.unknown().optional(),
234490
+ extra_data: exports_external.looseObject({
234491
+ reason: exports_external.string().optional().catch(undefined),
234492
+ errors: exports_external.array(exports_external.looseObject({ name: exports_external.string(), message: exports_external.string() })).optional().catch(undefined)
234493
+ }).optional().nullable().catch(undefined)
234494
+ });
234495
+
234496
+ // src/core/errors.ts
234497
+ function formatApiError(errorBody, parsed) {
234498
+ const data = parsed ?? ApiErrorResponseSchema.safeParse(errorBody).data;
234499
+ if (data) {
234500
+ const content = data.message ?? data.detail;
234501
+ if (typeof content === "string")
234502
+ return content;
234503
+ if (content !== undefined)
234504
+ return JSON.stringify(content, null, 2);
234120
234505
  }
234506
+ if (typeof errorBody === "string")
234507
+ return errorBody;
234508
+ return JSON.stringify(errorBody, null, 2);
234509
+ }
234510
+ function parseErrorDetails(extraData) {
234511
+ const errors3 = extraData?.errors;
234512
+ if (!errors3 || errors3.length === 0)
234513
+ return;
234514
+ return errors3.map((e2) => `${e2.name}: ${e2.message}`);
234121
234515
  }
234122
234516
 
234123
- // ../../node_modules/ky/distribution/utils/timeout.js
234124
- async function timeout(request, init, abortController, options) {
234125
- return new Promise((resolve, reject) => {
234126
- const timeoutId = setTimeout(() => {
234127
- if (abortController) {
234128
- abortController.abort();
234129
- }
234130
- reject(new TimeoutError2(request));
234131
- }, options.timeout);
234132
- options.fetch(request, init).then(resolve).catch(reject).then(() => {
234133
- clearTimeout(timeoutId);
234134
- });
234135
- });
234517
+ class CLIError extends Error {
234518
+ hints;
234519
+ details;
234520
+ cause;
234521
+ constructor(message, options) {
234522
+ super(message);
234523
+ this.name = this.constructor.name;
234524
+ this.hints = options?.hints ?? [];
234525
+ this.details = options?.details ?? [];
234526
+ this.cause = options?.cause;
234527
+ Error.captureStackTrace(this, this.constructor);
234528
+ }
234136
234529
  }
234137
234530
 
234138
- // ../../node_modules/ky/distribution/utils/delay.js
234139
- async function delay(ms, { signal }) {
234140
- return new Promise((resolve, reject) => {
234141
- if (signal) {
234142
- signal.throwIfAborted();
234143
- signal.addEventListener("abort", abortHandler, { once: true });
234144
- }
234145
- function abortHandler() {
234146
- clearTimeout(timeoutId);
234147
- reject(signal.reason);
234148
- }
234149
- const timeoutId = setTimeout(() => {
234150
- signal?.removeEventListener("abort", abortHandler);
234151
- resolve();
234152
- }, ms);
234153
- });
234531
+ class UserError extends CLIError {
234154
234532
  }
234155
234533
 
234156
- // ../../node_modules/ky/distribution/utils/options.js
234157
- var findUnknownOptions = (request, options) => {
234158
- const unknownOptions = {};
234159
- for (const key in options) {
234160
- if (!Object.hasOwn(options, key)) {
234161
- continue;
234162
- }
234163
- if (!(key in requestOptionsRegistry) && !(key in kyOptionKeys) && (!(key in request) || (key in vendorSpecificOptions))) {
234164
- unknownOptions[key] = options[key];
234165
- }
234166
- }
234167
- return unknownOptions;
234168
- };
234169
- var hasSearchParameters = (search) => {
234170
- if (search === undefined) {
234171
- return false;
234534
+ class SystemError extends CLIError {
234535
+ }
234536
+ class AuthExpiredError extends UserError {
234537
+ code = "AUTH_EXPIRED";
234538
+ constructor(message = "Authentication has expired", options) {
234539
+ super(message, {
234540
+ hints: options?.hints ?? [
234541
+ {
234542
+ message: "Run 'base44 login' to re-authenticate",
234543
+ command: "base44 login"
234544
+ }
234545
+ ],
234546
+ cause: options?.cause
234547
+ });
234172
234548
  }
234173
- if (Array.isArray(search)) {
234174
- return search.length > 0;
234549
+ }
234550
+
234551
+ class ConfigNotFoundError extends UserError {
234552
+ code = "CONFIG_NOT_FOUND";
234553
+ constructor(message = "No Base44 project found in this directory", options) {
234554
+ super(message, {
234555
+ hints: options?.hints ?? [
234556
+ {
234557
+ message: "Run 'base44 create' to create a new project",
234558
+ command: "base44 create"
234559
+ },
234560
+ {
234561
+ message: "Or run 'base44 link' to link an existing project",
234562
+ command: "base44 link"
234563
+ }
234564
+ ],
234565
+ cause: options?.cause
234566
+ });
234175
234567
  }
234176
- if (search instanceof URLSearchParams) {
234177
- return search.size > 0;
234568
+ }
234569
+
234570
+ class ConfigInvalidError extends UserError {
234571
+ code = "CONFIG_INVALID";
234572
+ constructor(message, configFilePath, options) {
234573
+ const defaultHint = configFilePath ? `Check the file at ${configFilePath} for syntax errors` : "Check the file for syntax errors";
234574
+ super(message, {
234575
+ hints: options?.hints ?? [{ message: defaultHint }],
234576
+ cause: options?.cause
234577
+ });
234178
234578
  }
234179
- if (typeof search === "object") {
234180
- return Object.keys(search).length > 0;
234579
+ }
234580
+
234581
+ class ConfigExistsError extends UserError {
234582
+ code = "CONFIG_EXISTS";
234583
+ constructor(message, options) {
234584
+ super(message, {
234585
+ hints: options?.hints ?? [
234586
+ {
234587
+ message: "Choose a different location or remove the existing project"
234588
+ }
234589
+ ],
234590
+ cause: options?.cause
234591
+ });
234181
234592
  }
234182
- if (typeof search === "string") {
234183
- return search.trim().length > 0;
234593
+ }
234594
+
234595
+ class SchemaValidationError extends UserError {
234596
+ code = "SCHEMA_INVALID";
234597
+ filePath;
234598
+ constructor(context, zodError, filePath) {
234599
+ const message = filePath ? `${context} in ${filePath}:
234600
+ ${exports_external.prettifyError(zodError)}` : `${context}:
234601
+ ${exports_external.prettifyError(zodError)}`;
234602
+ const hints = filePath ? [{ message: `Fix the schema/data structure errors in ${filePath}` }] : [{ message: "Fix the schema/data structure errors above" }];
234603
+ super(message, { hints });
234604
+ this.filePath = filePath;
234184
234605
  }
234185
- return Boolean(search);
234186
- };
234187
-
234188
- // ../../node_modules/ky/distribution/utils/type-guards.js
234189
- function isHTTPError(error48) {
234190
- return error48 instanceof HTTPError || error48?.name === HTTPError.name;
234191
234606
  }
234192
- function isTimeoutError(error48) {
234193
- return error48 instanceof TimeoutError2 || error48?.name === TimeoutError2.name;
234607
+
234608
+ class InvalidInputError extends UserError {
234609
+ code = "INVALID_INPUT";
234194
234610
  }
234195
234611
 
234196
- // ../../node_modules/ky/distribution/core/Ky.js
234197
- class Ky {
234198
- static create(input, options) {
234199
- const ky = new Ky(input, options);
234200
- const function_ = async () => {
234201
- if (typeof ky.#options.timeout === "number" && ky.#options.timeout > maxSafeTimeout) {
234202
- throw new RangeError(`The \`timeout\` option cannot be greater than ${maxSafeTimeout}`);
234203
- }
234204
- await Promise.resolve();
234205
- let response = await ky.#fetch();
234206
- for (const hook of ky.#options.hooks.afterResponse) {
234207
- const clonedResponse = ky.#decorateResponse(response.clone());
234208
- let modifiedResponse;
234209
- try {
234210
- modifiedResponse = await hook(ky.request, ky.#getNormalizedOptions(), clonedResponse, { retryCount: ky.#retryCount });
234211
- } catch (error48) {
234212
- ky.#cancelResponseBody(clonedResponse);
234213
- ky.#cancelResponseBody(response);
234214
- throw error48;
234215
- }
234216
- if (modifiedResponse instanceof RetryMarker) {
234217
- ky.#cancelResponseBody(clonedResponse);
234218
- ky.#cancelResponseBody(response);
234219
- throw new ForceRetryError(modifiedResponse.options);
234220
- }
234221
- const nextResponse = modifiedResponse instanceof globalThis.Response ? modifiedResponse : response;
234222
- if (clonedResponse !== nextResponse) {
234223
- ky.#cancelResponseBody(clonedResponse);
234224
- }
234225
- if (response !== nextResponse) {
234226
- ky.#cancelResponseBody(response);
234227
- }
234228
- response = nextResponse;
234229
- }
234230
- ky.#decorateResponse(response);
234231
- if (!response.ok && (typeof ky.#options.throwHttpErrors === "function" ? ky.#options.throwHttpErrors(response.status) : ky.#options.throwHttpErrors)) {
234232
- let error48 = new HTTPError(response, ky.request, ky.#getNormalizedOptions());
234233
- for (const hook of ky.#options.hooks.beforeError) {
234234
- error48 = await hook(error48, { retryCount: ky.#retryCount });
234235
- }
234236
- throw error48;
234237
- }
234238
- if (ky.#options.onDownloadProgress) {
234239
- if (typeof ky.#options.onDownloadProgress !== "function") {
234240
- throw new TypeError("The `onDownloadProgress` option must be a function");
234241
- }
234242
- if (!supportsResponseStreams) {
234243
- throw new Error("Streams are not supported in your environment. `ReadableStream` is missing.");
234244
- }
234245
- const progressResponse = response.clone();
234246
- ky.#cancelResponseBody(response);
234247
- return streamResponse(progressResponse, ky.#options.onDownloadProgress);
234248
- }
234249
- return response;
234250
- };
234251
- const result = ky.#retry(function_).finally(() => {
234252
- const originalRequest = ky.#originalRequest;
234253
- ky.#cancelBody(originalRequest?.body ?? undefined);
234254
- ky.#cancelBody(ky.request.body ?? undefined);
234612
+ class DependencyNotFoundError extends UserError {
234613
+ code = "DEPENDENCY_NOT_FOUND";
234614
+ constructor(message, options) {
234615
+ super(message, {
234616
+ hints: options?.hints ?? [
234617
+ { message: "Install the required dependency and try again" }
234618
+ ],
234619
+ cause: options?.cause
234255
234620
  });
234256
- for (const [type, mimeType] of Object.entries(responseTypes)) {
234257
- if (type === "bytes" && typeof globalThis.Response?.prototype?.bytes !== "function") {
234258
- continue;
234259
- }
234260
- result[type] = async () => {
234261
- ky.request.headers.set("accept", ky.request.headers.get("accept") || mimeType);
234262
- const response = await result;
234263
- if (type === "json") {
234264
- if (response.status === 204) {
234265
- return "";
234266
- }
234267
- const text = await response.text();
234268
- if (text === "") {
234269
- return "";
234270
- }
234271
- if (options.parseJson) {
234272
- return options.parseJson(text);
234273
- }
234274
- return JSON.parse(text);
234275
- }
234276
- return response[type]();
234277
- };
234278
- }
234279
- return result;
234280
234621
  }
234281
- static #normalizeSearchParams(searchParams) {
234282
- if (searchParams && typeof searchParams === "object" && !Array.isArray(searchParams) && !(searchParams instanceof URLSearchParams)) {
234283
- return Object.fromEntries(Object.entries(searchParams).filter(([, value]) => value !== undefined));
234284
- }
234285
- return searchParams;
234622
+ }
234623
+
234624
+ class ApiError extends SystemError {
234625
+ code = "API_ERROR";
234626
+ statusCode;
234627
+ requestUrl;
234628
+ requestMethod;
234629
+ requestBody;
234630
+ responseBody;
234631
+ requestId;
234632
+ constructor(message, options) {
234633
+ const hints = options?.hints ?? ApiError.getDefaultHints(options?.statusCode);
234634
+ super(message, { hints, details: options?.details, cause: options?.cause });
234635
+ this.statusCode = options?.statusCode;
234636
+ this.requestUrl = options?.requestUrl;
234637
+ this.requestMethod = options?.requestMethod;
234638
+ this.requestBody = options?.requestBody;
234639
+ this.responseBody = options?.responseBody;
234640
+ this.requestId = options?.requestId;
234286
234641
  }
234287
- request;
234288
- #abortController;
234289
- #retryCount = 0;
234290
- #input;
234291
- #options;
234292
- #originalRequest;
234293
- #userProvidedAbortSignal;
234294
- #cachedNormalizedOptions;
234295
- constructor(input, options = {}) {
234296
- this.#input = input;
234297
- this.#options = {
234298
- ...options,
234299
- headers: mergeHeaders(this.#input.headers, options.headers),
234300
- hooks: mergeHooks({
234301
- beforeRequest: [],
234302
- beforeRetry: [],
234303
- beforeError: [],
234304
- afterResponse: []
234305
- }, options.hooks),
234306
- method: normalizeRequestMethod(options.method ?? this.#input.method ?? "GET"),
234307
- prefixUrl: String(options.prefixUrl || ""),
234308
- retry: normalizeRetryOptions(options.retry),
234309
- throwHttpErrors: options.throwHttpErrors ?? true,
234310
- timeout: options.timeout ?? 1e4,
234311
- fetch: options.fetch ?? globalThis.fetch.bind(globalThis),
234312
- context: options.context ?? {}
234313
- };
234314
- if (typeof this.#input !== "string" && !(this.#input instanceof URL || this.#input instanceof globalThis.Request)) {
234315
- throw new TypeError("`input` must be a string, URL, or Request");
234316
- }
234317
- if (this.#options.prefixUrl && typeof this.#input === "string") {
234318
- if (this.#input.startsWith("/")) {
234319
- throw new Error("`input` must not begin with a slash when using `prefixUrl`");
234320
- }
234321
- if (!this.#options.prefixUrl.endsWith("/")) {
234322
- this.#options.prefixUrl += "/";
234323
- }
234324
- this.#input = this.#options.prefixUrl + this.#input;
234325
- }
234326
- if (supportsAbortController && supportsAbortSignal) {
234327
- this.#userProvidedAbortSignal = this.#options.signal ?? this.#input.signal;
234328
- this.#abortController = new globalThis.AbortController;
234329
- this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
234330
- }
234331
- if (supportsRequestStreams) {
234332
- this.#options.duplex = "half";
234333
- }
234334
- if (this.#options.json !== undefined) {
234335
- this.#options.body = this.#options.stringifyJson?.(this.#options.json) ?? JSON.stringify(this.#options.json);
234336
- this.#options.headers.set("content-type", this.#options.headers.get("content-type") ?? "application/json");
234337
- }
234338
- const userProvidedContentType = options.headers && new globalThis.Headers(options.headers).has("content-type");
234339
- if (this.#input instanceof globalThis.Request && (supportsFormData && this.#options.body instanceof globalThis.FormData || this.#options.body instanceof URLSearchParams) && !userProvidedContentType) {
234340
- this.#options.headers.delete("content-type");
234341
- }
234342
- this.request = new globalThis.Request(this.#input, this.#options);
234343
- if (hasSearchParameters(this.#options.searchParams)) {
234344
- const textSearchParams = typeof this.#options.searchParams === "string" ? this.#options.searchParams.replace(/^\?/, "") : new URLSearchParams(Ky.#normalizeSearchParams(this.#options.searchParams)).toString();
234345
- const searchParams = "?" + textSearchParams;
234346
- const url2 = this.request.url.replace(/(?:\?.*?)?(?=#|$)/, searchParams);
234347
- this.request = new globalThis.Request(url2, this.#options);
234348
- }
234349
- if (this.#options.onUploadProgress) {
234350
- if (typeof this.#options.onUploadProgress !== "function") {
234351
- throw new TypeError("The `onUploadProgress` option must be a function");
234352
- }
234353
- if (!supportsRequestStreams) {
234354
- throw new Error("Request streams are not supported in your environment. The `duplex` option for `Request` is not available.");
234642
+ static async fromHttpError(error48, context) {
234643
+ if (error48 instanceof HTTPError) {
234644
+ let message;
234645
+ let responseBody;
234646
+ let hints;
234647
+ let details;
234648
+ try {
234649
+ responseBody = await error48.response.clone().json();
234650
+ const parsed = ApiErrorResponseSchema.safeParse(responseBody);
234651
+ const parsedData = parsed.success ? parsed.data : undefined;
234652
+ message = formatApiError(responseBody, parsedData);
234653
+ if (parsedData) {
234654
+ hints = ApiError.getReasonHints(parsedData);
234655
+ details = parseErrorDetails(parsedData.extra_data);
234656
+ }
234657
+ } catch {
234658
+ message = error48.message;
234355
234659
  }
234356
- this.request = this.#wrapRequestWithUploadProgress(this.request, this.#options.body ?? undefined);
234660
+ const statusCode = ApiError.normalizeStatusCode(error48.response.status, responseBody);
234661
+ const requestBody = error48.options.context?.__requestBody;
234662
+ const requestId = error48.response.headers.get("X-Request-ID") ?? undefined;
234663
+ return new ApiError(`Error ${context}: ${message}`, {
234664
+ statusCode,
234665
+ requestUrl: error48.request.url,
234666
+ requestMethod: error48.request.method,
234667
+ requestBody,
234668
+ responseBody,
234669
+ requestId,
234670
+ hints,
234671
+ details,
234672
+ cause: error48
234673
+ });
234357
234674
  }
234358
- }
234359
- #calculateDelay() {
234360
- const retryDelay = this.#options.retry.delay(this.#retryCount);
234361
- let jitteredDelay = retryDelay;
234362
- if (this.#options.retry.jitter === true) {
234363
- jitteredDelay = Math.random() * retryDelay;
234364
- } else if (typeof this.#options.retry.jitter === "function") {
234365
- jitteredDelay = this.#options.retry.jitter(retryDelay);
234366
- if (!Number.isFinite(jitteredDelay) || jitteredDelay < 0) {
234367
- jitteredDelay = retryDelay;
234368
- }
234675
+ if (error48 instanceof Error) {
234676
+ return new ApiError(`Error ${context}: ${error48.message}`, {
234677
+ cause: error48
234678
+ });
234369
234679
  }
234370
- const backoffLimit = this.#options.retry.backoffLimit ?? Number.POSITIVE_INFINITY;
234371
- return Math.min(backoffLimit, jitteredDelay);
234680
+ return new ApiError(`Error ${context}: ${String(error48)}`);
234372
234681
  }
234373
- async#calculateRetryDelay(error48) {
234374
- this.#retryCount++;
234375
- if (this.#retryCount > this.#options.retry.limit) {
234376
- throw error48;
234377
- }
234378
- const errorObject = error48 instanceof Error ? error48 : new NonError(error48);
234379
- if (errorObject instanceof ForceRetryError) {
234380
- return errorObject.customDelay ?? this.#calculateDelay();
234682
+ static getDefaultHints(statusCode) {
234683
+ if (statusCode === 400) {
234684
+ return [
234685
+ {
234686
+ message: "The server rejected the request. Check the error message above for details."
234687
+ }
234688
+ ];
234381
234689
  }
234382
- if (!this.#options.retry.methods.includes(this.request.method.toLowerCase())) {
234383
- throw error48;
234690
+ if (statusCode === 401) {
234691
+ return [{ message: "Try logging in again", command: "base44 login" }];
234384
234692
  }
234385
- if (this.#options.retry.shouldRetry !== undefined) {
234386
- const result = await this.#options.retry.shouldRetry({ error: errorObject, retryCount: this.#retryCount });
234387
- if (result === false) {
234388
- throw error48;
234389
- }
234390
- if (result === true) {
234391
- return this.#calculateDelay();
234392
- }
234693
+ if (statusCode === 403) {
234694
+ return [{ message: "You don't have permission to perform this action" }];
234393
234695
  }
234394
- if (isTimeoutError(error48) && !this.#options.retry.retryOnTimeout) {
234395
- throw error48;
234696
+ if (statusCode === 404) {
234697
+ return [{ message: "The requested resource was not found" }];
234396
234698
  }
234397
- if (isHTTPError(error48)) {
234398
- if (!this.#options.retry.statusCodes.includes(error48.response.status)) {
234399
- throw error48;
234400
- }
234401
- const retryAfter = error48.response.headers.get("Retry-After") ?? error48.response.headers.get("RateLimit-Reset") ?? error48.response.headers.get("X-RateLimit-Retry-After") ?? error48.response.headers.get("X-RateLimit-Reset") ?? error48.response.headers.get("X-Rate-Limit-Reset");
234402
- if (retryAfter && this.#options.retry.afterStatusCodes.includes(error48.response.status)) {
234403
- let after = Number(retryAfter) * 1000;
234404
- if (Number.isNaN(after)) {
234405
- after = Date.parse(retryAfter) - Date.now();
234406
- } else if (after >= Date.parse("2024-01-01")) {
234407
- after -= Date.now();
234699
+ if (statusCode === 422) {
234700
+ return [
234701
+ {
234702
+ message: "The request was rejected due to a validation error. Check the error message above for details."
234408
234703
  }
234409
- const max = this.#options.retry.maxRetryAfter ?? after;
234410
- return after < max ? after : max;
234411
- }
234412
- if (error48.response.status === 413) {
234413
- throw error48;
234414
- }
234415
- }
234416
- return this.#calculateDelay();
234417
- }
234418
- #decorateResponse(response) {
234419
- if (this.#options.parseJson) {
234420
- response.json = async () => this.#options.parseJson(await response.text());
234704
+ ];
234421
234705
  }
234422
- return response;
234423
- }
234424
- #cancelBody(body) {
234425
- if (!body) {
234426
- return;
234706
+ if (statusCode === 428) {
234707
+ return [
234708
+ {
234709
+ message: "The server rejected the request due to a precondition failure. Check the error message above for details"
234710
+ }
234711
+ ];
234427
234712
  }
234428
- body.cancel().catch(() => {
234429
- return;
234430
- });
234431
- }
234432
- #cancelResponseBody(response) {
234433
- this.#cancelBody(response.body ?? undefined);
234713
+ return [{ message: "Check your network connection and try again" }];
234434
234714
  }
234435
- async#retry(function_) {
234436
- try {
234437
- return await function_();
234438
- } catch (error48) {
234439
- const ms = Math.min(await this.#calculateRetryDelay(error48), maxSafeTimeout);
234440
- if (this.#retryCount < 1) {
234441
- throw error48;
234442
- }
234443
- await delay(ms, this.#userProvidedAbortSignal ? { signal: this.#userProvidedAbortSignal } : {});
234444
- if (error48 instanceof ForceRetryError && error48.customRequest) {
234445
- const managedRequest = this.#options.signal ? new globalThis.Request(error48.customRequest, { signal: this.#options.signal }) : new globalThis.Request(error48.customRequest);
234446
- this.#assignRequest(managedRequest);
234447
- }
234448
- for (const hook of this.#options.hooks.beforeRetry) {
234449
- const hookResult = await hook({
234450
- request: this.request,
234451
- options: this.#getNormalizedOptions(),
234452
- error: error48,
234453
- retryCount: this.#retryCount
234454
- });
234455
- if (hookResult instanceof globalThis.Request) {
234456
- this.#assignRequest(hookResult);
234457
- break;
234458
- }
234459
- if (hookResult instanceof globalThis.Response) {
234460
- return hookResult;
234461
- }
234462
- if (hookResult === stop) {
234463
- return;
234715
+ static getReasonHints(parsedResponse) {
234716
+ const REASON_HINTS = {
234717
+ requires_backend_platform_app: [
234718
+ {
234719
+ message: "This feature requires an app created with the Base44 CLI. Remove `base44/.app.jsonc` and run 'base44 link' to connect your project to a CLI-created app."
234720
+ },
234721
+ {
234722
+ message: "Read more at https://docs.base44.com/developers/backend/overview/introduction"
234464
234723
  }
234465
- }
234466
- return this.#retry(function_);
234467
- }
234724
+ ]
234725
+ };
234726
+ const reason = parsedResponse.extra_data?.reason;
234727
+ if (typeof reason !== "string")
234728
+ return;
234729
+ return REASON_HINTS[reason];
234468
234730
  }
234469
- async#fetch() {
234470
- if (this.#abortController?.signal.aborted) {
234471
- this.#abortController = new globalThis.AbortController;
234472
- this.#options.signal = this.#userProvidedAbortSignal ? AbortSignal.any([this.#userProvidedAbortSignal, this.#abortController.signal]) : this.#abortController.signal;
234473
- this.request = new globalThis.Request(this.request, { signal: this.#options.signal });
234474
- }
234475
- for (const hook of this.#options.hooks.beforeRequest) {
234476
- const result = await hook(this.request, this.#getNormalizedOptions(), { retryCount: this.#retryCount });
234477
- if (result instanceof Response) {
234478
- return result;
234479
- }
234480
- if (result instanceof globalThis.Request) {
234481
- this.#assignRequest(result);
234482
- break;
234483
- }
234484
- }
234485
- const nonRequestOptions = findUnknownOptions(this.request, this.#options);
234486
- this.#originalRequest = this.request;
234487
- this.request = this.#originalRequest.clone();
234488
- if (this.#options.timeout === false) {
234489
- return this.#options.fetch(this.#originalRequest, nonRequestOptions);
234731
+ static normalizeStatusCode(statusCode, responseBody) {
234732
+ if (responseBody?.error_type === "KeyError") {
234733
+ return 404;
234490
234734
  }
234491
- return timeout(this.#originalRequest, nonRequestOptions, this.#abortController, this.#options);
234735
+ return statusCode;
234492
234736
  }
234493
- #getNormalizedOptions() {
234494
- if (!this.#cachedNormalizedOptions) {
234495
- const { hooks, ...normalizedOptions } = this.#options;
234496
- this.#cachedNormalizedOptions = Object.freeze(normalizedOptions);
234497
- }
234498
- return this.#cachedNormalizedOptions;
234737
+ }
234738
+
234739
+ class FileNotFoundError extends SystemError {
234740
+ code = "FILE_NOT_FOUND";
234741
+ constructor(message, options) {
234742
+ super(message, {
234743
+ hints: options?.hints ?? [
234744
+ { message: "Check the file path and try again" }
234745
+ ],
234746
+ cause: options?.cause
234747
+ });
234499
234748
  }
234500
- #assignRequest(request) {
234501
- this.#cachedNormalizedOptions = undefined;
234502
- this.request = this.#wrapRequestWithUploadProgress(request);
234749
+ }
234750
+
234751
+ class FileReadError extends SystemError {
234752
+ code = "FILE_READ_ERROR";
234753
+ constructor(message, options) {
234754
+ super(message, {
234755
+ hints: options?.hints ?? [
234756
+ { message: "Check file permissions and try again" }
234757
+ ],
234758
+ cause: options?.cause
234759
+ });
234503
234760
  }
234504
- #wrapRequestWithUploadProgress(request, originalBody) {
234505
- if (!this.#options.onUploadProgress || !request.body) {
234506
- return request;
234507
- }
234508
- return streamRequest(request, this.#options.onUploadProgress, originalBody ?? this.#options.body ?? undefined);
234761
+ }
234762
+
234763
+ class InternalError extends SystemError {
234764
+ code = "INTERNAL_ERROR";
234765
+ constructor(message, options) {
234766
+ super(message, {
234767
+ hints: options?.hints ?? [
234768
+ {
234769
+ message: "This is an unexpected error. Please report it if it persists."
234770
+ }
234771
+ ],
234772
+ cause: options?.cause
234773
+ });
234509
234774
  }
234510
234775
  }
234511
- // ../../node_modules/ky/distribution/index.js
234512
- /*! MIT License © Sindre Sorhus */
234513
- var createInstance = (defaults) => {
234514
- const ky = (input, options) => Ky.create(input, validateAndMerge(defaults, options));
234515
- for (const method of requestMethods) {
234516
- ky[method] = (input, options) => Ky.create(input, validateAndMerge(defaults, options, { method }));
234776
+
234777
+ class TypeGenerationError extends SystemError {
234778
+ code = "TYPE_GENERATION_ERROR";
234779
+ constructor(message, entityName, cause) {
234780
+ super(message, {
234781
+ hints: [
234782
+ {
234783
+ message: entityName ? `Check the schema for entity "${entityName}"` : "Check your entity schemas for errors"
234784
+ }
234785
+ ],
234786
+ cause: cause instanceof Error ? cause : undefined
234787
+ });
234517
234788
  }
234518
- ky.create = (newDefaults) => createInstance(validateAndMerge(newDefaults));
234519
- ky.extend = (newDefaults) => {
234520
- if (typeof newDefaults === "function") {
234521
- newDefaults = newDefaults(defaults ?? {});
234522
- }
234523
- return createInstance(validateAndMerge(defaults, newDefaults));
234524
- };
234525
- ky.stop = stop;
234526
- ky.retry = retry;
234527
- return ky;
234528
- };
234529
- var ky = createInstance();
234530
- var distribution_default = ky;
234789
+ }
234790
+ function isCLIError(error48) {
234791
+ return error48 instanceof CLIError;
234792
+ }
234793
+ function isUserError(error48) {
234794
+ return error48 instanceof UserError;
234795
+ }
234796
+
234797
+ // src/core/auth/schema.ts
234798
+ var AuthDataSchema = exports_external.object({
234799
+ accessToken: exports_external.string().min(1, "Token cannot be empty"),
234800
+ refreshToken: exports_external.string().min(1, "Refresh token cannot be empty"),
234801
+ expiresAt: exports_external.number().int().positive("Expires at must be a positive integer"),
234802
+ email: exports_external.email(),
234803
+ name: exports_external.string().min(1, "Name cannot be empty")
234804
+ });
234805
+ var DeviceCodeResponseSchema = exports_external.object({
234806
+ device_code: exports_external.string().min(1, "Device code cannot be empty"),
234807
+ user_code: exports_external.string().min(1, "User code cannot be empty"),
234808
+ verification_uri: exports_external.url("Invalid verification URL"),
234809
+ expires_in: exports_external.number().int().positive("Expires in must be a positive integer"),
234810
+ interval: exports_external.number().int().positive("Interval in must be a positive integer")
234811
+ }).transform((data) => ({
234812
+ deviceCode: data.device_code,
234813
+ userCode: data.user_code,
234814
+ verificationUri: data.verification_uri,
234815
+ expiresIn: data.expires_in,
234816
+ interval: data.interval
234817
+ }));
234818
+ var TokenResponseSchema = exports_external.object({
234819
+ access_token: exports_external.string().min(1, "Token cannot be empty"),
234820
+ token_type: exports_external.string().min(1, "Token type cannot be empty"),
234821
+ expires_in: exports_external.number().int().positive("Expires in must be a positive integer"),
234822
+ refresh_token: exports_external.string().min(1, "Refresh token cannot be empty"),
234823
+ scope: exports_external.string().optional()
234824
+ }).transform((data) => ({
234825
+ accessToken: data.access_token,
234826
+ tokenType: data.token_type,
234827
+ expiresIn: data.expires_in,
234828
+ refreshToken: data.refresh_token,
234829
+ scope: data.scope
234830
+ }));
234831
+ var OAuthErrorSchema = exports_external.object({
234832
+ error: exports_external.string(),
234833
+ error_description: exports_external.string().optional()
234834
+ });
234835
+ var UserInfoSchema = exports_external.object({
234836
+ email: exports_external.email(),
234837
+ name: exports_external.string()
234838
+ });
234839
+
234840
+ // src/core/clients/base44-client.ts
234841
+ import { randomUUID as randomUUID2 } from "node:crypto";
234531
234842
 
234532
234843
  // src/core/config.ts
234533
234844
  import { homedir } from "node:os";
@@ -234633,302 +234944,6 @@ function getTestOverrides() {
234633
234944
  }
234634
234945
  }
234635
234946
 
234636
- // src/core/clients/schemas.ts
234637
- var ApiErrorResponseSchema = exports_external.looseObject({
234638
- message: exports_external.unknown().optional(),
234639
- detail: exports_external.unknown().optional(),
234640
- extra_data: exports_external.looseObject({
234641
- reason: exports_external.string().optional().catch(undefined),
234642
- errors: exports_external.array(exports_external.looseObject({ name: exports_external.string(), message: exports_external.string() })).optional().catch(undefined)
234643
- }).optional().nullable().catch(undefined)
234644
- });
234645
-
234646
- // src/core/errors.ts
234647
- function formatApiError(errorBody, parsed) {
234648
- const data = parsed ?? ApiErrorResponseSchema.safeParse(errorBody).data;
234649
- if (data) {
234650
- const content = data.message ?? data.detail;
234651
- if (typeof content === "string")
234652
- return content;
234653
- if (content !== undefined)
234654
- return JSON.stringify(content, null, 2);
234655
- }
234656
- if (typeof errorBody === "string")
234657
- return errorBody;
234658
- return JSON.stringify(errorBody, null, 2);
234659
- }
234660
- function parseErrorDetails(extraData) {
234661
- const errors3 = extraData?.errors;
234662
- if (!errors3 || errors3.length === 0)
234663
- return;
234664
- return errors3.map((e2) => `${e2.name}: ${e2.message}`);
234665
- }
234666
-
234667
- class CLIError extends Error {
234668
- hints;
234669
- details;
234670
- cause;
234671
- constructor(message, options) {
234672
- super(message);
234673
- this.name = this.constructor.name;
234674
- this.hints = options?.hints ?? [];
234675
- this.details = options?.details ?? [];
234676
- this.cause = options?.cause;
234677
- Error.captureStackTrace(this, this.constructor);
234678
- }
234679
- }
234680
-
234681
- class UserError extends CLIError {
234682
- }
234683
-
234684
- class SystemError extends CLIError {
234685
- }
234686
- class ConfigNotFoundError extends UserError {
234687
- code = "CONFIG_NOT_FOUND";
234688
- constructor(message = "No Base44 project found in this directory", options) {
234689
- super(message, {
234690
- hints: options?.hints ?? [
234691
- {
234692
- message: "Run 'base44 create' to create a new project",
234693
- command: "base44 create"
234694
- },
234695
- {
234696
- message: "Or run 'base44 link' to link an existing project",
234697
- command: "base44 link"
234698
- }
234699
- ],
234700
- cause: options?.cause
234701
- });
234702
- }
234703
- }
234704
-
234705
- class ConfigInvalidError extends UserError {
234706
- code = "CONFIG_INVALID";
234707
- constructor(message, configFilePath, options) {
234708
- const defaultHint = configFilePath ? `Check the file at ${configFilePath} for syntax errors` : "Check the file for syntax errors";
234709
- super(message, {
234710
- hints: options?.hints ?? [{ message: defaultHint }],
234711
- cause: options?.cause
234712
- });
234713
- }
234714
- }
234715
-
234716
- class ConfigExistsError extends UserError {
234717
- code = "CONFIG_EXISTS";
234718
- constructor(message, options) {
234719
- super(message, {
234720
- hints: options?.hints ?? [
234721
- {
234722
- message: "Choose a different location or remove the existing project"
234723
- }
234724
- ],
234725
- cause: options?.cause
234726
- });
234727
- }
234728
- }
234729
-
234730
- class SchemaValidationError extends UserError {
234731
- code = "SCHEMA_INVALID";
234732
- filePath;
234733
- constructor(context, zodError, filePath) {
234734
- const message = filePath ? `${context} in ${filePath}:
234735
- ${exports_external.prettifyError(zodError)}` : `${context}:
234736
- ${exports_external.prettifyError(zodError)}`;
234737
- const hints = filePath ? [{ message: `Fix the schema/data structure errors in ${filePath}` }] : [{ message: "Fix the schema/data structure errors above" }];
234738
- super(message, { hints });
234739
- this.filePath = filePath;
234740
- }
234741
- }
234742
-
234743
- class InvalidInputError extends UserError {
234744
- code = "INVALID_INPUT";
234745
- }
234746
-
234747
- class DependencyNotFoundError extends UserError {
234748
- code = "DEPENDENCY_NOT_FOUND";
234749
- constructor(message, options) {
234750
- super(message, {
234751
- hints: options?.hints ?? [
234752
- { message: "Install the required dependency and try again" }
234753
- ],
234754
- cause: options?.cause
234755
- });
234756
- }
234757
- }
234758
-
234759
- class ApiError extends SystemError {
234760
- code = "API_ERROR";
234761
- statusCode;
234762
- requestUrl;
234763
- requestMethod;
234764
- requestBody;
234765
- responseBody;
234766
- requestId;
234767
- constructor(message, options) {
234768
- const hints = options?.hints ?? ApiError.getDefaultHints(options?.statusCode);
234769
- super(message, { hints, details: options?.details, cause: options?.cause });
234770
- this.statusCode = options?.statusCode;
234771
- this.requestUrl = options?.requestUrl;
234772
- this.requestMethod = options?.requestMethod;
234773
- this.requestBody = options?.requestBody;
234774
- this.responseBody = options?.responseBody;
234775
- this.requestId = options?.requestId;
234776
- }
234777
- static async fromHttpError(error48, context) {
234778
- if (error48 instanceof HTTPError) {
234779
- let message;
234780
- let responseBody;
234781
- let hints;
234782
- let details;
234783
- try {
234784
- responseBody = await error48.response.clone().json();
234785
- const parsed = ApiErrorResponseSchema.safeParse(responseBody);
234786
- const parsedData = parsed.success ? parsed.data : undefined;
234787
- message = formatApiError(responseBody, parsedData);
234788
- if (parsedData) {
234789
- hints = ApiError.getReasonHints(parsedData);
234790
- details = parseErrorDetails(parsedData.extra_data);
234791
- }
234792
- } catch {
234793
- message = error48.message;
234794
- }
234795
- const statusCode = ApiError.normalizeStatusCode(error48.response.status, responseBody);
234796
- const requestBody = error48.options.context?.__requestBody;
234797
- const requestId = error48.response.headers.get("X-Request-ID") ?? undefined;
234798
- return new ApiError(`Error ${context}: ${message}`, {
234799
- statusCode,
234800
- requestUrl: error48.request.url,
234801
- requestMethod: error48.request.method,
234802
- requestBody,
234803
- responseBody,
234804
- requestId,
234805
- hints,
234806
- details,
234807
- cause: error48
234808
- });
234809
- }
234810
- if (error48 instanceof Error) {
234811
- return new ApiError(`Error ${context}: ${error48.message}`, {
234812
- cause: error48
234813
- });
234814
- }
234815
- return new ApiError(`Error ${context}: ${String(error48)}`);
234816
- }
234817
- static getDefaultHints(statusCode) {
234818
- if (statusCode === 400) {
234819
- return [
234820
- {
234821
- message: "The server rejected the request. Check the error message above for details."
234822
- }
234823
- ];
234824
- }
234825
- if (statusCode === 401) {
234826
- return [{ message: "Try logging in again", command: "base44 login" }];
234827
- }
234828
- if (statusCode === 403) {
234829
- return [{ message: "You don't have permission to perform this action" }];
234830
- }
234831
- if (statusCode === 404) {
234832
- return [{ message: "The requested resource was not found" }];
234833
- }
234834
- if (statusCode === 422) {
234835
- return [
234836
- {
234837
- message: "The request was rejected due to a validation error. Check the error message above for details."
234838
- }
234839
- ];
234840
- }
234841
- if (statusCode === 428) {
234842
- return [
234843
- {
234844
- message: "The server rejected the request due to a precondition failure. Check the error message above for details"
234845
- }
234846
- ];
234847
- }
234848
- return [{ message: "Check your network connection and try again" }];
234849
- }
234850
- static getReasonHints(parsedResponse) {
234851
- const REASON_HINTS = {
234852
- requires_backend_platform_app: [
234853
- {
234854
- message: "This feature requires an app created with the Base44 CLI. Remove `base44/.app.jsonc` and run 'base44 link' to connect your project to a CLI-created app."
234855
- },
234856
- {
234857
- message: "Read more at https://docs.base44.com/developers/backend/overview/introduction"
234858
- }
234859
- ]
234860
- };
234861
- const reason = parsedResponse.extra_data?.reason;
234862
- if (typeof reason !== "string")
234863
- return;
234864
- return REASON_HINTS[reason];
234865
- }
234866
- static normalizeStatusCode(statusCode, responseBody) {
234867
- if (responseBody?.error_type === "KeyError") {
234868
- return 404;
234869
- }
234870
- return statusCode;
234871
- }
234872
- }
234873
-
234874
- class FileNotFoundError extends SystemError {
234875
- code = "FILE_NOT_FOUND";
234876
- constructor(message, options) {
234877
- super(message, {
234878
- hints: options?.hints ?? [
234879
- { message: "Check the file path and try again" }
234880
- ],
234881
- cause: options?.cause
234882
- });
234883
- }
234884
- }
234885
-
234886
- class FileReadError extends SystemError {
234887
- code = "FILE_READ_ERROR";
234888
- constructor(message, options) {
234889
- super(message, {
234890
- hints: options?.hints ?? [
234891
- { message: "Check file permissions and try again" }
234892
- ],
234893
- cause: options?.cause
234894
- });
234895
- }
234896
- }
234897
-
234898
- class InternalError extends SystemError {
234899
- code = "INTERNAL_ERROR";
234900
- constructor(message, options) {
234901
- super(message, {
234902
- hints: options?.hints ?? [
234903
- {
234904
- message: "This is an unexpected error. Please report it if it persists."
234905
- }
234906
- ],
234907
- cause: options?.cause
234908
- });
234909
- }
234910
- }
234911
-
234912
- class TypeGenerationError extends SystemError {
234913
- code = "TYPE_GENERATION_ERROR";
234914
- constructor(message, entityName, cause) {
234915
- super(message, {
234916
- hints: [
234917
- {
234918
- message: entityName ? `Check the schema for entity "${entityName}"` : "Check your entity schemas for errors"
234919
- }
234920
- ],
234921
- cause: cause instanceof Error ? cause : undefined
234922
- });
234923
- }
234924
- }
234925
- function isCLIError(error48) {
234926
- return error48 instanceof CLIError;
234927
- }
234928
- function isUserError(error48) {
234929
- return error48 instanceof UserError;
234930
- }
234931
-
234932
234947
  // src/core/utils/fs.ts
234933
234948
  var import_json5 = __toESM(require_lib(), 1);
234934
234949
  import {
@@ -242523,67 +242538,6 @@ async function readAllEntities(entitiesDir) {
242523
242538
  const entities = await Promise.all(files.map((filePath) => readEntityFile(filePath)));
242524
242539
  return entities;
242525
242540
  }
242526
- // src/core/resources/entity/data-api.ts
242527
- var EntityRecordSchema = exports_external.object({
242528
- id: exports_external.string(),
242529
- created_date: exports_external.string()
242530
- }).passthrough();
242531
- var EntityRecordListSchema = exports_external.array(EntityRecordSchema);
242532
- var CountResponseSchema = exports_external.object({
242533
- count: exports_external.number()
242534
- });
242535
- async function listEntityRecords(entityName, options = {}) {
242536
- const appClient = getAppClient();
242537
- const searchParams = new URLSearchParams;
242538
- if (options.limit !== undefined) {
242539
- searchParams.set("limit", String(options.limit));
242540
- }
242541
- if (options.skip !== undefined) {
242542
- searchParams.set("skip", String(options.skip));
242543
- }
242544
- if (options.sort) {
242545
- searchParams.set("sort", options.sort);
242546
- }
242547
- let response;
242548
- try {
242549
- response = await appClient.get(`entities/${encodeURIComponent(entityName)}`, { searchParams, timeout: 30000 });
242550
- } catch (error48) {
242551
- throw await ApiError.fromHttpError(error48, `listing records for entity "${entityName}"`);
242552
- }
242553
- const result = EntityRecordListSchema.safeParse(await response.json());
242554
- if (!result.success) {
242555
- throw new SchemaValidationError("Invalid response from server", result.error);
242556
- }
242557
- return result.data;
242558
- }
242559
- async function getEntityRecord(entityName, id) {
242560
- const appClient = getAppClient();
242561
- let response;
242562
- try {
242563
- response = await appClient.get(`entities/${encodeURIComponent(entityName)}/${encodeURIComponent(id)}`, { timeout: 30000 });
242564
- } catch (error48) {
242565
- throw await ApiError.fromHttpError(error48, `fetching record "${id}" from entity "${entityName}"`);
242566
- }
242567
- const result = EntityRecordSchema.safeParse(await response.json());
242568
- if (!result.success) {
242569
- throw new SchemaValidationError("Invalid response from server", result.error);
242570
- }
242571
- return result.data;
242572
- }
242573
- async function countEntityRecords(entityName) {
242574
- const appClient = getAppClient();
242575
- let response;
242576
- try {
242577
- response = await appClient.get(`entities/${encodeURIComponent(entityName)}/count`, { timeout: 30000 });
242578
- } catch (error48) {
242579
- throw await ApiError.fromHttpError(error48, `counting records for entity "${entityName}"`);
242580
- }
242581
- const result = CountResponseSchema.safeParse(await response.json());
242582
- if (!result.success) {
242583
- throw new SchemaValidationError("Invalid response from server", result.error);
242584
- }
242585
- return result.data.count;
242586
- }
242587
242541
  // src/core/resources/entity/deploy.ts
242588
242542
  async function pushEntities(entities) {
242589
242543
  if (entities.length === 0) {
@@ -243690,12 +243644,12 @@ async function waitForAuthentication(deviceCode, expiresIn, interval) {
243690
243644
  });
243691
243645
  } catch (error48) {
243692
243646
  if (error48 instanceof Error && error48.message.includes("timed out")) {
243693
- throw new Error("Authentication timed out. Please try again.");
243647
+ throw new AuthExpiredError("Authentication timed out. Please try again.");
243694
243648
  }
243695
243649
  throw error48;
243696
243650
  }
243697
243651
  if (tokenResponse === undefined) {
243698
- throw new Error("Failed to retrieve authentication token.");
243652
+ throw new InternalError("Failed to retrieve authentication token.");
243699
243653
  }
243700
243654
  return tokenResponse;
243701
243655
  }
@@ -251692,164 +251646,6 @@ function getDashboardCommand() {
251692
251646
  return new Command("dashboard").description("Manage app dashboard").addCommand(getDashboardOpenCommand());
251693
251647
  }
251694
251648
 
251695
- // src/cli/commands/automations/status.ts
251696
- function formatAutomationType(automation) {
251697
- if (automation.type === "entity")
251698
- return "entity";
251699
- if (automation.type === "scheduled") {
251700
- if (automation.schedule_mode === "one-time")
251701
- return "scheduled (one-time)";
251702
- if (automation.schedule_type === "cron")
251703
- return "scheduled (cron)";
251704
- return "scheduled (simple)";
251705
- }
251706
- return automation.type;
251707
- }
251708
- async function statusAction({
251709
- log
251710
- }) {
251711
- const { functions } = await runTask("Fetching automations...", async () => listDeployedFunctions(), { errorMessage: "Failed to fetch automations" });
251712
- let totalAutomations = 0;
251713
- let functionsWithAutomations = 0;
251714
- for (const fn of functions) {
251715
- if (fn.automations.length === 0)
251716
- continue;
251717
- functionsWithAutomations++;
251718
- for (const automation of fn.automations) {
251719
- totalAutomations++;
251720
- const active = automation.is_active;
251721
- const statusLabel = active ? theme.styles.bold("active") : theme.styles.dim("disabled");
251722
- const typeLabel = formatAutomationType(automation);
251723
- log.message(` ${fn.name} / ${automation.name} ${theme.styles.dim(typeLabel)} ${statusLabel}`);
251724
- }
251725
- }
251726
- if (totalAutomations === 0) {
251727
- return { outroMessage: "No automations found" };
251728
- }
251729
- return {
251730
- outroMessage: `${totalAutomations} automation${totalAutomations !== 1 ? "s" : ""} across ${functionsWithAutomations} function${functionsWithAutomations !== 1 ? "s" : ""}`
251731
- };
251732
- }
251733
- function getAutomationsStatusCommand() {
251734
- return new Base44Command("status").description("Show status of all automations").action(statusAction);
251735
- }
251736
-
251737
- // src/cli/commands/automations/index.ts
251738
- function getAutomationsCommand() {
251739
- return new Command("automations").description("Manage automations").addCommand(getAutomationsStatusCommand());
251740
- }
251741
-
251742
- // src/cli/commands/entities/count.ts
251743
- async function countAction(_ctx, entityName) {
251744
- const count2 = await runTask(`Counting ${entityName} records...`, async () => countEntityRecords(entityName), { errorMessage: `Failed to count ${entityName} records` });
251745
- return {
251746
- outroMessage: `${entityName} has ${count2} record${count2 !== 1 ? "s" : ""}`
251747
- };
251748
- }
251749
- function getEntitiesCountCommand() {
251750
- return new Base44Command("count").description("Count total records for an entity").argument("<entityName>", "Name of the entity").action(countAction);
251751
- }
251752
-
251753
- // src/cli/commands/entities/get.ts
251754
- async function getAction(_ctx, entityName, id) {
251755
- const record2 = await runTask(`Fetching ${entityName} record...`, async () => getEntityRecord(entityName, id), { errorMessage: `Failed to fetch ${entityName} record "${id}"` });
251756
- const formatted = JSON.stringify(record2, null, 2);
251757
- return {
251758
- outroMessage: `Fetched ${entityName} record ${id}`,
251759
- stdout: `${formatted}
251760
- `
251761
- };
251762
- }
251763
- function getEntitiesGetCommand() {
251764
- return new Base44Command("get").description("Get a single entity record by ID").argument("<entityName>", "Name of the entity").argument("<id>", "Record ID").action(getAction);
251765
- }
251766
-
251767
- // src/cli/commands/entities/list.ts
251768
- function formatRecordRow(record2, fields) {
251769
- const values = fields.map((field) => {
251770
- const value = record2[field];
251771
- if (value === undefined || value === null)
251772
- return "-";
251773
- if (typeof value === "object")
251774
- return JSON.stringify(value);
251775
- return String(value);
251776
- });
251777
- return values.join("\t");
251778
- }
251779
- function pickDisplayFields(records) {
251780
- const systemFields = ["id", "created_date"];
251781
- if (records.length === 0)
251782
- return systemFields;
251783
- const skipFields = new Set([
251784
- "id",
251785
- "created_date",
251786
- "updated_date",
251787
- "created_by",
251788
- "created_by_id",
251789
- "app_id",
251790
- "entity_name",
251791
- "is_deleted",
251792
- "deleted_date",
251793
- "environment",
251794
- "_id"
251795
- ]);
251796
- const dataFields = [];
251797
- for (const key of Object.keys(records[0])) {
251798
- if (!skipFields.has(key) && dataFields.length < 4) {
251799
- dataFields.push(key);
251800
- }
251801
- }
251802
- return [...systemFields, ...dataFields];
251803
- }
251804
- function validateLimit(limit) {
251805
- if (limit === undefined)
251806
- return;
251807
- const n2 = Number.parseInt(limit, 10);
251808
- if (Number.isNaN(n2) || n2 < 1) {
251809
- throw new InvalidInputError(`Invalid limit: "${limit}". Must be a positive integer.`);
251810
- }
251811
- }
251812
- function validateSkip(skip) {
251813
- if (skip === undefined)
251814
- return;
251815
- const n2 = Number.parseInt(skip, 10);
251816
- if (Number.isNaN(n2) || n2 < 0) {
251817
- throw new InvalidInputError(`Invalid skip: "${skip}". Must be a non-negative integer.`);
251818
- }
251819
- }
251820
- async function listAction({ log }, entityName, options) {
251821
- validateLimit(options.limit);
251822
- validateSkip(options.skip);
251823
- const apiOptions = {};
251824
- if (options.limit) {
251825
- apiOptions.limit = Number.parseInt(options.limit, 10);
251826
- } else {
251827
- apiOptions.limit = 10;
251828
- }
251829
- if (options.skip) {
251830
- apiOptions.skip = Number.parseInt(options.skip, 10);
251831
- }
251832
- if (options.sort) {
251833
- apiOptions.sort = options.sort;
251834
- }
251835
- const records = await runTask(`Fetching ${entityName} records...`, async () => listEntityRecords(entityName, apiOptions), { errorMessage: `Failed to fetch ${entityName} records` });
251836
- if (records.length === 0) {
251837
- return { outroMessage: `No records found for ${entityName}` };
251838
- }
251839
- const fields = pickDisplayFields(records);
251840
- const header2 = fields.join("\t");
251841
- log.message(theme.styles.dim(header2));
251842
- for (const record2 of records) {
251843
- log.message(` ${formatRecordRow(record2, fields)}`);
251844
- }
251845
- return {
251846
- outroMessage: `Showing ${records.length} ${entityName} record${records.length !== 1 ? "s" : ""}`
251847
- };
251848
- }
251849
- function getEntitiesListCommand() {
251850
- return new Base44Command("list").description("List entity records").argument("<entityName>", "Name of the entity").option("-n, --limit <n>", "Maximum number of records to return (default: 10)").option("--sort <field>", "Field to sort by").option("--skip <n>", "Number of records to skip").action(listAction);
251851
- }
251852
-
251853
251649
  // src/cli/commands/entities/push.ts
251854
251650
  async function pushEntitiesAction({
251855
251651
  log
@@ -251878,12 +251674,7 @@ async function pushEntitiesAction({
251878
251674
  return { outroMessage: "Entities pushed to Base44" };
251879
251675
  }
251880
251676
  function getEntitiesPushCommand() {
251881
- return new Base44Command("push").description("Push local entities to Base44").action(pushEntitiesAction);
251882
- }
251883
-
251884
- // src/cli/commands/entities/index.ts
251885
- function getEntitiesCommand() {
251886
- return new Command("entities").description("Manage project entities").addCommand(getEntitiesPushCommand()).addCommand(getEntitiesListCommand()).addCommand(getEntitiesGetCommand()).addCommand(getEntitiesCountCommand());
251677
+ return new Command("entities").description("Manage project entities").addCommand(new Base44Command("push").description("Push local entities to Base44").action(pushEntitiesAction));
251887
251678
  }
251888
251679
 
251889
251680
  // src/cli/commands/functions/delete.ts
@@ -252646,7 +252437,7 @@ async function getAllFunctionNames() {
252646
252437
  const { functions } = await readProjectConfig();
252647
252438
  return functions.map((fn) => fn.name);
252648
252439
  }
252649
- function validateLimit2(limit) {
252440
+ function validateLimit(limit) {
252650
252441
  if (limit === undefined)
252651
252442
  return;
252652
252443
  const n2 = Number.parseInt(limit, 10);
@@ -252655,7 +252446,7 @@ function validateLimit2(limit) {
252655
252446
  }
252656
252447
  }
252657
252448
  async function logsAction(_ctx, options) {
252658
- validateLimit2(options.limit);
252449
+ validateLimit(options.limit);
252659
252450
  const specifiedFunctions = parseFunctionNames(options.function);
252660
252451
  const allProjectFunctions = await getAllFunctionNames();
252661
252452
  const functionNames = specifiedFunctions.length > 0 ? specifiedFunctions : allProjectFunctions;
@@ -256097,7 +255888,7 @@ function createProgram(context) {
256097
255888
  program2.addCommand(getDeployCommand2());
256098
255889
  program2.addCommand(getLinkCommand());
256099
255890
  program2.addCommand(getEjectCommand());
256100
- program2.addCommand(getEntitiesCommand());
255891
+ program2.addCommand(getEntitiesPushCommand());
256101
255892
  program2.addCommand(getAgentsCommand());
256102
255893
  program2.addCommand(getConnectorsCommand());
256103
255894
  program2.addCommand(getFunctionsCommand());
@@ -256105,7 +255896,6 @@ function createProgram(context) {
256105
255896
  program2.addCommand(getAuthCommand());
256106
255897
  program2.addCommand(getSiteCommand());
256107
255898
  program2.addCommand(getTypesCommand());
256108
- program2.addCommand(getAutomationsCommand());
256109
255899
  program2.addCommand(getExecCommand());
256110
255900
  program2.addCommand(getDevCommand(), { hidden: true });
256111
255901
  program2.addCommand(getLogsCommand());
@@ -260352,4 +260142,4 @@ export {
260352
260142
  CLIExitError
260353
260143
  };
260354
260144
 
260355
- //# debugId=EBAC219376D5C03964756E2164756E21
260145
+ //# debugId=2F95C59D7C57E46064756E2164756E21