@reventlessdev/reventless-core 3.0.0-alpha.170 → 3.0.0-alpha.172
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 +14 -0
- package/package.json +14 -14
- package/src/components/ExtensionPoint/ExtensionPoint_Builder.res +5 -2
- package/src/components/ExtensionPoint/ExtensionPoint_Builder.res.mjs +3 -3
- package/src/components/Heartbeat/Heartbeat.res +2 -2
- package/src/components/Heartbeat/Heartbeat_Builder.res +2 -2
- package/src/components/Heartbeat/Heartbeat_Builder.res.mjs +2 -4
- package/src/components/Task/Task_Builder.res +6 -4
- package/src/components/Task/Task_Builder.res.mjs +4 -4
- package/src/plugin/component/Plugin_Builder.res +5 -1
- package/src/plugin/component/Plugin_Builder.res.mjs +1 -1
- package/src/plugin/component/Plugin_Helpers.res +6 -1
- package/src/plugin/connect/PluginExtensionPoint_Builder.res +2 -0
- package/src/plugin/connect/PluginExtensionPoint_Builder.res.mjs +3 -3
- package/src/plugin/connect/PluginExtensionPoint_Plugin.res +12 -5
- package/src/plugin/connect/PluginExtensionPoint_Plugin.res.mjs +8 -2
- package/tests/plugin/HeartbeatDisconnectGraceTest.res +98 -0
- package/tests/IdentityTest.res.mjs +0 -174
- package/tests/adapter/MonitoringTest.res.mjs +0 -82
- package/tests/admin/Platform_ComponentDefinitionsApiTest.res.mjs +0 -356
- package/tests/admin/Platform_UIFragmentsApiTest.res.mjs +0 -101
- package/tests/aggregate/AggregateCacheTest.res.mjs +0 -433
- package/tests/aggregate/AggregateCallbackTest.res.mjs +0 -143
- package/tests/aggregate/AggregateCausationTest.res.mjs +0 -47
- package/tests/aggregate/AggregateConflictTest.res.mjs +0 -386
- package/tests/aggregate/AggregateFixtures.res.mjs +0 -308
- package/tests/aggregate/AggregateRejectionTest.res.mjs +0 -166
- package/tests/aggregate/AggregateSnapshotTest.res.mjs +0 -645
- package/tests/api/ApiNoApiTest.res.mjs +0 -90
- package/tests/api/GraphQL_StitcherTest.res.mjs +0 -112
- package/tests/api/SimpleTest.res.mjs +0 -10
- package/tests/api/SuryToJsonSchemaTest.res.mjs +0 -674
- package/tests/commandgenerator/CommandGeneratorCallbackTest.res.mjs +0 -160
- package/tests/commandgenerator/CommandGeneratorFixtures.res.mjs +0 -197
- package/tests/commandtopic/CommandTopicCallbackFixtures.res.mjs +0 -152
- package/tests/commandtopic/CommandTopicCallbackTest.res.mjs +0 -106
- package/tests/commandtopic/CommandTopicHelpersRejectionTest.res.mjs +0 -109
- package/tests/counter/CounterCallbackTest.res.mjs +0 -140
- package/tests/counter/CounterFixtures.res.mjs +0 -67
- package/tests/dcb/DcbDecodeTest.res.mjs +0 -194
- package/tests/dcb/DcbEventLogOperationsTest.res.mjs +0 -268
- package/tests/dcb/DcbFixtures.res.mjs +0 -534
- package/tests/dcb/DcbScopeInferenceTest.res.mjs +0 -480
- package/tests/dcb/DcbStateChangeSliceTest.res.mjs +0 -540
- package/tests/dcb/DcbTagTest.res.mjs +0 -867
- package/tests/dcb/DcbValidationTest.res.mjs +0 -476
- package/tests/eventlog/EventLogFixtures.res.mjs +0 -196
- package/tests/eventlog/EventLogOperationsTest.res.mjs +0 -192
- package/tests/eventlog/EventLogRetryTest.res.mjs +0 -195
- package/tests/eventmapper/EventMapperCallbackTest.res.mjs +0 -141
- package/tests/eventmapper/EventMapperFixtures.res.mjs +0 -440
- package/tests/eventmapper/EventMapperTest.res.mjs +0 -83
- package/tests/eventtopic/EventTopicFixtures.res.mjs +0 -65
- package/tests/eventtopic/EventTopicOperationsTest.res.mjs +0 -71
- package/tests/extensionpoint/ExtensionPointCallbackTest.res.mjs +0 -94
- package/tests/extensionpoint/ExtensionPointFixtures.res.mjs +0 -205
- package/tests/extensionpoint/ExtensionPointOperationsTest.res.mjs +0 -304
- package/tests/ftp/FTPTest.res.mjs +0 -88
- package/tests/logger/LogFormatTest.res.mjs +0 -309
- package/tests/logger/LoggerLazyTest.res.mjs +0 -40
- package/tests/message/MessageTest.res.mjs +0 -218
- package/tests/message/MetaEnvelopeTest.res.mjs +0 -188
- package/tests/plugin/ManifestVisibilityTest.res.mjs +0 -215
- package/tests/plugin/PluginSpecExperiment.res.mjs +0 -31
- package/tests/plugin/PluginStructureTest.res.mjs +0 -419
- package/tests/plugin/PluginVersionTest.res.mjs +0 -30
- package/tests/plugin/SchemaWalkerTest.res.mjs +0 -160
- package/tests/plugin/StateChangeSlice/PsPlaceOrder.res.mjs +0 -62
- package/tests/plugin/StateChangeSlice/PsShipOrder.res.mjs +0 -69
- package/tests/plugin/StateViewSlice/PsAnnotatedView.res.mjs +0 -95
- package/tests/plugin/StateViewSlice/PsAvailableProductsView.res.mjs +0 -69
- package/tests/plugin/StateViewSlice/PsCustomersView.res.mjs +0 -69
- package/tests/plugin/StateViewSlice/PsOrdersView.res.mjs +0 -81
- package/tests/poc/StructuralSubtypingPoc.res.mjs +0 -61
- package/tests/projection/ProjectionOptimizeTest.res.mjs +0 -75
- package/tests/querydb/QueryDbFixtures.res.mjs +0 -135
- package/tests/querydb/QueryDbOperationsTest.res.mjs +0 -168
- package/tests/sideeffecthandler/SideEffectHandlerCallbackTest.res.mjs +0 -77
- package/tests/sideeffecthandler/SideEffectHandlerFixtures.res.mjs +0 -139
- package/tests/util/CommandPublisherTest.res.mjs +0 -78
- package/tests/util/CsvStreamTest.res.mjs +0 -51
- package/tests/util/LruTest.res.mjs +0 -105
- package/tests/util/MetricsTest.res.mjs +0 -53
|
@@ -1,309 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
import * as S from "sury/src/S.res.mjs";
|
|
4
|
-
import * as Stdlib_Dict from "@rescript/runtime/lib/es6/Stdlib_Dict.js";
|
|
5
|
-
import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
|
|
6
|
-
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
7
|
-
import * as Effect from "effect/Effect";
|
|
8
|
-
import * as Primitive_object from "@rescript/runtime/lib/es6/Primitive_object.js";
|
|
9
|
-
import * as AnsiStyle$Reventless from "@reventlessdev/reventless-spec/src/AnsiStyle.res.mjs";
|
|
10
|
-
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
11
|
-
import * as Logger$ReventlessCore from "../../src/util/Logger.res.mjs";
|
|
12
|
-
import * as Message$ReventlessCore from "../../src/Message.res.mjs";
|
|
13
|
-
import * as LogFormat$ReventlessCore from "../../src/util/LogFormat.res.mjs";
|
|
14
|
-
import * as PluginSpec$ReventlessCore from "../../src/plugin/lifecycle/PluginSpec.res.mjs";
|
|
15
|
-
import * as EffectLogger$ReventlessCore from "../../src/util/EffectLogger.res.mjs";
|
|
16
|
-
|
|
17
|
-
S.enableJson();
|
|
18
|
-
|
|
19
|
-
process.env["REVENTLESS_LOG_FORMAT"] = "text";
|
|
20
|
-
|
|
21
|
-
AnsiStyle$Reventless.reload();
|
|
22
|
-
|
|
23
|
-
globalThis.describe("LogFormat", () => {
|
|
24
|
-
globalThis.describe("commandJsonsToLogMessages", () => {
|
|
25
|
-
globalThis.test("empty", () => {
|
|
26
|
-
let arr = [];
|
|
27
|
-
globalThis.expect(LogFormat$ReventlessCore.commandJsonsToLogMessages(arr)).toEqual([]);
|
|
28
|
-
});
|
|
29
|
-
globalThis.test("simple", () => {
|
|
30
|
-
let commands = [{
|
|
31
|
-
TAG: "Heartbeat",
|
|
32
|
-
_0: "0.0.0"
|
|
33
|
-
}];
|
|
34
|
-
let meta = {
|
|
35
|
-
service: "testService",
|
|
36
|
-
time: "testTime",
|
|
37
|
-
ip: "testIp",
|
|
38
|
-
user: "testUser",
|
|
39
|
-
msgId: "testMsgId",
|
|
40
|
-
correlationId: "testCorrelationId"
|
|
41
|
-
};
|
|
42
|
-
let metaStr = JSON.stringify(Message$ReventlessCore.encode(meta, Message$ReventlessCore.metaSchema));
|
|
43
|
-
let arr = commands.map((command, idx) => ({
|
|
44
|
-
id: idx.toString(),
|
|
45
|
-
meta: meta,
|
|
46
|
-
commandJson: Message$ReventlessCore.encode(command, PluginSpec$ReventlessCore.commandSchema)
|
|
47
|
-
}));
|
|
48
|
-
let expected = `1/1: \x1b[1mHeartbeat\x1b[0m(0): {"command":{"TAG":"Heartbeat","_0":"0.0.0"},"meta":` + metaStr + `,"id":"0"}`;
|
|
49
|
-
globalThis.expect(LogFormat$ReventlessCore.commandJsonsToLogMessages(arr)).toEqual([expected]);
|
|
50
|
-
});
|
|
51
|
-
globalThis.test("complex", () => {
|
|
52
|
-
let commands = [
|
|
53
|
-
{
|
|
54
|
-
TAG: "Heartbeat",
|
|
55
|
-
_0: "0.0.0"
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
TAG: "Connect",
|
|
59
|
-
_0: {
|
|
60
|
-
id: "id",
|
|
61
|
-
name: "testName",
|
|
62
|
-
version: "testVersion",
|
|
63
|
-
extensionPoints: [{
|
|
64
|
-
name: "testExtensionPoint",
|
|
65
|
-
commandTopic: "testCommandTopic",
|
|
66
|
-
eventTopic: "testEventTopic"
|
|
67
|
-
}],
|
|
68
|
-
extensions: [{
|
|
69
|
-
name: "testExtension",
|
|
70
|
-
extensionPointName: "testExtensionPoint",
|
|
71
|
-
dcbSources: []
|
|
72
|
-
}],
|
|
73
|
-
eventCollector: "testEventCollector",
|
|
74
|
-
extensionProtocols: [],
|
|
75
|
-
apiSchemaFragment: undefined,
|
|
76
|
-
apiTarget: undefined,
|
|
77
|
-
structure: undefined,
|
|
78
|
-
dcbEventLog: undefined,
|
|
79
|
-
kind: "Domain"
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
];
|
|
83
|
-
let meta = {
|
|
84
|
-
service: "testService",
|
|
85
|
-
time: "testTime",
|
|
86
|
-
ip: "testIp",
|
|
87
|
-
user: "testUser",
|
|
88
|
-
msgId: "testMsgId",
|
|
89
|
-
correlationId: "testCorrelationId"
|
|
90
|
-
};
|
|
91
|
-
let metaStr = JSON.stringify(Message$ReventlessCore.encode(meta, Message$ReventlessCore.metaSchema));
|
|
92
|
-
let arr = commands.map((command, idx) => ({
|
|
93
|
-
id: idx.toString(),
|
|
94
|
-
meta: meta,
|
|
95
|
-
commandJson: Message$ReventlessCore.encode(command, PluginSpec$ReventlessCore.commandSchema)
|
|
96
|
-
}));
|
|
97
|
-
let expected1 = `1/2: \x1b[1mHeartbeat\x1b[0m(0): {"command":{"TAG":"Heartbeat","_0":"0.0.0"},"meta":` + metaStr + `,"id":"0"}`;
|
|
98
|
-
let expected2 = `2/2: \x1b[1mConnect\x1b[0m(1): {"command":{"TAG":"Connect","_0":{"id":"id","name":"testName","version":"testVersion","extensionPoints":[{"name":"testExtensionPoint","commandTopic":"testCommandTopic","eventTopic":"testEventTopic"}],"extensions":[{"name":"testExtension","extensionPointName":"testExtensionPoint","dcbSources":[]}],"eventCollector":"testEventCollector","extensionProtocols":[],"apiSchemaFragment":null,"apiTarget":null,"structure":null,"dcbEventLog":null,"kind":"Domain"}},"meta":` + metaStr + `,"id":"1"}`;
|
|
99
|
-
globalThis.expect(LogFormat$ReventlessCore.commandJsonsToLogMessages(arr)).toEqual([
|
|
100
|
-
expected1,
|
|
101
|
-
expected2
|
|
102
|
-
]);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
globalThis.describe("event'JsonToLogMessage", () => {
|
|
106
|
-
globalThis.test("simple", () => {
|
|
107
|
-
let eventJson$p = Message$ReventlessCore.encodeEvent$p({
|
|
108
|
-
id: "testId",
|
|
109
|
-
meta: {
|
|
110
|
-
service: "testService",
|
|
111
|
-
time: "testTime",
|
|
112
|
-
ip: "testIp",
|
|
113
|
-
user: "testUser",
|
|
114
|
-
msgId: "testMsgId",
|
|
115
|
-
correlationId: "testCorrelationId"
|
|
116
|
-
},
|
|
117
|
-
event: {
|
|
118
|
-
TAG: "VersionDetected",
|
|
119
|
-
_0: "0.0.0"
|
|
120
|
-
}
|
|
121
|
-
}, S.string, PluginSpec$ReventlessCore.eventSchema);
|
|
122
|
-
let msg = LogFormat$ReventlessCore.event$pJsonToLogMessage(eventJson$p);
|
|
123
|
-
globalThis.expect(msg).toEqual(`\x1b[1mVersionDetected\x1b[0m(testId): {"event":{"TAG":"VersionDetected","_0":"0.0.0"},"meta":{"service":"testService","time":"testTime","ip":"testIp","user":"testUser","msgId":"testMsgId","correlationId":"testCorrelationId"},"id":"testId"}`);
|
|
124
|
-
});
|
|
125
|
-
});
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
function hasAnsi(s) {
|
|
129
|
-
return s.includes("\x1b");
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
function captureLogs(fn) {
|
|
133
|
-
let captured = [];
|
|
134
|
-
let original = console.log;
|
|
135
|
-
console.log = s => {
|
|
136
|
-
captured.push(s);
|
|
137
|
-
};
|
|
138
|
-
let result;
|
|
139
|
-
try {
|
|
140
|
-
fn();
|
|
141
|
-
result = {
|
|
142
|
-
TAG: "Ok",
|
|
143
|
-
_0: undefined
|
|
144
|
-
};
|
|
145
|
-
} catch (raw_e) {
|
|
146
|
-
let e = Primitive_exceptions.internalToException(raw_e);
|
|
147
|
-
result = {
|
|
148
|
-
TAG: "Error",
|
|
149
|
-
_0: e
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
console.log = original;
|
|
153
|
-
if (result.TAG === "Ok") {
|
|
154
|
-
return captured;
|
|
155
|
-
}
|
|
156
|
-
throw result._0;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
let validLevels = [
|
|
160
|
-
"DEBUG",
|
|
161
|
-
"INFO",
|
|
162
|
-
"WARN",
|
|
163
|
-
"ERROR"
|
|
164
|
-
];
|
|
165
|
-
|
|
166
|
-
function isCleanRecord(line) {
|
|
167
|
-
if (line.includes("\x1b")) {
|
|
168
|
-
return false;
|
|
169
|
-
}
|
|
170
|
-
try {
|
|
171
|
-
let obj = Stdlib_JSON.Decode.object(JSON.parse(line));
|
|
172
|
-
if (obj === undefined) {
|
|
173
|
-
return false;
|
|
174
|
-
}
|
|
175
|
-
let levelOk = Stdlib_Option.mapOr(Stdlib_Option.flatMap(obj["level"], Stdlib_JSON.Decode.string), false, l => validLevels.includes(l));
|
|
176
|
-
let msgOk = Stdlib_Option.isSome(Stdlib_Option.flatMap(obj["message"], Stdlib_JSON.Decode.string));
|
|
177
|
-
if (levelOk) {
|
|
178
|
-
return msgOk;
|
|
179
|
-
} else {
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
} catch (exn) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function fieldOf(line, key) {
|
|
188
|
-
let obj = Stdlib_JSON.Decode.object(JSON.parse(line));
|
|
189
|
-
if (obj !== undefined) {
|
|
190
|
-
return Stdlib_Option.flatMap(obj[key], Stdlib_JSON.Decode.string);
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
globalThis.describe("JSON sink", () => {
|
|
195
|
-
globalThis.beforeAll(() => {
|
|
196
|
-
process.env["REVENTLESS_LOG_FORMAT"] = "json";
|
|
197
|
-
AnsiStyle$Reventless.reload();
|
|
198
|
-
});
|
|
199
|
-
globalThis.afterAll(() => {
|
|
200
|
-
process.env["REVENTLESS_LOG_FORMAT"] = "text";
|
|
201
|
-
AnsiStyle$Reventless.reload();
|
|
202
|
-
});
|
|
203
|
-
let log = Logger$ReventlessCore.makeLogger("Debug");
|
|
204
|
-
globalThis.test("Logger.info emits one clean JSON record with comp as a top-level field", () => {
|
|
205
|
-
let lines = captureLogs(() => log.info("Aggregate(Product)", undefined, "handling command"));
|
|
206
|
-
let line = lines.length === 1 ? lines[0] : "";
|
|
207
|
-
let ok = lines.length === 1 && isCleanRecord(line) && Primitive_object.equal(fieldOf(line, "comp"), "Aggregate(Product)") && Primitive_object.equal(fieldOf(line, "message"), "handling command");
|
|
208
|
-
globalThis.expect(ok).toBe(true);
|
|
209
|
-
});
|
|
210
|
-
globalThis.test("Logger.info resolves plugin to a top-level field when the comp is registered", () => {
|
|
211
|
-
Logger$ReventlessCore.registerComponentPlugin("Product", "Catalog");
|
|
212
|
-
let lines = captureLogs(() => log.info("Aggregate(Product)", undefined, "handling command"));
|
|
213
|
-
let line = lines.length === 1 ? lines[0] : "";
|
|
214
|
-
globalThis.expect(lines.length === 1 && Primitive_object.equal(fieldOf(line, "plugin"), "Catalog")).toBe(true);
|
|
215
|
-
});
|
|
216
|
-
globalThis.test("Logger.warn emits one clean JSON record", () => {
|
|
217
|
-
let lines = captureLogs(() => log.warn("Platform", undefined, "heartbeat skipped"));
|
|
218
|
-
globalThis.expect(lines.length === 1 && isCleanRecord(lines[0])).toBe(true);
|
|
219
|
-
});
|
|
220
|
-
globalThis.test("Logger.error with ~data emits one clean JSON record", () => {
|
|
221
|
-
let lines = captureLogs(() => log.error("Util_AppSync_Caller", JSON.parse(`{"errors":["boom"]}`), "query errors"));
|
|
222
|
-
globalThis.expect(lines.length === 1 && isCleanRecord(lines[0])).toBe(true);
|
|
223
|
-
});
|
|
224
|
-
globalThis.test("EffectLogger.logInfo emits clean JSON through install()", () => {
|
|
225
|
-
let lines = captureLogs(() => Effect.runSync(EffectLogger$ReventlessCore.logInfo("Aggregate(Product)", undefined, "replay done")));
|
|
226
|
-
let allClean = lines.filter(l => !isCleanRecord(l)).length === 0;
|
|
227
|
-
globalThis.expect(lines.length >= 1 && allClean).toBe(true);
|
|
228
|
-
});
|
|
229
|
-
globalThis.test("EffectLogger.logInfo carries ~comp + ~detail as structured fields (no \\x00)", () => {
|
|
230
|
-
let lines = captureLogs(() => Effect.runSync(EffectLogger$ReventlessCore.logInfo("Aggregate(Product)", JSON.parse(`{"id":"p-1"}`), "added")));
|
|
231
|
-
let ok = lines.some(line => {
|
|
232
|
-
let obj = Stdlib_JSON.Decode.object(JSON.parse(line));
|
|
233
|
-
if (obj !== undefined && Primitive_object.equal(Stdlib_Option.flatMap(obj["comp"], Stdlib_JSON.Decode.string), "Aggregate(Product)")) {
|
|
234
|
-
return Primitive_object.equal(Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_Option.flatMap(obj["detail"], Stdlib_JSON.Decode.object), d => d["id"]), Stdlib_JSON.Decode.string), "p-1");
|
|
235
|
-
} else {
|
|
236
|
-
return false;
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
globalThis.expect(ok).toBe(true);
|
|
240
|
-
});
|
|
241
|
-
globalThis.test("Effect.annotateLogs(correlationId) surfaces as a top-level field", () => {
|
|
242
|
-
let lines = captureLogs(() => Effect.runSync(Effect.annotateLogs(EffectLogger$ReventlessCore.logInfo("Aggregate(Product)", undefined, "handling"), "correlationId", "c-123")));
|
|
243
|
-
globalThis.expect(lines.some(line => Primitive_object.equal(fieldOf(line, "correlationId"), "c-123"))).toBe(true);
|
|
244
|
-
});
|
|
245
|
-
globalThis.test("Effect.annotateLogs(plugin) overrides registry resolution", () => {
|
|
246
|
-
let lines = captureLogs(() => Effect.runSync(Effect.annotateLogs(EffectLogger$ReventlessCore.logInfo("Aggregate(Unregistered)", undefined, "handling"), "plugin", "Ordering")));
|
|
247
|
-
globalThis.expect(lines.some(line => Primitive_object.equal(fieldOf(line, "plugin"), "Ordering"))).toBe(true);
|
|
248
|
-
});
|
|
249
|
-
globalThis.test("every JSON record carries an RFC 3339 time field", () => {
|
|
250
|
-
let lines = captureLogs(() => log.info("Platform", undefined, "tick"));
|
|
251
|
-
let t = Stdlib_Option.flatMap(lines[0], l => fieldOf(l, "time"));
|
|
252
|
-
let ok = t !== undefined ? t.includes("T") && t.endsWith("Z") : false;
|
|
253
|
-
globalThis.expect(ok).toBe(true);
|
|
254
|
-
});
|
|
255
|
-
globalThis.test("service field is emitted when REVENTLESS_SERVICE is set", () => {
|
|
256
|
-
process.env["REVENTLESS_SERVICE"] = "TestService";
|
|
257
|
-
let lines = captureLogs(() => log.info("Platform", undefined, "tick"));
|
|
258
|
-
let got = Stdlib_Option.flatMap(lines[0], l => fieldOf(l, "service"));
|
|
259
|
-
Stdlib_Dict.$$delete(process.env, "REVENTLESS_SERVICE");
|
|
260
|
-
globalThis.expect(got).toEqual("TestService");
|
|
261
|
-
});
|
|
262
|
-
globalThis.test("oversized detail is truncated to a preview stub", () => {
|
|
263
|
-
let big = "x".repeat(40000);
|
|
264
|
-
let detail = Object.fromEntries([[
|
|
265
|
-
"blob",
|
|
266
|
-
big
|
|
267
|
-
]]);
|
|
268
|
-
let direct = captureLogs(() => Logger$ReventlessCore.emit("Info", "Platform", undefined, detail, undefined, "big"));
|
|
269
|
-
let obj = Stdlib_Option.flatMap(direct[0], l => Stdlib_JSON.Decode.object(JSON.parse(l)));
|
|
270
|
-
let ok;
|
|
271
|
-
if (obj !== undefined) {
|
|
272
|
-
let d = Stdlib_Option.flatMap(obj["detail"], Stdlib_JSON.Decode.object);
|
|
273
|
-
ok = d !== undefined ? Primitive_object.equal(Stdlib_Option.flatMap(d["truncated"], Stdlib_JSON.Decode.bool), true) && Stdlib_Option.mapOr(Stdlib_Option.flatMap(d["preview"], Stdlib_JSON.Decode.string), false, p => p.length <= 512) : false;
|
|
274
|
-
} else {
|
|
275
|
-
ok = false;
|
|
276
|
-
}
|
|
277
|
-
globalThis.expect(ok).toBe(true);
|
|
278
|
-
});
|
|
279
|
-
globalThis.test("LogFormat.cmdName carries no ANSI in a JSON sink", () => {
|
|
280
|
-
let cmd_meta = {
|
|
281
|
-
service: "testService",
|
|
282
|
-
time: "testTime",
|
|
283
|
-
ip: "testIp",
|
|
284
|
-
user: "testUser",
|
|
285
|
-
msgId: "testMsgId",
|
|
286
|
-
correlationId: "testCorrelationId"
|
|
287
|
-
};
|
|
288
|
-
let cmd_commandJson = Message$ReventlessCore.encode({
|
|
289
|
-
TAG: "Heartbeat",
|
|
290
|
-
_0: "0.0.0"
|
|
291
|
-
}, PluginSpec$ReventlessCore.commandSchema);
|
|
292
|
-
let cmd = {
|
|
293
|
-
id: "0",
|
|
294
|
-
meta: cmd_meta,
|
|
295
|
-
commandJson: cmd_commandJson
|
|
296
|
-
};
|
|
297
|
-
let name = LogFormat$ReventlessCore.cmdName(cmd);
|
|
298
|
-
globalThis.expect(!name.includes("\x1b") && name === "Heartbeat").toBe(true);
|
|
299
|
-
});
|
|
300
|
-
});
|
|
301
|
-
|
|
302
|
-
export {
|
|
303
|
-
hasAnsi,
|
|
304
|
-
captureLogs,
|
|
305
|
-
validLevels,
|
|
306
|
-
isCleanRecord,
|
|
307
|
-
fieldOf,
|
|
308
|
-
}
|
|
309
|
-
/* Not a pure module */
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
import * as Logger$ReventlessCore from "../../src/util/Logger.res.mjs";
|
|
4
|
-
|
|
5
|
-
globalThis.describe("Logger.debugLazy", () => {
|
|
6
|
-
globalThis.test("does NOT invoke the thunk at the default Info level", () => {
|
|
7
|
-
let called = {
|
|
8
|
-
contents: false
|
|
9
|
-
};
|
|
10
|
-
let log = Logger$ReventlessCore.makeLogger("Info");
|
|
11
|
-
log.debugLazy("Test", () => {
|
|
12
|
-
called.contents = true;
|
|
13
|
-
return "should never be built";
|
|
14
|
-
});
|
|
15
|
-
globalThis.expect(called.contents).toEqual(false);
|
|
16
|
-
});
|
|
17
|
-
globalThis.test("invokes the thunk when debug output is enabled", () => {
|
|
18
|
-
let called = {
|
|
19
|
-
contents: false
|
|
20
|
-
};
|
|
21
|
-
let log = Logger$ReventlessCore.makeLogger("Debug");
|
|
22
|
-
log.debugLazy("Test", () => {
|
|
23
|
-
called.contents = true;
|
|
24
|
-
return "built";
|
|
25
|
-
});
|
|
26
|
-
globalThis.expect(called.contents).toEqual(true);
|
|
27
|
-
});
|
|
28
|
-
globalThis.test("the silent logger never invokes the thunk", () => {
|
|
29
|
-
let called = {
|
|
30
|
-
contents: false
|
|
31
|
-
};
|
|
32
|
-
Logger$ReventlessCore.silent.debugLazy("Test", () => {
|
|
33
|
-
called.contents = true;
|
|
34
|
-
return "x";
|
|
35
|
-
});
|
|
36
|
-
globalThis.expect(called.contents).toEqual(false);
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
/* Not a pure module */
|
|
@@ -1,218 +0,0 @@
|
|
|
1
|
-
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
-
|
|
3
|
-
import * as S from "sury/src/S.res.mjs";
|
|
4
|
-
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
5
|
-
import * as Message$ReventlessCore from "../../src/Message.res.mjs";
|
|
6
|
-
import * as PluginSpec$ReventlessCore from "../../src/plugin/lifecycle/PluginSpec.res.mjs";
|
|
7
|
-
|
|
8
|
-
globalThis.describe("Message should", () => {
|
|
9
|
-
globalThis.test("create a valid sequenceNr", () => {
|
|
10
|
-
globalThis.expect(Message$ReventlessCore.hrtimeToString([
|
|
11
|
-
1,
|
|
12
|
-
1
|
|
13
|
-
], 123456789)).toBe("123456789-000000001");
|
|
14
|
-
});
|
|
15
|
-
globalThis.test("get variant name of json without payload", () => {
|
|
16
|
-
let variantJson = Message$ReventlessCore.encode({
|
|
17
|
-
TAG: "Heartbeat",
|
|
18
|
-
_0: "0.0.0"
|
|
19
|
-
}, PluginSpec$ReventlessCore.commandSchema);
|
|
20
|
-
let variantName = Message$ReventlessCore.variantNameOfJson(variantJson);
|
|
21
|
-
globalThis.expect(variantName).toBe("Heartbeat");
|
|
22
|
-
});
|
|
23
|
-
globalThis.test("get variant name of json with payload", () => {
|
|
24
|
-
let variant = {
|
|
25
|
-
TAG: "Connect",
|
|
26
|
-
_0: {
|
|
27
|
-
id: "id",
|
|
28
|
-
name: "testName",
|
|
29
|
-
version: "testVersion",
|
|
30
|
-
extensionPoints: [{
|
|
31
|
-
name: "testExtensionPoint",
|
|
32
|
-
commandTopic: "testCommandTopic",
|
|
33
|
-
eventTopic: "testEventTopic"
|
|
34
|
-
}],
|
|
35
|
-
extensions: [{
|
|
36
|
-
name: "testExtension",
|
|
37
|
-
extensionPointName: "testExtensionPoint",
|
|
38
|
-
dcbSources: []
|
|
39
|
-
}],
|
|
40
|
-
eventCollector: "testEventCollector",
|
|
41
|
-
extensionProtocols: [],
|
|
42
|
-
apiSchemaFragment: undefined,
|
|
43
|
-
apiTarget: undefined,
|
|
44
|
-
structure: undefined,
|
|
45
|
-
dcbEventLog: undefined,
|
|
46
|
-
kind: "Domain"
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
let variantJson = Message$ReventlessCore.encode(variant, PluginSpec$ReventlessCore.commandSchema);
|
|
50
|
-
let variantName = Message$ReventlessCore.variantNameOfJson(variantJson);
|
|
51
|
-
globalThis.expect(variantName).toBe("Connect");
|
|
52
|
-
});
|
|
53
|
-
globalThis.test("get event name of eventJson'", () => {
|
|
54
|
-
let eventJson$p = Message$ReventlessCore.encodeEvent$p({
|
|
55
|
-
id: "testId",
|
|
56
|
-
meta: {
|
|
57
|
-
service: "testService",
|
|
58
|
-
time: "testTime",
|
|
59
|
-
ip: "testIp",
|
|
60
|
-
user: "testUser",
|
|
61
|
-
msgId: "testMsgId",
|
|
62
|
-
correlationId: "testCorrelationId"
|
|
63
|
-
},
|
|
64
|
-
event: {
|
|
65
|
-
TAG: "VersionDetected",
|
|
66
|
-
_0: "0.0.0"
|
|
67
|
-
}
|
|
68
|
-
}, S.string, PluginSpec$ReventlessCore.eventSchema);
|
|
69
|
-
let eventName = Message$ReventlessCore.eventNameOfEvent$pJson(eventJson$p);
|
|
70
|
-
globalThis.expect(eventName).toBe("VersionDetected");
|
|
71
|
-
});
|
|
72
|
-
globalThis.test("get id of eventJson'", () => {
|
|
73
|
-
let eventJson$p = Message$ReventlessCore.encodeEvent$p({
|
|
74
|
-
id: "testId",
|
|
75
|
-
meta: {
|
|
76
|
-
service: "testService",
|
|
77
|
-
time: "testTime",
|
|
78
|
-
ip: "testIp",
|
|
79
|
-
user: "testUser",
|
|
80
|
-
msgId: "testMsgId",
|
|
81
|
-
correlationId: "testCorrelationId"
|
|
82
|
-
},
|
|
83
|
-
event: {
|
|
84
|
-
TAG: "VersionDetected",
|
|
85
|
-
_0: "0.0.0"
|
|
86
|
-
}
|
|
87
|
-
}, S.string, PluginSpec$ReventlessCore.eventSchema);
|
|
88
|
-
let eventId = Stdlib_Option.getOrThrow(Message$ReventlessCore.idOfEvent$pJson(eventJson$p), undefined);
|
|
89
|
-
globalThis.expect(eventId).toBe("testId");
|
|
90
|
-
});
|
|
91
|
-
globalThis.test("tolerantly decode a VersionConnected persisted before kind/structure fields existed", () => {
|
|
92
|
-
let def = {
|
|
93
|
-
id: "id",
|
|
94
|
-
name: "Ordering",
|
|
95
|
-
version: "1.0.0",
|
|
96
|
-
extensionPoints: [],
|
|
97
|
-
extensions: [],
|
|
98
|
-
eventCollector: "arn",
|
|
99
|
-
extensionProtocols: [],
|
|
100
|
-
apiSchemaFragment: undefined,
|
|
101
|
-
apiTarget: undefined,
|
|
102
|
-
structure: {
|
|
103
|
-
readModels: [],
|
|
104
|
-
stateViewSlices: [],
|
|
105
|
-
stateChangeSlices: [],
|
|
106
|
-
aggregates: [{
|
|
107
|
-
name: "Order",
|
|
108
|
-
commands: [],
|
|
109
|
-
producedEventTypes: [],
|
|
110
|
-
consumedEventTypes: [],
|
|
111
|
-
linkedViews: [],
|
|
112
|
-
consistencyRead: undefined,
|
|
113
|
-
events: [],
|
|
114
|
-
chapter: undefined
|
|
115
|
-
}],
|
|
116
|
-
automationSlices: [],
|
|
117
|
-
outboundTranslationSlices: [],
|
|
118
|
-
inboundTranslationSlices: [],
|
|
119
|
-
extensions: [],
|
|
120
|
-
extensionPoints: undefined
|
|
121
|
-
},
|
|
122
|
-
dcbEventLog: undefined,
|
|
123
|
-
kind: "Domain"
|
|
124
|
-
};
|
|
125
|
-
let event$p_meta = {
|
|
126
|
-
service: "svc",
|
|
127
|
-
time: "t",
|
|
128
|
-
ip: "ip",
|
|
129
|
-
user: "u",
|
|
130
|
-
msgId: "m",
|
|
131
|
-
correlationId: "c"
|
|
132
|
-
};
|
|
133
|
-
let event$p_event = {
|
|
134
|
-
TAG: "VersionConnected",
|
|
135
|
-
_0: def
|
|
136
|
-
};
|
|
137
|
-
let event$p = {
|
|
138
|
-
id: "id",
|
|
139
|
-
meta: event$p_meta,
|
|
140
|
-
event: event$p_event
|
|
141
|
-
};
|
|
142
|
-
let json = Message$ReventlessCore.encodeEvent$p(event$p, S.string, PluginSpec$ReventlessCore.eventSchema);
|
|
143
|
-
let oldJson = (function(j){
|
|
144
|
-
var c = JSON.parse(JSON.stringify(j));
|
|
145
|
-
var d = c.event._0;
|
|
146
|
-
delete d.kind;
|
|
147
|
-
delete d.apiSchemaFragment;
|
|
148
|
-
var agg = d.structure.aggregates[0];
|
|
149
|
-
delete agg.events;
|
|
150
|
-
delete agg.chapter;
|
|
151
|
-
return c;
|
|
152
|
-
})(json);
|
|
153
|
-
let strictThrew;
|
|
154
|
-
try {
|
|
155
|
-
S.parseJsonOrThrow(oldJson, Message$ReventlessCore.toEventSchema$p(S.string, PluginSpec$ReventlessCore.eventSchema));
|
|
156
|
-
strictThrew = false;
|
|
157
|
-
} catch (exn) {
|
|
158
|
-
strictThrew = true;
|
|
159
|
-
}
|
|
160
|
-
globalThis.expect(strictThrew).toBe(true);
|
|
161
|
-
let decoded = Message$ReventlessCore.decodeEvent$p(oldJson, S.string, PluginSpec$ReventlessCore.eventSchema);
|
|
162
|
-
let d = decoded.event;
|
|
163
|
-
if (d.TAG === "VersionConnected") {
|
|
164
|
-
let d$1 = d._0;
|
|
165
|
-
let match = d$1.kind;
|
|
166
|
-
let tmp;
|
|
167
|
-
tmp = match === "Domain" ? "Domain" : "other";
|
|
168
|
-
globalThis.expect(tmp).toBe("Domain");
|
|
169
|
-
globalThis.expect(Stdlib_Option.isNone(d$1.apiSchemaFragment)).toBe(true);
|
|
170
|
-
let structure = Stdlib_Option.getOrThrow(d$1.structure, undefined);
|
|
171
|
-
let agg = structure.aggregates[0];
|
|
172
|
-
globalThis.expect(agg.events.length).toBe(0);
|
|
173
|
-
globalThis.expect(Stdlib_Option.isNone(agg.chapter)).toBe(true);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
globalThis.expect("wrong-variant").toBe("VersionConnected");
|
|
177
|
-
});
|
|
178
|
-
globalThis.test("Message.decode heals a VersionConnected variant missing kind (the replay path)", () => {
|
|
179
|
-
let def = {
|
|
180
|
-
id: "id",
|
|
181
|
-
name: "Ordering",
|
|
182
|
-
version: "1.0.0",
|
|
183
|
-
extensionPoints: [],
|
|
184
|
-
extensions: [],
|
|
185
|
-
eventCollector: "arn",
|
|
186
|
-
extensionProtocols: [],
|
|
187
|
-
apiSchemaFragment: undefined,
|
|
188
|
-
apiTarget: undefined,
|
|
189
|
-
structure: undefined,
|
|
190
|
-
dcbEventLog: undefined,
|
|
191
|
-
kind: "Domain"
|
|
192
|
-
};
|
|
193
|
-
let variantJson = Message$ReventlessCore.encode({
|
|
194
|
-
TAG: "VersionConnected",
|
|
195
|
-
_0: def
|
|
196
|
-
}, PluginSpec$ReventlessCore.eventSchema);
|
|
197
|
-
let staleJson = (function(j){ var c = JSON.parse(JSON.stringify(j)); delete c._0.kind; return c; })(variantJson);
|
|
198
|
-
let strictThrew;
|
|
199
|
-
try {
|
|
200
|
-
S.parseJsonOrThrow(staleJson, PluginSpec$ReventlessCore.eventSchema);
|
|
201
|
-
strictThrew = false;
|
|
202
|
-
} catch (exn) {
|
|
203
|
-
strictThrew = true;
|
|
204
|
-
}
|
|
205
|
-
globalThis.expect(strictThrew).toBe(true);
|
|
206
|
-
let d = Message$ReventlessCore.decode(staleJson, PluginSpec$ReventlessCore.eventSchema);
|
|
207
|
-
if (d.TAG === "VersionConnected") {
|
|
208
|
-
let match = d._0.kind;
|
|
209
|
-
let tmp;
|
|
210
|
-
tmp = match === "Domain" ? "Domain" : "other";
|
|
211
|
-
globalThis.expect(tmp).toBe("Domain");
|
|
212
|
-
return;
|
|
213
|
-
}
|
|
214
|
-
globalThis.expect("wrong-variant").toBe("VersionConnected");
|
|
215
|
-
});
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
/* Not a pure module */
|