@chevre/domain 20.1.0-alpha.15 → 20.1.0-alpha.16
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.
- package/example/src/chevre/migrateSellerMakesOfferTransactionDuration.ts +71 -0
- package/lib/chevre/service/account.d.ts +0 -4
- package/lib/chevre/service/account.js +24 -22
- package/lib/chevre/service/accountTransaction/deposit.d.ts +0 -2
- package/lib/chevre/service/accountTransaction/deposit.js +3 -3
- package/lib/chevre/service/accountTransaction/transfer.d.ts +0 -2
- package/lib/chevre/service/accountTransaction/transfer.js +3 -3
- package/lib/chevre/service/accountTransaction/withdraw.d.ts +0 -2
- package/lib/chevre/service/accountTransaction/withdraw.js +3 -3
- package/package.json +1 -1
- package/example/src/chevre/accountBlanceTest.ts +0 -24
- package/example/src/chevre/checkOffersAppliesToMovieTicket.ts +0 -56
- package/example/src/chevre/createSeats.ts +0 -59
- package/example/src/chevre/manageOwnedByOfOwnershipInfo.ts +0 -35
- package/example/src/chevre/migrateMovieTheaterOffersOnPOS.ts +0 -69
- package/example/src/chevre/migrateSellerMakesOffers.ts +0 -84
- package/example/src/chevre/migrateTTTSOldEventId.ts +0 -68
- package/example/src/chevre/publishConfirmationNumber.ts +0 -30
- package/example/src/chevre/publishServiceOutputIdentifier.ts +0 -28
- package/example/src/chevre/publishTransactionNumber.ts +0 -28
- package/example/src/chevre/renameTransaction.ts +0 -22
- package/lib/chevre/service/task/accountMoneyTransfer.d.ts +0 -3
- package/lib/chevre/service/task/accountMoneyTransfer.js +0 -31
- package/lib/chevre/service/task/cancelAccountMoneyTransfer.d.ts +0 -3
- 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);
|
|
@@ -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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
|
|
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 =
|
|
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 =
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
|
|
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 =
|
|
69
|
-
|
|
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 =
|
|
101
|
-
|
|
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 =
|
|
80
|
-
|
|
79
|
+
// const moneyTransferActionAttributes = createMoneyTransferActionAttributes({ transaction });
|
|
80
|
+
// await repos.accountAction.startByIdentifier(moneyTransferActionAttributes);
|
|
81
81
|
// 結果返却
|
|
82
82
|
return transaction;
|
|
83
83
|
});
|
package/package.json
CHANGED
|
@@ -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,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,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;
|