@wix/cli-app 1.1.53 → 1.1.55
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/README.md +45 -0
- package/build/{CreateVersionCommand-2W37YQW4.js → CreateVersionCommand-XTZT5DED.js} +2 -2
- package/build/{DevCommand-JDHE7RQB.js → DevCommand-Q5XLAGMG.js} +2 -2
- package/build/DevCommand-Q5XLAGMG.js.map +1 -0
- package/build/GenerateCommand-HNFICZJA.js +128 -0
- package/build/{GenerateCommand-3PPXF4B6.js.map → GenerateCommand-HNFICZJA.js.map} +1 -1
- package/build/LogsCommand-XJHE75L2.js +4 -0
- package/build/LogsCommand-XJHE75L2.js.map +1 -0
- package/build/PreviewCommand-JKPFMGWV.js +4 -0
- package/build/ServeCommand-CPZOI7DC.js +4 -0
- package/build/ServeCommand-CPZOI7DC.js.map +1 -0
- package/build/build-3RXHADZD.js +4 -0
- package/build/build-3RXHADZD.js.map +1 -0
- package/build/{chunk-FVG3T57Z.js → chunk-2FB5F5QF.js} +2 -2
- package/build/{chunk-TSAKYUDG.js → chunk-4BHNJVL2.js} +2 -2
- package/build/{chunk-PSQ4AQFG.js → chunk-6HSUK2A2.js} +2 -2
- package/build/{chunk-QXIKCJLU.js → chunk-7VOKCPZP.js} +3 -3
- package/build/{chunk-QXIKCJLU.js.map → chunk-7VOKCPZP.js.map} +1 -1
- package/build/{chunk-WXOIL7LC.js → chunk-B4SDDVMV.js} +2 -2
- package/build/{chunk-DLQYJEV6.js → chunk-C4SXZWXS.js} +2 -2
- package/build/{chunk-4CCKO52Z.js → chunk-FKBCPMYK.js} +3 -3
- package/build/chunk-FKBCPMYK.js.map +1 -0
- package/build/chunk-FMIXY6J5.js +115 -0
- package/build/chunk-FMIXY6J5.js.map +1 -0
- package/build/{chunk-YIGHU6O6.js → chunk-GWU77DPO.js} +2 -2
- package/build/chunk-GWU77DPO.js.map +1 -0
- package/build/{chunk-SZ5JWJ4Q.js → chunk-HDXLQ34N.js} +2 -2
- package/build/{chunk-2W2YJZP5.js → chunk-JXE3LQ2S.js} +15 -15
- package/build/chunk-JXE3LQ2S.js.map +1 -0
- package/build/chunk-K2A77MMN.js +4 -0
- package/build/chunk-K2A77MMN.js.map +1 -0
- package/build/{chunk-C3O7WWDR.js → chunk-KG7BHEJG.js} +2 -2
- package/build/chunk-LJEYXY4V.js +4 -0
- package/build/chunk-LJEYXY4V.js.map +1 -0
- package/build/{chunk-B5P4JHUW.js → chunk-N5D4TFKX.js} +132 -130
- package/build/chunk-N5D4TFKX.js.map +1 -0
- package/build/{chunk-AXAJ7DJ4.js → chunk-QOUZ6J7N.js} +2 -2
- package/build/{chunk-HILXNAWZ.js → chunk-X4BLMM2K.js} +2 -2
- package/build/chunk-X4BLMM2K.js.map +1 -0
- package/build/cloudflare-runtime/entry.js +300 -48
- package/build/cloudflare-runtime/getRegisteredExtensions.js +299 -47
- package/build/index.js +2 -2
- package/build/platform-sdk/chunk-GZP4Z76C.js +2 -0
- package/build/platform-sdk/chunk-GZP4Z76C.js.map +1 -0
- package/build/platform-sdk/chunk-KGLNBMRO.js +2 -0
- package/build/platform-sdk/chunk-KGLNBMRO.js.map +1 -0
- package/build/platform-sdk/dashboard.js +1 -1
- package/build/platform-sdk/editor.js +2 -2
- package/build/platform-sdk/editor.js.map +1 -1
- package/build/platform-sdk/site.js +1 -1
- package/build/platform-sdk/site.js.map +1 -1
- package/build/preview-TM7JAWFS.js +4 -0
- package/build/preview-TM7JAWFS.js.map +1 -0
- package/build/render-command-QEQ3L7OX.js +4 -0
- package/build/render-command-QEQ3L7OX.js.map +1 -0
- package/package.json +7 -6
- package/templates/dashboard-plugin/files/plugin.tsx.ejs +8 -18
- package/build/DevCommand-JDHE7RQB.js.map +0 -1
- package/build/GenerateCommand-3PPXF4B6.js +0 -128
- package/build/LogsCommand-LQKTBY6D.js +0 -4
- package/build/LogsCommand-LQKTBY6D.js.map +0 -1
- package/build/PreviewCommand-H3HVD7DH.js +0 -4
- package/build/ServeCommand-RHONEHTF.js +0 -4
- package/build/ServeCommand-RHONEHTF.js.map +0 -1
- package/build/build-QN6TGE3Q.js +0 -4
- package/build/build-QN6TGE3Q.js.map +0 -1
- package/build/chunk-2W2YJZP5.js.map +0 -1
- package/build/chunk-4CCKO52Z.js.map +0 -1
- package/build/chunk-B5P4JHUW.js.map +0 -1
- package/build/chunk-F6MVNSX2.js +0 -4
- package/build/chunk-F6MVNSX2.js.map +0 -1
- package/build/chunk-HILXNAWZ.js.map +0 -1
- package/build/chunk-LDGXTJLC.js +0 -4
- package/build/chunk-LDGXTJLC.js.map +0 -1
- package/build/chunk-YIGHU6O6.js.map +0 -1
- package/build/chunk-YMRYABCG.js +0 -115
- package/build/chunk-YMRYABCG.js.map +0 -1
- package/build/platform-sdk/chunk-32RIHE6N.js +0 -2
- package/build/platform-sdk/chunk-32RIHE6N.js.map +0 -1
- package/build/platform-sdk/chunk-DGX4CFXG.js +0 -2
- package/build/platform-sdk/chunk-DGX4CFXG.js.map +0 -1
- package/build/preview-457BTAHF.js +0 -4
- package/build/preview-457BTAHF.js.map +0 -1
- package/build/render-command-W6CY3R4Q.js +0 -4
- package/build/render-command-W6CY3R4Q.js.map +0 -1
- /package/build/{CreateVersionCommand-2W37YQW4.js.map → CreateVersionCommand-XTZT5DED.js.map} +0 -0
- /package/build/{PreviewCommand-H3HVD7DH.js.map → PreviewCommand-JKPFMGWV.js.map} +0 -0
- /package/build/{chunk-FVG3T57Z.js.map → chunk-2FB5F5QF.js.map} +0 -0
- /package/build/{chunk-TSAKYUDG.js.map → chunk-4BHNJVL2.js.map} +0 -0
- /package/build/{chunk-PSQ4AQFG.js.map → chunk-6HSUK2A2.js.map} +0 -0
- /package/build/{chunk-WXOIL7LC.js.map → chunk-B4SDDVMV.js.map} +0 -0
- /package/build/{chunk-DLQYJEV6.js.map → chunk-C4SXZWXS.js.map} +0 -0
- /package/build/{chunk-SZ5JWJ4Q.js.map → chunk-HDXLQ34N.js.map} +0 -0
- /package/build/{chunk-C3O7WWDR.js.map → chunk-KG7BHEJG.js.map} +0 -0
- /package/build/{chunk-AXAJ7DJ4.js.map → chunk-QOUZ6J7N.js.map} +0 -0
|
@@ -1,12 +1,166 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
1
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
2
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
3
7
|
var __esm = (fn, res) => function __init() {
|
|
4
8
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
5
9
|
};
|
|
10
|
+
var __commonJS = (cb, mod) => function __require() {
|
|
11
|
+
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
12
|
+
};
|
|
6
13
|
var __export = (target, all) => {
|
|
7
14
|
for (var name in all)
|
|
8
15
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
16
|
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
26
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
27
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
28
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
29
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
30
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
31
|
+
mod
|
|
32
|
+
));
|
|
33
|
+
|
|
34
|
+
// ../../node_modules/serialize-error/index.js
|
|
35
|
+
var require_serialize_error = __commonJS({
|
|
36
|
+
"../../node_modules/serialize-error/index.js"(exports, module) {
|
|
37
|
+
"use strict";
|
|
38
|
+
var NonError = class _NonError extends Error {
|
|
39
|
+
constructor(message2) {
|
|
40
|
+
super(_NonError._prepareSuperMessage(message2));
|
|
41
|
+
Object.defineProperty(this, "name", {
|
|
42
|
+
value: "NonError",
|
|
43
|
+
configurable: true,
|
|
44
|
+
writable: true
|
|
45
|
+
});
|
|
46
|
+
if (Error.captureStackTrace) {
|
|
47
|
+
Error.captureStackTrace(this, _NonError);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
static _prepareSuperMessage(message2) {
|
|
51
|
+
try {
|
|
52
|
+
return JSON.stringify(message2);
|
|
53
|
+
} catch {
|
|
54
|
+
return String(message2);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var commonProperties = [
|
|
59
|
+
{ property: "name", enumerable: false },
|
|
60
|
+
{ property: "message", enumerable: false },
|
|
61
|
+
{ property: "stack", enumerable: false },
|
|
62
|
+
{ property: "code", enumerable: true }
|
|
63
|
+
];
|
|
64
|
+
var isCalled = Symbol(".toJSON called");
|
|
65
|
+
var toJSON = (from) => {
|
|
66
|
+
from[isCalled] = true;
|
|
67
|
+
const json = from.toJSON();
|
|
68
|
+
delete from[isCalled];
|
|
69
|
+
return json;
|
|
70
|
+
};
|
|
71
|
+
var destroyCircular = ({
|
|
72
|
+
from,
|
|
73
|
+
seen,
|
|
74
|
+
to_,
|
|
75
|
+
forceEnumerable,
|
|
76
|
+
maxDepth,
|
|
77
|
+
depth
|
|
78
|
+
}) => {
|
|
79
|
+
const to = to_ || (Array.isArray(from) ? [] : {});
|
|
80
|
+
seen.push(from);
|
|
81
|
+
if (depth >= maxDepth) {
|
|
82
|
+
return to;
|
|
83
|
+
}
|
|
84
|
+
if (typeof from.toJSON === "function" && from[isCalled] !== true) {
|
|
85
|
+
return toJSON(from);
|
|
86
|
+
}
|
|
87
|
+
for (const [key, value] of Object.entries(from)) {
|
|
88
|
+
if (typeof Buffer === "function" && Buffer.isBuffer(value)) {
|
|
89
|
+
to[key] = "[object Buffer]";
|
|
90
|
+
continue;
|
|
91
|
+
}
|
|
92
|
+
if (typeof value === "function") {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (!value || typeof value !== "object") {
|
|
96
|
+
to[key] = value;
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (!seen.includes(from[key])) {
|
|
100
|
+
depth++;
|
|
101
|
+
to[key] = destroyCircular({
|
|
102
|
+
from: from[key],
|
|
103
|
+
seen: seen.slice(),
|
|
104
|
+
forceEnumerable,
|
|
105
|
+
maxDepth,
|
|
106
|
+
depth
|
|
107
|
+
});
|
|
108
|
+
continue;
|
|
109
|
+
}
|
|
110
|
+
to[key] = "[Circular]";
|
|
111
|
+
}
|
|
112
|
+
for (const { property, enumerable } of commonProperties) {
|
|
113
|
+
if (typeof from[property] === "string") {
|
|
114
|
+
Object.defineProperty(to, property, {
|
|
115
|
+
value: from[property],
|
|
116
|
+
enumerable: forceEnumerable ? true : enumerable,
|
|
117
|
+
configurable: true,
|
|
118
|
+
writable: true
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return to;
|
|
123
|
+
};
|
|
124
|
+
var serializeError2 = (value, options = {}) => {
|
|
125
|
+
const { maxDepth = Number.POSITIVE_INFINITY } = options;
|
|
126
|
+
if (typeof value === "object" && value !== null) {
|
|
127
|
+
return destroyCircular({
|
|
128
|
+
from: value,
|
|
129
|
+
seen: [],
|
|
130
|
+
forceEnumerable: true,
|
|
131
|
+
maxDepth,
|
|
132
|
+
depth: 0
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
if (typeof value === "function") {
|
|
136
|
+
return `[Function: ${value.name || "anonymous"}]`;
|
|
137
|
+
}
|
|
138
|
+
return value;
|
|
139
|
+
};
|
|
140
|
+
var deserializeError = (value, options = {}) => {
|
|
141
|
+
const { maxDepth = Number.POSITIVE_INFINITY } = options;
|
|
142
|
+
if (value instanceof Error) {
|
|
143
|
+
return value;
|
|
144
|
+
}
|
|
145
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) {
|
|
146
|
+
const newError = new Error();
|
|
147
|
+
destroyCircular({
|
|
148
|
+
from: value,
|
|
149
|
+
seen: [],
|
|
150
|
+
to_: newError,
|
|
151
|
+
maxDepth,
|
|
152
|
+
depth: 0
|
|
153
|
+
});
|
|
154
|
+
return newError;
|
|
155
|
+
}
|
|
156
|
+
return new NonError(value);
|
|
157
|
+
};
|
|
158
|
+
module.exports = {
|
|
159
|
+
serializeError: serializeError2,
|
|
160
|
+
deserializeError
|
|
161
|
+
};
|
|
162
|
+
}
|
|
163
|
+
});
|
|
10
164
|
|
|
11
165
|
// ../../node_modules/jose/dist/browser/runtime/webcrypto.js
|
|
12
166
|
var webcrypto_default, isCryptoKey;
|
|
@@ -4414,7 +4568,7 @@ function objectToKeyValue(input) {
|
|
|
4414
4568
|
return Object.entries(input).filter(([_, value]) => Boolean(value)).map(([key, value]) => `${key}=${value}`).join(",");
|
|
4415
4569
|
}
|
|
4416
4570
|
|
|
4417
|
-
// ../../node_modules/@wix/sdk
|
|
4571
|
+
// ../../node_modules/@wix/sdk-runtime/build/context.js
|
|
4418
4572
|
function runWithoutContext(fn) {
|
|
4419
4573
|
const globalContext = globalThis.__wix_context__;
|
|
4420
4574
|
const moduleContext = {
|
|
@@ -4746,6 +4900,120 @@ function servicePluginsModules(authStrategy) {
|
|
|
4746
4900
|
};
|
|
4747
4901
|
}
|
|
4748
4902
|
|
|
4903
|
+
// ../../node_modules/@wix/sdk/build/web-method-modules.js
|
|
4904
|
+
var import_serialize_error = __toESM(require_serialize_error(), 1);
|
|
4905
|
+
|
|
4906
|
+
// ../../node_modules/@wix/sdk/build/get-token-info.js
|
|
4907
|
+
async function getTokenInfo(token) {
|
|
4908
|
+
const tokenInfoRes = await fetch("https://www.wixapis.com/oauth2/token-info", {
|
|
4909
|
+
method: "POST",
|
|
4910
|
+
headers: {
|
|
4911
|
+
"Content-Type": "application/json"
|
|
4912
|
+
},
|
|
4913
|
+
body: JSON.stringify({
|
|
4914
|
+
token
|
|
4915
|
+
})
|
|
4916
|
+
});
|
|
4917
|
+
if (tokenInfoRes.status !== 200) {
|
|
4918
|
+
throw new Error(`Failed to get token info. Unexpected status code from Wix OAuth API: ${tokenInfoRes.status}`);
|
|
4919
|
+
}
|
|
4920
|
+
return await tokenInfoRes.json();
|
|
4921
|
+
}
|
|
4922
|
+
|
|
4923
|
+
// ../../node_modules/@wix/sdk/build/web-method-modules.js
|
|
4924
|
+
var isWebMethodModules = (val) => val.__type === "web-method-module";
|
|
4925
|
+
var Permissions;
|
|
4926
|
+
(function(Permissions2) {
|
|
4927
|
+
Permissions2["Anyone"] = "anyone";
|
|
4928
|
+
Permissions2["Admin"] = "admin";
|
|
4929
|
+
Permissions2["SiteMember"] = "site-member";
|
|
4930
|
+
})(Permissions || (Permissions = {}));
|
|
4931
|
+
async function checkPermission(request, permission) {
|
|
4932
|
+
const accessToken = request.headers.get("Authorization");
|
|
4933
|
+
if (!accessToken) {
|
|
4934
|
+
throw new Error("Request is missing authentication data");
|
|
4935
|
+
}
|
|
4936
|
+
const { subjectType } = await getTokenInfo(accessToken);
|
|
4937
|
+
switch (permission) {
|
|
4938
|
+
case Permissions.Anyone: {
|
|
4939
|
+
if (subjectType !== "VISITOR" && subjectType !== "MEMBER" && subjectType !== "USER") {
|
|
4940
|
+
throw new Error("Insufficient permissions");
|
|
4941
|
+
}
|
|
4942
|
+
break;
|
|
4943
|
+
}
|
|
4944
|
+
case Permissions.SiteMember: {
|
|
4945
|
+
if (subjectType !== "MEMBER" && subjectType !== "USER") {
|
|
4946
|
+
throw new Error("Insufficient permissions");
|
|
4947
|
+
}
|
|
4948
|
+
break;
|
|
4949
|
+
}
|
|
4950
|
+
case Permissions.Admin: {
|
|
4951
|
+
if (subjectType !== "USER") {
|
|
4952
|
+
throw new Error("Insufficient permissions");
|
|
4953
|
+
}
|
|
4954
|
+
break;
|
|
4955
|
+
}
|
|
4956
|
+
}
|
|
4957
|
+
}
|
|
4958
|
+
var urlRegex = /\/_webMethods\/(.+\..+)\/(.+\..+)/;
|
|
4959
|
+
function extractUrlParts(url) {
|
|
4960
|
+
const parts = url.match(urlRegex);
|
|
4961
|
+
if (parts) {
|
|
4962
|
+
return [parts[1], parts[2].replace(".ajax", "")];
|
|
4963
|
+
}
|
|
4964
|
+
}
|
|
4965
|
+
function isRequestBodyValid(body) {
|
|
4966
|
+
return !!body && typeof body === "object" && Array.isArray(body);
|
|
4967
|
+
}
|
|
4968
|
+
var productionErrorMessage = "Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information.";
|
|
4969
|
+
function webMethodModules() {
|
|
4970
|
+
const webMethods = {};
|
|
4971
|
+
const client = {
|
|
4972
|
+
async processRequest(request, devMode = false) {
|
|
4973
|
+
const urlParts = extractUrlParts(request.url);
|
|
4974
|
+
if (!urlParts) {
|
|
4975
|
+
return new Response("invalid request", { status: 400 });
|
|
4976
|
+
}
|
|
4977
|
+
const [file, method] = urlParts;
|
|
4978
|
+
const body = await request.json();
|
|
4979
|
+
if (!isRequestBodyValid(body)) {
|
|
4980
|
+
return new Response("invalid request", { status: 400 });
|
|
4981
|
+
}
|
|
4982
|
+
const loadWebMethodFile = webMethods[`/${file}`];
|
|
4983
|
+
try {
|
|
4984
|
+
if (!loadWebMethodFile) {
|
|
4985
|
+
throw new Error(`Error loading web module ${file}: Cannot find module '${file}'`);
|
|
4986
|
+
}
|
|
4987
|
+
const webMethodFile = await loadWebMethodFile();
|
|
4988
|
+
const webMethod = webMethodFile[method];
|
|
4989
|
+
if (!webMethod) {
|
|
4990
|
+
throw new Error(`Error loading function from web module ${file}: function '${method}' not found`);
|
|
4991
|
+
}
|
|
4992
|
+
await checkPermission(request, webMethod.permission);
|
|
4993
|
+
return Response.json({
|
|
4994
|
+
result: await webMethod.handler(...body)
|
|
4995
|
+
});
|
|
4996
|
+
} catch (error) {
|
|
4997
|
+
const serializedError = (0, import_serialize_error.serializeError)(error, { maxDepth: 1 });
|
|
4998
|
+
return Response.json({
|
|
4999
|
+
result: devMode || !(error instanceof Error) ? serializedError : {
|
|
5000
|
+
...serializedError,
|
|
5001
|
+
message: productionErrorMessage,
|
|
5002
|
+
stack: productionErrorMessage
|
|
5003
|
+
},
|
|
5004
|
+
exception: true
|
|
5005
|
+
});
|
|
5006
|
+
}
|
|
5007
|
+
}
|
|
5008
|
+
};
|
|
5009
|
+
return {
|
|
5010
|
+
initModule(webMethodModule) {
|
|
5011
|
+
Object.assign(webMethods, webMethodModule);
|
|
5012
|
+
},
|
|
5013
|
+
client
|
|
5014
|
+
};
|
|
5015
|
+
}
|
|
5016
|
+
|
|
4749
5017
|
// ../../node_modules/@wix/sdk/build/wixClient.js
|
|
4750
5018
|
function createClient(config) {
|
|
4751
5019
|
const _headers = config.headers || { Authorization: "" };
|
|
@@ -4754,8 +5022,25 @@ function createClient(config) {
|
|
|
4754
5022
|
};
|
|
4755
5023
|
const boundGetAuthHeaders = authStrategy.getAuthHeaders.bind(void 0, config.host);
|
|
4756
5024
|
authStrategy.getAuthHeaders = boundGetAuthHeaders;
|
|
5025
|
+
const fetchWithAuth = async (urlOrRequest, requestInit) => {
|
|
5026
|
+
if (typeof urlOrRequest === "string" || urlOrRequest instanceof URL) {
|
|
5027
|
+
return fetch(urlOrRequest, {
|
|
5028
|
+
...requestInit,
|
|
5029
|
+
headers: {
|
|
5030
|
+
...requestInit?.headers,
|
|
5031
|
+
...(await boundGetAuthHeaders()).headers
|
|
5032
|
+
}
|
|
5033
|
+
});
|
|
5034
|
+
} else {
|
|
5035
|
+
for (const [k, v] of Object.entries((await boundGetAuthHeaders()).headers)) {
|
|
5036
|
+
urlOrRequest.headers.set(k, v);
|
|
5037
|
+
}
|
|
5038
|
+
return fetch(urlOrRequest, requestInit);
|
|
5039
|
+
}
|
|
5040
|
+
};
|
|
4757
5041
|
const { client: servicePluginsClient, initModule: initServicePluginModule } = servicePluginsModules(authStrategy);
|
|
4758
5042
|
const { client: eventHandlersClient, initModule: initEventHandlerModule } = eventHandlersModules(authStrategy);
|
|
5043
|
+
const { client: webMethodClient, initModule } = webMethodModules();
|
|
4759
5044
|
const boundFetch = async (url, options) => {
|
|
4760
5045
|
const authHeaders = await boundGetAuthHeaders();
|
|
4761
5046
|
const defaultContentTypeHeader = getDefaultContentHeader(options);
|
|
@@ -4777,6 +5062,8 @@ function createClient(config) {
|
|
|
4777
5062
|
return initServicePluginModule(modules);
|
|
4778
5063
|
} else if (isHostModule(modules) && config.host) {
|
|
4779
5064
|
return buildHostModule(modules, config.host);
|
|
5065
|
+
} else if (isWebMethodModules(modules)) {
|
|
5066
|
+
return initModule(modules);
|
|
4780
5067
|
} else if (typeof modules === "function") {
|
|
4781
5068
|
if ("__type" in modules && modules.__type === SERVICE_PLUGIN_ERROR_TYPE) {
|
|
4782
5069
|
return modules;
|
|
@@ -4843,22 +5130,7 @@ function createClient(config) {
|
|
|
4843
5130
|
finalUrl.protocol = "https";
|
|
4844
5131
|
return boundFetch(finalUrl.toString(), options);
|
|
4845
5132
|
},
|
|
4846
|
-
fetchWithAuth
|
|
4847
|
-
if (typeof urlOrRequest === "string" || urlOrRequest instanceof URL) {
|
|
4848
|
-
return fetch(urlOrRequest, {
|
|
4849
|
-
...requestInit,
|
|
4850
|
-
headers: {
|
|
4851
|
-
...requestInit?.headers,
|
|
4852
|
-
...(await boundGetAuthHeaders()).headers
|
|
4853
|
-
}
|
|
4854
|
-
});
|
|
4855
|
-
} else {
|
|
4856
|
-
for (const [k, v] of Object.entries((await boundGetAuthHeaders()).headers)) {
|
|
4857
|
-
urlOrRequest.headers.set(k, v);
|
|
4858
|
-
}
|
|
4859
|
-
return fetch(urlOrRequest, requestInit);
|
|
4860
|
-
}
|
|
4861
|
-
},
|
|
5133
|
+
fetchWithAuth,
|
|
4862
5134
|
async graphql(query, variables, opts = {
|
|
4863
5135
|
apiVersion: "alpha"
|
|
4864
5136
|
}) {
|
|
@@ -4877,13 +5149,13 @@ function createClient(config) {
|
|
|
4877
5149
|
return { data: data ?? {}, errors };
|
|
4878
5150
|
},
|
|
4879
5151
|
webhooks: eventHandlersClient,
|
|
5152
|
+
webMethods: webMethodClient,
|
|
4880
5153
|
servicePlugins: servicePluginsClient
|
|
4881
5154
|
};
|
|
4882
5155
|
}
|
|
4883
5156
|
|
|
4884
5157
|
// ../../node_modules/@wix/sdk/build/auth/AppStrategy.js
|
|
4885
5158
|
function AppStrategy(opts) {
|
|
4886
|
-
const authServerBaseUrl = opts.authServerBaseUrl ?? "https://www.wixapis.com";
|
|
4887
5159
|
let refreshToken = "refreshToken" in opts ? opts.refreshToken : void 0;
|
|
4888
5160
|
let cachedToken;
|
|
4889
5161
|
return {
|
|
@@ -4913,8 +5185,7 @@ function AppStrategy(opts) {
|
|
|
4913
5185
|
if (!code || !instanceId) {
|
|
4914
5186
|
throw new Error("Invalid OAuth callback URL. Make sure you pass the url including the code and instanceId query params.");
|
|
4915
5187
|
}
|
|
4916
|
-
const
|
|
4917
|
-
const tokensRes = await fetch(tokenUrl.href, {
|
|
5188
|
+
const tokensRes = await fetch("https://www.wixapis.com/oauth/access", {
|
|
4918
5189
|
method: "POST",
|
|
4919
5190
|
headers: {
|
|
4920
5191
|
"Content-Type": "application/json"
|
|
@@ -4947,10 +5218,9 @@ function AppStrategy(opts) {
|
|
|
4947
5218
|
}
|
|
4948
5219
|
if ("refreshToken" in opts || refreshToken) {
|
|
4949
5220
|
if (!opts.appSecret) {
|
|
4950
|
-
throw new Error("App secret is required for
|
|
5221
|
+
throw new Error("App secret is required for retrieving app-level access tokens. Make sure to pass it to the AppStrategy");
|
|
4951
5222
|
}
|
|
4952
|
-
const
|
|
4953
|
-
const tokensRes = await fetch(tokenUrl.href, {
|
|
5223
|
+
const tokensRes = await fetch("https://www.wixapis.com/oauth/access", {
|
|
4954
5224
|
method: "POST",
|
|
4955
5225
|
headers: {
|
|
4956
5226
|
"Content-Type": "application/json"
|
|
@@ -4974,10 +5244,9 @@ function AppStrategy(opts) {
|
|
|
4974
5244
|
};
|
|
4975
5245
|
} else if ("instanceId" in opts) {
|
|
4976
5246
|
if (!opts.appSecret) {
|
|
4977
|
-
throw new Error("App secret is required for
|
|
5247
|
+
throw new Error("App secret is required for retrieving app-level access tokens. Make sure to pass it to the AppStrategy");
|
|
4978
5248
|
}
|
|
4979
|
-
const
|
|
4980
|
-
const tokensRes = await fetch(tokenUrl.href, {
|
|
5249
|
+
const tokensRes = await fetch("https://www.wixapis.com/oauth2/token", {
|
|
4981
5250
|
method: "POST",
|
|
4982
5251
|
headers: {
|
|
4983
5252
|
"Content-Type": "application/json"
|
|
@@ -5003,7 +5272,7 @@ function AppStrategy(opts) {
|
|
|
5003
5272
|
}
|
|
5004
5273
|
};
|
|
5005
5274
|
} else if ("accessToken" in opts && opts.accessToken) {
|
|
5006
|
-
const tokenRes = await fetch(
|
|
5275
|
+
const tokenRes = await fetch("https://www.wixapis.com/oauth2/token", {
|
|
5007
5276
|
method: "POST",
|
|
5008
5277
|
headers: {
|
|
5009
5278
|
"Content-Type": "application/json"
|
|
@@ -5033,7 +5302,7 @@ function AppStrategy(opts) {
|
|
|
5033
5302
|
},
|
|
5034
5303
|
async elevated() {
|
|
5035
5304
|
if ("accessToken" in opts && opts.accessToken) {
|
|
5036
|
-
const tokenInfo = await getTokenInfo(opts.accessToken
|
|
5305
|
+
const tokenInfo = await getTokenInfo(opts.accessToken);
|
|
5037
5306
|
if (tokenInfo.clientId !== opts.appId) {
|
|
5038
5307
|
throw new Error(`Invalid access token. The token is not issued for the app with ID "${opts.appId}"`);
|
|
5039
5308
|
}
|
|
@@ -5044,8 +5313,7 @@ function AppStrategy(opts) {
|
|
|
5044
5313
|
appId: opts.appId,
|
|
5045
5314
|
appSecret: opts.appSecret,
|
|
5046
5315
|
publicKey: opts.publicKey,
|
|
5047
|
-
instanceId: tokenInfo.instanceId
|
|
5048
|
-
authServerBaseUrl: opts.authServerBaseUrl
|
|
5316
|
+
instanceId: tokenInfo.instanceId
|
|
5049
5317
|
});
|
|
5050
5318
|
} else {
|
|
5051
5319
|
throw new Error("Providing an access token is required to perform elevation. Make sure to pass it to the AppStrategy");
|
|
@@ -5073,29 +5341,13 @@ function AppStrategy(opts) {
|
|
|
5073
5341
|
if (!tokenToCheck) {
|
|
5074
5342
|
throw new Error("Missing token to get info for. Either pass the token as an argument or provide it when initializing the AppStrategy");
|
|
5075
5343
|
}
|
|
5076
|
-
return getTokenInfo(tokenToCheck
|
|
5344
|
+
return getTokenInfo(tokenToCheck);
|
|
5077
5345
|
},
|
|
5078
5346
|
getActiveToken() {
|
|
5079
5347
|
return "accessToken" in opts ? opts.accessToken : refreshToken;
|
|
5080
5348
|
}
|
|
5081
5349
|
};
|
|
5082
5350
|
}
|
|
5083
|
-
async function getTokenInfo(token, authServerBaseUrl) {
|
|
5084
|
-
const tokenInfoUrl = new URL("/oauth2/token-info", authServerBaseUrl);
|
|
5085
|
-
const tokenInfoRes = await fetch(tokenInfoUrl.href, {
|
|
5086
|
-
method: "POST",
|
|
5087
|
-
headers: {
|
|
5088
|
-
"Content-Type": "application/json"
|
|
5089
|
-
},
|
|
5090
|
-
body: JSON.stringify({
|
|
5091
|
-
token
|
|
5092
|
-
})
|
|
5093
|
-
});
|
|
5094
|
-
if (tokenInfoRes.status !== 200) {
|
|
5095
|
-
throw new Error(`Failed to get token info. Unexpected status code from Wix OAuth API: ${tokenInfoRes.status}`);
|
|
5096
|
-
}
|
|
5097
|
-
return await tokenInfoRes.json();
|
|
5098
|
-
}
|
|
5099
5351
|
|
|
5100
5352
|
// src/utils.ts
|
|
5101
5353
|
import { dirname, sep } from "node:path";
|
package/build/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire as _createRequire } from 'node:module';
|
|
2
2
|
const require = _createRequire(import.meta.url);
|
|
3
|
-
import{a as A}from"./chunk-
|
|
3
|
+
import{a as A}from"./chunk-2FB5F5QF.js";import"./chunk-5OZZ7R6I.js";import{a as Z,b as V,m as S}from"./chunk-JXE3LQ2S.js";import{a as H,c as E,e as $,h as m}from"./chunk-V4TR6DCM.js";var k=E(W=>{"use strict";m();var P=class extends Error{constructor(e,t,i){super(i),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name,this.code=t,this.exitCode=e,this.nestedError=void 0}},N=class extends P{constructor(e){super(1,"commander.invalidArgument",e),Error.captureStackTrace(this,this.constructor),this.name=this.constructor.name}};W.CommanderError=P;W.InvalidArgumentError=N});var T=E(j=>{"use strict";m();var{InvalidArgumentError:He}=k(),M=class{constructor(e,t){switch(this.description=t||"",this.variadic=!1,this.parseArg=void 0,this.defaultValue=void 0,this.defaultValueDescription=void 0,this.argChoices=void 0,e[0]){case"<":this.required=!0,this._name=e.slice(1,-1);break;case"[":this.required=!1,this._name=e.slice(1,-1);break;default:this.required=!0,this._name=e;break}this._name.length>3&&this._name.slice(-3)==="..."&&(this.variadic=!0,this._name=this._name.slice(0,-3))}name(){return this._name}_concatValue(e,t){return t===this.defaultValue||!Array.isArray(t)?[e]:t.concat(e)}default(e,t){return this.defaultValue=e,this.defaultValueDescription=t,this}argParser(e){return this.parseArg=e,this}choices(e){return this.argChoices=e.slice(),this.parseArg=(t,i)=>{if(!this.argChoices.includes(t))throw new He(`Allowed choices are ${this.argChoices.join(", ")}.`);return this.variadic?this._concatValue(t,i):t},this}argRequired(){return this.required=!0,this}argOptional(){return this.required=!1,this}};function ke(o){let e=o.name()+(o.variadic===!0?"...":"");return o.required?"<"+e+">":"["+e+"]"}j.Argument=M;j.humanReadableArgName=ke});var R=E(ee=>{"use strict";m();var{humanReadableArgName:Pe}=T(),U=class{constructor(){this.helpWidth=void 0,this.sortSubcommands=!1,this.sortOptions=!1,this.showGlobalOptions=!1}visibleCommands(e){let t=e.commands.filter(n=>!n._hidden),i=e._getHelpCommand();return i&&!i._hidden&&t.push(i),this.sortSubcommands&&t.sort((n,r)=>n.name().localeCompare(r.name())),t}compareOptions(e,t){let i=n=>n.short?n.short.replace(/^-/,""):n.long.replace(/^--/,"");return i(e).localeCompare(i(t))}visibleOptions(e){let t=e.options.filter(n=>!n.hidden),i=e._getHelpOption();if(i&&!i.hidden){let n=i.short&&e._findOption(i.short),r=i.long&&e._findOption(i.long);!n&&!r?t.push(i):i.long&&!r?t.push(e.createOption(i.long,i.description)):i.short&&!n&&t.push(e.createOption(i.short,i.description))}return this.sortOptions&&t.sort(this.compareOptions),t}visibleGlobalOptions(e){if(!this.showGlobalOptions)return[];let t=[];for(let i=e.parent;i;i=i.parent){let n=i.options.filter(r=>!r.hidden);t.push(...n)}return this.sortOptions&&t.sort(this.compareOptions),t}visibleArguments(e){return e._argsDescription&&e.registeredArguments.forEach(t=>{t.description=t.description||e._argsDescription[t.name()]||""}),e.registeredArguments.find(t=>t.description)?e.registeredArguments:[]}subcommandTerm(e){let t=e.registeredArguments.map(i=>Pe(i)).join(" ");return e._name+(e._aliases[0]?"|"+e._aliases[0]:"")+(e.options.length?" [options]":"")+(t?" "+t:"")}optionTerm(e){return e.flags}argumentTerm(e){return e.name()}longestSubcommandTermLength(e,t){return t.visibleCommands(e).reduce((i,n)=>Math.max(i,t.subcommandTerm(n).length),0)}longestOptionTermLength(e,t){return t.visibleOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestGlobalOptionTermLength(e,t){return t.visibleGlobalOptions(e).reduce((i,n)=>Math.max(i,t.optionTerm(n).length),0)}longestArgumentTermLength(e,t){return t.visibleArguments(e).reduce((i,n)=>Math.max(i,t.argumentTerm(n).length),0)}commandUsage(e){let t=e._name;e._aliases[0]&&(t=t+"|"+e._aliases[0]);let i="";for(let n=e.parent;n;n=n.parent)i=n.name()+" "+i;return i+t+" "+e.usage()}commandDescription(e){return e.description()}subcommandDescription(e){return e.summary()||e.description()}optionDescription(e){let t=[];return e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&(e.required||e.optional||e.isBoolean()&&typeof e.defaultValue=="boolean")&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),e.presetArg!==void 0&&e.optional&&t.push(`preset: ${JSON.stringify(e.presetArg)}`),e.envVar!==void 0&&t.push(`env: ${e.envVar}`),t.length>0?`${e.description} (${t.join(", ")})`:e.description}argumentDescription(e){let t=[];if(e.argChoices&&t.push(`choices: ${e.argChoices.map(i=>JSON.stringify(i)).join(", ")}`),e.defaultValue!==void 0&&t.push(`default: ${e.defaultValueDescription||JSON.stringify(e.defaultValue)}`),t.length>0){let i=`(${t.join(", ")})`;return e.description?`${e.description} ${i}`:i}return e.description}formatHelp(e,t){let i=t.padWidth(e,t),n=t.helpWidth||80,r=2,s=2;function u(p,x){if(x){let D=`${p.padEnd(i+s)}${x}`;return t.wrap(D,n-r,i+s)}return p}function a(p){return p.join(`
|
|
4
4
|
`).replace(/^/gm," ".repeat(r))}let l=[`Usage: ${t.commandUsage(e)}`,""],h=t.commandDescription(e);h.length>0&&(l=l.concat([t.wrap(h,n,0),""]));let c=t.visibleArguments(e).map(p=>u(t.argumentTerm(p),t.argumentDescription(p)));c.length>0&&(l=l.concat(["Arguments:",a(c),""]));let C=t.visibleOptions(e).map(p=>u(t.optionTerm(p),t.optionDescription(p)));if(C.length>0&&(l=l.concat(["Options:",a(C),""])),this.showGlobalOptions){let p=t.visibleGlobalOptions(e).map(x=>u(t.optionTerm(x),t.optionDescription(x)));p.length>0&&(l=l.concat(["Global Options:",a(p),""]))}let y=t.visibleCommands(e).map(p=>u(t.subcommandTerm(p),t.subcommandDescription(p)));return y.length>0&&(l=l.concat(["Commands:",a(y),""])),l.join(`
|
|
5
5
|
`)}padWidth(e,t){return Math.max(t.longestOptionTermLength(e,t),t.longestGlobalOptionTermLength(e,t),t.longestSubcommandTermLength(e,t),t.longestArgumentTermLength(e,t))}wrap(e,t,i,n=40){let r=" \\f\\t\\v\xA0\u1680\u2000-\u200A\u202F\u205F\u3000\uFEFF",s=new RegExp(`[\\n][${r}]+`);if(e.match(s))return e;let u=t-i;if(u<n)return e;let a=e.slice(0,i),l=e.slice(i).replace(`\r
|
|
6
6
|
`,`
|
|
@@ -21,5 +21,5 @@ Expecting one of '${i.join("', '")}'`);return this._lifeCycleHooks[e]?this._life
|
|
|
21
21
|
`),this.outputHelp({error:!0}));let i=t||{},n=i.exitCode||1,r=i.code||"commander.error";this._exit(n,r,e)}_parseOptionsEnv(){this.options.forEach(e=>{if(e.envVar&&e.envVar in d.env){let t=e.attributeName();(this.getOptionValue(t)===void 0||["default","config","env"].includes(this.getOptionValueSource(t)))&&(e.required||e.optional?this.emit(`optionEnv:${e.name()}`,d.env[e.envVar]):this.emit(`optionEnv:${e.name()}`))}})}_parseOptionsImplied(){let e=new Ue(this.options),t=i=>this.getOptionValue(i)!==void 0&&!["default","implied"].includes(this.getOptionValueSource(i));this.options.filter(i=>i.implied!==void 0&&t(i.attributeName())&&e.valueFromOption(this.getOptionValue(i.attributeName()),i)).forEach(i=>{Object.keys(i.implied).filter(n=>!t(n)).forEach(n=>{this.setOptionValueWithSource(n,i.implied[n],"implied")})})}missingArgument(e){let t=`error: missing required argument '${e}'`;this.error(t,{code:"commander.missingArgument"})}optionMissingArgument(e){let t=`error: option '${e.flags}' argument missing`;this.error(t,{code:"commander.optionMissingArgument"})}missingMandatoryOptionValue(e){let t=`error: required option '${e.flags}' not specified`;this.error(t,{code:"commander.missingMandatoryOptionValue"})}_conflictingOption(e,t){let i=s=>{let u=s.attributeName(),a=this.getOptionValue(u),l=this.options.find(c=>c.negate&&u===c.attributeName()),h=this.options.find(c=>!c.negate&&u===c.attributeName());return l&&(l.presetArg===void 0&&a===!1||l.presetArg!==void 0&&a===l.presetArg)?l:h||s},n=s=>{let u=i(s),a=u.attributeName();return this.getOptionValueSource(a)==="env"?`environment variable '${u.envVar}'`:`option '${u.flags}'`},r=`error: ${n(e)} cannot be used with ${n(t)}`;this.error(r,{code:"commander.conflictingOption"})}unknownOption(e){if(this._allowUnknownOption)return;let t="";if(e.startsWith("--")&&this._showSuggestionAfterError){let n=[],r=this;do{let s=r.createHelp().visibleOptions(r).filter(u=>u.long).map(u=>u.long);n=n.concat(s),r=r.parent}while(r&&!r._enablePositionalOptions);t=re(e,n)}let i=`error: unknown option '${e}'${t}`;this.error(i,{code:"commander.unknownOption"})}_excessArguments(e){if(this._allowExcessArguments)return;let t=this.registeredArguments.length,i=t===1?"":"s",r=`error: too many arguments${this.parent?` for '${this.name()}'`:""}. Expected ${t} argument${i} but got ${e.length}.`;this.error(r,{code:"commander.excessArguments"})}unknownCommand(){let e=this.args[0],t="";if(this._showSuggestionAfterError){let n=[];this.createHelp().visibleCommands(this).forEach(r=>{n.push(r.name()),r.alias()&&n.push(r.alias())}),t=re(e,n)}let i=`error: unknown command '${e}'${t}`;this.error(i,{code:"commander.unknownCommand"})}version(e,t,i){if(e===void 0)return this._version;this._version=e,t=t||"-V, --version",i=i||"output the version number";let n=this.createOption(t,i);return this._versionOptionName=n.attributeName(),this._registerOption(n),this.on("option:"+n.name(),()=>{this._outputConfiguration.writeOut(`${e}
|
|
22
22
|
`),this._exit(0,"commander.version",e)}),this}description(e,t){return e===void 0&&t===void 0?this._description:(this._description=e,t&&(this._argsDescription=t),this)}summary(e){return e===void 0?this._summary:(this._summary=e,this)}alias(e){if(e===void 0)return this._aliases[0];let t=this;if(this.commands.length!==0&&this.commands[this.commands.length-1]._executableHandler&&(t=this.commands[this.commands.length-1]),e===t._name)throw new Error("Command alias can't be the same as its name");let i=this.parent?._findCommand(e);if(i){let n=[i.name()].concat(i.aliases()).join("|");throw new Error(`cannot add alias '${e}' to command '${this.name()}' as already have command '${n}'`)}return t._aliases.push(e),this}aliases(e){return e===void 0?this._aliases:(e.forEach(t=>this.alias(t)),this)}usage(e){if(e===void 0){if(this._usage)return this._usage;let t=this.registeredArguments.map(i=>Me(i));return[].concat(this.options.length||this._helpOption!==null?"[options]":[],this.commands.length?"[command]":[],this.registeredArguments.length?t:[]).join(" ")}return this._usage=e,this}name(e){return e===void 0?this._name:(this._name=e,this)}nameFromFilename(e){return this._name=v.basename(e,v.extname(e)),this}executableDir(e){return e===void 0?this._executableDir:(this._executableDir=e,this)}helpInformation(e){let t=this.createHelp();return t.helpWidth===void 0&&(t.helpWidth=e&&e.error?this._outputConfiguration.getErrHelpWidth():this._outputConfiguration.getOutHelpWidth()),t.formatHelp(this,t)}_getHelpContext(e){e=e||{};let t={error:!!e.error},i;return t.error?i=n=>this._outputConfiguration.writeErr(n):i=n=>this._outputConfiguration.writeOut(n),t.write=e.write||i,t.command=this,t}outputHelp(e){let t;typeof e=="function"&&(t=e,e=void 0);let i=this._getHelpContext(e);this._getCommandAndAncestors().reverse().forEach(r=>r.emit("beforeAllHelp",i)),this.emit("beforeHelp",i);let n=this.helpInformation(i);if(t&&(n=t(n),typeof n!="string"&&!Buffer.isBuffer(n)))throw new Error("outputHelp callback must return a string or a Buffer");i.write(n),this._getHelpOption()?.long&&this.emit(this._getHelpOption().long),this.emit("afterHelp",i),this._getCommandAndAncestors().forEach(r=>r.emit("afterAllHelp",i))}helpOption(e,t){return typeof e=="boolean"?(e?this._helpOption=this._helpOption??void 0:this._helpOption=null,this):(e=e??"-h, --help",t=t??"display help for command",this._helpOption=this.createOption(e,t),this)}_getHelpOption(){return this._helpOption===void 0&&this.helpOption(void 0,void 0),this._helpOption}addHelpOption(e){return this._helpOption=e,this}help(e){this.outputHelp(e);let t=d.exitCode||0;t===0&&e&&typeof e!="function"&&e.error&&(t=1),this._exit(t,"commander.help","(outputHelp)")}addHelpText(e,t){let i=["beforeAll","before","after","afterAll"];if(!i.includes(e))throw new Error(`Unexpected value for position to addHelpText.
|
|
23
23
|
Expecting one of '${i.join("', '")}'`);let n=`${e}Help`;return this.on(n,r=>{let s;typeof t=="function"?s=t({error:r.error,command:r.command}):s=t,s&&r.write(`${s}
|
|
24
|
-
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(n=>t.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function se(o){return o.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",n="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?n=r[3]:i=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],i=r[3],n=r[4]),t&&n!=="0"?`${t}=${i}:${parseInt(n)+1}`:e})}oe.Command=Q});var me=E(w=>{"use strict";m();var{Argument:ue}=T(),{Command:X}=ae(),{CommanderError:Re,InvalidArgumentError:le}=k(),{Help:Ge}=R(),{Option:he}=J();w.program=new X;w.createCommand=o=>new X(o);w.createOption=(o,e)=>new he(o,e);w.createArgument=(o,e)=>new ue(o,e);w.Command=X;w.Option=he;w.Argument=ue;w.Help=Ge;w.CommanderError=Re;w.InvalidArgumentError=le;w.InvalidOptionArgumentError=le});var de=E((O,ce)=>{"use strict";m();var b=me();O=ce.exports={};O.program=new b.Command;O.Argument=b.Argument;O.Command=b.Command;O.CommanderError=b.CommanderError;O.Help=b.Help;O.InvalidArgumentError=b.InvalidArgumentError;O.InvalidOptionArgumentError=b.InvalidArgumentError;O.Option=b.Option;O.createCommand=o=>new b.Command(o);O.createOption=(o,e)=>new b.Option(o,e);O.createArgument=(o,e)=>new b.Argument(o,e)});m();m();m();var pe=$(de(),1),{program:at,createCommand:_,createArgument:ut,createOption:lt,CommanderError:ht,InvalidArgumentError:I,InvalidOptionArgumentError:mt,Command:ct,Argument:dt,Option:fe,Help:pt}=pe.default;m();var ge=o=>_("build").action(async(e,t)=>{let{runCommand:i}=await import("./render-command-
|
|
24
|
+
`)}),this}_outputHelpIfRequested(e){let t=this._getHelpOption();t&&e.find(n=>t.is(n))&&(this.outputHelp(),this._exit(0,"commander.helpDisplayed","(outputHelp)"))}};function se(o){return o.map(e=>{if(!e.startsWith("--inspect"))return e;let t,i="127.0.0.1",n="9229",r;return(r=e.match(/^(--inspect(-brk)?)$/))!==null?t=r[1]:(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+)$/))!==null?(t=r[1],/^\d+$/.test(r[3])?n=r[3]:i=r[3]):(r=e.match(/^(--inspect(-brk|-port)?)=([^:]+):(\d+)$/))!==null&&(t=r[1],i=r[3],n=r[4]),t&&n!=="0"?`${t}=${i}:${parseInt(n)+1}`:e})}oe.Command=Q});var me=E(w=>{"use strict";m();var{Argument:ue}=T(),{Command:X}=ae(),{CommanderError:Re,InvalidArgumentError:le}=k(),{Help:Ge}=R(),{Option:he}=J();w.program=new X;w.createCommand=o=>new X(o);w.createOption=(o,e)=>new he(o,e);w.createArgument=(o,e)=>new ue(o,e);w.Command=X;w.Option=he;w.Argument=ue;w.Help=Ge;w.CommanderError=Re;w.InvalidArgumentError=le;w.InvalidOptionArgumentError=le});var de=E((O,ce)=>{"use strict";m();var b=me();O=ce.exports={};O.program=new b.Command;O.Argument=b.Argument;O.Command=b.Command;O.CommanderError=b.CommanderError;O.Help=b.Help;O.InvalidArgumentError=b.InvalidArgumentError;O.InvalidOptionArgumentError=b.InvalidArgumentError;O.Option=b.Option;O.createCommand=o=>new b.Command(o);O.createOption=(o,e)=>new b.Option(o,e);O.createArgument=(o,e)=>new b.Argument(o,e)});m();m();m();var pe=$(de(),1),{program:at,createCommand:_,createArgument:ut,createOption:lt,CommanderError:ht,InvalidArgumentError:I,InvalidOptionArgumentError:mt,Command:ct,Argument:dt,Option:fe,Help:pt}=pe.default;m();var ge=o=>_("build").action(async(e,t)=>{let{runCommand:i}=await import("./render-command-QEQ3L7OX.js"),{build:n}=await import("./build-3RXHADZD.js");await i(t,o,n)});m();var _e=$(V(),1);var Ce=o=>{let e=A();return _("dev").option("-s, --https",e("dev_command_def.option.https")).action(async(t,i)=>{let{DevCommand:n}=await import("./DevCommand-Q5XLAGMG.js"),{renderCommand:r}=await import("./render-command-QEQ3L7OX.js"),{https:s=!1}=t;await r(i,o,_e.default.createElement(n,{https:s}),{watchForModelChanges:!0})})};m();var we=$(V(),1);m();function F(o){let e=S.union([S.string().uuid(),S.literal("current")]).transform(t=>t==="current"?void 0:t).safeParse(o);if(e.success)return e.data;throw new I('Value must be a valid GUID or "current"')}function q(o){let e=S.string().url().safeParse(o);if(e.success)return e.data;throw new I("Value must be a valid URL")}function Oe(o){let e=S.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)(\.(0|[1-9]\d*))?$/).safeParse(o);if(e.success)return e.data;throw new I("Version value should be in semver format `x.x.x`")}var be=o=>{let e=A();return _("preview").option("-s, --site <site-id>",e("app_preview_command_def.option.site"),F).option("--base-url <url>",e("app_preview_command_def.option.base_url"),q).option("--no-input",e("app_preview_command_def.option.no_input")).action(async(t,i)=>{let{site:n,baseUrl:r,input:s}=t,{renderCommand:u,runCommand:a}=await import("./render-command-QEQ3L7OX.js");if(!s)return a(i,o,async h=>{let{nonInteractivePreview:c}=await import("./preview-TM7JAWFS.js");return c({siteId:n,baseUrl:r},h,o)});let{PreviewCommand:l}=await import("./PreviewCommand-JKPFMGWV.js");await u(i,o,we.default.createElement(l,{baseUrl:r,siteIdOverride:n}))})};m();var Ae=$(V(),1);var ve=o=>{let e=A();return _("create-version").addOption(new fe("-t, --version-type <type>",e("create_version_command_def.option.version_type")).choices(["major","minor"])).option("-s, --site <site-id>",e("create_version_command_def.option.site"),F).option("-y, --approve-preview",e("create_version_command_def.option.approve_preview")).option("--base-url <url>",e("create_version_command_def.option.base_url"),q).action(async(t,i)=>{let{VersionType:n}=await import("./types.impl-L2DPGJ77.js"),{renderCommand:r}=await import("./render-command-QEQ3L7OX.js"),{CreateVersionCommand:s}=await import("./CreateVersionCommand-XTZT5DED.js"),{approvePreview:u=!1,versionType:a,baseUrl:l,site:h}=t,c={major:n.MAJOR,minor:n.MINOR},C=a?c[a]:void 0;await r(i,o,Ae.default.createElement(s,{baseUrl:l,siteIdOverride:h,preApprovePreview:u,versionType:C}))})};m();var xe=$(V(),1);var Ee=o=>_("serve").action(async(e,t)=>{let{renderCommand:i}=await import("./render-command-QEQ3L7OX.js"),{ServeCommand:n}=await import("./ServeCommand-CPZOI7DC.js");await i(t,o,xe.default.createElement(n,null))});m();var ye=$(V(),1);var $e=o=>{let e=A();return _("generate").description(e("generate_command.description")).action(async(t,i)=>{let{GenerateCommand:n}=await import("./GenerateCommand-HNFICZJA.js"),{renderCommand:r}=await import("./render-command-QEQ3L7OX.js");await r(i,o,ye.default.createElement(n,null),{skipProjectValidation:!0})})};m();var Ve=$(V(),1);var Se=o=>{let e=A();return _("logs").requiredOption("--version <version>",e("logs_command_def.option.version"),Oe).action(async(t,i)=>{let{version:n}=t,{renderCommand:r}=await import("./render-command-QEQ3L7OX.js"),{LogsCommand:s}=await import("./LogsCommand-XJHE75L2.js");await r(i,o,Ve.default.createElement(s,{version:n}))})};var Le=async o=>_("app").version(Z,"-v, --version","Output the version number").enablePositionalOptions(!0).helpOption("-h, --help","Display help for command").helpCommand(!1).addCommand(Ce(o)).addCommand(ge(o)).addCommand(Ee(o)).addCommand(be(o)).addCommand(ve(o)).addCommand($e(o)).addCommand(Se(o));export{Le as getRootCommand};
|
|
25
25
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../node_modules/@wix/sdk-runtime/build/host-modules.js"],"sourcesContent":["import { contextualizeHostModuleV2 } from './context-v2.js';\nexport function createHostModule(hostModuleAPI) {\n return contextualizeHostModuleV2({\n __type: 'host',\n create: (host) => Object.entries(hostModuleAPI).reduce((acc, [key, fn]) => ({\n ...acc,\n [key]: fn(host),\n }), {}),\n }, Object.keys(hostModuleAPI));\n}\n"],"mappings":"wCACO,SAASA,EAAiBC,EAAe,CAC5C,OAAOC,EAA0B,CAC7B,OAAQ,OACR,OAASC,GAAS,OAAO,QAAQF,CAAa,EAAE,OAAO,CAACG,EAAK,CAACC,EAAKC,CAAE,KAAO,CACxE,GAAGF,EACH,CAACC,CAAG,EAAGC,EAAGH,CAAI,CAClB,GAAI,CAAC,CAAC,CACV,EAAG,OAAO,KAAKF,CAAa,CAAC,CACjC","names":["createHostModule","hostModuleAPI","contextualizeHostModuleV2","host","acc","key","fn"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as re,b as ie,c as se,d as ae,f as W}from"./chunk-SBZEOPXX.js";var le={};se(le,{EventDefinition:()=>v,SERVICE_PLUGIN_ERROR_TYPE:()=>S,ServicePluginDefinition:()=>ce});function v(e,t=!1,n=i=>i){return()=>({__type:"event-definition",type:e,isDomainEvent:t,transformations:n})}function ce(e,t){return{__type:"service-plugin-definition",componentType:e,methods:t}}var S,A=re(()=>{"use strict";S="wix_spi_error"});var K=ie((Fe,G)=>{"use strict";var R=class e extends Error{constructor(t){super(e._prepareSuperMessage(t)),Object.defineProperty(this,"name",{value:"NonError",configurable:!0,writable:!0}),Error.captureStackTrace&&Error.captureStackTrace(this,e)}static _prepareSuperMessage(t){try{return JSON.stringify(t)}catch{return String(t)}}},xe=[{property:"name",enumerable:!1},{property:"message",enumerable:!1},{property:"stack",enumerable:!1},{property:"code",enumerable:!0}],P=Symbol(".toJSON called"),me=e=>{e[P]=!0;let t=e.toJSON();return delete e[P],t},j=({from:e,seen:t,to_:n,forceEnumerable:i,maxDepth:o,depth:r})=>{let a=n||(Array.isArray(e)?[]:{});if(t.push(e),r>=o)return a;if(typeof e.toJSON=="function"&&e[P]!==!0)return me(e);for(let[s,l]of Object.entries(e)){if(typeof Buffer=="function"&&Buffer.isBuffer(l)){a[s]="[object Buffer]";continue}if(typeof l!="function"){if(!l||typeof l!="object"){a[s]=l;continue}if(!t.includes(e[s])){r++,a[s]=j({from:e[s],seen:t.slice(),forceEnumerable:i,maxDepth:o,depth:r});continue}a[s]="[Circular]"}}for(let{property:s,enumerable:l}of xe)typeof e[s]=="string"&&Object.defineProperty(a,s,{value:e[s],enumerable:i?!0:l,configurable:!0,writable:!0});return a},we=(e,t={})=>{let{maxDepth:n=Number.POSITIVE_INFINITY}=t;return typeof e=="object"&&e!==null?j({from:e,seen:[],forceEnumerable:!0,maxDepth:n,depth:0}):typeof e=="function"?`[Function: ${e.name||"anonymous"}]`:e},ye=(e,t={})=>{let{maxDepth:n=Number.POSITIVE_INFINITY}=t;if(e instanceof Error)return e;if(typeof e=="object"&&e!==null&&!Array.isArray(e)){let i=new Error;return j({from:e,seen:[],to_:i,maxDepth:n,depth:0}),i}return new R(e)};G.exports={serializeError:we,deserializeError:ye}});A();import{wixContext as te}from"@wix/sdk-context";var de=e=>{switch(e){case"get":case"GET":return"GET";case"post":case"POST":return"POST";case"put":case"PUT":return"PUT";case"delete":case"DELETE":return"DELETE";case"patch":case"PATCH":return"PATCH";case"head":case"HEAD":return"HEAD";case"options":case"OPTIONS":return"OPTIONS";default:throw new Error(`Unknown method: ${e}`)}},H=e=>t=>async n=>{let i,o=r=>{if(i=e(n)(r),i.url===void 0)throw new Error("Url was not successfully created for this request, please reach out to support channels for assistance.");let{method:a,url:s,params:l}=i;return{...i,method:de(a),url:s,data:i.data,params:l}};try{let r=await t.request(o);if(i===void 0)throw new Error("Request options were not created for this request, please reach out to support channels for assistance.");let a=Array.isArray(i.transformResponse)?i.transformResponse:[i.transformResponse],s=r.data;return a.forEach(l=>{l&&(s=l(r.data,r.headers))}),s}catch(r){throw typeof r=="object"&&r!==null&&"response"in r&&typeof r.response=="object"&&r.response!==null&&"data"in r.response?r.response.data:r}},I=e=>e.__isAmbassador?!0:!!e().__isAmbassador;var $="__metadata",E="www.wixapis.com";var M=class extends Error{constructor(n,i){super(n);W(this,"message");W(this,"response");this.message=n,this.response=i}async details(){let n=await this.response.json();return ue(this.response.status,n?.message,n?.details,{requestId:this.response.headers.get("X-Wix-Request-Id"),details:n})}},ue=(e,t,n,i)=>({details:{...!n?.validationError&&{applicationError:{description:t,code:e,data:i}},...n},message:t});var k=e=>e?.method&&["post","put","patch"].includes(e.method.toLocaleLowerCase())&&e.body?{"Content-Type":"application/json"}:{},U=e=>e&&typeof e=="object"&&!Array.isArray(e);var O=e=>e.__type==="host";function N(e,t){return e.create(t)}var pe="x-wix-bi-gateway";function q(e,t,n){return{[pe]:fe({environment:`js-sdk${n?`-${n}`:""}`,"package-name":e.packageName??t?.PACKAGE_NAME,"method-fqn":e.methodFqn,entity:e.entityFqdn})}}function fe(e){return Object.entries(e).filter(([t,n])=>!!n).map(([t,n])=>`${t}=${n}`).join(",")}import{wixContext as y}from"@wix/sdk-context";function Pe(e,t){return{...e,...Object.fromEntries(t.map(n=>[n,(...i)=>{let o=J();if(!o)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return o.initWixModules(e)[n].apply(void 0,i)}]))}}function J(){let e=typeof $wixContext<"u"&&$wixContext.initWixModules?$wixContext.initWixModules:typeof globalThis.__wix_context__<"u"&&globalThis.__wix_context__.initWixModules?globalThis.__wix_context__.initWixModules:void 0;if(e)return{initWixModules(i,o){return _(()=>e(i,o))},fetchWithAuth(){throw new Error("fetchWithAuth is not available in this context")},graphql(){throw new Error("graphql is not available in this context")}};let t=typeof $wixContext<"u"?$wixContext.client:typeof y.client<"u"?y.client:typeof globalThis.__wix_context__<"u"?globalThis.__wix_context__.client:void 0,n=typeof $wixContext<"u"?$wixContext.elevatedClient:typeof y.elevatedClient<"u"?y.elevatedClient:typeof globalThis.__wix_context__<"u"?globalThis.__wix_context__.elevatedClient:void 0;if(!(!t&&!n))return{initWixModules(i,o){if(o){if(!n)throw new Error("An elevated client is required to use elevated modules. Make sure to initialize the Wix context with an elevated client before using elevated SDK modules");return _(()=>n.use(i))}if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return _(()=>t.use(i))},fetchWithAuth:(i,o)=>{if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return t.fetchWithAuth(i,o)},async graphql(i,o,r){if(!t)throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");return t.graphql(i,o,r)}}}function _(e){let t=globalThis.__wix_context__,n={client:y.client,elevatedClient:y.elevatedClient},i;globalThis.__wix_context__=void 0,y.client=void 0,y.elevatedClient=void 0,typeof $wixContext<"u"&&(i={client:$wixContext?.client,elevatedClient:$wixContext?.elevatedClient},delete $wixContext.client,delete $wixContext.elevatedClient);try{return e()}finally{globalThis.__wix_context__=t,y.client=n.client,y.elevatedClient=n.elevatedClient,typeof $wixContext<"u"&&($wixContext.client=i.client,$wixContext.elevatedClient=i.elevatedClient)}}function D(e,t,n,i,o,r,a){return _(()=>e({request:async s=>{let l=s({host:r?.HTTPHost||E}),d=l;d.method==="GET"&&d.fallback?.length&&d.params.toString().length>4e3&&(d=l.fallback[0]);let h=`https://${r?.HTTPHost??E}${d.url}`;d.params&&d.params.toString()&&(h+=`?${d.params.toString()}`);try{let p=q(l,t,a),w=await n(h,{method:d.method,...d.data&&{body:JSON.stringify(d.data)},headers:{...p}});if(w.status!==200){let c=null;try{c=await w.json()}catch{}throw he(w.status,c?.message,c?.details,{requestId:w.headers.get("X-Wix-Request-Id"),details:c})}return{data:await w.json(),headers:w.headers,status:w.status,statusText:w.statusText}}catch(p){throw p.message?.includes("fetch is not defined")&&console.error("Node.js v18+ is required"),p}},fetchWithAuth:n,wixAPIFetch:i,getActiveToken:o}))}var he=(e,t,n,i)=>({response:{data:{details:{...!n?.validationError&&{applicationError:{description:t,code:e,data:i}},...n},message:t},status:e}});A();function C(){return{emit(e,...t){for(let n=0,i=this.events[e]||[],o=i.length;n<o;n++)i[n](...t)},events:{},on(e,t){return(this.events[e]||=[]).push(t),()=>{this.events[e]=this.events[e]?.filter(n=>t!==n)}}}}var L=e=>e.__type==="event-definition";function z(e,t,n,i){let o;if(e.isDomainEvent){let a=n,{deletedEvent:s,actionEvent:l,createdEvent:d,updatedEvent:u,...h}=a,p={...i,...h};s?s?.deletedEntity?o={entity:s?.deletedEntity,metadata:p}:o={metadata:p}:l?o={data:l.body,metadata:p}:o={entity:d?.entity??u?.currentEntity,metadata:p}}else o={data:n,metadata:i};let r=e.transformations??(a=>a);return t(r(o))}function B(e){let t=new Map,n=C(),i={...n,getRegisteredEvents:()=>t,async process(o,r={expectedEvents:[]}){let{eventType:a,identity:s,instanceId:l,payload:d}=await this.parseJWT(o),u=[...r.expectedEvents,...Array.from(t.keys()).map(p=>({type:p}))];if(u.length>0&&!u.some(({type:p})=>p===a))throw new Error(`Unexpected event type: ${a}. Expected one of: ${u.map(p=>p.type).join(", ")}`);let h=t.get(a)??[];return await Promise.all(h.map(({eventDefinition:p,handler:w})=>z(p,w,d,{instanceId:l,identity:s}))),{instanceId:l,eventType:a,payload:d,identity:s}},async processRequest(o,r){let a=await o.text();return this.process(a,r)},async parseJWT(o){if(!e.decodeJWT)throw new Error("decodeJWT is not supported by the authentication strategy");let{decoded:r,valid:a}=await e.decodeJWT(o);if(!a)throw new Error("JWT is not valid");if(typeof r.data!="string")throw new Error(`Unexpected type of JWT data: expected string, got ${typeof r.data}`);let s=JSON.parse(r.data),l=s.eventType,d=s.instanceId,u=s.identity?JSON.parse(s.identity):void 0,h=JSON.parse(s.data);return{instanceId:d,eventType:l,payload:h,identity:u}},async parseRequest(o){let r=await o.text();return this.parseJWT(r)},async executeHandlers(o){let r=Array.from(t.keys()).map(s=>({type:s}));if(r.length>0&&!r.some(({type:s})=>s===o.eventType))throw new Error(`Unexpected event type: ${o.eventType}. Expected one of: ${r.map(s=>s.type).join(", ")}`);let a=t.get(o.eventType)??[];await Promise.all(a.map(({eventDefinition:s,handler:l})=>z(s,l,o.payload,{instanceId:o.instanceId,identity:o.identity})))},apps:{AppInstalled:v("AppInstalled")(),AppRemoved:v("AppRemoved")()}};return{initModule(o){return r=>{let a=t.get(o.type)??[];a.push({eventDefinition:o,handler:r}),t.set(o.type,a),n.emit("registered",o)}},client:i}}var F=e=>e.__type==="service-plugin-definition";function V(e){let t=new Map,n=C(),i={...n,getRegisteredServicePlugins:()=>t,async parseJWT(o){if(!e.decodeJWT)throw new Error("decodeJWT is not supported by the authentication strategy");let{decoded:r,valid:a}=await e.decodeJWT(o,!0);if(!a)throw new Error("JWT is not valid");if(typeof r.data!="object"||r.data===null||!("metadata"in r.data)||typeof r.data.metadata!="object"||r.data.metadata===null||!("appExtensionType"in r.data.metadata)||typeof r.data.metadata.appExtensionType!="string")throw new Error("Unexpected JWT data: expected object with metadata.appExtensionType string");return r.data},async process(o){let r=await this.parseJWT(o.body);return this.executeHandler(r,o.url)},async parseRequest(o){let r=await o.text();return this.parseJWT(r)},async processRequest(o){let r=o.url,a=await o.text();try{let s=await this.process({url:r,body:a});return Response.json(s)}catch(s){if(s.errorType==="SPI"&&s.applicationCode&&s.httpCode)return Response.json({applicationError:{code:s.applicationCode,data:s.data}},{status:s.httpCode});throw s}},async executeHandler(o,r){let a=o.metadata.appExtensionType.toLowerCase(),s=t.get(a)??[];if(s.length===0)throw new Error(`No service plugin implementations found for component type ${a}`);if(s.length>1)throw new Error(`Multiple service plugin implementations found for component type ${a}. This is currently not supported`);let{implementation:l,servicePluginDefinition:d}=s[0],u=d.methods.find(p=>r.endsWith(p.primaryHttpMappingPath));if(!u)throw new Error("Unexpect request: request url did not match any method: "+r);let h=l[u.name];if(!h)throw new Error(`Got request for service plugin method ${u.name} but no implementation was provided. Available methods: ${Object.keys(l).join(", ")}`);return u.transformations.toREST(await h(u.transformations.fromREST(o)))}};return{initModule(o){return r=>{let a=t.get(o.componentType.toLowerCase())??[];a.push({servicePluginDefinition:o,implementation:r}),t.set(o.componentType.toLowerCase(),a),n.emit("registered",o)}},client:i}}var Q=ae(K(),1);async function Y(e){let t=await fetch("https://www.wixapis.com/oauth2/token-info",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:e})});if(t.status!==200)throw new Error(`Failed to get token info. Unexpected status code from Wix OAuth API: ${t.status}`);return await t.json()}var Z=e=>e.__type==="web-method-module",g;(function(e){e.Anyone="anyone",e.Admin="admin",e.SiteMember="site-member"})(g||(g={}));async function Ee(e,t){let n=e.headers.get("Authorization");if(!n)throw new Error("Request is missing authentication data");let{subjectType:i}=await Y(n);switch(t){case g.Anyone:{if(i!=="VISITOR"&&i!=="MEMBER"&&i!=="USER")throw new Error("Insufficient permissions");break}case g.SiteMember:{if(i!=="MEMBER"&&i!=="USER")throw new Error("Insufficient permissions");break}case g.Admin:{if(i!=="USER")throw new Error("Insufficient permissions");break}}}var _e=/\/_webMethods\/(.+\..+)\/(.+\..+)/;function be(e){let t=e.match(_e);if(t)return[t[1],t[2].replace(".ajax","")]}function Te(e){return!!e&&typeof e=="object"&&Array.isArray(e)}var X="Error: Unable to handle the request. Contact the site administrator or view site monitoring logs for more information.";function ee(){let e={};return{initModule(n){Object.assign(e,n)},client:{async processRequest(n,i=!1){let o=be(n.url);if(!o)return new Response("invalid request",{status:400});let[r,a]=o,s=await n.json();if(!Te(s))return new Response("invalid request",{status:400});let l=e[`/${r}`];try{if(!l)throw new Error(`Error loading web module ${r}: Cannot find module '${r}'`);let u=(await l())[a];if(!u)throw new Error(`Error loading function from web module ${r}: function '${a}' not found`);return await Ee(n,u.permission),Response.json({result:await u.handler(...s)})}catch(d){let u=(0,Q.serializeError)(d,{maxDepth:1});return Response.json({result:i||!(d instanceof Error)?u:{...u,message:X,stack:X},exception:!0})}}}}}function ct(e){let t=e.headers||{Authorization:""},n=e.auth||{getAuthHeaders:c=>Promise.resolve({headers:{}})},i=n.getAuthHeaders.bind(void 0,e.host);n.getAuthHeaders=i;let o=async(c,f)=>{if(typeof c=="string"||c instanceof URL)return fetch(c,{...f,headers:{...f?.headers,...(await i()).headers}});for(let[x,m]of Object.entries((await i()).headers))c.headers.set(x,m);return fetch(c,f)},{client:r,initModule:a}=V(n),{client:s,initModule:l}=B(n),{client:d,initModule:u}=ee(),h=async(c,f)=>{let x=await i(),m=k(f);return fetch(c,{...f,headers:{...m,...t,...x?.headers,...f?.headers,...e.host?.essentials?.passThroughHeaders}})},p=(c,f)=>{if(L(c))return l(c);if(F(c))return a(c);if(O(c)&&e.host)return N(c,e.host);if(Z(c))return u(c);if(typeof c=="function"){if("__type"in c&&c.__type===S)return c;let x=e.host?.apiBaseUrl??E;return D(_(()=>I(c))?H(c):c,f??{},h,(m,b)=>{let T=new URL(m,`https://${x}`);return T.host=x,T.protocol="https",h(T.toString(),b)},n.getActiveToken,{HTTPHost:x},e.host?.name)}else return U(c)?Object.fromEntries(Object.entries(c).map(([x,m])=>[x,p(m,c[$])])):c},w=c=>{for(let f in c)t[f]=c[f]};return{...e.modules?p(e.modules):{},auth:n,setHeaders:w,use:p,enableContext(c,f={elevated:!1}){c==="global"?globalThis.__wix_context__!=null?f.elevated?globalThis.__wix_context__.elevatedClient=this:globalThis.__wix_context__.client=this:f.elevated?globalThis.__wix_context__={elevatedClient:this}:globalThis.__wix_context__={client:this}:f.elevated?te.elevatedClient=this:te.client=this},fetch:(c,f)=>{let x=e.host?.apiBaseUrl??E,m=new URL(c,`https://${x}`);return m.host=x,m.protocol="https",h(m.toString(),f)},fetchWithAuth:o,async graphql(c,f,x={apiVersion:"alpha"}){let m=e?.host?.apiBaseUrl??E,b=await h(`https://${m}/graphql/${x.apiVersion}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({query:c,variables:f})});if(b.status!==200)throw new M(`GraphQL request failed with status ${b.status}`,b);let{data:T,errors:oe}=await b.json();return{data:T??{},errors:oe}},webhooks:s,webMethods:d,servicePlugins:r}}export{le as a,A as b,Pe as c,ct as d};
|
|
2
|
+
//# sourceMappingURL=chunk-KGLNBMRO.js.map
|