@toa.io/extensions.exposition 1.0.0-alpha.152 → 1.0.0-alpha.154
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/components/identity.bans/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.basic/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.federation/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.keys/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.otp/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.passkeys/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.roles/operations/tsconfig.tsbuildinfo +1 -1
- package/components/identity.tokens/operations/tsconfig.tsbuildinfo +1 -1
- package/documentation/io.md +42 -2
- package/documentation/notes/desync.jpg +0 -0
- package/documentation/notes/peers.md +59 -0
- package/documentation/notes/throttling.md +82 -0
- package/documentation/query.md +22 -0
- package/features/io.throttle.feature +40 -0
- package/features/query.feature +46 -0
- package/features/steps/components/pots/manifest.toa.yaml +3 -0
- package/package.json +4 -4
- package/schemas/io/throttle.cos.yaml +36 -0
- package/schemas/query.cos.yaml +1 -0
- package/schemas/querystring.cos.yaml +1 -0
- package/source/Directive.test.ts +4 -2
- package/source/Directive.ts +16 -1
- package/source/Gateway.ts +2 -0
- package/source/HTTP/Server.ts +47 -21
- package/source/HTTP/exceptions.ts +21 -15
- package/source/HTTP/messages.ts +1 -0
- package/source/Query.ts +5 -0
- package/source/RTD/Directives.ts +4 -0
- package/source/RTD/Tree.ts +4 -0
- package/source/RTD/syntax/types.ts +1 -0
- package/source/directives/io/Directive.ts +5 -2
- package/source/directives/io/IO.ts +17 -5
- package/source/directives/io/Input.ts +1 -1
- package/source/directives/io/Output.ts +1 -1
- package/source/directives/io/Throttle.ts +32 -0
- package/source/directives/io/lib/throttle/Configuration.test.ts +40 -0
- package/source/directives/io/lib/throttle/Configuration.ts +58 -0
- package/source/directives/io/lib/throttle/Interval.ts +31 -0
- package/source/directives/io/lib/throttle/Keys.ts +40 -0
- package/source/directives/io/lib/throttle/Quota.ts +22 -0
- package/source/directives/io/lib/throttle/Quotas.test.ts +136 -0
- package/source/directives/io/lib/throttle/Quotas.ts +83 -0
- package/source/directives/io/lib/throttle/components/Component.ts +5 -0
- package/source/directives/io/lib/throttle/components/IP.ts +40 -0
- package/source/directives/io/lib/throttle/components/Path.ts +8 -0
- package/source/directives/io/lib/throttle/components/index.ts +13 -0
- package/source/directives/io/lib/throttle/conditions/Condition.ts +5 -0
- package/source/directives/io/lib/throttle/conditions/Status.ts +17 -0
- package/source/directives/io/lib/throttle/conditions/index.ts +11 -0
- package/source/directives/io/lib/throttle/index.ts +2 -0
- package/source/directives/io/schemas.test.ts +9 -0
- package/source/directives/io/schemas.ts +3 -0
- package/transpiled/Directive.d.ts +3 -0
- package/transpiled/Directive.js +12 -1
- package/transpiled/Directive.js.map +1 -1
- package/transpiled/Gateway.js +1 -0
- package/transpiled/Gateway.js.map +1 -1
- package/transpiled/HTTP/Server.js +41 -16
- package/transpiled/HTTP/Server.js.map +1 -1
- package/transpiled/HTTP/exceptions.d.ts +11 -8
- package/transpiled/HTTP/exceptions.js +23 -17
- package/transpiled/HTTP/exceptions.js.map +1 -1
- package/transpiled/HTTP/messages.d.ts +1 -0
- package/transpiled/Query.d.ts +1 -0
- package/transpiled/Query.js +4 -0
- package/transpiled/Query.js.map +1 -1
- package/transpiled/RTD/Directives.d.ts +3 -0
- package/transpiled/RTD/Tree.d.ts +1 -0
- package/transpiled/RTD/Tree.js +3 -0
- package/transpiled/RTD/Tree.js.map +1 -1
- package/transpiled/RTD/syntax/types.d.ts +1 -0
- package/transpiled/RTD/syntax/types.js.map +1 -1
- package/transpiled/directives/io/Directive.d.ts +5 -2
- package/transpiled/directives/io/IO.d.ts +4 -2
- package/transpiled/directives/io/IO.js +13 -3
- package/transpiled/directives/io/IO.js.map +1 -1
- package/transpiled/directives/io/Input.d.ts +1 -1
- package/transpiled/directives/io/Input.js +1 -1
- package/transpiled/directives/io/Input.js.map +1 -1
- package/transpiled/directives/io/Output.d.ts +1 -1
- package/transpiled/directives/io/Output.js +1 -1
- package/transpiled/directives/io/Output.js.map +1 -1
- package/transpiled/directives/io/Throttle.d.ts +11 -0
- package/transpiled/directives/io/Throttle.js +51 -0
- package/transpiled/directives/io/Throttle.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/Configuration.d.ts +23 -0
- package/transpiled/directives/io/lib/throttle/Configuration.js +27 -0
- package/transpiled/directives/io/lib/throttle/Configuration.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/Interval.d.ts +9 -0
- package/transpiled/directives/io/lib/throttle/Interval.js +31 -0
- package/transpiled/directives/io/lib/throttle/Interval.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/Keys.d.ts +12 -0
- package/transpiled/directives/io/lib/throttle/Keys.js +34 -0
- package/transpiled/directives/io/lib/throttle/Keys.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/Quota.d.ts +8 -0
- package/transpiled/directives/io/lib/throttle/Quota.js +22 -0
- package/transpiled/directives/io/lib/throttle/Quota.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/Quotas.d.ts +26 -0
- package/transpiled/directives/io/lib/throttle/Quotas.js +61 -0
- package/transpiled/directives/io/lib/throttle/Quotas.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/components/Component.d.ts +4 -0
- package/transpiled/directives/io/lib/throttle/components/Component.js +3 -0
- package/transpiled/directives/io/lib/throttle/components/Component.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/components/IP.d.ts +6 -0
- package/transpiled/directives/io/lib/throttle/components/IP.js +33 -0
- package/transpiled/directives/io/lib/throttle/components/IP.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/components/Path.d.ts +5 -0
- package/transpiled/directives/io/lib/throttle/components/Path.js +10 -0
- package/transpiled/directives/io/lib/throttle/components/Path.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/components/index.d.ts +5 -0
- package/transpiled/directives/io/lib/throttle/components/index.js +10 -0
- package/transpiled/directives/io/lib/throttle/components/index.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/conditions/Condition.d.ts +4 -0
- package/transpiled/directives/io/lib/throttle/conditions/Condition.js +3 -0
- package/transpiled/directives/io/lib/throttle/conditions/Condition.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/conditions/Status.d.ts +7 -0
- package/transpiled/directives/io/lib/throttle/conditions/Status.js +19 -0
- package/transpiled/directives/io/lib/throttle/conditions/Status.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/conditions/index.d.ts +5 -0
- package/transpiled/directives/io/lib/throttle/conditions/index.js +8 -0
- package/transpiled/directives/io/lib/throttle/conditions/index.js.map +1 -0
- package/transpiled/directives/io/lib/throttle/index.d.ts +2 -0
- package/transpiled/directives/io/lib/throttle/index.js +8 -0
- package/transpiled/directives/io/lib/throttle/index.js.map +1 -0
- package/transpiled/directives/io/schemas.d.ts +2 -0
- package/transpiled/directives/io/schemas.js +2 -1
- package/transpiled/directives/io/schemas.js.map +1 -1
- package/transpiled/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Keys } from './Keys';
|
|
2
|
+
import { Interval } from './Interval';
|
|
3
|
+
import type { Configuration } from './Configuration';
|
|
4
|
+
import type { Input as Context, Output } from '../../../../io';
|
|
5
|
+
export declare class Quotas {
|
|
6
|
+
private readonly requests;
|
|
7
|
+
private readonly cooldown;
|
|
8
|
+
private readonly interval;
|
|
9
|
+
private readonly keys;
|
|
10
|
+
private readonly quotas;
|
|
11
|
+
private readonly blocked;
|
|
12
|
+
constructor(options: Options);
|
|
13
|
+
static create(configuration: Configuration): Quotas;
|
|
14
|
+
ok(context: Context): boolean;
|
|
15
|
+
use(input: Context, output: Output): void;
|
|
16
|
+
dispose(): void;
|
|
17
|
+
private readonly reset;
|
|
18
|
+
private block;
|
|
19
|
+
}
|
|
20
|
+
interface Options {
|
|
21
|
+
keys: Keys;
|
|
22
|
+
requests: number;
|
|
23
|
+
cooldown: number;
|
|
24
|
+
interval: Interval;
|
|
25
|
+
}
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Quotas = void 0;
|
|
4
|
+
const openspan_1 = require("openspan");
|
|
5
|
+
const Keys_1 = require("./Keys");
|
|
6
|
+
const Quota_1 = require("./Quota");
|
|
7
|
+
const Interval_1 = require("./Interval");
|
|
8
|
+
class Quotas {
|
|
9
|
+
requests;
|
|
10
|
+
cooldown;
|
|
11
|
+
interval;
|
|
12
|
+
keys;
|
|
13
|
+
quotas = {};
|
|
14
|
+
blocked = {};
|
|
15
|
+
constructor(options) {
|
|
16
|
+
this.requests = options.requests;
|
|
17
|
+
this.cooldown = options.cooldown;
|
|
18
|
+
this.interval = options.interval;
|
|
19
|
+
this.keys = options.keys;
|
|
20
|
+
this.interval.on('tick', this.reset);
|
|
21
|
+
}
|
|
22
|
+
static create(configuration) {
|
|
23
|
+
const requests = configuration.requests;
|
|
24
|
+
const cooldown = configuration.cooldown;
|
|
25
|
+
const keys = Keys_1.Keys.create(configuration.key, configuration.condition);
|
|
26
|
+
const interval = new Interval_1.Interval(configuration.interval);
|
|
27
|
+
return new this({ requests, cooldown, keys, interval });
|
|
28
|
+
}
|
|
29
|
+
ok(context) {
|
|
30
|
+
const key = this.keys.get(context);
|
|
31
|
+
return this.blocked[key] !== true;
|
|
32
|
+
}
|
|
33
|
+
use(input, output) {
|
|
34
|
+
const key = this.keys.match(input, output);
|
|
35
|
+
if (key === null)
|
|
36
|
+
return;
|
|
37
|
+
this.quotas[key] ??= new Quota_1.Quota(this.requests);
|
|
38
|
+
const ok = this.quotas[key].use();
|
|
39
|
+
if (!ok)
|
|
40
|
+
this.block(key);
|
|
41
|
+
}
|
|
42
|
+
dispose() {
|
|
43
|
+
this.interval.dispose();
|
|
44
|
+
}
|
|
45
|
+
reset = () => {
|
|
46
|
+
for (const key in this.quotas) {
|
|
47
|
+
const quota = this.quotas[key];
|
|
48
|
+
if (quota.idle)
|
|
49
|
+
delete this.quotas[key];
|
|
50
|
+
else
|
|
51
|
+
quota.reset();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
block(key) {
|
|
55
|
+
this.blocked[key] = true;
|
|
56
|
+
setTimeout(() => delete this.blocked[key], this.cooldown);
|
|
57
|
+
openspan_1.console.info('Quota exceeded, key blocked', { key, cooldown: this.cooldown });
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.Quotas = Quotas;
|
|
61
|
+
//# sourceMappingURL=Quotas.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Quotas.js","sourceRoot":"","sources":["../../../../../source/directives/io/lib/throttle/Quotas.ts"],"names":[],"mappings":";;;AAAA,uCAAkC;AAClC,iCAA6B;AAC7B,mCAA+B;AAC/B,yCAAqC;AAIrC,MAAa,MAAM;IACA,QAAQ,CAAQ;IAChB,QAAQ,CAAQ;IAChB,QAAQ,CAAU;IAClB,IAAI,CAAM;IACV,MAAM,GAAsC,EAAE,CAAA;IAC9C,OAAO,GAAwC,EAAE,CAAA;IAElE,YAAoB,OAAgB;QAClC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QAChC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QAChC,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAA;QAChC,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAA;QAExB,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,CAAA;IACtC,CAAC;IAEM,MAAM,CAAC,MAAM,CAAE,aAA4B;QAChD,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAA;QACvC,MAAM,QAAQ,GAAG,aAAa,CAAC,QAAQ,CAAA;QACvC,MAAM,IAAI,GAAG,WAAI,CAAC,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,aAAa,CAAC,SAAS,CAAC,CAAA;QACpE,MAAM,QAAQ,GAAG,IAAI,mBAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAA;QAErD,OAAO,IAAI,IAAI,CAAC,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAA;IACzD,CAAC;IAEM,EAAE,CAAE,OAAgB;QACzB,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAA;QAElC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,CAAA;IACnC,CAAC;IAEM,GAAG,CAAE,KAAc,EAAE,MAAc;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;QAE1C,IAAI,GAAG,KAAK,IAAI;YACd,OAAM;QAER,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,IAAI,aAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAE7C,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAE,CAAC,GAAG,EAAE,CAAA;QAElC,IAAI,CAAC,EAAE;YACL,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;IACnB,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE,CAAA;IACzB,CAAC;IAEgB,KAAK,GAAG,GAAS,EAAE;QAClC,KAAK,MAAM,GAAG,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAC9B,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAE,CAAA;YAE/B,IAAI,KAAK,CAAC,IAAI;gBACZ,OAAO,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;;gBAEvB,KAAK,CAAC,KAAK,EAAE,CAAA;QACjB,CAAC;IACH,CAAC,CAAA;IAEO,KAAK,CAAE,GAAW;QACxB,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAA;QAExB,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAA;QAEzD,kBAAO,CAAC,IAAI,CAAC,6BAA6B,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC/E,CAAC;CACF;AApED,wBAoEC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Component.js","sourceRoot":"","sources":["../../../../../../source/directives/io/lib/throttle/components/Component.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IP = void 0;
|
|
4
|
+
class IP {
|
|
5
|
+
get(context) {
|
|
6
|
+
return this.xff(context) ?? context.request.socket.remoteAddress ?? '';
|
|
7
|
+
}
|
|
8
|
+
xff(context) {
|
|
9
|
+
const xff = context.request.headers['x-forwarded-for'];
|
|
10
|
+
if (xff === undefined || typeof xff === 'string')
|
|
11
|
+
return xff;
|
|
12
|
+
let ip;
|
|
13
|
+
for (const value of xff) {
|
|
14
|
+
ip = value.trim();
|
|
15
|
+
if (!local(ip))
|
|
16
|
+
return ip;
|
|
17
|
+
}
|
|
18
|
+
return ip; // last otherwise
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.IP = IP;
|
|
22
|
+
function local(ip) {
|
|
23
|
+
return (ip === 'unknown' ||
|
|
24
|
+
ip === '' ||
|
|
25
|
+
ip === '127.0.0.1' ||
|
|
26
|
+
ip === '::1' ||
|
|
27
|
+
ip.startsWith('10.') ||
|
|
28
|
+
ip.startsWith('192.168.') ||
|
|
29
|
+
ip.match(/^172\.(1[6-9]|2[0-9]|3[0-1])\./) !== null ||
|
|
30
|
+
ip.startsWith('fd') ||
|
|
31
|
+
ip.startsWith('fe80:'));
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=IP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IP.js","sourceRoot":"","sources":["../../../../../../source/directives/io/lib/throttle/components/IP.ts"],"names":[],"mappings":";;;AAGA,MAAa,EAAE;IACN,GAAG,CAAE,OAAgB;QAC1B,OAAO,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,IAAI,EAAE,CAAA;IACxE,CAAC;IAEO,GAAG,CAAE,OAAgB;QAC3B,MAAM,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,iBAAiB,CAAC,CAAA;QAEtD,IAAI,GAAG,KAAK,SAAS,IAAI,OAAO,GAAG,KAAK,QAAQ;YAC9C,OAAO,GAAG,CAAA;QAEZ,IAAI,EAAE,CAAA;QAEN,KAAK,MAAM,KAAK,IAAI,GAAG,EAAE,CAAC;YACxB,EAAE,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;YAEjB,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;gBACZ,OAAO,EAAE,CAAA;QACb,CAAC;QAED,OAAO,EAAE,CAAA,CAAC,iBAAiB;IAC7B,CAAC;CACF;AAtBD,gBAsBC;AAED,SAAS,KAAK,CAAE,EAAU;IACxB,OAAO,CACL,EAAE,KAAK,SAAS;QAChB,EAAE,KAAK,EAAE;QACT,EAAE,KAAK,WAAW;QAClB,EAAE,KAAK,KAAK;QACZ,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC;QACpB,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;QACzB,EAAE,CAAC,KAAK,CAAC,gCAAgC,CAAC,KAAK,IAAI;QACnD,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC;QACnB,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CACvB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Path.js","sourceRoot":"","sources":["../../../../../../source/directives/io/lib/throttle/components/Path.ts"],"names":[],"mappings":";;;AAGA,MAAa,IAAI;IACR,GAAG,CAAE,OAAgB;QAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAA;IAC7B,CAAC;CACF;AAJD,oBAIC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { KeyComponentMethod } from '../Configuration';
|
|
2
|
+
import type { Component } from './Component';
|
|
3
|
+
type Constructor<T> = new (options: unknown) => T;
|
|
4
|
+
export declare const Components: Record<KeyComponentMethod, Constructor<Component>>;
|
|
5
|
+
export type { Component };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Components = void 0;
|
|
4
|
+
const Path_1 = require("./Path");
|
|
5
|
+
const IP_1 = require("./IP");
|
|
6
|
+
exports.Components = {
|
|
7
|
+
ip: IP_1.IP,
|
|
8
|
+
path: Path_1.Path
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../source/directives/io/lib/throttle/components/index.ts"],"names":[],"mappings":";;;AAAA,iCAA6B;AAC7B,6BAAyB;AAMZ,QAAA,UAAU,GAAuD;IAC5E,EAAE,EAAE,OAAE;IACN,IAAI,EAAE,WAAI;CACX,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Condition.js","sourceRoot":"","sources":["../../../../../../source/directives/io/lib/throttle/conditions/Condition.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Status = void 0;
|
|
7
|
+
const node_assert_1 = __importDefault(require("node:assert"));
|
|
8
|
+
class Status {
|
|
9
|
+
status;
|
|
10
|
+
constructor(status) {
|
|
11
|
+
node_assert_1.default.ok(typeof status === 'number', 'Status must be a number');
|
|
12
|
+
this.status = status;
|
|
13
|
+
}
|
|
14
|
+
match(input, output) {
|
|
15
|
+
return output?.status === this.status;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
exports.Status = Status;
|
|
19
|
+
//# sourceMappingURL=Status.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Status.js","sourceRoot":"","sources":["../../../../../../source/directives/io/lib/throttle/conditions/Status.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAgC;AAIhC,MAAa,MAAM;IACA,MAAM,CAAQ;IAE/B,YAAoB,MAAe;QACjC,qBAAM,CAAC,EAAE,CAAC,OAAO,MAAM,KAAK,QAAQ,EAAE,yBAAyB,CAAC,CAAA;QAEhE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAEM,KAAK,CAAE,KAAY,EAAE,MAAc;QACxC,OAAO,MAAM,EAAE,MAAM,KAAK,IAAI,CAAC,MAAM,CAAA;IACvC,CAAC;CACF;AAZD,wBAYC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { KeyConditionMethod } from '../Configuration';
|
|
2
|
+
import type { Condition } from './Condition';
|
|
3
|
+
type Constructor<T> = new (options: unknown) => T;
|
|
4
|
+
export declare const Conditions: Record<KeyConditionMethod, Constructor<Condition>>;
|
|
5
|
+
export type { Condition };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../../source/directives/io/lib/throttle/conditions/index.ts"],"names":[],"mappings":";;;AAAA,qCAAiC;AAMpB,QAAA,UAAU,GAAuD;IAC5E,MAAM,EAAE,eAAM;CACf,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parse = exports.Quotas = void 0;
|
|
4
|
+
var Quotas_1 = require("./Quotas");
|
|
5
|
+
Object.defineProperty(exports, "Quotas", { enumerable: true, get: function () { return Quotas_1.Quotas; } });
|
|
6
|
+
var Configuration_1 = require("./Configuration");
|
|
7
|
+
Object.defineProperty(exports, "parse", { enumerable: true, get: function () { return Configuration_1.parse; } });
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../source/directives/io/lib/throttle/index.ts"],"names":[],"mappings":";;;AAAA,mCAAiC;AAAxB,gGAAA,MAAM,OAAA;AACf,iDAA6E;AAApE,sGAAA,KAAK,OAAA"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type Schema } from '@toa.io/schemas';
|
|
2
2
|
import type { Permissions as InputPermissions } from './Input';
|
|
3
3
|
import type { Permissions as OutputPermissions } from './Output';
|
|
4
|
+
import type { Declaration as ThrottleDeclaration } from './lib/throttle';
|
|
4
5
|
import type { Message } from './Message';
|
|
5
6
|
export declare const message: Schema<Message | Message[]>;
|
|
6
7
|
export declare const input: Schema<InputPermissions>;
|
|
7
8
|
export declare const output: Schema<OutputPermissions>;
|
|
9
|
+
export declare const throttle: Schema<ThrottleDeclaration>;
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.output = exports.input = exports.message = void 0;
|
|
6
|
+
exports.throttle = exports.output = exports.input = exports.message = void 0;
|
|
7
7
|
const node_path_1 = require("node:path");
|
|
8
8
|
const schemas_1 = __importDefault(require("@toa.io/schemas"));
|
|
9
9
|
const path = (0, node_path_1.resolve)(__dirname, '../../../schemas/io');
|
|
@@ -11,4 +11,5 @@ const namespace = schemas_1.default.namespace(path);
|
|
|
11
11
|
exports.message = namespace.schema('message');
|
|
12
12
|
exports.input = namespace.schema('input');
|
|
13
13
|
exports.output = namespace.schema('output');
|
|
14
|
+
exports.throttle = namespace.schema('throttle');
|
|
14
15
|
//# sourceMappingURL=schemas.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../source/directives/io/schemas.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAmC;AACnC,8DAAsD;
|
|
1
|
+
{"version":3,"file":"schemas.js","sourceRoot":"","sources":["../../../source/directives/io/schemas.ts"],"names":[],"mappings":";;;;;;AAAA,yCAAmC;AACnC,8DAAsD;AAOtD,MAAM,IAAI,GAAG,IAAA,mBAAO,EAAC,SAAS,EAAE,qBAAqB,CAAC,CAAA;AACtD,MAAM,SAAS,GAAG,iBAAO,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;AAE5B,QAAA,OAAO,GAAgC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAA;AAClE,QAAA,KAAK,GAA6B,SAAS,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;AAC3D,QAAA,MAAM,GAA8B,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAA;AAC9D,QAAA,QAAQ,GAAgC,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAA"}
|