@chevre/domain 23.0.0-alpha.8 → 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.
Files changed (66) hide show
  1. package/example/src/chevre/assetTransaction/processReserve.ts +102 -40
  2. package/example/src/chevre/categoryCode/checkUniqueness.ts +69 -0
  3. package/example/src/chevre/event/checkEventAdditionalPropertyUniqueness.ts +108 -0
  4. package/example/src/chevre/event/migrateEventAdditionalProperty2identifier.ts +121 -0
  5. package/example/src/chevre/event/updateSellerMakesOffersByIdentifier.ts +106 -0
  6. package/example/src/chevre/offerCatalog/updateManyOfferCatalogsByIds.ts +49 -0
  7. package/example/src/chevre/paymentServices/findPaymentServices.ts +37 -0
  8. package/example/src/chevre/product/findHasOfferCatalog.ts +31 -0
  9. package/example/src/chevre/reIndex.ts +2 -3
  10. package/example/src/chevre/roles/addAdminNotePermissionIfNotExists.ts +48 -0
  11. package/example/src/chevre/roles/{addAdminProductOfferPermissionIfNotExists.ts → addAdminPaymentServiceReadPermissionIfNotExists.ts} +20 -19
  12. package/example/src/chevre/roles/addAdminProductHasOfferCatalogReadPermissionIfNotExists.ts +33 -0
  13. package/example/src/chevre/roles/addAdminSellerEventIfNotExists.ts +48 -0
  14. package/example/src/chevre/roles/removeConsolePermissionIfExists.ts +1 -1
  15. package/example/src/chevre/roles/removePermissionIfExists.ts +1 -6
  16. package/example/src/chevre/unsetUnnecessaryFields.ts +5 -7
  17. package/example/src/objectId.ts +12 -0
  18. package/example/src/signPayload.ts +12 -7
  19. package/lib/chevre/errorHandler.d.ts +6 -2
  20. package/lib/chevre/errorHandler.js +18 -2
  21. package/lib/chevre/repo/categoryCode.d.ts +26 -14
  22. package/lib/chevre/repo/categoryCode.js +53 -42
  23. package/lib/chevre/repo/event.d.ts +25 -11
  24. package/lib/chevre/repo/event.js +60 -35
  25. package/lib/chevre/repo/eventSellerMakesOffer.d.ts +24 -39
  26. package/lib/chevre/repo/eventSellerMakesOffer.js +88 -43
  27. package/lib/chevre/repo/issuer.js +9 -5
  28. package/lib/chevre/repo/mongoose/schemas/categoryCode.js +48 -42
  29. package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.d.ts +10 -0
  30. package/lib/chevre/repo/mongoose/schemas/movieTicketTypes.js +107 -0
  31. package/lib/chevre/repo/mongoose/schemas/product.d.ts +4 -4
  32. package/lib/chevre/repo/mongoose/schemas/product.js +2 -2
  33. package/lib/chevre/repo/movieTicketType.d.ts +57 -0
  34. package/lib/chevre/repo/movieTicketType.js +253 -0
  35. package/lib/chevre/repo/noteAboutOrder.d.ts +4 -11
  36. package/lib/chevre/repo/noteAboutOrder.js +16 -4
  37. package/lib/chevre/repo/offerCatalog.d.ts +17 -2
  38. package/lib/chevre/repo/offerCatalog.js +5 -2
  39. package/lib/chevre/repo/productHasOfferCatalog.d.ts +43 -0
  40. package/lib/chevre/repo/productHasOfferCatalog.js +71 -0
  41. package/lib/chevre/repository.d.ts +10 -0
  42. package/lib/chevre/repository.js +28 -2
  43. package/lib/chevre/service/assetTransaction/reserve/start.js +2 -2
  44. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +15 -0
  45. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +159 -0
  46. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +16 -0
  47. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +184 -0
  48. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +4 -1
  49. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +25 -139
  50. package/lib/chevre/service/event.js +1 -1
  51. package/lib/chevre/service/offer/event/importFromCOA.js +1 -1
  52. package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +3 -3
  53. package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +3 -3
  54. package/lib/chevre/service/offer/onEventChanged.js +26 -30
  55. package/lib/chevre/service/project.d.ts +3 -0
  56. package/lib/chevre/service/project.js +2 -1
  57. package/lib/chevre/service/task/onResourceUpdated/syncCategoryCode.js +1 -1
  58. package/lib/chevre/service/task/onResourceUpdated.js +1 -1
  59. package/package.json +4 -4
  60. package/example/src/chevre/aggregateEventSellerMakesOffer.ts +0 -32
  61. package/example/src/chevre/event/migrateEventIdentifier4ttts.ts +0 -96
  62. package/example/src/chevre/searchCategoryCodesByAggregate.ts +0 -31
  63. package/example/src/chevre/searchOfferCatalogItems.ts +0 -59
  64. package/example/src/chevre/searchPaymentServices.ts +0 -32
  65. package/example/src/chevre/unsetUnnecessaryFieldsInAction.ts +0 -50
  66. package/example/src/chevre/unsetUnnecessaryFieldsInTransaction.ts +0 -46
@@ -26,10 +26,10 @@ const categoryCode_1 = require("./mongoose/schemas/categoryCode");
26
26
  const factory = require("../factory");
27
27
  const settings_1 = require("../settings");
28
28
  const AVAILABLE_PROJECT_FIELDS = [
29
- 'additionalProperty', 'codeValue', 'color', 'image', 'inCodeSet', 'name', 'paymentMethod', 'project', 'typeOf'
29
+ 'additionalProperty', 'codeValue', 'color', 'image', 'inCodeSet', 'name', 'project', 'typeOf'
30
30
  ];
31
31
  /**
32
- * 区分リポジトリ
32
+ * 区分(決済カード区分を除く)リポジトリ
33
33
  */
34
34
  class CategoryCodeRepo {
35
35
  constructor(connection) {
@@ -37,8 +37,29 @@ class CategoryCodeRepo {
37
37
  }
38
38
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
39
39
  static CREATE_MONGO_CONDITIONS(params) {
40
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l;
40
+ var _a, _b, _c, _d, _e, _f, _g;
41
+ // const excludeMovieTicketType = true;
41
42
  const andConditions = [];
43
+ // 決済カード区分をmovieTicketTypesへ移行済なので、excludeMovieTicketTypeオプションは不要(2025-11-07~)
44
+ // if (excludeMovieTicketType) {
45
+ // andConditions.push({
46
+ // 'inCodeSet.identifier': {
47
+ // $in: [
48
+ // factory.categoryCode.CategorySetIdentifier.ContentRatingType,
49
+ // factory.categoryCode.CategorySetIdentifier.CurrencyType,
50
+ // factory.categoryCode.CategorySetIdentifier.CustomerType,
51
+ // factory.categoryCode.CategorySetIdentifier.DistributorType,
52
+ // factory.categoryCode.CategorySetIdentifier.MembershipType,
53
+ // factory.categoryCode.CategorySetIdentifier.OfferCategoryType,
54
+ // factory.categoryCode.CategorySetIdentifier.PaymentMethodType,
55
+ // factory.categoryCode.CategorySetIdentifier.SeatingType,
56
+ // factory.categoryCode.CategorySetIdentifier.ServiceType,
57
+ // factory.categoryCode.CategorySetIdentifier.SoundFormatType,
58
+ // factory.categoryCode.CategorySetIdentifier.VideoFormatType
59
+ // ]
60
+ // }
61
+ // });
62
+ // }
42
63
  // tslint:disable-next-line:no-single-line-block-comment
43
64
  /* istanbul ignore else */
44
65
  if (params.project !== undefined && params.project !== null) {
@@ -99,7 +120,6 @@ class CategoryCodeRepo {
99
120
  if (typeof params.inCodeSet.identifier.$eq === 'string') {
100
121
  andConditions.push({
101
122
  'inCodeSet.identifier': {
102
- $exists: true,
103
123
  $eq: params.inCodeSet.identifier.$eq
104
124
  }
105
125
  });
@@ -110,30 +130,29 @@ class CategoryCodeRepo {
110
130
  if (Array.isArray(inCodeSetIdentifierIn)) {
111
131
  andConditions.push({
112
132
  'inCodeSet.identifier': {
113
- $exists: true,
114
133
  $in: inCodeSetIdentifierIn
115
134
  }
116
135
  });
117
136
  }
118
- const paymentMethodTypeOfEq = (_h = (_g = params.paymentMethod) === null || _g === void 0 ? void 0 : _g.typeOf) === null || _h === void 0 ? void 0 : _h.$eq;
119
- if (typeof paymentMethodTypeOfEq === 'string') {
120
- andConditions.push({
121
- 'paymentMethod.typeOf': {
122
- $exists: true,
123
- $eq: paymentMethodTypeOfEq
124
- }
125
- });
126
- }
127
- const paymentMethodTypeOfIn = (_k = (_j = params.paymentMethod) === null || _j === void 0 ? void 0 : _j.typeOf) === null || _k === void 0 ? void 0 : _k.$in;
128
- if (Array.isArray(paymentMethodTypeOfIn)) {
129
- andConditions.push({
130
- 'paymentMethod.typeOf': {
131
- $exists: true,
132
- $in: paymentMethodTypeOfIn
133
- }
134
- });
135
- }
136
- const additionalPropertyElemMatch = (_l = params.additionalProperty) === null || _l === void 0 ? void 0 : _l.$elemMatch;
137
+ // const paymentMethodTypeOfEq = params.paymentMethod?.typeOf?.$eq;
138
+ // if (typeof paymentMethodTypeOfEq === 'string') {
139
+ // andConditions.push({
140
+ // 'paymentMethod.typeOf': {
141
+ // $exists: true,
142
+ // $eq: paymentMethodTypeOfEq
143
+ // }
144
+ // });
145
+ // }
146
+ // const paymentMethodTypeOfIn = params.paymentMethod?.typeOf?.$in;
147
+ // if (Array.isArray(paymentMethodTypeOfIn)) {
148
+ // andConditions.push({
149
+ // 'paymentMethod.typeOf': {
150
+ // $exists: true,
151
+ // $in: paymentMethodTypeOfIn
152
+ // }
153
+ // });
154
+ // }
155
+ const additionalPropertyElemMatch = (_g = params.additionalProperty) === null || _g === void 0 ? void 0 : _g.$elemMatch;
137
156
  if (additionalPropertyElemMatch !== undefined && additionalPropertyElemMatch !== null) {
138
157
  andConditions.push({
139
158
  additionalProperty: {
@@ -155,8 +174,8 @@ class CategoryCodeRepo {
155
174
  image: '$image',
156
175
  codeValue: '$codeValue',
157
176
  inCodeSet: '$inCodeSet',
158
- name: '$name',
159
- paymentMethod: '$paymentMethod'
177
+ name: '$name'
178
+ // paymentMethod: '$paymentMethod' // discontinue(2025-11-08~)
160
179
  };
161
180
  if (inclusion.length > 0) {
162
181
  projectStage = { _id: 0 };
@@ -174,9 +193,9 @@ class CategoryCodeRepo {
174
193
  return projectStage;
175
194
  }
176
195
  /**
177
- * 集計検索(publicな属性検索が目的)
196
+ * 区分集計検索(publicな属性検索が目的)
178
197
  */
179
- searchByAggregate(conditions, inclusion) {
198
+ findCategoryCodesByAggregate(conditions, inclusion) {
180
199
  return __awaiter(this, void 0, void 0, function* () {
181
200
  var _a;
182
201
  const matchStages = CategoryCodeRepo.CREATE_MONGO_CONDITIONS(conditions)
@@ -190,8 +209,6 @@ class CategoryCodeRepo {
190
209
  : [],
191
210
  { $project: projectStage }
192
211
  ]);
193
- // tslint:disable-next-line:no-single-line-block-comment
194
- /* istanbul ignore else */
195
212
  if (typeof conditions.limit === 'number' && conditions.limit > 0) {
196
213
  const page = (typeof conditions.page === 'number' && conditions.page > 0) ? conditions.page : 1;
197
214
  aggregate.limit(conditions.limit * page)
@@ -201,9 +218,9 @@ class CategoryCodeRepo {
201
218
  });
202
219
  }
203
220
  /**
204
- * 検索
221
+ * 区分検索
205
222
  */
206
- projectFields(params,
223
+ projectCategoryCodeFields(params,
207
224
  /**
208
225
  * 空の場合無効
209
226
  */
@@ -214,11 +231,6 @@ class CategoryCodeRepo {
214
231
  if (Array.isArray(inclusion) && inclusion.length > 0) {
215
232
  positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
216
233
  }
217
- else {
218
- // if (Array.isArray(exclusion) && exclusion.length > 0) {
219
- // positiveProjectionFields = positiveProjectionFields.filter((key) => !exclusion.includes(key));
220
- // }
221
- }
222
234
  const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
223
235
  const query = this.categoryCodeModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
224
236
  if (typeof params.limit === 'number' && params.limit > 0) {
@@ -236,7 +248,7 @@ class CategoryCodeRepo {
236
248
  .exec();
237
249
  });
238
250
  }
239
- save(params) {
251
+ saveCategoryCode(params) {
240
252
  return __awaiter(this, void 0, void 0, function* () {
241
253
  let savedId;
242
254
  // let doc: HydratedDocument<{ _id: Types.ObjectId }> | null;
@@ -265,7 +277,7 @@ class CategoryCodeRepo {
265
277
  return { id: savedId };
266
278
  });
267
279
  }
268
- saveManyByCodeValue(params) {
280
+ saveCategoryCodesByCodeValue(params) {
269
281
  return __awaiter(this, void 0, void 0, function* () {
270
282
  const bulkWriteOps = [];
271
283
  if (Array.isArray(params)) {
@@ -280,7 +292,6 @@ class CategoryCodeRepo {
280
292
  'project.id': { $eq: p.attributes.project.id },
281
293
  codeValue: { $eq: p.attributes.codeValue },
282
294
  'inCodeSet.identifier': {
283
- $exists: true,
284
295
  $eq: p.attributes.inCodeSet.identifier
285
296
  }
286
297
  },
@@ -301,7 +312,7 @@ class CategoryCodeRepo {
301
312
  /**
302
313
  * 削除する
303
314
  */
304
- deleteById(params) {
315
+ deleteCategoryCodeById(params) {
305
316
  return __awaiter(this, void 0, void 0, function* () {
306
317
  yield this.categoryCodeModel.findOneAndDelete({ _id: { $eq: params.id } }, { projection: { _id: 1 } })
307
318
  .exec();
@@ -310,7 +321,7 @@ class CategoryCodeRepo {
310
321
  /**
311
322
  * プロジェクト指定で削除する
312
323
  */
313
- deleteByProject(params) {
324
+ deleteCategoryCodesByProject(params) {
314
325
  return __awaiter(this, void 0, void 0, function* () {
315
326
  yield this.categoryCodeModel.deleteMany({
316
327
  'project.id': { $eq: params.project.id }
@@ -1,5 +1,5 @@
1
1
  import type { BulkWriteResult } from 'mongodb';
2
- import type { Connection, Document, FilterQuery } from 'mongoose';
2
+ import { Connection, FilterQuery } from 'mongoose';
3
3
  import * as factory from '../factory';
4
4
  import * as EventFactory from '../factory/event';
5
5
  export interface IAttributes4patchUpdate {
@@ -63,6 +63,10 @@ export type ICreatingEvent4ttts = Pick<factory.event.screeningEvent.IAttributes,
63
63
  export declare class EventRepo {
64
64
  private readonly eventModel;
65
65
  constructor(connection: Connection);
66
+ /**
67
+ * イベントIDを生成する
68
+ */
69
+ static CREATE_ID(): string;
66
70
  static CREATE_MONGO_CONDITIONS(conditions: ISearchConditions): FilterQuery<factory.event.screeningEvent.IEvent>[];
67
71
  /**
68
72
  * 複数イベントを作成する
@@ -136,19 +140,18 @@ export declare class EventRepo {
136
140
  attributes: IAttributes4patchUpdate;
137
141
  }): Promise<void>;
138
142
  /**
139
- * イベントを保管する
143
+ * 単一イベント編集
140
144
  */
141
- saveEvent(params: {
142
- id?: string;
143
- attributes: factory.event.screeningEvent.IAttributes;
145
+ updateEventById(params: {
146
+ id: string;
147
+ attributes: factory.event.screeningEvent.IAttributes & {
148
+ id?: never;
149
+ };
144
150
  /**
145
151
  * ドキュメント作成時には無視される
146
152
  */
147
153
  $unset?: IUnset;
148
- upsert: false;
149
- }): Promise<{
150
- id: string;
151
- }>;
154
+ }): Promise<void>;
152
155
  /**
153
156
  * sskts専用
154
157
  */
@@ -170,6 +173,17 @@ export declare class EventRepo {
170
173
  * イベントを検索する(inclusion projection)
171
174
  */
172
175
  projectEventFields(params: ISearchConditions, inclusion: IKeyOfProjection[]): Promise<Omit<factory.event.screeningEvent.IEvent, 'aggregateOffer'>[]>;
176
+ findByAdditionalProperty(params: {
177
+ project: {
178
+ id: string;
179
+ };
180
+ additionalProperty: factory.propertyValue.IPropertyValue<string>;
181
+ }): Promise<(import("mongoose").FlattenMaps<import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
182
+ _id: string;
183
+ aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
184
+ }> & Required<{
185
+ _id: string;
186
+ }>)[]>;
173
187
  /**
174
188
  * apiで公開属性を検索する(2024-10-13~)
175
189
  */
@@ -334,7 +348,7 @@ export declare class EventRepo {
334
348
  validationErrors: import("mongoose").Error[];
335
349
  } | undefined;
336
350
  }>;
337
- getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<Document<unknown, {}, import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
351
+ getCursor(conditions: FilterQuery<any>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
338
352
  _id: string;
339
353
  aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
340
354
  }> & import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
@@ -342,7 +356,7 @@ export declare class EventRepo {
342
356
  aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
343
357
  } & Required<{
344
358
  _id: string;
345
- }>, import("mongoose").QueryOptions<Document<unknown, {}, import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
359
+ }>, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
346
360
  _id: string;
347
361
  aggregateOffer?: factory.event.screeningEvent.IAggregateOffer;
348
362
  }> & import("@chevre/factory/lib/event/screeningEvent").IAttributes & {
@@ -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: uniqid() }, p);
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: uniqid() });
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: uniqid() });
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
- saveEvent(params) {
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
- if (params.id === undefined) {
488
- const uniqid = yield Promise.resolve().then(() => require('uniqid'));
489
- const id = uniqid();
490
- doc = yield this.eventModel.create(Object.assign(Object.assign({}, params.attributes), { _id: id }));
491
- savedEventId = id;
492
- }
493
- else {
494
- // const upsert: boolean = params.upsert === true;
495
- const upsert = false; // always false(2025-05-15~)
496
- doc = yield this.eventModel.findOneAndUpdate({
497
- _id: { $eq: params.id },
498
- typeOf: { $eq: typeOf }
499
- }, Object.assign({
500
- // 上書き禁止属性を除外(2022-08-24~)
501
- $setOnInsert: Object.assign({ typeOf,
502
- project }, (typeof identifier === 'string' && identifier !== '') ? { identifier } : undefined), $set: updateFields }, (params.$unset !== undefined) ? { $unset: params.$unset } : undefined), { upsert, new: true, projection: { _id: 1 } })
503
- .lean()
504
- .exec();
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 uniqid = yield Promise.resolve().then(() => require('uniqid'));
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
- * イベントの販売者makesOfferリポジトリ
5
+ * イベントのアプリケーションオファーリポジトリ
17
6
  */
18
7
  export declare class EventSellerMakesOfferRepo {
19
8
  private readonly eventModel;
20
9
  constructor(connection: Connection);
21
10
  /**
22
- * 指定クライアントのオファーを集計する(2024-10-09~)
11
+ * 単一イベントのmakesOfferを更新する
23
12
  */
24
- aggregateMakesOffer(conditions: {
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
- serviceOutput: {
42
- reservationFor: {
43
- /**
44
- * イベントID
45
- */
46
- id: {
47
- $in?: string[];
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<IAggregateMakesOfferResult[]>;
33
+ }[]): Promise<{
34
+ bulkWriteResult: BulkWriteResult;
35
+ modifiedEvents: {
36
+ id: string;
37
+ }[];
38
+ } | void>;
53
39
  }
54
- export {};