@ngageoint/mage.service 6.2.2

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 (869) hide show
  1. package/bin/mage.service.js +230 -0
  2. package/bin/migration.js +60 -0
  3. package/bin/poststop.sh +1 -0
  4. package/bin/prestart.sh +1 -0
  5. package/lib/@types/express/index.d.ts +18 -0
  6. package/lib/@types/geojson-validation/index.d.ts +15 -0
  7. package/lib/@types/mongodb-migrations/index.d.ts +99 -0
  8. package/lib/access/index.d.ts +21 -0
  9. package/lib/access/index.d.ts.map +1 -0
  10. package/lib/access/index.js +40 -0
  11. package/lib/access/index.js.map +1 -0
  12. package/lib/adapters/adapters.controllers.web.d.ts +22 -0
  13. package/lib/adapters/adapters.controllers.web.d.ts.map +1 -0
  14. package/lib/adapters/adapters.controllers.web.js +55 -0
  15. package/lib/adapters/adapters.controllers.web.js.map +1 -0
  16. package/lib/adapters/adapters.db.mongoose.d.ts +5 -0
  17. package/lib/adapters/adapters.db.mongoose.d.ts.map +1 -0
  18. package/lib/adapters/adapters.db.mongoose.js +70 -0
  19. package/lib/adapters/adapters.db.mongoose.js.map +1 -0
  20. package/lib/adapters/adapters.simple_id_factory.d.ts +5 -0
  21. package/lib/adapters/adapters.simple_id_factory.d.ts.map +1 -0
  22. package/lib/adapters/adapters.simple_id_factory.js +24 -0
  23. package/lib/adapters/adapters.simple_id_factory.js.map +1 -0
  24. package/lib/adapters/base/adapters.base.db.mongoose.d.ts +59 -0
  25. package/lib/adapters/base/adapters.base.db.mongoose.d.ts.map +1 -0
  26. package/lib/adapters/base/adapters.base.db.mongoose.js +143 -0
  27. package/lib/adapters/base/adapters.base.db.mongoose.js.map +1 -0
  28. package/lib/adapters/events/adapters.events.controllers.web.d.ts +14 -0
  29. package/lib/adapters/events/adapters.events.controllers.web.d.ts.map +1 -0
  30. package/lib/adapters/events/adapters.events.controllers.web.js +83 -0
  31. package/lib/adapters/events/adapters.events.controllers.web.js.map +1 -0
  32. package/lib/adapters/events/adapters.events.db.mongoose.d.ts +27 -0
  33. package/lib/adapters/events/adapters.events.db.mongoose.d.ts.map +1 -0
  34. package/lib/adapters/events/adapters.events.db.mongoose.js +127 -0
  35. package/lib/adapters/events/adapters.events.db.mongoose.js.map +1 -0
  36. package/lib/adapters/feeds/adapters.feeds.controllers.web.d.ts +25 -0
  37. package/lib/adapters/feeds/adapters.feeds.controllers.web.d.ts.map +1 -0
  38. package/lib/adapters/feeds/adapters.feeds.controllers.web.js +234 -0
  39. package/lib/adapters/feeds/adapters.feeds.controllers.web.js.map +1 -0
  40. package/lib/adapters/feeds/adapters.feeds.db.mongoose.d.ts +63 -0
  41. package/lib/adapters/feeds/adapters.feeds.db.mongoose.d.ts.map +1 -0
  42. package/lib/adapters/feeds/adapters.feeds.db.mongoose.js +199 -0
  43. package/lib/adapters/feeds/adapters.feeds.db.mongoose.js.map +1 -0
  44. package/lib/adapters/icons/adapters.icons.content_store.file_system.d.ts +7 -0
  45. package/lib/adapters/icons/adapters.icons.content_store.file_system.d.ts.map +1 -0
  46. package/lib/adapters/icons/adapters.icons.content_store.file_system.js +13 -0
  47. package/lib/adapters/icons/adapters.icons.content_store.file_system.js.map +1 -0
  48. package/lib/adapters/icons/adapters.icons.controllers.web.d.ts +10 -0
  49. package/lib/adapters/icons/adapters.icons.controllers.web.d.ts.map +1 -0
  50. package/lib/adapters/icons/adapters.icons.controllers.web.js +118 -0
  51. package/lib/adapters/icons/adapters.icons.controllers.web.js.map +1 -0
  52. package/lib/adapters/icons/adapters.icons.db.mongoose.d.ts +38 -0
  53. package/lib/adapters/icons/adapters.icons.db.mongoose.d.ts.map +1 -0
  54. package/lib/adapters/icons/adapters.icons.db.mongoose.js +287 -0
  55. package/lib/adapters/icons/adapters.icons.db.mongoose.js.map +1 -0
  56. package/lib/adapters/observations/adapters.observations.attachment_store.file_system.d.ts +29 -0
  57. package/lib/adapters/observations/adapters.observations.attachment_store.file_system.d.ts.map +1 -0
  58. package/lib/adapters/observations/adapters.observations.attachment_store.file_system.js +274 -0
  59. package/lib/adapters/observations/adapters.observations.attachment_store.file_system.js.map +1 -0
  60. package/lib/adapters/observations/adapters.observations.controllers.web.d.ts +40 -0
  61. package/lib/adapters/observations/adapters.observations.controllers.web.d.ts.map +1 -0
  62. package/lib/adapters/observations/adapters.observations.controllers.web.js +196 -0
  63. package/lib/adapters/observations/adapters.observations.controllers.web.js.map +1 -0
  64. package/lib/adapters/observations/adapters.observations.db.mongoose.d.ts +30 -0
  65. package/lib/adapters/observations/adapters.observations.db.mongoose.d.ts.map +1 -0
  66. package/lib/adapters/observations/adapters.observations.db.mongoose.js +294 -0
  67. package/lib/adapters/observations/adapters.observations.db.mongoose.js.map +1 -0
  68. package/lib/adapters/plugins/adapters.plugins.db.mongoose.d.ts +17 -0
  69. package/lib/adapters/plugins/adapters.plugins.db.mongoose.d.ts.map +1 -0
  70. package/lib/adapters/plugins/adapters.plugins.db.mongoose.js +59 -0
  71. package/lib/adapters/plugins/adapters.plugins.db.mongoose.js.map +1 -0
  72. package/lib/adapters/url_schemes/adapters.url_schemes.plugin.d.ts +38 -0
  73. package/lib/adapters/url_schemes/adapters.url_schemes.plugin.d.ts.map +1 -0
  74. package/lib/adapters/url_schemes/adapters.url_schemes.plugin.js +110 -0
  75. package/lib/adapters/url_schemes/adapters.url_schemes.plugin.js.map +1 -0
  76. package/lib/adapters/users/adapters.users.controllers.web.d.ts +7 -0
  77. package/lib/adapters/users/adapters.users.controllers.web.d.ts.map +1 -0
  78. package/lib/adapters/users/adapters.users.controllers.web.js +37 -0
  79. package/lib/adapters/users/adapters.users.controllers.web.js.map +1 -0
  80. package/lib/adapters/users/adapters.users.db.mongoose.d.ts +19 -0
  81. package/lib/adapters/users/adapters.users.db.mongoose.d.ts.map +1 -0
  82. package/lib/adapters/users/adapters.users.db.mongoose.js +126 -0
  83. package/lib/adapters/users/adapters.users.db.mongoose.js.map +1 -0
  84. package/lib/adapters/web_ui_plugins/adapters.web_ui_plugins.controllers.web.d.ts +3 -0
  85. package/lib/adapters/web_ui_plugins/adapters.web_ui_plugins.controllers.web.d.ts.map +1 -0
  86. package/lib/adapters/web_ui_plugins/adapters.web_ui_plugins.controllers.web.js +53 -0
  87. package/lib/adapters/web_ui_plugins/adapters.web_ui_plugins.controllers.web.js.map +1 -0
  88. package/lib/api/attachment.d.ts +12 -0
  89. package/lib/api/attachment.d.ts.map +1 -0
  90. package/lib/api/attachment.js +81 -0
  91. package/lib/api/attachment.js.map +1 -0
  92. package/lib/api/event.d.ts +20 -0
  93. package/lib/api/event.d.ts.map +1 -0
  94. package/lib/api/event.js +185 -0
  95. package/lib/api/event.js.map +1 -0
  96. package/lib/api/events/location.d.ts +11 -0
  97. package/lib/api/events/location.d.ts.map +1 -0
  98. package/lib/api/events/location.js +13 -0
  99. package/lib/api/events/location.js.map +1 -0
  100. package/lib/api/events/observation.d.ts +15 -0
  101. package/lib/api/events/observation.d.ts.map +1 -0
  102. package/lib/api/events/observation.js +21 -0
  103. package/lib/api/events/observation.js.map +1 -0
  104. package/lib/api/feature.d.ts +8 -0
  105. package/lib/api/feature.d.ts.map +1 -0
  106. package/lib/api/feature.js +15 -0
  107. package/lib/api/feature.js.map +1 -0
  108. package/lib/api/field/attachmentField.d.ts +12 -0
  109. package/lib/api/field/attachmentField.d.ts.map +1 -0
  110. package/lib/api/field/attachmentField.js +40 -0
  111. package/lib/api/field/attachmentField.js.map +1 -0
  112. package/lib/api/field/checkboxField.d.ts +7 -0
  113. package/lib/api/field/checkboxField.d.ts.map +1 -0
  114. package/lib/api/field/checkboxField.js +19 -0
  115. package/lib/api/field/checkboxField.js.map +1 -0
  116. package/lib/api/field/dateField.d.ts +8 -0
  117. package/lib/api/field/dateField.d.ts.map +1 -0
  118. package/lib/api/field/dateField.js +21 -0
  119. package/lib/api/field/dateField.js.map +1 -0
  120. package/lib/api/field/emailField.d.ts +7 -0
  121. package/lib/api/field/emailField.d.ts.map +1 -0
  122. package/lib/api/field/emailField.js +19 -0
  123. package/lib/api/field/emailField.js.map +1 -0
  124. package/lib/api/field/field.d.ts +12 -0
  125. package/lib/api/field/field.d.ts.map +1 -0
  126. package/lib/api/field/field.js +12 -0
  127. package/lib/api/field/field.js.map +1 -0
  128. package/lib/api/field/geometryField.d.ts +7 -0
  129. package/lib/api/field/geometryField.d.ts.map +1 -0
  130. package/lib/api/field/geometryField.js +35 -0
  131. package/lib/api/field/geometryField.js.map +1 -0
  132. package/lib/api/field/index.d.ts +7 -0
  133. package/lib/api/field/index.d.ts.map +1 -0
  134. package/lib/api/field/index.js +30 -0
  135. package/lib/api/field/index.js.map +1 -0
  136. package/lib/api/field/multiSelectField.d.ts +7 -0
  137. package/lib/api/field/multiSelectField.d.ts.map +1 -0
  138. package/lib/api/field/multiSelectField.js +27 -0
  139. package/lib/api/field/multiSelectField.js.map +1 -0
  140. package/lib/api/field/numberField.d.ts +7 -0
  141. package/lib/api/field/numberField.d.ts.map +1 -0
  142. package/lib/api/field/numberField.js +27 -0
  143. package/lib/api/field/numberField.js.map +1 -0
  144. package/lib/api/field/selectField.d.ts +7 -0
  145. package/lib/api/field/selectField.d.ts.map +1 -0
  146. package/lib/api/field/selectField.js +22 -0
  147. package/lib/api/field/selectField.js.map +1 -0
  148. package/lib/api/field/textField.d.ts +7 -0
  149. package/lib/api/field/textField.d.ts.map +1 -0
  150. package/lib/api/field/textField.js +21 -0
  151. package/lib/api/field/textField.js.map +1 -0
  152. package/lib/api/form.d.ts +12 -0
  153. package/lib/api/form.d.ts.map +1 -0
  154. package/lib/api/form.js +239 -0
  155. package/lib/api/form.js.map +1 -0
  156. package/lib/api/icon.d.ts +22 -0
  157. package/lib/api/icon.d.ts.map +1 -0
  158. package/lib/api/icon.js +178 -0
  159. package/lib/api/icon.js.map +1 -0
  160. package/lib/api/index.d.ts +10 -0
  161. package/lib/api/index.d.ts.map +1 -0
  162. package/lib/api/index.js +11 -0
  163. package/lib/api/index.js.map +1 -0
  164. package/lib/api/layer.d.ts +14 -0
  165. package/lib/api/layer.d.ts.map +1 -0
  166. package/lib/api/layer.js +70 -0
  167. package/lib/api/layer.js.map +1 -0
  168. package/lib/api/location.d.ts +14 -0
  169. package/lib/api/location.d.ts.map +1 -0
  170. package/lib/api/location.js +35 -0
  171. package/lib/api/location.js.map +1 -0
  172. package/lib/api/observation.d.ts +25 -0
  173. package/lib/api/observation.d.ts.map +1 -0
  174. package/lib/api/observation.js +224 -0
  175. package/lib/api/observation.js.map +1 -0
  176. package/lib/api/user.d.ts +16 -0
  177. package/lib/api/user.d.ts.map +1 -0
  178. package/lib/api/user.js +250 -0
  179. package/lib/api/user.js.map +1 -0
  180. package/lib/app.api/app.api.errors.d.ts +42 -0
  181. package/lib/app.api/app.api.errors.d.ts.map +1 -0
  182. package/lib/app.api/app.api.errors.js +43 -0
  183. package/lib/app.api/app.api.errors.js.map +1 -0
  184. package/lib/app.api/app.api.global.d.ts +74 -0
  185. package/lib/app.api/app.api.global.d.ts.map +1 -0
  186. package/lib/app.api/app.api.global.js +59 -0
  187. package/lib/app.api/app.api.global.js.map +1 -0
  188. package/lib/app.api/events/app.api.events.d.ts +31 -0
  189. package/lib/app.api/events/app.api.events.d.ts.map +1 -0
  190. package/lib/app.api/events/app.api.events.js +3 -0
  191. package/lib/app.api/events/app.api.events.js.map +1 -0
  192. package/lib/app.api/feeds/app.api.feeds.d.ts +139 -0
  193. package/lib/app.api/feeds/app.api.feeds.d.ts.map +1 -0
  194. package/lib/app.api/feeds/app.api.feeds.js +26 -0
  195. package/lib/app.api/feeds/app.api.feeds.js.map +1 -0
  196. package/lib/app.api/icons/app.api.icons.d.ts +60 -0
  197. package/lib/app.api/icons/app.api.icons.d.ts.map +1 -0
  198. package/lib/app.api/icons/app.api.icons.js +29 -0
  199. package/lib/app.api/icons/app.api.icons.js.map +1 -0
  200. package/lib/app.api/observations/app.api.observations.d.ts +126 -0
  201. package/lib/app.api/observations/app.api.observations.d.ts.map +1 -0
  202. package/lib/app.api/observations/app.api.observations.js +61 -0
  203. package/lib/app.api/observations/app.api.observations.js.map +1 -0
  204. package/lib/app.api/users/app.api.users.d.ts +24 -0
  205. package/lib/app.api/users/app.api.users.d.ts.map +1 -0
  206. package/lib/app.api/users/app.api.users.js +3 -0
  207. package/lib/app.api/users/app.api.users.js.map +1 -0
  208. package/lib/app.d.ts +38 -0
  209. package/lib/app.d.ts.map +1 -0
  210. package/lib/app.impl/events/app.impl.events.d.ts +8 -0
  211. package/lib/app.impl/events/app.impl.events.d.ts.map +1 -0
  212. package/lib/app.impl/events/app.impl.events.js +107 -0
  213. package/lib/app.impl/events/app.impl.events.js.map +1 -0
  214. package/lib/app.impl/feeds/app.impl.feeds.d.ts +21 -0
  215. package/lib/app.impl/feeds/app.impl.feeds.d.ts.map +1 -0
  216. package/lib/app.impl/feeds/app.impl.feeds.js +527 -0
  217. package/lib/app.impl/feeds/app.impl.feeds.js.map +1 -0
  218. package/lib/app.impl/icons/app.impl.icons.d.ts +7 -0
  219. package/lib/app.impl/icons/app.impl.icons.d.ts.map +1 -0
  220. package/lib/app.impl/icons/app.impl.icons.js +81 -0
  221. package/lib/app.impl/icons/app.impl.icons.js.map +1 -0
  222. package/lib/app.impl/observations/app.impl.observations.d.ts +11 -0
  223. package/lib/app.impl/observations/app.impl.observations.d.ts.map +1 -0
  224. package/lib/app.impl/observations/app.impl.observations.js +357 -0
  225. package/lib/app.impl/observations/app.impl.observations.js.map +1 -0
  226. package/lib/app.impl/users/app.impl.users.d.ts +4 -0
  227. package/lib/app.impl/users/app.impl.users.d.ts.map +1 -0
  228. package/lib/app.impl/users/app.impl.users.js +37 -0
  229. package/lib/app.impl/users/app.impl.users.js.map +1 -0
  230. package/lib/app.js +507 -0
  231. package/lib/app.js.map +1 -0
  232. package/lib/assets/default-icon.png +0 -0
  233. package/lib/authentication/anonymous.d.ts +6 -0
  234. package/lib/authentication/anonymous.d.ts.map +1 -0
  235. package/lib/authentication/anonymous.js +17 -0
  236. package/lib/authentication/anonymous.js.map +1 -0
  237. package/lib/authentication/index.d.ts +24 -0
  238. package/lib/authentication/index.d.ts.map +1 -0
  239. package/lib/authentication/index.js +104 -0
  240. package/lib/authentication/index.js.map +1 -0
  241. package/lib/authentication/ldap.d.ts +2 -0
  242. package/lib/authentication/ldap.d.ts.map +1 -0
  243. package/lib/authentication/ldap.js +130 -0
  244. package/lib/authentication/ldap.js.map +1 -0
  245. package/lib/authentication/local.d.ts +2 -0
  246. package/lib/authentication/local.d.ts.map +1 -0
  247. package/lib/authentication/local.js +77 -0
  248. package/lib/authentication/local.js.map +1 -0
  249. package/lib/authentication/oauth.d.ts +2 -0
  250. package/lib/authentication/oauth.d.ts.map +1 -0
  251. package/lib/authentication/oauth.js +197 -0
  252. package/lib/authentication/oauth.js.map +1 -0
  253. package/lib/authentication/openidconnect.d.ts +2 -0
  254. package/lib/authentication/openidconnect.d.ts.map +1 -0
  255. package/lib/authentication/openidconnect.js +148 -0
  256. package/lib/authentication/openidconnect.js.map +1 -0
  257. package/lib/authentication/saml.d.ts +2 -0
  258. package/lib/authentication/saml.d.ts.map +1 -0
  259. package/lib/authentication/saml.js +287 -0
  260. package/lib/authentication/saml.js.map +1 -0
  261. package/lib/authentication/verification.d.ts +33 -0
  262. package/lib/authentication/verification.d.ts.map +1 -0
  263. package/lib/authentication/verification.js +144 -0
  264. package/lib/authentication/verification.js.map +1 -0
  265. package/lib/config.d.ts +15 -0
  266. package/lib/config.d.ts.map +1 -0
  267. package/lib/config.js +20 -0
  268. package/lib/config.js.map +1 -0
  269. package/lib/dist-package.json +203 -0
  270. package/lib/docs/auth/local.yaml +90 -0
  271. package/lib/docs/geojson.yaml +375 -0
  272. package/lib/docs/openapi.yaml +4591 -0
  273. package/lib/entities/authentication/entities.authentication.d.ts +14 -0
  274. package/lib/entities/authentication/entities.authentication.d.ts.map +1 -0
  275. package/lib/entities/authentication/entities.authentication.js +3 -0
  276. package/lib/entities/authentication/entities.authentication.js.map +1 -0
  277. package/lib/entities/authorization/entities.authorization.d.ts +7 -0
  278. package/lib/entities/authorization/entities.authorization.d.ts.map +1 -0
  279. package/lib/entities/authorization/entities.authorization.js +3 -0
  280. package/lib/entities/authorization/entities.authorization.js.map +1 -0
  281. package/lib/entities/authorization/entities.permissions.d.ts +143 -0
  282. package/lib/entities/authorization/entities.permissions.d.ts.map +1 -0
  283. package/lib/entities/authorization/entities.permissions.js +101 -0
  284. package/lib/entities/authorization/entities.permissions.js.map +1 -0
  285. package/lib/entities/entities.domain_events.d.ts +1 -0
  286. package/lib/entities/entities.domain_events.d.ts.map +1 -0
  287. package/lib/entities/entities.domain_events.js +20 -0
  288. package/lib/entities/entities.domain_events.js.map +1 -0
  289. package/lib/entities/entities.global.d.ts +107 -0
  290. package/lib/entities/entities.global.d.ts.map +1 -0
  291. package/lib/entities/entities.global.js +67 -0
  292. package/lib/entities/entities.global.js.map +1 -0
  293. package/lib/entities/entities.i18n.d.ts +78 -0
  294. package/lib/entities/entities.i18n.d.ts.map +1 -0
  295. package/lib/entities/entities.i18n.js +69 -0
  296. package/lib/entities/entities.i18n.js.map +1 -0
  297. package/lib/entities/entities.json_types.d.ts +42 -0
  298. package/lib/entities/entities.json_types.d.ts.map +1 -0
  299. package/lib/entities/entities.json_types.js +3 -0
  300. package/lib/entities/entities.json_types.js.map +1 -0
  301. package/lib/entities/events/entities.events.d.ts +118 -0
  302. package/lib/entities/events/entities.events.d.ts.map +1 -0
  303. package/lib/entities/events/entities.events.forms.d.ts +132 -0
  304. package/lib/entities/events/entities.events.forms.d.ts.map +1 -0
  305. package/lib/entities/events/entities.events.forms.js +102 -0
  306. package/lib/entities/events/entities.events.forms.js.map +1 -0
  307. package/lib/entities/events/entities.events.js +146 -0
  308. package/lib/entities/events/entities.events.js.map +1 -0
  309. package/lib/entities/feeds/entities.feeds.d.ts +340 -0
  310. package/lib/entities/feeds/entities.feeds.d.ts.map +1 -0
  311. package/lib/entities/feeds/entities.feeds.js +213 -0
  312. package/lib/entities/feeds/entities.feeds.js.map +1 -0
  313. package/lib/entities/icons/entities.icons.d.ts +106 -0
  314. package/lib/entities/icons/entities.icons.d.ts.map +1 -0
  315. package/lib/entities/icons/entities.icons.js +26 -0
  316. package/lib/entities/icons/entities.icons.js.map +1 -0
  317. package/lib/entities/observations/entities.observations.d.ts +569 -0
  318. package/lib/entities/observations/entities.observations.d.ts.map +1 -0
  319. package/lib/entities/observations/entities.observations.fields.attachment.d.ts +5 -0
  320. package/lib/entities/observations/entities.observations.fields.attachment.d.ts.map +1 -0
  321. package/lib/entities/observations/entities.observations.fields.attachment.js +24 -0
  322. package/lib/entities/observations/entities.observations.fields.attachment.js.map +1 -0
  323. package/lib/entities/observations/entities.observations.fields.checkbox.d.ts +3 -0
  324. package/lib/entities/observations/entities.observations.fields.checkbox.d.ts.map +1 -0
  325. package/lib/entities/observations/entities.observations.fields.checkbox.js +17 -0
  326. package/lib/entities/observations/entities.observations.fields.checkbox.js.map +1 -0
  327. package/lib/entities/observations/entities.observations.fields.d.ts +20 -0
  328. package/lib/entities/observations/entities.observations.fields.d.ts.map +1 -0
  329. package/lib/entities/observations/entities.observations.fields.date.d.ts +3 -0
  330. package/lib/entities/observations/entities.observations.fields.date.d.ts.map +1 -0
  331. package/lib/entities/observations/entities.observations.fields.date.js +21 -0
  332. package/lib/entities/observations/entities.observations.fields.date.js.map +1 -0
  333. package/lib/entities/observations/entities.observations.fields.email.d.ts +3 -0
  334. package/lib/entities/observations/entities.observations.fields.email.d.ts.map +1 -0
  335. package/lib/entities/observations/entities.observations.fields.email.js +20 -0
  336. package/lib/entities/observations/entities.observations.fields.email.js.map +1 -0
  337. package/lib/entities/observations/entities.observations.fields.geometry.d.ts +3 -0
  338. package/lib/entities/observations/entities.observations.fields.geometry.d.ts.map +1 -0
  339. package/lib/entities/observations/entities.observations.fields.geometry.js +62 -0
  340. package/lib/entities/observations/entities.observations.fields.geometry.js.map +1 -0
  341. package/lib/entities/observations/entities.observations.fields.js +37 -0
  342. package/lib/entities/observations/entities.observations.fields.js.map +1 -0
  343. package/lib/entities/observations/entities.observations.fields.multiselect.d.ts +3 -0
  344. package/lib/entities/observations/entities.observations.fields.multiselect.d.ts.map +1 -0
  345. package/lib/entities/observations/entities.observations.fields.multiselect.js +24 -0
  346. package/lib/entities/observations/entities.observations.fields.multiselect.js.map +1 -0
  347. package/lib/entities/observations/entities.observations.fields.numeric.d.ts +3 -0
  348. package/lib/entities/observations/entities.observations.fields.numeric.d.ts.map +1 -0
  349. package/lib/entities/observations/entities.observations.fields.numeric.js +24 -0
  350. package/lib/entities/observations/entities.observations.fields.numeric.js.map +1 -0
  351. package/lib/entities/observations/entities.observations.fields.required.d.ts +3 -0
  352. package/lib/entities/observations/entities.observations.fields.required.d.ts.map +1 -0
  353. package/lib/entities/observations/entities.observations.fields.required.js +14 -0
  354. package/lib/entities/observations/entities.observations.fields.required.js.map +1 -0
  355. package/lib/entities/observations/entities.observations.fields.select.d.ts +3 -0
  356. package/lib/entities/observations/entities.observations.fields.select.d.ts.map +1 -0
  357. package/lib/entities/observations/entities.observations.fields.select.js +17 -0
  358. package/lib/entities/observations/entities.observations.fields.select.js.map +1 -0
  359. package/lib/entities/observations/entities.observations.fields.text.d.ts +3 -0
  360. package/lib/entities/observations/entities.observations.fields.text.d.ts.map +1 -0
  361. package/lib/entities/observations/entities.observations.fields.text.js +15 -0
  362. package/lib/entities/observations/entities.observations.fields.text.js.map +1 -0
  363. package/lib/entities/observations/entities.observations.js +873 -0
  364. package/lib/entities/observations/entities.observations.js.map +1 -0
  365. package/lib/entities/ogcapi-features/entities.ogcapi-features.d.ts +98 -0
  366. package/lib/entities/ogcapi-features/entities.ogcapi-features.d.ts.map +1 -0
  367. package/lib/entities/ogcapi-features/entities.ogcapi-features.js +30 -0
  368. package/lib/entities/ogcapi-features/entities.ogcapi-features.js.map +1 -0
  369. package/lib/entities/teams/entities.teams.d.ts +26 -0
  370. package/lib/entities/teams/entities.teams.d.ts.map +1 -0
  371. package/lib/entities/teams/entities.teams.js +3 -0
  372. package/lib/entities/teams/entities.teams.js.map +1 -0
  373. package/lib/entities/users/entities.users.d.ts +66 -0
  374. package/lib/entities/users/entities.users.d.ts.map +1 -0
  375. package/lib/entities/users/entities.users.js +10 -0
  376. package/lib/entities/users/entities.users.js.map +1 -0
  377. package/lib/environment/env.d.ts +29 -0
  378. package/lib/environment/env.d.ts.map +1 -0
  379. package/lib/environment/env.js +106 -0
  380. package/lib/environment/env.js.map +1 -0
  381. package/lib/export/csv.d.ts +11 -0
  382. package/lib/export/csv.d.ts.map +1 -0
  383. package/lib/export/csv.js +243 -0
  384. package/lib/export/csv.js.map +1 -0
  385. package/lib/export/exporter.d.ts +12 -0
  386. package/lib/export/exporter.d.ts.map +1 -0
  387. package/lib/export/exporter.js +38 -0
  388. package/lib/export/exporter.js.map +1 -0
  389. package/lib/export/exporterFactory.d.ts +11 -0
  390. package/lib/export/exporterFactory.d.ts.map +1 -0
  391. package/lib/export/exporterFactory.js +17 -0
  392. package/lib/export/exporterFactory.js.map +1 -0
  393. package/lib/export/geojson.d.ts +10 -0
  394. package/lib/export/geojson.d.ts.map +1 -0
  395. package/lib/export/geojson.js +167 -0
  396. package/lib/export/geojson.js.map +1 -0
  397. package/lib/export/geopackage.d.ts +25 -0
  398. package/lib/export/geopackage.d.ts.map +1 -0
  399. package/lib/export/geopackage.js +687 -0
  400. package/lib/export/geopackage.js.map +1 -0
  401. package/lib/export/kml.d.ts +10 -0
  402. package/lib/export/kml.d.ts.map +1 -0
  403. package/lib/export/kml.js +128 -0
  404. package/lib/export/kml.js.map +1 -0
  405. package/lib/export/kmlWriter.d.ts +24 -0
  406. package/lib/export/kmlWriter.d.ts.map +1 -0
  407. package/lib/export/kmlWriter.js +431 -0
  408. package/lib/export/kmlWriter.js.map +1 -0
  409. package/lib/express.d.ts +9 -0
  410. package/lib/express.d.ts.map +1 -0
  411. package/lib/express.js +70 -0
  412. package/lib/express.js.map +1 -0
  413. package/lib/format/geoJsonFormat.d.ts +3 -0
  414. package/lib/format/geoJsonFormat.d.ts.map +1 -0
  415. package/lib/format/geoJsonFormat.js +65 -0
  416. package/lib/format/geoJsonFormat.js.map +1 -0
  417. package/lib/logger.d.ts +2 -0
  418. package/lib/logger.d.ts.map +1 -0
  419. package/lib/logger.js +21 -0
  420. package/lib/logger.js.map +1 -0
  421. package/lib/main.impl/main.impl.plugins.d.ts +12 -0
  422. package/lib/main.impl/main.impl.plugins.d.ts.map +1 -0
  423. package/lib/main.impl/main.impl.plugins.js +41 -0
  424. package/lib/main.impl/main.impl.plugins.js.map +1 -0
  425. package/lib/main.impl/plugin_hooks/main.impl.plugin_hooks.events.d.ts +3 -0
  426. package/lib/main.impl/plugin_hooks/main.impl.plugin_hooks.events.d.ts.map +1 -0
  427. package/lib/main.impl/plugin_hooks/main.impl.plugin_hooks.events.js +32 -0
  428. package/lib/main.impl/plugin_hooks/main.impl.plugin_hooks.events.js.map +1 -0
  429. package/lib/main.impl/plugin_hooks/main.impl.plugin_hooks.feeds.d.ts +4 -0
  430. package/lib/main.impl/plugin_hooks/main.impl.plugin_hooks.feeds.d.ts.map +1 -0
  431. package/lib/main.impl/plugin_hooks/main.impl.plugin_hooks.feeds.js +26 -0
  432. package/lib/main.impl/plugin_hooks/main.impl.plugin_hooks.feeds.js.map +1 -0
  433. package/lib/main.impl/plugin_hooks/main.impl.plugin_hooks.icons.d.ts +4 -0
  434. package/lib/main.impl/plugin_hooks/main.impl.plugin_hooks.icons.d.ts.map +1 -0
  435. package/lib/main.impl/plugin_hooks/main.impl.plugin_hooks.icons.js +41 -0
  436. package/lib/main.impl/plugin_hooks/main.impl.plugin_hooks.icons.js.map +1 -0
  437. package/lib/migrate.d.ts +4 -0
  438. package/lib/migrate.d.ts.map +1 -0
  439. package/lib/migrate.js +96 -0
  440. package/lib/migrate.js.map +1 -0
  441. package/lib/migrations/002-create-user-role.d.ts +4 -0
  442. package/lib/migrations/002-create-user-role.d.ts.map +1 -0
  443. package/lib/migrations/002-create-user-role.js +30 -0
  444. package/lib/migrations/002-create-user-role.js.map +1 -0
  445. package/lib/migrations/003-create-admin-role.d.ts +4 -0
  446. package/lib/migrations/003-create-admin-role.d.ts.map +1 -0
  447. package/lib/migrations/003-create-admin-role.js +31 -0
  448. package/lib/migrations/003-create-admin-role.js.map +1 -0
  449. package/lib/migrations/005-create-osm-layer.d.ts +4 -0
  450. package/lib/migrations/005-create-osm-layer.d.ts.map +1 -0
  451. package/lib/migrations/005-create-osm-layer.js +51 -0
  452. package/lib/migrations/005-create-osm-layer.js.map +1 -0
  453. package/lib/migrations/006-event-teams.d.ts +4 -0
  454. package/lib/migrations/006-event-teams.d.ts.map +1 -0
  455. package/lib/migrations/006-event-teams.js +40 -0
  456. package/lib/migrations/006-event-teams.js.map +1 -0
  457. package/lib/migrations/007-user-icon.d.ts +4 -0
  458. package/lib/migrations/007-user-icon.d.ts.map +1 -0
  459. package/lib/migrations/007-user-icon.js +21 -0
  460. package/lib/migrations/007-user-icon.js.map +1 -0
  461. package/lib/migrations/008-create-user-no-edit-role.d.ts +4 -0
  462. package/lib/migrations/008-create-user-no-edit-role.d.ts.map +1 -0
  463. package/lib/migrations/008-create-user-no-edit-role.js +34 -0
  464. package/lib/migrations/008-create-user-no-edit-role.js.map +1 -0
  465. package/lib/migrations/009-create-manager-role.d.ts +4 -0
  466. package/lib/migrations/009-create-manager-role.d.ts.map +1 -0
  467. package/lib/migrations/009-create-manager-role.js +50 -0
  468. package/lib/migrations/009-create-manager-role.js.map +1 -0
  469. package/lib/migrations/010-add-user-device-manager-role.d.ts +4 -0
  470. package/lib/migrations/010-add-user-device-manager-role.d.ts.map +1 -0
  471. package/lib/migrations/010-add-user-device-manager-role.js +38 -0
  472. package/lib/migrations/010-add-user-device-manager-role.js.map +1 -0
  473. package/lib/migrations/011-multiple-forms.d.ts +4 -0
  474. package/lib/migrations/011-multiple-forms.d.ts.map +1 -0
  475. package/lib/migrations/011-multiple-forms.js +161 -0
  476. package/lib/migrations/011-multiple-forms.js.map +1 -0
  477. package/lib/migrations/012-user-role-remove-delete.d.ts +4 -0
  478. package/lib/migrations/012-user-role-remove-delete.d.ts.map +1 -0
  479. package/lib/migrations/012-user-role-remove-delete.js +15 -0
  480. package/lib/migrations/012-user-role-remove-delete.js.map +1 -0
  481. package/lib/migrations/013-ensure-event-indexes.d.ts +4 -0
  482. package/lib/migrations/013-ensure-event-indexes.d.ts.map +1 -0
  483. package/lib/migrations/013-ensure-event-indexes.js +50 -0
  484. package/lib/migrations/013-ensure-event-indexes.js.map +1 -0
  485. package/lib/migrations/014-add-role-update-permission.d.ts +4 -0
  486. package/lib/migrations/014-add-role-update-permission.d.ts.map +1 -0
  487. package/lib/migrations/014-add-role-update-permission.js +15 -0
  488. package/lib/migrations/014-add-role-update-permission.js.map +1 -0
  489. package/lib/migrations/015-manager-role-add-user-create.d.ts +4 -0
  490. package/lib/migrations/015-manager-role-add-user-create.d.ts.map +1 -0
  491. package/lib/migrations/015-manager-role-add-user-create.js +15 -0
  492. package/lib/migrations/015-manager-role-add-user-create.js.map +1 -0
  493. package/lib/migrations/016-set-feed-primary-secondary.d.ts +4 -0
  494. package/lib/migrations/016-set-feed-primary-secondary.d.ts.map +1 -0
  495. package/lib/migrations/016-set-feed-primary-secondary.js +36 -0
  496. package/lib/migrations/016-set-feed-primary-secondary.js.map +1 -0
  497. package/lib/migrations/017-make-layers-available.d.ts +4 -0
  498. package/lib/migrations/017-make-layers-available.d.ts.map +1 -0
  499. package/lib/migrations/017-make-layers-available.js +48 -0
  500. package/lib/migrations/017-make-layers-available.js.map +1 -0
  501. package/lib/migrations/018-feeds-admin-permissions.d.ts +4 -0
  502. package/lib/migrations/018-feeds-admin-permissions.d.ts.map +1 -0
  503. package/lib/migrations/018-feeds-admin-permissions.js +32 -0
  504. package/lib/migrations/018-feeds-admin-permissions.js.map +1 -0
  505. package/lib/migrations/018-set-default-password-policy.d.ts +4 -0
  506. package/lib/migrations/018-set-default-password-policy.d.ts.map +1 -0
  507. package/lib/migrations/018-set-default-password-policy.js +58 -0
  508. package/lib/migrations/018-set-default-password-policy.js.map +1 -0
  509. package/lib/migrations/019-move-user-authentication.d.ts +4 -0
  510. package/lib/migrations/019-move-user-authentication.d.ts.map +1 -0
  511. package/lib/migrations/019-move-user-authentication.js +68 -0
  512. package/lib/migrations/019-move-user-authentication.js.map +1 -0
  513. package/lib/migrations/020-add-export-permissions.d.ts +4 -0
  514. package/lib/migrations/020-add-export-permissions.d.ts.map +1 -0
  515. package/lib/migrations/020-add-export-permissions.js +36 -0
  516. package/lib/migrations/020-add-export-permissions.js.map +1 -0
  517. package/lib/migrations/022-copy-auth-from-config-to-db.d.ts +4 -0
  518. package/lib/migrations/022-copy-auth-from-config-to-db.d.ts.map +1 -0
  519. package/lib/migrations/022-copy-auth-from-config-to-db.js +86 -0
  520. package/lib/migrations/022-copy-auth-from-config-to-db.js.map +1 -0
  521. package/lib/migrations/023-move-local-auth-from-settings.d.ts +4 -0
  522. package/lib/migrations/023-move-local-auth-from-settings.d.ts.map +1 -0
  523. package/lib/migrations/023-move-local-auth-from-settings.js +54 -0
  524. package/lib/migrations/023-move-local-auth-from-settings.js.map +1 -0
  525. package/lib/migrations/024-link-auth-to-auth-config.d.ts +4 -0
  526. package/lib/migrations/024-link-auth-to-auth-config.d.ts.map +1 -0
  527. package/lib/migrations/024-link-auth-to-auth-config.js +59 -0
  528. package/lib/migrations/024-link-auth-to-auth-config.js.map +1 -0
  529. package/lib/migrations/025-add-auth-config-permissions.d.ts +4 -0
  530. package/lib/migrations/025-add-auth-config-permissions.d.ts.map +1 -0
  531. package/lib/migrations/025-add-auth-config-permissions.js +32 -0
  532. package/lib/migrations/025-add-auth-config-permissions.js.map +1 -0
  533. package/lib/migrations/028-move-security-settings-to-secret-store.d.ts +4 -0
  534. package/lib/migrations/028-move-security-settings-to-secret-store.d.ts.map +1 -0
  535. package/lib/migrations/028-move-security-settings-to-secret-store.js +59 -0
  536. package/lib/migrations/028-move-security-settings-to-secret-store.js.map +1 -0
  537. package/lib/migrations/029-attachment-form-field.d.ts +4 -0
  538. package/lib/migrations/029-attachment-form-field.d.ts.map +1 -0
  539. package/lib/migrations/029-attachment-form-field.js +130 -0
  540. package/lib/migrations/029-attachment-form-field.js.map +1 -0
  541. package/lib/models/authentication.d.ts +17 -0
  542. package/lib/models/authentication.d.ts.map +1 -0
  543. package/lib/models/authentication.js +174 -0
  544. package/lib/models/authentication.js.map +1 -0
  545. package/lib/models/authenticationconfiguration.d.ts +15 -0
  546. package/lib/models/authenticationconfiguration.d.ts.map +1 -0
  547. package/lib/models/authenticationconfiguration.js +105 -0
  548. package/lib/models/authenticationconfiguration.js.map +1 -0
  549. package/lib/models/cappedLocation.d.ts +8 -0
  550. package/lib/models/cappedLocation.d.ts.map +1 -0
  551. package/lib/models/cappedLocation.js +78 -0
  552. package/lib/models/cappedLocation.js.map +1 -0
  553. package/lib/models/counter.d.ts +3 -0
  554. package/lib/models/counter.d.ts.map +1 -0
  555. package/lib/models/counter.js +37 -0
  556. package/lib/models/counter.js.map +1 -0
  557. package/lib/models/device.d.ts +14 -0
  558. package/lib/models/device.d.ts.map +1 -0
  559. package/lib/models/device.js +220 -0
  560. package/lib/models/device.js.map +1 -0
  561. package/lib/models/event.d.ts +75 -0
  562. package/lib/models/event.d.ts.map +1 -0
  563. package/lib/models/event.js +839 -0
  564. package/lib/models/event.js.map +1 -0
  565. package/lib/models/export.d.ts +18 -0
  566. package/lib/models/export.d.ts.map +1 -0
  567. package/lib/models/export.js +107 -0
  568. package/lib/models/export.js.map +1 -0
  569. package/lib/models/feature.d.ts +4 -0
  570. package/lib/models/feature.d.ts.map +1 -0
  571. package/lib/models/feature.js +43 -0
  572. package/lib/models/feature.js.map +1 -0
  573. package/lib/models/icon.d.ts +9 -0
  574. package/lib/models/icon.d.ts.map +1 -0
  575. package/lib/models/icon.js +69 -0
  576. package/lib/models/icon.js.map +1 -0
  577. package/lib/models/index.d.ts +2 -0
  578. package/lib/models/index.d.ts.map +1 -0
  579. package/lib/models/index.js +12 -0
  580. package/lib/models/index.js.map +1 -0
  581. package/lib/models/layer.d.ts +13 -0
  582. package/lib/models/layer.d.ts.map +1 -0
  583. package/lib/models/layer.js +149 -0
  584. package/lib/models/layer.js.map +1 -0
  585. package/lib/models/location.d.ts +8 -0
  586. package/lib/models/location.d.ts.map +1 -0
  587. package/lib/models/location.js +96 -0
  588. package/lib/models/location.js.map +1 -0
  589. package/lib/models/login.d.ts +4 -0
  590. package/lib/models/login.d.ts.map +1 -0
  591. package/lib/models/login.js +90 -0
  592. package/lib/models/login.js.map +1 -0
  593. package/lib/models/observation.d.ts +93 -0
  594. package/lib/models/observation.d.ts.map +1 -0
  595. package/lib/models/observation.js +461 -0
  596. package/lib/models/observation.js.map +1 -0
  597. package/lib/models/role.d.ts +22 -0
  598. package/lib/models/role.d.ts.map +1 -0
  599. package/lib/models/role.js +80 -0
  600. package/lib/models/role.js.map +1 -0
  601. package/lib/models/setting.d.ts +6 -0
  602. package/lib/models/setting.d.ts.map +1 -0
  603. package/lib/models/setting.js +31 -0
  604. package/lib/models/setting.js.map +1 -0
  605. package/lib/models/team.d.ts +31 -0
  606. package/lib/models/team.d.ts.map +1 -0
  607. package/lib/models/team.js +511 -0
  608. package/lib/models/team.js.map +1 -0
  609. package/lib/models/token.d.ts +6 -0
  610. package/lib/models/token.d.ts.map +1 -0
  611. package/lib/models/token.js +68 -0
  612. package/lib/models/token.js.map +1 -0
  613. package/lib/models/user.d.ts +60 -0
  614. package/lib/models/user.d.ts.map +1 -0
  615. package/lib/models/user.js +400 -0
  616. package/lib/models/user.js.map +1 -0
  617. package/lib/permissions/permissions.events.d.ts +69 -0
  618. package/lib/permissions/permissions.events.d.ts.map +1 -0
  619. package/lib/permissions/permissions.events.js +154 -0
  620. package/lib/permissions/permissions.events.js.map +1 -0
  621. package/lib/permissions/permissions.feeds.d.ts +19 -0
  622. package/lib/permissions/permissions.feeds.d.ts.map +1 -0
  623. package/lib/permissions/permissions.feeds.js +58 -0
  624. package/lib/permissions/permissions.feeds.js.map +1 -0
  625. package/lib/permissions/permissions.icons.d.ts +9 -0
  626. package/lib/permissions/permissions.icons.d.ts.map +1 -0
  627. package/lib/permissions/permissions.icons.js +28 -0
  628. package/lib/permissions/permissions.icons.js.map +1 -0
  629. package/lib/permissions/permissions.observations.d.ts +14 -0
  630. package/lib/permissions/permissions.observations.d.ts.map +1 -0
  631. package/lib/permissions/permissions.observations.js +113 -0
  632. package/lib/permissions/permissions.observations.js.map +1 -0
  633. package/lib/permissions/permissions.role-based.base.d.ts +15 -0
  634. package/lib/permissions/permissions.role-based.base.d.ts.map +1 -0
  635. package/lib/permissions/permissions.role-based.base.js +14 -0
  636. package/lib/permissions/permissions.role-based.base.js.map +1 -0
  637. package/lib/permissions/permissions.users.d.ts +8 -0
  638. package/lib/permissions/permissions.users.d.ts.map +1 -0
  639. package/lib/permissions/permissions.users.js +23 -0
  640. package/lib/permissions/permissions.users.js.map +1 -0
  641. package/lib/plugins.api/index.d.ts +55 -0
  642. package/lib/plugins.api/index.d.ts.map +1 -0
  643. package/lib/plugins.api/index.js +5 -0
  644. package/lib/plugins.api/index.js.map +1 -0
  645. package/lib/plugins.api/plugins.api.db.d.ts +7 -0
  646. package/lib/plugins.api/plugins.api.db.d.ts.map +1 -0
  647. package/lib/plugins.api/plugins.api.db.js +5 -0
  648. package/lib/plugins.api/plugins.api.db.js.map +1 -0
  649. package/lib/plugins.api/plugins.api.events.d.ts +24 -0
  650. package/lib/plugins.api/plugins.api.events.d.ts.map +1 -0
  651. package/lib/plugins.api/plugins.api.events.js +5 -0
  652. package/lib/plugins.api/plugins.api.events.js.map +1 -0
  653. package/lib/plugins.api/plugins.api.feeds.d.ts +35 -0
  654. package/lib/plugins.api/plugins.api.feeds.d.ts.map +1 -0
  655. package/lib/plugins.api/plugins.api.feeds.js +12 -0
  656. package/lib/plugins.api/plugins.api.feeds.js.map +1 -0
  657. package/lib/plugins.api/plugins.api.icons.d.ts +21 -0
  658. package/lib/plugins.api/plugins.api.icons.d.ts.map +1 -0
  659. package/lib/plugins.api/plugins.api.icons.js +5 -0
  660. package/lib/plugins.api/plugins.api.icons.js.map +1 -0
  661. package/lib/plugins.api/plugins.api.observations.d.ts +10 -0
  662. package/lib/plugins.api/plugins.api.observations.d.ts.map +1 -0
  663. package/lib/plugins.api/plugins.api.observations.js +11 -0
  664. package/lib/plugins.api/plugins.api.observations.js.map +1 -0
  665. package/lib/plugins.api/plugins.api.users.d.ts +4 -0
  666. package/lib/plugins.api/plugins.api.users.d.ts.map +1 -0
  667. package/lib/plugins.api/plugins.api.users.js +5 -0
  668. package/lib/plugins.api/plugins.api.users.js.map +1 -0
  669. package/lib/plugins.api/plugins.api.web.d.ts +10 -0
  670. package/lib/plugins.api/plugins.api.web.d.ts.map +1 -0
  671. package/lib/plugins.api/plugins.api.web.js +3 -0
  672. package/lib/plugins.api/plugins.api.web.js.map +1 -0
  673. package/lib/provision/index.d.ts +23 -0
  674. package/lib/provision/index.d.ts.map +1 -0
  675. package/lib/provision/index.js +60 -0
  676. package/lib/provision/index.js.map +1 -0
  677. package/lib/provision/none.d.ts +3 -0
  678. package/lib/provision/none.d.ts.map +1 -0
  679. package/lib/provision/none.js +41 -0
  680. package/lib/provision/none.js.map +1 -0
  681. package/lib/provision/strategies/none.d.ts +9 -0
  682. package/lib/provision/strategies/none.d.ts.map +1 -0
  683. package/lib/provision/strategies/none.js +25 -0
  684. package/lib/provision/strategies/none.js.map +1 -0
  685. package/lib/provision/strategies/uid.d.ts +9 -0
  686. package/lib/provision/strategies/uid.d.ts.map +1 -0
  687. package/lib/provision/strategies/uid.js +28 -0
  688. package/lib/provision/strategies/uid.js.map +1 -0
  689. package/lib/provision/uid.d.ts +3 -0
  690. package/lib/provision/uid.d.ts.map +1 -0
  691. package/lib/provision/uid.js +43 -0
  692. package/lib/provision/uid.js.map +1 -0
  693. package/lib/routes/authenticationconfigurations.d.ts +3 -0
  694. package/lib/routes/authenticationconfigurations.d.ts.map +1 -0
  695. package/lib/routes/authenticationconfigurations.js +209 -0
  696. package/lib/routes/authenticationconfigurations.js.map +1 -0
  697. package/lib/routes/devices.d.ts +3 -0
  698. package/lib/routes/devices.d.ts.map +1 -0
  699. package/lib/routes/devices.js +201 -0
  700. package/lib/routes/devices.js.map +1 -0
  701. package/lib/routes/events.d.ts +47 -0
  702. package/lib/routes/events.d.ts.map +1 -0
  703. package/lib/routes/events.js +495 -0
  704. package/lib/routes/events.js.map +1 -0
  705. package/lib/routes/exports.d.ts +3 -0
  706. package/lib/routes/exports.d.ts.map +1 -0
  707. package/lib/routes/exports.js +204 -0
  708. package/lib/routes/exports.js.map +1 -0
  709. package/lib/routes/imports.d.ts +3 -0
  710. package/lib/routes/imports.d.ts.map +1 -0
  711. package/lib/routes/imports.js +41 -0
  712. package/lib/routes/imports.js.map +1 -0
  713. package/lib/routes/index.d.ts +3 -0
  714. package/lib/routes/index.d.ts.map +1 -0
  715. package/lib/routes/index.js +151 -0
  716. package/lib/routes/index.js.map +1 -0
  717. package/lib/routes/layers.d.ts +3 -0
  718. package/lib/routes/layers.d.ts.map +1 -0
  719. package/lib/routes/layers.js +433 -0
  720. package/lib/routes/layers.js.map +1 -0
  721. package/lib/routes/locations.d.ts +3 -0
  722. package/lib/routes/locations.d.ts.map +1 -0
  723. package/lib/routes/locations.js +124 -0
  724. package/lib/routes/locations.js.map +1 -0
  725. package/lib/routes/logins.d.ts +3 -0
  726. package/lib/routes/logins.d.ts.map +1 -0
  727. package/lib/routes/logins.js +64 -0
  728. package/lib/routes/logins.js.map +1 -0
  729. package/lib/routes/observations.d.ts +3 -0
  730. package/lib/routes/observations.d.ts.map +1 -0
  731. package/lib/routes/observations.js +363 -0
  732. package/lib/routes/observations.js.map +1 -0
  733. package/lib/routes/plugins.d.ts +3 -0
  734. package/lib/routes/plugins.d.ts.map +1 -0
  735. package/lib/routes/plugins.js +29 -0
  736. package/lib/routes/plugins.js.map +1 -0
  737. package/lib/routes/roles.d.ts +3 -0
  738. package/lib/routes/roles.d.ts.map +1 -0
  739. package/lib/routes/roles.js +64 -0
  740. package/lib/routes/roles.js.map +1 -0
  741. package/lib/routes/settings.d.ts +3 -0
  742. package/lib/routes/settings.d.ts.map +1 -0
  743. package/lib/routes/settings.js +21 -0
  744. package/lib/routes/settings.js.map +1 -0
  745. package/lib/routes/setup.d.ts +3 -0
  746. package/lib/routes/setup.d.ts.map +1 -0
  747. package/lib/routes/setup.js +90 -0
  748. package/lib/routes/setup.js.map +1 -0
  749. package/lib/routes/teams.d.ts +3 -0
  750. package/lib/routes/teams.d.ts.map +1 -0
  751. package/lib/routes/teams.js +213 -0
  752. package/lib/routes/teams.js.map +1 -0
  753. package/lib/routes/users.d.ts +3 -0
  754. package/lib/routes/users.d.ts.map +1 -0
  755. package/lib/routes/users.js +478 -0
  756. package/lib/routes/users.js.map +1 -0
  757. package/lib/schedule/export/export-task.d.ts +14 -0
  758. package/lib/schedule/export/export-task.d.ts.map +1 -0
  759. package/lib/schedule/export/export-task.js +70 -0
  760. package/lib/schedule/export/export-task.js.map +1 -0
  761. package/lib/schedule/index.d.ts +2 -0
  762. package/lib/schedule/index.d.ts.map +1 -0
  763. package/lib/schedule/index.js +27 -0
  764. package/lib/schedule/index.js.map +1 -0
  765. package/lib/security/key-mgt/key-mgt-factory.d.ts +7 -0
  766. package/lib/security/key-mgt/key-mgt-factory.d.ts.map +1 -0
  767. package/lib/security/key-mgt/key-mgt-factory.js +10 -0
  768. package/lib/security/key-mgt/key-mgt-factory.js.map +1 -0
  769. package/lib/security/key-mgt/plaintext-key-manager.d.ts +42 -0
  770. package/lib/security/key-mgt/plaintext-key-manager.d.ts.map +1 -0
  771. package/lib/security/key-mgt/plaintext-key-manager.js +52 -0
  772. package/lib/security/key-mgt/plaintext-key-manager.js.map +1 -0
  773. package/lib/security/responses/data-response.d.ts +13 -0
  774. package/lib/security/responses/data-response.d.ts.map +1 -0
  775. package/lib/security/responses/data-response.js +25 -0
  776. package/lib/security/responses/data-response.js.map +1 -0
  777. package/lib/security/secret-store-service.d.ts +39 -0
  778. package/lib/security/secret-store-service.d.ts.map +1 -0
  779. package/lib/security/secret-store-service.js +94 -0
  780. package/lib/security/secret-store-service.js.map +1 -0
  781. package/lib/security/storage/file-system-secret-store.d.ts +17 -0
  782. package/lib/security/storage/file-system-secret-store.d.ts.map +1 -0
  783. package/lib/security/storage/file-system-secret-store.js +46 -0
  784. package/lib/security/storage/file-system-secret-store.js.map +1 -0
  785. package/lib/security/storage/json-provider.d.ts +6 -0
  786. package/lib/security/storage/json-provider.d.ts.map +1 -0
  787. package/lib/security/storage/json-provider.js +17 -0
  788. package/lib/security/storage/json-provider.js.map +1 -0
  789. package/lib/security/utilities/secure-property-appender.d.ts +8 -0
  790. package/lib/security/utilities/secure-property-appender.d.ts.map +1 -0
  791. package/lib/security/utilities/secure-property-appender.js +39 -0
  792. package/lib/security/utilities/secure-property-appender.js.map +1 -0
  793. package/lib/transformers/authenticationconfiguration.d.ts +2 -0
  794. package/lib/transformers/authenticationconfiguration.d.ts.map +1 -0
  795. package/lib/transformers/authenticationconfiguration.js +22 -0
  796. package/lib/transformers/authenticationconfiguration.js.map +1 -0
  797. package/lib/transformers/export.d.ts +2 -0
  798. package/lib/transformers/export.d.ts.map +1 -0
  799. package/lib/transformers/export.js +13 -0
  800. package/lib/transformers/export.js.map +1 -0
  801. package/lib/transformers/geojson.d.ts +2 -0
  802. package/lib/transformers/geojson.d.ts.map +1 -0
  803. package/lib/transformers/geojson.js +24 -0
  804. package/lib/transformers/geojson.js.map +1 -0
  805. package/lib/transformers/layer.d.ts +2 -0
  806. package/lib/transformers/layer.d.ts.map +1 -0
  807. package/lib/transformers/layer.js +13 -0
  808. package/lib/transformers/layer.js.map +1 -0
  809. package/lib/transformers/observation.d.ts +2 -0
  810. package/lib/transformers/observation.d.ts.map +1 -0
  811. package/lib/transformers/observation.js +13 -0
  812. package/lib/transformers/observation.js.map +1 -0
  813. package/lib/transformers/pageinfo.d.ts +2 -0
  814. package/lib/transformers/pageinfo.d.ts.map +1 -0
  815. package/lib/transformers/pageinfo.js +27 -0
  816. package/lib/transformers/pageinfo.js.map +1 -0
  817. package/lib/transformers/user.d.ts +2 -0
  818. package/lib/transformers/user.d.ts.map +1 -0
  819. package/lib/transformers/user.js +21 -0
  820. package/lib/transformers/user.js.map +1 -0
  821. package/lib/tsconfig.tsbuildinfo +1 -0
  822. package/lib/upload.d.ts +8 -0
  823. package/lib/upload.d.ts.map +1 -0
  824. package/lib/upload.js +30 -0
  825. package/lib/upload.js.map +1 -0
  826. package/lib/utilities/authenticationApiAppender.d.ts +10 -0
  827. package/lib/utilities/authenticationApiAppender.d.ts.map +1 -0
  828. package/lib/utilities/authenticationApiAppender.js +48 -0
  829. package/lib/utilities/authenticationApiAppender.js.map +1 -0
  830. package/lib/utilities/filterParser.d.ts +2 -0
  831. package/lib/utilities/filterParser.d.ts.map +1 -0
  832. package/lib/utilities/filterParser.js +87 -0
  833. package/lib/utilities/filterParser.js.map +1 -0
  834. package/lib/utilities/geopackage.d.ts +56 -0
  835. package/lib/utilities/geopackage.d.ts.map +1 -0
  836. package/lib/utilities/geopackage.js +335 -0
  837. package/lib/utilities/geopackage.js.map +1 -0
  838. package/lib/utilities/loader.d.ts +9 -0
  839. package/lib/utilities/loader.d.ts.map +1 -0
  840. package/lib/utilities/loader.js +25 -0
  841. package/lib/utilities/loader.js.map +1 -0
  842. package/lib/utilities/paging.d.ts +15 -0
  843. package/lib/utilities/paging.d.ts.map +1 -0
  844. package/lib/utilities/paging.js +56 -0
  845. package/lib/utilities/paging.js.map +1 -0
  846. package/lib/utilities/passwordValidator.d.ts +8 -0
  847. package/lib/utilities/passwordValidator.d.ts.map +1 -0
  848. package/lib/utilities/passwordValidator.js +175 -0
  849. package/lib/utilities/passwordValidator.js.map +1 -0
  850. package/lib/utilities/pbkdf2.d.ts +6 -0
  851. package/lib/utilities/pbkdf2.d.ts.map +1 -0
  852. package/lib/utilities/pbkdf2.js +79 -0
  853. package/lib/utilities/pbkdf2.js.map +1 -0
  854. package/lib/utilities/togeojson.d.ts +2 -0
  855. package/lib/utilities/togeojson.d.ts.map +1 -0
  856. package/lib/utilities/togeojson.js +308 -0
  857. package/lib/utilities/togeojson.js.map +1 -0
  858. package/lib/utilities/waitForMongooseConnection.d.ts +3 -0
  859. package/lib/utilities/waitForMongooseConnection.d.ts.map +1 -0
  860. package/lib/utilities/waitForMongooseConnection.js +34 -0
  861. package/lib/utilities/waitForMongooseConnection.js.map +1 -0
  862. package/lib/utilities/whitelist.d.ts +2 -0
  863. package/lib/utilities/whitelist.d.ts.map +1 -0
  864. package/lib/utilities/whitelist.js +18 -0
  865. package/lib/utilities/whitelist.js.map +1 -0
  866. package/lib/views/authentication.pug +10 -0
  867. package/lib/views/oauth.pug +12 -0
  868. package/lib/views/observation.pug +137 -0
  869. package/package.json +203 -0
@@ -0,0 +1,873 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
26
+ if (kind === "m") throw new TypeError("Private method is not writable");
27
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
28
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
29
+ return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
30
+ };
31
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
32
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
33
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
34
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
35
+ };
36
+ var _Observation_validation, _Observation_formEntriesById, _Observation_attachmentsById, _FormEntryValidationError_entryLevelErrors, _FormEntryValidationError_fieldErrors, _ObservationValidationContext_coreAttrsErrors, _ObservationValidationContext_formCountErrors, _ObservationValidationContext_formEntryErrors, _ObservationValidationContext_attachmentErrors, _ObservationValidationContext_totalFormCountError;
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.AttachmentStoreErrorCode = exports.AttachmentStoreError = exports.StagedAttachmentContent = exports.StagedAttachmentContentRef = exports.ObservationRepositoryErrorCode = exports.ObservationRepositoryError = exports.AttachmentNotFoundError = exports.AttachmentAddError = exports.thumbnailIndexForTargetDimension = exports.putAttachmentThumbnailForMinDimension = exports.removeAttachment = exports.patchAttachment = exports.addAttachment = exports.removeFormEntry = exports.attachmentsForField = exports.formEntryForId = exports.ObservationUpdateErrorReason = exports.ObservationUpdateError = exports.validationResultMessage = exports.AttachmentValidationError = exports.AttachmentValidationErrorReason = exports.FormFieldValidationError = exports.FieldConstraintKey = exports.FormEntryValidationErrorReason = exports.FormEntryValidationError = exports.FormCountError = exports.TotalFormCountError = exports.MaxFormsConstraint = exports.MinFormsConstraint = exports.validateObservation = exports.ObservationDomainEventType = exports.Observation = exports.copyImportantFlagAttrs = exports.copyObservationStateAttrs = exports.copyThumbnailAttrs = exports.copyAttachmentAttrs = exports.copyObservationAttrs = void 0;
39
+ const entities_global_1 = require("../entities.global");
40
+ const entities_events_forms_1 = require("../events/entities.events.forms");
41
+ const fields = __importStar(require("./entities.observations.fields"));
42
+ function copyObservationAttrs(from) {
43
+ return {
44
+ id: from.id,
45
+ eventId: from.eventId,
46
+ userId: from.userId,
47
+ deviceId: from.deviceId,
48
+ createdAt: new Date(from.createdAt.getTime()),
49
+ lastModified: new Date(from.lastModified.getTime()),
50
+ attachments: from.attachments.map(copyAttachmentAttrs),
51
+ important: from.important ? copyImportantFlagAttrs(from.important) : undefined,
52
+ favoriteUserIds: Object.freeze([...from.favoriteUserIds]),
53
+ states: Object.freeze(from.states.map(copyObservationStateAttrs)),
54
+ type: 'Feature',
55
+ // meh, these shallow copies are probably fine ... right?
56
+ geometry: Object.freeze(Object.assign({}, from.geometry)),
57
+ properties: Object.assign(Object.assign({}, from.properties), { forms: from.properties.forms.map(x => (Object.assign({}, x))), timestamp: new Date(from.properties.timestamp) })
58
+ };
59
+ }
60
+ exports.copyObservationAttrs = copyObservationAttrs;
61
+ function copyAttachmentAttrs(from) {
62
+ return {
63
+ id: from.id,
64
+ fieldName: from.fieldName,
65
+ observationFormId: from.observationFormId,
66
+ lastModified: from.lastModified ? new Date(from.lastModified) : undefined,
67
+ contentType: from.contentType,
68
+ name: from.name,
69
+ size: from.size,
70
+ width: from.width,
71
+ height: from.height,
72
+ oriented: from.oriented,
73
+ thumbnails: from.thumbnails.map(copyThumbnailAttrs),
74
+ contentLocator: from.contentLocator
75
+ };
76
+ }
77
+ exports.copyAttachmentAttrs = copyAttachmentAttrs;
78
+ function copyThumbnailAttrs(from) {
79
+ return {
80
+ minDimension: from.minDimension,
81
+ contentLocator: from.contentLocator,
82
+ contentType: from.contentType,
83
+ name: from.name,
84
+ size: from.size,
85
+ width: from.width,
86
+ height: from.height
87
+ };
88
+ }
89
+ exports.copyThumbnailAttrs = copyThumbnailAttrs;
90
+ function copyObservationStateAttrs(from) {
91
+ return {
92
+ id: from.id,
93
+ name: from.name,
94
+ userId: from.userId
95
+ };
96
+ }
97
+ exports.copyObservationStateAttrs = copyObservationStateAttrs;
98
+ function copyImportantFlagAttrs(from) {
99
+ return {
100
+ userId: from.userId,
101
+ description: from.description,
102
+ timestamp: from.timestamp ? new Date(from.timestamp.getTime()) : undefined
103
+ };
104
+ }
105
+ exports.copyImportantFlagAttrs = copyImportantFlagAttrs;
106
+ /**
107
+ * The intention of this class is to provide a mutation model for observation
108
+ * updates. While `ObservationAttrs` is more just raw the keys and values of
109
+ * observations, this class retains some extra context for validation so
110
+ * the client can make changes to the observation data while receiving
111
+ * validation feedback for every operation performed on the observation.
112
+ * TODO: add domain event tracking to this class
113
+ */
114
+ class Observation {
115
+ constructor(...args) {
116
+ _Observation_validation.set(this, void 0);
117
+ _Observation_formEntriesById.set(this, void 0);
118
+ _Observation_attachmentsById.set(this, void 0);
119
+ this.type = 'Feature';
120
+ if (args[0] !== ObservationConstructionToken) {
121
+ throw new Error('use a factory function to create an observation instance');
122
+ }
123
+ const attrs = args[1];
124
+ this.mageEvent = args[2];
125
+ this.id = attrs.id;
126
+ this.eventId = attrs.eventId;
127
+ this.userId = attrs.userId;
128
+ this.deviceId = attrs.deviceId;
129
+ this.createdAt = new Date(attrs.createdAt);
130
+ this.lastModified = new Date(attrs.lastModified);
131
+ this.important = attrs.important ? Object.freeze(Object.assign({}, attrs.important)) : undefined;
132
+ const states = attrs.states.length ? attrs.states.map(copyObservationStateAttrs) : [
133
+ {
134
+ id: entities_global_1.PendingEntityId,
135
+ name: 'active',
136
+ userId: attrs.userId
137
+ }
138
+ ];
139
+ this.states = Object.freeze(states);
140
+ this.favoriteUserIds = Object.freeze(attrs.favoriteUserIds.slice());
141
+ this.type = 'Feature';
142
+ this.bbox = attrs.bbox;
143
+ this.geometry = attrs.geometry;
144
+ this.attachments = Object.freeze([...attrs.attachments]);
145
+ this.properties = Object.assign({}, attrs.properties);
146
+ __classPrivateFieldSet(this, _Observation_formEntriesById, new Map(this.properties.forms.map(x => [x.id, x])), "f");
147
+ __classPrivateFieldSet(this, _Observation_attachmentsById, new Map(this.attachments.map(x => [x.id, x])), "f");
148
+ __classPrivateFieldSet(this, _Observation_validation, args[3], "f");
149
+ this.pendingEvents = (args[4] || []);
150
+ }
151
+ /**
152
+ * Validate the given observation attributes against the given MAGE event's
153
+ * constraints and forms, and create the corresponding `Observation` instance
154
+ * with the validation result.
155
+ * @param attrs
156
+ * @param mageEvent
157
+ */
158
+ static evaluate(attrs, mageEvent) {
159
+ return createObservation(attrs, mageEvent);
160
+ }
161
+ /**
162
+ * TODO: This does not currently do anything besides assigning the
163
+ * `lastModified` timestamp on the updated observation and calling
164
+ * {@link Observation.evaluate()} with the given update attributes.
165
+ * Eventually this should perform the logic to find the differences and
166
+ * produce the domain events resulting from updating the target observation
167
+ * to the update attributes.
168
+ *
169
+ * Return an {@link ObservationUpdateError} if the event IDs on the target
170
+ * and udpate do not match.
171
+ *
172
+ * @param target
173
+ * @param update
174
+ * @returns
175
+ */
176
+ static assignTo(target, update) {
177
+ if (update.eventId !== target.eventId) {
178
+ return ObservationUpdateError.eventIdMismatch(target.eventId, update.eventId);
179
+ }
180
+ update = Object.assign(Object.assign({}, update), { createdAt: new Date(target.createdAt), lastModified: new Date() });
181
+ const updateAttachments = update.attachments.reduce((updateAttachments, att) => {
182
+ return updateAttachments.set(att.id, att);
183
+ }, new Map());
184
+ const removedAttachments = target.attachments.filter(x => !updateAttachments.has(x.id));
185
+ // TODO: whatever other mods generate events that matter
186
+ const updateEvents = removedAttachments.length ? [AttachmentsRemovedDomainEvent(target, removedAttachments)] : [];
187
+ const pendingEvents = mergePendingDomainEvents(target, updateEvents);
188
+ return createObservation(update, target.mageEvent, pendingEvents);
189
+ }
190
+ get validation() {
191
+ return __classPrivateFieldGet(this, _Observation_validation, "f");
192
+ }
193
+ /**
194
+ * This is a convenience accessor for {@link ObservationFeatureProperties.timestamp}.
195
+ */
196
+ get timestamp() {
197
+ return this.properties.timestamp;
198
+ }
199
+ /**
200
+ * This is a convenience accessor for {@link ObservationFeatureProperties.forms}.
201
+ */
202
+ get formEntries() {
203
+ return Array.from(__classPrivateFieldGet(this, _Observation_formEntriesById, "f").values());
204
+ }
205
+ formEntryForId(id) {
206
+ return __classPrivateFieldGet(this, _Observation_formEntriesById, "f").get(id) || null;
207
+ }
208
+ attachmentFor(id) {
209
+ return __classPrivateFieldGet(this, _Observation_attachmentsById, "f").get(id) || null;
210
+ }
211
+ attachmentsForField(fieldName, formEntryId) {
212
+ return attachmentsForField(fieldName, formEntryId, this);
213
+ }
214
+ }
215
+ exports.Observation = Observation;
216
+ _Observation_validation = new WeakMap(), _Observation_formEntriesById = new WeakMap(), _Observation_attachmentsById = new WeakMap();
217
+ var ObservationDomainEventType;
218
+ (function (ObservationDomainEventType) {
219
+ ObservationDomainEventType["AttachmentsRemoved"] = "Observation.AttachmentsRemoved";
220
+ })(ObservationDomainEventType = exports.ObservationDomainEventType || (exports.ObservationDomainEventType = {}));
221
+ function validateObservation(observationAttrs, mageEvent) {
222
+ const validation = validateObservationFormEntries(validateObservationAttachments(validateObservationCoreAttrs(new ObservationValidationContext(observationAttrs, mageEvent))));
223
+ return validation.result();
224
+ }
225
+ exports.validateObservation = validateObservation;
226
+ exports.MinFormsConstraint = Symbol('ObservationValidation.MinForms');
227
+ exports.MaxFormsConstraint = Symbol('ObservationValidation.MaxForms');
228
+ class TotalFormCountError {
229
+ constructor(constraint, constraintCount) {
230
+ this.constraint = constraint;
231
+ this.constraintCount = constraintCount;
232
+ }
233
+ static tooFewFormEntries(mageEvent) {
234
+ return new TotalFormCountError(exports.MinFormsConstraint, Number(mageEvent.minObservationForms));
235
+ }
236
+ static tooManyFormEntries(mageEvent) {
237
+ return new TotalFormCountError(exports.MaxFormsConstraint, Number(mageEvent.maxObservationForms));
238
+ }
239
+ message() {
240
+ if (this.constraint === exports.MinFormsConstraint) {
241
+ return `The event requires at least ${this.constraintCount} form ${this.constraintCount > 1 ? 'entries' : 'entry'}.`;
242
+ }
243
+ return `The event allows at most ${this.constraintCount} form ${this.constraintCount > 1 ? 'entries' : 'entry'}.`;
244
+ }
245
+ }
246
+ exports.TotalFormCountError = TotalFormCountError;
247
+ class FormCountError {
248
+ constructor(constraint, constraintCount, formId, formName) {
249
+ this.constraint = constraint;
250
+ this.constraintCount = constraintCount;
251
+ this.formId = formId;
252
+ this.formName = formName;
253
+ }
254
+ static tooFewEntriesForForm(form) {
255
+ return new FormCountError(exports.MinFormsConstraint, Number(form.min), form.id, form.name);
256
+ }
257
+ static tooManyEntriesForForm(form) {
258
+ return new FormCountError(exports.MaxFormsConstraint, Number(form.max), form.id, form.name);
259
+ }
260
+ message() {
261
+ if (this.constraint === exports.MinFormsConstraint) {
262
+ return `The event requires at least ${this.constraintCount} ${this.formName} form ${this.constraintCount > 1 ? 'entries' : 'entry'}.`;
263
+ }
264
+ return `The event allows at most ${this.constraintCount} ${this.formName} form ${this.constraintCount > 1 ? 'entries' : 'entry'}.`;
265
+ }
266
+ }
267
+ exports.FormCountError = FormCountError;
268
+ class FormEntryValidationError {
269
+ constructor(formEntryId, formEntryPosition) {
270
+ this.formEntryId = formEntryId;
271
+ this.formEntryPosition = formEntryPosition;
272
+ _FormEntryValidationError_entryLevelErrors.set(this, new Set());
273
+ _FormEntryValidationError_fieldErrors.set(this, new Map()
274
+ /**
275
+ * If there is no form reference error, set the form name for convenience
276
+ * when building the validation error message text.
277
+ */
278
+ );
279
+ /**
280
+ * If there is no form reference error, set the form name for convenience
281
+ * when building the validation error message text.
282
+ */
283
+ this.formName = null;
284
+ }
285
+ addEntryLevelError(x) {
286
+ __classPrivateFieldGet(this, _FormEntryValidationError_entryLevelErrors, "f").add(x);
287
+ return this;
288
+ }
289
+ addFieldError(x) {
290
+ __classPrivateFieldGet(this, _FormEntryValidationError_fieldErrors, "f").set(x.fieldName, x);
291
+ return this;
292
+ }
293
+ get entryLevelErrors() {
294
+ return new Set(__classPrivateFieldGet(this, _FormEntryValidationError_entryLevelErrors, "f"));
295
+ }
296
+ /**
297
+ * This is a map of field names to form field validation errors.
298
+ */
299
+ get fieldErrors() {
300
+ return new Map(__classPrivateFieldGet(this, _FormEntryValidationError_fieldErrors, "f"));
301
+ }
302
+ }
303
+ exports.FormEntryValidationError = FormEntryValidationError;
304
+ _FormEntryValidationError_entryLevelErrors = new WeakMap(), _FormEntryValidationError_fieldErrors = new WeakMap();
305
+ var FormEntryValidationErrorReason;
306
+ (function (FormEntryValidationErrorReason) {
307
+ FormEntryValidationErrorReason["FormRef"] = "FormEntryValidationErrorReason.FormRef";
308
+ FormEntryValidationErrorReason["DuplicateId"] = "FormEntryValidationErrorReason.DuplicateId";
309
+ })(FormEntryValidationErrorReason = exports.FormEntryValidationErrorReason || (exports.FormEntryValidationErrorReason = {}));
310
+ var FieldConstraintKey;
311
+ (function (FieldConstraintKey) {
312
+ FieldConstraintKey["Value"] = "value";
313
+ FieldConstraintKey["Min"] = "min";
314
+ FieldConstraintKey["Max"] = "max";
315
+ FieldConstraintKey["Required"] = "required";
316
+ })(FieldConstraintKey = exports.FieldConstraintKey || (exports.FieldConstraintKey = {}));
317
+ class FormFieldValidationError {
318
+ constructor(attrs) {
319
+ this.fieldName = attrs.fieldName;
320
+ this.constraint = attrs.constraint;
321
+ this.message = attrs.message;
322
+ }
323
+ /**
324
+ * `error` is a readonly accessor alias for `validationRuleKey` for backward
325
+ * compatibility.
326
+ * TODO: verify this is still necessary (NECESSARY?!)
327
+ */
328
+ get error() {
329
+ return this.constraint;
330
+ }
331
+ }
332
+ exports.FormFieldValidationError = FormFieldValidationError;
333
+ var AttachmentValidationErrorReason;
334
+ (function (AttachmentValidationErrorReason) {
335
+ AttachmentValidationErrorReason["FieldRef"] = "AttachmentValidationErrorReason.FieldRef";
336
+ AttachmentValidationErrorReason["FormEntryRef"] = "AttachmentValidationErrorReason.FormEntryRef";
337
+ AttachmentValidationErrorReason["DuplicateId"] = "AttachmentValidationErrorReason.DuplicateId";
338
+ })(AttachmentValidationErrorReason = exports.AttachmentValidationErrorReason || (exports.AttachmentValidationErrorReason = {}));
339
+ class AttachmentValidationError {
340
+ constructor(reason, message) {
341
+ this.reason = reason;
342
+ this.message = message;
343
+ }
344
+ }
345
+ exports.AttachmentValidationError = AttachmentValidationError;
346
+ function validationResultMessage(result) {
347
+ const { coreAttrsErrors, totalFormCountError, formCountErrors, formEntryErrors, attachmentErrors, } = result;
348
+ const bulletPoint = '\u2022';
349
+ const errList = [];
350
+ for (const message of Object.values(coreAttrsErrors)) {
351
+ errList.push(`${bulletPoint} ${message}`);
352
+ }
353
+ if (totalFormCountError) {
354
+ errList.push(`${bulletPoint} ${totalFormCountError.message()}`);
355
+ }
356
+ for (const [formId, err] of formCountErrors) {
357
+ errList.push(`${bulletPoint} ${err.message()}`);
358
+ }
359
+ for (const [formEntryId, formEntryErr] of formEntryErrors) {
360
+ errList.push(`${bulletPoint} Form entry ${formEntryErr.formEntryPosition + 1} (${formEntryErr.formName}) is invalid.`);
361
+ for (const fieldErr of formEntryErr.fieldErrors.values()) {
362
+ errList.push(` ${bulletPoint} ${fieldErr.message}`);
363
+ }
364
+ }
365
+ for (const [pos, attachmentErr] of attachmentErrors) {
366
+ errList.push(`${bulletPoint} Attachment ${pos + 1} is invalid. ${attachmentErr.message}`);
367
+ }
368
+ return errList.join('\n');
369
+ }
370
+ exports.validationResultMessage = validationResultMessage;
371
+ class ObservationUpdateError extends Error {
372
+ constructor(reason, message) {
373
+ super(message);
374
+ this.reason = reason;
375
+ }
376
+ static eventIdMismatch(expected, actual) {
377
+ return new ObservationUpdateError(ObservationUpdateErrorReason.EventId, `The update event ID ${actual} does not match the target event ID ${expected}.`);
378
+ }
379
+ }
380
+ exports.ObservationUpdateError = ObservationUpdateError;
381
+ var ObservationUpdateErrorReason;
382
+ (function (ObservationUpdateErrorReason) {
383
+ ObservationUpdateErrorReason["EventId"] = "event_id";
384
+ })(ObservationUpdateErrorReason = exports.ObservationUpdateErrorReason || (exports.ObservationUpdateErrorReason = {}));
385
+ function formEntryForId(formEntryId, observation) {
386
+ return observation.properties.forms.find(x => x.id === formEntryId) || null;
387
+ }
388
+ exports.formEntryForId = formEntryForId;
389
+ function attachmentsForField(field, formEntry, observationAttrs) {
390
+ const fieldName = typeof field === 'object' ? field.name : field;
391
+ const formEntryId = typeof formEntry === 'object' && 'id' in formEntry && 'formId' in formEntry ? formEntry.id : formEntry;
392
+ return observationAttrs.attachments.filter(x => x.fieldName === fieldName && x.observationFormId === formEntryId);
393
+ }
394
+ exports.attachmentsForField = attachmentsForField;
395
+ /**
396
+ * Remove the form entry with the given ID and return the resulting
397
+ * (potentially invalid) observation.
398
+ *
399
+ * TODO: add a `FormEntryNotFound` error similar to `removeAttachment()`
400
+ */
401
+ function removeFormEntry(observation, formEntryId) {
402
+ const mod = copyObservationAttrs(observation);
403
+ const targetPos = observation.formEntries.findIndex(x => x.id === formEntryId);
404
+ mod.properties.forms.splice(targetPos, 1);
405
+ mod.attachments = observation.attachments.filter(x => x.observationFormId !== formEntryId);
406
+ return Observation.assignTo(observation, mod);
407
+ }
408
+ exports.removeFormEntry = removeFormEntry;
409
+ /**
410
+ * Add the given attachment to the given observation. Return a new observation
411
+ * instance with the added attachment, or return an {@link AttachmentAddError}
412
+ * if the given attachment does not reference a valid form entry and field.
413
+ * Note that the returned observation may still have validation errors resulting
414
+ * from the added attachment if the attachment violates the associated form
415
+ * constraints, such as min/max or allowed attachment types.
416
+ * @param observation
417
+ * @param fieldName
418
+ * @param formEntryId
419
+ * @param attrs
420
+ * @returns
421
+ */
422
+ function addAttachment(observation, attachmentId, fieldName, formEntryId, attrs) {
423
+ const attachment = Object.assign(Object.assign({}, attrs), { id: attachmentId, fieldName, observationFormId: formEntryId, lastModified: new Date() });
424
+ const invalid = validateAttachment(attachment, observation, observation.mageEvent);
425
+ if (invalid) {
426
+ return AttachmentAddError.invalidNewAttachment(invalid);
427
+ }
428
+ const mod = copyObservationAttrs(observation);
429
+ mod.attachments = [...mod.attachments, attachment];
430
+ return Observation.assignTo(observation, mod);
431
+ }
432
+ exports.addAttachment = addAttachment;
433
+ /**
434
+ * Update the attachment for the given ID with the given patch object. Keys
435
+ * that are present in the patch whose values are `undefined` will assign
436
+ * `undefined` to the resulting updated attachment. Keys not present in the
437
+ * patch will have no affect on the resulting updated attachment.
438
+ * @param observation
439
+ * @param attachmentId
440
+ * @param patch
441
+ * @returns
442
+ */
443
+ function patchAttachment(observation, attachmentId, patch) {
444
+ var _a;
445
+ const targetPos = observation.attachments.findIndex(x => x.id === attachmentId);
446
+ const target = observation.attachments[targetPos];
447
+ if (!target) {
448
+ return new AttachmentNotFoundError(attachmentId);
449
+ }
450
+ const patched = copyAttachmentAttrs(target);
451
+ patched.contentType = patch.hasOwnProperty('contentType') ? patch.contentType : patched.contentType;
452
+ patched.height = patch.hasOwnProperty('height') ? patch.height : patched.height;
453
+ patched.width = patch.hasOwnProperty('width') ? patch.width : patched.width;
454
+ patched.name = patch.hasOwnProperty('name') ? patch.name : patched.name;
455
+ patched.oriented = patch.hasOwnProperty('oriented') ? !!patch.oriented : patched.oriented;
456
+ patched.size = patch.hasOwnProperty('size') ? patch.size : patched.size;
457
+ patched.contentLocator = patch.hasOwnProperty('contentLocator') ? patch.contentLocator : patched.contentLocator;
458
+ patched.thumbnails = patch.hasOwnProperty('thumbnails') ? (_a = patch.thumbnails) === null || _a === void 0 ? void 0 : _a.map(copyThumbnailAttrs) : patched.thumbnails;
459
+ patched.lastModified = new Date();
460
+ const patchedObservation = copyObservationAttrs(observation);
461
+ const before = patchedObservation.attachments.slice(0, targetPos);
462
+ const after = patchedObservation.attachments.slice(targetPos + 1);
463
+ const attachments = before.concat(patched, after);
464
+ patchedObservation.attachments = Object.freeze(attachments);
465
+ patchedObservation.lastModified = new Date(patched.lastModified);
466
+ return Observation.assignTo(observation, patchedObservation);
467
+ }
468
+ exports.patchAttachment = patchAttachment;
469
+ function removeAttachment(observation, attachmentId) {
470
+ const targetPos = observation.attachments.findIndex(x => x.id === attachmentId);
471
+ const target = observation.attachments[targetPos];
472
+ if (!target) {
473
+ return new AttachmentNotFoundError(attachmentId);
474
+ }
475
+ const afterAttrs = copyObservationAttrs(observation);
476
+ const attachments = afterAttrs.attachments.slice();
477
+ attachments.splice(targetPos, 1);
478
+ afterAttrs.attachments = attachments;
479
+ return Observation.assignTo(observation, afterAttrs);
480
+ }
481
+ exports.removeAttachment = removeAttachment;
482
+ /**
483
+ * Add the given thumbnail to the given attachment. If the attachment already
484
+ * has a thumbnail at the same minimum dimension as the given thumbnail,
485
+ * replace the existing thumbnail with the given thumbnail at the same position
486
+ * in the thumbnails array.
487
+ * @param observation
488
+ * @param attachmentId
489
+ * @param thumbnail
490
+ * @returns
491
+ */
492
+ function putAttachmentThumbnailForMinDimension(observation, attachmentId, thumbnail) {
493
+ const target = observation.attachmentFor(attachmentId);
494
+ if (!target) {
495
+ return new AttachmentNotFoundError(attachmentId);
496
+ }
497
+ const thumbnailsPatch = target.thumbnails.map(copyThumbnailAttrs);
498
+ const targetThumbPos = thumbnailsPatch.findIndex(x => x.minDimension === thumbnail.minDimension);
499
+ const putThumbAttrs = copyThumbnailAttrs(thumbnail);
500
+ if (targetThumbPos >= 0) {
501
+ thumbnailsPatch[targetThumbPos] = putThumbAttrs;
502
+ }
503
+ else {
504
+ thumbnailsPatch.push(putThumbAttrs);
505
+ }
506
+ return patchAttachment(observation, attachmentId, { thumbnails: thumbnailsPatch });
507
+ }
508
+ exports.putAttachmentThumbnailForMinDimension = putAttachmentThumbnailForMinDimension;
509
+ /**
510
+ * Return the index of the thumbnail on the given attachment that best satisfies
511
+ * the given target dimension. That will be the thumbnail with the smallest
512
+ * {@link Attachment.minDimension} greater than the target dimension.
513
+ */
514
+ function thumbnailIndexForTargetDimension(targetDimension, attachment) {
515
+ if (attachment.thumbnails.length === 0) {
516
+ return void (0);
517
+ }
518
+ return attachment.thumbnails.reduce((best, candidate, index) => {
519
+ if (candidate.minDimension >= targetDimension &&
520
+ (best === undefined || candidate.minDimension < attachment.thumbnails[best].minDimension)) {
521
+ return index;
522
+ }
523
+ return best;
524
+ }, void (0));
525
+ }
526
+ exports.thumbnailIndexForTargetDimension = thumbnailIndexForTargetDimension;
527
+ class AttachmentAddError extends Error {
528
+ constructor(validationErr) {
529
+ super(`Invalid new attachment: ${validationErr.message}`);
530
+ this.validationErr = validationErr;
531
+ }
532
+ static invalidNewAttachment(invalidErr) {
533
+ return new AttachmentAddError(invalidErr);
534
+ }
535
+ }
536
+ exports.AttachmentAddError = AttachmentAddError;
537
+ class AttachmentNotFoundError extends Error {
538
+ constructor(attachmentId) {
539
+ super(`Attachment ID ${attachmentId} does not exist.`);
540
+ this.attachmentId = attachmentId;
541
+ }
542
+ }
543
+ exports.AttachmentNotFoundError = AttachmentNotFoundError;
544
+ class ObservationRepositoryError extends Error {
545
+ constructor(code, message) {
546
+ super(message);
547
+ this.code = code;
548
+ }
549
+ }
550
+ exports.ObservationRepositoryError = ObservationRepositoryError;
551
+ var ObservationRepositoryErrorCode;
552
+ (function (ObservationRepositoryErrorCode) {
553
+ ObservationRepositoryErrorCode["InvalidObservationId"] = "ObservationRepositoryError.InvalidObservationId";
554
+ ObservationRepositoryErrorCode["InvalidObservation"] = "ObservationRepositoryError.InvalidObservation";
555
+ })(ObservationRepositoryErrorCode = exports.ObservationRepositoryErrorCode || (exports.ObservationRepositoryErrorCode = {}));
556
+ class StagedAttachmentContentRef {
557
+ constructor(id) {
558
+ this.id = id;
559
+ }
560
+ }
561
+ exports.StagedAttachmentContentRef = StagedAttachmentContentRef;
562
+ class StagedAttachmentContent extends StagedAttachmentContentRef {
563
+ constructor(id, tempLocation) {
564
+ super(id);
565
+ this.tempLocation = tempLocation;
566
+ }
567
+ }
568
+ exports.StagedAttachmentContent = StagedAttachmentContent;
569
+ class AttachmentStoreError extends Error {
570
+ constructor(errorCode, message) {
571
+ super(message);
572
+ this.errorCode = errorCode;
573
+ this.name = errorCode;
574
+ }
575
+ static invalidAttachmentId(attachmentId, observation) {
576
+ return new AttachmentStoreError(AttachmentStoreErrorCode.InvalidAttachmentId, `observation ${observation.id} has no attachment ${attachmentId}`);
577
+ }
578
+ static invalidThumbnailDimension(minDimension, attachmentId, observation) {
579
+ return new AttachmentStoreError(AttachmentStoreErrorCode.InvalidThumbnailDimension, `attachment ${attachmentId} on observation ${observation.id} has no thumbnail with dimension ${minDimension}`);
580
+ }
581
+ }
582
+ exports.AttachmentStoreError = AttachmentStoreError;
583
+ var AttachmentStoreErrorCode;
584
+ (function (AttachmentStoreErrorCode) {
585
+ /**
586
+ * The given attachment ID was not found in the given observation's
587
+ * attachment list.
588
+ */
589
+ AttachmentStoreErrorCode["InvalidAttachmentId"] = "AttachmentStoreError.InvalidAttachmentId";
590
+ AttachmentStoreErrorCode["InvalidThumbnailDimension"] = "AttachmentStoreError.InvalidThumbnailDimension";
591
+ /**
592
+ * The content for the given attachment ID was not found in the attachment
593
+ * store.
594
+ */
595
+ AttachmentStoreErrorCode["ContentNotFound"] = "AttachmentStoreError.ContentNotFound";
596
+ /**
597
+ * The underlying storage system, e.g. file system, raised an error during
598
+ * some I/O operation.
599
+ */
600
+ AttachmentStoreErrorCode["StorageError"] = "AttachmentStoreError.StorageError";
601
+ })(AttachmentStoreErrorCode = exports.AttachmentStoreErrorCode || (exports.AttachmentStoreErrorCode = {}));
602
+ const ObservationConstructionToken = Symbol('ObservationConstructor');
603
+ function createObservation(attrs, mageEvent, pendingEvents) {
604
+ attrs = copyObservationAttrs(attrs);
605
+ const validation = validateObservation(attrs, mageEvent);
606
+ return new Observation(ObservationConstructionToken, attrs, mageEvent, validation, pendingEvents);
607
+ }
608
+ function validateObservationCoreAttrs(validation) {
609
+ const { observationAttrs, mageEvent } = validation;
610
+ if (observationAttrs.eventId !== mageEvent.id) {
611
+ validation.addCoreAttrsError('eventId', `The observation event ID ${observationAttrs.eventId} does not match the asserted event ID ${mageEvent.id}.`);
612
+ }
613
+ if (observationAttrs.type !== 'Feature') {
614
+ validation.addCoreAttrsError('type', `The observation GeoJSON type must be 'Feature'.`);
615
+ }
616
+ const invalidGeometry = fields.geometry.GeometryFieldValidation({ title: 'Geometry', id: 0, name: 'geometry', required: true, type: entities_events_forms_1.FormFieldType.Geometry }, observationAttrs.geometry, { succeeded: () => null, failedBecauseTheEntry: reason => reason });
617
+ if (invalidGeometry) {
618
+ validation.addCoreAttrsError('geometry', `The observation geometry ${invalidGeometry}`);
619
+ }
620
+ if (!(observationAttrs.properties.timestamp instanceof Date)) {
621
+ validation.addCoreAttrsError('timestamp', 'The observation requires a valid timestamp.');
622
+ }
623
+ return validation;
624
+ }
625
+ function validateObservationFormEntries(validation) {
626
+ const { observationAttrs, mageEvent } = validation;
627
+ if (!Array.isArray(observationAttrs.properties.forms)) {
628
+ return validation.addCoreAttrsError('forms', 'The observation requires an array of form entries.');
629
+ }
630
+ const activeFormEntryCounts = mageEvent.forms.reduce((activeFormCounts, form) => {
631
+ if (!form.archived) {
632
+ activeFormCounts.set(form.id, 0);
633
+ }
634
+ return activeFormCounts;
635
+ }, new Map());
636
+ const formEntryIds = new Set();
637
+ const formEntryCounts = observationAttrs.properties.forms.reduce((formEntryCounts, formEntry, formEntryPos) => {
638
+ const formEntryError = new FormEntryValidationError(formEntry.id, formEntryPos);
639
+ if (formEntryIds.has(formEntry.id)) {
640
+ formEntryError.addEntryLevelError(FormEntryValidationErrorReason.DuplicateId);
641
+ }
642
+ formEntryIds.add(formEntry.id);
643
+ const form = mageEvent.formFor(formEntry.formId);
644
+ if (form) {
645
+ if (activeFormEntryCounts.has(form.id)) {
646
+ formEntryError.formName = form.name;
647
+ formEntryCounts.set(form.id, (formEntryCounts.get(form.id) || 0) + 1);
648
+ validateFormFieldEntries(formEntry, form, formEntryError, validation);
649
+ }
650
+ }
651
+ else {
652
+ formEntryError.addEntryLevelError(FormEntryValidationErrorReason.FormRef);
653
+ }
654
+ if (formEntryHasErrors(formEntryError)) {
655
+ validation.addFormEntryError(formEntryError);
656
+ }
657
+ return formEntryCounts;
658
+ }, activeFormEntryCounts);
659
+ let totalActiveFormEntryCount = 0;
660
+ for (const [formId, formEntryCount] of formEntryCounts) {
661
+ const form = mageEvent.formFor(formId);
662
+ if (typeof form.min === 'number' && formEntryCount < form.min) {
663
+ validation.addFormCountError(FormCountError.tooFewEntriesForForm(form));
664
+ }
665
+ else if (typeof form.max === 'number' && formEntryCount > form.max) {
666
+ validation.addFormCountError(FormCountError.tooManyEntriesForForm(form));
667
+ }
668
+ totalActiveFormEntryCount += formEntryCount;
669
+ }
670
+ if (typeof mageEvent.minObservationForms === 'number' && totalActiveFormEntryCount < mageEvent.minObservationForms) {
671
+ validation.setTotalFormCountError(TotalFormCountError.tooFewFormEntries(mageEvent));
672
+ }
673
+ else if (typeof mageEvent.maxObservationForms === 'number' && totalActiveFormEntryCount > mageEvent.maxObservationForms) {
674
+ validation.setTotalFormCountError(TotalFormCountError.tooManyFormEntries(mageEvent));
675
+ }
676
+ // TODO: invalidate new form entries that reference archived forms
677
+ return validation;
678
+ }
679
+ function formEntryHasErrors(err) {
680
+ return err.entryLevelErrors.size > 0 || err.fieldErrors.size > 0;
681
+ }
682
+ function validateObservationAttachments(validation) {
683
+ const { observationAttrs, mageEvent } = validation;
684
+ const attachments = observationAttrs.attachments;
685
+ attachments.forEach((x, index) => {
686
+ const invalid = validateAttachment(x, observationAttrs, mageEvent);
687
+ if (invalid) {
688
+ validation.setAttachmentError(index, invalid);
689
+ }
690
+ });
691
+ return validation;
692
+ }
693
+ function validateAttachment(attachment, observation, mageEvent) {
694
+ const formEntry = formEntryForId(attachment.observationFormId, observation);
695
+ if (!formEntry) {
696
+ return new AttachmentValidationError(AttachmentValidationErrorReason.FormEntryRef, `The attachment form entry reference ${attachment.observationFormId} is invalid.`);
697
+ }
698
+ const field = mageEvent.formFieldFor(attachment.fieldName, formEntry.formId);
699
+ if (!field || field.type !== entities_events_forms_1.FormFieldType.Attachment) {
700
+ return new AttachmentValidationError(AttachmentValidationErrorReason.FieldRef, `The attachment field reference ${attachment.fieldName} is invalid.`);
701
+ }
702
+ const dup = observation.attachments.find(x => x.id === attachment.id && x !== attachment);
703
+ if (dup) {
704
+ return new AttachmentValidationError(AttachmentValidationErrorReason.DuplicateId, `The attachment ID ${attachment.id} is not unique on the observation.`);
705
+ }
706
+ return null;
707
+ }
708
+ function FormFieldValidationResult(context) {
709
+ return {
710
+ failedBecauseTheEntry(reason, constraint = FieldConstraintKey.Value) {
711
+ return new FormFieldValidationError({ fieldName: context.field.name, message: `${context.field.title} ${reason}`, constraint: constraint });
712
+ },
713
+ succeeded(parsed) { return parsed; }
714
+ };
715
+ }
716
+ function validateRequiredThen(rule) {
717
+ return context => {
718
+ const requiredError = fields.required.RequiredFieldValidation(context.field, context.fieldEntry, FormFieldValidationResult(context));
719
+ if (requiredError) {
720
+ return requiredError;
721
+ }
722
+ return rule(context);
723
+ };
724
+ }
725
+ // TODO: these could be improved to be more cleanly comosable in a functional way, e.g., monadic. i'll figure that out eventually
726
+ const FieldTypeValidationRules = {
727
+ // attachments use min/max constraints, not required constraint
728
+ [entities_events_forms_1.FormFieldType.Attachment]: context => fields.attachment.AttachmentFieldValidation(context.field, context.formEntry.id, context.observationAttrs, FormFieldValidationResult(context)),
729
+ [entities_events_forms_1.FormFieldType.CheckBox]: validateRequiredThen(context => fields.checkbox.CheckboxFieldValidation(context.field, context.fieldEntry, FormFieldValidationResult(context))),
730
+ [entities_events_forms_1.FormFieldType.DateTime]: validateRequiredThen(context => fields.date.DateFieldValidation(context.field, context.fieldEntry, FormFieldValidationResult(context))),
731
+ [entities_events_forms_1.FormFieldType.Dropdown]: validateRequiredThen(context => fields.select.SelectFormFieldValidation(context.field, context.fieldEntry, FormFieldValidationResult(context))),
732
+ [entities_events_forms_1.FormFieldType.Email]: validateRequiredThen(context => fields.email.EmailFieldValidation(context.field, context.fieldEntry, FormFieldValidationResult(context))),
733
+ [entities_events_forms_1.FormFieldType.Geometry]: validateRequiredThen(context => fields.geometry.GeometryFieldValidation(context.field, context.fieldEntry, FormFieldValidationResult(context))),
734
+ // TODO: no validation at all? legacy validation code did nothing for hidden fields
735
+ [entities_events_forms_1.FormFieldType.Hidden]: context => null,
736
+ [entities_events_forms_1.FormFieldType.MultiSelectDropdown]: validateRequiredThen(context => fields.multiselect.MultiSelectFormFieldValidation(context.field, context.fieldEntry, FormFieldValidationResult(context))),
737
+ [entities_events_forms_1.FormFieldType.Numeric]: validateRequiredThen(context => fields.numeric.NumericFieldValidation(context.field, context.fieldEntry, FormFieldValidationResult(context))),
738
+ [entities_events_forms_1.FormFieldType.Password]: validateRequiredThen(context => fields.text.TextFieldValidation(context.field, context.fieldEntry, FormFieldValidationResult(context))),
739
+ [entities_events_forms_1.FormFieldType.Radio]: validateRequiredThen(context => fields.select.SelectFormFieldValidation(context.field, context.fieldEntry, FormFieldValidationResult(context))),
740
+ [entities_events_forms_1.FormFieldType.Text]: validateRequiredThen(context => fields.text.TextFieldValidation(context.field, context.fieldEntry, FormFieldValidationResult(context))),
741
+ [entities_events_forms_1.FormFieldType.TextArea]: validateRequiredThen(context => fields.text.TextFieldValidation(context.field, context.fieldEntry, FormFieldValidationResult(context))),
742
+ };
743
+ /**
744
+ * TODO: This retains legacy functionality of only keying of form fields in the
745
+ * event form to validate the values in the form entry. However, this leaves
746
+ * keys in the form entry that do not have a corresponding form field. A
747
+ * client could thus submit an observation with thousands of keys in a fomr
748
+ * entry.
749
+ */
750
+ function validateFormFieldEntries(formEntry, form, formEntryError, validation) {
751
+ const { mageEvent, observationAttrs } = validation;
752
+ const formFields = form.fields || [];
753
+ const activeFields = formFields.filter(x => !x.archived);
754
+ activeFields.forEach(field => {
755
+ const fieldEntry = formEntry[field.name];
756
+ const fieldValidation = { field, fieldEntry, formEntry, mageEvent, observationAttrs };
757
+ const resultEntry = FieldTypeValidationRules[field.type](fieldValidation);
758
+ if (resultEntry instanceof FormFieldValidationError) {
759
+ formEntryError.addFieldError(resultEntry);
760
+ }
761
+ else if (resultEntry !== void (0)) {
762
+ formEntry[field.name] = resultEntry;
763
+ }
764
+ });
765
+ }
766
+ class ObservationValidationContext {
767
+ constructor(...args) {
768
+ _ObservationValidationContext_coreAttrsErrors.set(this, void 0);
769
+ _ObservationValidationContext_formCountErrors.set(this, void 0);
770
+ _ObservationValidationContext_formEntryErrors.set(this, void 0);
771
+ _ObservationValidationContext_attachmentErrors.set(this, void 0);
772
+ _ObservationValidationContext_totalFormCountError.set(this, null);
773
+ const [fromOrAttrs, maybeMageEvent] = args;
774
+ if (fromOrAttrs instanceof ObservationValidationContext) {
775
+ this.observationAttrs = fromOrAttrs.observationAttrs;
776
+ this.mageEvent = fromOrAttrs.mageEvent;
777
+ __classPrivateFieldSet(this, _ObservationValidationContext_coreAttrsErrors, new Map(fromOrAttrs.coreAttrsErrors), "f");
778
+ __classPrivateFieldSet(this, _ObservationValidationContext_formEntryErrors, new Map(fromOrAttrs.formEntryErrors), "f");
779
+ __classPrivateFieldSet(this, _ObservationValidationContext_formCountErrors, new Map(fromOrAttrs.formCountErrors), "f");
780
+ __classPrivateFieldSet(this, _ObservationValidationContext_attachmentErrors, new Map(fromOrAttrs.attachmentErrors), "f");
781
+ }
782
+ else {
783
+ this.observationAttrs = fromOrAttrs;
784
+ this.mageEvent = maybeMageEvent;
785
+ __classPrivateFieldSet(this, _ObservationValidationContext_coreAttrsErrors, new Map(), "f");
786
+ __classPrivateFieldSet(this, _ObservationValidationContext_formEntryErrors, new Map(), "f");
787
+ __classPrivateFieldSet(this, _ObservationValidationContext_formCountErrors, new Map(), "f");
788
+ __classPrivateFieldSet(this, _ObservationValidationContext_attachmentErrors, new Map(), "f");
789
+ }
790
+ }
791
+ addCoreAttrsError(key, message) {
792
+ __classPrivateFieldGet(this, _ObservationValidationContext_coreAttrsErrors, "f").set(key, message);
793
+ return this;
794
+ }
795
+ setTotalFormCountError(x) {
796
+ __classPrivateFieldSet(this, _ObservationValidationContext_totalFormCountError, x, "f");
797
+ return this;
798
+ }
799
+ addFormCountError(x) {
800
+ __classPrivateFieldGet(this, _ObservationValidationContext_formCountErrors, "f").set(x.formId, x);
801
+ return this;
802
+ }
803
+ addFormEntryError(formEntryError) {
804
+ __classPrivateFieldGet(this, _ObservationValidationContext_formEntryErrors, "f").set(formEntryError.formEntryPosition, formEntryError);
805
+ return this;
806
+ }
807
+ setAttachmentError(index, err) {
808
+ __classPrivateFieldGet(this, _ObservationValidationContext_attachmentErrors, "f").set(index, err);
809
+ return this;
810
+ }
811
+ get coreAttrsErrors() {
812
+ return new Map(__classPrivateFieldGet(this, _ObservationValidationContext_coreAttrsErrors, "f"));
813
+ }
814
+ get formCountErrors() {
815
+ return new Map(__classPrivateFieldGet(this, _ObservationValidationContext_formCountErrors, "f"));
816
+ }
817
+ get formEntryErrors() {
818
+ return new Map(__classPrivateFieldGet(this, _ObservationValidationContext_formEntryErrors, "f"));
819
+ }
820
+ get attachmentErrors() {
821
+ return new Map(__classPrivateFieldGet(this, _ObservationValidationContext_attachmentErrors, "f"));
822
+ }
823
+ get totalFormCountError() {
824
+ return __classPrivateFieldGet(this, _ObservationValidationContext_totalFormCountError, "f");
825
+ }
826
+ get hasErrors() {
827
+ return __classPrivateFieldGet(this, _ObservationValidationContext_coreAttrsErrors, "f").size > 0
828
+ || __classPrivateFieldGet(this, _ObservationValidationContext_totalFormCountError, "f") !== null
829
+ || __classPrivateFieldGet(this, _ObservationValidationContext_formCountErrors, "f").size > 0
830
+ || __classPrivateFieldGet(this, _ObservationValidationContext_formEntryErrors, "f").size > 0
831
+ || __classPrivateFieldGet(this, _ObservationValidationContext_attachmentErrors, "f").size > 0;
832
+ }
833
+ result() {
834
+ const hasErrors = this.hasErrors;
835
+ const coreAttrsErrors = Object.freeze(Object.fromEntries(this.coreAttrsErrors));
836
+ const totalFormCountError = this.totalFormCountError;
837
+ const formCountErrors = Object.freeze(Array.from(this.formCountErrors.entries()));
838
+ const formEntryErrors = Object.freeze(Array.from(this.formEntryErrors.entries()));
839
+ const attachmentErrors = Object.freeze(Array.from(this.attachmentErrors.entries()));
840
+ return Object.freeze({
841
+ hasErrors,
842
+ coreAttrsErrors,
843
+ totalFormCountError,
844
+ formCountErrors,
845
+ formEntryErrors,
846
+ attachmentErrors,
847
+ });
848
+ }
849
+ }
850
+ _ObservationValidationContext_coreAttrsErrors = new WeakMap(), _ObservationValidationContext_formCountErrors = new WeakMap(), _ObservationValidationContext_formEntryErrors = new WeakMap(), _ObservationValidationContext_attachmentErrors = new WeakMap(), _ObservationValidationContext_totalFormCountError = new WeakMap();
851
+ function AttachmentsRemovedDomainEvent(observation, removedAttachments) {
852
+ return Object.freeze({
853
+ type: ObservationDomainEventType.AttachmentsRemoved,
854
+ removedAttachments: Object.freeze(removedAttachments)
855
+ });
856
+ }
857
+ function mergePendingDomainEvents(from, nextEvents) {
858
+ const removedAttachments = [];
859
+ const merged = [...from.pendingEvents, ...nextEvents].reduce((merged, e) => {
860
+ if (e.type === ObservationDomainEventType.AttachmentsRemoved) {
861
+ removedAttachments.push(...e.removedAttachments);
862
+ return merged;
863
+ }
864
+ else {
865
+ return [...merged, e];
866
+ }
867
+ }, []);
868
+ if (removedAttachments.length) {
869
+ merged.push(AttachmentsRemovedDomainEvent(from, removedAttachments));
870
+ }
871
+ return merged;
872
+ }
873
+ //# sourceMappingURL=entities.observations.js.map