@reventlessdev/reventless-gwt 1.0.0-alpha.238 → 1.0.0-alpha.240
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 +21 -0
- package/package.json +6 -6
- package/src/Automation_GWT.res +130 -0
- package/src/Automation_GWT.res.mjs +193 -0
- package/src/Behavior_GWT.res +6 -6
- package/src/Behavior_GWT.res.mjs +5 -5
- 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/src/StateChange/ExternalAddCategorySlice.res +1 -1
- package/src/StateChange/ExternalAddCategorySlice.res.mjs +2 -2
- package/src/StateChange/WithFixtures.res +1 -1
- package/src/StateChange/WithFixtures.res.mjs +2 -2
- package/src/StateChange/WithManualOpen.res +1 -1
- package/src/StateChange/WithManualOpen.res.mjs +2 -2
- package/tests/AutomationFromSliceGwtTest.res +145 -0
- package/tests/AutomationFromSliceGwtTest.res.mjs +353 -0
- package/tests/AutomationGwtTest.res.mjs +2 -2
- package/tests/DelegateGwtTest.res +5 -5
- package/tests/DelegateGwtTest.res.mjs +27 -27
- package/tests/FlowAggregateGwtTest.res.mjs +4 -4
- package/tests/FlowCrossPluginGwtTest.res +4 -4
- package/tests/FlowCrossPluginGwtTest.res.mjs +22 -22
- package/tests/FlowGwtTest.res.mjs +6 -6
- package/tests/InboundFromSliceGwtTest.res +63 -0
- package/tests/InboundFromSliceGwtTest.res.mjs +164 -0
- package/tests/InboundTranslationGwtTest.res.mjs +2 -7
- package/tests/MappingGwtTest.res.mjs +12 -12
- package/tests/OutboundFromSliceGwtTest.res +124 -0
- package/tests/OutboundFromSliceGwtTest.res.mjs +268 -0
- package/tests/StateChangeSliceAuthorizeGwtTest.res.mjs +20 -16
- package/tests/StateChangeSliceGwtTest.res.mjs +6 -6
|
@@ -81,7 +81,7 @@ module ProductDelegate = {
|
|
|
81
81
|
@schema type error = NoError
|
|
82
82
|
let moduleUrl = ""
|
|
83
83
|
type role = Reventless.Role.name
|
|
84
|
-
let
|
|
84
|
+
let authorizationOf = (_: string): Reventless.Authorization.rule<role> => AllowAuthenticated
|
|
85
85
|
type lifecycleState = unit
|
|
86
86
|
let commandTransition = (_: command): Reventless.Transition.t<lifecycleState> => Unrestricted
|
|
87
87
|
}
|
|
@@ -121,7 +121,7 @@ module OrderDelegate = {
|
|
|
121
121
|
@schema type error = NoError
|
|
122
122
|
let moduleUrl = ""
|
|
123
123
|
type role = Reventless.Role.name
|
|
124
|
-
let
|
|
124
|
+
let authorizationOf = (_: string): Reventless.Authorization.rule<role> => AllowAuthenticated
|
|
125
125
|
type lifecycleState = unit
|
|
126
126
|
let commandTransition = (_: command): Reventless.Transition.t<lifecycleState> => Unrestricted
|
|
127
127
|
}
|
|
@@ -159,7 +159,7 @@ module RecordDemandSlice = {
|
|
|
159
159
|
DemandRecorded({productId: @s.matches(Reventless.DcbTag.string) string, orderId: string})
|
|
160
160
|
let moduleUrl = ""
|
|
161
161
|
type role = Reventless.Role.name
|
|
162
|
-
let
|
|
162
|
+
let authorizationOf = (_: string): Reventless.Authorization.rule<role> => AllowAuthenticated
|
|
163
163
|
type lifecycleState = unit
|
|
164
164
|
let commandTransition = (_: command): Reventless.Transition.t<lifecycleState> => Unrestricted
|
|
165
165
|
}
|
|
@@ -220,7 +220,7 @@ module SyncProductSlice = {
|
|
|
220
220
|
})
|
|
221
221
|
let moduleUrl = ""
|
|
222
222
|
type role = Reventless.Role.name
|
|
223
|
-
let
|
|
223
|
+
let authorizationOf = (_: string): Reventless.Authorization.rule<role> => AllowAuthenticated
|
|
224
224
|
type lifecycleState = unit
|
|
225
225
|
let commandTransition = (_: command): Reventless.Transition.t<lifecycleState> => Unrestricted
|
|
226
226
|
}
|
|
@@ -26,7 +26,7 @@ let eventSchema = Sury.$schema(s => ({
|
|
|
26
26
|
price: s.m(Sury.number)
|
|
27
27
|
}));
|
|
28
28
|
|
|
29
|
-
function
|
|
29
|
+
function authorizationOf(param) {
|
|
30
30
|
return "AllowAuthenticated";
|
|
31
31
|
}
|
|
32
32
|
|
|
@@ -42,7 +42,7 @@ let AddProductSlice = {
|
|
|
42
42
|
commandSchema: commandSchema,
|
|
43
43
|
errorSchema: errorSchema,
|
|
44
44
|
eventSchema: eventSchema,
|
|
45
|
-
|
|
45
|
+
authorizationOf: authorizationOf,
|
|
46
46
|
commandTransition: commandTransition,
|
|
47
47
|
traits: traits,
|
|
48
48
|
readConsistency: "EscalateOnRetry"
|
|
@@ -95,7 +95,7 @@ let eventSchema$1 = Sury.$schema(s => ({
|
|
|
95
95
|
|
|
96
96
|
let directiveSchema = Sury.literal("NoDirective");
|
|
97
97
|
|
|
98
|
-
function
|
|
98
|
+
function authorizationOf$1(param) {
|
|
99
99
|
return "AllowAuthenticated";
|
|
100
100
|
}
|
|
101
101
|
|
|
@@ -111,7 +111,7 @@ let ProductsEpSpec = {
|
|
|
111
111
|
commandSchema: commandSchema$1,
|
|
112
112
|
eventSchema: eventSchema$1,
|
|
113
113
|
directiveSchema: directiveSchema,
|
|
114
|
-
|
|
114
|
+
authorizationOf: authorizationOf$1,
|
|
115
115
|
commandTransition: commandTransition$1,
|
|
116
116
|
traits: traits$1
|
|
117
117
|
};
|
|
@@ -131,7 +131,7 @@ let errorSchema$1 = Sury.literal("NoError");
|
|
|
131
131
|
|
|
132
132
|
let moduleUrl = "";
|
|
133
133
|
|
|
134
|
-
function
|
|
134
|
+
function authorizationOf$2(param) {
|
|
135
135
|
return "AllowAuthenticated";
|
|
136
136
|
}
|
|
137
137
|
|
|
@@ -148,7 +148,7 @@ let ProductDelegate = {
|
|
|
148
148
|
eventSchema: eventSchema$2,
|
|
149
149
|
errorSchema: errorSchema$1,
|
|
150
150
|
moduleUrl: moduleUrl,
|
|
151
|
-
|
|
151
|
+
authorizationOf: authorizationOf$2,
|
|
152
152
|
commandTransition: commandTransition$2,
|
|
153
153
|
traits: traits$2
|
|
154
154
|
};
|
|
@@ -200,7 +200,7 @@ let eventSchema$3 = Sury.$schema(s => ({
|
|
|
200
200
|
|
|
201
201
|
let directiveSchema$1 = Sury.literal("NoDirective");
|
|
202
202
|
|
|
203
|
-
function
|
|
203
|
+
function authorizationOf$3(param) {
|
|
204
204
|
return "AllowAuthenticated";
|
|
205
205
|
}
|
|
206
206
|
|
|
@@ -216,7 +216,7 @@ let OrdersEpSpec = {
|
|
|
216
216
|
commandSchema: commandSchema$3,
|
|
217
217
|
eventSchema: eventSchema$3,
|
|
218
218
|
directiveSchema: directiveSchema$1,
|
|
219
|
-
|
|
219
|
+
authorizationOf: authorizationOf$3,
|
|
220
220
|
commandTransition: commandTransition$3,
|
|
221
221
|
traits: traits$3
|
|
222
222
|
};
|
|
@@ -235,7 +235,7 @@ let errorSchema$2 = Sury.literal("NoError");
|
|
|
235
235
|
|
|
236
236
|
let moduleUrl$2 = "";
|
|
237
237
|
|
|
238
|
-
function
|
|
238
|
+
function authorizationOf$4(param) {
|
|
239
239
|
return "AllowAuthenticated";
|
|
240
240
|
}
|
|
241
241
|
|
|
@@ -252,7 +252,7 @@ let OrderDelegate = {
|
|
|
252
252
|
eventSchema: eventSchema$4,
|
|
253
253
|
errorSchema: errorSchema$2,
|
|
254
254
|
moduleUrl: moduleUrl$2,
|
|
255
|
-
|
|
255
|
+
authorizationOf: authorizationOf$4,
|
|
256
256
|
commandTransition: commandTransition$4,
|
|
257
257
|
traits: traits$4
|
|
258
258
|
};
|
|
@@ -317,7 +317,7 @@ let eventSchema$5 = Sury.$schema(s => ({
|
|
|
317
317
|
|
|
318
318
|
let moduleUrl$4 = "";
|
|
319
319
|
|
|
320
|
-
function
|
|
320
|
+
function authorizationOf$5(param) {
|
|
321
321
|
return "AllowAuthenticated";
|
|
322
322
|
}
|
|
323
323
|
|
|
@@ -335,7 +335,7 @@ let RecordDemandSlice = {
|
|
|
335
335
|
errorSchema: errorSchema$3,
|
|
336
336
|
eventSchema: eventSchema$5,
|
|
337
337
|
moduleUrl: moduleUrl$4,
|
|
338
|
-
|
|
338
|
+
authorizationOf: authorizationOf$5,
|
|
339
339
|
commandTransition: commandTransition$5,
|
|
340
340
|
traits: traits$5,
|
|
341
341
|
readConsistency: "EscalateOnRetry"
|
|
@@ -427,7 +427,7 @@ let eventSchema$6 = Sury.$schema(s => ({
|
|
|
427
427
|
|
|
428
428
|
let moduleUrl$6 = "";
|
|
429
429
|
|
|
430
|
-
function
|
|
430
|
+
function authorizationOf$6(param) {
|
|
431
431
|
return "AllowAuthenticated";
|
|
432
432
|
}
|
|
433
433
|
|
|
@@ -445,7 +445,7 @@ let SyncProductSlice = {
|
|
|
445
445
|
errorSchema: errorSchema$4,
|
|
446
446
|
eventSchema: eventSchema$6,
|
|
447
447
|
moduleUrl: moduleUrl$6,
|
|
448
|
-
|
|
448
|
+
authorizationOf: authorizationOf$6,
|
|
449
449
|
commandTransition: commandTransition$6,
|
|
450
450
|
traits: traits$6,
|
|
451
451
|
readConsistency: "EscalateOnRetry"
|
|
@@ -545,7 +545,7 @@ let eventSchema$7 = Sury.$schema(s => ({
|
|
|
545
545
|
productIds: s.m(Sury.array(DcbTag$Reventless.stringForKey("productId")))
|
|
546
546
|
}));
|
|
547
547
|
|
|
548
|
-
function
|
|
548
|
+
function authorizationOf$7(param) {
|
|
549
549
|
return "AllowAuthenticated";
|
|
550
550
|
}
|
|
551
551
|
|
|
@@ -561,7 +561,7 @@ let PlaceOrderSlice = {
|
|
|
561
561
|
commandSchema: commandSchema$7,
|
|
562
562
|
errorSchema: errorSchema$5,
|
|
563
563
|
eventSchema: eventSchema$7,
|
|
564
|
-
|
|
564
|
+
authorizationOf: authorizationOf$7,
|
|
565
565
|
commandTransition: commandTransition$7,
|
|
566
566
|
traits: traits$7,
|
|
567
567
|
readConsistency: "EscalateOnRetry"
|
|
@@ -648,7 +648,7 @@ let ProductsEp = Flow_GWT$ReventlessGwt.ExtensionPointStep({
|
|
|
648
648
|
errorSchema: errorSchema$1,
|
|
649
649
|
commandSchema: commandSchema$2,
|
|
650
650
|
moduleUrl: moduleUrl,
|
|
651
|
-
|
|
651
|
+
authorizationOf: authorizationOf$2,
|
|
652
652
|
commandTransition: commandTransition$2,
|
|
653
653
|
traits: traits$2
|
|
654
654
|
},
|
|
@@ -674,7 +674,7 @@ let ProductsExt = Flow_GWT$ReventlessGwt.ExtensionStep({
|
|
|
674
674
|
errorSchema: errorSchema$4,
|
|
675
675
|
commandSchema: commandSchema$6,
|
|
676
676
|
moduleUrl: moduleUrl$6,
|
|
677
|
-
|
|
677
|
+
authorizationOf: authorizationOf$6,
|
|
678
678
|
commandTransition: commandTransition$6,
|
|
679
679
|
traits: traits$6
|
|
680
680
|
},
|
|
@@ -692,7 +692,7 @@ let Sync = Flow_GWT$ReventlessGwt.CommandStep({
|
|
|
692
692
|
commandSchema: commandSchema$6,
|
|
693
693
|
errorSchema: errorSchema$4,
|
|
694
694
|
eventSchema: eventSchema$6,
|
|
695
|
-
|
|
695
|
+
authorizationOf: authorizationOf$6
|
|
696
696
|
})({
|
|
697
697
|
initialState: initialState$2,
|
|
698
698
|
evolve: evolve$2,
|
|
@@ -720,7 +720,7 @@ let OrdersEp = Flow_GWT$ReventlessGwt.ExtensionPointStep({
|
|
|
720
720
|
errorSchema: errorSchema$2,
|
|
721
721
|
commandSchema: commandSchema$4,
|
|
722
722
|
moduleUrl: moduleUrl$2,
|
|
723
|
-
|
|
723
|
+
authorizationOf: authorizationOf$4,
|
|
724
724
|
commandTransition: commandTransition$4,
|
|
725
725
|
traits: traits$4
|
|
726
726
|
},
|
|
@@ -746,7 +746,7 @@ let OrdersExt = Flow_GWT$ReventlessGwt.ExtensionStep({
|
|
|
746
746
|
errorSchema: errorSchema$3,
|
|
747
747
|
commandSchema: commandSchema$5,
|
|
748
748
|
moduleUrl: moduleUrl$4,
|
|
749
|
-
|
|
749
|
+
authorizationOf: authorizationOf$5,
|
|
750
750
|
commandTransition: commandTransition$5,
|
|
751
751
|
traits: traits$5
|
|
752
752
|
},
|
|
@@ -764,7 +764,7 @@ let Demand = Flow_GWT$ReventlessGwt.CommandStep({
|
|
|
764
764
|
commandSchema: commandSchema$5,
|
|
765
765
|
errorSchema: errorSchema$3,
|
|
766
766
|
eventSchema: eventSchema$5,
|
|
767
|
-
|
|
767
|
+
authorizationOf: authorizationOf$5
|
|
768
768
|
})({
|
|
769
769
|
initialState: initialState$1,
|
|
770
770
|
evolve: evolve$1,
|
|
@@ -24,7 +24,7 @@ let eventSchema = Sury.$schema(s => ({
|
|
|
24
24
|
item: s.m(Sury.string)
|
|
25
25
|
}));
|
|
26
26
|
|
|
27
|
-
function
|
|
27
|
+
function authorizationOf(param) {
|
|
28
28
|
return "AllowAuthenticated";
|
|
29
29
|
}
|
|
30
30
|
|
|
@@ -40,7 +40,7 @@ let PlaceOrderSlice = {
|
|
|
40
40
|
commandSchema: commandSchema,
|
|
41
41
|
errorSchema: errorSchema,
|
|
42
42
|
eventSchema: eventSchema,
|
|
43
|
-
|
|
43
|
+
authorizationOf: authorizationOf,
|
|
44
44
|
commandTransition: commandTransition,
|
|
45
45
|
traits: traits,
|
|
46
46
|
readConsistency: "EscalateOnRetry"
|
|
@@ -136,7 +136,7 @@ function onExhausted(_id, _todo) {
|
|
|
136
136
|
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
function
|
|
139
|
+
function authorizationOf$1(param) {
|
|
140
140
|
return "AllowAuthenticated";
|
|
141
141
|
}
|
|
142
142
|
|
|
@@ -155,7 +155,7 @@ let AutoShipSlice = {
|
|
|
155
155
|
resolve: resolve,
|
|
156
156
|
process: process,
|
|
157
157
|
onExhausted: onExhausted,
|
|
158
|
-
|
|
158
|
+
authorizationOf: authorizationOf$1,
|
|
159
159
|
commandTransition: commandTransition$1,
|
|
160
160
|
traits: traits$1
|
|
161
161
|
};
|
|
@@ -183,7 +183,7 @@ let eventSchema$1 = Sury.$schema(s => ({
|
|
|
183
183
|
orderId: s.m(DcbTag$Reventless.string)
|
|
184
184
|
}));
|
|
185
185
|
|
|
186
|
-
function
|
|
186
|
+
function authorizationOf$2(param) {
|
|
187
187
|
return "AllowAuthenticated";
|
|
188
188
|
}
|
|
189
189
|
|
|
@@ -199,7 +199,7 @@ let ShipOrderSlice = {
|
|
|
199
199
|
commandSchema: commandSchema$2,
|
|
200
200
|
errorSchema: errorSchema$1,
|
|
201
201
|
eventSchema: eventSchema$1,
|
|
202
|
-
|
|
202
|
+
authorizationOf: authorizationOf$2,
|
|
203
203
|
commandTransition: commandTransition$2,
|
|
204
204
|
traits: traits$2,
|
|
205
205
|
readConsistency: "EscalateOnRetry"
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// InboundTranslation_GWT.FromSlice: input decoded as it arrives, translated by
|
|
2
|
+
// the slice's own `translate`, and commands checked against their schema.
|
|
3
|
+
|
|
4
|
+
module PaymentHook = {
|
|
5
|
+
let name = "PaymentHook"
|
|
6
|
+
let moduleUrl = ""
|
|
7
|
+
|
|
8
|
+
@schema
|
|
9
|
+
type externalInput = {orderId: string, status: string}
|
|
10
|
+
|
|
11
|
+
@schema
|
|
12
|
+
type command = ConfirmPayment({orderId: string})
|
|
13
|
+
|
|
14
|
+
let targetName = "Order"
|
|
15
|
+
let externalSystem = Some("Payments")
|
|
16
|
+
type role = Reventless.Role.name
|
|
17
|
+
let authorizationOf = _ => Reventless.Authorization.AllowAuthenticated
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
module PaymentHook_Translation = {
|
|
21
|
+
let moduleUrl = ""
|
|
22
|
+
let translate = (input: PaymentHook.externalInput) =>
|
|
23
|
+
switch input.status {
|
|
24
|
+
| "paid" => Ok([(input.orderId, PaymentHook.ConfirmPayment({orderId: input.orderId}))])
|
|
25
|
+
| "pending" => Ok([])
|
|
26
|
+
| other => Error(`Unknown status: ${other}`)
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
open PaymentHook
|
|
31
|
+
include InboundTranslation_GWT.FromSlice(PaymentHook, PaymentHook_Translation)
|
|
32
|
+
|
|
33
|
+
let json = (pairs: array<(string, string)>) =>
|
|
34
|
+
pairs->Array.map(((k, v)) => (k, JSON.Encode.string(v)))->Dict.fromArray->JSON.Encode.object
|
|
35
|
+
|
|
36
|
+
describe("InboundTranslation_GWT.FromSlice", () => {
|
|
37
|
+
test("input translates to a command", () =>
|
|
38
|
+
whenInput({orderId: "o1", status: "paid"})->thenCommand("o1", ConfirmPayment({orderId: "o1"}))
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
test("received JSON decodes before it translates", () =>
|
|
42
|
+
whenReceived(json([("orderId", "o1"), ("status", "paid")]))->thenCommand(
|
|
43
|
+
"o1",
|
|
44
|
+
ConfirmPayment({orderId: "o1"}),
|
|
45
|
+
)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
test("input that does not decode is refused before translate", () =>
|
|
49
|
+
whenReceived(json([("status", "paid")]))->thenRefusedInput("orderId")
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
test("input translate declines is not understood", () =>
|
|
53
|
+
whenInput({orderId: "o1", status: "lost"})->thenNotUnderstood("Unknown status: lost")
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
test("thenTranslateError is the older name", () =>
|
|
57
|
+
whenInput({orderId: "o1", status: "lost"})->thenTranslateError("Unknown status: lost")
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
test("no commands is an answer", () =>
|
|
61
|
+
whenInput({orderId: "o1", status: "pending"})->thenNoCommand
|
|
62
|
+
)
|
|
63
|
+
})
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Sury from "sury";
|
|
4
|
+
import * as InboundTranslation_GWT$ReventlessGwt from "../src/InboundTranslation_GWT.res.mjs";
|
|
5
|
+
|
|
6
|
+
let externalInputSchema = Sury.$schema(s => ({
|
|
7
|
+
orderId: s.m(Sury.string),
|
|
8
|
+
status: s.m(Sury.string)
|
|
9
|
+
}));
|
|
10
|
+
|
|
11
|
+
let commandSchema = Sury.$schema(s => ({
|
|
12
|
+
TAG: "ConfirmPayment",
|
|
13
|
+
orderId: s.m(Sury.string)
|
|
14
|
+
}));
|
|
15
|
+
|
|
16
|
+
function authorizationOf(param) {
|
|
17
|
+
return "AllowAuthenticated";
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
let traits = [];
|
|
21
|
+
|
|
22
|
+
let PaymentHook_externalSystem = "Payments";
|
|
23
|
+
|
|
24
|
+
let PaymentHook = {
|
|
25
|
+
name: "PaymentHook",
|
|
26
|
+
moduleUrl: "",
|
|
27
|
+
externalInputSchema: externalInputSchema,
|
|
28
|
+
commandSchema: commandSchema,
|
|
29
|
+
targetName: "Order",
|
|
30
|
+
externalSystem: PaymentHook_externalSystem,
|
|
31
|
+
authorizationOf: authorizationOf,
|
|
32
|
+
traits: traits
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
let moduleUrl = "";
|
|
36
|
+
|
|
37
|
+
function translate(input) {
|
|
38
|
+
let other = input.status;
|
|
39
|
+
switch (other) {
|
|
40
|
+
case "paid" :
|
|
41
|
+
return {
|
|
42
|
+
TAG: "Ok",
|
|
43
|
+
_0: [[
|
|
44
|
+
input.orderId,
|
|
45
|
+
{
|
|
46
|
+
TAG: "ConfirmPayment",
|
|
47
|
+
orderId: input.orderId
|
|
48
|
+
}
|
|
49
|
+
]]
|
|
50
|
+
};
|
|
51
|
+
case "pending" :
|
|
52
|
+
return {
|
|
53
|
+
TAG: "Ok",
|
|
54
|
+
_0: []
|
|
55
|
+
};
|
|
56
|
+
default:
|
|
57
|
+
return {
|
|
58
|
+
TAG: "Error",
|
|
59
|
+
_0: `Unknown status: ` + other
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let PaymentHook_Translation = {
|
|
65
|
+
moduleUrl: moduleUrl,
|
|
66
|
+
translate: translate
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
let include = InboundTranslation_GWT$ReventlessGwt.FromSlice(PaymentHook)({
|
|
70
|
+
translate: translate,
|
|
71
|
+
moduleUrl: moduleUrl
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
let describe = include.describe;
|
|
75
|
+
|
|
76
|
+
let test = include.test;
|
|
77
|
+
|
|
78
|
+
let whenInput = include.whenInput;
|
|
79
|
+
|
|
80
|
+
let whenReceived = include.whenReceived;
|
|
81
|
+
|
|
82
|
+
let thenCommand = include.thenCommand;
|
|
83
|
+
|
|
84
|
+
let thenNoCommand = include.thenNoCommand;
|
|
85
|
+
|
|
86
|
+
let thenNotUnderstood = include.thenNotUnderstood;
|
|
87
|
+
|
|
88
|
+
let thenTranslateError = include.thenTranslateError;
|
|
89
|
+
|
|
90
|
+
let thenRefusedInput = include.thenRefusedInput;
|
|
91
|
+
|
|
92
|
+
function json(pairs) {
|
|
93
|
+
return Object.fromEntries(pairs.map(param => [
|
|
94
|
+
param[0],
|
|
95
|
+
param[1]
|
|
96
|
+
]));
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
describe("InboundTranslation_GWT.FromSlice", () => {
|
|
100
|
+
test("input translates to a command", () => thenCommand(whenInput({
|
|
101
|
+
orderId: "o1",
|
|
102
|
+
status: "paid"
|
|
103
|
+
}), "o1", {
|
|
104
|
+
TAG: "ConfirmPayment",
|
|
105
|
+
orderId: "o1"
|
|
106
|
+
}));
|
|
107
|
+
test("received JSON decodes before it translates", () => thenCommand(whenReceived(json([
|
|
108
|
+
[
|
|
109
|
+
"orderId",
|
|
110
|
+
"o1"
|
|
111
|
+
],
|
|
112
|
+
[
|
|
113
|
+
"status",
|
|
114
|
+
"paid"
|
|
115
|
+
]
|
|
116
|
+
])), "o1", {
|
|
117
|
+
TAG: "ConfirmPayment",
|
|
118
|
+
orderId: "o1"
|
|
119
|
+
}));
|
|
120
|
+
test("input that does not decode is refused before translate", () => thenRefusedInput(whenReceived(json([[
|
|
121
|
+
"status",
|
|
122
|
+
"paid"
|
|
123
|
+
]])), "orderId"));
|
|
124
|
+
test("input translate declines is not understood", () => thenNotUnderstood(whenInput({
|
|
125
|
+
orderId: "o1",
|
|
126
|
+
status: "lost"
|
|
127
|
+
}), "Unknown status: lost"));
|
|
128
|
+
test("thenTranslateError is the older name", () => thenTranslateError(whenInput({
|
|
129
|
+
orderId: "o1",
|
|
130
|
+
status: "lost"
|
|
131
|
+
}), "Unknown status: lost"));
|
|
132
|
+
test("no commands is an answer", () => thenNoCommand(whenInput({
|
|
133
|
+
orderId: "o1",
|
|
134
|
+
status: "pending"
|
|
135
|
+
})));
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
let encPairs = include.encPairs;
|
|
139
|
+
|
|
140
|
+
let describeOther = include.describeOther;
|
|
141
|
+
|
|
142
|
+
let roundTrips = include.roundTrips;
|
|
143
|
+
|
|
144
|
+
let thenCommands = include.thenCommands;
|
|
145
|
+
|
|
146
|
+
export {
|
|
147
|
+
PaymentHook,
|
|
148
|
+
PaymentHook_Translation,
|
|
149
|
+
describe,
|
|
150
|
+
test,
|
|
151
|
+
encPairs,
|
|
152
|
+
whenInput,
|
|
153
|
+
whenReceived,
|
|
154
|
+
describeOther,
|
|
155
|
+
roundTrips,
|
|
156
|
+
thenCommands,
|
|
157
|
+
thenCommand,
|
|
158
|
+
thenNoCommand,
|
|
159
|
+
thenNotUnderstood,
|
|
160
|
+
thenTranslateError,
|
|
161
|
+
thenRefusedInput,
|
|
162
|
+
json,
|
|
163
|
+
}
|
|
164
|
+
/* externalInputSchema Not a pure module */
|
|
@@ -37,14 +37,10 @@ function translate(input) {
|
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
function
|
|
40
|
+
function authorizationOf(param) {
|
|
41
41
|
return "AllowAuthenticated";
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
function commandTransition(param) {
|
|
45
|
-
return "Undeclared";
|
|
46
|
-
}
|
|
47
|
-
|
|
48
44
|
let traits = [];
|
|
49
45
|
|
|
50
46
|
let PaymentWebhookSlice = {
|
|
@@ -52,8 +48,7 @@ let PaymentWebhookSlice = {
|
|
|
52
48
|
externalInputSchema: externalInputSchema,
|
|
53
49
|
commandSchema: commandSchema,
|
|
54
50
|
translate: translate,
|
|
55
|
-
|
|
56
|
-
commandTransition: commandTransition,
|
|
51
|
+
authorizationOf: authorizationOf,
|
|
57
52
|
traits: traits,
|
|
58
53
|
externalSystem: undefined
|
|
59
54
|
};
|
|
@@ -23,7 +23,7 @@ let errorSchema = Sury.literal("CategoryAlreadyExists");
|
|
|
23
23
|
|
|
24
24
|
let moduleUrl = "";
|
|
25
25
|
|
|
26
|
-
function
|
|
26
|
+
function authorizationOf(param) {
|
|
27
27
|
return "AllowAuthenticated";
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -40,7 +40,7 @@ let CategorySpec = {
|
|
|
40
40
|
eventSchema: eventSchema,
|
|
41
41
|
errorSchema: errorSchema,
|
|
42
42
|
moduleUrl: moduleUrl,
|
|
43
|
-
|
|
43
|
+
authorizationOf: authorizationOf,
|
|
44
44
|
commandTransition: commandTransition,
|
|
45
45
|
traits: traits
|
|
46
46
|
};
|
|
@@ -98,7 +98,7 @@ let errorSchema$1 = Sury.literal("ProductAlreadyMirrored");
|
|
|
98
98
|
|
|
99
99
|
let moduleUrl$2 = "";
|
|
100
100
|
|
|
101
|
-
function
|
|
101
|
+
function authorizationOf$1(param) {
|
|
102
102
|
return "AllowAuthenticated";
|
|
103
103
|
}
|
|
104
104
|
|
|
@@ -115,7 +115,7 @@ let ProductSpec = {
|
|
|
115
115
|
eventSchema: eventSchema$1,
|
|
116
116
|
errorSchema: errorSchema$1,
|
|
117
117
|
moduleUrl: moduleUrl$2,
|
|
118
|
-
|
|
118
|
+
authorizationOf: authorizationOf$1,
|
|
119
119
|
commandTransition: commandTransition$1,
|
|
120
120
|
traits: traits$1
|
|
121
121
|
};
|
|
@@ -197,7 +197,7 @@ function decide$2(state, command) {
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
function
|
|
200
|
+
function authorizationOf$2(param) {
|
|
201
201
|
return "AllowAuthenticated";
|
|
202
202
|
}
|
|
203
203
|
|
|
@@ -220,7 +220,7 @@ let NotificationSlice = {
|
|
|
220
220
|
errorSchema: errorSchema$2,
|
|
221
221
|
eventSchema: eventSchema$2,
|
|
222
222
|
decide: decide$2,
|
|
223
|
-
|
|
223
|
+
authorizationOf: authorizationOf$2,
|
|
224
224
|
commandTransition: commandTransition$2,
|
|
225
225
|
traits: traits$2,
|
|
226
226
|
readConsistency: "EscalateOnRetry"
|
|
@@ -269,7 +269,7 @@ function decide$3(state, command) {
|
|
|
269
269
|
}
|
|
270
270
|
}
|
|
271
271
|
|
|
272
|
-
function
|
|
272
|
+
function authorizationOf$3(param) {
|
|
273
273
|
return "AllowAuthenticated";
|
|
274
274
|
}
|
|
275
275
|
|
|
@@ -292,7 +292,7 @@ let InventorySlice = {
|
|
|
292
292
|
errorSchema: errorSchema$3,
|
|
293
293
|
eventSchema: eventSchema$3,
|
|
294
294
|
decide: decide$3,
|
|
295
|
-
|
|
295
|
+
authorizationOf: authorizationOf$3,
|
|
296
296
|
commandTransition: commandTransition$3,
|
|
297
297
|
traits: traits$3,
|
|
298
298
|
readConsistency: "EscalateOnRetry"
|
|
@@ -311,7 +311,7 @@ let CategorySource = Mapping_GWT$ReventlessGwt.FromBehavior({
|
|
|
311
311
|
errorSchema: errorSchema,
|
|
312
312
|
commandSchema: commandSchema,
|
|
313
313
|
moduleUrl: moduleUrl,
|
|
314
|
-
|
|
314
|
+
authorizationOf: authorizationOf,
|
|
315
315
|
commandTransition: commandTransition,
|
|
316
316
|
traits: traits
|
|
317
317
|
})({
|
|
@@ -328,7 +328,7 @@ let CategorySource = Mapping_GWT$ReventlessGwt.FromBehavior({
|
|
|
328
328
|
errorSchema: errorSchema,
|
|
329
329
|
commandSchema: commandSchema,
|
|
330
330
|
moduleUrl: moduleUrl,
|
|
331
|
-
|
|
331
|
+
authorizationOf: authorizationOf,
|
|
332
332
|
commandTransition: commandTransition,
|
|
333
333
|
traits: traits
|
|
334
334
|
},
|
|
@@ -352,7 +352,7 @@ let ProductTarget = Mapping_GWT$ReventlessGwt.FromBehavior({
|
|
|
352
352
|
errorSchema: errorSchema$1,
|
|
353
353
|
commandSchema: commandSchema$1,
|
|
354
354
|
moduleUrl: moduleUrl$2,
|
|
355
|
-
|
|
355
|
+
authorizationOf: authorizationOf$1,
|
|
356
356
|
commandTransition: commandTransition$1,
|
|
357
357
|
traits: traits$1
|
|
358
358
|
})({
|
|
@@ -369,7 +369,7 @@ let ProductTarget = Mapping_GWT$ReventlessGwt.FromBehavior({
|
|
|
369
369
|
errorSchema: errorSchema$1,
|
|
370
370
|
commandSchema: commandSchema$1,
|
|
371
371
|
moduleUrl: moduleUrl$2,
|
|
372
|
-
|
|
372
|
+
authorizationOf: authorizationOf$1,
|
|
373
373
|
commandTransition: commandTransition$1,
|
|
374
374
|
traits: traits$1
|
|
375
375
|
},
|