From 1b4c990d8640dc88bdc087d572bfed9139f78254 Mon Sep 17 00:00:00 2001 From: Haoliang Yu Date: Thu, 29 Aug 2019 19:06:15 -0400 Subject: [PATCH] F/add latest functions from arcgis-rest-js v2.4.0 (#172) * add new item functions * add upload parameters * add getUserTags() * update dependencies --- CHANGELOG.md | 5 ++ addon/services/items-service.js | 74 ++++++++++++++++++++----- addon/services/user-service.js | 8 ++- package.json | 16 +++--- yarn.lock | 96 ++++++++++++++++----------------- 5 files changed, 127 insertions(+), 72 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdda706..be524ab 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,11 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## Unreleased +### Added +- `addParts`, `getParts`, `getStatus` functions in `items-service` +- `getUserTags` function in the `user-service` + ## 2.4.0 ### Added - `export` call to `item-service` to export an item diff --git a/addon/services/items-service.js b/addon/services/items-service.js index 92787f2..82fc5c7 100644 --- a/addon/services/items-service.js +++ b/addon/services/items-service.js @@ -6,12 +6,15 @@ import { searchItems, getItem, getItemData, + getItemStatus, + getItemParts, updateItem, createItemInFolder, moveItem, removeItem, protectItem, - unprotectItem + unprotectItem, + addItemPart } from '@esri/arcgis-rest-portal'; export default Service.extend(serviceMixin, { @@ -77,7 +80,14 @@ export default Service.extend(serviceMixin, { const args = this.addOptions({ item, owner: item.owner, - folderId + folderId, + // have to add these parameters to avoid changing the exiting function params + file: item.file, + filename: item.filename, + dataUrl: item.dataUrl, + text: item.text, + multipart: item.multipart, + async: item.async }, portalOpts); return createItemInFolder(args) @@ -198,6 +208,21 @@ export default Service.extend(serviceMixin, { return this.request(urlPath, options, portalOpts); }, + /** + * Add an item part + */ + addPart ({ id, owner, file, partNum }, portalOpts) { + const args = this.addOptions({ + id, + owner, + file, + partNum + }, portalOpts); + + return addItemPart(args) + .catch(handleError); + }, + /** * Update a resource */ @@ -273,6 +298,34 @@ export default Service.extend(serviceMixin, { }, portalOpts); }, + /** + * Get item (job) status + */ + getStatus ({ id, owner, jobId, jobType }, portalOpts) { + const args = this.addOptions({ + id, + owner, + jobId, + jobType, + }, portalOpts); + + return getItemStatus(args) + .catch(handleError); + }, + + /** + * Get uploaded item parts + */ + getParts ({ id, owner }, portalOpts) { + const args = this.addOptions({ + id, + owner + }, portalOpts); + + return getItemParts(args) + .catch(handleError); + }, + /** * Export item */ @@ -288,17 +341,12 @@ export default Service.extend(serviceMixin, { } }, portalOpts) .then(job => { - let jobStatusUrl = `/content/users/${username}/items/${job.exportItemId}/status`; - job.getStatus = () => { - return this.request(jobStatusUrl, { - method: 'POST', - data: { - jobId: job.jobId, - jobType: 'export', - f: 'json' - } - }, portalOpts); - }; + job.getStatus = this.getStatus.bind(this, { + id: job.exportItemId, + owner: username, + jobId: job.jobId, + jobType: 'export' + }, portalOpts); return job; }); } diff --git a/addon/services/user-service.js b/addon/services/user-service.js index 0df6335..6dba311 100644 --- a/addon/services/user-service.js +++ b/addon/services/user-service.js @@ -9,7 +9,8 @@ import { getUserInvitations, getUserInvitation, acceptInvitation, - declineInvitation + declineInvitation, + getUserTags } from '@esri/arcgis-rest-portal'; import { generateToken } from '@esri/arcgis-rest-auth'; @@ -109,6 +110,11 @@ export default Service.extend(serviceMixin, { return generateToken(url, args); }, + getUserTags (username, portalOpts) { + const args = this.addOptions({ username }, portalOpts); + return getUserTags(args); + }, + /** * Extra logic to transform the item prior to POSTing it */ diff --git a/package.json b/package.json index fad4b81..fbeceeb 100644 --- a/package.json +++ b/package.json @@ -35,17 +35,17 @@ "ember-fetch": "^6.2.0" }, "peerDependencies": { - "@esri/arcgis-rest-auth": "^2.3.0", - "@esri/arcgis-rest-portal": "^2.3.0", - "@esri/arcgis-rest-request": "^2.3.0", - "@esri/arcgis-rest-types": "^2.3.0" + "@esri/arcgis-rest-auth": "^2.4.0", + "@esri/arcgis-rest-portal": "^2.4.0", + "@esri/arcgis-rest-request": "^2.4.0", + "@esri/arcgis-rest-types": "^2.4.0" }, "devDependencies": { "@ember/optional-features": "^0.6.3", - "@esri/arcgis-rest-auth": "^2.3.0", - "@esri/arcgis-rest-portal": "^2.3.0", - "@esri/arcgis-rest-request": "^2.3.0", - "@esri/arcgis-rest-types": "^2.3.0", + "@esri/arcgis-rest-auth": "^2.4.0", + "@esri/arcgis-rest-portal": "^2.4.0", + "@esri/arcgis-rest-request": "^2.4.0", + "@esri/arcgis-rest-types": "^2.4.0", "broccoli-asset-rev": "^2.7.0", "ember-cli": "~3.5.0", "ember-cli-active-link-wrapper": "0.5.0", diff --git a/yarn.lock b/yarn.lock index 60627d1..bb668f0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -694,29 +694,33 @@ resolve "^1.8.1" semver "^5.6.0" -"@esri/arcgis-rest-auth@^2.3.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@esri/arcgis-rest-auth/-/arcgis-rest-auth-2.3.0.tgz#8a42930ae3ec739a6357a7ec1e944a4b47033417" +"@esri/arcgis-rest-auth@^2.4.0": + version "2.4.0" + resolved "https://registry.yarnpkg.com/@esri/arcgis-rest-auth/-/arcgis-rest-auth-2.4.0.tgz#9a48e3e39fcb361c15dc678f3da15191c3e4268f" + integrity sha512-9ArO9LPGYfjIyHKpwmsqOL4EiaIeb9CbwW7rYW8o0FcPQ7s21dsbNvNzgrWtkLjv4ljAd8r2bcrbBsdjIzBdXQ== dependencies: - "@esri/arcgis-rest-types" "^2.3.0" + "@esri/arcgis-rest-types" "^2.4.0" tslib "^1.9.3" -"@esri/arcgis-rest-portal@^2.3.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@esri/arcgis-rest-portal/-/arcgis-rest-portal-2.3.0.tgz#afdca186219767c9e97e33215db2b109c71c4d20" +"@esri/arcgis-rest-portal@^2.4.0": + version "2.4.0" + resolved "https://registry.yarnpkg.com/@esri/arcgis-rest-portal/-/arcgis-rest-portal-2.4.0.tgz#97583af38a7c7cb77af99542a1bcca62a2d94c22" + integrity sha512-lYOdh6CSY9c9emWrx1YM4SyBnA6GurRlfpOOM5wdAZfPxNhPtRrS40EnPyDGUeeFQzGjQG0MEI7qd6ejnKoJQw== dependencies: - "@esri/arcgis-rest-types" "^2.3.0" + "@esri/arcgis-rest-types" "^2.4.0" tslib "^1.9.3" -"@esri/arcgis-rest-request@^2.3.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@esri/arcgis-rest-request/-/arcgis-rest-request-2.3.0.tgz#d72c44a733fcdd6af9de821f55f76be7f3a1092f" +"@esri/arcgis-rest-request@^2.4.0": + version "2.4.0" + resolved "https://registry.yarnpkg.com/@esri/arcgis-rest-request/-/arcgis-rest-request-2.4.0.tgz#e738f5bdbf7a86caf99edf92c76dd763cbfb635f" + integrity sha512-+DN9VIl1+h8qDtnYkKK/vO7VFP6xykQUyBrdFXPyqW/T3te3y2S0l1vmlNp+6tM9ExG2w3+eRUXlIZ+fIdx/3A== dependencies: tslib "^1.9.3" -"@esri/arcgis-rest-types@^2.3.0": - version "2.3.0" - resolved "https://registry.yarnpkg.com/@esri/arcgis-rest-types/-/arcgis-rest-types-2.3.0.tgz#1f98768e865452a36ed60b3a03979085a8276b4e" +"@esri/arcgis-rest-types@^2.4.0": + version "2.4.0" + resolved "https://registry.yarnpkg.com/@esri/arcgis-rest-types/-/arcgis-rest-types-2.4.0.tgz#c767a51608ce5f1f6ff795ec466a617df387efa6" + integrity sha512-w34S5X5eHs1TqrSupe/aurVHF7YAHzgNmG4tB/6MSyUbOwiy5K5xnEO282MUEs7btNaDe0Jo6VyBsGGGHdV9rg== "@glimmer/di@^0.2.0": version "0.2.1" @@ -1111,10 +1115,6 @@ ansi-html@^0.0.7: version "0.0.7" resolved "https://registry.yarnpkg.com/ansi-html/-/ansi-html-0.0.7.tgz#813584021962a9e9e6fd039f940d12f56ca7859e" -ansi-regex@*, ansi-regex@^4.1.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" - ansi-regex@^2.0.0: version "2.1.1" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df" @@ -1123,6 +1123,10 @@ ansi-regex@^3.0.0, ansi-regex@~3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-3.0.0.tgz#ed0317c322064f79466c02966bddb605ab37d998" +ansi-regex@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-4.1.0.tgz#8b9f8f08cf1acb843756a839ca8c7e3168c51997" + ansi-styles@^2.2.1: version "2.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-2.2.1.tgz#b432dd3358b634cf75e1e4664368240533c1ddbe" @@ -3536,7 +3540,7 @@ debug@^4.0.0, debug@^4.1.0, debug@^4.1.1, debug@~4.1.0: dependencies: ms "^2.1.1" -debuglog@*, debuglog@^1.0.1: +debuglog@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" @@ -5877,7 +5881,7 @@ import-lazy@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/import-lazy/-/import-lazy-2.1.0.tgz#05698e3d45c88e8d7e9d92cb0584e77f096f3e43" -imurmurhash@*, imurmurhash@^0.1.4: +imurmurhash@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea" @@ -6741,7 +6745,7 @@ lodash._basefor@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/lodash._basefor/-/lodash._basefor-3.0.3.tgz#7550b4e9218ef09fad24343b612021c79b4c20c2" -lodash._baseindexof@*, lodash._baseindexof@^3.0.0: +lodash._baseindexof@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/lodash._baseindexof/-/lodash._baseindexof-3.1.0.tgz#fe52b53a1c6761e42618d654e4a25789ed61822c" @@ -6753,13 +6757,6 @@ lodash._baseisequal@^3.0.0: lodash.istypedarray "^3.0.0" lodash.keys "^3.0.0" -lodash._baseuniq@*, lodash._baseuniq@~4.6.0: - version "4.6.0" - resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8" - dependencies: - lodash._createset "~4.0.0" - lodash._root "~3.0.0" - lodash._baseuniq@^3.0.0: version "3.0.3" resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-3.0.3.tgz#2123fa0db2d69c28d5beb1c1f36d61522a740234" @@ -6768,11 +6765,18 @@ lodash._baseuniq@^3.0.0: lodash._cacheindexof "^3.0.0" lodash._createcache "^3.0.0" -lodash._bindcallback@*, lodash._bindcallback@^3.0.0: +lodash._baseuniq@~4.6.0: + version "4.6.0" + resolved "https://registry.yarnpkg.com/lodash._baseuniq/-/lodash._baseuniq-4.6.0.tgz#0ebb44e456814af7905c6212fa2c9b2d51b841e8" + dependencies: + lodash._createset "~4.0.0" + lodash._root "~3.0.0" + +lodash._bindcallback@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/lodash._bindcallback/-/lodash._bindcallback-3.0.1.tgz#e531c27644cf8b57a99e17ed95b35c748789392e" -lodash._cacheindexof@*, lodash._cacheindexof@^3.0.0: +lodash._cacheindexof@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/lodash._cacheindexof/-/lodash._cacheindexof-3.0.2.tgz#3dc69ac82498d2ee5e3ce56091bafd2adc7bde92" @@ -6784,7 +6788,7 @@ lodash._createassigner@^3.0.0: lodash._isiterateecall "^3.0.0" lodash.restparam "^3.0.0" -lodash._createcache@*, lodash._createcache@^3.0.0: +lodash._createcache@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/lodash._createcache/-/lodash._createcache-3.1.2.tgz#56d6a064017625e79ebca6b8018e17440bdcf093" dependencies: @@ -6794,7 +6798,7 @@ lodash._createset@~4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/lodash._createset/-/lodash._createset-4.0.3.tgz#0f4659fbb09d75194fa9e2b88a6644d363c9fe26" -lodash._getnative@*, lodash._getnative@^3.0.0: +lodash._getnative@^3.0.0: version "3.9.1" resolved "https://registry.yarnpkg.com/lodash._getnative/-/lodash._getnative-3.9.1.tgz#570bc7dede46d61cdcde687d65d3eecbaa3aaff5" @@ -6866,14 +6870,10 @@ lodash.get@^4.4.2: version "4.4.2" resolved "https://registry.yarnpkg.com/lodash.get/-/lodash.get-4.4.2.tgz#2d177f652fa31e939b4438d5341499dfa3825e99" -lodash.isarguments@*, lodash.isarguments@^3.0.0: +lodash.isarguments@^3.0.0: version "3.1.0" resolved "https://registry.yarnpkg.com/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz#2f573d85c6a24289ff00663b491c1d338ff3458a" -lodash.isarray@*: - version "4.0.0" - resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-4.0.0.tgz#2aca496b28c4ca6d726715313590c02e6ea34403" - lodash.isarray@^3.0.0: version "3.0.4" resolved "https://registry.yarnpkg.com/lodash.isarray/-/lodash.isarray-3.0.4.tgz#79e4eb88c36a8122af86f844aa9bcd851b5fbb55" @@ -6882,10 +6882,6 @@ lodash.istypedarray@^3.0.0: version "3.0.6" resolved "https://registry.yarnpkg.com/lodash.istypedarray/-/lodash.istypedarray-3.0.6.tgz#c9a477498607501d8e8494d283b87c39281cef62" -lodash.keys@*: - version "4.2.0" - resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-4.2.0.tgz#a08602ac12e4fb83f91fc1fb7a360a4d9ba35205" - lodash.keys@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/lodash.keys/-/lodash.keys-3.1.2.tgz#4dbc0472b156be50a0b286855d1bd0b0c656098a" @@ -6924,7 +6920,7 @@ lodash.pairs@^3.0.0: dependencies: lodash.keys "^3.0.0" -lodash.restparam@*, lodash.restparam@^3.0.0: +lodash.restparam@^3.0.0: version "3.6.1" resolved "https://registry.yarnpkg.com/lodash.restparam/-/lodash.restparam-3.6.1.tgz#936a4e309ef330a7645ed4145986c85ae5b20805" @@ -8964,7 +8960,7 @@ readable-stream@~2.0.5: string_decoder "~0.10.x" util-deprecate "~1.0.1" -readdir-scoped-modules@*, readdir-scoped-modules@^1.0.0: +readdir-scoped-modules@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/readdir-scoped-modules/-/readdir-scoped-modules-1.1.0.tgz#8d45407b4f870a0dcaebc0e28670d18e74514309" dependencies: @@ -10093,12 +10089,6 @@ stringstream@~0.0.4: version "0.0.6" resolved "https://registry.yarnpkg.com/stringstream/-/stringstream-0.0.6.tgz#7880225b0d4ad10e30927d167a1d6f2fd3b33a72" -strip-ansi@*, strip-ansi@^5.1.0, strip-ansi@^5.2.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" - dependencies: - ansi-regex "^4.1.0" - strip-ansi@^3.0.0, strip-ansi@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-3.0.1.tgz#6a385fb8853d952d5ff05d0e8aaf94278dc63dcf" @@ -10111,6 +10101,12 @@ strip-ansi@^4.0.0, strip-ansi@~4.0.0: dependencies: ansi-regex "^3.0.0" +strip-ansi@^5.1.0, strip-ansi@^5.2.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-5.2.0.tgz#8c9a536feb6afc962bdfa5b104a5091c1ad9c0ae" + dependencies: + ansi-regex "^4.1.0" + strip-bom@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" @@ -10834,7 +10830,7 @@ uuid@~3.1.0: version "3.1.0" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.1.0.tgz#3dd3d3e790abc24d7b0d3a034ffababe28ebbc04" -validate-npm-package-license@*, validate-npm-package-license@^3.0.1: +validate-npm-package-license@^3.0.1: version "3.0.4" resolved "https://registry.yarnpkg.com/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz#fc91f6b9c7ba15c857f4cb2c5defeec39d4f410a" dependencies: