@chevre/domain 22.7.0-alpha.4 → 22.7.0-alpha.6
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/aggregateAllEvents2.ts +0 -6
- package/example/src/chevre/createEventBySchedule.ts +0 -6
- package/example/src/chevre/findSetting.ts +8 -6
- package/lib/chevre/repo/action.d.ts +12 -12
- package/lib/chevre/repo/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +21 -0
- package/lib/chevre/repo/mongoose/schemas/setting.js +1 -0
- package/lib/chevre/repo/seller.d.ts +4 -4
- package/lib/chevre/repo/setting.d.ts +3 -3
- package/lib/chevre/repo/setting.js +2 -2
- package/lib/chevre/repo/task.d.ts +12 -12
- package/lib/chevre/repo/transaction.d.ts +1 -1
- package/lib/chevre/service/notification.d.ts +6 -6
- package/lib/chevre/service/notification.js +41 -13
- package/lib/chevre/service/offer/product.d.ts +1 -1
- package/lib/chevre/service/task/triggerWebhook.js +7 -5
- package/lib/chevre/service/task.d.ts +2 -0
- package/lib/chevre/service/task.js +6 -2
- package/lib/chevre/settings.d.ts +1 -18
- package/lib/chevre/settings.js +6 -8
- package/package.json +1 -1
|
@@ -44,12 +44,6 @@ export async function aggregateScreeningEvent() {
|
|
|
44
44
|
sendGrid: await chevre.credentials.SendGrid.createInstance({ apiKey: 'xxx' })
|
|
45
45
|
},
|
|
46
46
|
settings: new chevre.settings.Settings({
|
|
47
|
-
notification: {
|
|
48
|
-
timeout: 1000,
|
|
49
|
-
useFetchAPI: true,
|
|
50
|
-
secretKey: 'xx',
|
|
51
|
-
headerIdentifier: 'xx'
|
|
52
|
-
},
|
|
53
47
|
deliverOrderLimit: 1,
|
|
54
48
|
abortedTasksWithoutReport: [],
|
|
55
49
|
coa: { timeout: 1000 },
|
|
@@ -24,12 +24,6 @@ async function main() {
|
|
|
24
24
|
sendGrid: await chevre.credentials.SendGrid.createInstance({ apiKey: 'xxx' })
|
|
25
25
|
},
|
|
26
26
|
settings: new chevre.settings.Settings({
|
|
27
|
-
notification: {
|
|
28
|
-
timeout: 1000,
|
|
29
|
-
useFetchAPI: true,
|
|
30
|
-
secretKey: 'xx',
|
|
31
|
-
headerIdentifier: 'xx'
|
|
32
|
-
},
|
|
33
27
|
deliverOrderLimit: 1,
|
|
34
28
|
abortedTasksWithoutReport: [],
|
|
35
29
|
coa: { timeout: 1000 },
|
|
@@ -25,7 +25,7 @@ async function main() {
|
|
|
25
25
|
|
|
26
26
|
const settingRepo = await chevre.repository.Setting.createInstance(mongoose.connection);
|
|
27
27
|
|
|
28
|
-
const result = await settingRepo.findOne({}, ['
|
|
28
|
+
const result = await settingRepo.findOne({}, ['triggerWebhook']);
|
|
29
29
|
// tslint:disable-next-line:no-null-keyword
|
|
30
30
|
console.dir(result, { depth: null });
|
|
31
31
|
|
|
@@ -53,11 +53,13 @@ async function main() {
|
|
|
53
53
|
const updateResult = await settingRepo.updateByProject(
|
|
54
54
|
{ project: { id: { $eq: '*' } } },
|
|
55
55
|
{
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
triggerWebhook: {
|
|
57
|
+
timeout: 15000,
|
|
58
|
+
useFetchAPI: true,
|
|
59
|
+
secretKey: String(process.env.TRIGGER_WEBHOOK_SECRET_KEY),
|
|
60
|
+
headerIdentifier: String(process.env.TRIGGER_WEBHOOK_HEADER_IDENTIFIER),
|
|
61
|
+
retryCountMax: 2,
|
|
62
|
+
retryIntervalInMS: 1000
|
|
61
63
|
}
|
|
62
64
|
}
|
|
63
65
|
);
|
|
@@ -382,15 +382,15 @@ export declare class ActionRepo {
|
|
|
382
382
|
object: any;
|
|
383
383
|
error?: any;
|
|
384
384
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
385
|
+
typeOf: factory.actionType;
|
|
386
|
+
result?: any;
|
|
387
|
+
recipient?: import("@chevre/factory/lib/action").IParticipant | undefined;
|
|
385
388
|
agent: import("@chevre/factory/lib/action").IParticipant;
|
|
386
389
|
purpose?: import("@chevre/factory/lib/action").IPurpose | undefined;
|
|
387
|
-
typeOf: factory.actionType;
|
|
388
390
|
targetCollection?: any;
|
|
389
391
|
potentialActions?: any;
|
|
390
392
|
instrument?: any;
|
|
391
|
-
recipient?: import("@chevre/factory/lib/action").IParticipant | undefined;
|
|
392
393
|
location?: any;
|
|
393
|
-
result?: any;
|
|
394
394
|
endDate?: Date | undefined;
|
|
395
395
|
sameAs?: import("@chevre/factory/lib/action").ISameAs | undefined;
|
|
396
396
|
startDate: Date;
|
|
@@ -405,15 +405,15 @@ export declare class ActionRepo {
|
|
|
405
405
|
object: any;
|
|
406
406
|
error?: any;
|
|
407
407
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
408
|
+
typeOf: factory.actionType;
|
|
409
|
+
result?: any;
|
|
410
|
+
recipient?: import("@chevre/factory/lib/action").IParticipant | undefined;
|
|
408
411
|
agent: import("@chevre/factory/lib/action").IParticipant;
|
|
409
412
|
purpose?: import("@chevre/factory/lib/action").IPurpose | undefined;
|
|
410
|
-
typeOf: factory.actionType;
|
|
411
413
|
targetCollection?: any;
|
|
412
414
|
potentialActions?: any;
|
|
413
415
|
instrument?: any;
|
|
414
|
-
recipient?: import("@chevre/factory/lib/action").IParticipant | undefined;
|
|
415
416
|
location?: any;
|
|
416
|
-
result?: any;
|
|
417
417
|
endDate?: Date | undefined;
|
|
418
418
|
sameAs?: import("@chevre/factory/lib/action").ISameAs | undefined;
|
|
419
419
|
startDate: Date;
|
|
@@ -430,15 +430,15 @@ export declare class ActionRepo {
|
|
|
430
430
|
object: any;
|
|
431
431
|
error?: any;
|
|
432
432
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
433
|
+
typeOf: factory.actionType;
|
|
434
|
+
result?: any;
|
|
435
|
+
recipient?: import("@chevre/factory/lib/action").IParticipant | undefined;
|
|
433
436
|
agent: import("@chevre/factory/lib/action").IParticipant;
|
|
434
437
|
purpose?: import("@chevre/factory/lib/action").IPurpose | undefined;
|
|
435
|
-
typeOf: factory.actionType;
|
|
436
438
|
targetCollection?: any;
|
|
437
439
|
potentialActions?: any;
|
|
438
440
|
instrument?: any;
|
|
439
|
-
recipient?: import("@chevre/factory/lib/action").IParticipant | undefined;
|
|
440
441
|
location?: any;
|
|
441
|
-
result?: any;
|
|
442
442
|
endDate?: Date | undefined;
|
|
443
443
|
sameAs?: import("@chevre/factory/lib/action").ISameAs | undefined;
|
|
444
444
|
startDate: Date;
|
|
@@ -453,15 +453,15 @@ export declare class ActionRepo {
|
|
|
453
453
|
object: any;
|
|
454
454
|
error?: any;
|
|
455
455
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
456
|
+
typeOf: factory.actionType;
|
|
457
|
+
result?: any;
|
|
458
|
+
recipient?: import("@chevre/factory/lib/action").IParticipant | undefined;
|
|
456
459
|
agent: import("@chevre/factory/lib/action").IParticipant;
|
|
457
460
|
purpose?: import("@chevre/factory/lib/action").IPurpose | undefined;
|
|
458
|
-
typeOf: factory.actionType;
|
|
459
461
|
targetCollection?: any;
|
|
460
462
|
potentialActions?: any;
|
|
461
463
|
instrument?: any;
|
|
462
|
-
recipient?: import("@chevre/factory/lib/action").IParticipant | undefined;
|
|
463
464
|
location?: any;
|
|
464
|
-
result?: any;
|
|
465
465
|
endDate?: Date | undefined;
|
|
466
466
|
sameAs?: import("@chevre/factory/lib/action").ISameAs | undefined;
|
|
467
467
|
startDate: Date;
|
|
@@ -126,7 +126,7 @@ export declare class AssetTransactionRepo {
|
|
|
126
126
|
status: {
|
|
127
127
|
$in: factory.transactionStatusType[];
|
|
128
128
|
};
|
|
129
|
-
}): Promise<Pick<import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction, "id" | "
|
|
129
|
+
}): Promise<Pick<import("@chevre/factory/lib/assetTransaction/cancelReservation").ITransaction | import("@chevre/factory/lib/assetTransaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/assetTransaction/pay").ITransaction | import("@chevre/factory/lib/assetTransaction/refund").ITransaction | import("@chevre/factory/lib/assetTransaction/registerService").ITransaction | import("@chevre/factory/lib/assetTransaction/reserve").ITransaction, "id" | "typeOf" | "status">[]>;
|
|
130
130
|
/**
|
|
131
131
|
* set task status exported by transaction id
|
|
132
132
|
* IDでタスクをエクスポート済に変更する
|
|
@@ -48,6 +48,23 @@ interface IQuotaSettings {
|
|
|
48
48
|
placeOrderExpiresInSecondsMax?: number;
|
|
49
49
|
placeOrderExpiresInSecondsMin?: number;
|
|
50
50
|
}
|
|
51
|
+
export interface ITriggerWebhookSettings {
|
|
52
|
+
/**
|
|
53
|
+
* リクエストタイムアウト
|
|
54
|
+
*/
|
|
55
|
+
timeout?: number;
|
|
56
|
+
useFetchAPI?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* 通知署名の鍵
|
|
59
|
+
*/
|
|
60
|
+
secretKey?: string;
|
|
61
|
+
/**
|
|
62
|
+
* 固有署名ヘッダー識別子
|
|
63
|
+
*/
|
|
64
|
+
headerIdentifier?: string;
|
|
65
|
+
retryCountMax?: number;
|
|
66
|
+
retryIntervalInMS?: number;
|
|
67
|
+
}
|
|
51
68
|
export interface ISetting {
|
|
52
69
|
defaultSenderEmail?: string;
|
|
53
70
|
onEventChanged?: IOnEventChanged;
|
|
@@ -63,6 +80,10 @@ export interface ISetting {
|
|
|
63
80
|
};
|
|
64
81
|
quota?: IQuotaSettings;
|
|
65
82
|
storage?: IStorageSettings;
|
|
83
|
+
/**
|
|
84
|
+
* 通知設定
|
|
85
|
+
*/
|
|
86
|
+
triggerWebhook?: ITriggerWebhookSettings;
|
|
66
87
|
useInformResourceTypes?: string[];
|
|
67
88
|
userPoolIdOld?: string;
|
|
68
89
|
userPoolIdNew?: string;
|
|
@@ -16,6 +16,7 @@ const schemaDefinition = {
|
|
|
16
16
|
onTransactionStatusChanged: mongoose_1.SchemaTypes.Mixed,
|
|
17
17
|
quota: mongoose_1.SchemaTypes.Mixed,
|
|
18
18
|
storage: mongoose_1.SchemaTypes.Mixed,
|
|
19
|
+
triggerWebhook: mongoose_1.SchemaTypes.Mixed,
|
|
19
20
|
useInformResourceTypes: [String],
|
|
20
21
|
userPoolIdOld: String,
|
|
21
22
|
userPoolIdNew: String
|
|
@@ -102,8 +102,8 @@ export declare class SellerRepo {
|
|
|
102
102
|
getCursor(conditions: FilterQuery<factory.seller.ISeller>, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, {
|
|
103
103
|
url?: string | undefined;
|
|
104
104
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
105
|
-
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
106
105
|
typeOf: factory.organizationType.Corporation;
|
|
106
|
+
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
107
107
|
location?: import("@chevre/factory/lib/place").IPlace | undefined;
|
|
108
108
|
hasMerchantReturnPolicy?: factory.seller.IHasMerchantReturnPolicy | undefined;
|
|
109
109
|
makesOffer?: factory.seller.IMakesOffer[] | undefined;
|
|
@@ -114,8 +114,8 @@ export declare class SellerRepo {
|
|
|
114
114
|
}> & {
|
|
115
115
|
url?: string | undefined;
|
|
116
116
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
117
|
-
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
118
117
|
typeOf: factory.organizationType.Corporation;
|
|
118
|
+
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
119
119
|
location?: import("@chevre/factory/lib/place").IPlace | undefined;
|
|
120
120
|
hasMerchantReturnPolicy?: factory.seller.IHasMerchantReturnPolicy | undefined;
|
|
121
121
|
makesOffer?: factory.seller.IMakesOffer[] | undefined;
|
|
@@ -128,8 +128,8 @@ export declare class SellerRepo {
|
|
|
128
128
|
}, QueryOptions<import("mongoose").Document<unknown, {}, {
|
|
129
129
|
url?: string | undefined;
|
|
130
130
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
131
|
-
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
132
131
|
typeOf: factory.organizationType.Corporation;
|
|
132
|
+
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
133
133
|
location?: import("@chevre/factory/lib/place").IPlace | undefined;
|
|
134
134
|
hasMerchantReturnPolicy?: factory.seller.IHasMerchantReturnPolicy | undefined;
|
|
135
135
|
makesOffer?: factory.seller.IMakesOffer[] | undefined;
|
|
@@ -140,8 +140,8 @@ export declare class SellerRepo {
|
|
|
140
140
|
}> & {
|
|
141
141
|
url?: string | undefined;
|
|
142
142
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
143
|
-
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
144
143
|
typeOf: factory.organizationType.Corporation;
|
|
144
|
+
name: import("@chevre/factory/lib/multilingualString").IMultilingualString;
|
|
145
145
|
location?: import("@chevre/factory/lib/place").IPlace | undefined;
|
|
146
146
|
hasMerchantReturnPolicy?: factory.seller.IHasMerchantReturnPolicy | undefined;
|
|
147
147
|
makesOffer?: factory.seller.IMakesOffer[] | undefined;
|
|
@@ -23,9 +23,9 @@
|
|
|
23
23
|
/// <reference types="mongoose/types/virtuals" />
|
|
24
24
|
/// <reference types="mongoose/types/inferschematype" />
|
|
25
25
|
import type { Connection } from 'mongoose';
|
|
26
|
-
import { ISetting } from './mongoose/schemas/setting';
|
|
26
|
+
import { ISetting, ITriggerWebhookSettings } from './mongoose/schemas/setting';
|
|
27
27
|
type IKeyOfProjection = keyof ISetting;
|
|
28
|
-
export { ISetting };
|
|
28
|
+
export { ISetting, ITriggerWebhookSettings };
|
|
29
29
|
/**
|
|
30
30
|
* 設定リポジトリ
|
|
31
31
|
*/
|
|
@@ -46,5 +46,5 @@ export declare class SettingRepo {
|
|
|
46
46
|
$eq: string;
|
|
47
47
|
};
|
|
48
48
|
};
|
|
49
|
-
}, update: Pick<ISetting, 'onEventChanged' | 'onReservationStatusChanged' | 'onResourceUpdated' | 'defaultSenderEmail' | 'useInformResourceTypes' | 'userPoolIdNew' | 'userPoolIdOld' | 'storage' | 'quota'>): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
49
|
+
}, update: Pick<ISetting, 'onEventChanged' | 'onReservationStatusChanged' | 'onResourceUpdated' | 'defaultSenderEmail' | 'useInformResourceTypes' | 'userPoolIdNew' | 'userPoolIdOld' | 'storage' | 'quota' | 'triggerWebhook'>): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
50
50
|
}
|
|
@@ -49,9 +49,9 @@ class SettingRepo {
|
|
|
49
49
|
}
|
|
50
50
|
updateByProject(filter, update) {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
-
const { onEventChanged, onReservationStatusChanged, onResourceUpdated, defaultSenderEmail, useInformResourceTypes, userPoolIdNew, userPoolIdOld, storage, quota } = update;
|
|
52
|
+
const { onEventChanged, onReservationStatusChanged, onResourceUpdated, defaultSenderEmail, useInformResourceTypes, userPoolIdNew, userPoolIdOld, storage, quota, triggerWebhook } = update;
|
|
53
53
|
return this.settingModel.updateOne({ 'project.id': { $eq: filter.project.id.$eq } }, {
|
|
54
|
-
$set: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (onEventChanged !== undefined) ? { onEventChanged } : undefined), (onReservationStatusChanged !== undefined) ? { onReservationStatusChanged } : undefined), (onResourceUpdated !== undefined) ? { onResourceUpdated } : undefined), (defaultSenderEmail !== undefined) ? { defaultSenderEmail } : undefined), (useInformResourceTypes !== undefined) ? { useInformResourceTypes } : undefined), (userPoolIdNew !== undefined) ? { userPoolIdNew } : undefined), (userPoolIdOld !== undefined) ? { userPoolIdOld } : undefined), (storage !== undefined) ? { storage } : undefined), (quota !== undefined) ? { quota } : undefined)
|
|
54
|
+
$set: Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (onEventChanged !== undefined) ? { onEventChanged } : undefined), (onReservationStatusChanged !== undefined) ? { onReservationStatusChanged } : undefined), (onResourceUpdated !== undefined) ? { onResourceUpdated } : undefined), (defaultSenderEmail !== undefined) ? { defaultSenderEmail } : undefined), (useInformResourceTypes !== undefined) ? { useInformResourceTypes } : undefined), (userPoolIdNew !== undefined) ? { userPoolIdNew } : undefined), (userPoolIdOld !== undefined) ? { userPoolIdOld } : undefined), (storage !== undefined) ? { storage } : undefined), (quota !== undefined) ? { quota } : undefined), (triggerWebhook !== undefined) ? { triggerWebhook } : undefined)
|
|
55
55
|
})
|
|
56
56
|
.exec();
|
|
57
57
|
});
|
|
@@ -184,8 +184,10 @@ export declare class TaskRepo {
|
|
|
184
184
|
};
|
|
185
185
|
}): Promise<number>;
|
|
186
186
|
getCursor(conditions: any, projection: any): import("mongoose").Cursor<import("mongoose").Document<unknown, {}, {
|
|
187
|
-
identifier?: string | undefined;
|
|
188
187
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
188
|
+
expires?: Date | undefined;
|
|
189
|
+
data: any;
|
|
190
|
+
identifier?: string | undefined;
|
|
189
191
|
name: factory.taskName;
|
|
190
192
|
status: factory.taskStatus;
|
|
191
193
|
runsAt: Date;
|
|
@@ -194,12 +196,12 @@ export declare class TaskRepo {
|
|
|
194
196
|
numberOfTried: number;
|
|
195
197
|
executionResults: import("@chevre/factory/lib/task").IExecutionResult[];
|
|
196
198
|
executor?: import("@chevre/factory/lib/task").IExecutor | undefined;
|
|
197
|
-
data: any;
|
|
198
199
|
dateAborted?: Date | undefined;
|
|
199
|
-
expires?: Date | undefined;
|
|
200
200
|
}> & {
|
|
201
|
-
identifier?: string | undefined;
|
|
202
201
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
202
|
+
expires?: Date | undefined;
|
|
203
|
+
data: any;
|
|
204
|
+
identifier?: string | undefined;
|
|
203
205
|
name: factory.taskName;
|
|
204
206
|
status: factory.taskStatus;
|
|
205
207
|
runsAt: Date;
|
|
@@ -208,14 +210,14 @@ export declare class TaskRepo {
|
|
|
208
210
|
numberOfTried: number;
|
|
209
211
|
executionResults: import("@chevre/factory/lib/task").IExecutionResult[];
|
|
210
212
|
executor?: import("@chevre/factory/lib/task").IExecutor | undefined;
|
|
211
|
-
data: any;
|
|
212
213
|
dateAborted?: Date | undefined;
|
|
213
|
-
expires?: Date | undefined;
|
|
214
214
|
} & {
|
|
215
215
|
_id: import("mongoose").Types.ObjectId;
|
|
216
216
|
}, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, {
|
|
217
|
-
identifier?: string | undefined;
|
|
218
217
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
218
|
+
expires?: Date | undefined;
|
|
219
|
+
data: any;
|
|
220
|
+
identifier?: string | undefined;
|
|
219
221
|
name: factory.taskName;
|
|
220
222
|
status: factory.taskStatus;
|
|
221
223
|
runsAt: Date;
|
|
@@ -224,12 +226,12 @@ export declare class TaskRepo {
|
|
|
224
226
|
numberOfTried: number;
|
|
225
227
|
executionResults: import("@chevre/factory/lib/task").IExecutionResult[];
|
|
226
228
|
executor?: import("@chevre/factory/lib/task").IExecutor | undefined;
|
|
227
|
-
data: any;
|
|
228
229
|
dateAborted?: Date | undefined;
|
|
229
|
-
expires?: Date | undefined;
|
|
230
230
|
}> & {
|
|
231
|
-
identifier?: string | undefined;
|
|
232
231
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
232
|
+
expires?: Date | undefined;
|
|
233
|
+
data: any;
|
|
234
|
+
identifier?: string | undefined;
|
|
233
235
|
name: factory.taskName;
|
|
234
236
|
status: factory.taskStatus;
|
|
235
237
|
runsAt: Date;
|
|
@@ -238,9 +240,7 @@ export declare class TaskRepo {
|
|
|
238
240
|
numberOfTried: number;
|
|
239
241
|
executionResults: import("@chevre/factory/lib/task").IExecutionResult[];
|
|
240
242
|
executor?: import("@chevre/factory/lib/task").IExecutor | undefined;
|
|
241
|
-
data: any;
|
|
242
243
|
dateAborted?: Date | undefined;
|
|
243
|
-
expires?: Date | undefined;
|
|
244
244
|
} & {
|
|
245
245
|
_id: import("mongoose").Types.ObjectId;
|
|
246
246
|
}>>;
|
|
@@ -158,7 +158,7 @@ export declare class TransactionRepo {
|
|
|
158
158
|
status: {
|
|
159
159
|
$in: factory.transactionStatusType[];
|
|
160
160
|
};
|
|
161
|
-
}): Promise<Pick<import("@chevre/factory/lib/transaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/transaction/placeOrder").ITransaction | import("@chevre/factory/lib/transaction/returnOrder").ITransaction, "id" | "
|
|
161
|
+
}): Promise<Pick<import("@chevre/factory/lib/transaction/moneyTransfer").ITransaction | import("@chevre/factory/lib/transaction/placeOrder").ITransaction | import("@chevre/factory/lib/transaction/returnOrder").ITransaction, "id" | "typeOf" | "status">[]>;
|
|
162
162
|
/**
|
|
163
163
|
* set task status exported by transaction id
|
|
164
164
|
* IDでタスクをエクスポート済に変更する
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { LINENotifyCredentials } from '../credentials/lineNotify';
|
|
2
2
|
import { SendGridCredentials } from '../credentials/sendGrid';
|
|
3
3
|
import * as factory from '../factory';
|
|
4
|
-
import { IWebhookSettings } from '../settings';
|
|
5
4
|
import type { ActionRepo } from '../repo/action';
|
|
6
5
|
import type { MessageRepo } from '../repo/message';
|
|
7
6
|
import type { ProjectRepo } from '../repo/project';
|
|
8
|
-
type
|
|
7
|
+
import type { SettingRepo } from '../repo/setting';
|
|
8
|
+
type ILineNotifyOperation<T> = (repos: {
|
|
9
|
+
setting: SettingRepo;
|
|
10
|
+
}, credentials: {
|
|
9
11
|
lineNotify: LINENotifyCredentials;
|
|
10
12
|
}) => Promise<T>;
|
|
11
13
|
/**
|
|
@@ -30,15 +32,13 @@ declare function lineNotify({ subject, content, imageThumbnail, imageFullsize, l
|
|
|
30
32
|
imageThumbnail?: string;
|
|
31
33
|
imageFullsize?: string;
|
|
32
34
|
logLevel: LineNotifyLogLevel;
|
|
33
|
-
}, options: {
|
|
34
|
-
timeout: number;
|
|
35
|
-
useFetchAPI: boolean;
|
|
36
35
|
}): ILineNotifyOperation<void>;
|
|
37
36
|
declare function triggerWebhook(params: factory.task.IData<factory.taskName.TriggerWebhook> & {
|
|
38
37
|
project: {
|
|
39
38
|
id: string;
|
|
40
39
|
};
|
|
41
|
-
}
|
|
40
|
+
}): (repos: {
|
|
42
41
|
action: ActionRepo;
|
|
42
|
+
setting: SettingRepo;
|
|
43
43
|
}) => Promise<void>;
|
|
44
44
|
export { lineNotify, sendEmailMessage, triggerWebhook };
|
|
@@ -122,9 +122,21 @@ function sendEmailMessage(params) {
|
|
|
122
122
|
}
|
|
123
123
|
exports.sendEmailMessage = sendEmailMessage;
|
|
124
124
|
const MAX_LINE_NOTIFY_SUBJECT_LENGTH = 100;
|
|
125
|
-
function lineNotify({ subject, content, imageThumbnail, imageFullsize, logLevel }
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
function lineNotify({ subject, content, imageThumbnail, imageFullsize, logLevel }
|
|
126
|
+
// options: {
|
|
127
|
+
// timeout: number;
|
|
128
|
+
// useFetchAPI: boolean;
|
|
129
|
+
// }
|
|
130
|
+
) {
|
|
131
|
+
return (repos, credentials) => __awaiter(this, void 0, void 0, function* () {
|
|
132
|
+
var _a, _b;
|
|
133
|
+
// const { timeout, useFetchAPI } = options;
|
|
134
|
+
const setting = yield repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['triggerWebhook']);
|
|
135
|
+
const timeout = (_a = setting === null || setting === void 0 ? void 0 : setting.triggerWebhook) === null || _a === void 0 ? void 0 : _a.timeout;
|
|
136
|
+
const useFetchAPI = ((_b = setting === null || setting === void 0 ? void 0 : setting.triggerWebhook) === null || _b === void 0 ? void 0 : _b.useFetchAPI) === true;
|
|
137
|
+
if (typeof timeout !== 'number') {
|
|
138
|
+
throw new factory.errors.NotFound('setting.triggerWebhook.timeout');
|
|
139
|
+
}
|
|
128
140
|
const LINE_NOTIFY_URL = credentials.lineNotify.url;
|
|
129
141
|
if (typeof LINE_NOTIFY_URL !== 'string') {
|
|
130
142
|
throw new factory.errors.Internal('Environment variable LINE_NOTIFY_URL not set');
|
|
@@ -189,24 +201,36 @@ function lineNotify({ subject, content, imageThumbnail, imageFullsize, logLevel
|
|
|
189
201
|
}
|
|
190
202
|
exports.lineNotify = lineNotify;
|
|
191
203
|
const USERNAME_ARGUMENT_REQUIRED_MESSAGE = 'Missing required key \'Username\' in params';
|
|
192
|
-
const TRIGGER_WEBHOOK_MAX_RETRY_COUNT = 2;
|
|
193
|
-
const TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = 1000;
|
|
194
|
-
function triggerWebhook(params
|
|
204
|
+
// const TRIGGER_WEBHOOK_MAX_RETRY_COUNT = 2;
|
|
205
|
+
// const TRIGGER_WEBHOOK_RETRY_INTERVAL_IN_MS = 1000;
|
|
206
|
+
function triggerWebhook(params
|
|
207
|
+
// options: IWebhookSettings
|
|
208
|
+
) {
|
|
195
209
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
210
|
+
var _a, _b;
|
|
211
|
+
const setting = yield repos.setting.findOne({ project: { id: { $eq: '*' } } }, ['triggerWebhook']);
|
|
212
|
+
const retryCountMax = (_a = setting === null || setting === void 0 ? void 0 : setting.triggerWebhook) === null || _a === void 0 ? void 0 : _a.retryCountMax;
|
|
213
|
+
const retryIntervalInMS = (_b = setting === null || setting === void 0 ? void 0 : setting.triggerWebhook) === null || _b === void 0 ? void 0 : _b.retryIntervalInMS;
|
|
214
|
+
if (typeof retryCountMax !== 'number') {
|
|
215
|
+
throw new factory.errors.NotFound('setting.triggerWebhook.retryCountMax');
|
|
216
|
+
}
|
|
217
|
+
if (typeof retryIntervalInMS !== 'number') {
|
|
218
|
+
throw new factory.errors.NotFound('setting.triggerWebhook.retryIntervalInMS');
|
|
219
|
+
}
|
|
196
220
|
// retryableにする(2023-05-12~)
|
|
197
221
|
let retry = true;
|
|
198
222
|
let numberOfTry = 0;
|
|
199
223
|
while (numberOfTry >= 0) {
|
|
200
224
|
try {
|
|
201
225
|
numberOfTry += 1;
|
|
202
|
-
if (numberOfTry >
|
|
226
|
+
if (numberOfTry > retryCountMax) {
|
|
203
227
|
retry = false;
|
|
204
228
|
}
|
|
205
229
|
// retryInterval
|
|
206
230
|
if (numberOfTry > 1) {
|
|
207
|
-
yield sleep(
|
|
231
|
+
yield sleep(retryIntervalInMS * (numberOfTry - 1));
|
|
208
232
|
}
|
|
209
|
-
yield processInformAction(params,
|
|
233
|
+
yield processInformAction(params, setting)(repos);
|
|
210
234
|
break;
|
|
211
235
|
}
|
|
212
236
|
catch (error) {
|
|
@@ -245,12 +269,16 @@ function signRequest(params) {
|
|
|
245
269
|
function processInformAction(params, options) {
|
|
246
270
|
// tslint:disable-next-line:cyclomatic-complexity
|
|
247
271
|
return (repos) => __awaiter(this, void 0, void 0, function* () {
|
|
248
|
-
var _a, _b;
|
|
249
|
-
const { timeout, useFetchAPI, secretKey, headerIdentifier } = options;
|
|
272
|
+
var _a, _b, _c, _d, _e, _f;
|
|
273
|
+
// const { timeout, useFetchAPI, secretKey, headerIdentifier } = options;
|
|
274
|
+
const timeout = (_a = options === null || options === void 0 ? void 0 : options.triggerWebhook) === null || _a === void 0 ? void 0 : _a.timeout;
|
|
275
|
+
const useFetchAPI = ((_b = options === null || options === void 0 ? void 0 : options.triggerWebhook) === null || _b === void 0 ? void 0 : _b.useFetchAPI) === true;
|
|
276
|
+
const secretKey = (_c = options === null || options === void 0 ? void 0 : options.triggerWebhook) === null || _c === void 0 ? void 0 : _c.secretKey;
|
|
277
|
+
const headerIdentifier = (_d = options === null || options === void 0 ? void 0 : options.triggerWebhook) === null || _d === void 0 ? void 0 : _d.headerIdentifier;
|
|
250
278
|
const action = yield repos.action.start(createInformActionAttributes(params));
|
|
251
279
|
let result = {};
|
|
252
280
|
try {
|
|
253
|
-
if (typeof ((
|
|
281
|
+
if (typeof ((_e = params.recipient) === null || _e === void 0 ? void 0 : _e.url) === 'string') {
|
|
254
282
|
const url = params.recipient.url;
|
|
255
283
|
const requestBody = JSON.stringify(Object.assign({ data: params.object }, (typeof params.identifier === 'string' && params.identifier !== '')
|
|
256
284
|
? { identifier: params.identifier }
|
|
@@ -307,7 +335,7 @@ function processInformAction(params, options) {
|
|
|
307
335
|
catch (error) {
|
|
308
336
|
let throwsError = true;
|
|
309
337
|
// プロジェクト固有の特別対応
|
|
310
|
-
if (error.statusCode === http_status_1.INTERNAL_SERVER_ERROR && ((
|
|
338
|
+
if (error.statusCode === http_status_1.INTERNAL_SERVER_ERROR && ((_f = error.body) === null || _f === void 0 ? void 0 : _f.message) === USERNAME_ARGUMENT_REQUIRED_MESSAGE) {
|
|
311
339
|
throwsError = false;
|
|
312
340
|
}
|
|
313
341
|
if (throwsError) {
|
|
@@ -68,7 +68,7 @@ export declare function search(params: {
|
|
|
68
68
|
productOffer: ProductOfferRepo;
|
|
69
69
|
}) => Promise<{
|
|
70
70
|
offers: factory.product.ITicketOffer[];
|
|
71
|
-
product: Pick<factory.product.IProduct, "id" | "project" | "
|
|
71
|
+
product: Pick<factory.product.IProduct, "id" | "project" | "typeOf" | "name" | "description" | "serviceType" | "serviceOutput" | "productID">;
|
|
72
72
|
}>;
|
|
73
73
|
export type IAuthorizeOfferAction = factory.action.authorize.offer.product.IAction;
|
|
74
74
|
/**
|
|
@@ -11,16 +11,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.call = void 0;
|
|
13
13
|
const action_1 = require("../../repo/action");
|
|
14
|
+
const setting_1 = require("../../repo/setting");
|
|
14
15
|
const notification_1 = require("../notification");
|
|
15
16
|
/**
|
|
16
17
|
* タスク実行関数
|
|
17
18
|
*/
|
|
18
19
|
function call(params) {
|
|
19
|
-
return ({ connection
|
|
20
|
-
const { notification } = settings;
|
|
21
|
-
const { timeout, useFetchAPI, secretKey, headerIdentifier } = notification;
|
|
22
|
-
yield (0, notification_1.triggerWebhook)(Object.assign(Object.assign({}, params.data), { project: { id: params.project.id } })
|
|
23
|
-
action: new action_1.ActionRepo(connection)
|
|
20
|
+
return ({ connection }) => __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
// const { notification } = settings;
|
|
22
|
+
// const { timeout, useFetchAPI, secretKey, headerIdentifier } = notification;
|
|
23
|
+
yield (0, notification_1.triggerWebhook)(Object.assign(Object.assign({}, params.data), { project: { id: params.project.id } }))({
|
|
24
|
+
action: new action_1.ActionRepo(connection),
|
|
25
|
+
setting: new setting_1.SettingRepo(connection)
|
|
24
26
|
});
|
|
25
27
|
});
|
|
26
28
|
}
|
|
@@ -4,6 +4,7 @@ import { JWTCredentials } from '../credentials/jwt';
|
|
|
4
4
|
import { LINENotifyCredentials } from '../credentials/lineNotify';
|
|
5
5
|
import { SendGridCredentials } from '../credentials/sendGrid';
|
|
6
6
|
import * as factory from '../factory';
|
|
7
|
+
import type { SettingRepo } from '../repo/setting';
|
|
7
8
|
import type { IExecutableTask, IExecutableTaskKeys, TaskRepo } from '../repo/task';
|
|
8
9
|
import { Settings } from '../settings';
|
|
9
10
|
import { AggregationSettings } from '../settings/aggregation';
|
|
@@ -29,6 +30,7 @@ interface IExecuteOptions {
|
|
|
29
30
|
executeByName: boolean;
|
|
30
31
|
}
|
|
31
32
|
type TaskOperation<T> = (repos: {
|
|
33
|
+
setting: SettingRepo;
|
|
32
34
|
task: TaskRepo;
|
|
33
35
|
}, settings: Settings, credentials: {
|
|
34
36
|
lineNotify: LINENotifyCredentials;
|
|
@@ -172,7 +172,9 @@ function abort(params) {
|
|
|
172
172
|
yield notification.lineNotify({
|
|
173
173
|
subject: message.subject, content: message.content,
|
|
174
174
|
logLevel: 'error'
|
|
175
|
-
}
|
|
175
|
+
}
|
|
176
|
+
// { timeout, useFetchAPI }
|
|
177
|
+
)(repos, credentials);
|
|
176
178
|
}
|
|
177
179
|
});
|
|
178
180
|
}
|
|
@@ -192,7 +194,9 @@ function notifyAbortedTasks(params) {
|
|
|
192
194
|
yield notification.lineNotify({
|
|
193
195
|
subject: message.subject, content: message.content,
|
|
194
196
|
logLevel: 'error'
|
|
195
|
-
}
|
|
197
|
+
}
|
|
198
|
+
// { timeout, useFetchAPI }
|
|
199
|
+
)(repos, credentials);
|
|
196
200
|
}
|
|
197
201
|
});
|
|
198
202
|
}
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -1,19 +1,4 @@
|
|
|
1
1
|
import { AggregationSettings, ICallableTaskOperation, ICallResult, IOperationExecute } from './settings/aggregation';
|
|
2
|
-
interface IWebhookSettings {
|
|
3
|
-
/**
|
|
4
|
-
* リクエストタイムアウト
|
|
5
|
-
*/
|
|
6
|
-
timeout: number;
|
|
7
|
-
useFetchAPI: boolean;
|
|
8
|
-
/**
|
|
9
|
-
* 通知署名の鍵
|
|
10
|
-
*/
|
|
11
|
-
secretKey?: string;
|
|
12
|
-
/**
|
|
13
|
-
* 固有署名ヘッダー識別子
|
|
14
|
-
*/
|
|
15
|
-
headerIdentifier?: string;
|
|
16
|
-
}
|
|
17
2
|
interface ISurfrockSettings {
|
|
18
3
|
/**
|
|
19
4
|
* 着券時タイムアウト
|
|
@@ -47,7 +32,6 @@ interface IOptions {
|
|
|
47
32
|
};
|
|
48
33
|
movieticketReserve: ISurfrockSettings;
|
|
49
34
|
useExperimentalFeature: boolean;
|
|
50
|
-
notification: IWebhookSettings;
|
|
51
35
|
}
|
|
52
36
|
/**
|
|
53
37
|
* domain settings
|
|
@@ -69,10 +53,9 @@ declare class Settings {
|
|
|
69
53
|
/**
|
|
70
54
|
* 通知設定
|
|
71
55
|
*/
|
|
72
|
-
readonly notification: IWebhookSettings;
|
|
73
56
|
constructor(options: IOptions);
|
|
74
57
|
}
|
|
75
58
|
export declare const MONGO_MAX_TIME_MS: number;
|
|
76
59
|
export declare const MONGO_READ_PREFERENCE: string;
|
|
77
60
|
export declare const MONGO_AUTO_INDEX: boolean;
|
|
78
|
-
export { AggregationSettings, Settings, ICallableTaskOperation, ICallResult, IOperationExecute
|
|
61
|
+
export { AggregationSettings, Settings, ICallableTaskOperation, ICallResult, IOperationExecute };
|
package/lib/chevre/settings.js
CHANGED
|
@@ -7,22 +7,20 @@ Object.defineProperty(exports, "AggregationSettings", { enumerable: true, get: f
|
|
|
7
7
|
* domain settings
|
|
8
8
|
*/
|
|
9
9
|
class Settings {
|
|
10
|
+
/**
|
|
11
|
+
* 通知設定
|
|
12
|
+
*/
|
|
13
|
+
// public readonly notification: IWebhookSettings; // migrate to SettingRepo(2024-12-11~)
|
|
10
14
|
constructor(options) {
|
|
11
|
-
const { abortedTasksWithoutReport, numTryConfirmReserveTransaction,
|
|
12
|
-
// transaction,
|
|
13
|
-
deliverOrderLimit, coa, gmo, movieticketReserve,
|
|
14
|
-
// useAssetTransactionSyncProcessing,
|
|
15
|
-
useExperimentalFeature, notification } = options;
|
|
15
|
+
const { abortedTasksWithoutReport, numTryConfirmReserveTransaction, deliverOrderLimit, coa, gmo, movieticketReserve, useExperimentalFeature } = options;
|
|
16
16
|
this.abortedTasksWithoutReport = abortedTasksWithoutReport;
|
|
17
17
|
this.numTryConfirmReserveTransaction = numTryConfirmReserveTransaction;
|
|
18
|
-
// this.transaction = transaction;
|
|
19
18
|
this.deliverOrderLimit = deliverOrderLimit;
|
|
20
19
|
this.coa = coa;
|
|
21
20
|
this.gmo = gmo;
|
|
22
21
|
this.movieticketReserve = movieticketReserve;
|
|
23
|
-
// this.useAssetTransactionSyncProcessing = useAssetTransactionSyncProcessing;
|
|
24
22
|
this.useExperimentalFeature = useExperimentalFeature;
|
|
25
|
-
this.notification = notification;
|
|
23
|
+
// this.notification = notification;
|
|
26
24
|
}
|
|
27
25
|
}
|
|
28
26
|
exports.Settings = Settings;
|
package/package.json
CHANGED