@northflank/js-client 0.9.2 → 0.9.3-beta.0

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.
@@ -1,6 +1,7 @@
1
1
  import { EventEmitter } from 'events';
2
2
  import * as stream from 'node:stream';
3
3
  import { Stream } from 'node:stream';
4
+ import { ClientHttp2Session } from 'node:http2';
4
5
 
5
6
  type Optional<T, K extends keyof T> = Omit<T, K> & Partial<T>;
6
7
  declare abstract class ApiClientContextProvider {
@@ -419,6 +420,9 @@ declare class NorthflankPortForwarder extends EventEmitter {
419
420
  }
420
421
 
421
422
  interface ExecCommand extends EventEmitter {
423
+ readonly stdOut: stream.PassThrough;
424
+ readonly stdErr: stream.PassThrough;
425
+ readonly stdIn: stream.PassThrough;
422
426
  on(event: 'auth-success', listener: () => any): any;
423
427
  on(event: 'command-started', listener: () => any): any;
424
428
  on(event: 'command-completed', listener: () => any): any;
@@ -429,8 +433,15 @@ interface ExecCommand extends EventEmitter {
429
433
  on(event: 'error', listener: (error: any) => any): any;
430
434
  on(event: 'std-out-data', listener: (data: any) => any): any;
431
435
  on(event: 'std-err-data', listener: (data: any) => any): any;
436
+ waitForCommandResult: () => Promise<CommandResult>;
437
+ start: () => Promise<CommandResult>;
438
+ resizeTerminal: (size: {
439
+ rows?: number;
440
+ columns?: number;
441
+ }) => Promise<void>;
432
442
  }
433
-
443
+ declare const VALID_EXEC_LOCATIONS: readonly ["us", "eu", "asia"];
444
+ type ValidExecLocations = (typeof VALID_EXEC_LOCATIONS)[number];
434
445
  type ExecConfig = {
435
446
  teamId?: string;
436
447
  projectId: string;
@@ -446,7 +457,10 @@ type ExecConfig = {
446
457
  tty?: boolean;
447
458
  ttyRows?: number;
448
459
  ttyColumns?: number;
460
+ execLocationHint?: ValidExecLocations | undefined;
461
+ execLocationOverride?: string | undefined;
449
462
  };
463
+
450
464
  declare class ExecCommandStandard extends EventEmitter implements ExecCommand {
451
465
  private readonly baseUrl;
452
466
  readonly execConfig: ExecConfig;
@@ -456,7 +470,7 @@ declare class ExecCommandStandard extends EventEmitter implements ExecCommand {
456
470
  readonly stdErr: stream.PassThrough;
457
471
  readonly stdIn: stream.PassThrough;
458
472
  private remote;
459
- private currentCommand;
473
+ protected currentCommand: Promise<CommandResult> | undefined;
460
474
  private duplex;
461
475
  constructor(baseUrl: string, execConfig: ExecConfig, token: string, // readonly timeout: number = 120 // Timeout in seconds
462
476
  agent: any, stdOut?: stream.PassThrough, stdErr?: stream.PassThrough, stdIn?: stream.PassThrough);
@@ -486,6 +500,8 @@ type ExecCommandData = {
486
500
  shell?: string;
487
501
  user?: string | number;
488
502
  group?: string | number;
503
+ execLocationHint?: ValidExecLocations | undefined;
504
+ execLocationOverride?: string | undefined;
489
505
  };
490
506
  type ExecCommandDataAddon = ExecCommandData & {
491
507
  instanceName: string;
@@ -505,7 +521,15 @@ type CommandInfo = {
505
521
  declare class NorthflankExecCommand {
506
522
  private readonly contextProvider;
507
523
  private readonly agent?;
508
- constructor(contextProvider: ApiClientContextProvider, agent?: any | undefined);
524
+ protected sessionRegistry: Partial<Record<ValidExecLocations, ClientHttp2Session>>;
525
+ constructor(contextProvider: ApiClientContextProvider, agent?: any | undefined, prewarmExecLocations?: ValidExecLocations[]);
526
+ protected http2Session(opts: {
527
+ execLocationHint: ValidExecLocations;
528
+ execLocationOverride?: never;
529
+ } | {
530
+ execLocationOverride: string;
531
+ execLocationHint?: never;
532
+ }): any;
509
533
  /**
510
534
  * Runs command on a Northflank service and waits for completion returning command result and
511
535
  * standard output and standard error emitted during commmand execution.
@@ -528,7 +552,7 @@ declare class NorthflankExecCommand {
528
552
  teamId?: string;
529
553
  projectId: string;
530
554
  serviceId: string;
531
- }, data?: ExecSessionData, commandInitCompletedCallback?: (commandInfo: CommandInfo) => void): Promise<ExecCommandStandard>;
555
+ }, data?: ExecSessionData, commandInitCompletedCallback?: (commandInfo: CommandInfo) => void): Promise<ExecCommand>;
532
556
  /**
533
557
  * Runs command on a Northflank job and waits for completion returning command result and
534
558
  * standard output and standard error emitted during commmand execution.
@@ -551,7 +575,7 @@ declare class NorthflankExecCommand {
551
575
  teamId?: string;
552
576
  projectId: string;
553
577
  jobId: string;
554
- }, data?: ExecSessionData, commandInitCompletedCallback?: (commandInfo: CommandInfo) => void): Promise<ExecCommandStandard>;
578
+ }, data?: ExecSessionData, commandInitCompletedCallback?: (commandInfo: CommandInfo) => void): Promise<ExecCommand>;
555
579
  /**
556
580
  * Runs command on a Northflank job and waits for completion returning command result and
557
581
  * standard output and standard error emitted during commmand execution.
@@ -574,7 +598,7 @@ declare class NorthflankExecCommand {
574
598
  teamId?: string;
575
599
  projectId: string;
576
600
  addonId: string;
577
- }, data?: ExecSessionData, commandInitCompletedCallback?: (commandInfo: CommandInfo) => void): Promise<ExecCommandStandard>;
601
+ }, data?: ExecSessionData, commandInitCompletedCallback?: (commandInfo: CommandInfo) => void): Promise<ExecCommand>;
578
602
  private execCommand;
579
603
  private shellSession;
580
604
  private getCommandRunner;
@@ -594,6 +618,7 @@ type DownloadOptions = {
594
618
  containerName?: string;
595
619
  instanceName?: string;
596
620
  ignoreList?: string[];
621
+ execLocationHint?: ValidExecLocations;
597
622
  };
598
623
  type UploadOptions = {
599
624
  localPath: string;
@@ -601,6 +626,7 @@ type UploadOptions = {
601
626
  containerName?: string;
602
627
  instanceName?: string;
603
628
  ignoreList?: string[];
629
+ execLocationHint?: ValidExecLocations;
604
630
  };
605
631
  declare class NorthflankFileCopy {
606
632
  private readonly exec;