UNPKG

@themost/jspa

Version:
31 lines (28 loc) 1.36 kB
import { Args, TraceUtils, PathUtils } from '@themost/common'; import { EntityLoaderStrategy } from '@themost/jspa'; class DefaultEntityLoaderStrategy extends EntityLoaderStrategy { constructor(config) { super(config); const values = config.getSourceAt('settings/jspa/imports') || []; Args.check(Array.isArray(values), new Error('Invalid configuration. The persistent annotation imports, defined by `settings/jspa/imports`, must be an array of modules.')); // eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-return this.imports = values.map((id) => { if (/^(\.\/|\..\/)/.test(id)) { const executionPath = config.getExecutionPath(); if (executionPath) { TraceUtils.debug(`@themost/jspa Loading persistent types from relative module "${id}"`); return require(PathUtils.join(config.getExecutionPath(), id)); } } TraceUtils.debug(`@themost/jspa Loading persistent types from module "${id}"`); return require(id); }); // read imports this.readSync(); } getModelDefinition(name) { return super.getModelDefinition(name); } } export { DefaultEntityLoaderStrategy }; //# sourceMappingURL=index.esm.js.map