@wix/cli-app 1.1.107 → 1.1.108

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 (84) hide show
  1. package/build/{AddPermissionCommand-7E5GD5VD.js → AddPermissionCommand-W3TQTL3X.js} +2 -2
  2. package/build/{DevCommand-BWRRKEE6.js → DevCommand-3HZJQQIQ.js} +10 -10
  3. package/build/{DevCommand-BWRRKEE6.js.map → DevCommand-3HZJQQIQ.js.map} +1 -1
  4. package/build/{GenerateCommand-IO6ENBOG.js → GenerateCommand-UQ3JHQTJ.js} +47 -8
  5. package/build/GenerateCommand-UQ3JHQTJ.js.map +1 -0
  6. package/build/{LogsCommand-C62QNN65.js → LogsCommand-JHADSYUE.js} +3 -3
  7. package/build/PreviewCommand-WBQRDP7K.js +19 -0
  8. package/build/ReleaseCommand-3KDJB3KZ.js +23 -0
  9. package/build/{ServeCommand-NDUXIY75.js → ServeCommand-IPKP6PJ2.js} +3 -3
  10. package/build/{build-ZO7CXGLN.js → build-LZ3CJXNM.js} +6 -6
  11. package/build/{chunk-EC7IFTLG.js → chunk-6OQZW27N.js} +8 -2
  12. package/build/{chunk-EC7IFTLG.js.map → chunk-6OQZW27N.js.map} +1 -1
  13. package/build/{chunk-PSN6WZCB.js → chunk-7KESMWRI.js} +13 -7
  14. package/build/{chunk-PSN6WZCB.js.map → chunk-7KESMWRI.js.map} +1 -1
  15. package/build/{chunk-77PR2TSF.js → chunk-BER5YRAG.js} +2 -2
  16. package/build/{chunk-7B3P7MZT.js → chunk-FO7ABKNR.js} +3 -3
  17. package/build/{chunk-HNIJZROR.js → chunk-HAUIN5OS.js} +6 -6
  18. package/build/{chunk-657KFISY.js → chunk-IGC7QYU5.js} +2 -2
  19. package/build/{chunk-HJXYDXED.js → chunk-LOVLYP4H.js} +5 -5
  20. package/build/{chunk-VV6PV2NF.js → chunk-LWOWN5OI.js} +5 -5
  21. package/build/{chunk-6X7N6N75.js → chunk-MAZMH6ES.js} +6 -6
  22. package/build/{chunk-TZ37SYKU.js → chunk-OKHXUGGH.js} +2 -2
  23. package/build/{chunk-5ZI5USPK.js → chunk-PBROWK34.js} +8 -1
  24. package/build/{chunk-5ZI5USPK.js.map → chunk-PBROWK34.js.map} +1 -1
  25. package/build/{chunk-EH63OURU.js → chunk-PFAJ5ETM.js} +2 -2
  26. package/build/{chunk-AKBVXZXO.js → chunk-RDXTHRJ4.js} +14 -2
  27. package/build/{chunk-AKBVXZXO.js.map → chunk-RDXTHRJ4.js.map} +1 -1
  28. package/build/{chunk-VJAMKDBT.js → chunk-UEUJOHB4.js} +3 -3
  29. package/build/{chunk-OSDDOY2U.js → chunk-UN2TQTOP.js} +156 -10
  30. package/build/{chunk-OSDDOY2U.js.map → chunk-UN2TQTOP.js.map} +1 -1
  31. package/build/{chunk-GFXZXRO4.js → chunk-UPQ6AZFY.js} +2 -2
  32. package/build/{chunk-VCFM6SMQ.js → chunk-W5SE5OVE.js} +123 -7
  33. package/build/{chunk-VCFM6SMQ.js.map → chunk-W5SE5OVE.js.map} +1 -1
  34. package/build/{chunk-MK5OQBNN.js → chunk-Z4NG6X6T.js} +2 -2
  35. package/build/cloudflare-runtime/entry.js +256 -32
  36. package/build/cloudflare-runtime/getRegisteredExtensions.js +252 -28
  37. package/build/index.js +24 -24
  38. package/build/platform-sdk/chunk-J3SVE4GM.js +2 -0
  39. package/build/platform-sdk/chunk-J3SVE4GM.js.map +1 -0
  40. package/build/platform-sdk/chunk-J7RIIVO6.js +2 -0
  41. package/build/platform-sdk/chunk-J7RIIVO6.js.map +1 -0
  42. package/build/platform-sdk/chunk-RHDUKNAJ.js +2 -0
  43. package/build/platform-sdk/chunk-RHDUKNAJ.js.map +1 -0
  44. package/build/platform-sdk/dashboard.js +1 -1
  45. package/build/platform-sdk/dashboard.js.map +1 -1
  46. package/build/platform-sdk/editor.js +2 -2
  47. package/build/platform-sdk/editor.js.map +1 -1
  48. package/build/platform-sdk/sdk-context.js +1 -1
  49. package/build/platform-sdk/sdk-context.js.map +1 -1
  50. package/build/platform-sdk/site.js +1 -1
  51. package/build/{preview-ZGAFDUGX.js → preview-OVNN2RP4.js} +13 -13
  52. package/build/{release-YOEGOFAT.js → release-OMLRH2VC.js} +15 -15
  53. package/build/{render-command-FI2MU2Z5.js → render-command-DIMIKL4B.js} +6 -6
  54. package/package.json +6 -6
  55. package/build/GenerateCommand-IO6ENBOG.js.map +0 -1
  56. package/build/PreviewCommand-YAYKKYRN.js +0 -19
  57. package/build/ReleaseCommand-77SWCHH2.js +0 -23
  58. package/build/platform-sdk/chunk-BBFFXVJD.js +0 -2
  59. package/build/platform-sdk/chunk-BBFFXVJD.js.map +0 -1
  60. package/build/platform-sdk/chunk-MAZR75DI.js +0 -2
  61. package/build/platform-sdk/chunk-MAZR75DI.js.map +0 -1
  62. package/build/platform-sdk/chunk-NHYZDMR5.js +0 -2
  63. package/build/platform-sdk/chunk-NHYZDMR5.js.map +0 -1
  64. /package/build/{AddPermissionCommand-7E5GD5VD.js.map → AddPermissionCommand-W3TQTL3X.js.map} +0 -0
  65. /package/build/{LogsCommand-C62QNN65.js.map → LogsCommand-JHADSYUE.js.map} +0 -0
  66. /package/build/{PreviewCommand-YAYKKYRN.js.map → PreviewCommand-WBQRDP7K.js.map} +0 -0
  67. /package/build/{ReleaseCommand-77SWCHH2.js.map → ReleaseCommand-3KDJB3KZ.js.map} +0 -0
  68. /package/build/{ServeCommand-NDUXIY75.js.map → ServeCommand-IPKP6PJ2.js.map} +0 -0
  69. /package/build/{build-ZO7CXGLN.js.map → build-LZ3CJXNM.js.map} +0 -0
  70. /package/build/{chunk-77PR2TSF.js.map → chunk-BER5YRAG.js.map} +0 -0
  71. /package/build/{chunk-7B3P7MZT.js.map → chunk-FO7ABKNR.js.map} +0 -0
  72. /package/build/{chunk-HNIJZROR.js.map → chunk-HAUIN5OS.js.map} +0 -0
  73. /package/build/{chunk-657KFISY.js.map → chunk-IGC7QYU5.js.map} +0 -0
  74. /package/build/{chunk-HJXYDXED.js.map → chunk-LOVLYP4H.js.map} +0 -0
  75. /package/build/{chunk-VV6PV2NF.js.map → chunk-LWOWN5OI.js.map} +0 -0
  76. /package/build/{chunk-6X7N6N75.js.map → chunk-MAZMH6ES.js.map} +0 -0
  77. /package/build/{chunk-TZ37SYKU.js.map → chunk-OKHXUGGH.js.map} +0 -0
  78. /package/build/{chunk-EH63OURU.js.map → chunk-PFAJ5ETM.js.map} +0 -0
  79. /package/build/{chunk-VJAMKDBT.js.map → chunk-UEUJOHB4.js.map} +0 -0
  80. /package/build/{chunk-GFXZXRO4.js.map → chunk-UPQ6AZFY.js.map} +0 -0
  81. /package/build/{chunk-MK5OQBNN.js.map → chunk-Z4NG6X6T.js.map} +0 -0
  82. /package/build/{preview-ZGAFDUGX.js.map → preview-OVNN2RP4.js.map} +0 -0
  83. /package/build/{release-YOEGOFAT.js.map → release-OMLRH2VC.js.map} +0 -0
  84. /package/build/{render-command-FI2MU2Z5.js.map → render-command-DIMIKL4B.js.map} +0 -0
@@ -4438,7 +4438,7 @@ function objectToKeyValue(input) {
4438
4438
  return Object.entries(input).filter(([_, value]) => Boolean(value)).map(([key, value]) => `${key}=${value}`).join(",");
4439
4439
  }
4440
4440
 
4441
- // ../../node_modules/@wix/sdk-runtime/build/context.js
4441
+ // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/context.js
4442
4442
  function runWithoutContext(fn) {
4443
4443
  const globalContext = globalThis.__wix_context__;
4444
4444
  const moduleContext = {
@@ -4470,8 +4470,189 @@ function runWithoutContext(fn) {
4470
4470
  }
4471
4471
  }
4472
4472
 
4473
+ // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/utils.js
4474
+ function constantCase(input) {
4475
+ return split(input).map((part) => part.toLocaleUpperCase()).join("_");
4476
+ }
4477
+ var SPLIT_LOWER_UPPER_RE = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu");
4478
+ var SPLIT_UPPER_UPPER_RE = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu");
4479
+ var SPLIT_REPLACE_VALUE = "$1\0$2";
4480
+ var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
4481
+ function split(value) {
4482
+ let result = value.trim();
4483
+ result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
4484
+ result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
4485
+ let start = 0;
4486
+ let end = result.length;
4487
+ while (result.charAt(start) === "\0") {
4488
+ start++;
4489
+ }
4490
+ if (start === end) {
4491
+ return [];
4492
+ }
4493
+ while (result.charAt(end - 1) === "\0") {
4494
+ end--;
4495
+ }
4496
+ return result.slice(start, end).split(/\0/g);
4497
+ }
4498
+
4499
+ // ../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/transform-error.js
4500
+ var isValidationError = (httpClientError) => "validationError" in (httpClientError.response?.data?.details ?? {});
4501
+ var isApplicationError = (httpClientError) => "applicationError" in (httpClientError.response?.data?.details ?? {});
4502
+ var isClientError = (httpClientError) => (httpClientError.response?.status ?? -1) >= 400 && (httpClientError.response?.status ?? -1) < 500;
4503
+ function transformError(httpClientError, pathsToArguments = {
4504
+ explicitPathsToArguments: {},
4505
+ spreadPathsToArguments: {},
4506
+ singleArgumentUnchanged: false
4507
+ }, argumentNames = []) {
4508
+ if (typeof httpClientError !== "object" || httpClientError === null) {
4509
+ throw httpClientError;
4510
+ }
4511
+ if (isValidationError(httpClientError)) {
4512
+ return buildValidationError(httpClientError, pathsToArguments, argumentNames);
4513
+ }
4514
+ if (isApplicationError(httpClientError)) {
4515
+ return buildApplicationError(httpClientError);
4516
+ }
4517
+ if (isClientError(httpClientError)) {
4518
+ const status = httpClientError.response?.status;
4519
+ const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
4520
+ const message2 = httpClientError.response?.data?.message ?? statusText;
4521
+ const details = {
4522
+ applicationError: {
4523
+ description: statusText,
4524
+ code: constantCase(statusText),
4525
+ data: {}
4526
+ },
4527
+ requestId: httpClientError.requestId
4528
+ };
4529
+ return wrapError(httpClientError, {
4530
+ message: JSON.stringify({
4531
+ message: message2,
4532
+ details
4533
+ }, null, 2),
4534
+ extraProperties: {
4535
+ details,
4536
+ status
4537
+ }
4538
+ });
4539
+ }
4540
+ return buildSystemError(httpClientError);
4541
+ }
4542
+ var buildValidationError = (httpClientError, pathsToArguments, argumentNames) => {
4543
+ const validationErrorResponse = httpClientError.response?.data;
4544
+ const requestId = httpClientError.requestId;
4545
+ const { fieldViolations } = validationErrorResponse.details.validationError;
4546
+ const transformedFieldViolations = violationsWithRenamedFields(pathsToArguments, fieldViolations, argumentNames)?.sort((a, b) => a.field < b.field ? -1 : 1);
4547
+ const message2 = `INVALID_ARGUMENT: ${transformedFieldViolations?.map(({ field, description }) => `"${field}" ${description}`)?.join(", ")}`;
4548
+ const details = {
4549
+ validationError: { fieldViolations: transformedFieldViolations },
4550
+ requestId
4551
+ };
4552
+ return wrapError(httpClientError, {
4553
+ message: JSON.stringify({ message: message2, details }, null, 2),
4554
+ extraProperties: {
4555
+ details,
4556
+ status: httpClientError.response?.status,
4557
+ requestId
4558
+ }
4559
+ });
4560
+ };
4561
+ var wrapError = (baseError, { message: message2, extraProperties }) => {
4562
+ return Object.assign(baseError, {
4563
+ ...extraProperties,
4564
+ message: message2
4565
+ });
4566
+ };
4567
+ var buildApplicationError = (httpClientError) => {
4568
+ const status = httpClientError.response?.status;
4569
+ const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
4570
+ const message2 = httpClientError.response?.data?.message ?? statusText;
4571
+ const description = httpClientError.response?.data?.details?.applicationError?.description ?? statusText;
4572
+ const code = httpClientError.response?.data?.details?.applicationError?.code ?? constantCase(statusText);
4573
+ const data = httpClientError.response?.data?.details?.applicationError?.data ?? {};
4574
+ const combinedMessage = message2 === description ? message2 : `${message2}: ${description}`;
4575
+ const details = {
4576
+ applicationError: {
4577
+ description,
4578
+ code,
4579
+ data
4580
+ },
4581
+ requestId: httpClientError.requestId
4582
+ };
4583
+ return wrapError(httpClientError, {
4584
+ message: JSON.stringify({ message: combinedMessage, details }, null, 2),
4585
+ extraProperties: {
4586
+ details,
4587
+ status,
4588
+ requestId: httpClientError.requestId
4589
+ }
4590
+ });
4591
+ };
4592
+ var buildSystemError = (httpClientError) => {
4593
+ const message2 = httpClientError.requestId ? `System error occurred, request-id: ${httpClientError.requestId}` : `System error occurred: ${JSON.stringify(httpClientError)}`;
4594
+ return wrapError(httpClientError, {
4595
+ message: message2,
4596
+ extraProperties: {
4597
+ requestId: httpClientError.requestId,
4598
+ status: httpClientError.response?.status,
4599
+ code: constantCase(httpClientError.response?.statusText ?? "UNKNOWN"),
4600
+ ...!httpClientError.response && {
4601
+ runtimeError: httpClientError
4602
+ }
4603
+ }
4604
+ });
4605
+ };
4606
+ var violationsWithRenamedFields = ({ spreadPathsToArguments, explicitPathsToArguments, singleArgumentUnchanged }, fieldViolations, argumentNames) => {
4607
+ const allPathsToArguments = {
4608
+ ...spreadPathsToArguments,
4609
+ ...explicitPathsToArguments
4610
+ };
4611
+ const allPathsToArgumentsKeys = Object.keys(allPathsToArguments);
4612
+ return fieldViolations?.filter((fieldViolation) => {
4613
+ const containedInAMoreSpecificViolationField = fieldViolations.some((anotherViolation) => anotherViolation.field.length > fieldViolation.field.length && anotherViolation.field.startsWith(fieldViolation.field) && allPathsToArgumentsKeys.includes(anotherViolation.field));
4614
+ return !containedInAMoreSpecificViolationField;
4615
+ }).map((fieldViolation) => {
4616
+ const exactMatchArgumentExpression = explicitPathsToArguments[fieldViolation.field];
4617
+ if (exactMatchArgumentExpression) {
4618
+ return {
4619
+ ...fieldViolation,
4620
+ field: withRenamedArgument(exactMatchArgumentExpression, argumentNames)
4621
+ };
4622
+ }
4623
+ const longestPartialPathMatch = allPathsToArgumentsKeys?.sort((a, b) => b.length - a.length)?.find((path) => fieldViolation.field.startsWith(path));
4624
+ if (longestPartialPathMatch) {
4625
+ const partialMatchArgumentExpression = allPathsToArguments[longestPartialPathMatch];
4626
+ if (partialMatchArgumentExpression) {
4627
+ return {
4628
+ ...fieldViolation,
4629
+ field: fieldViolation.field.replace(longestPartialPathMatch, withRenamedArgument(partialMatchArgumentExpression, argumentNames))
4630
+ };
4631
+ }
4632
+ }
4633
+ if (singleArgumentUnchanged) {
4634
+ return {
4635
+ ...fieldViolation,
4636
+ field: `${argumentNames[0]}.${fieldViolation.field}`
4637
+ };
4638
+ }
4639
+ return fieldViolation;
4640
+ });
4641
+ };
4642
+ var withRenamedArgument = (fieldValue, argumentNames) => {
4643
+ const argIndex = getArgumentIndex(fieldValue);
4644
+ if (argIndex !== null && typeof argIndex !== "undefined") {
4645
+ return fieldValue.replace(`$[${argIndex}]`, argumentNames[argIndex]);
4646
+ }
4647
+ return fieldValue;
4648
+ };
4649
+ var getArgumentIndex = (s) => {
4650
+ const match = s.match(/\$\[(?<argIndex>\d+)\]/);
4651
+ return match && match.groups && Number(match.groups.argIndex);
4652
+ };
4653
+
4473
4654
  // ../../node_modules/@wix/sdk/build/rest-modules.js
4474
- function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
4655
+ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
4475
4656
  return runWithoutContext(() => origFunc({
4476
4657
  request: async (factory) => {
4477
4658
  const requestOptions = factory({
@@ -4488,7 +4669,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch,
4488
4669
  }
4489
4670
  try {
4490
4671
  const biHeader = biHeaderGenerator(requestOptions, publicMetadata, hostName);
4491
- const res = await boundFetch(url, {
4672
+ const requestOptionsInit = {
4492
4673
  method: request.method,
4493
4674
  ...request.data && {
4494
4675
  body: JSON.stringify(request.data)
@@ -4496,17 +4677,28 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch,
4496
4677
  headers: {
4497
4678
  ...biHeader
4498
4679
  }
4499
- });
4680
+ };
4681
+ const res = await boundFetch(url, requestOptionsInit);
4500
4682
  if (res.status !== 200) {
4501
4683
  let dataError = null;
4502
4684
  try {
4503
4685
  dataError = await res.json();
4504
4686
  } catch (e) {
4505
4687
  }
4506
- throw errorBuilder2(res.status, dataError?.message, dataError?.details, {
4688
+ const error = errorBuilder2(res.status, dataError?.message, dataError?.details, {
4507
4689
  requestId: res.headers.get("X-Wix-Request-Id"),
4508
4690
  details: dataError
4509
4691
  });
4692
+ const transformedError = transformError(error);
4693
+ errorHandler?.handleError(transformedError, {
4694
+ requestOptions: {
4695
+ url: request.url,
4696
+ method: request.method,
4697
+ entityFqdn: requestOptions.entityFqdn,
4698
+ methodFqn: requestOptions.methodFqn
4699
+ }
4700
+ });
4701
+ throw error;
4510
4702
  }
4511
4703
  const data = await res.json();
4512
4704
  return {
@@ -4527,8 +4719,17 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, wixAPIFetch,
4527
4719
  getActiveToken
4528
4720
  }));
4529
4721
  }
4722
+ var SDKError = class extends Error {
4723
+ response;
4724
+ requestId;
4725
+ constructor(params) {
4726
+ super();
4727
+ this.response = params.response;
4728
+ this.requestId = params.requestId;
4729
+ }
4730
+ };
4530
4731
  var errorBuilder2 = (code, description, details, data) => {
4531
- return {
4732
+ return new SDKError({
4532
4733
  response: {
4533
4734
  data: {
4534
4735
  details: {
@@ -4546,7 +4747,7 @@ var errorBuilder2 = (code, description, details, data) => {
4546
4747
  status: code
4547
4748
  },
4548
4749
  requestId: data?.requestId
4549
- };
4750
+ });
4550
4751
  };
4551
4752
 
4552
4753
  // ../../node_modules/@wix/sdk/build/nanoevents.js
@@ -4788,28 +4989,51 @@ function createClient(config) {
4788
4989
  ...config.host?.essentials?.passThroughHeaders,
4789
4990
  ..._headers[X_WIX_CONSISTENT_HEADER] ? { [X_WIX_CONSISTENT_HEADER]: _headers[X_WIX_CONSISTENT_HEADER] } : {}
4790
4991
  };
4791
- if (typeof urlOrRequest === "string" || urlOrRequest instanceof URL) {
4792
- const response = await fetch(urlOrRequest, {
4793
- ...requestInit,
4794
- headers
4795
- });
4796
- const consistentHeader = findConsistentHeader(response);
4797
- if (consistentHeader) {
4798
- _headers[X_WIX_CONSISTENT_HEADER] = consistentHeader;
4799
- }
4800
- return response;
4801
- } else {
4802
- for (const [k, v] of Object.entries(headers)) {
4803
- if (typeof v === "string") {
4804
- urlOrRequest.headers.set(k, v);
4992
+ const errorHandler = config.host?.getErrorHandler?.();
4993
+ try {
4994
+ if (typeof urlOrRequest === "string" || urlOrRequest instanceof URL) {
4995
+ const response = await fetch(urlOrRequest, {
4996
+ ...requestInit,
4997
+ headers
4998
+ });
4999
+ errorHandler?.handleError(response, {
5000
+ requestOptions: {
5001
+ url: urlOrRequest.toString(),
5002
+ method: requestInit?.method
5003
+ }
5004
+ });
5005
+ const consistentHeader = findConsistentHeader(response);
5006
+ if (consistentHeader) {
5007
+ _headers[X_WIX_CONSISTENT_HEADER] = consistentHeader;
4805
5008
  }
5009
+ return response;
5010
+ } else {
5011
+ for (const [k, v] of Object.entries(headers)) {
5012
+ if (typeof v === "string") {
5013
+ urlOrRequest.headers.set(k, v);
5014
+ }
5015
+ }
5016
+ const response = await fetch(urlOrRequest, requestInit);
5017
+ errorHandler?.handleError(response, {
5018
+ requestOptions: {
5019
+ url: urlOrRequest.url,
5020
+ method: requestInit?.method
5021
+ }
5022
+ });
5023
+ const consistentHeader = findConsistentHeader(response);
5024
+ if (consistentHeader) {
5025
+ _headers[X_WIX_CONSISTENT_HEADER] = consistentHeader;
5026
+ }
5027
+ return response;
4806
5028
  }
4807
- const response = await fetch(urlOrRequest, requestInit);
4808
- const consistentHeader = findConsistentHeader(response);
4809
- if (consistentHeader) {
4810
- _headers[X_WIX_CONSISTENT_HEADER] = consistentHeader;
4811
- }
4812
- return response;
5029
+ } catch (e) {
5030
+ errorHandler?.handleError(e, {
5031
+ requestOptions: {
5032
+ url: typeof urlOrRequest === "string" || urlOrRequest instanceof URL ? urlOrRequest.toString() : urlOrRequest.url,
5033
+ method: requestInit?.method
5034
+ }
5035
+ });
5036
+ throw e;
4813
5037
  }
4814
5038
  };
4815
5039
  const { client: servicePluginsClient, initModule: initServicePluginModule } = servicePluginsModules(authStrategy);
@@ -4848,7 +5072,7 @@ function createClient(config) {
4848
5072
  }
4849
5073
  const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;
4850
5074
  const shouldUseCDN = config.useCDN === void 0 ? config.auth?.shouldUseCDN : config.useCDN;
4851
- return buildRESTDescriptor(runWithoutContext(() => isAmbassadorModule(modules)) ? toHTTPModule(modules) : modules, metadata ?? {}, boundFetch, (relativeUrl, fetchOptions) => {
5075
+ return buildRESTDescriptor(runWithoutContext(() => isAmbassadorModule(modules)) ? toHTTPModule(modules) : modules, metadata ?? {}, boundFetch, config.host?.getErrorHandler?.(), (relativeUrl, fetchOptions) => {
4852
5076
  const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);
4853
5077
  finalUrl.host = apiBaseUrl;
4854
5078
  finalUrl.protocol = "https";
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-7B3P7MZT.js";
6
+ } from "./chunk-FO7ABKNR.js";
7
7
  import {
8
8
  runCommand
9
- } from "./chunk-VV6PV2NF.js";
10
- import "./chunk-GFXZXRO4.js";
11
- import "./chunk-5ZI5USPK.js";
12
- import "./chunk-657KFISY.js";
9
+ } from "./chunk-LWOWN5OI.js";
10
+ import "./chunk-UPQ6AZFY.js";
11
+ import "./chunk-PBROWK34.js";
12
+ import "./chunk-IGC7QYU5.js";
13
13
  import {
14
14
  package_default,
15
15
  require_react,
16
16
  z
17
- } from "./chunk-VCFM6SMQ.js";
17
+ } from "./chunk-W5SE5OVE.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-FI2MU2Z5.js");
3381
- const { build } = await import("./build-ZO7CXGLN.js");
3380
+ const { runCommand: runCommand2 } = await import("./render-command-DIMIKL4B.js");
3381
+ const { build } = await import("./build-LZ3CJXNM.js");
3382
3382
  await runCommand2(command, services, build);
3383
3383
  });
3384
3384
 
@@ -3388,8 +3388,8 @@ var import_react = __toESM(require_react(), 1);
3388
3388
  var devCommand = (services) => {
3389
3389
  const t = createI18nT();
3390
3390
  return createCommand("dev").option("-s, --https", t("dev_command_def.option.https")).action(async (options, command) => {
3391
- const { DevCommand } = await import("./DevCommand-BWRRKEE6.js");
3392
- const { renderCommand } = await import("./render-command-FI2MU2Z5.js");
3391
+ const { DevCommand } = await import("./DevCommand-3HZJQQIQ.js");
3392
+ const { renderCommand } = await import("./render-command-DIMIKL4B.js");
3393
3393
  const { https = false } = options;
3394
3394
  await renderCommand(command, services, /* @__PURE__ */ import_react.default.createElement(DevCommand, { https }), {
3395
3395
  watchForModelChanges: true
@@ -3465,17 +3465,17 @@ var previewCommand = (services) => {
3465
3465
  ).hideHelp()
3466
3466
  ).action(async (options, command) => {
3467
3467
  const { site, baseUrl, json } = options;
3468
- const { renderCommand, runCommand: runCommand2 } = await import("./render-command-FI2MU2Z5.js");
3468
+ const { renderCommand, runCommand: runCommand2 } = await import("./render-command-DIMIKL4B.js");
3469
3469
  if (json) {
3470
3470
  return runCommand2(command, services, async (model) => {
3471
- const { nonInteractivePreview } = await import("./preview-ZGAFDUGX.js");
3471
+ const { nonInteractivePreview } = await import("./preview-OVNN2RP4.js");
3472
3472
  return nonInteractivePreview(services, model, {
3473
3473
  baseUrl,
3474
3474
  siteId: site
3475
3475
  });
3476
3476
  });
3477
3477
  }
3478
- const { PreviewCommand } = await import("./PreviewCommand-YAYKKYRN.js");
3478
+ const { PreviewCommand } = await import("./PreviewCommand-WBQRDP7K.js");
3479
3479
  await renderCommand(
3480
3480
  command,
3481
3481
  services,
@@ -3492,8 +3492,8 @@ var addPermissionCommand = (services) => {
3492
3492
  return createCommand("add-permission").description("adding a permission to the app").addOption(
3493
3493
  new Option("-p, --permission-id <id>", t("the permission id to add"))
3494
3494
  ).action(async (options, command) => {
3495
- const { renderCommand } = await import("./render-command-FI2MU2Z5.js");
3496
- const { AddPermissionCommand } = await import("./AddPermissionCommand-7E5GD5VD.js");
3495
+ const { renderCommand } = await import("./render-command-DIMIKL4B.js");
3496
+ const { AddPermissionCommand } = await import("./AddPermissionCommand-W3TQTL3X.js");
3497
3497
  const { permissionId = "" } = options;
3498
3498
  await renderCommand(
3499
3499
  command,
@@ -3509,8 +3509,8 @@ var import_react4 = __toESM(require_react(), 1);
3509
3509
  var serveCommand = (services) => {
3510
3510
  const t = createI18nT();
3511
3511
  return createCommand("serve").description(t("serve_command_def.description")).action(async (_, command) => {
3512
- const { renderCommand } = await import("./render-command-FI2MU2Z5.js");
3513
- const { ServeCommandDeprecated } = await import("./ServeCommand-NDUXIY75.js");
3512
+ const { renderCommand } = await import("./render-command-DIMIKL4B.js");
3513
+ const { ServeCommandDeprecated } = await import("./ServeCommand-IPKP6PJ2.js");
3514
3514
  await renderCommand(command, services, /* @__PURE__ */ import_react4.default.createElement(ServeCommandDeprecated, null));
3515
3515
  });
3516
3516
  };
@@ -3525,8 +3525,8 @@ var generateCommand = (services) => {
3525
3525
  t("generate_command.type_flag"),
3526
3526
  validateDocsExtensionType
3527
3527
  ).description(t("generate_command.description")).action(async (options, command) => {
3528
- const { GenerateCommand } = await import("./GenerateCommand-IO6ENBOG.js");
3529
- const { renderCommand } = await import("./render-command-FI2MU2Z5.js");
3528
+ const { GenerateCommand } = await import("./GenerateCommand-UQ3JHQTJ.js");
3529
+ const { renderCommand } = await import("./render-command-DIMIKL4B.js");
3530
3530
  const { type } = options;
3531
3531
  await renderCommand(
3532
3532
  command,
@@ -3550,8 +3550,8 @@ var logsCommand = (services) => {
3550
3550
  validateVersion
3551
3551
  ).action(async (options, command) => {
3552
3552
  const { version } = options;
3553
- const { renderCommand } = await import("./render-command-FI2MU2Z5.js");
3554
- const { LogsCommand } = await import("./LogsCommand-C62QNN65.js");
3553
+ const { renderCommand } = await import("./render-command-DIMIKL4B.js");
3554
+ const { LogsCommand } = await import("./LogsCommand-JHADSYUE.js");
3555
3555
  await renderCommand(command, services, /* @__PURE__ */ import_react6.default.createElement(LogsCommand, { version }));
3556
3556
  });
3557
3557
  };
@@ -3584,8 +3584,8 @@ var releaseCommand = (services) => {
3584
3584
  t("app_preview_command_def.option.json")
3585
3585
  ).hideHelp()
3586
3586
  ).action(async (options, command) => {
3587
- const { renderCommand } = await import("./render-command-FI2MU2Z5.js");
3588
- const { ReleaseCommand, ReleaseVersionType } = await import("./ReleaseCommand-77SWCHH2.js");
3587
+ const { renderCommand } = await import("./render-command-DIMIKL4B.js");
3588
+ const { ReleaseCommand, ReleaseVersionType } = await import("./ReleaseCommand-3KDJB3KZ.js");
3589
3589
  const { baseUrl, site, comment, json } = options;
3590
3590
  const versionType = options.versionType ? {
3591
3591
  major: ReleaseVersionType.MAJOR,
@@ -3599,7 +3599,7 @@ var releaseCommand = (services) => {
3599
3599
  };
3600
3600
  if (json) {
3601
3601
  return runCommand(command, services, async (model) => {
3602
- const { nonInteractiveRelease } = await import("./release-YOEGOFAT.js");
3602
+ const { nonInteractiveRelease } = await import("./release-OMLRH2VC.js");
3603
3603
  return nonInteractiveRelease(services, model, props);
3604
3604
  });
3605
3605
  }
@@ -0,0 +1,2 @@
1
+ import{wixContext as n}from"@wix/sdk-context";function d(o,t){return(...i)=>{let e=u();return e?e.initWixModules(o,t).apply(void 0,i):o.apply(void 0,i)}}function u(){let o=typeof $wixContext<"u"&&$wixContext.initWixModules?$wixContext.initWixModules:typeof globalThis.__wix_context__<"u"&&globalThis.__wix_context__.initWixModules?globalThis.__wix_context__.initWixModules:void 0;if(o)return{initWixModules(e,l){return r(()=>o(e,l))},fetchWithAuth(){throw new Error("fetchWithAuth is not available in this context")},graphql(){throw new Error("graphql is not available in this context")}};let t=typeof $wixContext<"u"?$wixContext.client:typeof n.client<"u"?n.client:typeof globalThis.__wix_context__<"u"?globalThis.__wix_context__.client:void 0,i=typeof $wixContext<"u"?$wixContext.elevatedClient:typeof n.elevatedClient<"u"?n.elevatedClient:typeof globalThis.__wix_context__<"u"?globalThis.__wix_context__.elevatedClient:void 0;if(!(!t&&!i))return{initWixModules(e,l){if(l){if(!i)throw new Error("An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules");return r(()=>i.use(e))}if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return r(()=>t.use(e))},fetchWithAuth:(e,l)=>{if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return t.fetchWithAuth(e,l)},getAuth(){if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return t.auth},async graphql(e,l,x){if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return t.graphql(e,l,x)}}}function r(o){let t=globalThis.__wix_context__,i={client:n.client,elevatedClient:n.elevatedClient},e;globalThis.__wix_context__=void 0,n.client=void 0,n.elevatedClient=void 0,typeof $wixContext<"u"&&(e={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return o()}finally{globalThis.__wix_context__=t,n.client=i.client,n.elevatedClient=i.elevatedClient,typeof $wixContext<"u"&&($wixContext.client=e.client,$wixContext.elevatedClient=e.elevatedClient)}}export{d as a,r as b};
2
+ //# sourceMappingURL=chunk-J3SVE4GM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/context.js","../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/context-v2.js"],"sourcesContent":["import { wixContext } from '@wix/sdk-context';\nexport function resolveContext() {\n const oldContext = typeof $wixContext !== 'undefined' && $wixContext.initWixModules\n ? $wixContext.initWixModules\n : typeof globalThis.__wix_context__ !== 'undefined' &&\n globalThis.__wix_context__.initWixModules\n ? globalThis.__wix_context__.initWixModules\n : undefined;\n if (oldContext) {\n return {\n // @ts-expect-error\n initWixModules(modules, elevated) {\n return runWithoutContext(() => oldContext(modules, elevated));\n },\n fetchWithAuth() {\n throw new Error('fetchWithAuth is not available in this context');\n },\n graphql() {\n throw new Error('graphql is not available in this context');\n },\n };\n }\n const contextualClient = typeof $wixContext !== 'undefined'\n ? $wixContext.client\n : typeof wixContext.client !== 'undefined'\n ? wixContext.client\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.client\n : undefined;\n const elevatedClient = typeof $wixContext !== 'undefined'\n ? $wixContext.elevatedClient\n : typeof wixContext.elevatedClient !== 'undefined'\n ? wixContext.elevatedClient\n : typeof globalThis.__wix_context__ !== 'undefined'\n ? globalThis.__wix_context__.elevatedClient\n : undefined;\n if (!contextualClient && !elevatedClient) {\n return;\n }\n return {\n initWixModules(wixModules, elevated) {\n if (elevated) {\n if (!elevatedClient) {\n throw new Error('An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules');\n }\n return runWithoutContext(() => elevatedClient.use(wixModules));\n }\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return runWithoutContext(() => contextualClient.use(wixModules));\n },\n fetchWithAuth: (urlOrRequest, requestInit) => {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.fetchWithAuth(urlOrRequest, requestInit);\n },\n getAuth() {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.auth;\n },\n async graphql(query, variables, opts) {\n if (!contextualClient) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return contextualClient.graphql(query, variables, opts);\n },\n };\n}\nexport function contextualizeHostModule(hostModule, prop) {\n return (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(hostModule)[prop].apply(undefined, args);\n };\n}\nexport function getContextualAuth() {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.getAuth();\n}\nexport function contextualizeRESTModule(restModule, expectedArgsLength) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(restModule, args[expectedArgsLength]?.suppressAuth ? true : false)\n .apply(undefined, args);\n });\n}\nexport function contextualizeEventDefinitionModule(eventDefinition) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n}\nexport function contextualizeSerivcePluginModule(servicePlugin) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n}\nexport * from './context-v2.js';\nexport function runWithoutContext(fn) {\n const globalContext = globalThis.__wix_context__;\n const moduleContext = {\n client: wixContext.client,\n elevatedClient: wixContext.elevatedClient,\n };\n let closureContext;\n globalThis.__wix_context__ = undefined;\n wixContext.client = undefined;\n wixContext.elevatedClient = undefined;\n if (typeof $wixContext !== 'undefined') {\n closureContext = {\n client: $wixContext?.client,\n elevatedClient: $wixContext?.elevatedClient,\n };\n delete $wixContext.client;\n delete $wixContext.elevatedClient;\n }\n try {\n return fn();\n }\n finally {\n globalThis.__wix_context__ = globalContext;\n wixContext.client = moduleContext.client;\n wixContext.elevatedClient = moduleContext.elevatedClient;\n if (typeof $wixContext !== 'undefined') {\n $wixContext.client = closureContext.client;\n $wixContext.elevatedClient = closureContext.elevatedClient;\n }\n }\n}\n","import { EventDefinition, ServicePluginDefinition, } from '@wix/sdk-types';\nimport { resolveContext } from './context.js';\nexport { EventDefinition, ServicePluginDefinition, };\nexport function contextualizeHostModuleV2(hostModule, props) {\n return {\n ...hostModule,\n ...Object.fromEntries(props.map((prop) => [\n prop,\n (...args) => {\n const context = resolveContext();\n if (!context) {\n throw new Error('Wix context is not available. Make sure to initialize the Wix context before using SDK modules');\n }\n return context\n .initWixModules(hostModule)[prop].apply(undefined, args);\n },\n ])),\n };\n}\nexport function contextualizeRESTModuleV2(restModule, elevated) {\n return ((...args) => {\n const context = resolveContext();\n if (!context) {\n // @ts-expect-error - if there is no context, we want to behave like the original module\n return restModule.apply(undefined, args);\n }\n return (context\n .initWixModules(restModule, elevated)\n // @ts-expect-error - we know the args here are meant to be passed to the initalized module\n .apply(undefined, args));\n });\n}\nexport function contextualizeEventDefinitionModuleV2(eventDefinition) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(eventDefinition).apply(undefined, args);\n });\n contextualMethod.__type = eventDefinition.__type;\n contextualMethod.type = eventDefinition.type;\n contextualMethod.isDomainEvent = eventDefinition.isDomainEvent;\n contextualMethod.transformations = eventDefinition.transformations;\n return contextualMethod;\n}\nexport function contextualizeSerivcePluginModuleV2(servicePlugin) {\n const contextualMethod = ((...args) => {\n const context = resolveContext();\n if (!context) {\n // this line should throw, but this would be a breaking change for older SDK versions\n // this is because in wixClient there's code that calls any function it detects and checks\n // if it's an ambassador module (see isAmbassadorModule)\n return () => { };\n }\n return context.initWixModules(servicePlugin).apply(undefined, args);\n });\n contextualMethod.__type = servicePlugin.__type;\n contextualMethod.componentType = servicePlugin.componentType;\n contextualMethod.methods = servicePlugin.methods;\n return contextualMethod;\n}\n"],"mappings":"AAAA,OAAS,cAAAA,MAAkB,mBCmBpB,SAASC,EAA0BC,EAAYC,EAAU,CAC5D,MAAQ,IAAIC,IAAS,CACjB,IAAMC,EAAUC,EAAe,EAC/B,OAAKD,EAIGA,EACH,eAAeH,EAAYC,CAAQ,EAEnC,MAAM,OAAWC,CAAI,EALfF,EAAW,MAAM,OAAWE,CAAI,CAM/C,CACJ,CD9BO,SAASG,GAAiB,CAC7B,IAAMC,EAAa,OAAO,YAAgB,KAAe,YAAY,eAC/D,YAAY,eACZ,OAAO,WAAW,gBAAoB,KACpC,WAAW,gBAAgB,eACzB,WAAW,gBAAgB,eAC3B,OACV,GAAIA,EACA,MAAO,CAEH,eAAeC,EAASC,EAAU,CAC9B,OAAOC,EAAkB,IAAMH,EAAWC,EAASC,CAAQ,CAAC,CAChE,EACA,eAAgB,CACZ,MAAM,IAAI,MAAM,gDAAgD,CACpE,EACA,SAAU,CACN,MAAM,IAAI,MAAM,0CAA0C,CAC9D,CACJ,EAEJ,IAAME,EAAmB,OAAO,YAAgB,IAC1C,YAAY,OACZ,OAAOC,EAAW,OAAW,IACzBA,EAAW,OACX,OAAO,WAAW,gBAAoB,IAClC,WAAW,gBAAgB,OAC3B,OACRC,EAAiB,OAAO,YAAgB,IACxC,YAAY,eACZ,OAAOD,EAAW,eAAmB,IACjCA,EAAW,eACX,OAAO,WAAW,gBAAoB,IAClC,WAAW,gBAAgB,eAC3B,OACd,GAAI,GAACD,GAAoB,CAACE,GAG1B,MAAO,CACH,eAAeC,EAAYL,EAAU,CACjC,GAAIA,EAAU,CACV,GAAI,CAACI,EACD,MAAM,IAAI,MAAM,2JAA2J,EAE/K,OAAOH,EAAkB,IAAMG,EAAe,IAAIC,CAAU,CAAC,CACjE,CACA,GAAI,CAACH,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOD,EAAkB,IAAMC,EAAiB,IAAIG,CAAU,CAAC,CACnE,EACA,cAAe,CAACC,EAAcC,IAAgB,CAC1C,GAAI,CAACL,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EAAiB,cAAcI,EAAcC,CAAW,CACnE,EACA,SAAU,CACN,GAAI,CAACL,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EAAiB,IAC5B,EACA,MAAM,QAAQM,EAAOC,EAAWC,EAAM,CAClC,GAAI,CAACR,EACD,MAAM,IAAI,MAAM,gGAAgG,EAEpH,OAAOA,EAAiB,QAAQM,EAAOC,EAAWC,CAAI,CAC1D,CACJ,CACJ,CA+CO,SAASC,EAAkBC,EAAI,CAClC,IAAMC,EAAgB,WAAW,gBAC3BC,EAAgB,CAClB,OAAQC,EAAW,OACnB,eAAgBA,EAAW,cAC/B,EACIC,EACJ,WAAW,gBAAkB,OAC7BD,EAAW,OAAS,OACpBA,EAAW,eAAiB,OACxB,OAAO,YAAgB,MACvBC,EAAiB,CACb,OAAQ,aAAa,OACrB,eAAgB,aAAa,cACjC,EACA,OAAO,YAAY,OACnB,OAAO,YAAY,gBAEvB,GAAI,CACA,OAAOJ,EAAG,CACd,QACA,CACI,WAAW,gBAAkBC,EAC7BE,EAAW,OAASD,EAAc,OAClCC,EAAW,eAAiBD,EAAc,eACtC,OAAO,YAAgB,MACvB,YAAY,OAASE,EAAe,OACpC,YAAY,eAAiBA,EAAe,eAEpD,CACJ","names":["wixContext","contextualizeRESTModuleV2","restModule","elevated","args","context","resolveContext","resolveContext","oldContext","modules","elevated","runWithoutContext","contextualClient","wixContext","elevatedClient","wixModules","urlOrRequest","requestInit","query","variables","opts","runWithoutContext","fn","globalContext","moduleContext","wixContext","closureContext"]}
@@ -0,0 +1,2 @@
1
+ import{wixContext as d}from"@wix/sdk-context";function v(){let t=typeof $wixContext<"u"&&$wixContext.initWixModules?$wixContext.initWixModules:typeof globalThis.__wix_context__<"u"&&globalThis.__wix_context__.initWixModules?globalThis.__wix_context__.initWixModules:void 0;if(t)return{initWixModules(i,o){return w(()=>t(i,o))},fetchWithAuth(){throw new Error("fetchWithAuth is not available in this context")},graphql(){throw new Error("graphql is not available in this context")}};let e=typeof $wixContext<"u"?$wixContext.client:typeof d.client<"u"?d.client:typeof globalThis.__wix_context__<"u"?globalThis.__wix_context__.client:void 0,n=typeof $wixContext<"u"?$wixContext.elevatedClient:typeof d.elevatedClient<"u"?d.elevatedClient:typeof globalThis.__wix_context__<"u"?globalThis.__wix_context__.elevatedClient:void 0;if(!(!e&&!n))return{initWixModules(i,o){if(o){if(!n)throw new Error("An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules");return w(()=>n.use(i))}if(!e)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return w(()=>e.use(i))},fetchWithAuth:(i,o)=>{if(!e)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return e.fetchWithAuth(i,o)},getAuth(){if(!e)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return e.auth},async graphql(i,o,r){if(!e)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return e.graphql(i,o,r)}}}function w(t){let e=globalThis.__wix_context__,n={client:d.client,elevatedClient:d.elevatedClient},i;globalThis.__wix_context__=void 0,d.client=void 0,d.elevatedClient=void 0,typeof $wixContext<"u"&&(i={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return t()}finally{globalThis.__wix_context__=e,d.client=n.client,d.elevatedClient=n.elevatedClient,typeof $wixContext<"u"&&($wixContext.client=i.client,$wixContext.elevatedClient=i.elevatedClient)}}function M(t,e){return{...t,...Object.fromEntries(e.map(n=>[n,(...i)=>{let o=v();if(!o)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return o.initWixModules(t)[n].apply(void 0,i)}]))}}function Q(t){return M({__type:"host",create:e=>Object.entries(t).reduce((n,[i,o])=>({...n,[i]:o(e)}),{})},Object.keys(t))}var k=t=>t!=null&&t!=="",g=t=>C(t,k);function C(t,e=n=>!!n){if(!t)return{};let n={};for(let i in t)e(t[i],i)&&(n[i]=t[i]);return n}var _=t=>{let e=g({"app.id":t.appId,"app.version":t.appVersion,"app.instanceId":t.appInstanceId,"extension.id":t.extensionId,"extension.name":t.extensionName,"extension.type":t.extensionType,platform:t.platform}),n=C({"extension.data":g({...t.extensionData}),site:g({url:t.siteUrl,id:t.tenantType==="SITE"?t.tenantId:void 0}),account:g({id:t.tenantType==="ACCOUNT"?t.tenantId:void 0})},i=>!!i&&Object.keys(i).length>0);return{tags:e,contexts:n}},F=class{constructor(t){this.message=t,this.captureException=()=>{console.error(this.message)},this.captureMessage=()=>{console.error(this.message)},this.startSpan=(e,n)=>(console.error(this.message),n(void 0)),this.startSpanManual=()=>(console.error(this.message),{end:()=>{},fail:()=>{}}),this.endSpanManual=()=>{console.error(this.message)},this.addBreadcrumb=()=>{console.error(this.message)}}},p=t=>new F(t);var x=t=>typeof t?.then=="function",D=(t,e)=>e?x(t)?t.then(n=>(e(n,!0),n)):(e(t,!1),t):t,P=(t,e)=>{t&&(e?setTimeout(t,e):t())},y=()=>Date.now()+Math.random(),R=class{constructor(t){this.options=t,this.spanMap=new Map}createSpan(t,e){let n,i,o,r=Date.now(),l,a=D(e,({sentrySDK:u,scope:h},f)=>{f&&(l=Date.now()-r),u.startSpan({...t,scope:h,forceTransaction:this.options.forceTransaction},()=>new Promise((m,K)=>{n=m,i=K}))?.catch(m=>{if(m?.message!==o?.message)throw m})}),s=u=>{this.spanMap.delete(t.name),D(a,()=>{P(u,l)})},c={end:()=>{s(()=>n?.())},fail:u=>{o=o??u,s(()=>i?.(u))}};return this.spanMap.set(t.name,c),c}getSpan(t){return this.spanMap.get(t.name)}},b=t=>new R(t);var z=(t,{tags:e,contexts:n})=>{e&&t.setTags(e),n&&Object.entries(n).forEach(([i,o])=>typeof o<"u"&&t.setContext(i,o))},I=(t,e)=>{if(!e)return;let{tags:n,contexts:i}=_(e);z(t,{tags:n,contexts:i})},A=["onLoad","forceLoad"],W=new Map,B=class{constructor(t){this.options=t,this.resolvedState=null,this.validateOptions=n=>{let i=A.filter(o=>typeof n.sentrySDK?.[o]!="function");if(i.length>0)throw new Error(`Missing the following options.sentrySDK methods: ${i.join(", ")}`)},this.validateOptions(t);let e=W.get(t.dsn);e||(e=b({forceTransaction:!0}),W.set(t.dsn,e)),this.manualSpanRegistry=e}isFullSDK(){return typeof this.options.sentrySDK.BrowserClient=="function"}init(){if(this.resolvedState)return this.resolvedState;let{sentrySDK:t,transport:e,hostContext:n,dsn:i,release:o,environment:r,tracesSampleRate:l=1,debug:a=!1}=this.options,s=new t.Scope,c=new t.BrowserClient({dsn:i,transport:e??t.makeFetchTransport,integrations:t.getDefaultIntegrations({}),stackParser:t.defaultStackParser,tracesSampleRate:l||1,debug:a,environment:r,release:o});return I(s,n),s.setClient(c),c.init(),this.resolvedState={sentrySDK:t,scope:s,sentryClient:c},this.resolvedState}loadFullSDK(t){if(this.isFullSDK()){t?.(this.init());return}if(this.promise){this.promise.then(t);return}this.promise=new Promise(e=>{this.options.sentrySDK.onLoad(()=>{if(this.resolvedState)return;let n=this.init();e(n),t?.(n)})}),this.options.sentrySDK.forceLoad()}},$=class extends B{constructor(){super(...arguments),this.addBreadcrumb=t=>{let e={type:t.type,category:t.category,message:t.message,level:t.level,data:t.data};this.loadFullSDK(({scope:n})=>{n.addBreadcrumb(e)})},this.captureException=(t,e)=>{this.loadFullSDK(({sentryClient:n,scope:i})=>{n.captureException(t,{captureContext:{level:e?.level??"error",tags:e?.tags,contexts:e?.contexts}},i)})},this.captureMessage=(t,e)=>{this.loadFullSDK(({sentryClient:n,scope:i})=>{n.captureMessage(t,e?.level??"error",{captureContext:{level:e?.level??"error",tags:e?.tags,contexts:e?.contexts}},i)})},this.startSpan=(t,e)=>{if(this.isFullSDK()){let{sentrySDK:a,scope:s}=this.init();return a.startSpan({...t,scope:s},e)}this.loadFullSDK();let n=(a,s)=>{let c=Date.now()-s,u=()=>new Promise(h=>setTimeout(()=>h(a),c));this.loadFullSDK(async({sentrySDK:h,scope:f})=>h.startSpan({...t,scope:f},u))},i=async(a,s)=>{let c=Date.now()-s,u=()=>new Promise((h,f)=>setTimeout(()=>f(a),c));this.loadFullSDK(async({sentrySDK:h,scope:f})=>{try{await h.startSpan({...t,scope:f},u)}catch(S){if(S?.message!==a?.message)throw S}})},o=Date.now(),r,l;try{r=e()}catch(a){l=a}if(l)throw i(l,o),l;return x(r)?r.then(a=>n(a,o)).catch(a=>i(a,o)):n(r,o),r},this.startSpanManual=t=>{let e=this.isFullSDK()?this.init():new Promise(i=>this.loadFullSDK(i));return this.manualSpanRegistry.createSpan(t,e)},this.endSpanManual=t=>{this.manualSpanRegistry.getSpan(t)?.end()}}},V=t=>`Sentry SDK version "${t}" is not supported. Please make sure to use monitoring SDK only in supported environments.`,O=t=>{try{return parseInt(t.split(".")[0],10)}catch{console.warn("Failed to parse Sentry SDK version");return}},E=({sentrySDK:t,dsn:e,...n})=>{if(!t)return p("Unsupported environment - Sentry SDK is not loaded into the environment. Please make sure to use monitoring SDK only in supported environments.");if(!e)return p("Missing Sentry DSN in the app's monitoring configuration. Please make sure to set it.");try{let i=t.SDK_VERSION&&O(t.SDK_VERSION);return i&&i<7?p(V(t.SDK_VERSION)):new $({...n,dsn:e,sentrySDK:t})}catch(i){return p(`Failed to initialize monitoring client: ${i.message}`)}};var N=class{constructor(t){this.options=t,this.captureException=(e,n)=>{let{panoramaClient:i}=this.options;e instanceof Error||(e=new Error(e)),i.errorMonitor().reportError(e,this.contextToData(n))},this.captureMessage=(e,n)=>{let{panoramaClient:i}=this.options,o=i.logger(),r;switch(n?.level){case"error":r=o.error;break;case"warning":r=o.warn;break;default:r=o.info}r(e,this.contextToData(n))},this.startSpan=(e,n)=>{let{panoramaClient:i}=this.options,{name:o}=e,r,l=i.transaction(o,{id:y()}),a=this.contextToData(e);l.start(a);try{r=n(),x(r)?r=r.then(s=>(l.finish(a),s)).catch(s=>{throw this.reportErrorInContextOfSpan(s,e),s}):l.finish(a)}catch(s){throw this.reportErrorInContextOfSpan(s,e),s}return r},this.addBreadcrumb=e=>{let{panoramaClient:n}=this.options;n.errorMonitor().addBreadcrumb(e)}}contextToData(t){return t&&{...t?.tags&&{tags:t.tags},...t?.contexts&&{context:t.contexts},...t?.level&&{severity:t.level}}}reportErrorInContextOfSpan(t,e){let{panoramaClient:n}=this.options,{name:i}=e,o=this.contextToData({...e,contexts:{transaction:{name:i}}});n.errorMonitor().reportError(t,o)}startSpanManual(t){let{panoramaClient:e}=this.options,{name:n}=t,i=e.transaction(n,{id:y()}),o=this.contextToData(t);i.start(o);let r=!1,l=a=>{r||(r=!0,a())};return{end:()=>{l(()=>i.finish(o))},fail:a=>{l(()=>this.reportErrorInContextOfSpan(a,t))}}}endSpanManual(t){let{panoramaClient:e}=this.options,{name:n}=t;e.transaction(n).finish()}},T=t=>{let{panoramaClient:e}=t;return e?new N(t):p("Missing Panorama client")};var j=t=>t?.type==="SENTRY",q=t=>t?.type==="PANORAMA",gt=({sentrySDK:t,sentryTransport:e,panoramaClient:n,monitoringConfig:i,hostContext:o})=>{if(j(i)){let{sentryOptions:r}=i;return()=>E({dsn:r?.dsn,hostContext:o,sentrySDK:t,transport:e})}else if(q(i))return()=>T({panoramaClient:n});return()=>p("Invalid monitoring configuration. Please check the monitoring setup of your application.")};export{Q as a,gt as b};
2
+ //# sourceMappingURL=chunk-J7RIIVO6.js.map