UNPKG

@esri/solution-common

Version:

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

140 lines (139 loc) 5.25 kB
/** @license * Copyright 2018 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. */ import { IItemTemplate, ISolutionItemData } from "./interfaces"; /** * A parameterized server name to replace the organization URL in a Web Mapping Application's URL to * itself; name has to be acceptable to AGOL, otherwise it discards the URL, so substitution must be * made before attempting to create the item. * * @private */ export declare const SERVER_NAME: string; /** * A parameterized geometry server name * * @private */ export declare const GEOMETRY_SERVER_NAME: string; /** * A parameterized geocode server name * * @private */ export declare const GEOCODE_SERVER_NAME: string; /** * A parameterized network analyst server name * * @private */ export declare const NA_SERVER_NAME: string; /** * A parameterized network analyst server name * * @private */ export declare const PRINT_SERVER_NAME: string; export declare const TRANSFORMS: any; /** * Wraps double brackets around the supplied term. * * @param term Term to be wrapped, e.g., SERVER_NAME's "portalBaseUrl" * @returns Wrapped term, e.g., "\{\{portalBaseUrl\}\}" */ export declare function placeholder(term: string): string; export declare function createInitializedGroupTemplate(itemInfo: any): IItemTemplate; export declare function createInitializedItemTemplate(itemInfo: any): IItemTemplate; /** * Creates an empty template. * * @param id AGO id of item * @param type AGO item type; defaults to "" * @returns Empty template containing supplied id, optional type, and a key created using the function createShortId() */ export declare function createPlaceholderTemplate(id: string, type?: string): IItemTemplate; /** * Extracts the version of a solution from its data section. * * @param itemData Data section of the solution as JSON * @returns Zero-based version number */ export declare function extractSolutionVersion(itemData: ISolutionItemData): number; /** * Finds index of template by id in a list of templates. * * @param templates A collection of AGO item templates to search * @param id AGO id of template to find * @returns Offset of of matching template or -1 if not found * @private */ export declare function findTemplateIndexInList(templates: IItemTemplate[], id: string): number; /** * Finds template by id in a list of templates. * * @param templates A collection of AGO item templates to search * @param id AGO id of template to find * @returns Matching template or null */ export declare function findTemplateInList(templates: IItemTemplate[], id: string): IItemTemplate | null; export declare function hasUnresolvedVariables(data: any): boolean; export declare function getIdsInTemplatesList(templates: IItemTemplate[]): string[]; export declare function getDefaultExtent(itemInfo: any): any; /** * Removes a template entry in a list of templates. * * @param templates A collection of AGO item templates * @param id Id of item in templates list to find; if not found, no replacement is done * @private */ export declare function removeTemplate(templates: IItemTemplate[], id: string): void; /** * Replaces symbols in a template. * * @param template Template to check for replacements; template is modified by this function * @param replacements Hash of facts: org URL, adlib replacements, deferreds for dependencies * @returns template is returned after updating it */ export declare function replaceInTemplate(template: any, replacements: any): any; /** * Replaces a template entry in a list of templates. * * @param templates A collection of AGO item templates * @param id Id of item in templates list to find; if not found, no replacement is done * @param template Replacement template * @returns True if replacement was made * @private */ export declare function replaceTemplate(templates: IItemTemplate[], id: string, template: IItemTemplate): boolean; export declare function templatizeTerm(context: string, term: string, suffix?: string): string; /** * Helper function to templatize value and make sure its converted to lowercase * * @param basePath path used to de-templatize while deploying * @param value to be converted to lower case for lookup while deploying */ export declare function templatizeToLowerCase(basePath: string, value: string): string; /** * using each field from the datasource replace any occurances * of the field name with the templatized value * Needs to account for: * "NAME" * "NAME NAME2" * "NAME ASC" * "\{NAME\}" * "(NAME = value AND NAME2 = someOtherValue)" */ export declare function templatizeFieldReferences(obj: any, fields: any[], basePath: string, templatizeKeys?: boolean): any; export declare function templatizeIds(obj: any): any;