@chevre/domain 25.0.0 → 25.1.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/chevre/repo/mongoose/schemas/setting.d.ts +28 -0
- package/lib/chevre/repo/mongoose/schemas/setting.js +2 -1
- package/lib/chevre/repo/setting/rateLimit.d.ts +18 -0
- package/lib/chevre/repo/setting/rateLimit.js +48 -0
- package/lib/chevre/repository.d.ts +5 -0
- package/lib/chevre/repository.js +11 -0
- package/lib/chevre/service/transaction/deleteTransaction.js +10 -9
- package/lib/chevre/service/transaction/placeOrder/exportTasks/factory.js +3 -3
- package/lib/chevre/service/transaction/returnOrder/exportTasks/factory.js +3 -3
- package/package.json +2 -2
|
@@ -219,6 +219,33 @@ export interface IIntegrationSettings {
|
|
|
219
219
|
hub?: IHubSettings;
|
|
220
220
|
useExperimentalFeature: boolean;
|
|
221
221
|
}
|
|
222
|
+
/**
|
|
223
|
+
* 2026-06-30~
|
|
224
|
+
*/
|
|
225
|
+
export interface IRateLimitSetting {
|
|
226
|
+
unitInSeconds: number;
|
|
227
|
+
thresholdGloballyByProject: number;
|
|
228
|
+
thresholdGloballyByProjectGet: number;
|
|
229
|
+
thresholdGlobally: number;
|
|
230
|
+
thresholdGloballyGet: number;
|
|
231
|
+
thresholdSoftware: number;
|
|
232
|
+
exceptionClient: string[];
|
|
233
|
+
/**
|
|
234
|
+
* 進行中取引の接続回数制限
|
|
235
|
+
* 取引IDごとにレート制限
|
|
236
|
+
*/
|
|
237
|
+
transactionUnitInSeconds: number;
|
|
238
|
+
/**
|
|
239
|
+
* 進行中取引の接続回数制限
|
|
240
|
+
* 取引IDごとにレート制限
|
|
241
|
+
*/
|
|
242
|
+
transactionThreshold: number;
|
|
243
|
+
/**
|
|
244
|
+
* 進行中取引の接続回数制限
|
|
245
|
+
* 取引IDごとにレート制限
|
|
246
|
+
*/
|
|
247
|
+
transactionThresholdGet: number;
|
|
248
|
+
}
|
|
222
249
|
export interface ISetting {
|
|
223
250
|
defaultSenderEmail?: string;
|
|
224
251
|
jwt?: IJWTSetting;
|
|
@@ -256,6 +283,7 @@ export interface ISetting {
|
|
|
256
283
|
* 環境変数から移行(2026-05-23~)
|
|
257
284
|
*/
|
|
258
285
|
integration?: IIntegrationSettings;
|
|
286
|
+
rateLimit?: IRateLimitSetting;
|
|
259
287
|
}
|
|
260
288
|
type IDocType = ISetting;
|
|
261
289
|
type IModel = Model<IDocType, Record<string, never>, Record<string, never>, IVirtuals>;
|
|
@@ -32,7 +32,8 @@ const schemaDefinition = {
|
|
|
32
32
|
useMongo4confirmationNumberFrom: { type: Date, required: false },
|
|
33
33
|
useMongo4orderNumberFrom: { type: Date, required: false },
|
|
34
34
|
useMongo4transactionNumberFrom: { type: Date, required: false },
|
|
35
|
-
integration: { type: mongoose_1.SchemaTypes.Mixed, required: false } // 2026-05-23~
|
|
35
|
+
integration: { type: mongoose_1.SchemaTypes.Mixed, required: false }, // 2026-05-23~
|
|
36
|
+
rateLimit: { type: mongoose_1.SchemaTypes.Mixed, required: false } // 2026-06-30~
|
|
36
37
|
};
|
|
37
38
|
const schemaOptions = {
|
|
38
39
|
autoIndex: settings_1.MONGO_AUTO_INDEX,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Connection } from 'mongoose';
|
|
2
|
+
import { IRateLimitSetting } from '../mongoose/schemas/setting';
|
|
3
|
+
interface IDBOptions {
|
|
4
|
+
connection: Connection;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* apisレート制限設定リポジトリ
|
|
8
|
+
*/
|
|
9
|
+
export declare class RateLimitSettingRepo {
|
|
10
|
+
private readonly settingModel;
|
|
11
|
+
private static cachedSettings;
|
|
12
|
+
private static cacheExpiry;
|
|
13
|
+
private static readonly CACHE_TTL_MS;
|
|
14
|
+
constructor(options: IDBOptions);
|
|
15
|
+
findRateLimitSetting(): Promise<IRateLimitSetting>;
|
|
16
|
+
addRateLimitSetting(params: IRateLimitSetting): Promise<import("mongoose").UpdateWriteOpResult>;
|
|
17
|
+
}
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RateLimitSettingRepo = void 0;
|
|
4
|
+
const factory_1 = require("../../factory");
|
|
5
|
+
const setting_1 = require("../mongoose/schemas/setting");
|
|
6
|
+
/**
|
|
7
|
+
* apisレート制限設定リポジトリ
|
|
8
|
+
*/
|
|
9
|
+
class RateLimitSettingRepo {
|
|
10
|
+
settingModel;
|
|
11
|
+
// static にすることで、クラスが何回 new されてもメモリ上で1つだけ保持される
|
|
12
|
+
static cachedSettings;
|
|
13
|
+
static cacheExpiry = 0;
|
|
14
|
+
static CACHE_TTL_MS = 10 * 60 * 1000; // 10分
|
|
15
|
+
constructor(options) {
|
|
16
|
+
const { connection } = options;
|
|
17
|
+
this.settingModel = connection.model(setting_1.modelName, (0, setting_1.createSchema)());
|
|
18
|
+
}
|
|
19
|
+
async findRateLimitSetting() {
|
|
20
|
+
const now = Date.now();
|
|
21
|
+
// キャッシュ参照
|
|
22
|
+
if (RateLimitSettingRepo.cachedSettings !== undefined && now < RateLimitSettingRepo.cacheExpiry) {
|
|
23
|
+
return RateLimitSettingRepo.cachedSettings;
|
|
24
|
+
}
|
|
25
|
+
const settingDoc = await this.settingModel.findOne({ 'project.id': { $eq: '*' } }, {
|
|
26
|
+
_id: 0,
|
|
27
|
+
rateLimit: 1
|
|
28
|
+
})
|
|
29
|
+
.lean()
|
|
30
|
+
.exec();
|
|
31
|
+
if (settingDoc?.rateLimit === undefined) {
|
|
32
|
+
throw new factory_1.factory.errors.NotFound('rateLimitSetting');
|
|
33
|
+
}
|
|
34
|
+
// キャッシュを更新
|
|
35
|
+
RateLimitSettingRepo.cachedSettings = settingDoc.rateLimit;
|
|
36
|
+
RateLimitSettingRepo.cacheExpiry = now + RateLimitSettingRepo.CACHE_TTL_MS;
|
|
37
|
+
return RateLimitSettingRepo.cachedSettings;
|
|
38
|
+
}
|
|
39
|
+
async addRateLimitSetting(params) {
|
|
40
|
+
return this.settingModel.updateOne({ 'project.id': { $eq: '*' } }, {
|
|
41
|
+
$set: {
|
|
42
|
+
rateLimit: params
|
|
43
|
+
}
|
|
44
|
+
})
|
|
45
|
+
.exec();
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
exports.RateLimitSettingRepo = RateLimitSettingRepo;
|
|
@@ -81,6 +81,7 @@ import type { ServiceAvailableHourRepo } from './repo/service/availableHour';
|
|
|
81
81
|
import type { SettingRepo } from './repo/setting';
|
|
82
82
|
import type { IntegrationSettingRepo } from './repo/setting/integration';
|
|
83
83
|
import type { JWTSettingRepo } from './repo/setting/jwt';
|
|
84
|
+
import type { RateLimitSettingRepo } from './repo/setting/rateLimit';
|
|
84
85
|
import type { WaiterSettingRepo } from './repo/setting/waiter';
|
|
85
86
|
import type { StockHolderRepo } from './repo/stockHolder';
|
|
86
87
|
import type { TaskRepo } from './repo/task';
|
|
@@ -447,6 +448,10 @@ export declare namespace setting {
|
|
|
447
448
|
namespace JWT {
|
|
448
449
|
function createInstance(...params: ConstructorParameters<typeof JWTSettingRepo>): Promise<JWTSettingRepo>;
|
|
449
450
|
}
|
|
451
|
+
type RateLimit = RateLimitSettingRepo;
|
|
452
|
+
namespace RateLimit {
|
|
453
|
+
function createInstance(...params: ConstructorParameters<typeof RateLimitSettingRepo>): Promise<RateLimitSettingRepo>;
|
|
454
|
+
}
|
|
450
455
|
type Waiter = WaiterSettingRepo;
|
|
451
456
|
namespace Waiter {
|
|
452
457
|
function createInstance(...params: ConstructorParameters<typeof WaiterSettingRepo>): Promise<WaiterSettingRepo>;
|
package/lib/chevre/repository.js
CHANGED
|
@@ -933,6 +933,17 @@ var setting;
|
|
|
933
933
|
}
|
|
934
934
|
JWT.createInstance = createInstance;
|
|
935
935
|
})(JWT = setting.JWT || (setting.JWT = {}));
|
|
936
|
+
let RateLimit;
|
|
937
|
+
(function (RateLimit) {
|
|
938
|
+
let repo;
|
|
939
|
+
async function createInstance(...params) {
|
|
940
|
+
if (repo === undefined) {
|
|
941
|
+
repo = (await import('./repo/setting/rateLimit.js')).RateLimitSettingRepo;
|
|
942
|
+
}
|
|
943
|
+
return new repo(...params);
|
|
944
|
+
}
|
|
945
|
+
RateLimit.createInstance = createInstance;
|
|
946
|
+
})(RateLimit = setting.RateLimit || (setting.RateLimit = {}));
|
|
936
947
|
let Waiter;
|
|
937
948
|
(function (Waiter) {
|
|
938
949
|
let repo;
|
|
@@ -10,14 +10,14 @@ const deleteOrder_1 = require("../order/deleteOrder");
|
|
|
10
10
|
*/
|
|
11
11
|
function deleteTransaction(params) {
|
|
12
12
|
return async (repos) => {
|
|
13
|
-
if (params.object.specifyingMethod ===
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
// if (params.object.specifyingMethod === factory.action.update.deleteAction.ObjectAsTransactionSpecifyingMethod.AgentId) {
|
|
14
|
+
// throw new factory.errors.NotImplemented('deleteTransaction by agentId discontinued'); // discontinue(2026-06-28~)
|
|
15
|
+
// // // transaction.agent.id指定による取引削除に対応(2023-06-30~)
|
|
16
|
+
// // await createDeleteTransactionTasksByAgentId(params)(repos);
|
|
17
|
+
// } else {
|
|
18
|
+
// await deleteTransactionById(params)(repos);
|
|
19
|
+
// }
|
|
20
|
+
await deleteTransactionById(params)(repos);
|
|
21
21
|
};
|
|
22
22
|
}
|
|
23
23
|
function deleteTransactionById(params) {
|
|
@@ -55,10 +55,11 @@ function deleteTransactionById(params) {
|
|
|
55
55
|
return;
|
|
56
56
|
}
|
|
57
57
|
// アクション開始
|
|
58
|
+
const { project: _project, startDate: _startDate, endDate: _endDate, ...minimizedObject } = params.object; // minimize object(2026-07-01~)
|
|
58
59
|
const actionAttributes = {
|
|
59
60
|
typeOf: factory_1.factory.actionType.DeleteAction,
|
|
60
61
|
project: transaction.project,
|
|
61
|
-
object:
|
|
62
|
+
object: minimizedObject,
|
|
62
63
|
agent: transaction.project
|
|
63
64
|
};
|
|
64
65
|
let deletePayTransactionResult;
|
|
@@ -104,10 +104,10 @@ function createTasks(params, setting) {
|
|
|
104
104
|
? { orderNumber: transaction.object.orderNumber }
|
|
105
105
|
: undefined
|
|
106
106
|
},
|
|
107
|
-
project: transaction.project,
|
|
108
|
-
startDate: transaction.startDate,
|
|
107
|
+
// project: transaction.project,
|
|
108
|
+
// startDate: transaction.startDate,
|
|
109
109
|
typeOf: transaction.typeOf,
|
|
110
|
-
...(transaction.endDate !== undefined) ? { endDate: transaction.endDate } : undefined
|
|
110
|
+
// ...(transaction.endDate !== undefined) ? { endDate: transaction.endDate } : undefined
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
};
|
|
@@ -59,10 +59,10 @@ function createTasks(params, setting
|
|
|
59
59
|
object: {
|
|
60
60
|
order: transaction.object.order
|
|
61
61
|
},
|
|
62
|
-
project: transaction.project,
|
|
63
|
-
startDate: transaction.startDate,
|
|
62
|
+
// project: transaction.project,
|
|
63
|
+
// startDate: transaction.startDate,
|
|
64
64
|
typeOf: transaction.typeOf,
|
|
65
|
-
...(transaction.endDate !== undefined) ? { endDate: transaction.endDate } : undefined
|
|
65
|
+
// ...(transaction.endDate !== undefined) ? { endDate: transaction.endDate } : undefined
|
|
66
66
|
}
|
|
67
67
|
}
|
|
68
68
|
};
|
package/package.json
CHANGED
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dependencies": {
|
|
12
12
|
"@aws-sdk/client-cognito-identity-provider": "3.600.0",
|
|
13
13
|
"@aws-sdk/credential-providers": "3.600.0",
|
|
14
|
-
"@chevre/factory": "9.
|
|
14
|
+
"@chevre/factory": "9.4.0",
|
|
15
15
|
"@motionpicture/coa-service": "10.0.0",
|
|
16
16
|
"@motionpicture/gmo-service": "6.1.0-alpha.0",
|
|
17
17
|
"@sendgrid/client": "8.1.4",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"postversion": "git push origin --tags",
|
|
92
92
|
"prepublishOnly": "npm run clean && npm run build"
|
|
93
93
|
},
|
|
94
|
-
"version": "25.0.
|
|
94
|
+
"version": "25.1.0-alpha.1"
|
|
95
95
|
}
|