@usageflow/core 0.2.4 → 0.2.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/README.md +207 -26
- package/dist/base.d.ts +9 -8
- package/dist/base.js +111 -49
- package/dist/base.js.map +1 -1
- package/dist/socket.js +2 -2
- package/dist/socket.js.map +1 -1
- package/dist/types.d.ts +4 -0
- package/jest.config.js +14 -0
- package/package.json +6 -7
- package/src/base.ts +177 -67
- package/src/socket.ts +2 -2
- package/src/types.ts +5 -0
- package/test/base.test.ts +290 -0
- package/test/socket.test.ts +72 -0
- package/test/src/base.d.ts +62 -0
- package/test/src/base.js +440 -0
- package/test/src/base.js.map +1 -0
- package/test/src/index.d.ts +3 -0
- package/test/src/index.js +20 -0
- package/test/src/index.js.map +1 -0
- package/test/src/socket.d.ts +26 -0
- package/test/src/socket.js +266 -0
- package/test/src/socket.js.map +1 -0
- package/test/src/types.d.ts +117 -0
- package/test/src/types.js +11 -0
- package/test/src/types.js.map +1 -0
- package/test/tsconfig.test.tsbuildinfo +1 -0
- package/test/types.test.ts +56 -0
- package/tsconfig.json +2 -1
- package/tsconfig.test.json +11 -0
- package/tsconfig.test.tsbuildinfo +1 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -0,0 +1,266 @@
|
|
|
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.UsageFlowSocketManger = void 0;
|
|
7
|
+
const ws_1 = __importDefault(require("ws"));
|
|
8
|
+
class UsageFlowSocketManger {
|
|
9
|
+
constructor(apiKey, poolSize) {
|
|
10
|
+
this.apiKey = apiKey;
|
|
11
|
+
this.connections = [];
|
|
12
|
+
this.wsUrl = "wss://api.usageflow.io/ws";
|
|
13
|
+
this.poolSize = 10; // Default pool size
|
|
14
|
+
this.currentIndex = 0; // For round-robin selection
|
|
15
|
+
this.connecting = false;
|
|
16
|
+
this.connectionPromises = [];
|
|
17
|
+
this.apiKey = apiKey;
|
|
18
|
+
if (poolSize && poolSize > 0) {
|
|
19
|
+
this.poolSize = poolSize;
|
|
20
|
+
}
|
|
21
|
+
// Connection is explicit - call connect() when ready
|
|
22
|
+
// Do NOT auto-connect in constructor to avoid immediate execution
|
|
23
|
+
}
|
|
24
|
+
async createConnection(index) {
|
|
25
|
+
if (!this.apiKey) {
|
|
26
|
+
throw new Error("API key not available");
|
|
27
|
+
}
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
try {
|
|
30
|
+
const headers = {
|
|
31
|
+
"x-usage-key": this.apiKey,
|
|
32
|
+
};
|
|
33
|
+
const ws = new ws_1.default(this.wsUrl, {
|
|
34
|
+
headers,
|
|
35
|
+
family: 4 // This forces IPv4
|
|
36
|
+
});
|
|
37
|
+
const connection = {
|
|
38
|
+
ws,
|
|
39
|
+
connected: false,
|
|
40
|
+
pendingRequests: 0,
|
|
41
|
+
index
|
|
42
|
+
};
|
|
43
|
+
ws.on("open", () => {
|
|
44
|
+
connection.connected = true;
|
|
45
|
+
resolve(connection);
|
|
46
|
+
});
|
|
47
|
+
ws.on("error", (error) => {
|
|
48
|
+
connection.connected = false;
|
|
49
|
+
if (!connection.connected) {
|
|
50
|
+
reject(error);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
ws.on("close", () => {
|
|
54
|
+
connection.connected = false;
|
|
55
|
+
// Attempt to reconnect after a delay
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
if (this.apiKey) {
|
|
58
|
+
this.reconnectConnection(index).catch(() => { });
|
|
59
|
+
}
|
|
60
|
+
}, 5000);
|
|
61
|
+
});
|
|
62
|
+
ws.on("message", (data) => {
|
|
63
|
+
// Message handling done in _asyncSend
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
reject(error);
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
async reconnectConnection(index) {
|
|
72
|
+
const existingConnection = this.connections[index];
|
|
73
|
+
if (existingConnection && existingConnection.ws.readyState === ws_1.default.OPEN) {
|
|
74
|
+
return; // Already connected
|
|
75
|
+
}
|
|
76
|
+
// Clean up old connection
|
|
77
|
+
if (existingConnection) {
|
|
78
|
+
existingConnection.ws.removeAllListeners();
|
|
79
|
+
if (existingConnection.ws.readyState === ws_1.default.OPEN || existingConnection.ws.readyState === ws_1.default.CONNECTING) {
|
|
80
|
+
existingConnection.ws.close();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
try {
|
|
84
|
+
const newConnection = await this.createConnection(index);
|
|
85
|
+
this.connections[index] = newConnection;
|
|
86
|
+
}
|
|
87
|
+
catch (error) {
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
async connect() {
|
|
91
|
+
if (!this.apiKey) {
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (this.connecting) {
|
|
95
|
+
// Wait for existing connection attempts
|
|
96
|
+
await Promise.all(this.connectionPromises);
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
if (this.connections.length > 0 && this.isConnected()) {
|
|
100
|
+
// Already connected
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.connecting = true;
|
|
104
|
+
this.connectionPromises = [];
|
|
105
|
+
try {
|
|
106
|
+
// Create all connections in parallel
|
|
107
|
+
const connectionPromises = Array.from({ length: this.poolSize }, (_, index) => this.createConnection(index).catch((error) => {
|
|
108
|
+
// Return a placeholder that will be retried
|
|
109
|
+
return null;
|
|
110
|
+
}));
|
|
111
|
+
const results = await Promise.all(connectionPromises);
|
|
112
|
+
// Filter out failed connections and store successful ones
|
|
113
|
+
this.connections = results
|
|
114
|
+
.filter((conn) => conn !== null)
|
|
115
|
+
.sort((a, b) => a.index - b.index);
|
|
116
|
+
// Retry failed connections
|
|
117
|
+
for (let i = 0; i < this.poolSize; i++) {
|
|
118
|
+
if (!this.connections.find(c => c.index === i)) {
|
|
119
|
+
this.reconnectConnection(i).catch(console.error);
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
finally {
|
|
124
|
+
this.connecting = false;
|
|
125
|
+
this.connectionPromises = [];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
getConnection() {
|
|
129
|
+
if (this.connections.length === 0) {
|
|
130
|
+
return null;
|
|
131
|
+
}
|
|
132
|
+
// Filter to only connected connections
|
|
133
|
+
const connected = this.connections.filter(conn => conn.connected);
|
|
134
|
+
if (connected.length === 0) {
|
|
135
|
+
return null;
|
|
136
|
+
}
|
|
137
|
+
// Use least-busy connection strategy
|
|
138
|
+
let selected = connected[0];
|
|
139
|
+
for (const conn of connected) {
|
|
140
|
+
if (conn.pendingRequests < selected.pendingRequests) {
|
|
141
|
+
selected = conn;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
// If all connections have the same load, use round-robin for better distribution
|
|
145
|
+
const sameLoad = connected.every(conn => conn.pendingRequests === selected.pendingRequests);
|
|
146
|
+
if (sameLoad && connected.length > 1) {
|
|
147
|
+
this.currentIndex = (this.currentIndex + 1) % connected.length;
|
|
148
|
+
selected = connected[this.currentIndex];
|
|
149
|
+
}
|
|
150
|
+
return selected;
|
|
151
|
+
}
|
|
152
|
+
async sendAsync(payload) {
|
|
153
|
+
const connection = this.getConnection();
|
|
154
|
+
if (!connection) {
|
|
155
|
+
throw new Error("WebSocket not connected");
|
|
156
|
+
}
|
|
157
|
+
const socketResponse = await this._asyncSend(payload, connection);
|
|
158
|
+
return socketResponse;
|
|
159
|
+
}
|
|
160
|
+
send(payload) {
|
|
161
|
+
const connection = this.getConnection();
|
|
162
|
+
if (!connection) {
|
|
163
|
+
throw new Error("WebSocket not connected");
|
|
164
|
+
}
|
|
165
|
+
connection.ws.send(JSON.stringify(payload));
|
|
166
|
+
}
|
|
167
|
+
close() {
|
|
168
|
+
for (const conn of this.connections) {
|
|
169
|
+
if (conn.ws) {
|
|
170
|
+
conn.ws.close();
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
this.connections = [];
|
|
174
|
+
}
|
|
175
|
+
isConnected() {
|
|
176
|
+
return this.connections.some(conn => conn.connected);
|
|
177
|
+
}
|
|
178
|
+
getWs() {
|
|
179
|
+
const connection = this.getConnection();
|
|
180
|
+
return connection ? connection.ws : null;
|
|
181
|
+
}
|
|
182
|
+
async _asyncSend(payload, connection) {
|
|
183
|
+
return new Promise((resolve, reject) => {
|
|
184
|
+
if (!connection.ws || !connection.connected) {
|
|
185
|
+
reject(new Error("WebSocket not connected"));
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
// Increment pending requests counter
|
|
189
|
+
connection.pendingRequests++;
|
|
190
|
+
const id = Math.random().toString(36).slice(2) + Date.now().toString(36);
|
|
191
|
+
const message = { id, ...payload };
|
|
192
|
+
let isResolved = false;
|
|
193
|
+
// Set up timeout to prevent handlers from accumulating forever
|
|
194
|
+
const timeout = setTimeout(() => {
|
|
195
|
+
if (!isResolved) {
|
|
196
|
+
isResolved = true;
|
|
197
|
+
connection.pendingRequests--;
|
|
198
|
+
if (connection.ws) {
|
|
199
|
+
connection.ws.off('message', handleMessage);
|
|
200
|
+
}
|
|
201
|
+
// reject(new Error(`WebSocket request timeout for id: ${id}`));
|
|
202
|
+
}
|
|
203
|
+
}, 2000); // 20 second timeout
|
|
204
|
+
// Wrap resolve to clear timeout
|
|
205
|
+
const wrappedResolve = (value) => {
|
|
206
|
+
if (!isResolved) {
|
|
207
|
+
clearTimeout(timeout);
|
|
208
|
+
isResolved = true;
|
|
209
|
+
connection.pendingRequests--;
|
|
210
|
+
resolve(value);
|
|
211
|
+
}
|
|
212
|
+
};
|
|
213
|
+
const wrappedReject = (error) => {
|
|
214
|
+
if (!isResolved) {
|
|
215
|
+
clearTimeout(timeout);
|
|
216
|
+
isResolved = true;
|
|
217
|
+
connection.pendingRequests--;
|
|
218
|
+
reject(error);
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
const handleMessage = (data) => {
|
|
222
|
+
if (isResolved)
|
|
223
|
+
return; // Prevent multiple processing
|
|
224
|
+
try {
|
|
225
|
+
const response = JSON.parse(data.toString());
|
|
226
|
+
// Use strict equality and check if this response matches our request
|
|
227
|
+
if (response.id === id || response.replyTo === id) {
|
|
228
|
+
// Remove handler immediately before resolving
|
|
229
|
+
if (connection.ws) {
|
|
230
|
+
connection.ws.off('message', handleMessage);
|
|
231
|
+
}
|
|
232
|
+
wrappedResolve(response);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
catch (error) {
|
|
236
|
+
// Ignore parse errors for messages that don't match
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
connection.ws.on('message', handleMessage);
|
|
240
|
+
connection.ws.send(JSON.stringify(message), (err) => {
|
|
241
|
+
if (err) {
|
|
242
|
+
wrappedReject(err);
|
|
243
|
+
if (connection.ws) {
|
|
244
|
+
connection.ws.off('message', handleMessage);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* Clean up resources including WebSocket connections
|
|
252
|
+
*/
|
|
253
|
+
destroy() {
|
|
254
|
+
for (const conn of this.connections) {
|
|
255
|
+
if (conn.ws) {
|
|
256
|
+
conn.ws.removeAllListeners();
|
|
257
|
+
if (conn.ws.readyState === ws_1.default.OPEN || conn.ws.readyState === ws_1.default.CONNECTING) {
|
|
258
|
+
conn.ws.close();
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
this.connections = [];
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
exports.UsageFlowSocketManger = UsageFlowSocketManger;
|
|
266
|
+
//# sourceMappingURL=socket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":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Aa,CAAC,CAAC;oBAClC,CAAC;gBACL,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBACb,oDAAoD;gBACxD,CAAC;YACL,CAAC,CAAC;YAEF,UAAU,CAAC,EAAE,CAAC,EAAE,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;YAE3C,UAAU,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,CAAC,GAA6B,EAAE,EAAE;gBAC1E,IAAI,GAAG,EAAE,CAAC;oBACN,aAAa,CAAC,GAAG,CAAC,CAAC;oBACnB,IAAI,UAAU,CAAC,EAAE,EAAE,CAAC;wBAChB,UAAU,CAAC,EAAE,CAAC,GAAG,CAAC,SAAS,EAAE,aAAa,CAAC,CAAC;oBAChD,CAAC;gBACL,CAAC;YACL,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACP,CAAC;IAID;;OAEG;IACI,OAAO;QACV,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;YAClC,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;gBACV,IAAI,CAAC,EAAE,CAAC,kBAAkB,EAAE,CAAC;gBAC7B,IAAI,IAAI,CAAC,EAAE,CAAC,UAAU,KAAK,YAAS,CAAC,IAAI,IAAI,IAAI,CAAC,EAAE,CAAC,UAAU,KAAK,YAAS,CAAC,UAAU,EAAE,CAAC;oBACvF,IAAI,CAAC,EAAE,CAAC,KAAK,EAAE,CAAC;gBACpB,CAAC;YACL,CAAC;QACL,CAAC;QACD,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IAC1B,CAAC;CAIJ;AAjTD,sDAiTC"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
namespace Express {
|
|
3
|
+
interface Request {
|
|
4
|
+
usageflow?: {
|
|
5
|
+
startTime: number;
|
|
6
|
+
eventId?: string;
|
|
7
|
+
metadata?: RequestMetadata;
|
|
8
|
+
};
|
|
9
|
+
baseUrl: string;
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
namespace Fastify {
|
|
13
|
+
interface FastifyRequest {
|
|
14
|
+
usageflow?: {
|
|
15
|
+
startTime: number;
|
|
16
|
+
eventId?: string;
|
|
17
|
+
metadata?: RequestMetadata;
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
namespace NestJS {
|
|
22
|
+
interface Request {
|
|
23
|
+
usageflow?: {
|
|
24
|
+
startTime: number;
|
|
25
|
+
eventId?: string;
|
|
26
|
+
metadata?: RequestMetadata;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export interface Route {
|
|
32
|
+
method: string;
|
|
33
|
+
url: string;
|
|
34
|
+
}
|
|
35
|
+
export interface RequestMetadata {
|
|
36
|
+
method: string;
|
|
37
|
+
url: string;
|
|
38
|
+
rawUrl: string;
|
|
39
|
+
clientIP: string;
|
|
40
|
+
userAgent?: string;
|
|
41
|
+
timestamp: string;
|
|
42
|
+
headers: Record<string, string>;
|
|
43
|
+
queryParams: Record<string, any> | null;
|
|
44
|
+
pathParams: Record<string, any> | null;
|
|
45
|
+
body?: any;
|
|
46
|
+
requestDuration?: number;
|
|
47
|
+
}
|
|
48
|
+
export interface ResponseMetadata {
|
|
49
|
+
statusCode: number;
|
|
50
|
+
responseHeaders: Record<string, string>;
|
|
51
|
+
duration: number;
|
|
52
|
+
timestamp: string;
|
|
53
|
+
}
|
|
54
|
+
export interface UsageFlowConfig {
|
|
55
|
+
url: string;
|
|
56
|
+
method: string;
|
|
57
|
+
identityFieldName?: string;
|
|
58
|
+
identityFieldLocation?: string;
|
|
59
|
+
}
|
|
60
|
+
export interface UsageFlowResponse {
|
|
61
|
+
eventId: string;
|
|
62
|
+
status: string;
|
|
63
|
+
}
|
|
64
|
+
export interface Headers {
|
|
65
|
+
[key: string]: string;
|
|
66
|
+
}
|
|
67
|
+
export type RoutesMap = Record<string, Record<string, boolean>>;
|
|
68
|
+
export declare class UsageFlowError extends Error {
|
|
69
|
+
constructor(message: string);
|
|
70
|
+
}
|
|
71
|
+
export interface RequestForAllocation {
|
|
72
|
+
alias: string;
|
|
73
|
+
amount: number;
|
|
74
|
+
allocationId?: string;
|
|
75
|
+
metadata: RequestMetadata;
|
|
76
|
+
duration?: number;
|
|
77
|
+
}
|
|
78
|
+
export type MessageTypes = 'request_for_allocation' | 'use_allocation' | 'get_application_policies';
|
|
79
|
+
export interface UsageFlowSocketMessage {
|
|
80
|
+
type: MessageTypes;
|
|
81
|
+
payload: RequestForAllocation | null;
|
|
82
|
+
}
|
|
83
|
+
export interface UsageFlowAPIConfig {
|
|
84
|
+
apiKey: string;
|
|
85
|
+
poolSize?: number | 5;
|
|
86
|
+
}
|
|
87
|
+
export interface UsageFlowSocketResponse<T> {
|
|
88
|
+
type: 'success' | 'error';
|
|
89
|
+
payload: T;
|
|
90
|
+
status: 'success' | 'error' | 400;
|
|
91
|
+
message: string;
|
|
92
|
+
error?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface UsageFlowRequest {
|
|
95
|
+
method: string;
|
|
96
|
+
url?: string;
|
|
97
|
+
path?: string;
|
|
98
|
+
baseUrl?: string;
|
|
99
|
+
route?: {
|
|
100
|
+
path: string;
|
|
101
|
+
};
|
|
102
|
+
app?: any;
|
|
103
|
+
params?: Record<string, any>;
|
|
104
|
+
query?: Record<string, any>;
|
|
105
|
+
body?: any;
|
|
106
|
+
headers: Record<string, string | string[] | undefined> | Headers;
|
|
107
|
+
ip?: string;
|
|
108
|
+
originalUrl?: string;
|
|
109
|
+
usageflow?: {
|
|
110
|
+
eventId?: string;
|
|
111
|
+
metadata?: RequestMetadata;
|
|
112
|
+
startTime?: number;
|
|
113
|
+
};
|
|
114
|
+
routeOptions?: {
|
|
115
|
+
url: string;
|
|
116
|
+
};
|
|
117
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UsageFlowError = void 0;
|
|
4
|
+
class UsageFlowError extends Error {
|
|
5
|
+
constructor(message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'UsageFlowError';
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
exports.UsageFlowError = UsageFlowError;
|
|
11
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":";;;AA6EA,MAAa,cAAe,SAAQ,KAAK;IACrC,YAAY,OAAe;QACvB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IACjC,CAAC;CACJ;AALD,wCAKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"fileNames":["../../../node_modules/typescript/lib/lib.es5.d.ts","../../../node_modules/typescript/lib/lib.es2015.d.ts","../../../node_modules/typescript/lib/lib.es2016.d.ts","../../../node_modules/typescript/lib/lib.es2017.d.ts","../../../node_modules/typescript/lib/lib.es2018.d.ts","../../../node_modules/typescript/lib/lib.es2019.d.ts","../../../node_modules/typescript/lib/lib.es2020.d.ts","../../../node_modules/typescript/lib/lib.dom.d.ts","../../../node_modules/typescript/lib/lib.dom.iterable.d.ts","../../../node_modules/typescript/lib/lib.dom.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../../../node_modules/typescript/lib/lib.scripthost.d.ts","../../../node_modules/typescript/lib/lib.es2015.core.d.ts","../../../node_modules/typescript/lib/lib.es2015.collection.d.ts","../../../node_modules/typescript/lib/lib.es2015.generator.d.ts","../../../node_modules/typescript/lib/lib.es2015.iterable.d.ts","../../../node_modules/typescript/lib/lib.es2015.promise.d.ts","../../../node_modules/typescript/lib/lib.es2015.proxy.d.ts","../../../node_modules/typescript/lib/lib.es2015.reflect.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2016.array.include.d.ts","../../../node_modules/typescript/lib/lib.es2016.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.arraybuffer.d.ts","../../../node_modules/typescript/lib/lib.es2017.date.d.ts","../../../node_modules/typescript/lib/lib.es2017.object.d.ts","../../../node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2017.string.d.ts","../../../node_modules/typescript/lib/lib.es2017.intl.d.ts","../../../node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../../../node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../../../node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../../../node_modules/typescript/lib/lib.es2018.intl.d.ts","../../../node_modules/typescript/lib/lib.es2018.promise.d.ts","../../../node_modules/typescript/lib/lib.es2018.regexp.d.ts","../../../node_modules/typescript/lib/lib.es2019.array.d.ts","../../../node_modules/typescript/lib/lib.es2019.object.d.ts","../../../node_modules/typescript/lib/lib.es2019.string.d.ts","../../../node_modules/typescript/lib/lib.es2019.symbol.d.ts","../../../node_modules/typescript/lib/lib.es2019.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.bigint.d.ts","../../../node_modules/typescript/lib/lib.es2020.date.d.ts","../../../node_modules/typescript/lib/lib.es2020.promise.d.ts","../../../node_modules/typescript/lib/lib.es2020.sharedmemory.d.ts","../../../node_modules/typescript/lib/lib.es2020.string.d.ts","../../../node_modules/typescript/lib/lib.es2020.symbol.wellknown.d.ts","../../../node_modules/typescript/lib/lib.es2020.intl.d.ts","../../../node_modules/typescript/lib/lib.es2020.number.d.ts","../../../node_modules/typescript/lib/lib.decorators.d.ts","../../../node_modules/typescript/lib/lib.decorators.legacy.d.ts","../../../node_modules/typescript/lib/lib.es2018.full.d.ts","../dist/types.d.ts","../../../node_modules/@types/node/compatibility/disposable.d.ts","../../../node_modules/@types/node/compatibility/indexable.d.ts","../../../node_modules/@types/node/compatibility/iterators.d.ts","../../../node_modules/@types/node/compatibility/index.d.ts","../../../node_modules/@types/node/globals.typedarray.d.ts","../../../node_modules/@types/node/buffer.buffer.d.ts","../../../node_modules/undici-types/header.d.ts","../../../node_modules/undici-types/readable.d.ts","../../../node_modules/undici-types/file.d.ts","../../../node_modules/undici-types/fetch.d.ts","../../../node_modules/undici-types/formdata.d.ts","../../../node_modules/undici-types/connector.d.ts","../../../node_modules/undici-types/client.d.ts","../../../node_modules/undici-types/errors.d.ts","../../../node_modules/undici-types/dispatcher.d.ts","../../../node_modules/undici-types/global-dispatcher.d.ts","../../../node_modules/undici-types/global-origin.d.ts","../../../node_modules/undici-types/pool-stats.d.ts","../../../node_modules/undici-types/pool.d.ts","../../../node_modules/undici-types/handlers.d.ts","../../../node_modules/undici-types/balanced-pool.d.ts","../../../node_modules/undici-types/agent.d.ts","../../../node_modules/undici-types/mock-interceptor.d.ts","../../../node_modules/undici-types/mock-agent.d.ts","../../../node_modules/undici-types/mock-client.d.ts","../../../node_modules/undici-types/mock-pool.d.ts","../../../node_modules/undici-types/mock-errors.d.ts","../../../node_modules/undici-types/proxy-agent.d.ts","../../../node_modules/undici-types/env-http-proxy-agent.d.ts","../../../node_modules/undici-types/retry-handler.d.ts","../../../node_modules/undici-types/retry-agent.d.ts","../../../node_modules/undici-types/api.d.ts","../../../node_modules/undici-types/interceptors.d.ts","../../../node_modules/undici-types/util.d.ts","../../../node_modules/undici-types/cookies.d.ts","../../../node_modules/undici-types/patch.d.ts","../../../node_modules/undici-types/websocket.d.ts","../../../node_modules/undici-types/eventsource.d.ts","../../../node_modules/undici-types/filereader.d.ts","../../../node_modules/undici-types/diagnostics-channel.d.ts","../../../node_modules/undici-types/content-type.d.ts","../../../node_modules/undici-types/cache.d.ts","../../../node_modules/undici-types/index.d.ts","../../../node_modules/@types/node/globals.d.ts","../../../node_modules/@types/node/assert.d.ts","../../../node_modules/@types/node/assert/strict.d.ts","../../../node_modules/@types/node/async_hooks.d.ts","../../../node_modules/@types/node/buffer.d.ts","../../../node_modules/@types/node/child_process.d.ts","../../../node_modules/@types/node/cluster.d.ts","../../../node_modules/@types/node/console.d.ts","../../../node_modules/@types/node/constants.d.ts","../../../node_modules/@types/node/crypto.d.ts","../../../node_modules/@types/node/dgram.d.ts","../../../node_modules/@types/node/diagnostics_channel.d.ts","../../../node_modules/@types/node/dns.d.ts","../../../node_modules/@types/node/dns/promises.d.ts","../../../node_modules/@types/node/domain.d.ts","../../../node_modules/@types/node/dom-events.d.ts","../../../node_modules/@types/node/events.d.ts","../../../node_modules/@types/node/fs.d.ts","../../../node_modules/@types/node/fs/promises.d.ts","../../../node_modules/@types/node/http.d.ts","../../../node_modules/@types/node/http2.d.ts","../../../node_modules/@types/node/https.d.ts","../../../node_modules/@types/node/inspector.d.ts","../../../node_modules/@types/node/module.d.ts","../../../node_modules/@types/node/net.d.ts","../../../node_modules/@types/node/os.d.ts","../../../node_modules/@types/node/path.d.ts","../../../node_modules/@types/node/perf_hooks.d.ts","../../../node_modules/@types/node/process.d.ts","../../../node_modules/@types/node/punycode.d.ts","../../../node_modules/@types/node/querystring.d.ts","../../../node_modules/@types/node/readline.d.ts","../../../node_modules/@types/node/readline/promises.d.ts","../../../node_modules/@types/node/repl.d.ts","../../../node_modules/@types/node/sea.d.ts","../../../node_modules/@types/node/stream.d.ts","../../../node_modules/@types/node/stream/promises.d.ts","../../../node_modules/@types/node/stream/consumers.d.ts","../../../node_modules/@types/node/stream/web.d.ts","../../../node_modules/@types/node/string_decoder.d.ts","../../../node_modules/@types/node/test.d.ts","../../../node_modules/@types/node/timers.d.ts","../../../node_modules/@types/node/timers/promises.d.ts","../../../node_modules/@types/node/tls.d.ts","../../../node_modules/@types/node/trace_events.d.ts","../../../node_modules/@types/node/tty.d.ts","../../../node_modules/@types/node/url.d.ts","../../../node_modules/@types/node/util.d.ts","../../../node_modules/@types/node/v8.d.ts","../../../node_modules/@types/node/vm.d.ts","../../../node_modules/@types/node/wasi.d.ts","../../../node_modules/@types/node/worker_threads.d.ts","../../../node_modules/@types/node/zlib.d.ts","../../../node_modules/@types/node/index.d.ts","../../../node_modules/@types/ws/index.d.ts","../dist/socket.d.ts","../dist/base.d.ts","./base.test.ts","./socket.test.ts","./types.test.ts","./src/types.d.ts","./src/socket.d.ts","./src/base.d.ts","./src/index.d.ts","./test/base.test.d.ts","./test/socket.test.d.ts","./test/types.test.d.ts","../../../node_modules/@babel/types/lib/index.d.ts","../../../node_modules/@types/babel__generator/index.d.ts","../../../node_modules/@babel/parser/typings/babel-parser.d.ts","../../../node_modules/@types/babel__template/index.d.ts","../../../node_modules/@types/babel__traverse/index.d.ts","../../../node_modules/@types/babel__core/index.d.ts","../../../node_modules/@types/connect/index.d.ts","../../../node_modules/@types/body-parser/index.d.ts","../../../node_modules/@types/mime/index.d.ts","../../../node_modules/@types/send/index.d.ts","../../../node_modules/@types/qs/index.d.ts","../../../node_modules/@types/range-parser/index.d.ts","../../../node_modules/@types/express-serve-static-core/index.d.ts","../../../node_modules/@types/http-errors/index.d.ts","../../../node_modules/@types/serve-static/index.d.ts","../../../node_modules/@types/express/index.d.ts","../../../node_modules/@types/graceful-fs/index.d.ts","../../../node_modules/@types/istanbul-lib-coverage/index.d.ts","../../../node_modules/@types/istanbul-lib-report/index.d.ts","../../../node_modules/@types/istanbul-reports/index.d.ts","../../../node_modules/@jest/expect-utils/build/index.d.ts","../../../node_modules/chalk/index.d.ts","../../../node_modules/@jest/schemas/node_modules/@sinclair/typebox/typebox.d.ts","../../../node_modules/@jest/schemas/build/index.d.ts","../../../node_modules/pretty-format/build/index.d.ts","../../../node_modules/jest-diff/build/index.d.ts","../../../node_modules/jest-matcher-utils/build/index.d.ts","../../../node_modules/expect/build/index.d.ts","../../../node_modules/@types/jest/index.d.ts","../../../node_modules/@types/stack-utils/index.d.ts","../../../node_modules/@types/yargs-parser/index.d.ts","../../../node_modules/@types/yargs/index.d.ts"],"fileIdsList":[[58,100,163],[58,100],[58,100,185],[58,100,163,164,165,166,167],[58,100,163,165],[58,100,115,149,169],[58,100,115,149],[58,100,112,115,149,172,173,174],[58,100,170,173,175,177],[58,100,113,149],[58,100,180],[58,100,181],[58,100,187,190],[58,97,100],[58,99,100],[100],[58,100,105,134],[58,100,101,106,112,113,120,131,142],[58,100,101,102,112,120],[53,54,55,58,100],[58,100,103,143],[58,100,104,105,113,121],[58,100,105,131,139],[58,100,106,108,112,120],[58,99,100,107],[58,100,108,109],[58,100,112],[58,100,110,112],[58,99,100,112],[58,100,112,113,114,131,142],[58,100,112,113,114,127,131,134],[58,95,100,147],[58,100,108,112,115,120,131,142],[58,100,112,113,115,116,120,131,139,142],[58,100,115,117,131,139,142],[56,57,58,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148],[58,100,112,118],[58,100,119,142,147],[58,100,108,112,120,131],[58,100,121],[58,100,122],[58,99,100,123],[58,97,98,99,100,101,102,103,104,105,106,107,108,109,110,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148],[58,100,125],[58,100,126],[58,100,112,127,128],[58,100,127,129,143,145],[58,100,112,131,132,134],[58,100,131,133],[58,100,131,132],[58,100,134],[58,100,135],[58,97,100,131],[58,100,112,137,138],[58,100,137,138],[58,100,105,120,131,139],[58,100,140],[58,100,120,141],[58,100,115,126,142],[58,100,105,143],[58,100,131,144],[58,100,119,145],[58,100,146],[58,100,105,112,114,123,131,142,145,147],[58,100,131,148],[58,100,113,131,149,171],[58,100,115,149,172,176],[58,100,112,115,117,120,131,139,142,148,149],[58,100,193],[58,100,183,189],[58,100,187],[58,100,184,188],[58,100,186],[58,67,71,100,142],[58,67,100,131,142],[58,62,100],[58,64,67,100,139,142],[58,100,120,139],[58,100,149],[58,62,100,149],[58,64,67,100,120,142],[58,59,60,63,66,100,112,131,142],[58,67,74,100],[58,59,65,100],[58,67,88,89,100],[58,63,67,100,134,142,149],[58,88,100,149],[58,61,62,100,149],[58,67,100],[58,61,62,63,64,65,66,67,68,69,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,89,90,91,92,93,94,100],[58,67,82,100],[58,67,74,75,100],[58,65,67,75,76,100],[58,66,100],[58,59,62,67,100],[58,67,71,75,76,100],[58,71,100],[58,65,67,70,100,142],[58,59,64,67,74,100],[58,100,131],[58,62,67,88,100,147,149],[52,58,100,151],[52,58,100,150],[52,58,97,100,136,152],[52,58,97,100,136,151],[58,100,156,157],[58,100,156,157,158],[58,100,150,156],[52,58,97,100,136]],"fileInfos":[{"version":"69684132aeb9b5642cbcd9e22dff7818ff0ee1aa831728af0ecf97d3364d5546","affectsGlobalScope":true,"impliedFormat":1},{"version":"45b7ab580deca34ae9729e97c13cfd999df04416a79116c3bfb483804f85ded4","impliedFormat":1},{"version":"3facaf05f0c5fc569c5649dd359892c98a85557e3e0c847964caeb67076f4d75","impliedFormat":1},{"version":"e44bb8bbac7f10ecc786703fe0a6a4b952189f908707980ba8f3c8975a760962","impliedFormat":1},{"version":"5e1c4c362065a6b95ff952c0eab010f04dcd2c3494e813b493ecfd4fcb9fc0d8","impliedFormat":1},{"version":"68d73b4a11549f9c0b7d352d10e91e5dca8faa3322bfb77b661839c42b1ddec7","impliedFormat":1},{"version":"5efce4fc3c29ea84e8928f97adec086e3dc876365e0982cc8479a07954a3efd4","impliedFormat":1},{"version":"092c2bfe125ce69dbb1223c85d68d4d2397d7d8411867b5cc03cec902c233763","affectsGlobalScope":true,"impliedFormat":1},{"version":"07f073f19d67f74d732b1adea08e1dc66b1b58d77cb5b43931dee3d798a2fd53","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7a3c8b952931daebdfc7a2897c53c0a1c73624593fa070e46bd537e64dcd20a","affectsGlobalScope":true,"impliedFormat":1},{"version":"80e18897e5884b6723488d4f5652167e7bb5024f946743134ecc4aa4ee731f89","affectsGlobalScope":true,"impliedFormat":1},{"version":"cd034f499c6cdca722b60c04b5b1b78e058487a7085a8e0d6fb50809947ee573","affectsGlobalScope":true,"impliedFormat":1},{"version":"c57796738e7f83dbc4b8e65132f11a377649c00dd3eee333f672b8f0a6bea671","affectsGlobalScope":true,"impliedFormat":1},{"version":"dc2df20b1bcdc8c2d34af4926e2c3ab15ffe1160a63e58b7e09833f616efff44","affectsGlobalScope":true,"impliedFormat":1},{"version":"515d0b7b9bea2e31ea4ec968e9edd2c39d3eebf4a2d5cbd04e88639819ae3b71","affectsGlobalScope":true,"impliedFormat":1},{"version":"0559b1f683ac7505ae451f9a96ce4c3c92bdc71411651ca6ddb0e88baaaad6a3","affectsGlobalScope":true,"impliedFormat":1},{"version":"0dc1e7ceda9b8b9b455c3a2d67b0412feab00bd2f66656cd8850e8831b08b537","affectsGlobalScope":true,"impliedFormat":1},{"version":"ce691fb9e5c64efb9547083e4a34091bcbe5bdb41027e310ebba8f7d96a98671","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d697a2a929a5fcb38b7a65594020fcef05ec1630804a33748829c5ff53640d0","affectsGlobalScope":true,"impliedFormat":1},{"version":"4ff2a353abf8a80ee399af572debb8faab2d33ad38c4b4474cff7f26e7653b8d","affectsGlobalScope":true,"impliedFormat":1},{"version":"936e80ad36a2ee83fc3caf008e7c4c5afe45b3cf3d5c24408f039c1d47bdc1df","affectsGlobalScope":true,"impliedFormat":1},{"version":"d15bea3d62cbbdb9797079416b8ac375ae99162a7fba5de2c6c505446486ac0a","affectsGlobalScope":true,"impliedFormat":1},{"version":"68d18b664c9d32a7336a70235958b8997ebc1c3b8505f4f1ae2b7e7753b87618","affectsGlobalScope":true,"impliedFormat":1},{"version":"eb3d66c8327153d8fa7dd03f9c58d351107fe824c79e9b56b462935176cdf12a","affectsGlobalScope":true,"impliedFormat":1},{"version":"38f0219c9e23c915ef9790ab1d680440d95419ad264816fa15009a8851e79119","affectsGlobalScope":true,"impliedFormat":1},{"version":"69ab18c3b76cd9b1be3d188eaf8bba06112ebbe2f47f6c322b5105a6fbc45a2e","affectsGlobalScope":true,"impliedFormat":1},{"version":"fef8cfad2e2dc5f5b3d97a6f4f2e92848eb1b88e897bb7318cef0e2820bceaab","affectsGlobalScope":true,"impliedFormat":1},{"version":"2f11ff796926e0832f9ae148008138ad583bd181899ab7dd768a2666700b1893","affectsGlobalScope":true,"impliedFormat":1},{"version":"4de680d5bb41c17f7f68e0419412ca23c98d5749dcaaea1896172f06435891fc","affectsGlobalScope":true,"impliedFormat":1},{"version":"954296b30da6d508a104a3a0b5d96b76495c709785c1d11610908e63481ee667","affectsGlobalScope":true,"impliedFormat":1},{"version":"ac9538681b19688c8eae65811b329d3744af679e0bdfa5d842d0e32524c73e1c","affectsGlobalScope":true,"impliedFormat":1},{"version":"0a969edff4bd52585473d24995c5ef223f6652d6ef46193309b3921d65dd4376","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e9fbd7030c440b33d021da145d3232984c8bb7916f277e8ffd3dc2e3eae2bdb","affectsGlobalScope":true,"impliedFormat":1},{"version":"811ec78f7fefcabbda4bfa93b3eb67d9ae166ef95f9bff989d964061cbf81a0c","affectsGlobalScope":true,"impliedFormat":1},{"version":"717937616a17072082152a2ef351cb51f98802fb4b2fdabd32399843875974ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"d7e7d9b7b50e5f22c915b525acc5a49a7a6584cf8f62d0569e557c5cfc4b2ac2","affectsGlobalScope":true,"impliedFormat":1},{"version":"71c37f4c9543f31dfced6c7840e068c5a5aacb7b89111a4364b1d5276b852557","affectsGlobalScope":true,"impliedFormat":1},{"version":"576711e016cf4f1804676043e6a0a5414252560eb57de9faceee34d79798c850","affectsGlobalScope":true,"impliedFormat":1},{"version":"89c1b1281ba7b8a96efc676b11b264de7a8374c5ea1e6617f11880a13fc56dc6","affectsGlobalScope":true,"impliedFormat":1},{"version":"74f7fa2d027d5b33eb0471c8e82a6c87216223181ec31247c357a3e8e2fddc5b","affectsGlobalScope":true,"impliedFormat":1},{"version":"d6d7ae4d1f1f3772e2a3cde568ed08991a8ae34a080ff1151af28b7f798e22ca","affectsGlobalScope":true,"impliedFormat":1},{"version":"063600664504610fe3e99b717a1223f8b1900087fab0b4cad1496a114744f8df","affectsGlobalScope":true,"impliedFormat":1},{"version":"934019d7e3c81950f9a8426d093458b65d5aff2c7c1511233c0fd5b941e608ab","affectsGlobalScope":true,"impliedFormat":1},{"version":"52ada8e0b6e0482b728070b7639ee42e83a9b1c22d205992756fe020fd9f4a47","affectsGlobalScope":true,"impliedFormat":1},{"version":"3bdefe1bfd4d6dee0e26f928f93ccc128f1b64d5d501ff4a8cf3c6371200e5e6","affectsGlobalScope":true,"impliedFormat":1},{"version":"59fb2c069260b4ba00b5643b907ef5d5341b167e7d1dbf58dfd895658bda2867","affectsGlobalScope":true,"impliedFormat":1},{"version":"639e512c0dfc3fad96a84caad71b8834d66329a1f28dc95e3946c9b58176c73a","affectsGlobalScope":true,"impliedFormat":1},{"version":"368af93f74c9c932edd84c58883e736c9e3d53cec1fe24c0b0ff451f529ceab1","affectsGlobalScope":true,"impliedFormat":1},{"version":"8e7f8264d0fb4c5339605a15daadb037bf238c10b654bb3eee14208f860a32ea","affectsGlobalScope":true,"impliedFormat":1},{"version":"782dec38049b92d4e85c1585fbea5474a219c6984a35b004963b00beb1aab538","affectsGlobalScope":true,"impliedFormat":1},{"version":"95f1023b824c2c511c48f1201e2d1188bcb0ca1138a309a870b956d2e92e44ab","impliedFormat":1},{"version":"78404ae43e83a27c4e130adce53afa5abd7cb5691c5117650894d68bac772102","affectsGlobalScope":true},{"version":"70521b6ab0dcba37539e5303104f29b721bfb2940b2776da4cc818c07e1fefc1","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab41ef1f2cdafb8df48be20cd969d875602483859dc194e9c97c8a576892c052","affectsGlobalScope":true,"impliedFormat":1},{"version":"d153a11543fd884b596587ccd97aebbeed950b26933ee000f94009f1ab142848","affectsGlobalScope":true,"impliedFormat":1},{"version":"21d819c173c0cf7cc3ce57c3276e77fd9a8a01d35a06ad87158781515c9a438a","impliedFormat":1},{"version":"a79e62f1e20467e11a904399b8b18b18c0c6eea6b50c1168bf215356d5bebfaf","affectsGlobalScope":true,"impliedFormat":1},{"version":"6b80c6175da9de59bace50a72c2d68490d4ab5b07016ff5367bc7ba33cf2f219","affectsGlobalScope":true,"impliedFormat":1},{"version":"5929864ce17fba74232584d90cb721a89b7ad277220627cc97054ba15a98ea8f","impliedFormat":1},{"version":"24bd580b5743dc56402c440dc7f9a4f5d592ad7a419f25414d37a7bfe11e342b","impliedFormat":1},{"version":"25c8056edf4314820382a5fdb4bb7816999acdcb929c8f75e3f39473b87e85bc","impliedFormat":1},{"version":"c464d66b20788266e5353b48dc4aa6bc0dc4a707276df1e7152ab0c9ae21fad8","impliedFormat":1},{"version":"78d0d27c130d35c60b5e5566c9f1e5be77caf39804636bc1a40133919a949f21","impliedFormat":1},{"version":"c6fd2c5a395f2432786c9cb8deb870b9b0e8ff7e22c029954fabdd692bff6195","impliedFormat":1},{"version":"1d6e127068ea8e104a912e42fc0a110e2aa5a66a356a917a163e8cf9a65e4a75","impliedFormat":1},{"version":"5ded6427296cdf3b9542de4471d2aa8d3983671d4cac0f4bf9c637208d1ced43","impliedFormat":1},{"version":"6bdc71028db658243775263e93a7db2fd2abfce3ca569c3cca5aee6ed5eb186d","impliedFormat":1},{"version":"cadc8aced301244057c4e7e73fbcae534b0f5b12a37b150d80e5a45aa4bebcbd","impliedFormat":1},{"version":"385aab901643aa54e1c36f5ef3107913b10d1b5bb8cbcd933d4263b80a0d7f20","impliedFormat":1},{"version":"9670d44354bab9d9982eca21945686b5c24a3f893db73c0dae0fd74217a4c219","impliedFormat":1},{"version":"0b8a9268adaf4da35e7fa830c8981cfa22adbbe5b3f6f5ab91f6658899e657a7","impliedFormat":1},{"version":"11396ed8a44c02ab9798b7dca436009f866e8dae3c9c25e8c1fbc396880bf1bb","impliedFormat":1},{"version":"ba7bc87d01492633cb5a0e5da8a4a42a1c86270e7b3d2dea5d156828a84e4882","impliedFormat":1},{"version":"4893a895ea92c85345017a04ed427cbd6a1710453338df26881a6019432febdd","impliedFormat":1},{"version":"c21dc52e277bcfc75fac0436ccb75c204f9e1b3fa5e12729670910639f27343e","impliedFormat":1},{"version":"13f6f39e12b1518c6650bbb220c8985999020fe0f21d818e28f512b7771d00f9","impliedFormat":1},{"version":"9b5369969f6e7175740bf51223112ff209f94ba43ecd3bb09eefff9fd675624a","impliedFormat":1},{"version":"4fe9e626e7164748e8769bbf74b538e09607f07ed17c2f20af8d680ee49fc1da","impliedFormat":1},{"version":"24515859bc0b836719105bb6cc3d68255042a9f02a6022b3187948b204946bd2","impliedFormat":1},{"version":"ea0148f897b45a76544ae179784c95af1bd6721b8610af9ffa467a518a086a43","impliedFormat":1},{"version":"24c6a117721e606c9984335f71711877293a9651e44f59f3d21c1ea0856f9cc9","impliedFormat":1},{"version":"dd3273ead9fbde62a72949c97dbec2247ea08e0c6952e701a483d74ef92d6a17","impliedFormat":1},{"version":"405822be75ad3e4d162e07439bac80c6bcc6dbae1929e179cf467ec0b9ee4e2e","impliedFormat":1},{"version":"0db18c6e78ea846316c012478888f33c11ffadab9efd1cc8bcc12daded7a60b6","impliedFormat":1},{"version":"4d2b0eb911816f66abe4970898f97a2cfc902bcd743cbfa5017fad79f7ef90d8","impliedFormat":1},{"version":"bd0532fd6556073727d28da0edfd1736417a3f9f394877b6d5ef6ad88fba1d1a","impliedFormat":1},{"version":"89167d696a849fce5ca508032aabfe901c0868f833a8625d5a9c6e861ef935d2","impliedFormat":1},{"version":"e53a3c2a9f624d90f24bf4588aacd223e7bec1b9d0d479b68d2f4a9e6011147f","impliedFormat":1},{"version":"24b8685c62562f5d98615c5a0c1d05f297cf5065f15246edfe99e81ec4c0e011","impliedFormat":1},{"version":"93507c745e8f29090efb99399c3f77bec07db17acd75634249dc92f961573387","impliedFormat":1},{"version":"339dc5265ee5ed92e536a93a04c4ebbc2128f45eeec6ed29f379e0085283542c","impliedFormat":1},{"version":"4732aec92b20fb28c5fe9ad99521fb59974289ed1e45aecb282616202184064f","impliedFormat":1},{"version":"2e85db9e6fd73cfa3d7f28e0ab6b55417ea18931423bd47b409a96e4a169e8e6","impliedFormat":1},{"version":"c46e079fe54c76f95c67fb89081b3e399da2c7d109e7dca8e4b58d83e332e605","impliedFormat":1},{"version":"bf67d53d168abc1298888693338cb82854bdb2e69ef83f8a0092093c2d562107","impliedFormat":1},{"version":"08faa97886e71757779428dd4c69a545c32c85fd629d1116d42710b32c6378bc","affectsGlobalScope":true,"impliedFormat":1},{"version":"6b042aa5d277ad6963e2837179fd2f8fbb01968ac67115b0833c0244e93d1d50","impliedFormat":1},{"version":"7394959e5a741b185456e1ef5d64599c36c60a323207450991e7a42e08911419","impliedFormat":1},{"version":"3d77c73be94570813f8cadd1f05ebc3dc5e2e4fdefe4d340ca20cd018724ee36","impliedFormat":1},{"version":"23cfd70b42094e54cc3c5dab996d81b97e2b6f38ccb24ead85454b8ddfe2fc4f","affectsGlobalScope":true,"impliedFormat":1},{"version":"f3e58c4c18a031cbb17abec7a4ad0bd5ae9fc70c1f4ba1e7fb921ad87c504aca","impliedFormat":1},{"version":"a3e8bafb2af8e850c644f4be7f5156cf7d23b7bfdc3b786bd4d10ed40329649c","impliedFormat":1},{"version":"35ec8b6760fd7138bbf5809b84551e31028fb2ba7b6dc91d95d098bf212ca8b4","affectsGlobalScope":true,"impliedFormat":1},{"version":"5524481e56c48ff486f42926778c0a3cce1cc85dc46683b92b1271865bcf015a","impliedFormat":1},{"version":"4b87f767c7bc841511113c876a6b8bf1fd0cb0b718c888ad84478b372ec486b1","affectsGlobalScope":true,"impliedFormat":1},{"version":"8d04e3640dd9eb67f7f1e5bd3d0bf96c784666f7aefc8ac1537af6f2d38d4c29","impliedFormat":1},{"version":"3c884d9d9ec454bdf0d5a0b8465bf8297d2caa4d853851d92cc417ac6f30b969","impliedFormat":1},{"version":"5a369483ac4cfbdf0331c248deeb36140e6907db5e1daed241546b4a2055f82c","impliedFormat":1},{"version":"e8f5b5cc36615c17d330eaf8eebbc0d6bdd942c25991f96ef122f246f4ff722f","impliedFormat":1},{"version":"f0bd7e6d931657b59605c44112eaf8b980ba7f957a5051ed21cb93d978cf2f45","impliedFormat":1},{"version":"ee1ee365d88c4c6c0c0a5a5701d66ebc27ccd0bcfcfaa482c6e2e7fe7b98edf7","affectsGlobalScope":true,"impliedFormat":1},{"version":"0ada07543808f3b967624645a8e1ccd446f8b01ade47842acf1328aec899fed0","affectsGlobalScope":true,"impliedFormat":1},{"version":"c4a806152acbef81593f96cae6f2b04784d776457d97adbe2694478b243fcf03","impliedFormat":1},{"version":"71adf5dbc59568663d252a46179e71e4d544c053978bfc526d11543a3f716f42","impliedFormat":1},{"version":"c60db41f7bee80fb80c0b12819f5e465c8c8b465578da43e36d04f4a4646f57d","impliedFormat":1},{"version":"93bd413918fa921c8729cef45302b24d8b6c7855d72d5bf82d3972595ae8dcbf","impliedFormat":1},{"version":"4ff41188773cbf465807dd2f7059c7494cbee5115608efc297383832a1150c43","impliedFormat":1},{"version":"dccdf1677e531e33f8ac961a68bc537418c9a414797c1ea7e91307501cdc3f5e","impliedFormat":1},{"version":"e184c4b8918ef56c8c9e68bd79f3f3780e2d0d75bf2b8a41da1509a40c2deb46","affectsGlobalScope":true,"impliedFormat":1},{"version":"d206b4baf4ddcc15d9d69a9a2f4999a72a2c6adeaa8af20fa7a9960816287555","impliedFormat":1},{"version":"93f437e1398a4f06a984f441f7fa7a9f0535c04399619b5c22e0b87bdee182cb","impliedFormat":1},{"version":"afbe24ab0d74694372baa632ecb28bb375be53f3be53f9b07ecd7fc994907de5","impliedFormat":1},{"version":"70731d10d5311bd4cf710ef7f6539b62660f4b0bfdbb3f9fbe1d25fe6366a7fa","affectsGlobalScope":true,"impliedFormat":1},{"version":"6b19db3600a17af69d4f33d08cc7076a7d19fb65bb36e442cac58929ec7c9482","affectsGlobalScope":true,"impliedFormat":1},{"version":"9e043a1bc8fbf2a255bccf9bf27e0f1caf916c3b0518ea34aa72357c0afd42ec","impliedFormat":1},{"version":"137c2894e8f3e9672d401cc0a305dc7b1db7c69511cf6d3970fb53302f9eae09","impliedFormat":1},{"version":"3bc2f1e2c95c04048212c569ed38e338873f6a8593930cf5a7ef24ffb38fc3b6","impliedFormat":1},{"version":"8145e07aad6da5f23f2fcd8c8e4c5c13fb26ee986a79d03b0829b8fce152d8b2","impliedFormat":1},{"version":"f9d9d753d430ed050dc1bf2667a1bab711ccbb1c1507183d794cc195a5b085cc","impliedFormat":1},{"version":"9eece5e586312581ccd106d4853e861aaaa1a39f8e3ea672b8c3847eedd12f6e","impliedFormat":1},{"version":"ba1f814c22fd970255ddd60d61fb7e00c28271c933ab5d5cc19cd3ca66b8f57c","impliedFormat":1},{"version":"37ba7b45141a45ce6e80e66f2a96c8a5ab1bcef0fc2d0f56bb58df96ec67e972","impliedFormat":1},{"version":"93452d394fdd1dc551ec62f5042366f011a00d342d36d50793b3529bfc9bd633","impliedFormat":1},{"version":"295f068af94245ee9d780555351bef98adfd58f8baf0b9dadbc31a489b881f8b","affectsGlobalScope":true,"impliedFormat":1},{"version":"1851a3b4db78664f83901bb9cac9e45e03a37bb5933cc5bf37e10bb7e91ab4eb","impliedFormat":1},{"version":"09d479208911ac3ac6a7c2fe86217fc1abe6c4f04e2d52e4890e500699eeab32","affectsGlobalScope":true,"impliedFormat":1},{"version":"27d8987fd22d92efe6560cf0ce11767bf089903ffe26047727debfd1f3bf438b","affectsGlobalScope":true,"impliedFormat":1},{"version":"578d8bb6dcb2a1c03c4c3f8eb71abc9677e1a5c788b7f24848e3138ce17f3400","impliedFormat":1},{"version":"4f029899f9bae07e225c43aef893590541b2b43267383bf5e32e3a884d219ed5","impliedFormat":1},{"version":"ae56f65caf3be91108707bd8dfbccc2a57a91feb5daabf7165a06a945545ed26","impliedFormat":1},{"version":"a136d5de521da20f31631a0a96bf712370779d1c05b7015d7019a9b2a0446ca9","impliedFormat":1},{"version":"5b566927cad2ed2139655d55d690ffa87df378b956e7fe1c96024c4d9f75c4cf","affectsGlobalScope":true,"impliedFormat":1},{"version":"bce947017cb7a2deebcc4f5ba04cead891ce6ad1602a4438ae45ed9aa1f39104","affectsGlobalScope":true,"impliedFormat":1},{"version":"d3dffd70e6375b872f0b4e152de4ae682d762c61a24881ecc5eb9f04c5caf76f","impliedFormat":1},{"version":"e2c72c065a36bc9ab2a00ac6a6f51e71501619a72c0609defd304d46610487a4","impliedFormat":1},{"version":"d91a7d8b5655c42986f1bdfe2105c4408f472831c8f20cf11a8c3345b6b56c8c","impliedFormat":1},{"version":"616075a6ac578cf5a013ee12964188b4412823796ce0b202c6f1d2e4ca8480d7","affectsGlobalScope":true,"impliedFormat":1},{"version":"e8a979b8af001c9fc2e774e7809d233c8ca955a28756f52ee5dee88ccb0611d2","impliedFormat":1},{"version":"cac793cc47c29e26e4ac3601dcb00b4435ebed26203485790e44f2ad8b6ad847","impliedFormat":1},{"version":"1ba59c8bbeed2cb75b239bb12041582fa3e8ef32f8d0bd0ec802e38442d3f317","impliedFormat":1},"a27b9c06db4bdbf486420142b26cfbbb4cf7d7d1ca34afd11f53b73820b5e1f4","19ed825d72f9bcd25f87c80cc224cd6660be84ba3757903db31d6ab843550574",{"version":"fbce757c3445797cd585740d833c83c4b97ffc87a1000a8501445d5d0392fc0c","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"0819e4227dbcb7ea246672ac6f5ac0a19a84b21122c5705302b5af23e64b620e","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"73ee2ed96707bc00973eed1bd4ed44dc5796946126627af91028adc138358ca9","signature":"8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881"},{"version":"78404ae43e83a27c4e130adce53afa5abd7cb5691c5117650894d68bac772102","affectsGlobalScope":true},"a27b9c06db4bdbf486420142b26cfbbb4cf7d7d1ca34afd11f53b73820b5e1f4","19ed825d72f9bcd25f87c80cc224cd6660be84ba3757903db31d6ab843550574","fc610cccc68c9fb7986ac8db1b54981208232898f18edb00531a8e7e3df3a36c","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881","8e609bb71c20b858c77f0e9f90bb1319db8477b13f9f965f1a1e18524bf50881",{"version":"8d27e5f73b75340198b2df36f39326f693743e64006bd7b88a925a5f285df628","impliedFormat":1},{"version":"2c8e55457aaf4902941dfdba4061935922e8ee6e120539c9801cd7b400fae050","impliedFormat":1},{"version":"1c2cd862994b1fbed3cde0d1e8de47835ff112d197a3debfddf7b2ee3b2c52bc","impliedFormat":1},{"version":"670a76db379b27c8ff42f1ba927828a22862e2ab0b0908e38b671f0e912cc5ed","impliedFormat":1},{"version":"9e0cf651e8e2c5b9bebbabdff2f7c6f8cedd91b1d9afcc0a854cdff053a88f1b","impliedFormat":1},{"version":"069bebfee29864e3955378107e243508b163e77ab10de6a5ee03ae06939f0bb9","impliedFormat":1},{"version":"104c67f0da1bdf0d94865419247e20eded83ce7f9911a1aa75fc675c077ca66e","impliedFormat":1},{"version":"cc0d0b339f31ce0ab3b7a5b714d8e578ce698f1e13d7f8c60bfb766baeb1d35c","impliedFormat":1},{"version":"d3f2d715f57df3f04bf7b16dde01dec10366f64fce44503c92b8f78f614c1769","impliedFormat":1},{"version":"b78cd10245a90e27e62d0558564f5d9a16576294eee724a59ae21b91f9269e4a","impliedFormat":1},{"version":"936eb43a381712a8ec1249f2afc819f6fc7ca68f10dfec71762b428dfdc53bf1","impliedFormat":1},{"version":"2f5747b1508ccf83fad0c251ba1e5da2f5a30b78b09ffa1cfaf633045160afed","impliedFormat":1},{"version":"a45c25e77c911c1f2a04cade78f6f42b4d7d896a3882d4e226efd3a3fcd5f2c4","affectsGlobalScope":true,"impliedFormat":1},{"version":"b71c603a539078a5e3a039b20f2b0a0d1708967530cf97dec8850a9ca45baa2b","impliedFormat":1},{"version":"0e13570a7e86c6d83dd92e81758a930f63747483e2cd34ef36fcdb47d1f9726a","impliedFormat":1},{"version":"5c45abf1e13e4463eacfd5dedda06855da8748a6a6cb3334f582b52e219acc04","impliedFormat":1},{"version":"afe73051ff6a03a9565cbd8ebb0e956ee3df5e913ad5c1ded64218aabfa3dcb5","impliedFormat":1},{"version":"035a5df183489c2e22f3cf59fc1ed2b043d27f357eecc0eb8d8e840059d44245","impliedFormat":1},{"version":"a4809f4d92317535e6b22b01019437030077a76fec1d93b9881c9ed4738fcc54","impliedFormat":1},{"version":"5f53fa0bd22096d2a78533f94e02c899143b8f0f9891a46965294ee8b91a9434","impliedFormat":1},{"version":"cdcc132f207d097d7d3aa75615ab9a2e71d6a478162dde8b67f88ea19f3e54de","impliedFormat":1},{"version":"0d14fa22c41fdc7277e6f71473b20ebc07f40f00e38875142335d5b63cdfc9d2","impliedFormat":1},{"version":"c085e9aa62d1ae1375794c1fb927a445fa105fed891a7e24edbb1c3300f7384a","impliedFormat":1},{"version":"f315e1e65a1f80992f0509e84e4ae2df15ecd9ef73df975f7c98813b71e4c8da","impliedFormat":1},{"version":"5b9586e9b0b6322e5bfbd2c29bd3b8e21ab9d871f82346cb71020e3d84bae73e","impliedFormat":1},{"version":"3e70a7e67c2cb16f8cd49097360c0309fe9d1e3210ff9222e9dac1f8df9d4fb6","impliedFormat":1},{"version":"ab68d2a3e3e8767c3fba8f80de099a1cfc18c0de79e42cb02ae66e22dfe14a66","impliedFormat":1},{"version":"d96cc6598148bf1a98fb2e8dcf01c63a4b3558bdaec6ef35e087fd0562eb40ec","impliedFormat":1},{"version":"f8db4fea512ab759b2223b90ecbbe7dae919c02f8ce95ec03f7fb1cf757cfbeb","affectsGlobalScope":true,"impliedFormat":1},{"version":"ab82804a14454734010dcdcd43f564ff7b0389bee4c5692eec76ff5b30d4cf66","impliedFormat":1},{"version":"bae8d023ef6b23df7da26f51cea44321f95817c190342a36882e93b80d07a960","impliedFormat":1},{"version":"26a770cec4bd2e7dbba95c6e536390fffe83c6268b78974a93727903b515c4e7","impliedFormat":1}],"root":[[153,162]],"options":{"composite":true,"declaration":true,"emitDecoratorMetadata":true,"esModuleInterop":true,"experimentalDecorators":true,"module":1,"outDir":"./","rootDir":"..","skipLibCheck":true,"sourceMap":true,"strict":true,"target":5},"referencedMap":[[165,1],[163,2],[183,2],[186,3],[185,2],[168,4],[164,1],[166,5],[167,1],[170,6],[169,7],[175,8],[178,9],[179,10],[176,2],[180,2],[181,11],[182,12],[191,13],[171,2],[97,14],[98,14],[99,15],[58,16],[100,17],[101,18],[102,19],[53,2],[56,20],[54,2],[55,2],[103,21],[104,22],[105,23],[106,24],[107,25],[108,26],[109,26],[111,27],[110,28],[112,29],[113,30],[114,31],[96,32],[57,2],[115,33],[116,34],[117,35],[149,36],[118,37],[119,38],[120,39],[121,40],[122,41],[123,42],[124,43],[125,44],[126,45],[127,46],[128,46],[129,47],[130,2],[131,48],[133,49],[132,50],[134,51],[135,52],[136,53],[137,54],[138,55],[139,56],[140,57],[141,58],[142,59],[143,60],[144,61],[145,62],[146,63],[147,64],[148,65],[173,2],[174,2],[172,66],[177,67],[192,2],[150,68],[193,2],[194,69],[184,2],[190,70],[188,71],[189,72],[187,73],[49,2],[50,2],[10,2],[8,2],[9,2],[14,2],[13,2],[2,2],[15,2],[16,2],[17,2],[18,2],[19,2],[20,2],[21,2],[22,2],[3,2],[23,2],[24,2],[4,2],[25,2],[29,2],[26,2],[27,2],[28,2],[30,2],[31,2],[32,2],[5,2],[51,2],[33,2],[34,2],[35,2],[36,2],[6,2],[40,2],[37,2],[38,2],[39,2],[41,2],[7,2],[42,2],[47,2],[48,2],[43,2],[44,2],[45,2],[46,2],[1,2],[12,2],[11,2],[74,74],[84,75],[73,74],[94,76],[65,77],[64,78],[93,79],[87,80],[92,81],[67,82],[81,83],[66,84],[90,85],[62,86],[61,79],[91,87],[63,88],[68,89],[69,2],[72,89],[59,2],[95,90],[85,91],[76,92],[77,93],[79,94],[75,95],[78,96],[88,79],[70,97],[71,98],[80,99],[60,100],[83,91],[82,89],[86,2],[89,101],[152,102],[151,103],[52,2],[153,104],[154,105],[158,106],[159,107],[157,108],[156,2],[160,2],[161,2],[162,2],[155,109]],"semanticDiagnosticsPerFile":[52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194],"latestChangedDtsFile":"./src/index.d.ts","version":"5.8.2"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { test, describe } from 'node:test';
|
|
2
|
+
import assert from 'node:assert';
|
|
3
|
+
import { UsageFlowError, Route, RequestMetadata, UsageFlowConfig } from '../src/types';
|
|
4
|
+
|
|
5
|
+
describe('Types', () => {
|
|
6
|
+
test('UsageFlowError should extend Error', () => {
|
|
7
|
+
const error = new UsageFlowError('Test error');
|
|
8
|
+
assert.ok(error instanceof Error);
|
|
9
|
+
assert.strictEqual(error.name, 'UsageFlowError');
|
|
10
|
+
assert.strictEqual(error.message, 'Test error');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
test('Route interface should have method and url', () => {
|
|
14
|
+
const route: Route = {
|
|
15
|
+
method: 'GET',
|
|
16
|
+
url: '/users'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
assert.strictEqual(route.method, 'GET');
|
|
20
|
+
assert.strictEqual(route.url, '/users');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('RequestMetadata should have required fields', () => {
|
|
24
|
+
const metadata: RequestMetadata = {
|
|
25
|
+
method: 'GET',
|
|
26
|
+
url: '/users',
|
|
27
|
+
rawUrl: '/users?page=1',
|
|
28
|
+
clientIP: '127.0.0.1',
|
|
29
|
+
userAgent: 'test-agent',
|
|
30
|
+
timestamp: new Date().toISOString(),
|
|
31
|
+
headers: {},
|
|
32
|
+
queryParams: { page: '1' },
|
|
33
|
+
pathParams: null,
|
|
34
|
+
requestDuration: 100
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
assert.strictEqual(metadata.method, 'GET');
|
|
38
|
+
assert.strictEqual(metadata.url, '/users');
|
|
39
|
+
assert.strictEqual(metadata.clientIP, '127.0.0.1');
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
test('UsageFlowConfig should have required fields', () => {
|
|
43
|
+
const config: UsageFlowConfig = {
|
|
44
|
+
url: '/users/:id',
|
|
45
|
+
method: 'GET',
|
|
46
|
+
identityFieldName: 'id',
|
|
47
|
+
identityFieldLocation: 'path_params'
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
assert.strictEqual(config.url, '/users/:id');
|
|
51
|
+
assert.strictEqual(config.method, 'GET');
|
|
52
|
+
assert.strictEqual(config.identityFieldName, 'id');
|
|
53
|
+
assert.strictEqual(config.identityFieldLocation, 'path_params');
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
|
package/tsconfig.json
CHANGED