@dforge-core/metadata 0.0.34 → 0.0.36
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 +45 -0
- package/dist/index.d.ts +217 -1
- package/dist/index.js +668 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/schemas/entity.schema.json +25 -4
- package/schemas/registers.schema.json +27 -13
- package/schemas/stored_procedures.schema.json +24 -1
- package/schemas/translations.schema.json +7 -0
- package/src/index.ts +35 -2
- package/src/registers/check-binding.ts +233 -0
- package/src/registers/check-declaration.ts +425 -0
- package/src/registers/entities.ts +79 -0
- package/src/registers/index.ts +17 -0
- package/src/registers/issues.ts +25 -0
- package/src/registers/read.ts +81 -0
- package/src/registers/types.ts +141 -0
- package/src/stored-procedures.ts +7 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// Registers — the authoring shape of `registers.json` and of an A / L column's
|
|
2
|
+
// binding. Mirror of registers.schema.json and docs/business-logic/registers.md §3–4.
|
|
3
|
+
|
|
4
|
+
/** The four kinds. Each requires and refuses a fixed set of properties. */
|
|
5
|
+
export type RegisterKind = "balance" | "turnover" | "info" | "accounting";
|
|
6
|
+
|
|
7
|
+
export const REGISTER_KINDS: readonly RegisterKind[] = ["balance", "turnover", "info", "accounting"];
|
|
8
|
+
|
|
9
|
+
export const isRegisterKind = (value: unknown): value is RegisterKind =>
|
|
10
|
+
typeof value === "string" && (REGISTER_KINDS as readonly string[]).includes(value);
|
|
11
|
+
|
|
12
|
+
/** Register codes: lowercase letters, digits and underscores, starting with a letter. */
|
|
13
|
+
export const REGISTER_CODE = /^[a-z][a-z0-9_]*$/;
|
|
14
|
+
|
|
15
|
+
/** A column name as `registers.json` takes one. */
|
|
16
|
+
export const REGISTER_COLUMN_NAME = /^[a-z_][a-z0-9_]*$/;
|
|
17
|
+
|
|
18
|
+
/** How much one cached row of a `totals` cache covers. */
|
|
19
|
+
export type RegisterTotalsPeriod = "day" | "month" | "quarter" | "year";
|
|
20
|
+
|
|
21
|
+
export const REGISTER_TOTALS_PERIODS: readonly RegisterTotalsPeriod[] = ["day", "month", "quarter", "year"];
|
|
22
|
+
|
|
23
|
+
/** A measured column of the register: one shared column, or one per side on an accounting register. */
|
|
24
|
+
export interface RegisterResourceDef {
|
|
25
|
+
/** The column, on the state entity / journal / record entity. Not with `debitField` / `creditField`. */
|
|
26
|
+
field?: string;
|
|
27
|
+
/** Debit-side column, on an accounting register. Declared with `creditField`. */
|
|
28
|
+
debitField?: string;
|
|
29
|
+
creditField?: string;
|
|
30
|
+
/** Every binding must map it (default true). False for a resource only some writers supply. */
|
|
31
|
+
required?: boolean;
|
|
32
|
+
/** Under `recordChangesOnly`: what the resource compares as before any record is in effect. */
|
|
33
|
+
absentAs?: number | string | boolean;
|
|
34
|
+
description?: string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** The per-period cache (registers.md §8). */
|
|
38
|
+
export interface RegisterTotalsDef {
|
|
39
|
+
entity: string;
|
|
40
|
+
period: RegisterTotalsPeriod;
|
|
41
|
+
/** Column holding the first date of the period a row covers. */
|
|
42
|
+
periodField: string;
|
|
43
|
+
/** Account column; required on an accounting register, refused elsewhere. */
|
|
44
|
+
accountField?: string;
|
|
45
|
+
/** Which dimensions the cache is grouped by; accounting only; all of them when omitted. */
|
|
46
|
+
dimensions?: string[];
|
|
47
|
+
/** Every resource of the register: `inField` + `outField`, or `debitField` + `creditField` on an accounting register. */
|
|
48
|
+
resources: Record<string, { inField?: string; outField?: string; debitField?: string; creditField?: string }>;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Where the chart says which analytic each account carries in which slot. */
|
|
52
|
+
export interface RegisterCompositionDef {
|
|
53
|
+
entity: string;
|
|
54
|
+
account: string;
|
|
55
|
+
slot: string;
|
|
56
|
+
analytic: string;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** One declaration of `registers.json`. */
|
|
60
|
+
export interface RegisterDef {
|
|
61
|
+
kind: RegisterKind;
|
|
62
|
+
label?: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
/** State table (`balance`) or record table (`info`). */
|
|
65
|
+
entity?: string;
|
|
66
|
+
/** Movement / posting entity (`balance` optional, `turnover` and `accounting` required). */
|
|
67
|
+
journal?: string;
|
|
68
|
+
/** Journal column stamped +1 / −1 (`balance`, `turnover`). */
|
|
69
|
+
journalDirection?: string;
|
|
70
|
+
/** Journal column holding each movement's date. */
|
|
71
|
+
journalDate?: string;
|
|
72
|
+
/** Record-entity column holding when a record takes effect (`info`). */
|
|
73
|
+
period?: string;
|
|
74
|
+
/** Record-entity jsonb column the writing document is stamped into (`info`); makes the register subordinate. */
|
|
75
|
+
recorder?: string;
|
|
76
|
+
recordChangesOnly?: boolean;
|
|
77
|
+
/** Chart of accounts (`accounting`). */
|
|
78
|
+
chart?: string;
|
|
79
|
+
lineMode?: "classic" | "compound";
|
|
80
|
+
/** Posting column pointing at the chart (classic). */
|
|
81
|
+
account?: string;
|
|
82
|
+
debitAccount?: string;
|
|
83
|
+
creditAccount?: string;
|
|
84
|
+
/** Analytic slot columns in slot order (classic). */
|
|
85
|
+
analyticFields?: string[];
|
|
86
|
+
debitAnalyticFields?: string[];
|
|
87
|
+
creditAnalyticFields?: string[];
|
|
88
|
+
composition?: RegisterCompositionDef;
|
|
89
|
+
/** 1–8 column names: the key of the register, on its carrier. */
|
|
90
|
+
dimensions: string[];
|
|
91
|
+
/** Two-sided dimensions of a compound register, with the column per side. */
|
|
92
|
+
sideDimensions?: Record<string, { debitField: string; creditField: string }>;
|
|
93
|
+
resources: Record<string, RegisterResourceDef>;
|
|
94
|
+
totals?: RegisterTotalsDef;
|
|
95
|
+
/** `balance`: may the state go below zero (default false). */
|
|
96
|
+
allowNegative?: boolean;
|
|
97
|
+
/** `balance`: create the state row on first movement (default true). */
|
|
98
|
+
autoCreate?: boolean;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** `registers.json`: register code → declaration. */
|
|
102
|
+
export type RegistersFile = Record<string, RegisterDef>;
|
|
103
|
+
|
|
104
|
+
/** A map entry: a column of the row read, or on a compound ledger one column per side. */
|
|
105
|
+
export type RegisterMapValue = string | { debit?: string; credit?: string };
|
|
106
|
+
|
|
107
|
+
/** `params` of an A / L column bound to a register (registers.md §4). */
|
|
108
|
+
export interface RegisterBindingParams {
|
|
109
|
+
/** `module_cd.register_cd`. */
|
|
110
|
+
register?: string;
|
|
111
|
+
/** The bool column recording the posted state, when not the column itself. */
|
|
112
|
+
stateField?: string;
|
|
113
|
+
direction?: "increase" | "decrease";
|
|
114
|
+
/** Per-row direction from a document value, instead of `direction`. */
|
|
115
|
+
sign?: { field: string; positive?: unknown[]; negative?: unknown[] };
|
|
116
|
+
/** Document column (or path / expression) supplying the journal date. */
|
|
117
|
+
dateField?: string;
|
|
118
|
+
dateTrunc?: "day" | "month" | "year";
|
|
119
|
+
lineEntity?: string;
|
|
120
|
+
lineField?: string;
|
|
121
|
+
groupLinesBy?: string[];
|
|
122
|
+
/** Register dimension or resource name → column of the row read. */
|
|
123
|
+
map?: Record<string, RegisterMapValue>;
|
|
124
|
+
/** On a line posting: register name → DOCUMENT column. */
|
|
125
|
+
headerMap?: Record<string, string>;
|
|
126
|
+
lockedFields?: string[];
|
|
127
|
+
lockedLineFields?: string[];
|
|
128
|
+
skipPostingWhenEmpty?: string[];
|
|
129
|
+
/** Classic ledger: the line's account column. */
|
|
130
|
+
accountField?: string;
|
|
131
|
+
debitAccountField?: string;
|
|
132
|
+
creditAccountField?: string;
|
|
133
|
+
periodDimField?: string;
|
|
134
|
+
/** Analytic kind → line column (classic ledger). */
|
|
135
|
+
analytics?: Record<string, string>;
|
|
136
|
+
debitAnalytics?: Record<string, string>;
|
|
137
|
+
creditAnalytics?: Record<string, string>;
|
|
138
|
+
movementMapping?: Record<string, string>;
|
|
139
|
+
/** Inline restatement of a register; refused alongside `register`. */
|
|
140
|
+
registries?: unknown;
|
|
141
|
+
}
|
package/src/stored-procedures.ts
CHANGED
|
@@ -72,4 +72,11 @@ export interface SpColumnDef {
|
|
|
72
72
|
width?: number;
|
|
73
73
|
/** Control parameters, the same shape an entity column's `params` takes. */
|
|
74
74
|
params?: Record<string, unknown>;
|
|
75
|
+
/**
|
|
76
|
+
* Reusable column domain supplying the control, datatype and option list.
|
|
77
|
+
* Unqualified resolves within this module, then tenant-created domains;
|
|
78
|
+
* `module_cd.domain_cd` binds to that module. Mutually exclusive with
|
|
79
|
+
* `fieldTypeCd`, `baseDatatypeCd` and `params`.
|
|
80
|
+
*/
|
|
81
|
+
domain?: string;
|
|
75
82
|
}
|