@wix/vibe-bookings-plugin 0.67.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
@@ -3115,14 +3115,15 @@ The \`BookingProvider\` uses \`createBookingLoader(rootRouteLoader)\` to combine
3115
3115
 
3116
3116
  All the routes from the bookings router are 100% width, no titles, no background, no padding nor margin outside of their content area. Each route includes a \`<BookingsBreadcrumbs>\` component that must be rendered with the appropriate \`BOOKINGS_ROUTES\` constant.
3117
3117
 
3118
- To add styling (padding, margins, background, titles), wrap each route element with a layout structure. For example:
3118
+ To add styling (padding, margins, background) to the first div (<div className="bg-background...">), wrap each route element with a layout structure.
3119
+ also for the header (<h1 className="font-heading ...">Select Service</h1>) set padding top and bottom so it will not be too close to the BookingsBreadcrumbs and the page.
3120
+ For example:
3119
3121
  \`\`\`tsx
3120
3122
  {
3121
3123
  path: 'services',
3122
3124
  element: (
3123
- <div className="... bg-background">
3124
- <BookingsBreadcrumbs currentPage={BOOKINGS_ROUTES.SERVICES} />
3125
- <div className="...">
3125
+ <div className="bg-background...">
3126
+ <BookingsBreadcrumbs currentPage={BOOKINGS_ROUTES.SERVICES} />
3126
3127
  <h1 className="font-heading ...">Select Service</h1>
3127
3128
  <ServiceListPageRoute slotsPagePath="/booking/slots" formPagePath="/booking/form" />
3128
3129
  </div>
@@ -4641,7 +4642,6 @@ function EventDefinition(type, isDomainEvent = false, transformations = (x) => x
4641
4642
  transformations
4642
4643
  });
4643
4644
  }
4644
- var SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
4645
4645
 
4646
4646
  // ../../../node_modules/@wix/sdk-runtime/build/utils.js
4647
4647
  function alignIfLegacy(url, type) {
@@ -6554,7 +6554,8 @@ function transformSDKAddressToRESTAddress(payload) {
6554
6554
  streetAddress: payload.streetAddress && {
6555
6555
  name: payload.streetAddress.name,
6556
6556
  number: payload.streetAddress.number,
6557
- apt: payload.streetAddress.apt
6557
+ apt: payload.streetAddress.apt,
6558
+ formattedAddressLine: payload.streetAddress.formattedAddressLine
6558
6559
  }
6559
6560
  });
6560
6561
  }
@@ -6567,7 +6568,8 @@ function transformRESTAddressToSDKAddress(payload) {
6567
6568
  streetAddress: payload.streetAddress && {
6568
6569
  name: payload.streetAddress.name,
6569
6570
  number: payload.streetAddress.number,
6570
- apt: payload.streetAddress.apt
6571
+ apt: payload.streetAddress.apt,
6572
+ formattedAddressLine: payload.streetAddress.formattedAddressLine
6571
6573
  },
6572
6574
  hint: payload.hint,
6573
6575
  city: payload.city,
@@ -10439,6 +10441,7 @@ __export(es_exports3, {
10439
10441
  onStaffMemberDeleted: () => onStaffMemberDeleted2,
10440
10442
  onStaffMemberDisconnectedFromUser: () => onStaffMemberDisconnectedFromUser2,
10441
10443
  onStaffMemberFullyCreated: () => onStaffMemberFullyCreated2,
10444
+ onStaffMemberTagsModified: () => onStaffMemberTagsModified2,
10442
10445
  onStaffMemberUpdated: () => onStaffMemberUpdated2,
10443
10446
  queryStaffMembers: () => queryStaffMembers4,
10444
10447
  removeStaffMemberFromTrashBin: () => removeStaffMemberFromTrashBin4,
@@ -12010,6 +12013,26 @@ var onStaffMemberFullyCreated = EventDefinition(
12010
12013
  ])
12011
12014
  )
12012
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
+ )();
12013
12036
  var onStaffMemberUpdated = EventDefinition(
12014
12037
  "wix.bookings.staff.v1.staff_member_updated",
12015
12038
  true,
@@ -12077,6 +12100,9 @@ var onStaffMemberDisconnectedFromUser2 = createEventModule(
12077
12100
  var onStaffMemberFullyCreated2 = createEventModule(
12078
12101
  onStaffMemberFullyCreated
12079
12102
  );
12103
+ var onStaffMemberTagsModified2 = createEventModule(
12104
+ onStaffMemberTagsModified
12105
+ );
12080
12106
  var onStaffMemberUpdated2 = createEventModule(
12081
12107
  onStaffMemberUpdated
12082
12108
  );
@@ -12505,6 +12531,17 @@ function mapServiceType(serviceType) {
12505
12531
  return es_exports2.ServiceType.APPOINTMENT;
12506
12532
  }
12507
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
+
12508
12545
  // ../../../node_modules/@wix/sdk/build/ambassador-modules.js
12509
12546
  var parseMethod = (method) => {
12510
12547
  switch (method) {
@@ -12647,9 +12684,229 @@ function objectToKeyValue(input) {
12647
12684
  return Object.entries(input).filter(([_, value]) => Boolean(value)).map(([key2, value]) => `${key2}=${value}`).join(",");
12648
12685
  }
12649
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
+
12650
12907
  // ../../../node_modules/@wix/sdk/build/rest-modules.js
12651
12908
  function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
12652
- return runWithoutContext(() => origFunc({
12909
+ return runWithoutContext2(() => origFunc({
12653
12910
  request: async (factory) => {
12654
12911
  const requestOptions = factory({
12655
12912
  host: options?.HTTPHost || DEFAULT_API_URL
@@ -12685,7 +12942,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler,
12685
12942
  requestId: res.headers.get("X-Wix-Request-Id"),
12686
12943
  details: dataError
12687
12944
  });
12688
- const transformedError = transformError(error);
12945
+ const transformedError = transformError2(error);
12689
12946
  errorHandler?.handleError(transformedError, {
12690
12947
  requestOptions: {
12691
12948
  url: request.url,
@@ -12873,7 +13130,7 @@ var ModifiedFieldsManipulator = class {
12873
13130
  current = current[parseInt(part, 10)];
12874
13131
  };
12875
13132
  const handleTransformedKeyName = (part, currentObj) => {
12876
- const transformedKey = part in RESTResponseToSDKResponseRenameMap ? RESTResponseToSDKResponseRenameMap[part] : void 0;
13133
+ const transformedKey = part in RESTResponseToSDKResponseRenameMap2 ? RESTResponseToSDKResponseRenameMap2[part] : void 0;
12877
13134
  if (transformedKey && transformedKey in currentObj) {
12878
13135
  transformedPath.push(transformedKey);
12879
13136
  current = currentObj[transformedKey];
@@ -13130,8 +13387,8 @@ function eventHandlersModules(getAuthStrategy) {
13130
13387
  })));
13131
13388
  },
13132
13389
  apps: {
13133
- AppInstalled: EventDefinition("AppInstalled")(),
13134
- AppRemoved: EventDefinition("AppRemoved")()
13390
+ AppInstalled: EventDefinition2("AppInstalled")(),
13391
+ AppRemoved: EventDefinition2("AppRemoved")()
13135
13392
  }
13136
13393
  };
13137
13394
  return {
@@ -13326,7 +13583,7 @@ function createClient(config) {
13326
13583
  }
13327
13584
  const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;
13328
13585
  const shouldUseCDN = config.useCDN === void 0 ? getAuthStrategy().shouldUseCDN : config.useCDN;
13329
- 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) => {
13330
13587
  const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);
13331
13588
  finalUrl.host = apiBaseUrl;
13332
13589
  finalUrl.protocol = "https";