@antelopejs/interface-dms-builder 0.4.0 → 0.5.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/README.md +4 -4
- package/dist/addressing.d.ts +6 -0
- package/dist/analysis.d.ts +73 -0
- package/dist/analysis.js +18 -1
- package/dist/analysis.js.map +1 -1
- package/dist/catalog.d.ts +139 -1
- package/dist/compose.d.ts +44 -0
- package/dist/compose.js +7 -0
- package/dist/compose.js.map +1 -1
- package/dist/database.d.ts +230 -0
- package/dist/database.js +80 -0
- package/dist/database.js.map +1 -0
- package/dist/drafts.d.ts +61 -0
- package/dist/drafts.js +21 -0
- package/dist/drafts.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mapping.d.ts +122 -0
- package/dist/mapping.js +15 -0
- package/dist/mapping.js.map +1 -1
- package/dist/operation-map.d.ts +27 -1
- package/dist/operation-map.js +22 -0
- package/dist/operation-map.js.map +1 -1
- package/dist/operations.d.ts +57 -0
- package/dist/operations.js +18 -0
- package/dist/operations.js.map +1 -1
- package/dist/project.d.ts +63 -1
- package/dist/project.js +10 -0
- package/dist/project.js.map +1 -1
- package/dist/queries.d.ts +125 -0
- package/dist/resources.d.ts +132 -0
- package/dist/resources.js +9 -0
- package/dist/resources.js.map +1 -1
- package/dist/results.d.ts +49 -1
- package/dist/structure.d.ts +42 -0
- package/dist/table-view.d.ts +49 -0
- package/dist/table-view.js +7 -0
- package/dist/table-view.js.map +1 -1
- package/dist/theme.d.ts +144 -0
- package/dist/theme.js +46 -0
- package/dist/theme.js.map +1 -0
- package/dist/values.d.ts +64 -0
- package/dist/values.js +7 -0
- package/dist/values.js.map +1 -1
- package/docs/1.introduction.md +3 -0
- package/docs/10.a-chart-without-code.md +7 -7
- package/docs/11.external-databases.md +16 -11
- package/docs/11.theme-and-branding.md +135 -0
- package/docs/12.connect-a-database.md +87 -0
- package/docs/4.page-operations.md +1 -1
- package/package.json +15 -8
package/dist/project.js
CHANGED
|
@@ -2,8 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.CreateLocalModule = exports.ConfigureModule = exports.AddModule = exports.ConfigureProject = void 0;
|
|
4
4
|
const interface_core_1 = require("@antelopejs/interface-core");
|
|
5
|
+
/**
|
|
6
|
+
* Applies steps to `antelope.config.ts` in order, as one edit: every step is validated before
|
|
7
|
+
* anything is written, and none is written if one is refused. The configuration must be a
|
|
8
|
+
* `defineConfig({ … })` (or plain object) literal with a literal `modules`. With `variables`,
|
|
9
|
+
* `.env` is written first, once a dry run accepted the steps, and put back when the configuration
|
|
10
|
+
* cannot be written.
|
|
11
|
+
*/
|
|
5
12
|
exports.ConfigureProject = (0, interface_core_1.InterfaceFunction)();
|
|
13
|
+
/** One `AddModule` step. */
|
|
6
14
|
exports.AddModule = (0, interface_core_1.InterfaceFunction)();
|
|
15
|
+
/** One `ConfigureModule` step. */
|
|
7
16
|
exports.ConfigureModule = (0, interface_core_1.InterfaceFunction)();
|
|
17
|
+
/** One `CreateLocalModule` step; `opts.connection` is the step's `connection`. */
|
|
8
18
|
exports.CreateLocalModule = (0, interface_core_1.InterfaceFunction)();
|
|
9
19
|
//# sourceMappingURL=project.js.map
|
package/dist/project.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../src/project.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;AA2H/D;;;;;;GAMG;AACU,QAAA,gBAAgB,GAC3B,IAAA,kCAAiB,GAKd,CAAC;AAEN,4BAA4B;AACf,QAAA,SAAS,GACpB,IAAA,kCAAiB,GAMd,CAAC;AAEN,kCAAkC;AACrB,QAAA,eAAe,GAC1B,IAAA,kCAAiB,GAMd,CAAC;AAEN,kFAAkF;AACrE,QAAA,iBAAiB,GAC5B,IAAA,kCAAiB,GAOd,CAAC"}
|
package/dist/queries.d.ts
CHANGED
|
@@ -2,65 +2,190 @@ import type { ConfigSchema } from "./catalog";
|
|
|
2
2
|
import type { ResourceRef } from "./resources";
|
|
3
3
|
import type { MutationOpts, OpResult } from "./results";
|
|
4
4
|
import type { ConfigValue } from "./values";
|
|
5
|
+
/**
|
|
6
|
+
* A query's address: `<pageRef>@<name>`, e.g. `/books@inStockCount`. The page is
|
|
7
|
+
* where the route lives; the resource it reads is recorded in the query itself.
|
|
8
|
+
*/
|
|
5
9
|
export type QueryRef = string;
|
|
10
|
+
/**
|
|
11
|
+
* The shape a query's route responds with: one number as `{ value }`, or one
|
|
12
|
+
* point per group as `{ series }`, each point carrying its group as `x` and what
|
|
13
|
+
* was measured as `y`.
|
|
14
|
+
*/
|
|
6
15
|
export type QueryOutputKind = "scalar" | "series";
|
|
16
|
+
/**
|
|
17
|
+
* How a query's answer is arranged for the block that reads it.
|
|
18
|
+
*
|
|
19
|
+
* The calculation is the same either way — a measure, possibly per group. This
|
|
20
|
+
* says what the route wraps it in: the points themselves, a headline figure above
|
|
21
|
+
* them, that figure alone, or the points as a ranked list.
|
|
22
|
+
*/
|
|
7
23
|
export type QueryArrangement = "series" | "card" | "value" | "items";
|
|
24
|
+
/** The comparison operators a filter may use. */
|
|
8
25
|
export type FilterOp = "eq" | "ne" | "gt" | "ge" | "lt" | "le";
|
|
26
|
+
/**
|
|
27
|
+
* A filter value supplied per request rather than baked into the chain. It
|
|
28
|
+
* becomes a parameter of the model method and a `@Parameter` on the route.
|
|
29
|
+
*
|
|
30
|
+
* `name` and `in` describe the *route*, not the model: the route reads the value
|
|
31
|
+
* from that source, coerces it (`Number(...)` / `new Date(...)`), and passes it
|
|
32
|
+
* positionally to the model method. The model method neither knows nor cares
|
|
33
|
+
* where the value came from — its own parameter is named from the template, so
|
|
34
|
+
* `name`/`in` here only shape the route and are recovered from it on read-back.
|
|
35
|
+
*/
|
|
9
36
|
export type QueryParamBinding = {
|
|
10
37
|
$param: {
|
|
38
|
+
/** A camelCase identifier; the route exposes the value under this name. */
|
|
11
39
|
name: string;
|
|
40
|
+
/** Where the route reads the value from; defaults to `"query"`. */
|
|
12
41
|
in?: "query" | "param";
|
|
13
42
|
};
|
|
14
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* A filter value: either a plain scalar baked into the chain, or a
|
|
46
|
+
* {@link QueryParamBinding}. `$expr` is refused — a query's values are data.
|
|
47
|
+
*
|
|
48
|
+
* The alias is deliberate: it documents that a parameter value is data, never an
|
|
49
|
+
* expression, which `QueryParamBinding` relies on.
|
|
50
|
+
*/
|
|
15
51
|
export type QueryParamValue = ConfigValue;
|
|
52
|
+
/** One conjunct of a query's `where`. Filters combine with AND. */
|
|
16
53
|
export type QueryFilter = {
|
|
17
54
|
field: string;
|
|
18
55
|
op: FilterOp;
|
|
19
56
|
value: QueryParamValue;
|
|
20
57
|
};
|
|
58
|
+
/** A query template the builder can compile into a model method. */
|
|
21
59
|
export interface QueryTemplateDescriptor {
|
|
60
|
+
/** The template id, e.g. `"count"` | `"aggregate"`. */
|
|
22
61
|
id: string;
|
|
23
62
|
resourceType: "database-table";
|
|
24
63
|
title: string;
|
|
25
64
|
description?: string;
|
|
26
65
|
output: QueryOutputKind;
|
|
66
|
+
/** The template's parameter schema, in the same vocabulary as the block catalog. */
|
|
27
67
|
params: ConfigSchema;
|
|
28
68
|
}
|
|
69
|
+
/** One measured group, as a route answers it and a chart reads it. */
|
|
29
70
|
export interface QueryPoint {
|
|
30
71
|
x: number | string;
|
|
31
72
|
y: number;
|
|
32
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* The body a query's route returns.
|
|
76
|
+
*
|
|
77
|
+
* `{ value }` for a scalar and `{ series }` for a plain grouped route; for an
|
|
78
|
+
* arranged one, whatever the DMS helper built — `ChartCardData`, `KpiCardData`,
|
|
79
|
+
* `TopListData`. Those types belong to `@antelopejs/interface-dms`, which this
|
|
80
|
+
* package deliberately does not depend on, so the body travels as the JSON the
|
|
81
|
+
* route serves it as.
|
|
82
|
+
*/
|
|
33
83
|
export type QueryResponseBody = object;
|
|
84
|
+
/**
|
|
85
|
+
* What a draft query answers when run without being written.
|
|
86
|
+
*
|
|
87
|
+
* `body` is what the route would return, built by the same helper the route would
|
|
88
|
+
* call, so a block can be handed it directly; `output` and `response` report it
|
|
89
|
+
* the way {@link QueryStructure} reports the saved query, so a preview and the
|
|
90
|
+
* page it previews cannot disagree about what they show.
|
|
91
|
+
*
|
|
92
|
+
* `truncated` is the one thing the route has no equivalent of: a preview stops
|
|
93
|
+
* reading at some point, and a chart that silently lost its tail is worse than one
|
|
94
|
+
* that says so.
|
|
95
|
+
*/
|
|
34
96
|
export interface QueryPreview {
|
|
35
97
|
output: QueryOutputKind;
|
|
98
|
+
/**
|
|
99
|
+
* How the body is arranged, set only when a helper arranged it — the same
|
|
100
|
+
* condition under which read-back reports it.
|
|
101
|
+
*/
|
|
36
102
|
response?: QueryArrangement;
|
|
37
103
|
body: QueryResponseBody;
|
|
38
104
|
truncated: boolean;
|
|
39
105
|
}
|
|
106
|
+
/** Input for `AddQuery`. */
|
|
40
107
|
export interface AddQueryInput {
|
|
108
|
+
/**
|
|
109
|
+
* Query name — a camelCase identifier. Names the route method, and the model
|
|
110
|
+
* method too unless one of that name already exists compiling a *different*
|
|
111
|
+
* chain, in which case the model method is emitted under a free suffixed name
|
|
112
|
+
* so the queries already sharing the original keep their behaviour.
|
|
113
|
+
*/
|
|
41
114
|
name: string;
|
|
115
|
+
/** The resource the query reads. */
|
|
42
116
|
resource: ResourceRef;
|
|
117
|
+
/** A `QueryTemplateDescriptor.id`. */
|
|
43
118
|
template: string;
|
|
119
|
+
/** The template's parameters. */
|
|
44
120
|
params?: Record<string, QueryParamValue>;
|
|
121
|
+
/**
|
|
122
|
+
* How the answer is arranged for the block reading it. Defaults to what the
|
|
123
|
+
* template computes: a number for a scalar, its points for a series.
|
|
124
|
+
*
|
|
125
|
+
* A grouped calculation feeds a bare chart, a card with a headline figure, or
|
|
126
|
+
* a ranked list without being described three times.
|
|
127
|
+
*/
|
|
45
128
|
response?: QueryArrangement;
|
|
129
|
+
/**
|
|
130
|
+
* Answer the preceding period alongside the current one, so a card can show a
|
|
131
|
+
* variation. Only meaningful when the query binds a period.
|
|
132
|
+
*/
|
|
46
133
|
compare?: boolean;
|
|
134
|
+
/**
|
|
135
|
+
* The route path, relative to the page: the DMS serves it at
|
|
136
|
+
* `/dms/pages<pageRef><endpoint>` (`pageRoutePath` of interface-dms). Defaults to
|
|
137
|
+
* `/stats/<kebab-name>`; any path is allowed, since read-back identifies a
|
|
138
|
+
* query by its shape rather than its URL. Must not collide with another route
|
|
139
|
+
* on the page.
|
|
140
|
+
*/
|
|
47
141
|
endpoint?: string;
|
|
48
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
* A query as read back off disk. Read-back is purely structural: a route reads
|
|
145
|
+
* as a query when its shape and the chain it calls both parse, so a hand-written
|
|
146
|
+
* route matching the grammar is as editable as a generated one, and any edit
|
|
147
|
+
* that keeps the chain in-grammar is simply re-read. A query that no longer
|
|
148
|
+
* parses still reports `route`, `resource` and `modelMethod` — only
|
|
149
|
+
* `template`/`params` go missing — so the builder can always see and remove what
|
|
150
|
+
* it cannot edit.
|
|
151
|
+
*/
|
|
49
152
|
export interface QueryStructure {
|
|
50
153
|
name: string;
|
|
154
|
+
/** How the answer is arranged, when the route wraps the calculation. */
|
|
51
155
|
response?: QueryArrangement;
|
|
156
|
+
/** The route path relative to the page's slug, as {@link AddQueryInput.endpoint} takes it. */
|
|
52
157
|
endpoint: string;
|
|
53
158
|
resource?: ResourceRef;
|
|
159
|
+
/**
|
|
160
|
+
* The model method the route calls. Several queries may share one method, but
|
|
161
|
+
* only while they want the exact same chain — see {@link AddQueryInput.name}.
|
|
162
|
+
*/
|
|
54
163
|
modelMethod?: string;
|
|
55
164
|
output?: QueryOutputKind;
|
|
56
165
|
template?: string;
|
|
57
166
|
params?: Record<string, QueryParamValue>;
|
|
167
|
+
/**
|
|
168
|
+
* The route's declared parameters — the source of truth for a bound value's
|
|
169
|
+
* `name` and `in`. `header` appears only on hand-written routes; a generated
|
|
170
|
+
* one binds `$param` to `query` or `param`.
|
|
171
|
+
*/
|
|
58
172
|
routeParams?: {
|
|
59
173
|
name: string;
|
|
60
174
|
in: "query" | "param" | "header";
|
|
61
175
|
}[];
|
|
176
|
+
/**
|
|
177
|
+
* True when the route answers the preceding period beside the current one,
|
|
178
|
+
* as {@link AddQueryInput.compare} asked it to.
|
|
179
|
+
*/
|
|
62
180
|
compare?: boolean;
|
|
181
|
+
/** True when the query could not be reversed to an editable template. */
|
|
63
182
|
opaque?: boolean;
|
|
183
|
+
/**
|
|
184
|
+
* Set when `opaque === true`. `unparseable_route` — the GET wrapper is not the
|
|
185
|
+
* recognized `return { value: await model.m(...) }` shape. `unparseable_chain`
|
|
186
|
+
* — the model method it calls is not a chain any registered template accepts
|
|
187
|
+
* (hand-written, edited out of grammar, or from a newer builder).
|
|
188
|
+
*/
|
|
64
189
|
opaqueReason?: "unparseable_route" | "unparseable_chain";
|
|
65
190
|
}
|
|
66
191
|
export declare const ListQueryTemplates: (resourceType?: string | undefined) => Promise<QueryTemplateDescriptor[]>;
|
package/dist/resources.d.ts
CHANGED
|
@@ -1,60 +1,164 @@
|
|
|
1
1
|
import type { CategoryRef, PageRef } from "./addressing";
|
|
2
2
|
import type { MutationOpts, OpResult } from "./results";
|
|
3
3
|
import type { ConfigObject, DataTypeValue } from "./values";
|
|
4
|
+
/** A resource's stable ref — its `name`, e.g. `"product"`. */
|
|
4
5
|
export type ResourceRef = string;
|
|
6
|
+
/** A field's address within a resource: `<resourceRef>#<fieldName>`. */
|
|
5
7
|
export type FieldPath = string;
|
|
8
|
+
/** The paths of the files a resource is composed of. */
|
|
6
9
|
export interface ResourceFiles {
|
|
7
10
|
database: string;
|
|
8
11
|
dataApi: string;
|
|
9
12
|
index: string;
|
|
10
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* The semantic aspects of a resource field. The engine maps these to the paired
|
|
16
|
+
* `@Field`/`@Index` (Table) and `@Select`/`@Listable`/`@Column`/`@Access`/…
|
|
17
|
+
* (DataAPI) decorator stacks; the consumer never touches raw decorators.
|
|
18
|
+
*/
|
|
11
19
|
export interface FieldAspects {
|
|
20
|
+
/** The field's DataType value, e.g. `{ $dataType: "string" }`. */
|
|
12
21
|
dataType: DataTypeValue;
|
|
22
|
+
/** Column header label; defaults to the field name. */
|
|
13
23
|
label?: string;
|
|
24
|
+
/** Listed by the DataAPI's list route (`@Listable`). Default true. */
|
|
14
25
|
listable?: boolean;
|
|
26
|
+
/** Offered to relation pickers by the select route (`@Select`). */
|
|
15
27
|
selectable?: boolean;
|
|
28
|
+
/** Full-text searchable. */
|
|
16
29
|
searchable?: boolean;
|
|
30
|
+
/** Sortable in the TableView. */
|
|
17
31
|
sortable?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Column-filterable in the TableView. Never on an archive field: the filter
|
|
34
|
+
* `@ArchiveField` registers serves it, and `TableView` refuses another.
|
|
35
|
+
*/
|
|
18
36
|
filterable?: boolean;
|
|
37
|
+
/** Field access mode. Default `"readwrite"`. */
|
|
19
38
|
access?: "read" | "readwrite";
|
|
39
|
+
/** Whether the field is required. Default false → `@Optional()`. */
|
|
20
40
|
required?: boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Whether the Table column is indexed. When a field is created, defaults to
|
|
43
|
+
* true for `relation`, `cascader_relation` and `tree` fields and to false
|
|
44
|
+
* otherwise.
|
|
45
|
+
*/
|
|
21
46
|
indexed?: boolean;
|
|
47
|
+
/** The `@Column` display order. */
|
|
22
48
|
order?: number;
|
|
49
|
+
/** Included in the resource's CSV export (`@Exported`). */
|
|
23
50
|
exported?: boolean;
|
|
51
|
+
/** The boolean column archiving marks (`@ArchiveField`). */
|
|
24
52
|
archiveField?: boolean;
|
|
53
|
+
/** Routes the field is mandatory on, e.g. `["new", "edit"]` (`@Mandatory`). */
|
|
25
54
|
mandatory?: string[];
|
|
55
|
+
/**
|
|
56
|
+
* How the column is declared on the Table, as it stands: the `@Field(...)`
|
|
57
|
+
* argument and the TypeScript type. Only a handful of DataTypes map to a
|
|
58
|
+
* database type, so a field the builder did not write keeps its own
|
|
59
|
+
* declaration instead of being narrowed to the `string` fallback.
|
|
60
|
+
*/
|
|
26
61
|
dbField?: {
|
|
27
62
|
field: string;
|
|
28
63
|
ts: string;
|
|
29
64
|
optional?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* The Table decorators the builder does not model — `@Localized()` and
|
|
67
|
+
* anything else its author put there — carried verbatim. Dropping one
|
|
68
|
+
* changes how the column is stored, so it is never re-derived.
|
|
69
|
+
*/
|
|
30
70
|
decorators?: string[];
|
|
31
71
|
};
|
|
72
|
+
/**
|
|
73
|
+
* The `@Column` options the builder does not model — `defaultValue`,
|
|
74
|
+
* `description`, anything a hand-written field carries. They are read back
|
|
75
|
+
* and written again untouched, so configuring a field never silently drops
|
|
76
|
+
* what the builder did not put there.
|
|
77
|
+
*/
|
|
32
78
|
columnExtras?: ConfigObject;
|
|
33
79
|
}
|
|
80
|
+
/** A field in a `CreateResource`/`AddField` request. */
|
|
34
81
|
export interface FieldSpec extends FieldAspects {
|
|
82
|
+
/** Field name — immutable; rename = `RemoveField` + `AddField`. */
|
|
35
83
|
name: string;
|
|
36
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* A route a resource's DataAPI exposes. Selecting a subset lets a resource serve
|
|
87
|
+
* only the endpoints it needs (e.g. a singleton edit form wants `["get", "edit"]`
|
|
88
|
+
* and no list/create/delete). Each name maps to the paired `TableViewRoutes`
|
|
89
|
+
* members the engine emits:
|
|
90
|
+
*
|
|
91
|
+
* - **`list`** — the paginated table listing (`list` + `count`).
|
|
92
|
+
* - **`get`** — read a single row (detail / view).
|
|
93
|
+
* - **`create`** — create a row (`new`).
|
|
94
|
+
* - **`edit`** — update a row.
|
|
95
|
+
* - **`delete`** — delete a row.
|
|
96
|
+
* - **`select`** — option lists for relation pickers that reference this resource.
|
|
97
|
+
* - **`archive`** — soft delete + undo (`archive` + `restore`).
|
|
98
|
+
* - **`export`** — CSV/export endpoints (`exportStart`/`exportStatus`/`exportDownload`).
|
|
99
|
+
*/
|
|
37
100
|
export type ResourceRoute = "list" | "get" | "create" | "edit" | "delete" | "select" | "archive" | "export";
|
|
101
|
+
/**
|
|
102
|
+
* Where a resource's `<name>/` folder is placed, and which barrel re-exports it.
|
|
103
|
+
* The nearest ancestor barrel to the resolved folder is wired (the root barrel is
|
|
104
|
+
* the ultimate fallback), so a relative import chain to `src/index.ts` is kept.
|
|
105
|
+
*
|
|
106
|
+
* - **Omitted** — a `<name>/` folder at the src root (`src/<name>/`), as before.
|
|
107
|
+
* - **A `dir` string** — an explicit folder relative to the src root; the resource
|
|
108
|
+
* lands at `src/<dir>/<name>/`. Must stay within the src tree.
|
|
109
|
+
* - **`{ category }`** — the source folder of that category (mirrors page
|
|
110
|
+
* placement): `src/<category-dir>/<name>/`. A root category falls back to the
|
|
111
|
+
* src root.
|
|
112
|
+
* - **`{ page }`** — nested inside that page's feature folder:
|
|
113
|
+
* `src/<page-dir>/<name>/`, so the page imports `./<name>/data-api`.
|
|
114
|
+
*/
|
|
38
115
|
export type ResourceLocation = string | {
|
|
39
116
|
category: CategoryRef;
|
|
40
117
|
} | {
|
|
41
118
|
page: PageRef;
|
|
42
119
|
};
|
|
120
|
+
/**
|
|
121
|
+
* Input for `CreateResource`. Creates a `<name>/` folder (see `location`) and
|
|
122
|
+
* wires the nearest barrel.
|
|
123
|
+
*/
|
|
43
124
|
export interface CreateResourceInput {
|
|
125
|
+
/** Unique resource name — duplicate → `duplicate_name`. */
|
|
44
126
|
name: string;
|
|
45
127
|
displayName?: string;
|
|
128
|
+
/** DB schema; defaults to `CORE_SCHEMA_NAME`. */
|
|
46
129
|
schema?: string;
|
|
47
130
|
fields: FieldSpec[];
|
|
131
|
+
/** `@Fixture` seed rows; each row must supply its own `_id`. */
|
|
48
132
|
seeds?: ConfigObject[];
|
|
133
|
+
/** File placement; omit for `src/<name>/`. */
|
|
49
134
|
location?: ResourceLocation;
|
|
135
|
+
/**
|
|
136
|
+
* Which DataAPI routes to expose. Omit for the full set (list/get/create/edit/
|
|
137
|
+
* delete/select/archive/export); pass a subset to serve only those endpoints —
|
|
138
|
+
* an omitted route's HTTP endpoint is simply not registered. Must be non-empty
|
|
139
|
+
* when provided.
|
|
140
|
+
*/
|
|
50
141
|
routes?: ResourceRoute[];
|
|
142
|
+
/**
|
|
143
|
+
* The project module to write into, by its id in the project configuration. Unset, the
|
|
144
|
+
* project's own module. A module is one of the project's local modules with an `src/index.ts`;
|
|
145
|
+
* what it writes may only use declarations from that same module.
|
|
146
|
+
*/
|
|
51
147
|
module?: string;
|
|
52
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* A field as reported by `GetResourceStructure`. Aspects are present for
|
|
151
|
+
* cleanly-reversed fields; an `opaque` field (hand-edited / unknown decorator /
|
|
152
|
+
* relation) carries only `name` + `opaqueReason`.
|
|
153
|
+
*/
|
|
53
154
|
export interface ResourceFieldStructure extends Partial<FieldAspects> {
|
|
54
155
|
name: string;
|
|
156
|
+
/** True when the field's decorator stack could not be reversed. */
|
|
55
157
|
opaque?: boolean;
|
|
158
|
+
/** Set when `opaque === true`. */
|
|
56
159
|
opaqueReason?: string;
|
|
57
160
|
}
|
|
161
|
+
/** A resource's full structure. `version` is a content hash of both files. */
|
|
58
162
|
export interface ResourceStructure {
|
|
59
163
|
ref: ResourceRef;
|
|
60
164
|
className: string;
|
|
@@ -63,9 +167,15 @@ export interface ResourceStructure {
|
|
|
63
167
|
schema: string;
|
|
64
168
|
files: ResourceFiles;
|
|
65
169
|
fields: ResourceFieldStructure[];
|
|
170
|
+
/**
|
|
171
|
+
* The exposed DataAPI routes when the resource serves a subset; omitted when it
|
|
172
|
+
* serves the full set (`TableViewRoutes.All`). Best-effort — absent for a
|
|
173
|
+
* hand-edited route map the engine could not map back to semantic names.
|
|
174
|
+
*/
|
|
66
175
|
routes?: ResourceRoute[];
|
|
67
176
|
version: string;
|
|
68
177
|
}
|
|
178
|
+
/** A lightweight resource listing entry. */
|
|
69
179
|
export interface ResourceSummary {
|
|
70
180
|
ref: ResourceRef;
|
|
71
181
|
className: string;
|
|
@@ -76,19 +186,41 @@ export interface ResourceSummary {
|
|
|
76
186
|
database: string;
|
|
77
187
|
dataApi: string;
|
|
78
188
|
};
|
|
189
|
+
/** The project module the resource lives in, when it is not the project's own. */
|
|
79
190
|
sourceModule?: string;
|
|
80
191
|
}
|
|
192
|
+
/** Options for `DeleteResource`. */
|
|
81
193
|
export interface DeleteResourceOpts extends MutationOpts {
|
|
194
|
+
/**
|
|
195
|
+
* Keep the resource's database table data. By default `DeleteResource` also
|
|
196
|
+
* deletes every row of the resource's table (so a later resource reusing the
|
|
197
|
+
* name/table re-seeds cleanly instead of inheriting stale documents); set
|
|
198
|
+
* `true` to leave the data in place.
|
|
199
|
+
*/
|
|
82
200
|
keepData?: boolean;
|
|
83
201
|
}
|
|
84
202
|
export declare const CreateResource: (input: CreateResourceInput) => Promise<OpResult<{
|
|
85
203
|
ref: ResourceRef;
|
|
86
204
|
files: ResourceFiles;
|
|
87
205
|
}>>;
|
|
206
|
+
/** The resource fields `ConfigureResource` may patch. */
|
|
88
207
|
export interface EditableResourceMeta {
|
|
208
|
+
/**
|
|
209
|
+
* Which DataAPI routes the resource exposes. Replaces the current set, so
|
|
210
|
+
* pass the whole list; omit the field to leave it alone.
|
|
211
|
+
*/
|
|
89
212
|
routes?: ResourceRoute[];
|
|
90
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Patch a resource's DataAPI surface. Only what a route map can express is
|
|
216
|
+
* patchable — a resource's fields are edited with `AddField`/`ConfigureField`.
|
|
217
|
+
*/
|
|
91
218
|
export declare const ConfigureResource: (ref: string, patch: EditableResourceMeta, opts?: MutationOpts | undefined) => Promise<OpResult>;
|
|
219
|
+
/**
|
|
220
|
+
* Delete a resource's files and, unless `keepData`, its table rows. Refused
|
|
221
|
+
* with `referential_integrity` while another resource references it (a
|
|
222
|
+
* relation field pointing at it); `blockedBy` lists those resources.
|
|
223
|
+
*/
|
|
92
224
|
export declare const DeleteResource: (ref: string, opts?: DeleteResourceOpts | undefined) => Promise<OpResult>;
|
|
93
225
|
export declare const AddField: (ref: string, field: FieldSpec, opts?: MutationOpts | undefined) => Promise<OpResult<{
|
|
94
226
|
path: FieldPath;
|
package/dist/resources.js
CHANGED
|
@@ -3,7 +3,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.GetResourceStructure = exports.ListResources = exports.RemoveField = exports.ConfigureField = exports.AddField = exports.DeleteResource = exports.ConfigureResource = exports.CreateResource = void 0;
|
|
4
4
|
const interface_core_1 = require("@antelopejs/interface-core");
|
|
5
5
|
exports.CreateResource = (0, interface_core_1.InterfaceFunction)();
|
|
6
|
+
/**
|
|
7
|
+
* Patch a resource's DataAPI surface. Only what a route map can express is
|
|
8
|
+
* patchable — a resource's fields are edited with `AddField`/`ConfigureField`.
|
|
9
|
+
*/
|
|
6
10
|
exports.ConfigureResource = (0, interface_core_1.InterfaceFunction)();
|
|
11
|
+
/**
|
|
12
|
+
* Delete a resource's files and, unless `keepData`, its table rows. Refused
|
|
13
|
+
* with `referential_integrity` while another resource references it (a
|
|
14
|
+
* relation field pointing at it); `blockedBy` lists those resources.
|
|
15
|
+
*/
|
|
7
16
|
exports.DeleteResource = (0, interface_core_1.InterfaceFunction)();
|
|
8
17
|
exports.AddField = (0, interface_core_1.InterfaceFunction)();
|
|
9
18
|
exports.ConfigureField = (0, interface_core_1.InterfaceFunction)();
|
package/dist/resources.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;
|
|
1
|
+
{"version":3,"file":"resources.js","sourceRoot":"","sources":["../src/resources.ts"],"names":[],"mappings":";;;AAAA,+DAA+D;AA2NlD,QAAA,cAAc,GACzB,IAAA,kCAAiB,GAId,CAAC;AAUN;;;GAGG;AACU,QAAA,iBAAiB,GAC5B,IAAA,kCAAiB,GAMd,CAAC;AAEN;;;;GAIG;AACU,QAAA,cAAc,GACzB,IAAA,kCAAiB,GAEd,CAAC;AACO,QAAA,QAAQ,GACnB,IAAA,kCAAiB,GAMd,CAAC;AACO,QAAA,cAAc,GACzB,IAAA,kCAAiB,GAMd,CAAC;AACO,QAAA,WAAW,GACtB,IAAA,kCAAiB,GAEd,CAAC;AACO,QAAA,aAAa,GACxB,IAAA,kCAAiB,GAAoC,CAAC;AAC3C,QAAA,oBAAoB,GAC/B,IAAA,kCAAiB,GAEd,CAAC"}
|
package/dist/results.d.ts
CHANGED
|
@@ -1,23 +1,68 @@
|
|
|
1
1
|
import type { BlockPath } from "./addressing";
|
|
2
|
+
/** A single file mutation staged by an operation. */
|
|
2
3
|
export interface FileChange {
|
|
3
4
|
path: string;
|
|
4
5
|
kind: "create" | "modify" | "delete";
|
|
6
|
+
/**
|
|
7
|
+
* The change as unified diff hunks (`@@ -a,b +c,d @@`, then lines prefixed with a space, `-`
|
|
8
|
+
* or `+`), with no file headers; empty for a deleted file or folder.
|
|
9
|
+
*/
|
|
5
10
|
diff: string;
|
|
6
11
|
}
|
|
12
|
+
/** A config validation failure, addressed by a JSON pointer. */
|
|
7
13
|
export type ValidationIssue = {
|
|
8
14
|
pointer: string;
|
|
9
15
|
message: string;
|
|
10
16
|
};
|
|
17
|
+
/** A TypeScript diagnostic from the in-memory typecheck gate. */
|
|
11
18
|
export type TypecheckError = {
|
|
12
19
|
file: string;
|
|
13
20
|
line: number;
|
|
14
21
|
message: string;
|
|
15
22
|
};
|
|
23
|
+
/** A non-fatal advisory attached to an otherwise successful operation. */
|
|
16
24
|
export interface OpWarning {
|
|
17
|
-
code:
|
|
25
|
+
code:
|
|
26
|
+
/** A query on the page was taken over by hand, so the draft left it alone. */
|
|
27
|
+
"query_opaque"
|
|
28
|
+
/** A query the draft dropped is still read by a block, so it was kept. */
|
|
29
|
+
| "query_kept" | "index_clamped" | "datatype_fallback" | "data_not_dropped"
|
|
30
|
+
/** A page moved category, so its route changed and old links break. */
|
|
31
|
+
| "route_changed"
|
|
32
|
+
/** A mapped resource was deleted; its rows belong to the external database and were kept. */
|
|
33
|
+
| "data_kept"
|
|
34
|
+
/** A mapped relation's tables were written, but its TableView page could not be. */
|
|
35
|
+
| "page_not_written"
|
|
36
|
+
/** A relation the module maps is no longer in the database, or the role can no longer see it. */
|
|
37
|
+
| "relation_missing"
|
|
38
|
+
/** An SVG logo had scripts, event handlers or external references removed. */
|
|
39
|
+
| "svg_sanitized"
|
|
40
|
+
/**
|
|
41
|
+
* A relation was mapped without the `display` of its text columns, and neither a profile nor
|
|
42
|
+
* an analysis was there to propose a badge from, so those columns were written plain.
|
|
43
|
+
*/
|
|
44
|
+
| "display_not_proposed"
|
|
45
|
+
/**
|
|
46
|
+
* The mapping was written, but the module it was written into did not load again afterwards:
|
|
47
|
+
* it was unloaded and did not start within the wait, or the runtime does not report it active.
|
|
48
|
+
* The message names the module; the backend log holds the error.
|
|
49
|
+
*/
|
|
50
|
+
| "module_not_loaded"
|
|
51
|
+
/** A setting the page held no longer holds, because another change removed what it needed. */
|
|
52
|
+
| "setting_dropped"
|
|
53
|
+
/** A relation of a batch was left out because one of its choices was refused; the others were written. */
|
|
54
|
+
| "relation_skipped"
|
|
55
|
+
/** A column display was not written because it does not suit the column; the column is written plain. */
|
|
56
|
+
| "display_dropped"
|
|
57
|
+
/** A column was marked filterable or sortable because a view, footer figure, tab or grouping needs it. */
|
|
58
|
+
| "field_flag_set"
|
|
59
|
+
/** A relation's label was changed to one the generated code can read, or dropped when no column offers it. */
|
|
60
|
+
| "label_changed";
|
|
18
61
|
message: string;
|
|
19
62
|
}
|
|
63
|
+
/** The scope a duplicate name collides within. */
|
|
20
64
|
export type DuplicateScope = "page" | "siblings" | "category" | "resource" | "query" | "module";
|
|
65
|
+
/** Every way an operation can fail. */
|
|
21
66
|
export type BuilderError = {
|
|
22
67
|
code: "not_found";
|
|
23
68
|
ref: string;
|
|
@@ -45,6 +90,7 @@ export type BuilderError = {
|
|
|
45
90
|
code: "typecheck_failed";
|
|
46
91
|
diagnostics: TypecheckError[];
|
|
47
92
|
};
|
|
93
|
+
/** The result of a builder operation. On success, carries the staged changes. */
|
|
48
94
|
export type OpResult<T = void> = {
|
|
49
95
|
ok: true;
|
|
50
96
|
data: T;
|
|
@@ -54,6 +100,8 @@ export type OpResult<T = void> = {
|
|
|
54
100
|
ok: false;
|
|
55
101
|
error: BuilderError;
|
|
56
102
|
};
|
|
103
|
+
/** Optional trailing options for version-checked mutations; category mutations do not accept them. */
|
|
57
104
|
export interface MutationOpts {
|
|
105
|
+
/** The page or resource structure's `version` last read → `stale` on mismatch. */
|
|
58
106
|
expectedVersion?: string;
|
|
59
107
|
}
|
package/dist/structure.d.ts
CHANGED
|
@@ -2,8 +2,21 @@ import type { BlockPath, CategoryRef, PageRef } from "./addressing";
|
|
|
2
2
|
import type { QueryStructure } from "./queries";
|
|
3
3
|
import type { ResourceRef } from "./resources";
|
|
4
4
|
import type { ConfigObject } from "./values";
|
|
5
|
+
/**
|
|
6
|
+
* A page's permission, mirroring the DMS `MenuOptions.permission`: a partial
|
|
7
|
+
* permission spec — `id`, `title`, `icon`, `description`, `dependencies`,
|
|
8
|
+
* `defaultGranted`. The DMS also accepts an `Action` there, which is a live
|
|
9
|
+
* object rather than data and so has no encoding here; a page declaring one
|
|
10
|
+
* reads its permission back as `undefined`.
|
|
11
|
+
*/
|
|
5
12
|
export type PagePermission = ConfigObject;
|
|
13
|
+
/**
|
|
14
|
+
* A page's Direct / Pause valve over the realtime of its blocks, mirroring the
|
|
15
|
+
* DMS `MenuOptions.live`: `maxRate`, `slowRateAfter`, `rememberKey`. Present,
|
|
16
|
+
* even empty, the page is live; absent, it refetches on every event.
|
|
17
|
+
*/
|
|
6
18
|
export type PageLive = ConfigObject;
|
|
19
|
+
/** Page metadata the builder can read. */
|
|
7
20
|
export interface PageMeta {
|
|
8
21
|
ref: PageRef;
|
|
9
22
|
id: string;
|
|
@@ -15,8 +28,10 @@ export interface PageMeta {
|
|
|
15
28
|
hidden?: boolean;
|
|
16
29
|
permission?: PagePermission;
|
|
17
30
|
live?: PageLive;
|
|
31
|
+
/** Resolved by the builder's source index, NOT the runtime registry. */
|
|
18
32
|
filepath: string;
|
|
19
33
|
}
|
|
34
|
+
/** The page metadata fields `ConfigurePage` may patch. */
|
|
20
35
|
export interface EditablePageMeta {
|
|
21
36
|
displayName: string;
|
|
22
37
|
icon?: string;
|
|
@@ -27,25 +42,45 @@ export interface EditablePageMeta {
|
|
|
27
42
|
permission?: PagePermission;
|
|
28
43
|
live?: PageLive;
|
|
29
44
|
}
|
|
45
|
+
/** A single block in a page's tree. */
|
|
30
46
|
export interface BlockNode {
|
|
31
47
|
path: BlockPath;
|
|
48
|
+
/** Static key (top-level) or `.child()` id (nested). */
|
|
32
49
|
name: string;
|
|
50
|
+
/** Factory name; null if unresolved. */
|
|
33
51
|
type: string | null;
|
|
52
|
+
/** Whether understood options can be edited, independently of identity. */
|
|
34
53
|
editable: boolean;
|
|
54
|
+
/** Set when `editable === false`. */
|
|
35
55
|
opaqueReason?: string;
|
|
36
56
|
slot?: string;
|
|
57
|
+
/**
|
|
58
|
+
* The child metadata beyond `slot`, as declared in the third argument of
|
|
59
|
+
* `.child()` — `{ colSpan: 2 }` on a grid child, for instance. Nested blocks
|
|
60
|
+
* only; the catalog describes the accepted shape as `childMeta`.
|
|
61
|
+
*/
|
|
37
62
|
meta?: ConfigObject;
|
|
63
|
+
/** Present only when editable. */
|
|
38
64
|
config?: ConfigObject;
|
|
65
|
+
/** Top-level options retained on the server, with a reason for each lock. */
|
|
39
66
|
lockedOptions?: Record<string, string>;
|
|
67
|
+
/**
|
|
68
|
+
* Controller-leading blocks (e.g. `TableView`): the resource ref of the leading
|
|
69
|
+
* DataAPI class argument, when it resolves to a known generated resource.
|
|
70
|
+
*/
|
|
40
71
|
controller?: ResourceRef;
|
|
72
|
+
/** Containers only, in `.child()` order. */
|
|
41
73
|
children?: BlockNode[];
|
|
42
74
|
}
|
|
75
|
+
/** A page's full structure. `version` is a content hash. */
|
|
43
76
|
export interface PageStructure {
|
|
44
77
|
page: PageMeta;
|
|
45
78
|
blocks: BlockNode[];
|
|
79
|
+
/** The query routes declared on the page, found by shape. */
|
|
46
80
|
queries: QueryStructure[];
|
|
47
81
|
version: string;
|
|
48
82
|
}
|
|
83
|
+
/** A lightweight page listing entry. */
|
|
49
84
|
export interface PageSummary {
|
|
50
85
|
ref: PageRef;
|
|
51
86
|
id: string;
|
|
@@ -53,18 +88,25 @@ export interface PageSummary {
|
|
|
53
88
|
category: CategoryRef;
|
|
54
89
|
moduleId?: string;
|
|
55
90
|
filepath: string;
|
|
91
|
+
/** The icon the menu shows beside the page. */
|
|
56
92
|
icon?: string;
|
|
93
|
+
/** Sorts the page among the others of its category. */
|
|
57
94
|
order?: number;
|
|
95
|
+
/** Whether the menu leaves the page out; its route still answers. */
|
|
58
96
|
hidden?: boolean;
|
|
97
|
+
/** The project module the page lives in, when it is not the project's own. */
|
|
59
98
|
sourceModule?: string;
|
|
60
99
|
}
|
|
100
|
+
/** A lightweight category listing entry. */
|
|
61
101
|
export interface CategorySummary {
|
|
62
102
|
ref: CategoryRef;
|
|
63
103
|
displayName: string;
|
|
64
104
|
parent?: CategoryRef;
|
|
65
105
|
icon?: string;
|
|
106
|
+
/** Its place among its siblings in the menu, lowest first. */
|
|
66
107
|
order?: number;
|
|
67
108
|
}
|
|
109
|
+
/** The category metadata fields `ConfigureCategory` may patch. */
|
|
68
110
|
export interface EditableCategoryMeta {
|
|
69
111
|
displayName: string;
|
|
70
112
|
parent?: CategoryRef;
|