@evergis/api
Advanced tools
Comparing version 0.1.23 to 0.1.24
@@ -1,2 +0,2 @@ | ||
import { PostgresLayerServiceConfigurationDc, RemoteTileServiceConfigurationDc, ServiceListDc, StyledLayerServiceConfigurationDc, ServiceInfoDc, FileUploadResponse } from '../__generated__/data-contracts'; | ||
import { PostgresLayerServiceConfigurationDc, RemoteTileServiceConfigurationDc, ServiceListDc, StyledLayerServiceConfigurationDc, ServiceInfoDc, FileUploadResponse, ResourceDependenciesDc } from '../__generated__/data-contracts'; | ||
import { Layers as LayersService, GetLayersListParams } from '../__generated__/Layers'; | ||
@@ -6,2 +6,3 @@ import { ResourceService } from '../interfaces/ResourceService'; | ||
getLayerInfos(layers: string[]): Promise<ServiceInfoDc[]>; | ||
getLayersDeps(layers: string[]): Promise<ResourceDependenciesDc[]>; | ||
getBasemaps(params: GetListParams): Promise<ServiceListDc>; | ||
@@ -15,3 +16,3 @@ createSubLayer(configuration: StyledLayerServiceConfigurationDc): Promise<import("../__generated__/data-contracts").FeatureLayerServiceInfoDc>; | ||
update(configuration: PostgresLayerServiceConfigurationDc): Promise<import("../__generated__/data-contracts").FeatureLayerServiceInfoDc>; | ||
remove(name: string): Promise<void>; | ||
remove(name: string): Promise<string>; | ||
} | ||
@@ -18,0 +19,0 @@ export declare function isTileLayerService(layer: ServiceInfoDc): boolean | "" | undefined; |
@@ -8,2 +8,5 @@ import { Layers as LayersService, } from '../__generated__/Layers'; | ||
} | ||
getLayersDeps(layers) { | ||
return promiseAllIgnoreErrors(layers.map(layer => this.getResourceDependencies(layer))); | ||
} | ||
getBasemaps(params) { | ||
@@ -45,4 +48,5 @@ return this.getLayersList({ | ||
} | ||
remove(name) { | ||
return this.deleteResource(name); | ||
async remove(name) { | ||
await this.deleteResource(name); | ||
return name; | ||
} | ||
@@ -49,0 +53,0 @@ } |
import { Projects as ProjectsService, GetProjectsListParams } from '../__generated__/Projects'; | ||
import { ExtendedProjectInfoDc, FileUploadResponse, ProjectContentItemDc, ProjectInfoDc } from '../__generated__/data-contracts'; | ||
import { ExtendedProjectInfoDc, FileUploadResponse, ProjectContentItemDc, ProjectInfoDc, ResourceDependenciesDc } from '../__generated__/data-contracts'; | ||
import { ResourceService } from '../interfaces/ResourceService'; | ||
export declare class Projects extends ProjectsService implements ResourceService { | ||
getProjectInfos(projects: string[]): Promise<ExtendedProjectInfoDc[]>; | ||
getProjectsDeps(proejcts: string[]): Promise<ResourceDependenciesDc[]>; | ||
uploadPreview(name: string, file: File): Promise<FileUploadResponse>; | ||
@@ -11,3 +12,3 @@ findOne(name: string): Promise<ExtendedProjectInfoDc>; | ||
update(resource: ExtendedProjectInfoDc): Promise<ExtendedProjectInfoDc>; | ||
remove(name: string): Promise<void>; | ||
remove(name: string): Promise<string>; | ||
} | ||
@@ -14,0 +15,0 @@ export declare function isProjectContentItems(v: ProjectContentItemDc[] | undefined | null): v is ProjectContentItemDc[]; |
@@ -8,2 +8,5 @@ import { Projects as ProjectsService, } from '../__generated__/Projects'; | ||
} | ||
getProjectsDeps(proejcts) { | ||
return promiseAllIgnoreErrors(proejcts.map(project => this.getResourceDependencies(project))); | ||
} | ||
uploadPreview(name, file) { | ||
@@ -24,4 +27,5 @@ return this.setPreview({ name, file: formDataFromFile(file) }); | ||
} | ||
remove(name) { | ||
return this.deleteResource(name); | ||
async remove(name) { | ||
await this.deleteResource(name); | ||
return name; | ||
} | ||
@@ -28,0 +32,0 @@ } |
import { Projects, ProjectsWithDeps } from './Projects'; | ||
import { Layers, LayersWithDeps } from './Layers'; | ||
import { ProjectInfoDc, ServiceInfoDc, TableInfoDc } from '../__generated__/data-contracts'; | ||
export declare class Resources { | ||
@@ -10,3 +9,3 @@ private readonly projects; | ||
getLayerInfosWithDeps(layers: string[]): Promise<LayersWithDeps>; | ||
private getDependentNames; | ||
} | ||
export declare function isEditableResource(resource: ProjectInfoDc | ServiceInfoDc | TableInfoDc): boolean; |
@@ -1,5 +0,8 @@ | ||
import { isProjectContentItems } from './Projects'; | ||
import { isTileLayerService } from './Layers'; | ||
import { unique } from '../utils/unique'; | ||
import { isString } from '../utils/isString'; | ||
import { unique } from '../utils/unique'; | ||
var DependencyType; | ||
(function (DependencyType) { | ||
DependencyType["Layer"] = "Service"; | ||
DependencyType["Table"] = "Table"; | ||
})(DependencyType || (DependencyType = {})); | ||
export class Resources { | ||
@@ -12,18 +15,17 @@ constructor(projects, layers) { | ||
const projectInfos = await this.projects.getProjectInfos(projects); | ||
const layersInProjects = projectInfos | ||
.map(projectInfo => projectInfo.content && projectInfo.content.items) | ||
.filter(isProjectContentItems) | ||
.flat() | ||
.map(({ name }) => name) | ||
.filter(isString) | ||
.filter(unique); | ||
const layerInfos = await this.getLayerInfosWithDeps(layersInProjects); | ||
const editableLayers = layerInfos.layers.filter(layer => isEditableResource(layer) && !isTileLayerService(layer)); | ||
const layersDeps = editableLayers.map(({ name }) => name).filter(isString); | ||
const tables = layerInfos.deps.tables; | ||
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); | ||
}); | ||
return { | ||
projects: projectInfos, | ||
deps: { | ||
layers: layersDeps, | ||
tables, | ||
layers: layers.filter(unique), | ||
tables: tables.filter(unique), | ||
}, | ||
@@ -34,15 +36,23 @@ }; | ||
const layerInfos = await this.layers.getLayerInfos(layers); | ||
// TODO до конца августа обещали сделать в spcore получение информации о связанных со слоями таблицах | ||
const tables = []; | ||
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); | ||
}); | ||
return { | ||
layers: layerInfos, | ||
deps: { | ||
tables, | ||
tables: tables.filter(unique), | ||
}, | ||
}; | ||
} | ||
getDependentNames(deps, depType) { | ||
return deps | ||
.filter(({ type }) => type === depType) | ||
.map(({ name }) => name) | ||
.filter(isString); | ||
} | ||
} | ||
export function isEditableResource(resource) { | ||
return resource.permissions !== 'read'; | ||
} | ||
//# sourceMappingURL=Resources.js.map |
@@ -11,3 +11,3 @@ import { Tables as TablesService, GetTableListParams } from '../__generated__/Tables'; | ||
update(table: UpdateTableDc): Promise<DetailedTableInfoDc>; | ||
remove(name: string): Promise<void>; | ||
remove(name: string): Promise<string>; | ||
} |
@@ -23,6 +23,7 @@ import { Tables as TablesService, } from '../__generated__/Tables'; | ||
} | ||
remove(name) { | ||
return this.deleteResource(name); | ||
async remove(name) { | ||
await this.deleteResource(name); | ||
return name; | ||
} | ||
} | ||
//# sourceMappingURL=Tables.js.map |
{ | ||
"name": "@evergis/api", | ||
"version": "0.1.23", | ||
"version": "0.1.24", | ||
"license": "ISC", | ||
@@ -5,0 +5,0 @@ "author": "everpoint", |
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
229170
4953