@table-bro/mcp 0.0.0-stage → 1.2.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/LICENSE +21 -0
- package/README.md +97 -2
- package/dist/docs/docs.d.ts +21 -0
- package/dist/docs/docs.js +103 -0
- package/dist/docs/pages.d.ts +28 -0
- package/dist/docs/pages.js +2734 -0
- package/dist/docs/topics.d.ts +11 -0
- package/dist/docs/topics.js +410 -0
- package/dist/extension.d.ts +23 -0
- package/dist/extension.js +1 -0
- package/dist/generate/angular.d.ts +26 -0
- package/dist/generate/angular.js +241 -0
- package/dist/generate/cells.d.ts +22 -0
- package/dist/generate/cells.js +157 -0
- package/dist/generate/code.d.ts +48 -0
- package/dist/generate/code.js +153 -0
- package/dist/generate/config.d.ts +16 -0
- package/dist/generate/config.js +95 -0
- package/dist/generate/fillings.d.ts +49 -0
- package/dist/generate/fillings.js +130 -0
- package/dist/generate/filters.d.ts +36 -0
- package/dist/generate/filters.js +254 -0
- package/dist/generate/generate-code.d.ts +34 -0
- package/dist/generate/generate-code.js +59 -0
- package/dist/generate/names.d.ts +52 -0
- package/dist/generate/names.js +93 -0
- package/dist/generate/rows.d.ts +5 -0
- package/dist/generate/rows.js +22 -0
- package/dist/generate/scaffold.d.ts +35 -0
- package/dist/generate/scaffold.js +62 -0
- package/dist/generate/service.d.ts +16 -0
- package/dist/generate/service.js +320 -0
- package/dist/generate/setup.d.ts +34 -0
- package/dist/generate/setup.js +158 -0
- package/dist/generate/vanilla.d.ts +10 -0
- package/dist/generate/vanilla.js +160 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +10 -0
- package/dist/project/inspect-project.d.ts +53 -0
- package/dist/project/inspect-project.js +223 -0
- package/dist/server/main.d.ts +2 -0
- package/dist/server/main.js +8 -0
- package/dist/server/server.d.ts +17 -0
- package/dist/server/server.js +212 -0
- package/dist/spec/builtin-specs.d.ts +13 -0
- package/dist/spec/builtin-specs.js +167 -0
- package/dist/spec/css-variables.d.ts +22 -0
- package/dist/spec/css-variables.js +54 -0
- package/dist/spec/schema.d.ts +19 -0
- package/dist/spec/schema.js +278 -0
- package/dist/spec/skin-config.d.ts +30 -0
- package/dist/spec/skin-config.js +67 -0
- package/dist/spec/spec.d.ts +157 -0
- package/dist/spec/spec.js +2 -0
- package/dist/spec/validate-spec.d.ts +54 -0
- package/dist/spec/validate-spec.js +979 -0
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/package.json +71 -4
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { validateSpec } from '../spec/validate-spec.js';
|
|
2
|
+
import { angularTable } from './angular.js';
|
|
3
|
+
import { angularClasses, fillingsErrors } from './fillings.js';
|
|
4
|
+
import { setupSteps, skinFeatures } from './setup.js';
|
|
5
|
+
import { vanillaTable } from './vanilla.js';
|
|
6
|
+
/**
|
|
7
|
+
* Writes the code of a table from its spec for a target and a skin: a pure function, the spec and the fillings in,
|
|
8
|
+
* the files out. It checks the spec first and writes nothing for a spec with errors.
|
|
9
|
+
*/
|
|
10
|
+
export function generateCode(spec, options) {
|
|
11
|
+
const { target, skin } = options;
|
|
12
|
+
const report = validateSpec(spec, { skin, extensions: options.extensions, limits: options.limits });
|
|
13
|
+
if (target === 'vanilla' && skin === 'mat') {
|
|
14
|
+
report.valid = false;
|
|
15
|
+
report.errors.push({ path: '', message: 'the mat skin is for Angular', fix: 'use the target angular, or the skin bs or nv' });
|
|
16
|
+
}
|
|
17
|
+
// Fillings of another form would fail the generator: they are errors of the fillings, with their paths
|
|
18
|
+
const fillingIssues = fillingsErrors(options.fillings);
|
|
19
|
+
if (fillingIssues.length) {
|
|
20
|
+
report.valid = false;
|
|
21
|
+
report.errors.push(...fillingIssues);
|
|
22
|
+
}
|
|
23
|
+
// An import that the generator cannot place would crash it: it is an error of the fillings, with the path
|
|
24
|
+
for (const [cell, skins] of Object.entries(fillingIssues.length ? {} : options.fillings?.cells ?? {})) {
|
|
25
|
+
for (const [fillingSkin, filling] of Object.entries(skins ?? {})) {
|
|
26
|
+
(filling?.imports ?? []).forEach((item, index) => {
|
|
27
|
+
const known = (typeof item === 'string') ? Boolean(angularClasses[item]) : (typeof item?.name === 'string' && typeof item?.from === 'string');
|
|
28
|
+
if (!known) {
|
|
29
|
+
report.valid = false;
|
|
30
|
+
report.errors.push({
|
|
31
|
+
path: `fillings.cells.${cell}.${fillingSkin}.imports[${index}]`,
|
|
32
|
+
message: `${JSON.stringify(item)} is not an import that the generator can place`,
|
|
33
|
+
fix: 'give {"name": "OrderBadge", "from": "./order-badge"} for a class of the project; the classes of Angular Material and the pipes of Angular come from the template, and a string is only the name of such a class'
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (!report.valid) {
|
|
40
|
+
return { report, files: [], setup: [], todo: [] };
|
|
41
|
+
}
|
|
42
|
+
const fillings = options.fillings ?? {};
|
|
43
|
+
const extensions = options.extensions ?? [];
|
|
44
|
+
const table = (target === 'angular') ? angularTable(spec, skin, fillings, options.tagSuffix, extensions, options.simulateServer) : vanillaTable(spec, skin, fillings, options.tagSuffix, extensions);
|
|
45
|
+
// The cells of an Angular project are Angular components in every skin: they become Custom Elements with @angular/elements
|
|
46
|
+
const elements = (target === 'angular' && skin !== 'mat' && Boolean(spec.cells?.length)) ? ['@angular/elements'] : [];
|
|
47
|
+
// A module joins the setup when the spec uses one of its fields
|
|
48
|
+
const modules = extensions.filter(extension => Object.keys(extension.config ?? {}).some(field => (spec.config ?? {})[field] !== undefined));
|
|
49
|
+
// The page of an Angular server table loads the answers of its API with HttpClient; the simulated server needs none
|
|
50
|
+
const http = (target === 'angular' && spec.config?.server && (spec.api || !options.simulateServer))
|
|
51
|
+
? [{
|
|
52
|
+
title: 'Provide HttpClient',
|
|
53
|
+
text: 'The table loads its rows from the API with HttpClient. In the providers of `app.config.ts`:',
|
|
54
|
+
code: "import {provideHttpClient} from '@angular/common/http';\n\n// providers: [..., provideHttpClient()]",
|
|
55
|
+
language: 'typescript'
|
|
56
|
+
}]
|
|
57
|
+
: [];
|
|
58
|
+
return { report, files: table.files, setup: [...setupSteps(target, skin, elements, skinFeatures(spec, skin)), ...http, ...modules.flatMap(extension => (extension.setup ?? []).map(step => ({ ...step, module: extension.package })))], todo: table.todo };
|
|
59
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import type { BroTableSpec } from '../spec/spec.js';
|
|
2
|
+
/**
|
|
3
|
+
* The names of the generated code, from the type of the row and the names of the cells.
|
|
4
|
+
*/
|
|
5
|
+
export declare class BroNames {
|
|
6
|
+
readonly rowType: string;
|
|
7
|
+
private tagSuffix;
|
|
8
|
+
/** order or purchase-request: the part of the tags, the files and the id. */
|
|
9
|
+
readonly kebab: string;
|
|
10
|
+
/**
|
|
11
|
+
* @param rowType - the type of the row in the generated code, as Order; the names follow it
|
|
12
|
+
* @param tagSuffix - the suffix of the tags of the cells: the site defines new Custom Elements for every generation,
|
|
13
|
+
* and a tag cannot be defined twice
|
|
14
|
+
*/
|
|
15
|
+
constructor(rowType: string, tagSuffix?: string);
|
|
16
|
+
static of(spec: BroTableSpec, tagSuffix?: string): BroNames;
|
|
17
|
+
/** The folder of the generated files. */
|
|
18
|
+
get folder(): string;
|
|
19
|
+
get tableId(): string;
|
|
20
|
+
/** The id of the container of the Filter Drawer of the bs and nv skins. */
|
|
21
|
+
get drawerId(): string;
|
|
22
|
+
/** OrderFilterValues: the values of the filters, as the class of their component takes OrderFilters. */
|
|
23
|
+
get filtersType(): string;
|
|
24
|
+
/** OrderFilters: the component of the filters, without the suffix Component, as ng generate names it since Angular 20. */
|
|
25
|
+
get filtersClass(): string;
|
|
26
|
+
/** The file of the filters, from the folder of the page. */
|
|
27
|
+
get filtersFile(): string;
|
|
28
|
+
/** app-order-filters: the filters are a component of the application, as the page app-order-table. */
|
|
29
|
+
get filtersSelector(): string;
|
|
30
|
+
/** OrderTable: the page, without the suffix Component, as ng generate names it since Angular 20. */
|
|
31
|
+
get pageClass(): string;
|
|
32
|
+
/** The file of the page, from its folder. */
|
|
33
|
+
get pageFile(): string;
|
|
34
|
+
get pageSelector(): string;
|
|
35
|
+
/** The service of a server table: it maps the queries of the table and the answers of the API. */
|
|
36
|
+
get serviceClass(): string;
|
|
37
|
+
/** The file of the service, from the folder of the page. */
|
|
38
|
+
get serviceFile(): string;
|
|
39
|
+
/** The request, the answer and an item of the answer of the API of a server table. */
|
|
40
|
+
get apiQueryType(): string;
|
|
41
|
+
get apiPageType(): string;
|
|
42
|
+
get apiItemType(): string;
|
|
43
|
+
/** bro-cell-order-status for the cell status of the type Order: the prefix bro-cell- belongs to the application. */
|
|
44
|
+
tag(cell: string): string;
|
|
45
|
+
/**
|
|
46
|
+
* OrderStatusCell for the cell status of the type Order: the prefix Bro belongs to the library, and the suffix Cell
|
|
47
|
+
* keeps the names of the cells apart from the page, the filters and the types of the row.
|
|
48
|
+
*/
|
|
49
|
+
cellClass(cell: string): string;
|
|
50
|
+
/** The file of a cell, from the folder of the page: order-status-cell. */
|
|
51
|
+
cellFile(cell: string): string;
|
|
52
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The names of the generated code, from the type of the row and the names of the cells.
|
|
3
|
+
*/
|
|
4
|
+
export class BroNames {
|
|
5
|
+
rowType;
|
|
6
|
+
tagSuffix;
|
|
7
|
+
/** order or purchase-request: the part of the tags, the files and the id. */
|
|
8
|
+
kebab;
|
|
9
|
+
/**
|
|
10
|
+
* @param rowType - the type of the row in the generated code, as Order; the names follow it
|
|
11
|
+
* @param tagSuffix - the suffix of the tags of the cells: the site defines new Custom Elements for every generation,
|
|
12
|
+
* and a tag cannot be defined twice
|
|
13
|
+
*/
|
|
14
|
+
constructor(rowType, tagSuffix = '') {
|
|
15
|
+
this.rowType = rowType;
|
|
16
|
+
this.tagSuffix = tagSuffix;
|
|
17
|
+
this.kebab = rowType.replace(/([a-z0-9])([A-Z])/g, '$1-$2').toLowerCase();
|
|
18
|
+
}
|
|
19
|
+
static of(spec, tagSuffix = '') {
|
|
20
|
+
return new BroNames(spec.rowType, tagSuffix);
|
|
21
|
+
}
|
|
22
|
+
/** The folder of the generated files. */
|
|
23
|
+
get folder() {
|
|
24
|
+
return `${this.kebab}-table`;
|
|
25
|
+
}
|
|
26
|
+
get tableId() {
|
|
27
|
+
return `${this.kebab}-table${this.tagSuffix ? `-${this.tagSuffix}` : ''}`;
|
|
28
|
+
}
|
|
29
|
+
/** The id of the container of the Filter Drawer of the bs and nv skins. */
|
|
30
|
+
get drawerId() {
|
|
31
|
+
return `${this.tableId}-filters`;
|
|
32
|
+
}
|
|
33
|
+
/** OrderFilterValues: the values of the filters, as the class of their component takes OrderFilters. */
|
|
34
|
+
get filtersType() {
|
|
35
|
+
return `${this.rowType}FilterValues`;
|
|
36
|
+
}
|
|
37
|
+
/** OrderFilters: the component of the filters, without the suffix Component, as ng generate names it since Angular 20. */
|
|
38
|
+
get filtersClass() {
|
|
39
|
+
return `${this.rowType}Filters`;
|
|
40
|
+
}
|
|
41
|
+
/** The file of the filters, from the folder of the page. */
|
|
42
|
+
get filtersFile() {
|
|
43
|
+
return `${this.kebab}-filters`;
|
|
44
|
+
}
|
|
45
|
+
/** app-order-filters: the filters are a component of the application, as the page app-order-table. */
|
|
46
|
+
get filtersSelector() {
|
|
47
|
+
return `app-${this.kebab}-filters`;
|
|
48
|
+
}
|
|
49
|
+
/** OrderTable: the page, without the suffix Component, as ng generate names it since Angular 20. */
|
|
50
|
+
get pageClass() {
|
|
51
|
+
return `${this.rowType}Table`;
|
|
52
|
+
}
|
|
53
|
+
/** The file of the page, from its folder. */
|
|
54
|
+
get pageFile() {
|
|
55
|
+
return `${this.kebab}-table`;
|
|
56
|
+
}
|
|
57
|
+
get pageSelector() {
|
|
58
|
+
return `app-${this.kebab}-table`;
|
|
59
|
+
}
|
|
60
|
+
/** The service of a server table: it maps the queries of the table and the answers of the API. */
|
|
61
|
+
get serviceClass() {
|
|
62
|
+
return `${this.rowType}Service`;
|
|
63
|
+
}
|
|
64
|
+
/** The file of the service, from the folder of the page. */
|
|
65
|
+
get serviceFile() {
|
|
66
|
+
return `${this.kebab}.service`;
|
|
67
|
+
}
|
|
68
|
+
/** The request, the answer and an item of the answer of the API of a server table. */
|
|
69
|
+
get apiQueryType() {
|
|
70
|
+
return `${this.rowType}ApiQuery`;
|
|
71
|
+
}
|
|
72
|
+
get apiPageType() {
|
|
73
|
+
return `${this.rowType}ApiPage`;
|
|
74
|
+
}
|
|
75
|
+
get apiItemType() {
|
|
76
|
+
return `${this.rowType}ApiItem`;
|
|
77
|
+
}
|
|
78
|
+
/** bro-cell-order-status for the cell status of the type Order: the prefix bro-cell- belongs to the application. */
|
|
79
|
+
tag(cell) {
|
|
80
|
+
return `bro-cell-${this.kebab}-${cell}${this.tagSuffix ? `-${this.tagSuffix}` : ''}`;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* OrderStatusCell for the cell status of the type Order: the prefix Bro belongs to the library, and the suffix Cell
|
|
84
|
+
* keeps the names of the cells apart from the page, the filters and the types of the row.
|
|
85
|
+
*/
|
|
86
|
+
cellClass(cell) {
|
|
87
|
+
return `${this.rowType}${cell.split('-').map(part => part[0].toUpperCase() + part.slice(1)).join('')}Cell`;
|
|
88
|
+
}
|
|
89
|
+
/** The file of a cell, from the folder of the page: order-status-cell. */
|
|
90
|
+
cellFile(cell) {
|
|
91
|
+
return `${this.kebab}-${cell}-cell`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { BroTableSpec } from '../spec/spec.js';
|
|
2
|
+
/** The file of the type of the row and of the type of its filters. */
|
|
3
|
+
export declare function rowTypeCode(spec: BroTableSpec): string;
|
|
4
|
+
/** The rule of the CSS variables on the element itself: a value from an ancestor does not reach it. */
|
|
5
|
+
export declare function cssVarsRule(id: string, vars: [string, string][]): string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { blockComment, imports } from './code.js';
|
|
2
|
+
import { BroFiltersCode } from './filters.js';
|
|
3
|
+
/** The file of the type of the row and of the type of its filters. */
|
|
4
|
+
export function rowTypeCode(spec) {
|
|
5
|
+
const filters = new BroFiltersCode(spec);
|
|
6
|
+
return [
|
|
7
|
+
imports({ 'type @table-bro/core': filters.filters.length ? ['BroFilters', 'BroRow'] : ['BroRow'] }),
|
|
8
|
+
'',
|
|
9
|
+
`export interface ${spec.rowType} extends BroRow {`,
|
|
10
|
+
spec.fields.map(field => [
|
|
11
|
+
...(field.values ? [` /** ${blockComment(field.values.join(', '))} */`] : []),
|
|
12
|
+
` ${field.name}: ${field.type};`
|
|
13
|
+
].join('\n')).join('\n'),
|
|
14
|
+
'}',
|
|
15
|
+
...(filters.filters.length ? ['', filters.typeCode()] : []),
|
|
16
|
+
''
|
|
17
|
+
].join('\n');
|
|
18
|
+
}
|
|
19
|
+
/** The rule of the CSS variables on the element itself: a value from an ancestor does not reach it. */
|
|
20
|
+
export function cssVarsRule(id, vars) {
|
|
21
|
+
return `#${id} {\n${vars.map(([name, value]) => ` ${name}: ${value};`).join('\n')}\n}`;
|
|
22
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { BroSpecField, BroSpecFilter, BroSpecSkin } from '../spec/spec.js';
|
|
2
|
+
import { type BroSpecReport } from '../spec/validate-spec.js';
|
|
3
|
+
import { type BroCellFilling } from './fillings.js';
|
|
4
|
+
import type { BroTarget } from './setup.js';
|
|
5
|
+
export interface BroScaffoldRequest {
|
|
6
|
+
kind: 'cell' | 'details' | 'filters';
|
|
7
|
+
target: BroTarget;
|
|
8
|
+
skin: BroSpecSkin;
|
|
9
|
+
rowType: string;
|
|
10
|
+
/** The fields of the row: the names for a cell, the names and types for filters. */
|
|
11
|
+
fields: BroSpecField[];
|
|
12
|
+
/** A cell or details: its name in kebab-case. */
|
|
13
|
+
name?: string;
|
|
14
|
+
/** A cell or details: what it shows, in words. */
|
|
15
|
+
shows?: string;
|
|
16
|
+
/** A cell: the fields it reads. */
|
|
17
|
+
reads?: string[];
|
|
18
|
+
/** A cell: the actions it sends. */
|
|
19
|
+
actions?: string[];
|
|
20
|
+
filters?: BroSpecFilter[];
|
|
21
|
+
filling?: BroCellFilling;
|
|
22
|
+
}
|
|
23
|
+
export interface BroScaffold {
|
|
24
|
+
report: BroSpecReport;
|
|
25
|
+
/** The file from the folder of the page. */
|
|
26
|
+
path: string;
|
|
27
|
+
content: string;
|
|
28
|
+
/** How the page connects it: the registration and the column, or the container of the Filter Drawer. */
|
|
29
|
+
connect: string;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* One component for an existing table: a cell, the row details or the filters of the Filter Drawer, by the recipe
|
|
33
|
+
* of the generator. The request is checked as a small spec, so the messages are the messages of validate_spec.
|
|
34
|
+
*/
|
|
35
|
+
export declare function scaffoldComponent(request: BroScaffoldRequest): BroScaffold;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { validateSpec } from '../spec/validate-spec.js';
|
|
2
|
+
import { cellCode } from './cells.js';
|
|
3
|
+
import { literal, quote } from './code.js';
|
|
4
|
+
import { fillingErrors } from './fillings.js';
|
|
5
|
+
import { BroFiltersCode } from './filters.js';
|
|
6
|
+
import { BroNames } from './names.js';
|
|
7
|
+
/**
|
|
8
|
+
* One component for an existing table: a cell, the row details or the filters of the Filter Drawer, by the recipe
|
|
9
|
+
* of the generator. The request is checked as a small spec, so the messages are the messages of validate_spec.
|
|
10
|
+
*/
|
|
11
|
+
export function scaffoldComponent(request) {
|
|
12
|
+
const { kind, target, skin, rowType } = request;
|
|
13
|
+
const cell = (kind !== 'filters') ? { name: request.name ?? kind, kind: kind === 'details' ? 'details' : 'cell', shows: request.shows ?? '', fields: request.reads ?? [], actions: request.actions } : undefined;
|
|
14
|
+
const spec = {
|
|
15
|
+
specVersion: 1,
|
|
16
|
+
rowType,
|
|
17
|
+
fields: request.fields,
|
|
18
|
+
cols: (kind === 'cell') ? [{ title: '', component: { cell: cell.name } }] : [{ title: '', name: request.fields[0]?.name }],
|
|
19
|
+
cells: cell ? [cell] : undefined,
|
|
20
|
+
filters: (kind === 'filters') ? request.filters : undefined,
|
|
21
|
+
config: (kind === 'details') ? { rowDetailsComponent: { cell: cell.name } } : undefined
|
|
22
|
+
};
|
|
23
|
+
const report = validateSpec(spec, { skin });
|
|
24
|
+
if (target === 'vanilla' && skin === 'mat') {
|
|
25
|
+
report.valid = false;
|
|
26
|
+
report.errors.push({ path: '', message: 'the mat skin is for Angular', fix: 'use the target angular, or the skin bs or nv' });
|
|
27
|
+
}
|
|
28
|
+
if (kind === 'filters' && !request.filters?.length) {
|
|
29
|
+
report.valid = false;
|
|
30
|
+
report.errors.push({ path: 'filters', message: 'the filters of the drawer need at least one filter', fix: 'give the filters as the filters of a spec, get_docs topic filters' });
|
|
31
|
+
}
|
|
32
|
+
if (kind !== 'filters' && request.filling !== undefined) {
|
|
33
|
+
const fillingIssues = fillingErrors(request.filling, 'filling');
|
|
34
|
+
report.valid &&= !fillingIssues.length;
|
|
35
|
+
report.errors.push(...fillingIssues);
|
|
36
|
+
}
|
|
37
|
+
if (!report.valid) {
|
|
38
|
+
return { report, path: '', content: '', connect: '' };
|
|
39
|
+
}
|
|
40
|
+
if (kind === 'filters') {
|
|
41
|
+
const filters = new BroFiltersCode(spec);
|
|
42
|
+
return {
|
|
43
|
+
report,
|
|
44
|
+
path: `${BroNames.of(spec).filtersFile}.ts`,
|
|
45
|
+
content: (target === 'angular') ? filters.angularComponent(skin) : filters.vanillaForm(skin),
|
|
46
|
+
connect: [
|
|
47
|
+
`The type of the filters, next to the type ${rowType}:\n\n\`\`\`ts\n${filters.typeCode()}\n\`\`\``,
|
|
48
|
+
`filtersTransform of the local mode, in the config:\n\n\`\`\`ts\nfiltersTransform: ${filters.transformCode()}\n\`\`\``,
|
|
49
|
+
'The container of the Filter Drawer around the table: see get_docs with the topic filters.'
|
|
50
|
+
].join('\n\n')
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
const code = cellCode(spec, cell, target, request.filling);
|
|
54
|
+
const define = code.angular ? `customElements.define(${quote(code.tag)}, createCustomElement(${code.className}, {injector: this.injector}));` : `customElements.define(${quote(code.tag)}, ${code.className});`;
|
|
55
|
+
const use = (kind === 'details') ? `In the config: rowDetailsComponent: ${quote(code.tag)}` : `The column:\n\n\`\`\`ts\n${literal({ title: '', component: { selector: code.tag, event: cell.actions?.length ? 'action' : undefined } })}\n\`\`\``;
|
|
56
|
+
return {
|
|
57
|
+
report,
|
|
58
|
+
path: `${code.file}.ts`,
|
|
59
|
+
content: code.content,
|
|
60
|
+
connect: [`The registration, once before the table is created, with a customElements.get guard:\n\n\`\`\`ts\n${define}\n\`\`\``, use].join('\n\n')
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { BroTableSpec } from '../spec/spec.js';
|
|
2
|
+
import type { BroFiltersCode } from './filters.js';
|
|
3
|
+
/**
|
|
4
|
+
* Where a server table takes its rows: the API of the project, the simulated server of the site, or the API of the spec
|
|
5
|
+
* that gives its rows page by page or all at once.
|
|
6
|
+
*/
|
|
7
|
+
export type BroServerSource = 'project' | 'simulated' | 'api-pages' | 'api';
|
|
8
|
+
/**
|
|
9
|
+
* The service of a server table, as BroService of @table-bro/angular: loadPage sends the request of a query of the table
|
|
10
|
+
* and gives the rows of its page with the number of all rows; mapServerQuery turns the query into the request of the API,
|
|
11
|
+
* and mapServerResponse the answer of the API into the rows. The page only delivers the rows to the table. The simulated
|
|
12
|
+
* server of the site is a REST API with names of its own, so its service maps as the service of a real API does.
|
|
13
|
+
*/
|
|
14
|
+
export declare function serviceCode(spec: BroTableSpec, source: BroServerSource, filtersCode?: BroFiltersCode): string;
|
|
15
|
+
/** The fields of a row whose values come from other names of the API: the API sorts by its own names. */
|
|
16
|
+
export declare function renamedSources(spec: BroTableSpec): [string, string][];
|