@chevre/domain 22.5.0-alpha.38 → 22.5.0-alpha.39
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 +1 -7
- package/lib/chevre/repo/assetTransaction.d.ts +1 -1
- package/lib/chevre/repo/task.d.ts +24 -24
- package/lib/chevre/repo/transaction.d.ts +1 -1
- package/lib/chevre/service/task/handleNotification.js +5 -2
- package/lib/chevre/service/task.d.ts +2 -1
- package/lib/chevre/settings/aggregation.d.ts +29 -0
- package/lib/chevre/settings/aggregation.js +20 -0
- package/lib/chevre/settings.d.ts +5 -4
- package/lib/chevre/settings.js +11 -9
- package/package.json +1 -1
|
@@ -41,13 +41,7 @@ export async function aggregateScreeningEvent() {
|
|
|
41
41
|
connection: mongoose.connection,
|
|
42
42
|
redisClient,
|
|
43
43
|
credentials: {
|
|
44
|
-
sendGrid: await chevre.credentials.SendGrid.createInstance({ apiKey: 'xxx' })
|
|
45
|
-
lineNotify: await chevre.credentials.LINENotify.createInstance({
|
|
46
|
-
url: 'xxx',
|
|
47
|
-
accessToken: 'xxx',
|
|
48
|
-
accessTokenAlert: 'xxx',
|
|
49
|
-
accessTokenInfo: 'xxx'
|
|
50
|
-
})
|
|
44
|
+
sendGrid: await chevre.credentials.SendGrid.createInstance({ apiKey: 'xxx' })
|
|
51
45
|
},
|
|
52
46
|
settings: new chevre.settings.Settings({
|
|
53
47
|
onEventChanged: {
|
|
@@ -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" | "status" | "typeOf">[]>;
|
|
130
130
|
/**
|
|
131
131
|
* set task status exported by transaction id
|
|
132
132
|
* IDでタスクをエクスポート済に変更する
|
|
@@ -184,60 +184,60 @@ 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
|
+
data: any;
|
|
188
|
+
numberOfTried: number;
|
|
187
189
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
188
|
-
|
|
189
|
-
|
|
190
|
+
remainingNumberOfTries: number;
|
|
191
|
+
runsAt: Date;
|
|
190
192
|
expires?: Date | undefined;
|
|
191
|
-
|
|
193
|
+
name: factory.taskName;
|
|
194
|
+
identifier?: string | undefined;
|
|
192
195
|
status: factory.taskStatus;
|
|
193
|
-
runsAt: Date;
|
|
194
|
-
remainingNumberOfTries: number;
|
|
195
196
|
lastTriedAt?: Date | undefined;
|
|
196
|
-
numberOfTried: number;
|
|
197
197
|
executionResults: import("@chevre/factory/lib/task").IExecutionResult[];
|
|
198
198
|
executor?: import("@chevre/factory/lib/task").IExecutor | undefined;
|
|
199
199
|
dateAborted?: Date | undefined;
|
|
200
200
|
}> & {
|
|
201
|
+
data: any;
|
|
202
|
+
numberOfTried: number;
|
|
201
203
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
+
remainingNumberOfTries: number;
|
|
205
|
+
runsAt: Date;
|
|
204
206
|
expires?: Date | undefined;
|
|
205
|
-
|
|
207
|
+
name: factory.taskName;
|
|
208
|
+
identifier?: string | undefined;
|
|
206
209
|
status: factory.taskStatus;
|
|
207
|
-
runsAt: Date;
|
|
208
|
-
remainingNumberOfTries: number;
|
|
209
210
|
lastTriedAt?: Date | undefined;
|
|
210
|
-
numberOfTried: number;
|
|
211
211
|
executionResults: import("@chevre/factory/lib/task").IExecutionResult[];
|
|
212
212
|
executor?: import("@chevre/factory/lib/task").IExecutor | undefined;
|
|
213
213
|
dateAborted?: Date | undefined;
|
|
214
214
|
} & {
|
|
215
215
|
_id: import("mongoose").Types.ObjectId;
|
|
216
216
|
}, import("mongoose").QueryOptions<import("mongoose").Document<unknown, {}, {
|
|
217
|
+
data: any;
|
|
218
|
+
numberOfTried: number;
|
|
217
219
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
218
|
-
|
|
219
|
-
|
|
220
|
+
remainingNumberOfTries: number;
|
|
221
|
+
runsAt: Date;
|
|
220
222
|
expires?: Date | undefined;
|
|
221
|
-
|
|
223
|
+
name: factory.taskName;
|
|
224
|
+
identifier?: string | undefined;
|
|
222
225
|
status: factory.taskStatus;
|
|
223
|
-
runsAt: Date;
|
|
224
|
-
remainingNumberOfTries: number;
|
|
225
226
|
lastTriedAt?: Date | undefined;
|
|
226
|
-
numberOfTried: number;
|
|
227
227
|
executionResults: import("@chevre/factory/lib/task").IExecutionResult[];
|
|
228
228
|
executor?: import("@chevre/factory/lib/task").IExecutor | undefined;
|
|
229
229
|
dateAborted?: Date | undefined;
|
|
230
230
|
}> & {
|
|
231
|
+
data: any;
|
|
232
|
+
numberOfTried: number;
|
|
231
233
|
project: Pick<factory.project.IProject, "id" | "typeOf">;
|
|
232
|
-
|
|
233
|
-
|
|
234
|
+
remainingNumberOfTries: number;
|
|
235
|
+
runsAt: Date;
|
|
234
236
|
expires?: Date | undefined;
|
|
235
|
-
|
|
237
|
+
name: factory.taskName;
|
|
238
|
+
identifier?: string | undefined;
|
|
236
239
|
status: factory.taskStatus;
|
|
237
|
-
runsAt: Date;
|
|
238
|
-
remainingNumberOfTries: number;
|
|
239
240
|
lastTriedAt?: Date | undefined;
|
|
240
|
-
numberOfTried: number;
|
|
241
241
|
executionResults: import("@chevre/factory/lib/task").IExecutionResult[];
|
|
242
242
|
executor?: import("@chevre/factory/lib/task").IExecutor | undefined;
|
|
243
243
|
dateAborted?: Date | undefined;
|
|
@@ -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" | "status" | "typeOf">[]>;
|
|
162
162
|
/**
|
|
163
163
|
* set task status exported by transaction id
|
|
164
164
|
* IDでタスクをエクスポート済に変更する
|
|
@@ -14,13 +14,16 @@ const createDebug = require("debug");
|
|
|
14
14
|
const debug = createDebug('chevre-domain:service:task');
|
|
15
15
|
// let notification: typeof NotificationService | undefined;
|
|
16
16
|
function call(params) {
|
|
17
|
-
return () => __awaiter(this, void 0, void 0, function* () {
|
|
18
|
-
// return async ({ credentials, settings }) => {
|
|
17
|
+
return ({ aggregationSettings }) => __awaiter(this, void 0, void 0, function* () {
|
|
19
18
|
const { data } = params;
|
|
20
19
|
const { object } = data;
|
|
21
20
|
debug('handleNotification processing... object:', object);
|
|
22
21
|
// tslint:disable-next-line:no-suspicious-comment
|
|
23
22
|
// TODO implement
|
|
23
|
+
const handleNotification = aggregationSettings === null || aggregationSettings === void 0 ? void 0 : aggregationSettings.handleNotification;
|
|
24
|
+
if (typeof handleNotification === 'function') {
|
|
25
|
+
yield handleNotification(params);
|
|
26
|
+
}
|
|
24
27
|
// let message = `projectId: ${(Array.isArray(object)) ? object.at(0)?.project?.id : object?.project.id}
|
|
25
28
|
// taskId: ${params.id}
|
|
26
29
|
// ${util.inspect(data, { depth: 1 })}
|
|
@@ -10,10 +10,10 @@ import { SendGridCredentials } from '../credentials/sendGrid';
|
|
|
10
10
|
import * as factory from '../factory';
|
|
11
11
|
import type { IExecutableTask, IExecutableTaskKeys, TaskRepo } from '../repo/task';
|
|
12
12
|
import { Settings } from '../settings';
|
|
13
|
+
import { AggregationSettings } from '../settings/aggregation';
|
|
13
14
|
interface ICredentialSettings {
|
|
14
15
|
jwt?: JWTCredentials;
|
|
15
16
|
sendGrid: SendGridCredentials;
|
|
16
|
-
lineNotify?: LINENotifyCredentials;
|
|
17
17
|
}
|
|
18
18
|
interface IExecuteSettings {
|
|
19
19
|
/**
|
|
@@ -26,6 +26,7 @@ interface IExecuteSettings {
|
|
|
26
26
|
redisClient?: RedisClientType;
|
|
27
27
|
credentials: ICredentialSettings;
|
|
28
28
|
settings: Settings;
|
|
29
|
+
aggregationSettings?: AggregationSettings;
|
|
29
30
|
coaAuthClient?: COA.auth.RefreshToken;
|
|
30
31
|
}
|
|
31
32
|
interface IExecuteOptions {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as factory from '../factory';
|
|
2
|
+
interface IOnOrderStatusChanged {
|
|
3
|
+
informOrder2hub?: factory.project.IInformParams[];
|
|
4
|
+
}
|
|
5
|
+
interface IOnReservationStatusChanged {
|
|
6
|
+
informReservation2hub?: factory.project.IInformParams[];
|
|
7
|
+
}
|
|
8
|
+
interface IOptions {
|
|
9
|
+
handleNotification?: IHandleNotification;
|
|
10
|
+
onOrderStatusChanged: IOnOrderStatusChanged;
|
|
11
|
+
onReservationStatusChanged: IOnReservationStatusChanged;
|
|
12
|
+
useAggregateEntranceGateProjects: string[];
|
|
13
|
+
useAggregateOfferProjects: string[];
|
|
14
|
+
useOfferRateLimitProjects: string[];
|
|
15
|
+
}
|
|
16
|
+
type IHandleNotification = (params: Pick<factory.task.handleNotification.ITask, 'data' | 'id' | 'numberOfTried' | 'project' | 'remainingNumberOfTries' | 'runsAt' | 'expires'>) => Promise<void>;
|
|
17
|
+
/**
|
|
18
|
+
* aggregation domain settings
|
|
19
|
+
*/
|
|
20
|
+
declare class AggregationSettings {
|
|
21
|
+
readonly handleNotification?: IHandleNotification;
|
|
22
|
+
readonly onOrderStatusChanged: IOnOrderStatusChanged;
|
|
23
|
+
readonly onReservationStatusChanged: IOnReservationStatusChanged;
|
|
24
|
+
readonly useAggregateEntranceGateProjects: string[];
|
|
25
|
+
readonly useAggregateOfferProjects: string[];
|
|
26
|
+
readonly useOfferRateLimitProjects: string[];
|
|
27
|
+
constructor(options: IOptions);
|
|
28
|
+
}
|
|
29
|
+
export { AggregationSettings };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AggregationSettings = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* aggregation domain settings
|
|
6
|
+
*/
|
|
7
|
+
class AggregationSettings {
|
|
8
|
+
constructor(options) {
|
|
9
|
+
const { handleNotification, onOrderStatusChanged, onReservationStatusChanged, useAggregateEntranceGateProjects, useAggregateOfferProjects, useOfferRateLimitProjects } = options;
|
|
10
|
+
this.onOrderStatusChanged = onOrderStatusChanged;
|
|
11
|
+
this.onReservationStatusChanged = onReservationStatusChanged;
|
|
12
|
+
this.useAggregateEntranceGateProjects = useAggregateEntranceGateProjects;
|
|
13
|
+
this.useAggregateOfferProjects = useAggregateOfferProjects;
|
|
14
|
+
this.useOfferRateLimitProjects = useOfferRateLimitProjects;
|
|
15
|
+
if (handleNotification !== undefined) {
|
|
16
|
+
this.handleNotification = handleNotification;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
exports.AggregationSettings = AggregationSettings;
|
package/lib/chevre/settings.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import * as factory from './factory';
|
|
2
|
-
|
|
3
|
-
export declare const MONGO_READ_PREFERENCE: string;
|
|
4
|
-
export declare const MONGO_AUTO_INDEX: boolean;
|
|
2
|
+
import { AggregationSettings } from './settings/aggregation';
|
|
5
3
|
interface IOnOrderStatusChanged {
|
|
6
4
|
informOrder?: factory.project.IInformParams[];
|
|
7
5
|
informOrder2hub?: factory.project.IInformParams[];
|
|
@@ -146,4 +144,7 @@ declare class Settings {
|
|
|
146
144
|
};
|
|
147
145
|
constructor(options: IOptions);
|
|
148
146
|
}
|
|
149
|
-
export
|
|
147
|
+
export declare const MONGO_MAX_TIME_MS: number;
|
|
148
|
+
export declare const MONGO_READ_PREFERENCE: string;
|
|
149
|
+
export declare const MONGO_AUTO_INDEX: boolean;
|
|
150
|
+
export { AggregationSettings, Settings };
|
package/lib/chevre/settings.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Settings = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
// tslint:disable-next-line:no-magic-numbers
|
|
7
|
-
: 10000;
|
|
8
|
-
exports.MONGO_READ_PREFERENCE = (typeof process.env.MONGO_READ_PREFERENCE === 'string')
|
|
9
|
-
? process.env.MONGO_READ_PREFERENCE
|
|
10
|
-
: 'primaryPreferred';
|
|
11
|
-
exports.MONGO_AUTO_INDEX = process.env.MONGO_AUTO_INDEX === '1';
|
|
3
|
+
exports.Settings = exports.AggregationSettings = exports.MONGO_AUTO_INDEX = exports.MONGO_READ_PREFERENCE = exports.MONGO_MAX_TIME_MS = void 0;
|
|
4
|
+
const aggregation_1 = require("./settings/aggregation");
|
|
5
|
+
Object.defineProperty(exports, "AggregationSettings", { enumerable: true, get: function () { return aggregation_1.AggregationSettings; } });
|
|
12
6
|
/**
|
|
13
7
|
* domain settings
|
|
14
8
|
*/
|
|
@@ -38,3 +32,11 @@ class Settings {
|
|
|
38
32
|
}
|
|
39
33
|
}
|
|
40
34
|
exports.Settings = Settings;
|
|
35
|
+
exports.MONGO_MAX_TIME_MS = (typeof process.env.MONGO_MAX_TIME_MS === 'string')
|
|
36
|
+
? Number(process.env.MONGO_MAX_TIME_MS)
|
|
37
|
+
// tslint:disable-next-line:no-magic-numbers
|
|
38
|
+
: 10000;
|
|
39
|
+
exports.MONGO_READ_PREFERENCE = (typeof process.env.MONGO_READ_PREFERENCE === 'string')
|
|
40
|
+
? process.env.MONGO_READ_PREFERENCE
|
|
41
|
+
: 'primaryPreferred';
|
|
42
|
+
exports.MONGO_AUTO_INDEX = process.env.MONGO_AUTO_INDEX === '1';
|
package/package.json
CHANGED