diff --git a/plugins/arcgis/service/package-lock.json b/plugins/arcgis/service/package-lock.json index 246d648d1..4b696144d 100644 --- a/plugins/arcgis/service/package-lock.json +++ b/plugins/arcgis/service/package-lock.json @@ -12,7 +12,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" }, "devDependencies": { "@types/express": "^4.17.21", @@ -16992,9 +16992,10 @@ } }, "node_modules/form-data": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.1.tgz", + "integrity": "sha512-tzN8e4TX8+kkxGPK8D5u0FNmjPUjw3lwC9lSLxxoB/+GtsJG91CO8bSWy73APlgAZzZbXEYZJuxjkHH2w+Ezhw==", + "license": "MIT", "dependencies": { "asynckit": "^0.4.0", "combined-stream": "^1.0.8", diff --git a/plugins/arcgis/service/package.json b/plugins/arcgis/service/package.json index c1653745a..6d18e5827 100644 --- a/plugins/arcgis/service/package.json +++ b/plugins/arcgis/service/package.json @@ -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", diff --git a/plugins/arcgis/service/src/FeatureServiceAdmin.ts b/plugins/arcgis/service/src/FeatureServiceAdmin.ts index 7ed660f8a..50f15b1fd 100644 --- a/plugins/arcgis/service/src/FeatureServiceAdmin.ts +++ b/plugins/arcgis/service/src/FeatureServiceAdmin.ts @@ -92,6 +92,7 @@ export class FeatureServiceAdmin { const eventFields = this.fields(events) const layerFields = layerInfo.fields + // TODO - better naming: addFields is a boolean, array of fields, and a method. Ditto for deleteFields if (featureLayer.addFields) { const layerFieldSet = new Set() @@ -110,6 +111,7 @@ export class FeatureServiceAdmin { } } + // TODO - where does New_field and New_field_2 come from with each startup? if (addFields.length > 0) { this.addFields(service, featureLayer, addFields) } @@ -462,8 +464,7 @@ export class FeatureServiceAdmin { */ private async addFields(service: FeatureServiceConfig, featureLayer: FeatureLayerConfig, fields: Field[]) { - const layer = {} as Layer - layer.fields = fields + const layer = { fields: fields} as Layer const httpClient = this.httpClient(service) const identityManager = await getIdentityManager(service, httpClient) @@ -471,15 +472,19 @@ export class FeatureServiceAdmin { this._console.info('ArcGIS feature layer addToDefinition (add fields) url ' + url) - const form = new FormData() - form.append('addToDefinition', JSON.stringify(layer)) - - const postResponse = request(url, { + await request(url, { authentication: identityManager, - httpMethod: 'POST', - params: form + params: { + addToDefinition: JSON.stringify(layer), + f: "json" + } + }).then((postResponse) => { + console.log('Response: ' + postResponse) + }).catch((error) => { + console.log('Error: ' + error) }); - console.log('Response: ' + postResponse) + + console.log('Remove me') } @@ -507,14 +512,12 @@ export class FeatureServiceAdmin { this._console.info('ArcGIS feature layer deleteFromDefinition (delete fields) url ' + url) - const form = new FormData() - form.append('deleteFromDefinition', JSON.stringify(layer)) - - httpClient.sendPostForm(url, form) const postResponse = request(url, { authentication: identityManager, httpMethod: 'POST', - params: form + params: { + deleteFromDefinition: JSON.stringify(layer) + } }); console.log('Response: ' + postResponse) } diff --git a/plugins/arcgis/service/src/ObservationProcessor.ts b/plugins/arcgis/service/src/ObservationProcessor.ts index 398c9a63a..01cff2f63 100644 --- a/plugins/arcgis/service/src/ObservationProcessor.ts +++ b/plugins/arcgis/service/src/ObservationProcessor.ts @@ -244,6 +244,8 @@ export class ObservationProcessor { } for (const featureLayer of featureServiceConfig.layers) { + // Initiate the feature layer and event fields to sync with the feature service + featureLayer.addFields = true if (featureLayer.token == null) { featureLayer.token = featureServiceConfig.auth?.type == AuthType.Token ? featureServiceConfig.auth.token : "" @@ -311,8 +313,8 @@ export class ObservationProcessor { const identityManager = await getIdentityManager(featureServiceConfig, new HttpClient(console)) const layerProcessor = new FeatureLayerProcessor(info, config, identityManager,this._console); this._layerProcessors.push(layerProcessor); - clearTimeout(this._nextTimeout); - this.scheduleNext(config); + clearTimeout(this._nextTimeout); // TODO why is this needed? + // this.scheduleNext(config); // TODO why is this needed when processAndScheduleNext is called upstream and ends with scheduleNext() This causes a query before updateLayer. } }