@toa.io/extensions.configuration 1.0.0-alpha.273 → 1.0.0-alpha.275

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 (139) hide show
  1. package/CHANGELOG.md +220 -0
  2. package/components/configuration.values/manifest.toa.yaml +158 -0
  3. package/components/configuration.values/operations/create.d.ts +16 -0
  4. package/components/configuration.values/operations/create.js +58 -0
  5. package/components/configuration.values/operations/create.js.map +1 -0
  6. package/components/configuration.values/operations/fetch.d.ts +11 -0
  7. package/components/configuration.values/operations/fetch.js +17 -0
  8. package/components/configuration.values/operations/fetch.js.map +1 -0
  9. package/components/configuration.values/operations/get.d.ts +17 -0
  10. package/components/configuration.values/operations/get.js +23 -0
  11. package/components/configuration.values/operations/get.js.map +1 -0
  12. package/components/configuration.values/operations/lib/map.d.ts +11 -0
  13. package/components/configuration.values/operations/lib/map.js +26 -0
  14. package/components/configuration.values/operations/lib/map.js.map +1 -0
  15. package/components/configuration.values/operations/lib/map.test.d.ts +1 -0
  16. package/components/configuration.values/operations/lib/map.test.js +26 -0
  17. package/components/configuration.values/operations/lib/map.test.js.map +1 -0
  18. package/components/configuration.values/operations/lib/resolve.d.ts +27 -0
  19. package/components/configuration.values/operations/lib/resolve.js +28 -0
  20. package/components/configuration.values/operations/lib/resolve.js.map +1 -0
  21. package/components/configuration.values/operations/list.d.ts +10 -0
  22. package/components/configuration.values/operations/list.js +15 -0
  23. package/components/configuration.values/operations/list.js.map +1 -0
  24. package/components/configuration.values/operations/tsconfig.tsbuildinfo +1 -0
  25. package/components/configuration.values/source/create.ts +56 -0
  26. package/components/configuration.values/source/fetch.ts +24 -0
  27. package/components/configuration.values/source/get.ts +33 -0
  28. package/components/configuration.values/source/lib/map.test.ts +34 -0
  29. package/components/configuration.values/source/lib/map.ts +34 -0
  30. package/components/configuration.values/source/lib/resolve.ts +54 -0
  31. package/components/configuration.values/source/list.ts +19 -0
  32. package/components/configuration.values/tsconfig.json +9 -0
  33. package/cucumber.js +8 -0
  34. package/features/site/_app/immutable/asset.js +1 -0
  35. package/features/site/favicon.ico +0 -0
  36. package/features/site/index.html +6 -0
  37. package/features/steps/UI.ts +88 -0
  38. package/features/steps/tsconfig.json +9 -0
  39. package/features/ui.feature +93 -0
  40. package/package.json +12 -5
  41. package/readme.md +150 -34
  42. package/schemas/annotation.cos.yaml +27 -2
  43. package/source/Aspect.test.ts +84 -8
  44. package/source/Aspect.ts +59 -5
  45. package/source/Client.test.ts +104 -0
  46. package/source/Client.ts +258 -0
  47. package/source/Composition.ts +57 -0
  48. package/source/Factory.ts +28 -5
  49. package/source/Secret.test.ts +29 -0
  50. package/source/Secret.ts +29 -0
  51. package/source/UI.ts +212 -0
  52. package/source/configuration.test.ts +84 -52
  53. package/source/configuration.ts +28 -9
  54. package/source/const.ts +17 -0
  55. package/source/deployment.test.ts +80 -1
  56. package/source/deployment.ts +73 -23
  57. package/source/epoch.test.ts +26 -0
  58. package/source/epoch.ts +21 -0
  59. package/source/index.ts +2 -1
  60. package/transpiled/Aspect.d.ts +18 -4
  61. package/transpiled/Aspect.js +47 -3
  62. package/transpiled/Aspect.js.map +1 -1
  63. package/transpiled/Aspect.test.js +59 -9
  64. package/transpiled/Aspect.test.js.map +1 -1
  65. package/transpiled/Client.d.ts +61 -0
  66. package/transpiled/Client.js +173 -0
  67. package/transpiled/Client.js.map +1 -0
  68. package/transpiled/Client.test.d.ts +1 -0
  69. package/transpiled/Client.test.js +77 -0
  70. package/transpiled/Client.test.js.map +1 -0
  71. package/transpiled/Composition.d.ts +14 -0
  72. package/transpiled/Composition.js +43 -0
  73. package/transpiled/Composition.js.map +1 -0
  74. package/transpiled/Factory.d.ts +8 -2
  75. package/transpiled/Factory.js +17 -2
  76. package/transpiled/Factory.js.map +1 -1
  77. package/transpiled/Secret.d.ts +13 -0
  78. package/transpiled/Secret.js +26 -0
  79. package/transpiled/Secret.js.map +1 -0
  80. package/transpiled/Secret.test.d.ts +1 -0
  81. package/transpiled/Secret.test.js +26 -0
  82. package/transpiled/Secret.test.js.map +1 -0
  83. package/transpiled/UI.d.ts +25 -0
  84. package/transpiled/UI.js +199 -0
  85. package/transpiled/UI.js.map +1 -0
  86. package/transpiled/configuration.d.ts +7 -2
  87. package/transpiled/configuration.js +30 -12
  88. package/transpiled/configuration.js.map +1 -1
  89. package/transpiled/configuration.test.js +77 -51
  90. package/transpiled/configuration.test.js.map +1 -1
  91. package/transpiled/const.d.ts +11 -0
  92. package/transpiled/const.js +14 -0
  93. package/transpiled/const.js.map +1 -0
  94. package/transpiled/deployment.d.ts +10 -4
  95. package/transpiled/deployment.js +57 -20
  96. package/transpiled/deployment.js.map +1 -1
  97. package/transpiled/deployment.test.js +60 -0
  98. package/transpiled/deployment.test.js.map +1 -1
  99. package/transpiled/epoch.d.ts +2 -0
  100. package/transpiled/epoch.js +21 -0
  101. package/transpiled/epoch.js.map +1 -0
  102. package/transpiled/epoch.test.d.ts +1 -0
  103. package/transpiled/epoch.test.js +22 -0
  104. package/transpiled/epoch.test.js.map +1 -0
  105. package/transpiled/index.d.ts +2 -1
  106. package/transpiled/index.js +4 -1
  107. package/transpiled/index.js.map +1 -1
  108. package/transpiled/tsconfig.tsbuildinfo +1 -1
  109. package/ui/dist/_app/env.js +1 -0
  110. package/ui/dist/_app/immutable/assets/0.CNS8Cqhc.css +2 -0
  111. package/ui/dist/_app/immutable/assets/inter-cyrillic-ext-wght-normal.BOeWTOD4.woff2 +0 -0
  112. package/ui/dist/_app/immutable/assets/inter-cyrillic-wght-normal.DqGufNeO.woff2 +0 -0
  113. package/ui/dist/_app/immutable/assets/inter-greek-ext-wght-normal.DlzME5K_.woff2 +0 -0
  114. package/ui/dist/_app/immutable/assets/inter-greek-wght-normal.CkhJZR-_.woff2 +0 -0
  115. package/ui/dist/_app/immutable/assets/inter-latin-ext-wght-normal.DO1Apj_S.woff2 +0 -0
  116. package/ui/dist/_app/immutable/assets/inter-latin-wght-normal.Dx4kXJAl.woff2 +0 -0
  117. package/ui/dist/_app/immutable/assets/inter-vietnamese-wght-normal.CBcvBZtf.woff2 +0 -0
  118. package/ui/dist/_app/immutable/assets/ui.BghF56l_.css +1 -0
  119. package/ui/dist/_app/immutable/chunks/9jJjhQLX.js +8 -0
  120. package/ui/dist/_app/immutable/chunks/Bjy-W4x2.js +81 -0
  121. package/ui/dist/_app/immutable/chunks/CcD_ISxM.js +3 -0
  122. package/ui/dist/_app/immutable/chunks/DIMyK5Kn.js +6 -0
  123. package/ui/dist/_app/immutable/chunks/DeoPn_EJ.js +50 -0
  124. package/ui/dist/_app/immutable/chunks/DhkhwAIA.js +1 -0
  125. package/ui/dist/_app/immutable/chunks/DqaixZkn.js +1 -0
  126. package/ui/dist/_app/immutable/chunks/xihTtKlq.js +1 -0
  127. package/ui/dist/_app/immutable/entry/app.CuyzQBdh.js +2 -0
  128. package/ui/dist/_app/immutable/entry/start.DnMDIL4M.js +1 -0
  129. package/ui/dist/_app/immutable/nodes/0.Bo4-SMFs.js +1 -0
  130. package/ui/dist/_app/immutable/nodes/1.DvzV4Akx.js +1 -0
  131. package/ui/dist/_app/immutable/nodes/2.5jKweLxI.js +1 -0
  132. package/ui/dist/_app/immutable/nodes/3.B_6LXN2v.js +1 -0
  133. package/ui/dist/_app/immutable/nodes/4.D75qNOOe.js +1 -0
  134. package/ui/dist/_app/version.json +1 -0
  135. package/ui/dist/apple-touch-icon.png +0 -0
  136. package/ui/dist/favicon-96x96.png +0 -0
  137. package/ui/dist/favicon.ico +0 -0
  138. package/ui/dist/index.html +52 -0
  139. package/ui/dist/robots.txt +3 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,226 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [1.0.0-alpha.275](https://github.com/toa-io/toa/compare/v1.0.0-alpha.274...v1.0.0-alpha.275) (2026-09-02)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **configuration:** ship the component's code and the built page ([6ffe988](https://github.com/toa-io/toa/commit/6ffe988a9e67025c114e74ba94665b28a2cafaa1))
12
+ * **introspection:** keep a sideways scroll off the browser's back gesture ([419e012](https://github.com/toa-io/toa/commit/419e012ce093bcd0429dc93fe457bbd964cfc11c))
13
+
14
+
15
+ ### Features
16
+
17
+ * **ui:** give both consoles a favicon ([27d3881](https://github.com/toa-io/toa/commit/27d3881eda10e59dc4c9c5ef38c2a58b71e1448d))
18
+ * **ui:** leave signing out to its icon ([a82fbab](https://github.com/toa-io/toa/commit/a82fbab513706436254348a5e35115dc3721873f))
19
+
20
+
21
+
22
+
23
+
24
+ # [1.0.0-alpha.274](https://github.com/toa-io/toa/compare/v1.0.0-alpha.273...v1.0.0-alpha.274) (2026-09-02)
25
+
26
+
27
+ * Configuration is served by a component, followed live, and kept per epoch (#1017) ([b05997d](https://github.com/toa-io/toa/commit/b05997d3adb784f238a222cb46878b23859339a2)), closes [#1017](https://github.com/toa-io/toa/issues/1017)
28
+
29
+
30
+ ### Features
31
+
32
+ * **configuration:** drop the label from the epoch ([4baaff5](https://github.com/toa-io/toa/commit/4baaff5b22d00719142a65d56b50a1b100b29fbd))
33
+
34
+
35
+ ### BREAKING CHANGES
36
+
37
+ * a secret configuration value is an object, not a string;
38
+ read it with `unwrap()`.
39
+
40
+ Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
41
+
42
+ * test(configuration): wait for the second round rather than assume it
43
+
44
+ Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
45
+
46
+ * refactor(configuration)!: read a secret with its own unwrap
47
+
48
+ Component code depends on no Toa package, so a secret is read as
49
+ `context.configuration.apiKey.unwrap()` and the helper in `@toa.io/generic`
50
+ goes. A value a component reads as a secret is therefore given as a reference:
51
+ `identity.basic` no longer defaults `pepper` to `''`, the development context
52
+ and the feature harness give the token keys, the federation client secret and
53
+ the signing key as references, and the harness has a step for the secrets a
54
+ scenario refers to. CONTRIBUTING states the rule.
55
+ * `identity.basic` `pepper` has no default; a value read as a
56
+ secret must be given as a `$NAME` reference.
57
+
58
+ Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
59
+
60
+ * feat(configuration): list the configurations
61
+
62
+ `configuration.values.list` returns every component's configuration for its
63
+ deployed epoch, by component name, and `GET /configuration/values/` serves it
64
+ behind `system:configuration:get`.
65
+
66
+ Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
67
+
68
+ * fix(exposition): write a value in YAML the way its toJSON says
69
+
70
+ A redacted secret in a reply was dumped as an empty object; it is written as
71
+ `<REDACTED>`, as JSON and msgpack already write it.
72
+
73
+ Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
74
+
75
+ * test(configuration): a secret is an object, and stays redacted in a reply
76
+
77
+ A component with `{ a: 1, b: $SECRET_B }` returns its configuration as
78
+ `{ a: 1, b: '<REDACTED>' }` and the secret itself through `unwrap()`. The reply
79
+ step also accepts a reply as a caller across a process boundary receives it,
80
+ since a call within the process hands the object over as it is.
81
+
82
+ Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
83
+
84
+ * chore(schemas): bump the dependencies
85
+
86
+ ajv 8.18.0 to 8.20.0, ajv-formats 2.1.1 to 3.0.1, better-ajv-errors 1.2.0
87
+ to 2.0.3, fast-glob 3.2.12 to 3.3.3 and js-yaml 4.3.1 to 5.4.1 — the version
88
+ exposition already uses. The three majors keep the CommonJS entry points this
89
+ library calls: ajv-formats as a function, better-ajv-errors as .default, and
90
+ js-yaml's load.
91
+
92
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
93
+
94
+ * feat(configuration)!: serve the schema with the value
95
+
96
+ GET /configuration/values/:component/ answers { configuration, schema, epoch }
97
+ where it answered with the configuration alone, and list carries the schema of
98
+ every component. Nothing reads a configuration without needing to know what it
99
+ is checked against, and the schema was only ever on the values service.
100
+
101
+ An epoch the deployment does not know has no schema; the value stored for it
102
+ is still returned.
103
+
104
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
105
+
106
+ * feat(configuration): publish a configuration UI
107
+
108
+ The values service serves a page at /.configuration on port 8003, out of the
109
+ directory ui builds: the configured components, a screen per component showing
110
+ what it holds now, and a dialog creating the next one. Reading needs
111
+ system:configuration:get and creating needs system:configuration:create.
112
+
113
+ A configuration is immutable, so the dialog opens on the current value and what
114
+ is left out of it is left out of the component. The editor takes YAML, the
115
+ schema is applied before anything is sent, and a secret is a reference the page
116
+ never shows.
117
+
118
+ The page is always published: the annotation is the per-component values map
119
+ and has nowhere to carry a switch.
120
+
121
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
122
+
123
+ * feat(introspection): link a component to its configuration
124
+
125
+ A card carrying @toa.io/extensions.configuration reads that extension as a link
126
+ to the configuration UI rather than as a name, and configuration joins the
127
+ namespaces the runtime provides, so its components band under System.
128
+
129
+ Deployed, both pages sit behind the same ingress and the path alone is right;
130
+ locally each console has its own port.
131
+
132
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
133
+
134
+ * feat(introspection): scroll the map, zoom with a modifier
135
+
136
+ The map was grabbed to move and zoomed with a bare wheel, which is neither what
137
+ a page does nor what the wheel does anywhere else. A plain scroll now pans on
138
+ both axes and the wheel scales only with the modifier held — a trackpad pinch
139
+ arrives as one of those on every platform.
140
+
141
+ A card's own scrollable box keeps its wheel, in both paths.
142
+
143
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
144
+
145
+ * refactor(introspection): centre the filter in the header
146
+
147
+ The sides take equal space, which is what leaves the filter between them.
148
+ Neither side may shrink under what it holds, or the tabs run out from under
149
+ their side and across the filter, and the filter across the sign-out button;
150
+ the title gives way instead.
151
+
152
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
153
+
154
+ * fix(configuration): connect the UI to the values service
155
+
156
+ The page was declared as a dependency from inside `open`, and a connector connects
157
+ what it depends on before `open` runs — so the server was constructed and never
158
+ listened. Nothing caught it: the UI feature builds the server itself.
159
+
160
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
161
+
162
+ * feat(configuration)!: reserve resources in the annotation
163
+
164
+ The values service deploys like any other and must state what it may take, but the
165
+ annotation is a map of component ids and had nowhere to put it — so `toa env` failed
166
+ for every context using configuration unless it declared a context-wide `resources`.
167
+
168
+ `resources` is now the service's own, read the way `introspection` and `realtime` read
169
+ theirs. A component actually named `resources` is written `default.resources`, which is
170
+ what its id is anyway.
171
+
172
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
173
+
174
+ * feat(configuration): follow the system colour scheme
175
+
176
+ The dark tokens were behind a `.dark` class nothing sets, and the `dark:` variant was
177
+ pointed at that class too — so a component's own dark styling never applied either.
178
+ Both now key off `prefers-color-scheme`, and `color-scheme` hands the native chrome
179
+ the same answer.
180
+
181
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
182
+
183
+ * feat(introspection): follow the system colour scheme
184
+
185
+ The dark tokens were behind a `.dark` class nothing sets, and the `dark:` variant was
186
+ pointed at that class too — so a component's own dark styling never applied either.
187
+ Both now key off `prefers-color-scheme`, and `color-scheme` hands the native chrome
188
+ the same answer.
189
+
190
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
191
+
192
+ * feat(configuration): present a change as an edit of what is there
193
+
194
+ A configuration is immutable and creating one replaces the whole of it, but the dialog
195
+ opens on the current value and the page never shows an older one — so what the reader
196
+ does is edit. The words follow: Edit rather than New, Update rather than Create, and
197
+ the paragraph explaining the model goes, along with the field's label, which the title
198
+ above it already said.
199
+
200
+ The editor also stayed as wide as its longest line — `field-sizing: content` sizes to
201
+ content, and no `max-width` clamps that — so a long value painted outside the dialog.
202
+ It is fixed now, the dialog takes the width the screen has rather than a fixed step,
203
+ and the band held for errors no longer leaves a gap when there are none.
204
+
205
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
206
+
207
+ * feat(configuration): mark a component that keeps a secret
208
+
209
+ A key after the name on the row, wherever the configuration holds a reference, however
210
+ deep. The predicate reads the same lines the value screen renders, so the two cannot
211
+ disagree about what counts as a secret.
212
+
213
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
214
+
215
+ * feat(configuration): lead back to the list from the title
216
+
217
+ Every address ends in a slash, so the way up is the address itself on the list and one
218
+ level above it on a component's screen — which holds wherever the page is mounted.
219
+
220
+ Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
221
+
222
+
223
+
224
+
225
+
6
226
  # [1.0.0-alpha.273](https://github.com/toa-io/toa/compare/v1.0.0-alpha.272...v1.0.0-alpha.273) (2026-09-02)
7
227
 
8
228
  **Note:** Version bump only for package @toa.io/extensions.configuration
@@ -0,0 +1,158 @@
1
+ namespace: configuration
2
+ name: values
3
+
4
+ # One document per configuration created. Documents are immutable: a change is a new
5
+ # document, and the latest one for a component and an epoch is the last created.
6
+ # What every component's epoch, schema and defaults are, the service is told on
7
+ # deployment (`TOA_CONFIGURATION_VALUES`). A created object is published as the
8
+ # prototype's `created` event.
9
+
10
+ entity:
11
+ schema:
12
+ type: object
13
+ properties:
14
+ component:
15
+ type: string
16
+ epoch:
17
+ type: string
18
+ configuration:
19
+ type: object
20
+ originator:
21
+ type: string
22
+ required:
23
+ - component
24
+ - epoch
25
+ - configuration
26
+ - originator
27
+ index:
28
+ lookup:
29
+ component: asc
30
+ epoch: asc
31
+ _created: desc
32
+
33
+ operations:
34
+ # the latest configuration of a component: created, else deployed defaults, else none
35
+ get:
36
+ query: false
37
+ input:
38
+ type: object
39
+ properties:
40
+ component:
41
+ type: string
42
+ epoch:
43
+ type: string
44
+ required:
45
+ - component
46
+ # the value and the schema it is checked against, so a caller can show and check it
47
+ output:
48
+ type: object
49
+ nullable: true
50
+ properties:
51
+ configuration:
52
+ type: object
53
+ schema:
54
+ type: object
55
+ epoch:
56
+ type: string
57
+ required:
58
+ - configuration
59
+ - epoch
60
+ # the same for many at once, as the aspects of one process ask
61
+ fetch:
62
+ query: false
63
+ input:
64
+ type: array
65
+ items:
66
+ type: object
67
+ properties:
68
+ component:
69
+ type: string
70
+ epoch:
71
+ type: string
72
+ required:
73
+ - component
74
+ - epoch
75
+ output:
76
+ type: array
77
+ items:
78
+ type: object
79
+ properties:
80
+ component:
81
+ type: string
82
+ epoch:
83
+ type: string
84
+ configuration:
85
+ type: object
86
+ nullable: true
87
+ created:
88
+ type: integer
89
+ required:
90
+ - component
91
+ - epoch
92
+ - configuration
93
+ - created
94
+ # every component's configuration for its deployed epoch, by component name
95
+ list:
96
+ query: false
97
+ output:
98
+ type: array
99
+ items:
100
+ type: object
101
+ properties:
102
+ component:
103
+ type: string
104
+ epoch:
105
+ type: string
106
+ schema:
107
+ type: object
108
+ configuration:
109
+ type: object
110
+ required:
111
+ - component
112
+ - epoch
113
+ - schema
114
+ - configuration
115
+ create:
116
+ query: false
117
+ input:
118
+ type: object
119
+ properties:
120
+ component:
121
+ type: string
122
+ configuration:
123
+ type: object
124
+ originator:
125
+ type: object
126
+ properties:
127
+ id:
128
+ type: string
129
+ required:
130
+ - id
131
+ required:
132
+ - component
133
+ - configuration
134
+ - originator
135
+ errors:
136
+ - UNKNOWN_COMPONENT
137
+ - INVALID_CONFIGURATION
138
+
139
+ exposition:
140
+ isolated: true
141
+ /:
142
+ GET:
143
+ io:output: true
144
+ auth:role: system:configuration:get
145
+ endpoint: list
146
+ /:component:
147
+ map:segments:
148
+ component: component
149
+ GET:
150
+ io:output: true
151
+ auth:role: system:configuration:get
152
+ endpoint: get
153
+ POST:
154
+ io:output: [id, epoch]
155
+ auth:rule:
156
+ role: system:configuration:create
157
+ delegate: originator
158
+ endpoint: create
@@ -0,0 +1,16 @@
1
+ export declare function transition(input: Input, object: Entity): Promise<Entity | Error>;
2
+ interface Input {
3
+ component: string;
4
+ configuration: object;
5
+ originator: {
6
+ id: string;
7
+ };
8
+ }
9
+ interface Entity {
10
+ id: string;
11
+ component: string;
12
+ epoch: string;
13
+ configuration: object;
14
+ originator: string;
15
+ }
16
+ export {};
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.transition = void 0;
27
+ const schemas = __importStar(require("@toa.io/schemas"));
28
+ const map_1 = require("./lib/map");
29
+ async function transition(input, object) {
30
+ const known = (0, map_1.entry)(input.component);
31
+ if (known === undefined)
32
+ return new UnknownComponentError(input.component);
33
+ // the schema fills its defaults, so what is stored is whole
34
+ const configuration = structuredClone(input.configuration);
35
+ const schema = schemas.schema(known.schema);
36
+ try {
37
+ schema.validate(configuration);
38
+ }
39
+ catch (error) {
40
+ return new InvalidConfigurationError(error.message);
41
+ }
42
+ object.component = input.component;
43
+ object.epoch = known.epoch;
44
+ object.configuration = configuration;
45
+ object.originator = input.originator.id;
46
+ return object;
47
+ }
48
+ exports.transition = transition;
49
+ class UnknownComponentError extends Error {
50
+ code = 'UNKNOWN_COMPONENT';
51
+ constructor(component) {
52
+ super(`Component '${component}' is not configured`);
53
+ }
54
+ }
55
+ class InvalidConfigurationError extends Error {
56
+ code = 'INVALID_CONFIGURATION';
57
+ }
58
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1,11 @@
1
+ import { type Context } from './lib/resolve';
2
+ export declare function computation(input: Pair[], context: Context): Promise<Fetched[]>;
3
+ interface Pair {
4
+ component: string;
5
+ epoch: string;
6
+ }
7
+ interface Fetched extends Pair {
8
+ configuration: object | null;
9
+ created: number;
10
+ }
11
+ export {};
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computation = void 0;
4
+ const resolve_1 = require("./lib/resolve");
5
+ async function computation(input, context) {
6
+ return await Promise.all(input.map(async ({ component, epoch }) => {
7
+ const value = await (0, resolve_1.resolve)(context, component, epoch);
8
+ return {
9
+ component,
10
+ epoch,
11
+ configuration: value === null ? null : value.configuration,
12
+ created: value === null ? 0 : value.created
13
+ };
14
+ }));
15
+ }
16
+ exports.computation = computation;
17
+ //# sourceMappingURL=fetch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../source/fetch.ts"],"names":[],"mappings":";;;AAAA,2CAAqD;AAE9C,KAAK,UAAU,WAAW,CAAE,KAAa,EAAE,OAAgB;IAChE,OAAO,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,KAAK,EAAE,EAAE,EAAE;QAChE,MAAM,KAAK,GAAG,MAAM,IAAA,iBAAO,EAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAA;QAEtD,OAAO;YACL,SAAS;YACT,KAAK;YACL,aAAa,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa;YAC1D,OAAO,EAAE,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO;SAC5C,CAAA;IACH,CAAC,CAAC,CAAC,CAAA;AACL,CAAC;AAXD,kCAWC"}
@@ -0,0 +1,17 @@
1
+ import { type Context } from './lib/resolve';
2
+ /**
3
+ * The latest configuration of a component, with the schema it is checked against. The
4
+ * schema is the deployment's, so an epoch the deployment does not know has none — the
5
+ * value is still what was stored for it.
6
+ */
7
+ export declare function computation(input: Input, context: Context): Promise<Item | null>;
8
+ interface Input {
9
+ component: string;
10
+ epoch?: string;
11
+ }
12
+ interface Item {
13
+ configuration: object;
14
+ schema?: object;
15
+ epoch: string;
16
+ }
17
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computation = void 0;
4
+ const map_1 = require("./lib/map");
5
+ const resolve_1 = require("./lib/resolve");
6
+ /**
7
+ * The latest configuration of a component, with the schema it is checked against. The
8
+ * schema is the deployment's, so an epoch the deployment does not know has none — the
9
+ * value is still what was stored for it.
10
+ */
11
+ async function computation(input, context) {
12
+ const value = await (0, resolve_1.resolve)(context, input.component, input.epoch);
13
+ if (value === null)
14
+ return null;
15
+ const known = (0, map_1.entry)(input.component);
16
+ return {
17
+ configuration: value.configuration,
18
+ schema: known?.schema,
19
+ epoch: input.epoch ?? known.epoch
20
+ };
21
+ }
22
+ exports.computation = computation;
23
+ //# sourceMappingURL=get.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get.js","sourceRoot":"","sources":["../source/get.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AACjC,2CAAqD;AAErD;;;;GAIG;AACI,KAAK,UAAU,WAAW,CAAE,KAAY,EAAE,OAAgB;IAC/D,MAAM,KAAK,GAAG,MAAM,IAAA,iBAAO,EAAC,OAAO,EAAE,KAAK,CAAC,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;IAElE,IAAI,KAAK,KAAK,IAAI;QAChB,OAAO,IAAI,CAAA;IAEb,MAAM,KAAK,GAAG,IAAA,WAAK,EAAC,KAAK,CAAC,SAAS,CAAC,CAAA;IAEpC,OAAO;QACL,aAAa,EAAE,KAAK,CAAC,aAAa;QAClC,MAAM,EAAE,KAAK,EAAE,MAAM;QACrB,KAAK,EAAE,KAAK,CAAC,KAAK,IAAI,KAAM,CAAC,KAAK;KACnC,CAAA;AACH,CAAC;AAbD,kCAaC"}
@@ -0,0 +1,11 @@
1
+ /** What the deployment told the service about every configured component. */
2
+ export declare function entry(component: string): Entry | undefined;
3
+ /** The configured components, by name. */
4
+ export declare function components(): string[];
5
+ export declare const VARIABLE = "TOA_CONFIGURATION_VALUES";
6
+ export interface Entry {
7
+ epoch: string;
8
+ schema: object;
9
+ defaults?: object;
10
+ }
11
+ export type Values = Record<string, Entry>;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VARIABLE = exports.components = exports.entry = void 0;
4
+ /** What the deployment told the service about every configured component. */
5
+ function entry(component) {
6
+ return read()[component];
7
+ }
8
+ exports.entry = entry;
9
+ /** The configured components, by name. */
10
+ function components() {
11
+ return Object.keys(read()).sort();
12
+ }
13
+ exports.components = components;
14
+ function read() {
15
+ const source = process.env[exports.VARIABLE] ?? '{}';
16
+ // read again once the variable changes, as it does between scenarios of one process
17
+ if (source !== parsed) {
18
+ values = JSON.parse(source);
19
+ parsed = source;
20
+ }
21
+ return values;
22
+ }
23
+ let parsed = null;
24
+ let values = {};
25
+ exports.VARIABLE = 'TOA_CONFIGURATION_VALUES';
26
+ //# sourceMappingURL=map.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"map.js","sourceRoot":"","sources":["../../source/lib/map.ts"],"names":[],"mappings":";;;AAAA,6EAA6E;AAC7E,SAAgB,KAAK,CAAE,SAAiB;IACtC,OAAO,IAAI,EAAE,CAAC,SAAS,CAAC,CAAA;AAC1B,CAAC;AAFD,sBAEC;AAED,0CAA0C;AAC1C,SAAgB,UAAU;IACxB,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;AACnC,CAAC;AAFD,gCAEC;AAED,SAAS,IAAI;IACX,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAQ,CAAC,IAAI,IAAI,CAAA;IAE5C,oFAAoF;IACpF,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAW,CAAA;QACrC,MAAM,GAAG,MAAM,CAAA;IACjB,CAAC;IAED,OAAO,MAAM,CAAA;AACf,CAAC;AAED,IAAI,MAAM,GAAkB,IAAI,CAAA;AAChC,IAAI,MAAM,GAAW,EAAE,CAAA;AAEV,QAAA,QAAQ,GAAG,0BAA0B,CAAA"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const map_1 = require("./map");
4
+ afterEach(() => {
5
+ delete process.env[map_1.VARIABLE];
6
+ });
7
+ it('should be empty without the variable', () => {
8
+ expect((0, map_1.entry)('a.b')).toBeUndefined();
9
+ });
10
+ it('should read the variable', () => {
11
+ const values = { 'a.b': { epoch: 'e', schema: { type: 'object' }, defaults: { foo: 1 } } };
12
+ process.env[map_1.VARIABLE] = JSON.stringify(values);
13
+ expect((0, map_1.entry)('a.b')).toStrictEqual(values['a.b']);
14
+ expect((0, map_1.entry)('a.c')).toBeUndefined();
15
+ });
16
+ it('should follow the variable', () => {
17
+ process.env[map_1.VARIABLE] = JSON.stringify({ 'a.b': { epoch: 'e1', schema: {} } });
18
+ expect((0, map_1.entry)('a.b')?.epoch).toStrictEqual('e1');
19
+ process.env[map_1.VARIABLE] = JSON.stringify({ 'a.b': { epoch: 'e2', schema: {} } });
20
+ expect((0, map_1.entry)('a.b')?.epoch).toStrictEqual('e2');
21
+ });
22
+ it('should list the components by name', () => {
23
+ process.env[map_1.VARIABLE] = JSON.stringify({ 'b.two': { epoch: 'e', schema: {} }, 'a.one': { epoch: 'e', schema: {} } });
24
+ expect((0, map_1.components)()).toStrictEqual(['a.one', 'b.two']);
25
+ });
26
+ //# sourceMappingURL=map.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file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AAC,SAAS,CAAC,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IAE9E,MAAM,CAAC,IAAA,WAAK,EAAC,KAAK,CAAC,EAAE,KAAK,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAA;AACjD,CAAC,CAAC,CAAA;AAEF,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;IAC5C,OAAO,CAAC,GAAG,CAAC,cAAQ,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,CAAC,CAAA;IAEpH,MAAM,CAAC,IAAA,gBAAU,GAAE,CAAC,CAAC,aAAa,CAAC,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAA;AACxD,CAAC,CAAC,CAAA"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * The latest configuration created for the component and the epoch; the deployed
3
+ * defaults when none was; `null` when the epoch is not the one deployed.
4
+ */
5
+ export declare function resolve(context: Context, component: string, epoch?: string): Promise<Value | null>;
6
+ /** A configuration and when it was created; `0` for the deployed defaults. */
7
+ export interface Value {
8
+ configuration: object;
9
+ created: number;
10
+ }
11
+ export interface Context {
12
+ local: {
13
+ enumerate: (request: {
14
+ query: Query;
15
+ }) => Promise<Stored[]>;
16
+ };
17
+ }
18
+ interface Query {
19
+ criteria: string;
20
+ sort: string[];
21
+ limit: number;
22
+ }
23
+ interface Stored {
24
+ configuration: object;
25
+ _created: number;
26
+ }
27
+ export {};