@chevre/domain 23.1.0-alpha.9 → 23.1.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 (85) hide show
  1. package/example/src/chevre/{eventOffer/adminEventOffers.ts → acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts} +12 -11
  2. package/example/src/chevre/actions/checkAcceptPayActions.ts +60 -0
  3. package/example/src/chevre/assetTransaction/checkPayTransactionsTicketToken.ts +67 -0
  4. package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +93 -0
  5. package/example/src/chevre/importEventsFromCOA.ts +5 -5
  6. package/example/src/chevre/pendingReservation/findEventSeatOffersBySection.ts +46 -0
  7. package/example/src/chevre/place/checkSectionCount.ts +27 -0
  8. package/example/src/chevre/place/findSectionsByRoom.ts +50 -0
  9. package/example/src/chevre/project/unsetProjectSettings.ts +73 -0
  10. package/example/src/chevre/reIndex.ts +0 -1
  11. package/example/src/chevre/roles/{addAdminSellerEventIfNotExists.ts → addAdminSellerEventOfferIfNotExists.ts} +1 -1
  12. package/example/src/chevre/stockHolder/findSeatsBySection.ts +59 -0
  13. package/example/src/chevre/stockHolder/searchSeats.ts +2 -2
  14. package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -0
  15. package/lib/chevre/repo/acceptedPaymentMethod.js +180 -0
  16. package/lib/chevre/repo/authorization.d.ts +3 -2
  17. package/lib/chevre/repo/authorization.js +13 -5
  18. package/lib/chevre/repo/event.d.ts +1 -35
  19. package/lib/chevre/repo/event.js +2 -102
  20. package/lib/chevre/repo/eventOffer.js +3 -3
  21. package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.d.ts +10 -0
  22. package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.js +97 -0
  23. package/lib/chevre/repo/mongoose/schemas/eventOffer.js +9 -0
  24. package/lib/chevre/repo/note.js +4 -2
  25. package/lib/chevre/repo/pendingReservation.js +28 -71
  26. package/lib/chevre/repo/place/seat.d.ts +24 -0
  27. package/lib/chevre/repo/place/seat.js +103 -21
  28. package/lib/chevre/repo/place/section.d.ts +20 -0
  29. package/lib/chevre/repo/place/section.js +47 -0
  30. package/lib/chevre/repo/ticket.d.ts +7 -1
  31. package/lib/chevre/repo/ticket.js +14 -1
  32. package/lib/chevre/repository.d.ts +5 -0
  33. package/lib/chevre/repository.js +15 -2
  34. package/lib/chevre/service/assetTransaction/pay/factory.d.ts +1 -1
  35. package/lib/chevre/service/assetTransaction/pay/factory.js +8 -3
  36. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.d.ts +16 -0
  37. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.js +94 -0
  38. package/lib/chevre/service/assetTransaction/pay.d.ts +6 -1
  39. package/lib/chevre/service/assetTransaction/pay.js +6 -1
  40. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts +1 -2
  41. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +7 -7
  42. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +6 -2
  43. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +30 -30
  44. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +0 -1
  45. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +7 -51
  46. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +6 -8
  47. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +29 -1
  48. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +9 -9
  49. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +1 -1
  50. package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +48 -0
  51. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +123 -0
  52. package/lib/chevre/service/offer/event.d.ts +2 -1
  53. package/lib/chevre/service/offer/event.js +3 -1
  54. package/lib/chevre/service/offer.d.ts +31 -1
  55. package/lib/chevre/service/offer.js +104 -34
  56. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +9 -0
  57. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.js +22 -11
  58. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +19 -2
  59. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +87 -9
  60. package/lib/chevre/service/payment/any/factory.d.ts +20 -3
  61. package/lib/chevre/service/payment/any/factory.js +26 -6
  62. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +4 -0
  63. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js +15 -11
  64. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +6 -3
  65. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +8 -22
  66. package/lib/chevre/service/payment/any.d.ts +5 -1
  67. package/lib/chevre/service/payment/any.js +22 -13
  68. package/lib/chevre/service/payment/factory.js +0 -5
  69. package/lib/chevre/service/payment/movieTicket/authorize.js +0 -5
  70. package/lib/chevre/service/task/authorizePayment.js +2 -0
  71. package/lib/chevre/service/task/publishPaymentUrl.js +4 -0
  72. package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +1 -1
  73. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +9 -0
  74. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.js +2 -0
  75. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +8 -0
  76. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.js +45 -0
  77. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.d.ts +3 -0
  78. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +38 -0
  79. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +2 -8
  80. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +5 -35
  81. package/package.json +3 -3
  82. package/example/src/chevre/checkReplaceActions.ts +0 -65
  83. package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +0 -193
  84. package/lib/chevre/service/code.d.ts +0 -8
  85. package/lib/chevre/service/code.js +0 -7
@@ -0,0 +1,180 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.AcceptedPaymentMethodRepo = void 0;
13
+ const factory = require("../factory");
14
+ const settings_1 = require("../settings");
15
+ const acceptedPaymentMethod_1 = require("./mongoose/schemas/acceptedPaymentMethod");
16
+ const AVAILABLE_PROJECT_FIELDS = [
17
+ 'identifier',
18
+ 'project',
19
+ 'itemOffered',
20
+ 'acceptedPaymentMethod',
21
+ 'typeOf',
22
+ 'validFrom',
23
+ 'validThrough',
24
+ 'seller'
25
+ ];
26
+ /**
27
+ * 対応決済方法リポジトリ
28
+ */
29
+ class AcceptedPaymentMethodRepo {
30
+ constructor(connection) {
31
+ this.acceptedPaymentMethodModel = connection.model(acceptedPaymentMethod_1.modelName, (0, acceptedPaymentMethod_1.createSchema)());
32
+ }
33
+ static CREATE_MONGO_CONDITIONS(params) {
34
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
35
+ const andConditions = [];
36
+ const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
37
+ if (typeof idEq === 'string') {
38
+ andConditions.push({ _id: { $eq: idEq } });
39
+ }
40
+ const projectIdEq = (_c = (_b = params.project) === null || _b === void 0 ? void 0 : _b.id) === null || _c === void 0 ? void 0 : _c.$eq;
41
+ if (typeof projectIdEq === 'string') {
42
+ andConditions.push({ 'project.id': { $eq: projectIdEq } });
43
+ }
44
+ const identifierEq = (_d = params.identifier) === null || _d === void 0 ? void 0 : _d.$eq;
45
+ if (typeof identifierEq === 'string') {
46
+ andConditions.push({ identifier: { $eq: identifierEq } });
47
+ }
48
+ const identifierIn = (_e = params.identifier) === null || _e === void 0 ? void 0 : _e.$in;
49
+ if (Array.isArray(identifierIn)) {
50
+ andConditions.push({ identifier: { $in: identifierIn } });
51
+ }
52
+ const itemOfferedIdEq = (_g = (_f = params.itemOffered) === null || _f === void 0 ? void 0 : _f.id) === null || _g === void 0 ? void 0 : _g.$eq;
53
+ if (typeof itemOfferedIdEq === 'string') {
54
+ andConditions.push({ 'itemOffered.id': { $eq: itemOfferedIdEq } });
55
+ }
56
+ const itemOfferedIdIn = (_j = (_h = params.itemOffered) === null || _h === void 0 ? void 0 : _h.id) === null || _j === void 0 ? void 0 : _j.$in;
57
+ if (Array.isArray(itemOfferedIdIn)) {
58
+ andConditions.push({ 'itemOffered.id': { $in: itemOfferedIdIn } });
59
+ }
60
+ const acceptedPaymentMethodIdEq = (_l = (_k = params.acceptedPaymentMethod) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
61
+ if (typeof acceptedPaymentMethodIdEq === 'string') {
62
+ andConditions.push({ 'acceptedPaymentMethod.id': { $eq: acceptedPaymentMethodIdEq } });
63
+ }
64
+ const sellerByIdEq = (_o = (_m = params.seller) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
65
+ if (typeof sellerByIdEq === 'string') {
66
+ andConditions.push({ 'seller.id': { $eq: sellerByIdEq } });
67
+ }
68
+ const validFromLte = (_p = params.validFrom) === null || _p === void 0 ? void 0 : _p.$lte;
69
+ if (validFromLte instanceof Date) {
70
+ andConditions.push({ validFrom: { $lte: validFromLte } });
71
+ }
72
+ const validThroughGte = (_q = params.validThrough) === null || _q === void 0 ? void 0 : _q.$gte;
73
+ if (validThroughGte instanceof Date) {
74
+ andConditions.push({ validThrough: { $gte: validThroughGte } });
75
+ }
76
+ return andConditions;
77
+ }
78
+ findAcceptedPaymentMethods(params, inclusion) {
79
+ return __awaiter(this, void 0, void 0, function* () {
80
+ var _a;
81
+ const conditions = AcceptedPaymentMethodRepo.CREATE_MONGO_CONDITIONS(params);
82
+ let positiveProjectionFields = AVAILABLE_PROJECT_FIELDS;
83
+ if (Array.isArray(inclusion) && inclusion.length > 0) {
84
+ positiveProjectionFields = inclusion.filter((key) => AVAILABLE_PROJECT_FIELDS.includes(key));
85
+ }
86
+ else {
87
+ throw new factory.errors.ArgumentNull('inclusion', 'inclusion must be specified');
88
+ }
89
+ const projection = Object.assign({ _id: 0, id: { $toString: '$_id' } }, Object.fromEntries(positiveProjectionFields.map((key) => ([key, 1]))));
90
+ const query = this.acceptedPaymentMethodModel.find((conditions.length > 0) ? { $and: conditions } : {}, projection);
91
+ if (typeof ((_a = params.sort) === null || _a === void 0 ? void 0 : _a.validFrom) === 'number') {
92
+ query.sort({ validFrom: params.sort.validFrom });
93
+ }
94
+ if (typeof params.limit === 'number' && params.limit > 0) {
95
+ const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
96
+ query.limit(params.limit)
97
+ .skip(params.limit * (page - 1));
98
+ }
99
+ return query.setOptions({ maxTimeMS: settings_1.MONGO_MAX_TIME_MS })
100
+ .lean()
101
+ .exec();
102
+ });
103
+ }
104
+ /**
105
+ * オファーコードと提供リソースIDをキーにして冪等置換
106
+ */
107
+ upsertAcceptedPaymentMethodsByIdentifier(params, options) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ const { update } = options;
110
+ const bulkWriteOps = [];
111
+ const queryFilters = [];
112
+ if (Array.isArray(params)) {
113
+ params.forEach(({ $set, $unset }) => {
114
+ const { identifier, itemOffered, acceptedPaymentMethod, seller, project, validFrom, validThrough } = $set;
115
+ if (typeof identifier !== 'string' || identifier === '') {
116
+ throw new factory.errors.ArgumentNull('identifier');
117
+ }
118
+ if (typeof itemOffered.id !== 'string' || itemOffered.id === '') {
119
+ throw new factory.errors.ArgumentNull('itemOffered.id');
120
+ }
121
+ // リソースのユニークネスを保証するfilter
122
+ const filter = {
123
+ 'project.id': { $eq: project.id },
124
+ 'itemOffered.id': { $eq: itemOffered.id },
125
+ identifier: { $eq: identifier }
126
+ };
127
+ queryFilters.push({
128
+ 'project.id': { $eq: project.id },
129
+ 'itemOffered.id': { $eq: itemOffered.id },
130
+ identifier: { $eq: identifier }
131
+ });
132
+ if (update === true) {
133
+ const setFields = {
134
+ validFrom,
135
+ validThrough,
136
+ acceptedPaymentMethod
137
+ };
138
+ const updateFilter = Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
139
+ const updateOne = {
140
+ filter,
141
+ update: updateFilter,
142
+ upsert: false
143
+ };
144
+ bulkWriteOps.push({ updateOne });
145
+ }
146
+ else {
147
+ const setOnInsert = {
148
+ itemOffered, identifier, project, seller,
149
+ typeOf: factory.offerType.Offer,
150
+ validFrom,
151
+ validThrough,
152
+ acceptedPaymentMethod
153
+ };
154
+ const updateFilter = {
155
+ $setOnInsert: setOnInsert
156
+ };
157
+ const updateOne = {
158
+ filter,
159
+ update: updateFilter,
160
+ upsert: true
161
+ };
162
+ bulkWriteOps.push({ updateOne });
163
+ }
164
+ });
165
+ }
166
+ if (bulkWriteOps.length > 0) {
167
+ const bulkWriteResult = yield this.acceptedPaymentMethodModel.bulkWrite(bulkWriteOps, { ordered: false });
168
+ // modifiedの場合upsertedIdsに含まれないので、idを検索する
169
+ const modifiedProductOffers = yield this.acceptedPaymentMethodModel.find({ $or: queryFilters }, {
170
+ _id: 0,
171
+ id: { $toString: '$_id' }
172
+ })
173
+ .lean()
174
+ .exec();
175
+ return { bulkWriteResult, modifiedProductOffers };
176
+ }
177
+ });
178
+ }
179
+ }
180
+ exports.AcceptedPaymentMethodRepo = AcceptedPaymentMethodRepo;
@@ -16,9 +16,10 @@ export declare class AuthorizationRepo {
16
16
  constructor(connection: Connection);
17
17
  static CREATE_MONGO_CONDITIONS(params: factory.authorization.ISearchConditions): FilterQuery<factory.authorization.IAuthorization>[];
18
18
  /**
19
- * コードを発行する
19
+ * 承認を発行する
20
+ * コードが自動生成されます
20
21
  */
21
- publish(params: IPublishParams[]): Promise<factory.authorization.IAuthorization[]>;
22
+ issueAuthorization(params: IPublishParams[]): Promise<factory.authorization.IAuthorization[]>;
22
23
  /**
23
24
  * コードで有効な承認を参照する
24
25
  */
@@ -111,9 +111,10 @@ class AuthorizationRepo {
111
111
  return andConditions;
112
112
  }
113
113
  /**
114
- * コードを発行する
114
+ * 承認を発行する
115
+ * コードが自動生成されます
115
116
  */
116
- publish(params) {
117
+ issueAuthorization(params) {
117
118
  return __awaiter(this, void 0, void 0, function* () {
118
119
  const saveParams = params.map(({ project, object, validFrom, expiresInSeconds, audience, author, issuedBy }) => {
119
120
  const code = uuid.v4();
@@ -144,7 +145,7 @@ class AuthorizationRepo {
144
145
  throw new factory.errors.NotFound(this.authorizationModel.modelName);
145
146
  }
146
147
  const { id, object, typeOf, audience, issuedBy } = doc;
147
- return Object.assign(Object.assign({ id, object, typeOf }, (typeof (issuedBy === null || issuedBy === void 0 ? void 0 : issuedBy.id) === 'string') ? { issuedBy } : undefined), (typeof (audience === null || audience === void 0 ? void 0 : audience.id) === 'string') ? { audience } : undefined);
148
+ return Object.assign({ id, object, typeOf, issuedBy }, (typeof (audience === null || audience === void 0 ? void 0 : audience.id) === 'string') ? { audience } : undefined);
148
149
  });
149
150
  }
150
151
  /**
@@ -217,14 +218,21 @@ class AuthorizationRepo {
217
218
  return __awaiter(this, void 0, void 0, function* () {
218
219
  if (params.length > 0) {
219
220
  const docs = params.map(({ project, code, object, validFrom, expiresInSeconds, audience, author, issuedBy }) => {
221
+ // issuedByは必須化(2025-11-21~)
222
+ if (typeof (issuedBy === null || issuedBy === void 0 ? void 0 : issuedBy.id) !== 'string') {
223
+ throw new factory.errors.ArgumentNull('issuedBy?.id');
224
+ }
220
225
  const validUntil = moment(validFrom)
221
226
  .add(expiresInSeconds, 'seconds')
222
227
  .toDate();
223
- return Object.assign(Object.assign({ project, typeOf: 'Authorization', author,
228
+ return Object.assign({ project, typeOf: 'Authorization', author,
224
229
  code,
230
+ issuedBy,
225
231
  object,
226
232
  validFrom,
227
- validUntil }, (typeof (audience === null || audience === void 0 ? void 0 : audience.id) === 'string') ? { audience } : undefined), (typeof (issuedBy === null || issuedBy === void 0 ? void 0 : issuedBy.id) === 'string') ? { issuedBy } : undefined);
233
+ validUntil }, (typeof (audience === null || audience === void 0 ? void 0 : audience.id) === 'string') ? { audience } : undefined
234
+ // ...(typeof issuedBy?.id === 'string') ? { issuedBy } : undefined
235
+ );
228
236
  });
229
237
  const result = yield this.authorizationModel.insertMany(docs, { ordered: false, rawResult: true });
230
238
  if (result.insertedCount !== docs.length) {
@@ -44,7 +44,7 @@ interface IAggregateEvent {
44
44
  statuses: IStatus[];
45
45
  }
46
46
  export import IMinimizedIndividualEvent = EventFactory.IMinimizedIndividualEvent;
47
- type IKeyOfProjection = Exclude<keyof factory.event.screeningEvent.IEvent, 'id'> | 'aggregateOffer' | 'superEvent.location.id' | 'offers.itemOffered' | 'offers.itemOffered.id';
47
+ type IKeyOfProjection = Exclude<keyof factory.event.screeningEvent.IEvent, 'id'> | 'aggregateOffer' | 'superEvent.location.id' | 'offers.itemOffered' | 'offers.itemOffered.id' | 'offers.typeOf';
48
48
  type IKeyOfProjection4publicFields = Exclude<keyof factory.event.screeningEvent.IEvent, 'id' | 'offers'>;
49
49
  /**
50
50
  * minimizedEvent検索時のprojection候補
@@ -75,40 +75,6 @@ export declare class EventRepo {
75
75
  attributes: factory.event.screeningEvent.IAttributes[];
76
76
  expectsNoContent: boolean;
77
77
  }): Promise<string[] | void>;
78
- /**
79
- * 特定の追加特性をキーにして、存在しなければ作成する(複数対応)
80
- * 施設コンテンツとルームは1つに限定
81
- * 存在すれば、特定の属性のみ更新する
82
- */
83
- upsertManyByAdditionalProperty(params: {
84
- events: factory.event.screeningEvent.IAttributes[];
85
- additionalPropertyFilter: {
86
- name: string;
87
- };
88
- eventSeries: {
89
- /**
90
- * 施設コンテンツID
91
- */
92
- id: string;
93
- };
94
- screeningRoom: {
95
- /**
96
- * ルームコード
97
- */
98
- branchCode: string;
99
- };
100
- }, options: {
101
- /**
102
- * falseの場合setOnInsertのみ
103
- * trueの場合setのみ
104
- */
105
- update: boolean;
106
- }): Promise<{
107
- bulkWriteResult: BulkWriteResult;
108
- modifiedEvents: {
109
- id: string;
110
- }[];
111
- } | void>;
112
78
  /**
113
79
  * イベントコードをキーにして冪等置換
114
80
  */
@@ -22,13 +22,11 @@ var __rest = (this && this.__rest) || function (s, e) {
22
22
  Object.defineProperty(exports, "__esModule", { value: true });
23
23
  exports.EventRepo = void 0;
24
24
  const mongoose_1 = require("mongoose");
25
- const uniqid = require("uniqid");
26
25
  const errorHandler_1 = require("../errorHandler");
27
26
  const factory = require("../factory");
28
27
  const EventFactory = require("../factory/event");
29
28
  const settings_1 = require("../settings");
30
29
  const event_1 = require("./mongoose/schemas/event");
31
- const USE_OBJECT_ID_AS_EVENT_ID = process.env.USE_OBJECT_ID_AS_EVENT_ID === '1';
32
30
  const AVAILABLE_PUBLIC_PROJECT_FIELDS = [
33
31
  'additionalProperty', 'aggregateReservation', 'attendeeCount', 'checkInCount', 'coaInfo',
34
32
  // 'description',
@@ -49,7 +47,8 @@ class EventRepo {
49
47
  */
50
48
  static CREATE_ID() {
51
49
  // implement using ObjectId(2025-10-17~)
52
- return (USE_OBJECT_ID_AS_EVENT_ID) ? new mongoose_1.Types.ObjectId().toHexString() : uniqid();
50
+ // return (USE_OBJECT_ID_AS_EVENT_ID) ? new Types.ObjectId().toHexString() : uniqid();
51
+ return new mongoose_1.Types.ObjectId().toHexString(); // 設定を廃止(2025-11-20~)
53
52
  }
54
53
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
55
54
  static CREATE_MONGO_CONDITIONS(conditions) {
@@ -292,105 +291,6 @@ class EventRepo {
292
291
  return insertingDocs.map(({ _id }) => _id);
293
292
  });
294
293
  }
295
- /**
296
- * 特定の追加特性をキーにして、存在しなければ作成する(複数対応)
297
- * 施設コンテンツとルームは1つに限定
298
- * 存在すれば、特定の属性のみ更新する
299
- */
300
- // tslint:disable-next-line:max-func-body-length
301
- upsertManyByAdditionalProperty(params, options) {
302
- return __awaiter(this, void 0, void 0, function* () {
303
- const { update } = options;
304
- const bulkWriteOps = [];
305
- const additionalProperties = [];
306
- const { events, additionalPropertyFilter, eventSeries, screeningRoom } = params;
307
- if (Array.isArray(events)) {
308
- events.forEach((creatingEventParams) => {
309
- var _a, _b;
310
- if (creatingEventParams.typeOf !== factory.eventType.ScreeningEvent) {
311
- throw new factory.errors.NotImplemented(`only ${factory.eventType.ScreeningEvent} implemented`);
312
- }
313
- const additionalPropertyValue = (_b = (_a = creatingEventParams.additionalProperty) === null || _a === void 0 ? void 0 : _a.find((property) => property.name === additionalPropertyFilter.name)) === null || _b === void 0 ? void 0 : _b.value;
314
- if (typeof additionalPropertyValue !== 'string' || additionalPropertyValue === '') {
315
- throw new factory.errors.ArgumentNull('additionalProperty.value');
316
- }
317
- additionalProperties.push({ name: additionalPropertyFilter.name, value: additionalPropertyValue });
318
- if (creatingEventParams.superEvent.id !== eventSeries.id) {
319
- throw new factory.errors.Argument('superEvent.id', 'superEvent.id not matched');
320
- }
321
- if (creatingEventParams.location.branchCode !== screeningRoom.branchCode) {
322
- throw new factory.errors.Argument('location.branchCode', 'location.branchCode not matched');
323
- }
324
- const filter = {
325
- typeOf: { $eq: creatingEventParams.typeOf },
326
- 'project.id': { $eq: creatingEventParams.project.id },
327
- // 追加特性をキーに更新
328
- additionalProperty: {
329
- $exists: true,
330
- $all: [{ name: additionalPropertyFilter.name, value: additionalPropertyValue }]
331
- },
332
- 'superEvent.id': { $exists: true, $eq: creatingEventParams.superEvent.id } // add superEvent.id(2024-09-15~)
333
- };
334
- if (update === true) {
335
- // implemente(2024-12-20~)
336
- const { eventStatus, superEvent, offers // <-上書き可能な属性を限定的に
337
- } = creatingEventParams;
338
- bulkWriteOps.push({
339
- updateOne: {
340
- filter,
341
- update: {
342
- $set: {
343
- eventStatus,
344
- superEvent,
345
- 'offers.seller.makesOffer': offers.seller.makesOffer
346
- }
347
- },
348
- upsert: false
349
- }
350
- });
351
- }
352
- else {
353
- const { coaInfo, // ←適用しない
354
- // identifier, // support identifier(2025-05-13~)
355
- maximumAttendeeCapacity, remainingAttendeeCapacity, checkInCount, attendeeCount, aggregateReservation, // ←適用しない
356
- eventStatus, superEvent } = creatingEventParams, // <-上書き可能な属性を限定的に
357
- setOnInsertFields = __rest(creatingEventParams, ["coaInfo", "maximumAttendeeCapacity", "remainingAttendeeCapacity", "checkInCount", "attendeeCount", "aggregateReservation", "eventStatus", "superEvent"]);
358
- const setOnInsert = Object.assign(Object.assign({}, setOnInsertFields), { _id: EventRepo.CREATE_ID() });
359
- bulkWriteOps.push({
360
- updateOne: {
361
- filter,
362
- update: {
363
- $setOnInsert: setOnInsert,
364
- // 変更可能な属性のみ上書き
365
- $set: {
366
- eventStatus,
367
- superEvent // add superEvent(2024-09-15~)
368
- }
369
- },
370
- upsert: true
371
- }
372
- });
373
- }
374
- });
375
- }
376
- if (bulkWriteOps.length > 0) {
377
- const bulkWriteResult = yield this.eventModel.bulkWrite(bulkWriteOps, { ordered: false });
378
- // modifiedの場合upsertedIdsに含まれないので、idを検索する
379
- const modifiedEvents = yield this.eventModel.find({
380
- typeOf: { $eq: params.events[0].typeOf },
381
- 'project.id': { $eq: params.events[0].project.id },
382
- additionalProperty: { $exists: true, $in: additionalProperties },
383
- 'superEvent.id': { $exists: true, $eq: eventSeries.id } // add superEvent.id(2024-09-15~)
384
- }, {
385
- _id: 0,
386
- id: { $toString: '$_id' }
387
- })
388
- .lean() // lean(2024-09-15~)
389
- .exec();
390
- return { bulkWriteResult, modifiedEvents };
391
- }
392
- });
393
- }
394
294
  /**
395
295
  * イベントコードをキーにして冪等置換
396
296
  */
@@ -62,9 +62,9 @@ class EventOfferRepo {
62
62
  if (typeof availableAtOrFromIdentifierEq === 'string') {
63
63
  andConditions.push({ 'availableAtOrFrom.identifier': { $eq: availableAtOrFromIdentifierEq } });
64
64
  }
65
- const offeredByIdEq = (_o = (_m = params.offeredBy) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
66
- if (typeof offeredByIdEq === 'string') {
67
- andConditions.push({ 'offeredBy.id': { $exists: true, $eq: offeredByIdEq } });
65
+ const offeredByIdentifierEq = (_o = (_m = params.offeredBy) === null || _m === void 0 ? void 0 : _m.identifier) === null || _o === void 0 ? void 0 : _o.$eq;
66
+ if (typeof offeredByIdentifierEq === 'string') {
67
+ andConditions.push({ 'offeredBy.identifier': { $exists: true, $eq: offeredByIdentifierEq } });
68
68
  }
69
69
  const sellerByIdEq = (_q = (_p = params.seller) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$eq;
70
70
  if (typeof sellerByIdEq === 'string') {
@@ -0,0 +1,10 @@
1
+ import { IndexDefinition, IndexOptions, Model, Schema, SchemaDefinition } from 'mongoose';
2
+ import * as factory from '../../../factory';
3
+ type IDocType = factory.acceptedPaymentMethodOffer.IAcceptedPaymentMethodOffer;
4
+ type IModel = Model<IDocType>;
5
+ type ISchemaDefinition = SchemaDefinition<IDocType>;
6
+ type ISchema = Schema<IDocType, IModel, {}, {}, {}, {}, ISchemaDefinition, IDocType>;
7
+ declare const modelName = "AcceptedPaymentMethod";
8
+ declare const indexes: [d: IndexDefinition, o: IndexOptions][];
9
+ declare function createSchema(): ISchema;
10
+ export { createSchema, IDocType, IModel, indexes, modelName };
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.modelName = exports.indexes = void 0;
4
+ exports.createSchema = createSchema;
5
+ const mongoose_1 = require("mongoose");
6
+ const settings_1 = require("../../../settings");
7
+ const writeConcern_1 = require("../writeConcern");
8
+ const modelName = 'AcceptedPaymentMethod';
9
+ exports.modelName = modelName;
10
+ const schemaDefinition = {
11
+ project: { type: mongoose_1.SchemaTypes.Mixed, required: true },
12
+ seller: { type: mongoose_1.SchemaTypes.Mixed, required: true },
13
+ typeOf: { type: String, required: true },
14
+ identifier: { type: String, required: true },
15
+ itemOffered: { type: mongoose_1.SchemaTypes.Mixed, required: true },
16
+ validFrom: { type: Date, required: true },
17
+ validThrough: { type: Date, required: true },
18
+ acceptedPaymentMethod: { type: mongoose_1.SchemaTypes.Mixed, required: true }
19
+ // offeredBy: { type: SchemaTypes.Mixed, required: false }
20
+ };
21
+ const schemaOptions = {
22
+ autoIndex: settings_1.MONGO_AUTO_INDEX,
23
+ autoCreate: false,
24
+ collection: 'acceptedPaymentMethods',
25
+ id: true,
26
+ read: settings_1.MONGO_READ_PREFERENCE,
27
+ writeConcern: writeConcern_1.writeConcern,
28
+ strict: true,
29
+ strictQuery: false,
30
+ timestamps: false,
31
+ versionKey: false,
32
+ toJSON: {
33
+ getters: false,
34
+ virtuals: false,
35
+ minimize: false,
36
+ versionKey: false
37
+ },
38
+ toObject: {
39
+ getters: false,
40
+ virtuals: true,
41
+ minimize: false,
42
+ versionKey: false
43
+ }
44
+ };
45
+ const indexes = [
46
+ [
47
+ { validFrom: 1 },
48
+ { name: 'validFrom' }
49
+ ],
50
+ [
51
+ { validThrough: 1, validFrom: 1 },
52
+ { name: 'validThrough' }
53
+ ],
54
+ [
55
+ {
56
+ 'project.id': 1,
57
+ 'itemOffered.id': 1,
58
+ identifier: 1
59
+ },
60
+ {
61
+ name: 'uniqueByItemOfferedAndIdentifier',
62
+ unique: true
63
+ }
64
+ ],
65
+ [
66
+ { 'project.id': 1, validFrom: 1 },
67
+ { name: 'projectId' }
68
+ ],
69
+ [
70
+ { 'seller.id': 1, validFrom: 1 },
71
+ { name: 'sellerId' }
72
+ ],
73
+ [
74
+ { identifier: 1, validFrom: 1 },
75
+ { name: 'identifier' }
76
+ ],
77
+ [
78
+ { 'itemOffered.id': 1, validFrom: 1 },
79
+ { name: 'itemOfferedId' }
80
+ ]
81
+ ];
82
+ exports.indexes = indexes;
83
+ /**
84
+ * 対応決済方法オファースキーマ
85
+ */
86
+ let schema;
87
+ function createSchema() {
88
+ if (schema === undefined) {
89
+ schema = new mongoose_1.Schema(schemaDefinition, schemaOptions);
90
+ if (settings_1.MONGO_AUTO_INDEX) {
91
+ indexes.forEach((indexParams) => {
92
+ schema === null || schema === void 0 ? void 0 : schema.index(...indexParams);
93
+ });
94
+ }
95
+ }
96
+ return schema;
97
+ }
@@ -82,6 +82,15 @@ const indexes = [
82
82
  [
83
83
  { 'availableAtOrFrom.identifier': 1, validFrom: 1 },
84
84
  { name: 'availableAtOrFrom' }
85
+ ],
86
+ [
87
+ { 'offeredBy.identifier': 1, validFrom: 1 },
88
+ {
89
+ name: 'offeredByIdentifier',
90
+ partialFilterExpression: {
91
+ 'offeredBy.identifier': { $exists: true }
92
+ }
93
+ }
85
94
  ]
86
95
  ];
87
96
  exports.indexes = indexes;
@@ -192,8 +192,10 @@ class NoteRepo {
192
192
  })
193
193
  .lean()
194
194
  .exec();
195
- // tslint:disable-next-line:no-console
196
- console.log('NoteRepo.upsertNotesByIdentifier:', params.length, 'params ->', modifyingNotes.length, 'modifyingNotes found.', JSON.stringify(modifyingNotes));
195
+ // console.log(
196
+ // 'NoteRepo.upsertNotesByIdentifier:',
197
+ // params.length, 'params ->', modifyingNotes.length, 'modifyingNotes found.', JSON.stringify(modifyingNotes)
198
+ // );
197
199
  if (modifyingNotes.length !== bulkWriteOps.length) {
198
200
  throw new factory.errors.NotFound(factory.creativeWorkType.NoteDigitalDocument);
199
201
  }