@levo-so/core 0.1.35 → 0.1.37

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 (51) hide show
  1. package/dist/client.d.ts +81 -0
  2. package/dist/constants/media.d.ts +1 -1
  3. package/dist/control/audience.d.ts +22 -0
  4. package/dist/control/audience.d.ts.map +1 -0
  5. package/dist/control/index.d.ts +23 -0
  6. package/dist/control/index.d.ts.map +1 -0
  7. package/dist/httpClient.d.ts +13 -0
  8. package/dist/index.d.ts +1 -2
  9. package/dist/index.js +1196 -70
  10. package/dist/logger/batch.d.ts +3 -10
  11. package/dist/logger/batch.d.ts.map +1 -1
  12. package/dist/logger/index.d.ts +22 -0
  13. package/dist/logger/index.d.ts.map +1 -0
  14. package/dist/modules/blog.d.ts +10 -0
  15. package/dist/modules/blog.d.ts.map +1 -0
  16. package/dist/modules/collection.d.ts +25 -0
  17. package/dist/modules/collection.d.ts.map +1 -0
  18. package/dist/{plugins/LevoMedia.d.ts → modules/media.d.ts} +6 -4
  19. package/dist/modules/media.d.ts.map +1 -0
  20. package/dist/modules/membership.d.ts +21 -0
  21. package/dist/modules/membership.d.ts.map +1 -0
  22. package/dist/types/audience.d.ts +35 -2
  23. package/dist/types/audience.d.ts.map +1 -1
  24. package/dist/utils/listToX.d.ts +3 -0
  25. package/dist/utils/listToX.d.ts.map +1 -0
  26. package/dist/utils/lock.d.ts.map +1 -1
  27. package/package.json +5 -3
  28. package/dist/LevoClient.d.ts +0 -38
  29. package/dist/chunk-OT564SO4.js +0 -69
  30. package/dist/chunk-QJSKNLTV.js +0 -9
  31. package/dist/chunk-ZLLCLSGE.js +0 -8
  32. package/dist/plugins/LevoAudience.d.ts +0 -32
  33. package/dist/plugins/LevoAudience.d.ts.map +0 -1
  34. package/dist/plugins/LevoAudience.js +0 -561
  35. package/dist/plugins/LevoBlog.d.ts +0 -8
  36. package/dist/plugins/LevoBlog.d.ts.map +0 -1
  37. package/dist/plugins/LevoBlog.js +0 -21
  38. package/dist/plugins/LevoCollection.d.ts +0 -23
  39. package/dist/plugins/LevoCollection.d.ts.map +0 -1
  40. package/dist/plugins/LevoCollection.js +0 -47
  41. package/dist/plugins/LevoLogger.d.ts +0 -32
  42. package/dist/plugins/LevoLogger.d.ts.map +0 -1
  43. package/dist/plugins/LevoLogger.js +0 -193
  44. package/dist/plugins/LevoMedia.d.ts.map +0 -1
  45. package/dist/plugins/LevoMedia.js +0 -13
  46. package/dist/plugins/LevoMembership.d.ts +0 -38
  47. package/dist/plugins/LevoMembership.d.ts.map +0 -1
  48. package/dist/plugins/LevoMembership.js +0 -104
  49. package/dist/plugins/LevoPlugin.d.ts +0 -6
  50. package/dist/plugins/LevoPlugin.d.ts.map +0 -1
  51. package/dist/plugins/LevoPlugin.js +0 -1
@@ -1,16 +1,9 @@
1
- export interface BatchOptions {
1
+ export interface IBatchOptions {
2
2
  logApiUrl?: string;
3
3
  }
4
4
  export type CallbackFunction = (log: object) => Promise<void>;
5
- export declare class LogBatch {
6
- logApiUrl: string;
7
- logs: Array<object>;
8
- activeFlush: Promise<void>;
9
- nextFlush: NodeJS.Timeout;
10
- lastFlush: Date;
11
- constructor(options?: BatchOptions);
12
- sendLogs: (logs: Array<object>) => Promise<void | import("wretch").WretchResponse>;
5
+ export declare const createLogBatch: (options?: IBatchOptions) => {
13
6
  ingest: (log: object) => void;
14
7
  flush: () => Promise<void>;
15
- }
8
+ };
16
9
  //# sourceMappingURL=batch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/logger/batch.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE9D,qBAAa,QAAQ;IACnB,SAAS,SAAgC;IAEzC,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAM;IAEzB,WAAW,EAAE,OAAO,CAAC,IAAI,CAAC,CAAqB;IAC/C,SAAS,EAAE,MAAM,CAAC,OAAO,CAA2B;IACpD,SAAS,EAAE,IAAI,CAAc;gBAEjB,OAAO,GAAE,YAAiB;IAMtC,QAAQ,SAAgB,KAAK,CAAC,MAAM,CAAC,qDAqCnC;IAEF,MAAM,QAAS,MAAM,UAoBnB;IAEF,KAAK,QAAa,OAAO,CAAC,IAAI,CAAC,CAoB7B;CACH"}
1
+ {"version":3,"file":"batch.d.ts","sourceRoot":"","sources":["../../src/logger/batch.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,aAAa;IAC5B,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,MAAM,gBAAgB,GAAG,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE9D,eAAO,MAAM,cAAc,aAAa,aAAa;kBAiF9B,MAAM;iBAvBH,OAAO,CAAC,IAAI,CAAC;CA8CtC,CAAC"}
@@ -0,0 +1,22 @@
1
+ import { ILevoControl } from "../control";
2
+ import { IBatchOptions } from "./batch";
3
+ export declare const isBrowser: boolean;
4
+ export declare enum LogLevel {
5
+ debug = 0,
6
+ info = 1,
7
+ warn = 2,
8
+ error = 3,
9
+ off = 100
10
+ }
11
+ export interface ILoggerOptions extends IBatchOptions {
12
+ level?: LogLevel;
13
+ enableRemote?: boolean;
14
+ context?: Record<string, any>;
15
+ }
16
+ export declare const createLevoLogger: (core: ILevoControl, options?: ILoggerOptions) => {
17
+ debug: (...args: any[]) => void;
18
+ info: (...args: any[]) => void;
19
+ warn: (...args: any[]) => void;
20
+ error: (...args: any[]) => void;
21
+ };
22
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/logger/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,OAAO,EAAE,aAAa,EAAkB,MAAM,SAAS,CAAC;AAExD,eAAO,MAAM,SAAS,SAAgC,CAAC;AAEvD,oBAAY,QAAQ;IAClB,KAAK,IAAI;IACT,IAAI,IAAI;IACR,IAAI,IAAI;IACR,KAAK,IAAI;IACT,GAAG,MAAM;CACV;AAiBD,MAAM,WAAW,cAAe,SAAQ,aAAa;IACnD,KAAK,CAAC,EAAE,QAAQ,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC/B;AAED,eAAO,MAAM,gBAAgB,SACrB,YAAY,YACT,cAAc;qBAgHC,GAAG,EAAE;oBAIN,GAAG,EAAE;oBAIL,GAAG,EAAE;qBAIJ,GAAG,EAAE;CAU9B,CAAC"}
@@ -0,0 +1,10 @@
1
+ import type { BlogClient, IResponseMultiple, IResponseSingle } from "../types";
2
+ import type { LevoQuery } from "../types/levo-query";
3
+ import { ILevoControl } from "../control";
4
+ import { ILevoAudienceModule } from "../control/audience";
5
+ import { IHttpClient } from "../httpClient";
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("../types").IPost>>;
8
+ getSingleBlog: (blog_key: string, slug: string, options?: BlogClient.OptionParams) => Promise<IResponseSingle<import("../types").IPost, any>>;
9
+ };
10
+ //# sourceMappingURL=blog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"blog.d.ts","sourceRoot":"","sources":["../../src/modules/blog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,eAAO,MAAM,oBAAoB,SACzB,YAAY,cACN,WAAW,aACb,mBAAmB,GAAG,IAAI;4BAGxB,MAAM,SACV,SAAS,CAAC,SAAS,YACf,UAAU,CAAC,YAAY;8BAevB,MAAM,QACV,MAAM,YACF,UAAU,CAAC,YAAY;CAkBpC,CAAC"}
@@ -0,0 +1,25 @@
1
+ import type { WretchOptions } from "wretch";
2
+ import type { IDraftEntry, ILemaCollection, IResponseMultiple, IResponseSingle, Prettify } from "../types";
3
+ import type { LevoQuery } from "../types/levo-query";
4
+ import { ILevoControl } from "../control";
5
+ import { ILevoAudienceModule } from "../control/audience";
6
+ import { IHttpClient } from "../httpClient";
7
+ type ColumnKeys = Prettify<keyof ILemaCollection>;
8
+ export declare const createLevoCollectionModule: (core: ILevoControl, httpsClient: IHttpClient, audience?: ILevoAudienceModule | null) => {
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>>;
12
+ saveCollectionData: ({ collection_id, data, options, }: {
13
+ collection_id: string;
14
+ data: any;
15
+ options?: WretchOptions;
16
+ }) => Promise<IResponseSingle<any, any>>;
17
+ getCollectionContentList: ({ collection_key, page, search, limit, where, }: {
18
+ collection_key: string;
19
+ } & LevoQuery.FindQuery) => Promise<IResponseMultiple<Record<string, unknown>>>;
20
+ saveDraftEntry: (collection_key: string, data: any) => Promise<IResponseSingle<IDraftEntry, any>>;
21
+ getDraftEntry: (collection_key: string) => Promise<IResponseSingle<IDraftEntry, any>>;
22
+ submitDraftEntry: (collection_key: string, data: any) => Promise<IResponseSingle<IDraftEntry, any>>;
23
+ };
24
+ export {};
25
+ //# sourceMappingURL=collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/modules/collection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,eAAe,EACf,QAAQ,EACT,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,KAAK,UAAU,GAAG,QAAQ,CAAC,MAAM,eAAe,CAAC,CAAC;AAElD,eAAO,MAAM,0BAA0B,SAC/B,YAAY,eACL,WAAW,aACd,mBAAmB,GAAG,IAAI;+BAG5B,SAAS,CAAC,SAAS,CAAC,UAAU,CAAC,YAC5B,aAAa;gCASiB,CAAC,wBACpC,MAAM,YACD,aAAa;6BASc,eAAe;4DAWlD;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,EAAE,GAAG,CAAC;QACV,OAAO,CAAC,EAAE,aAAa,CAAC;KACzB;gFAcE;QACD,cAAc,EAAE,MAAM,CAAC;KACxB,GAAG,SAAS,CAAC,SAAS;qCAauB,MAAM,QAAQ,GAAG;oCAOlB,MAAM;uCAOH,MAAM,QAAQ,GAAG;CAiBlE,CAAC"}
@@ -1,9 +1,11 @@
1
1
  import type { WretchOptions } from "wretch";
2
2
  import type { IMedia, IResponseMultiple } from "../types";
3
3
  import type { LevoQuery } from "../types/levo-query";
4
- import { LevoPlugin } from "./LevoPlugin";
5
- export declare class LevoMedia extends LevoPlugin {
4
+ import { ILevoControl } from "../control";
5
+ import { ILevoAudienceModule } from "../control/audience";
6
+ import { IHttpClient } from "../httpClient";
7
+ export declare const createLevoMediaModule: (core: ILevoControl, httpsClient: IHttpClient, audience?: ILevoAudienceModule | null) => {
6
8
  mediaBulkUpload: (formData: FormData, options?: WretchOptions) => Promise<IResponseMultiple<IMedia>>;
7
9
  getAllMedia: (data?: LevoQuery.FindQuery) => Promise<IResponseMultiple<IMedia>>;
8
- }
9
- //# sourceMappingURL=LevoMedia.d.ts.map
10
+ };
11
+ //# sourceMappingURL=media.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"media.d.ts","sourceRoot":"","sources":["../../src/modules/media.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C,OAAO,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAC1D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,eAAO,MAAM,qBAAqB,SAC1B,YAAY,eACL,WAAW,aACd,mBAAmB,GAAG,IAAI;gCAED,QAAQ,YAAW,aAAa;yBAQlC,SAAS,CAAC,SAAS;CAWrD,CAAC"}
@@ -0,0 +1,21 @@
1
+ import type { WretchOptions } from "wretch";
2
+ import type { ILevoMembership } from "../types/membership";
3
+ import { ILevoControl } from "../control";
4
+ import { ILevoAudienceModule } from "../control/audience";
5
+ import { IHttpClient } from "../httpClient";
6
+ export declare const createLevoMembershipModule: (core: ILevoControl, httpsClient: IHttpClient, audience?: ILevoAudienceModule | null) => {
7
+ getOAuthURL: (options?: WretchOptions) => Promise<ILevoMembership.OAuthURLList>;
8
+ signOut: <T = {
9
+ status: boolean;
10
+ }>(options?: WretchOptions) => Promise<T>;
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>;
13
+ createPassword: <T = ILevoMembership.Account>(data: ILevoMembership.Request.CreatePassword, options?: WretchOptions) => Promise<T>;
14
+ isLoggedIn: <T = ILevoMembership.Account>(options?: WretchOptions) => Promise<T | null>;
15
+ requestMagicLink: (data: ILevoMembership.Request.RequestMagicLink, options?: WretchOptions) => Promise<Pick<ILevoMembership.Otp, "_id" | "content">>;
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>;
20
+ };
21
+ //# sourceMappingURL=membership.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"membership.d.ts","sourceRoot":"","sources":["../../src/modules/membership.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAM5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE3D,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE5C,eAAO,MAAM,0BAA0B,SAC/B,YAAY,eACL,WAAW,aACd,mBAAmB,GAAG,IAAI;4BAczB,aAAa,KACrB,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC;cAyDjB,CAAC;gBAAa,OAAO;iBACjC,aAAa,KACrB,OAAO,CAAC,CAAC,CAAC;YAYQ,CAAC,sCACX,aAAa,KACrB,OAAO,CAAC,CAAC,CAAC;eAWX,CAAC,4BACD,CAAC,8GAEK,CAAC,YACE,aAAa,KACrB,OAAO,CAAC,CAAC,CAAC;qBAUiB,CAAC,kCACvB,eAAe,CAAC,OAAO,CAAC,cAAc,YACnC,aAAa,KACrB,OAAO,CAAC,CAAC,CAAC;iBAUa,CAAC,sCAChB,aAAa,KACrB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;6BAUZ,eAAe,CAAC,OAAO,CAAC,gBAAgB,YACrC,aAAa,KACrB,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,KAAK,GAAG,SAAS,CAAC,CAAC;uBAkBhD,eAAe,CAAC,OAAO,CAAC,UAAU,YAC/B,aAAa,KACrB,OAAO,CAAC,IAAI,CAAC,eAAe,CAAC,GAAG,EAAE,KAAK,GAAG,SAAS,CAAC,CAAC;oBAU3B,CAAC,kCACtB,eAAe,CAAC,OAAO,CAAC,aAAa,YAClC,aAAa,KACrB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;yBAUc,CAAC,kCAC3B,eAAe,CAAC,OAAO,CAAC,kBAAkB,YACvC,aAAa,KACrB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;yBAUc,CAAC,kCAC3B,eAAe,CAAC,OAAO,CAAC,kBAAkB,YACvC,aAAa,KACrB,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CAuBrB,CAAC"}
@@ -1,3 +1,35 @@
1
+ export declare const AnalyticsEventsList: readonly ["bevy.collection.filled", "bevy.collection.submitted", "bevy.collection.view", "block.view", "blog.post.view", "event.booking.confirmed", "event.booking.initiated", "event.booking.pending", "event.coupon.applied", "event.event.view", "form.change", "form.submit", "membership.account.signin", "membership.account.signout", "membership.account.signup", "button.click", "page.bounce", "page.click", "page.copy", "page.impression", "page.scroll", "page.view", "page.metrics", "page.selection", "page.speedtest", "user.active", "user.speedtest", "user.idle"];
2
+ export type AnalyticsEventType = (typeof AnalyticsEventsList)[number];
3
+ export declare const AnalyticsEvents: {
4
+ "bevy.collection.filled": "bevy.collection.filled";
5
+ "bevy.collection.submitted": "bevy.collection.submitted";
6
+ "bevy.collection.view": "bevy.collection.view";
7
+ "block.view": "block.view";
8
+ "blog.post.view": "blog.post.view";
9
+ "event.booking.confirmed": "event.booking.confirmed";
10
+ "event.booking.initiated": "event.booking.initiated";
11
+ "event.booking.pending": "event.booking.pending";
12
+ "event.coupon.applied": "event.coupon.applied";
13
+ "event.event.view": "event.event.view";
14
+ "form.change": "form.change";
15
+ "form.submit": "form.submit";
16
+ "membership.account.signin": "membership.account.signin";
17
+ "membership.account.signout": "membership.account.signout";
18
+ "membership.account.signup": "membership.account.signup";
19
+ "button.click": "button.click";
20
+ "page.bounce": "page.bounce";
21
+ "page.click": "page.click";
22
+ "page.copy": "page.copy";
23
+ "page.impression": "page.impression";
24
+ "page.scroll": "page.scroll";
25
+ "page.view": "page.view";
26
+ "page.metrics": "page.metrics";
27
+ "page.selection": "page.selection";
28
+ "page.speedtest": "page.speedtest";
29
+ "user.active": "user.active";
30
+ "user.speedtest": "user.speedtest";
31
+ "user.idle": "user.idle";
32
+ };
1
33
  export declare namespace ILevoAudience {
2
34
  interface Traits {
3
35
  private_mode: boolean;
@@ -10,6 +42,7 @@ export declare namespace ILevoAudience {
10
42
  data: Record<string, string>;
11
43
  };
12
44
  properties: Record<string, any>;
45
+ withLock?: boolean;
13
46
  }
14
47
  type BaseProperties = Traits & {
15
48
  resource: string;
@@ -29,7 +62,7 @@ export declare namespace ILevoAudience {
29
62
  type EventProperties = {
30
63
  properties: Properties;
31
64
  traits: Traits;
32
- event: string;
65
+ event: AnalyticsEventType;
33
66
  type: "track" | "page" | "identify";
34
67
  userId: string | null;
35
68
  };
@@ -51,7 +84,7 @@ export declare namespace ILevoAudience {
51
84
  type CollectInput = BaseInput & {
52
85
  session_id?: string;
53
86
  device_id?: string;
54
- event: string;
87
+ event: AnalyticsEventType;
55
88
  version?: number;
56
89
  properties: Properties;
57
90
  resource: string;
@@ -1 +1 @@
1
- {"version":3,"file":"audience.d.ts","sourceRoot":"","sources":["../../src/types/audience.ts"],"names":[],"mappings":"AACA,yBAAiB,aAAa,CAAC;IAC7B,UAAiB,MAAM;QACrB,YAAY,EAAE,OAAO,CAAC;QACtB,SAAS,EAAE,OAAO,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE;YACR,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACjC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;SAC9B,CAAC;QACF,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;KACjC;IAED,KAAY,cAAc,GAAG,MAAM,GAAG;QACpC,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;KACpB,CAAC;IAEF,UAAiB,eAAe;QAC9B,EAAE,EAAE,MAAM,CAAC;KACZ;IAED,UAAiB,kBAAkB;QACjC,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB;IAED,UAAiB,gBAAgB;QAC/B,OAAO,EAAE,MAAM,CAAC;KACjB;IAED,KAAY,UAAU,GAAG,OAAO,CAC9B,cAAc,GAAG,eAAe,GAAG,kBAAkB,GAAG,gBAAgB,CACzE,GACC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,GAAG,WAAW,GAAG,QAAQ,CAAC,CAAC,GACjE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEtB,KAAY,eAAe,GAAG;QAC5B,UAAU,EAAE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GAAG,MAAM,GAAG,UAAU,CAAC;QACpC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,CAAC;IAEF,KAAY,SAAS,GAAG;QACtB,YAAY,EAAE,MAAM,CAAC;QACrB,QAAQ,EAAE,MAAM,CAAC;QACjB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,GAAG,EAAE,MAAM,CAAC;QACZ,UAAU,EAAE,MAAM,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;IAEF,KAAY,YAAY,GAAG,MAAM,GAAG,SAAS,CAAC;IAE9C,KAAY,eAAe,GAAG;QAC5B,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,MAAM,CAAC;KAChB,CAAC;IAEF,KAAY,YAAY,GAAG,SAAS,GAAG;QACrC,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,KAAK,EAAE,kBAAkB,CAAC;QAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,UAAU,CAAC;QACvB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;KAChC,CAAC;IAEF,KAAY,cAAc,GAAG;QAC3B,MAAM,EAAE,OAAO,CAAC;QAChB,UAAU,EAAE,OAAO,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;CACH"}
@@ -0,0 +1,3 @@
1
+ export declare const listToColumn: <T extends string>(columns: readonly string[]) => Record<T, string>;
2
+ export declare const listToRecord: <T extends string>(columns: readonly string[]) => { [K in T]: K; };
3
+ //# sourceMappingURL=listToX.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"listToX.d.ts","sourceRoot":"","sources":["../../src/utils/listToX.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,WAClC,SAAS,MAAM,EAAE,KACzB,MAAM,CAAC,CAAC,EAAE,MAAM,CAOlB,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,MAAM,WAClC,SAAS,MAAM,EAAE,KACzB,GACA,CAAM,IAAD,CAAC,GAAG,CAAC,GAUZ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../src/utils/lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,GAAG,CAAS;gBAER,OAAO,EAAE,MAAM;IAI3B,WAAW,CAAC,QAAQ,GAAE,MAAa,GAAG,OAAO;IAe7C,WAAW,IAAI,IAAI;IAInB,QAAQ,CAAC,QAAQ,GAAE,MAAa,GAAG,OAAO;CAO3C"}
1
+ {"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../src/utils/lock.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,GAAG,CAAS;gBAER,OAAO,EAAE,MAAM;IAI3B,WAAW,CAAC,QAAQ,GAAE,MAAa,GAAG,OAAO;IAuB7C,WAAW;IAIX,QAAQ,CAAC,QAAQ,GAAE,MAAa,GAAG,OAAO;CAS3C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/core",
3
- "version": "0.1.35",
3
+ "version": "0.1.37",
4
4
  "author": "Levo Engineering <devs@theinternetfolks.com>",
5
5
  "description": "Levo common utilities",
6
6
  "type": "module",
@@ -18,13 +18,15 @@
18
18
  "@analytics/visitor-source": "0.0.7",
19
19
  "analytics": "0.8.14",
20
20
  "get-user-locale": "2.3.2",
21
+ "lodash-es": "4.17.21",
21
22
  "wretch": "2.9.0"
22
23
  },
23
24
  "devDependencies": {
25
+ "@types/lodash-es": "4.17.12",
24
26
  "tsup": "8.2.4",
25
27
  "typescript": "5.5.4",
26
- "@levo/eslint-config": "0.0.0",
27
- "@levo/ts-config": "0.0.0"
28
+ "@levo/ts-config": "0.0.0",
29
+ "@levo/eslint-config": "0.0.0"
28
30
  },
29
31
  "main": "./dist/index.js",
30
32
  "module": "./dist/index.js",
@@ -1,38 +0,0 @@
1
- export type WorkspaceID = `W${string}`;
2
- export declare const workspaceIdRegex: RegExp;
3
- export interface IPageContext {
4
- url: string;
5
- id?: string;
6
- referrer?: string;
7
- title?: string;
8
- }
9
- export interface ILevoConfig {
10
- appName?: string;
11
- workspace: WorkspaceID | null;
12
- apiUrl: string;
13
- insightsUrl: string;
14
- NODE_ENV: string;
15
- APP_MODE?: "production" | "staging";
16
- pageContext?: IPageContext | null;
17
- }
18
- /**
19
- * @description LevoClient is class that provides a way to initialize the Levo SDK.
20
- * It is used to set the workspace and environment variables for the SDK.
21
- * It is intended to be used outside of framework boundary like Next.js, React, etc.
22
- */
23
- declare class LevoClient implements ILevoConfig {
24
- #private;
25
- appName?: string | undefined;
26
- constructor(props: Partial<ILevoConfig>);
27
- get workspace(): `W${string}` | null;
28
- get apiUrl(): string;
29
- get insightsUrl(): string;
30
- get NODE_ENV(): string;
31
- get APP_MODE(): "production" | "staging" | undefined;
32
- updateWorkspace(workspace: WorkspaceID): void;
33
- getPageContext(): IPageContext | null | undefined;
34
- updatePageContext(pageContext: IPageContext | null): void;
35
- get fetch(): import("wretch/addons/queryString").QueryStringAddon & import("wretch").Wretch<import("wretch/addons/queryString").QueryStringAddon, unknown, undefined>;
36
- }
37
- export { LevoClient, LevoClient as default };
38
- //# sourceMappingURL=LevoClient.d.ts.map
@@ -1,69 +0,0 @@
1
- import { WretchError } from 'wretch/resolver';
2
-
3
- // src/utils/LevoError.ts
4
- var LevoError = class extends Error {
5
- code;
6
- title;
7
- message;
8
- status;
9
- constructor(data) {
10
- super(data?.message || data?.description);
11
- this.name = "Levo Request Error";
12
- this.status = data?.status;
13
- this.code = data?.code;
14
- this.message = data?.message || data?.description;
15
- this.title = data?.title;
16
- }
17
- };
18
- var getLevoError = (error) => {
19
- if (error instanceof WretchError) {
20
- const errorResponse = error?.json;
21
- if (typeof errorResponse === "object" && errorResponse?.content) {
22
- const errorMessage = errorResponse?.content;
23
- return new LevoError(errorMessage);
24
- }
25
- }
26
- let displayMessage = error?.message || "Something unexpected happened.";
27
- switch (error?.message) {
28
- case "Network Error":
29
- displayMessage = "Couldn't connect to our servers.";
30
- break;
31
- }
32
- return new LevoError({
33
- status: "500",
34
- title: "Network Error",
35
- description: displayMessage,
36
- code: "UNKNOWN_ERROR"
37
- });
38
- };
39
-
40
- // src/utils/lock.ts
41
- var LocalStorageLock = class {
42
- key;
43
- constructor(lockKey) {
44
- this.key = `lock_${lockKey}`;
45
- }
46
- acquireLock(expiryMs = 5e3) {
47
- const now = Date.now();
48
- const lockValue = localStorage.getItem(this.key);
49
- if (lockValue) {
50
- const timestamp = Number(lockValue);
51
- if (now - timestamp < expiryMs) {
52
- return false;
53
- }
54
- }
55
- localStorage.setItem(this.key, now.toString());
56
- return true;
57
- }
58
- releaseLock() {
59
- localStorage.removeItem(this.key);
60
- }
61
- isLocked(expiryMs = 5e3) {
62
- const lockValue = localStorage.getItem(this.key);
63
- if (!lockValue) return false;
64
- const timestamp = Number(lockValue);
65
- return Date.now() - timestamp < expiryMs;
66
- }
67
- };
68
-
69
- export { LevoError, LocalStorageLock, getLevoError };
@@ -1,9 +0,0 @@
1
- // src/plugins/LevoPlugin.ts
2
- var LevoPlugin = class {
3
- client;
4
- constructor(client) {
5
- this.client = client;
6
- }
7
- };
8
-
9
- export { LevoPlugin };
@@ -1,8 +0,0 @@
1
- // src/constants/oauthProvider.ts
2
- var LevoOAuthProviderList = [
3
- "google",
4
- "linkedin",
5
- "microsoft"
6
- ];
7
-
8
- export { LevoOAuthProviderList };
@@ -1,32 +0,0 @@
1
- import { type AnalyticsInstance } from "analytics";
2
- import type { ILevoAudience } from "../types/audience";
3
- import { LevoPlugin } from "./LevoPlugin";
4
- export declare class LevoAudience extends LevoPlugin {
5
- #private;
6
- instance: AnalyticsInstance | null;
7
- idle_listener: any;
8
- request<ResponseBody = unknown, RequestBody = unknown>(url: string, data: RequestBody): Promise<Awaited<ResponseBody>>;
9
- initiate(properties: ILevoAudience.Properties): Promise<any>;
10
- identify(): Promise<void>;
11
- getReferrer(): {
12
- type?: undefined;
13
- referrer?: undefined;
14
- data?: undefined;
15
- raw?: undefined;
16
- } | {
17
- type: string;
18
- referrer: Record<string, string>;
19
- data: Record<string, string>;
20
- raw: string;
21
- };
22
- startActivityListener(): null;
23
- getActivityStatus(): {
24
- status: "idle" | "active";
25
- seconds: number;
26
- } | null;
27
- bounce(properties: ILevoAudience.Properties): Promise<void>;
28
- track<T extends ILevoAudience.Properties>(event: string, properties: T & ILevoAudience.Properties): Promise<any>;
29
- getCurrentTabId(): string;
30
- getTabCount(): number;
31
- }
32
- //# sourceMappingURL=LevoAudience.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LevoAudience.d.ts","sourceRoot":"","sources":["../../src/plugins/LevoAudience.ts"],"names":[],"mappings":"AAEA,OAAO,EAAa,KAAK,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAG9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAMvD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,YAAa,SAAQ,UAAU;;IAC1C,QAAQ,EAAE,iBAAiB,GAAG,IAAI,CAAQ;IAC1C,aAAa,EAAE,GAAG,CAAQ;IAoB1B,OAAO,CAAC,YAAY,GAAG,OAAO,EAAE,WAAW,GAAG,OAAO,EACnD,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,WAAW;IA8Bb,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU;IA8J7C,QAAQ;IAed,WAAW;;;;;;;;;;;IAmEX,qBAAqB;IAqBrB,iBAAiB,IAAI;QACnB,MAAM,EAAE,MAAM,GAAG,QAAQ,CAAC;QAC1B,OAAO,EAAE,MAAM,CAAC;KACjB,GAAG,IAAI;IAcF,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,UAAU;IAc3C,KAAK,CAAC,CAAC,SAAS,aAAa,CAAC,UAAU,EAC5C,KAAK,EAAE,MAAM,EACb,UAAU,EAAE,CAAC,GAAG,aAAa,CAAC,UAAU;IAuC1C,eAAe;IAaf,WAAW;CAYZ"}