@dforge-core/metadata 0.0.22 → 0.0.23
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/CHANGELOG.md +134 -0
- package/README.md +45 -0
- package/dist/actions-DvYTrCbP.d.ts +60 -0
- package/dist/dsl/index.d.ts +223 -0
- package/dist/dsl/index.js +1108 -0
- package/dist/dsl/index.js.map +1 -0
- package/dist/index.d.ts +3 -60
- package/package.json +10 -4
- package/schemas/jobs.schema.json +2 -2
- package/src/dsl/builtins.ts +210 -0
- package/src/dsl/check.ts +450 -0
- package/src/dsl/index.ts +36 -0
- package/src/dsl/lexer.ts +364 -0
- package/src/dsl/parse.ts +639 -0
- package/src/dsl/types.ts +90 -0
package/src/dsl/types.ts
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
// Host-agnostic types for the DSL checker.
|
|
2
|
+
//
|
|
3
|
+
// The checker reports OFFSETS plus a 1-indexed line/column, and never an editor
|
|
4
|
+
// range: a language server turns offsets into `Position`s with its own document
|
|
5
|
+
// model, while a validator prints `logic/actions/x.dsl:12`. Emitting both keeps
|
|
6
|
+
// either host from having to re-derive the other.
|
|
7
|
+
|
|
8
|
+
import type { ActionExecutionMode } from "../actions";
|
|
9
|
+
|
|
10
|
+
export type DslSeverity = "error" | "warning" | "info";
|
|
11
|
+
|
|
12
|
+
/** One reported problem. `rule` is stable — hosts filter and suppress on it. */
|
|
13
|
+
export interface DslIssue {
|
|
14
|
+
/** Stable rule id, namespaced: `dsl/unknown-column`. */
|
|
15
|
+
rule: string;
|
|
16
|
+
severity: DslSeverity;
|
|
17
|
+
message: string;
|
|
18
|
+
/** Byte offsets into the source, for range-based hosts. */
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
/** 1-indexed position of `start`, for line-based reporters. */
|
|
22
|
+
line: number;
|
|
23
|
+
column: number;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Column membership test. Structurally satisfied by both `Set<string>` and
|
|
28
|
+
* `Map<string, unknown>`, so a host that already holds a column map passes it
|
|
29
|
+
* straight in rather than copying it into a set on every check.
|
|
30
|
+
*/
|
|
31
|
+
export interface ColumnLookup {
|
|
32
|
+
has(name: string): boolean;
|
|
33
|
+
readonly size: number;
|
|
34
|
+
/**
|
|
35
|
+
* The column names, if the lookup can enumerate them — `Set` and `Map` both
|
|
36
|
+
* can. Matching is case-insensitive at the other end (`EntityColumnLookup`
|
|
37
|
+
* builds an OrdinalIgnoreCase set) and a mixed-case column name is legal, so
|
|
38
|
+
* the checker folds case itself when it can read the keys.
|
|
39
|
+
*
|
|
40
|
+
* Without it, a lookup that is not already case-insensitive will report a
|
|
41
|
+
* spelling the server accepts. A host that cannot expose keys should make
|
|
42
|
+
* `has` case-insensitive instead.
|
|
43
|
+
*/
|
|
44
|
+
keys?(): Iterable<string>;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** The resolved entity a script's record context refers to. */
|
|
48
|
+
export interface EntityShape {
|
|
49
|
+
/** Module-qualified, e.g. `fin.invoice` — used in messages. */
|
|
50
|
+
qualified: string;
|
|
51
|
+
/**
|
|
52
|
+
* Every declared name on the entity, **trait-expanded** — built-in traits
|
|
53
|
+
* and the module's own `traits.json` alike — and including the virtual
|
|
54
|
+
* columns (reference, set, formula), exactly as `EntityColumnLookup` builds
|
|
55
|
+
* the compiler's set.
|
|
56
|
+
*
|
|
57
|
+
* Handing over an unexpanded set is the one mistake that turns this rule
|
|
58
|
+
* into a wall of false errors: the identity PK and `[status]` live in
|
|
59
|
+
* traits, not in `fields`. When in doubt pass `currentEntity: null` — a
|
|
60
|
+
* skipped check costs an install round trip, a wrong one blocks a pack.
|
|
61
|
+
*/
|
|
62
|
+
columns: ColumnLookup;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* What the checker knows about the script's surroundings. Every field is
|
|
67
|
+
* optional and every rule that reads one FAILS OPEN: with an empty context the
|
|
68
|
+
* text-only rules still run and the rest stand down silently.
|
|
69
|
+
*
|
|
70
|
+
* That is deliberate. A false "unknown column" on a correct script is far more
|
|
71
|
+
* damaging than a missed one — an editor would underline working code, and a
|
|
72
|
+
* validator would block a pack — so a rule that cannot resolve what it needs
|
|
73
|
+
* reports nothing.
|
|
74
|
+
*/
|
|
75
|
+
export interface DslContext {
|
|
76
|
+
/** Owning module code, for the qualify-your-entity-codes message. */
|
|
77
|
+
moduleCode?: string;
|
|
78
|
+
/** The action this script implements, from `ui/actions.json`. */
|
|
79
|
+
action?: {
|
|
80
|
+
code: string;
|
|
81
|
+
executionMode?: ActionExecutionMode;
|
|
82
|
+
};
|
|
83
|
+
/**
|
|
84
|
+
* Entity behind the record context (`[field]`). `null` or absent when it
|
|
85
|
+
* can't be resolved — a bridge module acting on another module's entity —
|
|
86
|
+
* and then every column rule stands down. A partial set is worse than
|
|
87
|
+
* none: pass `null`, not the fragment. See `EntityShape.columns`.
|
|
88
|
+
*/
|
|
89
|
+
currentEntity?: EntityShape | null;
|
|
90
|
+
}
|