@chevre/domain 23.0.0-alpha.9 → 23.0.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/example/src/chevre/assetTransaction/processReserve.ts +102 -40
- package/example/src/chevre/categoryCode/checkUniqueness.ts +69 -0
- package/example/src/chevre/event/checkEventAdditionalPropertyUniqueness.ts +108 -0
- package/example/src/chevre/event/migrateEventAdditionalProperty2identifier.ts +121 -0
- package/example/src/chevre/event/updateSellerMakesOffersByIdentifier.ts +106 -0
- package/example/src/chevre/offerCatalog/updateManyOfferCatalogsByIds.ts +49 -0
- package/example/src/chevre/paymentServices/findPaymentServices.ts +37 -0
- package/example/src/chevre/product/findHasOfferCatalog.ts +14 -10
- package/example/src/chevre/reIndex.ts +2 -3
- package/example/src/chevre/roles/{addAdminProductReadPermissionIfNotExists.ts → addAdminPaymentServiceReadPermissionIfNotExists.ts} +1 -1
- package/example/src/chevre/roles/addAdminProductHasOfferCatalogReadPermissionIfNotExists.ts +33 -0
- package/example/src/chevre/roles/addAdminSellerEventIfNotExists.ts +48 -0
- package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -1
- package/example/src/chevre/roles/removePermissionIfExists.ts +1 -6
- package/example/src/objectId.ts +12 -0
- package/example/src/signPayload.ts +12 -7
- package/lib/chevre/errorHandler.d.ts +6 -2
- package/lib/chevre/errorHandler.js +18 -2
- package/lib/chevre/repo/categoryCode.d.ts +26 -14
- package/lib/chevre/repo/categoryCode.js +53 -42
- package/lib/chevre/repo/event.d.ts +25 -11
- package/lib/chevre/repo/event.js +60 -35
- package/lib/chevre/repo/eventSellerMakesOffer.d.ts +24 -39
- package/lib/chevre/repo/eventSellerMakesOffer.js +88 -43
- package/lib/chevre/repo/issuer.js +9 -5
- package/lib/chevre/repo/mongoose/schemas/categoryCode.js +48 -42
- package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.d.ts +10 -0
- package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.js +107 -0
- package/lib/chevre/repo/mongoose/schemas/product.d.ts +4 -4
- package/lib/chevre/repo/mongoose/schemas/product.js +2 -2
- package/lib/chevre/repo/movieTicketType.d.ts +57 -0
- package/lib/chevre/repo/movieTicketType.js +253 -0
- package/lib/chevre/repo/offerCatalog.d.ts +17 -2
- package/lib/chevre/repo/offerCatalog.js +5 -2
- package/lib/chevre/repo/productHasOfferCatalog.d.ts +1 -0
- package/lib/chevre/repo/productHasOfferCatalog.js +5 -1
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +15 -2
- package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +15 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +159 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +16 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +184 -0
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +4 -1
- package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +25 -139
- package/lib/chevre/service/event.js +1 -1
- package/lib/chevre/service/offer/event/importFromCOA.js +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +3 -3
- package/lib/chevre/service/offer/onEventChanged.js +26 -30
- package/lib/chevre/service/project.d.ts +3 -0
- package/lib/chevre/service/project.js +2 -1
- package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
- package/lib/chevre/service/task/onResourceUpdated.js +1 -1
- package/package.json +4 -4
- package/example/src/chevre/aggregateEventSellerMakesOffer.ts +0 -32
- package/example/src/chevre/event/migrateEventIdentifier4ttts.ts +0 -96
- package/example/src/chevre/searchCategoryCodesByAggregate.ts +0 -31
- package/example/src/chevre/searchOfferCatalogItems.ts +0 -59
- package/example/src/chevre/searchPaymentServices.ts +0 -32
package/lib/chevre/repo/event.js
CHANGED
|
@@ -21,11 +21,14 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
23
|
exports.EventRepo = void 0;
|
|
24
|
+
const mongoose_1 = require("mongoose");
|
|
25
|
+
const uniqid = require("uniqid");
|
|
26
|
+
const errorHandler_1 = require("../errorHandler");
|
|
24
27
|
const factory = require("../factory");
|
|
25
28
|
const EventFactory = require("../factory/event");
|
|
26
|
-
const event_1 = require("./mongoose/schemas/event");
|
|
27
|
-
const errorHandler_1 = require("../errorHandler");
|
|
28
29
|
const settings_1 = require("../settings");
|
|
30
|
+
const event_1 = require("./mongoose/schemas/event");
|
|
31
|
+
const USE_OBJECT_ID_AS_EVENT_ID = process.env.USE_OBJECT_ID_AS_EVENT_ID === '1';
|
|
29
32
|
const AVAILABLE_PUBLIC_PROJECT_FIELDS = [
|
|
30
33
|
'additionalProperty', 'aggregateReservation', 'attendeeCount', 'checkInCount', 'coaInfo',
|
|
31
34
|
// 'description',
|
|
@@ -41,6 +44,13 @@ class EventRepo {
|
|
|
41
44
|
constructor(connection) {
|
|
42
45
|
this.eventModel = connection.model(event_1.modelName, (0, event_1.createSchema)());
|
|
43
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* イベントIDを生成する
|
|
49
|
+
*/
|
|
50
|
+
static CREATE_ID() {
|
|
51
|
+
// implement using ObjectId(2025-10-17~)
|
|
52
|
+
return (USE_OBJECT_ID_AS_EVENT_ID) ? new mongoose_1.Types.ObjectId().toHexString() : uniqid();
|
|
53
|
+
}
|
|
44
54
|
// tslint:disable-next-line:cyclomatic-complexity max-func-body-length
|
|
45
55
|
static CREATE_MONGO_CONDITIONS(conditions) {
|
|
46
56
|
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4;
|
|
@@ -260,9 +270,8 @@ class EventRepo {
|
|
|
260
270
|
*/
|
|
261
271
|
createManyEvents(params) {
|
|
262
272
|
return __awaiter(this, void 0, void 0, function* () {
|
|
263
|
-
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
264
273
|
const insertingDocs = params.attributes.map((p) => {
|
|
265
|
-
return Object.assign({ _id:
|
|
274
|
+
return Object.assign({ _id: EventRepo.CREATE_ID() }, p);
|
|
266
275
|
});
|
|
267
276
|
try {
|
|
268
277
|
yield this.eventModel.insertMany(insertingDocs, { rawResult: true } // rawResult(2024-08-02~)
|
|
@@ -292,7 +301,6 @@ class EventRepo {
|
|
|
292
301
|
upsertManyByAdditionalProperty(params, options) {
|
|
293
302
|
return __awaiter(this, void 0, void 0, function* () {
|
|
294
303
|
const { update } = options;
|
|
295
|
-
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
296
304
|
const bulkWriteOps = [];
|
|
297
305
|
const additionalProperties = [];
|
|
298
306
|
const { events, additionalPropertyFilter, eventSeries, screeningRoom } = params;
|
|
@@ -347,7 +355,7 @@ class EventRepo {
|
|
|
347
355
|
maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation, // ←適用しない
|
|
348
356
|
eventStatus, superEvent } = creatingEventParams, // <-上書き可能な属性を限定的に
|
|
349
357
|
setOnInsertFields = __rest(creatingEventParams, ["coaInfo", "maximumAttendeeCapacity", "remainingAttendeeCapacity", "checkInCount", "attendeeCount", "aggregateReservation", "eventStatus", "superEvent"]);
|
|
350
|
-
const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { _id:
|
|
358
|
+
const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { _id: EventRepo.CREATE_ID() });
|
|
351
359
|
bulkWriteOps.push({
|
|
352
360
|
updateOne: {
|
|
353
361
|
filter,
|
|
@@ -389,7 +397,6 @@ class EventRepo {
|
|
|
389
397
|
upsertManyScreeningEventByIdentifier(params, options) {
|
|
390
398
|
return __awaiter(this, void 0, void 0, function* () {
|
|
391
399
|
const { update } = options;
|
|
392
|
-
const uniqid = yield Promise.resolve().then(() => require('uniqid'));
|
|
393
400
|
const bulkWriteOps = [];
|
|
394
401
|
const queryFilters = [];
|
|
395
402
|
if (Array.isArray(params)) {
|
|
@@ -423,7 +430,7 @@ class EventRepo {
|
|
|
423
430
|
}
|
|
424
431
|
else {
|
|
425
432
|
const { id, coaInfo, description, maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation } = $set, setOnInsertFields = __rest($set, ["id", "coaInfo", "description", "maximumAttendeeCapacity", "remainingAttendeeCapacity", "checkInCount", "attendeeCount", "aggregateReservation"]);
|
|
426
|
-
const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { identifier, _id:
|
|
433
|
+
const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { identifier, _id: EventRepo.CREATE_ID() });
|
|
427
434
|
const updateOne = {
|
|
428
435
|
filter,
|
|
429
436
|
update: {
|
|
@@ -473,37 +480,41 @@ class EventRepo {
|
|
|
473
480
|
});
|
|
474
481
|
}
|
|
475
482
|
/**
|
|
476
|
-
*
|
|
483
|
+
* 単一イベント編集
|
|
477
484
|
*/
|
|
478
|
-
|
|
485
|
+
updateEventById(params) {
|
|
479
486
|
return __awaiter(this, void 0, void 0, function* () {
|
|
480
|
-
let savedEventId;
|
|
481
487
|
let doc;
|
|
482
|
-
const _a = params.attributes, { identifier, project, typeOf } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf"])
|
|
488
|
+
const _a = params.attributes, { identifier, project, typeOf, organizer, aggregateReservation, maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, coaInfo } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf", "organizer", "aggregateReservation", "maximumAttendeeCapacity", "remainingAttendeeCapacity", "checkInCount", "attendeeCount", "coaInfo"])
|
|
489
|
+
// maximumPhysicalAttendeeCapacity, additionalProperty,
|
|
490
|
+
// eventStatus, location, name, superEvent, offers,
|
|
491
|
+
// doorTime, endDate, startDate
|
|
492
|
+
;
|
|
483
493
|
if (typeof typeOf !== 'string' || typeOf.length === 0) {
|
|
484
494
|
throw new factory.errors.ArgumentNull('attributes.typeOf');
|
|
485
495
|
}
|
|
496
|
+
if (typeof params.id !== 'string' || params.id === '') {
|
|
497
|
+
throw new factory.errors.ArgumentNull('id');
|
|
498
|
+
}
|
|
486
499
|
try {
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
//
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
savedEventId = params.id;
|
|
506
|
-
}
|
|
500
|
+
doc = yield this.eventModel.findOneAndUpdate({
|
|
501
|
+
_id: { $eq: params.id },
|
|
502
|
+
typeOf: { $eq: typeOf }
|
|
503
|
+
}, Object.assign({
|
|
504
|
+
// 編集のためのみのメソッドになったので、setOnInsertは廃止(2025-10-27~)
|
|
505
|
+
// 上書き禁止属性を除外(2022-08-24~)
|
|
506
|
+
// $setOnInsert: {
|
|
507
|
+
// typeOf,
|
|
508
|
+
// project,
|
|
509
|
+
// ...(typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined
|
|
510
|
+
// },
|
|
511
|
+
$set: updateFields }, (params.$unset !== undefined) ? { $unset: params.$unset } : undefined), {
|
|
512
|
+
upsert: false,
|
|
513
|
+
new: true,
|
|
514
|
+
projection: { _id: 1 }
|
|
515
|
+
})
|
|
516
|
+
.lean()
|
|
517
|
+
.exec();
|
|
507
518
|
}
|
|
508
519
|
catch (error) {
|
|
509
520
|
if (yield (0, errorHandler_1.isMongoError)(error)) {
|
|
@@ -516,7 +527,6 @@ class EventRepo {
|
|
|
516
527
|
if (doc === null) {
|
|
517
528
|
throw new factory.errors.NotFound(this.eventModel.modelName);
|
|
518
529
|
}
|
|
519
|
-
return { id: savedEventId }; // optimize(2024-07-31~)
|
|
520
530
|
});
|
|
521
531
|
}
|
|
522
532
|
/**
|
|
@@ -566,8 +576,7 @@ class EventRepo {
|
|
|
566
576
|
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
567
577
|
throw new factory.errors.ArgumentNull('identifier');
|
|
568
578
|
}
|
|
569
|
-
const
|
|
570
|
-
const id = uniqid();
|
|
579
|
+
const id = EventRepo.CREATE_ID();
|
|
571
580
|
const doc = yield this.eventModel.findOneAndUpdate(
|
|
572
581
|
// 全イベントにidentifierを保証したので、additionalPropertyによるフィルターからidentifierによるフィルターへ変更(2025-09-05~)
|
|
573
582
|
// {
|
|
@@ -646,6 +655,22 @@ class EventRepo {
|
|
|
646
655
|
.exec();
|
|
647
656
|
});
|
|
648
657
|
}
|
|
658
|
+
findByAdditionalProperty(params) {
|
|
659
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
660
|
+
const query = this.eventModel.find({
|
|
661
|
+
'project.id': { $eq: params.project.id },
|
|
662
|
+
additionalProperty: { $eq: params.additionalProperty }
|
|
663
|
+
}, { _id: 1 });
|
|
664
|
+
// if (typeof params.limit === 'number' && params.limit > 0) {
|
|
665
|
+
// const page: number = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
|
|
666
|
+
// query.limit(params.limit)
|
|
667
|
+
// .skip(params.limit * (page - 1));
|
|
668
|
+
// }
|
|
669
|
+
return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
670
|
+
.lean()
|
|
671
|
+
.exec();
|
|
672
|
+
});
|
|
673
|
+
}
|
|
649
674
|
/**
|
|
650
675
|
* apiで公開属性を検索する(2024-10-13~)
|
|
651
676
|
*/
|
|
@@ -1,54 +1,39 @@
|
|
|
1
|
+
import type { BulkWriteResult } from 'mongodb';
|
|
1
2
|
import type { Connection } from 'mongoose';
|
|
2
3
|
import * as factory from '../factory';
|
|
3
|
-
type IAggregateMakesOfferResult = Pick<factory.event.screeningEvent.ISellerMakesOffer, 'availabilityEnds' | 'availabilityStarts' | 'validFrom' | 'validThrough'> & {
|
|
4
|
-
itemOffered: {
|
|
5
|
-
serviceOutput: {
|
|
6
|
-
reservationFor: {
|
|
7
|
-
/**
|
|
8
|
-
* イベントID
|
|
9
|
-
*/
|
|
10
|
-
id: string;
|
|
11
|
-
};
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
};
|
|
15
4
|
/**
|
|
16
|
-
*
|
|
5
|
+
* イベントのアプリケーションオファーリポジトリ
|
|
17
6
|
*/
|
|
18
7
|
export declare class EventSellerMakesOfferRepo {
|
|
19
8
|
private readonly eventModel;
|
|
20
9
|
constructor(connection: Connection);
|
|
21
10
|
/**
|
|
22
|
-
*
|
|
11
|
+
* 単一イベントのmakesOfferを更新する
|
|
23
12
|
*/
|
|
24
|
-
|
|
25
|
-
limit?: number;
|
|
26
|
-
page?: number;
|
|
13
|
+
updateOffersByEventId(params: {
|
|
27
14
|
project: {
|
|
28
|
-
id:
|
|
29
|
-
$eq: string;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* アプリケーション(指定必須)
|
|
34
|
-
*/
|
|
35
|
-
availableAtOrFrom: {
|
|
36
|
-
id: {
|
|
37
|
-
$eq: string;
|
|
38
|
-
};
|
|
15
|
+
id: string;
|
|
39
16
|
};
|
|
17
|
+
offers: factory.event.screeningEvent.ISellerMakesOffer[];
|
|
40
18
|
itemOffered: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
19
|
+
id: string;
|
|
20
|
+
};
|
|
21
|
+
}): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* イベントコードをキーにして複数編集
|
|
24
|
+
* 2025-10-27~
|
|
25
|
+
*/
|
|
26
|
+
updateSellerMakesOffersByEventIdentifier(params: {
|
|
27
|
+
$set: Pick<factory.event.screeningEvent.IAttributes, 'project'> & {
|
|
28
|
+
identifier: string;
|
|
29
|
+
offers: {
|
|
30
|
+
seller: Pick<factory.event.screeningEvent.ISeller, 'makesOffer'>;
|
|
50
31
|
};
|
|
51
32
|
};
|
|
52
|
-
}): Promise<
|
|
33
|
+
}[]): Promise<{
|
|
34
|
+
bulkWriteResult: BulkWriteResult;
|
|
35
|
+
modifiedEvents: {
|
|
36
|
+
id: string;
|
|
37
|
+
}[];
|
|
38
|
+
} | void>;
|
|
53
39
|
}
|
|
54
|
-
export {};
|
|
@@ -11,62 +11,107 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.EventSellerMakesOfferRepo = void 0;
|
|
13
13
|
const factory = require("../factory");
|
|
14
|
-
|
|
14
|
+
// import { MONGO_MAX_TIME_MS } from '../settings';
|
|
15
15
|
const event_1 = require("./mongoose/schemas/event");
|
|
16
|
+
// type IMatchStage = PipelineStage.Match;
|
|
17
|
+
// type IAggregateMakesOfferResult = Pick<
|
|
18
|
+
// factory.event.screeningEvent.ISellerMakesOffer,
|
|
19
|
+
// 'availabilityEnds' | 'availabilityStarts' | 'validFrom' | 'validThrough'
|
|
20
|
+
// > & {
|
|
21
|
+
// itemOffered: {
|
|
22
|
+
// serviceOutput: {
|
|
23
|
+
// reservationFor: {
|
|
24
|
+
// /**
|
|
25
|
+
// * イベントID
|
|
26
|
+
// */
|
|
27
|
+
// id: string;
|
|
28
|
+
// };
|
|
29
|
+
// };
|
|
30
|
+
// };
|
|
31
|
+
// };
|
|
16
32
|
/**
|
|
17
|
-
*
|
|
33
|
+
* イベントのアプリケーションオファーリポジトリ
|
|
18
34
|
*/
|
|
19
35
|
class EventSellerMakesOfferRepo {
|
|
20
36
|
constructor(connection) {
|
|
21
37
|
this.eventModel = connection.model(event_1.modelName, (0, event_1.createSchema)());
|
|
22
38
|
}
|
|
23
39
|
/**
|
|
24
|
-
*
|
|
40
|
+
* 単一イベントのmakesOfferを更新する
|
|
25
41
|
*/
|
|
26
|
-
|
|
42
|
+
updateOffersByEventId(params) {
|
|
27
43
|
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
44
|
+
const { offers, itemOffered, project } = params;
|
|
45
|
+
const updateQuery = {
|
|
46
|
+
$set: {
|
|
47
|
+
'offers.seller.makesOffer': offers
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const updateFilter = {
|
|
51
|
+
_id: { $eq: itemOffered.id },
|
|
52
|
+
'project.id': { $eq: project.id }
|
|
53
|
+
};
|
|
54
|
+
const queryOptions = { upsert: false, new: false, projection: { _id: 1 } };
|
|
55
|
+
const doc = yield this.eventModel.findOneAndUpdate(updateFilter, updateQuery, queryOptions)
|
|
56
|
+
.lean()
|
|
57
|
+
.exec();
|
|
58
|
+
if (doc === null) {
|
|
59
|
+
throw new factory.errors.NotFound(this.eventModel.modelName);
|
|
40
60
|
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* イベントコードをキーにして複数編集
|
|
65
|
+
* 2025-10-27~
|
|
66
|
+
*/
|
|
67
|
+
updateSellerMakesOffersByEventIdentifier(params) {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
const bulkWriteOps = [];
|
|
70
|
+
const queryFilters = [];
|
|
71
|
+
if (Array.isArray(params)) {
|
|
72
|
+
params.forEach(({ $set }) => {
|
|
73
|
+
const { project, identifier, offers } = $set;
|
|
74
|
+
if (typeof identifier !== 'string' || identifier.length === 0) {
|
|
75
|
+
throw new factory.errors.ArgumentNull('identifier');
|
|
59
76
|
}
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
77
|
+
const sellerMakesOffer = offers.seller.makesOffer;
|
|
78
|
+
if (!Array.isArray(sellerMakesOffer)) {
|
|
79
|
+
throw new factory.errors.Argument('offers.seller.makesOffer', 'offers.seller.makesOffer must be an array');
|
|
80
|
+
}
|
|
81
|
+
// リソースのユニークネスを保証するfilter
|
|
82
|
+
const filter = {
|
|
83
|
+
'project.id': { $eq: project.id },
|
|
84
|
+
identifier: { $exists: true, $eq: identifier }
|
|
85
|
+
};
|
|
86
|
+
queryFilters.push({
|
|
87
|
+
'project.id': { $eq: project.id },
|
|
88
|
+
identifier: { $exists: true, $eq: identifier }
|
|
89
|
+
});
|
|
90
|
+
const setFields = {
|
|
91
|
+
'offers.seller.makesOffer': sellerMakesOffer
|
|
92
|
+
};
|
|
93
|
+
const updateQuery = {
|
|
94
|
+
$set: setFields
|
|
95
|
+
};
|
|
96
|
+
const updateOne = {
|
|
97
|
+
filter,
|
|
98
|
+
update: updateQuery,
|
|
99
|
+
upsert: false
|
|
100
|
+
};
|
|
101
|
+
bulkWriteOps.push({ updateOne });
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
if (bulkWriteOps.length > 0) {
|
|
105
|
+
const bulkWriteResult = yield this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
|
|
106
|
+
// modifiedの場合upsertedIdsに含まれないので、idを検索する
|
|
107
|
+
const modifiedEvents = yield this.eventModel.find({ $or: queryFilters }, {
|
|
108
|
+
_id: 0,
|
|
109
|
+
id: { $toString: '$_id' }
|
|
110
|
+
})
|
|
111
|
+
.lean()
|
|
112
|
+
.exec();
|
|
113
|
+
return { bulkWriteResult, modifiedEvents };
|
|
66
114
|
}
|
|
67
|
-
return aggregate
|
|
68
|
-
.option({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
|
|
69
|
-
.exec();
|
|
70
115
|
});
|
|
71
116
|
}
|
|
72
117
|
}
|
|
@@ -32,17 +32,21 @@ class IssuerRepo {
|
|
|
32
32
|
this.issuerModel = connection.model(issuer_1.modelName, (0, issuer_1.createSchema)());
|
|
33
33
|
}
|
|
34
34
|
static CREATE_MONGO_CONDITIONS(params) {
|
|
35
|
-
var _a, _b, _c, _d;
|
|
35
|
+
var _a, _b, _c, _d, _e;
|
|
36
36
|
const andConditions = [];
|
|
37
37
|
const projectIdEq = (_b = (_a = params.project) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq;
|
|
38
38
|
if (typeof projectIdEq === 'string') {
|
|
39
39
|
andConditions.push({ 'project.id': { $eq: projectIdEq } });
|
|
40
40
|
}
|
|
41
|
-
const
|
|
42
|
-
if (typeof
|
|
43
|
-
andConditions.push({ identifier: { $eq:
|
|
41
|
+
const identifierEq = (_c = params.identifier) === null || _c === void 0 ? void 0 : _c.$eq;
|
|
42
|
+
if (typeof identifierEq === 'string') {
|
|
43
|
+
andConditions.push({ identifier: { $eq: identifierEq } });
|
|
44
44
|
}
|
|
45
|
-
const
|
|
45
|
+
const identifierIn = (_d = params.identifier) === null || _d === void 0 ? void 0 : _d.$in;
|
|
46
|
+
if (Array.isArray(identifierIn)) {
|
|
47
|
+
andConditions.push({ identifier: { $in: identifierIn } });
|
|
48
|
+
}
|
|
49
|
+
const idEq = (_e = params.id) === null || _e === void 0 ? void 0 : _e.$eq;
|
|
46
50
|
if (typeof idEq === 'string') {
|
|
47
51
|
andConditions.push({ _id: { $eq: idEq } });
|
|
48
52
|
}
|
|
@@ -4,26 +4,19 @@ exports.modelName = exports.indexes = void 0;
|
|
|
4
4
|
exports.createSchema = createSchema;
|
|
5
5
|
const mongoose_1 = require("mongoose");
|
|
6
6
|
const writeConcern_1 = require("../writeConcern");
|
|
7
|
-
const factory = require("../../../factory");
|
|
8
7
|
const settings_1 = require("../../../settings");
|
|
9
8
|
const modelName = 'CategoryCode';
|
|
10
9
|
exports.modelName = modelName;
|
|
11
10
|
const schemaDefinition = {
|
|
12
11
|
project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
13
|
-
typeOf: {
|
|
14
|
-
type: String,
|
|
15
|
-
required: true
|
|
16
|
-
},
|
|
12
|
+
typeOf: { type: String, required: true },
|
|
17
13
|
additionalProperty: [mongoose_1.SchemaTypes.Mixed],
|
|
18
14
|
color: String,
|
|
19
15
|
image: String,
|
|
20
|
-
codeValue: {
|
|
21
|
-
type: String,
|
|
22
|
-
required: true
|
|
23
|
-
},
|
|
16
|
+
codeValue: { type: String, required: true },
|
|
24
17
|
inCodeSet: { type: mongoose_1.SchemaTypes.Mixed, required: true },
|
|
25
|
-
name: mongoose_1.SchemaTypes.Mixed
|
|
26
|
-
paymentMethod:
|
|
18
|
+
name: mongoose_1.SchemaTypes.Mixed
|
|
19
|
+
// paymentMethod: SchemaTypes.Mixed // discontinue(2025-11-08~)
|
|
27
20
|
};
|
|
28
21
|
const schemaOptions = {
|
|
29
22
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -76,15 +69,16 @@ const indexes = [
|
|
|
76
69
|
}
|
|
77
70
|
}
|
|
78
71
|
],
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
72
|
+
// discontinue(2025-11-08~)
|
|
73
|
+
// [
|
|
74
|
+
// { 'paymentMethod.typeOf': 1, codeValue: 1 },
|
|
75
|
+
// {
|
|
76
|
+
// name: 'searchByPaymentMethodTypeOf',
|
|
77
|
+
// partialFilterExpression: {
|
|
78
|
+
// 'paymentMethod.typeOf': { $exists: true }
|
|
79
|
+
// }
|
|
80
|
+
// }
|
|
81
|
+
// ],
|
|
88
82
|
[
|
|
89
83
|
{ 'project.id': 1, codeValue: 1 },
|
|
90
84
|
{
|
|
@@ -100,37 +94,49 @@ const indexes = [
|
|
|
100
94
|
}
|
|
101
95
|
}
|
|
102
96
|
],
|
|
103
|
-
//
|
|
97
|
+
// 決済カード区分をコレクション分離したので、reIndex unique index(2025-11-05~)
|
|
104
98
|
[
|
|
105
99
|
{
|
|
106
100
|
'project.id': 1,
|
|
107
|
-
'inCodeSet.identifier': 1,
|
|
101
|
+
'inCodeSet.identifier': 1, // ssktsでのみ区分分類をまたいで重複がある
|
|
108
102
|
codeValue: 1
|
|
109
103
|
},
|
|
110
104
|
{
|
|
111
105
|
unique: true,
|
|
112
|
-
name: '
|
|
113
|
-
partialFilterExpression: {
|
|
114
|
-
// tslint:disable-next-line:no-null-keyword
|
|
115
|
-
'paymentMethod.typeOf': null
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
],
|
|
119
|
-
[
|
|
120
|
-
{
|
|
121
|
-
'project.id': 1,
|
|
122
|
-
'paymentMethod.typeOf': 1,
|
|
123
|
-
codeValue: 1
|
|
124
|
-
},
|
|
125
|
-
{
|
|
126
|
-
unique: true,
|
|
127
|
-
name: 'uniqueByCodeValueAndPaymentMethod',
|
|
128
|
-
partialFilterExpression: {
|
|
129
|
-
'inCodeSet.identifier': { $eq: factory.categoryCode.CategorySetIdentifier.MovieTicketType },
|
|
130
|
-
'paymentMethod.typeOf': { $exists: true }
|
|
131
|
-
}
|
|
106
|
+
name: 'uniqueByCodeValue'
|
|
132
107
|
}
|
|
133
108
|
]
|
|
109
|
+
// add unique index(2024-11-14~)
|
|
110
|
+
// [
|
|
111
|
+
// {
|
|
112
|
+
// 'project.id': 1,
|
|
113
|
+
// 'inCodeSet.identifier': 1,
|
|
114
|
+
// codeValue: 1
|
|
115
|
+
// },
|
|
116
|
+
// {
|
|
117
|
+
// unique: true,
|
|
118
|
+
// name: 'uniqueByCodeValueAndInCodeSet',
|
|
119
|
+
// partialFilterExpression: {
|
|
120
|
+
// // tslint:disable-next-line:no-null-keyword
|
|
121
|
+
// 'paymentMethod.typeOf': null
|
|
122
|
+
// }
|
|
123
|
+
// }
|
|
124
|
+
// ],
|
|
125
|
+
// [
|
|
126
|
+
// {
|
|
127
|
+
// 'project.id': 1,
|
|
128
|
+
// 'paymentMethod.typeOf': 1,
|
|
129
|
+
// codeValue: 1
|
|
130
|
+
// },
|
|
131
|
+
// {
|
|
132
|
+
// unique: true,
|
|
133
|
+
// name: 'uniqueByCodeValueAndPaymentMethod',
|
|
134
|
+
// partialFilterExpression: {
|
|
135
|
+
// 'inCodeSet.identifier': { $eq: factory.movieTicketType.CategorySetIdentifier.MovieTicketType },
|
|
136
|
+
// 'paymentMethod.typeOf': { $exists: true }
|
|
137
|
+
// }
|
|
138
|
+
// }
|
|
139
|
+
// ]
|
|
134
140
|
];
|
|
135
141
|
exports.indexes = indexes;
|
|
136
142
|
/**
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
|
|
2
|
+
import * as factory from '../../../factory';
|
|
3
|
+
type IDocType = factory.movieTicketType.IMovieTicketType;
|
|
4
|
+
type IModel = Model<IDocType>;
|
|
5
|
+
type ISchemaDefinition = SchemaDefinition<IDocType>;
|
|
6
|
+
type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
|
|
7
|
+
declare const modelName = "MovieTicketType";
|
|
8
|
+
declare const indexes: [d: IndexDefinition, o: IndexOptions][];
|
|
9
|
+
declare function createSchema(): ISchema;
|
|
10
|
+
export { createSchema, IModel, IDocType, indexes, modelName };
|