@wix/cli-app 1.1.203 → 1.1.205

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 (79) hide show
  1. package/build/{AddPermissionCommand-6Z6GRQEW.js → AddPermissionCommand-TKH4IDGY.js} +2 -2
  2. package/build/{DevCommand-JISHSNMA.js → DevCommand-TZJTHEPK.js} +10 -10
  3. package/build/{GenerateCommand-MOA7RGTI.js → GenerateCommand-ATQX2HLT.js} +7 -7
  4. package/build/{LogsCommand-5GVCCIZR.js → LogsCommand-MGMPNTF6.js} +3 -3
  5. package/build/PreviewCommand-7XEF25NL.js +19 -0
  6. package/build/ReleaseCommand-QDZQCDD2.js +23 -0
  7. package/build/{ServeCommand-3O5KYQJ4.js → ServeCommand-CA446OFI.js} +3 -3
  8. package/build/{build-B4YPLLX5.js → build-PPQCMKBB.js} +6 -6
  9. package/build/{chunk-WYVW5PHI.js → chunk-55DNERET.js} +2 -2
  10. package/build/{chunk-7DSJSCRR.js → chunk-76JY27O6.js} +2 -2
  11. package/build/{chunk-IXYXDCPX.js → chunk-CIKITBXG.js} +6 -6
  12. package/build/{chunk-AX2ZGWHL.js → chunk-DVX75HMW.js} +2 -2
  13. package/build/{chunk-ICJEPBYH.js → chunk-ILL3SRYL.js} +3 -3
  14. package/build/{chunk-FJKSPEO6.js → chunk-LH34KBYD.js} +4 -4
  15. package/build/{chunk-7KN2TN7Q.js → chunk-LHSYBHMI.js} +6 -6
  16. package/build/{chunk-D7UTJB7M.js → chunk-MCH3LFTH.js} +2 -2
  17. package/build/{chunk-N72ZQDBM.js → chunk-NVRVXVAM.js} +7 -7
  18. package/build/{chunk-DGXIMCFR.js → chunk-R64KPCCU.js} +2 -2
  19. package/build/{chunk-YMZIPZHW.js → chunk-S3T3SC6X.js} +207 -203
  20. package/build/{chunk-YMZIPZHW.js.map → chunk-S3T3SC6X.js.map} +1 -1
  21. package/build/{chunk-7HAIU4K4.js → chunk-SEYDUHF7.js} +2 -2
  22. package/build/{chunk-4GIMBKKW.js → chunk-SRJIUE4M.js} +4 -4
  23. package/build/{chunk-J34RDXDM.js → chunk-TUIQSMUQ.js} +3 -3
  24. package/build/{chunk-TP5Y2Z7Q.js → chunk-UNLKQE2B.js} +2 -2
  25. package/build/{chunk-QHARPZL2.js → chunk-X4LNMVAS.js} +2 -2
  26. package/build/{chunk-A2D4NI6Z.js → chunk-ZD4OE3KH.js} +2 -2
  27. package/build/cloudflare-runtime/entry.js +37 -20
  28. package/build/cloudflare-runtime/getRegisteredExtensions.js +37 -20
  29. package/build/index.js +23 -23
  30. package/build/platform-sdk/chunk-2QLMI2GU.js +2 -0
  31. package/build/platform-sdk/chunk-2QLMI2GU.js.map +1 -0
  32. package/build/platform-sdk/chunk-TONDB6MX.js +2 -0
  33. package/build/platform-sdk/chunk-TONDB6MX.js.map +1 -0
  34. package/build/platform-sdk/{chunk-KXCY2KWZ.js → chunk-UTEFPCPF.js} +2 -2
  35. package/build/platform-sdk/dashboard.js +1 -1
  36. package/build/platform-sdk/editor.js +1 -1
  37. package/build/platform-sdk/sdk-context.js +1 -1
  38. package/build/platform-sdk/sdk-context.js.map +1 -1
  39. package/build/platform-sdk/site.js +1 -1
  40. package/build/platform-sdk/site.js.map +1 -1
  41. package/build/platform-sdk/web-methods.js +1 -1
  42. package/build/{preview-LENPSE2T.js → preview-LP2UHCWT.js} +12 -12
  43. package/build/{release-PAYLWX7K.js → release-NHG5YKSE.js} +14 -14
  44. package/build/{render-command-UIOYAX3T.js → render-command-WQTNWLO4.js} +5 -5
  45. package/package.json +2 -2
  46. package/build/PreviewCommand-5PHGFLEJ.js +0 -19
  47. package/build/ReleaseCommand-PEVBP6RK.js +0 -23
  48. package/build/platform-sdk/chunk-42Y3PAPA.js +0 -2
  49. package/build/platform-sdk/chunk-42Y3PAPA.js.map +0 -1
  50. package/build/platform-sdk/chunk-7JKHQSWI.js +0 -2
  51. package/build/platform-sdk/chunk-7JKHQSWI.js.map +0 -1
  52. /package/build/{AddPermissionCommand-6Z6GRQEW.js.map → AddPermissionCommand-TKH4IDGY.js.map} +0 -0
  53. /package/build/{DevCommand-JISHSNMA.js.map → DevCommand-TZJTHEPK.js.map} +0 -0
  54. /package/build/{GenerateCommand-MOA7RGTI.js.map → GenerateCommand-ATQX2HLT.js.map} +0 -0
  55. /package/build/{LogsCommand-5GVCCIZR.js.map → LogsCommand-MGMPNTF6.js.map} +0 -0
  56. /package/build/{PreviewCommand-5PHGFLEJ.js.map → PreviewCommand-7XEF25NL.js.map} +0 -0
  57. /package/build/{ReleaseCommand-PEVBP6RK.js.map → ReleaseCommand-QDZQCDD2.js.map} +0 -0
  58. /package/build/{ServeCommand-3O5KYQJ4.js.map → ServeCommand-CA446OFI.js.map} +0 -0
  59. /package/build/{build-B4YPLLX5.js.map → build-PPQCMKBB.js.map} +0 -0
  60. /package/build/{chunk-WYVW5PHI.js.map → chunk-55DNERET.js.map} +0 -0
  61. /package/build/{chunk-7DSJSCRR.js.map → chunk-76JY27O6.js.map} +0 -0
  62. /package/build/{chunk-IXYXDCPX.js.map → chunk-CIKITBXG.js.map} +0 -0
  63. /package/build/{chunk-AX2ZGWHL.js.map → chunk-DVX75HMW.js.map} +0 -0
  64. /package/build/{chunk-ICJEPBYH.js.map → chunk-ILL3SRYL.js.map} +0 -0
  65. /package/build/{chunk-FJKSPEO6.js.map → chunk-LH34KBYD.js.map} +0 -0
  66. /package/build/{chunk-7KN2TN7Q.js.map → chunk-LHSYBHMI.js.map} +0 -0
  67. /package/build/{chunk-D7UTJB7M.js.map → chunk-MCH3LFTH.js.map} +0 -0
  68. /package/build/{chunk-N72ZQDBM.js.map → chunk-NVRVXVAM.js.map} +0 -0
  69. /package/build/{chunk-DGXIMCFR.js.map → chunk-R64KPCCU.js.map} +0 -0
  70. /package/build/{chunk-7HAIU4K4.js.map → chunk-SEYDUHF7.js.map} +0 -0
  71. /package/build/{chunk-4GIMBKKW.js.map → chunk-SRJIUE4M.js.map} +0 -0
  72. /package/build/{chunk-J34RDXDM.js.map → chunk-TUIQSMUQ.js.map} +0 -0
  73. /package/build/{chunk-TP5Y2Z7Q.js.map → chunk-UNLKQE2B.js.map} +0 -0
  74. /package/build/{chunk-QHARPZL2.js.map → chunk-X4LNMVAS.js.map} +0 -0
  75. /package/build/{chunk-A2D4NI6Z.js.map → chunk-ZD4OE3KH.js.map} +0 -0
  76. /package/build/platform-sdk/{chunk-KXCY2KWZ.js.map → chunk-UTEFPCPF.js.map} +0 -0
  77. /package/build/{preview-LENPSE2T.js.map → preview-LP2UHCWT.js.map} +0 -0
  78. /package/build/{release-PAYLWX7K.js.map → release-NHG5YKSE.js.map} +0 -0
  79. /package/build/{render-command-UIOYAX3T.js.map → render-command-WQTNWLO4.js.map} +0 -0
@@ -4,7 +4,7 @@ import {
4
4
  extractHttpError,
5
5
  require_react,
6
6
  require_verror
7
- } from "./chunk-YMZIPZHW.js";
7
+ } from "./chunk-S3T3SC6X.js";
8
8
  import {
9
9
  __toESM,
10
10
  init_esm_shims
@@ -87,4 +87,4 @@ export {
87
87
  DebugLogProvider,
88
88
  useDebugLog
89
89
  };
90
- //# sourceMappingURL=chunk-7HAIU4K4.js.map
90
+ //# sourceMappingURL=chunk-SEYDUHF7.js.map
@@ -3,13 +3,13 @@ const require = _createRequire(import.meta.url);
3
3
  import {
4
4
  addUserFields,
5
5
  reportCommandStartEvent
6
- } from "./chunk-DGXIMCFR.js";
6
+ } from "./chunk-R64KPCCU.js";
7
7
  import {
8
8
  messages_default
9
9
  } from "./chunk-QBRIDBYB.js";
10
10
  import {
11
11
  DebugLogProvider
12
- } from "./chunk-7HAIU4K4.js";
12
+ } from "./chunk-SEYDUHF7.js";
13
13
  import {
14
14
  AuthProvider,
15
15
  BiProvider,
@@ -27,7 +27,7 @@ import {
27
27
  package_default,
28
28
  render,
29
29
  require_react
30
- } from "./chunk-YMZIPZHW.js";
30
+ } from "./chunk-S3T3SC6X.js";
31
31
  import {
32
32
  __toESM,
33
33
  init_esm_shims
@@ -135,4 +135,4 @@ export {
135
135
  renderCommand,
136
136
  runCommand
137
137
  };
138
- //# sourceMappingURL=chunk-4GIMBKKW.js.map
138
+ //# sourceMappingURL=chunk-SRJIUE4M.js.map
@@ -2,11 +2,11 @@ import { createRequire as _createRequire } from 'node:module';
2
2
  const require = _createRequire(import.meta.url);
3
3
  import {
4
4
  readAppManifest
5
- } from "./chunk-ICJEPBYH.js";
5
+ } from "./chunk-ILL3SRYL.js";
6
6
  import {
7
7
  getAppManifestPath,
8
8
  writeJson
9
- } from "./chunk-YMZIPZHW.js";
9
+ } from "./chunk-S3T3SC6X.js";
10
10
  import {
11
11
  init_esm_shims
12
12
  } from "./chunk-4EFJZ3GQ.js";
@@ -29,4 +29,4 @@ export {
29
29
  writeAppManifestFile,
30
30
  readAppManifestFile
31
31
  };
32
- //# sourceMappingURL=chunk-J34RDXDM.js.map
32
+ //# sourceMappingURL=chunk-TUIQSMUQ.js.map
@@ -16,7 +16,7 @@ import {
16
16
  require_semver,
17
17
  useProjectModel,
18
18
  writePackageJson
19
- } from "./chunk-YMZIPZHW.js";
19
+ } from "./chunk-S3T3SC6X.js";
20
20
  import {
21
21
  __commonJS,
22
22
  __require,
@@ -3941,4 +3941,4 @@ ejs/lib/ejs.js:
3941
3941
  * @license {@link http://www.apache.org/licenses/LICENSE-2.0 Apache License, Version 2.0}
3942
3942
  *)
3943
3943
  */
3944
- //# sourceMappingURL=chunk-TP5Y2Z7Q.js.map
3944
+ //# sourceMappingURL=chunk-UNLKQE2B.js.map
@@ -4,7 +4,7 @@ import {
4
4
  require_react,
5
5
  useBiLogger,
6
6
  wixCliAppBiEvents
7
- } from "./chunk-YMZIPZHW.js";
7
+ } from "./chunk-S3T3SC6X.js";
8
8
  import {
9
9
  __toESM,
10
10
  init_esm_shims
@@ -24,4 +24,4 @@ init_esm_shims();
24
24
  export {
25
25
  useWixCliAppBi
26
26
  };
27
- //# sourceMappingURL=chunk-QHARPZL2.js.map
27
+ //# sourceMappingURL=chunk-X4LNMVAS.js.map
@@ -15,7 +15,7 @@ import {
15
15
  toURLSearchParams,
16
16
  useHttpClient,
17
17
  usePanoramaMethodLogger
18
- } from "./chunk-YMZIPZHW.js";
18
+ } from "./chunk-S3T3SC6X.js";
19
19
  import {
20
20
  __commonJS,
21
21
  __toESM,
@@ -4806,4 +4806,4 @@ export {
4806
4806
  getBackendEventSlug,
4807
4807
  useExtensionDataClient
4808
4808
  };
4809
- //# sourceMappingURL=chunk-A2D4NI6Z.js.map
4809
+ //# sourceMappingURL=chunk-ZD4OE3KH.js.map
@@ -4435,7 +4435,7 @@ import { dirname, sep } from "node:path";
4435
4435
  // ../../node_modules/@wix/sdk-context/build/browser/index.mjs
4436
4436
  var wixContext = {};
4437
4437
 
4438
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-types/build/browser/index.mjs
4438
+ // ../../node_modules/@wix/sdk-types/build/browser/index.mjs
4439
4439
  function EventDefinition(type, isDomainEvent = false, transformations = (x) => x) {
4440
4440
  return () => ({
4441
4441
  __type: "event-definition",
@@ -4604,7 +4604,7 @@ function objectToKeyValue(input) {
4604
4604
  return Object.entries(input).filter(([_, value]) => Boolean(value)).map(([key, value]) => `${key}=${value}`).join(",");
4605
4605
  }
4606
4606
 
4607
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/context.js
4607
+ // ../../node_modules/@wix/sdk-runtime/build/context.js
4608
4608
  function runWithoutContext(fn) {
4609
4609
  const globalContext = globalThis.__wix_context__;
4610
4610
  const moduleContext = {
@@ -4636,14 +4636,14 @@ function runWithoutContext(fn) {
4636
4636
  }
4637
4637
  }
4638
4638
 
4639
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/constants.js
4639
+ // ../../node_modules/@wix/sdk-runtime/build/constants.js
4640
4640
  var RESTResponseToSDKResponseRenameMap = {
4641
4641
  id: "_id",
4642
4642
  createdDate: "_createdDate",
4643
4643
  updatedDate: "_updatedDate"
4644
4644
  };
4645
4645
 
4646
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/utils.js
4646
+ // ../../node_modules/@wix/sdk-runtime/build/utils.js
4647
4647
  function constantCase(input) {
4648
4648
  return split(input).map((part) => part.toLocaleUpperCase()).join("_");
4649
4649
  }
@@ -4669,7 +4669,7 @@ function split(value) {
4669
4669
  return result.slice(start, end).split(/\0/g);
4670
4670
  }
4671
4671
 
4672
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/transform-error.js
4672
+ // ../../node_modules/@wix/sdk-runtime/build/transform-error.js
4673
4673
  var isValidationError = (httpClientError) => "validationError" in (httpClientError.response?.data?.details ?? {});
4674
4674
  var isApplicationError = (httpClientError) => "applicationError" in (httpClientError.response?.data?.details ?? {});
4675
4675
  var isClientError = (httpClientError) => (httpClientError.response?.status ?? -1) >= 400 && (httpClientError.response?.status ?? -1) < 500;
@@ -4825,7 +4825,7 @@ var getArgumentIndex = (s) => {
4825
4825
  };
4826
4826
 
4827
4827
  // ../../node_modules/@wix/sdk/build/rest-modules.js
4828
- function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
4828
+ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, getAuthHeaders, options, hostName, useCDN, validateRequestSchema) {
4829
4829
  return runWithoutContext(() => origFunc({
4830
4830
  request: async (factory) => {
4831
4831
  const requestOptions = factory({
@@ -4858,7 +4858,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler,
4858
4858
  dataError = await res.json();
4859
4859
  } catch (e) {
4860
4860
  }
4861
- const error = errorBuilder2(res.status, dataError?.message, dataError?.details, {
4861
+ const error = errorBuilder2(res.status, dataError?.message ?? res.statusText, dataError?.details, {
4862
4862
  requestId: res.headers.get("X-Wix-Request-Id"),
4863
4863
  details: dataError
4864
4864
  });
@@ -4895,8 +4895,9 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler,
4895
4895
  },
4896
4896
  fetchWithAuth: boundFetch,
4897
4897
  wixAPIFetch,
4898
- getActiveToken
4899
- }));
4898
+ getActiveToken,
4899
+ getAuthHeaders
4900
+ }, { validateRequestSchema }));
4900
4901
  }
4901
4902
  var SDKError = class extends Error {
4902
4903
  response;
@@ -4929,7 +4930,7 @@ var errorBuilder2 = (code, description, details, data) => {
4929
4930
  });
4930
4931
  };
4931
4932
 
4932
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/rest-modules.js
4933
+ // ../../node_modules/@wix/sdk-runtime/build/rest-modules.js
4933
4934
  var DOMAINS = ["wix.com", "editorx.com"];
4934
4935
  var REGEX_CAPTURE_DOMAINS = new RegExp(`\\.(${DOMAINS.join("|")})$`);
4935
4936
  var WIX_API_DOMAINS = ["42.wixprod.net", "uw2-edt-1.wixprod.net"];
@@ -5162,7 +5163,7 @@ function camelCase(str) {
5162
5163
  return str.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : "").replace(/^./, (c) => c.toLowerCase());
5163
5164
  }
5164
5165
 
5165
- // ../../node_modules/@wix/sdk/build/nanoevents.js
5166
+ // ../../node_modules/@wix/sdk-runtime/build/nanoevents.js
5166
5167
  function createNanoEvents() {
5167
5168
  return {
5168
5169
  emit(event, ...args) {
@@ -5420,7 +5421,9 @@ function createClient(config) {
5420
5421
  const boundGetAuthHeaders = () => {
5421
5422
  return getAuthStrategy().getAuthHeaders(config.host);
5422
5423
  };
5424
+ const getFetchFn = () => config.fetch ?? fetch;
5423
5425
  const fetchWithAuth = async (urlOrRequest, requestInit) => {
5426
+ const fetch2 = getFetchFn();
5424
5427
  const authHeaders = await boundGetAuthHeaders();
5425
5428
  const headers = {
5426
5429
  ...requestInit?.headers ?? {},
@@ -5431,7 +5434,7 @@ function createClient(config) {
5431
5434
  const errorHandler = config.host?.getErrorHandler?.();
5432
5435
  try {
5433
5436
  if (typeof urlOrRequest === "string" || urlOrRequest instanceof URL) {
5434
- const response = await fetch(urlOrRequest, {
5437
+ const response = await fetch2(urlOrRequest, {
5435
5438
  ...requestInit,
5436
5439
  headers
5437
5440
  });
@@ -5452,7 +5455,7 @@ function createClient(config) {
5452
5455
  urlOrRequest.headers.set(k, v);
5453
5456
  }
5454
5457
  }
5455
- const response = await fetch(urlOrRequest, requestInit);
5458
+ const response = await fetch2(urlOrRequest, requestInit);
5456
5459
  errorHandler?.handleError(response, {
5457
5460
  requestOptions: {
5458
5461
  url: urlOrRequest.url,
@@ -5478,9 +5481,10 @@ function createClient(config) {
5478
5481
  const { client: servicePluginsClient, initModule: initServicePluginModule } = servicePluginsModules(getAuthStrategy);
5479
5482
  const { client: eventHandlersClient, initModule: initEventHandlerModule } = eventHandlersModules(getAuthStrategy);
5480
5483
  const boundFetch = async (url, options) => {
5484
+ const fetch2 = getFetchFn();
5481
5485
  const authHeaders = await boundGetAuthHeaders();
5482
5486
  const defaultContentTypeHeader = getDefaultContentHeader(options);
5483
- const response = await fetch(url, {
5487
+ const response = await fetch2(url, {
5484
5488
  ...options,
5485
5489
  headers: {
5486
5490
  ...defaultContentTypeHeader,
@@ -5511,12 +5515,25 @@ function createClient(config) {
5511
5515
  }
5512
5516
  const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;
5513
5517
  const shouldUseCDN = config.useCDN === void 0 ? getAuthStrategy().shouldUseCDN : config.useCDN;
5514
- return buildRESTDescriptor(runWithoutContext(() => isAmbassadorModule(modules)) ? toHTTPModule(modules) : modules, metadata ?? {}, boundFetch, config.host?.getErrorHandler?.(), (relativeUrl, fetchOptions) => {
5515
- const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);
5516
- finalUrl.host = apiBaseUrl;
5517
- finalUrl.protocol = "https";
5518
- return boundFetch(finalUrl.toString(), fetchOptions);
5519
- }, getAuthStrategy().getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name, shouldUseCDN);
5518
+ return buildRESTDescriptor(
5519
+ runWithoutContext(() => isAmbassadorModule(modules)) ? toHTTPModule(modules) : modules,
5520
+ metadata ?? {},
5521
+ boundFetch,
5522
+ config.host?.getErrorHandler?.(),
5523
+ (relativeUrl, fetchOptions) => {
5524
+ const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);
5525
+ finalUrl.host = apiBaseUrl;
5526
+ finalUrl.protocol = "https";
5527
+ return boundFetch(finalUrl.toString(), fetchOptions);
5528
+ },
5529
+ getAuthStrategy().getActiveToken,
5530
+ // async wrapper normalizes the sync/async union from AuthenticationStrategy.getAuthHeaders
5531
+ async () => boundGetAuthHeaders(),
5532
+ { HTTPHost: apiBaseUrl },
5533
+ config.host?.name,
5534
+ shouldUseCDN,
5535
+ config.validateRequestSchema
5536
+ );
5520
5537
  } else if (isObject(modules)) {
5521
5538
  return Object.fromEntries(Object.entries(modules).map(([key, value]) => {
5522
5539
  return [key, use(value, modules[PUBLIC_METADATA_KEY])];
@@ -4278,7 +4278,7 @@ var init_browser = __esm({
4278
4278
  // ../../node_modules/@wix/sdk-context/build/browser/index.mjs
4279
4279
  var wixContext = {};
4280
4280
 
4281
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-types/build/browser/index.mjs
4281
+ // ../../node_modules/@wix/sdk-types/build/browser/index.mjs
4282
4282
  function EventDefinition(type, isDomainEvent = false, transformations = (x) => x) {
4283
4283
  return () => ({
4284
4284
  __type: "event-definition",
@@ -4447,7 +4447,7 @@ function objectToKeyValue(input) {
4447
4447
  return Object.entries(input).filter(([_, value]) => Boolean(value)).map(([key, value]) => `${key}=${value}`).join(",");
4448
4448
  }
4449
4449
 
4450
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/context.js
4450
+ // ../../node_modules/@wix/sdk-runtime/build/context.js
4451
4451
  function runWithoutContext(fn) {
4452
4452
  const globalContext = globalThis.__wix_context__;
4453
4453
  const moduleContext = {
@@ -4479,14 +4479,14 @@ function runWithoutContext(fn) {
4479
4479
  }
4480
4480
  }
4481
4481
 
4482
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/constants.js
4482
+ // ../../node_modules/@wix/sdk-runtime/build/constants.js
4483
4483
  var RESTResponseToSDKResponseRenameMap = {
4484
4484
  id: "_id",
4485
4485
  createdDate: "_createdDate",
4486
4486
  updatedDate: "_updatedDate"
4487
4487
  };
4488
4488
 
4489
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/utils.js
4489
+ // ../../node_modules/@wix/sdk-runtime/build/utils.js
4490
4490
  function constantCase(input) {
4491
4491
  return split(input).map((part) => part.toLocaleUpperCase()).join("_");
4492
4492
  }
@@ -4512,7 +4512,7 @@ function split(value) {
4512
4512
  return result.slice(start, end).split(/\0/g);
4513
4513
  }
4514
4514
 
4515
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/transform-error.js
4515
+ // ../../node_modules/@wix/sdk-runtime/build/transform-error.js
4516
4516
  var isValidationError = (httpClientError) => "validationError" in (httpClientError.response?.data?.details ?? {});
4517
4517
  var isApplicationError = (httpClientError) => "applicationError" in (httpClientError.response?.data?.details ?? {});
4518
4518
  var isClientError = (httpClientError) => (httpClientError.response?.status ?? -1) >= 400 && (httpClientError.response?.status ?? -1) < 500;
@@ -4668,7 +4668,7 @@ var getArgumentIndex = (s) => {
4668
4668
  };
4669
4669
 
4670
4670
  // ../../node_modules/@wix/sdk/build/rest-modules.js
4671
- function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
4671
+ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, getAuthHeaders, options, hostName, useCDN, validateRequestSchema) {
4672
4672
  return runWithoutContext(() => origFunc({
4673
4673
  request: async (factory) => {
4674
4674
  const requestOptions = factory({
@@ -4701,7 +4701,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler,
4701
4701
  dataError = await res.json();
4702
4702
  } catch (e) {
4703
4703
  }
4704
- const error = errorBuilder2(res.status, dataError?.message, dataError?.details, {
4704
+ const error = errorBuilder2(res.status, dataError?.message ?? res.statusText, dataError?.details, {
4705
4705
  requestId: res.headers.get("X-Wix-Request-Id"),
4706
4706
  details: dataError
4707
4707
  });
@@ -4738,8 +4738,9 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler,
4738
4738
  },
4739
4739
  fetchWithAuth: boundFetch,
4740
4740
  wixAPIFetch,
4741
- getActiveToken
4742
- }));
4741
+ getActiveToken,
4742
+ getAuthHeaders
4743
+ }, { validateRequestSchema }));
4743
4744
  }
4744
4745
  var SDKError = class extends Error {
4745
4746
  response;
@@ -4772,7 +4773,7 @@ var errorBuilder2 = (code, description, details, data) => {
4772
4773
  });
4773
4774
  };
4774
4775
 
4775
- // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/rest-modules.js
4776
+ // ../../node_modules/@wix/sdk-runtime/build/rest-modules.js
4776
4777
  var DOMAINS = ["wix.com", "editorx.com"];
4777
4778
  var REGEX_CAPTURE_DOMAINS = new RegExp(`\\.(${DOMAINS.join("|")})$`);
4778
4779
  var WIX_API_DOMAINS = ["42.wixprod.net", "uw2-edt-1.wixprod.net"];
@@ -5005,7 +5006,7 @@ function camelCase(str) {
5005
5006
  return str.replace(/[-_\s]+(.)?/g, (_, c) => c ? c.toUpperCase() : "").replace(/^./, (c) => c.toLowerCase());
5006
5007
  }
5007
5008
 
5008
- // ../../node_modules/@wix/sdk/build/nanoevents.js
5009
+ // ../../node_modules/@wix/sdk-runtime/build/nanoevents.js
5009
5010
  function createNanoEvents() {
5010
5011
  return {
5011
5012
  emit(event, ...args) {
@@ -5263,7 +5264,9 @@ function createClient(config) {
5263
5264
  const boundGetAuthHeaders = () => {
5264
5265
  return getAuthStrategy().getAuthHeaders(config.host);
5265
5266
  };
5267
+ const getFetchFn = () => config.fetch ?? fetch;
5266
5268
  const fetchWithAuth = async (urlOrRequest, requestInit) => {
5269
+ const fetch2 = getFetchFn();
5267
5270
  const authHeaders = await boundGetAuthHeaders();
5268
5271
  const headers = {
5269
5272
  ...requestInit?.headers ?? {},
@@ -5274,7 +5277,7 @@ function createClient(config) {
5274
5277
  const errorHandler = config.host?.getErrorHandler?.();
5275
5278
  try {
5276
5279
  if (typeof urlOrRequest === "string" || urlOrRequest instanceof URL) {
5277
- const response = await fetch(urlOrRequest, {
5280
+ const response = await fetch2(urlOrRequest, {
5278
5281
  ...requestInit,
5279
5282
  headers
5280
5283
  });
@@ -5295,7 +5298,7 @@ function createClient(config) {
5295
5298
  urlOrRequest.headers.set(k, v);
5296
5299
  }
5297
5300
  }
5298
- const response = await fetch(urlOrRequest, requestInit);
5301
+ const response = await fetch2(urlOrRequest, requestInit);
5299
5302
  errorHandler?.handleError(response, {
5300
5303
  requestOptions: {
5301
5304
  url: urlOrRequest.url,
@@ -5321,9 +5324,10 @@ function createClient(config) {
5321
5324
  const { client: servicePluginsClient, initModule: initServicePluginModule } = servicePluginsModules(getAuthStrategy);
5322
5325
  const { client: eventHandlersClient, initModule: initEventHandlerModule } = eventHandlersModules(getAuthStrategy);
5323
5326
  const boundFetch = async (url, options) => {
5327
+ const fetch2 = getFetchFn();
5324
5328
  const authHeaders = await boundGetAuthHeaders();
5325
5329
  const defaultContentTypeHeader = getDefaultContentHeader(options);
5326
- const response = await fetch(url, {
5330
+ const response = await fetch2(url, {
5327
5331
  ...options,
5328
5332
  headers: {
5329
5333
  ...defaultContentTypeHeader,
@@ -5354,12 +5358,25 @@ function createClient(config) {
5354
5358
  }
5355
5359
  const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;
5356
5360
  const shouldUseCDN = config.useCDN === void 0 ? getAuthStrategy().shouldUseCDN : config.useCDN;
5357
- return buildRESTDescriptor(runWithoutContext(() => isAmbassadorModule(modules)) ? toHTTPModule(modules) : modules, metadata ?? {}, boundFetch, config.host?.getErrorHandler?.(), (relativeUrl, fetchOptions) => {
5358
- const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);
5359
- finalUrl.host = apiBaseUrl;
5360
- finalUrl.protocol = "https";
5361
- return boundFetch(finalUrl.toString(), fetchOptions);
5362
- }, getAuthStrategy().getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name, shouldUseCDN);
5361
+ return buildRESTDescriptor(
5362
+ runWithoutContext(() => isAmbassadorModule(modules)) ? toHTTPModule(modules) : modules,
5363
+ metadata ?? {},
5364
+ boundFetch,
5365
+ config.host?.getErrorHandler?.(),
5366
+ (relativeUrl, fetchOptions) => {
5367
+ const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);
5368
+ finalUrl.host = apiBaseUrl;
5369
+ finalUrl.protocol = "https";
5370
+ return boundFetch(finalUrl.toString(), fetchOptions);
5371
+ },
5372
+ getAuthStrategy().getActiveToken,
5373
+ // async wrapper normalizes the sync/async union from AuthenticationStrategy.getAuthHeaders
5374
+ async () => boundGetAuthHeaders(),
5375
+ { HTTPHost: apiBaseUrl },
5376
+ config.host?.name,
5377
+ shouldUseCDN,
5378
+ config.validateRequestSchema
5379
+ );
5363
5380
  } else if (isObject(modules)) {
5364
5381
  return Object.fromEntries(Object.entries(modules).map(([key, value]) => {
5365
5382
  return [key, use(value, modules[PUBLIC_METADATA_KEY])];
package/build/index.js CHANGED
@@ -3,18 +3,18 @@ const require = _createRequire(import.meta.url);
3
3
  import {
4
4
  createI18nT,
5
5
  docsExtensionTypeSchema
6
- } from "./chunk-WYVW5PHI.js";
6
+ } from "./chunk-55DNERET.js";
7
7
  import {
8
8
  runCommand
9
- } from "./chunk-4GIMBKKW.js";
10
- import "./chunk-DGXIMCFR.js";
9
+ } from "./chunk-SRJIUE4M.js";
10
+ import "./chunk-R64KPCCU.js";
11
11
  import "./chunk-QBRIDBYB.js";
12
- import "./chunk-7HAIU4K4.js";
12
+ import "./chunk-SEYDUHF7.js";
13
13
  import {
14
14
  external_exports,
15
15
  package_default,
16
16
  require_react
17
- } from "./chunk-YMZIPZHW.js";
17
+ } from "./chunk-S3T3SC6X.js";
18
18
  import {
19
19
  __commonJS,
20
20
  __require,
@@ -3377,8 +3377,8 @@ var {
3377
3377
  // src/commands/build.ts
3378
3378
  init_esm_shims();
3379
3379
  var buildCommand = (services) => createCommand("build").action(async (_, command) => {
3380
- const { runCommand: runCommand2 } = await import("./render-command-UIOYAX3T.js");
3381
- const { build } = await import("./build-B4YPLLX5.js");
3380
+ const { runCommand: runCommand2 } = await import("./render-command-WQTNWLO4.js");
3381
+ const { build } = await import("./build-PPQCMKBB.js");
3382
3382
  await runCommand2(command, services, build);
3383
3383
  });
3384
3384
 
@@ -3443,8 +3443,8 @@ var devCommand = (services) => {
3443
3443
  return createCommand("dev").option("-s, --https", t("dev_command_def.option.https")).option("--port <port>", t("dev_command_def.option.port"), validatePort).addOption(
3444
3444
  new Option("--origin <url>", t("dev_command_def.option.origin")).argParser(validateBase).hideHelp()
3445
3445
  ).action(async (options, command) => {
3446
- const { DevCommand } = await import("./DevCommand-JISHSNMA.js");
3447
- const { renderCommand } = await import("./render-command-UIOYAX3T.js");
3446
+ const { DevCommand } = await import("./DevCommand-TZJTHEPK.js");
3447
+ const { renderCommand } = await import("./render-command-WQTNWLO4.js");
3448
3448
  const { https = false, origin, port } = options;
3449
3449
  await renderCommand(
3450
3450
  command,
@@ -3483,17 +3483,17 @@ var previewCommand = (services) => {
3483
3483
  ).hideHelp()
3484
3484
  ).action(async (options, command) => {
3485
3485
  const { site, baseUrl, json } = options;
3486
- const { renderCommand, runCommand: runCommand2 } = await import("./render-command-UIOYAX3T.js");
3486
+ const { renderCommand, runCommand: runCommand2 } = await import("./render-command-WQTNWLO4.js");
3487
3487
  if (json) {
3488
3488
  return runCommand2(command, services, async (model) => {
3489
- const { nonInteractivePreview } = await import("./preview-LENPSE2T.js");
3489
+ const { nonInteractivePreview } = await import("./preview-LP2UHCWT.js");
3490
3490
  return nonInteractivePreview(services, model, {
3491
3491
  baseUrl,
3492
3492
  siteId: site
3493
3493
  });
3494
3494
  });
3495
3495
  }
3496
- const { PreviewCommand } = await import("./PreviewCommand-5PHGFLEJ.js");
3496
+ const { PreviewCommand } = await import("./PreviewCommand-7XEF25NL.js");
3497
3497
  await renderCommand(
3498
3498
  command,
3499
3499
  services,
@@ -3510,8 +3510,8 @@ var addPermissionCommand = (services) => {
3510
3510
  return createCommand("add-permission").description("adding a permission to the app").addOption(
3511
3511
  new Option("-p, --permission-id <id>", t("the permission id to add"))
3512
3512
  ).action(async (options, command) => {
3513
- const { renderCommand } = await import("./render-command-UIOYAX3T.js");
3514
- const { AddPermissionCommand } = await import("./AddPermissionCommand-6Z6GRQEW.js");
3513
+ const { renderCommand } = await import("./render-command-WQTNWLO4.js");
3514
+ const { AddPermissionCommand } = await import("./AddPermissionCommand-TKH4IDGY.js");
3515
3515
  const { permissionId = "" } = options;
3516
3516
  await renderCommand(
3517
3517
  command,
@@ -3527,8 +3527,8 @@ var import_react4 = __toESM(require_react(), 1);
3527
3527
  var serveCommand = (services) => {
3528
3528
  const t = createI18nT();
3529
3529
  return createCommand("serve").description(t("serve_command_def.description")).action(async (_, command) => {
3530
- const { renderCommand } = await import("./render-command-UIOYAX3T.js");
3531
- const { ServeCommandDeprecated } = await import("./ServeCommand-3O5KYQJ4.js");
3530
+ const { renderCommand } = await import("./render-command-WQTNWLO4.js");
3531
+ const { ServeCommandDeprecated } = await import("./ServeCommand-CA446OFI.js");
3532
3532
  await renderCommand(command, services, /* @__PURE__ */ import_react4.default.createElement(ServeCommandDeprecated, null));
3533
3533
  });
3534
3534
  };
@@ -3543,8 +3543,8 @@ var generateCommand = (services) => {
3543
3543
  t("generate_command.type_flag"),
3544
3544
  validateDocsExtensionType
3545
3545
  ).description(t("generate_command.description")).action(async (options, command) => {
3546
- const { GenerateCommand } = await import("./GenerateCommand-MOA7RGTI.js");
3547
- const { renderCommand } = await import("./render-command-UIOYAX3T.js");
3546
+ const { GenerateCommand } = await import("./GenerateCommand-ATQX2HLT.js");
3547
+ const { renderCommand } = await import("./render-command-WQTNWLO4.js");
3548
3548
  const { type } = options;
3549
3549
  await renderCommand(
3550
3550
  command,
@@ -3568,8 +3568,8 @@ var logsCommand = (services) => {
3568
3568
  validateVersion
3569
3569
  ).action(async (options, command) => {
3570
3570
  const { version } = options;
3571
- const { renderCommand } = await import("./render-command-UIOYAX3T.js");
3572
- const { LogsCommand } = await import("./LogsCommand-5GVCCIZR.js");
3571
+ const { renderCommand } = await import("./render-command-WQTNWLO4.js");
3572
+ const { LogsCommand } = await import("./LogsCommand-MGMPNTF6.js");
3573
3573
  await renderCommand(command, services, /* @__PURE__ */ import_react6.default.createElement(LogsCommand, { version }));
3574
3574
  });
3575
3575
  };
@@ -3602,8 +3602,8 @@ var releaseCommand = (services) => {
3602
3602
  t("app_preview_command_def.option.json")
3603
3603
  ).hideHelp()
3604
3604
  ).action(async (options, command) => {
3605
- const { renderCommand } = await import("./render-command-UIOYAX3T.js");
3606
- const { ReleaseCommand, ReleaseVersionType } = await import("./ReleaseCommand-PEVBP6RK.js");
3605
+ const { renderCommand } = await import("./render-command-WQTNWLO4.js");
3606
+ const { ReleaseCommand, ReleaseVersionType } = await import("./ReleaseCommand-QDZQCDD2.js");
3607
3607
  const { baseUrl, site, comment, json } = options;
3608
3608
  const versionType = options.versionType ? {
3609
3609
  major: ReleaseVersionType.MAJOR,
@@ -3617,7 +3617,7 @@ var releaseCommand = (services) => {
3617
3617
  };
3618
3618
  if (json) {
3619
3619
  return runCommand(command, services, async (model) => {
3620
- const { nonInteractiveRelease } = await import("./release-PAYLWX7K.js");
3620
+ const { nonInteractiveRelease } = await import("./release-NHG5YKSE.js");
3621
3621
  return nonInteractiveRelease(services, model, props);
3622
3622
  });
3623
3623
  }
@@ -0,0 +1,2 @@
1
+ import{a as I,b as O}from"./chunk-TONDB6MX.js";import{a as C,b as j,d as q}from"./chunk-UTEFPCPF.js";import{f as y}from"./chunk-SBZEOPXX.js";q();import{wixContext as de}from"@wix/sdk-context";var ue=e=>{switch(e){case"get":case"GET":return"GET";case"post":case"POST":return"POST";case"put":case"PUT":return"PUT";case"delete":case"DELETE":return"DELETE";case"patch":case"PATCH":return"PATCH";case"head":case"HEAD":return"HEAD";case"options":case"OPTIONS":return"OPTIONS";default:throw new Error(`Unknown method: ${e}`)}},W=e=>t=>async r=>{let n,s=o=>{if(n=e(r)(o),n.url===void 0)throw new Error("Url was not successfully created for this request, please reach out to support channels for assistance.");let{method:a,url:i,params:c}=n;return{...n,method:ue(a),url:i,data:n.data,params:c}};try{let o=await t.request(s);if(n===void 0)throw new Error("Request options were not created for this request, please reach out to support channels for assistance.");let a=Array.isArray(n.transformResponse)?n.transformResponse:[n.transformResponse],i=o.data;return a.forEach(c=>{c&&(i=c(o.data,o.headers))}),i}catch(o){throw typeof o=="object"&&o!==null&&"response"in o&&typeof o.response=="object"&&o.response!==null&&"data"in o.response?o.response.data:o}},B=e=>e.__isAmbassador?!0:!!e().__isAmbassador;var K="__metadata",R="www.wixapis.com",J="edge.wixapis.com";var S=class extends Error{constructor(r,n){super(r);y(this,"message");y(this,"response");this.message=r,this.response=n}async details(){let r=await this.response.json();return le(this.response.status,r?.message,r?.details,{requestId:this.response.headers.get("X-Wix-Request-Id"),details:r})}},le=(e,t,r,n)=>({details:{...!r?.validationError&&{applicationError:{description:t,code:e,data:n}},...r},message:t,requestId:n?.requestId});var k=e=>e?.method&&["post","put","patch"].includes(e.method.toLocaleLowerCase())&&e.body?{"Content-Type":"application/json"}:{},G=e=>e&&typeof e=="object"&&!Array.isArray(e);var X=e=>e.__type==="host";function Y(e,t){return e.create(t)}var pe="x-wix-bi-gateway";function z(e,t,r){return{[pe]:fe({environment:`js-sdk${r?`-${r}`:""}`,"package-name":e.packageName??t?.PACKAGE_NAME,"method-fqn":e.methodFqn,entity:e.entityFqdn})}}function fe(e){return Object.entries(e).filter(([t,r])=>!!r).map(([t,r])=>`${t}=${r}`).join(",")}function v(e){return Te(e).map(t=>t.toLocaleUpperCase()).join("_")}var he=/([\p{Ll}\d])(\p{Lu})/gu,me=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,Q="$1\0$2",Ee=/[^\p{L}\d]+/giu;function Te(e){let t=e.trim();t=t.replace(he,Q).replace(me,Q),t=t.replace(Ee,"\0");let r=0,n=t.length;for(;t.charAt(r)==="\0";)r++;if(r===n)return[];for(;t.charAt(n-1)==="\0";)n--;return t.slice(r,n).split(/\0/g)}var ye=e=>"validationError"in(e.response?.data?.details??{}),_e=e=>"applicationError"in(e.response?.data?.details??{}),ge=e=>(e.response?.status??-1)>=400&&(e.response?.status??-1)<500;function Z(e,t={explicitPathsToArguments:{},spreadPathsToArguments:{},singleArgumentUnchanged:!1},r=[]){if(typeof e!="object"||e===null)throw e;if(ye(e))return Ae(e,t,r);if(_e(e))return Pe(e);if(ge(e)){let n=e.response?.status,s=e.response?.statusText??"UNKNOWN",o=e.response?.data?.message??s,a={applicationError:{description:s,code:v(s),data:{}},requestId:e.requestId};return L(e,{message:JSON.stringify({message:o,details:a},null,2),extraProperties:{details:a,status:n}})}return we(e)}var Ae=(e,t,r)=>{let n=e.response?.data,s=e.requestId,{fieldViolations:o}=n.details.validationError,a=xe(t,o,r)?.sort((u,p)=>u.field<p.field?-1:1),i=`INVALID_ARGUMENT: ${a?.map(({field:u,description:p})=>`"${u}" ${p}`)?.join(", ")}`,c={validationError:{fieldViolations:a},requestId:s};return L(e,{message:JSON.stringify({message:i,details:c},null,2),extraProperties:{details:c,status:e.response?.status,requestId:s}})},L=(e,{message:t,extraProperties:r})=>Object.assign(e,{...r,message:t}),Pe=e=>{let t=e.response?.status,r=e.response?.statusText??"UNKNOWN",n=e.response?.data?.message??r,s=e.response?.data?.details?.applicationError?.description??r,o=e.response?.data?.details?.applicationError?.code??v(r),a=e.response?.data?.details?.applicationError?.data??{},i=n===s?n:`${n}: ${s}`,c={applicationError:{description:s,code:o,data:a},requestId:e.requestId};return L(e,{message:JSON.stringify({message:i,details:c},null,2),extraProperties:{details:c,status:t,requestId:e.requestId}})},we=e=>{let t=e.requestId?`System error occurred, request-id: ${e.requestId}`:`System error occurred: ${JSON.stringify(e)}`;return L(e,{message:t,extraProperties:{requestId:e.requestId,status:e.response?.status,code:v(e.response?.statusText??"UNKNOWN"),...!e.response&&{runtimeError:e}}})},xe=({spreadPathsToArguments:e,explicitPathsToArguments:t,singleArgumentUnchanged:r},n,s)=>{let o={...e,...t},a=Object.keys(o);return n?.filter(i=>!n.some(u=>u.field.length>i.field.length&&u.field.startsWith(i.field)&&a.includes(u.field))).map(i=>{let c=t[i.field];if(c)return{...i,field:V(c,s)};let u=a?.sort((p,E)=>E.length-p.length)?.find(p=>i.field.startsWith(p));if(u){let p=o[u];if(p)return{...i,field:i.field.replace(u,V(p,s))}}return r?{...i,field:`${s[0]}.${i.field}`}:i})},V=(e,t)=>{let r=Re(e);return r!==null&&typeof r<"u"?e.replace(`$[${r}]`,t[r]):e},Re=e=>{let t=e.match(/\$\[(?<argIndex>\d+)\]/);return t&&t.groups&&Number(t.groups.argIndex)};function ee(e,t,r,n,s,o,a,i,c,u,p){return I(()=>e({request:async E=>{let T=E({host:i?.HTTPHost||R}),l=T;l.method==="GET"&&l.fallback?.length&&(l.params?.toString().length??0)>4e3&&(l=T.fallback[0]);let P=i?.HTTPHost??R,H=`https://${u?J:P}${l.url}`;l.params&&l.params.toString()&&(H+=`?${l.params.toString()}`);try{let d=z(T,t,c),f={method:l.method,...l.data&&{body:JSON.stringify(l.data)},headers:{...d}},h=await r(H,f);if(h.status!==200){let g=null;try{g=await h.json()}catch{}let m=be(h.status,g?.message??h.statusText,g?.details,{requestId:h.headers.get("X-Wix-Request-Id"),details:g}),x=Z(m);throw n?.handleError(x,{requestOptions:{url:l.url,method:l.method,entityFqdn:T.entityFqdn,methodFqn:T.methodFqn}}),m}let _=await h.json();return{data:l.migrationOptions?.optInTransformResponse&&l.transformResponse?Array.isArray(l.transformResponse)?l.transformResponse[0](_):l.transformResponse(_):_,headers:h.headers,status:h.status,statusText:h.statusText}}catch(d){throw d.message?.includes("fetch is not defined")&&console.error("Node.js v18+ is required"),d}},fetchWithAuth:r,wixAPIFetch:s,getActiveToken:o,getAuthHeaders:a},{validateRequestSchema:p}))}var D=class extends Error{constructor(r){super();y(this,"response");y(this,"requestId");this.response=r.response,this.requestId=r.requestId}},be=(e,t,r,n)=>new D({response:{data:{details:{...!r?.validationError&&{applicationError:{description:t,code:e,data:n}},...r},message:t},status:e},requestId:n?.requestId});q();var Ie=".";function te(e,t,r){if(e==null)throw new Error("Cannot set value on null or undefined");let n=N(t),s=e;for(let o=0;o<n.length;o++){let a=n[o];if(o===n.length-1){s[a]=r;break}let i=n[o+1];!(a in s)||s[a]==null?s[a]=typeof i=="number"?[]:{}:(typeof s[a]!="object"||s[a]===null)&&(s[a]=typeof i=="number"?[]:{}),s=s[a]}return e}function N(e){return Array.isArray(e)?e:e.split(Ie).map(t=>Se(t)?Number(t):t)}function Se(e){return/^\d+$/.test(e)}function se(e){let t={};for(let[r,n]of Object.entries(e)){if(ve(r))continue;let s=N(r);te(t,s,n)}return t}function ve(e){return e==="__proto__"||e==="constructor"||e==="prototype"}var U=class{constructor(t){y(this,"BRACKET_PATTERN",/\[(\d+)\]/g);y(this,"NUMERIC_PATTERN",/^\d+$/);y(this,"ESCAPED_DOT_PATTERN",/\\\./g);y(this,"ESCAPED_LEFT_BRACKET_PATTERN",/\\\[/g);y(this,"ESCAPED_RIGHT_BRACKET_PATTERN",/\\\]/g);y(this,"SPLIT_PATTERN",/\.|\[(\d+)\]/g);y(this,"DOT_BEFORE_BRACKET_PATTERN",/\.\[/g);y(this,"ESCAPED_DOT_PLACEHOLDER","__DOT__");y(this,"ESCAPED_RIGHT_BRACKET_PLACEHOLDER","__RB__");y(this,"ESCAPED_LEFT_BRACKET_PLACEHOLDER","__LB__");y(this,"modifiedFields");y(this,"cleanedModifiedFields");this.modifiedFields=t}replaceEscapedCharacters(t){return t.replace(this.ESCAPED_DOT_PATTERN,this.ESCAPED_DOT_PLACEHOLDER).replace(this.ESCAPED_LEFT_BRACKET_PATTERN,this.ESCAPED_LEFT_BRACKET_PLACEHOLDER).replace(this.ESCAPED_RIGHT_BRACKET_PATTERN,this.ESCAPED_RIGHT_BRACKET_PLACEHOLDER)}restoreEscapedCharacters(t){return t.replace(this.ESCAPED_DOT_PLACEHOLDER,"\\.").replace(this.ESCAPED_RIGHT_BRACKET_PLACEHOLDER,"\\]").replace(this.ESCAPED_LEFT_BRACKET_PLACEHOLDER,"\\[")}unflatten(){return this.cleanedModifiedFields=Object.fromEntries(Object.entries(this.modifiedFields).map(([t,r])=>[this.replaceEscapedCharacters(this.bracketToDotNotation(t)),r])),se(this.cleanedModifiedFields)}flatten(t){let r={};for(let n of Object.keys(this.cleanedModifiedFields)){let s=this.splitPath(n),o=this.navigatePath(t,s);r={...r,...o}}return Object.fromEntries(Object.entries(r).map(([n,s])=>[this.restoreEscapedCharacters(n),s]))}splitPath(t){let r=[],n=0,s=Array.from(t.matchAll(this.SPLIT_PATTERN));for(let o of s)o.index>n&&r.push(t.substring(n,o.index)),o[1]&&r.push(o[1]),n=o.index+o[0].length;return n<t.length&&r.push(t.substring(n)),r}navigatePath(t,r){let n=t,s=[],o=c=>{if(!Array.isArray(n))throw new Error(`Expected array at path ${this.buildPathString(s)}, but got ${typeof n}`);s.push(`[${c}]`),n=n[parseInt(c,10)]},a=(c,u)=>{let p=c in O?O[c]:void 0;if(p&&p in u){s.push(p),n=u[p];return}let E=Ce(c);if(E&&E in u){s.push(E),n=u[E];return}throw new Error(`Cannot find key '${c}' or its transformations at path ${this.buildPathString(s)}`)},i=(c,u)=>{s.push(c),n=u[c]};for(let c of r){if(this.NUMERIC_PATTERN.test(c)){o(c);continue}if(n===null||typeof n!="object")throw new Error(`Cannot access property '${c}' on ${typeof n} at path ${this.buildPathString(s)}`);let u=n;if(c in n){i(c,u);continue}a(c,u)}return{[this.buildPathString(s)]:n}}buildPathString(t){return t.join(".").replace(this.DOT_BEFORE_BRACKET_PATTERN,"[")}bracketToDotNotation(t){return t.replace(this.BRACKET_PATTERN,(r,n,s)=>s>0&&t[s-1]==="\\"?r:"."+n)}};function re(e,t){let r=e?.modifiedFields;if(!r)return null;let n=Le(r);if(!n)return null;let{unflattenedModifiedFields:s,modifiedFieldsManipulator:o}=n;e={...e,modifiedFields:s};let a=t(e),i=a?.modifiedFields;if(!i)return null;let c=He(i,o);return c!==null?(a.modifiedFields=c,a):null}function Le(e){if(typeof e=="object"&&e!==null&&!Array.isArray(e))try{let t=new U(e);return{unflattenedModifiedFields:t.unflatten(),modifiedFieldsManipulator:t}}catch{return null}return null}function He(e,t){if(typeof e=="object"&&e!==null&&!Array.isArray(e))try{return t.flatten(e)}catch{return null}return null}function Ce(e){return e.replace(/[-_\s]+(.)?/g,(t,r)=>r?r.toUpperCase():"").replace(/^./,t=>t.toLowerCase())}function b(){return{emit(e,...t){for(let r=0,n=this.events[e]||[],s=n.length;r<s;r++)n[r](...t)},events:{},on(e,t){return(this.events[e]||=[]).push(t),()=>{this.events[e]=this.events[e]?.filter(r=>t!==r)}}}}var oe=e=>e.__type==="event-definition";function ne(e,t,r,n){let s;if(e.isDomainEvent){let c=r,{deletedEvent:u,actionEvent:p,createdEvent:E,updatedEvent:T,...l}=c,P={...n,...l};u?u?.deletedEntity?s={entity:u?.deletedEntity,metadata:P}:s={metadata:P}:p?s={data:p.body,metadata:P}:T?s={entity:T.currentEntity,metadata:P,...T.modifiedFields?{modifiedFields:T.modifiedFields}:{}}:s={entity:E?.entity,metadata:P}}else s={data:r,metadata:n};let o=e.transformations??(c=>c),a=s,i=s;if(i.modifiedFields){let c=i.modifiedFields;if(typeof c=="object"&&c!==null&&!Array.isArray(c)){a=structuredClone(s);let u=re(i,o);if(u)return t(u)}}return t(o(a))}function ae(e){let t=new Map,r=b(),n={...r,getRegisteredEvents:()=>t,async process(s,o={expectedEvents:[]}){let{eventType:a,identity:i,instanceId:c,payload:u,accountInfo:p}=await this.parseJWT(s),E=[...o.expectedEvents,...Array.from(t.keys()).map(l=>({type:l}))];if(E.length>0&&!E.some(({type:l})=>l===a))throw new Error(`Unexpected event type: ${a}. Expected one of: ${E.map(l=>l.type).join(", ")}`);let T=t.get(a)??[];return await Promise.all(T.map(({eventDefinition:l,handler:P})=>ne(l,P,u,{instanceId:c,identity:i,accountInfo:p}))),{instanceId:c,eventType:a,payload:u,identity:i,accountInfo:p}},async processRequest(s,o){let a=await s.text();return this.process(a,o)},async parseJWT(s){let o=e();if(!o.decodeJWT)throw new Error("decodeJWT is not supported by the authentication strategy");let{decoded:a,valid:i}=await o.decodeJWT(s);if(!i)throw new Error("JWT is not valid");if(typeof a.data!="string")throw new Error(`Unexpected type of JWT data: expected string, got ${typeof a.data}`);let c=JSON.parse(a.data),u=c.eventType,p=c.accountInfo,E=c.instanceId,T=c.identity?JSON.parse(c.identity):void 0,l=JSON.parse(c.data);return{instanceId:E,eventType:u,payload:l,identity:T,accountInfo:p}},async parseRequest(s){let o=await s.text();return this.parseJWT(o)},async executeHandlers(s){let o=Array.from(t.keys()).map(i=>({type:i}));if(o.length>0&&!o.some(({type:i})=>i===s.eventType))throw new Error(`Unexpected event type: ${s.eventType}. Expected one of: ${o.map(i=>i.type).join(", ")}`);let a=t.get(s.eventType)??[];await Promise.all(a.map(({eventDefinition:i,handler:c})=>ne(i,c,s.payload,{instanceId:s.instanceId,identity:s.identity})))},apps:{AppInstalled:C("AppInstalled")(),AppRemoved:C("AppRemoved")()}};return{initModule(s){return o=>{let a=t.get(s.type)??[];a.push({eventDefinition:s,handler:o}),t.set(s.type,a),r.emit("registered",s)}},client:n}}var ie=e=>e.__type==="service-plugin-definition";function ce(e){let t=new Map,r=b(),n={...r,getRegisteredServicePlugins:()=>t,async parseJWT(s){let o=e();if(!o.decodeJWT)throw new Error("decodeJWT is not supported by the authentication strategy");let{decoded:a,valid:i}=await o.decodeJWT(s,!0);if(!i)throw new Error("JWT is not valid");if(typeof a.data!="object"||a.data===null||!("metadata"in a.data)||typeof a.data.metadata!="object"||a.data.metadata===null||!("appExtensionType"in a.data.metadata)||typeof a.data.metadata.appExtensionType!="string")throw new Error("Unexpected JWT data: expected object with metadata.appExtensionType string");return a.data},async process(s){let o=await this.parseJWT(s.body);return this.executeHandler(o,s.url)},async parseRequest(s){let o=await s.text();return this.parseJWT(o)},async processRequest(s){let o=s.url,a=await s.text();try{let i=await this.process({url:o,body:a});return Response.json(i)}catch(i){if(i.errorType==="SPI"&&i.applicationCode&&i.httpCode)return Response.json({applicationError:{code:i.applicationCode,data:i.data}},{status:i.httpCode});throw i}},async executeHandler(s,o){let a=s.metadata.appExtensionType.toLowerCase(),i=t.get(a)??[];if(i.length===0)throw new Error(`No service plugin implementations found for component type ${a}`);if(i.length>1)throw new Error(`Multiple service plugin implementations found for component type ${a}. This is currently not supported`);let{implementation:c,servicePluginDefinition:u}=i[0],p=u.methods.find(T=>o.endsWith(T.primaryHttpMappingPath));if(!p)throw new Error("Unexpect request: request url did not match any method: "+o);let E=c[p.name];if(!E)throw new Error(`Got request for service plugin method ${p.name} but no implementation was provided. Available methods: ${Object.keys(c).join(", ")}`);return p.transformations.toREST(await E(p.transformations.fromREST(s)))}};return{initModule(s){return o=>{let a=t.get(s.componentType.toLowerCase())??[];a.push({servicePluginDefinition:s,implementation:o}),t.set(s.componentType.toLowerCase(),a),r.emit("registered",s)}},client:n}}var w="X-Wix-Consistent";function Pt(e){let t=e.headers||{Authorization:""},r={getAuthHeaders:d=>Promise.resolve({headers:{}})},n=e.auth,s=typeof n=="function"?n:()=>n??r,o=()=>s().getAuthHeaders(e.host),a=()=>e.fetch??fetch,i=async(d,f)=>{let h=a(),_=await o(),A={...f?.headers??{},..._.headers,...e.host?.essentials?.passThroughHeaders,...t[w]?{[w]:t[w]}:{}},g=e.host?.getErrorHandler?.();try{if(typeof d=="string"||d instanceof URL){let m=await h(d,{...f,headers:A});g?.handleError(m,{requestOptions:{url:d.toString(),method:f?.method}});let x=M(m);return x&&(t[w]=x),m}else{for(let[$,F]of Object.entries(A))typeof F=="string"&&d.headers.set($,F);let m=await h(d,f);g?.handleError(m,{requestOptions:{url:d.url,method:f?.method}});let x=M(m);return x&&(t[w]=x),m}}catch(m){throw g?.handleError(m,{requestOptions:{url:typeof d=="string"||d instanceof URL?d.toString():d.url,method:f?.method}}),m}},{client:c,initModule:u}=ce(s),{client:p,initModule:E}=ae(s),T=async(d,f)=>{let h=a(),_=await o(),A=k(f),g=await h(d,{...f,headers:{...A,...t,..._?.headers,...f?.headers,...e.host?.essentials?.passThroughHeaders,...t[w]?{[w]:t[w]}:{}}}),m=M(g);return m&&(t[w]=m),g},l=(d,f)=>{if(oe(d))return E(d);if(ie(d))return u(d);if(X(d)&&e.host)return Y(d,e.host);if(typeof d=="function"){if("__type"in d&&d.__type===j)return d;let h=e.host?.apiBaseUrl??R,_=e.useCDN===void 0?s().shouldUseCDN:e.useCDN;return ee(I(()=>B(d))?W(d):d,f??{},T,e.host?.getErrorHandler?.(),(A,g)=>{let m=new URL(A,`https://${h}`);return m.host=h,m.protocol="https",T(m.toString(),g)},s().getActiveToken,async()=>o(),{HTTPHost:h},e.host?.name,_,e.validateRequestSchema)}else return G(d)?Object.fromEntries(Object.entries(d).map(([h,_])=>[h,l(_,d[K])])):d},P=d=>{for(let f in d)t[f]=d[f]};return{...e.modules?l(e.modules):{},get auth(){let d=s(),f=d.getAuthHeaders;return d.getAuthHeaders=f.bind(void 0,e.host),d},setHeaders:P,use:l,enableContext(d,f={elevated:!1}){d==="global"?globalThis.__wix_context__!=null?f.elevated?globalThis.__wix_context__.elevatedClient=this:globalThis.__wix_context__.client=this:f.elevated?globalThis.__wix_context__={elevatedClient:this}:globalThis.__wix_context__={client:this}:f.elevated?de.elevatedClient=this:de.client=this},fetch:(d,f)=>{let h=e.host?.apiBaseUrl??R,_=new URL(d,`https://${h}`);return _.host=h,_.protocol="https",T(_.toString(),f)},fetchWithAuth:i,async graphql(d,f,h={apiVersion:"alpha"}){let _=e?.host?.apiBaseUrl??R,A=await T(`https://${_}/graphql/${h.apiVersion}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:d,variables:f})});if(A.status!==200)throw new S(`GraphQL request failed with status ${A.status}`,A);let{data:g,errors:m}=await A.json();return{data:g??{},errors:m}},webhooks:p,servicePlugins:c}}function M(e){return e.headers?.get(w)??e.headers?.get(w.toLowerCase())}export{Pt as a};
2
+ //# sourceMappingURL=chunk-2QLMI2GU.js.map