How to use @esri/solution-common - 10 common examples

To help you get started, we’ve selected a few @esri/solution-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Esri / solution.js / packages / simple-types / src / dashboard.ts View on Github external
export function _getDatasourceInfo(
  obj: any,
  datasourceInfos: common.IDatasourceInfo[]
): any {
  let info: any;
  // the datasource will have an id property when it's referencing a map layer
  // the fields collection will already be defined
  const id: string =
    common.getProp(obj, "dataSource.id") || common.getProp(obj, "targetId");
  if (id) {
    const dashboardLayerId: string = id.split("#")[1];
    if (
      !datasourceInfos.some(di => {
        info = di.ids.indexOf(dashboardLayerId) > -1 ? di : info;
        return di.ids.indexOf(dashboardLayerId) > -1;
      })
    ) {
      // in some cases the id will not contain a layer name...it will have the dashboard id for another widget
      // in that case lookup the datasource from referenced widget
      const dashboardWidgetId: string = id.split("#")[0];
      datasourceInfos.some(di => {
        const references: string[] = di.references || [];
        const hasRef: boolean = references.indexOf(dashboardWidgetId) > -1;
        info = hasRef ? di : info;
        return hasRef;
github Esri / solution.js / packages / simple-types / src / dashboard.ts View on Github external
})
    ) {
      // in some cases the id will not contain a layer name...it will have the dashboard id for another widget
      // in that case lookup the datasource from referenced widget
      const dashboardWidgetId: string = id.split("#")[0];
      datasourceInfos.some(di => {
        const references: string[] = di.references || [];
        const hasRef: boolean = references.indexOf(dashboardWidgetId) > -1;
        info = hasRef ? di : info;
        return hasRef;
      });
    }
  } else {
    // otherwise match the itemId and the layerId to get the correct fields and path
    const itemId: any = common.cleanLayerBasedItemId(
      common.getProp(obj, "dataSource.itemId")
    );
    const layerId: any = common.cleanLayerId(
      common.getProp(obj, "dataSource.layerId")
    );
    if (itemId) {
      datasourceInfos.some(di => {
        const matches: boolean = itemId === di.itemId && layerId === di.layerId;
        info = matches ? di : info;
        return matches;
      });
    }
  }
  return info;
}
github Esri / solution.js / packages / simple-types / src / webmappingapplication.ts View on Github external
// This was causing many other more typical layer references to be set incorrectly as the first
        // layerId found in this high level string would be used against the main object.
        let parsedProp: any;
        try {
          parsedProp = JSON.parse(obj[i]);
        } catch (error) {
          parsedProp = undefined;
        }
        if (parsedProp && typeof parsedProp === "object") {
          clone[i] = JSON.stringify(
            _templatizeParentByWebMapLayerId(parsedProp, ds, id, templatizeKeys)
          );
        } else if (typeof obj[i] === "object") {
          // some widgets store the layerId as a key to a collection of details that contain field references
          if (idTest.test(i) && templatizeKeys) {
            obj[i] = common.templatizeFieldReferences(
              obj[i],
              ds.fields,
              ds.basePath,
              templatizeKeys
            );
          }
          clone[i] = _templatizeParentByWebMapLayerId(
            obj[i],
            ds,
            id,
            templatizeKeys
          );
        } else {
          if (idTest.test(obj[i])) {
            obj = common.templatizeFieldReferences(
              obj,
github Esri / solution.js / packages / creator / src / createItemTemplate.ts View on Github external
() => {
            _replaceTemplate(
              existingTemplates,
              itemId,
              common.createPlaceholderTemplate(itemId, "unknown")
            );
            console.log(
              "!----- " +
                itemId +
                " ----- FAILED Id not found or item is not accessible -----"
            ); // ???
            resolve(true);
          }
        );
github Esri / solution.js / packages / creator / src / createItemTemplate.ts View on Github external
itemInfo => {
            const placeholder = common.findTemplateInList(
              existingTemplates,
              itemId
            );
            let itemType = placeholder!.type;
            if (!itemType) {
              // Groups have this defined when fetched above
              itemType = itemInfo.type;
              placeholder!.type = itemType;
            }
            itemInfo.type = itemType; // Groups don't have this property

            const itemHandler = moduleMap[itemType];
            if (!itemHandler) {
              placeholder!.properties["partial"] = true;
              _replaceTemplate(existingTemplates, itemId, placeholder!);
              console.log(
github Esri / solution.js / packages / simple-types / src / dashboard.ts View on Github external
return di.ids.indexOf(dashboardLayerId) > -1;
      })
    ) {
      // in some cases the id will not contain a layer name...it will have the dashboard id for another widget
      // in that case lookup the datasource from referenced widget
      const dashboardWidgetId: string = id.split("#")[0];
      datasourceInfos.some(di => {
        const references: string[] = di.references || [];
        const hasRef: boolean = references.indexOf(dashboardWidgetId) > -1;
        info = hasRef ? di : info;
        return hasRef;
      });
    }
  } else {
    // otherwise match the itemId and the layerId to get the correct fields and path
    const itemId: any = common.cleanLayerBasedItemId(
      common.getProp(obj, "dataSource.itemId")
    );
    const layerId: any = common.cleanLayerId(
      common.getProp(obj, "dataSource.layerId")
    );
    if (itemId) {
      datasourceInfos.some(di => {
        const matches: boolean = itemId === di.itemId && layerId === di.layerId;
        info = matches ? di : info;
        return matches;
      });
    }
  }
  return info;
}
github Esri / solution.js / packages / deployer / src / deployer.ts View on Github external
folderResponse.folder.id +
                        ")"
                    );
                    console.log(
                      "totalEstimatedCost, progressPercentStep",
                      totalEstimatedCost.toString(),
                      progressPercentStep.toFixed(2).toString()
                    );
                    progressCallback((percentDone += 2 * progressPercentStep)); // for data fetch and folder creation

                    const updateItemInfo = {
                      ...item,
                      type: "Solution",
                      typeKeywords: ["Solution"]
                    };
                    common
                      .createItemWithData(
                        updateItemInfo,
                        {},
                        destinationAuthentication,
                        templateDictionary.folderId
                      )
                      .then(
                        updateResponse => {
                          const oldID: string = sourceId;
                          const newID: string = updateResponse.id;
                          console.log("Solution " + newID + " created");
                          templateDictionary.solutionItemId = newID;
                          item.id = newID;
                          item.thumbnailUrl = _checkedReplaceAll(
                            item.thumbnailUrl,
                            oldID,
github Esri / solution.js / packages / simple-types / src / dashboard.ts View on Github external
// in some cases the id will not contain a layer name...it will have the dashboard id for another widget
      // in that case lookup the datasource from referenced widget
      const dashboardWidgetId: string = id.split("#")[0];
      datasourceInfos.some(di => {
        const references: string[] = di.references || [];
        const hasRef: boolean = references.indexOf(dashboardWidgetId) > -1;
        info = hasRef ? di : info;
        return hasRef;
      });
    }
  } else {
    // otherwise match the itemId and the layerId to get the correct fields and path
    const itemId: any = common.cleanLayerBasedItemId(
      common.getProp(obj, "dataSource.itemId")
    );
    const layerId: any = common.cleanLayerId(
      common.getProp(obj, "dataSource.layerId")
    );
    if (itemId) {
      datasourceInfos.some(di => {
        const matches: boolean = itemId === di.itemId && layerId === di.layerId;
        info = matches ? di : info;
        return matches;
      });
    }
  }
  return info;
}
github Esri / solution.js / packages / simple-types / src / dashboard.ts View on Github external
obj.datasets.forEach((dataset: IDashboardDataset) => {
          // when the datasource has an itemId it's an external datasource
          const itemId: string = common.cleanLayerBasedItemId(
            common.getProp(dataset, "dataSource.itemId")
          );
          if (itemId) {
            const layerId: number = common.cleanLayerId(
              common.getProp(dataset, "dataSource.layerId")
            );
            datasourceInfos.some(ds => {
              if (ds.itemId === itemId && ds.layerId === layerId) {
                _updateReferences(ds, obj.id);
                return true;
              } else {
                return false;
              }
            });
          } else {
            // add placeholder for map layer datasource info so we can know the items that reference them
            // needed when item field reference are derived from another widgets datasource eg. #datasetname
            const id: any = common.getProp(dataset, "dataSource.id");
            if (id) {
              const dashboardLayerId: string = id.split("#")[1];
github Esri / solution.js / packages / simple-types / src / webmappingapplication.ts View on Github external
templatizedUrl.indexOf("/", iSep + 2),
          templatizedUrl.lastIndexOf("=") + 1
        ) +
        itemTemplate.item.id; // templatized id

      portalUrl = templatizedUrl.replace(
        templatizedUrl.substring(templatizedUrl.indexOf("/", iSep + 2)),
        ""
      );
    }

    // Extract dependencies
    itemTemplate.dependencies = _extractDependencies(itemTemplate);

    // Set the folder
    common.setProp(itemTemplate, "data.folderId", "{{folderId}}");
    // Set the map or group after we've extracted them as dependencies
    _templatizeIdPaths(itemTemplate, [
      "data.map.itemId",
      "data.map.appProxy.mapItemId",
      "data.appItemId",
      "data.values.webmap",
      "data.values.group"
    ]);

    setValues(
      itemTemplate,
      [
        "data.logo",
        "data.map.portalUrl",
        "data.portalUrl",
        "data.httpProxy.url"