@planeasyinc/le-core 0.0.11 → 0.0.13

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.
@@ -1,5 +1,5 @@
1
1
 
2
2
  
3
- > @planeasyinc/le-core@0.0.10 build /Users/yefimenko/Work/amsdal/form-engine/packages/le-core
3
+ > @planeasyinc/le-core@0.0.13 build /Users/yefimenko/Work/amsdal/form-engine/packages/le-core
4
4
  > tsc -p tsconfig.json
5
5
 
@@ -1,5 +1,5 @@
1
1
 
2
2
  
3
- > @planeasyinc/le-core@0.0.10 lint /Users/yefimenko/Work/amsdal/form-engine/packages/le-core
3
+ > @planeasyinc/le-core@0.0.12 lint /Users/yefimenko/Work/amsdal/form-engine/packages/le-core
4
4
  > eslint src
5
5
 
@@ -1,6 +1,6 @@
1
1
 
2
2
  
3
- > @planeasyinc/le-core@0.0.10 test /Users/yefimenko/Work/amsdal/form-engine/packages/le-core
3
+ > @planeasyinc/le-core@0.0.12 test /Users/yefimenko/Work/amsdal/form-engine/packages/le-core
4
4
  > vitest --run
5
5
 
6
6
  [?25l▲ [WARNING] The condition "path" here will never be used as it comes after both "import" and "require" [package.json]
@@ -29,44 +29,28 @@
29
29
 
30
30
   Test Files 0 passed (5)
31
31
   Tests 0 passed (0)
32
-  Start at 16:36:37
33
-  Duration 926ms
32
+  Start at 17:34:28
33
+  Duration 205ms
34
34
  [?2026l[?2026h
35
-  ❯ src/adapter/normalize-ui.test.ts [queued]
36
-  ❯ src/utils/decodeJwt.test.ts [queued]
37
-
38
-  Test Files 0 passed (5)
39
-  Tests 0 passed (0)
40
-  Start at 16:36:37
41
-  Duration 1.09s
42
- [?2026l[?2026h ✓ src/utils/url-fragment-builder.test.ts (2 tests) 5ms
43
-
44
35
   ❯ src/adapter/normalize-actions.test.ts [queued]
45
36
   ❯ src/adapter/normalize-config.test.ts [queued]
46
37
   ❯ src/adapter/normalize-ui.test.ts [queued]
47
38
   ❯ src/utils/decodeJwt.test.ts 0/9
39
+  ❯ src/utils/url-fragment-builder.test.ts [queued]
48
40
 
49
-  Test Files 1 passed (5)
50
-  Tests 2 passed (11)
51
-  Start at 16:36:37
52
-  Duration 1.57s
53
- [?2026l[?2026h ✓ src/utils/decodeJwt.test.ts (9 tests) 10ms
54
-
55
-  ❯ src/adapter/normalize-actions.test.ts [queued]
56
-  ❯ src/adapter/normalize-config.test.ts [queued]
57
-  ❯ src/adapter/normalize-ui.test.ts 0/5
58
-
59
-  Test Files 2 passed (5)
60
-  Tests 11 passed (16)
61
-  Start at 16:36:37
62
-  Duration 1.68s
63
- [?2026l ✓ src/adapter/normalize-ui.test.ts (5 tests) 7ms
64
- ✓ src/adapter/normalize-actions.test.ts (3 tests) 7ms
65
- ✓ src/adapter/normalize-config.test.ts (2 tests) 5ms
41
+  Test Files 0 passed (5)
42
+  Tests 0 passed (9)
43
+  Start at 17:34:28
44
+  Duration 305ms
45
+ [?2026l ✓ src/utils/decodeJwt.test.ts (9 tests) 12ms
46
+ ✓ src/utils/url-fragment-builder.test.ts (2 tests) 6ms
47
+ ✓ src/adapter/normalize-ui.test.ts (5 tests) 11ms
48
+ ✓ src/adapter/normalize-actions.test.ts (3 tests) 8ms
49
+ ✓ src/adapter/normalize-config.test.ts (11 tests) 12ms
66
50
 
67
51
   Test Files  5 passed (5)
68
-  Tests  21 passed (21)
69
-  Start at  16:36:37
70
-  Duration  1.75s (transform 1.13s, setup 0ms, import 2.16s, tests 34ms, environment 1ms)
52
+  Tests  30 passed (30)
53
+  Start at  17:34:28
54
+  Duration  492ms (transform 542ms, setup 0ms, import 740ms, tests 49ms, environment 1ms)
71
55
 
72
56
  [?25h
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-config.d.ts","sourceRoot":"","sources":["../../src/adapter/normalize-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,MAAM,EAAe,MAAM,oBAAoB,CAAC;AAQrE,eAAO,MAAM,eAAe,QAAS,GAAG,KAAG,MAE1C,CAAC"}
1
+ {"version":3,"file":"normalize-config.d.ts","sourceRoot":"","sources":["../../src/adapter/normalize-config.ts"],"names":[],"mappings":"AACA,OAAO,EAAc,MAAM,EAAe,MAAM,oBAAoB,CAAC;AASrE,eAAO,MAAM,eAAe,QAAS,GAAG,KAAG,MAE1C,CAAC"}
@@ -5,6 +5,7 @@ import { normalizeDataSource } from './normalize-data-source';
5
5
  import { normalizeControlSource } from './normalize-control-source';
6
6
  import { normalizeActions } from './normalize-actions';
7
7
  import { normalizeAppearance, normalizeUi } from './normalize-ui';
8
+ import { normalizeDocumentation } from './normalize-documentation';
8
9
  export const normalizeConfig = (raw) => {
9
10
  return normalizeNode(raw);
10
11
  };
@@ -29,6 +30,7 @@ function normalizeNode(node) {
29
30
  const appearance = normalizeAppearance(node);
30
31
  return {
31
32
  ...base,
33
+ ...normalizeDocumentation(node),
32
34
  controlSource: normalizeControlSource(node.control_source),
33
35
  ...(appearance ? { ui: { appearance } } : {}),
34
36
  };
@@ -36,6 +38,8 @@ function normalizeNode(node) {
36
38
  if (node.type === 'table') {
37
39
  return {
38
40
  ...base,
41
+ ...(node.id ? { configId: node.id } : {}),
42
+ ...normalizeDocumentation(node),
39
43
  dataSource: normalizeDataSource(node.data_source),
40
44
  actions: normalizeActions(node),
41
45
  ui: normalizeUi(node),
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-config.js","sourceRoot":"","sources":["../../src/adapter/normalize-config.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,yBAAyB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,mB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L,GAAG,IAAI;SACR,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;AAC/C,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { LeDocumented } from '../models/internal';
2
+ /**
3
+ * The documentation of a table or a form node: only the fields it really has, so a node of a
4
+ * stored dashboard or an older backend, which sends neither, comes out as it did before.
5
+ * */
6
+ export declare const normalizeDocumentation: (node: any) => LeDocumented;
7
+ //# sourceMappingURL=normalize-documentation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-documentation.d.ts","sourceRoot":"","sources":["../../src/adapter/normalize-documentation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAkBtE;;;KAGK;AACL,eAAO,MAAM,sBAAsB,SAAU,GAAG,KAAG,YAQlD,CAAC"}
@@ -0,0 +1,24 @@
1
+ const KINDS = ['model', 'transaction'];
2
+ const text = (value) => {
3
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
4
+ };
5
+ const normalizeDocumentationRef = (raw) => {
6
+ const name = text(raw?.name);
7
+ if (!name || !KINDS.includes(raw.kind))
8
+ return undefined;
9
+ const provider = text(raw.provider);
10
+ return { kind: raw.kind, name, ...(provider ? { provider } : {}) };
11
+ };
12
+ /**
13
+ * The documentation of a table or a form node: only the fields it really has, so a node of a
14
+ * stored dashboard or an older backend, which sends neither, comes out as it did before.
15
+ * */
16
+ export const normalizeDocumentation = (node) => {
17
+ const description = text(node.description);
18
+ const documentation = normalizeDocumentationRef(node.documentation);
19
+ return {
20
+ ...(description ? { description } : {}),
21
+ ...(documentation ? { documentation } : {}),
22
+ };
23
+ };
24
+ //# sourceMappingURL=normalize-documentation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"normalize-documentation.js","sourceRoot":"","sources":["../../src/adapter/normalize-documentation.ts"],"names":[],"mappings":"AAEA,MAAM,KAAK,GAA8C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LeGridColNode extends LeBaseNode, LeContainerNode {
26
26
  type: 'grid_col';
27
27
  }
28
- export interface LeFormNode extends LeBaseNode {
28
+ /**
29
+ * Where the full documentation of a model or a transaction comes from: the transaction `provider`
30
+ * (`get_documentation_form` when absent) answers `{ kind, name }` with a form for the side panel.
31
+ * */
32
+ export interface LeDocumentationRef {
33
+ kind: 'model' | 'transaction';
34
+ name: string;
35
+ provider?: string;
36
+ }
37
+ /**
38
+ * The documentation a table or a form carries: `description` is one line of plain text drawn
39
+ * under the title, never as HTML; `documentation` puts an info button next to the title.
40
+ * */
41
+ export interface LeDocumented {
42
+ description?: string;
43
+ documentation?: LeDocumentationRef;
44
+ }
45
+ export interface LeFormNode extends LeBaseNode, LeDocumented {
29
46
  type: 'form';
30
47
  controlSource?: LeDataSource;
31
48
  onRender?: FeControlAction[];
@@ -34,8 +51,13 @@ export interface LeFormNode extends LeBaseNode {
34
51
  appearance?: LeAppearance;
35
52
  };
36
53
  }
37
- export interface LeTableNode extends LeBaseNode {
54
+ export interface LeTableNode extends LeBaseNode, LeDocumented {
38
55
  type: 'table';
56
+ /**
57
+ * The `id` the dashboard config gave the element. `id` is always set, generated when the config
58
+ * gives none, so this is how a table tells an id of its own from a made-up one.
59
+ */
60
+ configId?: string;
39
61
  dataSource?: LeDataSource;
40
62
  actions?: LeNodeActions;
41
63
  ui?: {
@@ -1 +1 @@
1
- {"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../../src/models/internal.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,MAAM,MAAM,MAAM,GACd,UAAU,GACV,aAAa,GACb,aAAa,GACb,UAAU,GACV,WAAW,GACX,WAAW,CAAC;AAEhB,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,eAAe,EAAE,CAAC;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7B,YAAY,CAAC,EAAE,aAAa,EAAE,CAAC;CAChC;AAED,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,YAAY,CAAC;CAC3B;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;KAEK;AACL,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,QAAQ,EAAE,CAAC;CACrB"}
@@ -2,7 +2,7 @@ export { normalizeConfig } from './adapter/normalize-config';
2
2
  export { normalizeControlSource } from './adapter/normalize-control-source';
3
3
  export { normalizeDataSource } from './adapter/normalize-data-source';
4
4
  export { normalizeActions } from './adapter/normalize-actions';
5
- export { LeNode, LeSectionNode, LeGridNode, LeGridColNode, LeChartNode, LeFormNode, LeTableNode, LeSort, LePagination, LeQuickFilter, LeAppearance, LeAction, LeRowAction, LeCellAction, LeTableAction, LeDataSource, } from './models/internal';
5
+ export { LeNode, LeSectionNode, LeGridNode, LeGridColNode, LeChartNode, LeFormNode, LeTableNode, LeSort, LePagination, LeQuickFilter, LeAppearance, LeAction, LeRowAction, LeCellAction, LeTableAction, LeDataSource, LeDocumentationRef, LeDocumented, } from './models/internal';
6
6
  export { LeApiConfigModel, LeTheme } from './models/api-config.model';
7
7
  export { isFormNode, isChartNode, isGridNode, isTableNode, isSectionNode } from './guards';
8
8
  export { UrlFragmentBuilder } from './utils/url-fragment-builder';
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.d.ts","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4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2BAA2B,CAAC;AACtE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAoB/D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
1
+ {"version":3,"file":"public-api.js","sourceRoot":"","sources":["../src/public-api.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAsB/D,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC3F,OAAO,EAAE,kBAAkB,EAAE,MAAM,8BAA8B,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planeasyinc/le-core",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/public-api.jcs",
@@ -23,7 +23,7 @@
23
23
  "typescript": "5.6.3",
24
24
  "@types/node": "18.15.3",
25
25
  "@types/web": "0.0.347",
26
- "@planeasyinc/fe-core": "0.1.36"
26
+ "@planeasyinc/fe-core": "0.1.41"
27
27
  },
28
28
  "scripts": {
29
29
  "build": "tsc -p tsconfig.json",
@@ -1,6 +1,6 @@
1
1
  import { describe, it, expect } from 'vitest';
2
2
  import { normalizeConfig } from './normalize-config';
3
- import { LeFormNode } from '../models/internal';
3
+ import { LeFormNode, LeTableNode } from '../models/internal';
4
4
 
5
5
  const form = (extra: Record<string, unknown> = {}) => {
6
6
  return normalizeConfig({
@@ -24,3 +24,78 @@ describe('normalizeConfig — form', () => {
24
24
  expect(form({ appearance: 'fancy' }).ui).toBeUndefined();
25
25
  });
26
26
  });
27
+
28
+ const table = (extra: Record<string, unknown> = {}) => {
29
+ return normalizeConfig({
30
+ id: 'cls-Deal',
31
+ type: 'table',
32
+ title: 'Deal',
33
+ data_source: { type: 'class', entity_name: 'Deal' },
34
+ ...extra,
35
+ }) as LeTableNode;
36
+ };
37
+
38
+ const DEAL_DOCUMENTATION = { kind: 'model', name: 'Deal', provider: 'get_documentation_form' };
39
+
40
+ describe('normalizeConfig — documentation', () => {
41
+ it('keeps the description and the documentation reference of a table', () => {
42
+ const node = table({ description: 'A sales opportunity.', documentation: DEAL_DOCUMENTATION });
43
+
44
+ expect(node.description).toBe('A sales opportunity.');
45
+ expect(node.documentation).toEqual(DEAL_DOCUMENTATION);
46
+ });
47
+
48
+ it('keeps the description and the documentation reference of a form', () => {
49
+ const node = form({
50
+ description: 'Close a deal.',
51
+ documentation: { kind: 'transaction', name: 'close_deal' },
52
+ });
53
+
54
+ expect(node.description).toBe('Close a deal.');
55
+ expect(node.documentation).toEqual({ kind: 'transaction', name: 'close_deal' });
56
+ });
57
+
58
+ it('adds no documentation keys to a node of a stored dashboard, which sends neither field', () => {
59
+ expect('description' in table()).toBe(false);
60
+ expect('documentation' in table()).toBe(false);
61
+ expect('description' in form()).toBe(false);
62
+ expect('documentation' in form()).toBe(false);
63
+ });
64
+
65
+ it('keeps the description text as it is, HTML included, for the view to draw as text', () => {
66
+ expect(table({ description: '<b>bold</b> deal' }).description).toBe('<b>bold</b> deal');
67
+ });
68
+
69
+ it('drops a blank or non-text description, so no empty line is drawn', () => {
70
+ expect(table({ description: ' ' }).description).toBeUndefined();
71
+ expect(table({ description: 42 }).description).toBeUndefined();
72
+ });
73
+
74
+ it('drops a documentation reference without a name or with an unknown kind', () => {
75
+ expect(table({ documentation: { kind: 'model' } }).documentation).toBeUndefined();
76
+ expect(table({ documentation: { kind: 'class', name: 'Deal' } }).documentation).toBeUndefined();
77
+ expect(table({ documentation: 'Deal' }).documentation).toBeUndefined();
78
+ });
79
+
80
+ it('leaves the provider out when it is blank, so the default transaction is used', () => {
81
+ expect(
82
+ table({ documentation: { kind: 'model', name: 'Deal', provider: '' } }).documentation,
83
+ ).toEqual({ kind: 'model', name: 'Deal' });
84
+ });
85
+ });
86
+
87
+ describe('normalizeConfig — table id', () => {
88
+ it('keeps the id the config gives a table', () => {
89
+ const node = table();
90
+
91
+ expect(node.id).toBe('cls-Deal');
92
+ expect(node.configId).toBe('cls-Deal');
93
+ });
94
+
95
+ it('makes up an id for a table the config gives none, and tells it apart', () => {
96
+ const node = table({ id: undefined });
97
+
98
+ expect(node.id).toBeTruthy();
99
+ expect('configId' in node).toBe(false);
100
+ });
101
+ });
@@ -6,6 +6,7 @@ import { normalizeDataSource } from './normalize-data-source';
6
6
  import { normalizeControlSource } from './normalize-control-source';
7
7
  import { normalizeActions } from './normalize-actions';
8
8
  import { normalizeAppearance, normalizeUi } from './normalize-ui';
9
+ import { normalizeDocumentation } from './normalize-documentation';
9
10
 
10
11
  export const normalizeConfig = (raw: any): LeNode => {
11
12
  return normalizeNode(raw);
@@ -36,6 +37,7 @@ function normalizeNode(node: any): LeNode {
36
37
 
37
38
  return {
38
39
  ...base,
40
+ ...normalizeDocumentation(node),
39
41
  controlSource: normalizeControlSource(node.control_source),
40
42
  ...(appearance ? { ui: { appearance } } : {}),
41
43
  } satisfies LeFormNode;
@@ -44,6 +46,8 @@ function normalizeNode(node: any): LeNode {
44
46
  if (node.type === 'table') {
45
47
  return {
46
48
  ...base,
49
+ ...(node.id ? { configId: node.id } : {}),
50
+ ...normalizeDocumentation(node),
47
51
  dataSource: normalizeDataSource(node.data_source),
48
52
  actions: normalizeActions(node),
49
53
  ui: normalizeUi(node),
@@ -0,0 +1,31 @@
1
+ import { LeDocumentationRef, LeDocumented } from '../models/internal';
2
+
3
+ const KINDS: ReadonlyArray<LeDocumentationRef['kind']> = ['model', 'transaction'];
4
+
5
+ const text = (value: unknown): string | undefined => {
6
+ return typeof value === 'string' && value.trim() ? value.trim() : undefined;
7
+ };
8
+
9
+ const normalizeDocumentationRef = (raw: any): LeDocumentationRef | undefined => {
10
+ const name = text(raw?.name);
11
+
12
+ if (!name || !KINDS.includes(raw.kind)) return undefined;
13
+
14
+ const provider = text(raw.provider);
15
+
16
+ return { kind: raw.kind, name, ...(provider ? { provider } : {}) };
17
+ };
18
+
19
+ /**
20
+ * The documentation of a table or a form node: only the fields it really has, so a node of a
21
+ * stored dashboard or an older backend, which sends neither, comes out as it did before.
22
+ * */
23
+ export const normalizeDocumentation = (node: any): LeDocumented => {
24
+ const description = text(node.description);
25
+ const documentation = normalizeDocumentationRef(node.documentation);
26
+
27
+ return {
28
+ ...(description ? { description } : {}),
29
+ ...(documentation ? { documentation } : {}),
30
+ };
31
+ };
@@ -38,7 +38,26 @@ export interface LeGridColNode extends LeBaseNode, LeContainerNode {
38
38
  type: 'grid_col';
39
39
  }
40
40
 
41
- export interface LeFormNode extends LeBaseNode {
41
+ /**
42
+ * Where the full documentation of a model or a transaction comes from: the transaction `provider`
43
+ * (`get_documentation_form` when absent) answers `{ kind, name }` with a form for the side panel.
44
+ * */
45
+ export interface LeDocumentationRef {
46
+ kind: 'model' | 'transaction';
47
+ name: string;
48
+ provider?: string;
49
+ }
50
+
51
+ /**
52
+ * The documentation a table or a form carries: `description` is one line of plain text drawn
53
+ * under the title, never as HTML; `documentation` puts an info button next to the title.
54
+ * */
55
+ export interface LeDocumented {
56
+ description?: string;
57
+ documentation?: LeDocumentationRef;
58
+ }
59
+
60
+ export interface LeFormNode extends LeBaseNode, LeDocumented {
42
61
  type: 'form';
43
62
  controlSource?: LeDataSource;
44
63
  onRender?: FeControlAction[];
@@ -48,8 +67,13 @@ export interface LeFormNode extends LeBaseNode {
48
67
  };
49
68
  }
50
69
 
51
- export interface LeTableNode extends LeBaseNode {
70
+ export interface LeTableNode extends LeBaseNode, LeDocumented {
52
71
  type: 'table';
72
+ /**
73
+ * The `id` the dashboard config gave the element. `id` is always set, generated when the config
74
+ * gives none, so this is how a table tells an id of its own from a made-up one.
75
+ */
76
+ configId?: string;
53
77
  dataSource?: LeDataSource;
54
78
  actions?: LeNodeActions;
55
79
  ui?: {
package/src/public-api.ts CHANGED
@@ -19,6 +19,8 @@ export {
19
19
  LeCellAction,
20
20
  LeTableAction,
21
21
  LeDataSource,
22
+ LeDocumentationRef,
23
+ LeDocumented,
22
24
  } from './models/internal';
23
25
  export { LeApiConfigModel, LeTheme } from './models/api-config.model';
24
26
  export { isFormNode, isChartNode, isGridNode, isTableNode, isSectionNode } from './guards';