Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(databox): stream output records as available
- Loading branch information
1 parent
a6f6ab4
commit a92da44
Showing
101 changed files
with
2,814 additions
and
1,471 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import ICrawlerOutputSchema from './ICrawlerOutputSchema'; | ||
|
||
export default interface ICrawlerComponents<TSchema, TContext, TDisableCache extends boolean = false> { | ||
name?: string; | ||
pricePerQuery?: number; | ||
addOnPricing?: { | ||
perKb?: never; | ||
}; | ||
minimumPrice?: number; | ||
schema?: TSchema; | ||
disableCache?: TDisableCache; | ||
run(context: TContext): Promise<{ toCrawlerOutput(): Promise<ICrawlerOutputSchema> }>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { string } from '@ulixee/schema'; | ||
|
||
export const CrawlerOutputSchema = { | ||
crawler: string({ description: 'The type of crawler output that has been produced.' }), | ||
version: string({ description: 'The semantic version of the crawler output.' }), | ||
sessionId: string({ | ||
description: 'A session id providing context for how to look up the assets', | ||
}), | ||
}; | ||
|
||
export default interface ICrawlerOutputSchema { | ||
crawler: string; | ||
version: string; | ||
sessionId: string; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,37 @@ | ||
import Crawler from '../lib/Crawler'; | ||
import Function from '../lib/Function'; | ||
import Table from '../lib/Table'; | ||
|
||
export default interface IDataboxComponents< | ||
TTable extends Table<any>, | ||
TFunction extends Function<any>, | ||
TTable extends TTables<any>, | ||
TFunction extends TFunctions<any>, | ||
TCrawler extends TCrawlers<any>, | ||
> { | ||
name?: string; | ||
description?: string; | ||
remoteDataboxes?: { [source: string]: string }; | ||
tables?: Record<string, TTable>; | ||
functions?: Record<string, TFunction>; | ||
tables?: TTable; | ||
functions?: TFunction; | ||
crawlers?: TCrawler; | ||
paymentAddress?: string; | ||
giftCardIssuerIdentity?: string; | ||
authenticateIdentity?(identity: string, nonce: string): Promise<boolean> | boolean; | ||
} | ||
|
||
export type TFunctions<T = any> = T extends Function | ||
? { | ||
[K in keyof T]: T[K]; | ||
} | ||
: never; | ||
|
||
export type TTables<T = any> = T extends Table | ||
? { | ||
[K in keyof T]: T[K]; | ||
} | ||
: never; | ||
|
||
export type TCrawlers<T = any> = T extends Crawler | ||
? { | ||
[K in keyof T]: T[K]; | ||
} | ||
: never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export default interface IDataboxEvents { | ||
'FunctionStream.output': { output: any }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { IAnySchemaJson } from '@ulixee/schema/interfaces/ISchemaJson'; | ||
import IFunctionComponents from './IFunctionComponents'; | ||
|
||
export default interface IDataboxMetadata { | ||
coreVersion: string; | ||
remoteDataboxes?: Record<string, string>; | ||
paymentAddress?: string; | ||
giftCardIssuerIdentity?: string; | ||
functionsByName: { | ||
[name: string]: { | ||
corePlugins: { [name: string]: string }; | ||
remoteFunction?: string; | ||
remoteSource?: string; | ||
remoteDataboxVersionHash?: string; | ||
} & Omit<IFunctionComponents<any, any>, 'run'>; | ||
}; | ||
crawlersByName: { | ||
[name: string]: { | ||
corePlugins: { [name: string]: string }; | ||
remoteFunction?: string; | ||
remoteSource?: string; | ||
remoteDataboxVersionHash?: string; | ||
} & Omit<IFunctionComponents<any, any>, 'run'>; | ||
}; | ||
tablesByName: { | ||
[name: string]: { | ||
schema: Record<string, IAnySchemaJson>; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,11 @@ | ||
import IFunctionSchema, { ExtractSchemaType } from './IFunctionSchema'; | ||
import Databox from '../lib/Databox'; | ||
import { IOutputClass } from '../lib/Output'; | ||
import IDataboxMetadata from './IDataboxMetadata'; | ||
|
||
export default interface IFunctionContext< | ||
ISchema extends IFunctionSchema, | ||
TOutput = ExtractSchemaType<ISchema['output']>, | ||
> { | ||
input?: ExtractSchemaType<ISchema['input']>; | ||
readonly outputs?: TOutput[]; | ||
readonly Output?: IOutputClass<TOutput>; | ||
schema?: ISchema; | ||
databox: Databox<any, any>; | ||
export default interface IFunctionContext<TSchema extends IFunctionSchema> { | ||
input?: ExtractSchemaType<TSchema['input']>; | ||
readonly outputs?: ExtractSchemaType<TSchema['output']>[]; | ||
readonly Output?: IOutputClass<ExtractSchemaType<TSchema['output']>>; | ||
schema?: TSchema; | ||
databoxMetadata: IDataboxMetadata; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,29 @@ | ||
import { DateUtilities, ExtractSchemaType, ISchemaAny, ObjectSchema } from '@ulixee/schema'; | ||
import { DateUtilities, ExtractSchemaType, ISchemaAny } from '@ulixee/schema'; | ||
|
||
export { ExtractSchemaType }; | ||
|
||
type IOutputType = Record<string, ISchemaAny> | ObjectSchema<any>; | ||
export type ISchemaRecordType<T> = T extends Record<string, ISchemaAny> | ||
? { | ||
[K in keyof T]: T[K]; | ||
} | ||
: never; | ||
|
||
export default interface IFunctionSchema< | ||
TInput extends Record<string, ISchemaAny> = Record<string, ISchemaAny>, | ||
TOutput extends IOutputType = IOutputType, | ||
TInput extends ISchemaRecordType<any> = ISchemaRecordType<any>, | ||
TOutput extends ISchemaRecordType<any> = ISchemaRecordType<any>, | ||
> { | ||
input?: TInput; | ||
output?: TOutput; | ||
inputExamples?: IInputSchemaType<this['input']>[]; | ||
} | ||
|
||
export const FunctionSchema = <TInput extends Record<string, ISchemaAny>, TOutput extends IOutputType>( | ||
export const FunctionSchema = < | ||
TInput extends ISchemaRecordType<any>, | ||
TOutput extends ISchemaRecordType<any>, | ||
>( | ||
schema: IFunctionSchema<TInput, TOutput>, | ||
): IFunctionSchema<TInput, TOutput> => schema; | ||
|
||
type IInputSchemaType<T extends Record<string, ISchemaAny>> = { | ||
type IInputSchemaType<T extends ISchemaRecordType<any>> = { | ||
[P in keyof T]?: T[P]['$type'] | DateUtilities; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
export default interface ITableComponents<TSchema> { | ||
export default interface ITableComponents<TSchema, TSeedlings> { | ||
name?: string; | ||
description?: string; | ||
schema: TSchema; | ||
seedlings?: any[]; | ||
seedlings?: TSeedlings[]; | ||
isPublic?: boolean; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,6 @@ | ||
import { | ||
ExtractSchemaType, | ||
ISchemaAny, | ||
} from '@ulixee/schema'; | ||
import { ExtractSchemaType, ISchemaAny } from '@ulixee/schema'; | ||
|
||
export { ExtractSchemaType }; | ||
|
||
type ITableSchema = Record<string, ISchemaAny>; | ||
export default ITableSchema; | ||
export default ITableSchema; |
Oops, something went wrong.