@chevre/domain 23.2.0-alpha.4 → 23.2.0-alpha.40

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 (86) hide show
  1. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +1 -1
  2. package/example/src/chevre/eventSeries/migrateEventSeriesOffers.ts +75 -0
  3. package/example/src/chevre/eventSeries/migrateEventSeriesVideoFormat.ts +80 -0
  4. package/example/src/chevre/{upsertScreeningEventSeriesByVersion.ts → eventSeries/upsertScreeningEventSeriesByVersion.ts} +47 -42
  5. package/example/src/chevre/{upsertOfferCatalogItemsByIdentifier.ts → offerCatalog/upsertOfferCatalogItemsByIdentifier.ts} +3 -3
  6. package/example/src/chevre/{upsertOfferCatalogsByIdentifier.ts → offerCatalog/upsertOfferCatalogsByIdentifier.ts} +4 -3
  7. package/example/src/chevre/place/adminEntranceGates.ts +69 -0
  8. package/example/src/chevre/place/checkEntranceGatesCount.ts +82 -0
  9. package/example/src/chevre/place/findRooms.ts +24 -0
  10. package/example/src/chevre/place/findSections.ts +28 -0
  11. package/example/src/chevre/place/migrateSectionIdentifier.ts +92 -0
  12. package/example/src/chevre/place/seatsJson2csv.ts +63 -0
  13. package/example/src/chevre/place/upsertMovieTheatersByBranchCode.ts +41 -0
  14. package/example/src/chevre/place/upsertRoomsByBranchCode.ts +40 -0
  15. package/example/src/chevre/place/upsertSeatSectionsByBranchCode.ts +56 -0
  16. package/example/src/chevre/reIndex.ts +1 -1
  17. package/example/src/chevre/roles/addAdminEventSeriesReadPermissionIfNotExists.ts +49 -0
  18. package/example/src/chevre/roles/addAdminMovieReadPermissionIfNotExists.ts +49 -0
  19. package/example/src/chevre/roles/addAdminMovieTheaterReadPermissionIfNotExists.ts +34 -0
  20. package/example/src/chevre/roles/addAdminMovieTheaterWritePermissionIfNotExists.ts +34 -0
  21. package/example/src/chevre/roles/addAdminRoomReadPermissionIfNotExists.ts +34 -0
  22. package/example/src/chevre/roles/addAdminRoomWritePermissionIfNotExists.ts +34 -0
  23. package/example/src/chevre/unsetUnnecessaryFields.ts +8 -4
  24. package/lib/chevre/factory/event.js +5 -5
  25. package/lib/chevre/repo/aggregateOrder.js +0 -93
  26. package/lib/chevre/repo/aggregateReservation.d.ts +0 -1
  27. package/lib/chevre/repo/aggregateReservation.js +0 -2
  28. package/lib/chevre/repo/creativeWork.js +9 -5
  29. package/lib/chevre/repo/event.d.ts +2 -2
  30. package/lib/chevre/repo/event.js +20 -8
  31. package/lib/chevre/repo/eventOffer.d.ts +8 -0
  32. package/lib/chevre/repo/eventOffer.js +11 -0
  33. package/lib/chevre/repo/eventSeries.d.ts +10 -4
  34. package/lib/chevre/repo/eventSeries.js +56 -28
  35. package/lib/chevre/repo/mongoose/schemas/aggregateReservation.js +0 -1
  36. package/lib/chevre/repo/mongoose/schemas/creativeWork.js +10 -9
  37. package/lib/chevre/repo/mongoose/schemas/eventSeries.js +10 -0
  38. package/lib/chevre/repo/mongoose/schemas/place.d.ts +6 -2
  39. package/lib/chevre/repo/offerCatalog.d.ts +6 -1
  40. package/lib/chevre/repo/offerCatalog.js +26 -17
  41. package/lib/chevre/repo/offerCatalogItem.d.ts +6 -1
  42. package/lib/chevre/repo/offerCatalogItem.js +24 -15
  43. package/lib/chevre/repo/place/entranceGate.d.ts +57 -0
  44. package/lib/chevre/repo/place/entranceGate.js +172 -0
  45. package/lib/chevre/repo/place/movieTheater.d.ts +40 -3
  46. package/lib/chevre/repo/place/movieTheater.js +77 -6
  47. package/lib/chevre/repo/place/screeningRoom.d.ts +60 -31
  48. package/lib/chevre/repo/place/screeningRoom.js +227 -135
  49. package/lib/chevre/repo/place/seat.d.ts +47 -45
  50. package/lib/chevre/repo/place/seat.js +175 -45
  51. package/lib/chevre/repo/place/section.d.ts +60 -30
  52. package/lib/chevre/repo/place/section.js +337 -127
  53. package/lib/chevre/repo/task.d.ts +1 -1
  54. package/lib/chevre/repository.d.ts +8 -0
  55. package/lib/chevre/repository.js +16 -0
  56. package/lib/chevre/service/assetTransaction/reserve/start/factory/createStartParams.js +6 -3
  57. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +1 -1
  58. package/lib/chevre/service/event/processUpdateMovieTheater.js +13 -11
  59. package/lib/chevre/service/event/saveScreeningEvents.d.ts +1 -1
  60. package/lib/chevre/service/event/saveScreeningEvents.js +6 -5
  61. package/lib/chevre/service/offer/event/authorize/factory.js +4 -1
  62. package/lib/chevre/service/offer/event/searchEventTicketOffers.js +7 -4
  63. package/lib/chevre/service/offer/event/searchOfferAppliesToMovieTicket.js +9 -6
  64. package/lib/chevre/service/offer/event/searchOffersByIds.js +7 -4
  65. package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.js +4 -13
  66. package/lib/chevre/service/offer/onEventChanged.js +7 -5
  67. package/lib/chevre/service/offer.d.ts +5 -0
  68. package/lib/chevre/service/offer.js +34 -9
  69. package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
  70. package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
  71. package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
  72. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.d.ts +1 -1
  73. package/lib/chevre/service/task/createEvent/createEventBySchedule/factory.js +5 -3
  74. package/lib/chevre/service/task/createEvent/createEventBySchedule/schedule2events.js +1 -1
  75. package/lib/chevre/service/task/onResourceDeleted.d.ts +6 -0
  76. package/lib/chevre/service/task/onResourceDeleted.js +60 -0
  77. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.d.ts +3 -7
  78. package/lib/chevre/service/task/onResourceUpdated/onResourceDeleted.js +19 -7
  79. package/lib/chevre/service/task/onResourceUpdated.js +206 -42
  80. package/lib/chevre/service/task/syncResourcesFromCOA.js +1 -1
  81. package/lib/chevre/service/taskHandler.js +1 -0
  82. package/package.json +4 -3
  83. package/example/src/chevre/event/upsertManyScreeningEventByIdentifier.ts +0 -191
  84. package/example/src/chevre/offers/createSampleOffers.ts +0 -154
  85. package/lib/chevre/service/eventOld.d.ts +0 -60
  86. package/lib/chevre/service/eventOld.js +0 -864
@@ -50,7 +50,7 @@ class CreativeWorkRepo {
50
50
  }
51
51
  // tslint:disable-next-line:max-func-body-length
52
52
  static CREATE_MONGO_CONDITIONS(params) {
53
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
53
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
54
54
  const andConditions = [
55
55
  { typeOf: { $eq: factory.creativeWorkType.Movie } }
56
56
  ];
@@ -90,12 +90,16 @@ class CreativeWorkRepo {
90
90
  if (Array.isArray(identifierIn)) {
91
91
  andConditions.push({ identifier: { $in: identifierIn } });
92
92
  }
93
+ const identifierRegex = (_k = params.identifier) === null || _k === void 0 ? void 0 : _k.$regex;
94
+ if (typeof identifierRegex === 'string' && identifierRegex !== '') {
95
+ andConditions.push({ identifier: { $regex: new RegExp(identifierRegex) } });
96
+ }
93
97
  }
94
98
  if (typeof params.name === 'string' && params.name.length > 0) {
95
99
  // 多言語名称対応(2022-07-11~)
96
100
  andConditions.push({
97
101
  $or: [
98
- { name: { $exists: true, $regex: new RegExp(params.name) } },
102
+ // { name: { $exists: true, $regex: new RegExp(params.name) } }, // string型への互換性維持を廃止(2025-12-20~)
99
103
  { 'name.ja': { $exists: true, $regex: new RegExp(params.name) } },
100
104
  { 'name.en': { $exists: true, $regex: new RegExp(params.name) } }
101
105
  ]
@@ -111,15 +115,15 @@ class CreativeWorkRepo {
111
115
  if (params.datePublishedThrough !== undefined) {
112
116
  andConditions.push({ datePublished: { $exists: true, $lte: params.datePublishedThrough } });
113
117
  }
114
- const offersAvailableFrom = (_k = params.offers) === null || _k === void 0 ? void 0 : _k.availableFrom;
118
+ const offersAvailableFrom = (_l = params.offers) === null || _l === void 0 ? void 0 : _l.availableFrom;
115
119
  if (offersAvailableFrom instanceof Date) {
116
120
  andConditions.push({ 'offers.availabilityEnds': { $exists: true, $gte: offersAvailableFrom } });
117
121
  }
118
- const offersAvailableThrough = (_l = params.offers) === null || _l === void 0 ? void 0 : _l.availableThrough;
122
+ const offersAvailableThrough = (_m = params.offers) === null || _m === void 0 ? void 0 : _m.availableThrough;
119
123
  if (offersAvailableThrough instanceof Date) {
120
124
  andConditions.push({ 'offers.availabilityStarts': { $exists: true, $lte: offersAvailableThrough } });
121
125
  }
122
- const additionalPropertyElemMatch = (_m = params.additionalProperty) === null || _m === void 0 ? void 0 : _m.$elemMatch;
126
+ const additionalPropertyElemMatch = (_o = params.additionalProperty) === null || _o === void 0 ? void 0 : _o.$elemMatch;
123
127
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
124
128
  andConditions.push({
125
129
  additionalProperty: {
@@ -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
  */
@@ -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;
@@ -27,17 +27,23 @@ export declare class EventSeriesRepo {
27
27
  attributes: factory.eventSeries.IAttributes;
28
28
  }[]): Promise<BulkWriteResult | void>;
29
29
  /**
30
- * コンテンツ+バージョンをキーにして冪等置換
30
+ * 施設+コンテンツ+バージョンをキーにして冪等置換
31
31
  */
32
32
  upsertByVersion(params: {
33
33
  $set: factory.eventSeries.IAttributes;
34
34
  $unset?: IUnset;
35
- }[]): Promise<{
36
- bulkWriteResult4insert: BulkWriteResult;
35
+ }[], options: {
36
+ /**
37
+ * falseの場合setOnInsertのみ
38
+ * trueの場合setOnInsert+setのみ
39
+ */
40
+ upsert: boolean;
41
+ }): Promise<{
42
+ bulkWriteResult?: BulkWriteResult;
37
43
  modifiedEvents: {
38
44
  id: string;
39
45
  }[];
40
- } | void>;
46
+ }>;
41
47
  saveEventSeries(params: {
42
48
  id?: string;
43
49
  attributes: factory.eventSeries.IAttributes;
@@ -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') {
@@ -294,13 +298,13 @@ class EventSeriesRepo {
294
298
  });
295
299
  }
296
300
  /**
297
- * コンテンツ+バージョンをキーにして冪等置換
301
+ * 施設+コンテンツ+バージョンをキーにして冪等置換
298
302
  */
299
- // tslint:disable-next-line:max-func-body-length
300
- upsertByVersion(params) {
303
+ upsertByVersion(params, options) {
301
304
  return __awaiter(this, void 0, void 0, function* () {
305
+ const { upsert } = options;
302
306
  const uniqid = yield Promise.resolve().then(() => require('uniqid'));
303
- const bulkWriteOps4insert = [];
307
+ const bulkWriteOps = [];
304
308
  const queryFilters = [];
305
309
  if (Array.isArray(params)) {
306
310
  params.forEach(({ $set, $unset }) => {
@@ -329,21 +333,45 @@ class EventSeriesRepo {
329
333
  typeOf,
330
334
  _id: uniqid()
331
335
  };
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 });
336
+ let updateOne;
337
+ if (upsert === true) {
338
+ updateOne = {
339
+ filter,
340
+ update: Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
341
+ upsert: true
342
+ };
343
+ }
344
+ else {
345
+ updateOne = {
346
+ filter,
347
+ update: {
348
+ $setOnInsert: Object.assign(Object.assign({}, setOnInsert), setFields)
349
+ },
350
+ upsert: true
351
+ };
352
+ }
353
+ bulkWriteOps.push({ updateOne });
338
354
  });
339
355
  }
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 };
356
+ if (bulkWriteOps.length > 0) {
357
+ const bulkWriteResult = yield this.eventSeriesModel.bulkWrite(bulkWriteOps, { ordered: false });
358
+ // upsert:falseの場合、upsertedIdsのみmodifiedEventsとして返せばよい(2026-01-27~)
359
+ if (!upsert) {
360
+ // BulkWriteResult -> upsertedIds: { '0': '7iri6p4m54k0r3g' }
361
+ return {
362
+ bulkWriteResult,
363
+ modifiedEvents: Object.values(bulkWriteResult.upsertedIds)
364
+ .map((id) => ({ id: String(id) }))
365
+ };
366
+ }
367
+ else {
368
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
369
+ const modifiedEvents = yield this.eventSeriesModel.find({ $or: queryFilters }, { _id: 1 })
370
+ .exec();
371
+ return { bulkWriteResult, modifiedEvents };
372
+ }
346
373
  }
374
+ return { modifiedEvents: [] };
347
375
  });
348
376
  }
349
377
  saveEventSeries(params) {
@@ -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 = {
@@ -67,15 +67,16 @@ const indexes = [
67
67
  name: 'searchByProjectId-v20220721'
68
68
  }
69
69
  ],
70
- [
71
- { name: 1, identifier: 1 },
72
- {
73
- name: 'searchByName2',
74
- partialFilterExpression: {
75
- name: { $exists: true }
76
- }
77
- }
78
- ],
70
+ // string型への互換性維持を廃止(2025-12-20~
71
+ // [
72
+ // { name: 1, identifier: 1 },
73
+ // {
74
+ // name: 'searchByName2',
75
+ // partialFilterExpression: {
76
+ // name: { $exists: true }
77
+ // }
78
+ // }
79
+ // ],
79
80
  [
80
81
  { 'name.ja': 1, identifier: 1 },
81
82
  {
@@ -24,6 +24,7 @@ const schemaDefinition = {
24
24
  headline: mongoose_1.SchemaTypes.Mixed,
25
25
  location: mongoose_1.SchemaTypes.Mixed,
26
26
  startDate: { type: Date, required: true }, // required(2025-10-08~)
27
+ subEvent: mongoose_1.SchemaTypes.Mixed, // support(2025-12-31~)
27
28
  workPerformed: mongoose_1.SchemaTypes.Mixed,
28
29
  videoFormat: mongoose_1.SchemaTypes.Mixed,
29
30
  soundFormat: mongoose_1.SchemaTypes.Mixed,
@@ -146,6 +147,15 @@ const indexes = [
146
147
  }
147
148
  }
148
149
  ],
150
+ [
151
+ { 'subEvent.videoFormat': 1, startDate: 1 },
152
+ {
153
+ name: 'subEventVideoFormat',
154
+ partialFilterExpression: {
155
+ 'subEvent.videoFormat': { $exists: true }
156
+ }
157
+ }
158
+ ],
149
159
  [
150
160
  { 'soundFormat.typeOf': 1, startDate: 1 },
151
161
  {
@@ -1,9 +1,13 @@
1
1
  import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
2
  import * as factory from '../../../factory';
3
- type IDocType = factory.place.screeningRoom.IPlace & {
3
+ type ISeatSection = Pick<factory.place.screeningRoomSection.IPlace, 'additionalProperty' | 'branchCode' | 'name' | 'typeOf'> & {
4
+ containsPlace?: factory.place.seat.IPlace[];
5
+ };
6
+ type IDocType = Omit<factory.place.screeningRoom.IPlace, 'containsPlace'> & {
4
7
  description?: any;
5
8
  openingHoursSpecification?: any;
6
9
  smokingAllowed?: boolean;
10
+ containsPlace: ISeatSection[];
7
11
  };
8
12
  type IModel = Model<IDocType>;
9
13
  type ISchemaDefinition = SchemaDefinition<IDocType>;
@@ -11,4 +15,4 @@ type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocT
11
15
  declare const modelName = "Place";
12
16
  declare const indexes: [d: IndexDefinition, o: IndexOptions][];
13
17
  declare function createSchema(): ISchema;
14
- export { createSchema, IModel, indexes, modelName };
18
+ export { createSchema, IDocType, IModel, indexes, modelName };
@@ -35,7 +35,12 @@ export declare class OfferCatalogRepo {
35
35
  $unset?: {
36
36
  [key in keyof factory.offerCatalog.IOfferCatalog]?: 1;
37
37
  };
38
- }[]): Promise<{
38
+ }[], options: {
39
+ /**
40
+ * support only update(2026-01-30~)
41
+ */
42
+ update: boolean;
43
+ }): Promise<{
39
44
  bulkWriteResult: BulkWriteResult;
40
45
  modifiedCatalogs: {
41
46
  id: string;
@@ -195,11 +195,9 @@ class OfferCatalogRepo {
195
195
  /**
196
196
  * コードをキーにして冪等置換(2023-12-14~)
197
197
  */
198
- upsertManyByIdentifier(params
199
- // options?: {
200
- // }
201
- ) {
198
+ upsertManyByIdentifier(params, options) {
202
199
  return __awaiter(this, void 0, void 0, function* () {
200
+ const { update } = options;
203
201
  const uniqid = yield Promise.resolve().then(() => require('uniqid'));
204
202
  const bulkWriteOps = [];
205
203
  const queryFilters = [];
@@ -218,19 +216,30 @@ class OfferCatalogRepo {
218
216
  'project.id': { $eq: project.id },
219
217
  identifier: { $eq: identifier }
220
218
  });
221
- const newId = uniqid();
222
- const setOnInsert = {
223
- identifier,
224
- project,
225
- typeOf,
226
- _id: newId
227
- };
228
- const updateOne = {
229
- filter,
230
- update: Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
231
- upsert: true
232
- };
233
- bulkWriteOps.push({ updateOne });
219
+ if (update === true) {
220
+ const updateOne = {
221
+ filter,
222
+ update: Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
223
+ upsert: false
224
+ };
225
+ bulkWriteOps.push({ updateOne });
226
+ }
227
+ else {
228
+ // デフォルトはupsert操作
229
+ const newId = uniqid();
230
+ const setOnInsert = {
231
+ identifier,
232
+ project,
233
+ typeOf,
234
+ _id: newId
235
+ };
236
+ const updateOne = {
237
+ filter,
238
+ update: Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
239
+ upsert: true
240
+ };
241
+ bulkWriteOps.push({ updateOne });
242
+ }
234
243
  });
235
244
  }
236
245
  if (bulkWriteOps.length > 0) {
@@ -32,7 +32,12 @@ export declare class OfferCatalogItemRepo {
32
32
  $unset?: {
33
33
  [key in keyof factory.offerCatalog.IOfferCatalog]?: 1;
34
34
  };
35
- }[]): Promise<{
35
+ }[], options: {
36
+ /**
37
+ * support only update(2026-01-30~)
38
+ */
39
+ update: boolean;
40
+ }): Promise<{
36
41
  bulkWriteResult: BulkWriteResult;
37
42
  modifiedCatalogs: {
38
43
  id: string;
@@ -159,11 +159,9 @@ class OfferCatalogItemRepo {
159
159
  /**
160
160
  * コードをキーにして冪等置換(2023-12-14~)
161
161
  */
162
- upsertManyByIdentifier(params
163
- // options?: {
164
- // }
165
- ) {
162
+ upsertManyByIdentifier(params, options) {
166
163
  return __awaiter(this, void 0, void 0, function* () {
164
+ const { update } = options;
167
165
  const bulkWriteOps = [];
168
166
  const queryFilters = [];
169
167
  if (Array.isArray(params)) {
@@ -181,17 +179,28 @@ class OfferCatalogItemRepo {
181
179
  'project.id': { $eq: project.id },
182
180
  identifier: { $eq: identifier }
183
181
  });
184
- const setOnInsert = {
185
- identifier,
186
- project,
187
- typeOf
188
- };
189
- const updateOne = {
190
- filter,
191
- update: Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
192
- upsert: true
193
- };
194
- bulkWriteOps.push({ updateOne });
182
+ if (update === true) {
183
+ const updateOne = {
184
+ filter,
185
+ update: Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
186
+ upsert: false
187
+ };
188
+ bulkWriteOps.push({ updateOne });
189
+ }
190
+ else {
191
+ // デフォルトはupsert操作
192
+ const setOnInsert = {
193
+ identifier,
194
+ project,
195
+ typeOf
196
+ };
197
+ const updateOne = {
198
+ filter,
199
+ update: Object.assign({ $setOnInsert: setOnInsert, $set: setFields }, ($unset !== undefined) ? { $unset } : undefined),
200
+ upsert: true
201
+ };
202
+ bulkWriteOps.push({ updateOne });
203
+ }
195
204
  });
196
205
  }
197
206
  if (bulkWriteOps.length > 0) {
@@ -0,0 +1,57 @@
1
+ import type { BulkWriteResult } from 'mongodb';
2
+ import { Connection } from 'mongoose';
3
+ import * as factory from '../../factory';
4
+ /**
5
+ * ゲートを操作する組織
6
+ */
7
+ interface IOperator {
8
+ /**
9
+ * 施設ID
10
+ */
11
+ id: string;
12
+ }
13
+ type IEntranceGate = Pick<factory.place.entranceGate.IEntranceGate, 'identifier' | 'name'>;
14
+ type ICreatingEntranceGate = Pick<factory.place.entranceGate.IEntranceGate, 'identifier' | 'name'>;
15
+ interface IUpdateOptions {
16
+ project: {
17
+ id: string;
18
+ };
19
+ }
20
+ /**
21
+ * 施設の入場ゲートリポジトリ
22
+ */
23
+ export declare class EntranceGateRepo {
24
+ /**
25
+ * 施設
26
+ */
27
+ private readonly operator;
28
+ private readonly civicStructureModel;
29
+ constructor(connection: Connection, operater: IOperator);
30
+ /**
31
+ * リポジトリの施設をセットする
32
+ */
33
+ setOperatorId(params: {
34
+ id: string;
35
+ }): void;
36
+ findEntranceGates(params: factory.place.entranceGate.ISearchConditions): Promise<IEntranceGate[]>;
37
+ addEntranceGatesByIdentifierIfNotExist(params: {
38
+ $set: ICreatingEntranceGate;
39
+ }[], options: IUpdateOptions): Promise<{
40
+ bulkWriteResult?: BulkWriteResult;
41
+ }>;
42
+ updateEntranceGatesByIdentifier(params: {
43
+ $set: ICreatingEntranceGate;
44
+ }[], options: IUpdateOptions): Promise<{
45
+ bulkWriteResult?: BulkWriteResult;
46
+ }>;
47
+ deleteEntranceGatesByIdentifier(params: {
48
+ /**
49
+ * ゲートコード
50
+ */
51
+ identifier: string;
52
+ }[], options: IUpdateOptions): Promise<{
53
+ bulkWriteResult?: BulkWriteResult;
54
+ }>;
55
+ private createMatchStages;
56
+ }
57
+ export {};