@flarehr/superhero-basic-profile 0.1.2217 → 0.1.2223
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/dist/assets/delete.dcc7b157.svg +5 -0
- package/dist/assets/dialog-warning.cc77f3ba.svg +5 -0
- package/dist/assets/pencil.05fe6be6.svg +5 -0
- package/dist/index.html +20 -0
- package/dist/superhero-basic-profile.js +50 -0
- package/package.json +1 -1
- package/dist/App.jsx +0 -4
- package/dist/Basic.Profile.Domain/AnalyticsEvent.jsx +0 -102
- package/dist/Basic.Profile.Domain/Audit.jsx +0 -149
- package/dist/Basic.Profile.Domain/Commands.jsx +0 -68
- package/dist/Basic.Profile.Domain/CommonTypes.jsx +0 -194
- package/dist/Basic.Profile.Domain/Config/Api/Admin/Read.jsx +0 -58
- package/dist/Basic.Profile.Domain/Config/Api/Admin/Write.jsx +0 -23
- package/dist/Basic.Profile.Domain/Config/Api/FlareAdminShell/Read.jsx +0 -35
- package/dist/Basic.Profile.Domain/Config/Commands.jsx +0 -72
- package/dist/Basic.Profile.Domain/Config/ConfigCommandHandler.jsx +0 -197
- package/dist/Basic.Profile.Domain/Config/Dto.jsx +0 -181
- package/dist/Basic.Profile.Domain/Config/Types.jsx +0 -152
- package/dist/Basic.Profile.Domain/DateTimeProvider.jsx +0 -23
- package/dist/Basic.Profile.Domain/DomainAggregates.jsx +0 -801
- package/dist/Basic.Profile.Domain/DomainPrimitives.jsx +0 -426
- package/dist/Basic.Profile.Domain/Dto/Aggregates.jsx +0 -564
- package/dist/Basic.Profile.Domain/Dto/AnalyticsEvent.jsx +0 -157
- package/dist/Basic.Profile.Domain/Dto/Api/Backend/Common.jsx +0 -102
- package/dist/Basic.Profile.Domain/Dto/Api/Backend/Read.jsx +0 -85
- package/dist/Basic.Profile.Domain/Dto/Api/Backend/Write.jsx +0 -16
- package/dist/Basic.Profile.Domain/Dto/Api/Common.jsx +0 -427
- package/dist/Basic.Profile.Domain/Dto/Api/External/Read.jsx +0 -118
- package/dist/Basic.Profile.Domain/Dto/Api/External/ReadV2.jsx +0 -6
- package/dist/Basic.Profile.Domain/Dto/Api/External/Write.jsx +0 -184
- package/dist/Basic.Profile.Domain/Dto/Api/External/WriteV2.jsx +0 -439
- package/dist/Basic.Profile.Domain/Dto/Api/FlareAdminShell/Read.jsx +0 -38
- package/dist/Basic.Profile.Domain/Dto/Api/FlareAdminShell/Write.jsx +0 -199
- package/dist/Basic.Profile.Domain/Dto/Api/Internal/Read.jsx +0 -125
- package/dist/Basic.Profile.Domain/Dto/Audit.jsx +0 -121
- package/dist/Basic.Profile.Domain/Dto/Commands.jsx +0 -256
- package/dist/Basic.Profile.Domain/Dto/Common.jsx +0 -84
- package/dist/Basic.Profile.Domain/Dto/Events.jsx +0 -220
- package/dist/Basic.Profile.Domain/Dto/Primitives.jsx +0 -580
- package/dist/Basic.Profile.Domain/Dto/ProfileCreationModels.jsx +0 -324
- package/dist/Basic.Profile.Domain/Dto/Validation.jsx +0 -229
- package/dist/Basic.Profile.Domain/Events.jsx +0 -64
- package/dist/Basic.Profile.Domain/Import/Api/InternalApi/Read.jsx +0 -140
- package/dist/Basic.Profile.Domain/Import/Api/InternalApi/Validation.jsx +0 -499
- package/dist/Basic.Profile.Domain/Import/Api/InternalApi/Write.jsx +0 -51
- package/dist/Basic.Profile.Domain/Import/Api/Read.jsx +0 -154
- package/dist/Basic.Profile.Domain/Import/CommonTypes.jsx +0 -187
- package/dist/Basic.Profile.Domain/Import/Dto.jsx +0 -475
- package/dist/Basic.Profile.Domain/Import/ImportCommandHandler.jsx +0 -531
- package/dist/Basic.Profile.Domain/Import/Types.jsx +0 -405
- package/dist/Basic.Profile.Domain/JwtPayload.jsx +0 -44
- package/dist/Basic.Profile.Domain/Metadata.jsx +0 -257
- package/dist/Basic.Profile.Domain/ProfileCommandHandler.jsx +0 -261
- package/dist/Basic.Profile.Domain/ProfileModels.jsx +0 -59
- package/dist/Basic.Profile.Domain/Utils.jsx +0 -372
- package/dist/Common/PreactCustomElement.jsx +0 -8
- package/dist/Common/Resources.jsx +0 -20
- package/dist/Common/Tailwind.jsx +0 -8
- package/dist/Common/Utils.jsx +0 -18
- package/dist/Directory/App.jsx +0 -192
- package/dist/Directory/BackendServices/Common.jsx +0 -115
- package/dist/Directory/BackendServices/ConfigService.jsx +0 -168
- package/dist/Directory/BackendServices/ImportService.jsx +0 -137
- package/dist/Directory/Common.jsx +0 -93
- package/dist/Directory/Config/Components.jsx +0 -173
- package/dist/Directory/Config/Types.jsx +0 -187
- package/dist/Directory/PastImports/PastImports.jsx +0 -81
- package/dist/Directory/ProfileImport/ProfileImport.jsx +0 -284
- package/dist/Directory/ProfileImport/Types.jsx +0 -91
- package/dist/Directory/TabNav.jsx +0 -24
- package/dist/Directory/Types.jsx +0 -101
- package/dist/Directory/User.jsx +0 -117
- package/dist/HeadlessUI/Dialog.jsx +0 -66
- package/dist/HeadlessUI/ModalDialog.jsx +0 -74
- package/dist/HeadlessUI/Switch.jsx +0 -66
- package/dist/HeadlessUI/Transition.jsx +0 -66
|
@@ -1,531 +0,0 @@
|
|
|
1
|
-
import { Record, Union } from "../../fable_modules/fable-library-js.4.20.0/Types.js";
|
|
2
|
-
import { AccountImportData_completeActiveImport, ActiveImport, AccountImportData_tryUpdateActiveImport, AccountImportsDomainMetadata, AccountImportData_init, AccountImportData_tryAddActiveImport, ActiveImportModule_create, RowImportFailedEventPayload, RowImportSucceededEventPayload, AccountImportData_getActiveImportById, ActiveImportModule_importsRemaining, FileInfoModule_$007CCSV$007CJSON$007CUnknown$007C, ImportIdModule_init, ImportEventPayload, ImportEventDomainMetadata, AccountImportData_hasActiveImport, AccountImportData_tryGetImport, AccountImportData_getNextImportId, ImportStartedEventPayload, Actor_$reflection, FileInfo_$reflection, Origin_$reflection, ImportEventDomainMetadata_$reflection, ImportEventPayload_$reflection, AccountImportsDomainMetadata_$reflection, AccountImportsData_$reflection, ImportId_$reflection } from "./Types.jsx";
|
|
3
|
-
import { string_type, record_type, option_type, list_type, union_type, int32_type, anonRecord_type } from "../../fable_modules/fable-library-js.4.20.0/Reflection.js";
|
|
4
|
-
import { AggregateMetadata$1, Aggregate$2, AggregateMetadata_incrementVersion, Command_toEvent, Event$2_$reflection, Aggregate$2_$reflection } from "./CommonTypes.jsx";
|
|
5
|
-
import { defaultArg } from "../../fable_modules/fable-library-js.4.20.0/Option.js";
|
|
6
|
-
import { FSharpResult$2 } from "../../fable_modules/fable-library-js.4.20.0/Result.js";
|
|
7
|
-
import { isEmpty, fold, singleton } from "../../fable_modules/fable-library-js.4.20.0/List.js";
|
|
8
|
-
import { equals } from "../../fable_modules/fable-library-js.4.20.0/Util.js";
|
|
9
|
-
|
|
10
|
-
export class ImportError extends Union {
|
|
11
|
-
constructor(tag, fields) {
|
|
12
|
-
super();
|
|
13
|
-
this.tag = tag;
|
|
14
|
-
this.fields = fields;
|
|
15
|
-
}
|
|
16
|
-
cases() {
|
|
17
|
-
return ["ImportAlreadyExists", "ActiveImportExists", "ActiveImportNotFound", "InconsistentCommand", "InvalidRowId", "MoreRowsToProcess", "NoMoreRowsToProcess"];
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function ImportError_$reflection() {
|
|
22
|
-
return union_type("Basic.Profile.Domain.Import.ImportCommandHandler.ImportError", [], ImportError, () => [[], [], [["Item", anonRecord_type(["ImportId", ImportId_$reflection()])]], [], [["Item", anonRecord_type(["GivenRow", int32_type], ["NextRow", int32_type], ["RowsRemaining", int32_type])]], [["Item", anonRecord_type(["NextRow", int32_type], ["RowsRemaining", int32_type])]], []]);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export class HandlerResult extends Union {
|
|
26
|
-
constructor(tag, fields) {
|
|
27
|
-
super();
|
|
28
|
-
this.tag = tag;
|
|
29
|
-
this.fields = fields;
|
|
30
|
-
}
|
|
31
|
-
cases() {
|
|
32
|
-
return ["Failed", "NoChange", "Create", "Update"];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export function HandlerResult_$reflection() {
|
|
37
|
-
return union_type("Basic.Profile.Domain.Import.ImportCommandHandler.HandlerResult", [], HandlerResult, () => [[["Item", ImportError_$reflection()]], [], [["Item1", Aggregate$2_$reflection(AccountImportsData_$reflection(), AccountImportsDomainMetadata_$reflection())], ["Item2", list_type(Event$2_$reflection(ImportEventPayload_$reflection(), ImportEventDomainMetadata_$reflection()))]], [["Item1", Aggregate$2_$reflection(AccountImportsData_$reflection(), AccountImportsDomainMetadata_$reflection())], ["Item2", list_type(Event$2_$reflection(ImportEventPayload_$reflection(), ImportEventDomainMetadata_$reflection()))]]]);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export class StartImportCommandPayload extends Record {
|
|
41
|
-
constructor(ImportId, Origin, FileInfo, Actor, TotalRowCount) {
|
|
42
|
-
super();
|
|
43
|
-
this.ImportId = ImportId;
|
|
44
|
-
this.Origin = Origin;
|
|
45
|
-
this.FileInfo = FileInfo;
|
|
46
|
-
this.Actor = Actor;
|
|
47
|
-
this.TotalRowCount = (TotalRowCount | 0);
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function StartImportCommandPayload_$reflection() {
|
|
52
|
-
return record_type("Basic.Profile.Domain.Import.ImportCommandHandler.StartImportCommandPayload", [], StartImportCommandPayload, () => [["ImportId", option_type(ImportId_$reflection())], ["Origin", Origin_$reflection()], ["FileInfo", FileInfo_$reflection()], ["Actor", Actor_$reflection()], ["TotalRowCount", int32_type]]);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export class ConfirmRowImportSucceededCommandPayload extends Record {
|
|
56
|
-
constructor(ImportId, RowId, ProfileId) {
|
|
57
|
-
super();
|
|
58
|
-
this.ImportId = ImportId;
|
|
59
|
-
this.RowId = (RowId | 0);
|
|
60
|
-
this.ProfileId = ProfileId;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export function ConfirmRowImportSucceededCommandPayload_$reflection() {
|
|
65
|
-
return record_type("Basic.Profile.Domain.Import.ImportCommandHandler.ConfirmRowImportSucceededCommandPayload", [], ConfirmRowImportSucceededCommandPayload, () => [["ImportId", ImportId_$reflection()], ["RowId", int32_type], ["ProfileId", string_type]]);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export class ConfirmRowImportFailedCommandPayload extends Record {
|
|
69
|
-
constructor(ImportId, RowId, Reason) {
|
|
70
|
-
super();
|
|
71
|
-
this.ImportId = ImportId;
|
|
72
|
-
this.RowId = (RowId | 0);
|
|
73
|
-
this.Reason = Reason;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function ConfirmRowImportFailedCommandPayload_$reflection() {
|
|
78
|
-
return record_type("Basic.Profile.Domain.Import.ImportCommandHandler.ConfirmRowImportFailedCommandPayload", [], ConfirmRowImportFailedCommandPayload, () => [["ImportId", ImportId_$reflection()], ["RowId", int32_type], ["Reason", string_type]]);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export class CompleteImportCommandPayload extends Record {
|
|
82
|
-
constructor(ImportId) {
|
|
83
|
-
super();
|
|
84
|
-
this.ImportId = ImportId;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
export function CompleteImportCommandPayload_$reflection() {
|
|
89
|
-
return record_type("Basic.Profile.Domain.Import.ImportCommandHandler.CompleteImportCommandPayload", [], CompleteImportCommandPayload, () => [["ImportId", ImportId_$reflection()]]);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
export class ImportCommandPayload extends Union {
|
|
93
|
-
constructor(tag, fields) {
|
|
94
|
-
super();
|
|
95
|
-
this.tag = tag;
|
|
96
|
-
this.fields = fields;
|
|
97
|
-
}
|
|
98
|
-
cases() {
|
|
99
|
-
return ["StartImport", "ConfirmRowImportSucceeded", "ConfirmRowImportFailed", "CompleteImport"];
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function ImportCommandPayload_$reflection() {
|
|
104
|
-
return union_type("Basic.Profile.Domain.Import.ImportCommandHandler.ImportCommandPayload", [], ImportCommandPayload, () => [[["Item", StartImportCommandPayload_$reflection()]], [["Item", ConfirmRowImportSucceededCommandPayload_$reflection()]], [["Item", ConfirmRowImportFailedCommandPayload_$reflection()]], [["Item", CompleteImportCommandPayload_$reflection()]]]);
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
function createImportStartedPayload(payload) {
|
|
108
|
-
return new ImportStartedEventPayload(payload.Origin, payload.Actor, payload.FileInfo, payload.TotalRowCount);
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
function handleStartImportCommand(account, command, payload) {
|
|
112
|
-
if (account != null) {
|
|
113
|
-
const acc = account;
|
|
114
|
-
const importId_1 = defaultArg(payload.ImportId, AccountImportData_getNextImportId(acc.Data));
|
|
115
|
-
const matchValue = AccountImportData_tryGetImport(acc.Data, importId_1);
|
|
116
|
-
const matchValue_1 = AccountImportData_hasActiveImport(acc.Data);
|
|
117
|
-
if (matchValue == null) {
|
|
118
|
-
if (matchValue_1) {
|
|
119
|
-
return new FSharpResult$2(1, [new ImportError(1, [])]);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
return new FSharpResult$2(0, [singleton(Command_toEvent(new ImportEventDomainMetadata(command.Metadata.PartnerId, command.Metadata.AccountId, importId_1), acc.Metadata.Version + 1, command, new ImportEventPayload(0, [createImportStartedPayload(payload)])))]);
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
else {
|
|
126
|
-
return new FSharpResult$2(1, [new ImportError(0, [])]);
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
return new FSharpResult$2(0, [singleton(Command_toEvent(new ImportEventDomainMetadata(command.Metadata.PartnerId, command.Metadata.AccountId, defaultArg(payload.ImportId, ImportIdModule_init())), 0, command, new ImportEventPayload(0, [createImportStartedPayload(payload)])))]);
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
function ensureConsistentRowId(current, givenRowId) {
|
|
135
|
-
let activePatternResult;
|
|
136
|
-
const isCsv = (activePatternResult = FileInfoModule_$007CCSV$007CJSON$007CUnknown$007C(current.FileInfo), (activePatternResult.tag === 1) ? false : (!(activePatternResult.tag === 2)));
|
|
137
|
-
const matchValue_1 = current.NextRow;
|
|
138
|
-
if (matchValue_1 != null) {
|
|
139
|
-
if (matchValue_1 === givenRowId) {
|
|
140
|
-
const nextRow_1 = matchValue_1 | 0;
|
|
141
|
-
return new FSharpResult$2(0, [undefined]);
|
|
142
|
-
}
|
|
143
|
-
else if (!isCsv) {
|
|
144
|
-
return new FSharpResult$2(0, [undefined]);
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
const nextRow_2 = matchValue_1 | 0;
|
|
148
|
-
return new FSharpResult$2(1, [new ImportError(4, [{
|
|
149
|
-
GivenRow: givenRowId,
|
|
150
|
-
NextRow: nextRow_2,
|
|
151
|
-
RowsRemaining: ActiveImportModule_importsRemaining(current),
|
|
152
|
-
}])]);
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
else {
|
|
156
|
-
return new FSharpResult$2(1, [new ImportError(6, [])]);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
function handleRowImportSucceededCommand(account, command, payload) {
|
|
161
|
-
const id = payload.ImportId;
|
|
162
|
-
let input_2;
|
|
163
|
-
const error = new ImportError(2, [{
|
|
164
|
-
ImportId: payload.ImportId,
|
|
165
|
-
}]);
|
|
166
|
-
const option_1 = AccountImportData_getActiveImportById(account.Data, id);
|
|
167
|
-
input_2 = ((option_1 == null) ? (new FSharpResult$2(1, [error])) : (new FSharpResult$2(0, [option_1])));
|
|
168
|
-
if (input_2.tag === 1) {
|
|
169
|
-
return new FSharpResult$2(1, [input_2.fields[0]]);
|
|
170
|
-
}
|
|
171
|
-
else {
|
|
172
|
-
const input = ensureConsistentRowId(input_2.fields[0], payload.RowId);
|
|
173
|
-
if (input.tag === 1) {
|
|
174
|
-
return new FSharpResult$2(1, [input.fields[0]]);
|
|
175
|
-
}
|
|
176
|
-
else {
|
|
177
|
-
return new FSharpResult$2(0, [singleton(Command_toEvent(new ImportEventDomainMetadata(command.Metadata.PartnerId, command.Metadata.AccountId, id), account.Metadata.Version, command, new ImportEventPayload(1, [new RowImportSucceededEventPayload(payload.RowId, payload.ProfileId)])))]);
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
function handleRowImportFailedCommand(account, command, payload) {
|
|
183
|
-
let input_2;
|
|
184
|
-
const error = new ImportError(2, [{
|
|
185
|
-
ImportId: payload.ImportId,
|
|
186
|
-
}]);
|
|
187
|
-
const option_1 = AccountImportData_getActiveImportById(account.Data, payload.ImportId);
|
|
188
|
-
input_2 = ((option_1 == null) ? (new FSharpResult$2(1, [error])) : (new FSharpResult$2(0, [option_1])));
|
|
189
|
-
if (input_2.tag === 1) {
|
|
190
|
-
return new FSharpResult$2(1, [input_2.fields[0]]);
|
|
191
|
-
}
|
|
192
|
-
else {
|
|
193
|
-
const input = ensureConsistentRowId(input_2.fields[0], payload.RowId);
|
|
194
|
-
if (input.tag === 1) {
|
|
195
|
-
return new FSharpResult$2(1, [input.fields[0]]);
|
|
196
|
-
}
|
|
197
|
-
else {
|
|
198
|
-
return new FSharpResult$2(0, [singleton(Command_toEvent(new ImportEventDomainMetadata(command.Metadata.PartnerId, command.Metadata.AccountId, payload.ImportId), account.Metadata.Version, command, new ImportEventPayload(2, [new RowImportFailedEventPayload(payload.RowId, payload.Reason)])))]);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function handleCompleteImportCommand(account, command, payload) {
|
|
204
|
-
let input_2;
|
|
205
|
-
const error = new ImportError(2, [{
|
|
206
|
-
ImportId: payload.ImportId,
|
|
207
|
-
}]);
|
|
208
|
-
const option_1 = AccountImportData_getActiveImportById(account.Data, payload.ImportId);
|
|
209
|
-
input_2 = ((option_1 == null) ? (new FSharpResult$2(1, [error])) : (new FSharpResult$2(0, [option_1])));
|
|
210
|
-
if (input_2.tag === 1) {
|
|
211
|
-
return new FSharpResult$2(1, [input_2.fields[0]]);
|
|
212
|
-
}
|
|
213
|
-
else {
|
|
214
|
-
const current = input_2.fields[0];
|
|
215
|
-
let input;
|
|
216
|
-
const matchValue = current.NextRow;
|
|
217
|
-
input = ((matchValue != null) ? (new FSharpResult$2(1, [new ImportError(5, [{
|
|
218
|
-
NextRow: matchValue,
|
|
219
|
-
RowsRemaining: ActiveImportModule_importsRemaining(current),
|
|
220
|
-
}])])) : (new FSharpResult$2(0, [undefined])));
|
|
221
|
-
if (input.tag === 1) {
|
|
222
|
-
return new FSharpResult$2(1, [input.fields[0]]);
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
return new FSharpResult$2(0, [singleton(Command_toEvent(new ImportEventDomainMetadata(command.Metadata.PartnerId, command.Metadata.AccountId, payload.ImportId), account.Metadata.Version, command, new ImportEventPayload(3, [])))]);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
function handleImportStartedEvent(account, event, payload) {
|
|
231
|
-
const activeImport = ActiveImportModule_create(payload, event.Metadata.Domain.ImportId, event.Metadata.Timestamp);
|
|
232
|
-
if (account != null) {
|
|
233
|
-
const acc = account;
|
|
234
|
-
const input_1 = AccountImportData_tryAddActiveImport(acc.Data, new ImportError(1, []), activeImport);
|
|
235
|
-
if (input_1.tag === 1) {
|
|
236
|
-
return new FSharpResult$2(1, [input_1.fields[0]]);
|
|
237
|
-
}
|
|
238
|
-
else {
|
|
239
|
-
return new FSharpResult$2(0, [new Aggregate$2(input_1.fields[0], AggregateMetadata_incrementVersion(acc.Metadata, event.Metadata.Timestamp))]);
|
|
240
|
-
}
|
|
241
|
-
}
|
|
242
|
-
else {
|
|
243
|
-
const input = AccountImportData_tryAddActiveImport(AccountImportData_init(), new ImportError(1, []), activeImport);
|
|
244
|
-
if (input.tag === 1) {
|
|
245
|
-
return new FSharpResult$2(1, [input.fields[0]]);
|
|
246
|
-
}
|
|
247
|
-
else {
|
|
248
|
-
return new FSharpResult$2(0, [new Aggregate$2(input.fields[0], new AggregateMetadata$1(event.Metadata.StreamId, 1, event.Metadata.Timestamp, event.Metadata.Timestamp, new AccountImportsDomainMetadata(event.Metadata.Domain.AccountId, event.Metadata.Domain.PartnerId)))]);
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function handleRowImportSucceededEvent(account, metadata, _payload) {
|
|
254
|
-
let input_1;
|
|
255
|
-
let input_4;
|
|
256
|
-
const error = new ImportError(2, [{
|
|
257
|
-
ImportId: metadata.Domain.ImportId,
|
|
258
|
-
}]);
|
|
259
|
-
const option_1 = AccountImportData_getActiveImportById(account.Data, metadata.Domain.ImportId);
|
|
260
|
-
input_4 = ((option_1 == null) ? (new FSharpResult$2(1, [error])) : (new FSharpResult$2(0, [option_1])));
|
|
261
|
-
if (input_4.tag === 1) {
|
|
262
|
-
return new FSharpResult$2(1, [input_4.fields[0]]);
|
|
263
|
-
}
|
|
264
|
-
else {
|
|
265
|
-
const current = input_4.fields[0];
|
|
266
|
-
const input_2 = AccountImportData_tryUpdateActiveImport(account.Data, new ImportError(2, [{
|
|
267
|
-
ImportId: metadata.Domain.ImportId,
|
|
268
|
-
}]), new ActiveImport(current.ImportId, current.Origin, current.Actor, current.FileInfo, current.NumberOfRecords, current.CompletedSuccessfully + 1, current.CompletedFailed, (ActiveImportModule_importsRemaining(current) === 1) ? undefined : ((input_1 = current.NextRow, (input_1 == null) ? undefined : (1 + input_1))), current.StartTime));
|
|
269
|
-
if (input_2.tag === 1) {
|
|
270
|
-
return new FSharpResult$2(1, [input_2.fields[0]]);
|
|
271
|
-
}
|
|
272
|
-
else {
|
|
273
|
-
return new FSharpResult$2(0, [new Aggregate$2(input_2.fields[0], AggregateMetadata_incrementVersion(account.Metadata, metadata.Timestamp))]);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
function handleRowImportFailedEvent(account, metadata, _payload) {
|
|
279
|
-
let input_1;
|
|
280
|
-
let input_4;
|
|
281
|
-
const error = new ImportError(2, [{
|
|
282
|
-
ImportId: metadata.Domain.ImportId,
|
|
283
|
-
}]);
|
|
284
|
-
const option_1 = AccountImportData_getActiveImportById(account.Data, metadata.Domain.ImportId);
|
|
285
|
-
input_4 = ((option_1 == null) ? (new FSharpResult$2(1, [error])) : (new FSharpResult$2(0, [option_1])));
|
|
286
|
-
if (input_4.tag === 1) {
|
|
287
|
-
return new FSharpResult$2(1, [input_4.fields[0]]);
|
|
288
|
-
}
|
|
289
|
-
else {
|
|
290
|
-
const current = input_4.fields[0];
|
|
291
|
-
const input_2 = AccountImportData_tryUpdateActiveImport(account.Data, new ImportError(2, [{
|
|
292
|
-
ImportId: metadata.Domain.ImportId,
|
|
293
|
-
}]), new ActiveImport(current.ImportId, current.Origin, current.Actor, current.FileInfo, current.NumberOfRecords, current.CompletedSuccessfully, current.CompletedFailed + 1, (ActiveImportModule_importsRemaining(current) === 1) ? undefined : ((input_1 = current.NextRow, (input_1 == null) ? undefined : (1 + input_1))), current.StartTime));
|
|
294
|
-
if (input_2.tag === 1) {
|
|
295
|
-
return new FSharpResult$2(1, [input_2.fields[0]]);
|
|
296
|
-
}
|
|
297
|
-
else {
|
|
298
|
-
return new FSharpResult$2(0, [new Aggregate$2(input_2.fields[0], AggregateMetadata_incrementVersion(account.Metadata, metadata.Timestamp))]);
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
function handleImportCompleteEvent(account, metadata) {
|
|
304
|
-
const input = AccountImportData_completeActiveImport(metadata.Timestamp, account.Data, new ImportError(2, [{
|
|
305
|
-
ImportId: metadata.Domain.ImportId,
|
|
306
|
-
}]), metadata.Domain.ImportId);
|
|
307
|
-
if (input.tag === 1) {
|
|
308
|
-
return new FSharpResult$2(1, [input.fields[0]]);
|
|
309
|
-
}
|
|
310
|
-
else {
|
|
311
|
-
return new FSharpResult$2(0, [new Aggregate$2(input.fields[0], AggregateMetadata_incrementVersion(account.Metadata, metadata.Timestamp))]);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
function execute(account, command) {
|
|
316
|
-
const matchValue = command.Payload;
|
|
317
|
-
let matchResult, payload, importId, payload_2, acc, payload_4, acc_1, payload_6, acc_2, payload_8;
|
|
318
|
-
if (account != null) {
|
|
319
|
-
switch (matchValue.tag) {
|
|
320
|
-
case 1: {
|
|
321
|
-
matchResult = 3;
|
|
322
|
-
acc = account;
|
|
323
|
-
payload_4 = matchValue.fields[0];
|
|
324
|
-
break;
|
|
325
|
-
}
|
|
326
|
-
case 2: {
|
|
327
|
-
matchResult = 4;
|
|
328
|
-
acc_1 = account;
|
|
329
|
-
payload_6 = matchValue.fields[0];
|
|
330
|
-
break;
|
|
331
|
-
}
|
|
332
|
-
case 3: {
|
|
333
|
-
matchResult = 5;
|
|
334
|
-
acc_2 = account;
|
|
335
|
-
payload_8 = matchValue.fields[0];
|
|
336
|
-
break;
|
|
337
|
-
}
|
|
338
|
-
default: {
|
|
339
|
-
matchResult = 2;
|
|
340
|
-
payload_2 = matchValue.fields[0];
|
|
341
|
-
}
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
else {
|
|
345
|
-
switch (matchValue.tag) {
|
|
346
|
-
case 1: {
|
|
347
|
-
matchResult = 1;
|
|
348
|
-
importId = matchValue.fields[0].ImportId;
|
|
349
|
-
break;
|
|
350
|
-
}
|
|
351
|
-
case 2: {
|
|
352
|
-
matchResult = 1;
|
|
353
|
-
importId = matchValue.fields[0].ImportId;
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
case 3: {
|
|
357
|
-
matchResult = 1;
|
|
358
|
-
importId = matchValue.fields[0].ImportId;
|
|
359
|
-
break;
|
|
360
|
-
}
|
|
361
|
-
default: {
|
|
362
|
-
matchResult = 0;
|
|
363
|
-
payload = matchValue.fields[0];
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
|
-
switch (matchResult) {
|
|
368
|
-
case 0: {
|
|
369
|
-
const tupledArg = [command, payload];
|
|
370
|
-
return handleStartImportCommand(account, tupledArg[0], tupledArg[1]);
|
|
371
|
-
}
|
|
372
|
-
case 1:
|
|
373
|
-
return new FSharpResult$2(1, [new ImportError(2, [{
|
|
374
|
-
ImportId: importId,
|
|
375
|
-
}])]);
|
|
376
|
-
case 2: {
|
|
377
|
-
const tupledArg_1 = [command, payload_2];
|
|
378
|
-
return handleStartImportCommand(account, tupledArg_1[0], tupledArg_1[1]);
|
|
379
|
-
}
|
|
380
|
-
case 3: {
|
|
381
|
-
const tupledArg_2 = [command, payload_4];
|
|
382
|
-
return handleRowImportSucceededCommand(acc, tupledArg_2[0], tupledArg_2[1]);
|
|
383
|
-
}
|
|
384
|
-
case 4: {
|
|
385
|
-
const tupledArg_3 = [command, payload_6];
|
|
386
|
-
return handleRowImportFailedCommand(acc_1, tupledArg_3[0], tupledArg_3[1]);
|
|
387
|
-
}
|
|
388
|
-
default: {
|
|
389
|
-
const tupledArg_4 = [command, payload_8];
|
|
390
|
-
return handleCompleteImportCommand(acc_2, tupledArg_4[0], tupledArg_4[1]);
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
function apply(account, event) {
|
|
396
|
-
let input_1;
|
|
397
|
-
const matchValue = event.Payload;
|
|
398
|
-
let matchResult, payload, acc, payload_2, acc_1, payload_4, acc_2, payload_5, acc_3, error;
|
|
399
|
-
const copyOfStruct = account;
|
|
400
|
-
if (copyOfStruct.tag === 1) {
|
|
401
|
-
matchResult = 6;
|
|
402
|
-
error = copyOfStruct.fields[0];
|
|
403
|
-
}
|
|
404
|
-
else if (copyOfStruct.fields[0] != null) {
|
|
405
|
-
switch (matchValue.tag) {
|
|
406
|
-
case 1: {
|
|
407
|
-
matchResult = 3;
|
|
408
|
-
acc_1 = copyOfStruct.fields[0];
|
|
409
|
-
payload_4 = matchValue.fields[0];
|
|
410
|
-
break;
|
|
411
|
-
}
|
|
412
|
-
case 2: {
|
|
413
|
-
matchResult = 4;
|
|
414
|
-
acc_2 = copyOfStruct.fields[0];
|
|
415
|
-
payload_5 = matchValue.fields[0];
|
|
416
|
-
break;
|
|
417
|
-
}
|
|
418
|
-
case 3: {
|
|
419
|
-
matchResult = 5;
|
|
420
|
-
acc_3 = copyOfStruct.fields[0];
|
|
421
|
-
break;
|
|
422
|
-
}
|
|
423
|
-
default: {
|
|
424
|
-
matchResult = 2;
|
|
425
|
-
acc = copyOfStruct.fields[0];
|
|
426
|
-
payload_2 = matchValue.fields[0];
|
|
427
|
-
}
|
|
428
|
-
}
|
|
429
|
-
}
|
|
430
|
-
else {
|
|
431
|
-
switch (matchValue.tag) {
|
|
432
|
-
case 1:
|
|
433
|
-
case 2:
|
|
434
|
-
case 3: {
|
|
435
|
-
matchResult = 1;
|
|
436
|
-
break;
|
|
437
|
-
}
|
|
438
|
-
default: {
|
|
439
|
-
matchResult = 0;
|
|
440
|
-
payload = matchValue.fields[0];
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
switch (matchResult) {
|
|
445
|
-
case 0: {
|
|
446
|
-
const tupledArg = [event, payload];
|
|
447
|
-
input_1 = handleImportStartedEvent(undefined, tupledArg[0], tupledArg[1]);
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
case 1: {
|
|
451
|
-
input_1 = (new FSharpResult$2(1, [new ImportError(2, [{
|
|
452
|
-
ImportId: event.Metadata.Domain.ImportId,
|
|
453
|
-
}])]));
|
|
454
|
-
break;
|
|
455
|
-
}
|
|
456
|
-
case 2: {
|
|
457
|
-
const tupledArg_1 = [event, payload_2];
|
|
458
|
-
input_1 = handleImportStartedEvent(acc, tupledArg_1[0], tupledArg_1[1]);
|
|
459
|
-
break;
|
|
460
|
-
}
|
|
461
|
-
case 3: {
|
|
462
|
-
const tupledArg_2 = [event.Metadata, payload_4];
|
|
463
|
-
input_1 = handleRowImportSucceededEvent(acc_1, tupledArg_2[0], tupledArg_2[1]);
|
|
464
|
-
break;
|
|
465
|
-
}
|
|
466
|
-
case 4: {
|
|
467
|
-
const tupledArg_3 = [event.Metadata, payload_5];
|
|
468
|
-
input_1 = handleRowImportFailedEvent(acc_2, tupledArg_3[0], tupledArg_3[1]);
|
|
469
|
-
break;
|
|
470
|
-
}
|
|
471
|
-
case 5: {
|
|
472
|
-
input_1 = handleImportCompleteEvent(acc_3, event.Metadata);
|
|
473
|
-
break;
|
|
474
|
-
}
|
|
475
|
-
default:
|
|
476
|
-
input_1 = (new FSharpResult$2(1, [error]));
|
|
477
|
-
}
|
|
478
|
-
if (input_1.tag === 1) {
|
|
479
|
-
return new FSharpResult$2(1, [input_1.fields[0]]);
|
|
480
|
-
}
|
|
481
|
-
else {
|
|
482
|
-
return new FSharpResult$2(0, [input_1.fields[0]]);
|
|
483
|
-
}
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
function handleConsistentCommand(aggregate, command) {
|
|
487
|
-
let agg_1, agg;
|
|
488
|
-
let r;
|
|
489
|
-
const input_3 = execute(aggregate, command);
|
|
490
|
-
if (input_3.tag === 1) {
|
|
491
|
-
r = (new FSharpResult$2(1, [input_3.fields[0]]));
|
|
492
|
-
}
|
|
493
|
-
else {
|
|
494
|
-
const events = input_3.fields[0];
|
|
495
|
-
const input_1 = fold(apply, new FSharpResult$2(0, [aggregate]), events);
|
|
496
|
-
if (input_1.tag === 1) {
|
|
497
|
-
r = (new FSharpResult$2(1, [input_1.fields[0]]));
|
|
498
|
-
}
|
|
499
|
-
else {
|
|
500
|
-
const updatedAggregate = input_1.fields[0];
|
|
501
|
-
r = (new FSharpResult$2(0, [(aggregate != null) ? ((updatedAggregate == null) ? (isEmpty(events) ? (new HandlerResult(1, [])) : (new HandlerResult(1, []))) : ((agg_1 = updatedAggregate, new HandlerResult(3, [agg_1, events])))) : ((updatedAggregate == null) ? (isEmpty(events) ? (new HandlerResult(1, [])) : (new HandlerResult(1, []))) : ((agg = updatedAggregate, new HandlerResult(2, [agg, events]))))]));
|
|
502
|
-
}
|
|
503
|
-
}
|
|
504
|
-
if (r.tag === 1) {
|
|
505
|
-
return new HandlerResult(0, [r.fields[0]]);
|
|
506
|
-
}
|
|
507
|
-
else {
|
|
508
|
-
return r.fields[0];
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
|
|
512
|
-
export function handle(aggregate, command) {
|
|
513
|
-
let cmd, a;
|
|
514
|
-
const matchValue = command.Metadata;
|
|
515
|
-
if (aggregate != null) {
|
|
516
|
-
if ((cmd = matchValue, (a = aggregate, equals(a.Metadata.StreamId, cmd.StreamId) && (a.Metadata.Version === cmd.Version)))) {
|
|
517
|
-
const a_1 = aggregate;
|
|
518
|
-
return handleConsistentCommand(aggregate, command);
|
|
519
|
-
}
|
|
520
|
-
else {
|
|
521
|
-
return new HandlerResult(0, [new ImportError(3, [])]);
|
|
522
|
-
}
|
|
523
|
-
}
|
|
524
|
-
else if (matchValue.Version === 0) {
|
|
525
|
-
return handleConsistentCommand(aggregate, command);
|
|
526
|
-
}
|
|
527
|
-
else {
|
|
528
|
-
return new HandlerResult(0, [new ImportError(3, [])]);
|
|
529
|
-
}
|
|
530
|
-
}
|
|
531
|
-
|