@chevre/domain 23.1.0-alpha.9 → 23.2.0-alpha.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 (100) 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/event/importEventSeriesFromCOAByTitle.ts +83 -0
  5. package/example/src/chevre/event/importEventsFromCOAByTitle.ts +148 -0
  6. package/example/src/chevre/eventSeries/migrateEventSeriesUnacceptedPaymentMethod.ts +93 -0
  7. package/example/src/chevre/importEventsFromCOA.ts +5 -5
  8. package/example/src/chevre/pendingReservation/findEventSeatOffersBySection.ts +46 -0
  9. package/example/src/chevre/place/checkSectionCount.ts +27 -0
  10. package/example/src/chevre/place/findSectionsByRoom.ts +50 -0
  11. package/example/src/chevre/project/unsetProjectSettings.ts +73 -0
  12. package/example/src/chevre/reIndex.ts +0 -1
  13. package/example/src/chevre/roles/{addAdminSellerEventIfNotExists.ts → addAdminSellerEventOfferIfNotExists.ts} +1 -1
  14. package/example/src/chevre/stockHolder/findSeatsBySection.ts +59 -0
  15. package/example/src/chevre/stockHolder/searchSeats.ts +2 -2
  16. package/lib/chevre/repo/acceptedPaymentMethod.d.ts +41 -0
  17. package/lib/chevre/repo/acceptedPaymentMethod.js +180 -0
  18. package/lib/chevre/repo/authorization.d.ts +3 -2
  19. package/lib/chevre/repo/authorization.js +13 -5
  20. package/lib/chevre/repo/event.d.ts +1 -35
  21. package/lib/chevre/repo/event.js +2 -102
  22. package/lib/chevre/repo/eventOffer.js +3 -3
  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 +9 -0
  26. package/lib/chevre/repo/note.js +4 -2
  27. package/lib/chevre/repo/pendingReservation.js +28 -71
  28. package/lib/chevre/repo/place/seat.d.ts +24 -0
  29. package/lib/chevre/repo/place/seat.js +103 -21
  30. package/lib/chevre/repo/place/section.d.ts +20 -0
  31. package/lib/chevre/repo/place/section.js +47 -0
  32. package/lib/chevre/repo/ticket.d.ts +7 -1
  33. package/lib/chevre/repo/ticket.js +14 -1
  34. package/lib/chevre/repository.d.ts +5 -0
  35. package/lib/chevre/repository.js +15 -2
  36. package/lib/chevre/service/aggregation/event/importFromCOA.js +2 -2
  37. package/lib/chevre/service/assetTransaction/pay/factory.d.ts +1 -1
  38. package/lib/chevre/service/assetTransaction/pay/factory.js +8 -3
  39. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.d.ts +16 -0
  40. package/lib/chevre/service/assetTransaction/pay/validateAcceptedPaymentMethodIfNeeded.js +94 -0
  41. package/lib/chevre/service/assetTransaction/pay.d.ts +6 -1
  42. package/lib/chevre/service/assetTransaction/pay.js +6 -1
  43. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.d.ts +1 -2
  44. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/fixExtendedEventOffer.js +7 -7
  45. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.d.ts +6 -2
  46. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateIssuedOfferIfExists.js +30 -30
  47. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.d.ts +0 -1
  48. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/validateMemberTierIfExists.js +7 -51
  49. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest/verifyTicketTokenAsNeeded.js +6 -8
  50. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.d.ts +29 -1
  51. package/lib/chevre/service/assetTransaction/reserve/validateStartRequest.js +9 -9
  52. package/lib/chevre/service/event/factory.d.ts +22 -0
  53. package/lib/chevre/service/event/factory.js +2 -0
  54. package/lib/chevre/service/event/processUpdateMovieTheater.d.ts +24 -0
  55. package/lib/chevre/service/event/processUpdateMovieTheater.js +190 -0
  56. package/lib/chevre/service/event/saveScreeningEventSeries.d.ts +63 -0
  57. package/lib/chevre/service/event/saveScreeningEventSeries.js +277 -0
  58. package/lib/chevre/service/event/saveScreeningEvents.d.ts +46 -0
  59. package/lib/chevre/service/event/saveScreeningEvents.js +321 -0
  60. package/lib/chevre/service/event.d.ts +4 -34
  61. package/lib/chevre/service/event.js +12 -698
  62. package/lib/chevre/service/eventOld.d.ts +60 -0
  63. package/lib/chevre/service/eventOld.js +864 -0
  64. package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +1 -1
  65. package/lib/chevre/service/offer/event/issueEventOfferTicket.d.ts +48 -0
  66. package/lib/chevre/service/offer/event/issueEventOfferTicket.js +123 -0
  67. package/lib/chevre/service/offer/event.d.ts +2 -1
  68. package/lib/chevre/service/offer/event.js +3 -1
  69. package/lib/chevre/service/offer.d.ts +31 -1
  70. package/lib/chevre/service/offer.js +104 -34
  71. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.d.ts +9 -0
  72. package/lib/chevre/service/payment/any/authorize/fixTransactionNumber.js +22 -11
  73. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.d.ts +19 -2
  74. package/lib/chevre/service/payment/any/authorize/handlePrePublishedPaymentMethodIdOnAuthorizing.js +87 -9
  75. package/lib/chevre/service/payment/any/factory.d.ts +20 -3
  76. package/lib/chevre/service/payment/any/factory.js +26 -6
  77. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.d.ts +4 -0
  78. package/lib/chevre/service/payment/any/publishPaymentUrl/fixTransactionNumberOnPublishPaymentUrl.js +15 -11
  79. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.d.ts +6 -3
  80. package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +8 -22
  81. package/lib/chevre/service/payment/any.d.ts +5 -1
  82. package/lib/chevre/service/payment/any.js +22 -13
  83. package/lib/chevre/service/payment/factory.js +0 -5
  84. package/lib/chevre/service/payment/movieTicket/authorize.js +0 -5
  85. package/lib/chevre/service/task/authorizePayment.js +2 -0
  86. package/lib/chevre/service/task/publishPaymentUrl.js +4 -0
  87. package/lib/chevre/service/transaction/placeOrder/confirm/publishCode.js +1 -1
  88. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.d.ts +9 -0
  89. package/lib/chevre/service/transaction/placeOrder/confirm/validation/factory.js +2 -0
  90. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.d.ts +8 -0
  91. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validateInvoiceReferencesOrder.js +45 -0
  92. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.d.ts +3 -0
  93. package/lib/chevre/service/transaction/placeOrder/confirm/validation/validatePrice.js +38 -0
  94. package/lib/chevre/service/transaction/placeOrder/confirm/validation.d.ts +2 -8
  95. package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +5 -35
  96. package/package.json +3 -3
  97. package/example/src/chevre/checkReplaceActions.ts +0 -65
  98. package/example/src/chevre/upsertManyEventsByAdditionalProperty.ts +0 -193
  99. package/lib/chevre/service/code.d.ts +0 -8
  100. package/lib/chevre/service/code.js +0 -7
@@ -0,0 +1,73 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ // tslint:disable-next-line:max-func-body-length
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const projectRepo = await chevre.repository.Project.createInstance(mongoose.connection);
11
+
12
+ const cursor = projectRepo.getCursor(
13
+ {
14
+ _id: {
15
+ $nin: [
16
+ 'ttts-development',
17
+ 'ttts-test',
18
+ 'ttts-production'
19
+ ]
20
+ }
21
+ },
22
+ {
23
+ _id: 1,
24
+ settings: 1,
25
+ typeOf: 1
26
+ }
27
+ );
28
+ console.log('docs found');
29
+
30
+ let i = 0;
31
+ let updateCount = 0;
32
+ await cursor.eachAsync(async (doc) => {
33
+ i += 1;
34
+ const project: Pick<chevre.factory.project.IProject, 'id' | 'typeOf' | 'settings'> = doc.toObject();
35
+
36
+ console.log(
37
+ 'alreadyMigrated?', project.id, i);
38
+ const includeCustomerAsFindByConfirmationNumberResult = project.settings?.includeCustomerAsFindByConfirmationNumberResult;
39
+ let alreadyMigrated = true;
40
+ if (typeof includeCustomerAsFindByConfirmationNumberResult === 'boolean'
41
+ && includeCustomerAsFindByConfirmationNumberResult === true) {
42
+ alreadyMigrated = false;
43
+ }
44
+
45
+ if (alreadyMigrated) {
46
+ console.log(
47
+ 'already migrated.', project.id, i);
48
+ } else {
49
+ console.log(
50
+ 'updating project...',
51
+ project.id, i);
52
+ await projectRepo.unsetUnnecessaryFields({
53
+ filter: {
54
+ _id: { $eq: project.id }
55
+ },
56
+ $unset: {
57
+ 'settings.includeCustomerAsFindByConfirmationNumberResult': 1
58
+ }
59
+ });
60
+ updateCount += 1;
61
+ console.log(
62
+ 'updated.',
63
+ project.id, i);
64
+ }
65
+ });
66
+
67
+ console.log(i, 'docs checked');
68
+ console.log(updateCount, 'docs updated');
69
+ }
70
+
71
+ main()
72
+ .then()
73
+ .catch(console.error);
@@ -12,7 +12,6 @@ async function main() {
12
12
  await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
13
13
 
14
14
  await chevre.repository.EventOffer.createInstance(mongoose.connection);
15
- await chevre.repository.Member.createInstance(mongoose.connection);
16
15
  console.log('success!');
17
16
  }
18
17
 
@@ -14,7 +14,7 @@ async function main() {
14
14
  chevre.factory.role.organizationRole.RoleName.SellersInventoryManager
15
15
  ];
16
16
  const permissions = [
17
- 'admin.sellers.events.*'
17
+ 'admin.sellers.eventOffers.*'
18
18
  ];
19
19
  for (const roleName of roleNames) {
20
20
  for (const permission of permissions) {
@@ -0,0 +1,59 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../../lib/index';
5
+
6
+ const PROJECT_ID = String(process.env.PROJECT_ID);
7
+ const SCREEN_CODE = '100';
8
+ const MOVIE_THEATER_CODE = '118';
9
+ const SELLER_ID = '59d20831e53ebc2b4e774466';
10
+
11
+ const formatter = new Intl.NumberFormat('ja-JP');
12
+
13
+ // tslint:disable-next-line:max-func-body-length
14
+ async function main() {
15
+ let startTime: [number, number] = process.hrtime();
16
+ let diff: [number, number] = process.hrtime(startTime);
17
+
18
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
19
+
20
+ const seatRepo = await chevre.repository.place.Seat.createInstance(mongoose.connection);
21
+
22
+ setInterval(
23
+ async () => {
24
+ startTime = process.hrtime();
25
+ const seats = await seatRepo.findSeatsBySection(
26
+ {
27
+ limit: 100,
28
+ page: 100,
29
+ projectId: PROJECT_ID,
30
+ sellerId: SELLER_ID,
31
+ movieTheaterCode: MOVIE_THEATER_CODE,
32
+ roomCode: SCREEN_CODE,
33
+ sectionCode: 'Default'
34
+ },
35
+ {
36
+ // branchCode: { $in: ['Z-384'] },
37
+ // containedInPlace: {
38
+ // branchCode: {
39
+ // $in: ['Default']
40
+ // }
41
+ // }
42
+ }
43
+ );
44
+ diff = process.hrtime(startTime);
45
+ // tslint:disable-next-line:no-null-keyword
46
+ console.dir(seats, { depth: null });
47
+ console.log(seats.length, 'seats found');
48
+ console.log('diff:', [diff[0], formatter.format(diff[1])]);
49
+ },
50
+ // tslint:disable-next-line:no-magic-numbers
51
+ 1000
52
+ );
53
+ }
54
+
55
+ main()
56
+ .then(() => {
57
+ console.log('success!');
58
+ })
59
+ .catch(console.error);
@@ -28,8 +28,8 @@ async function main() {
28
28
  'containedInPlace.containedInPlace': 0,
29
29
  'containedInPlace.typeOf': 0,
30
30
  'containedInPlace.name': 0,
31
- typeOf: 0,
32
- additionalProperty: 0
31
+ typeOf: 0
32
+ // additionalProperty: 0
33
33
  },
34
34
  project: { id: { $eq: PROJECT_ID } },
35
35
  screeningRoom: {
@@ -0,0 +1,41 @@
1
+ import type { BulkWriteResult } from 'mongodb';
2
+ import { Connection, FilterQuery } from 'mongoose';
3
+ import * as factory from '../factory';
4
+ import { IDocType } from './mongoose/schemas/acceptedPaymentMethod';
5
+ type IUnset = {
6
+ [key in keyof IDocType]?: 1;
7
+ };
8
+ type IDocWithId = IDocType & {
9
+ id: string;
10
+ };
11
+ type IKeyOfProjection = keyof IDocType;
12
+ /**
13
+ * 対応決済方法リポジトリ
14
+ */
15
+ export declare class AcceptedPaymentMethodRepo {
16
+ private readonly acceptedPaymentMethodModel;
17
+ constructor(connection: Connection);
18
+ static CREATE_MONGO_CONDITIONS(params: factory.acceptedPaymentMethodOffer.ISearchConditions): FilterQuery<IDocType>[];
19
+ findAcceptedPaymentMethods(params: factory.acceptedPaymentMethodOffer.ISearchConditions, inclusion: IKeyOfProjection[]): Promise<IDocWithId[]>;
20
+ /**
21
+ * オファーコードと提供リソースIDをキーにして冪等置換
22
+ */
23
+ upsertAcceptedPaymentMethodsByIdentifier(params: {
24
+ $set: Pick<IDocType, 'identifier' | 'itemOffered' | 'acceptedPaymentMethod' | 'seller' | 'project' | 'typeOf' | 'validFrom' | 'validThrough'> & {
25
+ id?: never;
26
+ };
27
+ $unset: IUnset;
28
+ }[], options: {
29
+ /**
30
+ * falseの場合setOnInsertのみ
31
+ * trueの場合setのみ
32
+ */
33
+ update: boolean;
34
+ }): Promise<{
35
+ bulkWriteResult: BulkWriteResult;
36
+ modifiedProductOffers: {
37
+ id: string;
38
+ }[];
39
+ } | void>;
40
+ }
41
+ export {};
@@ -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 };