mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
fix: import resource imporements
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
import { Knex } from 'knex';
|
||||
import * as Yup from 'yup';
|
||||
import { ImportableContext } from './interfaces';
|
||||
|
||||
export abstract class Importable {
|
||||
/**
|
||||
@@ -13,6 +15,16 @@ export abstract class Importable {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Transformes the DTO before passing it to importable and validation.
|
||||
* @param {Record<string, any>} createDTO
|
||||
* @param {ImportableContext} context
|
||||
* @returns {Record<string, any>}
|
||||
*/
|
||||
public transform(createDTO: Record<string, any>, context: ImportableContext) {
|
||||
return createDTO;
|
||||
}
|
||||
|
||||
/**
|
||||
* Concurrency controlling of the importing process.
|
||||
* @returns {number}
|
||||
@@ -20,4 +32,41 @@ export abstract class Importable {
|
||||
public get concurrency() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the sample data of importable.
|
||||
* @returns {Array<any>}
|
||||
*/
|
||||
public sampleData(): Array<any> {
|
||||
return [];
|
||||
}
|
||||
|
||||
// ------------------
|
||||
// # Params
|
||||
// ------------------
|
||||
/**
|
||||
* Params Yup validation schema.
|
||||
* @returns {Yup.ObjectSchema<object, object>}
|
||||
*/
|
||||
public paramsValidationSchema(): Yup.ObjectSchema<object, object> {
|
||||
return Yup.object().nullable();
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the params of the importable service.
|
||||
* @param {Record<string, any>}
|
||||
* @returns {Promise<boolean>} - True means passed and false failed.
|
||||
*/
|
||||
public async validateParams(
|
||||
tenantId: number,
|
||||
params: Record<string, any>
|
||||
): Promise<void> {}
|
||||
|
||||
/**
|
||||
* Transformes the import params before storing them.
|
||||
* @param {Record<string, any>} parmas
|
||||
*/
|
||||
public transformParams(parmas: Record<string, any>) {
|
||||
return parmas;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user