import { Flow as FlowDefinition, NodeDefinition, NodeDefinitions } from '@chix/common'; import { NodeDefinitionLocationFS } from './fs'; import { LoaderResponse } from './interfaces'; import { Loader } from './loader'; import { BaseNodeDefinitionLocation } from './types'; export interface LoadUrlEvent { url: string; } export declare type LoadNodeResult = { providerLocation: string; nodeDef: NodeDefinition; }; export declare type PreloadResult = { provider: string; nodeDefinitions: NodeDefinitions; }; export declare type PreloadConfig = { provider: string; collection: string; }; export interface NodeDefinitionLocationRemote extends BaseNodeDefinitionLocation { url: string; } export declare class RemoteLoader extends Loader { defaultProvider: string; workload: never[]; headers: { Authorization: string; }; /** * * Just load the whole map. * All remote needs is the providers sections and the nodes. * * Use `update` whenever you expect subflows or nodeDefinitions * have changed changed. * * @param {FlowDefinition[] | FlowDefinition} flows * @param {Boolean} update * @param {Object} dependencies */ load(flows: FlowDefinition[] | FlowDefinition, update?: boolean): Promise; /** * Preloads all definitions at a providers location. * * From a remote api this is relatively easy, * It also understands the filesystem in which case we just use globbing * * For a remote api we can assume the structure is just correct. * * But for the file system some extra checks are made to ensure what we * are loading are actually component definitions. * * This method is used to prefill our loader, which means it will * hold more definitions then our registered nodes need. * * In that matter, a clean unused definitions would be handy. * * Provider is in the form of: * * - http://serve.chix.io/nodes/{ns}/{name} * - ./nodes/{ns}/{name}.json * - /var/lib/chix/nodes/{ns}/{name}.fbp * * An optional second parameter can give a full url at which *all* definitions can be loaded. * * e.g. http://serve.chix.io/nodes * * For loading from the filesystem, it's just interpolated. * * @param {Object} config * @param {String} config.provider provider url * @param {String} config.collection endpoint to get full collection */ preload(config: PreloadConfig): Promise; _loadRemote(flows: FlowDefinition[], update?: boolean): Promise; /** * * Remote loader does not store it's definitions * */ saveNodeDefinition(_providerLocation: string, _nodeDefinition: NodeDefinition): void; /** * Loads the node * * Either remote, if there is an url property. * Or else tries to load the file if there is a path property. * * const d = { * url: || path: - the location * providerLocation: - provider url * } * * url & path is just the provider url with it's variables filled in. * * @param {object} d * @param {Function} cb */ loadNode(location: NodeDefinitionLocationFS | NodeDefinitionLocationRemote): Promise; loadFile(_location: any): Promise; /** * * Loads a nodeDefinition URL * * @param {NodeDefinitionLocationRemote} location */ loadUrl(location: NodeDefinitionLocationRemote): Promise; }