UNPKG

@esri/solution-common

Version:

Provides general helper functions for @esri/solution.js.

122 lines (121 loc) 6.1 kB
/** @license * Copyright 2020 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. */ /** * Provides general helper functions. * * @module workforceHelpers */ import { UserSession } from "./arcgisRestJS"; import { IItemTemplate, IFeatureServiceProperties } from "./interfaces"; /** * Converts an workforce item to a template. * * @param itemTemplate template for the workforce project item * @param authentication credentials for any requests * @param templateDictionary Hash of key details used for variable replacement * @returns templatized itemTemplate */ export declare function convertWorkforceItemToTemplate(itemTemplate: IItemTemplate, authentication: UserSession, templateDictionary: any): Promise<IItemTemplate>; /** * Gets the ids of the dependencies of the workforce project. * * @param data itemTemplate data * @param keyProperties workforce project properties that contain references to dependencies * @param authentication credentials for any requests * @returns List of dependencies ids */ export declare function extractWorkforceDependencies(data: any, keyProperties: string[], authentication: UserSession): Promise<any>; /** * Templatizes key item properties. * * @param data itemTemplate data * @param keyProperties workforce project properties that should be templatized * @param urlHash a key value pair of url and itemId * @param templateDictionary Hash of key details used for variable replacement * @returns an updated data object to be stored in the template */ export declare function templatizeWorkforce(data: any, keyProperties: string[], urlHash: any, templateDictionary: any): any; /** * Evaluate key properties in the workforce service of additional items that are needed * * @param itemTemplate template for the workforce project item * @param dependencies list of the items dependencies * @returns an array of objects with dependency ids */ export declare function getWorkforceDependencies(itemTemplate: IItemTemplate, dependencies: any[]): any; export declare function getWorkforceServiceInfo(properties: IFeatureServiceProperties, url: string, authentication: UserSession): Promise<IFeatureServiceProperties>; /** * Wrap global id and assignmenttype values in curly braces * * Added for issue #734 * * This function will update the provided workforceInfos object * * @param workforceInfos the object that stores the integration and type info with global ids * @private */ export declare function _updateGlobalIdAndAssignmentType(workforceInfos: any): void; export declare function _getAssignmentTypeInfos(assignmentTypes: any): any[]; export declare function _getAssignmentIntegrationInfos(assignmentIntegrations: any, authentication: UserSession): Promise<any>; export declare function getUrlDependencies(requests: Array<Promise<any>>, urls: string[]): Promise<any>; /** * Templatizes values from a urlTemplate * * @param item the object that may contain a urlTemplate * @param urlHash a key value pair of url and itemId * @private */ export declare function _templatizeUrlTemplate(item: any, urlHash: any): void; export declare function getLayerId(url: string): any; export declare function getReplaceValue(layerId: any, suffix: string): string; export declare function postProcessWorkforceTemplates(templates: IItemTemplate[]): IItemTemplate[]; export declare function _templatizeWorkforceProject(t: IItemTemplate, groupUpdates: any): any; export declare function _templatizeWorkforceDispatcherOrWorker(t: IItemTemplate, type: string): IItemTemplate; export declare function isWorkforceProject(itemTemplate: IItemTemplate): boolean; export declare function getKeyWorkforceProperties(version: number): string[]; /** * Test the provided value for any urls and submit a request to obtain the service item id for the url * * @param v a string value to test for urls * @param authentication credentials for the requests * @returns an object with any pending requests and the urls that requests were made to */ export declare function urlTest(v: any, authentication: UserSession): any; export declare function _getURLs(v: string): string[]; /** * Gets the current user and updates the dispatchers service * * @param newlyCreatedItem Item to be created; n.b.: this item is modified * @param destinationAuthentication The session used to create the new item(s) * @returns A promise that will resolve with \{ "success" === true || false \} */ export declare function fineTuneCreatedWorkforceItem(newlyCreatedItem: IItemTemplate, destinationAuthentication: UserSession, url: string, templateDictionary: any): Promise<any>; export declare function _getFields(url: string, ids: number[], authentication: UserSession): Promise<any>; export declare function _updateUrl(url: string): string; export declare function _getAddFeatures(updateInfos: any, fields: any[]): any; export declare function _getField(name: string, fields: string[]): string; /** * Updates the dispatchers service to include the current user as a dispatcher * * @param dispatchers The dispatchers object from the workforce items data * @param name Current users name * @param fullName Current users full name * @param destinationAuthentication The session used to create the new item(s) * @returns A promise that will resolve with true || false * @private */ export declare function _updateDispatchers(url: any, name: string, fullName: string, authentication: UserSession, isPortal: boolean): Promise<boolean>; export declare function _applyEdits(url: string, adds: any[], authentication: UserSession, useGlobalIds?: boolean): any;