@scaffoldly/rowdy 0.0.2-1-beta.20251015161516.e1f6f24 → 0.0.2-1-beta.20251016225027.95deb3d

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.
Files changed (3) hide show
  1. package/dist/index.d.ts +178 -115
  2. package/dist/index.js +3994 -1440
  3. package/package.json +3 -1
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import { Observable, ReplaySubject } from 'rxjs';
3
+ import * as path_to_regexp from 'path-to-regexp';
3
4
  import { PassThrough, Readable, Writable } from 'stream';
4
- import { AxiosHeaders, AxiosResponseHeaders } from 'axios';
5
+ import { AxiosHeaders, AxiosResponseHeaders, AxiosInstance } from 'axios';
5
6
  import { Agent } from 'https';
6
7
  import { APIGatewayProxyEventV2 } from 'aws-lambda';
7
8
 
@@ -34,29 +35,8 @@ type CheckResult = {
34
35
  reason?: string | undefined;
35
36
  };
36
37
 
37
- type Secrets = Record<string, string>;
38
- declare class Environment implements ILoggable {
39
- readonly log: Logger;
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
38
  declare abstract class Pipeline implements ILoggable {
59
- protected readonly environment: Environment;
39
+ readonly environment: Environment;
60
40
  private _createdAt;
61
41
  constructor(environment: Environment);
62
42
  get log(): Logger;
@@ -120,55 +100,45 @@ declare class Result<P extends Pipeline> implements ILoggable {
120
100
  repr(): string;
121
101
  }
122
102
 
123
- declare abstract class HttpProxy<P extends Pipeline> extends Proxy<P, HttpResponse> {
124
- readonly method: string;
125
- readonly uri: URI;
126
- readonly headers: HttpHeaders;
127
- readonly body: Buffer;
128
- constructor(pipeline: P, request: Request<P>, method: string, uri: URI, headers: HttpHeaders, body: Buffer);
129
- get httpsAgent(): Agent | undefined;
130
- invoke(): Observable<HttpResponse>;
131
- repr(): string;
132
- }
133
- declare class HttpHeaders implements ILoggable {
134
- private headers;
135
- private constructor();
136
- get userAgent(): string;
137
- proxy(): HttpHeaders;
138
- static from(obj: Record<string, string | string[]>): HttpHeaders;
139
- static fromAxios(axiosHeaders: Partial<AxiosHeaders | AxiosResponseHeaders>): HttpHeaders;
140
- static fromLambda(headers: Partial<APIGatewayProxyEventV2['headers']>): HttpHeaders;
141
- intoAxios(): AxiosHeaders;
142
- intoJSON(): Record<string, unknown>;
143
- override(key: string, value?: string | string[]): this;
103
+ type Secrets = Record<string, string>;
104
+ type Args = {
105
+ debug: boolean;
106
+ trace: boolean;
107
+ routes: string;
108
+ registry: string | undefined;
109
+ '--'?: string[];
110
+ };
111
+ declare class Environment implements ILoggable {
112
+ readonly log: Logger;
113
+ abort: AbortController;
114
+ readonly signal: AbortSignal;
115
+ readonly bin: string | undefined;
116
+ private _pipelines;
117
+ private subscriptions;
118
+ private _routes;
119
+ private _command?;
120
+ private _env;
121
+ private _args;
122
+ constructor(log: Logger);
123
+ get opts(): Args;
124
+ get routes(): Routes;
125
+ get command(): string[] | undefined;
126
+ get env(): Record<string, string | undefined>;
127
+ init(): this;
128
+ poll(): Observable<Result<Pipeline>>;
129
+ protected withSecrets(secrets: Secrets): this;
144
130
  repr(): string;
145
131
  }
146
- declare abstract class HttpResponse implements ILoggable {
147
- private _status;
148
- private _headers;
149
- private _cookies;
150
- private _data;
151
- constructor(status: number, headers: HttpHeaders, cookies: string[], data: Readable);
152
- get status(): number;
153
- get headers(): HttpHeaders;
154
- get cookies(): string[];
155
- get data(): Readable;
156
- prelude(): {
157
- statusCode?: number;
158
- headers?: Record<string, unknown>;
159
- cookies?: string[];
160
- };
161
- withStatus(code: number): this;
162
- withHeader(key: string, value?: string): this;
163
- withHeaders(headers: HttpHeaders): this;
164
- withCookies(cookies: string[]): this;
165
- withData(data: Readable): this;
166
- abstract handle<P extends Pipeline>(proxy: HttpProxy<P>): Observable<HttpResponse>;
167
- abstract repr(): string;
168
- }
169
132
 
133
+ type IImageApi = {
134
+ getImage(req: Image['Req'], opts?: Image['Opts']['GET']): Observable<ApiSchema<Image['Req'], Image['Res']>>;
135
+ putImage(req: Image['Req'], opts?: Image['Opts']['PUT']): Observable<ApiSchema<Image['Req'], Image['Res']>>;
136
+ };
137
+ interface IRegistryApi {
138
+ getRegistry(req: Registry['Req']): Observable<ApiSchema<Registry['Req'], Registry['Res']>>;
139
+ }
170
140
  type ApiVersion = 'rowdy.run/v1alpha1';
171
- type ApiKind = 'Routes' | 'NotFound' | Health$1['kind'] | Image['kind'];
141
+ type ApiKind = 'Routes' | 'NotFound' | Health$1['kind'] | Image['kind'] | Registry['kind'];
172
142
  type ApiSchema<Spec, Status> = {
173
143
  apiVersion: ApiVersion;
174
144
  kind: ApiKind;
@@ -190,67 +160,71 @@ type Health$1 = {
190
160
  healthy: boolean;
191
161
  };
192
162
  };
193
- type Ref<T extends string> = Partial<{
194
- mediaType: T;
195
- size: number;
196
- digest: string;
197
- annotations: Record<string, string>;
198
- }>;
199
- type Config = Ref<'application/vnd.oci.image.config.v1+json'>;
200
- type Layer = Ref<'application/vnd.oci.image.layer.v1.tar+gzip' | 'application/vnd.oci.image.layer.v1.tar'>;
201
- type Manifest = Ref<'application/vnd.oci.image.manifest.v1+json'> & Partial<{
202
- platform: Partial<{
203
- architecture: string;
204
- os: string;
205
- }>;
206
- }>;
207
- type ImageManifest = Partial<{
208
- schemaVersion: number;
209
- mediaType: 'application/vnd.oci.image.manifest.v1+json';
210
- config: Config;
211
- layers: Layer[];
212
- }>;
213
- type IndexManifest = Partial<{
214
- schemaVersion: number;
215
- mediaType: 'application/vnd.oci.image.index.v1+json';
216
- manifests: Manifest[];
217
- }>;
163
+ type Registry = {
164
+ kind: 'Registry';
165
+ Req: {
166
+ registry?: string;
167
+ authorization?: string;
168
+ };
169
+ Res: ApiResponseStatus & {
170
+ registry: string;
171
+ authorization: string;
172
+ };
173
+ };
218
174
  type Image = {
219
175
  kind: 'Image';
220
- req: {
176
+ Req: {
221
177
  image: string | string[];
222
178
  };
223
- opts: {
224
- authorization?: string | undefined;
179
+ Opts: {
180
+ GET: {
181
+ authorization?: string;
182
+ };
183
+ PUT: Image['Opts']['GET'] & {
184
+ registry?: string;
185
+ };
225
186
  };
226
- res: ApiResponseStatus & {
187
+ Res: ApiResponseStatus & {
227
188
  registry: string;
228
189
  namespace: string;
229
190
  name: string;
230
191
  reference: string;
231
192
  tags: string[];
232
- index: IndexManifest;
233
- images: Record<string, ImageManifest>;
234
- blobs: (Ref<string> & {
193
+ index: Image['External']['ImageIndex'];
194
+ images: Record<string, Image['External']['ImageManifest']>;
195
+ blobs: (Image['External']['Ref'] & {
235
196
  platform: string;
236
197
  url: string;
237
198
  })[];
238
199
  };
200
+ External: {
201
+ Ref: Partial<{
202
+ mediaType: string;
203
+ size: number;
204
+ digest: string;
205
+ annotations: Record<string, string>;
206
+ }>;
207
+ Config: Image['External']['Ref'];
208
+ Layer: Image['External']['Ref'];
209
+ Manifest: Image['External']['Ref'] & Partial<{
210
+ platform: Partial<{
211
+ architecture: string;
212
+ os: string;
213
+ }>;
214
+ }>;
215
+ ImageIndex: Partial<{
216
+ schemaVersion: number;
217
+ mediaType: 'application/vnd.oci.image.index.v1+json' | 'application/vnd.docker.distribution.manifest.list.v2+json';
218
+ manifests: Image['External']['Manifest'][];
219
+ }>;
220
+ ImageManifest: Partial<{
221
+ schemaVersion: number;
222
+ mediaType: 'application/vnd.oci.image.manifest.v1+json' | 'application/vnd.docker.distribution.manifest.v2+json';
223
+ config: Image['External']['Config'];
224
+ layers: Image['External']['Layer'][];
225
+ }>;
226
+ };
239
227
  };
240
- declare class Api {
241
- private log;
242
- static readonly SLUG = "@rowdy";
243
- private proxy?;
244
- private axios;
245
- constructor(log: Logger);
246
- private routes;
247
- withProxy(proxy: HttpProxy<Pipeline>): this;
248
- health(): Observable<ApiSchema<Health$1['res'], ApiResponseStatus>>;
249
- image(req: Image['req'], opts?: Image['opts']): Observable<ApiSchema<Image['req'], Image['res']>>;
250
- handle(): Observable<ApiSchema<unknown, ApiResponseStatus>>;
251
- private handler;
252
- private notFound;
253
- }
254
228
 
255
229
  type RoutePaths = {
256
230
  [key: string]: string | undefined;
@@ -317,6 +291,95 @@ declare class Routes implements IRoutes, ILoggable {
317
291
  repr(): string;
318
292
  }
319
293
 
294
+ declare abstract class HttpProxy<P extends Pipeline> extends Proxy<P, HttpResponse> {
295
+ readonly method: string;
296
+ readonly uri: URI;
297
+ readonly headers: HttpHeaders;
298
+ readonly body: Buffer;
299
+ constructor(pipeline: P, request: Request<P>, method: string, uri: URI, headers: HttpHeaders, body: Buffer);
300
+ get httpsAgent(): Agent | undefined;
301
+ invoke(): Observable<HttpResponse>;
302
+ repr(): string;
303
+ }
304
+ declare class HttpHeaders implements ILoggable {
305
+ private headers;
306
+ private constructor();
307
+ get userAgent(): string;
308
+ proxy(): HttpHeaders;
309
+ static from(obj: Record<string, string | string[]>): HttpHeaders;
310
+ static fromAxios(axiosHeaders: Partial<AxiosHeaders | AxiosResponseHeaders>): HttpHeaders;
311
+ static fromLambda(headers: Partial<APIGatewayProxyEventV2['headers']>): HttpHeaders;
312
+ intoAxios(): AxiosHeaders;
313
+ intoJSON(): Record<string, unknown>;
314
+ override(key: string, value?: string | string[]): this;
315
+ repr(): string;
316
+ }
317
+ declare abstract class HttpResponse implements ILoggable {
318
+ private _status;
319
+ private _headers;
320
+ private _cookies;
321
+ private _data;
322
+ constructor(status: number, headers: HttpHeaders, cookies: string[], data: Readable);
323
+ get status(): number;
324
+ get headers(): HttpHeaders;
325
+ get cookies(): string[];
326
+ get data(): Readable;
327
+ prelude(): {
328
+ statusCode?: number;
329
+ headers?: Record<string, unknown>;
330
+ cookies?: string[];
331
+ };
332
+ withStatus(code: number): this;
333
+ withHeader(key: string, value?: string): this;
334
+ withHeaders(headers: HttpHeaders): this;
335
+ withCookies(cookies: string[]): this;
336
+ withData(data: Readable): this;
337
+ abstract handle<P extends Pipeline>(proxy: HttpProxy<P>): Observable<HttpResponse>;
338
+ abstract repr(): string;
339
+ }
340
+
341
+ declare class Rowdy {
342
+ readonly log: Logger;
343
+ static readonly SLUG = "@rowdy";
344
+ readonly http: AxiosInstance;
345
+ private _images;
346
+ private _registry;
347
+ private _proxy?;
348
+ constructor(log: Logger);
349
+ get Images(): IImageApi;
350
+ get Registry(): IRegistryApi;
351
+ get proxy(): HttpProxy<Pipeline>;
352
+ get environment(): Environment;
353
+ readonly routes: {
354
+ GET: ({
355
+ match: path_to_regexp.MatchFunction<never>;
356
+ handler: () => Observable<ApiSchema<Health$1["res"], ApiResponseStatus>>;
357
+ } | {
358
+ match: path_to_regexp.MatchFunction<{
359
+ image: string | string[];
360
+ }>;
361
+ handler: (req: Image["Req"], opts?: Image["Opts"]["GET"]) => Observable<ApiSchema<Image["Req"], Image["Res"]>>;
362
+ } | {
363
+ match: path_to_regexp.MatchFunction<{
364
+ registry?: string;
365
+ authorization?: string;
366
+ }>;
367
+ handler: (req: Registry["Req"]) => Observable<ApiSchema<Registry["Req"], Registry["Res"]>>;
368
+ })[];
369
+ PUT: {
370
+ match: path_to_regexp.MatchFunction<{
371
+ image: string | string[];
372
+ }>;
373
+ handler: (req: Image["Req"], opts?: Image["Opts"]["PUT"]) => Observable<ApiSchema<Image["Req"], Image["Res"]>>;
374
+ }[];
375
+ };
376
+ withProxy(proxy: HttpProxy<Pipeline>): this;
377
+ health(): Observable<ApiSchema<Health$1['res'], ApiResponseStatus>>;
378
+ handle(): Observable<ApiSchema<unknown, ApiResponseStatus>>;
379
+ private handler;
380
+ private notFound;
381
+ }
382
+
320
383
  declare const ABORT: AbortController;
321
384
 
322
- export { ABORT, Api, Logger, Routes, URI };
385
+ export { ABORT, Logger, Routes, Rowdy, URI };