@reventlessdev/reventless-aws 3.0.0-alpha.173 → 3.0.0-alpha.174
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 +9 -0
- package/package.json +6 -6
- package/src/Platform.res +77 -7
- package/src/Platform.res.mjs +77 -3
- package/src/adapter/DcbEventLog/DcbBackend.res +78 -0
- package/src/adapter/DcbEventLog/DcbBackend.res.mjs +53 -0
- package/src/adapter/DcbEventLog/DcbEventLogStorage.res +20 -0
- package/src/adapter/DcbEventLog/DcbEventLogStorage.res.mjs +21 -1
- package/src/adapter/DcbEventLog/DcbEventLogStorage_Postgres.res +43 -0
- package/src/adapter/DcbEventLog/DcbEventLogStorage_Postgres.res.mjs +21 -0
- package/src/adapter/Postgres/PgChangeFeedRelay_Builder.res +7 -0
- package/src/adapter/Postgres/PgChangeFeedRelay_Builder.res.mjs +7 -1
- package/src/adapter/Postgres/PgChangeFeedRelay_Runtime.res +9 -1
- package/src/adapter/Postgres/PgChangeFeedRelay_Runtime.res.mjs +6 -2
- package/src/adapter/Runtime/StateChangeSliceRuntime_Builder_Single.res +84 -6
- package/src/adapter/Runtime/StateChangeSliceRuntime_Builder_Single.res.mjs +49 -4
- package/src/components/Api/AppSync_Adapter.res +3 -3
- package/src/components/Api/AppSync_Adapter.res.mjs +2 -2
- package/src/components/Plugin.res +1 -1
- package/src/components/Plugin.res.mjs +2 -2
- package/src/plugin/runtime/PluginRuntime_Builder.res +20 -0
- package/src/plugin/runtime/PluginRuntime_Builder.res.mjs +8 -0
- package/tests/AppSync_AdapterTest.res +12 -12
- package/tests/AppSync_AdapterTest.res.mjs +15 -15
- package/tests/PgChangeFeedRelay_RuntimeTest.res +31 -0
- package/tests/PgChangeFeedRelay_RuntimeTest.res.mjs +65 -0
|
@@ -42,3 +42,34 @@ describe("PgChangeFeedRelay_Runtime.toEventCollectorJson", () => {
|
|
|
42
42
|
expect(obj->Dict.get("id"))->toEqual(Some(JSON.Encode.string("dcb")))
|
|
43
43
|
})
|
|
44
44
|
})
|
|
45
|
+
|
|
46
|
+
describe("PgChangeFeedRelay_Runtime partitionTag (B2.3d)", () => {
|
|
47
|
+
let multiTagEvent = {
|
|
48
|
+
...sampleEvent,
|
|
49
|
+
tags: [{key: "orderId", value: "o-1"}, {key: "customerId", value: "c-9"}],
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
testSync("a Simple partitionTag selects its tag for the id, not just the first", () => {
|
|
53
|
+
let pt = Reventless.DcbTag.Simple({key: "customerId"})
|
|
54
|
+
let json =
|
|
55
|
+
PgChangeFeedRelay_Runtime.toEventCollectorJson(multiTagEvent, ~partitionTag=pt)->Option.getOrThrow
|
|
56
|
+
let obj = json->JSON.Decode.object->Option.getOrThrow
|
|
57
|
+
// Without partitionTag the id would be "orderId:o-1" (first tag); the tag
|
|
58
|
+
// pins it to "customerId:c-9".
|
|
59
|
+
expect(obj->Dict.get("id"))->toEqual(Some(JSON.Encode.string("customerId:c-9")))
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
testSync("derivedPartitionTag round-trips through the sury schema (relay wire-format)", () => {
|
|
63
|
+
// The relay builder serialises partitionTag with this schema into HANDLER_CONFIG
|
|
64
|
+
// and PgChangeFeedRelay_Runtime.relay parses it back the same way. Guard the
|
|
65
|
+
// round-trip so a schema change can't silently break the id derivation.
|
|
66
|
+
let simple = Reventless.DcbTag.Simple({key: "courseId"})
|
|
67
|
+
let composite =
|
|
68
|
+
Reventless.DcbTag.Composite({keys: ["studentId", "courseId"], seps: [":"]})
|
|
69
|
+
[simple, composite]->Array.forEach(pt => {
|
|
70
|
+
let wire = pt->S.reverseConvertToJsonOrThrow(Reventless.DcbTag.derivedPartitionTagSchema)
|
|
71
|
+
let back = wire->S.parseJsonOrThrow(Reventless.DcbTag.derivedPartitionTagSchema)
|
|
72
|
+
expect(back)->toEqual(pt)
|
|
73
|
+
})
|
|
74
|
+
})
|
|
75
|
+
})
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
2
|
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
3
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";
|
|
6
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
5
7
|
import * as PgChangeFeedRelay_Runtime$ReventlessAws from "../src/adapter/Postgres/PgChangeFeedRelay_Runtime.res.mjs";
|
|
6
8
|
|
|
7
9
|
let sampleEvent_data = Object.fromEntries([[
|
|
@@ -64,6 +66,69 @@ globalThis.describe("PgChangeFeedRelay_Runtime.toEventCollectorJson", () => {
|
|
|
64
66
|
});
|
|
65
67
|
});
|
|
66
68
|
|
|
69
|
+
globalThis.describe("PgChangeFeedRelay_Runtime partitionTag (B2.3d)", () => {
|
|
70
|
+
let multiTagEvent_data = sampleEvent_data;
|
|
71
|
+
let multiTagEvent_tags = [
|
|
72
|
+
{
|
|
73
|
+
key: "orderId",
|
|
74
|
+
value: "o-1"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
key: "customerId",
|
|
78
|
+
value: "c-9"
|
|
79
|
+
}
|
|
80
|
+
];
|
|
81
|
+
let multiTagEvent_meta = {
|
|
82
|
+
service: "Orders",
|
|
83
|
+
time: "2026-07-05T10:00:00.000Z",
|
|
84
|
+
msgId: "m-1",
|
|
85
|
+
correlationId: "m-1"
|
|
86
|
+
};
|
|
87
|
+
let multiTagEvent = {
|
|
88
|
+
position: "00000000000000000042:00000000000000000007",
|
|
89
|
+
eventType: "OrderCreated",
|
|
90
|
+
data: multiTagEvent_data,
|
|
91
|
+
tags: multiTagEvent_tags,
|
|
92
|
+
meta: multiTagEvent_meta,
|
|
93
|
+
recordedAt: "2026-07-05T10:00:00.000Z"
|
|
94
|
+
};
|
|
95
|
+
globalThis.test("a Simple partitionTag selects its tag for the id, not just the first", () => {
|
|
96
|
+
let json = Stdlib_Option.getOrThrow(PgChangeFeedRelay_Runtime$ReventlessAws.toEventCollectorJson(multiTagEvent, {
|
|
97
|
+
TAG: "Simple",
|
|
98
|
+
_0: {
|
|
99
|
+
key: "customerId"
|
|
100
|
+
}
|
|
101
|
+
}), undefined);
|
|
102
|
+
let obj = Stdlib_Option.getOrThrow(Stdlib_JSON.Decode.object(json), undefined);
|
|
103
|
+
globalThis.expect(obj["id"]).toEqual("customerId:c-9");
|
|
104
|
+
});
|
|
105
|
+
globalThis.test("derivedPartitionTag round-trips through the sury schema (relay wire-format)", () => {
|
|
106
|
+
let composite = {
|
|
107
|
+
TAG: "Composite",
|
|
108
|
+
_0: {
|
|
109
|
+
keys: [
|
|
110
|
+
"studentId",
|
|
111
|
+
"courseId"
|
|
112
|
+
],
|
|
113
|
+
seps: [":"]
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
[
|
|
117
|
+
{
|
|
118
|
+
TAG: "Simple",
|
|
119
|
+
_0: {
|
|
120
|
+
key: "courseId"
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
composite
|
|
124
|
+
].forEach(pt => {
|
|
125
|
+
let wire = S.reverseConvertToJsonOrThrow(pt, DcbTag$Reventless.derivedPartitionTagSchema);
|
|
126
|
+
let back = S.parseJsonOrThrow(wire, DcbTag$Reventless.derivedPartitionTagSchema);
|
|
127
|
+
globalThis.expect(back).toEqual(pt);
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
});
|
|
131
|
+
|
|
67
132
|
export {
|
|
68
133
|
sampleEvent,
|
|
69
134
|
}
|