mirror of
https://github.com/strapi/strapi.git
synced 2025-09-25 16:29:34 +00:00
creating getSchemas in the engine to manage caching schemas
This commit is contained in:
parent
8ae00e4b9e
commit
b86c6ee875
@ -614,6 +614,21 @@ class TransferEngine<
|
||||
}
|
||||
}
|
||||
|
||||
async #getSchemas() {
|
||||
if (this.#schema.source) {
|
||||
this.#schema.source = (await this.sourceProvider.getSchemas?.()) as SchemaMap;
|
||||
}
|
||||
|
||||
if (this.#schema.destination) {
|
||||
this.#schema.destination = (await this.destinationProvider.getSchemas?.()) as SchemaMap;
|
||||
}
|
||||
|
||||
return {
|
||||
sourceSchema: this.#schema.source,
|
||||
destinationSchema: this.#schema.destination,
|
||||
};
|
||||
}
|
||||
|
||||
async integrityCheck() {
|
||||
const sourceMetadata = await this.sourceProvider.getMetadata();
|
||||
const destinationMetadata = await this.destinationProvider.getMetadata();
|
||||
@ -625,12 +640,11 @@ class TransferEngine<
|
||||
);
|
||||
}
|
||||
|
||||
this.#schema.source = (await this.sourceProvider.getSchemas?.()) as SchemaMap;
|
||||
this.#schema.destination = (await this.destinationProvider.getSchemas?.()) as SchemaMap;
|
||||
const { sourceSchema, destinationSchema } = await this.#getSchemas();
|
||||
|
||||
try {
|
||||
if (this.#schema.source && this.#schema.destination) {
|
||||
this.#assertSchemasMatching(this.#schema.source, this.#schema.destination);
|
||||
if (sourceSchema && destinationSchema) {
|
||||
this.#assertSchemasMatching(sourceSchema, destinationSchema);
|
||||
}
|
||||
} catch (error) {
|
||||
// if this is a schema matching error, allow handlers to resolve it
|
||||
@ -762,7 +776,7 @@ class TransferEngine<
|
||||
new Transform({
|
||||
objectMode: true,
|
||||
transform: async (entity: IEntity, _encoding, callback) => {
|
||||
const schemas = this.#schema.destination;
|
||||
const { destinationSchema: schemas } = await this.#getSchemas();
|
||||
|
||||
if (!schemas) {
|
||||
return callback(null, entity);
|
||||
@ -803,7 +817,7 @@ class TransferEngine<
|
||||
new Transform({
|
||||
objectMode: true,
|
||||
transform: async (link: ILink, _encoding, callback) => {
|
||||
const schemas = this.#schema.destination;
|
||||
const { destinationSchema: schemas } = await this.#getSchemas();
|
||||
|
||||
if (!schemas) {
|
||||
return callback(null, link);
|
||||
|
Loading…
x
Reference in New Issue
Block a user