@sentropic/diagram-core 0.0.0-stage → 0.2.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/LICENSE +21 -0
- package/LICENSE.THIRD-PARTY.md +28 -0
- package/README.md +279 -2
- package/dist/archimate-cases.d.ts +11 -0
- package/dist/archimate-cases.js +30 -0
- package/dist/attributes.d.ts +133 -0
- package/dist/attributes.js +313 -0
- package/dist/bindings.d.ts +81 -0
- package/dist/bindings.js +225 -0
- package/dist/canonical.d.ts +47 -0
- package/dist/canonical.js +117 -0
- package/dist/chain-profile.d.ts +4 -0
- package/dist/chain-profile.js +85 -0
- package/dist/chain.d.ts +11 -0
- package/dist/chain.js +284 -0
- package/dist/commands.d.ts +279 -0
- package/dist/commands.js +1194 -0
- package/dist/diagnostics.d.ts +63 -0
- package/dist/diagnostics.js +30 -0
- package/dist/document.d.ts +153 -0
- package/dist/document.js +58 -0
- package/dist/erd-validate.d.ts +5 -0
- package/dist/erd-validate.js +33 -0
- package/dist/erd.d.ts +69 -0
- package/dist/erd.js +72 -0
- package/dist/flows.d.ts +36 -0
- package/dist/flows.js +144 -0
- package/dist/fold.d.ts +147 -0
- package/dist/fold.js +720 -0
- package/dist/hash.d.ts +19 -0
- package/dist/hash.js +56 -0
- package/dist/index.d.ts +35 -0
- package/dist/index.js +35 -0
- package/dist/migrate.d.ts +69 -0
- package/dist/migrate.js +402 -0
- package/dist/multiplicity.d.ts +31 -0
- package/dist/multiplicity.js +36 -0
- package/dist/presentation-apply.d.ts +32 -0
- package/dist/presentation-apply.js +257 -0
- package/dist/presentation-catalog.d.ts +217 -0
- package/dist/presentation-catalog.js +263 -0
- package/dist/presentation-pinned-adapter.d.ts +7 -0
- package/dist/presentation-pinned-adapter.js +7 -0
- package/dist/presentation-relations.d.ts +4 -0
- package/dist/presentation-relations.js +17 -0
- package/dist/presentation-validate.d.ts +13 -0
- package/dist/presentation-validate.js +798 -0
- package/dist/presentation.d.ts +145 -0
- package/dist/presentation.js +266 -0
- package/dist/profile-migrations.d.ts +83 -0
- package/dist/profile-migrations.js +959 -0
- package/dist/profile.d.ts +250 -0
- package/dist/profile.js +681 -0
- package/dist/profiles/archimate-matrix.d.ts +31 -0
- package/dist/profiles/archimate-matrix.js +111 -0
- package/dist/profiles/archimate2.d.ts +21 -0
- package/dist/profiles/archimate2.js +126 -0
- package/dist/profiles/erd.d.ts +6 -0
- package/dist/profiles/erd.js +29 -0
- package/dist/profiles/generic.d.ts +14 -0
- package/dist/profiles/generic.js +111 -0
- package/dist/profiles/generic2.d.ts +20 -0
- package/dist/profiles/generic2.js +161 -0
- package/dist/profiles/index.d.ts +39 -0
- package/dist/profiles/index.js +92 -0
- package/dist/profiles/skeletons.d.ts +32 -0
- package/dist/profiles/skeletons.js +225 -0
- package/dist/profiles/uml2.d.ts +11 -0
- package/dist/profiles/uml2.js +138 -0
- package/dist/refs.d.ts +112 -0
- package/dist/refs.js +139 -0
- package/dist/relation-types.d.ts +6 -0
- package/dist/relation-types.js +16 -0
- package/dist/resolver.d.ts +50 -0
- package/dist/resolver.js +259 -0
- package/dist/sha256.d.ts +16 -0
- package/dist/sha256.js +190 -0
- package/dist/state.d.ts +20 -0
- package/dist/state.js +23 -0
- package/dist/validate.d.ts +51 -0
- package/dist/validate.js +2037 -0
- package/dist/view-schema-pin.d.ts +54 -0
- package/dist/view-schema-pin.js +169 -0
- package/dist/view.d.ts +228 -0
- package/dist/view.js +81 -0
- package/package.json +35 -4
- package/schemas/diagram-view-schema-3.json +1 -0
- package/schemas/diagram-view-schema-3.sha256 +1 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 rhanka
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
<!-- GÉNÉRÉ par scripts/generate-third-party-notices.mjs — ne pas éditer à la main. -->
|
|
2
|
+
<!-- Régénérer : `npm run notices:generate`. La dérive fait échouer `npm run licensing:check`. -->
|
|
3
|
+
|
|
4
|
+
# Notices de tiers — `@sentropic/diagram-core`
|
|
5
|
+
|
|
6
|
+
Licence de ce paquet : **MIT** — voir `LICENSE`.
|
|
7
|
+
Ce fichier couvre le code **tiers**, et lui seul.
|
|
8
|
+
|
|
9
|
+
Périmètre, littéralement : le code tiers recopié dans ce paquet (§1) et la
|
|
10
|
+
fermeture transitive de ses dépendances d'exécution (§2). Hors périmètre, et
|
|
11
|
+
c'est délibéré : les `peerDependencies`, fournies par le consommateur, et les
|
|
12
|
+
`devDependencies`, qui n'entrent dans aucun tarball.
|
|
13
|
+
|
|
14
|
+
## 1. Code tiers recopié dans ce paquet
|
|
15
|
+
|
|
16
|
+
**Rien de mesuré.** Ce qui a été cherché, littéralement : les données de
|
|
17
|
+
tracé publiées par `lucide`, comparées octet pour octet aux sources de ce
|
|
18
|
+
paquet. Aucune n'y figure.
|
|
19
|
+
|
|
20
|
+
Ce qui n'a **pas** été cherché : tout amont non déclaré dans
|
|
21
|
+
`scripts/third-party-sources.json`. L'absence ci-dessus est donc l'absence
|
|
22
|
+
de ces données-là, et non un constat d'absence générale de code tiers dans
|
|
23
|
+
ce paquet.
|
|
24
|
+
|
|
25
|
+
## 2. Dépendances installées avec ce paquet
|
|
26
|
+
|
|
27
|
+
Aucune. Ce paquet ne déclare aucune dépendance tierce : installer ce paquet
|
|
28
|
+
n'installe aucun code tiers de notre fait.
|
package/README.md
CHANGED
|
@@ -1,3 +1,280 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @sentropic/diagram-core
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The typed semantic core of the diagram programme: versioned documents and
|
|
4
|
+
profiles, views with occurrences, and transactional commands that return their
|
|
5
|
+
logical inverse. No runtime dependency, no DOM, no framework, no renderer.
|
|
6
|
+
|
|
7
|
+
This package is public as `@sentropic/diagram-core` (0.1.0, first publication).
|
|
8
|
+
Pin the exact version — never a range, never `latest`. Publication is CI-only
|
|
9
|
+
through `.github/workflows/diagram-core-publish.yml` on tags `diagram-core-v<version>`.
|
|
10
|
+
|
|
11
|
+
## The five objects, and which two live here
|
|
12
|
+
|
|
13
|
+
| Object | Where it lives |
|
|
14
|
+
|---|---|
|
|
15
|
+
| `SemanticDocument` — business truth | **here** |
|
|
16
|
+
| `ViewDocument` — drawings of that truth | **here** |
|
|
17
|
+
| `ProcessingSnapshot` — normalised input of a layout | `@sentropic/graph/processing` |
|
|
18
|
+
| `Scene` / `GeometryFrame` — what a backend draws | GD-M2-CANVAS, not written |
|
|
19
|
+
| `TextSource` — imported text with its AST and spans | GD-M4 codecs, not written |
|
|
20
|
+
|
|
21
|
+
## The model
|
|
22
|
+
|
|
23
|
+
### References are nominal, and they say their own namespace
|
|
24
|
+
|
|
25
|
+
Seven reference types, none assignable to another: `EntityRef`, `RelationRef`,
|
|
26
|
+
`OccurrenceRef`, `PortRef`, `ViewRef`, `ResourceRef`, `DocumentRef`. The brand is
|
|
27
|
+
a phantom property keyed by a module-private `unique symbol`, so nothing of it
|
|
28
|
+
survives compilation; at runtime a reference carries its identity namespace as a
|
|
29
|
+
prefix (`entity:alpha`, `occurrence:alpha-1`), which is how a function that
|
|
30
|
+
expects an occurrence refuses an entity that crossed a file or process boundary —
|
|
31
|
+
with a `reference-type-mismatch` diagnostic, not a silent misread.
|
|
32
|
+
|
|
33
|
+
The spec names five. `RelationRef` and `DocumentRef` are declared because a
|
|
34
|
+
relation occurrence points at a relation and a view at a document; typing either
|
|
35
|
+
as `EntityRef` would be exactly the mis-typing the rule exists to prevent.
|
|
36
|
+
|
|
37
|
+
### A document is a schema, not a bag
|
|
38
|
+
|
|
39
|
+
An entity is discriminated by `profile` **and** `type`, and every attribute is
|
|
40
|
+
read through the schema of that type: `text`, `boolean`, `date` (ISO-8601),
|
|
41
|
+
`quantity` (a magnitude **and** its unit), `enum`, `reference` (with the
|
|
42
|
+
namespace it must carry) or a **bounded** `collection` — `maxItems` is required,
|
|
43
|
+
because an unbounded list is how a schema becomes a bag. An attribute the schema
|
|
44
|
+
does not declare is refused; unmodelled content belongs in an extension.
|
|
45
|
+
|
|
46
|
+
A relation has two or more endpoints, each with a **role** declared by its type,
|
|
47
|
+
a cardinality per role and a declared set of legal targets. A hyperrelation
|
|
48
|
+
(`generic@1`'s `association`, 2..8 members) keeps one business id, which is what
|
|
49
|
+
lets a projection turn it into a junction node without losing it.
|
|
50
|
+
|
|
51
|
+
A semantic port belongs to an entity and has a direction. Its side, order and
|
|
52
|
+
anchor are geometric and live on the **port occurrence** in a view.
|
|
53
|
+
|
|
54
|
+
Collections are records keyed by the element's own reference. Insertion order is
|
|
55
|
+
therefore never content, and every order that matters is an explicit field
|
|
56
|
+
(`PortOccurrence.order`, `EntityOccurrence.z`).
|
|
57
|
+
|
|
58
|
+
### Profiles are versioned schema modules
|
|
59
|
+
|
|
60
|
+
`generic@1` is the only **complete** profile of this lot. `bpmn@1`,
|
|
61
|
+
`archimate@1` and `uml@1` are declared **skeletons**: they carry
|
|
62
|
+
`completeness: "skeleton"`, their types and relation arity are declared and
|
|
63
|
+
validated by the same machinery, their qualification fixtures are partial, and
|
|
64
|
+
each lists in `notes` what it does **not** declare. **No BPMN, ArchiMate or UML
|
|
65
|
+
conformance is claimed anywhere in this package.** The native profiles are GD-M3.
|
|
66
|
+
|
|
67
|
+
### A view holds drawings, never facts
|
|
68
|
+
|
|
69
|
+
One entity has N occurrences in a view and occurrences in several views. Removing
|
|
70
|
+
an occurrence removes a drawing. Deleting the **entity** requires an explicit
|
|
71
|
+
policy for its occurrences, its relations and its ports — the field is mandatory
|
|
72
|
+
in the type and a malformed one is `delete-policy-required` at runtime. A visual
|
|
73
|
+
group declares itself and membership lives on the occurrence (`group`), so there
|
|
74
|
+
is one source of truth for it.
|
|
75
|
+
|
|
76
|
+
The persisted presentation state holds a camera (`x`, `y`, `zoom`) and an
|
|
77
|
+
optional grid. It is stored here, and deliberately not imported from a renderer
|
|
78
|
+
package: a migration-versioned persisted schema must not be hostage to another
|
|
79
|
+
package's type evolution.
|
|
80
|
+
|
|
81
|
+
### Endpoint provenance: fold and chain
|
|
82
|
+
|
|
83
|
+
Endpoints attach a relation role to a drawn occurrence. When the drawing differs
|
|
84
|
+
from its semantic target, exactly one provenance arm supplies the witness:
|
|
85
|
+
|
|
86
|
+
| Form | Fields beyond `role`, `occurrence` |
|
|
87
|
+
| --- | --- |
|
|
88
|
+
| Plain | None; the occurrence draws the role target directly. |
|
|
89
|
+
| Fold | `semanticTarget` and `sourceOccurrence`; the current fold proves the representative. |
|
|
90
|
+
| Chain | `semanticTarget` and `chainProvenance`; `sourceOccurrence` is absent. |
|
|
91
|
+
|
|
92
|
+
`chainProvenance` contains a profile-declared `predicateId`, ordered relation
|
|
93
|
+
`hops` from the semantic target to the drawn entity, and aggregate-only `members`.
|
|
94
|
+
Profiles declare `chainPredicates` as serialisable DATA: typed directed steps,
|
|
95
|
+
repeat modes, strict string/boolean attribute constraints, alternatives and
|
|
96
|
+
`unique`, `ordered`, `first-drawn` or `aggregate` selection. Types include resolved
|
|
97
|
+
ancestry in their own profile. Walks see only that profile's semantic entities,
|
|
98
|
+
relations and attributes; the sole view input is whether an occurrence exists
|
|
99
|
+
for an entity. Geometry, groups, collapsed state and filters cannot prove a chain.
|
|
100
|
+
A drawn port is tested through its owner entity.
|
|
101
|
+
|
|
102
|
+
Walks stop at the first admitted end and close cycles with an iterative branch
|
|
103
|
+
stack. Completed suffixes are reused while their cycle-pruning ancestors remain
|
|
104
|
+
on the branch, preserving the first witness in candidate order. `first-drawn`
|
|
105
|
+
accepts a drawn completed single-step prefix (the exposer in an external-API
|
|
106
|
+
chain) without requiring the remaining suffix. A drawn non-admitted intermediate
|
|
107
|
+
blocks further lifting.
|
|
108
|
+
Aggregates recompute the complete member set, test each member's target and source
|
|
109
|
+
chains, sort by UTF-16 `(sourceId, targetId, relationId)`, and require the smallest
|
|
110
|
+
member as carrier. Any occurrence of the same repo entity is an equivalent end.
|
|
111
|
+
|
|
112
|
+
`validateView` reports `occurrence-endpoint-mismatch` with one of
|
|
113
|
+
`chain-not-declared`, `chain-hop-mismatch`, `chain-not-proven`, `chain-ambiguous`
|
|
114
|
+
or `chain-aggregation-mismatch` in `details.check`. Candidate lists are in `refs`;
|
|
115
|
+
details remain scalar. Pairing failures retain the fold `provenance-missing`
|
|
116
|
+
template, and dangling witness refs precede chain checks. `validateProfile` uses
|
|
117
|
+
`type-definition-conflict` with `chain-duplicate-id`, `chain-unknown-type`,
|
|
118
|
+
`chain-invalid-direction`, `chain-invalid-repeat` or `chain-members-not-aggregate`;
|
|
119
|
+
functions fail serialisation with `value-not-serialisable`.
|
|
120
|
+
|
|
121
|
+
Selection owns its cardinality outcome: several distinct ends under `unique`
|
|
122
|
+
give `chain-not-proven` with `cause: "cardinality"`; several drawn ends in the
|
|
123
|
+
chosen `ordered` alternative give `chain-ambiguous`. Semantic cardinality remains
|
|
124
|
+
profile-side; `validateView` never calls `validateDocument`.
|
|
125
|
+
|
|
126
|
+
Projection, removal repair and replacement inverses carry chain endpoints
|
|
127
|
+
verbatim, including hop/member order, and leave validation to `validateView`.
|
|
128
|
+
Old views keep their canonical bytes. Frozen schemas `@1/@2` refuse chain fields;
|
|
129
|
+
`@3` adds the exclusive pairing forms and resolves by exact pin only, without
|
|
130
|
+
changing the presentation pin. The package includes
|
|
131
|
+
[`schemas/diagram-view-schema-3.json`](schemas/diagram-view-schema-3.json) and its
|
|
132
|
+
[canonical SHA-256](schemas/diagram-view-schema-3.sha256):
|
|
133
|
+
`b415c05197692baa5f74ab35e3150ce58079cf9f06201df5e581d222a8d2c0df`.
|
|
134
|
+
This branch includes the successor `@3` schema lot but defers the specification's
|
|
135
|
+
`0.2.0` release lot: the current package version and downstream dependency pins
|
|
136
|
+
remain `0.1.0`. The release conductor owns that version/pin/lockfile update and
|
|
137
|
+
the owner-confirmed tag; schema inclusion does not certify downstream adoption.
|
|
138
|
+
|
|
139
|
+
### Commands are transactions
|
|
140
|
+
|
|
141
|
+
`applyTransaction(state, transaction, { registry })` returns either
|
|
142
|
+
`{ status: "applied", state, effects, inverse }` or
|
|
143
|
+
`{ status: "rejected", diagnostics }`.
|
|
144
|
+
|
|
145
|
+
- **No partial success.** Commands run on a working copy, the final state is
|
|
146
|
+
validated once, and any refusal throws the whole copy away. The caller's state
|
|
147
|
+
is never mutated.
|
|
148
|
+
- **Revision conflicts are explicit.** `baseRevision` must be the state's
|
|
149
|
+
revision; otherwise `revision-conflict`, carrying `expected` and `seen`.
|
|
150
|
+
- **One counter.** A transaction bumps `document.revision` by one and stamps the
|
|
151
|
+
views it touched with that revision, so a view is never ahead of its document.
|
|
152
|
+
- **An inverse, or a reason.** Every one of the 18 commands returns a logical
|
|
153
|
+
inverse built from the pre-image it captured. `non-invertible` is returned when
|
|
154
|
+
a cascade's inverse would exceed the declared `inverseBudget`, with the budget
|
|
155
|
+
in the reason: an unbounded inverse is an unbounded cost on the host's undo
|
|
156
|
+
stack.
|
|
157
|
+
- **Undo is a new transaction**, replayed against the current revision, never a
|
|
158
|
+
rewrite of the journal. After a command and its inverse the content is
|
|
159
|
+
identical and the revision is two ahead — which is why the round-trip tests
|
|
160
|
+
compare `serialiseContent` (revisions normalised) and assert the revision
|
|
161
|
+
arithmetic separately.
|
|
162
|
+
|
|
163
|
+
The 18th command, `remove-preserved-extension`, is an addition to the spec's list
|
|
164
|
+
of seventeen: adding an extension can only be undone by removing one, and no
|
|
165
|
+
command in the list removed one.
|
|
166
|
+
|
|
167
|
+
### Canonical form
|
|
168
|
+
|
|
169
|
+
`serialiseState` / `serialiseDocument` produce sorted-key JSON with no
|
|
170
|
+
whitespace. A function, a non-finite number, a `BigInt`, a symbol or a cycle is
|
|
171
|
+
**refused** with a diagnostic rather than silently turned into `null`. That
|
|
172
|
+
refusal is also what keeps a function out of a document.
|
|
173
|
+
|
|
174
|
+
`hashContent` is a 64-bit FNV-1a printed as `fnv1a64:<16 hex>`. It is **not
|
|
175
|
+
cryptographic**: it makes drift detectable, it must never gate trust. A real
|
|
176
|
+
digest belongs to the codecs lot, where a hash crosses a trust boundary.
|
|
177
|
+
|
|
178
|
+
### Migration
|
|
179
|
+
|
|
180
|
+
A stored version is migrated only by a registered, versioned function, which
|
|
181
|
+
returns a report: `from`, `to`, the operations it performed, the items it could
|
|
182
|
+
not carry over **with a reason each**, and the original bytes with their hash.
|
|
183
|
+
This build knows `1.0 -> 1.1`. An unknown **major** is refused for write and
|
|
184
|
+
preserved for inspection and export (`exportPreserved`).
|
|
185
|
+
|
|
186
|
+
A migration is not a repair. It migrates what it can and says what it could not,
|
|
187
|
+
so a migrated document may still be unwritable — for instance when a value that
|
|
188
|
+
failed to convert was a **required** attribute. The report names the element; the
|
|
189
|
+
decision is the host's.
|
|
190
|
+
|
|
191
|
+
## What this package does not import
|
|
192
|
+
|
|
193
|
+
Nothing. Not one specifier that is not a relative module of its own source, which
|
|
194
|
+
a test asserts by scanning every file. In particular:
|
|
195
|
+
|
|
196
|
+
- **no `@sentropic/graph`.** SPEC 3.1 allows DOM-free graph contracts and offers
|
|
197
|
+
to create a `@sentropic/graph/contracts` subpath for them. This lot needs none:
|
|
198
|
+
its only candidate consumer would be the persisted view schema, and binding a
|
|
199
|
+
migration-versioned persisted schema to another package's evolving types is
|
|
200
|
+
what the migration rule exists to prevent. `@sentropic/graph/processing` already
|
|
201
|
+
exists and is DOM-free, and contains nothing this package consumes. The
|
|
202
|
+
`diagram-core -> graph` edge of `docs/graph-dataviz-architecture-dag.json`
|
|
203
|
+
stays `"status": "proposed"`, which is what that file already says.
|
|
204
|
+
- **no DOM.** Enforced by the compiler first: `tsconfig.json` gives `src`
|
|
205
|
+
`lib: ["ES2022"]` and `types: []`, so `document`, `window` and every node
|
|
206
|
+
builtin are unresolvable names. Then by tests: the barrel is imported in Node
|
|
207
|
+
with no jsdom, with a throwing proxy installed as `document`/`window`, and the
|
|
208
|
+
source is scanned for those identifiers in executable code.
|
|
209
|
+
- **no renderer, no WebGL, no framework, no design system package.**
|
|
210
|
+
|
|
211
|
+
## What is not covered yet
|
|
212
|
+
|
|
213
|
+
- **Projection** (study invariant 7): this package produces no projection,
|
|
214
|
+
no geometry and no layout. `LayoutOutcome.inverse` in
|
|
215
|
+
`@sentropic/graph/processing` already carries the origin → projected index →
|
|
216
|
+
result correspondence; the scene side is GD-M2-CANVAS.
|
|
217
|
+
- **The world → view → CSS pixel → device pixel transform contract** (second half
|
|
218
|
+
of invariant 8): a rendering contract. This package persists a camera and finite
|
|
219
|
+
geometry and exposes no transform composition, no `devicePixelRatio` and no hit
|
|
220
|
+
testing.
|
|
221
|
+
- **Codecs, source text, AST/CST and conversion reports**: GD-M4. Nothing here
|
|
222
|
+
parses, fetches or executes imported content, a URI or markup.
|
|
223
|
+
- **Native BPMN / ArchiMate / UML profiles**: GD-M3. See the skeletons' `notes`.
|
|
224
|
+
- **A reference disposition in the delete policy.** The policy governs
|
|
225
|
+
occurrences, relations and ports. An entity a typed reference attribute still
|
|
226
|
+
points at cannot be deleted: the transaction refuses itself on the final state
|
|
227
|
+
(`dangling-reference`) rather than clearing someone's attribute. "Clear",
|
|
228
|
+
"refuse" or "reassign" as an explicit choice is a later decision.
|
|
229
|
+
- **Filter evaluation, and commands over groups and filters.** A view's groups and
|
|
230
|
+
filters are declared, validated and persisted here; nothing in this lot decides
|
|
231
|
+
what a filter hides, nor what happens to a relation whose endpoint is hidden,
|
|
232
|
+
and no command of this lot edits a group or a filter. Both are GD-M2-CANVAS.
|
|
233
|
+
- **Selection, geometric port editing and annotations**: GD-M2-CANVAS, by SPEC 3.5.
|
|
234
|
+
- **A cryptographic content hash**: see `hash.ts`.
|
|
235
|
+
- **Concurrency beyond compare-and-swap semantics.** `revision-conflict` is a
|
|
236
|
+
refusal, not a merge. No conflict resolution, no CRDT, no operational transform.
|
|
237
|
+
|
|
238
|
+
## Layout
|
|
239
|
+
|
|
240
|
+
```
|
|
241
|
+
src/refs.ts the seven nominal reference types, their guards and diagnostics
|
|
242
|
+
src/diagnostics.ts one code per refusal; nothing returns a boolean validity
|
|
243
|
+
src/attributes.ts typed attribute values and their schemas
|
|
244
|
+
src/profile.ts profile declarations, registry, and profile self-validation
|
|
245
|
+
src/chain-profile.ts chain predicate DATA declaration checks
|
|
246
|
+
src/chain.ts indexed document-only chain walks, selection and aggregate witnesses
|
|
247
|
+
src/profiles/ generic@1 (complete), bpmn@1 / archimate@1 / uml@1 (skeletons)
|
|
248
|
+
src/document.ts SemanticDocument, entities, relations, ports, resources, extensions
|
|
249
|
+
src/view.ts ViewDocument, the three occurrence kinds, groups, filters, presentation
|
|
250
|
+
src/state.ts { document, views } - the transactional unit
|
|
251
|
+
src/canonical.ts canonical JSON and content serialisation
|
|
252
|
+
src/hash.ts fnv1a64, dependency-free, non-cryptographic
|
|
253
|
+
src/validate.ts every refusal, including the nine named rejected cases
|
|
254
|
+
src/commands.ts 18 commands, transactions, effects, inverses
|
|
255
|
+
src/migrate.ts registered migrations and their reports
|
|
256
|
+
fixtures/ valid documents, a divergent-revision state, a command
|
|
257
|
+
sequence, the nine rejected cases, a 1.0 stored document
|
|
258
|
+
tests/ 10 suites; `refs-nominal.test.ts` is a COMPILER test
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
## Gates
|
|
262
|
+
|
|
263
|
+
```
|
|
264
|
+
npm run --workspace @sentropic/diagram-core build # tsc -> dist
|
|
265
|
+
npm run --workspace @sentropic/diagram-core check # tsc over src AND tests
|
|
266
|
+
npm run --workspace @sentropic/diagram-core test # vitest, node environment
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
`check` compiles the tests on purpose: `tests/refs-nominal.test.ts` proves the
|
|
270
|
+
reference types are not interchangeable with one `@ts-expect-error` per
|
|
271
|
+
illegitimate assignment (42 ordered pairs). Those assertions only mean something
|
|
272
|
+
if a compiler reads them. Remove the brand from `Ref<K>` and `check` reports 42
|
|
273
|
+
× TS2578 ("Unused '@ts-expect-error' directive") — measured, not assumed.
|
|
274
|
+
|
|
275
|
+
## Numbered flows (DC-2c.1)
|
|
276
|
+
|
|
277
|
+
`withFlowTypes`, `validateFlows` and `flowIndex` provide authored flow relations
|
|
278
|
+
and scenarios. Relation refinements resolve through `relationBaseType` and
|
|
279
|
+
`relationSchema`, preserving inherited roles and constraints. See
|
|
280
|
+
[the authoring contract and mapping examples](../../docs/DC2C_NUMBERED_FLOWS.md).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ArchimateTuple } from "./profiles/archimate2.js";
|
|
2
|
+
export interface ArchimatePairCase {
|
|
3
|
+
readonly relationType: string;
|
|
4
|
+
readonly sourceType: string;
|
|
5
|
+
readonly targetType: string;
|
|
6
|
+
readonly expected: "allowed" | "rejected";
|
|
7
|
+
}
|
|
8
|
+
/** @deprecated Use ArchimatePairCase (renamed to keep the no-transform invariant). */
|
|
9
|
+
export type ArchimateMatrixCase = ArchimatePairCase;
|
|
10
|
+
export declare function buildArchimatePairCases(tuples: readonly ArchimateTuple[], relationshipIds: readonly string[]): ArchimatePairCase[];
|
|
11
|
+
//# sourceMappingURL=archimate-cases.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deterministic ArchiMate matrix case builder (spec A.4).
|
|
3
|
+
*
|
|
4
|
+
* The finite closed corpus: 62 ordered concept pairs × 11 relation ids =
|
|
5
|
+
* 42,284 cases. Each expanded tuple yields an allowed case; every absent
|
|
6
|
+
* tuple yields a rejection. `@relation` witnesses use real relation
|
|
7
|
+
* targets, never entity stubs.
|
|
8
|
+
*/
|
|
9
|
+
import { ARCHIMATE_CONCEPT_NAMES } from "./profiles/archimate-matrix.js";
|
|
10
|
+
const typeIdOf = (name) => name === "Relationship" ? "@relation" : name.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
|
|
11
|
+
export function buildArchimatePairCases(tuples, relationshipIds) {
|
|
12
|
+
const allowed = new Set(tuples.map((t) => `${t.relationType}\0${t.sourceType}\0${t.targetType}`));
|
|
13
|
+
const cases = [];
|
|
14
|
+
for (const sourceName of ARCHIMATE_CONCEPT_NAMES) {
|
|
15
|
+
for (const targetName of ARCHIMATE_CONCEPT_NAMES) {
|
|
16
|
+
for (const relationType of relationshipIds) {
|
|
17
|
+
const sourceType = typeIdOf(sourceName);
|
|
18
|
+
const targetType = typeIdOf(targetName);
|
|
19
|
+
cases.push({
|
|
20
|
+
relationType,
|
|
21
|
+
sourceType,
|
|
22
|
+
targetType,
|
|
23
|
+
expected: allowed.has(`${relationType}\0${sourceType}\0${targetType}`) ? "allowed" : "rejected",
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return cases;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=archimate-cases.js.map
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Typed attributes. SPEC 3.3: "attributs typés selon le schéma du profil
|
|
3
|
+
* (quantité+unité, énumération, référence, texte, date, booléen, collection
|
|
4
|
+
* bornée) - jamais un dictionnaire libre."
|
|
5
|
+
*
|
|
6
|
+
* Two consequences that shape everything below:
|
|
7
|
+
* - a VALUE carries its kind, so a number is never silently read as a
|
|
8
|
+
* quantity: a quantity without a unit is `quantity-unit-missing`, which is
|
|
9
|
+
* one of the nine named rejected cases;
|
|
10
|
+
* - a SCHEMA is required to read a value. There is no "any attribute"
|
|
11
|
+
* escape. Content a profile does not declare is not an attribute; it is an
|
|
12
|
+
* extension (see extensions in `document.ts`), preserved with its hash and
|
|
13
|
+
* never promoted to a business fact (decision D3-C).
|
|
14
|
+
*/
|
|
15
|
+
import { type Diagnostic } from "./diagnostics.js";
|
|
16
|
+
import { type RefKind } from "./refs.js";
|
|
17
|
+
export type ScalarAttributeKind = "text" | "boolean" | "date" | "quantity" | "enum" | "reference";
|
|
18
|
+
export type AttributeKind = ScalarAttributeKind | "collection" | "struct";
|
|
19
|
+
export type ScalarAttributeValue = {
|
|
20
|
+
readonly kind: "text";
|
|
21
|
+
readonly value: string;
|
|
22
|
+
} | {
|
|
23
|
+
readonly kind: "boolean";
|
|
24
|
+
readonly value: boolean;
|
|
25
|
+
}
|
|
26
|
+
/** ISO-8601 calendar date or date-time, as text. No date object: the model stays serialisable. */
|
|
27
|
+
| {
|
|
28
|
+
readonly kind: "date";
|
|
29
|
+
readonly value: string;
|
|
30
|
+
}
|
|
31
|
+
/** A magnitude AND its unit. Neither half is optional. */
|
|
32
|
+
| {
|
|
33
|
+
readonly kind: "quantity";
|
|
34
|
+
readonly value: number;
|
|
35
|
+
readonly unit: string;
|
|
36
|
+
} | {
|
|
37
|
+
readonly kind: "enum";
|
|
38
|
+
readonly value: string;
|
|
39
|
+
}
|
|
40
|
+
/** A raw reference string; the namespace it must carry is declared by the schema. */
|
|
41
|
+
| {
|
|
42
|
+
readonly kind: "reference";
|
|
43
|
+
readonly value: string;
|
|
44
|
+
};
|
|
45
|
+
export type AttributeValue = ScalarAttributeValue | StructAttributeValue | {
|
|
46
|
+
readonly kind: "collection";
|
|
47
|
+
readonly items: readonly ScalarAttributeValue[];
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* A structured value (K6 carrier). `type` names a profile-declared structured
|
|
51
|
+
* type; `fields` carries the nested attribute values, validated against that
|
|
52
|
+
* type's declared field schemas. It has no entity identity: an entity record
|
|
53
|
+
* can never instantiate an abstract structured type.
|
|
54
|
+
*/
|
|
55
|
+
export type StructAttributeValue = {
|
|
56
|
+
readonly kind: "struct";
|
|
57
|
+
readonly type: string;
|
|
58
|
+
readonly fields: Readonly<Record<string, AttributeValue>>;
|
|
59
|
+
};
|
|
60
|
+
export type TextSchema = {
|
|
61
|
+
readonly kind: "text";
|
|
62
|
+
readonly maxLength?: number;
|
|
63
|
+
/** Minimum length. A present value below it is refused (pattern "min-length"). */
|
|
64
|
+
readonly minLength?: number;
|
|
65
|
+
/** Anchored ASCII RegExp source, no flags. `patternName` is required with it. */
|
|
66
|
+
readonly pattern?: string;
|
|
67
|
+
readonly patternName?: string;
|
|
68
|
+
};
|
|
69
|
+
export type QuantitySchema = {
|
|
70
|
+
readonly kind: "quantity";
|
|
71
|
+
readonly units: readonly string[];
|
|
72
|
+
/** When true, only integers validate; a fraction is refused. */
|
|
73
|
+
readonly integer?: boolean;
|
|
74
|
+
readonly min?: number;
|
|
75
|
+
readonly max?: number;
|
|
76
|
+
};
|
|
77
|
+
export type ReferenceSchema = {
|
|
78
|
+
readonly kind: "reference";
|
|
79
|
+
readonly refKind: RefKind;
|
|
80
|
+
/** K2 target types: the referenced entity's resolved chain must contain one. */
|
|
81
|
+
readonly targetTypes?: readonly string[];
|
|
82
|
+
};
|
|
83
|
+
/** A structured-value slot (K6 carrier): only the named types are allowed here. */
|
|
84
|
+
export type StructSchema = {
|
|
85
|
+
readonly kind: "struct";
|
|
86
|
+
readonly targetTypes: readonly string[];
|
|
87
|
+
};
|
|
88
|
+
export type ScalarSchema = TextSchema | {
|
|
89
|
+
readonly kind: "boolean";
|
|
90
|
+
} | {
|
|
91
|
+
readonly kind: "date";
|
|
92
|
+
}
|
|
93
|
+
/** The units a quantity may use. A one-unit list is how a profile pins a unit. */
|
|
94
|
+
| QuantitySchema | {
|
|
95
|
+
readonly kind: "enum";
|
|
96
|
+
readonly values: readonly string[];
|
|
97
|
+
} | ReferenceSchema;
|
|
98
|
+
/**
|
|
99
|
+
* A collection is ALWAYS bounded: `maxItems` is required, because "collection
|
|
100
|
+
* bornée" is the contract and an unbounded list is how a schema becomes a bag.
|
|
101
|
+
*/
|
|
102
|
+
export type CollectionSchema = {
|
|
103
|
+
readonly kind: "collection";
|
|
104
|
+
readonly item: ScalarSchema;
|
|
105
|
+
readonly maxItems: number;
|
|
106
|
+
readonly minItems?: number;
|
|
107
|
+
};
|
|
108
|
+
export type AttributeSchema = {
|
|
109
|
+
readonly name: string;
|
|
110
|
+
readonly required?: boolean;
|
|
111
|
+
} & (ScalarSchema | CollectionSchema | StructSchema);
|
|
112
|
+
/**
|
|
113
|
+
* Validate ONE attribute value against its schema. Resolution of reference
|
|
114
|
+
* values against the document is NOT done here (this module knows nothing about
|
|
115
|
+
* documents); `validate.ts` resolves them and reports `dangling-reference`.
|
|
116
|
+
*/
|
|
117
|
+
export declare function validateAttributeValue(schema: AttributeSchema, value: AttributeValue, path: string): readonly Diagnostic[];
|
|
118
|
+
/** Every reference a value carries, with the namespace its schema requires. */
|
|
119
|
+
export declare function referencesOf(schema: AttributeSchema, value: AttributeValue): readonly {
|
|
120
|
+
readonly raw: string;
|
|
121
|
+
readonly refKind: RefKind;
|
|
122
|
+
readonly index?: number;
|
|
123
|
+
}[];
|
|
124
|
+
/** Convenience constructors, so fixtures and tests read as data, not as casts. */
|
|
125
|
+
export declare const text: (value: string) => AttributeValue;
|
|
126
|
+
export declare const boolean: (value: boolean) => AttributeValue;
|
|
127
|
+
export declare const date: (value: string) => AttributeValue;
|
|
128
|
+
export declare const quantity: (value: number, unit: string) => AttributeValue;
|
|
129
|
+
export declare const enumeration: (value: string) => AttributeValue;
|
|
130
|
+
export declare const reference: (value: string) => AttributeValue;
|
|
131
|
+
export declare const collection: (items: readonly ScalarAttributeValue[]) => AttributeValue;
|
|
132
|
+
export declare const structValue: (type: string, fields: Readonly<Record<string, AttributeValue>>) => AttributeValue;
|
|
133
|
+
//# sourceMappingURL=attributes.d.ts.map
|