@chevre/domain 26.0.0-alpha.27 → 26.0.0-alpha.29

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 (48) hide show
  1. package/lib/chevre/repo/action.d.ts +3 -19
  2. package/lib/chevre/repo/action.js +0 -298
  3. package/lib/chevre/repo/adminAssetTransaction.d.ts +0 -6
  4. package/lib/chevre/repo/adminAssetTransaction.js +0 -13
  5. package/lib/chevre/repo/adminTask.d.ts +0 -8
  6. package/lib/chevre/repo/adminTask.js +0 -16
  7. package/lib/chevre/repo/aggregation.d.ts +0 -8
  8. package/lib/chevre/repo/aggregation.js +0 -10
  9. package/lib/chevre/repo/authorization.d.ts +0 -6
  10. package/lib/chevre/repo/authorization.js +0 -12
  11. package/lib/chevre/repo/message.d.ts +0 -7
  12. package/lib/chevre/repo/message.js +0 -38
  13. package/lib/chevre/repo/mongoose/schemas/action.d.ts +1 -1
  14. package/lib/chevre/repo/mongoose/schemas/action.js +1 -1
  15. package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +85 -76
  16. package/lib/chevre/repo/mongoose/schemas/updateAction.d.ts +12 -0
  17. package/lib/chevre/repo/mongoose/schemas/updateAction.js +107 -0
  18. package/lib/chevre/repo/ticket.d.ts +0 -6
  19. package/lib/chevre/repo/ticket.js +0 -11
  20. package/lib/chevre/repo/updateAction.d.ts +56 -0
  21. package/lib/chevre/repo/updateAction.js +173 -0
  22. package/lib/chevre/repository.d.ts +5 -0
  23. package/lib/chevre/repository.js +12 -1
  24. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +2 -2
  25. package/lib/chevre/service/event/processUpdateMovieTheater.js +3 -3
  26. package/lib/chevre/service/event.d.ts +2 -2
  27. package/lib/chevre/service/event.js +3 -3
  28. package/lib/chevre/service/task/deleteTransaction.js +4 -35
  29. package/lib/chevre/service/task/importEventsFromCOA.js +2 -2
  30. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.d.ts +2 -2
  31. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +4 -4
  32. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +2 -2
  33. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +4 -4
  34. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +2 -2
  35. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +4 -4
  36. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +2 -2
  37. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +4 -4
  38. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +2 -2
  39. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +4 -4
  40. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +2 -2
  41. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +4 -4
  42. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +2 -2
  43. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +4 -4
  44. package/lib/chevre/service/task/onResourceDeleted.js +2 -3
  45. package/lib/chevre/service/task/syncResourcesFromCOA.js +26 -18
  46. package/lib/chevre/service/transaction/deleteTransaction.d.ts +2 -0
  47. package/lib/chevre/service/transaction/deleteTransaction.js +3 -3
  48. package/package.json +2 -2
@@ -71,10 +71,11 @@ const indexes = [
71
71
  name: 'uniqueTransactionNumber'
72
72
  }
73
73
  ],
74
- [
75
- { transactionNumber: 1, startDate: -1 },
76
- { name: 'searchByTransactionNumber' }
77
- ],
74
+ // discontinue(2026-08-12~)
75
+ // [
76
+ // { transactionNumber: 1, startDate: -1 },
77
+ // { name: 'searchByTransactionNumber' }
78
+ // ],
78
79
  [
79
80
  { 'project.id': 1, startDate: -1 },
80
81
  {
@@ -124,15 +125,16 @@ const indexes = [
124
125
  }
125
126
  }
126
127
  ],
127
- [
128
- { 'object.provider.id': 1, startDate: -1 },
129
- {
130
- name: 'searchByObjectProviderId',
131
- partialFilterExpression: {
132
- 'object.provider.id': { $exists: true }
133
- }
134
- }
135
- ],
128
+ // discontinue(2026-08-12~)
129
+ // [
130
+ // { 'object.provider.id': 1, startDate: -1 },
131
+ // {
132
+ // name: 'searchByObjectProviderId',
133
+ // partialFilterExpression: {
134
+ // 'object.provider.id': { $exists: true }
135
+ // }
136
+ // }
137
+ // ],
136
138
  [
137
139
  { 'object.subReservation.id': 1, startDate: -1 },
138
140
  {
@@ -142,24 +144,26 @@ const indexes = [
142
144
  }
143
145
  }
144
146
  ],
145
- [
146
- { 'object.subReservation.reservationNumber': 1, startDate: -1 },
147
- {
148
- name: 'searchByObjectSubReservationsReservationNumber',
149
- partialFilterExpression: {
150
- 'object.subReservation.reservationNumber': { $exists: true }
151
- }
152
- }
153
- ],
154
- [
155
- { 'object.subReservation.reservationFor.id': 1, startDate: -1 },
156
- {
157
- name: 'searchByObjectSubReservationsReservationForId',
158
- partialFilterExpression: {
159
- 'object.subReservation.reservationFor.id': { $exists: true }
160
- }
161
- }
162
- ],
147
+ // discontinue(2026-08-12~)
148
+ // [
149
+ // { 'object.subReservation.reservationNumber': 1, startDate: -1 },
150
+ // {
151
+ // name: 'searchByObjectSubReservationsReservationNumber',
152
+ // partialFilterExpression: {
153
+ // 'object.subReservation.reservationNumber': { $exists: true }
154
+ // }
155
+ // }
156
+ // ],
157
+ // discontinue(2026-08-12~)
158
+ // [
159
+ // { 'object.subReservation.reservationFor.id': 1, startDate: -1 },
160
+ // {
161
+ // name: 'searchByObjectSubReservationsReservationForId',
162
+ // partialFilterExpression: {
163
+ // 'object.subReservation.reservationFor.id': { $exists: true }
164
+ // }
165
+ // }
166
+ // ],
163
167
  [
164
168
  { 'object.subReservation.reservedTicket.ticketedSeat.seatNumber': 1, startDate: -1 },
165
169
  {
@@ -178,15 +182,16 @@ const indexes = [
178
182
  }
179
183
  }
180
184
  ],
181
- [
182
- { 'object.underName.id': 1, startDate: -1 },
183
- {
184
- name: 'searchByObjectUnderNameId',
185
- partialFilterExpression: {
186
- 'object.underName.id': { $exists: true }
187
- }
188
- }
189
- ],
185
+ // discontinue(2026-08-12~)
186
+ // [
187
+ // { 'object.underName.id': 1, startDate: -1 },
188
+ // {
189
+ // name: 'searchByObjectUnderNameId',
190
+ // partialFilterExpression: {
191
+ // 'object.underName.id': { $exists: true }
192
+ // }
193
+ // }
194
+ // ],
190
195
  [
191
196
  { 'object.reservationNumber': 1, startDate: -1 },
192
197
  {
@@ -217,42 +222,46 @@ const indexes = [
217
222
  partialFilterExpression: { 'object.reservations.reservationFor.id': { $exists: true } }
218
223
  }
219
224
  ],
220
- [
221
- { 'object.fromLocation.identifier': 1, startDate: -1 },
222
- {
223
- name: 'searchByObjectFromLocationIdentifier',
224
- partialFilterExpression: {
225
- 'object.fromLocation.identifier': { $exists: true }
226
- }
227
- }
228
- ],
229
- [
230
- { 'object.toLocation.identifier': 1, startDate: -1 },
231
- {
232
- name: 'searchByObjectToLocationIdentifier',
233
- partialFilterExpression: {
234
- 'object.toLocation.identifier': { $exists: true }
235
- }
236
- }
237
- ],
238
- [
239
- { 'object.pendingTransaction.identifier': 1, startDate: -1 },
240
- {
241
- name: 'searchByObjectPendingTransactionIdentifier',
242
- partialFilterExpression: {
243
- 'object.pendingTransaction.identifier': { $exists: true }
244
- }
245
- }
246
- ],
247
- [
248
- { 'object.itemOffered.serviceOutput.identifier': 1, startDate: -1 },
249
- {
250
- name: 'searchByObjectItemOfferedServiceOutputIdentifier',
251
- partialFilterExpression: {
252
- 'object.itemOffered.serviceOutput.identifier': { $exists: true }
253
- }
254
- }
255
- ],
225
+ // discontinue(2026-08-12~)
226
+ // [
227
+ // { 'object.fromLocation.identifier': 1, startDate: -1 },
228
+ // {
229
+ // name: 'searchByObjectFromLocationIdentifier',
230
+ // partialFilterExpression: {
231
+ // 'object.fromLocation.identifier': { $exists: true }
232
+ // }
233
+ // }
234
+ // ],
235
+ // discontinue(2026-08-12~)
236
+ // [
237
+ // { 'object.toLocation.identifier': 1, startDate: -1 },
238
+ // {
239
+ // name: 'searchByObjectToLocationIdentifier',
240
+ // partialFilterExpression: {
241
+ // 'object.toLocation.identifier': { $exists: true }
242
+ // }
243
+ // }
244
+ // ],
245
+ // discontinue(2026-08-12~)
246
+ // [
247
+ // { 'object.pendingTransaction.identifier': 1, startDate: -1 },
248
+ // {
249
+ // name: 'searchByObjectPendingTransactionIdentifier',
250
+ // partialFilterExpression: {
251
+ // 'object.pendingTransaction.identifier': { $exists: true }
252
+ // }
253
+ // }
254
+ // ],
255
+ // discontinue(2026-08-12~)
256
+ // [
257
+ // { 'object.itemOffered.serviceOutput.identifier': 1, startDate: -1 },
258
+ // {
259
+ // name: 'searchByObjectItemOfferedServiceOutputIdentifier',
260
+ // partialFilterExpression: {
261
+ // 'object.itemOffered.serviceOutput.identifier': { $exists: true }
262
+ // }
263
+ // }
264
+ // ],
256
265
  [
257
266
  { 'object.typeOf': 1, startDate: -1 },
258
267
  {
@@ -0,0 +1,12 @@
1
+ import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
+ import { IVirtuals } from '../virtuals';
3
+ import { factory } from '../../../factory';
4
+ type Keys = 'actionStatus' | 'agent' | 'endDate' | 'error' | 'instrument' | 'object' | 'project' | 'result' | 'sameAs' | 'startDate' | 'targetCollection' | 'typeOf';
5
+ type IDocType = Pick<factory.action.update.add.IAction, Keys> | Pick<factory.action.update.replace.IAction, Keys> | Pick<factory.action.update.update.IAction, Keys> | Pick<factory.action.update.deleteAction.IAction, Keys>;
6
+ type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
7
+ type ISchemaDefinition = SchemaDefinition<IDocType>;
8
+ type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition, IDocType>;
9
+ declare const modelName = "UpdateAction";
10
+ declare const indexes: [d: IndexDefinition, o: IndexOptions][];
11
+ declare function createSchema(): ISchema;
12
+ export { createSchema, IDocType, IModel, indexes, modelName };
@@ -0,0 +1,107 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.modelName = exports.indexes = void 0;
4
+ exports.createSchema = createSchema;
5
+ const mongoose_1 = require("mongoose");
6
+ const writeConcern_1 = require("../writeConcern");
7
+ const settings_1 = require("../../../settings");
8
+ const modelName = 'UpdateAction';
9
+ exports.modelName = modelName;
10
+ const schemaDefinition = {
11
+ project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
+ actionStatus: { type: String, required: true },
13
+ typeOf: { type: String, required: true },
14
+ agent: { type: mongoose_1.SchemaTypes.Mixed, required: true },
15
+ object: { type: mongoose_1.SchemaTypes.Mixed, required: true },
16
+ startDate: { type: Date, required: true },
17
+ result: mongoose_1.SchemaTypes.Mixed,
18
+ error: mongoose_1.SchemaTypes.Mixed,
19
+ endDate: Date,
20
+ instrument: mongoose_1.SchemaTypes.Mixed,
21
+ targetCollection: mongoose_1.SchemaTypes.Mixed,
22
+ sameAs: mongoose_1.SchemaTypes.Mixed,
23
+ };
24
+ const schemaOptions = {
25
+ autoIndex: settings_1.MONGO_AUTO_INDEX,
26
+ autoCreate: false,
27
+ collection: 'updateActions',
28
+ id: true,
29
+ read: 'primary',
30
+ writeConcern: writeConcern_1.writeConcern,
31
+ strict: true,
32
+ strictQuery: false,
33
+ timestamps: false,
34
+ versionKey: false,
35
+ toJSON: {
36
+ getters: false,
37
+ virtuals: false,
38
+ minimize: false,
39
+ versionKey: false
40
+ },
41
+ toObject: {
42
+ getters: false,
43
+ virtuals: true,
44
+ minimize: false,
45
+ versionKey: false
46
+ }
47
+ };
48
+ const indexes = [
49
+ [
50
+ { startDate: 1 },
51
+ {
52
+ name: 'ttlByStartDate',
53
+ expireAfterSeconds: 2592000 // 30 days
54
+ }
55
+ ],
56
+ [
57
+ { 'project.id': 1, startDate: 1 },
58
+ { name: 'projectId' }
59
+ ],
60
+ [
61
+ { typeOf: 1, startDate: 1 },
62
+ { name: 'typeOf' }
63
+ ],
64
+ [
65
+ { 'object.id': 1, startDate: 1 },
66
+ {
67
+ name: 'objectId',
68
+ partialFilterExpression: {
69
+ 'object.id': { $exists: true }
70
+ }
71
+ }
72
+ ],
73
+ [
74
+ { 'result.id': 1, startDate: 1 },
75
+ {
76
+ name: 'resultId',
77
+ partialFilterExpression: {
78
+ 'result.id': { $exists: true }
79
+ }
80
+ }
81
+ ],
82
+ [
83
+ { 'sameAs.id': 1, startDate: 1 },
84
+ {
85
+ name: 'sameAsId',
86
+ partialFilterExpression: {
87
+ 'sameAs.id': { $exists: true }
88
+ }
89
+ }
90
+ ],
91
+ ];
92
+ exports.indexes = indexes;
93
+ /**
94
+ * 編集アクションスキーマ
95
+ */
96
+ let schema;
97
+ function createSchema() {
98
+ if (schema === undefined) {
99
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
100
+ }
101
+ if (settings_1.MONGO_AUTO_INDEX) {
102
+ indexes.forEach((indexParams) => {
103
+ schema?.index(...indexParams);
104
+ });
105
+ }
106
+ return schema;
107
+ }
@@ -39,10 +39,4 @@ export declare class TicketRepo {
39
39
  */
40
40
  issueByTicketToken(params: IIssueParams): Promise<Pick<ITicket, 'id'>>;
41
41
  findTickets(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<ITicket[]>;
42
- /**
43
- * 発行日時を一定期間過ぎたチケットを削除する
44
- */
45
- deleteTicketsByDateIssued(params: {
46
- dateIssuedLt: Date;
47
- }): Promise<void>;
48
42
  }
@@ -81,16 +81,5 @@ class TicketRepo {
81
81
  .lean() // 2024-08-20~
82
82
  .exec();
83
83
  }
84
- /**
85
- * 発行日時を一定期間過ぎたチケットを削除する
86
- */
87
- async deleteTicketsByDateIssued(params) {
88
- await this.ticketModel.deleteMany({
89
- dateIssued: {
90
- $lt: params.dateIssuedLt
91
- }
92
- })
93
- .exec();
94
- }
95
84
  }
96
85
  exports.TicketRepo = TicketRepo;
@@ -0,0 +1,56 @@
1
+ import { Connection, FilterQuery } from 'mongoose';
2
+ import { factory } from '../factory';
3
+ import { IDocType } from './mongoose/schemas/updateAction';
4
+ type StartableActionType = factory.actionType.AddAction | factory.actionType.UpdateAction | factory.actionType.ReplaceAction | factory.actionType.DeleteAction;
5
+ type IAction<T extends StartableActionType> = T extends factory.actionType.AddAction ? factory.action.update.add.IAction : T extends factory.actionType.ReplaceAction ? factory.action.update.replace.IAction : T extends factory.actionType.UpdateAction ? factory.action.update.update.IAction : T extends factory.actionType.DeleteAction ? factory.action.update.deleteAction.IAction : never;
6
+ type IKeyOfProjection = keyof IDocType;
7
+ type IFindParams = Pick<factory.action.ISearchConditions, 'limit' | 'page' | 'project' | 'sort' | 'startFrom' | 'startThrough'> & {
8
+ id?: string;
9
+ typeOf?: StartableActionType;
10
+ object?: {
11
+ id?: string;
12
+ };
13
+ result?: {
14
+ id?: string;
15
+ };
16
+ };
17
+ /**
18
+ * リソース編集アクションリポジトリ
19
+ */
20
+ export declare class UpdateActionRepo {
21
+ private readonly updateActionModel;
22
+ constructor(connection: Connection);
23
+ static CREATE_MONGO_CONDITIONS(params: IFindParams): FilterQuery<IDocType>[];
24
+ /**
25
+ * アクション開始
26
+ */
27
+ startUpdateAction<T extends StartableActionType>(attributes: factory.action.IAttributes<T, any, any>): Promise<Pick<IAction<T>, 'id' | 'typeOf' | 'startDate'>>;
28
+ completeUpdateAction(params: {
29
+ typeOf: StartableActionType;
30
+ id: string;
31
+ result: any;
32
+ }): Promise<void>;
33
+ /**
34
+ * アクション失敗
35
+ */
36
+ giveUpUpdateAction(params: {
37
+ typeOf: StartableActionType;
38
+ id: string;
39
+ error: Error | Error[] | unknown;
40
+ }): Promise<void>;
41
+ findUpdateActions(params: IFindParams, inclusion: IKeyOfProjection[]): Promise<IAction<StartableActionType>[]>;
42
+ findUpdateActionsBySameAs(params: {
43
+ sameAs: {
44
+ id: {
45
+ $eq: string;
46
+ };
47
+ };
48
+ /**
49
+ * 1taskから複数actionが発生する可能性があるので、typeOf指定が必須
50
+ */
51
+ typeOf: {
52
+ $eq: StartableActionType;
53
+ };
54
+ }): Promise<Pick<IAction<StartableActionType>, 'id' | 'actionStatus' | 'error'>[]>;
55
+ }
56
+ export {};
@@ -0,0 +1,173 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UpdateActionRepo = void 0;
4
+ const factory_1 = require("../factory");
5
+ const settings_1 = require("../settings");
6
+ const updateAction_1 = require("./mongoose/schemas/updateAction");
7
+ const AVAILABLE_PROJECT_FIELDS = [
8
+ 'project',
9
+ 'actionStatus',
10
+ 'typeOf',
11
+ 'agent',
12
+ 'result',
13
+ 'error',
14
+ 'object',
15
+ 'startDate',
16
+ 'endDate',
17
+ 'instrument',
18
+ 'targetCollection',
19
+ 'sameAs',
20
+ ];
21
+ // 内部で正規化関数を定義(または外部ヘルパーを呼び出す)
22
+ function unknown2actionError(e) {
23
+ if (e instanceof Error) {
24
+ // Errorオブジェクトの場合は、既存のロジック通り展開
25
+ return { ...e, name: e.name, message: e.message };
26
+ }
27
+ else {
28
+ // Error以外(文字列など)が投げられた場合のハンドリング
29
+ return { name: 'UnknownError', message: String(e) };
30
+ }
31
+ }
32
+ ;
33
+ /**
34
+ * リソース編集アクションリポジトリ
35
+ */
36
+ class UpdateActionRepo {
37
+ updateActionModel;
38
+ constructor(connection) {
39
+ this.updateActionModel = connection.model(updateAction_1.modelName, (0, updateAction_1.createSchema)());
40
+ }
41
+ static CREATE_MONGO_CONDITIONS(params) {
42
+ const andConditions = [];
43
+ const idEq = params.id;
44
+ if (typeof idEq === 'string') {
45
+ andConditions.push({ _id: { $eq: idEq } });
46
+ }
47
+ const projectIdEq = params.project?.id?.$eq;
48
+ if (typeof projectIdEq === 'string') {
49
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
50
+ }
51
+ const objectIdEq = params.object?.id;
52
+ if (typeof objectIdEq === 'string') {
53
+ andConditions.push({ 'object.id': { $exists: true, $eq: objectIdEq } });
54
+ }
55
+ const resultIdEq = params.result?.id;
56
+ if (typeof resultIdEq === 'string') {
57
+ andConditions.push({ 'result.id': { $exists: true, $eq: resultIdEq } });
58
+ }
59
+ if (typeof params.typeOf === 'string') {
60
+ andConditions.push({ typeOf: { $eq: params.typeOf } });
61
+ }
62
+ const startDateGte = params.startFrom;
63
+ if (startDateGte instanceof Date) {
64
+ andConditions.push({ startDate: { $gte: startDateGte } });
65
+ }
66
+ const startDateLte = params.startThrough;
67
+ if (startDateLte instanceof Date) {
68
+ andConditions.push({ startDate: { $lte: startDateLte } });
69
+ }
70
+ return andConditions;
71
+ }
72
+ /**
73
+ * アクション開始
74
+ */
75
+ async startUpdateAction(attributes) {
76
+ const startDate = new Date();
77
+ const creatingAction = {
78
+ ...attributes,
79
+ actionStatus: factory_1.factory.actionStatusType.ActiveActionStatus,
80
+ startDate
81
+ };
82
+ const result = await this.updateActionModel.insertMany(creatingAction, { rawResult: true });
83
+ const id = result.insertedIds?.[0]?.toHexString();
84
+ if (typeof id !== 'string') {
85
+ throw new factory_1.factory.errors.Internal('action not saved');
86
+ }
87
+ return { id, startDate, typeOf: creatingAction.typeOf };
88
+ }
89
+ async completeUpdateAction(params) {
90
+ const doc = await this.updateActionModel.findOneAndUpdate({
91
+ _id: { $eq: params.id },
92
+ typeOf: { $eq: params.typeOf }
93
+ }, {
94
+ $set: {
95
+ actionStatus: factory_1.factory.actionStatusType.CompletedActionStatus,
96
+ result: params.result,
97
+ endDate: new Date()
98
+ }
99
+ }, { new: false, projection: { _id: 1 } })
100
+ .lean()
101
+ .exec();
102
+ if (doc === null) {
103
+ throw new factory_1.factory.errors.NotFound(this.updateActionModel.modelName);
104
+ }
105
+ }
106
+ /**
107
+ * アクション失敗
108
+ */
109
+ async giveUpUpdateAction(params) {
110
+ const actionError = Array.isArray(params.error)
111
+ ? params.error.map(unknown2actionError)
112
+ : unknown2actionError(params.error);
113
+ const doc = await this.updateActionModel.findOneAndUpdate({
114
+ typeOf: { $eq: params.typeOf },
115
+ _id: { $eq: params.id }
116
+ }, {
117
+ $set: {
118
+ actionStatus: factory_1.factory.actionStatusType.FailedActionStatus,
119
+ error: actionError,
120
+ endDate: new Date()
121
+ }
122
+ }, { new: true, projection: { _id: 1 } })
123
+ .lean()
124
+ .exec();
125
+ if (doc === null) {
126
+ throw new factory_1.factory.errors.NotFound(this.updateActionModel.modelName);
127
+ }
128
+ }
129
+ async findUpdateActions(params, inclusion) {
130
+ const conditions = UpdateActionRepo.CREATE_MONGO_CONDITIONS(params);
131
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
132
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
133
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
134
+ }
135
+ const projection = {
136
+ _id: 0,
137
+ id: { $toString: '$_id' },
138
+ ...Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1])))
139
+ };
140
+ const query = this.updateActionModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
141
+ if (typeof params.limit === 'number' && params.limit > 0) {
142
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
143
+ query.limit(params.limit)
144
+ .skip(params.limit * (page - 1));
145
+ }
146
+ /* istanbul ignore else */
147
+ if (params.sort?.startDate !== undefined) {
148
+ query.sort({ startDate: params.sort.startDate });
149
+ }
150
+ // const explainResult = await (<any>query).explain();
151
+ // console.log(explainResult[0].executionStats.allPlansExecution.map((e: any) => e.executionStages.inputStage));
152
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
153
+ .lean() // 2024-08-26~
154
+ .exec();
155
+ }
156
+ async findUpdateActionsBySameAs(params) {
157
+ const projection = {
158
+ _id: 0,
159
+ id: { $toString: '$_id' },
160
+ actionStatus: 1,
161
+ error: 1
162
+ };
163
+ const query = this.updateActionModel.find({
164
+ typeOf: { $eq: params.typeOf.$eq },
165
+ 'sameAs.id': { $exists: true, $eq: params.sameAs.id.$eq }
166
+ }, projection)
167
+ .limit(1);
168
+ return query
169
+ .lean()
170
+ .exec();
171
+ }
172
+ }
173
+ exports.UpdateActionRepo = UpdateActionRepo;
@@ -103,6 +103,7 @@ import type { PlaceOrderRepo } from './repo/transaction/placeOrder';
103
103
  import type { ReturnOrderRepo } from './repo/transaction/returnOrder';
104
104
  import type { TransactionNumberRepo } from './repo/transactionNumber';
105
105
  import type { TransactionProcessRepo } from './repo/transactionProcess';
106
+ import type { UpdateActionRepo } from './repo/updateAction';
106
107
  import type { WebSiteRepo } from './repo/webSite';
107
108
  import type { ConfirmationNumberRepo } from './repo/confirmationNumber';
108
109
  import type { OrderNumberRepo } from './repo/orderNumber';
@@ -557,6 +558,10 @@ export declare namespace rateLimit {
557
558
  function createInstance(...params: ConstructorParameters<typeof OfferRateLimitRepo>): Promise<OfferRateLimitRepo>;
558
559
  }
559
560
  }
561
+ export type UpdateAction = UpdateActionRepo;
562
+ export declare namespace UpdateAction {
563
+ function createInstance(...params: ConstructorParameters<typeof UpdateActionRepo>): Promise<UpdateActionRepo>;
564
+ }
560
565
  export type WebSite = WebSiteRepo;
561
566
  export declare namespace WebSite {
562
567
  function createInstance(...params: ConstructorParameters<typeof WebSiteRepo>): Promise<WebSiteRepo>;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OrderInTransaction = exports.Order = exports.Offer = exports.OfferItemCondition = exports.OfferCatalogItem = exports.OfferCatalog = exports.NoteAboutOrder = exports.Note = exports.MovieTicketType = exports.Message = exports.MerchantReturnPolicy = exports.MemberProgram = exports.Member = exports.Issuer = exports.IdentityProvider = exports.Identity = exports.EventSeries = exports.EventSellerMakesOffer = exports.EventOffer = exports.Event = exports.EmailMessage = exports.CustomerType = exports.Customer = exports.Credentials = exports.CreativeWork = exports.ConfirmationNumber = exports.Authorization = exports.CategoryCode = exports.assetTransaction = exports.AssetTransaction = exports.Aggregation = exports.AggregateReservation = exports.AggregateOrder = exports.AggregateOffer = exports.AggregateAssetTransaction = exports.AggregateTransaction = exports.AggregateTask = exports.AggregateScheduledTask = exports.AggregateAction = exports.AdminTransaction = exports.AdminTask = exports.AdminScheduledTask = exports.AdminAsyncAction = exports.AdminAssetTransaction = exports.AdditionalProperty = exports.action = exports.Action = exports.AccountTitle = exports.AccountingReport = exports.AcceptedOffer = void 0;
4
- exports.WebSite = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.AsyncAction = exports.TaskDelayed = exports.Task = exports.ScheduledTask = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OrderNumber = void 0;
4
+ exports.WebSite = exports.UpdateAction = exports.rateLimit = exports.TransactionProcess = exports.TransactionNumber = exports.transaction = exports.Transaction = exports.Ticket = exports.AsyncAction = exports.TaskDelayed = exports.Task = exports.ScheduledTask = exports.StockHolder = exports.setting = exports.Setting = exports.ServiceAvailableHour = exports.SellerReturnPolicy = exports.SellerPaymentAccepted = exports.SellerMakesOffer = exports.Seller = exports.Schedule = exports.Role = exports.ReserveInterface = exports.Reservation = exports.ProjectMakesOffer = exports.Project = exports.ProductHasOfferCatalog = exports.Product = exports.PriceSpecification = exports.PotentialAction = exports.place = exports.Person = exports.PendingReservation = exports.PaymentServiceProvider = exports.PaymentServiceChannel = exports.PaymentService = exports.Passport = exports.OrderNumber = void 0;
5
5
  var AcceptedOffer;
6
6
  (function (AcceptedOffer) {
7
7
  let repo;
@@ -1193,6 +1193,17 @@ var rateLimit;
1193
1193
  Offer.createInstance = createInstance;
1194
1194
  })(Offer = rateLimit.Offer || (rateLimit.Offer = {}));
1195
1195
  })(rateLimit || (exports.rateLimit = rateLimit = {}));
1196
+ var UpdateAction;
1197
+ (function (UpdateAction) {
1198
+ let repo;
1199
+ async function createInstance(...params) {
1200
+ if (repo === undefined) {
1201
+ repo = (await import('./repo/updateAction.js')).UpdateActionRepo;
1202
+ }
1203
+ return new repo(...params);
1204
+ }
1205
+ UpdateAction.createInstance = createInstance;
1206
+ })(UpdateAction || (exports.UpdateAction = UpdateAction = {}));
1196
1207
  var WebSite;
1197
1208
  (function (WebSite) {
1198
1209
  let repo;
@@ -1,5 +1,5 @@
1
1
  import type { COA } from '@motionpicture/coa-service';
2
- import type { ActionRepo } from '../../repo/action';
2
+ import type { UpdateActionRepo } from '../../repo/updateAction';
3
3
  import type { CategoryCodeRepo } from '../../repo/categoryCode';
4
4
  import type { MovieTheaterRepo } from '../../repo/place/movieTheater';
5
5
  import type { ScreeningRoomRepo } from '../../repo/place/screeningRoom';
@@ -9,7 +9,7 @@ import { IImportFromCOAParams } from './factory';
9
9
  type IMovieTheater = Pick<factory.place.movieTheater.IPlace, 'id' | 'typeOf' | 'branchCode' | 'name' | 'kanaName'>;
10
10
  declare function processUpdateMovieTheater(params: IImportFromCOAParams): (repos: {
11
11
  masterService: COA.service.Master;
12
- action: ActionRepo;
12
+ updateAction: UpdateActionRepo;
13
13
  categoryCode: CategoryCodeRepo;
14
14
  movieTheater: MovieTheaterRepo;
15
15
  screeningRoom: ScreeningRoomRepo;
@@ -20,7 +20,7 @@ function processUpdateMovieTheater(params) {
20
20
  },
21
21
  targetCollection: { typeOf: factory_1.factory.placeType.MovieTheater }
22
22
  };
23
- const action = await repos.action.start(actionAttributes);
23
+ const action = await repos.updateAction.startUpdateAction(actionAttributes);
24
24
  let seller;
25
25
  let movieTheater;
26
26
  let screeningRooms;
@@ -66,7 +66,7 @@ function processUpdateMovieTheater(params) {
66
66
  }
67
67
  catch (error) {
68
68
  try {
69
- await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
69
+ await repos.updateAction.giveUpUpdateAction({ typeOf: action.typeOf, id: action.id, error });
70
70
  }
71
71
  catch (__) {
72
72
  // 失敗したら仕方ない
@@ -77,7 +77,7 @@ function processUpdateMovieTheater(params) {
77
77
  screeningRoomsCount: screeningRooms.length,
78
78
  ...(processTime !== undefined) ? { processTime } : undefined
79
79
  };
80
- await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
80
+ await repos.updateAction.completeUpdateAction({ typeOf: action.typeOf, id: action.id, result: actionResult });
81
81
  return { seller, movieTheater, screeningRooms };
82
82
  };
83
83
  }