@chevre/domain 20.1.0-alpha.15 → 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.
Files changed (31) hide show
  1. package/example/src/chevre/migrateSellerMakesOfferTransactionDuration.ts +71 -0
  2. package/lib/chevre/repo/transaction.d.ts +1 -3
  3. package/lib/chevre/repo/transaction.js +14 -6
  4. package/lib/chevre/service/account.d.ts +0 -4
  5. package/lib/chevre/service/account.js +24 -22
  6. package/lib/chevre/service/accountTransaction/deposit.d.ts +0 -2
  7. package/lib/chevre/service/accountTransaction/deposit.js +3 -3
  8. package/lib/chevre/service/accountTransaction/transfer.d.ts +0 -2
  9. package/lib/chevre/service/accountTransaction/transfer.js +3 -3
  10. package/lib/chevre/service/accountTransaction/withdraw.d.ts +0 -2
  11. package/lib/chevre/service/accountTransaction/withdraw.js +3 -3
  12. package/lib/chevre/service/transaction/orderProgramMembership.js +6 -5
  13. package/lib/chevre/service/transaction/placeOrderInProgress/factory.d.ts +1 -3
  14. package/lib/chevre/service/transaction/placeOrderInProgress/factory.js +19 -6
  15. package/lib/chevre/service/transaction/placeOrderInProgress.js +13 -1
  16. package/package.json +3 -3
  17. package/example/src/chevre/accountBlanceTest.ts +0 -24
  18. package/example/src/chevre/checkOffersAppliesToMovieTicket.ts +0 -56
  19. package/example/src/chevre/createSeats.ts +0 -59
  20. package/example/src/chevre/manageOwnedByOfOwnershipInfo.ts +0 -35
  21. package/example/src/chevre/migrateMovieTheaterOffersOnPOS.ts +0 -69
  22. package/example/src/chevre/migrateSellerMakesOffers.ts +0 -84
  23. package/example/src/chevre/migrateTTTSOldEventId.ts +0 -68
  24. package/example/src/chevre/publishConfirmationNumber.ts +0 -30
  25. package/example/src/chevre/publishServiceOutputIdentifier.ts +0 -28
  26. package/example/src/chevre/publishTransactionNumber.ts +0 -28
  27. package/example/src/chevre/renameTransaction.ts +0 -22
  28. package/lib/chevre/service/task/accountMoneyTransfer.d.ts +0 -3
  29. package/lib/chevre/service/task/accountMoneyTransfer.js +0 -31
  30. package/lib/chevre/service/task/cancelAccountMoneyTransfer.d.ts +0 -3
  31. package/lib/chevre/service/task/cancelAccountMoneyTransfer.js +0 -33
@@ -0,0 +1,71 @@
1
+ // tslint:disable:no-console
2
+ import * as mongoose from 'mongoose';
3
+
4
+ import { chevre } from '../../../lib/index';
5
+
6
+ // const project = { id: String(process.env.PROJECT_ID) };
7
+
8
+ const DEFAULT_TRANSACTION_DURATION = 900;
9
+
10
+ async function main() {
11
+ await mongoose.connect(<string>process.env.MONGOLAB_URI);
12
+
13
+ const sellerRepo = new chevre.repository.Seller(mongoose.connection);
14
+
15
+ const cursor = sellerRepo.getCursor(
16
+ {
17
+ // 'project.id': { $eq: project.id }
18
+ },
19
+ {
20
+ // _id: 1,
21
+ }
22
+ );
23
+ console.log('sellers found');
24
+
25
+ let i = 0;
26
+ let updateCount = 0;
27
+ await cursor.eachAsync(async (doc) => {
28
+ i += 1;
29
+ const seller: chevre.factory.seller.ISeller = doc.toObject();
30
+
31
+ const makesOffer = seller.makesOffer;
32
+
33
+ if (Array.isArray(makesOffer) && makesOffer.length > 0) {
34
+ const everyMakesHasTransactionDuration = makesOffer.every((offer) => {
35
+ const transactionDuration = offer.eligibleTransactionDuration?.maxValue;
36
+
37
+ return typeof transactionDuration === 'number';
38
+ });
39
+
40
+ if (everyMakesHasTransactionDuration) {
41
+ console.log(
42
+ 'already migrated...', seller.project.id, seller.id, makesOffer.length, i);
43
+ } else {
44
+ const eligibleTransactionDuration: chevre.factory.seller.IEligibleTransactionDuration = {
45
+ typeOf: 'QuantitativeValue',
46
+ unitCode: chevre.factory.unitCode.Sec,
47
+ // tslint:disable-next-line:no-magic-numbers
48
+ maxValue: (seller.project.id.slice(0, 6) === 'sskts-') ? 600 : DEFAULT_TRANSACTION_DURATION
49
+ };
50
+ console.log(
51
+ 'updating seller...', seller.project.id, seller.id, i);
52
+ await sellerRepo.save({
53
+ id: seller.id,
54
+ attributes: <any>{
55
+ 'makesOffer.$[].eligibleTransactionDuration': eligibleTransactionDuration
56
+ }
57
+ });
58
+ updateCount += 1;
59
+ console.log(
60
+ 'updated...', seller.project.id, seller.id, i);
61
+ }
62
+ }
63
+ });
64
+
65
+ console.log(i, 'sellers checked');
66
+ console.log(updateCount, 'sellers updated');
67
+ }
68
+
69
+ main()
70
+ .then()
71
+ .catch(console.error);
@@ -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());
@@ -4,7 +4,6 @@
4
4
  */
5
5
  import * as factory from '../factory';
6
6
  import { MongoRepository as AccountRepo } from '../repo/account';
7
- import { MongoRepository as AccountActionRepo } from '../repo/accountAction';
8
7
  import { MongoRepository as AccountTransactionRepo } from '../repo/accountTransaction';
9
8
  export declare type IOpenOperation<T> = (repos: {
10
9
  account: AccountRepo;
@@ -52,8 +51,6 @@ export declare function close(params: {
52
51
  */
53
52
  export declare function transferMoney(actionAttributes: factory.account.action.moneyTransfer.IAttributes): (repos: {
54
53
  account: AccountRepo;
55
- accountAction: AccountActionRepo;
56
- accountTransaction: AccountTransactionRepo;
57
54
  }) => Promise<void>;
58
55
  /**
59
56
  * 転送取消
@@ -66,6 +63,5 @@ export declare function cancelMoneyTransfer(params: {
66
63
  };
67
64
  }): (repos: {
68
65
  account: AccountRepo;
69
- accountAction: AccountActionRepo;
70
66
  accountTransaction: AccountTransactionRepo;
71
67
  }) => Promise<void>;
@@ -53,11 +53,13 @@ exports.close = close;
53
53
  */
54
54
  function transferMoney(actionAttributes) {
55
55
  return (repos) => __awaiter(this, void 0, void 0, function* () {
56
- let action = yield repos.accountAction.startByIdentifier(actionAttributes);
56
+ // 口座取引におけるAccountAction管理を廃止(2022-11-28~)
57
+ // let action = await repos.accountAction.startByIdentifier<factory.actionType.MoneyTransfer>(actionAttributes);
57
58
  // すでに完了していれば何もしない
58
- if (action.actionStatus === factory.actionStatusType.CompletedActionStatus) {
59
- return;
60
- }
59
+ // if (action.actionStatus === factory.actionStatusType.CompletedActionStatus) {
60
+ // return;
61
+ // }
62
+ const action = actionAttributes;
61
63
  let fromAccountNumber;
62
64
  let toAccountNumber;
63
65
  try {
@@ -80,18 +82,17 @@ function transferMoney(actionAttributes) {
80
82
  }
81
83
  catch (error) {
82
84
  // actionにエラー結果を追加
83
- try {
84
- const actionError = Object.assign(Object.assign({}, error), { message: error.message, name: error.name });
85
- yield repos.accountAction.giveUp(action.typeOf, action.id, actionError);
86
- }
87
- catch (__) {
88
- // 失敗したら仕方ない
89
- }
85
+ // try {
86
+ // const actionError = { ...error, message: error.message, name: error.name };
87
+ // await repos.accountAction.giveUp(action.typeOf, action.id, actionError);
88
+ // } catch (__) {
89
+ // // 失敗したら仕方ない
90
+ // }
90
91
  throw error;
91
92
  }
92
93
  // アクション完了
93
- const actionResult = {};
94
- action = yield repos.accountAction.complete(action.typeOf, action.id, actionResult);
94
+ // const actionResult: factory.account.action.moneyTransfer.IResult = {};
95
+ // action = await repos.accountAction.complete(action.typeOf, action.id, actionResult);
95
96
  });
96
97
  }
97
98
  exports.transferMoney = transferMoney;
@@ -132,16 +133,17 @@ function cancelMoneyTransfer(params) {
132
133
  : transaction.object.amount.value,
133
134
  transactionId: transaction.id
134
135
  });
136
+ // 口座取引におけるAccountAction管理を廃止(2022-11-28~)
135
137
  // アクション取得
136
- const actions = yield repos.accountAction.searchTransferActions({
137
- purpose: {
138
- typeOf: { $eq: transaction.typeOf },
139
- id: { $eq: transaction.id }
140
- }
141
- });
142
- yield Promise.all(actions.map((action) => __awaiter(this, void 0, void 0, function* () {
143
- yield repos.accountAction.cancel(action.typeOf, action.id);
144
- })));
138
+ // const actions = await repos.accountAction.searchTransferActions({
139
+ // purpose: {
140
+ // typeOf: { $eq: transaction.typeOf },
141
+ // id: { $eq: transaction.id }
142
+ // }
143
+ // });
144
+ // await Promise.all(actions.map(async (action) => {
145
+ // await repos.accountAction.cancel(action.typeOf, action.id);
146
+ // }));
145
147
  });
146
148
  }
147
149
  exports.cancelMoneyTransfer = cancelMoneyTransfer;
@@ -3,11 +3,9 @@
3
3
  */
4
4
  import * as factory from '../../factory';
5
5
  import { MongoRepository as AccountRepo } from '../../repo/account';
6
- import { MongoRepository as AccountActionRepo } from '../../repo/accountAction';
7
6
  import { MongoRepository as AccountTransactionRepo } from '../../repo/accountTransaction';
8
7
  export declare type IStartOperation<T> = (repos: {
9
8
  account: AccountRepo;
10
- accountAction: AccountActionRepo;
11
9
  accountTransaction: AccountTransactionRepo;
12
10
  }) => Promise<T>;
13
11
  /**
@@ -14,7 +14,6 @@ exports.start = void 0;
14
14
  * 入金取引サービス
15
15
  */
16
16
  const factory = require("../../factory");
17
- const factory_1 = require("./factory");
18
17
  /**
19
18
  * 取引開始
20
19
  */
@@ -64,9 +63,10 @@ function start(params) {
64
63
  accountNumber: params.object.toLocation.accountNumber,
65
64
  transaction: pendingTransaction
66
65
  });
66
+ // 口座取引におけるAccountAction管理を廃止(2022-11-28~)
67
67
  // アクション開始
68
- const moneyTransferActionAttributes = (0, factory_1.createMoneyTransferActionAttributes)({ transaction });
69
- yield repos.accountAction.startByIdentifier(moneyTransferActionAttributes);
68
+ // const moneyTransferActionAttributes = createMoneyTransferActionAttributes({ transaction });
69
+ // await repos.accountAction.startByIdentifier(moneyTransferActionAttributes);
70
70
  // 結果返却
71
71
  return transaction;
72
72
  });
@@ -3,11 +3,9 @@
3
3
  */
4
4
  import * as factory from '../../factory';
5
5
  import { MongoRepository as AccountRepo } from '../../repo/account';
6
- import { MongoRepository as AccountActionRepo } from '../../repo/accountAction';
7
6
  import { MongoRepository as AccountTransactionRepo } from '../../repo/accountTransaction';
8
7
  export declare type IStartOperation<T> = (repos: {
9
8
  account: AccountRepo;
10
- accountAction: AccountActionRepo;
11
9
  accountTransaction: AccountTransactionRepo;
12
10
  }) => Promise<T>;
13
11
  /**
@@ -14,7 +14,6 @@ exports.start = void 0;
14
14
  * 転送取引サービス
15
15
  */
16
16
  const factory = require("../../factory");
17
- const factory_1 = require("./factory");
18
17
  /**
19
18
  * 取引開始
20
19
  */
@@ -96,9 +95,10 @@ function start(params) {
96
95
  accountNumber: params.object.toLocation.accountNumber,
97
96
  transaction: pendingTransaction
98
97
  });
98
+ // 口座取引におけるAccountAction管理を廃止(2022-11-28~)
99
99
  // アクション開始
100
- const moneyTransferActionAttributes = (0, factory_1.createMoneyTransferActionAttributes)({ transaction });
101
- yield repos.accountAction.startByIdentifier(moneyTransferActionAttributes);
100
+ // const moneyTransferActionAttributes = createMoneyTransferActionAttributes({ transaction });
101
+ // await repos.accountAction.startByIdentifier(moneyTransferActionAttributes);
102
102
  // 結果返却
103
103
  return transaction;
104
104
  });
@@ -3,11 +3,9 @@
3
3
  */
4
4
  import * as factory from '../../factory';
5
5
  import { MongoRepository as AccountRepo } from '../../repo/account';
6
- import { MongoRepository as AccountActionRepo } from '../../repo/accountAction';
7
6
  import { MongoRepository as AccountTransactionRepo } from '../../repo/accountTransaction';
8
7
  export declare type IStartOperation<T> = (repos: {
9
8
  account: AccountRepo;
10
- accountAction: AccountActionRepo;
11
9
  accountTransaction: AccountTransactionRepo;
12
10
  }) => Promise<T>;
13
11
  /**
@@ -14,7 +14,6 @@ exports.start = void 0;
14
14
  * 出金取引サービス
15
15
  */
16
16
  const factory = require("../../factory");
17
- const factory_1 = require("./factory");
18
17
  /**
19
18
  * 取引開始
20
19
  */
@@ -75,9 +74,10 @@ function start(params) {
75
74
  transaction: pendingTransaction,
76
75
  force: forcibly
77
76
  });
77
+ // 口座取引におけるAccountAction管理を廃止(2022-11-28~)
78
78
  // アクション開始
79
- const moneyTransferActionAttributes = (0, factory_1.createMoneyTransferActionAttributes)({ transaction });
80
- yield repos.accountAction.startByIdentifier(moneyTransferActionAttributes);
79
+ // const moneyTransferActionAttributes = createMoneyTransferActionAttributes({ transaction });
80
+ // await repos.accountAction.startByIdentifier(moneyTransferActionAttributes);
81
81
  // 結果返却
82
82
  return transaction;
83
83
  });
@@ -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.15"
123
+ "version": "20.1.0-alpha.17"
124
124
  }
@@ -1,24 +0,0 @@
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);
9
-
10
- const accountRepo = new chevre.repository.Account(mongoose.connection);
11
-
12
- // 不要な所有権を削除
13
- const result = await accountRepo.authorizeAmount({
14
- accountNumber: '139151625010963',
15
- amount: 10,
16
- transaction: <any>{ id: 'test' },
17
- force: false
18
- });
19
- console.log('result:', result);
20
- }
21
-
22
- main()
23
- .then(console.log)
24
- .catch(console.error);
@@ -1,56 +0,0 @@
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
- // const project = { id: String(process.env.PROJECT_ID) };
8
-
9
- async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
11
-
12
- const offerRepo = new chevre.repository.Offer(mongoose.connection);
13
-
14
- const cursor = offerRepo.getCursor(
15
- {
16
- // 'project.id': { $eq: project.id }
17
- 'priceSpecification.appliesToMovieTicket': {
18
- $exists: true,
19
- $type: 'array'
20
- // $not: { $type: 'array' }
21
- }
22
- },
23
- {
24
- // _id: 1,
25
- // ownedFrom: 1,
26
- // typeOfGood: 1
27
- }
28
- );
29
- console.log('offers found');
30
-
31
- let i = 0;
32
- let isArrayCount = 0;
33
- let updateCount = 0;
34
- await cursor.eachAsync(async (doc) => {
35
- i += 1;
36
- const offer = <chevre.factory.unitPriceOffer.IUnitPriceOffer>doc.toObject();
37
- const applieToMovieTicket = offer.priceSpecification?.appliesToMovieTicket;
38
- if (Array.isArray(applieToMovieTicket)) {
39
- console.log('is Array', offer.project.id, offer.id, i);
40
- isArrayCount += 1;
41
- } else if (typeof (<any>applieToMovieTicket)?.typeOf === 'string') {
42
- console.log('is not array', offer.project.id, offer.id, i);
43
- updateCount += 1;
44
- } else {
45
- console.log('no applieToMovieTicket', offer.project.id, offer.id, i);
46
- }
47
- });
48
-
49
- console.log(i, 'offers checked');
50
- console.log(isArrayCount, 'isArrayCount');
51
- console.log(updateCount, 'offers updated');
52
- }
53
-
54
- main()
55
- .then()
56
- .catch(console.error);
@@ -1,59 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as fs from 'fs';
3
-
4
- const columns = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W'];
5
- const rows = [
6
- { column: 'A', min: 4, max: 22 },
7
- { column: 'B', min: 4, max: 22 },
8
- { column: 'C', min: 3, max: 23 },
9
- { column: 'D', min: 3, max: 23 },
10
- { column: 'E', min: 3, max: 23 },
11
- { column: 'F', min: 2, max: 24 },
12
- { column: 'G', min: 2, max: 24 },
13
- { column: 'H', min: 1, max: 24 },
14
- { column: 'I', min: 1, max: 24 },
15
- { column: 'J', min: 1, max: 24 },
16
- { column: 'K', min: 1, max: 24 },
17
- { column: 'L', min: 1, max: 24 },
18
- { column: 'M', min: 1, max: 24 },
19
- { column: 'N', min: 1, max: 24 },
20
- { column: 'O', min: 1, max: 24 },
21
- { column: 'P', min: 1, max: 24 },
22
- { column: 'Q', min: 1, max: 24 },
23
- { column: 'R', min: 1, max: 24 },
24
- { column: 'S', min: 4, max: 21 },
25
- { column: 'T', min: 4, max: 21 },
26
- { column: 'U', min: 4, max: 21 },
27
- { column: 'V', min: 1, max: 24 },
28
- { column: 'W', min: 1, max: 24 }
29
- ];
30
-
31
- const seats: {
32
- branchCode: string;
33
- typeOf: 'Seat';
34
- }[] = [];
35
- columns.forEach((column) => {
36
- const row = rows.find((r) => r.column === column);
37
-
38
- if (row !== undefined) {
39
- const seatsByRow: {
40
- branchCode: string;
41
- typeOf: 'Seat';
42
- }[] = [];
43
- // tslint:disable-next-line:no-increment-decrement
44
- for (let i = row.min; i <= row.max; i++) {
45
- seatsByRow.push(
46
- {
47
- branchCode: `${column}-${i}`,
48
- typeOf: 'Seat'
49
- }
50
- );
51
- }
52
-
53
- seats.push(...seatsByRow);
54
- }
55
- });
56
-
57
- console.log(seats);
58
- // tslint:disable-next-line:non-literal-fs-path
59
- fs.writeFileSync(`${__dirname}/createSeatsResult.json`, JSON.stringify(seats, null, ' '));
@@ -1,35 +0,0 @@
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
- // const project = { id: String(process.env.PROJECT_ID) };
8
- const ownershipInfoId = '40576fe8-5e6a-4caa-9622-0944d6d9cf7b';
9
- const newOwnerId = '600ad33b-8ed1-4a8c-ad50-694bec02ff12';
10
-
11
- async function main() {
12
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
13
-
14
- const ownershipInfoRepo = new chevre.repository.OwnershipInfo(mongoose.connection);
15
- await ownershipInfoRepo.addOwnerIfNotExist({
16
- id: ownershipInfoId,
17
- ownedBy: {
18
- id: newOwnerId,
19
- typeOf: chevre.factory.personType.Person
20
- }
21
- });
22
- console.log('added');
23
-
24
- await ownershipInfoRepo.removeOwnerIfExist({
25
- id: ownershipInfoId,
26
- ownedBy: {
27
- id: newOwnerId
28
- }
29
- });
30
- console.log('removed');
31
- }
32
-
33
- main()
34
- .then()
35
- .catch(console.error);
@@ -1,69 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- // const project = { id: String(process.env.PROJECT_ID) };
7
-
8
- async function main() {
9
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
10
-
11
- const placeRepo = new chevre.repository.Place(mongoose.connection);
12
-
13
- const cursor = placeRepo.getCursor(
14
- {
15
- // 'project.id': { $eq: project.id },
16
- },
17
- {
18
- // _id: 1,
19
- }
20
- );
21
- console.log('places found');
22
-
23
- let i = 0;
24
- let updateCount = 0;
25
- await cursor.eachAsync(async (doc) => {
26
- i += 1;
27
- const movieTheater: chevre.factory.place.movieTheater.IPlace = doc.toObject();
28
- const availabilityEndsGraceTimeOnPOSValue = movieTheater.offers?.availabilityEndsGraceTimeOnPOS?.value;
29
- const availabilityStartsGraceTimeOnPOSValue = movieTheater.offers?.availabilityStartsGraceTimeOnPOS?.value;
30
-
31
- if (typeof availabilityEndsGraceTimeOnPOSValue === 'number' && typeof availabilityStartsGraceTimeOnPOSValue === 'number') {
32
- console.log(
33
- 'already migrated.',
34
- movieTheater.project?.id, movieTheater.branchCode, movieTheater.name.ja, i);
35
- } else {
36
- const availabilityStartsGraceTimeOnPOS: Pick<chevre.factory.quantitativeValue.IQuantitativeValue<chevre.factory.unitCode.Day>, 'typeOf' | 'value' | 'unitCode'> = {
37
- typeOf: 'QuantitativeValue',
38
- value: -93,
39
- unitCode: chevre.factory.unitCode.Day
40
- };
41
- const availabilityEndsGraceTimeOnPOS: Pick<chevre.factory.quantitativeValue.IQuantitativeValue<chevre.factory.unitCode.Sec>, 'typeOf' | 'value' | 'unitCode'> = {
42
- typeOf: 'QuantitativeValue',
43
- value: 2678400,
44
- unitCode: chevre.factory.unitCode.Sec
45
- };
46
- console.log(
47
- 'updating movieTheater...',
48
- movieTheater.project?.id, movieTheater.branchCode, movieTheater.name.ja, i);
49
- await placeRepo.saveMovieTheater(<any>{
50
- id: movieTheater.id,
51
- 'offers.availabilityEndsGraceTimeOnPOS': availabilityEndsGraceTimeOnPOS,
52
- 'offers.availabilityStartsGraceTimeOnPOS': availabilityStartsGraceTimeOnPOS
53
- });
54
-
55
- updateCount += 1;
56
- console.log(
57
- 'updated',
58
- movieTheater.project?.id, movieTheater.branchCode, movieTheater.name.ja, i);
59
-
60
- }
61
- });
62
-
63
- console.log(i, 'places checked');
64
- console.log(updateCount, 'places updated');
65
- }
66
-
67
- main()
68
- .then()
69
- .catch(console.error);
@@ -1,84 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as mongoose from 'mongoose';
3
-
4
- import { chevre } from '../../../lib/index';
5
-
6
- // const project = { id: String(process.env.PROJECT_ID) };
7
-
8
- const AVAILABLE_ROLE_NAMES = ['customer', 'pos'];
9
-
10
- async function main() {
11
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
12
-
13
- const sellerRepo = new chevre.repository.Seller(mongoose.connection);
14
- const memberRepo = new chevre.repository.Member(mongoose.connection);
15
-
16
- const cursor = sellerRepo.getCursor(
17
- {
18
- // 'project.id': { $eq: project.id },
19
- },
20
- {
21
- // _id: 1,
22
- }
23
- );
24
- console.log('sellers found');
25
-
26
- let i = 0;
27
- let updateCount = 0;
28
- await cursor.eachAsync(async (doc) => {
29
- i += 1;
30
- const seller: chevre.factory.seller.ISeller = doc.toObject();
31
-
32
- const makesOffer = seller.makesOffer;
33
-
34
- if (Array.isArray(makesOffer) && makesOffer.length > 0) {
35
- console.log(
36
- 'already exist...', seller.project.id, seller.id, makesOffer.length, i);
37
- } else {
38
- let existingApplicationMembers = await memberRepo.search({
39
- limit: 100,
40
- page: 1,
41
- project: { id: { $eq: seller.project.id } },
42
- member: {
43
- typeOf: { $eq: chevre.factory.creativeWorkType.WebApplication }
44
- }
45
- });
46
- // ロールで絞る(customer or pos)
47
- existingApplicationMembers = existingApplicationMembers
48
- .filter((m) => {
49
- return Array.isArray(m.member.hasRole) && m.member.hasRole.some((r) => AVAILABLE_ROLE_NAMES.includes(r.roleName));
50
- });
51
- console.log(
52
- existingApplicationMembers.length,
53
- 'existingApplicationMembers found.',
54
- seller.project.id,
55
- existingApplicationMembers.map((m) => m.member.name)
56
- .join(',')
57
- );
58
- const newMakesOffer: chevre.factory.seller.IMakesOffer[] = existingApplicationMembers.map((a) => {
59
- return {
60
- typeOf: chevre.factory.offerType.Offer,
61
- availableAtOrFrom: [{ id: a.member.id }]
62
- };
63
- });
64
- console.log(
65
- 'updating seller...', seller.project.id, seller.id, newMakesOffer.length, i);
66
- await sellerRepo.save({
67
- id: seller.id,
68
- attributes: <any>{
69
- makesOffer: newMakesOffer
70
- }
71
- });
72
- updateCount += 1;
73
- console.log(
74
- 'updated...', seller.project.id, seller.id, newMakesOffer.length, i);
75
- }
76
- });
77
-
78
- console.log(i, 'sellers checked');
79
- console.log(updateCount, 'sellers updated');
80
- }
81
-
82
- main()
83
- .then()
84
- .catch(console.error);
@@ -1,68 +0,0 @@
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
- // const project = { id: String(process.env.PROJECT_ID) };
8
-
9
- async function main() {
10
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
11
-
12
- const eventRepo = new chevre.repository.Event(mongoose.connection);
13
-
14
- const cursor = eventRepo.getCursor(
15
- {
16
- 'project.id': { $eq: '' },
17
- typeOf: { $eq: chevre.factory.eventType.ScreeningEvent },
18
- startDate: {
19
- $gte: moment()
20
- .add(-1, 'month')
21
- .toDate()
22
- }
23
- // _id: { $eq: 'al6afd7np' }
24
- },
25
- {
26
- // _id: 1,
27
- }
28
- );
29
- console.log('events found');
30
-
31
- let i = 0;
32
- let updateCount = 0;
33
- await cursor.eachAsync(async (doc) => {
34
- i += 1;
35
- const event: chevre.factory.event.screeningEvent.IEvent = doc.toObject();
36
-
37
- const oldEventId = event.additionalProperty?.find((p) => p.name === 'oldEventId')?.value;
38
-
39
- if (typeof oldEventId === 'string' && event.id === oldEventId) {
40
- console.log(
41
- 'already exist...', event.project.id, event.id, event.startDate, oldEventId, i);
42
- } else {
43
- const newAdditionalProperty: chevre.factory.propertyValue.IPropertyValue<string>[] = [
44
- ...(Array.isArray(event.additionalProperty)) ? event.additionalProperty : [],
45
- { name: 'oldEventId', value: String(event.id) }
46
- ];
47
- console.log(
48
- 'updating event...', event.project.id, event.id, event.startDate, oldEventId, newAdditionalProperty, i);
49
- await eventRepo.updatePartiallyById({
50
- id: event.id,
51
- attributes: <any>{
52
- typeOf: event.typeOf,
53
- additionalProperty: newAdditionalProperty
54
- }
55
- });
56
- updateCount += 1;
57
- console.log(
58
- 'updated', event.project.id, event.id, event.startDate, oldEventId, i);
59
- }
60
- });
61
-
62
- console.log(i, 'events checked');
63
- console.log(updateCount, 'events updated');
64
- }
65
-
66
- main()
67
- .then()
68
- .catch(console.error);
@@ -1,30 +0,0 @@
1
- // tslint:disable:no-console
2
- import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
- import * as redis from 'redis';
5
-
6
- import { chevre } from '../../../lib/index';
7
-
8
- async function main() {
9
- const client = redis.createClient({
10
- host: process.env.REDIS_HOST,
11
- port: Number(process.env.REDIS_PORT),
12
- password: process.env.REDIS_KEY
13
- });
14
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
15
-
16
- const confirmationNumberRepo = new chevre.repository.ConfirmationNumber(client);
17
-
18
- const confirmationNumber = await confirmationNumberRepo.publish({
19
- orderDate: moment()
20
- // .add(-1, 'month')
21
- .toDate()
22
- });
23
- console.log(confirmationNumber);
24
- }
25
-
26
- main()
27
- .then(() => {
28
- console.log('success!');
29
- })
30
- .catch(console.error);
@@ -1,28 +0,0 @@
1
- // tslint:disable:no-console
2
- // import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
- import * as redis from 'redis';
5
-
6
- import { chevre } from '../../../lib/index';
7
-
8
- async function main() {
9
- const client = redis.createClient({
10
- host: process.env.REDIS_HOST,
11
- port: Number(process.env.REDIS_PORT),
12
- password: process.env.REDIS_KEY
13
- });
14
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
15
-
16
- const serviceOutputIdentifierRepo = new chevre.repository.ServiceOutputIdentifier(client);
17
-
18
- const identifier = await serviceOutputIdentifierRepo.publishByTimestamp({
19
- startDate: new Date()
20
- });
21
- console.log(identifier);
22
- }
23
-
24
- main()
25
- .then(() => {
26
- console.log('success!');
27
- })
28
- .catch(console.error);
@@ -1,28 +0,0 @@
1
- // tslint:disable:no-console
2
- // import * as moment from 'moment';
3
- import * as mongoose from 'mongoose';
4
- import * as redis from 'redis';
5
-
6
- import { chevre } from '../../../lib/index';
7
-
8
- async function main() {
9
- const client = redis.createClient({
10
- host: process.env.REDIS_HOST,
11
- port: Number(process.env.REDIS_PORT),
12
- password: process.env.REDIS_KEY
13
- });
14
- await mongoose.connect(<string>process.env.MONGOLAB_URI);
15
-
16
- const transactionNumberRepo = new chevre.repository.TransactionNumber(client);
17
-
18
- const reservationNumber = await transactionNumberRepo.publishByTimestamp({
19
- startDate: new Date()
20
- });
21
- console.log(reservationNumber);
22
- }
23
-
24
- main()
25
- .then(() => {
26
- console.log('success!');
27
- })
28
- .catch(console.error);
@@ -1,22 +0,0 @@
1
- // tslint:disable:no-console
2
- // import * as redis from 'redis';
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);
9
-
10
- // Access the underlying database object provided by the MongoDB driver.
11
- const db = mongoose.connection.db;
12
-
13
- // Rename the `test` collection to `foobar`
14
- const result = await db.collection('transactions')
15
- .rename('assetTransactions', { dropTarget: true });
16
-
17
- console.log(result);
18
- }
19
-
20
- main()
21
- .then(console.log)
22
- .catch(console.error);
@@ -1,3 +0,0 @@
1
- import * as factory from '../../factory';
2
- import { IOperation } from '../task';
3
- export declare function call(data: factory.task.accountMoneyTransfer.IData): IOperation<void>;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.call = void 0;
13
- const account_1 = require("../../repo/account");
14
- const accountAction_1 = require("../../repo/accountAction");
15
- const accountTransaction_1 = require("../../repo/accountTransaction");
16
- const AccountService = require("../account");
17
- // tslint:disable-next-line:no-single-line-block-comment
18
- /* istanbul ignore next */
19
- function call(data) {
20
- return (settings) => __awaiter(this, void 0, void 0, function* () {
21
- const accountRepo = new account_1.MongoRepository(settings.connection);
22
- const accountActionRepo = new accountAction_1.MongoRepository(settings.connection);
23
- const accountTransactionRepo = new accountTransaction_1.MongoRepository(settings.connection);
24
- yield AccountService.transferMoney(data.actionAttributes)({
25
- account: accountRepo,
26
- accountAction: accountActionRepo,
27
- accountTransaction: accountTransactionRepo
28
- });
29
- });
30
- }
31
- exports.call = call;
@@ -1,3 +0,0 @@
1
- import * as factory from '../../factory';
2
- import { IOperation } from '../task';
3
- export declare function call(data: factory.task.cancelAccountMoneyTransfer.IData): IOperation<void>;
@@ -1,33 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.call = void 0;
13
- const account_1 = require("../../repo/account");
14
- const accountAction_1 = require("../../repo/accountAction");
15
- const accountTransaction_1 = require("../../repo/accountTransaction");
16
- const AccountService = require("../account");
17
- // tslint:disable-next-line:no-single-line-block-comment
18
- /* istanbul ignore next */
19
- function call(data) {
20
- return (settings) => __awaiter(this, void 0, void 0, function* () {
21
- const accountRepo = new account_1.MongoRepository(settings.connection);
22
- const actionRepo = new accountAction_1.MongoRepository(settings.connection);
23
- const transactionRepo = new accountTransaction_1.MongoRepository(settings.connection);
24
- yield AccountService.cancelMoneyTransfer({
25
- transaction: data.transaction
26
- })({
27
- account: accountRepo,
28
- accountAction: actionRepo,
29
- accountTransaction: transactionRepo
30
- });
31
- });
32
- }
33
- exports.call = call;