@chevre/domain 21.2.0-alpha.77 → 21.2.0-alpha.78

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.
@@ -75,6 +75,7 @@ export declare class MongoRepository {
75
75
  confirm<T extends factory.assetTransactionType>(params: {
76
76
  typeOf: T;
77
77
  id: string;
78
+ object?: Pick<factory.action.reserve.IReservationPackageAsObject, 'underName'>;
78
79
  result: factory.assetTransaction.IResult<T>;
79
80
  potentialActions: factory.assetTransaction.IPotentialActions<T>;
80
81
  }): Promise<void>;
@@ -311,17 +311,15 @@ class MongoRepository {
311
311
  * 取引を確定する
312
312
  */
313
313
  confirm(params) {
314
+ var _a, _b, _c;
314
315
  return __awaiter(this, void 0, void 0, function* () {
315
316
  const doc = yield this.transactionModel.findOneAndUpdate({
316
317
  _id: { $eq: params.id },
317
318
  typeOf: { $eq: params.typeOf },
318
319
  status: { $eq: factory.transactionStatusType.InProgress }
319
- }, {
320
- status: factory.transactionStatusType.Confirmed,
321
- endDate: new Date(),
322
- result: params.result,
323
- potentialActions: params.potentialActions // resultを更新
324
- }, {
320
+ }, Object.assign({ status: factory.transactionStatusType.Confirmed, endDate: new Date(), result: params.result, potentialActions: params.potentialActions }, (typeof ((_b = (_a = params.object) === null || _a === void 0 ? void 0 : _a.underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string')
321
+ ? { 'object.underName': (_c = params.object) === null || _c === void 0 ? void 0 : _c.underName }
322
+ : undefined), {
325
323
  new: true,
326
324
  projection: { _id: 1 }
327
325
  })
@@ -65,6 +65,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
65
65
  broker?: any;
66
66
  price?: any;
67
67
  priceCurrency?: string | undefined;
68
+ underName?: any;
68
69
  issuedThrough?: any;
69
70
  reservedTicket?: any;
70
71
  additionalTicketText?: string | undefined;
@@ -72,7 +73,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
72
73
  modifiedTime?: Date | undefined;
73
74
  numSeats?: number | undefined;
74
75
  programMembershipUsed?: any;
75
- underName?: any;
76
76
  bookingAgent?: any;
77
77
  cancelReservationUrl?: string | undefined;
78
78
  checkinUrl?: string | undefined;
@@ -93,6 +93,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
93
93
  broker?: any;
94
94
  price?: any;
95
95
  priceCurrency?: string | undefined;
96
+ underName?: any;
96
97
  issuedThrough?: any;
97
98
  reservedTicket?: any;
98
99
  additionalTicketText?: string | undefined;
@@ -100,7 +101,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
100
101
  modifiedTime?: Date | undefined;
101
102
  numSeats?: number | undefined;
102
103
  programMembershipUsed?: any;
103
- underName?: any;
104
104
  bookingAgent?: any;
105
105
  cancelReservationUrl?: string | undefined;
106
106
  checkinUrl?: string | undefined;
@@ -121,6 +121,7 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
121
121
  broker?: any;
122
122
  price?: any;
123
123
  priceCurrency?: string | undefined;
124
+ underName?: any;
124
125
  issuedThrough?: any;
125
126
  reservedTicket?: any;
126
127
  additionalTicketText?: string | undefined;
@@ -128,7 +129,6 @@ declare const schema: Schema<any, import("mongoose").Model<any, any, any, any, a
128
129
  modifiedTime?: Date | undefined;
129
130
  numSeats?: number | undefined;
130
131
  programMembershipUsed?: any;
131
- underName?: any;
132
132
  bookingAgent?: any;
133
133
  cancelReservationUrl?: string | undefined;
134
134
  checkinUrl?: string | undefined;
@@ -86,7 +86,9 @@ export declare class MongoRepository {
86
86
  /**
87
87
  * 注文を検索する
88
88
  */
89
- search(params: factory.order.ISearchConditions, projection?: any): Promise<factory.order.IOrder[]>;
89
+ search(params: factory.order.ISearchConditions, projection?: {
90
+ [key: string]: 0 | 1;
91
+ }): Promise<factory.order.IOrder[]>;
90
92
  /**
91
93
  * 注文の受入オファーIDリストを検索する
92
94
  */
@@ -896,8 +896,15 @@ class MongoRepository {
896
896
  var _a;
897
897
  return __awaiter(this, void 0, void 0, function* () {
898
898
  const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
899
+ const projectionSpecified = projection !== undefined && projection !== null;
900
+ const positiveProjectionExists = (projectionSpecified)
901
+ ? Object.values(projection)
902
+ .some((value) => value !== 0)
903
+ : false;
899
904
  const query = this.orderModel.find((conditions.length > 0) ? { $and: conditions } : {})
900
- .select(Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
905
+ .select((projectionSpecified && positiveProjectionExists)
906
+ ? projection
907
+ : Object.assign({ __v: 0, createdAt: 0, updatedAt: 0 }, projection));
901
908
  if (typeof params.limit === 'number' && params.limit > 0) {
902
909
  const page = (typeof params.page === 'number' && params.page > 0) ? params.page : 1;
903
910
  query.limit(params.limit)
@@ -71,8 +71,11 @@ export declare function createReservation(params: {
71
71
  }): IObjectSubReservation;
72
72
  export declare function createPotentialActions(params: factory.assetTransaction.reserve.IConfirmParams & {
73
73
  transaction: factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>;
74
- order?: factory.order.IOrder;
75
- }): factory.assetTransaction.reserve.IPotentialActions;
74
+ order?: Pick<factory.order.IOrder, 'orderNumber' | 'customer' | 'typeOf'>;
75
+ }): {
76
+ potentialActions: factory.assetTransaction.reserve.IPotentialActions;
77
+ reservationPackage?: factory.action.reserve.IReservationPackageAsObject;
78
+ };
76
79
  export declare function createPendingReservationAction(params: {
77
80
  transaction: factory.assetTransaction.ITransaction<factory.assetTransactionType.Reserve>;
78
81
  }): factory.action.cancel.reservation.IAttributes[];
@@ -448,6 +448,7 @@ function createPotentialActions(params) {
448
448
  // 予約アクション属性作成
449
449
  const pendingReservations = (Array.isArray(transaction.object.subReservation)) ? transaction.object.subReservation : [];
450
450
  let reserveActionAttributes = [];
451
+ let reservationPackage;
451
452
  if (pendingReservations.length > 0) {
452
453
  // ReservationPackageに対応(2022-12-22~)
453
454
  let underName;
@@ -467,7 +468,7 @@ function createPotentialActions(params) {
467
468
  underName
468
469
  }));
469
470
  });
470
- const reservationPackage = Object.assign({ reservationFor, reservationNumber: transaction.object.reservationNumber, reservationStatus: (typeof params.transaction.object.reservationStatus === 'string')
471
+ reservationPackage = Object.assign({ reservationFor, reservationNumber: transaction.object.reservationNumber, reservationStatus: (typeof params.transaction.object.reservationStatus === 'string')
471
472
  ? params.transaction.object.reservationStatus
472
473
  : factory.reservationStatusType.ReservationPending,
473
474
  // 不要なので廃止(2023-01-19~)
@@ -486,7 +487,10 @@ function createPotentialActions(params) {
486
487
  }];
487
488
  }
488
489
  return {
489
- reserve: reserveActionAttributes
490
+ potentialActions: {
491
+ reserve: reserveActionAttributes
492
+ },
493
+ reservationPackage
490
494
  };
491
495
  }
492
496
  exports.createPotentialActions = createPotentialActions;
@@ -505,10 +509,6 @@ function createReservationUnderName(params) {
505
509
  */
506
510
  function ordre2reservationUnderName(params) {
507
511
  return {
508
- // issuedBy: {
509
- // typeOf: params.order.seller.typeOf,
510
- // name: params.order.seller.name
511
- // },
512
512
  underName: createReservationUnderName({ order: params.order })
513
513
  };
514
514
  }
@@ -698,6 +698,7 @@ function onReservationsCreated(params) {
698
698
  */
699
699
  function confirm(params) {
700
700
  return (repos) => __awaiter(this, void 0, void 0, function* () {
701
+ var _a;
701
702
  let transaction;
702
703
  // 取引存在確認
703
704
  if (typeof params.id === 'string') {
@@ -716,17 +717,14 @@ function confirm(params) {
716
717
  throw new factory.errors.ArgumentNull('Transaction ID or Transaction Number');
717
718
  }
718
719
  const order = yield fixOrderAsPurpose(params, transaction)(repos);
719
- const potentialActions = (0, factory_1.createPotentialActions)(Object.assign(Object.assign({}, params), { transaction: transaction, order }));
720
+ const { potentialActions, reservationPackage } = (0, factory_1.createPotentialActions)(Object.assign(Object.assign({}, params), { transaction: transaction, order }));
720
721
  // 取引確定
721
722
  const result = {};
722
- yield repos.assetTransaction.confirm({
723
- typeOf: factory.assetTransactionType.Reserve,
724
- id: transaction.id,
725
- result: result,
726
- potentialActions: (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING)
723
+ yield repos.assetTransaction.confirm(Object.assign({ typeOf: factory.assetTransactionType.Reserve, id: transaction.id, result: result, potentialActions: (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING)
727
724
  ? { reserve: [] }
728
- : potentialActions
729
- });
725
+ : potentialActions }, (typeof ((_a = reservationPackage === null || reservationPackage === void 0 ? void 0 : reservationPackage.underName) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string')
726
+ ? { object: { underName: reservationPackage.underName } }
727
+ : undefined));
730
728
  if (settings_1.USE_ASSET_TRANSACTION_SYNC_PROCESSING) {
731
729
  // sync対応(2023-01-13~)
732
730
  yield (0, confirmReservation_1.confirmReservation)(potentialActions.reserve)(repos);
@@ -750,7 +748,7 @@ function fixOrderAsPurpose(params, transaction) {
750
748
  project: { id: { $eq: transaction.project.id } },
751
749
  confirmationNumbers: [payPurposeConfirmationNumber],
752
750
  orderNumbers: [payPurposeOrderNumber]
753
- });
751
+ }, { customer: 1, orderNumber: 1, typeOf: 1 });
754
752
  order = orders.shift();
755
753
  if (order === undefined) {
756
754
  throw new factory.errors.NotFound('Order as purpose');
@@ -1,6 +1,3 @@
1
- /**
2
- * 予約サービス
3
- */
4
1
  import { MongoRepository as ReservationRepo } from '../../repo/reservation';
5
2
  import { MongoRepository as TaskRepo } from '../../repo/task';
6
3
  export declare function checkInRerservation(params: {
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // import * as factory from '../../factory';
2
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -10,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
10
11
  };
11
12
  Object.defineProperty(exports, "__esModule", { value: true });
12
13
  exports.checkInRerservation = void 0;
14
+ // import { confirmReservation } from './confirmReservation';
13
15
  const onReservationCheckedIn_1 = require("./potentialActions/onReservationCheckedIn");
14
16
  function checkInRerservation(params) {
15
17
  return (repos) => __awaiter(this, void 0, void 0, function* () {
@@ -17,6 +19,28 @@ function checkInRerservation(params) {
17
19
  // 発券処理(Array対応)
18
20
  let checkedInReservationIds;
19
21
  if (Array.isArray(params.object.ids) && params.object.ids.length > 0) {
22
+ // confirmReservationが間に合わない可能性を考慮する(2023-05-30~)
23
+ // const reserveTransactions = await repos.assetTransaction.search<factory.assetTransactionType.Reserve>({
24
+ // typeOf: factory.assetTransactionType.Reserve,
25
+ // object: {
26
+ // reservations: {
27
+ // id: { $in: params.object.ids }
28
+ // }
29
+ // }
30
+ // });
31
+ // await Promise.all(reserveTransactions.map(async (reserveTransaction) => {
32
+ // await confirmReservation([{
33
+ // project: reserveTransaction.project,
34
+ // typeOf: <factory.actionType.ReserveAction>factory.actionType.ReserveAction,
35
+ // // result: {},
36
+ // object: reservationPackage,
37
+ // agent: reserveTransaction.project,
38
+ // potentialActions: {
39
+ // moneyTransfer: moneyTransferActions
40
+ // },
41
+ // purpose: { typeOf: transaction.typeOf, id: transaction.id }
42
+ // }])(repos);
43
+ // }))
20
44
  yield repos.reservation.checkInIfNot({ id: { $in: params.object.ids }, now });
21
45
  checkedInReservationIds = params.object.ids;
22
46
  }
@@ -24,21 +24,30 @@ function confirmReservation(actionAttributesList) {
24
24
  let confirmedReservations = [];
25
25
  if (actionAttributesList.length > 0) {
26
26
  yield Promise.all(actionAttributesList.map((actionAttributes) => __awaiter(this, void 0, void 0, function* () {
27
- const reservation = actionAttributes.object;
27
+ var _a, _b;
28
+ const reservationPackage = actionAttributes.object;
28
29
  const action = yield repos.action.start(actionAttributes);
29
30
  try {
30
31
  const reserveTransactions = yield repos.assetTransaction.search({
31
32
  limit: 1,
32
33
  page: 1,
33
34
  typeOf: factory.assetTransactionType.Reserve,
34
- transactionNumber: { $eq: reservation.reservationNumber }
35
+ transactionNumber: { $eq: reservationPackage.reservationNumber }
35
36
  });
36
37
  const reserveTransaction = reserveTransactions.shift();
37
38
  if (reserveTransaction === undefined) {
38
39
  throw new factory.errors.NotFound(factory.assetTransactionType.Reserve);
39
40
  }
41
+ let underName;
42
+ // 予約取引に保管されたunderNameを使用する(2023-05-30~)
43
+ if (typeof ((_a = reserveTransaction.object.underName) === null || _a === void 0 ? void 0 : _a.typeOf) === 'string') {
44
+ underName = reserveTransaction.object.underName;
45
+ }
46
+ else if (typeof ((_b = reservationPackage.underName) === null || _b === void 0 ? void 0 : _b.typeOf) === 'string') {
47
+ underName = reservationPackage.underName;
48
+ }
40
49
  // ReservationPackageに対応(2022-12-22~)
41
- if (reservation.typeOf === factory.reservationType.ReservationPackage) {
50
+ if (reservationPackage.typeOf === factory.reservationType.ReservationPackage) {
42
51
  // Pendingの予約が存在しないバージョンに対応する(2023-05-29~)
43
52
  if (reserveTransaction.object.disablePendingReservations === true) {
44
53
  const reservationFor = reserveTransaction.object.reservationFor;
@@ -49,7 +58,7 @@ function confirmReservation(actionAttributesList) {
49
58
  yield repos.reservation.confirmByIdIfNotExist({
50
59
  reservation: subReservation,
51
60
  reservationFor,
52
- underName: reservation.underName
61
+ underName
53
62
  });
54
63
  })));
55
64
  }
@@ -57,15 +66,15 @@ function confirmReservation(actionAttributesList) {
57
66
  else {
58
67
  // 予約を確定状態に変更する
59
68
  yield repos.reservation.confirmByReservationNumber({
60
- reservationNumber: reservation.reservationNumber,
61
- previousReservationStatus: reservation.reservationStatus,
62
- underName: reservation.underName
69
+ reservationNumber: reservationPackage.reservationNumber,
70
+ previousReservationStatus: reservationPackage.reservationStatus,
71
+ underName
63
72
  });
64
73
  }
65
74
  }
66
75
  else {
67
76
  // 廃止(2023-01-18)
68
- throw new factory.errors.Forbidden(`${reservation.typeOf} not acceptable`);
77
+ throw new factory.errors.Forbidden(`${reservationPackage.typeOf} not acceptable`);
69
78
  // 予約を確定状態に変更する
70
79
  // await repos.reservation.confirm<factory.reservationType.EventReservation>({
71
80
  // id: reservation.id,
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.313.0-alpha.16",
12
+ "@chevre/factory": "4.313.0-alpha.17",
13
13
  "@cinerino/sdk": "3.157.0-alpha.3",
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.77"
120
+ "version": "21.2.0-alpha.78"
121
121
  }