@esri/solution-common 6.1.2 → 6.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (404) hide show
  1. package/package.json +2 -2
  2. package/dist/cjs/arcgisRestJS.d.ts +0 -61
  3. package/dist/cjs/arcgisRestJS.js +0 -144
  4. package/dist/cjs/arcgisRestJS.js.map +0 -1
  5. package/dist/cjs/completeItem.d.ts +0 -30
  6. package/dist/cjs/completeItem.js +0 -72
  7. package/dist/cjs/completeItem.js.map +0 -1
  8. package/dist/cjs/create-hub-request-options.d.ts +0 -29
  9. package/dist/cjs/create-hub-request-options.js +0 -64
  10. package/dist/cjs/create-hub-request-options.js.map +0 -1
  11. package/dist/cjs/deleteHelpers/deleteEmptyGroups.d.ts +0 -24
  12. package/dist/cjs/deleteHelpers/deleteEmptyGroups.js +0 -42
  13. package/dist/cjs/deleteHelpers/deleteEmptyGroups.js.map +0 -1
  14. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.d.ts +0 -27
  15. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js +0 -99
  16. package/dist/cjs/deleteHelpers/deleteGroupIfEmpty.js.map +0 -1
  17. package/dist/cjs/deleteHelpers/deleteSolutionContents.d.ts +0 -39
  18. package/dist/cjs/deleteHelpers/deleteSolutionContents.js +0 -127
  19. package/dist/cjs/deleteHelpers/deleteSolutionContents.js.map +0 -1
  20. package/dist/cjs/deleteHelpers/deleteSolutionFolder.d.ts +0 -29
  21. package/dist/cjs/deleteHelpers/deleteSolutionFolder.js +0 -81
  22. package/dist/cjs/deleteHelpers/deleteSolutionFolder.js.map +0 -1
  23. package/dist/cjs/deleteHelpers/deleteSolutionItem.d.ts +0 -31
  24. package/dist/cjs/deleteHelpers/deleteSolutionItem.js +0 -52
  25. package/dist/cjs/deleteHelpers/deleteSolutionItem.js.map +0 -1
  26. package/dist/cjs/deleteHelpers/index.d.ts +0 -22
  27. package/dist/cjs/deleteHelpers/index.js +0 -26
  28. package/dist/cjs/deleteHelpers/index.js.map +0 -1
  29. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.d.ts +0 -27
  30. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js +0 -34
  31. package/dist/cjs/deleteHelpers/reconstructBuildOrderIds.js.map +0 -1
  32. package/dist/cjs/deleteHelpers/removeItems.d.ts +0 -35
  33. package/dist/cjs/deleteHelpers/removeItems.js +0 -116
  34. package/dist/cjs/deleteHelpers/removeItems.js.map +0 -1
  35. package/dist/cjs/deleteHelpers/reportProgress.d.ts +0 -27
  36. package/dist/cjs/deleteHelpers/reportProgress.js +0 -46
  37. package/dist/cjs/deleteHelpers/reportProgress.js.map +0 -1
  38. package/dist/cjs/deleteSolution.d.ts +0 -56
  39. package/dist/cjs/deleteSolution.js +0 -107
  40. package/dist/cjs/deleteSolution.js.map +0 -1
  41. package/dist/cjs/dependencies.d.ts +0 -26
  42. package/dist/cjs/dependencies.js +0 -171
  43. package/dist/cjs/dependencies.js.map +0 -1
  44. package/dist/cjs/featureServiceHelpers.d.ts +0 -847
  45. package/dist/cjs/featureServiceHelpers.js +0 -2553
  46. package/dist/cjs/featureServiceHelpers.js.map +0 -1
  47. package/dist/cjs/formHelpers.d.ts +0 -26
  48. package/dist/cjs/formHelpers.js +0 -40
  49. package/dist/cjs/formHelpers.js.map +0 -1
  50. package/dist/cjs/generalHelpers.d.ts +0 -447
  51. package/dist/cjs/generalHelpers.js +0 -959
  52. package/dist/cjs/generalHelpers.js.map +0 -1
  53. package/dist/cjs/get-subscription-info.d.ts +0 -27
  54. package/dist/cjs/get-subscription-info.js +0 -38
  55. package/dist/cjs/get-subscription-info.js.map +0 -1
  56. package/dist/cjs/getDeletableSolutionInfo.d.ts +0 -30
  57. package/dist/cjs/getDeletableSolutionInfo.js +0 -53
  58. package/dist/cjs/getDeletableSolutionInfo.js.map +0 -1
  59. package/dist/cjs/getItemTypeAbbrev.d.ts +0 -19
  60. package/dist/cjs/getItemTypeAbbrev.js +0 -186
  61. package/dist/cjs/getItemTypeAbbrev.js.map +0 -1
  62. package/dist/cjs/getSolutionSummary.d.ts +0 -28
  63. package/dist/cjs/getSolutionSummary.js +0 -100
  64. package/dist/cjs/getSolutionSummary.js.map +0 -1
  65. package/dist/cjs/index.d.ts +0 -49
  66. package/dist/cjs/index.js +0 -53
  67. package/dist/cjs/index.js.map +0 -1
  68. package/dist/cjs/interfaces.d.ts +0 -1446
  69. package/dist/cjs/interfaces.js +0 -72
  70. package/dist/cjs/interfaces.js.map +0 -1
  71. package/dist/cjs/item-reuse.d.ts +0 -140
  72. package/dist/cjs/item-reuse.js +0 -176
  73. package/dist/cjs/item-reuse.js.map +0 -1
  74. package/dist/cjs/libConnectors.d.ts +0 -73
  75. package/dist/cjs/libConnectors.js +0 -115
  76. package/dist/cjs/libConnectors.js.map +0 -1
  77. package/dist/cjs/migrations/apply-schema.d.ts +0 -24
  78. package/dist/cjs/migrations/apply-schema.js +0 -36
  79. package/dist/cjs/migrations/apply-schema.js.map +0 -1
  80. package/dist/cjs/migrations/is-legacy-solution.d.ts +0 -24
  81. package/dist/cjs/migrations/is-legacy-solution.js +0 -39
  82. package/dist/cjs/migrations/is-legacy-solution.js.map +0 -1
  83. package/dist/cjs/migrations/upgrade-three-dot-one.d.ts +0 -26
  84. package/dist/cjs/migrations/upgrade-three-dot-one.js +0 -48
  85. package/dist/cjs/migrations/upgrade-three-dot-one.js.map +0 -1
  86. package/dist/cjs/migrations/upgrade-three-dot-zero.d.ts +0 -27
  87. package/dist/cjs/migrations/upgrade-three-dot-zero.js +0 -43
  88. package/dist/cjs/migrations/upgrade-three-dot-zero.js.map +0 -1
  89. package/dist/cjs/migrations/upgrade-two-dot-five.d.ts +0 -24
  90. package/dist/cjs/migrations/upgrade-two-dot-five.js +0 -73
  91. package/dist/cjs/migrations/upgrade-two-dot-five.js.map +0 -1
  92. package/dist/cjs/migrations/upgrade-two-dot-four.d.ts +0 -24
  93. package/dist/cjs/migrations/upgrade-two-dot-four.js +0 -72
  94. package/dist/cjs/migrations/upgrade-two-dot-four.js.map +0 -1
  95. package/dist/cjs/migrations/upgrade-two-dot-one.d.ts +0 -7
  96. package/dist/cjs/migrations/upgrade-two-dot-one.js +0 -39
  97. package/dist/cjs/migrations/upgrade-two-dot-one.js.map +0 -1
  98. package/dist/cjs/migrations/upgrade-two-dot-seven.d.ts +0 -23
  99. package/dist/cjs/migrations/upgrade-two-dot-seven.js +0 -58
  100. package/dist/cjs/migrations/upgrade-two-dot-seven.js.map +0 -1
  101. package/dist/cjs/migrations/upgrade-two-dot-six.d.ts +0 -27
  102. package/dist/cjs/migrations/upgrade-two-dot-six.js +0 -61
  103. package/dist/cjs/migrations/upgrade-two-dot-six.js.map +0 -1
  104. package/dist/cjs/migrations/upgrade-two-dot-three.d.ts +0 -23
  105. package/dist/cjs/migrations/upgrade-two-dot-three.js +0 -55
  106. package/dist/cjs/migrations/upgrade-two-dot-three.js.map +0 -1
  107. package/dist/cjs/migrations/upgrade-two-dot-two.d.ts +0 -23
  108. package/dist/cjs/migrations/upgrade-two-dot-two.js +0 -58
  109. package/dist/cjs/migrations/upgrade-two-dot-two.js.map +0 -1
  110. package/dist/cjs/migrations/upgrade-two-dot-zero.d.ts +0 -44
  111. package/dist/cjs/migrations/upgrade-two-dot-zero.js +0 -95
  112. package/dist/cjs/migrations/upgrade-two-dot-zero.js.map +0 -1
  113. package/dist/cjs/migrator.d.ts +0 -25
  114. package/dist/cjs/migrator.js +0 -75
  115. package/dist/cjs/migrator.js.map +0 -1
  116. package/dist/cjs/resourceHelpers.d.ts +0 -192
  117. package/dist/cjs/resourceHelpers.js +0 -380
  118. package/dist/cjs/resourceHelpers.js.map +0 -1
  119. package/dist/cjs/resources/add-resource.d.ts +0 -38
  120. package/dist/cjs/resources/add-resource.js +0 -84
  121. package/dist/cjs/resources/add-resource.js.map +0 -1
  122. package/dist/cjs/resources/addMetadataFromBlob.d.ts +0 -25
  123. package/dist/cjs/resources/addMetadataFromBlob.js +0 -43
  124. package/dist/cjs/resources/addMetadataFromBlob.js.map +0 -1
  125. package/dist/cjs/resources/convert-item-resource-to-storage-resource.d.ts +0 -32
  126. package/dist/cjs/resources/convert-item-resource-to-storage-resource.js +0 -70
  127. package/dist/cjs/resources/convert-item-resource-to-storage-resource.js.map +0 -1
  128. package/dist/cjs/resources/convert-storage-resource-to-item-resource.d.ts +0 -29
  129. package/dist/cjs/resources/convert-storage-resource-to-item-resource.js +0 -70
  130. package/dist/cjs/resources/convert-storage-resource-to-item-resource.js.map +0 -1
  131. package/dist/cjs/resources/copyAssociatedFiles.d.ts +0 -79
  132. package/dist/cjs/resources/copyAssociatedFiles.js +0 -348
  133. package/dist/cjs/resources/copyAssociatedFiles.js.map +0 -1
  134. package/dist/cjs/resources/copyDataIntoItem.d.ts +0 -34
  135. package/dist/cjs/resources/copyDataIntoItem.js +0 -45
  136. package/dist/cjs/resources/copyDataIntoItem.js.map +0 -1
  137. package/dist/cjs/resources/copyMetadataIntoItem.d.ts +0 -27
  138. package/dist/cjs/resources/copyMetadataIntoItem.js +0 -44
  139. package/dist/cjs/resources/copyMetadataIntoItem.js.map +0 -1
  140. package/dist/cjs/resources/copyResourceIntoZip.d.ts +0 -34
  141. package/dist/cjs/resources/copyResourceIntoZip.js +0 -74
  142. package/dist/cjs/resources/copyResourceIntoZip.js.map +0 -1
  143. package/dist/cjs/resources/copyZipIntoItem.d.ts +0 -26
  144. package/dist/cjs/resources/copyZipIntoItem.js +0 -53
  145. package/dist/cjs/resources/copyZipIntoItem.js.map +0 -1
  146. package/dist/cjs/resources/createCopyResults.d.ts +0 -25
  147. package/dist/cjs/resources/createCopyResults.js +0 -36
  148. package/dist/cjs/resources/createCopyResults.js.map +0 -1
  149. package/dist/cjs/resources/get-blob.d.ts +0 -25
  150. package/dist/cjs/resources/get-blob.js +0 -42
  151. package/dist/cjs/resources/get-blob.js.map +0 -1
  152. package/dist/cjs/resources/getItemResourcesFilesFromPaths.d.ts +0 -25
  153. package/dist/cjs/resources/getItemResourcesFilesFromPaths.js +0 -49
  154. package/dist/cjs/resources/getItemResourcesFilesFromPaths.js.map +0 -1
  155. package/dist/cjs/resources/getItemResourcesPaths.d.ts +0 -27
  156. package/dist/cjs/resources/getItemResourcesPaths.js +0 -80
  157. package/dist/cjs/resources/getItemResourcesPaths.js.map +0 -1
  158. package/dist/cjs/resources/index.d.ts +0 -30
  159. package/dist/cjs/resources/index.js +0 -34
  160. package/dist/cjs/resources/index.js.map +0 -1
  161. package/dist/cjs/resources/solution-resource.d.ts +0 -35
  162. package/dist/cjs/resources/solution-resource.js +0 -31
  163. package/dist/cjs/resources/solution-resource.js.map +0 -1
  164. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.d.ts +0 -56
  165. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js +0 -140
  166. package/dist/cjs/resources/transform-resource-paths-to-solution-resources.js.map +0 -1
  167. package/dist/cjs/resources/update-resource.d.ts +0 -27
  168. package/dist/cjs/resources/update-resource.js +0 -52
  169. package/dist/cjs/resources/update-resource.js.map +0 -1
  170. package/dist/cjs/restHelpers.d.ts +0 -634
  171. package/dist/cjs/restHelpers.js +0 -2008
  172. package/dist/cjs/restHelpers.js.map +0 -1
  173. package/dist/cjs/restHelpersGet.d.ts +0 -303
  174. package/dist/cjs/restHelpersGet.js +0 -835
  175. package/dist/cjs/restHelpersGet.js.map +0 -1
  176. package/dist/cjs/sharing/index.d.ts +0 -16
  177. package/dist/cjs/sharing/index.js +0 -20
  178. package/dist/cjs/sharing/index.js.map +0 -1
  179. package/dist/cjs/sharing/share-item-to-groups.d.ts +0 -26
  180. package/dist/cjs/sharing/share-item-to-groups.js +0 -44
  181. package/dist/cjs/sharing/share-item-to-groups.js.map +0 -1
  182. package/dist/cjs/templatization.d.ts +0 -139
  183. package/dist/cjs/templatization.js +0 -311
  184. package/dist/cjs/templatization.js.map +0 -1
  185. package/dist/cjs/trackingHelpers.d.ts +0 -115
  186. package/dist/cjs/trackingHelpers.js +0 -212
  187. package/dist/cjs/trackingHelpers.js.map +0 -1
  188. package/dist/cjs/velocityHelpers.d.ts +0 -68
  189. package/dist/cjs/velocityHelpers.js +0 -151
  190. package/dist/cjs/velocityHelpers.js.map +0 -1
  191. package/dist/cjs/webtoolHelpers.d.ts +0 -57
  192. package/dist/cjs/webtoolHelpers.js +0 -102
  193. package/dist/cjs/webtoolHelpers.js.map +0 -1
  194. package/dist/cjs/workflowHelpers.d.ts +0 -112
  195. package/dist/cjs/workflowHelpers.js +0 -284
  196. package/dist/cjs/workflowHelpers.js.map +0 -1
  197. package/dist/cjs/workforceHelpers.d.ts +0 -121
  198. package/dist/cjs/workforceHelpers.js +0 -720
  199. package/dist/cjs/workforceHelpers.js.map +0 -1
  200. package/dist/cjs/zip-utils.d.ts +0 -85
  201. package/dist/cjs/zip-utils.js +0 -154
  202. package/dist/cjs/zip-utils.js.map +0 -1
  203. package/dist/esm/arcgisRestJS.d.ts +0 -61
  204. package/dist/esm/arcgisRestJS.js +0 -95
  205. package/dist/esm/arcgisRestJS.js.map +0 -1
  206. package/dist/esm/completeItem.d.ts +0 -30
  207. package/dist/esm/completeItem.js +0 -67
  208. package/dist/esm/completeItem.js.map +0 -1
  209. package/dist/esm/create-hub-request-options.d.ts +0 -29
  210. package/dist/esm/create-hub-request-options.js +0 -60
  211. package/dist/esm/create-hub-request-options.js.map +0 -1
  212. package/dist/esm/deleteHelpers/deleteEmptyGroups.d.ts +0 -24
  213. package/dist/esm/deleteHelpers/deleteEmptyGroups.js +0 -38
  214. package/dist/esm/deleteHelpers/deleteEmptyGroups.js.map +0 -1
  215. package/dist/esm/deleteHelpers/deleteGroupIfEmpty.d.ts +0 -27
  216. package/dist/esm/deleteHelpers/deleteGroupIfEmpty.js +0 -95
  217. package/dist/esm/deleteHelpers/deleteGroupIfEmpty.js.map +0 -1
  218. package/dist/esm/deleteHelpers/deleteSolutionContents.d.ts +0 -39
  219. package/dist/esm/deleteHelpers/deleteSolutionContents.js +0 -122
  220. package/dist/esm/deleteHelpers/deleteSolutionContents.js.map +0 -1
  221. package/dist/esm/deleteHelpers/deleteSolutionFolder.d.ts +0 -29
  222. package/dist/esm/deleteHelpers/deleteSolutionFolder.js +0 -77
  223. package/dist/esm/deleteHelpers/deleteSolutionFolder.js.map +0 -1
  224. package/dist/esm/deleteHelpers/deleteSolutionItem.d.ts +0 -31
  225. package/dist/esm/deleteHelpers/deleteSolutionItem.js +0 -48
  226. package/dist/esm/deleteHelpers/deleteSolutionItem.js.map +0 -1
  227. package/dist/esm/deleteHelpers/index.d.ts +0 -22
  228. package/dist/esm/deleteHelpers/index.js +0 -23
  229. package/dist/esm/deleteHelpers/index.js.map +0 -1
  230. package/dist/esm/deleteHelpers/reconstructBuildOrderIds.d.ts +0 -27
  231. package/dist/esm/deleteHelpers/reconstructBuildOrderIds.js +0 -29
  232. package/dist/esm/deleteHelpers/reconstructBuildOrderIds.js.map +0 -1
  233. package/dist/esm/deleteHelpers/removeItems.d.ts +0 -35
  234. package/dist/esm/deleteHelpers/removeItems.js +0 -111
  235. package/dist/esm/deleteHelpers/removeItems.js.map +0 -1
  236. package/dist/esm/deleteHelpers/reportProgress.d.ts +0 -27
  237. package/dist/esm/deleteHelpers/reportProgress.js +0 -42
  238. package/dist/esm/deleteHelpers/reportProgress.js.map +0 -1
  239. package/dist/esm/deleteSolution.d.ts +0 -56
  240. package/dist/esm/deleteSolution.js +0 -101
  241. package/dist/esm/deleteSolution.js.map +0 -1
  242. package/dist/esm/dependencies.d.ts +0 -26
  243. package/dist/esm/dependencies.js +0 -167
  244. package/dist/esm/dependencies.js.map +0 -1
  245. package/dist/esm/featureServiceHelpers.d.ts +0 -847
  246. package/dist/esm/featureServiceHelpers.js +0 -2466
  247. package/dist/esm/featureServiceHelpers.js.map +0 -1
  248. package/dist/esm/formHelpers.d.ts +0 -26
  249. package/dist/esm/formHelpers.js +0 -35
  250. package/dist/esm/formHelpers.js.map +0 -1
  251. package/dist/esm/generalHelpers.d.ts +0 -447
  252. package/dist/esm/generalHelpers.js +0 -903
  253. package/dist/esm/generalHelpers.js.map +0 -1
  254. package/dist/esm/get-subscription-info.d.ts +0 -27
  255. package/dist/esm/get-subscription-info.js +0 -34
  256. package/dist/esm/get-subscription-info.js.map +0 -1
  257. package/dist/esm/getDeletableSolutionInfo.d.ts +0 -30
  258. package/dist/esm/getDeletableSolutionInfo.js +0 -48
  259. package/dist/esm/getDeletableSolutionInfo.js.map +0 -1
  260. package/dist/esm/getItemTypeAbbrev.d.ts +0 -19
  261. package/dist/esm/getItemTypeAbbrev.js +0 -182
  262. package/dist/esm/getItemTypeAbbrev.js.map +0 -1
  263. package/dist/esm/getSolutionSummary.d.ts +0 -28
  264. package/dist/esm/getSolutionSummary.js +0 -95
  265. package/dist/esm/getSolutionSummary.js.map +0 -1
  266. package/dist/esm/index.d.ts +0 -49
  267. package/dist/esm/index.js +0 -50
  268. package/dist/esm/index.js.map +0 -1
  269. package/dist/esm/interfaces.d.ts +0 -1446
  270. package/dist/esm/interfaces.js +0 -69
  271. package/dist/esm/interfaces.js.map +0 -1
  272. package/dist/esm/item-reuse.d.ts +0 -140
  273. package/dist/esm/item-reuse.js +0 -167
  274. package/dist/esm/item-reuse.js.map +0 -1
  275. package/dist/esm/libConnectors.d.ts +0 -73
  276. package/dist/esm/libConnectors.js +0 -105
  277. package/dist/esm/libConnectors.js.map +0 -1
  278. package/dist/esm/migrations/apply-schema.d.ts +0 -24
  279. package/dist/esm/migrations/apply-schema.js +0 -32
  280. package/dist/esm/migrations/apply-schema.js.map +0 -1
  281. package/dist/esm/migrations/is-legacy-solution.d.ts +0 -24
  282. package/dist/esm/migrations/is-legacy-solution.js +0 -35
  283. package/dist/esm/migrations/is-legacy-solution.js.map +0 -1
  284. package/dist/esm/migrations/upgrade-three-dot-one.d.ts +0 -26
  285. package/dist/esm/migrations/upgrade-three-dot-one.js +0 -44
  286. package/dist/esm/migrations/upgrade-three-dot-one.js.map +0 -1
  287. package/dist/esm/migrations/upgrade-three-dot-zero.d.ts +0 -27
  288. package/dist/esm/migrations/upgrade-three-dot-zero.js +0 -39
  289. package/dist/esm/migrations/upgrade-three-dot-zero.js.map +0 -1
  290. package/dist/esm/migrations/upgrade-two-dot-five.d.ts +0 -24
  291. package/dist/esm/migrations/upgrade-two-dot-five.js +0 -69
  292. package/dist/esm/migrations/upgrade-two-dot-five.js.map +0 -1
  293. package/dist/esm/migrations/upgrade-two-dot-four.d.ts +0 -24
  294. package/dist/esm/migrations/upgrade-two-dot-four.js +0 -68
  295. package/dist/esm/migrations/upgrade-two-dot-four.js.map +0 -1
  296. package/dist/esm/migrations/upgrade-two-dot-one.d.ts +0 -7
  297. package/dist/esm/migrations/upgrade-two-dot-one.js +0 -35
  298. package/dist/esm/migrations/upgrade-two-dot-one.js.map +0 -1
  299. package/dist/esm/migrations/upgrade-two-dot-seven.d.ts +0 -23
  300. package/dist/esm/migrations/upgrade-two-dot-seven.js +0 -54
  301. package/dist/esm/migrations/upgrade-two-dot-seven.js.map +0 -1
  302. package/dist/esm/migrations/upgrade-two-dot-six.d.ts +0 -27
  303. package/dist/esm/migrations/upgrade-two-dot-six.js +0 -57
  304. package/dist/esm/migrations/upgrade-two-dot-six.js.map +0 -1
  305. package/dist/esm/migrations/upgrade-two-dot-three.d.ts +0 -23
  306. package/dist/esm/migrations/upgrade-two-dot-three.js +0 -51
  307. package/dist/esm/migrations/upgrade-two-dot-three.js.map +0 -1
  308. package/dist/esm/migrations/upgrade-two-dot-two.d.ts +0 -23
  309. package/dist/esm/migrations/upgrade-two-dot-two.js +0 -54
  310. package/dist/esm/migrations/upgrade-two-dot-two.js.map +0 -1
  311. package/dist/esm/migrations/upgrade-two-dot-zero.d.ts +0 -44
  312. package/dist/esm/migrations/upgrade-two-dot-zero.js +0 -88
  313. package/dist/esm/migrations/upgrade-two-dot-zero.js.map +0 -1
  314. package/dist/esm/migrator.d.ts +0 -25
  315. package/dist/esm/migrator.js +0 -71
  316. package/dist/esm/migrator.js.map +0 -1
  317. package/dist/esm/resourceHelpers.d.ts +0 -192
  318. package/dist/esm/resourceHelpers.js +0 -361
  319. package/dist/esm/resourceHelpers.js.map +0 -1
  320. package/dist/esm/resources/add-resource.d.ts +0 -38
  321. package/dist/esm/resources/add-resource.js +0 -79
  322. package/dist/esm/resources/add-resource.js.map +0 -1
  323. package/dist/esm/resources/addMetadataFromBlob.d.ts +0 -25
  324. package/dist/esm/resources/addMetadataFromBlob.js +0 -39
  325. package/dist/esm/resources/addMetadataFromBlob.js.map +0 -1
  326. package/dist/esm/resources/convert-item-resource-to-storage-resource.d.ts +0 -32
  327. package/dist/esm/resources/convert-item-resource-to-storage-resource.js +0 -66
  328. package/dist/esm/resources/convert-item-resource-to-storage-resource.js.map +0 -1
  329. package/dist/esm/resources/convert-storage-resource-to-item-resource.d.ts +0 -29
  330. package/dist/esm/resources/convert-storage-resource-to-item-resource.js +0 -66
  331. package/dist/esm/resources/convert-storage-resource-to-item-resource.js.map +0 -1
  332. package/dist/esm/resources/copyAssociatedFiles.d.ts +0 -79
  333. package/dist/esm/resources/copyAssociatedFiles.js +0 -339
  334. package/dist/esm/resources/copyAssociatedFiles.js.map +0 -1
  335. package/dist/esm/resources/copyDataIntoItem.d.ts +0 -34
  336. package/dist/esm/resources/copyDataIntoItem.js +0 -40
  337. package/dist/esm/resources/copyDataIntoItem.js.map +0 -1
  338. package/dist/esm/resources/copyMetadataIntoItem.d.ts +0 -27
  339. package/dist/esm/resources/copyMetadataIntoItem.js +0 -40
  340. package/dist/esm/resources/copyMetadataIntoItem.js.map +0 -1
  341. package/dist/esm/resources/copyResourceIntoZip.d.ts +0 -34
  342. package/dist/esm/resources/copyResourceIntoZip.js +0 -69
  343. package/dist/esm/resources/copyResourceIntoZip.js.map +0 -1
  344. package/dist/esm/resources/copyZipIntoItem.d.ts +0 -26
  345. package/dist/esm/resources/copyZipIntoItem.js +0 -49
  346. package/dist/esm/resources/copyZipIntoItem.js.map +0 -1
  347. package/dist/esm/resources/createCopyResults.d.ts +0 -25
  348. package/dist/esm/resources/createCopyResults.js +0 -32
  349. package/dist/esm/resources/createCopyResults.js.map +0 -1
  350. package/dist/esm/resources/get-blob.d.ts +0 -25
  351. package/dist/esm/resources/get-blob.js +0 -38
  352. package/dist/esm/resources/get-blob.js.map +0 -1
  353. package/dist/esm/resources/getItemResourcesFilesFromPaths.d.ts +0 -25
  354. package/dist/esm/resources/getItemResourcesFilesFromPaths.js +0 -45
  355. package/dist/esm/resources/getItemResourcesFilesFromPaths.js.map +0 -1
  356. package/dist/esm/resources/getItemResourcesPaths.d.ts +0 -27
  357. package/dist/esm/resources/getItemResourcesPaths.js +0 -76
  358. package/dist/esm/resources/getItemResourcesPaths.js.map +0 -1
  359. package/dist/esm/resources/index.d.ts +0 -30
  360. package/dist/esm/resources/index.js +0 -31
  361. package/dist/esm/resources/index.js.map +0 -1
  362. package/dist/esm/resources/solution-resource.d.ts +0 -35
  363. package/dist/esm/resources/solution-resource.js +0 -28
  364. package/dist/esm/resources/solution-resource.js.map +0 -1
  365. package/dist/esm/resources/transform-resource-paths-to-solution-resources.d.ts +0 -56
  366. package/dist/esm/resources/transform-resource-paths-to-solution-resources.js +0 -132
  367. package/dist/esm/resources/transform-resource-paths-to-solution-resources.js.map +0 -1
  368. package/dist/esm/resources/update-resource.d.ts +0 -27
  369. package/dist/esm/resources/update-resource.js +0 -48
  370. package/dist/esm/resources/update-resource.js.map +0 -1
  371. package/dist/esm/restHelpers.d.ts +0 -634
  372. package/dist/esm/restHelpers.js +0 -1943
  373. package/dist/esm/restHelpers.js.map +0 -1
  374. package/dist/esm/restHelpersGet.d.ts +0 -303
  375. package/dist/esm/restHelpersGet.js +0 -793
  376. package/dist/esm/restHelpersGet.js.map +0 -1
  377. package/dist/esm/sharing/index.d.ts +0 -16
  378. package/dist/esm/sharing/index.js +0 -17
  379. package/dist/esm/sharing/index.js.map +0 -1
  380. package/dist/esm/sharing/share-item-to-groups.d.ts +0 -26
  381. package/dist/esm/sharing/share-item-to-groups.js +0 -40
  382. package/dist/esm/sharing/share-item-to-groups.js.map +0 -1
  383. package/dist/esm/templatization.d.ts +0 -139
  384. package/dist/esm/templatization.js +0 -291
  385. package/dist/esm/templatization.js.map +0 -1
  386. package/dist/esm/trackingHelpers.d.ts +0 -115
  387. package/dist/esm/trackingHelpers.js +0 -200
  388. package/dist/esm/trackingHelpers.js.map +0 -1
  389. package/dist/esm/velocityHelpers.d.ts +0 -68
  390. package/dist/esm/velocityHelpers.js +0 -144
  391. package/dist/esm/velocityHelpers.js.map +0 -1
  392. package/dist/esm/webtoolHelpers.d.ts +0 -57
  393. package/dist/esm/webtoolHelpers.js +0 -95
  394. package/dist/esm/webtoolHelpers.js.map +0 -1
  395. package/dist/esm/workflowHelpers.d.ts +0 -112
  396. package/dist/esm/workflowHelpers.js +0 -270
  397. package/dist/esm/workflowHelpers.js.map +0 -1
  398. package/dist/esm/workforceHelpers.d.ts +0 -121
  399. package/dist/esm/workforceHelpers.js +0 -691
  400. package/dist/esm/workforceHelpers.js.map +0 -1
  401. package/dist/esm/zip-utils.d.ts +0 -85
  402. package/dist/esm/zip-utils.js +0 -142
  403. package/dist/esm/zip-utils.js.map +0 -1
  404. package/dist/solution.js_commit.txt +0 -7
@@ -1,2466 +0,0 @@
1
- /** @license
2
- * Copyright 2019 Esri
3
- *
4
- * Licensed under the Apache License, Version 2.0 (the "License");
5
- * you may not use this file except in compliance with the License.
6
- * You may obtain a copy of the License at
7
- *
8
- * http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software
11
- * distributed under the License is distributed on an "AS IS" BASIS,
12
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
- * See the License for the specific language governing permissions and
14
- * limitations under the License.
15
- */
16
- /**
17
- * Provides general helper functions.
18
- *
19
- * @module featureServiceHelpers
20
- */
21
- // ------------------------------------------------------------------------------------------------------------------ //
22
- //#region Imports -------------------------------------------------------------------------------------------------------//
23
- import { UNREACHABLE, } from "./interfaces";
24
- import { checkUrlPathTermination, deleteProp, deleteProps, fail, generateGUID, getProp, setCreateProp, setProp, } from "./generalHelpers";
25
- import { replaceInTemplate, templatizeTerm, templatizeIds } from "./templatization";
26
- import { addToServiceDefinition, getLayerUpdates, getRequest } from "./restHelpers";
27
- import { isTrackingViewTemplate, templatizeTracker } from "./trackingHelpers";
28
- import { queryRelated, request, } from "./arcgisRestJS";
29
- //#endregion ------------------------------------------------------------------------------------------------------------//
30
- //#region Public functions ----------------------------------------------------------------------------------------------//
31
- /**
32
- * Get the related records for a feature service.
33
- *
34
- * @param url Feature service's URL, e.g., layer.url
35
- * @param relationshipId Id of relationship
36
- * @param objectIds Objects in the feature service whose related records are sought
37
- */
38
- export function getFeatureServiceRelatedRecords(url, relationshipId, objectIds) {
39
- const options = {
40
- url: url + `/${relationshipId}`,
41
- relationshipId,
42
- objectIds,
43
- };
44
- return queryRelated(options);
45
- }
46
- /**
47
- * Templatize the ID, url, field references ect
48
- *
49
- * @param itemTemplate Template for feature service item
50
- * @param dependencies Array of IDependency for name mapping
51
- * @param templatizeFieldReferences Templatize all field references within a layer
52
- * @param templateDictionary Hash mapping property names to replacement values
53
- * @returns A promise that will resolve when template has been updated
54
- * @private
55
- */
56
- export function templatize(itemTemplate, dependencies, templatizeFieldReferences, templateDictionary) {
57
- templateDictionary = templateDictionary || {};
58
- // Common templatizations
59
- const id = itemTemplate.item.id;
60
- const fsUrl = itemTemplate.item.url;
61
- itemTemplate.item = {
62
- ...itemTemplate.item,
63
- id: templatizeTerm(id, id, ".itemId"),
64
- url: _templatize(id, "url"),
65
- typeKeywords: templatizeIds(itemTemplate.item.typeKeywords),
66
- };
67
- // special handeling if we are dealing with a tracker view
68
- templatizeTracker(itemTemplate);
69
- // added for issue #928
70
- deleteProp(itemTemplate, "properties.service.size");
71
- const jsonLayers = itemTemplate.properties.layers || [];
72
- const jsonTables = itemTemplate.properties.tables || [];
73
- const jsonItems = jsonLayers.concat(jsonTables);
74
- const data = itemTemplate.data || {};
75
- const layers = data.layers || [];
76
- const tables = data.tables || [];
77
- const _items = layers.concat(tables);
78
- // Set up symbols for the URL of the feature service and its layers and tables
79
- templateDictionary[fsUrl] = itemTemplate.item.url; // map FS URL to its templatized form
80
- jsonItems.concat(_items).forEach((layer) => {
81
- templateDictionary[fsUrl + "/" + layer.id] = _templatize(id, "layer" + layer.id + ".url");
82
- });
83
- // templatize the service references serviceItemId
84
- itemTemplate.properties.service.serviceItemId = templatizeTerm(itemTemplate.properties.service.serviceItemId, itemTemplate.properties.service.serviceItemId, ".itemId");
85
- const initialExtent = getProp(itemTemplate, "properties.service.initialExtent");
86
- /* istanbul ignore else */
87
- if (initialExtent) {
88
- itemTemplate.properties.service.initialExtent = templatizeTerm(id, id, ".solutionExtent");
89
- }
90
- const fullExtent = getProp(itemTemplate, "properties.service.fullExtent");
91
- /* istanbul ignore else */
92
- if (fullExtent) {
93
- itemTemplate.properties.service.fullExtent = templatizeTerm(id, id, ".solutionExtent");
94
- }
95
- // this default extent will be used in cases where it does not make sense to apply the orgs
96
- // extent to a service with a local spatial reference
97
- itemTemplate.properties.defaultExtent = initialExtent || fullExtent;
98
- // in some cases a service does not have a spatial reference defined
99
- // added for issue #699
100
- if (!getProp(itemTemplate, "properties.service.spatialReference") &&
101
- getProp(itemTemplate, "properties.defaultExtent.spatialReference")) {
102
- setCreateProp(itemTemplate, "properties.service.spatialReference", itemTemplate.properties.defaultExtent.spatialReference);
103
- }
104
- // if any layer hasZ enabled then we need to set
105
- // enableZDefaults and zDefault to deploy to enterprise
106
- let hasZ = false;
107
- jsonItems.forEach((jsonItem) => {
108
- // get the source service json for the given data item
109
- const matchingItems = _items.filter((item) => {
110
- return jsonItem.id === item.id;
111
- });
112
- // templatize the source service json
113
- const _item = matchingItems.length === 1 ? matchingItems[0] : undefined;
114
- _templatizeLayer(_item, jsonItem, itemTemplate, dependencies, templatizeFieldReferences, templateDictionary);
115
- hasZ = jsonItem.hasZ || (_item && _item.hasZ) ? true : hasZ;
116
- });
117
- if (hasZ) {
118
- itemTemplate.properties.service.enableZDefaults = true;
119
- itemTemplate.properties.service.zDefault = 0;
120
- }
121
- return itemTemplate;
122
- }
123
- /**
124
- * Delete key properties that are system managed
125
- *
126
- * @param layer The data layer instance with field name references within
127
- * @param isPortal When true we are deploying to portal
128
- */
129
- export function deleteViewProps(layer, isPortal) {
130
- const props = ["definitionQuery"];
131
- const portalOnlyProps = ["indexes"];
132
- props.forEach((prop) => deleteProp(layer, prop));
133
- if (isPortal) {
134
- portalOnlyProps.forEach((prop) => {
135
- deleteProp(layer, prop);
136
- });
137
- }
138
- }
139
- /**
140
- * Cache properties that contain field references
141
- *
142
- * removeProp added for issue #644
143
- * setting all props on add for online now
144
- * investigating if we can also just allow them to be set during add for portal
145
- *
146
- * @param layer The data layer instance with field name references within
147
- * @param fieldInfos the object that stores the cached field infos
148
- * @param isView When true the current layer is a view and does not need to cache subtype details
149
- * @param isPortal When true we are deploying to portal
150
- * @returns An updated instance of the fieldInfos
151
- */
152
- export function cacheFieldInfos(layer, fieldInfos, isView, isPortal) {
153
- // cache the source fields as they are in the original source
154
- if (layer && layer.fields) {
155
- fieldInfos[layer.id] = {
156
- sourceFields: JSON.parse(JSON.stringify(layer.fields)),
157
- type: layer.type,
158
- id: layer.id,
159
- };
160
- /* istanbul ignore else */
161
- if (!isView && isPortal) {
162
- fieldInfos[layer.id].subtypes = layer.subtypes;
163
- fieldInfos[layer.id].subtypeField = layer.subtypeField;
164
- fieldInfos[layer.id].defaultSubtypeCode = layer.defaultSubtypeCode;
165
- }
166
- }
167
- // cache each of these properties as they each can contain field references
168
- // and will have associated updateDefinition calls when deploying to portal
169
- // as well as online for relationships...as relationships added with addToDef will cause failure
170
- // https://devtopia.esri.com/WebGIS/solutions-development-support/issues/299
171
- // subtypes, subtypeField, and defaultSubtypeCode should not exist in initial addToDef call and
172
- // should be added with subsequent add and update calls in a specific order
173
- const props = {
174
- editFieldsInfo: false,
175
- types: false,
176
- templates: false,
177
- relationships: true,
178
- drawingInfo: false,
179
- timeInfo: false,
180
- viewDefinitionQuery: false,
181
- };
182
- /* istanbul ignore else */
183
- if (!isView && isPortal) {
184
- props["subtypes"] = true;
185
- props["subtypeField"] = true;
186
- props["defaultSubtypeCode"] = true;
187
- }
188
- Object.keys(props).forEach((k) => {
189
- _cacheFieldInfo(layer, k, fieldInfos, props[k]);
190
- });
191
- return fieldInfos;
192
- }
193
- /**
194
- * Cache the stored contingent values so we can add them in subsequent addToDef calls
195
- *
196
- * @param id The layer id for the associated values to be stored with
197
- * @param fieldInfos The object that stores the cached field infos
198
- * @param itemTemplate The current itemTemplate being processed
199
- * @returns An updated instance of the fieldInfos
200
- */
201
- export function cacheContingentValues(id, fieldInfos, itemTemplate) {
202
- const contingentValues = getProp(itemTemplate, "properties.contingentValues");
203
- if (contingentValues && contingentValues[id]) {
204
- fieldInfos[id]["contingentValues"] = contingentValues[id];
205
- }
206
- return fieldInfos;
207
- }
208
- /**
209
- * Cache the stored contingent values so we can add them in subsequent addToDef calls
210
- *
211
- * @param layer The current layer to check indexes on
212
- * @param fieldInfos The object that stores the cached field infos
213
- * @returns An updated instance of the fieldInfos
214
- */
215
- export function cacheIndexes(layer, fieldInfos, isView, isMsView) {
216
- /* istanbul ignore else */
217
- if (!isView && !isMsView && Array.isArray(layer.indexes)) {
218
- const oidField = layer.objectIdField;
219
- const guidField = layer.globalIdField;
220
- fieldInfos[layer.id].indexes = layer.indexes.filter((i) => {
221
- if ((i.isUnique && i.fields !== oidField && i.fields !== guidField) || i.indexType === "FullText") {
222
- if (i.name) {
223
- delete i.name;
224
- }
225
- return i;
226
- }
227
- });
228
- delete layer.indexes;
229
- }
230
- return fieldInfos;
231
- }
232
- /**
233
- * Helper function to cache a single property into the fieldInfos object
234
- * This property will be removed from the layer instance.
235
- *
236
- * @param layer the data layer being cloned
237
- * @param prop the property name used to cache
238
- * @param fieldInfos the object that will store the cached property
239
- * @param removeProp when true relationships prop will be set to null and subtype props will be deleted
240
- * @private
241
- */
242
- export function _cacheFieldInfo(layer, prop, fieldInfos, removeProp) {
243
- /* istanbul ignore else */
244
- if (layer && layer.hasOwnProperty(prop) && fieldInfos && fieldInfos.hasOwnProperty(layer.id)) {
245
- fieldInfos[layer.id][prop] = layer[prop];
246
- // editFieldsInfo does not come through unless its with the layer
247
- // when it's being added
248
- /* istanbul ignore else */
249
- if (removeProp && prop === "relationships") {
250
- layer[prop] = null;
251
- }
252
- else if (removeProp) {
253
- delete layer[prop];
254
- }
255
- }
256
- }
257
- /**
258
- * Cache popup info that can contain field references
259
- *
260
- * @param data The items data property
261
- * @returns An updated instance of the popupInfos
262
- */
263
- export function cachePopupInfos(data) {
264
- // store any popupInfo so we can update after any potential name changes
265
- const popupInfos = {
266
- layers: {},
267
- tables: {},
268
- };
269
- if (data && data.layers && data.layers.length > 0) {
270
- _cachePopupInfo(popupInfos, "layers", data.layers);
271
- }
272
- if (data && data.tables && data.tables.length > 0) {
273
- _cachePopupInfo(popupInfos, "tables", data.tables);
274
- }
275
- return popupInfos;
276
- }
277
- /**
278
- * Helper function to cache a single popupInfo
279
- * This property will be reset on the layer
280
- *
281
- * @param popupInfos object to store the cahced popupInfo
282
- * @param type is it a layer or table
283
- * @param _items list or either layers or tables
284
- * @private
285
- */
286
- export function _cachePopupInfo(popupInfos, type, _items) {
287
- _items.forEach((item) => {
288
- if (item && item.hasOwnProperty("popupInfo")) {
289
- popupInfos[type][item.id] = item.popupInfo;
290
- item.popupInfo = {};
291
- }
292
- });
293
- }
294
- /**
295
- * Store basic layer information for potential replacement if we are unable to access a given service
296
- * added for issue #859
297
- *
298
- * @param layerId the id for the layer
299
- * @param itemId the id for the item
300
- * @param url the url for the layer
301
- * @param templateDictionary Hash of key details used for variable replacement
302
- * @returns templatized itemTemplate
303
- */
304
- export function cacheLayerInfo(layerId, itemId, url, templateDictionary) {
305
- if (layerId) {
306
- const layerIdVar = `layer${layerId}`;
307
- // need to structure these differently so they are not used for standard replacement calls
308
- // this now adds additional vars that are not needing replacement unless we fail to fetch the service
309
- const newVars = getProp(templateDictionary, `${UNREACHABLE}.${itemId}`) || {
310
- itemId,
311
- };
312
- newVars[layerIdVar] = getProp(newVars, layerIdVar) || {
313
- layerId,
314
- itemId,
315
- };
316
- if (url !== "") {
317
- newVars[layerIdVar]["url"] = url;
318
- }
319
- const unreachableVars = {};
320
- unreachableVars[itemId] = newVars;
321
- templateDictionary[UNREACHABLE] = {
322
- ...templateDictionary[UNREACHABLE],
323
- ...unreachableVars,
324
- };
325
- }
326
- }
327
- /**
328
- * Creates an item in a specified folder (except for Group item type).
329
- *
330
- * @param itemTemplate Item to be created; n.b.: this item is modified
331
- * @param templateDictionary Hash mapping property names to replacement values
332
- * @param createResponse Response from create service
333
- * @returns An updated instance of the template
334
- * @private
335
- */
336
- export function updateTemplate(itemTemplate, templateDictionary, createResponse) {
337
- // Update the item with any typeKeywords that were added on create
338
- _updateTypeKeywords(itemTemplate, createResponse);
339
- // Add the new item to the template dictionary
340
- templateDictionary[itemTemplate.itemId] = Object.assign(templateDictionary[itemTemplate.itemId] || {}, {
341
- itemId: createResponse.serviceItemId,
342
- url: checkUrlPathTermination(createResponse.serviceurl),
343
- name: createResponse.name,
344
- });
345
- // Update the item template now that the new service has been created
346
- itemTemplate.itemId = createResponse.serviceItemId;
347
- return replaceInTemplate(itemTemplate, templateDictionary);
348
- }
349
- /**
350
- * Updates the items typeKeywords to include any typeKeywords that
351
- * were added by the create service request
352
- *
353
- * @param itemTemplate Item to be created; n.b.: this item is modified
354
- * @param createResponse Response from create service
355
- * @returns An updated instance of the template
356
- * @private
357
- */
358
- export function _updateTypeKeywords(itemTemplate, createResponse) {
359
- // https://github.com/Esri/solution.js/issues/589
360
- const iKwords = getProp(itemTemplate, "item.typeKeywords");
361
- const cKwords = getProp(createResponse, "typeKeywords");
362
- if (iKwords && cKwords) {
363
- setProp(itemTemplate, "item.typeKeywords", iKwords.concat(cKwords.filter((k) => iKwords.indexOf(k) < 0)));
364
- }
365
- return itemTemplate;
366
- }
367
- /**
368
- * Add layer urls from tracking views to the templateDictionary to be used for adlib replacements
369
- *
370
- * @param itemTemplate Item to be created; n.b.: this item is modified
371
- * @param templateDictionary Hash mapping property names to replacement values
372
- * @returns void
373
- * @private
374
- */
375
- export function _setTrackingViewLayerSettings(itemTemplate, templateDictionary) {
376
- const url = itemTemplate.item.url;
377
- const newId = itemTemplate.itemId;
378
- let k;
379
- Object.keys(templateDictionary).some((_k) => {
380
- if (newId === templateDictionary[_k].itemId) {
381
- k = _k;
382
- return true;
383
- }
384
- });
385
- itemTemplate.properties.layers.forEach((l) => {
386
- const id = l.id.toString();
387
- templateDictionary[k][`layer${id}`] = {
388
- url: checkUrlPathTermination(url) + id,
389
- };
390
- });
391
- }
392
- /**
393
- * Create the name mapping object that will allow for all templatized field
394
- * references to be de-templatized.
395
- * This also removes the stored sourceFields and newFields arrays from fieldInfos.
396
- *
397
- * @example
398
- * \{ layer0: \{ fields: \{ lowerCaseSourceFieldName: newFieldNameAfterDeployment \} \} \}
399
- *
400
- * @param layerInfos The object that stores the cached layer properties and name mapping
401
- * @returns The settings object that will be used to de-templatize the field references.
402
- */
403
- export function getLayerSettings(layerInfos, url, itemId, enterpriseIDMapping) {
404
- const settings = {};
405
- const ids = Object.keys(layerInfos);
406
- ids.forEach((id) => {
407
- const _layerId = getProp(layerInfos[id], "item.id");
408
- const isNum = parseInt(_layerId, 10) > -1;
409
- const layerId = isNum && enterpriseIDMapping ? enterpriseIDMapping[_layerId] : isNum ? _layerId : id;
410
- settings[`layer${isNum ? _layerId : id}`] = {
411
- fields: _getNameMapping(layerInfos, id),
412
- url: checkUrlPathTermination(url) + layerId,
413
- layerId,
414
- itemId,
415
- };
416
- deleteProp(layerInfos[id], "newFields");
417
- deleteProp(layerInfos[id], "sourceFields");
418
- });
419
- return settings;
420
- }
421
- /**
422
- * Set the names and titles for all feature services.
423
- *
424
- * This function will ensure that we have unique feature service names.
425
- * The feature service name will have a generated GUID appended.
426
- *
427
- * @param templates A collection of AGO item templates.
428
- * @returns An updated collection of AGO templates with unique feature service names.
429
- */
430
- export function setNamesAndTitles(templates) {
431
- const guid = generateGUID();
432
- const names = [];
433
- return templates.map((t) => {
434
- /* istanbul ignore else */
435
- if (t.item.type === "Feature Service") {
436
- // Retain the existing title but swap with name if it's missing
437
- t.item.title = t.item.title || t.item.name;
438
- /* istanbul ignore else */
439
- if (!isTrackingViewTemplate(t)) {
440
- // Need to set the service name: name + "_" + newItemId
441
- let baseName = t.item.name || t.item.title;
442
- // If the name already contains a GUID remove it
443
- baseName = baseName.replace(/_[0-9A-F]{32}/gi, "");
444
- // The name length limit is 98
445
- // Limit the baseName to 50 characters before the _<guid>
446
- const name = baseName.substring(0, 50) + "_" + guid;
447
- // If the name + GUID already exists then append "_occurrenceCount"
448
- t.item.name = names.indexOf(name) === -1 ? name : `${name}_${names.filter((n) => n === name).length}`;
449
- names.push(name);
450
- }
451
- }
452
- return t;
453
- });
454
- }
455
- /**
456
- * This is used when deploying views.
457
- * We need to update fields referenced in adminLayerInfo for relationships prior to deploying the view.
458
- * This moves the fieldInfos for the views source layers from the item settings for the source layer
459
- * to the item settings for the view.
460
- *
461
- * @param itemTemplate The current itemTemplate being processed.
462
- * @param settings The settings object used to de-templatize the various templates within the item.
463
- */
464
- export function updateSettingsFieldInfos(itemTemplate, settings) {
465
- const dependencies = itemTemplate.dependencies;
466
- const id = itemTemplate.itemId;
467
- const settingsKeys = Object.keys(settings);
468
- settingsKeys.forEach((k) => {
469
- if (id === settings[k].itemId) {
470
- dependencies.forEach((d) => {
471
- settingsKeys.forEach((_k) => {
472
- /* istanbul ignore else */
473
- if (d === _k) {
474
- // combine for multi-source views
475
- const fieldInfos = {};
476
- fieldInfos[d] = getProp(settings[_k], "fieldInfos");
477
- settings[k]["sourceServiceFields"] = settings[k]["sourceServiceFields"]
478
- ? { ...settings[k]["sourceServiceFields"], ...fieldInfos }
479
- : fieldInfos;
480
- const layerKeys = Object.keys(settings[_k]);
481
- layerKeys.forEach((layerKey) => {
482
- /* istanbul ignore else */
483
- if (layerKey.startsWith("layer")) {
484
- settings[k][layerKey] = settings[_k][layerKey];
485
- }
486
- });
487
- }
488
- });
489
- });
490
- }
491
- });
492
- }
493
- /**
494
- * Add flag to indicate item should be ignored.
495
- * Construct template dictionary to detemplatize any references to this item by other items.
496
- *
497
- * @param template Template for feature service item
498
- * @param authentication Credentials for the request
499
- * @returns A promise that will resolve when template has been updated
500
- * @private
501
- */
502
- export function updateTemplateForInvalidDesignations(template, authentication) {
503
- return new Promise((resolve, reject) => {
504
- template.properties.hasInvalidDesignations = true;
505
- if (template.item.url) {
506
- // get the admin URL
507
- const url = template.item.url;
508
- request(url + "?f=json", {
509
- authentication: authentication,
510
- }).then((serviceData) => {
511
- const layerInfos = {};
512
- const layersAndTables = (serviceData.layers || []).concat(serviceData.tables || []);
513
- layersAndTables.forEach((l) => {
514
- /* istanbul ignore else */
515
- if (l && l.hasOwnProperty("id")) {
516
- layerInfos[l.id] = l;
517
- }
518
- });
519
- template.data[template.itemId] = Object.assign({
520
- itemId: template.itemId,
521
- }, getLayerSettings(layerInfos, url, template.itemId));
522
- resolve(template);
523
- }, (e) => reject(fail(e)));
524
- }
525
- else {
526
- resolve(template);
527
- }
528
- });
529
- }
530
- /**
531
- * Get the contingent values for each layer in the service.
532
- * Remove key props that cannot be included with the addToDef call on deploy.
533
- * Store the values alongside other key feature service properties in the template
534
- *
535
- * @param properties the current feature services properties
536
- * @param adminUrl the current feature service url
537
- * @param authentication Credentials for the request to AGOL
538
- * @returns A promise that will resolve when the contingent values have been fetched.
539
- * This function will update the provided properties argument when contingent values are found.
540
- */
541
- export function processContingentValues(properties, adminUrl, authentication) {
542
- return new Promise((resolve, reject) => {
543
- if (getProp(properties, "service.isView")) {
544
- // views will inherit from the source service
545
- resolve();
546
- }
547
- else {
548
- const layersAndTables = (properties.layers || []).concat(properties.tables || []);
549
- const layerIds = [];
550
- const contingentValuePromises = layersAndTables.reduce((prev, cur) => {
551
- /* istanbul ignore else */
552
- if (cur.hasContingentValuesDefinition) {
553
- prev.push(request(`${adminUrl}/${cur["id"]}/contingentValues?f=json`, {
554
- authentication,
555
- }));
556
- layerIds.push(cur["id"]);
557
- }
558
- return prev;
559
- }, []);
560
- if (contingentValuePromises.length > 0) {
561
- Promise.all(contingentValuePromises).then((results) => {
562
- const contingentValues = {};
563
- results.forEach((r, i) => {
564
- deleteProp(r, "typeCodes");
565
- /* istanbul ignore else */
566
- if (getProp(r, "stringDicts") && getProp(r, "contingentValuesDefinition")) {
567
- r.contingentValuesDefinition["stringDicts"] = r.stringDicts;
568
- deleteProp(r, "stringDicts");
569
- }
570
- deleteProps(getProp(r, "contingentValuesDefinition"), [
571
- "layerID",
572
- "layerName",
573
- "geometryType",
574
- "hasSubType",
575
- ]);
576
- contingentValues[layerIds[i]] = r;
577
- });
578
- properties.contingentValues = contingentValues;
579
- resolve();
580
- }, reject);
581
- }
582
- else {
583
- resolve();
584
- }
585
- }
586
- });
587
- }
588
- /**
589
- * Replace the field name reference templates with the new field names after deployment.
590
- *
591
- * @param fieldInfos The object that stores the cached layer properties and name mapping
592
- * @param popupInfos The object from the popupInfo property for the layer
593
- * @param adminLayerInfos The object from the adminLayerInfo property for the layer
594
- * @param settings The settings object that has all of the mappings for de-templatizing.
595
- * @returns An object that contains updated instances of popupInfos, fieldInfos, and adminLayerInfos
596
- */
597
- export function deTemplatizeFieldInfos(fieldInfos, popupInfos, adminLayerInfos, settings) {
598
- const fieldInfoKeys = Object.keys(fieldInfos);
599
- fieldInfoKeys.forEach((id) => {
600
- if (fieldInfos[id].hasOwnProperty("templates")) {
601
- fieldInfos[id].templates = JSON.parse(replaceInTemplate(JSON.stringify(fieldInfos[id].templates), settings));
602
- }
603
- if (fieldInfos[id].hasOwnProperty("adminLayerInfo")) {
604
- adminLayerInfos[id].viewLayerDefinition.table.relatedTables = fieldInfos[id].adminLayerInfo;
605
- deleteProp(fieldInfos[id], "adminLayerInfo");
606
- }
607
- if (fieldInfos[id].hasOwnProperty("types")) {
608
- fieldInfos[id].types = JSON.parse(replaceInTemplate(JSON.stringify(fieldInfos[id].types), settings));
609
- }
610
- });
611
- return {
612
- popupInfos: replaceInTemplate(popupInfos, settings),
613
- fieldInfos: replaceInTemplate(fieldInfos, settings),
614
- adminLayerInfos: replaceInTemplate(adminLayerInfos, settings),
615
- };
616
- }
617
- /**
618
- * This is used when deploying views.
619
- * We need to update fields referenced in adminLayerInfo for relationships prior to deploying the view.
620
- * This moves the fieldInfos for the views source layers from the item settings for the source layer
621
- * to the item settings for the view.
622
- *
623
- * @param itemTemplate The current itemTemplate being processed.
624
- * @returns array of layers and tables
625
- */
626
- export function getLayersAndTables(itemTemplate) {
627
- const properties = itemTemplate.properties;
628
- const layersAndTables = [];
629
- (properties.layers || []).forEach(function (layer) {
630
- layersAndTables.push({
631
- item: layer,
632
- type: "layer",
633
- });
634
- });
635
- (properties.tables || []).forEach(function (table) {
636
- layersAndTables.push({
637
- item: table,
638
- type: "table",
639
- });
640
- });
641
- return layersAndTables;
642
- }
643
- /**
644
- * Fetch each layer and table from service so we can determine what fields they have.
645
- * This is leveraged when we are using existing services so we can determine if we need to
646
- * remove any fields from views that depend on these layers and tables.
647
- *
648
- * @param url Feature service endpoint
649
- * @param ids layer and table ids
650
- * @param authentication Credentials for the request
651
- * @returns A promise that will resolve an array of promises with either a failure or the data
652
- * @private
653
- */
654
- export function getExistingLayersAndTables(url, ids, authentication) {
655
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
656
- return new Promise((resolve) => {
657
- const defs = ids.map((id) => {
658
- return request(checkUrlPathTermination(url) + id, {
659
- authentication,
660
- });
661
- });
662
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
663
- Promise.all(defs.map((p) => p.catch((e) => e))).then(resolve);
664
- });
665
- }
666
- /**
667
- * Adds the layers and tables of a feature service to it and restores their relationships.
668
- *
669
- * @param itemTemplate Feature service
670
- * @param templateDictionary Hash mapping Solution source id to id of its clone (and name & URL for feature
671
- * service)
672
- * @param popupInfos the cached popup info from the layers
673
- * @param authentication Credentials for the request
674
- * @returns A promise that will resolve when all layers and tables have been added
675
- * @private
676
- */
677
- export function addFeatureServiceLayersAndTables(itemTemplate, templateDictionary, popupInfos, authentication) {
678
- return new Promise((resolve, reject) => {
679
- if (isTrackingViewTemplate(itemTemplate)) {
680
- _setTrackingViewLayerSettings(itemTemplate, templateDictionary);
681
- resolve(null);
682
- }
683
- else {
684
- // Create a hash of various properties that contain field references
685
- const fieldInfos = {};
686
- const adminLayerInfos = {};
687
- // Add the service's layers and tables to it
688
- const layersAndTables = getLayersAndTables(itemTemplate);
689
- if (layersAndTables.length > 0) {
690
- addFeatureServiceDefinition(itemTemplate.item.url || "", layersAndTables, templateDictionary, authentication, itemTemplate.key, adminLayerInfos, fieldInfos, itemTemplate).then(() => {
691
- // Detemplatize field references and update the layer properties
692
- // Only failure path is handled by addFeatureServiceDefinition
693
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
694
- updateLayerFieldReferences(itemTemplate, fieldInfos, popupInfos, adminLayerInfos, templateDictionary).then((r) => {
695
- // Update relationships and layer definitions
696
- const updates = getLayerUpdates({
697
- message: "updated layer definition",
698
- objects: r.layerInfos.fieldInfos,
699
- itemTemplate: r.itemTemplate,
700
- authentication,
701
- }, templateDictionary.isPortal);
702
- // Process the updates sequentially
703
- updates
704
- .reduce((prev, update) => {
705
- return prev.then(() => {
706
- return getRequest(update, false, false, templateDictionary.isPortal);
707
- });
708
- }, Promise.resolve(null))
709
- .then(() => resolve(null), (e) => reject(fail(e)));
710
- });
711
- }, (e) => reject(fail(e)));
712
- }
713
- else {
714
- resolve(null);
715
- }
716
- }
717
- });
718
- }
719
- /**
720
- * Updates a feature service with a list of layers and/or tables.
721
- *
722
- * @param serviceUrl URL of feature service
723
- * @param listToAdd List of layers and/or tables to add
724
- * @param templateDictionary Hash mapping Solution source id to id of its clone (and name & URL for feature
725
- * service)
726
- * @param authentication Credentials for the request
727
- * @param key
728
- * @param adminLayerInfos Hash map of a layers adminLayerInfo
729
- * @param fieldInfos Hash map of properties that contain field references
730
- * @param itemTemplate
731
- * @returns A promise that will resolve when the feature service has been updated
732
- * @private
733
- */
734
- export function addFeatureServiceDefinition(serviceUrl, listToAdd, templateDictionary, authentication, key, adminLayerInfos, fieldInfos, itemTemplate) {
735
- return new Promise((resolve, reject) => {
736
- if (isTrackingViewTemplate(itemTemplate)) {
737
- resolve(null);
738
- }
739
- else {
740
- let options = {
741
- layers: [],
742
- tables: [],
743
- authentication,
744
- };
745
- // if the service has veiws keep track of the fields so we can use them to
746
- // compare with the view fields
747
- /* istanbul ignore else */
748
- if (getProp(itemTemplate, "properties.service.hasViews")) {
749
- _updateTemplateDictionaryFields(itemTemplate, templateDictionary);
750
- }
751
- const isSelfReferential = _isSelfReferential(listToAdd);
752
- listToAdd = _updateOrder(listToAdd, isSelfReferential, itemTemplate);
753
- const chunkSize = _getLayerChunkSize();
754
- const layerChunks = [];
755
- listToAdd.forEach((toAdd, i) => {
756
- let item = toAdd.item;
757
- const originalId = item.id;
758
- const isView = itemTemplate.properties.service.isView;
759
- const isMsView = itemTemplate.properties.service.isMultiServicesView;
760
- const isPortal = templateDictionary.isPortal;
761
- fieldInfos = cacheFieldInfos(item, fieldInfos, isView, isPortal);
762
- // cache the values to be added in seperate addToDef calls
763
- fieldInfos = cacheContingentValues(item.id, fieldInfos, itemTemplate);
764
- // cache specific field indexes when deploying to ArcGIS Enterprise portal
765
- if (isPortal) {
766
- fieldInfos = cacheIndexes(item, fieldInfos, isView, isMsView);
767
- }
768
- /* istanbul ignore else */
769
- if (item.isView) {
770
- deleteViewProps(item, isPortal);
771
- }
772
- // when the item is a view we need to grab the supporting fieldInfos
773
- /* istanbul ignore else */
774
- if (isView) {
775
- _updateGeomFieldName(item.adminLayerInfo, templateDictionary);
776
- adminLayerInfos[originalId] = item.adminLayerInfo;
777
- // need to update adminLayerInfo before adding to the service def
778
- // bring over the fieldInfos from the source layer
779
- updateSettingsFieldInfos(itemTemplate, templateDictionary);
780
- // update adminLayerInfo before add to definition with view source fieldInfo settings
781
- item.adminLayerInfo = replaceInTemplate(item.adminLayerInfo, templateDictionary);
782
- /* istanbul ignore else */
783
- if (fieldInfos && fieldInfos.hasOwnProperty(item.id)) {
784
- Object.keys(templateDictionary).some((k) => {
785
- if (templateDictionary[k].itemId === itemTemplate.itemId) {
786
- fieldInfos[item.id]["sourceServiceFields"] = templateDictionary[k].sourceServiceFields;
787
- return true;
788
- }
789
- else {
790
- return false;
791
- }
792
- });
793
- _validateViewDomainFields(item, isPortal, isMsView);
794
- }
795
- }
796
- /* istanbul ignore else */
797
- if (isPortal) {
798
- item = _updateForPortal(item, itemTemplate, templateDictionary);
799
- }
800
- removeLayerOptimization(item);
801
- // this can still chunk layers
802
- options = _updateAddOptions(itemTemplate, options, layerChunks, isSelfReferential, authentication);
803
- if (item.type === "Feature Layer") {
804
- options.layers.push(item);
805
- }
806
- else {
807
- options.tables.push(item);
808
- }
809
- // In general we are switching to not use chunking. Rather if we exceed the defined chunk size
810
- // we will use an async request.
811
- // Currently the only case that should chunk the requests is when we have a multisource view
812
- // handled in _updateAddOptions above
813
- /* istanbul ignore else */
814
- if (i + 1 === listToAdd.length) {
815
- layerChunks.push(Object.assign({}, options));
816
- options = {
817
- layers: [],
818
- tables: [],
819
- authentication,
820
- };
821
- }
822
- });
823
- // will use async by default rather than chunk the layer requests when we have more layers
824
- // than the defined chunk size
825
- const useAsync = listToAdd.length > chunkSize;
826
- layerChunks
827
- .reduce((prev, curr) => prev.then(() => addToServiceDefinition(serviceUrl, curr, false, useAsync)), Promise.resolve(null))
828
- .then(() => resolve(null), (e) => reject(fail(e)));
829
- }
830
- });
831
- }
832
- /**
833
- * When a view is a multi service view sort based on the id
834
- * https://github.com/Esri/solution.js/issues/1048
835
- *
836
- * @param layersAndTables The list of layers and tables for the current template
837
- * @param isSelfReferential Indicates if any layers or tables have relationships with other layers or tables in the same service
838
- * @param itemTemplate The current itemTemplate being processed
839
- *
840
- * @returns Sorted list of layers and tables when using a multi-service view
841
- * @private
842
- */
843
- export function _updateOrder(layersAndTables, isSelfReferential, itemTemplate) {
844
- const isMsView = getProp(itemTemplate, "properties.service.isMultiServicesView") || false;
845
- return isSelfReferential || isMsView ? layersAndTables.sort((a, b) => a.item.id - b.item.id) : layersAndTables;
846
- }
847
- /**
848
- * When a view is a multi service view add each layer separately
849
- * https://github.com/Esri/solution.js/issues/871
850
- *
851
- * @param itemTemplate The current itemTemplate being processed
852
- * @param options Add to service definition options
853
- * @param layerChunks Groups of layers or tables to add to the service
854
- * @param isSelfReferential Indicates if any layers or tables have relationships with other layers or tables in the same service
855
- * @param authentication Credentials for the request
856
- *
857
- * @returns Add to service definition options
858
- * @private
859
- */
860
- export function _updateAddOptions(itemTemplate, options, layerChunks, isSelfReferential, authentication) {
861
- const isMsView = getProp(itemTemplate, "properties.service.isMultiServicesView") || false;
862
- /* istanbul ignore else */
863
- if (isMsView || isSelfReferential) {
864
- // if we already have some layers or tables add them first
865
- /* istanbul ignore else */
866
- if (options.layers.length > 0 || options.tables.length > 0) {
867
- layerChunks.push(Object.assign({}, options));
868
- options = {
869
- layers: [],
870
- tables: [],
871
- authentication,
872
- };
873
- }
874
- }
875
- return options;
876
- }
877
- /**
878
- * Determine if any layer or table within the service references
879
- * other layers or tables within the same service
880
- *
881
- * @param layersAndTables the list of layers and tables from the service
882
- *
883
- * @returns true when valid internal references are found
884
- * @private
885
- */
886
- export function _isSelfReferential(layersAndTables) {
887
- const names = layersAndTables.map((l) => l.item.name);
888
- const srcTables = {};
889
- return layersAndTables.some((l) => {
890
- const table = l.item.adminLayerInfo?.viewLayerDefinition?.table;
891
- if (table) {
892
- const name = table.sourceServiceName;
893
- const id = table.sourceLayerId;
894
- if (name && id > -1) {
895
- if (Object.keys(srcTables).indexOf(name) > -1) {
896
- if (srcTables[name].indexOf(id) > -1) {
897
- return true;
898
- }
899
- else {
900
- srcTables[name].push(id);
901
- }
902
- }
903
- else {
904
- srcTables[name] = [id];
905
- }
906
- }
907
- return (table.relatedTables || []).some((r) => names.indexOf(r.name) > -1);
908
- }
909
- });
910
- }
911
- /**
912
- * Remove "multiScaleGeometryInfo" for issue #526 to prevent invalid enablement of layer optimization
913
- *
914
- * @param layer the layer to evaluate
915
- * @private
916
- */
917
- export function removeLayerOptimization(layer) {
918
- /* istanbul ignore else */
919
- if (layer.multiScaleGeometryInfo) {
920
- deleteProp(layer, "multiScaleGeometryInfo");
921
- }
922
- }
923
- /**
924
- * Handle portal specific updates to the item
925
- *
926
- * @param item the item to update
927
- * @param itemTemplate the item template
928
- * @param templateDictionary Hash mapping Solution source id to id of its clone
929
- *
930
- * @returns the updated item
931
- * @private
932
- */
933
- export function _updateForPortal(item, itemTemplate, templateDictionary) {
934
- // When deploying to portal we need to adjust the uniquie ID field up front
935
- /* istanbul ignore else */
936
- if (item.uniqueIdField && item.uniqueIdField.name) {
937
- item.uniqueIdField.name = String(item.uniqueIdField.name).toLocaleLowerCase();
938
- }
939
- // Portal will fail if the geometryField is null
940
- if (item.type === "Table" && item.adminLayerInfo) {
941
- deleteProp(item.adminLayerInfo, "geometryField");
942
- }
943
- // Portal will fail if the sourceFields in the viewLayerDef contain fields that are not in the source service
944
- /* istanbul ignore else */
945
- if (item.isView) {
946
- const viewLayerDefTable = getProp(item, "adminLayerInfo.viewLayerDefinition.table");
947
- let fieldNames = [];
948
- if (viewLayerDefTable) {
949
- const tableFieldNames = _getFieldNames(viewLayerDefTable, itemTemplate, templateDictionary);
950
- fieldNames = fieldNames.concat(tableFieldNames);
951
- const dynamicFieldNames = _getDynamicFieldNames(viewLayerDefTable);
952
- fieldNames = fieldNames.concat(dynamicFieldNames);
953
- setProp(item, "adminLayerInfo.viewLayerDefinition.table", _updateSourceLayerFields(viewLayerDefTable, fieldNames));
954
- // Handle related also
955
- /* istanbul ignore else */
956
- if (Array.isArray(viewLayerDefTable.relatedTables)) {
957
- viewLayerDefTable.relatedTables.map((relatedTable) => {
958
- const relatedTableFieldNames = _getFieldNames(relatedTable, itemTemplate, templateDictionary);
959
- fieldNames = fieldNames.concat(relatedTableFieldNames);
960
- const dynamicRelatedFieldNames = _getDynamicFieldNames(relatedTable);
961
- fieldNames = fieldNames.concat(dynamicRelatedFieldNames);
962
- return _updateSourceLayerFields(relatedTable, [...relatedTableFieldNames, ...dynamicRelatedFieldNames]);
963
- });
964
- }
965
- }
966
- else {
967
- Object.keys(templateDictionary).some((k) => {
968
- /* istanbul ignore else */
969
- if (templateDictionary[k].itemId === item.serviceItemId) {
970
- const layerInfo = templateDictionary[k][`layer${item.id}`];
971
- /* istanbul ignore else */
972
- if (layerInfo && layerInfo.fields) {
973
- if (Array.isArray(layerInfo.fields)) {
974
- fieldNames = layerInfo.fields.map((f) => f.name);
975
- }
976
- else {
977
- fieldNames = Object.keys(layerInfo.fields);
978
- }
979
- }
980
- return true;
981
- }
982
- });
983
- }
984
- item = _updateItemFields(item, fieldNames);
985
- }
986
- // not allowed to set sourceSchemaChangesAllowed or isView for portal
987
- // these are set when you create the service
988
- deleteProp(item, "isView");
989
- return item;
990
- }
991
- /**
992
- * Get a list of the source layer field names
993
- *
994
- * @param table the table instance to compare
995
- * @param itemTemplate the item template
996
- * @param templateDictionary Hash mapping Solution source id to id of its clone
997
- *
998
- * @returns an array of the source layers fields
999
- * @private
1000
- */
1001
- export function _getFieldNames(table, itemTemplate, templateDictionary) {
1002
- let sourceLayerFields = [];
1003
- const viewSourceLayerId = table.sourceLayerId;
1004
- /* istanbul ignore else */
1005
- if (typeof viewSourceLayerId === "number") {
1006
- // need to make sure these actually exist in the source..
1007
- itemTemplate.dependencies.forEach((d) => {
1008
- const layerInfo = templateDictionary[d][`layer${viewSourceLayerId}`];
1009
- /* istanbul ignore else */
1010
- if (layerInfo && layerInfo.fields && templateDictionary[d].name === table.sourceServiceName) {
1011
- if (Array.isArray(layerInfo.fields)) {
1012
- sourceLayerFields = sourceLayerFields.concat(layerInfo.fields.map((f) => f.name));
1013
- }
1014
- else {
1015
- sourceLayerFields = sourceLayerFields.concat(Object.keys(layerInfo.fields));
1016
- }
1017
- }
1018
- });
1019
- return sourceLayerFields;
1020
- }
1021
- }
1022
- /**
1023
- * Get a list of any dynamically calculated fields
1024
- * These fields are still valid but will not exist in the source service
1025
- *
1026
- * @param table the table instance to compare
1027
- *
1028
- * @returns an array of field names
1029
- * @private
1030
- */
1031
- export function _getDynamicFieldNames(table) {
1032
- const fieldNames = table.sourceLayerFields.reduce((prev, cur) => {
1033
- if (cur.statisticType) {
1034
- prev.push(cur.name);
1035
- }
1036
- return prev;
1037
- }, []);
1038
- return [...new Set(fieldNames)];
1039
- }
1040
- /**
1041
- * Remove fields references from fields and indexes that do not exist in the source service
1042
- *
1043
- * @param item Layer or table
1044
- * @param templateDictionary Hash mapping Solution source id to id of its clone
1045
- *
1046
- * @returns updated layer or table
1047
- * @private
1048
- */
1049
- export function _updateItemFields(item, fieldNames) {
1050
- /* istanbul ignore else */
1051
- if (fieldNames.length > 0) {
1052
- /* istanbul ignore else */
1053
- if (item.fields) {
1054
- item.fields = item.fields.filter((f) => fieldNames.indexOf(f.name) > -1);
1055
- }
1056
- /* istanbul ignore else */
1057
- if (item.indexes) {
1058
- item.indexes = item.indexes.filter((f) => fieldNames.indexOf(f.fields) > -1);
1059
- }
1060
- }
1061
- return item;
1062
- }
1063
- /**
1064
- * Filter the sourceLayerFields for the table
1065
- *
1066
- * @param table the table instance to evaluate
1067
- * @param sourceLayerFields array of fields from the source service
1068
- * @returns Updated instance of the table
1069
- * @private
1070
- */
1071
- export function _updateSourceLayerFields(table, sourceLayerFields) {
1072
- /* istanbul ignore else */
1073
- if (Array.isArray(table.sourceLayerFields) && table.sourceLayerFields.length > 0) {
1074
- // need to make sure these actually exist in the source..
1075
- /* istanbul ignore else */
1076
- if (sourceLayerFields.length > 0) {
1077
- setProp(table, "sourceLayerFields", table.sourceLayerFields.filter((f) => sourceLayerFields.indexOf(f.source.toLowerCase()) > -1));
1078
- }
1079
- }
1080
- return table;
1081
- }
1082
- /**
1083
- * When the itemm is a view with a geometry field update the value to
1084
- * use the table name from the view layer def
1085
- *
1086
- * @param item the item details from the current template
1087
- * @param templateDictionary Hash mapping property names to replacement values
1088
- * @private
1089
- */
1090
- export function _updateGeomFieldName(adminLayerInfo, templateDictionary) {
1091
- // issue #471
1092
- const tableName = getProp(adminLayerInfo, "viewLayerDefinition.table.name");
1093
- const fieldName = getProp(adminLayerInfo, "geometryField.name");
1094
- /* istanbul ignore else */
1095
- if (fieldName && tableName) {
1096
- const geomName = templateDictionary.isPortal ? `${tableName}.shape` : `${tableName}.Shape`;
1097
- setProp(adminLayerInfo, "geometryField.name", geomName);
1098
- }
1099
- else if (!fieldName && getProp(adminLayerInfo, "geometryField")) {
1100
- // null geom field will cause failure to deploy in portal
1101
- // this is also checked and removed on deploy for older solutions
1102
- deleteProp(adminLayerInfo, "geometryField");
1103
- }
1104
- }
1105
- /**
1106
- * Add the fields to the templateDictionary when a service has views
1107
- * these are used to compare with fields from the view when domains are involved
1108
- * when a view field has a domain that differs from that of the source service
1109
- * the definition needs to be modified in an update call rather than when it is first added.
1110
- * This should only happen when the domain differs.
1111
- *
1112
- * @param itemTemplate
1113
- * @param templateDictionary Hash mapping Solution source id to id of its clone (and name & URL for feature service)
1114
- * @private
1115
- */
1116
- export function _updateTemplateDictionaryFields(itemTemplate, templateDictionary, compareItemId = true) {
1117
- const layers = itemTemplate.properties.layers;
1118
- const tables = itemTemplate.properties.tables;
1119
- const layersAndTables = layers.concat(tables);
1120
- const fieldInfos = {};
1121
- layersAndTables.forEach((layerOrTable) => {
1122
- fieldInfos[layerOrTable.id] = layerOrTable.fields;
1123
- });
1124
- Object.keys(templateDictionary).some((k) => {
1125
- if (compareItemId ? templateDictionary[k].itemId === itemTemplate.itemId : k === itemTemplate.itemId) {
1126
- templateDictionary[k].fieldInfos = fieldInfos;
1127
- return true;
1128
- }
1129
- else {
1130
- return false;
1131
- }
1132
- });
1133
- }
1134
- /**
1135
- * Set the defaultSpatialReference variable with the services spatial reference.
1136
- * If this item is a Feature Service that has child views then we will use this value
1137
- * if one or more of the child views spatial reference differs from that of its parent.
1138
- *
1139
- * @param templateDictionary Hash mapping Solution source id to id of its clone (and name & URL for feature service)
1140
- * @param itemId The source id for the item
1141
- * @param spatialReference \{ wkid: 102100 \} for example
1142
- * @private
1143
- */
1144
- export function setDefaultSpatialReference(templateDictionary, itemId, spatialReference) {
1145
- /* istanbul ignore else */
1146
- if (spatialReference) {
1147
- setCreateProp(templateDictionary, `${itemId}.defaultSpatialReference`, spatialReference);
1148
- }
1149
- }
1150
- /**
1151
- * Compare the spatial reference of the current item against its dependencies.
1152
- * The spatial reference of a view cannot differ from its source service.
1153
- * If the view has a different spatial reference from its source use the source spatial reference.
1154
- *
1155
- * @param serviceInfo Basic service information
1156
- * @param itemTemplate The current template to process
1157
- * @param templateDictionary Hash mapping Solution source id to id of its clone (and name & URL for feature service)
1158
- * @private
1159
- */
1160
- export function validateSpatialReferenceAndExtent(serviceInfo, itemTemplate, templateDictionary) {
1161
- /* istanbul ignore else */
1162
- if (getProp(serviceInfo, "service.isView")) {
1163
- // first pass ensure we have a geometry type before getting the spatial reference or extent
1164
- // issue: #1368
1165
- const geomCheckResults = _getSourceSpatialReferenceAndExtent(serviceInfo, itemTemplate, templateDictionary, true);
1166
- // if not found with first pass just check for the first service that has the key values defined
1167
- // as we did before the above handeling
1168
- const results = _getSourceSpatialReferenceAndExtent(serviceInfo, itemTemplate, templateDictionary, false);
1169
- const sourceSR = geomCheckResults.spatialReference || results.spatialReference;
1170
- const sourceExt = geomCheckResults.extent || results.extent;
1171
- const sourceWkid = getProp(sourceSR, "wkid");
1172
- const viewWkid = getProp(serviceInfo, "service.spatialReference.wkid");
1173
- /* istanbul ignore else */
1174
- if (sourceWkid && viewWkid && sourceWkid !== viewWkid) {
1175
- setCreateProp(serviceInfo, "service.spatialReference", sourceSR);
1176
- }
1177
- const viewExt = getProp(serviceInfo, "service.fullExtent");
1178
- /* istanbul ignore else */
1179
- if (sourceExt && viewExt && JSON.stringify(sourceExt) !== JSON.stringify(viewExt)) {
1180
- setCreateProp(serviceInfo, "defaultExtent", sourceExt);
1181
- }
1182
- }
1183
- }
1184
- /**
1185
- * Get the spatial reference from a views source.
1186
- * Optionally ensure that the source has a valid geometry type prior to using its values.
1187
- *
1188
- * @param serviceInfo Basic service information
1189
- * @param itemTemplate The current template to process
1190
- * @param templateDictionary Hash mapping Solution source id to id of its clone (and name & URL for feature service)
1191
- * @param validateGeom When true the source must contain a geometryType for values to be returned
1192
- *
1193
- * @returns An object that contains the default spatial reference and extent value
1194
- * @private
1195
- */
1196
- export function _getSourceSpatialReferenceAndExtent(serviceInfo, itemTemplate, templateDictionary, validateGeom) {
1197
- const layersAndTables = [...(serviceInfo.layers || []), ...(serviceInfo.tables || [])];
1198
- let spatialReference;
1199
- let extent;
1200
- itemTemplate.dependencies.some((id) => {
1201
- const source = templateDictionary[id];
1202
- const hasGeom = validateGeom
1203
- ? layersAndTables.some((layerOrTable) => {
1204
- const name = getProp(layerOrTable, "adminLayerInfo.viewLayerDefinition.table.sourceServiceName");
1205
- return name && source.name && name === source.name && layerOrTable.geometryType;
1206
- })
1207
- : true;
1208
- const sr = getProp(source, "defaultSpatialReference");
1209
- /* istanbul ignore else */
1210
- if (!spatialReference && sr && hasGeom) {
1211
- spatialReference = sr;
1212
- }
1213
- const ext = getProp(source, "defaultExtent");
1214
- /* istanbul ignore else */
1215
- if (!extent && ext && hasGeom) {
1216
- extent = ext;
1217
- }
1218
- return spatialReference && extent;
1219
- });
1220
- return {
1221
- spatialReference,
1222
- extent,
1223
- };
1224
- }
1225
- /**
1226
- * Updates a feature service with a list of layers and/or tables.
1227
- *
1228
- * @param itemTemplate
1229
- * @param fieldInfos Hash map of properties that contain field references
1230
- * @param popupInfos Hash map of a layers popupInfo
1231
- * @param adminLayerInfos Hash map of a layers adminLayerInfo
1232
- * @param templateDictionary Hash mapping Solution source id to id of its clone (and name & URL for feature service)
1233
- * @param authentication Credentials for the request
1234
- * @returns A promise that will resolve when the feature service has been updated
1235
- * @private
1236
- */
1237
- export function updateLayerFieldReferences(itemTemplate, fieldInfos, popupInfos, adminLayerInfos, templateDictionary) {
1238
- return new Promise((resolveFn, rejectFn) => {
1239
- // Will need to do some post processing for fields
1240
- // to handle any potential field name changes when deploying to portal
1241
- postProcessFields(itemTemplate, fieldInfos, popupInfos, adminLayerInfos, templateDictionary).then((layerInfos) => {
1242
- // Update the items text with detemplatized popupInfo
1243
- updatePopupInfo(itemTemplate, layerInfos.popupInfos);
1244
- resolveFn({
1245
- itemTemplate,
1246
- layerInfos,
1247
- });
1248
- }, (e) => rejectFn(fail(e)));
1249
- });
1250
- }
1251
- /**
1252
- * Update the names of fields for each layer or table after it has been
1253
- * added to the definition
1254
- *
1255
- * @param itemTemplate Item to be created
1256
- * @param layerInfos Hash map of properties that contain field references and various layer info
1257
- * @param popupInfos Hash map of a layers popupInfo
1258
- * @param adminLayerInfos Hash map of a layers adminLayerInfo
1259
- * @param templateDictionary
1260
- * @param authentication Credentials for the request
1261
- * @returns An object with detemplatized field references
1262
- * @private
1263
- */
1264
- export function postProcessFields(itemTemplate, layerInfos, popupInfos, adminLayerInfos, templateDictionary) {
1265
- return new Promise((resolveFn, rejectFn) => {
1266
- if (!itemTemplate.item.url) {
1267
- rejectFn(fail("Feature layer " + itemTemplate.itemId + " does not have a URL"));
1268
- }
1269
- else {
1270
- const id = itemTemplate.itemId;
1271
- const settingsKeys = Object.keys(templateDictionary);
1272
- let templateInfo;
1273
- settingsKeys.some((k) => {
1274
- if (templateDictionary[k].itemId === id) {
1275
- templateInfo = templateDictionary[k];
1276
- return true;
1277
- }
1278
- else {
1279
- return false;
1280
- }
1281
- });
1282
- // concat any layers and tables to process
1283
- const layers = itemTemplate.properties.layers;
1284
- const tables = itemTemplate.properties.tables;
1285
- const layersAndTables = layers.concat(tables);
1286
- // Set the newFields property for the layerInfos...this will contain all fields
1287
- // as they are after being added to the definition.
1288
- // This allows us to handle any potential field name changes after deploy to portal
1289
- layersAndTables.forEach((item) => {
1290
- // when deploying to portal "isView" is only set for create service and will fail when
1291
- // present on addToDef so this property is removed from item and we should check the templates service info
1292
- const isView = item.isView || itemTemplate.properties.service.isView;
1293
- /* istanbul ignore else */
1294
- if (layerInfos && layerInfos.hasOwnProperty(item.id)) {
1295
- const layerInfo = layerInfos[item.id];
1296
- layerInfo["isView"] = item.isView;
1297
- layerInfo["newFields"] = item.fields;
1298
- layerInfo["sourceSchemaChangesAllowed"] = item.sourceSchemaChangesAllowed;
1299
- /* istanbul ignore else */
1300
- if (item.editFieldsInfo) {
1301
- // more than case change when deployed to protal so keep track of the new names
1302
- layerInfo["newEditFieldsInfo"] = JSON.parse(JSON.stringify(item.editFieldsInfo));
1303
- }
1304
- /* istanbul ignore else */
1305
- if (isView && templateInfo && templateDictionary.isPortal) {
1306
- // when the item is a view bring over the source service fields so we can compare the domains
1307
- layerInfo["sourceServiceFields"] = templateInfo.sourceServiceFields;
1308
- }
1309
- }
1310
- });
1311
- // Add the layerInfos to the settings object to be used while detemplatizing
1312
- settingsKeys.forEach((k) => {
1313
- if (id === templateDictionary[k].itemId) {
1314
- templateDictionary[k] = Object.assign(templateDictionary[k], getLayerSettings(layerInfos, templateDictionary[k].url, id));
1315
- }
1316
- });
1317
- // update the layerInfos object with current field names
1318
- resolveFn(deTemplatizeFieldInfos(layerInfos, popupInfos, adminLayerInfos, templateDictionary));
1319
- }
1320
- });
1321
- }
1322
- /**
1323
- * Set isViewOverride to false for single source view fields in portal when the field has
1324
- * a domain and isViewOverride is not currently defined
1325
- *
1326
- * https://devtopia.esri.com/WebGIS/solution-deployment-apps/issues/414
1327
- *
1328
- * @param item that stores the view fields
1329
- * @param isPortal When true we are deploying to portal
1330
- * @param isMsView When true the view is a multi-source view
1331
- *
1332
- * This function will update the item that is provided
1333
- * @private
1334
- */
1335
- export function _validateViewDomainFields(item, isPortal, isMsView) {
1336
- /* istanbul ignore else */
1337
- if (isPortal && !isMsView) {
1338
- const k = "domain";
1339
- const k2 = "isViewOverride";
1340
- item.fields.map((field) => {
1341
- /* istanbul ignore else */
1342
- if (field.hasOwnProperty(k) && getProp(field, k) && !field.hasOwnProperty(k2)) {
1343
- field.isViewOverride = false;
1344
- }
1345
- return field;
1346
- });
1347
- }
1348
- }
1349
- /**
1350
- * Add popup info back to the layer item
1351
- *
1352
- * @param itemTemplate
1353
- * @param popupInfos popup info to be added back to the layer
1354
- * @private
1355
- */
1356
- export function updatePopupInfo(itemTemplate, popupInfos) {
1357
- ["layers", "tables"].forEach((type) => {
1358
- const _items = getProp(itemTemplate, "data." + type);
1359
- /* istanbul ignore else */
1360
- if (_items && Array.isArray(_items)) {
1361
- _items.forEach((item) => {
1362
- item.popupInfo = getProp(popupInfos, type + "." + item.id) || {};
1363
- });
1364
- }
1365
- });
1366
- }
1367
- //#endregion
1368
- //#region Private helper functions --------------------------------------------------//
1369
- /**
1370
- * Helper function to templatize value and make sure its converted to lowercase
1371
- *
1372
- * @param basePath path used to de-templatize while deploying
1373
- * @param value to be converted to lower case for lookup while deploying
1374
- * @private
1375
- */
1376
- export function _templatize(basePath, value, suffix) {
1377
- if (value.startsWith("{{")) {
1378
- return value;
1379
- }
1380
- else {
1381
- return String(templatizeTerm(basePath, basePath, "." + String(value).toLowerCase() + (suffix ? "." + suffix : "")));
1382
- }
1383
- }
1384
- /**
1385
- * templatize an objects property
1386
- *
1387
- * @param object the object with the property to templatize
1388
- * @param property the property of the object to templatize
1389
- * @param basePath path used to de-templatize while deploying
1390
- * @private
1391
- */
1392
- export function _templatizeProperty(object, property, basePath, suffix) {
1393
- if (object && object.hasOwnProperty(property) && object[property]) {
1394
- object[property] = _templatize(basePath, object[property], suffix);
1395
- }
1396
- }
1397
- /**
1398
- * Templatize field references, serviceItemId, and adminLayerInfo for a layer
1399
- *
1400
- * @param dataItem from the items data property
1401
- * @param adminItem from the services admin api
1402
- * @param itemTemplate Template for feature service item
1403
- * @param dependencies Array of IDependency for name mapping
1404
- * @param templatizeFieldReferences Templatize all field references within a layer
1405
- * @returns A promise that will resolve when template has been updated
1406
- * @private
1407
- */
1408
- export function _templatizeLayer(dataItem, adminItem, itemTemplate, dependencies, templatizeFieldReferences, templateDictionary) {
1409
- // check for and repair common field issues
1410
- _validateFields(adminItem);
1411
- // Templatize all properties that contain field references
1412
- /* istanbul ignore else */
1413
- if (templatizeFieldReferences) {
1414
- _templatizeLayerFieldReferences(dataItem, itemTemplate.itemId, adminItem, dependencies);
1415
- }
1416
- const updates = [adminItem];
1417
- if (dataItem) {
1418
- updates.push(dataItem);
1419
- }
1420
- updates.forEach((update) => {
1421
- if (update.hasOwnProperty("name")) {
1422
- // templatize the name but leave the current name as the optional default
1423
- update.name = templatizeTerm(update["serviceItemId"] + ".layer" + update.id, update["serviceItemId"] + ".layer" + update.id, ".name||" + update.name);
1424
- }
1425
- if (update.hasOwnProperty("extent")) {
1426
- update.extent = templatizeTerm(update["serviceItemId"], update["serviceItemId"], ".solutionExtent");
1427
- }
1428
- if (update.hasOwnProperty("serviceItemId")) {
1429
- update["serviceItemId"] = templatizeTerm(update["serviceItemId"], update["serviceItemId"], ".itemId");
1430
- }
1431
- if (update.hasOwnProperty("adminLayerInfo")) {
1432
- update.adminLayerInfo = _templatizeAdminLayerInfo(update, dependencies, templateDictionary);
1433
- }
1434
- });
1435
- }
1436
- /**
1437
- * Repair common issues that can occur with feature service field references.
1438
- * This function will mutate the input item if any of the common issues have occured.
1439
- *
1440
- * @param adminItem layer or table from the service
1441
- */
1442
- export function _validateFields(adminItem) {
1443
- const fieldNames = (adminItem.fields || []).map((f) => f.name);
1444
- // Update primary display field if field isn't in the layer.
1445
- _validateDisplayField(adminItem, fieldNames);
1446
- // Remove indexes on fields that don't exist in the layer.
1447
- // Remove duplicate indexes on the same field.
1448
- _validateIndexes(adminItem, fieldNames);
1449
- // Remove field references in templates when field doesn't exist in the layer.
1450
- _validateTemplatesFields(adminItem, fieldNames);
1451
- _validateTypesTemplates(adminItem, fieldNames);
1452
- // Repair editFieldsInfo if field referenced doesn't exist in the layer
1453
- _validateEditFieldsInfo(adminItem, fieldNames);
1454
- }
1455
- /**
1456
- * Update primary display field if casing doesn't match.
1457
- * Update primary display field to the first non OID or GlobalId if the field isn't in the layer.
1458
- *
1459
- * @param adminItem layer or table from the service
1460
- * @param fieldNames string list of fields names
1461
- * @private
1462
- */
1463
- export function _validateDisplayField(adminItem, fieldNames) {
1464
- const displayField = adminItem.displayField || "";
1465
- let i = -1;
1466
- if (fieldNames.some((name) => {
1467
- i += 1;
1468
- return name === displayField || name === displayField.toLowerCase();
1469
- })) {
1470
- adminItem.displayField = fieldNames[i];
1471
- }
1472
- else {
1473
- // use the first non-OID non-globalId field we find
1474
- const skipFields = [];
1475
- const oidField = getProp(adminItem, "uniqueIdField.name");
1476
- /* istanbul ignore else */
1477
- if (oidField) {
1478
- skipFields.push(oidField);
1479
- }
1480
- const globalIdField = getProp(adminItem, "globalIdField");
1481
- /* istanbul ignore else */
1482
- if (globalIdField) {
1483
- skipFields.push(globalIdField);
1484
- }
1485
- fieldNames.some((name) => {
1486
- if (skipFields.indexOf(name) === -1) {
1487
- adminItem.displayField = name;
1488
- return true;
1489
- }
1490
- else {
1491
- return false;
1492
- }
1493
- });
1494
- }
1495
- }
1496
- /**
1497
- * Remove indexes on fields that don't exist in the layer.
1498
- * Remove duplicate indexes on the same field.
1499
- *
1500
- * @param adminItem layer or table from the service
1501
- * @param fieldNames string list of fields names
1502
- * @private
1503
- */
1504
- export function _validateIndexes(adminItem, fieldNames) {
1505
- const indexes = adminItem.indexes;
1506
- /* istanbul ignore else */
1507
- if (indexes) {
1508
- const indexedFields = [];
1509
- adminItem.indexes = indexes.reduce((filtered, index) => {
1510
- const indexFields = index.fields.split(",");
1511
- const verifiedFields = [];
1512
- indexFields.forEach((indexField) => {
1513
- /* istanbul ignore else */
1514
- if (indexedFields.indexOf(indexField) === -1) {
1515
- indexedFields.push(indexField);
1516
- // this is the first index with this field and it should be added if the field exists
1517
- /* istanbul ignore else */
1518
- if (fieldNames.indexOf(indexField) > -1) {
1519
- verifiedFields.push(indexField);
1520
- }
1521
- }
1522
- // else the field has more than one index associated and should not be returned
1523
- });
1524
- /* istanbul ignore else */
1525
- if (verifiedFields.length > 0) {
1526
- index.fields = verifiedFields.join(",");
1527
- filtered.push(index);
1528
- }
1529
- return filtered;
1530
- }, []);
1531
- }
1532
- }
1533
- /**
1534
- * Remove field references from templates that no longer exist.
1535
- *
1536
- * @param adminItem layer or table from the service
1537
- * @param fieldNames string list of fields names
1538
- * @private
1539
- */
1540
- export function _validateTemplatesFields(adminItem, fieldNames) {
1541
- const templates = adminItem.templates;
1542
- /* istanbul ignore else */
1543
- if (templates) {
1544
- adminItem.templates = templates.map((template) => {
1545
- const attributes = getProp(template, "prototype.attributes");
1546
- /* istanbul ignore else */
1547
- if (attributes) {
1548
- Object.keys(attributes).forEach((k) => {
1549
- /* istanbul ignore else */
1550
- if (fieldNames.indexOf(k) === -1) {
1551
- delete attributes[k];
1552
- }
1553
- });
1554
- setProp(template, "prototype.attributes", attributes);
1555
- }
1556
- return template;
1557
- });
1558
- }
1559
- }
1560
- /**
1561
- * Remove field references from templates that no longer exist.
1562
- *
1563
- * @param adminItem layer or table from the service
1564
- * @param fieldNames string list of fields names
1565
- * @private
1566
- */
1567
- export function _validateTypesTemplates(adminItem, fieldNames) {
1568
- const types = adminItem.types;
1569
- /* istanbul ignore else */
1570
- if (types) {
1571
- adminItem.types = types.map((t) => {
1572
- _validateTemplatesFields(t, fieldNames);
1573
- return t;
1574
- });
1575
- }
1576
- }
1577
- /**
1578
- * Check if edit feilds exist but with lower case
1579
- *
1580
- * @param adminItem layer or table from the service
1581
- * @param fieldNames string list of fields names
1582
- * @private
1583
- */
1584
- export function _validateEditFieldsInfo(adminItem, fieldNames) {
1585
- const editFieldsInfo = adminItem.editFieldsInfo;
1586
- /* istanbul ignore else */
1587
- if (editFieldsInfo) {
1588
- const editFieldsInfoKeys = Object.keys(editFieldsInfo);
1589
- editFieldsInfoKeys.forEach((k) => {
1590
- const editFieldName = editFieldsInfo[k];
1591
- /* istanbul ignore else */
1592
- if (editFieldName) {
1593
- fieldNames.some((name) => {
1594
- if (name === editFieldName) {
1595
- return true;
1596
- }
1597
- else if (name === editFieldName.toLowerCase()) {
1598
- editFieldsInfo[k] = name;
1599
- return true;
1600
- }
1601
- else {
1602
- return false;
1603
- }
1604
- });
1605
- }
1606
- });
1607
- }
1608
- }
1609
- /**
1610
- *
1611
- * Templatize all field references within a layer
1612
- * This is necessary to support potential field name changes when deploying to portal
1613
- * Portal will force all field names to be lower case
1614
- *
1615
- * @param dataItem The data layer instance with field name references within
1616
- * @param itemID The id for the item that contains this layer.
1617
- * @param layer JSON return from the layer being templatized.
1618
- * @param dependencies
1619
- * @returns An updated instance of the layer
1620
- * @private
1621
- */
1622
- export function _templatizeLayerFieldReferences(dataItem, itemID, layer, dependencies) {
1623
- // This is the value that will be used as the template for adlib replacement
1624
- const path = itemID + ".layer" + layer.id + ".fields";
1625
- // Get the field names for various tests
1626
- const fieldNames = layer.fields.map((f) => f.name);
1627
- // Update the layer from the items data property
1628
- if (dataItem) {
1629
- _templatizeAdminLayerInfoFields(dataItem, dependencies);
1630
- _templatizePopupInfo(dataItem, layer, path, itemID, fieldNames);
1631
- }
1632
- // Update the layer
1633
- _templatizeAdminLayerInfoFields(layer, dependencies);
1634
- _templatizeRelationshipFields(layer, itemID);
1635
- _templatizeDefinitionEditor(layer, path, fieldNames);
1636
- _templatizeDefinitionExpression(layer, path, fieldNames);
1637
- _templatizeDrawingInfo(layer, path, fieldNames);
1638
- _templatizeTemplates(layer, path);
1639
- _templatizeTypeTemplates(layer, path);
1640
- _templatizeTimeInfo(layer, path);
1641
- _templatizeDefinitionQuery(layer, path, fieldNames);
1642
- }
1643
- /**
1644
- * Templatize a layers adminLayerInfo by removing properties that will case issues with clone.
1645
- * Also templatizes the source service name when we are dealing with a view.
1646
- *
1647
- * @param layer The layer to be modified
1648
- * @param dependencies Array of service dependencies
1649
- * @returns A new copy of the modified adminLayerInfo for the given layer
1650
- * @private
1651
- */
1652
- export function _templatizeAdminLayerInfo(layer, dependencies, templateDictionary) {
1653
- // Create new instance of adminLayerInfo to update for clone
1654
- const adminLayerInfo = Object.assign({}, layer.adminLayerInfo);
1655
- _updateGeomFieldName(adminLayerInfo, templateDictionary);
1656
- deleteProp(adminLayerInfo, "xssTrustedFields");
1657
- deleteProp(adminLayerInfo, "tableName");
1658
- // Remove unnecessary properties and templatize key properties from viewLayerDefinition
1659
- /* istanbul ignore else */
1660
- if (adminLayerInfo.viewLayerDefinition) {
1661
- const viewDef = Object.assign({}, adminLayerInfo.viewLayerDefinition);
1662
- _processAdminObject(viewDef, dependencies);
1663
- // Remove unnecessary properties and templatize key properties from viewLayerDefinition.table
1664
- /* istanbul ignore else */
1665
- if (viewDef.table) {
1666
- _processAdminObject(viewDef.table, dependencies);
1667
- /* istanbul ignore else */
1668
- if (viewDef.table.relatedTables) {
1669
- viewDef.table.relatedTables.forEach((table) => {
1670
- _processAdminObject(table, dependencies);
1671
- });
1672
- }
1673
- }
1674
- adminLayerInfo.viewLayerDefinition = viewDef;
1675
- }
1676
- return adminLayerInfo;
1677
- }
1678
- /**
1679
- * Remove sourceId and templatize the sourceServiceName
1680
- *
1681
- * @param object The layer to be modified
1682
- * @param dependencies Array of service dependencies
1683
- * @private
1684
- */
1685
- export function _processAdminObject(object, dependencies) {
1686
- deleteProp(object, "sourceId");
1687
- if (object.hasOwnProperty("sourceServiceName")) {
1688
- object.sourceServiceName = _templatizeSourceServiceName(object.sourceServiceName, dependencies);
1689
- }
1690
- }
1691
- /**
1692
- * Templatize the name based on the given dependencies
1693
- *
1694
- * @param lookupName The current name from the source service
1695
- * @param dependencies Array of IDependency for name mapping
1696
- * @returns The templatized name || undefined when no matching dependency is found
1697
- * @private
1698
- */
1699
- export function _templatizeSourceServiceName(lookupName, dependencies) {
1700
- const deps = dependencies.filter((dependency) => dependency.name === lookupName);
1701
- return deps.length === 1 ? _templatize(deps[0].id, "name") : undefined;
1702
- }
1703
- /**
1704
- * templatize the fields referenced in adminLayerInfo
1705
- *
1706
- * @param layer the layer object with the adminLayerInfo property to templatize
1707
- * @param basePath path used to de-templatize while deploying
1708
- * @param itemID the id for the item that contains this layer
1709
- * @private
1710
- */
1711
- export function _templatizeAdminLayerInfoFields(layer, dependencies) {
1712
- // templatize the source layer fields
1713
- const table = getProp(layer, "adminLayerInfo.viewLayerDefinition.table");
1714
- if (table) {
1715
- let id = _getDependantItemId(table.sourceServiceName, dependencies);
1716
- const path = id + ".layer" + table.sourceLayerId + ".fields";
1717
- _templatizeAdminSourceLayerFields(table.sourceLayerFields || [], path);
1718
- // templatize the releated table fields
1719
- const relatedTables = getProp(layer, "adminLayerInfo.viewLayerDefinition.table.relatedTables") || [];
1720
- if (relatedTables.length > 0) {
1721
- relatedTables.forEach((t) => {
1722
- id = _getDependantItemId(t.sourceServiceName, dependencies);
1723
- const relatedPath = id + ".layer" + t.sourceLayerId + ".fields";
1724
- _templatizeTopFilter(t.topFilter || {}, relatedPath);
1725
- _templatizeAdminSourceLayerFields(t.sourceLayerFields || [], relatedPath);
1726
- const parentKeyFields = t.parentKeyFields || [];
1727
- t.parentKeyFields = parentKeyFields.map((f) => {
1728
- return _templatize(path, f, "name");
1729
- });
1730
- const keyFields = t.keyFields || [];
1731
- t.keyFields = keyFields.map((f) => {
1732
- return _templatize(relatedPath, f, "name");
1733
- });
1734
- });
1735
- }
1736
- }
1737
- }
1738
- /**
1739
- * find id based on dependency name
1740
- *
1741
- * @param lookupName name of dependency we want to find the id of
1742
- * @param dependencies array of item dependencies
1743
- * @private
1744
- */
1745
- export function _getDependantItemId(lookupName, dependencies) {
1746
- const deps = dependencies.filter((dependency) => dependency.name === lookupName);
1747
- return deps.length === 1 ? deps[0].id : "";
1748
- }
1749
- /**
1750
- * templatize the sourceLayerFields referenced in adminLayerInfo
1751
- *
1752
- * @param fields array of sourceLayerFields to templatize
1753
- * @param basePath path used to de-templatize while deploying
1754
- * @private
1755
- */
1756
- export function _templatizeAdminSourceLayerFields(fields, basePath) {
1757
- fields.forEach((f) => _templatizeProperty(f, "source", basePath, "name"));
1758
- }
1759
- /**
1760
- * templatize the topFilter property from adminLayerInfo related tables
1761
- *
1762
- * @param topFilter the topFilter object to templatize
1763
- * @param basePath path used to de-templatize while deploying
1764
- * @private
1765
- */
1766
- export function _templatizeTopFilter(topFilter, basePath) {
1767
- /* istanbul ignore else */
1768
- if (topFilter) {
1769
- // templatize the orderByFields prop
1770
- const orderByFields = topFilter["orderByFields"] || "";
1771
- /* istanbul ignore else */
1772
- if (orderByFields !== "") {
1773
- const orderByField = orderByFields.split(" ")[0];
1774
- topFilter.orderByFields = topFilter.orderByFields.replace(orderByField, _templatize(basePath, orderByField, "name"));
1775
- }
1776
- const groupByFields = topFilter["groupByFields"] || "";
1777
- /* istanbul ignore else */
1778
- if (groupByFields !== "") {
1779
- const _groupByFields = groupByFields.split(",");
1780
- /* istanbul ignore else */
1781
- if (_groupByFields.length > 0) {
1782
- const mappedFields = _groupByFields.map((f) => {
1783
- return _templatize(basePath, f, "name");
1784
- });
1785
- topFilter.groupByFields = mappedFields.join(",");
1786
- }
1787
- }
1788
- }
1789
- }
1790
- /**
1791
- * templatize the relationships key fields using the related table id in the basePath
1792
- *
1793
- * @param layer the layer that has the relationships to templatize
1794
- * @param itemID the id of the item that contains the related table
1795
- * @private
1796
- */
1797
- export function _templatizeRelationshipFields(layer, itemID) {
1798
- if (layer && layer.relationships) {
1799
- const relationships = layer.relationships;
1800
- relationships.forEach((r) => {
1801
- /* istanbul ignore else */
1802
- if (r.keyField) {
1803
- const basePath = itemID + ".layer" + layer.id + ".fields";
1804
- _templatizeProperty(r, "keyField", basePath, "name");
1805
- }
1806
- });
1807
- }
1808
- }
1809
- /**
1810
- * templatize the popupInfo
1811
- *
1812
- * @param layerDefinition the layerDefinition that has the popupInfo to templatize
1813
- * @param layer the JSON for the layer being templatized
1814
- * @param basePath path used to de-templatize while deploying
1815
- * @param itemID the id for the item that contains this layer
1816
- * @param fieldNames array of fieldNames
1817
- * @private
1818
- */
1819
- export function _templatizePopupInfo(layerDefinition, layer, basePath, itemID, fieldNames) {
1820
- // the data layer does not have the fields...will need to get those
1821
- // from the associated layer json
1822
- if (fieldNames && layerDefinition.popupInfo) {
1823
- const popupInfo = layerDefinition.popupInfo;
1824
- _templatizeName(popupInfo, "title", fieldNames, basePath);
1825
- _templatizeName(popupInfo, "description", fieldNames, basePath);
1826
- const fieldInfos = popupInfo.fieldInfos || [];
1827
- _templatizePopupInfoFieldInfos(fieldInfos, layer, itemID, basePath);
1828
- const expressionInfos = popupInfo.expressionInfos || [];
1829
- _templatizeExpressionInfos(expressionInfos, fieldNames, basePath);
1830
- const popupElements = popupInfo.popupElements || [];
1831
- _templatizePopupElements(popupElements, basePath, layer, itemID, fieldNames);
1832
- const mediaInfos = popupInfo.mediaInfos || [];
1833
- _templatizeMediaInfos(mediaInfos, fieldNames, basePath, layer, itemID);
1834
- }
1835
- }
1836
- /**
1837
- * templatize field name when referenced like this: \{\{fieldName\}\}
1838
- * checks each field name from the layer
1839
- *
1840
- * @param object with the property to test for a field name
1841
- * @param property that could have a field name referenced
1842
- * @param fieldNames array for field names for the layer
1843
- * @param basePath path used to de-templatize while deploying
1844
- * @private
1845
- */
1846
- export function _templatizeName(object, property, fieldNames, basePath) {
1847
- if (object.hasOwnProperty(property)) {
1848
- fieldNames.forEach((name) => {
1849
- // Only test and replace instance of the name so any enclosing characters
1850
- // will be retained
1851
- const regEx = new RegExp("(\\b" + name + "\\b(?![}]{2}))", "gm");
1852
- if (regEx.test(object[property])) {
1853
- object[property] = object[property].replace(regEx, _templatize(basePath, name, "name"));
1854
- }
1855
- });
1856
- }
1857
- }
1858
- /**
1859
- * templatize field name when referenced like this: \{\{fieldName\}\}
1860
- * checks each field name from the layer
1861
- *
1862
- * @param fieldInfos object that contains the popups fieldInfos
1863
- * @param layer json of layer being cloned
1864
- * @param itemID id of the item that contains the current layer
1865
- * @param basePath path used to de-templatize while deploying
1866
- * @private
1867
- */
1868
- export function _templatizePopupInfoFieldInfos(fieldInfos, layer, itemID, basePath) {
1869
- fieldInfos.forEach((f) => {
1870
- f.fieldName = _templatizeFieldName(f.fieldName, layer, itemID, basePath);
1871
- });
1872
- }
1873
- /**
1874
- * templatize field name when referenced like this: \{\{fieldName\}\}
1875
- * checks each field name from the layer
1876
- *
1877
- * @param name the field name to templatize
1878
- * @param layer json of layer being cloned
1879
- * @param itemID id of the item that contains the current layer
1880
- * @param basePath path used to de-templatize while deploying
1881
- * @private
1882
- */
1883
- export function _templatizeFieldName(name, layer, itemID, basePath) {
1884
- if (name.indexOf("relationships/") > -1) {
1885
- const rels = name.split("/");
1886
- const relationshipId = rels[1];
1887
- const adminRelatedTables = getProp(layer, "adminLayerInfo.viewLayerDefinition.table.relatedTables");
1888
- const relatedTables = layer.relationships || adminRelatedTables;
1889
- /* istanbul ignore else */
1890
- if (relatedTables && relatedTables.length > parseInt(relationshipId, 10)) {
1891
- const relatedTable = relatedTables[relationshipId];
1892
- // the layers relationships stores the property as relatedTableId
1893
- // the layers adminLayerInfo relatedTables stores the property as sourceLayerId
1894
- const prop = getProp(relatedTable, "relatedTableId") ? "relatedTableId" : "sourceLayerId";
1895
- const _basePath = itemID + ".layer" + relatedTable[prop] + ".fields";
1896
- rels[2] = _templatize(_basePath, rels[2], "name");
1897
- name = rels.join("/");
1898
- }
1899
- }
1900
- else {
1901
- // do not need to templatize expression references as the expression
1902
- // itself will be templatized
1903
- if (name.indexOf("expression/") === -1) {
1904
- name = _templatize(basePath, name, "name");
1905
- }
1906
- }
1907
- return name;
1908
- }
1909
- /**
1910
- * templatize field name when referenced in expressionInfos
1911
- *
1912
- * @param expressionInfos the popups expressionInfos to check
1913
- * @param fieldNames array of the layers field names
1914
- * @param basePath path used to de-templatize while deploying
1915
- * @private
1916
- */
1917
- export function _templatizeExpressionInfos(expressionInfos, fieldNames, basePath) {
1918
- return expressionInfos.map((i) => {
1919
- fieldNames.forEach((name) => {
1920
- i.expression = _templatizeArcadeExpressions(i.expression, name, basePath);
1921
- });
1922
- return i;
1923
- });
1924
- }
1925
- /**
1926
- * templatize field name when referenced in popupElelments
1927
- *
1928
- * @param popupElelments the popups popupElelments to check
1929
- * @param basePath path used to de-templatize while deploying
1930
- * @param layer json of layer being cloned
1931
- * @param itemID id of the item that contains the current layer
1932
- * @param fieldNames array of field names
1933
- * @private
1934
- */
1935
- export function _templatizePopupElements(popupElelments, basePath, layer, itemID, fieldNames) {
1936
- popupElelments.forEach((pe) => {
1937
- if (pe.hasOwnProperty("fieldInfos")) {
1938
- _templatizePopupInfoFieldInfos(pe.fieldInfos, layer, itemID, basePath);
1939
- }
1940
- if (pe.hasOwnProperty("mediaInfos")) {
1941
- _templatizeMediaInfos(pe.mediaInfos, fieldNames, basePath, layer, itemID);
1942
- }
1943
- });
1944
- }
1945
- /**
1946
- * templatize field name when referenced in mediaInfos
1947
- *
1948
- * @param mediaInfos the popups mediaInfos to check
1949
- * @param fieldNames array of the layers field names
1950
- * @param basePath path used to de-templatize while deploying
1951
- * @param layer json of layer being cloned
1952
- * @param itemID id of the item that contains the current layer
1953
- * @private
1954
- */
1955
- export function _templatizeMediaInfos(mediaInfos, fieldNames, basePath, layer, itemId) {
1956
- // templatize various properties of mediaInfos
1957
- const props = ["title", "caption"];
1958
- props.forEach((p) => _templatizeName(mediaInfos, p, fieldNames, basePath));
1959
- mediaInfos.forEach((mi) => {
1960
- /* istanbul ignore else */
1961
- if (mi.hasOwnProperty("value")) {
1962
- const v = mi.value;
1963
- const vfields = v.fields || [];
1964
- v.fields = vfields.map((f) => _templatizeFieldName(f, layer, itemId, basePath));
1965
- if (v.hasOwnProperty("normalizeField")) {
1966
- _templatizeProperty(v, "normalizeField", basePath, "name");
1967
- }
1968
- /* istanbul ignore else */
1969
- if (v.hasOwnProperty("tooltipField")) {
1970
- v.tooltipField = _templatizeFieldName(v.tooltipField, layer, itemId, basePath);
1971
- }
1972
- }
1973
- });
1974
- }
1975
- /**
1976
- * templatize field names when referenced in definitionEditor
1977
- *
1978
- * @param layer the layer with the definition editor
1979
- * @param basePath path used to de-templatize while deploying
1980
- * @param fieldNames json of layer being cloned
1981
- * @private
1982
- */
1983
- export function _templatizeDefinitionEditor(layer, basePath, fieldNames) {
1984
- if (layer) {
1985
- const defEditor = layer.definitionEditor || {};
1986
- /* istanbul ignore else */
1987
- if (defEditor) {
1988
- const inputs = defEditor.inputs;
1989
- if (inputs) {
1990
- inputs.forEach((i) => {
1991
- /* istanbul ignore else */
1992
- if (i.parameters) {
1993
- i.parameters.forEach((p) => {
1994
- _templatizeProperty(p, "fieldName", basePath, "name");
1995
- });
1996
- }
1997
- });
1998
- }
1999
- if (defEditor.hasOwnProperty("parameterizedExpression")) {
2000
- defEditor.parameterizedExpression = _templatizeSimpleName(defEditor.parameterizedExpression || "", basePath, fieldNames, "name");
2001
- }
2002
- }
2003
- }
2004
- }
2005
- /**
2006
- * templatize field names when referenced in definitionExpression
2007
- *
2008
- * @param layer the layer with the definition editor
2009
- * @param basePath path used to de-templatize while deploying
2010
- * @param fieldNames array of field names
2011
- * @private
2012
- */
2013
- export function _templatizeDefinitionExpression(layer, basePath, fieldNames) {
2014
- if (layer && layer.hasOwnProperty("definitionExpression")) {
2015
- layer.definitionExpression = _templatizeSimpleName(layer.definitionExpression || "", basePath, fieldNames, "name");
2016
- }
2017
- }
2018
- /**
2019
- * Case sensitive test for field names that appear anywhere within a string
2020
- *
2021
- * @param expression the expression to test for field name references
2022
- * @param basePath path used to de-templatize while deploying
2023
- * @param fieldNames array of the layers field names
2024
- * @private
2025
- */
2026
- export function _templatizeSimpleName(expression, basePath, fieldNames, suffix) {
2027
- fieldNames.forEach((name) => {
2028
- // look for the name but not if its followed by }}
2029
- const regEx = new RegExp("\\b" + name + "\\b(?![}]{2})", "gm");
2030
- if (expression && regEx.test(expression)) {
2031
- expression = expression.replace(regEx, _templatize(basePath, name, suffix));
2032
- }
2033
- });
2034
- return expression;
2035
- }
2036
- /**
2037
- * Templatize field references within a layers drawingInfo
2038
- *
2039
- * @param layer the data layer
2040
- * @param basePath path used to de-templatize while deploying
2041
- * @param fieldNames array of the layers field names
2042
- * @private
2043
- */
2044
- export function _templatizeDrawingInfo(layer, basePath, fieldNames) {
2045
- if (layer) {
2046
- const drawingInfo = layer.drawingInfo;
2047
- if (drawingInfo) {
2048
- // templatize the renderer fields
2049
- const renderer = drawingInfo.renderer || {};
2050
- _templatizeRenderer(renderer, basePath, fieldNames);
2051
- // templatize the labelingInfo
2052
- const labelingInfo = drawingInfo.labelingInfo || [];
2053
- _templatizeLabelingInfo(labelingInfo, basePath, fieldNames);
2054
- }
2055
- }
2056
- }
2057
- /**
2058
- * Templatize field references within a layers drawingInfo
2059
- *
2060
- * @param renderer the layers renderer
2061
- * @param basePath path used to de-templatize while deploying
2062
- * @param fieldNames array of the layers field names
2063
- * @private
2064
- */
2065
- export function _templatizeRenderer(renderer, basePath, fieldNames) {
2066
- switch (renderer.type) {
2067
- case "classBreaks":
2068
- case "uniqueValue":
2069
- case "predominance":
2070
- case "simple":
2071
- case "heatmap":
2072
- _templatizeGenRenderer(renderer, basePath, fieldNames);
2073
- break;
2074
- case "temporal":
2075
- _templatizeTemporalRenderer(renderer, basePath, fieldNames);
2076
- break;
2077
- default:
2078
- break;
2079
- }
2080
- }
2081
- /**
2082
- * Templatize field references within a layers renderer
2083
- *
2084
- * @param renderer the renderer object to check for field references
2085
- * @param basePath path used to de-templatize while deploying
2086
- * @param fieldNames array of field names that will be used to search expressions
2087
- * @private
2088
- */
2089
- export function _templatizeGenRenderer(renderer, basePath, fieldNames) {
2090
- /* istanbul ignore else */
2091
- if (renderer) {
2092
- // update authoringInfo
2093
- const authoringInfo = renderer.authoringInfo;
2094
- if (authoringInfo) {
2095
- _templatizeAuthoringInfo(authoringInfo, basePath, fieldNames);
2096
- }
2097
- const props = ["field", "normalizationField"];
2098
- props.forEach((p) => _templatizeProperty(renderer, p, basePath, "name"));
2099
- const fieldNameProps = ["field1", "field2", "field3"];
2100
- fieldNameProps.forEach((fnP) => _templatizeProperty(renderer, fnP, basePath, "name"));
2101
- // When an attribute name is specified, it's enclosed in square brackets
2102
- const rExp = renderer.rotationExpression;
2103
- if (rExp) {
2104
- fieldNames.forEach((name) => {
2105
- const regEx = new RegExp("(\\[" + name + "\\])", "gm");
2106
- if (regEx.test(rExp)) {
2107
- renderer.rotationExpression = rExp.replace(regEx, "[" + _templatize(basePath, name, "name") + "]");
2108
- }
2109
- });
2110
- }
2111
- // update valueExpression
2112
- if (renderer.valueExpression) {
2113
- fieldNames.forEach((name) => {
2114
- renderer.valueExpression = _templatizeArcadeExpressions(renderer.valueExpression, name, basePath);
2115
- });
2116
- }
2117
- // update visualVariables
2118
- const visualVariables = renderer.visualVariables;
2119
- if (visualVariables) {
2120
- visualVariables.forEach((v) => {
2121
- props.forEach((p) => _templatizeProperty(v, p, basePath, "name"));
2122
- if (v.valueExpression) {
2123
- fieldNames.forEach((name) => {
2124
- v.valueExpression = _templatizeArcadeExpressions(v.valueExpression, name, basePath);
2125
- });
2126
- }
2127
- });
2128
- }
2129
- }
2130
- }
2131
- /**
2132
- * Templatize field references within a layers renderer
2133
- *
2134
- * @param renderer the renderer object to check for field references
2135
- * @param basePath path used to de-templatize while deploying
2136
- * @param fieldNames array of field names that will be used to search expressions
2137
- * @private
2138
- */
2139
- export function _templatizeTemporalRenderer(renderer, basePath, fieldNames) {
2140
- const renderers = [renderer.latestObservationRenderer, renderer.observationRenderer, renderer.trackRenderer];
2141
- renderers.forEach((r) => {
2142
- _templatizeRenderer(r, basePath, fieldNames);
2143
- });
2144
- }
2145
- /**
2146
- * Templatize renderers authoringInfo
2147
- *
2148
- * @param authoringInfo object containing metadata about the authoring process
2149
- * @param basePath path used to de-templatize while deploying
2150
- * @param fieldNames the name of fields from the layer
2151
- * @private
2152
- */
2153
- export function _templatizeAuthoringInfo(authoringInfo, basePath, fieldNames) {
2154
- /* istanbul ignore else */
2155
- if (authoringInfo) {
2156
- const props = ["field", "normalizationField"];
2157
- const field1 = authoringInfo.field1;
2158
- props.forEach((p) => _templatizeProperty(field1, p, basePath, "name"));
2159
- const field2 = authoringInfo.field2;
2160
- props.forEach((p) => _templatizeProperty(field2, p, basePath, "name"));
2161
- const fields = authoringInfo.fields;
2162
- if (fields) {
2163
- authoringInfo.fields = fields.map((f) => _templatize(basePath, f, "name"));
2164
- }
2165
- const vProps = ["endTime", "field", "startTime"];
2166
- const vVars = authoringInfo.visualVariables;
2167
- if (vVars) {
2168
- vProps.forEach((p) => {
2169
- // endTime and startTime may or may not be a field name
2170
- if (fieldNames.indexOf(vVars[p]) > -1) {
2171
- _templatizeProperty(vVars, p, basePath, "name");
2172
- }
2173
- });
2174
- }
2175
- }
2176
- }
2177
- /**
2178
- * Templatize field references within an arcade expression
2179
- *
2180
- * @param text the text that contains the expression
2181
- * @param fieldName name of the field to test for
2182
- * @param basePath path used to de-templatize while deploying
2183
- * @private
2184
- */
2185
- export function _templatizeArcadeExpressions(text, fieldName, basePath) {
2186
- const t = _templatize(basePath, fieldName, "name");
2187
- if (text) {
2188
- // test for $feature. notation
2189
- // captures VOTED_DEM_2012 from $feature.VOTED_DEM_2012
2190
- let exp = "(?:\\$feature\\.)(" + fieldName + ")\\b";
2191
- let regEx = new RegExp(exp, "gm");
2192
- text = regEx.test(text) ? text.replace(regEx, "$feature." + t) : text;
2193
- // test for $feature[] notation
2194
- // captures VOTED_DEM_2012 from $feature["VOTED_DEM_2012"]
2195
- // captures VOTED_DEM_2012 from $feature['VOTED_DEM_2012']
2196
- // captures VOTED_DEM_2012 from $feature[VOTED_DEM_2012]
2197
- exp = "(?:[$]feature)(\\[\\\"?\\'?)" + fieldName + "(\\\"?\\'?\\])";
2198
- regEx = new RegExp(exp, "gm");
2199
- let result = regEx.exec(text);
2200
- if (result) {
2201
- text = text.replace(regEx, "$feature" + result[1] + t + result[2]);
2202
- }
2203
- // test for $feature[] with join case
2204
- // captures VOTED_DEM_2016 from $feature["COUNTY_ID.VOTED_DEM_2016"]
2205
- exp = "(?:[$]feature)(\\[\\\"?\\'?)(\\w+)[.]" + fieldName + "(\\\"?\\'?\\])";
2206
- regEx = new RegExp(exp, "gm");
2207
- result = regEx.exec(text);
2208
- if (result && result.length > 3) {
2209
- // TODO result[2] is the table name...this needs to be templatized as well
2210
- text = text.replace(regEx, "$feature" + result[1] + result[2] + "." + t + result[3]);
2211
- }
2212
- // test for "fieldName"
2213
- // captures fieldName from "var names = ["fieldName", "fieldName2"]..."
2214
- // captures fieldName from "var names = ['fieldName', 'fieldName2']..."
2215
- exp = "(\\\"|\\')+" + fieldName + "(\\\"|\\')+";
2216
- regEx = new RegExp(exp, "gm");
2217
- result = regEx.exec(text);
2218
- if (result) {
2219
- text = text.replace(regEx, result[1] + t + result[2]);
2220
- }
2221
- }
2222
- return text;
2223
- }
2224
- /**
2225
- * templatize field names when referenced in the layers labelingInfo
2226
- *
2227
- * @param labelingInfo the object that contains the labelingInfo
2228
- * @param basePath path used to de-templatize while deploying
2229
- * @param fieldNames array of the layers field names
2230
- * @private
2231
- */
2232
- export function _templatizeLabelingInfo(labelingInfo, basePath, fieldNames) {
2233
- labelingInfo.forEach((li) => {
2234
- /* istanbul ignore else */
2235
- if (li.hasOwnProperty("fieldInfos")) {
2236
- const fieldInfos = li.fieldInfos || [];
2237
- fieldInfos.forEach((fi) => _templatizeProperty(fi, "fieldName", basePath, "name"));
2238
- }
2239
- const labelExp = li.labelExpression || "";
2240
- const labelExpInfo = li.labelExpressionInfo || {};
2241
- fieldNames.forEach((n) => {
2242
- const t = _templatize(basePath, n, "name");
2243
- // check for [fieldName] or ["fieldName"]
2244
- const regExBracket = new RegExp('(\\[\\"*)+(' + n + ')(\\"*\\])+', "gm");
2245
- let result = regExBracket.exec(labelExp);
2246
- if (result) {
2247
- li.labelExpression = labelExp.replace(regExBracket, result[1] + t + result[3]);
2248
- }
2249
- /* istanbul ignore else */
2250
- if (labelExpInfo.value) {
2251
- let v = labelExpInfo.value;
2252
- // check for {fieldName}
2253
- const regExCurly = new RegExp("(\\{" + n + "\\})", "gm");
2254
- v = regExCurly.test(v) ? v.replace(regExCurly, "{" + t + "}") : v;
2255
- // check for [fieldName] or ["fieldName"]
2256
- result = regExBracket.exec(v);
2257
- v = result ? v.replace(regExBracket, result[1] + t + result[3]) : v;
2258
- li.labelExpressionInfo.value = v;
2259
- }
2260
- /* istanbul ignore else */
2261
- if (labelExpInfo.expression) {
2262
- li.labelExpressionInfo.expression = _templatizeArcadeExpressions(labelExpInfo.expression, n, basePath);
2263
- }
2264
- });
2265
- });
2266
- }
2267
- /**
2268
- * templatize the layers editing templates
2269
- *
2270
- * @param layer the data layer being cloned
2271
- * @param basePath path used to de-templatize while deploying
2272
- * @private
2273
- */
2274
- export function _templatizeTemplates(layer, basePath) {
2275
- const templates = layer.templates || [];
2276
- templates.forEach((t) => {
2277
- const attributes = getProp(t, "prototype.attributes");
2278
- const _attributes = _templatizeKeys(attributes, basePath, "name");
2279
- /* istanbul ignore else */
2280
- if (_attributes) {
2281
- t.prototype.attributes = _attributes;
2282
- }
2283
- });
2284
- }
2285
- /**
2286
- * templatize the layer types and templates
2287
- *
2288
- * @param layer the data layer being cloned
2289
- * @param basePath path used to de-templatize while deploying
2290
- * @private
2291
- */
2292
- export function _templatizeTypeTemplates(layer, basePath) {
2293
- const types = layer.types;
2294
- if (types && Array.isArray(types) && types.length > 0) {
2295
- types.forEach((type) => {
2296
- const domains = _templatizeKeys(type.domains, basePath, "name");
2297
- /* istanbul ignore else */
2298
- if (domains) {
2299
- type.domains = domains;
2300
- }
2301
- const templates = type.templates;
2302
- /* istanbul ignore else */
2303
- if (templates && templates.length > 0) {
2304
- templates.forEach((t) => {
2305
- const attributes = getProp(t, "prototype.attributes");
2306
- const _attributes = _templatizeKeys(attributes, basePath, "name");
2307
- /* istanbul ignore else */
2308
- if (_attributes) {
2309
- t.prototype.attributes = _attributes;
2310
- }
2311
- });
2312
- }
2313
- });
2314
- }
2315
- }
2316
- /**
2317
- * templatize object keys
2318
- *
2319
- * @param obj the object to templatize
2320
- * @param basePath path used to de-templatize while deploying
2321
- * @param suffix expected suffix for template variable
2322
- * @private
2323
- */
2324
- export function _templatizeKeys(obj, basePath, suffix) {
2325
- let _obj;
2326
- /* istanbul ignore else */
2327
- if (obj) {
2328
- _obj = {};
2329
- const objKeys = Object.keys(obj);
2330
- /* istanbul ignore else */
2331
- if (objKeys && objKeys.length > 0) {
2332
- objKeys.forEach((k) => {
2333
- _obj[_templatize(basePath, k, suffix)] = obj[k];
2334
- });
2335
- }
2336
- }
2337
- return _obj;
2338
- }
2339
- /**
2340
- * templatize fields referenced in the layers time info
2341
- *
2342
- * @param layer the data layer being cloned
2343
- * @param basePath path used to de-templatize while deploying
2344
- * @private
2345
- */
2346
- export function _templatizeTimeInfo(layer, basePath) {
2347
- if (layer.timeInfo) {
2348
- const timeInfo = layer.timeInfo;
2349
- const timeProps = ["endTimeField", "startTimeField", "trackIdField"];
2350
- timeProps.forEach((t) => {
2351
- if (timeInfo[t] !== "") {
2352
- _templatizeProperty(timeInfo, t, basePath, "name");
2353
- }
2354
- else {
2355
- timeInfo[t] = null;
2356
- }
2357
- });
2358
- }
2359
- }
2360
- /**
2361
- * templatize the layers definition query
2362
- *
2363
- * @param layer the data layer being cloned
2364
- * @param basePath path used to de-templatize while deploying
2365
- * @param fieldNames array of the layers field names
2366
- * @private
2367
- */
2368
- export function _templatizeDefinitionQuery(layer, basePath, fieldNames) {
2369
- // templatize view definition query
2370
- if (layer && layer.hasOwnProperty("viewDefinitionQuery")) {
2371
- layer.viewDefinitionQuery = _templatizeSimpleName(layer.viewDefinitionQuery || "", basePath, fieldNames, "name");
2372
- }
2373
- if (layer && layer.hasOwnProperty("definitionQuery")) {
2374
- layer.definitionQuery = _templatizeSimpleName(layer.definitionQuery || "", basePath, fieldNames, "name");
2375
- }
2376
- }
2377
- /**
2378
- * Helper function to create the name mapping used to
2379
- * de-templatize the field reference
2380
- *
2381
- * @param fieldInfos the object that stores the cached information
2382
- * @param id the id for the current layer being processed
2383
- * @private
2384
- */
2385
- export function _getNameMapping(fieldInfos, id) {
2386
- // create name mapping
2387
- const fInfo = fieldInfos[id];
2388
- const nameMapping = {};
2389
- const newFields = fInfo.newFields;
2390
- const newFieldNames = newFields ? newFields.map((f) => f.name) : [];
2391
- const sourceFields = fInfo.sourceFields || [];
2392
- sourceFields.forEach((field) => {
2393
- const lName = String(field.name).toLowerCase();
2394
- newFields.forEach((f) => {
2395
- // Names can change more than case
2396
- if (newFieldNames.indexOf(field.name) === -1 && newFieldNames.indexOf(lName) === -1) {
2397
- // If both new (f) and source (field) aliases are defined and are equal, map the source name to the new name
2398
- if (f.alias && f.alias === field.alias) {
2399
- nameMapping[lName] = {
2400
- name: f.name,
2401
- alias: f.alias,
2402
- type: f.type ? f.type : "",
2403
- };
2404
- }
2405
- }
2406
- if (String(f.name).toLowerCase() === lName) {
2407
- nameMapping[lName] = {
2408
- name: f.name,
2409
- alias: f.alias ? f.alias : "",
2410
- type: f.type ? f.type : "",
2411
- };
2412
- }
2413
- });
2414
- });
2415
- // update for editFieldsInfo
2416
- if (fInfo.editFieldsInfo && fInfo.newEditFieldsInfo) {
2417
- const efi = JSON.parse(JSON.stringify(fInfo.editFieldsInfo));
2418
- const newEfi = JSON.parse(JSON.stringify(fInfo.newEditFieldsInfo));
2419
- const nameMappingKeys = Object.keys(nameMapping);
2420
- Object.keys(efi).forEach((k) => {
2421
- const lowerEfi = String(efi[k]).toLowerCase();
2422
- if ((nameMappingKeys.indexOf(lowerEfi) === -1 || nameMapping[lowerEfi].name !== newEfi[k]) &&
2423
- newFieldNames.indexOf(lowerEfi) > -1) {
2424
- // Only add delete fields if source schema changes allowed
2425
- /* istanbul ignore else */
2426
- if (fInfo.sourceSchemaChangesAllowed && !fInfo.isView) {
2427
- /* istanbul ignore else */
2428
- if (!fInfo.hasOwnProperty("deleteFields")) {
2429
- fInfo.deleteFields = [];
2430
- }
2431
- // This issue only occurs on portal so we
2432
- // need to delete the lcase version of the field
2433
- fInfo.deleteFields.push(lowerEfi);
2434
- }
2435
- // editFieldsInfo only has the name and not the alias and type
2436
- let sourceEfiField;
2437
- fInfo.sourceFields.some((sf) => {
2438
- if (sf.name === efi[k]) {
2439
- sourceEfiField = sf;
2440
- }
2441
- return sf.name === efi[k];
2442
- });
2443
- nameMapping[lowerEfi] = {
2444
- name: newEfi[k],
2445
- alias: sourceEfiField && sourceEfiField.alias ? sourceEfiField.alias : "",
2446
- type: sourceEfiField && sourceEfiField.type ? sourceEfiField.type : "",
2447
- };
2448
- }
2449
- });
2450
- deleteProp(fInfo, "sourceSchemaChangesAllowed");
2451
- deleteProp(fInfo, "editFieldsInfo");
2452
- deleteProp(fInfo, "newEditFieldsInfo");
2453
- deleteProp(fInfo, "isView");
2454
- }
2455
- return nameMapping;
2456
- }
2457
- /**
2458
- * Helper function to ensure same chunk size value is used in multiple locations
2459
- *
2460
- * @returns a number that represents how many layers should be included per addToDef call
2461
- * @private
2462
- */
2463
- export function _getLayerChunkSize() {
2464
- return 20;
2465
- }
2466
- //# sourceMappingURL=featureServiceHelpers.js.map