@chevre/domain 24.0.0-alpha.82 → 24.0.0-alpha.84
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/lib/chevre/repo/product.js +0 -3
- package/lib/chevre/repo/transaction.d.ts +4 -4
- package/lib/chevre/repository.d.ts +0 -30
- package/lib/chevre/repository.js +2 -68
- package/lib/chevre/service/assetTransaction/reserve/start/createSubReservations.js +1 -19
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre/requestedProgramMembershipUsed2permit.js +1 -31
- package/lib/chevre/service/payment/any/verifyTicketTokenAsNeeded.js +1 -5
- package/lib/chevre/service/task/deletePerson.js +0 -2
- package/lib/chevre/service/task/onResourceDeleted.js +0 -3
- package/lib/chevre/service/transaction/placeOrder/confirm/validation.js +4 -4
- package/lib/chevre/service.d.ts +0 -12
- package/lib/chevre/service.js +1 -35
- package/package.json +2 -2
- package/lib/chevre/factory/availableProductTypes.d.ts +0 -1
- package/lib/chevre/factory/availableProductTypes.js +0 -8
- package/lib/chevre/repo/account.d.ts +0 -129
- package/lib/chevre/repo/account.js +0 -391
- package/lib/chevre/repo/accountTransaction.d.ts +0 -65
- package/lib/chevre/repo/accountTransaction.js +0 -277
- package/lib/chevre/repo/comment.d.ts +0 -42
- package/lib/chevre/repo/comment.js +0 -121
- package/lib/chevre/repo/mongoose/schemas/account.d.ts +0 -11
- package/lib/chevre/repo/mongoose/schemas/account.js +0 -118
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.d.ts +0 -11
- package/lib/chevre/repo/mongoose/schemas/accountTransaction.js +0 -149
- package/lib/chevre/repo/mongoose/schemas/comments.d.ts +0 -11
- package/lib/chevre/repo/mongoose/schemas/comments.js +0 -103
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.d.ts +0 -11
- package/lib/chevre/repo/mongoose/schemas/serviceOutput.js +0 -144
- package/lib/chevre/repo/permit.d.ts +0 -42
- package/lib/chevre/repo/permit.js +0 -77
- package/lib/chevre/repo/serviceOutput.d.ts +0 -36
- package/lib/chevre/repo/serviceOutput.js +0 -167
- package/lib/chevre/repo/serviceOutputIdentifier.d.ts +0 -18
- package/lib/chevre/repo/serviceOutputIdentifier.js +0 -74
- package/lib/chevre/service/account.d.ts +0 -59
- package/lib/chevre/service/account.js +0 -108
- package/lib/chevre/service/accountTransaction/deposit.d.ts +0 -14
- package/lib/chevre/service/accountTransaction/deposit.js +0 -57
- package/lib/chevre/service/accountTransaction/factory.d.ts +0 -10
- package/lib/chevre/service/accountTransaction/factory.js +0 -101
- package/lib/chevre/service/accountTransaction/transfer.d.ts +0 -14
- package/lib/chevre/service/accountTransaction/transfer.js +0 -87
- package/lib/chevre/service/accountTransaction/withdraw.d.ts +0 -14
- package/lib/chevre/service/accountTransaction/withdraw.js +0 -68
- package/lib/chevre/service/accountTransaction.d.ts +0 -20
- package/lib/chevre/service/accountTransaction.js +0 -81
- package/lib/chevre/service/permit.d.ts +0 -45
- package/lib/chevre/service/permit.js +0 -158
- package/lib/chevre/service/product.d.ts +0 -9
- package/lib/chevre/service/product.js +0 -77
- package/lib/chevre/service/task/registerService.d.ts +0 -6
- package/lib/chevre/service/task/registerService.js +0 -22
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.start = start;
|
|
4
|
-
/**
|
|
5
|
-
* 転送取引サービス
|
|
6
|
-
*/
|
|
7
|
-
const factory_1 = require("../../factory");
|
|
8
|
-
/**
|
|
9
|
-
* 取引開始
|
|
10
|
-
*/
|
|
11
|
-
function start(params) {
|
|
12
|
-
return async (repos) => {
|
|
13
|
-
// 口座存在確認
|
|
14
|
-
const fromAccount = await repos.account.findByAccountNumber({
|
|
15
|
-
accountNumber: params.object.fromLocation.accountNumber
|
|
16
|
-
});
|
|
17
|
-
const toAccount = await repos.account.findByAccountNumber({
|
|
18
|
-
accountNumber: params.object.toLocation.accountNumber
|
|
19
|
-
});
|
|
20
|
-
/* istanbul ignore if */
|
|
21
|
-
if (fromAccount.accountType !== toAccount.accountType) {
|
|
22
|
-
throw new factory_1.factory.errors.Argument('accountType', 'FromLocation accountType must be the same as ToLocation');
|
|
23
|
-
}
|
|
24
|
-
/* istanbul ignore if */
|
|
25
|
-
if (fromAccount.accountNumber === toAccount.accountNumber) {
|
|
26
|
-
throw new factory_1.factory.errors.Argument('accountNumber', 'FromLocation accountNumber must be different from ToLocation');
|
|
27
|
-
}
|
|
28
|
-
// 残高検証(2022-10-28~)
|
|
29
|
-
if (fromAccount.availableBalance < params.object.amount.value) {
|
|
30
|
-
throw new factory_1.factory.errors.Argument('fromLocation', 'Insufficient balance');
|
|
31
|
-
}
|
|
32
|
-
// 取引ファクトリーで新しい進行中取引オブジェクトを作成
|
|
33
|
-
const startParams = {
|
|
34
|
-
project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
35
|
-
typeOf: factory_1.factory.account.transactionType.Transfer,
|
|
36
|
-
agent: params.agent,
|
|
37
|
-
recipient: params.recipient,
|
|
38
|
-
object: {
|
|
39
|
-
amount: params.object.amount,
|
|
40
|
-
fromLocation: {
|
|
41
|
-
typeOf: fromAccount.typeOf,
|
|
42
|
-
// 廃止(2023-02-16~)
|
|
43
|
-
// accountType: fromAccount.accountType,
|
|
44
|
-
accountNumber: fromAccount.accountNumber,
|
|
45
|
-
name: fromAccount.name
|
|
46
|
-
},
|
|
47
|
-
toLocation: {
|
|
48
|
-
typeOf: toAccount.typeOf,
|
|
49
|
-
// 廃止(2023-02-16~)
|
|
50
|
-
// accountType: toAccount.accountType,
|
|
51
|
-
accountNumber: toAccount.accountNumber,
|
|
52
|
-
name: toAccount.name
|
|
53
|
-
},
|
|
54
|
-
description: params.object.description
|
|
55
|
-
},
|
|
56
|
-
expires: params.expires,
|
|
57
|
-
// 必須化(2022-09-26~)
|
|
58
|
-
transactionNumber: params.transactionNumber,
|
|
59
|
-
...(typeof params.identifier === 'string' && params.identifier.length > 0) ? { identifier: params.identifier } : undefined
|
|
60
|
-
};
|
|
61
|
-
// 取引作成
|
|
62
|
-
// 取引識別子が指定されていれば、進行中取引のユニークネスを保証する
|
|
63
|
-
const transaction = await repos.accountTransaction.startByIdentifier(startParams);
|
|
64
|
-
const pendingTransaction = {
|
|
65
|
-
typeOf: transaction.typeOf,
|
|
66
|
-
id: transaction.id,
|
|
67
|
-
amount: (typeof params.object.amount === 'number')
|
|
68
|
-
? params.object.amount
|
|
69
|
-
: params.object.amount.value
|
|
70
|
-
};
|
|
71
|
-
// 残高確認
|
|
72
|
-
await repos.account.authorizeAmount({
|
|
73
|
-
accountNumber: params.object.fromLocation.accountNumber,
|
|
74
|
-
amount: (typeof params.object.amount === 'number')
|
|
75
|
-
? params.object.amount
|
|
76
|
-
: params.object.amount.value,
|
|
77
|
-
transaction: pendingTransaction
|
|
78
|
-
});
|
|
79
|
-
// 転送先口座に進行中取引を追加
|
|
80
|
-
await repos.account.startTransaction({
|
|
81
|
-
accountNumber: params.object.toLocation.accountNumber,
|
|
82
|
-
transaction: pendingTransaction
|
|
83
|
-
});
|
|
84
|
-
// 結果返却
|
|
85
|
-
return transaction;
|
|
86
|
-
};
|
|
87
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 出金取引サービス
|
|
3
|
-
*/
|
|
4
|
-
import { factory } from '../../factory';
|
|
5
|
-
import type { AccountRepo } from '../../repo/account';
|
|
6
|
-
import type { AccountTransactionRepo } from '../../repo/accountTransaction';
|
|
7
|
-
export type IStartOperation<T> = (repos: {
|
|
8
|
-
account: AccountRepo;
|
|
9
|
-
accountTransaction: AccountTransactionRepo;
|
|
10
|
-
}) => Promise<T>;
|
|
11
|
-
/**
|
|
12
|
-
* 取引開始
|
|
13
|
-
*/
|
|
14
|
-
export declare function start(params: factory.account.transaction.withdraw.IStartParamsWithoutDetail): IStartOperation<factory.account.transaction.withdraw.ITransaction>;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.start = start;
|
|
4
|
-
/**
|
|
5
|
-
* 出金取引サービス
|
|
6
|
-
*/
|
|
7
|
-
const factory_1 = require("../../factory");
|
|
8
|
-
/**
|
|
9
|
-
* 取引開始
|
|
10
|
-
*/
|
|
11
|
-
function start(params) {
|
|
12
|
-
return async (repos) => {
|
|
13
|
-
// 口座存在確認
|
|
14
|
-
const fromAccount = await repos.account.findByAccountNumber({
|
|
15
|
-
accountNumber: params.object.fromLocation.accountNumber
|
|
16
|
-
});
|
|
17
|
-
const forcibly = (params.object.force === true);
|
|
18
|
-
if (!forcibly) {
|
|
19
|
-
// 残高検証(2022-10-28~)
|
|
20
|
-
if (fromAccount.availableBalance < params.object.amount.value) {
|
|
21
|
-
throw new factory_1.factory.errors.Argument('fromLocation', 'Insufficient balance');
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
// 取引ファクトリーで新しい進行中取引オブジェクトを作成
|
|
25
|
-
const startParams = {
|
|
26
|
-
project: { typeOf: params.project.typeOf, id: params.project.id },
|
|
27
|
-
typeOf: factory_1.factory.account.transactionType.Withdraw,
|
|
28
|
-
agent: params.agent,
|
|
29
|
-
recipient: params.recipient,
|
|
30
|
-
object: {
|
|
31
|
-
amount: params.object.amount,
|
|
32
|
-
fromLocation: {
|
|
33
|
-
typeOf: fromAccount.typeOf,
|
|
34
|
-
// 廃止(2023-02-16~)
|
|
35
|
-
// accountType: fromAccount.accountType,
|
|
36
|
-
accountNumber: fromAccount.accountNumber,
|
|
37
|
-
name: fromAccount.name
|
|
38
|
-
},
|
|
39
|
-
description: params.object.description
|
|
40
|
-
},
|
|
41
|
-
expires: params.expires,
|
|
42
|
-
// 必須化(2022-09-26~)
|
|
43
|
-
transactionNumber: params.transactionNumber,
|
|
44
|
-
...(typeof params.identifier === 'string' && params.identifier.length > 0) ? { identifier: params.identifier } : undefined
|
|
45
|
-
};
|
|
46
|
-
// 取引作成
|
|
47
|
-
// 取引識別子が指定されていれば、進行中取引のユニークネスを保証する
|
|
48
|
-
const transaction = await repos.accountTransaction.startByIdentifier(startParams);
|
|
49
|
-
const pendingTransaction = {
|
|
50
|
-
typeOf: transaction.typeOf,
|
|
51
|
-
id: transaction.id,
|
|
52
|
-
amount: (typeof params.object.amount === 'number')
|
|
53
|
-
? params.object.amount
|
|
54
|
-
: params.object.amount.value
|
|
55
|
-
};
|
|
56
|
-
// 残高確保
|
|
57
|
-
await repos.account.authorizeAmount({
|
|
58
|
-
accountNumber: params.object.fromLocation.accountNumber,
|
|
59
|
-
amount: (typeof params.object.amount === 'number')
|
|
60
|
-
? params.object.amount
|
|
61
|
-
: params.object.amount.value,
|
|
62
|
-
transaction: pendingTransaction,
|
|
63
|
-
force: forcibly
|
|
64
|
-
});
|
|
65
|
-
// 結果返却
|
|
66
|
-
return transaction;
|
|
67
|
-
};
|
|
68
|
-
}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 口座取引サービス
|
|
3
|
-
*/
|
|
4
|
-
import type { AccountTransactionRepo } from '../repo/accountTransaction';
|
|
5
|
-
import { factory } from '../factory';
|
|
6
|
-
import * as DepositTransactionService from './accountTransaction/deposit';
|
|
7
|
-
import * as TransferTransactionService from './accountTransaction/transfer';
|
|
8
|
-
import * as WithdrawTransactionService from './accountTransaction/withdraw';
|
|
9
|
-
type IConfirmOperation<T> = (repos: {
|
|
10
|
-
accountTransaction: AccountTransactionRepo;
|
|
11
|
-
}) => Promise<T>;
|
|
12
|
-
/**
|
|
13
|
-
* 取引確定
|
|
14
|
-
*/
|
|
15
|
-
declare function confirm(params: {
|
|
16
|
-
id?: string;
|
|
17
|
-
transactionNumber?: string;
|
|
18
|
-
typeOf?: factory.account.transactionType;
|
|
19
|
-
}): IConfirmOperation<factory.account.transaction.ITransaction<factory.account.transactionType>>;
|
|
20
|
-
export { DepositTransactionService as deposit, TransferTransactionService as transfer, WithdrawTransactionService as withdraw, confirm };
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.withdraw = exports.transfer = exports.deposit = void 0;
|
|
37
|
-
exports.confirm = confirm;
|
|
38
|
-
const factory_1 = require("../factory");
|
|
39
|
-
const DepositTransactionService = __importStar(require("./accountTransaction/deposit"));
|
|
40
|
-
exports.deposit = DepositTransactionService;
|
|
41
|
-
const TransferTransactionService = __importStar(require("./accountTransaction/transfer"));
|
|
42
|
-
exports.transfer = TransferTransactionService;
|
|
43
|
-
const WithdrawTransactionService = __importStar(require("./accountTransaction/withdraw"));
|
|
44
|
-
exports.withdraw = WithdrawTransactionService;
|
|
45
|
-
const factory_2 = require("./accountTransaction/factory");
|
|
46
|
-
/**
|
|
47
|
-
* 取引確定
|
|
48
|
-
*/
|
|
49
|
-
function confirm(params) {
|
|
50
|
-
return async (repos) => {
|
|
51
|
-
let transaction;
|
|
52
|
-
// 取引存在確認
|
|
53
|
-
/* istanbul ignore else */
|
|
54
|
-
if (typeof params.id === 'string') {
|
|
55
|
-
transaction = await repos.accountTransaction.findById({ typeOf: params.typeOf, id: params.id });
|
|
56
|
-
}
|
|
57
|
-
else if (typeof params.transactionNumber === 'string') {
|
|
58
|
-
/* istanbul ignore next */
|
|
59
|
-
transaction = await repos.accountTransaction.findByTransactionNumber({
|
|
60
|
-
typeOf: params.typeOf,
|
|
61
|
-
transactionNumber: params.transactionNumber
|
|
62
|
-
});
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
/* istanbul ignore next */
|
|
66
|
-
throw new factory_1.factory.errors.ArgumentNull('Transaction ID or Transaction Number');
|
|
67
|
-
}
|
|
68
|
-
// 現金転送アクション属性作成
|
|
69
|
-
const moneyTransferActionAttributes = (0, factory_2.createMoneyTransferActionAttributes)({ transaction });
|
|
70
|
-
const potentialActions = {
|
|
71
|
-
moneyTransfer: moneyTransferActionAttributes
|
|
72
|
-
};
|
|
73
|
-
// 取引確定
|
|
74
|
-
return repos.accountTransaction.confirm({
|
|
75
|
-
typeOf: transaction.typeOf,
|
|
76
|
-
id: transaction.id,
|
|
77
|
-
// result: {},
|
|
78
|
-
potentialActions
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* 許可証サービス
|
|
3
|
-
*/
|
|
4
|
-
import { factory } from '../factory';
|
|
5
|
-
import type { AccountRepo } from '../repo/account';
|
|
6
|
-
import type { ServiceOutputRepo } from '../repo/serviceOutput';
|
|
7
|
-
/**
|
|
8
|
-
* 許可証発行
|
|
9
|
-
*/
|
|
10
|
-
export declare function issue(params: {
|
|
11
|
-
project: {
|
|
12
|
-
id: string;
|
|
13
|
-
};
|
|
14
|
-
issuedThrough: {
|
|
15
|
-
typeOf: factory.product.ProductType;
|
|
16
|
-
};
|
|
17
|
-
serviceOutputs: factory.permit.IPermit[];
|
|
18
|
-
}): (repos: {
|
|
19
|
-
account: AccountRepo;
|
|
20
|
-
serviceOutput: ServiceOutputRepo;
|
|
21
|
-
}) => Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
* 許可証有効化
|
|
24
|
-
*/
|
|
25
|
-
export declare function activate(params: {
|
|
26
|
-
typeOf: string;
|
|
27
|
-
identifier: string;
|
|
28
|
-
validFrom: Date;
|
|
29
|
-
validUntil?: Date;
|
|
30
|
-
}): (repos: {
|
|
31
|
-
serviceOutput: ServiceOutputRepo;
|
|
32
|
-
}) => Promise<factory.permit.IPermit>;
|
|
33
|
-
type IPermitWithAccountDetail = Omit<factory.permit.IPermit, 'paymentAccount'> & {
|
|
34
|
-
paymentAccount?: factory.permit.IPaymentAccountWithDetail;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* プロジェクト指定で、許可証を検索する(ペイメントカードプロダクトの場合、口座詳細込み)
|
|
38
|
-
*/
|
|
39
|
-
export declare function search(project: {
|
|
40
|
-
id: string;
|
|
41
|
-
}, params: factory.product.IServiceOutputSearchConditions, projection?: any): (repos: {
|
|
42
|
-
account: AccountRepo;
|
|
43
|
-
serviceOutput: ServiceOutputRepo;
|
|
44
|
-
}) => Promise<IPermitWithAccountDetail[]>;
|
|
45
|
-
export {};
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.issue = issue;
|
|
37
|
-
exports.activate = activate;
|
|
38
|
-
exports.search = search;
|
|
39
|
-
/**
|
|
40
|
-
* 許可証サービス
|
|
41
|
-
*/
|
|
42
|
-
const factory_1 = require("../factory");
|
|
43
|
-
const AccountService = __importStar(require("./account"));
|
|
44
|
-
/**
|
|
45
|
-
* 許可証発行
|
|
46
|
-
*/
|
|
47
|
-
function issue(params) {
|
|
48
|
-
return async (repos) => {
|
|
49
|
-
switch (params.issuedThrough.typeOf) {
|
|
50
|
-
case factory_1.factory.product.ProductType.PaymentCard: {
|
|
51
|
-
// 口座開設
|
|
52
|
-
const openAccountParams = params.serviceOutputs.map((serviceOutput) => {
|
|
53
|
-
const accountTypeOf = serviceOutput?.paymentAccount?.typeOf;
|
|
54
|
-
const accountNumber = serviceOutput?.paymentAccount?.accountNumber;
|
|
55
|
-
const serviceOutputName = serviceOutput?.name;
|
|
56
|
-
const accountType = serviceOutput?.amount?.currency;
|
|
57
|
-
const initialBalance = serviceOutput?.amount?.value;
|
|
58
|
-
if (typeof accountTypeOf !== 'string' || accountTypeOf.length === 0) {
|
|
59
|
-
throw new factory_1.factory.errors.Internal('serviceOutput.paymentAccount.typeOf undefined');
|
|
60
|
-
}
|
|
61
|
-
if (typeof accountNumber !== 'string' || accountNumber.length === 0) {
|
|
62
|
-
throw new factory_1.factory.errors.Internal('serviceOutput.paymentAccount.accountNumber undefined');
|
|
63
|
-
}
|
|
64
|
-
if (typeof accountType !== 'string' || accountType.length === 0) {
|
|
65
|
-
throw new factory_1.factory.errors.Internal('Account currency undefined');
|
|
66
|
-
}
|
|
67
|
-
return {
|
|
68
|
-
project: { id: params.project.id },
|
|
69
|
-
accountType: accountType,
|
|
70
|
-
accountNumber,
|
|
71
|
-
name: (typeof serviceOutputName === 'string') ? serviceOutputName : accountNumber,
|
|
72
|
-
typeOf: accountTypeOf,
|
|
73
|
-
...(typeof initialBalance === 'number') ? { initialBalance } : undefined
|
|
74
|
-
};
|
|
75
|
-
});
|
|
76
|
-
await AccountService.open(openAccountParams.map((bodyParams) => {
|
|
77
|
-
return {
|
|
78
|
-
project: { id: bodyParams.project.id },
|
|
79
|
-
typeOf: bodyParams.typeOf,
|
|
80
|
-
accountType: bodyParams.accountType,
|
|
81
|
-
accountNumber: bodyParams.accountNumber,
|
|
82
|
-
name: bodyParams.name,
|
|
83
|
-
initialBalance: (typeof bodyParams.initialBalance === 'number') ? Number(bodyParams.initialBalance) : 0
|
|
84
|
-
};
|
|
85
|
-
}))({
|
|
86
|
-
account: repos.account
|
|
87
|
-
});
|
|
88
|
-
break;
|
|
89
|
-
}
|
|
90
|
-
default:
|
|
91
|
-
// no op
|
|
92
|
-
}
|
|
93
|
-
// サービスアウトプット保管
|
|
94
|
-
await repos.serviceOutput.issue(params.serviceOutputs);
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
/**
|
|
98
|
-
* 許可証有効化
|
|
99
|
-
*/
|
|
100
|
-
function activate(params) {
|
|
101
|
-
return async (repos) => {
|
|
102
|
-
// Permitに有効期間を設定する
|
|
103
|
-
return repos.serviceOutput.activate(params);
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* プロジェクト指定で、許可証を検索する(ペイメントカードプロダクトの場合、口座詳細込み)
|
|
108
|
-
*/
|
|
109
|
-
function search(project, params, projection) {
|
|
110
|
-
return async (repos) => {
|
|
111
|
-
let permitsWithAccountDetail;
|
|
112
|
-
// アウトプット検索条件のプロジェクトは強制的に上書き
|
|
113
|
-
const searchConditions = {
|
|
114
|
-
...params,
|
|
115
|
-
project: { id: { $eq: project.id } }
|
|
116
|
-
};
|
|
117
|
-
const productType = params.issuedThrough?.typeOf?.$eq;
|
|
118
|
-
switch (productType) {
|
|
119
|
-
case factory_1.factory.product.ProductType.PaymentCard: {
|
|
120
|
-
const permits = await repos.serviceOutput.search(searchConditions, projection);
|
|
121
|
-
permitsWithAccountDetail = permits;
|
|
122
|
-
// 口座詳細取得
|
|
123
|
-
const accountNumbers = [];
|
|
124
|
-
permits.forEach((permit) => {
|
|
125
|
-
const accountNumber = permit.paymentAccount?.accountNumber;
|
|
126
|
-
if (typeof accountNumber === 'string') {
|
|
127
|
-
accountNumbers.push(accountNumber);
|
|
128
|
-
}
|
|
129
|
-
});
|
|
130
|
-
if (accountNumbers.length > 0) {
|
|
131
|
-
const accounts = await repos.account.search({
|
|
132
|
-
project: { id: { $eq: project.id } },
|
|
133
|
-
accountNumbers: accountNumbers
|
|
134
|
-
});
|
|
135
|
-
permitsWithAccountDetail = permits.map((permit) => {
|
|
136
|
-
const account = accounts.find((a) => a.accountNumber === permit.paymentAccount?.accountNumber);
|
|
137
|
-
const paymentAccount = (typeof account?.typeOf === 'string')
|
|
138
|
-
? {
|
|
139
|
-
accountNumber: account.accountNumber,
|
|
140
|
-
availableBalance: account.availableBalance,
|
|
141
|
-
balance: account.balance,
|
|
142
|
-
typeOf: account.typeOf
|
|
143
|
-
}
|
|
144
|
-
: undefined;
|
|
145
|
-
return {
|
|
146
|
-
...permit,
|
|
147
|
-
paymentAccount
|
|
148
|
-
};
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
default:
|
|
154
|
-
permitsWithAccountDetail = await repos.serviceOutput.search(searchConditions, projection);
|
|
155
|
-
}
|
|
156
|
-
return permitsWithAccountDetail;
|
|
157
|
-
};
|
|
158
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { factory } from '../factory';
|
|
2
|
-
import type { ActionRepo } from '../repo/action';
|
|
3
|
-
import type { ServiceOutputRepo } from '../repo/serviceOutput';
|
|
4
|
-
import type { TaskRepo } from '../repo/task';
|
|
5
|
-
export declare function registerService(params: factory.action.interact.register.service.IAttributes[]): (repos: {
|
|
6
|
-
action: ActionRepo;
|
|
7
|
-
serviceOutput: ServiceOutputRepo;
|
|
8
|
-
task: TaskRepo;
|
|
9
|
-
}) => Promise<void>;
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.registerService = registerService;
|
|
7
|
-
/**
|
|
8
|
-
* プロダクトサービス
|
|
9
|
-
*/
|
|
10
|
-
const moment_1 = __importDefault(require("moment"));
|
|
11
|
-
const permit_1 = require("./permit");
|
|
12
|
-
function registerService(params) {
|
|
13
|
-
return async (repos) => {
|
|
14
|
-
await Promise.all(params.map(async (actionAttributes) => {
|
|
15
|
-
let serviceOutput = actionAttributes.object;
|
|
16
|
-
const action = await repos.action.start(actionAttributes);
|
|
17
|
-
try {
|
|
18
|
-
// Permitに有効期間を設定する
|
|
19
|
-
serviceOutput = await (0, permit_1.activate)({
|
|
20
|
-
typeOf: serviceOutput.typeOf,
|
|
21
|
-
identifier: String(serviceOutput.identifier),
|
|
22
|
-
validFrom: (0, moment_1.default)(serviceOutput.validFrom)
|
|
23
|
-
.toDate(),
|
|
24
|
-
...(serviceOutput.validUntil !== undefined && serviceOutput.validUntil !== null)
|
|
25
|
-
? {
|
|
26
|
-
validUntil: (0, moment_1.default)(serviceOutput.validUntil)
|
|
27
|
-
.toDate()
|
|
28
|
-
}
|
|
29
|
-
: undefined
|
|
30
|
-
})({ serviceOutput: repos.serviceOutput });
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
try {
|
|
34
|
-
await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
35
|
-
}
|
|
36
|
-
catch (__) {
|
|
37
|
-
// 失敗したら仕方ない
|
|
38
|
-
}
|
|
39
|
-
throw error;
|
|
40
|
-
}
|
|
41
|
-
// アクション完了
|
|
42
|
-
const actionResult = {};
|
|
43
|
-
await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
44
|
-
await onRegistered(actionAttributes, serviceOutput)(repos);
|
|
45
|
-
}));
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* サービス登録後アクション
|
|
50
|
-
*/
|
|
51
|
-
function onRegistered(actionAttributes, __) {
|
|
52
|
-
return async (repos) => {
|
|
53
|
-
const potentialActions = actionAttributes.potentialActions;
|
|
54
|
-
// const now = new Date();
|
|
55
|
-
const taskAttributes = [];
|
|
56
|
-
/* istanbul ignore else */
|
|
57
|
-
if (potentialActions !== undefined) {
|
|
58
|
-
// discontinue(2026-04-18~)
|
|
59
|
-
// if (Array.isArray(potentialActions.moneyTransfer)) {
|
|
60
|
-
// taskAttributes.push(...potentialActions.moneyTransfer.map((a) => {
|
|
61
|
-
// return {
|
|
62
|
-
// project: a.project,
|
|
63
|
-
// name: factory.taskName.MoneyTransfer as factory.taskName.MoneyTransfer,
|
|
64
|
-
// status: factory.taskStatus.Ready,
|
|
65
|
-
// runsAt: now,
|
|
66
|
-
// remainingNumberOfTries: 10,
|
|
67
|
-
// numberOfTried: 0,
|
|
68
|
-
// executionResults: [],
|
|
69
|
-
// data: a
|
|
70
|
-
// };
|
|
71
|
-
// }));
|
|
72
|
-
// }
|
|
73
|
-
}
|
|
74
|
-
// タスク保管
|
|
75
|
-
await repos.task.saveMany(taskAttributes, { emitImmediately: true });
|
|
76
|
-
};
|
|
77
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.call = call;
|
|
4
|
-
const action_1 = require("../../repo/action");
|
|
5
|
-
const serviceOutput_1 = require("../../repo/serviceOutput");
|
|
6
|
-
const task_1 = require("../../repo/task");
|
|
7
|
-
const product_1 = require("../product");
|
|
8
|
-
/**
|
|
9
|
-
* タスク実行関数
|
|
10
|
-
*/
|
|
11
|
-
function call(data) {
|
|
12
|
-
return async ({ connection }) => {
|
|
13
|
-
const actionRepo = new action_1.ActionRepo(connection);
|
|
14
|
-
const serviceOutputRepo = new serviceOutput_1.ServiceOutputRepo(connection);
|
|
15
|
-
const taskRepo = new task_1.TaskRepo(connection);
|
|
16
|
-
await (0, product_1.registerService)(data)({
|
|
17
|
-
action: actionRepo,
|
|
18
|
-
serviceOutput: serviceOutputRepo,
|
|
19
|
-
task: taskRepo
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
}
|