@levo-so/core 0.1.34 → 0.1.36

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 (46) hide show
  1. package/dist/client.d.ts +72 -0
  2. package/dist/constants/media.d.ts +1 -1
  3. package/dist/control/audience.d.ts +13 -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 +2 -2
  9. package/dist/index.js +1124 -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/package.json +3 -1
  23. package/dist/LevoClient.d.ts +0 -38
  24. package/dist/chunk-QJSKNLTV.js +0 -9
  25. package/dist/chunk-VQMSBMEM.js +0 -40
  26. package/dist/chunk-ZLLCLSGE.js +0 -8
  27. package/dist/plugins/LevoAudience.d.ts +0 -32
  28. package/dist/plugins/LevoAudience.d.ts.map +0 -1
  29. package/dist/plugins/LevoAudience.js +0 -589
  30. package/dist/plugins/LevoBlog.d.ts +0 -8
  31. package/dist/plugins/LevoBlog.d.ts.map +0 -1
  32. package/dist/plugins/LevoBlog.js +0 -21
  33. package/dist/plugins/LevoCollection.d.ts +0 -23
  34. package/dist/plugins/LevoCollection.d.ts.map +0 -1
  35. package/dist/plugins/LevoCollection.js +0 -47
  36. package/dist/plugins/LevoLogger.d.ts +0 -32
  37. package/dist/plugins/LevoLogger.d.ts.map +0 -1
  38. package/dist/plugins/LevoLogger.js +0 -193
  39. package/dist/plugins/LevoMedia.d.ts.map +0 -1
  40. package/dist/plugins/LevoMedia.js +0 -13
  41. package/dist/plugins/LevoMembership.d.ts +0 -38
  42. package/dist/plugins/LevoMembership.d.ts.map +0 -1
  43. package/dist/plugins/LevoMembership.js +0 -104
  44. package/dist/plugins/LevoPlugin.d.ts +0 -6
  45. package/dist/plugins/LevoPlugin.d.ts.map +0 -1
  46. package/dist/plugins/LevoPlugin.js +0 -1
@@ -1,589 +0,0 @@
1
- import { getLevoError } from '../chunk-VQMSBMEM.js';
2
- import { LevoPlugin } from '../chunk-QJSKNLTV.js';
3
- import { onUserActivity } from '@analytics/activity-utils';
4
- import { getVisitorSource } from '@analytics/visitor-source';
5
- import { Analytics } from 'analytics';
6
- import wretch from 'wretch';
7
- import getUserLocale from 'get-user-locale';
8
-
9
- // src/utils/isIncognito.ts
10
- var isIncognito = () => new Promise((resolve, reject) => {
11
- let browserName = "Unknown";
12
- function __callback(isPrivate) {
13
- resolve({
14
- isPrivate,
15
- browserName
16
- });
17
- }
18
- function identifyChromium() {
19
- const ua = navigator.userAgent;
20
- if (ua.match(/Chrome/)) {
21
- if (navigator.brave !== void 0) {
22
- return "Brave";
23
- }
24
- if (ua.match(/Edg/)) {
25
- return "Edge";
26
- }
27
- if (ua.match(/OPR/)) {
28
- return "Opera";
29
- }
30
- return "Chrome";
31
- }
32
- return "Chromium";
33
- }
34
- function assertEvalToString(value) {
35
- return value === eval.toString().length;
36
- }
37
- function isSafari() {
38
- const v = navigator.vendor;
39
- return v !== void 0 && v.indexOf("Apple") === 0 && assertEvalToString(37);
40
- }
41
- function isChrome() {
42
- const v = navigator.vendor;
43
- return v !== void 0 && v.indexOf("Google") === 0 && assertEvalToString(33);
44
- }
45
- function isFirefox() {
46
- return document.documentElement !== void 0 && document.documentElement.style.MozAppearance !== void 0 && assertEvalToString(37);
47
- }
48
- function isMSIE() {
49
- return navigator.msSaveBlob !== void 0 && assertEvalToString(39);
50
- }
51
- function newSafariTest() {
52
- const tmp_name = String(Math.random());
53
- try {
54
- const db = window.indexedDB.open(tmp_name, 1);
55
- db.onupgradeneeded = (i) => {
56
- const res = i.target?.result;
57
- try {
58
- res.createObjectStore("test", {
59
- autoIncrement: true
60
- }).put(new Blob());
61
- __callback(false);
62
- } catch (e) {
63
- let message = e;
64
- if (e instanceof Error) {
65
- message = e.message ?? e;
66
- }
67
- if (typeof message !== "string") {
68
- return __callback(false);
69
- }
70
- const matchesExpectedError = /BlobURLs are not yet supported/.test(
71
- message
72
- );
73
- return __callback(matchesExpectedError);
74
- } finally {
75
- res.close();
76
- window.indexedDB.deleteDatabase(tmp_name);
77
- }
78
- };
79
- } catch (e) {
80
- return __callback(false);
81
- }
82
- }
83
- function oldSafariTest() {
84
- const openDB = window.openDatabase;
85
- const storage = window.localStorage;
86
- try {
87
- openDB(null, null, null, null);
88
- } catch (e) {
89
- return __callback(true);
90
- }
91
- try {
92
- storage.setItem("test", "1");
93
- storage.removeItem("test");
94
- } catch (e) {
95
- return __callback(true);
96
- }
97
- return __callback(false);
98
- }
99
- function safariPrivateTest() {
100
- if (navigator.maxTouchPoints !== void 0) {
101
- newSafariTest();
102
- } else {
103
- oldSafariTest();
104
- }
105
- }
106
- function getQuotaLimit() {
107
- const w = window;
108
- if (w.performance !== void 0 && w.performance.memory !== void 0 && w.performance.memory.jsHeapSizeLimit !== void 0) {
109
- return performance.memory.jsHeapSizeLimit;
110
- }
111
- return 1073741824;
112
- }
113
- function storageQuotaChromePrivateTest() {
114
- navigator.webkitTemporaryStorage.queryUsageAndQuota(
115
- (_, quota) => {
116
- const quotaInMib = Math.round(quota / (1024 * 1024));
117
- const quotaLimitInMib = Math.round(getQuotaLimit() / (1024 * 1024)) * 2;
118
- __callback(quotaInMib < quotaLimitInMib);
119
- },
120
- (e) => {
121
- reject(
122
- new Error(
123
- `detectIncognito somehow failed to query storage quota: ${e.message}`
124
- )
125
- );
126
- }
127
- );
128
- }
129
- function oldChromePrivateTest() {
130
- const fs = window.webkitRequestFileSystem;
131
- const success = () => {
132
- __callback(false);
133
- };
134
- const error = () => {
135
- __callback(true);
136
- };
137
- fs(0, 1, success, error);
138
- }
139
- function chromePrivateTest() {
140
- if (self.Promise !== void 0 && self.Promise.allSettled !== void 0) {
141
- storageQuotaChromePrivateTest();
142
- } else {
143
- oldChromePrivateTest();
144
- }
145
- }
146
- function firefoxPrivateTest() {
147
- __callback(navigator.serviceWorker === void 0);
148
- }
149
- function msiePrivateTest() {
150
- __callback(window.indexedDB === void 0);
151
- }
152
- function main() {
153
- if (isSafari()) {
154
- browserName = "Safari";
155
- safariPrivateTest();
156
- } else if (isChrome()) {
157
- browserName = identifyChromium();
158
- chromePrivateTest();
159
- } else if (isFirefox()) {
160
- browserName = "Firefox";
161
- firefoxPrivateTest();
162
- } else if (isMSIE()) {
163
- browserName = "Internet Explorer";
164
- msiePrivateTest();
165
- } else {
166
- reject(new Error("detectIncognito cannot determine the browser"));
167
- }
168
- }
169
- main();
170
- });
171
- var isIncognito_default = isIncognito;
172
-
173
- // src/utils/getUserProperties.ts
174
- var getGPUInfo = () => {
175
- const canvas = document.createElement("canvas");
176
- const gl = canvas?.getContext("webgl") || canvas?.getContext("experimental-webgl");
177
- if (!gl) {
178
- return null;
179
- }
180
- const debugInfo = gl?.getExtension("WEBGL_debug_renderer_info");
181
- return debugInfo ? gl?.getParameter(debugInfo.UNMASKED_RENDERER_WEBGL) : null;
182
- };
183
- var getUserProperties = async () => {
184
- let locale = "";
185
- let timezone = "";
186
- let dark_mode = false;
187
- let private_mode = false;
188
- const properties = {};
189
- if (!window) {
190
- return {
191
- locale,
192
- timezone,
193
- dark_mode,
194
- private_mode,
195
- properties
196
- };
197
- }
198
- try {
199
- ({ isPrivate: private_mode } = await isIncognito_default());
200
- } catch (e) {
201
- console.error(e);
202
- }
203
- try {
204
- dark_mode = window.matchMedia?.("(prefers-color-scheme: dark)").matches;
205
- } catch (e) {
206
- console.error(e);
207
- }
208
- try {
209
- timezone = Intl.DateTimeFormat().resolvedOptions().timeZone;
210
- } catch (e) {
211
- console.error(e);
212
- }
213
- try {
214
- locale = getUserLocale();
215
- } catch (e) {
216
- console.error(e);
217
- }
218
- if (navigator && "connection" in navigator) {
219
- const connection = navigator.connection || navigator?.mozConnection || navigator.webkitConnection;
220
- properties.network_type = connection.effectiveType;
221
- }
222
- properties.width = window?.innerWidth;
223
- properties.height = window?.innerHeight;
224
- properties.pixel_ratio = window?.devicePixelRatio;
225
- if (screen) {
226
- properties.screen_width = screen?.width;
227
- properties.screen_height = screen?.height;
228
- properties.color_depth = screen?.colorDepth;
229
- properties.orientation = screen?.orientation?.type;
230
- }
231
- if (navigator && "getBattery" in navigator) {
232
- const battery = await navigator?.getBattery();
233
- if (battery) {
234
- properties.battery_level = Number((battery?.level * 100).toFixed(0));
235
- properties.battery_charging = battery?.charging;
236
- properties.battery_discharging_time = battery?.dischargingTime;
237
- properties.battery_full_charge_capacity = battery?.fullChargeCapacity;
238
- properties.battery_charging_time = battery?.chargingTime;
239
- }
240
- }
241
- if (navigator && "deviceMemory" in navigator) {
242
- properties.device_memory = navigator?.deviceMemory;
243
- }
244
- const supportsTouch = "ontouchstart" in window || typeof navigator?.maxTouchPoints !== "undefined" && navigator?.maxTouchPoints > 0;
245
- properties.touch_supported = supportsTouch;
246
- if ("hardwareConcurrency" in navigator) {
247
- properties.hardware_concurrency = navigator?.hardwareConcurrency;
248
- }
249
- if (navigator && "mediaDevices" in navigator) {
250
- const mediaDevices = navigator?.mediaDevices;
251
- const devices = await mediaDevices?.enumerateDevices();
252
- const hasCamera = devices.some((device) => device?.kind === "videoinput");
253
- properties.camera_supported = hasCamera;
254
- const hasMicrophone = devices.some(
255
- (device) => device?.kind === "audioinput"
256
- );
257
- properties.microphone_supported = hasMicrophone;
258
- }
259
- properties.gpu = getGPUInfo();
260
- return {
261
- locale,
262
- timezone,
263
- dark_mode,
264
- private_mode,
265
- properties
266
- };
267
- };
268
-
269
- // src/utils/lock.ts
270
- var LocalStorageLock = class {
271
- key;
272
- constructor(lockKey) {
273
- this.key = `lock_${lockKey}`;
274
- }
275
- acquireLock(expiryMs = 5e3) {
276
- const now = Date.now();
277
- const lockValue = localStorage.getItem(this.key);
278
- if (lockValue) {
279
- const timestamp = Number(lockValue);
280
- if (now - timestamp < expiryMs) {
281
- return false;
282
- }
283
- }
284
- localStorage.setItem(this.key, now.toString());
285
- return true;
286
- }
287
- releaseLock() {
288
- localStorage.removeItem(this.key);
289
- }
290
- isLocked(expiryMs = 5e3) {
291
- const lockValue = localStorage.getItem(this.key);
292
- if (!lockValue) return false;
293
- const timestamp = Number(lockValue);
294
- return Date.now() - timestamp < expiryMs;
295
- }
296
- };
297
-
298
- // src/plugins/LevoAudience.ts
299
- var LevoAudience = class extends LevoPlugin {
300
- instance = null;
301
- idle_listener = null;
302
- #IDLE_THROTTLE = 1 * 1e3;
303
- // every 1 second we check for idleness
304
- #IDLE_TIMEOUT = 60 * 1e3;
305
- // 60 seconds till we consider user idle
306
- #session = "";
307
- #device = "";
308
- #is_identified = false;
309
- #batch = [];
310
- #events = [];
311
- request(url, data) {
312
- const headers = {
313
- Accept: "application/json",
314
- "Content-Type": "application/json"
315
- };
316
- if (this.client.workspace) {
317
- headers["Levo-Workspace"] = this.client.workspace;
318
- }
319
- const pageContext = this.client.getPageContext();
320
- if (pageContext) {
321
- headers["Levo-Page-Context"] = encodeURIComponent(
322
- JSON.stringify(pageContext)
323
- );
324
- }
325
- return wretch(url, {
326
- credentials: "include"
327
- }).options({
328
- keepAlive: true
329
- }).headers(headers).post(data).json();
330
- }
331
- async initiate(properties) {
332
- if (this.client.NODE_ENV === "development") {
333
- return;
334
- }
335
- const plugin = {
336
- name: this.client.workspace,
337
- track: ({ payload }) => {
338
- if (!this?.client?.insightsUrl || !this.client.workspace) {
339
- return;
340
- }
341
- const payloadProperties = payload?.properties || {};
342
- const collectInput = {
343
- session_id: this.#session,
344
- device_id: this.#device,
345
- event: payload.event,
346
- version: payload.version || 1,
347
- workspace_id: this.client.workspace,
348
- properties: {
349
- ...properties,
350
- ...payloadProperties,
351
- version: void 0,
352
- resource: void 0,
353
- identifier: void 0,
354
- hostname: void 0,
355
- pathname: void 0,
356
- url: void 0,
357
- page_title: void 0,
358
- created_at: void 0
359
- },
360
- hostname: payload?.hostname || window.location.hostname,
361
- pathname: payload?.pathname || window.location.pathname,
362
- url: payload?.url || window.location.href,
363
- page_title: payload?.page_title || document.title,
364
- resource: payloadProperties?.resource || "page",
365
- identifier: payloadProperties?.identifier || properties?.id,
366
- created_at: payload?.created_at || (/* @__PURE__ */ new Date()).toISOString(),
367
- tab_id: this.getCurrentTabId(),
368
- tab_count: this.getTabCount()
369
- };
370
- let isQueued = false;
371
- try {
372
- isQueued = navigator.sendBeacon(
373
- `${this?.client?.insightsUrl}/v1/insights/event/collect`,
374
- JSON.stringify(collectInput)
375
- );
376
- } catch (e) {
377
- }
378
- if (!isQueued) {
379
- this.request("/v1/insights/event/collect", collectInput);
380
- }
381
- this.#events.push({
382
- input: payload,
383
- payload: collectInput,
384
- queued: isQueued
385
- });
386
- },
387
- page: ({ payload }) => {
388
- if (!this?.client?.insightsUrl) {
389
- return;
390
- }
391
- const payloadProperties = payload?.properties || {};
392
- this.track("page.view", {
393
- ...properties,
394
- ...payloadProperties,
395
- title: document.title,
396
- identifier: properties.id,
397
- resource: "page"
398
- });
399
- },
400
- identify: ({ payload }) => {
401
- if (!this?.client?.insightsUrl || !this.client.workspace) {
402
- return;
403
- }
404
- const welcomeInput = {
405
- private_mode: payload.traits.private_mode,
406
- dark_mode: payload.traits.dark_mode,
407
- timezone: payload.traits.timezone,
408
- locale: payload.traits.locale,
409
- referrer: payload.traits.referrer,
410
- properties: payload.traits.properties,
411
- workspace_id: this.client.workspace,
412
- hostname: window.location.hostname,
413
- pathname: window.location.pathname,
414
- page_title: document.title,
415
- url: window.location.href,
416
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
417
- tab_id: this.getCurrentTabId(),
418
- tab_count: this.getTabCount()
419
- };
420
- const identifyLock = new LocalStorageLock("lv_aud_identify");
421
- if (identifyLock.acquireLock()) {
422
- this.request(
423
- `${this?.client?.insightsUrl}/v1/insights/event/welcome`,
424
- welcomeInput
425
- ).then((data) => {
426
- this.#is_identified = true;
427
- this.#session = data.content.data.session;
428
- this.#device = data.content.data.device;
429
- let isQueued = false;
430
- try {
431
- isQueued = navigator.sendBeacon(
432
- `${this?.client?.insightsUrl}/v1/insights/event/bulk?workspace=${this?.client?.workspace}`,
433
- JSON.stringify(this.#batch)
434
- );
435
- } catch (e) {
436
- }
437
- if (!isQueued) {
438
- this.request("/v1/insights/event/bulk", this.#batch);
439
- }
440
- this.#batch = [];
441
- identifyLock.releaseLock();
442
- }).catch((e) => {
443
- identifyLock.releaseLock();
444
- return getLevoError(e);
445
- });
446
- }
447
- }
448
- };
449
- this.instance = Analytics({
450
- app: this.client.workspace || "",
451
- plugins: [plugin]
452
- });
453
- await this.identify();
454
- this.startActivityListener();
455
- return this.instance.page({
456
- resource: "page",
457
- identifier: properties.id
458
- });
459
- }
460
- async identify() {
461
- if (!this.instance) {
462
- return;
463
- }
464
- const referrer = this.getReferrer();
465
- const traits = await getUserProperties();
466
- await this.instance.identify("", {
467
- ...traits,
468
- referrer
469
- });
470
- }
471
- getReferrer() {
472
- if (typeof document === "undefined") {
473
- return {};
474
- }
475
- const {
476
- type,
477
- referrer,
478
- data = {}
479
- } = getVisitorSource({
480
- referrer: document.referrer,
481
- currentUrl: window.location.href,
482
- mapper: null
483
- });
484
- const dataKeys = Object.keys(data);
485
- for (const key of dataKeys) {
486
- if (data[key] && Array.isArray(data[key]) && data[key].length > 0) {
487
- data[key] = data[key]?.[0];
488
- }
489
- }
490
- return { type, referrer, data, raw: document.referrer };
491
- }
492
- startActivityListener() {
493
- if (typeof document !== "undefined" && !this.idle_listener) {
494
- this.idle_listener = onUserActivity({
495
- timeout: this.#IDLE_TIMEOUT,
496
- throttle: this.#IDLE_THROTTLE,
497
- onIdle: (activeForSeconds) => {
498
- this.track("user.idle", {
499
- seconds_active: activeForSeconds
500
- });
501
- },
502
- onWakeUp: (idleForSeconds) => {
503
- this.track("user.active", {
504
- seconds_idle: idleForSeconds
505
- });
506
- }
507
- });
508
- }
509
- return null;
510
- }
511
- getActivityStatus() {
512
- const status = this?.idle_listener?.getStatus();
513
- if (!status) {
514
- return null;
515
- }
516
- return {
517
- status: status.isIdle ? "idle" : "active",
518
- seconds: status.isIdle ? status.idle : status.active
519
- };
520
- }
521
- async bounce(properties) {
522
- const activity_status = this.getActivityStatus();
523
- if (activity_status) {
524
- if (activity_status?.status === "idle") {
525
- properties.seconds_idle = activity_status.seconds;
526
- } else {
527
- properties.seconds_active = activity_status.seconds;
528
- }
529
- }
530
- this.track("page.bounce", properties);
531
- }
532
- async track(event, properties) {
533
- if (!this.client.workspace) {
534
- return;
535
- }
536
- if (this.instance && this.#is_identified) {
537
- return this.instance.track(event, properties);
538
- }
539
- return this.#batch.push({
540
- event,
541
- version: properties?.version || 1,
542
- properties: {
543
- ...properties,
544
- version: void 0,
545
- resource: void 0,
546
- identifier: void 0,
547
- hostname: void 0,
548
- pathname: void 0,
549
- url: void 0,
550
- page_title: void 0,
551
- created_at: void 0
552
- },
553
- hostname: window.location.hostname,
554
- pathname: window.location.pathname,
555
- url: window.location.href,
556
- page_title: document.title,
557
- resource: properties?.resource || "page",
558
- identifier: properties?.identifier || properties?.id,
559
- workspace_id: this.client.workspace,
560
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
561
- tab_id: this.getCurrentTabId(),
562
- tab_count: this.getTabCount()
563
- });
564
- }
565
- getCurrentTabId() {
566
- try {
567
- if (typeof window === "undefined" || !("sessionStorage" in window)) {
568
- return "";
569
- }
570
- const CURRENT_TAB_LOCAL_STORAGE_KEY = "lv_insights_ct";
571
- return window.sessionStorage.getItem(CURRENT_TAB_LOCAL_STORAGE_KEY) || "";
572
- } catch (_) {
573
- return "";
574
- }
575
- }
576
- getTabCount() {
577
- try {
578
- if (typeof window === "undefined" || !("localStorage" in window)) {
579
- return 0;
580
- }
581
- const OT_LOCAL_STORAGE_KEY = "lv_insights_ot";
582
- return Number(window.localStorage.getItem(OT_LOCAL_STORAGE_KEY)) || 0;
583
- } catch (_) {
584
- return 0;
585
- }
586
- }
587
- };
588
-
589
- export { LevoAudience };
@@ -1,8 +0,0 @@
1
- import type { BlogClient, IResponseMultiple, IResponseSingle } from "../types";
2
- import type { LevoQuery } from "../types/levo-query";
3
- import { LevoPlugin } from "./LevoPlugin";
4
- export declare class LevoBlog extends LevoPlugin {
5
- getAllBlogs(blog_key: string, data?: LevoQuery.FindQuery, options?: BlogClient.OptionParams): Promise<IResponseMultiple<import("../types").IPost>>;
6
- getSingleBlog(blog_key: string, slug: string, options?: BlogClient.OptionParams): Promise<IResponseSingle<import("../types").IPost, any>>;
7
- }
8
- //# sourceMappingURL=LevoBlog.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LevoBlog.d.ts","sourceRoot":"","sources":["../../src/plugins/LevoBlog.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;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,qBAAa,QAAS,SAAQ,UAAU;IACtC,WAAW,CACT,QAAQ,EAAE,MAAM,EAChB,IAAI,GAAE,SAAS,CAAC,SAAc,EAC9B,OAAO,CAAC,EAAE,UAAU,CAAC,YAAY;IAcnC,aAAa,CACX,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,UAAU,CAAC,YAAY;CAapC"}
@@ -1,21 +0,0 @@
1
- import { LevoPlugin } from '../chunk-QJSKNLTV.js';
2
-
3
- // src/plugins/LevoBlog.ts
4
- var LevoBlog = class extends LevoPlugin {
5
- getAllBlogs(blog_key, data = {}, options) {
6
- return this.client.fetch.url(`/v1/blog/${blog_key}/post/query`).query({ ...options?.params || {} }).options({
7
- headers: {
8
- "Levo-Workspace": options?.workspace_id || ""
9
- }
10
- }).post(data).json();
11
- }
12
- getSingleBlog(blog_key, slug, options) {
13
- return this.client.fetch.url(`/v1/blog/${blog_key}/post/${slug}`).query({ ...options?.params || {} }).options({
14
- headers: {
15
- "Levo-Workspace": options?.workspace_id || ""
16
- }
17
- }).get().json();
18
- }
19
- };
20
-
21
- export { LevoBlog };
@@ -1,23 +0,0 @@
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 { LevoPlugin } from "./LevoPlugin";
5
- type ColumnKeys = Prettify<keyof ILemaCollection>;
6
- export declare class LevoCollection extends LevoPlugin {
7
- getAllCollections(data?: LevoQuery.FindQuery<ColumnKeys>, options?: WretchOptions): Promise<IResponseMultiple<ILemaCollection>>;
8
- getCollectionByIDExpanded<T = ILemaCollection>(id: string, options?: WretchOptions): Promise<IResponseSingle<T, any>>;
9
- createCollection(data: ILemaCollection): Promise<IResponseSingle<ILemaCollection, any>>;
10
- saveCollectionData({ collection_id, data, options, }: {
11
- collection_id: string;
12
- data: any;
13
- options?: WretchOptions;
14
- }): Promise<IResponseSingle<any, any>>;
15
- getCollectionContentList({ collection_key, page, search, limit, where, }: {
16
- collection_key: string;
17
- } & LevoQuery.FindQuery): Promise<IResponseMultiple<Record<string, unknown>>>;
18
- saveDraftEntry(collection_key: string, data: any): Promise<IResponseSingle<IDraftEntry, any>>;
19
- getDraftEntry(collection_key: string): Promise<IResponseSingle<IDraftEntry, any>>;
20
- submitDraftEntry(collection_key: string, data: any): Promise<IResponseSingle<IDraftEntry, any>>;
21
- }
22
- export {};
23
- //# sourceMappingURL=LevoCollection.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"LevoCollection.d.ts","sourceRoot":"","sources":["../../src/plugins/LevoCollection.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;AAErD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,KAAK,UAAU,GAAG,QAAQ,CAAC,MAAM,eAAe,CAAC,CAAC;AAElD,qBAAa,cAAe,SAAQ,UAAU;IAC5C,iBAAiB,CACf,IAAI,GAAE,SAAS,CAAC,SAAS,CAAC,UAAU,CAAM,EAC1C,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,EACV,KAAK,GACN,EAAE;QACD,cAAc,EAAE,MAAM,CAAC;KACxB,GAAG,SAAS,CAAC,SAAS;IAavB,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"}
@@ -1,47 +0,0 @@
1
- import { LevoPlugin } from '../chunk-QJSKNLTV.js';
2
-
3
- // src/plugins/LevoCollection.ts
4
- var LevoCollection = class extends LevoPlugin {
5
- getAllCollections(data = {}, options = {}) {
6
- return this.client.fetch.url("/v1/bevy/collection/query").options(options).post(data).json();
7
- }
8
- getCollectionByIDExpanded(id, options = {}) {
9
- return this.client.fetch.url(`/v1/bevy/collection/${id}`).options(options).get().json();
10
- }
11
- createCollection(data) {
12
- return this.client.fetch.url("/v1/bevy/collection").post(data).json();
13
- }
14
- saveCollectionData({
15
- collection_id,
16
- data,
17
- options = {}
18
- }) {
19
- return this.client.fetch.url(`/v1/bevy/content/${collection_id}`).options(options).post(data).json();
20
- }
21
- getCollectionContentList({
22
- collection_key,
23
- page,
24
- search,
25
- limit = 10,
26
- where
27
- }) {
28
- return this.client.fetch.url(`/v1/bevy/content/${collection_key}/query`).post({
29
- page,
30
- limit,
31
- search,
32
- where
33
- }).json();
34
- }
35
- // Collection Draft APIs
36
- saveDraftEntry(collection_key, data) {
37
- return this.client.fetch.url(`/v1/bevy/content/${collection_key}/save-entry`).post(data).json();
38
- }
39
- getDraftEntry(collection_key) {
40
- return this.client.fetch.url(`/v1/bevy/content/${collection_key}/list-entry`).get().json();
41
- }
42
- submitDraftEntry(collection_key, data) {
43
- return this.client.fetch.url(`/v1/bevy/content/${collection_key}/submit-entry`).post(data).json();
44
- }
45
- };
46
-
47
- export { LevoCollection };