@levo-so/core 0.3.19 → 0.3.21

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/index.d.ts CHANGED
@@ -197,7 +197,7 @@ export declare const createLevoClient: (options: ILevoClientOptions) => {
197
197
  signUpWithPassword: <T = import("./types").ILevoMembership.Account>(data: import("./types").ILevoMembership.Request.SignUpWithPassword, options?: WretchOptions) => Promise<T>;
198
198
  };
199
199
  readonly collection: {
200
- getAllCollections: (data?: import("./types").LevoQuery.FindQuery<"name" | "workspace_id" | "created_at" | "id" | "kind" | "description" | "updated_at" | "icon" | "key" | "readonly" | "hidden" | "on_submit" | "on_update" | "module_name" | "allow_public_submit" | "public_submit_set_by" | "sections" | "views" | "title_field" | "email_field" | "mobile_field" | "settings" | "allow_draft" | "allow_multiple" | "allow_public_view" | "public_view_set_by" | "public_view_set_by_account" | "public_submit_set_by_account" | "entry_count">, options?: WretchOptions) => Promise<IResponseMultiple<ILemaCollection>>;
200
+ getAllCollections: (data?: import("./types").LevoQuery.FindQuery<"name" | "workspace_id" | "created_at" | "id" | "kind" | "description" | "updated_at" | "icon" | "hidden" | "key" | "readonly" | "on_submit" | "on_update" | "module_name" | "allow_public_submit" | "public_submit_set_by" | "sections" | "views" | "title_field" | "email_field" | "mobile_field" | "settings" | "allow_draft" | "allow_multiple" | "allow_public_view" | "public_view_set_by" | "public_view_set_by_account" | "public_submit_set_by_account" | "entry_count">, options?: WretchOptions) => Promise<IResponseMultiple<ILemaCollection>>;
201
201
  getCollectionByIDExpanded: <T = ILemaCollection>(id: string, options?: WretchOptions) => Promise<IResponseSingle<T>>;
202
202
  createCollection: (data: ILemaCollection) => Promise<IResponseSingle<ILemaCollection>>;
203
203
  saveCollectionData: ({ collection_id, data, options, }: {
@@ -276,6 +276,13 @@ export declare type DeepPartial<T> = {
276
276
  [P in keyof T]?: T[P] extends object ? DeepPartial<T[P]> : T[P];
277
277
  };
278
278
 
279
+ /**
280
+ * Form rules for an event saved before registration_fields existed, and for older APIs
281
+ * that send none: name + email only. Email stays required — it is how the guest gets
282
+ * their confirmation.
283
+ */
284
+ export declare const DEFAULT_REGISTRATION_FIELDS: LevoEvent.RegistrationFields;
285
+
279
286
  export declare const defaultByKinds: Record<(typeof FieldKindList)[number], any>;
280
287
 
281
288
  /**
@@ -1888,6 +1895,14 @@ export declare interface INotificationData {
1888
1895
  body?: string;
1889
1896
  subject?: string;
1890
1897
  richtext?: string;
1898
+ /**
1899
+ * Puck email-builder tree for the richtext template — present when the
1900
+ * notification was authored with the visual builder. `richtext` above
1901
+ * holds the frontend-rendered HTML for the current bevy send path; this
1902
+ * holds the tree so the design round-trips on edit and so bevy can
1903
+ * render it server-side (like campaigns) once it adopts that renderer.
1904
+ */
1905
+ puck_data?: IPuckEmailData;
1891
1906
  };
1892
1907
  };
1893
1908
  }
@@ -2083,6 +2098,20 @@ export declare interface IPostStaffAccount {
2083
2098
  last_access_at?: string | null;
2084
2099
  }
2085
2100
 
2101
+ /**
2102
+ * Serialized Puck email-builder tree — the same `dnd_editor:v1` format campaign
2103
+ * emails store in their `content` field. Typed structurally here to avoid a
2104
+ * core → `@levo/email-builder` dependency; the dashboard casts to
2105
+ * `IEmailBuilderData` at the boundary.
2106
+ */
2107
+ export declare interface IPuckEmailData {
2108
+ root: {
2109
+ props?: Record<string, unknown>;
2110
+ };
2111
+ content: Array<Record<string, unknown>>;
2112
+ zones?: Record<string, unknown>;
2113
+ }
2114
+
2086
2115
  export declare interface IRemoteLoggerMiddlewareOptions {
2087
2116
  /** URL of the log ingestion API */
2088
2117
  logApiUrl: string;
@@ -2333,6 +2362,19 @@ export declare class LevoError extends Error {
2333
2362
  }
2334
2363
 
2335
2364
  export declare namespace LevoEvent {
2365
+ /** Built-in attendee fields the registration form can ask for. */
2366
+ export type RegistrationFieldKey = "email" | "mobile" | "organization" | "designation";
2367
+ /** How a form field behaves: hidden, shown and skippable, or shown and mandatory. */
2368
+ export type FieldCollection = "off" | "optional" | "required";
2369
+ /**
2370
+ * Per-field form rules, e.g. { email: "required", mobile: "optional", ... }. Defaults live
2371
+ * in `DEFAULT_REGISTRATION_FIELDS`.
2372
+ *
2373
+ * The API is the authority on a phone's format (`isMobilePhone`). The forms only pre-check
2374
+ * it, and not identically: studio uses libphonenumber's per-country rules, while
2375
+ * site-runtime counts digits — frozen v3 sites can't resolve libphonenumber.
2376
+ */
2377
+ export type RegistrationFields = Record<RegistrationFieldKey, FieldCollection>;
2336
2378
  export interface Root {
2337
2379
  _id: string;
2338
2380
  cover_image: IMediaObject | null;
@@ -2354,6 +2396,11 @@ export declare namespace LevoEvent {
2354
2396
  status: "draft" | "canceled" | "published";
2355
2397
  accept_registration: boolean;
2356
2398
  one_attendee_per_account: boolean;
2399
+ /**
2400
+ * The organizer's saved form setting, as stored. May be partial or missing on older
2401
+ * events — forms should read the resolved `Ticket.Root.registration_fields` instead.
2402
+ */
2403
+ registration_fields?: Partial<RegistrationFields>;
2357
2404
  max_capacity: number;
2358
2405
  /** Registered attendees, returned by the list/read endpoints — no extra call needed. */
2359
2406
  attendee_count?: number;
@@ -2382,6 +2429,15 @@ export declare namespace LevoEvent {
2382
2429
  percentage: number;
2383
2430
  country_code: string;
2384
2431
  }
2432
+ /** One pre-calculated tax row on a priced ticket or a validated coupon. */
2433
+ export interface TaxLine {
2434
+ id?: string;
2435
+ _id?: string;
2436
+ label: string;
2437
+ percentage: number;
2438
+ /** In minor units. */
2439
+ amount: number;
2440
+ }
2385
2441
  export interface Root {
2386
2442
  _id: string;
2387
2443
  event: string;
@@ -2409,11 +2465,33 @@ export declare namespace LevoEvent {
2409
2465
  created_by: string;
2410
2466
  updated_at: Date | string;
2411
2467
  updated_by: string;
2468
+ /**
2469
+ * Which fields the register form shows and requires for this ticket, computed by the
2470
+ * ticket list: the event's registration_fields with rules the organizer can't turn off
2471
+ * (email always required; mobile required on a paid ticket when the workspace pays
2472
+ * through Cashfree). Every form reads this. Absent on older APIs.
2473
+ */
2474
+ registration_fields?: RegistrationFields;
2412
2475
  tax_enabled?: boolean;
2413
2476
  tax_inclusive?: boolean;
2414
2477
  taxes?: Tax[] | string[];
2415
2478
  }
2416
2479
  export type Create = Pick<Root, "title" | "description" | "quantity" | "starts_at" | "ends_at" | "waitlist_enabled" | "hidden" | "enforce_max_quantity" | "offerings" | "coupons"> & Partial<Pick<Root, "currency" | "unit_amount" | "base_price">>;
2480
+ /**
2481
+ * A ticket as the public ticket query returns it when taxes apply: the price is broken
2482
+ * down server-side, so no client computes tax. `taxes` are line items here, not the Tax
2483
+ * references `Root` carries.
2484
+ */
2485
+ export interface WithTaxBreakdown extends Omit<Root, "taxes"> {
2486
+ /** Price before tax (back-calculated when the price is tax-inclusive). */
2487
+ subtotal: number;
2488
+ tax_amount: number;
2489
+ /** Final payable, in minor units. */
2490
+ total: number;
2491
+ taxes: TaxLine[];
2492
+ tax_inclusive: boolean;
2493
+ tax_enabled: boolean;
2494
+ }
2417
2495
  }
2418
2496
  export namespace Coupon {
2419
2497
  export interface Root {
@@ -2453,6 +2531,13 @@ export declare namespace LevoEvent {
2453
2531
  sale_amount: number;
2454
2532
  discountable_amount: number;
2455
2533
  discount: number;
2534
+ /** Tax breakdown after the discount — present when the ticket is taxed. */
2535
+ taxable_amount?: number;
2536
+ taxes?: Ticket.TaxLine[];
2537
+ tax_amount?: number;
2538
+ tax_inclusive?: boolean;
2539
+ /** Final payable, in minor units. Newer APIs send it; older ones only `sale_amount`. */
2540
+ total_amount?: number;
2456
2541
  };
2457
2542
  }
2458
2543
  export namespace Offering {
@@ -2622,6 +2707,36 @@ export declare namespace LevoEvent {
2622
2707
 
2623
2708
  export declare const LevoOAuthProviderList: readonly ["google", "linkedin", "microsoft"];
2624
2709
 
2710
+ /** Checkout contracts shared by every flow that takes a payment (events, collection bookings). */
2711
+ export declare namespace LevoPayment {
2712
+ export type Provider = "razorpay" | "stripe" | "cashfree";
2713
+ /**
2714
+ * The `meta` a booking endpoint returns when payment is owed — create-new-booking and
2715
+ * retry-payment for events, `/payment/booking/:id/pay` for collection bookings. Which of the
2716
+ * provider fields are set depends on `provider`.
2717
+ */
2718
+ export interface CheckoutMeta {
2719
+ /** Provider publishable key. No key means nothing is owed. */
2720
+ key: string;
2721
+ /** Absent on older APIs, which only spoke Razorpay. */
2722
+ provider?: Provider;
2723
+ currency?: string;
2724
+ /** In minor units. */
2725
+ amount?: number;
2726
+ reference_id?: string;
2727
+ /** Razorpay and Cashfree order id — Cashfree's confirm call sends only this back. */
2728
+ order_id?: string;
2729
+ /** Stripe Checkout Session id, sent back to confirm. */
2730
+ session_id?: string;
2731
+ /** Stripe Checkout Session secret, for embedded mode. */
2732
+ client_secret?: string;
2733
+ /** Cashfree payment session — opens the Cashfree popup. */
2734
+ payment_session_id?: string;
2735
+ /** Cashfree mode, derived by the API from the workspace's Secret Key. */
2736
+ environment?: "sandbox" | "production";
2737
+ }
2738
+ }
2739
+
2625
2740
  export declare namespace LevoQuery {
2626
2741
  export type Select<Fields extends string = string> = Partial<Record<Fields, boolean | {
2627
2742
  select: Record<string, boolean>;
package/dist/index.js CHANGED
@@ -31,16 +31,17 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
31
31
  let i = e(n.apiUrl).addon(t), o = (e = a) => {
32
32
  let t = {
33
33
  credentials: "include",
34
- signal: AbortSignal.timeout(e),
35
34
  headers: {}
36
35
  };
37
- return n.workspace && (t.headers = {
36
+ n.workspace && (t.headers = {
38
37
  ...t?.headers || {},
39
38
  "Levo-Workspace": n.workspace
40
39
  }), r && typeof r == "object" && Object.keys(r).length > 0 && (t.headers = {
41
40
  ...t?.headers || {},
42
41
  "Levo-Page-Context": encodeURIComponent(JSON.stringify(r))
43
- }), n.workspace ? i.options(t).query({ workspace: n.workspace }) : i.options(t);
42
+ });
43
+ let o = i.defer((t) => t.options({ signal: AbortSignal.timeout(e) }));
44
+ return n.workspace ? o.options(t).query({ workspace: n.workspace }) : o.options(t);
44
45
  };
45
46
  return {
46
47
  get instance() {
@@ -132,7 +133,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
132
133
  name: e,
133
134
  callback: t
134
135
  }), p = (e, t = {}) => {
135
- let { level: n = e.NODE_ENV === "development" ? d.debug : d.warn } = t, r = /* @__PURE__ */ new Map(), i = (e) => (r.set(e.name, e), () => {
136
+ let { level: n = e.NODE_ENV === "development" ? 0 : 2 } = t, r = /* @__PURE__ */ new Map(), i = (e) => (r.set(e.name, e), () => {
136
137
  r.delete(e.name);
137
138
  }), a = (t, i) => {
138
139
  let a = Array.isArray(i) ? i : [i];
@@ -149,15 +150,14 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
149
150
  console.log(...a);
150
151
  }
151
152
  }, o = (...e) => {
152
- a(d.debug, e);
153
+ a(0, e);
153
154
  }, s = (...e) => {
154
- a(d.info, e);
155
+ a(1, e);
155
156
  }, c = (...e) => {
156
- a(d.warn, e);
157
+ a(2, e);
157
158
  };
158
159
  function l(e, t) {
159
- let n = t === void 0 ? [e] : [e, t];
160
- a(d.error, n);
160
+ a(3, t === void 0 ? [e] : [e, t]);
161
161
  }
162
162
  return {
163
163
  debug: o,
@@ -317,7 +317,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
317
317
  "google",
318
318
  "linkedin",
319
319
  "microsoft"
320
- ], S = (e, t) => {
320
+ ], te = (e, t) => {
321
321
  let n = async (n = {}) => t.instance.url("/v1/membership/auth/oauth/get-redirect-url").options(n).get().json().then((n) => {
322
322
  let r = n?.content?.data, i = Object.keys(r);
323
323
  if (typeof window < "u") for (let n of i) {
@@ -360,12 +360,12 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
360
360
  throw g(e);
361
361
  })
362
362
  };
363
- }, C = (e) => {
363
+ }, S = (e) => {
364
364
  let { pageContext: t = {
365
365
  url: typeof window < "u" ? window?.location?.href : "",
366
366
  referrer: typeof document < "u" ? document?.referrer : "",
367
367
  title: typeof document < "u" ? document?.title : ""
368
- }, 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 = y(s, c), m = b(s, c), h = p(s, n);
368
+ }, loggerOptions: n = {}, ...r } = e, a = t, s = i(r), c = o(s, a), l = _(s, c), u = te(s, c), d = v(s, c), f = y(s, c), m = b(s, c), h = p(s, n);
369
369
  return {
370
370
  get apiUrl() {
371
371
  return s.apiUrl;
@@ -410,7 +410,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
410
410
  s.workspace = e;
411
411
  }
412
412
  };
413
- }, te = {
413
+ }, C = {
414
414
  "public-id": "",
415
415
  string: "",
416
416
  number: null,
@@ -572,7 +572,12 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
572
572
  MultiGeocoderWidget: j["array-location"],
573
573
  CollectionWidget: j.collection,
574
574
  JSONWidget: j.json
575
- }, N = [
575
+ }, N = {
576
+ email: "required",
577
+ mobile: "off",
578
+ organization: "off",
579
+ designation: "off"
580
+ }, P = [
576
581
  "pdf",
577
582
  "txt",
578
583
  "xml",
@@ -586,7 +591,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
586
591
  "odp",
587
592
  "ppt",
588
593
  "pptx"
589
- ], P = [
594
+ ], F = [
590
595
  "svg",
591
596
  "png",
592
597
  "jpg",
@@ -594,15 +599,15 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
594
599
  "gif",
595
600
  "webp",
596
601
  "avif"
597
- ], F = [
602
+ ], I = [
598
603
  "mp4",
599
604
  "ogv",
600
605
  "webm"
601
- ], I = [
606
+ ], L = [
602
607
  "mp3",
603
608
  "ogg",
604
609
  "opus"
605
- ], L = {
610
+ ], R = {
606
611
  "application/xml": [".xml"],
607
612
  "text/plain": [".txt"],
608
613
  "application/pdf": [".pdf"],
@@ -611,7 +616,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
611
616
  "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
612
617
  "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [".docx"],
613
618
  "text/csv": [".csv"]
614
- }, R = {
619
+ }, z = {
615
620
  "image/jpeg": [".jpeg", ".jpg"],
616
621
  "image/jpg": [".jpg"],
617
622
  "image/png": [".png"],
@@ -620,40 +625,40 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
620
625
  "image/svg+xml": [".svg"],
621
626
  "image/webp": [".webp"],
622
627
  "image/avif": [".avif"]
623
- }, z = {
628
+ }, B = {
624
629
  "video/mp4": [".mp4"],
625
630
  "video/mpeg": [".mpeg"],
626
631
  "video/webm": [".webm"]
627
- }, B = {
632
+ }, V = {
628
633
  "audio/mpeg": [".mp3"],
629
634
  "audio/ogg": [".oga"],
630
635
  "audio/opus": [".opus"]
631
- }, V = {
632
- audio: B,
633
- document: L,
634
- image: R,
635
- video: z
636
636
  }, H = {
637
- audio: I,
638
- document: N,
639
- image: P,
640
- video: F
641
- }, U = [
637
+ audio: V,
638
+ document: R,
639
+ image: z,
640
+ video: B
641
+ }, U = {
642
+ audio: L,
643
+ document: P,
644
+ image: F,
645
+ video: I
646
+ }, W = [
647
+ ...U.audio,
648
+ ...U.document,
649
+ ...U.image,
650
+ ...U.video
651
+ ], G = {
642
652
  ...H.audio,
643
653
  ...H.document,
644
654
  ...H.image,
645
655
  ...H.video
646
- ], W = {
647
- ...V.audio,
648
- ...V.document,
649
- ...V.image,
650
- ...V.video
651
- }, G = [
656
+ }, K = [
652
657
  "image",
653
658
  "video",
654
659
  "audio",
655
660
  "document"
656
- ], K = G.reduce((e, t) => (e[t] = t, e), {}), q = (e) => e.reduce((e, t) => (e[t] = t, e), {}), J = [
661
+ ], q = K.reduce((e, t) => (e[t] = t, e), {}), J = (e) => e.reduce((e, t) => (e[t] = t, e), {}), Y = [
657
662
  "bevy.collection.filled",
658
663
  "bevy.collection.submitted",
659
664
  "bevy.collection.view",
@@ -679,7 +684,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
679
684
  "page.selection",
680
685
  "user.active",
681
686
  "user.idle"
682
- ], Y = q(J), X = (e) => e.kind === "ai_fill", Z = (e) => e.kind !== "ai_fill", ne = (e) => e.module_name ? "module" : e.allow_public_submit && !e.public_submit_set_by ? "form" : "collection", Q = {
687
+ ], X = J(Y), Z = (e) => e.kind === "ai_fill", ne = (e) => e.kind !== "ai_fill", Q = (e) => e.module_name ? "module" : e.allow_public_submit && !e.public_submit_set_by ? "form" : "collection", re = {
683
688
  string: [
684
689
  "equals",
685
690
  "not",
@@ -746,7 +751,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
746
751
  identifier: ["equals", "not"],
747
752
  record: [],
748
753
  group: []
749
- }, re = {
754
+ }, ie = {
750
755
  published: "published",
751
756
  unpublished: "unpublished",
752
757
  archived: "archived",
@@ -757,7 +762,7 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
757
762
  poll: "poll",
758
763
  gallery: "gallery",
759
764
  link: "link"
760
- }, ie = Object.keys($), ae = {
765
+ }, ae = Object.keys($), oe = {
761
766
  draft: "draft",
762
767
  published: "published",
763
768
  unpublished: "unpublished",
@@ -766,4 +771,4 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
766
771
  pending_moderation: "pending_moderation"
767
772
  };
768
773
  //#endregion
769
- export { Y as AnalyticsEvents, J as AnalyticsEventsList, re as COMMENT_STATUS, O as CommonFieldIntefaces, T as CommonFieldInterfacesList, E as ComplexFieldInterfacesList, $ as FORUM_POST_KIND, ae as FORUM_POST_STATUS, k as FieldInterfaces, D as FieldInterfacesList, j as FieldKind, A as FieldKindList, ie as ForumPostKindExpandedList, m as LevoError, x as LevoOAuthProviderList, d as LogLevel, K as MediaKind, G as MediaKindList, U as allMediaFileExtensions, W as allMediaMimetypes, I as audioFileExtensions, B as audioMimetype, C as createLevoClient, p as createLevoLogger, te as defaultByKinds, f as defineLevoLoggerMiddleware, N as documentFileExtensions, L as documentMimetype, w as formatsByInterface, ne as getCollectionKind, g as getLevoError, P as imageFileExtensions, R as imageMimetype, M as interfaceKinds, X as isAiFillEffect, Z as isNotificationEffect, q as listToRecord, H as mediaExtensionsByKind, V as mediaMimetypeByKind, Q as operatorsByKind, u as remoteLoggerMiddleware, F as videoFileExtensions, z as videoMimetype };
774
+ export { X as AnalyticsEvents, Y as AnalyticsEventsList, ie as COMMENT_STATUS, O as CommonFieldIntefaces, T as CommonFieldInterfacesList, E as ComplexFieldInterfacesList, N as DEFAULT_REGISTRATION_FIELDS, $ as FORUM_POST_KIND, oe as FORUM_POST_STATUS, k as FieldInterfaces, D as FieldInterfacesList, j as FieldKind, A as FieldKindList, ae as ForumPostKindExpandedList, m as LevoError, x as LevoOAuthProviderList, d as LogLevel, q as MediaKind, K as MediaKindList, W as allMediaFileExtensions, G as allMediaMimetypes, L as audioFileExtensions, V as audioMimetype, S as createLevoClient, p as createLevoLogger, C as defaultByKinds, f as defineLevoLoggerMiddleware, P as documentFileExtensions, R as documentMimetype, w as formatsByInterface, Q as getCollectionKind, g as getLevoError, F as imageFileExtensions, z as imageMimetype, M as interfaceKinds, Z as isAiFillEffect, ne as isNotificationEffect, J as listToRecord, U as mediaExtensionsByKind, H as mediaMimetypeByKind, re as operatorsByKind, u as remoteLoggerMiddleware, I as videoFileExtensions, B as videoMimetype };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@levo-so/core",
3
3
  "description": "Levo common utilities",
4
- "version": "0.3.19",
4
+ "version": "0.3.21",
5
5
  "author": "Levo Engineering <devs@theinternetfolks.com>",
6
6
  "dependencies": {
7
7
  "wretch": "2.9.0"
@@ -9,7 +9,7 @@
9
9
  "devDependencies": {
10
10
  "@levo/ts-config": "0.0.0",
11
11
  "typescript": "5.9.3",
12
- "vite": "8.0.8",
12
+ "vite": "8.0.16",
13
13
  "vite-plugin-dts": "4.5.4"
14
14
  },
15
15
  "exports": {