@scaffoldly/rowdy 0.1.0-beta.20251029121749.6bd8f24 → 0.1.0-beta.20251107133750.a03c442

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 +32 -129
  2. package/dist/index.js +4289 -2560
  3. package/package.json +3 -3
package/dist/index.d.ts CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  import { Observable, ReplaySubject } from 'rxjs';
3
3
  import { AxiosInstance, AxiosHeaders, AxiosResponseHeaders } from 'axios';
4
- import * as path_to_regexp from 'path-to-regexp';
5
4
  import { PassThrough, Readable, Writable } from 'stream';
6
5
  import { GrpcRouter, GrpcResponse } from '@scaffoldly/rowdy-grpc';
7
6
  import { Agent } from 'https';
@@ -40,6 +39,8 @@ declare abstract class Pipeline implements ILoggable {
40
39
  readonly environment: Environment;
41
40
  private _createdAt;
42
41
  constructor(environment: Environment);
42
+ get name(): string;
43
+ get version(): string;
43
44
  get log(): Logger;
44
45
  get env(): Record<string, string | undefined>;
45
46
  get signal(): AbortSignal;
@@ -121,8 +122,12 @@ declare class Environment implements ILoggable {
121
122
  private _command?;
122
123
  private _env;
123
124
  private _args;
125
+ private _rowdy;
124
126
  constructor(log: Logger);
125
127
  get opts(): Args;
128
+ get name(): string;
129
+ get version(): string;
130
+ get rowdy(): Rowdy;
126
131
  get routes(): Routes;
127
132
  get command(): string[] | undefined;
128
133
  get env(): Record<string, string | undefined>;
@@ -132,105 +137,29 @@ declare class Environment implements ILoggable {
132
137
  repr(): string;
133
138
  }
134
139
 
135
- interface IImageApi {
136
- log: Logger;
140
+ type ApiVersion = 'rowdy.run/v1alpha1';
141
+ interface IApi {
137
142
  http: AxiosInstance;
138
- getImage(req: Image['Req'], opts?: Image['Opts']['GET']): Observable<ApiSchema<Image['Req'], Image['Res']>>;
139
- putImage(req: Image['Req'], opts?: Image['Opts']['PUT']): Observable<ApiSchema<Image['Req'], Image['Res']>>;
143
+ log: Logger;
144
+ environment: Environment | undefined;
140
145
  }
141
- interface IRegistryApi {
146
+ type PullImageOptions = {
147
+ authorization?: string;
148
+ registry?: string;
149
+ };
150
+ interface IImageApi {
142
151
  log: Logger;
143
152
  http: AxiosInstance;
144
- infer(): Observable<IRegistryApi>;
145
- getRegistry(req?: Registry['Req']): Observable<ApiSchema<Registry['Req'], Registry['Res']>>;
153
+ registry: Observable<TRegistry>;
154
+ pullImage(image: string, opts?: PullImageOptions): Observable<TPulledImage>;
146
155
  }
147
- type ApiVersion = 'rowdy.run/v1alpha1';
148
- type ApiKind = 'Routes' | 'NotFound' | 'BadRequest' | Health$1['kind'] | Image['kind'] | Registry['kind'];
149
- type ApiSchema<Spec, Status> = {
150
- apiVersion: ApiVersion;
151
- kind: ApiKind;
152
- spec?: Spec;
153
- status: Status;
156
+ type TPulledImage = {
157
+ image: string;
158
+ imageRef: string;
154
159
  };
155
- type ApiResponseStatus = {
156
- code: number;
157
- headers?: {
158
- [key: string]: string | string[];
159
- };
160
- reason?: string | undefined;
161
- };
162
- type Health$1 = {
163
- kind: 'Health';
164
- req: never;
165
- opts: never;
166
- res: {
167
- healthy: boolean;
168
- };
169
- };
170
- type Registry = {
171
- kind: 'Registry';
172
- Req: {
173
- registry?: string;
174
- authorization?: string;
175
- };
176
- Res: ApiResponseStatus & {
177
- registry: string;
178
- };
179
- };
180
- type Image = {
181
- kind: 'Image';
182
- Req: {
183
- image: string | string[];
184
- };
185
- Opts: {
186
- GET: {
187
- authorization?: string;
188
- };
189
- PUT: Image['Opts']['GET'] & {
190
- namepace?: string;
191
- registry?: string;
192
- };
193
- };
194
- Res: ApiResponseStatus & {
195
- registry: string;
196
- namespace: string;
197
- name: string;
198
- reference: string;
199
- tags: string[];
200
- index: Image['External']['ImageIndex'];
201
- images: Record<string, Image['External']['ImageManifest']>;
202
- blobs: (Image['External']['Ref'] & {
203
- platform: string;
204
- url: string;
205
- })[];
206
- };
207
- External: {
208
- Ref: Partial<{
209
- mediaType: string;
210
- size: number;
211
- digest: string;
212
- annotations: Record<string, string>;
213
- }>;
214
- Config: Image['External']['Ref'];
215
- Layer: Image['External']['Ref'];
216
- Manifest: Image['External']['Ref'] & Partial<{
217
- platform: Partial<{
218
- architecture: string;
219
- os: string;
220
- }>;
221
- }>;
222
- ImageIndex: Image['External']['Ref'] & Partial<{
223
- schemaVersion: number;
224
- mediaType: 'application/vnd.oci.image.index.v1+json' | 'application/vnd.docker.distribution.manifest.list.v2+json';
225
- manifests: Image['External']['Manifest'][];
226
- }>;
227
- ImageManifest: Image['External']['Manifest'] & Partial<{
228
- schemaVersion: number;
229
- mediaType: 'application/vnd.oci.image.manifest.v1+json' | 'application/vnd.docker.distribution.manifest.v2+json';
230
- config: Image['External']['Config'];
231
- layers: Image['External']['Layer'][];
232
- }>;
233
- };
160
+ type TRegistry = {
161
+ registry: string;
162
+ authorization?: string;
234
163
  };
235
164
 
236
165
  type RoutePaths = {
@@ -310,6 +239,7 @@ declare abstract class HttpProxy<P extends Pipeline> extends Proxy<P, HttpRespon
310
239
  readonly body: Buffer;
311
240
  readonly source: Source;
312
241
  constructor(pipeline: P, request: Request<P>, method: string, uri: URI, headers: HttpHeaders, body: Buffer, source: Source);
242
+ get environment(): Environment;
313
243
  get httpsAgent(): Agent | undefined;
314
244
  invoke(): Observable<HttpResponse>;
315
245
  repr(): string;
@@ -320,22 +250,24 @@ declare class HttpHeaders implements ILoggable {
320
250
  get userAgent(): string;
321
251
  get(header: string): string | string[] | undefined;
322
252
  proxy(): HttpHeaders;
323
- static from(obj: Record<string, string | string[]>): HttpHeaders;
253
+ static from(obj: Record<string, string | string[] | undefined | null>): HttpHeaders;
324
254
  static fromHeaders(headers: Headers): HttpHeaders;
325
255
  static fromAxios(axiosHeaders: Partial<AxiosHeaders | AxiosResponseHeaders>): HttpHeaders;
326
256
  static fromLambda(headers: Partial<APIGatewayProxyEventV2['headers']>): HttpHeaders;
327
257
  intoAxios(): AxiosHeaders;
328
258
  intoJSON(): Record<string, unknown>;
329
259
  intoHeaders(): Headers;
330
- override(key: string, value?: string | string[]): this;
260
+ override(key: string, value?: string | string[] | undefined): this;
331
261
  repr(): string;
332
262
  }
333
263
  declare abstract class HttpResponse implements ILoggable {
264
+ protected environment: Environment;
334
265
  private _status;
335
266
  private _headers;
336
267
  private _cookies;
337
268
  private _data;
338
- constructor(status: number, headers: HttpHeaders, cookies: string[], data: Readable);
269
+ constructor(environment: Environment, status: number, headers: HttpHeaders, cookies: string[], data: Readable);
270
+ get rowdy(): Rowdy;
339
271
  get status(): number;
340
272
  get headers(): HttpHeaders;
341
273
  get cookies(): string[];
@@ -354,13 +286,12 @@ declare abstract class HttpResponse implements ILoggable {
354
286
  abstract repr(): string;
355
287
  }
356
288
 
357
- declare class Rowdy {
289
+ declare class Rowdy implements IApi {
358
290
  readonly log: Logger;
359
291
  readonly signal: AbortSignal;
360
292
  static readonly SLUG = "@rowdy";
361
293
  static readonly ERROR = "error";
362
294
  static readonly HTTP = "http";
363
- static readonly API = "api";
364
295
  static readonly CRI = "cri";
365
296
  static readonly HEALTH = "health";
366
297
  static readonly PING = "ping";
@@ -370,42 +301,14 @@ declare class Rowdy {
370
301
  };
371
302
  readonly http: AxiosInstance;
372
303
  private _images;
373
- private _registry;
374
304
  private _proxy?;
375
305
  constructor(log: Logger, signal: AbortSignal);
376
- get Images(): IImageApi;
377
- get Registry(): IRegistryApi;
306
+ get images(): IImageApi;
307
+ get registry(): Observable<TRegistry>;
378
308
  get proxy(): HttpProxy<Pipeline> | undefined;
379
309
  get environment(): Environment | undefined;
380
- readonly routes: {
381
- GET: ({
382
- match: path_to_regexp.MatchFunction<never>;
383
- handler: () => Observable<ApiSchema<Health$1["res"], ApiResponseStatus>>;
384
- } | {
385
- match: path_to_regexp.MatchFunction<{
386
- image: string | string[];
387
- }>;
388
- handler: (req: Image["Req"], opts?: Image["Opts"]["GET"]) => Observable<ApiSchema<Image["Req"], Image["Res"]>>;
389
- } | {
390
- match: path_to_regexp.MatchFunction<{
391
- registry?: string;
392
- authorization?: string;
393
- }>;
394
- handler: (req?: Registry["Req"]) => Observable<ApiSchema<Registry["Req"], Registry["Res"]>>;
395
- })[];
396
- PUT: {
397
- match: path_to_regexp.MatchFunction<{
398
- image: string | string[];
399
- }>;
400
- handler: (req: Image["Req"], opts?: Image["Opts"]["PUT"]) => Observable<ApiSchema<Image["Req"], Image["Res"]>>;
401
- }[];
402
- };
403
310
  withProxy(proxy: HttpProxy<Pipeline>): this;
404
- health(): Observable<ApiSchema<Health$1['res'], ApiResponseStatus>>;
405
311
  cri(proxy: HttpProxy<Pipeline>): Observable<GrpcResponse>;
406
- api(): Observable<ApiSchema<unknown, ApiResponseStatus>>;
407
- private notFound;
408
- private badRequest;
409
312
  }
410
313
 
411
314
  declare const ABORT: AbortController;