mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #55648 barnard59-core: complete Pipeline class hierarchy by @tpluscode
* feat: complete Pipeline class hierarchy * fix: build errors
This commit is contained in:
committed by
GitHub
parent
d92b1278d2
commit
8a456683f3
@@ -1,8 +1,11 @@
|
||||
import { createPipeline, defaultLogger, run } from 'barnard59-core';
|
||||
import Pipeline, { VariableMap } from "barnard59-core/lib/Pipeline";
|
||||
import { createPipeline, defaultLogger, run, VariableMap } from 'barnard59-core';
|
||||
import Pipeline, { Context } from 'barnard59-core/lib/Pipeline';
|
||||
import StreamObject from 'barnard59-core/lib/StreamObject';
|
||||
import { GraphPointer } from 'clownface';
|
||||
import { Logger } from 'winston';
|
||||
import LoaderRegistry = require('rdf-loaders-registry');
|
||||
import { LoaderRegistry } from 'rdf-loaders-registry';
|
||||
import * as Stream from 'readable-stream';
|
||||
import Step from 'barnard59-core/lib/Step';
|
||||
|
||||
function testCreatePipeline() {
|
||||
const ptr: GraphPointer = <any> {};
|
||||
@@ -75,3 +78,55 @@ function testAugmentedVariables(variables: VariableMap) {
|
||||
// $ExpectError
|
||||
const notBar: string = variables.get('bar');
|
||||
}
|
||||
|
||||
function testPipeline() {
|
||||
let basePath: string;
|
||||
let children: StreamObject[];
|
||||
let context: Context;
|
||||
let loaderRegistry: LoaderRegistry;
|
||||
let logger: Logger;
|
||||
let ptr: GraphPointer;
|
||||
let variables: VariableMap;
|
||||
let stream: Stream.Readable | Stream.Writable;
|
||||
|
||||
const pipeline: Pipeline = <any> {};
|
||||
|
||||
({
|
||||
basePath,
|
||||
children,
|
||||
context,
|
||||
logger,
|
||||
ptr,
|
||||
variables,
|
||||
stream,
|
||||
loaderRegistry
|
||||
} = pipeline);
|
||||
}
|
||||
|
||||
function testStep() {
|
||||
let basePath: string;
|
||||
let children: StreamObject[];
|
||||
let context: Context;
|
||||
let loaderRegistry: LoaderRegistry;
|
||||
let logger: Logger;
|
||||
let ptr: GraphPointer;
|
||||
let variables: VariableMap;
|
||||
let args: unknown[] | Record<string, any>;
|
||||
let operation: unknown;
|
||||
let stream: Stream.Readable | Stream.Writable;
|
||||
|
||||
const step: Step = <any> {};
|
||||
|
||||
({
|
||||
basePath,
|
||||
children,
|
||||
context,
|
||||
logger,
|
||||
ptr,
|
||||
variables,
|
||||
stream,
|
||||
args,
|
||||
operation,
|
||||
loaderRegistry
|
||||
} = step);
|
||||
}
|
||||
|
||||
2
types/barnard59-core/index.d.ts
vendored
2
types/barnard59-core/index.d.ts
vendored
@@ -7,7 +7,7 @@ import { Logger } from 'winston';
|
||||
import LoaderRegistry = require('rdf-loaders-registry');
|
||||
export { default as createPipeline } from './lib/factory/pipeline';
|
||||
export { default as run } from './lib/run';
|
||||
export { Variables } from './lib/Pipeline';
|
||||
export { Variables, VariableMap } from './lib/StreamObject';
|
||||
|
||||
interface DefaultLogger {
|
||||
console?: boolean;
|
||||
|
||||
35
types/barnard59-core/lib/Pipeline.d.ts
vendored
35
types/barnard59-core/lib/Pipeline.d.ts
vendored
@@ -1,27 +1,22 @@
|
||||
import { Stream } from "stream";
|
||||
import { Logger } from 'winston';
|
||||
import * as stream from "readable-stream";
|
||||
import StreamObject from "./StreamObject";
|
||||
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
export interface Variables {}
|
||||
export { Context } from './StreamObject';
|
||||
|
||||
type Keys = keyof Variables extends never ? string : keyof Variables;
|
||||
export default class Pipeline extends StreamObject {
|
||||
readable: boolean;
|
||||
readableObjectMode: boolean;
|
||||
writable: boolean;
|
||||
writableObjectMode: boolean;
|
||||
onInit: () => void;
|
||||
init: () => void;
|
||||
stream: stream.Readable | stream.Writable;
|
||||
|
||||
interface TypedMap extends Map<Keys, any> {
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
get<K extends keyof Variables>(key: K): Variables[typeof key];
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
set<K extends keyof Variables>(key: K, value: Variables[typeof key] | undefined): this;
|
||||
}
|
||||
get firstChild(): StreamObject;
|
||||
get lastChild(): StreamObject;
|
||||
|
||||
export type VariableMap = keyof Variables extends never ? Map<string, any> : TypedMap;
|
||||
|
||||
export interface Context {
|
||||
logger: Logger;
|
||||
variables: VariableMap;
|
||||
}
|
||||
|
||||
export default class Pipeline extends Stream {
|
||||
context: Context;
|
||||
destroy(err: Error): void;
|
||||
finish(): stream['push'];
|
||||
}
|
||||
|
||||
export {};
|
||||
|
||||
10
types/barnard59-core/lib/Step.d.ts
vendored
Normal file
10
types/barnard59-core/lib/Step.d.ts
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
import * as stream from 'readable-stream';
|
||||
import StreamObject from './StreamObject';
|
||||
|
||||
export default class Step extends StreamObject {
|
||||
args: unknown[] | Record<string, any>;
|
||||
operation: unknown;
|
||||
stream: stream.Readable | stream.Writable;
|
||||
}
|
||||
|
||||
export {};
|
||||
36
types/barnard59-core/lib/StreamObject.d.ts
vendored
Normal file
36
types/barnard59-core/lib/StreamObject.d.ts
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
import * as stream from 'readable-stream';
|
||||
import { GraphPointer } from 'clownface';
|
||||
import { LoaderRegistry } from 'rdf-loaders-registry';
|
||||
import { Logger } from 'winston';
|
||||
|
||||
// tslint:disable-next-line:no-empty-interface
|
||||
export interface Variables {}
|
||||
|
||||
type Keys = keyof Variables extends never ? string : keyof Variables;
|
||||
|
||||
interface TypedMap extends Map<Keys, any> {
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
get<K extends keyof Variables>(key: K): Variables[typeof key];
|
||||
// tslint:disable-next-line:no-unnecessary-generics
|
||||
set<K extends keyof Variables>(key: K, value: Variables[typeof key] | undefined): this;
|
||||
}
|
||||
|
||||
export type VariableMap = keyof Variables extends never ? Map<string, any> : TypedMap;
|
||||
|
||||
export interface Context {
|
||||
logger: Logger;
|
||||
variables: VariableMap;
|
||||
}
|
||||
|
||||
export default class StreamObject {
|
||||
basePath: string;
|
||||
children: StreamObject[];
|
||||
context: Context;
|
||||
loaderRegistry: LoaderRegistry;
|
||||
logger: Logger;
|
||||
ptr: GraphPointer;
|
||||
variables: VariableMap;
|
||||
stream?: stream.Readable | stream.Writable;
|
||||
}
|
||||
|
||||
export {};
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Logger } from 'winston';
|
||||
import { GraphPointer } from 'clownface';
|
||||
import LoaderRegistry = require('rdf-loaders-registry');
|
||||
import Pipeline, { VariableMap } from "../Pipeline";
|
||||
import { LoaderRegistry } from 'rdf-loaders-registry';
|
||||
import Pipeline from "../Pipeline";
|
||||
import { VariableMap } from '../..';
|
||||
|
||||
interface CreatePipeline {
|
||||
basePath: string;
|
||||
|
||||
3
types/barnard59/runner.d.ts
vendored
3
types/barnard59/runner.d.ts
vendored
@@ -1,7 +1,8 @@
|
||||
import { GraphPointer } from "clownface";
|
||||
import { Writable } from "stream";
|
||||
import { Logger } from 'winston';
|
||||
import Pipeline, { VariableMap } from 'barnard59-core/lib/Pipeline';
|
||||
import Pipeline from 'barnard59-core/lib/Pipeline';
|
||||
import { VariableMap } from 'barnard59-core';
|
||||
|
||||
interface Runner {
|
||||
finished: Promise<any>;
|
||||
|
||||
Reference in New Issue
Block a user