@wix/vibe-bookings-plugin 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4041,6 +4041,7 @@ __export(es_exports, {
4041
4041
  SortType: () => SortType,
4042
4042
  SortingMethodType: () => SortingMethodType,
4043
4043
  Status: () => Status,
4044
+ TaxableAddressType: () => TaxableAddressType,
4044
4045
  V2RequestedFields: () => V2RequestedFields,
4045
4046
  WebhookIdentityType: () => WebhookIdentityType,
4046
4047
  bulkCreateServices: () => bulkCreateServices4,
@@ -4079,6 +4080,7 @@ __export(es_exports, {
4079
4080
  function transformSDKAddressToRESTAddress(payload) {
4080
4081
  return payload && removeUndefinedKeys({
4081
4082
  city: payload.city,
4083
+ hint: payload.hint,
4082
4084
  subdivision: payload.subdivision,
4083
4085
  country: payload.country,
4084
4086
  postalCode: payload.postalCode,
@@ -4104,6 +4106,7 @@ function transformRESTAddressToSDKAddress(payload) {
4104
4106
  number: payload.streetAddress.number,
4105
4107
  apt: payload.streetAddress.apt
4106
4108
  },
4109
+ hint: payload.hint,
4107
4110
  city: payload.city,
4108
4111
  subdivision: payload.subdivision,
4109
4112
  country: payload.country,
@@ -4409,6 +4412,9 @@ function createAddOnGroup(payload) {
4409
4412
  method: "POST",
4410
4413
  methodFqn: "wix.bookings.services.v2.AddOnGroupsService.CreateAddOnGroup",
4411
4414
  packageName: PACKAGE_NAME,
4415
+ migrationOptions: {
4416
+ optInTransformResponse: true
4417
+ },
4412
4418
  url: resolveWixBookingsServicesV2AddOnGroupsServiceUrl({
4413
4419
  protoPath: "/v2/services/add-on-groups/create",
4414
4420
  data: payload,
@@ -4427,6 +4433,9 @@ function deleteAddOnGroup(payload) {
4427
4433
  method: "POST",
4428
4434
  methodFqn: "wix.bookings.services.v2.AddOnGroupsService.DeleteAddOnGroup",
4429
4435
  packageName: PACKAGE_NAME,
4436
+ migrationOptions: {
4437
+ optInTransformResponse: true
4438
+ },
4430
4439
  url: resolveWixBookingsServicesV2AddOnGroupsServiceUrl({
4431
4440
  protoPath: "/v2/services/add-on-groups/delete",
4432
4441
  data: payload,
@@ -4451,6 +4460,9 @@ function updateAddOnGroup(payload) {
4451
4460
  method: "POST",
4452
4461
  methodFqn: "wix.bookings.services.v2.AddOnGroupsService.UpdateAddOnGroup",
4453
4462
  packageName: PACKAGE_NAME,
4463
+ migrationOptions: {
4464
+ optInTransformResponse: true
4465
+ },
4454
4466
  url: resolveWixBookingsServicesV2AddOnGroupsServiceUrl({
4455
4467
  protoPath: "/v2/services/add-on-groups/update",
4456
4468
  data: serializedData,
@@ -4469,6 +4481,9 @@ function listAddOnGroupsByServiceId(payload) {
4469
4481
  method: "POST",
4470
4482
  methodFqn: "wix.bookings.services.v2.AddOnGroupsService.ListAddOnGroupsByServiceId",
4471
4483
  packageName: PACKAGE_NAME,
4484
+ migrationOptions: {
4485
+ optInTransformResponse: true
4486
+ },
4472
4487
  url: resolveWixBookingsServicesV2AddOnGroupsServiceUrl({
4473
4488
  protoPath: "/v2/services/add-on-groups/list-add-on-groups-by-service-id",
4474
4489
  data: payload,
@@ -4487,6 +4502,9 @@ function setAddOnsForGroup(payload) {
4487
4502
  method: "POST",
4488
4503
  methodFqn: "wix.bookings.services.v2.AddOnGroupsService.SetAddOnsForGroup",
4489
4504
  packageName: PACKAGE_NAME,
4505
+ migrationOptions: {
4506
+ optInTransformResponse: true
4507
+ },
4490
4508
  url: resolveWixBookingsServicesV2AddOnGroupsServiceUrl({
4491
4509
  protoPath: "/v2/services/add-on-groups/set-add-ons-for-group",
4492
4510
  data: payload,
@@ -4538,6 +4556,9 @@ function createService(payload) {
4538
4556
  method: "POST",
4539
4557
  methodFqn: "wix.bookings.services.v2.ServicesService.CreateService",
4540
4558
  packageName: PACKAGE_NAME,
4559
+ migrationOptions: {
4560
+ optInTransformResponse: true
4561
+ },
4541
4562
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
4542
4563
  protoPath: "/v2/services",
4543
4564
  data: serializedData,
@@ -4624,6 +4645,9 @@ function bulkCreateServices(payload) {
4624
4645
  method: "POST",
4625
4646
  methodFqn: "wix.bookings.services.v2.ServicesService.BulkCreateServices",
4626
4647
  packageName: PACKAGE_NAME,
4648
+ migrationOptions: {
4649
+ optInTransformResponse: true
4650
+ },
4627
4651
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
4628
4652
  protoPath: "/v2/bulk/services/create",
4629
4653
  data: serializedData,
@@ -4689,6 +4713,9 @@ function getService(payload) {
4689
4713
  method: "GET",
4690
4714
  methodFqn: "wix.bookings.services.v2.ServicesService.GetService",
4691
4715
  packageName: PACKAGE_NAME,
4716
+ migrationOptions: {
4717
+ optInTransformResponse: true
4718
+ },
4692
4719
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
4693
4720
  protoPath: "/v2/services/{serviceId}",
4694
4721
  data: payload,
@@ -4779,6 +4806,9 @@ function updateService(payload) {
4779
4806
  method: "PATCH",
4780
4807
  methodFqn: "wix.bookings.services.v2.ServicesService.UpdateService",
4781
4808
  packageName: PACKAGE_NAME,
4809
+ migrationOptions: {
4810
+ optInTransformResponse: true
4811
+ },
4782
4812
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
4783
4813
  protoPath: "/v2/services/{service.id}",
4784
4814
  data: serializedData,
@@ -4883,6 +4913,9 @@ function bulkUpdateServices(payload) {
4883
4913
  method: "POST",
4884
4914
  methodFqn: "wix.bookings.services.v2.ServicesService.BulkUpdateServices",
4885
4915
  packageName: PACKAGE_NAME,
4916
+ migrationOptions: {
4917
+ optInTransformResponse: true
4918
+ },
4886
4919
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
4887
4920
  protoPath: "/v2/bulk/services/update",
4888
4921
  data: serializedData,
@@ -4985,6 +5018,9 @@ function bulkUpdateServicesByFilter(payload) {
4985
5018
  method: "POST",
4986
5019
  methodFqn: "wix.bookings.services.v2.ServicesService.BulkUpdateServicesByFilter",
4987
5020
  packageName: PACKAGE_NAME,
5021
+ migrationOptions: {
5022
+ optInTransformResponse: true
5023
+ },
4988
5024
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
4989
5025
  protoPath: "/v2/bulk/services/update-by-filter",
4990
5026
  data: serializedData,
@@ -5003,6 +5039,9 @@ function deleteService(payload) {
5003
5039
  method: "DELETE",
5004
5040
  methodFqn: "wix.bookings.services.v2.ServicesService.DeleteService",
5005
5041
  packageName: PACKAGE_NAME,
5042
+ migrationOptions: {
5043
+ optInTransformResponse: true
5044
+ },
5006
5045
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5007
5046
  protoPath: "/v2/services/{serviceId}",
5008
5047
  data: payload,
@@ -5021,6 +5060,9 @@ function bulkDeleteServices(payload) {
5021
5060
  method: "POST",
5022
5061
  methodFqn: "wix.bookings.services.v2.ServicesService.BulkDeleteServices",
5023
5062
  packageName: PACKAGE_NAME,
5063
+ migrationOptions: {
5064
+ optInTransformResponse: true
5065
+ },
5024
5066
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5025
5067
  protoPath: "/v2/bulk/services/delete",
5026
5068
  data: payload,
@@ -5086,6 +5128,9 @@ function bulkDeleteServicesByFilter(payload) {
5086
5128
  method: "POST",
5087
5129
  methodFqn: "wix.bookings.services.v2.ServicesService.BulkDeleteServicesByFilter",
5088
5130
  packageName: PACKAGE_NAME,
5131
+ migrationOptions: {
5132
+ optInTransformResponse: true
5133
+ },
5089
5134
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5090
5135
  protoPath: "/v2/bulk/services/delete-by-filter",
5091
5136
  data: payload,
@@ -5104,6 +5149,9 @@ function queryServices(payload) {
5104
5149
  method: "POST",
5105
5150
  methodFqn: "wix.bookings.services.v2.ServicesService.QueryServices",
5106
5151
  packageName: PACKAGE_NAME,
5152
+ migrationOptions: {
5153
+ optInTransformResponse: true
5154
+ },
5107
5155
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5108
5156
  protoPath: "/v2/services/query",
5109
5157
  data: payload,
@@ -5174,6 +5222,9 @@ function searchServices(payload) {
5174
5222
  method: "POST",
5175
5223
  methodFqn: "wix.bookings.services.v2.ServicesService.SearchServices",
5176
5224
  packageName: PACKAGE_NAME,
5225
+ migrationOptions: {
5226
+ optInTransformResponse: true
5227
+ },
5177
5228
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5178
5229
  protoPath: "/v2/services/search",
5179
5230
  data: serializedData,
@@ -5250,6 +5301,9 @@ function queryPolicies(payload) {
5250
5301
  method: "POST",
5251
5302
  methodFqn: "wix.bookings.services.v2.ServicesService.QueryPolicies",
5252
5303
  packageName: PACKAGE_NAME,
5304
+ migrationOptions: {
5305
+ optInTransformResponse: true
5306
+ },
5253
5307
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5254
5308
  protoPath: "/v2/services/policies/query",
5255
5309
  data: payload,
@@ -5376,6 +5430,9 @@ function queryBookingForms(payload) {
5376
5430
  method: "POST",
5377
5431
  methodFqn: "wix.bookings.services.v2.ServicesService.QueryBookingForms",
5378
5432
  packageName: PACKAGE_NAME,
5433
+ migrationOptions: {
5434
+ optInTransformResponse: true
5435
+ },
5379
5436
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5380
5437
  protoPath: "/v2/services/booking-forms/query",
5381
5438
  data: payload,
@@ -5394,6 +5451,9 @@ function countServices(payload) {
5394
5451
  method: "POST",
5395
5452
  methodFqn: "wix.bookings.services.v2.ServicesService.CountServices",
5396
5453
  packageName: PACKAGE_NAME,
5454
+ migrationOptions: {
5455
+ optInTransformResponse: true
5456
+ },
5397
5457
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5398
5458
  protoPath: "/v2/services/count",
5399
5459
  data: payload,
@@ -5412,6 +5472,9 @@ function queryLocations(payload) {
5412
5472
  method: "POST",
5413
5473
  methodFqn: "wix.bookings.services.v2.ServicesService.QueryLocations",
5414
5474
  packageName: PACKAGE_NAME,
5475
+ migrationOptions: {
5476
+ optInTransformResponse: true
5477
+ },
5415
5478
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5416
5479
  protoPath: "/v2/services/locations/query",
5417
5480
  data: payload,
@@ -5455,6 +5518,9 @@ function queryCategories(payload) {
5455
5518
  method: "POST",
5456
5519
  methodFqn: "wix.bookings.services.v2.ServicesService.QueryCategories",
5457
5520
  packageName: PACKAGE_NAME,
5521
+ migrationOptions: {
5522
+ optInTransformResponse: true
5523
+ },
5458
5524
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5459
5525
  protoPath: "/v2/services/categories/query",
5460
5526
  data: payload,
@@ -5504,6 +5570,9 @@ function setServiceLocations(payload) {
5504
5570
  method: "POST",
5505
5571
  methodFqn: "wix.bookings.services.v2.ServicesService.SetServiceLocations",
5506
5572
  packageName: PACKAGE_NAME,
5573
+ migrationOptions: {
5574
+ optInTransformResponse: true
5575
+ },
5507
5576
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5508
5577
  protoPath: "/v2/services/{serviceId}/locations",
5509
5578
  data: serializedData,
@@ -5557,6 +5626,9 @@ function enablePricingPlansForService(payload) {
5557
5626
  method: "POST",
5558
5627
  methodFqn: "wix.bookings.services.v2.ServicesService.EnablePricingPlansForService",
5559
5628
  packageName: PACKAGE_NAME,
5629
+ migrationOptions: {
5630
+ optInTransformResponse: true
5631
+ },
5560
5632
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5561
5633
  protoPath: "/v2/services/{serviceId}/pricing-plans/add",
5562
5634
  data: payload,
@@ -5610,6 +5682,9 @@ function disablePricingPlansForService(payload) {
5610
5682
  method: "POST",
5611
5683
  methodFqn: "wix.bookings.services.v2.ServicesService.DisablePricingPlansForService",
5612
5684
  packageName: PACKAGE_NAME,
5685
+ migrationOptions: {
5686
+ optInTransformResponse: true
5687
+ },
5613
5688
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5614
5689
  protoPath: "/v2/services/{serviceId}/pricing-plans/remove",
5615
5690
  data: payload,
@@ -5663,6 +5738,9 @@ function setCustomSlug(payload) {
5663
5738
  method: "POST",
5664
5739
  methodFqn: "wix.bookings.services.v2.ServicesService.SetCustomSlug",
5665
5740
  packageName: PACKAGE_NAME,
5741
+ migrationOptions: {
5742
+ optInTransformResponse: true
5743
+ },
5666
5744
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5667
5745
  protoPath: "/v2/services/{serviceId}/slugs/custom",
5668
5746
  data: payload,
@@ -5717,6 +5795,9 @@ function validateSlug(payload) {
5717
5795
  method: "POST",
5718
5796
  methodFqn: "wix.bookings.services.v2.ServicesService.ValidateSlug",
5719
5797
  packageName: PACKAGE_NAME,
5798
+ migrationOptions: {
5799
+ optInTransformResponse: true
5800
+ },
5720
5801
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5721
5802
  protoPath: "/v2/services/slugs/validate",
5722
5803
  data: payload,
@@ -5735,6 +5816,9 @@ function cloneService(payload) {
5735
5816
  method: "POST",
5736
5817
  methodFqn: "wix.bookings.services.v2.ServicesService.CloneService",
5737
5818
  packageName: PACKAGE_NAME,
5819
+ migrationOptions: {
5820
+ optInTransformResponse: true
5821
+ },
5738
5822
  url: resolveWixBookingsServicesV2ServicesServiceUrl({
5739
5823
  protoPath: "/v2/services/clone",
5740
5824
  data: payload,
@@ -5821,6 +5905,12 @@ var SortingMethodType = /* @__PURE__ */ ((SortingMethodType2) => {
5821
5905
  SortingMethodType2["CUSTOM"] = "CUSTOM";
5822
5906
  return SortingMethodType2;
5823
5907
  })(SortingMethodType || {});
5908
+ var TaxableAddressType = /* @__PURE__ */ ((TaxableAddressType2) => {
5909
+ TaxableAddressType2["UNKNOWN_TAXABLE_ADDRESS_TYPE"] = "UNKNOWN_TAXABLE_ADDRESS_TYPE";
5910
+ TaxableAddressType2["BUSINESS"] = "BUSINESS";
5911
+ TaxableAddressType2["BILLING"] = "BILLING";
5912
+ return TaxableAddressType2;
5913
+ })(TaxableAddressType || {});
5824
5914
  var WebhookIdentityType = /* @__PURE__ */ ((WebhookIdentityType2) => {
5825
5915
  WebhookIdentityType2["UNKNOWN"] = "UNKNOWN";
5826
5916
  WebhookIdentityType2["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
@@ -8320,15 +8410,228 @@ function objectToKeyValue(input) {
8320
8410
  return Object.entries(input).filter(([_, value]) => Boolean(value)).map(([key, value]) => `${key}=${value}`).join(",");
8321
8411
  }
8322
8412
 
8413
+ // ../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/context.js
8414
+ function runWithoutContext2(fn) {
8415
+ const globalContext = globalThis.__wix_context__;
8416
+ const moduleContext = {
8417
+ client: wixContext.client,
8418
+ elevatedClient: wixContext.elevatedClient
8419
+ };
8420
+ let closureContext;
8421
+ globalThis.__wix_context__ = void 0;
8422
+ wixContext.client = void 0;
8423
+ wixContext.elevatedClient = void 0;
8424
+ if (typeof $wixContext !== "undefined") {
8425
+ closureContext = {
8426
+ client: $wixContext?.client,
8427
+ elevatedClient: $wixContext?.elevatedClient
8428
+ };
8429
+ delete $wixContext.client;
8430
+ delete $wixContext.elevatedClient;
8431
+ }
8432
+ try {
8433
+ return fn();
8434
+ } finally {
8435
+ globalThis.__wix_context__ = globalContext;
8436
+ wixContext.client = moduleContext.client;
8437
+ wixContext.elevatedClient = moduleContext.elevatedClient;
8438
+ if (typeof $wixContext !== "undefined") {
8439
+ $wixContext.client = closureContext.client;
8440
+ $wixContext.elevatedClient = closureContext.elevatedClient;
8441
+ }
8442
+ }
8443
+ }
8444
+
8445
+ // ../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/utils.js
8446
+ function constantCase2(input) {
8447
+ return split2(input).map((part) => part.toLocaleUpperCase()).join("_");
8448
+ }
8449
+ var SPLIT_LOWER_UPPER_RE2 = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu");
8450
+ var SPLIT_UPPER_UPPER_RE2 = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu");
8451
+ var SPLIT_REPLACE_VALUE2 = "$1\0$2";
8452
+ var DEFAULT_STRIP_REGEXP2 = /[^\p{L}\d]+/giu;
8453
+ function split2(value) {
8454
+ let result = value.trim();
8455
+ result = result.replace(SPLIT_LOWER_UPPER_RE2, SPLIT_REPLACE_VALUE2).replace(SPLIT_UPPER_UPPER_RE2, SPLIT_REPLACE_VALUE2);
8456
+ result = result.replace(DEFAULT_STRIP_REGEXP2, "\0");
8457
+ let start = 0;
8458
+ let end = result.length;
8459
+ while (result.charAt(start) === "\0") {
8460
+ start++;
8461
+ }
8462
+ if (start === end) {
8463
+ return [];
8464
+ }
8465
+ while (result.charAt(end - 1) === "\0") {
8466
+ end--;
8467
+ }
8468
+ return result.slice(start, end).split(/\0/g);
8469
+ }
8470
+
8471
+ // ../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/transform-error.js
8472
+ var isValidationError2 = (httpClientError) => "validationError" in (httpClientError.response?.data?.details ?? {});
8473
+ var isApplicationError2 = (httpClientError) => "applicationError" in (httpClientError.response?.data?.details ?? {});
8474
+ var isClientError2 = (httpClientError) => (httpClientError.response?.status ?? -1) >= 400 && (httpClientError.response?.status ?? -1) < 500;
8475
+ function transformError2(httpClientError, pathsToArguments = {
8476
+ explicitPathsToArguments: {},
8477
+ spreadPathsToArguments: {},
8478
+ singleArgumentUnchanged: false
8479
+ }, argumentNames = []) {
8480
+ if (typeof httpClientError !== "object" || httpClientError === null) {
8481
+ throw httpClientError;
8482
+ }
8483
+ if (isValidationError2(httpClientError)) {
8484
+ return buildValidationError2(httpClientError, pathsToArguments, argumentNames);
8485
+ }
8486
+ if (isApplicationError2(httpClientError)) {
8487
+ return buildApplicationError2(httpClientError);
8488
+ }
8489
+ if (isClientError2(httpClientError)) {
8490
+ const status = httpClientError.response?.status;
8491
+ const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
8492
+ const message = httpClientError.response?.data?.message ?? statusText;
8493
+ const details = {
8494
+ applicationError: {
8495
+ description: statusText,
8496
+ code: constantCase2(statusText),
8497
+ data: {}
8498
+ },
8499
+ requestId: httpClientError.requestId
8500
+ };
8501
+ return wrapError2(httpClientError, {
8502
+ message: JSON.stringify({
8503
+ message,
8504
+ details
8505
+ }, null, 2),
8506
+ extraProperties: {
8507
+ details,
8508
+ status
8509
+ }
8510
+ });
8511
+ }
8512
+ return buildSystemError2(httpClientError);
8513
+ }
8514
+ var buildValidationError2 = (httpClientError, pathsToArguments, argumentNames) => {
8515
+ const validationErrorResponse = httpClientError.response?.data;
8516
+ const requestId = httpClientError.requestId;
8517
+ const { fieldViolations } = validationErrorResponse.details.validationError;
8518
+ const transformedFieldViolations = violationsWithRenamedFields2(pathsToArguments, fieldViolations, argumentNames)?.sort((a, b) => a.field < b.field ? -1 : 1);
8519
+ const message = `INVALID_ARGUMENT: ${transformedFieldViolations?.map(({ field, description }) => `"${field}" ${description}`)?.join(", ")}`;
8520
+ const details = {
8521
+ validationError: { fieldViolations: transformedFieldViolations },
8522
+ requestId
8523
+ };
8524
+ return wrapError2(httpClientError, {
8525
+ message: JSON.stringify({ message, details }, null, 2),
8526
+ extraProperties: {
8527
+ details,
8528
+ status: httpClientError.response?.status,
8529
+ requestId
8530
+ }
8531
+ });
8532
+ };
8533
+ var wrapError2 = (baseError, { message, extraProperties }) => {
8534
+ return Object.assign(baseError, {
8535
+ ...extraProperties,
8536
+ message
8537
+ });
8538
+ };
8539
+ var buildApplicationError2 = (httpClientError) => {
8540
+ const status = httpClientError.response?.status;
8541
+ const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
8542
+ const message = httpClientError.response?.data?.message ?? statusText;
8543
+ const description = httpClientError.response?.data?.details?.applicationError?.description ?? statusText;
8544
+ const code = httpClientError.response?.data?.details?.applicationError?.code ?? constantCase2(statusText);
8545
+ const data = httpClientError.response?.data?.details?.applicationError?.data ?? {};
8546
+ const combinedMessage = message === description ? message : `${message}: ${description}`;
8547
+ const details = {
8548
+ applicationError: {
8549
+ description,
8550
+ code,
8551
+ data
8552
+ },
8553
+ requestId: httpClientError.requestId
8554
+ };
8555
+ return wrapError2(httpClientError, {
8556
+ message: JSON.stringify({ message: combinedMessage, details }, null, 2),
8557
+ extraProperties: {
8558
+ details,
8559
+ status,
8560
+ requestId: httpClientError.requestId
8561
+ }
8562
+ });
8563
+ };
8564
+ var buildSystemError2 = (httpClientError) => {
8565
+ const message = httpClientError.requestId ? `System error occurred, request-id: ${httpClientError.requestId}` : `System error occurred: ${JSON.stringify(httpClientError)}`;
8566
+ return wrapError2(httpClientError, {
8567
+ message,
8568
+ extraProperties: {
8569
+ requestId: httpClientError.requestId,
8570
+ status: httpClientError.response?.status,
8571
+ code: constantCase2(httpClientError.response?.statusText ?? "UNKNOWN"),
8572
+ ...!httpClientError.response && {
8573
+ runtimeError: httpClientError
8574
+ }
8575
+ }
8576
+ });
8577
+ };
8578
+ var violationsWithRenamedFields2 = ({ spreadPathsToArguments, explicitPathsToArguments, singleArgumentUnchanged }, fieldViolations, argumentNames) => {
8579
+ const allPathsToArguments = {
8580
+ ...spreadPathsToArguments,
8581
+ ...explicitPathsToArguments
8582
+ };
8583
+ const allPathsToArgumentsKeys = Object.keys(allPathsToArguments);
8584
+ return fieldViolations?.filter((fieldViolation) => {
8585
+ const containedInAMoreSpecificViolationField = fieldViolations.some((anotherViolation) => anotherViolation.field.length > fieldViolation.field.length && anotherViolation.field.startsWith(fieldViolation.field) && allPathsToArgumentsKeys.includes(anotherViolation.field));
8586
+ return !containedInAMoreSpecificViolationField;
8587
+ }).map((fieldViolation) => {
8588
+ const exactMatchArgumentExpression = explicitPathsToArguments[fieldViolation.field];
8589
+ if (exactMatchArgumentExpression) {
8590
+ return {
8591
+ ...fieldViolation,
8592
+ field: withRenamedArgument2(exactMatchArgumentExpression, argumentNames)
8593
+ };
8594
+ }
8595
+ const longestPartialPathMatch = allPathsToArgumentsKeys?.sort((a, b) => b.length - a.length)?.find((path2) => fieldViolation.field.startsWith(path2));
8596
+ if (longestPartialPathMatch) {
8597
+ const partialMatchArgumentExpression = allPathsToArguments[longestPartialPathMatch];
8598
+ if (partialMatchArgumentExpression) {
8599
+ return {
8600
+ ...fieldViolation,
8601
+ field: fieldViolation.field.replace(longestPartialPathMatch, withRenamedArgument2(partialMatchArgumentExpression, argumentNames))
8602
+ };
8603
+ }
8604
+ }
8605
+ if (singleArgumentUnchanged) {
8606
+ return {
8607
+ ...fieldViolation,
8608
+ field: `${argumentNames[0]}.${fieldViolation.field}`
8609
+ };
8610
+ }
8611
+ return fieldViolation;
8612
+ });
8613
+ };
8614
+ var withRenamedArgument2 = (fieldValue, argumentNames) => {
8615
+ const argIndex = getArgumentIndex2(fieldValue);
8616
+ if (argIndex !== null && typeof argIndex !== "undefined") {
8617
+ return fieldValue.replace(`$[${argIndex}]`, argumentNames[argIndex]);
8618
+ }
8619
+ return fieldValue;
8620
+ };
8621
+ var getArgumentIndex2 = (s) => {
8622
+ const match = s.match(/\$\[(?<argIndex>\d+)\]/);
8623
+ return match && match.groups && Number(match.groups.argIndex);
8624
+ };
8625
+
8323
8626
  // ../../../node_modules/@wix/sdk/build/rest-modules.js
8324
8627
  function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
8325
- return runWithoutContext(() => origFunc({
8628
+ return runWithoutContext2(() => origFunc({
8326
8629
  request: async (factory) => {
8327
8630
  const requestOptions = factory({
8328
8631
  host: options?.HTTPHost || DEFAULT_API_URL
8329
8632
  });
8330
8633
  let request = requestOptions;
8331
- if (request.method === "GET" && request.fallback?.length && request.params.toString().length > 4e3) {
8634
+ if (request.method === "GET" && request.fallback?.length && (request.params?.toString().length ?? 0) > 4e3) {
8332
8635
  request = requestOptions.fallback[0];
8333
8636
  }
8334
8637
  const domain = options?.HTTPHost ?? DEFAULT_API_URL;
@@ -8358,7 +8661,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler,
8358
8661
  requestId: res.headers.get("X-Wix-Request-Id"),
8359
8662
  details: dataError
8360
8663
  });
8361
- const transformedError = transformError(error);
8664
+ const transformedError = transformError2(error);
8362
8665
  errorHandler?.handleError(transformedError, {
8363
8666
  requestOptions: {
8364
8667
  url: request.url,
@@ -8369,7 +8672,13 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler,
8369
8672
  });
8370
8673
  throw error;
8371
8674
  }
8372
- const data = await res.json();
8675
+ const rawData = await res.json();
8676
+ const data = (
8677
+ // we only transform the response if the optInTransformResponse flag is set
8678
+ // this is for backwards compatibility as some users might rely on not transforming the response
8679
+ // in older modules. In that case the modules would not have the optInTransformResponse flag set
8680
+ request.migrationOptions?.optInTransformResponse && request.transformResponse ? Array.isArray(request.transformResponse) ? request.transformResponse[0](rawData) : request.transformResponse(rawData) : rawData
8681
+ );
8373
8682
  return {
8374
8683
  data,
8375
8684
  headers: res.headers,
@@ -8741,7 +9050,7 @@ function createClient(config) {
8741
9050
  }
8742
9051
  const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;
8743
9052
  const shouldUseCDN = config.useCDN === void 0 ? config.auth?.shouldUseCDN : config.useCDN;
8744
- return buildRESTDescriptor(runWithoutContext(() => isAmbassadorModule(modules)) ? toHTTPModule(modules) : modules, metadata ?? {}, boundFetch, config.host?.getErrorHandler?.(), (relativeUrl, fetchOptions) => {
9053
+ return buildRESTDescriptor(runWithoutContext2(() => isAmbassadorModule(modules)) ? toHTTPModule(modules) : modules, metadata ?? {}, boundFetch, config.host?.getErrorHandler?.(), (relativeUrl, fetchOptions) => {
8745
9054
  const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);
8746
9055
  finalUrl.host = apiBaseUrl;
8747
9056
  finalUrl.protocol = "https";
@@ -8933,7 +9242,7 @@ var getSetupPrompt = () => {
8933
9242
  var generateMockServices = async (env) => {
8934
9243
  console.log(`[${VERTICAL_NAME}-plugin-generateData] Generating mock services...`);
8935
9244
  const model = await env.providers.getOpenAIProvider({
8936
- model: "O3_MINI_2025_01_31",
9245
+ model: "GPT_4O_2024_11_20",
8937
9246
  tag: "Bookings Setup Agent",
8938
9247
  responseFormat: { type: "json_object" }
8939
9248
  });
@@ -9188,14 +9497,75 @@ IF THE SITE IS IN ENGLISH OR THE LANGUAGE IS NOT SPECIFIED, YOU MUST NOT READ OR
9188
9497
  };
9189
9498
 
9190
9499
  // src/wix-apis.ts
9191
- var installWixApp = async (env, appId) => {
9500
+ var callWixAPI = async (url, method, _siteId, body, headers) => {
9501
+ if (!process.env.WIX_TOKEN) {
9502
+ console.error("[wix-apis] WIX_TOKEN is not set");
9503
+ }
9504
+ try {
9505
+ console.log("[wix-apis] Calling Wix API...", {
9506
+ url,
9507
+ method,
9508
+ _siteId,
9509
+ headers
9510
+ });
9511
+ const response = await fetch(url, {
9512
+ method,
9513
+ headers: {
9514
+ "Content-Type": "application/json",
9515
+ Authorization: process.env.WIX_TOKEN,
9516
+ ...headers
9517
+ },
9518
+ ...method === "GET" ? {} : { body: JSON.stringify(body) }
9519
+ });
9520
+ if (!response.ok) {
9521
+ const text = await response.text();
9522
+ console.error("[wix-apis] Error calling Wix API", {
9523
+ repsponseText: text,
9524
+ url,
9525
+ method,
9526
+ body,
9527
+ requestId: response.headers.get("x-wix-request-id")
9528
+ });
9529
+ return null;
9530
+ }
9531
+ const data = await response.json();
9532
+ return data;
9533
+ } catch (error) {
9534
+ console.error("[wix-apis] Error calling Wix API", {
9535
+ error,
9536
+ url,
9537
+ method,
9538
+ body,
9539
+ requestId: isErrorWithRequestId(error) ? error.requestId : void 0
9540
+ });
9541
+ return null;
9542
+ }
9543
+ };
9544
+ var isErrorWithRequestId = (error) => {
9545
+ return error instanceof Error && "requestId" in error;
9546
+ };
9547
+ var installApp = async (appDefId, siteId) => {
9548
+ console.log("Installing Wix app...", { appDefId, siteId });
9549
+ const response = await callWixAPI(
9550
+ "https://www.wixapis.com/apps-installer-service/v1/app-instance/install",
9551
+ "POST",
9552
+ siteId,
9553
+ {
9554
+ tenant: {
9555
+ tenantType: "SITE",
9556
+ id: siteId
9557
+ },
9558
+ appInstance: { appDefId }
9559
+ }
9560
+ );
9561
+ return response;
9192
9562
  };
9193
9563
 
9194
9564
  // src/index.ts
9195
9565
  var install = async (env) => {
9196
9566
  console.log(`[${VERTICAL_NAME}-plugin-install] Starting installation`, env);
9197
9567
  console.log(`[${VERTICAL_NAME}-plugin-install] Installing vertical functionality...`);
9198
- await installWixApp();
9568
+ await installApp("cc552162-24a4-45e0-9695-230c4931ef40", env.WIX_SITE_ID);
9199
9569
  console.log(`[${VERTICAL_NAME}-plugin-install] Unzipping and merging plugin files...`);
9200
9570
  await unzipAndMergePluginFiles(env, PLUGIN_FILES_ZIP_URL);
9201
9571
  console.log(`