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

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 (173) 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/testRandomness.ts +54 -0
  12. package/example/src/chevre/place/adminEntranceGates.ts +69 -0
  13. package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
  14. package/example/src/chevre/place/findRooms.ts +24 -0
  15. package/example/src/chevre/place/findSections.ts +28 -0
  16. package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
  17. package/example/src/chevre/place/seatsJson2csv.ts +63 -0
  18. package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
  19. package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
  20. package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
  21. package/example/src/chevre/reIndex.ts +1 -1
  22. package/example/src/chevre/roles/addAdminAcceptedPaymentMethodReadPermissionIfNotExists.ts +33 -0
  23. package/example/src/chevre/roles/addAdminAcceptedPaymentMethodWritePermissionIfNotExists.ts +33 -0
  24. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  25. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
  26. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
  27. package/example/src/chevre/settings/addOrderNumberSetting.ts +44 -0
  28. package/example/src/chevre/settings/addTransactionNumberSetting.ts +40 -0
  29. package/example/src/chevre/transactionNumber/publishByTimestamp.ts +23 -0
  30. package/example/src/chevre/transactionNumber/testRandomness.ts +42 -0
  31. package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
  32. package/lib/chevre/emailMessageBuilder.js +1 -0
  33. package/lib/chevre/factory/event.d.ts +1 -1
  34. package/lib/chevre/factory/event.js +11 -5
  35. package/lib/chevre/factory/transactionNumber.d.ts +19 -0
  36. package/lib/chevre/factory/transactionNumber.js +54 -0
  37. package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -8
  38. package/lib/chevre/repo/acceptedPaymentMethod.js +72 -27
  39. package/lib/chevre/repo/aggregateOffer.d.ts +6 -1
  40. package/lib/chevre/repo/aggregateOffer.js +11 -3
  41. package/lib/chevre/repo/aggregateOrder.js +0 -93
  42. package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
  43. package/lib/chevre/repo/aggregateReservation.js +0 -2
  44. package/lib/chevre/repo/confirmationNumber.d.ts +1 -0
  45. package/lib/chevre/repo/confirmationNumber.js +32 -25
  46. package/lib/chevre/repo/event.d.ts +3 -18
  47. package/lib/chevre/repo/event.js +94 -83
  48. package/lib/chevre/repo/eventOffer.d.ts +8 -0
  49. package/lib/chevre/repo/eventOffer.js +11 -0
  50. package/lib/chevre/repo/eventSeries.d.ts +17 -30
  51. package/lib/chevre/repo/eventSeries.js +204 -146
  52. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
  53. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +20 -5
  54. package/lib/chevre/repo/mongoose/schemas/offerCatalog.js +2 -8
  55. package/lib/chevre/repo/mongoose/schemas/offerCatalogItem.js +28 -2
  56. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -2
  57. package/lib/chevre/repo/mongoose/schemas/setting.d.ts +40 -0
  58. package/lib/chevre/repo/mongoose/schemas/setting.js +3 -0
  59. package/lib/chevre/repo/offerCatalog.d.ts +14 -1
  60. package/lib/chevre/repo/offerCatalog.js +41 -19
  61. package/lib/chevre/repo/offerCatalogItem.d.ts +10 -1
  62. package/lib/chevre/repo/offerCatalogItem.js +32 -17
  63. package/lib/chevre/repo/orderNumber.d.ts +6 -0
  64. package/lib/chevre/repo/orderNumber.js +110 -35
  65. package/lib/chevre/repo/place/entranceGate.d.ts +57 -0
  66. package/lib/chevre/repo/place/entranceGate.js +172 -0
  67. package/lib/chevre/repo/place/movieTheater.d.ts +40 -3
  68. package/lib/chevre/repo/place/movieTheater.js +77 -6
  69. package/lib/chevre/repo/place/screeningRoom.d.ts +60 -31
  70. package/lib/chevre/repo/place/screeningRoom.js +227 -135
  71. package/lib/chevre/repo/place/seat.d.ts +47 -45
  72. package/lib/chevre/repo/place/seat.js +175 -45
  73. package/lib/chevre/repo/place/section.d.ts +60 -30
  74. package/lib/chevre/repo/place/section.js +337 -127
  75. package/lib/chevre/repo/serviceOutputIdentifier.d.ts +3 -1
  76. package/lib/chevre/repo/serviceOutputIdentifier.js +42 -27
  77. package/lib/chevre/repo/setting.d.ts +1 -1
  78. package/lib/chevre/repo/setting.js +2 -2
  79. package/lib/chevre/repo/task.d.ts +1 -1
  80. package/lib/chevre/repo/transactionNumber.d.ts +5 -0
  81. package/lib/chevre/repo/transactionNumber.js +63 -27
  82. package/lib/chevre/repository.d.ts +8 -0
  83. package/lib/chevre/repository.js +16 -0
  84. package/lib/chevre/service/assetTransaction/fixInformAction.d.ts +3 -0
  85. package/lib/chevre/service/assetTransaction/fixInformAction.js +3 -0
  86. package/lib/chevre/service/assetTransaction/pay/cancel.d.ts +12 -0
  87. package/lib/chevre/service/assetTransaction/pay/cancel.js +25 -0
  88. package/lib/chevre/service/assetTransaction/pay/check.d.ts +23 -0
  89. package/lib/chevre/service/assetTransaction/pay/check.js +37 -0
  90. package/lib/chevre/service/assetTransaction/pay/confirm.d.ts +24 -0
  91. package/lib/chevre/service/assetTransaction/pay/confirm.js +72 -0
  92. package/lib/chevre/service/assetTransaction/pay/exportTasksById.d.ts +18 -0
  93. package/lib/chevre/service/assetTransaction/pay/exportTasksById.js +111 -0
  94. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.d.ts +48 -0
  95. package/lib/chevre/service/assetTransaction/pay/publishPaymentUrl.js +164 -0
  96. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.d.ts +20 -0
  97. package/lib/chevre/service/assetTransaction/pay/searchGMOTrade.js +59 -0
  98. package/lib/chevre/service/assetTransaction/pay/{account → start/account}/validation.d.ts +2 -2
  99. package/lib/chevre/service/assetTransaction/pay/{account → start/account}/validation.js +1 -1
  100. package/lib/chevre/service/assetTransaction/pay/{factory.d.ts → start/factory.d.ts} +1 -1
  101. package/lib/chevre/service/assetTransaction/pay/{factory.js → start/factory.js} +1 -1
  102. package/lib/chevre/service/assetTransaction/pay/{validateAcceptedPaymentMethodIfNeeded.d.ts → start/preStart/validateAcceptedPaymentMethodIfNeeded.d.ts} +4 -4
  103. package/lib/chevre/service/assetTransaction/pay/{validateAcceptedPaymentMethodIfNeeded.js → start/preStart/validateAcceptedPaymentMethodIfNeeded.js} +1 -4
  104. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.d.ts +8 -0
  105. package/lib/chevre/service/assetTransaction/pay/start/preStart/validateSeller.js +54 -0
  106. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.d.ts +13 -0
  107. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeAccount.js +49 -0
  108. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.d.ts +29 -0
  109. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeCreditCard.js +37 -0
  110. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.d.ts +42 -0
  111. package/lib/chevre/service/assetTransaction/pay/start/processAuthorizeMovieTicket.js +31 -0
  112. package/lib/chevre/service/assetTransaction/pay/start.d.ts +60 -0
  113. package/lib/chevre/service/assetTransaction/pay/start.js +145 -0
  114. package/lib/chevre/service/assetTransaction/pay.d.ts +8 -170
  115. package/lib/chevre/service/assetTransaction/pay.js +16 -623
  116. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +10 -2
  117. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
  118. package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
  119. package/lib/chevre/service/event/saveScreeningEventSeries.js +4 -5
  120. package/lib/chevre/service/event/saveScreeningEvents.d.ts +2 -2
  121. package/lib/chevre/service/event/saveScreeningEvents.js +16 -12
  122. package/lib/chevre/service/offer/event/authorize/factory.js +9 -1
  123. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
  124. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
  125. package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
  126. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +7 -1
  127. package/lib/chevre/service/offer/onEventChanged.js +10 -6
  128. package/lib/chevre/service/offer/product.js +1 -1
  129. package/lib/chevre/service/offer.d.ts +5 -0
  130. package/lib/chevre/service/offer.js +34 -9
  131. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  132. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  133. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  134. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.d.ts +13 -0
  135. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByAggregateOffer.js +53 -0
  136. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.d.ts +13 -0
  137. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByEventSeries.js +56 -0
  138. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.d.ts +15 -0
  139. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByMovieTheater.js +58 -0
  140. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.d.ts +17 -0
  141. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByOfferCatalog.js +75 -0
  142. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.d.ts +19 -0
  143. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByProduct.js +60 -0
  144. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.d.ts +20 -0
  145. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesByRoom.js +51 -0
  146. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.d.ts +27 -0
  147. package/lib/chevre/service/task/onResourceDeleted/deleteResourcesBySeller.js +100 -0
  148. package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
  149. package/lib/chevre/service/task/onResourceDeleted.js +168 -0
  150. package/lib/chevre/service/task/onResourceUpdated.js +205 -42
  151. package/lib/chevre/service/task/syncResourcesFromCOA.js +4 -2
  152. package/lib/chevre/service/taskHandler.js +1 -0
  153. package/package.json +9 -9
  154. package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
  155. package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +0 -93
  156. package/example/src/chevre/offers/createSampleOffers.ts +0 -154
  157. package/example/src/chevre/settings/addSettings.ts +0 -46
  158. package/lib/chevre/service/eventOld.d.ts +0 -60
  159. package/lib/chevre/service/eventOld.js +0 -864
  160. package/lib/chevre/service/task/createEvent/createEvent.d.ts +0 -25
  161. package/lib/chevre/service/task/createEvent/createEvent.js +0 -45
  162. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +0 -22
  163. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +0 -188
  164. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.d.ts +0 -15
  165. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +0 -116
  166. package/lib/chevre/service/task/createEvent/createEventBySchedule.d.ts +0 -25
  167. package/lib/chevre/service/task/createEvent/createEventBySchedule.js +0 -107
  168. package/lib/chevre/service/task/createEvent/createEventSeries.d.ts +0 -13
  169. package/lib/chevre/service/task/createEvent/createEventSeries.js +0 -118
  170. package/lib/chevre/service/task/createEvent.d.ts +0 -6
  171. package/lib/chevre/service/task/createEvent.js +0 -46
  172. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +0 -45
  173. 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");
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;
@@ -68,13 +68,6 @@ export declare class EventRepo {
68
68
  */
69
69
  static CREATE_ID(): string;
70
70
  static CREATE_MONGO_CONDITIONS(conditions: ISearchConditions): FilterQuery<factory.event.screeningEvent.IEvent>[];
71
- /**
72
- * 複数イベントを作成する
73
- */
74
- createManyEvents(params: {
75
- attributes: factory.event.screeningEvent.IAttributes[];
76
- expectsNoContent: boolean;
77
- }): Promise<string[] | void>;
78
71
  /**
79
72
  * イベントコードをキーにして冪等置換
80
73
  */
@@ -90,11 +83,11 @@ export declare class EventRepo {
90
83
  */
91
84
  update: boolean;
92
85
  }): Promise<{
93
- bulkWriteResult: BulkWriteResult;
86
+ bulkWriteResult?: BulkWriteResult;
94
87
  modifiedEvents: {
95
88
  id: string;
96
89
  }[];
97
- } | void>;
90
+ }>;
98
91
  /**
99
92
  * イベント部分更新
100
93
  */
@@ -127,14 +120,6 @@ export declare class EventRepo {
127
120
  $unset?: IUnset;
128
121
  upsert: boolean;
129
122
  }[]): Promise<void>;
130
- /**
131
- * tttsイベントを識別子によって冪等作成する
132
- */
133
- saveEventByIdentifier4ttts(params: {
134
- attributes: ICreatingEvent4ttts;
135
- }): Promise<{
136
- id: string;
137
- }>;
138
123
  /**
139
124
  * イベントを検索する(inclusion projection)
140
125
  */
@@ -210,7 +195,7 @@ export declare class EventRepo {
210
195
  project: {
211
196
  id: string;
212
197
  };
213
- superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'videoFormat' | 'workPerformed'>;
198
+ superEventFromDB: Pick<factory.eventSeries.IEvent, 'additionalProperty' | 'alternativeHeadline' | 'description' | 'dubLanguage' | 'endDate' | 'headline' | 'id' | 'kanaName' | 'location' | 'name' | 'soundFormat' | 'startDate' | 'subtitleLanguage' | 'typeOf' | 'workPerformed'>;
214
199
  startDate: {
215
200
  $gte: Date;
216
201
  };
@@ -264,33 +264,39 @@ class EventRepo {
264
264
  }
265
265
  return andConditions;
266
266
  }
267
- /**
268
- * 複数イベントを作成する
269
- */
270
- createManyEvents(params) {
271
- return __awaiter(this, void 0, void 0, function* () {
272
- const insertingDocs = params.attributes.map((p) => {
273
- return Object.assign({ _id: EventRepo.CREATE_ID() }, p);
274
- });
275
- try {
276
- yield this.eventModel.insertMany(insertingDocs, { rawResult: true } // rawResult(2024-08-02~)
277
- );
278
- // console.dir(insertResult, { depth: null });
279
- }
280
- catch (error) {
281
- if (yield (0, errorHandler_1.isMongoError)(error)) {
282
- if (error.code === errorHandler_1.MongoErrorCode.DuplicateKey) {
283
- throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEvent, ['offeredBy.member.identifier']);
284
- }
285
- }
286
- throw error;
287
- }
288
- if (params.expectsNoContent) {
289
- return;
290
- }
291
- return insertingDocs.map(({ _id }) => _id);
292
- });
293
- }
267
+ // /**
268
+ // * 複数イベントを作成する
269
+ // */
270
+ // public async createManyEvents(params: {
271
+ // attributes: factory.event.screeningEvent.IAttributes[];
272
+ // expectsNoContent: boolean;
273
+ // }): Promise<string[] | void> { // optimize response(only id)(2024-08-02~)
274
+ // const insertingDocs: (factory.event.screeningEvent.IAttributes & { _id: string })[] =
275
+ // params.attributes.map((p) => {
276
+ // return {
277
+ // _id: EventRepo.CREATE_ID(),
278
+ // ...p
279
+ // };
280
+ // });
281
+ // try {
282
+ // await this.eventModel.insertMany<factory.event.screeningEvent.IAttributes & { _id: string }>(
283
+ // insertingDocs,
284
+ // { rawResult: true } // rawResult(2024-08-02~)
285
+ // );
286
+ // // console.dir(insertResult, { depth: null });
287
+ // } catch (error) {
288
+ // if (await isMongoError(error)) {
289
+ // if (error.code === MongoErrorCode.DuplicateKey) {
290
+ // throw new factory.errors.AlreadyInUse(factory.eventType.ScreeningEvent, ['offeredBy.member.identifier']);
291
+ // }
292
+ // }
293
+ // throw error;
294
+ // }
295
+ // if (params.expectsNoContent) {
296
+ // return;
297
+ // }
298
+ // return insertingDocs.map(({ _id }) => _id);
299
+ // }
294
300
  /**
295
301
  * イベントコードをキーにして冪等置換
296
302
  */
@@ -344,15 +350,27 @@ class EventRepo {
344
350
  }
345
351
  if (bulkWriteOps.length > 0) {
346
352
  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 };
353
+ // update:falseの場合、upsertedIdsのみmodifiedEventsとして返せばよい(2026-01-16~)
354
+ if (!update) {
355
+ // BulkWriteResult -> upsertedIds: { '0': '7iri6p4m54k0r3g' }
356
+ return {
357
+ bulkWriteResult,
358
+ modifiedEvents: Object.values(bulkWriteResult.upsertedIds)
359
+ .map((id) => ({ id: String(id) }))
360
+ };
361
+ }
362
+ else {
363
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
364
+ const modifiedEvents = yield this.eventModel.find({ $or: queryFilters }, {
365
+ _id: 0,
366
+ id: { $toString: '$_id' }
367
+ })
368
+ .lean()
369
+ .exec();
370
+ return { bulkWriteResult, modifiedEvents };
371
+ }
355
372
  }
373
+ return { modifiedEvents: [] };
356
374
  });
357
375
  }
358
376
  /**
@@ -465,54 +483,47 @@ class EventRepo {
465
483
  }
466
484
  });
467
485
  }
468
- /**
469
- * tttsイベントを識別子によって冪等作成する
470
- */
471
- saveEventByIdentifier4ttts(params) {
472
- return __awaiter(this, void 0, void 0, function* () {
473
- // const { oldEventId } = params;
474
- const _a = params.attributes, { project, typeOf, eventStatus, identifier, organizer } = _a, updateFields = __rest(_a, ["project", "typeOf", "eventStatus", "identifier", "organizer"]);
475
- // const identifier = oldEventId;
476
- if (typeof identifier !== 'string' || identifier.length === 0) {
477
- throw new factory.errors.ArgumentNull('identifier');
478
- }
479
- const id = EventRepo.CREATE_ID();
480
- const doc = yield this.eventModel.findOneAndUpdate(
481
- // 全イベントにidentifierを保証したので、additionalPropertyによるフィルターからidentifierによるフィルターへ変更(2025-09-05~)
482
- // {
483
- // 'project.id': { $eq: project.id },
484
- // typeOf: { $eq: typeOf },
485
- // // 追加特性をキーに更新
486
- // additionalProperty: {
487
- // $exists: true,
488
- // $all: [{ name: 'oldEventId', value: identifier }]
489
- // }
490
- // },
491
- {
492
- 'project.id': { $eq: project.id },
493
- identifier: { $exists: true, $eq: identifier }
494
- },
495
- // upsertの場合、createがありうるので属性を除外しない
496
- {
497
- $setOnInsert: {
498
- _id: id,
499
- typeOf,
500
- project,
501
- eventStatus,
502
- organizer,
503
- identifier // イベントコードを必ず追加(2025-09-03~)
504
- // ...(typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined
505
- },
506
- $set: updateFields
507
- }, { upsert: true, new: true, projection: { _id: 1 } })
508
- .lean()
509
- .exec();
510
- if (doc === null) {
511
- throw new factory.errors.NotFound(this.eventModel.modelName);
512
- }
513
- return { id: doc._id }; // optimize(2024-07-31~)
514
- });
515
- }
486
+ // /**
487
+ // * tttsイベントを識別子によって冪等作成する
488
+ // */
489
+ // public async saveEventByIdentifier4ttts(params: {
490
+ // // oldEventId: string;
491
+ // attributes: ICreatingEvent4ttts;
492
+ // }): Promise<{ id: string }> {
493
+ // // const { oldEventId } = params;
494
+ // const { project, typeOf, eventStatus, identifier, organizer, ...updateFields } = params.attributes;
495
+ // // const identifier = oldEventId;
496
+ // if (typeof identifier !== 'string' || identifier.length === 0) {
497
+ // throw new factory.errors.ArgumentNull('identifier');
498
+ // }
499
+ // const id = EventRepo.CREATE_ID();
500
+ // const doc = await this.eventModel.findOneAndUpdate(
501
+ // {
502
+ // 'project.id': { $eq: project.id },
503
+ // identifier: { $exists: true, $eq: identifier }
504
+ // },
505
+ // // upsertの場合、createがありうるので属性を除外しない
506
+ // {
507
+ // $setOnInsert: {
508
+ // _id: id,
509
+ // typeOf,
510
+ // project,
511
+ // eventStatus,
512
+ // organizer,
513
+ // identifier // イベントコードを必ず追加(2025-09-03~)
514
+ // // ...(typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined
515
+ // },
516
+ // $set: updateFields
517
+ // },
518
+ // { upsert: true, new: true, projection: { _id: 1 } }
519
+ // )
520
+ // .lean<{ _id: string }>()
521
+ // .exec();
522
+ // if (doc === null) {
523
+ // throw new factory.errors.NotFound(this.eventModel.modelName);
524
+ // }
525
+ // return { id: doc._id }; // optimize(2024-07-31~)
526
+ // }
516
527
  /**
517
528
  * イベントを検索する(inclusion projection)
518
529
  */
@@ -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
  };
@@ -14,39 +14,22 @@ export declare class EventSeriesRepo {
14
14
  constructor(connection: Connection);
15
15
  static CREATE_MONGO_CONDITIONS(conditions: ISearchConditions): FilterQuery<factory.eventSeries.IEvent>[];
16
16
  /**
17
- * 複数イベントを作成する
18
- */
19
- createManyEventSeries(params: {
20
- attributes: factory.eventSeries.IAttributes[];
21
- expectsNoContent: boolean;
22
- }): Promise<string[] | void>;
23
- /**
24
- * コンテンツ+バージョンをキーにして、なければ作成する(複数対応)
25
- */
26
- createIfNotExistByWorkPerformed(params: {
27
- attributes: factory.eventSeries.IAttributes;
28
- }[]): Promise<BulkWriteResult | void>;
29
- /**
30
- * コンテンツ+バージョンをキーにして冪等置換
17
+ * 施設+コンテンツ+バージョンをキーにして冪等置換
31
18
  */
32
19
  upsertByVersion(params: {
33
20
  $set: factory.eventSeries.IAttributes;
34
21
  $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;
22
+ }[], options: {
44
23
  /**
45
- * ドキュメント作成時には無視される
24
+ * falseの場合setOnInsertのみ
25
+ * trueの場合setOnInsert+setのみ
46
26
  */
47
- $unset?: IUnset;
27
+ upsert: boolean;
48
28
  }): Promise<{
49
- id: string;
29
+ bulkWriteResult?: BulkWriteResult;
30
+ modifiedEvents: {
31
+ id: string;
32
+ }[];
50
33
  }>;
51
34
  /**
52
35
  * sskts施設コンテンツ保管
@@ -103,18 +86,22 @@ export declare class EventSeriesRepo {
103
86
  }): Promise<{
104
87
  maxVersion: string;
105
88
  }>;
106
- getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<Document<unknown, {}, factory.eventSeries.IAttributes & {
89
+ getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, factory.eventSeries.IAttributes & {
107
90
  _id: string;
108
91
  }> & factory.eventSeries.IAttributes & {
109
92
  _id: string;
110
93
  } & Required<{
111
94
  _id: string;
112
- }>, import("mongoose").QueryOptions<Document<unknown, {}, factory.eventSeries.IAttributes & {
95
+ }>, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, factory.eventSeries.IAttributes & {
113
96
  _id: string;
114
97
  }> & factory.eventSeries.IAttributes & {
115
98
  _id: string;
116
99
  } & Required<{
117
100
  _id: string;
118
101
  }>>>;
102
+ unsetUnnecessaryFields(params: {
103
+ filter: FilterQuery<factory.eventSeries.IEvent>;
104
+ $unset: IUnset;
105
+ }): Promise<import("mongoose").UpdateWriteOpResult>;
119
106
  }
120
107
  export {};