diff --git a/packages/common/src/resources/getItemResourcesPaths.ts b/packages/common/src/resources/getItemResourcesPaths.ts index 9434271f4..ee2a6ee7c 100644 --- a/packages/common/src/resources/getItemResourcesPaths.ts +++ b/packages/common/src/resources/getItemResourcesPaths.ts @@ -76,6 +76,11 @@ export function getItemResourcesPaths( } } + // GP Services + if (itemTemplate.type === "Geoprocessing Service") { + return res.indexOf("webtool") > -1; + } + return result; }); // create the filePaths diff --git a/packages/common/test/resources/getItemResourcesPaths.test.ts b/packages/common/test/resources/getItemResourcesPaths.test.ts index 1a0937813..762ffc0c5 100644 --- a/packages/common/test/resources/getItemResourcesPaths.test.ts +++ b/packages/common/test/resources/getItemResourcesPaths.test.ts @@ -297,6 +297,58 @@ describe("getItemResourcesPaths :: ", () => { expect(getResSpy.calls.argsFor(0)[0]).withContext("should get resources for template item").toBe("bc3"); }); }); + + it("filters out geoprocessing service resources", () => { + const getResSpy = spyOn(restHelpersModule, "getItemResources").and.resolveTo({ + total: 4, + start: 1, + num: 0, + nextStart: -1, + resources: [ + { + resource: "webtool.json", + created: 1591306005000, + size: 13850, + access: "inherit", + }, + { + resource: "other.json", + created: 1591306005000, + size: 13850, + access: "inherit", + }, + ], + }); + + const itemTemplate: IItemTemplate = templates.getItemTemplateSkeleton(); + itemTemplate.itemId = "bc3"; + itemTemplate.type = "Geoprocessing Service"; + + return getItemResourcesPaths(itemTemplate, "4de", MOCK_USER_SESSION, 1).then((response) => { + expect(Array.isArray(response)).withContext("should return an array").toBe(true); + expect(response.length).withContext("filter out non webtool files").toBe(2); + + expect(response).toEqual( + [ + { + itemId: "bc3", + url: "https://myorg.maps.arcgis.com/sharing/rest/content/items/bc3/resources/webtool.json", + folder: "bc3", + filename: "webtool.json", + }, + { + itemId: "bc3", + url: "https://myorg.maps.arcgis.com/sharing/rest/content/items/bc3/info/metadata/metadata.xml", + folder: "bc3_info_metadata", + filename: "metadata.xml", + }, + ], + "should return full path of the file in the storage item", + ); + expect(getResSpy.calls.count()).withContext("should get resources").toBe(1); + expect(getResSpy.calls.argsFor(0)[0]).withContext("should get resources for template item").toBe("bc3"); + }); + }); }); describe("getItemResourcesPaths, template version 0", () => { diff --git a/packages/creator/src/createItemTemplate.ts b/packages/creator/src/createItemTemplate.ts index d586fbffc..44a5717a2 100644 --- a/packages/creator/src/createItemTemplate.ts +++ b/packages/creator/src/createItemTemplate.ts @@ -296,7 +296,7 @@ export function createItemTemplate( } /** - * Remove webtoolDefinition resource from Geoprocessing Service + * Remove webtool resource files from Geoprocessing Service * This needs to be done after fetched so we can read from the file before we remove it * * @param template The current template