@event-driven-io/emmett-honojs 0.42.0-rc.1
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/dist/index.d.mts +194 -0
- package/dist/index.d.ts +194 -0
- package/dist/index.js +589 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +589 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +59 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import * as _hono_node_server from '@hono/node-server';
|
|
2
|
+
import * as hono_types from 'hono/types';
|
|
3
|
+
import { Hono, Context } from 'hono';
|
|
4
|
+
import { ProblemDocument } from 'http-problem-details';
|
|
5
|
+
import * as _event_driven_io_emmett from '@event-driven-io/emmett';
|
|
6
|
+
import { Brand, Event, TestEventStream, EventStore } from '@event-driven-io/emmett';
|
|
7
|
+
import { StatusCode } from 'hono/utils/http-status';
|
|
8
|
+
|
|
9
|
+
type ErrorToProblemDetailsMapping = (error: Error) => ProblemDocument | undefined;
|
|
10
|
+
type WebApiSetup = (router: Hono) => void;
|
|
11
|
+
type ApplicationOptions = {
|
|
12
|
+
apis: WebApiSetup[];
|
|
13
|
+
mapError?: ErrorToProblemDetailsMapping;
|
|
14
|
+
disableProblemDetailsMiddleware?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type StartApiOptions = {
|
|
17
|
+
port?: number;
|
|
18
|
+
};
|
|
19
|
+
declare const getApplication: (options: ApplicationOptions) => Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
|
|
20
|
+
declare const startAPI: (app: Hono, options?: StartApiOptions) => _hono_node_server.ServerType;
|
|
21
|
+
|
|
22
|
+
declare const HeaderNames: {
|
|
23
|
+
IF_MATCH: string;
|
|
24
|
+
IF_NOT_MATCH: string;
|
|
25
|
+
ETag: string;
|
|
26
|
+
};
|
|
27
|
+
type WeakETag = Brand<`W/${string}`, 'ETag'>;
|
|
28
|
+
type ETag = Brand<string, 'ETag'>;
|
|
29
|
+
declare const WeakETagRegex: RegExp;
|
|
30
|
+
declare const enum ETagErrors {
|
|
31
|
+
WRONG_WEAK_ETAG_FORMAT = "WRONG_WEAK_ETAG_FORMAT",
|
|
32
|
+
MISSING_IF_MATCH_HEADER = "MISSING_IF_MATCH_HEADER",
|
|
33
|
+
MISSING_IF_NOT_MATCH_HEADER = "MISSING_IF_NOT_MATCH_HEADER"
|
|
34
|
+
}
|
|
35
|
+
declare const isWeakETag: (etag: ETag) => etag is WeakETag;
|
|
36
|
+
declare const getWeakETagValue: (etag: ETag) => string;
|
|
37
|
+
declare const toWeakETag: (value: number | bigint | string) => WeakETag;
|
|
38
|
+
declare const getETagFromIfMatch: (context: Context) => ETag;
|
|
39
|
+
declare const getETagFromIfNotMatch: (context: Context) => ETag;
|
|
40
|
+
declare const setETag: (context: Context, etag: ETag) => void;
|
|
41
|
+
declare const getETagValueFromIfMatch: (context: Context) => string;
|
|
42
|
+
|
|
43
|
+
type ContextWithBody<T> = Omit<Context, 'req'> & {
|
|
44
|
+
req: Omit<Context['req'], 'json'> & {
|
|
45
|
+
json(): Promise<T>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
type ContextWithQuery<T> = Omit<Context, 'req'> & {
|
|
49
|
+
req: Omit<Context['req'], 'query'> & {
|
|
50
|
+
query(): T;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
type ContextWithParams<T> = Omit<Context, 'req'> & {
|
|
54
|
+
req: Omit<Context['req'], 'param'> & {
|
|
55
|
+
param<K extends keyof T>(key: K): T[K];
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
declare const OK: (options: HttpResponseOptions & {
|
|
59
|
+
context: Context;
|
|
60
|
+
}) => Response;
|
|
61
|
+
declare const Created: (options: CreatedHttpResponseOptions & {
|
|
62
|
+
context: Context;
|
|
63
|
+
}) => Response;
|
|
64
|
+
declare const Accepted: (options: AcceptedHttpResponseOptions & {
|
|
65
|
+
context: Context;
|
|
66
|
+
}) => Response;
|
|
67
|
+
declare const NoContent: (options: NoContentHttpResponseOptions & {
|
|
68
|
+
context: Context;
|
|
69
|
+
}) => Response;
|
|
70
|
+
declare const HttpResponse: (options: HttpResponseOptions & {
|
|
71
|
+
context: Context;
|
|
72
|
+
statusCode: StatusCode;
|
|
73
|
+
}) => Response;
|
|
74
|
+
declare const BadRequest: (options: HttpProblemResponseOptions & {
|
|
75
|
+
context: Context;
|
|
76
|
+
}) => Response;
|
|
77
|
+
declare const Forbidden: (options: HttpProblemResponseOptions & {
|
|
78
|
+
context: Context;
|
|
79
|
+
}) => Response;
|
|
80
|
+
declare const NotFound: (options: HttpProblemResponseOptions & {
|
|
81
|
+
context: Context;
|
|
82
|
+
}) => Response;
|
|
83
|
+
declare const Conflict: (options: HttpProblemResponseOptions & {
|
|
84
|
+
context: Context;
|
|
85
|
+
}) => Response;
|
|
86
|
+
declare const PreconditionFailed: (options: HttpProblemResponseOptions & {
|
|
87
|
+
context: Context;
|
|
88
|
+
}) => Response;
|
|
89
|
+
declare const HttpProblem: (options: HttpProblemResponseOptions & {
|
|
90
|
+
context: Context;
|
|
91
|
+
statusCode: StatusCode;
|
|
92
|
+
}) => Response;
|
|
93
|
+
|
|
94
|
+
declare const defaultErrorToProblemDetailsMapping: (error: Error) => ProblemDocument;
|
|
95
|
+
|
|
96
|
+
type HttpResponseOptions = {
|
|
97
|
+
body?: unknown;
|
|
98
|
+
location?: string;
|
|
99
|
+
eTag?: ETag;
|
|
100
|
+
};
|
|
101
|
+
declare const DefaultHttpResponseOptions: HttpResponseOptions;
|
|
102
|
+
type HttpProblemResponseOptions = {
|
|
103
|
+
location?: string;
|
|
104
|
+
eTag?: ETag;
|
|
105
|
+
} & Omit<HttpResponseOptions, 'body'> & ({
|
|
106
|
+
problem: ProblemDocument;
|
|
107
|
+
} | {
|
|
108
|
+
problemDetails: string;
|
|
109
|
+
});
|
|
110
|
+
declare const DefaultHttpProblemResponseOptions: HttpProblemResponseOptions;
|
|
111
|
+
type CreatedHttpResponseOptions = ({
|
|
112
|
+
createdId: string;
|
|
113
|
+
} | {
|
|
114
|
+
createdId?: string;
|
|
115
|
+
url: string;
|
|
116
|
+
}) & HttpResponseOptions;
|
|
117
|
+
declare const sendCreated: (context: Context, { eTag, ...options }: CreatedHttpResponseOptions) => Response;
|
|
118
|
+
type AcceptedHttpResponseOptions = {
|
|
119
|
+
location: string;
|
|
120
|
+
} & HttpResponseOptions;
|
|
121
|
+
declare const sendAccepted: (context: Context, options: AcceptedHttpResponseOptions) => Response;
|
|
122
|
+
type NoContentHttpResponseOptions = Omit<HttpResponseOptions, 'body'>;
|
|
123
|
+
declare const send: (context: Context, statusCode: StatusCode, options?: HttpResponseOptions) => Response;
|
|
124
|
+
declare const sendProblem: (context: Context, statusCode: StatusCode, options?: HttpProblemResponseOptions) => Response;
|
|
125
|
+
|
|
126
|
+
declare class HonoTestRequest {
|
|
127
|
+
private app;
|
|
128
|
+
private method;
|
|
129
|
+
private path;
|
|
130
|
+
private options;
|
|
131
|
+
constructor(app: Hono, method: string, path: string, options?: {
|
|
132
|
+
body?: unknown;
|
|
133
|
+
headers?: Record<string, string>;
|
|
134
|
+
});
|
|
135
|
+
send(body?: unknown): HonoTestRequest;
|
|
136
|
+
set(headers: Record<string, string>): HonoTestRequest;
|
|
137
|
+
expect(): Promise<HonoResponse>;
|
|
138
|
+
execute(): Promise<HonoResponse>;
|
|
139
|
+
}
|
|
140
|
+
declare class HonoTestAgent {
|
|
141
|
+
private app;
|
|
142
|
+
constructor(app: Hono);
|
|
143
|
+
get(path: string): HonoTestRequest;
|
|
144
|
+
post(path: string): HonoTestRequest;
|
|
145
|
+
put(path: string): HonoTestRequest;
|
|
146
|
+
patch(path: string): HonoTestRequest;
|
|
147
|
+
delete(path: string): HonoTestRequest;
|
|
148
|
+
}
|
|
149
|
+
declare class HonoResponse {
|
|
150
|
+
private response;
|
|
151
|
+
private _body;
|
|
152
|
+
private _bodyPromise;
|
|
153
|
+
constructor(response: Response);
|
|
154
|
+
get statusCode(): number;
|
|
155
|
+
get status(): number;
|
|
156
|
+
get headers(): Record<string, string>;
|
|
157
|
+
get body(): unknown;
|
|
158
|
+
json(): Promise<unknown>;
|
|
159
|
+
text(): Promise<string>;
|
|
160
|
+
}
|
|
161
|
+
type TestRequest = (request: HonoTestAgent) => HonoTestRequest | Promise<HonoResponse>;
|
|
162
|
+
declare const existingStream: <EventType extends Event = Event>(streamId: string, events: EventType[]) => TestEventStream<EventType>;
|
|
163
|
+
type ResponseAssert = (response: HonoResponse) => boolean | void | Promise<boolean> | Promise<void>;
|
|
164
|
+
type ApiSpecificationAssert<EventType extends Event = Event> = TestEventStream<EventType>[] | ResponseAssert | [ResponseAssert, ...TestEventStream<EventType>[]];
|
|
165
|
+
declare const expect: <EventType extends Event = Event>(streamId: string, events: EventType[]) => TestEventStream<EventType>;
|
|
166
|
+
declare const expectNewEvents: <EventType extends Event = Event>(streamId: string, events: EventType[]) => TestEventStream<EventType>;
|
|
167
|
+
declare const expectResponse: <Body = unknown>(statusCode: number, options?: {
|
|
168
|
+
body?: Body;
|
|
169
|
+
headers?: {
|
|
170
|
+
[index: string]: string;
|
|
171
|
+
};
|
|
172
|
+
}) => (response: HonoResponse) => Promise<void>;
|
|
173
|
+
declare const expectError: (errorCode: number, problemDetails?: Partial<ProblemDocument>) => (response: HonoResponse) => Promise<void>;
|
|
174
|
+
type ApiSpecification<EventType extends Event = Event> = (...givenStreams: TestEventStream<EventType>[]) => {
|
|
175
|
+
when: (setupRequest: TestRequest) => {
|
|
176
|
+
then: (verify: ApiSpecificationAssert<EventType>) => Promise<void>;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
declare const ApiSpecification: {
|
|
180
|
+
for: <EventType extends Event = Event, Store extends EventStore = EventStore<_event_driven_io_emmett.AnyRecordedMessageMetadata>>(getEventStore: () => Store, getApplication: (eventStore: Store) => Hono) => ApiSpecification<EventType>;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
type E2EResponseAssert = (response: HonoResponse) => boolean | void | Promise<boolean> | Promise<void>;
|
|
184
|
+
type ApiE2ESpecificationAssert = [E2EResponseAssert];
|
|
185
|
+
type ApiE2ESpecification = (...givenRequests: TestRequest[]) => {
|
|
186
|
+
when: (setupRequest: TestRequest) => {
|
|
187
|
+
then: (verify: ApiE2ESpecificationAssert) => Promise<void>;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
declare const ApiE2ESpecification: {
|
|
191
|
+
for: <Store extends EventStore = EventStore<_event_driven_io_emmett.AnyRecordedMessageMetadata>>(getEventStore: () => Store, getApplication: (eventStore: Store) => Hono) => ApiE2ESpecification;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export { Accepted, type AcceptedHttpResponseOptions, ApiE2ESpecification, type ApiE2ESpecificationAssert, ApiSpecification, type ApiSpecificationAssert, type ApplicationOptions, BadRequest, Conflict, type ContextWithBody, type ContextWithParams, type ContextWithQuery, Created, type CreatedHttpResponseOptions, DefaultHttpProblemResponseOptions, DefaultHttpResponseOptions, type E2EResponseAssert, type ETag, ETagErrors, type ErrorToProblemDetailsMapping, Forbidden, HeaderNames, HonoResponse, HonoTestAgent, HonoTestRequest, HttpProblem, type HttpProblemResponseOptions, HttpResponse, type HttpResponseOptions, NoContent, type NoContentHttpResponseOptions, NotFound, OK, PreconditionFailed, type ResponseAssert, type StartApiOptions, type TestRequest, type WeakETag, WeakETagRegex, type WebApiSetup, defaultErrorToProblemDetailsMapping, existingStream, expect, expectError, expectNewEvents, expectResponse, getApplication, getETagFromIfMatch, getETagFromIfNotMatch, getETagValueFromIfMatch, getWeakETagValue, isWeakETag, send, sendAccepted, sendCreated, sendProblem, setETag, startAPI, toWeakETag };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import * as _hono_node_server from '@hono/node-server';
|
|
2
|
+
import * as hono_types from 'hono/types';
|
|
3
|
+
import { Hono, Context } from 'hono';
|
|
4
|
+
import { ProblemDocument } from 'http-problem-details';
|
|
5
|
+
import * as _event_driven_io_emmett from '@event-driven-io/emmett';
|
|
6
|
+
import { Brand, Event, TestEventStream, EventStore } from '@event-driven-io/emmett';
|
|
7
|
+
import { StatusCode } from 'hono/utils/http-status';
|
|
8
|
+
|
|
9
|
+
type ErrorToProblemDetailsMapping = (error: Error) => ProblemDocument | undefined;
|
|
10
|
+
type WebApiSetup = (router: Hono) => void;
|
|
11
|
+
type ApplicationOptions = {
|
|
12
|
+
apis: WebApiSetup[];
|
|
13
|
+
mapError?: ErrorToProblemDetailsMapping;
|
|
14
|
+
disableProblemDetailsMiddleware?: boolean;
|
|
15
|
+
};
|
|
16
|
+
type StartApiOptions = {
|
|
17
|
+
port?: number;
|
|
18
|
+
};
|
|
19
|
+
declare const getApplication: (options: ApplicationOptions) => Hono<hono_types.BlankEnv, hono_types.BlankSchema, "/">;
|
|
20
|
+
declare const startAPI: (app: Hono, options?: StartApiOptions) => _hono_node_server.ServerType;
|
|
21
|
+
|
|
22
|
+
declare const HeaderNames: {
|
|
23
|
+
IF_MATCH: string;
|
|
24
|
+
IF_NOT_MATCH: string;
|
|
25
|
+
ETag: string;
|
|
26
|
+
};
|
|
27
|
+
type WeakETag = Brand<`W/${string}`, 'ETag'>;
|
|
28
|
+
type ETag = Brand<string, 'ETag'>;
|
|
29
|
+
declare const WeakETagRegex: RegExp;
|
|
30
|
+
declare const enum ETagErrors {
|
|
31
|
+
WRONG_WEAK_ETAG_FORMAT = "WRONG_WEAK_ETAG_FORMAT",
|
|
32
|
+
MISSING_IF_MATCH_HEADER = "MISSING_IF_MATCH_HEADER",
|
|
33
|
+
MISSING_IF_NOT_MATCH_HEADER = "MISSING_IF_NOT_MATCH_HEADER"
|
|
34
|
+
}
|
|
35
|
+
declare const isWeakETag: (etag: ETag) => etag is WeakETag;
|
|
36
|
+
declare const getWeakETagValue: (etag: ETag) => string;
|
|
37
|
+
declare const toWeakETag: (value: number | bigint | string) => WeakETag;
|
|
38
|
+
declare const getETagFromIfMatch: (context: Context) => ETag;
|
|
39
|
+
declare const getETagFromIfNotMatch: (context: Context) => ETag;
|
|
40
|
+
declare const setETag: (context: Context, etag: ETag) => void;
|
|
41
|
+
declare const getETagValueFromIfMatch: (context: Context) => string;
|
|
42
|
+
|
|
43
|
+
type ContextWithBody<T> = Omit<Context, 'req'> & {
|
|
44
|
+
req: Omit<Context['req'], 'json'> & {
|
|
45
|
+
json(): Promise<T>;
|
|
46
|
+
};
|
|
47
|
+
};
|
|
48
|
+
type ContextWithQuery<T> = Omit<Context, 'req'> & {
|
|
49
|
+
req: Omit<Context['req'], 'query'> & {
|
|
50
|
+
query(): T;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
type ContextWithParams<T> = Omit<Context, 'req'> & {
|
|
54
|
+
req: Omit<Context['req'], 'param'> & {
|
|
55
|
+
param<K extends keyof T>(key: K): T[K];
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
declare const OK: (options: HttpResponseOptions & {
|
|
59
|
+
context: Context;
|
|
60
|
+
}) => Response;
|
|
61
|
+
declare const Created: (options: CreatedHttpResponseOptions & {
|
|
62
|
+
context: Context;
|
|
63
|
+
}) => Response;
|
|
64
|
+
declare const Accepted: (options: AcceptedHttpResponseOptions & {
|
|
65
|
+
context: Context;
|
|
66
|
+
}) => Response;
|
|
67
|
+
declare const NoContent: (options: NoContentHttpResponseOptions & {
|
|
68
|
+
context: Context;
|
|
69
|
+
}) => Response;
|
|
70
|
+
declare const HttpResponse: (options: HttpResponseOptions & {
|
|
71
|
+
context: Context;
|
|
72
|
+
statusCode: StatusCode;
|
|
73
|
+
}) => Response;
|
|
74
|
+
declare const BadRequest: (options: HttpProblemResponseOptions & {
|
|
75
|
+
context: Context;
|
|
76
|
+
}) => Response;
|
|
77
|
+
declare const Forbidden: (options: HttpProblemResponseOptions & {
|
|
78
|
+
context: Context;
|
|
79
|
+
}) => Response;
|
|
80
|
+
declare const NotFound: (options: HttpProblemResponseOptions & {
|
|
81
|
+
context: Context;
|
|
82
|
+
}) => Response;
|
|
83
|
+
declare const Conflict: (options: HttpProblemResponseOptions & {
|
|
84
|
+
context: Context;
|
|
85
|
+
}) => Response;
|
|
86
|
+
declare const PreconditionFailed: (options: HttpProblemResponseOptions & {
|
|
87
|
+
context: Context;
|
|
88
|
+
}) => Response;
|
|
89
|
+
declare const HttpProblem: (options: HttpProblemResponseOptions & {
|
|
90
|
+
context: Context;
|
|
91
|
+
statusCode: StatusCode;
|
|
92
|
+
}) => Response;
|
|
93
|
+
|
|
94
|
+
declare const defaultErrorToProblemDetailsMapping: (error: Error) => ProblemDocument;
|
|
95
|
+
|
|
96
|
+
type HttpResponseOptions = {
|
|
97
|
+
body?: unknown;
|
|
98
|
+
location?: string;
|
|
99
|
+
eTag?: ETag;
|
|
100
|
+
};
|
|
101
|
+
declare const DefaultHttpResponseOptions: HttpResponseOptions;
|
|
102
|
+
type HttpProblemResponseOptions = {
|
|
103
|
+
location?: string;
|
|
104
|
+
eTag?: ETag;
|
|
105
|
+
} & Omit<HttpResponseOptions, 'body'> & ({
|
|
106
|
+
problem: ProblemDocument;
|
|
107
|
+
} | {
|
|
108
|
+
problemDetails: string;
|
|
109
|
+
});
|
|
110
|
+
declare const DefaultHttpProblemResponseOptions: HttpProblemResponseOptions;
|
|
111
|
+
type CreatedHttpResponseOptions = ({
|
|
112
|
+
createdId: string;
|
|
113
|
+
} | {
|
|
114
|
+
createdId?: string;
|
|
115
|
+
url: string;
|
|
116
|
+
}) & HttpResponseOptions;
|
|
117
|
+
declare const sendCreated: (context: Context, { eTag, ...options }: CreatedHttpResponseOptions) => Response;
|
|
118
|
+
type AcceptedHttpResponseOptions = {
|
|
119
|
+
location: string;
|
|
120
|
+
} & HttpResponseOptions;
|
|
121
|
+
declare const sendAccepted: (context: Context, options: AcceptedHttpResponseOptions) => Response;
|
|
122
|
+
type NoContentHttpResponseOptions = Omit<HttpResponseOptions, 'body'>;
|
|
123
|
+
declare const send: (context: Context, statusCode: StatusCode, options?: HttpResponseOptions) => Response;
|
|
124
|
+
declare const sendProblem: (context: Context, statusCode: StatusCode, options?: HttpProblemResponseOptions) => Response;
|
|
125
|
+
|
|
126
|
+
declare class HonoTestRequest {
|
|
127
|
+
private app;
|
|
128
|
+
private method;
|
|
129
|
+
private path;
|
|
130
|
+
private options;
|
|
131
|
+
constructor(app: Hono, method: string, path: string, options?: {
|
|
132
|
+
body?: unknown;
|
|
133
|
+
headers?: Record<string, string>;
|
|
134
|
+
});
|
|
135
|
+
send(body?: unknown): HonoTestRequest;
|
|
136
|
+
set(headers: Record<string, string>): HonoTestRequest;
|
|
137
|
+
expect(): Promise<HonoResponse>;
|
|
138
|
+
execute(): Promise<HonoResponse>;
|
|
139
|
+
}
|
|
140
|
+
declare class HonoTestAgent {
|
|
141
|
+
private app;
|
|
142
|
+
constructor(app: Hono);
|
|
143
|
+
get(path: string): HonoTestRequest;
|
|
144
|
+
post(path: string): HonoTestRequest;
|
|
145
|
+
put(path: string): HonoTestRequest;
|
|
146
|
+
patch(path: string): HonoTestRequest;
|
|
147
|
+
delete(path: string): HonoTestRequest;
|
|
148
|
+
}
|
|
149
|
+
declare class HonoResponse {
|
|
150
|
+
private response;
|
|
151
|
+
private _body;
|
|
152
|
+
private _bodyPromise;
|
|
153
|
+
constructor(response: Response);
|
|
154
|
+
get statusCode(): number;
|
|
155
|
+
get status(): number;
|
|
156
|
+
get headers(): Record<string, string>;
|
|
157
|
+
get body(): unknown;
|
|
158
|
+
json(): Promise<unknown>;
|
|
159
|
+
text(): Promise<string>;
|
|
160
|
+
}
|
|
161
|
+
type TestRequest = (request: HonoTestAgent) => HonoTestRequest | Promise<HonoResponse>;
|
|
162
|
+
declare const existingStream: <EventType extends Event = Event>(streamId: string, events: EventType[]) => TestEventStream<EventType>;
|
|
163
|
+
type ResponseAssert = (response: HonoResponse) => boolean | void | Promise<boolean> | Promise<void>;
|
|
164
|
+
type ApiSpecificationAssert<EventType extends Event = Event> = TestEventStream<EventType>[] | ResponseAssert | [ResponseAssert, ...TestEventStream<EventType>[]];
|
|
165
|
+
declare const expect: <EventType extends Event = Event>(streamId: string, events: EventType[]) => TestEventStream<EventType>;
|
|
166
|
+
declare const expectNewEvents: <EventType extends Event = Event>(streamId: string, events: EventType[]) => TestEventStream<EventType>;
|
|
167
|
+
declare const expectResponse: <Body = unknown>(statusCode: number, options?: {
|
|
168
|
+
body?: Body;
|
|
169
|
+
headers?: {
|
|
170
|
+
[index: string]: string;
|
|
171
|
+
};
|
|
172
|
+
}) => (response: HonoResponse) => Promise<void>;
|
|
173
|
+
declare const expectError: (errorCode: number, problemDetails?: Partial<ProblemDocument>) => (response: HonoResponse) => Promise<void>;
|
|
174
|
+
type ApiSpecification<EventType extends Event = Event> = (...givenStreams: TestEventStream<EventType>[]) => {
|
|
175
|
+
when: (setupRequest: TestRequest) => {
|
|
176
|
+
then: (verify: ApiSpecificationAssert<EventType>) => Promise<void>;
|
|
177
|
+
};
|
|
178
|
+
};
|
|
179
|
+
declare const ApiSpecification: {
|
|
180
|
+
for: <EventType extends Event = Event, Store extends EventStore = EventStore<_event_driven_io_emmett.AnyRecordedMessageMetadata>>(getEventStore: () => Store, getApplication: (eventStore: Store) => Hono) => ApiSpecification<EventType>;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
type E2EResponseAssert = (response: HonoResponse) => boolean | void | Promise<boolean> | Promise<void>;
|
|
184
|
+
type ApiE2ESpecificationAssert = [E2EResponseAssert];
|
|
185
|
+
type ApiE2ESpecification = (...givenRequests: TestRequest[]) => {
|
|
186
|
+
when: (setupRequest: TestRequest) => {
|
|
187
|
+
then: (verify: ApiE2ESpecificationAssert) => Promise<void>;
|
|
188
|
+
};
|
|
189
|
+
};
|
|
190
|
+
declare const ApiE2ESpecification: {
|
|
191
|
+
for: <Store extends EventStore = EventStore<_event_driven_io_emmett.AnyRecordedMessageMetadata>>(getEventStore: () => Store, getApplication: (eventStore: Store) => Hono) => ApiE2ESpecification;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export { Accepted, type AcceptedHttpResponseOptions, ApiE2ESpecification, type ApiE2ESpecificationAssert, ApiSpecification, type ApiSpecificationAssert, type ApplicationOptions, BadRequest, Conflict, type ContextWithBody, type ContextWithParams, type ContextWithQuery, Created, type CreatedHttpResponseOptions, DefaultHttpProblemResponseOptions, DefaultHttpResponseOptions, type E2EResponseAssert, type ETag, ETagErrors, type ErrorToProblemDetailsMapping, Forbidden, HeaderNames, HonoResponse, HonoTestAgent, HonoTestRequest, HttpProblem, type HttpProblemResponseOptions, HttpResponse, type HttpResponseOptions, NoContent, type NoContentHttpResponseOptions, NotFound, OK, PreconditionFailed, type ResponseAssert, type StartApiOptions, type TestRequest, type WeakETag, WeakETagRegex, type WebApiSetup, defaultErrorToProblemDetailsMapping, existingStream, expect, expectError, expectNewEvents, expectResponse, getApplication, getETagFromIfMatch, getETagFromIfNotMatch, getETagValueFromIfMatch, getWeakETagValue, isWeakETag, send, sendAccepted, sendCreated, sendProblem, setETag, startAPI, toWeakETag };
|