@zeeshan60/event-processor 1.0.118 → 1.0.119

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.
Files changed (42) hide show
  1. package/dist/AttachmentProcessEventHandler.d.ts +23 -0
  2. package/dist/AttachmentProcessEventHandler.d.ts.map +1 -0
  3. package/dist/AttachmentProcessEventHandler.js +138 -0
  4. package/dist/AttachmentProcessEventHandler.js.map +1 -0
  5. package/dist/AttachmentProcessEvents.d.ts +236 -0
  6. package/dist/AttachmentProcessEvents.d.ts.map +1 -0
  7. package/dist/AttachmentProcessEvents.js +236 -0
  8. package/dist/AttachmentProcessEvents.js.map +1 -0
  9. package/dist/EventProcessorSDK.d.ts +8 -1
  10. package/dist/EventProcessorSDK.d.ts.map +1 -1
  11. package/dist/EventProcessorSDK.js +15 -0
  12. package/dist/EventProcessorSDK.js.map +1 -1
  13. package/dist/client/controllers/ExpenseController.d.ts +24 -0
  14. package/dist/client/controllers/ExpenseController.d.ts.map +1 -1
  15. package/dist/client/controllers/ExpenseController.js +108 -0
  16. package/dist/client/controllers/ExpenseController.js.map +1 -1
  17. package/dist/common/DomainEvents.d.ts +2 -0
  18. package/dist/common/DomainEvents.d.ts.map +1 -1
  19. package/dist/common/EventTypes.d.ts +8 -0
  20. package/dist/common/EventTypes.d.ts.map +1 -1
  21. package/dist/common/EventTypes.js +9 -0
  22. package/dist/common/EventTypes.js.map +1 -1
  23. package/dist/converters/eventConverter.d.ts.map +1 -1
  24. package/dist/converters/eventConverter.js +31 -0
  25. package/dist/converters/eventConverter.js.map +1 -1
  26. package/dist/events.d.ts +4 -0
  27. package/dist/events.d.ts.map +1 -1
  28. package/dist/events.js +6 -1
  29. package/dist/events.js.map +1 -1
  30. package/dist/index.d.ts +2 -2
  31. package/dist/index.d.ts.map +1 -1
  32. package/dist/index.js +3 -2
  33. package/dist/index.js.map +1 -1
  34. package/dist/store/AttachmentProcessEventStore.d.ts +5 -0
  35. package/dist/store/AttachmentProcessEventStore.d.ts.map +1 -0
  36. package/dist/store/AttachmentProcessEventStore.js +3 -0
  37. package/dist/store/AttachmentProcessEventStore.js.map +1 -0
  38. package/dist/store/AttachmentProcessModelStore.d.ts +11 -0
  39. package/dist/store/AttachmentProcessModelStore.d.ts.map +1 -0
  40. package/dist/store/AttachmentProcessModelStore.js +5 -0
  41. package/dist/store/AttachmentProcessModelStore.js.map +1 -0
  42. package/package.json +1 -1
@@ -0,0 +1,23 @@
1
+ import { AttachmentProcessModel } from "./AttachmentProcessEvents";
2
+ import { AttachmentProcessEvent } from "./common/DomainEvents";
3
+ import { BaseEventHandler } from "./BaseEventHandler";
4
+ import { ModelChangeEmitter } from "./ModelChangeEmitter";
5
+ import { AttachmentProcessEventStore } from "./store/AttachmentProcessEventStore";
6
+ import { AttachmentProcessModelStore } from "./store/AttachmentProcessModelStore";
7
+ import { ClientType } from "./EventProcessorSDK";
8
+ export declare class AttachmentProcessEventHandler extends BaseEventHandler<AttachmentProcessEvent> {
9
+ private modelStore;
10
+ private attachmentProcessEventStore;
11
+ constructor(modelStore: AttachmentProcessModelStore, attachmentProcessEventStore: AttachmentProcessEventStore, isClient: boolean, clientType: ClientType, modelChangeEmitter?: ModelChangeEmitter);
12
+ getModelStore(): AttachmentProcessModelStore;
13
+ getEventStore(): AttachmentProcessEventStore;
14
+ handleEvent(event: AttachmentProcessEvent): Promise<AttachmentProcessModel>;
15
+ private handleStarted;
16
+ private handleUploaded;
17
+ private handleAnalyzed;
18
+ private handleCreatingExpense;
19
+ private handleCreatingExpenses;
20
+ private handleCompleted;
21
+ private handleFailed;
22
+ }
23
+ //# sourceMappingURL=AttachmentProcessEventHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttachmentProcessEventHandler.d.ts","sourceRoot":"","sources":["../src/AttachmentProcessEventHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EAQvB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAClF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,qBAAa,6BAA8B,SAAQ,gBAAgB,CAAC,sBAAsB,CAAC;IAEvF,OAAO,CAAC,UAAU;IAClB,OAAO,CAAC,2BAA2B;gBAD3B,UAAU,EAAE,2BAA2B,EACvC,2BAA2B,EAAE,2BAA2B,EAChE,QAAQ,EAAE,OAAO,EACjB,UAAU,EAAE,UAAU,EACtB,kBAAkB,CAAC,EAAE,kBAAkB;IAKlC,aAAa,IAAI,2BAA2B;IAI5C,aAAa,IAAI,2BAA2B;IAI7C,WAAW,CACf,KAAK,EAAE,sBAAsB,GAC5B,OAAO,CAAC,sBAAsB,CAAC;YA6DpB,aAAa;YAkBb,cAAc;YAkBd,cAAc;YAkBd,qBAAqB;YAkBrB,sBAAsB;YAkBtB,eAAe;YAkBf,YAAY;CAiB3B"}
@@ -0,0 +1,138 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AttachmentProcessEventHandler = void 0;
4
+ const BaseEventHandler_1 = require("./BaseEventHandler");
5
+ const EventTypes_1 = require("./common/EventTypes");
6
+ class AttachmentProcessEventHandler extends BaseEventHandler_1.BaseEventHandler {
7
+ constructor(modelStore, attachmentProcessEventStore, isClient, clientType, modelChangeEmitter) {
8
+ super(isClient, clientType, modelChangeEmitter);
9
+ this.modelStore = modelStore;
10
+ this.attachmentProcessEventStore = attachmentProcessEventStore;
11
+ }
12
+ getModelStore() {
13
+ return this.modelStore;
14
+ }
15
+ getEventStore() {
16
+ return this.attachmentProcessEventStore;
17
+ }
18
+ async handleEvent(event) {
19
+ const eventType = event.eventType;
20
+ const existingModel = await this.modelStore.getByStreamIdWhereDeletedIsFalse(event.streamId);
21
+ if (this.shouldSkipSave(existingModel, event)) {
22
+ return existingModel;
23
+ }
24
+ let updatedModel;
25
+ switch (eventType) {
26
+ case EventTypes_1.EventType.ATTACHMENT_PROCESS_STARTED:
27
+ updatedModel = await this.handleStarted(event, existingModel);
28
+ break;
29
+ case EventTypes_1.EventType.ATTACHMENT_PROCESS_UPLOADED:
30
+ updatedModel = await this.handleUploaded(event, existingModel);
31
+ break;
32
+ case EventTypes_1.EventType.ATTACHMENT_PROCESS_ANALYZED:
33
+ updatedModel = await this.handleAnalyzed(event, existingModel);
34
+ break;
35
+ case EventTypes_1.EventType.ATTACHMENT_PROCESS_CREATING_EXPENSE:
36
+ updatedModel = await this.handleCreatingExpense(event, existingModel);
37
+ break;
38
+ case EventTypes_1.EventType.ATTACHMENT_PROCESS_CREATING_EXPENSES:
39
+ updatedModel = await this.handleCreatingExpenses(event, existingModel);
40
+ break;
41
+ case EventTypes_1.EventType.ATTACHMENT_PROCESS_COMPLETED:
42
+ updatedModel = await this.handleCompleted(event, existingModel);
43
+ break;
44
+ case EventTypes_1.EventType.ATTACHMENT_PROCESS_FAILED:
45
+ updatedModel = await this.handleFailed(event, existingModel);
46
+ break;
47
+ default:
48
+ throw new Error(`Unknown attachment process event type: ${eventType}`);
49
+ }
50
+ return updatedModel;
51
+ }
52
+ async handleStarted(event, existingModel) {
53
+ console.log(`[AttachmentProcessStarted] clientType=${this.clientType}, isClient=${this.isClient}, streamId=${event.streamId}, accountId=${event.accountId}, userId=${event.userId}`);
54
+ const updatedModel = event.apply(existingModel);
55
+ if (this.isNotAIClient()) {
56
+ await this.modelStore.save(updatedModel);
57
+ }
58
+ if (this.isClient) {
59
+ await this.attachmentProcessEventStore.addEvent(event);
60
+ this.modelChangeEmitter?.emit(event.eventMainType);
61
+ }
62
+ return updatedModel;
63
+ }
64
+ async handleUploaded(event, existingModel) {
65
+ console.log(`[AttachmentProcessUploaded] clientType=${this.clientType}, isClient=${this.isClient}, streamId=${event.streamId}, userId=${event.userId}`);
66
+ const updatedModel = event.apply(existingModel);
67
+ if (this.isNotAIClient()) {
68
+ await this.modelStore.save(updatedModel);
69
+ }
70
+ if (this.isClient) {
71
+ await this.attachmentProcessEventStore.addEvent(event);
72
+ this.modelChangeEmitter?.emit(event.eventMainType);
73
+ }
74
+ return updatedModel;
75
+ }
76
+ async handleAnalyzed(event, existingModel) {
77
+ console.log(`[AttachmentProcessAnalyzed] clientType=${this.clientType}, isClient=${this.isClient}, streamId=${event.streamId}, userId=${event.userId}`);
78
+ const updatedModel = event.apply(existingModel);
79
+ if (this.isNotAIClient()) {
80
+ await this.modelStore.save(updatedModel);
81
+ }
82
+ if (this.isClient) {
83
+ await this.attachmentProcessEventStore.addEvent(event);
84
+ this.modelChangeEmitter?.emit(event.eventMainType);
85
+ }
86
+ return updatedModel;
87
+ }
88
+ async handleCreatingExpense(event, existingModel) {
89
+ console.log(`[AttachmentProcessCreatingExpense] clientType=${this.clientType}, isClient=${this.isClient}, streamId=${event.streamId}, userId=${event.userId}`);
90
+ const updatedModel = event.apply(existingModel);
91
+ if (this.isNotAIClient()) {
92
+ await this.modelStore.save(updatedModel);
93
+ }
94
+ if (this.isClient) {
95
+ await this.attachmentProcessEventStore.addEvent(event);
96
+ this.modelChangeEmitter?.emit(event.eventMainType);
97
+ }
98
+ return updatedModel;
99
+ }
100
+ async handleCreatingExpenses(event, existingModel) {
101
+ console.log(`[AttachmentProcessCreatingExpenses] clientType=${this.clientType}, isClient=${this.isClient}, streamId=${event.streamId}, userId=${event.userId}`);
102
+ const updatedModel = event.apply(existingModel);
103
+ if (this.isNotAIClient()) {
104
+ await this.modelStore.save(updatedModel);
105
+ }
106
+ if (this.isClient) {
107
+ await this.attachmentProcessEventStore.addEvent(event);
108
+ this.modelChangeEmitter?.emit(event.eventMainType);
109
+ }
110
+ return updatedModel;
111
+ }
112
+ async handleCompleted(event, existingModel) {
113
+ console.log(`[AttachmentProcessCompleted] clientType=${this.clientType}, isClient=${this.isClient}, streamId=${event.streamId}, userId=${event.userId}`);
114
+ const updatedModel = event.apply(existingModel);
115
+ if (this.isNotAIClient()) {
116
+ await this.modelStore.save(updatedModel);
117
+ }
118
+ if (this.isClient) {
119
+ await this.attachmentProcessEventStore.addEvent(event);
120
+ this.modelChangeEmitter?.emit(event.eventMainType);
121
+ }
122
+ return updatedModel;
123
+ }
124
+ async handleFailed(event, existingModel) {
125
+ console.log(`[AttachmentProcessFailed] clientType=${this.clientType}, isClient=${this.isClient}, streamId=${event.streamId}, userId=${event.userId}, error=${event.errorMessage}`);
126
+ const updatedModel = event.apply(existingModel);
127
+ if (this.isNotAIClient()) {
128
+ await this.modelStore.save(updatedModel);
129
+ }
130
+ if (this.isClient) {
131
+ await this.attachmentProcessEventStore.addEvent(event);
132
+ this.modelChangeEmitter?.emit(event.eventMainType);
133
+ }
134
+ return updatedModel;
135
+ }
136
+ }
137
+ exports.AttachmentProcessEventHandler = AttachmentProcessEventHandler;
138
+ //# sourceMappingURL=AttachmentProcessEventHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttachmentProcessEventHandler.js","sourceRoot":"","sources":["../src/AttachmentProcessEventHandler.ts"],"names":[],"mappings":";;;AAWA,yDAAsD;AAEtD,oDAAgD;AAKhD,MAAa,6BAA8B,SAAQ,mCAAwC;IACzF,YACU,UAAuC,EACvC,2BAAwD,EAChE,QAAiB,EACjB,UAAsB,EACtB,kBAAuC;QAEvC,KAAK,CAAC,QAAQ,EAAE,UAAU,EAAE,kBAAkB,CAAC,CAAC;QANxC,eAAU,GAAV,UAAU,CAA6B;QACvC,gCAA2B,GAA3B,2BAA2B,CAA6B;IAMlE,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,UAAU,CAAC;IACzB,CAAC;IAEM,aAAa;QAClB,OAAO,IAAI,CAAC,2BAA2B,CAAC;IAC1C,CAAC;IAED,KAAK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AC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,CAAC,2BAA2B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACvD,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;IAEO,KAAK,CAAC,YAAY,CACxB,KAA8B,EAC9B,aAAiD;QAEjD,OAAO,CAAC,GAAG,CACT,wCAAwC,IAAI,CAAC,UAAU,cAAc,IAAI,CAAC,QAAQ,cAAc,KAAK,CAAC,QAAQ,YAAY,KAAK,CAAC,MAAM,WAAW,KAAK,CAAC,YAAY,EAAE,CACtK,CAAC;QACF,MAAM,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,aAAa,CAA2B,CAAC;QAC1E,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;YACzB,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3C,CAAC;QACD,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClB,MAAM,IAAI,CAAC,2BAA2B,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;YACvD,IAAI,CAAC,kBAAkB,EAAE,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,YAAY,CAAC;IACtB,CAAC;CACF;AA/MD,sEA+MC"}
@@ -0,0 +1,236 @@
1
+ import { AttachmentProcessEvent } from "./common/DomainEvents";
2
+ import { Model, ModelProps } from "./common/Model";
3
+ import { TransactionType } from "./contracts/expenses";
4
+ export declare const AttachmentProcessStatus: {
5
+ readonly STARTED: "STARTED";
6
+ readonly UPLOADED: "UPLOADED";
7
+ readonly ANALYZED: "ANALYZED";
8
+ readonly CREATING_EXPENSE: "CREATING_EXPENSE";
9
+ readonly CREATING_EXPENSES: "CREATING_EXPENSES";
10
+ readonly COMPLETED: "COMPLETED";
11
+ readonly FAILED: "FAILED";
12
+ };
13
+ export type AttachmentProcessStatusType = (typeof AttachmentProcessStatus)[keyof typeof AttachmentProcessStatus];
14
+ export interface ParsedReceiptData {
15
+ merchantName?: string;
16
+ totalAmount?: number;
17
+ currency?: string;
18
+ date?: number;
19
+ category?: string;
20
+ items?: ParsedReceiptItem[];
21
+ }
22
+ export interface ParsedReceiptItem {
23
+ description: string;
24
+ amount: number;
25
+ currency?: string;
26
+ date?: number;
27
+ category?: string;
28
+ transactionType?: TransactionType;
29
+ }
30
+ export interface AttachmentProcessModelProps extends Omit<ModelProps, "synced"> {
31
+ accountId: string;
32
+ tempLocalUrl?: string;
33
+ firestoreUrl?: string;
34
+ status: AttachmentProcessStatusType;
35
+ ocrText?: string;
36
+ parsedData?: ParsedReceiptData;
37
+ expenseIds?: string[];
38
+ errorMessage?: string;
39
+ errorCode?: string;
40
+ createdAt: number;
41
+ synced?: boolean;
42
+ }
43
+ export declare class AttachmentProcessModel implements AttachmentProcessModelProps {
44
+ userId: string;
45
+ streamId: string;
46
+ version: number;
47
+ deleted: boolean;
48
+ accountId: string;
49
+ tempLocalUrl?: string;
50
+ firestoreUrl?: string;
51
+ status: AttachmentProcessStatusType;
52
+ ocrText?: string;
53
+ parsedData?: ParsedReceiptData;
54
+ expenseIds?: string[];
55
+ errorMessage?: string;
56
+ errorCode?: string;
57
+ createdAt: number;
58
+ updatedAt: number;
59
+ synced: boolean;
60
+ constructor(props: AttachmentProcessModelProps);
61
+ }
62
+ export interface AttachmentProcessStartedProps {
63
+ eventId: string;
64
+ userId: string;
65
+ accountId: string;
66
+ tempLocalUrl: string;
67
+ createdAt: number;
68
+ createdBy: string;
69
+ streamId: string;
70
+ version: number;
71
+ systemGenerated: boolean;
72
+ }
73
+ export declare class AttachmentProcessStarted implements AttachmentProcessEvent {
74
+ readonly eventMainType: "attachmentProcess";
75
+ readonly eventType: "AttachmentProcessStarted";
76
+ eventId: string;
77
+ userId: string;
78
+ accountId: string;
79
+ tempLocalUrl: string;
80
+ createdAt: number;
81
+ createdBy: string;
82
+ streamId: string;
83
+ version: number;
84
+ systemGenerated: boolean;
85
+ constructor(props: AttachmentProcessStartedProps);
86
+ apply(_existing?: Model): AttachmentProcessModel;
87
+ }
88
+ export interface AttachmentProcessUploadedProps {
89
+ eventId: string;
90
+ userId: string;
91
+ firestoreUrl: string;
92
+ createdAt: number;
93
+ createdBy: string;
94
+ streamId: string;
95
+ version: number;
96
+ systemGenerated: boolean;
97
+ }
98
+ export declare class AttachmentProcessUploaded implements AttachmentProcessEvent {
99
+ readonly eventMainType: "attachmentProcess";
100
+ readonly eventType: "AttachmentProcessUploaded";
101
+ eventId: string;
102
+ userId: string;
103
+ firestoreUrl: string;
104
+ createdAt: number;
105
+ createdBy: string;
106
+ streamId: string;
107
+ version: number;
108
+ systemGenerated: boolean;
109
+ constructor(props: AttachmentProcessUploadedProps);
110
+ apply(existing?: Model): AttachmentProcessModel;
111
+ }
112
+ export interface AttachmentProcessAnalyzedProps {
113
+ eventId: string;
114
+ userId: string;
115
+ ocrText: string;
116
+ parsedData?: ParsedReceiptData;
117
+ createdAt: number;
118
+ createdBy: string;
119
+ streamId: string;
120
+ version: number;
121
+ systemGenerated: boolean;
122
+ }
123
+ export declare class AttachmentProcessAnalyzed implements AttachmentProcessEvent {
124
+ readonly eventMainType: "attachmentProcess";
125
+ readonly eventType: "AttachmentProcessAnalyzed";
126
+ eventId: string;
127
+ userId: string;
128
+ ocrText: string;
129
+ parsedData?: ParsedReceiptData;
130
+ createdAt: number;
131
+ createdBy: string;
132
+ streamId: string;
133
+ version: number;
134
+ systemGenerated: boolean;
135
+ constructor(props: AttachmentProcessAnalyzedProps);
136
+ apply(existing?: Model): AttachmentProcessModel;
137
+ }
138
+ export interface AttachmentProcessCreatingExpenseProps {
139
+ eventId: string;
140
+ userId: string;
141
+ expenseId: string;
142
+ createdAt: number;
143
+ createdBy: string;
144
+ streamId: string;
145
+ version: number;
146
+ systemGenerated: boolean;
147
+ }
148
+ export declare class AttachmentProcessCreatingExpense implements AttachmentProcessEvent {
149
+ readonly eventMainType: "attachmentProcess";
150
+ readonly eventType: "AttachmentProcessCreatingExpense";
151
+ eventId: string;
152
+ userId: string;
153
+ expenseId: string;
154
+ createdAt: number;
155
+ createdBy: string;
156
+ streamId: string;
157
+ version: number;
158
+ systemGenerated: boolean;
159
+ constructor(props: AttachmentProcessCreatingExpenseProps);
160
+ apply(existing?: Model): AttachmentProcessModel;
161
+ }
162
+ export interface AttachmentProcessCreatingExpensesProps {
163
+ eventId: string;
164
+ userId: string;
165
+ expenseIds: string[];
166
+ createdAt: number;
167
+ createdBy: string;
168
+ streamId: string;
169
+ version: number;
170
+ systemGenerated: boolean;
171
+ }
172
+ export declare class AttachmentProcessCreatingExpenses implements AttachmentProcessEvent {
173
+ readonly eventMainType: "attachmentProcess";
174
+ readonly eventType: "AttachmentProcessCreatingExpenses";
175
+ eventId: string;
176
+ userId: string;
177
+ expenseIds: string[];
178
+ createdAt: number;
179
+ createdBy: string;
180
+ streamId: string;
181
+ version: number;
182
+ systemGenerated: boolean;
183
+ constructor(props: AttachmentProcessCreatingExpensesProps);
184
+ apply(existing?: Model): AttachmentProcessModel;
185
+ }
186
+ export interface AttachmentProcessCompletedProps {
187
+ eventId: string;
188
+ userId: string;
189
+ expenseIds: string[];
190
+ createdAt: number;
191
+ createdBy: string;
192
+ streamId: string;
193
+ version: number;
194
+ systemGenerated: boolean;
195
+ }
196
+ export declare class AttachmentProcessCompleted implements AttachmentProcessEvent {
197
+ readonly eventMainType: "attachmentProcess";
198
+ readonly eventType: "AttachmentProcessCompleted";
199
+ eventId: string;
200
+ userId: string;
201
+ expenseIds: string[];
202
+ createdAt: number;
203
+ createdBy: string;
204
+ streamId: string;
205
+ version: number;
206
+ systemGenerated: boolean;
207
+ constructor(props: AttachmentProcessCompletedProps);
208
+ apply(existing?: Model): AttachmentProcessModel;
209
+ }
210
+ export interface AttachmentProcessFailedProps {
211
+ eventId: string;
212
+ userId: string;
213
+ errorMessage: string;
214
+ errorCode?: string;
215
+ createdAt: number;
216
+ createdBy: string;
217
+ streamId: string;
218
+ version: number;
219
+ systemGenerated: boolean;
220
+ }
221
+ export declare class AttachmentProcessFailed implements AttachmentProcessEvent {
222
+ readonly eventMainType: "attachmentProcess";
223
+ readonly eventType: "AttachmentProcessFailed";
224
+ eventId: string;
225
+ userId: string;
226
+ errorMessage: string;
227
+ errorCode?: string;
228
+ createdAt: number;
229
+ createdBy: string;
230
+ streamId: string;
231
+ version: number;
232
+ systemGenerated: boolean;
233
+ constructor(props: AttachmentProcessFailedProps);
234
+ apply(existing?: Model): AttachmentProcessModel;
235
+ }
236
+ //# sourceMappingURL=AttachmentProcessEvents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AttachmentProcessEvents.d.ts","sourceRoot":"","sources":["../src/AttachmentProcessEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEnD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,eAAO,MAAM,uBAAuB;;;;;;;;CAQO,CAAC;AAE5C,MAAM,MAAM,2BAA2B,GACrC,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,OAAO,uBAAuB,CAAC,CAAC;AAEzE,MAAM,WAAW,iBAAiB;IAChC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,iBAAiB,EAAE,CAAC;CAC7B;AAED,MAAM,WAAW,iBAAiB;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,C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,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,OAAO,CAAC;gBAEpB,KAAK,EAAE,4BAA4B;IAY/C,KAAK,CAAC,QAAQ,CAAC,EAAE,KAAK,GAAG,sBAAsB;CAchD"}
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AttachmentProcessFailed = exports.AttachmentProcessCompleted = exports.AttachmentProcessCreatingExpenses = exports.AttachmentProcessCreatingExpense = exports.AttachmentProcessAnalyzed = exports.AttachmentProcessUploaded = exports.AttachmentProcessStarted = exports.AttachmentProcessModel = exports.AttachmentProcessStatus = void 0;
4
+ const EventTypes_1 = require("./common/EventTypes");
5
+ exports.AttachmentProcessStatus = {
6
+ STARTED: "STARTED",
7
+ UPLOADED: "UPLOADED",
8
+ ANALYZED: "ANALYZED",
9
+ CREATING_EXPENSE: "CREATING_EXPENSE",
10
+ CREATING_EXPENSES: "CREATING_EXPENSES",
11
+ COMPLETED: "COMPLETED",
12
+ FAILED: "FAILED",
13
+ };
14
+ class AttachmentProcessModel {
15
+ constructor(props) {
16
+ this.userId = props.userId;
17
+ this.streamId = props.streamId;
18
+ this.version = props.version;
19
+ this.deleted = props.deleted;
20
+ this.accountId = props.accountId;
21
+ this.tempLocalUrl = props.tempLocalUrl;
22
+ this.firestoreUrl = props.firestoreUrl;
23
+ this.status = props.status;
24
+ this.ocrText = props.ocrText;
25
+ this.parsedData = props.parsedData;
26
+ this.expenseIds = props.expenseIds;
27
+ this.errorMessage = props.errorMessage;
28
+ this.errorCode = props.errorCode;
29
+ this.createdAt = props.createdAt;
30
+ this.updatedAt = props.updatedAt;
31
+ this.synced = props.synced ?? false;
32
+ }
33
+ }
34
+ exports.AttachmentProcessModel = AttachmentProcessModel;
35
+ class AttachmentProcessStarted {
36
+ constructor(props) {
37
+ this.eventMainType = EventTypes_1.EventMainType.ATTACHMENT_PROCESS;
38
+ this.eventType = EventTypes_1.EventType.ATTACHMENT_PROCESS_STARTED;
39
+ this.eventId = props.eventId;
40
+ this.userId = props.userId;
41
+ this.accountId = props.accountId;
42
+ this.tempLocalUrl = props.tempLocalUrl;
43
+ this.createdAt = props.createdAt;
44
+ this.createdBy = props.createdBy;
45
+ this.streamId = props.streamId;
46
+ this.version = props.version;
47
+ this.systemGenerated = props.systemGenerated;
48
+ }
49
+ apply(_existing) {
50
+ return new AttachmentProcessModel({
51
+ userId: this.userId,
52
+ streamId: this.streamId,
53
+ version: this.version,
54
+ deleted: false,
55
+ accountId: this.accountId,
56
+ tempLocalUrl: this.tempLocalUrl,
57
+ status: exports.AttachmentProcessStatus.STARTED,
58
+ createdAt: this.createdAt,
59
+ updatedAt: this.createdAt,
60
+ });
61
+ }
62
+ }
63
+ exports.AttachmentProcessStarted = AttachmentProcessStarted;
64
+ class AttachmentProcessUploaded {
65
+ constructor(props) {
66
+ this.eventMainType = EventTypes_1.EventMainType.ATTACHMENT_PROCESS;
67
+ this.eventType = EventTypes_1.EventType.ATTACHMENT_PROCESS_UPLOADED;
68
+ this.eventId = props.eventId;
69
+ this.userId = props.userId;
70
+ this.firestoreUrl = props.firestoreUrl;
71
+ this.createdAt = props.createdAt;
72
+ this.createdBy = props.createdBy;
73
+ this.streamId = props.streamId;
74
+ this.version = props.version;
75
+ this.systemGenerated = props.systemGenerated;
76
+ }
77
+ apply(existing) {
78
+ if (!existing) {
79
+ throw new Error("AttachmentProcessModel is required for uploaded event");
80
+ }
81
+ const existingModel = existing;
82
+ return new AttachmentProcessModel({
83
+ ...existingModel,
84
+ firestoreUrl: this.firestoreUrl,
85
+ status: exports.AttachmentProcessStatus.UPLOADED,
86
+ version: this.version,
87
+ updatedAt: this.createdAt,
88
+ });
89
+ }
90
+ }
91
+ exports.AttachmentProcessUploaded = AttachmentProcessUploaded;
92
+ class AttachmentProcessAnalyzed {
93
+ constructor(props) {
94
+ this.eventMainType = EventTypes_1.EventMainType.ATTACHMENT_PROCESS;
95
+ this.eventType = EventTypes_1.EventType.ATTACHMENT_PROCESS_ANALYZED;
96
+ this.eventId = props.eventId;
97
+ this.userId = props.userId;
98
+ this.ocrText = props.ocrText;
99
+ this.parsedData = props.parsedData;
100
+ this.createdAt = props.createdAt;
101
+ this.createdBy = props.createdBy;
102
+ this.streamId = props.streamId;
103
+ this.version = props.version;
104
+ this.systemGenerated = props.systemGenerated;
105
+ }
106
+ apply(existing) {
107
+ if (!existing) {
108
+ throw new Error("AttachmentProcessModel is required for analyzed event");
109
+ }
110
+ const existingModel = existing;
111
+ return new AttachmentProcessModel({
112
+ ...existingModel,
113
+ ocrText: this.ocrText,
114
+ parsedData: this.parsedData,
115
+ status: exports.AttachmentProcessStatus.ANALYZED,
116
+ version: this.version,
117
+ updatedAt: this.createdAt,
118
+ });
119
+ }
120
+ }
121
+ exports.AttachmentProcessAnalyzed = AttachmentProcessAnalyzed;
122
+ class AttachmentProcessCreatingExpense {
123
+ constructor(props) {
124
+ this.eventMainType = EventTypes_1.EventMainType.ATTACHMENT_PROCESS;
125
+ this.eventType = EventTypes_1.EventType.ATTACHMENT_PROCESS_CREATING_EXPENSE;
126
+ this.eventId = props.eventId;
127
+ this.userId = props.userId;
128
+ this.expenseId = props.expenseId;
129
+ this.createdAt = props.createdAt;
130
+ this.createdBy = props.createdBy;
131
+ this.streamId = props.streamId;
132
+ this.version = props.version;
133
+ this.systemGenerated = props.systemGenerated;
134
+ }
135
+ apply(existing) {
136
+ if (!existing) {
137
+ throw new Error("AttachmentProcessModel is required for creating expense event");
138
+ }
139
+ const existingModel = existing;
140
+ return new AttachmentProcessModel({
141
+ ...existingModel,
142
+ expenseIds: [this.expenseId],
143
+ status: exports.AttachmentProcessStatus.CREATING_EXPENSE,
144
+ version: this.version,
145
+ updatedAt: this.createdAt,
146
+ });
147
+ }
148
+ }
149
+ exports.AttachmentProcessCreatingExpense = AttachmentProcessCreatingExpense;
150
+ class AttachmentProcessCreatingExpenses {
151
+ constructor(props) {
152
+ this.eventMainType = EventTypes_1.EventMainType.ATTACHMENT_PROCESS;
153
+ this.eventType = EventTypes_1.EventType.ATTACHMENT_PROCESS_CREATING_EXPENSES;
154
+ this.eventId = props.eventId;
155
+ this.userId = props.userId;
156
+ this.expenseIds = props.expenseIds;
157
+ this.createdAt = props.createdAt;
158
+ this.createdBy = props.createdBy;
159
+ this.streamId = props.streamId;
160
+ this.version = props.version;
161
+ this.systemGenerated = props.systemGenerated;
162
+ }
163
+ apply(existing) {
164
+ if (!existing) {
165
+ throw new Error("AttachmentProcessModel is required for creating expenses event");
166
+ }
167
+ const existingModel = existing;
168
+ return new AttachmentProcessModel({
169
+ ...existingModel,
170
+ expenseIds: this.expenseIds,
171
+ status: exports.AttachmentProcessStatus.CREATING_EXPENSES,
172
+ version: this.version,
173
+ updatedAt: this.createdAt,
174
+ });
175
+ }
176
+ }
177
+ exports.AttachmentProcessCreatingExpenses = AttachmentProcessCreatingExpenses;
178
+ class AttachmentProcessCompleted {
179
+ constructor(props) {
180
+ this.eventMainType = EventTypes_1.EventMainType.ATTACHMENT_PROCESS;
181
+ this.eventType = EventTypes_1.EventType.ATTACHMENT_PROCESS_COMPLETED;
182
+ this.eventId = props.eventId;
183
+ this.userId = props.userId;
184
+ this.expenseIds = props.expenseIds;
185
+ this.createdAt = props.createdAt;
186
+ this.createdBy = props.createdBy;
187
+ this.streamId = props.streamId;
188
+ this.version = props.version;
189
+ this.systemGenerated = props.systemGenerated;
190
+ }
191
+ apply(existing) {
192
+ if (!existing) {
193
+ throw new Error("AttachmentProcessModel is required for completed event");
194
+ }
195
+ const existingModel = existing;
196
+ return new AttachmentProcessModel({
197
+ ...existingModel,
198
+ expenseIds: this.expenseIds,
199
+ status: exports.AttachmentProcessStatus.COMPLETED,
200
+ version: this.version,
201
+ updatedAt: this.createdAt,
202
+ });
203
+ }
204
+ }
205
+ exports.AttachmentProcessCompleted = AttachmentProcessCompleted;
206
+ class AttachmentProcessFailed {
207
+ constructor(props) {
208
+ this.eventMainType = EventTypes_1.EventMainType.ATTACHMENT_PROCESS;
209
+ this.eventType = EventTypes_1.EventType.ATTACHMENT_PROCESS_FAILED;
210
+ this.eventId = props.eventId;
211
+ this.userId = props.userId;
212
+ this.errorMessage = props.errorMessage;
213
+ this.errorCode = props.errorCode;
214
+ this.createdAt = props.createdAt;
215
+ this.createdBy = props.createdBy;
216
+ this.streamId = props.streamId;
217
+ this.version = props.version;
218
+ this.systemGenerated = props.systemGenerated;
219
+ }
220
+ apply(existing) {
221
+ if (!existing) {
222
+ throw new Error("AttachmentProcessModel is required for failed event");
223
+ }
224
+ const existingModel = existing;
225
+ return new AttachmentProcessModel({
226
+ ...existingModel,
227
+ errorMessage: this.errorMessage,
228
+ errorCode: this.errorCode,
229
+ status: exports.AttachmentProcessStatus.FAILED,
230
+ version: this.version,
231
+ updatedAt: this.createdAt,
232
+ });
233
+ }
234
+ }
235
+ exports.AttachmentProcessFailed = AttachmentProcessFailed;
236
+ //# sourceMappingURL=AttachmentProcessEvents.js.map