@chevre/domain 21.7.0-alpha.9 → 21.8.0-alpha.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/example/src/chevre/countDelayedTasks.ts +1 -1
- package/example/src/chevre/createDeleteTransactionTasks.ts +108 -0
- package/example/src/chevre/createDeleteTransactionTasksIfNotExist.ts +98 -0
- package/example/src/chevre/deleteRunsAtPassedCertainPeriod.ts +28 -0
- package/example/src/chevre/deleteTasksByName.ts +1 -1
- package/example/src/chevre/migrateAuthorizePaymentActionResult.ts +1 -1
- package/example/src/chevre/migrateOwnershipInfos2newUserPool.ts +4 -1
- package/example/src/chevre/unsetUnnecessaryFields.ts +1 -1
- package/lib/chevre/emailMessageBuilder.js +2 -1
- package/lib/chevre/repo/assetTransaction.js +22 -23
- package/lib/chevre/repo/mongoose/schemas/offer.d.ts +4 -4
- package/lib/chevre/repo/mongoose/schemas/offer.js +5 -6
- package/lib/chevre/repo/project.d.ts +1 -0
- package/lib/chevre/repo/project.js +10 -4
- package/lib/chevre/repo/task.d.ts +6 -2
- package/lib/chevre/repo/task.js +25 -1
- package/lib/chevre/repo/transaction.d.ts +25 -1
- package/lib/chevre/repo/transaction.js +6 -1
- package/lib/chevre/service/notification.js +13 -6
- package/lib/chevre/service/order/onOrderStatusChanged/factory.d.ts +20 -0
- package/lib/chevre/service/order/onOrderStatusChanged/factory.js +242 -1
- package/lib/chevre/service/order/onOrderStatusChanged.d.ts +2 -1
- package/lib/chevre/service/order/onOrderStatusChanged.js +139 -110
- package/lib/chevre/service/order/payOrder.d.ts +23 -0
- package/lib/chevre/service/order/payOrder.js +74 -0
- package/lib/chevre/service/order/placeOrder.d.ts +1 -3
- package/lib/chevre/service/order/placeOrder.js +33 -76
- package/lib/chevre/service/order/returnOrder.d.ts +1 -2
- package/lib/chevre/service/order/returnOrder.js +15 -97
- package/lib/chevre/service/order/sendOrder.d.ts +0 -1
- package/lib/chevre/service/order/sendOrder.js +6 -68
- package/lib/chevre/service/payment/any/factory.js +3 -2
- package/lib/chevre/service/task/confirmPayTransaction.js +56 -0
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.d.ts +1 -1
- package/lib/chevre/service/task/confirmRegisterServiceTransaction.js +6 -6
- package/lib/chevre/service/transaction/moneyTransfer/factory.js +1 -5
- package/lib/chevre/service/transaction/moneyTransfer.js +0 -1
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +12 -6
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.d.ts +4 -0
- package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js +92 -88
- package/lib/chevre/service/transaction/placeOrderInProgress/result.js +1 -1
- package/lib/chevre/service/transaction/placeOrderInProgress.js +0 -2
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +8 -1
- package/lib/chevre/service/transaction/returnOrder/potentialActions.js +7 -4
- package/lib/chevre/service/transaction/returnOrder.js +0 -1
- package/lib/chevre/settings.d.ts +1 -1
- package/lib/chevre/settings.js +2 -2
- package/package.json +3 -3
- package/example/src/chevre/checkOrderMembershipTasks.ts +0 -127
- package/example/src/chevre/transaction/callOrderMembershipServiceTask.ts +0 -65
- package/example/src/chevre/transaction/orderMembershipService.ts +0 -105
- package/lib/chevre/service/task/orderProgramMembership.d.ts +0 -6
- package/lib/chevre/service/task/orderProgramMembership.js +0 -98
- package/lib/chevre/service/transaction/orderProgramMembership.d.ts +0 -50
- package/lib/chevre/service/transaction/orderProgramMembership.js +0 -349
package/lib/chevre/service/transaction/placeOrderInProgress/potentialActions/registerService.js
CHANGED
|
@@ -10,7 +10,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.createRegisterServiceActions = void 0;
|
|
13
|
-
const moment = require("moment");
|
|
14
13
|
const factory = require("../../../../factory");
|
|
15
14
|
const availableProductTypes_1 = require("../../../../factory/availableProductTypes");
|
|
16
15
|
const order_1 = require("../../../../factory/order");
|
|
@@ -47,20 +46,22 @@ function createRegisterServiceActions(params) {
|
|
|
47
46
|
transaction: params.transaction,
|
|
48
47
|
transactionNumber: (_a = a.instrument) === null || _a === void 0 ? void 0 : _a.transactionNumber
|
|
49
48
|
});
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
});
|
|
49
|
+
// 廃止(2023-08-18~)
|
|
50
|
+
// const orderProgramMembershipTask = createOrderProgramMembershipTask({
|
|
51
|
+
// order: params.order,
|
|
52
|
+
// authorizeAction: a
|
|
53
|
+
// });
|
|
55
54
|
registerServiceActions.push({
|
|
56
55
|
project: params.transaction.project,
|
|
57
56
|
typeOf: factory.actionType.ConfirmAction,
|
|
58
57
|
object: registerServiceObject,
|
|
59
58
|
agent: params.transaction.project,
|
|
60
59
|
purpose: registerServicePurpose,
|
|
61
|
-
potentialActions:
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
potentialActions: {
|
|
61
|
+
// ...(orderProgramMembershipTask !== undefined)
|
|
62
|
+
// ? { orderProgramMembership: [orderProgramMembershipTask] }
|
|
63
|
+
// : undefined
|
|
64
|
+
}
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
});
|
|
@@ -80,82 +81,85 @@ function createRegisterServiceActionObject(params) {
|
|
|
80
81
|
* ssktsへの互換性対応として
|
|
81
82
|
* 次回メンバーシップ注文タスクを作成する
|
|
82
83
|
*/
|
|
83
|
-
function createOrderProgramMembershipTask(params
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
84
|
+
// function createOrderProgramMembershipTask(params: {
|
|
85
|
+
// order: factory.order.IOrder;
|
|
86
|
+
// authorizeAction: factory.action.authorize.offer.product.IAction;
|
|
87
|
+
// }): factory.task.IAttributes<factory.taskName.OrderProgramMembership> | undefined {
|
|
88
|
+
// let orderMembershipTask: factory.task.IAttributes<factory.taskName.OrderProgramMembership> | undefined;
|
|
89
|
+
// const acceptedOffer = params.authorizeAction.object[0];
|
|
90
|
+
// // ssktsへの互換性対応なので、限定的に(暫定対応のautomaticRenewal設定で判定)
|
|
91
|
+
// const serviceOutput = acceptedOffer.itemOffered.serviceOutput;
|
|
92
|
+
// if (acceptedOffer.itemOffered.typeOf === factory.product.ProductType.MembershipService
|
|
93
|
+
// && typeof serviceOutput?.typeOf === 'string'
|
|
94
|
+
// && serviceOutput.typeOf.length > 0
|
|
95
|
+
// && serviceOutput.automaticRenewal === true) {
|
|
96
|
+
// const memebershipFor: Pick<factory.product.IProduct, 'project' | 'typeOf' | 'id'> = {
|
|
97
|
+
// project: { typeOf: factory.organizationType.Project, id: params.order.project.id },
|
|
98
|
+
// typeOf: acceptedOffer.itemOffered.typeOf,
|
|
99
|
+
// id: String(acceptedOffer.itemOffered.id)
|
|
100
|
+
// };
|
|
101
|
+
// const orderMembershipObject: factory.task.orderProgramMembership.IAcceptedOffer = {
|
|
102
|
+
// seller: { id: String(acceptedOffer.seller.id) },
|
|
103
|
+
// typeOf: acceptedOffer.typeOf,
|
|
104
|
+
// itemOffered: {
|
|
105
|
+
// typeOf: serviceOutput.typeOf,
|
|
106
|
+
// name: (typeof serviceOutput.name === 'string') ? serviceOutput.name : serviceOutput.typeOf,
|
|
107
|
+
// issuedThrough: { id: String(memebershipFor.id), typeOf: factory.product.ProductType.MembershipService }
|
|
108
|
+
// },
|
|
109
|
+
// id: String(acceptedOffer.id),
|
|
110
|
+
// identifier: String(acceptedOffer.identifier)
|
|
111
|
+
// };
|
|
112
|
+
// // 次回のメンバーシップ注文タスクを生成
|
|
113
|
+
// const orderProgramMembershipTaskData: factory.task.IData<factory.taskName.OrderProgramMembership> = {
|
|
114
|
+
// // 最低限の情報のみagentに設定
|
|
115
|
+
// agent: {
|
|
116
|
+
// typeOf: factory.personType.Person,
|
|
117
|
+
// id: params.order.customer.id,
|
|
118
|
+
// // transaction.agent.identifierにissがあれば情報を引き継ぐ
|
|
119
|
+
// identifier: (Array.isArray(params.order.customer.identifier))
|
|
120
|
+
// ? params.order.customer.identifier
|
|
121
|
+
// : []
|
|
122
|
+
// },
|
|
123
|
+
// object: orderMembershipObject,
|
|
124
|
+
// project: params.order.project,
|
|
125
|
+
// typeOf: factory.actionType.OrderAction
|
|
126
|
+
// };
|
|
127
|
+
// // どういう期間でいくらのオファーなのか
|
|
128
|
+
// const priceSpec = <factory.compoundPriceSpecification.IPriceSpecification<factory.priceSpecificationType>>
|
|
129
|
+
// acceptedOffer.priceSpecification;
|
|
130
|
+
// if (priceSpec === undefined) {
|
|
131
|
+
// throw new factory.errors.NotFound('Order.acceptedOffers.priceSpecification');
|
|
132
|
+
// }
|
|
133
|
+
// const unitPriceSpec =
|
|
134
|
+
// <factory.priceSpecification.IPriceSpecification<factory.priceSpecificationType.UnitPriceSpecification>>
|
|
135
|
+
// priceSpec.priceComponent.find(
|
|
136
|
+
// (p) => p.typeOf === factory.priceSpecificationType.UnitPriceSpecification
|
|
137
|
+
// );
|
|
138
|
+
// if (unitPriceSpec === undefined) {
|
|
139
|
+
// throw new factory.errors.NotFound('Unit Price Specification in Order.acceptedOffers.priceSpecification');
|
|
140
|
+
// }
|
|
141
|
+
// // 期間単位としては秒のみ実装
|
|
142
|
+
// if (unitPriceSpec.referenceQuantity.unitCode !== factory.unitCode.Sec) {
|
|
143
|
+
// throw new factory.errors.NotImplemented('Only \'SEC\' is implemented for priceSpecification.referenceQuantity.unitCode ');
|
|
144
|
+
// }
|
|
145
|
+
// const referenceQuantityValue = unitPriceSpec.referenceQuantity.value;
|
|
146
|
+
// if (typeof referenceQuantityValue !== 'number') {
|
|
147
|
+
// throw new factory.errors.NotFound('Order.acceptedOffers.priceSpecification.referenceQuantity.value');
|
|
148
|
+
// }
|
|
149
|
+
// // プログラム更新日時は、今回のプログラムの所有期限
|
|
150
|
+
// const runsAt = moment(params.order.orderDate)
|
|
151
|
+
// .add(referenceQuantityValue, 'seconds')
|
|
152
|
+
// .toDate();
|
|
153
|
+
// orderMembershipTask = {
|
|
154
|
+
// data: orderProgramMembershipTaskData,
|
|
155
|
+
// executionResults: [],
|
|
156
|
+
// name: <factory.taskName.OrderProgramMembership>factory.taskName.OrderProgramMembership,
|
|
157
|
+
// numberOfTried: 0,
|
|
158
|
+
// project: params.order.project,
|
|
159
|
+
// remainingNumberOfTries: 10,
|
|
160
|
+
// runsAt: runsAt,
|
|
161
|
+
// status: factory.taskStatus.Ready
|
|
162
|
+
// };
|
|
163
|
+
// }
|
|
164
|
+
// return orderMembershipTask;
|
|
165
|
+
// }
|
|
@@ -81,7 +81,7 @@ function createPaymentMethods(params) {
|
|
|
81
81
|
if (typeof paymentMethodType !== 'string') {
|
|
82
82
|
throw new factory.errors.NotFound('authorizePaymentAction.result.paymentMethodAsObject.typeOf');
|
|
83
83
|
}
|
|
84
|
-
paymentMethods.push(Object.assign({ accountId: result.accountId, additionalProperty: (Array.isArray(result.additionalProperty)) ? result.additionalProperty : [], issuedThrough: result.issuedThrough, name: result.name, paymentMethodId: result.paymentMethodId, totalPaymentDue: result.totalPaymentDue, typeOf: paymentMethodType }, (paymentMethodOfInvoice !== undefined) ? { paymentMethod: paymentMethodOfInvoice } : undefined));
|
|
84
|
+
paymentMethods.push(Object.assign({ accountId: result.accountId, additionalProperty: (Array.isArray(result.additionalProperty)) ? result.additionalProperty : [], issuedThrough: result.issuedThrough, name: result.name, paymentMethodId: result.paymentMethodId, paymentStatus: result.paymentStatus, totalPaymentDue: result.totalPaymentDue, typeOf: paymentMethodType }, (paymentMethodOfInvoice !== undefined) ? { paymentMethod: paymentMethodOfInvoice } : undefined));
|
|
85
85
|
});
|
|
86
86
|
// 決済方法から注文金額の計算
|
|
87
87
|
// price += authorizePaymentActions
|
|
@@ -56,6 +56,13 @@ function createTasks(params) {
|
|
|
56
56
|
if (Array.isArray(returnOrderPotentialActions)) {
|
|
57
57
|
// 返品タスク
|
|
58
58
|
const returnOrderTask = returnOrderPotentialActions.map((r) => {
|
|
59
|
+
// data最適化(2023-08-22~)
|
|
60
|
+
const returnOrderTaskData = {
|
|
61
|
+
agent: r.agent,
|
|
62
|
+
object: r.object,
|
|
63
|
+
project: transaction.project,
|
|
64
|
+
typeOf: r.typeOf
|
|
65
|
+
};
|
|
59
66
|
return {
|
|
60
67
|
project: transaction.project,
|
|
61
68
|
name: factory.taskName.ReturnOrder,
|
|
@@ -64,7 +71,7 @@ function createTasks(params) {
|
|
|
64
71
|
remainingNumberOfTries: 10,
|
|
65
72
|
numberOfTried: 0,
|
|
66
73
|
executionResults: [],
|
|
67
|
-
data:
|
|
74
|
+
data: returnOrderTaskData
|
|
68
75
|
};
|
|
69
76
|
});
|
|
70
77
|
taskAttributes.push(...returnOrderTask);
|
|
@@ -52,7 +52,6 @@ function createPotentialActions(params) {
|
|
|
52
52
|
},
|
|
53
53
|
// mask
|
|
54
54
|
customer: (0, order_1.createMaskedCustomer)(order, { noProfile: true }),
|
|
55
|
-
// confirmationNumber: order.confirmationNumber,
|
|
56
55
|
orderNumber: order.orderNumber,
|
|
57
56
|
price: order.price,
|
|
58
57
|
priceCurrency: order.priceCurrency,
|
|
@@ -60,9 +59,13 @@ function createPotentialActions(params) {
|
|
|
60
59
|
dateReturned: params.dateReturned
|
|
61
60
|
};
|
|
62
61
|
// recipientを最低限の情報に
|
|
63
|
-
const recipient
|
|
62
|
+
// const recipient: factory.action.IParticipantAsSeller = {
|
|
63
|
+
// id: order.seller.id,
|
|
64
|
+
// typeOf: order.seller.typeOf,
|
|
65
|
+
// ...(order.seller.name !== undefined) ? { name: order.seller.name } : undefined
|
|
66
|
+
// };
|
|
64
67
|
return {
|
|
65
|
-
project: order.project,
|
|
68
|
+
// project: order.project,
|
|
66
69
|
typeOf: factory.actionType.ReturnAction,
|
|
67
70
|
object: returnOrderObject,
|
|
68
71
|
// ↓agentは注文のreturnerに反映される
|
|
@@ -70,7 +73,7 @@ function createPotentialActions(params) {
|
|
|
70
73
|
typeOf: params.transaction.agent.typeOf,
|
|
71
74
|
id: params.transaction.agent.id
|
|
72
75
|
},
|
|
73
|
-
recipient,
|
|
76
|
+
// recipient,
|
|
74
77
|
potentialActions: potentialActionsOnReturnOrder
|
|
75
78
|
};
|
|
76
79
|
})));
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -34,7 +34,6 @@ export type ISettings = factory.project.ISettings & {
|
|
|
34
34
|
useAggregateOfferProjects: string[];
|
|
35
35
|
useOfferRateLimitProjects: string[];
|
|
36
36
|
};
|
|
37
|
-
export declare const DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD: string;
|
|
38
37
|
export declare const DEFAULT_TASKS_EXPORT_AGENT_NAME: string;
|
|
39
38
|
export declare const USE_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
40
39
|
export declare const USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING: boolean;
|
|
@@ -42,6 +41,7 @@ export declare const USE_NEW_EVENT_AVAILABILITY_KEY_FROM: moment.Moment;
|
|
|
42
41
|
export declare const USE_ADVANCE_BOOKING_REQUIREMENT: boolean;
|
|
43
42
|
export declare const USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT: boolean;
|
|
44
43
|
export declare const USE_DELETE_EVENT_BY_ORDER: boolean;
|
|
44
|
+
export declare const USE_CUSTOM_SENDER_EMAIL: boolean;
|
|
45
45
|
export declare const INFORM_RESERVATION_TASK_DELAY_IN_SECONDS: number;
|
|
46
46
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
47
47
|
/**
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.
|
|
3
|
+
exports.settings = exports.MONGO_MAX_TIME_MS = exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = exports.USE_CUSTOM_SENDER_EMAIL = exports.USE_DELETE_EVENT_BY_ORDER = exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = exports.USE_ADVANCE_BOOKING_REQUIREMENT = exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = exports.DEFAULT_SENDER_EMAIL = exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = exports.TRANSACTION_CONFIRMED_STORAGE_PERIOD_IN_DAYS = exports.ASSET_TRANSACTION_STORAGE_PERIOD_IN_DAYS = exports.ABORTED_TASKS_WITHOUT_REPORT = exports.TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = exports.TRIGGER_WEBHOOK_MAX_RETRY_COUNT = void 0;
|
|
4
4
|
const moment = require("moment");
|
|
5
5
|
const factory = require("./factory");
|
|
6
6
|
const transactionWebhookUrls = (typeof process.env.INFORM_TRANSACTION_URL === 'string')
|
|
@@ -58,7 +58,6 @@ exports.TRANSACTION_CANCELED_STORAGE_PERIOD_IN_DAYS = (typeof process.env.TRANSA
|
|
|
58
58
|
// tslint:disable-next-line:no-magic-numbers
|
|
59
59
|
: 7;
|
|
60
60
|
exports.DEFAULT_SENDER_EMAIL = process.env.DEFAULT_SENDER_EMAIL;
|
|
61
|
-
exports.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD = String(process.env.DEFAULT_PAYMENT_METHOD_TYPE_FOR_CREDIT_CARD);
|
|
62
61
|
exports.DEFAULT_TASKS_EXPORT_AGENT_NAME = `${process.env.GAE_APPLICATION}:${process.env.GAE_SERVICE}:jobs`;
|
|
63
62
|
exports.USE_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
|
|
64
63
|
exports.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING = process.env.USE_PAY_ASSET_TRANSACTION_SYNC_PROCESSING === '1';
|
|
@@ -74,6 +73,7 @@ exports.USE_NEW_EVENT_AVAILABILITY_KEY_FROM = (typeof process.env.USE_NEW_EVENT_
|
|
|
74
73
|
exports.USE_ADVANCE_BOOKING_REQUIREMENT = process.env.USE_ADVANCE_BOOKING_REQUIREMENT === '1';
|
|
75
74
|
exports.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT = process.env.USE_OBJECT_AS_PAY_TRANSACTION_AMOUNT === '1';
|
|
76
75
|
exports.USE_DELETE_EVENT_BY_ORDER = process.env.USE_DELETE_EVENT_BY_ORDER === '1';
|
|
76
|
+
exports.USE_CUSTOM_SENDER_EMAIL = process.env.USE_CUSTOM_SENDER_EMAIL === '1';
|
|
77
77
|
exports.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS = (typeof process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS === 'string')
|
|
78
78
|
? Number(process.env.INFORM_RESERVATION_TASK_DELAY_IN_SECONDS)
|
|
79
79
|
: 0;
|
package/package.json
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
}
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@chevre/factory": "4.
|
|
13
|
-
"@cinerino/sdk": "3.
|
|
12
|
+
"@chevre/factory": "4.327.0-alpha.1",
|
|
13
|
+
"@cinerino/sdk": "3.165.0",
|
|
14
14
|
"@motionpicture/coa-service": "9.2.0",
|
|
15
15
|
"@motionpicture/gmo-service": "5.2.0",
|
|
16
16
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -117,5 +117,5 @@
|
|
|
117
117
|
"postversion": "git push origin --tags",
|
|
118
118
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
119
119
|
},
|
|
120
|
-
"version": "21.
|
|
120
|
+
"version": "21.8.0-alpha.0"
|
|
121
121
|
}
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
// import * as moment from 'moment';
|
|
3
|
-
import * as mongoose from 'mongoose';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../lib/index';
|
|
6
|
-
|
|
7
|
-
import { migrateUser } from './migrateCognitoUser';
|
|
8
|
-
|
|
9
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
10
|
-
export const USERPOOL_ID_OLD = String(process.env.USERPOOL_ID_OLD);
|
|
11
|
-
export const USERPOOL_ID_NEW = String(process.env.USERPOOL_ID_NEW);
|
|
12
|
-
export const ISS_PREFIX = 'https://cognito-idp.ap-northeast-1.amazonaws.com/';
|
|
13
|
-
|
|
14
|
-
// tslint:disable-next-line:max-func-body-length
|
|
15
|
-
export async function main() {
|
|
16
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI);
|
|
17
|
-
|
|
18
|
-
const taskRepo = new chevre.repository.Task(mongoose.connection);
|
|
19
|
-
|
|
20
|
-
// const now = new Date();
|
|
21
|
-
const cursor = await taskRepo.taskModel.find(
|
|
22
|
-
{
|
|
23
|
-
// _id: { $eq: '60398ca3bdadde000a308709' },
|
|
24
|
-
status: { $eq: chevre.factory.taskStatus.Ready },
|
|
25
|
-
name: { $eq: chevre.factory.taskName.OrderProgramMembership },
|
|
26
|
-
'project.id': { $eq: project.id }
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
// _id: 1,
|
|
30
|
-
}
|
|
31
|
-
)
|
|
32
|
-
.sort({ runsAt: chevre.factory.sortType.Ascending })
|
|
33
|
-
.cursor();
|
|
34
|
-
console.log('tasks found');
|
|
35
|
-
|
|
36
|
-
let i = 0;
|
|
37
|
-
let notFoundCount = 0;
|
|
38
|
-
let updateCount = 0;
|
|
39
|
-
await cursor.eachAsync(async (doc) => {
|
|
40
|
-
i += 1;
|
|
41
|
-
const task = <chevre.factory.task.ITask<chevre.factory.taskName.OrderProgramMembership>>doc.toObject();
|
|
42
|
-
|
|
43
|
-
const owner = <chevre.factory.person.IPerson>task.data.agent;
|
|
44
|
-
let iss =
|
|
45
|
-
(<chevre.factory.propertyValue.IPropertyValue<string>[] | undefined>owner.identifier)?.find((p) => p.name === 'iss')?.value;
|
|
46
|
-
if (typeof iss === 'string') {
|
|
47
|
-
iss = iss.replace(ISS_PREFIX, '');
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
// 新会員ならok
|
|
51
|
-
if (iss === USERPOOL_ID_NEW) {
|
|
52
|
-
console.log('already new userPool', task.runsAt, i, notFoundCount);
|
|
53
|
-
} else {
|
|
54
|
-
// 旧会員の場合、新会員の存在確認
|
|
55
|
-
console.log(
|
|
56
|
-
'checking...',
|
|
57
|
-
task.runsAt,
|
|
58
|
-
owner.id, owner.memberOf?.membershipNumber, i, notFoundCount);
|
|
59
|
-
const personRepo = new chevre.repository.Person({ userPoolId: USERPOOL_ID_NEW });
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
const newUserAttributes = await personRepo.getUserAttributes({ username: `SSKTS_${owner.id}` });
|
|
63
|
-
const newUserId = newUserAttributes.additionalProperty?.find((p) => p.name === 'sub')?.value;
|
|
64
|
-
const person = await personRepo.findById({ userId: String(newUserId) });
|
|
65
|
-
console.log(
|
|
66
|
-
'found',
|
|
67
|
-
task.runsAt,
|
|
68
|
-
owner.id,
|
|
69
|
-
owner.memberOf?.membershipNumber,
|
|
70
|
-
person.id, i, notFoundCount);
|
|
71
|
-
|
|
72
|
-
// 所有権の所有者を新会員に置換
|
|
73
|
-
const newOwner: chevre.factory.person.IPerson = {
|
|
74
|
-
...owner,
|
|
75
|
-
id: person.id,
|
|
76
|
-
identifier: [
|
|
77
|
-
...(Array.isArray(person.identifier)) ? person.identifier : [],
|
|
78
|
-
// 手動移行した証拠を残す
|
|
79
|
-
{ name: 'dataAgentMigratedManually', value: '1' }
|
|
80
|
-
]
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
updateCount += 1;
|
|
84
|
-
console.log(
|
|
85
|
-
'updating data.agent...',
|
|
86
|
-
task.runsAt,
|
|
87
|
-
owner.id,
|
|
88
|
-
owner.memberOf?.membershipNumber,
|
|
89
|
-
person.id, i, notFoundCount, updateCount);
|
|
90
|
-
const result = await taskRepo.taskModel.updateOne(
|
|
91
|
-
{ _id: task.id },
|
|
92
|
-
{ 'data.agent': newOwner }
|
|
93
|
-
)
|
|
94
|
-
.exec();
|
|
95
|
-
console.log(
|
|
96
|
-
'data.agent updated',
|
|
97
|
-
task.runsAt,
|
|
98
|
-
owner.id,
|
|
99
|
-
owner.memberOf?.membershipNumber,
|
|
100
|
-
person.id, i, notFoundCount, updateCount,
|
|
101
|
-
result);
|
|
102
|
-
|
|
103
|
-
} catch (error) {
|
|
104
|
-
// NotFoundエラーは、新ユーザープールでのユーザーがまだ存在しないだけ
|
|
105
|
-
if (error.code === 'UserNotFoundException') {
|
|
106
|
-
notFoundCount += 1;
|
|
107
|
-
console.log(
|
|
108
|
-
'not found',
|
|
109
|
-
task.runsAt,
|
|
110
|
-
owner.id, owner.memberOf?.membershipNumber, i, notFoundCount);
|
|
111
|
-
// migrateUser
|
|
112
|
-
await migrateUser({ id: owner.id });
|
|
113
|
-
} else {
|
|
114
|
-
throw error;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
console.log(i, 'infos checked');
|
|
121
|
-
console.log(notFoundCount, 'people not found');
|
|
122
|
-
console.log(updateCount, 'tasks updated');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
main()
|
|
126
|
-
.then()
|
|
127
|
-
.catch(console.error);
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
// tslint:disable:no-console
|
|
2
|
-
import * as mongoose from 'mongoose';
|
|
3
|
-
import * as redis from 'redis';
|
|
4
|
-
|
|
5
|
-
import { chevre } from '../../../../lib/index';
|
|
6
|
-
|
|
7
|
-
import { call } from '../../../../lib/chevre/service/task/orderProgramMembership';
|
|
8
|
-
|
|
9
|
-
const project = { id: String(process.env.PROJECT_ID) };
|
|
10
|
-
async function main() {
|
|
11
|
-
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
-
|
|
13
|
-
const redisClient = redis.createClient<redis.RedisDefaultModules, Record<string, never>, Record<string, never>>({
|
|
14
|
-
socket: {
|
|
15
|
-
port: Number(<string>process.env.REDIS_PORT),
|
|
16
|
-
host: <string>process.env.REDIS_HOST
|
|
17
|
-
},
|
|
18
|
-
password: <string>process.env.REDIS_KEY
|
|
19
|
-
});
|
|
20
|
-
await redisClient.connect();
|
|
21
|
-
|
|
22
|
-
const result = await call(
|
|
23
|
-
{
|
|
24
|
-
agent: {
|
|
25
|
-
typeOf: chevre.factory.personType.Person,
|
|
26
|
-
id: 'b2bc2b6d-aea2-41fc-9f6e-e4ec89c11d2e',
|
|
27
|
-
identifier: [
|
|
28
|
-
{
|
|
29
|
-
name: 'iss',
|
|
30
|
-
value: String(process.env.ISS)
|
|
31
|
-
}
|
|
32
|
-
]
|
|
33
|
-
},
|
|
34
|
-
object: {
|
|
35
|
-
seller: {
|
|
36
|
-
id: '5d0abf30ac3fb200198ebb2c'
|
|
37
|
-
},
|
|
38
|
-
typeOf: chevre.factory.offerType.Offer,
|
|
39
|
-
itemOffered: {
|
|
40
|
-
typeOf: chevre.factory.permit.PermitType.Permit,
|
|
41
|
-
name: '[development]会員ポイントプログラム',
|
|
42
|
-
issuedThrough: {
|
|
43
|
-
id: '5afff104d51e59232c7b481b',
|
|
44
|
-
typeOf: chevre.factory.product.ProductType.MembershipService
|
|
45
|
-
}
|
|
46
|
-
},
|
|
47
|
-
id: '7k9f3ht34',
|
|
48
|
-
identifier: 'AnnualPlan'
|
|
49
|
-
},
|
|
50
|
-
project: {
|
|
51
|
-
typeOf: chevre.factory.organizationType.Project,
|
|
52
|
-
id: project.id
|
|
53
|
-
},
|
|
54
|
-
typeOf: chevre.factory.actionType.OrderAction
|
|
55
|
-
}
|
|
56
|
-
)({
|
|
57
|
-
connection: mongoose.connection,
|
|
58
|
-
redisClient
|
|
59
|
-
});
|
|
60
|
-
console.log(result);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
main()
|
|
64
|
-
.then(console.log)
|
|
65
|
-
.catch(console.error);
|