@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,274 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
12
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13
+ 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");
14
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
15
+ };
16
+ var __importDefault = (this && this.__importDefault) || function (mod) {
17
+ return (mod && mod.__esModule) ? mod : { "default": mod };
18
+ };
19
+ var _FileSystemAttachmentStore_instances, _FileSystemAttachmentStore_saveContent, _FileSystemAttachmentStore_baseDirIsAncestorOf;
20
+ Object.defineProperty(exports, "__esModule", { value: true });
21
+ exports.FileSystemAttachmentStoreInitError = exports.intializeAttachmentStore = exports.FileSystemAttachmentStore = void 0;
22
+ const fs_1 = __importDefault(require("fs"));
23
+ const path_1 = __importDefault(require("path"));
24
+ const stream_1 = __importDefault(require("stream"));
25
+ const util_1 = __importDefault(require("util"));
26
+ const uniqid_1 = __importDefault(require("uniqid"));
27
+ const entities_observations_1 = require("../../entities/observations/entities.observations");
28
+ const mime_types_1 = __importDefault(require("mime-types"));
29
+ class FileSystemAttachmentStore {
30
+ constructor(token, baseDirPath, pendingDirPath) {
31
+ this.baseDirPath = baseDirPath;
32
+ this.pendingDirPath = pendingDirPath;
33
+ _FileSystemAttachmentStore_instances.add(this);
34
+ if (token !== FileSystemAttachmentStoreConstructorToken) {
35
+ throw new FileSystemAttachmentStoreInitError('use the factory function');
36
+ }
37
+ }
38
+ stagePendingContent() {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const id = (0, uniqid_1.default)();
41
+ const tempPath = path_1.default.join(this.pendingDirPath, id);
42
+ const tempLocation = fs_1.default.createWriteStream(tempPath);
43
+ return new entities_observations_1.StagedAttachmentContent(id, tempLocation);
44
+ });
45
+ }
46
+ saveContent(content, attachmentId, observation) {
47
+ return __awaiter(this, void 0, void 0, function* () {
48
+ const attachment = observation.attachmentFor(attachmentId);
49
+ if (!attachment) {
50
+ return entities_observations_1.AttachmentStoreError.invalidAttachmentId(attachmentId, observation);
51
+ }
52
+ const saveRelPath = relativeWritePathForAttachment(attachment, observation);
53
+ const savePath = path_1.default.join(this.baseDirPath, saveRelPath);
54
+ const savedSize = yield __classPrivateFieldGet(this, _FileSystemAttachmentStore_instances, "m", _FileSystemAttachmentStore_saveContent).call(this, content, savePath);
55
+ if (typeof savedSize !== 'number') {
56
+ return savedSize;
57
+ }
58
+ if (!attachment.contentLocator || attachment.size !== savedSize) {
59
+ return { contentLocator: saveRelPath, size: savedSize };
60
+ }
61
+ return null;
62
+ });
63
+ }
64
+ saveThumbnailContent(content, minDimension, attachmentId, observation) {
65
+ return __awaiter(this, void 0, void 0, function* () {
66
+ const attachment = observation.attachmentFor(attachmentId);
67
+ if (!attachment) {
68
+ return entities_observations_1.AttachmentStoreError.invalidAttachmentId(attachmentId, observation);
69
+ }
70
+ const thumbnailPos = attachment.thumbnails.findIndex(x => x.minDimension === minDimension);
71
+ const thumbnail = attachment.thumbnails[thumbnailPos];
72
+ if (!thumbnail) {
73
+ return entities_observations_1.AttachmentStoreError.invalidThumbnailDimension(minDimension, attachmentId, observation);
74
+ }
75
+ const saveRelPath = relativeWritePathForThumbnail(thumbnail, attachment, observation);
76
+ const savePath = path_1.default.join(this.baseDirPath, saveRelPath);
77
+ const savedSize = yield __classPrivateFieldGet(this, _FileSystemAttachmentStore_instances, "m", _FileSystemAttachmentStore_saveContent).call(this, content, savePath);
78
+ if (typeof savedSize !== 'number') {
79
+ return savedSize;
80
+ }
81
+ if (!thumbnail.contentLocator || thumbnail.size !== savedSize) {
82
+ const savedThumbnail = (0, entities_observations_1.copyThumbnailAttrs)(thumbnail);
83
+ savedThumbnail.contentLocator = saveRelPath;
84
+ savedThumbnail.size = savedSize;
85
+ return savedThumbnail;
86
+ }
87
+ return null;
88
+ });
89
+ }
90
+ readContent(attachmentId, observation, range = { start: 0 }) {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ const attachment = observation.attachmentFor(attachmentId);
93
+ if (!attachment) {
94
+ return Promise.resolve(entities_observations_1.AttachmentStoreError.invalidAttachmentId(attachmentId, observation));
95
+ }
96
+ const contentRelPath = relativeReadPathForAttachment(attachment, observation);
97
+ const contentPath = path_1.default.join(this.baseDirPath, contentRelPath);
98
+ try {
99
+ const fd = yield util_1.default.promisify(fs_1.default.open)(contentPath, 'r');
100
+ return fs_1.default.createReadStream(contentPath, Object.assign(Object.assign({}, range), { fd }));
101
+ }
102
+ catch (err) {
103
+ console.error(`error reading attachment content`, contentPath, err);
104
+ return new entities_observations_1.AttachmentStoreError(entities_observations_1.AttachmentStoreErrorCode.StorageError, `error reading attachment ${attachmentId} on observation ${observation.id}`);
105
+ }
106
+ });
107
+ }
108
+ readThumbnailContent(minDimension, attachmentId, observation) {
109
+ return __awaiter(this, void 0, void 0, function* () {
110
+ const attachment = observation.attachmentFor(attachmentId);
111
+ if (!attachment) {
112
+ return entities_observations_1.AttachmentStoreError.invalidAttachmentId(attachmentId, observation);
113
+ }
114
+ const thumbnail = attachment.thumbnails.find(x => x.minDimension === minDimension);
115
+ if (!thumbnail) {
116
+ return entities_observations_1.AttachmentStoreError.invalidThumbnailDimension(minDimension, attachmentId, observation);
117
+ }
118
+ const contentRelPath = relativeReadPathForThumbnail(thumbnail, attachment, observation);
119
+ const contentPath = path_1.default.join(this.baseDirPath, contentRelPath);
120
+ try {
121
+ const fd = yield util_1.default.promisify(fs_1.default.open)(contentPath, 'r');
122
+ return fs_1.default.createReadStream(contentPath, { fd });
123
+ }
124
+ catch (err) {
125
+ console.error(`error reading attachment thumbnail content`, contentPath, err);
126
+ return new entities_observations_1.AttachmentStoreError(entities_observations_1.AttachmentStoreErrorCode.StorageError, `error reading thumbnail ${minDimension} of attachment ${attachmentId} on observation ${observation.id}`);
127
+ }
128
+ });
129
+ }
130
+ deleteContent(attachment, observation) {
131
+ return __awaiter(this, void 0, void 0, function* () {
132
+ const attachmentOnObservation = observation.attachmentFor(attachment.id);
133
+ const thumbnails = attachment.thumbnails;
134
+ const contentRelPath = relativeReadPathForAttachment(attachment, observation);
135
+ const contentPath = path_1.default.join(this.baseDirPath, contentRelPath);
136
+ const rm = (path) => __awaiter(this, void 0, void 0, function* () {
137
+ if (!__classPrivateFieldGet(this, _FileSystemAttachmentStore_instances, "m", _FileSystemAttachmentStore_baseDirIsAncestorOf).call(this, path)) {
138
+ throw new Error(`cannot remove path ${path} because it is not a descendant of store base dir ${this.baseDirPath}`);
139
+ }
140
+ return yield util_1.default.promisify(fs_1.default.rm)(path);
141
+ });
142
+ const err = yield rm(contentPath).then(() => null, err => err);
143
+ if (err) {
144
+ // TODO: maybe instead move on and try to delete thumbnails too
145
+ const message = `error deleting content for attachment ${attachment} on observation ${observation.id}`;
146
+ console.error(message, err);
147
+ return new entities_observations_1.AttachmentStoreError(entities_observations_1.AttachmentStoreErrorCode.StorageError, `${message}: ${String(err)}`);
148
+ }
149
+ const thumbRemoves = yield Promise.all(thumbnails.map(thumb => {
150
+ const thumbRelPath = relativeReadPathForThumbnail(thumb, attachment, observation);
151
+ const thumbPath = path_1.default.join(this.baseDirPath, thumbRelPath);
152
+ return rm(thumbPath).then(() => ({ thumb, success: true }), err => {
153
+ console.error(`error deleting thumbnail ${thumb.minDimension} for attachment ${attachment} on observation ${observation.id} @ ${thumbPath}`, err);
154
+ return { thumb, success: false };
155
+ });
156
+ }));
157
+ const thumbUpdate = thumbRemoves.reduce((thumbUpdate, thumbRemove) => {
158
+ const { success, thumb } = thumbRemove;
159
+ if (success && thumb.contentLocator) {
160
+ const updatedThumb = Object.assign(Object.assign({}, (0, entities_observations_1.copyThumbnailAttrs)(thumb)), { contentLocator: undefined });
161
+ thumbUpdate = { isNecessary: true, thumbnails: thumbUpdate.thumbnails.concat(updatedThumb) };
162
+ }
163
+ else {
164
+ thumbUpdate = { isNecessary: thumbUpdate.isNecessary, thumbnails: thumbUpdate.thumbnails.concat(thumb) };
165
+ }
166
+ return thumbUpdate;
167
+ }, { isNecessary: false, thumbnails: [] });
168
+ if (attachmentOnObservation && (attachment.contentLocator || thumbUpdate.isNecessary)) {
169
+ return { contentLocator: undefined, thumbnails: thumbUpdate.thumbnails };
170
+ }
171
+ return null;
172
+ });
173
+ }
174
+ }
175
+ exports.FileSystemAttachmentStore = FileSystemAttachmentStore;
176
+ _FileSystemAttachmentStore_instances = new WeakSet(), _FileSystemAttachmentStore_saveContent = function _FileSystemAttachmentStore_saveContent(content, dest) {
177
+ const destResolved = path_1.default.resolve(dest);
178
+ if (!__classPrivateFieldGet(this, _FileSystemAttachmentStore_instances, "m", _FileSystemAttachmentStore_baseDirIsAncestorOf).call(this, destResolved)) {
179
+ return Promise.resolve(new entities_observations_1.AttachmentStoreError(entities_observations_1.AttachmentStoreErrorCode.StorageError, `content destination ${dest} is not a descendent of base dir ${this.baseDirPath}`));
180
+ }
181
+ const destBaseDirPath = path_1.default.dirname(destResolved);
182
+ const mkdir = () => util_1.default.promisify(fs_1.default.mkdir)(destBaseDirPath, { recursive: true }).then(_ => void (0));
183
+ const statSize = ((path) => util_1.default.promisify(fs_1.default.stat)(path).then(x => x.size));
184
+ if (content instanceof entities_observations_1.StagedAttachmentContentRef) {
185
+ const move = util_1.default.promisify(fs_1.default.rename);
186
+ const tempPath = path_1.default.join(this.pendingDirPath, content.id);
187
+ return mkdir()
188
+ .then(_ => move(tempPath, dest))
189
+ .then(_ => statSize(dest), err => {
190
+ const message = `error moving staged content ${tempPath} to ${dest}`;
191
+ console.error(message, err);
192
+ return new entities_observations_1.AttachmentStoreError(entities_observations_1.AttachmentStoreErrorCode.StorageError, message);
193
+ });
194
+ }
195
+ const pipe = util_1.default.promisify(stream_1.default.pipeline);
196
+ return mkdir()
197
+ .then(_ => fs_1.default.createWriteStream(dest))
198
+ .then(dest => pipe(content, dest))
199
+ .then(_ => statSize(dest), err => {
200
+ const message = `error saving source stream to path ${dest}`;
201
+ console.error(message, err);
202
+ return new entities_observations_1.AttachmentStoreError(entities_observations_1.AttachmentStoreErrorCode.StorageError, message);
203
+ });
204
+ }, _FileSystemAttachmentStore_baseDirIsAncestorOf = function _FileSystemAttachmentStore_baseDirIsAncestorOf(testPath) {
205
+ return path_1.default.relative(testPath, this.baseDirPath).split(path_1.default.sep).every(x => x === '..');
206
+ };
207
+ /**
208
+ * Create the directories for an attachment store at the given path if they
209
+ * do not exist. Return a file system attachment store that stores content
210
+ * under the given base directory. Return an error if there was an error
211
+ * creating the required directories.
212
+ * @param baseDirPath
213
+ * @returns {@link FileSystemAttachmentStore} or {@link FileSystemAttachmentStoreInitError}
214
+ */
215
+ function intializeAttachmentStore(baseDirPath) {
216
+ return __awaiter(this, void 0, void 0, function* () {
217
+ const mkdir = util_1.default.promisify(fs_1.default.mkdir);
218
+ baseDirPath = path_1.default.resolve(baseDirPath);
219
+ const pendingDirPath = path_1.default.resolve(baseDirPath, 'pending');
220
+ yield mkdir(pendingDirPath, { recursive: true }).catch(err => {
221
+ console.error(`error creating attachment store base direcgtory ${baseDirPath}:`, err);
222
+ return new FileSystemAttachmentStoreInitError(`error creating attachment store base direcgtory ${baseDirPath}: ${String(err)}`);
223
+ });
224
+ return new FileSystemAttachmentStore(FileSystemAttachmentStoreConstructorToken, baseDirPath, pendingDirPath);
225
+ });
226
+ }
227
+ exports.intializeAttachmentStore = intializeAttachmentStore;
228
+ class FileSystemAttachmentStoreInitError extends Error {
229
+ }
230
+ exports.FileSystemAttachmentStoreInitError = FileSystemAttachmentStoreInitError;
231
+ /**
232
+ * Return a path relative to the store's base directory suitable to write the
233
+ * file for the given attachment's main content bytes. If the attachment has
234
+ * a {@link Attachment.contentLocator contentLocator}, simply return that as
235
+ * the relative path. Otherwise, construct a relative path based on the
236
+ * property values of the attachment and its parent observation.
237
+ * @returns `string`
238
+ */
239
+ function relativeWritePathForAttachment(attachment, observation) {
240
+ if (attachment.contentLocator) {
241
+ return attachment.contentLocator;
242
+ }
243
+ const created = observation.createdAt;
244
+ const ext = mime_types_1.default.extension(attachment.contentType || '');
245
+ const baseDirPath = path_1.default.join(`event-${observation.eventId}`, String(created.getUTCFullYear()), String(created.getUTCMonth() + 1).padStart(2, '0'), String(created.getUTCDate()).padStart(2, '0'), observation.id, attachment.id + (ext ? `.${ext}` : ''));
246
+ return baseDirPath;
247
+ }
248
+ /**
249
+ * If the attachment has a non-empty {@link Attachment.contentLocator | `contentLocator`},
250
+ * return that. Otherwise, return the presumed path based on the observation
251
+ * and attachment attributes.
252
+ */
253
+ function relativeReadPathForAttachment(attachment, observation) {
254
+ if (attachment.contentLocator) {
255
+ return attachment.contentLocator;
256
+ }
257
+ return relativeWritePathForAttachment(attachment, observation);
258
+ }
259
+ function relativeWritePathForThumbnail(thumbnail, attachment, observation) {
260
+ if (thumbnail.contentLocator) {
261
+ return thumbnail.contentLocator;
262
+ }
263
+ const basePath = relativeWritePathForAttachment(attachment, observation);
264
+ const pathParts = path_1.default.parse(basePath);
265
+ return path_1.default.join(pathParts.dir, `${pathParts.name}-${thumbnail.minDimension}${pathParts.ext}`);
266
+ }
267
+ function relativeReadPathForThumbnail(thumbnail, attachment, observation) {
268
+ if (thumbnail.contentLocator) {
269
+ return thumbnail.contentLocator;
270
+ }
271
+ return relativeWritePathForThumbnail(thumbnail, attachment, observation);
272
+ }
273
+ const FileSystemAttachmentStoreConstructorToken = Symbol('FileSystemAttachmentStoreConstructorToken');
274
+ //# sourceMappingURL=adapters.observations.attachment_store.file_system.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.observations.attachment_store.file_system.js","sourceRoot":"","sources":["../../../src/adapters/observations/adapters.observations.attachment_store.file_system.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,4CAAmB;AACnB,gDAAuB;AACvB,oDAA2B;AAC3B,gDAAuB;AACvB,oDAA2B;AAC3B,6FAAgV;AAChV,4DAA6B;AAE7B,MAAa,yBAAyB;IAEpC,YAAY,KAAa,EAAW,WAAmB,EAAW,cAAsB;QAApD,gBAAW,GAAX,WAAW,CAAQ;QAAW,mBAAc,GAAd,cAAc,CAAQ;;QACtF,IAAI,KAAK,KAAK,yCAAyC,EAAE;YACvD,MAAM,IAAI,kCAAkC,CAAC,0BAA0B,CAAC,CAAA;SACzE;IACH,CAAC;IAEK,mBAAmB;;YACvB,MAAM,EAAE,GAAG,IAAA,gBAAM,GAAE,CAAA;YACnB,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE,EAAE,CAAC,CAAA;YACnD,MAAM,YAAY,GAAG,YAAE,CAAC,iBAAiB,CAAC,QAAQ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Q,CAAC,CAAA;IACtC,OAAO,cAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,IAAI,IAAI,SAAS,CAAC,YAAY,GAAG,SAAS,CAAC,GAAG,EAAE,CAAC,CAAA;AAChG,CAAC;AAED,SAAS,4BAA4B,CAAC,SAAoB,EAAE,UAAsB,EAAE,WAAwB;IAC1G,IAAI,SAAS,CAAC,cAAc,EAAE;QAC5B,OAAO,SAAS,CAAC,cAAc,CAAA;KAChC;IACD,OAAO,6BAA6B,CAAC,SAAS,EAAE,UAAU,EAAE,WAAW,CAAC,CAAA;AAC1E,CAAC;AAED,MAAM,yCAAyC,GAAG,MAAM,CAAC,2CAA2C,CAAC,CAAA"}
@@ -0,0 +1,40 @@
1
+ import express from 'express';
2
+ import { AllocateObservationId, ExoAttachment, ExoObservation, ObservationRequest, ReadAttachmentContent, SaveObservation, StoreAttachmentContent } from '../../app.api/observations/app.api.observations';
3
+ import { AttachmentStore, EventScopedObservationRepository, ObservationState } from '../../entities/observations/entities.observations';
4
+ import { MageEvent, MageEventId } from '../../entities/events/entities.events';
5
+ import busboy from 'busboy';
6
+ declare module 'express-serve-static-core' {
7
+ interface Request {
8
+ attachmentUpload: busboy.Busboy | null;
9
+ }
10
+ }
11
+ export interface ObservationAppLayer {
12
+ allocateObservationId: AllocateObservationId;
13
+ saveObservation: SaveObservation;
14
+ storeAttachmentContent: StoreAttachmentContent;
15
+ readAttachmentContent: ReadAttachmentContent;
16
+ }
17
+ export interface ObservationWebAppRequestFactory {
18
+ <Params extends object>(req: express.Request, params?: Params): Params & ObservationRequest<unknown>;
19
+ }
20
+ export interface EnsureEventScope {
21
+ (eventId: MageEventId): Promise<null | {
22
+ mageEvent: MageEvent;
23
+ observationRepository: EventScopedObservationRepository;
24
+ }>;
25
+ }
26
+ export declare function ObservationRoutes(app: ObservationAppLayer, attachmentStore: AttachmentStore, createAppRequest: ObservationWebAppRequestFactory): express.Router;
27
+ export declare type WebObservation = Omit<ExoObservation, 'attachments' | 'state'> & {
28
+ url: string;
29
+ state?: WebObservationState;
30
+ attachments: WebAttachment[];
31
+ };
32
+ export declare type WebObservationState = ObservationState & {
33
+ url: string;
34
+ };
35
+ export declare type WebAttachment = ExoAttachment & {
36
+ url?: string;
37
+ };
38
+ export declare function jsonForObservation(o: ExoObservation, baseUrl: string): WebObservation;
39
+ export declare function jsonForAttachment(a: ExoAttachment, observationUrl: string): WebAttachment;
40
+ //# sourceMappingURL=adapters.observations.controllers.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.observations.controllers.web.d.ts","sourceRoot":"","sources":["../../../src/adapters/observations/adapters.observations.controllers.web.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,SAAS,CAAA;AAE7B,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAgC,cAAc,EAAqB,kBAAkB,EAAE,qBAAqB,EAAgC,eAAe,EAA0B,sBAAsB,EAAiC,MAAM,iDAAiD,CAAA;AAChV,OAAO,EAAE,eAAe,EAAE,gCAAgC,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAA;AACvI,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,uCAAuC,CAAA;AAC9E,OAAO,MAAM,MAAM,QAAQ,CAAA;AAG3B,OAAO,QAAQ,2BAA2B,CAAC;IACzC,UAAU,OAAO;QACf,gBAAgB,EAAE,MAAM,CAAC,MAAM,GAAG,IAAI,CAAA;KACvC;CACF;AAED,MAAM,WAAW,mBAAmB;IAClC,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,eAAe,EAAE,eAAe,CAAA;IAChC,sBAAsB,EAAE,sBAAsB,CAAA;IAC9C,qBAAqB,EAAE,qBAAqB,CAAA;CAC7C;AAED,MAAM,WAAW,+BAA+B;IAC9C,CAAC,MAAM,SAAS,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAA;CACrG;AAED,MAAM,WAAW,gBAAgB;IAC/B,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,GAAG;QAAE,SAAS,EAAE,SAAS,CAAC;QAAC,qBAAqB,EAAE,gCAAgC,CAAA;KAAE,CAAC,CAAA;CAC1H;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,mBAAmB,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,+BAA+B,GAAG,OAAO,CAAC,MAAM,CAyK/J;AAED,oBAAY,cAAc,GAAG,IAAI,CAAC,cAAc,EAAE,aAAa,GAAG,OAAO,CAAC,GAAG;IAC3E,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,CAAC,EAAE,mBAAmB,CAAA;IAC3B,WAAW,EAAE,aAAa,EAAE,CAAA;CAC7B,CAAA;AAED,oBAAY,mBAAmB,GAAG,gBAAgB,GAAG;IACnD,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED,oBAAY,aAAa,GAAG,aAAa,GAAG;IAC1C,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,CAAA;AAED,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,cAAc,EAAE,OAAO,EAAE,MAAM,GAAG,cAAc,CAQrF;AAED,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,GAAG,aAAa,CAEzF"}
@@ -0,0 +1,196 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.jsonForAttachment = exports.jsonForObservation = exports.ObservationRoutes = void 0;
16
+ const express_1 = __importDefault(require("express"));
17
+ const adapters_controllers_web_1 = require("../adapters.controllers.web");
18
+ const busboy_1 = __importDefault(require("busboy"));
19
+ const app_api_errors_1 = require("../../app.api/app.api.errors");
20
+ function ObservationRoutes(app, attachmentStore, createAppRequest) {
21
+ const routes = express_1.default.Router().use(express_1.default.json());
22
+ routes.route('/id')
23
+ .post((req, res, next) => __awaiter(this, void 0, void 0, function* () {
24
+ const appReq = createAppRequest(req);
25
+ const appRes = yield app.allocateObservationId(appReq);
26
+ const id = appRes.success;
27
+ const path = `${req.baseUrl}/${id}`;
28
+ if (id) {
29
+ // TODO: add location header? kind of a gray area restfully speaking
30
+ return res.status(201).location(path).json({
31
+ id,
32
+ eventId: appReq.context.mageEvent.id,
33
+ url: `${req.getRoot()}${path}`
34
+ });
35
+ }
36
+ next(appRes.error);
37
+ }));
38
+ routes.route('/:observationId/attachments/:attachmentId')
39
+ .put((req, res, next) => {
40
+ /*
41
+ encapsulate the busboy init in a middleware so the request can
42
+ fail-fast when busboy throws a validation error
43
+ */
44
+ try {
45
+ req.attachmentUpload = (0, busboy_1.default)({
46
+ headers: req.headers,
47
+ limits: { files: 1, fields: 0 }
48
+ });
49
+ }
50
+ catch (err) {
51
+ console.error('error initializing attachment upload\n', req.params, '\nheaders:\n', req.headers, '\n', err);
52
+ return res.status(400).json({ message: err instanceof Error ? err.message : String(err) });
53
+ }
54
+ next();
55
+ }, (req, res, next) => __awaiter(this, void 0, void 0, function* () {
56
+ const afterUploadStreamEvent = 'afterUploadStream';
57
+ const sendInvalidRequestStructure = () => next((0, app_api_errors_1.invalidInput)(`request must contain only one file part named 'attachment'`));
58
+ const afterUploadStream = (finishResponse) => {
59
+ var _a, _b;
60
+ if ((_a = req.attachmentUpload) === null || _a === void 0 ? void 0 : _a.listenerCount(afterUploadStreamEvent)) {
61
+ return;
62
+ }
63
+ if ((_b = req.attachmentUpload) === null || _b === void 0 ? void 0 : _b.writable) {
64
+ return void (req.attachmentUpload.on(afterUploadStreamEvent, finishResponse));
65
+ }
66
+ finishResponse();
67
+ };
68
+ const { observationId, attachmentId } = req.params;
69
+ req.pipe(req.attachmentUpload
70
+ .on('file', (fieldName, stream, info) => __awaiter(this, void 0, void 0, function* () {
71
+ if (fieldName !== 'attachment') {
72
+ // per busboy docs, drain the file stream and move on
73
+ console.error(`unexpected file entry '${fieldName}' uploading attachment ${attachmentId} on observation ${observationId}`);
74
+ stream.resume();
75
+ return afterUploadStream(sendInvalidRequestStructure);
76
+ }
77
+ const content = {
78
+ bytes: stream,
79
+ mediaType: info.mimeType,
80
+ name: info.filename,
81
+ };
82
+ const appReqParams = { observationId, attachmentId, content };
83
+ const appReq = createAppRequest(req, appReqParams);
84
+ const appRes = yield app.storeAttachmentContent(appReq);
85
+ if (appRes.success) {
86
+ const obs = appRes.success;
87
+ const attachment = obs.attachments.find(x => x.id === appReq.attachmentId);
88
+ const attachmentJson = jsonForAttachment(attachment, `${qualifiedBaseUrl(req)}/${observationId}`);
89
+ console.info(`successfully stored attachment ${attachmentId} on observation ${observationId}`);
90
+ return void (afterUploadStream(() => res.json(attachmentJson)));
91
+ }
92
+ if (appRes.error) {
93
+ const error = appRes.error;
94
+ afterUploadStream(() => next(error));
95
+ }
96
+ else {
97
+ afterUploadStream(sendInvalidRequestStructure);
98
+ }
99
+ /*
100
+ per busboy docs, drain the stream and ignore the contents; necessary
101
+ for the busboy stream to terminate properly
102
+ */
103
+ stream.resume();
104
+ }))
105
+ .on('field', (fieldName, content, info) => {
106
+ console.error(`unexpected field ${fieldName} uploading attachment ${attachmentId} on observation ${observationId}`);
107
+ afterUploadStream(sendInvalidRequestStructure);
108
+ })
109
+ .on('filesLimit', () => {
110
+ console.error(`too many file parts in upload request for attachment ${attachmentId} on observation ${observationId}`);
111
+ afterUploadStream(sendInvalidRequestStructure);
112
+ })
113
+ .on('fieldsLimit', () => {
114
+ console.error(`too many field parts in upload request for attachment ${attachmentId} on observation ${observationId}`);
115
+ afterUploadStream(sendInvalidRequestStructure);
116
+ })
117
+ .on('close', () => {
118
+ var _a, _b;
119
+ (_a = req.attachmentUpload) === null || _a === void 0 ? void 0 : _a.emit(afterUploadStreamEvent);
120
+ (_b = req.attachmentUpload) === null || _b === void 0 ? void 0 : _b.removeAllListeners();
121
+ }));
122
+ }))
123
+ .get((req, res, next) => __awaiter(this, void 0, void 0, function* () {
124
+ const minDimension = parseInt(String(req.query.size), 10) || undefined;
125
+ const contentRange = req.headers.range ?
126
+ req.headers.range.replace(/bytes=/i, '').split('-').map(x => parseInt(x, 10)).filter(x => typeof x === 'number' && !Number.isNaN(x)) : [];
127
+ const appReq = createAppRequest(req, {
128
+ observationId: req.params.observationId,
129
+ attachmentId: req.params.attachmentId,
130
+ minDimension,
131
+ contentRange: contentRange.length === 2 ? { start: contentRange[0], end: contentRange[1] } : undefined
132
+ });
133
+ const appRes = yield app.readAttachmentContent(appReq);
134
+ if (appRes.error) {
135
+ return next(appRes.error);
136
+ }
137
+ const content = appRes.success;
138
+ if (!content) {
139
+ return res.status(500).json({ message: 'unknown application response' });
140
+ }
141
+ const { bytesRange } = content;
142
+ const headers = {
143
+ 'content-type': String(content.attachment.contentType),
144
+ 'content-length': String(bytesRange ? bytesRange.end - bytesRange.start + 1 : content.attachment.size)
145
+ };
146
+ if (bytesRange) {
147
+ headers['content-range'] = `bytes ${bytesRange.start}-${bytesRange.end}/${content.attachment.size || '*'}`;
148
+ }
149
+ return content.bytes.pipe(res.writeHead(bytesRange ? 206 : 200, headers));
150
+ }))
151
+ .delete((req, res, next) => __awaiter(this, void 0, void 0, function* () {
152
+ // TODO: this should go away when ios app is fixed to stop sending delete requests
153
+ res.sendStatus(204);
154
+ }));
155
+ routes.route('/:observationId')
156
+ .put((req, res, next) => __awaiter(this, void 0, void 0, function* () {
157
+ const body = req.body;
158
+ const observationId = req.params.observationId;
159
+ if (body.hasOwnProperty('id') && body.id !== observationId) {
160
+ return res.status(400).json({ message: 'Body observation ID does not match path observation ID' });
161
+ }
162
+ const mod = {
163
+ id: observationId,
164
+ type: 'Feature',
165
+ geometry: req.body.geometry,
166
+ properties: {
167
+ timestamp: new Date(body.properties.timestamp),
168
+ forms: body.properties.forms
169
+ }
170
+ };
171
+ const appReq = createAppRequest(req, { observation: mod });
172
+ if (body.hasOwnProperty('eventId') && body.eventId !== appReq.context.mageEvent.id) {
173
+ return res.status(400).json({ message: 'Body event ID does not match path event ID' });
174
+ }
175
+ const appRes = yield app.saveObservation(appReq);
176
+ if (appRes.success) {
177
+ return res.json(jsonForObservation(appRes.success, `${qualifiedBaseUrl(req)}`));
178
+ }
179
+ next(appRes.error);
180
+ }));
181
+ return routes.use(adapters_controllers_web_1.compatibilityMageAppErrorHandler);
182
+ }
183
+ exports.ObservationRoutes = ObservationRoutes;
184
+ function jsonForObservation(o, baseUrl) {
185
+ const obsUrl = `${baseUrl}/${o.id}`;
186
+ return Object.assign(Object.assign({}, o), { url: obsUrl, state: o.state ? Object.assign(Object.assign({}, o.state), { url: `${obsUrl}/states/${o.state.id}` }) : void (0), attachments: o.attachments.map(a => jsonForAttachment(a, obsUrl)) });
187
+ }
188
+ exports.jsonForObservation = jsonForObservation;
189
+ function jsonForAttachment(a, observationUrl) {
190
+ return Object.assign(Object.assign({}, a), { url: a.contentStored ? `${observationUrl}/attachments/${a.id}` : void (0) });
191
+ }
192
+ exports.jsonForAttachment = jsonForAttachment;
193
+ function qualifiedBaseUrl(req) {
194
+ return req.getRoot() + req.baseUrl;
195
+ }
196
+ //# sourceMappingURL=adapters.observations.controllers.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.observations.controllers.web.js","sourceRoot":"","sources":["../../../src/adapters/observations/adapters.observations.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C,EAAY,EAAE,IAAG,CAAC,CAAC,KAAI,CAAC,CAAC,CAAC,EAC1F,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,IAClE;AACH,CAAC;AARD,gDAQC;AAED,SAAgB,iBAAiB,CAAC,CAAgB,EAAE,cAAsB;IACxE,uCAAY,CAAC,KAAE,GAAG,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,cAAc,gBAAgB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAI,CAAC,CAAC,CAAC,IAAE;AAC3F,CAAC;AAFD,8CAEC;AAED,SAAS,gBAAgB,CAAC,GAAoB;IAC5C,OAAO,GAAG,CAAC,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,CAAA;AACpC,CAAC"}
@@ -0,0 +1,30 @@
1
+ /// <reference types="node" />
2
+ import { MageEvent, MageEventId } from '../../entities/events/entities.events';
3
+ import { AttachmentId, AttachmentNotFoundError, AttachmentPatchAttrs, EventScopedObservationRepository, FormEntryId, Observation, ObservationAttrs, ObservationId, ObservationRepositoryError, ObservationRepositoryForEvent } from '../../entities/observations/entities.observations';
4
+ import { BaseMongooseRepository } from '../base/adapters.base.db.mongoose';
5
+ import mongoose from 'mongoose';
6
+ import * as legacy from '../../models/observation';
7
+ import { MageEventDocument } from '../../models/event';
8
+ import { PageOf, PagingParameters } from '../../entities/entities.global';
9
+ import { MongooseMageEventRepository } from '../events/adapters.events.db.mongoose';
10
+ import { EventEmitter } from 'events';
11
+ export declare type ObservationIdDocument = mongoose.Document;
12
+ export declare type ObservationIdModel = mongoose.Model<ObservationIdDocument>;
13
+ export declare class MongooseObservationRepository extends BaseMongooseRepository<legacy.ObservationDocument, legacy.ObservationModel, ObservationAttrs> implements EventScopedObservationRepository {
14
+ readonly eventLookup: (eventId: MageEventId) => Promise<MageEvent | null>;
15
+ readonly domainEvents: EventEmitter;
16
+ readonly eventScope: MageEventId;
17
+ readonly idModel: ObservationIdModel;
18
+ constructor(eventDoc: Pick<MageEventDocument, 'id' | 'collectionName'>, eventLookup: (eventId: MageEventId) => Promise<MageEvent | null>, domainEvents: EventEmitter);
19
+ allocateObservationId(): Promise<ObservationId>;
20
+ save(observation: Observation): Promise<Observation | ObservationRepositoryError>;
21
+ findById(id: ObservationId): Promise<Observation | null>;
22
+ findLatest(): Promise<ObservationAttrs | null>;
23
+ findLastModifiedAfter(timestamp: number, paging: PagingParameters): Promise<PageOf<Observation>>;
24
+ patchAttachment(observation: Observation, attachmentId: AttachmentId, patch: AttachmentPatchAttrs): Promise<Observation | AttachmentNotFoundError | null>;
25
+ nextFormEntryIds(count?: number): Promise<FormEntryId[]>;
26
+ nextAttachmentIds(count?: number): Promise<AttachmentId[]>;
27
+ }
28
+ export declare const createObservationRepositoryFactory: (eventRepo: MongooseMageEventRepository, domainEvents: EventEmitter) => ObservationRepositoryForEvent;
29
+ export declare function docToEntity(doc: legacy.ObservationDocument, eventId: MageEventId): ObservationAttrs;
30
+ //# sourceMappingURL=adapters.observations.db.mongoose.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapters.observations.db.mongoose.d.ts","sourceRoot":"","sources":["../../../src/adapters/observations/adapters.observations.db.mongoose.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAuB,MAAM,uCAAuC,CAAA;AACnG,OAAO,EAA2C,YAAY,EAAE,uBAAuB,EAAE,oBAAoB,EAAwB,gCAAgC,EAAa,WAAW,EAAE,WAAW,EAAE,gBAAgB,EAAE,aAAa,EAA4B,0BAA0B,EAAkC,6BAA6B,EAAgD,MAAM,mDAAmD,CAAA;AACzc,OAAO,EAAE,sBAAsB,EAAmB,MAAM,mCAAmC,CAAA;AAC3F,OAAO,QAAQ,MAAM,UAAU,CAAA;AAC/B,OAAO,KAAK,MAAM,MAAM,0BAA0B,CAAA;AAClD,OAAO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