@levo-so/core 0.1.111 → 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;
@@ -191,15 +205,23 @@ export declare const createLevoClient: (options: ILevoClientOptions) => {
191
205
  data: any;
192
206
  options?: WretchOptions;
193
207
  }) => Promise<IResponseSingle<any>>;
194
- getCollectionContentList: ({ collection_key, page, search, limit, where, }: {
208
+ getCollectionContentList: ({ collection_key, page, search, limit, where, sort, select, include, }: {
195
209
  collection_key: string;
196
210
  } & import("./types").LevoQuery.FindQuery) => Promise<IResponseMultiple<Record<string, unknown>>>;
211
+ getCollectionContent: ({ collection_key, slug, }: {
212
+ collection_key: string;
213
+ slug: string;
214
+ }, options?: WretchOptions) => Promise<IResponseSingle<Record<string, unknown>>>;
197
215
  saveDraftEntry: (collection_key: string, data: any) => Promise<IResponseSingle<IDraftEntry>>;
198
216
  editDraftEntry: (collection_key: string, id: string, data: any) => Promise<IResponseSingle<IDraftEntry>>;
199
217
  getDraftEntry: (collection_key: string) => Promise<IResponseMultiple<IDraftEntry>>;
200
218
  submitDraftEntry: (collection_key: string, data: any) => Promise<IResponseSingle<IDraftEntry>>;
201
219
  getFilters: (collectionId: string, options?: WretchOptions) => Promise<IResponseMultiple<ILemaCollection["sections"][number]["fields"][number]>>;
202
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
+ };
203
225
  readonly media: {
204
226
  mediaBulkUpload: (formData: FormData, options?: WretchOptions, context?: IMediaUploadContext) => Promise<IResponseMultiple<IMedia>>;
205
227
  getAllMedia: (data?: import("./types").LevoQuery.FindQuery) => Promise<IResponseMultiple<IMedia>>;
@@ -262,6 +284,19 @@ export declare const defaultByKinds: Record<(typeof FieldKindList)[number], any>
262
284
  */
263
285
  export declare const defineLevoLoggerMiddleware: (name: string, callback: (core: ILevoControl, level: LogLevel, args: any[]) => void) => ILevoLoggerMiddleware;
264
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
+
265
300
  export declare type FieldFilter<T extends string = string> = Partial<Record<T, ComparableFilter<T> | FieldType>>;
266
301
 
267
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">;
@@ -299,8 +334,6 @@ export declare type FieldType = string | number | Date | boolean | null;
299
334
 
300
335
  export declare type Filter<T extends string = string> = LogicalFilter<T> | FieldFilter<T>;
301
336
 
302
- export declare const formatImagePath: (string: string) => string;
303
-
304
337
  export declare const formatsByInterface: Record<(typeof FieldInterfacesList)[number], string[]>;
305
338
 
306
339
  export declare const FORUM_POST_KIND: {
@@ -1408,6 +1441,19 @@ export declare interface ILogicRule {
1408
1441
  when: LogicWhen;
1409
1442
  }
1410
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
+
1411
1457
  export declare interface IMe {
1412
1458
  _id: string;
1413
1459
  public_id: string;
@@ -1927,6 +1973,7 @@ export declare namespace LevoEvent {
1927
1973
  location: IGeocoderLocation | null;
1928
1974
  is_location_public?: boolean;
1929
1975
  is_url_public?: boolean;
1976
+ is_attendee_listing_public?: boolean;
1930
1977
  starts_at?: string | null;
1931
1978
  ends_at?: string | null;
1932
1979
  cadence: string;
@@ -2220,8 +2267,6 @@ export declare namespace LevoQuery {
2220
2267
  }>;
2221
2268
  }
2222
2269
 
2223
- export declare const listToColumn: <T extends string>(columns: readonly string[]) => Record<T, string>;
2224
-
2225
2270
  export declare const listToRecord: <T extends string>(columns: readonly string[]) => { [K in T]: K; };
2226
2271
 
2227
2272
  export declare type LogicAction = "show" | "hide";
@@ -2279,10 +2324,14 @@ export declare enum LogLevel {
2279
2324
 
2280
2325
  export declare type Mandatory<T, K extends keyof T> = Prettify<Pick<T, K> & Partial<Omit<T, K>>>;
2281
2326
 
2327
+ export declare const mediaExtensionsByKind: Record<(typeof MediaKindList)[number], string[]>;
2328
+
2282
2329
  export declare const MediaKind: Record<"image" | "video" | "audio" | "document", "image" | "video" | "audio" | "document">;
2283
2330
 
2284
2331
  export declare const MediaKindList: readonly ["image", "video", "audio", "document"];
2285
2332
 
2333
+ export declare const mediaMimetypeByKind: Record<(typeof MediaKindList)[number], Record<string, string[]>>;
2334
+
2286
2335
  /** Reject types assignable to Error — forces `{ exception }` wrapping at the call site. */
2287
2336
  declare type NotError<T> = T extends Error ? never : T;
2288
2337
 
@@ -2300,6 +2349,14 @@ export declare type Prettify<T> = {
2300
2349
  */
2301
2350
  export declare const remoteLoggerMiddleware: (options: IRemoteLoggerMiddlewareOptions) => ILevoLoggerMiddleware;
2302
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
+
2303
2360
  export declare type WithinFilterType = {
2304
2361
  latitude: number;
2305
2362
  longitude: number;
package/dist/index.js CHANGED
@@ -267,14 +267,20 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
267
267
  saveCollectionData: async ({ collection_id: e, data: n, options: r = {} }) => t.instance.url(`/v1/bevy/content/${e}`).options(r).post(n).json().then((e) => e).catch((e) => {
268
268
  throw g(e);
269
269
  }),
270
- getCollectionContentList: async ({ collection_key: e, page: n, search: r, limit: i = 10, where: a }) => t.instance.url(`/v1/bevy/content/${e}/query`).post({
270
+ getCollectionContentList: async ({ collection_key: e, page: n, search: r, limit: i = 10, where: a, sort: o, select: s, include: c }) => t.instance.url(`/v1/bevy/content/${e}/query`).post({
271
271
  page: n,
272
272
  limit: i,
273
273
  search: r,
274
- where: a
274
+ where: a,
275
+ sort: o,
276
+ select: s,
277
+ include: c
275
278
  }).json().then((e) => e).catch((e) => {
276
279
  throw g(e);
277
280
  }),
281
+ getCollectionContent: async ({ collection_key: e, slug: n }, r = {}) => t.instance.url(`/v1/bevy/content/${e}/${n}`).options(r).get().json().then((e) => e).catch((e) => {
282
+ throw g(e);
283
+ }),
278
284
  saveDraftEntry: async (e, n) => t.instance.url(`/v1/bevy/content/${e}/save-entry`).post(n).json().then((e) => e).catch((e) => {
279
285
  throw g(e);
280
286
  }),
@@ -290,21 +296,28 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
290
296
  getFilters: async (e, n = {}) => t.instance.url(`/v1/bevy/collection/${e}/get-filters`).options(n).get().json().then((e) => e).catch((e) => {
291
297
  throw g(e);
292
298
  })
293
- }), 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) => ({
294
307
  mediaBulkUpload: async (e, n = {}, r) => {
295
308
  let i = { ...n };
296
- 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) => {
297
310
  throw g(e);
298
311
  });
299
312
  },
300
313
  getAllMedia: async (e = {}) => t.instance.url("/v1/assets/media/query").post(e).json().then((e) => e).catch((e) => {
301
314
  throw g(e);
302
315
  })
303
- }), x = [
316
+ }), S = [
304
317
  "google",
305
318
  "linkedin",
306
319
  "microsoft"
307
- ], S = (e, t) => {
320
+ ], C = (e, t) => {
308
321
  let n = async (n = {}) => t.instance.url("/v1/membership/auth/oauth/get-redirect-url").options(n).get().json().then((n) => {
309
322
  let r = n?.content?.data, i = Object.keys(r);
310
323
  if (typeof window < "u") for (let n of i) {
@@ -315,7 +328,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
315
328
  }
316
329
  }
317
330
  return r;
318
- }).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) => {
319
332
  throw g(e);
320
333
  }), i = async (e = {}) => t.instance.url("/v1/membership/auth/get-me").options(e).get().json().then((e) => e?.content?.data).catch((e) => {
321
334
  throw g(e);
@@ -347,12 +360,12 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
347
360
  throw g(e);
348
361
  })
349
362
  };
350
- }, C = (e) => {
363
+ }, w = (e) => {
351
364
  let { pageContext: t = {
352
365
  url: typeof window < "u" ? window?.location?.href : "",
353
366
  referrer: typeof document < "u" ? document?.referrer : "",
354
367
  title: typeof document < "u" ? document?.title : ""
355
- }, 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);
356
369
  return {
357
370
  get apiUrl() {
358
371
  return s.apiUrl;
@@ -369,12 +382,15 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
369
382
  get collection() {
370
383
  return d;
371
384
  },
372
- get media() {
385
+ get event() {
373
386
  return f;
374
387
  },
375
- get logger() {
388
+ get media() {
376
389
  return m;
377
390
  },
391
+ get logger() {
392
+ return h;
393
+ },
378
394
  get fetch() {
379
395
  return c.instance;
380
396
  },
@@ -394,7 +410,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
394
410
  s.workspace = e;
395
411
  }
396
412
  };
397
- }, w = {
413
+ }, ee = {
398
414
  "public-id": "",
399
415
  string: "",
400
416
  number: null,
@@ -557,11 +573,87 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
557
573
  CollectionWidget: M.collection,
558
574
  JSONWidget: M.json
559
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 = [
560
652
  "image",
561
653
  "video",
562
654
  "audio",
563
655
  "document"
564
- ], 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 = [
565
657
  "bevy.collection.filled",
566
658
  "bevy.collection.submitted",
567
659
  "bevy.collection.view",
@@ -587,7 +679,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
587
679
  "page.selection",
588
680
  "user.active",
589
681
  "user.idle"
590
- ], 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 = {
591
683
  string: [
592
684
  "equals",
593
685
  "not",
@@ -654,31 +746,24 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
654
746
  identifier: ["equals", "not"],
655
747
  record: [],
656
748
  group: []
657
- }, H = {
749
+ }, te = {
658
750
  published: "published",
659
751
  unpublished: "unpublished",
660
752
  archived: "archived",
661
753
  flagged: "flagged",
662
754
  pending_moderation: "pending_moderation"
663
- }, U = {
755
+ }, $ = {
664
756
  post: "post",
665
757
  poll: "poll",
666
758
  gallery: "gallery",
667
759
  link: "link"
668
- }, W = Object.keys(U), G = {
760
+ }, ne = Object.keys($), re = {
669
761
  draft: "draft",
670
762
  published: "published",
671
763
  unpublished: "unpublished",
672
764
  archived: "archived",
673
765
  flagged: "flagged",
674
766
  pending_moderation: "pending_moderation"
675
- }, K = (e) => {
676
- let t = e.split("/"), n = t[t.length - 1];
677
- if (n) {
678
- let t = encodeURIComponent(n);
679
- return e.replace(n, t);
680
- }
681
- return "";
682
767
  };
683
768
  //#endregion
684
- 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.111",
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",