@chevre/domain 21.2.0-alpha.50 → 21.2.0-alpha.51

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,44 @@
1
+ // tslint:disable:no-console
2
+ // import * as moment from 'moment';
3
+ import * as mongoose from 'mongoose';
4
+
5
+ import { chevre } from '../../../lib/index';
6
+
7
+ async function main() {
8
+ await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
9
+
10
+ const actionRepo = new chevre.repository.Action(mongoose.connection);
11
+
12
+ const actions = <chevre.factory.action.transfer.send.message.email.IAction[]>await actionRepo.search(
13
+ {
14
+ limit: 1000,
15
+ page: 1,
16
+ typeOf: { $eq: chevre.factory.actionType.SendAction },
17
+ object: {
18
+ typeOf: { $eq: chevre.factory.creativeWorkType.EmailMessage }
19
+ }
20
+ // startFrom: moment()
21
+ // .add(-20, 'days')
22
+ // .toDate(),
23
+ // startThrough: moment()
24
+ // .add(-19, 'days')
25
+ // .toDate(),
26
+ },
27
+ ['project', '_id', 'object', 'purpose'],
28
+ []
29
+ );
30
+ const maxLenght = Math.max(...actions.map((action) => {
31
+ return (Array.isArray(action.object)) ? action.object[0].text?.length : action.object.text?.length;
32
+ }));
33
+ actions.forEach((action) => {
34
+ const length = (Array.isArray(action.object)) ? action.object[0].text?.length : action.object.text?.length;
35
+ if (typeof length !== 'number') {
36
+ throw new Error(`${action.project.id},${action.id},${action.purpose?.typeOf},${action.purpose?.orderNumber},${action.object.text?.length}`);
37
+ }
38
+ });
39
+ console.log('maxLenght:', maxLenght);
40
+ }
41
+
42
+ main()
43
+ .then(console.log)
44
+ .catch(console.error);
@@ -18,7 +18,14 @@ const factory = require("../../factory");
18
18
  */
19
19
  function deleteOrder(params) {
20
20
  return (repos) => __awaiter(this, void 0, void 0, function* () {
21
- const order = params.object;
21
+ const orders = yield repos.order.search({
22
+ orderNumbers: [params.object.orderNumber]
23
+ });
24
+ const order = orders.shift();
25
+ if (order === undefined) {
26
+ // すでに削除済
27
+ return;
28
+ }
22
29
  // 注文アイテムの予約を削除
23
30
  yield deleteReservationsByOrder(order)(repos);
24
31
  // 所有権削除
@@ -119,22 +119,26 @@ exports.exportTasks = exportTasks;
119
119
  * 取引に関わるリソースを削除する
120
120
  * 冪等性を確保すること
121
121
  */
122
+ // tslint:disable-next-line:max-func-body-length
122
123
  function deleteTransaction(params) {
123
124
  return (repos) => __awaiter(this, void 0, void 0, function* () {
124
- var _a;
125
- const transaction = params.object;
125
+ const transactions = yield repos.transaction.search({
126
+ ids: [params.object.id],
127
+ typeOf: params.object.typeOf,
128
+ inclusion: [],
129
+ exclusion: []
130
+ });
131
+ const transaction = transactions.shift();
132
+ if (transaction === undefined) {
133
+ // すでに削除済
134
+ return;
135
+ }
126
136
  // DeleteTransactionアクションを作成(logとしての意味合いも含めて)
127
137
  const actionAttributes = {
128
138
  typeOf: factory.actionType.DeleteAction,
129
139
  project: transaction.project,
130
140
  object: transaction,
131
- agent: {
132
- typeOf: transaction.seller.typeOf,
133
- id: transaction.seller.id,
134
- name: (typeof transaction.seller.name === 'string')
135
- ? transaction.seller.name
136
- : String((_a = transaction.seller.name) === null || _a === void 0 ? void 0 : _a.ja)
137
- }
141
+ agent: transaction.project
138
142
  };
139
143
  let deleteReservationsResult;
140
144
  let deleteReserveTransactionResult;
package/package.json CHANGED
@@ -9,7 +9,7 @@
9
9
  }
10
10
  ],
11
11
  "dependencies": {
12
- "@chevre/factory": "4.313.0-alpha.0",
12
+ "@chevre/factory": "4.313.0-alpha.1",
13
13
  "@cinerino/sdk": "3.156.0",
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.50"
120
+ "version": "21.2.0-alpha.51"
121
121
  }