@chevre/domain 24.0.0-alpha.83 → 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 -25
- package/lib/chevre/repository.js +2 -57
- 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/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/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,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
|
-
}
|