rapida-partner 8.0.0 → 8.1.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/index.ts CHANGED
@@ -3,6 +3,7 @@
3
3
  import { tsProjectToJsonProject } from "./src/controllers/ts_project_to_json_project";
4
4
  import { validateProjectJson } from "./src/utils/json";
5
5
  import { checkListReferences } from "./src/utils/list-references";
6
+ import { checkFormReferences } from "./src/utils/form-references";
6
7
  import type { IProject } from "./src/interfaces/project.interface";
7
8
  import * as fs from "fs";
8
9
  import * as path from "path";
@@ -78,7 +79,7 @@ async function main() {
78
79
  process.exit(1);
79
80
  }
80
81
 
81
- for (const warning of checkListReferences(project)) {
82
+ for (const warning of [...checkListReferences(project), ...checkFormReferences(project)]) {
82
83
  console.warn("Aviso: " + warning);
83
84
  }
84
85
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rapida-partner",
3
- "version": "8.0.0",
3
+ "version": "8.1.0",
4
4
  "main": "dist/index.js",
5
5
  "module": "index.ts",
6
6
  "files": [
@@ -0,0 +1,4 @@
1
+ // Como as opções de checkbox e radio aparecem. "list" (padrão): uma por linha. "chips": botões
2
+ // lado a lado, para opções curtas (dias da semana, durações). "cards": cartões com a description
3
+ // de cada opção, para escolhas que mudam o resto do formulário.
4
+ export type TChoiceDisplay = "list" | "chips" | "cards";
@@ -14,4 +14,7 @@ export interface IFormArray {
14
14
  businessRules?: IBusinessRule[];
15
15
  elementDescription?: string;
16
16
  isRequired?: boolean;
17
+ // Nome de um item, no singular ("dependente"), para "Adicionar dependente",
18
+ // "Dependente 2" e "Remover dependente 2". Sem ele, a tela usa "item".
19
+ itemLabel?: TTranslatable;
17
20
  }
@@ -2,6 +2,7 @@ import type { TTranslatable } from "./translatable.interface";
2
2
  // MODIFICATION BASED ON: src/interfaces/form-checkbox.interface.ts
3
3
  import type { IFormCondition } from "./condition.interface";
4
4
  import type { IBusinessRule } from "./project.interface";
5
+ import type { TChoiceDisplay } from "./choice-display.interface";
5
6
 
6
7
  export interface IFormCheckbox {
7
8
  type: "checkbox";
@@ -18,11 +19,16 @@ export interface IFormCheckbox {
18
19
  businessRules?: IBusinessRule[];
19
20
  elementDescription?: string;
20
21
  space?: 1 | 2 | 3 | 4;
22
+ display?: TChoiceDisplay; // ver choice-display.interface.ts
21
23
  }
22
24
 
25
+ export type { TChoiceDisplay } from "./choice-display.interface";
26
+
23
27
  export interface ICheckboxOption {
24
28
  label: TTranslatable;
25
29
  value: string | number | boolean;
26
30
  isDisabled?: boolean;
27
31
  isSelected?: boolean;
32
+ // Texto de apoio da opção, mostrado só com display "cards".
33
+ description?: TTranslatable;
28
34
  }
@@ -19,4 +19,8 @@ export interface IFormDatePicker {
19
19
  businessRules?: IBusinessRule[];
20
20
  elementDescription?: string;
21
21
  space?: 1 | 2 | 3 | 4;
22
+ // Só em listFilters: vira um filtro de período, com "De" e "Até" e atalhos (hoje, esta
23
+ // semana, este mês, mês passado). Busca os registros com a data dentro do período.
24
+ // Em formulários é ignorado.
25
+ range?: boolean;
22
26
  }
@@ -19,6 +19,7 @@ export interface IFormFile {
19
19
  accept?: Record<string, string[]>;
20
20
  isMultiple?: boolean;
21
21
  isProfilePicture?: boolean;
22
+ // Tamanho máximo de cada arquivo, em bytes (5 MB = 5242880).
22
23
  maxSize?: number;
23
24
  isDisabled?: boolean;
24
25
  isDisabledOnUpdate?: boolean;
@@ -2,6 +2,7 @@ import type { TTranslatable } from "./translatable.interface";
2
2
  // MODIFICATION BASED ON: src/interfaces/form-radio.interface.ts
3
3
  import type { IFormCondition } from "./condition.interface";
4
4
  import type { IBusinessRule } from "./project.interface";
5
+ import type { TChoiceDisplay } from "./choice-display.interface";
5
6
 
6
7
  export interface IFormRadio {
7
8
  type: "radio";
@@ -18,6 +19,7 @@ export interface IFormRadio {
18
19
  businessRules?: IBusinessRule[];
19
20
  elementDescription?: string;
20
21
  space?: 1 | 2 | 3 | 4;
22
+ display?: TChoiceDisplay; // ver choice-display.interface.ts
21
23
  }
22
24
 
23
25
  export interface IRadioOption {
@@ -25,4 +27,6 @@ export interface IRadioOption {
25
27
  value: string | number | boolean;
26
28
  isDisabled?: boolean;
27
29
  isSelected?: boolean;
30
+ // Texto de apoio da opção, mostrado só com display "cards".
31
+ description?: TTranslatable;
28
32
  }
@@ -16,4 +16,10 @@ export interface IFormSwitch {
16
16
  businessRules?: IBusinessRule[];
17
17
  elementDescription?: string;
18
18
  space?: 1 | 2 | 3 | 4;
19
+ // Consentimento: guarda o último aceite e a última revogação, não um histórico completo. Ao
20
+ // ligar, o backend grava a data e o usuário em <name>At e <name>By; ao desligar, grava a
21
+ // revogação em <name>RevokedAt e <name>RevokedBy, sem apagar o aceite. Ligar de novo troca o
22
+ // aceite e limpa a revogação. Evite names que gerem campos já existentes (e.g.: "created"
23
+ // vira createdAt).
24
+ recordTimestamp?: boolean;
19
25
  }
@@ -43,6 +43,7 @@ export interface IList {
43
43
  tones?: Record<string, TTone>; // só em type "badge" (nos outros tipos é ignorado): tom de cada valor. e.g.: { "paid": "success", "overdue": "danger" }
44
44
  mobilePriority?: 1 | 2 | 3; // 1 e 2 aparecem no card do celular; 3 só no desktop
45
45
  relativeDate?: "plain" | "deadline"; // data com texto relativo abaixo ("há 3 dias"); "deadline" pinta o passado de vermelho e os próximos 7 dias de âmbar
46
+ columnGroup?: TTranslatable; // grupo da coluna (e.g.: "Valores"), escrito acima do nome e usado no seletor de colunas; colunas do mesmo grupo devem ficar juntas
46
47
  conditions?: IFormCondition;
47
48
  businessRules?: IBusinessRule[];
48
49
  todo?: string;
@@ -50,6 +51,10 @@ export interface IList {
50
51
  listFilters?: IFormElement[]; // filters to be applied on dataSource
51
52
  quickFilters?: string[]; // até 2 `name` de listFilters que ficam ao lado da busca; os demais vão para a área "Mais filtros". Sem isso, todos ficam na área "Filtros"
52
53
  tabs?: IListTabs; // abas com contador acima da tabela, uma por valor de `property`, mais "Todos"
54
+ kpis?: IListKpi[]; // até 4 números-resumo acima da tabela; clicar num deles filtra a lista
55
+ columnViews?: IListColumnView[]; // visualizações de colunas (e.g.: Resumo, Fiscal, Completo); com elas aparece o seletor de colunas e a escolha fica salva por pessoa e por tela
56
+ stickyStart?: boolean; // em tabelas largas, a coluna de identificação (title) fica fixa à esquerda e as ações à direita enquanto o meio rola
57
+ views?: TListView[]; // modos de ver a lista; o primeiro é o padrão. Com os dois, aparece o seletor Tabela/Lista e a escolha fica salva por pessoa e por tela
53
58
  listActions?: IFormElement[]; // actions that can be performed on the list
54
59
  cardAsALink?: {
55
60
  link: string; // e.g.: "/user"
@@ -114,4 +119,30 @@ export interface IListPagination {
114
119
  pageSize: number;
115
120
  pageSizeOptions?: number[];
116
121
  position?: "top" | "bottom" | "both";
117
- }
122
+ }
123
+ // Número-resumo acima da tabela. Sem sumOf, conta os registros que passam no filtro;
124
+ // com sumOf, soma esse campo numérico. Clicar aplica o filtro na lista.
125
+ export interface IListKpi {
126
+ label: TTranslatable;
127
+ description?: TTranslatable; // contexto abaixo do valor, e.g.: "contas vencidas"
128
+ filter?: IListKpiCondition[]; // condições que o registro precisa cumprir (todas), e.g.: [{ field: "dueDate", op: "lt", value: "$today" }]
129
+ sumOf?: string; // campo numérico do form do módulo, e.g.: "accountAmount"
130
+ tone?: TTone | "brand"; // "brand" no número principal (no máximo 1), "danger" para atraso, "warning" para hoje
131
+ }
132
+
133
+ // "table": tabela com colunas, para comparar e ordenar. "list": um card largo por registro, com
134
+ // avatar, título, situação e até 4 campos, para entender e agir em cada um.
135
+ export type TListView = "table" | "list";
136
+
137
+ export interface IListColumnView {
138
+ label: TTranslatable; // e.g.: "Resumo"
139
+ columns: string[]; // property de cada listItem visível nesta visualização; a coluna title aparece sempre
140
+ }
141
+
142
+ export type TListKpiOperator = "eq" | "ne" | "lt" | "lte" | "gt" | "gte" | "in";
143
+
144
+ export interface IListKpiCondition {
145
+ field: string; // name de um campo do form do módulo
146
+ op: TListKpiOperator;
147
+ value: string | number | boolean | (string | number)[]; // "$today" e "$tomorrow" viram as datas do dia; com "in", uma lista
148
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "$id": "choice-display.ref.json",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "type": "string",
5
+ "enum": ["list", "chips", "cards"]
6
+ }
@@ -31,6 +31,9 @@
31
31
  },
32
32
  "isRequired": {
33
33
  "type": "boolean"
34
+ },
35
+ "itemLabel": {
36
+ "$ref": "translatable.ref.json"
34
37
  }
35
38
  },
36
39
  "required": [
@@ -32,6 +32,9 @@
32
32
  },
33
33
  "isSelected": {
34
34
  "type": "boolean"
35
+ },
36
+ "description": {
37
+ "$ref": "translatable.ref.json"
35
38
  }
36
39
  },
37
40
  "required": ["label", "value"]
@@ -67,6 +70,9 @@
67
70
  "space": {
68
71
  "type": "number",
69
72
  "enum": [1, 2, 3, 4]
73
+ },
74
+ "display": {
75
+ "$ref": "choice-display.ref.json"
70
76
  }
71
77
  },
72
78
  "required": ["type", "name", "label", "options"]
@@ -59,6 +59,9 @@
59
59
  3,
60
60
  4
61
61
  ]
62
+ },
63
+ "range": {
64
+ "type": "boolean"
62
65
  }
63
66
  },
64
67
  "required": [
@@ -32,6 +32,9 @@
32
32
  },
33
33
  "isSelected": {
34
34
  "type": "boolean"
35
+ },
36
+ "description": {
37
+ "$ref": "translatable.ref.json"
35
38
  }
36
39
  },
37
40
  "required": ["label", "value"]
@@ -67,6 +70,9 @@
67
70
  "space": {
68
71
  "type": "number",
69
72
  "enum": [1, 2, 3, 4]
73
+ },
74
+ "display": {
75
+ "$ref": "choice-display.ref.json"
70
76
  }
71
77
  },
72
78
  "required": ["type", "name", "label", "options"]
@@ -43,6 +43,9 @@
43
43
  },
44
44
  "elementDescription": {
45
45
  "type": "string"
46
+ },
47
+ "recordTimestamp": {
48
+ "type": "boolean"
46
49
  }
47
50
  },
48
51
  "required": ["type", "name", "label"]
@@ -81,6 +81,10 @@
81
81
  "enum": [1, 2, 3],
82
82
  "description": "1 e 2 aparecem no card do celular; 3 só no desktop."
83
83
  },
84
+ "columnGroup": {
85
+ "$ref": "translatable.ref.json",
86
+ "description": "Grupo da coluna, escrito acima do nome e usado no seletor de colunas."
87
+ },
84
88
  "relativeDate": {
85
89
  "type": "string",
86
90
  "enum": ["plain", "deadline"],
@@ -275,6 +279,70 @@
275
279
  "items": { "type": "string" },
276
280
  "description": "Até 2 `name` de listFilters que ficam ao lado da busca; os demais vão para a área 'Mais filtros'. Sem isso, todos ficam na área 'Filtros'."
277
281
  },
282
+ "columnViews": {
283
+ "type": "array",
284
+ "description": "Visualizações de colunas; com elas aparece o seletor de colunas.",
285
+ "items": {
286
+ "type": "object",
287
+ "properties": {
288
+ "label": { "$ref": "translatable.ref.json" },
289
+ "columns": { "type": "array", "minItems": 1, "items": { "type": "string" } }
290
+ },
291
+ "required": ["label", "columns"],
292
+ "additionalProperties": false
293
+ }
294
+ },
295
+ "stickyStart": {
296
+ "type": "boolean",
297
+ "description": "Em tabelas largas, a identificação fica fixa à esquerda e as ações à direita."
298
+ },
299
+ "views": {
300
+ "type": "array",
301
+ "minItems": 1,
302
+ "maxItems": 2,
303
+ "uniqueItems": true,
304
+ "items": { "type": "string", "enum": ["table", "list"] },
305
+ "description": "Modos de ver a lista; o primeiro é o padrão. Com os dois, aparece o seletor Tabela/Lista."
306
+ },
307
+ "kpis": {
308
+ "type": "array",
309
+ "maxItems": 4,
310
+ "description": "Até 4 números-resumo acima da tabela; clicar num deles filtra a lista.",
311
+ "items": {
312
+ "type": "object",
313
+ "properties": {
314
+ "label": { "$ref": "translatable.ref.json" },
315
+ "description": { "$ref": "translatable.ref.json" },
316
+ "filter": {
317
+ "type": "array",
318
+ "items": {
319
+ "type": "object",
320
+ "properties": {
321
+ "field": { "type": "string" },
322
+ "op": { "type": "string", "enum": ["eq", "ne", "lt", "lte", "gt", "gte", "in"] },
323
+ "value": {
324
+ "oneOf": [
325
+ { "type": "string" },
326
+ { "type": "number" },
327
+ { "type": "boolean" },
328
+ { "type": "array", "items": { "type": ["string", "number"] } }
329
+ ]
330
+ }
331
+ },
332
+ "required": ["field", "op", "value"],
333
+ "additionalProperties": false,
334
+ "if": { "properties": { "op": { "const": "in" } } },
335
+ "then": { "properties": { "value": { "type": "array", "minItems": 1 } } },
336
+ "else": { "properties": { "value": { "not": { "type": "array" } } } }
337
+ }
338
+ },
339
+ "sumOf": { "type": "string" },
340
+ "tone": { "oneOf": [{ "$ref": "tone.ref.json" }, { "const": "brand" }] }
341
+ },
342
+ "required": ["label"],
343
+ "additionalProperties": false
344
+ }
345
+ },
278
346
  "tabs": {
279
347
  "type": "object",
280
348
  "description": "Abas com contador acima da tabela, uma por valor de `property`, mais 'Todos'.",
@@ -0,0 +1,48 @@
1
+ import { EDataType } from "../enums/form.enum";
2
+
3
+ export interface IFlatElement {
4
+ name?: string;
5
+ type?: string;
6
+ dataType?: string;
7
+ range?: boolean;
8
+ recordTimestamp?: boolean;
9
+ }
10
+
11
+ interface INode extends IFlatElement {
12
+ elements?: unknown[];
13
+ tabs?: { elements?: unknown[] }[];
14
+ }
15
+
16
+ const nodeOf = (element: unknown): INode => (element ?? {}) as INode;
17
+
18
+ const childrenOf = (node: INode): unknown[] =>
19
+ node.type === "tab" ? (node.tabs ?? []).flatMap((tab) => tab.elements ?? []) : (node.elements ?? []);
20
+
21
+ const isContainer = (node: INode): boolean => node.type === "tab" || node.type === "fieldset";
22
+
23
+ // Campos de um mesmo nível: entra em tabs e fieldsets; o array conta como um campo, sem os de dentro.
24
+ export const flattenElements = (elements: unknown[] | undefined): IFlatElement[] =>
25
+ (elements ?? []).map(nodeOf).flatMap((node: INode): IFlatElement[] => (isContainer(node) ? flattenElements(childrenOf(node)) : [node]));
26
+
27
+ // Cada nível de campos separado: o form e, depois, o item de cada array (também os aninhados).
28
+ export const fieldScopes = (elements: unknown[] | undefined): IFlatElement[][] => {
29
+ const fields: IFlatElement[] = flattenElements(elements);
30
+ const nested: IFlatElement[][] = fields
31
+ .filter((field: IFlatElement) => field.type === "array")
32
+ .flatMap((field: IFlatElement) => fieldScopes(nodeOf(field).elements));
33
+ return [fields, ...nested];
34
+ };
35
+
36
+ // Todos os campos, inclusive os de dentro dos arrays.
37
+ export const allFields = (elements: unknown[] | undefined): IFlatElement[] => fieldScopes(elements).flat();
38
+
39
+ export const NUMERIC_DATA_TYPES: string[] = [
40
+ EDataType.NUMBER,
41
+ EDataType.INTEGER,
42
+ EDataType.DECIMAL,
43
+ EDataType.NUMERIC,
44
+ EDataType.FLOAT,
45
+ EDataType.DOUBLE,
46
+ EDataType.REAL,
47
+ EDataType.CURRENCY,
48
+ ];
@@ -0,0 +1,34 @@
1
+ import type { IComponent, IModule, IProject } from "../interfaces/project.interface";
2
+ import { fieldScopes, type IFlatElement } from "./form-elements";
3
+
4
+ const RESERVED_FIELDS: string[] = ["createdAt", "createdBy", "updatedAt", "updatedBy", "deletedAt", "workspaceId"];
5
+ const CONSENT_SUFFIXES: string[] = ["At", "By", "RevokedAt", "RevokedBy"];
6
+
7
+ const scopeWarnings = (id: string, fields: IFlatElement[], isRoot: boolean): string[] => {
8
+ const names = new Set(fields.map((field: IFlatElement) => field.name).filter(Boolean));
9
+ const reserved: string[] = isRoot ? RESERVED_FIELDS : [];
10
+ const warnings: string[] = [];
11
+ for (const field of fields) {
12
+ if (field.type === "datepicker" && field.range === true) {
13
+ warnings.push(id + ": \"" + field.name + "\" tem range, que só vale em listFilters; no form vira uma data simples");
14
+ }
15
+ if (field.type === "switch" && field.recordTimestamp === true && field.name) {
16
+ for (const generated of CONSENT_SUFFIXES.map((suffix: string) => field.name + suffix)) {
17
+ if (reserved.includes(generated) || names.has(generated)) {
18
+ warnings.push(id + ": recordTimestamp em \"" + field.name + "\" gera o campo \"" + generated + "\", que já existe");
19
+ }
20
+ }
21
+ }
22
+ }
23
+ return warnings;
24
+ };
25
+
26
+ const formWarnings = (component: IComponent): string[] =>
27
+ component.componentType === "form"
28
+ ? fieldScopes(component.elements).flatMap((fields: IFlatElement[], index: number) => scopeWarnings(component.id, fields, index === 0))
29
+ : [];
30
+
31
+ // Regras de formulário que o schema não consegue conferir (range fora de filtro, colisão do recordTimestamp),
32
+ // no form e dentro de cada item de array.
33
+ export const checkFormReferences = (project: IProject): string[] =>
34
+ (project.modules ?? []).flatMap((module: IModule): string[] => module.components.flatMap(formWarnings));
@@ -1,51 +1,99 @@
1
1
  import type { IList } from "../interfaces/list.interface";
2
2
  import type { IComponent, IModule, IProject } from "../interfaces/project.interface";
3
+ import { allFields, fieldScopes, NUMERIC_DATA_TYPES, type IFlatElement } from "./form-elements";
3
4
 
4
- interface INamedNode {
5
- name?: string;
6
- elements?: unknown[];
7
- tabs?: { elements?: unknown[] }[];
5
+ interface IModuleFields {
6
+ names: Set<string>;
7
+ fields: Map<string, IFlatElement>;
8
8
  }
9
9
 
10
- const namesOf = (elements: unknown[] | undefined): string[] =>
11
- (elements ?? []).flatMap((element: unknown): string[] => {
12
- const node = (element ?? {}) as INamedNode;
13
- return [
14
- ...(node.name ? [node.name] : []),
15
- ...namesOf(node.elements),
16
- ...namesOf((node.tabs ?? []).flatMap((tab) => tab.elements ?? [])),
17
- ];
18
- });
10
+ const namesOf = (elements: unknown[] | undefined): Set<string> =>
11
+ new Set(allFields(elements).flatMap((field: IFlatElement): string[] => (field.name ? [field.name] : [])));
19
12
 
20
13
  const isList = (component: IComponent): component is IList => component.componentType === "list";
21
14
 
22
- const formNamesOf = (module: IModule): Set<string> =>
23
- new Set(
24
- module.components.flatMap((component: IComponent): string[] =>
25
- component.componentType === "form" ? namesOf(component.elements) : [],
26
- ),
15
+ const namedFields = (fields: IFlatElement[]): [string, IFlatElement][] =>
16
+ fields.flatMap((field: IFlatElement): [string, IFlatElement][] => (field.name ? [[field.name, field]] : []));
17
+
18
+ // names: todos os campos, inclusive de arrays (tabs.property). fields: só o nível de cima de cada form,
19
+ // que é o que o registro tem e o que os KPIs conseguem contar e somar.
20
+ const moduleFieldsOf = (module: IModule): IModuleFields => {
21
+ const elementsOf = (component: IComponent): unknown[] | undefined =>
22
+ component.componentType === "form" ? component.elements : undefined;
23
+ const forms: IComponent[] = module.components.filter((component: IComponent) => component.componentType === "form");
24
+ return {
25
+ names: new Set(namedFields(forms.flatMap((form: IComponent) => allFields(elementsOf(form)))).map(([name]) => name)),
26
+ fields: new Map(namedFields(forms.flatMap((form: IComponent) => fieldScopes(elementsOf(form))[0]))),
27
+ };
28
+ };
29
+
30
+ const columnViewWarnings = (list: IList): string[] => {
31
+ const properties = new Set(list.listItems.map((item) => item.property).filter(Boolean));
32
+ return (list.columnViews ?? []).flatMap((view) =>
33
+ view.columns
34
+ .filter((column: string) => !properties.has(column))
35
+ .map((column: string) => list.id + ": columnViews cita a coluna \"" + column + "\", que não está em listItems"),
27
36
  );
37
+ };
38
+
39
+ const columnGroupWarnings = (list: IList): string[] => {
40
+ const groups: string[] = list.listItems.filter((item) => item.columnGroup).map((item) => JSON.stringify(item.columnGroup));
41
+ const seen: string[] = [];
42
+ const warnings: string[] = [];
43
+ groups.forEach((group: string, index: number) => {
44
+ if (index > 0 && group !== groups[index - 1] && seen.includes(group)) {
45
+ warnings.push(list.id + ": o columnGroup " + group + " aparece separado; deixe as colunas do mesmo grupo juntas");
46
+ }
47
+ if (!seen.includes(group)) seen.push(group);
48
+ });
49
+ return warnings;
50
+ };
51
+
52
+ const kpiWarnings = (list: IList, fields: Map<string, IFlatElement>): string[] => {
53
+ const kpis = list.kpis ?? [];
54
+ const warnings: string[] = [];
55
+ if (kpis.filter((kpi) => kpi.tone === "brand").length > 1) {
56
+ warnings.push(list.id + ": mais de um KPI com tone \"brand\"; use no máximo um");
57
+ }
58
+ for (const kpi of kpis) {
59
+ if (kpi.sumOf) {
60
+ const field = fields.get(kpi.sumOf);
61
+ if (!field) warnings.push(list.id + ": kpis.sumOf \"" + kpi.sumOf + "\" não existe no nível de cima de nenhum form do módulo (campos de array não valem)");
62
+ else if (!NUMERIC_DATA_TYPES.includes((field.dataType ?? "").toLowerCase())) {
63
+ warnings.push(list.id + ": kpis.sumOf \"" + kpi.sumOf + "\" não é um campo numérico");
64
+ }
65
+ }
66
+ for (const condition of Array.isArray(kpi.filter) ? kpi.filter : []) {
67
+ if (!fields.has(condition.field)) {
68
+ warnings.push(list.id + ": kpis.filter cita o campo \"" + condition.field + "\", que não existe no nível de cima de nenhum form do módulo (campos de array não valem)");
69
+ }
70
+ }
71
+ }
72
+ return warnings;
73
+ };
28
74
 
29
- const listWarnings = (list: IList, formNames: Set<string>): string[] => {
75
+ const listWarnings = (list: IList, moduleFields: IModuleFields): string[] => {
30
76
  const warnings: string[] = [];
31
- const filterNames = new Set(namesOf(list.listFilters));
77
+ const filterNames: Set<string> = namesOf(list.listFilters);
32
78
  for (const name of list.quickFilters ?? []) {
33
79
  if (!filterNames.has(name)) {
34
80
  warnings.push(list.id + ": quickFilters cita \"" + name + "\", que não está em listFilters");
35
81
  }
36
82
  }
37
83
  const tabs = list.tabs;
38
- if (tabs && !tabs.options?.length && !formNames.has(tabs.property)) {
84
+ if (tabs && !tabs.options?.length && !moduleFields.names.has(tabs.property)) {
39
85
  warnings.push(
40
86
  list.id + ": tabs.property \"" + tabs.property + "\" não existe em nenhum form do módulo e tabs.options está vazio",
41
87
  );
42
88
  }
43
- return warnings;
89
+ return [...warnings, ...columnViewWarnings(list), ...columnGroupWarnings(list), ...kpiWarnings(list, moduleFields.fields)];
44
90
  };
45
91
 
46
- // Nomes citados por texto (quickFilters e tabs.property) que o schema não consegue conferir.
92
+ // Nomes citados por texto (quickFilters, tabs.property, columnViews, kpis) que o schema não consegue conferir.
47
93
  export const checkListReferences = (project: IProject): string[] =>
48
94
  (project.modules ?? []).flatMap((module: IModule): string[] => {
49
- const formNames = formNamesOf(module);
50
- return module.components.filter(isList).flatMap((list: IList) => listWarnings(list, formNames));
95
+ const lists: IList[] = module.components.filter(isList);
96
+ if (lists.length === 0) return [];
97
+ const moduleFields: IModuleFields = moduleFieldsOf(module);
98
+ return lists.flatMap((list: IList) => listWarnings(list, moduleFields));
51
99
  });