Skip to content

Commit

Permalink
feat(@esri/hub-downloads): if item is a portal item and it is multila…
Browse files Browse the repository at this point in the history
…yer, export all layers

affects: @esri/hub-oauth-demo, @esri/hub-annotations, @esri/hub-common, @esri/hub-content,
@esri/hub-downloads, @esri/hub-events, @esri/hub-initiatives, @esri/hub-search, @esri/hub-sites,
@esri/hub-surveys, @esri/hub-teams
  • Loading branch information
rgwozdz committed Nov 16, 2020
1 parent 2dcea3a commit 4681f05
Show file tree
Hide file tree
Showing 14 changed files with 105 additions and 52 deletions.
4 changes: 2 additions & 2 deletions demos/oauth2-browser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
"author": "",
"license": "Apache-2.0",
"dependencies": {
"@esri/arcgis-rest-auth": "^1.16.0",
"@esri/arcgis-rest-request": "^1.16.0",
"@esri/arcgis-rest-auth": "^2.21.0",
"@esri/arcgis-rest-request": "^2.21.0",
"@esri/hub-auth": "^6.10.0"
},
"devDependencies": {
Expand Down
8 changes: 4 additions & 4 deletions packages/annotations/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"@esri/arcgis-rest-types": "^2.13.0"
},
"devDependencies": {
"@esri/arcgis-rest-auth": "^2.14.1",
"@esri/arcgis-rest-feature-layer": "^2.14.1",
"@esri/arcgis-rest-portal": "^2.18.0",
"@esri/arcgis-rest-request": "^2.14.1",
"@esri/arcgis-rest-auth": "^2.21.0",
"@esri/arcgis-rest-feature-layer": "^2.21.0",
"@esri/arcgis-rest-portal": "^2.21.0",
"@esri/arcgis-rest-request": "^2.21.0",
"@esri/arcgis-rest-service-admin": "^2.14.1",
"@esri/arcgis-rest-types": "^2.15.0",
"@rollup/plugin-commonjs": "^15.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
"@esri/arcgis-rest-types": "^2.15.0"
},
"devDependencies": {
"@esri/arcgis-rest-auth": "^2.14.1",
"@esri/arcgis-rest-portal": "^2.18.0",
"@esri/arcgis-rest-request": "^2.14.1",
"@esri/arcgis-rest-auth": "^2.21.0",
"@esri/arcgis-rest-portal": "^2.21.0",
"@esri/arcgis-rest-request": "^2.21.0",
"@esri/arcgis-rest-types": "^2.15.0",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-json": "^4.1.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/content/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"@esri/hub-common": "^6.15.0"
},
"devDependencies": {
"@esri/arcgis-rest-auth": "^2.14.1",
"@esri/arcgis-rest-portal": "^2.18.0",
"@esri/arcgis-rest-request": "^2.14.1",
"@esri/arcgis-rest-auth": "^2.21.0",
"@esri/arcgis-rest-portal": "^2.21.0",
"@esri/arcgis-rest-request": "^2.21.0",
"@esri/hub-common": "^6.18.0",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-json": "^4.1.0",
Expand Down
29 changes: 17 additions & 12 deletions packages/downloads/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions packages/downloads/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
"types": "dist/esm/index.d.ts",
"license": "Apache-2.0",
"dependencies": {
"@esri/arcgis-rest-feature-layer": "^2.14.1",
"@esri/arcgis-rest-portal": "^2.14.1",
"@esri/arcgis-rest-request": "^2.14.1",
"@esri/arcgis-rest-feature-layer": "^2.21.0",
"@esri/arcgis-rest-portal": "^2.21.0",
"@esri/arcgis-rest-request": "^2.21.0",
"eventemitter3": "^4.0.4",
"tslib": "^1.13.0"
},
"devDependencies": {
"@esri/arcgis-rest-auth": "^2.14.1",
"@esri/arcgis-rest-auth": "^2.21.0",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ export function portalRequestDatasetExport(

function composeExportParameters(params: any) {
const { datasetId, spatialRefId, where } = params;
const layerId = datasetId.split("_")[1] || 0;
const layerId = datasetId.split("_")[1];

if (!layerId) {
return spatialRefId ? { targetSR: { wkid: Number(spatialRefId) } } : {};
}

const layers = [{ id: Number(layerId), where }];
return spatialRefId
? {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ describe("portalRequestDatasetExport", () => {
{
id: "abcdef0123456789abcdef0123456789",
exportFormat: "CSV",
exportParameters: { layers: [Object({ id: 0, where: undefined })] },
exportParameters: {},
title: "test-export",
authentication
}
Expand All @@ -125,7 +125,7 @@ describe("portalRequestDatasetExport", () => {
}
});

it("succeeds, uses spatialRefId", async done => {
it("succeeds, uses single layer and spatialRefId", async done => {
try {
spyOn(portal, "exportItem").and.returnValue(
new Promise((resolve, reject) => {
Expand Down Expand Up @@ -169,6 +169,49 @@ describe("portalRequestDatasetExport", () => {
}
});

it("succeeds, uses no layers and spatialRefId", async done => {
try {
spyOn(portal, "exportItem").and.returnValue(
new Promise((resolve, reject) => {
resolve({
size: 1000,
jobId: "job-id",
exportItemId: "abcdef"
});
})
);

const result = await portalRequestDatasetExport({
datasetId: "abcdef0123456789abcdef0123456789",
format: "CSV",
authentication,
spatialRefId: "4326",
title: "test-export"
});
expect(portal.exportItem).toHaveBeenCalledTimes(1);
expect((portal.exportItem as any).calls.first().args).toEqual([
{
id: "abcdef0123456789abcdef0123456789",
exportFormat: "CSV",
exportParameters: {
targetSR: { wkid: 4326 }
},
title: "test-export",
authentication
}
]);
expect(result).toBeDefined();
expect(result.downloadId).toEqual("abcdef");
expect(result.jobId).toEqual("job-id");
expect(result.size).toEqual(1000);
expect(typeof result.exportCreated === "number").toEqual(true);
} catch (err) {
expect(err).toBeUndefined();
} finally {
done();
}
});

it("succeeds, uses where", async done => {
try {
spyOn(portal, "exportItem").and.returnValue(
Expand Down
8 changes: 4 additions & 4 deletions packages/events/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"@esri/hub-common": "4.x || 5.x || 6.x"
},
"devDependencies": {
"@esri/arcgis-rest-auth": "^2.14.1",
"@esri/arcgis-rest-feature-layer": "^2.14.1",
"@esri/arcgis-rest-portal": "^2.18.0",
"@esri/arcgis-rest-request": "^2.14.1",
"@esri/arcgis-rest-auth": "^2.21.0",
"@esri/arcgis-rest-feature-layer": "^2.21.0",
"@esri/arcgis-rest-portal": "^2.21.0",
"@esri/arcgis-rest-request": "^2.21.0",
"@esri/arcgis-rest-types": "^2.15.0",
"@esri/hub-common": "^6.18.0",
"@rollup/plugin-commonjs": "^15.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/initiatives/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
"@esri/hub-common": "^6.4.0"
},
"devDependencies": {
"@esri/arcgis-rest-auth": "^2.14.1",
"@esri/arcgis-rest-portal": "^2.18.0",
"@esri/arcgis-rest-request": "^2.14.1",
"@esri/arcgis-rest-request": "^2.21.0",
"@esri/arcgis-rest-portal": "^2.21.0",
"@esri/arcgis-rest-auth": "^2.21.0",
"@esri/hub-common": "^6.18.0",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-json": "^4.1.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/search/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"@esri/hub-common": "4.x || 5.x || 6.x"
},
"devDependencies": {
"@esri/arcgis-rest-auth": "^2.14.1",
"@esri/arcgis-rest-feature-layer": "^2.14.1",
"@esri/arcgis-rest-portal": "^2.18.0",
"@esri/arcgis-rest-request": "^2.14.1",
"@esri/arcgis-rest-auth": "^2.21.0",
"@esri/arcgis-rest-feature-layer": "^2.21.0",
"@esri/arcgis-rest-portal": "^2.21.0",
"@esri/arcgis-rest-request": "^2.21.0",
"@esri/arcgis-rest-types": "^2.15.0",
"@esri/hub-common": "^6.18.0",
"@rollup/plugin-commonjs": "^15.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/sites/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
"@esri/hub-teams": "^6.11.0"
},
"devDependencies": {
"@esri/arcgis-rest-auth": "^2.14.1",
"@esri/arcgis-rest-portal": "^2.19.0",
"@esri/arcgis-rest-request": "^2.14.1",
"@esri/arcgis-rest-auth": "^2.21.0",
"@esri/arcgis-rest-portal": "^2.21.0",
"@esri/arcgis-rest-request": "^2.21.0",
"@esri/hub-common": "^6.18.0",
"@esri/hub-initiatives": "^6.18.0",
"@esri/hub-teams": "^6.18.0",
Expand Down
8 changes: 4 additions & 4 deletions packages/surveys/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@
"@esri/hub-common": "4.x || 5.x || 6.x"
},
"devDependencies": {
"@esri/arcgis-rest-auth": "^2.14.1",
"@esri/arcgis-rest-feature-layer": "^2.14.1",
"@esri/arcgis-rest-portal": "^2.18.0",
"@esri/arcgis-rest-request": "^2.14.1",
"@esri/arcgis-rest-auth": "^2.21.0",
"@esri/arcgis-rest-feature-layer": "^2.21.0",
"@esri/arcgis-rest-portal": "^2.21.0",
"@esri/arcgis-rest-request": "^2.21.0",
"@esri/arcgis-rest-types": "^2.15.0",
"@esri/hub-common": "^6.18.0",
"@rollup/plugin-commonjs": "^15.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/teams/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@
"@esri/hub-common": "4.x || 5.x || 6.x"
},
"devDependencies": {
"@esri/arcgis-rest-auth": "^2.14.1",
"@esri/arcgis-rest-portal": "^2.18.0",
"@esri/arcgis-rest-request": "^2.14.1",
"@esri/arcgis-rest-auth": "^2.21.0",
"@esri/arcgis-rest-portal": "^2.21.0",
"@esri/arcgis-rest-request": "^2.21.0",
"@esri/arcgis-rest-types": "^2.15.0",
"@esri/hub-common": "^6.18.0",
"@rollup/plugin-commonjs": "^15.0.0",
Expand Down

0 comments on commit 4681f05

Please sign in to comment.