@monorise/core 0.0.1-dev.0
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/configs/service.config.d.ts +5 -0
- package/dist/configs/service.config.d.ts.map +1 -0
- package/dist/configs/service.config.js +5 -0
- package/dist/configs/service.config.js.map +1 -0
- package/dist/constants/table.d.ts +4 -0
- package/dist/constants/table.d.ts.map +1 -0
- package/dist/constants/table.js +4 -0
- package/dist/constants/table.js.map +1 -0
- package/dist/controllers/entity/create-entity.controller.d.ts +8 -0
- package/dist/controllers/entity/create-entity.controller.d.ts.map +1 -0
- package/dist/controllers/entity/create-entity.controller.js +44 -0
- package/dist/controllers/entity/create-entity.controller.js.map +1 -0
- package/dist/controllers/entity/delete-entity.controller.d.ts +8 -0
- package/dist/controllers/entity/delete-entity.controller.d.ts.map +1 -0
- package/dist/controllers/entity/delete-entity.controller.js +29 -0
- package/dist/controllers/entity/delete-entity.controller.js.map +1 -0
- package/dist/controllers/entity/get-entity.controller.d.ts +8 -0
- package/dist/controllers/entity/get-entity.controller.d.ts.map +1 -0
- package/dist/controllers/entity/get-entity.controller.js +24 -0
- package/dist/controllers/entity/get-entity.controller.js.map +1 -0
- package/dist/controllers/entity/list-entities.controller.d.ts +8 -0
- package/dist/controllers/entity/list-entities.controller.d.ts.map +1 -0
- package/dist/controllers/entity/list-entities.controller.js +56 -0
- package/dist/controllers/entity/list-entities.controller.js.map +1 -0
- package/dist/controllers/entity/update-entity.controller.d.ts +8 -0
- package/dist/controllers/entity/update-entity.controller.d.ts.map +1 -0
- package/dist/controllers/entity/update-entity.controller.js +45 -0
- package/dist/controllers/entity/update-entity.controller.js.map +1 -0
- package/dist/controllers/entity/upsert-entity.controller.d.ts +12 -0
- package/dist/controllers/entity/upsert-entity.controller.d.ts.map +1 -0
- package/dist/controllers/entity/upsert-entity.controller.js +74 -0
- package/dist/controllers/entity/upsert-entity.controller.js.map +1 -0
- package/dist/controllers/mutual/create-mutual.controller.d.ts +8 -0
- package/dist/controllers/mutual/create-mutual.controller.d.ts.map +1 -0
- package/dist/controllers/mutual/create-mutual.controller.js +49 -0
- package/dist/controllers/mutual/create-mutual.controller.js.map +1 -0
- package/dist/controllers/mutual/delete-mutual.controller.d.ts +8 -0
- package/dist/controllers/mutual/delete-mutual.controller.d.ts.map +1 -0
- package/dist/controllers/mutual/delete-mutual.controller.js +31 -0
- package/dist/controllers/mutual/delete-mutual.controller.js.map +1 -0
- package/dist/controllers/mutual/get-mutual.controller.d.ts +8 -0
- package/dist/controllers/mutual/get-mutual.controller.d.ts.map +1 -0
- package/dist/controllers/mutual/get-mutual.controller.js +24 -0
- package/dist/controllers/mutual/get-mutual.controller.js.map +1 -0
- package/dist/controllers/mutual/list-entities-by-entity.controller.d.ts +8 -0
- package/dist/controllers/mutual/list-entities-by-entity.controller.d.ts.map +1 -0
- package/dist/controllers/mutual/list-entities-by-entity.controller.js +56 -0
- package/dist/controllers/mutual/list-entities-by-entity.controller.js.map +1 -0
- package/dist/controllers/mutual/update-mutual.controller.d.ts +8 -0
- package/dist/controllers/mutual/update-mutual.controller.d.ts.map +1 -0
- package/dist/controllers/mutual/update-mutual.controller.js +40 -0
- package/dist/controllers/mutual/update-mutual.controller.js.map +1 -0
- package/dist/controllers/setupRoutes.d.ts +5 -0
- package/dist/controllers/setupRoutes.d.ts.map +1 -0
- package/dist/controllers/setupRoutes.js +30 -0
- package/dist/controllers/setupRoutes.js.map +1 -0
- package/dist/controllers/tag/list-tags.controller.d.ts +8 -0
- package/dist/controllers/tag/list-tags.controller.d.ts.map +1 -0
- package/dist/controllers/tag/list-tags.controller.js +48 -0
- package/dist/controllers/tag/list-tags.controller.js.map +1 -0
- package/dist/data/DbUtils.d.ts +7 -0
- package/dist/data/DbUtils.d.ts.map +1 -0
- package/dist/data/DbUtils.js +23 -0
- package/dist/data/DbUtils.js.map +1 -0
- package/dist/data/Entity.d.ts +73 -0
- package/dist/data/Entity.d.ts.map +1 -0
- package/dist/data/Entity.js +361 -0
- package/dist/data/Entity.js.map +1 -0
- package/dist/data/EventUtils.d.ts +15 -0
- package/dist/data/EventUtils.d.ts.map +1 -0
- package/dist/data/EventUtils.js +35 -0
- package/dist/data/EventUtils.js.map +1 -0
- package/dist/data/FileObject.d.ts +62 -0
- package/dist/data/FileObject.d.ts.map +1 -0
- package/dist/data/FileObject.js +13 -0
- package/dist/data/FileObject.js.map +1 -0
- package/dist/data/Mutual.d.ts +94 -0
- package/dist/data/Mutual.d.ts.map +1 -0
- package/dist/data/Mutual.js +492 -0
- package/dist/data/Mutual.js.map +1 -0
- package/dist/data/ProjectionExpression.d.ts +6 -0
- package/dist/data/ProjectionExpression.d.ts.map +1 -0
- package/dist/data/ProjectionExpression.js +5 -0
- package/dist/data/ProjectionExpression.js.map +1 -0
- package/dist/data/Tag.d.ts +77 -0
- package/dist/data/Tag.d.ts.map +1 -0
- package/dist/data/Tag.js +330 -0
- package/dist/data/Tag.js.map +1 -0
- package/dist/data/abstract/Item.base.d.ts +11 -0
- package/dist/data/abstract/Item.base.d.ts.map +1 -0
- package/dist/data/abstract/Item.base.js +9 -0
- package/dist/data/abstract/Item.base.js.map +1 -0
- package/dist/data/abstract/Repository.base.d.ts +11 -0
- package/dist/data/abstract/Repository.base.d.ts.map +1 -0
- package/dist/data/abstract/Repository.base.js +54 -0
- package/dist/data/abstract/Repository.base.js.map +1 -0
- package/dist/errors/api-error.d.ts +23 -0
- package/dist/errors/api-error.d.ts.map +1 -0
- package/dist/errors/api-error.js +26 -0
- package/dist/errors/api-error.js.map +1 -0
- package/dist/errors/extendable-error.d.ts +18 -0
- package/dist/errors/extendable-error.d.ts.map +1 -0
- package/dist/errors/extendable-error.js +22 -0
- package/dist/errors/extendable-error.js.map +1 -0
- package/dist/errors/standard-error.d.ts +11 -0
- package/dist/errors/standard-error.d.ts.map +1 -0
- package/dist/errors/standard-error.js +21 -0
- package/dist/errors/standard-error.js.map +1 -0
- package/dist/helpers/dependencies.d.ts +8 -0
- package/dist/helpers/dependencies.d.ts.map +1 -0
- package/dist/helpers/dependencies.js +10 -0
- package/dist/helpers/dependencies.js.map +1 -0
- package/dist/helpers/event.d.ts +22 -0
- package/dist/helpers/event.d.ts.map +1 -0
- package/dist/helpers/event.js +47 -0
- package/dist/helpers/event.js.map +1 -0
- package/dist/helpers/fromLastKeyQuery.d.ts +3 -0
- package/dist/helpers/fromLastKeyQuery.d.ts.map +1 -0
- package/dist/helpers/fromLastKeyQuery.js +7 -0
- package/dist/helpers/fromLastKeyQuery.js.map +1 -0
- package/dist/helpers/sleep.d.ts +2 -0
- package/dist/helpers/sleep.d.ts.map +1 -0
- package/dist/helpers/sleep.js +2 -0
- package/dist/helpers/sleep.js.map +1 -0
- package/dist/helpers/toLastKeyResponse.d.ts +3 -0
- package/dist/helpers/toLastKeyResponse.d.ts.map +1 -0
- package/dist/helpers/toLastKeyResponse.js +7 -0
- package/dist/helpers/toLastKeyResponse.js.map +1 -0
- package/dist/index.d.ts +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/middlewares/entity-type-check.d.ts +4 -0
- package/dist/middlewares/entity-type-check.d.ts.map +1 -0
- package/dist/middlewares/entity-type-check.js +12 -0
- package/dist/middlewares/entity-type-check.js.map +1 -0
- package/dist/middlewares/mutual-type-check.d.ts +4 -0
- package/dist/middlewares/mutual-type-check.d.ts.map +1 -0
- package/dist/middlewares/mutual-type-check.js +13 -0
- package/dist/middlewares/mutual-type-check.js.map +1 -0
- package/dist/mock/entity.d.ts +5 -0
- package/dist/mock/entity.d.ts.map +1 -0
- package/dist/mock/entity.js +6 -0
- package/dist/mock/entity.js.map +1 -0
- package/dist/mock/monorise/admin.d.ts +127 -0
- package/dist/mock/monorise/admin.d.ts.map +1 -0
- package/dist/mock/monorise/admin.js +26 -0
- package/dist/mock/monorise/admin.js.map +1 -0
- package/dist/mock/monorise/course.d.ts +118 -0
- package/dist/mock/monorise/course.d.ts.map +1 -0
- package/dist/mock/monorise/course.js +53 -0
- package/dist/mock/monorise/course.js.map +1 -0
- package/dist/mock/monorise/index.d.ts +330 -0
- package/dist/mock/monorise/index.d.ts.map +1 -0
- package/dist/mock/monorise/index.js +19 -0
- package/dist/mock/monorise/index.js.map +1 -0
- package/dist/processors/create-entity-processor.d.ts +6 -0
- package/dist/processors/create-entity-processor.d.ts.map +1 -0
- package/dist/processors/create-entity-processor.js +32 -0
- package/dist/processors/create-entity-processor.js.map +1 -0
- package/dist/processors/mutual-processor.d.ts +16 -0
- package/dist/processors/mutual-processor.d.ts.map +1 -0
- package/dist/processors/mutual-processor.js +131 -0
- package/dist/processors/mutual-processor.js.map +1 -0
- package/dist/processors/prejoin-processor.d.ts +13 -0
- package/dist/processors/prejoin-processor.d.ts.map +1 -0
- package/dist/processors/prejoin-processor.js +149 -0
- package/dist/processors/prejoin-processor.js.map +1 -0
- package/dist/processors/replication-processor.d.ts +9 -0
- package/dist/processors/replication-processor.d.ts.map +1 -0
- package/dist/processors/replication-processor.js +179 -0
- package/dist/processors/replication-processor.js.map +1 -0
- package/dist/processors/tag-processor.d.ts +12 -0
- package/dist/processors/tag-processor.d.ts.map +1 -0
- package/dist/processors/tag-processor.js +105 -0
- package/dist/processors/tag-processor.js.map +1 -0
- package/dist/services/DependencyContainer.d.ts +63 -0
- package/dist/services/DependencyContainer.d.ts.map +1 -0
- package/dist/services/DependencyContainer.js +121 -0
- package/dist/services/DependencyContainer.js.map +1 -0
- package/dist/services/entity-service-lifecycle.d.ts +12 -0
- package/dist/services/entity-service-lifecycle.d.ts.map +1 -0
- package/dist/services/entity-service-lifecycle.js +32 -0
- package/dist/services/entity-service-lifecycle.js.map +1 -0
- package/dist/services/entity.service.d.ts +34 -0
- package/dist/services/entity.service.d.ts.map +1 -0
- package/dist/services/entity.service.js +117 -0
- package/dist/services/entity.service.js.map +1 -0
- package/dist/services/mutual.service.d.ts +64 -0
- package/dist/services/mutual.service.d.ts.map +1 -0
- package/dist/services/mutual.service.js +137 -0
- package/dist/services/mutual.service.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/entity.type.d.ts +20 -0
- package/dist/types/entity.type.d.ts.map +1 -0
- package/dist/types/entity.type.js +2 -0
- package/dist/types/entity.type.js.map +1 -0
- package/dist/types/event.d.ts +72 -0
- package/dist/types/event.d.ts.map +1 -0
- package/dist/types/event.js +74 -0
- package/dist/types/event.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import type { z } from 'zod';
|
|
2
|
+
import admin from './admin';
|
|
3
|
+
import course from './course';
|
|
4
|
+
export declare enum Entity {
|
|
5
|
+
ADMIN = "admin",
|
|
6
|
+
COURSE = "course"
|
|
7
|
+
}
|
|
8
|
+
export type AdminType = z.infer<(typeof admin)['finalSchema']>;
|
|
9
|
+
export type CourseType = z.infer<(typeof course)['finalSchema']>;
|
|
10
|
+
export interface EntitySchemaMap {
|
|
11
|
+
admin: AdminType;
|
|
12
|
+
course: CourseType;
|
|
13
|
+
}
|
|
14
|
+
declare const EntityConfig: {
|
|
15
|
+
admin: {
|
|
16
|
+
finalSchema: z.ZodObject<z.objectUtil.extendShape<{
|
|
17
|
+
email: z.ZodOptional<z.ZodString>;
|
|
18
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
19
|
+
}, {
|
|
20
|
+
email: z.ZodString;
|
|
21
|
+
displayName: z.ZodString;
|
|
22
|
+
}>, "strip", z.ZodTypeAny, {
|
|
23
|
+
email: string;
|
|
24
|
+
displayName: string;
|
|
25
|
+
}, {
|
|
26
|
+
email: string;
|
|
27
|
+
displayName: string;
|
|
28
|
+
}> | z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
|
|
29
|
+
email: z.ZodOptional<z.ZodString>;
|
|
30
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
31
|
+
}, {
|
|
32
|
+
email: z.ZodString;
|
|
33
|
+
displayName: z.ZodString;
|
|
34
|
+
}>, "strip", z.ZodTypeAny, {
|
|
35
|
+
email: string;
|
|
36
|
+
displayName: string;
|
|
37
|
+
}, {
|
|
38
|
+
email: string;
|
|
39
|
+
displayName: string;
|
|
40
|
+
}>, {
|
|
41
|
+
email: string;
|
|
42
|
+
displayName: string;
|
|
43
|
+
}, {
|
|
44
|
+
email: string;
|
|
45
|
+
displayName: string;
|
|
46
|
+
}>;
|
|
47
|
+
name: string;
|
|
48
|
+
displayName: string;
|
|
49
|
+
authMethod?: {
|
|
50
|
+
email: {
|
|
51
|
+
tokenExpiresIn: number;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
baseSchema: z.ZodObject<{
|
|
55
|
+
email: z.ZodOptional<z.ZodString>;
|
|
56
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
57
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
58
|
+
email?: string | undefined;
|
|
59
|
+
displayName?: string | undefined;
|
|
60
|
+
}, {
|
|
61
|
+
email?: string | undefined;
|
|
62
|
+
displayName?: string | undefined;
|
|
63
|
+
}>;
|
|
64
|
+
createSchema?: z.ZodObject<z.objectUtil.extendShape<{
|
|
65
|
+
email: z.ZodOptional<z.ZodString>;
|
|
66
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, {
|
|
68
|
+
email: z.ZodString;
|
|
69
|
+
displayName: z.ZodString;
|
|
70
|
+
}>, "strip", z.ZodTypeAny, {
|
|
71
|
+
email: string;
|
|
72
|
+
displayName: string;
|
|
73
|
+
}, {
|
|
74
|
+
email: string;
|
|
75
|
+
displayName: string;
|
|
76
|
+
}> | undefined;
|
|
77
|
+
searchableFields?: ("email" | "displayName")[] | undefined;
|
|
78
|
+
mutual?: {
|
|
79
|
+
subscribes?: {
|
|
80
|
+
entityType: import("@monorise/base").Entity;
|
|
81
|
+
}[];
|
|
82
|
+
mutualSchema: undefined;
|
|
83
|
+
mutualFields: {
|
|
84
|
+
[key: string]: {
|
|
85
|
+
entityType: import("@monorise/base").Entity;
|
|
86
|
+
toMutualIds?: (context: any) => string[];
|
|
87
|
+
mutualDataProcessor?: (mutualIds: string[], currentMutual: any, customContext?: Record<string, any>) => Record<string, any>;
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
prejoins?: {
|
|
91
|
+
mutualField: string;
|
|
92
|
+
targetEntityType: import("@monorise/base").Entity;
|
|
93
|
+
entityPaths: {
|
|
94
|
+
skipCache?: boolean;
|
|
95
|
+
entityType: import("@monorise/base").Entity;
|
|
96
|
+
processor?: (items: any[], context: Record<string, any>) => any;
|
|
97
|
+
}[];
|
|
98
|
+
}[];
|
|
99
|
+
} | undefined;
|
|
100
|
+
effect?: ((schema: z.ZodObject<z.objectUtil.extendShape<{
|
|
101
|
+
email: z.ZodOptional<z.ZodString>;
|
|
102
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
103
|
+
}, {
|
|
104
|
+
email: z.ZodString;
|
|
105
|
+
displayName: z.ZodString;
|
|
106
|
+
}>, "strip", z.ZodTypeAny, {
|
|
107
|
+
email: string;
|
|
108
|
+
displayName: string;
|
|
109
|
+
}, {
|
|
110
|
+
email: string;
|
|
111
|
+
displayName: string;
|
|
112
|
+
}>) => z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
|
|
113
|
+
email: z.ZodOptional<z.ZodString>;
|
|
114
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
115
|
+
}, {
|
|
116
|
+
email: z.ZodString;
|
|
117
|
+
displayName: z.ZodString;
|
|
118
|
+
}>, "strip", z.ZodTypeAny, {
|
|
119
|
+
email: string;
|
|
120
|
+
displayName: string;
|
|
121
|
+
}, {
|
|
122
|
+
email: string;
|
|
123
|
+
displayName: string;
|
|
124
|
+
}>, {
|
|
125
|
+
email: string;
|
|
126
|
+
displayName: string;
|
|
127
|
+
}, {
|
|
128
|
+
email: string;
|
|
129
|
+
displayName: string;
|
|
130
|
+
}>) | undefined;
|
|
131
|
+
tags?: {
|
|
132
|
+
name: string;
|
|
133
|
+
processor: (entity: import("@monorise/base").CreatedEntity<import("@monorise/base").Entity>) => {
|
|
134
|
+
group?: string;
|
|
135
|
+
sortValue?: string;
|
|
136
|
+
}[];
|
|
137
|
+
}[] | undefined;
|
|
138
|
+
};
|
|
139
|
+
course: {
|
|
140
|
+
finalSchema: z.ZodObject<{
|
|
141
|
+
admins: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
142
|
+
} & {} & {
|
|
143
|
+
title: z.ZodString;
|
|
144
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
145
|
+
title: string;
|
|
146
|
+
admins?: string[] | undefined;
|
|
147
|
+
}, {
|
|
148
|
+
title: string;
|
|
149
|
+
admins?: string[] | undefined;
|
|
150
|
+
}> | z.ZodEffects<z.ZodObject<{
|
|
151
|
+
admins: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
152
|
+
} & {} & {
|
|
153
|
+
title: z.ZodString;
|
|
154
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
155
|
+
title: string;
|
|
156
|
+
admins?: string[] | undefined;
|
|
157
|
+
}, {
|
|
158
|
+
title: string;
|
|
159
|
+
admins?: string[] | undefined;
|
|
160
|
+
}>, {
|
|
161
|
+
title: string;
|
|
162
|
+
admins?: string[] | undefined;
|
|
163
|
+
}, {
|
|
164
|
+
title: string;
|
|
165
|
+
admins?: string[] | undefined;
|
|
166
|
+
}>;
|
|
167
|
+
name: string;
|
|
168
|
+
displayName: string;
|
|
169
|
+
authMethod?: {
|
|
170
|
+
email: {
|
|
171
|
+
tokenExpiresIn: number;
|
|
172
|
+
};
|
|
173
|
+
};
|
|
174
|
+
baseSchema: z.ZodObject<{
|
|
175
|
+
title: z.ZodOptional<z.ZodString>;
|
|
176
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
177
|
+
title?: string | undefined;
|
|
178
|
+
}, {
|
|
179
|
+
title?: string | undefined;
|
|
180
|
+
}>;
|
|
181
|
+
createSchema?: z.ZodObject<z.objectUtil.extendShape<{
|
|
182
|
+
title: z.ZodOptional<z.ZodString>;
|
|
183
|
+
}, {
|
|
184
|
+
title: z.ZodString;
|
|
185
|
+
}>, "strip", z.ZodTypeAny, {
|
|
186
|
+
title: string;
|
|
187
|
+
}, {
|
|
188
|
+
title: string;
|
|
189
|
+
}> | undefined;
|
|
190
|
+
searchableFields?: "title"[] | undefined;
|
|
191
|
+
mutual?: {
|
|
192
|
+
subscribes?: {
|
|
193
|
+
entityType: import("@monorise/base").Entity;
|
|
194
|
+
}[];
|
|
195
|
+
mutualSchema: z.ZodObject<{
|
|
196
|
+
admins: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
197
|
+
}, "strip", z.ZodTypeAny, {
|
|
198
|
+
admins?: string[] | undefined;
|
|
199
|
+
}, {
|
|
200
|
+
admins?: string[] | undefined;
|
|
201
|
+
}>;
|
|
202
|
+
mutualFields: {
|
|
203
|
+
[key: string]: {
|
|
204
|
+
entityType: import("@monorise/base").Entity;
|
|
205
|
+
toMutualIds?: (context: any) => string[];
|
|
206
|
+
mutualDataProcessor?: (mutualIds: string[], currentMutual: any, customContext?: Record<string, any>) => Record<string, any>;
|
|
207
|
+
};
|
|
208
|
+
};
|
|
209
|
+
prejoins?: {
|
|
210
|
+
mutualField: string;
|
|
211
|
+
targetEntityType: import("@monorise/base").Entity;
|
|
212
|
+
entityPaths: {
|
|
213
|
+
skipCache?: boolean;
|
|
214
|
+
entityType: import("@monorise/base").Entity;
|
|
215
|
+
processor?: (items: any[], context: Record<string, any>) => any;
|
|
216
|
+
}[];
|
|
217
|
+
}[];
|
|
218
|
+
} | undefined;
|
|
219
|
+
effect?: ((schema: z.ZodObject<{
|
|
220
|
+
admins: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
221
|
+
} & {} & {
|
|
222
|
+
title: z.ZodString;
|
|
223
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
224
|
+
title: string;
|
|
225
|
+
admins?: string[] | undefined;
|
|
226
|
+
}, {
|
|
227
|
+
title: string;
|
|
228
|
+
admins?: string[] | undefined;
|
|
229
|
+
}>) => z.ZodEffects<z.ZodObject<{
|
|
230
|
+
admins: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
231
|
+
} & {} & {
|
|
232
|
+
title: z.ZodString;
|
|
233
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
234
|
+
title: string;
|
|
235
|
+
admins?: string[] | undefined;
|
|
236
|
+
}, {
|
|
237
|
+
title: string;
|
|
238
|
+
admins?: string[] | undefined;
|
|
239
|
+
}>, {
|
|
240
|
+
title: string;
|
|
241
|
+
admins?: string[] | undefined;
|
|
242
|
+
}, {
|
|
243
|
+
title: string;
|
|
244
|
+
admins?: string[] | undefined;
|
|
245
|
+
}>) | undefined;
|
|
246
|
+
tags?: {
|
|
247
|
+
name: string;
|
|
248
|
+
processor: (entity: import("@monorise/base").CreatedEntity<import("@monorise/base").Entity>) => {
|
|
249
|
+
group?: string;
|
|
250
|
+
sortValue?: string;
|
|
251
|
+
}[];
|
|
252
|
+
}[] | undefined;
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
declare const FormSchema: {
|
|
256
|
+
admin: z.ZodObject<z.objectUtil.extendShape<{
|
|
257
|
+
email: z.ZodOptional<z.ZodString>;
|
|
258
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
259
|
+
}, {
|
|
260
|
+
email: z.ZodString;
|
|
261
|
+
displayName: z.ZodString;
|
|
262
|
+
}>, "strip", z.ZodTypeAny, {
|
|
263
|
+
email: string;
|
|
264
|
+
displayName: string;
|
|
265
|
+
}, {
|
|
266
|
+
email: string;
|
|
267
|
+
displayName: string;
|
|
268
|
+
}> | z.ZodEffects<z.ZodObject<z.objectUtil.extendShape<{
|
|
269
|
+
email: z.ZodOptional<z.ZodString>;
|
|
270
|
+
displayName: z.ZodOptional<z.ZodString>;
|
|
271
|
+
}, {
|
|
272
|
+
email: z.ZodString;
|
|
273
|
+
displayName: z.ZodString;
|
|
274
|
+
}>, "strip", z.ZodTypeAny, {
|
|
275
|
+
email: string;
|
|
276
|
+
displayName: string;
|
|
277
|
+
}, {
|
|
278
|
+
email: string;
|
|
279
|
+
displayName: string;
|
|
280
|
+
}>, {
|
|
281
|
+
email: string;
|
|
282
|
+
displayName: string;
|
|
283
|
+
}, {
|
|
284
|
+
email: string;
|
|
285
|
+
displayName: string;
|
|
286
|
+
}>;
|
|
287
|
+
course: z.ZodObject<{
|
|
288
|
+
admins: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
289
|
+
} & {} & {
|
|
290
|
+
title: z.ZodString;
|
|
291
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
292
|
+
title: string;
|
|
293
|
+
admins?: string[] | undefined;
|
|
294
|
+
}, {
|
|
295
|
+
title: string;
|
|
296
|
+
admins?: string[] | undefined;
|
|
297
|
+
}> | z.ZodEffects<z.ZodObject<{
|
|
298
|
+
admins: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
299
|
+
} & {} & {
|
|
300
|
+
title: z.ZodString;
|
|
301
|
+
}, z.UnknownKeysParam, z.ZodTypeAny, {
|
|
302
|
+
title: string;
|
|
303
|
+
admins?: string[] | undefined;
|
|
304
|
+
}, {
|
|
305
|
+
title: string;
|
|
306
|
+
admins?: string[] | undefined;
|
|
307
|
+
}>, {
|
|
308
|
+
title: string;
|
|
309
|
+
admins?: string[] | undefined;
|
|
310
|
+
}, {
|
|
311
|
+
title: string;
|
|
312
|
+
admins?: string[] | undefined;
|
|
313
|
+
}>;
|
|
314
|
+
};
|
|
315
|
+
declare const AllowedEntityTypes: Entity[];
|
|
316
|
+
declare const EmailAuthEnabledEntities: Entity[];
|
|
317
|
+
export { EntityConfig, FormSchema, AllowedEntityTypes, EmailAuthEnabledEntities, };
|
|
318
|
+
declare module '@monorise/base' {
|
|
319
|
+
enum Entity {
|
|
320
|
+
ADMIN = "admin",
|
|
321
|
+
COURSE = "course"
|
|
322
|
+
}
|
|
323
|
+
type AdminType = z.infer<(typeof admin)['finalSchema']>;
|
|
324
|
+
type CourseType = z.infer<(typeof course)['finalSchema']>;
|
|
325
|
+
interface EntitySchemaMap {
|
|
326
|
+
admin: AdminType;
|
|
327
|
+
course: CourseType;
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../mock/monorise/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAC7B,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,oBAAY,MAAM;IAChB,KAAK,UAAU;IACf,MAAM,WAAW;CAClB;AAED,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;AAC/D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;AAEjE,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,SAAS,CAAC;IACjB,MAAM,EAAE,UAAU,CAAC;CACpB;AAED,QAAA,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAmC2pE,CAAC;uCAA+T,CAAC,yDAAwF,CAAC;;;;;;;6BAA40B,CAAC;;6BAAwD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAAs0E,CAAC;yBAAyB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAAjoH,CAAC;uCAA+T,CAAC,yDAAwF,CAAC;;;;;;;6BAA40B,CAAC;;6BAAwD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAAs0E,CAAC;yBAAyB,CAAC;;;;CAhC7yL,CAAC;AAEF,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGf,CAAC;AAEF,QAAA,MAAM,kBAAkB,UAAgC,CAAC;AAEzD,QAAA,MAAM,wBAAwB,UAAiB,CAAC;AAEhD,OAAO,EACL,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,wBAAwB,GACzB,CAAC;AAEF,OAAO,QAAQ,gBAAgB,CAAC;IAC9B,KAAY,MAAM;QAChB,KAAK,UAAU;QACf,MAAM,WAAW;KAClB;IAED,KAAY,SAAS,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,KAAK,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;IAC/D,KAAY,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;IAEjE,UAAiB,eAAe;QAC9B,KAAK,EAAE,SAAS,CAAC;QACjB,MAAM,EAAE,UAAU,CAAC;KACpB;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import admin from './admin';
|
|
2
|
+
import course from './course';
|
|
3
|
+
export var Entity;
|
|
4
|
+
(function (Entity) {
|
|
5
|
+
Entity["ADMIN"] = "admin";
|
|
6
|
+
Entity["COURSE"] = "course";
|
|
7
|
+
})(Entity || (Entity = {}));
|
|
8
|
+
const EntityConfig = {
|
|
9
|
+
[Entity.ADMIN]: admin,
|
|
10
|
+
[Entity.COURSE]: course,
|
|
11
|
+
};
|
|
12
|
+
const FormSchema = {
|
|
13
|
+
[Entity.ADMIN]: admin.finalSchema,
|
|
14
|
+
[Entity.COURSE]: course.finalSchema,
|
|
15
|
+
};
|
|
16
|
+
const AllowedEntityTypes = [Entity.ADMIN, Entity.COURSE];
|
|
17
|
+
const EmailAuthEnabledEntities = [Entity.ADMIN];
|
|
18
|
+
export { EntityConfig, FormSchema, AllowedEntityTypes, EmailAuthEnabledEntities, };
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../mock/monorise/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,SAAS,CAAC;AAC5B,OAAO,MAAM,MAAM,UAAU,CAAC;AAE9B,MAAM,CAAN,IAAY,MAGX;AAHD,WAAY,MAAM;IAChB,yBAAe,CAAA;IACf,2BAAiB,CAAA;AACnB,CAAC,EAHW,MAAM,KAAN,MAAM,QAGjB;AAUD,MAAM,YAAY,GAAG;IACnB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK;IACrB,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM;CACxB,CAAC;AAEF,MAAM,UAAU,GAAG;IACjB,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC,WAAW;IACjC,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,WAAW;CACpC,CAAC;AAEF,MAAM,kBAAkB,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC;AAEzD,MAAM,wBAAwB,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAEhD,OAAO,EACL,YAAY,EACZ,UAAU,EACV,kBAAkB,EAClB,wBAAwB,GACzB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SQSBatchItemFailure, SQSEvent } from 'aws-lambda';
|
|
2
|
+
import type { DependencyContainer } from '../services/DependencyContainer';
|
|
3
|
+
export declare const handler: (container: DependencyContainer) => (ev: SQSEvent) => Promise<{
|
|
4
|
+
batchItemFailures: SQSBatchItemFailure[];
|
|
5
|
+
}>;
|
|
6
|
+
//# sourceMappingURL=create-entity-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-entity-processor.d.ts","sourceRoot":"","sources":["../../processors/create-entity-processor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAa3E,eAAO,MAAM,OAAO,GACjB,WAAW,mBAAmB,MAAY,IAAI,QAAQ;;EAuCtD,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { StandardError } from '../errors/standard-error';
|
|
2
|
+
import { parseSQSBusEvent } from '../helpers/event';
|
|
3
|
+
export const handler = (container) => async (ev) => {
|
|
4
|
+
const { entityService } = container;
|
|
5
|
+
const batchItemFailures = [];
|
|
6
|
+
for (const record of ev.Records) {
|
|
7
|
+
const errorContext = {};
|
|
8
|
+
const body = parseSQSBusEvent(record.body);
|
|
9
|
+
const { detail } = body;
|
|
10
|
+
const { entityType, entityId, entityPayload, accountId, options } = detail;
|
|
11
|
+
errorContext.body = body;
|
|
12
|
+
try {
|
|
13
|
+
await entityService.createEntity({
|
|
14
|
+
entityType,
|
|
15
|
+
entityId,
|
|
16
|
+
entityPayload,
|
|
17
|
+
accountId,
|
|
18
|
+
options,
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
catch (err) {
|
|
22
|
+
console.error('=====CREATE_ENTITY_PROCESSOR_ERROR=====', err, JSON.stringify({ errorContext }, null, 2));
|
|
23
|
+
if (err instanceof StandardError &&
|
|
24
|
+
err.code === 'INVALID_ENTITY_TYPE') {
|
|
25
|
+
continue; // do not retry
|
|
26
|
+
}
|
|
27
|
+
batchItemFailures.push({ itemIdentifier: record.messageId });
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return { batchItemFailures };
|
|
31
|
+
};
|
|
32
|
+
//# sourceMappingURL=create-entity-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-entity-processor.js","sourceRoot":"","sources":["../../processors/create-entity-processor.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAcpD,MAAM,CAAC,MAAM,OAAO,GAClB,CAAC,SAA8B,EAAE,EAAE,CAAC,KAAK,EAAE,EAAY,EAAE,EAAE;IACzD,MAAM,EAAE,aAAa,EAAE,GAAG,SAAS,CAAC;IACpC,MAAM,iBAAiB,GAA0B,EAAE,CAAC;IAEpD,KAAK,MAAM,MAAM,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAChC,MAAM,YAAY,GAA4B,EAAE,CAAC;QACjD,MAAM,IAAI,GAAG,gBAAgB,CAAkB,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5D,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;QACxB,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,aAAa,EAAE,SAAS,EAAE,OAAO,EAAE,GAC/D,MAAM,CAAC;QACT,YAAY,CAAC,IAAI,GAAG,IAAI,CAAC;QAEzB,IAAI,CAAC;YACH,MAAM,aAAa,CAAC,YAAY,CAAC;gBAC/B,UAAU;gBACV,QAAQ;gBACR,aAAa;gBACb,SAAS;gBACT,OAAO;aACR,CAAC,CAAC;QACL,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC,KAAK,CACX,yCAAyC,EACzC,GAAG,EACH,IAAI,CAAC,SAAS,CAAC,EAAE,YAAY,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAC1C,CAAC;YAEF,IACE,GAAG,YAAY,aAAa;gBAC5B,GAAG,CAAC,IAAI,KAAK,qBAAqB,EAClC,CAAC;gBACD,SAAS,CAAC,eAAe;YAC3B,CAAC;YAED,iBAAiB,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC;IAED,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Entity } from '@monorise/base';
|
|
2
|
+
import type { SQSBatchItemFailure, SQSEvent } from 'aws-lambda';
|
|
3
|
+
import type { DependencyContainer } from '../services/DependencyContainer';
|
|
4
|
+
export type EventDetailBody = {
|
|
5
|
+
mutualIds: string[];
|
|
6
|
+
byEntityType: Entity;
|
|
7
|
+
byEntityId: string;
|
|
8
|
+
entityType: Entity;
|
|
9
|
+
field: string;
|
|
10
|
+
publishedAt: string;
|
|
11
|
+
customContext?: Record<string, unknown>;
|
|
12
|
+
};
|
|
13
|
+
export declare const handler: (container: DependencyContainer) => (ev: SQSEvent) => Promise<{
|
|
14
|
+
batchItemFailures: SQSBatchItemFailure[];
|
|
15
|
+
}>;
|
|
16
|
+
//# sourceMappingURL=mutual-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutual-processor.d.ts","sourceRoot":"","sources":["../../processors/mutual-processor.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAKhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAG3E,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACzC,CAAC;AAOF,eAAO,MAAM,OAAO,GACjB,WAAW,mBAAmB,MAAY,IAAI,QAAQ;;EAmPtD,CAAC"}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { TransactionCanceledException } from '@aws-sdk/client-dynamodb';
|
|
2
|
+
// import { EntityConfig } from '#/lambda-layer/monorise';
|
|
3
|
+
import { Mutual } from '../data/Mutual';
|
|
4
|
+
import { StandardError } from '../errors/standard-error';
|
|
5
|
+
import { parseSQSBusEvent } from '../helpers/event';
|
|
6
|
+
import { EVENT } from '../types/event';
|
|
7
|
+
const processEntities = async (entityIds, action) => Promise.allSettled(entityIds.map(action));
|
|
8
|
+
export const handler = (container) => async (ev) => {
|
|
9
|
+
const batchItemFailures = [];
|
|
10
|
+
const { entityRepository, mutualRepository, publishEvent } = container;
|
|
11
|
+
await Promise.allSettled(ev.Records.map(async (record) => {
|
|
12
|
+
const errorContext = {};
|
|
13
|
+
const body = parseSQSBusEvent(record.body);
|
|
14
|
+
const { detail } = body;
|
|
15
|
+
const { mutualIds, byEntityType, byEntityId, entityType, field, publishedAt, customContext, } = detail;
|
|
16
|
+
errorContext.body = body;
|
|
17
|
+
try {
|
|
18
|
+
// Validate if mutual configuration exists
|
|
19
|
+
const config = container.config.EntityConfig[byEntityType]?.mutual?.mutualFields?.[field];
|
|
20
|
+
if (!config) {
|
|
21
|
+
throw new StandardError('INVALID_MUTUAL', 'Invalid mutual');
|
|
22
|
+
}
|
|
23
|
+
const mutualDataProcessor = config.mutualDataProcessor ?? (() => ({}));
|
|
24
|
+
// Create a lock to prevent concurrent modifications
|
|
25
|
+
await mutualRepository.createMutualLock({
|
|
26
|
+
byEntityType,
|
|
27
|
+
byEntityId,
|
|
28
|
+
entityType,
|
|
29
|
+
version: publishedAt,
|
|
30
|
+
});
|
|
31
|
+
// Fetch related entities in parallel
|
|
32
|
+
const [byEntity, mutuals] = await Promise.all([
|
|
33
|
+
entityRepository.getEntity(byEntityType, byEntityId),
|
|
34
|
+
mutualRepository.listEntitiesByEntity(byEntityType, byEntityId, entityType),
|
|
35
|
+
]);
|
|
36
|
+
// Determine which entities were added, removed, or need updates
|
|
37
|
+
const existingEntityIds = new Set(mutuals.items.map((m) => m.entityId));
|
|
38
|
+
const newMutualIds = new Set(mutualIds ?? []);
|
|
39
|
+
const addedEntityIds = [...newMutualIds].filter((id) => !existingEntityIds.has(id));
|
|
40
|
+
const deletedEntityIds = [...existingEntityIds].filter((id) => !newMutualIds.has(id));
|
|
41
|
+
const toUpdateEntityIds = [...existingEntityIds].filter((id) => newMutualIds.has(id));
|
|
42
|
+
errorContext.existingEntityIds = [...existingEntityIds];
|
|
43
|
+
errorContext.addedEntityIds = addedEntityIds;
|
|
44
|
+
errorContext.deletedEntityIds = deletedEntityIds;
|
|
45
|
+
errorContext.toUpdateEntityIds = toUpdateEntityIds;
|
|
46
|
+
const addEntities = await processEntities(addedEntityIds, async (id) => {
|
|
47
|
+
const entity = await entityRepository.getEntity(entityType, id);
|
|
48
|
+
await mutualRepository.createMutual(byEntityType, byEntityId, byEntity.data, entityType, id, entity.data, mutualDataProcessor(mutualIds, new Mutual(byEntityType, byEntityId, byEntity.data, entityType, id, entity.data, {}), customContext), {
|
|
49
|
+
ConditionExpression: 'attribute_not_exists(#mutualUpdatedAt) OR #mutualUpdatedAt < :publishedAt',
|
|
50
|
+
ExpressionAttributeNames: {
|
|
51
|
+
'#mutualUpdatedAt': 'mutualUpdatedAt',
|
|
52
|
+
},
|
|
53
|
+
ExpressionAttributeValues: {
|
|
54
|
+
':publishedAt': { S: publishedAt },
|
|
55
|
+
},
|
|
56
|
+
createAndUpdateDatetime: new Date(publishedAt),
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
const deleteEntities = await processEntities(deletedEntityIds, async (id) => {
|
|
60
|
+
await mutualRepository.deleteMutual(byEntityType, byEntityId, entityType, id, {
|
|
61
|
+
ConditionExpression: 'attribute_exists(PK) AND #mutualUpdatedAt < :publishedAt',
|
|
62
|
+
ExpressionAttributeNames: {
|
|
63
|
+
'#mutualUpdatedAt': 'mutualUpdatedAt',
|
|
64
|
+
},
|
|
65
|
+
ExpressionAttributeValues: {
|
|
66
|
+
':publishedAt': { S: publishedAt },
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
const updateEntities = await processEntities(toUpdateEntityIds, async (id) => {
|
|
71
|
+
await mutualRepository.updateMutual(byEntityType, byEntityId, entityType, id, {
|
|
72
|
+
mutualData: mutualDataProcessor(mutualIds, new Mutual(byEntityType, byEntityId, byEntity.data, entityType, id, {}, {}), customContext),
|
|
73
|
+
mutualUpdatedAt: publishedAt,
|
|
74
|
+
}, {
|
|
75
|
+
ConditionExpression: 'attribute_exists(PK) AND #mutualUpdatedAt < :publishedAt',
|
|
76
|
+
ExpressionAttributeNames: {
|
|
77
|
+
'#mutualUpdatedAt': 'mutualUpdatedAt',
|
|
78
|
+
},
|
|
79
|
+
ExpressionAttributeValues: {
|
|
80
|
+
':publishedAt': { S: publishedAt },
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
});
|
|
84
|
+
errorContext.results = {
|
|
85
|
+
addEntities,
|
|
86
|
+
deleteEntities,
|
|
87
|
+
updateEntities,
|
|
88
|
+
};
|
|
89
|
+
// release lock
|
|
90
|
+
await mutualRepository.deleteMutualLock({
|
|
91
|
+
byEntityType,
|
|
92
|
+
byEntityId,
|
|
93
|
+
entityType,
|
|
94
|
+
});
|
|
95
|
+
// Check for unprocessable errors in processing results
|
|
96
|
+
if ([...addEntities, ...deleteEntities, ...updateEntities].some((res) => res.status === 'rejected' &&
|
|
97
|
+
!(res.reason instanceof TransactionCanceledException ||
|
|
98
|
+
(res.reason instanceof StandardError &&
|
|
99
|
+
res.reason.code === 'MUTUAL_NOT_FOUND')))) {
|
|
100
|
+
throw new StandardError('MUTUAL_PROCESSOR_ERROR', 'Mutual processor error', null, errorContext);
|
|
101
|
+
}
|
|
102
|
+
await publishEvent({
|
|
103
|
+
event: EVENT.CORE.ENTITY_MUTUAL_PROCESSED,
|
|
104
|
+
payload: {
|
|
105
|
+
byEntityType,
|
|
106
|
+
byEntityId,
|
|
107
|
+
entityType,
|
|
108
|
+
field,
|
|
109
|
+
mutualIds,
|
|
110
|
+
publishedAt,
|
|
111
|
+
},
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
catch (err) {
|
|
115
|
+
console.error('=====MUTUAL_PROCESSOR_ERROR=====', err, JSON.stringify({ errorContext }, null, 2));
|
|
116
|
+
// Release the lock to avoid deadlocks
|
|
117
|
+
await mutualRepository.deleteMutualLock({
|
|
118
|
+
byEntityType,
|
|
119
|
+
byEntityId,
|
|
120
|
+
entityType,
|
|
121
|
+
});
|
|
122
|
+
if (err instanceof StandardError &&
|
|
123
|
+
['INVALID_MUTUAL', 'MUTUAL_LOCK_CONFLICT'].includes(err.code)) {
|
|
124
|
+
return;
|
|
125
|
+
}
|
|
126
|
+
batchItemFailures.push({ itemIdentifier: record.messageId });
|
|
127
|
+
}
|
|
128
|
+
}));
|
|
129
|
+
return { batchItemFailures };
|
|
130
|
+
};
|
|
131
|
+
//# sourceMappingURL=mutual-processor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutual-processor.js","sourceRoot":"","sources":["../../processors/mutual-processor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,0BAA0B,CAAC;AAGxE,0DAA0D;AAC1D,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAYvC,MAAM,eAAe,GAAG,KAAK,EAC3B,SAAmB,EACnB,MAAqC,EACrC,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;A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EAAE,CAAC,CAAC,CAC1C,CAAC;YAEF,sCAAsC;YACtC,MAAM,gBAAgB,CAAC,gBAAgB,CAAC;gBACtC,YAAY;gBACZ,UAAU;gBACV,UAAU;aACX,CAAC,CAAC;YAEH,IACE,GAAG,YAAY,aAAa;gBAC5B,CAAC,gBAAgB,EAAE,sBAAsB,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,EAC7D,CAAC;gBACD,OAAO;YACT,CAAC;YAED,iBAAiB,CAAC,IAAI,CAAC,EAAE,cAAc,EAAE,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;QAC/D,CAAC;IACH,CAAC,CAAC,CACH,CAAC;IAEF,OAAO,EAAE,iBAAiB,EAAE,CAAC;AAC/B,CAAC,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { Entity } from '@monorise/base';
|
|
2
|
+
import type { SQSBatchItemFailure, SQSEvent } from 'aws-lambda';
|
|
3
|
+
import type { DependencyContainer } from '../services/DependencyContainer';
|
|
4
|
+
export type EventDetailBody = {
|
|
5
|
+
byEntityType: Entity;
|
|
6
|
+
byEntityId: string;
|
|
7
|
+
entityType: Entity;
|
|
8
|
+
publishedAt: string;
|
|
9
|
+
};
|
|
10
|
+
export declare const handler: (container: DependencyContainer) => (ev: SQSEvent) => Promise<{
|
|
11
|
+
batchItemFailures: SQSBatchItemFailure[];
|
|
12
|
+
}>;
|
|
13
|
+
//# sourceMappingURL=prejoin-processor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prejoin-processor.d.ts","sourceRoot":"","sources":["../../processors/prejoin-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAMhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC;AAI3E,MAAM,MAAM,eAAe,GAAG;IAC5B,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;CACrB,CAAC;AA2LF,eAAO,MAAM,OAAO,GACjB,WAAW,mBAAmB,MAAY,IAAI,QAAQ;;EA8DtD,CAAC"}
|