@chevre/domain 21.2.0-alpha.71 → 21.2.0-alpha.73

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.
@@ -68,7 +68,8 @@ async function main() {
68
68
  },
69
69
  validateEvent: false,
70
70
  validateEventOfferPeriod: false,
71
- validateAppliesToMovieTicket: true
71
+ validateAppliesToMovieTicket: true,
72
+ disablePendingReservations: true
72
73
  })({
73
74
  stockHolder: itemAvailabilityRepo,
74
75
  event: eventRepo,
@@ -64,9 +64,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
64
64
  project?: any;
65
65
  orderNumber?: string | undefined;
66
66
  seller?: any;
67
+ broker?: any;
67
68
  price?: number | undefined;
68
69
  priceCurrency?: string | undefined;
69
- broker?: any;
70
70
  customer?: any;
71
71
  returner?: any;
72
72
  confirmationNumber?: string | undefined;
@@ -87,9 +87,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
87
87
  project?: any;
88
88
  orderNumber?: string | undefined;
89
89
  seller?: any;
90
+ broker?: any;
90
91
  price?: number | undefined;
91
92
  priceCurrency?: string | undefined;
92
- broker?: any;
93
93
  customer?: any;
94
94
  returner?: any;
95
95
  confirmationNumber?: string | undefined;
@@ -110,9 +110,9 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
110
110
  project?: any;
111
111
  orderNumber?: string | undefined;
112
112
  seller?: any;
113
+ broker?: any;
113
114
  price?: number | undefined;
114
115
  priceCurrency?: string | undefined;
115
- broker?: any;
116
116
  customer?: any;
117
117
  returner?: any;
118
118
  confirmationNumber?: string | undefined;
@@ -62,16 +62,16 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
62
62
  additionalProperty?: any;
63
63
  reservationFor?: any;
64
64
  subReservation?: any;
65
+ broker?: any;
65
66
  price?: any;
66
67
  priceCurrency?: string | undefined;
68
+ issuedThrough?: any;
69
+ reservedTicket?: any;
67
70
  additionalTicketText?: string | undefined;
68
71
  bookingTime?: Date | undefined;
69
- broker?: any;
70
- issuedThrough?: any;
71
72
  modifiedTime?: Date | undefined;
72
73
  numSeats?: number | undefined;
73
74
  programMembershipUsed?: any;
74
- reservedTicket?: any;
75
75
  underName?: any;
76
76
  bookingAgent?: any;
77
77
  cancelReservationUrl?: string | undefined;
@@ -90,16 +90,16 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
90
90
  additionalProperty?: any;
91
91
  reservationFor?: any;
92
92
  subReservation?: any;
93
+ broker?: any;
93
94
  price?: any;
94
95
  priceCurrency?: string | undefined;
96
+ issuedThrough?: any;
97
+ reservedTicket?: any;
95
98
  additionalTicketText?: string | undefined;
96
99
  bookingTime?: Date | undefined;
97
- broker?: any;
98
- issuedThrough?: any;
99
100
  modifiedTime?: Date | undefined;
100
101
  numSeats?: number | undefined;
101
102
  programMembershipUsed?: any;
102
- reservedTicket?: any;
103
103
  underName?: any;
104
104
  bookingAgent?: any;
105
105
  cancelReservationUrl?: string | undefined;
@@ -118,16 +118,16 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
118
118
  additionalProperty?: any;
119
119
  reservationFor?: any;
120
120
  subReservation?: any;
121
+ broker?: any;
121
122
  price?: any;
122
123
  priceCurrency?: string | undefined;
124
+ issuedThrough?: any;
125
+ reservedTicket?: any;
123
126
  additionalTicketText?: string | undefined;
124
127
  bookingTime?: Date | undefined;
125
- broker?: any;
126
- issuedThrough?: any;
127
128
  modifiedTime?: Date | undefined;
128
129
  numSeats?: number | undefined;
129
130
  programMembershipUsed?: any;
130
- reservedTicket?: any;
131
131
  underName?: any;
132
132
  bookingAgent?: any;
133
133
  cancelReservationUrl?: string | undefined;
@@ -31,14 +31,16 @@ export declare class MongoRepository {
31
31
  inclusion?: string[];
32
32
  exclusion?: string[];
33
33
  }): Promise<factory.reservation.IReservation<T>>;
34
- /**
35
- * 予約確定
36
- */
37
34
  confirmByReservationNumber(params: {
38
35
  reservationNumber: string;
39
36
  previousReservationStatus: factory.reservationStatusType;
40
37
  underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
41
38
  }): Promise<void>;
39
+ confirmByIdIfNotExist(params: {
40
+ reservation: factory.assetTransaction.reserve.IObjectSubReservation;
41
+ reservationFor: factory.assetTransaction.reserve.IReservationFor;
42
+ underName?: factory.reservation.IUnderName<factory.reservationType.EventReservation>;
43
+ }): Promise<void>;
42
44
  /**
43
45
  * 予約取消
44
46
  */
@@ -910,48 +910,6 @@ class MongoRepository {
910
910
  return doc.toObject();
911
911
  });
912
912
  }
913
- /**
914
- * 予約確定
915
- */
916
- // public async confirm<T extends factory.reservationType>(params: {
917
- // id: string;
918
- // previousReservationStatus: factory.reservationStatusType;
919
- // underName?: factory.reservation.IUnderName<T>;
920
- // }): Promise<factory.reservation.IReservation<T>> {
921
- // const conditions = {
922
- // _id: { $eq: String(params.id) },
923
- // reservationStatus: { $eq: params.previousReservationStatus }
924
- // };
925
- // // 更新属性をwhitelist化(2022-06-13~)
926
- // const update = {
927
- // // previousReservationStatusを保管(2023-01-19~)
928
- // previousReservationStatus: params.previousReservationStatus,
929
- // reservationStatus: factory.reservationStatusType.ReservationConfirmed,
930
- // modifiedTime: new Date(),
931
- // ...(params.underName !== undefined) ? { underName: params.underName } : undefined
932
- // };
933
- // const doc = await this.reservationModel.findOneAndUpdate(
934
- // conditions,
935
- // update,
936
- // { new: true }
937
- // )
938
- // .select({ __v: 0, createdAt: 0, updatedAt: 0 })
939
- // .exec();
940
- // // NotFoundであれば状態確認
941
- // if (doc === null) {
942
- // const reservation = await this.findById<T>({ id: String(params.id) });
943
- // if (reservation.reservationStatus === factory.reservationStatusType.ReservationConfirmed) {
944
- // // すでに確定済の場合
945
- // return reservation;
946
- // } else {
947
- // throw new factory.errors.Argument(
948
- // 'id',
949
- // `Reservation ${reservation.id} already changed -> ${reservation.reservationStatus}`
950
- // );
951
- // }
952
- // }
953
- // return doc.toObject();
954
- // }
955
913
  confirmByReservationNumber(params) {
956
914
  return __awaiter(this, void 0, void 0, function* () {
957
915
  const conditions = {
@@ -965,6 +923,14 @@ class MongoRepository {
965
923
  .exec();
966
924
  });
967
925
  }
926
+ confirmByIdIfNotExist(params) {
927
+ return __awaiter(this, void 0, void 0, function* () {
928
+ yield this.reservationModel.findByIdAndUpdate({ _id: { $eq: params.reservation.id } }, {
929
+ $setOnInsert: Object.assign(Object.assign(Object.assign({}, params.reservation), { _id: params.reservation.id, reservationFor: params.reservationFor, reservationStatus: factory.reservationStatusType.ReservationConfirmed, modifiedTime: new Date() }), (params.underName !== undefined) ? { underName: params.underName } : undefined)
930
+ })
931
+ .exec();
932
+ });
933
+ }
968
934
  /**
969
935
  * 予約取消
970
936
  */
@@ -4,6 +4,7 @@ type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservat
4
4
  export { IAcceptedAddOn };
5
5
  export declare function createStartParams(params: factory.assetTransaction.reserve.IStartParamsWithoutDetail & {
6
6
  reservationNumber: string;
7
+ disablePendingReservations: boolean;
7
8
  }): factory.assetTransaction.IStartParams<factory.assetTransactionType.Reserve>;
8
9
  /**
9
10
  * ポイント特典を作成する
@@ -12,8 +12,8 @@ function createStartParams(params) {
12
12
  var _a;
13
13
  const reservationNumber = params.reservationNumber;
14
14
  const reservationPackage = Object.assign({
15
- // clientUser: params.object.clientUser,
16
- project: params.project, reservationNumber: reservationNumber, typeOf: factory.reservationType.ReservationPackage }, (typeof ((_a = params.object.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { broker: params.object.broker } : undefined);
15
+ // project: params.project,
16
+ reservationNumber: reservationNumber, reservationStatus: factory.reservationStatusType.ReservationPending, disablePendingReservations: params.disablePendingReservations, typeOf: factory.reservationType.ReservationPackage }, (typeof ((_a = params.object.broker) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') ? { broker: params.object.broker } : undefined);
17
17
  return {
18
18
  project: { id: params.project.id, typeOf: factory.organizationType.Project },
19
19
  typeOf: factory.assetTransactionType.Reserve,
@@ -467,7 +467,9 @@ function createPotentialActions(params) {
467
467
  underName
468
468
  }));
469
469
  });
470
- const reservationPackage = Object.assign({ reservationFor, reservationNumber: transaction.object.reservationNumber, reservationStatus: pendingReservations[0].reservationStatus,
470
+ const reservationPackage = Object.assign({ reservationFor, reservationNumber: transaction.object.reservationNumber, reservationStatus: (typeof params.transaction.object.reservationStatus === 'string')
471
+ ? params.transaction.object.reservationStatus
472
+ : factory.reservationStatusType.ReservationPending,
471
473
  // 不要なので廃止(2023-01-19~)
472
474
  // subReservation: pendingReservations,
473
475
  typeOf: factory.reservationType.ReservationPackage }, (typeof (underName === null || underName === void 0 ? void 0 : underName.typeOf) === 'string') ? { underName } : undefined);
@@ -521,11 +523,11 @@ function createMoneyTransferActions(params) {
521
523
  && typeof pointAwardToLocationIdentifier === 'string'
522
524
  && typeof pointAwardToLocationTypeOf === 'string') {
523
525
  const fromLocation = {
524
- typeOf: (typeof ((_f = params.reservation.underName) === null || _f === void 0 ? void 0 : _f.typeOf) === 'string')
525
- ? params.reservation.underName.typeOf
526
+ typeOf: (typeof ((_f = params.reservation.reservedTicket.issuedBy) === null || _f === void 0 ? void 0 : _f.typeOf) === 'string')
527
+ ? params.reservation.reservedTicket.issuedBy.typeOf
526
528
  : params.transaction.typeOf,
527
- name: (typeof ((_g = params.reservation.underName) === null || _g === void 0 ? void 0 : _g.name) === 'string')
528
- ? params.reservation.underName.name
529
+ name: (typeof ((_g = params.reservation.reservedTicket.issuedBy) === null || _g === void 0 ? void 0 : _g.name) === 'string')
530
+ ? params.reservation.reservedTicket.issuedBy.name
529
531
  : params.transaction.id
530
532
  };
531
533
  const toLocation = {
@@ -566,7 +568,9 @@ function createPendingReservationAction(params) {
566
568
  typeOf: factory.reservationType.ReservationPackage,
567
569
  reservationNumber: transaction.transactionNumber,
568
570
  reservationFor: { typeOf: reservationFor.typeOf, id: String(reservationFor.id) },
569
- reservationStatus: pendingReservations[0].reservationStatus
571
+ reservationStatus: (typeof params.transaction.object.reservationStatus === 'string')
572
+ ? params.transaction.object.reservationStatus
573
+ : factory.reservationStatusType.ReservationPending
570
574
  };
571
575
  cancelActionAttributes = [{
572
576
  project: transaction.project,
@@ -95,7 +95,9 @@ type IStartParams = factory.assetTransaction.reserve.IStartParamsWithoutDetail &
95
95
  /**
96
96
  * 取引開始
97
97
  */
98
- export declare function start(params: IStartParams): IStartOperation<{
98
+ export declare function start(params: IStartParams & {
99
+ disablePendingReservations: boolean;
100
+ }): IStartOperation<{
99
101
  transaction: factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>;
100
102
  objectSubReservations: IObjectSubReservation[];
101
103
  }>;
@@ -135,6 +135,20 @@ function addReservations(params) {
135
135
  })(repos);
136
136
  // 予約イベント最適化
137
137
  const reservationFor = (0, factory_1.createReservationFor)(event);
138
+ // const minimizedObjectSubReservations: factory.assetTransaction.reserve.IMinimizedObjectSubReservation[] =
139
+ // objectSubReservations.map((r) => {
140
+ // return {
141
+ // id: r.id,
142
+ // typeOf: r.typeOf,
143
+ // reservedTicket: {
144
+ // ticketType: r.reservedTicket.ticketType,
145
+ // ...(typeof r.reservedTicket.ticketedSeat?.typeOf === 'string')
146
+ // ? { ticketedSeat: r.reservedTicket.ticketedSeat }
147
+ // : undefined
148
+ // },
149
+ // ...(Array.isArray(r.subReservation)) ? { subReservation: r.subReservation } : undefined
150
+ // };
151
+ // });
138
152
  // 取引に予約追加
139
153
  let lockedOfferRateLimitKeys = [];
140
154
  try {
@@ -147,6 +161,7 @@ function addReservations(params) {
147
161
  reservationFor,
148
162
  // subReservationにreservationForを保管しない(2021-10-19~)
149
163
  subReservation: objectSubReservations
164
+ // subReservation: minimizedObjectSubReservations
150
165
  }
151
166
  });
152
167
  }
@@ -165,10 +180,12 @@ function addReservations(params) {
165
180
  reservations: objectSubReservations,
166
181
  transaction: transaction
167
182
  })(repos);
168
- // 予約作成(insertManyで実装)
169
- yield repos.reservation.createMany({ reservationFor, reservations: objectSubReservations });
170
- // 予約作成後処理
171
- yield onReservationsCreated({ event })(repos);
183
+ if (transaction.object.disablePendingReservations !== true) {
184
+ // 予約作成(insertManyで実装)
185
+ yield repos.reservation.createMany({ reservationFor, reservations: objectSubReservations });
186
+ // 予約作成後処理
187
+ yield onReservationsCreated({ event })(repos);
188
+ }
172
189
  return { transaction, objectSubReservations };
173
190
  });
174
191
  }
@@ -57,5 +57,6 @@ declare function authorize(params: {
57
57
  */
58
58
  id: string;
59
59
  };
60
+ disablePendingReservations: boolean;
60
61
  }): IAuthorizeOperation<IAuthorizeOfferAction>;
61
62
  export { authorize };
@@ -66,7 +66,8 @@ function authorize(params) {
66
66
  ticketOffers,
67
67
  unitPriceOffers,
68
68
  validateEvent: params.validateEvent === true,
69
- validateEventOfferPeriod: params.validateEventOfferPeriod === true
69
+ validateEventOfferPeriod: params.validateEventOfferPeriod === true,
70
+ disablePendingReservations: params.disablePendingReservations
70
71
  })(repos);
71
72
  // requestBody = processStartReserveResult.requestBody;
72
73
  // responseBody = processStartReserveResult.responseBody;
@@ -162,7 +163,7 @@ function processStartReserve4chevre(params) {
162
163
  // requestBody = startParams;
163
164
  const startParamObject = yield validateObjectWithoutDetail(startParams)(repos);
164
165
  // 予約取引開始
165
- const startReserveTransactionResult = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject, preSearchedEvent: event, preSearchedTicketOffers: params.ticketOffers, preSearchedUnitPriceOffers: params.unitPriceOffers, availableAtOrFrom: { id: params.availableAtOrFrom.id }, validateEvent: params.validateEvent, validateEventOfferPeriod: params.validateEventOfferPeriod, validateAppliesToMovieTicket: true }))(repos);
166
+ const startReserveTransactionResult = yield ReserveTransactionService.start(Object.assign(Object.assign({}, startParams), { object: startParamObject, preSearchedEvent: event, preSearchedTicketOffers: params.ticketOffers, preSearchedUnitPriceOffers: params.unitPriceOffers, availableAtOrFrom: { id: params.availableAtOrFrom.id }, validateEvent: params.validateEvent, validateEventOfferPeriod: params.validateEventOfferPeriod, validateAppliesToMovieTicket: true, disablePendingReservations: params.disablePendingReservations }))(repos);
166
167
  responseBody = startReserveTransactionResult.transaction;
167
168
  // 予約取引からオファー情報を生成する
168
169
  acceptedOffers4result = (0, factory_1.responseBody2acceptedOffers4result)({
@@ -5,7 +5,6 @@ import { RedisRepository as OfferRateLimitRepo } from '../../repo/rateLimit/offe
5
5
  import { MongoRepository as ReservationRepo } from '../../repo/reservation';
6
6
  import { StockHolderRepository as StockHolderRepo } from '../../repo/stockHolder';
7
7
  import { MongoRepository as TaskRepo } from '../../repo/task';
8
- type IObjectSubReservation = factory.assetTransaction.reserve.IObjectSubReservation;
9
8
  /**
10
9
  * 進行中の予約をキャンセルする
11
10
  */
@@ -29,7 +28,10 @@ declare function cancelReservation(actionAttributesList: factory.action.cancel.r
29
28
  assetTransaction: AssetTransactionRepo;
30
29
  }) => Promise<void>;
31
30
  declare function processUnlockOfferRateLimit(params: {
32
- reservation: Pick<IObjectSubReservation, 'reservationNumber' | 'reservedTicket'>;
31
+ reservation: {
32
+ reservationNumber: string;
33
+ reservedTicket: factory.assetTransaction.reserve.IObjectSubReservationReservedTicket;
34
+ };
33
35
  reservationFor: factory.assetTransaction.reserve.IReservationFor;
34
36
  }): (repos: {
35
37
  offerRateLimit: OfferRateLimitRepo;
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import * as factory from '../../factory';
5
5
  import { MongoRepository as ActionRepo } from '../../repo/action';
6
+ import { MongoRepository as AssetTrasactionRepo } from '../../repo/assetTransaction';
6
7
  import { MongoRepository as ReservationRepo } from '../../repo/reservation';
7
8
  import { MongoRepository as TaskRepo } from '../../repo/task';
8
9
  /**
@@ -10,6 +11,7 @@ import { MongoRepository as TaskRepo } from '../../repo/task';
10
11
  */
11
12
  export declare function confirmReservation(actionAttributesList: factory.action.reserve.IAttributes[]): (repos: {
12
13
  action: ActionRepo;
14
+ assetTransaction: AssetTrasactionRepo;
13
15
  reservation: ReservationRepo;
14
16
  task: TaskRepo;
15
17
  }) => Promise<void>;
@@ -27,14 +27,41 @@ function confirmReservation(actionAttributesList) {
27
27
  const reservation = actionAttributes.object;
28
28
  const action = yield repos.action.start(actionAttributes);
29
29
  try {
30
+ const reserveTransactions = yield repos.assetTransaction.search({
31
+ limit: 1,
32
+ page: 1,
33
+ typeOf: factory.assetTransactionType.Reserve,
34
+ transactionNumber: { $eq: reservation.reservationNumber }
35
+ });
36
+ const reserveTransaction = reserveTransactions.shift();
37
+ if (reserveTransaction === undefined) {
38
+ throw new factory.errors.NotFound(factory.assetTransactionType.Reserve);
39
+ }
30
40
  // ReservationPackageに対応(2022-12-22~)
31
41
  if (reservation.typeOf === factory.reservationType.ReservationPackage) {
32
- // 予約を確定状態に変更する
33
- yield repos.reservation.confirmByReservationNumber({
34
- reservationNumber: reservation.reservationNumber,
35
- previousReservationStatus: reservation.reservationStatus,
36
- underName: reservation.underName
37
- });
42
+ // Pendingの予約が存在しないバージョンに対応する(2023-05-29~)
43
+ if (reserveTransaction.object.disablePendingReservations === true) {
44
+ const reservationFor = reserveTransaction.object.reservationFor;
45
+ const subReservations = reserveTransaction.object.subReservation;
46
+ if (Array.isArray(subReservations)
47
+ && typeof (reservationFor === null || reservationFor === void 0 ? void 0 : reservationFor.typeOf) === 'string') {
48
+ yield Promise.all(subReservations.map((subReservation) => __awaiter(this, void 0, void 0, function* () {
49
+ yield repos.reservation.confirmByIdIfNotExist({
50
+ reservation: subReservation,
51
+ reservationFor,
52
+ underName: reservation.underName
53
+ });
54
+ })));
55
+ }
56
+ }
57
+ else {
58
+ // 予約を確定状態に変更する
59
+ yield repos.reservation.confirmByReservationNumber({
60
+ reservationNumber: reservation.reservationNumber,
61
+ previousReservationStatus: reservation.reservationStatus,
62
+ underName: reservation.underName
63
+ });
64
+ }
38
65
  }
39
66
  else {
40
67
  // 廃止(2023-01-18)
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.call = void 0;
13
13
  const action_1 = require("../../repo/action");
14
+ const assetTransaction_1 = require("../../repo/assetTransaction");
14
15
  const reservation_1 = require("../../repo/reservation");
15
16
  const task_1 = require("../../repo/task");
16
17
  const ReserveService = require("../reserve");
@@ -19,13 +20,11 @@ const ReserveService = require("../reserve");
19
20
  */
20
21
  function call(data) {
21
22
  return (settings) => __awaiter(this, void 0, void 0, function* () {
22
- const actionRepo = new action_1.MongoRepository(settings.connection);
23
- const reservationRepo = new reservation_1.MongoRepository(settings.connection);
24
- const taskRepo = new task_1.MongoRepository(settings.connection);
25
23
  yield ReserveService.confirmReservation(data.actionAttributes)({
26
- action: actionRepo,
27
- reservation: reservationRepo,
28
- task: taskRepo
24
+ action: new action_1.MongoRepository(settings.connection),
25
+ assetTransaction: new assetTransaction_1.MongoRepository(settings.connection),
26
+ reservation: new reservation_1.MongoRepository(settings.connection),
27
+ task: new task_1.MongoRepository(settings.connection)
29
28
  });
30
29
  });
31
30
  }
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.313.0-alpha.12",
12
+ "@chevre/factory": "4.313.0-alpha.14",
13
13
  "@cinerino/sdk": "3.157.0-alpha.2",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
@@ -117,5 +117,5 @@
117
117
  "postversion": "git push origin --tags",
118
118
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
119
119
  },
120
- "version": "21.2.0-alpha.71"
120
+ "version": "21.2.0-alpha.73"
121
121
  }