@reventlessdev/reventless-core 3.0.0-alpha.326 → 3.0.0-alpha.327
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.
- package/CHANGELOG.md +8 -0
- package/package.json +5 -5
- package/src/adapter/Runtime/AggregateRuntime_Builder_Common.res.mjs +5 -5
- package/src/adapter/Runtime/EventCollectorRuntime_Builder_Single.res.mjs +2 -2
- package/src/admin/Platform_Admin_Callback.res.mjs +1 -1
- package/src/components/Aggregate/Aggregate_Callback.res +88 -18
- package/src/components/Aggregate/Aggregate_Callback.res.mjs +53 -32
- package/src/components/AutomationSlice/AutomationSlice_Builder.res.mjs +1 -1
- package/src/components/AutomationSlice/AutomationSlice_Callback.res +8 -0
- package/src/components/AutomationSlice/AutomationSlice_Callback.res.mjs +16 -12
- package/src/components/CommandGenerator/CommandGenerator_Callback.res +47 -6
- package/src/components/CommandGenerator/CommandGenerator_Callback.res.mjs +41 -4
- package/src/components/CommandTopic/CommandTopic_Callback.res.mjs +1 -1
- package/src/components/CommandTopic/CommandTopic_Helpers.res +9 -1
- package/src/components/CommandTopic/CommandTopic_Helpers.res.mjs +7 -6
- package/src/components/CommandTopic/CommandTopic_Operations.res +2 -0
- package/src/components/CommandTopic/CommandTopic_Operations.res.mjs +2 -2
- package/src/components/Counter/Counter_Callback.res.mjs +3 -3
- package/src/components/Counter/Counter_Operations.res.mjs +4 -4
- package/src/components/DcbEventLog/DcbEventLog_Operations.res.mjs +3 -3
- package/src/components/EventLog/EventLog_Operations.res +1 -0
- package/src/components/EventLog/EventLog_Operations.res.mjs +3 -3
- package/src/components/EventMapper/EventMapper_Callback.res +4 -0
- package/src/components/EventMapper/EventMapper_Callback.res.mjs +13 -12
- package/src/components/EventTopic/EventTopic_Operations.res +2 -0
- package/src/components/EventTopic/EventTopic_Operations.res.mjs +2 -2
- package/src/components/Extension/Extension_Operations.res +4 -0
- package/src/components/Extension/Extension_Operations.res.mjs +8 -8
- package/src/components/ExtensionPoint/ExtensionPoint_Callback.res.mjs +2 -2
- package/src/components/ExtensionPoint/ExtensionPoint_Operations.res +2 -0
- package/src/components/ExtensionPoint/ExtensionPoint_Operations.res.mjs +9 -8
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Callback.res.mjs +1 -1
- package/src/components/InboundTranslationSlice/InboundTranslationSlice_Webhook.res.mjs +1 -1
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Builder.res.mjs +1 -1
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res +8 -0
- package/src/components/OutboundTranslationSlice/OutboundTranslationSlice_Callback.res.mjs +10 -10
- package/src/components/ReadModel/ReadModel_Callback.res +1 -0
- package/src/components/ReadModel/ReadModel_Callback.res.mjs +1 -1
- package/src/components/SideEffectHandler/SideEffectHandler_Callback.res +2 -0
- package/src/components/SideEffectHandler/SideEffectHandler_Callback.res.mjs +6 -6
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res +36 -7
- package/src/components/StateChangeSlice/StateChangeSlice_Callback.res.mjs +38 -20
- package/src/components/StateViewSlice/StateViewSlice_Builder.res +2 -0
- package/src/components/StateViewSlice/StateViewSlice_Builder.res.mjs +2 -2
- package/src/components/StateViewSlice/StateViewSlice_Callback.res +6 -0
- package/src/components/StateViewSlice/StateViewSlice_Callback.res.mjs +3 -2
- package/src/plugin/component/Plugin_Callback.res.mjs +2 -2
- package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +6 -6
- package/src/util/CommandPublisher.res.mjs +9 -9
- package/src/util/EffectLogger.res +85 -17
- package/src/util/EffectLogger.res.mjs +63 -12
- package/src/util/FTPHandler.res.mjs +6 -6
- package/src/util/ScheduleOps.res.mjs +4 -4
- package/src/util/Util_AdapterRuntime.res.mjs +2 -2
- package/src/util/Util_Promise.res.mjs +1 -1
- package/src/util/Util_QueryDbRuntime.res.mjs +1 -1
- package/src/util/Validation.res.mjs +1 -1
- package/tests/commandgenerator/OwnerStampingTest.res +65 -0
- package/tests/commandgenerator/OwnerStampingTest.res.mjs +62 -0
- package/tests/commandtopic/CommandOutcomeHookTest.res +25 -0
- package/tests/commandtopic/CommandOutcomeHookTest.res.mjs +28 -0
- package/tests/commandtopic/CommandTopicHelpersRejectionTest.res.mjs +4 -4
- package/tests/logger/ComponentLineIdsTest.res +97 -0
- package/tests/logger/ComponentLineIdsTest.res.mjs +118 -0
- package/tests/logger/LogFormatTest.res.mjs +5 -5
- package/tests/logger/LoggerSinkTest.res.mjs +3 -3
|
@@ -122,14 +122,14 @@ function Make(RuntimeEnvironment) {
|
|
|
122
122
|
} catch (raw_exn) {
|
|
123
123
|
let exn$1 = Primitive_exceptions.internalToException(raw_exn);
|
|
124
124
|
let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn$1), Stdlib_JsExn.message), "unknown");
|
|
125
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError(comp, undefined, `project failed for ` + eventType + `: ` + errMsg));
|
|
125
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError(comp, undefined, EffectLogger$ReventlessCore.idsOf(undefined, undefined, meta), `project failed for ` + eventType + `: ` + errMsg));
|
|
126
126
|
actions = [];
|
|
127
127
|
}
|
|
128
128
|
let idxStr = (i + 1 | 0).toString();
|
|
129
129
|
let actionsStr = LogFormat$ReventlessCore.actionNames(actions);
|
|
130
130
|
let f = Object.entries(dataDict).map(param => param[0] + `:` + JSON.stringify(param[1])).join(",");
|
|
131
131
|
let fieldsStr = f === "" ? "" : `({` + f + `})`;
|
|
132
|
-
Effect.runSync(EffectLogger$ReventlessCore.logInfo(comp, dataDict, `handling event ` + idxStr + `/` + total + `: ` + LogFormat$ReventlessCore.bold(eventType) + fieldsStr + ` ` + actionsStr));
|
|
132
|
+
Effect.runSync(EffectLogger$ReventlessCore.logInfo(comp, dataDict, EffectLogger$ReventlessCore.idsOf(undefined, undefined, meta), `handling event ` + idxStr + `/` + total + `: ` + LogFormat$ReventlessCore.bold(eventType) + fieldsStr + ` ` + actionsStr));
|
|
133
133
|
let match$1 = ViewChange$ReventlessCore.entityOfEnvelope(envelopeDict);
|
|
134
134
|
let sources = [ViewChange$ReventlessCore.sourceOf(meta, match$1[0], match$1[1], undefined)];
|
|
135
135
|
return actions.map(action => [
|
|
@@ -59,8 +59,14 @@ module Make = (
|
|
|
59
59
|
),
|
|
60
60
|
)
|
|
61
61
|
let actionsStr = LogFormat.actionNames(actions)
|
|
62
|
+
let tag = raw.tags->Array.get(0)
|
|
62
63
|
EffectLogger.logInfo(
|
|
63
64
|
~comp,
|
|
65
|
+
~ids=EffectLogger.idsOf(
|
|
66
|
+
raw.meta,
|
|
67
|
+
~entityId=?tag->Option.map(t => t.value),
|
|
68
|
+
~entityType=?tag->Option.map(t => t.key),
|
|
69
|
+
),
|
|
64
70
|
~detail=raw.data,
|
|
65
71
|
`handling event ${idx.contents->Int.toString}/${count}: ${LogFormat.bold(
|
|
66
72
|
raw.eventType,
|
|
@@ -43,7 +43,8 @@ function Make(Spec) {
|
|
|
43
43
|
recordedAt: raw.recordedAt
|
|
44
44
|
}).map(__x => Projection$Reventless.mapActionId(__x, Spec.Id.toString, Spec.Id.makeFromString));
|
|
45
45
|
let actionsStr = LogFormat$ReventlessCore.actionNames(actions);
|
|
46
|
-
|
|
46
|
+
let tag = raw.tags[0];
|
|
47
|
+
Effect.runSync(EffectLogger$ReventlessCore.logInfo(comp, raw.data, EffectLogger$ReventlessCore.idsOf(Stdlib_Option.map(tag, t => t.value), Stdlib_Option.map(tag, t => t.key), raw.meta), `handling event ` + idx.contents.toString() + `/` + count + `: ` + LogFormat$ReventlessCore.bold(raw.eventType) + `(` + id + `) ` + actionsStr));
|
|
47
48
|
let sources = [ViewChange$ReventlessCore.sourceOf(raw.meta, Stdlib_Option.map(raw.tags[0], tag => tag.value), Stdlib_Option.map(raw.tags[0], tag => tag.key), undefined)];
|
|
48
49
|
allActions.push(...actions.map(action => ({
|
|
49
50
|
action: Projection$ReventlessCore.rewriteAction(action, raw.meta.time, Spec.stateSchema),
|
|
@@ -53,7 +54,7 @@ function Make(Spec) {
|
|
|
53
54
|
});
|
|
54
55
|
let skipped = rawEvents.length - events.length | 0;
|
|
55
56
|
if (skipped > 0) {
|
|
56
|
-
Effect.runSync(EffectLogger$ReventlessCore.logWarn(comp, undefined, `skipped=` + skipped.toString() + ` events (decode mismatch)`));
|
|
57
|
+
Effect.runSync(EffectLogger$ReventlessCore.logWarn(comp, undefined, undefined, `skipped=` + skipped.toString() + ` events (decode mismatch)`));
|
|
57
58
|
}
|
|
58
59
|
return await Projection$ReventlessCore.handleSourcedActions(comp, onChange, allActions, queryDbOps, Spec.subIdConfig);
|
|
59
60
|
};
|
|
@@ -27,7 +27,7 @@ function Make(Spec) {
|
|
|
27
27
|
return Stdlib_Option.mapOr(Message$ReventlessCore.serviceNameOfMsg(eventJson$p), Effect.succeed(), serviceName => {
|
|
28
28
|
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]);
|
|
29
29
|
if (isHandled) {
|
|
30
|
-
return Effect.zipRight(EffectLogger$ReventlessCore.logInfo(`Plugin(` + id + `)`, undefined, `incoming event: ` + LogFormat$ReventlessCore.eventSummary(eventJson$p)), Effect.zipRight(handleEventEffect(eventJson$p, Spec.incomingConnectExtensionEventHandlers), Effect.map(Effect.all([
|
|
30
|
+
return Effect.zipRight(EffectLogger$ReventlessCore.logInfo(`Plugin(` + id + `)`, undefined, undefined, `incoming event: ` + LogFormat$ReventlessCore.eventSummary(eventJson$p)), Effect.zipRight(handleEventEffect(eventJson$p, Spec.incomingConnectExtensionEventHandlers), Effect.map(Effect.all([
|
|
31
31
|
handleEventEffect(eventJson$p, Spec.outgoingExtensionPointEventHandlers),
|
|
32
32
|
handleEventEffect(eventJson$p, Spec.outgoingExtensionEventHandlers),
|
|
33
33
|
handleEventEffect(eventJson$p, Spec.incomingExtensionEventHandlers)
|
|
@@ -40,7 +40,7 @@ function Make(Spec) {
|
|
|
40
40
|
}
|
|
41
41
|
warnedServices.contents = Belt_SetString.add(warnedServices.contents, serviceName);
|
|
42
42
|
let known = knownServiceNames().join(", ");
|
|
43
|
-
return EffectLogger$ReventlessCore.logWarn(`Plugin(` + id + `)`, undefined, `incoming event has service="` + serviceName + `" but no handler is registered for it — known services: [` + known + `]. Likely cause: an ExtensionPointMapping/Extension Delegate.name does not match the source's serviceName (DCB sources use "<plugin>DcbEventLog").`);
|
|
43
|
+
return EffectLogger$ReventlessCore.logWarn(`Plugin(` + id + `)`, undefined, undefined, `incoming event has service="` + serviceName + `" but no handler is registered for it — known services: [` + known + `]. Likely cause: an ExtensionPointMapping/Extension Delegate.name does not match the source's serviceName (DCB sources use "<plugin>DcbEventLog").`);
|
|
44
44
|
}
|
|
45
45
|
});
|
|
46
46
|
}));
|
|
@@ -44,7 +44,7 @@ function Make(Spec) {
|
|
|
44
44
|
]
|
|
45
45
|
], 1000);
|
|
46
46
|
if (jsons.length === 0) {
|
|
47
|
-
return Effect.runSync(EffectLogger$ReventlessCore.logWarn(PluginExtensionPointSpec$ReventlessInfra.name, undefined, `ForwardCommand: Couldn't find Plugin with ExtensionPoint ` + extensionPointName));
|
|
47
|
+
return Effect.runSync(EffectLogger$ReventlessCore.logWarn(PluginExtensionPointSpec$ReventlessInfra.name, undefined, undefined, `ForwardCommand: Couldn't find Plugin with ExtensionPoint ` + extensionPointName));
|
|
48
48
|
}
|
|
49
49
|
let plugin = jsons[0];
|
|
50
50
|
let exit = 0;
|
|
@@ -55,12 +55,12 @@ function Make(Spec) {
|
|
|
55
55
|
} catch (raw_err) {
|
|
56
56
|
let err = Primitive_exceptions.internalToException(raw_err);
|
|
57
57
|
let errMsg = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(err), Stdlib_JsExn.message), "unknown");
|
|
58
|
-
return Effect.runSync(EffectLogger$ReventlessCore.logError(PluginExtensionPointSpec$ReventlessInfra.name, undefined, `ForwardCommand: Couldn't decode Plugin: ` + errMsg));
|
|
58
|
+
return Effect.runSync(EffectLogger$ReventlessCore.logError(PluginExtensionPointSpec$ReventlessInfra.name, undefined, undefined, `ForwardCommand: Couldn't decode Plugin: ` + errMsg));
|
|
59
59
|
}
|
|
60
60
|
if (exit === 1) {
|
|
61
61
|
let extensionPoint = plugin$1.extensionPoints.find(extensionPoint => extensionPoint.name === extensionPointName);
|
|
62
62
|
if (extensionPoint === undefined) {
|
|
63
|
-
return Effect.runSync(EffectLogger$ReventlessCore.logWarn(PluginExtensionPointSpec$ReventlessInfra.name, undefined, `ForwardCommand: Couldn't find ExtensionPoint ` + extensionPointName + ` in ` + plugin$1.name));
|
|
63
|
+
return Effect.runSync(EffectLogger$ReventlessCore.logWarn(PluginExtensionPointSpec$ReventlessInfra.name, undefined, undefined, `ForwardCommand: Couldn't find ExtensionPoint ` + extensionPointName + ` in ` + plugin$1.name));
|
|
64
64
|
}
|
|
65
65
|
let exit$1 = 0;
|
|
66
66
|
let val;
|
|
@@ -70,10 +70,10 @@ function Make(Spec) {
|
|
|
70
70
|
} catch (raw_err$1) {
|
|
71
71
|
let err$1 = Primitive_exceptions.internalToException(raw_err$1);
|
|
72
72
|
let errMsg$1 = Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_JsExn.fromException(err$1), Stdlib_JsExn.message), "unknown");
|
|
73
|
-
return Effect.runSync(EffectLogger$ReventlessCore.logError(PluginExtensionPointSpec$ReventlessInfra.name, undefined, `ForwardCommand: Error on publish command: ` + errMsg$1));
|
|
73
|
+
return Effect.runSync(EffectLogger$ReventlessCore.logError(PluginExtensionPointSpec$ReventlessInfra.name, undefined, undefined, `ForwardCommand: Error on publish command: ` + errMsg$1));
|
|
74
74
|
}
|
|
75
75
|
if (exit$1 === 2) {
|
|
76
|
-
return Effect.runSync(EffectLogger$ReventlessCore.logInfo(PluginExtensionPointSpec$ReventlessInfra.name, undefined, `ForwardCommand: published command to ` + plugin$1.name + ` ` + extensionPoint.commandTopic));
|
|
76
|
+
return Effect.runSync(EffectLogger$ReventlessCore.logInfo(PluginExtensionPointSpec$ReventlessInfra.name, undefined, undefined, `ForwardCommand: published command to ` + plugin$1.name + ` ` + extensionPoint.commandTopic));
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
};
|
|
@@ -164,7 +164,7 @@ function Make(Spec) {
|
|
|
164
164
|
case "ConnectPlugin" :
|
|
165
165
|
let pluginDefinition = cmd._0;
|
|
166
166
|
let protocolErrors = pluginDefinition.extensionProtocols.flatMap(proto => Compat$ReventlessInterop.validateProtocol(CompatMatrix$ReventlessInterop.platformPlugin, proto.extensionPointName, proto.commandVersion, proto.eventVersion));
|
|
167
|
-
let reportAction = protocolErrors.length !== 0 ? (Effect.runSync(EffectLogger$ReventlessCore.logWarn(PluginExtensionPointSpec$ReventlessInfra.name, undefined, `Protocol version mismatch for plugin ` + pluginDefinition.id + `: ` + Stdlib_Option.getOr(JSON.stringify(protocolErrors), "[]"))), [{
|
|
167
|
+
let reportAction = protocolErrors.length !== 0 ? (Effect.runSync(EffectLogger$ReventlessCore.logWarn(PluginExtensionPointSpec$ReventlessInfra.name, undefined, undefined, `Protocol version mismatch for plugin ` + pluginDefinition.id + `: ` + Stdlib_Option.getOr(JSON.stringify(protocolErrors), "[]"))), [{
|
|
168
168
|
TAG: "PublishCommand",
|
|
169
169
|
_0: Plugin$ReventlessCore.name(id),
|
|
170
170
|
_1: {
|
|
@@ -30,13 +30,13 @@ function Make(Spec) {
|
|
|
30
30
|
let e = Primitive_exceptions.internalToException(raw_e);
|
|
31
31
|
if (e.RE_EXN_ID === "JsExn") {
|
|
32
32
|
let errMsg = Stdlib_Option.getOr(Stdlib_JsExn.message(e._1), "unknown");
|
|
33
|
-
return Effect.runSync(EffectLogger$ReventlessCore.logError("CommandPublisher", undefined, `Couldn't publish commands: ` + errMsg));
|
|
33
|
+
return Effect.runSync(EffectLogger$ReventlessCore.logError("CommandPublisher", undefined, undefined, `Couldn't publish commands: ` + errMsg));
|
|
34
34
|
}
|
|
35
35
|
throw e;
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
let toJsons = commandsToSend => {
|
|
39
|
-
Effect.runSync(EffectLogger$ReventlessCore.logDebug("CommandPublisher", undefined, `toJsons: commandsToSend: ` + commandsToSend.length.toString() + ` rest: ` + buffer.length.toString()));
|
|
39
|
+
Effect.runSync(EffectLogger$ReventlessCore.logDebug("CommandPublisher", undefined, undefined, `toJsons: commandsToSend: ` + commandsToSend.length.toString() + ` rest: ` + buffer.length.toString()));
|
|
40
40
|
return commandsToSend.map(param => {
|
|
41
41
|
let commandJson = Message$ReventlessCore.encode(param[1], Spec.commandSchema);
|
|
42
42
|
return {
|
|
@@ -67,13 +67,13 @@ function Make(Spec) {
|
|
|
67
67
|
let e = Primitive_exceptions.internalToException(raw_e);
|
|
68
68
|
if (e.RE_EXN_ID === "JsExn") {
|
|
69
69
|
let errMsg = Stdlib_Option.getOr(Stdlib_JsExn.message(e._1), "unknown");
|
|
70
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError("CommandPublisher", undefined, `send error: couldn't publish ` + size.toString() + ` commands: ` + errMsg));
|
|
70
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError("CommandPublisher", undefined, undefined, `send error: couldn't publish ` + size.toString() + ` commands: ` + errMsg));
|
|
71
71
|
} else {
|
|
72
72
|
throw e;
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
if (exit === 1) {
|
|
76
|
-
Effect.runSync(EffectLogger$ReventlessCore.logDebug("CommandPublisher", undefined, `send: finished SendAllInOneChunk: ` + size.toString()));
|
|
76
|
+
Effect.runSync(EffectLogger$ReventlessCore.logDebug("CommandPublisher", undefined, undefined, `send: finished SendAllInOneChunk: ` + size.toString()));
|
|
77
77
|
}
|
|
78
78
|
running.contents = undefined;
|
|
79
79
|
return;
|
|
@@ -88,7 +88,7 @@ function Make(Spec) {
|
|
|
88
88
|
let sizeStr = size$1.toString();
|
|
89
89
|
let bufferSizeStr = buffer.length.toString();
|
|
90
90
|
let chunkCountStr = chunkCount.contents.toString();
|
|
91
|
-
Effect.runSync(EffectLogger$ReventlessCore.logDebug("CommandPublisher", undefined, `send: bufferSize: ` + bufferSizeStr + `, chunk: ` + chunkCountStr + `, size: ` + sizeStr));
|
|
91
|
+
Effect.runSync(EffectLogger$ReventlessCore.logDebug("CommandPublisher", undefined, undefined, `send: bufferSize: ` + bufferSizeStr + `, chunk: ` + chunkCountStr + `, size: ` + sizeStr));
|
|
92
92
|
let commandsToSend$1 = buffer.slice(0, size$1);
|
|
93
93
|
buffer.splice(0, size$1);
|
|
94
94
|
let promise$1 = Config.publishCommands(Spec.name, toJsons(commandsToSend$1));
|
|
@@ -102,13 +102,13 @@ function Make(Spec) {
|
|
|
102
102
|
let e$1 = Primitive_exceptions.internalToException(raw_e$1);
|
|
103
103
|
if (e$1.RE_EXN_ID === "JsExn") {
|
|
104
104
|
let errorMessage = Stdlib_Option.getOr(Stdlib_JsExn.message(e$1._1), "unknown Error");
|
|
105
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError("CommandPublisher", undefined, `send error: couldn't publish chunk ` + chunkCountStr + ` (` + sizeStr + ` commands): ` + errorMessage));
|
|
105
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError("CommandPublisher", undefined, undefined, `send error: couldn't publish chunk ` + chunkCountStr + ` (` + sizeStr + ` commands): ` + errorMessage));
|
|
106
106
|
} else {
|
|
107
107
|
throw e$1;
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
if (exit$1 === 1) {
|
|
111
|
-
Effect.runSync(EffectLogger$ReventlessCore.logDebug("CommandPublisher", undefined, `send: finished chunk ` + chunkCountStr + `: ` + sizeStr));
|
|
111
|
+
Effect.runSync(EffectLogger$ReventlessCore.logDebug("CommandPublisher", undefined, undefined, `send: finished chunk ` + chunkCountStr + `: ` + sizeStr));
|
|
112
112
|
}
|
|
113
113
|
return await send();
|
|
114
114
|
};
|
|
@@ -128,12 +128,12 @@ function Make(Spec) {
|
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
130
|
let clear = () => {
|
|
131
|
-
Effect.runSync(EffectLogger$ReventlessCore.logDebug("CommandPublisher", undefined, "clear"));
|
|
131
|
+
Effect.runSync(EffectLogger$ReventlessCore.logDebug("CommandPublisher", undefined, undefined, "clear"));
|
|
132
132
|
buffer.splice(0, buffer.length);
|
|
133
133
|
flush.contents = false;
|
|
134
134
|
};
|
|
135
135
|
let flush$1 = async () => {
|
|
136
|
-
Effect.runSync(EffectLogger$ReventlessCore.logDebug("CommandPublisher", undefined, "flush"));
|
|
136
|
+
Effect.runSync(EffectLogger$ReventlessCore.logDebug("CommandPublisher", undefined, undefined, "flush"));
|
|
137
137
|
flush.contents = true;
|
|
138
138
|
return await send();
|
|
139
139
|
};
|
|
@@ -153,29 +153,97 @@ install()
|
|
|
153
153
|
|
|
154
154
|
// ─── Structured log helpers ──────────────────────────────────────────────────
|
|
155
155
|
// Returns Effect.t<unit> — usable in Effect pipelines or with ->Effect.runSync.
|
|
156
|
+
// Run with ->Effect.runSync, a line is on a fiber of its own and loses what the
|
|
157
|
+
// invocation annotated (its correlationId, causationId, plugin): pass ~ids, the ids
|
|
158
|
+
// of the message the line is about, which ride on the log effect itself.
|
|
156
159
|
//
|
|
157
|
-
// ~comp / ~detail attach as Effect log annotations; install() reads them back.
|
|
160
|
+
// ~comp / ~detail / ~ids attach as Effect log annotations; install() reads them back.
|
|
158
161
|
// ~detail: structured JSON shown only in a JSON sink (expandable on click);
|
|
159
162
|
// the in-memory terminal output shows only the message line.
|
|
160
163
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
164
|
+
/** The ids of the message a line is about, and of the entity it is handled for. Given on the
|
|
165
|
+
log call, they are annotations of the log effect itself, so they reach the line also when it
|
|
166
|
+
runs on a fiber of its own (`->Effect.runSync`), and they win over the same fields the
|
|
167
|
+
invocation annotated: one invocation can carry messages of several flows. */
|
|
168
|
+
type ids = {
|
|
169
|
+
msgId?: string,
|
|
170
|
+
correlationId?: string,
|
|
171
|
+
causationId?: string,
|
|
172
|
+
entityId?: string,
|
|
173
|
+
entityType?: string,
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
/** The ids of a message, from its meta; the entity when the caller knows it. */
|
|
177
|
+
let idsOf = (~entityId=?, ~entityType=?, meta: Message.meta): ids => {
|
|
178
|
+
msgId: meta.msgId,
|
|
179
|
+
correlationId: meta.correlationId,
|
|
180
|
+
causationId: ?meta.causationId,
|
|
181
|
+
?entityId,
|
|
182
|
+
?entityType,
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/** The ids of the event a work item came from: an automation's or a translation's row. */
|
|
186
|
+
let idsOfSource = (source: Message.flowSource): ids => {
|
|
187
|
+
msgId: source.msgId,
|
|
188
|
+
correlationId: source.correlationId,
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** The ids of a message given as JSON, read from its `meta` without decoding the rest; none
|
|
192
|
+
when it has no meta. */
|
|
193
|
+
let idsOfJson = (json: JSON.t): option<ids> =>
|
|
194
|
+
switch json {
|
|
195
|
+
| JSON.Object(d) =>
|
|
196
|
+
switch d->Dict.get("meta") {
|
|
197
|
+
| Some(JSON.Object(m)) =>
|
|
198
|
+
let str = k =>
|
|
199
|
+
switch m->Dict.get(k) {
|
|
200
|
+
| Some(JSON.String(s)) if s != "" => Some(s)
|
|
201
|
+
| _ => None
|
|
202
|
+
}
|
|
203
|
+
Some({
|
|
204
|
+
msgId: ?str("msgId"),
|
|
205
|
+
correlationId: ?str("correlationId"),
|
|
206
|
+
causationId: ?str("causationId"),
|
|
207
|
+
})
|
|
208
|
+
| _ => None
|
|
209
|
+
}
|
|
210
|
+
| _ => None
|
|
167
211
|
}
|
|
168
|
-
|
|
169
|
-
|
|
212
|
+
|
|
213
|
+
// Attach comp/detail/ids as annotations on the log effect. detail is stringified
|
|
214
|
+
// so it rides through Effect's string-keyed annotation map; install() re-parses it.
|
|
215
|
+
let _annotate = (eff, ~comp=?, ~detail=?, ~ids: option<ids>=?) => {
|
|
216
|
+
let one = (eff, key, value) =>
|
|
217
|
+
switch value {
|
|
218
|
+
| Some(v) => eff->Effect.annotateLogs(key, v)
|
|
219
|
+
| None => eff
|
|
220
|
+
}
|
|
221
|
+
let eff = eff->one("comp", comp)->one("detail", detail->Option.map(d => d->JSON.stringify))
|
|
222
|
+
switch ids {
|
|
223
|
+
| Some(i) =>
|
|
224
|
+
eff
|
|
225
|
+
->one("msgId", i.msgId)
|
|
226
|
+
->one("correlationId", i.correlationId)
|
|
227
|
+
->one("causationId", i.causationId)
|
|
228
|
+
->one("entityId", i.entityId)
|
|
229
|
+
->one("entityType", i.entityType)
|
|
170
230
|
| None => eff
|
|
171
231
|
}
|
|
172
232
|
}
|
|
173
233
|
|
|
174
|
-
let logInfo = (~comp=?, ~detail=?, msg) =>
|
|
175
|
-
Effect.logInfo(msg)
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
let
|
|
179
|
-
Effect.
|
|
180
|
-
|
|
181
|
-
|
|
234
|
+
let logInfo = (~comp=?, ~detail=?, ~ids=?, msg) =>
|
|
235
|
+
Effect.logInfo(msg)
|
|
236
|
+
->_annotate(~comp?, ~detail?, ~ids?)
|
|
237
|
+
->_withMinimumLogLevel(_effectMin(~comp?, ()))
|
|
238
|
+
let logWarn = (~comp=?, ~detail=?, ~ids=?, msg) =>
|
|
239
|
+
Effect.logWarning(msg)
|
|
240
|
+
->_annotate(~comp?, ~detail?, ~ids?)
|
|
241
|
+
->_withMinimumLogLevel(_effectMin(~comp?, ()))
|
|
242
|
+
let logError = (~comp=?, ~detail=?, ~ids=?, msg) =>
|
|
243
|
+
Effect.logError(msg)
|
|
244
|
+
->_annotate(~comp?, ~detail?, ~ids?)
|
|
245
|
+
->_withMinimumLogLevel(_effectMin(~comp?, ()))
|
|
246
|
+
let logDebug = (~comp=?, ~detail=?, ~ids=?, msg) =>
|
|
247
|
+
Effect.logDebug(msg)
|
|
248
|
+
->_annotate(~comp?, ~detail?, ~ids?)
|
|
249
|
+
->_withMinimumLogLevel(_effectMin(~comp?, ()))
|
|
@@ -113,29 +113,77 @@ function install() {
|
|
|
113
113
|
|
|
114
114
|
install();
|
|
115
115
|
|
|
116
|
-
function
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
116
|
+
function idsOf(entityId, entityType, meta) {
|
|
117
|
+
return {
|
|
118
|
+
msgId: meta.msgId,
|
|
119
|
+
correlationId: meta.correlationId,
|
|
120
|
+
causationId: meta.causationId,
|
|
121
|
+
entityId: entityId,
|
|
122
|
+
entityType: entityType
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function idsOfSource(source) {
|
|
127
|
+
return {
|
|
128
|
+
msgId: source.msgId,
|
|
129
|
+
correlationId: source.correlationId
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function idsOfJson(json) {
|
|
134
|
+
if (typeof json !== "object" || json === null || Array.isArray(json)) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
let match = json["meta"];
|
|
138
|
+
if (match === undefined) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (typeof match !== "object" || match === null || Array.isArray(match)) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
let str = k => {
|
|
145
|
+
let match$1 = match[k];
|
|
146
|
+
if (typeof match$1 === "string" && match$1 !== "") {
|
|
147
|
+
return match$1;
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
return {
|
|
151
|
+
msgId: str("msgId"),
|
|
152
|
+
correlationId: str("correlationId"),
|
|
153
|
+
causationId: str("causationId")
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function _annotate(eff, comp, detail, ids) {
|
|
158
|
+
let one = (eff, key, value) => {
|
|
159
|
+
if (value !== undefined) {
|
|
160
|
+
return Effect.annotateLogs(eff, key, value);
|
|
161
|
+
} else {
|
|
162
|
+
return eff;
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
let eff$1 = one(one(eff, "comp", comp), "detail", Stdlib_Option.map(detail, d => JSON.stringify(d)));
|
|
166
|
+
if (ids !== undefined) {
|
|
167
|
+
return one(one(one(one(one(eff$1, "msgId", ids.msgId), "correlationId", ids.correlationId), "causationId", ids.causationId), "entityId", ids.entityId), "entityType", ids.entityType);
|
|
120
168
|
} else {
|
|
121
169
|
return eff$1;
|
|
122
170
|
}
|
|
123
171
|
}
|
|
124
172
|
|
|
125
|
-
function logInfo(comp, detail, msg) {
|
|
126
|
-
return Logger.withMinimumLogLevel(_annotate(Effect.logInfo(msg), comp, detail), _effectMin(comp, undefined));
|
|
173
|
+
function logInfo(comp, detail, ids, msg) {
|
|
174
|
+
return Logger.withMinimumLogLevel(_annotate(Effect.logInfo(msg), comp, detail, ids), _effectMin(comp, undefined));
|
|
127
175
|
}
|
|
128
176
|
|
|
129
|
-
function logWarn(comp, detail, msg) {
|
|
130
|
-
return Logger.withMinimumLogLevel(_annotate(Effect.logWarning(msg), comp, detail), _effectMin(comp, undefined));
|
|
177
|
+
function logWarn(comp, detail, ids, msg) {
|
|
178
|
+
return Logger.withMinimumLogLevel(_annotate(Effect.logWarning(msg), comp, detail, ids), _effectMin(comp, undefined));
|
|
131
179
|
}
|
|
132
180
|
|
|
133
|
-
function logError(comp, detail, msg) {
|
|
134
|
-
return Logger.withMinimumLogLevel(_annotate(Effect.logError(msg), comp, detail), _effectMin(comp, undefined));
|
|
181
|
+
function logError(comp, detail, ids, msg) {
|
|
182
|
+
return Logger.withMinimumLogLevel(_annotate(Effect.logError(msg), comp, detail, ids), _effectMin(comp, undefined));
|
|
135
183
|
}
|
|
136
184
|
|
|
137
|
-
function logDebug(comp, detail, msg) {
|
|
138
|
-
return Logger.withMinimumLogLevel(_annotate(Effect.logDebug(msg), comp, detail), _effectMin(comp, undefined));
|
|
185
|
+
function logDebug(comp, detail, ids, msg) {
|
|
186
|
+
return Logger.withMinimumLogLevel(_annotate(Effect.logDebug(msg), comp, detail, ids), _effectMin(comp, undefined));
|
|
139
187
|
}
|
|
140
188
|
|
|
141
189
|
let setDefaultMinLevel = Logger$ReventlessCore.setDefaultMinLevel;
|
|
@@ -146,6 +194,9 @@ export {
|
|
|
146
194
|
_effectMin,
|
|
147
195
|
ordinalToLevel,
|
|
148
196
|
install,
|
|
197
|
+
idsOf,
|
|
198
|
+
idsOfSource,
|
|
199
|
+
idsOfJson,
|
|
149
200
|
_annotate,
|
|
150
201
|
logInfo,
|
|
151
202
|
logWarn,
|
|
@@ -45,7 +45,7 @@ function ftp(connectionParams, ftpAction) {
|
|
|
45
45
|
readyTimeout: readyTimeout
|
|
46
46
|
});
|
|
47
47
|
SSH2.Client.onReady(client.on("end", () => {
|
|
48
|
-
Effect.runSync(EffectLogger$ReventlessCore.logInfo("FTPHandler-ReventlessCore", undefined, "Client.onEnd"));
|
|
48
|
+
Effect.runSync(EffectLogger$ReventlessCore.logInfo("FTPHandler-ReventlessCore", undefined, undefined, "Client.onEnd"));
|
|
49
49
|
resolve(result.contents);
|
|
50
50
|
}).on("error", err => resolve({
|
|
51
51
|
TAG: "Error",
|
|
@@ -74,8 +74,8 @@ function ftp(connectionParams, ftpAction) {
|
|
|
74
74
|
let endFtp = () => {
|
|
75
75
|
client.end();
|
|
76
76
|
};
|
|
77
|
-
sftp.on("end", () => Effect.runSync(EffectLogger$ReventlessCore.logInfo("FTPHandler-ReventlessCore", undefined, "end sftp stream"))).on("error", err => {
|
|
78
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError("FTPHandler-ReventlessCore", undefined, `Error: ` + Stdlib_Option.getOr(JSON.stringify(err), "unknown")));
|
|
77
|
+
sftp.on("end", () => Effect.runSync(EffectLogger$ReventlessCore.logInfo("FTPHandler-ReventlessCore", undefined, undefined, "end sftp stream"))).on("error", err => {
|
|
78
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError("FTPHandler-ReventlessCore", undefined, undefined, `Error: ` + Stdlib_Option.getOr(JSON.stringify(err), "unknown")));
|
|
79
79
|
client.emit("error", err);
|
|
80
80
|
client.end();
|
|
81
81
|
});
|
|
@@ -109,16 +109,16 @@ function ftp(connectionParams, ftpAction) {
|
|
|
109
109
|
TAG: "Ok",
|
|
110
110
|
_0: true
|
|
111
111
|
};
|
|
112
|
-
Effect.runSync(EffectLogger$ReventlessCore.logInfo("FTPHandler-ReventlessCore", undefined, "writable ended"));
|
|
112
|
+
Effect.runSync(EffectLogger$ReventlessCore.logInfo("FTPHandler-ReventlessCore", undefined, undefined, "writable ended"));
|
|
113
113
|
}).on("close", () => {
|
|
114
114
|
result.contents = {
|
|
115
115
|
TAG: "Ok",
|
|
116
116
|
_0: true
|
|
117
117
|
};
|
|
118
|
-
Effect.runSync(EffectLogger$ReventlessCore.logInfo("FTPHandler-ReventlessCore", undefined, "writable closed"));
|
|
118
|
+
Effect.runSync(EffectLogger$ReventlessCore.logInfo("FTPHandler-ReventlessCore", undefined, undefined, "writable closed"));
|
|
119
119
|
client.end();
|
|
120
120
|
}).on("error", err => {
|
|
121
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError("FTPHandler-ReventlessCore", undefined, `Error in Write Stream: ` + Stdlib_Option.getOr(Stdlib_JsExn.message(err), "unknown")));
|
|
121
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError("FTPHandler-ReventlessCore", undefined, undefined, `Error in Write Stream: ` + Stdlib_Option.getOr(Stdlib_JsExn.message(err), "unknown")));
|
|
122
122
|
let err$1 = new Error("FTPHandler: Error in Write Stream");
|
|
123
123
|
sftp.emit("error", err$1);
|
|
124
124
|
});
|
|
@@ -42,12 +42,12 @@ function create(scheduler, channelResources, resourceNaming) {
|
|
|
42
42
|
payload: schedule_payload
|
|
43
43
|
};
|
|
44
44
|
let createSchedule = scheduler.createSchedule;
|
|
45
|
-
let exit = await Effect$1.runPromiseExit(Effect$1.tap(Effect.tryPromise(err => Util_Error$ReventlessCore.messageFromUnknown(err, "schedule create"), () => createSchedule(channelResources, schedule$1)), () => EffectLogger$ReventlessCore.logInfo("ScheduleOps-ReventlessCore", undefined, `create: created ` + Stdlib_Option.getOr(JSON.stringify(schedule$1), ""))));
|
|
45
|
+
let exit = await Effect$1.runPromiseExit(Effect$1.tap(Effect.tryPromise(err => Util_Error$ReventlessCore.messageFromUnknown(err, "schedule create"), () => createSchedule(channelResources, schedule$1)), () => EffectLogger$ReventlessCore.logInfo("ScheduleOps-ReventlessCore", undefined, undefined, `create: created ` + Stdlib_Option.getOr(JSON.stringify(schedule$1), ""))));
|
|
46
46
|
if (Exit$1.isSuccess(exit)) {
|
|
47
47
|
return;
|
|
48
48
|
}
|
|
49
49
|
let errMsg = Exit.match(exit, cause => Cause.pretty(cause), () => "unknown");
|
|
50
|
-
Effect$1.runSync(EffectLogger$ReventlessCore.logError("ScheduleOps-ReventlessCore", undefined, `create: couldn't create ` + Stdlib_Option.getOr(JSON.stringify(schedule$1), "") + `: ` + errMsg));
|
|
50
|
+
Effect$1.runSync(EffectLogger$ReventlessCore.logError("ScheduleOps-ReventlessCore", undefined, undefined, `create: couldn't create ` + Stdlib_Option.getOr(JSON.stringify(schedule$1), "") + `: ` + errMsg));
|
|
51
51
|
throw {
|
|
52
52
|
RE_EXN_ID: ScheduleNotCreated,
|
|
53
53
|
_1: schedule$1,
|
|
@@ -60,12 +60,12 @@ function $$delete(scheduler, channelResources, resourceNaming) {
|
|
|
60
60
|
return async name => {
|
|
61
61
|
let name$1 = resourceNaming.validateName(name);
|
|
62
62
|
let deleteSchedule = scheduler.deleteSchedule;
|
|
63
|
-
let exit = await Effect$1.runPromiseExit(Effect$1.tap(Effect.tryPromise(err => Util_Error$ReventlessCore.messageFromUnknown(err, "schedule delete"), () => deleteSchedule(channelResources, name$1)), () => EffectLogger$ReventlessCore.logInfo("ScheduleOps-ReventlessCore", undefined, `delete: deleted ` + name$1)));
|
|
63
|
+
let exit = await Effect$1.runPromiseExit(Effect$1.tap(Effect.tryPromise(err => Util_Error$ReventlessCore.messageFromUnknown(err, "schedule delete"), () => deleteSchedule(channelResources, name$1)), () => EffectLogger$ReventlessCore.logInfo("ScheduleOps-ReventlessCore", undefined, undefined, `delete: deleted ` + name$1)));
|
|
64
64
|
if (Exit$1.isSuccess(exit)) {
|
|
65
65
|
return;
|
|
66
66
|
}
|
|
67
67
|
let errMsg = Exit.match(exit, cause => Cause.pretty(cause), () => "unknown");
|
|
68
|
-
Effect$1.runSync(EffectLogger$ReventlessCore.logError("ScheduleOps-ReventlessCore", undefined, `delete: couldn't delete ` + name$1 + `: ` + errMsg));
|
|
68
|
+
Effect$1.runSync(EffectLogger$ReventlessCore.logError("ScheduleOps-ReventlessCore", undefined, undefined, `delete: couldn't delete ` + name$1 + `: ` + errMsg));
|
|
69
69
|
throw {
|
|
70
70
|
RE_EXN_ID: ScheduleNotDeleted,
|
|
71
71
|
_1: name$1,
|
|
@@ -19,7 +19,7 @@ function findResource(resources, service) {
|
|
|
19
19
|
return matching[0];
|
|
20
20
|
}
|
|
21
21
|
let err = `Util.Adapter.findResource: Couldn't find service ` + service + ` in resources: ` + resources.map(res => Stdlib_Option.getOrThrow(JSON.stringify(res), undefined)).join(", ");
|
|
22
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError("Util_AdapterRuntime-ReventlessCore", undefined, err));
|
|
22
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError("Util_AdapterRuntime-ReventlessCore", undefined, undefined, err));
|
|
23
23
|
return Stdlib_JsError.throwWithMessage(err);
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -29,7 +29,7 @@ function findResolvedResource(resources, service) {
|
|
|
29
29
|
return resources$1[0];
|
|
30
30
|
}
|
|
31
31
|
let err = `Util.Adapter.findResolvedResource: Couldn't find service ` + service + ` in resources: ` + resources.map(res => Stdlib_Option.getOrThrow(JSON.stringify(res), undefined)).join(", ");
|
|
32
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError("Util_AdapterRuntime-ReventlessCore", undefined, err));
|
|
32
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError("Util_AdapterRuntime-ReventlessCore", undefined, undefined, err));
|
|
33
33
|
return Stdlib_JsError.throwWithMessage(err);
|
|
34
34
|
}
|
|
35
35
|
|
|
@@ -70,7 +70,7 @@ async function onEndHandler(flush, resolve) {
|
|
|
70
70
|
} catch (raw_e) {
|
|
71
71
|
let e = Primitive_exceptions.internalToException(raw_e);
|
|
72
72
|
if (e.RE_EXN_ID === "JsExn") {
|
|
73
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError("Util_Promise-ReventlessCore", undefined, "File \"Util_Promise.res\", line 57, characters 9-16" + `: ` + Stdlib_Option.getOr(Stdlib_JsExn.message(e._1), "unknown")));
|
|
73
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError("Util_Promise-ReventlessCore", undefined, undefined, "File \"Util_Promise.res\", line 57, characters 9-16" + `: ` + Stdlib_Option.getOr(Stdlib_JsExn.message(e._1), "unknown")));
|
|
74
74
|
} else {
|
|
75
75
|
throw e;
|
|
76
76
|
}
|
|
@@ -8,7 +8,7 @@ function getRuntimeResource(allQueryDbs, queryDbName) {
|
|
|
8
8
|
try {
|
|
9
9
|
return Stdlib_Option.getOrThrow(allQueryDbs[queryDbName], undefined);
|
|
10
10
|
} catch (exn) {
|
|
11
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError("Util_QueryDbRuntime-ReventlessCore", undefined, `getRuntimeResource: Couldn't find QueryDb ` + queryDbName + ` in ` + Object.keys(allQueryDbs).join(", ")));
|
|
11
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError("Util_QueryDbRuntime-ReventlessCore", undefined, undefined, `getRuntimeResource: Couldn't find QueryDb ` + queryDbName + ` in ` + Object.keys(allQueryDbs).join(", ")));
|
|
12
12
|
throw exn;
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -105,7 +105,7 @@ function merge(v1, v2) {
|
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
function defaultErrorHandler(err) {
|
|
108
|
-
Effect.runSync(EffectLogger$ReventlessCore.logError("Validation-ReventlessCore", undefined, Util_Sury$Reventless.exnMessage(err, undefined)));
|
|
108
|
+
Effect.runSync(EffectLogger$ReventlessCore.logError("Validation-ReventlessCore", undefined, undefined, Util_Sury$Reventless.exnMessage(err, undefined)));
|
|
109
109
|
return {
|
|
110
110
|
TAG: "Failure",
|
|
111
111
|
_0: "Couldn't resolve promise."
|
|
@@ -346,3 +346,68 @@ describe("the caller claim on the envelope:", () => {
|
|
|
346
346
|
expect(Message.deriveMeta(~parent).callerClaim)->toEqual(None)
|
|
347
347
|
})
|
|
348
348
|
})
|
|
349
|
+
|
|
350
|
+
describe("the command's entry names the command on its lines", () => {
|
|
351
|
+
let capture = async (run: unit => promise<unit>) => {
|
|
352
|
+
let lines = []
|
|
353
|
+
let remove = Logger.addSink(r => lines->Array.push(r))
|
|
354
|
+
await run()
|
|
355
|
+
remove()
|
|
356
|
+
lines
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
testPromise("a generated command's line carries its own msgId and flow", async () => {
|
|
360
|
+
let lines = await capture(
|
|
361
|
+
async () => {
|
|
362
|
+
let _ = await generate(
|
|
363
|
+
placeOrder(~customerId="cust-A", ~identity=cognito(~userId="cust-A", ~groups=[])),
|
|
364
|
+
)->Effect.runPromise
|
|
365
|
+
},
|
|
366
|
+
)
|
|
367
|
+
let line =
|
|
368
|
+
lines->Array.find(r => r.message->String.startsWith("generated command"))->Option.getOrThrow
|
|
369
|
+
let msgId = line.annotations->Dict.get("msgId")
|
|
370
|
+
expect(msgId->Option.isSome)->toBe(true)
|
|
371
|
+
// A command sent from outside starts its own flow.
|
|
372
|
+
expect(line.annotations->Dict.get("correlationId"))->toEqual(msgId)
|
|
373
|
+
expect(Some(lastPublished().meta.msgId))->toEqual(msgId)
|
|
374
|
+
})
|
|
375
|
+
|
|
376
|
+
testPromise(
|
|
377
|
+
"a refusal before the handler is logged with the command's ids, and heard",
|
|
378
|
+
async () => {
|
|
379
|
+
let heard = []
|
|
380
|
+
let remove = CommandTopic_Helpers.registerCommandOutcome(r => heard->Array.push(r))
|
|
381
|
+
let lines = await capture(
|
|
382
|
+
async () =>
|
|
383
|
+
switch await generate(
|
|
384
|
+
placeOrder(~customerId="cust-B", ~identity=Reventless.Identity.anonymous),
|
|
385
|
+
)->Effect.runPromise {
|
|
386
|
+
| _ => ()
|
|
387
|
+
| exception _ => ()
|
|
388
|
+
},
|
|
389
|
+
)
|
|
390
|
+
remove()
|
|
391
|
+
let line =
|
|
392
|
+
lines
|
|
393
|
+
->Array.find(r => r.message->String.startsWith("refused before its handler"))
|
|
394
|
+
->Option.getOrThrow
|
|
395
|
+
expect(line.level)->toEqual(Logger.Warn)
|
|
396
|
+
expect(line.annotations->Dict.get("msgId")->Option.isSome)->toBe(true)
|
|
397
|
+
expect(
|
|
398
|
+
heard->Array.map(
|
|
399
|
+
r => (r.component, r.reference == line.annotations->Dict.get("msgId")->Option.getOr("")),
|
|
400
|
+
),
|
|
401
|
+
)->toEqual([("Ordering", true)])
|
|
402
|
+
expect(
|
|
403
|
+
heard->Array.map(
|
|
404
|
+
r =>
|
|
405
|
+
switch r.outcome {
|
|
406
|
+
| OutcomeRejected({cause: AccessRefusal}) => true
|
|
407
|
+
| _ => false
|
|
408
|
+
},
|
|
409
|
+
),
|
|
410
|
+
)->toEqual([true])
|
|
411
|
+
},
|
|
412
|
+
)
|
|
413
|
+
})
|