@esri/solution-common 6.0.4-alpha.0 → 6.1.0-alpha.0

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