Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
private async downloadPartition(
dataHandle: string,
abortSignal?: AbortSignal
): Promise {
const builder = await this.getRequestBuilder("blob", abortSignal);
return BlobApi.getBlob(builder, {
dataHandle,
layerId: this.layerId
}).catch(this.errorHandler);
}
private async downloadTile(
dataHandle: string,
abortSignal?: AbortSignal
): Promise {
const builder = await this.getRequestBuilder("blob", abortSignal);
return BlobApi.getBlob(builder, {
dataHandle,
layerId: this.layerId
}).catch(async error => Promise.reject(error));
}
private async getDataHandleByPartitionId(
partitionId: string,
version?: number
): Promise {
const queryRequestBilder = await this.getRequestBuilder("query");
const latestVersion = version || (await this.getLatestVersion());
const partitions = await QueryApi.getPartitionsById(
queryRequestBilder,
{
version: `${latestVersion}`,
layerId: this.layerId,
partition: [partitionId]
}
);
const partition = partitions.partitions.find(element => {
return element.partition === partitionId;
});
return partition && partition.dataHandle
? partition.dataHandle
: Promise.reject(
`No partition dataHandle for partition ${partitionId}. HRN: ${this.hrn}`
);
private async downloadPartitionData(
partitionId: string
): Promise {
const queryRequestBilder = await this.getRequestBuilder("query");
const latestVersion = await this.getLatestVersion();
return QueryApi.getPartitionsById(queryRequestBilder, {
version: `${latestVersion}`,
layerId: this.layerId,
partition: [partitionId]
});
}
private async downloadPartitionData(
partitionId: string
): Promise {
const queryRequestBilder = await this.getRequestBuilder("query");
return QueryApi.getPartitionsById(queryRequestBilder, {
layerId: this.layerId,
partition: [partitionId]
});
}
private async getDataHandleByPartitionId(
partitionId: string
): Promise {
const queryRequestBilder = await this.getRequestBuilder("query");
const partitions = await QueryApi.getPartitionsById(
queryRequestBilder,
{
layerId: this.layerId,
partition: [partitionId]
}
);
const partition = partitions.partitions.find(element => {
return element.partition === partitionId;
});
return partition && partition.dataHandle
? partition.dataHandle
: Promise.reject(
`No partition dataHandle for partition ${partitionId}. HRN: ${this.hrn}`
);
}
return Promise.reject("Please provide correct partitionIds list");
}
const requestBuilder = await RequestFactory.create(
"query",
this.apiVersion,
this.settings,
hrn,
abortSignal
).catch(error =>
Promise.reject(
`Erorr creating request object for query service: ${error}`
)
);
return QueryApi.getPartitionsById(
requestBuilder,
{
layerId,
partition: idsList,
version: version ? `${version}` : undefined,
}
);
}
private async downloadIndex(indexRootKey: QuadKey): Promise {
let dsIndex: ConfigApi.Index;
const queryRequestBuilder = await this.getRequestBuilder("query");
dsIndex = await QueryApi.quadTreeIndexVolatile(queryRequestBuilder, {
layerId: this.layerId,
quadKey: utils.mortonCodeFromQuadKey(indexRootKey).toString(),
depth: this.indexDepth
});
return this.parseIndex(indexRootKey, dsIndex);
}
public async getLatestVersion(
request: CatalogVersionRequest,
abortSignal?: AbortSignal
): Promise {
const startVersion = request.getStartVersion() || -1;
const builder = await this.getRequestBuilder(
"metadata",
HRN.fromString(this.hrn),
abortSignal
).catch(error => Promise.reject(error));
const latestVersion = await MetadataApi.latestVersion(builder, {
startVersion,
billingTag: request.getBillingTag()
});
return latestVersion.version;
}
private async getLatestVersion(): Promise {
const builder = await this.getRequestBuilder("metadata").catch(error =>
Promise.reject(error)
);
const latestVersion = await MetadataApi.latestVersion(builder, {
startVersion: -1
}).catch(async (error: Response) =>
Promise.reject(
new Error(
`Metadata Service error: HTTP ${
error.status
}, ${error.statusText || ""}`
)
)
);
return latestVersion.version;
}