Skip to content

Commit

Permalink
feat(:hammer:): new package to create and admin feature services
Browse files Browse the repository at this point in the history
AFFECTS PACKAGES:
@esri/arcgis-rest-feature-service-admin
@esri/arcgis-rest-items
  • Loading branch information
jgravois committed Sep 10, 2018
1 parent d1bd319 commit cfdcee9
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 49 deletions.
66 changes: 66 additions & 0 deletions packages/arcgis-rest-feature-service-admin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[![npm version][npm-img]][npm-url]
[![build status][travis-img]][travis-url]
[![apache licensed](https://img.shields.io/badge/license-Apache-green.svg?style=flat-square)](https://raw.githubusercontent.com/Esri/arcgis-rest-js/master/LICENSE)

[npm-img]: https://img.shields.io/npm/v/@esri/arcgis-rest-feature-service-admin.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/@esri/arcgis-rest-feature-service-admin
[travis-img]: https://img.shields.io/travis/Esri/arcgis-rest-js/master.svg?style=flat-square
[travis-url]: https://travis-ci.org/Esri/arcgis-rest-js

# @esri/arcgis-rest-feature-service-admin

> A module for administering ArcGIS feature services that runs in Node.js and modern browsers.
### Example

```bash
npm install @esri/arcgis-rest-request
npm install @esri/arcgis-rest-auth
npm install @esri/arcgis-rest-items
npm install @esri/arcgis-rest-feature-service-admin
```

```js
import { createFeatureService } from '@esri/arcgis-rest-feature-service-admin';

createFeatureService({
authentication,
item: { name: "GreenField" }
})
```

### [API Reference](https://esri.github.io/arcgis-rest-js/api/feature-service-admin/)

### Issues

If something isn't working the way you expected, please take a look at [previously logged issues](https://github.com/Esri/arcgis-rest-js/issues) first. Have you found a new bug? Want to request a new feature? We'd [**love**](https://github.com/Esri/arcgis-rest-js/issues/new) to hear from you.

If you're looking for help you can also post issues on [GIS Stackexchange](http://gis.stackexchange.com/questions/ask?tags=esri-oss).

### Versioning

For transparency into the release cycle and in striving to maintain backward compatibility, @esri/arcgis-rest-js is maintained under Semantic Versioning guidelines and will adhere to these rules whenever possible.

For more information on SemVer, please visit <http://semver.org/>.

### Contributing

Esri welcomes contributions from anyone and everyone. Please see our [guidelines for contributing](CONTRIBUTING.md).

### License

Copyright &copy; 2018 Esri

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

> http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

A copy of the license is available in the repository's [LICENSE](../../LICENSE) file.
11 changes: 11 additions & 0 deletions packages/arcgis-rest-feature-service-admin/package-lock.json

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

53 changes: 53 additions & 0 deletions packages/arcgis-rest-feature-service-admin/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"name": "@esri/arcgis-rest-feature-service-admin",
"version": "1.8.0",
"description": "Feature service administration helpers for @esri/arcgis-rest-request",
"main": "dist/node/index.js",
"browser": "dist/umd/feature-service-admin.umd.js",
"module": "dist/esm/index.js",
"js:next": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"license": "Apache-2.0",
"files": [
"dist/**"
],
"dependencies": {
"tslib": "^1.7.1"
},
"peerDependencies": {
"@esri/arcgis-rest-request": "^1.8.0",
"@esri/arcgis-rest-common-types": "^1.8.0",
"@esri/arcgis-rest-auth": "^1.8.0",
"@esri/arcgis-rest-items": "^1.8.0"
},
"devDependencies": {
"@esri/arcgis-rest-request": "^1.8.0",
"@esri/arcgis-rest-common-types": "^1.8.0",
"@esri/arcgis-rest-auth": "^1.8.0",
"@esri/arcgis-rest-items": "^1.8.0"
},
"scripts": {
"prepare": "npm run build",
"build": "npm run build:node && npm run build:umd && npm run build:esm",
"build:esm": "tsc -p ./tsconfig.json --module es2015 --outDir ./dist/esm --declaration",
"build:umd": "rollup -c ../../umd-base-profile.js && rollup -c ../../umd-production-profile.js",
"build:node": "tsc -p ./tsconfig.json --module commonjs --outDir ./dist/node"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Esri/arcgis-rest-js.git"
},
"contributors": [
{
"name": "Mike Tschudi",
"email": "mtschudi@esri.com"
}
],
"bugs": {
"url": "https://github.com/Esri/arcgis-rest-js/issues"
},
"homepage": "https://github.com/Esri/arcgis-rest-js#readme"
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,22 @@
* Apache-2.0 */

import { request, getPortalUrl } from "@esri/arcgis-rest-request";
import { moveItem } from "./update";
import { IItemCrudRequestOptions, determineOwner } from "./helpers";
import {
moveItem,
IItemCrudRequestOptions,
determineOwner
} from "@esri/arcgis-rest-items";
import { IExtent, ISpatialReference } from "@esri/arcgis-rest-common-types";

/**
* A [`createParameters` JSON object for a new
* service](https://developers.arcgis.com/rest/users-groups-and-items/create-service.htm).
*/
export interface IFeatureServiceAdd {
export interface ICreateServiceParams {
/**
* Name of the service to be created. This name must be unique. If the name already exists, the operation will fail. ArcGIS Enterprise does not allow spaces or special characters other than underscores in a service name.
*/
name?: string;
name: string;
/**
* Description given to the service.
*/
Expand Down Expand Up @@ -68,22 +71,21 @@ export interface IFeatureServiceAdd {
xssPreventionInfo?: any;
}

export interface IAddFeatureServiceRequestOptions
extends IItemCrudRequestOptions {
export interface ICreateServiceRequestOptions extends IItemCrudRequestOptions {
/**
* A JSON object specifying the properties of the newly-created service. See the [REST
* Documentation](https://developers.arcgis.com/rest/users-groups-and-items/working-with-users-groups-and-items.htm)
* for more information.
*/
item: IFeatureServiceAdd;
item: ICreateServiceParams;
/**
* Alphanumeric id of folder to house moved item. If null, empty, or "/", the destination is the
* root folder.
*/
folderId?: string;
}

export interface IAddFeatureServiceResult {
export interface ICreateServiceResult {
/**
* The encoded URL to the hosted service.
*/
Expand Down Expand Up @@ -131,43 +133,16 @@ export interface IAddFeatureServiceResult {
}

/**
* Create a hosted feature service in the specified folder.
* Create a new hosted feature service.
*
* ```js
* import { createFeatureService } from '@esri/arcgis-rest-items';
* import { createFeatureService } from '@esri/arcgis-rest-feature-service-admin';
*
* createFeatureService({
* authentication: userSession,
* //folderId: "/", // not specified, empty string, or "/": into root folder
* item: {
* "name": "EmptyServiceName",
* "serviceDescription": "",
* "hasStaticData": false,
* "maxRecordCount": 1000,
* "supportedQueryFormats": "JSON",
* "capabilities": "Create,Delete,Query,Update,Editing",
* "description": "",
* "copyrightText": "",
* "spatialReference": {
* "wkid": 102100
* },
* "initialExtent": {
* "xmin": -20037507.0671618,
* "ymin": -30240971.9583862,
* "xmax": 20037507.0671618,
* "ymax": 18398924.324645,
* "spatialReference": {
* "wkid": 102100,
* "latestWkid": 3857
* }
* },
* "allowGeometryUpdates": true,
* "units": "esriMeters",
* "xssPreventionInfo": {
* "xssPreventionEnabled": true,
* "xssPreventionRule": "InputOnly",
* "xssInputRule": "rejectInvalid"
* }
* "name": "NewEmptyService",
* "capabilities": "Create,Delete,Query,Update,Editing"
* }
* });
* ```
Expand All @@ -176,8 +151,8 @@ export interface IAddFeatureServiceResult {
* @returns A Promise that resolves with service details once the service has been created
*/
export function createFeatureService(
requestOptions: IAddFeatureServiceRequestOptions
): Promise<IAddFeatureServiceResult> {
requestOptions: ICreateServiceRequestOptions
): Promise<ICreateServiceResult> {
const owner = determineOwner(requestOptions);

const baseUrl = `${getPortalUrl(requestOptions)}/content/users/${owner}`;
Expand Down
1 change: 1 addition & 0 deletions packages/arcgis-rest-feature-service-admin/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./create";
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@

import * as fetchMock from "fetch-mock";

import { createFeatureService } from "../src/createFeatureService";
import { createFeatureService } from "../src/create";

import {
FeatureServiceSuccessResponse,
FeatureServiceFailResponse
} from "./mocks/featureService";
} from "./mocks/service";
import {
MoveToFolderSuccessResponse,
MoveToFolderFailResponse
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
* Apache-2.0 */

export const MoveToFolderSuccessResponse: any = {
import { IItemMoveResponse } from "@esri/arcgis-rest-items";

export const MoveToFolderSuccessResponse: IItemMoveResponse = {
folder: "83216cba44bf4357bf06687ec88a847b",
itemId: "1b1a3c914ef94c49ae55ce223cac5754",
owner: "ArcGISTeamLocalGovOrg",
owner: "casey",
success: true
};

export const MoveToFolderFailResponse: any = {
success: false
};
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* Copyright (c) 2018 Environmental Systems Research Institute, Inc.
* Apache-2.0 */

export const FeatureServiceSuccessResponse: any = {
import { ICreateServiceResult } from "../../src/create";

export const FeatureServiceSuccessResponse: ICreateServiceResult = {
encodedServiceURL:
"https://services.arcgis.com/b6gLrKHqgkQb393u/arcgis/rest/services/EmptyServiceName/FeatureServer",
isView: false,
Expand All @@ -14,7 +16,6 @@ export const FeatureServiceSuccessResponse: any = {
success: true,
type: "Feature Service"
};

export const FeatureServiceFailResponse: any = {
success: false
};
6 changes: 6 additions & 0 deletions packages/arcgis-rest-feature-service-admin/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../tsconfig.json",
"include": [
"src/**/*.ts"
]
}
1 change: 0 additions & 1 deletion packages/arcgis-rest-items/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

export * from "./add";
export * from "./create";
export * from "./createFeatureService";
export * from "./get";
export * from "./protect";
export * from "./remove";
Expand Down

0 comments on commit cfdcee9

Please sign in to comment.