@levo-so/core 0.1.10 → 0.1.12
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/dist/LevoClient.d.ts +5 -3
- package/dist/index.js +10 -2
- package/dist/plugins/LevoCollection.d.ts.map +1 -1
- package/dist/plugins/LevoCollection.js +2 -6
- package/dist/plugins/LevoLogger.js +1 -1
- package/dist/plugins/LevoMembership.d.ts +3 -1
- package/dist/plugins/LevoMembership.d.ts.map +1 -1
- package/dist/plugins/LevoMembership.js +10 -40
- package/dist/types/audience.d.ts +0 -1
- package/dist/types/audience.d.ts.map +1 -1
- package/dist/types/membership/index.d.ts +3 -3
- package/package.json +1 -1
package/dist/LevoClient.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
export type WorkspaceID = `W${string}`;
|
|
2
|
+
export declare const workspaceIdRegex: RegExp;
|
|
1
3
|
export interface ILevoConfig {
|
|
2
|
-
workspace:
|
|
4
|
+
workspace: WorkspaceID | null;
|
|
3
5
|
apiUrl: string;
|
|
4
6
|
insightsUrl: string;
|
|
5
7
|
NODE_ENV: string;
|
|
@@ -13,12 +15,12 @@ export interface ILevoConfig {
|
|
|
13
15
|
declare class LevoClient implements ILevoConfig {
|
|
14
16
|
#private;
|
|
15
17
|
constructor(props: Partial<ILevoConfig>);
|
|
16
|
-
get workspace(): string | null;
|
|
18
|
+
get workspace(): `W${string}` | null;
|
|
17
19
|
get apiUrl(): string;
|
|
18
20
|
get insightsUrl(): string;
|
|
19
21
|
get NODE_ENV(): string;
|
|
20
22
|
get APP_MODE(): "production" | "staging" | undefined;
|
|
21
|
-
updateWorkspace(workspace:
|
|
23
|
+
updateWorkspace(workspace: WorkspaceID): void;
|
|
22
24
|
get fetch(): import("wretch/addons/queryString").QueryStringAddon & import("wretch").Wretch<import("wretch/addons/queryString").QueryStringAddon, unknown, undefined>;
|
|
23
25
|
}
|
|
24
26
|
export { LevoClient, LevoClient as default };
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,7 @@ export { LevoPlugin } from './chunk-QJSKNLTV.js';
|
|
|
4
4
|
import wretch from 'wretch';
|
|
5
5
|
import QueryStringAddon from 'wretch/addons/queryString';
|
|
6
6
|
|
|
7
|
+
var workspaceIdRegex = /^W[A-Z0-9]{7}$/;
|
|
7
8
|
var LevoClient = class {
|
|
8
9
|
#workspace;
|
|
9
10
|
#apiUrl;
|
|
@@ -13,11 +14,18 @@ var LevoClient = class {
|
|
|
13
14
|
constructor(props) {
|
|
14
15
|
const defaultProps = {
|
|
15
16
|
workspace: null,
|
|
16
|
-
apiUrl: "https://
|
|
17
|
+
apiUrl: "https://public-api.levo.so",
|
|
17
18
|
insightsUrl: "/.levo/insights/api",
|
|
18
19
|
NODE_ENV: "production"
|
|
19
20
|
};
|
|
20
21
|
const finalProps = { ...defaultProps, ...props };
|
|
22
|
+
if (props.workspace) {
|
|
23
|
+
if (!workspaceIdRegex.test(props.workspace)) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
`Invalid workspace ID: ${props.workspace}. Workspace ID must be a string of the format "W[A-Z0-9]{7}".`
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
}
|
|
21
29
|
this.#workspace = finalProps.workspace;
|
|
22
30
|
this.#apiUrl = finalProps.apiUrl;
|
|
23
31
|
this.#insightsUrl = finalProps.insightsUrl;
|
|
@@ -267,4 +275,4 @@ var createSrcSet = (srcSetObj) => {
|
|
|
267
275
|
return Object.entries(srcSetObj).map(([key, value]) => `${formatImagePath(value)} ${key}w`).join(", ");
|
|
268
276
|
};
|
|
269
277
|
|
|
270
|
-
export { FieldInterfaces, FieldInterfacesList, FieldKind, FieldKindList, LevoClient, MediaKind, MediaKindList, createSrcSet, defaultByKinds, formatImagePath, formatsByInterface, interfaceKinds };
|
|
278
|
+
export { FieldInterfaces, FieldInterfacesList, FieldKind, FieldKindList, LevoClient, MediaKind, MediaKindList, createSrcSet, defaultByKinds, formatImagePath, formatsByInterface, interfaceKinds, workspaceIdRegex };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LevoCollection.d.ts","sourceRoot":"","sources":["../../src/plugins/LevoCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,eAAe,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,cAAe,SAAQ,UAAU;IAC5C,iBAAiB,
|
|
1
|
+
{"version":3,"file":"LevoCollection.d.ts","sourceRoot":"","sources":["../../src/plugins/LevoCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAC5C,OAAO,KAAK,EACV,WAAW,EACX,eAAe,EACf,iBAAiB,EACjB,eAAe,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,cAAe,SAAQ,UAAU;IAC5C,iBAAiB,CACf,IAAI,GAAE,SAAS,CAAC,SAAc,EAC9B,OAAO,GAAE,aAAkB;IAS7B,yBAAyB,CAAC,CAAC,GAAG,eAAe,EAC3C,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,aAAkB;IAS7B,gBAAgB,CAAC,IAAI,EAAE,eAAe;IAOtC,kBAAkB,CAAC,EACjB,aAAa,EACb,IAAI,EACJ,OAAY,GACb,EAAE;QACD,aAAa,EAAE,MAAM,CAAC;QACtB,IAAI,EAAE,GAAG,CAAC;QACV,OAAO,CAAC,EAAE,aAAa,CAAC;KACzB;IAQD,wBAAwB,CAAC,EACvB,cAAc,EACd,IAAI,EACJ,MAAM,EACN,KAAU,GACX,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;QACvB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB;IAYD,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;IAOhD,aAAa,CAAC,cAAc,EAAE,MAAM;IAOpC,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,IAAI,EAAE,GAAG;CAMnD"}
|
|
@@ -2,12 +2,8 @@ import { LevoPlugin } from '../chunk-QJSKNLTV.js';
|
|
|
2
2
|
|
|
3
3
|
// src/plugins/LevoCollection.ts
|
|
4
4
|
var LevoCollection = class extends LevoPlugin {
|
|
5
|
-
getAllCollections(data = {}, options) {
|
|
6
|
-
|
|
7
|
-
if (options) {
|
|
8
|
-
request = request.options(options);
|
|
9
|
-
}
|
|
10
|
-
return request.post(data).json();
|
|
5
|
+
getAllCollections(data = {}, options = {}) {
|
|
6
|
+
return this.client.fetch.url("/v1/bevy/collection/query").options(options).post(data).json();
|
|
11
7
|
}
|
|
12
8
|
getCollectionByIDExpanded(id, options = {}) {
|
|
13
9
|
return this.client.fetch.url(`/v1/bevy/collection/${id}`).options(options).get().json();
|
|
@@ -9,7 +9,7 @@ var LevoLogger = class extends LevoPlugin {
|
|
|
9
9
|
logger.setLevel(
|
|
10
10
|
this.client.NODE_ENV === "production" ? logger.levels.INFO : logger.levels.DEBUG
|
|
11
11
|
);
|
|
12
|
-
logger.methodFactory = (methodName
|
|
12
|
+
logger.methodFactory = (methodName) => (message, attributes = {}) => {
|
|
13
13
|
wretch().url(`${this.client.apiUrl}/v1/apm/logs/json`).post({
|
|
14
14
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
15
15
|
level: methodName,
|
|
@@ -18,7 +18,9 @@ export declare class LevoMembership extends LevoPlugin {
|
|
|
18
18
|
* Sign out the current user's account
|
|
19
19
|
* @returns T | null
|
|
20
20
|
*/
|
|
21
|
-
signOut<T =
|
|
21
|
+
signOut<T = {
|
|
22
|
+
status: boolean;
|
|
23
|
+
}>(options?: WretchOptions): Promise<T>;
|
|
22
24
|
/**
|
|
23
25
|
* Get the current user's account
|
|
24
26
|
* @returns T | null
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LevoMembership.d.ts","sourceRoot":"","sources":["../../src/plugins/LevoMembership.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAM5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,qBAAa,cAAe,SAAQ,UAAU;IAC5C;;;;;;;;;;OAUG;IACG,WAAW,CACf,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"LevoMembership.d.ts","sourceRoot":"","sources":["../../src/plugins/LevoMembership.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAM5C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAC3D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG1C,qBAAa,cAAe,SAAQ,UAAU;IAC5C;;;;;;;;;;OAUG;IACG,WAAW,CACf,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC;IA+CxC;;;OAGG;IACG,OAAO,CAAC,CAAC,GAAG;QAAE,MAAM,EAAE,OAAO,CAAA;KAAE,EACnC,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,CAAC,CAAC;IAQb;;;OAGG;IACG,KAAK,CAAC,CAAC,GAAG,eAAe,CAAC,OAAO,EACrC,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,CAAC,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CAAC,kBAAkB,EAChD,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CASrB"}
|
|
@@ -17,9 +17,7 @@ var LevoMembership = class extends LevoPlugin {
|
|
|
17
17
|
async getOAuthURL(options = {}) {
|
|
18
18
|
try {
|
|
19
19
|
const response = await this.client.fetch.url("/v1/membership/auth/oauth/get-redirect-url").options(options).get().json();
|
|
20
|
-
const
|
|
21
|
-
content: { data: result }
|
|
22
|
-
} = response;
|
|
20
|
+
const result = response?.content?.data;
|
|
23
21
|
const providers = Object.keys(result);
|
|
24
22
|
if (typeof window !== "undefined") {
|
|
25
23
|
for (const provider of providers) {
|
|
@@ -48,11 +46,7 @@ var LevoMembership = class extends LevoPlugin {
|
|
|
48
46
|
* @returns T | null
|
|
49
47
|
*/
|
|
50
48
|
async signOut(options = {}) {
|
|
51
|
-
|
|
52
|
-
const {
|
|
53
|
-
content: { data: result }
|
|
54
|
-
} = response;
|
|
55
|
-
return result;
|
|
49
|
+
return this.client.fetch.url("/v1/membership/auth/sign-out").options(options).post("").json();
|
|
56
50
|
}
|
|
57
51
|
/**
|
|
58
52
|
* Get the current user's account
|
|
@@ -60,24 +54,15 @@ var LevoMembership = class extends LevoPlugin {
|
|
|
60
54
|
*/
|
|
61
55
|
async getMe(options = {}) {
|
|
62
56
|
const response = await this.client.fetch.url("/v1/membership/auth/get-me").options(options).get().json();
|
|
63
|
-
|
|
64
|
-
content: { data: result }
|
|
65
|
-
} = response;
|
|
66
|
-
return result;
|
|
57
|
+
return response?.content?.data;
|
|
67
58
|
}
|
|
68
59
|
async updateMe(data, options = {}) {
|
|
69
60
|
const response = await this.client.fetch.url("/v1/membership/auth/update-me").options(options).put(data).json();
|
|
70
|
-
|
|
71
|
-
content: { data: result }
|
|
72
|
-
} = response;
|
|
73
|
-
return result;
|
|
61
|
+
return response?.content?.data;
|
|
74
62
|
}
|
|
75
63
|
async createPassword(data, options = {}) {
|
|
76
64
|
const response = await this.client.fetch.url("/v1/membership/auth/change-password").options(options).put(data).json();
|
|
77
|
-
|
|
78
|
-
content: { data: result }
|
|
79
|
-
} = response;
|
|
80
|
-
return result;
|
|
65
|
+
return response?.content?.data;
|
|
81
66
|
}
|
|
82
67
|
async isLoggedIn(options = {}) {
|
|
83
68
|
try {
|
|
@@ -92,38 +77,23 @@ var LevoMembership = class extends LevoPlugin {
|
|
|
92
77
|
data.redirect_uri = window.location.href;
|
|
93
78
|
}
|
|
94
79
|
const response = await this.client.fetch.url("/v1/membership/auth/request-magic-link").options(options).post(data).json();
|
|
95
|
-
|
|
96
|
-
content: { data: result }
|
|
97
|
-
} = response;
|
|
98
|
-
return result;
|
|
80
|
+
return response?.content?.data;
|
|
99
81
|
}
|
|
100
82
|
async requestOtp(data, options = {}) {
|
|
101
83
|
const response = await this.client.fetch.url("/v1/membership/auth/request-otp").options(options).post(data).json();
|
|
102
|
-
|
|
103
|
-
content: { data: result }
|
|
104
|
-
} = response;
|
|
105
|
-
return result;
|
|
84
|
+
return response?.content?.data;
|
|
106
85
|
}
|
|
107
86
|
async signInWithOtp(data, options = {}) {
|
|
108
87
|
const response = await this.client.fetch.url("/v1/membership/auth/signin-with-otp").options(options).post(data).json();
|
|
109
|
-
|
|
110
|
-
content: { data: result }
|
|
111
|
-
} = response;
|
|
112
|
-
return result;
|
|
88
|
+
return response?.content?.data;
|
|
113
89
|
}
|
|
114
90
|
async signInWithPassword(data, options = {}) {
|
|
115
91
|
const response = await this.client.fetch.url("/v1/membership/auth/signin-with-password").options(options).post(data).json();
|
|
116
|
-
|
|
117
|
-
content: { data: result }
|
|
118
|
-
} = response;
|
|
119
|
-
return result;
|
|
92
|
+
return response?.content?.data;
|
|
120
93
|
}
|
|
121
94
|
async signUpWithPassword(data, options = {}) {
|
|
122
95
|
const response = await this.client.fetch.url("/v1/membership/auth/signup-with-password").options(options).post(data).json();
|
|
123
|
-
|
|
124
|
-
content: { data: result }
|
|
125
|
-
} = response;
|
|
126
|
-
return result;
|
|
96
|
+
return response?.content?.data;
|
|
127
97
|
}
|
|
128
98
|
};
|
|
129
99
|
|
package/dist/types/audience.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audience.d.ts","sourceRoot":"","sources":["../../src/types/audience.ts"],"names":[],"mappings":"AAAA,yBAAiB,aAAa,CAAC;IAC7B,UAAiB,cAAc;QAC7B,YAAY,EAAE,OAAO,CAAC;QACtB,SAAS,EAAE,OAAO,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QAEjB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE;YACR,IAAI,EAAE,GAAG,CAAC;YACV,QAAQ,EAAE,GAAG,CAAC;YACd,IAAI,EAAE,GAAG,CAAC;SACX,CAAC;KACH;IAED,UAAiB,eAAe;QAC9B,EAAE,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"audience.d.ts","sourceRoot":"","sources":["../../src/types/audience.ts"],"names":[],"mappings":"AAAA,yBAAiB,aAAa,CAAC;IAC7B,UAAiB,cAAc;QAC7B,YAAY,EAAE,OAAO,CAAC;QACtB,SAAS,EAAE,OAAO,CAAC;QACnB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QAEjB,QAAQ,EAAE,MAAM,CAAC;QACjB,UAAU,EAAE,MAAM,CAAC;QACnB,QAAQ,EAAE;YACR,IAAI,EAAE,GAAG,CAAC;YACV,QAAQ,EAAE,GAAG,CAAC;YACd,IAAI,EAAE,GAAG,CAAC;SACX,CAAC;KACH;IAED,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,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAEtB,KAAY,eAAe,GAAG;QAC5B,UAAU,EAAE,UAAU,CAAC;QACvB,MAAM,EAAE,UAAU,CAAC;QACnB,KAAK,EAAE,MAAM,CAAC;QACd,IAAI,EAAE,OAAO,GAAG,MAAM,GAAG,UAAU,CAAC;QACpC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;KACvB,CAAC;CACH"}
|
|
@@ -58,9 +58,9 @@ export declare namespace ILevoMembership {
|
|
|
58
58
|
* @example
|
|
59
59
|
* ```javascript
|
|
60
60
|
* {
|
|
61
|
-
* "google": 'https://
|
|
62
|
-
* "microsoft": 'https://
|
|
63
|
-
* "linkedin": 'https://
|
|
61
|
+
* "google": 'https://public-api.levo.so/v1/membership/auth/oauth/google?redirect_uri=https://example.com&workspace=my-workspace',
|
|
62
|
+
* "microsoft": 'https://public-api.levo.so/v1/membership/auth/oauth/microsoft?redirect_uri=https://example.com&workspace=my-workspace',
|
|
63
|
+
* "linkedin": 'https://public-api.levo.so/v1/membership/auth/oauth/linkedin?redirect_uri=https://example.com&workspace=my-workspace'
|
|
64
64
|
* }
|
|
65
65
|
* ```
|
|
66
66
|
*/
|