@fougere/app 0.16.4-alpha.0 → 0.16.5-alpha.0

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/Choices.d.ts CHANGED
@@ -5,11 +5,16 @@ export interface Choice {
5
5
  value: string;
6
6
  label: string;
7
7
  }
8
+ /** What one load offers, and whether the target holds more than it — which is when a search is worth showing. */
9
+ export interface Offer {
10
+ choices: Choice[];
11
+ more: boolean;
12
+ }
8
13
  /** The rows a reference field offers — a handful, and a search to reach the others. */
9
14
  export declare class Choices {
10
15
  /** Enough to choose among at a glance; the rest is what a search is for. */
11
16
  static readonly LIMIT = 20;
12
17
  /** The first rows of the target, or those whose label contains `text`. */
13
- static of(fetcher: Fetcher, reference: FormReference, text?: string): Promise<Choice[]>;
18
+ static of(fetcher: Fetcher, reference: FormReference, text?: string): Promise<Offer>;
14
19
  }
15
20
  //# sourceMappingURL=Choices.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"Choices.d.ts","sourceRoot":"","sources":["../src/Choices.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,6DAA6D;AAC7D,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,uFAAuF;AACvF,qBAAa,OAAO;IAClB,4EAA4E;IAC5E,MAAM,CAAC,QAAQ,CAAC,KAAK,MAAM;IAE3B,0EAA0E;IAC1E,OAAa,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,SAAK,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAYxF;CACF"}
1
+ {"version":3,"file":"Choices.d.ts","sourceRoot":"","sources":["../src/Choices.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAEpD,6DAA6D;AAC7D,MAAM,WAAW,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAED,iHAAiH;AACjH,MAAM,WAAW,KAAK;IACpB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,IAAI,EAAE,OAAO,CAAC;CACf;AAED,uFAAuF;AACvF,qBAAa,OAAO;IAClB,4EAA4E;IAC5E,MAAM,CAAC,QAAQ,CAAC,KAAK,MAAM;IAE3B,0EAA0E;IAC1E,OAAa,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,IAAI,SAAK,GAAG,OAAO,CAAC,KAAK,CAAC,CAgBrF;CACF"}
package/dist/Choices.js CHANGED
@@ -6,11 +6,15 @@ export class Choices {
6
6
  /** The first rows of the target, or those whose label contains `text`. */
7
7
  static async of(fetcher, reference, text = '') {
8
8
  const where = text ? { [reference.label]: { contains: text } } : undefined;
9
- const answer = await sendCall(fetcher, { entity: reference.to, op: 'list' }, invocationOf({ query: { limit: Choices.LIMIT, ...(where ? { where } : {}) } }));
10
- return itemsOf(answer).map((row) => ({
11
- value: String(row[reference.key]),
12
- label: String(row[reference.label] ?? row[reference.key]),
13
- }));
9
+ const answer = await sendCall(fetcher, { entity: reference.to, op: 'list' }, invocationOf({ query: { limit: Choices.LIMIT + 1, ...(where ? { where } : {}) } }));
10
+ const rows = itemsOf(answer);
11
+ return {
12
+ choices: rows.slice(0, Choices.LIMIT).map((row) => ({
13
+ value: String(row[reference.key]),
14
+ label: String(row[reference.label] ?? row[reference.key]),
15
+ })),
16
+ more: rows.length > Choices.LIMIT,
17
+ };
14
18
  }
15
19
  }
16
20
  //# sourceMappingURL=Choices.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Choices.js","sourceRoot":"","sources":["../src/Choices.ts"],"names":[],"m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fouger
6
6
  export { errorsByField, formFieldsOf, payloadOf, tableColumnsOf, type FormEntity } from '../FormEntity.js';
7
7
  export { type FormRow, type FormValues, type FormErrors, type FormFieldName } from '../FormRow.js';
8
8
  export { type FormField, type FormReference } from '../FormField.js';
9
- export { Choices, type Choice } from '../Choices.js';
10
- export { cellOf, summaryOf, type Summary } from '../Summary.js';
9
+ export { Choices, type Choice, type Offer } from '../Choices.js';
11
10
  export { type TableColumn } from '../TableColumn.js';
12
11
  export { sessionViewOf, type SessionView } from '../session.js';
13
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EACL,KAAK,WAAW,EAChB,aAAa,EACb,SAAS,EACT,cAAc,EACd,MAAM,EACN,WAAW,EACX,MAAM,EACN,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,OAAO,EACP,WAAW,EACX,SAAS,EACT,MAAM,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,UAAU,GACX,MAAM,mBAAmB,CAAC;AAE3B,YAAY,EACV,SAAS,EACT,MAAM,EACN,UAAU,EACV,UAAU,EACV,eAAe,EACf,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,IAAI,GACL,MAAM,wBAAwB,CAAC;AAKhC,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC3G,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,eAAe,CAAC;AACnG,OAAO,EAAE,KAAK,SA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,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC"}
@@ -4,6 +4,5 @@ export { CALL_ENDPOINT, addressOf, asFougereError, callOf, entityKeyOf, facade,
4
4
  // which carries the boot.
5
5
  export { errorsByField, formFieldsOf, payloadOf, tableColumnsOf } from '../FormEntity.js';
6
6
  export { Choices } from '../Choices.js';
7
- export { cellOf, summaryOf } from '../Summary.js';
8
7
  export { sessionViewOf } from '../session.js';
9
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,aAAa,EACb,SAAS,EACT,cAAc,EACd,MAAM,EACN,WAAW,EACX,MAAM,EACN,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,OAAO,EACP,WAAW,EACX,SAAS,EACT,MAAM,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,UAAU,GACX,MAAM,mBAAmB,CAAC;AAc3B,+EAA+E;AAC/E,iFAAiF;AACjF,0BAA0B;AAC1B,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAmB,MAAM,kBAAkB,CAAC;AAG3G,OAAO,EAAE,OAAO,EAAe,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,MAAM,EAAE,SAAS,EAAgB,MAAM,eAAe,CAAC;AAEhE,OAAO,EAAE,aAAa,EAAoB,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,aAAa,EACb,SAAS,EACT,cAAc,EACd,MAAM,EACN,WAAW,EACX,MAAM,EACN,QAAQ,EACR,OAAO,EACP,YAAY,EACZ,OAAO,EACP,WAAW,EACX,SAAS,EACT,MAAM,EACN,UAAU,EACV,UAAU,EACV,QAAQ,EACR,UAAU,GACX,MAAM,mBAAmB,CAAC;AAc3B,+EAA+E;AAC/E,iFAAiF;AACjF,0BAA0B;AAC1B,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,SAAS,EAAE,cAAc,EAAmB,MAAM,kBAAkB,CAAC;AAG3G,OAAO,EAAE,OAAO,EAA2B,MAAM,eAAe,CAAC;AAEjE,OAAO,EAAE,aAAa,EAAoB,MAAM,eAAe,CAAC"}
package/dist/index.d.ts CHANGED
@@ -6,8 +6,7 @@ export { invokeOn, rpcParseError, serveRest, serveRpc, surfaceOf } from './Outco
6
6
  export { errorsByField, formFieldsOf, payloadOf, tableColumnsOf, type FormEntity } from './FormEntity.js';
7
7
  export { type FormRow, type FormValues, type FormErrors, type FormFieldName } from './FormRow.js';
8
8
  export { type FormField, type FormReference } from './FormField.js';
9
- export { Choices, type Choice } from './Choices.js';
10
- export { cellOf, summaryOf, type Summary } from './Summary.js';
9
+ export { Choices, type Choice, type Offer } from './Choices.js';
11
10
  export { type TableColumn } from './TableColumn.js';
12
11
  export { sessionViewOf, type SessionView } from './session.js';
13
12
  export { stateFor } from './state.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,EACb,KAAK,mBAAmB,GACzB,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEvF,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,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K,UAAU,EAAE,KAAK,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAClG,OAAO,EAAE,KAAK,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,gBAAgB,CAAC;AACpE,OAAO,EAAE,OAAO,EAAE,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,aAAa,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAC;AAE/D,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,OAAO,EAAE,YAAY,EAAE,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -5,7 +5,6 @@ export { tableOf } from './RouteMatch.js';
5
5
  export { invokeOn, rpcParseError, serveRest, serveRpc, surfaceOf } from './Outcome.js';
6
6
  export { errorsByField, formFieldsOf, payloadOf, tableColumnsOf } from './FormEntity.js';
7
7
  export { Choices } from './Choices.js';
8
- export { cellOf, summaryOf } from './Summary.js';
9
8
  export { sessionViewOf } from './session.js';
10
9
  export { stateFor } from './state.js';
11
10
  export { serveGraphQL } from './graphql.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,aAAa,EACb,aAAa,GAEd,MAAM,WAAW,CAAC;AAEnB,OAAO,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,cAAc,CA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16.4-alpha.0",
3
+ "version": "0.16.5-alpha.0",
4
4
  "description": "The host-independent half of a Fougere app: boot, call envelope, REST table, form contract.",
5
5
  "keywords": [
6
6
  "fougere",
@@ -41,26 +41,26 @@
41
41
  "src"
42
42
  ],
43
43
  "dependencies": {
44
- "@fougere/core": "0.16.4-alpha.0",
45
- "@fougere/defaults": "0.16.4-alpha.0",
46
- "@fougere/schema": "0.16.4-alpha.0",
47
- "@fougere/adapter-rest": "0.16.4-alpha.0",
48
- "@fougere/transport-http": "0.16.4-alpha.0",
44
+ "@fougere/core": "0.16.5-alpha.0",
45
+ "@fougere/defaults": "0.16.5-alpha.0",
46
+ "@fougere/schema": "0.16.5-alpha.0",
47
+ "@fougere/adapter-rest": "0.16.5-alpha.0",
48
+ "@fougere/transport-http": "0.16.5-alpha.0",
49
49
  "jiti": "^2.6.1",
50
- "@fougere/http": "0.16.4-alpha.0",
51
- "@fougere/container": "0.16.4-alpha.0",
52
- "@fougere/adapter-memory": "0.16.4-alpha.0",
53
- "@fougere/compiler": "0.16.4-alpha.0"
50
+ "@fougere/http": "0.16.5-alpha.0",
51
+ "@fougere/container": "0.16.5-alpha.0",
52
+ "@fougere/adapter-memory": "0.16.5-alpha.0",
53
+ "@fougere/compiler": "0.16.5-alpha.0"
54
54
  },
55
55
  "devDependencies": {
56
56
  "vitest": "^4.1.0",
57
- "@fougere/adapter-graphql": "0.16.4-alpha.0"
57
+ "@fougere/adapter-graphql": "0.16.5-alpha.0"
58
58
  },
59
59
  "publishConfig": {
60
60
  "access": "public"
61
61
  },
62
62
  "peerDependencies": {
63
- "@fougere/adapter-graphql": "^0.16.4-alpha.0"
63
+ "@fougere/adapter-graphql": "^0.16.5-alpha.0"
64
64
  },
65
65
  "peerDependenciesMeta": {
66
66
  "@fougere/adapter-graphql": {
package/src/Choices.ts CHANGED
@@ -8,23 +8,33 @@ export interface Choice {
8
8
  label: string;
9
9
  }
10
10
 
11
+ /** What one load offers, and whether the target holds more than it — which is when a search is worth showing. */
12
+ export interface Offer {
13
+ choices: Choice[];
14
+ more: boolean;
15
+ }
16
+
11
17
  /** The rows a reference field offers — a handful, and a search to reach the others. */
12
18
  export class Choices {
13
19
  /** Enough to choose among at a glance; the rest is what a search is for. */
14
20
  static readonly LIMIT = 20;
15
21
 
16
22
  /** The first rows of the target, or those whose label contains `text`. */
17
- static async of(fetcher: Fetcher, reference: FormReference, text = ''): Promise<Choice[]> {
23
+ static async of(fetcher: Fetcher, reference: FormReference, text = ''): Promise<Offer> {
18
24
  const where = text ? { [reference.label]: { contains: text } } : undefined;
19
25
  const answer = await sendCall(
20
26
  fetcher,
21
27
  { entity: reference.to, op: 'list' },
22
- invocationOf({ query: { limit: Choices.LIMIT, ...(where ? { where } : {}) } }),
28
+ invocationOf({ query: { limit: Choices.LIMIT + 1, ...(where ? { where } : {}) } }),
23
29
  );
30
+ const rows = itemsOf<Record<string, unknown>>(answer);
24
31
 
25
- return itemsOf<Record<string, unknown>>(answer).map((row) => ({
26
- value: String(row[reference.key]),
27
- label: String(row[reference.label] ?? row[reference.key]),
28
- }));
32
+ return {
33
+ choices: rows.slice(0, Choices.LIMIT).map((row) => ({
34
+ value: String(row[reference.key]),
35
+ label: String(row[reference.label] ?? row[reference.key]),
36
+ })),
37
+ more: rows.length > Choices.LIMIT,
38
+ };
29
39
  }
30
40
  }
@@ -40,7 +40,6 @@ export type {
40
40
  export { errorsByField, formFieldsOf, payloadOf, tableColumnsOf, type FormEntity } from '../FormEntity.js';
41
41
  export { type FormRow, type FormValues, type FormErrors, type FormFieldName } from '../FormRow.js';
42
42
  export { type FormField, type FormReference } from '../FormField.js';
43
- export { Choices, type Choice } from '../Choices.js';
44
- export { cellOf, summaryOf, type Summary } from '../Summary.js';
43
+ export { Choices, type Choice, type Offer } from '../Choices.js';
45
44
  export { type TableColumn } from '../TableColumn.js';
46
45
  export { sessionViewOf, type SessionView } from '../session.js';
package/src/index.ts CHANGED
@@ -16,8 +16,7 @@ export { invokeOn, rpcParseError, serveRest, serveRpc, surfaceOf } from './Outco
16
16
  export { errorsByField, formFieldsOf, payloadOf, tableColumnsOf, type FormEntity } from './FormEntity.js';
17
17
  export { type FormRow, type FormValues, type FormErrors, type FormFieldName } from './FormRow.js';
18
18
  export { type FormField, type FormReference } from './FormField.js';
19
- export { Choices, type Choice } from './Choices.js';
20
- export { cellOf, summaryOf, type Summary } from './Summary.js';
19
+ export { Choices, type Choice, type Offer } from './Choices.js';
21
20
  export { type TableColumn } from './TableColumn.js';
22
21
 
23
22
  export { sessionViewOf, type SessionView } from './session.js';
package/dist/Summary.d.ts DELETED
@@ -1,11 +0,0 @@
1
- import { type FormEntity } from './FormEntity.js';
2
- import type { TableColumn } from './TableColumn.js';
3
- /** What a line of a list shows of a row: the field that names it, and the facts read at a glance. */
4
- export interface Summary {
5
- name?: TableColumn;
6
- facts: TableColumn[];
7
- }
8
- export declare function summaryOf(entity: FormEntity, entityKey: string): Summary;
9
- /** One column of a row as a line prints it: a date without its hour, a true boolean by its label, a false one not at all. */
10
- export declare function cellOf(column: TableColumn, row: object): string;
11
- //# sourceMappingURL=Summary.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Summary.d.ts","sourceRoot":"","sources":["../src/Summary.ts"],"names":[],"mappings":"AACA,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAEpD,qGAAqG;AACrG,MAAM,WAAW,OAAO;IACtB,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE,WAAW,EAAE,CAAC;CACtB;AAKD,wBAAgB,SAAS,CAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAYxE;AAED,6HAA6H;AAC7H,wBAAgB,MAAM,CAAC,MAAM,EAAE,WAAW,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAO/D"}
package/dist/Summary.js DELETED
@@ -1,28 +0,0 @@
1
- import { Role, Shapes } from '@fougere/schema';
2
- import { tableColumnsOf } from './FormEntity.js';
3
- import { rowNameOf } from './RowName.js';
4
- /** What reads at a glance. A long text, a key, a reference or a document does not. */
5
- const AT_A_GLANCE = new Set(['choice', 'boolean', 'number', 'integer', 'date']);
6
- export function summaryOf(entity, entityKey) {
7
- const fields = entity.getFields();
8
- const columns = tableColumnsOf(entity, entityKey);
9
- const name = columns.find((column) => column.name === rowNameOf(fields));
10
- const facts = columns.filter((column) => {
11
- const field = fields[column.name];
12
- const type = Shapes.typeOf(field.shape);
13
- return column !== name && type !== undefined && AT_A_GLANCE.has(type) && !Role.of(field).isRelation();
14
- });
15
- return { ...(name ? { name } : {}), facts };
16
- }
17
- /** One column of a row as a line prints it: a date without its hour, a true boolean by its label, a false one not at all. */
18
- export function cellOf(column, row) {
19
- const value = row[column.name];
20
- if (value === undefined || value === null || value === false)
21
- return '';
22
- if (value === true)
23
- return column.label;
24
- if (column.render === 'date')
25
- return new Date(value).toLocaleDateString();
26
- return String(value);
27
- }
28
- //# sourceMappingURL=Summary.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Summary.js","sourceRoot":"","sources":["../src/Summary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAkB,MAAM,iBAAiB,CAAC;AAC/D,OAAO,EAAE,cAAc,EAAmB,MAAM,iBAAiB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AASzC,sFAAsF;AACtF,MAAM,WAAW,GAAG,IAAI,GAAG,CAAY,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;AAE3F,MAAM,UAAU,SAAS,CAAC,MAAkB,EAAE,SAAiB;IAC7D,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,EAAE,CAAC;IAClC,MAAM,OAAO,GAAG,cAAc,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAClD,M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ableColumnsOf, type FormEntity } from './FormEntity.js';
3
- import { rowNameOf } from './RowName.js';
4
- import type { TableColumn } from './TableColumn.js';
5
-
6
- /** What a line of a list shows of a row: the field that names it, and the facts read at a glance. */
7
- export interface Summary {
8
- name?: TableColumn;
9
- facts: TableColumn[];
10
- }
11
-
12
- /** What reads at a glance. A long text, a key, a reference or a document does not. */
13
- const AT_A_GLANCE = new Set<ShapeType>(['choice', 'boolean', 'number', 'integer', 'date']);
14
-
15
- export function summaryOf(entity: FormEntity, entityKey: string): Summary {
16
- const fields = entity.getFields();
17
- const columns = tableColumnsOf(entity, entityKey);
18
- const name = columns.find((column) => column.name === rowNameOf(fields));
19
- const facts = columns.filter((column) => {
20
- const field = fields[column.name]!;
21
- const type = Shapes.typeOf(field.shape);
22
-
23
- return column !== name && type !== undefined && AT_A_GLANCE.has(type) && !Role.of(field).isRelation();
24
- });
25
-
26
- return { ...(name ? { name } : {}), facts };
27
- }
28
-
29
- /** One column of a row as a line prints it: a date without its hour, a true boolean by its label, a false one not at all. */
30
- export function cellOf(column: TableColumn, row: object): string {
31
- const value = (row as Record<string, unknown>)[column.name];
32
- if (value === undefined || value === null || value === false) return '';
33
- if (value === true) return column.label;
34
- if (column.render === 'date') return new Date(value as string | Date).toLocaleDateString();
35
-
36
- return String(value);
37
- }