@shipdit/cli 0.3.1 → 0.4.0

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.
Files changed (2) hide show
  1. package/dist/index.mjs +644 -516
  2. package/package.json +10 -11
package/dist/index.mjs CHANGED
@@ -77,64 +77,21 @@ function resolveRuntimeConfig(flags, options) {
77
77
  }
78
78
 
79
79
  //#endregion
80
- //#region ../../node_modules/.pnpm/hono@4.13.5/node_modules/hono/dist/utils/cookie.js
81
- var validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
82
- var _serialize = (name, value, opt = {}) => {
83
- if (!validCookieNameRegEx.test(name)) throw new Error("Invalid cookie name");
84
- let cookie = `${name}=${value}`;
85
- if (name.startsWith("__Secure-") && !opt.secure) throw new Error("__Secure- Cookie must have Secure attributes");
86
- if (name.startsWith("__Host-")) {
87
- if (!opt.secure) throw new Error("__Host- Cookie must have Secure attributes");
88
- if (opt.path !== "/") throw new Error("__Host- Cookie must have Path attributes with \"/\"");
89
- if (opt.domain) throw new Error("__Host- Cookie must not have Domain attributes");
90
- }
91
- for (const key of [
92
- "domain",
93
- "path",
94
- "sameSite",
95
- "priority"
96
- ]) if (opt[key] && /[;\r\n]/.test(opt[key])) throw new Error(`${key} must not contain ";", "\\r", or "\\n"`);
97
- if (opt && typeof opt.maxAge === "number" && opt.maxAge >= 0) {
98
- if (opt.maxAge > 3456e4) throw new Error("Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.");
99
- cookie += `; Max-Age=${opt.maxAge | 0}`;
100
- }
101
- if (opt.domain && opt.prefix !== "host") cookie += `; Domain=${opt.domain}`;
102
- if (opt.path) cookie += `; Path=${opt.path}`;
103
- if (opt.expires) {
104
- if (opt.expires.getTime() - Date.now() > 3456e7) throw new Error("Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.");
105
- cookie += `; Expires=${opt.expires.toUTCString()}`;
106
- }
107
- if (opt.httpOnly) cookie += "; HttpOnly";
108
- if (opt.secure) cookie += "; Secure";
109
- if (opt.sameSite) cookie += `; SameSite=${opt.sameSite.charAt(0).toUpperCase() + opt.sameSite.slice(1)}`;
110
- if (opt.priority) cookie += `; Priority=${opt.priority.charAt(0).toUpperCase() + opt.priority.slice(1)}`;
111
- if (opt.partitioned) {
112
- if (!opt.secure) throw new Error("Partitioned Cookie must have Secure attributes");
113
- cookie += "; Partitioned";
114
- }
115
- return cookie;
116
- };
117
- var serialize = (name, value, opt) => {
118
- value = encodeURIComponent(value);
119
- return _serialize(name, value, opt);
120
- };
121
-
122
- //#endregion
123
- //#region ../../node_modules/.pnpm/hono@4.13.5/node_modules/hono/dist/client/utils.js
124
- var mergePath = (base, path) => {
80
+ //#region ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/client/utils.js
81
+ const mergePath = (base, path) => {
125
82
  base = base.replace(/\/+$/, "");
126
83
  base = base + "/";
127
84
  path = path.replace(/^\/+/, "");
128
85
  return base + path;
129
86
  };
130
- var replaceUrlParam = (urlString, params) => {
87
+ const replaceUrlParam = (urlString, params) => {
131
88
  for (const [k, v] of Object.entries(params)) {
132
89
  const reg = new RegExp("/:" + k + "(?:{[^/]+})?\\??(?=/|$)");
133
90
  urlString = urlString.replace(reg, () => v ? `/${v}` : "");
134
91
  }
135
92
  return urlString;
136
93
  };
137
- var buildSearchParams = (query) => {
94
+ const buildSearchParams = (query) => {
138
95
  const searchParams = new URLSearchParams();
139
96
  for (const [k, v] of Object.entries(query)) {
140
97
  if (v === void 0) continue;
@@ -146,13 +103,13 @@ var buildSearchParams = (query) => {
146
103
  }
147
104
  return searchParams;
148
105
  };
149
- var replaceUrlProtocol = (urlString, protocol) => {
106
+ const replaceUrlProtocol = (urlString, protocol) => {
150
107
  switch (protocol) {
151
108
  case "ws": return urlString.replace(/^http/, "ws");
152
109
  case "http": return urlString.replace(/^ws/, "http");
153
110
  }
154
111
  };
155
- var removeIndexString = (urlString) => {
112
+ const removeIndexString = (urlString) => {
156
113
  if (/^https?:\/\/[^\/]+?\/index(?=\?|$)/.test(urlString)) return urlString.replace(/\/index(?=\?|$)/, "/");
157
114
  return urlString.replace(/\/index(?=\?|$)/, "");
158
115
  };
@@ -171,8 +128,51 @@ function deepMerge(target, source) {
171
128
  }
172
129
 
173
130
  //#endregion
174
- //#region ../../node_modules/.pnpm/hono@4.13.5/node_modules/hono/dist/client/client.js
175
- var createProxy = (callback, path) => {
131
+ //#region ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/utils/cookie.js
132
+ const validCookieNameRegEx = /^[\w!#$%&'*.^`|~+-]+$/;
133
+ const _serialize = (name, value, opt = {}) => {
134
+ if (!validCookieNameRegEx.test(name)) throw new Error("Invalid cookie name");
135
+ let cookie = `${name}=${value}`;
136
+ if (name.startsWith("__Secure-") && !opt.secure) throw new Error("__Secure- Cookie must have Secure attributes");
137
+ if (name.startsWith("__Host-")) {
138
+ if (!opt.secure) throw new Error("__Host- Cookie must have Secure attributes");
139
+ if (opt.path !== "/") throw new Error("__Host- Cookie must have Path attributes with \"/\"");
140
+ if (opt.domain) throw new Error("__Host- Cookie must not have Domain attributes");
141
+ }
142
+ for (const key of [
143
+ "domain",
144
+ "path",
145
+ "sameSite",
146
+ "priority"
147
+ ]) if (opt[key] && /[;\r\n]/.test(opt[key])) throw new Error(`${key} must not contain ";", "\\r", or "\\n"`);
148
+ if (opt && typeof opt.maxAge === "number" && opt.maxAge >= 0) {
149
+ if (opt.maxAge > 3456e4) throw new Error("Cookies Max-Age SHOULD NOT be greater than 400 days (34560000 seconds) in duration.");
150
+ cookie += `; Max-Age=${opt.maxAge | 0}`;
151
+ }
152
+ if (opt.domain && opt.prefix !== "host") cookie += `; Domain=${opt.domain}`;
153
+ if (opt.path) cookie += `; Path=${opt.path}`;
154
+ if (opt.expires) {
155
+ if (opt.expires.getTime() - Date.now() > 3456e7) throw new Error("Cookies Expires SHOULD NOT be greater than 400 days (34560000 seconds) in the future.");
156
+ cookie += `; Expires=${opt.expires.toUTCString()}`;
157
+ }
158
+ if (opt.httpOnly) cookie += "; HttpOnly";
159
+ if (opt.secure) cookie += "; Secure";
160
+ if (opt.sameSite) cookie += `; SameSite=${opt.sameSite.charAt(0).toUpperCase() + opt.sameSite.slice(1)}`;
161
+ if (opt.priority) cookie += `; Priority=${opt.priority.charAt(0).toUpperCase() + opt.priority.slice(1)}`;
162
+ if (opt.partitioned) {
163
+ if (!opt.secure) throw new Error("Partitioned Cookie must have Secure attributes");
164
+ cookie += "; Partitioned";
165
+ }
166
+ return cookie;
167
+ };
168
+ const serialize = (name, value, opt) => {
169
+ value = encodeURIComponent(value);
170
+ return _serialize(name, value, opt);
171
+ };
172
+
173
+ //#endregion
174
+ //#region ../../node_modules/.pnpm/hono@4.13.13/node_modules/hono/dist/client/client.js
175
+ const createProxy = (callback, path) => {
176
176
  return new Proxy(() => {}, {
177
177
  get(_obj, key) {
178
178
  if (typeof key !== "string" || key === "then") return;
@@ -186,7 +186,7 @@ var createProxy = (callback, path) => {
186
186
  }
187
187
  });
188
188
  };
189
- var appendQueryParams = (url, searchParams) => {
189
+ const appendQueryParams = (url, searchParams) => {
190
190
  const queryString = searchParams.toString();
191
191
  return queryString ? `${url}?${queryString}` : url;
192
192
  };
@@ -254,7 +254,7 @@ var ClientRequestImpl = class {
254
254
  });
255
255
  };
256
256
  };
257
- var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
257
+ const hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
258
258
  const buildSearchParamsOption = options?.buildSearchParams ?? buildSearchParams;
259
259
  const parts = [...opts.path];
260
260
  const lastParts = parts.slice(-3).reverse();
@@ -274,17 +274,17 @@ var hc = (baseUrl, options) => createProxy(function proxyCallback(opts) {
274
274
  const path = parts.join("/");
275
275
  const url = mergePath(baseUrl, path);
276
276
  if (method === "url" || method === "path") {
277
- let result = url;
277
+ let result = removeIndexString(url);
278
278
  if (opts.args[0]) {
279
- if (opts.args[0].param) result = replaceUrlParam(url, opts.args[0].param);
279
+ if (opts.args[0].param) result = replaceUrlParam(result, opts.args[0].param);
280
280
  if (opts.args[0].query) result = appendQueryParams(result, buildSearchParamsOption(opts.args[0].query));
281
281
  }
282
- result = removeIndexString(result);
283
282
  if (method === "url") return new URL(result);
284
283
  return result.slice(baseUrl.replace(/\/+$/, "").length).replace(/^\/?/, "/");
285
284
  }
286
285
  if (method === "ws") {
287
- const webSocketUrl = replaceUrlProtocol(opts.args[0]?.param ? replaceUrlParam(url, opts.args[0].param) : url, "ws");
286
+ const normalizedUrl = removeIndexString(url);
287
+ const webSocketUrl = replaceUrlProtocol(opts.args[0]?.param ? replaceUrlParam(normalizedUrl, opts.args[0].param) : normalizedUrl, "ws");
288
288
  const targetUrl = new URL(webSocketUrl);
289
289
  const queryParams = opts.args[0]?.query;
290
290
  if (queryParams) buildSearchParamsOption(queryParams).forEach((value, key) => {
@@ -361,8 +361,11 @@ var r$1 = class e extends Error {
361
361
  retryAfterSeconds: s
362
362
  });
363
363
  }
364
+ get isServerFailure() {
365
+ return this.status >= 500 || this.code === `internal` && this.status < 400;
366
+ }
364
367
  };
365
- async function i$1(e) {
368
+ async function a$1(e) {
366
369
  let t;
367
370
  try {
368
371
  t = await e.json();
@@ -384,7 +387,6 @@ async function i$1(e) {
384
387
  });
385
388
  return t.data;
386
389
  }
387
- const a$1 = (...t) => hc(...t);
388
390
  const o$1 = (...t) => hc(...t);
389
391
  const s$1 = (...t) => hc(...t);
390
392
  const c$1 = (...t) => hc(...t);
@@ -403,10 +405,12 @@ const b$1 = (...t) => hc(...t);
403
405
  const x$1 = (...t) => hc(...t);
404
406
  const S$1 = (...t) => hc(...t);
405
407
  const C$1 = (...t) => hc(...t);
406
- function w$1(e) {
408
+ const w$1 = (...t) => hc(...t);
409
+ const T$1 = (...t) => hc(...t);
410
+ function E$1(e) {
407
411
  return `${e.replace(/\/+$/, ``)}/api/v1/rpc`;
408
412
  }
409
- function T$1(e) {
413
+ function D$1(e) {
410
414
  return {
411
415
  ...e.fetch ? { fetch: e.fetch } : {},
412
416
  init: { credentials: e.client === `dashboard` ? `include` : `same-origin` },
@@ -416,177 +420,193 @@ function T$1(e) {
416
420
  }
417
421
  };
418
422
  }
419
- async function E$1(e, t) {
420
- return i$1(await e({ json: t }));
423
+ async function O$1(e, t) {
424
+ return a$1(await e({ json: t }));
421
425
  }
422
- async function D$1(e, t) {
426
+ async function k$1(e, t) {
423
427
  let n = await e({ json: t });
424
428
  return {
425
- items: await i$1(n),
429
+ items: await a$1(n),
426
430
  nextCursor: n.headers.get(`next-cursor`)
427
431
  };
428
432
  }
429
- function O$1(e) {
430
- let t = w$1(e.baseUrl), n = T$1(e), r = a$1(t, n), i = o$1(t, n), O = s$1(t, n), k = c$1(t, n), A = l$1(t, n), j = u$1(t, n), M = d$2(t, n), N = f$2(t, n), P = g$1(t, n), F = h$1(t, n), I = p$1(t, n), L = m$1(t, n), R = _$1(t, n), z = v$1(t, n), B = y$1(t, n), V = C$1(t, n), H = b$1(t, n), U = x$1(t, n), W = S$1(t, n);
433
+ function A$1(e) {
434
+ let t = E$1(e.baseUrl), n = D$1(e), r = o$1(t, n), i = s$1(t, n), a = c$1(t, n), A = l$1(t, n), j = u$1(t, n), M = d$2(t, n), N = f$2(t, n), P = p$1(t, n), F = _$1(t, n), I = g$1(t, n), L = m$1(t, n), R = h$1(t, n), z = v$1(t, n), B = y$1(t, n), V = b$1(t, n), H = x$1(t, n), U = T$1(t, n), W = S$1(t, n), G = C$1(t, n), K = w$1(t, n);
431
435
  return {
432
436
  me: {
433
- get: (e = {}) => E$1(r.me.$post, e),
434
- feedback: (e) => E$1(r.me.feedback.$post, e)
437
+ get: (e = {}) => O$1(r.me.$post, e),
438
+ feedback: (e) => O$1(r.me.feedback.$post, e)
435
439
  },
436
440
  project: {
437
- list: (e = {}) => E$1(i.project.list.$post, e),
438
- create: (e) => E$1(i.project.create.$post, e),
439
- update: (e) => E$1(i.project.update.$post, e),
440
- archive: (e) => E$1(i.project.archive.$post, e),
441
- listTeams: (e) => E$1(i.project.listTeams.$post, e),
442
- setTeams: (e) => E$1(i.project.setTeams.$post, e)
441
+ list: (e = {}) => O$1(i.project.list.$post, e),
442
+ create: (e) => O$1(i.project.create.$post, e),
443
+ update: (e) => O$1(i.project.update.$post, e),
444
+ archive: (e) => O$1(i.project.archive.$post, e),
445
+ listArchived: (e = {}) => O$1(i.project.listArchived.$post, e),
446
+ restore: (e) => O$1(i.project.restore.$post, e),
447
+ listTeams: (e) => O$1(i.project.listTeams.$post, e),
448
+ setTeams: (e) => O$1(i.project.setTeams.$post, e)
443
449
  },
444
- team: { listMembers: (e) => E$1(H.team.listMembers.$post, e) },
450
+ team: { listMembers: (e) => O$1(W.team.listMembers.$post, e) },
445
451
  environment: {
446
- list: (e) => E$1(O.environment.list.$post, e),
447
- create: (e) => E$1(O.environment.create.$post, e),
448
- update: (e) => E$1(O.environment.update.$post, e),
449
- archive: (e) => E$1(O.environment.archive.$post, e)
452
+ list: (e) => O$1(a.environment.list.$post, e),
453
+ create: (e) => O$1(a.environment.create.$post, e),
454
+ update: (e) => O$1(a.environment.update.$post, e),
455
+ archive: (e) => O$1(a.environment.archive.$post, e),
456
+ listArchived: (e) => O$1(a.environment.listArchived.$post, e),
457
+ restore: (e) => O$1(a.environment.restore.$post, e)
450
458
  },
451
459
  flag: {
452
- list: (e) => E$1(k.flag.list.$post, e),
453
- get: (e) => E$1(k.flag.get.$post, e),
454
- create: (e) => E$1(k.flag.create.$post, e),
455
- update: (e) => E$1(k.flag.update.$post, e),
456
- archive: (e) => E$1(k.flag.archive.$post, e),
457
- updateEnvironment: (e) => E$1(k.flag.updateEnvironment.$post, e),
458
- toggleEnvironment: (e) => E$1(k.flag.toggleEnvironment.$post, e),
459
- listEnvironmentStates: (e) => E$1(k.flag.listEnvironmentStates.$post, e),
460
- pull: (e) => E$1(k.flag.pull.$post, e),
461
- diff: (e) => E$1(k.flag.diff.$post, e),
462
- push: (e) => E$1(k.flag.push.$post, e)
460
+ list: (e) => O$1(A.flag.list.$post, e),
461
+ get: (e) => O$1(A.flag.get.$post, e),
462
+ create: (e) => O$1(A.flag.create.$post, e),
463
+ update: (e) => O$1(A.flag.update.$post, e),
464
+ archive: (e) => O$1(A.flag.archive.$post, e),
465
+ listArchived: (e) => O$1(A.flag.listArchived.$post, e),
466
+ restore: (e) => O$1(A.flag.restore.$post, e),
467
+ updateEnvironment: (e) => O$1(A.flag.updateEnvironment.$post, e),
468
+ toggleEnvironment: (e) => O$1(A.flag.toggleEnvironment.$post, e),
469
+ listEnvironmentStates: (e) => O$1(A.flag.listEnvironmentStates.$post, e),
470
+ pull: (e) => O$1(A.flag.pull.$post, e),
471
+ diff: (e) => O$1(A.flag.diff.$post, e),
472
+ push: (e) => O$1(A.flag.push.$post, e)
463
473
  },
464
474
  apiKey: {
465
- list: (e = {}) => E$1(A.apiKey.list.$post, e),
466
- create: (e) => E$1(A.apiKey.create.$post, e),
467
- revoke: (e) => E$1(A.apiKey.revoke.$post, e)
475
+ list: (e = {}) => O$1(j.apiKey.list.$post, e),
476
+ create: (e) => O$1(j.apiKey.create.$post, e),
477
+ revoke: (e) => O$1(j.apiKey.revoke.$post, e)
468
478
  },
469
479
  sdkKey: {
470
- list: (e = {}) => E$1(N.sdkKey.list.$post, e),
471
- create: (e) => E$1(N.sdkKey.create.$post, e),
472
- revoke: (e) => E$1(N.sdkKey.revoke.$post, e)
480
+ list: (e = {}) => O$1(P.sdkKey.list.$post, e),
481
+ create: (e) => O$1(P.sdkKey.create.$post, e),
482
+ revoke: (e) => O$1(P.sdkKey.revoke.$post, e)
473
483
  },
474
484
  serviceAccount: {
475
- list: (e = {}) => E$1(P.serviceAccount.list.$post, e),
476
- get: (e) => E$1(P.serviceAccount.get.$post, e),
477
- create: (e) => E$1(P.serviceAccount.create.$post, e),
478
- update: (e) => E$1(P.serviceAccount.update.$post, e),
479
- disable: (e) => E$1(P.serviceAccount.disable.$post, e),
480
- enable: (e) => E$1(P.serviceAccount.enable.$post, e),
481
- delete: (e) => E$1(P.serviceAccount.delete.$post, e),
482
- createToken: (e) => E$1(P.serviceAccount.createToken.$post, e),
483
- listTokens: (e) => E$1(P.serviceAccount.listTokens.$post, e),
484
- revokeToken: (e) => E$1(P.serviceAccount.revokeToken.$post, e),
485
- rotateToken: (e) => E$1(P.serviceAccount.rotateToken.$post, e)
485
+ list: (e = {}) => O$1(F.serviceAccount.list.$post, e),
486
+ get: (e) => O$1(F.serviceAccount.get.$post, e),
487
+ create: (e) => O$1(F.serviceAccount.create.$post, e),
488
+ update: (e) => O$1(F.serviceAccount.update.$post, e),
489
+ disable: (e) => O$1(F.serviceAccount.disable.$post, e),
490
+ enable: (e) => O$1(F.serviceAccount.enable.$post, e),
491
+ delete: (e) => O$1(F.serviceAccount.delete.$post, e),
492
+ createToken: (e) => O$1(F.serviceAccount.createToken.$post, e),
493
+ listTokens: (e) => O$1(F.serviceAccount.listTokens.$post, e),
494
+ revokeToken: (e) => O$1(F.serviceAccount.revokeToken.$post, e),
495
+ rotateToken: (e) => O$1(F.serviceAccount.rotateToken.$post, e)
486
496
  },
487
497
  segment: {
488
- list: (e) => E$1(F.segment.list.$post, e),
489
- get: (e) => E$1(F.segment.get.$post, e),
490
- create: (e) => E$1(F.segment.create.$post, e),
491
- update: (e) => E$1(F.segment.update.$post, e),
492
- archive: (e) => E$1(F.segment.archive.$post, e),
493
- listEnvironmentStates: (e) => E$1(F.segment.listEnvironmentStates.$post, e),
494
- updateEnvironment: (e) => E$1(F.segment.updateEnvironment.$post, e)
498
+ list: (e) => O$1(I.segment.list.$post, e),
499
+ get: (e) => O$1(I.segment.get.$post, e),
500
+ create: (e) => O$1(I.segment.create.$post, e),
501
+ update: (e) => O$1(I.segment.update.$post, e),
502
+ archive: (e) => O$1(I.segment.archive.$post, e),
503
+ listArchived: (e) => O$1(I.segment.listArchived.$post, e),
504
+ restore: (e) => O$1(I.segment.restore.$post, e),
505
+ listEnvironmentStates: (e) => O$1(I.segment.listEnvironmentStates.$post, e),
506
+ updateEnvironment: (e) => O$1(I.segment.updateEnvironment.$post, e)
495
507
  },
496
508
  evaluatedEntity: {
497
- list: (e) => E$1(I.evaluatedEntity.list.$post, e),
498
- listPage: (e) => D$1(I.evaluatedEntity.list.$post, e),
499
- get: (e) => E$1(I.evaluatedEntity.get.$post, e),
500
- delete: (e) => E$1(I.evaluatedEntity.delete.$post, e)
509
+ list: (e) => O$1(L.evaluatedEntity.list.$post, e),
510
+ listPage: (e) => k$1(L.evaluatedEntity.list.$post, e),
511
+ get: (e) => O$1(L.evaluatedEntity.get.$post, e),
512
+ delete: (e) => O$1(L.evaluatedEntity.delete.$post, e)
501
513
  },
502
514
  evaluationFact: {
503
- list: (e) => E$1(L.evaluationFact.list.$post, e),
504
- byRule: (e) => E$1(L.evaluationFact.byRule.$post, e),
505
- orgSummary: (e = {}) => E$1(L.evaluationFact.orgSummary.$post, e),
506
- projectSummary: (e) => E$1(L.evaluationFact.projectSummary.$post, e),
507
- simulate: (e) => E$1(L.evaluationFact.simulate.$post, e)
515
+ list: (e) => O$1(R.evaluationFact.list.$post, e),
516
+ byRule: (e) => O$1(R.evaluationFact.byRule.$post, e),
517
+ orgSummary: (e = {}) => O$1(R.evaluationFact.orgSummary.$post, e),
518
+ projectSummary: (e) => O$1(R.evaluationFact.projectSummary.$post, e),
519
+ simulate: (e) => O$1(R.evaluationFact.simulate.$post, e)
508
520
  },
509
521
  snapshot: {
510
- publish: (e) => E$1(R.snapshot.publish.$post, e),
511
- listOutbox: (e = {}) => E$1(R.snapshot.outbox.list.$post, e),
512
- listOutboxPage: (e = {}) => D$1(R.snapshot.outbox.list.$post, e),
513
- requeue: (e) => E$1(R.snapshot.outbox.requeue.$post, e),
514
- rebuild: (e) => E$1(R.snapshot.rebuild.$post, e),
515
- listPublications: (e) => E$1(R.snapshot.publications.list.$post, e),
516
- listPublicationsPage: (e) => D$1(R.snapshot.publications.list.$post, e)
522
+ publish: (e) => O$1(z.snapshot.publish.$post, e),
523
+ listOutbox: (e = {}) => O$1(z.snapshot.outbox.list.$post, e),
524
+ listOutboxPage: (e = {}) => k$1(z.snapshot.outbox.list.$post, e),
525
+ requeue: (e) => O$1(z.snapshot.outbox.requeue.$post, e),
526
+ rebuild: (e) => O$1(z.snapshot.rebuild.$post, e),
527
+ listPublications: (e) => O$1(z.snapshot.publications.list.$post, e),
528
+ listPublicationsPage: (e) => k$1(z.snapshot.publications.list.$post, e)
517
529
  },
518
- device: { authorize: (e) => E$1(z.device.authorize.$post, e) },
530
+ snapshotWebhook: {
531
+ list: (e) => O$1(B.snapshotWebhook.list.$post, e),
532
+ create: (e) => O$1(B.snapshotWebhook.create.$post, e),
533
+ update: (e) => O$1(B.snapshotWebhook.update.$post, e),
534
+ delete: (e) => O$1(B.snapshotWebhook.delete.$post, e),
535
+ test: (e) => O$1(B.snapshotWebhook.test.$post, e)
536
+ },
537
+ device: { authorize: (e) => O$1(V.device.authorize.$post, e) },
519
538
  billing: {
520
- get: (e = {}) => E$1(B.billing.get.$post, e),
521
- attach: (e) => E$1(B.billing.attach.$post, e),
522
- openPortal: (e) => E$1(B.billing.openPortal.$post, e)
539
+ get: (e = {}) => O$1(H.billing.get.$post, e),
540
+ attach: (e) => O$1(H.billing.attach.$post, e),
541
+ openPortal: (e) => O$1(H.billing.openPortal.$post, e)
523
542
  },
524
- usage: { get: (e = {}) => E$1(V.usage.get.$post, e) },
543
+ usage: { get: (e = {}) => O$1(U.usage.get.$post, e) },
525
544
  approval: {
526
- listPolicies: (e = {}) => E$1(j.approval.listPolicies.$post, e),
527
- createPolicy: (e) => E$1(j.approval.createPolicy.$post, e),
528
- updatePolicy: (e) => E$1(j.approval.updatePolicy.$post, e),
529
- deletePolicy: (e) => E$1(j.approval.deletePolicy.$post, e),
530
- listRequests: (e = {}) => E$1(j.approval.listRequests.$post, e),
531
- listRequestsPage: (e = {}) => D$1(j.approval.listRequests.$post, e),
532
- get: (e) => E$1(j.approval.get.$post, e),
533
- approve: (e) => E$1(j.approval.approve.$post, e),
534
- reject: (e) => E$1(j.approval.reject.$post, e),
535
- cancel: (e) => E$1(j.approval.cancel.$post, e)
545
+ listPolicies: (e = {}) => O$1(M.approval.listPolicies.$post, e),
546
+ createPolicy: (e) => O$1(M.approval.createPolicy.$post, e),
547
+ updatePolicy: (e) => O$1(M.approval.updatePolicy.$post, e),
548
+ deletePolicy: (e) => O$1(M.approval.deletePolicy.$post, e),
549
+ listRequests: (e = {}) => O$1(M.approval.listRequests.$post, e),
550
+ listRequestsPage: (e = {}) => k$1(M.approval.listRequests.$post, e),
551
+ get: (e) => O$1(M.approval.get.$post, e),
552
+ approve: (e) => O$1(M.approval.approve.$post, e),
553
+ reject: (e) => O$1(M.approval.reject.$post, e),
554
+ cancel: (e) => O$1(M.approval.cancel.$post, e)
536
555
  },
537
556
  audit: {
538
- list: (e = {}) => E$1(M.audit.list.$post, e),
539
- get: (e) => E$1(M.audit.get.$post, e),
540
- actions: (e = {}) => E$1(M.audit.actions.$post, e),
541
- export: (e) => E$1(M.audit.export.$post, e),
542
- getSettings: (e = {}) => E$1(M.audit.getSettings.$post, e),
543
- updateSettings: (e) => E$1(M.audit.updateSettings.$post, e),
544
- listDestinations: (e = {}) => E$1(M.audit.listDestinations.$post, e),
545
- createDestination: (e) => E$1(M.audit.createDestination.$post, e),
546
- updateDestination: (e) => E$1(M.audit.updateDestination.$post, e),
547
- deleteDestination: (e) => E$1(M.audit.deleteDestination.$post, e),
548
- testDestination: (e) => E$1(M.audit.testDestination.$post, e)
557
+ list: (e = {}) => O$1(N.audit.list.$post, e),
558
+ get: (e) => O$1(N.audit.get.$post, e),
559
+ actions: (e = {}) => O$1(N.audit.actions.$post, e),
560
+ export: (e) => O$1(N.audit.export.$post, e),
561
+ getSettings: (e = {}) => O$1(N.audit.getSettings.$post, e),
562
+ updateSettings: (e) => O$1(N.audit.updateSettings.$post, e),
563
+ listDestinations: (e = {}) => O$1(N.audit.listDestinations.$post, e),
564
+ createDestination: (e) => O$1(N.audit.createDestination.$post, e),
565
+ updateDestination: (e) => O$1(N.audit.updateDestination.$post, e),
566
+ deleteDestination: (e) => O$1(N.audit.deleteDestination.$post, e),
567
+ testDestination: (e) => O$1(N.audit.testDestination.$post, e)
549
568
  },
550
569
  sso: {
551
- getSettings: (e = {}) => E$1(U.sso.getSettings.$post, e),
552
- listProviders: (e = {}) => E$1(U.sso.listProviders.$post, e),
553
- updateAllowedDomains: (e) => E$1(U.sso.updateAllowedDomains.$post, e),
554
- setEnforcement: (e) => E$1(U.sso.setEnforcement.$post, e),
555
- setRequireTwoFactor: (e) => E$1(U.sso.setRequireTwoFactor.$post, e)
570
+ getSettings: (e = {}) => O$1(G.sso.getSettings.$post, e),
571
+ listProviders: (e = {}) => O$1(G.sso.listProviders.$post, e),
572
+ updateAllowedDomains: (e) => O$1(G.sso.updateAllowedDomains.$post, e),
573
+ setEnforcement: (e) => O$1(G.sso.setEnforcement.$post, e),
574
+ setRequireTwoFactor: (e) => O$1(G.sso.setRequireTwoFactor.$post, e)
556
575
  },
557
576
  scim: {
558
- getConnection: (e = {}) => E$1(W.scim.getConnection.$post, e),
559
- createConnection: (e = { creationRequestId: crypto.randomUUID() }) => E$1(W.scim.createConnection.$post, e),
560
- rotateCredential: (e) => E$1(W.scim.rotateCredential.$post, e),
561
- revokeCredential: (e) => E$1(W.scim.revokeCredential.$post, e),
562
- decommissionConnection: (e) => E$1(W.scim.decommissionConnection.$post, e)
577
+ getConnection: (e = {}) => O$1(K.scim.getConnection.$post, e),
578
+ createConnection: (e = { creationRequestId: crypto.randomUUID() }) => O$1(K.scim.createConnection.$post, e),
579
+ rotateCredential: (e) => O$1(K.scim.rotateCredential.$post, e),
580
+ revokeCredential: (e) => O$1(K.scim.revokeCredential.$post, e),
581
+ decommissionConnection: (e) => O$1(K.scim.decommissionConnection.$post, e)
563
582
  },
564
583
  raw: {
565
584
  me: r,
566
585
  project: i,
567
- environment: O,
568
- flag: k,
569
- apiKey: A,
570
- approval: j,
571
- audit: M,
572
- sdkKey: N,
573
- serviceAccount: P,
574
- segment: F,
575
- evaluatedEntity: I,
576
- evaluationFact: L,
577
- snapshot: R,
578
- device: z,
579
- billing: B,
580
- usage: V,
581
- team: H,
582
- sso: U,
583
- scim: W
586
+ environment: a,
587
+ flag: A,
588
+ apiKey: j,
589
+ approval: M,
590
+ audit: N,
591
+ sdkKey: P,
592
+ serviceAccount: F,
593
+ segment: I,
594
+ evaluatedEntity: L,
595
+ evaluationFact: R,
596
+ snapshot: z,
597
+ snapshotWebhook: B,
598
+ device: V,
599
+ billing: H,
600
+ usage: U,
601
+ team: W,
602
+ sso: G,
603
+ scim: K
584
604
  }
585
605
  };
586
606
  }
587
607
 
588
608
  //#endregion
589
- //#region ../../node_modules/.pnpm/@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@opentelemet_2e71ba5b354a0fbab5c1bdc9f6326b28/node_modules/@better-auth/core/dist/utils/error-codes.mjs
609
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.7.7_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.2_@opentelemet_e02eb0bf6cc57b8ec4097db90c5ddf37/node_modules/@better-auth/core/dist/utils/error-codes.mjs
590
610
  function defineErrorCodes(codes) {
591
611
  return Object.fromEntries(Object.entries(codes).map(([key, value]) => [key, {
592
612
  code: key,
@@ -596,7 +616,7 @@ function defineErrorCodes(codes) {
596
616
  }
597
617
 
598
618
  //#endregion
599
- //#region ../../node_modules/.pnpm/better-call@1.4.0_zod@4.4.3/node_modules/better-call/dist/error.mjs
619
+ //#region ../../node_modules/.pnpm/better-call@1.4.0_zod@4.6.5/node_modules/better-call/dist/error.mjs
600
620
  function isErrorStackTraceLimitWritable() {
601
621
  const desc = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
602
622
  if (desc === void 0) return Object.isExtensible(Error);
@@ -713,7 +733,7 @@ var InternalAPIError = class extends Error {
713
733
  const APIError = makeErrorForHideStackFrame(InternalAPIError, Error);
714
734
 
715
735
  //#endregion
716
- //#region ../../node_modules/.pnpm/@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@opentelemet_2e71ba5b354a0fbab5c1bdc9f6326b28/node_modules/@better-auth/core/dist/error/index.mjs
736
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.7.7_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.2_@opentelemet_e02eb0bf6cc57b8ec4097db90c5ddf37/node_modules/@better-auth/core/dist/error/index.mjs
717
737
  var BetterAuthError = class extends Error {
718
738
  constructor(message, options) {
719
739
  super(message, options);
@@ -724,7 +744,7 @@ var BetterAuthError = class extends Error {
724
744
  };
725
745
 
726
746
  //#endregion
727
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/access/access.mjs
747
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/access/access.mjs
728
748
  function unknownResourceResponse(requestedResource) {
729
749
  return {
730
750
  success: false,
@@ -801,12 +821,13 @@ function createAccessControl(s) {
801
821
  }
802
822
 
803
823
  //#endregion
804
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/two-factor/error-code.mjs
824
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/two-factor/error-code.mjs
805
825
  const TWO_FACTOR_ERROR_CODES = defineErrorCodes({
806
826
  OTP_NOT_ENABLED: "OTP not enabled",
807
827
  OTP_NOT_CONFIGURED: "OTP is not available",
808
828
  OTP_HAS_EXPIRED: "OTP has expired",
809
829
  TOTP_NOT_ENABLED: "TOTP not enabled",
830
+ TOTP_ALREADY_ENABLED: "TOTP is already enabled",
810
831
  TOTP_NOT_CONFIGURED: "TOTP is not available",
811
832
  TWO_FACTOR_NOT_ENABLED: "Two factor isn't enabled",
812
833
  BACKUP_CODES_NOT_ENABLED: "Backup codes aren't enabled",
@@ -818,15 +839,15 @@ const TWO_FACTOR_ERROR_CODES = defineErrorCodes({
818
839
  });
819
840
 
820
841
  //#endregion
821
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/package.mjs
822
- var version = "1.7.1";
842
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/package.mjs
843
+ var version = "1.7.7";
823
844
 
824
845
  //#endregion
825
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/version.mjs
846
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/version.mjs
826
847
  const PACKAGE_VERSION$3 = version;
827
848
 
828
849
  //#endregion
829
- //#region ../../node_modules/.pnpm/@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@opentelemet_2e71ba5b354a0fbab5c1bdc9f6326b28/node_modules/@better-auth/core/dist/utils/url.mjs
850
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.7.7_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.2_@opentelemet_e02eb0bf6cc57b8ec4097db90c5ddf37/node_modules/@better-auth/core/dist/utils/url.mjs
830
851
  /**
831
852
  * Schemes that execute or embed code when navigated to or accepted as a
832
853
  * redirect target. These are never safe as an OAuth `redirect_uri` or as a
@@ -858,7 +879,7 @@ function isSafeUrlScheme(value) {
858
879
  }
859
880
 
860
881
  //#endregion
861
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/two-factor/client.mjs
882
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/two-factor/client.mjs
862
883
  const twoFactorClient = (options) => {
863
884
  return {
864
885
  id: "two-factor",
@@ -896,7 +917,7 @@ const twoFactorClient = (options) => {
896
917
  };
897
918
 
898
919
  //#endregion
899
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/admin/access/statement.mjs
920
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/admin/access/statement.mjs
900
921
  const defaultStatements$1 = {
901
922
  user: [
902
923
  "create",
@@ -947,7 +968,7 @@ const defaultRoles$1 = {
947
968
  };
948
969
 
949
970
  //#endregion
950
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/admin/error-codes.mjs
971
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/admin/error-codes.mjs
951
972
  const ADMIN_ERROR_CODES = defineErrorCodes({
952
973
  FAILED_TO_CREATE_USER: "Failed to create user",
953
974
  USER_ALREADY_EXISTS: "User already exists.",
@@ -975,7 +996,7 @@ const ADMIN_ERROR_CODES = defineErrorCodes({
975
996
  });
976
997
 
977
998
  //#endregion
978
- //#region ../../node_modules/.pnpm/@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@opentelemet_2e71ba5b354a0fbab5c1bdc9f6326b28/node_modules/@better-auth/core/dist/env/env-impl.mjs
999
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.7.7_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.2_@opentelemet_e02eb0bf6cc57b8ec4097db90c5ddf37/node_modules/@better-auth/core/dist/env/env-impl.mjs
979
1000
  const _envShim = Object.create(null);
980
1001
  const _getEnv = (useShim) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (useShim ? _envShim : globalThis);
981
1002
  const env = new Proxy(_envShim, {
@@ -1039,7 +1060,7 @@ const ENV = Object.freeze({
1039
1060
  });
1040
1061
 
1041
1062
  //#endregion
1042
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/utils/url.mjs
1063
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/utils/url.mjs
1043
1064
  const SLASH_CHAR_CODE = "/".charCodeAt(0);
1044
1065
  function trimTrailingSlashes(value) {
1045
1066
  let end = value.length;
@@ -1118,7 +1139,7 @@ function getOrigin(url) {
1118
1139
  }
1119
1140
 
1120
1141
  //#endregion
1121
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/admin/has-permission.mjs
1142
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/admin/has-permission.mjs
1122
1143
  const hasPermission = (input) => {
1123
1144
  if (input.userId && input.options?.adminUserIds?.includes(input.userId)) return true;
1124
1145
  if (!input.permissions) return false;
@@ -1170,27 +1191,7 @@ const defuArrayFn = createDefu((object, key, currentValue) => {
1170
1191
  });
1171
1192
 
1172
1193
  //#endregion
1173
- //#region ../../node_modules/.pnpm/@better-fetch+fetch@1.3.1/node_modules/@better-fetch/fetch/dist/index.js
1174
- var __defProp = Object.defineProperty;
1175
- var __defProps = Object.defineProperties;
1176
- var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
1177
- var __getOwnPropSymbols = Object.getOwnPropertySymbols;
1178
- var __hasOwnProp = Object.prototype.hasOwnProperty;
1179
- var __propIsEnum = Object.prototype.propertyIsEnumerable;
1180
- var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
1181
- enumerable: true,
1182
- configurable: true,
1183
- writable: true,
1184
- value
1185
- }) : obj[key] = value;
1186
- var __spreadValues = (a, b) => {
1187
- for (var prop in b || (b = {})) if (__hasOwnProp.call(b, prop)) __defNormalProp(a, prop, b[prop]);
1188
- if (__getOwnPropSymbols) {
1189
- for (var prop of __getOwnPropSymbols(b)) if (__propIsEnum.call(b, prop)) __defNormalProp(a, prop, b[prop]);
1190
- }
1191
- return a;
1192
- };
1193
- var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
1194
+ //#region ../../node_modules/.pnpm/@better-fetch+fetch@1.3.2/node_modules/@better-fetch/fetch/dist/index.js
1194
1195
  var BetterFetchError = class extends Error {
1195
1196
  constructor(status, statusText, error) {
1196
1197
  super(statusText || status.toString(), { cause: error });
@@ -1200,32 +1201,33 @@ var BetterFetchError = class extends Error {
1200
1201
  Error.captureStackTrace(this, this.constructor);
1201
1202
  }
1202
1203
  };
1203
- var initializePlugins = async (url, options) => {
1204
- var _a, _b, _c, _d, _e, _f;
1204
+ const initializePlugins = async (url, options) => {
1205
1205
  let opts = options || {};
1206
1206
  const hooks = {
1207
- onRequest: [options == null ? void 0 : options.onRequest],
1208
- onResponse: [options == null ? void 0 : options.onResponse],
1209
- onSuccess: [options == null ? void 0 : options.onSuccess],
1210
- onError: [options == null ? void 0 : options.onError],
1211
- onRetry: [options == null ? void 0 : options.onRetry]
1207
+ onRequest: [options === null || options === void 0 ? void 0 : options.onRequest],
1208
+ onResponse: [options === null || options === void 0 ? void 0 : options.onResponse],
1209
+ onSuccess: [options === null || options === void 0 ? void 0 : options.onSuccess],
1210
+ onError: [options === null || options === void 0 ? void 0 : options.onError],
1211
+ onRetry: [options === null || options === void 0 ? void 0 : options.onRetry]
1212
1212
  };
1213
- if (!options || !(options == null ? void 0 : options.plugins)) return {
1213
+ if (!options || !(options === null || options === void 0 ? void 0 : options.plugins)) return {
1214
1214
  url,
1215
1215
  options: opts,
1216
1216
  hooks
1217
1217
  };
1218
- for (const plugin of (options == null ? void 0 : options.plugins) || []) {
1218
+ for (const plugin of (options === null || options === void 0 ? void 0 : options.plugins) || []) {
1219
+ var _plugin$hooks, _plugin$hooks2, _plugin$hooks3, _plugin$hooks4, _plugin$hooks5;
1219
1220
  if (plugin.init) {
1220
- const pluginRes = await ((_a = plugin.init) == null ? void 0 : _a.call(plugin, url.toString(), options));
1221
+ var _plugin$init;
1222
+ const pluginRes = await ((_plugin$init = plugin.init) === null || _plugin$init === void 0 ? void 0 : _plugin$init.call(plugin, url.toString(), opts));
1221
1223
  opts = pluginRes.options || opts;
1222
1224
  url = pluginRes.url;
1223
1225
  }
1224
- hooks.onRequest.push((_b = plugin.hooks) == null ? void 0 : _b.onRequest);
1225
- hooks.onResponse.push((_c = plugin.hooks) == null ? void 0 : _c.onResponse);
1226
- hooks.onSuccess.push((_d = plugin.hooks) == null ? void 0 : _d.onSuccess);
1227
- hooks.onError.push((_e = plugin.hooks) == null ? void 0 : _e.onError);
1228
- hooks.onRetry.push((_f = plugin.hooks) == null ? void 0 : _f.onRetry);
1226
+ hooks.onRequest.push((_plugin$hooks = plugin.hooks) === null || _plugin$hooks === void 0 ? void 0 : _plugin$hooks.onRequest);
1227
+ hooks.onResponse.push((_plugin$hooks2 = plugin.hooks) === null || _plugin$hooks2 === void 0 ? void 0 : _plugin$hooks2.onResponse);
1228
+ hooks.onSuccess.push((_plugin$hooks3 = plugin.hooks) === null || _plugin$hooks3 === void 0 ? void 0 : _plugin$hooks3.onSuccess);
1229
+ hooks.onError.push((_plugin$hooks4 = plugin.hooks) === null || _plugin$hooks4 === void 0 ? void 0 : _plugin$hooks4.onError);
1230
+ hooks.onRetry.push((_plugin$hooks5 = plugin.hooks) === null || _plugin$hooks5 === void 0 ? void 0 : _plugin$hooks5.onRetry);
1229
1231
  }
1230
1232
  return {
1231
1233
  url,
@@ -1269,10 +1271,81 @@ function createRetryStrategy(options) {
1269
1271
  default: throw new Error("Invalid retry strategy");
1270
1272
  }
1271
1273
  }
1272
- var getAuthHeader = async (options) => {
1274
+ const methods = [
1275
+ "get",
1276
+ "post",
1277
+ "put",
1278
+ "patch",
1279
+ "delete"
1280
+ ];
1281
+ function parseMethodModifier(path) {
1282
+ if (!path.startsWith("@")) return {
1283
+ method: void 0,
1284
+ path
1285
+ };
1286
+ const separator = path.indexOf("/");
1287
+ const method = path.slice(1, separator === -1 ? void 0 : separator);
1288
+ if (!methods.includes(method)) return {
1289
+ method: void 0,
1290
+ path
1291
+ };
1292
+ return {
1293
+ method,
1294
+ path: separator === -1 ? path : path.slice(separator + 1)
1295
+ };
1296
+ }
1297
+ const isReservedPathSegment = (value) => value === "." || value === "..";
1298
+ const encodeLiteralPathSegment = (segment) => segment.split(":").map((part) => encodeURIComponent(part)).join(":");
1299
+ function resolvePathSegment(segment, pathParams) {
1300
+ const pathParam = pathParams.get(segment);
1301
+ if (pathParam === void 0) return encodeLiteralPathSegment(segment);
1302
+ if (isReservedPathSegment(pathParam)) throw new TypeError("Path parameters cannot be reserved path segments");
1303
+ return encodeURIComponent(pathParam);
1304
+ }
1305
+ /**
1306
+ * Normalize URL
1307
+ */
1308
+ function getURL$1(url, option) {
1309
+ const { baseURL, params, query } = option || {
1310
+ query: {},
1311
+ params: {},
1312
+ baseURL: ""
1313
+ };
1314
+ let basePath = url.startsWith("http") ? url.split("/").slice(0, 3).join("/") : baseURL || "";
1315
+ const { path: requestPath } = parseMethodModifier(url);
1316
+ if (requestPath !== url) url = `/${requestPath}`;
1317
+ if (!basePath.endsWith("/")) basePath += "/";
1318
+ let [path, urlQuery] = url.replace(basePath, "").split("?");
1319
+ const queryParams = new URLSearchParams(urlQuery);
1320
+ for (const [key, value] of Object.entries(query || {})) {
1321
+ if (value == null) continue;
1322
+ let serializedValue;
1323
+ if (typeof value === "string") serializedValue = value;
1324
+ else if (Array.isArray(value)) {
1325
+ for (const val of value) queryParams.append(key, val);
1326
+ continue;
1327
+ } else serializedValue = JSON.stringify(value);
1328
+ queryParams.set(key, serializedValue);
1329
+ }
1330
+ const pathParams = /* @__PURE__ */ new Map();
1331
+ if (params) if (Array.isArray(params)) {
1332
+ const paramPaths = path.split("/").filter((p) => p.startsWith(":"));
1333
+ for (const [index, key] of paramPaths.entries()) {
1334
+ const value = params[index];
1335
+ pathParams.set(key, String(value));
1336
+ }
1337
+ } else for (const [key, value] of Object.entries(params)) pathParams.set(`:${key}`, String(value));
1338
+ path = path.split("/").map((segment) => resolvePathSegment(segment, pathParams)).join("/");
1339
+ path = path.replace(/^\/+/, "");
1340
+ let queryParamString = queryParams.toString();
1341
+ queryParamString = queryParamString.length > 0 ? `?${queryParamString}`.replace(/\+/g, "%20") : "";
1342
+ if (!basePath.startsWith("http")) return `${basePath}${path}${queryParamString}`;
1343
+ return new URL(`${path}${queryParamString}`, basePath);
1344
+ }
1345
+ const getAuthHeader = async (options) => {
1273
1346
  const headers = {};
1274
1347
  const getValue = async (value) => typeof value === "function" ? await value() : value;
1275
- if (options == null ? void 0 : options.auth) {
1348
+ if (options === null || options === void 0 ? void 0 : options.auth) {
1276
1349
  if (options.auth.type === "Bearer") {
1277
1350
  const token = await getValue(options.auth.token);
1278
1351
  if (!token) return headers;
@@ -1284,12 +1357,12 @@ var getAuthHeader = async (options) => {
1284
1357
  } else if (options.auth.type === "Custom") {
1285
1358
  const [prefix, value] = await Promise.all([getValue(options.auth.prefix), getValue(options.auth.value)]);
1286
1359
  if (!value) return headers;
1287
- headers["authorization"] = `${prefix != null ? prefix : ""} ${value}`;
1360
+ headers["authorization"] = `${prefix !== null && prefix !== void 0 ? prefix : ""} ${value}`;
1288
1361
  }
1289
1362
  }
1290
1363
  return headers;
1291
1364
  };
1292
- var JSON_RE = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
1365
+ const JSON_RE = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
1293
1366
  function detectResponseType(request) {
1294
1367
  const _contentType = request.headers.get("content-type");
1295
1368
  const textTypes = /* @__PURE__ */ new Set([
@@ -1332,7 +1405,7 @@ function isFunction(value) {
1332
1405
  return typeof value === "function";
1333
1406
  }
1334
1407
  function getFetch(options) {
1335
- if (options == null ? void 0 : options.customFetchImpl) return options.customFetchImpl;
1408
+ if (options === null || options === void 0 ? void 0 : options.customFetchImpl) return options.customFetchImpl;
1336
1409
  if (typeof globalThis !== "undefined" && isFunction(globalThis.fetch)) return globalThis.fetch;
1337
1410
  if (typeof window !== "undefined" && isFunction(window.fetch)) return window.fetch;
1338
1411
  throw new Error("No fetch implementation found");
@@ -1352,9 +1425,9 @@ function mergeHeaders(...sources) {
1352
1425
  return merged;
1353
1426
  }
1354
1427
  async function getHeaders(opts) {
1355
- const headers = new Headers(mergeHeaders(opts == null ? void 0 : opts.headers, await getAuthHeader(opts)));
1428
+ const headers = new Headers(mergeHeaders(opts === null || opts === void 0 ? void 0 : opts.headers, await getAuthHeader(opts)));
1356
1429
  if (!headers.has("content-type")) {
1357
- const contentType = detectContentType(opts == null ? void 0 : opts.body);
1430
+ const contentType = detectContentType(opts === null || opts === void 0 ? void 0 : opts.body);
1358
1431
  if (contentType) headers.set("content-type", contentType);
1359
1432
  }
1360
1433
  return headers;
@@ -1376,18 +1449,14 @@ function getBody(options, headers) {
1376
1449
  return JSON.stringify(body);
1377
1450
  }
1378
1451
  function getMethod$1(url, options) {
1379
- var _a;
1380
- if (options == null ? void 0 : options.method) return options.method.toUpperCase();
1381
- if (url.startsWith("@")) {
1382
- const pMethod = (_a = url.split("@")[1]) == null ? void 0 : _a.split("/")[0];
1383
- if (!methods.includes(pMethod)) return (options == null ? void 0 : options.body) ? "POST" : "GET";
1384
- return pMethod.toUpperCase();
1385
- }
1386
- return (options == null ? void 0 : options.body) ? "POST" : "GET";
1452
+ if (options === null || options === void 0 ? void 0 : options.method) return options.method.toUpperCase();
1453
+ const { method } = parseMethodModifier(url);
1454
+ if (method) return method.toUpperCase();
1455
+ return (options === null || options === void 0 ? void 0 : options.body) ? "POST" : "GET";
1387
1456
  }
1388
1457
  function getTimeout(options, controller) {
1389
1458
  let abortTimeout;
1390
- if (!(options == null ? void 0 : options.signal) && (options == null ? void 0 : options.timeout)) abortTimeout = setTimeout(() => controller == null ? void 0 : controller.abort(), options == null ? void 0 : options.timeout);
1459
+ if (!(options === null || options === void 0 ? void 0 : options.signal) && (options === null || options === void 0 ? void 0 : options.timeout)) abortTimeout = setTimeout(() => controller === null || controller === void 0 ? void 0 : controller.abort(), options === null || options === void 0 ? void 0 : options.timeout);
1391
1460
  return {
1392
1461
  abortTimeout,
1393
1462
  clearTimeout: () => {
@@ -1395,11 +1464,11 @@ function getTimeout(options, controller) {
1395
1464
  }
1396
1465
  };
1397
1466
  }
1398
- var ValidationError = class _ValidationError extends Error {
1467
+ var ValidationError = class ValidationError extends Error {
1399
1468
  constructor(issues, message) {
1400
1469
  super(message || JSON.stringify(issues, null, 2));
1401
1470
  this.issues = issues;
1402
- Object.setPrototypeOf(this, _ValidationError.prototype);
1471
+ Object.setPrototypeOf(this, ValidationError.prototype);
1403
1472
  }
1404
1473
  };
1405
1474
  async function parseStandardSchema(schema, input) {
@@ -1407,186 +1476,100 @@ async function parseStandardSchema(schema, input) {
1407
1476
  if (result.issues) throw new ValidationError(result.issues);
1408
1477
  return result.value;
1409
1478
  }
1410
- var methods = [
1411
- "get",
1412
- "post",
1413
- "put",
1414
- "patch",
1415
- "delete"
1416
- ];
1417
- var applySchemaPlugin = (config) => ({
1418
- id: "apply-schema",
1419
- name: "Apply Schema",
1420
- version: "1.0.0",
1421
- async init(url, options) {
1422
- var _a, _b, _c, _d;
1423
- const schema = ((_b = (_a = config.plugins) == null ? void 0 : _a.find((plugin) => {
1424
- var _a2;
1425
- return ((_a2 = plugin.schema) == null ? void 0 : _a2.config) ? url.startsWith(plugin.schema.config.baseURL || "") || url.startsWith(plugin.schema.config.prefix || "") : false;
1426
- })) == null ? void 0 : _b.schema) || config.schema;
1427
- if (schema) {
1428
- let urlKey = url;
1429
- if ((_c = schema.config) == null ? void 0 : _c.prefix) {
1430
- if (urlKey.startsWith(schema.config.prefix)) {
1431
- urlKey = urlKey.replace(schema.config.prefix, "");
1432
- if (schema.config.baseURL) url = url.replace(schema.config.prefix, schema.config.baseURL);
1433
- }
1434
- }
1435
- if ((_d = schema.config) == null ? void 0 : _d.baseURL) {
1436
- if (urlKey.startsWith(schema.config.baseURL)) urlKey = urlKey.replace(schema.config.baseURL, "");
1437
- }
1438
- if (urlKey.startsWith("/") && urlKey.charAt(1) === "@") urlKey = urlKey.substring(1);
1439
- const keySchema = schema.schema[urlKey];
1440
- if (keySchema) {
1441
- let validatedHeaders = options == null ? void 0 : options.headers;
1442
- if (keySchema.headers && !(options == null ? void 0 : options.disableValidation)) {
1443
- const normalizedHeaders = {};
1444
- if (options == null ? void 0 : options.headers) {
1445
- if (options.headers instanceof Headers) options.headers.forEach((value, key) => {
1446
- normalizedHeaders[key.toLowerCase()] = value;
1447
- });
1448
- else if (typeof options.headers === "object") {
1449
- for (const [key, value] of Object.entries(options.headers)) if (value !== null && value !== void 0) normalizedHeaders[key.toLowerCase()] = value;
1450
- }
1451
- }
1452
- const validated = await parseStandardSchema(keySchema.headers, normalizedHeaders);
1453
- const finalHeaders = {};
1454
- for (const [key, value] of Object.entries(validated)) finalHeaders[key.toLowerCase()] = value;
1455
- validatedHeaders = finalHeaders;
1456
- }
1457
- let opts = __spreadProps(__spreadValues({}, options), {
1458
- method: keySchema.method,
1459
- output: keySchema.output,
1460
- headers: validatedHeaders
1461
- });
1462
- if (!(options == null ? void 0 : options.disableValidation)) opts = __spreadProps(__spreadValues({}, opts), {
1463
- body: keySchema.input ? await parseStandardSchema(keySchema.input, options == null ? void 0 : options.body) : options == null ? void 0 : options.body,
1464
- params: keySchema.params ? await parseStandardSchema(keySchema.params, options == null ? void 0 : options.params) : options == null ? void 0 : options.params,
1465
- query: keySchema.query ? await parseStandardSchema(keySchema.query, options == null ? void 0 : options.query) : options == null ? void 0 : options.query
1466
- });
1467
- return {
1468
- url,
1469
- options: opts
1470
- };
1471
- }
1472
- }
1473
- return {
1474
- url,
1475
- options
1476
- };
1479
+ function _typeof(o) {
1480
+ "@babel/helpers - typeof";
1481
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
1482
+ return typeof o;
1483
+ } : function(o) {
1484
+ return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
1485
+ }, _typeof(o);
1486
+ }
1487
+ function toPrimitive(t, r) {
1488
+ if ("object" != _typeof(t) || !t) return t;
1489
+ var e = t[Symbol.toPrimitive];
1490
+ if (void 0 !== e) {
1491
+ var i = e.call(t, r || "default");
1492
+ if ("object" != _typeof(i)) return i;
1493
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1477
1494
  }
1478
- });
1479
- var createFetch = (config) => {
1480
- async function $fetch(url, options) {
1481
- const opts = __spreadProps(__spreadValues(__spreadValues({}, config), options), {
1482
- headers: mergeHeaders(config == null ? void 0 : config.headers, options == null ? void 0 : options.headers),
1483
- plugins: [
1484
- ...(config == null ? void 0 : config.plugins) || [],
1485
- applySchemaPlugin(config || {}),
1486
- ...(options == null ? void 0 : options.plugins) || []
1487
- ]
1488
- });
1489
- if (config == null ? void 0 : config.catchAllError) try {
1490
- return await betterFetch(url, opts);
1491
- } catch (error) {
1492
- return {
1493
- data: null,
1494
- error: {
1495
- status: 500,
1496
- statusText: "Fetch Error",
1497
- message: "Fetch related error. Captured by catchAllError option. See error property for more details.",
1498
- error
1499
- }
1500
- };
1501
- }
1502
- return await betterFetch(url, opts);
1503
- }
1504
- return $fetch;
1505
- };
1506
- var isReservedPathSegment = (value) => value === "." || value === "..";
1507
- function encodePathSegment(segment, pathParams) {
1508
- let pathSegment = segment;
1509
- for (const [key, value] of pathParams) pathSegment = pathSegment.replace(key, value);
1510
- if (isReservedPathSegment(pathSegment)) throw new TypeError("Path parameters cannot be reserved path segments");
1511
- return encodeURIComponent(pathSegment);
1512
- }
1513
- function getURL2(url, option) {
1514
- const { baseURL, params, query } = option || {
1515
- query: {},
1516
- params: {},
1517
- baseURL: ""
1518
- };
1519
- let basePath = url.startsWith("http") ? url.split("/").slice(0, 3).join("/") : baseURL || "";
1520
- if (url.startsWith("@")) {
1521
- const m = url.toString().split("@")[1].split("/")[0];
1522
- if (methods.includes(m)) url = url.replace(`@${m}/`, "/");
1495
+ return ("string" === r ? String : Number)(t);
1496
+ }
1497
+ function toPropertyKey(t) {
1498
+ var i = toPrimitive(t, "string");
1499
+ return "symbol" == _typeof(i) ? i : i + "";
1500
+ }
1501
+ function _defineProperty(e, r, t) {
1502
+ return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
1503
+ value: t,
1504
+ enumerable: !0,
1505
+ configurable: !0,
1506
+ writable: !0
1507
+ }) : e[r] = t, e;
1508
+ }
1509
+ function ownKeys(e, r) {
1510
+ var t = Object.keys(e);
1511
+ if (Object.getOwnPropertySymbols) {
1512
+ var o = Object.getOwnPropertySymbols(e);
1513
+ r && (o = o.filter(function(r) {
1514
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
1515
+ })), t.push.apply(t, o);
1523
1516
  }
1524
- if (!basePath.endsWith("/")) basePath += "/";
1525
- let [path, urlQuery] = url.replace(basePath, "").split("?");
1526
- const queryParams = new URLSearchParams(urlQuery);
1527
- for (const [key, value] of Object.entries(query || {})) {
1528
- if (value == null) continue;
1529
- let serializedValue;
1530
- if (typeof value === "string") serializedValue = value;
1531
- else if (Array.isArray(value)) {
1532
- for (const val of value) queryParams.append(key, val);
1533
- continue;
1534
- } else serializedValue = JSON.stringify(value);
1535
- queryParams.set(key, serializedValue);
1536
- }
1537
- const pathParams = /* @__PURE__ */ new Map();
1538
- if (params) {
1539
- if (Array.isArray(params)) {
1540
- const paramPaths = path.split("/").filter((p) => p.startsWith(":"));
1541
- for (const [index, key] of paramPaths.entries()) {
1542
- const value = params[index];
1543
- pathParams.set(key, String(value));
1544
- }
1545
- } else for (const [key, value] of Object.entries(params)) pathParams.set(`:${key}`, String(value));
1517
+ return t;
1518
+ }
1519
+ function _objectSpread2(e) {
1520
+ for (var r = 1; r < arguments.length; r++) {
1521
+ var t = null != arguments[r] ? arguments[r] : {};
1522
+ r % 2 ? ownKeys(Object(t), !0).forEach(function(r) {
1523
+ _defineProperty(e, r, t[r]);
1524
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function(r) {
1525
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
1526
+ });
1546
1527
  }
1547
- path = path.split("/").map((segment) => encodePathSegment(segment, pathParams)).join("/");
1548
- path = path.replace(/^\/+/, "");
1549
- let queryParamString = queryParams.toString();
1550
- queryParamString = queryParamString.length > 0 ? `?${queryParamString}`.replace(/\+/g, "%20") : "";
1551
- if (!basePath.startsWith("http")) return `${basePath}${path}${queryParamString}`;
1552
- return new URL(`${path}${queryParamString}`, basePath);
1528
+ return e;
1553
1529
  }
1554
- var betterFetch = async (url, options) => {
1555
- var _a, _b, _c, _d, _e, _f, _g, _h;
1530
+ const betterFetch = async (url, options) => {
1531
+ var _opts$signal, _options$body, _options$jsonParser;
1556
1532
  const { hooks, url: __url, options: opts } = await initializePlugins(url, options);
1557
1533
  const fetch = getFetch(opts);
1558
1534
  const controller = new AbortController();
1559
- const signal = (_a = opts.signal) != null ? _a : controller.signal;
1560
- const _url = getURL2(__url, opts);
1535
+ const signal = (_opts$signal = opts.signal) !== null && _opts$signal !== void 0 ? _opts$signal : controller.signal;
1536
+ const _url = getURL$1(__url, opts);
1561
1537
  const headers = await getHeaders(opts);
1562
1538
  const body = getBody(opts, headers);
1563
1539
  const method = getMethod$1(__url, opts);
1564
- const context = __spreadProps(__spreadValues({}, opts), {
1540
+ const context = _objectSpread2(_objectSpread2({}, opts), {}, {
1565
1541
  url: _url,
1566
1542
  headers,
1567
1543
  body,
1568
1544
  method,
1569
1545
  signal
1570
1546
  });
1547
+ /**
1548
+ * Run all on request hooks
1549
+ */
1571
1550
  for (const onRequest of hooks.onRequest) if (onRequest) {
1572
1551
  const res = await onRequest(context);
1573
1552
  if (typeof res === "object" && res !== null) Object.assign(context, res);
1574
1553
  }
1575
- if ("pipeTo" in context && typeof context.pipeTo === "function" || typeof ((_b = options == null ? void 0 : options.body) == null ? void 0 : _b.pipe) === "function") {
1554
+ if ("pipeTo" in context && typeof context.pipeTo === "function" || typeof (options === null || options === void 0 || (_options$body = options.body) === null || _options$body === void 0 ? void 0 : _options$body.pipe) === "function") {
1576
1555
  if (!("duplex" in context)) context.duplex = "half";
1577
1556
  }
1578
- const { clearTimeout: clearTimeout2 } = getTimeout(opts, controller);
1557
+ const { clearTimeout } = getTimeout(opts, controller);
1579
1558
  let response = await fetch(context.url, context);
1580
- clearTimeout2();
1559
+ clearTimeout();
1581
1560
  const responseContext = {
1582
1561
  response,
1583
1562
  request: context
1584
1563
  };
1585
1564
  for (const onResponse of hooks.onResponse) if (onResponse) {
1586
- const r = await onResponse(__spreadProps(__spreadValues({}, responseContext), { response: ((_c = options == null ? void 0 : options.hookOptions) == null ? void 0 : _c.cloneResponse) ? response.clone() : response }));
1565
+ var _options$hookOptions;
1566
+ const r = await onResponse(_objectSpread2(_objectSpread2({}, responseContext), {}, { response: (options === null || options === void 0 || (_options$hookOptions = options.hookOptions) === null || _options$hookOptions === void 0 ? void 0 : _options$hookOptions.cloneResponse) ? response.clone() : response }));
1587
1567
  if (r instanceof Response) response = r;
1588
1568
  else if (typeof r === "object" && r !== null) response = r.response;
1589
1569
  }
1570
+ /**
1571
+ * OK Branch
1572
+ */
1590
1573
  if (response.ok) {
1591
1574
  if (!(context.method !== "HEAD")) return {
1592
1575
  data: "",
@@ -1599,55 +1582,166 @@ var betterFetch = async (url, options) => {
1599
1582
  request: context
1600
1583
  };
1601
1584
  if (responseType === "json" || responseType === "text") {
1585
+ var _context$jsonParser;
1602
1586
  const text = await response.text();
1603
- successContext.data = await ((_d = context.jsonParser) != null ? _d : jsonParse)(text);
1587
+ successContext.data = await ((_context$jsonParser = context.jsonParser) !== null && _context$jsonParser !== void 0 ? _context$jsonParser : jsonParse)(text);
1604
1588
  } else successContext.data = await response[responseType]();
1605
- if (context == null ? void 0 : context.output) {
1589
+ /**
1590
+ * Parse the data if the output schema is defined
1591
+ */
1592
+ if (context === null || context === void 0 ? void 0 : context.output) {
1606
1593
  if (context.output && !context.disableValidation) successContext.data = await parseStandardSchema(context.output, successContext.data);
1607
1594
  }
1608
- for (const onSuccess of hooks.onSuccess) if (onSuccess) await onSuccess(__spreadProps(__spreadValues({}, successContext), { response: ((_e = options == null ? void 0 : options.hookOptions) == null ? void 0 : _e.cloneResponse) ? response.clone() : response }));
1609
- if (options == null ? void 0 : options.throw) return successContext.data;
1595
+ for (const onSuccess of hooks.onSuccess) if (onSuccess) {
1596
+ var _options$hookOptions2;
1597
+ await onSuccess(_objectSpread2(_objectSpread2({}, successContext), {}, { response: (options === null || options === void 0 || (_options$hookOptions2 = options.hookOptions) === null || _options$hookOptions2 === void 0 ? void 0 : _options$hookOptions2.cloneResponse) ? response.clone() : response }));
1598
+ }
1599
+ if (options === null || options === void 0 ? void 0 : options.throw) return successContext.data;
1610
1600
  return {
1611
1601
  data: successContext.data,
1612
1602
  error: null
1613
1603
  };
1614
1604
  }
1615
- const parser = (_f = options == null ? void 0 : options.jsonParser) != null ? _f : jsonParse;
1605
+ const parser = (_options$jsonParser = options === null || options === void 0 ? void 0 : options.jsonParser) !== null && _options$jsonParser !== void 0 ? _options$jsonParser : jsonParse;
1616
1606
  const responseText = await response.text();
1617
1607
  const isJSONResponse = isJSONParsable(responseText);
1618
1608
  const errorObject = isJSONResponse ? await parser(responseText) : null;
1609
+ /**
1610
+ * Error Branch
1611
+ */
1619
1612
  const errorContext = {
1620
1613
  response,
1621
1614
  responseText,
1622
1615
  request: context,
1623
- error: __spreadProps(__spreadValues({}, errorObject), {
1616
+ error: _objectSpread2(_objectSpread2({}, errorObject), {}, {
1624
1617
  status: response.status,
1625
1618
  statusText: response.statusText
1626
1619
  })
1627
1620
  };
1628
- for (const onError of hooks.onError) if (onError) await onError(__spreadProps(__spreadValues({}, errorContext), { response: ((_g = options == null ? void 0 : options.hookOptions) == null ? void 0 : _g.cloneResponse) ? response.clone() : response }));
1629
- if (options == null ? void 0 : options.retry) {
1621
+ for (const onError of hooks.onError) if (onError) {
1622
+ var _options$hookOptions3;
1623
+ await onError(_objectSpread2(_objectSpread2({}, errorContext), {}, { response: (options === null || options === void 0 || (_options$hookOptions3 = options.hookOptions) === null || _options$hookOptions3 === void 0 ? void 0 : _options$hookOptions3.cloneResponse) ? response.clone() : response }));
1624
+ }
1625
+ if (options === null || options === void 0 ? void 0 : options.retry) {
1626
+ var _options$retryAttempt;
1630
1627
  const retryStrategy = createRetryStrategy(options.retry);
1631
- const _retryAttempt = (_h = options.retryAttempt) != null ? _h : 0;
1628
+ const _retryAttempt = (_options$retryAttempt = options.retryAttempt) !== null && _options$retryAttempt !== void 0 ? _options$retryAttempt : 0;
1632
1629
  if (await retryStrategy.shouldAttemptRetry(_retryAttempt, response)) {
1633
1630
  for (const onRetry of hooks.onRetry) if (onRetry) await onRetry(responseContext);
1634
1631
  const delay = retryStrategy.getDelay(_retryAttempt);
1635
1632
  await new Promise((resolve) => setTimeout(resolve, delay));
1636
- return await betterFetch(url, __spreadProps(__spreadValues({}, options), { retryAttempt: _retryAttempt + 1 }));
1633
+ return await betterFetch(url, _objectSpread2(_objectSpread2({}, options), {}, { retryAttempt: _retryAttempt + 1 }));
1637
1634
  }
1638
1635
  }
1639
- if (options == null ? void 0 : options.throw) throw new BetterFetchError(response.status, response.statusText, isJSONResponse ? errorObject : responseText);
1636
+ if (options === null || options === void 0 ? void 0 : options.throw) throw new BetterFetchError(response.status, response.statusText, isJSONResponse ? errorObject : responseText);
1640
1637
  return {
1641
1638
  data: null,
1642
- error: __spreadProps(__spreadValues({}, errorObject), {
1639
+ error: _objectSpread2(_objectSpread2({}, errorObject), {}, {
1643
1640
  status: response.status,
1644
1641
  statusText: response.statusText
1645
1642
  })
1646
1643
  };
1647
1644
  };
1645
+ const applySchemaPlugin = (config) => ({
1646
+ id: "apply-schema",
1647
+ name: "Apply Schema",
1648
+ version: "1.0.0",
1649
+ async init(url, options) {
1650
+ var _config$plugins;
1651
+ let opts = _objectSpread2(_objectSpread2({}, options), config.query !== void 0 && { query: _objectSpread2(_objectSpread2({}, config.query), options === null || options === void 0 ? void 0 : options.query) });
1652
+ const schema = ((_config$plugins = config.plugins) === null || _config$plugins === void 0 || (_config$plugins = _config$plugins.find((plugin) => {
1653
+ var _plugin$schema;
1654
+ return ((_plugin$schema = plugin.schema) === null || _plugin$schema === void 0 ? void 0 : _plugin$schema.config) ? url.startsWith(plugin.schema.config.baseURL || "") || url.startsWith(plugin.schema.config.prefix || "") : false;
1655
+ })) === null || _config$plugins === void 0 ? void 0 : _config$plugins.schema) || config.schema;
1656
+ if (schema) {
1657
+ var _schema$config, _schema$config2;
1658
+ let urlKey = url;
1659
+ if ((_schema$config = schema.config) === null || _schema$config === void 0 ? void 0 : _schema$config.prefix) {
1660
+ if (urlKey.startsWith(schema.config.prefix)) {
1661
+ urlKey = urlKey.replace(schema.config.prefix, "");
1662
+ if (schema.config.baseURL) url = url.replace(schema.config.prefix, schema.config.baseURL);
1663
+ }
1664
+ }
1665
+ if ((_schema$config2 = schema.config) === null || _schema$config2 === void 0 ? void 0 : _schema$config2.baseURL) {
1666
+ if (urlKey.startsWith(schema.config.baseURL)) urlKey = urlKey.replace(schema.config.baseURL, "");
1667
+ }
1668
+ if (urlKey.startsWith("/") && urlKey.charAt(1) === "@") urlKey = urlKey.substring(1);
1669
+ const keySchema = schema.schema[urlKey];
1670
+ if (keySchema) {
1671
+ var _keySchema$method;
1672
+ const { method: schemaMethod, path } = parseMethodModifier(urlKey);
1673
+ if (schemaMethod) url = url.slice(0, url.length - urlKey.length) + path;
1674
+ let validatedHeaders = options === null || options === void 0 ? void 0 : options.headers;
1675
+ if (keySchema.headers && !(options === null || options === void 0 ? void 0 : options.disableValidation)) {
1676
+ const normalizedHeaders = {};
1677
+ if (options === null || options === void 0 ? void 0 : options.headers) {
1678
+ if (options.headers instanceof Headers) options.headers.forEach((value, key) => {
1679
+ normalizedHeaders[key.toLowerCase()] = value;
1680
+ });
1681
+ else if (typeof options.headers === "object") {
1682
+ for (const [key, value] of Object.entries(options.headers)) if (value !== null && value !== void 0) normalizedHeaders[key.toLowerCase()] = value;
1683
+ }
1684
+ }
1685
+ const validated = await parseStandardSchema(keySchema.headers, normalizedHeaders);
1686
+ const finalHeaders = {};
1687
+ for (const [key, value] of Object.entries(validated)) finalHeaders[key.toLowerCase()] = value;
1688
+ validatedHeaders = finalHeaders;
1689
+ }
1690
+ const method = (_keySchema$method = keySchema.method) !== null && _keySchema$method !== void 0 ? _keySchema$method : schemaMethod;
1691
+ opts = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, opts), method !== void 0 && { method }), keySchema.output !== void 0 && { output: keySchema.output }), validatedHeaders !== void 0 && { headers: validatedHeaders });
1692
+ if (!(options === null || options === void 0 ? void 0 : options.disableValidation)) {
1693
+ if (keySchema.query) {
1694
+ opts.query = await parseStandardSchema(keySchema.query, options === null || options === void 0 ? void 0 : options.query);
1695
+ if (opts.query !== null && typeof opts.query === "object") {
1696
+ const defaults = _objectSpread2({}, config.query);
1697
+ for (const key of Object.keys(defaults)) if ((options === null || options === void 0 ? void 0 : options.query) && Object.prototype.hasOwnProperty.call(options.query, key)) defaults[key] = options.query[key];
1698
+ opts.query = _objectSpread2(_objectSpread2({}, defaults), opts.query);
1699
+ }
1700
+ }
1701
+ opts = _objectSpread2(_objectSpread2({}, opts), {}, {
1702
+ body: keySchema.input ? await parseStandardSchema(keySchema.input, options === null || options === void 0 ? void 0 : options.body) : options === null || options === void 0 ? void 0 : options.body,
1703
+ params: keySchema.params ? await parseStandardSchema(keySchema.params, options === null || options === void 0 ? void 0 : options.params) : options === null || options === void 0 ? void 0 : options.params
1704
+ });
1705
+ }
1706
+ return {
1707
+ url,
1708
+ options: opts
1709
+ };
1710
+ }
1711
+ }
1712
+ return _objectSpread2({ url }, (options !== void 0 || config.query !== void 0) && { options: opts });
1713
+ }
1714
+ });
1715
+ const createFetch = (config) => {
1716
+ async function $fetch(url, options) {
1717
+ const opts = _objectSpread2(_objectSpread2(_objectSpread2({}, config), options), {}, {
1718
+ headers: mergeHeaders(config === null || config === void 0 ? void 0 : config.headers, options === null || options === void 0 ? void 0 : options.headers),
1719
+ plugins: [
1720
+ ...(config === null || config === void 0 ? void 0 : config.plugins) || [],
1721
+ applySchemaPlugin(config || {}),
1722
+ ...(options === null || options === void 0 ? void 0 : options.plugins) || []
1723
+ ]
1724
+ });
1725
+ if (config === null || config === void 0 ? void 0 : config.catchAllError) try {
1726
+ return await betterFetch(url, opts);
1727
+ } catch (error) {
1728
+ return {
1729
+ data: null,
1730
+ error: {
1731
+ status: 500,
1732
+ statusText: "Fetch Error",
1733
+ message: "Fetch related error. Captured by catchAllError option. See error property for more details.",
1734
+ error
1735
+ }
1736
+ };
1737
+ }
1738
+ return await betterFetch(url, opts);
1739
+ }
1740
+ return $fetch;
1741
+ };
1648
1742
 
1649
1743
  //#endregion
1650
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/client/parser.mjs
1744
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/parser.mjs
1651
1745
  const PROTO_POLLUTION_PATTERNS = {
1652
1746
  proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
1653
1747
  constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
@@ -1717,7 +1811,7 @@ function parseJSON(value, options = { strict: true }) {
1717
1811
  }
1718
1812
 
1719
1813
  //#endregion
1720
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/organization/access/statement.mjs
1814
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/organization/access/statement.mjs
1721
1815
  const defaultStatements = {
1722
1816
  organization: ["update", "delete"],
1723
1817
  member: [
@@ -1793,7 +1887,7 @@ const defaultRoles = {
1793
1887
  };
1794
1888
 
1795
1889
  //#endregion
1796
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/organization/permission.mjs
1890
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/organization/permission.mjs
1797
1891
  const hasPermissionFn = (input, acRoles) => {
1798
1892
  if (!input.permissions) return false;
1799
1893
  const roles = input.role.split(",");
@@ -1806,7 +1900,7 @@ const hasPermissionFn = (input, acRoles) => {
1806
1900
  };
1807
1901
 
1808
1902
  //#endregion
1809
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/organization/error-codes.mjs
1903
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/organization/error-codes.mjs
1810
1904
  const ORGANIZATION_ERROR_CODES = defineErrorCodes({
1811
1905
  YOU_ARE_NOT_ALLOWED_TO_CREATE_A_NEW_ORGANIZATION: "You are not allowed to create a new organization",
1812
1906
  YOU_HAVE_REACHED_THE_MAXIMUM_NUMBER_OF_ORGANIZATIONS: "You have reached the maximum number of organizations",
@@ -1898,6 +1992,7 @@ const t$1 = createAccessControl({
1898
1992
  `read`,
1899
1993
  `update`,
1900
1994
  `archive`,
1995
+ `restore`,
1901
1996
  `assign_teams`
1902
1997
  ],
1903
1998
  environment: [
@@ -1905,13 +2000,15 @@ const t$1 = createAccessControl({
1905
2000
  `read`,
1906
2001
  `update`,
1907
2002
  `archive`,
2003
+ `restore`,
1908
2004
  `set_production`
1909
2005
  ],
1910
2006
  flag: [
1911
2007
  `read`,
1912
2008
  `create`,
1913
2009
  `update`,
1914
- `archive`
2010
+ `archive`,
2011
+ `restore`
1915
2012
  ],
1916
2013
  flag_state: [`update`],
1917
2014
  flag_production: [`toggle`],
@@ -1927,6 +2024,7 @@ const t$1 = createAccessControl({
1927
2024
  ],
1928
2025
  evaluated_entity: [`read`, `delete`],
1929
2026
  snapshot: [`read`],
2027
+ snapshot_webhook: [`read`, `manage`],
1930
2028
  billing: [`read`, `manage`],
1931
2029
  sso: [
1932
2030
  `read`,
@@ -1954,6 +2052,7 @@ const n$1 = {
1954
2052
  environment: [`read`],
1955
2053
  flag: [`read`],
1956
2054
  evaluated_entity: [`read`],
2055
+ snapshot_webhook: [`read`],
1957
2056
  billing: [`read`],
1958
2057
  approval_policy: [`read`],
1959
2058
  approval_request: [`read`]
@@ -1977,6 +2076,7 @@ const n$1 = {
1977
2076
  `revoke`
1978
2077
  ],
1979
2078
  evaluated_entity: [`read`],
2079
+ snapshot_webhook: [`read`],
1980
2080
  billing: [`read`],
1981
2081
  approval_policy: [`read`],
1982
2082
  approval_request: [`read`]
@@ -2008,6 +2108,7 @@ const n$1 = {
2008
2108
  `read`,
2009
2109
  `update`,
2010
2110
  `archive`,
2111
+ `restore`,
2011
2112
  `assign_teams`
2012
2113
  ],
2013
2114
  environment: [
@@ -2015,13 +2116,15 @@ const n$1 = {
2015
2116
  `read`,
2016
2117
  `update`,
2017
2118
  `archive`,
2119
+ `restore`,
2018
2120
  `set_production`
2019
2121
  ],
2020
2122
  flag: [
2021
2123
  `read`,
2022
2124
  `create`,
2023
2125
  `update`,
2024
- `archive`
2126
+ `archive`,
2127
+ `restore`
2025
2128
  ],
2026
2129
  flag_state: [`update`],
2027
2130
  flag_production: [`toggle`],
@@ -2037,6 +2140,7 @@ const n$1 = {
2037
2140
  ],
2038
2141
  evaluated_entity: [`read`, `delete`],
2039
2142
  snapshot: [`read`],
2143
+ snapshot_webhook: [`read`, `manage`],
2040
2144
  billing: [`read`, `manage`],
2041
2145
  sso: [`read`, `manage`],
2042
2146
  service_account: [
@@ -2079,6 +2183,7 @@ const n$1 = {
2079
2183
  `read`,
2080
2184
  `update`,
2081
2185
  `archive`,
2186
+ `restore`,
2082
2187
  `assign_teams`
2083
2188
  ],
2084
2189
  environment: [
@@ -2086,13 +2191,15 @@ const n$1 = {
2086
2191
  `read`,
2087
2192
  `update`,
2088
2193
  `archive`,
2194
+ `restore`,
2089
2195
  `set_production`
2090
2196
  ],
2091
2197
  flag: [
2092
2198
  `read`,
2093
2199
  `create`,
2094
2200
  `update`,
2095
- `archive`
2201
+ `archive`,
2202
+ `restore`
2096
2203
  ],
2097
2204
  flag_state: [`update`],
2098
2205
  flag_production: [`toggle`],
@@ -2108,6 +2215,7 @@ const n$1 = {
2108
2215
  ],
2109
2216
  evaluated_entity: [`read`, `delete`],
2110
2217
  snapshot: [`read`],
2218
+ snapshot_webhook: [`read`, `manage`],
2111
2219
  billing: [`read`, `manage`],
2112
2220
  sso: [
2113
2221
  `read`,
@@ -2130,7 +2238,7 @@ const n$1 = {
2130
2238
  };
2131
2239
 
2132
2240
  //#endregion
2133
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/client/broadcast-channel.mjs
2241
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/broadcast-channel.mjs
2134
2242
  const kBroadcastChannel = Symbol.for("better-auth:broadcast-channel");
2135
2243
  const now$1 = () => Math.floor(Date.now() / 1e3);
2136
2244
  var WindowBroadcastChannel = class {
@@ -2354,7 +2462,7 @@ let onMount = ($store, initialize) => {
2354
2462
  };
2355
2463
 
2356
2464
  //#endregion
2357
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/client/equality.mjs
2465
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/equality.mjs
2358
2466
  function isPlainObject(value) {
2359
2467
  if (typeof value !== "object" || value === null) return false;
2360
2468
  const prototype = Object.getPrototypeOf(value);
@@ -2395,7 +2503,7 @@ function withEquality(store, isEqual) {
2395
2503
  }
2396
2504
 
2397
2505
  //#endregion
2398
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/client/focus-manager.mjs
2506
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/focus-manager.mjs
2399
2507
  const kFocusManager = Symbol.for("better-auth:focus-manager");
2400
2508
  var WindowFocusManager = class {
2401
2509
  listeners = /* @__PURE__ */ new Set();
@@ -2425,7 +2533,7 @@ function getGlobalFocusManager() {
2425
2533
  }
2426
2534
 
2427
2535
  //#endregion
2428
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/client/online-manager.mjs
2536
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/online-manager.mjs
2429
2537
  const kOnlineManager = Symbol.for("better-auth:online-manager");
2430
2538
  var WindowOnlineManager = class {
2431
2539
  listeners = /* @__PURE__ */ new Set();
@@ -2458,13 +2566,22 @@ function getGlobalOnlineManager() {
2458
2566
  }
2459
2567
 
2460
2568
  //#endregion
2461
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/client/query.mjs
2569
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/query-atom.mjs
2570
+ const kAuthQuery = Symbol.for("better-auth:auth-query");
2571
+ function createAuthQueryAtom(initialValue) {
2572
+ const queryAtom = /* @__PURE__ */ atom(initialValue);
2573
+ Object.defineProperty(queryAtom, kAuthQuery, { value: true });
2574
+ return queryAtom;
2575
+ }
2576
+
2577
+ //#endregion
2578
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/query.mjs
2462
2579
  const isServer$1 = () => typeof window === "undefined";
2463
2580
  function isAuthQueryStateEqual(a, b) {
2464
2581
  return isJsonEqual(a.data, b.data) && a.error === b.error && a.isPending === b.isPending && a.isRefetching === b.isRefetching && a.refetch === b.refetch;
2465
2582
  }
2466
2583
  const useAuthQuery = (initializedAtom, path, $fetch, options) => {
2467
- const value = /* @__PURE__ */ atom({
2584
+ const value = createAuthQueryAtom({
2468
2585
  data: null,
2469
2586
  error: null,
2470
2587
  isPending: true,
@@ -2472,7 +2589,9 @@ const useAuthQuery = (initializedAtom, path, $fetch, options) => {
2472
2589
  refetch: (queryParams) => fn(queryParams)
2473
2590
  });
2474
2591
  onMount(value, () => withEquality(value, isAuthQueryStateEqual));
2592
+ let latestRequestId = 0;
2475
2593
  const fn = async (queryParams) => {
2594
+ const requestId = ++latestRequestId;
2476
2595
  return new Promise((resolve) => {
2477
2596
  const opts = typeof options === "function" ? options({
2478
2597
  data: value.get().data,
@@ -2486,15 +2605,17 @@ const useAuthQuery = (initializedAtom, path, $fetch, options) => {
2486
2605
  ...queryParams?.query
2487
2606
  },
2488
2607
  async onSuccess(context) {
2489
- const current = value.get();
2490
- const stableData = current.data != null && context.data != null && isJsonEqual(current.data, context.data) ? current.data : context.data;
2491
- value.set({
2492
- data: stableData,
2493
- error: null,
2494
- isPending: false,
2495
- isRefetching: false,
2496
- refetch: value.value.refetch
2497
- });
2608
+ if (requestId === latestRequestId) {
2609
+ const current = value.get();
2610
+ const stableData = current.data != null && context.data != null && isJsonEqual(current.data, context.data) ? current.data : context.data;
2611
+ value.set({
2612
+ data: stableData,
2613
+ error: null,
2614
+ isPending: false,
2615
+ isRefetching: false,
2616
+ refetch: value.value.refetch
2617
+ });
2618
+ }
2498
2619
  await opts?.onSuccess?.(context);
2499
2620
  },
2500
2621
  async onError(context) {
@@ -2502,28 +2623,33 @@ const useAuthQuery = (initializedAtom, path, $fetch, options) => {
2502
2623
  const retryAttempts = typeof request.retry === "number" ? request.retry : request.retry?.attempts;
2503
2624
  const retryAttempt = request.retryAttempt || 0;
2504
2625
  if (retryAttempts && retryAttempt < retryAttempts) return;
2505
- const isUnauthorized = context.error.status === 401;
2506
- value.set({
2507
- error: context.error,
2508
- data: isUnauthorized ? null : value.get().data,
2509
- isPending: false,
2510
- isRefetching: false,
2511
- refetch: value.value.refetch
2512
- });
2626
+ if (requestId === latestRequestId) {
2627
+ const isUnauthorized = context.error.status === 401;
2628
+ value.set({
2629
+ error: context.error,
2630
+ data: isUnauthorized ? null : value.get().data,
2631
+ isPending: false,
2632
+ isRefetching: false,
2633
+ refetch: value.value.refetch
2634
+ });
2635
+ }
2513
2636
  await opts?.onError?.(context);
2514
2637
  },
2515
2638
  async onRequest(context) {
2516
- const currentValue = value.get();
2517
- value.set({
2518
- isPending: currentValue.data === null,
2519
- data: currentValue.data,
2520
- error: null,
2521
- isRefetching: true,
2522
- refetch: value.value.refetch
2523
- });
2639
+ if (requestId === latestRequestId) {
2640
+ const currentValue = value.get();
2641
+ value.set({
2642
+ isPending: currentValue.data === null,
2643
+ data: currentValue.data,
2644
+ error: null,
2645
+ isRefetching: true,
2646
+ refetch: value.value.refetch
2647
+ });
2648
+ }
2524
2649
  await opts?.onRequest?.(context);
2525
2650
  }
2526
2651
  }).catch((error) => {
2652
+ if (requestId !== latestRequestId) return;
2527
2653
  value.set({
2528
2654
  error,
2529
2655
  data: value.get().data,
@@ -2580,7 +2706,7 @@ const useAuthQuery = (initializedAtom, path, $fetch, options) => {
2580
2706
  };
2581
2707
 
2582
2708
  //#endregion
2583
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/client/session-refresh.mjs
2709
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/session-refresh.mjs
2584
2710
  const now = () => Math.floor(Date.now() / 1e3);
2585
2711
  /**
2586
2712
  * Rate limit: don't refetch on focus if a session request was made within this many seconds
@@ -2708,7 +2834,7 @@ function createSessionRefreshManager(opts) {
2708
2834
  }
2709
2835
 
2710
2836
  //#endregion
2711
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/client/fetch-plugins.mjs
2837
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/fetch-plugins.mjs
2712
2838
  const redirectPlugin = {
2713
2839
  id: "redirect",
2714
2840
  name: "Redirect",
@@ -2724,7 +2850,7 @@ const redirectPlugin = {
2724
2850
  };
2725
2851
 
2726
2852
  //#endregion
2727
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/client/session-atom.mjs
2853
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/session-atom.mjs
2728
2854
  const isServer = () => typeof window === "undefined";
2729
2855
  const SESSION_MOUNT_DEDUPE_INTERVAL = STORE_UNMOUNT_DELAY;
2730
2856
  function hydrateSessionAtom(sessionAtom, session) {
@@ -2767,7 +2893,7 @@ function getSessionAtom($fetch, options) {
2767
2893
  freshUntil = 0;
2768
2894
  });
2769
2895
  const refetch = (queryParams) => fetchSession(queryParams);
2770
- const session = /* @__PURE__ */ atom({
2896
+ const session = createAuthQueryAtom({
2771
2897
  data: null,
2772
2898
  error: null,
2773
2899
  isPending: true,
@@ -2899,7 +3025,7 @@ function getSessionAtom($fetch, options) {
2899
3025
  }
2900
3026
 
2901
3027
  //#endregion
2902
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/client/config.mjs
3028
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/config.mjs
2903
3029
  const resolvePublicAuthUrl = (basePath) => {
2904
3030
  if (typeof process === "undefined") return void 0;
2905
3031
  const path = basePath ?? "/api/auth";
@@ -2914,6 +3040,7 @@ const resolvePublicAuthUrl = (basePath) => {
2914
3040
  } catch {}
2915
3041
  }
2916
3042
  };
3043
+ const matchesSessionSignal = (path) => path === "/sign-out" || path === "/update-user" || path === "/update-session" || path === "/sign-up/email" || path === "/sign-in/email" || path === "/delete-user" || path === "/verify-email" || path === "/revoke-sessions" || path === "/revoke-session" || path === "/revoke-other-sessions" || path === "/change-email" || path === "/change-password";
2917
3044
  const getClientConfig = (options, loadEnv) => {
2918
3045
  const isCredentialsSupported = "credentials" in Request.prototype;
2919
3046
  const baseURL = getBaseURL(options?.baseURL, options?.basePath, void 0, loadEnv) ?? resolvePublicAuthUrl(options?.basePath) ?? "/api/auth";
@@ -2967,9 +3094,7 @@ const getClientConfig = (options, loadEnv) => {
2967
3094
  };
2968
3095
  const atomListeners = [{
2969
3096
  signal: "$sessionSignal",
2970
- matcher(path) {
2971
- return path === "/sign-out" || path === "/update-user" || path === "/update-session" || path === "/sign-up/email" || path === "/sign-in/email" || path === "/delete-user" || path === "/verify-email" || path === "/revoke-sessions" || path === "/revoke-session" || path === "/revoke-other-sessions" || path === "/change-email" || path === "/change-password";
2972
- },
3097
+ matcher: matchesSessionSignal,
2973
3098
  callback(path) {
2974
3099
  if (path === "/sign-out") broadcastSessionUpdate("signout");
2975
3100
  else if (path === "/update-user" || path === "/update-session") broadcastSessionUpdate("updateUser");
@@ -2999,19 +3124,20 @@ const getClientConfig = (options, loadEnv) => {
2999
3124
  pluginPathMethods,
3000
3125
  atomListeners,
3001
3126
  hydrateSession,
3127
+ $sessionSignal,
3002
3128
  $fetch,
3003
3129
  $store
3004
3130
  };
3005
3131
  };
3006
3132
 
3007
3133
  //#endregion
3008
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/utils/is-atom.mjs
3134
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/utils/is-atom.mjs
3009
3135
  function isAtom(value) {
3010
3136
  return typeof value === "object" && value !== null && "get" in value && typeof value.get === "function" && "lc" in value && typeof value.lc === "number";
3011
3137
  }
3012
3138
 
3013
3139
  //#endregion
3014
- //#region ../../node_modules/.pnpm/@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.1_@opentelemet_2e71ba5b354a0fbab5c1bdc9f6326b28/node_modules/@better-auth/core/dist/utils/string.mjs
3140
+ //#region ../../node_modules/.pnpm/@better-auth+core@1.7.7_@better-auth+utils@0.4.2_@better-fetch+fetch@1.3.2_@opentelemet_e02eb0bf6cc57b8ec4097db90c5ddf37/node_modules/@better-auth/core/dist/utils/string.mjs
3015
3141
  function capitalizeFirstLetter(str) {
3016
3142
  return str.charAt(0).toUpperCase() + str.slice(1);
3017
3143
  }
@@ -3025,7 +3151,7 @@ function toKebabCase(input) {
3025
3151
  }
3026
3152
 
3027
3153
  //#endregion
3028
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/client/proxy.mjs
3154
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/proxy.mjs
3029
3155
  function getMethod(path, knownPathMethods, args) {
3030
3156
  const method = knownPathMethods[path];
3031
3157
  const { fetchOptions, query: _query, ...body } = args || {};
@@ -3101,7 +3227,7 @@ function createDynamicPathProxy(routes, client, knownPathMethods, atoms, atomLis
3101
3227
  }
3102
3228
 
3103
3229
  //#endregion
3104
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/client/vanilla.mjs
3230
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/client/vanilla.mjs
3105
3231
  function createAuthClient(options) {
3106
3232
  const { pluginPathMethods, pluginsActions, pluginsAtoms, hydrateSession, $fetch, atomListeners, $store } = getClientConfig(options);
3107
3233
  const resolvedHooks = {};
@@ -3116,7 +3242,7 @@ function createAuthClient(options) {
3116
3242
  }
3117
3243
 
3118
3244
  //#endregion
3119
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/additional-fields/client.mjs
3245
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/additional-fields/client.mjs
3120
3246
  const inferAdditionalFields = (schema) => {
3121
3247
  return {
3122
3248
  id: "additional-fields-client",
@@ -3126,7 +3252,7 @@ const inferAdditionalFields = (schema) => {
3126
3252
  };
3127
3253
 
3128
3254
  //#endregion
3129
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/admin/client.mjs
3255
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/admin/client.mjs
3130
3256
  const adminClient = (options) => {
3131
3257
  const roles = {
3132
3258
  admin: adminAc$1,
@@ -3161,7 +3287,7 @@ const adminClient = (options) => {
3161
3287
  };
3162
3288
 
3163
3289
  //#endregion
3164
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/device-authorization/client.mjs
3290
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/device-authorization/client.mjs
3165
3291
  const deviceAuthorizationClient = () => {
3166
3292
  return {
3167
3293
  id: "device-authorization",
@@ -3178,7 +3304,7 @@ const deviceAuthorizationClient = () => {
3178
3304
  };
3179
3305
 
3180
3306
  //#endregion
3181
- //#region ../../node_modules/.pnpm/better-auth@1.7.1_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._29983ac85a08632d26ca60fb0be17581/node_modules/better-auth/dist/plugins/organization/client.mjs
3307
+ //#region ../../node_modules/.pnpm/better-auth@1.7.7_@opentelemetry+api@1.9.1_drizzle-kit@1.0.0-rc.4_drizzle-orm@1.0.0-rc._025f420fe344f13948728b361b367060/node_modules/better-auth/dist/plugins/organization/client.mjs
3182
3308
  /**
3183
3309
  * Using the same `hasPermissionFn` function, but without the need for a `ctx` parameter or the `organizationId` parameter.
3184
3310
  */
@@ -3245,7 +3371,7 @@ const organizationClient = (options) => {
3245
3371
  },
3246
3372
  {
3247
3373
  matcher(path) {
3248
- return path === "/sign-out" || path.startsWith("/organization");
3374
+ return matchesSessionSignal(path) || path.startsWith("/organization");
3249
3375
  },
3250
3376
  signal: "$activeOrgSignal"
3251
3377
  },
@@ -3273,7 +3399,7 @@ const organizationClient = (options) => {
3273
3399
  };
3274
3400
 
3275
3401
  //#endregion
3276
- //#region ../../node_modules/.pnpm/@better-auth+api-key@1.7.1_@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fet_a4fe5759ddb57f435137bfe015134721/node_modules/@better-auth/api-key/dist/version-D365O1mH.mjs
3402
+ //#region ../../node_modules/.pnpm/@better-auth+api-key@1.7.7_@better-auth+core@1.7.7_@better-auth+utils@0.4.2_@better-fet_1231755eab9fee363c80bc8eefaed94a/node_modules/@better-auth/api-key/dist/version-CUtTQbZf.mjs
3277
3403
  const API_KEY_ERROR_CODES = defineErrorCodes({
3278
3404
  INVALID_METADATA_TYPE: "metadata must be an object or undefined",
3279
3405
  REFILL_AMOUNT_AND_INTERVAL_REQUIRED: "refillAmount is required when refillInterval is provided",
@@ -3307,10 +3433,10 @@ const API_KEY_ERROR_CODES = defineErrorCodes({
3307
3433
  NO_DEFAULT_API_KEY_CONFIGURATION_FOUND: "No default api-key configuration found.",
3308
3434
  ORGANIZATION_PLUGIN_REQUIRED: "Organization plugin is required for organization-owned API keys. Please install and configure the organization plugin."
3309
3435
  });
3310
- const PACKAGE_VERSION$2 = "1.7.1";
3436
+ const PACKAGE_VERSION$2 = "1.7.7";
3311
3437
 
3312
3438
  //#endregion
3313
- //#region ../../node_modules/.pnpm/@better-auth+api-key@1.7.1_@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fet_a4fe5759ddb57f435137bfe015134721/node_modules/@better-auth/api-key/dist/client.mjs
3439
+ //#region ../../node_modules/.pnpm/@better-auth+api-key@1.7.7_@better-auth+core@1.7.7_@better-auth+utils@0.4.2_@better-fet_1231755eab9fee363c80bc8eefaed94a/node_modules/@better-auth/api-key/dist/client.mjs
3314
3440
  const apiKeyClient = () => {
3315
3441
  return {
3316
3442
  id: "api-key",
@@ -3326,7 +3452,7 @@ const apiKeyClient = () => {
3326
3452
  };
3327
3453
 
3328
3454
  //#endregion
3329
- //#region ../../node_modules/.pnpm/@better-auth+passkey@1.7.1_@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fet_670374e089e097efe27e0c3a48cf5b4e/node_modules/@better-auth/passkey/dist/version-CNE1I0BY.mjs
3455
+ //#region ../../node_modules/.pnpm/@better-auth+passkey@1.7.7_8a2847836f4e26061e61f8849e215b9d/node_modules/@better-auth/passkey/dist/version-Bx477_EO.mjs
3330
3456
  const PASSKEY_ERROR_CODES = defineErrorCodes({
3331
3457
  CHALLENGE_NOT_FOUND: "Challenge not found",
3332
3458
  YOU_ARE_NOT_ALLOWED_TO_REGISTER_THIS_PASSKEY: "You are not allowed to register this passkey",
@@ -3344,7 +3470,7 @@ const PASSKEY_ERROR_CODES = defineErrorCodes({
3344
3470
  RESOLVE_USER_REQUIRED: "Passkey registration requires either an authenticated session or a resolveUser callback when requireSession is false",
3345
3471
  RESOLVED_USER_INVALID: "Resolved user is invalid"
3346
3472
  });
3347
- const PACKAGE_VERSION$1 = "1.7.1";
3473
+ const PACKAGE_VERSION$1 = "1.7.7";
3348
3474
 
3349
3475
  //#endregion
3350
3476
  //#region ../../node_modules/.pnpm/@simplewebauthn+browser@13.3.0/node_modules/@simplewebauthn/browser/esm/helpers/bufferToBase64URLString.js
@@ -3816,7 +3942,7 @@ async function startAuthentication(options) {
3816
3942
  }
3817
3943
 
3818
3944
  //#endregion
3819
- //#region ../../node_modules/.pnpm/@better-auth+passkey@1.7.1_@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fet_670374e089e097efe27e0c3a48cf5b4e/node_modules/@better-auth/passkey/dist/client.mjs
3945
+ //#region ../../node_modules/.pnpm/@better-auth+passkey@1.7.7_8a2847836f4e26061e61f8849e215b9d/node_modules/@better-auth/passkey/dist/client.mjs
3820
3946
  const getPasskeyActions = ($fetch, { $listPasskeys, $store }) => {
3821
3947
  const signInPasskey = async (opts, options) => {
3822
3948
  const response = await $fetch("/passkey/generate-authenticate-options", {
@@ -4018,11 +4144,11 @@ const passkeyClient = () => {
4018
4144
  };
4019
4145
 
4020
4146
  //#endregion
4021
- //#region ../../node_modules/.pnpm/@better-auth+sso@1.7.1_@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fetch+f_f113731728b549e501373576d6a425b0/node_modules/@better-auth/sso/dist/version-BbG1DbY-.mjs
4022
- const PACKAGE_VERSION = "1.7.1";
4147
+ //#region ../../node_modules/.pnpm/@better-auth+sso@1.7.7_9007e608a51715e1e8e182bfada736ab/node_modules/@better-auth/sso/dist/version-DFla2W8i.mjs
4148
+ const PACKAGE_VERSION = "1.7.7";
4023
4149
 
4024
4150
  //#endregion
4025
- //#region ../../node_modules/.pnpm/@better-auth+sso@1.7.1_@better-auth+core@1.7.1_@better-auth+utils@0.4.2_@better-fetch+f_f113731728b549e501373576d6a425b0/node_modules/@better-auth/sso/dist/client.mjs
4151
+ //#region ../../node_modules/.pnpm/@better-auth+sso@1.7.7_9007e608a51715e1e8e182bfada736ab/node_modules/@better-auth/sso/dist/client.mjs
4026
4152
  const ssoClient = (options) => {
4027
4153
  return {
4028
4154
  id: "sso-client",
@@ -4159,7 +4285,7 @@ async function createCliApiClient(runtime) {
4159
4285
  sessionToken,
4160
4286
  orgSlug: runtime.org
4161
4287
  });
4162
- const client = O$1({
4288
+ const client = A$1({
4163
4289
  baseUrl: runtime.apiUrl,
4164
4290
  client: "cli",
4165
4291
  getHeaders: () => {
@@ -4503,25 +4629,27 @@ const T = z.object({
4503
4629
  tags: z.array(z.string()).optional()
4504
4630
  });
4505
4631
  const E = z.object({ flagId: z.string().min(1) });
4506
- const D = z.object({
4632
+ const D = z.object({ projectId: z.string().min(1) });
4633
+ const O = z.object({ flagId: z.string().min(1) });
4634
+ const k = z.object({
4507
4635
  flagId: z.string().min(1),
4508
4636
  environmentId: z.string().min(1),
4509
4637
  enabled: z.boolean().optional(),
4510
4638
  rules: z.array(b).optional(),
4511
4639
  fallthrough: u.optional()
4512
4640
  });
4513
- const O = z.object({
4641
+ const A = z.object({
4514
4642
  flagId: z.string().min(1),
4515
4643
  environmentId: z.string().min(1),
4516
4644
  enabled: z.boolean()
4517
4645
  });
4518
- const k = z.object({ flagId: z.string().min(1) });
4519
- const A = z.enum([`active`, `deprecated`]);
4520
- function j(e) {
4646
+ const j = z.object({ flagId: z.string().min(1) });
4647
+ const M = z.enum([`active`, `deprecated`]);
4648
+ function N(e) {
4521
4649
  let t = Object.getPrototypeOf(e);
4522
4650
  return t === Object.prototype || t === null;
4523
4651
  }
4524
- function M(e, t) {
4652
+ function P(e, t) {
4525
4653
  if (e === null) return !0;
4526
4654
  switch (typeof e) {
4527
4655
  case `boolean`:
@@ -4529,13 +4657,13 @@ function M(e, t) {
4529
4657
  case `number`: return Number.isFinite(e);
4530
4658
  case `object`: {
4531
4659
  let n = t ?? /* @__PURE__ */ new WeakSet();
4532
- return !n.has(e) && (n.add(e), Array.isArray(e) ? e.every((e) => M(e, n)) : !j(e) || Object.getOwnPropertySymbols(e).length > 0 ? !1 : Object.keys(e).every((t) => M(e[t], n)));
4660
+ return !n.has(e) && (n.add(e), Array.isArray(e) ? e.every((e) => P(e, n)) : !N(e) || Object.getOwnPropertySymbols(e).length > 0 ? !1 : Object.keys(e).every((t) => P(e[t], n)));
4533
4661
  }
4534
4662
  default: return !1;
4535
4663
  }
4536
4664
  }
4537
- const N = z.custom(M, { message: `default must be JSON-serializable` });
4538
- function P(e, t) {
4665
+ const F = z.custom(P, { message: `default must be JSON-serializable` });
4666
+ function I(e, t) {
4539
4667
  switch (e.type) {
4540
4668
  case `boolean`:
4541
4669
  typeof e.default != `boolean` && t.addIssue({
@@ -4564,43 +4692,43 @@ function P(e, t) {
4564
4692
  });
4565
4693
  break;
4566
4694
  }
4567
- case `json`: N.safeParse(e.default).success || t.addIssue({
4695
+ case `json`: F.safeParse(e.default).success || t.addIssue({
4568
4696
  code: `custom`,
4569
4697
  path: [`default`],
4570
4698
  message: `json flag default must be JSON-serializable`
4571
4699
  });
4572
4700
  }
4573
4701
  }
4574
- const F = z.object({
4702
+ const L = z.object({
4575
4703
  key: o,
4576
4704
  type: t,
4577
4705
  default: z.unknown(),
4578
4706
  description: z.string().optional(),
4579
4707
  tags: z.array(z.string()).default([]),
4580
- lifecycle: A.default(`active`),
4708
+ lifecycle: M.default(`active`),
4581
4709
  variants: z.array(z.string()).optional(),
4582
4710
  disabled: z.boolean().optional()
4583
4711
  });
4584
- const I = F.superRefine(P);
4585
- const L = F.extend({
4712
+ const R = L.superRefine(I);
4713
+ const z$1 = L.extend({
4586
4714
  version: z.number().int().positive(),
4587
4715
  environmentVersion: z.number().int().positive().optional(),
4588
4716
  managedBy: n
4589
- }).superRefine(P);
4590
- const R = z.object({
4717
+ }).superRefine(I);
4718
+ const B = z.object({
4591
4719
  version: z.number().int().positive(),
4592
4720
  environmentVersion: z.number().int().positive().optional()
4593
4721
  });
4594
- const z$1 = z.object({
4722
+ const V = z.object({
4595
4723
  projectId: z.string().min(1),
4596
4724
  environmentId: z.string().min(1)
4597
4725
  });
4598
- const B = z.object({
4726
+ const H = z.object({
4599
4727
  projectId: z.string(),
4600
4728
  environmentId: z.string(),
4601
- flags: z.array(L)
4729
+ flags: z.array(z$1)
4602
4730
  });
4603
- function V(e, t) {
4731
+ function U(e, t) {
4604
4732
  let n = /* @__PURE__ */ new Set();
4605
4733
  for (let [r, i] of e.entries()) n.has(i.key) && t.addIssue({
4606
4734
  code: `custom`,
@@ -4612,12 +4740,12 @@ function V(e, t) {
4612
4740
  message: `duplicate flag key "${i.key}"`
4613
4741
  }), n.add(i.key);
4614
4742
  }
4615
- const H = z.object({
4743
+ const W = z.object({
4616
4744
  projectId: z.string().min(1),
4617
4745
  environmentId: z.string().min(1),
4618
- flags: z.array(I).max(500)
4619
- }).superRefine((e, t) => V(e.flags, t));
4620
- const U = z.object({
4746
+ flags: z.array(R).max(500)
4747
+ }).superRefine((e, t) => U(e.flags, t));
4748
+ const G = z.object({
4621
4749
  key: z.string(),
4622
4750
  op: z.enum([
4623
4751
  `add`,
@@ -4625,32 +4753,32 @@ const U = z.object({
4625
4753
  `remove`,
4626
4754
  `unlinked`
4627
4755
  ]),
4628
- before: L.optional(),
4629
- after: I.optional(),
4756
+ before: z$1.optional(),
4757
+ after: R.optional(),
4630
4758
  message: z.string().optional()
4631
4759
  });
4632
- const W = z.object({
4760
+ const K = z.object({
4633
4761
  projectId: z.string(),
4634
4762
  environmentId: z.string(),
4635
- changes: z.array(U),
4636
- remoteOnly: z.array(L).default([])
4763
+ changes: z.array(G),
4764
+ remoteOnly: z.array(z$1).default([])
4637
4765
  });
4638
- const G = z.object({
4766
+ const q = z.object({
4639
4767
  projectId: z.string().min(1),
4640
4768
  environmentId: z.string().min(1),
4641
- flags: z.array(I).max(500),
4769
+ flags: z.array(R).max(500),
4642
4770
  apply: z.boolean().default(!1),
4643
4771
  prune: z.boolean().default(!1),
4644
4772
  force: z.boolean().default(!1),
4645
4773
  adopt: z.boolean().default(!1),
4646
- expectedVersions: z.record(z.string(), R).optional()
4647
- }).superRefine((e, t) => V(e.flags, t));
4648
- const K = z.object({
4774
+ expectedVersions: z.record(z.string(), B).optional()
4775
+ }).superRefine((e, t) => U(e.flags, t));
4776
+ const J = z.object({
4649
4777
  projectId: z.string(),
4650
4778
  environmentId: z.string(),
4651
4779
  applied: z.boolean(),
4652
- changes: z.array(U),
4653
- remoteOnly: z.array(L).default([]),
4780
+ changes: z.array(G),
4781
+ remoteOnly: z.array(z$1).default([]),
4654
4782
  forced: z.boolean().default(!1),
4655
4783
  adopted: z.boolean().default(!1),
4656
4784
  approvalRequests: z.array(z.string()).default([])
@@ -4658,7 +4786,7 @@ const K = z.object({
4658
4786
 
4659
4787
  //#endregion
4660
4788
  //#region src/lib/local-config.ts
4661
- const localFlagsArraySchema = z.array(I).superRefine((flags, ctx) => {
4789
+ const localFlagsArraySchema = z.array(R).superRefine((flags, ctx) => {
4662
4790
  const seen = /* @__PURE__ */ new Set();
4663
4791
  for (const [index, flag] of flags.entries()) {
4664
4792
  if (seen.has(flag.key)) ctx.addIssue({