-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert httpClient calls to @esri/arcgis-rest-request (#228)
* Convert httpClient calls to @esri/arcgis-rest-request with ArcGISIdentityManager for authentication * Fix addFields and deleteFields * Fixed outFields and returnGeometry for query generation * [service] prepend form name to all event form fields for clarity and to avoid ESRI column name conflicts * [service] Fix check to determine if an observation sync to ESRI is a create or update * [service] OAuth refresh token flow in work * [service] Add IdentityManager to ObservationSender construction * [service] Remove httpClient * [service] fix FeatureQuerier response from request * [service] Refactor ArcGISIdentityManager management * draft changes * [service] ArcGIS field names are lowercase, account for this when adding/removing fields * Undo revert of FeatureQuerier * [service] Remove HttpClient.ts, no longer used * [service] updateConfig inner async methods await before we query * [server] Attribute sync fix upon adding feature server * [web/service] API update to include feature service authentication status * [service] fix regression in token, username/password validation req parameter parsing * [service] Clean up TODO comments * [service] form field mapping need to account for form name and field name to avoid conflicts * Reduce response logging that may cause confusion * [service] include event forms in detecting config changes * Merge develop --------- Co-authored-by: Rick Saccoccia <[email protected]> Co-authored-by: William Newman <[email protected]> Co-authored-by: Ryan Slatten <[email protected]>
- Loading branch information
1 parent
f5ac5c1
commit bfb3e8d
Showing
27 changed files
with
1,500 additions
and
1,912 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 0 additions & 118 deletions
118
plugins/arcgis/service/src/ArcGISIdentityManagerFactory.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.