@reventlessdev/reventless-core 3.0.0-alpha.323 → 3.0.0-alpha.324
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 +7 -0
- package/package.json +5 -5
- package/src/Message.res +4 -1
- package/src/Message.res.mjs +4 -2
- package/tests/message/MessageTest.res +21 -0
- package/tests/message/MessageTest.res.mjs +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# 3.0.0-alpha.324 (2026-10-30)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* **core:** an SQS command body keeps a stable msgId ([eb098db](https://github.com/ReventlessDev/reventless-core/commit/eb098dbca24d63d15b9f9a7d961a170e3a86b961))
|
|
11
|
+
|
|
12
|
+
|
|
6
13
|
# 3.0.0-alpha.323 (2026-10-30)
|
|
7
14
|
|
|
8
15
|
### Bug Fixes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reventlessdev/reventless-core",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.324",
|
|
4
4
|
"description": "Core package for Reventless framework",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"jest": {
|
|
@@ -28,17 +28,17 @@
|
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"sury": "11.0.0",
|
|
30
30
|
"uuid": "^13.0.0",
|
|
31
|
+
"@reventlessdev/rescript-hash-object": "1.2.0-alpha.15",
|
|
31
32
|
"@reventlessdev/rescript-fast-csv": "2.0.0-alpha.24",
|
|
32
33
|
"@reventlessdev/rescript-effect": "1.0.0-alpha.1",
|
|
33
|
-
"@reventlessdev/rescript-hash-object": "1.2.0-alpha.15",
|
|
34
34
|
"@reventlessdev/rescript-node": "2.0.0-alpha.24",
|
|
35
35
|
"@reventlessdev/rescript-jest": "1.0.0-alpha.13",
|
|
36
|
-
"@reventlessdev/reventless-infra": "3.0.0-alpha.219",
|
|
37
|
-
"@reventlessdev/rescript-uuid": "2.0.0-alpha.1",
|
|
38
36
|
"@reventlessdev/rescript-pulumi-pulumi": "3.0.0-alpha.0",
|
|
37
|
+
"@reventlessdev/rescript-uuid": "2.0.0-alpha.1",
|
|
39
38
|
"@reventlessdev/rescript-ssh2": "2.0.0-alpha.25",
|
|
39
|
+
"@reventlessdev/reventless-spec": "3.0.0-alpha.190",
|
|
40
40
|
"@reventlessdev/reventless-interop": "3.0.0-alpha.42",
|
|
41
|
-
"@reventlessdev/reventless-
|
|
41
|
+
"@reventlessdev/reventless-infra": "3.0.0-alpha.219"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"rescript": "12.3.1",
|
package/src/Message.res
CHANGED
|
@@ -104,8 +104,11 @@ let now = () => Date.make()->Date.getTime
|
|
|
104
104
|
|
|
105
105
|
let nowAsISOString = () => Date.make()->Date.toISOString
|
|
106
106
|
|
|
107
|
+
// A stable id is kept: it is what a handler recognizes a redelivered command by,
|
|
108
|
+
// and minting a fresh one here, on every SQS send, made the drop inert on AWS.
|
|
107
109
|
let toMessageBody = ({id, meta, commandJson}) => {
|
|
108
|
-
let
|
|
110
|
+
let msgId = ReventlessInfra.Message.hasStableMsgId(meta) ? meta.msgId : uuid()
|
|
111
|
+
let commandMeta: meta = {...meta, msgId, time: nowAsISOString()}
|
|
109
112
|
[
|
|
110
113
|
("id", id->JSON.Encode.string),
|
|
111
114
|
("meta", commandMeta->Reventless.Util_Sury.toJson(metaSchema)),
|
package/src/Message.res.mjs
CHANGED
|
@@ -85,8 +85,10 @@ function nowAsISOString() {
|
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
function toMessageBody(param) {
|
|
88
|
-
let
|
|
89
|
-
|
|
88
|
+
let meta = param.meta;
|
|
89
|
+
let msgId = Message$ReventlessInfra.hasStableMsgId(meta) ? meta.msgId : Uuid.v4();
|
|
90
|
+
let newrecord = {...meta};
|
|
91
|
+
newrecord.msgId = msgId;
|
|
90
92
|
newrecord.time = new Date().toISOString();
|
|
91
93
|
return JSON.stringify(Object.fromEntries([
|
|
92
94
|
[
|
|
@@ -283,6 +283,27 @@ describe("Message.deriveStableMeta", () => {
|
|
|
283
283
|
expect(ids->Belt.Set.String.fromArray->Belt.Set.String.size)->toBe(5)
|
|
284
284
|
})
|
|
285
285
|
|
|
286
|
+
// The SQS transport writes the body through `toMessageBody`. It used to mint a
|
|
287
|
+
// fresh id on every send, which dropped the stable one at the first hop on AWS.
|
|
288
|
+
testSync("the SQS message body keeps a stable id and still re-mints a random one", () => {
|
|
289
|
+
let msgIdOfBody = body =>
|
|
290
|
+
body
|
|
291
|
+
->JSON.parseOrThrow
|
|
292
|
+
->JSON.Decode.object
|
|
293
|
+
->Option.flatMap(o => o->Dict.get("meta"))
|
|
294
|
+
->Option.flatMap(JSON.Decode.object)
|
|
295
|
+
->Option.flatMap(m => m->Dict.get("msgId"))
|
|
296
|
+
->Option.flatMap(JSON.Decode.string)
|
|
297
|
+
->Option.getOr("")
|
|
298
|
+
let commandJson = JSON.Encode.string("Noop")
|
|
299
|
+
let stable = deriveStableMeta(~parent, ~service="RecordProductDemand", ~index=0)
|
|
300
|
+
expect(msgIdOfBody(toMessageBody({id: "p-1", meta: stable, commandJson})))->toBe(stable.msgId)
|
|
301
|
+
let plain = deriveMeta(~parent, ~service="RecordProductDemand")
|
|
302
|
+
expect(msgIdOfBody(toMessageBody({id: "p-1", meta: plain, commandJson})) != plain.msgId)->toBe(
|
|
303
|
+
true,
|
|
304
|
+
)
|
|
305
|
+
})
|
|
306
|
+
|
|
286
307
|
testSync("a derived message never carries its parent's caller claim", () => {
|
|
287
308
|
let claimed = {...parent, callerClaim: Reventless.Message.CallerClaim.Exempt}
|
|
288
309
|
let a = deriveStableMeta(~parent=claimed, ~service="Ordering.Orders", ~index=0)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
3
|
import * as Sury from "sury";
|
|
4
|
+
import * as Stdlib_JSON from "@rescript/runtime/lib/es6/Stdlib_JSON.js";
|
|
4
5
|
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
5
6
|
import * as Belt_SetString from "@rescript/runtime/lib/es6/Belt_SetString.js";
|
|
6
7
|
import * as Offload$Reventless from "@reventlessdev/reventless-spec/src/semantic/Offload.res.mjs";
|
|
@@ -263,6 +264,22 @@ globalThis.describe("Message.deriveStableMeta", () => {
|
|
|
263
264
|
];
|
|
264
265
|
globalThis.expect(Belt_SetString.size(Belt_SetString.fromArray(ids))).toBe(5);
|
|
265
266
|
});
|
|
267
|
+
globalThis.test("the SQS message body keeps a stable id and still re-mints a random one", () => {
|
|
268
|
+
let msgIdOfBody = body => Stdlib_Option.getOr(Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_Option.flatMap(Stdlib_JSON.Decode.object(JSON.parse(body)), o => o["meta"]), Stdlib_JSON.Decode.object), m => m["msgId"]), Stdlib_JSON.Decode.string), "");
|
|
269
|
+
let commandJson = "Noop";
|
|
270
|
+
let stable = Message$ReventlessCore.deriveStableMeta(parent, "RecordProductDemand", 0, undefined);
|
|
271
|
+
globalThis.expect(msgIdOfBody(Message$ReventlessCore.toMessageBody({
|
|
272
|
+
id: "p-1",
|
|
273
|
+
meta: stable,
|
|
274
|
+
commandJson: commandJson
|
|
275
|
+
}))).toBe(stable.msgId);
|
|
276
|
+
let plain = Message$ReventlessCore.deriveMeta(parent, "RecordProductDemand");
|
|
277
|
+
globalThis.expect(msgIdOfBody(Message$ReventlessCore.toMessageBody({
|
|
278
|
+
id: "p-1",
|
|
279
|
+
meta: plain,
|
|
280
|
+
commandJson: commandJson
|
|
281
|
+
})) !== plain.msgId).toBe(true);
|
|
282
|
+
});
|
|
266
283
|
globalThis.test("a derived message never carries its parent's caller claim", () => {
|
|
267
284
|
let newrecord = {...parent};
|
|
268
285
|
newrecord.callerClaim = "Exempt";
|