@reventlessdev/reventless-aws 3.0.0-alpha.232 → 3.0.0-alpha.234
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 +23 -0
- package/package.json +7 -7
- package/src/adapter/Api/AppSyncEventsSigner_Ops.res +137 -0
- package/src/adapter/Api/AppSyncEventsSigner_Ops.res.mjs +121 -0
- package/src/adapter/Api/Platform_AdminScan_Ops.res +136 -0
- package/src/adapter/Api/Platform_AdminScan_Ops.res.mjs +98 -0
- package/src/adapter/Api/Platform_ComponentDefinitions_Lambda.res +12 -90
- package/src/adapter/Api/Platform_ComponentDefinitions_Lambda.res.mjs +11 -84
- package/src/adapter/Api/Platform_ComponentDefinitions_Lambda_Ops.res +86 -0
- package/src/adapter/Api/Platform_ComponentDefinitions_Lambda_Ops.res.mjs +79 -0
- package/src/adapter/Api/Platform_UIFragments_Lambda.res +9 -79
- package/src/adapter/Api/Platform_UIFragments_Lambda.res.mjs +7 -143
- package/src/adapter/Api/Platform_UIFragments_Lambda_Ops.res +48 -0
- package/src/adapter/Api/Platform_UIFragments_Lambda_Ops.res.mjs +63 -0
- package/src/adapter/EventLogSubscription/EventLogSubscription_AppSync.res +21 -80
- package/src/adapter/EventLogSubscription/EventLogSubscription_AppSync.res.mjs +23 -68
- package/src/adapter/EventLogSubscription/EventLogSubscription_AppSync_Ops.res +70 -0
- package/src/adapter/EventLogSubscription/EventLogSubscription_AppSync_Ops.res.mjs +68 -0
- package/src/adapter/Postgres/PgChangeFeedRelay_Builder.res +1 -1
- package/src/adapter/Postgres/PgChangeFeedRelay_Builder.res.mjs +1 -1
- package/src/adapter/Postgres/PgMigration_Builder.res +1 -1
- package/src/adapter/Postgres/PgMigration_Builder.res.mjs +1 -1
- package/src/adapter/Runtime/AutomationSliceEntryPoint.mjs +42 -126
- package/src/adapter/Runtime/AutomationSliceEntryPoint_Ops.res +246 -0
- package/src/adapter/Runtime/AutomationSliceEntryPoint_Ops.res.mjs +145 -0
- package/src/adapter/Runtime/AutomationSliceRuntime_Builder_Single.res +27 -2
- package/src/adapter/Runtime/AutomationSliceRuntime_Builder_Single.res.mjs +10 -3
- package/src/adapter/Runtime/CounterEntryPoint.mjs +19 -73
- package/src/adapter/Runtime/CounterEntryPoint_Ops.res +145 -0
- package/src/adapter/Runtime/CounterEntryPoint_Ops.res.mjs +129 -0
- package/src/adapter/Runtime/DcbCommandTopicEntryPoint.mjs +14 -1
- package/src/adapter/Runtime/DcbCommandTopicEntryPoint_Ops.res +22 -2
- package/src/adapter/Runtime/DcbCommandTopicEntryPoint_Ops.res.mjs +15 -4
- package/src/adapter/Runtime/EventCollectorEntryPoint.mjs +52 -510
- package/src/adapter/Runtime/EventCollectorEntryPoint_Ops.res +816 -0
- package/src/adapter/Runtime/EventCollectorEntryPoint_Ops.res.mjs +651 -0
- package/src/adapter/Runtime/EventMapperEntryPoint.mjs +23 -67
- package/src/adapter/Runtime/EventMapperEntryPoint_Ops.res +126 -0
- package/src/adapter/Runtime/EventMapperEntryPoint_Ops.res.mjs +83 -0
- package/src/adapter/Runtime/ExtensionPointEntryPoint.mjs +16 -63
- package/src/adapter/Runtime/ExtensionPointEntryPoint_Ops.res +150 -0
- package/src/adapter/Runtime/ExtensionPointEntryPoint_Ops.res.mjs +111 -0
- package/src/adapter/Runtime/PgChangeFeedRelayEntryPoint.res +96 -0
- package/src/adapter/Runtime/PgChangeFeedRelayEntryPoint.res.mjs +70 -0
- package/src/adapter/Runtime/PgMigrationEntryPoint.res +54 -0
- package/src/adapter/Runtime/PgMigrationEntryPoint.res.mjs +37 -0
- package/src/adapter/Runtime/PgQueryResolverEntryPoint.mjs +20 -55
- package/src/adapter/Runtime/PgQueryResolverEntryPoint_Ops.res +155 -0
- package/src/adapter/Runtime/PgQueryResolverEntryPoint_Ops.res.mjs +94 -0
- package/src/adapter/Runtime/ProjectionEntryPoint_Ops.res +80 -0
- package/src/adapter/Runtime/ProjectionEntryPoint_Ops.res.mjs +39 -0
- package/src/adapter/Runtime/QueryDbEntryPoint_Ops.res +4 -4
- package/src/adapter/Runtime/ReadModelEntryPoint.mjs +34 -153
- package/src/adapter/Runtime/ReadModelEntryPoint_Ops.res +114 -0
- package/src/adapter/Runtime/ReadModelEntryPoint_Ops.res.mjs +83 -0
- package/src/adapter/Runtime/RuntimeEnvironment_Lambda.res +26 -6
- package/src/adapter/Runtime/SideEffectEntryPoint.mjs +23 -64
- package/src/adapter/Runtime/SideEffectEntryPoint_Ops.res +71 -0
- package/src/adapter/Runtime/SideEffectEntryPoint_Ops.res.mjs +57 -0
- package/src/adapter/Runtime/StateChangeSliceRuntime_Builder_Single.res +5 -2
- package/src/adapter/Runtime/StateChangeSliceRuntime_Builder_Single.res.mjs +1 -1
- package/src/adapter/Runtime/StateViewSliceEntryPoint.mjs +34 -165
- package/src/adapter/Runtime/StateViewSliceEntryPoint_Ops.res +206 -0
- package/src/adapter/Runtime/StateViewSliceEntryPoint_Ops.res.mjs +105 -0
- package/src/adapter/Runtime/StreamRoutedEntryPoint_Ops.res +156 -0
- package/src/adapter/Runtime/StreamRoutedEntryPoint_Ops.res.mjs +123 -0
- package/src/adapter/Runtime/TaskBucketEntryPoint.mjs +18 -138
- package/src/adapter/Runtime/TaskBucketEntryPoint_Ops.res +198 -0
- package/src/adapter/Runtime/TaskBucketEntryPoint_Ops.res.mjs +155 -0
- package/src/adapter/StateTopic/StateTopic_AppSync.res +12 -170
- package/src/adapter/StateTopic/StateTopic_AppSync.res.mjs +7 -167
- package/src/adapter/StateTopic/StateTopic_AppSync_Ops.res +208 -0
- package/src/adapter/StateTopic/StateTopic_AppSync_Ops.res.mjs +183 -0
- package/src/components/AutomationSlice_Builder.res +2 -0
- package/src/components/AutomationSlice_Builder.res.mjs +1 -1
- package/src/components/OutboundTranslationSlice_Builder.res +1 -0
- package/src/components/OutboundTranslationSlice_Builder.res.mjs +1 -1
- package/src/plugin/runtime/PluginRuntime_Builder.res +13 -4
- package/src/plugin/runtime/PluginRuntime_Builder.res.mjs +1 -1
- package/tests/AppSyncEventsSigner_OpsTest.res +75 -0
- package/tests/AppSyncEventsSigner_OpsTest.res.mjs +44 -0
- package/tests/AppSyncEventsSigner_ParityFixture.mjs +36 -0
- package/tests/AutomationSliceEntryPoint_OpsTest.res +165 -0
- package/tests/AutomationSliceEntryPoint_OpsTest.res.mjs +280 -0
- package/tests/CounterEntryPoint_OpsTest.res +115 -0
- package/tests/CounterEntryPoint_OpsTest.res.mjs +150 -0
- package/tests/EventCollectorEntryPoint_OpsTest.res +216 -0
- package/tests/EventCollectorEntryPoint_OpsTest.res.mjs +339 -0
- package/tests/EventMapperEntryPoint_OpsTest.res +103 -0
- package/tests/EventMapperEntryPoint_OpsTest.res.mjs +120 -0
- package/tests/ExtensionPointEntryPoint_OpsTest.res +57 -0
- package/tests/ExtensionPointEntryPoint_OpsTest.res.mjs +54 -0
- package/tests/PgMigrationEntryPoint_IntegrationTest.res +22 -31
- package/tests/PgMigrationEntryPoint_IntegrationTest.res.mjs +20 -23
- package/tests/PgQueryResolverEntryPoint_OpsTest.res +38 -0
- package/tests/PgQueryResolverEntryPoint_OpsTest.res.mjs +31 -0
- package/tests/Platform_AdminScan_OpsTest.res +80 -0
- package/tests/Platform_AdminScan_OpsTest.res.mjs +127 -0
- package/tests/ReadModelEntryPoint_OpsTest.res +141 -0
- package/tests/ReadModelEntryPoint_OpsTest.res.mjs +267 -0
- package/tests/SideEffectEntryPoint_OpsTest.res +79 -0
- package/tests/SideEffectEntryPoint_OpsTest.res.mjs +105 -0
- package/tests/StateViewSliceEntryPoint_OpsTest.res +167 -0
- package/tests/StateViewSliceEntryPoint_OpsTest.res.mjs +296 -0
- package/tests/TaskBucketEntryPoint_OpsTest.res +117 -0
- package/tests/TaskBucketEntryPoint_OpsTest.res.mjs +165 -0
- package/tests/integration/StateViewSliceEntryPoint_IntegrationTest.res +42 -13
- package/tests/integration/StateViewSliceEntryPoint_IntegrationTest.res.mjs +29 -6
- package/src/adapter/Runtime/PgChangeFeedRelayEntryPoint.mjs +0 -57
- package/src/adapter/Runtime/PgMigrationEntryPoint.mjs +0 -40
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
// Guards the typed cold-start core hoisted out of EventCollectorEntryPoint.mjs:
|
|
2
|
+
// - projectPluginRow — the Plugin-RM row projection the admin cross-plugin
|
|
3
|
+
// subscription manager reads; a drift in the decode (a dropped nested
|
|
4
|
+
// field, a mis-defaulted optional) would silently break cross-plugin SNS
|
|
5
|
+
// wiring, invisible until a multi-plugin deploy.
|
|
6
|
+
// - parseHandlerConfig — the HANDLER_CONFIG contract every EventCollector
|
|
7
|
+
// Lambda cold-starts on: named errors for malformed deploys, the former JS
|
|
8
|
+
// normalizer's defaults, and the connectExtension null/absent → None rule.
|
|
9
|
+
|
|
10
|
+
open JestGlobals
|
|
11
|
+
|
|
12
|
+
let str = JSON.Encode.string
|
|
13
|
+
let obj = pairs => JSON.Encode.object(Dict.fromArray(pairs))
|
|
14
|
+
|
|
15
|
+
let project = EventCollectorEntryPoint_Ops.projectPluginRow
|
|
16
|
+
|
|
17
|
+
describe("EventCollectorEntryPoint_Ops.projectPluginRow", () => {
|
|
18
|
+
testSync("rejects a non-object row", () => {
|
|
19
|
+
expect((project(JSON.Encode.string("nope")))->Option.isNone)->toBe(true)
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
testSync("rejects a row missing id or status", () => {
|
|
23
|
+
expect(project(obj([("status", str("Connected"))]))->Option.isNone)->toBe(true)
|
|
24
|
+
expect(project(obj([("id", str("Catalog@1"))]))->Option.isNone)->toBe(true)
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
testSync("projects the id/status/eventCollector subset with defaults", () => {
|
|
28
|
+
let p = project(obj([("id", str("Catalog@1")), ("status", str("Connected"))]))->Option.getOrThrow
|
|
29
|
+
expect(p.id)->toBe("Catalog@1")
|
|
30
|
+
expect(p.status)->toBe("Connected")
|
|
31
|
+
expect(p.eventCollector)->toBe("") // defaulted when absent
|
|
32
|
+
expect(p.extensions->Array.length)->toBe(0)
|
|
33
|
+
expect(p.extensionPoints->Array.length)->toBe(0)
|
|
34
|
+
expect(p.dcbEventLog->Option.isNone)->toBe(true)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
testSync("decodes extensions, dropping entries without extensionPointName", () => {
|
|
38
|
+
let row = obj([
|
|
39
|
+
("id", str("Ordering@2")),
|
|
40
|
+
("status", str("Connected")),
|
|
41
|
+
("eventCollector", str("ec-arn")),
|
|
42
|
+
(
|
|
43
|
+
"extensions",
|
|
44
|
+
JSON.Encode.array([
|
|
45
|
+
obj([("name", str("OrdersExt")), ("extensionPointName", str("Catalog.Products")), ("dcbSources", JSON.Encode.array([str("prod"), JSON.Encode.int(7)]))]),
|
|
46
|
+
obj([("name", str("Malformed"))]), // no extensionPointName -> dropped
|
|
47
|
+
]),
|
|
48
|
+
),
|
|
49
|
+
])
|
|
50
|
+
let p = project(row)->Option.getOrThrow
|
|
51
|
+
expect(p.eventCollector)->toBe("ec-arn")
|
|
52
|
+
expect(p.extensions->Array.length)->toBe(1)
|
|
53
|
+
let e = p.extensions->Array.getUnsafe(0)
|
|
54
|
+
expect(e.name)->toBe("OrdersExt")
|
|
55
|
+
expect(e.extensionPointName)->toBe("Catalog.Products")
|
|
56
|
+
// Non-string dcbSources elements are filtered out.
|
|
57
|
+
expect(e.dcbSources)->toEqual(["prod"])
|
|
58
|
+
})
|
|
59
|
+
|
|
60
|
+
testSync("decodes extensionPoints and dcbEventLog; drops EPs without name/eventTopic", () => {
|
|
61
|
+
let row = obj([
|
|
62
|
+
("id", str("Catalog@1")),
|
|
63
|
+
("status", str("Connected")),
|
|
64
|
+
(
|
|
65
|
+
"extensionPoints",
|
|
66
|
+
JSON.Encode.array([
|
|
67
|
+
obj([("name", str("Catalog.Products")), ("eventTopic", str("t-arn"))]),
|
|
68
|
+
obj([("name", str("NoTopic"))]), // no eventTopic -> dropped
|
|
69
|
+
]),
|
|
70
|
+
),
|
|
71
|
+
("dcbEventLog", obj([("name", str("catalog-dcb")), ("eventTopicArn", str("dcb-arn"))])),
|
|
72
|
+
])
|
|
73
|
+
let p = project(row)->Option.getOrThrow
|
|
74
|
+
expect(p.extensionPoints->Array.length)->toBe(1)
|
|
75
|
+
let ep = p.extensionPoints->Array.getUnsafe(0)
|
|
76
|
+
expect(ep.name)->toBe("Catalog.Products")
|
|
77
|
+
expect(ep.commandTopic)->toBe("") // defaulted
|
|
78
|
+
expect(ep.eventTopic)->toBe("t-arn")
|
|
79
|
+
let dcb = p.dcbEventLog->Option.getOrThrow
|
|
80
|
+
expect(dcb.name)->toBe("catalog-dcb")
|
|
81
|
+
expect(dcb.eventTopicArn)->toBe("dcb-arn")
|
|
82
|
+
})
|
|
83
|
+
|
|
84
|
+
testSync("drops a dcbEventLog missing eventTopicArn", () => {
|
|
85
|
+
let row = obj([
|
|
86
|
+
("id", str("Catalog@1")),
|
|
87
|
+
("status", str("Connected")),
|
|
88
|
+
("dcbEventLog", obj([("name", str("catalog-dcb"))])),
|
|
89
|
+
])
|
|
90
|
+
expect((project(row)->Option.getOrThrow).dcbEventLog->Option.isNone)->toBe(true)
|
|
91
|
+
})
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
// ── parseHandlerConfig ────────────────────────────────────────────────────────
|
|
95
|
+
|
|
96
|
+
// A minimal valid HANDLER_CONFIG (every required field present).
|
|
97
|
+
let minimalConfig = (extras: array<(string, JSON.t)>): string =>
|
|
98
|
+
Array.concat(
|
|
99
|
+
[
|
|
100
|
+
("queueUrl", str("q-url")),
|
|
101
|
+
("pluginExtensionPointCmdTopicUrl", str("ep-url")),
|
|
102
|
+
("eventTopicArn", str("topic-arn")),
|
|
103
|
+
("pluginReadModelTableName", str("plugin-rm")),
|
|
104
|
+
("appSyncApiId", str("NOT_AVAILABLE")),
|
|
105
|
+
("schedulerRoleArn", str("role-arn")),
|
|
106
|
+
("schedulerQueueArn", str("")),
|
|
107
|
+
("schedulerQueueName", str("")),
|
|
108
|
+
("extensionPoints", JSON.Encode.array([])),
|
|
109
|
+
("extensions", JSON.Encode.array([])),
|
|
110
|
+
("publishToAggregates", obj([])),
|
|
111
|
+
],
|
|
112
|
+
extras,
|
|
113
|
+
)
|
|
114
|
+
->Dict.fromArray
|
|
115
|
+
->JSON.Encode.object
|
|
116
|
+
->JSON.stringify
|
|
117
|
+
|
|
118
|
+
let throws = (f: unit => 'a): option<string> =>
|
|
119
|
+
try {
|
|
120
|
+
let _ = f()
|
|
121
|
+
None
|
|
122
|
+
} catch {
|
|
123
|
+
| exn => exn->JsExn.fromException->Option.flatMap(JsExn.message)
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
describe("EventCollectorEntryPoint_Ops.parseHandlerConfig", () => {
|
|
127
|
+
testSync("throws the named errors for empty / malformed / incomplete config", () => {
|
|
128
|
+
let msgOf = raw => throws(() => EventCollectorEntryPoint_Ops.parseHandlerConfig(raw))
|
|
129
|
+
expect(msgOf(""))->toEqual(Some("HANDLER_CONFIG env var is empty"))
|
|
130
|
+
expect(
|
|
131
|
+
msgOf("{nope")->Option.mapOr(false, m => m->String.startsWith("HANDLER_CONFIG JSON parse error:")),
|
|
132
|
+
)->toBe(true)
|
|
133
|
+
expect(msgOf(`{"queueUrl":"q"}`))->toEqual(
|
|
134
|
+
Some("HANDLER_CONFIG missing required field: pluginExtensionPointCmdTopicUrl"),
|
|
135
|
+
)
|
|
136
|
+
})
|
|
137
|
+
|
|
138
|
+
testSync("decodes a minimal config with empty-collection defaults", () => {
|
|
139
|
+
let c = EventCollectorEntryPoint_Ops.parseHandlerConfig(minimalConfig([]))
|
|
140
|
+
expect(c.queueUrl)->toBe("q-url")
|
|
141
|
+
expect(c.connectExtension->Option.isNone)->toBe(true) // absent → None
|
|
142
|
+
expect(c.readModelQueueUrls->Dict.keysToArray->Array.length)->toBe(0)
|
|
143
|
+
expect(c.readModelNamesForSourceName->Dict.keysToArray->Array.length)->toBe(0)
|
|
144
|
+
})
|
|
145
|
+
|
|
146
|
+
testSync("connectExtension: JSON null (admin) maps to None; a record decodes", () => {
|
|
147
|
+
let asNull = EventCollectorEntryPoint_Ops.parseHandlerConfig(
|
|
148
|
+
minimalConfig([("connectExtension", JSON.Encode.null)]),
|
|
149
|
+
)
|
|
150
|
+
expect(asNull.connectExtension->Option.isNone)->toBe(true)
|
|
151
|
+
|
|
152
|
+
let asRecord = EventCollectorEntryPoint_Ops.parseHandlerConfig(
|
|
153
|
+
minimalConfig([
|
|
154
|
+
(
|
|
155
|
+
"connectExtension",
|
|
156
|
+
obj([
|
|
157
|
+
("specModule", str("spec.mjs")),
|
|
158
|
+
("mappingsModule", str("map.mjs")),
|
|
159
|
+
("extensionPointName", str("Platform.Plugin")),
|
|
160
|
+
]),
|
|
161
|
+
),
|
|
162
|
+
]),
|
|
163
|
+
)
|
|
164
|
+
let ce = asRecord.connectExtension->Option.getOrThrow
|
|
165
|
+
expect(ce.extensionPointName)->toBe("Platform.Plugin")
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
testSync("extension entries get the former JS normalizer's defaults", () => {
|
|
169
|
+
let c = EventCollectorEntryPoint_Ops.parseHandlerConfig(
|
|
170
|
+
minimalConfig([
|
|
171
|
+
(
|
|
172
|
+
"extensions",
|
|
173
|
+
JSON.Encode.array([
|
|
174
|
+
// no name, no module specifiers, no aggregate/readModel lists
|
|
175
|
+
obj([("extensionPointName", str("Ordering.Orders"))]),
|
|
176
|
+
]),
|
|
177
|
+
),
|
|
178
|
+
]),
|
|
179
|
+
)
|
|
180
|
+
let ext = c.extensions->Array.getUnsafe(0)
|
|
181
|
+
expect(ext.name)->toBe("Ordering.Orders") // name falls back to the EP name
|
|
182
|
+
expect(ext.specModule)->toBe("")
|
|
183
|
+
expect(ext.aggregateNames)->toEqual([])
|
|
184
|
+
expect(ext.readModelNames)->toEqual([])
|
|
185
|
+
})
|
|
186
|
+
|
|
187
|
+
testSync("decodes extensionPoints entries and the env-var maps", () => {
|
|
188
|
+
let c = EventCollectorEntryPoint_Ops.parseHandlerConfig(
|
|
189
|
+
minimalConfig([
|
|
190
|
+
(
|
|
191
|
+
"extensionPoints",
|
|
192
|
+
JSON.Encode.array([
|
|
193
|
+
obj([
|
|
194
|
+
("specModule", str("s.mjs")),
|
|
195
|
+
("mappingsModule", str("m.mjs")),
|
|
196
|
+
("eventTopicArn", str("arn:ep")),
|
|
197
|
+
("aggregateNames", JSON.Encode.array([str("Plugin")])),
|
|
198
|
+
]),
|
|
199
|
+
]),
|
|
200
|
+
),
|
|
201
|
+
("publishToAggregates", obj([("Plugin", str("PTA_Plugin_QUEUE_URL"))])),
|
|
202
|
+
(
|
|
203
|
+
"readModelNamesForSourceName",
|
|
204
|
+
obj([("Ordering.Orders", JSON.Encode.array([str("ProductDemands")]))]),
|
|
205
|
+
),
|
|
206
|
+
]),
|
|
207
|
+
)
|
|
208
|
+
let ep = c.extensionPoints->Array.getUnsafe(0)
|
|
209
|
+
expect(ep.eventTopicArn)->toBe("arn:ep")
|
|
210
|
+
expect(ep.aggregateNames)->toEqual(["Plugin"])
|
|
211
|
+
expect(c.publishToAggregates->Dict.get("Plugin"))->toEqual(Some("PTA_Plugin_QUEUE_URL"))
|
|
212
|
+
expect(c.readModelNamesForSourceName->Dict.get("Ordering.Orders"))->toEqual(
|
|
213
|
+
Some(["ProductDemands"]),
|
|
214
|
+
)
|
|
215
|
+
})
|
|
216
|
+
})
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Stdlib_JsExn from "@rescript/runtime/lib/es6/Stdlib_JsExn.js";
|
|
4
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
5
|
+
import * as Primitive_exceptions from "@rescript/runtime/lib/es6/Primitive_exceptions.js";
|
|
6
|
+
import * as EventCollectorEntryPoint_Ops$ReventlessAws from "../src/adapter/Runtime/EventCollectorEntryPoint_Ops.res.mjs";
|
|
7
|
+
|
|
8
|
+
function str(prim) {
|
|
9
|
+
return prim;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function obj(pairs) {
|
|
13
|
+
return Object.fromEntries(pairs);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
globalThis.describe("EventCollectorEntryPoint_Ops.projectPluginRow", () => {
|
|
17
|
+
globalThis.test("rejects a non-object row", () => {
|
|
18
|
+
globalThis.expect(Stdlib_Option.isNone(EventCollectorEntryPoint_Ops$ReventlessAws.projectPluginRow("nope"))).toBe(true);
|
|
19
|
+
});
|
|
20
|
+
globalThis.test("rejects a row missing id or status", () => {
|
|
21
|
+
globalThis.expect(Stdlib_Option.isNone(EventCollectorEntryPoint_Ops$ReventlessAws.projectPluginRow(Object.fromEntries([[
|
|
22
|
+
"status",
|
|
23
|
+
"Connected"
|
|
24
|
+
]])))).toBe(true);
|
|
25
|
+
globalThis.expect(Stdlib_Option.isNone(EventCollectorEntryPoint_Ops$ReventlessAws.projectPluginRow(Object.fromEntries([[
|
|
26
|
+
"id",
|
|
27
|
+
"Catalog@1"
|
|
28
|
+
]])))).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
globalThis.test("projects the id/status/eventCollector subset with defaults", () => {
|
|
31
|
+
let p = Stdlib_Option.getOrThrow(EventCollectorEntryPoint_Ops$ReventlessAws.projectPluginRow(Object.fromEntries([
|
|
32
|
+
[
|
|
33
|
+
"id",
|
|
34
|
+
"Catalog@1"
|
|
35
|
+
],
|
|
36
|
+
[
|
|
37
|
+
"status",
|
|
38
|
+
"Connected"
|
|
39
|
+
]
|
|
40
|
+
])), undefined);
|
|
41
|
+
globalThis.expect(p.id).toBe("Catalog@1");
|
|
42
|
+
globalThis.expect(p.status).toBe("Connected");
|
|
43
|
+
globalThis.expect(p.eventCollector).toBe("");
|
|
44
|
+
globalThis.expect(p.extensions.length).toBe(0);
|
|
45
|
+
globalThis.expect(p.extensionPoints.length).toBe(0);
|
|
46
|
+
globalThis.expect(Stdlib_Option.isNone(p.dcbEventLog)).toBe(true);
|
|
47
|
+
});
|
|
48
|
+
globalThis.test("decodes extensions, dropping entries without extensionPointName", () => {
|
|
49
|
+
let row = Object.fromEntries([
|
|
50
|
+
[
|
|
51
|
+
"id",
|
|
52
|
+
"Ordering@2"
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
"status",
|
|
56
|
+
"Connected"
|
|
57
|
+
],
|
|
58
|
+
[
|
|
59
|
+
"eventCollector",
|
|
60
|
+
"ec-arn"
|
|
61
|
+
],
|
|
62
|
+
[
|
|
63
|
+
"extensions",
|
|
64
|
+
[
|
|
65
|
+
Object.fromEntries([
|
|
66
|
+
[
|
|
67
|
+
"name",
|
|
68
|
+
"OrdersExt"
|
|
69
|
+
],
|
|
70
|
+
[
|
|
71
|
+
"extensionPointName",
|
|
72
|
+
"Catalog.Products"
|
|
73
|
+
],
|
|
74
|
+
[
|
|
75
|
+
"dcbSources",
|
|
76
|
+
[
|
|
77
|
+
"prod",
|
|
78
|
+
7
|
|
79
|
+
]
|
|
80
|
+
]
|
|
81
|
+
]),
|
|
82
|
+
Object.fromEntries([[
|
|
83
|
+
"name",
|
|
84
|
+
"Malformed"
|
|
85
|
+
]])
|
|
86
|
+
]
|
|
87
|
+
]
|
|
88
|
+
]);
|
|
89
|
+
let p = Stdlib_Option.getOrThrow(EventCollectorEntryPoint_Ops$ReventlessAws.projectPluginRow(row), undefined);
|
|
90
|
+
globalThis.expect(p.eventCollector).toBe("ec-arn");
|
|
91
|
+
globalThis.expect(p.extensions.length).toBe(1);
|
|
92
|
+
let e = p.extensions[0];
|
|
93
|
+
globalThis.expect(e.name).toBe("OrdersExt");
|
|
94
|
+
globalThis.expect(e.extensionPointName).toBe("Catalog.Products");
|
|
95
|
+
globalThis.expect(e.dcbSources).toEqual(["prod"]);
|
|
96
|
+
});
|
|
97
|
+
globalThis.test("decodes extensionPoints and dcbEventLog; drops EPs without name/eventTopic", () => {
|
|
98
|
+
let row = Object.fromEntries([
|
|
99
|
+
[
|
|
100
|
+
"id",
|
|
101
|
+
"Catalog@1"
|
|
102
|
+
],
|
|
103
|
+
[
|
|
104
|
+
"status",
|
|
105
|
+
"Connected"
|
|
106
|
+
],
|
|
107
|
+
[
|
|
108
|
+
"extensionPoints",
|
|
109
|
+
[
|
|
110
|
+
Object.fromEntries([
|
|
111
|
+
[
|
|
112
|
+
"name",
|
|
113
|
+
"Catalog.Products"
|
|
114
|
+
],
|
|
115
|
+
[
|
|
116
|
+
"eventTopic",
|
|
117
|
+
"t-arn"
|
|
118
|
+
]
|
|
119
|
+
]),
|
|
120
|
+
Object.fromEntries([[
|
|
121
|
+
"name",
|
|
122
|
+
"NoTopic"
|
|
123
|
+
]])
|
|
124
|
+
]
|
|
125
|
+
],
|
|
126
|
+
[
|
|
127
|
+
"dcbEventLog",
|
|
128
|
+
Object.fromEntries([
|
|
129
|
+
[
|
|
130
|
+
"name",
|
|
131
|
+
"catalog-dcb"
|
|
132
|
+
],
|
|
133
|
+
[
|
|
134
|
+
"eventTopicArn",
|
|
135
|
+
"dcb-arn"
|
|
136
|
+
]
|
|
137
|
+
])
|
|
138
|
+
]
|
|
139
|
+
]);
|
|
140
|
+
let p = Stdlib_Option.getOrThrow(EventCollectorEntryPoint_Ops$ReventlessAws.projectPluginRow(row), undefined);
|
|
141
|
+
globalThis.expect(p.extensionPoints.length).toBe(1);
|
|
142
|
+
let ep = p.extensionPoints[0];
|
|
143
|
+
globalThis.expect(ep.name).toBe("Catalog.Products");
|
|
144
|
+
globalThis.expect(ep.commandTopic).toBe("");
|
|
145
|
+
globalThis.expect(ep.eventTopic).toBe("t-arn");
|
|
146
|
+
let dcb = Stdlib_Option.getOrThrow(p.dcbEventLog, undefined);
|
|
147
|
+
globalThis.expect(dcb.name).toBe("catalog-dcb");
|
|
148
|
+
globalThis.expect(dcb.eventTopicArn).toBe("dcb-arn");
|
|
149
|
+
});
|
|
150
|
+
globalThis.test("drops a dcbEventLog missing eventTopicArn", () => {
|
|
151
|
+
let row = Object.fromEntries([
|
|
152
|
+
[
|
|
153
|
+
"id",
|
|
154
|
+
"Catalog@1"
|
|
155
|
+
],
|
|
156
|
+
[
|
|
157
|
+
"status",
|
|
158
|
+
"Connected"
|
|
159
|
+
],
|
|
160
|
+
[
|
|
161
|
+
"dcbEventLog",
|
|
162
|
+
Object.fromEntries([[
|
|
163
|
+
"name",
|
|
164
|
+
"catalog-dcb"
|
|
165
|
+
]])
|
|
166
|
+
]
|
|
167
|
+
]);
|
|
168
|
+
globalThis.expect(Stdlib_Option.isNone(Stdlib_Option.getOrThrow(EventCollectorEntryPoint_Ops$ReventlessAws.projectPluginRow(row), undefined).dcbEventLog)).toBe(true);
|
|
169
|
+
});
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
function minimalConfig(extras) {
|
|
173
|
+
return JSON.stringify(Object.fromEntries([
|
|
174
|
+
[
|
|
175
|
+
"queueUrl",
|
|
176
|
+
"q-url"
|
|
177
|
+
],
|
|
178
|
+
[
|
|
179
|
+
"pluginExtensionPointCmdTopicUrl",
|
|
180
|
+
"ep-url"
|
|
181
|
+
],
|
|
182
|
+
[
|
|
183
|
+
"eventTopicArn",
|
|
184
|
+
"topic-arn"
|
|
185
|
+
],
|
|
186
|
+
[
|
|
187
|
+
"pluginReadModelTableName",
|
|
188
|
+
"plugin-rm"
|
|
189
|
+
],
|
|
190
|
+
[
|
|
191
|
+
"appSyncApiId",
|
|
192
|
+
"NOT_AVAILABLE"
|
|
193
|
+
],
|
|
194
|
+
[
|
|
195
|
+
"schedulerRoleArn",
|
|
196
|
+
"role-arn"
|
|
197
|
+
],
|
|
198
|
+
[
|
|
199
|
+
"schedulerQueueArn",
|
|
200
|
+
""
|
|
201
|
+
],
|
|
202
|
+
[
|
|
203
|
+
"schedulerQueueName",
|
|
204
|
+
""
|
|
205
|
+
],
|
|
206
|
+
[
|
|
207
|
+
"extensionPoints",
|
|
208
|
+
[]
|
|
209
|
+
],
|
|
210
|
+
[
|
|
211
|
+
"extensions",
|
|
212
|
+
[]
|
|
213
|
+
],
|
|
214
|
+
[
|
|
215
|
+
"publishToAggregates",
|
|
216
|
+
Object.fromEntries([])
|
|
217
|
+
]
|
|
218
|
+
].concat(extras)));
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
function throws(f) {
|
|
222
|
+
try {
|
|
223
|
+
f();
|
|
224
|
+
return;
|
|
225
|
+
} catch (raw_exn) {
|
|
226
|
+
let exn = Primitive_exceptions.internalToException(raw_exn);
|
|
227
|
+
return Stdlib_Option.flatMap(Stdlib_JsExn.fromException(exn), Stdlib_JsExn.message);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
globalThis.describe("EventCollectorEntryPoint_Ops.parseHandlerConfig", () => {
|
|
232
|
+
globalThis.test("throws the named errors for empty / malformed / incomplete config", () => {
|
|
233
|
+
globalThis.expect(throws(() => EventCollectorEntryPoint_Ops$ReventlessAws.parseHandlerConfig(""))).toEqual("HANDLER_CONFIG env var is empty");
|
|
234
|
+
globalThis.expect(Stdlib_Option.mapOr(throws(() => EventCollectorEntryPoint_Ops$ReventlessAws.parseHandlerConfig("{nope")), false, m => m.startsWith("HANDLER_CONFIG JSON parse error:"))).toBe(true);
|
|
235
|
+
globalThis.expect(throws(() => EventCollectorEntryPoint_Ops$ReventlessAws.parseHandlerConfig(`{"queueUrl":"q"}`))).toEqual("HANDLER_CONFIG missing required field: pluginExtensionPointCmdTopicUrl");
|
|
236
|
+
});
|
|
237
|
+
globalThis.test("decodes a minimal config with empty-collection defaults", () => {
|
|
238
|
+
let c = EventCollectorEntryPoint_Ops$ReventlessAws.parseHandlerConfig(minimalConfig([]));
|
|
239
|
+
globalThis.expect(c.queueUrl).toBe("q-url");
|
|
240
|
+
globalThis.expect(Stdlib_Option.isNone(c.connectExtension)).toBe(true);
|
|
241
|
+
globalThis.expect(Object.keys(c.readModelQueueUrls).length).toBe(0);
|
|
242
|
+
globalThis.expect(Object.keys(c.readModelNamesForSourceName).length).toBe(0);
|
|
243
|
+
});
|
|
244
|
+
globalThis.test("connectExtension: JSON null (admin) maps to None; a record decodes", () => {
|
|
245
|
+
let asNull = EventCollectorEntryPoint_Ops$ReventlessAws.parseHandlerConfig(minimalConfig([[
|
|
246
|
+
"connectExtension",
|
|
247
|
+
null
|
|
248
|
+
]]));
|
|
249
|
+
globalThis.expect(Stdlib_Option.isNone(asNull.connectExtension)).toBe(true);
|
|
250
|
+
let asRecord = EventCollectorEntryPoint_Ops$ReventlessAws.parseHandlerConfig(minimalConfig([[
|
|
251
|
+
"connectExtension",
|
|
252
|
+
Object.fromEntries([
|
|
253
|
+
[
|
|
254
|
+
"specModule",
|
|
255
|
+
"spec.mjs"
|
|
256
|
+
],
|
|
257
|
+
[
|
|
258
|
+
"mappingsModule",
|
|
259
|
+
"map.mjs"
|
|
260
|
+
],
|
|
261
|
+
[
|
|
262
|
+
"extensionPointName",
|
|
263
|
+
"Platform.Plugin"
|
|
264
|
+
]
|
|
265
|
+
])
|
|
266
|
+
]]));
|
|
267
|
+
let ce = Stdlib_Option.getOrThrow(asRecord.connectExtension, undefined);
|
|
268
|
+
globalThis.expect(ce.extensionPointName).toBe("Platform.Plugin");
|
|
269
|
+
});
|
|
270
|
+
globalThis.test("extension entries get the former JS normalizer's defaults", () => {
|
|
271
|
+
let c = EventCollectorEntryPoint_Ops$ReventlessAws.parseHandlerConfig(minimalConfig([[
|
|
272
|
+
"extensions",
|
|
273
|
+
[Object.fromEntries([[
|
|
274
|
+
"extensionPointName",
|
|
275
|
+
"Ordering.Orders"
|
|
276
|
+
]])]
|
|
277
|
+
]]));
|
|
278
|
+
let ext = c.extensions[0];
|
|
279
|
+
globalThis.expect(ext.name).toBe("Ordering.Orders");
|
|
280
|
+
globalThis.expect(ext.specModule).toBe("");
|
|
281
|
+
globalThis.expect(ext.aggregateNames).toEqual([]);
|
|
282
|
+
globalThis.expect(ext.readModelNames).toEqual([]);
|
|
283
|
+
});
|
|
284
|
+
globalThis.test("decodes extensionPoints entries and the env-var maps", () => {
|
|
285
|
+
let c = EventCollectorEntryPoint_Ops$ReventlessAws.parseHandlerConfig(minimalConfig([
|
|
286
|
+
[
|
|
287
|
+
"extensionPoints",
|
|
288
|
+
[Object.fromEntries([
|
|
289
|
+
[
|
|
290
|
+
"specModule",
|
|
291
|
+
"s.mjs"
|
|
292
|
+
],
|
|
293
|
+
[
|
|
294
|
+
"mappingsModule",
|
|
295
|
+
"m.mjs"
|
|
296
|
+
],
|
|
297
|
+
[
|
|
298
|
+
"eventTopicArn",
|
|
299
|
+
"arn:ep"
|
|
300
|
+
],
|
|
301
|
+
[
|
|
302
|
+
"aggregateNames",
|
|
303
|
+
["Plugin"]
|
|
304
|
+
]
|
|
305
|
+
])]
|
|
306
|
+
],
|
|
307
|
+
[
|
|
308
|
+
"publishToAggregates",
|
|
309
|
+
Object.fromEntries([[
|
|
310
|
+
"Plugin",
|
|
311
|
+
"PTA_Plugin_QUEUE_URL"
|
|
312
|
+
]])
|
|
313
|
+
],
|
|
314
|
+
[
|
|
315
|
+
"readModelNamesForSourceName",
|
|
316
|
+
Object.fromEntries([[
|
|
317
|
+
"Ordering.Orders",
|
|
318
|
+
["ProductDemands"]
|
|
319
|
+
]])
|
|
320
|
+
]
|
|
321
|
+
]));
|
|
322
|
+
let ep = c.extensionPoints[0];
|
|
323
|
+
globalThis.expect(ep.eventTopicArn).toBe("arn:ep");
|
|
324
|
+
globalThis.expect(ep.aggregateNames).toEqual(["Plugin"]);
|
|
325
|
+
globalThis.expect(c.publishToAggregates["Plugin"]).toEqual("PTA_Plugin_QUEUE_URL");
|
|
326
|
+
globalThis.expect(c.readModelNamesForSourceName["Ordering.Orders"]).toEqual(["ProductDemands"]);
|
|
327
|
+
});
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
let project = EventCollectorEntryPoint_Ops$ReventlessAws.projectPluginRow;
|
|
331
|
+
|
|
332
|
+
export {
|
|
333
|
+
str,
|
|
334
|
+
obj,
|
|
335
|
+
project,
|
|
336
|
+
minimalConfig,
|
|
337
|
+
throws,
|
|
338
|
+
}
|
|
339
|
+
/* Not a pure module */
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
// Guards the typed cold-start core hoisted out of EventMapperEntryPoint.mjs:
|
|
2
|
+
// - parseHandlerConfig — the {targetSpecModule, mappingsModule, queueUrl}
|
|
3
|
+
// shape written by AggregateRuntime_Builder_Micro / _Micro_Async.
|
|
4
|
+
// - makeCounterOps — the queryEngine stub shape (the former shell's stub had
|
|
5
|
+
// `query`/`get` fields where QueryEngine.operations needs `scan`/`query`).
|
|
6
|
+
// - makeStreamHandler — the full pipeline: SQS-record body parse →
|
|
7
|
+
// commonEventsHandler → publish of the produced commands.
|
|
8
|
+
|
|
9
|
+
open JestGlobals
|
|
10
|
+
|
|
11
|
+
external toCbRecord: PulumiAws.SQS.Queue.record => PulumiAws.Lambda.CallbackFunction.record =
|
|
12
|
+
"%identity"
|
|
13
|
+
|
|
14
|
+
let sqsRecord = (body: string): PulumiAws.Lambda.CallbackFunction.record =>
|
|
15
|
+
(
|
|
16
|
+
{
|
|
17
|
+
messageId: "m1",
|
|
18
|
+
receiptHandle: "r1",
|
|
19
|
+
body,
|
|
20
|
+
md5OfBody: "",
|
|
21
|
+
eventSource: "aws:sqs",
|
|
22
|
+
eventSourceARN: "arn:aws:sqs:eu-west-1:000000000000:q",
|
|
23
|
+
awsRegion: "eu-west-1",
|
|
24
|
+
}: PulumiAws.SQS.Queue.record
|
|
25
|
+
)->toCbRecord
|
|
26
|
+
|
|
27
|
+
let context: PulumiAws.Lambda.context = {
|
|
28
|
+
callbackWaitsForEmptyEventLoop: false,
|
|
29
|
+
functionName: "test",
|
|
30
|
+
functionVersion: "1",
|
|
31
|
+
invokedFunctionArn: "arn:test",
|
|
32
|
+
memoryLimitInMB: 128,
|
|
33
|
+
awsRequestId: "req-1",
|
|
34
|
+
logGroupName: "lg",
|
|
35
|
+
logStreamName: "ls",
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
describe("EventMapperEntryPoint_Ops.parseHandlerConfig", () => {
|
|
39
|
+
testSync("reads the builder's field names", () => {
|
|
40
|
+
let config = EventMapperEntryPoint_Ops.parseHandlerConfig(
|
|
41
|
+
`{"targetSpecModule":"@x/p/src/Aggregate/Product.res.mjs","mappingsModule":"@x/p/src/Aggregate/Product_Mappings.res.mjs","queueUrl":"https://sqs/q"}`,
|
|
42
|
+
)
|
|
43
|
+
expect(config.targetSpecModule)->toEqual(Some("@x/p/src/Aggregate/Product.res.mjs"))
|
|
44
|
+
expect(config.mappingsModule)->toEqual(Some("@x/p/src/Aggregate/Product_Mappings.res.mjs"))
|
|
45
|
+
expect(config.queueUrl)->toEqual(Some("https://sqs/q"))
|
|
46
|
+
})
|
|
47
|
+
})
|
|
48
|
+
|
|
49
|
+
describe("EventMapperEntryPoint_Ops.makeCounterOps", () => {
|
|
50
|
+
test("queryEngine stubs return empty results instead of crashing", async () => {
|
|
51
|
+
let ops = EventMapperEntryPoint_Ops.makeCounterOps({queueUrl: "https://sqs/q"})
|
|
52
|
+
let scanned = await ops.queryEngine.scan(~readModelName="X", ~filterConfigs=[], ~limit=10)
|
|
53
|
+
expect(scanned->Array.length)->toBe(0)
|
|
54
|
+
let queried = await ops.queryEngine.query(
|
|
55
|
+
~readModelName="X",
|
|
56
|
+
~id=Reventless.QueryEngine.String("a"),
|
|
57
|
+
)
|
|
58
|
+
expect(queried->Array.length)->toBe(0)
|
|
59
|
+
})
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
describe("EventMapperEntryPoint_Ops.makeStreamHandler", () => {
|
|
63
|
+
test("parses SQS bodies, runs commonEventsHandler, publishes produced commands", async () => {
|
|
64
|
+
let received: ref<array<JSON.t>> = ref([])
|
|
65
|
+
let published: ref<array<ReventlessCore.Message.commandJson>> = ref([])
|
|
66
|
+
let ops: EventMapperEntryPoint_Ops.counterOps = {
|
|
67
|
+
publishJsons: async jsons => published := published.contents->Array.concat(jsons),
|
|
68
|
+
queryEngine: {
|
|
69
|
+
scan: async (~readModelName as _, ~filterConfigs as _, ~limit as _) => [],
|
|
70
|
+
query: async (
|
|
71
|
+
~readModelName as _,
|
|
72
|
+
~key as _=?,
|
|
73
|
+
~id as _,
|
|
74
|
+
~subIdConfig as _=?,
|
|
75
|
+
~filterConfigs as _=?,
|
|
76
|
+
~ascending as _=?,
|
|
77
|
+
~limit as _=?,
|
|
78
|
+
) => [],
|
|
79
|
+
},
|
|
80
|
+
}
|
|
81
|
+
let command: ReventlessCore.Message.commandJson = {
|
|
82
|
+
id: "prd-1",
|
|
83
|
+
meta: ReventlessCore.Message.generateMeta(~service="Product", ~ip="", ~user="test"),
|
|
84
|
+
commandJson: JSON.Encode.string("Add"),
|
|
85
|
+
}
|
|
86
|
+
let commonEventsHandler: EventMapperEntryPoint_Ops.commonEventsHandler = async jsons => {
|
|
87
|
+
received := received.contents->Array.concat(jsons)
|
|
88
|
+
(Promise.resolve([command]), [])
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
let streamHandler = EventMapperEntryPoint_Ops.makeStreamHandler(ops, commonEventsHandler)
|
|
92
|
+
let event: PulumiAws.Lambda.CallbackFunction.event = {
|
|
93
|
+
records: [sqsRecord(`{"id":"e1","event":"Added"}`), sqsRecord("not json")],
|
|
94
|
+
}
|
|
95
|
+
await streamHandler(event, context)->Effect.runPromise
|
|
96
|
+
|
|
97
|
+
// The unparsable body is dropped by the channel decode; the parsed one
|
|
98
|
+
// reaches the mapper and its produced command is published.
|
|
99
|
+
expect(received.contents->Array.length)->toBe(1)
|
|
100
|
+
expect(published.contents->Array.length)->toBe(1)
|
|
101
|
+
expect((published.contents->Array.getUnsafe(0)).id)->toBe("prd-1")
|
|
102
|
+
})
|
|
103
|
+
})
|