Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/ngageoint/mage-server in…
Browse files Browse the repository at this point in the history
…to ArcProcessingFacelift
  • Loading branch information
ryanslatten committed Dec 11, 2024
2 parents 259e322 + 6030daf commit 0456638
Show file tree
Hide file tree
Showing 29 changed files with 1,526 additions and 1,912 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,15 @@ npm run build
After building the core packages, install them as dependencies in the `instance` package.
```bash
cd instance
npm i
```

In the case that the dev dependencies need to be over ridden (eg nga-msi plugin)
```bash
cd instance
npm i --omit dev ../service ../web-app/dist ../plugins/nga-msi
```

The project's root [`package.json`](./package.json) provides some convenience script entries to install, build, and run
the MAGE server components, however, those are deprecated and will likely go away after migrating to NPM 7+'s
[workspaces](https://docs.npmjs.com/cli/v8/using-npm/workspaces) feature.
Expand Down
19 changes: 19 additions & 0 deletions plugins/arcgis/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Build with arcgis plugin

Follow the instructions in the root README. After completing the web-app package install and build in the 'Building from source' section:

Build arcgis plugin:
```bash
cd plugins/arcgis/service
npm ci
npm link ../../../service # **IMPORTANT** see root README
npm run build
```
```bash
cd plugins/arcgis/web-app
npm ci
npm link ../../../web-app # **IMPORTANT** see root README
npm run build
```

Continue to install dependencies in the `instance` package as instructed in the root README.
9 changes: 5 additions & 4 deletions plugins/arcgis/service/package-lock.json

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

2 changes: 1 addition & 1 deletion plugins/arcgis/service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@esri/arcgis-rest-feature-service": "^4.0.6",
"@esri/arcgis-rest-request": "^4.2.3",
"@terraformer/arcgis": "2.1.2",
"form-data": "^4.0.0"
"form-data": "^4.0.1"
},
"peerDependencies": {
"@ngageoint/mage.service": "^6.2.9 || ^6.3.0-beta",
Expand Down
115 changes: 4 additions & 111 deletions plugins/arcgis/service/src/ArcGISConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,25 +8,10 @@ export interface FeatureServiceConfig {
*/
url: string

/**
* Username and password for ArcGIS authentication
*/
auth?: ArcGISAuthConfig

/**
* Create layers that don't exist
*/
createLayers?: boolean

/**
* The administration url to the arc feature service.
*/
adminUrl?: string

/**
* Administration access token
*/
adminToken?: string
/**
* Serialized ArcGISIdentityManager
*/
identityManager: string

/**
* The feature layers.
Expand All @@ -49,104 +34,12 @@ export interface FeatureLayerConfig {
*/
geometryType?: string

/**
* Access token
*/
token?: string // TODO - can this be removed? Will Layers have a token too?
/**
* The event ids or names that sync to this arc feature layer.
*/
events?: (number|string)[]

/**
* Add layer fields from form fields
*/
addFields?: boolean

/**
* Delete editable layer fields missing from form fields
*/
deleteFields?: boolean

}

export enum AuthType {
Token = 'token',
UsernamePassword = 'usernamePassword',
OAuth = 'oauth'
}


/**
* Contains token-based authentication configuration.
*/
export interface TokenAuthConfig {
type: AuthType.Token
token: string
authTokenExpires?: string
}

/**
* Contains username and password for ArcGIS server authentication.
*/
export interface UsernamePasswordAuthConfig {
type: AuthType.UsernamePassword
/**
* The username for authentication.
*/
username: string

/**
* The password for authentication.
*/
password: string
}

/**
* Contains OAuth authentication configuration.
*/
export interface OAuthAuthConfig {

type: AuthType.OAuth

/**
* The Client Id for OAuth
*/
clientId: string

/**
* The redirectUri for OAuth
*/
redirectUri?: string

/**
* The temporary auth token for OAuth
*/
authToken?: string

/**
* The expiration date for the temporary token
*/
authTokenExpires?: number

/**
* The Refresh token for OAuth
*/
refreshToken?: string

/**
* The expiration date for the Refresh token
*/
refreshTokenExpires?: number
}

/**
* Union type for authentication configurations.
*/
export type ArcGISAuthConfig =
| TokenAuthConfig
| UsernamePasswordAuthConfig
| OAuthAuthConfig

/**
* Attribute configurations
Expand Down
118 changes: 0 additions & 118 deletions plugins/arcgis/service/src/ArcGISIdentityManagerFactory.ts

This file was deleted.

2 changes: 1 addition & 1 deletion plugins/arcgis/service/src/ArcGISPluginConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export const defaultArcGISPluginConfig = Object.freeze<ArcGISPluginConfig>({
textAreaFieldLength: 256,
observationIdField: 'description',
idSeparator: '-',
// eventIdField: 'event_id',
eventIdField: 'event_id',
lastEditedDateField: 'last_edited_date',
eventNameField: 'event_name',
userIdField: 'user_id',
Expand Down
57 changes: 57 additions & 0 deletions plugins/arcgis/service/src/ArcGISService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { ArcGISIdentityManager } from '@esri/arcgis-rest-request'
import { FeatureServiceConfig } from './ArcGISConfig'
import { PluginStateRepository } from '@ngageoint/mage.service/lib/plugins.api'

export interface ArcGISIdentityService {
signin(featureService: FeatureServiceConfig): Promise<ArcGISIdentityManager>
updateIndentityManagers(): Promise<void>
}

export function createArcGISIdentityService(
stateRepo: PluginStateRepository<any>
): ArcGISIdentityService {
const identityManagerCache: Map<string, Promise<ArcGISIdentityManager>> = new Map()

return {
async signin(featureService: FeatureServiceConfig): Promise<ArcGISIdentityManager> {
let cached = await identityManagerCache.get(featureService.url)
if (!cached) {
const identityManager = ArcGISIdentityManager.deserialize(featureService.identityManager)
const promise = identityManager.getUser().then(() => identityManager)
identityManagerCache.set(featureService.url, promise)
return promise
} else {
return cached
}
},
async updateIndentityManagers() {
const config = await stateRepo.get()
for (let [url, persistedIdentityManagerPromise] of identityManagerCache) {
const persistedIdentityManager = await persistedIdentityManagerPromise
const featureService: FeatureServiceConfig | undefined = config.featureServices.find((service: FeatureServiceConfig) => service.url === url)
if (featureService) {
const identityManager = ArcGISIdentityManager.deserialize(featureService.identityManager)
if (identityManager.token !== persistedIdentityManager.token || identityManager.refreshToken !== persistedIdentityManager.refreshToken) {
featureService.identityManager = persistedIdentityManager.serialize()
await stateRepo.put(config)
}
}
}
}
}
}

export function getPortalUrl(featureService: FeatureServiceConfig | string): string {
const url = getFeatureServiceUrl(featureService)
return `https://${url.hostname}/arcgis/sharing/rest`
}

export function getServerUrl(featureService: FeatureServiceConfig | string): string {
const url = getFeatureServiceUrl(featureService)
return `https://${url.hostname}/arcgis`
}

export function getFeatureServiceUrl(featureService: FeatureServiceConfig | string): URL {
const url = typeof featureService === 'string' ? featureService : featureService.url
return new URL(url)
}
Loading

0 comments on commit 0456638

Please sign in to comment.