@evergis/api
Advanced tools
Comparing version 0.1.35 to 0.1.36
@@ -20,3 +20,3 @@ import { defaultApiConfig } from './defaultApiConfig'; | ||
this.projects = new Projects(config.Projects, this.http); | ||
this.resources = new Resources(this.projects, this.layers); | ||
this.resources = new Resources(this.projects, this.layers, this.tables); | ||
this.styles = new Styles(config.Styles, this.http); | ||
@@ -23,0 +23,0 @@ this.security = new Security(config.PostgresSecurityService, this.http); |
import { PostgresLayerServiceConfigurationDc, RemoteTileServiceConfigurationDc, ServiceListDc, StyledLayerServiceConfigurationDc, ServiceInfoDc, FileUploadResponse, ResourceDependenciesDc } from '../__generated__/data-contracts'; | ||
import { Layers as LayersService, GetLayersListParams } from '../__generated__/Layers'; | ||
import { ResourceService } from '../interfaces/ResourceService'; | ||
import { DependencyResource } from './Resources'; | ||
export declare class Layers extends LayersService implements ResourceService { | ||
@@ -25,5 +26,5 @@ getLayerInfos(layers: string[]): Promise<ServiceInfoDc[]>; | ||
deps: { | ||
tables: string[]; | ||
tables: DependencyResource[]; | ||
}; | ||
}; | ||
export {}; |
import { Projects as ProjectsService, GetProjectsListParams } from '../__generated__/Projects'; | ||
import { ExtendedProjectInfoDc, FileUploadResponse, ProjectContentItemDc, ProjectInfoDc, ResourceDependenciesDc } from '../__generated__/data-contracts'; | ||
import { ResourceService } from '../interfaces/ResourceService'; | ||
import { DependencyResource } from './Resources'; | ||
export declare class Projects extends ProjectsService implements ResourceService { | ||
@@ -18,5 +19,5 @@ getProjectInfos(projects: string[]): Promise<ExtendedProjectInfoDc[]>; | ||
deps: { | ||
layers: string[]; | ||
tables: string[]; | ||
layers: DependencyResource[]; | ||
tables: DependencyResource[]; | ||
}; | ||
}; |
@@ -0,10 +1,16 @@ | ||
import { ServiceInfoDc, TableInfoDc, ProjectInfoDc } from '../__generated__/data-contracts'; | ||
import { Projects, ProjectsWithDeps } from './Projects'; | ||
import { Layers, LayersWithDeps } from './Layers'; | ||
import { Tables } from './Tables'; | ||
export declare type DependencyResource = Partial<Pick<TableInfoDc | ServiceInfoDc | ProjectInfoDc, 'name' | 'alias' | 'owner'>>; | ||
export declare class Resources { | ||
private readonly projects; | ||
private readonly layers; | ||
constructor(projects: Projects, layers: Layers); | ||
private readonly tables; | ||
constructor(projects: Projects, layers: Layers, tables: Tables); | ||
getProjectInfosWithDeps(projects: string[]): Promise<ProjectsWithDeps>; | ||
getLayerInfosWithDeps(layers: string[]): Promise<LayersWithDeps>; | ||
private getDependencies; | ||
private getDependentNames; | ||
private getDependencyResources; | ||
} |
@@ -9,5 +9,6 @@ import { unique } from '../utils/unique'; | ||
export class Resources { | ||
constructor(projects, layers) { | ||
constructor(projects, layers, tables) { | ||
this.projects = projects; | ||
this.layers = layers; | ||
this.tables = tables; | ||
} | ||
@@ -17,16 +18,8 @@ async getProjectInfosWithDeps(projects) { | ||
const projectDeps = await this.projects.getProjectsDeps(projects); | ||
let tables = []; | ||
let layers = []; | ||
projectDeps.map(layerDep => { | ||
const deps = layerDep.dependencies || []; | ||
const layerNames = this.getDependentNames(deps, DependencyType.Layer); | ||
const tableNames = this.getDependentNames(deps, DependencyType.Table); | ||
layers.push(...layerNames); | ||
tables.push(...tableNames); | ||
}); | ||
const { layers, tables } = await this.getDependencies(projectDeps, true, true); | ||
return { | ||
projects: projectInfos, | ||
deps: { | ||
layers: layers.filter(unique), | ||
tables: tables.filter(unique), | ||
layers, | ||
tables, | ||
}, | ||
@@ -38,15 +31,31 @@ }; | ||
const layersDeps = await this.layers.getLayersDeps(layers); | ||
let tables = []; | ||
layersDeps.map(layerDep => { | ||
const deps = layerDep.dependencies || []; | ||
const tableNames = this.getDependentNames(deps, DependencyType.Table); | ||
tables.push(...tableNames); | ||
}); | ||
const { tables } = await this.getDependencies(layersDeps, false, true); | ||
return { | ||
layers: layerInfos, | ||
deps: { | ||
tables: tables.filter(unique), | ||
tables, | ||
}, | ||
}; | ||
} | ||
async getDependencies(resourceDeps, pickLayers, pickTables) { | ||
const { tables, layers } = resourceDeps.reduce((acc, layerDep) => { | ||
const deps = layerDep.dependencies || []; | ||
if (pickLayers) { | ||
const layerNames = this.getDependentNames(deps, DependencyType.Layer); | ||
acc.layers.push(...layerNames); | ||
} | ||
if (pickTables) { | ||
const tableNames = this.getDependentNames(deps, DependencyType.Table); | ||
acc.tables.push(...tableNames); | ||
} | ||
return acc; | ||
}, { | ||
tables: [], | ||
layers: [], | ||
}); | ||
return { | ||
tables: this.getDependencyResources(await this.tables.getTableInfos(tables.filter(unique))), | ||
layers: this.getDependencyResources(await this.layers.getLayerInfos(layers.filter(unique))), | ||
}; | ||
} | ||
getDependentNames(deps, depType) { | ||
@@ -58,3 +67,10 @@ return deps | ||
} | ||
getDependencyResources(resources) { | ||
return resources.map(resource => ({ | ||
name: resource.name, | ||
owner: resource.owner, | ||
alias: resource.alias, | ||
})); | ||
} | ||
} | ||
//# sourceMappingURL=Resources.js.map |
{ | ||
"name": "@evergis/api", | ||
"version": "0.1.35", | ||
"version": "0.1.36", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "author": "everpoint", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
257022
5510
173