@wix/vibe-bookings-plugin 0.25.0 → 0.27.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 +367 -280
- package/dist/index.cjs.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -46,7 +46,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
46
46
|
|
|
47
47
|
// ../../../packages/vibe-plugin-utils/dist/index.cjs
|
|
48
48
|
var require_dist = __commonJS({
|
|
49
|
-
"../../../packages/vibe-plugin-utils/dist/index.cjs"(exports) {
|
|
49
|
+
"../../../packages/vibe-plugin-utils/dist/index.cjs"(exports$1) {
|
|
50
50
|
var fs = __require("fs");
|
|
51
51
|
var path2 = __require("path");
|
|
52
52
|
var https = __require("https");
|
|
@@ -107,7 +107,7 @@ var require_dist = __commonJS({
|
|
|
107
107
|
mod
|
|
108
108
|
));
|
|
109
109
|
var require_constants = __commonJS2({
|
|
110
|
-
"../../node_modules/adm-zip/util/constants.js"(
|
|
110
|
+
"../../node_modules/adm-zip/util/constants.js"(exports$1, module2) {
|
|
111
111
|
module2.exports = {
|
|
112
112
|
/* The local file header */
|
|
113
113
|
LOCHDR: 30,
|
|
@@ -324,7 +324,7 @@ var require_dist = __commonJS({
|
|
|
324
324
|
}
|
|
325
325
|
});
|
|
326
326
|
var require_errors = __commonJS2({
|
|
327
|
-
"../../node_modules/adm-zip/util/errors.js"(
|
|
327
|
+
"../../node_modules/adm-zip/util/errors.js"(exports$1) {
|
|
328
328
|
var errors = {
|
|
329
329
|
/* Header error messages */
|
|
330
330
|
INVALID_LOC: "Invalid LOC header (bad signature)",
|
|
@@ -377,12 +377,12 @@ var require_dist = __commonJS({
|
|
|
377
377
|
};
|
|
378
378
|
}
|
|
379
379
|
for (const msg of Object.keys(errors)) {
|
|
380
|
-
|
|
380
|
+
exports$1[msg] = E(errors[msg]);
|
|
381
381
|
}
|
|
382
382
|
}
|
|
383
383
|
});
|
|
384
384
|
var require_utils = __commonJS2({
|
|
385
|
-
"../../node_modules/adm-zip/util/utils.js"(
|
|
385
|
+
"../../node_modules/adm-zip/util/utils.js"(exports$1, module2) {
|
|
386
386
|
var fsystem = __require2("fs");
|
|
387
387
|
var pth = __require2("path");
|
|
388
388
|
var Constants = require_constants();
|
|
@@ -634,7 +634,7 @@ var require_dist = __commonJS({
|
|
|
634
634
|
}
|
|
635
635
|
});
|
|
636
636
|
var require_fattr = __commonJS2({
|
|
637
|
-
"../../node_modules/adm-zip/util/fattr.js"(
|
|
637
|
+
"../../node_modules/adm-zip/util/fattr.js"(exports$1, module2) {
|
|
638
638
|
var pth = __require2("path");
|
|
639
639
|
module2.exports = function(path22, { fs: fs2 }) {
|
|
640
640
|
var _path = path22 || "", _obj = newAttr(), _stat = null;
|
|
@@ -701,7 +701,7 @@ var require_dist = __commonJS({
|
|
|
701
701
|
}
|
|
702
702
|
});
|
|
703
703
|
var require_decoder = __commonJS2({
|
|
704
|
-
"../../node_modules/adm-zip/util/decoder.js"(
|
|
704
|
+
"../../node_modules/adm-zip/util/decoder.js"(exports$1, module2) {
|
|
705
705
|
module2.exports = {
|
|
706
706
|
efs: true,
|
|
707
707
|
encode: (data) => Buffer.from(data, "utf8"),
|
|
@@ -710,7 +710,7 @@ var require_dist = __commonJS({
|
|
|
710
710
|
}
|
|
711
711
|
});
|
|
712
712
|
var require_util = __commonJS2({
|
|
713
|
-
"../../node_modules/adm-zip/util/index.js"(
|
|
713
|
+
"../../node_modules/adm-zip/util/index.js"(exports$1, module2) {
|
|
714
714
|
module2.exports = require_utils();
|
|
715
715
|
module2.exports.Constants = require_constants();
|
|
716
716
|
module2.exports.Errors = require_errors();
|
|
@@ -719,7 +719,7 @@ var require_dist = __commonJS({
|
|
|
719
719
|
}
|
|
720
720
|
});
|
|
721
721
|
var require_entryHeader = __commonJS2({
|
|
722
|
-
"../../node_modules/adm-zip/headers/entryHeader.js"(
|
|
722
|
+
"../../node_modules/adm-zip/headers/entryHeader.js"(exports$1, module2) {
|
|
723
723
|
var Utils = require_util();
|
|
724
724
|
var Constants = Utils.Constants;
|
|
725
725
|
module2.exports = function() {
|
|
@@ -984,7 +984,7 @@ var require_dist = __commonJS({
|
|
|
984
984
|
}
|
|
985
985
|
});
|
|
986
986
|
var require_mainHeader = __commonJS2({
|
|
987
|
-
"../../node_modules/adm-zip/headers/mainHeader.js"(
|
|
987
|
+
"../../node_modules/adm-zip/headers/mainHeader.js"(exports$1, module2) {
|
|
988
988
|
var Utils = require_util();
|
|
989
989
|
var Constants = Utils.Constants;
|
|
990
990
|
module2.exports = function() {
|
|
@@ -1075,13 +1075,13 @@ var require_dist = __commonJS({
|
|
|
1075
1075
|
}
|
|
1076
1076
|
});
|
|
1077
1077
|
var require_headers = __commonJS2({
|
|
1078
|
-
"../../node_modules/adm-zip/headers/index.js"(
|
|
1079
|
-
|
|
1080
|
-
|
|
1078
|
+
"../../node_modules/adm-zip/headers/index.js"(exports$1) {
|
|
1079
|
+
exports$1.EntryHeader = require_entryHeader();
|
|
1080
|
+
exports$1.MainHeader = require_mainHeader();
|
|
1081
1081
|
}
|
|
1082
1082
|
});
|
|
1083
1083
|
var require_deflater = __commonJS2({
|
|
1084
|
-
"../../node_modules/adm-zip/methods/deflater.js"(
|
|
1084
|
+
"../../node_modules/adm-zip/methods/deflater.js"(exports$1, module2) {
|
|
1085
1085
|
module2.exports = function(inbuf) {
|
|
1086
1086
|
var zlib = __require2("zlib");
|
|
1087
1087
|
var opts = { chunkSize: (parseInt(inbuf.length / 1024) + 1) * 1024 };
|
|
@@ -1112,7 +1112,7 @@ var require_dist = __commonJS({
|
|
|
1112
1112
|
}
|
|
1113
1113
|
});
|
|
1114
1114
|
var require_inflater = __commonJS2({
|
|
1115
|
-
"../../node_modules/adm-zip/methods/inflater.js"(
|
|
1115
|
+
"../../node_modules/adm-zip/methods/inflater.js"(exports$1, module2) {
|
|
1116
1116
|
var version = +(process.versions ? process.versions.node : "").split(".")[0] || 0;
|
|
1117
1117
|
module2.exports = function(inbuf, expectedLength) {
|
|
1118
1118
|
var zlib = __require2("zlib");
|
|
@@ -1144,7 +1144,7 @@ var require_dist = __commonJS({
|
|
|
1144
1144
|
}
|
|
1145
1145
|
});
|
|
1146
1146
|
var require_zipcrypto = __commonJS2({
|
|
1147
|
-
"../../node_modules/adm-zip/methods/zipcrypto.js"(
|
|
1147
|
+
"../../node_modules/adm-zip/methods/zipcrypto.js"(exports$1, module2) {
|
|
1148
1148
|
var { randomFillSync } = __require2("crypto");
|
|
1149
1149
|
var Errors = require_errors();
|
|
1150
1150
|
var crctable = new Uint32Array(256).map((t, crc) => {
|
|
@@ -1257,14 +1257,14 @@ var require_dist = __commonJS({
|
|
|
1257
1257
|
}
|
|
1258
1258
|
});
|
|
1259
1259
|
var require_methods = __commonJS2({
|
|
1260
|
-
"../../node_modules/adm-zip/methods/index.js"(
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1260
|
+
"../../node_modules/adm-zip/methods/index.js"(exports$1) {
|
|
1261
|
+
exports$1.Deflater = require_deflater();
|
|
1262
|
+
exports$1.Inflater = require_inflater();
|
|
1263
|
+
exports$1.ZipCrypto = require_zipcrypto();
|
|
1264
1264
|
}
|
|
1265
1265
|
});
|
|
1266
1266
|
var require_zipEntry = __commonJS2({
|
|
1267
|
-
"../../node_modules/adm-zip/zipEntry.js"(
|
|
1267
|
+
"../../node_modules/adm-zip/zipEntry.js"(exports$1, module2) {
|
|
1268
1268
|
var Utils = require_util();
|
|
1269
1269
|
var Headers = require_headers();
|
|
1270
1270
|
var Constants = Utils.Constants;
|
|
@@ -1593,7 +1593,7 @@ var require_dist = __commonJS({
|
|
|
1593
1593
|
}
|
|
1594
1594
|
});
|
|
1595
1595
|
var require_zipFile = __commonJS2({
|
|
1596
|
-
"../../node_modules/adm-zip/zipFile.js"(
|
|
1596
|
+
"../../node_modules/adm-zip/zipFile.js"(exports$1, module2) {
|
|
1597
1597
|
var ZipEntry = require_zipEntry();
|
|
1598
1598
|
var Headers = require_headers();
|
|
1599
1599
|
var Utils = require_util();
|
|
@@ -1936,7 +1936,7 @@ var require_dist = __commonJS({
|
|
|
1936
1936
|
}
|
|
1937
1937
|
});
|
|
1938
1938
|
var require_adm_zip = __commonJS2({
|
|
1939
|
-
"../../node_modules/adm-zip/adm-zip.js"(
|
|
1939
|
+
"../../node_modules/adm-zip/adm-zip.js"(exports$1, module2) {
|
|
1940
1940
|
var Utils = require_util();
|
|
1941
1941
|
var pth = __require2("path");
|
|
1942
1942
|
var ZipEntry = require_zipEntry();
|
|
@@ -2836,9 +2836,9 @@ var require_dist = __commonJS({
|
|
|
2836
2836
|
throw error;
|
|
2837
2837
|
}
|
|
2838
2838
|
}
|
|
2839
|
-
exports.downloadZipFile = downloadZipFile;
|
|
2840
|
-
exports.getPluginFilesVersion = getPluginFilesVersion2;
|
|
2841
|
-
exports.unzipAndMergePluginFiles = unzipAndMergePluginFiles2;
|
|
2839
|
+
exports$1.downloadZipFile = downloadZipFile;
|
|
2840
|
+
exports$1.getPluginFilesVersion = getPluginFilesVersion2;
|
|
2841
|
+
exports$1.unzipAndMergePluginFiles = unzipAndMergePluginFiles2;
|
|
2842
2842
|
}
|
|
2843
2843
|
});
|
|
2844
2844
|
|
|
@@ -2907,6 +2907,7 @@ function createDedent(options) {
|
|
|
2907
2907
|
function dedent2(strings, ...values) {
|
|
2908
2908
|
const raw = typeof strings === "string" ? [strings] : strings.raw;
|
|
2909
2909
|
const {
|
|
2910
|
+
alignValues = false,
|
|
2910
2911
|
escapeSpecialCharacters = Array.isArray(strings),
|
|
2911
2912
|
trimWhitespace = true
|
|
2912
2913
|
} = options;
|
|
@@ -2918,7 +2919,8 @@ function createDedent(options) {
|
|
|
2918
2919
|
}
|
|
2919
2920
|
result += next;
|
|
2920
2921
|
if (i < values.length) {
|
|
2921
|
-
result
|
|
2922
|
+
const value = alignValues ? alignValue(values[i], result) : values[i];
|
|
2923
|
+
result += value;
|
|
2922
2924
|
}
|
|
2923
2925
|
}
|
|
2924
2926
|
const lines = result.split("\n");
|
|
@@ -2947,6 +2949,19 @@ function createDedent(options) {
|
|
|
2947
2949
|
return result;
|
|
2948
2950
|
}
|
|
2949
2951
|
}
|
|
2952
|
+
function alignValue(value, precedingText) {
|
|
2953
|
+
if (typeof value !== "string" || !value.includes("\n")) {
|
|
2954
|
+
return value;
|
|
2955
|
+
}
|
|
2956
|
+
const currentLine = precedingText.slice(precedingText.lastIndexOf("\n") + 1);
|
|
2957
|
+
const indentMatch = currentLine.match(/^(\s+)/);
|
|
2958
|
+
if (indentMatch) {
|
|
2959
|
+
const indent = indentMatch[1];
|
|
2960
|
+
return value.replace(/\n/g, `
|
|
2961
|
+
${indent}`);
|
|
2962
|
+
}
|
|
2963
|
+
return value;
|
|
2964
|
+
}
|
|
2950
2965
|
|
|
2951
2966
|
// src/services/instructions.service.ts
|
|
2952
2967
|
var getRouterFileContent = () => {
|
|
@@ -4477,17 +4492,29 @@ function renameAllNestedKeys(payload, renameMap, ignorePaths) {
|
|
|
4477
4492
|
if (isIgnored(newPath)) {
|
|
4478
4493
|
return;
|
|
4479
4494
|
}
|
|
4480
|
-
|
|
4481
|
-
|
|
4495
|
+
const transformedKey = renameKey(key2, renameMap);
|
|
4496
|
+
if (transformedKey !== key2 && !(transformedKey in objAsRecord)) {
|
|
4497
|
+
objAsRecord[transformedKey] = objAsRecord[key2];
|
|
4482
4498
|
delete objAsRecord[key2];
|
|
4483
4499
|
}
|
|
4484
|
-
traverse(objAsRecord[
|
|
4500
|
+
traverse(objAsRecord[transformedKey], newPath);
|
|
4485
4501
|
});
|
|
4486
4502
|
}
|
|
4487
4503
|
};
|
|
4488
4504
|
traverse(payload, "");
|
|
4489
4505
|
return payload;
|
|
4490
4506
|
}
|
|
4507
|
+
function renameKey(key2, renameMap) {
|
|
4508
|
+
let transformedKey;
|
|
4509
|
+
if (key2.includes(".")) {
|
|
4510
|
+
const parts = key2.split(".");
|
|
4511
|
+
const transformedParts = parts.map((part) => renameMap[part] ?? part);
|
|
4512
|
+
transformedKey = transformedParts.join(".");
|
|
4513
|
+
} else {
|
|
4514
|
+
transformedKey = renameMap[key2] ?? key2;
|
|
4515
|
+
}
|
|
4516
|
+
return transformedKey;
|
|
4517
|
+
}
|
|
4491
4518
|
function renameKeysFromSDKRequestToRESTRequest(payload, ignorePaths = []) {
|
|
4492
4519
|
return renameAllNestedKeys(payload, SDKRequestToRESTRequestRenameMap, ignorePaths);
|
|
4493
4520
|
}
|
|
@@ -4542,6 +4569,7 @@ function EventDefinition(type, isDomainEvent = false, transformations = (x) => x
|
|
|
4542
4569
|
transformations
|
|
4543
4570
|
});
|
|
4544
4571
|
}
|
|
4572
|
+
var SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
|
|
4545
4573
|
|
|
4546
4574
|
// ../../../node_modules/@wix/sdk-runtime/build/utils.js
|
|
4547
4575
|
function alignIfLegacy(url, type) {
|
|
@@ -12085,7 +12113,7 @@ createEventModule(
|
|
|
12085
12113
|
onCategoryNotification
|
|
12086
12114
|
);
|
|
12087
12115
|
|
|
12088
|
-
// node_modules/@wix/auto_sdk_bookings_bookings/build/es/index.mjs
|
|
12116
|
+
// ../../../node_modules/@wix/auto_sdk_bookings_bookings/build/es/index.mjs
|
|
12089
12117
|
var onBookingCanceled = EventDefinition(
|
|
12090
12118
|
"wix.bookings.v2.booking_canceled",
|
|
12091
12119
|
true,
|
|
@@ -12362,7 +12390,7 @@ function mapBookingServiceDetailsToServerService(details) {
|
|
|
12362
12390
|
custom: {
|
|
12363
12391
|
address: {
|
|
12364
12392
|
addressLine: "Business location",
|
|
12365
|
-
|
|
12393
|
+
formatted: "Business location"
|
|
12366
12394
|
}
|
|
12367
12395
|
}
|
|
12368
12396
|
}
|
|
@@ -12402,21 +12430,10 @@ function mapBookingServiceDetailsToServerService(details) {
|
|
|
12402
12430
|
service.defaultCapacity = defaultCapacity;
|
|
12403
12431
|
return service;
|
|
12404
12432
|
}
|
|
12405
|
-
function mapServiceType() {
|
|
12433
|
+
function mapServiceType(serviceType) {
|
|
12406
12434
|
return es_exports2.ServiceType.APPOINTMENT;
|
|
12407
12435
|
}
|
|
12408
12436
|
|
|
12409
|
-
// ../../../node_modules/@wix/sdk/node_modules/@wix/sdk-types/build/index.mjs
|
|
12410
|
-
function EventDefinition2(type, isDomainEvent = false, transformations = (x) => x) {
|
|
12411
|
-
return () => ({
|
|
12412
|
-
__type: "event-definition",
|
|
12413
|
-
type,
|
|
12414
|
-
isDomainEvent,
|
|
12415
|
-
transformations
|
|
12416
|
-
});
|
|
12417
|
-
}
|
|
12418
|
-
var SERVICE_PLUGIN_ERROR_TYPE = "wix_spi_error";
|
|
12419
|
-
|
|
12420
12437
|
// ../../../node_modules/@wix/sdk/build/ambassador-modules.js
|
|
12421
12438
|
var parseMethod = (method) => {
|
|
12422
12439
|
switch (method) {
|
|
@@ -12559,222 +12576,9 @@ function objectToKeyValue(input) {
|
|
|
12559
12576
|
return Object.entries(input).filter(([_, value]) => Boolean(value)).map(([key2, value]) => `${key2}=${value}`).join(",");
|
|
12560
12577
|
}
|
|
12561
12578
|
|
|
12562
|
-
// ../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/context.js
|
|
12563
|
-
function runWithoutContext2(fn) {
|
|
12564
|
-
const globalContext = globalThis.__wix_context__;
|
|
12565
|
-
const moduleContext = {
|
|
12566
|
-
client: wixContext.client,
|
|
12567
|
-
elevatedClient: wixContext.elevatedClient
|
|
12568
|
-
};
|
|
12569
|
-
let closureContext;
|
|
12570
|
-
globalThis.__wix_context__ = void 0;
|
|
12571
|
-
wixContext.client = void 0;
|
|
12572
|
-
wixContext.elevatedClient = void 0;
|
|
12573
|
-
if (typeof $wixContext !== "undefined") {
|
|
12574
|
-
closureContext = {
|
|
12575
|
-
client: $wixContext?.client,
|
|
12576
|
-
elevatedClient: $wixContext?.elevatedClient
|
|
12577
|
-
};
|
|
12578
|
-
delete $wixContext.client;
|
|
12579
|
-
delete $wixContext.elevatedClient;
|
|
12580
|
-
}
|
|
12581
|
-
try {
|
|
12582
|
-
return fn();
|
|
12583
|
-
} finally {
|
|
12584
|
-
globalThis.__wix_context__ = globalContext;
|
|
12585
|
-
wixContext.client = moduleContext.client;
|
|
12586
|
-
wixContext.elevatedClient = moduleContext.elevatedClient;
|
|
12587
|
-
if (typeof $wixContext !== "undefined") {
|
|
12588
|
-
$wixContext.client = closureContext.client;
|
|
12589
|
-
$wixContext.elevatedClient = closureContext.elevatedClient;
|
|
12590
|
-
}
|
|
12591
|
-
}
|
|
12592
|
-
}
|
|
12593
|
-
|
|
12594
|
-
// ../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/utils.js
|
|
12595
|
-
function constantCase2(input) {
|
|
12596
|
-
return split2(input).map((part) => part.toLocaleUpperCase()).join("_");
|
|
12597
|
-
}
|
|
12598
|
-
var SPLIT_LOWER_UPPER_RE2 = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu");
|
|
12599
|
-
var SPLIT_UPPER_UPPER_RE2 = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu");
|
|
12600
|
-
var SPLIT_REPLACE_VALUE2 = "$1\0$2";
|
|
12601
|
-
var DEFAULT_STRIP_REGEXP2 = /[^\p{L}\d]+/giu;
|
|
12602
|
-
function split2(value) {
|
|
12603
|
-
let result = value.trim();
|
|
12604
|
-
result = result.replace(SPLIT_LOWER_UPPER_RE2, SPLIT_REPLACE_VALUE2).replace(SPLIT_UPPER_UPPER_RE2, SPLIT_REPLACE_VALUE2);
|
|
12605
|
-
result = result.replace(DEFAULT_STRIP_REGEXP2, "\0");
|
|
12606
|
-
let start = 0;
|
|
12607
|
-
let end = result.length;
|
|
12608
|
-
while (result.charAt(start) === "\0") {
|
|
12609
|
-
start++;
|
|
12610
|
-
}
|
|
12611
|
-
if (start === end) {
|
|
12612
|
-
return [];
|
|
12613
|
-
}
|
|
12614
|
-
while (result.charAt(end - 1) === "\0") {
|
|
12615
|
-
end--;
|
|
12616
|
-
}
|
|
12617
|
-
return result.slice(start, end).split(/\0/g);
|
|
12618
|
-
}
|
|
12619
|
-
|
|
12620
|
-
// ../../../node_modules/@wix/sdk/node_modules/@wix/sdk-runtime/build/transform-error.js
|
|
12621
|
-
var isValidationError2 = (httpClientError) => "validationError" in (httpClientError.response?.data?.details ?? {});
|
|
12622
|
-
var isApplicationError2 = (httpClientError) => "applicationError" in (httpClientError.response?.data?.details ?? {});
|
|
12623
|
-
var isClientError2 = (httpClientError) => (httpClientError.response?.status ?? -1) >= 400 && (httpClientError.response?.status ?? -1) < 500;
|
|
12624
|
-
function transformError2(httpClientError, pathsToArguments = {
|
|
12625
|
-
explicitPathsToArguments: {},
|
|
12626
|
-
spreadPathsToArguments: {},
|
|
12627
|
-
singleArgumentUnchanged: false
|
|
12628
|
-
}, argumentNames = []) {
|
|
12629
|
-
if (typeof httpClientError !== "object" || httpClientError === null) {
|
|
12630
|
-
throw httpClientError;
|
|
12631
|
-
}
|
|
12632
|
-
if (isValidationError2(httpClientError)) {
|
|
12633
|
-
return buildValidationError2(httpClientError, pathsToArguments, argumentNames);
|
|
12634
|
-
}
|
|
12635
|
-
if (isApplicationError2(httpClientError)) {
|
|
12636
|
-
return buildApplicationError2(httpClientError);
|
|
12637
|
-
}
|
|
12638
|
-
if (isClientError2(httpClientError)) {
|
|
12639
|
-
const status = httpClientError.response?.status;
|
|
12640
|
-
const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
|
|
12641
|
-
const message = httpClientError.response?.data?.message ?? statusText;
|
|
12642
|
-
const details = {
|
|
12643
|
-
applicationError: {
|
|
12644
|
-
description: statusText,
|
|
12645
|
-
code: constantCase2(statusText),
|
|
12646
|
-
data: {}
|
|
12647
|
-
},
|
|
12648
|
-
requestId: httpClientError.requestId
|
|
12649
|
-
};
|
|
12650
|
-
return wrapError2(httpClientError, {
|
|
12651
|
-
message: JSON.stringify({
|
|
12652
|
-
message,
|
|
12653
|
-
details
|
|
12654
|
-
}, null, 2),
|
|
12655
|
-
extraProperties: {
|
|
12656
|
-
details,
|
|
12657
|
-
status
|
|
12658
|
-
}
|
|
12659
|
-
});
|
|
12660
|
-
}
|
|
12661
|
-
return buildSystemError2(httpClientError);
|
|
12662
|
-
}
|
|
12663
|
-
var buildValidationError2 = (httpClientError, pathsToArguments, argumentNames) => {
|
|
12664
|
-
const validationErrorResponse = httpClientError.response?.data;
|
|
12665
|
-
const requestId = httpClientError.requestId;
|
|
12666
|
-
const { fieldViolations } = validationErrorResponse.details.validationError;
|
|
12667
|
-
const transformedFieldViolations = violationsWithRenamedFields2(pathsToArguments, fieldViolations, argumentNames)?.sort((a, b) => a.field < b.field ? -1 : 1);
|
|
12668
|
-
const message = `INVALID_ARGUMENT: ${transformedFieldViolations?.map(({ field, description }) => `"${field}" ${description}`)?.join(", ")}`;
|
|
12669
|
-
const details = {
|
|
12670
|
-
validationError: { fieldViolations: transformedFieldViolations },
|
|
12671
|
-
requestId
|
|
12672
|
-
};
|
|
12673
|
-
return wrapError2(httpClientError, {
|
|
12674
|
-
message: JSON.stringify({ message, details }, null, 2),
|
|
12675
|
-
extraProperties: {
|
|
12676
|
-
details,
|
|
12677
|
-
status: httpClientError.response?.status,
|
|
12678
|
-
requestId
|
|
12679
|
-
}
|
|
12680
|
-
});
|
|
12681
|
-
};
|
|
12682
|
-
var wrapError2 = (baseError, { message, extraProperties }) => {
|
|
12683
|
-
return Object.assign(baseError, {
|
|
12684
|
-
...extraProperties,
|
|
12685
|
-
message
|
|
12686
|
-
});
|
|
12687
|
-
};
|
|
12688
|
-
var buildApplicationError2 = (httpClientError) => {
|
|
12689
|
-
const status = httpClientError.response?.status;
|
|
12690
|
-
const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
|
|
12691
|
-
const message = httpClientError.response?.data?.message ?? statusText;
|
|
12692
|
-
const description = httpClientError.response?.data?.details?.applicationError?.description ?? statusText;
|
|
12693
|
-
const code = httpClientError.response?.data?.details?.applicationError?.code ?? constantCase2(statusText);
|
|
12694
|
-
const data = httpClientError.response?.data?.details?.applicationError?.data ?? {};
|
|
12695
|
-
const combinedMessage = message === description ? message : `${message}: ${description}`;
|
|
12696
|
-
const details = {
|
|
12697
|
-
applicationError: {
|
|
12698
|
-
description,
|
|
12699
|
-
code,
|
|
12700
|
-
data
|
|
12701
|
-
},
|
|
12702
|
-
requestId: httpClientError.requestId
|
|
12703
|
-
};
|
|
12704
|
-
return wrapError2(httpClientError, {
|
|
12705
|
-
message: JSON.stringify({ message: combinedMessage, details }, null, 2),
|
|
12706
|
-
extraProperties: {
|
|
12707
|
-
details,
|
|
12708
|
-
status,
|
|
12709
|
-
requestId: httpClientError.requestId
|
|
12710
|
-
}
|
|
12711
|
-
});
|
|
12712
|
-
};
|
|
12713
|
-
var buildSystemError2 = (httpClientError) => {
|
|
12714
|
-
const message = httpClientError.requestId ? `System error occurred, request-id: ${httpClientError.requestId}` : `System error occurred: ${JSON.stringify(httpClientError)}`;
|
|
12715
|
-
return wrapError2(httpClientError, {
|
|
12716
|
-
message,
|
|
12717
|
-
extraProperties: {
|
|
12718
|
-
requestId: httpClientError.requestId,
|
|
12719
|
-
status: httpClientError.response?.status,
|
|
12720
|
-
code: constantCase2(httpClientError.response?.statusText ?? "UNKNOWN"),
|
|
12721
|
-
...!httpClientError.response && {
|
|
12722
|
-
runtimeError: httpClientError
|
|
12723
|
-
}
|
|
12724
|
-
}
|
|
12725
|
-
});
|
|
12726
|
-
};
|
|
12727
|
-
var violationsWithRenamedFields2 = ({ spreadPathsToArguments, explicitPathsToArguments, singleArgumentUnchanged }, fieldViolations, argumentNames) => {
|
|
12728
|
-
const allPathsToArguments = {
|
|
12729
|
-
...spreadPathsToArguments,
|
|
12730
|
-
...explicitPathsToArguments
|
|
12731
|
-
};
|
|
12732
|
-
const allPathsToArgumentsKeys = Object.keys(allPathsToArguments);
|
|
12733
|
-
return fieldViolations?.filter((fieldViolation) => {
|
|
12734
|
-
const containedInAMoreSpecificViolationField = fieldViolations.some((anotherViolation) => anotherViolation.field.length > fieldViolation.field.length && anotherViolation.field.startsWith(fieldViolation.field) && allPathsToArgumentsKeys.includes(anotherViolation.field));
|
|
12735
|
-
return !containedInAMoreSpecificViolationField;
|
|
12736
|
-
}).map((fieldViolation) => {
|
|
12737
|
-
const exactMatchArgumentExpression = explicitPathsToArguments[fieldViolation.field];
|
|
12738
|
-
if (exactMatchArgumentExpression) {
|
|
12739
|
-
return {
|
|
12740
|
-
...fieldViolation,
|
|
12741
|
-
field: withRenamedArgument2(exactMatchArgumentExpression, argumentNames)
|
|
12742
|
-
};
|
|
12743
|
-
}
|
|
12744
|
-
const longestPartialPathMatch = allPathsToArgumentsKeys?.sort((a, b) => b.length - a.length)?.find((path2) => fieldViolation.field.startsWith(path2));
|
|
12745
|
-
if (longestPartialPathMatch) {
|
|
12746
|
-
const partialMatchArgumentExpression = allPathsToArguments[longestPartialPathMatch];
|
|
12747
|
-
if (partialMatchArgumentExpression) {
|
|
12748
|
-
return {
|
|
12749
|
-
...fieldViolation,
|
|
12750
|
-
field: fieldViolation.field.replace(longestPartialPathMatch, withRenamedArgument2(partialMatchArgumentExpression, argumentNames))
|
|
12751
|
-
};
|
|
12752
|
-
}
|
|
12753
|
-
}
|
|
12754
|
-
if (singleArgumentUnchanged) {
|
|
12755
|
-
return {
|
|
12756
|
-
...fieldViolation,
|
|
12757
|
-
field: `${argumentNames[0]}.${fieldViolation.field}`
|
|
12758
|
-
};
|
|
12759
|
-
}
|
|
12760
|
-
return fieldViolation;
|
|
12761
|
-
});
|
|
12762
|
-
};
|
|
12763
|
-
var withRenamedArgument2 = (fieldValue, argumentNames) => {
|
|
12764
|
-
const argIndex = getArgumentIndex2(fieldValue);
|
|
12765
|
-
if (argIndex !== null && typeof argIndex !== "undefined") {
|
|
12766
|
-
return fieldValue.replace(`$[${argIndex}]`, argumentNames[argIndex]);
|
|
12767
|
-
}
|
|
12768
|
-
return fieldValue;
|
|
12769
|
-
};
|
|
12770
|
-
var getArgumentIndex2 = (s) => {
|
|
12771
|
-
const match = s.match(/\$\[(?<argIndex>\d+)\]/);
|
|
12772
|
-
return match && match.groups && Number(match.groups.argIndex);
|
|
12773
|
-
};
|
|
12774
|
-
|
|
12775
12579
|
// ../../../node_modules/@wix/sdk/build/rest-modules.js
|
|
12776
12580
|
function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler, wixAPIFetch, getActiveToken, options, hostName, useCDN) {
|
|
12777
|
-
return
|
|
12581
|
+
return runWithoutContext(() => origFunc({
|
|
12778
12582
|
request: async (factory) => {
|
|
12779
12583
|
const requestOptions = factory({
|
|
12780
12584
|
host: options?.HTTPHost || DEFAULT_API_URL
|
|
@@ -12810,7 +12614,7 @@ function buildRESTDescriptor(origFunc, publicMetadata, boundFetch, errorHandler,
|
|
|
12810
12614
|
requestId: res.headers.get("X-Wix-Request-Id"),
|
|
12811
12615
|
details: dataError
|
|
12812
12616
|
});
|
|
12813
|
-
const transformedError =
|
|
12617
|
+
const transformedError = transformError(error);
|
|
12814
12618
|
errorHandler?.handleError(transformedError, {
|
|
12815
12619
|
requestOptions: {
|
|
12816
12620
|
url: request.url,
|
|
@@ -12877,6 +12681,231 @@ var errorBuilder2 = (code, description, details, data) => {
|
|
|
12877
12681
|
});
|
|
12878
12682
|
};
|
|
12879
12683
|
|
|
12684
|
+
// ../../../node_modules/@wix/sdk/build/object-utils.js
|
|
12685
|
+
var DELIMITER = ".";
|
|
12686
|
+
function set(obj, path2, value) {
|
|
12687
|
+
if (obj == null) {
|
|
12688
|
+
throw new Error("Cannot set value on null or undefined");
|
|
12689
|
+
}
|
|
12690
|
+
const keys = toPathObject(path2);
|
|
12691
|
+
let current = obj;
|
|
12692
|
+
for (let i = 0; i < keys.length; i++) {
|
|
12693
|
+
const key2 = keys[i];
|
|
12694
|
+
if (i === keys.length - 1) {
|
|
12695
|
+
current[key2] = value;
|
|
12696
|
+
break;
|
|
12697
|
+
}
|
|
12698
|
+
const nextKey = keys[i + 1];
|
|
12699
|
+
if (!(key2 in current) || current[key2] == null) {
|
|
12700
|
+
current[key2] = typeof nextKey === "number" ? [] : {};
|
|
12701
|
+
} else if (typeof current[key2] !== "object" || current[key2] === null) {
|
|
12702
|
+
current[key2] = typeof nextKey === "number" ? [] : {};
|
|
12703
|
+
}
|
|
12704
|
+
current = current[key2];
|
|
12705
|
+
}
|
|
12706
|
+
return obj;
|
|
12707
|
+
}
|
|
12708
|
+
function toPathObject(path2) {
|
|
12709
|
+
if (Array.isArray(path2)) {
|
|
12710
|
+
return path2;
|
|
12711
|
+
}
|
|
12712
|
+
return path2.split(DELIMITER).map((segment) => isNumericSegment(segment) ? Number(segment) : segment);
|
|
12713
|
+
}
|
|
12714
|
+
function isNumericSegment(segment) {
|
|
12715
|
+
return /^\d+$/.test(segment);
|
|
12716
|
+
}
|
|
12717
|
+
|
|
12718
|
+
// ../../../node_modules/@wix/sdk/build/flat-utils.js
|
|
12719
|
+
function unflatten(flatObject) {
|
|
12720
|
+
const result = {};
|
|
12721
|
+
for (const [flatKey, value] of Object.entries(flatObject)) {
|
|
12722
|
+
if (isPrototypePollutionKey(flatKey)) {
|
|
12723
|
+
continue;
|
|
12724
|
+
}
|
|
12725
|
+
const path2 = toPathObject(flatKey);
|
|
12726
|
+
set(result, path2, value);
|
|
12727
|
+
}
|
|
12728
|
+
return result;
|
|
12729
|
+
}
|
|
12730
|
+
function isPrototypePollutionKey(key2) {
|
|
12731
|
+
return key2 === "__proto__" || key2 === "constructor" || key2 === "prototype";
|
|
12732
|
+
}
|
|
12733
|
+
|
|
12734
|
+
// ../../../node_modules/@wix/sdk/build/modified-fields-manipulator.js
|
|
12735
|
+
var ModifiedFieldsManipulator = class {
|
|
12736
|
+
BRACKET_PATTERN = /\[(\d+)\]/g;
|
|
12737
|
+
NUMERIC_PATTERN = /^\d+$/;
|
|
12738
|
+
ESCAPED_DOT_PATTERN = /\\\./g;
|
|
12739
|
+
ESCAPED_LEFT_BRACKET_PATTERN = /\\\[/g;
|
|
12740
|
+
ESCAPED_RIGHT_BRACKET_PATTERN = /\\\]/g;
|
|
12741
|
+
SPLIT_PATTERN = /\.|\[(\d+)\]/g;
|
|
12742
|
+
DOT_BEFORE_BRACKET_PATTERN = /\.\[/g;
|
|
12743
|
+
ESCAPED_DOT_PLACEHOLDER = "__DOT__";
|
|
12744
|
+
ESCAPED_RIGHT_BRACKET_PLACEHOLDER = "__RB__";
|
|
12745
|
+
ESCAPED_LEFT_BRACKET_PLACEHOLDER = "__LB__";
|
|
12746
|
+
modifiedFields;
|
|
12747
|
+
cleanedModifiedFields;
|
|
12748
|
+
constructor(modifiedFields) {
|
|
12749
|
+
this.modifiedFields = modifiedFields;
|
|
12750
|
+
}
|
|
12751
|
+
replaceEscapedCharacters(key2) {
|
|
12752
|
+
return key2.replace(this.ESCAPED_DOT_PATTERN, this.ESCAPED_DOT_PLACEHOLDER).replace(this.ESCAPED_LEFT_BRACKET_PATTERN, this.ESCAPED_LEFT_BRACKET_PLACEHOLDER).replace(this.ESCAPED_RIGHT_BRACKET_PATTERN, this.ESCAPED_RIGHT_BRACKET_PLACEHOLDER);
|
|
12753
|
+
}
|
|
12754
|
+
restoreEscapedCharacters(key2) {
|
|
12755
|
+
return key2.replace(this.ESCAPED_DOT_PLACEHOLDER, "\\.").replace(this.ESCAPED_RIGHT_BRACKET_PLACEHOLDER, "\\]").replace(this.ESCAPED_LEFT_BRACKET_PLACEHOLDER, "\\[");
|
|
12756
|
+
}
|
|
12757
|
+
unflatten() {
|
|
12758
|
+
this.cleanedModifiedFields = Object.fromEntries(Object.entries(this.modifiedFields).map(([key2, value]) => [
|
|
12759
|
+
this.replaceEscapedCharacters(this.bracketToDotNotation(key2)),
|
|
12760
|
+
value
|
|
12761
|
+
]));
|
|
12762
|
+
return unflatten(this.cleanedModifiedFields);
|
|
12763
|
+
}
|
|
12764
|
+
flatten(transformedModifiedFields) {
|
|
12765
|
+
let result = {};
|
|
12766
|
+
for (const originalKey of Object.keys(this.cleanedModifiedFields)) {
|
|
12767
|
+
const pathParts = this.splitPath(originalKey);
|
|
12768
|
+
const value = this.navigatePath(transformedModifiedFields, pathParts);
|
|
12769
|
+
result = { ...result, ...value };
|
|
12770
|
+
}
|
|
12771
|
+
return Object.fromEntries(Object.entries(result).map(([key2, value]) => [
|
|
12772
|
+
this.restoreEscapedCharacters(key2),
|
|
12773
|
+
value
|
|
12774
|
+
]));
|
|
12775
|
+
}
|
|
12776
|
+
splitPath(path2) {
|
|
12777
|
+
const parts = [];
|
|
12778
|
+
let lastIndex = 0;
|
|
12779
|
+
const matches = Array.from(path2.matchAll(this.SPLIT_PATTERN));
|
|
12780
|
+
for (const match of matches) {
|
|
12781
|
+
if (match.index > lastIndex) {
|
|
12782
|
+
parts.push(path2.substring(lastIndex, match.index));
|
|
12783
|
+
}
|
|
12784
|
+
if (match[1]) {
|
|
12785
|
+
parts.push(match[1]);
|
|
12786
|
+
}
|
|
12787
|
+
lastIndex = match.index + match[0].length;
|
|
12788
|
+
}
|
|
12789
|
+
if (lastIndex < path2.length) {
|
|
12790
|
+
parts.push(path2.substring(lastIndex));
|
|
12791
|
+
}
|
|
12792
|
+
return parts;
|
|
12793
|
+
}
|
|
12794
|
+
navigatePath(obj, pathParts) {
|
|
12795
|
+
let current = obj;
|
|
12796
|
+
const transformedPath = [];
|
|
12797
|
+
const handleArray = (part) => {
|
|
12798
|
+
if (!Array.isArray(current)) {
|
|
12799
|
+
throw new Error(`Expected array at path ${this.buildPathString(transformedPath)}, but got ${typeof current}`);
|
|
12800
|
+
}
|
|
12801
|
+
transformedPath.push(`[${part}]`);
|
|
12802
|
+
current = current[parseInt(part, 10)];
|
|
12803
|
+
};
|
|
12804
|
+
const handleTransformedKeyName = (part, currentObj) => {
|
|
12805
|
+
const transformedKey = part in RESTResponseToSDKResponseRenameMap ? RESTResponseToSDKResponseRenameMap[part] : void 0;
|
|
12806
|
+
if (transformedKey && transformedKey in currentObj) {
|
|
12807
|
+
transformedPath.push(transformedKey);
|
|
12808
|
+
current = currentObj[transformedKey];
|
|
12809
|
+
return;
|
|
12810
|
+
}
|
|
12811
|
+
const camelCaseKey = camelCase(part);
|
|
12812
|
+
if (camelCaseKey && camelCaseKey in currentObj) {
|
|
12813
|
+
transformedPath.push(camelCaseKey);
|
|
12814
|
+
current = currentObj[camelCaseKey];
|
|
12815
|
+
return;
|
|
12816
|
+
}
|
|
12817
|
+
throw new Error(`Cannot find key '${part}' or its transformations at path ${this.buildPathString(transformedPath)}`);
|
|
12818
|
+
};
|
|
12819
|
+
const handleObject = (part, currentObj) => {
|
|
12820
|
+
transformedPath.push(part);
|
|
12821
|
+
current = currentObj[part];
|
|
12822
|
+
return;
|
|
12823
|
+
};
|
|
12824
|
+
for (const part of pathParts) {
|
|
12825
|
+
if (this.NUMERIC_PATTERN.test(part)) {
|
|
12826
|
+
handleArray(part);
|
|
12827
|
+
continue;
|
|
12828
|
+
}
|
|
12829
|
+
if (current === null || typeof current !== "object") {
|
|
12830
|
+
throw new Error(`Cannot access property '${part}' on ${typeof current} at path ${this.buildPathString(transformedPath)}`);
|
|
12831
|
+
}
|
|
12832
|
+
const currentObj = current;
|
|
12833
|
+
if (part in current) {
|
|
12834
|
+
handleObject(part, currentObj);
|
|
12835
|
+
continue;
|
|
12836
|
+
}
|
|
12837
|
+
handleTransformedKeyName(part, currentObj);
|
|
12838
|
+
}
|
|
12839
|
+
return { [this.buildPathString(transformedPath)]: current };
|
|
12840
|
+
}
|
|
12841
|
+
buildPathString(pathParts) {
|
|
12842
|
+
return pathParts.join(".").replace(this.DOT_BEFORE_BRACKET_PATTERN, "[");
|
|
12843
|
+
}
|
|
12844
|
+
bracketToDotNotation(key2) {
|
|
12845
|
+
return key2.replace(this.BRACKET_PATTERN, (match, number, offset) => {
|
|
12846
|
+
if (offset > 0 && key2[offset - 1] === "\\") {
|
|
12847
|
+
return match;
|
|
12848
|
+
}
|
|
12849
|
+
return "." + number;
|
|
12850
|
+
});
|
|
12851
|
+
}
|
|
12852
|
+
};
|
|
12853
|
+
function attemptTransformationWithModifiedFields(envelope, transformFromRESTFn) {
|
|
12854
|
+
const modifiedFields = envelope?.modifiedFields;
|
|
12855
|
+
if (!modifiedFields) {
|
|
12856
|
+
return null;
|
|
12857
|
+
}
|
|
12858
|
+
const unflattenedResult = attemptUnflatten(modifiedFields);
|
|
12859
|
+
if (!unflattenedResult) {
|
|
12860
|
+
return null;
|
|
12861
|
+
}
|
|
12862
|
+
const { unflattenedModifiedFields, modifiedFieldsManipulator } = unflattenedResult;
|
|
12863
|
+
envelope = {
|
|
12864
|
+
...envelope,
|
|
12865
|
+
modifiedFields: unflattenedModifiedFields
|
|
12866
|
+
};
|
|
12867
|
+
const transformedEnvelope = transformFromRESTFn(envelope);
|
|
12868
|
+
const transformedModifiedFields = transformedEnvelope?.modifiedFields;
|
|
12869
|
+
if (!transformedModifiedFields) {
|
|
12870
|
+
return null;
|
|
12871
|
+
}
|
|
12872
|
+
const flattened = attemptFlatten(transformedModifiedFields, modifiedFieldsManipulator);
|
|
12873
|
+
if (flattened !== null) {
|
|
12874
|
+
transformedEnvelope.modifiedFields = flattened;
|
|
12875
|
+
return transformedEnvelope;
|
|
12876
|
+
}
|
|
12877
|
+
return null;
|
|
12878
|
+
}
|
|
12879
|
+
function attemptUnflatten(modifiedFields) {
|
|
12880
|
+
if (typeof modifiedFields === "object" && modifiedFields !== null && !Array.isArray(modifiedFields)) {
|
|
12881
|
+
try {
|
|
12882
|
+
const modifiedFieldsManipulator = new ModifiedFieldsManipulator(modifiedFields);
|
|
12883
|
+
const unflattened = modifiedFieldsManipulator.unflatten();
|
|
12884
|
+
return {
|
|
12885
|
+
unflattenedModifiedFields: unflattened,
|
|
12886
|
+
modifiedFieldsManipulator
|
|
12887
|
+
};
|
|
12888
|
+
} catch (error) {
|
|
12889
|
+
return null;
|
|
12890
|
+
}
|
|
12891
|
+
}
|
|
12892
|
+
return null;
|
|
12893
|
+
}
|
|
12894
|
+
function attemptFlatten(transformedModifiedFields, modifiedFieldsManipulator) {
|
|
12895
|
+
if (typeof transformedModifiedFields === "object" && transformedModifiedFields !== null && !Array.isArray(transformedModifiedFields)) {
|
|
12896
|
+
try {
|
|
12897
|
+
const flattened = modifiedFieldsManipulator.flatten(transformedModifiedFields);
|
|
12898
|
+
return flattened;
|
|
12899
|
+
} catch (error) {
|
|
12900
|
+
return null;
|
|
12901
|
+
}
|
|
12902
|
+
}
|
|
12903
|
+
return null;
|
|
12904
|
+
}
|
|
12905
|
+
function camelCase(str) {
|
|
12906
|
+
return str.replace(/[-_\s]+(.)?/g, (_, c2) => c2 ? c2.toUpperCase() : "").replace(/^./, (c2) => c2.toLowerCase());
|
|
12907
|
+
}
|
|
12908
|
+
|
|
12880
12909
|
// ../../../node_modules/@wix/sdk/build/nanoevents.js
|
|
12881
12910
|
function createNanoEvents() {
|
|
12882
12911
|
return {
|
|
@@ -12920,9 +12949,15 @@ function runHandler(eventDefinition, handler, payload, baseEventMetadata) {
|
|
|
12920
12949
|
data: actionEvent.body,
|
|
12921
12950
|
metadata
|
|
12922
12951
|
};
|
|
12952
|
+
} else if (updatedEvent) {
|
|
12953
|
+
envelope = {
|
|
12954
|
+
entity: updatedEvent.currentEntity,
|
|
12955
|
+
metadata,
|
|
12956
|
+
...updatedEvent.modifiedFields ? { modifiedFields: updatedEvent.modifiedFields } : {}
|
|
12957
|
+
};
|
|
12923
12958
|
} else {
|
|
12924
12959
|
envelope = {
|
|
12925
|
-
entity: createdEvent?.entity
|
|
12960
|
+
entity: createdEvent?.entity,
|
|
12926
12961
|
metadata
|
|
12927
12962
|
};
|
|
12928
12963
|
}
|
|
@@ -12933,9 +12968,21 @@ function runHandler(eventDefinition, handler, payload, baseEventMetadata) {
|
|
|
12933
12968
|
};
|
|
12934
12969
|
}
|
|
12935
12970
|
const transformFromRESTFn = eventDefinition.transformations ?? ((x) => x);
|
|
12936
|
-
|
|
12971
|
+
let originalEnvelope = envelope;
|
|
12972
|
+
const envelopeAny = envelope;
|
|
12973
|
+
if (envelopeAny.modifiedFields) {
|
|
12974
|
+
const modifiedFieldsValue = envelopeAny.modifiedFields;
|
|
12975
|
+
if (typeof modifiedFieldsValue === "object" && modifiedFieldsValue !== null && !Array.isArray(modifiedFieldsValue)) {
|
|
12976
|
+
originalEnvelope = structuredClone(envelope);
|
|
12977
|
+
const transformedEnvelope = attemptTransformationWithModifiedFields(envelopeAny, transformFromRESTFn);
|
|
12978
|
+
if (transformedEnvelope) {
|
|
12979
|
+
return handler(transformedEnvelope);
|
|
12980
|
+
}
|
|
12981
|
+
}
|
|
12982
|
+
}
|
|
12983
|
+
return handler(transformFromRESTFn(originalEnvelope));
|
|
12937
12984
|
}
|
|
12938
|
-
function eventHandlersModules(
|
|
12985
|
+
function eventHandlersModules(getAuthStrategy) {
|
|
12939
12986
|
const eventHandlers = /* @__PURE__ */ new Map();
|
|
12940
12987
|
const webhooksEmitter = createNanoEvents();
|
|
12941
12988
|
const client = {
|
|
@@ -12969,6 +13016,7 @@ function eventHandlersModules(authStrategy) {
|
|
|
12969
13016
|
return this.process(body, opts);
|
|
12970
13017
|
},
|
|
12971
13018
|
async parseJWT(jwt) {
|
|
13019
|
+
const authStrategy = getAuthStrategy();
|
|
12972
13020
|
if (!authStrategy.decodeJWT) {
|
|
12973
13021
|
throw new Error("decodeJWT is not supported by the authentication strategy");
|
|
12974
13022
|
}
|
|
@@ -13007,8 +13055,8 @@ function eventHandlersModules(authStrategy) {
|
|
|
13007
13055
|
})));
|
|
13008
13056
|
},
|
|
13009
13057
|
apps: {
|
|
13010
|
-
AppInstalled:
|
|
13011
|
-
AppRemoved:
|
|
13058
|
+
AppInstalled: EventDefinition("AppInstalled")(),
|
|
13059
|
+
AppRemoved: EventDefinition("AppRemoved")()
|
|
13012
13060
|
}
|
|
13013
13061
|
};
|
|
13014
13062
|
return {
|
|
@@ -13026,13 +13074,14 @@ function eventHandlersModules(authStrategy) {
|
|
|
13026
13074
|
|
|
13027
13075
|
// ../../../node_modules/@wix/sdk/build/service-plugin-modules.js
|
|
13028
13076
|
var isServicePluginModule = (val) => val.__type === "service-plugin-definition";
|
|
13029
|
-
function servicePluginsModules(
|
|
13077
|
+
function servicePluginsModules(getAuthStrategy) {
|
|
13030
13078
|
const servicePluginsImplementations = /* @__PURE__ */ new Map();
|
|
13031
13079
|
const servicePluginsEmitter = createNanoEvents();
|
|
13032
13080
|
const client = {
|
|
13033
13081
|
...servicePluginsEmitter,
|
|
13034
13082
|
getRegisteredServicePlugins: () => servicePluginsImplementations,
|
|
13035
13083
|
async parseJWT(jwt) {
|
|
13084
|
+
const authStrategy = getAuthStrategy();
|
|
13036
13085
|
if (!authStrategy.decodeJWT) {
|
|
13037
13086
|
throw new Error("decodeJWT is not supported by the authentication strategy");
|
|
13038
13087
|
}
|
|
@@ -13103,11 +13152,14 @@ function servicePluginsModules(authStrategy) {
|
|
|
13103
13152
|
var X_WIX_CONSISTENT_HEADER = "X-Wix-Consistent";
|
|
13104
13153
|
function createClient(config) {
|
|
13105
13154
|
const _headers = config.headers || { Authorization: "" };
|
|
13106
|
-
const
|
|
13155
|
+
const defaultStrategy = {
|
|
13107
13156
|
getAuthHeaders: (_) => Promise.resolve({ headers: {} })
|
|
13108
13157
|
};
|
|
13109
|
-
const
|
|
13110
|
-
|
|
13158
|
+
const auth = config.auth;
|
|
13159
|
+
const getAuthStrategy = typeof auth === "function" ? auth : () => auth ?? defaultStrategy;
|
|
13160
|
+
const boundGetAuthHeaders = () => {
|
|
13161
|
+
return getAuthStrategy().getAuthHeaders(config.host);
|
|
13162
|
+
};
|
|
13111
13163
|
const fetchWithAuth = async (urlOrRequest, requestInit) => {
|
|
13112
13164
|
const authHeaders = await boundGetAuthHeaders();
|
|
13113
13165
|
const headers = {
|
|
@@ -13163,8 +13215,8 @@ function createClient(config) {
|
|
|
13163
13215
|
throw e;
|
|
13164
13216
|
}
|
|
13165
13217
|
};
|
|
13166
|
-
const { client: servicePluginsClient, initModule: initServicePluginModule } = servicePluginsModules(
|
|
13167
|
-
const { client: eventHandlersClient, initModule: initEventHandlerModule } = eventHandlersModules(
|
|
13218
|
+
const { client: servicePluginsClient, initModule: initServicePluginModule } = servicePluginsModules(getAuthStrategy);
|
|
13219
|
+
const { client: eventHandlersClient, initModule: initEventHandlerModule } = eventHandlersModules(getAuthStrategy);
|
|
13168
13220
|
const boundFetch = async (url, options) => {
|
|
13169
13221
|
const authHeaders = await boundGetAuthHeaders();
|
|
13170
13222
|
const defaultContentTypeHeader = getDefaultContentHeader(options);
|
|
@@ -13198,13 +13250,13 @@ function createClient(config) {
|
|
|
13198
13250
|
return modules;
|
|
13199
13251
|
}
|
|
13200
13252
|
const apiBaseUrl = config.host?.apiBaseUrl ?? DEFAULT_API_URL;
|
|
13201
|
-
const shouldUseCDN = config.useCDN === void 0 ?
|
|
13202
|
-
return buildRESTDescriptor(
|
|
13253
|
+
const shouldUseCDN = config.useCDN === void 0 ? getAuthStrategy().shouldUseCDN : config.useCDN;
|
|
13254
|
+
return buildRESTDescriptor(runWithoutContext(() => isAmbassadorModule(modules)) ? toHTTPModule(modules) : modules, metadata ?? {}, boundFetch, config.host?.getErrorHandler?.(), (relativeUrl, fetchOptions) => {
|
|
13203
13255
|
const finalUrl = new URL(relativeUrl, `https://${apiBaseUrl}`);
|
|
13204
13256
|
finalUrl.host = apiBaseUrl;
|
|
13205
13257
|
finalUrl.protocol = "https";
|
|
13206
13258
|
return boundFetch(finalUrl.toString(), fetchOptions);
|
|
13207
|
-
},
|
|
13259
|
+
}, getAuthStrategy().getActiveToken, { HTTPHost: apiBaseUrl }, config.host?.name, shouldUseCDN);
|
|
13208
13260
|
} else if (isObject(modules)) {
|
|
13209
13261
|
return Object.fromEntries(Object.entries(modules).map(([key2, value]) => {
|
|
13210
13262
|
return [key2, use(value, modules[PUBLIC_METADATA_KEY])];
|
|
@@ -13221,7 +13273,12 @@ function createClient(config) {
|
|
|
13221
13273
|
const wrappedModules = config.modules ? use(config.modules) : {};
|
|
13222
13274
|
return {
|
|
13223
13275
|
...wrappedModules,
|
|
13224
|
-
auth
|
|
13276
|
+
get auth() {
|
|
13277
|
+
const authStrategy = getAuthStrategy();
|
|
13278
|
+
const originalGetAuthHeaders = authStrategy.getAuthHeaders;
|
|
13279
|
+
authStrategy.getAuthHeaders = originalGetAuthHeaders.bind(void 0, config.host);
|
|
13280
|
+
return authStrategy;
|
|
13281
|
+
},
|
|
13225
13282
|
setHeaders,
|
|
13226
13283
|
use,
|
|
13227
13284
|
enableContext(contextType, opts = { elevated: false }) {
|
|
@@ -13402,13 +13459,28 @@ var CategoriesAPIClient = class {
|
|
|
13402
13459
|
if (!client) {
|
|
13403
13460
|
return null;
|
|
13404
13461
|
}
|
|
13405
|
-
const response = await client.categoriesV2.queryCategories();
|
|
13406
|
-
|
|
13462
|
+
const response = await client.categoriesV2.queryCategories().find();
|
|
13463
|
+
this.logger.info("queryCategories response", { response });
|
|
13464
|
+
return response?.items ?? [];
|
|
13407
13465
|
} catch (error) {
|
|
13408
13466
|
this.logger.error("Failed to query categories", { error });
|
|
13409
13467
|
return null;
|
|
13410
13468
|
}
|
|
13411
13469
|
}
|
|
13470
|
+
async createCategory(name) {
|
|
13471
|
+
try {
|
|
13472
|
+
const client = await this.createCategoriesClient();
|
|
13473
|
+
if (!client) {
|
|
13474
|
+
return null;
|
|
13475
|
+
}
|
|
13476
|
+
const response = await client.categoriesV2.createCategory({ name });
|
|
13477
|
+
this.logger.info("createCategory response", { response });
|
|
13478
|
+
return response;
|
|
13479
|
+
} catch (error) {
|
|
13480
|
+
this.logger.error("Failed to create category", { error });
|
|
13481
|
+
return null;
|
|
13482
|
+
}
|
|
13483
|
+
}
|
|
13412
13484
|
};
|
|
13413
13485
|
|
|
13414
13486
|
// src/utils.ts
|
|
@@ -13444,7 +13516,7 @@ var prompts = {
|
|
|
13444
13516
|
var bookingServicesDetailsExample = {
|
|
13445
13517
|
items: [
|
|
13446
13518
|
{
|
|
13447
|
-
type: "
|
|
13519
|
+
type: "APPOINTMENT",
|
|
13448
13520
|
name: "Service name",
|
|
13449
13521
|
description: "Service description",
|
|
13450
13522
|
location: "business address",
|
|
@@ -13455,6 +13527,7 @@ var bookingServicesDetailsExample = {
|
|
|
13455
13527
|
}
|
|
13456
13528
|
]
|
|
13457
13529
|
};
|
|
13530
|
+
var defaultCategoryName = "Our services";
|
|
13458
13531
|
var ContentInjectionService = class {
|
|
13459
13532
|
constructor(env, logger) {
|
|
13460
13533
|
this.env = env;
|
|
@@ -13478,6 +13551,11 @@ var ContentInjectionService = class {
|
|
|
13478
13551
|
null,
|
|
13479
13552
|
2
|
|
13480
13553
|
);
|
|
13554
|
+
this.logger.info("generating services", {
|
|
13555
|
+
businessDescription,
|
|
13556
|
+
lng,
|
|
13557
|
+
responseExample
|
|
13558
|
+
});
|
|
13481
13559
|
const response = await this.llmService.generateObjectByProject(
|
|
13482
13560
|
prompts.serviceGenerationProjectId,
|
|
13483
13561
|
{
|
|
@@ -13538,10 +13616,19 @@ var ContentInjectionService = class {
|
|
|
13538
13616
|
fn: async () => {
|
|
13539
13617
|
this.logger.info("getting categories");
|
|
13540
13618
|
const categories = await this.categoriesAPIClient.queryCategories();
|
|
13541
|
-
|
|
13542
|
-
|
|
13543
|
-
|
|
13619
|
+
if (!categories || categories.length === 0) {
|
|
13620
|
+
this.logger.warn("No categories found, creating default category");
|
|
13621
|
+
const createCategoryResponse = await this.categoriesAPIClient.createCategory(defaultCategoryName);
|
|
13622
|
+
if (!createCategoryResponse) {
|
|
13623
|
+
this.logger.error("Failed to create default category");
|
|
13624
|
+
throw new Error("Failed to create default category");
|
|
13625
|
+
}
|
|
13626
|
+
this.logger.info("default category created", {
|
|
13627
|
+
createCategoryResponse
|
|
13628
|
+
});
|
|
13629
|
+
return createCategoryResponse;
|
|
13544
13630
|
}
|
|
13631
|
+
const defaultCategory = categories[0];
|
|
13545
13632
|
this.logger.info("default category", { defaultCategory });
|
|
13546
13633
|
return defaultCategory;
|
|
13547
13634
|
}
|