@levo-so/core 0.1.49 → 0.1.52

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 (69) hide show
  1. package/dist/client.d.ts +26 -26
  2. package/dist/constants/index.d.ts +1 -0
  3. package/dist/constants/integration.d.ts +25 -0
  4. package/dist/index.js +179 -96
  5. package/dist/modules/blog.d.ts +2 -2
  6. package/dist/modules/collection.d.ts +6 -6
  7. package/dist/modules/membership.d.ts +4 -4
  8. package/dist/types/blog/index.d.ts +0 -7
  9. package/dist/types/collection/lemaCollection.d.ts +38 -5
  10. package/dist/types/collection/lemaField.d.ts +27 -3
  11. package/dist/types/collection/lemaSection.d.ts +4 -0
  12. package/dist/types/emoji.d.ts +2 -1
  13. package/dist/types/event.d.ts +211 -0
  14. package/dist/types/index.d.ts +3 -0
  15. package/dist/types/location.d.ts +6 -0
  16. package/dist/types/membership/index.d.ts +2 -17
  17. package/dist/types/query.d.ts +15 -11
  18. package/dist/types/schema/field.d.ts +29 -1
  19. package/dist/types/schema/schema.d.ts +29 -0
  20. package/dist/types/workspace.d.ts +138 -0
  21. package/dist/utils/LevoError.d.ts +16 -18
  22. package/dist/utils/getLevoError.d.ts +0 -1
  23. package/package.json +12 -39
  24. package/dist/constants/collection/defaultByKind.d.ts.map +0 -1
  25. package/dist/constants/collection/fieldInterfaceFormat.d.ts.map +0 -1
  26. package/dist/constants/collection/fieldInterfaces.d.ts.map +0 -1
  27. package/dist/constants/collection/fieldKind.d.ts.map +0 -1
  28. package/dist/constants/index.d.ts.map +0 -1
  29. package/dist/constants/media.d.ts.map +0 -1
  30. package/dist/constants/oauthProvider.d.ts.map +0 -1
  31. package/dist/control/audience.d.ts.map +0 -1
  32. package/dist/control/index.d.ts.map +0 -1
  33. package/dist/logger/batch.d.ts.map +0 -1
  34. package/dist/logger/index.d.ts.map +0 -1
  35. package/dist/modules/blog.d.ts.map +0 -1
  36. package/dist/modules/collection.d.ts.map +0 -1
  37. package/dist/modules/media.d.ts.map +0 -1
  38. package/dist/modules/membership.d.ts.map +0 -1
  39. package/dist/types/audience.d.ts.map +0 -1
  40. package/dist/types/blog/author.d.ts.map +0 -1
  41. package/dist/types/blog/blogClient.d.ts.map +0 -1
  42. package/dist/types/blog/category.d.ts.map +0 -1
  43. package/dist/types/blog/index.d.ts.map +0 -1
  44. package/dist/types/blog/post.d.ts.map +0 -1
  45. package/dist/types/blog/tag.d.ts.map +0 -1
  46. package/dist/types/collection/collectionView.d.ts.map +0 -1
  47. package/dist/types/collection/draft.d.ts.map +0 -1
  48. package/dist/types/collection/index.d.ts.map +0 -1
  49. package/dist/types/collection/lemaCollection.d.ts.map +0 -1
  50. package/dist/types/collection/lemaField.d.ts.map +0 -1
  51. package/dist/types/collection/lemaSection.d.ts.map +0 -1
  52. package/dist/types/collection/relation.d.ts.map +0 -1
  53. package/dist/types/emoji.d.ts.map +0 -1
  54. package/dist/types/index.d.ts.map +0 -1
  55. package/dist/types/levo-query.d.ts.map +0 -1
  56. package/dist/types/media.d.ts.map +0 -1
  57. package/dist/types/membership/index.d.ts.map +0 -1
  58. package/dist/types/query.d.ts.map +0 -1
  59. package/dist/types/schema/field.d.ts.map +0 -1
  60. package/dist/types/schema/index.d.ts.map +0 -1
  61. package/dist/types/schema/schema.d.ts.map +0 -1
  62. package/dist/types/utils.d.ts.map +0 -1
  63. package/dist/utils/LevoError.d.ts.map +0 -1
  64. package/dist/utils/formatImagePath.d.ts.map +0 -1
  65. package/dist/utils/getLevoError.d.ts.map +0 -1
  66. package/dist/utils/getUserProperties.d.ts.map +0 -1
  67. package/dist/utils/isIncognito.d.ts.map +0 -1
  68. package/dist/utils/listToX.d.ts.map +0 -1
  69. package/dist/utils/lock.d.ts.map +0 -1
package/dist/client.d.ts CHANGED
@@ -18,52 +18,52 @@ export declare const createLevoClient: (options: ILevoClientOptions) => {
18
18
  current_tab: string;
19
19
  all_tabs: string;
20
20
  };
21
- initiate: (properties: import("./types").ILevoAudience.Properties) => Promise<any>;
21
+ initiate: (properties: import(".").ILevoAudience.Properties) => Promise<any>;
22
22
  identify: (options?: {
23
23
  withLock?: boolean;
24
24
  }) => Promise<void>;
25
- track: <T extends import("./types").ILevoAudience.Properties>(event: import("./types").AnalyticsEventType, properties: T & import("./types").ILevoAudience.Properties) => Promise<any>;
26
- bounce: (properties: import("./types").ILevoAudience.Properties) => Promise<void>;
25
+ track: <T extends import(".").ILevoAudience.Properties>(event: import(".").AnalyticsEventType, properties: T & import(".").ILevoAudience.Properties) => Promise<any>;
26
+ bounce: (properties: import(".").ILevoAudience.Properties) => Promise<void>;
27
27
  };
28
28
  readonly blog: {
29
- getAllBlogs: (blog_key: string, data?: import("./types").LevoQuery.FindQuery, options?: import("./types").BlogClient.OptionParams) => Promise<import("./types").IResponseMultiple<import("./types").IPost>>;
30
- getSingleBlog: (blog_key: string, slug: string, options?: import("./types").BlogClient.OptionParams) => Promise<import("./types").IResponseSingle<import("./types").IPost, any>>;
29
+ getAllBlogs: (blog_key: string, data?: import(".").LevoQuery.FindQuery, options?: import(".").BlogClient.OptionParams) => Promise<import(".").IResponseMultiple<import(".").BlogClient.BlogData>>;
30
+ getSingleBlog: (blog_key: string, slug: string, options?: import(".").BlogClient.OptionParams) => Promise<import(".").IResponseSingle<import(".").BlogClient.BlogData>>;
31
31
  };
32
32
  readonly membership: {
33
- getOAuthURL: (options?: import("wretch").WretchOptions) => Promise<import("./types").ILevoMembership.OAuthURLList>;
33
+ getOAuthURL: (options?: import("wretch").WretchOptions) => Promise<import(".").ILevoMembership.OAuthURLList>;
34
34
  signOut: <T = {
35
35
  status: boolean;
36
36
  }>(options?: import("wretch").WretchOptions) => Promise<T>;
37
- getMe: <T = import("./types").ILevoMembership.Account>(options?: import("wretch").WretchOptions) => Promise<T>;
38
- updateMe: <T = import("./types").ILevoMembership.Account, D = Partial<Pick<import("./types").ILevoMembership.Account, "first_name" | "last_name" | "username" | "profile_picture">>>(data: D, options?: import("wretch").WretchOptions) => Promise<T>;
39
- createPassword: <T = import("./types").ILevoMembership.Account>(data: import("./types").ILevoMembership.Request.CreatePassword, options?: import("wretch").WretchOptions) => Promise<T>;
40
- isLoggedIn: <T = import("./types").ILevoMembership.Account>(options?: import("wretch").WretchOptions) => Promise<T | null>;
41
- requestMagicLink: (data: import("./types").ILevoMembership.Request.RequestMagicLink, options?: import("wretch").WretchOptions) => Promise<Pick<import("./types").ILevoMembership.Otp, "_id" | "content">>;
42
- requestOtp: (data: import("./types").ILevoMembership.Request.RequestOtp, options?: import("wretch").WretchOptions) => Promise<Pick<import("./types").ILevoMembership.Otp, "_id" | "content">>;
43
- signInWithOtp: <T = import("./types").ILevoMembership.Account>(data: import("./types").ILevoMembership.Request.SignInWithOtp, options?: import("wretch").WretchOptions) => Promise<T | null>;
44
- signInWithPassword: <T = import("./types").ILevoMembership.Account>(data: import("./types").ILevoMembership.Request.SignInWithPassword, options?: import("wretch").WretchOptions) => Promise<T | null>;
45
- signUpWithPassword: <T = import("./types").ILevoMembership.Account>(data: import("./types").ILevoMembership.Request.SignUpWithPassword, options?: import("wretch").WretchOptions) => Promise<T | null>;
37
+ getMe: <T = import(".").ILevoMembership.Account>(options?: import("wretch").WretchOptions) => Promise<T>;
38
+ updateMe: <T = import(".").ILevoMembership.Account>(data: import(".").ILevoMembership.Request.UpdateMe, options?: import("wretch").WretchOptions) => Promise<T>;
39
+ createPassword: <T = import(".").ILevoMembership.Account>(data: import(".").ILevoMembership.Request.CreatePassword, options?: import("wretch").WretchOptions) => Promise<T>;
40
+ isLoggedIn: <T = import(".").ILevoMembership.Account>(options?: import("wretch").WretchOptions) => Promise<T | null>;
41
+ requestMagicLink: (data: import(".").ILevoMembership.Request.RequestMagicLink, options?: import("wretch").WretchOptions) => Promise<Pick<import(".").ILevoMembership.Otp, "_id" | "content">>;
42
+ requestOtp: (data: import(".").ILevoMembership.Request.RequestOtp, options?: import("wretch").WretchOptions) => Promise<Pick<import(".").ILevoMembership.Otp, "_id" | "content">>;
43
+ signInWithOtp: <T = import(".").ILevoMembership.Account>(data: import(".").ILevoMembership.Request.SignInWithOtp, options?: import("wretch").WretchOptions) => Promise<T>;
44
+ signInWithPassword: <T = import(".").ILevoMembership.Account>(data: import(".").ILevoMembership.Request.SignInWithPassword, options?: import("wretch").WretchOptions) => Promise<T>;
45
+ signUpWithPassword: <T = import(".").ILevoMembership.Account>(data: import(".").ILevoMembership.Request.SignUpWithPassword, options?: import("wretch").WretchOptions) => Promise<T>;
46
46
  };
47
47
  readonly collection: {
48
- getAllCollections: (data?: import("./types").LevoQuery.FindQuery<"description" | "id" | "workspace_id" | "created_at" | "updated_at" | "key" | "readonly" | "hidden" | "icon" | "name" | "sections" | "views" | "title_field" | "settings" | "module_name" | "on_submit" | "on_update" | "allow_draft">, options?: import("wretch").WretchOptions) => Promise<import("./types").IResponseMultiple<import("./types").ILemaCollection>>;
49
- getCollectionByIDExpanded: <T = import("./types").ILemaCollection>(id: string, options?: import("wretch").WretchOptions) => Promise<import("./types").IResponseSingle<T, any>>;
50
- createCollection: (data: import("./types").ILemaCollection) => Promise<import("./types").IResponseSingle<import("./types").ILemaCollection, any>>;
48
+ getAllCollections: (data?: import(".").LevoQuery.FindQuery<"id" | "workspace_id" | "description" | "created_at" | "updated_at" | "key" | "readonly" | "hidden" | "icon" | "name" | "sections" | "views" | "title_field" | "email_field" | "settings" | "module_name" | "on_submit" | "on_update" | "allow_draft">, options?: import("wretch").WretchOptions) => Promise<import(".").IResponseMultiple<import(".").ILemaCollection>>;
49
+ getCollectionByIDExpanded: <T = import(".").ILemaCollection>(id: string, options?: import("wretch").WretchOptions) => Promise<import(".").IResponseSingle<T>>;
50
+ createCollection: (data: import(".").ILemaCollection) => Promise<import(".").IResponseSingle<import(".").ILemaCollection>>;
51
51
  saveCollectionData: ({ collection_id, data, options, }: {
52
52
  collection_id: string;
53
53
  data: any;
54
54
  options?: import("wretch").WretchOptions;
55
- }) => Promise<import("./types").IResponseSingle<any, any>>;
55
+ }) => Promise<import(".").IResponseSingle<any>>;
56
56
  getCollectionContentList: ({ collection_key, page, search, limit, where, }: {
57
57
  collection_key: string;
58
- } & import("./types").LevoQuery.FindQuery) => Promise<import("./types").IResponseMultiple<Record<string, unknown>>>;
59
- saveDraftEntry: (collection_key: string, data: any) => Promise<import("./types").IResponseSingle<import("./types").IDraftEntry, any>>;
60
- editDraftEntry: (collection_key: string, id: string, data: any) => Promise<import("./types").IResponseSingle<import("./types").IDraftEntry, any>>;
61
- getDraftEntry: (collection_key: string) => Promise<import("./types").IResponseMultiple<import("./types").IDraftEntry>>;
62
- submitDraftEntry: (collection_key: string, data: any) => Promise<import("./types").IResponseSingle<import("./types").IDraftEntry, any>>;
58
+ } & import(".").LevoQuery.FindQuery) => Promise<import(".").IResponseMultiple<Record<string, unknown>>>;
59
+ saveDraftEntry: (collection_key: string, data: any) => Promise<import(".").IResponseSingle<import(".").IDraftEntry>>;
60
+ editDraftEntry: (collection_key: string, id: string, data: any) => Promise<import(".").IResponseSingle<import(".").IDraftEntry>>;
61
+ getDraftEntry: (collection_key: string) => Promise<import(".").IResponseMultiple<import(".").IDraftEntry>>;
62
+ submitDraftEntry: (collection_key: string, data: any) => Promise<import(".").IResponseSingle<import(".").IDraftEntry>>;
63
63
  };
64
64
  readonly media: {
65
- mediaBulkUpload: (formData: FormData, options?: import("wretch").WretchOptions) => Promise<import("./types").IResponseMultiple<import("./types").IMedia>>;
66
- getAllMedia: (data?: import("./types").LevoQuery.FindQuery) => Promise<import("./types").IResponseMultiple<import("./types").IMedia>>;
65
+ mediaBulkUpload: (formData: FormData, options?: import("wretch").WretchOptions) => Promise<import(".").IResponseMultiple<import(".").IMedia>>;
66
+ getAllMedia: (data?: import(".").LevoQuery.FindQuery) => Promise<import(".").IResponseMultiple<import(".").IMedia>>;
67
67
  };
68
68
  readonly logger: {
69
69
  debug: (...args: any[]) => void;
@@ -4,4 +4,5 @@ export * from "./collection/fieldKind";
4
4
  export * from "./collection/fieldInterfaces";
5
5
  export * from "./media";
6
6
  export * from "./oauthProvider";
7
+ export * from "./integration";
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,25 @@
1
+ export declare const LEVO_INTEGRATIONS: {
2
+ readonly beacon: "so.levo.beacon";
3
+ readonly blog: "so.levo.blog";
4
+ readonly collection: "so.levo.collection";
5
+ readonly event: "so.levo.event";
6
+ readonly membership: "so.levo.membership";
7
+ readonly payment: "so.levo.payment";
8
+ readonly studio: "so.levo.studio";
9
+ readonly search_console: "com.google.search_console";
10
+ };
11
+ export declare const LEVO_INTEGRATIONS_LIST: ("so.levo.beacon" | "so.levo.blog" | "so.levo.collection" | "so.levo.event" | "so.levo.membership" | "so.levo.payment" | "so.levo.studio" | "com.google.search_console")[];
12
+ export type ILevoIntegrationList = (typeof LEVO_INTEGRATIONS)[keyof typeof LEVO_INTEGRATIONS][];
13
+ export type ILevoIntegrationInstance = {
14
+ id: string;
15
+ name: string;
16
+ publisher: string;
17
+ description: string;
18
+ url: string | null;
19
+ logo: string | null;
20
+ dashboard_url: string | null;
21
+ sidebar_icon: string | null;
22
+ show_on_sidebar: boolean;
23
+ key: string;
24
+ };
25
+ //# sourceMappingURL=integration.d.ts.map
package/dist/index.js CHANGED
@@ -272,62 +272,89 @@ var getUserProperties = async () => {
272
272
  var LevoError = class extends Error {
273
273
  code;
274
274
  title;
275
- message;
276
275
  status;
276
+ type;
277
277
  errors;
278
278
  constructor(data) {
279
- super(data?.message || data?.description);
279
+ super(data.description);
280
280
  this.name = "Levo Request Error";
281
- this.status = data?.status;
282
- this.code = data?.code;
283
- this.message = data?.message || data?.description;
284
- this.title = data?.title;
285
- this.errors = data?.errors || [];
281
+ this.status = data.status;
282
+ this.code = data.code;
283
+ this.title = data.title;
284
+ this.type = data.type;
285
+ this.errors = data.errors;
286
+ }
287
+ /**
288
+ * Get validation errors for form fields
289
+ */
290
+ get fieldErrors() {
291
+ return this.errors || [];
292
+ }
293
+ /**
294
+ * Check if this is a validation error with field-specific errors
295
+ */
296
+ get hasFieldErrors() {
297
+ return Boolean(this.errors?.length);
286
298
  }
287
299
  };
288
300
 
289
301
  // src/utils/getLevoError.ts
290
302
  var getLevoError = (error) => {
291
- if (error instanceof WretchError) {
303
+ if (error instanceof LevoError) {
304
+ return error;
305
+ }
306
+ if (error instanceof WretchError && error?.json) {
292
307
  const errorResponse = error?.json;
293
- if (typeof errorResponse === "object" && errorResponse?.content) {
294
- const errorMessage = errorResponse?.content;
295
- return new LevoError(errorMessage);
308
+ return new LevoError({
309
+ status: errorResponse?.content?.status || 500,
310
+ code: errorResponse?.content?.code || `Unknown`,
311
+ title: errorResponse?.content?.title || `HTTP ${error?.status || 500} Error`,
312
+ description: errorResponse?.content?.description || `Request failed with status ${error?.status || 500}`,
313
+ type: errorResponse?.content?.type,
314
+ errors: errorResponse?.content?.errors
315
+ });
316
+ }
317
+ if (error instanceof TypeError) {
318
+ if (error?.message.includes("Failed to fetch") || error?.message.includes("Network request failed") || error?.message.includes("fetch")) {
319
+ return new LevoError({
320
+ status: 0,
321
+ code: "NETWORK_ERROR",
322
+ title: "Network Error",
323
+ description: "Unable to connect to the server. Please check your internet connection."
324
+ });
325
+ }
326
+ if (error?.message.includes("CORS") || error?.message.includes("cross-origin")) {
327
+ return new LevoError({
328
+ status: 0,
329
+ code: "CORS_ERROR",
330
+ title: "CORS Error",
331
+ description: "Cross-origin request blocked. Please contact support."
332
+ });
296
333
  }
297
334
  }
298
- let displayMessage = error?.message || "Something unexpected happened.";
299
- switch (error?.message) {
300
- case "Network Error":
301
- displayMessage = "Couldn't connect to our servers.";
302
- break;
335
+ if (error?.name === "AbortError" || error instanceof DOMException) {
336
+ return new LevoError({
337
+ status: 408,
338
+ code: "REQUEST_TIMEOUT",
339
+ title: "Request Timeout",
340
+ description: "The request was cancelled or timed out. Please try again."
341
+ });
342
+ }
343
+ if (error?.request) {
344
+ return new LevoError({
345
+ status: error?.response?.status || 500,
346
+ code: error?.code || "REQUEST_ERROR",
347
+ title: "Request Error",
348
+ description: error?.message || "An error occurred while making the request"
349
+ });
303
350
  }
304
351
  return new LevoError({
305
- status: "500",
306
- title: "Network Error",
307
- description: displayMessage,
308
- code: "UNKNOWN_ERROR"
352
+ status: 500,
353
+ code: "UNKNOWN_ERROR",
354
+ title: "Unexpected Error",
355
+ description: error?.message || "Something unexpected happened"
309
356
  });
310
357
  };
311
- var getParsedError = (error) => {
312
- if (error instanceof WretchError) {
313
- const errorResponse = error?.json;
314
- if (typeof errorResponse === "object" && errorResponse?.content) {
315
- return errorResponse?.content;
316
- }
317
- }
318
- let displayMessage = error?.message || "Something unexpected happened.";
319
- switch (error?.message) {
320
- case "Network Error":
321
- displayMessage = "Couldn't connect to our servers.";
322
- break;
323
- }
324
- return {
325
- status: "500",
326
- title: "Network Error",
327
- description: displayMessage,
328
- code: "UNKNOWN_ERROR"
329
- };
330
- };
331
358
 
332
359
  // src/utils/lock.ts
333
360
  var LocalStorageLock = class {
@@ -447,14 +474,20 @@ var createLevoAudienceModule = (core, httpClient) => {
447
474
  withLock
448
475
  });
449
476
  };
450
- const request = (url, data) => {
477
+ const request = async (url, data) => {
451
478
  const headers = {
452
479
  Accept: "application/json",
453
480
  "Content-Type": "application/json"
454
481
  };
455
- return httpClient.instance.url(core?.insightsUrl, true).url(url).options({
456
- keepAlive: true
457
- }).headers(headers).post(data).json();
482
+ try {
483
+ const response = await httpClient.instance.url(core?.insightsUrl, true).url(url).options({
484
+ keepAlive: true
485
+ }).headers(headers).post(data).json();
486
+ return response;
487
+ } catch (error) {
488
+ console.warn(`Analytics request failed for ${url}:`, error);
489
+ return null;
490
+ }
458
491
  };
459
492
  const initiate = async (properties) => {
460
493
  if (core.NODE_ENV === "development") {
@@ -496,12 +529,11 @@ var createLevoAudienceModule = (core, httpClient) => {
496
529
  tab_count: getTabCount()
497
530
  };
498
531
  let isQueued = false;
499
- try {
532
+ if (navigator.sendBeacon) {
500
533
  isQueued = navigator.sendBeacon(
501
534
  `${core?.insightsUrl}/v1/insights/event/collect`,
502
535
  JSON.stringify(collectInput)
503
536
  );
504
- } catch (e) {
505
537
  }
506
538
  if (!isQueued) {
507
539
  request("/v1/insights/event/collect", collectInput);
@@ -548,15 +580,18 @@ var createLevoAudienceModule = (core, httpClient) => {
548
580
  if (!identifyLock || identifyLock.acquireLock()) {
549
581
  request(`/v1/insights/event/welcome`, welcomeInput).then((data) => {
550
582
  is_identified = true;
551
- _session = data.content.data.session;
552
- _device = data.content.data.device;
583
+ if (data?.content?.data?.session) {
584
+ _session = data?.content.data.session;
585
+ }
586
+ if (data?.content?.data?.device) {
587
+ _device = data?.content.data.device;
588
+ }
553
589
  let isQueued = false;
554
- try {
590
+ if (navigator.sendBeacon) {
555
591
  isQueued = navigator.sendBeacon(
556
592
  `${core?.insightsUrl}/v1/insights/event/bulk?workspace=${core?.workspace}`,
557
593
  JSON.stringify(_batch)
558
594
  );
559
- } catch (e) {
560
595
  }
561
596
  if (!isQueued) {
562
597
  request("/v1/insights/event/bulk", _batch);
@@ -785,7 +820,7 @@ var createLogBatch = (options = {}) => {
785
820
  try {
786
821
  await sendLogs(tasks);
787
822
  } catch (e) {
788
- console.log("error sending logs", e);
823
+ console.error("error sending logs", e);
789
824
  } finally {
790
825
  lastFlush = /* @__PURE__ */ new Date();
791
826
  }
@@ -927,19 +962,23 @@ var createLevoLogger = (core, options = {}) => {
927
962
 
928
963
  // src/modules/blog.ts
929
964
  var createLevoBlogModule = (core, httpClient, audience = null) => {
930
- const getAllBlogs = (blog_key, data = {}, options) => {
965
+ const getAllBlogs = async (blog_key, data = {}, options) => {
931
966
  return httpClient.instance.url(`/v1/blog/${blog_key}/post/query`).query({ ...options?.params || {} }).options({
932
967
  headers: {
933
968
  "Levo-Workspace": options?.workspace_id || void 0
934
969
  }
935
- }).post(data).json();
970
+ }).post(data).json().then((response) => response).catch((error) => {
971
+ throw getLevoError(error);
972
+ });
936
973
  };
937
- const getSingleBlog = (blog_key, slug, options) => {
974
+ const getSingleBlog = async (blog_key, slug, options) => {
938
975
  return httpClient.instance.url(`/v1/blog/${blog_key}/post/${slug}`).query({ ...options?.params || {} }).options({
939
976
  headers: {
940
977
  "Levo-Workspace": options?.workspace_id || void 0
941
978
  }
942
- }).get().json();
979
+ }).get().json().then((response) => response).catch((error) => {
980
+ throw getLevoError(error);
981
+ });
943
982
  };
944
983
  return {
945
984
  getAllBlogs,
@@ -950,20 +989,28 @@ var createLevoBlogModule = (core, httpClient, audience = null) => {
950
989
  // src/modules/collection.ts
951
990
  var createLevoCollectionModule = (core, httpsClient, audience = null) => {
952
991
  const getAllCollections = async (data = {}, options = {}) => {
953
- return httpsClient.instance.url("/v1/bevy/collection/query").options(options).post(data).json();
992
+ return httpsClient.instance.url("/v1/bevy/collection/query").options(options).post(data).json().then((response) => response).catch((error) => {
993
+ throw getLevoError(error);
994
+ });
954
995
  };
955
996
  const getCollectionByIDExpanded = async (id, options = {}) => {
956
- return httpsClient.instance.url(`/v1/bevy/collection/${id}`).options(options).get().json();
997
+ return httpsClient.instance.url(`/v1/bevy/collection/${id}`).options(options).get().json().then((response) => response).catch((error) => {
998
+ throw getLevoError(error);
999
+ });
957
1000
  };
958
1001
  const createCollection = async (data) => {
959
- return httpsClient.instance.url("/v1/bevy/collection").post(data).json();
1002
+ return httpsClient.instance.url("/v1/bevy/collection").post(data).json().then((response) => response).catch((error) => {
1003
+ throw getLevoError(error);
1004
+ });
960
1005
  };
961
1006
  const saveCollectionData = async ({
962
1007
  collection_id,
963
1008
  data,
964
1009
  options = {}
965
1010
  }) => {
966
- return httpsClient.instance.url(`/v1/bevy/content/${collection_id}`).options(options).post(data).json();
1011
+ return httpsClient.instance.url(`/v1/bevy/content/${collection_id}`).options(options).post(data).json().then((response) => response).catch((error) => {
1012
+ throw getLevoError(error);
1013
+ });
967
1014
  };
968
1015
  const getCollectionContentList = async ({
969
1016
  collection_key,
@@ -977,19 +1024,29 @@ var createLevoCollectionModule = (core, httpsClient, audience = null) => {
977
1024
  limit,
978
1025
  search,
979
1026
  where
980
- }).json();
1027
+ }).json().then((response) => response).catch((error) => {
1028
+ throw getLevoError(error);
1029
+ });
981
1030
  };
982
1031
  const saveDraftEntry = async (collection_key, data) => {
983
- return httpsClient.instance.url(`/v1/bevy/content/${collection_key}/save-entry`).post(data).json();
1032
+ return httpsClient.instance.url(`/v1/bevy/content/${collection_key}/save-entry`).post(data).json().then((response) => response).catch((error) => {
1033
+ throw getLevoError(error);
1034
+ });
984
1035
  };
985
1036
  const editDraftEntry = async (collection_key, id, data) => {
986
- return httpsClient.instance.url(`/v1/bevy/content/${collection_key}/${id}/edit-entry`).put(data).json();
1037
+ return httpsClient.instance.url(`/v1/bevy/content/${collection_key}/${id}/edit-entry`).put(data).json().then((response) => response).catch((error) => {
1038
+ throw getLevoError(error);
1039
+ });
987
1040
  };
988
1041
  const getDraftEntry = async (collection_key) => {
989
- return httpsClient.instance.url(`/v1/bevy/content/${collection_key}/list-entry`).get().json();
1042
+ return httpsClient.instance.url(`/v1/bevy/content/${collection_key}/list-entry`).get().json().then((response) => response).catch((error) => {
1043
+ throw getLevoError(error);
1044
+ });
990
1045
  };
991
1046
  const submitDraftEntry = async (collection_key, data) => {
992
- return httpsClient.instance.url(`/v1/bevy/content/${collection_key}/submit-entry`).post(data).json();
1047
+ return httpsClient.instance.url(`/v1/bevy/content/${collection_key}/submit-entry`).post(data).json().then((response) => response).catch((error) => {
1048
+ throw getLevoError(error);
1049
+ });
993
1050
  };
994
1051
  return {
995
1052
  getAllCollections,
@@ -1006,11 +1063,15 @@ var createLevoCollectionModule = (core, httpsClient, audience = null) => {
1006
1063
 
1007
1064
  // src/modules/media.ts
1008
1065
  var createLevoMediaModule = (core, httpsClient, audience = null) => {
1009
- const mediaBulkUpload = (formData, options = {}) => {
1010
- return httpsClient.instance.url("/v1/assets/media/bulk").options(options).post(formData).json();
1066
+ const mediaBulkUpload = async (formData, options = {}) => {
1067
+ return httpsClient.instance.url("/v1/assets/media/bulk").options(options).post(formData).json().then((response) => response).catch((error) => {
1068
+ throw getLevoError(error);
1069
+ });
1011
1070
  };
1012
1071
  const getAllMedia = async (data = {}) => {
1013
- return await httpsClient.instance.url("/v1/assets/media/query").post(data).json();
1072
+ return httpsClient.instance.url("/v1/assets/media/query").post(data).json().then((response) => response).catch((error) => {
1073
+ throw getLevoError(error);
1074
+ });
1014
1075
  };
1015
1076
  return {
1016
1077
  mediaBulkUpload,
@@ -1028,8 +1089,7 @@ var LevoOAuthProviderList = [
1028
1089
  // src/modules/membership.ts
1029
1090
  var createLevoMembershipModule = (core, httpsClient, audience = null) => {
1030
1091
  const getOAuthURL = async (options = {}) => {
1031
- try {
1032
- const response = await httpsClient.instance.url("/v1/membership/auth/oauth/get-redirect-url").options(options).get().json();
1092
+ return httpsClient.instance.url("/v1/membership/auth/oauth/get-redirect-url").options(options).get().json().then((response) => {
1033
1093
  const result = response?.content?.data;
1034
1094
  const providers = Object.keys(result);
1035
1095
  if (typeof window !== "undefined") {
@@ -1053,58 +1113,63 @@ var createLevoMembershipModule = (core, httpsClient, audience = null) => {
1053
1113
  }
1054
1114
  }
1055
1115
  return result;
1056
- } catch {
1116
+ }).catch(() => {
1057
1117
  return LevoOAuthProviderList.reduce((acc, provider) => {
1058
1118
  acc[provider] = null;
1059
1119
  return acc;
1060
1120
  }, {});
1061
- }
1121
+ });
1062
1122
  };
1063
1123
  const signOut = async (options = {}) => {
1064
- return httpsClient.instance.url("/v1/membership/auth/sign-out").options(options).post("").json();
1124
+ return httpsClient.instance.url("/v1/membership/auth/sign-out").options(options).post("").json().then((response) => response?.content?.data).catch((error) => {
1125
+ throw getLevoError(error);
1126
+ });
1065
1127
  };
1066
1128
  const getMe = async (options = {}) => {
1067
- const response = await httpsClient.instance.url("/v1/membership/auth/get-me").options(options).get().json();
1068
- return response?.content?.data;
1129
+ return httpsClient.instance.url("/v1/membership/auth/get-me").options(options).get().json().then((response) => response?.content?.data).catch((error) => {
1130
+ throw getLevoError(error);
1131
+ });
1069
1132
  };
1070
1133
  const updateMe = async (data, options = {}) => {
1071
- const response = await httpsClient.instance.url("/v1/membership/auth/update-me").options(options).put(data).json();
1072
- return response?.content?.data;
1134
+ return httpsClient.instance.url("/v1/membership/auth/update-me").options(options).put(data).json().then((response) => response?.content?.data).catch((error) => {
1135
+ throw getLevoError(error);
1136
+ });
1073
1137
  };
1074
1138
  const createPassword = async (data, options = {}) => {
1075
- const response = await httpsClient.instance.url("/v1/membership/auth/change-password").options(options).put(data).json();
1076
- return response?.content?.data;
1139
+ return httpsClient.instance.url("/v1/membership/auth/change-password").options(options).put(data).json().then((response) => response?.content?.data).catch((error) => {
1140
+ throw getLevoError(error);
1141
+ });
1077
1142
  };
1078
1143
  const isLoggedIn = async (options = {}) => {
1079
- try {
1080
- const account = await getMe(options);
1081
- return account;
1082
- } catch (_) {
1083
- return null;
1084
- }
1144
+ return getMe(options).then((account) => account).catch(() => null);
1085
1145
  };
1086
1146
  const requestMagicLink = async (data, options = {}) => {
1087
1147
  if (typeof window !== "undefined" && !data.redirect_uri) {
1088
1148
  data.redirect_uri = window.location.href;
1089
1149
  }
1090
- const response = await httpsClient.instance.url("/v1/membership/auth/request-magic-link").options(options).post(data).json();
1091
- return response?.content?.data;
1150
+ return httpsClient.instance.url("/v1/membership/auth/request-magic-link").options(options).post(data).json().then((response) => response?.content?.data).catch((error) => {
1151
+ throw getLevoError(error);
1152
+ });
1092
1153
  };
1093
1154
  const requestOtp = async (data, options = {}) => {
1094
- const response = await httpsClient.instance.url("/v1/membership/auth/request-otp").options(options).post(data).json();
1095
- return response?.content?.data;
1155
+ return httpsClient.instance.url("/v1/membership/auth/request-otp").options(options).post(data).json().then((response) => response?.content?.data).catch((error) => {
1156
+ throw getLevoError(error);
1157
+ });
1096
1158
  };
1097
1159
  const signInWithOtp = async (data, options = {}) => {
1098
- const response = await httpsClient.instance.url("/v1/membership/auth/signin-with-otp").options(options).post(data).json();
1099
- return response?.content?.data;
1160
+ return httpsClient.instance.url("/v1/membership/auth/signin-with-otp").options(options).post(data).json().then((response) => response?.content?.data).catch((error) => {
1161
+ throw getLevoError(error);
1162
+ });
1100
1163
  };
1101
1164
  const signInWithPassword = async (data, options = {}) => {
1102
- const response = await httpsClient.instance.url("/v1/membership/auth/signin-with-password").options(options).post(data).json();
1103
- return response?.content?.data;
1165
+ return httpsClient.instance.url("/v1/membership/auth/signin-with-password").options(options).post(data).json().then((response) => response?.content?.data).catch((error) => {
1166
+ throw getLevoError(error);
1167
+ });
1104
1168
  };
1105
1169
  const signUpWithPassword = async (data, options = {}) => {
1106
- const response = await httpsClient.instance.url("/v1/membership/auth/signup-with-password").options(options).post(data).json();
1107
- return response?.content?.data;
1170
+ return httpsClient.instance.url("/v1/membership/auth/signup-with-password").options(options).post(data).json().then((response) => response?.content?.data).catch((error) => {
1171
+ throw getLevoError(error);
1172
+ });
1108
1173
  };
1109
1174
  return {
1110
1175
  getOAuthURL,
@@ -1284,7 +1349,12 @@ var defaultByKinds = {
1284
1349
  identifier: null,
1285
1350
  record: null,
1286
1351
  group: [],
1287
- collection: null,
1352
+ collection: {
1353
+ o2m: null,
1354
+ m2o: null,
1355
+ o2o: null,
1356
+ m2m: []
1357
+ },
1288
1358
  richtext: {
1289
1359
  html: "",
1290
1360
  text: "",
@@ -1444,6 +1514,19 @@ var MediaKind = MediaKindList.reduce(
1444
1514
  {}
1445
1515
  );
1446
1516
 
1517
+ // src/constants/integration.ts
1518
+ var LEVO_INTEGRATIONS = {
1519
+ beacon: "so.levo.beacon",
1520
+ blog: "so.levo.blog",
1521
+ collection: "so.levo.collection",
1522
+ event: "so.levo.event",
1523
+ membership: "so.levo.membership",
1524
+ payment: "so.levo.payment",
1525
+ studio: "so.levo.studio",
1526
+ search_console: "com.google.search_console"
1527
+ };
1528
+ var LEVO_INTEGRATIONS_LIST = Object.values(LEVO_INTEGRATIONS);
1529
+
1447
1530
  // src/utils/formatImagePath.ts
1448
1531
  var formatImagePath = (string) => {
1449
1532
  const parts = string.split("/");
@@ -1455,4 +1538,4 @@ var formatImagePath = (string) => {
1455
1538
  return "";
1456
1539
  };
1457
1540
 
1458
- export { AnalyticsEvents, AnalyticsEventsList, FieldInterfaces, FieldInterfacesList, FieldKind, FieldKindList, LevoError, LevoOAuthProviderList, LocalStorageLock, MediaKind, MediaKindList, createLevoClient, defaultByKinds, formatImagePath, formatsByInterface, getLevoError, getParsedError, interfaceKinds };
1541
+ export { AnalyticsEvents, AnalyticsEventsList, FieldInterfaces, FieldInterfacesList, FieldKind, FieldKindList, LEVO_INTEGRATIONS, LEVO_INTEGRATIONS_LIST, LevoError, LevoOAuthProviderList, LocalStorageLock, MediaKind, MediaKindList, createLevoClient, defaultByKinds, formatImagePath, formatsByInterface, getLevoError, interfaceKinds };
@@ -4,7 +4,7 @@ import { ILevoControl } from "../control";
4
4
  import { ILevoAudienceModule } from "../control/audience";
5
5
  import { IHttpClient } from "../httpClient";
6
6
  export declare const createLevoBlogModule: (core: ILevoControl, httpClient: IHttpClient, audience?: ILevoAudienceModule | null) => {
7
- getAllBlogs: (blog_key: string, data?: LevoQuery.FindQuery, options?: BlogClient.OptionParams) => Promise<IResponseMultiple<import("..").IPost>>;
8
- getSingleBlog: (blog_key: string, slug: string, options?: BlogClient.OptionParams) => Promise<IResponseSingle<import("..").IPost, any>>;
7
+ getAllBlogs: (blog_key: string, data?: LevoQuery.FindQuery, options?: BlogClient.OptionParams) => Promise<IResponseMultiple<BlogClient.BlogData>>;
8
+ getSingleBlog: (blog_key: string, slug: string, options?: BlogClient.OptionParams) => Promise<IResponseSingle<BlogClient.BlogData>>;
9
9
  };
10
10
  //# sourceMappingURL=blog.d.ts.map
@@ -7,20 +7,20 @@ import { IHttpClient } from "../httpClient";
7
7
  type ColumnKeys = Prettify<keyof ILemaCollection>;
8
8
  export declare const createLevoCollectionModule: (core: ILevoControl, httpsClient: IHttpClient, audience?: ILevoAudienceModule | null) => {
9
9
  getAllCollections: (data?: LevoQuery.FindQuery<ColumnKeys>, options?: WretchOptions) => Promise<IResponseMultiple<ILemaCollection>>;
10
- getCollectionByIDExpanded: <T = ILemaCollection>(id: string, options?: WretchOptions) => Promise<IResponseSingle<T, any>>;
11
- createCollection: (data: ILemaCollection) => Promise<IResponseSingle<ILemaCollection, any>>;
10
+ getCollectionByIDExpanded: <T = ILemaCollection>(id: string, options?: WretchOptions) => Promise<IResponseSingle<T>>;
11
+ createCollection: (data: ILemaCollection) => Promise<IResponseSingle<ILemaCollection>>;
12
12
  saveCollectionData: ({ collection_id, data, options, }: {
13
13
  collection_id: string;
14
14
  data: any;
15
15
  options?: WretchOptions;
16
- }) => Promise<IResponseSingle<any, any>>;
16
+ }) => Promise<IResponseSingle<any>>;
17
17
  getCollectionContentList: ({ collection_key, page, search, limit, where, }: {
18
18
  collection_key: string;
19
19
  } & LevoQuery.FindQuery) => Promise<IResponseMultiple<Record<string, unknown>>>;
20
- saveDraftEntry: (collection_key: string, data: any) => Promise<IResponseSingle<IDraftEntry, any>>;
21
- editDraftEntry: (collection_key: string, id: string, data: any) => Promise<IResponseSingle<IDraftEntry, any>>;
20
+ saveDraftEntry: (collection_key: string, data: any) => Promise<IResponseSingle<IDraftEntry>>;
21
+ editDraftEntry: (collection_key: string, id: string, data: any) => Promise<IResponseSingle<IDraftEntry>>;
22
22
  getDraftEntry: (collection_key: string) => Promise<IResponseMultiple<IDraftEntry>>;
23
- submitDraftEntry: (collection_key: string, data: any) => Promise<IResponseSingle<IDraftEntry, any>>;
23
+ submitDraftEntry: (collection_key: string, data: any) => Promise<IResponseSingle<IDraftEntry>>;
24
24
  };
25
25
  export {};
26
26
  //# sourceMappingURL=collection.d.ts.map
@@ -9,13 +9,13 @@ export declare const createLevoMembershipModule: (core: ILevoControl, httpsClien
9
9
  status: boolean;
10
10
  }>(options?: WretchOptions) => Promise<T>;
11
11
  getMe: <T = ILevoMembership.Account>(options?: WretchOptions) => Promise<T>;
12
- updateMe: <T = ILevoMembership.Account, D = Partial<Pick<ILevoMembership.Account, "first_name" | "last_name" | "username" | "profile_picture">>>(data: D, options?: WretchOptions) => Promise<T>;
12
+ updateMe: <T = ILevoMembership.Account>(data: ILevoMembership.Request.UpdateMe, options?: WretchOptions) => Promise<T>;
13
13
  createPassword: <T = ILevoMembership.Account>(data: ILevoMembership.Request.CreatePassword, options?: WretchOptions) => Promise<T>;
14
14
  isLoggedIn: <T = ILevoMembership.Account>(options?: WretchOptions) => Promise<T | null>;
15
15
  requestMagicLink: (data: ILevoMembership.Request.RequestMagicLink, options?: WretchOptions) => Promise<Pick<ILevoMembership.Otp, "_id" | "content">>;
16
16
  requestOtp: (data: ILevoMembership.Request.RequestOtp, options?: WretchOptions) => Promise<Pick<ILevoMembership.Otp, "_id" | "content">>;
17
- signInWithOtp: <T = ILevoMembership.Account>(data: ILevoMembership.Request.SignInWithOtp, options?: WretchOptions) => Promise<T | null>;
18
- signInWithPassword: <T = ILevoMembership.Account>(data: ILevoMembership.Request.SignInWithPassword, options?: WretchOptions) => Promise<T | null>;
19
- signUpWithPassword: <T = ILevoMembership.Account>(data: ILevoMembership.Request.SignUpWithPassword, options?: WretchOptions) => Promise<T | null>;
17
+ signInWithOtp: <T = ILevoMembership.Account>(data: ILevoMembership.Request.SignInWithOtp, options?: WretchOptions) => Promise<T>;
18
+ signInWithPassword: <T = ILevoMembership.Account>(data: ILevoMembership.Request.SignInWithPassword, options?: WretchOptions) => Promise<T>;
19
+ signUpWithPassword: <T = ILevoMembership.Account>(data: ILevoMembership.Request.SignUpWithPassword, options?: WretchOptions) => Promise<T>;
20
20
  };
21
21
  //# sourceMappingURL=membership.d.ts.map