@reventlessdev/reventless-core 3.0.0-alpha.235 → 3.0.0-alpha.237

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 (36) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/package.json +7 -7
  3. package/src/admin/Platform_Admin_Structure.res +5 -1
  4. package/src/admin/Platform_Admin_Structure.res.mjs +4 -2
  5. package/src/admin/Platform_BakedManifest.res +52 -0
  6. package/src/admin/Platform_BakedManifest.res.mjs +38 -0
  7. package/src/admin/Platform_ComponentDefinitionsApi.res +4 -2
  8. package/src/admin/Platform_ComponentDefinitionsApi.res.mjs +11 -3
  9. package/src/components/Api/GraphQL_FragmentGenerator.res +14 -1
  10. package/src/components/Api/GraphQL_FragmentGenerator.res.mjs +1 -1
  11. package/src/components/Api/QueryDbListQuery.res +25 -1
  12. package/src/components/Api/QueryDbListQuery.res.mjs +11 -4
  13. package/src/components/Api/SuryToJsonSchema.res +39 -0
  14. package/src/components/Api/SuryToJsonSchema.res.mjs +34 -3
  15. package/src/components/Dcb/Dcb_Builder.res +52 -3
  16. package/src/components/Dcb/Dcb_Builder.res.mjs +57 -1
  17. package/src/plugin/component/Plugin_Structure.res +112 -15
  18. package/src/plugin/component/Plugin_Structure.res.mjs +77 -9
  19. package/src/plugin/lifecycle/PluginsReadModelSpec.res.mjs +3 -2
  20. package/tests/admin/Platform_Admin_StructureTest.res +49 -0
  21. package/tests/admin/Platform_Admin_StructureTest.res.mjs +24 -0
  22. package/tests/admin/Platform_BakedManifestTest.res +3 -1
  23. package/tests/admin/Platform_BakedManifestTest.res.mjs +3 -1
  24. package/tests/admin/Platform_ComponentDefinitionsApiTest.res +14 -8
  25. package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +24 -12
  26. package/tests/admin/Platform_PluginStructuresApiTest.res +3 -1
  27. package/tests/admin/Platform_PluginStructuresApiTest.res.mjs +6 -2
  28. package/tests/api/Api_IdsTest.res.mjs +1 -1
  29. package/tests/api/SuryToJsonSchemaTest.res +141 -1
  30. package/tests/api/SuryToJsonSchemaTest.res.mjs +269 -54
  31. package/tests/dcb/DcbEventLogSchemaTest.res +77 -0
  32. package/tests/dcb/DcbEventLogSchemaTest.res.mjs +90 -0
  33. package/tests/plugin/PluginStructureTest.res +168 -12
  34. package/tests/plugin/PluginStructureTest.res.mjs +146 -9
  35. package/tests/plugin/StateViewSlice/PsAnnotatedView.res.mjs +3 -2
  36. package/tests/plugin/pluginDefinitionRequiredScalars.txt +2 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,27 @@
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
+ # 3.0.0-alpha.237 (2026-08-16)
7
+
8
+ ### Features
9
+
10
+ * **core:** exclude retired rows from reads a caller may not widen ([662f31a](https://github.com/ReventlessDev/reventless-core/commit/662f31abb717bda5154199d349da6dcf8e2d3e78))
11
+ * **core:** let [@retired](https://github.com/retired) name a lifecycle state, not only a boolean ([6bb346b](https://github.com/ReventlessDev/reventless-core/commit/6bb346b4f6a5f33826fc24537953482a76067177))
12
+ * **core:** mark the state that retires a row, and allow more than one ([cb1461f](https://github.com/ReventlessDev/reventless-core/commit/cb1461f024d3ca3b53fd9c8b010a054e3fcc4555))
13
+ * **core:** publish queryableDef.retiredField from the [@retired](https://github.com/retired) annotation ([b44436a](https://github.com/ReventlessDev/reventless-core/commit/b44436a997b6c4ff0531f0b07d793cc858eef94a))
14
+ * **spec:** [@retired](https://github.com/retired) state-field annotation and its schema emission ([2d8234b](https://github.com/ReventlessDev/reventless-core/commit/2d8234b6b3dd8f479031a67eb5b4b47b5c0c2ff9))
15
+
16
+
17
+ # 3.0.0-alpha.236 (2026-08-15)
18
+
19
+ ### Bug Fixes
20
+
21
+ * **core:** describe a DCB event log by every event it carries ([047bc0b](https://github.com/ReventlessDev/reventless-core/commit/047bc0beb9be1468410fde37a7f787a3d68f92d2))
22
+ ### Features
23
+
24
+ * **aws:** serve one baked manifest per journey ([16d6307](https://github.com/ReventlessDev/reventless-core/commit/16d63071f059cf1fc7025f9be9206dda51f71053))
25
+
26
+
6
27
  # 3.0.0-alpha.235 (2026-08-15)
7
28
 
8
29
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/reventless-core",
3
- "version": "3.0.0-alpha.235",
3
+ "version": "3.0.0-alpha.237",
4
4
  "description": "Core package for Reventless framework",
5
5
  "license": "Apache-2.0",
6
6
  "jest": {
@@ -29,21 +29,21 @@
29
29
  "sury": "11.0.0-alpha.4",
30
30
  "uuid": "^13.0.0",
31
31
  "@reventlessdev/rescript-effect": "0.1.0-alpha.32",
32
+ "@reventlessdev/rescript-hash-object": "1.2.0-alpha.14",
33
+ "@reventlessdev/rescript-node": "2.0.0-alpha.7",
32
34
  "@reventlessdev/rescript-fast-csv": "2.0.0-alpha.7",
33
35
  "@reventlessdev/rescript-jest": "1.0.0-alpha.10",
34
- "@reventlessdev/rescript-node": "2.0.0-alpha.7",
35
- "@reventlessdev/rescript-hash-object": "1.2.0-alpha.14",
36
- "@reventlessdev/rescript-pulumi-pulumi": "2.3.0-alpha.19",
37
36
  "@reventlessdev/rescript-ssh2": "2.0.0-alpha.7",
37
+ "@reventlessdev/rescript-pulumi-pulumi": "2.3.0-alpha.19",
38
38
  "@reventlessdev/rescript-uuid": "2.0.0-alpha.0",
39
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.143",
39
40
  "@reventlessdev/reventless-interop": "3.0.0-alpha.31",
40
- "@reventlessdev/reventless-spec": "3.0.0-alpha.114",
41
- "@reventlessdev/reventless-infra": "3.0.0-alpha.142"
41
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.115"
42
42
  },
43
43
  "devDependencies": {
44
44
  "rescript": "12.3.0",
45
45
  "sury-ppx": "11.0.0-alpha.2",
46
- "@reventlessdev/reventless-ppx": "1.0.0-alpha.66"
46
+ "@reventlessdev/reventless-ppx": "1.0.0-alpha.67"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "rescript": "12.3.0"
@@ -122,7 +122,9 @@ let pluginReadModel: queryableDef = {
122
122
  // Hand-rolled rather than resolved, but the rung is the same one
123
123
  // `labelFieldsFromStateSchema` would report for a field literally named `name`.
124
124
  labelFieldSource: Some("convention"),
125
- statusField: Some("status"),
125
+ // The published wire name stays `status` — it is what the SDL declares and what
126
+ // stored rows carry. Only the key naming it moved.
127
+ lifecycleField: Some("status"),
126
128
  visibility: None,
127
129
  chapter: None,
128
130
  // The admin fragment hand-declares its query names rather than deriving them from
@@ -137,6 +139,8 @@ let pluginReadModel: queryableDef = {
137
139
  idFieldSource: None,
138
140
  requiredAccess: None,
139
141
  ownerField: None,
142
+ retiredField: None,
143
+ retiredValues: None,
140
144
  }
141
145
 
142
146
  let structure: pluginStructure = {
@@ -137,7 +137,7 @@ let pluginReadModel_searchableFields = ["name"];
137
137
 
138
138
  let pluginReadModel_labelFieldSource = "convention";
139
139
 
140
- let pluginReadModel_statusField = "status";
140
+ let pluginReadModel_lifecycleField = "status";
141
141
 
142
142
  let pluginReadModel_singleQueryField = Api_Naming$ReventlessCore.adminField("Plugin");
143
143
 
@@ -150,8 +150,10 @@ let pluginReadModel = {
150
150
  labelField: "name",
151
151
  searchableFields: pluginReadModel_searchableFields,
152
152
  labelFieldSource: pluginReadModel_labelFieldSource,
153
- statusField: pluginReadModel_statusField,
153
+ lifecycleField: pluginReadModel_lifecycleField,
154
154
  ownerField: undefined,
155
+ retiredField: undefined,
156
+ retiredValues: undefined,
155
157
  visibility: undefined,
156
158
  chapter: undefined,
157
159
  singleQueryField: pluginReadModel_singleQueryField,
@@ -204,6 +204,58 @@ let journeyKey = (~group: string): string => {
204
204
  `component-manifest-${slug}.json`
205
205
  }
206
206
 
207
+ let toSelection = (s: ReventlessInfra.Platform.bakedManifestSelection): selection => {
208
+ plugin: s.plugin,
209
+ views: s.views,
210
+ commands: s.commands,
211
+ derived: s.derived,
212
+ }
213
+
214
+ /** One declared journey, with everything a platform needs to serve it: the group
215
+ it serves, the file it is written to, and the include-list that decides the
216
+ file's contents. */
217
+ type journeyFile = {group: string, key: string, selections: array<selection>}
218
+
219
+ /**
220
+ The declared journeys, in declaration order, with their keys resolved.
221
+
222
+ The default journey is deliberately not among them: it is the file
223
+ `manifestUrl` points at, which is what a caller matching no declared group reads
224
+ and what every deployment had before journeys existed.
225
+ */
226
+ let journeyFiles = (~config: ReventlessInfra.Platform.bakedManifest): array<journeyFile> =>
227
+ config.journeys
228
+ ->Option.getOr([])
229
+ ->Array.map(j => {
230
+ group: j.group,
231
+ key: j.key->Option.getOr(journeyKey(~group=j.group)),
232
+ selections: j.components->Array.map(toSelection),
233
+ })
234
+
235
+ /**
236
+ Every file a bake declaration produces, as (key, selections) pairs.
237
+
238
+ The default journey first and always — it is what a caller matching no declared
239
+ group gets, which includes the no-bearer identity a local dev session starts
240
+ from — then one per declared journey.
241
+
242
+ Here rather than on either platform because several separate things have to
243
+ agree about this set on a deploy: the objects the bake writes, the IAM grant
244
+ that lets it write them, and the URLs `config.json` sends a caller to. A key
245
+ derived twice is a shop whose file is written where nothing fetches it, and the
246
+ symptom is an empty menu rather than a missing file.
247
+ */
248
+ let files = (
249
+ ~config: ReventlessInfra.Platform.bakedManifest,
250
+ ): array<(string, array<selection>)> =>
251
+ [
252
+ (config.key->Option.getOr(defaultKey), config.components->Array.map(toSelection)),
253
+ ]->Array.concat(journeyFiles(~config)->Array.map(j => (j.key, j.selections)))
254
+
255
+ /** Each declared journey's group and the URL a shell fetches its file from. */
256
+ let journeyUrls = (~config: ReventlessInfra.Platform.bakedManifest): array<(string, string)> =>
257
+ journeyFiles(~config)->Array.map(j => (j.group, urlForKey(Some(j.key))))
258
+
207
259
  // The whole file: one entry per selection, in the order the deployment declared
208
260
  // them, so the include-list also states the order a consumer reads plugins in.
209
261
  let curate = (
@@ -192,6 +192,40 @@ function journeyKey(group) {
192
192
  return `component-manifest-` + slug + `.json`;
193
193
  }
194
194
 
195
+ function toSelection(s) {
196
+ return {
197
+ plugin: s.plugin,
198
+ views: s.views,
199
+ commands: s.commands,
200
+ derived: s.derived
201
+ };
202
+ }
203
+
204
+ function journeyFiles(config) {
205
+ return Stdlib_Option.getOr(config.journeys, []).map(j => ({
206
+ group: j.group,
207
+ key: Stdlib_Option.getOr(j.key, journeyKey(j.group)),
208
+ selections: j.components.map(toSelection)
209
+ }));
210
+ }
211
+
212
+ function files(config) {
213
+ return [[
214
+ Stdlib_Option.getOr(config.key, defaultKey),
215
+ config.components.map(toSelection)
216
+ ]].concat(journeyFiles(config).map(j => [
217
+ j.key,
218
+ j.selections
219
+ ]));
220
+ }
221
+
222
+ function journeyUrls(config) {
223
+ return journeyFiles(config).map(j => [
224
+ j.group,
225
+ urlForKey(j.key)
226
+ ]);
227
+ }
228
+
195
229
  function curate(structures, selections) {
196
230
  return Stdlib_Result.map(Stdlib_Array.reduce(selections, {
197
231
  TAG: "Ok",
@@ -228,6 +262,10 @@ export {
228
262
  defaultKey,
229
263
  urlForKey,
230
264
  journeyKey,
265
+ toSelection,
266
+ journeyFiles,
267
+ files,
268
+ journeyUrls,
231
269
  curate,
232
270
  }
233
271
  /* No side effect */
@@ -29,7 +29,7 @@ let sdlTypes: array<string> = [
29
29
  // structures persisted before the fields existed decode as `None`, a hand-rolled
30
30
  // def may decline to state them, and a state whose key cannot be resolved has no
31
31
  // `idField` to report.
32
- `type Platform_ReadSideDef {\n name: String!\n queryField: String!\n schema: String!\n consumedEventTypes: [String!]!\n linkedWriteSide: [String!]!\n labelField: String!\n searchableFields: [String!]!\n labelFieldSource: String\n statusField: String\n visibility: String\n chapter: String\n singleQueryField: String\n idField: String\n idFieldSource: String\n requiredAccess: [String!]\n ownerField: String\n}`,
32
+ `type Platform_ReadSideDef {\n name: String!\n queryField: String!\n schema: String!\n consumedEventTypes: [String!]!\n linkedWriteSide: [String!]!\n labelField: String!\n searchableFields: [String!]!\n labelFieldSource: String\n lifecycleField: String\n visibility: String\n chapter: String\n singleQueryField: String\n idField: String\n idFieldSource: String\n requiredAccess: [String!]\n ownerField: String\n retiredField: String\n retiredValues: [String!]\n}`,
33
33
  `type Platform_AutomationSliceDef {\n name: String!\n consumedEventTypes: [String!]!\n producedCommandTypes: [String!]!\n targetName: String\n chapter: String\n}`,
34
34
  `type Platform_OutboundTranslationSliceDef {\n name: String!\n consumedEventTypes: [String!]!\n inboundCommandTypes: [String!]!\n targetName: String\n externalSystem: String\n chapter: String\n}`,
35
35
  `type Platform_InboundTranslationSliceDef {\n name: String!\n commandTypes: [String!]!\n targetName: String\n externalSystem: String\n chapter: String\n}`,
@@ -113,7 +113,7 @@ let encodeQueryableDef = (r: queryableDef): JSON.t =>
113
113
  "labelFieldSource",
114
114
  r.labelFieldSource->Option.mapOr(JSON.Encode.null, JSON.Encode.string),
115
115
  ),
116
- ("statusField", r.statusField->Option.mapOr(JSON.Encode.null, JSON.Encode.string)),
116
+ ("lifecycleField", r.lifecycleField->Option.mapOr(JSON.Encode.null, JSON.Encode.string)),
117
117
  // Carried rather than only filtered on: a tooling consumer reading the
118
118
  // unfiltered structure needs to know WHICH components are Internal, and a
119
119
  // consumer of the filtered query reads null here because nothing Internal
@@ -128,6 +128,8 @@ let encodeQueryableDef = (r: queryableDef): JSON.t =>
128
128
  ("idFieldSource", r.idFieldSource->Option.mapOr(JSON.Encode.null, JSON.Encode.string)),
129
129
  ("requiredAccess", r.requiredAccess->Option.mapOr(JSON.Encode.null, encodeStrings)),
130
130
  ("ownerField", r.ownerField->Option.mapOr(JSON.Encode.null, JSON.Encode.string)),
131
+ ("retiredField", r.retiredField->Option.mapOr(JSON.Encode.null, JSON.Encode.string)),
132
+ ("retiredValues", r.retiredValues->Option.mapOr(JSON.Encode.null, encodeStrings)),
131
133
  ])->JSON.Encode.object
132
134
 
133
135
  let encodeEventDef = (e: eventDef): JSON.t =>
@@ -10,7 +10,7 @@ let sdlTypes = [
10
10
  `type Platform_EventDef {\n name: String!\n schema: String!\n references: [Platform_FieldReference!]!\n}`,
11
11
  `type Platform_ErrorDef {\n name: String!\n schema: String!\n references: [Platform_FieldReference!]!\n}`,
12
12
  `type Platform_WriteSideDef {\n name: String!\n commands: [Platform_CommandDef!]!\n linkedViews: [String!]!\n consistencyRead: String\n producedEventTypes: [String!]!\n consumedEventTypes: [String!]!\n events: [Platform_EventDef!]!\n errors: [Platform_ErrorDef!]!\n chapter: String\n}`,
13
- `type Platform_ReadSideDef {\n name: String!\n queryField: String!\n schema: String!\n consumedEventTypes: [String!]!\n linkedWriteSide: [String!]!\n labelField: String!\n searchableFields: [String!]!\n labelFieldSource: String\n statusField: String\n visibility: String\n chapter: String\n singleQueryField: String\n idField: String\n idFieldSource: String\n requiredAccess: [String!]\n ownerField: String\n}`,
13
+ `type Platform_ReadSideDef {\n name: String!\n queryField: String!\n schema: String!\n consumedEventTypes: [String!]!\n linkedWriteSide: [String!]!\n labelField: String!\n searchableFields: [String!]!\n labelFieldSource: String\n lifecycleField: String\n visibility: String\n chapter: String\n singleQueryField: String\n idField: String\n idFieldSource: String\n requiredAccess: [String!]\n ownerField: String\n retiredField: String\n retiredValues: [String!]\n}`,
14
14
  `type Platform_AutomationSliceDef {\n name: String!\n consumedEventTypes: [String!]!\n producedCommandTypes: [String!]!\n targetName: String\n chapter: String\n}`,
15
15
  `type Platform_OutboundTranslationSliceDef {\n name: String!\n consumedEventTypes: [String!]!\n inboundCommandTypes: [String!]!\n targetName: String\n externalSystem: String\n chapter: String\n}`,
16
16
  `type Platform_InboundTranslationSliceDef {\n name: String!\n commandTypes: [String!]!\n targetName: String\n externalSystem: String\n chapter: String\n}`,
@@ -130,8 +130,8 @@ function encodeQueryableDef(r) {
130
130
  Stdlib_Option.mapOr(r.labelFieldSource, null, prim => prim)
131
131
  ],
132
132
  [
133
- "statusField",
134
- Stdlib_Option.mapOr(r.statusField, null, prim => prim)
133
+ "lifecycleField",
134
+ Stdlib_Option.mapOr(r.lifecycleField, null, prim => prim)
135
135
  ],
136
136
  [
137
137
  "visibility",
@@ -160,6 +160,14 @@ function encodeQueryableDef(r) {
160
160
  [
161
161
  "ownerField",
162
162
  Stdlib_Option.mapOr(r.ownerField, null, prim => prim)
163
+ ],
164
+ [
165
+ "retiredField",
166
+ Stdlib_Option.mapOr(r.retiredField, null, prim => prim)
167
+ ],
168
+ [
169
+ "retiredValues",
170
+ Stdlib_Option.mapOr(r.retiredValues, null, encodeStrings)
163
171
  ]
164
172
  ]);
165
173
  }
@@ -436,6 +436,19 @@ let deriveByIdsQueryField = (
436
436
  ): string =>
437
437
  ` ${listFieldName}ByIds(ids: [String!]!): [${returnTypeName}!]!`
438
438
 
439
+ // `includeRetired` sits beside the paging arguments rather than inside `filter`,
440
+ // and that placement is the point. `filter` is the caller's description of the
441
+ // rows they want; this is a request to lift a restriction the server placed on
442
+ // them, which the server grants or ignores on its own terms. Putting it in the
443
+ // filter input would also require the field to be a declared filter field, which
444
+ // would publish `<field>Eq` to callers who can only ever get an empty page from
445
+ // it.
446
+ //
447
+ // Emitted unconditionally, on every connection field, whether or not the view
448
+ // declares a retirement flag. A view that declares none ignores it, and the
449
+ // alternative — an argument that appears and disappears with the annotation —
450
+ // makes adding `@retired` a breaking schema change for every client that had
451
+ // already learned the field's shape.
439
452
  let deriveConnectionQueryField = (
440
453
  ~listFieldName: string,
441
454
  ~singularTypeName: string,
@@ -443,7 +456,7 @@ let deriveConnectionQueryField = (
443
456
  ~hasOrderBy: bool=false,
444
457
  ): string => {
445
458
  let orderByArg = hasOrderBy ? `, orderBy: ${singularTypeName}OrderBy` : ""
446
- ` ${listFieldName}(filter: ${filterTypeName}${orderByArg}, first: Int, after: String, last: Int, before: String): ${singularTypeName}Connection!`
459
+ ` ${listFieldName}(filter: ${filterTypeName}${orderByArg}, first: Int, after: String, last: Int, before: String, includeRetired: Boolean): ${singularTypeName}Connection!`
447
460
  }
448
461
 
449
462
  // ── Mutation field derivation ──────────────────────────────────────────────
@@ -374,7 +374,7 @@ function deriveByIdsQueryField(listFieldName, returnTypeName) {
374
374
  function deriveConnectionQueryField(listFieldName, singularTypeName, filterTypeName, hasOrderByOpt) {
375
375
  let hasOrderBy = hasOrderByOpt !== undefined ? hasOrderByOpt : false;
376
376
  let orderByArg = hasOrderBy ? `, orderBy: ` + singularTypeName + `OrderBy` : "";
377
- return ` ` + listFieldName + `(filter: ` + filterTypeName + orderByArg + `, first: Int, after: String, last: Int, before: String): ` + singularTypeName + `Connection!`;
377
+ return ` ` + listFieldName + `(filter: ` + filterTypeName + orderByArg + `, first: Int, after: String, last: Int, before: String, includeRetired: Boolean): ` + singularTypeName + `Connection!`;
378
378
  }
379
379
 
380
380
  function deriveMutationFieldFromObject(fieldName, collectedTypes, seenTypes, variantSchema) {
@@ -35,6 +35,17 @@ let getId = (item: JSON.t): string =>
35
35
  // String form of a field for comparison / cursor purposes: the string itself,
36
36
  // or a number rendered via Float.toString, else None. The push-down must render
37
37
  // the same string in SQL (CAST … AS TEXT) for cursor/order parity.
38
+ // A boolean field's value, or None when the row does not carry one. Separate
39
+ // from `getFieldString` rather than reusing it: JSON `true` stringifies to
40
+ // nothing useful, and a retirement predicate read off a coerced string would
41
+ // treat `"false"` — a legitimate value for a field someone stored as text — as
42
+ // truthy and hide the row.
43
+ let getFieldBool = (item: JSON.t, field: string): option<bool> =>
44
+ item
45
+ ->JSON.Decode.object
46
+ ->Option.flatMap(d => d->Dict.get(field))
47
+ ->Option.flatMap(JSON.Decode.bool)
48
+
38
49
  let getFieldString = (item: JSON.t, field: string): option<string> =>
39
50
  item
40
51
  ->JSON.Decode.object
@@ -97,6 +108,7 @@ let run = (
97
108
  ~labelField: string,
98
109
  ~decodeLocalId: string => option<string>=Api_Ids.toLocalId,
99
110
  ~ownerScope: option<(string, string)>=?,
111
+ ~retiredScope: option<Reventless.OwnerScope.retiredScope>=?,
100
112
  ): JSON.t => {
101
113
  let filterDict =
102
114
  argsDict->Dict.get("filter")->Option.flatMap(JSON.Decode.object)->Option.getOr(Dict.make())
@@ -185,7 +197,19 @@ let run = (
185
197
  getFieldString(item, field)->Option.mapOr(false, v => v == required)
186
198
  | None => true
187
199
  }
188
- passSearch && passPrefix && passIds && passPerField && passOwner
200
+ // The missing-field rule lives in `OwnerScope.isRetiredValue`, beside the two
201
+ // forms it has to answer for; the note on why it lands the opposite way from
202
+ // `passOwner` is there.
203
+ let passRetired = switch retiredScope {
204
+ | Some(scope) =>
205
+ !(
206
+ scope->Reventless.OwnerScope.isRetiredValue(
207
+ item->JSON.Decode.object->Option.flatMap(d => d->Dict.get(scope.field)),
208
+ )
209
+ )
210
+ | None => true
211
+ }
212
+ passSearch && passPrefix && passIds && passPerField && passOwner && passRetired
189
213
  })
190
214
 
191
215
  let orderByDict = argsDict->Dict.get("orderBy")->Option.flatMap(JSON.Decode.object)
@@ -5,6 +5,7 @@ import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
5
5
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
6
6
  import * as Stdlib_Nullable from "@rescript/runtime/lib/es6/Stdlib_Nullable.js";
7
7
  import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
8
+ import * as OwnerScope$Reventless from "@reventlessdev/reventless-spec/src/types/OwnerScope.res.mjs";
8
9
  import * as Api_Ids$ReventlessCore from "./Api_Ids.res.mjs";
9
10
 
10
11
  function encodeCursor(value) {
@@ -19,6 +20,10 @@ function getId(item) {
19
20
  return Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_JSON.Decode.object(item), d => d["id"]), Stdlib_JSON.Decode.string), "");
20
21
  }
21
22
 
23
+ function getFieldBool(item, field) {
24
+ return Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_JSON.Decode.object(item), d => d[field]), Stdlib_JSON.Decode.bool);
25
+ }
26
+
22
27
  function getFieldString(item, field) {
23
28
  return Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_JSON.Decode.object(item), d => d[field]), v => {
24
29
  let s = Stdlib_JSON.Decode.string(v);
@@ -48,7 +53,7 @@ function buildConnection(pageItems, hasNextPage, hasPreviousPage, cursorValueOf)
48
53
  };
49
54
  }
50
55
 
51
- function run(items, argsDict, capability, labelField, decodeLocalIdOpt, ownerScope) {
56
+ function run(items, argsDict, capability, labelField, decodeLocalIdOpt, ownerScope, retiredScope) {
52
57
  let decodeLocalId = decodeLocalIdOpt !== undefined ? decodeLocalIdOpt : Api_Ids$ReventlessCore.toLocalId;
53
58
  let filterDict = Stdlib_Option.getOr(Stdlib_Option.flatMap(argsDict["filter"], Stdlib_JSON.Decode.object), {});
54
59
  let search = Stdlib_Option.flatMap(filterDict["search"], Stdlib_JSON.Decode.string);
@@ -102,8 +107,9 @@ function run(items, argsDict, capability, labelField, decodeLocalIdOpt, ownerSco
102
107
  } else {
103
108
  passOwner = true;
104
109
  }
105
- if (passSearch && passPrefix && passIds && passPerField) {
106
- return passOwner;
110
+ let passRetired = retiredScope !== undefined ? !OwnerScope$Reventless.isRetiredValue(retiredScope, Stdlib_Option.flatMap(Stdlib_JSON.Decode.object(item), d => d[retiredScope.field])) : true;
111
+ if (passSearch && passPrefix && passIds && passPerField && passOwner) {
112
+ return passRetired;
107
113
  } else {
108
114
  return false;
109
115
  }
@@ -214,8 +220,9 @@ export {
214
220
  decodeCursor,
215
221
  defaultListPageSize,
216
222
  getId,
223
+ getFieldBool,
217
224
  getFieldString,
218
225
  buildConnection,
219
226
  run,
220
227
  }
221
- /* No side effect */
228
+ /* OwnerScope-Reventless Not a pure module */
@@ -101,6 +101,45 @@ let mergeAnnotations = (
101
101
  }
102
102
  | None => ()
103
103
  }
104
+ switch spec.retired {
105
+ | Some(r) if r.field === fieldName =>
106
+ // `x-reventless-retired: {label?, showWhenFalse, values?, value?}`. The
107
+ // label is omitted when empty, the way `x-reventless-metric` omits its own,
108
+ // so a consumer deriving one from the field name can tell "not stated" from
109
+ // "stated as empty". `showWhenFalse` always travels: it is a decision the
110
+ // annotation author made either way, and its default is not the consumer's
111
+ // to pick.
112
+ //
113
+ // `values` follows the same omit-rather-than-write-empty rule, and its
114
+ // absence is what says which form this is: absent ⇒ the row is retired when
115
+ // the field is `true`; present ⇒ retired when the field's value is in the
116
+ // set, and the field is the record's lifecycle.
117
+ //
118
+ // The singular `value` rides alongside for one release, and only where the
119
+ // set has exactly one member — there is no singular reading of two. It
120
+ // exists to close a window, not to support two shapes: a consumer pinned
121
+ // before the set degrades to nothing at all rather than to a missing badge.
122
+ // Enforcement never depended on it — the resolvers exclude retired rows
123
+ // whatever the consumer understands — so the whole of the lag is cosmetic.
124
+ // Drop it once no consumer predating the set can be reached.
125
+ let entries = [("showWhenFalse", JSON.Encode.bool(r.showWhenFalse))]
126
+ let entries = switch r.values {
127
+ | Some(vs) =>
128
+ let entries = Array.concat(
129
+ entries,
130
+ [("values", JSON.Encode.array(vs->Array.map(JSON.Encode.string)))],
131
+ )
132
+ switch vs {
133
+ | [only] => Array.concat(entries, [("value", JSON.Encode.string(only))])
134
+ | _ => entries
135
+ }
136
+ | None => entries
137
+ }
138
+ let entries =
139
+ r.label === "" ? entries : Array.concat([("label", JSON.Encode.string(r.label))], entries)
140
+ obj->Dict.set("x-reventless-retired", JSON.Encode.object(Dict.fromArray(entries)))
141
+ | _ => ()
142
+ }
104
143
  switch spec.metric->Array.find(((field, _)) => field === fieldName) {
105
144
  | Some((_, m)) =>
106
145
  // `x-reventless-metric: {aggregate, label}`. Omit an empty label so the
@@ -90,18 +90,49 @@ function mergeAnnotations(fieldSchema, fieldName, spec) {
90
90
  obj["x-reventless-semantic"] = semanticId;
91
91
  }
92
92
  }
93
+ let r = spec.retired;
94
+ if (r !== undefined && r.field === fieldName) {
95
+ let entries = [[
96
+ "showWhenFalse",
97
+ r.showWhenFalse
98
+ ]];
99
+ let vs = r.values;
100
+ let entries$1;
101
+ if (vs !== undefined) {
102
+ let entries$2 = entries.concat([[
103
+ "values",
104
+ vs.map(prim => prim)
105
+ ]]);
106
+ if (vs.length !== 1) {
107
+ entries$1 = entries$2;
108
+ } else {
109
+ let only = vs[0];
110
+ entries$1 = entries$2.concat([[
111
+ "value",
112
+ only
113
+ ]]);
114
+ }
115
+ } else {
116
+ entries$1 = entries;
117
+ }
118
+ let entries$3 = r.label === "" ? entries$1 : [[
119
+ "label",
120
+ r.label
121
+ ]].concat(entries$1);
122
+ obj["x-reventless-retired"] = Object.fromEntries(entries$3);
123
+ }
93
124
  let match$4 = spec.metric.find(param => param[0] === fieldName);
94
125
  if (match$4 !== undefined) {
95
126
  let m = match$4[1];
96
- let entries = [[
127
+ let entries$4 = [[
97
128
  "aggregate",
98
129
  m.aggregate
99
130
  ]];
100
- let entries$1 = m.label === "" ? entries : entries.concat([[
131
+ let entries$5 = m.label === "" ? entries$4 : entries$4.concat([[
101
132
  "label",
102
133
  m.label
103
134
  ]]);
104
- obj["x-reventless-metric"] = Object.fromEntries(entries$1);
135
+ obj["x-reventless-metric"] = Object.fromEntries(entries$5);
105
136
  }
106
137
  return obj;
107
138
  }
@@ -21,6 +21,52 @@ let toRelativePath: string => string = %raw(`function toRelativePath(moduleUrl)
21
21
  }
22
22
  }`)
23
23
 
24
+ // The tag of one compiled variant arm: `{TAG: "<Name>", …}` for a payload-bearing
25
+ // constructor, a bare string const for a payload-less one.
26
+ let variantTag = (variant: S.t<unknown>) =>
27
+ switch variant {
28
+ | S.Object({properties}) =>
29
+ switch properties->Dict.get("TAG") {
30
+ | Some(String({const: ?Some(tag)})) => Some(tag)
31
+ | _ => None
32
+ }
33
+ | S.String({const: ?Some(tag)}) => Some(tag)
34
+ | _ => None
35
+ }
36
+
37
+ /**
38
+ The event schema of a DCB event log: one union over every event its slices produce.
39
+
40
+ Flattened, not nested. Every reader of an `eventLogSchemaEntry` walks exactly one
41
+ level — `Union` → per-variant `Object` with a `TAG` const — so a union OF unions
42
+ would present each slice as an arm with no tag and read as a log carrying no
43
+ event types at all. Arms are deduped by tag because two slices producing the same
44
+ event would otherwise hand sury two arms with one discriminant.
45
+ */
46
+ let mergedEventSchema = (schemas: array<S.t<unknown>>) =>
47
+ switch schemas {
48
+ | [single] => single
49
+ | many =>
50
+ let seen = Set.make()
51
+ many
52
+ ->Array.flatMap(schema =>
53
+ switch schema {
54
+ | S.Union({anyOf}) => anyOf
55
+ | other => [other]
56
+ }
57
+ )
58
+ ->Array.filter(arm =>
59
+ switch arm->variantTag {
60
+ | Some(tag) if seen->Set.has(tag) => false
61
+ | Some(tag) =>
62
+ seen->Set.add(tag)
63
+ true
64
+ | None => true
65
+ }
66
+ )
67
+ ->S.union
68
+ }
69
+
24
70
  type dcbResult = {
25
71
  dcbEventLogOutputs: option<DcbEventLog.outputs>,
26
72
  stateChangeSlicesOutputs: dict<StateChangeSlice.outputs>,
@@ -1047,7 +1093,11 @@ module Make = (
1047
1093
  }
1048
1094
  })
1049
1095
 
1050
- // Collect all event schemas from produced events for eventLogEntries
1096
+ // Every event this plugin's slices produce lands in the one DCB event log,
1097
+ // so the log's schema entry is the union of all of them. Taking the first
1098
+ // slice's schema as representative left the readers of that entry — the
1099
+ // upload claimer's `CLAIM_REF_FIELDS`, MCP's event-history resource —
1100
+ // describing one slice and silently blind to the rest.
1051
1101
  let allProducedSchemas =
1052
1102
  stateChangeSlices->Array.map((module(Sc: StateChangeSlice.T)) =>
1053
1103
  Sc.Spec.eventSchema->S.castToUnknown
@@ -1102,12 +1152,11 @@ module Make = (
1102
1152
  ->Array.concat(outboundEntries)
1103
1153
  ->Array.concat(inboundEntries),
1104
1154
  eventLogEntries: if allProducedSchemas->Array.length > 0 {
1105
- // Use the first produced event schema as representative for the event log
1106
1155
  [
1107
1156
  {
1108
1157
  ReventlessInfra.Api.busKey: name ++ "DcbEventLog",
1109
1158
  displayName: name,
1110
- eventSchema: allProducedSchemas->Array.getUnsafe(0),
1159
+ eventSchema: allProducedSchemas->mergedEventSchema,
1111
1160
  },
1112
1161
  ]
1113
1162
  } else {