Skip to content

Commit 0456638

Browse files
committed
Merge branch 'develop' of https://github.com/ngageoint/mage-server into ArcProcessingFacelift
2 parents 259e322 + 6030daf commit 0456638

29 files changed

+1526
-1912
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,8 +295,15 @@ npm run build
295295
After building the core packages, install them as dependencies in the `instance` package.
296296
```bash
297297
cd instance
298+
npm i
299+
```
300+
301+
In the case that the dev dependencies need to be over ridden (eg nga-msi plugin)
302+
```bash
303+
cd instance
298304
npm i --omit dev ../service ../web-app/dist ../plugins/nga-msi
299305
```
306+
300307
The project's root [`package.json`](./package.json) provides some convenience script entries to install, build, and run
301308
the MAGE server components, however, those are deprecated and will likely go away after migrating to NPM 7+'s
302309
[workspaces](https://docs.npmjs.com/cli/v8/using-npm/workspaces) feature.

plugins/arcgis/README.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Build with arcgis plugin
2+
3+
Follow the instructions in the root README. After completing the web-app package install and build in the 'Building from source' section:
4+
5+
Build arcgis plugin:
6+
```bash
7+
cd plugins/arcgis/service
8+
npm ci
9+
npm link ../../../service # **IMPORTANT** see root README
10+
npm run build
11+
```
12+
```bash
13+
cd plugins/arcgis/web-app
14+
npm ci
15+
npm link ../../../web-app # **IMPORTANT** see root README
16+
npm run build
17+
```
18+
19+
Continue to install dependencies in the `instance` package as instructed in the root README.

plugins/arcgis/service/package-lock.json

Lines changed: 5 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

plugins/arcgis/service/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"@esri/arcgis-rest-feature-service": "^4.0.6",
4242
"@esri/arcgis-rest-request": "^4.2.3",
4343
"@terraformer/arcgis": "2.1.2",
44-
"form-data": "^4.0.0"
44+
"form-data": "^4.0.1"
4545
},
4646
"peerDependencies": {
4747
"@ngageoint/mage.service": "^6.2.9 || ^6.3.0-beta",

plugins/arcgis/service/src/ArcGISConfig.ts

Lines changed: 4 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -8,25 +8,10 @@ export interface FeatureServiceConfig {
88
*/
99
url: string
1010

11-
/**
12-
* Username and password for ArcGIS authentication
13-
*/
14-
auth?: ArcGISAuthConfig
15-
16-
/**
17-
* Create layers that don't exist
18-
*/
19-
createLayers?: boolean
20-
21-
/**
22-
* The administration url to the arc feature service.
23-
*/
24-
adminUrl?: string
25-
26-
/**
27-
* Administration access token
28-
*/
29-
adminToken?: string
11+
/**
12+
* Serialized ArcGISIdentityManager
13+
*/
14+
identityManager: string
3015

3116
/**
3217
* The feature layers.
@@ -49,104 +34,12 @@ export interface FeatureLayerConfig {
4934
*/
5035
geometryType?: string
5136

52-
/**
53-
* Access token
54-
*/
55-
token?: string // TODO - can this be removed? Will Layers have a token too?
5637
/**
5738
* The event ids or names that sync to this arc feature layer.
5839
*/
5940
events?: (number|string)[]
60-
61-
/**
62-
* Add layer fields from form fields
63-
*/
64-
addFields?: boolean
65-
66-
/**
67-
* Delete editable layer fields missing from form fields
68-
*/
69-
deleteFields?: boolean
70-
7141
}
7242

73-
export enum AuthType {
74-
Token = 'token',
75-
UsernamePassword = 'usernamePassword',
76-
OAuth = 'oauth'
77-
}
78-
79-
80-
/**
81-
* Contains token-based authentication configuration.
82-
*/
83-
export interface TokenAuthConfig {
84-
type: AuthType.Token
85-
token: string
86-
authTokenExpires?: string
87-
}
88-
89-
/**
90-
* Contains username and password for ArcGIS server authentication.
91-
*/
92-
export interface UsernamePasswordAuthConfig {
93-
type: AuthType.UsernamePassword
94-
/**
95-
* The username for authentication.
96-
*/
97-
username: string
98-
99-
/**
100-
* The password for authentication.
101-
*/
102-
password: string
103-
}
104-
105-
/**
106-
* Contains OAuth authentication configuration.
107-
*/
108-
export interface OAuthAuthConfig {
109-
110-
type: AuthType.OAuth
111-
112-
/**
113-
* The Client Id for OAuth
114-
*/
115-
clientId: string
116-
117-
/**
118-
* The redirectUri for OAuth
119-
*/
120-
redirectUri?: string
121-
122-
/**
123-
* The temporary auth token for OAuth
124-
*/
125-
authToken?: string
126-
127-
/**
128-
* The expiration date for the temporary token
129-
*/
130-
authTokenExpires?: number
131-
132-
/**
133-
* The Refresh token for OAuth
134-
*/
135-
refreshToken?: string
136-
137-
/**
138-
* The expiration date for the Refresh token
139-
*/
140-
refreshTokenExpires?: number
141-
}
142-
143-
/**
144-
* Union type for authentication configurations.
145-
*/
146-
export type ArcGISAuthConfig =
147-
| TokenAuthConfig
148-
| UsernamePasswordAuthConfig
149-
| OAuthAuthConfig
15043

15144
/**
15245
* Attribute configurations

plugins/arcgis/service/src/ArcGISIdentityManagerFactory.ts

Lines changed: 0 additions & 118 deletions
This file was deleted.

plugins/arcgis/service/src/ArcGISPluginConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ export const defaultArcGISPluginConfig = Object.freeze<ArcGISPluginConfig>({
145145
textAreaFieldLength: 256,
146146
observationIdField: 'description',
147147
idSeparator: '-',
148-
// eventIdField: 'event_id',
148+
eventIdField: 'event_id',
149149
lastEditedDateField: 'last_edited_date',
150150
eventNameField: 'event_name',
151151
userIdField: 'user_id',
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import { ArcGISIdentityManager } from '@esri/arcgis-rest-request'
2+
import { FeatureServiceConfig } from './ArcGISConfig'
3+
import { PluginStateRepository } from '@ngageoint/mage.service/lib/plugins.api'
4+
5+
export interface ArcGISIdentityService {
6+
signin(featureService: FeatureServiceConfig): Promise<ArcGISIdentityManager>
7+
updateIndentityManagers(): Promise<void>
8+
}
9+
10+
export function createArcGISIdentityService(
11+
stateRepo: PluginStateRepository<any>
12+
): ArcGISIdentityService {
13+
const identityManagerCache: Map<string, Promise<ArcGISIdentityManager>> = new Map()
14+
15+
return {
16+
async signin(featureService: FeatureServiceConfig): Promise<ArcGISIdentityManager> {
17+
let cached = await identityManagerCache.get(featureService.url)
18+
if (!cached) {
19+
const identityManager = ArcGISIdentityManager.deserialize(featureService.identityManager)
20+
const promise = identityManager.getUser().then(() => identityManager)
21+
identityManagerCache.set(featureService.url, promise)
22+
return promise
23+
} else {
24+
return cached
25+
}
26+
},
27+
async updateIndentityManagers() {
28+
const config = await stateRepo.get()
29+
for (let [url, persistedIdentityManagerPromise] of identityManagerCache) {
30+
const persistedIdentityManager = await persistedIdentityManagerPromise
31+
const featureService: FeatureServiceConfig | undefined = config.featureServices.find((service: FeatureServiceConfig) => service.url === url)
32+
if (featureService) {
33+
const identityManager = ArcGISIdentityManager.deserialize(featureService.identityManager)
34+
if (identityManager.token !== persistedIdentityManager.token || identityManager.refreshToken !== persistedIdentityManager.refreshToken) {
35+
featureService.identityManager = persistedIdentityManager.serialize()
36+
await stateRepo.put(config)
37+
}
38+
}
39+
}
40+
}
41+
}
42+
}
43+
44+
export function getPortalUrl(featureService: FeatureServiceConfig | string): string {
45+
const url = getFeatureServiceUrl(featureService)
46+
return `https://${url.hostname}/arcgis/sharing/rest`
47+
}
48+
49+
export function getServerUrl(featureService: FeatureServiceConfig | string): string {
50+
const url = getFeatureServiceUrl(featureService)
51+
return `https://${url.hostname}/arcgis`
52+
}
53+
54+
export function getFeatureServiceUrl(featureService: FeatureServiceConfig | string): URL {
55+
const url = typeof featureService === 'string' ? featureService : featureService.url
56+
return new URL(url)
57+
}

0 commit comments

Comments
 (0)