@chevre/domain 23.2.0-alpha.6 → 23.2.0-alpha.60

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 (133) hide show
  1. package/example/src/chevre/acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts +25 -17
  2. package/example/src/chevre/confirmationNumber/testRandomness.ts +49 -0
  3. package/example/src/chevre/emailMessage/createEmailMessageText.ts +63 -0
  4. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +2 -2
  5. package/example/src/chevre/event/unsetSuperEventVideoFormat.ts +30 -0
  6. package/example/src/chevre/eventSeries/unsetVideoFormat.ts +31 -0
  7. package/example/src/chevre/{upsertScreeningEventSeriesByVersion.ts → eventSeries/upsertScreeningEventSeriesByVersion.ts} +47 -43
  8. package/example/src/chevre/{upsertOfferCatalogItemsByIdentifier.ts → offerCatalog/upsertOfferCatalogItemsByIdentifier.ts} +6 -3
  9. package/example/src/chevre/{upsertOfferCatalogsByIdentifier.ts → offerCatalog/upsertOfferCatalogsByIdentifier.ts} +8 -3
  10. package/example/src/chevre/{upsertOffersByIdentifier.ts → offers/upsertOffersByIdentifier.ts} +5 -3
  11. package/example/src/chevre/orderNumber/decryptOrderNumber.ts +14 -0
  12. package/example/src/chevre/orderNumber/testRandomness.ts +54 -0
  13. package/example/src/chevre/place/adminEntranceGates.ts +69 -0
  14. package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
  15. package/example/src/chevre/place/findRooms.ts +24 -0
  16. package/example/src/chevre/place/findSections.ts +28 -0
  17. package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
  18. package/example/src/chevre/place/seatsJson2csv.ts +63 -0
  19. package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
  20. package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
  21. package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
  22. package/example/src/chevre/reIndex.ts +1 -1
  23. package/example/src/chevre/roles/addAdminAcceptedPaymentMethodReadPermissionIfNotExists.ts +33 -0
  24. package/example/src/chevre/roles/addAdminAcceptedPaymentMethodWritePermissionIfNotExists.ts +33 -0
  25. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  26. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
  27. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
  28. package/example/src/chevre/settings/addOrderNumberSetting.ts +44 -0
  29. package/example/src/chevre/settings/addTransactionNumberSetting.ts +40 -0
  30. package/example/src/chevre/transactionNumber/publishByTimestamp.ts +23 -0
  31. package/example/src/chevre/transactionNumber/testRandomness.ts +42 -0
  32. package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
  33. package/lib/chevre/emailMessageBuilder.js +1 -0
  34. package/lib/chevre/factory/event.d.ts +1 -1
  35. package/lib/chevre/factory/event.js +11 -5
  36. package/lib/chevre/factory/transactionNumber.d.ts +19 -0
  37. package/lib/chevre/factory/transactionNumber.js +54 -0
  38. package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -8
  39. package/lib/chevre/repo/acceptedPaymentMethod.js +72 -27
  40. package/lib/chevre/repo/aggregateOffer.d.ts +6 -1
  41. package/lib/chevre/repo/aggregateOffer.js +11 -3
  42. package/lib/chevre/repo/aggregateOrder.js +0 -93
  43. package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
  44. package/lib/chevre/repo/aggregateReservation.js +0 -2
  45. package/lib/chevre/repo/confirmationNumber.d.ts +1 -0
  46. package/lib/chevre/repo/confirmationNumber.js +32 -25
  47. package/lib/chevre/repo/event.d.ts +3 -3
  48. package/lib/chevre/repo/event.js +20 -8
  49. package/lib/chevre/repo/eventOffer.d.ts +8 -0
  50. package/lib/chevre/repo/eventOffer.js +11 -0
  51. package/lib/chevre/repo/eventSeries.d.ts +18 -25
  52. package/lib/chevre/repo/eventSeries.js +155 -101
  53. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
  54. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +13 -25
  55. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +2 -8
  56. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +28 -2
  57. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -2
  58. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +40 -0
  59. package/lib/chevre/repo/mongoose/schemas/setting.js +3 -0
  60. package/lib/chevre/repo/offerCatalog.d.ts +14 -1
  61. package/lib/chevre/repo/offerCatalog.js +41 -19
  62. package/lib/chevre/repo/offerCatalogItem.d.ts +10 -1
  63. package/lib/chevre/repo/offerCatalogItem.js +32 -17
  64. package/lib/chevre/repo/orderNumber.d.ts +7 -0
  65. package/lib/chevre/repo/orderNumber.js +110 -34
  66. package/lib/chevre/repo/place/entranceGate.d.ts +57 -0
  67. package/lib/chevre/repo/place/entranceGate.js +172 -0
  68. package/lib/chevre/repo/place/movieTheater.d.ts +40 -3
  69. package/lib/chevre/repo/place/movieTheater.js +77 -6
  70. package/lib/chevre/repo/place/screeningRoom.d.ts +60 -31
  71. package/lib/chevre/repo/place/screeningRoom.js +227 -135
  72. package/lib/chevre/repo/place/seat.d.ts +47 -45
  73. package/lib/chevre/repo/place/seat.js +175 -45
  74. package/lib/chevre/repo/place/section.d.ts +60 -30
  75. package/lib/chevre/repo/place/section.js +337 -127
  76. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +3 -1
  77. package/lib/chevre/repo/serviceOutputIdentifier.js +42 -27
  78. package/lib/chevre/repo/setting.d.ts +1 -1
  79. package/lib/chevre/repo/setting.js +2 -2
  80. package/lib/chevre/repo/task.d.ts +1 -1
  81. package/lib/chevre/repo/transactionNumber.d.ts +5 -0
  82. package/lib/chevre/repo/transactionNumber.js +63 -27
  83. package/lib/chevre/repository.d.ts +8 -0
  84. package/lib/chevre/repository.js +16 -0
  85. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +10 -2
  86. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
  87. package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
  88. package/lib/chevre/service/event/saveScreeningEventSeries.js +4 -5
  89. package/lib/chevre/service/event/saveScreeningEvents.d.ts +2 -2
  90. package/lib/chevre/service/event/saveScreeningEvents.js +16 -12
  91. package/lib/chevre/service/offer/event/authorize/factory.js +9 -1
  92. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
  93. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
  94. package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
  95. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +7 -1
  96. package/lib/chevre/service/offer/onEventChanged.js +10 -6
  97. package/lib/chevre/service/offer/product.js +1 -1
  98. package/lib/chevre/service/offer.d.ts +5 -0
  99. package/lib/chevre/service/offer.js +34 -9
  100. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  101. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  102. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  103. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +2 -2
  104. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +5 -3
  105. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +4 -2
  106. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.d.ts +13 -0
  107. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +53 -0
  108. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +13 -0
  109. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +56 -0
  110. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +15 -0
  111. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +58 -0
  112. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +17 -0
  113. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +75 -0
  114. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +19 -0
  115. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +60 -0
  116. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +20 -0
  117. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +51 -0
  118. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +27 -0
  119. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +100 -0
  120. package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
  121. package/lib/chevre/service/task/onResourceDeleted.js +168 -0
  122. package/lib/chevre/service/task/onResourceUpdated.js +205 -42
  123. package/lib/chevre/service/task/syncResourcesFromCOA.js +4 -2
  124. package/lib/chevre/service/taskHandler.js +1 -0
  125. package/package.json +10 -8
  126. package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
  127. package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +0 -93
  128. package/example/src/chevre/offers/createSampleOffers.ts +0 -154
  129. package/example/src/chevre/settings/addSettings.ts +0 -46
  130. package/lib/chevre/service/eventOld.d.ts +0 -60
  131. package/lib/chevre/service/eventOld.js +0 -864
  132. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +0 -45
  133. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +0 -447
@@ -10,12 +10,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.ConfirmationNumberRepo = void 0;
13
- const cdigit = require("cdigit");
13
+ // import * as cdigit from 'cdigit';
14
+ const crypto_1 = require("crypto");
14
15
  const moment = require("moment-timezone");
15
- // import { RedisClientType } from 'redis';
16
+ const fpe2Module = require("node-fpe-v2");
17
+ // 型定義が新しいtypescriptに適合しないので、強制的に型変更
18
+ const fpe2 = fpe2Module;
16
19
  // tslint:disable-next-line:no-require-imports no-var-requires
17
- const fpe = require('node-fpe');
18
- // import { createSchema as createSettingSchema, modelName as settingModelName } from './mongoose/schemas/setting';
20
+ // const fpe = require('node-fpe-v1');
19
21
  const transactionNumber_1 = require("./mongoose/schemas/transactionNumber");
20
22
  const transactionNumberCounter_1 = require("./transactionNumberCounter");
21
23
  const CONFIRMATION_NUMBER_MIN_LENGH = 4;
@@ -25,8 +27,6 @@ const TIMEZONE = 'Asia/Tokyo';
25
27
  */
26
28
  class ConfirmationNumberRepo {
27
29
  constructor(params) {
28
- // const { connection } = params;
29
- // this.settingModel = connection.model(settingModelName, createSettingSchema());
30
30
  this.counterRepo = new transactionNumberCounter_1.TransactionNumberCounterRepo(params);
31
31
  }
32
32
  static alignDigits(params) {
@@ -37,32 +37,32 @@ class ConfirmationNumberRepo {
37
37
  }
38
38
  return aligndNumber;
39
39
  }
40
- // private static createKey(params: {
41
- // orderDate: Date;
42
- // }): string {
43
- // return util.format(
44
- // '%s:%s',
45
- // ConfirmationNumberRepo.REDIS_KEY_PREFIX_NEW,
46
- // moment(params.orderDate)
47
- // .tz(TIMEZONE)
48
- // .format('YYMM')
49
- // );
50
- // }
51
40
  static createDataFeedIdentifier(params) {
52
41
  return moment(params.orderDate)
53
42
  .tz(TIMEZONE)
54
43
  .format('YYMM');
55
44
  }
45
+ // private static count2confirmationNumberUsingFPE1(params: { count: number }): string {
46
+ // // 桁数調整
47
+ // let confirmationNumber: string = ConfirmationNumberRepo.alignDigits(params.count);
48
+ // // checkdigit
49
+ // const cd = cdigit.luhn.compute(confirmationNumber);
50
+ // // debug('check digit:', cd);
51
+ // confirmationNumber = fpe({ password: cd })
52
+ // .encrypt(confirmationNumber);
53
+ // confirmationNumber = `${cd}${confirmationNumber}`;
54
+ // return confirmationNumber;
55
+ // }
56
+ // reimplement using fpe2(2026-02-02~)
56
57
  static count2confirmationNumber(params) {
57
58
  // 桁数調整
58
- let confirmationNumber = ConfirmationNumberRepo.alignDigits(params.count);
59
- // checkdigit
60
- const cd = cdigit.luhn.compute(confirmationNumber);
61
- // debug('check digit:', cd);
62
- confirmationNumber = fpe({ password: cd })
63
- .encrypt(confirmationNumber);
64
- confirmationNumber = `${cd}${confirmationNumber}`;
65
- return confirmationNumber;
59
+ const rawBody = ConfirmationNumberRepo.alignDigits(params.count);
60
+ // tslint:disable-next-line:no-magic-numbers
61
+ const saltDigit = (0, crypto_1.randomInt)(0, 10);
62
+ const saltStr = saltDigit.toString();
63
+ const cipher = fpe2({ secret: `${saltStr}` });
64
+ const encryptedBody = cipher.encrypt(rawBody);
65
+ return `${saltStr}${encryptedBody}`;
66
66
  }
67
67
  /**
68
68
  * 発行する
@@ -87,5 +87,12 @@ class ConfirmationNumberRepo {
87
87
  return ConfirmationNumberRepo.count2confirmationNumber({ count: incrReply });
88
88
  });
89
89
  }
90
+ // tslint:disable-next-line:prefer-function-over-method
91
+ decrypt(id) {
92
+ return __awaiter(this, void 0, void 0, function* () {
93
+ const cipher = fpe2({ secret: id[0] });
94
+ return cipher.decrypt(id.slice(1));
95
+ });
96
+ }
90
97
  }
91
98
  exports.ConfirmationNumberRepo = ConfirmationNumberRepo;
@@ -90,11 +90,11 @@ export declare class EventRepo {
90
90
  */
91
91
  update: boolean;
92
92
  }): Promise<{
93
- bulkWriteResult: BulkWriteResult;
93
+ bulkWriteResult?: BulkWriteResult;
94
94
  modifiedEvents: {
95
95
  id: string;
96
96
  }[];
97
- } | void>;
97
+ }>;
98
98
  /**
99
99
  * イベント部分更新
100
100
  */
@@ -210,7 +210,7 @@ export declare class EventRepo {
210
210
  project: {
211
211
  id: string;
212
212
  };
213
- superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'videoFormat' | 'workPerformed'>;
213
+ superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'workPerformed'>;
214
214
  startDate: {
215
215
  $gte: Date;
216
216
  };
@@ -344,15 +344,27 @@ class EventRepo {
344
344
  }
345
345
  if (bulkWriteOps.length > 0) {
346
346
  const bulkWriteResult = yield this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
347
- // modifiedの場合upsertedIdsに含まれないので、idを検索する
348
- const modifiedEvents = yield this.eventModel.find({ $or: queryFilters }, {
349
- _id: 0,
350
- id: { $toString: '$_id' }
351
- })
352
- .lean()
353
- .exec();
354
- return { bulkWriteResult, modifiedEvents };
347
+ // update:falseの場合、upsertedIdsのみmodifiedEventsとして返せばよい(2026-01-16~)
348
+ if (!update) {
349
+ // BulkWriteResult -> upsertedIds: { '0': '7iri6p4m54k0r3g' }
350
+ return {
351
+ bulkWriteResult,
352
+ modifiedEvents: Object.values(bulkWriteResult.upsertedIds)
353
+ .map((id) => ({ id: String(id) }))
354
+ };
355
+ }
356
+ else {
357
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
358
+ const modifiedEvents = yield this.eventModel.find({ $or: queryFilters }, {
359
+ _id: 0,
360
+ id: { $toString: '$_id' }
361
+ })
362
+ .lean()
363
+ .exec();
364
+ return { bulkWriteResult, modifiedEvents };
365
+ }
355
366
  }
367
+ return { modifiedEvents: [] };
356
368
  });
357
369
  }
358
370
  /**
@@ -48,5 +48,13 @@ export declare class EventOfferRepo {
48
48
  id: string;
49
49
  };
50
50
  }): Promise<DeleteResult>;
51
+ /**
52
+ * 有効期間を過ぎたイベントオファーを削除する
53
+ */
54
+ deleteEventOffersExpired(params: {
55
+ validThrough: {
56
+ $lte: Date;
57
+ };
58
+ }): Promise<DeleteResult>;
51
59
  }
52
60
  export {};
@@ -187,5 +187,16 @@ class EventOfferRepo {
187
187
  .exec();
188
188
  });
189
189
  }
190
+ /**
191
+ * 有効期間を過ぎたイベントオファーを削除する
192
+ */
193
+ deleteEventOffersExpired(params) {
194
+ return __awaiter(this, void 0, void 0, function* () {
195
+ return this.eventOfferModel.deleteMany({
196
+ validThrough: { $lte: params.validThrough.$lte }
197
+ })
198
+ .exec();
199
+ });
200
+ }
190
201
  }
191
202
  exports.EventOfferRepo = EventOfferRepo;
@@ -1,8 +1,8 @@
1
1
  import type { BulkWriteResult } from 'mongodb';
2
- import type { Connection, Document, FilterQuery } from 'mongoose';
2
+ import type { Connection, FilterQuery } from 'mongoose';
3
3
  import * as factory from '../factory';
4
4
  type ISearchConditions = factory.eventSeries.ISearchConditions;
5
- type IKeyOfProjection = Exclude<keyof factory.eventSeries.IEvent, 'id'>;
5
+ type IKeyOfProjection = Exclude<keyof factory.eventSeries.IEvent, 'id' | 'videoFormat'>;
6
6
  type IUnset = {
7
7
  [key in keyof factory.eventSeries.IEvent]?: 1;
8
8
  };
@@ -13,13 +13,6 @@ export declare class EventSeriesRepo {
13
13
  private readonly eventSeriesModel;
14
14
  constructor(connection: Connection);
15
15
  static CREATE_MONGO_CONDITIONS(conditions: ISearchConditions): FilterQuery<factory.eventSeries.IEvent>[];
16
- /**
17
- * 複数イベントを作成する
18
- */
19
- createManyEventSeries(params: {
20
- attributes: factory.eventSeries.IAttributes[];
21
- expectsNoContent: boolean;
22
- }): Promise<string[] | void>;
23
16
  /**
24
17
  * コンテンツ+バージョンをキーにして、なければ作成する(複数対応)
25
18
  */
@@ -27,26 +20,22 @@ export declare class EventSeriesRepo {
27
20
  attributes: factory.eventSeries.IAttributes;
28
21
  }[]): Promise<BulkWriteResult | void>;
29
22
  /**
30
- * コンテンツ+バージョンをキーにして冪等置換
23
+ * 施設+コンテンツ+バージョンをキーにして冪等置換
31
24
  */
32
25
  upsertByVersion(params: {
33
26
  $set: factory.eventSeries.IAttributes;
34
27
  $unset?: IUnset;
35
- }[]): Promise<{
36
- bulkWriteResult4insert: BulkWriteResult;
37
- modifiedEvents: {
38
- id: string;
39
- }[];
40
- } | void>;
41
- saveEventSeries(params: {
42
- id?: string;
43
- attributes: factory.eventSeries.IAttributes;
28
+ }[], options: {
44
29
  /**
45
- * ドキュメント作成時には無視される
30
+ * falseの場合setOnInsertのみ
31
+ * trueの場合setOnInsert+setのみ
46
32
  */
47
- $unset?: IUnset;
33
+ upsert: boolean;
48
34
  }): Promise<{
49
- id: string;
35
+ bulkWriteResult?: BulkWriteResult;
36
+ modifiedEvents: {
37
+ id: string;
38
+ }[];
50
39
  }>;
51
40
  /**
52
41
  * sskts施設コンテンツ保管
@@ -58,7 +47,7 @@ export declare class EventSeriesRepo {
58
47
  /**
59
48
  * イベントを検索する(inclusion projection)
60
49
  */
61
- projectEventSeriesFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<factory.eventSeries.IEvent[]>;
50
+ projectEventSeriesFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<Omit<factory.eventSeries.IEvent, 'videoFormat'>[]>;
62
51
  deleteEventSeriesById(params: {
63
52
  project: {
64
53
  id: string;
@@ -103,18 +92,22 @@ export declare class EventSeriesRepo {
103
92
  }): Promise<{
104
93
  maxVersion: string;
105
94
  }>;
106
- getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<Document<unknown, {}, factory.eventSeries.IAttributes & {
95
+ getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, factory.eventSeries.IAttributes & {
107
96
  _id: string;
108
97
  }> & factory.eventSeries.IAttributes & {
109
98
  _id: string;
110
99
  } & Required<{
111
100
  _id: string;
112
- }>, import("mongoose").QueryOptions<Document<unknown, {}, factory.eventSeries.IAttributes & {
101
+ }>, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, factory.eventSeries.IAttributes & {
113
102
  _id: string;
114
103
  }> & factory.eventSeries.IAttributes & {
115
104
  _id: string;
116
105
  } & Required<{
117
106
  _id: string;
118
107
  }>>>;
108
+ unsetUnnecessaryFields(params: {
109
+ filter: FilterQuery<factory.eventSeries.IEvent>;
110
+ $unset: IUnset;
111
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
119
112
  }
120
113
  export {};
@@ -23,7 +23,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.EventSeriesRepo = void 0;
24
24
  const factory = require("../factory");
25
25
  const eventSeries_1 = require("./mongoose/schemas/eventSeries");
26
- const errorHandler_1 = require("../errorHandler");
26
+ // import { isMongoError, MongoErrorCode } from '../errorHandler';
27
27
  const settings_1 = require("../settings");
28
28
  /**
29
29
  * 施設コンテンツリポジトリ
@@ -184,21 +184,25 @@ class EventSeriesRepo {
184
184
  }
185
185
  const videoFormatTypeOfEq = (_t = (_s = conditions.videoFormat) === null || _s === void 0 ? void 0 : _s.typeOf) === null || _t === void 0 ? void 0 : _t.$eq;
186
186
  if (typeof videoFormatTypeOfEq === 'string') {
187
- andConditions.push({
188
- 'videoFormat.typeOf': {
189
- $exists: true,
190
- $eq: videoFormatTypeOfEq
191
- }
192
- });
187
+ // 新しい参照先へ変更(2025-12-31~)
188
+ // andConditions.push({
189
+ // 'videoFormat.typeOf': {
190
+ // $exists: true,
191
+ // $eq: videoFormatTypeOfEq
192
+ // }
193
+ // });
194
+ andConditions.push({ 'subEvent.videoFormat': { $exists: true, $eq: videoFormatTypeOfEq } });
193
195
  }
194
196
  const videoFormatTypeOfIn = (_v = (_u = conditions.videoFormat) === null || _u === void 0 ? void 0 : _u.typeOf) === null || _v === void 0 ? void 0 : _v.$in;
195
197
  if (Array.isArray(videoFormatTypeOfIn)) {
196
- andConditions.push({
197
- 'videoFormat.typeOf': {
198
- $exists: true,
199
- $in: videoFormatTypeOfIn
200
- }
201
- });
198
+ // 新しい参照先へ変更(2025-12-31~)
199
+ // andConditions.push({
200
+ // 'videoFormat.typeOf': {
201
+ // $exists: true,
202
+ // $in: videoFormatTypeOfIn
203
+ // }
204
+ // });
205
+ andConditions.push({ 'subEvent.videoFormat': { $exists: true, $in: videoFormatTypeOfIn } });
202
206
  }
203
207
  const soundFormatTypeOfEq = (_x = (_w = conditions.soundFormat) === null || _w === void 0 ? void 0 : _w.typeOf) === null || _x === void 0 ? void 0 : _x.$eq;
204
208
  if (typeof soundFormatTypeOfEq === 'string') {
@@ -220,34 +224,40 @@ class EventSeriesRepo {
220
224
  }
221
225
  return andConditions;
222
226
  }
223
- /**
224
- * 複数イベントを作成する
225
- */
226
- createManyEventSeries(params) {
227
- return __awaiter(this, void 0, void 0, function* () {
228
- const uniqid = yield Promise.resolve().then(() => require('uniqid'));
229
- const insertingDocs = params.attributes.map((p) => {
230
- return Object.assign({ _id: uniqid() }, p);
231
- });
232
- try {
233
- yield this.eventSeriesModel.insertMany(insertingDocs, { rawResult: true } // rawResult(2024-08-02~)
234
- );
235
- // console.dir(insertResult, { depth: null });
236
- }
237
- catch (error) {
238
- if (yield (0, errorHandler_1.isMongoError)(error)) {
239
- if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
240
- throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEventSeries, ['workPerformed.version']);
241
- }
242
- }
243
- throw error;
244
- }
245
- if (params.expectsNoContent) {
246
- return;
247
- }
248
- return insertingDocs.map(({ _id }) => _id);
249
- });
250
- }
227
+ // /**
228
+ // * 複数イベントを作成する
229
+ // */
230
+ // public async createManyEventSeries(params: {
231
+ // attributes: factory.eventSeries.IAttributes[];
232
+ // expectsNoContent: boolean;
233
+ // }): Promise<string[] | void> { // optimize response(only id)(2024-08-02~)
234
+ // const uniqid = await import('uniqid');
235
+ // const insertingDocs: (factory.eventSeries.IAttributes & { _id: string })[] =
236
+ // params.attributes.map((p) => {
237
+ // return {
238
+ // _id: uniqid(),
239
+ // ...p
240
+ // };
241
+ // });
242
+ // try {
243
+ // await this.eventSeriesModel.insertMany<factory.eventSeries.IAttributes & { _id: string }>(
244
+ // insertingDocs,
245
+ // { rawResult: true } // rawResult(2024-08-02~)
246
+ // );
247
+ // // console.dir(insertResult, { depth: null });
248
+ // } catch (error) {
249
+ // if (await isMongoError(error)) {
250
+ // if (error.code === MongoErrorCode.DuplicateKey) {
251
+ // throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEventSeries, ['workPerformed.version']);
252
+ // }
253
+ // }
254
+ // throw error;
255
+ // }
256
+ // if (params.expectsNoContent) {
257
+ // return;
258
+ // }
259
+ // return insertingDocs.map(({ _id }) => _id);
260
+ // }
251
261
  /**
252
262
  * コンテンツ+バージョンをキーにして、なければ作成する(複数対応)
253
263
  */
@@ -294,13 +304,13 @@ class EventSeriesRepo {
294
304
  });
295
305
  }
296
306
  /**
297
- * コンテンツ+バージョンをキーにして冪等置換
307
+ * 施設+コンテンツ+バージョンをキーにして冪等置換
298
308
  */
299
- // tslint:disable-next-line:max-func-body-length
300
- upsertByVersion(params) {
309
+ upsertByVersion(params, options) {
301
310
  return __awaiter(this, void 0, void 0, function* () {
311
+ const { upsert } = options;
302
312
  const uniqid = yield Promise.resolve().then(() => require('uniqid'));
303
- const bulkWriteOps4insert = [];
313
+ const bulkWriteOps = [];
304
314
  const queryFilters = [];
305
315
  if (Array.isArray(params)) {
306
316
  params.forEach(({ $set, $unset }) => {
@@ -329,71 +339,109 @@ class EventSeriesRepo {
329
339
  typeOf,
330
340
  _id: uniqid()
331
341
  };
332
- const updateOne = {
333
- filter,
334
- update: Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
335
- upsert: true
336
- };
337
- bulkWriteOps4insert.push({ updateOne });
342
+ let updateOne;
343
+ if (upsert === true) {
344
+ updateOne = {
345
+ filter,
346
+ update: Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
347
+ upsert: true
348
+ };
349
+ }
350
+ else {
351
+ updateOne = {
352
+ filter,
353
+ update: {
354
+ $setOnInsert: Object.assign(Object.assign({}, setOnInsert), setFields)
355
+ },
356
+ upsert: true
357
+ };
358
+ }
359
+ bulkWriteOps.push({ updateOne });
338
360
  });
339
361
  }
340
- if (bulkWriteOps4insert.length > 0) {
341
- const bulkWriteResult4insert = yield this.eventSeriesModel.bulkWrite(bulkWriteOps4insert, { ordered: false });
342
- // modifiedの場合upsertedIdsに含まれないので、idを検索する
343
- const modifiedEvents = yield this.eventSeriesModel.find({ $or: queryFilters }, { _id: 1 })
344
- .exec();
345
- return { bulkWriteResult4insert, modifiedEvents };
346
- }
347
- });
348
- }
349
- saveEventSeries(params) {
350
- return __awaiter(this, void 0, void 0, function* () {
351
- let savedEventId;
352
- let doc;
353
- const _a = params.attributes, { identifier, project, typeOf } = _a, updateFields = __rest(_a, ["identifier", "project", "typeOf"]);
354
- if (typeof typeOf !== 'string' || typeOf.length === 0) {
355
- throw new factory.errors.ArgumentNull('attributes.typeOf');
356
- }
357
- try {
358
- if (params.id === undefined) {
359
- const uniqid = yield Promise.resolve().then(() => require('uniqid'));
360
- const id = uniqid();
361
- doc = yield this.eventSeriesModel.create(Object.assign(Object.assign({}, params.attributes), { _id: id }));
362
- savedEventId = id;
362
+ if (bulkWriteOps.length > 0) {
363
+ const bulkWriteResult = yield this.eventSeriesModel.bulkWrite(bulkWriteOps, { ordered: false });
364
+ // upsert:falseの場合、upsertedIdsのみmodifiedEventsとして返せばよい(2026-01-27~)
365
+ if (!upsert) {
366
+ // BulkWriteResult -> upsertedIds: { '0': '7iri6p4m54k0r3g' }
367
+ return {
368
+ bulkWriteResult,
369
+ modifiedEvents: Object.values(bulkWriteResult.upsertedIds)
370
+ .map((id) => ({ id: String(id) }))
371
+ };
363
372
  }
364
373
  else {
365
- // const upsert: boolean = params.upsert === true;
366
- const upsert = false;
367
- doc = yield this.eventSeriesModel.findOneAndUpdate({
368
- _id: { $eq: params.id },
369
- typeOf: { $eq: typeOf }
370
- }, Object.assign({
371
- // 上書き禁止属性を除外(2022-08-24~)
372
- $setOnInsert: Object.assign({ typeOf,
373
- project }, (identifier !== undefined) ? { identifier } : undefined), $set: updateFields }, (params.$unset !== undefined) ? { $unset: params.$unset } : undefined), {
374
- upsert,
375
- new: true,
376
- projection: { _id: 1 }
377
- })
378
- .lean()
374
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
375
+ const modifiedEvents = yield this.eventSeriesModel.find({ $or: queryFilters }, { _id: 1 })
379
376
  .exec();
380
- savedEventId = params.id;
381
- }
382
- }
383
- catch (error) {
384
- if (yield (0, errorHandler_1.isMongoError)(error)) {
385
- if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
386
- throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEventSeries, ['workPerformed.version']);
387
- }
377
+ return { bulkWriteResult, modifiedEvents };
388
378
  }
389
- throw error;
390
379
  }
391
- if (doc === null) {
392
- throw new factory.errors.NotFound(this.eventSeriesModel.modelName);
393
- }
394
- return { id: savedEventId }; // optimize(2024-07-31~)
380
+ return { modifiedEvents: [] };
395
381
  });
396
382
  }
383
+ // public async saveEventSeries(params: {
384
+ // id?: string;
385
+ // attributes: factory.eventSeries.IAttributes;
386
+ // /**
387
+ // * ドキュメント作成時には無視される
388
+ // */
389
+ // $unset?: IUnset;
390
+ // // upsert?: boolean;
391
+ // }): Promise<{ id: string }> {
392
+ // let savedEventId: string;
393
+ // let doc: Document | { _id: string } | null;
394
+ // const { identifier, project, typeOf, ...updateFields } = params.attributes;
395
+ // if (typeof typeOf !== 'string' || typeOf.length === 0) {
396
+ // throw new factory.errors.ArgumentNull('attributes.typeOf');
397
+ // }
398
+ // try {
399
+ // if (params.id === undefined) {
400
+ // const uniqid = await import('uniqid');
401
+ // const id = uniqid();
402
+ // doc = await this.eventSeriesModel.create({ ...params.attributes, _id: id });
403
+ // savedEventId = id;
404
+ // } else {
405
+ // // const upsert: boolean = params.upsert === true;
406
+ // const upsert: boolean = false;
407
+ // doc = await this.eventSeriesModel.findOneAndUpdate(
408
+ // {
409
+ // _id: { $eq: params.id },
410
+ // typeOf: { $eq: typeOf }
411
+ // },
412
+ // {
413
+ // // 上書き禁止属性を除外(2022-08-24~)
414
+ // $setOnInsert: {
415
+ // typeOf,
416
+ // project,
417
+ // ...(identifier !== undefined) ? { identifier } : undefined
418
+ // },
419
+ // $set: updateFields,
420
+ // ...(params.$unset !== undefined) ? { $unset: params.$unset } : undefined
421
+ // },
422
+ // {
423
+ // upsert,
424
+ // new: true,
425
+ // projection: { _id: 1 }
426
+ // }
427
+ // )
428
+ // .lean<{ _id: string }>()
429
+ // .exec();
430
+ // savedEventId = params.id;
431
+ // }
432
+ // } catch (error) {
433
+ // if (await isMongoError(error)) {
434
+ // if (error.code === MongoErrorCode.DuplicateKey) {
435
+ // throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEventSeries, ['workPerformed.version']);
436
+ // }
437
+ // }
438
+ // throw error;
439
+ // }
440
+ // if (doc === null) {
441
+ // throw new factory.errors.NotFound(this.eventSeriesModel.modelName);
442
+ // }
443
+ // return { id: savedEventId }; // optimize(2024-07-31~)
444
+ // }
397
445
  /**
398
446
  * sskts施設コンテンツ保管
399
447
  */
@@ -541,5 +589,11 @@ class EventSeriesRepo {
541
589
  .sort({ startDate: factory.sortType.Descending })
542
590
  .cursor();
543
591
  }
592
+ unsetUnnecessaryFields(params) {
593
+ return __awaiter(this, void 0, void 0, function* () {
594
+ return this.eventSeriesModel.updateMany(params.filter, { $unset: params.$unset }, { timestamps: false })
595
+ .exec();
596
+ });
597
+ }
544
598
  }
545
599
  exports.EventSeriesRepo = EventSeriesRepo;
@@ -11,7 +11,6 @@ const schemaDefinition = {
11
11
  project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
12
  typeOf: { type: String, required: true },
13
13
  reservationFor: { type: mongoose_1.SchemaTypes.Mixed, required: true },
14
- // aggregateEntranceGate: SchemaTypes.Mixed, // discontinue(2024-12-23~)
15
14
  aggregateOffer: mongoose_1.SchemaTypes.Mixed
16
15
  };
17
16
  const schemaOptions = {
@@ -8,31 +8,10 @@ const factory = require("../../../factory");
8
8
  const settings_1 = require("../../../settings");
9
9
  const modelName = 'EventSeries';
10
10
  exports.modelName = modelName;
11
- const schemaDefinition = {
12
- project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
13
- organizer: { type: mongoose_1.SchemaTypes.Mixed, required: true },
14
- _id: String,
15
- typeOf: { type: String, required: true },
16
- identifier: String,
17
- name: mongoose_1.SchemaTypes.Mixed,
18
- additionalProperty: mongoose_1.SchemaTypes.Mixed,
19
- alternativeHeadline: mongoose_1.SchemaTypes.Mixed,
20
- description: mongoose_1.SchemaTypes.Mixed,
21
- duration: String,
22
- endDate: { type: Date, required: true }, // required(2025-10-08~)
23
- eventStatus: String,
24
- headline: mongoose_1.SchemaTypes.Mixed,
25
- location: mongoose_1.SchemaTypes.Mixed,
26
- startDate: { type: Date, required: true }, // required(2025-10-08~)
27
- workPerformed: mongoose_1.SchemaTypes.Mixed,
28
- videoFormat: mongoose_1.SchemaTypes.Mixed,
29
- soundFormat: mongoose_1.SchemaTypes.Mixed,
30
- subtitleLanguage: mongoose_1.SchemaTypes.Mixed,
31
- dubLanguage: mongoose_1.SchemaTypes.Mixed,
32
- kanaName: String,
33
- offers: mongoose_1.SchemaTypes.Mixed,
34
- coaInfo: mongoose_1.SchemaTypes.Mixed
35
- };
11
+ const schemaDefinition = Object.assign({ project: { type: mongoose_1.SchemaTypes.Mixed, required: true }, organizer: { type: mongoose_1.SchemaTypes.Mixed, required: true }, _id: String, typeOf: { type: String, required: true }, identifier: String, name: mongoose_1.SchemaTypes.Mixed, additionalProperty: mongoose_1.SchemaTypes.Mixed, alternativeHeadline: mongoose_1.SchemaTypes.Mixed, description: mongoose_1.SchemaTypes.Mixed, duration: String, endDate: { type: Date, required: true }, eventStatus: String, headline: mongoose_1.SchemaTypes.Mixed, location: mongoose_1.SchemaTypes.Mixed, startDate: { type: Date, required: true }, subEvent: mongoose_1.SchemaTypes.Mixed, workPerformed: mongoose_1.SchemaTypes.Mixed, soundFormat: mongoose_1.SchemaTypes.Mixed, subtitleLanguage: mongoose_1.SchemaTypes.Mixed, dubLanguage: mongoose_1.SchemaTypes.Mixed, kanaName: String, offers: mongoose_1.SchemaTypes.Mixed, coaInfo: mongoose_1.SchemaTypes.Mixed }, {
12
+ // factory.eventSeries.IEventから廃止したので、ひとまずspread operatorで解決(2026-02-10~)
13
+ videoFormat: mongoose_1.SchemaTypes.Mixed
14
+ });
36
15
  const schemaOptions = {
37
16
  autoIndex: settings_1.MONGO_AUTO_INDEX,
38
17
  autoCreate: false,
@@ -146,6 +125,15 @@ const indexes = [
146
125
  }
147
126
  }
148
127
  ],
128
+ [
129
+ { 'subEvent.videoFormat': 1, startDate: 1 },
130
+ {
131
+ name: 'subEventVideoFormat',
132
+ partialFilterExpression: {
133
+ 'subEvent.videoFormat': { $exists: true }
134
+ }
135
+ }
136
+ ],
149
137
  [
150
138
  { 'soundFormat.typeOf': 1, startDate: 1 },
151
139
  {