@reventlessdev/reventless-gwt 1.0.0-alpha.237 → 1.0.0-alpha.239
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 +18 -0
- package/package.json +5 -5
- package/src/Automation_GWT.res +130 -0
- package/src/Automation_GWT.res.mjs +193 -0
- package/src/Capabilities_Fake.res +157 -0
- package/src/Capabilities_Fake.res.mjs +254 -0
- package/src/Flow_GWT.res +112 -1
- package/src/Flow_GWT.res.mjs +165 -11
- package/src/InboundTranslation_GWT.res +112 -0
- package/src/InboundTranslation_GWT.res.mjs +190 -1
- package/src/OutboundTranslation_GWT.res +207 -4
- package/src/OutboundTranslation_GWT.res.mjs +257 -1
- package/tests/AutomationFromSliceGwtTest.res +145 -0
- package/tests/AutomationFromSliceGwtTest.res.mjs +353 -0
- package/tests/InboundFromSliceGwtTest.res +63 -0
- package/tests/InboundFromSliceGwtTest.res.mjs +164 -0
- package/tests/InboundTranslationGwtTest.res.mjs +0 -5
- package/tests/OutboundFromSliceGwtTest.res +124 -0
- package/tests/OutboundFromSliceGwtTest.res.mjs +268 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Sury from "sury";
|
|
4
|
+
import * as Stdlib_JsError from "@rescript/runtime/lib/es6/Stdlib_JsError.js";
|
|
5
|
+
import * as Messaging$Reventless from "@reventlessdev/reventless-spec/src/semantic/Messaging.res.mjs";
|
|
6
|
+
import * as Capabilities_Fake$ReventlessGwt from "../src/Capabilities_Fake.res.mjs";
|
|
7
|
+
import * as OutboundTranslation_GWT$ReventlessGwt from "../src/OutboundTranslation_GWT.res.mjs";
|
|
8
|
+
|
|
9
|
+
let consumedEventSchema = Sury.$schema(s => ({
|
|
10
|
+
TAG: "Registered",
|
|
11
|
+
customerId: s.m(Sury.string),
|
|
12
|
+
email: s.m(Sury.string)
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
let outboundItemSchema = Sury.$schema(s => ({
|
|
16
|
+
email: s.m(Sury.string)
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
let inboundCommandSchema = Sury.union([
|
|
20
|
+
Sury.$schema(s => ({
|
|
21
|
+
TAG: "MarkWelcomed",
|
|
22
|
+
customerId: s.m(Sury.string)
|
|
23
|
+
})),
|
|
24
|
+
Sury.$schema(s => ({
|
|
25
|
+
TAG: "MarkUnreachable",
|
|
26
|
+
customerId: s.m(Sury.string)
|
|
27
|
+
}))
|
|
28
|
+
]);
|
|
29
|
+
|
|
30
|
+
let sourceNames = [];
|
|
31
|
+
|
|
32
|
+
let capabilityNeeds = [];
|
|
33
|
+
|
|
34
|
+
let traits = [];
|
|
35
|
+
|
|
36
|
+
let Welcome_targetName = "Customer";
|
|
37
|
+
|
|
38
|
+
let Welcome = {
|
|
39
|
+
name: "Welcome",
|
|
40
|
+
moduleUrl: "",
|
|
41
|
+
consumedEventSchema: consumedEventSchema,
|
|
42
|
+
outboundItemSchema: outboundItemSchema,
|
|
43
|
+
inboundCommandSchema: inboundCommandSchema,
|
|
44
|
+
maxRetries: 2,
|
|
45
|
+
heartbeatInterval: 60,
|
|
46
|
+
targetName: Welcome_targetName,
|
|
47
|
+
sourceNames: sourceNames,
|
|
48
|
+
externalSystem: undefined,
|
|
49
|
+
capabilityNeeds: capabilityNeeds,
|
|
50
|
+
traits: traits
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
let moduleUrl = "";
|
|
54
|
+
|
|
55
|
+
function collect(event, sourceId) {
|
|
56
|
+
return [[
|
|
57
|
+
sourceId,
|
|
58
|
+
{
|
|
59
|
+
email: event.email
|
|
60
|
+
}
|
|
61
|
+
]];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function translate(id, item, capabilities) {
|
|
65
|
+
let failure = await capabilities.messaging.send({
|
|
66
|
+
TAG: "ToEmail",
|
|
67
|
+
_0: item.email
|
|
68
|
+
}, {
|
|
69
|
+
subject: "Welcome",
|
|
70
|
+
body: "Hello"
|
|
71
|
+
});
|
|
72
|
+
if (failure.TAG === "Ok") {
|
|
73
|
+
return {
|
|
74
|
+
TAG: "Ok",
|
|
75
|
+
_0: [
|
|
76
|
+
id,
|
|
77
|
+
{
|
|
78
|
+
TAG: "MarkWelcomed",
|
|
79
|
+
customerId: id
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
};
|
|
83
|
+
} else {
|
|
84
|
+
return {
|
|
85
|
+
TAG: "Error",
|
|
86
|
+
_0: Messaging$Reventless.failureReason(failure._0)
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function onExhausted(id, _item, param) {
|
|
92
|
+
return [
|
|
93
|
+
id,
|
|
94
|
+
{
|
|
95
|
+
TAG: "MarkUnreachable",
|
|
96
|
+
customerId: id
|
|
97
|
+
}
|
|
98
|
+
];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
let Welcome_Translation = {
|
|
102
|
+
moduleUrl: moduleUrl,
|
|
103
|
+
collect: collect,
|
|
104
|
+
translate: translate,
|
|
105
|
+
onExhausted: onExhausted
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
let include = OutboundTranslation_GWT$ReventlessGwt.FromSlice(Welcome)({
|
|
109
|
+
collect: collect,
|
|
110
|
+
translate: translate,
|
|
111
|
+
onExhausted: onExhausted,
|
|
112
|
+
moduleUrl: moduleUrl
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
let describe = include.describe;
|
|
116
|
+
|
|
117
|
+
let test = include.test;
|
|
118
|
+
|
|
119
|
+
let testSync = include.testSync;
|
|
120
|
+
|
|
121
|
+
let givenEvent = include.givenEvent;
|
|
122
|
+
|
|
123
|
+
let whenCollect = include.whenCollect;
|
|
124
|
+
|
|
125
|
+
let thenTodos = include.thenTodos;
|
|
126
|
+
|
|
127
|
+
let givenTodo = include.givenTodo;
|
|
128
|
+
|
|
129
|
+
let givenCapabilities = include.givenCapabilities;
|
|
130
|
+
|
|
131
|
+
let whenTranslated = include.whenTranslated;
|
|
132
|
+
|
|
133
|
+
let whenTranslateMocked = include.whenTranslateMocked;
|
|
134
|
+
|
|
135
|
+
let whenTranslateRetrying = include.whenTranslateRetrying;
|
|
136
|
+
|
|
137
|
+
let whenExhausted = include.whenExhausted;
|
|
138
|
+
|
|
139
|
+
let thenCommand = include.thenCommand;
|
|
140
|
+
|
|
141
|
+
let thenSent = include.thenSent;
|
|
142
|
+
|
|
143
|
+
let thenNothingSent = include.thenNothingSent;
|
|
144
|
+
|
|
145
|
+
let thenRetryRecorded = include.thenRetryRecorded;
|
|
146
|
+
|
|
147
|
+
let thenTodoStatus = include.thenTodoStatus;
|
|
148
|
+
|
|
149
|
+
let down = Capabilities_Fake$ReventlessGwt.make(undefined, async (param, param$1) => ({
|
|
150
|
+
TAG: "Error",
|
|
151
|
+
_0: {
|
|
152
|
+
TAG: "Unavailable",
|
|
153
|
+
_0: "smtp down"
|
|
154
|
+
}
|
|
155
|
+
}), undefined, undefined, undefined, undefined, undefined, undefined, undefined);
|
|
156
|
+
|
|
157
|
+
let welcome = {
|
|
158
|
+
TAG: "Sent",
|
|
159
|
+
recipient: {
|
|
160
|
+
TAG: "ToEmail",
|
|
161
|
+
_0: "a@b.c"
|
|
162
|
+
},
|
|
163
|
+
message: {
|
|
164
|
+
subject: "Welcome",
|
|
165
|
+
body: "Hello"
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
describe("OutboundTranslation_GWT.FromSlice", () => {
|
|
170
|
+
testSync("collect keys by the source id", () => thenTodos(whenCollect(givenEvent({
|
|
171
|
+
TAG: "Registered",
|
|
172
|
+
customerId: "c1",
|
|
173
|
+
email: "a@b.c"
|
|
174
|
+
}), "c1"), [[
|
|
175
|
+
"c1",
|
|
176
|
+
{
|
|
177
|
+
email: "a@b.c"
|
|
178
|
+
}
|
|
179
|
+
]]));
|
|
180
|
+
test("translate sends through the messaging capability", undefined, () => thenSent(whenTranslated(givenTodo("c1", {
|
|
181
|
+
email: "a@b.c"
|
|
182
|
+
})), [welcome]));
|
|
183
|
+
test("translate answers with a command", undefined, () => thenCommand(whenTranslated(givenTodo("c1", {
|
|
184
|
+
email: "a@b.c"
|
|
185
|
+
})), "c1", {
|
|
186
|
+
TAG: "MarkWelcomed",
|
|
187
|
+
customerId: "c1"
|
|
188
|
+
}));
|
|
189
|
+
test("a failed attempt leaves the row Failed", undefined, () => thenTodoStatus(whenTranslated(givenCapabilities(givenTodo("c1", {
|
|
190
|
+
email: "a@b.c"
|
|
191
|
+
}), down)), "c1", "Failed"));
|
|
192
|
+
test("#Pending still reads as #Failed", undefined, () => thenTodoStatus(whenTranslated(givenCapabilities(givenTodo("c1", {
|
|
193
|
+
email: "a@b.c"
|
|
194
|
+
}), down)), "c1", "Pending"));
|
|
195
|
+
test("maxRetries failed attempts abandon the row", undefined, () => thenTodoStatus(whenTranslateRetrying(givenTodo("c1", {
|
|
196
|
+
email: "a@b.c"
|
|
197
|
+
}), undefined, async (param, param$1) => ({
|
|
198
|
+
TAG: "Error",
|
|
199
|
+
_0: "down"
|
|
200
|
+
})), "c1", "Abandoned"));
|
|
201
|
+
test("maxRetries attempts in all, as the runtime makes them", undefined, () => thenRetryRecorded(whenTranslateRetrying(givenTodo("c1", {
|
|
202
|
+
email: "a@b.c"
|
|
203
|
+
}), undefined, async (param, param$1) => ({
|
|
204
|
+
TAG: "Error",
|
|
205
|
+
_0: "down"
|
|
206
|
+
})), 2));
|
|
207
|
+
test("a throw is a failed attempt", undefined, () => thenTodoStatus(whenTranslateMocked(givenTodo("c1", {
|
|
208
|
+
email: "a@b.c"
|
|
209
|
+
}), async (param, param$1) => Stdlib_JsError.throwWithMessage("boom")), "c1", "Failed"));
|
|
210
|
+
test("exhausted: onExhausted is what the domain hears", undefined, () => thenCommand(whenExhausted(givenTodo("c1", {
|
|
211
|
+
email: "a@b.c"
|
|
212
|
+
}), "smtp down"), "c1", {
|
|
213
|
+
TAG: "MarkUnreachable",
|
|
214
|
+
customerId: "c1"
|
|
215
|
+
}));
|
|
216
|
+
test("nothing sent when the slice is never translated", undefined, () => thenNothingSent(whenExhausted(givenTodo("c1", {
|
|
217
|
+
email: "a@b.c"
|
|
218
|
+
}), undefined)));
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
let encItems = include.encItems;
|
|
222
|
+
|
|
223
|
+
let commandPairJson = include.commandPairJson;
|
|
224
|
+
|
|
225
|
+
let errorOf = include.errorOf;
|
|
226
|
+
|
|
227
|
+
let fakes = include.fakes;
|
|
228
|
+
|
|
229
|
+
let attemptWith = include.attemptWith;
|
|
230
|
+
|
|
231
|
+
let attempts = include.attempts;
|
|
232
|
+
|
|
233
|
+
let thenNoCommand = include.thenNoCommand;
|
|
234
|
+
|
|
235
|
+
let statusName = include.statusName;
|
|
236
|
+
|
|
237
|
+
export {
|
|
238
|
+
Welcome,
|
|
239
|
+
Welcome_Translation,
|
|
240
|
+
describe,
|
|
241
|
+
test,
|
|
242
|
+
testSync,
|
|
243
|
+
encItems,
|
|
244
|
+
commandPairJson,
|
|
245
|
+
errorOf,
|
|
246
|
+
givenEvent,
|
|
247
|
+
whenCollect,
|
|
248
|
+
thenTodos,
|
|
249
|
+
givenTodo,
|
|
250
|
+
fakes,
|
|
251
|
+
givenCapabilities,
|
|
252
|
+
attemptWith,
|
|
253
|
+
attempts,
|
|
254
|
+
whenTranslated,
|
|
255
|
+
whenTranslateMocked,
|
|
256
|
+
whenTranslateRetrying,
|
|
257
|
+
whenExhausted,
|
|
258
|
+
thenCommand,
|
|
259
|
+
thenNoCommand,
|
|
260
|
+
thenSent,
|
|
261
|
+
thenNothingSent,
|
|
262
|
+
thenRetryRecorded,
|
|
263
|
+
statusName,
|
|
264
|
+
thenTodoStatus,
|
|
265
|
+
down,
|
|
266
|
+
welcome,
|
|
267
|
+
}
|
|
268
|
+
/* consumedEventSchema Not a pure module */
|