@chevre/domain 23.1.0-alpha.3 → 23.1.0-alpha.30

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 (91) hide show
  1. package/example/src/chevre/acceptedPaymentMethodOffer/adminAcceptedPaymentMethodOffers.ts +68 -0
  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/assetTransaction/processReserve.ts +8 -3
  5. package/example/src/chevre/authorizeEventServiceOffer.ts +7 -5
  6. package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +93 -0
  7. package/example/src/chevre/member/migrateMemberIdentifier.ts +99 -0
  8. package/example/src/chevre/project/unsetProjectSettings.ts +73 -0
  9. package/example/src/chevre/reIndex.ts +1 -2
  10. package/example/src/chevre/roles/{addAdminSellerEventIfNotExists.ts → addAdminSellerEventOfferIfNotExists.ts} +1 -1
  11. package/example/src/chevre/stockHolder/findSeatsBySection.ts +59 -0
  12. package/example/src/chevre/stockHolder/searchSeats.ts +2 -2
  13. package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -0
  14. package/lib/chevre/repo/acceptedPaymentMethod.js +180 -0
  15. package/lib/chevre/repo/authorization.d.ts +3 -2
  16. package/lib/chevre/repo/authorization.js +13 -5
  17. package/lib/chevre/repo/event.d.ts +1 -35
  18. package/lib/chevre/repo/event.js +2 -102
  19. package/lib/chevre/repo/eventOffer.d.ts +1 -1
  20. package/lib/chevre/repo/eventOffer.js +16 -10
  21. package/lib/chevre/repo/member.d.ts +18 -1
  22. package/lib/chevre/repo/member.js +14 -8
  23. package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.d.ts +10 -0
  24. package/lib/chevre/repo/mongoose/schemas/acceptedPaymentMethod.js +97 -0
  25. package/lib/chevre/repo/mongoose/schemas/eventOffer.js +48 -35
  26. package/lib/chevre/repo/mongoose/schemas/member.js +10 -0
  27. package/lib/chevre/repo/place/seat.d.ts +24 -0
  28. package/lib/chevre/repo/place/seat.js +103 -21
  29. package/lib/chevre/repo/ticket.d.ts +7 -1
  30. package/lib/chevre/repo/ticket.js +14 -1
  31. package/lib/chevre/repository.d.ts +5 -0
  32. package/lib/chevre/repository.js +15 -2
  33. package/lib/chevre/service/assetTransaction/pay/factory.d.ts +1 -1
  34. package/lib/chevre/service/assetTransaction/pay/factory.js +8 -3
  35. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.d.ts +16 -0
  36. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.js +92 -0
  37. package/lib/chevre/service/assetTransaction/pay.d.ts +6 -1
  38. package/lib/chevre/service/assetTransaction/pay.js +6 -1
  39. package/lib/chevre/service/assetTransaction/reserve/start.d.ts +6 -0
  40. package/lib/chevre/service/assetTransaction/reserve/start.js +5 -1
  41. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts +22 -0
  42. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +63 -0
  43. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +7 -2
  44. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +32 -32
  45. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +1 -1
  46. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +10 -54
  47. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.d.ts +23 -0
  48. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +62 -0
  49. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +36 -1
  50. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +23 -27
  51. package/lib/chevre/service/offer/event/authorize/factory.d.ts +0 -3
  52. package/lib/chevre/service/offer/event/authorize/factory.js +4 -3
  53. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +43 -26
  54. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +4 -0
  55. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.js +4 -4
  56. package/lib/chevre/service/offer/event/authorize.d.ts +3 -0
  57. package/lib/chevre/service/offer/event/authorize.js +10 -5
  58. package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +48 -0
  59. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +123 -0
  60. package/lib/chevre/service/offer/event.d.ts +2 -1
  61. package/lib/chevre/service/offer/event.js +3 -1
  62. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +9 -0
  63. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.js +22 -11
  64. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +19 -2
  65. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +87 -9
  66. package/lib/chevre/service/payment/any/factory.d.ts +20 -3
  67. package/lib/chevre/service/payment/any/factory.js +26 -6
  68. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +4 -0
  69. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js +15 -11
  70. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +6 -3
  71. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +20 -28
  72. package/lib/chevre/service/payment/any.d.ts +5 -1
  73. package/lib/chevre/service/payment/any.js +22 -13
  74. package/lib/chevre/service/payment/factory.js +0 -5
  75. package/lib/chevre/service/payment/movieTicket/authorize.js +0 -5
  76. package/lib/chevre/service/task/authorizePayment.js +2 -0
  77. package/lib/chevre/service/task/publishPaymentUrl.js +4 -0
  78. package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +1 -1
  79. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +9 -0
  80. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.js +2 -0
  81. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +8 -0
  82. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.js +45 -0
  83. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.d.ts +3 -0
  84. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +38 -0
  85. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +2 -8
  86. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +5 -35
  87. package/package.json +3 -3
  88. package/example/src/chevre/checkReplaceActions.ts +0 -65
  89. package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +0 -193
  90. package/lib/chevre/service/code.d.ts +0 -8
  91. 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
  */
@@ -21,7 +21,7 @@ export declare class EventOfferRepo {
21
21
  * オファーコードとイベントIDをキーにして冪等置換
22
22
  */
23
23
  upsertEventOffersByIdentifier(params: {
24
- $set: Pick<IDocType, 'identifier' | 'itemOffered' | 'offeredBy' | 'seller' | 'project' | 'typeOf' | 'validFrom' | 'validThrough'> & {
24
+ $set: Pick<IDocType, 'identifier' | 'itemOffered' | 'offeredBy' | 'seller' | 'project' | 'typeOf' | 'validFrom' | 'validThrough' | 'availableAtOrFrom'> & {
25
25
  id?: never;
26
26
  };
27
27
  $unset: IUnset;
@@ -32,7 +32,7 @@ class EventOfferRepo {
32
32
  this.eventOfferModel = connection.model(eventOffer_1.modelName, (0, eventOffer_1.createSchema)());
33
33
  }
34
34
  static CREATE_MONGO_CONDITIONS(params) {
35
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
35
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
36
36
  const andConditions = [];
37
37
  const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
38
38
  if (typeof idEq === 'string') {
@@ -58,19 +58,23 @@ class EventOfferRepo {
58
58
  if (Array.isArray(itemOfferedIdIn)) {
59
59
  andConditions.push({ 'itemOffered.id': { $in: itemOfferedIdIn } });
60
60
  }
61
- const offeredByIdEq = (_l = (_k = params.offeredBy) === null || _k === void 0 ? void 0 : _k.id) === null || _l === void 0 ? void 0 : _l.$eq;
62
- if (typeof offeredByIdEq === 'string') {
63
- andConditions.push({ 'offeredBy.id': { $exists: true, $eq: offeredByIdEq } });
61
+ const availableAtOrFromIdentifierEq = (_l = (_k = params.availableAtOrFrom) === null || _k === void 0 ? void 0 : _k.identifier) === null || _l === void 0 ? void 0 : _l.$eq;
62
+ if (typeof availableAtOrFromIdentifierEq === 'string') {
63
+ andConditions.push({ 'availableAtOrFrom.identifier': { $eq: availableAtOrFromIdentifierEq } });
64
64
  }
65
- const sellerByIdEq = (_o = (_m = params.seller) === null || _m === void 0 ? void 0 : _m.id) === null || _o === void 0 ? void 0 : _o.$eq;
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
+ }
69
+ const sellerByIdEq = (_q = (_p = params.seller) === null || _p === void 0 ? void 0 : _p.id) === null || _q === void 0 ? void 0 : _q.$eq;
66
70
  if (typeof sellerByIdEq === 'string') {
67
71
  andConditions.push({ 'seller.id': { $eq: sellerByIdEq } });
68
72
  }
69
- const validFromLte = (_p = params.validFrom) === null || _p === void 0 ? void 0 : _p.$lte;
73
+ const validFromLte = (_r = params.validFrom) === null || _r === void 0 ? void 0 : _r.$lte;
70
74
  if (validFromLte instanceof Date) {
71
75
  andConditions.push({ validFrom: { $lte: validFromLte } });
72
76
  }
73
- const validThroughGte = (_q = params.validThrough) === null || _q === void 0 ? void 0 : _q.$gte;
77
+ const validThroughGte = (_s = params.validThrough) === null || _s === void 0 ? void 0 : _s.$gte;
74
78
  if (validThroughGte instanceof Date) {
75
79
  andConditions.push({ validThrough: { $gte: validThroughGte } });
76
80
  }
@@ -112,7 +116,7 @@ class EventOfferRepo {
112
116
  const queryFilters = [];
113
117
  if (Array.isArray(params)) {
114
118
  params.forEach(({ $set, $unset }) => {
115
- const { identifier, itemOffered, offeredBy, seller, project, validFrom, validThrough } = $set;
119
+ const { identifier, itemOffered, offeredBy, seller, project, validFrom, validThrough, availableAtOrFrom } = $set;
116
120
  if (typeof identifier !== 'string' || identifier === '') {
117
121
  throw new factory.errors.ArgumentNull('identifier');
118
122
  }
@@ -132,7 +136,8 @@ class EventOfferRepo {
132
136
  });
133
137
  if (update === true) {
134
138
  const setFields = Object.assign({ validFrom,
135
- validThrough }, (typeof (offeredBy === null || offeredBy === void 0 ? void 0 : offeredBy.identifier) === 'string') ? { offeredBy } : undefined);
139
+ validThrough,
140
+ availableAtOrFrom }, (typeof (offeredBy === null || offeredBy === void 0 ? void 0 : offeredBy.identifier) === 'string') ? { offeredBy } : undefined);
136
141
  const updateFilter = Object.assign({ $set: setFields }, ($unset !== undefined) ? { $unset } : undefined);
137
142
  const updateOne = {
138
143
  filter,
@@ -143,7 +148,8 @@ class EventOfferRepo {
143
148
  }
144
149
  else {
145
150
  const setOnInsert = Object.assign({ itemOffered, identifier, project, seller, typeOf: factory.offerType.Offer, validFrom,
146
- validThrough }, (typeof (offeredBy === null || offeredBy === void 0 ? void 0 : offeredBy.identifier) === 'string') ? { offeredBy } : undefined);
151
+ validThrough,
152
+ availableAtOrFrom }, (typeof (offeredBy === null || offeredBy === void 0 ? void 0 : offeredBy.identifier) === 'string') ? { offeredBy } : undefined);
147
153
  const updateFilter = {
148
154
  $setOnInsert: setOnInsert
149
155
  };
@@ -2,7 +2,13 @@ import type { Connection, FilterQuery } from 'mongoose';
2
2
  import * as factory from '../factory';
3
3
  import { IGlobalMember } from './mongoose/schemas/member/global';
4
4
  type IKeyOfProjection = keyof factory.iam.IMember;
5
- export type ICustomerMember = Pick<factory.iam.IMemberOfRole, 'hasRole' | 'id' | 'name' | 'memberOf'>;
5
+ export type ICustomerMember = Pick<factory.iam.IMemberOfRole, 'hasRole' | 'id' | 'name' | 'memberOf'> & {
6
+ /**
7
+ * アプリケーションコード
8
+ * 2025-11-13~
9
+ */
10
+ identifier?: string;
11
+ };
6
12
  /**
7
13
  * IAMメンバーリポジトリ
8
14
  */
@@ -35,6 +41,13 @@ export declare class MemberRepo {
35
41
  name?: {
36
42
  $regex?: string;
37
43
  };
44
+ /**
45
+ * アプリケーションコード
46
+ * 2025-11-15~
47
+ */
48
+ identifier?: {
49
+ $eq?: string;
50
+ };
38
51
  };
39
52
  }): Promise<{
40
53
  member: ICustomerMember;
@@ -87,6 +100,10 @@ export declare class MemberRepo {
87
100
  hasRole?: factory.iam.IMemberRole[];
88
101
  image?: string;
89
102
  name?: string;
103
+ /**
104
+ * アプリケーションコード
105
+ */
106
+ identifier?: string;
90
107
  };
91
108
  $unset: {
92
109
  'member.member'?: 1;
@@ -30,7 +30,7 @@ class MemberRepo {
30
30
  }
31
31
  // tslint:disable-next-line:cyclomatic-complexity max-func-body-length
32
32
  static CREATE_MONGO_CONDITIONS(params) {
33
- 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;
33
+ 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;
34
34
  const andConditions = [];
35
35
  const idEq = (_a = params.id) === null || _a === void 0 ? void 0 : _a.$eq;
36
36
  if (typeof idEq === 'string') {
@@ -64,7 +64,11 @@ class MemberRepo {
64
64
  if (Array.isArray(memberIdIn)) {
65
65
  andConditions.push({ 'member.id': { $in: memberIdIn } });
66
66
  }
67
- const memberNameRegex = (_u = (_t = params.member) === null || _t === void 0 ? void 0 : _t.name) === null || _u === void 0 ? void 0 : _u.$regex;
67
+ const memberIdentifierEq = (_u = (_t = params.member) === null || _t === void 0 ? void 0 : _t.identifier) === null || _u === void 0 ? void 0 : _u.$eq;
68
+ if (typeof memberIdentifierEq === 'string') {
69
+ andConditions.push({ 'member.identifier': { $exists: true, $eq: memberIdentifierEq } });
70
+ }
71
+ const memberNameRegex = (_w = (_v = params.member) === null || _v === void 0 ? void 0 : _v.name) === null || _w === void 0 ? void 0 : _w.$regex;
68
72
  if (typeof memberNameRegex === 'string' && memberNameRegex.length > 0) {
69
73
  andConditions.push({
70
74
  'member.name': {
@@ -73,7 +77,7 @@ class MemberRepo {
73
77
  }
74
78
  });
75
79
  }
76
- const memberHasRoleRoleNameEq = (_x = (_w = (_v = params.member) === null || _v === void 0 ? void 0 : _v.hasRole) === null || _w === void 0 ? void 0 : _w.roleName) === null || _x === void 0 ? void 0 : _x.$eq;
80
+ const memberHasRoleRoleNameEq = (_z = (_y = (_x = params.member) === null || _x === void 0 ? void 0 : _x.hasRole) === null || _y === void 0 ? void 0 : _y.roleName) === null || _z === void 0 ? void 0 : _z.$eq;
77
81
  if (typeof memberHasRoleRoleNameEq === 'string') {
78
82
  andConditions.push({
79
83
  'member.hasRole.roleName': {
@@ -82,7 +86,7 @@ class MemberRepo {
82
86
  }
83
87
  });
84
88
  }
85
- const memberHasRoleRoleNameIn = (_0 = (_z = (_y = params.member) === null || _y === void 0 ? void 0 : _y.hasRole) === null || _z === void 0 ? void 0 : _z.roleName) === null || _0 === void 0 ? void 0 : _0.$in;
89
+ const memberHasRoleRoleNameIn = (_2 = (_1 = (_0 = params.member) === null || _0 === void 0 ? void 0 : _0.hasRole) === null || _1 === void 0 ? void 0 : _1.roleName) === null || _2 === void 0 ? void 0 : _2.$in;
86
90
  if (Array.isArray(memberHasRoleRoleNameIn)) {
87
91
  andConditions.push({
88
92
  'member.hasRole.roleName': {
@@ -110,7 +114,7 @@ class MemberRepo {
110
114
  */
111
115
  searchCustomerMembers(params) {
112
116
  return __awaiter(this, void 0, void 0, function* () {
113
- var _a, _b, _c, _d, _e, _f, _g;
117
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j;
114
118
  if (typeof params.project.id !== 'string' || params.project.id === '') {
115
119
  throw new factory.errors.ArgumentNull('project.id');
116
120
  }
@@ -128,7 +132,8 @@ class MemberRepo {
128
132
  }
129
133
  },
130
134
  id: Object.assign(Object.assign({}, (typeof ((_b = (_a = params.member) === null || _a === void 0 ? void 0 : _a.id) === null || _b === void 0 ? void 0 : _b.$eq) === 'string') ? { $eq: params.member.id.$eq } : undefined), (Array.isArray((_d = (_c = params.member) === null || _c === void 0 ? void 0 : _c.id) === null || _d === void 0 ? void 0 : _d.$in)) ? { $in: params.member.id.$in } : undefined),
131
- name: Object.assign({}, (typeof ((_f = (_e = params.member) === null || _e === void 0 ? void 0 : _e.name) === null || _f === void 0 ? void 0 : _f.$regex) === 'string') ? { $regex: params.member.name.$regex } : undefined)
135
+ identifier: Object.assign({}, (typeof ((_f = (_e = params.member) === null || _e === void 0 ? void 0 : _e.identifier) === null || _f === void 0 ? void 0 : _f.$eq) === 'string') ? { $eq: params.member.identifier.$eq } : undefined),
136
+ name: Object.assign({}, (typeof ((_h = (_g = params.member) === null || _g === void 0 ? void 0 : _g.name) === null || _h === void 0 ? void 0 : _h.$regex) === 'string') ? { $regex: params.member.name.$regex } : undefined)
132
137
  }
133
138
  });
134
139
  const projection = {
@@ -138,6 +143,7 @@ class MemberRepo {
138
143
  // typeOf: 'WebApplication',
139
144
  hasRole: '$member.hasRole',
140
145
  id: '$member.id',
146
+ identifier: '$member.identifier',
141
147
  member: '$member.member',
142
148
  memberOf: '$member.memberOf',
143
149
  name: '$member.name'
@@ -154,7 +160,7 @@ class MemberRepo {
154
160
  },
155
161
  { $project: projection }
156
162
  ]);
157
- if (typeof ((_g = params.sort) === null || _g === void 0 ? void 0 : _g['member.id']) === 'number') {
163
+ if (typeof ((_j = params.sort) === null || _j === void 0 ? void 0 : _j['member.id']) === 'number') {
158
164
  aggregate.sort(params.sort);
159
165
  }
160
166
  if (typeof params.limit === 'number' && params.limit > 0) {
@@ -259,7 +265,7 @@ class MemberRepo {
259
265
  'member.memberOf.id': { $eq: params.member.memberOf.id },
260
266
  'member.memberOf.typeOf': { $eq: params.member.memberOf.typeOf }
261
267
  }, {
262
- $set: Object.assign(Object.assign(Object.assign({}, (Array.isArray(params.member.hasRole)) ? { 'member.hasRole': params.member.hasRole } : undefined), (typeof params.member.image === 'string') ? { 'member.image': params.member.image } : undefined), (typeof params.member.name === 'string') ? { 'member.name': params.member.name } : undefined
268
+ $set: Object.assign(Object.assign(Object.assign(Object.assign({}, (Array.isArray(params.member.hasRole)) ? { 'member.hasRole': params.member.hasRole } : undefined), (typeof params.member.image === 'string') ? { 'member.image': params.member.image } : undefined), (typeof params.member.name === 'string') ? { 'member.name': params.member.name } : undefined), (typeof params.member.identifier === 'string') ? { 'member.identifier': params.member.identifier } : undefined
263
269
  // discontinue(2025-01-14~)
264
270
  // ...(Array.isArray(params.member.member)) ? { 'member.member': params.member.member } : undefined
265
271
  ),
@@ -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 };