@levo-so/core 0.1.78 → 0.1.80

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/core",
3
- "version": "0.1.78",
3
+ "version": "0.1.80",
4
4
  "author": "Levo Engineering <devs@theinternetfolks.com>",
5
5
  "description": "Levo common utilities",
6
6
  "type": "module",
package/dist/client.js DELETED
@@ -1,66 +0,0 @@
1
- import { createLevoControl as m } from "./control/index.js";
2
- import { createHttpClient as d } from "./httpClient.js";
3
- import { createLevoLogger as f } from "./logger/index.js";
4
- import { createLevoBlogModule as C } from "./modules/blog.js";
5
- import { createLevoCollectionModule as v } from "./modules/collection.js";
6
- import { createLevoMediaModule as L } from "./modules/media.js";
7
- import { createLevoMembershipModule as M } from "./modules/membership.js";
8
- const D = (n) => {
9
- const {
10
- pageContext: c = {
11
- url: typeof window < "u" ? window?.location?.href : "",
12
- referrer: typeof document < "u" ? document?.referrer : "",
13
- title: typeof document < "u" ? document?.title : ""
14
- },
15
- loggerOptions: i = {
16
- logApiUrl: "https://public-api.levo.so"
17
- },
18
- ...p
19
- } = n;
20
- let o = c;
21
- const e = m(p), t = d(e, o), a = C(e, t), l = M(e, t), g = v(e, t), u = L(e, t), s = f(e, i);
22
- return {
23
- get apiUrl() {
24
- return e.apiUrl;
25
- },
26
- get workspace() {
27
- return e.workspace;
28
- },
29
- get blog() {
30
- return a;
31
- },
32
- get membership() {
33
- return l;
34
- },
35
- get collection() {
36
- return g;
37
- },
38
- get media() {
39
- return u;
40
- },
41
- get logger() {
42
- return s;
43
- },
44
- get fetch() {
45
- return t.instance;
46
- },
47
- get APP_MODE() {
48
- return e.APP_MODE;
49
- },
50
- get NODE_ENV() {
51
- return e.NODE_ENV;
52
- },
53
- get pageContext() {
54
- return o;
55
- },
56
- updatePageContext: (r) => {
57
- o = Object.assign({}, o, r);
58
- },
59
- updateWorkspace: (r) => {
60
- e.workspace = r;
61
- }
62
- };
63
- };
64
- export {
65
- D as createLevoClient
66
- };
@@ -1,33 +0,0 @@
1
- const l = {
2
- "public-id": "",
3
- string: "",
4
- number: null,
5
- boolean: !1,
6
- location: null,
7
- file: null,
8
- date: null,
9
- identifier: null,
10
- record: null,
11
- group: [],
12
- collection: {
13
- m2o: null,
14
- o2o: null,
15
- m2m: []
16
- },
17
- richtext: {
18
- html: "",
19
- text: "",
20
- json: []
21
- },
22
- json: {},
23
- "array-string": [],
24
- "array-number": [],
25
- "array-file": [],
26
- "array-json": [],
27
- "array-date": [],
28
- "array-boolean": [],
29
- "array-location": []
30
- };
31
- export {
32
- l as defaultByKinds
33
- };
@@ -1,34 +0,0 @@
1
- const e = {
2
- ArrayWidget: [],
3
- RecordWidget: [],
4
- TextWidget: [],
5
- MultiTextWidget: [],
6
- CurrencyWidget: [],
7
- TextareaWidget: [],
8
- GeocoderWidget: [],
9
- DropdownWidget: [],
10
- ToggleCheckboxWidget: [],
11
- RadioWidget: [],
12
- NumberWidget: [],
13
- EmailWidget: ["email"],
14
- PhoneWidget: ["phone"],
15
- URLWidget: ["url"],
16
- DateWidget: [],
17
- TimeWidget: [],
18
- SwitchWidget: [],
19
- RichTextWidget: [],
20
- DateTimeWidget: [],
21
- CheckboxWidget: [],
22
- ImageUploadWidget: [],
23
- MultiImageUploadWidget: [],
24
- FileUploadWidget: [],
25
- MultiFileUploadWidget: [],
26
- MultiDropdownWidget: [],
27
- CollectionWidget: [],
28
- MultiGeocoderWidget: [],
29
- JSONWidget: [],
30
- SlugWidget: []
31
- };
32
- export {
33
- e as formatsByInterface
34
- };
@@ -1,48 +0,0 @@
1
- const i = [
2
- "TextWidget",
3
- "CurrencyWidget",
4
- "TextareaWidget",
5
- "GeocoderWidget",
6
- "MultiGeocoderWidget",
7
- "DropdownWidget",
8
- "ToggleCheckboxWidget",
9
- "RadioWidget",
10
- "NumberWidget",
11
- "EmailWidget",
12
- "PhoneWidget",
13
- "URLWidget",
14
- "DateWidget",
15
- "TimeWidget",
16
- "SwitchWidget",
17
- "RichTextWidget",
18
- "DateTimeWidget",
19
- "CheckboxWidget",
20
- "ImageUploadWidget",
21
- "MultiImageUploadWidget",
22
- "FileUploadWidget",
23
- "MultiFileUploadWidget",
24
- "MultiDropdownWidget",
25
- "MultiTextWidget"
26
- ], d = [
27
- "CollectionWidget",
28
- "ArrayWidget",
29
- "RecordWidget",
30
- "JSONWidget",
31
- "SlugWidget"
32
- ], g = [
33
- ...i,
34
- ...d
35
- ], o = i.reduce(
36
- (e, t) => (e[t] = t, e),
37
- {}
38
- ), W = g.reduce(
39
- (e, t) => (e[t] = t, e),
40
- {}
41
- );
42
- export {
43
- o as CommonFieldIntefaces,
44
- i as CommonFieldInterfacesList,
45
- d as ComplexFieldInterfacesList,
46
- W as FieldInterfaces,
47
- g as FieldInterfacesList
48
- };
@@ -1,78 +0,0 @@
1
- const i = [
2
- "collection",
3
- "record",
4
- "group",
5
- "public-id",
6
- "string",
7
- "array-string",
8
- "number",
9
- "array-number",
10
- "date",
11
- "array-date",
12
- "boolean",
13
- "array-boolean",
14
- "json",
15
- "array-json",
16
- "file",
17
- "array-file",
18
- "location",
19
- "array-location",
20
- "richtext",
21
- "identifier"
22
- ], r = {
23
- identifier: "identifier",
24
- collection: "collection",
25
- "public-id": "public-id",
26
- string: "string",
27
- number: "number",
28
- boolean: "boolean",
29
- date: "date",
30
- json: "json",
31
- "array-string": "array-string",
32
- "array-number": "array-number",
33
- "array-date": "array-date",
34
- "array-boolean": "array-boolean",
35
- file: "file",
36
- "array-file": "array-file",
37
- record: "record",
38
- group: "group",
39
- location: "location",
40
- "array-location": "array-location",
41
- richtext: "richtext",
42
- "array-json": "array-json"
43
- }, e = {
44
- ArrayWidget: r.group,
45
- RecordWidget: r.record,
46
- TextWidget: r.string,
47
- TextareaWidget: r.string,
48
- EmailWidget: r.string,
49
- URLWidget: r.string,
50
- CurrencyWidget: r.string,
51
- NumberWidget: r.number,
52
- PhoneWidget: r.string,
53
- SlugWidget: r.string,
54
- RichTextWidget: r.string,
55
- DateWidget: r.date,
56
- TimeWidget: r.string,
57
- DateTimeWidget: r.date,
58
- RadioWidget: r.string,
59
- CheckboxWidget: r["array-string"],
60
- ToggleCheckboxWidget: r.boolean,
61
- SwitchWidget: r.boolean,
62
- DropdownWidget: r.string,
63
- MultiDropdownWidget: r["array-string"],
64
- MultiTextWidget: r["array-string"],
65
- FileUploadWidget: r.file,
66
- MultiFileUploadWidget: r["array-file"],
67
- MultiImageUploadWidget: r["array-file"],
68
- ImageUploadWidget: r.file,
69
- GeocoderWidget: r.location,
70
- MultiGeocoderWidget: r["array-location"],
71
- CollectionWidget: r.collection,
72
- JSONWidget: r.json
73
- };
74
- export {
75
- r as FieldKind,
76
- i as FieldKindList,
77
- e as interfaceKinds
78
- };
@@ -1,13 +0,0 @@
1
- const o = {
2
- beacon: "so.levo.beacon",
3
- blog: "so.levo.blog",
4
- event: "so.levo.event",
5
- membership: "so.levo.membership",
6
- payment: "so.levo.payment",
7
- community: "so.levo.community",
8
- search_console: "com.google.search_console"
9
- }, e = Object.values(o);
10
- export {
11
- o as LEVO_INTEGRATIONS,
12
- e as LEVO_INTEGRATIONS_LIST
13
- };
@@ -1,8 +0,0 @@
1
- const i = ["image", "video", "audio", "document"], o = i.reduce(
2
- (e, d) => (e[d] = d, e),
3
- {}
4
- );
5
- export {
6
- o as MediaKind,
7
- i as MediaKindList
8
- };
@@ -1,4 +0,0 @@
1
- const o = ["google", "linkedin", "microsoft"];
2
- export {
3
- o as LevoOAuthProviderList
4
- };
@@ -1,42 +0,0 @@
1
- const o = /^W[A-Z0-9]{7}$/, i = (s) => {
2
- const {
3
- appName: a,
4
- workspace: r = null,
5
- apiUrl: p = "https://public-api.levo.so",
6
- NODE_ENV: n = "",
7
- APP_MODE: c = "production"
8
- } = s;
9
- if (r && !o.test(r))
10
- throw new Error(
11
- `Invalid workspace ID: ${r}. Workspace ID must be a string of the format "W[A-Z0-9]{7}".`
12
- );
13
- let t = r;
14
- return {
15
- get workspace() {
16
- return t;
17
- },
18
- set workspace(e) {
19
- if (e && !o.test(e))
20
- throw new Error(
21
- `Invalid workspace ID: ${e}. Workspace ID must be a string of the format "W[A-Z0-9]{7}".`
22
- );
23
- t = e;
24
- },
25
- get appName() {
26
- return a;
27
- },
28
- get apiUrl() {
29
- return p;
30
- },
31
- get NODE_ENV() {
32
- return n;
33
- },
34
- get APP_MODE() {
35
- return c;
36
- }
37
- };
38
- };
39
- export {
40
- i as createLevoControl,
41
- o as workspaceIdRegex
42
- };
@@ -1,26 +0,0 @@
1
- import s from "wretch";
2
- import n from "wretch/addons/queryString";
3
- const c = (r, o) => {
4
- const t = s(r.apiUrl).addon(n);
5
- return {
6
- get instance() {
7
- const e = {
8
- credentials: "include",
9
- signal: AbortSignal.timeout(3e4),
10
- // 30 seconds timeout,
11
- headers: {}
12
- };
13
- return r.workspace && (e.headers = {
14
- ...e?.headers || {},
15
- "Levo-Workspace": r.workspace
16
- }), o && typeof o == "object" && Object.keys(o).length > 0 && (e.headers = {
17
- ...e?.headers || {},
18
- "Levo-Page-Context": encodeURIComponent(JSON.stringify(o))
19
- }), r.workspace ? t.options(e).query({ workspace: r.workspace }) : t.options(e);
20
- },
21
- pageContext: o
22
- };
23
- };
24
- export {
25
- c as createHttpClient
26
- };
@@ -1,52 +0,0 @@
1
- import y from "wretch";
2
- const w = (f = {}) => {
3
- const { logApiUrl: l = "https://public-api.levo.so" } = f, d = l, n = /* @__PURE__ */ new Map();
4
- let o = Promise.resolve(), r = setTimeout(() => {
5
- }, 0), a = /* @__PURE__ */ new Date();
6
- const u = (e) => {
7
- const t = JSON.stringify(e?.content ?? "{}"), s = e?.message ?? "";
8
- n.set(`${s}${t}`, e);
9
- }, h = async (e) => {
10
- const t = `${d}/v1/apm/logs/json`, s = () => y().url(t).post(e).res().catch((i) => console.error(i));
11
- try {
12
- if (typeof fetch > "u")
13
- throw new Error("fetch is not defined");
14
- if (typeof window < "u" && navigator.sendBeacon)
15
- try {
16
- if (!navigator.sendBeacon.bind(navigator)(t, JSON.stringify(e)))
17
- return s();
18
- } catch {
19
- return s();
20
- }
21
- else
22
- return s();
23
- } catch (i) {
24
- console.warn(`Failed to send logs to server: ${i}`), e.forEach((g) => u(g));
25
- }
26
- }, c = async () => {
27
- const e = Array.from(n.values());
28
- if (n.clear(), clearTimeout(r), await o, e.length === 0) {
29
- a = /* @__PURE__ */ new Date();
30
- return;
31
- }
32
- try {
33
- await h(e);
34
- } catch (t) {
35
- console.error("error sending logs", t);
36
- } finally {
37
- a = /* @__PURE__ */ new Date();
38
- }
39
- };
40
- return {
41
- ingest: (e) => {
42
- if (!l) return;
43
- (Array.isArray(e) ? e : [e]).forEach((s) => u(s)), n.size >= 50 || a.getTime() < Date.now() - 1500 ? (clearTimeout(r), o = c()) : (clearTimeout(r), r = setTimeout(() => {
44
- o = c();
45
- }, 1500));
46
- },
47
- flush: c
48
- };
49
- };
50
- export {
51
- w as createLogBatch
52
- };
@@ -1,77 +0,0 @@
1
- import { createLogBatch as h } from "./batch.js";
2
- const l = typeof window < "u", y = (r) => {
3
- switch (r) {
4
- case 0:
5
- return "log";
6
- case 1:
7
- return "info";
8
- case 2:
9
- return "warn";
10
- case 3:
11
- return "error";
12
- default:
13
- return "log";
14
- }
15
- }, A = (r, m = {}) => {
16
- const {
17
- enableRemote: f = r.NODE_ENV !== "development",
18
- level: p = r.NODE_ENV !== "development" ? 2 : 0,
19
- context: w = {},
20
- logApiUrl: d
21
- } = m, g = h({ logApiUrl: d }), u = (t) => {
22
- let n = "";
23
- const o = t.map((e) => {
24
- let s = "";
25
- const a = !n;
26
- return typeof e == "string" ? (s = e, a && (n = e)) : e instanceof Error ? (s = {
27
- message: e.message,
28
- name: e.name,
29
- stack: e.stack
30
- }, a && (n = e.message)) : typeof e == "object" ? s = e : (s = String(e), a && (n = String(e))), s;
31
- }).filter(Boolean);
32
- return !n && o.length > 0 && (n = "Default message (Check content for details)"), o?.length === 1 && o[0] === n ? { message: n, content: {} } : {
33
- message: n,
34
- content: o
35
- };
36
- }, c = (t, n) => {
37
- const o = Array.isArray(n) ? n : [n];
38
- if (t < p)
39
- return;
40
- if (f && t === 3) {
41
- const { content: s = {}, message: a } = u(o);
42
- if (a) {
43
- const i = {
44
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
45
- level: "error",
46
- workspace: r.workspace,
47
- appName: r?.appName,
48
- isBrowser: l,
49
- ...w,
50
- message: a,
51
- content: s
52
- };
53
- l && (i.hostname = window.location.hostname, i.pathname = window.location.pathname, i.url = window.location.href, i.page_title = window.document.title, i.userAgent = window.navigator.userAgent), g.ingest(i);
54
- }
55
- }
56
- const e = y(t);
57
- console[e](...o);
58
- };
59
- return {
60
- debug: (...t) => {
61
- c(0, t);
62
- },
63
- info: (...t) => {
64
- c(1, t);
65
- },
66
- warn: (...t) => {
67
- c(2, t);
68
- },
69
- error: (...t) => {
70
- c(3, t);
71
- }
72
- };
73
- };
74
- export {
75
- A as createLevoLogger,
76
- l as isBrowser
77
- };
@@ -1,20 +0,0 @@
1
- import { getLevoError as a } from "../utils/getLevoError.js";
2
- const p = (c, s) => ({
3
- getAllBlogs: async (r, t = {}, o) => s.instance.url(`/v1/blog/${r}/post/query`).query({ ...o?.params || {} }).options({
4
- headers: {
5
- "Levo-Workspace": o?.workspace_id || void 0
6
- }
7
- }).post(t).json().then((e) => e).catch((e) => {
8
- throw a(e);
9
- }),
10
- getSingleBlog: async (r, t, o) => s.instance.url(`/v1/blog/${r}/post/${t}`).query({ ...o?.params || {} }).options({
11
- headers: {
12
- "Levo-Workspace": o?.workspace_id || void 0
13
- }
14
- }).get().json().then((e) => e).catch((e) => {
15
- throw a(e);
16
- })
17
- });
18
- export {
19
- p as createLevoBlogModule
20
- };
@@ -1,51 +0,0 @@
1
- import { getLevoError as c } from "../utils/getLevoError.js";
2
- const w = (l, o) => ({
3
- getAllCollections: async (e = {}, n = {}) => o.instance.url("/v1/bevy/collection/query").options(n).post(e).json().then((t) => t).catch((t) => {
4
- throw c(t);
5
- }),
6
- getCollectionByIDExpanded: async (e, n = {}) => o.instance.url(`/v1/bevy/collection/${e}`).options(n).get().json().then((t) => t).catch((t) => {
7
- throw c(t);
8
- }),
9
- createCollection: async (e) => o.instance.url("/v1/bevy/collection").post(e).json().then((n) => n).catch((n) => {
10
- throw c(n);
11
- }),
12
- saveCollectionData: async ({
13
- collection_id: e,
14
- data: n,
15
- options: t = {}
16
- }) => o.instance.url(`/v1/bevy/content/${e}`).options(t).post(n).json().then((r) => r).catch((r) => {
17
- throw c(r);
18
- }),
19
- getCollectionContentList: async ({
20
- collection_key: e,
21
- page: n,
22
- search: t,
23
- limit: r = 10,
24
- where: a
25
- }) => o.instance.url(`/v1/bevy/content/${e}/query`).post({
26
- page: n,
27
- limit: r,
28
- search: t,
29
- where: a
30
- }).json().then((s) => s).catch((s) => {
31
- throw c(s);
32
- }),
33
- saveDraftEntry: async (e, n) => o.instance.url(`/v1/bevy/content/${e}/save-entry`).post(n).json().then((t) => t).catch((t) => {
34
- throw c(t);
35
- }),
36
- editDraftEntry: async (e, n, t) => o.instance.url(`/v1/bevy/content/${e}/${n}/edit-entry`).put(t).json().then((r) => r).catch((r) => {
37
- throw c(r);
38
- }),
39
- getDraftEntry: async (e) => o.instance.url(`/v1/bevy/content/${e}/list-entry`).get().json().then((n) => n).catch((n) => {
40
- throw c(n);
41
- }),
42
- submitDraftEntry: async (e, n) => o.instance.url(`/v1/bevy/content/${e}/submit-entry`).post(n).json().then((t) => t).catch((t) => {
43
- throw c(t);
44
- }),
45
- getFilters: async (e, n = {}) => o.instance.url(`/v1/bevy/collection/${e}/get-filters`).options(n).get().json().then((t) => t).catch((t) => {
46
- throw c(t);
47
- })
48
- });
49
- export {
50
- w as createLevoCollectionModule
51
- };
@@ -1,12 +0,0 @@
1
- import { getLevoError as a } from "../utils/getLevoError.js";
2
- const d = (s, r) => ({
3
- mediaBulkUpload: async (t, e = {}) => r.instance.url("/v1/assets/media/bulk").options(e).post(t).json().then((o) => o).catch((o) => {
4
- throw a(o);
5
- }),
6
- getAllMedia: async (t = {}) => r.instance.url("/v1/assets/media/query").post(t).json().then((e) => e).catch((e) => {
7
- throw a(e);
8
- })
9
- });
10
- export {
11
- d as createLevoMediaModule
12
- };
@@ -1,50 +0,0 @@
1
- import { LevoOAuthProviderList as g } from "../constants/oauthProvider.js";
2
- import { getLevoError as o } from "../utils/getLevoError.js";
3
- const k = (a, r) => {
4
- const p = async (e = {}) => r.instance.url("/v1/membership/auth/oauth/get-redirect-url").options(e).get().json().then((n) => {
5
- const t = n?.content?.data, w = Object.keys(t);
6
- if (typeof window < "u")
7
- for (const i of w) {
8
- const u = t[i];
9
- if (u) {
10
- const h = new URL(u), s = h.searchParams;
11
- s.set("redirect_uri", window.location.href), a.workspace && s.set("workspace_id", a.workspace), r.pageContext && s.set("page_context", JSON.stringify(r.pageContext)), t[i] = h.toString();
12
- }
13
- }
14
- return t;
15
- }).catch(() => g.reduce((n, t) => (n[t] = null, n), {})), d = async (e = {}) => r.instance.url("/v1/membership/auth/sign-out").options(e).post("").json().then((n) => n?.content?.data).catch((n) => {
16
- throw o(n);
17
- }), c = async (e = {}) => r.instance.url("/v1/membership/auth/get-me").options(e).get().json().then((n) => n?.content?.data).catch((n) => {
18
- throw o(n);
19
- });
20
- return {
21
- getOAuthURL: p,
22
- signOut: d,
23
- getMe: c,
24
- updateMe: async (e, n = {}) => r.instance.url("/v1/membership/auth/update-me").options(n).put(e).json().then((t) => t?.content?.data).catch((t) => {
25
- throw o(t);
26
- }),
27
- createPassword: async (e, n = {}) => r.instance.url("/v1/membership/auth/change-password").options(n).put(e).json().then((t) => t?.content?.data).catch((t) => {
28
- throw o(t);
29
- }),
30
- isLoggedIn: async (e = {}) => c(e).then((n) => n).catch(() => null),
31
- requestMagicLink: async (e, n = {}) => (typeof window < "u" && !e.redirect_uri && (e.redirect_uri = window.location.href), r.instance.url("/v1/membership/auth/request-magic-link").options(n).post(e).json().then((t) => t?.content?.data).catch((t) => {
32
- throw o(t);
33
- })),
34
- requestOtp: async (e, n = {}) => r.instance.url("/v1/membership/auth/request-otp").options(n).post(e).json().then((t) => t?.content?.data).catch((t) => {
35
- throw o(t);
36
- }),
37
- signInWithOtp: async (e, n = {}) => r.instance.url("/v1/membership/auth/signin-with-otp").options(n).post(e).json().then((t) => t?.content?.data).catch((t) => {
38
- throw o(t);
39
- }),
40
- signInWithPassword: async (e, n = {}) => r.instance.url("/v1/membership/auth/signin-with-password").options(n).post(e).json().then((t) => t?.content?.data).catch((t) => {
41
- throw o(t);
42
- }),
43
- signUpWithPassword: async (e, n = {}) => r.instance.url("/v1/membership/auth/signup-with-password").options(n).post(e).json().then((t) => t?.content?.data).catch((t) => {
44
- throw o(t);
45
- })
46
- };
47
- };
48
- export {
49
- k as createLevoMembershipModule
50
- };
@@ -1,40 +0,0 @@
1
- import { listToRecord as e } from "../utils/listToX.js";
2
- const i = [
3
- // Bevy Events
4
- "bevy.collection.filled",
5
- "bevy.collection.submitted",
6
- "bevy.collection.view",
7
- // Block Events
8
- "block.view",
9
- // Blog Events
10
- "blog.post.view",
11
- // Event Events
12
- "event.booking.confirmed",
13
- "event.booking.initiated",
14
- "event.booking.pending",
15
- "event.coupon.applied",
16
- "event.event.view",
17
- // Form Events
18
- "form.change",
19
- "form.submit",
20
- // Membership Events
21
- "membership.account.signin",
22
- "membership.account.signout",
23
- "membership.account.signup",
24
- // UI Events
25
- "button.click",
26
- "page.bounce",
27
- "page.click",
28
- "page.copy",
29
- "page.impression",
30
- "page.scroll",
31
- "page.view",
32
- "page.selection",
33
- // User Activity Events
34
- "user.active",
35
- "user.idle"
36
- ], n = e(i);
37
- export {
38
- n as AnalyticsEvents,
39
- i as AnalyticsEventsList
40
- };