@reventlessdev/reventless-gwt 1.0.0-alpha.243 → 1.0.0-alpha.244
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 +6 -6
- package/src/Automation_GWT.res +100 -15
- package/src/Automation_GWT.res.mjs +94 -7
- package/src/Flow_GWT.res.mjs +1 -1
- package/tests/AutomationDeadlineGwtTest.res +2 -0
- package/tests/AutomationDeadlineGwtTest.res.mjs +25 -1
- package/tests/AutomationFromSliceGwtTest.res +3 -0
- package/tests/AutomationFromSliceGwtTest.res.mjs +31 -2
- package/tests/AutomationRescheduleGwtTest.res +264 -0
- package/tests/AutomationRescheduleGwtTest.res.mjs +723 -0
- package/tests/AutomationScheduleGwtTest.res +140 -0
- package/tests/AutomationScheduleGwtTest.res.mjs +356 -0
|
@@ -0,0 +1,723 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Sury from "sury";
|
|
4
|
+
import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
|
|
5
|
+
import * as Clock$Reventless from "@reventlessdev/reventless-spec/src/components/Clock.res.mjs";
|
|
6
|
+
import * as Schedule$Reventless from "@reventlessdev/reventless-spec/src/types/Schedule.res.mjs";
|
|
7
|
+
import * as JestBind$ReventlessGwt from "../src/JestBind.res.mjs";
|
|
8
|
+
import * as AutomationSlice$Reventless from "@reventlessdev/reventless-spec/src/components/AutomationSlice.res.mjs";
|
|
9
|
+
import * as Automation_GWT$ReventlessGwt from "../src/Automation_GWT.res.mjs";
|
|
10
|
+
|
|
11
|
+
let todoItemSchema = Sury.$schema(s => ({
|
|
12
|
+
recipientId: s.m(Sury.string)
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
let commandSchema = Sury.$schema(s => ({
|
|
16
|
+
TAG: "RequestNotification",
|
|
17
|
+
recipientId: s.m(Sury.string),
|
|
18
|
+
reference: s.m(Sury.string)
|
|
19
|
+
}));
|
|
20
|
+
|
|
21
|
+
function authorizationOf(param) {
|
|
22
|
+
return "AllowAuthenticated";
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function commandTransition(param) {
|
|
26
|
+
return "Undeclared";
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let traits = [];
|
|
30
|
+
|
|
31
|
+
let MarketingDigest = {
|
|
32
|
+
name: "MarketingDigest",
|
|
33
|
+
moduleUrl: "",
|
|
34
|
+
todoItemSchema: todoItemSchema,
|
|
35
|
+
commandSchema: commandSchema,
|
|
36
|
+
maxRetries: 3,
|
|
37
|
+
heartbeatInterval: 60,
|
|
38
|
+
targetName: "NotificationPreferences",
|
|
39
|
+
schedule: undefined,
|
|
40
|
+
authorizationOf: authorizationOf,
|
|
41
|
+
commandTransition: commandTransition,
|
|
42
|
+
traits: traits
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
let M = AutomationSlice$Reventless.Mappings.Make(MarketingDigest);
|
|
46
|
+
|
|
47
|
+
let moduleUrl = "";
|
|
48
|
+
|
|
49
|
+
let name = "OrderingDcbEventLog";
|
|
50
|
+
|
|
51
|
+
let categorySchema = Sury.union([
|
|
52
|
+
Sury.literal("Marketing"),
|
|
53
|
+
Sury.literal("Orders")
|
|
54
|
+
]);
|
|
55
|
+
|
|
56
|
+
let eventSchema = Sury.union([
|
|
57
|
+
Sury.$schema(s => ({
|
|
58
|
+
TAG: "DigestTimeChosen",
|
|
59
|
+
recipientId: s.m(Sury.string),
|
|
60
|
+
time: s.m(Schedule$Reventless.timeSchema)
|
|
61
|
+
})),
|
|
62
|
+
Sury.$schema(s => ({
|
|
63
|
+
TAG: "NotificationUnsubscribed",
|
|
64
|
+
recipientId: s.m(Sury.string),
|
|
65
|
+
category: s.m(categorySchema)
|
|
66
|
+
})),
|
|
67
|
+
Sury.$schema(s => ({
|
|
68
|
+
TAG: "NotificationRequested",
|
|
69
|
+
recipientId: s.m(Sury.string),
|
|
70
|
+
reference: s.m(Sury.string)
|
|
71
|
+
}))
|
|
72
|
+
]);
|
|
73
|
+
|
|
74
|
+
let OrderingDcbSource = {
|
|
75
|
+
Id: undefined,
|
|
76
|
+
name: name,
|
|
77
|
+
categorySchema: categorySchema,
|
|
78
|
+
eventSchema: eventSchema
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
function collect(param, param$1, _ctx) {
|
|
82
|
+
let key = param.key;
|
|
83
|
+
return [[
|
|
84
|
+
Clock$Reventless.itemId(key, param.at),
|
|
85
|
+
{
|
|
86
|
+
recipientId: key
|
|
87
|
+
}
|
|
88
|
+
]];
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function resolve(param) {
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function reschedule(param) {
|
|
96
|
+
return [];
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
let FromClock = AutomationSlice$Reventless.Mapping.Make({
|
|
100
|
+
Id: Id$Reventless.$$String,
|
|
101
|
+
name: Clock$Reventless.name,
|
|
102
|
+
eventSchema: Clock$Reventless.eventSchema
|
|
103
|
+
})(MarketingDigest)({
|
|
104
|
+
collect: collect,
|
|
105
|
+
resolve: resolve,
|
|
106
|
+
reschedule: reschedule
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
function collect$1(param, param$1, _ctx) {
|
|
110
|
+
return [];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function resolve$1(event) {
|
|
114
|
+
switch (event.TAG) {
|
|
115
|
+
case "DigestTimeChosen" :
|
|
116
|
+
case "NotificationUnsubscribed" :
|
|
117
|
+
return;
|
|
118
|
+
case "NotificationRequested" :
|
|
119
|
+
return event.reference;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
function reschedule$1(event) {
|
|
124
|
+
switch (event.TAG) {
|
|
125
|
+
case "DigestTimeChosen" :
|
|
126
|
+
return [{
|
|
127
|
+
TAG: "Set",
|
|
128
|
+
key: event.recipientId,
|
|
129
|
+
time: event.time
|
|
130
|
+
}];
|
|
131
|
+
case "NotificationUnsubscribed" :
|
|
132
|
+
if (event.category === "Marketing") {
|
|
133
|
+
return [{
|
|
134
|
+
TAG: "Clear",
|
|
135
|
+
key: event.recipientId
|
|
136
|
+
}];
|
|
137
|
+
} else {
|
|
138
|
+
return [];
|
|
139
|
+
}
|
|
140
|
+
case "NotificationRequested" :
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
let FromOrderingDcb = AutomationSlice$Reventless.Mapping.Make({
|
|
146
|
+
Id: Id$Reventless.$$String,
|
|
147
|
+
name: name,
|
|
148
|
+
eventSchema: eventSchema
|
|
149
|
+
})(MarketingDigest)({
|
|
150
|
+
collect: collect$1,
|
|
151
|
+
resolve: resolve$1,
|
|
152
|
+
reschedule: reschedule$1
|
|
153
|
+
});
|
|
154
|
+
|
|
155
|
+
let mappings = [
|
|
156
|
+
FromClock,
|
|
157
|
+
FromOrderingDcb
|
|
158
|
+
];
|
|
159
|
+
|
|
160
|
+
function process(id, item, param) {
|
|
161
|
+
return [
|
|
162
|
+
item.recipientId,
|
|
163
|
+
{
|
|
164
|
+
TAG: "RequestNotification",
|
|
165
|
+
recipientId: item.recipientId,
|
|
166
|
+
reference: id
|
|
167
|
+
}
|
|
168
|
+
];
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
function onExhausted(_id, _item) {
|
|
172
|
+
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
let MarketingDigest_Automation = {
|
|
176
|
+
M: M,
|
|
177
|
+
moduleUrl: moduleUrl,
|
|
178
|
+
OrderingDcbSource: OrderingDcbSource,
|
|
179
|
+
FromClock: FromClock,
|
|
180
|
+
FromOrderingDcb: FromOrderingDcb,
|
|
181
|
+
mappings: mappings,
|
|
182
|
+
process: process,
|
|
183
|
+
onExhausted: onExhausted
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
let include = Automation_GWT$ReventlessGwt.FromSlice(MarketingDigest)({
|
|
187
|
+
process: process,
|
|
188
|
+
onExhausted: onExhausted,
|
|
189
|
+
moduleUrl: moduleUrl,
|
|
190
|
+
mappings: mappings
|
|
191
|
+
});
|
|
192
|
+
|
|
193
|
+
let test = include.test;
|
|
194
|
+
|
|
195
|
+
let Mapping = include.Mapping;
|
|
196
|
+
|
|
197
|
+
let givenEvents = include.givenEvents;
|
|
198
|
+
|
|
199
|
+
let whenSweep = include.whenSweep;
|
|
200
|
+
|
|
201
|
+
let whenTick = include.whenTick;
|
|
202
|
+
|
|
203
|
+
let thenCommands = include.thenCommands;
|
|
204
|
+
|
|
205
|
+
let andThenEvents = include.andThenEvents;
|
|
206
|
+
|
|
207
|
+
let thenSchedules = include.thenSchedules;
|
|
208
|
+
|
|
209
|
+
let thenScenarioTodos = include.thenScenarioTodos;
|
|
210
|
+
|
|
211
|
+
let OrderingLog = Mapping(FromOrderingDcb);
|
|
212
|
+
|
|
213
|
+
let Digest_Route = include.Route;
|
|
214
|
+
|
|
215
|
+
let Digest_describe = include.describe;
|
|
216
|
+
|
|
217
|
+
let Digest_testContext = include.testContext;
|
|
218
|
+
|
|
219
|
+
let Digest_withRecordedAt = include.withRecordedAt;
|
|
220
|
+
|
|
221
|
+
let Digest_encTodos = include.encTodos;
|
|
222
|
+
|
|
223
|
+
let Digest_encPair = include.encPair;
|
|
224
|
+
|
|
225
|
+
let Digest_thenTodos = include.thenTodos;
|
|
226
|
+
|
|
227
|
+
let Digest_thenResolved = include.thenResolved;
|
|
228
|
+
|
|
229
|
+
let Digest_givenTodo = include.givenTodo;
|
|
230
|
+
|
|
231
|
+
let Digest_whenProcess = include.whenProcess;
|
|
232
|
+
|
|
233
|
+
let Digest_whenExhausted = include.whenExhausted;
|
|
234
|
+
|
|
235
|
+
let Digest_thenCommand = include.thenCommand;
|
|
236
|
+
|
|
237
|
+
let Digest_thenNoCommand = include.thenNoCommand;
|
|
238
|
+
|
|
239
|
+
let Digest_atTime = include.atTime;
|
|
240
|
+
|
|
241
|
+
let Digest_latestRecorded = include.latestRecorded;
|
|
242
|
+
|
|
243
|
+
let Digest_routeEach = include.routeEach;
|
|
244
|
+
|
|
245
|
+
let Digest_routeAll = include.routeAll;
|
|
246
|
+
|
|
247
|
+
let Digest_foldSchedules = include.foldSchedules;
|
|
248
|
+
|
|
249
|
+
let Digest_declaredRows = include.declaredRows;
|
|
250
|
+
|
|
251
|
+
let Digest_sweep = include.sweep;
|
|
252
|
+
|
|
253
|
+
let Digest_tick = include.tick;
|
|
254
|
+
|
|
255
|
+
let Digest = {
|
|
256
|
+
Route: Digest_Route,
|
|
257
|
+
describe: Digest_describe,
|
|
258
|
+
test: test,
|
|
259
|
+
testContext: Digest_testContext,
|
|
260
|
+
withRecordedAt: Digest_withRecordedAt,
|
|
261
|
+
encTodos: Digest_encTodos,
|
|
262
|
+
encPair: Digest_encPair,
|
|
263
|
+
thenTodos: Digest_thenTodos,
|
|
264
|
+
thenResolved: Digest_thenResolved,
|
|
265
|
+
Mapping: Mapping,
|
|
266
|
+
givenTodo: Digest_givenTodo,
|
|
267
|
+
whenProcess: Digest_whenProcess,
|
|
268
|
+
whenExhausted: Digest_whenExhausted,
|
|
269
|
+
thenCommand: Digest_thenCommand,
|
|
270
|
+
thenNoCommand: Digest_thenNoCommand,
|
|
271
|
+
givenEvents: givenEvents,
|
|
272
|
+
atTime: Digest_atTime,
|
|
273
|
+
latestRecorded: Digest_latestRecorded,
|
|
274
|
+
routeEach: Digest_routeEach,
|
|
275
|
+
routeAll: Digest_routeAll,
|
|
276
|
+
foldSchedules: Digest_foldSchedules,
|
|
277
|
+
declaredRows: Digest_declaredRows,
|
|
278
|
+
sweep: Digest_sweep,
|
|
279
|
+
whenSweep: whenSweep,
|
|
280
|
+
tick: Digest_tick,
|
|
281
|
+
whenTick: whenTick,
|
|
282
|
+
thenCommands: thenCommands,
|
|
283
|
+
andThenEvents: andThenEvents,
|
|
284
|
+
thenSchedules: thenSchedules,
|
|
285
|
+
thenScenarioTodos: thenScenarioTodos,
|
|
286
|
+
OrderingLog: OrderingLog
|
|
287
|
+
};
|
|
288
|
+
|
|
289
|
+
function time(iso) {
|
|
290
|
+
return new Date(iso).getTime();
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
let at18 = {
|
|
294
|
+
TAG: "Calendar",
|
|
295
|
+
calendar: {
|
|
296
|
+
TAG: "Daily",
|
|
297
|
+
hour: 18,
|
|
298
|
+
minute: 0
|
|
299
|
+
}
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
let at730Berlin = {
|
|
303
|
+
TAG: "Calendar",
|
|
304
|
+
calendar: {
|
|
305
|
+
TAG: "Daily",
|
|
306
|
+
hour: 7,
|
|
307
|
+
minute: 30
|
|
308
|
+
},
|
|
309
|
+
zone: "Europe/Berlin"
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
JestBind$ReventlessGwt.describe("a schedule per customer: the marketing digest", () => {
|
|
313
|
+
test("each recipient's choice sets their own schedule", () => thenSchedules(whenSweep(givenEvents([
|
|
314
|
+
OrderingLog.event({
|
|
315
|
+
TAG: "DigestTimeChosen",
|
|
316
|
+
recipientId: "r1",
|
|
317
|
+
time: at18
|
|
318
|
+
}, undefined, undefined),
|
|
319
|
+
OrderingLog.event({
|
|
320
|
+
TAG: "DigestTimeChosen",
|
|
321
|
+
recipientId: "r2",
|
|
322
|
+
time: at730Berlin
|
|
323
|
+
}, undefined, undefined)
|
|
324
|
+
]), undefined, undefined), [
|
|
325
|
+
[
|
|
326
|
+
"r1",
|
|
327
|
+
at18
|
|
328
|
+
],
|
|
329
|
+
[
|
|
330
|
+
"r2",
|
|
331
|
+
at730Berlin
|
|
332
|
+
]
|
|
333
|
+
]));
|
|
334
|
+
test("a recipient's tick makes their digest, with the item id as reference", () => thenCommands(whenTick(givenEvents([OrderingLog.event({
|
|
335
|
+
TAG: "DigestTimeChosen",
|
|
336
|
+
recipientId: "r1",
|
|
337
|
+
time: at18
|
|
338
|
+
}, undefined, undefined)]), "r1", new Date("2026-10-16T18:00:00Z").getTime(), undefined), [[
|
|
339
|
+
"r1",
|
|
340
|
+
{
|
|
341
|
+
TAG: "RequestNotification",
|
|
342
|
+
recipientId: "r1",
|
|
343
|
+
reference: "r1@2026-10-16T18:00Z"
|
|
344
|
+
}
|
|
345
|
+
]]));
|
|
346
|
+
test("the request's own event completes the digest", () => thenScenarioTodos(andThenEvents(whenTick(givenEvents([OrderingLog.event({
|
|
347
|
+
TAG: "DigestTimeChosen",
|
|
348
|
+
recipientId: "r1",
|
|
349
|
+
time: at18
|
|
350
|
+
}, undefined, undefined)]), "r1", new Date("2026-10-16T18:00:00Z").getTime(), undefined), [OrderingLog.event({
|
|
351
|
+
TAG: "NotificationRequested",
|
|
352
|
+
recipientId: "r1",
|
|
353
|
+
reference: "r1@2026-10-16T18:00Z"
|
|
354
|
+
}, undefined, undefined)], undefined), []));
|
|
355
|
+
test("unsubscribing from marketing clears the recipient's schedule, and only theirs", () => thenSchedules(whenSweep(givenEvents([
|
|
356
|
+
OrderingLog.event({
|
|
357
|
+
TAG: "DigestTimeChosen",
|
|
358
|
+
recipientId: "r1",
|
|
359
|
+
time: at18
|
|
360
|
+
}, undefined, undefined),
|
|
361
|
+
OrderingLog.event({
|
|
362
|
+
TAG: "DigestTimeChosen",
|
|
363
|
+
recipientId: "r2",
|
|
364
|
+
time: at730Berlin
|
|
365
|
+
}, undefined, undefined),
|
|
366
|
+
OrderingLog.event({
|
|
367
|
+
TAG: "NotificationUnsubscribed",
|
|
368
|
+
recipientId: "r1",
|
|
369
|
+
category: "Marketing"
|
|
370
|
+
}, undefined, undefined),
|
|
371
|
+
OrderingLog.event({
|
|
372
|
+
TAG: "NotificationUnsubscribed",
|
|
373
|
+
recipientId: "r2",
|
|
374
|
+
category: "Orders"
|
|
375
|
+
}, undefined, undefined)
|
|
376
|
+
]), undefined, undefined), [[
|
|
377
|
+
"r2",
|
|
378
|
+
at730Berlin
|
|
379
|
+
]]));
|
|
380
|
+
test("a later choice replaces the earlier one", () => thenSchedules(whenSweep(givenEvents([
|
|
381
|
+
OrderingLog.event({
|
|
382
|
+
TAG: "DigestTimeChosen",
|
|
383
|
+
recipientId: "r1",
|
|
384
|
+
time: at18
|
|
385
|
+
}, undefined, undefined),
|
|
386
|
+
OrderingLog.event({
|
|
387
|
+
TAG: "DigestTimeChosen",
|
|
388
|
+
recipientId: "r1",
|
|
389
|
+
time: at730Berlin
|
|
390
|
+
}, undefined, undefined)
|
|
391
|
+
]), undefined, undefined), [[
|
|
392
|
+
"r1",
|
|
393
|
+
at730Berlin
|
|
394
|
+
]]));
|
|
395
|
+
});
|
|
396
|
+
|
|
397
|
+
let todoItemSchema$1 = Sury.$schema(s => ({
|
|
398
|
+
orderId: s.m(Sury.string)
|
|
399
|
+
}));
|
|
400
|
+
|
|
401
|
+
let commandSchema$1 = Sury.$schema(s => ({
|
|
402
|
+
TAG: "RemindOrder",
|
|
403
|
+
orderId: s.m(Sury.string)
|
|
404
|
+
}));
|
|
405
|
+
|
|
406
|
+
function authorizationOf$1(param) {
|
|
407
|
+
return "AllowAuthenticated";
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
function commandTransition$1(param) {
|
|
411
|
+
return "Undeclared";
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
let traits$1 = [];
|
|
415
|
+
|
|
416
|
+
let Reminder = {
|
|
417
|
+
name: "OrderReminder",
|
|
418
|
+
moduleUrl: "",
|
|
419
|
+
todoItemSchema: todoItemSchema$1,
|
|
420
|
+
commandSchema: commandSchema$1,
|
|
421
|
+
maxRetries: 3,
|
|
422
|
+
heartbeatInterval: 60,
|
|
423
|
+
targetName: "Order",
|
|
424
|
+
schedule: undefined,
|
|
425
|
+
authorizationOf: authorizationOf$1,
|
|
426
|
+
commandTransition: commandTransition$1,
|
|
427
|
+
traits: traits$1
|
|
428
|
+
};
|
|
429
|
+
|
|
430
|
+
let M$1 = AutomationSlice$Reventless.Mappings.Make(Reminder);
|
|
431
|
+
|
|
432
|
+
let moduleUrl$1 = "";
|
|
433
|
+
|
|
434
|
+
let name$1 = "OrderingDcbEventLog";
|
|
435
|
+
|
|
436
|
+
let eventSchema$1 = Sury.union([
|
|
437
|
+
Sury.$schema(s => ({
|
|
438
|
+
TAG: "OrderPlaced",
|
|
439
|
+
orderId: s.m(Sury.string)
|
|
440
|
+
})),
|
|
441
|
+
Sury.$schema(s => ({
|
|
442
|
+
TAG: "OrderShipped",
|
|
443
|
+
orderId: s.m(Sury.string)
|
|
444
|
+
}))
|
|
445
|
+
]);
|
|
446
|
+
|
|
447
|
+
let OrderingDcbSource$1 = {
|
|
448
|
+
Id: undefined,
|
|
449
|
+
name: name$1,
|
|
450
|
+
eventSchema: eventSchema$1
|
|
451
|
+
};
|
|
452
|
+
|
|
453
|
+
function collect$2(param, param$1, _ctx) {
|
|
454
|
+
let key = param.key;
|
|
455
|
+
return [[
|
|
456
|
+
Clock$Reventless.itemId(key, param.at),
|
|
457
|
+
{
|
|
458
|
+
orderId: key
|
|
459
|
+
}
|
|
460
|
+
]];
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
function resolve$2(param) {
|
|
464
|
+
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
function reschedule$2(param) {
|
|
468
|
+
return [];
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
let FromClock$1 = AutomationSlice$Reventless.Mapping.Make({
|
|
472
|
+
Id: Id$Reventless.$$String,
|
|
473
|
+
name: Clock$Reventless.name,
|
|
474
|
+
eventSchema: Clock$Reventless.eventSchema
|
|
475
|
+
})(Reminder)({
|
|
476
|
+
collect: collect$2,
|
|
477
|
+
resolve: resolve$2,
|
|
478
|
+
reschedule: reschedule$2
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
function collect$3(param, param$1, _ctx) {
|
|
482
|
+
return [];
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function resolve$3(param) {
|
|
486
|
+
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
function reschedule$3(event) {
|
|
490
|
+
if (event.TAG === "OrderPlaced") {
|
|
491
|
+
return [{
|
|
492
|
+
TAG: "Set",
|
|
493
|
+
key: event.orderId,
|
|
494
|
+
time: {
|
|
495
|
+
TAG: "Once",
|
|
496
|
+
moment: {
|
|
497
|
+
TAG: "After",
|
|
498
|
+
_0: {
|
|
499
|
+
TAG: "Minutes",
|
|
500
|
+
_0: 10
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
}];
|
|
505
|
+
} else {
|
|
506
|
+
return [{
|
|
507
|
+
TAG: "Clear",
|
|
508
|
+
key: event.orderId
|
|
509
|
+
}];
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
let FromOrdering = AutomationSlice$Reventless.Mapping.Make({
|
|
514
|
+
Id: Id$Reventless.$$String,
|
|
515
|
+
name: name$1,
|
|
516
|
+
eventSchema: eventSchema$1
|
|
517
|
+
})(Reminder)({
|
|
518
|
+
collect: collect$3,
|
|
519
|
+
resolve: resolve$3,
|
|
520
|
+
reschedule: reschedule$3
|
|
521
|
+
});
|
|
522
|
+
|
|
523
|
+
let mappings$1 = [
|
|
524
|
+
FromClock$1,
|
|
525
|
+
FromOrdering
|
|
526
|
+
];
|
|
527
|
+
|
|
528
|
+
function process$1(_id, item, param) {
|
|
529
|
+
return [
|
|
530
|
+
item.orderId,
|
|
531
|
+
{
|
|
532
|
+
TAG: "RemindOrder",
|
|
533
|
+
orderId: item.orderId
|
|
534
|
+
}
|
|
535
|
+
];
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
function onExhausted$1(_id, _item) {
|
|
539
|
+
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
let Reminder_Automation = {
|
|
543
|
+
M: M$1,
|
|
544
|
+
moduleUrl: moduleUrl$1,
|
|
545
|
+
OrderingDcbSource: OrderingDcbSource$1,
|
|
546
|
+
FromClock: FromClock$1,
|
|
547
|
+
FromOrdering: FromOrdering,
|
|
548
|
+
mappings: mappings$1,
|
|
549
|
+
process: process$1,
|
|
550
|
+
onExhausted: onExhausted$1
|
|
551
|
+
};
|
|
552
|
+
|
|
553
|
+
let include$1 = Automation_GWT$ReventlessGwt.FromSlice(Reminder)({
|
|
554
|
+
process: process$1,
|
|
555
|
+
onExhausted: onExhausted$1,
|
|
556
|
+
moduleUrl: moduleUrl$1,
|
|
557
|
+
mappings: mappings$1
|
|
558
|
+
});
|
|
559
|
+
|
|
560
|
+
let test$1 = include$1.test;
|
|
561
|
+
|
|
562
|
+
let Mapping$1 = include$1.Mapping;
|
|
563
|
+
|
|
564
|
+
let givenEvents$1 = include$1.givenEvents;
|
|
565
|
+
|
|
566
|
+
let whenSweep$1 = include$1.whenSweep;
|
|
567
|
+
|
|
568
|
+
let whenTick$1 = include$1.whenTick;
|
|
569
|
+
|
|
570
|
+
let thenCommands$1 = include$1.thenCommands;
|
|
571
|
+
|
|
572
|
+
let thenSchedules$1 = include$1.thenSchedules;
|
|
573
|
+
|
|
574
|
+
let OrderingLog$1 = Mapping$1(FromOrdering);
|
|
575
|
+
|
|
576
|
+
let ReminderGwt_Route = include$1.Route;
|
|
577
|
+
|
|
578
|
+
let ReminderGwt_describe = include$1.describe;
|
|
579
|
+
|
|
580
|
+
let ReminderGwt_testContext = include$1.testContext;
|
|
581
|
+
|
|
582
|
+
let ReminderGwt_withRecordedAt = include$1.withRecordedAt;
|
|
583
|
+
|
|
584
|
+
let ReminderGwt_encTodos = include$1.encTodos;
|
|
585
|
+
|
|
586
|
+
let ReminderGwt_encPair = include$1.encPair;
|
|
587
|
+
|
|
588
|
+
let ReminderGwt_thenTodos = include$1.thenTodos;
|
|
589
|
+
|
|
590
|
+
let ReminderGwt_thenResolved = include$1.thenResolved;
|
|
591
|
+
|
|
592
|
+
let ReminderGwt_givenTodo = include$1.givenTodo;
|
|
593
|
+
|
|
594
|
+
let ReminderGwt_whenProcess = include$1.whenProcess;
|
|
595
|
+
|
|
596
|
+
let ReminderGwt_whenExhausted = include$1.whenExhausted;
|
|
597
|
+
|
|
598
|
+
let ReminderGwt_thenCommand = include$1.thenCommand;
|
|
599
|
+
|
|
600
|
+
let ReminderGwt_thenNoCommand = include$1.thenNoCommand;
|
|
601
|
+
|
|
602
|
+
let ReminderGwt_atTime = include$1.atTime;
|
|
603
|
+
|
|
604
|
+
let ReminderGwt_latestRecorded = include$1.latestRecorded;
|
|
605
|
+
|
|
606
|
+
let ReminderGwt_routeEach = include$1.routeEach;
|
|
607
|
+
|
|
608
|
+
let ReminderGwt_routeAll = include$1.routeAll;
|
|
609
|
+
|
|
610
|
+
let ReminderGwt_foldSchedules = include$1.foldSchedules;
|
|
611
|
+
|
|
612
|
+
let ReminderGwt_declaredRows = include$1.declaredRows;
|
|
613
|
+
|
|
614
|
+
let ReminderGwt_sweep = include$1.sweep;
|
|
615
|
+
|
|
616
|
+
let ReminderGwt_tick = include$1.tick;
|
|
617
|
+
|
|
618
|
+
let ReminderGwt_andThenEvents = include$1.andThenEvents;
|
|
619
|
+
|
|
620
|
+
let ReminderGwt_thenScenarioTodos = include$1.thenScenarioTodos;
|
|
621
|
+
|
|
622
|
+
let ReminderGwt = {
|
|
623
|
+
Route: ReminderGwt_Route,
|
|
624
|
+
describe: ReminderGwt_describe,
|
|
625
|
+
test: test$1,
|
|
626
|
+
testContext: ReminderGwt_testContext,
|
|
627
|
+
withRecordedAt: ReminderGwt_withRecordedAt,
|
|
628
|
+
encTodos: ReminderGwt_encTodos,
|
|
629
|
+
encPair: ReminderGwt_encPair,
|
|
630
|
+
thenTodos: ReminderGwt_thenTodos,
|
|
631
|
+
thenResolved: ReminderGwt_thenResolved,
|
|
632
|
+
Mapping: Mapping$1,
|
|
633
|
+
givenTodo: ReminderGwt_givenTodo,
|
|
634
|
+
whenProcess: ReminderGwt_whenProcess,
|
|
635
|
+
whenExhausted: ReminderGwt_whenExhausted,
|
|
636
|
+
thenCommand: ReminderGwt_thenCommand,
|
|
637
|
+
thenNoCommand: ReminderGwt_thenNoCommand,
|
|
638
|
+
givenEvents: givenEvents$1,
|
|
639
|
+
atTime: ReminderGwt_atTime,
|
|
640
|
+
latestRecorded: ReminderGwt_latestRecorded,
|
|
641
|
+
routeEach: ReminderGwt_routeEach,
|
|
642
|
+
routeAll: ReminderGwt_routeAll,
|
|
643
|
+
foldSchedules: ReminderGwt_foldSchedules,
|
|
644
|
+
declaredRows: ReminderGwt_declaredRows,
|
|
645
|
+
sweep: ReminderGwt_sweep,
|
|
646
|
+
whenSweep: whenSweep$1,
|
|
647
|
+
tick: ReminderGwt_tick,
|
|
648
|
+
whenTick: whenTick$1,
|
|
649
|
+
thenCommands: thenCommands$1,
|
|
650
|
+
andThenEvents: ReminderGwt_andThenEvents,
|
|
651
|
+
thenSchedules: thenSchedules$1,
|
|
652
|
+
thenScenarioTodos: ReminderGwt_thenScenarioTodos,
|
|
653
|
+
OrderingLog: OrderingLog$1
|
|
654
|
+
};
|
|
655
|
+
|
|
656
|
+
let placedAt = new Date("2026-10-16T09:00:00Z").getTime();
|
|
657
|
+
|
|
658
|
+
let tenPast = {
|
|
659
|
+
TAG: "Once",
|
|
660
|
+
moment: {
|
|
661
|
+
TAG: "At",
|
|
662
|
+
_0: {
|
|
663
|
+
year: 2026,
|
|
664
|
+
month: 10,
|
|
665
|
+
day: 16,
|
|
666
|
+
hour: 9,
|
|
667
|
+
minute: 10
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
};
|
|
671
|
+
|
|
672
|
+
JestBind$ReventlessGwt.describe("a once-only time: the reminder", () => {
|
|
673
|
+
test$1("is set ten minutes after the order was recorded", () => thenSchedules$1(whenSweep$1(givenEvents$1([OrderingLog$1.event({
|
|
674
|
+
TAG: "OrderPlaced",
|
|
675
|
+
orderId: "o1"
|
|
676
|
+
}, undefined, placedAt)]), undefined, undefined), [[
|
|
677
|
+
"o1",
|
|
678
|
+
tenPast
|
|
679
|
+
]]));
|
|
680
|
+
test$1("is cleared when the order ships", () => thenSchedules$1(whenSweep$1(givenEvents$1([
|
|
681
|
+
OrderingLog$1.event({
|
|
682
|
+
TAG: "OrderPlaced",
|
|
683
|
+
orderId: "o1"
|
|
684
|
+
}, undefined, placedAt),
|
|
685
|
+
OrderingLog$1.event({
|
|
686
|
+
TAG: "OrderShipped",
|
|
687
|
+
orderId: "o1"
|
|
688
|
+
}, undefined, placedAt + 60000)
|
|
689
|
+
]), undefined, undefined), []));
|
|
690
|
+
test$1("is cleared once it has fired, and its tick sends the reminder", () => {
|
|
691
|
+
let scenario = whenTick$1(givenEvents$1([OrderingLog$1.event({
|
|
692
|
+
TAG: "OrderPlaced",
|
|
693
|
+
orderId: "o1"
|
|
694
|
+
}, undefined, placedAt)]), "o1", new Date("2026-10-16T09:10:00Z").getTime(), undefined);
|
|
695
|
+
let failed = thenSchedules$1(scenario, []);
|
|
696
|
+
if (failed.TAG === "Ok") {
|
|
697
|
+
return thenCommands$1(scenario, [[
|
|
698
|
+
"o1",
|
|
699
|
+
{
|
|
700
|
+
TAG: "RemindOrder",
|
|
701
|
+
orderId: "o1"
|
|
702
|
+
}
|
|
703
|
+
]]);
|
|
704
|
+
} else {
|
|
705
|
+
return failed;
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
export {
|
|
711
|
+
MarketingDigest,
|
|
712
|
+
MarketingDigest_Automation,
|
|
713
|
+
Digest,
|
|
714
|
+
time,
|
|
715
|
+
at18,
|
|
716
|
+
at730Berlin,
|
|
717
|
+
Reminder,
|
|
718
|
+
Reminder_Automation,
|
|
719
|
+
ReminderGwt,
|
|
720
|
+
placedAt,
|
|
721
|
+
tenPast,
|
|
722
|
+
}
|
|
723
|
+
/* todoItemSchema Not a pure module */
|