@reventlessdev/reventless-core 3.0.0-alpha.327 → 3.0.0-alpha.328

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 (35) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/package.json +6 -6
  3. package/src/CommandSent.res +22 -0
  4. package/src/CommandSent.res.mjs +22 -0
  5. package/src/Projection.res +26 -1
  6. package/src/Projection.res.mjs +19 -1
  7. package/src/RowChange.res +37 -0
  8. package/src/RowChange.res.mjs +62 -0
  9. package/src/components/Api/GraphQL_FragmentGenerator.res +22 -0
  10. package/src/components/Api/GraphQL_FragmentGenerator.res.mjs +20 -4
  11. package/src/components/Api/GraphQL_SchemaInspector.res.mjs +2 -2
  12. package/src/components/AutomationSlice/AutomationSlice_Callback.res +1 -0
  13. package/src/components/AutomationSlice/AutomationSlice_Callback.res.mjs +4 -2
  14. package/src/components/EventMapper/EventMapper_Callback.res +8 -2
  15. package/src/components/EventMapper/EventMapper_Callback.res.mjs +3 -2
  16. package/src/components/ExtensionPoint/ExtensionPoint_Callback.res +5 -1
  17. package/src/components/ExtensionPoint/ExtensionPoint_Callback.res.mjs +2 -1
  18. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res +4 -0
  19. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +3 -1
  20. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res +4 -0
  21. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res.mjs +4 -2
  22. package/src/components/QueryDb/QueryDb_Operations.res +2 -0
  23. package/src/components/QueryDb/QueryDb_Operations.res.mjs +3 -0
  24. package/src/components/Task/Task_Builder.res +5 -3
  25. package/src/components/Task/Task_Builder.res.mjs +2 -1
  26. package/src/plugin/component/Plugin_Callback.res +6 -2
  27. package/src/plugin/component/Plugin_Callback.res.mjs +3 -2
  28. package/src/util/Metrics.res +151 -16
  29. package/src/util/Metrics.res.mjs +123 -3
  30. package/tests/api/GraphQL_FragmentGeneratorTest.res.mjs +2 -2
  31. package/tests/api/IdentitySemanticTest.res.mjs +1 -1
  32. package/tests/querydb/RowChangeTest.res +87 -0
  33. package/tests/querydb/RowChangeTest.res.mjs +157 -0
  34. package/tests/util/MetricsTest.res +72 -0
  35. package/tests/util/MetricsTest.res.mjs +108 -0
package/CHANGELOG.md CHANGED
@@ -3,6 +3,16 @@
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.328 (2026-11-02)
7
+
8
+ ### Features
9
+
10
+ * a view row knows its last change, and the local platform keeps every change ([1a1fd71](https://github.com/ReventlessDev/reventless-core/commit/1a1fd7117d9837696a7c0080dcd6f0983e57780c))
11
+ * every component that sends a command names it in a line of its own ([84d5742](https://github.com/ReventlessDev/reventless-core/commit/84d57420fe58d47f483e726d1748b1a98da7f1b8))
12
+ * **local:** the app's API logs each request and subscription it answers ([31a163c](https://github.com/ReventlessDev/reventless-core/commit/31a163c945d8929e9a604cc0dc8a74939320f85e))
13
+ * **local:** the local platform counts its metrics instead of logging them ([76c6094](https://github.com/ReventlessDev/reventless-core/commit/76c60946fa74520519dccb4ae39fae5880817832))
14
+
15
+
6
16
  # 3.0.0-alpha.327 (2026-11-01)
7
17
 
8
18
  ### Features
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reventlessdev/reventless-core",
3
- "version": "3.0.0-alpha.327",
3
+ "version": "3.0.0-alpha.328",
4
4
  "description": "Core package for Reventless framework",
5
5
  "license": "Apache-2.0",
6
6
  "jest": {
@@ -28,17 +28,17 @@
28
28
  "dependencies": {
29
29
  "sury": "11.0.0",
30
30
  "uuid": "^13.0.0",
31
- "@reventlessdev/rescript-fast-csv": "2.0.0-alpha.25",
32
31
  "@reventlessdev/rescript-effect": "1.0.0-alpha.1",
33
32
  "@reventlessdev/rescript-hash-object": "1.2.0-alpha.15",
33
+ "@reventlessdev/rescript-fast-csv": "2.0.0-alpha.26",
34
34
  "@reventlessdev/rescript-jest": "1.0.0-alpha.13",
35
- "@reventlessdev/rescript-node": "2.0.0-alpha.25",
35
+ "@reventlessdev/rescript-node": "2.0.0-alpha.26",
36
36
  "@reventlessdev/rescript-pulumi-pulumi": "3.0.0-alpha.0",
37
- "@reventlessdev/rescript-ssh2": "2.0.0-alpha.26",
38
37
  "@reventlessdev/rescript-uuid": "2.0.0-alpha.1",
39
38
  "@reventlessdev/reventless-interop": "3.0.0-alpha.42",
40
- "@reventlessdev/reventless-spec": "3.0.0-alpha.192",
41
- "@reventlessdev/reventless-infra": "3.0.0-alpha.221"
39
+ "@reventlessdev/reventless-infra": "3.0.0-alpha.222",
40
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.193",
41
+ "@reventlessdev/rescript-ssh2": "2.0.0-alpha.27"
42
42
  },
43
43
  "devDependencies": {
44
44
  "rescript": "12.3.1",
@@ -0,0 +1,22 @@
1
+ // The line a component writes when it sends a command, under its own name and with the
2
+ // command's ids: `AutomationSlice(NotificationIntake) sending command: RequestNotification({…})`.
3
+ // The plugin's command topic publishes for every sender alike and cannot say whose a command
4
+ // is; this line does, as the API's `generated command` and a contract's `EP→` line do.
5
+
6
+ let log = (~comp: string, cmdJson: Message.commandJson) =>
7
+ EffectLogger.logInfo(
8
+ ~comp,
9
+ ~ids=EffectLogger.idsOf(cmdJson.meta),
10
+ ~detail=cmdJson.commandJson,
11
+ `sending command: ${LogFormat.cmdDetailNoId(cmdJson)}`,
12
+ )->Effect.runSync
13
+
14
+ /** The same publishing, each command announced first under `comp`. */
15
+ let announcing = (
16
+ ~comp: string,
17
+ publishJsons: ReventlessInfra.CommandTopic.publishJsons,
18
+ ): ReventlessInfra.CommandTopic.publishJsons =>
19
+ cmdJsons => {
20
+ cmdJsons->Array.forEach(cmdJson => log(~comp, cmdJson))
21
+ publishJsons(cmdJsons)
22
+ }
@@ -0,0 +1,22 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Effect from "effect/Effect";
4
+ import * as LogFormat$ReventlessCore from "./util/LogFormat.res.mjs";
5
+ import * as EffectLogger$ReventlessCore from "./util/EffectLogger.res.mjs";
6
+
7
+ function log(comp, cmdJson) {
8
+ Effect.runSync(EffectLogger$ReventlessCore.logInfo(comp, cmdJson.commandJson, EffectLogger$ReventlessCore.idsOf(undefined, undefined, cmdJson.meta), `sending command: ` + LogFormat$ReventlessCore.cmdDetailNoId(cmdJson)));
9
+ }
10
+
11
+ function announcing(comp, publishJsons) {
12
+ return cmdJsons => {
13
+ cmdJsons.forEach(cmdJson => log(comp, cmdJson));
14
+ return publishJsons(cmdJsons);
15
+ };
16
+ }
17
+
18
+ export {
19
+ log,
20
+ announcing,
21
+ }
22
+ /* effect/Effect Not a pure module */
@@ -303,7 +303,7 @@ let stateToString: 'a => string = state =>
303
303
  let statesToString: array<'a> => string = states =>
304
304
  states->Array.map(stateToString)->Array.joinUnsafe(", ")
305
305
 
306
- let handleAction = async (
306
+ let applyAction = async (
307
307
  ~comp="Projection",
308
308
  ~sources: array<changeSource>=[],
309
309
  ~onChange: option<rowChange<'state> => unit>=?,
@@ -491,6 +491,31 @@ let handleAction = async (
491
491
  }
492
492
  }
493
493
 
494
+ /** Applies one action to the store, its rows stamped with the last of its sources as their
495
+ `_change` ([RowChange]). Without a source the rows are written unstamped. */
496
+ let handleAction = (
497
+ ~comp="Projection",
498
+ ~sources: array<changeSource>=[],
499
+ ~onChange: option<rowChange<'state> => unit>=?,
500
+ action,
501
+ operations,
502
+ subIdConfig,
503
+ ) => {
504
+ let apply = () => applyAction(~comp, ~sources, ~onChange?, action, operations, subIdConfig)
505
+ switch sources->Array.at(-1) {
506
+ | Some(s) =>
507
+ RowChange.during(
508
+ {
509
+ flow: ?s.correlationId,
510
+ msgId: s.msgId,
511
+ at: Date.make()->Date.toISOString,
512
+ },
513
+ apply,
514
+ )
515
+ | None => apply()
516
+ }
517
+ }
518
+
494
519
  let actionsWithId = action =>
495
520
  switch action {
496
521
  | Ignore => []
@@ -20,6 +20,7 @@ import * as Message$ReventlessCore from "./Message.res.mjs";
20
20
  import * as QueryDb$ReventlessCore from "./components/QueryDb/QueryDb.res.mjs";
21
21
  import * as QueryDb$ReventlessInfra from "@reventlessdev/reventless-infra/src/components/QueryDb.res.mjs";
22
22
  import * as LogFormat$ReventlessCore from "./util/LogFormat.res.mjs";
23
+ import * as RowChange$ReventlessCore from "./RowChange.res.mjs";
23
24
 
24
25
  let log = Logger$ReventlessCore.fromEnv();
25
26
 
@@ -289,7 +290,7 @@ function statesToString(states) {
289
290
  return states.map(stateToString).join(", ");
290
291
  }
291
292
 
292
- async function handleAction($staropt$star, $staropt$star$1, onChange, action, operations, subIdConfig) {
293
+ async function applyAction($staropt$star, $staropt$star$1, onChange, action, operations, subIdConfig) {
293
294
  let saveBatch = operations.saveBatch;
294
295
  let save = operations.save;
295
296
  let loadStream = operations.loadStream;
@@ -512,6 +513,22 @@ async function handleAction($staropt$star, $staropt$star$1, onChange, action, op
512
513
  }
513
514
  }
514
515
 
516
+ function handleAction(compOpt, sourcesOpt, onChange, action, operations, subIdConfig) {
517
+ let comp = compOpt !== undefined ? compOpt : "Projection";
518
+ let sources = sourcesOpt !== undefined ? sourcesOpt : [];
519
+ let apply = () => applyAction(comp, sources, onChange, action, operations, subIdConfig);
520
+ let s = sources.at(-1);
521
+ if (s !== undefined) {
522
+ return RowChange$ReventlessCore.during({
523
+ flow: s.correlationId,
524
+ msgId: s.msgId,
525
+ at: new Date().toISOString()
526
+ }, apply);
527
+ } else {
528
+ return apply();
529
+ }
530
+ }
531
+
515
532
  function actionsWithId(action) {
516
533
  if (typeof action !== "object") {
517
534
  return [];
@@ -896,6 +913,7 @@ export {
896
913
  applyChanges,
897
914
  stateToString,
898
915
  statesToString,
916
+ applyAction,
899
917
  handleAction,
900
918
  actionsWithId,
901
919
  groupSourcedById,
@@ -0,0 +1,37 @@
1
+ // The change a projection is writing, stamped on the rows it writes as `_change`: the flow,
2
+ // the event and the time. A projection runs each action `during` its change; the encoder
3
+ // that turns a row into JSON reads it back with `stampInto`. The value follows the call
4
+ // and what it awaits, so rows written at the same time each get their own.
5
+
6
+ /** The last change of a row: its flow, the event behind it, and when it was written. */
7
+ type t = {flow?: string, msgId: string, at: string}
8
+
9
+ /** The key a row carries it under; no state field may use it. */
10
+ let key = "_change"
11
+
12
+ let storage: NodeAsyncHooks.asyncLocalStorage<t> = NodeAsyncHooks.makeAsyncLocalStorage()
13
+
14
+ /** Runs `f` with `change` as the change its writes stamp. */
15
+ let during = (change: t, f: unit => 'a): 'a => storage->NodeAsyncHooks.run(change, f)
16
+
17
+ /** The change being written, outside a projection none. */
18
+ let current = (): option<t> => storage->NodeAsyncHooks.getStore
19
+
20
+ let toJson = (c: t): JSON.t =>
21
+ [("msgId", JSON.Encode.string(c.msgId)), ("at", JSON.Encode.string(c.at))]
22
+ ->Array.concat(c.flow->Option.mapOr([], f => [("flow", JSON.Encode.string(f))]))
23
+ ->Dict.fromArray
24
+ ->JSON.Encode.object
25
+
26
+ /** Adds the current change to a row about to be stored. */
27
+ let stampInto = (row: dict<JSON.t>) => current()->Option.forEach(c => row->Dict.set(key, toJson(c)))
28
+
29
+ /** The same for a row as JSON; a value that is not an object is left as it is. */
30
+ let stamp = (row: JSON.t): JSON.t =>
31
+ switch (current(), row) {
32
+ | (Some(c), JSON.Object(d)) =>
33
+ let d = d->Dict.copy
34
+ d->Dict.set(key, toJson(c))
35
+ JSON.Object(d)
36
+ | _ => row
37
+ }
@@ -0,0 +1,62 @@
1
+ // Generated by ReScript, PLEASE EDIT WITH CARE
2
+
3
+ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
4
+ import * as Nodeasync_hooks from "node:async_hooks";
5
+
6
+ let key = "_change";
7
+
8
+ let storage = new Nodeasync_hooks.AsyncLocalStorage();
9
+
10
+ function during(change, f) {
11
+ return storage.run(change, f);
12
+ }
13
+
14
+ function current() {
15
+ return storage.getStore();
16
+ }
17
+
18
+ function toJson(c) {
19
+ return Object.fromEntries([
20
+ [
21
+ "msgId",
22
+ c.msgId
23
+ ],
24
+ [
25
+ "at",
26
+ c.at
27
+ ]
28
+ ].concat(Stdlib_Option.mapOr(c.flow, [], f => [[
29
+ "flow",
30
+ f
31
+ ]])));
32
+ }
33
+
34
+ function stampInto(row) {
35
+ Stdlib_Option.forEach(storage.getStore(), c => {
36
+ row[key] = toJson(c);
37
+ });
38
+ }
39
+
40
+ function stamp(row) {
41
+ let match = storage.getStore();
42
+ if (match === undefined) {
43
+ return row;
44
+ }
45
+ if (typeof row !== "object" || row === null || Array.isArray(row)) {
46
+ return row;
47
+ }
48
+ let d = Object.assign({}, row);
49
+ d[key] = toJson(match);
50
+ return d;
51
+ }
52
+
53
+ export {
54
+ key,
55
+ storage,
56
+ during,
57
+ current,
58
+ toJson,
59
+ stampInto,
60
+ stamp,
61
+ }
62
+ /* storage Not a pure module */
@@ -38,6 +38,15 @@ let commandResultSdlTypes: array<string> = [
38
38
  }`,
39
39
  ]
40
40
 
41
+ // The last change a view row was written by: its flow, the event behind it and the time
42
+ // (`RowChange`). Every view type carries it as `_change`, answered to elevated callers only;
43
+ // emitted once per fragment that has a view, deduped by name like the command results.
44
+ let rowChangeSdlType = `type RowChange {
45
+ flow: String
46
+ msgId: String!
47
+ at: String!
48
+ }`
49
+
41
50
  // ── SchemaType → GraphQL type reference ──────────────────────────────────────
42
51
 
43
52
  let rec fromSchemaType = (
@@ -196,6 +205,7 @@ let deriveObjectTypeWithNested = (
196
205
  ~excludeFields: array<string>=[],
197
206
  ~includeIdParam: bool=true,
198
207
  ~resolvedFields: array<resolvedFieldEntry>=[],
208
+ ~rowChange: bool=false,
199
209
  schema: S.t<unknown>,
200
210
  ): array<string> => {
201
211
  reportUnclassifiedUnions(~typeName, schema)
@@ -241,6 +251,14 @@ let deriveObjectTypeWithNested = (
241
251
  } else {
242
252
  mainType
243
253
  }
254
+ if rowChange && filteredFields->Dict.get(RowChange.key)->Option.isSome {
255
+ JsError.throwWithMessage(
256
+ `${typeName}.${RowChange.key} is a field of the state record, and every view row carries its last change under that name. Name the field something else.`,
257
+ )
258
+ }
259
+ let mainTypeWithId = rowChange
260
+ ? mainTypeWithId->String.replace("{\n", `{\n ${RowChange.key}: RowChange\n`)
261
+ : mainTypeWithId
244
262
  // A cross-table field shares the type with the state record's own fields, so
245
263
  // a name already taken would emit the field twice and fail the whole document
246
264
  // — for every plugin in the merge, not just this one. Refuse at build time,
@@ -935,6 +953,7 @@ let generate = (
935
953
  ~excludeFields,
936
954
  ~includeIdParam,
937
955
  ~resolvedFields=entry.resolvedFields->Option.getOr([]),
956
+ ~rowChange=true,
938
957
  entry.stateSchema,
939
958
  )
940
959
  nestedTypes->Array.forEach(t => {
@@ -1080,6 +1099,9 @@ let generate = (
1080
1099
  if mutations->Array.length > 0 {
1081
1100
  commandResultSdlTypes->Array.forEach(t => types->Array.push(t))
1082
1101
  }
1102
+ if queryEntries->Array.length > 0 {
1103
+ types->Array.push(rowChangeSdlType)
1104
+ }
1083
1105
 
1084
1106
  GraphQL_Stitcher.encode({
1085
1107
  types,
@@ -8,6 +8,7 @@ import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js
8
8
  import * as Semantic$Reventless from "@reventlessdev/reventless-spec/src/semantic/Semantic.res.mjs";
9
9
  import * as ReadModel$Reventless from "@reventlessdev/reventless-spec/src/components/ReadModel.res.mjs";
10
10
  import * as Logger$ReventlessCore from "../../util/Logger.res.mjs";
11
+ import * as RowChange$ReventlessCore from "../../RowChange.res.mjs";
11
12
  import * as Api_Naming$ReventlessCore from "./Api_Naming.res.mjs";
12
13
  import * as SchemaType$ReventlessCore from "./SchemaType.res.mjs";
13
14
  import * as SchemaWalker$ReventlessCore from "../../plugin/component/SchemaWalker.res.mjs";
@@ -39,6 +40,12 @@ let commandResultSdlTypes = [
39
40
  }`
40
41
  ];
41
42
 
43
+ let rowChangeSdlType = `type RowChange {
44
+ flow: String
45
+ msgId: String!
46
+ at: String!
47
+ }`;
48
+
42
49
  function fromSchemaType(_required, _asInputOpt, _st, collectedTypes, seenTypes) {
43
50
  while (true) {
44
51
  let asInputOpt = _asInputOpt;
@@ -156,10 +163,11 @@ function resolvedFieldSdl(param) {
156
163
  }
157
164
  }
158
165
 
159
- function deriveObjectTypeWithNested(typeName, excludeFieldsOpt, includeIdParamOpt, resolvedFieldsOpt, schema) {
166
+ function deriveObjectTypeWithNested(typeName, excludeFieldsOpt, includeIdParamOpt, resolvedFieldsOpt, rowChangeOpt, schema) {
160
167
  let excludeFields = excludeFieldsOpt !== undefined ? excludeFieldsOpt : [];
161
168
  let includeIdParam = includeIdParamOpt !== undefined ? includeIdParamOpt : true;
162
169
  let resolvedFields = resolvedFieldsOpt !== undefined ? resolvedFieldsOpt : [];
170
+ let rowChange = rowChangeOpt !== undefined ? rowChangeOpt : false;
163
171
  reportUnclassifiedUnions(typeName, schema);
164
172
  let fields = SchemaType$ReventlessCore.fromSuryObject(typeName, schema);
165
173
  if (fields === undefined) {
@@ -186,6 +194,10 @@ function deriveObjectTypeWithNested(typeName, excludeFieldsOpt, includeIdParamOp
186
194
  seenTypes.add(typeName);
187
195
  let mainType = objectRefToGraphQL(undefined, typeName, filteredFields, collectedTypes, seenTypes);
188
196
  let mainTypeWithId = includeIdParam ? mainType.replace(`type ` + typeName + ` {\n`, `type ` + typeName + ` implements Node {\n id: ID!\n`) : mainType;
197
+ if (rowChange && Stdlib_Option.isSome(filteredFields[RowChange$ReventlessCore.key])) {
198
+ Stdlib_JsError.throwWithMessage(typeName + `.` + RowChange$ReventlessCore.key + ` is a field of the state record, and every view row carries its last change under that name. Name the field something else.`);
199
+ }
200
+ let mainTypeWithId$1 = rowChange ? mainTypeWithId.replace("{\n", `{\n ` + RowChange$ReventlessCore.key + `: RowChange\n`) : mainTypeWithId;
189
201
  resolvedFields.forEach(param => {
190
202
  let fieldName = param.fieldName;
191
203
  if (Stdlib_Option.isSome(filteredFields[fieldName]) || includeIdParam && fieldName === "id") {
@@ -194,9 +206,9 @@ function deriveObjectTypeWithNested(typeName, excludeFieldsOpt, includeIdParamOp
194
206
  });
195
207
  let mainTypeComplete;
196
208
  if (resolvedFields.length === 0) {
197
- mainTypeComplete = mainTypeWithId;
209
+ mainTypeComplete = mainTypeWithId$1;
198
210
  } else {
199
- let body = mainTypeWithId.slice(0, mainTypeWithId.length - 1 | 0);
211
+ let body = mainTypeWithId$1.slice(0, mainTypeWithId$1.length - 1 | 0);
200
212
  mainTypeComplete = body + resolvedFields.map(resolvedFieldSdl).join("\n") + "\n}";
201
213
  }
202
214
  return collectedTypes.concat([mainTypeComplete]);
@@ -624,7 +636,7 @@ function generate(mutationEntries, queryEntries) {
624
636
  seenTypes.add(entry.returnTypeName);
625
637
  let fields = entry.excludeFields;
626
638
  let excludeFields = fields !== undefined ? fields : [];
627
- let nestedTypes = deriveObjectTypeWithNested(entry.returnTypeName, excludeFields, includeIdParam, Stdlib_Option.getOr(entry.resolvedFields, []), entry.stateSchema);
639
+ let nestedTypes = deriveObjectTypeWithNested(entry.returnTypeName, excludeFields, includeIdParam, Stdlib_Option.getOr(entry.resolvedFields, []), true, entry.stateSchema);
628
640
  nestedTypes.forEach(t => {
629
641
  types.push(t);
630
642
  });
@@ -703,6 +715,9 @@ function generate(mutationEntries, queryEntries) {
703
715
  types.push(t);
704
716
  });
705
717
  }
718
+ if (queryEntries.length !== 0) {
719
+ types.push(rowChangeSdlType);
720
+ }
706
721
  return GraphQL_Stitcher$ReventlessCore.encode({
707
722
  types: types,
708
723
  mutations: mutations,
@@ -715,6 +730,7 @@ function generate(mutationEntries, queryEntries) {
715
730
  export {
716
731
  log,
717
732
  commandResultSdlTypes,
733
+ rowChangeSdlType,
718
734
  fromSchemaType,
719
735
  objectRefToGraphQL,
720
736
  deriveFieldType,
@@ -13,7 +13,7 @@ function inspectScalar(schema) {
13
13
  }
14
14
 
15
15
  function inspectObjectType(typeName, schema) {
16
- let types = GraphQL_FragmentGenerator$ReventlessCore.deriveObjectTypeWithNested(typeName, undefined, undefined, undefined, schema);
16
+ let types = GraphQL_FragmentGenerator$ReventlessCore.deriveObjectTypeWithNested(typeName, undefined, undefined, undefined, undefined, schema);
17
17
  return types[types.length - 1 | 0];
18
18
  }
19
19
 
@@ -42,7 +42,7 @@ function inspectMutationFields(fieldPrefix, commandSchema) {
42
42
  }
43
43
 
44
44
  function inspectQueryFields(name, typeName, stateSchema) {
45
- let types = GraphQL_FragmentGenerator$ReventlessCore.deriveObjectTypeWithNested(typeName, undefined, undefined, undefined, stateSchema);
45
+ let types = GraphQL_FragmentGenerator$ReventlessCore.deriveObjectTypeWithNested(typeName, undefined, undefined, undefined, undefined, stateSchema);
46
46
  let typeDef = types[types.length - 1 | 0];
47
47
  let singleQuery = GraphQL_FragmentGenerator$ReventlessCore.deriveObjectQueryField(name, typeName, undefined, undefined);
48
48
  let pluralName = name + "s";
@@ -462,6 +462,7 @@ module Make = (
462
462
  }
463
463
 
464
464
  let phase2 = async (publishJsons: ReventlessInfra.CommandTopic.publishJsons) => {
465
+ let publishJsons = CommandSent.announcing(~comp=`AutomationSlice(${Spec.name})`, publishJsons)
465
466
  let currentTime = await Clock.currentTimeMillis->Effect.runPromise
466
467
  // A `Failed` row at or past the ceiling is one an older build left stranded,
467
468
  // or one whose Spec lowered `maxRetries` under it. Either way it is abandoned
@@ -15,6 +15,7 @@ import * as Message$Reventless from "@reventlessdev/reventless-spec/src/types/Me
15
15
  import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
16
16
  import * as Util_Sury$Reventless from "@reventlessdev/reventless-spec/src/util/Util_Sury.res.mjs";
17
17
  import * as Message$ReventlessCore from "../../Message.res.mjs";
18
+ import * as CommandSent$ReventlessCore from "../../CommandSent.res.mjs";
18
19
  import * as EffectLogger$ReventlessCore from "../../util/EffectLogger.res.mjs";
19
20
  import * as AutomationSlice_Route$ReventlessCore from "./AutomationSlice_Route.res.mjs";
20
21
  import * as AutomationSlice_Schedules$ReventlessCore from "./AutomationSlice_Schedules.res.mjs";
@@ -326,6 +327,7 @@ function Make(Spec) {
326
327
  scheduleChanges.contents = [];
327
328
  };
328
329
  let phase2 = async publishJsons => {
330
+ let publishJsons$1 = CommandSent$ReventlessCore.announcing(`AutomationSlice(` + Spec.name + `)`, publishJsons);
329
331
  let currentTime = await Effect.runPromise(Clock.currentTimeMillis);
330
332
  let newlyAbandoned = [];
331
333
  Object.entries(todoItems).forEach(param => {
@@ -424,7 +426,7 @@ function Make(Spec) {
424
426
  }
425
427
  if (commands.length !== 0) {
426
428
  try {
427
- await publishJsons(commands);
429
+ await publishJsons$1(commands);
428
430
  } catch (raw_exn$1) {
429
431
  let exn$1 = Primitive_exceptions.internalToException(raw_exn$1);
430
432
  let errMsg$1 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$1), Stdlib_JsExn.message), "unknown");
@@ -462,7 +464,7 @@ function Make(Spec) {
462
464
  return;
463
465
  }
464
466
  try {
465
- return await publishJsons(abandonmentCommands);
467
+ return await publishJsons$1(abandonmentCommands);
466
468
  } catch (raw_exn$2) {
467
469
  let exn$2 = Primitive_exceptions.internalToException(raw_exn$2);
468
470
  let errMsg$2 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$2), Stdlib_JsExn.message), "unknown");
@@ -236,7 +236,10 @@ module MakeCounterHandler = (
236
236
  )
237
237
  ->Effect.flatMap(((publisherEntries, _)) =>
238
238
  Effect.promise(() => publisherEntries)->Effect.flatMap(
239
- entries => Effect.promise(() => Ops.publishJsons(entries)),
239
+ entries =>
240
+ Effect.promise(
241
+ () => CommandSent.announcing(~comp="EventMapper", Ops.publishJsons)(entries),
242
+ ),
240
243
  )
241
244
  )
242
245
  )
@@ -334,7 +337,10 @@ module MakeEventCollectorHandler = (Ops: EventCollectorOps): EventCollectorHandl
334
337
  ->Effect.flatMap(
335
338
  _ =>
336
339
  Effect.promise(() => publisherEntries)->Effect.flatMap(
337
- entries => Effect.promise(() => Ops.publishJsons(entries)),
340
+ entries =>
341
+ Effect.promise(
342
+ () => CommandSent.announcing(~comp="EventMapper", Ops.publishJsons)(entries),
343
+ ),
338
344
  ),
339
345
  )
340
346
  })
@@ -16,6 +16,7 @@ import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_excep
16
16
  import * as Message$ReventlessCore from "../../Message.res.mjs";
17
17
  import * as LogFormat$ReventlessCore from "../../util/LogFormat.res.mjs";
18
18
  import * as Util_Error$ReventlessCore from "../../util/Util_Error.res.mjs";
19
+ import * as CommandSent$ReventlessCore from "../../CommandSent.res.mjs";
19
20
  import * as EffectLogger$ReventlessCore from "../../util/EffectLogger.res.mjs";
20
21
 
21
22
  function MakeCounterHandler(Target) {
@@ -183,7 +184,7 @@ function MakeCounterHandler(Target) {
183
184
  }
184
185
  }), param => {
185
186
  let publisherEntries = param[0];
186
- return Effect$1.flatMap(Effect$1.promise(() => publisherEntries), entries => Effect$1.promise(() => Ops.publishJsons(entries)));
187
+ return Effect$1.flatMap(Effect$1.promise(() => publisherEntries), entries => Effect$1.promise(() => CommandSent$ReventlessCore.announcing("EventMapper", Ops.publishJsons)(entries)));
187
188
  }));
188
189
  return {
189
190
  commonEventsHandler: commonEventsHandler,
@@ -218,7 +219,7 @@ function MakeEventCollectorHandler(Ops) {
218
219
  return Primitive_option.some(Effect$1.promise(() => Ops.addToCounterTarget(counterTarget)));
219
220
  }), {
220
221
  concurrency: "unbounded"
221
- }), param => {})), () => Effect$1.flatMap(Effect$1.promise(() => publisherEntries), entries => Effect$1.promise(() => Ops.publishJsons(entries))));
222
+ }), param => {})), () => Effect$1.flatMap(Effect$1.promise(() => publisherEntries), entries => Effect$1.promise(() => CommandSent$ReventlessCore.announcing("EventMapper", Ops.publishJsons)(entries))));
222
223
  }));
223
224
  return {
224
225
  handleJsonEvents: handleJsonEvents
@@ -59,7 +59,11 @@ module Make = (
59
59
  let result =
60
60
  Spec.publishToAggregates
61
61
  ->Dict.get(aggregateName)
62
- ->Option.map((publishJsons: CommandTopic.publishJsons) => publishJsons([cmdJson]))
62
+ ->Option.map((publishJsons: CommandTopic.publishJsons) =>
63
+ CommandSent.announcing(~comp=`ExtensionPoint(${MappingSpec.name})`, publishJsons)([
64
+ cmdJson,
65
+ ])
66
+ )
63
67
  ->Option.mapOr(
64
68
  () =>
65
69
  JsError.throwWithMessage(
@@ -6,6 +6,7 @@ import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
6
6
  import * as Effect$1 from "effect/Effect";
7
7
  import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
8
8
  import * as Util_Error$ReventlessCore from "../../util/Util_Error.res.mjs";
9
+ import * as CommandSent$ReventlessCore from "../../CommandSent.res.mjs";
9
10
  import * as ScheduleOps$ReventlessCore from "../../util/ScheduleOps.res.mjs";
10
11
  import * as EffectLogger$ReventlessCore from "../../util/EffectLogger.res.mjs";
11
12
 
@@ -27,7 +28,7 @@ function Make(Spec) {
27
28
  `ExtensionPoint: Error on publish command: ` + errMsg
28
29
  ];
29
30
  }, () => {
30
- let result = Stdlib_Option.mapOr(Stdlib_Option.map(Spec.publishToAggregates[aggregateName], publishJsons => publishJsons([cmdJson])), () => Stdlib_JsError.throwWithMessage(`ExtensionPoint.applyCommandAction: Aggregate ` + aggregateName + ` doesn't exist`), x => (() => x));
31
+ let result = Stdlib_Option.mapOr(Stdlib_Option.map(Spec.publishToAggregates[aggregateName], publishJsons => CommandSent$ReventlessCore.announcing(`ExtensionPoint(` + MappingSpec.name + `)`, publishJsons)([cmdJson])), () => Stdlib_JsError.throwWithMessage(`ExtensionPoint.applyCommandAction: Aggregate ` + aggregateName + ` doesn't exist`), x => (() => x));
31
32
  result();
32
33
  return {
33
34
  TAG: "Ok",
@@ -241,6 +241,10 @@ module Make = (
241
241
  ~caller: option<Reventless.Identity.t>=?,
242
242
  ~door: ReventlessInfra.InboundTranslationSlice.door=Mutation,
243
243
  ): ReventlessInfra.InboundTranslationSlice.receiveResult => {
244
+ let publishJsons = CommandSent.announcing(
245
+ ~comp=`InboundTranslationSlice(${Spec.name})`,
246
+ publishJsons,
247
+ )
244
248
  let requestId = Uuid.v4()
245
249
  let callerId = caller->Option.map(identity => identity.userId)
246
250
  let fail = (~errorCode=?, error) =>
@@ -19,6 +19,7 @@ import * as OwnerScope$Reventless from "@reventlessdev/reventless-spec/src/types
19
19
  import * as Message$ReventlessCore from "../../Message.res.mjs";
20
20
  import * as Authorization$Reventless from "@reventlessdev/reventless-spec/src/types/Authorization.res.mjs";
21
21
  import * as CommandOutcome$Reventless from "@reventlessdev/reventless-spec/src/components/CommandOutcome.res.mjs";
22
+ import * as CommandSent$ReventlessCore from "../../CommandSent.res.mjs";
22
23
  import * as EffectLogger$ReventlessCore from "../../util/EffectLogger.res.mjs";
23
24
  import * as ApiNoApiHelpers$ReventlessCore from "../Api/ApiNoApiHelpers.res.mjs";
24
25
  import * as InboundTranslationSlice$ReventlessInfra from "@reventlessdev/reventless-infra/src/components/InboundTranslationSlice.res.mjs";
@@ -192,6 +193,7 @@ function Make(Spec) {
192
193
  };
193
194
  let receive = async (publishJsons, inputJson, capabilities, caller, doorOpt) => {
194
195
  let door = doorOpt !== undefined ? doorOpt : "Mutation";
196
+ let publishJsons$1 = CommandSent$ReventlessCore.announcing(`InboundTranslationSlice(` + Spec.name + `)`, publishJsons);
195
197
  let requestId = Uuid.v4();
196
198
  let callerId = Stdlib_Option.map(caller, identity => identity.userId);
197
199
  let fail = (errorCode, error) => failWith(requestId, JSON.stringify(redactInput(inputJson, sensitive)), door, callerId, errorCode, error);
@@ -277,7 +279,7 @@ function Make(Spec) {
277
279
  return succeed([]);
278
280
  }
279
281
  try {
280
- await publishJsons(msgs);
282
+ await publishJsons$1(msgs);
281
283
  return succeed(pairs.map(param => param[0]));
282
284
  } catch (raw_exn$2) {
283
285
  let exn$2 = Primitive_exceptions.internalToException(raw_exn$2);
@@ -302,6 +302,10 @@ module Make = (
302
302
  publishJsons: ReventlessInfra.CommandTopic.publishJsons,
303
303
  ~capabilities: Reventless.Capabilities.t,
304
304
  ) => {
305
+ let publishJsons = CommandSent.announcing(
306
+ ~comp=`OutboundTranslationSlice(${Spec.name})`,
307
+ publishJsons,
308
+ )
305
309
  // Ids that ran out of budget during this pass, announced once at the end so
306
310
  // one item's abandonment cannot interleave with another's attempt.
307
311
  let newlyAbandoned: array<string> = []
@@ -12,6 +12,7 @@ import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js
12
12
  import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
13
13
  import * as Util_Sury$Reventless from "@reventlessdev/reventless-spec/src/util/Util_Sury.res.mjs";
14
14
  import * as Message$ReventlessCore from "../../Message.res.mjs";
15
+ import * as CommandSent$ReventlessCore from "../../CommandSent.res.mjs";
15
16
  import * as EffectLogger$ReventlessCore from "../../util/EffectLogger.res.mjs";
16
17
 
17
18
  let todoStatusSchema = Sury.union([
@@ -157,6 +158,7 @@ function Make(Spec) {
157
158
  }
158
159
  };
159
160
  let phase2 = async (publishJsons, capabilities) => {
161
+ let publishJsons$1 = CommandSent$ReventlessCore.announcing(`OutboundTranslationSlice(` + Spec.name + `)`, publishJsons);
160
162
  let newlyAbandoned = [];
161
163
  Object.entries(todoItems).forEach(param => {
162
164
  let row = param[1];
@@ -284,7 +286,7 @@ function Make(Spec) {
284
286
  meta: msg_meta,
285
287
  commandJson: commandJson
286
288
  };
287
- await publishJsons([msg$1]);
289
+ await publishJsons$1([msg$1]);
288
290
  let newrecord$2 = {...row};
289
291
  newrecord$2.completedAt = new Date().toISOString();
290
292
  newrecord$2.status = "Completed";
@@ -335,7 +337,7 @@ function Make(Spec) {
335
337
  await prev;
336
338
  let row = todoItems[id];
337
339
  if (row !== undefined) {
338
- return await announceAbandonment(id, row, publishJsons);
340
+ return await announceAbandonment(id, row, publishJsons$1);
339
341
  }
340
342
  });
341
343
  };