@reventlessdev/reventless-core 3.0.0-alpha.330 → 3.0.0-alpha.332

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 (84) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/package.json +8 -8
  3. package/src/CommandSent.res.mjs +2 -2
  4. package/src/Projection.res.mjs +7 -7
  5. package/src/RequestContext.res.mjs +1 -1
  6. package/src/adapter/Runtime/AggregateRuntime_Builder_Common.res.mjs +2 -2
  7. package/src/adapter/Runtime/EventCollectorRuntime_Builder_Single.res.mjs +2 -2
  8. package/src/adapter/Runtime/Runtime.res.mjs +8 -7
  9. package/src/admin/Platform_Admin_Callback.res.mjs +4 -3
  10. package/src/components/Aggregate/Aggregate_Callback.res.mjs +23 -22
  11. package/src/components/AutomationSlice/AutomationSlice_Builder.res.mjs +5 -4
  12. package/src/components/AutomationSlice/AutomationSlice_Callback.res.mjs +1 -1
  13. package/src/components/CommandGenerator/CommandGenerator_Callback.res.mjs +9 -8
  14. package/src/components/CommandTopic/CommandTopic_Builder.res.mjs +5 -4
  15. package/src/components/CommandTopic/CommandTopic_Callback.res.mjs +9 -7
  16. package/src/components/CommandTopic/CommandTopic_Helpers.res.mjs +2 -2
  17. package/src/components/CommandTopic/CommandTopic_Operations.res.mjs +2 -2
  18. package/src/components/Counter/Counter_Callback.res.mjs +4 -3
  19. package/src/components/Counter/Counter_Operations.res.mjs +1 -1
  20. package/src/components/DcbEventLog/DcbEventLog_Operations.res.mjs +5 -4
  21. package/src/components/EventCollector/EventCollector_Builder.res.mjs +1 -1
  22. package/src/components/EventLog/EventLog_Operations.res +1 -1
  23. package/src/components/EventLog/EventLog_Operations.res.mjs +9 -8
  24. package/src/components/EventMapper/EventMapper_Callback.res.mjs +11 -10
  25. package/src/components/EventTopic/EventTopic_Operations.res.mjs +2 -2
  26. package/src/components/Extension/Extension_Operations.res.mjs +2 -2
  27. package/src/components/ExtensionPoint/ExtensionPoint_Callback.res.mjs +3 -3
  28. package/src/components/ExtensionPoint/ExtensionPoint_Operations.res.mjs +2 -2
  29. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +1 -1
  30. package/src/components/InboundTranslationSlice/InboundTranslationSlice_Webhook.res.mjs +2 -2
  31. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res.mjs +5 -4
  32. package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res.mjs +1 -1
  33. package/src/components/QueryDb/QueryDb_Operations.res.mjs +1 -1
  34. package/src/components/ReadModel/ReadModel_Callback.res.mjs +7 -6
  35. package/src/components/SideEffectHandler/SideEffectHandler_Callback.res.mjs +7 -6
  36. package/src/components/StateChangeSlice/StateChangeSlice_Builder.res.mjs +5 -4
  37. package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +19 -18
  38. package/src/components/StateViewSlice/StateViewSlice_Builder.res.mjs +9 -8
  39. package/src/components/StateViewSlice/StateViewSlice_Callback.res.mjs +2 -2
  40. package/src/plugin/component/Plugin_Callback.res.mjs +5 -4
  41. package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +1 -1
  42. package/src/plugin/lifecycle/PluginSpec.res +8 -3
  43. package/src/plugin/lifecycle/PluginSpec.res.mjs +8 -4
  44. package/src/util/CommandPublisher.res.mjs +2 -2
  45. package/src/util/CsvStream.res +8 -4
  46. package/src/util/CsvStream.res.mjs +7 -6
  47. package/src/util/EffectLogger.res +26 -46
  48. package/src/util/EffectLogger.res.mjs +24 -21
  49. package/src/util/FTPHandler.res.mjs +1 -1
  50. package/src/util/ScheduleOps.res.mjs +2 -2
  51. package/src/util/ScheduleTime.res.mjs +5 -5
  52. package/src/util/Util_AdapterRuntime.res.mjs +2 -2
  53. package/src/util/Util_Promise.res.mjs +2 -2
  54. package/src/util/Util_QueryDbRuntime.res.mjs +2 -2
  55. package/src/util/Validation.res.mjs +2 -2
  56. package/tests/adapter/RuntimeExtensionHookReachTest.res.mjs +1 -1
  57. package/tests/aggregate/AggregateCacheTest.res.mjs +1 -1
  58. package/tests/aggregate/AggregateCallbackTest.res.mjs +1 -1
  59. package/tests/aggregate/AggregateCausationTest.res.mjs +1 -1
  60. package/tests/aggregate/AggregateConflictTest.res.mjs +1 -1
  61. package/tests/aggregate/AggregateRejectionTest.res.mjs +1 -1
  62. package/tests/aggregate/AggregateRepeatTest.res.mjs +1 -1
  63. package/tests/aggregate/AggregateSnapshotTest.res.mjs +10 -11
  64. package/tests/commandgenerator/CommandGeneratorCallbackTest.res.mjs +1 -1
  65. package/tests/commandgenerator/OwnerActingTest.res.mjs +1 -1
  66. package/tests/commandgenerator/OwnerStampingTest.res.mjs +1 -1
  67. package/tests/commandtopic/CommandOutcomeHookTest.res.mjs +1 -1
  68. package/tests/commandtopic/CommandTopicCallbackFixtures.res.mjs +1 -1
  69. package/tests/commandtopic/CommandTopicCallbackTest.res.mjs +1 -1
  70. package/tests/commandtopic/CommandTopicHelpersRejectionTest.res.mjs +1 -1
  71. package/tests/counter/CounterFixtures.res.mjs +1 -1
  72. package/tests/dcb/DcbPiiSliceTest.res.mjs +1 -1
  73. package/tests/dcb/DcbStateChangeSliceTest.res.mjs +1 -1
  74. package/tests/eventmapper/EventMapperCallbackTest.res.mjs +1 -1
  75. package/tests/extensionpoint/ExtensionPointCallbackTest.res.mjs +1 -1
  76. package/tests/logger/ComponentLineIdsTest.res.mjs +1 -1
  77. package/tests/logger/LogFormatTest.res.mjs +4 -3
  78. package/tests/logger/LoggerSinkTest.res.mjs +1 -1
  79. package/tests/querydb/QueryDbOperationsTest.res.mjs +2 -2
  80. package/tests/querydb/RowChangeTest.res.mjs +2 -2
  81. package/tests/querydb/TaggedUnionStampTest.res.mjs +2 -2
  82. package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res.mjs +1 -1
  83. package/tests/util/CsvStreamTest.res.mjs +4 -4
  84. package/tests/util/ScheduleTimeTest.res.mjs +1 -1
@@ -1,12 +1,13 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
+ import * as Effect from "@reventlessdev/rescript-effect/src/Effect.res.mjs";
3
4
  import * as Stream from "@reventlessdev/rescript-effect/src/Stream.res.mjs";
4
5
  import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
5
6
  import * as Stdlib_Lazy from "@rescript/runtime/lib/es6/Stdlib_Lazy.js";
6
7
  import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
7
8
  import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
8
9
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
9
- import * as Effect from "effect/Effect";
10
+ import * as Effect$1 from "effect/Effect";
10
11
  import * as Stream$1 from "effect/Stream";
11
12
  import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
12
13
  import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
@@ -79,7 +80,7 @@ function Make(Spec) {
79
80
  let openRaw = raw => {
80
81
  let data = raw.data;
81
82
  if (typeof data === "object" && data !== null && !Array.isArray(data) && Pii$Reventless.needsOpen(Spec.consumedEventSchema, raw.eventType, data)) {
82
- return Effect.promise(async () => {
83
+ return Effect$1.promise(async () => {
83
84
  let opened = await Pii$Reventless.openData(Spec.consumedEventSchema, raw.eventType, data);
84
85
  if (opened.TAG === "Ok") {
85
86
  return {
@@ -95,7 +96,7 @@ function Make(Spec) {
95
96
  }
96
97
  });
97
98
  } else {
98
- return Effect.succeed(raw);
99
+ return Effect$1.succeed(raw);
99
100
  }
100
101
  };
101
102
  let slicePartitionTag = Stdlib_Lazy.make(() => {
@@ -265,7 +266,7 @@ function Make(Spec) {
265
266
  strongConsistency = false;
266
267
  break;
267
268
  }
268
- return Effect.flatMap(Effect.tap(Stream$1.runFold(Stream$1.mapEffect(dcbEventLog.readStream(query, afterPos, strongConsistency), openRaw), [
269
+ return Effect$1.flatMap(Effect$1.tap(Stream.runFold(Stream.mapEffect(dcbEventLog.readStream(query, afterPos, strongConsistency), openRaw), [
269
270
  match$1[0],
270
271
  afterPos,
271
272
  [],
@@ -310,7 +311,7 @@ function Make(Spec) {
310
311
  let owners = param[3];
311
312
  let headPosition = param[1];
312
313
  let state = param[0];
313
- return Effect.flatMap(EffectLogger$ReventlessCore.logDebug(comp, undefined, ids, `deciding: id=` + Stdlib_Option.getOr(entityId, "-") + ` head=` + Stdlib_Option.getOr(headPosition, "-") + ` cmd=` + LogFormat$ReventlessCore.cmdName(cmdJson)), () => {
314
+ return Effect$1.flatMap(EffectLogger$ReventlessCore.logDebug(comp, undefined, ids, `deciding: id=` + Stdlib_Option.getOr(entityId, "-") + ` head=` + Stdlib_Option.getOr(headPosition, "-") + ` cmd=` + LogFormat$ReventlessCore.cmdName(cmdJson)), () => {
314
315
  let match = ownershipRefusal(owners);
315
316
  if (repeated) {
316
317
  CommandTopic_Helpers$ReventlessCore.reportAccepted(Spec.name, cmdJson.meta.correlationId, cmdJson.meta.causationId, cmdJson.meta.msgId, entityId !== undefined ? ({
@@ -319,7 +320,7 @@ function Make(Spec) {
319
320
  }) : ({
320
321
  eventCount: 0
321
322
  }));
322
- return Effect.map(EffectLogger$ReventlessCore.logInfo(comp, undefined, ids, `repeat dropped: ` + LogFormat$ReventlessCore.cmdName(cmdJson) + ` msgId=` + cmdJson.meta.msgId + ` already caused events in id=` + Stdlib_Option.getOr(entityId, "-")), () => ({
323
+ return Effect$1.map(EffectLogger$ReventlessCore.logInfo(comp, undefined, ids, `repeat dropped: ` + LogFormat$ReventlessCore.cmdName(cmdJson) + ` msgId=` + cmdJson.meta.msgId + ` already caused events in id=` + Stdlib_Option.getOr(entityId, "-")), () => ({
323
324
  TAG: "Ok",
324
325
  _0: "ok"
325
326
  }));
@@ -333,7 +334,7 @@ function Make(Spec) {
333
334
  ]);
334
335
  CommandTopic_Helpers$ReventlessCore.reportRejected(Spec.name, "AccessRefusal", cmdJson.meta.correlationId, cmdJson.meta.causationId, cmdJson.meta.msgId, rejected);
335
336
  let line = `refused: ` + rejected.errorDetail + ` id=` + Stdlib_Option.getOr(entityId, "-");
336
- return Effect.map(match.isDefect ? EffectLogger$ReventlessCore.logError(comp, undefined, ids, line) : EffectLogger$ReventlessCore.logWarn(comp, undefined, ids, line), () => ({
337
+ return Effect$1.map(match.isDefect ? EffectLogger$ReventlessCore.logError(comp, undefined, ids, line) : EffectLogger$ReventlessCore.logWarn(comp, undefined, ids, line), () => ({
337
338
  TAG: "Ok",
338
339
  _0: "rejected"
339
340
  }));
@@ -353,7 +354,7 @@ function Make(Spec) {
353
354
  }) : ({
354
355
  eventCount: 0
355
356
  }));
356
- return Effect.map(EffectLogger$ReventlessCore.logInfo(comp, undefined, ids, "no events produced"), () => ({
357
+ return Effect$1.map(EffectLogger$ReventlessCore.logInfo(comp, undefined, ids, "no events produced"), () => ({
357
358
  TAG: "Ok",
358
359
  _0: "ok"
359
360
  }));
@@ -374,7 +375,7 @@ function Make(Spec) {
374
375
  meta: meta
375
376
  };
376
377
  });
377
- return Effect.flatMap(Effect.promise(() => sealRawEvents(encoded)), sealResult => {
378
+ return Effect$1.flatMap(Effect$1.promise(() => sealRawEvents(encoded)), sealResult => {
378
379
  if (sealResult.TAG === "Ok") {
379
380
  let rawEvents = sealResult._0;
380
381
  let eventCount = rawEvents.length.toString();
@@ -391,7 +392,7 @@ function Make(Spec) {
391
392
  query: query,
392
393
  after: headPosition
393
394
  };
394
- return Effect.flatMap(Effect.flatMap(EffectLogger$ReventlessCore.logInfo(comp, eventJsons, ids, `produced ` + eventCount + ` event(s): [` + eventDetails + `]`), () => Effect.promise(() => dcbEventLog.append(rawEvents, condition))), appendResult => {
395
+ return Effect$1.flatMap(Effect$1.flatMap(EffectLogger$ReventlessCore.logInfo(comp, eventJsons, ids, `produced ` + eventCount + ` event(s): [` + eventDetails + `]`), () => Effect$1.promise(() => dcbEventLog.append(rawEvents, condition))), appendResult => {
395
396
  if (appendResult.TAG === "Ok") {
396
397
  cachePut([
397
398
  state,
@@ -404,7 +405,7 @@ function Make(Spec) {
404
405
  }) : ({
405
406
  eventCount: rawEvents.length
406
407
  }));
407
- return Effect.map(EffectLogger$ReventlessCore.logInfo(comp, undefined, ids, `append: ` + eventCount + ` event(s)`), () => ({
408
+ return Effect$1.map(EffectLogger$ReventlessCore.logInfo(comp, undefined, ids, `append: ` + eventCount + ` event(s)`), () => ({
408
409
  TAG: "Ok",
409
410
  _0: "ok"
410
411
  }));
@@ -427,7 +428,7 @@ function Make(Spec) {
427
428
  owners
428
429
  ];
429
430
  Metrics$ReventlessCore.emitCount("AppendRetry", Spec.name, undefined);
430
- return Effect.flatMap(EffectLogger$ReventlessCore.logWarn(comp, undefined, ids, `append failed (retrying ` + ((3 - retries | 0) + 1 | 0).toString() + `/` + (3).toString() + `): ` + errDetail), () => attempt(retries - 1 | 0));
431
+ return Effect$1.flatMap(EffectLogger$ReventlessCore.logWarn(comp, undefined, ids, `append failed (retrying ` + ((3 - retries | 0) + 1 | 0).toString() + `/` + (3).toString() + `): ` + errDetail), () => attempt(retries - 1 | 0));
431
432
  } else {
432
433
  cacheInvalidate();
433
434
  if (errorCode === CommandOutcome$Reventless.code("Conflict")) {
@@ -437,7 +438,7 @@ function Make(Spec) {
437
438
  errorCode: errorCode,
438
439
  errorDetail: errDetail
439
440
  });
440
- return Effect.map(EffectLogger$ReventlessCore.logError(comp, undefined, ids, `append failed, retries exhausted: ` + errDetail), () => ({
441
+ return Effect$1.map(EffectLogger$ReventlessCore.logError(comp, undefined, ids, `append failed, retries exhausted: ` + errDetail), () => ({
441
442
  TAG: "Error",
442
443
  _0: errDetail
443
444
  }));
@@ -454,7 +455,7 @@ function Make(Spec) {
454
455
  errorCode: CommandOutcome$Reventless.code("AppendFailed"),
455
456
  errorDetail: detail
456
457
  });
457
- return Effect.map(EffectLogger$ReventlessCore.logError(comp, undefined, ids, `append refused: ` + detail), () => ({
458
+ return Effect$1.map(EffectLogger$ReventlessCore.logError(comp, undefined, ids, `append refused: ` + detail), () => ({
458
459
  TAG: "Error",
459
460
  _0: detail
460
461
  }));
@@ -474,7 +475,7 @@ function Make(Spec) {
474
475
  errorCode: errorCode,
475
476
  errorDetail: errorDetail
476
477
  });
477
- return Effect.map(EffectLogger$ReventlessCore.logError(comp, undefined, ids, `decide rejected: ` + errorCode + ` ` + errorDetail), () => ({
478
+ return Effect$1.map(EffectLogger$ReventlessCore.logError(comp, undefined, ids, `decide rejected: ` + errorCode + ` ` + errorDetail), () => ({
478
479
  TAG: "Ok",
479
480
  _0: "rejected"
480
481
  }));
@@ -488,9 +489,9 @@ function Make(Spec) {
488
489
  let crossPartitionTagKeys = crossPartitionTagKeysOpt !== undefined ? crossPartitionTagKeysOpt : [];
489
490
  let partitionTag$1 = partitionTag !== undefined ? partitionTag : Stdlib_Lazy.get(slicePartitionTag);
490
491
  let payloadTagKeys = DcbTag$Reventless.commandPayloadTagKeys(scopeShape, partitionTag$1, crossPartitionTagKeys);
491
- return Stream.runCollect(Stream$1.mapEffect(stream, param => {
492
+ return Stream$1.runCollect(Stream.mapEffect(stream, param => {
492
493
  let reference = param.reference;
493
- return Effect.map(handleSingleCommand(tagKeysByEventType, crossPartitionTagKeys, payloadTagKeys, partitionTag$1, dcbEventLog, param.command), result => {
494
+ return Effect$1.map(handleSingleCommand(tagKeysByEventType, crossPartitionTagKeys, payloadTagKeys, partitionTag$1, dcbEventLog, param.command), result => {
494
495
  if (result.TAG === "Ok") {
495
496
  return {
496
497
  TAG: "Ok",
@@ -516,4 +517,4 @@ function Make(Spec) {
516
517
  export {
517
518
  Make,
518
519
  }
519
- /* Stream Not a pure module */
520
+ /* Effect Not a pure module */
@@ -1,13 +1,14 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
- import * as Stream from "@reventlessdev/rescript-effect/src/Stream.res.mjs";
3
+ import * as Effect from "@reventlessdev/rescript-effect/src/Effect.res.mjs";
4
4
  import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
5
5
  import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
6
6
  import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
7
7
  import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
8
8
  import * as Output$Pulumi from "@reventlessdev/rescript-pulumi-pulumi/src/Output.res.mjs";
9
9
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
10
- import * as Effect from "effect/Effect";
10
+ import * as Effect$1 from "effect/Effect";
11
+ import * as Stream from "effect/Stream";
11
12
  import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
12
13
  import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
13
14
  import * as DcbDecode$Reventless from "@reventlessdev/reventless-spec/src/components/DcbDecode.res.mjs";
@@ -82,11 +83,11 @@ function Make(RuntimeEnvironment) {
82
83
  }, opts);
83
84
  let comp = `StateViewSlice(` + Spec.name + `)`;
84
85
  let onChange = ViewChange$ReventlessCore.reporter(comp, Spec.name, state => Util_Sury$Reventless.toJson(state, Spec.stateSchema));
85
- let jsonEventsHandler = stream => Effect.flatMap(Effect.tap(Stream.runCollect(stream), events => {
86
+ let jsonEventsHandler = stream => Effect$1.flatMap(Effect$1.tap(Stream.runCollect(stream), events => {
86
87
  if (Pii$Reventless.needsPrepare(events)) {
87
- return Effect.promise(() => Pii$Reventless.prepareOrThrow(events));
88
+ return Effect$1.promise(() => Pii$Reventless.prepareOrThrow(events));
88
89
  } else {
89
- return Effect.succeed();
90
+ return Effect$1.succeed();
90
91
  }
91
92
  }), events => {
92
93
  let total = events.length.toString();
@@ -136,10 +137,10 @@ function Make(RuntimeEnvironment) {
136
137
  Projection$ReventlessCore.rewriteAction(action, meta.time, Spec.stateSchema),
137
138
  sources
138
139
  ]);
139
- }).flat(), Effect.succeed(), (acc, param) => {
140
+ }).flat(), Effect$1.succeed(), (acc, param) => {
140
141
  let sources = param[1];
141
142
  let action = param[0];
142
- return Effect.flatMap(acc, () => Effect.map(Effect.promise(() => Projection$ReventlessCore.handleAction(comp, sources, onChange, action, projectionOps, Spec.subIdConfig)), param => {}));
143
+ return Effect$1.flatMap(acc, () => Effect$1.map(Effect$1.promise(() => Projection$ReventlessCore.handleAction(comp, sources, onChange, action, projectionOps, Spec.subIdConfig)), param => {}));
143
144
  });
144
145
  });
145
146
  let handler = SpecificEventCollector.makeHandler(ec, jsonEventsHandler);
@@ -177,4 +178,4 @@ export {
177
178
  FrameworkProjection,
178
179
  Make,
179
180
  }
180
- /* Stream Not a pure module */
181
+ /* Effect Not a pure module */
@@ -1,9 +1,9 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
+ import * as Effect from "@reventlessdev/rescript-effect/src/Effect.res.mjs";
3
4
  import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
4
5
  import * as Stdlib_Array from "@rescript/runtime/lib/es6/Stdlib_Array.js";
5
6
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
6
- import * as Effect from "effect/Effect";
7
7
  import * as Pii$Reventless from "@reventlessdev/reventless-spec/src/components/Pii.res.mjs";
8
8
  import * as Primitive_option from "@rescript/runtime/lib/es6/Primitive_option.js";
9
9
  import * as DcbDecode$Reventless from "@reventlessdev/reventless-spec/src/components/DcbDecode.res.mjs";
@@ -71,4 +71,4 @@ export {
71
71
  FrameworkProjection,
72
72
  Make,
73
73
  }
74
- /* effect/Effect Not a pure module */
74
+ /* Effect Not a pure module */
@@ -1,8 +1,9 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
+ import * as Stream from "@reventlessdev/rescript-effect/src/Stream.res.mjs";
3
4
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
4
5
  import * as Effect from "effect/Effect";
5
- import * as Stream from "effect/Stream";
6
+ import * as Stream$1 from "effect/Stream";
6
7
  import * as Belt_SetString from "@rescript/runtime/lib/es6/Belt_SetString.js";
7
8
  import * as Message$ReventlessCore from "../../Message.res.mjs";
8
9
  import * as LogFormat$ReventlessCore from "../../util/LogFormat.res.mjs";
@@ -23,12 +24,12 @@ function Make(Spec) {
23
24
  let handleEventEffect = (eventJson$p, jsonEventsHandlersByService) => Stdlib_Option.mapOr(Stdlib_Option.flatMap(Message$ReventlessCore.serviceNameOfMsg(eventJson$p), serviceName => jsonEventsHandlersByService[serviceName]), Effect.succeed(), jsonEventsHandlers => Effect.map(Effect.all(jsonEventsHandlers.map(jsonEventsHandler => Effect.promise(() => jsonEventsHandler(eventJson$p, Spec.pluginDefinition))), {
24
25
  concurrency: "unbounded"
25
26
  }), param => {}));
26
- let handleJsonEvents = stream => Stream.runDrain(Stream.mapEffect(stream, eventJson$p => {
27
+ let handleJsonEvents = stream => Stream$1.runDrain(Stream.mapEffect(stream, eventJson$p => {
27
28
  let id = Spec.pluginDefinition.id;
28
29
  return Stdlib_Option.mapOr(Message$ReventlessCore.serviceNameOfMsg(eventJson$p), Effect.succeed(), serviceName => {
29
30
  let isHandled = Stdlib_Option.isSome(Spec.incomingConnectExtensionEventHandlers[serviceName]) || Stdlib_Option.isSome(Spec.outgoingExtensionPointEventHandlers[serviceName]) || Stdlib_Option.isSome(Spec.outgoingExtensionEventHandlers[serviceName]) || Stdlib_Option.isSome(Spec.incomingExtensionEventHandlers[serviceName]);
30
31
  if (isHandled) {
31
- return Effect.zipRight(EffectLogger$ReventlessCore.logInfo(comp(id), undefined, undefined, `incoming event: ` + LogFormat$ReventlessCore.eventSummary(eventJson$p)), Effect.zipRight(handleEventEffect(eventJson$p, Spec.incomingConnectExtensionEventHandlers), Effect.map(Effect.all([
32
+ return Effect.andThen(EffectLogger$ReventlessCore.logInfo(comp(id), undefined, undefined, `incoming event: ` + LogFormat$ReventlessCore.eventSummary(eventJson$p)), Effect.andThen(handleEventEffect(eventJson$p, Spec.incomingConnectExtensionEventHandlers), Effect.map(Effect.all([
32
33
  handleEventEffect(eventJson$p, Spec.outgoingExtensionPointEventHandlers),
33
34
  handleEventEffect(eventJson$p, Spec.outgoingExtensionEventHandlers),
34
35
  handleEventEffect(eventJson$p, Spec.incomingExtensionEventHandlers)
@@ -53,4 +54,4 @@ function Make(Spec) {
53
54
  export {
54
55
  Make,
55
56
  }
56
- /* effect/Effect Not a pure module */
57
+ /* Stream Not a pure module */
@@ -1,11 +1,11 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Sury from "sury";
4
+ import * as Effect from "@reventlessdev/rescript-effect/src/Effect.res.mjs";
4
5
  import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
5
6
  import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
6
7
  import * as Primitive_int from "@rescript/runtime/lib/es6/Primitive_int.js";
7
8
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
8
- import * as Effect from "effect/Effect";
9
9
  import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
10
10
  import * as Plugin$ReventlessCore from "../component/Plugin.res.mjs";
11
11
  import * as Message$ReventlessCore from "../../Message.res.mjs";
@@ -12,6 +12,11 @@ module Plugins = PluginsReadModelSpec
12
12
  // supersession synchronously. Version-scoped commands carry the `version`
13
13
  // the transition targets; the ExtensionPoint→Plugin mapping supplies it
14
14
  // (translated from the transport-level `name@version` id — Approach 1).
15
+
16
+ // The version an admin command acts on is picked from the row's other connected
17
+ // versions; a form opened on the row adds the row's own version to that list.
18
+ let otherVersion = Reventless.MemberRef.of_(~view="Plugins", ~field="otherConnectedVersions")
19
+
15
20
  // Order is load-bearing: sury strands constructors declared after a run of two or
16
21
  // more same-shaped ones, so the `pluginDefinition` pair must lead (DZakh/sury#392).
17
22
  @schema
@@ -33,11 +38,11 @@ type command =
33
38
  // a caller cannot match it against a field it holds, and a coercion failure says
34
39
  // `Variable '_0'` rather than what was missing. These three are the ones a person
35
40
  // calls, so their argument carries its own name.
36
- | Activate({version: version})
37
- | Deactivate({version: version})
41
+ | Activate({version: @s.matches(otherVersion) version})
42
+ | Deactivate({version: @s.matches(otherVersion) version})
38
43
  // Manual admin retirement of a specific version (archive). Distinct from the
39
44
  // automatic `Superseded` transition (which is decided, not commanded).
40
- | Retire({version: version})
45
+ | Retire({version: @s.matches(otherVersion) version})
41
46
 
42
47
  // Carries both the superseded and the superseding version's full definition —
43
48
  // a deterministic trigger for version-to-version schema/data migrations
@@ -3,6 +3,9 @@
3
3
  import * as Sury from "sury";
4
4
  import * as Plugin$Reventless from "@reventlessdev/reventless-spec/src/components/Plugin.res.mjs";
5
5
  import * as Api$ReventlessInfra from "@reventlessdev/reventless-infra/src/components/Api.res.mjs";
6
+ import * as MemberRef$Reventless from "@reventlessdev/reventless-spec/src/semantic/MemberRef.res.mjs";
7
+
8
+ let otherVersion = MemberRef$Reventless.of_(undefined, "Plugins", undefined, "otherConnectedVersions");
6
9
 
7
10
  let commandSchema = Sury.union([
8
11
  Sury.$schema(s => ({
@@ -27,15 +30,15 @@ let commandSchema = Sury.union([
27
30
  })),
28
31
  Sury.$schema(s => ({
29
32
  TAG: "Activate",
30
- version: s.m(Plugin$Reventless.versionSchema)
33
+ version: s.m(otherVersion)
31
34
  })),
32
35
  Sury.$schema(s => ({
33
36
  TAG: "Deactivate",
34
- version: s.m(Plugin$Reventless.versionSchema)
37
+ version: s.m(otherVersion)
35
38
  })),
36
39
  Sury.$schema(s => ({
37
40
  TAG: "Retire",
38
- version: s.m(Plugin$Reventless.versionSchema)
41
+ version: s.m(otherVersion)
39
42
  }))
40
43
  ]);
41
44
 
@@ -164,6 +167,7 @@ export {
164
167
  name,
165
168
  Id,
166
169
  Plugins,
170
+ otherVersion,
167
171
  versionSupersededDataSchema,
168
172
  eventSchema,
169
173
  errorSchema,
@@ -173,4 +177,4 @@ export {
173
177
  authorizationOf,
174
178
  traits,
175
179
  }
176
- /* commandSchema Not a pure module */
180
+ /* otherVersion Not a pure module */
@@ -1,8 +1,8 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
+ import * as Effect from "@reventlessdev/rescript-effect/src/Effect.res.mjs";
3
4
  import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
4
5
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
5
- import * as Effect from "effect/Effect";
6
6
  import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
7
7
  import * as Message$ReventlessCore from "../Message.res.mjs";
8
8
  import * as EffectLogger$ReventlessCore from "./EffectLogger.res.mjs";
@@ -154,4 +154,4 @@ function Make(Spec) {
154
154
  export {
155
155
  Make,
156
156
  }
157
- /* Stdlib_JsExn Not a pure module */
157
+ /* Effect Not a pure module */
@@ -8,8 +8,10 @@
8
8
  //
9
9
  // Note: Stream.take(n) short-circuits queue consumption, but the underlying
10
10
  // CSV parser runs at full speed and continues reading in the background.
11
- // Effect.runSyncExit is used inside the onData/onEnd/onError callbacks so that
12
- // a shut-down queue (e.g. after stream interruption) never throws.
11
+ // Effect.runSyncExit is used inside the onData/onError callbacks so that a
12
+ // queue that is already done (e.g. after stream interruption) never throws.
13
+ // The input is finished with Queue.endUnsafe, not shutdown: shutdown would
14
+ // discard rows the reader has not taken yet.
13
15
 
14
16
  // Parse a CSV file, emitting one row per stream item.
15
17
  // The first row is treated as column headers (not emitted as data).
@@ -20,11 +22,13 @@ let parseRows = (~path: string): Stream.t<CSV.row, string, unit> =>
20
22
  let _ =
21
23
  CSV.parseFile(~path, ~options={headers: CSV.Options.Bool(true)})
22
24
  ->CSV.onData(row => Queue.offer(queue, Ok(row))->Effect.runSyncExit->ignore)
23
- ->CSV.onEnd(_ => Queue.shutdown(queue)->Effect.runSyncExit->ignore)
25
+ ->CSV.onEnd(_ => {
26
+ let _ = Queue.endUnsafe(queue)
27
+ })
24
28
  ->CSV.onError(err => {
25
29
  let msg = err->JsExn.message->Option.getOr("CSV parse error")
26
30
  Queue.offer(queue, Error(msg))->Effect.runSyncExit->ignore
27
- Queue.shutdown(queue)->Effect.runSyncExit->ignore
31
+ let _ = Queue.endUnsafe(queue)
28
32
  })
29
33
  Effect.succeed(queue)
30
34
  })
@@ -1,14 +1,15 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
+ import * as Stream from "@reventlessdev/rescript-effect/src/Stream.res.mjs";
3
4
  import * as FastCsv from "fast-csv";
4
5
  import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
5
6
  import * as Queue from "effect/Queue";
6
7
  import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
7
8
  import * as Effect from "effect/Effect";
8
- import * as Stream from "effect/Stream";
9
+ import * as Stream$1 from "effect/Stream";
9
10
 
10
11
  function parseRows(path) {
11
- return Stream.flatMap(Stream.fromEffect(Effect.flatMap(Queue.unbounded(), queue => {
12
+ return Stream$1.flatMap(Stream$1.fromEffect(Effect.flatMap(Queue.unbounded(), queue => {
12
13
  FastCsv.parseFile(path, {
13
14
  headers: true
14
15
  }).on("data", row => {
@@ -17,17 +18,17 @@ function parseRows(path) {
17
18
  _0: row
18
19
  }));
19
20
  }).on("end", param => {
20
- Effect.runSyncExit(Queue.shutdown(queue));
21
+ Queue.endUnsafe(queue);
21
22
  }).on("error", err => {
22
23
  let msg = Stdlib_Option.getOr(Stdlib_JsExn.message(err), "CSV parse error");
23
24
  Effect.runSyncExit(Queue.offer(queue, {
24
25
  TAG: "Error",
25
26
  _0: msg
26
27
  }));
27
- Effect.runSyncExit(Queue.shutdown(queue));
28
+ Queue.endUnsafe(queue);
28
29
  });
29
30
  return Effect.succeed(queue);
30
- })), queue => Stream.mapEffect(Stream.fromQueue(queue), item => {
31
+ })), queue => Stream.mapEffect(Stream$1.fromQueue(queue), item => {
31
32
  if (item.TAG === "Ok") {
32
33
  return Effect.succeed(item._0);
33
34
  } else {
@@ -39,4 +40,4 @@ function parseRows(path) {
39
40
  export {
40
41
  parseRows,
41
42
  }
42
- /* fast-csv Not a pure module */
43
+ /* Stream Not a pure module */
@@ -8,27 +8,18 @@
8
8
  //
9
9
  // ~comp / ~detail and any ambient annotations (e.g. correlationId, requestId set
10
10
  // via Effect.annotateLogs at the request boundary) travel as Effect log
11
- // annotations — NOT baked into the message string. install() reads them off
12
- // `loggerOptions.annotations` and forwards them to Logger.emit, which promotes
13
- // them to top-level JSON fields. The message stays clean human text.
11
+ // annotations — NOT baked into the message string. install() reads them off the
12
+ // logging fiber and forwards them to Logger.emit, which promotes them to
13
+ // top-level JSON fields. The message stays clean human text.
14
14
  //
15
15
  // Usage: import at platform startup (module init calls install()).
16
16
  // EffectLogger.logInfo(~comp=`Aggregate(${Spec.name})`, ~detail=eventJson, "replay done")
17
17
 
18
18
  type loggerOptions
19
- type logLevel
20
- type annotationsMap
21
19
 
22
20
  @get external _message: loggerOptions => JSON.t = "message"
23
- @get external _logLevel: loggerOptions => logLevel = "logLevel"
24
- @get external _ordinal: logLevel => int = "ordinal"
25
- @get external _annotations: loggerOptions => annotationsMap = "annotations"
26
-
27
- // Effect stores log annotations as a HashMap<string, unknown>; toEntries gives a
28
- // plain [key, value] array. Values arrive as raw JS — string annotations decode
29
- // directly via JSON.Decode.string.
30
- @module("effect/HashMap")
31
- external _annotationEntries: annotationsMap => array<(string, JSON.t)> = "toEntries"
21
+ @get external _logLevel: loggerOptions => Effect.logLevel = "logLevel"
22
+ @get external _fiber: loggerOptions => Fiber.t<unknown, unknown> = "fiber"
32
23
 
33
24
  let _messageToString = (msg: JSON.t): string =>
34
25
  switch msg {
@@ -53,16 +44,6 @@ external _defaultLogger: effectLogger = "defaultLogger"
53
44
  // Effect's runtime gates log effects by a minimum LogLevel BEFORE they reach the
54
45
  // installed logger above — so `Effect.logDebug` is dropped unless the threshold is
55
46
  // lowered. We set that threshold per log effect from a configurable minimum.
56
- type effectLogLevel
57
- @module("effect/LogLevel") external _llDebug: effectLogLevel = "Debug"
58
- @module("effect/LogLevel") external _llInfo: effectLogLevel = "Info"
59
- @module("effect/LogLevel") external _llWarning: effectLogLevel = "Warning"
60
- @module("effect/LogLevel") external _llError: effectLogLevel = "Error"
61
- @module("effect/LogLevel") external _llNone: effectLogLevel = "None"
62
-
63
- @module("effect/Logger")
64
- external _withMinimumLogLevel: (Effect.t<'a, 'e, 'r>, effectLogLevel) => Effect.t<'a, 'e, 'r> =
65
- "withMinimumLogLevel"
66
47
 
67
48
  // Minimum level used when LOG_LEVEL is unset. Framework default is Info; a platform
68
49
  // may lower it (e.g. the in-memory dev platform sets Debug) via setDefaultMinLevel.
@@ -73,30 +54,27 @@ let setDefaultMinLevel = Logger.setDefaultMinLevel
73
54
 
74
55
  // Resolve the active minimum for one line of `comp`: a level set while running
75
56
  // for it (or its plugin) first, then LOG_LEVEL, then the platform default.
76
- let _effectMin = (~comp: option<string>=?, ()): effectLogLevel =>
57
+ let _effectMin = (~comp: option<string>=?, ()): Effect.logLevel =>
77
58
  switch Logger.minLevelFor(~comp?, ()) {
78
- | None => _llNone
79
- | Some(Logger.Debug) => _llDebug
80
- | Some(Logger.Info) => _llInfo
81
- | Some(Logger.Warn) => _llWarning
82
- | Some(Logger.Error) => _llError
59
+ | None => #None
60
+ | Some(Logger.Debug) => #Debug
61
+ | Some(Logger.Info) => #Info
62
+ | Some(Logger.Warn) => #Warn
63
+ | Some(Logger.Error) => #Error
83
64
  }
84
65
 
85
- let ordinalToLevel = ordinal =>
86
- if ordinal >= 40000 {
87
- Logger.Error
88
- } else if ordinal >= 30000 {
89
- Logger.Warn
90
- } else if ordinal >= 20000 {
91
- Logger.Info
92
- } else {
93
- Logger.Debug
66
+ let levelOf = (level: Effect.logLevel) =>
67
+ switch level {
68
+ | #Fatal | #Error => Logger.Error
69
+ | #Warn => Logger.Warn
70
+ | #Info => Logger.Info
71
+ | #All | #Debug | #Trace | #None => Logger.Debug
94
72
  }
95
73
 
96
74
  let install = () =>
97
75
  _defaultLogger.log = opts => {
98
76
  let msg = opts->_message->_messageToString
99
- let level = opts->_logLevel->_ordinal->ordinalToLevel
77
+ let level = opts->_logLevel->levelOf
100
78
  // Decode log annotations: `comp`, `plugin`, and `detail` get dedicated
101
79
  // Logger.emit handling (prefix/plugin resolution, expandable payload);
102
80
  // everything else (correlationId, requestId, …) flows through as
@@ -106,8 +84,10 @@ let install = () =>
106
84
  let detail = ref(None)
107
85
  let extra = Dict.make()
108
86
  opts
109
- ->_annotations
110
- ->_annotationEntries
87
+ ->_fiber
88
+ ->Fiber.getRef(Effect.currentLogAnnotations)
89
+ ->Dict.toArray
90
+ ->Array.map(((k, v)) => (k, JSON.Encode.string(v)))
111
91
  ->Array.forEach(((k, v)) =>
112
92
  switch k {
113
93
  | "comp" => comp := v->JSON.Decode.string
@@ -234,16 +214,16 @@ let _annotate = (eff, ~comp=?, ~detail=?, ~ids: option<ids>=?) => {
234
214
  let logInfo = (~comp=?, ~detail=?, ~ids=?, msg) =>
235
215
  Effect.logInfo(msg)
236
216
  ->_annotate(~comp?, ~detail?, ~ids?)
237
- ->_withMinimumLogLevel(_effectMin(~comp?, ()))
217
+ ->Effect.withMinimumLogLevel(_effectMin(~comp?, ()))
238
218
  let logWarn = (~comp=?, ~detail=?, ~ids=?, msg) =>
239
219
  Effect.logWarning(msg)
240
220
  ->_annotate(~comp?, ~detail?, ~ids?)
241
- ->_withMinimumLogLevel(_effectMin(~comp?, ()))
221
+ ->Effect.withMinimumLogLevel(_effectMin(~comp?, ()))
242
222
  let logError = (~comp=?, ~detail=?, ~ids=?, msg) =>
243
223
  Effect.logError(msg)
244
224
  ->_annotate(~comp?, ~detail?, ~ids?)
245
- ->_withMinimumLogLevel(_effectMin(~comp?, ()))
225
+ ->Effect.withMinimumLogLevel(_effectMin(~comp?, ()))
246
226
  let logDebug = (~comp=?, ~detail=?, ~ids=?, msg) =>
247
227
  Effect.logDebug(msg)
248
228
  ->_annotate(~comp?, ~detail?, ~ids?)
249
- ->_withMinimumLogLevel(_effectMin(~comp?, ()))
229
+ ->Effect.withMinimumLogLevel(_effectMin(~comp?, ()))