@atscript/ui 0.1.163 → 0.1.164
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/client-factory.cjs +27 -0
- package/dist/client-factory.d.cts +53 -0
- package/dist/client-factory.d.mts +53 -0
- package/dist/client-factory.mjs +25 -0
- package/dist/form/apply.cjs +38 -0
- package/dist/form/apply.d.cts +36 -0
- package/dist/form/apply.d.mts +36 -0
- package/dist/form/apply.mjs +38 -0
- package/dist/form/clone.cjs +30 -0
- package/dist/form/clone.d.cts +23 -0
- package/dist/form/clone.d.mts +23 -0
- package/dist/form/clone.mjs +30 -0
- package/dist/form/create-form-def.cjs +440 -0
- package/dist/form/create-form-def.d.cts +67 -0
- package/dist/form/create-form-def.d.mts +67 -0
- package/dist/form/create-form-def.mjs +438 -0
- package/dist/form/decimal-format.cjs +324 -0
- package/dist/form/decimal-format.d.cts +86 -0
- package/dist/form/decimal-format.d.mts +86 -0
- package/dist/form/decimal-format.mjs +315 -0
- package/dist/form/diff.cjs +458 -0
- package/dist/form/diff.d.cts +80 -0
- package/dist/form/diff.d.mts +80 -0
- package/dist/form/diff.mjs +457 -0
- package/dist/form/dirty.cjs +65 -0
- package/dist/form/dirty.d.cts +47 -0
- package/dist/form/dirty.d.mts +47 -0
- package/dist/form/dirty.mjs +64 -0
- package/dist/form/error-utils.cjs +97 -0
- package/dist/form/error-utils.d.cts +58 -0
- package/dist/form/error-utils.d.mts +58 -0
- package/dist/form/error-utils.mjs +92 -0
- package/dist/form/form-actions.cjs +30 -0
- package/dist/form/form-actions.d.cts +17 -0
- package/dist/form/form-actions.d.mts +17 -0
- package/dist/form/form-actions.mjs +30 -0
- package/dist/form/grid.cjs +69 -0
- package/dist/form/grid.d.cts +49 -0
- package/dist/form/grid.d.mts +49 -0
- package/dist/form/grid.mjs +64 -0
- package/dist/form/labels.cjs +10 -0
- package/dist/form/labels.d.cts +7 -0
- package/dist/form/labels.d.mts +7 -0
- package/dist/form/labels.mjs +10 -0
- package/dist/form/measurement.cjs +20 -0
- package/dist/form/measurement.d.cts +29 -0
- package/dist/form/measurement.d.mts +29 -0
- package/dist/form/measurement.mjs +20 -0
- package/dist/form/path-utils.cjs +182 -0
- package/dist/form/path-utils.d.cts +47 -0
- package/dist/form/path-utils.d.mts +47 -0
- package/dist/form/path-utils.mjs +175 -0
- package/dist/form/rebase.cjs +89 -0
- package/dist/form/rebase.d.cts +61 -0
- package/dist/form/rebase.d.mts +61 -0
- package/dist/form/rebase.mjs +89 -0
- package/dist/form/skipped-nav.cjs +100 -0
- package/dist/form/skipped-nav.d.cts +13 -0
- package/dist/form/skipped-nav.d.mts +13 -0
- package/dist/form/skipped-nav.mjs +98 -0
- package/dist/form/types.cjs +40 -0
- package/dist/form/types.d.cts +133 -0
- package/dist/form/types.d.mts +133 -0
- package/dist/form/types.mjs +36 -0
- package/dist/form/union-detect.cjs +46 -0
- package/dist/form/union-detect.d.cts +22 -0
- package/dist/form/union-detect.d.mts +22 -0
- package/dist/form/union-detect.mjs +46 -0
- package/dist/form/validate.cjs +150 -0
- package/dist/form/validate.d.cts +50 -0
- package/dist/form/validate.d.mts +50 -0
- package/dist/form/validate.mjs +147 -0
- package/dist/index.cjs +217 -3360
- package/dist/index.d.cts +38 -1693
- package/dist/index.d.mts +38 -1693
- package/dist/index.mjs +35 -3179
- package/dist/nav/model-routes.cjs +59 -0
- package/dist/nav/model-routes.d.cts +33 -0
- package/dist/nav/model-routes.d.mts +33 -0
- package/dist/nav/model-routes.mjs +59 -0
- package/dist/plugin/annotations.cjs +577 -0
- package/dist/plugin/annotations.mjs +577 -0
- package/dist/plugin/primitives.cjs +30 -0
- package/dist/plugin/primitives.mjs +30 -0
- package/dist/plugin/value-help-validation.cjs +419 -0
- package/dist/plugin/value-help-validation.mjs +413 -0
- package/dist/plugin.cjs +4 -1001
- package/dist/plugin.mjs +2 -999
- package/dist/shared/annotation-keys.cjs +189 -0
- package/dist/shared/annotation-keys.d.cts +82 -0
- package/dist/shared/annotation-keys.d.mts +82 -0
- package/dist/shared/annotation-keys.mjs +97 -0
- package/dist/shared/field-resolver.cjs +123 -0
- package/dist/shared/field-resolver.d.cts +77 -0
- package/dist/shared/field-resolver.d.mts +77 -0
- package/dist/shared/field-resolver.mjs +110 -0
- package/dist/shared/meta-cache.cjs +244 -0
- package/dist/shared/meta-cache.d.cts +110 -0
- package/dist/shared/meta-cache.d.mts +110 -0
- package/dist/shared/meta-cache.mjs +237 -0
- package/dist/shared/str.cjs +19 -0
- package/dist/shared/str.d.cts +7 -0
- package/dist/shared/str.d.mts +7 -0
- package/dist/shared/str.mjs +17 -0
- package/dist/table/column-resolver.cjs +17 -0
- package/dist/table/column-resolver.d.cts +11 -0
- package/dist/table/column-resolver.d.mts +11 -0
- package/dist/table/column-resolver.mjs +15 -0
- package/dist/table/create-table-def.cjs +233 -0
- package/dist/table/create-table-def.d.cts +15 -0
- package/dist/table/create-table-def.d.mts +15 -0
- package/dist/table/create-table-def.mjs +233 -0
- package/dist/table/navigate-href.cjs +45 -0
- package/dist/table/navigate-href.d.cts +31 -0
- package/dist/table/navigate-href.d.mts +31 -0
- package/dist/table/navigate-href.mjs +45 -0
- package/dist/table/types.d.cts +287 -0
- package/dist/table/types.d.mts +287 -0
- package/dist/table/value-kind.cjs +20 -0
- package/dist/table/value-kind.d.cts +15 -0
- package/dist/table/value-kind.d.mts +15 -0
- package/dist/table/value-kind.mjs +19 -0
- package/dist/value-help/dict-paths.cjs +17 -0
- package/dist/value-help/dict-paths.d.cts +11 -0
- package/dist/value-help/dict-paths.d.mts +11 -0
- package/dist/value-help/dict-paths.mjs +17 -0
- package/dist/value-help/distinct-client.cjs +51 -0
- package/dist/value-help/distinct-client.d.cts +40 -0
- package/dist/value-help/distinct-client.d.mts +40 -0
- package/dist/value-help/distinct-client.mjs +50 -0
- package/dist/value-help/extract-literals.cjs +76 -0
- package/dist/value-help/extract-literals.d.cts +32 -0
- package/dist/value-help/extract-literals.d.mts +32 -0
- package/dist/value-help/extract-literals.mjs +74 -0
- package/dist/value-help/extract-ref.cjs +100 -0
- package/dist/value-help/extract-ref.d.cts +37 -0
- package/dist/value-help/extract-ref.d.mts +37 -0
- package/dist/value-help/extract-ref.mjs +100 -0
- package/dist/value-help/filter-tree.cjs +45 -0
- package/dist/value-help/filter-tree.mjs +45 -0
- package/dist/value-help/index.d.mts +8 -0
- package/dist/value-help/resolve-options.cjs +64 -0
- package/dist/value-help/resolve-options.d.cts +35 -0
- package/dist/value-help/resolve-options.d.mts +35 -0
- package/dist/value-help/resolve-options.mjs +60 -0
- package/dist/value-help/resolve.cjs +62 -0
- package/dist/value-help/resolve.d.cts +31 -0
- package/dist/value-help/resolve.d.mts +31 -0
- package/dist/value-help/resolve.mjs +61 -0
- package/dist/value-help/types.d.cts +36 -0
- package/dist/value-help/types.d.mts +36 -0
- package/dist/value-help/value-help-client.cjs +136 -0
- package/dist/value-help/value-help-client.d.cts +67 -0
- package/dist/value-help/value-help-client.d.mts +67 -0
- package/dist/value-help/value-help-client.mjs +134 -0
- package/package.json +10 -10
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
const require_annotation_keys = require("../shared/annotation-keys.cjs");
|
|
2
|
+
const require_field_resolver = require("../shared/field-resolver.cjs");
|
|
3
|
+
const require_str = require("../shared/str.cjs");
|
|
4
|
+
//#region src/nav/model-routes.ts
|
|
5
|
+
/**
|
|
6
|
+
* Derives navigable routes from DB-backed models' metadata.
|
|
7
|
+
*
|
|
8
|
+
* A model is included only when it is a DB entity (`@db.table`, `@db.view`,
|
|
9
|
+
* or `@db.view.for`) AND a path can be derived: `@db.http.path` first, then
|
|
10
|
+
* the string value of `@db.table` / `@db.view`, then the type's own id
|
|
11
|
+
* as-is. Models where none of these yield a non-empty path are omitted.
|
|
12
|
+
*
|
|
13
|
+
* Routes are sorted by `order` ascending (undefined last, ties keep input
|
|
14
|
+
* order). Hidden models are returned with `hidden: true` — filtering and
|
|
15
|
+
* grouping are left to the consumer.
|
|
16
|
+
*/
|
|
17
|
+
function buildModelRoutes(models) {
|
|
18
|
+
const routes = [];
|
|
19
|
+
for (const model of models) {
|
|
20
|
+
const table = require_field_resolver.getFieldMeta(model, require_annotation_keys.DB_TABLE);
|
|
21
|
+
const view = require_field_resolver.getFieldMeta(model, require_annotation_keys.DB_VIEW);
|
|
22
|
+
const isView = view !== void 0 || require_field_resolver.hasFieldMeta(model, "db.view.for");
|
|
23
|
+
if (table === void 0 && !isView) continue;
|
|
24
|
+
const path = resolvePath(model, table, view);
|
|
25
|
+
if (path === void 0) continue;
|
|
26
|
+
const route = {
|
|
27
|
+
model,
|
|
28
|
+
path,
|
|
29
|
+
label: require_field_resolver.getFieldMeta(model, "meta.label") ?? require_str.humanizePath(path.slice(path.lastIndexOf("/") + 1)),
|
|
30
|
+
kind: isView ? "view" : "table"
|
|
31
|
+
};
|
|
32
|
+
const group = require_field_resolver.getFieldMeta(model, require_annotation_keys.UI_NAV_GROUP);
|
|
33
|
+
if (typeof group === "string") route.group = group;
|
|
34
|
+
const order = require_field_resolver.getFieldMeta(model, require_annotation_keys.UI_NAV_ORDER);
|
|
35
|
+
if (typeof order === "number") route.order = order;
|
|
36
|
+
if (require_field_resolver.getFieldMeta(model, "ui.nav.hidden") === true) route.hidden = true;
|
|
37
|
+
routes.push(route);
|
|
38
|
+
}
|
|
39
|
+
routes.sort((a, b) => {
|
|
40
|
+
const ao = a.order ?? Number.POSITIVE_INFINITY;
|
|
41
|
+
const bo = b.order ?? Number.POSITIVE_INFINITY;
|
|
42
|
+
return ao === bo ? 0 : ao - bo;
|
|
43
|
+
});
|
|
44
|
+
return routes;
|
|
45
|
+
}
|
|
46
|
+
/** `db.http.path` > string `db.table`/`db.view` name > type id — mirrors moost-db's controller prefix resolution, so the path matches the HTTP mount of a token-bound controller. */
|
|
47
|
+
function resolvePath(model, table, view) {
|
|
48
|
+
const http = require_field_resolver.getFieldMeta(model, require_annotation_keys.DB_HTTP_PATH);
|
|
49
|
+
let raw;
|
|
50
|
+
if (typeof http === "string") raw = http;
|
|
51
|
+
else if (typeof table === "string") raw = table;
|
|
52
|
+
else if (typeof view === "string") raw = view;
|
|
53
|
+
else if (typeof model.id === "string") raw = model.id;
|
|
54
|
+
if (!raw) return void 0;
|
|
55
|
+
const path = raw.replace(/^\/+|\/+$/g, "");
|
|
56
|
+
return path.length > 0 ? path : void 0;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
exports.buildModelRoutes = buildModelRoutes;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
2
|
+
|
|
3
|
+
//#region src/nav/model-routes.d.ts
|
|
4
|
+
/** A navigable route derived from a DB-backed model's metadata. */
|
|
5
|
+
interface TModelRoute {
|
|
6
|
+
model: TAtscriptAnnotatedType;
|
|
7
|
+
/** Route path without leading/trailing slashes — mountable anywhere. */
|
|
8
|
+
path: string;
|
|
9
|
+
/** Display label — from @meta.label or humanized last path segment. */
|
|
10
|
+
label: string;
|
|
11
|
+
kind: "table" | "view";
|
|
12
|
+
/** Nav section from @ui.nav.group — grouping is the consumer's job. */
|
|
13
|
+
group?: string;
|
|
14
|
+
/** Position from @ui.nav.order — lower first, undefined last. */
|
|
15
|
+
order?: number;
|
|
16
|
+
/** From @ui.nav.hidden — hidden routes are still returned; consumers filter. */
|
|
17
|
+
hidden?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Derives navigable routes from DB-backed models' metadata.
|
|
21
|
+
*
|
|
22
|
+
* A model is included only when it is a DB entity (`@db.table`, `@db.view`,
|
|
23
|
+
* or `@db.view.for`) AND a path can be derived: `@db.http.path` first, then
|
|
24
|
+
* the string value of `@db.table` / `@db.view`, then the type's own id
|
|
25
|
+
* as-is. Models where none of these yield a non-empty path are omitted.
|
|
26
|
+
*
|
|
27
|
+
* Routes are sorted by `order` ascending (undefined last, ties keep input
|
|
28
|
+
* order). Hidden models are returned with `hidden: true` — filtering and
|
|
29
|
+
* grouping are left to the consumer.
|
|
30
|
+
*/
|
|
31
|
+
declare function buildModelRoutes(models: readonly TAtscriptAnnotatedType[]): TModelRoute[];
|
|
32
|
+
//#endregion
|
|
33
|
+
export { TModelRoute, buildModelRoutes };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { TAtscriptAnnotatedType } from "@atscript/typescript/utils";
|
|
2
|
+
|
|
3
|
+
//#region src/nav/model-routes.d.ts
|
|
4
|
+
/** A navigable route derived from a DB-backed model's metadata. */
|
|
5
|
+
interface TModelRoute {
|
|
6
|
+
model: TAtscriptAnnotatedType;
|
|
7
|
+
/** Route path without leading/trailing slashes — mountable anywhere. */
|
|
8
|
+
path: string;
|
|
9
|
+
/** Display label — from @meta.label or humanized last path segment. */
|
|
10
|
+
label: string;
|
|
11
|
+
kind: "table" | "view";
|
|
12
|
+
/** Nav section from @ui.nav.group — grouping is the consumer's job. */
|
|
13
|
+
group?: string;
|
|
14
|
+
/** Position from @ui.nav.order — lower first, undefined last. */
|
|
15
|
+
order?: number;
|
|
16
|
+
/** From @ui.nav.hidden — hidden routes are still returned; consumers filter. */
|
|
17
|
+
hidden?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Derives navigable routes from DB-backed models' metadata.
|
|
21
|
+
*
|
|
22
|
+
* A model is included only when it is a DB entity (`@db.table`, `@db.view`,
|
|
23
|
+
* or `@db.view.for`) AND a path can be derived: `@db.http.path` first, then
|
|
24
|
+
* the string value of `@db.table` / `@db.view`, then the type's own id
|
|
25
|
+
* as-is. Models where none of these yield a non-empty path are omitted.
|
|
26
|
+
*
|
|
27
|
+
* Routes are sorted by `order` ascending (undefined last, ties keep input
|
|
28
|
+
* order). Hidden models are returned with `hidden: true` — filtering and
|
|
29
|
+
* grouping are left to the consumer.
|
|
30
|
+
*/
|
|
31
|
+
declare function buildModelRoutes(models: readonly TAtscriptAnnotatedType[]): TModelRoute[];
|
|
32
|
+
//#endregion
|
|
33
|
+
export { TModelRoute, buildModelRoutes };
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { DB_HTTP_PATH, DB_TABLE, DB_VIEW, UI_NAV_GROUP, UI_NAV_ORDER } from "../shared/annotation-keys.mjs";
|
|
2
|
+
import { getFieldMeta, hasFieldMeta } from "../shared/field-resolver.mjs";
|
|
3
|
+
import { humanizePath } from "../shared/str.mjs";
|
|
4
|
+
//#region src/nav/model-routes.ts
|
|
5
|
+
/**
|
|
6
|
+
* Derives navigable routes from DB-backed models' metadata.
|
|
7
|
+
*
|
|
8
|
+
* A model is included only when it is a DB entity (`@db.table`, `@db.view`,
|
|
9
|
+
* or `@db.view.for`) AND a path can be derived: `@db.http.path` first, then
|
|
10
|
+
* the string value of `@db.table` / `@db.view`, then the type's own id
|
|
11
|
+
* as-is. Models where none of these yield a non-empty path are omitted.
|
|
12
|
+
*
|
|
13
|
+
* Routes are sorted by `order` ascending (undefined last, ties keep input
|
|
14
|
+
* order). Hidden models are returned with `hidden: true` — filtering and
|
|
15
|
+
* grouping are left to the consumer.
|
|
16
|
+
*/
|
|
17
|
+
function buildModelRoutes(models) {
|
|
18
|
+
const routes = [];
|
|
19
|
+
for (const model of models) {
|
|
20
|
+
const table = getFieldMeta(model, DB_TABLE);
|
|
21
|
+
const view = getFieldMeta(model, DB_VIEW);
|
|
22
|
+
const isView = view !== void 0 || hasFieldMeta(model, "db.view.for");
|
|
23
|
+
if (table === void 0 && !isView) continue;
|
|
24
|
+
const path = resolvePath(model, table, view);
|
|
25
|
+
if (path === void 0) continue;
|
|
26
|
+
const route = {
|
|
27
|
+
model,
|
|
28
|
+
path,
|
|
29
|
+
label: getFieldMeta(model, "meta.label") ?? humanizePath(path.slice(path.lastIndexOf("/") + 1)),
|
|
30
|
+
kind: isView ? "view" : "table"
|
|
31
|
+
};
|
|
32
|
+
const group = getFieldMeta(model, UI_NAV_GROUP);
|
|
33
|
+
if (typeof group === "string") route.group = group;
|
|
34
|
+
const order = getFieldMeta(model, UI_NAV_ORDER);
|
|
35
|
+
if (typeof order === "number") route.order = order;
|
|
36
|
+
if (getFieldMeta(model, "ui.nav.hidden") === true) route.hidden = true;
|
|
37
|
+
routes.push(route);
|
|
38
|
+
}
|
|
39
|
+
routes.sort((a, b) => {
|
|
40
|
+
const ao = a.order ?? Number.POSITIVE_INFINITY;
|
|
41
|
+
const bo = b.order ?? Number.POSITIVE_INFINITY;
|
|
42
|
+
return ao === bo ? 0 : ao - bo;
|
|
43
|
+
});
|
|
44
|
+
return routes;
|
|
45
|
+
}
|
|
46
|
+
/** `db.http.path` > string `db.table`/`db.view` name > type id — mirrors moost-db's controller prefix resolution, so the path matches the HTTP mount of a token-bound controller. */
|
|
47
|
+
function resolvePath(model, table, view) {
|
|
48
|
+
const http = getFieldMeta(model, DB_HTTP_PATH);
|
|
49
|
+
let raw;
|
|
50
|
+
if (typeof http === "string") raw = http;
|
|
51
|
+
else if (typeof table === "string") raw = table;
|
|
52
|
+
else if (typeof view === "string") raw = view;
|
|
53
|
+
else if (typeof model.id === "string") raw = model.id;
|
|
54
|
+
if (!raw) return void 0;
|
|
55
|
+
const path = raw.replace(/^\/+|\/+$/g, "");
|
|
56
|
+
return path.length > 0 ? path : void 0;
|
|
57
|
+
}
|
|
58
|
+
//#endregion
|
|
59
|
+
export { buildModelRoutes };
|