@loopstack/quota 0.22.3 → 0.24.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/README.md +1 -1
- package/dist/calculators/__tests__/ai-generate-text-quota.calculator.spec.js +71 -34
- package/dist/calculators/__tests__/ai-generate-text-quota.calculator.spec.js.map +1 -1
- package/dist/calculators/__tests__/processing-time-quota.calculator.spec.js +3 -4
- package/dist/calculators/__tests__/processing-time-quota.calculator.spec.js.map +1 -1
- package/dist/calculators/ai-generate-text-quota.calculator.d.ts +2 -2
- package/dist/calculators/ai-generate-text-quota.calculator.d.ts.map +1 -1
- package/dist/calculators/ai-generate-text-quota.calculator.js +19 -19
- package/dist/calculators/ai-generate-text-quota.calculator.js.map +1 -1
- package/dist/calculators/index.d.ts +3 -2
- package/dist/calculators/index.d.ts.map +1 -1
- package/dist/calculators/index.js +3 -18
- package/dist/calculators/index.js.map +1 -1
- package/dist/calculators/model-pricing.d.ts +8 -0
- package/dist/calculators/model-pricing.d.ts.map +1 -0
- package/dist/calculators/model-pricing.js +59 -0
- package/dist/calculators/model-pricing.js.map +1 -0
- package/dist/calculators/processing-time-quota.calculator.d.ts +2 -2
- package/dist/calculators/processing-time-quota.calculator.d.ts.map +1 -1
- package/dist/calculators/processing-time-quota.calculator.js +1 -5
- package/dist/calculators/processing-time-quota.calculator.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -20
- package/dist/index.js.map +1 -1
- package/dist/interfaces/index.d.ts +3 -3
- package/dist/interfaces/index.d.ts.map +1 -1
- package/dist/interfaces/index.js +3 -19
- package/dist/interfaces/index.js.map +1 -1
- package/dist/interfaces/quota-client.interface.js +1 -4
- package/dist/interfaces/quota-client.interface.js.map +1 -1
- package/dist/interfaces/quota.interface.js +1 -2
- package/dist/interfaces/tool-quota-calculator.interface.d.ts +1 -1
- package/dist/interfaces/tool-quota-calculator.interface.d.ts.map +1 -1
- package/dist/interfaces/tool-quota-calculator.interface.js +1 -2
- package/dist/quota.module.d.ts +1 -1
- package/dist/quota.module.d.ts.map +1 -1
- package/dist/quota.module.js +29 -30
- package/dist/quota.module.js.map +1 -1
- package/dist/services/__tests__/quota-calculator-registry.service.spec.js +3 -4
- package/dist/services/__tests__/quota-calculator-registry.service.spec.js.map +1 -1
- package/dist/services/__tests__/quota-client.service.spec.js +19 -20
- package/dist/services/__tests__/quota-client.service.spec.js.map +1 -1
- package/dist/services/__tests__/quota.interceptor.spec.js +21 -22
- package/dist/services/__tests__/quota.interceptor.spec.js.map +1 -1
- package/dist/services/index.d.ts +3 -3
- package/dist/services/index.d.ts.map +1 -1
- package/dist/services/index.js +3 -19
- package/dist/services/index.js.map +1 -1
- package/dist/services/quota-calculator-registry.service.d.ts +1 -1
- package/dist/services/quota-calculator-registry.service.d.ts.map +1 -1
- package/dist/services/quota-calculator-registry.service.js +5 -8
- package/dist/services/quota-calculator-registry.service.js.map +1 -1
- package/dist/services/quota-client.service.d.ts +2 -2
- package/dist/services/quota-client.service.d.ts.map +1 -1
- package/dist/services/quota-client.service.js +8 -11
- package/dist/services/quota-client.service.js.map +1 -1
- package/dist/services/quota.interceptor.d.ts +2 -2
- package/dist/services/quota.interceptor.d.ts.map +1 -1
- package/dist/services/quota.interceptor.js +12 -15
- package/dist/services/quota.interceptor.js.map +1 -1
- package/package.json +11 -36
package/dist/quota.module.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -8,40 +7,31 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
9
|
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
10
|
var QuotaModule_1;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const interfaces_1 = require("./interfaces");
|
|
21
|
-
const services_1 = require("./services");
|
|
11
|
+
import { Module } from '@nestjs/common';
|
|
12
|
+
import { Redis } from 'ioredis';
|
|
13
|
+
import { AiGenerateTextQuotaCalculator } from './calculators/index.js';
|
|
14
|
+
import { QUOTA_CLIENT_SERVICE } from './interfaces/index.js';
|
|
15
|
+
import { QUOTA_REDIS, QuotaCalculatorRegistry, QuotaClientService, QuotaInterceptor } from './services/index.js';
|
|
22
16
|
let QuotaModule = QuotaModule_1 = class QuotaModule {
|
|
23
17
|
calculatorRegistry;
|
|
24
18
|
constructor(calculatorRegistry) {
|
|
25
19
|
this.calculatorRegistry = calculatorRegistry;
|
|
26
20
|
}
|
|
27
21
|
onModuleInit() {
|
|
28
|
-
const aiTokenCalculator = new
|
|
29
|
-
this.calculatorRegistry.register('
|
|
30
|
-
this.calculatorRegistry.register('
|
|
31
|
-
this.calculatorRegistry.register('AiGenerateDocument', aiTokenCalculator);
|
|
32
|
-
this.calculatorRegistry.register('ClaudeGenerateText', aiTokenCalculator);
|
|
33
|
-
this.calculatorRegistry.register('ClaudeGenerateObject', aiTokenCalculator);
|
|
34
|
-
this.calculatorRegistry.register('ClaudeGenerateDocument', aiTokenCalculator);
|
|
22
|
+
const aiTokenCalculator = new AiGenerateTextQuotaCalculator();
|
|
23
|
+
this.calculatorRegistry.register('LlmGenerateTextTool', aiTokenCalculator);
|
|
24
|
+
this.calculatorRegistry.register('LlmGenerateObjectTool', aiTokenCalculator);
|
|
35
25
|
}
|
|
36
26
|
static forRoot(options) {
|
|
37
27
|
const enabled = options?.enabled ?? false;
|
|
38
28
|
const redisProvider = {
|
|
39
|
-
provide:
|
|
29
|
+
provide: QUOTA_REDIS,
|
|
40
30
|
useFactory: () => {
|
|
41
31
|
if (!enabled) {
|
|
42
32
|
return null;
|
|
43
33
|
}
|
|
44
|
-
return new
|
|
34
|
+
return new Redis({
|
|
45
35
|
host: options?.redisHost ?? 'localhost',
|
|
46
36
|
port: options?.redisPort ?? 6379,
|
|
47
37
|
password: options?.redisPassword,
|
|
@@ -58,15 +48,15 @@ let QuotaModule = QuotaModule_1 = class QuotaModule {
|
|
|
58
48
|
global: true,
|
|
59
49
|
providers: [
|
|
60
50
|
redisProvider,
|
|
61
|
-
|
|
51
|
+
QuotaClientService,
|
|
62
52
|
{
|
|
63
|
-
provide:
|
|
64
|
-
useExisting:
|
|
53
|
+
provide: QUOTA_CLIENT_SERVICE,
|
|
54
|
+
useExisting: QuotaClientService,
|
|
65
55
|
},
|
|
66
|
-
|
|
67
|
-
|
|
56
|
+
QuotaCalculatorRegistry,
|
|
57
|
+
QuotaInterceptor,
|
|
68
58
|
],
|
|
69
|
-
exports: [
|
|
59
|
+
exports: [QUOTA_CLIENT_SERVICE, QuotaClientService, QuotaCalculatorRegistry],
|
|
70
60
|
};
|
|
71
61
|
}
|
|
72
62
|
static forRootAsync() {
|
|
@@ -78,9 +68,18 @@ let QuotaModule = QuotaModule_1 = class QuotaModule {
|
|
|
78
68
|
});
|
|
79
69
|
}
|
|
80
70
|
};
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
71
|
+
QuotaModule = QuotaModule_1 = __decorate([
|
|
72
|
+
Module({
|
|
73
|
+
providers: [
|
|
74
|
+
{ provide: QUOTA_REDIS, useValue: null },
|
|
75
|
+
QuotaClientService,
|
|
76
|
+
{ provide: QUOTA_CLIENT_SERVICE, useExisting: QuotaClientService },
|
|
77
|
+
QuotaCalculatorRegistry,
|
|
78
|
+
QuotaInterceptor,
|
|
79
|
+
],
|
|
80
|
+
exports: [QUOTA_CLIENT_SERVICE, QuotaClientService, QuotaCalculatorRegistry],
|
|
81
|
+
}),
|
|
82
|
+
__metadata("design:paramtypes", [QuotaCalculatorRegistry])
|
|
85
83
|
], QuotaModule);
|
|
84
|
+
export { QuotaModule };
|
|
86
85
|
//# sourceMappingURL=quota.module.js.map
|
package/dist/quota.module.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota.module.js","sourceRoot":"","sources":["../src/quota.module.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quota.module.js","sourceRoot":"","sources":["../src/quota.module.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAO,EAAiB,MAAM,EAAgB,MAAM,gBAAgB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AACvE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAmB1G,IAAM,WAAW,mBAAjB,MAAM,WAAW;IACO;IAA7B,YAA6B,kBAA2C;QAA3C,uBAAkB,GAAlB,kBAAkB,CAAyB;IAAG,CAAC;IAE5E,YAAY;QACV,MAAM,iBAAiB,GAAG,IAAI,6BAA6B,EAAE,CAAC;QAC9D,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,qBAAqB,EAAE,iBAAiB,CAAC,CAAC;QAC3E,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,uBAAuB,EAAE,iBAAiB,CAAC,CAAC;IAC/E,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,OAA4B;QACzC,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,KAAK,CAAC;QAE1C,MAAM,aAAa,GAAG;YACpB,OAAO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CAAC;IACL,CAAC;CACF,CAAA;AAxDY,WAAW;IAVvB,MAAM,CAAC;QACN,SAAS,EAAE;YACT,EAAE,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,IAAI,EAAE;YACxC,kBAAkB;YAClB,EAAE,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,kBAAkB,EAAE;YAClE,uBAAuB;YACvB,gBAAgB;SACjB;QACD,OAAO,EAAE,CAAC,oBAAoB,EAAE,kBAAkB,EAAE,uBAAuB,CAAC;KAC7E,CAAC;qCAEiD,uBAAuB;GAD7D,WAAW,CAwDvB"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const quota_calculator_registry_service_1 = require("../quota-calculator-registry.service");
|
|
1
|
+
import { beforeEach, describe, expect, it } from 'vitest';
|
|
2
|
+
import { QuotaCalculatorRegistry } from '../quota-calculator-registry.service.js';
|
|
4
3
|
class MockCalculator {
|
|
5
4
|
quotaType = 'test-type';
|
|
6
5
|
calculateQuotaUsage(_context, _result) {
|
|
@@ -10,7 +9,7 @@ class MockCalculator {
|
|
|
10
9
|
describe('QuotaCalculatorRegistry', () => {
|
|
11
10
|
let registry;
|
|
12
11
|
beforeEach(() => {
|
|
13
|
-
registry = new
|
|
12
|
+
registry = new QuotaCalculatorRegistry();
|
|
14
13
|
});
|
|
15
14
|
it('should register and retrieve a calculator', () => {
|
|
16
15
|
const calculator = new MockCalculator();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-calculator-registry.service.spec.js","sourceRoot":"","sources":["../../../src/services/__tests__/quota-calculator-registry.service.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quota-calculator-registry.service.spec.js","sourceRoot":"","sources":["../../../src/services/__tests__/quota-calculator-registry.service.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAG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CAAC,oDAAoD,EAAE,GAAG,EAAE;QAC5D,MAAM,WAAW,GAAG,IAAI,cAAc,EAAE,CAAC;QACzC,MAAM,WAAW,GAAG,IAAI,cAAc,EAAE,CAAC;QACzC,WAAW,CAAC,SAAS,GAAG,iBAAiB,CAAC;QAE1C,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAC3C,QAAQ,CAAC,QAAQ,CAAC,UAAU,EAAE,WAAW,CAAC,CAAC;QAE3C,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IACrD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,GAAG,EAAE;QACzE,MAAM,UAAU,GAAG,IAAI,cAAc,EAAE,CAAC;QACxC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACvC,QAAQ,CAAC,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QAEvC,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAC/C,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const quota_client_service_1 = require("../quota-client.service");
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { QuotaClientService } from '../quota-client.service.js';
|
|
4
3
|
describe('QuotaClientService', () => {
|
|
5
4
|
describe('without Redis (null)', () => {
|
|
6
5
|
let service;
|
|
7
6
|
beforeEach(() => {
|
|
8
|
-
service = new
|
|
7
|
+
service = new QuotaClientService(null);
|
|
9
8
|
});
|
|
10
9
|
it('checkQuota should return not exceeded with unlimited', async () => {
|
|
11
|
-
const result = await service.checkQuota('user-1', '
|
|
10
|
+
const result = await service.checkQuota('user-1', 'llm-cost');
|
|
12
11
|
expect(result).toEqual({ exceeded: false, used: 0, limit: -1 });
|
|
13
12
|
});
|
|
14
13
|
it('report should complete without error', async () => {
|
|
15
|
-
await expect(service.report('user-1', '
|
|
14
|
+
await expect(service.report('user-1', 'llm-cost', 100)).resolves.toBeUndefined();
|
|
16
15
|
});
|
|
17
16
|
});
|
|
18
17
|
describe('with Redis mock', () => {
|
|
@@ -20,62 +19,62 @@ describe('QuotaClientService', () => {
|
|
|
20
19
|
let redisMock;
|
|
21
20
|
beforeEach(() => {
|
|
22
21
|
redisMock = {
|
|
23
|
-
get:
|
|
24
|
-
incrby:
|
|
22
|
+
get: vi.fn(),
|
|
23
|
+
incrby: vi.fn(),
|
|
25
24
|
};
|
|
26
|
-
service = new
|
|
25
|
+
service = new QuotaClientService(redisMock);
|
|
27
26
|
});
|
|
28
27
|
describe('checkQuota', () => {
|
|
29
28
|
it('should return not exceeded when under limit', async () => {
|
|
30
29
|
redisMock.get.mockResolvedValueOnce('50').mockResolvedValueOnce('1000');
|
|
31
|
-
const result = await service.checkQuota('user-1', '
|
|
30
|
+
const result = await service.checkQuota('user-1', 'llm-cost');
|
|
32
31
|
expect(result).toEqual({ exceeded: false, used: 50, limit: 1000 });
|
|
33
32
|
});
|
|
34
33
|
it('should return exceeded when at limit', async () => {
|
|
35
34
|
redisMock.get.mockResolvedValueOnce('1000').mockResolvedValueOnce('1000');
|
|
36
|
-
const result = await service.checkQuota('user-1', '
|
|
35
|
+
const result = await service.checkQuota('user-1', 'llm-cost');
|
|
37
36
|
expect(result).toEqual({ exceeded: true, used: 1000, limit: 1000 });
|
|
38
37
|
});
|
|
39
38
|
it('should return exceeded when over limit', async () => {
|
|
40
39
|
redisMock.get.mockResolvedValueOnce('1500').mockResolvedValueOnce('1000');
|
|
41
|
-
const result = await service.checkQuota('user-1', '
|
|
40
|
+
const result = await service.checkQuota('user-1', 'llm-cost');
|
|
42
41
|
expect(result).toEqual({ exceeded: true, used: 1500, limit: 1000 });
|
|
43
42
|
});
|
|
44
43
|
it('should block when no limit key exists (no quota assigned)', async () => {
|
|
45
44
|
redisMock.get.mockResolvedValueOnce('500').mockResolvedValueOnce(null);
|
|
46
|
-
const result = await service.checkQuota('user-1', '
|
|
45
|
+
const result = await service.checkQuota('user-1', 'llm-cost');
|
|
47
46
|
expect(result).toEqual({ exceeded: true, used: 500, limit: 0 });
|
|
48
47
|
});
|
|
49
48
|
it('should treat missing used as 0', async () => {
|
|
50
49
|
redisMock.get.mockResolvedValueOnce(null).mockResolvedValueOnce('1000');
|
|
51
|
-
const result = await service.checkQuota('user-1', '
|
|
50
|
+
const result = await service.checkQuota('user-1', 'llm-cost');
|
|
52
51
|
expect(result).toEqual({ exceeded: false, used: 0, limit: 1000 });
|
|
53
52
|
});
|
|
54
53
|
it('should treat explicit limit of -1 as unlimited', async () => {
|
|
55
54
|
redisMock.get.mockResolvedValueOnce('999999').mockResolvedValueOnce('-1');
|
|
56
|
-
const result = await service.checkQuota('user-1', '
|
|
55
|
+
const result = await service.checkQuota('user-1', 'llm-cost');
|
|
57
56
|
expect(result).toEqual({ exceeded: false, used: 999999, limit: -1 });
|
|
58
57
|
});
|
|
59
58
|
it('should block when no limit key and no usage exist', async () => {
|
|
60
59
|
redisMock.get.mockResolvedValueOnce(null).mockResolvedValueOnce(null);
|
|
61
|
-
const result = await service.checkQuota('user-1', '
|
|
60
|
+
const result = await service.checkQuota('user-1', 'llm-cost');
|
|
62
61
|
expect(result).toEqual({ exceeded: true, used: 0, limit: 0 });
|
|
63
62
|
});
|
|
64
63
|
it('should fail-open on Redis error', async () => {
|
|
65
64
|
redisMock.get.mockRejectedValue(new Error('Connection refused'));
|
|
66
|
-
const result = await service.checkQuota('user-1', '
|
|
65
|
+
const result = await service.checkQuota('user-1', 'llm-cost');
|
|
67
66
|
expect(result).toEqual({ exceeded: false, used: 0, limit: -1 });
|
|
68
67
|
});
|
|
69
68
|
});
|
|
70
69
|
describe('report', () => {
|
|
71
70
|
it('should increment the used key', async () => {
|
|
72
71
|
redisMock.incrby.mockResolvedValue(150);
|
|
73
|
-
await service.report('user-1', '
|
|
74
|
-
expect(redisMock.incrby).toHaveBeenCalledWith('user:user-1:quota:
|
|
72
|
+
await service.report('user-1', 'llm-cost', 150);
|
|
73
|
+
expect(redisMock.incrby).toHaveBeenCalledWith('user:user-1:quota:llm-cost:used', 150);
|
|
75
74
|
});
|
|
76
75
|
it('should not throw on Redis error', async () => {
|
|
77
76
|
redisMock.incrby.mockRejectedValue(new Error('Connection refused'));
|
|
78
|
-
await expect(service.report('user-1', '
|
|
77
|
+
await expect(service.report('user-1', 'llm-cost', 100)).resolves.toBeUndefined();
|
|
79
78
|
});
|
|
80
79
|
});
|
|
81
80
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-client.service.spec.js","sourceRoot":"","sources":["../../../src/services/__tests__/quota-client.service.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quota-client.service.spec.js","sourceRoot":"","sources":["../../../src/services/__tests__/quota-client.service.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAEhE,QAAQ,CAAC,oBAAoB,EAAE,GAAG,EAAE;IAClC,QAAQ,CAAC,sBAAsB,EAAE,GAAG,EAAE;QACpC,IAAI,OAA2B,CAAC;QAEhC,UAAU,CAAC,GAAG,EAAE;YACd,OAAO,GAAG,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;YACpE,MAAM,MAAM,GAAG,MAAM,O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'vitest';
|
|
2
|
+
import { QuotaCalculatorRegistry } from '../quota-calculator-registry.service.js';
|
|
3
|
+
import { QuotaInterceptor } from '../quota.interceptor.js';
|
|
5
4
|
class FakeTool {
|
|
6
5
|
name;
|
|
7
6
|
constructor(name) {
|
|
@@ -22,14 +21,14 @@ describe('QuotaInterceptor', () => {
|
|
|
22
21
|
let interceptor;
|
|
23
22
|
let quotaClientService;
|
|
24
23
|
let registry;
|
|
25
|
-
const noopNext =
|
|
24
|
+
const noopNext = vi.fn().mockResolvedValue({ data: {} });
|
|
26
25
|
beforeEach(() => {
|
|
27
26
|
quotaClientService = {
|
|
28
|
-
checkQuota:
|
|
29
|
-
report:
|
|
27
|
+
checkQuota: vi.fn().mockResolvedValue({ exceeded: false, used: 0, limit: -1 }),
|
|
28
|
+
report: vi.fn().mockResolvedValue(undefined),
|
|
30
29
|
};
|
|
31
|
-
registry = new
|
|
32
|
-
interceptor = new
|
|
30
|
+
registry = new QuotaCalculatorRegistry();
|
|
31
|
+
interceptor = new QuotaInterceptor(quotaClientService, registry);
|
|
33
32
|
noopNext.mockClear();
|
|
34
33
|
});
|
|
35
34
|
describe('before execution (quota checks)', () => {
|
|
@@ -47,31 +46,31 @@ describe('QuotaInterceptor', () => {
|
|
|
47
46
|
});
|
|
48
47
|
it('should check both processing time and tool-specific quota', async () => {
|
|
49
48
|
registry.register('AiGenerateText', {
|
|
50
|
-
quotaType: '
|
|
51
|
-
calculateQuotaUsage:
|
|
49
|
+
quotaType: 'llm-cost',
|
|
50
|
+
calculateQuotaUsage: vi.fn(),
|
|
52
51
|
});
|
|
53
52
|
const context = createContext('AiGenerateText');
|
|
54
53
|
await interceptor.intercept(context, noopNext);
|
|
55
54
|
expect(quotaClientService.checkQuota).toHaveBeenCalledWith('user-1', 'processing-time-ms');
|
|
56
|
-
expect(quotaClientService.checkQuota).toHaveBeenCalledWith('user-1', '
|
|
55
|
+
expect(quotaClientService.checkQuota).toHaveBeenCalledWith('user-1', 'llm-cost');
|
|
57
56
|
expect(quotaClientService.checkQuota).toHaveBeenCalledTimes(2);
|
|
58
57
|
});
|
|
59
58
|
it('should throw when tool-specific quota is exceeded', async () => {
|
|
60
59
|
registry.register('AiGenerateText', {
|
|
61
|
-
quotaType: '
|
|
62
|
-
calculateQuotaUsage:
|
|
60
|
+
quotaType: 'llm-cost',
|
|
61
|
+
calculateQuotaUsage: vi.fn(),
|
|
63
62
|
});
|
|
64
63
|
quotaClientService.checkQuota
|
|
65
64
|
.mockResolvedValueOnce({ exceeded: false, used: 0, limit: -1 })
|
|
66
65
|
.mockResolvedValueOnce({ exceeded: true, used: 1000, limit: 1000 });
|
|
67
66
|
const context = createContext('AiGenerateText');
|
|
68
|
-
await expect(interceptor.intercept(context, noopNext)).rejects.toThrow('Quota exceeded for "
|
|
67
|
+
await expect(interceptor.intercept(context, noopNext)).rejects.toThrow('Quota exceeded for "llm-cost": 1000/1000');
|
|
69
68
|
expect(noopNext).not.toHaveBeenCalled();
|
|
70
69
|
});
|
|
71
70
|
it('should not throw when all quotas are within limits', async () => {
|
|
72
71
|
registry.register('AiGenerateText', {
|
|
73
|
-
quotaType: '
|
|
74
|
-
calculateQuotaUsage:
|
|
72
|
+
quotaType: 'llm-cost',
|
|
73
|
+
calculateQuotaUsage: vi.fn(),
|
|
75
74
|
});
|
|
76
75
|
quotaClientService.checkQuota.mockResolvedValue({ exceeded: false, used: 500, limit: 1000 });
|
|
77
76
|
const context = createContext('AiGenerateText');
|
|
@@ -91,19 +90,19 @@ describe('QuotaInterceptor', () => {
|
|
|
91
90
|
});
|
|
92
91
|
it('should report tool-specific usage when calculator returns usage', async () => {
|
|
93
92
|
registry.register('AiGenerateText', {
|
|
94
|
-
quotaType: '
|
|
95
|
-
calculateQuotaUsage:
|
|
93
|
+
quotaType: 'llm-cost',
|
|
94
|
+
calculateQuotaUsage: vi.fn().mockReturnValue({ quotaType: 'llm-cost', actualAmount: 500 }),
|
|
96
95
|
});
|
|
97
96
|
const context = createContext('AiGenerateText', { metadata: { durationMs: 1000 } });
|
|
98
97
|
await interceptor.intercept(context, noopNext);
|
|
99
98
|
expect(quotaClientService.report).toHaveBeenCalledWith('user-1', 'processing-time-ms', 1000);
|
|
100
|
-
expect(quotaClientService.report).toHaveBeenCalledWith('user-1', '
|
|
99
|
+
expect(quotaClientService.report).toHaveBeenCalledWith('user-1', 'llm-cost', 500);
|
|
101
100
|
expect(quotaClientService.report).toHaveBeenCalledTimes(2);
|
|
102
101
|
});
|
|
103
102
|
it('should not report tool-specific usage when calculator returns null', async () => {
|
|
104
103
|
registry.register('AiGenerateText', {
|
|
105
|
-
quotaType: '
|
|
106
|
-
calculateQuotaUsage:
|
|
104
|
+
quotaType: 'llm-cost',
|
|
105
|
+
calculateQuotaUsage: vi.fn().mockReturnValue(null),
|
|
107
106
|
});
|
|
108
107
|
const context = createContext('AiGenerateText', { metadata: { durationMs: 100 } });
|
|
109
108
|
await interceptor.intercept(context, noopNext);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota.interceptor.spec.js","sourceRoot":"","sources":["../../../src/services/__tests__/quota.interceptor.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quota.interceptor.spec.js","sourceRoot":"","sources":["../../../src/services/__tests__/quota.interceptor.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE3E,OAAO,EAAE,uBAAuB,EAAE,MAAM,yCAAyC,CAAC;AAElF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,QAAQ;IACgB;IAA5B,YAA4B,IAAY;QAAZ,SAAI,GAAJ,IAAI,CAAQ;QACtC,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,WAAW,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACnE,CAAC;CACF;AAED,SAAS,a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AC,oBAAoB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,IAAI,CAAC,CAAC;YAC7F,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,QAAQ,EAAE,UAAU,EAAE,GAAG,CAAC,CAAC;YAClF,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;QAC7D,CAAC,CAAC,CAAC;QAEH,EAAE,CAAC,oEAAoE,EAAE,KAAK,IAAI,EAAE;YAClF,QAAQ,CAAC,QAAQ,CAAC,gBAAgB,EAAE;gBAClC,SAAS,EAAE,UAAU;gBACrB,mBAAmB,EAAE,EAAE,CAAC,EAAE,EAAE,CAAC,eAAe,CAAC,IAAI,CAAC;aACnD,CAAC,CAAC;YACH,MAAM,OAAO,GAAG,aAAa,CAAC,gBAAgB,EAAE,EAAE,QAAQ,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;YAEnF,MAAM,WAAW,CAAC,SAAS,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;YAE/C,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,qBAAqB,CAAC,CAAC,CAAC,CAAC;YAC3D,MAAM,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,oBAAoB,CAAC,QAAQ,EAAE,oBAAoB,EAAE,GAAG,CAAC,CAAC;QAC9F,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/dist/services/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './quota-calculator-registry.service';
|
|
2
|
-
export * from './quota-client.service';
|
|
3
|
-
export * from './quota.interceptor';
|
|
1
|
+
export * from './quota-calculator-registry.service.js';
|
|
2
|
+
export * from './quota-client.service.js';
|
|
3
|
+
export * from './quota.interceptor.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC"}
|
package/dist/services/index.js
CHANGED
|
@@ -1,20 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./quota-calculator-registry.service"), exports);
|
|
18
|
-
__exportStar(require("./quota-client.service"), exports);
|
|
19
|
-
__exportStar(require("./quota.interceptor"), exports);
|
|
1
|
+
export * from './quota-calculator-registry.service.js';
|
|
2
|
+
export * from './quota-client.service.js';
|
|
3
|
+
export * from './quota.interceptor.js';
|
|
20
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,wCAAwC,CAAC;AACvD,cAAc,2BAA2B,CAAC;AAC1C,cAAc,wBAAwB,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ToolQuotaCalculator } from '../interfaces/tool-quota-calculator.interface';
|
|
1
|
+
import { ToolQuotaCalculator } from '../interfaces/tool-quota-calculator.interface.js';
|
|
2
2
|
export declare class QuotaCalculatorRegistry {
|
|
3
3
|
private readonly logger;
|
|
4
4
|
private readonly calculators;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-calculator-registry.service.d.ts","sourceRoot":"","sources":["../../src/services/quota-calculator-registry.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM
|
|
1
|
+
{"version":3,"file":"quota-calculator-registry.service.d.ts","sourceRoot":"","sources":["../../src/services/quota-calculator-registry.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kDAAkD,CAAC;AAEvF,qBACa,uBAAuB;IAClC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAA4C;IACnE,OAAO,CAAC,QAAQ,CAAC,WAAW,CAA0C;IAEtE,QAAQ,CAAC,aAAa,EAAE,MAAM,EAAE,UAAU,EAAE,mBAAmB,GAAG,IAAI;IAQtE,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,mBAAmB,GAAG,SAAS;IAI3D,GAAG,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;CAGpC"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -6,11 +5,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
6
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
6
|
};
|
|
8
7
|
var QuotaCalculatorRegistry_1;
|
|
9
|
-
|
|
10
|
-
exports.QuotaCalculatorRegistry = void 0;
|
|
11
|
-
const common_1 = require("@nestjs/common");
|
|
8
|
+
import { Injectable, Logger } from '@nestjs/common';
|
|
12
9
|
let QuotaCalculatorRegistry = QuotaCalculatorRegistry_1 = class QuotaCalculatorRegistry {
|
|
13
|
-
logger = new
|
|
10
|
+
logger = new Logger(QuotaCalculatorRegistry_1.name);
|
|
14
11
|
calculators = new Map();
|
|
15
12
|
register(toolClassName, calculator) {
|
|
16
13
|
if (this.calculators.has(toolClassName)) {
|
|
@@ -26,8 +23,8 @@ let QuotaCalculatorRegistry = QuotaCalculatorRegistry_1 = class QuotaCalculatorR
|
|
|
26
23
|
return this.calculators.has(toolClassName);
|
|
27
24
|
}
|
|
28
25
|
};
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
(0, common_1.Injectable)()
|
|
26
|
+
QuotaCalculatorRegistry = QuotaCalculatorRegistry_1 = __decorate([
|
|
27
|
+
Injectable()
|
|
32
28
|
], QuotaCalculatorRegistry);
|
|
29
|
+
export { QuotaCalculatorRegistry };
|
|
33
30
|
//# sourceMappingURL=quota-calculator-registry.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-calculator-registry.service.js","sourceRoot":"","sources":["../../src/services/quota-calculator-registry.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quota-calculator-registry.service.js","sourceRoot":"","sources":["../../src/services/quota-calculator-registry.service.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAI7C,IAAM,uBAAuB,+BAA7B,MAAM,uBAAuB;IACjB,MAAM,GAAG,IAAI,MAAM,CAAC,yBAAuB,CAAC,IAAI,CAAC,CAAC;IAClD,WAAW,GAAG,IAAI,GAAG,EAA+B,CAAC;IAEtE,QAAQ,CAAC,aAAqB,EAAE,UAA+B;QAC7D,IAAI,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,EAAE,CAAC;YACxC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,yBAAyB,aAAa,kCAAkC,CAAC,CAAC;QAC7F,CAAC;QACD,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,aAAa,EAAE,UAAU,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,yCAAyC,aAAa,EAAE,CAAC,CAAC;IAC5E,CAAC;IAED,GAAG,CAAC,aAAqB;QACvB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC;IAED,GAAG,CAAC,aAAqB;QACvB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAC7C,CAAC;CACF,CAAA;AAnBY,uBAAuB;IADnC,UAAU,EAAE;GACA,uBAAuB,CAmBnC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import Redis from 'ioredis';
|
|
2
|
-
import { QuotaCheckResult, QuotaClientServiceInterface } from '../interfaces';
|
|
1
|
+
import { Redis } from 'ioredis';
|
|
2
|
+
import { QuotaCheckResult, QuotaClientServiceInterface } from '../interfaces/index.js';
|
|
3
3
|
export declare const QUOTA_REDIS = "QUOTA_REDIS";
|
|
4
4
|
export declare class QuotaClientService implements QuotaClientServiceInterface {
|
|
5
5
|
private readonly redis;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-client.service.d.ts","sourceRoot":"","sources":["../../src/services/quota-client.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"quota-client.service.d.ts","sourceRoot":"","sources":["../../src/services/quota-client.service.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAEvF,eAAO,MAAM,WAAW,gBAAgB,CAAC;AAEzC,qBACa,kBAAmB,YAAW,2BAA2B;IAMlE,OAAO,CAAC,QAAQ,CAAC,KAAK;IALxB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuC;gBAK3C,KAAK,EAAE,KAAK,GAAG,IAAI;IAGhC,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC;IA2CxE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAgB9E,OAAO,CAAC,GAAG;CAGZ"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -12,13 +11,11 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
12
|
};
|
|
14
13
|
var QuotaClientService_1;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const common_1 = require("@nestjs/common");
|
|
18
|
-
exports.QUOTA_REDIS = 'QUOTA_REDIS';
|
|
14
|
+
import { Inject, Injectable, Logger, Optional } from '@nestjs/common';
|
|
15
|
+
export const QUOTA_REDIS = 'QUOTA_REDIS';
|
|
19
16
|
let QuotaClientService = QuotaClientService_1 = class QuotaClientService {
|
|
20
17
|
redis;
|
|
21
|
-
logger = new
|
|
18
|
+
logger = new Logger(QuotaClientService_1.name);
|
|
22
19
|
constructor(redis) {
|
|
23
20
|
this.redis = redis;
|
|
24
21
|
}
|
|
@@ -66,11 +63,11 @@ let QuotaClientService = QuotaClientService_1 = class QuotaClientService {
|
|
|
66
63
|
return `user:${userId}:quota:${quotaType}:${suffix}`;
|
|
67
64
|
}
|
|
68
65
|
};
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
(0,
|
|
72
|
-
__param(0, (
|
|
73
|
-
__param(0, (0, common_1.Inject)(exports.QUOTA_REDIS)),
|
|
66
|
+
QuotaClientService = QuotaClientService_1 = __decorate([
|
|
67
|
+
Injectable(),
|
|
68
|
+
__param(0, Optional()),
|
|
69
|
+
__param(0, Inject(QUOTA_REDIS)),
|
|
74
70
|
__metadata("design:paramtypes", [Object])
|
|
75
71
|
], QuotaClientService);
|
|
72
|
+
export { QuotaClientService };
|
|
76
73
|
//# sourceMappingURL=quota-client.service.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota-client.service.js","sourceRoot":"","sources":["../../src/services/quota-client.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"quota-client.service.js","sourceRoot":"","sources":["../../src/services/quota-client.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAItE,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AAGlC,IAAM,kBAAkB,0BAAxB,MAAM,kBAAkB;IAMV;IALF,MAAM,GAAG,IAAI,MAAM,CAAC,oBAAkB,CAAC,IAAI,CAAC,CAAC;IAE9D,YAGmB,KAAmB;QAAnB,UAAK,GAAL,KAAK,CAAc;IACnC,CAAC;IAEJ,KAAK,CAAC,UAAU,CAAC,MAAc,EAAE,SAAiB;QAChD,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;YAChB,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,E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AAC,WAAW,CAAC,CAAA;;GALX,kBAAkB,CAuE9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ToolExecutionContext, ToolInterceptor, ToolResult } from '@loopstack/common';
|
|
2
|
-
import { QuotaCalculatorRegistry } from './quota-calculator-registry.service';
|
|
3
|
-
import { QuotaClientService } from './quota-client.service';
|
|
2
|
+
import { QuotaCalculatorRegistry } from './quota-calculator-registry.service.js';
|
|
3
|
+
import { QuotaClientService } from './quota-client.service.js';
|
|
4
4
|
export declare class QuotaInterceptor implements ToolInterceptor {
|
|
5
5
|
private readonly quotaClientService;
|
|
6
6
|
private readonly calculatorRegistry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"quota.interceptor.d.ts","sourceRoot":"","sources":["../../src/services/quota.interceptor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,UAAU,EAAsB,MAAM,mBAAmB,CAAC;AAE1G,OAAO,EAAE,uBAAuB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"quota.interceptor.d.ts","sourceRoot":"","sources":["../../src/services/quota.interceptor.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,UAAU,EAAsB,MAAM,mBAAmB,CAAC;AAE1G,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AACjF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,qBACa,gBAAiB,YAAW,eAAe;IAKpD,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IALrC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAqC;IAC5D,OAAO,CAAC,QAAQ,CAAC,wBAAwB,CAAuC;gBAG7D,kBAAkB,EAAE,kBAAkB,EACtC,kBAAkB,EAAE,uBAAuB;IAGxD,SAAS,CAAC,OAAO,EAAE,oBAAoB,EAAE,IAAI,EAAE,MAAM,OAAO,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,UAAU,CAAC;CAyCrG"}
|