@chevre/domain 20.1.0-alpha.16 → 20.1.0-alpha.17

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.
@@ -12,9 +12,7 @@ export declare class MongoRepository {
12
12
  /**
13
13
  * 取引を開始する
14
14
  */
15
- start<T extends factory.transactionType>(params: factory.transaction.IStartParams<T> & {
16
- expiresInSeconds?: number;
17
- }): Promise<factory.transaction.ITransaction<T>>;
15
+ start<T extends factory.transactionType>(params: factory.transaction.IStartParams<T>): Promise<factory.transaction.ITransaction<T>>;
18
16
  /**
19
17
  * 特定取引検索
20
18
  */
@@ -248,12 +248,20 @@ class MongoRepository {
248
248
  start(params) {
249
249
  return __awaiter(this, void 0, void 0, function* () {
250
250
  const startDate = new Date();
251
- let expires = params.expires;
252
- // expiresInSecondsの指定があれば優先して適用する(2022-11-25~)
253
- if (typeof params.expiresInSeconds === 'number' && params.expiresInSeconds > 0) {
254
- expires = moment(startDate)
255
- .add(params.expiresInSeconds, 'seconds')
256
- .toDate();
251
+ let expires;
252
+ if (params.typeOf === factory.transactionType.PlaceOrder) {
253
+ // expiresInSecondsの指定があれば優先して適用する(2022-11-25~)
254
+ if (typeof params.expiresInSeconds === 'number' && params.expiresInSeconds > 0) {
255
+ expires = moment(startDate)
256
+ .add(params.expiresInSeconds, 'seconds')
257
+ .toDate();
258
+ }
259
+ else {
260
+ throw new factory.errors.ArgumentNull('expiresInSeconds');
261
+ }
262
+ }
263
+ else {
264
+ expires = params.expires;
257
265
  }
258
266
  return this.transactionModel.create(Object.assign(Object.assign({}, params), { typeOf: params.typeOf, status: factory.transactionStatusType.InProgress, startDate, endDate: undefined, expires, tasksExportationStatus: factory.transactionTasksExportationStatus.Unexported }))
259
267
  .then((doc) => doc.toObject());
@@ -15,7 +15,6 @@ exports.orderProgramMembership = exports.ISS_PREFIX = void 0;
15
15
  */
16
16
  const GMO = require("@motionpicture/gmo-service");
17
17
  const createDebug = require("debug");
18
- const moment = require("moment-timezone");
19
18
  const accountTransactionIdentifier_1 = require("../../factory/accountTransactionIdentifier");
20
19
  const OfferService = require("../offer");
21
20
  const AnyPaymentService = require("../payment/any");
@@ -123,10 +122,12 @@ function createStartPlaceOrderInProgressParams(params) {
123
122
  };
124
123
  return {
125
124
  project: { typeOf: factory.organizationType.Project, id: params.project.id },
126
- expires: moment()
127
- // tslint:disable-next-line:no-magic-numbers
128
- .add(5, 'minutes')
129
- .toDate(),
125
+ // expiresInSeconds指定に変更(2022-11-29~)
126
+ // expires: moment()
127
+ // // tslint:disable-next-line:no-magic-numbers
128
+ // .add(5, 'minutes')
129
+ // .toDate(),
130
+ expiresInSeconds: 300,
130
131
  agent,
131
132
  seller: { id: params.seller.id },
132
133
  object: {
@@ -1,4 +1,2 @@
1
1
  import * as factory from '../../../factory';
2
- export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: factory.seller.ISeller, broker?: factory.order.IBroker, makesOfferFromClient?: factory.seller.IMakesOffer): factory.transaction.placeOrder.IStartParams & {
3
- expiresInSeconds?: number;
4
- };
2
+ export declare function createStartParams(params: factory.transaction.placeOrder.IStartParamsWithoutDetail, passport: factory.waiter.passport.IPassport | undefined, seller: factory.seller.ISeller, broker?: factory.order.IBroker): factory.transaction.placeOrder.IStartParams;
@@ -2,20 +2,33 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.createStartParams = void 0;
4
4
  const factory = require("../../../factory");
5
- function createStartParams(params, passport, seller, broker, makesOfferFromClient) {
6
- var _a, _b, _c, _d, _e;
5
+ function createStartParams(params, passport, seller, broker) {
6
+ var _a, _b, _c, _d;
7
7
  const transactionObject = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({ passportToken: (typeof ((_a = params.object.passport) === null || _a === void 0 ? void 0 : _a.token) === 'string') ? params.object.passport.token : undefined, authorizeActions: [] }, (passport !== undefined) ? { passport } : undefined), (params.object.clientUser !== undefined && params.object.clientUser !== null)
8
8
  ? { clientUser: params.object.clientUser }
9
9
  : undefined), (typeof ((_b = params.object) === null || _b === void 0 ? void 0 : _b.name) === 'string') ? { name: (_c = params.object) === null || _c === void 0 ? void 0 : _c.name } : undefined), (typeof (broker === null || broker === void 0 ? void 0 : broker.typeOf) === 'string') ? { broker: broker } : undefined), (typeof ((_d = params.object.customer) === null || _d === void 0 ? void 0 : _d.typeOf) === 'string') ? { customer: params.object.customer } : undefined);
10
10
  if (typeof seller.id !== 'string') {
11
11
  throw new factory.errors.NotFound('seller.id');
12
12
  }
13
- return Object.assign({ project: { typeOf: seller.project.typeOf, id: seller.project.id }, typeOf: factory.transactionType.PlaceOrder, agent: params.agent, seller: {
13
+ if (typeof params.expiresInSeconds !== 'number') {
14
+ throw new factory.errors.ArgumentNull('expiresInSeconds');
15
+ }
16
+ return {
17
+ project: { typeOf: seller.project.typeOf, id: seller.project.id },
18
+ typeOf: factory.transactionType.PlaceOrder,
19
+ agent: params.agent,
20
+ seller: {
14
21
  id: seller.id,
15
22
  name: seller.name,
16
23
  typeOf: seller.typeOf
17
- }, object: transactionObject, expires: params.expires }, (typeof ((_e = makesOfferFromClient === null || makesOfferFromClient === void 0 ? void 0 : makesOfferFromClient.eligibleTransactionDuration) === null || _e === void 0 ? void 0 : _e.maxValue) === 'number')
18
- ? { expiresInSeconds: makesOfferFromClient.eligibleTransactionDuration.maxValue }
19
- : undefined);
24
+ },
25
+ object: transactionObject,
26
+ // expires: params.expires,
27
+ expiresInSeconds: params.expiresInSeconds
28
+ // 販売者にexpires設定があれば適用
29
+ // ...(typeof makesOfferFromClient?.eligibleTransactionDuration?.maxValue === 'number')
30
+ // ? { expiresInSeconds: makesOfferFromClient.eligibleTransactionDuration.maxValue }
31
+ // : undefined
32
+ };
20
33
  }
21
34
  exports.createStartParams = createStartParams;
@@ -27,6 +27,7 @@ exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
27
27
  */
28
28
  function start(params) {
29
29
  return (repos) => __awaiter(this, void 0, void 0, function* () {
30
+ var _a;
30
31
  const seller = yield repos.seller.findById({ id: params.seller.id });
31
32
  let makesOfferFromClient;
32
33
  // 販売者オファー検証(2022-10-14~)
@@ -35,8 +36,19 @@ function start(params) {
35
36
  makesOfferFromClient = validateSellerResult.makesOfferFromClient;
36
37
  }
37
38
  const passport = yield (0, validation_2.validateWaiterPassport)(params);
39
+ // fix expiresInSeconds(2022-11-29~)
40
+ let expiresInSeconds;
41
+ if (typeof ((_a = makesOfferFromClient === null || makesOfferFromClient === void 0 ? void 0 : makesOfferFromClient.eligibleTransactionDuration) === null || _a === void 0 ? void 0 : _a.maxValue) === 'number') {
42
+ expiresInSeconds = makesOfferFromClient.eligibleTransactionDuration.maxValue;
43
+ }
44
+ else if (typeof params.expiresInSeconds === 'number') {
45
+ expiresInSeconds = params.expiresInSeconds;
46
+ }
47
+ else {
48
+ throw new factory.errors.ArgumentNull('expiresInSeconds');
49
+ }
38
50
  // 取引ファクトリーで新しい進行中取引オブジェクトを作成
39
- const startParams = (0, factory_1.createStartParams)(params, passport, seller, params.broker, makesOfferFromClient);
51
+ const startParams = (0, factory_1.createStartParams)(Object.assign(Object.assign({}, params), { expiresInSeconds }), passport, seller, params.broker);
40
52
  let transaction;
41
53
  try {
42
54
  transaction = yield repos.transaction.start(startParams);
package/package.json CHANGED
@@ -9,8 +9,8 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.278.0-alpha.4",
13
- "@cinerino/sdk": "3.133.0-alpha.2",
12
+ "@chevre/factory": "4.279.0-alpha.0",
13
+ "@cinerino/sdk": "3.133.0",
14
14
  "@motionpicture/coa-service": "9.2.0",
15
15
  "@motionpicture/gmo-service": "5.2.0",
16
16
  "@sendgrid/mail": "6.4.0",
@@ -120,5 +120,5 @@
120
120
  "postversion": "git push origin --tags",
121
121
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
122
122
  },
123
- "version": "20.1.0-alpha.16"
123
+ "version": "20.1.0-alpha.17"
124
124
  }