@levo-so/core 0.1.76 → 0.1.79
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 +263 -0
- package/dist/client.js +66 -0
- package/dist/constants/collection/defaultByKind.js +33 -0
- package/dist/constants/collection/fieldInterfaceFormat.js +34 -0
- package/dist/constants/collection/fieldInterfaces.js +48 -0
- package/dist/constants/collection/fieldKind.js +78 -0
- package/dist/constants/integration.js +13 -0
- package/dist/constants/media.js +8 -0
- package/dist/constants/oauthProvider.js +4 -0
- package/dist/control/index.js +42 -0
- package/dist/httpClient.js +26 -0
- package/dist/index.js +42 -726
- package/dist/logger/batch.js +52 -0
- package/dist/logger/index.js +77 -0
- package/dist/modules/blog.js +20 -0
- package/dist/modules/collection.js +51 -0
- package/dist/modules/media.js +12 -0
- package/dist/modules/membership.js +50 -0
- package/dist/types/audience.js +40 -0
- package/dist/types/forum/comment.js +10 -0
- package/dist/types/forum/post.js +18 -0
- package/dist/utils/LevoError.js +25 -0
- package/dist/utils/formatImagePath.js +12 -0
- package/dist/utils/getLevoError.js +66 -0
- package/dist/utils/listToX.js +5 -0
- package/package.json +2 -1
package/dist/index.js
CHANGED
|
@@ -1,728 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
get workspace() {
|
|
17
|
-
return a;
|
|
18
|
-
},
|
|
19
|
-
set workspace(g) {
|
|
20
|
-
if (g && !T.test(g))
|
|
21
|
-
throw new Error(
|
|
22
|
-
`Invalid workspace ID: ${g}. Workspace ID must be a string of the format "W[A-Z0-9]{7}".`
|
|
23
|
-
);
|
|
24
|
-
a = g;
|
|
25
|
-
},
|
|
26
|
-
get appName() {
|
|
27
|
-
return t;
|
|
28
|
-
},
|
|
29
|
-
get apiUrl() {
|
|
30
|
-
return d;
|
|
31
|
-
},
|
|
32
|
-
get NODE_ENV() {
|
|
33
|
-
return u;
|
|
34
|
-
},
|
|
35
|
-
get APP_MODE() {
|
|
36
|
-
return i;
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
};
|
|
40
|
-
function O(e) {
|
|
41
|
-
return typeof e < "u" ? e : "";
|
|
42
|
-
}
|
|
43
|
-
const M = (e, t, s, d, u) => {
|
|
44
|
-
let i;
|
|
45
|
-
if (typeof t == "string")
|
|
46
|
-
i = t;
|
|
47
|
-
else {
|
|
48
|
-
const g = u.polyfill("URLSearchParams", !0, !0);
|
|
49
|
-
for (const f in t) {
|
|
50
|
-
const w = t[f];
|
|
51
|
-
if (!(d && w == null))
|
|
52
|
-
if (t[f] instanceof Array)
|
|
53
|
-
for (const E of w)
|
|
54
|
-
g.append(f, O(E));
|
|
55
|
-
else
|
|
56
|
-
g.append(f, O(w));
|
|
57
|
-
}
|
|
58
|
-
i = g.toString();
|
|
59
|
-
}
|
|
60
|
-
const a = e.split("?");
|
|
61
|
-
return i ? s || a.length < 2 ? a[0] + "?" + i : e + "&" + i : s ? a[0] : e;
|
|
62
|
-
}, j = {
|
|
63
|
-
wretch: {
|
|
64
|
-
query(e, t = !1, s = !1) {
|
|
65
|
-
return { ...this, _url: M(this._url, e, t, s, this._config) };
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
}, x = (e, t) => {
|
|
69
|
-
const s = _(e.apiUrl).addon(j);
|
|
70
|
-
return {
|
|
71
|
-
get instance() {
|
|
72
|
-
const d = {
|
|
73
|
-
credentials: "include",
|
|
74
|
-
signal: AbortSignal.timeout(3e4),
|
|
75
|
-
// 30 seconds timeout,
|
|
76
|
-
headers: {}
|
|
77
|
-
};
|
|
78
|
-
return e.workspace && (d.headers = {
|
|
79
|
-
...d?.headers || {},
|
|
80
|
-
"Levo-Workspace": e.workspace
|
|
81
|
-
}), t && typeof t == "object" && Object.keys(t).length > 0 && (d.headers = {
|
|
82
|
-
...d?.headers || {},
|
|
83
|
-
"Levo-Page-Context": encodeURIComponent(JSON.stringify(t))
|
|
84
|
-
}), e.workspace ? s.options(d).query({ workspace: e.workspace }) : s.options(d);
|
|
85
|
-
},
|
|
86
|
-
pageContext: t
|
|
87
|
-
};
|
|
88
|
-
}, L = (e = {}) => {
|
|
89
|
-
const { logApiUrl: t = "https://public-api.levo.so" } = e, s = t, d = /* @__PURE__ */ new Map();
|
|
90
|
-
let u = Promise.resolve(), i = setTimeout(() => {
|
|
91
|
-
}, 0), a = /* @__PURE__ */ new Date();
|
|
92
|
-
const g = (h) => {
|
|
93
|
-
const c = JSON.stringify(h?.content ?? "{}"), o = h?.message ?? "";
|
|
94
|
-
d.set(`${o}${c}`, h);
|
|
95
|
-
}, f = async (h) => {
|
|
96
|
-
const c = `${s}/v1/apm/logs/json`, o = () => _().url(c).post(h).res().catch((n) => console.error(n));
|
|
97
|
-
try {
|
|
98
|
-
if (typeof fetch > "u")
|
|
99
|
-
throw new Error("fetch is not defined");
|
|
100
|
-
if (typeof window < "u" && navigator.sendBeacon)
|
|
101
|
-
try {
|
|
102
|
-
if (!navigator.sendBeacon.bind(navigator)(c, JSON.stringify(h)))
|
|
103
|
-
return o();
|
|
104
|
-
} catch {
|
|
105
|
-
return o();
|
|
106
|
-
}
|
|
107
|
-
else
|
|
108
|
-
return o();
|
|
109
|
-
} catch (n) {
|
|
110
|
-
console.warn(`Failed to send logs to server: ${n}`), h.forEach((r) => g(r));
|
|
111
|
-
}
|
|
112
|
-
}, w = async () => {
|
|
113
|
-
const h = Array.from(d.values());
|
|
114
|
-
if (d.clear(), clearTimeout(i), await u, h.length === 0) {
|
|
115
|
-
a = /* @__PURE__ */ new Date();
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
try {
|
|
119
|
-
await f(h);
|
|
120
|
-
} catch (c) {
|
|
121
|
-
console.error("error sending logs", c);
|
|
122
|
-
} finally {
|
|
123
|
-
a = /* @__PURE__ */ new Date();
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
return {
|
|
127
|
-
ingest: (h) => {
|
|
128
|
-
if (!t) return;
|
|
129
|
-
(Array.isArray(h) ? h : [h]).forEach((o) => g(o)), d.size >= 50 || a.getTime() < Date.now() - 1500 ? (clearTimeout(i), u = w()) : (clearTimeout(i), i = setTimeout(() => {
|
|
130
|
-
u = w();
|
|
131
|
-
}, 1500));
|
|
132
|
-
},
|
|
133
|
-
flush: w
|
|
134
|
-
};
|
|
135
|
-
}, R = typeof window < "u", S = (e) => {
|
|
136
|
-
switch (e) {
|
|
137
|
-
case 0:
|
|
138
|
-
return "log";
|
|
139
|
-
case 1:
|
|
140
|
-
return "info";
|
|
141
|
-
case 2:
|
|
142
|
-
return "warn";
|
|
143
|
-
case 3:
|
|
144
|
-
return "error";
|
|
145
|
-
default:
|
|
146
|
-
return "log";
|
|
147
|
-
}
|
|
148
|
-
}, N = (e, t = {}) => {
|
|
149
|
-
const {
|
|
150
|
-
enableRemote: s = e.NODE_ENV !== "development",
|
|
151
|
-
level: d = e.NODE_ENV !== "development" ? 2 : 0,
|
|
152
|
-
context: u = {},
|
|
153
|
-
logApiUrl: i
|
|
154
|
-
} = t, a = L({ logApiUrl: i }), g = (o) => {
|
|
155
|
-
let n = "";
|
|
156
|
-
const r = o.map((m) => {
|
|
157
|
-
let y = "";
|
|
158
|
-
const b = !n;
|
|
159
|
-
return typeof m == "string" ? (y = m, b && (n = m)) : m instanceof Error ? (y = {
|
|
160
|
-
message: m.message,
|
|
161
|
-
name: m.name,
|
|
162
|
-
stack: m.stack
|
|
163
|
-
}, b && (n = m.message)) : typeof m == "object" ? y = m : (y = String(m), b && (n = String(m))), y;
|
|
164
|
-
}).filter(Boolean);
|
|
165
|
-
return !n && r.length > 0 && (n = "Default message (Check content for details)"), r?.length === 1 && r[0] === n ? { message: n, content: {} } : {
|
|
166
|
-
message: n,
|
|
167
|
-
content: r
|
|
168
|
-
};
|
|
169
|
-
}, f = (o, n) => {
|
|
170
|
-
const r = Array.isArray(n) ? n : [n];
|
|
171
|
-
if (o < d)
|
|
172
|
-
return;
|
|
173
|
-
if (s && o === 3) {
|
|
174
|
-
const { content: y = {}, message: b } = g(r);
|
|
175
|
-
if (b) {
|
|
176
|
-
const W = {
|
|
177
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
178
|
-
level: "error",
|
|
179
|
-
workspace: e.workspace,
|
|
180
|
-
appName: e?.appName,
|
|
181
|
-
isBrowser: R,
|
|
182
|
-
...u,
|
|
183
|
-
message: b,
|
|
184
|
-
content: y
|
|
185
|
-
};
|
|
186
|
-
R && (W.hostname = window.location.hostname, W.pathname = window.location.pathname, W.url = window.location.href, W.page_title = window.document.title, W.userAgent = window.navigator.userAgent), a.ingest(W);
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
const m = S(o);
|
|
190
|
-
console[m](...r);
|
|
191
|
-
};
|
|
192
|
-
return {
|
|
193
|
-
debug: (...o) => {
|
|
194
|
-
f(0, o);
|
|
195
|
-
},
|
|
196
|
-
info: (...o) => {
|
|
197
|
-
f(1, o);
|
|
198
|
-
},
|
|
199
|
-
warn: (...o) => {
|
|
200
|
-
f(2, o);
|
|
201
|
-
},
|
|
202
|
-
error: (...o) => {
|
|
203
|
-
f(3, o);
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
};
|
|
207
|
-
class A extends Error {
|
|
208
|
-
}
|
|
209
|
-
class v extends Error {
|
|
210
|
-
code;
|
|
211
|
-
title;
|
|
212
|
-
status;
|
|
213
|
-
type;
|
|
214
|
-
errors;
|
|
215
|
-
constructor(t) {
|
|
216
|
-
super(t.description), this.name = "Levo Request Error", this.status = t.status, this.code = t.code, this.title = t.title, this.type = t.type, this.errors = t.errors;
|
|
217
|
-
}
|
|
218
|
-
/**
|
|
219
|
-
* Get validation errors for form fields
|
|
220
|
-
*/
|
|
221
|
-
get fieldErrors() {
|
|
222
|
-
return this.errors || [];
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Check if this is a validation error with field-specific errors
|
|
226
|
-
*/
|
|
227
|
-
get hasFieldErrors() {
|
|
228
|
-
return !!this.errors?.length;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
const I = (e) => e instanceof A || e instanceof Error && "response" in e && "status" in e && "url" in e, p = (e) => {
|
|
232
|
-
if (e instanceof v)
|
|
233
|
-
return e;
|
|
234
|
-
if (I(e)) {
|
|
235
|
-
let t = e?.json;
|
|
236
|
-
if (!t && (e?.text || e?.message))
|
|
237
|
-
try {
|
|
238
|
-
t = JSON.parse(e.text || e.message);
|
|
239
|
-
} catch {
|
|
240
|
-
}
|
|
241
|
-
if (t) {
|
|
242
|
-
const s = t;
|
|
243
|
-
return new v({
|
|
244
|
-
status: s?.content?.status || e?.status || 500,
|
|
245
|
-
code: s?.content?.code || "Unknown",
|
|
246
|
-
title: s?.content?.title || `HTTP ${e?.status || 500} Error`,
|
|
247
|
-
description: s?.content?.description || s?.content?.errors?.[0]?.message || `Request failed with status ${e?.status || 500}`,
|
|
248
|
-
type: s?.content?.type,
|
|
249
|
-
errors: s?.content?.errors
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
|
-
return new v({
|
|
253
|
-
status: e?.status || 500,
|
|
254
|
-
code: "HTTP_ERROR",
|
|
255
|
-
title: `HTTP ${e?.status || 500} Error`,
|
|
256
|
-
description: `Request failed with status ${e?.status || 500}`
|
|
257
|
-
});
|
|
258
|
-
}
|
|
259
|
-
if (e instanceof TypeError) {
|
|
260
|
-
if (e?.message.includes("Failed to fetch") || e?.message.includes("Network request failed") || e?.message.includes("fetch"))
|
|
261
|
-
return new v({
|
|
262
|
-
status: 0,
|
|
263
|
-
code: "NETWORK_ERROR",
|
|
264
|
-
title: "Network Error",
|
|
265
|
-
description: "Unable to connect to the server. Please check your internet connection."
|
|
266
|
-
});
|
|
267
|
-
if (e?.message.includes("CORS") || e?.message.includes("cross-origin"))
|
|
268
|
-
return new v({
|
|
269
|
-
status: 0,
|
|
270
|
-
code: "CORS_ERROR",
|
|
271
|
-
title: "CORS Error",
|
|
272
|
-
description: "Cross-origin request blocked. Please contact support."
|
|
273
|
-
});
|
|
274
|
-
}
|
|
275
|
-
return e?.name === "AbortError" || e instanceof DOMException ? new v({
|
|
276
|
-
status: 408,
|
|
277
|
-
code: "REQUEST_TIMEOUT",
|
|
278
|
-
title: "Request Timeout",
|
|
279
|
-
description: "The request was cancelled or timed out. Please try again."
|
|
280
|
-
}) : e?.request ? new v({
|
|
281
|
-
status: e?.response?.status || 500,
|
|
282
|
-
code: e?.code || "REQUEST_ERROR",
|
|
283
|
-
title: "Request Error",
|
|
284
|
-
description: e?.message || "An error occurred while making the request"
|
|
285
|
-
}) : new v({
|
|
286
|
-
status: 500,
|
|
287
|
-
code: "UNKNOWN_ERROR",
|
|
288
|
-
title: "Unexpected Error",
|
|
289
|
-
description: e?.message || "Something unexpected happened"
|
|
290
|
-
});
|
|
291
|
-
}, P = (e, t) => ({
|
|
292
|
-
getAllBlogs: async (u, i = {}, a) => t.instance.url(`/v1/blog/${u}/post/query`).query({ ...a?.params || {} }).options({
|
|
293
|
-
headers: {
|
|
294
|
-
"Levo-Workspace": a?.workspace_id || void 0
|
|
295
|
-
}
|
|
296
|
-
}).post(i).json().then((g) => g).catch((g) => {
|
|
297
|
-
throw p(g);
|
|
298
|
-
}),
|
|
299
|
-
getSingleBlog: async (u, i, a) => t.instance.url(`/v1/blog/${u}/post/${i}`).query({ ...a?.params || {} }).options({
|
|
300
|
-
headers: {
|
|
301
|
-
"Levo-Workspace": a?.workspace_id || void 0
|
|
302
|
-
}
|
|
303
|
-
}).get().json().then((g) => g).catch((g) => {
|
|
304
|
-
throw p(g);
|
|
305
|
-
})
|
|
306
|
-
}), F = (e, t) => ({
|
|
307
|
-
getAllCollections: async (c = {}, o = {}) => t.instance.url("/v1/bevy/collection/query").options(o).post(c).json().then((n) => n).catch((n) => {
|
|
308
|
-
throw p(n);
|
|
309
|
-
}),
|
|
310
|
-
getCollectionByIDExpanded: async (c, o = {}) => t.instance.url(`/v1/bevy/collection/${c}`).options(o).get().json().then((n) => n).catch((n) => {
|
|
311
|
-
throw p(n);
|
|
312
|
-
}),
|
|
313
|
-
createCollection: async (c) => t.instance.url("/v1/bevy/collection").post(c).json().then((o) => o).catch((o) => {
|
|
314
|
-
throw p(o);
|
|
315
|
-
}),
|
|
316
|
-
saveCollectionData: async ({
|
|
317
|
-
collection_id: c,
|
|
318
|
-
data: o,
|
|
319
|
-
options: n = {}
|
|
320
|
-
}) => t.instance.url(`/v1/bevy/content/${c}`).options(n).post(o).json().then((r) => r).catch((r) => {
|
|
321
|
-
throw p(r);
|
|
322
|
-
}),
|
|
323
|
-
getCollectionContentList: async ({
|
|
324
|
-
collection_key: c,
|
|
325
|
-
page: o,
|
|
326
|
-
search: n,
|
|
327
|
-
limit: r = 10,
|
|
328
|
-
where: m
|
|
329
|
-
}) => t.instance.url(`/v1/bevy/content/${c}/query`).post({
|
|
330
|
-
page: o,
|
|
331
|
-
limit: r,
|
|
332
|
-
search: n,
|
|
333
|
-
where: m
|
|
334
|
-
}).json().then((y) => y).catch((y) => {
|
|
335
|
-
throw p(y);
|
|
336
|
-
}),
|
|
337
|
-
saveDraftEntry: async (c, o) => t.instance.url(`/v1/bevy/content/${c}/save-entry`).post(o).json().then((n) => n).catch((n) => {
|
|
338
|
-
throw p(n);
|
|
339
|
-
}),
|
|
340
|
-
editDraftEntry: async (c, o, n) => t.instance.url(`/v1/bevy/content/${c}/${o}/edit-entry`).put(n).json().then((r) => r).catch((r) => {
|
|
341
|
-
throw p(r);
|
|
342
|
-
}),
|
|
343
|
-
getDraftEntry: async (c) => t.instance.url(`/v1/bevy/content/${c}/list-entry`).get().json().then((o) => o).catch((o) => {
|
|
344
|
-
throw p(o);
|
|
345
|
-
}),
|
|
346
|
-
submitDraftEntry: async (c, o) => t.instance.url(`/v1/bevy/content/${c}/submit-entry`).post(o).json().then((n) => n).catch((n) => {
|
|
347
|
-
throw p(n);
|
|
348
|
-
}),
|
|
349
|
-
getFilters: async (c, o = {}) => t.instance.url(`/v1/bevy/collection/${c}/get-filters`).options(o).get().json().then((n) => n).catch((n) => {
|
|
350
|
-
throw p(n);
|
|
351
|
-
})
|
|
352
|
-
}), q = (e, t) => ({
|
|
353
|
-
mediaBulkUpload: async (u, i = {}) => t.instance.url("/v1/assets/media/bulk").options(i).post(u).json().then((a) => a).catch((a) => {
|
|
354
|
-
throw p(a);
|
|
355
|
-
}),
|
|
356
|
-
getAllMedia: async (u = {}) => t.instance.url("/v1/assets/media/query").post(u).json().then((i) => i).catch((i) => {
|
|
357
|
-
throw p(i);
|
|
358
|
-
})
|
|
359
|
-
}), C = ["google", "linkedin", "microsoft"], $ = (e, t) => {
|
|
360
|
-
const s = async (o = {}) => t.instance.url("/v1/membership/auth/oauth/get-redirect-url").options(o).get().json().then((n) => {
|
|
361
|
-
const r = n?.content?.data, m = Object.keys(r);
|
|
362
|
-
if (typeof window < "u")
|
|
363
|
-
for (const y of m) {
|
|
364
|
-
const b = r[y];
|
|
365
|
-
if (b) {
|
|
366
|
-
const W = new URL(b), k = W.searchParams;
|
|
367
|
-
k.set("redirect_uri", window.location.href), e.workspace && k.set("workspace_id", e.workspace), t.pageContext && k.set("page_context", JSON.stringify(t.pageContext)), r[y] = W.toString();
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
return r;
|
|
371
|
-
}).catch(() => C.reduce((n, r) => (n[r] = null, n), {})), d = async (o = {}) => t.instance.url("/v1/membership/auth/sign-out").options(o).post("").json().then((n) => n?.content?.data).catch((n) => {
|
|
372
|
-
throw p(n);
|
|
373
|
-
}), u = async (o = {}) => t.instance.url("/v1/membership/auth/get-me").options(o).get().json().then((n) => n?.content?.data).catch((n) => {
|
|
374
|
-
throw p(n);
|
|
375
|
-
});
|
|
376
|
-
return {
|
|
377
|
-
getOAuthURL: s,
|
|
378
|
-
signOut: d,
|
|
379
|
-
getMe: u,
|
|
380
|
-
updateMe: async (o, n = {}) => t.instance.url("/v1/membership/auth/update-me").options(n).put(o).json().then((r) => r?.content?.data).catch((r) => {
|
|
381
|
-
throw p(r);
|
|
382
|
-
}),
|
|
383
|
-
createPassword: async (o, n = {}) => t.instance.url("/v1/membership/auth/change-password").options(n).put(o).json().then((r) => r?.content?.data).catch((r) => {
|
|
384
|
-
throw p(r);
|
|
385
|
-
}),
|
|
386
|
-
isLoggedIn: async (o = {}) => u(o).then((n) => n).catch(() => null),
|
|
387
|
-
requestMagicLink: async (o, n = {}) => (typeof window < "u" && !o.redirect_uri && (o.redirect_uri = window.location.href), t.instance.url("/v1/membership/auth/request-magic-link").options(n).post(o).json().then((r) => r?.content?.data).catch((r) => {
|
|
388
|
-
throw p(r);
|
|
389
|
-
})),
|
|
390
|
-
requestOtp: async (o, n = {}) => t.instance.url("/v1/membership/auth/request-otp").options(n).post(o).json().then((r) => r?.content?.data).catch((r) => {
|
|
391
|
-
throw p(r);
|
|
392
|
-
}),
|
|
393
|
-
signInWithOtp: async (o, n = {}) => t.instance.url("/v1/membership/auth/signin-with-otp").options(n).post(o).json().then((r) => r?.content?.data).catch((r) => {
|
|
394
|
-
throw p(r);
|
|
395
|
-
}),
|
|
396
|
-
signInWithPassword: async (o, n = {}) => t.instance.url("/v1/membership/auth/signin-with-password").options(n).post(o).json().then((r) => r?.content?.data).catch((r) => {
|
|
397
|
-
throw p(r);
|
|
398
|
-
}),
|
|
399
|
-
signUpWithPassword: async (o, n = {}) => t.instance.url("/v1/membership/auth/signup-with-password").options(n).post(o).json().then((r) => r?.content?.data).catch((r) => {
|
|
400
|
-
throw p(r);
|
|
401
|
-
})
|
|
402
|
-
};
|
|
403
|
-
}, z = (e) => {
|
|
404
|
-
const {
|
|
405
|
-
pageContext: t = {
|
|
406
|
-
url: typeof window < "u" ? window?.location?.href : "",
|
|
407
|
-
referrer: typeof document < "u" ? document?.referrer : "",
|
|
408
|
-
title: typeof document < "u" ? document?.title : ""
|
|
409
|
-
},
|
|
410
|
-
loggerOptions: s = {
|
|
411
|
-
logApiUrl: "https://public-api.levo.so"
|
|
412
|
-
},
|
|
413
|
-
...d
|
|
414
|
-
} = e;
|
|
415
|
-
let u = t;
|
|
416
|
-
const i = U(d), a = x(i, u), g = P(i, a), f = $(i, a), w = F(i, a), E = q(i, a), h = N(i, s);
|
|
417
|
-
return {
|
|
418
|
-
get apiUrl() {
|
|
419
|
-
return i.apiUrl;
|
|
420
|
-
},
|
|
421
|
-
get workspace() {
|
|
422
|
-
return i.workspace;
|
|
423
|
-
},
|
|
424
|
-
get blog() {
|
|
425
|
-
return g;
|
|
426
|
-
},
|
|
427
|
-
get membership() {
|
|
428
|
-
return f;
|
|
429
|
-
},
|
|
430
|
-
get collection() {
|
|
431
|
-
return w;
|
|
432
|
-
},
|
|
433
|
-
get media() {
|
|
434
|
-
return E;
|
|
435
|
-
},
|
|
436
|
-
get logger() {
|
|
437
|
-
return h;
|
|
438
|
-
},
|
|
439
|
-
get fetch() {
|
|
440
|
-
return a.instance;
|
|
441
|
-
},
|
|
442
|
-
get APP_MODE() {
|
|
443
|
-
return i.APP_MODE;
|
|
444
|
-
},
|
|
445
|
-
get NODE_ENV() {
|
|
446
|
-
return i.NODE_ENV;
|
|
447
|
-
},
|
|
448
|
-
get pageContext() {
|
|
449
|
-
return u;
|
|
450
|
-
},
|
|
451
|
-
updatePageContext: (n) => {
|
|
452
|
-
u = Object.assign({}, u, n);
|
|
453
|
-
},
|
|
454
|
-
updateWorkspace: (n) => {
|
|
455
|
-
i.workspace = n;
|
|
456
|
-
}
|
|
457
|
-
};
|
|
458
|
-
}, X = {
|
|
459
|
-
"public-id": "",
|
|
460
|
-
string: "",
|
|
461
|
-
number: null,
|
|
462
|
-
boolean: !1,
|
|
463
|
-
location: null,
|
|
464
|
-
file: null,
|
|
465
|
-
date: null,
|
|
466
|
-
identifier: null,
|
|
467
|
-
record: null,
|
|
468
|
-
group: [],
|
|
469
|
-
collection: {
|
|
470
|
-
m2o: null,
|
|
471
|
-
o2o: null,
|
|
472
|
-
m2m: []
|
|
473
|
-
},
|
|
474
|
-
richtext: {
|
|
475
|
-
html: "",
|
|
476
|
-
text: "",
|
|
477
|
-
json: []
|
|
478
|
-
},
|
|
479
|
-
json: {},
|
|
480
|
-
"array-string": [],
|
|
481
|
-
"array-number": [],
|
|
482
|
-
"array-file": [],
|
|
483
|
-
"array-json": [],
|
|
484
|
-
"array-date": [],
|
|
485
|
-
"array-boolean": [],
|
|
486
|
-
"array-location": []
|
|
487
|
-
}, Y = {
|
|
488
|
-
ArrayWidget: [],
|
|
489
|
-
RecordWidget: [],
|
|
490
|
-
TextWidget: [],
|
|
491
|
-
MultiTextWidget: [],
|
|
492
|
-
CurrencyWidget: [],
|
|
493
|
-
TextareaWidget: [],
|
|
494
|
-
GeocoderWidget: [],
|
|
495
|
-
DropdownWidget: [],
|
|
496
|
-
ToggleCheckboxWidget: [],
|
|
497
|
-
RadioWidget: [],
|
|
498
|
-
NumberWidget: [],
|
|
499
|
-
EmailWidget: ["email"],
|
|
500
|
-
PhoneWidget: ["phone"],
|
|
501
|
-
URLWidget: ["url"],
|
|
502
|
-
DateWidget: [],
|
|
503
|
-
TimeWidget: [],
|
|
504
|
-
SwitchWidget: [],
|
|
505
|
-
RichTextWidget: [],
|
|
506
|
-
DateTimeWidget: [],
|
|
507
|
-
CheckboxWidget: [],
|
|
508
|
-
ImageUploadWidget: [],
|
|
509
|
-
MultiImageUploadWidget: [],
|
|
510
|
-
FileUploadWidget: [],
|
|
511
|
-
MultiFileUploadWidget: [],
|
|
512
|
-
MultiDropdownWidget: [],
|
|
513
|
-
CollectionWidget: [],
|
|
514
|
-
MultiGeocoderWidget: [],
|
|
515
|
-
JSONWidget: [],
|
|
516
|
-
SlugWidget: []
|
|
517
|
-
}, D = [
|
|
518
|
-
"TextWidget",
|
|
519
|
-
"CurrencyWidget",
|
|
520
|
-
"TextareaWidget",
|
|
521
|
-
"GeocoderWidget",
|
|
522
|
-
"MultiGeocoderWidget",
|
|
523
|
-
"DropdownWidget",
|
|
524
|
-
"ToggleCheckboxWidget",
|
|
525
|
-
"RadioWidget",
|
|
526
|
-
"NumberWidget",
|
|
527
|
-
"EmailWidget",
|
|
528
|
-
"PhoneWidget",
|
|
529
|
-
"URLWidget",
|
|
530
|
-
"DateWidget",
|
|
531
|
-
"TimeWidget",
|
|
532
|
-
"SwitchWidget",
|
|
533
|
-
"RichTextWidget",
|
|
534
|
-
"DateTimeWidget",
|
|
535
|
-
"CheckboxWidget",
|
|
536
|
-
"ImageUploadWidget",
|
|
537
|
-
"MultiImageUploadWidget",
|
|
538
|
-
"FileUploadWidget",
|
|
539
|
-
"MultiFileUploadWidget",
|
|
540
|
-
"MultiDropdownWidget",
|
|
541
|
-
"MultiTextWidget"
|
|
542
|
-
], B = [
|
|
543
|
-
"CollectionWidget",
|
|
544
|
-
"ArrayWidget",
|
|
545
|
-
"RecordWidget",
|
|
546
|
-
"JSONWidget",
|
|
547
|
-
"SlugWidget"
|
|
548
|
-
], K = [
|
|
549
|
-
...D,
|
|
550
|
-
...B
|
|
551
|
-
], ee = D.reduce(
|
|
552
|
-
(e, t) => (e[t] = t, e),
|
|
553
|
-
{}
|
|
554
|
-
), te = K.reduce(
|
|
555
|
-
(e, t) => (e[t] = t, e),
|
|
556
|
-
{}
|
|
557
|
-
), ne = [
|
|
558
|
-
"collection",
|
|
559
|
-
"record",
|
|
560
|
-
"group",
|
|
561
|
-
"public-id",
|
|
562
|
-
"string",
|
|
563
|
-
"array-string",
|
|
564
|
-
"number",
|
|
565
|
-
"array-number",
|
|
566
|
-
"date",
|
|
567
|
-
"array-date",
|
|
568
|
-
"boolean",
|
|
569
|
-
"array-boolean",
|
|
570
|
-
"json",
|
|
571
|
-
"array-json",
|
|
572
|
-
"file",
|
|
573
|
-
"array-file",
|
|
574
|
-
"location",
|
|
575
|
-
"array-location",
|
|
576
|
-
"richtext",
|
|
577
|
-
"identifier"
|
|
578
|
-
], l = {
|
|
579
|
-
identifier: "identifier",
|
|
580
|
-
collection: "collection",
|
|
581
|
-
"public-id": "public-id",
|
|
582
|
-
string: "string",
|
|
583
|
-
number: "number",
|
|
584
|
-
boolean: "boolean",
|
|
585
|
-
date: "date",
|
|
586
|
-
json: "json",
|
|
587
|
-
"array-string": "array-string",
|
|
588
|
-
"array-number": "array-number",
|
|
589
|
-
"array-date": "array-date",
|
|
590
|
-
"array-boolean": "array-boolean",
|
|
591
|
-
file: "file",
|
|
592
|
-
"array-file": "array-file",
|
|
593
|
-
record: "record",
|
|
594
|
-
group: "group",
|
|
595
|
-
location: "location",
|
|
596
|
-
"array-location": "array-location",
|
|
597
|
-
richtext: "richtext",
|
|
598
|
-
"array-json": "array-json"
|
|
599
|
-
}, oe = {
|
|
600
|
-
ArrayWidget: l.group,
|
|
601
|
-
RecordWidget: l.record,
|
|
602
|
-
TextWidget: l.string,
|
|
603
|
-
TextareaWidget: l.string,
|
|
604
|
-
EmailWidget: l.string,
|
|
605
|
-
URLWidget: l.string,
|
|
606
|
-
CurrencyWidget: l.string,
|
|
607
|
-
NumberWidget: l.number,
|
|
608
|
-
PhoneWidget: l.string,
|
|
609
|
-
SlugWidget: l.string,
|
|
610
|
-
RichTextWidget: l.string,
|
|
611
|
-
DateWidget: l.date,
|
|
612
|
-
TimeWidget: l.string,
|
|
613
|
-
DateTimeWidget: l.date,
|
|
614
|
-
RadioWidget: l.string,
|
|
615
|
-
CheckboxWidget: l["array-string"],
|
|
616
|
-
ToggleCheckboxWidget: l.boolean,
|
|
617
|
-
SwitchWidget: l.boolean,
|
|
618
|
-
DropdownWidget: l.string,
|
|
619
|
-
MultiDropdownWidget: l["array-string"],
|
|
620
|
-
MultiTextWidget: l["array-string"],
|
|
621
|
-
FileUploadWidget: l.file,
|
|
622
|
-
MultiFileUploadWidget: l["array-file"],
|
|
623
|
-
MultiImageUploadWidget: l["array-file"],
|
|
624
|
-
ImageUploadWidget: l.file,
|
|
625
|
-
GeocoderWidget: l.location,
|
|
626
|
-
MultiGeocoderWidget: l["array-location"],
|
|
627
|
-
CollectionWidget: l.collection,
|
|
628
|
-
JSONWidget: l.json
|
|
629
|
-
}, J = {
|
|
630
|
-
beacon: "so.levo.beacon",
|
|
631
|
-
blog: "so.levo.blog",
|
|
632
|
-
event: "so.levo.event",
|
|
633
|
-
membership: "so.levo.membership",
|
|
634
|
-
payment: "so.levo.payment",
|
|
635
|
-
community: "so.levo.community",
|
|
636
|
-
search_console: "com.google.search_console"
|
|
637
|
-
}, re = Object.values(J), G = ["image", "video", "audio", "document"], se = G.reduce(
|
|
638
|
-
(e, t) => (e[t] = t, e),
|
|
639
|
-
{}
|
|
640
|
-
), ie = (e) => e.reduce((t, s) => (t[s] = s, t), {}), V = (e) => e.reduce((t, s) => (t[s] = s, t), {}), H = [
|
|
641
|
-
// Bevy Events
|
|
642
|
-
"bevy.collection.filled",
|
|
643
|
-
"bevy.collection.submitted",
|
|
644
|
-
"bevy.collection.view",
|
|
645
|
-
// Block Events
|
|
646
|
-
"block.view",
|
|
647
|
-
// Blog Events
|
|
648
|
-
"blog.post.view",
|
|
649
|
-
// Event Events
|
|
650
|
-
"event.booking.confirmed",
|
|
651
|
-
"event.booking.initiated",
|
|
652
|
-
"event.booking.pending",
|
|
653
|
-
"event.coupon.applied",
|
|
654
|
-
"event.event.view",
|
|
655
|
-
// Form Events
|
|
656
|
-
"form.change",
|
|
657
|
-
"form.submit",
|
|
658
|
-
// Membership Events
|
|
659
|
-
"membership.account.signin",
|
|
660
|
-
"membership.account.signout",
|
|
661
|
-
"membership.account.signup",
|
|
662
|
-
// UI Events
|
|
663
|
-
"button.click",
|
|
664
|
-
"page.bounce",
|
|
665
|
-
"page.click",
|
|
666
|
-
"page.copy",
|
|
667
|
-
"page.impression",
|
|
668
|
-
"page.scroll",
|
|
669
|
-
"page.view",
|
|
670
|
-
"page.selection",
|
|
671
|
-
// User Activity Events
|
|
672
|
-
"user.active",
|
|
673
|
-
"user.idle"
|
|
674
|
-
], ae = V(H), ce = {
|
|
675
|
-
published: "published",
|
|
676
|
-
unpublished: "unpublished",
|
|
677
|
-
archived: "archived",
|
|
678
|
-
flagged: "flagged",
|
|
679
|
-
pending_moderation: "pending_moderation"
|
|
680
|
-
}, Q = {
|
|
681
|
-
post: "post",
|
|
682
|
-
poll: "poll",
|
|
683
|
-
gallery: "gallery",
|
|
684
|
-
link: "link"
|
|
685
|
-
}, le = Object.keys(Q), de = {
|
|
686
|
-
draft: "draft",
|
|
687
|
-
published: "published",
|
|
688
|
-
unpublished: "unpublished",
|
|
689
|
-
archived: "archived",
|
|
690
|
-
flagged: "flagged",
|
|
691
|
-
pending_moderation: "pending_moderation"
|
|
692
|
-
}, ue = (e) => {
|
|
693
|
-
const t = e.split("/"), s = t[t.length - 1];
|
|
694
|
-
if (s) {
|
|
695
|
-
const d = encodeURIComponent(s);
|
|
696
|
-
return e.replace(s, d);
|
|
697
|
-
}
|
|
698
|
-
return "";
|
|
699
|
-
};
|
|
1
|
+
import { createLevoClient as r } from "./client.js";
|
|
2
|
+
import { formatImagePath as i } from "./utils/formatImagePath.js";
|
|
3
|
+
import { getLevoError as m } from "./utils/getLevoError.js";
|
|
4
|
+
import { LevoError as s } from "./utils/LevoError.js";
|
|
5
|
+
import { listToColumn as a, listToRecord as p } from "./utils/listToX.js";
|
|
6
|
+
import { defaultByKinds as l } from "./constants/collection/defaultByKind.js";
|
|
7
|
+
import { formatsByInterface as T } from "./constants/collection/fieldInterfaceFormat.js";
|
|
8
|
+
import { CommonFieldIntefaces as c, CommonFieldInterfacesList as E, ComplexFieldInterfacesList as F, FieldInterfaces as O, FieldInterfacesList as S } from "./constants/collection/fieldInterfaces.js";
|
|
9
|
+
import { FieldKind as _, FieldKindList as v, interfaceKinds as A } from "./constants/collection/fieldKind.js";
|
|
10
|
+
import { LEVO_INTEGRATIONS as M, LEVO_INTEGRATIONS_LIST as N } from "./constants/integration.js";
|
|
11
|
+
import { MediaKind as R, MediaKindList as u } from "./constants/media.js";
|
|
12
|
+
import { LevoOAuthProviderList as U } from "./constants/oauthProvider.js";
|
|
13
|
+
import { AnalyticsEvents as h, AnalyticsEventsList as B } from "./types/audience.js";
|
|
14
|
+
import { COMMENT_STATUS as V } from "./types/forum/comment.js";
|
|
15
|
+
import { FORUM_POST_KIND as b, FORUM_POST_STATUS as j, ForumPostKindExpandedList as k } from "./types/forum/post.js";
|
|
700
16
|
export {
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
17
|
+
h as AnalyticsEvents,
|
|
18
|
+
B as AnalyticsEventsList,
|
|
19
|
+
V as COMMENT_STATUS,
|
|
20
|
+
c as CommonFieldIntefaces,
|
|
21
|
+
E as CommonFieldInterfacesList,
|
|
22
|
+
F as ComplexFieldInterfacesList,
|
|
23
|
+
b as FORUM_POST_KIND,
|
|
24
|
+
j as FORUM_POST_STATUS,
|
|
25
|
+
O as FieldInterfaces,
|
|
26
|
+
S as FieldInterfacesList,
|
|
27
|
+
_ as FieldKind,
|
|
28
|
+
v as FieldKindList,
|
|
29
|
+
k as ForumPostKindExpandedList,
|
|
30
|
+
M as LEVO_INTEGRATIONS,
|
|
31
|
+
N as LEVO_INTEGRATIONS_LIST,
|
|
32
|
+
s as LevoError,
|
|
33
|
+
U as LevoOAuthProviderList,
|
|
34
|
+
R as MediaKind,
|
|
35
|
+
u as MediaKindList,
|
|
36
|
+
r as createLevoClient,
|
|
37
|
+
l as defaultByKinds,
|
|
38
|
+
i as formatImagePath,
|
|
39
|
+
T as formatsByInterface,
|
|
40
|
+
m as getLevoError,
|
|
41
|
+
A as interfaceKinds,
|
|
42
|
+
a as listToColumn,
|
|
43
|
+
p as listToRecord
|
|
728
44
|
};
|