archidocs 1.2.0 → 1.3.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 (68) hide show
  1. package/README.md +62 -13
  2. package/dist/cli/commands.d.ts +225 -4
  3. package/dist/cli/commands.js +129 -4
  4. package/dist/cli/init.d.ts +1 -1
  5. package/dist/cli/init.js +2 -2
  6. package/dist/cli/main.js +9 -14
  7. package/dist/core/compare.d.ts +2 -13
  8. package/dist/core/compare.js +2 -35
  9. package/dist/core/index.d.ts +2 -5
  10. package/dist/core/index.js +2 -5
  11. package/dist/core/rules.d.ts +10 -0
  12. package/dist/core/rules.js +186 -7
  13. package/dist/core/views/compare.d.ts +12 -0
  14. package/dist/core/views/compare.js +37 -0
  15. package/dist/core/{deployment-views.d.ts → views/deployment.d.ts} +4 -5
  16. package/dist/core/{deployment-views.js → views/deployment.js} +5 -7
  17. package/dist/core/{dynamic-views.d.ts → views/dynamic.d.ts} +1 -3
  18. package/dist/core/{dynamic-views.js → views/dynamic.js} +4 -8
  19. package/dist/core/views/generated.d.ts +18 -0
  20. package/dist/core/views/generated.js +92 -0
  21. package/dist/core/views/ids.d.ts +36 -0
  22. package/dist/core/views/ids.js +51 -0
  23. package/dist/core/views/index.d.ts +13 -0
  24. package/dist/core/views/index.js +12 -0
  25. package/dist/core/views/lens.d.ts +27 -0
  26. package/dist/core/views/lens.js +112 -0
  27. package/dist/core/views/model.d.ts +21 -0
  28. package/dist/core/views/model.js +69 -0
  29. package/dist/core/views/resolve.d.ts +42 -0
  30. package/dist/core/views/resolve.js +81 -0
  31. package/dist/core/{save-as-view.d.ts → views/save-as-view.d.ts} +2 -2
  32. package/dist/core/{save-as-view.js → views/save-as-view.js} +13 -10
  33. package/dist/core/{saved-views.d.ts → views/saved.d.ts} +4 -18
  34. package/dist/core/{saved-views.js → views/saved.js} +8 -103
  35. package/dist/core/views/types.d.ts +91 -0
  36. package/dist/core/views/types.js +2 -0
  37. package/dist/mcp/errors.d.ts +37 -0
  38. package/dist/mcp/errors.js +35 -0
  39. package/dist/mcp/index.d.ts +2 -1
  40. package/dist/mcp/index.js +1 -0
  41. package/dist/mcp/server.d.ts +1 -2
  42. package/dist/mcp/server.js +12 -12
  43. package/dist/render/layout.d.ts +20 -3
  44. package/dist/render/layout.js +49 -12
  45. package/dist/render/sequence-svg.d.ts +1 -1
  46. package/dist/render/sequence.d.ts +1 -1
  47. package/dist/render/svg.d.ts +1 -1
  48. package/dist/render/svg.js +4 -4
  49. package/dist/schema/adr.js +18 -13
  50. package/dist/schema/workspace.js +226 -130
  51. package/dist/viewer/assets/index-BXa5R96a.js +138 -0
  52. package/dist/viewer/assets/index-YFA-pYjQ.css +1 -0
  53. package/dist/viewer/assets/{layout.worker-Bg-OaLVN.js → layout.worker-BRHAGJrD.js} +1 -1
  54. package/dist/viewer/assets/{png-BDKIXtm5.js → png-CAaXWR-k.js} +1 -1
  55. package/dist/viewer/assets/{svg-Bulv5YWn.js → svg-BPVHfD36.js} +2 -2
  56. package/dist/viewer/index.html +2 -2
  57. package/guide/SKILL.md +1 -1
  58. package/guide/topics/bootstrap.md +1 -1
  59. package/guide/topics/relationships.md +1 -1
  60. package/package.json +4 -3
  61. package/schemas/adr.schema.json +18 -15
  62. package/schemas/model.schema.json +637 -1144
  63. package/schemas/project.schema.json +8 -4
  64. package/schemas/workspace.schema.json +39 -20
  65. package/dist/core/views.d.ts +0 -126
  66. package/dist/core/views.js +0 -217
  67. package/dist/viewer/assets/index-DvKgCpBr.css +0 -1
  68. package/dist/viewer/assets/index-gucix3xm.js +0 -113
@@ -1,127 +1,186 @@
1
1
  import { z } from "zod";
2
2
  /** An author-chosen slug: Team, Environment, Project and Element ids. */
3
3
  export const Id = z.string().regex(/^[a-z0-9][a-z0-9-]*$/, "must be a lowercase slug (a-z, 0-9 and -)");
4
- export const Link = z.strictObject({
5
- label: z.string(),
6
- url: z.url(),
7
- });
8
- export const Team = z.strictObject({
9
- name: z.string(),
10
- description: z.string().optional(),
11
- links: z.array(Link).optional(),
12
- });
13
- export const Environment = z.strictObject({
14
- name: z.string(),
15
- description: z.string().optional(),
16
- });
4
+ /*
5
+ * Every field below carries a description: editors show it on hover, and the
6
+ * Model YAML reference prints it. A description that ends in a `Default: ….`
7
+ * sentence fills the reference's Default column. A shape used in several
8
+ * places has an `id`, so its JSON Schema is written once, under `$defs`.
9
+ */
10
+ export const Link = z
11
+ .strictObject({
12
+ label: z.string().describe("The text of the link, such as `Runbook`."),
13
+ url: z.url().describe("The page the link opens. A full URL, such as `https://wiki.example.com/runbooks/web`."),
14
+ })
15
+ .meta({ id: "Link", title: "Link", description: "A link to a page about the thing it is declared on, such as a runbook or a dashboard." });
16
+ export const Team = z
17
+ .strictObject({
18
+ name: z.string().describe("The Team's display name."),
19
+ description: z.string().optional().describe("A short description of the Team."),
20
+ links: z.array(Link).optional().describe("Links to pages about the Team."),
21
+ })
22
+ .describe("A Team: a group that can own Elements and Deployment Targets. Its key is the Team's id.");
23
+ export const Environment = z
24
+ .strictObject({
25
+ name: z.string().describe("The Environment's display name, such as `Production`."),
26
+ description: z.string().optional().describe("A short description of the Environment."),
27
+ })
28
+ .describe("An Environment: a named stage that Services run in, such as prod or staging. Its key is the Environment's id.");
17
29
  /** `workspace.yaml`: the only place Teams and Environments are defined. */
18
- export const WorkspaceFile = z.strictObject({
19
- teams: z.record(Id, Team).optional(),
20
- environments: z.record(Id, Environment).optional(),
21
- });
30
+ export const WorkspaceFile = z
31
+ .strictObject({
32
+ teams: z.record(Id, Team).optional().describe("The Teams of the Workspace, keyed by id. Every `owner` in every Project names one of these ids."),
33
+ environments: z.record(Id, Environment).optional().describe("The Environments of the Workspace, keyed by id. Every Deployment in every Project names one of these ids."),
34
+ })
35
+ .describe("`workspace.yaml`: the Teams and Environments that every Project in the Workspace shares.");
22
36
  /** `project.yaml`: marks a folder as a Project. */
23
- export const ProjectFile = z.strictObject({
24
- id: Id,
25
- name: z.string(),
26
- owner: Id,
27
- });
37
+ export const ProjectFile = z
38
+ .strictObject({
39
+ id: Id.describe("The Project's id, unique in the Workspace. Other Projects write it as the prefix of a Qualified id, such as `payments:ledger`."),
40
+ name: z.string().describe("The Project's display name."),
41
+ owner: Id.describe("The Team that owns the Project: the id of a Team in `workspace.yaml`. It is the Owner of every Element and Deployment Target in the Project that sets no `owner` of its own."),
42
+ })
43
+ .describe("`project.yaml`: marks its folder as a Project.");
28
44
  /** A reference to an Element or Deployment Target: a bare id in its own Project, or `project:id`. */
29
45
  export const Ref = z
30
46
  .string()
31
47
  .regex(/^([a-z0-9][a-z0-9-]*:)?[a-z0-9][a-z0-9-]*$/, "must be an id, or `project:id` for one in another Project")
32
- .describe("An id in this Project, or `project:id` for one in another Project");
48
+ .describe("An id in this Project, or `project:id` for one in another Project.");
33
49
  /**
34
50
  * A dependency of the Element it is declared under (the consumer) on the
35
51
  * Element `to` names (the provider). An async one may run through a broker
36
52
  * Service (`via`) on a topic or queue (`channel`).
37
53
  */
38
- export const Relationship = z.strictObject({
39
- to: Ref,
40
- id: Id.optional(),
41
- description: z.string().optional(),
42
- technology: z.string().optional(),
43
- interaction: z.enum(["sync", "async"]).optional(),
44
- via: Ref.optional(),
45
- channel: z.string().optional(),
46
- tags: z.array(z.string()).optional(),
54
+ export const Relationship = z
55
+ .strictObject({
56
+ to: Ref.describe("The provider: the Element this one depends on. An id in this Project, or `project:id` for an Element in another Project. It can't be a Person, this Element itself, or an ancestor or descendant of this Element."),
57
+ id: Id.optional().describe("An id for the Relationship, unique among the Project's Relationships. Needed only when several Relationships connect the same two Elements, so that a Dynamic View Step can name one."),
58
+ description: z.string().optional().describe("What the consumer uses the provider for, as a verb phrase that reads from consumer to provider, such as `Reads prices from`."),
59
+ technology: z.string().optional().describe("How the consumer reaches the provider: a protocol, a driver or a format, such as `JSON/HTTPS`, `gRPC` or `SQL`."),
60
+ interaction: z
61
+ .enum(["sync", "async"])
62
+ .optional()
63
+ .describe("`sync`: a call that waits for an answer. `async`: an event or message that gets no reply, such as an event through a broker or a webhook. Default: `sync`."),
64
+ via: Ref.optional().describe("For an `async` Relationship only: the broker the events travel through. A Service with `type: broker`, as an id in this Project or `project:id`. Leave it out when there is no broker, as with a webhook."),
65
+ channel: z.string().optional().describe("For an `async` Relationship only: the topic or queue the events travel on, such as `orders.placed`."),
66
+ tags: z.array(z.string()).optional().describe("Free-form labels for the Relationship."),
67
+ })
68
+ .meta({
69
+ id: "Relationship",
70
+ title: "Relationship",
71
+ description: "A Relationship: a dependency of the Element it is declared under (the consumer) on the Element `to` names (the provider). Declare it once, under the consumer.",
47
72
  });
73
+ /** The fields every kind of Element takes. */
48
74
  const elementFields = {
49
- name: z.string(),
50
- description: z.string().optional(),
51
- owner: Id.optional(),
52
- tags: z.array(z.string()).optional(),
53
- links: z.array(Link).optional(),
54
- relationships: z.array(Relationship).optional(),
75
+ name: z.string().describe("The Element's display name."),
76
+ description: z.string().optional().describe("What the Element is or does, in a sentence or two."),
77
+ owner: Id.optional().describe("The Team that owns the Element: the id of a Team in `workspace.yaml`. Set it only when it differs from the Project's; nothing is inherited from the parent Element. Default: the Project's `owner`."),
78
+ tags: z.array(z.string()).optional().describe("Free-form labels. A Saved View's `{tag}` selector picks Elements by them."),
79
+ links: z.array(Link).optional().describe("Links to pages about the Element, such as a runbook or a dashboard."),
80
+ relationships: z.array(Relationship).optional().describe("The Relationships this Element is the consumer of: what it depends on. A Relationship is never declared under its provider."),
55
81
  };
56
- /** Names the parent of a top-level Service or Component declared in another file. */
57
- const parentRef = Id.describe("Id of the parent declared in another file of this Project");
58
- export const Person = z.strictObject({ ...elementFields });
59
- export const Component = z.strictObject({
60
- ...elementFields,
61
- technology: z.string().optional(),
62
- in: parentRef.optional(),
82
+ export const Person = z.strictObject({ ...elementFields }).meta({
83
+ id: "Person",
84
+ title: "Person",
85
+ description: "A Person: a human or role that uses a System, such as a shopper or a support agent. A Person is only ever the consumer in a Relationship.",
63
86
  });
64
- export const Service = z.strictObject({
87
+ export const Component = z
88
+ .strictObject({
65
89
  ...elementFields,
66
- type: z.enum(["app", "datastore", "broker"]).optional(),
67
- technology: z.string().optional(),
68
- external: z.boolean().optional(),
69
- in: parentRef.optional(),
70
- components: z.record(Id, Component).optional(),
71
- });
72
- export const System = z.strictObject({
90
+ technology: z.string().optional().describe("What the Component is built with, such as `TypeScript module`. Shown under its name."),
91
+ in: Id.optional().describe("The Service this Component belongs to, as an id in this Project. Required for a Component under the top-level `components` key, and not allowed for one nested under a Service's `components`."),
92
+ })
93
+ .meta({ id: "Component", title: "Component", description: "A Component: a part inside a Service that is not deployed on its own." });
94
+ export const Service = z
95
+ .strictObject({
73
96
  ...elementFields,
74
- external: z.boolean().optional(),
75
- services: z.record(Id, Service).optional(),
76
- });
97
+ type: z
98
+ .enum(["app", "datastore", "broker"])
99
+ .optional()
100
+ .describe("What the Service is; each type is drawn differently. `app`: an application, the usual case. `datastore`: a database or other store. `broker`: a message broker that async Relationships run through, named by their `via`. Default: `app`."),
101
+ technology: z.string().optional().describe("What the Service is built with, such as `Go` or `PostgreSQL`. Shown under its name."),
102
+ external: z.boolean().optional().describe("`true` for a Service run outside the organization, such as a payment provider's API. An External Service can't declare Components. Default: `false`."),
103
+ in: Id.optional().describe("The System this Service belongs to, as an id in this Project. Only for a Service under the top-level `services` key, and not allowed for one nested under a System's `services`. Without it, a top-level Service stands outside any System."),
104
+ components: z.record(Id, Component).optional().describe("The Components inside the Service, keyed by id."),
105
+ })
106
+ .meta({ id: "Service", title: "Service", description: "A Service: a deployable, addressable unit of software; the thing that has a URL and a Deployment." });
107
+ export const System = z
108
+ .strictObject({
109
+ ...elementFields,
110
+ external: z.boolean().optional().describe("`true` for a System run outside the organization, such as a payment provider. Nothing inside an External System can declare Components. Default: `false`."),
111
+ services: z.record(Id, Service).optional().describe("The Services in the System, keyed by id."),
112
+ })
113
+ .meta({ id: "System", title: "System", description: "A System: a named grouping of Services that together deliver a business capability. Systems do not nest." });
77
114
  const targetFields = {
78
- name: z.string(),
79
- kind: z.string().describe("What the Target is, such as region, cluster, namespace or platform"),
80
- description: z.string().optional(),
81
- owner: Id.optional(),
82
- tags: z.array(z.string()).optional(),
83
- links: z.array(Link).optional(),
115
+ name: z.string().describe("The Deployment Target's display name."),
116
+ kind: z.string().describe("What the Deployment Target is, in a word you choose, such as `region`, `cluster`, `namespace` or `platform`."),
117
+ description: z.string().optional().describe("What the Deployment Target is, in a sentence or two."),
118
+ owner: Id.optional().describe("The Team that owns the Deployment Target: the id of a Team in `workspace.yaml`. Default: the Project's `owner`."),
119
+ tags: z.array(z.string()).optional().describe("Free-form labels for the Deployment Target."),
120
+ links: z.array(Link).optional().describe("Links to pages about the Deployment Target, such as a dashboard."),
84
121
  };
85
122
  /** A Deployment Target: where Services run. Targets nest to any depth and are not Elements. */
86
123
  export const Target = z
87
124
  .strictObject({
88
125
  ...targetFields,
89
126
  get targets() {
90
- return z.record(Id, Target).optional();
127
+ return z.record(Id, Target).optional().describe("The Deployment Targets inside this one, keyed by id, such as the clusters in a region.");
91
128
  },
92
129
  })
93
- .meta({ id: "Target" });
94
- export const Endpoint = z.strictObject({
95
- name: z.string(),
96
- url: z.url(),
130
+ .meta({
131
+ id: "Target",
132
+ title: "Deployment Target",
133
+ description: "A Deployment Target: a place Services run, such as a region, a cluster in it or a platform. Deployment Targets nest to any depth and are not Elements.",
97
134
  });
135
+ export const Endpoint = z
136
+ .strictObject({
137
+ name: z.string().describe("What the endpoint is, such as `health` or `admin`."),
138
+ url: z.url().describe("The endpoint's address. A full URL."),
139
+ })
140
+ .describe("A further named URL of the Service in this Environment.");
98
141
  /** One Service running in one Environment on one Deployment Target. */
99
- export const Deployment = z.strictObject({
100
- service: Ref,
101
- environment: Id,
102
- target: Ref,
103
- url: z.url().optional(),
104
- endpoints: z.array(Endpoint).optional(),
105
- });
142
+ export const Deployment = z
143
+ .strictObject({
144
+ service: Ref.describe("The Service that runs: an id in this Project, or `project:id`. It must name a Service, not a System or a Component."),
145
+ environment: Id.describe("The Environment it runs in: the id of an Environment in `workspace.yaml`."),
146
+ target: Ref.describe("The Deployment Target it runs on: an id in this Project, or `project:id` for one another Project declares."),
147
+ url: z.url().optional().describe("The Service's main URL in this Environment. A full URL, such as `https://cart.example.com`."),
148
+ endpoints: z.array(Endpoint).optional().describe("Further named URLs of the Service in this Environment, such as a health check or an admin console."),
149
+ })
150
+ .describe("A Deployment: one Service running in one Environment on one Deployment Target. The three together name it, so the same three can appear only once.");
106
151
  /** How far `upstream` or `downstream` reaches: a number of hops, or `all` for the full transitive closure. */
107
- const Hops = z.union([z.number().int().min(0), z.literal("all")], { error: "must be a number of hops, or `all`" }).describe("A number of hops, or `all`");
152
+ const Hops = z.union([z.number().int().min(0), z.literal("all")], { error: "must be a number of hops, or `all`" }).describe("A number of hops, or `all`.");
108
153
  /** Which paths a path selector or Lens takes: the shortest, or every path of at most n hops. */
109
- const Paths = z.union([z.literal("shortest"), z.number().int().min(1)], { error: "must be `shortest`, or a number of hops" }).describe("`shortest` (the default), or n for every path of at most n hops");
154
+ const Paths = z.union([z.literal("shortest"), z.number().int().min(1)], { error: "must be `shortest`, or a number of hops" }).describe("`shortest`, or n for every path of at most n hops. Default: `shortest`.");
110
155
  /** `{element}`: an Element, optionally with its children or descendants, and what it reaches upstream or downstream. */
111
- export const ElementSelector = z.strictObject({
112
- element: Ref,
113
- with: z.enum(["children", "descendants"]).optional(),
114
- upstream: Hops.optional(),
115
- downstream: Hops.optional(),
116
- });
156
+ export const ElementSelector = z
157
+ .strictObject({
158
+ element: Ref.describe("The Element to start from: an id in this Project, or `project:id`."),
159
+ with: z.enum(["children", "descendants"]).optional().describe("Also selects what is inside the Element. `children`: the Elements directly inside it. `descendants`: everything inside it, at any depth."),
160
+ upstream: Hops.optional().describe("Also selects the Elements upstream of it, those that depend on it: a number of hops, or `all` for every one of them."),
161
+ downstream: Hops.optional().describe("Also selects the Elements downstream of it, those it depends on: a number of hops, or `all` for every one of them."),
162
+ })
163
+ .describe("One Element, and optionally what is inside it and what is upstream or downstream of it.");
117
164
  /** `{team}`: every Element the Team owns. */
118
- export const TeamSelector = z.strictObject({ team: Id });
165
+ export const TeamSelector = z.strictObject({ team: Id.describe("The Team: the id of a Team in `workspace.yaml`.") }).describe("Every Element a Team owns.");
119
166
  /** `{tag}`: every Element carrying the tag. */
120
- export const TagSelector = z.strictObject({ tag: z.string() });
167
+ export const TagSelector = z.strictObject({ tag: z.string().describe("The tag, as written in the Elements' `tags`.") }).describe("Every Element that carries a tag.");
121
168
  /** `{from, to}`: every Element on the paths between two Elements, as `find_paths` follows them. */
122
- export const PathSelector = z.strictObject({ from: Ref, to: Ref, paths: Paths.optional() });
169
+ export const PathSelector = z
170
+ .strictObject({
171
+ from: Ref.describe("One end of the paths: an id in this Project, or `project:id`."),
172
+ to: Ref.describe("The other end of the paths: an id in this Project, or `project:id`."),
173
+ paths: Paths.optional().describe("Which paths to take. `shortest`: the shortest paths, however long. A number n: every path of at most n hops. Default: `shortest`."),
174
+ })
175
+ .meta({
176
+ id: "PathSelector",
177
+ title: "Path selector",
178
+ description: "The paths between two Elements, followed in both directions. As a selector it picks every Element on them; as a Lens it highlights them.",
179
+ });
123
180
  /** One entry of a Saved View's `include` or `exclude`: a bare id is the Element itself. */
124
- export const Selector = z.union([Ref, ElementSelector, TeamSelector, TagSelector, PathSelector]);
181
+ export const Selector = z
182
+ .union([Ref.describe("One Element, by its id: an id in this Project, or `project:id`."), ElementSelector, TeamSelector, TagSelector, PathSelector])
183
+ .meta({ id: "Selector", title: "Selector", description: "One entry of a Saved View's `include` or `exclude`: an id, or a map that picks several Elements at once." });
125
184
  /** The schema a selector as written is checked against, picked by its keys, so a mistake is reported against the form meant. */
126
185
  export function selectorSchemaFor(value) {
127
186
  if (typeof value === "string")
@@ -138,11 +197,21 @@ export function selectorSchemaFor(value) {
138
197
  return PathSelector;
139
198
  return undefined;
140
199
  }
141
- export const ImpactLens = z.strictObject({ impact: Ref, direction: z.enum(["upstream", "downstream", "both"]).optional() });
142
- export const TeamLens = z.strictObject({ team: Id });
143
- export const PathLens = z.strictObject({ path: PathSelector });
200
+ export const ImpactLens = z
201
+ .strictObject({
202
+ impact: Ref.describe("The Element whose impact is highlighted: an id in this Project, or `project:id`."),
203
+ direction: z
204
+ .enum(["upstream", "downstream", "both"])
205
+ .optional()
206
+ .describe("Which side to highlight. `upstream`: what depends on the Element. `downstream`: what it depends on. `both`: both sides. Default: `both`."),
207
+ })
208
+ .describe("The Impact Lens: what is upstream or downstream of one Element, each node marked with how many hops away it is.");
209
+ export const TeamLens = z.strictObject({ team: Id.describe("The Team: the id of a Team in `workspace.yaml`.") }).describe("The Team Lens: what one Team owns.");
210
+ export const PathLens = z.strictObject({ path: PathSelector }).describe("The Path Lens: the paths between two Elements.");
144
211
  /** Presentation-only highlighting a Saved View opens with; it never changes which nodes the View holds. */
145
- export const Lens = z.union([ImpactLens, TeamLens, PathLens]);
212
+ export const Lens = z
213
+ .union([ImpactLens, TeamLens, PathLens])
214
+ .meta({ id: "Lens", title: "Lens", description: "The Lens the View opens with. A Lens highlights nodes and never changes which nodes the View shows." });
146
215
  /** The schema a Lens as written is checked against, picked by its keys. */
147
216
  export function lensSchemaFor(value) {
148
217
  if (value === null || typeof value !== "object" || Array.isArray(value))
@@ -157,27 +226,43 @@ export function lensSchemaFor(value) {
157
226
  }
158
227
  export const levels = ["c1", "c2", "c3", "deployment"];
159
228
  const viewFields = {
160
- title: z.string(),
161
- description: z.string().optional(),
162
- tags: z.array(z.string()).optional(),
163
- level: z.enum(levels),
164
- expand: z.array(Ref).optional().describe("Elements opened one level deeper than `level`"),
165
- collapse: z.array(Ref).optional().describe("Elements closed, hiding everything inside them"),
166
- direction: z.enum(["TB", "BT", "LR", "RL"]).optional(),
167
- environment: Id.optional().describe("For `level: deployment`: the Environment shown"),
168
- targets: z.array(Ref).optional().describe("For `level: deployment`: only these Deployment Target subtrees"),
229
+ title: z.string().describe("The View's display title."),
230
+ description: z.string().optional().describe("What the View shows, or the question it answers."),
231
+ tags: z.array(z.string()).optional().describe("Free-form labels for the View."),
232
+ level: z
233
+ .enum(levels)
234
+ .describe("The level every selected Element is collapsed to. `c1`: Persons and Systems. `c2`: Services, grouped in their Systems. `c3`: Components, inside their Services. `deployment`: a Deployment View, which places Deployments on their Deployment Targets in one Environment and needs `environment`."),
235
+ expand: z
236
+ .array(Ref)
237
+ .optional()
238
+ .describe("Elements to open one level deeper than `level`, showing their children. Each is an id in this Project, or `project:id`, and must be a node of the View that has children. A Deployment View ignores it."),
239
+ collapse: z
240
+ .array(Ref)
241
+ .optional()
242
+ .describe("Elements to close, hiding everything inside them. Each is an id in this Project, or `project:id`, and must be a node of the View that has children. A Deployment View ignores it."),
243
+ direction: z
244
+ .enum(["TB", "BT", "LR", "RL"])
245
+ .optional()
246
+ .describe("The way the diagram runs. `TB`: top to bottom. `BT`: bottom to top. `LR`: left to right. `RL`: right to left. Default: `LR`, or `TB` for a Deployment View."),
247
+ environment: Id.optional().describe("For a Deployment View (`level: deployment`), which must have it, and for no other View: the Environment shown, as the id of an Environment in `workspace.yaml`."),
248
+ targets: z
249
+ .array(Ref)
250
+ .optional()
251
+ .describe("For a Deployment View (`level: deployment`) only: shows only the Deployments on these Deployment Targets and on the Targets inside them. Each is an id in this Project, or `project:id`. Default: every Deployment Target."),
169
252
  };
170
253
  /**
171
254
  * A Saved structural or Deployment View: `include` selectors (every Element
172
255
  * when absent) less `exclude`, collapsed to `level`, then `expand` and
173
256
  * `collapse` applied. A Deployment View also names its `environment`.
174
257
  */
175
- export const StructuralView = z.strictObject({
258
+ export const StructuralView = z
259
+ .strictObject({
176
260
  ...viewFields,
177
- include: z.array(Selector).optional().describe("Selectors to show; every Element when absent"),
178
- exclude: z.array(Selector).optional(),
261
+ include: z.array(Selector).optional().describe("Selectors for the Elements to show. Default: every Element in the Workspace."),
262
+ exclude: z.array(Selector).optional().describe("Selectors for the Elements to leave out of what `include` picked. An excluded Element takes everything inside it with it."),
179
263
  lens: Lens.optional(),
180
- });
264
+ })
265
+ .describe("A structural Saved View: the Elements its selectors pick, drawn at one `level`. With `level: deployment` it is a Deployment View. Its key is the View's id, unique among the Project's Saved Views.");
181
266
  /** Shallow form used by Load: selectors and the Lens are checked one by one against the form each is written in. */
182
267
  export const shallowView = z.strictObject({
183
268
  ...viewFields,
@@ -191,40 +276,51 @@ export const shallowView = z.strictObject({
191
276
  * subscribers, or with `return: true` the reply to a sync Relationship the
192
277
  * other way.
193
278
  */
194
- export const Step = z.strictObject({
195
- from: Ref,
196
- to: Ref,
197
- relationship: Ref.optional().describe("The id of the Relationship the Step takes, when several connect the pair"),
198
- description: z.string().optional(),
199
- note: z.string().optional(),
200
- return: z.boolean().optional().describe("The reply to a sync Relationship from `to` to `from`"),
201
- });
279
+ export const Step = z
280
+ .strictObject({
281
+ from: Ref.describe("The Element the Step starts at: the consumer of a call, the Publisher of an event, or the sender of a reply. An id in this Project, or `project:id`."),
282
+ to: Ref.describe("The Element the Step reaches: the provider of a call, the Subscriber of an event, or the receiver of a reply. An id in this Project, or `project:id`."),
283
+ relationship: Ref.optional().describe("The `id` of the Relationship the Step takes, as an id in this Project or `project:id`. Needed only when several Relationships match the two Elements."),
284
+ description: z.string().optional().describe("The text on the Step's arrow. Default: the Relationship's `description`, or its `channel` for an event."),
285
+ note: z.string().optional().describe("A note shown under the Step."),
286
+ return: z.boolean().optional().describe("`true` makes the Step the reply to a sync Relationship declared from `to` to `from`. An async Relationship has no reply. Default: `false`."),
287
+ })
288
+ .describe("A Step: one interaction of the scenario, which must follow a Relationship in the Model. It is a call from a consumer to its provider, an event from a Publisher to a Subscriber, or with `return: true` a reply.");
202
289
  /** A Saved Dynamic View: one scenario as an ordered list of Steps, each resolved to an existing Relationship. */
203
- export const DynamicView = z.strictObject({
204
- title: z.string(),
205
- description: z.string().optional(),
206
- tags: z.array(z.string()).optional(),
207
- participants: z.array(Ref).optional().describe("Fixes the participants' order; otherwise they are ordered by first appearance"),
208
- steps: z.array(Step),
209
- });
210
- export const Views = z.strictObject({
211
- structural: z.record(Id, StructuralView).optional(),
212
- dynamic: z.record(Id, DynamicView).optional(),
213
- });
290
+ export const DynamicView = z
291
+ .strictObject({
292
+ title: z.string().describe("The View's display title."),
293
+ description: z.string().optional().describe("What the scenario is."),
294
+ tags: z.array(z.string()).optional().describe("Free-form labels for the View."),
295
+ participants: z
296
+ .array(Ref)
297
+ .optional()
298
+ .describe("Elements that take part, in the order to draw them, each as an id in this Project or `project:id`. Participants not listed follow, in the order the Steps first use them. An Element and its own ancestor can't both take part. Default: the order the Steps first use them."),
299
+ steps: z.array(Step).describe("The Steps of the scenario, in order."),
300
+ })
301
+ .describe("A Dynamic View: one scenario as an ordered list of Steps, shown as a sequence chart. Its key is the View's id, unique among the Project's Saved Views.");
302
+ export const Views = z
303
+ .strictObject({
304
+ structural: z.record(Id, StructuralView).optional().describe("Structural Views and Deployment Views, keyed by id. Other Projects name a View as `project:id`."),
305
+ dynamic: z.record(Id, DynamicView).optional().describe("Dynamic Views, keyed by id. Other Projects name a View as `project:id`."),
306
+ })
307
+ .describe("The Project's Saved Views: `structural` ones, which include Deployment Views, and `dynamic` ones.");
214
308
  /**
215
309
  * Any other `*.yaml` in a Project: `people`, `systems > services > components`,
216
310
  * and top-level `services` and `components` (which attach with `in:`).
217
311
  * This full, nested form is what editors validate against.
218
312
  */
219
- export const ModelFile = z.strictObject({
220
- people: z.record(Id, Person).optional(),
221
- systems: z.record(Id, System).optional(),
222
- services: z.record(Id, Service).optional(),
223
- components: z.record(Id, Component).optional(),
224
- targets: z.record(Id, Target).optional(),
225
- deployments: z.array(Deployment).optional(),
313
+ export const ModelFile = z
314
+ .strictObject({
315
+ people: z.record(Id, Person).optional().describe("Persons, keyed by id. An id is unique in the Project across all its Elements and Deployment Targets."),
316
+ systems: z.record(Id, System).optional().describe("Systems, keyed by id, each with its Services nested under `services`."),
317
+ services: z.record(Id, Service).optional().describe("Services declared at the top level, keyed by id: those outside any System, and those that join a System with `in`."),
318
+ components: z.record(Id, Component).optional().describe("Components declared at the top level, keyed by id. Each names its Service with `in`."),
319
+ targets: z.record(Id, Target).optional().describe("Deployment Targets, keyed by id and nested as they nest. Their ids share the Project's ids with its Elements."),
320
+ deployments: z.array(Deployment).optional().describe("Deployments: which Service runs in which Environment on which Deployment Target, with its URLs."),
226
321
  views: Views.optional(),
227
- });
322
+ })
323
+ .describe("A Project file: any `.yaml` file in a Project folder other than `project.yaml`.");
228
324
  /** The map key each kind is declared under. */
229
325
  export const collectionOf = { person: "people", system: "systems", service: "services", component: "components" };
230
326
  export const kindOfCollection = Object.fromEntries(Object.entries(collectionOf).map(([kind, key]) => [key, kind]));