balda 0.0.11 → 0.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/index.cjs +44 -44
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +60 -58
- package/lib/index.d.ts +60 -58
- package/lib/index.js +44 -44
- package/lib/index.js.map +1 -1
- package/package.json +1 -1
package/lib/index.d.cts
CHANGED
|
@@ -974,64 +974,6 @@ declare class GraphQL {
|
|
|
974
974
|
private ensureTypeDefsArray;
|
|
975
975
|
}
|
|
976
976
|
|
|
977
|
-
declare class MockResponse<T = any> {
|
|
978
|
-
private readonly response;
|
|
979
|
-
constructor(response: Response$1);
|
|
980
|
-
body(): T;
|
|
981
|
-
statusCode(): number;
|
|
982
|
-
headers(): Record<string, string>;
|
|
983
|
-
assertStatus(status: number): this;
|
|
984
|
-
assertHeader(header: string, value: string): this;
|
|
985
|
-
assertHeaderExists(header: string): this;
|
|
986
|
-
assertHeaderNotExists(header: string): this;
|
|
987
|
-
assertBodySubset(subset: Partial<T>): this;
|
|
988
|
-
assertBodyDeepEqual(expected: T): this;
|
|
989
|
-
assertBodyNotSubset(subset: Partial<T>): this;
|
|
990
|
-
assertBodyNotDeepEqual(expected: T): this;
|
|
991
|
-
assertCustom(assertion: (response: Response$1) => void): this;
|
|
992
|
-
private assertSubset;
|
|
993
|
-
private assertDeepEqual;
|
|
994
|
-
private assertNotSubset;
|
|
995
|
-
private assertNotDeepEqual;
|
|
996
|
-
private assertArraySubset;
|
|
997
|
-
private assertArrayDeepEqual;
|
|
998
|
-
private isObject;
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
/**
|
|
1002
|
-
* The options for the mock server, only one of body, formData, urlencoded can be provided
|
|
1003
|
-
*/
|
|
1004
|
-
interface MockServerOptions {
|
|
1005
|
-
/**
|
|
1006
|
-
* The body of the request, if formData is provided, it will be ignored
|
|
1007
|
-
*/
|
|
1008
|
-
body?: any;
|
|
1009
|
-
/**
|
|
1010
|
-
* The form data of the request
|
|
1011
|
-
*/
|
|
1012
|
-
formData?: FormData;
|
|
1013
|
-
/**
|
|
1014
|
-
* The urlencoded body of the request
|
|
1015
|
-
*/
|
|
1016
|
-
urlencoded?: Record<string, string>;
|
|
1017
|
-
/**
|
|
1018
|
-
* The headers of the request
|
|
1019
|
-
*/
|
|
1020
|
-
headers?: Record<string, string>;
|
|
1021
|
-
/**
|
|
1022
|
-
* The query parameters of the request, if provided, they will be merged with the query parameters from the path (precedence is given to the query parameters provided here)
|
|
1023
|
-
*/
|
|
1024
|
-
query?: Record<string, string>;
|
|
1025
|
-
/**
|
|
1026
|
-
* The cookies of the request
|
|
1027
|
-
*/
|
|
1028
|
-
cookies?: Record<string, string>;
|
|
1029
|
-
/**
|
|
1030
|
-
* The ip of the request
|
|
1031
|
-
*/
|
|
1032
|
-
ip?: string;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
977
|
/**
|
|
1036
978
|
* Singleton that handles the routing of requests to the appropriate handler(s).
|
|
1037
979
|
*/
|
|
@@ -1040,6 +982,7 @@ declare class Router {
|
|
|
1040
982
|
private routes;
|
|
1041
983
|
private middlewares;
|
|
1042
984
|
private basePath;
|
|
985
|
+
private staticRouteCache;
|
|
1043
986
|
/**
|
|
1044
987
|
* Create a new router with an optional base path and default middlewares.
|
|
1045
988
|
* Base path is normalized so it never produces duplicate slashes and never ends with a trailing slash (except root).
|
|
@@ -1055,6 +998,7 @@ declare class Router {
|
|
|
1055
998
|
/**
|
|
1056
999
|
* Find the matching route for the given HTTP method and path.
|
|
1057
1000
|
* Returns the resolved middleware chain, handler, and extracted params; or null if not found.
|
|
1001
|
+
* Uses O(1) cache lookup for static routes, falls back to O(k) tree traversal for dynamic routes.
|
|
1058
1002
|
*/
|
|
1059
1003
|
find(method: string, rawPath: string): {
|
|
1060
1004
|
middleware: ServerRouteMiddleware[];
|
|
@@ -1229,6 +1173,64 @@ declare class Server<H extends NodeHttpClient = NodeHttpClient> implements Serve
|
|
|
1229
1173
|
private registerNotFoundRoutes;
|
|
1230
1174
|
}
|
|
1231
1175
|
|
|
1176
|
+
declare class MockResponse<T = any> {
|
|
1177
|
+
private readonly response;
|
|
1178
|
+
constructor(response: Response$1);
|
|
1179
|
+
body(): T;
|
|
1180
|
+
statusCode(): number;
|
|
1181
|
+
headers(): Record<string, string>;
|
|
1182
|
+
assertStatus(status: number): this;
|
|
1183
|
+
assertHeader(header: string, value: string): this;
|
|
1184
|
+
assertHeaderExists(header: string): this;
|
|
1185
|
+
assertHeaderNotExists(header: string): this;
|
|
1186
|
+
assertBodySubset(subset: Partial<T>): this;
|
|
1187
|
+
assertBodyDeepEqual(expected: T): this;
|
|
1188
|
+
assertBodyNotSubset(subset: Partial<T>): this;
|
|
1189
|
+
assertBodyNotDeepEqual(expected: T): this;
|
|
1190
|
+
assertCustom(assertion: (response: Response$1) => void): this;
|
|
1191
|
+
private assertSubset;
|
|
1192
|
+
private assertDeepEqual;
|
|
1193
|
+
private assertNotSubset;
|
|
1194
|
+
private assertNotDeepEqual;
|
|
1195
|
+
private assertArraySubset;
|
|
1196
|
+
private assertArrayDeepEqual;
|
|
1197
|
+
private isObject;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
/**
|
|
1201
|
+
* The options for the mock server, only one of body, formData, urlencoded can be provided
|
|
1202
|
+
*/
|
|
1203
|
+
interface MockServerOptions {
|
|
1204
|
+
/**
|
|
1205
|
+
* The body of the request, if formData is provided, it will be ignored
|
|
1206
|
+
*/
|
|
1207
|
+
body?: any;
|
|
1208
|
+
/**
|
|
1209
|
+
* The form data of the request
|
|
1210
|
+
*/
|
|
1211
|
+
formData?: FormData;
|
|
1212
|
+
/**
|
|
1213
|
+
* The urlencoded body of the request
|
|
1214
|
+
*/
|
|
1215
|
+
urlencoded?: Record<string, string>;
|
|
1216
|
+
/**
|
|
1217
|
+
* The headers of the request
|
|
1218
|
+
*/
|
|
1219
|
+
headers?: Record<string, string>;
|
|
1220
|
+
/**
|
|
1221
|
+
* The query parameters of the request, if provided, they will be merged with the query parameters from the path (precedence is given to the query parameters provided here)
|
|
1222
|
+
*/
|
|
1223
|
+
query?: Record<string, string>;
|
|
1224
|
+
/**
|
|
1225
|
+
* The cookies of the request
|
|
1226
|
+
*/
|
|
1227
|
+
cookies?: Record<string, string>;
|
|
1228
|
+
/**
|
|
1229
|
+
* The ip of the request
|
|
1230
|
+
*/
|
|
1231
|
+
ip?: string;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1232
1234
|
/**
|
|
1233
1235
|
* Allows to mock server requests without needing to start the server, useful for testing purposes
|
|
1234
1236
|
*/
|
package/lib/index.d.ts
CHANGED
|
@@ -974,64 +974,6 @@ declare class GraphQL {
|
|
|
974
974
|
private ensureTypeDefsArray;
|
|
975
975
|
}
|
|
976
976
|
|
|
977
|
-
declare class MockResponse<T = any> {
|
|
978
|
-
private readonly response;
|
|
979
|
-
constructor(response: Response$1);
|
|
980
|
-
body(): T;
|
|
981
|
-
statusCode(): number;
|
|
982
|
-
headers(): Record<string, string>;
|
|
983
|
-
assertStatus(status: number): this;
|
|
984
|
-
assertHeader(header: string, value: string): this;
|
|
985
|
-
assertHeaderExists(header: string): this;
|
|
986
|
-
assertHeaderNotExists(header: string): this;
|
|
987
|
-
assertBodySubset(subset: Partial<T>): this;
|
|
988
|
-
assertBodyDeepEqual(expected: T): this;
|
|
989
|
-
assertBodyNotSubset(subset: Partial<T>): this;
|
|
990
|
-
assertBodyNotDeepEqual(expected: T): this;
|
|
991
|
-
assertCustom(assertion: (response: Response$1) => void): this;
|
|
992
|
-
private assertSubset;
|
|
993
|
-
private assertDeepEqual;
|
|
994
|
-
private assertNotSubset;
|
|
995
|
-
private assertNotDeepEqual;
|
|
996
|
-
private assertArraySubset;
|
|
997
|
-
private assertArrayDeepEqual;
|
|
998
|
-
private isObject;
|
|
999
|
-
}
|
|
1000
|
-
|
|
1001
|
-
/**
|
|
1002
|
-
* The options for the mock server, only one of body, formData, urlencoded can be provided
|
|
1003
|
-
*/
|
|
1004
|
-
interface MockServerOptions {
|
|
1005
|
-
/**
|
|
1006
|
-
* The body of the request, if formData is provided, it will be ignored
|
|
1007
|
-
*/
|
|
1008
|
-
body?: any;
|
|
1009
|
-
/**
|
|
1010
|
-
* The form data of the request
|
|
1011
|
-
*/
|
|
1012
|
-
formData?: FormData;
|
|
1013
|
-
/**
|
|
1014
|
-
* The urlencoded body of the request
|
|
1015
|
-
*/
|
|
1016
|
-
urlencoded?: Record<string, string>;
|
|
1017
|
-
/**
|
|
1018
|
-
* The headers of the request
|
|
1019
|
-
*/
|
|
1020
|
-
headers?: Record<string, string>;
|
|
1021
|
-
/**
|
|
1022
|
-
* The query parameters of the request, if provided, they will be merged with the query parameters from the path (precedence is given to the query parameters provided here)
|
|
1023
|
-
*/
|
|
1024
|
-
query?: Record<string, string>;
|
|
1025
|
-
/**
|
|
1026
|
-
* The cookies of the request
|
|
1027
|
-
*/
|
|
1028
|
-
cookies?: Record<string, string>;
|
|
1029
|
-
/**
|
|
1030
|
-
* The ip of the request
|
|
1031
|
-
*/
|
|
1032
|
-
ip?: string;
|
|
1033
|
-
}
|
|
1034
|
-
|
|
1035
977
|
/**
|
|
1036
978
|
* Singleton that handles the routing of requests to the appropriate handler(s).
|
|
1037
979
|
*/
|
|
@@ -1040,6 +982,7 @@ declare class Router {
|
|
|
1040
982
|
private routes;
|
|
1041
983
|
private middlewares;
|
|
1042
984
|
private basePath;
|
|
985
|
+
private staticRouteCache;
|
|
1043
986
|
/**
|
|
1044
987
|
* Create a new router with an optional base path and default middlewares.
|
|
1045
988
|
* Base path is normalized so it never produces duplicate slashes and never ends with a trailing slash (except root).
|
|
@@ -1055,6 +998,7 @@ declare class Router {
|
|
|
1055
998
|
/**
|
|
1056
999
|
* Find the matching route for the given HTTP method and path.
|
|
1057
1000
|
* Returns the resolved middleware chain, handler, and extracted params; or null if not found.
|
|
1001
|
+
* Uses O(1) cache lookup for static routes, falls back to O(k) tree traversal for dynamic routes.
|
|
1058
1002
|
*/
|
|
1059
1003
|
find(method: string, rawPath: string): {
|
|
1060
1004
|
middleware: ServerRouteMiddleware[];
|
|
@@ -1229,6 +1173,64 @@ declare class Server<H extends NodeHttpClient = NodeHttpClient> implements Serve
|
|
|
1229
1173
|
private registerNotFoundRoutes;
|
|
1230
1174
|
}
|
|
1231
1175
|
|
|
1176
|
+
declare class MockResponse<T = any> {
|
|
1177
|
+
private readonly response;
|
|
1178
|
+
constructor(response: Response$1);
|
|
1179
|
+
body(): T;
|
|
1180
|
+
statusCode(): number;
|
|
1181
|
+
headers(): Record<string, string>;
|
|
1182
|
+
assertStatus(status: number): this;
|
|
1183
|
+
assertHeader(header: string, value: string): this;
|
|
1184
|
+
assertHeaderExists(header: string): this;
|
|
1185
|
+
assertHeaderNotExists(header: string): this;
|
|
1186
|
+
assertBodySubset(subset: Partial<T>): this;
|
|
1187
|
+
assertBodyDeepEqual(expected: T): this;
|
|
1188
|
+
assertBodyNotSubset(subset: Partial<T>): this;
|
|
1189
|
+
assertBodyNotDeepEqual(expected: T): this;
|
|
1190
|
+
assertCustom(assertion: (response: Response$1) => void): this;
|
|
1191
|
+
private assertSubset;
|
|
1192
|
+
private assertDeepEqual;
|
|
1193
|
+
private assertNotSubset;
|
|
1194
|
+
private assertNotDeepEqual;
|
|
1195
|
+
private assertArraySubset;
|
|
1196
|
+
private assertArrayDeepEqual;
|
|
1197
|
+
private isObject;
|
|
1198
|
+
}
|
|
1199
|
+
|
|
1200
|
+
/**
|
|
1201
|
+
* The options for the mock server, only one of body, formData, urlencoded can be provided
|
|
1202
|
+
*/
|
|
1203
|
+
interface MockServerOptions {
|
|
1204
|
+
/**
|
|
1205
|
+
* The body of the request, if formData is provided, it will be ignored
|
|
1206
|
+
*/
|
|
1207
|
+
body?: any;
|
|
1208
|
+
/**
|
|
1209
|
+
* The form data of the request
|
|
1210
|
+
*/
|
|
1211
|
+
formData?: FormData;
|
|
1212
|
+
/**
|
|
1213
|
+
* The urlencoded body of the request
|
|
1214
|
+
*/
|
|
1215
|
+
urlencoded?: Record<string, string>;
|
|
1216
|
+
/**
|
|
1217
|
+
* The headers of the request
|
|
1218
|
+
*/
|
|
1219
|
+
headers?: Record<string, string>;
|
|
1220
|
+
/**
|
|
1221
|
+
* The query parameters of the request, if provided, they will be merged with the query parameters from the path (precedence is given to the query parameters provided here)
|
|
1222
|
+
*/
|
|
1223
|
+
query?: Record<string, string>;
|
|
1224
|
+
/**
|
|
1225
|
+
* The cookies of the request
|
|
1226
|
+
*/
|
|
1227
|
+
cookies?: Record<string, string>;
|
|
1228
|
+
/**
|
|
1229
|
+
* The ip of the request
|
|
1230
|
+
*/
|
|
1231
|
+
ip?: string;
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1232
1234
|
/**
|
|
1233
1235
|
* Allows to mock server requests without needing to start the server, useful for testing purposes
|
|
1234
1236
|
*/
|