@chevre/domain 28.0.0-alpha.1 → 28.0.0-alpha.10
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/lib/chevre/eventEmitter/transaction.d.ts +2 -2
- package/lib/chevre/eventEmitter/transaction.js +1 -1
- package/lib/chevre/repo/adminEvent.d.ts +0 -6
- package/lib/chevre/repo/adminEvent.js +3 -9
- package/lib/chevre/repo/adminEventSeries.d.ts +89 -0
- package/lib/chevre/repo/adminEventSeries.js +174 -0
- package/lib/chevre/repo/adminTransaction.d.ts +35 -39
- package/lib/chevre/repo/adminTransaction.js +0 -98
- package/lib/chevre/repo/aggregateEvent.js +0 -1
- package/lib/chevre/repo/aggregateTransaction.d.ts +0 -1
- package/lib/chevre/repo/aggregateTransaction.js +0 -1
- package/lib/chevre/repo/event.d.ts +2 -2
- package/lib/chevre/repo/event.js +71 -110
- package/lib/chevre/repo/eventSeries.d.ts +3 -82
- package/lib/chevre/repo/eventSeries.js +3 -201
- package/lib/chevre/repo/mongoose/schemas/transaction.d.ts +2 -3
- package/lib/chevre/repo/mongoose/schemas/transaction.js +81 -70
- package/lib/chevre/repo/order.js +3 -1
- package/lib/chevre/repo/orderInTransaction.js +0 -6
- package/lib/chevre/repo/place/{hasPOS.d.ts → pos.d.ts} +3 -7
- package/lib/chevre/repo/place/{hasPOS.js → pos.js} +14 -13
- package/lib/chevre/repo/place/screeningRoom.d.ts +22 -1
- package/lib/chevre/repo/place/screeningRoom.js +28 -17
- package/lib/chevre/repo/transaction/placeOrder.d.ts +6 -12
- package/lib/chevre/repo/transaction/placeOrder.js +53 -146
- package/lib/chevre/repo/transaction/returnOrderInProgress.d.ts +1 -1
- package/lib/chevre/repo/transaction.d.ts +1 -1
- package/lib/chevre/repo/transaction.js +0 -1
- package/lib/chevre/repository.d.ts +10 -5
- package/lib/chevre/repository.js +19 -8
- package/lib/chevre/service/aggregation/event/aggregateOffers.js +1 -2
- package/lib/chevre/service/aggregation/event/aggregateScreeningEvent.js +0 -1
- package/lib/chevre/service/aggregation/system.js +1 -3
- package/lib/chevre/service/assetTransaction/pay/start/preStart/validateAcceptedPaymentMethodIfNeeded.js +1 -2
- package/lib/chevre/service/event/saveScreeningEventSeries.d.ts +2 -2
- package/lib/chevre/service/event/saveScreeningEventSeries.js +1 -1
- package/lib/chevre/service/event/saveScreeningEvents.d.ts +2 -0
- package/lib/chevre/service/event.d.ts +2 -0
- package/lib/chevre/service/event.js +0 -1
- package/lib/chevre/service/offer/event/authorize/factory.d.ts +2 -2
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +1 -1
- package/lib/chevre/service/offer/event/authorize.js +1 -4
- package/lib/chevre/service/offer/event/issueEventOfferTicket.js +1 -1
- package/lib/chevre/service/offer/event/voidTransaction.js +2 -5
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +1 -4
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +2 -9
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +1 -4
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +1 -4
- package/lib/chevre/service/offer/onEventChanged.js +2 -4
- package/lib/chevre/service/offer.js +1 -2
- package/lib/chevre/service/order/onAssetTransactionStatusChanged/onPayTransactionCanceled.js +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderInTransit.js +1 -1
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +1 -1
- package/lib/chevre/service/payment/any/authorize.js +1 -1
- package/lib/chevre/service/payment/any/factory.d.ts +2 -2
- package/lib/chevre/service/payment/any/invalidatePaymentUrl.js +1 -4
- package/lib/chevre/service/payment/any/processVoidPayTransaction.js +2 -2
- package/lib/chevre/service/payment/any/publishPaymentUrl.js +1 -1
- package/lib/chevre/service/task/importEventsFromCOA.js +2 -0
- package/lib/chevre/service/task/onResourceDeleted.js +2 -2
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.d.ts +2 -2
- package/lib/chevre/service/task/onResourceUpdated/onHasPOSUpdated.js +3 -4
- package/lib/chevre/service/task/onResourceUpdated.js +2 -2
- package/lib/chevre/service/task/syncResourcesFromCOA.js +3 -1
- package/lib/chevre/service/transaction/deleteTransaction.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/confirm.js +1 -2
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +2 -2
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +1 -4
- package/lib/chevre/service/transaction/placeOrder/start.js +1 -1
- package/lib/chevre/service/transaction/placeOrder/updateAgent.js +1 -4
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +1 -3
- package/lib/chevre/service/transaction/returnOrder/preStart.d.ts +13 -1
- package/lib/chevre/service/transaction/returnOrder/preStart.js +1 -2
- package/lib/chevre/service/transaction/returnOrder.d.ts +14 -3
- package/lib/chevre/service/transaction/returnOrder.js +1 -6
- package/lib/chevre/service/transaction.d.ts +1 -1
- package/package.json +2 -2
package/lib/chevre/repo/event.js
CHANGED
|
@@ -22,18 +22,18 @@ class EventRepo {
|
|
|
22
22
|
}
|
|
23
23
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
24
24
|
const andConditions = [];
|
|
25
|
-
const typeOfEq = conditions.typeOf;
|
|
26
|
-
if (typeof typeOfEq === 'string') {
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
const typeOfIn = conditions.typeOfIn;
|
|
30
|
-
if (Array.isArray(typeOfIn)) {
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
// typeOf条件必須検証(2023-07-13~)
|
|
34
|
-
if (typeof typeOfEq !== 'string' && !Array.isArray(typeOfIn)) {
|
|
35
|
-
|
|
36
|
-
}
|
|
25
|
+
// const typeOfEq = conditions.typeOf;
|
|
26
|
+
// if (typeof typeOfEq === 'string') {
|
|
27
|
+
// andConditions.push({ typeOf: { $eq: typeOfEq } });
|
|
28
|
+
// }
|
|
29
|
+
// const typeOfIn = conditions.typeOfIn;
|
|
30
|
+
// if (Array.isArray(typeOfIn)) {
|
|
31
|
+
// andConditions.push({ typeOf: { $in: typeOfIn } });
|
|
32
|
+
// }
|
|
33
|
+
// // typeOf条件必須検証(2023-07-13~)
|
|
34
|
+
// if (typeof typeOfEq !== 'string' && !Array.isArray(typeOfIn)) {
|
|
35
|
+
// throw new factory.errors.ArgumentNull('typeOf');
|
|
36
|
+
// }
|
|
37
37
|
const projectIdEq = conditions.project?.id?.$eq;
|
|
38
38
|
if (typeof projectIdEq === 'string') {
|
|
39
39
|
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
@@ -113,110 +113,72 @@ class EventRepo {
|
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
// $or: [
|
|
124
|
-
// {
|
|
125
|
-
// 'name.ja': {
|
|
126
|
-
// $exists: true,
|
|
127
|
-
// $regex: new RegExp(params.name)
|
|
128
|
-
// }
|
|
129
|
-
// },
|
|
130
|
-
// {
|
|
131
|
-
// 'name.en': {
|
|
132
|
-
// $exists: true,
|
|
133
|
-
// $regex: new RegExp(params.name)
|
|
134
|
-
// }
|
|
135
|
-
// }
|
|
136
|
-
// ]
|
|
137
|
-
// });
|
|
138
|
-
// }
|
|
139
|
-
/* istanbul ignore else */
|
|
140
|
-
const superEventLocationIdEq = params.superEvent?.location?.id?.$eq;
|
|
141
|
-
if (typeof superEventLocationIdEq === 'string') {
|
|
142
|
-
andConditions.push({
|
|
143
|
-
'superEvent.location.id': {
|
|
144
|
-
$exists: true,
|
|
145
|
-
$eq: superEventLocationIdEq
|
|
146
|
-
}
|
|
147
|
-
});
|
|
116
|
+
/* istanbul ignore else */
|
|
117
|
+
const superEventLocationIdEq = conditions.superEvent?.location?.id?.$eq;
|
|
118
|
+
if (typeof superEventLocationIdEq === 'string') {
|
|
119
|
+
andConditions.push({
|
|
120
|
+
'superEvent.location.id': {
|
|
121
|
+
$exists: true,
|
|
122
|
+
$eq: superEventLocationIdEq
|
|
148
123
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
/* istanbul ignore else */
|
|
127
|
+
if (conditions.superEvent !== undefined) {
|
|
128
|
+
/* istanbul ignore else */
|
|
129
|
+
if (Array.isArray(conditions.superEvent.ids)) {
|
|
130
|
+
andConditions.push({
|
|
131
|
+
'superEvent.id': {
|
|
132
|
+
$exists: true,
|
|
133
|
+
$in: conditions.superEvent.ids
|
|
159
134
|
}
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
/* istanbul ignore else */
|
|
138
|
+
if (Array.isArray(conditions.superEvent.locationBranchCodes)) {
|
|
139
|
+
andConditions.push({
|
|
140
|
+
'superEvent.location.branchCode': {
|
|
141
|
+
$exists: true,
|
|
142
|
+
$in: conditions.superEvent.locationBranchCodes
|
|
168
143
|
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
/* istanbul ignore else */
|
|
147
|
+
if (Array.isArray(conditions.superEvent.workPerformedIdentifiers)) {
|
|
148
|
+
andConditions.push({
|
|
149
|
+
'superEvent.workPerformed.identifier': {
|
|
150
|
+
$exists: true,
|
|
151
|
+
$in: conditions.superEvent.workPerformedIdentifiers
|
|
177
152
|
}
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
const itemOfferedIdIn = conditions.offers?.itemOffered?.id?.$in;
|
|
157
|
+
if (Array.isArray(itemOfferedIdIn)) {
|
|
158
|
+
andConditions.push({
|
|
159
|
+
'offers.itemOffered.id': {
|
|
160
|
+
$exists: true,
|
|
161
|
+
$in: itemOfferedIdIn
|
|
178
162
|
}
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}
|
|
188
|
-
const itemOfferedTicketedSeatTypeOfIn = params.offers?.itemOffered?.serviceOutput?.reservedTicket?.ticketedSeat?.typeOfs;
|
|
189
|
-
if (Array.isArray(itemOfferedTicketedSeatTypeOfIn)) {
|
|
190
|
-
andConditions.push({
|
|
191
|
-
'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
|
|
192
|
-
$exists: true,
|
|
193
|
-
$in: itemOfferedTicketedSeatTypeOfIn
|
|
194
|
-
}
|
|
195
|
-
});
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
const itemOfferedTicketedSeatTypeOfIn = conditions.offers?.itemOffered?.serviceOutput?.reservedTicket?.ticketedSeat?.typeOfs;
|
|
166
|
+
if (Array.isArray(itemOfferedTicketedSeatTypeOfIn)) {
|
|
167
|
+
andConditions.push({
|
|
168
|
+
'offers.itemOffered.serviceOutput.reservedTicket.ticketedSeat.typeOf': {
|
|
169
|
+
$exists: true,
|
|
170
|
+
$in: itemOfferedTicketedSeatTypeOfIn
|
|
196
171
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
// }
|
|
206
|
-
const sellerMakesOfferElemMatch = params.offers?.seller?.makesOffer?.$elemMatch;
|
|
207
|
-
if (typeof sellerMakesOfferElemMatch?.['availableAtOrFrom.id']?.$eq === 'string') {
|
|
208
|
-
andConditions.push({
|
|
209
|
-
'offers.seller.makesOffer': {
|
|
210
|
-
$exists: true,
|
|
211
|
-
$elemMatch: sellerMakesOfferElemMatch
|
|
212
|
-
}
|
|
213
|
-
});
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
const sellerMakesOfferElemMatch = conditions.offers?.seller?.makesOffer?.$elemMatch;
|
|
175
|
+
if (typeof sellerMakesOfferElemMatch?.['availableAtOrFrom.id']?.$eq === 'string') {
|
|
176
|
+
andConditions.push({
|
|
177
|
+
'offers.seller.makesOffer': {
|
|
178
|
+
$exists: true,
|
|
179
|
+
$elemMatch: sellerMakesOfferElemMatch
|
|
214
180
|
}
|
|
215
|
-
|
|
216
|
-
}
|
|
217
|
-
case factory_1.factory.eventType.ScreeningEventSeries: // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
218
|
-
throw new factory_1.factory.errors.Internal('typeOf: ScreeningEventSeries discontinued');
|
|
219
|
-
default:
|
|
181
|
+
});
|
|
220
182
|
}
|
|
221
183
|
return andConditions;
|
|
222
184
|
}
|
|
@@ -339,7 +301,6 @@ class EventRepo {
|
|
|
339
301
|
const doc = await this.eventModel.findOne({
|
|
340
302
|
_id: { $eq: params.id.$eq },
|
|
341
303
|
'project.id': { $eq: params.project.id.$eq },
|
|
342
|
-
typeOf: { $in: [factory_1.factory.eventType.ScreeningEvent] },
|
|
343
304
|
...(typeof params.organizer?.id.$eq === 'string')
|
|
344
305
|
? { 'organizer.id': { $exists: true, $eq: params.organizer.id.$eq } }
|
|
345
306
|
: undefined
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import type { Connection, FilterQuery
|
|
1
|
+
import type { Connection, FilterQuery } from 'mongoose';
|
|
2
2
|
import { factory } from '../factory';
|
|
3
3
|
type ISearchConditions = factory.eventSeries.ISearchConditions;
|
|
4
4
|
type IKeyOfProjection = Exclude<keyof factory.eventSeries.IEvent, 'id' | 'videoFormat'>;
|
|
5
|
-
type IUnset = {
|
|
6
|
-
[key in keyof factory.eventSeries.IEvent]?: 1;
|
|
7
|
-
};
|
|
8
5
|
/**
|
|
9
6
|
* 施設コンテンツリポジトリ
|
|
10
7
|
*/
|
|
@@ -12,41 +9,10 @@ export declare class EventSeriesRepo {
|
|
|
12
9
|
private readonly eventSeriesModel;
|
|
13
10
|
constructor(connection: Connection);
|
|
14
11
|
static CREATE_MONGO_CONDITIONS(conditions: ISearchConditions): FilterQuery<factory.eventSeries.IEvent>[];
|
|
15
|
-
/**
|
|
16
|
-
* 施設+コンテンツ+バージョンをキーにして冪等置換
|
|
17
|
-
*/
|
|
18
|
-
upsertByVersion(params: {
|
|
19
|
-
$set: factory.eventSeries.IAttributes;
|
|
20
|
-
$unset?: IUnset;
|
|
21
|
-
}[], options: {
|
|
22
|
-
/**
|
|
23
|
-
* falseの場合setOnInsertのみ
|
|
24
|
-
* trueの場合setOnInsert+setのみ
|
|
25
|
-
*/
|
|
26
|
-
upsert: boolean;
|
|
27
|
-
}): Promise<{
|
|
28
|
-
bulkWriteResult?: mongo.BulkWriteResult;
|
|
29
|
-
modifiedEvents: {
|
|
30
|
-
id: string;
|
|
31
|
-
}[];
|
|
32
|
-
}>;
|
|
33
|
-
/**
|
|
34
|
-
* sskts施設コンテンツ保管
|
|
35
|
-
*/
|
|
36
|
-
upsertManyEventSeriesById4sskts(params: {
|
|
37
|
-
id: string;
|
|
38
|
-
attributes: factory.eventSeries.IAttributes;
|
|
39
|
-
}[]): Promise<void>;
|
|
40
12
|
/**
|
|
41
13
|
* イベントを検索する(inclusion projection)
|
|
42
14
|
*/
|
|
43
15
|
projectEventSeriesFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<factory.eventSeries.IEvent[]>;
|
|
44
|
-
deleteEventSeriesById(params: {
|
|
45
|
-
project: {
|
|
46
|
-
id: string;
|
|
47
|
-
};
|
|
48
|
-
id: string;
|
|
49
|
-
}): Promise<void>;
|
|
50
16
|
deleteManyByOrganizerId(params: {
|
|
51
17
|
project: {
|
|
52
18
|
id: string;
|
|
@@ -54,7 +20,7 @@ export declare class EventSeriesRepo {
|
|
|
54
20
|
organizer: {
|
|
55
21
|
id: string;
|
|
56
22
|
};
|
|
57
|
-
}): Promise<
|
|
23
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
58
24
|
deleteManyByLocationId(params: {
|
|
59
25
|
project: {
|
|
60
26
|
id: string;
|
|
@@ -62,51 +28,6 @@ export declare class EventSeriesRepo {
|
|
|
62
28
|
location: {
|
|
63
29
|
id: string;
|
|
64
30
|
};
|
|
65
|
-
}): Promise<
|
|
66
|
-
/**
|
|
67
|
-
* 既存施設コンテンツの最大バージョンを集計する
|
|
68
|
-
*/
|
|
69
|
-
aggregateMaxVersion(params: {
|
|
70
|
-
project: {
|
|
71
|
-
id: {
|
|
72
|
-
$eq: string;
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
workPerformed: {
|
|
76
|
-
identifier: {
|
|
77
|
-
$eq: string;
|
|
78
|
-
};
|
|
79
|
-
};
|
|
80
|
-
location: {
|
|
81
|
-
branchCode: {
|
|
82
|
-
$in: string[];
|
|
83
|
-
};
|
|
84
|
-
};
|
|
85
|
-
}): Promise<{
|
|
86
|
-
maxVersion: string;
|
|
87
|
-
}>;
|
|
88
|
-
getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, Record<string, never>, factory.eventSeries.IAttributes & {
|
|
89
|
-
_id: string;
|
|
90
|
-
}, import("./mongoose/virtuals").IVirtuals, {}> & factory.eventSeries.IAttributes & {
|
|
91
|
-
_id: string;
|
|
92
|
-
} & Required<{
|
|
93
|
-
_id: string;
|
|
94
|
-
}> & {
|
|
95
|
-
__v: number;
|
|
96
|
-
}, import("mongoose").QueryOptions<factory.eventSeries.IAttributes & {
|
|
97
|
-
_id: string;
|
|
98
|
-
}>, (import("mongoose").Document<unknown, Record<string, never>, factory.eventSeries.IAttributes & {
|
|
99
|
-
_id: string;
|
|
100
|
-
}, import("./mongoose/virtuals").IVirtuals, {}> & factory.eventSeries.IAttributes & {
|
|
101
|
-
_id: string;
|
|
102
|
-
} & Required<{
|
|
103
|
-
_id: string;
|
|
104
|
-
}> & {
|
|
105
|
-
__v: number;
|
|
106
|
-
}) | null>;
|
|
107
|
-
unsetUnnecessaryFields(params: {
|
|
108
|
-
filter: FilterQuery<factory.eventSeries.IEvent>;
|
|
109
|
-
$unset: IUnset;
|
|
110
|
-
}): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
31
|
+
}): Promise<import("mongodb").DeleteResult>;
|
|
111
32
|
}
|
|
112
33
|
export {};
|
|
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.EventSeriesRepo = void 0;
|
|
4
4
|
const factory_1 = require("../factory");
|
|
5
5
|
const eventSeries_1 = require("./mongoose/schemas/eventSeries");
|
|
6
|
-
// import { isMongoError, MongoErrorCode } from '../errorHandler';
|
|
7
6
|
const settings_1 = require("../settings");
|
|
8
7
|
/**
|
|
9
8
|
* 施設コンテンツリポジトリ
|
|
@@ -14,10 +13,7 @@ class EventSeriesRepo {
|
|
|
14
13
|
this.eventSeriesModel = connection.model(eventSeries_1.modelName, (0, eventSeries_1.createSchema)());
|
|
15
14
|
}
|
|
16
15
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
17
|
-
const andConditions = [
|
|
18
|
-
// typeOfは必ずScreeningEventSeriesなので不要(2026-02-14~)
|
|
19
|
-
// { typeOf: { $eq: factory.eventType.ScreeningEventSeries } } // fix(2024-09-08~)
|
|
20
|
-
];
|
|
16
|
+
const andConditions = [];
|
|
21
17
|
const projectIdEq = conditions.project?.id?.$eq;
|
|
22
18
|
if (typeof projectIdEq === 'string') {
|
|
23
19
|
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
@@ -34,12 +30,6 @@ class EventSeriesRepo {
|
|
|
34
30
|
if (Array.isArray(idIn)) {
|
|
35
31
|
andConditions.push({ _id: { $in: idIn } });
|
|
36
32
|
}
|
|
37
|
-
// /* istanbul ignore else */
|
|
38
|
-
// if (Array.isArray(conditions.eventStatuses)) {
|
|
39
|
-
// andConditions.push({
|
|
40
|
-
// eventStatus: { $in: conditions.eventStatuses }
|
|
41
|
-
// });
|
|
42
|
-
// }
|
|
43
33
|
/* istanbul ignore else */
|
|
44
34
|
if (conditions.inSessionFrom !== undefined) {
|
|
45
35
|
andConditions.push({
|
|
@@ -158,143 +148,8 @@ class EventSeriesRepo {
|
|
|
158
148
|
if (Array.isArray(videoFormatTypeOfIn)) {
|
|
159
149
|
andConditions.push({ 'subEvent.videoFormat': { $exists: true, $in: videoFormatTypeOfIn } });
|
|
160
150
|
}
|
|
161
|
-
// const soundFormatTypeOfEq = conditions.soundFormat?.typeOf?.$eq;
|
|
162
|
-
// if (typeof soundFormatTypeOfEq === 'string') {
|
|
163
|
-
// andConditions.push({
|
|
164
|
-
// 'soundFormat.typeOf': {
|
|
165
|
-
// $exists: true,
|
|
166
|
-
// $eq: soundFormatTypeOfEq
|
|
167
|
-
// }
|
|
168
|
-
// });
|
|
169
|
-
// }
|
|
170
|
-
// const soundFormatTypeOfIn = conditions.soundFormat?.typeOf?.$in;
|
|
171
|
-
// if (Array.isArray(soundFormatTypeOfIn)) {
|
|
172
|
-
// andConditions.push({
|
|
173
|
-
// 'soundFormat.typeOf': {
|
|
174
|
-
// $exists: true,
|
|
175
|
-
// $in: soundFormatTypeOfIn
|
|
176
|
-
// }
|
|
177
|
-
// });
|
|
178
|
-
// }
|
|
179
151
|
return andConditions;
|
|
180
152
|
}
|
|
181
|
-
/**
|
|
182
|
-
* 施設+コンテンツ+バージョンをキーにして冪等置換
|
|
183
|
-
*/
|
|
184
|
-
async upsertByVersion(params, options) {
|
|
185
|
-
const { upsert } = options;
|
|
186
|
-
const { default: uniqid } = await import('uniqid');
|
|
187
|
-
const bulkWriteOps = [];
|
|
188
|
-
const queryFilters = [];
|
|
189
|
-
if (Array.isArray(params)) {
|
|
190
|
-
params.forEach(({ $set, $unset }) => {
|
|
191
|
-
const version = $set.workPerformed.version;
|
|
192
|
-
if (typeof version !== 'string' || version.length === 0) {
|
|
193
|
-
throw new factory_1.factory.errors.ArgumentNull('workPerformed.version');
|
|
194
|
-
}
|
|
195
|
-
// リソースのユニークネスを保証するfilter
|
|
196
|
-
const filter = {
|
|
197
|
-
typeOf: $set.typeOf,
|
|
198
|
-
'project.id': { $eq: $set.project.id },
|
|
199
|
-
'location.branchCode': { $exists: true, $eq: $set.location.branchCode },
|
|
200
|
-
'workPerformed.identifier': { $exists: true, $eq: $set.workPerformed.identifier },
|
|
201
|
-
'workPerformed.version': { $exists: true, $eq: version }
|
|
202
|
-
};
|
|
203
|
-
queryFilters.push({
|
|
204
|
-
typeOf: $set.typeOf,
|
|
205
|
-
'project.id': { $eq: $set.project.id },
|
|
206
|
-
'location.branchCode': { $exists: true, $eq: $set.location.branchCode },
|
|
207
|
-
'workPerformed.identifier': { $exists: true, $eq: $set.workPerformed.identifier },
|
|
208
|
-
'workPerformed.version': { $exists: true, $eq: version }
|
|
209
|
-
});
|
|
210
|
-
const { identifier, project, typeOf, ...setFields } = $set; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
211
|
-
const setOnInsert = {
|
|
212
|
-
project,
|
|
213
|
-
typeOf,
|
|
214
|
-
_id: uniqid()
|
|
215
|
-
};
|
|
216
|
-
let updateOne;
|
|
217
|
-
if (upsert === true) {
|
|
218
|
-
updateOne = {
|
|
219
|
-
filter,
|
|
220
|
-
update: {
|
|
221
|
-
$setOnInsert: setOnInsert,
|
|
222
|
-
$set: setFields,
|
|
223
|
-
...($unset !== undefined) ? { $unset } : undefined
|
|
224
|
-
},
|
|
225
|
-
upsert: true
|
|
226
|
-
};
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
updateOne = {
|
|
230
|
-
filter,
|
|
231
|
-
update: {
|
|
232
|
-
$setOnInsert: {
|
|
233
|
-
...setOnInsert,
|
|
234
|
-
...setFields
|
|
235
|
-
}
|
|
236
|
-
},
|
|
237
|
-
upsert: true
|
|
238
|
-
};
|
|
239
|
-
}
|
|
240
|
-
bulkWriteOps.push({ updateOne });
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
if (bulkWriteOps.length > 0) {
|
|
244
|
-
const bulkWriteResult = await this.eventSeriesModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
245
|
-
// upsert:falseの場合、upsertedIdsのみmodifiedEventsとして返せばよい(2026-01-27~)
|
|
246
|
-
if (!upsert) {
|
|
247
|
-
// BulkWriteResult -> upsertedIds: { '0': '7iri6p4m54k0r3g' }
|
|
248
|
-
return {
|
|
249
|
-
bulkWriteResult,
|
|
250
|
-
modifiedEvents: Object.values(bulkWriteResult.upsertedIds)
|
|
251
|
-
.map((id) => ({ id: String(id) }))
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
|
-
else {
|
|
255
|
-
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
256
|
-
const modifiedEvents = await this.eventSeriesModel.find({ $or: queryFilters }, { _id: 1 })
|
|
257
|
-
.exec();
|
|
258
|
-
return { bulkWriteResult, modifiedEvents };
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return { modifiedEvents: [] };
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* sskts施設コンテンツ保管
|
|
265
|
-
*/
|
|
266
|
-
async upsertManyEventSeriesById4sskts(params) {
|
|
267
|
-
const bulkWriteOps = [];
|
|
268
|
-
if (Array.isArray(params)) {
|
|
269
|
-
params.forEach((p) => {
|
|
270
|
-
// 上書き禁止属性を除外(2022-08-24~)
|
|
271
|
-
const { identifier, project, typeOf, ...updateFields } = p.attributes; // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
272
|
-
bulkWriteOps.push({
|
|
273
|
-
updateOne: {
|
|
274
|
-
filter: {
|
|
275
|
-
_id: { $eq: p.id },
|
|
276
|
-
typeOf: { $eq: factory_1.factory.eventType.ScreeningEventSeries }
|
|
277
|
-
},
|
|
278
|
-
update: {
|
|
279
|
-
$setOnInsert: {
|
|
280
|
-
typeOf: factory_1.factory.eventType.ScreeningEventSeries,
|
|
281
|
-
project: p.attributes.project,
|
|
282
|
-
...(typeof p.attributes.identifier === 'string')
|
|
283
|
-
? { identifier: p.attributes.identifier } : undefined
|
|
284
|
-
},
|
|
285
|
-
$set: updateFields
|
|
286
|
-
// $unsetに対応(2022-08-31~)
|
|
287
|
-
// ...(p.$unset !== undefined) ? { $unset: p.$unset } : undefined
|
|
288
|
-
},
|
|
289
|
-
upsert: true
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
if (bulkWriteOps.length > 0) {
|
|
295
|
-
await this.eventSeriesModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
296
|
-
}
|
|
297
|
-
}
|
|
298
153
|
/**
|
|
299
154
|
* イベントを検索する(inclusion projection)
|
|
300
155
|
*/
|
|
@@ -337,72 +192,19 @@ class EventSeriesRepo {
|
|
|
337
192
|
.lean() // lean(2024-08-01~)
|
|
338
193
|
.exec();
|
|
339
194
|
}
|
|
340
|
-
async deleteEventSeriesById(params) {
|
|
341
|
-
await this.eventSeriesModel.findOneAndDelete({
|
|
342
|
-
_id: { $eq: params.id },
|
|
343
|
-
'project.id': { $eq: params.project.id },
|
|
344
|
-
typeOf: { $eq: factory_1.factory.eventType.ScreeningEventSeries }
|
|
345
|
-
}, { projection: { _id: 1 } })
|
|
346
|
-
.exec();
|
|
347
|
-
}
|
|
348
195
|
async deleteManyByOrganizerId(params) {
|
|
349
196
|
return this.eventSeriesModel.deleteMany({
|
|
350
197
|
'project.id': { $eq: params.project.id },
|
|
351
|
-
'organizer.id': { $exists: true, $eq: params.organizer.id }
|
|
352
|
-
typeOf: { $eq: factory_1.factory.eventType.ScreeningEventSeries }
|
|
198
|
+
'organizer.id': { $exists: true, $eq: params.organizer.id }
|
|
353
199
|
})
|
|
354
200
|
.exec();
|
|
355
201
|
}
|
|
356
202
|
async deleteManyByLocationId(params) {
|
|
357
203
|
return this.eventSeriesModel.deleteMany({
|
|
358
204
|
'project.id': { $eq: params.project.id },
|
|
359
|
-
'location.id': { $exists: true, $eq: params.location.id }
|
|
360
|
-
typeOf: { $eq: factory_1.factory.eventType.ScreeningEventSeries }
|
|
205
|
+
'location.id': { $exists: true, $eq: params.location.id }
|
|
361
206
|
})
|
|
362
207
|
.exec();
|
|
363
208
|
}
|
|
364
|
-
/**
|
|
365
|
-
* 既存施設コンテンツの最大バージョンを集計する
|
|
366
|
-
*/
|
|
367
|
-
async aggregateMaxVersion(params) {
|
|
368
|
-
const aggregations = await this.eventSeriesModel.aggregate([
|
|
369
|
-
{
|
|
370
|
-
$match: {
|
|
371
|
-
typeOf: { $eq: factory_1.factory.eventType.ScreeningEventSeries },
|
|
372
|
-
'project.id': { $eq: params.project.id.$eq },
|
|
373
|
-
'workPerformed.identifier': { $exists: true, $eq: params.workPerformed.identifier.$eq },
|
|
374
|
-
'workPerformed.version': { $exists: true },
|
|
375
|
-
'location.branchCode': { $exists: true, $in: params.location.branchCode.$in }
|
|
376
|
-
}
|
|
377
|
-
},
|
|
378
|
-
{
|
|
379
|
-
$project: {
|
|
380
|
-
workPerformed: '$workPerformed',
|
|
381
|
-
// version: { $toInt: '$workPerformed.version' }
|
|
382
|
-
version: { $toLong: '$workPerformed.version' } // support YYYYMMDDHHmmss
|
|
383
|
-
}
|
|
384
|
-
},
|
|
385
|
-
{
|
|
386
|
-
$group: {
|
|
387
|
-
_id: '$typeOf',
|
|
388
|
-
maxVersion: { $max: '$version' }
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
])
|
|
392
|
-
.exec();
|
|
393
|
-
const maxVersion = (aggregations.length > 0)
|
|
394
|
-
? String(aggregations.shift()?.maxVersion)
|
|
395
|
-
: '0';
|
|
396
|
-
return { maxVersion };
|
|
397
|
-
}
|
|
398
|
-
getCursor(conditions, projection) {
|
|
399
|
-
return this.eventSeriesModel.find(conditions, projection)
|
|
400
|
-
.sort({ startDate: factory_1.factory.sortType.Descending })
|
|
401
|
-
.cursor();
|
|
402
|
-
}
|
|
403
|
-
async unsetUnnecessaryFields(params) {
|
|
404
|
-
return this.eventSeriesModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
|
|
405
|
-
.exec();
|
|
406
|
-
}
|
|
407
209
|
}
|
|
408
210
|
exports.EventSeriesRepo = EventSeriesRepo;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
2
|
import { IVirtuals } from '../virtuals';
|
|
3
3
|
import { factory } from '../../../factory';
|
|
4
|
-
type IPlaceOrder =
|
|
5
|
-
type
|
|
6
|
-
type IDocType = IPlaceOrder | IReturnOrder;
|
|
4
|
+
type IPlaceOrder = Pick<factory.transaction.placeOrder.ITransaction, 'agent' | 'endDate' | 'expires' | 'instrument' | 'object' | 'project' | 'result' | 'seller' | 'startDate' | 'status' | 'tasksExportAction' | 'typeOf'>;
|
|
5
|
+
type IDocType = IPlaceOrder;
|
|
7
6
|
type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
|
|
8
7
|
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
9
8
|
type ISchema = Schema<IDocType, IModel, Record<string, never>, Record<string, never>, IVirtuals, Record<string, never>, ISchemaDefinition, IDocType>;
|