@scaffoldly/rowdy 0.0.2-1-beta.20251011182751.ccfebc8 → 0.0.2-1-beta.20251013190835.df2655f
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.ts +208 -12
- package/dist/index.js +573 -425
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,211 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Observable } from 'rxjs';
|
|
2
|
+
import { Observable, ReplaySubject } from 'rxjs';
|
|
3
|
+
import { PassThrough, Readable, Writable } from 'stream';
|
|
4
|
+
import { AxiosHeaders, AxiosResponseHeaders } from 'axios';
|
|
5
|
+
import { Agent } from 'https';
|
|
6
|
+
import { APIGatewayProxyEventV2 } from 'aws-lambda';
|
|
3
7
|
|
|
4
8
|
interface ILoggable {
|
|
5
9
|
repr(): string;
|
|
6
10
|
}
|
|
11
|
+
type Primitive = string | number | boolean | undefined | null | Error;
|
|
12
|
+
type Loggable = Error | AbortSignal | Buffer | Primitive | Array<Primitive> | ILoggable | Array<ILoggable>;
|
|
13
|
+
declare class Logger {
|
|
14
|
+
private _debug;
|
|
15
|
+
private _trace;
|
|
16
|
+
constructor();
|
|
17
|
+
get isDebugging(): boolean;
|
|
18
|
+
get isTracing(): boolean;
|
|
19
|
+
withDebugging(): this;
|
|
20
|
+
withTracing(): this;
|
|
21
|
+
static asPrimitive(value: Loggable): Primitive;
|
|
22
|
+
private log;
|
|
23
|
+
info: (message: string, params?: Record<string, Loggable>) => void;
|
|
24
|
+
error: (message: string, params?: Record<string, Loggable>) => void;
|
|
25
|
+
warn: (message: string, params?: Record<string, Loggable>) => void;
|
|
26
|
+
debug: (message: string, params?: Loggable | Record<string, Loggable>) => void;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
type Status = 'ok' | 'error' | 'timeout' | 'unknown';
|
|
30
|
+
type Latency = `${number}ms`;
|
|
31
|
+
type CheckResult = {
|
|
32
|
+
status: Status;
|
|
33
|
+
latency?: Latency;
|
|
34
|
+
reason?: string | undefined;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
type Secrets = Record<string, string>;
|
|
38
|
+
declare class Environment implements ILoggable {
|
|
39
|
+
private log;
|
|
40
|
+
abort: AbortController;
|
|
41
|
+
readonly signal: AbortSignal;
|
|
42
|
+
readonly bin: string | undefined;
|
|
43
|
+
private _pipelines;
|
|
44
|
+
private subscriptions;
|
|
45
|
+
private _routes;
|
|
46
|
+
private _command?;
|
|
47
|
+
private _env;
|
|
48
|
+
constructor(log: Logger);
|
|
49
|
+
get routes(): Routes;
|
|
50
|
+
get command(): string[] | undefined;
|
|
51
|
+
get env(): Record<string, string | undefined>;
|
|
52
|
+
init(): this;
|
|
53
|
+
poll(): Observable<Result<Pipeline>>;
|
|
54
|
+
protected withSecrets(secrets: Secrets): this;
|
|
55
|
+
repr(): string;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
declare abstract class Pipeline implements ILoggable {
|
|
59
|
+
protected readonly environment: Environment;
|
|
60
|
+
private _createdAt;
|
|
61
|
+
constructor(environment: Environment);
|
|
62
|
+
get env(): Record<string, string | undefined>;
|
|
63
|
+
get signal(): AbortSignal;
|
|
64
|
+
get routes(): Routes;
|
|
65
|
+
get createdAt(): number;
|
|
66
|
+
abstract into(): Observable<Request<Pipeline>>;
|
|
67
|
+
abstract repr(): string;
|
|
68
|
+
}
|
|
69
|
+
declare class FileDescriptors {
|
|
70
|
+
readonly stdin: PassThrough;
|
|
71
|
+
readonly stdout: PassThrough;
|
|
72
|
+
readonly stderr: PassThrough;
|
|
73
|
+
end(): void;
|
|
74
|
+
}
|
|
75
|
+
declare abstract class Request<P extends Pipeline> implements ILoggable {
|
|
76
|
+
protected readonly pipeline: P;
|
|
77
|
+
readonly createdAt: number;
|
|
78
|
+
readonly fds: FileDescriptors;
|
|
79
|
+
constructor(pipeline: P);
|
|
80
|
+
get signal(): AbortSignal;
|
|
81
|
+
get stdin(): Readable;
|
|
82
|
+
get stdout(): Writable;
|
|
83
|
+
get stderr(): Writable;
|
|
84
|
+
withInput(input: Readable): this;
|
|
85
|
+
abstract into(): Observable<Proxy<P, unknown>>;
|
|
86
|
+
abstract repr(): string;
|
|
87
|
+
}
|
|
88
|
+
declare abstract class Proxy<P extends Pipeline, T> implements ILoggable {
|
|
89
|
+
readonly pipeline: P;
|
|
90
|
+
readonly request: Request<P>;
|
|
91
|
+
constructor(pipeline: P, request: Request<P>);
|
|
92
|
+
get signal(): AbortSignal;
|
|
93
|
+
abstract invoke(): Observable<T>;
|
|
94
|
+
abstract into(): Observable<Response<P>>;
|
|
95
|
+
abstract repr(): string;
|
|
96
|
+
}
|
|
97
|
+
declare class Chunk {
|
|
98
|
+
readonly data: Buffer | string;
|
|
99
|
+
readonly bytes: number;
|
|
100
|
+
constructor(data: Buffer | string, bytes: number);
|
|
101
|
+
}
|
|
102
|
+
declare abstract class Response<P extends Pipeline> extends ReplaySubject<Chunk> implements ILoggable {
|
|
103
|
+
protected readonly pipeline: P;
|
|
104
|
+
readonly request: Request<P>;
|
|
105
|
+
constructor(pipeline: P, request: Request<P>);
|
|
106
|
+
get signal(): AbortSignal;
|
|
107
|
+
abstract into(): Observable<Result<P>>;
|
|
108
|
+
abstract repr(): string;
|
|
109
|
+
}
|
|
110
|
+
declare class Result<P extends Pipeline> implements ILoggable {
|
|
111
|
+
protected readonly pipeline: P;
|
|
112
|
+
readonly request: Request<P>;
|
|
113
|
+
readonly success: boolean;
|
|
114
|
+
readonly bytes: number;
|
|
115
|
+
readonly createdAt: number;
|
|
116
|
+
constructor(pipeline: P, request: Request<P>, success: boolean, bytes: number);
|
|
117
|
+
get uptime(): number;
|
|
118
|
+
get duration(): number;
|
|
119
|
+
repr(): string;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
declare abstract class HttpProxy<P extends Pipeline> extends Proxy<P, HttpResponse> {
|
|
123
|
+
readonly method: string;
|
|
124
|
+
readonly uri: URI;
|
|
125
|
+
readonly headers: HttpHeaders;
|
|
126
|
+
readonly body: Buffer;
|
|
127
|
+
constructor(pipeline: P, request: Request<P>, method: string, uri: URI, headers: HttpHeaders, body: Buffer);
|
|
128
|
+
get httpsAgent(): Agent | undefined;
|
|
129
|
+
invoke(): Observable<HttpResponse>;
|
|
130
|
+
repr(): string;
|
|
131
|
+
}
|
|
132
|
+
declare class HttpHeaders implements ILoggable {
|
|
133
|
+
private headers;
|
|
134
|
+
private constructor();
|
|
135
|
+
proxy(): HttpHeaders;
|
|
136
|
+
static from(obj: Record<string, string | string[]>): HttpHeaders;
|
|
137
|
+
static fromAxios(axiosHeaders: Partial<AxiosHeaders | AxiosResponseHeaders>): HttpHeaders;
|
|
138
|
+
static fromLambda(headers: Partial<APIGatewayProxyEventV2['headers']>): HttpHeaders;
|
|
139
|
+
intoAxios(): AxiosHeaders;
|
|
140
|
+
intoJSON(): Record<string, unknown>;
|
|
141
|
+
override(key: string, value?: string | string[]): this;
|
|
142
|
+
repr(): string;
|
|
143
|
+
}
|
|
144
|
+
declare abstract class HttpResponse implements ILoggable {
|
|
145
|
+
private _status;
|
|
146
|
+
private _headers;
|
|
147
|
+
private _cookies;
|
|
148
|
+
private _data;
|
|
149
|
+
constructor(status: number, headers: HttpHeaders, cookies: string[], data: Readable);
|
|
150
|
+
get status(): number;
|
|
151
|
+
get headers(): HttpHeaders;
|
|
152
|
+
get cookies(): string[];
|
|
153
|
+
get data(): Readable;
|
|
154
|
+
prelude(): {
|
|
155
|
+
statusCode?: number;
|
|
156
|
+
headers?: Record<string, unknown>;
|
|
157
|
+
cookies?: string[];
|
|
158
|
+
};
|
|
159
|
+
withStatus(code: number): this;
|
|
160
|
+
withHeader(key: string, value?: string): this;
|
|
161
|
+
withHeaders(headers: HttpHeaders): this;
|
|
162
|
+
withCookies(cookies: string[]): this;
|
|
163
|
+
withData(data: Readable): this;
|
|
164
|
+
abstract handle<P extends Pipeline>(proxy: HttpProxy<P>): Observable<HttpResponse>;
|
|
165
|
+
abstract repr(): string;
|
|
166
|
+
}
|
|
7
167
|
|
|
8
|
-
type
|
|
168
|
+
type ApiVersion = 'rowdy.run/v1alpha1';
|
|
169
|
+
type ApiKind = 'Routes' | 'Health' | 'Hello' | 'NotFound';
|
|
170
|
+
type ApiSchema<Spec, Status> = {
|
|
171
|
+
apiVersion: ApiVersion;
|
|
172
|
+
kind: ApiKind;
|
|
173
|
+
spec?: Spec;
|
|
174
|
+
status: Status;
|
|
175
|
+
};
|
|
176
|
+
type ApiResponseStatus = {
|
|
177
|
+
code: number;
|
|
178
|
+
headers: {
|
|
179
|
+
[key: string]: string | string[];
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
type Health$1 = {
|
|
183
|
+
req: never;
|
|
184
|
+
opts: never;
|
|
185
|
+
res: {
|
|
186
|
+
healthy: boolean;
|
|
187
|
+
};
|
|
188
|
+
};
|
|
189
|
+
type Hello = {
|
|
190
|
+
req: {
|
|
191
|
+
to: string;
|
|
192
|
+
};
|
|
193
|
+
opts: {
|
|
194
|
+
enthusiastic?: boolean;
|
|
195
|
+
};
|
|
196
|
+
res: {
|
|
197
|
+
to: string;
|
|
198
|
+
};
|
|
199
|
+
};
|
|
200
|
+
declare class Api {
|
|
201
|
+
private routes;
|
|
202
|
+
constructor();
|
|
203
|
+
health(): Observable<ApiSchema<Health$1['res'], ApiResponseStatus>>;
|
|
204
|
+
hello(req: Hello['req'], opts?: Hello['opts']): Observable<ApiSchema<Hello['res'], ApiResponseStatus>>;
|
|
205
|
+
handle<P extends Pipeline>(proxy: HttpProxy<P>): Observable<ApiSchema<unknown, ApiResponseStatus>>;
|
|
206
|
+
private handler;
|
|
207
|
+
}
|
|
9
208
|
|
|
10
|
-
type RoutesApiVersion = 'rowdy.run/v1alpha1';
|
|
11
209
|
type RoutePaths = {
|
|
12
210
|
[key: string]: string | undefined;
|
|
13
211
|
};
|
|
@@ -27,13 +225,10 @@ type RouteRule = {
|
|
|
27
225
|
backendRefs?: Array<RouteRuleBackendRef>;
|
|
28
226
|
};
|
|
29
227
|
interface IRoutes {
|
|
30
|
-
readonly version:
|
|
228
|
+
readonly version: ApiVersion;
|
|
31
229
|
readonly rules: Array<RouteRule>;
|
|
32
230
|
}
|
|
33
|
-
type URIHealth =
|
|
34
|
-
healthy: boolean;
|
|
35
|
-
latency: CheckResult;
|
|
36
|
-
};
|
|
231
|
+
type URIHealth = CheckResult;
|
|
37
232
|
type Search = {
|
|
38
233
|
key: string;
|
|
39
234
|
value: string;
|
|
@@ -41,9 +236,10 @@ type Search = {
|
|
|
41
236
|
declare class URI extends URL implements ILoggable {
|
|
42
237
|
readonly insecure: boolean;
|
|
43
238
|
protected static awaits: Map<string, Observable<URI>>;
|
|
44
|
-
static
|
|
239
|
+
static ERROR: string;
|
|
45
240
|
protected constructor(url: URL, insecure?: boolean);
|
|
46
|
-
get
|
|
241
|
+
get server(): string;
|
|
242
|
+
get error(): string | undefined;
|
|
47
243
|
withSearch(search: Search, value?: string): this;
|
|
48
244
|
static from(uri: string): URI;
|
|
49
245
|
static fromError(error: Error, code?: number): URI;
|
|
@@ -55,7 +251,7 @@ type Health = {
|
|
|
55
251
|
[origin: string]: URIHealth;
|
|
56
252
|
};
|
|
57
253
|
declare class Routes implements IRoutes, ILoggable {
|
|
58
|
-
readonly version:
|
|
254
|
+
readonly version: ApiVersion;
|
|
59
255
|
readonly rules: Array<RouteRule>;
|
|
60
256
|
private constructor();
|
|
61
257
|
static empty(): Routes;
|
|
@@ -77,4 +273,4 @@ declare class Routes implements IRoutes, ILoggable {
|
|
|
77
273
|
|
|
78
274
|
declare const ABORT: AbortController;
|
|
79
275
|
|
|
80
|
-
export { ABORT, Routes, URI };
|
|
276
|
+
export { ABORT, Api, Routes, URI };
|