@chevre/domain 25.0.0-alpha.9 → 25.0.0
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/message.d.ts +7 -15
- package/lib/chevre/repo/message.js +37 -74
- package/lib/chevre/repo/mongoose/schemas/message.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/order.js +2 -110
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +7 -9
- package/lib/chevre/repo/mongoose/schemas/setting.js +1 -1
- package/lib/chevre/repo/mongoose/schemas/transaction.js +51 -50
- package/lib/chevre/repo/order.d.ts +1 -7
- package/lib/chevre/repo/order.js +56 -26
- package/lib/chevre/repo/orderInTransaction.d.ts +41 -22
- package/lib/chevre/repo/orderInTransaction.js +108 -79
- package/lib/chevre/repo/passport.d.ts +5 -2
- package/lib/chevre/repo/setting/waiter.d.ts +17 -0
- package/lib/chevre/repo/setting/waiter.js +39 -0
- package/lib/chevre/repo/setting.d.ts +12 -11
- package/lib/chevre/repo/setting.js +6 -18
- package/lib/chevre/repo/task.d.ts +1 -1
- package/lib/chevre/repo/transaction/placeOrder.d.ts +1 -6
- package/lib/chevre/repo/transaction/placeOrder.js +37 -26
- package/lib/chevre/repo/transaction.d.ts +1 -1
- package/lib/chevre/repo/transaction.js +2 -2
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +11 -0
- package/lib/chevre/service/assetTransaction/reserve/start.d.ts +0 -2
- package/lib/chevre/service/offer/any.d.ts +1 -3
- package/lib/chevre/service/offer/any.js +7 -8
- package/lib/chevre/service/offer/event/authorize/processStartReserve4chevre.d.ts +0 -2
- package/lib/chevre/service/offer/event/authorize.d.ts +0 -4
- package/lib/chevre/service/offer/event/authorize.js +5 -8
- package/lib/chevre/service/offer/event/voidTransaction.js +29 -17
- package/lib/chevre/service/offer/event/voidTransactionByActionId.js +16 -12
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.d.ts +0 -6
- package/lib/chevre/service/offer/eventServiceByCOA/acceptOffer.js +10 -12
- package/lib/chevre/service/offer/eventServiceByCOA/authorize/factory.d.ts +1 -1
- package/lib/chevre/service/offer/eventServiceByCOA/authorize.js +6 -7
- package/lib/chevre/service/offer/eventServiceByCOA/changeOffers.js +20 -17
- package/lib/chevre/service/order/deleteOrder.d.ts +6 -10
- package/lib/chevre/service/order/deleteOrder.js +7 -48
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderCancelled/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderDeliveredPartially/factory.d.ts +1 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.d.ts +4 -1
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderPaymentDue.js +1 -26
- package/lib/chevre/service/order/onOrderStatusChanged/onOrderReturned/factory.d.ts +1 -1
- package/lib/chevre/service/order/placeOrder/createPlacingOrderFromExistingTransaction.js +3 -2
- package/lib/chevre/service/order/placeOrder/factory.d.ts +1 -1
- package/lib/chevre/service/order/placeOrder/factory.js +6 -6
- package/lib/chevre/service/order/placeOrder/voidAcceptedOfferIfNecessary.d.ts +1 -3
- package/lib/chevre/service/order/placeOrder/voidAcceptedOfferIfNecessary.js +3 -15
- package/lib/chevre/service/order/placeOrder.js +6 -6
- package/lib/chevre/service/order.d.ts +1 -2
- package/lib/chevre/service/order.js +1 -5
- package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.d.ts +2 -4
- package/lib/chevre/service/payment/any/authorize/fixOrderAsNeeded.js +4 -6
- package/lib/chevre/service/payment/any/authorize.d.ts +2 -0
- package/lib/chevre/service/payment/any/publishPaymentUrl.d.ts +0 -4
- package/lib/chevre/service/payment/any/publishPaymentUrl.js +5 -8
- package/lib/chevre/service/task/acceptCOAOffer.js +8 -10
- package/lib/chevre/service/task/authorizePayment.js +2 -6
- package/lib/chevre/service/task/deleteTransaction.js +2 -10
- package/lib/chevre/service/task/publishPaymentUrl.js +6 -9
- package/lib/chevre/service/taskHandler.js +0 -1
- package/lib/chevre/service/transaction/deleteTransaction.d.ts +8 -16
- package/lib/chevre/service/transaction/deleteTransaction.js +46 -145
- package/lib/chevre/service/transaction/placeOrder/confirm/factory/result.d.ts +7 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions/sendEmailMessage.d.ts +3 -2
- package/lib/chevre/service/transaction/placeOrder/confirm/potentialActions.d.ts +3 -2
- package/lib/chevre/service/transaction/placeOrder/confirm.d.ts +2 -5
- package/lib/chevre/service/transaction/placeOrder/confirm.js +29 -24
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.d.ts +2 -3
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +45 -54
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.d.ts +0 -4
- package/lib/chevre/service/transaction/placeOrder/exportTasksById.js +2 -3
- package/lib/chevre/service/transaction/placeOrder/issueOrderNumberIfNotExist.d.ts +5 -0
- package/lib/chevre/service/transaction/placeOrder/issueOrderNumberIfNotExist.js +37 -23
- package/lib/chevre/service/transaction/placeOrder/start/factory.d.ts +20 -4
- package/lib/chevre/service/transaction/placeOrder/start/factory.js +20 -7
- package/lib/chevre/service/transaction/placeOrder/start.d.ts +9 -4
- package/lib/chevre/service/transaction/placeOrder/start.js +18 -1
- package/lib/chevre/service/transaction/placeOrder/updateAgent.d.ts +0 -4
- package/lib/chevre/service/transaction/placeOrder/updateAgent.js +19 -22
- package/lib/chevre/service/transaction/placeOrder.d.ts +1 -2
- package/lib/chevre/service/transaction/placeOrder.js +1 -3
- package/lib/chevre/service/transaction.d.ts +0 -4
- package/lib/chevre/service/transaction.js +1 -1
- package/lib/chevre/service.d.ts +0 -2
- package/lib/chevre/service.js +0 -2
- package/package.json +2 -2
- package/lib/chevre/factory/order.d.ts +0 -2
- package/lib/chevre/factory/order.js +0 -5
- package/lib/chevre/service/order/placeOrderWithoutTransaction.d.ts +0 -22
- package/lib/chevre/service/order/placeOrderWithoutTransaction.js +0 -51
- package/lib/chevre/service/task/deletePerson.d.ts +0 -6
- package/lib/chevre/service/task/deletePerson.js +0 -465
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { AccountingReportRepo } from '../../repo/accountingReport';
|
|
2
|
-
import type { ActionRepo } from '../../repo/action';
|
|
3
|
-
import type { OrderRepo } from '../../repo/order';
|
|
4
|
-
import type { TaskRepo } from '../../repo/task';
|
|
5
|
-
import { factory } from '../../factory';
|
|
6
|
-
import { IExternalOrder } from './onOrderStatusChanged';
|
|
7
|
-
/**
|
|
8
|
-
* 注文取引なしに注文を作成する
|
|
9
|
-
*/
|
|
10
|
-
declare function placeOrderWithoutTransaction(params: {
|
|
11
|
-
agent?: factory.action.trade.order.IAgent;
|
|
12
|
-
project: {
|
|
13
|
-
id: string;
|
|
14
|
-
};
|
|
15
|
-
object: IExternalOrder;
|
|
16
|
-
}): (repos: {
|
|
17
|
-
accountingReport: AccountingReportRepo;
|
|
18
|
-
action: ActionRepo;
|
|
19
|
-
order: OrderRepo;
|
|
20
|
-
task: TaskRepo;
|
|
21
|
-
}) => Promise<void>;
|
|
22
|
-
export { placeOrderWithoutTransaction };
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.placeOrderWithoutTransaction = placeOrderWithoutTransaction;
|
|
4
|
-
const factory_1 = require("../../factory");
|
|
5
|
-
/**
|
|
6
|
-
* 注文取引なしに注文を作成する
|
|
7
|
-
*/
|
|
8
|
-
function placeOrderWithoutTransaction(params) {
|
|
9
|
-
return async (repos) => {
|
|
10
|
-
const order = params.object;
|
|
11
|
-
const simpleOrder = {
|
|
12
|
-
typeOf: order.typeOf,
|
|
13
|
-
// seller: {
|
|
14
|
-
// id: order.seller.id,
|
|
15
|
-
// typeOf: order.seller.typeOf,
|
|
16
|
-
// name: order.seller.name
|
|
17
|
-
// }, // 廃止(2024-03-06~)
|
|
18
|
-
// customer: { typeOf: maskedCustomer.typeOf, id: maskedCustomer.id }, // 廃止(2024-03-06~)
|
|
19
|
-
orderNumber: order.orderNumber,
|
|
20
|
-
// price: order.price,
|
|
21
|
-
// priceCurrency: order.priceCurrency,
|
|
22
|
-
orderDate: order.orderDate
|
|
23
|
-
};
|
|
24
|
-
const orderActionAttributes = {
|
|
25
|
-
agent: (typeof params.agent?.typeOf === 'string') ? params.agent : order.project,
|
|
26
|
-
object: simpleOrder,
|
|
27
|
-
// potentialActions: {}, // discontinue(2024-06-28~)
|
|
28
|
-
project: order.project,
|
|
29
|
-
// purpose: { typeOf: placeOrderTransaction.typeOf, id: placeOrderTransaction.id },
|
|
30
|
-
typeOf: factory_1.factory.actionType.OrderAction
|
|
31
|
-
};
|
|
32
|
-
const action = await repos.action.start(orderActionAttributes);
|
|
33
|
-
try {
|
|
34
|
-
await repos.order.createIfNotExist({
|
|
35
|
-
...order,
|
|
36
|
-
// discounts: [], // 廃止(2024-04-16~)
|
|
37
|
-
acceptedOffers: []
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
catch (error) {
|
|
41
|
-
try {
|
|
42
|
-
await repos.action.giveUp({ typeOf: orderActionAttributes.typeOf, id: action.id, error });
|
|
43
|
-
}
|
|
44
|
-
catch (__) {
|
|
45
|
-
// 失敗したら仕方ない
|
|
46
|
-
}
|
|
47
|
-
throw error;
|
|
48
|
-
}
|
|
49
|
-
await repos.action.completeWithVoid({ typeOf: orderActionAttributes.typeOf, id: action.id, result: {} });
|
|
50
|
-
};
|
|
51
|
-
}
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { factory } from '../../factory';
|
|
2
|
-
import type { ICallResult, IExecutableTaskKeys, IOperationExecute } from '../taskHandler';
|
|
3
|
-
/**
|
|
4
|
-
* タスク実行関数
|
|
5
|
-
*/
|
|
6
|
-
export declare function call(params: Pick<factory.task.deletePerson.ITask, IExecutableTaskKeys>): IOperationExecute<ICallResult>;
|
|
@@ -1,465 +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.call = call;
|
|
7
|
-
const debug_1 = __importDefault(require("debug"));
|
|
8
|
-
const factory_1 = require("../../factory");
|
|
9
|
-
const action_1 = require("../../repo/action");
|
|
10
|
-
const ownershipInfo_1 = require("../../repo/ownershipInfo");
|
|
11
|
-
const paymentService_1 = require("../../repo/paymentService");
|
|
12
|
-
const person_1 = require("../../repo/person");
|
|
13
|
-
const setting_1 = require("../../repo/setting");
|
|
14
|
-
const task_1 = require("../../repo/task");
|
|
15
|
-
const debug = (0, debug_1.default)('chevre-domain:service:task:deletePerson');
|
|
16
|
-
// type IOwnershipInfoPermit = factory.ownershipInfo.IPermitAsGood;
|
|
17
|
-
const ADMIN_PROVIDER_NAME = 'Google';
|
|
18
|
-
let cognitoIdentityServiceProvider;
|
|
19
|
-
/**
|
|
20
|
-
* タスク実行関数
|
|
21
|
-
*/
|
|
22
|
-
function call(params) {
|
|
23
|
-
return async ({ connection }) => {
|
|
24
|
-
if (cognitoIdentityServiceProvider === undefined) {
|
|
25
|
-
const { CognitoIdentityProvider } = await import('@aws-sdk/client-cognito-identity-provider');
|
|
26
|
-
const { fromEnv } = await import('@aws-sdk/credential-providers');
|
|
27
|
-
cognitoIdentityServiceProvider = new CognitoIdentityProvider({
|
|
28
|
-
apiVersion: 'latest',
|
|
29
|
-
region: 'ap-northeast-1',
|
|
30
|
-
credentials: fromEnv()
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
const settingRepo = new setting_1.SettingRepo(connection);
|
|
34
|
-
const setting = await settingRepo.findOne({ project: { id: { $eq: '*' } } }, ['userPoolIdOld']);
|
|
35
|
-
if (typeof setting?.userPoolIdOld !== 'string') {
|
|
36
|
-
throw new factory_1.factory.errors.NotFound('setting.userPoolIdOld');
|
|
37
|
-
}
|
|
38
|
-
const newPersonRepo = new person_1.PersonRepo({
|
|
39
|
-
userPoolId: params.data.userPoolId,
|
|
40
|
-
cognitoIdentityServiceProvider
|
|
41
|
-
});
|
|
42
|
-
const oldPersonRepo = new person_1.PersonRepo({
|
|
43
|
-
// userPoolId: settings.userPoolIdOld,
|
|
44
|
-
userPoolId: setting.userPoolIdOld,
|
|
45
|
-
cognitoIdentityServiceProvider
|
|
46
|
-
});
|
|
47
|
-
const paymentServiceRepo = new paymentService_1.PaymentServiceRepo(connection);
|
|
48
|
-
await deleteById({
|
|
49
|
-
...params.data,
|
|
50
|
-
project: { id: params.project.id }
|
|
51
|
-
})({
|
|
52
|
-
action: new action_1.ActionRepo(connection),
|
|
53
|
-
ownershipInfo: new ownershipInfo_1.OwnershipInfoRepo(connection),
|
|
54
|
-
paymentService: paymentServiceRepo,
|
|
55
|
-
newPerson: newPersonRepo,
|
|
56
|
-
oldPerson: oldPersonRepo,
|
|
57
|
-
task: new task_1.TaskRepo(connection),
|
|
58
|
-
cognitoIdentityServiceProvider
|
|
59
|
-
});
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* 会員削除処理
|
|
64
|
-
*/
|
|
65
|
-
function deleteById(params
|
|
66
|
-
// setting: Pick<ISetting, 'userPoolIdOld'>
|
|
67
|
-
) {
|
|
68
|
-
return async (repos) => {
|
|
69
|
-
const deleteObject = {
|
|
70
|
-
id: params.id,
|
|
71
|
-
typeOf: factory_1.factory.personType.Person,
|
|
72
|
-
// migrate: params.migrate, // discontinue(2026-04-08~)
|
|
73
|
-
physically: params.physically
|
|
74
|
-
};
|
|
75
|
-
const deleteMemberAction = {
|
|
76
|
-
agent: params.agent,
|
|
77
|
-
object: deleteObject,
|
|
78
|
-
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
79
|
-
typeOf: factory_1.factory.actionType.DeleteAction
|
|
80
|
-
};
|
|
81
|
-
const action = await repos.action.start(deleteMemberAction);
|
|
82
|
-
let existingPeople;
|
|
83
|
-
try {
|
|
84
|
-
existingPeople = await repos.newPerson.search({ id: params.id });
|
|
85
|
-
// exclude ADMIN_PROVIDER_NAME
|
|
86
|
-
const username = existingPeople.at(0)?.Username;
|
|
87
|
-
const isAdminPerson = typeof username === 'string' && username.startsWith(ADMIN_PROVIDER_NAME, 0);
|
|
88
|
-
if (isAdminPerson) {
|
|
89
|
-
throw new factory_1.factory.errors.Argument('id', `${ADMIN_PROVIDER_NAME} people cannot be deleted`);
|
|
90
|
-
}
|
|
91
|
-
// if (!params.migrate) {
|
|
92
|
-
// }
|
|
93
|
-
// 移行でなければDeleteTransactionタスクを作成(2023-07-03~)
|
|
94
|
-
await createDeleteTransactionTask({
|
|
95
|
-
id: params.id,
|
|
96
|
-
project: { id: params.project.id },
|
|
97
|
-
now: action.startDate
|
|
98
|
-
})({ task: repos.task });
|
|
99
|
-
if (existingPeople.length > 0) {
|
|
100
|
-
// if (repos.creditCard !== undefined) {
|
|
101
|
-
// // クレジットカード削除
|
|
102
|
-
// await deleteCreditCardsById(
|
|
103
|
-
// {
|
|
104
|
-
// id: params.id,
|
|
105
|
-
// useUsernameAsGMOMemberId: params.useUsernameAsGMOMemberId
|
|
106
|
-
// },
|
|
107
|
-
// setting
|
|
108
|
-
// )(
|
|
109
|
-
// {
|
|
110
|
-
// person: repos.newPerson,
|
|
111
|
-
// creditCard: repos.creditCard,
|
|
112
|
-
// cognitoIdentityServiceProvider: repos.cognitoIdentityServiceProvider
|
|
113
|
-
// }
|
|
114
|
-
// );
|
|
115
|
-
// }
|
|
116
|
-
}
|
|
117
|
-
// 所有権削除
|
|
118
|
-
debug('task:deletePerson:deleteById: deleteOwnershipInfosById processing... personId:', params.id);
|
|
119
|
-
await deleteOwnershipInfosById({
|
|
120
|
-
id: params.id,
|
|
121
|
-
project: { id: params.project.id }
|
|
122
|
-
})({ ownershipInfo: repos.ownershipInfo });
|
|
123
|
-
if (existingPeople.length > 0) {
|
|
124
|
-
// 会員削除
|
|
125
|
-
if (params.physically === true) {
|
|
126
|
-
debug('task:deletePerson:deleteById: deleteById processing...userId:', params.id);
|
|
127
|
-
await repos.newPerson.deleteById({ userId: params.id });
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
// Cognitoユーザを無効にする
|
|
131
|
-
await repos.newPerson.globalSignOutAndDisable({ userId: params.id });
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
catch (error) {
|
|
136
|
-
try {
|
|
137
|
-
await repos.action.giveUp({ typeOf: action.typeOf, id: action.id, error });
|
|
138
|
-
}
|
|
139
|
-
catch (__) {
|
|
140
|
-
// no op
|
|
141
|
-
}
|
|
142
|
-
throw error;
|
|
143
|
-
}
|
|
144
|
-
const actionResult = { existingPeople };
|
|
145
|
-
await repos.action.completeWithVoid({ typeOf: action.typeOf, id: action.id, result: actionResult });
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
// interface ICreditCardPaymentServiceCredentials {
|
|
149
|
-
// endpoint: string;
|
|
150
|
-
// siteId: string;
|
|
151
|
-
// sitePass: string;
|
|
152
|
-
// }
|
|
153
|
-
// function getCreditCardPaymentServiceChannel(params: {
|
|
154
|
-
// project: { id: string };
|
|
155
|
-
// paymentMethodType: string;
|
|
156
|
-
// }) {
|
|
157
|
-
// return async (repos: {
|
|
158
|
-
// paymentService: PaymentServiceRepo;
|
|
159
|
-
// }): Promise<ICreditCardPaymentServiceCredentials> => {
|
|
160
|
-
// const paymentServices = await repos.paymentService.projectFields(
|
|
161
|
-
// {
|
|
162
|
-
// limit: 1,
|
|
163
|
-
// project: { id: { $eq: params.project.id } },
|
|
164
|
-
// typeOf: { $eq: factory.service.paymentService.PaymentServiceType.CreditCard },
|
|
165
|
-
// serviceType: { codeValue: { $eq: params.paymentMethodType } }
|
|
166
|
-
// },
|
|
167
|
-
// ['availableChannel']
|
|
168
|
-
// ) as Pick<factory.service.paymentService.IService, 'availableChannel' | 'id'>[];
|
|
169
|
-
// const paymentService = paymentServices.shift();
|
|
170
|
-
// if (paymentService === undefined) {
|
|
171
|
-
// throw new factory.errors.NotFound('PaymentService');
|
|
172
|
-
// }
|
|
173
|
-
// if (typeof paymentService.id !== 'string') {
|
|
174
|
-
// throw new factory.errors.NotFound('paymentService.id.id');
|
|
175
|
-
// }
|
|
176
|
-
// const availableChannel = await repos.paymentService.findAvailableChannelCreditCard({
|
|
177
|
-
// project: { id: params.project.id },
|
|
178
|
-
// id: paymentService.id
|
|
179
|
-
// });
|
|
180
|
-
// // const availableChannel = paymentService?.availableChannel;
|
|
181
|
-
// if (typeof availableChannel?.serviceUrl !== 'string') {
|
|
182
|
-
// throw new factory.errors.NotFound('paymentService.availableChannel.serviceUrl');
|
|
183
|
-
// }
|
|
184
|
-
// if (typeof availableChannel?.credentials?.siteId !== 'string') {
|
|
185
|
-
// throw new factory.errors.NotFound('paymentService.availableChannel.credentials.siteId');
|
|
186
|
-
// }
|
|
187
|
-
// if (typeof availableChannel?.credentials?.sitePass !== 'string') {
|
|
188
|
-
// throw new factory.errors.NotFound('paymentService.availableChannel.credentials.sitePass');
|
|
189
|
-
// }
|
|
190
|
-
// return {
|
|
191
|
-
// endpoint: availableChannel.serviceUrl,
|
|
192
|
-
// siteId: availableChannel.credentials.siteId,
|
|
193
|
-
// sitePass: availableChannel.credentials.sitePass
|
|
194
|
-
// };
|
|
195
|
-
// };
|
|
196
|
-
// }
|
|
197
|
-
// function createInformTask(params: {
|
|
198
|
-
// id: string;
|
|
199
|
-
// project: { id: string };
|
|
200
|
-
// now: Date;
|
|
201
|
-
// migratePersonRecipientUrl: string;
|
|
202
|
-
// }) {
|
|
203
|
-
// // tslint:disable-next-line:max-func-body-length
|
|
204
|
-
// return async (repos: {
|
|
205
|
-
// account: AccountRepo;
|
|
206
|
-
// ownershipInfo: OwnershipInfoRepo;
|
|
207
|
-
// newPerson: PersonRepo;
|
|
208
|
-
// oldPerson: PersonRepo;
|
|
209
|
-
// task: TaskRepo;
|
|
210
|
-
// }) => {
|
|
211
|
-
// const person = await repos.newPerson.findById({ userId: params.id });
|
|
212
|
-
// let oldUser: factory.person.IPerson | undefined;
|
|
213
|
-
// const userIdentitiesStr = person.additionalProperty?.find((p) => p.name === 'identities')?.value;
|
|
214
|
-
// if (typeof userIdentitiesStr === 'string' && userIdentitiesStr.length > 0) {
|
|
215
|
-
// try {
|
|
216
|
-
// const identities = JSON.parse(userIdentitiesStr);
|
|
217
|
-
// if (Array.isArray(identities) && identities.length > 0) {
|
|
218
|
-
// const userIdByIdentities = identities[0].userId;
|
|
219
|
-
// if (typeof userIdByIdentities === 'string' && userIdByIdentities.length > 0) {
|
|
220
|
-
// // oldUserは必ず存在するはず
|
|
221
|
-
// oldUser = await repos.oldPerson.findById({ userId: userIdByIdentities });
|
|
222
|
-
// }
|
|
223
|
-
// }
|
|
224
|
-
// } catch (error) {
|
|
225
|
-
// // tslint:disable-next-line:no-console
|
|
226
|
-
// console.error('find oldUser throwed', error);
|
|
227
|
-
// throw error;
|
|
228
|
-
// }
|
|
229
|
-
// }
|
|
230
|
-
// const reservations = await repos.ownershipInfo.projectFields({
|
|
231
|
-
// project: { id: { $eq: params.project.id } },
|
|
232
|
-
// ownedBy: { id: params.id },
|
|
233
|
-
// typeOfGood: { issuedThrough: { typeOf: { $eq: factory.product.ProductType.EventService } } }
|
|
234
|
-
// });
|
|
235
|
-
// const memberships = <factory.ownershipInfo.IOwnershipInfo<factory.ownershipInfo.IPermitAsGood>[]>
|
|
236
|
-
// await repos.ownershipInfo.projectFields({
|
|
237
|
-
// limit: 1,
|
|
238
|
-
// page: 1,
|
|
239
|
-
// project: { id: { $eq: params.project.id } },
|
|
240
|
-
// ownedBy: { id: params.id },
|
|
241
|
-
// typeOfGood: { issuedThrough: { typeOf: { $eq: factory.product.ProductType.MembershipService } } },
|
|
242
|
-
// ownedFrom: params.now,
|
|
243
|
-
// ownedThrough: params.now
|
|
244
|
-
// });
|
|
245
|
-
// let paymentCards = <factory.ownershipInfo.IOwnershipInfo<factory.ownershipInfo.IPermitAsGood & {
|
|
246
|
-
// balance: number;
|
|
247
|
-
// }>[]>
|
|
248
|
-
// await repos.ownershipInfo.projectFields({
|
|
249
|
-
// // 最も古い所有ペイメントカードをデフォルトペイメントカードとして扱う使用なので、ソート条件は以下の通り
|
|
250
|
-
// sort: { ownedFrom: factory.sortType.Ascending },
|
|
251
|
-
// limit: 1,
|
|
252
|
-
// page: 1,
|
|
253
|
-
// project: { id: { $eq: params.project.id } },
|
|
254
|
-
// ownedBy: { id: params.id },
|
|
255
|
-
// typeOfGood: { issuedThrough: { typeOf: { $eq: factory.product.ProductType.PaymentCard } } },
|
|
256
|
-
// ownedFrom: params.now,
|
|
257
|
-
// ownedThrough: params.now
|
|
258
|
-
// });
|
|
259
|
-
// paymentCards = await Promise.all(paymentCards.map(async (paymentCard) => {
|
|
260
|
-
// // 口座検索
|
|
261
|
-
// const accountNumber = String((<IOwnershipInfoPermit>paymentCard.typeOfGood).identifier);
|
|
262
|
-
// const account = await repos.account.findByAccountNumber({ accountNumber });
|
|
263
|
-
// return {
|
|
264
|
-
// ...paymentCard,
|
|
265
|
-
// typeOfGood: {
|
|
266
|
-
// ...paymentCard.typeOfGood,
|
|
267
|
-
// balance: account.balance
|
|
268
|
-
// }
|
|
269
|
-
// };
|
|
270
|
-
// }));
|
|
271
|
-
// // create task
|
|
272
|
-
// let informTask: factory.task.IAttributes<factory.taskName.TriggerWebhook> & {
|
|
273
|
-
// data: factory.task.triggerWebhook.IInformAnyResourceAction & {
|
|
274
|
-
// object: factory.notification.person.IPersonAsNotification;
|
|
275
|
-
// };
|
|
276
|
-
// };
|
|
277
|
-
// const informObject: factory.notification.person.IPersonAsNotification = {
|
|
278
|
-
// id: person.id,
|
|
279
|
-
// memberOf: person.memberOf,
|
|
280
|
-
// typeOf: person.typeOf,
|
|
281
|
-
// cognitoUser: {
|
|
282
|
-
// Attributes: (<any>oldUser)?.Attributes,
|
|
283
|
-
// Enabled: (<any>oldUser)?.Enabled,
|
|
284
|
-
// UserCreateDate: (<any>oldUser)?.UserCreateDate,
|
|
285
|
-
// UserLastModifiedDate: (<any>oldUser)?.UserLastModifiedDate,
|
|
286
|
-
// UserStatus: (<any>oldUser)?.UserStatus,
|
|
287
|
-
// Username: (<any>oldUser)?.Username
|
|
288
|
-
// },
|
|
289
|
-
// reservations: reservations.map((ownershipInfo) => {
|
|
290
|
-
// const { id, typeOf, typeOfGood, ownedFrom, ownedThrough } = ownershipInfo;
|
|
291
|
-
// return { id, typeOf, typeOfGood, ownedFrom, ownedThrough };
|
|
292
|
-
// }),
|
|
293
|
-
// memberships: memberships.map((ownershipInfo) => {
|
|
294
|
-
// const { id, typeOf, typeOfGood, ownedFrom, ownedThrough } = ownershipInfo;
|
|
295
|
-
// const { identifier } = typeOfGood;
|
|
296
|
-
// return {
|
|
297
|
-
// id,
|
|
298
|
-
// typeOf,
|
|
299
|
-
// typeOfGood: { identifier },
|
|
300
|
-
// ownedFrom,
|
|
301
|
-
// ownedThrough
|
|
302
|
-
// };
|
|
303
|
-
// }),
|
|
304
|
-
// paymentCards: paymentCards.map((ownershipInfo) => {
|
|
305
|
-
// const { id, typeOf, typeOfGood } = ownershipInfo;
|
|
306
|
-
// const { balance, identifier } = typeOfGood;
|
|
307
|
-
// return {
|
|
308
|
-
// id,
|
|
309
|
-
// typeOf,
|
|
310
|
-
// typeOfGood: { balance, identifier }
|
|
311
|
-
// };
|
|
312
|
-
// })
|
|
313
|
-
// };
|
|
314
|
-
// const informActionAttributes: factory.task.triggerWebhook.IInformAnyResourceAction & {
|
|
315
|
-
// object: factory.notification.person.IPersonAsNotification;
|
|
316
|
-
// } = { // optimize(2024-07-01~)
|
|
317
|
-
// object: informObject,
|
|
318
|
-
// recipient: {
|
|
319
|
-
// // url: params.migratePersonRecipientUrl, // discontinue(2025-02-13~)
|
|
320
|
-
// id: '',
|
|
321
|
-
// name: 'NewUserPool',
|
|
322
|
-
// typeOf: factory.creativeWorkType.WebApplication
|
|
323
|
-
// },
|
|
324
|
-
// target: {
|
|
325
|
-
// httpMethod: 'POST',
|
|
326
|
-
// encodingType: factory.encodingFormat.Application.json,
|
|
327
|
-
// typeOf: 'EntryPoint',
|
|
328
|
-
// urlTemplate: params.migratePersonRecipientUrl
|
|
329
|
-
// }
|
|
330
|
-
// };
|
|
331
|
-
// informTask = {
|
|
332
|
-
// project: { id: params.project.id, typeOf: factory.organizationType.Project },
|
|
333
|
-
// name: factory.taskName.TriggerWebhook,
|
|
334
|
-
// status: factory.taskStatus.Ready,
|
|
335
|
-
// runsAt: params.now,
|
|
336
|
-
// remainingNumberOfTries: 10,
|
|
337
|
-
// numberOfTried: 0,
|
|
338
|
-
// executionResults: [],
|
|
339
|
-
// data: informActionAttributes
|
|
340
|
-
// };
|
|
341
|
-
// await repos.task.createInformTaskIfNotExist(informTask, { emitImmediately: true });
|
|
342
|
-
// };
|
|
343
|
-
// }
|
|
344
|
-
function createDeleteTransactionTask(params) {
|
|
345
|
-
return async (repos) => {
|
|
346
|
-
const deleteTransactionTasks = [
|
|
347
|
-
factory_1.factory.transactionType.PlaceOrder,
|
|
348
|
-
factory_1.factory.transactionType.ReturnOrder
|
|
349
|
-
].map((transactionType) => {
|
|
350
|
-
return {
|
|
351
|
-
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
352
|
-
name: factory_1.factory.taskName.DeleteTransaction,
|
|
353
|
-
status: factory_1.factory.taskStatus.Ready,
|
|
354
|
-
runsAt: params.now,
|
|
355
|
-
remainingNumberOfTries: 3,
|
|
356
|
-
numberOfTried: 0,
|
|
357
|
-
executionResults: [],
|
|
358
|
-
data: {
|
|
359
|
-
object: {
|
|
360
|
-
specifyingMethod: factory_1.factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.AgentId,
|
|
361
|
-
agent: { id: params.id },
|
|
362
|
-
project: { id: params.project.id },
|
|
363
|
-
typeOf: transactionType
|
|
364
|
-
}
|
|
365
|
-
}
|
|
366
|
-
};
|
|
367
|
-
});
|
|
368
|
-
await repos.task.saveMany(deleteTransactionTasks, { emitImmediately: true });
|
|
369
|
-
};
|
|
370
|
-
}
|
|
371
|
-
function deleteOwnershipInfosById(params) {
|
|
372
|
-
return async (repos) => {
|
|
373
|
-
// まず所有権削除
|
|
374
|
-
await repos.ownershipInfo.deleteByOwnedById({
|
|
375
|
-
project: { id: params.project.id },
|
|
376
|
-
ownedBy: { id: params.id }
|
|
377
|
-
});
|
|
378
|
-
};
|
|
379
|
-
}
|
|
380
|
-
// async function sleep(waitTime: number): Promise<void> {
|
|
381
|
-
// return new Promise<void>((resolve) => {
|
|
382
|
-
// setTimeout(
|
|
383
|
-
// () => {
|
|
384
|
-
// resolve();
|
|
385
|
-
// },
|
|
386
|
-
// waitTime
|
|
387
|
-
// );
|
|
388
|
-
// });
|
|
389
|
-
// }
|
|
390
|
-
// const DELETE_CREDIT_CARD_MAX_RETRY_COUNT = 2;
|
|
391
|
-
// const DELETE_CREDIT_CARD_RETRY_INTERVAL_IN_MS = 1000;
|
|
392
|
-
// function deleteCreditCardsById(
|
|
393
|
-
// params: {
|
|
394
|
-
// id: string;
|
|
395
|
-
// useUsernameAsGMOMemberId: boolean;
|
|
396
|
-
// },
|
|
397
|
-
// setting: Pick<ISetting, 'userPoolIdOld'>
|
|
398
|
-
// ) {
|
|
399
|
-
// return async (
|
|
400
|
-
// repos: {
|
|
401
|
-
// person: PersonRepo;
|
|
402
|
-
// creditCard: CreditCardRepo;
|
|
403
|
-
// cognitoIdentityServiceProvider: CognitoIdentityServiceProvider;
|
|
404
|
-
// }
|
|
405
|
-
// ) => {
|
|
406
|
-
// let retry = true;
|
|
407
|
-
// let numberOfTry = 0;
|
|
408
|
-
// while (numberOfTry >= 0) {
|
|
409
|
-
// try {
|
|
410
|
-
// numberOfTry += 1;
|
|
411
|
-
// if (numberOfTry > DELETE_CREDIT_CARD_MAX_RETRY_COUNT) {
|
|
412
|
-
// retry = false;
|
|
413
|
-
// }
|
|
414
|
-
// // retryInterval
|
|
415
|
-
// if (numberOfTry > 1) {
|
|
416
|
-
// await sleep(DELETE_CREDIT_CARD_RETRY_INTERVAL_IN_MS * (numberOfTry - 1));
|
|
417
|
-
// }
|
|
418
|
-
// // クレジットカード削除
|
|
419
|
-
// if (params.useUsernameAsGMOMemberId) {
|
|
420
|
-
// const person = await repos.person.findById({ userId: params.id });
|
|
421
|
-
// let oldUsername: string | undefined;
|
|
422
|
-
// try {
|
|
423
|
-
// oldUsername = await person2username(
|
|
424
|
-
// person, repos.cognitoIdentityServiceProvider,
|
|
425
|
-
// // settings
|
|
426
|
-
// setting
|
|
427
|
-
// );
|
|
428
|
-
// } catch (error) {
|
|
429
|
-
// let throwsPerson2usernameError = true;
|
|
430
|
-
// // oldUserが存在しないケースをハンドル
|
|
431
|
-
// if (error instanceof factory.errors.NotFound && error.entityName === 'User') {
|
|
432
|
-
// debug(
|
|
433
|
-
// 'task:deletePerson:deleteById: deleteCreditCardsById oldUsername not found',
|
|
434
|
-
// 'personId:', params.id,
|
|
435
|
-
// 'numberOfTry:', numberOfTry
|
|
436
|
-
// );
|
|
437
|
-
// throwsPerson2usernameError = false;
|
|
438
|
-
// }
|
|
439
|
-
// if (throwsPerson2usernameError) {
|
|
440
|
-
// throw error;
|
|
441
|
-
// }
|
|
442
|
-
// }
|
|
443
|
-
// if (typeof oldUsername === 'string') {
|
|
444
|
-
// debug(
|
|
445
|
-
// 'task:deletePerson:deleteById: deleteCreditCardsById processing... oldUsername:', oldUsername,
|
|
446
|
-
// 'personId:', params.id,
|
|
447
|
-
// 'numberOfTry:', numberOfTry
|
|
448
|
-
// );
|
|
449
|
-
// await repos.creditCard.deleteAll({ personId: oldUsername });
|
|
450
|
-
// }
|
|
451
|
-
// } else {
|
|
452
|
-
// await repos.creditCard.deleteAll({ personId: params.id });
|
|
453
|
-
// }
|
|
454
|
-
// debug('task:deletePerson:deleteById: deleteCreditCardsById processed. personId:', params.id, 'numberOfTry:', numberOfTry);
|
|
455
|
-
// break;
|
|
456
|
-
// } catch (error) {
|
|
457
|
-
// if (retry) {
|
|
458
|
-
// continue;
|
|
459
|
-
// } else {
|
|
460
|
-
// throw error;
|
|
461
|
-
// }
|
|
462
|
-
// }
|
|
463
|
-
// }
|
|
464
|
-
// };
|
|
465
|
-
// }
|