@levo-so/core 0.1.105 → 0.1.108

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
@@ -268,6 +268,8 @@ export declare const FieldInterfaces: Record<"TextWidget" | "CurrencyWidget" | "
268
268
 
269
269
  export declare const FieldInterfacesList: readonly ["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"];
270
270
 
271
+ export declare type FieldKind = (typeof FieldKindList)[number];
272
+
271
273
  export declare const FieldKind: {
272
274
  identifier: "identifier";
273
275
  collection: "collection";
@@ -1080,6 +1082,7 @@ export declare type ILemaField = Mandatory<Omit<IField, "fields" | "options">, "
1080
1082
  allow_public_view?: boolean;
1081
1083
  /** Whether this field accepts public submissions. */
1082
1084
  allow_public_submit?: boolean;
1085
+ logic?: ILogicRule[];
1083
1086
  };
1084
1087
 
1085
1088
  /**
@@ -1146,6 +1149,7 @@ export declare type ILemaRelationOnDelete = "CASCADE" | "SET_NULL" | "RESTRICT";
1146
1149
  export declare interface ILemaSection extends Omit<ISection, "fields"> {
1147
1150
  /** Fields contained within this section. */
1148
1151
  fields: ILemaField[];
1152
+ logic?: ILogicRule[];
1149
1153
  }
1150
1154
 
1151
1155
  export declare namespace ILevoAudience {
@@ -1417,6 +1421,12 @@ export declare interface ILoggerOptions {
1417
1421
  level?: LogLevel;
1418
1422
  }
1419
1423
 
1424
+ export declare interface ILogicRule {
1425
+ /** Undefined means the rule has been created but no action picked yet — engine treats it as a no-op. */
1426
+ action?: LogicAction;
1427
+ when: LogicWhen;
1428
+ }
1429
+
1420
1430
  export declare interface IMe {
1421
1431
  _id: string;
1422
1432
  public_id: string;
@@ -2229,6 +2239,8 @@ export declare const listToColumn: <T extends string>(columns: readonly string[]
2229
2239
 
2230
2240
  export declare const listToRecord: <T extends string>(columns: readonly string[]) => { [K in T]: K; };
2231
2241
 
2242
+ export declare type LogicAction = "show" | "hide";
2243
+
2232
2244
  export declare type LogicalFilter<T extends string = string> = {
2233
2245
  [LogicalOperators.AND]: Filter<T>[];
2234
2246
  [LogicalOperators.OR]?: never;
@@ -2244,6 +2256,34 @@ export declare const LogicalOperators: {
2244
2256
 
2245
2257
  export declare type LogicalOperators = keyof typeof LogicalOperators;
2246
2258
 
2259
+ /** Operator-discriminated leaf — value is always scalar. `is_empty`/`is_not_empty` carry no value. */
2260
+ export declare type LogicCondition = {
2261
+ source: string;
2262
+ operator: "is_empty" | "is_not_empty";
2263
+ } | {
2264
+ source: string;
2265
+ operator: "equals" | "not" | "contains" | "not_contains" | "starts_with" | "not_starts_with" | "ends_with" | "not_ends_with" | "gt" | "gte" | "lt" | "lte";
2266
+ value: LogicValue;
2267
+ };
2268
+
2269
+ export declare interface LogicGroup {
2270
+ combinator: "AND" | "OR";
2271
+ conditions: (LogicCondition | LogicGroup)[];
2272
+ }
2273
+
2274
+ /**
2275
+ * Operator surface is intentionally scalar-only. Multi-value semantics (`in`, `not_in`, `between`)
2276
+ * were removed in favour of composition: a user who wants "show when nominee is Father OR Mother"
2277
+ * writes two conditions in an OR group instead of `in [Father, Mother]`. Same for `between`, which
2278
+ * composes as `gte min AND lte max`. Simplifies the picker UI (every value input is single) and
2279
+ * the engine (one less arity tier).
2280
+ */
2281
+ export declare type LogicOperator = "equals" | "not" | "contains" | "not_contains" | "starts_with" | "not_starts_with" | "ends_with" | "not_ends_with" | "gt" | "gte" | "lt" | "lte" | "is_empty" | "is_not_empty";
2282
+
2283
+ export declare type LogicValue = string | number | boolean | Date | null;
2284
+
2285
+ export declare type LogicWhen = LogicCondition | LogicGroup;
2286
+
2247
2287
  export declare enum LogLevel {
2248
2288
  debug = 0,
2249
2289
  info = 1,
@@ -2261,6 +2301,8 @@ export declare const MediaKindList: readonly ["image", "video", "audio", "docume
2261
2301
  /** Reject types assignable to Error — forces `{ exception }` wrapping at the call site. */
2262
2302
  declare type NotError<T> = T extends Error ? never : T;
2263
2303
 
2304
+ export declare const operatorsByKind: Record<FieldKind, LogicOperator[]>;
2305
+
2264
2306
  export declare type PlanKind = "addon" | "base";
2265
2307
 
2266
2308
  export declare type Prettify<T> = {
package/dist/index.js CHANGED
@@ -588,24 +588,91 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
588
588
  "user.active",
589
589
  "user.idle"
590
590
  ], z = L(R), B = (e) => e.module_name ? "module" : e.allow_public_submit && !e.public_submit_set_by ? "form" : "collection", V = {
591
+ string: [
592
+ "equals",
593
+ "not",
594
+ "contains",
595
+ "not_contains",
596
+ "starts_with",
597
+ "not_starts_with",
598
+ "ends_with",
599
+ "not_ends_with",
600
+ "is_empty",
601
+ "is_not_empty"
602
+ ],
603
+ number: [
604
+ "equals",
605
+ "not",
606
+ "gt",
607
+ "gte",
608
+ "lt",
609
+ "lte",
610
+ "is_empty",
611
+ "is_not_empty"
612
+ ],
613
+ boolean: ["equals", "not"],
614
+ date: [
615
+ "equals",
616
+ "not",
617
+ "gt",
618
+ "gte",
619
+ "lt",
620
+ "lte",
621
+ "is_empty",
622
+ "is_not_empty"
623
+ ],
624
+ "array-string": [
625
+ "contains",
626
+ "not_contains",
627
+ "is_empty",
628
+ "is_not_empty"
629
+ ],
630
+ "array-number": [
631
+ "contains",
632
+ "not_contains",
633
+ "is_empty",
634
+ "is_not_empty"
635
+ ],
636
+ "array-date": ["is_empty", "is_not_empty"],
637
+ "array-boolean": ["is_empty", "is_not_empty"],
638
+ file: ["is_empty", "is_not_empty"],
639
+ "array-file": ["is_empty", "is_not_empty"],
640
+ location: ["is_empty", "is_not_empty"],
641
+ "array-location": ["is_empty", "is_not_empty"],
642
+ richtext: ["is_empty", "is_not_empty"],
643
+ json: ["is_empty", "is_not_empty"],
644
+ "array-json": ["is_empty", "is_not_empty"],
645
+ collection: [
646
+ "equals",
647
+ "not",
648
+ "contains",
649
+ "not_contains",
650
+ "is_empty",
651
+ "is_not_empty"
652
+ ],
653
+ "public-id": ["equals", "not"],
654
+ identifier: ["equals", "not"],
655
+ record: [],
656
+ group: []
657
+ }, H = {
591
658
  published: "published",
592
659
  unpublished: "unpublished",
593
660
  archived: "archived",
594
661
  flagged: "flagged",
595
662
  pending_moderation: "pending_moderation"
596
- }, H = {
663
+ }, U = {
597
664
  post: "post",
598
665
  poll: "poll",
599
666
  gallery: "gallery",
600
667
  link: "link"
601
- }, U = Object.keys(H), W = {
668
+ }, W = Object.keys(U), G = {
602
669
  draft: "draft",
603
670
  published: "published",
604
671
  unpublished: "unpublished",
605
672
  archived: "archived",
606
673
  flagged: "flagged",
607
674
  pending_moderation: "pending_moderation"
608
- }, G = (e) => {
675
+ }, K = (e) => {
609
676
  let t = e.split("/"), n = t[t.length - 1];
610
677
  if (n) {
611
678
  let t = encodeURIComponent(n);
@@ -614,4 +681,4 @@ var r = /^W[A-Z0-9]{7}$/, i = (e) => {
614
681
  return "";
615
682
  };
616
683
  //#endregion
617
- export { z as AnalyticsEvents, R as AnalyticsEventsList, V as COMMENT_STATUS, k as CommonFieldIntefaces, E as CommonFieldInterfacesList, D as ComplexFieldInterfacesList, H as FORUM_POST_KIND, W as FORUM_POST_STATUS, A as FieldInterfaces, O as FieldInterfacesList, M as FieldKind, j as FieldKindList, U 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, G as formatImagePath, T as formatsByInterface, B as getCollectionKind, g as getLevoError, N as interfaceKinds, I as listToColumn, L as listToRecord, u as remoteLoggerMiddleware };
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 };
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.1.105",
4
+ "version": "0.1.108",
5
5
  "author": "Levo Engineering <devs@theinternetfolks.com>",
6
6
  "dependencies": {
7
7
  "lodash-es": "4.18.1",
@@ -23,6 +23,7 @@
23
23
  "files": [
24
24
  "dist/**",
25
25
  "!dist/**/*.d.ts.map",
26
+ "!dist/**/*.js.map",
26
27
  "package.json"
27
28
  ],
28
29
  "main": "./dist/index.js",