move types to types file

This commit is contained in:
Ben Irvin 2023-05-08 16:56:38 +02:00
parent d81966f5b6
commit e68a233820
2 changed files with 19 additions and 14 deletions

View File

@ -22,6 +22,9 @@ import type {
IProvider,
TransferFilters,
TransferFilterPreset,
SchemaDiffHandler,
SchemaMap,
Middleware,
} from '../../types';
import type { Diff } from '../utils/json';
@ -76,14 +79,6 @@ export const TransferGroupPresets: TransferGroupFilter = {
},
};
export const DEFAULT_VERSION_STRATEGY = 'ignore';
export const DEFAULT_SCHEMA_STRATEGY = 'strict';
type SchemaMap = Record<string, Schema>;
// Error resolving handler middleware for the transfer engine
type Next = (context: any) => void | Promise<void>;
type Middleware<T> = (context: T, next: Next) => Promise<void> | void;
async function runMiddleware<T>(context: T, middlewares: Middleware<T>[]): Promise<void> {
if (!middlewares.length) {
return;
@ -93,12 +88,9 @@ async function runMiddleware<T>(context: T, middlewares: Middleware<T>[]): Promi
await runMiddleware(newContext, middlewares.slice(1));
});
}
type SchemaDiffHandlerContext = {
diffs: Record<string, Diff[]>;
source: ISourceProvider;
destination: IDestinationProvider;
};
type SchemaDiffHandler = (data: SchemaDiffHandlerContext, next: SchemaDiffHandler) => void;
export const DEFAULT_VERSION_STRATEGY = 'ignore';
export const DEFAULT_SCHEMA_STRATEGY = 'strict';
/**
* Transfer Engine Class

View File

@ -5,6 +5,19 @@ import type { DiagnosticReporter } from '../src/engine/diagnostic';
export type TransferFilterPreset = 'content' | 'files' | 'config';
type SchemaMap = Record<string, Schema>;
// Error resolving handler middleware for the transfer engine
export type Next = (context: any) => void | Promise<void>;
export type Middleware<T> = (context: T, next: Next) => Promise<void> | void;
export type SchemaDiffHandlerContext = {
diffs: Record<string, Diff[]>;
source: ISourceProvider;
destination: IDestinationProvider;
};
export type SchemaDiffHandler = (data: SchemaDiffHandlerContext, next: SchemaDiffHandler) => void;
/**
* Defines the capabilities and properties of the transfer engine
*/