@budibase/backend-core 3.2.26 → 3.2.27

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 (466) hide show
  1. package/dist/index.js +62 -23
  2. package/dist/index.js.map +4 -4
  3. package/dist/index.js.meta.json +1 -1
  4. package/dist/package.json +7 -7
  5. package/dist/plugins.js.map +2 -2
  6. package/dist/plugins.js.meta.json +1 -1
  7. package/dist/src/events/processors/types.d.ts +1 -1
  8. package/dist/src/events/publishers/index.d.ts +1 -0
  9. package/dist/src/events/publishers/rowAction.d.ts +6 -0
  10. package/dist/src/events/publishers/table.d.ts +2 -2
  11. package/dist/src/events/publishers/view.d.ts +17 -6
  12. package/dist/src/index.d.ts +11 -11
  13. package/dist/src/platform/platformDb.d.ts +1 -1
  14. package/dist/src/queue/queue.d.ts +1 -1
  15. package/dist/src/tenancy/db.d.ts +1 -1
  16. package/package.json +7 -7
  17. package/dist/jest.config.js +0 -25
  18. package/dist/jest.config.js.map +0 -1
  19. package/dist/src/accounts/accounts.js +0 -83
  20. package/dist/src/accounts/accounts.js.map +0 -1
  21. package/dist/src/accounts/api.js +0 -102
  22. package/dist/src/accounts/api.js.map +0 -1
  23. package/dist/src/accounts/index.js +0 -18
  24. package/dist/src/accounts/index.js.map +0 -1
  25. package/dist/src/auth/auth.js +0 -198
  26. package/dist/src/auth/auth.js.map +0 -1
  27. package/dist/src/auth/index.js +0 -18
  28. package/dist/src/auth/index.js.map +0 -1
  29. package/dist/src/blacklist/blacklist.js +0 -75
  30. package/dist/src/blacklist/blacklist.js.map +0 -1
  31. package/dist/src/blacklist/index.js +0 -18
  32. package/dist/src/blacklist/index.js.map +0 -1
  33. package/dist/src/cache/appMetadata.js +0 -96
  34. package/dist/src/cache/appMetadata.js.map +0 -1
  35. package/dist/src/cache/base/index.js +0 -189
  36. package/dist/src/cache/base/index.js.map +0 -1
  37. package/dist/src/cache/docWritethrough.js +0 -123
  38. package/dist/src/cache/docWritethrough.js.map +0 -1
  39. package/dist/src/cache/generic.js +0 -37
  40. package/dist/src/cache/generic.js.map +0 -1
  41. package/dist/src/cache/index.js +0 -48
  42. package/dist/src/cache/index.js.map +0 -1
  43. package/dist/src/cache/invite.js +0 -128
  44. package/dist/src/cache/invite.js.map +0 -1
  45. package/dist/src/cache/passwordReset.js +0 -92
  46. package/dist/src/cache/passwordReset.js.map +0 -1
  47. package/dist/src/cache/user.js +0 -183
  48. package/dist/src/cache/user.js.map +0 -1
  49. package/dist/src/cache/writethrough.js +0 -170
  50. package/dist/src/cache/writethrough.js.map +0 -1
  51. package/dist/src/configs/configs.js +0 -294
  52. package/dist/src/configs/configs.js.map +0 -1
  53. package/dist/src/configs/index.js +0 -18
  54. package/dist/src/configs/index.js.map +0 -1
  55. package/dist/src/constants/db.js +0 -75
  56. package/dist/src/constants/db.js.map +0 -1
  57. package/dist/src/constants/index.js +0 -19
  58. package/dist/src/constants/index.js.map +0 -1
  59. package/dist/src/constants/misc.js +0 -40
  60. package/dist/src/constants/misc.js.map +0 -1
  61. package/dist/src/context/Context.js +0 -14
  62. package/dist/src/context/Context.js.map +0 -1
  63. package/dist/src/context/identity.js +0 -81
  64. package/dist/src/context/identity.js.map +0 -1
  65. package/dist/src/context/index.js +0 -44
  66. package/dist/src/context/index.js.map +0 -1
  67. package/dist/src/context/mainContext.js +0 -446
  68. package/dist/src/context/mainContext.js.map +0 -1
  69. package/dist/src/context/types.js +0 -3
  70. package/dist/src/context/types.js.map +0 -1
  71. package/dist/src/db/Replication.js +0 -90
  72. package/dist/src/db/Replication.js.map +0 -1
  73. package/dist/src/db/couch/DatabaseImpl.js +0 -475
  74. package/dist/src/db/couch/DatabaseImpl.js.map +0 -1
  75. package/dist/src/db/couch/connections.js +0 -101
  76. package/dist/src/db/couch/connections.js.map +0 -1
  77. package/dist/src/db/couch/index.js +0 -26
  78. package/dist/src/db/couch/index.js.map +0 -1
  79. package/dist/src/db/couch/pouchDB.js +0 -108
  80. package/dist/src/db/couch/pouchDB.js.map +0 -1
  81. package/dist/src/db/couch/pouchDump.js +0 -2
  82. package/dist/src/db/couch/pouchDump.js.map +0 -1
  83. package/dist/src/db/couch/utils.js +0 -60
  84. package/dist/src/db/couch/utils.js.map +0 -1
  85. package/dist/src/db/db.js +0 -47
  86. package/dist/src/db/db.js.map +0 -1
  87. package/dist/src/db/errors.js +0 -21
  88. package/dist/src/db/errors.js.map +0 -1
  89. package/dist/src/db/index.js +0 -58
  90. package/dist/src/db/index.js.map +0 -1
  91. package/dist/src/db/instrumentation.js +0 -202
  92. package/dist/src/db/instrumentation.js.map +0 -1
  93. package/dist/src/db/lucene.js +0 -638
  94. package/dist/src/db/lucene.js.map +0 -1
  95. package/dist/src/db/searchIndexes/index.js +0 -18
  96. package/dist/src/db/searchIndexes/index.js.map +0 -1
  97. package/dist/src/db/searchIndexes/searchIndexes.js +0 -76
  98. package/dist/src/db/searchIndexes/searchIndexes.js.map +0 -1
  99. package/dist/src/db/utils.js +0 -212
  100. package/dist/src/db/utils.js.map +0 -1
  101. package/dist/src/db/views.js +0 -224
  102. package/dist/src/db/views.js.map +0 -1
  103. package/dist/src/docIds/conversions.js +0 -62
  104. package/dist/src/docIds/conversions.js.map +0 -1
  105. package/dist/src/docIds/ids.js +0 -125
  106. package/dist/src/docIds/ids.js.map +0 -1
  107. package/dist/src/docIds/index.js +0 -19
  108. package/dist/src/docIds/index.js.map +0 -1
  109. package/dist/src/docIds/newid.js +0 -8
  110. package/dist/src/docIds/newid.js.map +0 -1
  111. package/dist/src/docIds/params.js +0 -141
  112. package/dist/src/docIds/params.js.map +0 -1
  113. package/dist/src/docUpdates/index.js +0 -35
  114. package/dist/src/docUpdates/index.js.map +0 -1
  115. package/dist/src/environment.js +0 -182
  116. package/dist/src/environment.js.map +0 -1
  117. package/dist/src/errors/errors.js +0 -97
  118. package/dist/src/errors/errors.js.map +0 -1
  119. package/dist/src/errors/index.js +0 -18
  120. package/dist/src/errors/index.js.map +0 -1
  121. package/dist/src/events/analytics.js +0 -52
  122. package/dist/src/events/analytics.js.map +0 -1
  123. package/dist/src/events/asyncEvents/index.js +0 -19
  124. package/dist/src/events/asyncEvents/index.js.map +0 -1
  125. package/dist/src/events/asyncEvents/publisher.js +0 -26
  126. package/dist/src/events/asyncEvents/publisher.js.map +0 -1
  127. package/dist/src/events/asyncEvents/queue.js +0 -26
  128. package/dist/src/events/asyncEvents/queue.js.map +0 -1
  129. package/dist/src/events/backfill.js +0 -189
  130. package/dist/src/events/backfill.js.map +0 -1
  131. package/dist/src/events/documentId.js +0 -27
  132. package/dist/src/events/documentId.js.map +0 -1
  133. package/dist/src/events/events.js +0 -87
  134. package/dist/src/events/events.js.map +0 -1
  135. package/dist/src/events/identification.js +0 -299
  136. package/dist/src/events/identification.js.map +0 -1
  137. package/dist/src/events/index.js +0 -59
  138. package/dist/src/events/index.js.map +0 -1
  139. package/dist/src/events/processors/AnalyticsProcessor.js +0 -103
  140. package/dist/src/events/processors/AnalyticsProcessor.js.map +0 -1
  141. package/dist/src/events/processors/AuditLogsProcessor.js +0 -86
  142. package/dist/src/events/processors/AuditLogsProcessor.js.map +0 -1
  143. package/dist/src/events/processors/LoggingProcessor.js +0 -47
  144. package/dist/src/events/processors/LoggingProcessor.js.map +0 -1
  145. package/dist/src/events/processors/Processors.js +0 -52
  146. package/dist/src/events/processors/Processors.js.map +0 -1
  147. package/dist/src/events/processors/async/DocumentUpdateProcessor.js +0 -44
  148. package/dist/src/events/processors/async/DocumentUpdateProcessor.js.map +0 -1
  149. package/dist/src/events/processors/index.js +0 -23
  150. package/dist/src/events/processors/index.js.map +0 -1
  151. package/dist/src/events/processors/posthog/PosthogProcessor.js +0 -149
  152. package/dist/src/events/processors/posthog/PosthogProcessor.js.map +0 -1
  153. package/dist/src/events/processors/posthog/index.js +0 -8
  154. package/dist/src/events/processors/posthog/index.js.map +0 -1
  155. package/dist/src/events/processors/posthog/rateLimiting.js +0 -129
  156. package/dist/src/events/processors/posthog/rateLimiting.js.map +0 -1
  157. package/dist/src/events/processors/types.js +0 -3
  158. package/dist/src/events/processors/types.js.map +0 -1
  159. package/dist/src/events/publishers/account.js +0 -43
  160. package/dist/src/events/publishers/account.js.map +0 -1
  161. package/dist/src/events/publishers/ai.js +0 -30
  162. package/dist/src/events/publishers/ai.js.map +0 -1
  163. package/dist/src/events/publishers/app.js +0 -166
  164. package/dist/src/events/publishers/app.js.map +0 -1
  165. package/dist/src/events/publishers/auditLog.js +0 -34
  166. package/dist/src/events/publishers/auditLog.js.map +0 -1
  167. package/dist/src/events/publishers/auth.js +0 -80
  168. package/dist/src/events/publishers/auth.js.map +0 -1
  169. package/dist/src/events/publishers/automation.js +0 -117
  170. package/dist/src/events/publishers/automation.js.map +0 -1
  171. package/dist/src/events/publishers/backfill.js +0 -85
  172. package/dist/src/events/publishers/backfill.js.map +0 -1
  173. package/dist/src/events/publishers/backup.js +0 -41
  174. package/dist/src/events/publishers/backup.js.map +0 -1
  175. package/dist/src/events/publishers/datasource.js +0 -54
  176. package/dist/src/events/publishers/datasource.js.map +0 -1
  177. package/dist/src/events/publishers/email.js +0 -30
  178. package/dist/src/events/publishers/email.js.map +0 -1
  179. package/dist/src/events/publishers/environmentVariable.js +0 -44
  180. package/dist/src/events/publishers/environmentVariable.js.map +0 -1
  181. package/dist/src/events/publishers/group.js +0 -107
  182. package/dist/src/events/publishers/group.js.map +0 -1
  183. package/dist/src/events/publishers/index.js +0 -57
  184. package/dist/src/events/publishers/index.js.map +0 -1
  185. package/dist/src/events/publishers/installation.js +0 -52
  186. package/dist/src/events/publishers/installation.js.map +0 -1
  187. package/dist/src/events/publishers/layout.js +0 -34
  188. package/dist/src/events/publishers/layout.js.map +0 -1
  189. package/dist/src/events/publishers/license.js +0 -77
  190. package/dist/src/events/publishers/license.js.map +0 -1
  191. package/dist/src/events/publishers/org.js +0 -52
  192. package/dist/src/events/publishers/org.js.map +0 -1
  193. package/dist/src/events/publishers/plugin.js +0 -55
  194. package/dist/src/events/publishers/plugin.js.map +0 -1
  195. package/dist/src/events/publishers/query.js +0 -74
  196. package/dist/src/events/publishers/query.js.map +0 -1
  197. package/dist/src/events/publishers/role.js +0 -69
  198. package/dist/src/events/publishers/role.js.map +0 -1
  199. package/dist/src/events/publishers/rows.js +0 -32
  200. package/dist/src/events/publishers/rows.js.map +0 -1
  201. package/dist/src/events/publishers/screen.js +0 -46
  202. package/dist/src/events/publishers/screen.js.map +0 -1
  203. package/dist/src/events/publishers/serve.js +0 -47
  204. package/dist/src/events/publishers/serve.js.map +0 -1
  205. package/dist/src/events/publishers/table.js +0 -77
  206. package/dist/src/events/publishers/table.js.map +0 -1
  207. package/dist/src/events/publishers/user.js +0 -201
  208. package/dist/src/events/publishers/user.js.map +0 -1
  209. package/dist/src/events/publishers/view.js +0 -111
  210. package/dist/src/events/publishers/view.js.map +0 -1
  211. package/dist/src/features/features.js +0 -271
  212. package/dist/src/features/features.js.map +0 -1
  213. package/dist/src/features/index.js +0 -42
  214. package/dist/src/features/index.js.map +0 -1
  215. package/dist/src/features/tests/utils.js +0 -56
  216. package/dist/src/features/tests/utils.js.map +0 -1
  217. package/dist/src/helpers.js +0 -13
  218. package/dist/src/helpers.js.map +0 -1
  219. package/dist/src/index.js +0 -99
  220. package/dist/src/index.js.map +0 -1
  221. package/dist/src/installation.js +0 -159
  222. package/dist/src/installation.js.map +0 -1
  223. package/dist/src/logging/alerts.js +0 -23
  224. package/dist/src/logging/alerts.js.map +0 -1
  225. package/dist/src/logging/correlation/correlation.js +0 -18
  226. package/dist/src/logging/correlation/correlation.js.map +0 -1
  227. package/dist/src/logging/correlation/index.js +0 -18
  228. package/dist/src/logging/correlation/index.js.map +0 -1
  229. package/dist/src/logging/correlation/middleware.js +0 -17
  230. package/dist/src/logging/correlation/middleware.js.map +0 -1
  231. package/dist/src/logging/index.js +0 -45
  232. package/dist/src/logging/index.js.map +0 -1
  233. package/dist/src/logging/pino/logger.js +0 -234
  234. package/dist/src/logging/pino/logger.js.map +0 -1
  235. package/dist/src/logging/pino/middleware.js +0 -46
  236. package/dist/src/logging/pino/middleware.js.map +0 -1
  237. package/dist/src/logging/system.js +0 -110
  238. package/dist/src/logging/system.js.map +0 -1
  239. package/dist/src/middleware/adminOnly.js +0 -19
  240. package/dist/src/middleware/adminOnly.js.map +0 -1
  241. package/dist/src/middleware/auditLog.js +0 -18
  242. package/dist/src/middleware/auditLog.js.map +0 -1
  243. package/dist/src/middleware/authenticated.js +0 -254
  244. package/dist/src/middleware/authenticated.js.map +0 -1
  245. package/dist/src/middleware/builderOnly.js +0 -33
  246. package/dist/src/middleware/builderOnly.js.map +0 -1
  247. package/dist/src/middleware/builderOrAdmin.js +0 -33
  248. package/dist/src/middleware/builderOrAdmin.js.map +0 -1
  249. package/dist/src/middleware/contentSecurityPolicy.js +0 -124
  250. package/dist/src/middleware/contentSecurityPolicy.js.map +0 -1
  251. package/dist/src/middleware/csrf.js +0 -81
  252. package/dist/src/middleware/csrf.js.map +0 -1
  253. package/dist/src/middleware/errorHandling.js +0 -88
  254. package/dist/src/middleware/errorHandling.js.map +0 -1
  255. package/dist/src/middleware/index.js +0 -79
  256. package/dist/src/middleware/index.js.map +0 -1
  257. package/dist/src/middleware/internalApi.js +0 -30
  258. package/dist/src/middleware/internalApi.js.map +0 -1
  259. package/dist/src/middleware/ip.js +0 -23
  260. package/dist/src/middleware/ip.js.map +0 -1
  261. package/dist/src/middleware/joi-validator.js +0 -53
  262. package/dist/src/middleware/joi-validator.js.map +0 -1
  263. package/dist/src/middleware/matchers.js +0 -36
  264. package/dist/src/middleware/matchers.js.map +0 -1
  265. package/dist/src/middleware/passport/datasource/google.js +0 -107
  266. package/dist/src/middleware/passport/datasource/google.js.map +0 -1
  267. package/dist/src/middleware/passport/local.js +0 -91
  268. package/dist/src/middleware/passport/local.js.map +0 -1
  269. package/dist/src/middleware/passport/sso/google.js +0 -98
  270. package/dist/src/middleware/passport/sso/google.js.map +0 -1
  271. package/dist/src/middleware/passport/sso/oidc.js +0 -158
  272. package/dist/src/middleware/passport/sso/oidc.js.map +0 -1
  273. package/dist/src/middleware/passport/sso/sso.js +0 -150
  274. package/dist/src/middleware/passport/sso/sso.js.map +0 -1
  275. package/dist/src/middleware/passport/utils.js +0 -75
  276. package/dist/src/middleware/passport/utils.js.map +0 -1
  277. package/dist/src/middleware/querystringToBody.js +0 -29
  278. package/dist/src/middleware/querystringToBody.js.map +0 -1
  279. package/dist/src/middleware/tenancy.js +0 -37
  280. package/dist/src/middleware/tenancy.js.map +0 -1
  281. package/dist/src/migrations/definitions.js +0 -39
  282. package/dist/src/migrations/definitions.js.map +0 -1
  283. package/dist/src/migrations/index.js +0 -19
  284. package/dist/src/migrations/index.js.map +0 -1
  285. package/dist/src/migrations/migrations.js +0 -203
  286. package/dist/src/migrations/migrations.js.map +0 -1
  287. package/dist/src/objectStore/buckets/app.js +0 -95
  288. package/dist/src/objectStore/buckets/app.js.map +0 -1
  289. package/dist/src/objectStore/buckets/global.js +0 -68
  290. package/dist/src/objectStore/buckets/global.js.map +0 -1
  291. package/dist/src/objectStore/buckets/index.js +0 -20
  292. package/dist/src/objectStore/buckets/index.js.map +0 -1
  293. package/dist/src/objectStore/buckets/plugins.js +0 -104
  294. package/dist/src/objectStore/buckets/plugins.js.map +0 -1
  295. package/dist/src/objectStore/cloudfront.js +0 -73
  296. package/dist/src/objectStore/cloudfront.js.map +0 -1
  297. package/dist/src/objectStore/index.js +0 -20
  298. package/dist/src/objectStore/index.js.map +0 -1
  299. package/dist/src/objectStore/objectStore.js +0 -509
  300. package/dist/src/objectStore/objectStore.js.map +0 -1
  301. package/dist/src/objectStore/utils.js +0 -148
  302. package/dist/src/objectStore/utils.js.map +0 -1
  303. package/dist/src/platform/index.js +0 -43
  304. package/dist/src/platform/index.js.map +0 -1
  305. package/dist/src/platform/platformDb.js +0 -9
  306. package/dist/src/platform/platformDb.js.map +0 -1
  307. package/dist/src/platform/tenants.js +0 -149
  308. package/dist/src/platform/tenants.js.map +0 -1
  309. package/dist/src/platform/users.js +0 -118
  310. package/dist/src/platform/users.js.map +0 -1
  311. package/dist/src/plugin/index.js +0 -18
  312. package/dist/src/plugin/index.js.map +0 -1
  313. package/dist/src/plugin/utils.js +0 -158
  314. package/dist/src/plugin/utils.js.map +0 -1
  315. package/dist/src/queue/constants.js +0 -13
  316. package/dist/src/queue/constants.js.map +0 -1
  317. package/dist/src/queue/inMemoryQueue.js +0 -192
  318. package/dist/src/queue/inMemoryQueue.js.map +0 -1
  319. package/dist/src/queue/index.js +0 -19
  320. package/dist/src/queue/index.js.map +0 -1
  321. package/dist/src/queue/listeners.js +0 -199
  322. package/dist/src/queue/listeners.js.map +0 -1
  323. package/dist/src/queue/queue.js +0 -124
  324. package/dist/src/queue/queue.js.map +0 -1
  325. package/dist/src/redis/index.js +0 -47
  326. package/dist/src/redis/index.js.map +0 -1
  327. package/dist/src/redis/init.js +0 -184
  328. package/dist/src/redis/init.js.map +0 -1
  329. package/dist/src/redis/redis.js +0 -396
  330. package/dist/src/redis/redis.js.map +0 -1
  331. package/dist/src/redis/redlockImpl.js +0 -181
  332. package/dist/src/redis/redlockImpl.js.map +0 -1
  333. package/dist/src/redis/utils.js +0 -131
  334. package/dist/src/redis/utils.js.map +0 -1
  335. package/dist/src/security/auth.js +0 -26
  336. package/dist/src/security/auth.js.map +0 -1
  337. package/dist/src/security/encryption.js +0 -169
  338. package/dist/src/security/encryption.js.map +0 -1
  339. package/dist/src/security/index.js +0 -18
  340. package/dist/src/security/index.js.map +0 -1
  341. package/dist/src/security/permissions.js +0 -147
  342. package/dist/src/security/permissions.js.map +0 -1
  343. package/dist/src/security/roles.js +0 -566
  344. package/dist/src/security/roles.js.map +0 -1
  345. package/dist/src/security/secrets.js +0 -53
  346. package/dist/src/security/secrets.js.map +0 -1
  347. package/dist/src/security/sessions.js +0 -156
  348. package/dist/src/security/sessions.js.map +0 -1
  349. package/dist/src/sql/designDoc.js +0 -19
  350. package/dist/src/sql/designDoc.js.map +0 -1
  351. package/dist/src/sql/index.js +0 -47
  352. package/dist/src/sql/index.js.map +0 -1
  353. package/dist/src/sql/sql.js +0 -1536
  354. package/dist/src/sql/sql.js.map +0 -1
  355. package/dist/src/sql/sqlTable.js +0 -256
  356. package/dist/src/sql/sqlTable.js.map +0 -1
  357. package/dist/src/sql/utils.js +0 -179
  358. package/dist/src/sql/utils.js.map +0 -1
  359. package/dist/src/tenancy/db.js +0 -9
  360. package/dist/src/tenancy/db.js.map +0 -1
  361. package/dist/src/tenancy/index.js +0 -19
  362. package/dist/src/tenancy/index.js.map +0 -1
  363. package/dist/src/tenancy/tenancy.js +0 -125
  364. package/dist/src/tenancy/tenancy.js.map +0 -1
  365. package/dist/src/timers/index.js +0 -18
  366. package/dist/src/timers/index.js.map +0 -1
  367. package/dist/src/timers/timers.js +0 -25
  368. package/dist/src/timers/timers.js.map +0 -1
  369. package/dist/src/users/db.js +0 -489
  370. package/dist/src/users/db.js.map +0 -1
  371. package/dist/src/users/events.js +0 -179
  372. package/dist/src/users/events.js.map +0 -1
  373. package/dist/src/users/index.js +0 -23
  374. package/dist/src/users/index.js.map +0 -1
  375. package/dist/src/users/lookup.js +0 -126
  376. package/dist/src/users/lookup.js.map +0 -1
  377. package/dist/src/users/users.js +0 -376
  378. package/dist/src/users/users.js.map +0 -1
  379. package/dist/src/users/utils.js +0 -127
  380. package/dist/src/users/utils.js.map +0 -1
  381. package/dist/src/utils/Duration.js +0 -54
  382. package/dist/src/utils/Duration.js.map +0 -1
  383. package/dist/src/utils/hashing.js +0 -46
  384. package/dist/src/utils/hashing.js.map +0 -1
  385. package/dist/src/utils/index.js +0 -21
  386. package/dist/src/utils/index.js.map +0 -1
  387. package/dist/src/utils/stringUtils.js +0 -8
  388. package/dist/src/utils/stringUtils.js.map +0 -1
  389. package/dist/src/utils/utils.js +0 -267
  390. package/dist/src/utils/utils.js.map +0 -1
  391. package/dist/tests/core/logging.js +0 -33
  392. package/dist/tests/core/logging.js.map +0 -1
  393. package/dist/tests/core/utilities/index.js +0 -48
  394. package/dist/tests/core/utilities/index.js.map +0 -1
  395. package/dist/tests/core/utilities/jestUtils.js +0 -21
  396. package/dist/tests/core/utilities/jestUtils.js.map +0 -1
  397. package/dist/tests/core/utilities/mocks/alerts.js +0 -40
  398. package/dist/tests/core/utilities/mocks/alerts.js.map +0 -1
  399. package/dist/tests/core/utilities/mocks/date.js +0 -6
  400. package/dist/tests/core/utilities/mocks/date.js.map +0 -1
  401. package/dist/tests/core/utilities/mocks/events.js +0 -154
  402. package/dist/tests/core/utilities/mocks/events.js.map +0 -1
  403. package/dist/tests/core/utilities/mocks/index.js +0 -47
  404. package/dist/tests/core/utilities/mocks/index.js.map +0 -1
  405. package/dist/tests/core/utilities/mocks/licenses.js +0 -109
  406. package/dist/tests/core/utilities/mocks/licenses.js.map +0 -1
  407. package/dist/tests/core/utilities/queue.js +0 -21
  408. package/dist/tests/core/utilities/queue.js.map +0 -1
  409. package/dist/tests/core/utilities/structures/Chance.js +0 -21
  410. package/dist/tests/core/utilities/structures/Chance.js.map +0 -1
  411. package/dist/tests/core/utilities/structures/accounts.js +0 -43
  412. package/dist/tests/core/utilities/structures/accounts.js.map +0 -1
  413. package/dist/tests/core/utilities/structures/apps.js +0 -23
  414. package/dist/tests/core/utilities/structures/apps.js.map +0 -1
  415. package/dist/tests/core/utilities/structures/common.js +0 -11
  416. package/dist/tests/core/utilities/structures/common.js.map +0 -1
  417. package/dist/tests/core/utilities/structures/db.js +0 -15
  418. package/dist/tests/core/utilities/structures/db.js.map +0 -1
  419. package/dist/tests/core/utilities/structures/documents/index.js +0 -18
  420. package/dist/tests/core/utilities/structures/documents/index.js.map +0 -1
  421. package/dist/tests/core/utilities/structures/documents/platform/index.js +0 -38
  422. package/dist/tests/core/utilities/structures/documents/platform/index.js.map +0 -1
  423. package/dist/tests/core/utilities/structures/documents/platform/installation.js +0 -47
  424. package/dist/tests/core/utilities/structures/documents/platform/installation.js.map +0 -1
  425. package/dist/tests/core/utilities/structures/generator.js +0 -9
  426. package/dist/tests/core/utilities/structures/generator.js.map +0 -1
  427. package/dist/tests/core/utilities/structures/index.js +0 -56
  428. package/dist/tests/core/utilities/structures/index.js.map +0 -1
  429. package/dist/tests/core/utilities/structures/koa.js +0 -10
  430. package/dist/tests/core/utilities/structures/koa.js.map +0 -1
  431. package/dist/tests/core/utilities/structures/licenses.js +0 -157
  432. package/dist/tests/core/utilities/structures/licenses.js.map +0 -1
  433. package/dist/tests/core/utilities/structures/plugins.js +0 -22
  434. package/dist/tests/core/utilities/structures/plugins.js.map +0 -1
  435. package/dist/tests/core/utilities/structures/quotas.js +0 -73
  436. package/dist/tests/core/utilities/structures/quotas.js.map +0 -1
  437. package/dist/tests/core/utilities/structures/scim.js +0 -62
  438. package/dist/tests/core/utilities/structures/scim.js.map +0 -1
  439. package/dist/tests/core/utilities/structures/sso.js +0 -140
  440. package/dist/tests/core/utilities/structures/sso.js.map +0 -1
  441. package/dist/tests/core/utilities/structures/tenants.js +0 -8
  442. package/dist/tests/core/utilities/structures/tenants.js.map +0 -1
  443. package/dist/tests/core/utilities/structures/userGroups.js +0 -12
  444. package/dist/tests/core/utilities/structures/userGroups.js.map +0 -1
  445. package/dist/tests/core/utilities/structures/users.js +0 -53
  446. package/dist/tests/core/utilities/structures/users.js.map +0 -1
  447. package/dist/tests/core/utilities/testContainerUtils.js +0 -161
  448. package/dist/tests/core/utilities/testContainerUtils.js.map +0 -1
  449. package/dist/tests/core/utilities/utils/index.js +0 -39
  450. package/dist/tests/core/utilities/utils/index.js.map +0 -1
  451. package/dist/tests/core/utilities/utils/queue.js +0 -37
  452. package/dist/tests/core/utilities/utils/queue.js.map +0 -1
  453. package/dist/tests/core/utilities/utils/time.js +0 -7
  454. package/dist/tests/core/utilities/utils/time.js.map +0 -1
  455. package/dist/tests/extra/DBTestConfiguration.js +0 -65
  456. package/dist/tests/extra/DBTestConfiguration.js.map +0 -1
  457. package/dist/tests/extra/index.js +0 -43
  458. package/dist/tests/extra/index.js.map +0 -1
  459. package/dist/tests/extra/testEnv.js +0 -136
  460. package/dist/tests/extra/testEnv.js.map +0 -1
  461. package/dist/tests/index.js +0 -19
  462. package/dist/tests/index.js.map +0 -1
  463. package/dist/tests/jestEnv.js +0 -12
  464. package/dist/tests/jestEnv.js.map +0 -1
  465. package/dist/tests/jestSetup.js +0 -33
  466. package/dist/tests/jestSetup.js.map +0 -1
@@ -1,96 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AppState = void 0;
13
- exports.getAppMetadata = getAppMetadata;
14
- exports.invalidateAppMetadata = invalidateAppMetadata;
15
- const init_1 = require("../redis/init");
16
- const db_1 = require("../db");
17
- var AppState;
18
- (function (AppState) {
19
- AppState["INVALID"] = "invalid";
20
- })(AppState || (exports.AppState = AppState = {}));
21
- const EXPIRY_SECONDS = 3600;
22
- const INVALID_EXPIRY_SECONDS = 60;
23
- /**
24
- * The default populate app metadata function
25
- */
26
- function populateFromDB(appId) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- return (0, db_1.doWithDB)(appId, (db) => {
29
- return db.get(db_1.DocumentType.APP_METADATA);
30
- }, { skip_setup: true });
31
- });
32
- }
33
- function isInvalid(metadata) {
34
- return !metadata || metadata.state === AppState.INVALID;
35
- }
36
- /**
37
- * Get the requested app metadata by id.
38
- * Use redis cache to first read the app metadata.
39
- * If not present fallback to loading the app metadata directly and re-caching.
40
- * @param appId the id of the app to get metadata from.
41
- * @returns the app metadata.
42
- */
43
- function getAppMetadata(appId) {
44
- return __awaiter(this, void 0, void 0, function* () {
45
- const client = yield (0, init_1.getAppClient)();
46
- // try cache
47
- let metadata = yield client.get(appId);
48
- if (!metadata) {
49
- let expiry = EXPIRY_SECONDS;
50
- try {
51
- metadata = yield populateFromDB(appId);
52
- }
53
- catch (err) {
54
- // app DB left around, but no metadata, it is invalid
55
- if (err && err.status === 404) {
56
- metadata = { state: AppState.INVALID };
57
- // expire invalid apps regularly, in-case it was only briefly invalid
58
- expiry = INVALID_EXPIRY_SECONDS;
59
- }
60
- else {
61
- throw err;
62
- }
63
- }
64
- // needed for some scenarios where the caching happens
65
- // so quickly the requests can get slightly out of sync
66
- // might store its invalid just before it stores its valid
67
- if (isInvalid(metadata)) {
68
- const temp = yield client.get(appId);
69
- if (temp) {
70
- metadata = temp;
71
- }
72
- }
73
- yield client.store(appId, metadata, expiry);
74
- }
75
- return metadata;
76
- });
77
- }
78
- /**
79
- * Invalidate/reset the cached metadata when a change occurs in the db.
80
- * @param appId the cache key to bust/update.
81
- * @param newMetadata optional - can simply provide the new metadata to update with.
82
- * @return will respond with success when cache is updated.
83
- */
84
- function invalidateAppMetadata(appId, newMetadata) {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- if (!appId) {
87
- throw "Cannot invalidate if no app ID provided.";
88
- }
89
- const client = yield (0, init_1.getAppClient)();
90
- yield client.delete(appId);
91
- if (newMetadata) {
92
- yield client.store(appId, newMetadata, EXPIRY_SECONDS);
93
- }
94
- });
95
- }
96
- //# sourceMappingURL=appMetadata.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"appMetadata.js","sourceRoot":"","sources":["../../../src/cache/appMetadata.ts"],"names":[],"mappings":";;;;;;;;;;;;AAuCA,wCA+BC;AAQD,sDASC;AAvFD,wCAA4C;AAC5C,8BAA8C;AAG9C,IAAY,QAEX;AAFD,WAAY,QAAQ;IAClB,+BAAmB,CAAA;AACrB,CAAC,EAFW,QAAQ,wBAAR,QAAQ,QAEnB;AAMD,MAAM,cAA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AAG,CAAC,KAAK,CAAC,CAAA;gBACpC,IAAI,IAAI,EAAE,CAAC;oBACT,QAAQ,GAAG,IAAI,CAAA;gBACjB,CAAC;YACH,CAAC;YACD,MAAM,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAA;QAC7C,CAAC;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC;CAAA;AAED;;;;;GAKG;AACH,SAAsB,qBAAqB,CAAC,KAAa,EAAE,WAAiB;;QAC1E,IAAI,CAAC,KAAK,EAAE,CAAC;YACX,MAAM,0CAA0C,CAAA;QAClD,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,IAAA,mBAAY,GAAE,CAAA;QACnC,MAAM,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;QAC1B,IAAI,WAAW,EAAE,CAAC;YAChB,MAAM,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,WAAW,EAAE,cAAc,CAAC,CAAA;QACxD,CAAC;IACH,CAAC;CAAA"}
@@ -1,189 +0,0 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- const context_1 = require("../../context");
46
- const redis = __importStar(require("../../redis/init"));
47
- function generateTenantKey(key) {
48
- const tenantId = (0, context_1.getTenantId)();
49
- return `${key}:${tenantId}`;
50
- }
51
- class BaseCache {
52
- constructor(client = undefined) {
53
- this.client = client;
54
- }
55
- getClient() {
56
- return __awaiter(this, void 0, void 0, function* () {
57
- return !this.client ? yield redis.getCacheClient() : this.client;
58
- });
59
- }
60
- keys(pattern) {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- const client = yield this.getClient();
63
- return client.keys(pattern);
64
- });
65
- }
66
- exists(key_1) {
67
- return __awaiter(this, arguments, void 0, function* (key, opts = { useTenancy: true }) {
68
- key = opts.useTenancy ? generateTenantKey(key) : key;
69
- const client = yield this.getClient();
70
- return client.exists(key);
71
- });
72
- }
73
- scan(key_1) {
74
- return __awaiter(this, arguments, void 0, function* (key, opts = { useTenancy: true }) {
75
- key = opts.useTenancy ? generateTenantKey(key) : key;
76
- const client = yield this.getClient();
77
- return client.scan(key);
78
- });
79
- }
80
- /**
81
- * Read only from the cache.
82
- */
83
- get(key_1) {
84
- return __awaiter(this, arguments, void 0, function* (key, opts = { useTenancy: true }) {
85
- key = opts.useTenancy ? generateTenantKey(key) : key;
86
- const client = yield this.getClient();
87
- return client.get(key);
88
- });
89
- }
90
- /**
91
- * Read only from the cache.
92
- */
93
- bulkGet(keys_1) {
94
- return __awaiter(this, arguments, void 0, function* (keys, opts = { useTenancy: true }) {
95
- keys = opts.useTenancy ? keys.map(key => generateTenantKey(key)) : keys;
96
- const client = yield this.getClient();
97
- return client.bulkGet(keys);
98
- });
99
- }
100
- /**
101
- * Write to the cache.
102
- */
103
- store(key_1, value_1) {
104
- return __awaiter(this, arguments, void 0, function* (key, value, ttl = null, opts = { useTenancy: true }) {
105
- key = opts.useTenancy ? generateTenantKey(key) : key;
106
- const client = yield this.getClient();
107
- yield client.store(key, value, ttl);
108
- });
109
- }
110
- /**
111
- * Bulk write to the cache.
112
- */
113
- bulkStore(data_1) {
114
- return __awaiter(this, arguments, void 0, function* (data, ttl = null, opts = { useTenancy: true }) {
115
- if (opts.useTenancy) {
116
- data = Object.entries(data).reduce((acc, [key, value]) => {
117
- acc[generateTenantKey(key)] = value;
118
- return acc;
119
- }, {});
120
- }
121
- const client = yield this.getClient();
122
- yield client.bulkStore(data, ttl);
123
- });
124
- }
125
- /**
126
- * Remove from cache.
127
- */
128
- delete(key_1) {
129
- return __awaiter(this, arguments, void 0, function* (key, opts = { useTenancy: true }) {
130
- key = opts.useTenancy ? generateTenantKey(key) : key;
131
- const client = yield this.getClient();
132
- return client.delete(key);
133
- });
134
- }
135
- /**
136
- * Remove from cache.
137
- */
138
- bulkDelete(keys_1) {
139
- return __awaiter(this, arguments, void 0, function* (keys, opts = { useTenancy: true }) {
140
- keys = opts.useTenancy ? keys.map(key => generateTenantKey(key)) : keys;
141
- const client = yield this.getClient();
142
- return client.bulkDelete(keys);
143
- });
144
- }
145
- /**
146
- * Read from the cache. Write to the cache if not exists.
147
- */
148
- withCache(key_1) {
149
- return __awaiter(this, arguments, void 0, function* (key, ttl = null, fetchFn, opts = { useTenancy: true }) {
150
- const cachedValue = yield this.get(key, opts);
151
- if (cachedValue) {
152
- return cachedValue;
153
- }
154
- try {
155
- const fetchedValue = yield fetchFn();
156
- yield this.store(key, fetchedValue, ttl, opts);
157
- return fetchedValue;
158
- }
159
- catch (err) {
160
- console.error("Error fetching before cache - ", err);
161
- throw err;
162
- }
163
- });
164
- }
165
- bustCache(key) {
166
- return __awaiter(this, void 0, void 0, function* () {
167
- const client = yield this.getClient();
168
- try {
169
- yield client.delete(generateTenantKey(key));
170
- }
171
- catch (err) {
172
- console.error("Error busting cache - ", err);
173
- throw err;
174
- }
175
- });
176
- }
177
- /**
178
- * Delete the entry if the provided value matches the stored one.
179
- */
180
- deleteIfValue(key_1, value_1) {
181
- return __awaiter(this, arguments, void 0, function* (key, value, opts = { useTenancy: true }) {
182
- key = opts.useTenancy ? generateTenantKey(key) : key;
183
- const client = yield this.getClient();
184
- yield client.deleteIfValue(key, value);
185
- });
186
- }
187
- }
188
- exports.default = BaseCache;
189
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/cache/base/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA2C;AAC3C,wDAAyC;AAGzC,SAAS,iBAAiB,CAAC,GAAW;IACpC,MAAM,QAAQ,GAAG,IAAA,qBAAW,GAAE,CAAA;IAC9B,OAAO,GAAG,GAAG,IAAI,QAAQ,EAAE,CAAA;AAC7B,CAAC;AAED,MAAqB,SAAS;IAG5B,YAAY,SAA6B,SAAS;QAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAEK,SAAS;;YACb,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,cAAc,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAA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,KAAK,CAAC,gCAAgC,EAAE,GAAG,CAAC,CAAA;gBACpD,MAAM,GAAG,CAAA;YACX,CAAC;QACH,CAAC;KAAA;IAEK,SAAS,CAAC,GAAW;;YACzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;YACrC,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,MAAM,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAA;YAC7C,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,KAAK,CAAC,wBAAwB,EAAE,GAAG,CAAC,CAAA;gBAC5C,MAAM,GAAG,CAAA;YACX,CAAC;QACH,CAAC;KAAA;IAED;;OAEG;IACG,aAAa;6DAAC,GAAW,EAAE,KAAU,EAAE,IAAI,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE;YACtE,GAAG,GAAG,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAA;YACpD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAA;YACrC,MAAM,MAAM,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;QACxC,CAAC;KAAA;CACF;AA5ID,4BA4IC"}
@@ -1,123 +0,0 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- Object.defineProperty(exports, "__esModule", { value: true });
45
- exports.DocWritethrough = exports.DocWritethroughProcessor = void 0;
46
- exports.init = init;
47
- exports.getProcessor = getProcessor;
48
- const queue_1 = require("../queue");
49
- const dbUtils = __importStar(require("../db"));
50
- const PERSIST_MAX_ATTEMPTS = 100;
51
- let processor;
52
- class DocWritethroughProcessor {
53
- static get queue() {
54
- if (!DocWritethroughProcessor._queue) {
55
- DocWritethroughProcessor._queue = (0, queue_1.createQueue)(queue_1.JobQueue.DOC_WRITETHROUGH_QUEUE, {
56
- jobOptions: {
57
- attempts: PERSIST_MAX_ATTEMPTS,
58
- },
59
- });
60
- }
61
- return DocWritethroughProcessor._queue;
62
- }
63
- init() {
64
- DocWritethroughProcessor.queue.process((message) => __awaiter(this, void 0, void 0, function* () {
65
- try {
66
- yield this.persistToDb(message.data);
67
- }
68
- catch (err) {
69
- if (err.status === 409) {
70
- // If we get a 409, it means that another job updated it meanwhile. We want to retry it to persist it again.
71
- throw new Error(`Conflict persisting message ${message.id}. Attempt ${message.attemptsMade}`);
72
- }
73
- throw err;
74
- }
75
- }));
76
- return this;
77
- }
78
- persistToDb(_a) {
79
- return __awaiter(this, arguments, void 0, function* ({ dbName, docId, data, }) {
80
- const db = dbUtils.getDB(dbName);
81
- let doc;
82
- try {
83
- doc = yield db.get(docId);
84
- }
85
- catch (_b) {
86
- doc = { _id: docId };
87
- }
88
- doc = Object.assign(Object.assign({}, doc), data);
89
- yield db.put(doc);
90
- });
91
- }
92
- }
93
- exports.DocWritethroughProcessor = DocWritethroughProcessor;
94
- class DocWritethrough {
95
- constructor(db, docId) {
96
- this.db = db;
97
- this._docId = docId;
98
- }
99
- get docId() {
100
- return this._docId;
101
- }
102
- patch(data) {
103
- return __awaiter(this, void 0, void 0, function* () {
104
- yield DocWritethroughProcessor.queue.add({
105
- dbName: this.db.name,
106
- docId: this.docId,
107
- data,
108
- });
109
- });
110
- }
111
- }
112
- exports.DocWritethrough = DocWritethrough;
113
- function init() {
114
- processor = new DocWritethroughProcessor().init();
115
- return processor;
116
- }
117
- function getProcessor() {
118
- if (!processor) {
119
- return init();
120
- }
121
- return processor;
122
- }
123
- //# sourceMappingURL=docWritethrough.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"docWritethrough.js","sourceRoot":"","sources":["../../../src/cache/docWritethrough.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8FA,oBAGC;AAED,oCAKC;AAtGD,oCAAuD;AACvD,+CAAgC;AAQhC,MAAM,oBAAoB,GAAG,GAAG,CAAA;AAChC,IAAI,SAA+C,CAAA;AAEnD,MAAa,wBAAwB;IAG5B,MAAM,KAAK,KAAK;QACrB,IAAI,CAAC,wBAAwB,CAAC,MAAM,EAAE,CAAC;YACrC,wBAAw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,GAAG,EAAE,CAAA;QACZ,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACrB,CAAC;IAED,IAAI,KAAK;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;IAEK,KAAK,CAAC,IAAyB;;YACnC,MAAM,wBAAwB,CAAC,KAAK,CAAC,GAAG,CAAC;gBACvC,MAAM,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI;gBACpB,KAAK,EAAE,IAAI,CAAC,KAAK;gBACjB,IAAI;aACL,CAAC,CAAA;QACJ,CAAC;KAAA;CACF;AApBD,0CAoBC;AAED,SAAgB,IAAI;IAClB,SAAS,GAAG,IAAI,wBAAwB,EAAE,CAAC,IAAI,EAAE,CAAA;IACjD,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAgB,YAAY;IAC1B,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,IAAI,EAAE,CAAA;IACf,CAAC;IACD,OAAO,SAAS,CAAA;AAClB,CAAC"}
@@ -1,37 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.bustCache = exports.withCache = exports.destroy = exports.store = exports.get = exports.keys = exports.TTL = exports.CacheKey = void 0;
7
- const base_1 = __importDefault(require("./base"));
8
- const GENERIC = new base_1.default();
9
- var CacheKey;
10
- (function (CacheKey) {
11
- CacheKey["CHECKLIST"] = "checklist";
12
- CacheKey["INSTALLATION"] = "installation";
13
- CacheKey["ANALYTICS_ENABLED"] = "analyticsEnabled";
14
- CacheKey["UNIQUE_TENANT_ID"] = "uniqueTenantId";
15
- CacheKey["EVENTS"] = "events";
16
- CacheKey["BACKFILL_METADATA"] = "backfillMetadata";
17
- CacheKey["EVENTS_RATE_LIMIT"] = "eventsRateLimit";
18
- })(CacheKey || (exports.CacheKey = CacheKey = {}));
19
- var TTL;
20
- (function (TTL) {
21
- TTL[TTL["ONE_MINUTE"] = 600] = "ONE_MINUTE";
22
- TTL[TTL["ONE_HOUR"] = 3600] = "ONE_HOUR";
23
- TTL[TTL["ONE_DAY"] = 86400] = "ONE_DAY";
24
- })(TTL || (exports.TTL = TTL = {}));
25
- const keys = (...args) => GENERIC.keys(...args);
26
- exports.keys = keys;
27
- const get = (...args) => GENERIC.get(...args);
28
- exports.get = get;
29
- const store = (...args) => GENERIC.store(...args);
30
- exports.store = store;
31
- const destroy = (...args) => GENERIC.delete(...args);
32
- exports.destroy = destroy;
33
- const withCache = (...args) => GENERIC.withCache(...args);
34
- exports.withCache = withCache;
35
- const bustCache = (...args) => GENERIC.bustCache(...args);
36
- exports.bustCache = bustCache;
37
- //# sourceMappingURL=generic.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generic.js","sourceRoot":"","sources":["../../../src/cache/generic.ts"],"names":[],"mappings":";;;;;;AAAA,kDAA8B;AAE9B,MAAM,OAAO,GAAG,IAAI,cAAS,EAAE,CAAA;AAE/B,IAAY,QAQX;AARD,WAAY,QAAQ;IAClB,mCAAuB,CAAA;IACvB,yCAA6B,CAAA;IAC7B,kDAAsC,CAAA;IACtC,+CAAmC,CAAA;IACnC,6BAAiB,CAAA;IACjB,kDAAsC,CAAA;IACtC,iDAAqC,CAAA;AACvC,CAAC,EARW,QAAQ,wBAAR,QAAQ,QAQnB;AAED,IAAY,GAIX;AAJD,WAAY,GAAG;IACb,2CAAgB,CAAA;IAChB,wCAAe,CAAA;IACf,uCAAe,CAAA;AACjB,CAAC,EAJW,GAAG,mBAAH,GAAG,QAId;AAEM,MAAM,IAAI,GAAG,CAAC,GAAG,IAAqC,EAAE,EAAE,CAC/D,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAA;AADV,QAAA,IAAI,QACM;AAChB,MAAM,GAAG,GAAG,CAAC,GAAG,IAAoC,EAAE,EAAE,CAC7D,OAAO,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,CAAA;AADT,QAAA,GAAG,OACM;AACf,MAAM,KAAK,GAAG,CAAC,GAAG,IAAsC,EAAE,EAAE,CACjE,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;AADX,QAAA,KAAK,SACM;AACjB,MAAM,OAAO,GAAG,CAAC,GAAG,IAAuC,EAAE,EAAE,CACpE,OAAO,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,CAAA;AADZ,QAAA,OAAO,WACK;AAClB,MAAM,SAAS,GAAG,CACvB,GAAG,IAA6C,EAChD,EAAE,CAAC,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAA;AAFlB,QAAA,SAAS,aAES;AACxB,MAAM,SAAS,GAAG,CAAC,GAAG,IAA0C,EAAE,EAAE,CACzE,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI,CAAC,CAAA;AADf,QAAA,SAAS,aACM"}
@@ -1,48 +0,0 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
36
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.docWritethrough = exports.passwordReset = exports.invite = exports.writethrough = exports.app = exports.user = exports.generic = void 0;
40
- exports.generic = __importStar(require("./generic"));
41
- exports.user = __importStar(require("./user"));
42
- exports.app = __importStar(require("./appMetadata"));
43
- exports.writethrough = __importStar(require("./writethrough"));
44
- exports.invite = __importStar(require("./invite"));
45
- exports.passwordReset = __importStar(require("./passwordReset"));
46
- __exportStar(require("./generic"), exports);
47
- exports.docWritethrough = __importStar(require("./docWritethrough"));
48
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cache/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAoC;AACpC,+CAA8B;AAC9B,qDAAoC;AACpC,+DAA8C;AAC9C,mDAAkC;AAClC,iEAAgD;AAChD,4CAAyB;AACzB,qEAAoD"}
@@ -1,128 +0,0 @@
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 () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
- return new (P || (P = Promise))(function (resolve, reject) {
38
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
- step((generator = generator.apply(thisArg, _arguments || [])).next());
42
- });
43
- };
44
- var __importDefault = (this && this.__importDefault) || function (mod) {
45
- return (mod && mod.__esModule) ? mod : { "default": mod };
46
- };
47
- Object.defineProperty(exports, "__esModule", { value: true });
48
- exports.updateCode = updateCode;
49
- exports.createCode = createCode;
50
- exports.getCode = getCode;
51
- exports.deleteCode = deleteCode;
52
- exports.getInviteCodes = getInviteCodes;
53
- exports.getExistingInvites = getExistingInvites;
54
- const utils = __importStar(require("../utils"));
55
- const utils_1 = require("../utils");
56
- const environment_1 = __importDefault(require("../environment"));
57
- const context_1 = require("../context");
58
- const redis = __importStar(require("../redis/init"));
59
- const TTL_SECONDS = utils_1.Duration.fromDays(7).toSeconds();
60
- /**
61
- * Given an invite code and invite body, allow the update an existing/valid invite in redis
62
- * @param code The invite code for an invite in redis
63
- * @param value The body of the updated user invitation
64
- */
65
- function updateCode(code, value) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const client = yield redis.getInviteClient();
68
- yield client.store(code, value, TTL_SECONDS);
69
- });
70
- }
71
- /**
72
- * Generates an invitation code and writes it to redis - which can later be checked for user creation.
73
- * @param email the email address which the code is being sent to (for use later).
74
- * @param info Information to be carried along with the invitation.
75
- * @return returns the code that was stored to redis.
76
- */
77
- function createCode(email, info) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- const code = utils.newid();
80
- const client = yield redis.getInviteClient();
81
- yield client.store(code, { email, info }, TTL_SECONDS);
82
- return code;
83
- });
84
- }
85
- /**
86
- * Checks that the provided invite code is valid - will return the email address of user that was invited.
87
- * @param code the invite code that was provided as part of the link.
88
- * @return If the code is valid then an email address will be returned.
89
- */
90
- function getCode(code) {
91
- return __awaiter(this, void 0, void 0, function* () {
92
- const client = yield redis.getInviteClient();
93
- const value = (yield client.get(code));
94
- if (!value) {
95
- throw "Invitation is not valid or has expired, please request a new one.";
96
- }
97
- return value;
98
- });
99
- }
100
- function deleteCode(code) {
101
- return __awaiter(this, void 0, void 0, function* () {
102
- const client = yield redis.getInviteClient();
103
- yield client.delete(code);
104
- });
105
- }
106
- /**
107
- Get all currently available user invitations for the current tenant.
108
- **/
109
- function getInviteCodes() {
110
- return __awaiter(this, void 0, void 0, function* () {
111
- const client = yield redis.getInviteClient();
112
- const invites = yield client.scan();
113
- const results = invites.map(invite => {
114
- return Object.assign(Object.assign({}, invite.value), { code: invite.key });
115
- });
116
- if (!environment_1.default.MULTI_TENANCY) {
117
- return results;
118
- }
119
- const tenantId = (0, context_1.getTenantId)();
120
- return results.filter(invite => tenantId === invite.info.tenantId);
121
- });
122
- }
123
- function getExistingInvites(emails) {
124
- return __awaiter(this, void 0, void 0, function* () {
125
- return (yield getInviteCodes()).filter(invite => emails.includes(invite.email));
126
- });
127
- }
128
- //# sourceMappingURL=invite.js.map
@@ -1 +0,0 @@
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