@c9up/ream 0.1.26 → 0.1.28
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 +65 -0
- package/dist/Ignitor.d.ts +115 -7
- package/dist/Ignitor.d.ts.map +1 -1
- package/dist/Ignitor.js +233 -37
- package/dist/Ignitor.js.map +1 -1
- package/dist/console/BaseCommand.d.ts +217 -0
- package/dist/console/BaseCommand.d.ts.map +1 -0
- package/dist/console/BaseCommand.js +340 -0
- package/dist/console/BaseCommand.js.map +1 -0
- package/dist/console/Console.d.ts +86 -0
- package/dist/console/Console.d.ts.map +1 -0
- package/dist/console/Console.js +134 -0
- package/dist/console/Console.js.map +1 -0
- package/dist/console/ExceptionHandler.d.ts +28 -0
- package/dist/console/ExceptionHandler.d.ts.map +1 -0
- package/dist/console/ExceptionHandler.js +76 -0
- package/dist/console/ExceptionHandler.js.map +1 -0
- package/dist/console/HelpCommand.d.ts +16 -0
- package/dist/console/HelpCommand.d.ts.map +1 -0
- package/dist/console/HelpCommand.js +40 -0
- package/dist/console/HelpCommand.js.map +1 -0
- package/dist/console/IndexGenerator.d.ts +24 -0
- package/dist/console/IndexGenerator.d.ts.map +1 -0
- package/dist/console/IndexGenerator.js +65 -0
- package/dist/console/IndexGenerator.js.map +1 -0
- package/dist/console/Kernel.d.ts +298 -0
- package/dist/console/Kernel.d.ts.map +1 -0
- package/dist/console/Kernel.js +1120 -0
- package/dist/console/Kernel.js.map +1 -0
- package/dist/console/ListCommand.d.ts +18 -0
- package/dist/console/ListCommand.d.ts.map +1 -0
- package/dist/console/ListCommand.js +60 -0
- package/dist/console/ListCommand.js.map +1 -0
- package/dist/console/assertions.d.ts +20 -0
- package/dist/console/assertions.d.ts.map +1 -0
- package/dist/console/assertions.js +84 -0
- package/dist/console/assertions.js.map +1 -0
- package/dist/console/cliui.d.ts +248 -0
- package/dist/console/cliui.d.ts.map +1 -0
- package/dist/console/cliui.js +587 -0
- package/dist/console/cliui.js.map +1 -0
- package/dist/console/decorators.d.ts +90 -0
- package/dist/console/decorators.d.ts.map +1 -0
- package/dist/console/decorators.js +142 -0
- package/dist/console/decorators.js.map +1 -0
- package/dist/console/index.d.ts +32 -0
- package/dist/console/index.d.ts.map +1 -0
- package/dist/console/index.js +24 -0
- package/dist/console/index.js.map +1 -0
- package/dist/console/loaders.d.ts +52 -0
- package/dist/console/loaders.d.ts.map +1 -0
- package/dist/console/loaders.js +131 -0
- package/dist/console/loaders.js.map +1 -0
- package/dist/console/parser.d.ts +86 -0
- package/dist/console/parser.d.ts.map +1 -0
- package/dist/console/parser.js +440 -0
- package/dist/console/parser.js.map +1 -0
- package/dist/console/prompts.d.ts +124 -0
- package/dist/console/prompts.d.ts.map +1 -0
- package/dist/console/prompts.js +364 -0
- package/dist/console/prompts.js.map +1 -0
- package/dist/console/tracing.d.ts +17 -0
- package/dist/console/tracing.d.ts.map +1 -0
- package/dist/console/tracing.js +11 -0
- package/dist/console/tracing.js.map +1 -0
- package/dist/console/types.d.ts +255 -0
- package/dist/console/types.d.ts.map +1 -0
- package/dist/console/types.js +25 -0
- package/dist/console/types.js.map +1 -0
- package/dist/console/ui.d.ts +20 -0
- package/dist/console/ui.d.ts.map +1 -0
- package/dist/console/ui.js +31 -0
- package/dist/console/ui.js.map +1 -0
- package/dist/console/utils.d.ts +27 -0
- package/dist/console/utils.d.ts.map +1 -0
- package/dist/console/utils.js +56 -0
- package/dist/console/utils.js.map +1 -0
- package/dist/container/Container.d.ts.map +1 -1
- package/dist/container/Container.js +40 -12
- package/dist/container/Container.js.map +1 -1
- package/dist/container/types.d.ts +14 -2
- package/dist/container/types.d.ts.map +1 -1
- package/dist/decorators/Service.d.ts +7 -0
- package/dist/decorators/Service.d.ts.map +1 -1
- package/dist/decorators/Service.js +23 -3
- package/dist/decorators/Service.js.map +1 -1
- package/dist/errors/ReamError.d.ts +25 -0
- package/dist/errors/ReamError.d.ts.map +1 -1
- package/dist/errors/ReamError.js +5 -0
- package/dist/errors/ReamError.js.map +1 -1
- package/dist/errors/prettyPrintError.d.ts +9 -0
- package/dist/errors/prettyPrintError.d.ts.map +1 -0
- package/dist/errors/prettyPrintError.js +22 -0
- package/dist/errors/prettyPrintError.js.map +1 -0
- package/dist/index.d.ts +14 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +16 -2
- package/dist/index.js.map +1 -1
- package/dist/middleware/Pipeline.d.ts +29 -8
- package/dist/middleware/Pipeline.d.ts.map +1 -1
- package/dist/middleware/Pipeline.js +39 -1
- package/dist/middleware/Pipeline.js.map +1 -1
- package/dist/rpc/RpcRouter.d.ts.map +1 -1
- package/dist/rpc/RpcRouter.js +13 -2
- package/dist/rpc/RpcRouter.js.map +1 -1
- package/dist/services/app.d.ts +1 -1
- package/dist/services/app.js +1 -1
- package/dist/services/console.d.ts +21 -0
- package/dist/services/console.d.ts.map +1 -0
- package/dist/services/console.js +35 -0
- package/dist/services/console.js.map +1 -0
- package/dist/testing/ApiResponse.d.ts +218 -0
- package/dist/testing/ApiResponse.d.ts.map +1 -0
- package/dist/testing/ApiResponse.js +576 -0
- package/dist/testing/ApiResponse.js.map +1 -0
- package/dist/testing/RequestBuilder.d.ts +132 -72
- package/dist/testing/RequestBuilder.d.ts.map +1 -1
- package/dist/testing/RequestBuilder.js +389 -222
- package/dist/testing/RequestBuilder.js.map +1 -1
- package/dist/testing/TestClient.d.ts +34 -39
- package/dist/testing/TestClient.d.ts.map +1 -1
- package/dist/testing/TestClient.js +48 -56
- package/dist/testing/TestClient.js.map +1 -1
- package/dist/utils/Macroable.js +3 -3
- package/dist/utils/Macroable.js.map +1 -1
- package/events.darwin-arm64.node +0 -0
- package/events.darwin-x64.node +0 -0
- package/events.linux-arm64-gnu.node +0 -0
- package/events.linux-x64-gnu.node +0 -0
- package/events.win32-x64-msvc.node +0 -0
- package/index.darwin-arm64.node +0 -0
- package/index.darwin-x64.node +0 -0
- package/index.linux-arm64-gnu.node +0 -0
- package/index.linux-x64-gnu.node +0 -0
- package/index.win32-x64-msvc.node +0 -0
- package/package.json +15 -2
- package/scheduler.darwin-arm64.node +0 -0
- package/scheduler.darwin-x64.node +0 -0
- package/scheduler.linux-arm64-gnu.node +0 -0
- package/scheduler.linux-x64-gnu.node +0 -0
- package/scheduler.win32-x64-msvc.node +0 -0
- package/src/Ignitor.ts +340 -42
- package/src/console/BaseCommand.ts +467 -0
- package/src/console/Console.ts +174 -0
- package/src/console/ExceptionHandler.ts +91 -0
- package/src/console/HelpCommand.ts +37 -0
- package/src/console/IndexGenerator.ts +79 -0
- package/src/console/Kernel.ts +1382 -0
- package/src/console/ListCommand.ts +55 -0
- package/src/console/assertions.ts +114 -0
- package/src/console/cliui.ts +756 -0
- package/src/console/decorators.ts +199 -0
- package/src/console/index.ts +67 -0
- package/src/console/loaders.ts +145 -0
- package/src/console/parser.ts +598 -0
- package/src/console/prompts.ts +556 -0
- package/src/console/tracing.ts +22 -0
- package/src/console/types.ts +280 -0
- package/src/console/ui.ts +37 -0
- package/src/console/utils.ts +69 -0
- package/src/container/Container.ts +55 -13
- package/src/container/types.ts +15 -2
- package/src/decorators/Service.ts +28 -3
- package/src/errors/ReamError.ts +31 -0
- package/src/errors/prettyPrintError.ts +20 -0
- package/src/index.ts +30 -4
- package/src/middleware/Pipeline.ts +76 -5
- package/src/rpc/RpcRouter.ts +16 -2
- package/src/services/app.ts +1 -1
- package/src/services/console.ts +42 -0
- package/src/testing/ApiResponse.ts +691 -0
- package/src/testing/RequestBuilder.ts +498 -275
- package/src/testing/TestClient.ts +63 -86
- package/src/utils/Macroable.ts +3 -3
- package/dist/console/CommandRunner.d.ts +0 -18
- package/dist/console/CommandRunner.d.ts.map +0 -1
- package/dist/console/CommandRunner.js +0 -65
- package/dist/console/CommandRunner.js.map +0 -1
- package/src/console/CommandRunner.ts +0 -82
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Console singleton service.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* import consoleApp from '@c9up/ream/services/console'
|
|
6
|
+
* if (await consoleApp.hasCommand('make:controller')) {
|
|
7
|
+
* const command = await consoleApp.exec('make:controller', ['user', '--resource'])
|
|
8
|
+
* }
|
|
9
|
+
*/
|
|
10
|
+
let instance;
|
|
11
|
+
/** @internal Set the consoleApp instance (called by Ignitor). */
|
|
12
|
+
export function setConsole(consoleApp) {
|
|
13
|
+
instance = consoleApp;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* @internal Unset the locator IF it still points at `consoleApp` (called by
|
|
17
|
+
* Ignitor.stop()) — same ownership guard as the app service: a second Ignitor
|
|
18
|
+
* rebinding the locator must not be torn down by the first one stopping.
|
|
19
|
+
*/
|
|
20
|
+
export function clearConsole(consoleApp) {
|
|
21
|
+
if (instance === consoleApp)
|
|
22
|
+
instance = undefined;
|
|
23
|
+
}
|
|
24
|
+
const consoleApp = new Proxy({}, {
|
|
25
|
+
get(_target, prop) {
|
|
26
|
+
if (!instance) {
|
|
27
|
+
throw new Error('Console accessed before initialization. ' +
|
|
28
|
+
'Ensure this code runs during or after the boot phase.');
|
|
29
|
+
}
|
|
30
|
+
const value = Reflect.get(instance, prop, instance);
|
|
31
|
+
return typeof value === 'function' ? value.bind(instance) : value;
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
export default consoleApp;
|
|
35
|
+
//# sourceMappingURL=console.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"console.js","sourceRoot":"","sources":["../../src/services/console.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH,IAAI,QAA6B,CAAA;AAEjC,iEAAiE;AACjE,MAAM,UAAU,UAAU,CAAC,UAAmB;IAC5C,QAAQ,GAAG,UAAU,CAAA;AACvB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAAC,UAAmB;IAC9C,IAAI,QAAQ,KAAK,UAAU;QAAE,QAAQ,GAAG,SAAS,CAAA;AACnD,CAAC;AAED,MAAM,UAAU,GAAY,IAAI,KAAK,CAAC,EAAa,EAAE;IACnD,GAAG,CAAC,OAAO,EAAE,IAAI;QACf,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CACb,0CAA0C;gBACxC,uDAAuD,CAC1D,CAAA;QACH,CAAC;QACD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAA;QACnD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,KAAK,CAAA;IACnE,CAAC;CACF,CAAC,CAAA;AAEF,eAAe,UAAU,CAAA"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rich HTTP test response — `@japa/api-client`'s `ApiResponse` parity.
|
|
3
|
+
*
|
|
4
|
+
* Wraps the raw {@link TestResponse} and exposes the full Japa response surface:
|
|
5
|
+
* accessor METHODS (`status()`, `headers()`, `body()`, `text()`, `header()`,
|
|
6
|
+
* `cookies()`, `redirects()`, `error()`, …) matching Japa exactly, the complete
|
|
7
|
+
* `assert*` family, response `dump*()` debuggers, and `macro()`/`getter()` for
|
|
8
|
+
* consumer extension.
|
|
9
|
+
*
|
|
10
|
+
* `json()` is kept as an additive convenience (not in Japa, but harmless for
|
|
11
|
+
* parity — Japa code never calls it) so `res.json()` call sites need no change.
|
|
12
|
+
*/
|
|
13
|
+
import type { Dict } from '../types/helpers.js';
|
|
14
|
+
/** The raw response shape the low-level sender produces. */
|
|
15
|
+
export interface TestResponse {
|
|
16
|
+
status: number;
|
|
17
|
+
headers: Dict;
|
|
18
|
+
body: string;
|
|
19
|
+
json<T = unknown>(): T;
|
|
20
|
+
}
|
|
21
|
+
/** Assertion failure — plain Error so tests see a clean stack trace. */
|
|
22
|
+
export declare class ExpectationError extends Error {
|
|
23
|
+
constructor(message: string);
|
|
24
|
+
}
|
|
25
|
+
export declare function capBody(s: string, max?: number): string;
|
|
26
|
+
/** Narrowing guard — a non-null, non-array object usable as a string map. */
|
|
27
|
+
export declare function isRecord(x: unknown): x is Record<string, unknown>;
|
|
28
|
+
/** Exact structural equality (order-insensitive object keys) for `assertBody`. */
|
|
29
|
+
export declare function deepEqual(a: unknown, b: unknown): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Partial deep-match. For objects, every key in `expected` must match in
|
|
32
|
+
* `actual`. For arrays, every element in `expected` must match SOMEWHERE in
|
|
33
|
+
* `actual` (order-independent). Primitives compared by strict equality.
|
|
34
|
+
*/
|
|
35
|
+
export declare function partialMatch(actual: unknown, expected: unknown): boolean;
|
|
36
|
+
/** A parsed response cookie — `name` + `value` plus any attributes present. */
|
|
37
|
+
export interface ResponseCookie {
|
|
38
|
+
name: string;
|
|
39
|
+
value: string;
|
|
40
|
+
[attr: string]: string;
|
|
41
|
+
}
|
|
42
|
+
/** A file parsed from a `multipart/form-data` response — Japa `files()` entry. */
|
|
43
|
+
export interface ResponseFile {
|
|
44
|
+
/** The form field name. */
|
|
45
|
+
fieldName: string;
|
|
46
|
+
/** The advertised filename. */
|
|
47
|
+
filename: string;
|
|
48
|
+
/** The part's `Content-Type`. */
|
|
49
|
+
type: string;
|
|
50
|
+
/** Byte length of the file content. */
|
|
51
|
+
size: number;
|
|
52
|
+
/** The raw file bytes. */
|
|
53
|
+
content: Buffer;
|
|
54
|
+
}
|
|
55
|
+
/** The Japa error object returned by `response.error()`. */
|
|
56
|
+
export interface ResponseError {
|
|
57
|
+
/** The error status code (>= 400). */
|
|
58
|
+
status: number;
|
|
59
|
+
/** The response text. */
|
|
60
|
+
text: string;
|
|
61
|
+
}
|
|
62
|
+
/** Extra context the builder threads into the response. */
|
|
63
|
+
export interface ApiResponseMeta {
|
|
64
|
+
/** The (final) request method — Japa `response.method()`. */
|
|
65
|
+
method?: string;
|
|
66
|
+
/** URLs followed when redirects were configured — Japa `response.redirects()`. */
|
|
67
|
+
redirects?: string[];
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Every Japa status-shortcut assertion, as `methodName → code`. Consumed to
|
|
71
|
+
* generate the `assert*` methods on both {@link ApiResponse} and the builder,
|
|
72
|
+
* so the two surfaces never drift.
|
|
73
|
+
*/
|
|
74
|
+
export declare const STATUS_ASSERTIONS: {
|
|
75
|
+
readonly assertOk: 200;
|
|
76
|
+
readonly assertCreated: 201;
|
|
77
|
+
readonly assertAccepted: 202;
|
|
78
|
+
readonly assertNoContent: 204;
|
|
79
|
+
readonly assertMovedPermanently: 301;
|
|
80
|
+
readonly assertFound: 302;
|
|
81
|
+
readonly assertBadRequest: 400;
|
|
82
|
+
readonly assertUnauthorized: 401;
|
|
83
|
+
readonly assertPaymentRequired: 402;
|
|
84
|
+
readonly assertForbidden: 403;
|
|
85
|
+
readonly assertNotFound: 404;
|
|
86
|
+
readonly assertMethodNotAllowed: 405;
|
|
87
|
+
readonly assertNotAcceptable: 406;
|
|
88
|
+
readonly assertRequestTimeout: 408;
|
|
89
|
+
readonly assertConflict: 409;
|
|
90
|
+
readonly assertGone: 410;
|
|
91
|
+
readonly assertLengthRequired: 411;
|
|
92
|
+
readonly assertPreconditionFailed: 412;
|
|
93
|
+
readonly assertPayloadTooLarge: 413;
|
|
94
|
+
readonly assertURITooLong: 414;
|
|
95
|
+
readonly assertUnsupportedMediaType: 415;
|
|
96
|
+
readonly assertRangeNotSatisfiable: 416;
|
|
97
|
+
readonly assertImATeapot: 418;
|
|
98
|
+
readonly assertUnprocessableEntity: 422;
|
|
99
|
+
readonly assertLocked: 423;
|
|
100
|
+
readonly assertTooManyRequests: 429;
|
|
101
|
+
/** ream extra (not in Japa's list, kept for convenience). */
|
|
102
|
+
readonly assertInternalServerError: 500;
|
|
103
|
+
};
|
|
104
|
+
/**
|
|
105
|
+
* The rich response. Constructed by the request builder from a raw
|
|
106
|
+
* {@link TestResponse}; exposes the Japa accessor + assertion surface.
|
|
107
|
+
*
|
|
108
|
+
* PARITY NOTE: the status code / headers / raw text are METHODS — `status()`,
|
|
109
|
+
* `headers()`, `text()` — and `body()` returns the content-type-parsed body,
|
|
110
|
+
* exactly like Japa. `json()` is kept as an additive convenience.
|
|
111
|
+
*/
|
|
112
|
+
export declare class ApiResponse {
|
|
113
|
+
#private;
|
|
114
|
+
constructor(raw: TestResponse, meta?: ApiResponseMeta);
|
|
115
|
+
/** HTTP status code — Japa `status()`. */
|
|
116
|
+
status(): number;
|
|
117
|
+
/** Status class digit (2 for 2xx, 4 for 4xx, …) — Japa `statusType()`. */
|
|
118
|
+
statusType(): number;
|
|
119
|
+
/** All response headers (lower-cased keys) — Japa `headers()`. */
|
|
120
|
+
headers(): Dict;
|
|
121
|
+
/** A single response header value — Japa `header(name)`. */
|
|
122
|
+
header(name: string): string | undefined;
|
|
123
|
+
/** Raw response text — Japa `text()`. */
|
|
124
|
+
text(): string;
|
|
125
|
+
/**
|
|
126
|
+
* The parsed response body — Japa `body()`. Parses by `Content-Type`:
|
|
127
|
+
* `application/json` → object, `application/x-www-form-urlencoded` → object,
|
|
128
|
+
* `multipart/form-data` → the non-file fields (files come from {@link files});
|
|
129
|
+
* otherwise the raw text. A registered parser (`ApiResponse.addParser`) for the
|
|
130
|
+
* content-type takes precedence.
|
|
131
|
+
*/
|
|
132
|
+
body(): unknown;
|
|
133
|
+
/** Convenience JSON parse (additive; not in Japa). */
|
|
134
|
+
json<T = unknown>(): T;
|
|
135
|
+
/** The request method that produced this response — Japa `method()`. */
|
|
136
|
+
method(): string;
|
|
137
|
+
/** Response `Content-Type` without parameters — Japa `type()`. */
|
|
138
|
+
type(): string | undefined;
|
|
139
|
+
/** Charset from `Content-Type`, if any — Japa `charset()`. */
|
|
140
|
+
charset(): string | undefined;
|
|
141
|
+
/** All response cookies, parsed from `Set-Cookie` — Japa `cookies()`. */
|
|
142
|
+
cookies(): Record<string, ResponseCookie>;
|
|
143
|
+
/** A single parsed response cookie — Japa `cookie(name)`. */
|
|
144
|
+
cookie(name: string): ResponseCookie | undefined;
|
|
145
|
+
/** URLs followed for a redirected request — Japa `redirects()`. */
|
|
146
|
+
redirects(): string[];
|
|
147
|
+
/** Parsed `Link` header (`rel → url`) — Japa `links()`. */
|
|
148
|
+
links(): Record<string, string>;
|
|
149
|
+
/**
|
|
150
|
+
* Files parsed from a `multipart/form-data` response — Japa `files()`. Each
|
|
151
|
+
* entry carries the field name, filename, content-type and the raw bytes.
|
|
152
|
+
* Empty for non-multipart responses.
|
|
153
|
+
*/
|
|
154
|
+
files(): Record<string, ResponseFile>;
|
|
155
|
+
/** Whether the response carries a body — Japa `hasBody()`. */
|
|
156
|
+
hasBody(): boolean;
|
|
157
|
+
/** Whether the status is an error (>= 400) — Japa `hasError()`. */
|
|
158
|
+
hasError(): boolean;
|
|
159
|
+
/** Whether the status is a server error (>= 500) — Japa `hasFatalError()`. */
|
|
160
|
+
hasFatalError(): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* The error object when the response is an error, else `undefined` — Japa
|
|
163
|
+
* `error()`. Exposes `.status` and `.text` (superagent-style).
|
|
164
|
+
*/
|
|
165
|
+
error(): ResponseError | undefined;
|
|
166
|
+
/** Print status + headers + body to stderr — Japa `response.dump()`. */
|
|
167
|
+
dump(): this;
|
|
168
|
+
/** Print only the response body — Japa `response.dumpBody()`. */
|
|
169
|
+
dumpBody(): this;
|
|
170
|
+
/** Print only the response headers — Japa `response.dumpHeaders()`. */
|
|
171
|
+
dumpHeaders(): this;
|
|
172
|
+
/** Print only the response cookies — Japa `response.dumpCookies()`. */
|
|
173
|
+
dumpCookies(): this;
|
|
174
|
+
/** Print the error object, if any — Japa `response.dumpError()`. */
|
|
175
|
+
dumpError(): this;
|
|
176
|
+
assertStatus(code: number): this;
|
|
177
|
+
assertHeader(name: string, value?: string | RegExp): this;
|
|
178
|
+
assertHeaderMissing(name: string): this;
|
|
179
|
+
assertCookie(name: string, value?: string | RegExp): this;
|
|
180
|
+
assertCookieMissing(name: string): this;
|
|
181
|
+
assertBody(expected: unknown): this;
|
|
182
|
+
assertBodyContains(subset: unknown): this;
|
|
183
|
+
assertBodyNotContains(subset: unknown): this;
|
|
184
|
+
assertTextIncludes(substring: string): this;
|
|
185
|
+
/**
|
|
186
|
+
* Assert the request was redirected to `path` — Japa `assertRedirectsTo`.
|
|
187
|
+
* Checks the followed redirect chain (`redirects()`); also accepts a direct
|
|
188
|
+
* 3xx `Location` match when no redirects were followed.
|
|
189
|
+
*/
|
|
190
|
+
assertRedirectsTo(path: string): this;
|
|
191
|
+
/**
|
|
192
|
+
* Assert the response conforms to the registered OpenAPI spec — Japa
|
|
193
|
+
* `assertAgainstApiSpec()`. Japa ships this via the SEPARATE opt-in
|
|
194
|
+
* `@japa/openapi-assertions` plugin; register a validator with
|
|
195
|
+
* {@link ApiResponse.registerApiSpecValidator} to enable it. Without one, this
|
|
196
|
+
* throws (never silently passes).
|
|
197
|
+
*/
|
|
198
|
+
assertAgainstApiSpec(): this;
|
|
199
|
+
/**
|
|
200
|
+
* Register a shared property (Japa `ApiResponse.macro`) or lazy getter
|
|
201
|
+
* (`ApiResponse.getter`). The callback is invoked with `this` bound to the
|
|
202
|
+
* response AND the response as its first argument, so both Japa's
|
|
203
|
+
* `function () { return this.header('x') }` and `(res) => res.header('x')` work.
|
|
204
|
+
*/
|
|
205
|
+
static macro(name: string, value: unknown): void;
|
|
206
|
+
static getter(name: string, fn: (this: ApiResponse, res: ApiResponse) => unknown): void;
|
|
207
|
+
/** Register a response body parser for a content-type — Japa `ApiRequest.addParser`. */
|
|
208
|
+
static addParser(contentType: string, fn: (body: string, headers: Dict) => unknown): void;
|
|
209
|
+
/** Register the validator backing {@link assertAgainstApiSpec} (OpenAPI opt-in). */
|
|
210
|
+
static registerApiSpecValidator(fn: (res: ApiResponse) => void): void;
|
|
211
|
+
}
|
|
212
|
+
/** The status-shortcut assertion methods, typed onto ApiResponse + the builder. */
|
|
213
|
+
export type StatusAssertions<T> = {
|
|
214
|
+
[K in keyof typeof STATUS_ASSERTIONS]: () => T;
|
|
215
|
+
};
|
|
216
|
+
export interface ApiResponse extends StatusAssertions<ApiResponse> {
|
|
217
|
+
}
|
|
218
|
+
//# sourceMappingURL=ApiResponse.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ApiResponse.d.ts","sourceRoot":"","sources":["../../src/testing/ApiResponse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAA;AAE/C,4DAA4D;AAC5D,MAAM,WAAW,YAAY;IAC3B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,IAAI,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,CAAC,CAAC,GAAG,OAAO,KAAK,CAAC,CAAA;CACvB;AAED,wEAAwE;AACxE,qBAAa,gBAAiB,SAAQ,KAAK;gBAC7B,OAAO,EAAE,MAAM;CAI5B;AAED,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,GAAG,SAAM,GAAG,MAAM,CAEpD;AAED,6EAA6E;AAC7E,wBAAgB,QAAQ,CAAC,CAAC,EAAE,OAAO,GAAG,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEjE;AAED,kFAAkF;AAClF,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAczD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAcxE;AAOD,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,KAAK,EAAE,MAAM,CAAA;IACb,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAAA;CACvB;AAuBD,kFAAkF;AAClF,MAAM,WAAW,YAAY;IAC3B,2BAA2B;IAC3B,SAAS,EAAE,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