@chevre/domain 21.35.0-alpha.25 → 21.35.0-alpha.26

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.
@@ -0,0 +1,84 @@
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 actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
11
+ const cursor = actionRepo.getCursor(
12
+ {
13
+ // _id: { $eq: '66697991037c9d7243208261' },
14
+ typeOf: { $eq: chevre.factory.actionType.AuthorizeAction },
15
+ // actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
16
+ // startDate: {
17
+ // $lte: moment()
18
+ // // tslint:disable-next-line:no-magic-numbers
19
+ // .add(-180, 'days'),
20
+ // $gte: moment()
21
+ // // tslint:disable-next-line:no-magic-numbers
22
+ // .add(-180, 'days')
23
+ // },
24
+ 'object.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.offer.eventService.ObjectType.SeatReservation },
25
+ 'instrument.typeOf': { $exists: true, $eq: 'COAReserveTransaction' }
26
+ },
27
+ {
28
+ __id: 1, startDate: 1, project: 1, typeOf: 1, actionStatus: 1, instrument: 1, object: 1
29
+ }
30
+ );
31
+ console.log('actions found');
32
+
33
+ let i = 0;
34
+ let updateCount = 0;
35
+ const saveResultCount = 0;
36
+ // tslint:disable-next-line:max-func-body-length
37
+ await cursor.eachAsync(async (doc) => {
38
+ i += 1;
39
+ const authorizeAction = <Pick<
40
+ chevre.factory.action.authorize.offer.eventService.IAction<chevre.factory.service.webAPI.Identifier>,
41
+ 'id' | 'startDate' | 'project' | 'typeOf' | 'actionStatus' | 'instrument' | 'object'
42
+ >>doc.toObject();
43
+
44
+ let migrated = false;
45
+ if (authorizeAction.instrument.typeOf === chevre.factory.assetTransactionType.Reserve) {
46
+ migrated = true;
47
+ } else {
48
+ const acceptedOffers = (<any>authorizeAction.object).acceptedOffer;
49
+ if (acceptedOffers === undefined) {
50
+ migrated = true;
51
+ }
52
+ }
53
+
54
+ if (migrated) {
55
+ console.log(
56
+ 'already migrated.',
57
+ authorizeAction.project.id, authorizeAction.id, authorizeAction.actionStatus, authorizeAction.startDate,
58
+ i, updateCount, saveResultCount);
59
+
60
+ } else {
61
+ // optimize action
62
+ let unsetResult: any;
63
+ unsetResult = await actionRepo.unsetUnnecessaryFields({
64
+ filter: { _id: { $eq: authorizeAction.id } },
65
+ $unset: {
66
+ 'object.acceptedOffer': 1
67
+ }
68
+ });
69
+ updateCount += 1;
70
+ console.log(
71
+ 'result unset. unsetResult:', unsetResult,
72
+ authorizeAction.project.id, authorizeAction.id, authorizeAction.actionStatus, authorizeAction.startDate, i,
73
+ updateCount, saveResultCount);
74
+ }
75
+ });
76
+
77
+ console.log(i, 'actions checked');
78
+ console.log(updateCount, 'actions updated');
79
+ console.log(saveResultCount, 'result saved');
80
+ }
81
+
82
+ main()
83
+ .then()
84
+ .catch(console.error);
@@ -0,0 +1,84 @@
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 actionRepo = await chevre.repository.Action.createInstance(mongoose.connection);
11
+ const cursor = actionRepo.getCursor(
12
+ {
13
+ // _id: { $eq: '666bf2f1903cf9f62b41ca6e' },
14
+ typeOf: { $eq: chevre.factory.actionType.AuthorizeAction },
15
+ // actionStatus: { $eq: chevre.factory.actionStatusType.CompletedActionStatus },
16
+ // startDate: {
17
+ // $lte: moment()
18
+ // // tslint:disable-next-line:no-magic-numbers
19
+ // .add(-180, 'days'),
20
+ // $gte: moment()
21
+ // // tslint:disable-next-line:no-magic-numbers
22
+ // .add(-180, 'days')
23
+ // },
24
+ 'object.typeOf': { $exists: true, $eq: chevre.factory.action.authorize.offer.eventService.ObjectType.SeatReservation },
25
+ 'instrument.typeOf': { $exists: true, $eq: chevre.factory.assetTransactionType.Reserve }
26
+ },
27
+ {
28
+ __id: 1, startDate: 1, project: 1, typeOf: 1, actionStatus: 1, instrument: 1, object: 1
29
+ }
30
+ );
31
+ console.log('actions found');
32
+
33
+ let i = 0;
34
+ let updateCount = 0;
35
+ const saveResultCount = 0;
36
+ // tslint:disable-next-line:max-func-body-length
37
+ await cursor.eachAsync(async (doc) => {
38
+ i += 1;
39
+ const authorizeAction = <Pick<
40
+ chevre.factory.action.authorize.offer.eventService.IAction<chevre.factory.service.webAPI.Identifier>,
41
+ 'id' | 'startDate' | 'project' | 'typeOf' | 'actionStatus' | 'instrument' | 'object'
42
+ >>doc.toObject();
43
+
44
+ let migrated = false;
45
+ if (authorizeAction.instrument.typeOf === 'COAReserveTransaction') {
46
+ migrated = true;
47
+ } else {
48
+ const pendingTransaction = authorizeAction.object.pendingTransaction;
49
+ if (pendingTransaction === undefined) {
50
+ migrated = true;
51
+ }
52
+ }
53
+
54
+ if (migrated) {
55
+ console.log(
56
+ 'already migrated.',
57
+ authorizeAction.project.id, authorizeAction.id, authorizeAction.actionStatus, authorizeAction.startDate,
58
+ i, updateCount, saveResultCount);
59
+
60
+ } else {
61
+ // optimize action
62
+ let unsetResult: any;
63
+ unsetResult = await actionRepo.unsetUnnecessaryFields({
64
+ filter: { _id: { $eq: authorizeAction.id } },
65
+ $unset: {
66
+ 'object.pendingTransaction': 1
67
+ }
68
+ });
69
+ updateCount += 1;
70
+ console.log(
71
+ 'result unset. unsetResult:', unsetResult,
72
+ authorizeAction.project.id, authorizeAction.id, authorizeAction.actionStatus, authorizeAction.startDate, i,
73
+ updateCount, saveResultCount);
74
+ }
75
+ });
76
+
77
+ console.log(i, 'actions checked');
78
+ console.log(updateCount, 'actions updated');
79
+ console.log(saveResultCount, 'result saved');
80
+ }
81
+
82
+ main()
83
+ .then()
84
+ .catch(console.error);
@@ -26,7 +26,7 @@ export declare function creatPayTransactionStartParams(params: {
26
26
  }): factory.assetTransaction.pay.IStartParamsWithoutDetail;
27
27
  export declare function createMovieTicket(params: factory.action.trade.pay.IMovieTicket): factory.action.trade.pay.IMovieTicket;
28
28
  export declare function createAuthorizeResult(params: {
29
- object: factory.action.authorize.paymentMethod.any.IObject;
29
+ object: factory.action.authorize.paymentMethod.any.IObjectIncludingPaymentMethodDetails;
30
30
  payTransaction: factory.assetTransaction.pay.ITransaction;
31
31
  }): factory.action.authorize.paymentMethod.any.IResultAsInvoice[];
32
32
  /**
@@ -8,17 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
9
  });
10
10
  };
11
- var __rest = (this && this.__rest) || function (s, e) {
12
- var t = {};
13
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
14
- t[p] = s[p];
15
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
16
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
17
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
18
- t[p[i]] = s[p[i]];
19
- }
20
- return t;
21
- };
22
11
  Object.defineProperty(exports, "__esModule", { value: true });
23
12
  exports.publishPaymentUrl = exports.processVoidPayTransaction = exports.person2username = exports.voidPayTransaction = exports.invalidatePaymentUrl = exports.findCheckAction = exports.findAuthorizeAction = exports.findAcceptAction = exports.authorize = exports.onPaymentStatusChanged = void 0;
24
13
  /**
@@ -307,8 +296,8 @@ exports.publishPaymentUrl = publishPaymentUrl;
307
296
  function minimizeObjectIncludingPaymentMethodDetails(authorizeObjectIncludingPaymentMethodDetails) {
308
297
  if (settings_1.USE_EXPERIMENTAL_FEATURE) {
309
298
  // experimental(2024-06-21~)
310
- const { creditCard, method, movieTickets } = authorizeObjectIncludingPaymentMethodDetails, authorizeObject = __rest(authorizeObjectIncludingPaymentMethodDetails, ["creditCard", "method", "movieTickets"]);
311
- return { authorizeObject };
299
+ const { accountId, paymentMethodId, typeOf } = authorizeObjectIncludingPaymentMethodDetails;
300
+ return { authorizeObject: { accountId, paymentMethodId, typeOf } };
312
301
  }
313
302
  else {
314
303
  return { authorizeObject: authorizeObjectIncludingPaymentMethodDetails };
@@ -435,7 +424,7 @@ function authorize(params) {
435
424
  throw error;
436
425
  }
437
426
  }
438
- const result = (0, factory_1.createAuthorizeResult)({ payTransaction, object: authorizeObject });
427
+ const result = (0, factory_1.createAuthorizeResult)({ payTransaction, object: authorizeObjectIncludingPaymentMethodDetails });
439
428
  yield repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: result });
440
429
  return { id: action.id };
441
430
  });
package/package.json CHANGED
@@ -10,7 +10,7 @@
10
10
  ],
11
11
  "dependencies": {
12
12
  "@aws-sdk/credential-providers": "3.433.0",
13
- "@chevre/factory": "4.375.0-alpha.17",
13
+ "@chevre/factory": "4.375.0-alpha.18",
14
14
  "@cinerino/sdk": "7.3.0-alpha.2",
15
15
  "@motionpicture/coa-service": "9.4.0",
16
16
  "@motionpicture/gmo-service": "5.3.0",
@@ -110,5 +110,5 @@
110
110
  "postversion": "git push origin --tags",
111
111
  "prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
112
112
  },
113
- "version": "21.35.0-alpha.25"
113
+ "version": "21.35.0-alpha.26"
114
114
  }