@reventlessdev/online-shop-hybrid-catalog 1.0.0-alpha.100
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 +878 -0
- package/LICENSE +202 -0
- package/__mocks__/emptyModule.js +1 -0
- package/package.json +57 -0
- package/rescript.json +37 -0
- package/src/Category/StateChangeSlice/AddCategory.res +17 -0
- package/src/Category/StateChangeSlice/AddCategory.res.mjs +48 -0
- package/src/Category/StateChangeSlice/AddCategory_Behavior.res +21 -0
- package/src/Category/StateChangeSlice/AddCategory_Behavior.res.mjs +52 -0
- package/src/Category/StateChangeSlice/ArchiveCategory.res +18 -0
- package/src/Category/StateChangeSlice/ArchiveCategory.res.mjs +49 -0
- package/src/Category/StateChangeSlice/ArchiveCategory_Behavior.res +23 -0
- package/src/Category/StateChangeSlice/ArchiveCategory_Behavior.res.mjs +58 -0
- package/src/Category/StateChangeSlice/RenameCategory.res +23 -0
- package/src/Category/StateChangeSlice/RenameCategory.res.mjs +58 -0
- package/src/Category/StateChangeSlice/RenameCategory_Behavior.res +26 -0
- package/src/Category/StateChangeSlice/RenameCategory_Behavior.res.mjs +74 -0
- package/src/Category/StateViewSliceStream/Categories.res +13 -0
- package/src/Category/StateViewSliceStream/Categories.res.mjs +54 -0
- package/src/Category/StateViewSliceStream/Categories_Projection.res +8 -0
- package/src/Category/StateViewSliceStream/Categories_Projection.res.mjs +50 -0
- package/src/Extension/Orders_Extension.res +48 -0
- package/src/Extension/Orders_Extension.res.mjs +76 -0
- package/src/ExtensionPoint/Products_ExtensionPointMapping.res +59 -0
- package/src/ExtensionPoint/Products_ExtensionPointMapping.res.mjs +99 -0
- package/src/Plugin.res +63 -0
- package/src/Plugin.res.mjs +335 -0
- package/src/Product/InboundTranslationSlice/ImportProduct.res +28 -0
- package/src/Product/InboundTranslationSlice/ImportProduct.res.mjs +48 -0
- package/src/Product/InboundTranslationSlice/ImportProduct_Translation.res +23 -0
- package/src/Product/InboundTranslationSlice/ImportProduct_Translation.res.mjs +52 -0
- package/src/Product/StateChangeSlice/AddProduct.res +37 -0
- package/src/Product/StateChangeSlice/AddProduct.res.mjs +68 -0
- package/src/Product/StateChangeSlice/AddProduct_Behavior.res +35 -0
- package/src/Product/StateChangeSlice/AddProduct_Behavior.res.mjs +72 -0
- package/src/Product/StateChangeSlice/ChangeProductDescription.res +23 -0
- package/src/Product/StateChangeSlice/ChangeProductDescription.res.mjs +54 -0
- package/src/Product/StateChangeSlice/ChangeProductDescription_Behavior.res +26 -0
- package/src/Product/StateChangeSlice/ChangeProductDescription_Behavior.res.mjs +59 -0
- package/src/Product/StateChangeSlice/ChangeProductName.res +19 -0
- package/src/Product/StateChangeSlice/ChangeProductName.res.mjs +54 -0
- package/src/Product/StateChangeSlice/ChangeProductName_Behavior.res +23 -0
- package/src/Product/StateChangeSlice/ChangeProductName_Behavior.res.mjs +59 -0
- package/src/Product/StateChangeSlice/ChangeProductPrice.res +19 -0
- package/src/Product/StateChangeSlice/ChangeProductPrice.res.mjs +54 -0
- package/src/Product/StateChangeSlice/ChangeProductPrice_Behavior.res +23 -0
- package/src/Product/StateChangeSlice/ChangeProductPrice_Behavior.res.mjs +59 -0
- package/src/Product/StateViewSliceStream/ProductDemand.res +13 -0
- package/src/Product/StateViewSliceStream/ProductDemand.res.mjs +55 -0
- package/src/Product/StateViewSliceStream/ProductDemand_Projection.res +11 -0
- package/src/Product/StateViewSliceStream/ProductDemand_Projection.res.mjs +61 -0
- package/src/Product/StateViewSliceStream/Products.res +20 -0
- package/src/Product/StateViewSliceStream/Products.res.mjs +65 -0
- package/src/Product/StateViewSliceStream/Products_Projection.res +13 -0
- package/src/Product/StateViewSliceStream/Products_Projection.res.mjs +70 -0
- package/src/ProductDemand/StateChangeSlice/RecordProductDemand.res +24 -0
- package/src/ProductDemand/StateChangeSlice/RecordProductDemand.res.mjs +71 -0
- package/src/ProductDemand/StateChangeSlice/RecordProductDemand_Behavior.res +30 -0
- package/src/ProductDemand/StateChangeSlice/RecordProductDemand_Behavior.res.mjs +68 -0
- package/src/Task/ImportProducts.res +15 -0
- package/src/Task/ImportProducts.res.mjs +23 -0
- package/src/plugin.json +1 -0
- package/tests/Category/StateChangeSlice/AddCategory_GWT.res +21 -0
- package/tests/Category/StateChangeSlice/AddCategory_GWT.res.mjs +88 -0
- package/tests/Category/StateChangeSlice/ArchiveCategory_GWT.res +21 -0
- package/tests/Category/StateChangeSlice/ArchiveCategory_GWT.res.mjs +84 -0
- package/tests/Category/StateChangeSlice/RenameCategory_GWT.res +27 -0
- package/tests/Category/StateChangeSlice/RenameCategory_GWT.res.mjs +102 -0
- package/tests/Category/StateViewSliceStream/Categories_GWT.res +21 -0
- package/tests/Category/StateViewSliceStream/Categories_GWT.res.mjs +103 -0
- package/tests/Extension/Orders_Extension_GWT.res +40 -0
- package/tests/Extension/Orders_Extension_GWT.res.mjs +126 -0
- package/tests/ExtensionPoint/Products_ExtensionPointMapping_GWT.res +37 -0
- package/tests/ExtensionPoint/Products_ExtensionPointMapping_GWT.res.mjs +123 -0
- package/tests/Product/InboundTranslationSlice/ImportProduct_GWT.res +53 -0
- package/tests/Product/InboundTranslationSlice/ImportProduct_GWT.res.mjs +103 -0
- package/tests/Product/StateChangeSlice/AddProduct_GWT.res +64 -0
- package/tests/Product/StateChangeSlice/AddProduct_GWT.res.mjs +144 -0
- package/tests/Product/StateChangeSlice/ChangeProductDescription_GWT.res +21 -0
- package/tests/Product/StateChangeSlice/ChangeProductDescription_GWT.res.mjs +91 -0
- package/tests/Product/StateChangeSlice/ChangeProductName_GWT.res +21 -0
- package/tests/Product/StateChangeSlice/ChangeProductName_GWT.res.mjs +91 -0
- package/tests/Product/StateChangeSlice/ChangeProductPrice_GWT.res +21 -0
- package/tests/Product/StateChangeSlice/ChangeProductPrice_GWT.res.mjs +91 -0
- package/tests/Product/StateViewSliceStream/ProductDemand_GWT.res +31 -0
- package/tests/Product/StateViewSliceStream/ProductDemand_GWT.res.mjs +132 -0
- package/tests/Product/StateViewSliceStream/Products_GWT.res +47 -0
- package/tests/Product/StateViewSliceStream/Products_GWT.res.mjs +137 -0
- package/tests/ProductDemand/StateChangeSlice/RecordProductDemand_GWT.res +39 -0
- package/tests/ProductDemand/StateChangeSlice/RecordProductDemand_GWT.res.mjs +120 -0
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as Id$Reventless from "@reventlessdev/reventless-spec/src/types/Id.res.mjs";
|
|
4
|
+
import * as Stdlib_Option from "@rescript/runtime/lib/es6/Stdlib_Option.js";
|
|
5
|
+
import * as Products$CatalogPlugin from "./Product/StateViewSliceStream/Products.res.mjs";
|
|
6
|
+
import * as AddProduct$CatalogPlugin from "./Product/StateChangeSlice/AddProduct.res.mjs";
|
|
7
|
+
import * as Categories$CatalogPlugin from "./Category/StateViewSliceStream/Categories.res.mjs";
|
|
8
|
+
import * as AddCategory$CatalogPlugin from "./Category/StateChangeSlice/AddCategory.res.mjs";
|
|
9
|
+
import * as ImportProduct$CatalogPlugin from "./Product/InboundTranslationSlice/ImportProduct.res.mjs";
|
|
10
|
+
import * as ProductDemand$CatalogPlugin from "./Product/StateViewSliceStream/ProductDemand.res.mjs";
|
|
11
|
+
import * as ImportProducts$CatalogPlugin from "./Task/ImportProducts.res.mjs";
|
|
12
|
+
import * as RenameCategory$CatalogPlugin from "./Category/StateChangeSlice/RenameCategory.res.mjs";
|
|
13
|
+
import * as ArchiveCategory$CatalogPlugin from "./Category/StateChangeSlice/ArchiveCategory.res.mjs";
|
|
14
|
+
import * as Orders_Extension$CatalogPlugin from "./Extension/Orders_Extension.res.mjs";
|
|
15
|
+
import * as ChangeProductName$CatalogPlugin from "./Product/StateChangeSlice/ChangeProductName.res.mjs";
|
|
16
|
+
import * as ChangeProductPrice$CatalogPlugin from "./Product/StateChangeSlice/ChangeProductPrice.res.mjs";
|
|
17
|
+
import * as AddProduct_Behavior$CatalogPlugin from "./Product/StateChangeSlice/AddProduct_Behavior.res.mjs";
|
|
18
|
+
import * as Products_Projection$CatalogPlugin from "./Product/StateViewSliceStream/Products_Projection.res.mjs";
|
|
19
|
+
import * as RecordProductDemand$CatalogPlugin from "./ProductDemand/StateChangeSlice/RecordProductDemand.res.mjs";
|
|
20
|
+
import * as AddCategory_Behavior$CatalogPlugin from "./Category/StateChangeSlice/AddCategory_Behavior.res.mjs";
|
|
21
|
+
import * as Orders_ExtensionPoint$OrderingSpec from "@reventlessdev/online-shop-hybrid-ordering-spec/src/Orders_ExtensionPoint.res.mjs";
|
|
22
|
+
import * as Categories_Projection$CatalogPlugin from "./Category/StateViewSliceStream/Categories_Projection.res.mjs";
|
|
23
|
+
import * as Products_ExtensionPoint$CatalogSpec from "@reventlessdev/online-shop-hybrid-catalog-spec/src/Products_ExtensionPoint.res.mjs";
|
|
24
|
+
import * as RenameCategory_Behavior$CatalogPlugin from "./Category/StateChangeSlice/RenameCategory_Behavior.res.mjs";
|
|
25
|
+
import * as ArchiveCategory_Behavior$CatalogPlugin from "./Category/StateChangeSlice/ArchiveCategory_Behavior.res.mjs";
|
|
26
|
+
import * as ChangeProductDescription$CatalogPlugin from "./Product/StateChangeSlice/ChangeProductDescription.res.mjs";
|
|
27
|
+
import * as ProductDemand_Projection$CatalogPlugin from "./Product/StateViewSliceStream/ProductDemand_Projection.res.mjs";
|
|
28
|
+
import * as ImportProduct_Translation$CatalogPlugin from "./Product/InboundTranslationSlice/ImportProduct_Translation.res.mjs";
|
|
29
|
+
import * as ChangeProductName_Behavior$CatalogPlugin from "./Product/StateChangeSlice/ChangeProductName_Behavior.res.mjs";
|
|
30
|
+
import * as ChangeProductPrice_Behavior$CatalogPlugin from "./Product/StateChangeSlice/ChangeProductPrice_Behavior.res.mjs";
|
|
31
|
+
import * as RecordProductDemand_Behavior$CatalogPlugin from "./ProductDemand/StateChangeSlice/RecordProductDemand_Behavior.res.mjs";
|
|
32
|
+
import * as Products_ExtensionPointMapping$CatalogPlugin from "./ExtensionPoint/Products_ExtensionPointMapping.res.mjs";
|
|
33
|
+
import * as ChangeProductDescription_Behavior$CatalogPlugin from "./Product/StateChangeSlice/ChangeProductDescription_Behavior.res.mjs";
|
|
34
|
+
|
|
35
|
+
function Make(Platform) {
|
|
36
|
+
let AddCategorySlice = Platform.StateChangeSlice.Make({
|
|
37
|
+
name: AddCategory$CatalogPlugin.name,
|
|
38
|
+
moduleUrl: AddCategory$CatalogPlugin.moduleUrl,
|
|
39
|
+
Id: Id$Reventless.$$String,
|
|
40
|
+
consumedEventSchema: AddCategory$CatalogPlugin.consumedEventSchema,
|
|
41
|
+
errorSchema: AddCategory$CatalogPlugin.errorSchema,
|
|
42
|
+
eventSchema: AddCategory$CatalogPlugin.eventSchema,
|
|
43
|
+
commandSchema: AddCategory$CatalogPlugin.commandSchema,
|
|
44
|
+
commandAuthorization: AddCategory$CatalogPlugin.commandAuthorization,
|
|
45
|
+
readConsistency: AddCategory$CatalogPlugin.readConsistency
|
|
46
|
+
})({
|
|
47
|
+
initialState: AddCategory_Behavior$CatalogPlugin.initialState,
|
|
48
|
+
evolve: AddCategory_Behavior$CatalogPlugin.evolve,
|
|
49
|
+
decide: AddCategory_Behavior$CatalogPlugin.decide,
|
|
50
|
+
moduleUrl: AddCategory_Behavior$CatalogPlugin.moduleUrl
|
|
51
|
+
});
|
|
52
|
+
let AddProductSlice = Platform.StateChangeSlice.Make({
|
|
53
|
+
name: AddProduct$CatalogPlugin.name,
|
|
54
|
+
moduleUrl: AddProduct$CatalogPlugin.moduleUrl,
|
|
55
|
+
Id: Id$Reventless.$$String,
|
|
56
|
+
consumedEventSchema: AddProduct$CatalogPlugin.consumedEventSchema,
|
|
57
|
+
errorSchema: AddProduct$CatalogPlugin.errorSchema,
|
|
58
|
+
eventSchema: AddProduct$CatalogPlugin.eventSchema,
|
|
59
|
+
commandSchema: AddProduct$CatalogPlugin.commandSchema,
|
|
60
|
+
commandAuthorization: AddProduct$CatalogPlugin.commandAuthorization,
|
|
61
|
+
readConsistency: AddProduct$CatalogPlugin.readConsistency
|
|
62
|
+
})({
|
|
63
|
+
initialState: AddProduct_Behavior$CatalogPlugin.initialState,
|
|
64
|
+
evolve: AddProduct_Behavior$CatalogPlugin.evolve,
|
|
65
|
+
decide: AddProduct_Behavior$CatalogPlugin.decide,
|
|
66
|
+
moduleUrl: AddProduct_Behavior$CatalogPlugin.moduleUrl
|
|
67
|
+
});
|
|
68
|
+
let ArchiveCategorySlice = Platform.StateChangeSlice.Make({
|
|
69
|
+
name: ArchiveCategory$CatalogPlugin.name,
|
|
70
|
+
moduleUrl: ArchiveCategory$CatalogPlugin.moduleUrl,
|
|
71
|
+
Id: Id$Reventless.$$String,
|
|
72
|
+
consumedEventSchema: ArchiveCategory$CatalogPlugin.consumedEventSchema,
|
|
73
|
+
errorSchema: ArchiveCategory$CatalogPlugin.errorSchema,
|
|
74
|
+
eventSchema: ArchiveCategory$CatalogPlugin.eventSchema,
|
|
75
|
+
commandSchema: ArchiveCategory$CatalogPlugin.commandSchema,
|
|
76
|
+
commandAuthorization: ArchiveCategory$CatalogPlugin.commandAuthorization,
|
|
77
|
+
readConsistency: ArchiveCategory$CatalogPlugin.readConsistency
|
|
78
|
+
})({
|
|
79
|
+
initialState: ArchiveCategory_Behavior$CatalogPlugin.initialState,
|
|
80
|
+
evolve: ArchiveCategory_Behavior$CatalogPlugin.evolve,
|
|
81
|
+
decide: ArchiveCategory_Behavior$CatalogPlugin.decide,
|
|
82
|
+
moduleUrl: ArchiveCategory_Behavior$CatalogPlugin.moduleUrl
|
|
83
|
+
});
|
|
84
|
+
let ChangeProductDescriptionSlice = Platform.StateChangeSlice.Make({
|
|
85
|
+
name: ChangeProductDescription$CatalogPlugin.name,
|
|
86
|
+
moduleUrl: ChangeProductDescription$CatalogPlugin.moduleUrl,
|
|
87
|
+
Id: Id$Reventless.$$String,
|
|
88
|
+
consumedEventSchema: ChangeProductDescription$CatalogPlugin.consumedEventSchema,
|
|
89
|
+
errorSchema: ChangeProductDescription$CatalogPlugin.errorSchema,
|
|
90
|
+
eventSchema: ChangeProductDescription$CatalogPlugin.eventSchema,
|
|
91
|
+
commandSchema: ChangeProductDescription$CatalogPlugin.commandSchema,
|
|
92
|
+
commandAuthorization: ChangeProductDescription$CatalogPlugin.commandAuthorization,
|
|
93
|
+
readConsistency: ChangeProductDescription$CatalogPlugin.readConsistency
|
|
94
|
+
})({
|
|
95
|
+
initialState: ChangeProductDescription_Behavior$CatalogPlugin.initialState,
|
|
96
|
+
evolve: ChangeProductDescription_Behavior$CatalogPlugin.evolve,
|
|
97
|
+
decide: ChangeProductDescription_Behavior$CatalogPlugin.decide,
|
|
98
|
+
moduleUrl: ChangeProductDescription_Behavior$CatalogPlugin.moduleUrl
|
|
99
|
+
});
|
|
100
|
+
let ChangeProductNameSlice = Platform.StateChangeSlice.Make({
|
|
101
|
+
name: ChangeProductName$CatalogPlugin.name,
|
|
102
|
+
moduleUrl: ChangeProductName$CatalogPlugin.moduleUrl,
|
|
103
|
+
Id: Id$Reventless.$$String,
|
|
104
|
+
consumedEventSchema: ChangeProductName$CatalogPlugin.consumedEventSchema,
|
|
105
|
+
errorSchema: ChangeProductName$CatalogPlugin.errorSchema,
|
|
106
|
+
eventSchema: ChangeProductName$CatalogPlugin.eventSchema,
|
|
107
|
+
commandSchema: ChangeProductName$CatalogPlugin.commandSchema,
|
|
108
|
+
commandAuthorization: ChangeProductName$CatalogPlugin.commandAuthorization,
|
|
109
|
+
readConsistency: ChangeProductName$CatalogPlugin.readConsistency
|
|
110
|
+
})({
|
|
111
|
+
initialState: ChangeProductName_Behavior$CatalogPlugin.initialState,
|
|
112
|
+
evolve: ChangeProductName_Behavior$CatalogPlugin.evolve,
|
|
113
|
+
decide: ChangeProductName_Behavior$CatalogPlugin.decide,
|
|
114
|
+
moduleUrl: ChangeProductName_Behavior$CatalogPlugin.moduleUrl
|
|
115
|
+
});
|
|
116
|
+
let ChangeProductPriceSlice = Platform.StateChangeSlice.Make({
|
|
117
|
+
name: ChangeProductPrice$CatalogPlugin.name,
|
|
118
|
+
moduleUrl: ChangeProductPrice$CatalogPlugin.moduleUrl,
|
|
119
|
+
Id: Id$Reventless.$$String,
|
|
120
|
+
consumedEventSchema: ChangeProductPrice$CatalogPlugin.consumedEventSchema,
|
|
121
|
+
errorSchema: ChangeProductPrice$CatalogPlugin.errorSchema,
|
|
122
|
+
eventSchema: ChangeProductPrice$CatalogPlugin.eventSchema,
|
|
123
|
+
commandSchema: ChangeProductPrice$CatalogPlugin.commandSchema,
|
|
124
|
+
commandAuthorization: ChangeProductPrice$CatalogPlugin.commandAuthorization,
|
|
125
|
+
readConsistency: ChangeProductPrice$CatalogPlugin.readConsistency
|
|
126
|
+
})({
|
|
127
|
+
initialState: ChangeProductPrice_Behavior$CatalogPlugin.initialState,
|
|
128
|
+
evolve: ChangeProductPrice_Behavior$CatalogPlugin.evolve,
|
|
129
|
+
decide: ChangeProductPrice_Behavior$CatalogPlugin.decide,
|
|
130
|
+
moduleUrl: ChangeProductPrice_Behavior$CatalogPlugin.moduleUrl
|
|
131
|
+
});
|
|
132
|
+
let RecordProductDemandSlice = Platform.StateChangeSlice.Make({
|
|
133
|
+
name: RecordProductDemand$CatalogPlugin.name,
|
|
134
|
+
moduleUrl: RecordProductDemand$CatalogPlugin.moduleUrl,
|
|
135
|
+
Id: Id$Reventless.$$String,
|
|
136
|
+
consumedEventSchema: RecordProductDemand$CatalogPlugin.consumedEventSchema,
|
|
137
|
+
errorSchema: RecordProductDemand$CatalogPlugin.errorSchema,
|
|
138
|
+
eventSchema: RecordProductDemand$CatalogPlugin.eventSchema,
|
|
139
|
+
commandSchema: RecordProductDemand$CatalogPlugin.commandSchema,
|
|
140
|
+
commandAuthorization: RecordProductDemand$CatalogPlugin.commandAuthorization,
|
|
141
|
+
readConsistency: RecordProductDemand$CatalogPlugin.readConsistency
|
|
142
|
+
})({
|
|
143
|
+
initialState: RecordProductDemand_Behavior$CatalogPlugin.initialState,
|
|
144
|
+
evolve: RecordProductDemand_Behavior$CatalogPlugin.evolve,
|
|
145
|
+
decide: RecordProductDemand_Behavior$CatalogPlugin.decide,
|
|
146
|
+
moduleUrl: RecordProductDemand_Behavior$CatalogPlugin.moduleUrl
|
|
147
|
+
});
|
|
148
|
+
let RenameCategorySlice = Platform.StateChangeSlice.Make({
|
|
149
|
+
name: RenameCategory$CatalogPlugin.name,
|
|
150
|
+
moduleUrl: RenameCategory$CatalogPlugin.moduleUrl,
|
|
151
|
+
Id: Id$Reventless.$$String,
|
|
152
|
+
consumedEventSchema: RenameCategory$CatalogPlugin.consumedEventSchema,
|
|
153
|
+
errorSchema: RenameCategory$CatalogPlugin.errorSchema,
|
|
154
|
+
eventSchema: RenameCategory$CatalogPlugin.eventSchema,
|
|
155
|
+
commandSchema: RenameCategory$CatalogPlugin.commandSchema,
|
|
156
|
+
commandAuthorization: RenameCategory$CatalogPlugin.commandAuthorization,
|
|
157
|
+
readConsistency: RenameCategory$CatalogPlugin.readConsistency
|
|
158
|
+
})({
|
|
159
|
+
initialState: RenameCategory_Behavior$CatalogPlugin.initialState,
|
|
160
|
+
evolve: RenameCategory_Behavior$CatalogPlugin.evolve,
|
|
161
|
+
decide: RenameCategory_Behavior$CatalogPlugin.decide,
|
|
162
|
+
moduleUrl: RenameCategory_Behavior$CatalogPlugin.moduleUrl
|
|
163
|
+
});
|
|
164
|
+
let CategoriesStreamSlice = Platform.StateViewSliceStream.Make({
|
|
165
|
+
name: Categories$CatalogPlugin.name,
|
|
166
|
+
moduleUrl: Categories$CatalogPlugin.moduleUrl,
|
|
167
|
+
stateSchema: Categories$CatalogPlugin.stateSchema,
|
|
168
|
+
consumedEventSchema: Categories$CatalogPlugin.consumedEventSchema,
|
|
169
|
+
config: Categories$CatalogPlugin.config,
|
|
170
|
+
subIdConfig: undefined,
|
|
171
|
+
authorization: Categories$CatalogPlugin.authorization,
|
|
172
|
+
visibility: Categories$CatalogPlugin.visibility
|
|
173
|
+
})({
|
|
174
|
+
project: Categories_Projection$CatalogPlugin.project,
|
|
175
|
+
moduleUrl: Categories_Projection$CatalogPlugin.moduleUrl
|
|
176
|
+
});
|
|
177
|
+
let ProductDemandStreamSlice = Platform.StateViewSliceStream.Make({
|
|
178
|
+
name: ProductDemand$CatalogPlugin.name,
|
|
179
|
+
moduleUrl: ProductDemand$CatalogPlugin.moduleUrl,
|
|
180
|
+
stateSchema: ProductDemand$CatalogPlugin.stateSchema,
|
|
181
|
+
consumedEventSchema: ProductDemand$CatalogPlugin.consumedEventSchema,
|
|
182
|
+
config: ProductDemand$CatalogPlugin.config,
|
|
183
|
+
subIdConfig: undefined,
|
|
184
|
+
authorization: ProductDemand$CatalogPlugin.authorization,
|
|
185
|
+
visibility: ProductDemand$CatalogPlugin.visibility
|
|
186
|
+
})({
|
|
187
|
+
project: ProductDemand_Projection$CatalogPlugin.project,
|
|
188
|
+
moduleUrl: ProductDemand_Projection$CatalogPlugin.moduleUrl
|
|
189
|
+
});
|
|
190
|
+
let ProductsStreamSlice = Platform.StateViewSliceStream.Make({
|
|
191
|
+
name: Products$CatalogPlugin.name,
|
|
192
|
+
moduleUrl: Products$CatalogPlugin.moduleUrl,
|
|
193
|
+
stateSchema: Products$CatalogPlugin.stateSchema,
|
|
194
|
+
consumedEventSchema: Products$CatalogPlugin.consumedEventSchema,
|
|
195
|
+
config: Products$CatalogPlugin.config,
|
|
196
|
+
subIdConfig: undefined,
|
|
197
|
+
authorization: Products$CatalogPlugin.authorization,
|
|
198
|
+
visibility: Products$CatalogPlugin.visibility
|
|
199
|
+
})({
|
|
200
|
+
project: Products_Projection$CatalogPlugin.project,
|
|
201
|
+
moduleUrl: Products_Projection$CatalogPlugin.moduleUrl
|
|
202
|
+
});
|
|
203
|
+
let ImportProductSlice = Platform.InboundTranslationSlice.Make({
|
|
204
|
+
name: ImportProduct$CatalogPlugin.name,
|
|
205
|
+
moduleUrl: ImportProduct$CatalogPlugin.moduleUrl,
|
|
206
|
+
externalInputSchema: ImportProduct$CatalogPlugin.externalInputSchema,
|
|
207
|
+
commandSchema: ImportProduct$CatalogPlugin.commandSchema,
|
|
208
|
+
targetName: ImportProduct$CatalogPlugin.targetName,
|
|
209
|
+
externalSystem: ImportProduct$CatalogPlugin.externalSystem,
|
|
210
|
+
commandAuthorization: ImportProduct$CatalogPlugin.commandAuthorization
|
|
211
|
+
})({
|
|
212
|
+
translate: ImportProduct_Translation$CatalogPlugin.translate,
|
|
213
|
+
moduleUrl: ImportProduct_Translation$CatalogPlugin.moduleUrl
|
|
214
|
+
});
|
|
215
|
+
let ImportProductsTask = Platform.Task.Make({
|
|
216
|
+
name: ImportProducts$CatalogPlugin.name,
|
|
217
|
+
moduleUrl: ImportProducts$CatalogPlugin.moduleUrl,
|
|
218
|
+
setup: ImportProducts$CatalogPlugin.setup
|
|
219
|
+
});
|
|
220
|
+
let Products_ExtensionPoint = Platform.ExtensionPoint.Make({
|
|
221
|
+
ExtensionPoint: {
|
|
222
|
+
name: Products_ExtensionPoint$CatalogSpec.name,
|
|
223
|
+
moduleUrl: Products_ExtensionPoint$CatalogSpec.moduleUrl,
|
|
224
|
+
commandSchema: Products_ExtensionPoint$CatalogSpec.commandSchema,
|
|
225
|
+
eventSchema: Products_ExtensionPoint$CatalogSpec.eventSchema,
|
|
226
|
+
directiveSchema: Products_ExtensionPoint$CatalogSpec.directiveSchema
|
|
227
|
+
},
|
|
228
|
+
Delegate: {
|
|
229
|
+
Id: Id$Reventless.$$String,
|
|
230
|
+
name: Products_ExtensionPointMapping$CatalogPlugin.Delegate.name,
|
|
231
|
+
eventSchema: Products_ExtensionPointMapping$CatalogPlugin.Delegate.eventSchema,
|
|
232
|
+
errorSchema: Products_ExtensionPointMapping$CatalogPlugin.Delegate.errorSchema,
|
|
233
|
+
commandSchema: Products_ExtensionPointMapping$CatalogPlugin.Delegate.commandSchema,
|
|
234
|
+
moduleUrl: Products_ExtensionPointMapping$CatalogPlugin.Delegate.moduleUrl,
|
|
235
|
+
commandAuthorization: Products_ExtensionPointMapping$CatalogPlugin.Delegate.commandAuthorization
|
|
236
|
+
},
|
|
237
|
+
moduleUrl: Products_ExtensionPointMapping$CatalogPlugin.moduleUrl,
|
|
238
|
+
mapIncomingCommand: Products_ExtensionPointMapping$CatalogPlugin.mapIncomingCommand,
|
|
239
|
+
mapOutgoingEvent: Products_ExtensionPointMapping$CatalogPlugin.mapOutgoingEvent
|
|
240
|
+
});
|
|
241
|
+
let Orders_Extension = Platform.Extension.Make({
|
|
242
|
+
ExtensionPoint: {
|
|
243
|
+
name: Orders_ExtensionPoint$OrderingSpec.name,
|
|
244
|
+
moduleUrl: Orders_ExtensionPoint$OrderingSpec.moduleUrl,
|
|
245
|
+
commandSchema: Orders_ExtensionPoint$OrderingSpec.commandSchema,
|
|
246
|
+
eventSchema: Orders_ExtensionPoint$OrderingSpec.eventSchema,
|
|
247
|
+
directiveSchema: Orders_ExtensionPoint$OrderingSpec.directiveSchema
|
|
248
|
+
},
|
|
249
|
+
Delegate: {
|
|
250
|
+
Id: Id$Reventless.$$String,
|
|
251
|
+
name: RecordProductDemand$CatalogPlugin.name,
|
|
252
|
+
eventSchema: RecordProductDemand$CatalogPlugin.eventSchema,
|
|
253
|
+
errorSchema: RecordProductDemand$CatalogPlugin.errorSchema,
|
|
254
|
+
commandSchema: RecordProductDemand$CatalogPlugin.commandSchema,
|
|
255
|
+
moduleUrl: RecordProductDemand$CatalogPlugin.moduleUrl,
|
|
256
|
+
commandAuthorization: RecordProductDemand$CatalogPlugin.commandAuthorization
|
|
257
|
+
},
|
|
258
|
+
moduleUrl: Orders_Extension$CatalogPlugin.Mapping.moduleUrl,
|
|
259
|
+
delegateModuleUrl: Orders_Extension$CatalogPlugin.Mapping.delegateModuleUrl,
|
|
260
|
+
mapIncomingEvent: Orders_Extension$CatalogPlugin.Mapping.mapIncomingEvent,
|
|
261
|
+
mapOutgoingEvent: Orders_Extension$CatalogPlugin.Mapping.mapOutgoingEvent
|
|
262
|
+
});
|
|
263
|
+
let pluginStructure = Platform.Plugin.makePluginDefinition("Catalog", undefined, undefined, [
|
|
264
|
+
CategoriesStreamSlice,
|
|
265
|
+
ProductDemandStreamSlice,
|
|
266
|
+
ProductsStreamSlice
|
|
267
|
+
], [
|
|
268
|
+
AddCategorySlice,
|
|
269
|
+
AddProductSlice,
|
|
270
|
+
ArchiveCategorySlice,
|
|
271
|
+
ChangeProductDescriptionSlice,
|
|
272
|
+
ChangeProductNameSlice,
|
|
273
|
+
ChangeProductPriceSlice,
|
|
274
|
+
RecordProductDemandSlice,
|
|
275
|
+
RenameCategorySlice
|
|
276
|
+
], undefined, undefined, [ImportProductSlice], [Orders_Extension], [{
|
|
277
|
+
ExtensionPoint: {
|
|
278
|
+
name: Products_ExtensionPoint$CatalogSpec.name,
|
|
279
|
+
moduleUrl: Products_ExtensionPoint$CatalogSpec.moduleUrl,
|
|
280
|
+
commandSchema: Products_ExtensionPoint$CatalogSpec.commandSchema,
|
|
281
|
+
eventSchema: Products_ExtensionPoint$CatalogSpec.eventSchema,
|
|
282
|
+
directiveSchema: Products_ExtensionPoint$CatalogSpec.directiveSchema
|
|
283
|
+
},
|
|
284
|
+
Delegate: {
|
|
285
|
+
Id: Id$Reventless.$$String,
|
|
286
|
+
name: Products_ExtensionPointMapping$CatalogPlugin.Delegate.name,
|
|
287
|
+
eventSchema: Products_ExtensionPointMapping$CatalogPlugin.Delegate.eventSchema,
|
|
288
|
+
errorSchema: Products_ExtensionPointMapping$CatalogPlugin.Delegate.errorSchema,
|
|
289
|
+
commandSchema: Products_ExtensionPointMapping$CatalogPlugin.Delegate.commandSchema,
|
|
290
|
+
moduleUrl: Products_ExtensionPointMapping$CatalogPlugin.Delegate.moduleUrl,
|
|
291
|
+
commandAuthorization: Products_ExtensionPointMapping$CatalogPlugin.Delegate.commandAuthorization
|
|
292
|
+
},
|
|
293
|
+
moduleUrl: Products_ExtensionPointMapping$CatalogPlugin.moduleUrl,
|
|
294
|
+
mapIncomingCommand: Products_ExtensionPointMapping$CatalogPlugin.mapIncomingCommand,
|
|
295
|
+
mapOutgoingEvent: Products_ExtensionPointMapping$CatalogPlugin.mapOutgoingEvent
|
|
296
|
+
}]);
|
|
297
|
+
let make = () => Platform.Plugin.make("Catalog", 5, [Products_ExtensionPoint], [Orders_Extension], undefined, undefined, [ImportProductsTask], [
|
|
298
|
+
AddCategorySlice,
|
|
299
|
+
AddProductSlice,
|
|
300
|
+
ArchiveCategorySlice,
|
|
301
|
+
ChangeProductDescriptionSlice,
|
|
302
|
+
ChangeProductNameSlice,
|
|
303
|
+
ChangeProductPriceSlice,
|
|
304
|
+
RecordProductDemandSlice,
|
|
305
|
+
RenameCategorySlice
|
|
306
|
+
], [
|
|
307
|
+
CategoriesStreamSlice,
|
|
308
|
+
ProductDemandStreamSlice,
|
|
309
|
+
ProductsStreamSlice
|
|
310
|
+
], undefined, undefined, [ImportProductSlice], Stdlib_Option.map(process.env.CATALOG_UI_BUNDLE_URL, url => Platform.Plugin.makeAutoUIManifest(url, "Catalog", pluginStructure, ["platform-summary"], ["resource-detail"])), pluginStructure, undefined);
|
|
311
|
+
return {
|
|
312
|
+
AddCategorySlice: AddCategorySlice,
|
|
313
|
+
AddProductSlice: AddProductSlice,
|
|
314
|
+
ArchiveCategorySlice: ArchiveCategorySlice,
|
|
315
|
+
ChangeProductDescriptionSlice: ChangeProductDescriptionSlice,
|
|
316
|
+
ChangeProductNameSlice: ChangeProductNameSlice,
|
|
317
|
+
ChangeProductPriceSlice: ChangeProductPriceSlice,
|
|
318
|
+
RecordProductDemandSlice: RecordProductDemandSlice,
|
|
319
|
+
RenameCategorySlice: RenameCategorySlice,
|
|
320
|
+
CategoriesStreamSlice: CategoriesStreamSlice,
|
|
321
|
+
ProductDemandStreamSlice: ProductDemandStreamSlice,
|
|
322
|
+
ProductsStreamSlice: ProductsStreamSlice,
|
|
323
|
+
ImportProductSlice: ImportProductSlice,
|
|
324
|
+
ImportProductsTask: ImportProductsTask,
|
|
325
|
+
Products_ExtensionPoint: Products_ExtensionPoint,
|
|
326
|
+
Orders_Extension: Orders_Extension,
|
|
327
|
+
pluginStructure: pluginStructure,
|
|
328
|
+
make: make
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export {
|
|
333
|
+
Make,
|
|
334
|
+
}
|
|
335
|
+
/* Id-Reventless Not a pure module */
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// ImportProduct InboundTranslationSlice.
|
|
2
|
+
// Receives external supplier JSON, validates and translates to an AddProduct command.
|
|
3
|
+
|
|
4
|
+
@@reventless.spec
|
|
5
|
+
|
|
6
|
+
@schema
|
|
7
|
+
type externalInput = {
|
|
8
|
+
sku: string,
|
|
9
|
+
title: string,
|
|
10
|
+
desc: string,
|
|
11
|
+
unitPrice: int,
|
|
12
|
+
currency: string,
|
|
13
|
+
category: string,
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
@schema
|
|
17
|
+
type command = AddProduct({
|
|
18
|
+
productId: string,
|
|
19
|
+
name: string,
|
|
20
|
+
description: string,
|
|
21
|
+
price: float,
|
|
22
|
+
categoryId: string,
|
|
23
|
+
})
|
|
24
|
+
|
|
25
|
+
let targetName = "AddProduct"
|
|
26
|
+
// Foreign system this anti-corruption slice receives product data from — drawn as an
|
|
27
|
+
// external box outside the Catalog plugin in the Event Graph.
|
|
28
|
+
let externalSystem = Some("SupplierFeed")
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
5
|
+
|
|
6
|
+
let externalInputSchema = S.schema(s => ({
|
|
7
|
+
sku: s.m(S.string),
|
|
8
|
+
title: s.m(S.string),
|
|
9
|
+
desc: s.m(S.string),
|
|
10
|
+
unitPrice: s.m(S.int),
|
|
11
|
+
currency: s.m(S.string),
|
|
12
|
+
category: s.m(S.string)
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
let commandSchema = S.schema(s => ({
|
|
16
|
+
TAG: "AddProduct",
|
|
17
|
+
productId: s.m(DcbTag$Reventless.string),
|
|
18
|
+
name: s.m(S.string),
|
|
19
|
+
description: s.m(S.string),
|
|
20
|
+
price: s.m(S.float),
|
|
21
|
+
categoryId: s.m(DcbTag$Reventless.string)
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
function commandAuthorization(param) {
|
|
25
|
+
return "AllowAuthenticated";
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
let name = "ImportProduct";
|
|
29
|
+
|
|
30
|
+
let Id;
|
|
31
|
+
|
|
32
|
+
let targetName = "AddProduct";
|
|
33
|
+
|
|
34
|
+
let externalSystem = "SupplierFeed";
|
|
35
|
+
|
|
36
|
+
let moduleUrl = "@reventlessdev/online-shop-hybrid-catalog/src/Product/InboundTranslationSlice/ImportProduct.res.mjs";
|
|
37
|
+
|
|
38
|
+
export {
|
|
39
|
+
name,
|
|
40
|
+
Id,
|
|
41
|
+
externalInputSchema,
|
|
42
|
+
commandSchema,
|
|
43
|
+
targetName,
|
|
44
|
+
externalSystem,
|
|
45
|
+
moduleUrl,
|
|
46
|
+
commandAuthorization,
|
|
47
|
+
}
|
|
48
|
+
/* externalInputSchema Not a pure module */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@@reventless.translation
|
|
2
|
+
|
|
3
|
+
let translate = (input: externalInput) =>
|
|
4
|
+
if input.currency !== "USD" {
|
|
5
|
+
Error("Unsupported currency: " ++ input.currency)
|
|
6
|
+
} else if input.unitPrice <= 0 {
|
|
7
|
+
Error("Price must be positive")
|
|
8
|
+
} else if input.sku === "" {
|
|
9
|
+
Error("SKU is required")
|
|
10
|
+
} else if input.category === "" {
|
|
11
|
+
Error("Category is required")
|
|
12
|
+
} else {
|
|
13
|
+
Ok([(
|
|
14
|
+
input.sku,
|
|
15
|
+
AddProduct({
|
|
16
|
+
productId: input.sku,
|
|
17
|
+
name: input.title,
|
|
18
|
+
description: input.desc,
|
|
19
|
+
price: Int.toFloat(input.unitPrice) /. 100.0,
|
|
20
|
+
categoryId: input.category,
|
|
21
|
+
}),
|
|
22
|
+
)])
|
|
23
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
function translate(input) {
|
|
5
|
+
if (input.currency !== "USD") {
|
|
6
|
+
return {
|
|
7
|
+
TAG: "Error",
|
|
8
|
+
_0: "Unsupported currency: " + input.currency
|
|
9
|
+
};
|
|
10
|
+
} else if (input.unitPrice <= 0) {
|
|
11
|
+
return {
|
|
12
|
+
TAG: "Error",
|
|
13
|
+
_0: "Price must be positive"
|
|
14
|
+
};
|
|
15
|
+
} else if (input.sku === "") {
|
|
16
|
+
return {
|
|
17
|
+
TAG: "Error",
|
|
18
|
+
_0: "SKU is required"
|
|
19
|
+
};
|
|
20
|
+
} else if (input.category === "") {
|
|
21
|
+
return {
|
|
22
|
+
TAG: "Error",
|
|
23
|
+
_0: "Category is required"
|
|
24
|
+
};
|
|
25
|
+
} else {
|
|
26
|
+
return {
|
|
27
|
+
TAG: "Ok",
|
|
28
|
+
_0: [[
|
|
29
|
+
input.sku,
|
|
30
|
+
{
|
|
31
|
+
TAG: "AddProduct",
|
|
32
|
+
productId: input.sku,
|
|
33
|
+
name: input.title,
|
|
34
|
+
description: input.desc,
|
|
35
|
+
price: input.unitPrice / 100.0,
|
|
36
|
+
categoryId: input.category
|
|
37
|
+
}
|
|
38
|
+
]]
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
let Spec;
|
|
44
|
+
|
|
45
|
+
let moduleUrl = "@reventlessdev/online-shop-hybrid-catalog/src/Product/InboundTranslationSlice/ImportProduct_Translation.res.mjs";
|
|
46
|
+
|
|
47
|
+
export {
|
|
48
|
+
Spec,
|
|
49
|
+
translate,
|
|
50
|
+
moduleUrl,
|
|
51
|
+
}
|
|
52
|
+
/* No side effect */
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// AddProduct StateChangeSlice.
|
|
2
|
+
// Rejects duplicate creation and validates that the referenced category exists
|
|
3
|
+
// and is active.
|
|
4
|
+
|
|
5
|
+
@@reventless.spec
|
|
6
|
+
|
|
7
|
+
@schema
|
|
8
|
+
type consumedEvent =
|
|
9
|
+
| ProductAdded({productId: string})
|
|
10
|
+
| CategoryAdded({categoryId: string})
|
|
11
|
+
| CategoryArchived({categoryId: string})
|
|
12
|
+
|
|
13
|
+
@schema
|
|
14
|
+
type command =
|
|
15
|
+
| AddProduct({
|
|
16
|
+
// Two *Id fields (productId + categoryId) — @partitionTag picks the storage partition.
|
|
17
|
+
@partitionTag productId: string,
|
|
18
|
+
name: string,
|
|
19
|
+
description: string,
|
|
20
|
+
price: float,
|
|
21
|
+
@ref("Categories") categoryId: string,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
@schema
|
|
25
|
+
type error =
|
|
26
|
+
| ProductAlreadyExists
|
|
27
|
+
| CategoryNotFound
|
|
28
|
+
|
|
29
|
+
@schema
|
|
30
|
+
type event =
|
|
31
|
+
| ProductAdded({
|
|
32
|
+
@partitionTag productId: string,
|
|
33
|
+
name: string,
|
|
34
|
+
description: string,
|
|
35
|
+
price: float,
|
|
36
|
+
categoryId: string,
|
|
37
|
+
})
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Generated by ReScript, PLEASE EDIT WITH CARE
|
|
2
|
+
|
|
3
|
+
import * as S from "sury/src/S.res.mjs";
|
|
4
|
+
import * as DcbTag$Reventless from "@reventlessdev/reventless-spec/src/components/DcbTag.res.mjs";
|
|
5
|
+
import * as Reference$Reventless from "@reventlessdev/reventless-spec/src/components/Reference.res.mjs";
|
|
6
|
+
|
|
7
|
+
let consumedEventSchema = S.union([
|
|
8
|
+
S.schema(s => ({
|
|
9
|
+
TAG: "ProductAdded",
|
|
10
|
+
productId: s.m(DcbTag$Reventless.string)
|
|
11
|
+
})),
|
|
12
|
+
S.schema(s => ({
|
|
13
|
+
TAG: "CategoryAdded",
|
|
14
|
+
categoryId: s.m(DcbTag$Reventless.string)
|
|
15
|
+
})),
|
|
16
|
+
S.schema(s => ({
|
|
17
|
+
TAG: "CategoryArchived",
|
|
18
|
+
categoryId: s.m(DcbTag$Reventless.string)
|
|
19
|
+
}))
|
|
20
|
+
]);
|
|
21
|
+
|
|
22
|
+
let commandSchema = S.schema(s => ({
|
|
23
|
+
TAG: "AddProduct",
|
|
24
|
+
productId: s.m(DcbTag$Reventless.partition),
|
|
25
|
+
name: s.m(S.string),
|
|
26
|
+
description: s.m(S.string),
|
|
27
|
+
price: s.m(S.float),
|
|
28
|
+
categoryId: s.m(Reference$Reventless.to_(undefined, undefined, "Categories"))
|
|
29
|
+
}));
|
|
30
|
+
|
|
31
|
+
let errorSchema = S.union([
|
|
32
|
+
S.literal("ProductAlreadyExists"),
|
|
33
|
+
S.literal("CategoryNotFound")
|
|
34
|
+
]);
|
|
35
|
+
|
|
36
|
+
let eventSchema = S.schema(s => ({
|
|
37
|
+
TAG: "ProductAdded",
|
|
38
|
+
productId: s.m(DcbTag$Reventless.partition),
|
|
39
|
+
name: s.m(S.string),
|
|
40
|
+
description: s.m(S.string),
|
|
41
|
+
price: s.m(S.float),
|
|
42
|
+
categoryId: s.m(DcbTag$Reventless.string)
|
|
43
|
+
}));
|
|
44
|
+
|
|
45
|
+
function commandAuthorization(param) {
|
|
46
|
+
return "AllowAuthenticated";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let name = "AddProduct";
|
|
50
|
+
|
|
51
|
+
let Id;
|
|
52
|
+
|
|
53
|
+
let moduleUrl = "@reventlessdev/online-shop-hybrid-catalog/src/Product/StateChangeSlice/AddProduct.res.mjs";
|
|
54
|
+
|
|
55
|
+
let readConsistency = "EscalateOnRetry";
|
|
56
|
+
|
|
57
|
+
export {
|
|
58
|
+
name,
|
|
59
|
+
Id,
|
|
60
|
+
consumedEventSchema,
|
|
61
|
+
commandSchema,
|
|
62
|
+
errorSchema,
|
|
63
|
+
eventSchema,
|
|
64
|
+
moduleUrl,
|
|
65
|
+
commandAuthorization,
|
|
66
|
+
readConsistency,
|
|
67
|
+
}
|
|
68
|
+
/* consumedEventSchema Not a pure module */
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@@reventless.behavior
|
|
2
|
+
|
|
3
|
+
// `exists` flags whether this product already exists; `liveCategoryIds` holds
|
|
4
|
+
// categories that exist and are not archived — adding a product to a missing or
|
|
5
|
+
// archived category is rejected.
|
|
6
|
+
type state = {exists: bool, liveCategoryIds: array<string>}
|
|
7
|
+
|
|
8
|
+
let initialState = {exists: false, liveCategoryIds: []}
|
|
9
|
+
|
|
10
|
+
let evolve = (state, event: consumedEvent) =>
|
|
11
|
+
switch event {
|
|
12
|
+
| ProductAdded(_) => {...state, exists: true}
|
|
13
|
+
| CategoryAdded({categoryId}) => {
|
|
14
|
+
...state,
|
|
15
|
+
liveCategoryIds: state.liveCategoryIds->Array.includes(categoryId)
|
|
16
|
+
? state.liveCategoryIds
|
|
17
|
+
: Array.concat(state.liveCategoryIds, [categoryId]),
|
|
18
|
+
}
|
|
19
|
+
| CategoryArchived({categoryId}) => {
|
|
20
|
+
...state,
|
|
21
|
+
liveCategoryIds: state.liveCategoryIds->Array.filter(id => id !== categoryId),
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
let decide = (state, command) =>
|
|
26
|
+
switch command {
|
|
27
|
+
| AddProduct({productId, name, description, price, categoryId}) =>
|
|
28
|
+
if state.exists {
|
|
29
|
+
Error(ProductAlreadyExists)
|
|
30
|
+
} else if !(state.liveCategoryIds->Array.includes(categoryId)) {
|
|
31
|
+
Error(CategoryNotFound)
|
|
32
|
+
} else {
|
|
33
|
+
Ok([ProductAdded({productId, name, description, price, categoryId})])
|
|
34
|
+
}
|
|
35
|
+
}
|