@levo-so/core 0.1.82 → 0.1.108

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