@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 CHANGED
@@ -7,6 +7,51 @@ and this package adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.0.36] — 2026-10-08
11
+
12
+ ### Added
13
+
14
+ - **Registers, typed and checked:** `RegisterDef` / `RegistersFile` (the authoring shape of
15
+ `registers.json`), `RegisterBindingParams` (an A / L column's `params` bound to a register),
16
+ and the installer's rules as functions every tool can share — `checkRegister` /
17
+ `checkRegisters` for a declaration (per-kind required and refused properties, resource shapes,
18
+ the accounting and totals rules; with a `RegisterEntityLookup`, the entities it names and the
19
+ columns they store) and `checkRegisterBinding` for a binding (qualified and declared register,
20
+ the kind a column type may post to, map keys, unmapped required resources, locked fields, the
21
+ date column being locked, line and account fields, `headerMap` and `skipPostingWhenEmpty`
22
+ rules). Issues carry a JSON path, a stable code and a severity, and every rule fails open where
23
+ the caller can't resolve what is named. Helpers: `registerDimensions`, `registerResources`,
24
+ `registerCarrier`, `registerResourceShape`, `registerLineMode`, `registerRequiredProps`,
25
+ `registerRefusedProps`, `isPlainColumnRef`; constants `REGISTER_KINDS`, `REGISTER_CODE`,
26
+ `REGISTER_COLUMN_NAME`, `REGISTER_TOTALS_PERIODS`.
27
+
28
+ ## [0.0.35] — 2026-10-07
29
+
30
+ ### Added
31
+
32
+ - **Domain-backed stored-procedure result columns:** `stored_procedures.schema.json` and
33
+ `SpColumnDef` accept `domain`; the domain supplies `fieldTypeCd`, `baseDatatypeCd` and
34
+ `params`, so a status a report returns no longer repeats the entity's option list.
35
+ - **`entity.schema.json`:** an `A` column posting from lines takes `groupLinesBy` — line
36
+ columns whose distinct values each post one movement instead of one per line, with `map`
37
+ read over the grouped columns plus the document.
38
+ - **`entity.schema.json`:** a binding's `map`, `headerMap` and `dateField` value may be an
39
+ expression — a string starting with `=` holding an `F`-column formula over the row, with
40
+ one-hop `[ref].[column]` reads.
41
+ - **`entity.schema.json`:** an `A` binding takes `dateTrunc` (`day`, `month`, `year`), which
42
+ takes the `dateField` value back to the start of that period.
43
+ - **`registers.schema.json`:** a register takes `label`, translated under the new
44
+ `registers` section of `translations.schema.json`.
45
+ - **`registers.schema.json`:** an `info` register with a `recorder` takes
46
+ `recordChangesOnly`, and its resources take `absentAs` — what a resource compares as
47
+ before any record is in effect.
48
+
49
+ ### Changed
50
+
51
+ - **`entity.schema.json`:** an index is typed — `fields` (required) plus an optional `using`
52
+ (`btree`, `hash`, `gin`, `gist`, `brin`). Any other key, `columns` among them, is refused;
53
+ the installer used to skip such an index without a word.
54
+
10
55
  ## [0.0.34] — 2026-10-06
11
56
 
12
57
  ### Added
package/dist/index.d.ts CHANGED
@@ -1134,6 +1134,13 @@ interface SpColumnDef {
1134
1134
  width?: number;
1135
1135
  /** Control parameters, the same shape an entity column's `params` takes. */
1136
1136
  params?: Record<string, unknown>;
1137
+ /**
1138
+ * Reusable column domain supplying the control, datatype and option list.
1139
+ * Unqualified resolves within this module, then tenant-created domains;
1140
+ * `module_cd.domain_cd` binds to that module. Mutually exclusive with
1141
+ * `fieldTypeCd`, `baseDatatypeCd` and `params`.
1142
+ */
1143
+ domain?: string;
1137
1144
  }
1138
1145
 
1139
1146
  /** Author block on a manifest. */
@@ -1549,6 +1556,215 @@ type SettingDef = (SettingDefBase & {
1549
1556
  /** A `settings.json` file: setting code → definition. */
1550
1557
  type SettingsFile = Record<string, SettingDef>;
1551
1558
 
1559
+ /** The four kinds. Each requires and refuses a fixed set of properties. */
1560
+ type RegisterKind = "balance" | "turnover" | "info" | "accounting";
1561
+ declare const REGISTER_KINDS: readonly RegisterKind[];
1562
+ declare const isRegisterKind: (value: unknown) => value is RegisterKind;
1563
+ /** Register codes: lowercase letters, digits and underscores, starting with a letter. */
1564
+ declare const REGISTER_CODE: RegExp;
1565
+ /** A column name as `registers.json` takes one. */
1566
+ declare const REGISTER_COLUMN_NAME: RegExp;
1567
+ /** How much one cached row of a `totals` cache covers. */
1568
+ type RegisterTotalsPeriod = "day" | "month" | "quarter" | "year";
1569
+ declare const REGISTER_TOTALS_PERIODS: readonly RegisterTotalsPeriod[];
1570
+ /** A measured column of the register: one shared column, or one per side on an accounting register. */
1571
+ interface RegisterResourceDef {
1572
+ /** The column, on the state entity / journal / record entity. Not with `debitField` / `creditField`. */
1573
+ field?: string;
1574
+ /** Debit-side column, on an accounting register. Declared with `creditField`. */
1575
+ debitField?: string;
1576
+ creditField?: string;
1577
+ /** Every binding must map it (default true). False for a resource only some writers supply. */
1578
+ required?: boolean;
1579
+ /** Under `recordChangesOnly`: what the resource compares as before any record is in effect. */
1580
+ absentAs?: number | string | boolean;
1581
+ description?: string;
1582
+ }
1583
+ /** The per-period cache (registers.md §8). */
1584
+ interface RegisterTotalsDef {
1585
+ entity: string;
1586
+ period: RegisterTotalsPeriod;
1587
+ /** Column holding the first date of the period a row covers. */
1588
+ periodField: string;
1589
+ /** Account column; required on an accounting register, refused elsewhere. */
1590
+ accountField?: string;
1591
+ /** Which dimensions the cache is grouped by; accounting only; all of them when omitted. */
1592
+ dimensions?: string[];
1593
+ /** Every resource of the register: `inField` + `outField`, or `debitField` + `creditField` on an accounting register. */
1594
+ resources: Record<string, {
1595
+ inField?: string;
1596
+ outField?: string;
1597
+ debitField?: string;
1598
+ creditField?: string;
1599
+ }>;
1600
+ }
1601
+ /** Where the chart says which analytic each account carries in which slot. */
1602
+ interface RegisterCompositionDef {
1603
+ entity: string;
1604
+ account: string;
1605
+ slot: string;
1606
+ analytic: string;
1607
+ }
1608
+ /** One declaration of `registers.json`. */
1609
+ interface RegisterDef {
1610
+ kind: RegisterKind;
1611
+ label?: string;
1612
+ description?: string;
1613
+ /** State table (`balance`) or record table (`info`). */
1614
+ entity?: string;
1615
+ /** Movement / posting entity (`balance` optional, `turnover` and `accounting` required). */
1616
+ journal?: string;
1617
+ /** Journal column stamped +1 / −1 (`balance`, `turnover`). */
1618
+ journalDirection?: string;
1619
+ /** Journal column holding each movement's date. */
1620
+ journalDate?: string;
1621
+ /** Record-entity column holding when a record takes effect (`info`). */
1622
+ period?: string;
1623
+ /** Record-entity jsonb column the writing document is stamped into (`info`); makes the register subordinate. */
1624
+ recorder?: string;
1625
+ recordChangesOnly?: boolean;
1626
+ /** Chart of accounts (`accounting`). */
1627
+ chart?: string;
1628
+ lineMode?: "classic" | "compound";
1629
+ /** Posting column pointing at the chart (classic). */
1630
+ account?: string;
1631
+ debitAccount?: string;
1632
+ creditAccount?: string;
1633
+ /** Analytic slot columns in slot order (classic). */
1634
+ analyticFields?: string[];
1635
+ debitAnalyticFields?: string[];
1636
+ creditAnalyticFields?: string[];
1637
+ composition?: RegisterCompositionDef;
1638
+ /** 1–8 column names: the key of the register, on its carrier. */
1639
+ dimensions: string[];
1640
+ /** Two-sided dimensions of a compound register, with the column per side. */
1641
+ sideDimensions?: Record<string, {
1642
+ debitField: string;
1643
+ creditField: string;
1644
+ }>;
1645
+ resources: Record<string, RegisterResourceDef>;
1646
+ totals?: RegisterTotalsDef;
1647
+ /** `balance`: may the state go below zero (default false). */
1648
+ allowNegative?: boolean;
1649
+ /** `balance`: create the state row on first movement (default true). */
1650
+ autoCreate?: boolean;
1651
+ }
1652
+ /** `registers.json`: register code → declaration. */
1653
+ type RegistersFile = Record<string, RegisterDef>;
1654
+ /** A map entry: a column of the row read, or on a compound ledger one column per side. */
1655
+ type RegisterMapValue = string | {
1656
+ debit?: string;
1657
+ credit?: string;
1658
+ };
1659
+ /** `params` of an A / L column bound to a register (registers.md §4). */
1660
+ interface RegisterBindingParams {
1661
+ /** `module_cd.register_cd`. */
1662
+ register?: string;
1663
+ /** The bool column recording the posted state, when not the column itself. */
1664
+ stateField?: string;
1665
+ direction?: "increase" | "decrease";
1666
+ /** Per-row direction from a document value, instead of `direction`. */
1667
+ sign?: {
1668
+ field: string;
1669
+ positive?: unknown[];
1670
+ negative?: unknown[];
1671
+ };
1672
+ /** Document column (or path / expression) supplying the journal date. */
1673
+ dateField?: string;
1674
+ dateTrunc?: "day" | "month" | "year";
1675
+ lineEntity?: string;
1676
+ lineField?: string;
1677
+ groupLinesBy?: string[];
1678
+ /** Register dimension or resource name → column of the row read. */
1679
+ map?: Record<string, RegisterMapValue>;
1680
+ /** On a line posting: register name → DOCUMENT column. */
1681
+ headerMap?: Record<string, string>;
1682
+ lockedFields?: string[];
1683
+ lockedLineFields?: string[];
1684
+ skipPostingWhenEmpty?: string[];
1685
+ /** Classic ledger: the line's account column. */
1686
+ accountField?: string;
1687
+ debitAccountField?: string;
1688
+ creditAccountField?: string;
1689
+ periodDimField?: string;
1690
+ /** Analytic kind → line column (classic ledger). */
1691
+ analytics?: Record<string, string>;
1692
+ debitAnalytics?: Record<string, string>;
1693
+ creditAnalytics?: Record<string, string>;
1694
+ movementMapping?: Record<string, string>;
1695
+ /** Inline restatement of a register; refused alongside `register`. */
1696
+ registries?: unknown;
1697
+ }
1698
+
1699
+ type Raw = Record<string, unknown>;
1700
+ /** A declaration's dimension names, only the ones that are strings. */
1701
+ declare const registerDimensions: (def: RegisterDef | Raw) => string[];
1702
+ /** A declaration's resources in file order, each with its definition object. */
1703
+ declare const registerResources: (def: RegisterDef | Raw) => Array<{
1704
+ name: string;
1705
+ def: Raw;
1706
+ }>;
1707
+ /** The entity the dimensions, resources and stamps are columns of. */
1708
+ declare function registerCarrier(def: RegisterDef | Raw): string | undefined;
1709
+ /** How a resource names its column: one shared column, or one per side. */
1710
+ declare const registerResourceShape: (resource: RegisterResourceDef | Raw) => "field" | "split";
1711
+ declare const registerLineMode: (def: RegisterDef | Raw) => "classic" | "compound";
1712
+ declare const registerRefusedProps: (kind: RegisterKind) => readonly string[];
1713
+ declare const registerRequiredProps: (kind: RegisterKind) => readonly string[];
1714
+
1715
+ type IssuePath = Array<string | number>;
1716
+ /** One finding, addressed by a JSON path relative to what was checked. */
1717
+ interface RegisterIssue {
1718
+ path: IssuePath;
1719
+ message: string;
1720
+ /** `error`: install refuses it. `warning`: worth a look. */
1721
+ severity: "error" | "warning";
1722
+ /** Stable id, namespaced `registers/*` for a declaration and `entity/register-*` for a binding. */
1723
+ code: string;
1724
+ }
1725
+
1726
+ /**
1727
+ * What an entity a declaration names looks like, as far as the caller knows.
1728
+ * `columns` is left undefined when they can't be listed (a dependency known
1729
+ * only from its contract), and no column rule runs against it.
1730
+ */
1731
+ interface RegisterEntityInfo {
1732
+ columns?: Iterable<string>;
1733
+ }
1734
+ /**
1735
+ * Resolves an entity code as `registers.json` writes it — bare for the module's
1736
+ * own, `module.entity` for another's. Returns `null` when nothing can be known
1737
+ * (the module named isn't available: the rule stands down) and `undefined` when
1738
+ * the module is known and has no such entity.
1739
+ */
1740
+ type RegisterEntityLookup = (code: string) => RegisterEntityInfo | null | undefined;
1741
+
1742
+ /**
1743
+ * Check one declaration against the schema's per-kind rules and the installer's
1744
+ * — paths relative to the declaration. With a lookup, the entities it names are
1745
+ * checked to exist and the columns it names to be stored on them.
1746
+ */
1747
+ declare function checkRegister(raw: unknown, lookup?: RegisterEntityLookup): RegisterIssue[];
1748
+ /**
1749
+ * Check a whole `registers.json`: every declaration (paths prefixed by its
1750
+ * code), plus the codes themselves and the file's limits.
1751
+ */
1752
+ declare function checkRegisters(file: unknown, lookup?: RegisterEntityLookup): RegisterIssue[];
1753
+
1754
+ /** What a binding is checked against: the parts of a declaration it has to agree with. */
1755
+ type RegisterBindingTarget = Pick<RegisterDef, "kind" | "dimensions" | "resources" | "recorder" | "lineMode" | "sideDimensions">;
1756
+ /** A reference path (`ref.column`), an expression (`=…`) or a quoted constant — not a plain column. */
1757
+ declare const isPlainColumnRef: (value: string) => boolean;
1758
+ /**
1759
+ * Check an A / L column's `params` against the register it binds — paths
1760
+ * relative to `params`. `register` is the resolved declaration, `undefined`
1761
+ * when the module named declares no such register, `null` when that module
1762
+ * can't be seen (every rule that needs the declaration then stands down).
1763
+ */
1764
+ declare function checkRegisterBinding(columnType: "A" | "L", rawParams: unknown, register: RegisterBindingTarget | null | undefined, options?: {
1765
+ moduleCode?: string;
1766
+ }): RegisterIssue[];
1767
+
1552
1768
  /** A single scheduled-job declaration. */
1553
1769
  interface JobDef {
1554
1770
  /** Unique identifier within the module. */
@@ -1784,4 +2000,4 @@ declare const flagDefs: readonly {
1784
2000
  label: string;
1785
2001
  }[];
1786
2002
 
1787
- export { AGG_TYPE_LIST, type AccumulationConfig, AggType, type AlignType, type AuditHistoryLevel, type BaseDatatypeCd, type CalendarViewConfig, type CardFieldDef, type CardFieldEntry, type CardLayout, type CardLayoutDef, type CardLayoutsFile, type CardSection, type CardSetConfig, type CardTabRef, type ColumnDef, type ColumnGroupSection, type ColumnTypeCd, type ColumnTypeDef, DEP_COLUMN_TYPES, type DataSource, type DataViewDef, type DataViewsFile, type Dataset, type DepColumn, type DepColumnMode, type DepColumnType, type DepEntity, type DepProvenance, type DepProvenanceKind, type DepsFile, type DeriveOptions, type DiagramDef, type DiagramDetail, type DiagramEntity, type DiagramFile, type DiagramRelation, type DiagramViewConfig, type DomainDef, type DomainsFile, type EntityDef, type EntityEvent, type EntityReference, type EntityViewColumnDef, type EntityViewDef, FILTER_GROUP_OPERATORS, FILTER_OPERATORS, type FieldDef, type FieldLink, type FieldOption, type FieldTypeCd, type FieldTypeDef, type Filter, type FilterCondition, type FilterGroup, type FilterGroupOperator, type FilterOperator, type FlagCd, type FolderDef, type FolderEntityBinding, type FoldersFile, type JobDef, type JobsFile, type KanbanViewConfig, type LedgerRegistryEntry, type ListLevelConfig, type ListViewConfig, type ManifestAuthor, type ManifestDef, type MenuDef, type MenuItemDef, type MenuItemType, type MenusFile, type ModuleDependency, type ModuleFeature, NUMERIC_TOTAL, type NamedKind, type NumberSequenceDef, type ParamDef, type ParamDefBase, type PeriodConfig, type PrintMargins, type PrintPageSettings, type PrintTemplateDef, type PrintTemplatesFile, type ReportDef, type ReportEntityAttachment, type ReportLayout, type ReportPanel, type ReportQuery, type ReportsFile, type RoleDef, type RolesFile, type SeedDataFile, type SeedDataRepeat, type SetSection, type SettingBaseDatatype, type SettingDef, type SettingsFile, type SignConfig, type SortClause, type SpColumnDef, type SpParamDef, type StoredProcedureDef, type StoredProceduresFile, type TabGroupSection, type TraitCd, type TraitDef, type TraitFieldConflict, type TraitsFile, type TranslatedAction, type TranslatedEntity, type TranslatedMenu, type TranslatedOption, type TranslatedReport, type TranslatedWithOptions, type TranslationsFile, type TreeGridViewConfig, type TriggerDef, type TriggersFile, type ViewColumn, type ViewType, type VizType, type WebhookPayload, type WebhookSubscription, type WebhooksFile, baseDatatypes, baseToDbDatatype, chartTypes, columnTypes, dataViewKinds, defaultParams, deriveBaseDatatype, deriveDbDatatype, expandTrait, expandTraits, fieldTypeCds, fieldTypes, fieldTypesByColumnType, flagDefs, getColumnType, getFieldType, getIdentityKeys, getLinks, getPrimaryKeys, getTrait, isFieldTypeCd, traitFieldConflicts, traits, vizTypes };
2003
+ export { AGG_TYPE_LIST, type AccumulationConfig, AggType, type AlignType, type AuditHistoryLevel, type BaseDatatypeCd, type CalendarViewConfig, type CardFieldDef, type CardFieldEntry, type CardLayout, type CardLayoutDef, type CardLayoutsFile, type CardSection, type CardSetConfig, type CardTabRef, type ColumnDef, type ColumnGroupSection, type ColumnTypeCd, type ColumnTypeDef, DEP_COLUMN_TYPES, type DataSource, type DataViewDef, type DataViewsFile, type Dataset, type DepColumn, type DepColumnMode, type DepColumnType, type DepEntity, type DepProvenance, type DepProvenanceKind, type DepsFile, type DeriveOptions, type DiagramDef, type DiagramDetail, type DiagramEntity, type DiagramFile, type DiagramRelation, type DiagramViewConfig, type DomainDef, type DomainsFile, type EntityDef, type EntityEvent, type EntityReference, type EntityViewColumnDef, type EntityViewDef, FILTER_GROUP_OPERATORS, FILTER_OPERATORS, type FieldDef, type FieldLink, type FieldOption, type FieldTypeCd, type FieldTypeDef, type Filter, type FilterCondition, type FilterGroup, type FilterGroupOperator, type FilterOperator, type FlagCd, type FolderDef, type FolderEntityBinding, type FoldersFile, type JobDef, type JobsFile, type KanbanViewConfig, type LedgerRegistryEntry, type ListLevelConfig, type ListViewConfig, type ManifestAuthor, type ManifestDef, type MenuDef, type MenuItemDef, type MenuItemType, type MenusFile, type ModuleDependency, type ModuleFeature, NUMERIC_TOTAL, type NamedKind, type NumberSequenceDef, type ParamDef, type ParamDefBase, type PeriodConfig, type PrintMargins, type PrintPageSettings, type PrintTemplateDef, type PrintTemplatesFile, REGISTER_CODE, REGISTER_COLUMN_NAME, REGISTER_KINDS, REGISTER_TOTALS_PERIODS, type RegisterBindingParams, type RegisterBindingTarget, type RegisterCompositionDef, type RegisterDef, type RegisterEntityInfo, type RegisterEntityLookup, type RegisterIssue, type RegisterKind, type RegisterMapValue, type RegisterResourceDef, type RegisterTotalsDef, type RegisterTotalsPeriod, type RegistersFile, type ReportDef, type ReportEntityAttachment, type ReportLayout, type ReportPanel, type ReportQuery, type ReportsFile, type RoleDef, type RolesFile, type SeedDataFile, type SeedDataRepeat, type SetSection, type SettingBaseDatatype, type SettingDef, type SettingsFile, type SignConfig, type SortClause, type SpColumnDef, type SpParamDef, type StoredProcedureDef, type StoredProceduresFile, type TabGroupSection, type TraitCd, type TraitDef, type TraitFieldConflict, type TraitsFile, type TranslatedAction, type TranslatedEntity, type TranslatedMenu, type TranslatedOption, type TranslatedReport, type TranslatedWithOptions, type TranslationsFile, type TreeGridViewConfig, type TriggerDef, type TriggersFile, type ViewColumn, type ViewType, type VizType, type WebhookPayload, type WebhookSubscription, type WebhooksFile, baseDatatypes, baseToDbDatatype, chartTypes, checkRegister, checkRegisterBinding, checkRegisters, columnTypes, dataViewKinds, defaultParams, deriveBaseDatatype, deriveDbDatatype, expandTrait, expandTraits, fieldTypeCds, fieldTypes, fieldTypesByColumnType, flagDefs, getColumnType, getFieldType, getIdentityKeys, getLinks, getPrimaryKeys, getTrait, isFieldTypeCd, isPlainColumnRef, isRegisterKind, registerCarrier, registerDimensions, registerLineMode, registerRefusedProps, registerRequiredProps, registerResourceShape, registerResources, traitFieldConflicts, traits, vizTypes };