@meltemi/diagrams-model 0.0.0-stage → 1.9.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.
Files changed (83) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +48 -2
  3. package/dist/c4.d.ts +44 -0
  4. package/dist/c4.d.ts.map +1 -0
  5. package/dist/c4.js +803 -0
  6. package/dist/c4.js.map +1 -0
  7. package/dist/compile.d.ts +20 -0
  8. package/dist/compile.d.ts.map +1 -0
  9. package/dist/compile.js +525 -0
  10. package/dist/compile.js.map +1 -0
  11. package/dist/diagram-types.d.ts +67 -0
  12. package/dist/diagram-types.d.ts.map +1 -0
  13. package/dist/diagram-types.js +282 -0
  14. package/dist/diagram-types.js.map +1 -0
  15. package/dist/diff.d.ts +91 -0
  16. package/dist/diff.d.ts.map +1 -0
  17. package/dist/diff.js +575 -0
  18. package/dist/diff.js.map +1 -0
  19. package/dist/export.d.ts +22 -0
  20. package/dist/export.d.ts.map +1 -0
  21. package/dist/export.js +243 -0
  22. package/dist/export.js.map +1 -0
  23. package/dist/flow.d.ts +247 -0
  24. package/dist/flow.d.ts.map +1 -0
  25. package/dist/flow.js +1693 -0
  26. package/dist/flow.js.map +1 -0
  27. package/dist/index.d.ts +16 -0
  28. package/dist/index.d.ts.map +1 -0
  29. package/dist/index.js +16 -0
  30. package/dist/index.js.map +1 -0
  31. package/dist/json.d.ts +400 -0
  32. package/dist/json.d.ts.map +1 -0
  33. package/dist/json.js +433 -0
  34. package/dist/json.js.map +1 -0
  35. package/dist/messages/changes.d.ts +64 -0
  36. package/dist/messages/changes.d.ts.map +1 -0
  37. package/dist/messages/changes.js +117 -0
  38. package/dist/messages/changes.js.map +1 -0
  39. package/dist/messages/en.d.ts +554 -0
  40. package/dist/messages/en.d.ts.map +1 -0
  41. package/dist/messages/en.js +566 -0
  42. package/dist/messages/en.js.map +1 -0
  43. package/dist/messages/es.d.ts +3 -0
  44. package/dist/messages/es.d.ts.map +1 -0
  45. package/dist/messages/es.js +551 -0
  46. package/dist/messages/es.js.map +1 -0
  47. package/dist/messages/index.d.ts +449 -0
  48. package/dist/messages/index.d.ts.map +1 -0
  49. package/dist/messages/index.js +11 -0
  50. package/dist/messages/index.js.map +1 -0
  51. package/dist/model.d.ts +11 -0
  52. package/dist/model.d.ts.map +1 -0
  53. package/dist/model.js +363 -0
  54. package/dist/model.js.map +1 -0
  55. package/dist/scenario.d.ts +11 -0
  56. package/dist/scenario.d.ts.map +1 -0
  57. package/dist/scenario.js +91 -0
  58. package/dist/scenario.js.map +1 -0
  59. package/dist/schema.d.ts +311 -0
  60. package/dist/schema.d.ts.map +1 -0
  61. package/dist/schema.js +658 -0
  62. package/dist/schema.js.map +1 -0
  63. package/dist/sequence.d.ts +8 -0
  64. package/dist/sequence.d.ts.map +1 -0
  65. package/dist/sequence.js +722 -0
  66. package/dist/sequence.js.map +1 -0
  67. package/dist/story.d.ts +18 -0
  68. package/dist/story.d.ts.map +1 -0
  69. package/dist/story.js +406 -0
  70. package/dist/story.js.map +1 -0
  71. package/dist/style-values.d.ts +107 -0
  72. package/dist/style-values.d.ts.map +1 -0
  73. package/dist/style-values.js +558 -0
  74. package/dist/style-values.js.map +1 -0
  75. package/dist/theme-block.d.ts +10 -0
  76. package/dist/theme-block.d.ts.map +1 -0
  77. package/dist/theme-block.js +135 -0
  78. package/dist/theme-block.js.map +1 -0
  79. package/dist/types.d.ts +785 -0
  80. package/dist/types.d.ts.map +1 -0
  81. package/dist/types.js +2 -0
  82. package/dist/types.js.map +1 -0
  83. package/package.json +36 -3
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Architecture Studio contributors
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.
package/README.md CHANGED
@@ -1,3 +1,49 @@
1
- # Temporary Holding Version
1
+ # @meltemi/diagrams-model
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The typed intermediate model of `.meltemi` documents: compilation of the flow, free, sequence
4
+ and C4 profiles, models, stories and export profiles, validation with stable diagnostics, and the
5
+ model JSON interchange format.
6
+
7
+ It is part of [Meltemi Diagrams](https://github.com/askenaz-dev/meltemi-diagrams#readme), diagrams as code with a canvas, motion and
8
+ exports. Every package of the product has the same version.
9
+
10
+ ## Install
11
+
12
+ ```bash
13
+ npm install @meltemi/diagrams-model
14
+ ```
15
+
16
+ Node 22.12.0 or later. The package is an ES module with type declarations.
17
+
18
+ ## Use
19
+
20
+ ```ts
21
+ import { compile, toJson } from "@meltemi/diagrams-model";
22
+
23
+ const text = `language "0.2"
24
+
25
+ diagram shop: flow {
26
+ web["Web shop"]
27
+ api["Orders API"]
28
+ db[("Orders")]
29
+ web -> api: "HTTPS" as call
30
+ api -> db: "SQL" as store
31
+ }
32
+ `;
33
+
34
+ const compilation = compile(text);
35
+ console.log(compilation.diagnostics); // []
36
+ const diagram = compilation.document.diagrams[0]!;
37
+ console.log(diagram.id, diagram.elements.length, diagram.relations.length); // shop 3 2
38
+ console.log(toJson(compilation).format); // the model JSON format name
39
+ ```
40
+
41
+ ## Documentation
42
+
43
+ - [Model JSON](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/language/model-json.md)
44
+ - [Grammar](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/language/grammar-0.2.md)
45
+ - [All documentation](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/docs/README.md)
46
+
47
+ ## Licence
48
+
49
+ MIT. Third-party components and their licences are listed in [THIRD_PARTY_LICENSES.md](https://github.com/askenaz-dev/meltemi-diagrams/blob/main/THIRD_PARTY_LICENSES.md).
package/dist/c4.d.ts ADDED
@@ -0,0 +1,44 @@
1
+ import { type DiagnosticBag, type DiagramBlock, type LineIndex, type QualifiedRef, type Token } from "@meltemi/diagrams-language";
2
+ import { isAncestorPath } from "./model.js";
3
+ import type { C4Level, C4View, EntityKind, EntityReference, FlowDiagram, ModelDefinition, ModelEntity, ResolvedModel } from "./types.js";
4
+ /** The model a view uses, as compile found it. */
5
+ export interface ViewModel {
6
+ /** The name written after `using`. */
7
+ readonly name: string;
8
+ readonly ref: QualifiedRef;
9
+ /** The model, or null when the name does not resolve. */
10
+ readonly resolved: ResolvedModel | null;
11
+ /** True when the name goes through an import that the host did not resolve: stay silent. */
12
+ readonly pending: boolean;
13
+ }
14
+ /** Analyzes `diagram <id>: c4 using <model> { }` into a view. */
15
+ export declare function analyzeC4View(node: DiagramBlock, id: Token, lines: LineIndex, bag: DiagnosticBag, model: ViewModel): {
16
+ diagram: FlowDiagram;
17
+ errors: number;
18
+ };
19
+ /**
20
+ * The entities a C4 view of a level and scope may draw: persons and systems at the context level;
21
+ * the scope's containers and datastores, persons and other systems at the container level; the
22
+ * scope's components, the other containers of its system, persons and other systems at the
23
+ * component level.
24
+ */
25
+ export declare function allowedEntities(model: ModelDefinition, level: C4Level, scopePath: string | null): Set<string>;
26
+ /**
27
+ * The level of the view that opens an entity of a kind: a system opens a container view scoped
28
+ * to it, a container a component view scoped to it; persons, datastores and components open
29
+ * nothing.
30
+ */
31
+ export declare function childLevel(kind: EntityKind): C4Level | null;
32
+ /**
33
+ * Whether a compiled C4 view is the child view of an entity: it uses the same model (the model's
34
+ * file and id; `owner` is the view's own file, standing for a model resolved in that file), has
35
+ * the level `childLevel` gives the entity's kind, and is scoped to the entity. A context view
36
+ * scoped to a system is not its child view.
37
+ */
38
+ export declare function isChildView(view: C4View, owner: string | null, model: {
39
+ readonly file: string | null;
40
+ readonly id: string;
41
+ }, entity: Pick<ModelEntity, "kind" | "path">): boolean;
42
+ export type { EntityReference };
43
+ export { isAncestorPath };
44
+ //# sourceMappingURL=c4.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"c4.d.ts","sourceRoot":"","sources":["../src/c4.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,YAAY,EAEjB,KAAK,SAAS,EACd,KAAK,YAAY,EAGjB,KAAK,KAAK,EACX,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EAAc,cAAc,EAAE,MAAM,YAAY,CAAC;AAGxD,OAAO,KAAK,EACV,OAAO,EACP,MAAM,EACN,UAAU,EACV,eAAe,EAEf,WAAW,EAEX,eAAe,EACf,WAAW,EAEX,aAAa,EAGd,MAAM,YAAY,CAAC;AAEpB,kDAAkD;AAClD,MAAM,WAAW,SAAS;IACxB,sCAAsC;IACtC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;IAC3B,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,EAAE,aAAa,GAAG,IAAI,CAAC;IACxC,4FAA4F;IAC5F,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAC3B,IAAI,EAAE,YAAY,EAClB,EAAE,EAAE,KAAK,EACT,KAAK,EAA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