@planeasyinc/le-core 0.0.8 → 0.0.10

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 (78) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/.turbo/turbo-lint.log +5 -0
  3. package/.turbo/turbo-test.log +79 -0
  4. package/dist/adapter/normalize-actions.d.ts.map +1 -1
  5. package/dist/adapter/normalize-actions.js +9 -0
  6. package/dist/adapter/normalize-actions.js.map +1 -1
  7. package/dist/adapter/normalize-config.js +3 -1
  8. package/dist/adapter/normalize-config.js.map +1 -1
  9. package/dist/adapter/normalize-ui.d.ts +2 -0
  10. package/dist/adapter/normalize-ui.d.ts.map +1 -1
  11. package/dist/adapter/normalize-ui.js +13 -0
  12. package/dist/adapter/normalize-ui.js.map +1 -1
  13. package/dist/models/api-config.model.d.ts.map +1 -1
  14. package/dist/models/internal.d.ts +30 -0
  15. package/dist/models/internal.d.ts.map +1 -1
  16. package/dist/public-api.d.ts +1 -1
  17. package/dist/public-api.d.ts.map +1 -1
  18. package/dist/public-api.js.map +1 -1
  19. package/dist/utils/decodeJwt.js +1 -1
  20. package/dist/utils/decodeJwt.js.map +1 -1
  21. package/dist/utils/swr-cache.d.ts +29 -0
  22. package/dist/utils/swr-cache.d.ts.map +1 -0
  23. package/dist/utils/swr-cache.js +120 -0
  24. package/dist/utils/swr-cache.js.map +1 -0
  25. package/package.json +8 -4
  26. package/src/adapter/normalize-actions.test.ts +48 -0
  27. package/src/adapter/normalize-actions.ts +13 -1
  28. package/src/adapter/normalize-config.test.ts +26 -0
  29. package/src/adapter/normalize-config.ts +4 -1
  30. package/src/adapter/normalize-ui.test.ts +36 -0
  31. package/src/adapter/normalize-ui.ts +19 -0
  32. package/src/models/api-config.model.ts +1 -1
  33. package/src/models/internal.ts +34 -0
  34. package/src/public-api.ts +4 -1
  35. package/src/utils/decodeJwt.test.ts +60 -0
  36. package/src/utils/decodeJwt.ts +1 -1
  37. package/tsconfig.json +0 -12
  38. package/dist/adapter/normalizeConfig.d.ts +0 -3
  39. package/dist/adapter/normalizeConfig.d.ts.map +0 -1
  40. package/dist/adapter/normalizeConfig.js +0 -49
  41. package/dist/adapter/normalizeConfig.js.map +0 -1
  42. package/dist/planeasyinc-le-core-0.0.4.tgz +0 -0
  43. package/dist/utils/normalize-actions.d.ts +0 -3
  44. package/dist/utils/normalize-actions.d.ts.map +0 -1
  45. package/dist/utils/normalize-actions.js +0 -48
  46. package/dist/utils/normalize-actions.js.map +0 -1
  47. package/dist/utils/normalize-control-source.d.ts +0 -3
  48. package/dist/utils/normalize-control-source.d.ts.map +0 -1
  49. package/dist/utils/normalize-control-source.js +0 -17
  50. package/dist/utils/normalize-control-source.js.map +0 -1
  51. package/dist/utils/normalize-data-source.d.ts +0 -3
  52. package/dist/utils/normalize-data-source.d.ts.map +0 -1
  53. package/dist/utils/normalize-data-source.js +0 -10
  54. package/dist/utils/normalize-data-source.js.map +0 -1
  55. package/dist/utils/normalize-ui.d.ts +0 -2
  56. package/dist/utils/normalize-ui.d.ts.map +0 -1
  57. package/dist/utils/normalize-ui.js +0 -17
  58. package/dist/utils/normalize-ui.js.map +0 -1
  59. package/dist/utils/normalizeActions.d.ts +0 -3
  60. package/dist/utils/normalizeActions.d.ts.map +0 -1
  61. package/dist/utils/normalizeActions.js +0 -35
  62. package/dist/utils/normalizeActions.js.map +0 -1
  63. package/dist/utils/normalizeControlSource.d.ts +0 -3
  64. package/dist/utils/normalizeControlSource.d.ts.map +0 -1
  65. package/dist/utils/normalizeControlSource.js +0 -17
  66. package/dist/utils/normalizeControlSource.js.map +0 -1
  67. package/dist/utils/normalizeDataSource.d.ts +0 -3
  68. package/dist/utils/normalizeDataSource.d.ts.map +0 -1
  69. package/dist/utils/normalizeDataSource.js +0 -10
  70. package/dist/utils/normalizeDataSource.js.map +0 -1
  71. package/dist/utils/normalizeUI.d.ts +0 -2
  72. package/dist/utils/normalizeUI.d.ts.map +0 -1
  73. package/dist/utils/normalizeUI.js +0 -17
  74. package/dist/utils/normalizeUI.js.map +0 -1
  75. package/dist/utils/urlFragmantBuilder.d.ts +0 -11
  76. package/dist/utils/urlFragmantBuilder.d.ts.map +0 -1
  77. package/dist/utils/urlFragmantBuilder.js +0 -34
  78. package/dist/utils/urlFragmantBuilder.js.map +0 -1
@@ -0,0 +1,26 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { normalizeConfig } from './normalize-config';
3
+ import { LeFormNode } from '../models/internal';
4
+
5
+ const form = (extra: Record<string, unknown> = {}) => {
6
+ return normalizeConfig({
7
+ id: 'page',
8
+ type: 'form',
9
+ control_source: {
10
+ type: 'dynamic',
11
+ dynamic_value: { type: 'transaction', entity_name: 'page' },
12
+ },
13
+ ...extra,
14
+ }) as LeFormNode;
15
+ };
16
+
17
+ describe('normalizeConfig — form', () => {
18
+ it('keeps the card appearance of a form', () => {
19
+ expect(form({ appearance: 'card' }).ui).toEqual({ appearance: 'card' });
20
+ });
21
+
22
+ it('gives a form without an appearance no ui settings', () => {
23
+ expect(form().ui).toBeUndefined();
24
+ expect(form({ appearance: 'fancy' }).ui).toBeUndefined();
25
+ });
26
+ });
@@ -5,7 +5,7 @@ import { extractLayout } from '../utils/extractLayout';
5
5
  import { normalizeDataSource } from './normalize-data-source';
6
6
  import { normalizeControlSource } from './normalize-control-source';
7
7
  import { normalizeActions } from './normalize-actions';
8
- import { normalizeUi } from './normalize-ui';
8
+ import { normalizeAppearance, normalizeUi } from './normalize-ui';
9
9
 
10
10
  export const normalizeConfig = (raw: any): LeNode => {
11
11
  return normalizeNode(raw);
@@ -32,9 +32,12 @@ function normalizeNode(node: any): LeNode {
32
32
  }
33
33
 
34
34
  if (node.type === 'form') {
35
+ const appearance = normalizeAppearance(node);
36
+
35
37
  return {
36
38
  ...base,
37
39
  controlSource: normalizeControlSource(node.control_source),
40
+ ...(appearance ? { ui: { appearance } } : {}),
38
41
  } satisfies LeFormNode;
39
42
  }
40
43
 
@@ -0,0 +1,36 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { normalizeUi } from './normalize-ui';
3
+
4
+ describe('normalizeUi', () => {
5
+ it('returns undefined for a node without ui settings', () => {
6
+ expect(normalizeUi({})).toBeUndefined();
7
+ });
8
+
9
+ it('keeps the quick filters in their order, a button without filters stays without them', () => {
10
+ const ui = normalizeUi({
11
+ quick_filters: [
12
+ { label: 'all' },
13
+ { label: 'domain', filters: { kind: 'domain' } },
14
+ { label: 'awaiting deploy', filters: { deployed: 'awaiting deploy' } },
15
+ ],
16
+ });
17
+
18
+ expect(ui?.quickFilters).toEqual([
19
+ { label: 'all' },
20
+ { label: 'domain', filters: { kind: 'domain' } },
21
+ { label: 'awaiting deploy', filters: { deployed: 'awaiting deploy' } },
22
+ ]);
23
+ });
24
+
25
+ it('leaves out an empty list of quick filters', () => {
26
+ expect(normalizeUi({ quick_filters: [] })).toBeUndefined();
27
+ });
28
+
29
+ it('keeps the card appearance of a table', () => {
30
+ expect(normalizeUi({ appearance: 'card' })?.appearance).toBe('card');
31
+ });
32
+
33
+ it('leaves out an appearance it does not know', () => {
34
+ expect(normalizeUi({ appearance: 'fancy' })).toBeUndefined();
35
+ });
36
+ });
@@ -1,3 +1,9 @@
1
+ import { LeAppearance } from '../models/internal';
2
+
3
+ export const normalizeAppearance = (node: any): LeAppearance | undefined => {
4
+ return node.appearance === 'card' ? 'card' : undefined;
5
+ };
6
+
1
7
  export const normalizeUi = (node: any) => {
2
8
  const ui: any = {};
3
9
 
@@ -15,5 +21,18 @@ export const normalizeUi = (node: any) => {
15
21
  };
16
22
  }
17
23
 
24
+ if (node.quick_filters?.length) {
25
+ ui.quickFilters = node.quick_filters.map((filter: any) => ({
26
+ label: filter.label,
27
+ ...(filter.filters ? { filters: filter.filters } : {}),
28
+ }));
29
+ }
30
+
31
+ const appearance = normalizeAppearance(node);
32
+
33
+ if (appearance) {
34
+ ui.appearance = appearance;
35
+ }
36
+
18
37
  return Object.keys(ui).length ? ui : undefined;
19
38
  };
@@ -23,5 +23,5 @@ export interface LeApiConfigModel {
23
23
  title: string;
24
24
  elements: unknown[];
25
25
  theme?: LeTheme;
26
- custom_css?: string
26
+ custom_css?: string;
27
27
  }
@@ -1,3 +1,5 @@
1
+ import { FeControlAction } from '@planeasyinc/fe-core';
2
+
1
3
  export type LeNode =
2
4
  | LeGridNode
3
5
  | LeGridColNode
@@ -10,6 +12,8 @@ export interface LeBaseNode {
10
12
  id: string;
11
13
  type: string;
12
14
  title?: string;
15
+ onRender?: FeControlAction[];
16
+ onDestroy?: FeControlAction[];
13
17
  }
14
18
 
15
19
  export interface LeContainerNode {
@@ -37,6 +41,11 @@ export interface LeGridColNode extends LeBaseNode, LeContainerNode {
37
41
  export interface LeFormNode extends LeBaseNode {
38
42
  type: 'form';
39
43
  controlSource?: LeDataSource;
44
+ onRender?: FeControlAction[];
45
+ onDestroy?: FeControlAction[];
46
+ ui?: {
47
+ appearance?: LeAppearance;
48
+ };
40
49
  }
41
50
 
42
51
  export interface LeTableNode extends LeBaseNode {
@@ -46,6 +55,8 @@ export interface LeTableNode extends LeBaseNode {
46
55
  ui?: {
47
56
  pagination?: LePagination;
48
57
  sort?: LeSort;
58
+ quickFilters?: LeQuickFilter[];
59
+ appearance?: LeAppearance;
49
60
  };
50
61
  }
51
62
 
@@ -63,6 +74,21 @@ export interface LeSort {
63
74
  fields: string[];
64
75
  }
65
76
 
77
+ /**
78
+ * `card`: the page of a table or a form follows one page format - no empty toolbar above the content,
79
+ * a table titled like a form header and framed like a form card.
80
+ * */
81
+ export type LeAppearance = 'card';
82
+
83
+ /**
84
+ * A button above the table that narrows its rows: a click puts its `filters` into the request,
85
+ * in place of the filters of the previous button. A button without filters shows all rows.
86
+ * */
87
+ export interface LeQuickFilter {
88
+ label: string;
89
+ filters?: Record<string, string>;
90
+ }
91
+
66
92
  export interface LeDataSource {
67
93
  kind: string;
68
94
  entity: string;
@@ -71,6 +97,7 @@ export interface LeDataSource {
71
97
 
72
98
  export interface LeNodeActions {
73
99
  onRowClick?: LeRowAction[];
100
+ onCellClick?: LeCellAction[];
74
101
  tableActions?: LeTableAction[];
75
102
  }
76
103
 
@@ -84,6 +111,13 @@ export interface LeRowAction {
84
111
  node: LeNode;
85
112
  }
86
113
 
114
+ /**
115
+ * A row action bound to one column: it runs on a click on that column's cell, not on the whole row.
116
+ * */
117
+ export interface LeCellAction extends LeRowAction {
118
+ column: string;
119
+ }
120
+
87
121
  export interface LeTableAction {
88
122
  type: string;
89
123
  label: string;
package/src/public-api.ts CHANGED
@@ -12,12 +12,15 @@ export {
12
12
  LeTableNode,
13
13
  LeSort,
14
14
  LePagination,
15
+ LeQuickFilter,
16
+ LeAppearance,
15
17
  LeAction,
16
18
  LeRowAction,
19
+ LeCellAction,
17
20
  LeTableAction,
18
21
  LeDataSource,
19
22
  } from './models/internal';
20
23
  export { LeApiConfigModel, LeTheme } from './models/api-config.model';
21
- export { isFormNode, isChartNode, isGridNode, isTableNode, isSectionNode } from './guards';
24
+ export { isFormNode, isChartNode, isGridNode, isTableNode, isSectionNode } from './guards';
22
25
  export { UrlFragmentBuilder } from './utils/url-fragment-builder';
23
26
  export { decodeJwt } from './utils/decodeJwt';
@@ -0,0 +1,60 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { decodeJwt } from './decodeJwt';
3
+
4
+ describe('decodeJwt', () => {
5
+ it('should decode JWT', () => {
6
+ const jwt =
7
+ 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImFkbWluQHBsYW5lYXN5LmNvbSIsImV4cCI6MTc4NzE2MDg2OH0.oEtdcH-PDBKvtLqrT9aJm0CEM9wgqj1SmbK4q8oGHiY';
8
+ const result = decodeJwt<{ email: string; exp: number }>(jwt);
9
+
10
+ expect(result.email).toBe('admin@planeasy.com');
11
+ expect(result.exp).toBe(1787160868);
12
+ });
13
+
14
+ it('should decode payload with URL-safe base64 chars', () => {
15
+ // payload: {"data":"a+b/c","n":1} encoded with -/_ and no padding
16
+ const jwt = 'header.eyJkYXRhIjoiYStiL2MiLCJuIjoxfQ.sig';
17
+ const result = decodeJwt<{ data: string; n: number }>(jwt);
18
+
19
+ expect(result.data).toBe('a+b/c');
20
+ expect(result.n).toBe(1);
21
+ });
22
+
23
+ it('should decode payload with UTF-8 multibyte chars', () => {
24
+ // payload: {"name":"Андрій"}
25
+ const jwt = 'header.eyJuYW1lIjoi0JDQvdC00YDRltC5In0.sig';
26
+ const result = decodeJwt<{ name: string }>(jwt);
27
+
28
+ expect(result.name).toBe('Андрій');
29
+ });
30
+
31
+ it('should throw when payload segment is missing', () => {
32
+ expect(() => decodeJwt('onlyonesegment')).toThrow('missing payload segment');
33
+ });
34
+
35
+ it('should throw when payload segment is empty', () => {
36
+ expect(() => decodeJwt('header..sig')).toThrow('missing payload segment');
37
+ });
38
+
39
+ it('should throw on empty string', () => {
40
+ expect(() => decodeJwt('')).toThrow('missing payload segment');
41
+ });
42
+
43
+ it('should throw when payload is not valid JSON', () => {
44
+ // "not json" base64url-encoded → decodes fine but JSON.parse fails
45
+ const jwt = 'header.bm90IGpzb24.sig';
46
+ expect(() => decodeJwt(jwt)).toThrow('not valid JSON');
47
+ });
48
+
49
+ it('should throw when payload is a JSON non-object (array)', () => {
50
+ // payload: [1,2,3]
51
+ const jwt = 'header.WzEsMiwzXQ.sig';
52
+ expect(() => decodeJwt(jwt)).toThrow('must be an object');
53
+ });
54
+
55
+ it('should throw when payload is a JSON primitive (number)', () => {
56
+ // payload: 42
57
+ const jwt = 'header.NDI.sig';
58
+ expect(() => decodeJwt(jwt)).toThrow('must be an object');
59
+ });
60
+ });
@@ -28,7 +28,7 @@ export const decodeJwt = <T extends object>(token: string): T => {
28
28
  throw new Error('Invalid JWT: payload is not valid JSON');
29
29
  }
30
30
 
31
- if (typeof parsed !== 'object' || parsed === null) {
31
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
32
32
  throw new Error('Invalid JWT: payload must be an object');
33
33
  }
34
34
 
package/tsconfig.json CHANGED
@@ -1,15 +1,3 @@
1
- //{
2
- // "extends": "../../tsconfig.base.json",
3
- // "compilerOptions": {
4
- // "target": "ES2022",
5
- // "module": "ESNext",
6
- // "rootDir": "./src",
7
- // "outDir": "./dist",
8
- // "composite": true
9
- // },
10
- // "include": ["src"]
11
- //}
12
-
13
1
  {
14
2
  "compilerOptions": {
15
3
  "target": "ES2022",
@@ -1,3 +0,0 @@
1
- import { LeNode } from '../models/internal';
2
- export declare const normalizeConfig: (raw: any) => LeNode;
3
- //# sourceMappingURL=normalizeConfig.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeConfig.d.ts","sourceRoot":"","sources":["../../src/adapter/normalizeConfig.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,MAAM,EAAe,MAAM,oBAAoB,CAAC;AAQrE,eAAO,MAAM,eAAe,QAAS,GAAG,KAAG,MAE1C,CAAC"}
@@ -1,49 +0,0 @@
1
- import { v7 as uuid } from 'uuid';
2
- import { isContainer } from '../utils/isContainer';
3
- import { extractLayout } from '../utils/extractLayout';
4
- import { normalizeDataSource } from '../utils/normalize-data-source';
5
- import { normalizeControlSource } from '../utils/normalize-control-source';
6
- import { normalizeActions } from '../utils/normalize-actions';
7
- import { normalizeUi } from '../utils/normalize-ui';
8
- export const normalizeConfig = (raw) => {
9
- return normalizeNode(raw);
10
- };
11
- function normalizeNode(node) {
12
- const id = node.id || uuid();
13
- const base = {
14
- id,
15
- type: node.type,
16
- title: node.title || undefined,
17
- };
18
- // container nodes
19
- if (isContainer(node)) {
20
- return {
21
- ...base,
22
- kind: 'container',
23
- isParentMenu: node.type === 'section' && (node.elements?.length ?? 0) > 1,
24
- children: (node.elements || []).map(normalizeNode),
25
- layout: extractLayout(node),
26
- };
27
- }
28
- if (node.type === 'form') {
29
- return {
30
- ...base,
31
- controlSource: normalizeControlSource(node.control_source),
32
- };
33
- }
34
- if (node.type === 'table') {
35
- return {
36
- ...base,
37
- dataSource: normalizeDataSource(node.data_source),
38
- actions: normalizeActions(node),
39
- ui: normalizeUi(node),
40
- };
41
- }
42
- if (node.type === 'chart') {
43
- return {
44
- ...base,
45
- };
46
- }
47
- throw new Error(`Unknown type ${node.type}`);
48
- }
49
- //# sourceMappingURL=normalizeConfig.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeConfig.js","sourceRoot":"","sources":["../../src/adapter/normalizeConfig.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEpD,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,GAAQ,EAAU,EAAE;IAClD,OAAO,aAAa,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC,CAAC;AAEF,SAAS,aAAa,CAAC,IAAS;IAC9B,MAAM,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,IAAI,EAAE,CAAC;IAE7B,MAAM,IAAI,GAAG;QACX,EAAE;QACF,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,SAAS;KAC/B,CAAC;IAEF,kBAAkB;IAClB,IAAI,WAAW,CAAC,IAAI,CAAC,EAAE,CAAC;QACtB,OAAO;YACL,GAAG,IAAI;YACP,IAAI,EAAE,WAAW;YACjB,YAAY,EAAE,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,IAAI,CAAC,CAAC,GAAG,CAAC;YACzE,QAAQ,EAAE,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC;YAClD,MAAM,EAAE,aAAa,CAAC,IAAI,CAAC;SAC5B,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QACzB,OAAO;YACL,GAAG,IAAI;YACP,aAAa,EAAE,sBAAsB,CAAC,IAAI,CAAC,cAAc,CAAC;SACtC,CAAC;IACzB,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1B,OAAO;YACL,GAAG,IAAI;YACP,UAAU,EAAE,mBAAmB,CAAC,IAAI,CAAC,WAAW,CAAC;YACjD,OAAO,EAAE,gBAAgB,CAAC,IAAI,CAAC;YAC/B,EAAE,EAAE,WAAW,CAAC,IAAI,CAAC;SACA,CAAC;IAC1B,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC1B,OAAO;YACL,GAAG,IAAI;SACR,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAC/C,CAAC"}
Binary file
@@ -1,3 +0,0 @@
1
- import { LeNodeActions } from '../models/internal';
2
- export declare const normalizeActions: (node: any) => LeNodeActions | undefined;
3
- //# sourceMappingURL=normalize-actions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-actions.d.ts","sourceRoot":"","sources":["../../src/utils/normalize-actions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAAe,MAAM,oBAAoB,CAAC;AAqC1E,eAAO,MAAM,gBAAgB,SAAU,GAAG,KAAG,aAAa,GAAG,SAkB5D,CAAC"}
@@ -1,48 +0,0 @@
1
- import { normalizeControlSource } from './normalize-control-source';
2
- const normalizeAction = (action) => {
3
- return {
4
- type: action.type,
5
- dataSource: normalizeControlSource(action.control_source),
6
- };
7
- };
8
- const normalizeRowAction = (action) => {
9
- if (!action.content && !action.control_source) {
10
- throw new Error(`Row action of type "${action.type}" is missing required "content" property`);
11
- }
12
- if (action.control_source) {
13
- return {
14
- type: action.type,
15
- node: {
16
- id: '',
17
- type: 'form',
18
- controlSource: normalizeControlSource(action.control_source),
19
- },
20
- };
21
- }
22
- return {
23
- type: action.type,
24
- node: {
25
- id: action.id,
26
- // title: action.title,
27
- type: action.content.content_type,
28
- controlSource: normalizeControlSource(action.content.control_source),
29
- },
30
- };
31
- };
32
- export const normalizeActions = (node) => {
33
- const result = {};
34
- if (node.on_row_click) {
35
- result.onRowClick = node.on_row_click.map(normalizeRowAction);
36
- }
37
- if (node.table_actions) {
38
- result.tableActions = node.table_actions.map((action) => ({
39
- type: action.type,
40
- name: action.name,
41
- label: action.label,
42
- hideLabel: action.hideLabel,
43
- actions: action.actions.map(normalizeAction),
44
- }));
45
- }
46
- return Object.keys(result).length ? result : undefined;
47
- };
48
- //# sourceMappingURL=normalize-actions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-actions.js","sourceRoot":"","sources":["../../src/utils/normalize-actions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,MAAM,eAAe,GAAG,CAAC,MAAW,EAAY,EAAE;IAChD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,UAAU,EAAE,sBAAsB,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1D,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,MAAW,EAAe,EAAE;IACtD,IAAI,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,MAAM,CAAC,cAAc,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CAAC,uBAAuB,MAAM,CAAC,IAAI,0CAA0C,CAAC,CAAC;IAChG,CAAC;IAED,IAAI,MAAM,CAAC,cAAc,EAAE,CAAC;QAC1B,OAAO;YACL,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE;gBACJ,EAAE,EAAE,EAAE;gBACN,IAAI,EAAE,MAAM;gBACZ,aAAa,EAAE,sBAAsB,CAAC,MAAM,CAAC,cAAc,CAAC;aAC7D;SACF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE;YACJ,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,uBAAuB;YACvB,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY;YACjC,aAAa,EAAE,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;SACrE;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAS,EAA6B,EAAE;IACvE,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,CAAC;YAC7D,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;SAC7C,CAAC,CAAC,CAAC;IACN,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { LeDataSource } from '../models/internal';
2
- export declare const normalizeControlSource: (cs: any) => LeDataSource | undefined;
3
- //# sourceMappingURL=normalize-control-source.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-control-source.d.ts","sourceRoot":"","sources":["../../src/utils/normalize-control-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,eAAO,MAAM,sBAAsB,OAAQ,GAAG,KAAG,YAAY,GAAG,SAgB/D,CAAC"}
@@ -1,17 +0,0 @@
1
- import { normalizeDataSource } from './normalize-data-source';
2
- export const normalizeControlSource = (cs) => {
3
- if (!cs)
4
- return undefined;
5
- if (cs.type === 'dynamic') {
6
- return normalizeDataSource(cs.dynamic_value);
7
- }
8
- if (cs.type === 'static') {
9
- return {
10
- kind: 'static',
11
- entity: 'static',
12
- params: cs.static_value,
13
- };
14
- }
15
- return undefined;
16
- };
17
- //# sourceMappingURL=normalize-control-source.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-control-source.js","sourceRoot":"","sources":["../../src/utils/normalize-control-source.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC;AAE9D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAO,EAA4B,EAAE;IAC1E,IAAI,CAAC,EAAE;QAAE,OAAO,SAAS,CAAC;IAE1B,IAAI,EAAE,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,mBAAmB,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,EAAE,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,EAAE,CAAC,YAAY;SACxB,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { LeDataSource } from '../models/internal';
2
- export declare const normalizeDataSource: (ds: any) => LeDataSource | undefined;
3
- //# sourceMappingURL=normalize-data-source.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-data-source.d.ts","sourceRoot":"","sources":["../../src/utils/normalize-data-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,eAAO,MAAM,mBAAmB,OAAQ,GAAG,KAAG,YAAY,GAAG,SAQ5D,CAAC"}
@@ -1,10 +0,0 @@
1
- export const normalizeDataSource = (ds) => {
2
- if (!ds)
3
- return undefined;
4
- return {
5
- kind: ds.type,
6
- entity: ds.entity_name,
7
- params: ds.body || undefined,
8
- };
9
- };
10
- //# sourceMappingURL=normalize-data-source.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-data-source.js","sourceRoot":"","sources":["../../src/utils/normalize-data-source.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAO,EAA4B,EAAE;IACvE,IAAI,CAAC,EAAE;QAAE,OAAO,SAAS,CAAC;IAE1B,OAAO;QACL,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,MAAM,EAAE,EAAE,CAAC,WAAW;QACtB,MAAM,EAAE,EAAE,CAAC,IAAI,IAAI,SAAS;KAC7B,CAAC;AACJ,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const normalizeUi: (node: any) => any;
2
- //# sourceMappingURL=normalize-ui.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-ui.d.ts","sourceRoot":"","sources":["../../src/utils/normalize-ui.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,SAAU,GAAG,QAkBpC,CAAC"}
@@ -1,17 +0,0 @@
1
- export const normalizeUi = (node) => {
2
- const ui = {};
3
- if (node.pagination?.enabled) {
4
- ui.pagination = {
5
- pageSize: node.pagination.default_page_size,
6
- options: node.pagination.page_size_options,
7
- };
8
- }
9
- if (node.sort?.enabled && node.sort?.sortable_fields?.length) {
10
- ui.sort = {
11
- default: node.sort.default_sort,
12
- fields: node.sort.sortable_fields,
13
- };
14
- }
15
- return Object.keys(ui).length ? ui : undefined;
16
- };
17
- //# sourceMappingURL=normalize-ui.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalize-ui.js","sourceRoot":"","sources":["../../src/utils/normalize-ui.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,IAAS,EAAE,EAAE;IACvC,MAAM,EAAE,GAAQ,EAAE,CAAC;IAEnB,IAAI,IAAI,CAAC,UAAU,EAAE,OAAO,EAAE,CAAC;QAC7B,EAAE,CAAC,UAAU,GAAG;YACd,QAAQ,EAAE,IAAI,CAAC,UAAU,CAAC,iBAAiB;YAC3C,OAAO,EAAE,IAAI,CAAC,UAAU,CAAC,iBAAiB;SAC3C,CAAC;IACJ,CAAC;IAED,IAAI,IAAI,CAAC,IAAI,EAAE,OAAO,IAAI,IAAI,CAAC,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,CAAC;QAC7D,EAAE,CAAC,IAAI,GAAG;YACR,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY;YAC/B,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,eAAe;SAClC,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC;AACjD,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { LeNodeActions } from '../models/internal';
2
- export declare const normalizeActions: (node: any) => LeNodeActions | undefined;
3
- //# sourceMappingURL=normalizeActions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeActions.d.ts","sourceRoot":"","sources":["../../src/utils/normalizeActions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,aAAa,EAAe,MAAM,oBAAoB,CAAC;AAsB1E,eAAO,MAAM,gBAAgB,SAAU,GAAG,KAAG,aAAa,GAAG,SAkB5D,CAAC"}
@@ -1,35 +0,0 @@
1
- import { normalizeControlSource } from './normalizeControlSource';
2
- const normalizeAction = (action) => {
3
- return {
4
- type: action.type,
5
- dataSource: normalizeControlSource(action.control_source),
6
- };
7
- };
8
- const normalizeRowAction = (action) => {
9
- return {
10
- type: action.type,
11
- node: {
12
- id: action.id,
13
- // title: action.title,
14
- type: action.content.content_type,
15
- controlSource: normalizeControlSource(action.content.control_source),
16
- },
17
- };
18
- };
19
- export const normalizeActions = (node) => {
20
- const result = {};
21
- if (node.on_row_click) {
22
- result.onRowClick = node.on_row_click.map(normalizeRowAction);
23
- }
24
- if (node.table_actions) {
25
- result.tableActions = node.table_actions.map((action) => ({
26
- type: action.type,
27
- name: action.name,
28
- label: action.label,
29
- hideLabel: action.hideLabel,
30
- actions: action.actions.map(normalizeAction),
31
- }));
32
- }
33
- return Object.keys(result).length ? result : undefined;
34
- };
35
- //# sourceMappingURL=normalizeActions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeActions.js","sourceRoot":"","sources":["../../src/utils/normalizeActions.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,eAAe,GAAG,CAAC,MAAW,EAAY,EAAE;IAChD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,UAAU,EAAE,sBAAsB,CAAC,MAAM,CAAC,cAAc,CAAC;KAC1D,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,MAAW,EAAe,EAAE;IACtD,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,IAAI,EAAE;YACJ,EAAE,EAAE,MAAM,CAAC,EAAE;YACb,uBAAuB;YACvB,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,YAAY;YACjC,aAAa,EAAE,sBAAsB,CAAC,MAAM,CAAC,OAAO,CAAC,cAAc,CAAC;SACrE;KACF,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,IAAS,EAA6B,EAAE;IACvE,MAAM,MAAM,GAAkB,EAAE,CAAC;IAEjC,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;QACtB,MAAM,CAAC,UAAU,GAAG,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;IAChE,CAAC;IAED,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,MAAM,CAAC,YAAY,GAAG,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC,MAAW,EAAE,EAAE,CAAC,CAAC;YAC7D,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,MAAM,CAAC,KAAK;YACnB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC;SAC7C,CAAC,CAAC,CAAC;IACN,CAAC;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { LeDataSource } from '../models/internal';
2
- export declare const normalizeControlSource: (cs: any) => LeDataSource | undefined;
3
- //# sourceMappingURL=normalizeControlSource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeControlSource.d.ts","sourceRoot":"","sources":["../../src/utils/normalizeControlSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGlD,eAAO,MAAM,sBAAsB,OAAQ,GAAG,KAAG,YAAY,GAAG,SAgB/D,CAAC"}
@@ -1,17 +0,0 @@
1
- import { normalizeDataSource } from './normalizeDataSource';
2
- export const normalizeControlSource = (cs) => {
3
- if (!cs)
4
- return undefined;
5
- if (cs.type === 'dynamic') {
6
- return normalizeDataSource(cs.dynamic_value);
7
- }
8
- if (cs.type === 'static') {
9
- return {
10
- kind: 'static',
11
- entity: 'static',
12
- params: cs.static_value,
13
- };
14
- }
15
- return undefined;
16
- };
17
- //# sourceMappingURL=normalizeControlSource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeControlSource.js","sourceRoot":"","sources":["../../src/utils/normalizeControlSource.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAE5D,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAO,EAA4B,EAAE;IAC1E,IAAI,CAAC,EAAE;QAAE,OAAO,SAAS,CAAC;IAE1B,IAAI,EAAE,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC1B,OAAO,mBAAmB,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC;IAC/C,CAAC;IAED,IAAI,EAAE,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;QACzB,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,MAAM,EAAE,QAAQ;YAChB,MAAM,EAAE,EAAE,CAAC,YAAY;SACxB,CAAC;IACJ,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC"}
@@ -1,3 +0,0 @@
1
- import { LeDataSource } from '../models/internal';
2
- export declare const normalizeDataSource: (ds: any) => LeDataSource | undefined;
3
- //# sourceMappingURL=normalizeDataSource.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeDataSource.d.ts","sourceRoot":"","sources":["../../src/utils/normalizeDataSource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD,eAAO,MAAM,mBAAmB,OAAQ,GAAG,KAAG,YAAY,GAAG,SAQ5D,CAAC"}
@@ -1,10 +0,0 @@
1
- export const normalizeDataSource = (ds) => {
2
- if (!ds)
3
- return undefined;
4
- return {
5
- kind: ds.type,
6
- entity: ds.entity_name,
7
- params: ds.body || undefined,
8
- };
9
- };
10
- //# sourceMappingURL=normalizeDataSource.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeDataSource.js","sourceRoot":"","sources":["../../src/utils/normalizeDataSource.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAO,EAA4B,EAAE;IACvE,IAAI,CAAC,EAAE;QAAE,OAAO,SAAS,CAAC;IAE1B,OAAO;QACL,IAAI,EAAE,EAAE,CAAC,IAAI;QACb,MAAM,EAAE,EAAE,CAAC,WAAW;QACtB,MAAM,EAAE,EAAE,CAAC,IAAI,IAAI,SAAS;KAC7B,CAAC;AACJ,CAAC,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare const normalizeUI: (node: any) => any;
2
- //# sourceMappingURL=normalizeUI.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"normalizeUI.d.ts","sourceRoot":"","sources":["../../src/utils/normalizeUI.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,SAAU,GAAG,QAkBpC,CAAC"}