@netlify/content-engine
Version:
85 lines • 3.25 kB
TypeScript
import { IGatsbyNode } from "./redux/types";
import { ChildProcess } from "child_process";
import { GatsbyConfig } from "./types";
import { ExecutionResult } from "graphql";
import { IDataStore } from "./datastore/types";
export * from "./types";
export { setFrameworkHook } from "./framework-hooks/index";
export interface ContentEngineConfiguration {
directory?: string;
verbose?: boolean;
openTracingConfigFile?: string;
host?: string;
port?: number | string;
engineConfig?: GatsbyConfig;
env?: Record<string, string>;
frameworkHooks?: string;
printLogs?: false;
runInSubProcess?: boolean;
}
type InitializeOptions = {
clearCache?: boolean;
context?: Record<string, unknown>;
} & Pick<ContentEngineConfiguration, "env">;
type SyncOptions = InitializeOptions & {
runServer?: boolean;
webhookBody?: {
[key: string]: any;
};
connector?: string;
buildSchema?: true | boolean;
};
export interface SyncState {
exitCode?: number;
exited?: boolean;
error?: {
message: string;
stack: string;
};
}
export interface syncLedgerArgs {
dataLayerId: string;
sourcingConfigurationId: string;
cacheSourceVersionId: string;
blockVersionId?: string;
onAction?: (action: Record<string, any>) => void;
}
export interface DataStore extends Pick<IDataStore, "getNode" | "getTypes" | "countNodes" | "runQuery"> {
getNodes: IDataStore["iterateNodes"];
getNodesByType: IDataStore["iterateNodesByType"];
}
export interface ContentEngine {
sync: (options?: SyncOptions) => Promise<SyncState>;
startGraphQLServer: () => Promise<void>;
initialize: (options?: InitializeOptions) => Promise<void>;
restart: (options?: SyncOptions) => Promise<SyncState>;
stop: () => Promise<void>;
config: (config: ContentEngineConfiguration) => Promise<ContentEnginePublicAPI>;
onStdOut: (callback: (data: string) => void) => void;
onStdErr: (callback: (data: string) => void) => void;
onMessage: (callback: (message: any) => void) => void;
sendMessage: (message: any) => void;
clearListeners: () => void;
/**
* Test utils, only available when process.env.NODE_ENV === `test`
*/
test: {
query: <TData>(query: string, variables?: Record<string, unknown>, querySettings?: {
context?: Record<string, any>;
}) => Promise<ExecutionResult<TData>>;
getNodes: <NodeFields>() => Promise<Array<IGatsbyNode & NodeFields>>;
getNode: <NodeFields>(id: string) => Promise<IGatsbyNode & NodeFields>;
getNodesByType: <NodeFields>(type: string) => Promise<Array<IGatsbyNode & NodeFields>>;
};
query: (query: string, variables?: Record<string, unknown>, querySettings?: {
context?: Record<string, any>;
}) => Promise<any>;
store?: DataStore;
getProcess: () => ChildProcess;
buildSchema(): Promise<void>;
syncLedger: (args: syncLedgerArgs) => Promise<number>;
}
export type ContentEnginePublicAPI = ContentEngine;
export declare const contentEngine: (engineOptions?: ContentEngineConfiguration) => ContentEnginePublicAPI;
export declare function throwOutsideTestEnv<T>(fns: Record<string, any>): T;
//# sourceMappingURL=index.d.ts.map