@levo-so/core 0.1.113 → 0.2.1

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/README.md CHANGED
@@ -256,8 +256,4 @@ const query: LevoQuery.FindQuery = {
256
256
 
257
257
  **`getLevoError(error)`** — Normalize any thrown value into a `LevoError`. See [Error Handling](#error-handling).
258
258
 
259
- **`formatImagePath(path)`** — URI-encodes the filename portion of a path. Use this when constructing image URLs that may contain spaces or special characters.
260
-
261
- **`listToColumn(arr)`** — Converts `["name", "email"]` into `{ name: "name", email: "email" }`. Useful for building field selection objects programmatically.
262
-
263
259
  **Type utilities** — `Prettify<T>`, `Mandatory<T, K>`, and `DeepPartial<T>` are exported from the package for use in consuming packages that build on top of `@levo-so/core`.
package/dist/index.d.ts CHANGED
@@ -2,6 +2,12 @@ import { QueryStringAddon } from 'wretch/addons/queryString';
2
2
  import { Wretch } from 'wretch';
3
3
  import { WretchOptions } from 'wretch';
4
4
 
5
+ export declare const allMediaFileExtensions: string[];
6
+
7
+ export declare const allMediaMimetypes: {
8
+ [x: string]: string[];
9
+ };
10
+
5
11
  export declare const AnalyticsEvents: {
6
12
  "bevy.collection.filled": "bevy.collection.filled";
7
13
  "bevy.collection.submitted": "bevy.collection.submitted";
@@ -34,6 +40,14 @@ export declare const AnalyticsEventsList: readonly ["bevy.collection.filled", "b
34
40
 
35
41
  export declare type AnalyticsEventType = (typeof AnalyticsEventsList)[number];
36
42
 
43
+ export declare const audioFileExtensions: string[];
44
+
45
+ export declare const audioMimetype: {
46
+ "audio/mpeg": string[];
47
+ "audio/ogg": string[];
48
+ "audio/opus": string[];
49
+ };
50
+
37
51
  export declare namespace BlogClient {
38
52
  export interface CoverImage {
39
53
  _id: string;
@@ -204,6 +218,10 @@ export declare const createLevoClient: (options: ILevoClientOptions) => {
204
218
  submitDraftEntry: (collection_key: string, data: any) => Promise<IResponseSingle<IDraftEntry>>;
205
219
  getFilters: (collectionId: string, options?: WretchOptions) => Promise<IResponseMultiple<ILemaCollection["sections"][number]["fields"][number]>>;
206
220
  };
221
+ readonly event: {
222
+ getAllEvents: (series_key: string, data?: import("./types").LevoQuery.FindQuery, options?: import("./types").BlogClient.OptionParams) => Promise<IResponseMultiple<import("./types").LevoEvent.Root>>;
223
+ getSingleEvent: (slug: string, options?: import("./types").BlogClient.OptionParams) => Promise<IResponseSingle<import("./types").LevoEvent.Root>>;
224
+ };
207
225
  readonly media: {
208
226
  mediaBulkUpload: (formData: FormData, options?: WretchOptions, context?: IMediaUploadContext) => Promise<IResponseMultiple<IMedia>>;
209
227
  getAllMedia: (data?: import("./types").LevoQuery.FindQuery) => Promise<IResponseMultiple<IMedia>>;
@@ -266,6 +284,19 @@ export declare const defaultByKinds: Record<(typeof FieldKindList)[number], any>
266
284
  */
267
285
  export declare const defineLevoLoggerMiddleware: (name: string, callback: (core: ILevoControl, level: LogLevel, args: any[]) => void) => ILevoLoggerMiddleware;
268
286
 
287
+ export declare const documentFileExtensions: string[];
288
+
289
+ export declare const documentMimetype: {
290
+ "application/xml": string[];
291
+ "text/plain": string[];
292
+ "application/pdf": string[];
293
+ "application/msword": string[];
294
+ "application/vnd.ms-excel": string[];
295
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": string[];
296
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": string[];
297
+ "text/csv": string[];
298
+ };
299
+
269
300
  export declare type FieldFilter<T extends string = string> = Partial<Record<T, ComparableFilter<T> | FieldType>>;
270
301
 
271
302
  export declare const FieldInterfaces: Record<"TextWidget" | "CurrencyWidget" | "TextareaWidget" | "GeocoderWidget" | "MultiGeocoderWidget" | "DropdownWidget" | "ToggleCheckboxWidget" | "RadioWidget" | "NumberWidget" | "EmailWidget" | "PhoneWidget" | "URLWidget" | "DateWidget" | "TimeWidget" | "SwitchWidget" | "RichTextWidget" | "DateTimeWidget" | "CheckboxWidget" | "ImageUploadWidget" | "MultiImageUploadWidget" | "FileUploadWidget" | "MultiFileUploadWidget" | "MultiDropdownWidget" | "MultiTextWidget" | "CollectionWidget" | "ArrayWidget" | "RecordWidget" | "JSONWidget" | "SlugWidget", "TextWidget" | "CurrencyWidget" | "TextareaWidget" | "GeocoderWidget" | "MultiGeocoderWidget" | "DropdownWidget" | "ToggleCheckboxWidget" | "RadioWidget" | "NumberWidget" | "EmailWidget" | "PhoneWidget" | "URLWidget" | "DateWidget" | "TimeWidget" | "SwitchWidget" | "RichTextWidget" | "DateTimeWidget" | "CheckboxWidget" | "ImageUploadWidget" | "MultiImageUploadWidget" | "FileUploadWidget" | "MultiFileUploadWidget" | "MultiDropdownWidget" | "MultiTextWidget" | "CollectionWidget" | "ArrayWidget" | "RecordWidget" | "JSONWidget" | "SlugWidget">;
@@ -303,8 +334,6 @@ export declare type FieldType = string | number | Date | boolean | null;
303
334
 
304
335
  export declare type Filter<T extends string = string> = LogicalFilter<T> | FieldFilter<T>;
305
336
 
306
- export declare const formatImagePath: (string: string) => string;
307
-
308
337
  export declare const formatsByInterface: Record<(typeof FieldInterfacesList)[number], string[]>;
309
338
 
310
339
  export declare const FORUM_POST_KIND: {
@@ -1412,6 +1441,19 @@ export declare interface ILogicRule {
1412
1441
  when: LogicWhen;
1413
1442
  }
1414
1443
 
1444
+ export declare const imageFileExtensions: string[];
1445
+
1446
+ export declare const imageMimetype: {
1447
+ "image/jpeg": string[];
1448
+ "image/jpg": string[];
1449
+ "image/png": string[];
1450
+ "image/gif": string[];
1451
+ "image/svg": string[];
1452
+ "image/svg+xml": string[];
1453
+ "image/webp": string[];
1454
+ "image/avif": string[];
1455
+ };
1456
+
1415
1457
  export declare interface IMe {
1416
1458
  _id: string;
1417
1459
  public_id: string;
@@ -2225,8 +2267,6 @@ export declare namespace LevoQuery {
2225
2267
  }>;
2226
2268
  }
2227
2269
 
2228
- export declare const listToColumn: <T extends string>(columns: readonly string[]) => Record<T, string>;
2229
-
2230
2270
  export declare const listToRecord: <T extends string>(columns: readonly string[]) => { [K in T]: K; };
2231
2271
 
2232
2272
  export declare type LogicAction = "show" | "hide";
@@ -2284,10 +2324,14 @@ export declare enum LogLevel {
2284
2324
 
2285
2325
  export declare type Mandatory<T, K extends keyof T> = Prettify<Pick<T, K> & Partial<Omit<T, K>>>;
2286
2326
 
2327
+ export declare const mediaExtensionsByKind: Record<(typeof MediaKindList)[number], string[]>;
2328
+
2287
2329
  export declare const MediaKind: Record<"image" | "video" | "audio" | "document", "image" | "video" | "audio" | "document">;
2288
2330
 
2289
2331
  export declare const MediaKindList: readonly ["image", "video", "audio", "document"];
2290
2332
 
2333
+ export declare const mediaMimetypeByKind: Record<(typeof MediaKindList)[number], Record<string, string[]>>;
2334
+
2291
2335
  /** Reject types assignable to Error — forces `{ exception }` wrapping at the call site. */
2292
2336
  declare type NotError<T> = T extends Error ? never : T;
2293
2337
 
@@ -2305,6 +2349,14 @@ export declare type Prettify<T> = {
2305
2349
  */
2306
2350
  export declare const remoteLoggerMiddleware: (options: IRemoteLoggerMiddlewareOptions) => ILevoLoggerMiddleware;
2307
2351
 
2352
+ export declare const videoFileExtensions: string[];
2353
+
2354
+ export declare const videoMimetype: {
2355
+ "video/mp4": string[];
2356
+ "video/mpeg": string[];
2357
+ "video/webm": string[];
2358
+ };
2359
+
2308
2360
  export declare type WithinFilterType = {
2309
2361
  latitude: number;
2310
2362
  longitude: number;
package/dist/index.js CHANGED
@@ -296,21 +296,28 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
296
296
  getFilters: async (e, n = {}) => t.instance.url(`/v1/bevy/collection/${e}/get-filters`).options(n).get().json().then((e) => e).catch((e) => {
297
297
  throw g(e);
298
298
  })
299
- }), y = 600 * 1e3, b = (e, t) => ({
299
+ }), y = (e, t) => ({
300
+ getAllEvents: async (e, n = {}, r) => t.instance.url(`/v1/event/event/${e}/event/query`).query({ ...r?.params || {} }).options({ headers: { "Levo-Workspace": r?.workspace_id || void 0 } }).post(n).json().then((e) => e).catch((e) => {
301
+ throw g(e);
302
+ }),
303
+ getSingleEvent: async (e, n) => t.instance.url(`/v1/event/event/${e}/get-single-event`).query({ ...n?.params || {} }).options({ headers: { "Levo-Workspace": n?.workspace_id || void 0 } }).get().json().then((e) => e).catch((e) => {
304
+ throw g(e);
305
+ })
306
+ }), b = 600 * 1e3, x = (e, t) => ({
300
307
  mediaBulkUpload: async (e, n = {}, r) => {
301
308
  let i = { ...n };
302
- return delete i.signal, t.getInstance(y).url("/v1/assets/media/bulk").query(r ?? {}).options(i).post(e).json().then((e) => e).catch((e) => {
309
+ return delete i.signal, t.getInstance(b).url("/v1/assets/media/bulk").query(r ?? {}).options(i).post(e).json().then((e) => e).catch((e) => {
303
310
  throw g(e);
304
311
  });
305
312
  },
306
313
  getAllMedia: async (e = {}) => t.instance.url("/v1/assets/media/query").post(e).json().then((e) => e).catch((e) => {
307
314
  throw g(e);
308
315
  })
309
- }), x = [
316
+ }), S = [
310
317
  "google",
311
318
  "linkedin",
312
319
  "microsoft"
313
- ], S = (e, t) => {
320
+ ], C = (e, t) => {
314
321
  let n = async (n = {}) => t.instance.url("/v1/membership/auth/oauth/get-redirect-url").options(n).get().json().then((n) => {
315
322
  let r = n?.content?.data, i = Object.keys(r);
316
323
  if (typeof window < "u") for (let n of i) {
@@ -321,7 +328,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
321
328
  }
322
329
  }
323
330
  return r;
324
- }).catch(() => x.reduce((e, t) => (e[t] = null, e), {})), r = async (e = {}) => t.instance.url("/v1/membership/auth/sign-out").options(e).post("").json().then((e) => e?.content?.data).catch((e) => {
331
+ }).catch(() => S.reduce((e, t) => (e[t] = null, e), {})), r = async (e = {}) => t.instance.url("/v1/membership/auth/sign-out").options(e).post("").json().then((e) => e?.content?.data).catch((e) => {
325
332
  throw g(e);
326
333
  }), i = async (e = {}) => t.instance.url("/v1/membership/auth/get-me").options(e).get().json().then((e) => e?.content?.data).catch((e) => {
327
334
  throw g(e);
@@ -353,12 +360,12 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
353
360
  throw g(e);
354
361
  })
355
362
  };
356
- }, C = (e) => {
363
+ }, w = (e) => {
357
364
  let { pageContext: t = {
358
365
  url: typeof window < "u" ? window?.location?.href : "",
359
366
  referrer: typeof document < "u" ? document?.referrer : "",
360
367
  title: typeof document < "u" ? document?.title : ""
361
- }, loggerOptions: n = {}, ...r } = e, a = t, s = i(r), c = o(s, a), l = _(s, c), u = S(s, c), d = v(s, c), f = b(s, c), m = p(s, n);
368
+ }, loggerOptions: n = {}, ...r } = e, a = t, s = i(r), c = o(s, a), l = _(s, c), u = C(s, c), d = v(s, c), f = y(s, c), m = x(s, c), h = p(s, n);
362
369
  return {
363
370
  get apiUrl() {
364
371
  return s.apiUrl;
@@ -375,12 +382,15 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
375
382
  get collection() {
376
383
  return d;
377
384
  },
378
- get media() {
385
+ get event() {
379
386
  return f;
380
387
  },
381
- get logger() {
388
+ get media() {
382
389
  return m;
383
390
  },
391
+ get logger() {
392
+ return h;
393
+ },
384
394
  get fetch() {
385
395
  return c.instance;
386
396
  },
@@ -400,7 +410,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
400
410
  s.workspace = e;
401
411
  }
402
412
  };
403
- }, w = {
413
+ }, ee = {
404
414
  "public-id": "",
405
415
  string: "",
406
416
  number: null,
@@ -563,11 +573,87 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
563
573
  CollectionWidget: M.collection,
564
574
  JSONWidget: M.json
565
575
  }, P = [
576
+ "pdf",
577
+ "txt",
578
+ "xml",
579
+ "xls",
580
+ "xlsx",
581
+ "ods",
582
+ "odt",
583
+ "doc",
584
+ "docx",
585
+ "csv",
586
+ "odp",
587
+ "ppt",
588
+ "pptx"
589
+ ], F = [
590
+ "svg",
591
+ "png",
592
+ "jpg",
593
+ "jpeg",
594
+ "gif",
595
+ "webp",
596
+ "avif"
597
+ ], I = [
598
+ "mp4",
599
+ "ogv",
600
+ "webm"
601
+ ], L = [
602
+ "mp3",
603
+ "ogg",
604
+ "opus"
605
+ ], R = {
606
+ "application/xml": [".xml"],
607
+ "text/plain": [".txt"],
608
+ "application/pdf": [".pdf"],
609
+ "application/msword": [".doc"],
610
+ "application/vnd.ms-excel": [".xls"],
611
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
612
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [".docx"],
613
+ "text/csv": [".csv"]
614
+ }, z = {
615
+ "image/jpeg": [".jpeg", ".jpg"],
616
+ "image/jpg": [".jpg"],
617
+ "image/png": [".png"],
618
+ "image/gif": [".gif"],
619
+ "image/svg": [".svg"],
620
+ "image/svg+xml": [".svg"],
621
+ "image/webp": [".webp"],
622
+ "image/avif": [".avif"]
623
+ }, B = {
624
+ "video/mp4": [".mp4"],
625
+ "video/mpeg": [".mpeg"],
626
+ "video/webm": [".webm"]
627
+ }, V = {
628
+ "audio/mpeg": [".mp3"],
629
+ "audio/ogg": [".oga"],
630
+ "audio/opus": [".opus"]
631
+ }, H = {
632
+ audio: V,
633
+ document: R,
634
+ image: z,
635
+ video: B
636
+ }, U = {
637
+ audio: L,
638
+ document: P,
639
+ image: F,
640
+ video: I
641
+ }, W = [
642
+ ...U.audio,
643
+ ...U.document,
644
+ ...U.image,
645
+ ...U.video
646
+ ], G = {
647
+ ...H.audio,
648
+ ...H.document,
649
+ ...H.image,
650
+ ...H.video
651
+ }, K = [
566
652
  "image",
567
653
  "video",
568
654
  "audio",
569
655
  "document"
570
- ], F = P.reduce((e, t) => (e[t] = t, e), {}), I = (e) => e.reduce((e, t) => (e[t] = t, e), {}), L = (e) => e.reduce((e, t) => (e[t] = t, e), {}), R = [
656
+ ], q = K.reduce((e, t) => (e[t] = t, e), {}), J = (e) => e.reduce((e, t) => (e[t] = t, e), {}), Y = [
571
657
  "bevy.collection.filled",
572
658
  "bevy.collection.submitted",
573
659
  "bevy.collection.view",
@@ -593,7 +679,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
593
679
  "page.selection",
594
680
  "user.active",
595
681
  "user.idle"
596
- ], z = L(R), B = (e) => e.module_name ? "module" : e.allow_public_submit && !e.public_submit_set_by ? "form" : "collection", V = {
682
+ ], X = J(Y), Z = (e) => e.module_name ? "module" : e.allow_public_submit && !e.public_submit_set_by ? "form" : "collection", Q = {
597
683
  string: [
598
684
  "equals",
599
685
  "not",
@@ -660,31 +746,24 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
660
746
  identifier: ["equals", "not"],
661
747
  record: [],
662
748
  group: []
663
- }, H = {
749
+ }, te = {
664
750
  published: "published",
665
751
  unpublished: "unpublished",
666
752
  archived: "archived",
667
753
  flagged: "flagged",
668
754
  pending_moderation: "pending_moderation"
669
- }, U = {
755
+ }, $ = {
670
756
  post: "post",
671
757
  poll: "poll",
672
758
  gallery: "gallery",
673
759
  link: "link"
674
- }, W = Object.keys(U), G = {
760
+ }, ne = Object.keys($), re = {
675
761
  draft: "draft",
676
762
  published: "published",
677
763
  unpublished: "unpublished",
678
764
  archived: "archived",
679
765
  flagged: "flagged",
680
766
  pending_moderation: "pending_moderation"
681
- }, K = (e) => {
682
- let t = e.split("/"), n = t[t.length - 1];
683
- if (n) {
684
- let t = encodeURIComponent(n);
685
- return e.replace(n, t);
686
- }
687
- return "";
688
767
  };
689
768
  //#endregion
690
- export { z as AnalyticsEvents, R as AnalyticsEventsList, H as COMMENT_STATUS, k as CommonFieldIntefaces, E as CommonFieldInterfacesList, D as ComplexFieldInterfacesList, U as FORUM_POST_KIND, G as FORUM_POST_STATUS, A as FieldInterfaces, O as FieldInterfacesList, M as FieldKind, j as FieldKindList, W as ForumPostKindExpandedList, m as LevoError, x as LevoOAuthProviderList, d as LogLevel, F as MediaKind, P as MediaKindList, C as createLevoClient, p as createLevoLogger, w as defaultByKinds, f as defineLevoLoggerMiddleware, K as formatImagePath, T as formatsByInterface, B as getCollectionKind, g as getLevoError, N as interfaceKinds, I as listToColumn, L as listToRecord, V as operatorsByKind, u as remoteLoggerMiddleware };
769
+ export { X as AnalyticsEvents, Y as AnalyticsEventsList, te as COMMENT_STATUS, k as CommonFieldIntefaces, E as CommonFieldInterfacesList, D as ComplexFieldInterfacesList, $ as FORUM_POST_KIND, re as FORUM_POST_STATUS, A as FieldInterfaces, O as FieldInterfacesList, M as FieldKind, j as FieldKindList, ne as ForumPostKindExpandedList, m as LevoError, S as LevoOAuthProviderList, d as LogLevel, q as MediaKind, K as MediaKindList, W as allMediaFileExtensions, G as allMediaMimetypes, L as audioFileExtensions, V as audioMimetype, w as createLevoClient, p as createLevoLogger, ee as defaultByKinds, f as defineLevoLoggerMiddleware, P as documentFileExtensions, R as documentMimetype, T as formatsByInterface, Z as getCollectionKind, g as getLevoError, F as imageFileExtensions, z as imageMimetype, N as interfaceKinds, J as listToRecord, U as mediaExtensionsByKind, H as mediaMimetypeByKind, Q as operatorsByKind, u as remoteLoggerMiddleware, I as videoFileExtensions, B as videoMimetype };
package/package.json CHANGED
@@ -1,14 +1,12 @@
1
1
  {
2
2
  "name": "@levo-so/core",
3
3
  "description": "Levo common utilities",
4
- "version": "0.1.113",
4
+ "version": "0.2.1",
5
5
  "author": "Levo Engineering <devs@theinternetfolks.com>",
6
6
  "dependencies": {
7
- "lodash-es": "4.18.1",
8
7
  "wretch": "2.9.0"
9
8
  },
10
9
  "devDependencies": {
11
- "@types/lodash-es": "4.17.12",
12
10
  "typescript": "5.9.3",
13
11
  "vite": "8.0.8",
14
12
  "vite-plugin-dts": "4.5.4",