@wix/vibe-bookings-plugin 0.68.0 → 0.70.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
@@ -4642,7 +4642,6 @@ function EventDefinition(type, isDomainEvent = false, transformations = (x) => x
4642
4642
  transformations
4643
4643
  });
4644
4644
  }
4645
- var SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
4646
4645
 
4647
4646
  // ../../../node_modules/@wix/sdk-runtime/build/utils.js
4648
4647
  function alignIfLegacy(url, type) {
@@ -6555,7 +6554,8 @@ function transformSDKAddressToRESTAddress(payload) {
6555
6554
  streetAddress: payload.streetAddress && {
6556
6555
  name: payload.streetAddress.name,
6557
6556
  number: payload.streetAddress.number,
6558
- apt: payload.streetAddress.apt
6557
+ apt: payload.streetAddress.apt,
6558
+ formattedAddressLine: payload.streetAddress.formattedAddressLine
6559
6559
  }
6560
6560
  });
6561
6561
  }
@@ -6568,7 +6568,8 @@ function transformRESTAddressToSDKAddress(payload) {
6568
6568
  streetAddress: payload.streetAddress && {
6569
6569
  name: payload.streetAddress.name,
6570
6570
  number: payload.streetAddress.number,
6571
- apt: payload.streetAddress.apt
6571
+ apt: payload.streetAddress.apt,
6572
+ formattedAddressLine: payload.streetAddress.formattedAddressLine
6572
6573
  },
6573
6574
  hint: payload.hint,
6574
6575
  city: payload.city,
@@ -10440,6 +10441,7 @@ __export(es_exports3, {
10440
10441
  onStaffMemberDeleted: () => onStaffMemberDeleted2,
10441
10442
  onStaffMemberDisconnectedFromUser: () => onStaffMemberDisconnectedFromUser2,
10442
10443
  onStaffMemberFullyCreated: () => onStaffMemberFullyCreated2,
10444
+ onStaffMemberTagsModified: () => onStaffMemberTagsModified2,
10443
10445
  onStaffMemberUpdated: () => onStaffMemberUpdated2,
10444
10446
  queryStaffMembers: () => queryStaffMembers4,
10445
10447
  removeStaffMemberFromTrashBin: () => removeStaffMemberFromTrashBin4,
@@ -12011,6 +12013,26 @@ var onStaffMemberFullyCreated = EventDefinition(
12011
12013
  ])
12012
12014
  )
12013
12015
  )();
12016
+ var onStaffMemberTagsModified = EventDefinition(
12017
+ "wix.bookings.staff.v1.staff_member_tags_modified",
12018
+ true,
12019
+ (event) => renameKeysFromRESTResponseToSDKResponse(
12020
+ transformPaths(event, [
12021
+ {
12022
+ transformFn: transformRESTTimestampToSDKTimestamp,
12023
+ paths: [
12024
+ { path: "data.staffMember.createdDate" },
12025
+ { path: "data.staffMember.updatedDate" },
12026
+ { path: "metadata.eventTime" }
12027
+ ]
12028
+ },
12029
+ {
12030
+ transformFn: transformRESTImageToSDKImage,
12031
+ paths: [{ path: "data.staffMember.mainMedia.image" }]
12032
+ }
12033
+ ])
12034
+ )
12035
+ )();
12014
12036
  var onStaffMemberUpdated = EventDefinition(
12015
12037
  "wix.bookings.staff.v1.staff_member_updated",
12016
12038
  true,
@@ -12078,6 +12100,9 @@ var onStaffMemberDisconnectedFromUser2 = createEventModule(
12078
12100
  var onStaffMemberFullyCreated2 = createEventModule(
12079
12101
  onStaffMemberFullyCreated
12080
12102
  );
12103
+ var onStaffMemberTagsModified2 = createEventModule(
12104
+ onStaffMemberTagsModified
12105
+ );
12081
12106
  var onStaffMemberUpdated2 = createEventModule(
12082
12107
  onStaffMemberUpdated
12083
12108
  );
@@ -12506,6 +12531,17 @@ function mapServiceType(serviceType) {
12506
12531
  return es_exports2.ServiceType.APPOINTMENT;
12507
12532
  }
12508
12533
 
12534
+ // ../../../node_modules/@wix/sdk/node_modules/@wix/sdk-types/build/index.mjs
12535
+ function EventDefinition2(type, isDomainEvent = false, transformations = (x) => x) {
12536
+ return () => ({
12537
+ __type: "event-definition",
12538
+ type,
12539
+ isDomainEvent,
12540
+ transformations
12541
+ });
12542
+ }
12543
+ var SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
12544
+
12509
12545
  // ../../../node_modules/@wix/sdk/build/ambassador-modules.js
12510
12546
  var parseMethod = (method) => {
12511
12547
  switch (method) {
@@ -12648,9 +12684,229 @@ function objectToKeyValue(input) {
12648
12684
  return Object.entries(input).filter(([_, value]) => Boolean(value)).map(([key2, value]) => `${key2}=${value}`).join(",");
12649
12685
  }
12650
12686
 
12687
+ // ../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/context.js
12688
+ function runWithoutContext2(fn) {
12689
+ const globalContext = globalThis.__wix_context__;
12690
+ const moduleContext = {
12691
+ client: wixContext.client,
12692
+ elevatedClient: wixContext.elevatedClient
12693
+ };
12694
+ let closureContext;
12695
+ globalThis.__wix_context__ = void 0;
12696
+ wixContext.client = void 0;
12697
+ wixContext.elevatedClient = void 0;
12698
+ if (typeof $wixContext !== "undefined") {
12699
+ closureContext = {
12700
+ client: $wixContext?.client,
12701
+ elevatedClient: $wixContext?.elevatedClient
12702
+ };
12703
+ delete $wixContext.client;
12704
+ delete $wixContext.elevatedClient;
12705
+ }
12706
+ try {
12707
+ return fn();
12708
+ } finally {
12709
+ globalThis.__wix_context__ = globalContext;
12710
+ wixContext.client = moduleContext.client;
12711
+ wixContext.elevatedClient = moduleContext.elevatedClient;
12712
+ if (typeof $wixContext !== "undefined") {
12713
+ $wixContext.client = closureContext.client;
12714
+ $wixContext.elevatedClient = closureContext.elevatedClient;
12715
+ }
12716
+ }
12717
+ }
12718
+
12719
+ // ../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/constants.js
12720
+ var RESTResponseToSDKResponseRenameMap2 = {
12721
+ id: "_id",
12722
+ createdDate: "_createdDate",
12723
+ updatedDate: "_updatedDate"
12724
+ };
12725
+
12726
+ // ../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/utils.js
12727
+ function constantCase2(input) {
12728
+ return split2(input).map((part) => part.toLocaleUpperCase()).join("_");
12729
+ }
12730
+ var SPLIT_LOWER_UPPER_RE2 = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu");
12731
+ var SPLIT_UPPER_UPPER_RE2 = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu");
12732
+ var SPLIT_REPLACE_VALUE2 = "$1\0$2";
12733
+ var DEFAULT_STRIP_REGEXP2 = /[^\p{L}\d]+/giu;
12734
+ function split2(value) {
12735
+ let result = value.trim();
12736
+ result = result.replace(SPLIT_LOWER_UPPER_RE2, SPLIT_REPLACE_VALUE2).replace(SPLIT_UPPER_UPPER_RE2, SPLIT_REPLACE_VALUE2);
12737
+ result = result.replace(DEFAULT_STRIP_REGEXP2, "\0");
12738
+ let start = 0;
12739
+ let end = result.length;
12740
+ while (result.charAt(start) === "\0") {
12741
+ start++;
12742
+ }
12743
+ if (start === end) {
12744
+ return [];
12745
+ }
12746
+ while (result.charAt(end - 1) === "\0") {
12747
+ end--;
12748
+ }
12749
+ return result.slice(start, end).split(/\0/g);
12750
+ }
12751
+
12752
+ // ../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/transform-error.js
12753
+ var isValidationError2 = (httpClientError) => "validationError" in (httpClientError.response?.data?.details ?? {});
12754
+ var isApplicationError2 = (httpClientError) => "applicationError" in (httpClientError.response?.data?.details ?? {});
12755
+ var isClientError2 = (httpClientError) => (httpClientError.response?.status ?? -1) >= 400 && (httpClientError.response?.status ?? -1) < 500;
12756
+ function transformError2(httpClientError, pathsToArguments = {
12757
+ explicitPathsToArguments: {},
12758
+ spreadPathsToArguments: {},
12759
+ singleArgumentUnchanged: false
12760
+ }, argumentNames = []) {
12761
+ if (typeof httpClientError !== "object" || httpClientError === null) {
12762
+ throw httpClientError;
12763
+ }
12764
+ if (isValidationError2(httpClientError)) {
12765
+ return buildValidationError2(httpClientError, pathsToArguments, argumentNames);
12766
+ }
12767
+ if (isApplicationError2(httpClientError)) {
12768
+ return buildApplicationError2(httpClientError);
12769
+ }
12770
+ if (isClientError2(httpClientError)) {
12771
+ const status = httpClientError.response?.status;
12772
+ const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
12773
+ const message = httpClientError.response?.data?.message ?? statusText;
12774
+ const details = {
12775
+ applicationError: {
12776
+ description: statusText,
12777
+ code: constantCase2(statusText),
12778
+ data: {}
12779
+ },
12780
+ requestId: httpClientError.requestId
12781
+ };
12782
+ return wrapError2(httpClientError, {
12783
+ message: JSON.stringify({
12784
+ message,
12785
+ details
12786
+ }, null, 2),
12787
+ extraProperties: {
12788
+ details,
12789
+ status
12790
+ }
12791
+ });
12792
+ }
12793
+ return buildSystemError2(httpClientError);
12794
+ }
12795
+ var buildValidationError2 = (httpClientError, pathsToArguments, argumentNames) => {
12796
+ const validationErrorResponse = httpClientError.response?.data;
12797
+ const requestId = httpClientError.requestId;
12798
+ const { fieldViolations } = validationErrorResponse.details.validationError;
12799
+ const transformedFieldViolations = violationsWithRenamedFields2(pathsToArguments, fieldViolations, argumentNames)?.sort((a, b) => a.field < b.field ? -1 : 1);
12800
+ const message = `INVALID_ARGUMENT: ${transformedFieldViolations?.map(({ field, description }) => `"${field}" ${description}`)?.join(", ")}`;
12801
+ const details = {
12802
+ validationError: { fieldViolations: transformedFieldViolations },
12803
+ requestId
12804
+ };
12805
+ return wrapError2(httpClientError, {
12806
+ message: JSON.stringify({ message, details }, null, 2),
12807
+ extraProperties: {
12808
+ details,
12809
+ status: httpClientError.response?.status,
12810
+ requestId
12811
+ }
12812
+ });
12813
+ };
12814
+ var wrapError2 = (baseError, { message, extraProperties }) => {
12815
+ return Object.assign(baseError, {
12816
+ ...extraProperties,
12817
+ message
12818
+ });
12819
+ };
12820
+ var buildApplicationError2 = (httpClientError) => {
12821
+ const status = httpClientError.response?.status;
12822
+ const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
12823
+ const message = httpClientError.response?.data?.message ?? statusText;
12824
+ const description = httpClientError.response?.data?.details?.applicationError?.description ?? statusText;
12825
+ const code = httpClientError.response?.data?.details?.applicationError?.code ?? constantCase2(statusText);
12826
+ const data = httpClientError.response?.data?.details?.applicationError?.data ?? {};
12827
+ const combinedMessage = message === description ? message : `${message}: ${description}`;
12828
+ const details = {
12829
+ applicationError: {
12830
+ description,
12831
+ code,
12832
+ data
12833
+ },
12834
+ requestId: httpClientError.requestId
12835
+ };
12836
+ return wrapError2(httpClientError, {
12837
+ message: JSON.stringify({ message: combinedMessage, details }, null, 2),
12838
+ extraProperties: {
12839
+ details,
12840
+ status,
12841
+ requestId: httpClientError.requestId
12842
+ }
12843
+ });
12844
+ };
12845
+ var buildSystemError2 = (httpClientError) => {
12846
+ const message = httpClientError.requestId ? `System error occurred, request-id: ${httpClientError.requestId}` : `System error occurred: ${JSON.stringify(httpClientError)}`;
12847
+ return wrapError2(httpClientError, {
12848
+ message,
12849
+ extraProperties: {
12850
+ requestId: httpClientError.requestId,
12851
+ status: httpClientError.response?.status,
12852
+ code: constantCase2(httpClientError.response?.statusText ?? "UNKNOWN"),
12853
+ ...!httpClientError.response && {
12854
+ runtimeError: httpClientError
12855
+ }
12856
+ }
12857
+ });
12858
+ };
12859
+ var violationsWithRenamedFields2 = ({ spreadPathsToArguments, explicitPathsToArguments, singleArgumentUnchanged }, fieldViolations, argumentNames) => {
12860
+ const allPathsToArguments = {
12861
+ ...spreadPathsToArguments,
12862
+ ...explicitPathsToArguments
12863
+ };
12864
+ const allPathsToArgumentsKeys = Object.keys(allPathsToArguments);
12865
+ return fieldViolations?.filter((fieldViolation) => {
12866
+ const containedInAMoreSpecificViolationField = fieldViolations.some((anotherViolation) => anotherViolation.field.length > fieldViolation.field.length && anotherViolation.field.startsWith(fieldViolation.field) && allPathsToArgumentsKeys.includes(anotherViolation.field));
12867
+ return !containedInAMoreSpecificViolationField;
12868
+ }).map((fieldViolation) => {
12869
+ const exactMatchArgumentExpression = explicitPathsToArguments[fieldViolation.field];
12870
+ if (exactMatchArgumentExpression) {
12871
+ return {
12872
+ ...fieldViolation,
12873
+ field: withRenamedArgument2(exactMatchArgumentExpression, argumentNames)
12874
+ };
12875
+ }
12876
+ const longestPartialPathMatch = allPathsToArgumentsKeys?.sort((a, b) => b.length - a.length)?.find((path2) => fieldViolation.field.startsWith(path2));
12877
+ if (longestPartialPathMatch) {
12878
+ const partialMatchArgumentExpression = allPathsToArguments[longestPartialPathMatch];
12879
+ if (partialMatchArgumentExpression) {
12880
+ return {
12881
+ ...fieldViolation,
12882
+ field: fieldViolation.field.replace(longestPartialPathMatch, withRenamedArgument2(partialMatchArgumentExpression, argumentNames))
12883
+ };
12884
+ }
12885
+ }
12886
+ if (singleArgumentUnchanged) {
12887
+ return {
12888
+ ...fieldViolation,
12889
+ field: `${argumentNames[0]}.${fieldViolation.field}`
12890
+ };
12891
+ }
12892
+ return fieldViolation;
12893
+ });
12894
+ };
12895
+ var withRenamedArgument2 = (fieldValue, argumentNames) => {
12896
+ const argIndex = getArgumentIndex2(fieldValue);
12897
+ if (argIndex !== null && typeof argIndex !== "undefined") {
12898
+ return fieldValue.replace(`$[${argIndex}]`, argumentNames[argIndex]);
12899
+ }
12900
+ return fieldValue;
12901
+ };
12902
+ var getArgumentIndex2 = (s) => {
12903
+ const match = s.match(/\$\[(?<argIndex>\d+)\]/);
12904
+ return match && match.groups && Number(match.groups.argIndex);
12905
+ };
12906
+
12651
12907
  // ../../../node_modules/@wix/sdk/build/rest-modules.js
12652
12908
  function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
12653
- return runWithoutContext(() => origFunc({
12909
+ return runWithoutContext2(() => origFunc({
12654
12910
  request: async (factory) => {
12655
12911
  const requestOptions = factory({
12656
12912
  host: options?.HTTPHost || DEFAULT_API_URL
@@ -12686,7 +12942,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler,
12686
12942
  requestId: res.headers.get("X-Wix-Request-Id"),
12687
12943
  details: dataError
12688
12944
  });
12689
- const transformedError = transformError(error);
12945
+ const transformedError = transformError2(error);
12690
12946
  errorHandler?.handleError(transformedError, {
12691
12947
  requestOptions: {
12692
12948
  url: request.url,
@@ -12874,7 +13130,7 @@ var ModifiedFieldsManipulator = class {
12874
13130
  current = current[parseInt(part, 10)];
12875
13131
  };
12876
13132
  const handleTransformedKeyName = (part, currentObj) => {
12877
- const transformedKey = part in RESTResponseToSDKResponseRenameMap ? RESTResponseToSDKResponseRenameMap[part] : void 0;
13133
+ const transformedKey = part in RESTResponseToSDKResponseRenameMap2 ? RESTResponseToSDKResponseRenameMap2[part] : void 0;
12878
13134
  if (transformedKey && transformedKey in currentObj) {
12879
13135
  transformedPath.push(transformedKey);
12880
13136
  current = currentObj[transformedKey];
@@ -13131,8 +13387,8 @@ function eventHandlersModules(getAuthStrategy) {
13131
13387
  })));
13132
13388
  },
13133
13389
  apps: {
13134
- AppInstalled: EventDefinition("AppInstalled")(),
13135
- AppRemoved: EventDefinition("AppRemoved")()
13390
+ AppInstalled: EventDefinition2("AppInstalled")(),
13391
+ AppRemoved: EventDefinition2("AppRemoved")()
13136
13392
  }
13137
13393
  };
13138
13394
  return {
@@ -13327,7 +13583,7 @@ function createClient(config) {
13327
13583
  }
13328
13584
  const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;
13329
13585
  const shouldUseCDN = config.useCDN === void 0 ? getAuthStrategy().shouldUseCDN : config.useCDN;
13330
- return buildRESTDescriptor(runWithoutContext(() => isAmbassadorModule(modules)) ? toHTTPModule(modules) : modules, metadata ?? {}, boundFetch, config.host?.getErrorHandler?.(), (relativeUrl, fetchOptions) => {
13586
+ return buildRESTDescriptor(runWithoutContext2(() => isAmbassadorModule(modules)) ? toHTTPModule(modules) : modules, metadata ?? {}, boundFetch, config.host?.getErrorHandler?.(), (relativeUrl, fetchOptions) => {
13331
13587
  const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);
13332
13588
  finalUrl.host = apiBaseUrl;
13333
13589
  finalUrl.protocol = "https";