@chevre/domain 22.9.0-alpha.10 → 22.9.0-alpha.11
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/migratePaymentServiceInformActionMovieTicket.ts +115 -0
- package/example/src/chevre/{migratePaymentServiceContactPointMovieTicket.ts → migratePaymentServicePotentialActions.ts} +36 -14
- package/lib/chevre/repo/mongoose/schemas/assetTransaction.js +2 -2
- package/lib/chevre/repo/potentialAction.js +2 -1
- package/lib/chevre/repo/seller.d.ts +4 -4
- package/lib/chevre/service/assetTransaction/fixInformAction.d.ts +3 -1
- package/lib/chevre/service/assetTransaction/fixInformAction.js +10 -2
- package/lib/chevre/service/assetTransaction/pay/factory.d.ts +3 -1
- package/lib/chevre/service/assetTransaction/pay/factory.js +9 -2
- package/lib/chevre/service/assetTransaction/refund/factory.d.ts +3 -1
- package/lib/chevre/service/assetTransaction/refund/factory.js +9 -10
- package/lib/chevre/service/assetTransaction/refund/potentialActions.js +4 -8
- package/lib/chevre/service/notification.d.ts +2 -0
- package/lib/chevre/service/notification.js +16 -10
- package/lib/chevre/service/payment/any/onPaid.js +4 -4
- package/lib/chevre/service/payment/any/onRefund.js +4 -4
- package/lib/chevre/service/payment/factory.d.ts +1 -1
- package/lib/chevre/service/payment/factory.js +4 -8
- package/lib/chevre/service/task/triggerWebhook.js +2 -2
- package/package.json +3 -3
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
// tslint:disable:no-console
|
|
2
|
+
import * as mongoose from 'mongoose';
|
|
3
|
+
|
|
4
|
+
import { chevre } from '../../../lib/index';
|
|
5
|
+
|
|
6
|
+
// const project = { id: String(process.env.PROJECT_ID) };
|
|
7
|
+
// const excludedProject = { id: String(process.env.EXCLUDED_PROJECT_ID) };
|
|
8
|
+
|
|
9
|
+
// tslint:disable-next-line:max-func-body-length
|
|
10
|
+
async function main() {
|
|
11
|
+
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
|
+
|
|
13
|
+
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
14
|
+
const potentialActionRepo = await chevre.repository.PotentialAction.createInstance(mongoose.connection);
|
|
15
|
+
|
|
16
|
+
const cursor = paymentServiceRepo.getCursor(
|
|
17
|
+
{
|
|
18
|
+
typeOf: { $eq: chevre.factory.service.paymentService.PaymentServiceType.MovieTicket }
|
|
19
|
+
// _id: { $eq: 'cinerino' }
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
_id: 1,
|
|
23
|
+
availableChannel: 1,
|
|
24
|
+
productID: 1,
|
|
25
|
+
project: 1,
|
|
26
|
+
typeOf: 1,
|
|
27
|
+
potentialAction: 1
|
|
28
|
+
}
|
|
29
|
+
);
|
|
30
|
+
console.log('docs found');
|
|
31
|
+
|
|
32
|
+
let i = 0;
|
|
33
|
+
let updateCount = 0;
|
|
34
|
+
let recipientUrls: string[] = [];
|
|
35
|
+
const unexpectedProjectIds: string[] = [];
|
|
36
|
+
await cursor.eachAsync(async (doc) => {
|
|
37
|
+
i += 1;
|
|
38
|
+
const paymentService: Pick<
|
|
39
|
+
chevre.factory.service.paymentService.IService,
|
|
40
|
+
'availableChannel' | 'id' | 'productID' | 'project' | 'typeOf' | 'potentialAction'
|
|
41
|
+
> = doc.toObject();
|
|
42
|
+
|
|
43
|
+
console.log(
|
|
44
|
+
'alreadyMigrated?', paymentService.project.id, i);
|
|
45
|
+
if (typeof paymentService.id !== 'string') {
|
|
46
|
+
throw new Error('id must be string');
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
let alreadyMigrated = false;
|
|
50
|
+
let recipientUrl: string | undefined;
|
|
51
|
+
let potentialActionId: string | undefined;
|
|
52
|
+
|
|
53
|
+
const informPayment = paymentService.availableChannel?.onPaymentStatusChanged?.informPayment;
|
|
54
|
+
if (Array.isArray(informPayment) && informPayment.length > 0) {
|
|
55
|
+
recipientUrl = informPayment.at(0)?.recipient?.url;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (typeof recipientUrl === 'string') {
|
|
59
|
+
recipientUrls.push(recipientUrl);
|
|
60
|
+
|
|
61
|
+
const existingAction = (await potentialActionRepo.projectFields(
|
|
62
|
+
{
|
|
63
|
+
project: { id: { $eq: '*' } },
|
|
64
|
+
target: { urlTemplate: { $eq: recipientUrl } }
|
|
65
|
+
},
|
|
66
|
+
['target']
|
|
67
|
+
)).shift();
|
|
68
|
+
if (existingAction === undefined) {
|
|
69
|
+
throw new Error('existingAction not found');
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
potentialActionId = existingAction.id;
|
|
73
|
+
const potentialActionIdByProduct = paymentService.potentialAction?.at(0)?.id;
|
|
74
|
+
if (potentialActionIdByProduct === existingAction.id) {
|
|
75
|
+
alreadyMigrated = true;
|
|
76
|
+
// } else {
|
|
77
|
+
// throw new Error('unexpected existingAction');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
if (alreadyMigrated) {
|
|
82
|
+
console.log(
|
|
83
|
+
'already migrated.', paymentService.project.id, i);
|
|
84
|
+
} else {
|
|
85
|
+
if (typeof recipientUrl === 'string' && typeof potentialActionId === 'string') {
|
|
86
|
+
console.log(
|
|
87
|
+
'updating...',
|
|
88
|
+
paymentService.project.id, paymentService.productID, recipientUrl, i);
|
|
89
|
+
await paymentServiceRepo.savePaymentService({
|
|
90
|
+
id: String(paymentService.id),
|
|
91
|
+
$set: <any>{
|
|
92
|
+
typeOf: paymentService.typeOf,
|
|
93
|
+
potentialAction: [{ id: potentialActionId, typeOf: chevre.factory.actionType.InformAction }]
|
|
94
|
+
},
|
|
95
|
+
$unset: {}
|
|
96
|
+
});
|
|
97
|
+
updateCount += 1;
|
|
98
|
+
console.log(
|
|
99
|
+
'updated.',
|
|
100
|
+
paymentService.project.id, i);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
recipientUrls = [...new Set(recipientUrls)];
|
|
106
|
+
console.log('unexpectedProjectIds:', unexpectedProjectIds);
|
|
107
|
+
console.log(recipientUrls);
|
|
108
|
+
console.log(recipientUrls.length, 'recipientUrls found');
|
|
109
|
+
console.log(i, 'docs checked');
|
|
110
|
+
console.log(updateCount, 'docs updated');
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
main()
|
|
114
|
+
.then()
|
|
115
|
+
.catch(console.error);
|
|
@@ -11,6 +11,7 @@ async function main() {
|
|
|
11
11
|
await mongoose.connect(<string>process.env.MONGOLAB_URI, { autoIndex: false });
|
|
12
12
|
|
|
13
13
|
const paymentServiceRepo = await chevre.repository.PaymentService.createInstance(mongoose.connection);
|
|
14
|
+
const potentialActionRepo = await chevre.repository.PotentialAction.createInstance(mongoose.connection);
|
|
14
15
|
|
|
15
16
|
const cursor = paymentServiceRepo.getCursor(
|
|
16
17
|
{
|
|
@@ -50,27 +51,48 @@ async function main() {
|
|
|
50
51
|
const informPayment = paymentService.availableChannel?.onPaymentStatusChanged?.informPayment;
|
|
51
52
|
if (Array.isArray(informPayment) && informPayment.length > 0) {
|
|
52
53
|
recipientUrl = informPayment.at(0)?.recipient?.url;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (typeof recipientUrl === 'string') {
|
|
57
|
+
recipientUrls.push(recipientUrl);
|
|
58
|
+
|
|
59
|
+
const existingActions = await potentialActionRepo.projectFields(
|
|
60
|
+
{
|
|
61
|
+
project: { id: { $eq: '*' } },
|
|
62
|
+
target: { urlTemplate: { $eq: recipientUrl } }
|
|
63
|
+
},
|
|
64
|
+
['target']
|
|
65
|
+
);
|
|
66
|
+
if (existingActions.length > 0) {
|
|
67
|
+
alreadyMigrated = true;
|
|
57
68
|
}
|
|
58
|
-
} else {
|
|
59
|
-
alreadyMigrated = true;
|
|
60
69
|
}
|
|
61
70
|
|
|
62
71
|
if (alreadyMigrated) {
|
|
63
72
|
console.log(
|
|
64
73
|
'already migrated.', paymentService.project.id, i);
|
|
65
74
|
} else {
|
|
66
|
-
|
|
67
|
-
'
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
75
|
+
if (typeof recipientUrl === 'string') {
|
|
76
|
+
const newPotentialAction: Omit<chevre.factory.potentialAction.IPotentialAction, 'id'> = {
|
|
77
|
+
identifier: 'inform2surfrock',
|
|
78
|
+
project: { id: '*', typeOf: chevre.factory.organizationType.Project },
|
|
79
|
+
target: {
|
|
80
|
+
httpMethod: 'POST',
|
|
81
|
+
encodingType: 'application/json',
|
|
82
|
+
typeOf: 'EntryPoint',
|
|
83
|
+
urlTemplate: recipientUrl
|
|
84
|
+
},
|
|
85
|
+
typeOf: chevre.factory.actionType.InformAction
|
|
86
|
+
};
|
|
87
|
+
console.log(
|
|
88
|
+
'updating...',
|
|
89
|
+
paymentService.project.id, paymentService.productID, recipientUrl, i, newPotentialAction);
|
|
90
|
+
await potentialActionRepo.save({ attributes: newPotentialAction });
|
|
91
|
+
updateCount += 1;
|
|
92
|
+
console.log(
|
|
93
|
+
'updated.',
|
|
94
|
+
paymentService.project.id, i);
|
|
95
|
+
}
|
|
74
96
|
}
|
|
75
97
|
});
|
|
76
98
|
|
|
@@ -25,8 +25,8 @@ const schemaDefinition = {
|
|
|
25
25
|
// tasksExportedAt: Date, // discontinue(2024-06-19~)
|
|
26
26
|
// tasksExportationStatus: String, // discontinue(2024-06-19~)
|
|
27
27
|
potentialActions: mongoose_1.SchemaTypes.Mixed,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
location: mongoose_1.SchemaTypes.Mixed,
|
|
29
|
+
potentialAction: mongoose_1.SchemaTypes.Mixed // add(2025-02-06~)
|
|
30
30
|
};
|
|
31
31
|
const schemaOptions = {
|
|
32
32
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -81,9 +81,9 @@ export declare class SellerRepo {
|
|
|
81
81
|
typeOf: factory.organizationType.Corporation;
|
|
82
82
|
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
83
83
|
location?: factory.organization.ILocation | undefined;
|
|
84
|
+
additionalProperty?: import("@chevre/factory/lib/propertyValue").IPropertyValue<string>[] | undefined;
|
|
84
85
|
hasMerchantReturnPolicy?: factory.seller.IHasMerchantReturnPolicy | undefined;
|
|
85
86
|
makesOffer?: factory.seller.IMakesOffer[] | undefined;
|
|
86
|
-
additionalProperty?: import("@chevre/factory/lib/propertyValue").IPropertyValue<string>[] | undefined;
|
|
87
87
|
telephone?: string | undefined;
|
|
88
88
|
branchCode: string;
|
|
89
89
|
paymentAccepted?: factory.seller.IPaymentAccepted[] | undefined;
|
|
@@ -93,9 +93,9 @@ export declare class SellerRepo {
|
|
|
93
93
|
typeOf: factory.organizationType.Corporation;
|
|
94
94
|
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
95
95
|
location?: factory.organization.ILocation | undefined;
|
|
96
|
+
additionalProperty?: import("@chevre/factory/lib/propertyValue").IPropertyValue<string>[] | undefined;
|
|
96
97
|
hasMerchantReturnPolicy?: factory.seller.IHasMerchantReturnPolicy | undefined;
|
|
97
98
|
makesOffer?: factory.seller.IMakesOffer[] | undefined;
|
|
98
|
-
additionalProperty?: import("@chevre/factory/lib/propertyValue").IPropertyValue<string>[] | undefined;
|
|
99
99
|
telephone?: string | undefined;
|
|
100
100
|
branchCode: string;
|
|
101
101
|
paymentAccepted?: factory.seller.IPaymentAccepted[] | undefined;
|
|
@@ -107,9 +107,9 @@ export declare class SellerRepo {
|
|
|
107
107
|
typeOf: factory.organizationType.Corporation;
|
|
108
108
|
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
109
109
|
location?: factory.organization.ILocation | undefined;
|
|
110
|
+
additionalProperty?: import("@chevre/factory/lib/propertyValue").IPropertyValue<string>[] | undefined;
|
|
110
111
|
hasMerchantReturnPolicy?: factory.seller.IHasMerchantReturnPolicy | undefined;
|
|
111
112
|
makesOffer?: factory.seller.IMakesOffer[] | undefined;
|
|
112
|
-
additionalProperty?: import("@chevre/factory/lib/propertyValue").IPropertyValue<string>[] | undefined;
|
|
113
113
|
telephone?: string | undefined;
|
|
114
114
|
branchCode: string;
|
|
115
115
|
paymentAccepted?: factory.seller.IPaymentAccepted[] | undefined;
|
|
@@ -119,9 +119,9 @@ export declare class SellerRepo {
|
|
|
119
119
|
typeOf: factory.organizationType.Corporation;
|
|
120
120
|
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
121
121
|
location?: factory.organization.ILocation | undefined;
|
|
122
|
+
additionalProperty?: import("@chevre/factory/lib/propertyValue").IPropertyValue<string>[] | undefined;
|
|
122
123
|
hasMerchantReturnPolicy?: factory.seller.IHasMerchantReturnPolicy | undefined;
|
|
123
124
|
makesOffer?: factory.seller.IMakesOffer[] | undefined;
|
|
124
|
-
additionalProperty?: import("@chevre/factory/lib/propertyValue").IPropertyValue<string>[] | undefined;
|
|
125
125
|
telephone?: string | undefined;
|
|
126
126
|
branchCode: string;
|
|
127
127
|
paymentAccepted?: factory.seller.IPaymentAccepted[] | undefined;
|
|
@@ -18,7 +18,12 @@ function fixInformAction(params) {
|
|
|
18
18
|
// プロダクト設定を適用
|
|
19
19
|
const informPaymentParamsByProduct = (_c = (_b = (_a = params.paymentService) === null || _a === void 0 ? void 0 : _a.availableChannel) === null || _b === void 0 ? void 0 : _b.onPaymentStatusChanged) === null || _c === void 0 ? void 0 : _c.informPayment;
|
|
20
20
|
if (Array.isArray(informPaymentParamsByProduct)) {
|
|
21
|
-
informPaymentParams.push(...informPaymentParamsByProduct)
|
|
21
|
+
informPaymentParams.push(...informPaymentParamsByProduct.map(({ recipient }) => {
|
|
22
|
+
return {
|
|
23
|
+
recipient,
|
|
24
|
+
id: ''
|
|
25
|
+
};
|
|
26
|
+
}));
|
|
22
27
|
}
|
|
23
28
|
// support potentialAction(2025-02-05~)
|
|
24
29
|
const potentialActionByProduct = (_d = params.paymentService) === null || _d === void 0 ? void 0 : _d.potentialAction;
|
|
@@ -35,7 +40,10 @@ function fixInformAction(params) {
|
|
|
35
40
|
if (potentialInformAction === undefined) {
|
|
36
41
|
throw new factory.errors.NotFound(factory.actionType.InformAction);
|
|
37
42
|
}
|
|
38
|
-
informPaymentParams = [{
|
|
43
|
+
informPaymentParams = [{
|
|
44
|
+
recipient: { url: potentialInformAction.target.urlTemplate },
|
|
45
|
+
id: potentialInformActionId
|
|
46
|
+
}];
|
|
39
47
|
}
|
|
40
48
|
}
|
|
41
49
|
return informPaymentParams;
|
|
@@ -8,7 +8,9 @@ export declare function createStartParams(params: factory.assetTransaction.pay.I
|
|
|
8
8
|
amount: number;
|
|
9
9
|
paymentService?: Pick<factory.service.paymentService.IService, 'availableChannel' | 'id' | 'serviceOutput' | 'serviceType'> | Pick<factory.product.IProduct, 'availableChannel' | 'id' | 'serviceOutput' | 'serviceType'>;
|
|
10
10
|
location?: factory.action.trade.pay.ILocation;
|
|
11
|
-
informActions: factory.product.IInformPayment
|
|
11
|
+
informActions: (factory.product.IInformPayment & {
|
|
12
|
+
id: string;
|
|
13
|
+
})[];
|
|
12
14
|
}, options: {
|
|
13
15
|
checkedAction: {
|
|
14
16
|
id: string;
|
|
@@ -109,9 +109,16 @@ function createStartParams(params, options) {
|
|
|
109
109
|
const object = Object.assign({ accountId: (typeof accountId === 'string') ? accountId : '', paymentMethodId: params.transactionNumber, typeOf: params.paymentServiceType, id: paymentServiceId, onPaymentStatusChanged: { informPayment: params.informActions }, paymentMethod }, (params.paymentServiceType === factory.service.paymentService.PaymentServiceType.MovieTicket)
|
|
110
110
|
? { checkedAction: { id: options.checkedAction.id } } // add checkedAction(2024-12-13~)
|
|
111
111
|
: undefined);
|
|
112
|
-
|
|
112
|
+
const potentialAction = [];
|
|
113
|
+
params.informActions.forEach((informAction) => {
|
|
114
|
+
if (typeof informAction.id === 'string' && informAction.id !== '') {
|
|
115
|
+
potentialAction.push({ id: informAction.id, typeOf: factory.actionType.InformAction });
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
return Object.assign(Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, transactionNumber: params.transactionNumber, typeOf: factory.assetTransactionType.Pay, agent: params.agent, recipient: params.recipient, object, expires: params.expires }, (typeof ((_0 = params.location) === null || _0 === void 0 ? void 0 : _0.typeOf) === 'string')
|
|
113
119
|
? { location: params.location }
|
|
114
|
-
: undefined)
|
|
120
|
+
: undefined), (potentialAction.length > 0) ? { potentialAction } : undefined // add potentialAction(2025-02-05~)
|
|
121
|
+
);
|
|
115
122
|
}
|
|
116
123
|
// function createInformPaymentParams(params: {
|
|
117
124
|
// paymentService?: Pick<factory.service.paymentService.IService, 'availableChannel' | 'potentialAction'>;
|
|
@@ -7,5 +7,7 @@ export declare function createStartParams(params: factory.assetTransaction.refun
|
|
|
7
7
|
paymentServiceType: factory.service.paymentService.PaymentServiceType;
|
|
8
8
|
payAction: factory.action.trade.pay.IAction;
|
|
9
9
|
paymentService?: Pick<factory.product.IProduct, 'availableChannel' | 'typeOf'> | Pick<factory.service.paymentService.IService, 'availableChannel' | 'id' | 'typeOf' | 'serviceOutput'>;
|
|
10
|
-
informActions: factory.product.IInformPayment
|
|
10
|
+
informActions: (factory.product.IInformPayment & {
|
|
11
|
+
id: string;
|
|
12
|
+
})[];
|
|
11
13
|
}): factory.assetTransaction.IStartParams<factory.assetTransactionType.Refund>;
|
|
@@ -36,19 +36,18 @@ function createStartParams(params) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
39
|
+
const potentialAction = [];
|
|
40
|
+
params.informActions.forEach((informAction) => {
|
|
41
|
+
if (typeof informAction.id === 'string' && informAction.id !== '') {
|
|
42
|
+
potentialAction.push({ id: informAction.id, typeOf: factory.actionType.InformAction });
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return Object.assign({ project: { typeOf: factory.organizationType.Project, id: params.project.id }, transactionNumber: params.transactionNumber, typeOf: factory.assetTransactionType.Refund, agent: params.agent, recipient: params.recipient, object: Object.assign({ accountId: (typeof accountId === 'string') ? accountId : '', paymentMethodId: paymentMethodId, typeOf: params.paymentServiceType, id: (Array.isArray(params.payAction.object) && params.payAction.object.length > 0)
|
|
46
46
|
? params.payAction.object[0].id
|
|
47
47
|
: '', onPaymentStatusChanged: { informPayment: params.informActions }, paymentMethod: Object.assign({ additionalProperty: (Array.isArray(additionalProperty)) ? additionalProperty : [], name: (typeof name === 'string') ? name : paymentMethodType, paymentMethodId: paymentMethodId, typeOf: paymentMethodType }, (Array.isArray(params.payAction.object) && params.payAction.object.length > 0)
|
|
48
48
|
? { totalPaymentDue: params.payAction.object[0].paymentMethod.totalPaymentDue }
|
|
49
|
-
: undefined) }, (typeof refundFee === 'number') ? { refundFee } : undefined),
|
|
50
|
-
|
|
51
|
-
};
|
|
49
|
+
: undefined) }, (typeof refundFee === 'number') ? { refundFee } : undefined), expires: params.expires }, (potentialAction.length > 0) ? { potentialAction } : undefined // add potentialAction(2025-02-05~)
|
|
50
|
+
);
|
|
52
51
|
}
|
|
53
52
|
// function createInformPaymentParams(params: {
|
|
54
53
|
// paymentService?: factory.product.IProduct
|
|
@@ -32,11 +32,12 @@ function createReundActions(params) {
|
|
|
32
32
|
return refundActions;
|
|
33
33
|
}
|
|
34
34
|
function createInformPaymentActions(params) {
|
|
35
|
-
var _a;
|
|
35
|
+
var _a, _b, _c;
|
|
36
36
|
const transaction = params.transaction;
|
|
37
37
|
const informPaymentActions = [];
|
|
38
38
|
// 取引に指定があれば設定
|
|
39
39
|
const informPayment = (_a = transaction.object.onPaymentStatusChanged) === null || _a === void 0 ? void 0 : _a.informPayment;
|
|
40
|
+
const potentialInformActionId = (_c = (_b = transaction.potentialAction) === null || _b === void 0 ? void 0 : _b.find(({ typeOf }) => typeOf === factory.actionType.InformAction)) === null || _c === void 0 ? void 0 : _c.id;
|
|
40
41
|
if (Array.isArray(informPayment)) {
|
|
41
42
|
informPaymentActions.push(...informPayment.map((a) => {
|
|
42
43
|
var _a, _b, _c;
|
|
@@ -51,15 +52,10 @@ function createInformPaymentActions(params) {
|
|
|
51
52
|
url: String((_c = a.recipient) === null || _c === void 0 ? void 0 : _c.url)
|
|
52
53
|
};
|
|
53
54
|
// optimize(2024-07-01~)
|
|
54
|
-
return {
|
|
55
|
-
// project: transaction.project,
|
|
56
|
-
// typeOf: factory.actionType.InformAction,
|
|
57
|
-
// agent: transaction.project,
|
|
58
|
-
recipient,
|
|
55
|
+
return Object.assign({ recipient,
|
|
59
56
|
// 実際にタスクが生成される直前にactionに置き換える
|
|
60
57
|
// object: {},
|
|
61
|
-
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
62
|
-
};
|
|
58
|
+
purpose: { typeOf: transaction.typeOf, id: transaction.id } }, (typeof potentialInformActionId === 'string') ? { id: potentialInformActionId } : undefined);
|
|
63
59
|
}));
|
|
64
60
|
}
|
|
65
61
|
return informPaymentActions;
|
|
@@ -3,6 +3,7 @@ import { SendGridCredentials } from '../credentials/sendGrid';
|
|
|
3
3
|
import * as factory from '../factory';
|
|
4
4
|
import type { ActionRepo } from '../repo/action';
|
|
5
5
|
import type { MessageRepo } from '../repo/message';
|
|
6
|
+
import type { PotentialActionRepo } from '../repo/potentialAction';
|
|
6
7
|
import type { ProjectRepo } from '../repo/project';
|
|
7
8
|
import type { SettingRepo } from '../repo/setting';
|
|
8
9
|
type ILineNotifyOperation<T> = (repos: undefined, credentials: {
|
|
@@ -37,6 +38,7 @@ declare function triggerWebhook(params: factory.task.IData<factory.taskName.Trig
|
|
|
37
38
|
};
|
|
38
39
|
}): (repos: {
|
|
39
40
|
action: ActionRepo;
|
|
41
|
+
potentialAction: PotentialActionRepo;
|
|
40
42
|
setting: SettingRepo;
|
|
41
43
|
}) => Promise<void>;
|
|
42
44
|
export { lineNotify, sendEmailMessage, triggerWebhook };
|
|
@@ -189,11 +189,7 @@ function lineNotify({ subject, content, imageThumbnail, imageFullsize, logLevel
|
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
191
|
const USERNAME_ARGUMENT_REQUIRED_MESSAGE = 'Missing required key \'Username\' in params';
|
|
192
|
-
|
|
193
|
-
// const TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = 1000;
|
|
194
|
-
function triggerWebhook(params
|
|
195
|
-
// options: IWebhookSettings
|
|
196
|
-
) {
|
|
192
|
+
function triggerWebhook(params) {
|
|
197
193
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
198
194
|
var _a, _b;
|
|
199
195
|
const setting = yield repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['triggerWebhook']);
|
|
@@ -242,9 +238,20 @@ function sleep(waitTime) {
|
|
|
242
238
|
});
|
|
243
239
|
}
|
|
244
240
|
function createInformActionAttributes(params) {
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
241
|
+
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
242
|
+
const { about, object, purpose, recipient, project, id } = params;
|
|
243
|
+
if (typeof id === 'string' && id !== '') {
|
|
244
|
+
// tslint:disable-next-line:no-suspicious-comment
|
|
245
|
+
// TODO find target from potentialAction(2025-02-06~)
|
|
246
|
+
yield repos.potentialAction.projectFields({
|
|
247
|
+
limit: 1,
|
|
248
|
+
page: 1,
|
|
249
|
+
id: { $eq: id }
|
|
250
|
+
}, ['target']);
|
|
251
|
+
}
|
|
252
|
+
return Object.assign(Object.assign({ agent: { id: project.id, typeOf: factory.organizationType.Project }, object, project: { id: project.id, typeOf: factory.organizationType.Project }, recipient, typeOf: factory.actionType.InformAction }, (typeof (purpose === null || purpose === void 0 ? void 0 : purpose.typeOf) === 'string') ? { purpose } : undefined), (typeof (about === null || about === void 0 ? void 0 : about.typeOf) === 'string') ? { about } : undefined // add(2025-01-23~)
|
|
253
|
+
);
|
|
254
|
+
});
|
|
248
255
|
}
|
|
249
256
|
function signRequest(params) {
|
|
250
257
|
const { requestBody, timestamp, secretKey } = params;
|
|
@@ -258,12 +265,11 @@ function processInformAction(params, options) {
|
|
|
258
265
|
// tslint:disable-next-line:cyclomatic-complexity
|
|
259
266
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
260
267
|
var _a, _b, _c, _d, _e, _f;
|
|
261
|
-
// const { timeout, useFetchAPI, secretKey, headerIdentifier } = options;
|
|
262
268
|
const timeout = (_a = options === null || options === void 0 ? void 0 : options.triggerWebhook) === null || _a === void 0 ? void 0 : _a.timeout;
|
|
263
269
|
const useFetchAPI = ((_b = options === null || options === void 0 ? void 0 : options.triggerWebhook) === null || _b === void 0 ? void 0 : _b.useFetchAPI) === true;
|
|
264
270
|
const secretKey = (_c = options === null || options === void 0 ? void 0 : options.triggerWebhook) === null || _c === void 0 ? void 0 : _c.secretKey;
|
|
265
271
|
const headerIdentifier = (_d = options === null || options === void 0 ? void 0 : options.triggerWebhook) === null || _d === void 0 ? void 0 : _d.headerIdentifier;
|
|
266
|
-
const action = yield repos.action.start(createInformActionAttributes(params));
|
|
272
|
+
const action = yield repos.action.start(yield createInformActionAttributes(params)(repos));
|
|
267
273
|
let result = {};
|
|
268
274
|
try {
|
|
269
275
|
if (typeof ((_e = params.recipient) === null || _e === void 0 ? void 0 : _e.url) === 'string') {
|
|
@@ -32,7 +32,7 @@ function onPaid(payAction) {
|
|
|
32
32
|
}
|
|
33
33
|
const informPayment = potentialActions === null || potentialActions === void 0 ? void 0 : potentialActions.informPayment;
|
|
34
34
|
if (Array.isArray(informPayment)) {
|
|
35
|
-
taskAttributes.push(...informPayment.map(({ purpose, recipient }) => {
|
|
35
|
+
taskAttributes.push(...informPayment.map(({ purpose, recipient, id }) => {
|
|
36
36
|
return {
|
|
37
37
|
project: payAction.project,
|
|
38
38
|
name: factory.taskName.TriggerWebhook,
|
|
@@ -41,10 +41,10 @@ function onPaid(payAction) {
|
|
|
41
41
|
remainingNumberOfTries: 30, // 通知先で429が散見されるので少し多めに
|
|
42
42
|
numberOfTried: 0,
|
|
43
43
|
executionResults: [],
|
|
44
|
-
data: Object.assign({
|
|
44
|
+
data: Object.assign(Object.assign({
|
|
45
45
|
// optimize(2024-07-01~)
|
|
46
|
-
//
|
|
47
|
-
|
|
46
|
+
recipient, object: aciton4inform }, (typeof (purpose === null || purpose === void 0 ? void 0 : purpose.typeOf) === 'string') ? { purpose } : undefined), (typeof id === 'string') ? { id } : undefined // add potentialAction(2025-02-05~)
|
|
47
|
+
)
|
|
48
48
|
};
|
|
49
49
|
}));
|
|
50
50
|
}
|
|
@@ -103,7 +103,7 @@ function onRefund(refundAction) {
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
if (Array.isArray(informPayment)) {
|
|
106
|
-
taskAttributes.push(...informPayment.map(({ purpose, recipient }) => {
|
|
106
|
+
taskAttributes.push(...informPayment.map(({ purpose, recipient, id }) => {
|
|
107
107
|
return {
|
|
108
108
|
project: refundAction.project,
|
|
109
109
|
name: factory.taskName.TriggerWebhook,
|
|
@@ -112,10 +112,10 @@ function onRefund(refundAction) {
|
|
|
112
112
|
remainingNumberOfTries: 30, // 通知先で429が散見されるので少し多めに
|
|
113
113
|
numberOfTried: 0,
|
|
114
114
|
executionResults: [],
|
|
115
|
-
data: Object.assign({
|
|
115
|
+
data: Object.assign(Object.assign({
|
|
116
116
|
// optimize(2024-07-01~)
|
|
117
|
-
//
|
|
118
|
-
|
|
117
|
+
recipient, object: aciton4inform }, (typeof (purpose === null || purpose === void 0 ? void 0 : purpose.typeOf) === 'string') ? { purpose } : undefined), (typeof id === 'string') ? { id } : undefined // add potentialAction(2025-02-05~)
|
|
118
|
+
)
|
|
119
119
|
};
|
|
120
120
|
}));
|
|
121
121
|
}
|
|
@@ -4,7 +4,7 @@ import { IAcceptedOfferMovieTicketUsed } from './factory/createPayObjectServiceO
|
|
|
4
4
|
* 注文に対する決済アクションを生成する
|
|
5
5
|
*/
|
|
6
6
|
declare function createPayOrderAction(params: {
|
|
7
|
-
transaction: Pick<factory.assetTransaction.ITransaction<factory.assetTransactionType.Pay>, 'id' | 'object' | 'transactionNumber' | 'typeOf' | 'agent' | 'project' | 'recipient' | 'location'>;
|
|
7
|
+
transaction: Pick<factory.assetTransaction.ITransaction<factory.assetTransactionType.Pay>, 'id' | 'object' | 'transactionNumber' | 'typeOf' | 'agent' | 'project' | 'recipient' | 'location' | 'potentialAction'>;
|
|
8
8
|
potentialActions?: factory.assetTransaction.pay.IPotentialActionsParams;
|
|
9
9
|
order: Pick<factory.order.IOrder, 'typeOf' | 'confirmationNumber' | 'orderNumber'> & {
|
|
10
10
|
acceptedOffersMovieTicketUsed: IAcceptedOfferMovieTicketUsed[];
|
|
@@ -117,11 +117,12 @@ function createPayObject(params) {
|
|
|
117
117
|
return payObject;
|
|
118
118
|
}
|
|
119
119
|
function createInformPaymentActions(params) {
|
|
120
|
-
var _a;
|
|
120
|
+
var _a, _b, _c;
|
|
121
121
|
const transaction = params.transaction;
|
|
122
122
|
const informPaymentActions = [];
|
|
123
123
|
// 取引に指定があれば設定
|
|
124
124
|
const informPayment = (_a = transaction.object.onPaymentStatusChanged) === null || _a === void 0 ? void 0 : _a.informPayment;
|
|
125
|
+
const potentialInformActionId = (_c = (_b = transaction.potentialAction) === null || _b === void 0 ? void 0 : _b.find(({ typeOf }) => typeOf === factory.actionType.InformAction)) === null || _c === void 0 ? void 0 : _c.id;
|
|
125
126
|
if (Array.isArray(informPayment)) {
|
|
126
127
|
informPaymentActions.push(...informPayment.map((a) => {
|
|
127
128
|
var _a, _b, _c;
|
|
@@ -140,15 +141,10 @@ function createInformPaymentActions(params) {
|
|
|
140
141
|
url: String((_c = a.recipient) === null || _c === void 0 ? void 0 : _c.url)
|
|
141
142
|
};
|
|
142
143
|
// optimize(2024-07-01~)
|
|
143
|
-
return {
|
|
144
|
-
// project: transaction.project,
|
|
145
|
-
// typeOf: factory.actionType.InformAction,
|
|
146
|
-
// agent: transaction.project,
|
|
147
|
-
recipient,
|
|
144
|
+
return Object.assign({ recipient,
|
|
148
145
|
// 実際にタスクが生成される直前にactionに置き換える
|
|
149
146
|
// object: {},
|
|
150
|
-
purpose: { typeOf: transaction.typeOf, id: transaction.id }
|
|
151
|
-
};
|
|
147
|
+
purpose: { typeOf: transaction.typeOf, id: transaction.id } }, (typeof potentialInformActionId === 'string') ? { id: potentialInformActionId } : undefined);
|
|
152
148
|
}));
|
|
153
149
|
}
|
|
154
150
|
return informPaymentActions;
|
|
@@ -11,6 +11,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = call;
|
|
13
13
|
const action_1 = require("../../repo/action");
|
|
14
|
+
const potentialAction_1 = require("../../repo/potentialAction");
|
|
14
15
|
const setting_1 = require("../../repo/setting");
|
|
15
16
|
const notification_1 = require("../notification");
|
|
16
17
|
/**
|
|
@@ -18,10 +19,9 @@ const notification_1 = require("../notification");
|
|
|
18
19
|
*/
|
|
19
20
|
function call(params) {
|
|
20
21
|
return (_a) => __awaiter(this, [_a], void 0, function* ({ connection }) {
|
|
21
|
-
// const { notification } = settings;
|
|
22
|
-
// const { timeout, useFetchAPI, secretKey, headerIdentifier } = notification;
|
|
23
22
|
yield (0, notification_1.triggerWebhook)(Object.assign(Object.assign({}, params.data), { project: { id: params.project.id } }))({
|
|
24
23
|
action: new action_1.ActionRepo(connection),
|
|
24
|
+
potentialAction: new potentialAction_1.PotentialActionRepo(connection),
|
|
25
25
|
setting: new setting_1.SettingRepo(connection)
|
|
26
26
|
});
|
|
27
27
|
});
|
package/package.json
CHANGED
|
@@ -11,8 +11,8 @@
|
|
|
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": "4.393.0-alpha.
|
|
15
|
-
"@cinerino/sdk": "10.21.0-alpha.
|
|
14
|
+
"@chevre/factory": "4.393.0-alpha.7",
|
|
15
|
+
"@cinerino/sdk": "10.21.0-alpha.8",
|
|
16
16
|
"@motionpicture/coa-service": "9.6.0",
|
|
17
17
|
"@motionpicture/gmo-service": "5.3.0",
|
|
18
18
|
"@sendgrid/mail": "6.4.0",
|
|
@@ -112,5 +112,5 @@
|
|
|
112
112
|
"postversion": "git push origin --tags",
|
|
113
113
|
"prepublishOnly": "npm run clean && npm run build && npm test && npm run doc"
|
|
114
114
|
},
|
|
115
|
-
"version": "22.9.0-alpha.
|
|
115
|
+
"version": "22.9.0-alpha.11"
|
|
116
116
|
}
|