mirror of
https://github.com/strapi/strapi.git
synced 2025-09-17 20:40:17 +00:00
fix comments
This commit is contained in:
parent
e6efa4681a
commit
6fdc3c99fd
@ -23,6 +23,7 @@ import type {
|
||||
TransferFilters,
|
||||
TransferFilterPreset,
|
||||
SchemaDiffHandler,
|
||||
SchemaDiffHandlerContext,
|
||||
SchemaMap,
|
||||
} from '../../types';
|
||||
import type { Diff } from '../utils/json';
|
||||
@ -30,11 +31,7 @@ import type { Diff } from '../utils/json';
|
||||
import { compareSchemas, validateProvider } from './validation';
|
||||
import { filter, map } from '../utils/stream';
|
||||
|
||||
import {
|
||||
TransferEngineError,
|
||||
TransferEngineInitializationError,
|
||||
TransferEngineValidationError,
|
||||
} from './errors';
|
||||
import { TransferEngineError, TransferEngineValidationError } from './errors';
|
||||
import {
|
||||
createDiagnosticReporter,
|
||||
IDiagnosticReporter,
|
||||
@ -98,8 +95,6 @@ class TransferEngine<
|
||||
|
||||
#metadata: { source?: IMetadata; destination?: IMetadata } = {};
|
||||
|
||||
#ignoredDiffs: Record<string, utils.json.Diff[]> = {};
|
||||
|
||||
// Progress of the current stage
|
||||
progress: {
|
||||
// metrics on the progress such as size and record count
|
||||
@ -556,7 +551,7 @@ class TransferEngine<
|
||||
if (!this.#currentStream) {
|
||||
throw err;
|
||||
}
|
||||
this.#currentStream?.destroy(err);
|
||||
this.#currentStream.destroy(err);
|
||||
}
|
||||
|
||||
async init(): Promise<void> {
|
||||
@ -640,20 +635,29 @@ class TransferEngine<
|
||||
if (error instanceof TransferEngineValidationError && error.details?.details?.diffs) {
|
||||
const schemaDiffs = error.details?.details?.diffs as Record<string, Diff[]>;
|
||||
|
||||
const context = {
|
||||
ignoreDiffs: {},
|
||||
const context: SchemaDiffHandlerContext = {
|
||||
ignoredDiffs: {},
|
||||
diffs: schemaDiffs,
|
||||
source: this.sourceProvider,
|
||||
destination: this.destinationProvider,
|
||||
};
|
||||
|
||||
await runMiddleware<typeof context>(context, this.#handlers.schemaDiff);
|
||||
// if we don't have any handlers, throw the original error
|
||||
if (isEmpty(this.#handlers.schemaDiff)) {
|
||||
throw error;
|
||||
}
|
||||
|
||||
this.#ignoredDiffs = context.ignoreDiffs;
|
||||
await runMiddleware<SchemaDiffHandlerContext>(context, this.#handlers.schemaDiff);
|
||||
|
||||
// if there are any remaining diffs that weren't ignored
|
||||
if (utils.json.diff(context.diffs, this.#ignoredDiffs).length) {
|
||||
this.panic(new TransferEngineInitializationError('Unresolved differences in schema'));
|
||||
const unresolvedDiffs = utils.json.diff(context.diffs, context.ignoredDiffs);
|
||||
if (unresolvedDiffs.length) {
|
||||
this.panic(
|
||||
new TransferEngineValidationError('Unresolved differences in schema', {
|
||||
check: 'schema.changes',
|
||||
unresolvedDiffs,
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
return;
|
||||
|
@ -8,15 +8,16 @@ export type TransferFilterPreset = 'content' | 'files' | 'config';
|
||||
type SchemaMap = Record<string, Schema>;
|
||||
|
||||
// Error resolving handler middleware for the transfer engine
|
||||
export type Next<T> = (context: T) => void | Promise<void>;
|
||||
export type Middleware<T> = (context: T, next: Next) => Promise<void> | void;
|
||||
export type NextMiddleware<T> = (context: T) => void | Promise<void>;
|
||||
export type Middleware<T> = (context: T, next: NextMiddleware<T>) => Promise<void> | void;
|
||||
|
||||
export type SchemaDiffHandlerContext = {
|
||||
ignoredDiffs: Record<string, Diff[]>;
|
||||
diffs: Record<string, Diff[]>;
|
||||
source: ISourceProvider;
|
||||
destination: IDestinationProvider;
|
||||
};
|
||||
export type SchemaDiffHandler = (data: SchemaDiffHandlerContext, next: SchemaDiffHandler) => void;
|
||||
export type SchemaDiffHandler = Middleware<SchemaDiffHandlerContext>;
|
||||
|
||||
/**
|
||||
* Defines the capabilities and properties of the transfer engine
|
||||
|
@ -334,7 +334,7 @@ const getDiffHandler = (engine, { force }) => {
|
||||
setSignalHandler(() => abortTransfer({ engine, strapi }));
|
||||
|
||||
if (confirmed) {
|
||||
context.ignoreDiffs = merge(context.diffs, context.ignoredDiffs);
|
||||
context.ignoredDiffs = merge(context.diffs, context.ignoredDiffs);
|
||||
}
|
||||
|
||||
return next(context);
|
||||
|
Loading…
x
Reference in New Issue
Block a user