@onivoro/server-process 1.17.0 → 1.18.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.
Files changed (48) hide show
  1. package/README.md +3 -0
  2. package/{cjs → dist}/index.d.ts +8 -8
  3. package/dist/index.es.js +1352 -0
  4. package/dist/index.es.js.map +1 -0
  5. package/dist/index.js +1363 -0
  6. package/dist/index.js.map +1 -0
  7. package/{cjs → dist}/lib/docker.d.ts +9 -9
  8. package/{cjs → dist}/lib/exec-promise.d.ts +4 -4
  9. package/{cjs → dist}/lib/exec-rx-as-json.d.ts +2 -3
  10. package/dist/lib/exec-rx-as-lines.d.ts +2 -0
  11. package/{cjs → dist}/lib/exec-rx.d.ts +5 -5
  12. package/{cjs → dist}/lib/exec-rx.spec.d.ts +1 -1
  13. package/dist/lib/exit.d.ts +1 -0
  14. package/{cjs → dist}/lib/listen.d.ts +5 -5
  15. package/{cjs → dist}/lib/psql.d.ts +6 -6
  16. package/package.json +14 -9
  17. package/cjs/index.js +0 -19
  18. package/cjs/lib/docker.js +0 -14
  19. package/cjs/lib/exec-promise.js +0 -17
  20. package/cjs/lib/exec-rx-as-json.js +0 -8
  21. package/cjs/lib/exec-rx-as-lines.d.ts +0 -3
  22. package/cjs/lib/exec-rx-as-lines.js +0 -9
  23. package/cjs/lib/exec-rx.js +0 -19
  24. package/cjs/lib/exec-rx.spec.js +0 -21
  25. package/cjs/lib/exit.d.ts +0 -1
  26. package/cjs/lib/exit.js +0 -4
  27. package/cjs/lib/listen.js +0 -11
  28. package/cjs/lib/psql.js +0 -20
  29. package/mjs/index.d.ts +0 -8
  30. package/mjs/index.js +0 -8
  31. package/mjs/lib/docker.d.ts +0 -9
  32. package/mjs/lib/docker.js +0 -10
  33. package/mjs/lib/exec-promise.d.ts +0 -4
  34. package/mjs/lib/exec-promise.js +0 -13
  35. package/mjs/lib/exec-rx-as-json.d.ts +0 -3
  36. package/mjs/lib/exec-rx-as-json.js +0 -5
  37. package/mjs/lib/exec-rx-as-lines.d.ts +0 -3
  38. package/mjs/lib/exec-rx-as-lines.js +0 -6
  39. package/mjs/lib/exec-rx.d.ts +0 -5
  40. package/mjs/lib/exec-rx.js +0 -15
  41. package/mjs/lib/exec-rx.spec.d.ts +0 -1
  42. package/mjs/lib/exec-rx.spec.js +0 -19
  43. package/mjs/lib/exit.d.ts +0 -1
  44. package/mjs/lib/exit.js +0 -1
  45. package/mjs/lib/listen.d.ts +0 -5
  46. package/mjs/lib/listen.js +0 -8
  47. package/mjs/lib/psql.d.ts +0 -6
  48. package/mjs/lib/psql.js +0 -16
@@ -1,9 +0,0 @@
1
- /// <reference types="node" />
2
- import { ExecOptions } from "child_process";
3
- import { BaseEncodingOptions } from "fs";
4
- export declare class Docker {
5
- readonly containerName: string;
6
- readonly binaryName: string;
7
- constructor(containerName: string, binaryName: string);
8
- execRx(cmd: string, options?: BaseEncodingOptions & ExecOptions, emitStdErr?: boolean): import("rxjs").Observable<any>;
9
- }
package/mjs/lib/docker.js DELETED
@@ -1,10 +0,0 @@
1
- import { execRx } from "./exec-rx";
2
- export class Docker {
3
- constructor(containerName, binaryName) {
4
- this.containerName = containerName;
5
- this.binaryName = binaryName;
6
- }
7
- execRx(cmd, options, emitStdErr = true) {
8
- return execRx(`docker exec ${this.containerName} ${this.binaryName} ${cmd}`, options, emitStdErr);
9
- }
10
- }
@@ -1,4 +0,0 @@
1
- /// <reference types="node" />
2
- import { ExecOptions } from "child_process";
3
- import { BaseEncodingOptions } from 'fs';
4
- export declare function execPromise(cmd: string, options?: BaseEncodingOptions & ExecOptions): Promise<any>;
@@ -1,13 +0,0 @@
1
- import { exec } from "child_process";
2
- export function execPromise(cmd, options) {
3
- return new Promise((resolve, reject) => {
4
- exec(cmd, options, (err, stdout) => {
5
- if (err) {
6
- reject(err);
7
- }
8
- else {
9
- resolve(stdout.toString());
10
- }
11
- });
12
- });
13
- }
@@ -1,3 +0,0 @@
1
- /// <reference types="node" />
2
- import { ExecOptions } from 'child_process';
3
- export declare const execRxAsJson: (cmd: string, options?: ExecOptions | undefined, emitStdErr?: boolean) => import("rxjs").Observable<any>;
@@ -1,5 +0,0 @@
1
- import { map } from 'rxjs/operators';
2
- import { execRx } from './exec-rx';
3
- export const execRxAsJson = (cmd, options, emitStdErr = true) => {
4
- return execRx(cmd, options, emitStdErr).pipe(map((s) => JSON.parse(s)));
5
- };
@@ -1,3 +0,0 @@
1
- /// <reference types="node" />
2
- import { ExecOptions } from 'child_process';
3
- export declare const execRxAsLines: (cmd: string, options?: ExecOptions | undefined, emitStdErr?: boolean) => import("rxjs").Observable<string>;
@@ -1,6 +0,0 @@
1
- import { from } from 'rxjs';
2
- import { concatMap } from 'rxjs/operators';
3
- import { execRx } from './exec-rx';
4
- export const execRxAsLines = (cmd, options, emitStdErr = true) => {
5
- return execRx(cmd, options, emitStdErr).pipe(concatMap((s) => from(s.split('\n'))));
6
- };
@@ -1,5 +0,0 @@
1
- /// <reference types="node" />
2
- import { ExecOptions } from "child_process";
3
- import { BaseEncodingOptions } from 'fs';
4
- import { Observable } from "rxjs";
5
- export declare function execRx(cmd: string, options?: BaseEncodingOptions & ExecOptions, emitStdErr?: boolean): Observable<any>;
@@ -1,15 +0,0 @@
1
- import { exec } from "child_process";
2
- import { Observable } from "rxjs";
3
- export function execRx(cmd, options, emitStdErr = true) {
4
- return new Observable((observer) => {
5
- exec(cmd, options, (err, stdout, stderr) => {
6
- if (err) {
7
- observer.error(err);
8
- }
9
- else {
10
- observer.next(`${stdout}${emitStdErr && ` ${stderr}`}`);
11
- observer.complete();
12
- }
13
- });
14
- });
15
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,19 +0,0 @@
1
- import { execRx } from './exec-rx';
2
- import { of } from 'rxjs';
3
- import { catchError } from 'rxjs/operators';
4
- describe(execRx.name, () => {
5
- describe('GIVEN command succeeds', () => {
6
- it('returns the stdout', (done) => {
7
- execRx(`cat ${__filename}`).subscribe((d) => {
8
- expect(d).toEqual(expect.stringContaining('execRx worx!'));
9
- done();
10
- }, fail);
11
- });
12
- });
13
- describe('GIVEN command fails', () => {
14
- it('emits error', (done) => {
15
- execRx(`cat ${__filename + 'blah'}`).pipe(catchError(() => of(done())))
16
- .subscribe();
17
- });
18
- });
19
- });
package/mjs/lib/exit.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare const exit: (code: number) => () => never;
package/mjs/lib/exit.js DELETED
@@ -1 +0,0 @@
1
- export const exit = (code) => process.exit.bind(process, code);
@@ -1,5 +0,0 @@
1
- import { Subject } from 'rxjs';
2
- export declare const listen: () => {
3
- stdout: Subject<unknown>;
4
- stdin: Subject<unknown>;
5
- };
package/mjs/lib/listen.js DELETED
@@ -1,8 +0,0 @@
1
- import { Subject } from 'rxjs';
2
- const stdin = new Subject();
3
- const stdout = new Subject();
4
- export const listen = () => {
5
- process.stdin.on('data', d => stdin.next(d));
6
- process.stdin.on('close', () => stdin.complete());
7
- return { stdout, stdin };
8
- };
package/mjs/lib/psql.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export declare class PSql {
2
- readonly containerName: string;
3
- private container;
4
- constructor(containerName: string);
5
- execRx(cmd: string, db: string, username: string): import("rxjs").Observable<any>;
6
- }
package/mjs/lib/psql.js DELETED
@@ -1,16 +0,0 @@
1
- import { Docker } from "./docker";
2
- import { execRx } from "./exec-rx";
3
- const binaryName = 'psql';
4
- export class PSql {
5
- constructor(containerName) {
6
- this.containerName = containerName;
7
- this.container = new Docker(this.containerName, binaryName);
8
- }
9
- execRx(cmd, db, username) {
10
- const dbOptions = db ? ['-d', db] : [];
11
- const commonArgs = ['-qtAX', '-U', username, ...dbOptions, '-c'].join(' ') + cmd;
12
- return this.containerName
13
- ? this.container.execRx(commonArgs)
14
- : execRx([binaryName, commonArgs].join(' '));
15
- }
16
- }