@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
|
@@ -9,53 +9,52 @@ const factory_1 = require("../../../../factory");
|
|
|
9
9
|
/**
|
|
10
10
|
* 取引のタスクを作成する
|
|
11
11
|
*/
|
|
12
|
-
function createTasks(params, setting
|
|
13
|
-
// settings: Settings
|
|
14
|
-
) {
|
|
12
|
+
function createTasks(params, setting) {
|
|
15
13
|
const taskAttributes = [];
|
|
16
14
|
const transaction = params.transaction;
|
|
17
15
|
const taskRunsAt = params.runsAt;
|
|
18
|
-
|
|
19
|
-
const
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
16
|
+
// 取引通知は廃止(2026-06-29~)
|
|
17
|
+
// const informTransaction = setting?.onTransactionStatusChanged?.informTransaction;
|
|
18
|
+
// const transactionWebhookUrls = (Array.isArray(informTransaction)) ? informTransaction : [];
|
|
19
|
+
// const triggerWebhookTaskAttributes: factory.task.IAttributes<factory.taskName.TriggerWebhook>[] = [];
|
|
20
|
+
// transactionWebhookUrls.forEach(({ recipient }) => {
|
|
21
|
+
// if (typeof recipient?.url === 'string') {
|
|
22
|
+
// const informObject: factory.notification.transaction.IPlaceOrderAsNotification = {
|
|
23
|
+
// id: transaction.id,
|
|
24
|
+
// typeOf: transaction.typeOf,
|
|
25
|
+
// project: transaction.project,
|
|
26
|
+
// seller: transaction.seller,
|
|
27
|
+
// startDate: transaction.startDate,
|
|
28
|
+
// status: transaction.status,
|
|
29
|
+
// ...(transaction.endDate !== undefined) ? { endDate: transaction.endDate } : undefined
|
|
30
|
+
// };
|
|
31
|
+
// const data: factory.task.triggerWebhook.IInformAnyResourceAction = {
|
|
32
|
+
// object: informObject,
|
|
33
|
+
// recipient: {
|
|
34
|
+
// id: (typeof recipient?.id === 'string') ? recipient.id : '',
|
|
35
|
+
// name: recipient?.name,
|
|
36
|
+
// typeOf: factory.creativeWorkType.WebApplication
|
|
37
|
+
// // url: recipient.url // discontinue(2025-02-13~)
|
|
38
|
+
// },
|
|
39
|
+
// target: {
|
|
40
|
+
// httpMethod: 'POST',
|
|
41
|
+
// encodingType: factory.encodingFormat.Application.json,
|
|
42
|
+
// typeOf: 'EntryPoint',
|
|
43
|
+
// urlTemplate: recipient.url
|
|
44
|
+
// }
|
|
45
|
+
// };
|
|
46
|
+
// triggerWebhookTaskAttributes.push({
|
|
47
|
+
// project: transaction.project,
|
|
48
|
+
// name: factory.taskName.TriggerWebhook,
|
|
49
|
+
// status: factory.taskStatus.Ready,
|
|
50
|
+
// runsAt: taskRunsAt,
|
|
51
|
+
// remainingNumberOfTries: 3,
|
|
52
|
+
// numberOfTried: 0,
|
|
53
|
+
// executionResults: [],
|
|
54
|
+
// data
|
|
55
|
+
// });
|
|
56
|
+
// }
|
|
57
|
+
// });
|
|
59
58
|
const confirmedStoragePeriodInDays = setting?.storage?.transactionConfirmedInDays;
|
|
60
59
|
const canceledStoragePeriodInDays = setting?.storage?.transactionCanceledInDays;
|
|
61
60
|
if (typeof confirmedStoragePeriodInDays !== 'number') {
|
|
@@ -140,7 +139,7 @@ function createTasks(params, setting
|
|
|
140
139
|
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
141
140
|
}
|
|
142
141
|
};
|
|
143
|
-
taskAttributes.push(
|
|
142
|
+
taskAttributes.push(deleteTransactionTask);
|
|
144
143
|
switch (transaction.status) {
|
|
145
144
|
case factory_1.factory.transactionStatusType.Confirmed: {
|
|
146
145
|
taskAttributes.push(voidReserveTaskAttributes, voidPaymentTaskAttributes);
|
|
@@ -182,15 +181,7 @@ function createTasks(params, setting
|
|
|
182
181
|
taskAttributes.push(voidReserveTaskAttributes, voidPaymentTaskAttributes);
|
|
183
182
|
break;
|
|
184
183
|
case factory_1.factory.transactionStatusType.Expired:
|
|
185
|
-
|
|
186
|
-
if (params.optimizeRedundantTasks === true) {
|
|
187
|
-
if (typeof params.transaction.object.orderNumber === 'string') {
|
|
188
|
-
taskAttributes.push(voidReserveTaskAttributes, voidPaymentTaskAttributes);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
else {
|
|
192
|
-
taskAttributes.push(voidReserveTaskAttributes, voidPaymentTaskAttributes);
|
|
193
|
-
}
|
|
184
|
+
taskAttributes.push(voidReserveTaskAttributes, voidPaymentTaskAttributes);
|
|
194
185
|
break;
|
|
195
186
|
default:
|
|
196
187
|
throw new factory_1.factory.errors.NotImplemented(`Transaction status "${transaction.status}" not implemented.`);
|
|
@@ -16,9 +16,5 @@ declare function exportTasksById(params: {
|
|
|
16
16
|
* タスク実行日時バッファ
|
|
17
17
|
*/
|
|
18
18
|
runsTasksAfterInSeconds?: number;
|
|
19
|
-
/**
|
|
20
|
-
* support optimizeRedundantTasks(2025-03-11~)
|
|
21
|
-
*/
|
|
22
|
-
optimizeRedundantTasks: boolean;
|
|
23
19
|
}): ITaskAndTransactionOperation<void>;
|
|
24
20
|
export { IExportTasksByIdRepos, exportTasksById };
|
|
@@ -26,11 +26,10 @@ function exportTasksById(params) {
|
|
|
26
26
|
.toDate();
|
|
27
27
|
}
|
|
28
28
|
// search settings
|
|
29
|
-
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['
|
|
29
|
+
const setting = await repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['storage']);
|
|
30
30
|
const taskAttributes = (0, factory_2.createTasks)({
|
|
31
31
|
transaction,
|
|
32
|
-
runsAt: taskRunsAt
|
|
33
|
-
optimizeRedundantTasks: params.optimizeRedundantTasks === true
|
|
32
|
+
runsAt: taskRunsAt
|
|
34
33
|
}, setting
|
|
35
34
|
// settings
|
|
36
35
|
);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { OrderInTransactionRepo, IOrderInTransaction } from '../../../repo/orderInTransaction';
|
|
1
2
|
import type { OrderNumberRepo } from '../../../repo/orderNumber';
|
|
2
3
|
import type { ProjectRepo } from '../../../repo/project';
|
|
3
4
|
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
@@ -15,9 +16,13 @@ declare function issueOrderNumberIfNotExist(params: {
|
|
|
15
16
|
object: {
|
|
16
17
|
orderDate: Date;
|
|
17
18
|
};
|
|
19
|
+
creatingOrderInTransaction: Pick<IOrderInTransaction, 'broker' | 'seller' | 'customer'>;
|
|
20
|
+
}, options: {
|
|
21
|
+
saveOrderNumberInPlaceOrderInProgress: boolean;
|
|
18
22
|
}): (repos: {
|
|
19
23
|
project: ProjectRepo;
|
|
20
24
|
placeOrder: PlaceOrderRepo;
|
|
25
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
21
26
|
orderNumber: OrderNumberRepo;
|
|
22
27
|
}) => Promise<string>;
|
|
23
28
|
export { issueOrderNumberIfNotExist };
|
|
@@ -5,40 +5,54 @@ const factory_1 = require("../../../factory");
|
|
|
5
5
|
/**
|
|
6
6
|
* 未発行であれば、注文番号を発行して取引に保管する
|
|
7
7
|
*/
|
|
8
|
-
function issueOrderNumberIfNotExist(params) {
|
|
8
|
+
function issueOrderNumberIfNotExist(params, options) {
|
|
9
9
|
return async (repos) => {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
//
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
//
|
|
10
|
+
const { saveOrderNumberInPlaceOrderInProgress } = options;
|
|
11
|
+
// // 1. 最初のチェック
|
|
12
|
+
// let orderNumber = await repos.placeOrder.findInProgressOrderNumberById({ id: params.id });
|
|
13
|
+
// // すでに発行済であれば何もしない
|
|
14
|
+
// if (typeof orderNumber === 'string') {
|
|
15
|
+
// return orderNumber;
|
|
16
|
+
// }
|
|
17
|
+
// 新注文番号発行
|
|
17
18
|
const { alternateName } = await repos.project.findAlternateNameById({ id: params.project.id });
|
|
18
19
|
if (typeof alternateName !== 'string') {
|
|
19
20
|
throw new factory_1.factory.errors.NotFound('project.alternateName');
|
|
20
21
|
}
|
|
21
|
-
// 3. 番号発行
|
|
22
22
|
const issuedOrderNumber = await repos.orderNumber.issueOrderNumber({
|
|
23
23
|
project: { alternateName },
|
|
24
24
|
orderDate: params.object.orderDate
|
|
25
25
|
});
|
|
26
|
-
//
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
orderNumber: issuedOrderNumber
|
|
26
|
+
// 注文ドキュメント作成
|
|
27
|
+
await repos.orderInTransaction.createPlaceOrderIfNotExists({
|
|
28
|
+
...params.creatingOrderInTransaction,
|
|
29
|
+
orderNumber: issuedOrderNumber,
|
|
30
|
+
project: { id: params.project.id, typeOf: factory_1.factory.organizationType.Project },
|
|
31
|
+
identifier: params.id,
|
|
30
32
|
});
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
33
|
+
// 注文ドキュメント(存在するはず)から注文番号を参照
|
|
34
|
+
const orderNumber = await repos.orderInTransaction.findOrderNumberByIdentifier({
|
|
35
|
+
identifier: params.id,
|
|
36
|
+
project: { id: params.project.id }
|
|
37
|
+
}, { onlyPlaceOrder: true });
|
|
38
|
+
if (saveOrderNumberInPlaceOrderInProgress) {
|
|
39
|
+
// 取引に保管を試みる
|
|
40
|
+
await repos.placeOrder.saveOrderNumberIfNotExist({
|
|
41
|
+
id: params.id,
|
|
42
|
+
orderNumber
|
|
43
|
+
});
|
|
41
44
|
}
|
|
45
|
+
// // 5. 書き込めたなら、自分が発行した番号が「真実」
|
|
46
|
+
// if (modifiedCount === 1) {
|
|
47
|
+
// return issuedOrderNumber;
|
|
48
|
+
// }
|
|
49
|
+
// // 6. 競合が発生した場合(他者が先に書き込んだ場合)
|
|
50
|
+
// // DBにある「正解」を再取得して返す
|
|
51
|
+
// const orderNumber = await repos.placeOrder.findInProgressOrderNumberById({ id: params.id });
|
|
52
|
+
// if (typeof orderNumber !== 'string') {
|
|
53
|
+
// // ここを通るのは、他者が保存した直後に取引がキャンセル/削除された等の極めて稀なケース
|
|
54
|
+
// throw new factory.errors.Internal('OrderNumber conflict: failed to retrieve existing number');
|
|
55
|
+
// }
|
|
42
56
|
return orderNumber;
|
|
43
57
|
};
|
|
44
58
|
}
|
|
@@ -6,13 +6,29 @@ type IVerifiedPassport = factory.waiter.passport.IPassport & {
|
|
|
6
6
|
*/
|
|
7
7
|
identifier: string;
|
|
8
8
|
};
|
|
9
|
-
type
|
|
10
|
-
|
|
9
|
+
type ICustomerInObject = Pick<factory.order.ICustomer, 'id' | 'identifier' | 'typeOf'>;
|
|
10
|
+
interface IStartPlaceOrderParams {
|
|
11
|
+
project: Pick<factory.project.IProject, 'id' | 'typeOf'>;
|
|
12
|
+
agent: factory.transaction.placeOrder.IAgent;
|
|
13
|
+
seller: {
|
|
14
|
+
id: string;
|
|
15
|
+
};
|
|
16
|
+
object: {
|
|
11
17
|
/**
|
|
12
18
|
* api経由で取引が開始されれば必ず存在するはず
|
|
13
19
|
*/
|
|
14
20
|
clientUser: factory.transaction.placeOrder.IClientUserBeforeStart;
|
|
21
|
+
/**
|
|
22
|
+
* 注文ドキュメントに保管するcustomer
|
|
23
|
+
*/
|
|
24
|
+
customer?: ICustomerInObject;
|
|
25
|
+
passport?: factory.transaction.IPassportBeforeStart;
|
|
26
|
+
name?: never;
|
|
15
27
|
};
|
|
16
|
-
|
|
17
|
-
|
|
28
|
+
/**
|
|
29
|
+
* 注文ドキュメントに保管する代理人
|
|
30
|
+
*/
|
|
31
|
+
broker?: factory.order.IBroker;
|
|
32
|
+
}
|
|
33
|
+
declare function createStartParams(params: IStartPlaceOrderParams, expiresInSeconds: number, passport: IVerifiedPassport | undefined, seller: Pick<factory.seller.ISeller, 'id' | 'name' | 'typeOf' | 'project'>, customerType?: string): factory.transaction.placeOrder.IStartParams;
|
|
18
34
|
export { AGENT_IDENTIFIER_NAME_PASSPORT, createStartParams, IStartPlaceOrderParams };
|
|
@@ -5,6 +5,7 @@ exports.createStartParams = createStartParams;
|
|
|
5
5
|
const factory_1 = require("../../../../factory");
|
|
6
6
|
const AGENT_IDENTIFIER_NAME_PASSPORT = 'passport';
|
|
7
7
|
exports.AGENT_IDENTIFIER_NAME_PASSPORT = AGENT_IDENTIFIER_NAME_PASSPORT;
|
|
8
|
+
;
|
|
8
9
|
function createStartParams(params, expiresInSeconds, passport, seller, customerType) {
|
|
9
10
|
// const { broker } = params;
|
|
10
11
|
// let clientUser: Omit<factory.clientUser.IClientUser, 'scope' | 'scopes'> | undefined;
|
|
@@ -20,7 +21,7 @@ function createStartParams(params, expiresInSeconds, passport, seller, customerT
|
|
|
20
21
|
// ...(typeof clientUser?.client_id === 'string') ? { clientUser } : undefined, // discontinue(2026-06-10~)
|
|
21
22
|
// ...(typeof params.object?.name === 'string') ? { name: params.object?.name } : undefined, // discontinue(2026-06-11~)
|
|
22
23
|
// ...(typeof broker?.typeOf === 'string') ? { broker: broker } : undefined, // discontinue(2026-06-22~)
|
|
23
|
-
...(typeof params.object.customer?.typeOf === 'string') ? { customer: params.object.customer } : undefined,
|
|
24
|
+
// ...(!minimizeStartPlaceOrderParams && typeof params.object.customer?.typeOf === 'string') ? { customer: params.object.customer } : undefined, // discontinue(2026-06-26~)
|
|
24
25
|
...(typeof customerType === 'string') ? { customerType } : undefined
|
|
25
26
|
};
|
|
26
27
|
if (typeof seller.id !== 'string') {
|
|
@@ -39,16 +40,28 @@ function createStartParams(params, expiresInSeconds, passport, seller, customerT
|
|
|
39
40
|
// ...(memeberOfPayload !== undefined) ? { memeberOfPayload } : undefined, // discontinue(2026-06-10~)
|
|
40
41
|
identifier: agentIdentifier
|
|
41
42
|
};
|
|
43
|
+
const sellerOfPlaceOrder = {
|
|
44
|
+
id: seller.id,
|
|
45
|
+
name: { ja: String(seller.name.ja) },
|
|
46
|
+
typeOf: seller.typeOf
|
|
47
|
+
};
|
|
42
48
|
return {
|
|
43
49
|
project: { typeOf: seller.project.typeOf, id: seller.project.id },
|
|
44
50
|
typeOf: factory_1.factory.transactionType.PlaceOrder,
|
|
45
51
|
agent,
|
|
46
|
-
seller:
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
+
seller: sellerOfPlaceOrder, // sellerを最小化(2026-06-26~)
|
|
53
|
+
// seller: (minimizeStartPlaceOrderParams)
|
|
54
|
+
// ? {
|
|
55
|
+
// id: seller.id,
|
|
56
|
+
// name: { ja: String(seller.name.ja) },
|
|
57
|
+
// typeOf: seller.typeOf
|
|
58
|
+
// }
|
|
59
|
+
// : {
|
|
60
|
+
// id: seller.id,
|
|
61
|
+
// name: seller.name,
|
|
62
|
+
// typeOf: seller.typeOf,
|
|
63
|
+
// additionalProperty: (Array.isArray(seller.additionalProperty)) ? seller.additionalProperty : [] // 追加特性を追加(2023-08-08~)
|
|
64
|
+
// },
|
|
52
65
|
object: transactionObject,
|
|
53
66
|
expiresInSeconds,
|
|
54
67
|
...(typeof instrument?.id === 'string') ? { instrument } : undefined
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { IssuerRepo } from '../../../repo/issuer';
|
|
2
2
|
import type { MemberRepo } from '../../../repo/member';
|
|
3
3
|
import type { MemberProgramRepo } from '../../../repo/memberProgram';
|
|
4
|
+
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
5
|
+
import type { OrderNumberRepo } from '../../../repo/orderNumber';
|
|
4
6
|
import type { PassportRepo } from '../../../repo/passport';
|
|
7
|
+
import type { ProjectRepo } from '../../../repo/project';
|
|
5
8
|
import type { ProjectMakesOfferRepo } from '../../../repo/projectMakesOffer';
|
|
6
9
|
import type { SellerRepo } from '../../../repo/seller';
|
|
7
10
|
import type { IStartedPlaceOrder, PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
@@ -14,13 +17,15 @@ interface IStartOperationRepos {
|
|
|
14
17
|
projectMakesOffer: ProjectMakesOfferRepo;
|
|
15
18
|
seller: SellerRepo;
|
|
16
19
|
placeOrder: PlaceOrderRepo;
|
|
20
|
+
orderInTransaction: OrderInTransactionRepo;
|
|
21
|
+
project: ProjectRepo;
|
|
22
|
+
orderNumber: OrderNumberRepo;
|
|
17
23
|
}
|
|
18
24
|
type IStartOperation<T> = (repos: IStartOperationRepos) => Promise<T>;
|
|
19
|
-
interface IStartOptions {
|
|
20
|
-
lockPassport: boolean;
|
|
21
|
-
}
|
|
22
25
|
/**
|
|
23
26
|
* 取引開始
|
|
24
27
|
*/
|
|
25
|
-
declare function start(params: IStartPlaceOrderParams, options:
|
|
28
|
+
declare function start(params: IStartPlaceOrderParams, options: {
|
|
29
|
+
saveOrderNumberInPlaceOrderInProgress: boolean;
|
|
30
|
+
}): IStartOperation<IStartedPlaceOrder>;
|
|
26
31
|
export { start, IStartPlaceOrderParams };
|
|
@@ -4,6 +4,7 @@ exports.start = start;
|
|
|
4
4
|
const factory_1 = require("../../../factory");
|
|
5
5
|
const factory_2 = require("./start/factory");
|
|
6
6
|
const validateStartRequest_1 = require("./start/validateStartRequest");
|
|
7
|
+
const issueOrderNumberIfNotExist_1 = require("./issueOrderNumberIfNotExist");
|
|
7
8
|
/**
|
|
8
9
|
* 取引開始
|
|
9
10
|
*/
|
|
@@ -25,7 +26,7 @@ function start(params, options) {
|
|
|
25
26
|
const startParams = (0, factory_2.createStartParams)(params, expiresInSeconds, passport, seller, customerType);
|
|
26
27
|
let transaction;
|
|
27
28
|
// lock passport(2024-07-05~)
|
|
28
|
-
if (
|
|
29
|
+
if (passport !== undefined) {
|
|
29
30
|
try {
|
|
30
31
|
await repos.passport.lock(passport);
|
|
31
32
|
}
|
|
@@ -51,6 +52,22 @@ function start(params, options) {
|
|
|
51
52
|
if (transaction === undefined) {
|
|
52
53
|
transaction = await repos.placeOrder.startPlaceOrder(startParams);
|
|
53
54
|
}
|
|
55
|
+
await (0, issueOrderNumberIfNotExist_1.issueOrderNumberIfNotExist)({
|
|
56
|
+
project: { id: params.project.id },
|
|
57
|
+
id: transaction.id,
|
|
58
|
+
object: { orderDate: new Date() },
|
|
59
|
+
// support createOrderDocument(2026-06-23~)
|
|
60
|
+
creatingOrderInTransaction: {
|
|
61
|
+
seller: {
|
|
62
|
+
id: seller.id,
|
|
63
|
+
name: (typeof seller.name === 'string') ? seller.name : String(seller.name?.ja),
|
|
64
|
+
typeOf: seller.typeOf,
|
|
65
|
+
additionalProperty: (Array.isArray(seller.additionalProperty)) ? seller.additionalProperty : [] // 追加特性を追加(2023-08-08~)
|
|
66
|
+
},
|
|
67
|
+
...((typeof params.object.customer?.typeOf === 'string') && { customer: params.object.customer }),
|
|
68
|
+
...((typeof params.broker?.typeOf === 'string') && { broker: params.broker })
|
|
69
|
+
}
|
|
70
|
+
}, options)(repos);
|
|
54
71
|
return transaction;
|
|
55
72
|
};
|
|
56
73
|
}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { factory } from '../../../factory';
|
|
2
2
|
import type { OrderInTransactionRepo } from '../../../repo/orderInTransaction';
|
|
3
|
-
import type { OrderNumberRepo } from '../../../repo/orderNumber';
|
|
4
|
-
import type { ProjectRepo } from '../../../repo/project';
|
|
5
3
|
import type { PlaceOrderRepo } from '../../../repo/transaction/placeOrder';
|
|
6
4
|
/**
|
|
7
5
|
* 取引人プロフィール更新
|
|
@@ -17,7 +15,5 @@ export declare function updateAgent(params: {
|
|
|
17
15
|
};
|
|
18
16
|
}): (repos: {
|
|
19
17
|
orderInTransaction: OrderInTransactionRepo;
|
|
20
|
-
orderNumber: OrderNumberRepo;
|
|
21
|
-
project: ProjectRepo;
|
|
22
18
|
placeOrder: PlaceOrderRepo;
|
|
23
19
|
}) => Promise<void>;
|
|
@@ -3,8 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.updateAgent = updateAgent;
|
|
4
4
|
const google_libphonenumber_1 = require("google-libphonenumber");
|
|
5
5
|
const factory_1 = require("../../../factory");
|
|
6
|
-
const issueOrderNumberIfNotExist_1 = require("./issueOrderNumberIfNotExist");
|
|
7
|
-
// export type ITransactionOperation<T> = (repos: { transaction: TransactionRepo }) => Promise<T>;
|
|
8
6
|
function fixCustomer(params) {
|
|
9
7
|
return async (repos) => {
|
|
10
8
|
let formattedTelephone;
|
|
@@ -20,7 +18,7 @@ function fixCustomer(params) {
|
|
|
20
18
|
throw new factory_1.factory.errors.Argument('telephone', (error instanceof Error) ? error.message : String(error));
|
|
21
19
|
}
|
|
22
20
|
const transaction = await repos.placeOrder.findPlaceOrderInProgressById({
|
|
23
|
-
typeOf:
|
|
21
|
+
typeOf: factory_1.factory.transactionType.PlaceOrder,
|
|
24
22
|
id: params.id
|
|
25
23
|
}, ['agent', 'object', 'typeOf', 'project']);
|
|
26
24
|
if (transaction.agent.id !== params.agent.id) {
|
|
@@ -29,20 +27,20 @@ function fixCustomer(params) {
|
|
|
29
27
|
// 注文取引の場合、object.customerにも適用
|
|
30
28
|
let customer;
|
|
31
29
|
if (transaction.typeOf === factory_1.factory.transactionType.PlaceOrder) {
|
|
32
|
-
//
|
|
33
|
-
const
|
|
34
|
-
|
|
30
|
+
// orderInTransaction.customer?.typeOfは取引開始時にセットされている前提で再実装(2026-06-24~)
|
|
31
|
+
const customerByTransaction = await repos.orderInTransaction.findCustomerByOrderIdentifier({
|
|
32
|
+
identifier: params.id,
|
|
33
|
+
// project: { id: transaction.project.id }
|
|
34
|
+
});
|
|
35
|
+
// // いったんtransaction.object.customer?.typeOfは取引開始時にセットされている前提
|
|
36
|
+
// const customerByTransaction = transaction.object.customer;
|
|
37
|
+
if (typeof customerByTransaction?.typeOf === 'string') {
|
|
35
38
|
customer = {
|
|
36
|
-
typeOf:
|
|
37
|
-
id:
|
|
38
|
-
...(Array.isArray(
|
|
39
|
-
? { identifier:
|
|
39
|
+
typeOf: customerByTransaction.typeOf,
|
|
40
|
+
id: customerByTransaction.id,
|
|
41
|
+
...(Array.isArray(customerByTransaction.identifier))
|
|
42
|
+
? { identifier: customerByTransaction.identifier }
|
|
40
43
|
: /* istanbul ignore next */ undefined,
|
|
41
|
-
// discontinue(2024-05-16~)
|
|
42
|
-
// ...(transaction.object.customer.typeOf === factory.personType.Person
|
|
43
|
-
// && typeof transaction.object.customer.memberOf?.typeOf === 'string')
|
|
44
|
-
// ? { memberOf: transaction.object.customer.memberOf }
|
|
45
|
-
// : undefined,
|
|
46
44
|
...(Array.isArray(params.agent.additionalProperty))
|
|
47
45
|
? { additionalProperty: params.agent.additionalProperty }
|
|
48
46
|
: /* istanbul ignore next */ undefined,
|
|
@@ -75,11 +73,11 @@ function updateAgent(params) {
|
|
|
75
73
|
const { customer, transaction } = await fixCustomer(params)(repos);
|
|
76
74
|
// also save in orderInTransaction(2024-06-20~)
|
|
77
75
|
if (customer !== undefined) {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
})
|
|
76
|
+
// // 注文ドキュメントを参照(2026-06-24~)
|
|
77
|
+
// const orderNumber = await repos.orderInTransaction.findOrderNumberByIdentifier({
|
|
78
|
+
// identifier: params.id,
|
|
79
|
+
// project: { id: transaction.project.id },
|
|
80
|
+
// }, { onlyPlaceOrder: true });
|
|
83
81
|
const customerName = (typeof customer.name === 'string' && customer.name !== '')
|
|
84
82
|
? customer.name
|
|
85
83
|
: (typeof customer.givenName === 'string' && typeof customer.familyName === 'string'
|
|
@@ -91,8 +89,7 @@ function updateAgent(params) {
|
|
|
91
89
|
identifier: (Array.isArray(customer.identifier)) ? customer.identifier : [],
|
|
92
90
|
...(typeof customerName === 'string') ? { name: customerName } : undefined
|
|
93
91
|
};
|
|
94
|
-
await repos.orderInTransaction.
|
|
95
|
-
orderNumber,
|
|
92
|
+
await repos.orderInTransaction.setCustomerByIdentifier({
|
|
96
93
|
project: transaction.project,
|
|
97
94
|
identifier: params.id,
|
|
98
95
|
customer: customerInOrder
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 注文取引サービス
|
|
3
3
|
*/
|
|
4
|
-
import { POINT_AWARD_IDENTIFIER_NAME } from '../../factory/order';
|
|
5
4
|
import { confirm } from './placeOrder/confirm';
|
|
6
5
|
import { exportTasksById } from './placeOrder/exportTasksById';
|
|
7
6
|
import { start, IStartPlaceOrderParams } from './placeOrder/start';
|
|
8
7
|
import { updateAgent } from './placeOrder/updateAgent';
|
|
9
|
-
export { confirm,
|
|
8
|
+
export { confirm, start, IStartPlaceOrderParams, exportTasksById, updateAgent };
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.updateAgent = exports.exportTasksById = exports.start = exports.
|
|
3
|
+
exports.updateAgent = exports.exportTasksById = exports.start = exports.confirm = void 0;
|
|
4
4
|
/**
|
|
5
5
|
* 注文取引サービス
|
|
6
6
|
*/
|
|
7
|
-
const order_1 = require("../../factory/order");
|
|
8
|
-
Object.defineProperty(exports, "POINT_AWARD_IDENTIFIER_NAME", { enumerable: true, get: function () { return order_1.POINT_AWARD_IDENTIFIER_NAME; } });
|
|
9
7
|
const confirm_1 = require("./placeOrder/confirm");
|
|
10
8
|
Object.defineProperty(exports, "confirm", { enumerable: true, get: function () { return confirm_1.confirm; } });
|
|
11
9
|
const exportTasksById_1 = require("./placeOrder/exportTasksById");
|
|
@@ -28,10 +28,6 @@ export declare function exportOneTransactionTasksIfExists(params: {
|
|
|
28
28
|
* タスク実行日時バッファ
|
|
29
29
|
*/
|
|
30
30
|
runsTasksAfterInSeconds?: number;
|
|
31
|
-
/**
|
|
32
|
-
* support optimizeRedundantTasks(2025-03-11~)
|
|
33
|
-
*/
|
|
34
|
-
optimizeRedundantTasks: boolean;
|
|
35
31
|
status?: {
|
|
36
32
|
$eq?: factory.transactionStatusType;
|
|
37
33
|
};
|
|
@@ -65,7 +65,7 @@ function exportOneTransactionTasksIfExists(params) {
|
|
|
65
65
|
case factory_1.factory.transactionType.PlaceOrder:
|
|
66
66
|
await PlaceOrderTransactionService.exportTasksById({
|
|
67
67
|
id: transaction.id,
|
|
68
|
-
optimizeRedundantTasks: params.optimizeRedundantTasks === true,
|
|
68
|
+
// optimizeRedundantTasks: params.optimizeRedundantTasks === true,
|
|
69
69
|
...(typeof params.runsTasksAfterInSeconds === 'number')
|
|
70
70
|
? { runsTasksAfterInSeconds: params.runsTasksAfterInSeconds }
|
|
71
71
|
: undefined
|
package/lib/chevre/service.d.ts
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import * as AccountTransactionIdentifierFactory from './factory/accountTransactionIdentifier';
|
|
5
5
|
import * as EventFactory from './factory/event';
|
|
6
|
-
import * as OrderFactory from './factory/order';
|
|
7
6
|
import * as ReservedAgentIdentifireNamesFactory from './factory/reservedAgentIdentifireNames';
|
|
8
7
|
import * as TaskIdentifierFactory from './factory/taskIdentifier';
|
|
9
8
|
import * as TransactionFactory from './factory/transaction';
|
|
@@ -60,7 +59,6 @@ export declare namespace transaction {
|
|
|
60
59
|
export declare namespace factory {
|
|
61
60
|
export import accountTransactionIdentifier = AccountTransactionIdentifierFactory;
|
|
62
61
|
export import event = EventFactory;
|
|
63
|
-
export import order = OrderFactory;
|
|
64
62
|
export import reservedAgentIdentifireNames = ReservedAgentIdentifireNamesFactory;
|
|
65
63
|
export import taskIdentifier = TaskIdentifierFactory;
|
|
66
64
|
export import transaction = TransactionFactory;
|
package/lib/chevre/service.js
CHANGED
|
@@ -40,7 +40,6 @@ exports.factory = exports.transaction = exports.task = exports.reserve = exports
|
|
|
40
40
|
*/
|
|
41
41
|
const AccountTransactionIdentifierFactory = __importStar(require("./factory/accountTransactionIdentifier"));
|
|
42
42
|
const EventFactory = __importStar(require("./factory/event"));
|
|
43
|
-
const OrderFactory = __importStar(require("./factory/order"));
|
|
44
43
|
const ReservedAgentIdentifireNamesFactory = __importStar(require("./factory/reservedAgentIdentifireNames"));
|
|
45
44
|
const TaskIdentifierFactory = __importStar(require("./factory/taskIdentifier"));
|
|
46
45
|
const TransactionFactory = __importStar(require("./factory/transaction"));
|
|
@@ -183,7 +182,6 @@ var factory;
|
|
|
183
182
|
(function (factory) {
|
|
184
183
|
factory.accountTransactionIdentifier = AccountTransactionIdentifierFactory;
|
|
185
184
|
factory.event = EventFactory;
|
|
186
|
-
factory.order = OrderFactory;
|
|
187
185
|
factory.reservedAgentIdentifireNames = ReservedAgentIdentifireNamesFactory;
|
|
188
186
|
factory.taskIdentifier = TaskIdentifierFactory;
|
|
189
187
|
factory.transaction = TransactionFactory;
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "9.
|
|
14
|
+
"@chevre/factory": "9.3.0",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"postversion": "git push origin --tags",
|
|
92
92
|
"prepublishOnly": "npm run clean && npm run build"
|
|
93
93
|
},
|
|
94
|
-
"version": "25.0.0
|
|
94
|
+
"version": "25.0.0"
|
|
95
95
|
}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AWARD_ACCOUNTS_IDENTIFIER_NAME = exports.POINT_AWARD_IDENTIFIER_NAME = void 0;
|
|
4
|
-
exports.POINT_AWARD_IDENTIFIER_NAME = 'pointAwardIdentifiers';
|
|
5
|
-
exports.AWARD_ACCOUNTS_IDENTIFIER_NAME = 'awardAccounts';
|