@wix/astro 0.0.0-experimental-react-component → 0.0.1-experimental
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/build/fsevents-X6WP4TKM.node +0 -0
- package/build/index.d.ts +9 -0
- package/build/index.js +17347 -0
- package/build/index.js.map +1 -0
- package/build-browser-runtime/setup.d.ts +5 -0
- package/build-browser-runtime/setup.js +963 -0
- package/build-runtime/auth.d.ts +5 -0
- package/build-runtime/auth.js +3557 -0
- package/build-runtime/chunk-24J7STEA.js +8 -0
- package/build-runtime/chunk-B6RICTPP.js +94 -0
- package/build-runtime/chunk-C3QOE2TZ.js +7 -0
- package/build-runtime/chunk-EK7YZVWJ.js +353 -0
- package/build-runtime/chunk-FR26HCAT.js +471 -0
- package/build-runtime/chunk-HDTWPOIV.js +811 -0
- package/build-runtime/chunk-HPW4ZAEJ.js +23 -0
- package/build-runtime/chunk-JODQ44LE.js +1079 -0
- package/build-runtime/chunk-MLKGABMK.js +9 -0
- package/build-runtime/chunk-NVTQFGTR.js +7 -0
- package/build-runtime/chunk-PSHIUVP2.js +131 -0
- package/build-runtime/chunk-Q3KPY4P2.js +3104 -0
- package/build-runtime/chunk-QRPWKJ4C.js +41 -0
- package/build-runtime/chunk-RKE6XT5Z.js +3104 -0
- package/build-runtime/chunk-UZPSWWI5.js +13 -0
- package/build-runtime/chunk-VMS3NKCF.js +18 -0
- package/build-runtime/chunk-W73LN534.js +24 -0
- package/build-runtime/chunk-WYNC47R3.js +7 -0
- package/build-runtime/chunk-YMZMZCBN.js +4063 -0
- package/build-runtime/chunk-YX6EVX5Q.js +11 -0
- package/build-runtime/context/elevated.d.ts +2 -0
- package/build-runtime/context/elevated.js +25 -0
- package/build-runtime/context/non-elevated.d.ts +2 -0
- package/build-runtime/context/non-elevated.js +32 -0
- package/build-runtime/context/nonElevated.d.ts +2 -0
- package/build-runtime/context/nonElevated.js +38 -0
- package/build-runtime/context/setupServicePlugin.d.ts +5 -0
- package/build-runtime/context/setupServicePlugin.js +16 -0
- package/build-runtime/context/setupWebhook.d.ts +5 -0
- package/build-runtime/context/setupWebhook.js +16 -0
- package/build-runtime/middleware/auth.d.ts +5 -0
- package/build-runtime/middleware/auth.js +74 -0
- package/build-runtime/middleware/html-embeds.d.ts +5 -0
- package/build-runtime/middleware/html-embeds.js +166 -0
- package/build-runtime/routes/auth/callback.d.ts +5 -0
- package/build-runtime/routes/auth/callback.js +52 -0
- package/build-runtime/routes/auth/login.d.ts +5 -0
- package/build-runtime/routes/auth/login.js +45 -0
- package/build-runtime/routes/auth/logout-callback.d.ts +5 -0
- package/build-runtime/routes/auth/logout-callback.js +23 -0
- package/build-runtime/routes/auth/logout.d.ts +5 -0
- package/build-runtime/routes/auth/logout.js +32 -0
- package/build-runtime/routes/paylink/checkout.d.ts +5 -0
- package/build-runtime/routes/paylink/checkout.js +35 -0
- package/build-runtime/routes/paylink/paylink.d.ts +5 -0
- package/build-runtime/routes/paylink/paylink.js +34 -0
- package/build-runtime/routes/robots/robots.d.ts +5 -0
- package/build-runtime/routes/robots/robots.js +44 -0
- package/build-runtime/routes/service-plugins.d.ts +5 -0
- package/build-runtime/routes/service-plugins.js +11 -0
- package/build-runtime/routes/servicePluginsDevRoute.d.ts +5 -0
- package/build-runtime/routes/servicePluginsDevRoute.js +13 -0
- package/build-runtime/routes/webhooks.d.ts +5 -0
- package/build-runtime/routes/webhooks.js +11 -0
- package/build-runtime/routes/webhooksDevRoute.d.ts +5 -0
- package/build-runtime/routes/webhooksDevRoute.js +13 -0
- package/build-runtime/routes/wix-apis/api.d.ts +5 -0
- package/build-runtime/routes/wix-apis/api.js +34 -0
- package/package.json +45 -16
- package/runtime/entry.astro +26 -0
- package/CHANGELOG.md +0 -82
- package/src/builders.ts +0 -18
- package/src/index.ts +0 -42
- package/tsconfig.json +0 -7
- package/tsup.config.mjs +0 -36
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
// ../../node_modules/@wix/sdk-runtime/build/constants.js
|
|
2
|
+
var SDKRequestToRESTRequestRenameMap = {
|
|
3
|
+
_id: "id",
|
|
4
|
+
_createdDate: "createdDate",
|
|
5
|
+
_updatedDate: "updatedDate"
|
|
6
|
+
};
|
|
7
|
+
var RESTResponseToSDKResponseRenameMap = {
|
|
8
|
+
id: "_id",
|
|
9
|
+
createdDate: "_createdDate",
|
|
10
|
+
updatedDate: "_updatedDate"
|
|
11
|
+
};
|
|
12
|
+
var ITEMS_RESULT_PROPERTY_NAME = "items";
|
|
13
|
+
var PAGING_METADATA_RESULT_PROPERTY_NAME = "pagingMetadata";
|
|
14
|
+
var DEFAULT_LIMIT = 50;
|
|
15
|
+
|
|
16
|
+
// ../../node_modules/@wix/sdk-runtime/build/utils.js
|
|
17
|
+
function constantCase(input) {
|
|
18
|
+
return split(input).map((part) => part.toLocaleUpperCase()).join("_");
|
|
19
|
+
}
|
|
20
|
+
var SPLIT_LOWER_UPPER_RE = new RegExp("([\\p{Ll}\\d])(\\p{Lu})", "gu");
|
|
21
|
+
var SPLIT_UPPER_UPPER_RE = new RegExp("(\\p{Lu})([\\p{Lu}][\\p{Ll}])", "gu");
|
|
22
|
+
var SPLIT_REPLACE_VALUE = "$1\0$2";
|
|
23
|
+
var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
|
|
24
|
+
function split(value) {
|
|
25
|
+
let result = value.trim();
|
|
26
|
+
result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
|
|
27
|
+
result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
|
|
28
|
+
let start = 0;
|
|
29
|
+
let end = result.length;
|
|
30
|
+
while (result.charAt(start) === "\0") {
|
|
31
|
+
start++;
|
|
32
|
+
}
|
|
33
|
+
if (start === end) {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
while (result.charAt(end - 1) === "\0") {
|
|
37
|
+
end--;
|
|
38
|
+
}
|
|
39
|
+
return result.slice(start, end).split(/\0/g);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ../../node_modules/@wix/sdk-runtime/build/transform-error.js
|
|
43
|
+
var isValidationError = (httpClientError) => "validationError" in (httpClientError.response?.data?.details ?? {});
|
|
44
|
+
var isApplicationError = (httpClientError) => "applicationError" in (httpClientError.response?.data?.details ?? {});
|
|
45
|
+
var isClientError = (httpClientError) => (httpClientError.response?.status ?? -1) >= 400 && (httpClientError.response?.status ?? -1) < 500;
|
|
46
|
+
function transformError(httpClientError, pathsToArguments = {
|
|
47
|
+
explicitPathsToArguments: {},
|
|
48
|
+
spreadPathsToArguments: {},
|
|
49
|
+
singleArgumentUnchanged: false
|
|
50
|
+
}, argumentNames = []) {
|
|
51
|
+
if (typeof httpClientError !== "object" || httpClientError === null) {
|
|
52
|
+
throw httpClientError;
|
|
53
|
+
}
|
|
54
|
+
if (isValidationError(httpClientError)) {
|
|
55
|
+
return buildValidationError(httpClientError, pathsToArguments, argumentNames);
|
|
56
|
+
}
|
|
57
|
+
if (isApplicationError(httpClientError)) {
|
|
58
|
+
return buildApplicationError(httpClientError);
|
|
59
|
+
}
|
|
60
|
+
if (isClientError(httpClientError)) {
|
|
61
|
+
const status = httpClientError.response?.status;
|
|
62
|
+
const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
|
|
63
|
+
const message = httpClientError.response?.data?.message ?? statusText;
|
|
64
|
+
const details = {
|
|
65
|
+
applicationError: {
|
|
66
|
+
description: statusText,
|
|
67
|
+
code: constantCase(statusText),
|
|
68
|
+
data: {}
|
|
69
|
+
},
|
|
70
|
+
requestId: httpClientError.requestId
|
|
71
|
+
};
|
|
72
|
+
return buildError({
|
|
73
|
+
message: JSON.stringify({
|
|
74
|
+
message,
|
|
75
|
+
details
|
|
76
|
+
}, null, 2),
|
|
77
|
+
extraProperties: { details, status }
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return buildSystemError(httpClientError);
|
|
81
|
+
}
|
|
82
|
+
var buildValidationError = (httpClientError, pathsToArguments, argumentNames) => {
|
|
83
|
+
const validationErrorResponse = httpClientError.response?.data;
|
|
84
|
+
const requestId = httpClientError.requestId;
|
|
85
|
+
const { fieldViolations } = validationErrorResponse.details.validationError;
|
|
86
|
+
const transformedFieldViolations = violationsWithRenamedFields(pathsToArguments, fieldViolations, argumentNames)?.sort((a, b) => a.field < b.field ? -1 : 1);
|
|
87
|
+
const message = `INVALID_ARGUMENT: ${transformedFieldViolations?.map(({ field, description }) => `"${field}" ${description}`)?.join(", ")}`;
|
|
88
|
+
const details = {
|
|
89
|
+
validationError: { fieldViolations: transformedFieldViolations },
|
|
90
|
+
requestId
|
|
91
|
+
};
|
|
92
|
+
return buildError({
|
|
93
|
+
message: JSON.stringify({ message, details }, null, 2),
|
|
94
|
+
extraProperties: {
|
|
95
|
+
details,
|
|
96
|
+
status: httpClientError.response?.status,
|
|
97
|
+
requestId
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
var buildError = ({ message, extraProperties }) => {
|
|
102
|
+
const error = new Error(message);
|
|
103
|
+
return Object.assign(error, extraProperties);
|
|
104
|
+
};
|
|
105
|
+
var buildApplicationError = (httpClientError) => {
|
|
106
|
+
const status = httpClientError.response?.status;
|
|
107
|
+
const statusText = httpClientError.response?.statusText ?? "UNKNOWN";
|
|
108
|
+
const message = httpClientError.response?.data?.message ?? statusText;
|
|
109
|
+
const description = httpClientError.response?.data?.details?.applicationError?.description ?? statusText;
|
|
110
|
+
const code = httpClientError.response?.data?.details?.applicationError?.code ?? constantCase(statusText);
|
|
111
|
+
const data = httpClientError.response?.data?.details?.applicationError?.data ?? {};
|
|
112
|
+
const combinedMessage = message === description ? message : `${message}: ${description}`;
|
|
113
|
+
const details = {
|
|
114
|
+
applicationError: {
|
|
115
|
+
description,
|
|
116
|
+
code,
|
|
117
|
+
data
|
|
118
|
+
},
|
|
119
|
+
requestId: httpClientError.requestId
|
|
120
|
+
};
|
|
121
|
+
return buildError({
|
|
122
|
+
message: JSON.stringify({ message: combinedMessage, details }, null, 2),
|
|
123
|
+
extraProperties: {
|
|
124
|
+
details,
|
|
125
|
+
status,
|
|
126
|
+
requestId: httpClientError.requestId
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
var buildSystemError = (httpClientError) => {
|
|
131
|
+
const message = httpClientError.requestId ? `System error occurred, request-id: ${httpClientError.requestId}` : `System error occurred: ${JSON.stringify(httpClientError)}`;
|
|
132
|
+
return buildError({
|
|
133
|
+
message,
|
|
134
|
+
extraProperties: {
|
|
135
|
+
requestId: httpClientError.requestId,
|
|
136
|
+
status: httpClientError.response?.status,
|
|
137
|
+
code: constantCase(httpClientError.response?.statusText ?? "UNKNOWN"),
|
|
138
|
+
...!httpClientError.response && {
|
|
139
|
+
runtimeError: httpClientError
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
var violationsWithRenamedFields = ({ spreadPathsToArguments, explicitPathsToArguments, singleArgumentUnchanged }, fieldViolations, argumentNames) => {
|
|
145
|
+
const allPathsToArguments = {
|
|
146
|
+
...spreadPathsToArguments,
|
|
147
|
+
...explicitPathsToArguments
|
|
148
|
+
};
|
|
149
|
+
const allPathsToArgumentsKeys = Object.keys(allPathsToArguments);
|
|
150
|
+
return fieldViolations?.filter((fieldViolation) => {
|
|
151
|
+
const containedInAMoreSpecificViolationField = fieldViolations.some((anotherViolation) => anotherViolation.field.length > fieldViolation.field.length && anotherViolation.field.startsWith(fieldViolation.field) && allPathsToArgumentsKeys.includes(anotherViolation.field));
|
|
152
|
+
return !containedInAMoreSpecificViolationField;
|
|
153
|
+
}).map((fieldViolation) => {
|
|
154
|
+
const exactMatchArgumentExpression = explicitPathsToArguments[fieldViolation.field];
|
|
155
|
+
if (exactMatchArgumentExpression) {
|
|
156
|
+
return {
|
|
157
|
+
...fieldViolation,
|
|
158
|
+
field: withRenamedArgument(exactMatchArgumentExpression, argumentNames)
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
const longestPartialPathMatch = allPathsToArgumentsKeys?.sort((a, b) => b.length - a.length)?.find((path) => fieldViolation.field.startsWith(path));
|
|
162
|
+
if (longestPartialPathMatch) {
|
|
163
|
+
const partialMatchArgumentExpression = allPathsToArguments[longestPartialPathMatch];
|
|
164
|
+
if (partialMatchArgumentExpression) {
|
|
165
|
+
return {
|
|
166
|
+
...fieldViolation,
|
|
167
|
+
field: fieldViolation.field.replace(longestPartialPathMatch, withRenamedArgument(partialMatchArgumentExpression, argumentNames))
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
if (singleArgumentUnchanged) {
|
|
172
|
+
return {
|
|
173
|
+
...fieldViolation,
|
|
174
|
+
field: `${argumentNames[0]}.${fieldViolation.field}`
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
return fieldViolation;
|
|
178
|
+
});
|
|
179
|
+
};
|
|
180
|
+
var withRenamedArgument = (fieldValue, argumentNames) => {
|
|
181
|
+
const argIndex = getArgumentIndex(fieldValue);
|
|
182
|
+
if (argIndex !== null && typeof argIndex !== "undefined") {
|
|
183
|
+
return fieldValue.replace(`$[${argIndex}]`, argumentNames[argIndex]);
|
|
184
|
+
}
|
|
185
|
+
return fieldValue;
|
|
186
|
+
};
|
|
187
|
+
var getArgumentIndex = (s) => {
|
|
188
|
+
const match = s.match(/\$\[(?<argIndex>\d+)\]/);
|
|
189
|
+
return match && match.groups && Number(match.groups.argIndex);
|
|
190
|
+
};
|
|
191
|
+
|
|
192
|
+
// ../../node_modules/@wix/sdk-runtime/build/rename-all-nested-keys.js
|
|
193
|
+
function renameAllNestedKeys(payload, renameMap, ignorePaths) {
|
|
194
|
+
const isIgnored = (path) => ignorePaths.includes(path);
|
|
195
|
+
const traverse = (obj, path) => {
|
|
196
|
+
if (Array.isArray(obj)) {
|
|
197
|
+
obj.forEach((item) => {
|
|
198
|
+
traverse(item, path);
|
|
199
|
+
});
|
|
200
|
+
} else if (typeof obj === "object" && obj !== null) {
|
|
201
|
+
const objAsRecord = obj;
|
|
202
|
+
Object.keys(objAsRecord).forEach((key) => {
|
|
203
|
+
const newPath = path === "" ? key : `${path}.${key}`;
|
|
204
|
+
if (isIgnored(newPath)) {
|
|
205
|
+
return;
|
|
206
|
+
}
|
|
207
|
+
if (key in renameMap && !(renameMap[key] in objAsRecord)) {
|
|
208
|
+
objAsRecord[renameMap[key]] = objAsRecord[key];
|
|
209
|
+
delete objAsRecord[key];
|
|
210
|
+
}
|
|
211
|
+
traverse(objAsRecord[key], newPath);
|
|
212
|
+
});
|
|
213
|
+
}
|
|
214
|
+
};
|
|
215
|
+
traverse(payload, "");
|
|
216
|
+
return payload;
|
|
217
|
+
}
|
|
218
|
+
function renameKeysFromSDKRequestToRESTRequest(payload, ignorePaths = []) {
|
|
219
|
+
return renameAllNestedKeys(payload, SDKRequestToRESTRequestRenameMap, ignorePaths);
|
|
220
|
+
}
|
|
221
|
+
function renameKeysFromRESTResponseToSDKResponse(payload, ignorePaths = []) {
|
|
222
|
+
return renameAllNestedKeys(payload, RESTResponseToSDKResponseRenameMap, ignorePaths);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// ../../node_modules/@wix/sdk-types/build/index.mjs
|
|
226
|
+
function EventDefinition(type, isDomainEvent = false, transformations = (x) => x) {
|
|
227
|
+
return () => ({
|
|
228
|
+
__type: "event-definition",
|
|
229
|
+
type,
|
|
230
|
+
isDomainEvent,
|
|
231
|
+
transformations
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
// ../../node_modules/@wix/sdk-context/build/index.mjs
|
|
236
|
+
var wixContext = {};
|
|
237
|
+
|
|
238
|
+
// ../../node_modules/@wix/sdk-runtime/build/context.js
|
|
239
|
+
function resolveContext() {
|
|
240
|
+
const oldContext = typeof $wixContext !== "undefined" && $wixContext.initWixModules ? $wixContext.initWixModules : typeof globalThis.__wix_context__ !== "undefined" && globalThis.__wix_context__.initWixModules ? globalThis.__wix_context__.initWixModules : void 0;
|
|
241
|
+
if (oldContext) {
|
|
242
|
+
return {
|
|
243
|
+
// @ts-expect-error
|
|
244
|
+
initWixModules(modules, elevated) {
|
|
245
|
+
return runWithoutContext(() => oldContext(modules, elevated));
|
|
246
|
+
},
|
|
247
|
+
fetchWithAuth() {
|
|
248
|
+
throw new Error("fetchWithAuth is not available in this context");
|
|
249
|
+
},
|
|
250
|
+
graphql() {
|
|
251
|
+
throw new Error("graphql is not available in this context");
|
|
252
|
+
}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
const contextualClient = typeof $wixContext !== "undefined" ? $wixContext.client : typeof wixContext.client !== "undefined" ? wixContext.client : typeof globalThis.__wix_context__ !== "undefined" ? globalThis.__wix_context__.client : void 0;
|
|
256
|
+
const elevatedClient = typeof $wixContext !== "undefined" ? $wixContext.elevatedClient : typeof wixContext.elevatedClient !== "undefined" ? wixContext.elevatedClient : typeof globalThis.__wix_context__ !== "undefined" ? globalThis.__wix_context__.elevatedClient : void 0;
|
|
257
|
+
if (!contextualClient && !elevatedClient) {
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
return {
|
|
261
|
+
initWixModules(wixModules, elevated) {
|
|
262
|
+
if (elevated) {
|
|
263
|
+
if (!elevatedClient) {
|
|
264
|
+
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");
|
|
265
|
+
}
|
|
266
|
+
return runWithoutContext(() => elevatedClient.use(wixModules));
|
|
267
|
+
}
|
|
268
|
+
if (!contextualClient) {
|
|
269
|
+
throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
|
|
270
|
+
}
|
|
271
|
+
return runWithoutContext(() => contextualClient.use(wixModules));
|
|
272
|
+
},
|
|
273
|
+
fetchWithAuth: (urlOrRequest, requestInit) => {
|
|
274
|
+
if (!contextualClient) {
|
|
275
|
+
throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
|
|
276
|
+
}
|
|
277
|
+
return contextualClient.fetchWithAuth(urlOrRequest, requestInit);
|
|
278
|
+
},
|
|
279
|
+
getAuth() {
|
|
280
|
+
if (!contextualClient) {
|
|
281
|
+
throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
|
|
282
|
+
}
|
|
283
|
+
return contextualClient.auth;
|
|
284
|
+
},
|
|
285
|
+
async graphql(query, variables, opts) {
|
|
286
|
+
if (!contextualClient) {
|
|
287
|
+
throw new Error("Wix context is not available. Make sure to initialize the Wix context before using SDK modules");
|
|
288
|
+
}
|
|
289
|
+
return contextualClient.graphql(query, variables, opts);
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function runWithoutContext(fn) {
|
|
294
|
+
const globalContext = globalThis.__wix_context__;
|
|
295
|
+
const moduleContext = {
|
|
296
|
+
client: wixContext.client,
|
|
297
|
+
elevatedClient: wixContext.elevatedClient
|
|
298
|
+
};
|
|
299
|
+
let closureContext;
|
|
300
|
+
globalThis.__wix_context__ = void 0;
|
|
301
|
+
wixContext.client = void 0;
|
|
302
|
+
wixContext.elevatedClient = void 0;
|
|
303
|
+
if (typeof $wixContext !== "undefined") {
|
|
304
|
+
closureContext = {
|
|
305
|
+
client: $wixContext?.client,
|
|
306
|
+
elevatedClient: $wixContext?.elevatedClient
|
|
307
|
+
};
|
|
308
|
+
delete $wixContext.client;
|
|
309
|
+
delete $wixContext.elevatedClient;
|
|
310
|
+
}
|
|
311
|
+
try {
|
|
312
|
+
return fn();
|
|
313
|
+
} finally {
|
|
314
|
+
globalThis.__wix_context__ = globalContext;
|
|
315
|
+
wixContext.client = moduleContext.client;
|
|
316
|
+
wixContext.elevatedClient = moduleContext.elevatedClient;
|
|
317
|
+
if (typeof $wixContext !== "undefined") {
|
|
318
|
+
$wixContext.client = closureContext.client;
|
|
319
|
+
$wixContext.elevatedClient = closureContext.elevatedClient;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// ../../node_modules/@wix/sdk-runtime/build/context-v2.js
|
|
325
|
+
function contextualizeRESTModuleV2(restModule, elevated) {
|
|
326
|
+
return (...args) => {
|
|
327
|
+
const context = resolveContext();
|
|
328
|
+
if (!context) {
|
|
329
|
+
return restModule.apply(void 0, args);
|
|
330
|
+
}
|
|
331
|
+
return context.initWixModules(restModule, elevated).apply(void 0, args);
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
function contextualizeEventDefinitionModuleV2(eventDefinition) {
|
|
335
|
+
const contextualMethod = (...args) => {
|
|
336
|
+
const context = resolveContext();
|
|
337
|
+
if (!context) {
|
|
338
|
+
return () => {
|
|
339
|
+
};
|
|
340
|
+
}
|
|
341
|
+
return context.initWixModules(eventDefinition).apply(void 0, args);
|
|
342
|
+
};
|
|
343
|
+
contextualMethod.__type = eventDefinition.__type;
|
|
344
|
+
contextualMethod.type = eventDefinition.type;
|
|
345
|
+
contextualMethod.isDomainEvent = eventDefinition.isDomainEvent;
|
|
346
|
+
contextualMethod.transformations = eventDefinition.transformations;
|
|
347
|
+
return contextualMethod;
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
// ../../node_modules/@wix/sdk-runtime/build/rest-modules.js
|
|
351
|
+
function createRESTModule(descriptor, elevated = false) {
|
|
352
|
+
return contextualizeRESTModuleV2(descriptor, elevated);
|
|
353
|
+
}
|
|
354
|
+
function toURLSearchParams(params, isComplexRequest) {
|
|
355
|
+
const flatten = flattenParams(params);
|
|
356
|
+
const isPayloadNonSerializableAsUrlSearchParams = Object.entries(flatten).some(([key, value]) => key.includes(".") || Array.isArray(value) && value.some((v) => typeof v === "object"));
|
|
357
|
+
const shouldSerializeToRParam = isComplexRequest && isPayloadNonSerializableAsUrlSearchParams;
|
|
358
|
+
if (shouldSerializeToRParam) {
|
|
359
|
+
return new URLSearchParams({ ".r": base64Encode(JSON.stringify(params)) });
|
|
360
|
+
} else {
|
|
361
|
+
return Object.entries(flatten).reduce((urlSearchParams, [key, value]) => {
|
|
362
|
+
const keyParams = Array.isArray(value) ? value : [value];
|
|
363
|
+
keyParams.forEach((param) => {
|
|
364
|
+
if (param === void 0 || param === null || Array.isArray(value) && typeof param === "object") {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
urlSearchParams.append(key, param);
|
|
368
|
+
});
|
|
369
|
+
return urlSearchParams;
|
|
370
|
+
}, new URLSearchParams());
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
function resolveUrl(opts) {
|
|
374
|
+
const domain = resolveDomain(opts.host);
|
|
375
|
+
const mappings = resolveMappingsByDomain(domain, opts.domainToMappings);
|
|
376
|
+
const path = injectDataIntoProtoPath(opts.protoPath, opts.data || {});
|
|
377
|
+
return resolvePathFromMappings(path, mappings);
|
|
378
|
+
}
|
|
379
|
+
function flattenParams(data, path = "") {
|
|
380
|
+
const params = {};
|
|
381
|
+
Object.entries(data).forEach(([key, value]) => {
|
|
382
|
+
const isObject = value !== null && typeof value === "object" && !Array.isArray(value);
|
|
383
|
+
const fieldPath = resolvePath(path, key);
|
|
384
|
+
if (isObject) {
|
|
385
|
+
const serializedObject = flattenParams(value, fieldPath);
|
|
386
|
+
Object.assign(params, serializedObject);
|
|
387
|
+
} else {
|
|
388
|
+
params[fieldPath] = value;
|
|
389
|
+
}
|
|
390
|
+
});
|
|
391
|
+
return params;
|
|
392
|
+
}
|
|
393
|
+
function resolvePath(path, key) {
|
|
394
|
+
return `${path}${path ? "." : ""}${key}`;
|
|
395
|
+
}
|
|
396
|
+
var base64Encode = (value) => {
|
|
397
|
+
const base64 = typeof btoa !== "undefined" ? btoa(value) : Buffer.from(value, "utf-8").toString("base64");
|
|
398
|
+
return base64.replace(/=/g, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
399
|
+
};
|
|
400
|
+
var DOMAINS = ["wix.com", "editorx.com"];
|
|
401
|
+
var USER_DOMAIN = "_";
|
|
402
|
+
var REGEX_CAPTURE_DOMAINS = new RegExp(`\\.(${DOMAINS.join("|")})$`);
|
|
403
|
+
var WIX_API_DOMAINS = ["42.wixprod.net", "uw2-edt-1.wixprod.net"];
|
|
404
|
+
var DEV_WIX_CODE_DOMAIN = "dev.wix-code.com";
|
|
405
|
+
var REGEX_CAPTURE_PROTO_FIELD = /{(.*)}/;
|
|
406
|
+
var REGEX_CAPTURE_API_DOMAINS = new RegExp(`\\.(${WIX_API_DOMAINS.join("|")})$`);
|
|
407
|
+
var REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN = new RegExp(`.*\\.${DEV_WIX_CODE_DOMAIN}$`);
|
|
408
|
+
function resolveDomain(host) {
|
|
409
|
+
const resolvedHost = fixHostExceptions(host);
|
|
410
|
+
return resolvedHost.replace(REGEX_CAPTURE_DOMAINS, "._base_domain_").replace(REGEX_CAPTURE_API_DOMAINS, "._api_base_domain_").replace(REGEX_CAPTURE_DEV_WIX_CODE_DOMAIN, "*.dev.wix-code.com");
|
|
411
|
+
}
|
|
412
|
+
function fixHostExceptions(host) {
|
|
413
|
+
return host.replace("create.editorx.com", "editor.editorx.com");
|
|
414
|
+
}
|
|
415
|
+
function resolveMappingsByDomain(domain, domainToMappings) {
|
|
416
|
+
const mappings = domainToMappings[domain] || domainToMappings[USER_DOMAIN];
|
|
417
|
+
if (!mappings) {
|
|
418
|
+
if (isBaseDomain(domain)) {
|
|
419
|
+
return domainToMappings[wwwBaseDomain];
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return mappings;
|
|
423
|
+
}
|
|
424
|
+
function isBaseDomain(domain) {
|
|
425
|
+
return !!domain.match(/\._base_domain_$/);
|
|
426
|
+
}
|
|
427
|
+
var wwwBaseDomain = "www._base_domain_";
|
|
428
|
+
function injectDataIntoProtoPath(protoPath, data) {
|
|
429
|
+
return protoPath.split("/").map((path) => maybeProtoPathToData(path, data)).join("/");
|
|
430
|
+
}
|
|
431
|
+
function maybeProtoPathToData(protoPath, data) {
|
|
432
|
+
const protoRegExpMatch = protoPath.match(REGEX_CAPTURE_PROTO_FIELD) || [];
|
|
433
|
+
const field = protoRegExpMatch[1];
|
|
434
|
+
if (field) {
|
|
435
|
+
const suffix = protoPath.replace(protoRegExpMatch[0], "");
|
|
436
|
+
return findByPath(data, field, protoPath, suffix);
|
|
437
|
+
}
|
|
438
|
+
return protoPath;
|
|
439
|
+
}
|
|
440
|
+
function findByPath(obj, path, defaultValue, suffix) {
|
|
441
|
+
let result = obj;
|
|
442
|
+
for (const field of path.split(".")) {
|
|
443
|
+
if (!result) {
|
|
444
|
+
return defaultValue;
|
|
445
|
+
}
|
|
446
|
+
result = result[field];
|
|
447
|
+
}
|
|
448
|
+
return `${result}${suffix}`;
|
|
449
|
+
}
|
|
450
|
+
function resolvePathFromMappings(protoPath, mappings) {
|
|
451
|
+
const mapping = mappings?.find((m) => protoPath.startsWith(m.destPath));
|
|
452
|
+
if (!mapping) {
|
|
453
|
+
return protoPath;
|
|
454
|
+
}
|
|
455
|
+
return mapping.srcPath + protoPath.slice(mapping.destPath.length);
|
|
456
|
+
}
|
|
457
|
+
|
|
458
|
+
export {
|
|
459
|
+
SDKRequestToRESTRequestRenameMap,
|
|
460
|
+
ITEMS_RESULT_PROPERTY_NAME,
|
|
461
|
+
PAGING_METADATA_RESULT_PROPERTY_NAME,
|
|
462
|
+
DEFAULT_LIMIT,
|
|
463
|
+
transformError,
|
|
464
|
+
renameKeysFromSDKRequestToRESTRequest,
|
|
465
|
+
renameKeysFromRESTResponseToSDKResponse,
|
|
466
|
+
EventDefinition,
|
|
467
|
+
contextualizeEventDefinitionModuleV2,
|
|
468
|
+
createRESTModule,
|
|
469
|
+
toURLSearchParams,
|
|
470
|
+
resolveUrl
|
|
471
|
+
};
|