@budibase/backend-core 3.2.41 → 3.2.43

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 (358) hide show
  1. package/dist/package.json +3 -3
  2. package/dist/src/accounts/accounts.js +83 -0
  3. package/dist/src/accounts/accounts.js.map +1 -0
  4. package/dist/src/accounts/api.js +102 -0
  5. package/dist/src/accounts/api.js.map +1 -0
  6. package/dist/src/accounts/index.js +18 -0
  7. package/dist/src/accounts/index.js.map +1 -0
  8. package/dist/src/cache/appMetadata.js +96 -0
  9. package/dist/src/cache/appMetadata.js.map +1 -0
  10. package/dist/src/cache/base/index.js +189 -0
  11. package/dist/src/cache/base/index.js.map +1 -0
  12. package/dist/src/cache/docWritethrough.js +123 -0
  13. package/dist/src/cache/docWritethrough.js.map +1 -0
  14. package/dist/src/cache/generic.js +37 -0
  15. package/dist/src/cache/generic.js.map +1 -0
  16. package/dist/src/cache/index.js +48 -0
  17. package/dist/src/cache/index.js.map +1 -0
  18. package/dist/src/cache/invite.js +128 -0
  19. package/dist/src/cache/invite.js.map +1 -0
  20. package/dist/src/cache/passwordReset.js +92 -0
  21. package/dist/src/cache/passwordReset.js.map +1 -0
  22. package/dist/src/cache/user.js +183 -0
  23. package/dist/src/cache/user.js.map +1 -0
  24. package/dist/src/cache/writethrough.js +170 -0
  25. package/dist/src/cache/writethrough.js.map +1 -0
  26. package/dist/src/configs/configs.js +294 -0
  27. package/dist/src/configs/configs.js.map +1 -0
  28. package/dist/src/configs/index.js +18 -0
  29. package/dist/src/configs/index.js.map +1 -0
  30. package/dist/src/constants/db.js +75 -0
  31. package/dist/src/constants/db.js.map +1 -0
  32. package/dist/src/constants/index.js +19 -0
  33. package/dist/src/constants/index.js.map +1 -0
  34. package/dist/src/constants/misc.js +40 -0
  35. package/dist/src/constants/misc.js.map +1 -0
  36. package/dist/src/context/Context.js +14 -0
  37. package/dist/src/context/Context.js.map +1 -0
  38. package/dist/src/context/identity.js +81 -0
  39. package/dist/src/context/identity.js.map +1 -0
  40. package/dist/src/context/index.js +44 -0
  41. package/dist/src/context/index.js.map +1 -0
  42. package/dist/src/context/mainContext.js +446 -0
  43. package/dist/src/context/mainContext.js.map +1 -0
  44. package/dist/src/context/types.js +3 -0
  45. package/dist/src/context/types.js.map +1 -0
  46. package/dist/src/db/Replication.js +90 -0
  47. package/dist/src/db/Replication.js.map +1 -0
  48. package/dist/src/db/couch/DatabaseImpl.js +475 -0
  49. package/dist/src/db/couch/DatabaseImpl.js.map +1 -0
  50. package/dist/src/db/couch/connections.js +101 -0
  51. package/dist/src/db/couch/connections.js.map +1 -0
  52. package/dist/src/db/couch/index.js +26 -0
  53. package/dist/src/db/couch/index.js.map +1 -0
  54. package/dist/src/db/couch/pouchDB.js +108 -0
  55. package/dist/src/db/couch/pouchDB.js.map +1 -0
  56. package/dist/src/db/couch/utils.js +60 -0
  57. package/dist/src/db/couch/utils.js.map +1 -0
  58. package/dist/src/db/db.js +47 -0
  59. package/dist/src/db/db.js.map +1 -0
  60. package/dist/src/db/errors.js +21 -0
  61. package/dist/src/db/errors.js.map +1 -0
  62. package/dist/src/db/index.js +58 -0
  63. package/dist/src/db/index.js.map +1 -0
  64. package/dist/src/db/instrumentation.js +202 -0
  65. package/dist/src/db/instrumentation.js.map +1 -0
  66. package/dist/src/db/lucene.js +638 -0
  67. package/dist/src/db/lucene.js.map +1 -0
  68. package/dist/src/db/searchIndexes/index.js +18 -0
  69. package/dist/src/db/searchIndexes/index.js.map +1 -0
  70. package/dist/src/db/searchIndexes/searchIndexes.js +76 -0
  71. package/dist/src/db/searchIndexes/searchIndexes.js.map +1 -0
  72. package/dist/src/db/utils.js +212 -0
  73. package/dist/src/db/utils.js.map +1 -0
  74. package/dist/src/db/views.js +224 -0
  75. package/dist/src/db/views.js.map +1 -0
  76. package/dist/src/docIds/conversions.js +62 -0
  77. package/dist/src/docIds/conversions.js.map +1 -0
  78. package/dist/src/docIds/ids.js +125 -0
  79. package/dist/src/docIds/ids.js.map +1 -0
  80. package/dist/src/docIds/index.js +19 -0
  81. package/dist/src/docIds/index.js.map +1 -0
  82. package/dist/src/docIds/newid.js +8 -0
  83. package/dist/src/docIds/newid.js.map +1 -0
  84. package/dist/src/docIds/params.js +141 -0
  85. package/dist/src/docIds/params.js.map +1 -0
  86. package/dist/src/environment.js +182 -0
  87. package/dist/src/environment.js.map +1 -0
  88. package/dist/src/errors/errors.js +97 -0
  89. package/dist/src/errors/errors.js.map +1 -0
  90. package/dist/src/errors/index.js +18 -0
  91. package/dist/src/errors/index.js.map +1 -0
  92. package/dist/src/events/analytics.js +52 -0
  93. package/dist/src/events/analytics.js.map +1 -0
  94. package/dist/src/events/asyncEvents/index.js +19 -0
  95. package/dist/src/events/asyncEvents/index.js.map +1 -0
  96. package/dist/src/events/asyncEvents/publisher.js +26 -0
  97. package/dist/src/events/asyncEvents/publisher.js.map +1 -0
  98. package/dist/src/events/asyncEvents/queue.js +26 -0
  99. package/dist/src/events/asyncEvents/queue.js.map +1 -0
  100. package/dist/src/events/backfill.js +189 -0
  101. package/dist/src/events/backfill.js.map +1 -0
  102. package/dist/src/events/events.js +87 -0
  103. package/dist/src/events/events.js.map +1 -0
  104. package/dist/src/events/identification.js +299 -0
  105. package/dist/src/events/identification.js.map +1 -0
  106. package/dist/src/events/index.js +59 -0
  107. package/dist/src/events/index.js.map +1 -0
  108. package/dist/src/events/processors/AnalyticsProcessor.js +103 -0
  109. package/dist/src/events/processors/AnalyticsProcessor.js.map +1 -0
  110. package/dist/src/events/processors/AuditLogsProcessor.js +86 -0
  111. package/dist/src/events/processors/AuditLogsProcessor.js.map +1 -0
  112. package/dist/src/events/processors/LoggingProcessor.js +47 -0
  113. package/dist/src/events/processors/LoggingProcessor.js.map +1 -0
  114. package/dist/src/events/processors/Processors.js +52 -0
  115. package/dist/src/events/processors/Processors.js.map +1 -0
  116. package/dist/src/events/processors/index.js +23 -0
  117. package/dist/src/events/processors/index.js.map +1 -0
  118. package/dist/src/events/processors/posthog/PosthogProcessor.js +147 -0
  119. package/dist/src/events/processors/posthog/PosthogProcessor.js.map +1 -0
  120. package/dist/src/events/processors/posthog/index.js +8 -0
  121. package/dist/src/events/processors/posthog/index.js.map +1 -0
  122. package/dist/src/events/processors/posthog/rateLimiting.js +129 -0
  123. package/dist/src/events/processors/posthog/rateLimiting.js.map +1 -0
  124. package/dist/src/events/processors/types.js +3 -0
  125. package/dist/src/events/processors/types.js.map +1 -0
  126. package/dist/src/events/publishers/account.js +43 -0
  127. package/dist/src/events/publishers/account.js.map +1 -0
  128. package/dist/src/events/publishers/ai.js +30 -0
  129. package/dist/src/events/publishers/ai.js.map +1 -0
  130. package/dist/src/events/publishers/app.js +166 -0
  131. package/dist/src/events/publishers/app.js.map +1 -0
  132. package/dist/src/events/publishers/auditLog.js +34 -0
  133. package/dist/src/events/publishers/auditLog.js.map +1 -0
  134. package/dist/src/events/publishers/auth.js +80 -0
  135. package/dist/src/events/publishers/auth.js.map +1 -0
  136. package/dist/src/events/publishers/automation.js +117 -0
  137. package/dist/src/events/publishers/automation.js.map +1 -0
  138. package/dist/src/events/publishers/backfill.js +85 -0
  139. package/dist/src/events/publishers/backfill.js.map +1 -0
  140. package/dist/src/events/publishers/backup.js +41 -0
  141. package/dist/src/events/publishers/backup.js.map +1 -0
  142. package/dist/src/events/publishers/datasource.js +54 -0
  143. package/dist/src/events/publishers/datasource.js.map +1 -0
  144. package/dist/src/events/publishers/email.js +30 -0
  145. package/dist/src/events/publishers/email.js.map +1 -0
  146. package/dist/src/events/publishers/environmentVariable.js +44 -0
  147. package/dist/src/events/publishers/environmentVariable.js.map +1 -0
  148. package/dist/src/events/publishers/group.js +107 -0
  149. package/dist/src/events/publishers/group.js.map +1 -0
  150. package/dist/src/events/publishers/index.js +59 -0
  151. package/dist/src/events/publishers/index.js.map +1 -0
  152. package/dist/src/events/publishers/installation.js +52 -0
  153. package/dist/src/events/publishers/installation.js.map +1 -0
  154. package/dist/src/events/publishers/layout.js +34 -0
  155. package/dist/src/events/publishers/layout.js.map +1 -0
  156. package/dist/src/events/publishers/license.js +77 -0
  157. package/dist/src/events/publishers/license.js.map +1 -0
  158. package/dist/src/events/publishers/org.js +52 -0
  159. package/dist/src/events/publishers/org.js.map +1 -0
  160. package/dist/src/events/publishers/plugin.js +55 -0
  161. package/dist/src/events/publishers/plugin.js.map +1 -0
  162. package/dist/src/events/publishers/query.js +73 -0
  163. package/dist/src/events/publishers/query.js.map +1 -0
  164. package/dist/src/events/publishers/role.js +69 -0
  165. package/dist/src/events/publishers/role.js.map +1 -0
  166. package/dist/src/events/publishers/rowAction.js +22 -0
  167. package/dist/src/events/publishers/rowAction.js.map +1 -0
  168. package/dist/src/events/publishers/rows.js +31 -0
  169. package/dist/src/events/publishers/rows.js.map +1 -0
  170. package/dist/src/events/publishers/screen.js +46 -0
  171. package/dist/src/events/publishers/screen.js.map +1 -0
  172. package/dist/src/events/publishers/serve.js +47 -0
  173. package/dist/src/events/publishers/serve.js.map +1 -0
  174. package/dist/src/events/publishers/table.js +95 -0
  175. package/dist/src/events/publishers/table.js.map +1 -0
  176. package/dist/src/events/publishers/user.js +201 -0
  177. package/dist/src/events/publishers/user.js.map +1 -0
  178. package/dist/src/events/publishers/view.js +123 -0
  179. package/dist/src/events/publishers/view.js.map +1 -0
  180. package/dist/src/helpers.js +13 -0
  181. package/dist/src/helpers.js.map +1 -0
  182. package/dist/src/installation.js +159 -0
  183. package/dist/src/installation.js.map +1 -0
  184. package/dist/src/logging/alerts.js +23 -0
  185. package/dist/src/logging/alerts.js.map +1 -0
  186. package/dist/src/logging/correlation/correlation.js +18 -0
  187. package/dist/src/logging/correlation/correlation.js.map +1 -0
  188. package/dist/src/logging/correlation/index.js +18 -0
  189. package/dist/src/logging/correlation/index.js.map +1 -0
  190. package/dist/src/logging/index.js +45 -0
  191. package/dist/src/logging/index.js.map +1 -0
  192. package/dist/src/logging/pino/logger.js +234 -0
  193. package/dist/src/logging/pino/logger.js.map +1 -0
  194. package/dist/src/logging/system.js +110 -0
  195. package/dist/src/logging/system.js.map +1 -0
  196. package/dist/src/objectStore/buckets/app.js +95 -0
  197. package/dist/src/objectStore/buckets/app.js.map +1 -0
  198. package/dist/src/objectStore/buckets/global.js +68 -0
  199. package/dist/src/objectStore/buckets/global.js.map +1 -0
  200. package/dist/src/objectStore/buckets/index.js +20 -0
  201. package/dist/src/objectStore/buckets/index.js.map +1 -0
  202. package/dist/src/objectStore/buckets/plugins.js +104 -0
  203. package/dist/src/objectStore/buckets/plugins.js.map +1 -0
  204. package/dist/src/objectStore/cloudfront.js +73 -0
  205. package/dist/src/objectStore/cloudfront.js.map +1 -0
  206. package/dist/src/objectStore/index.js +20 -0
  207. package/dist/src/objectStore/index.js.map +1 -0
  208. package/dist/src/objectStore/objectStore.js +509 -0
  209. package/dist/src/objectStore/objectStore.js.map +1 -0
  210. package/dist/src/objectStore/utils.js +148 -0
  211. package/dist/src/objectStore/utils.js.map +1 -0
  212. package/dist/src/platform/index.js +43 -0
  213. package/dist/src/platform/index.js.map +1 -0
  214. package/dist/src/platform/platformDb.js +9 -0
  215. package/dist/src/platform/platformDb.js.map +1 -0
  216. package/dist/src/platform/tenants.js +149 -0
  217. package/dist/src/platform/tenants.js.map +1 -0
  218. package/dist/src/platform/users.js +118 -0
  219. package/dist/src/platform/users.js.map +1 -0
  220. package/dist/src/queue/constants.js +13 -0
  221. package/dist/src/queue/constants.js.map +1 -0
  222. package/dist/src/queue/inMemoryQueue.js +192 -0
  223. package/dist/src/queue/inMemoryQueue.js.map +1 -0
  224. package/dist/src/queue/index.js +19 -0
  225. package/dist/src/queue/index.js.map +1 -0
  226. package/dist/src/queue/listeners.js +199 -0
  227. package/dist/src/queue/listeners.js.map +1 -0
  228. package/dist/src/queue/queue.js +124 -0
  229. package/dist/src/queue/queue.js.map +1 -0
  230. package/dist/src/redis/index.js +47 -0
  231. package/dist/src/redis/index.js.map +1 -0
  232. package/dist/src/redis/init.js +184 -0
  233. package/dist/src/redis/init.js.map +1 -0
  234. package/dist/src/redis/redis.js +396 -0
  235. package/dist/src/redis/redis.js.map +1 -0
  236. package/dist/src/redis/redlockImpl.js +181 -0
  237. package/dist/src/redis/redlockImpl.js.map +1 -0
  238. package/dist/src/redis/utils.js +131 -0
  239. package/dist/src/redis/utils.js.map +1 -0
  240. package/dist/src/security/auth.js +26 -0
  241. package/dist/src/security/auth.js.map +1 -0
  242. package/dist/src/security/index.js +18 -0
  243. package/dist/src/security/index.js.map +1 -0
  244. package/dist/src/security/roles.js +566 -0
  245. package/dist/src/security/roles.js.map +1 -0
  246. package/dist/src/security/sessions.js +156 -0
  247. package/dist/src/security/sessions.js.map +1 -0
  248. package/dist/src/sql/utils.js +180 -0
  249. package/dist/src/sql/utils.js.map +1 -0
  250. package/dist/src/tenancy/db.js +9 -0
  251. package/dist/src/tenancy/db.js.map +1 -0
  252. package/dist/src/tenancy/index.js +19 -0
  253. package/dist/src/tenancy/index.js.map +1 -0
  254. package/dist/src/tenancy/tenancy.js +125 -0
  255. package/dist/src/tenancy/tenancy.js.map +1 -0
  256. package/dist/src/timers/index.js +18 -0
  257. package/dist/src/timers/index.js.map +1 -0
  258. package/dist/src/timers/timers.js +25 -0
  259. package/dist/src/timers/timers.js.map +1 -0
  260. package/dist/src/users/db.js +489 -0
  261. package/dist/src/users/db.js.map +1 -0
  262. package/dist/src/users/events.js +179 -0
  263. package/dist/src/users/events.js.map +1 -0
  264. package/dist/src/users/index.js +23 -0
  265. package/dist/src/users/index.js.map +1 -0
  266. package/dist/src/users/lookup.js +126 -0
  267. package/dist/src/users/lookup.js.map +1 -0
  268. package/dist/src/users/users.js +376 -0
  269. package/dist/src/users/users.js.map +1 -0
  270. package/dist/src/users/utils.js +127 -0
  271. package/dist/src/users/utils.js.map +1 -0
  272. package/dist/src/utils/Duration.js +54 -0
  273. package/dist/src/utils/Duration.js.map +1 -0
  274. package/dist/src/utils/hashing.js +46 -0
  275. package/dist/src/utils/hashing.js.map +1 -0
  276. package/dist/src/utils/index.js +21 -0
  277. package/dist/src/utils/index.js.map +1 -0
  278. package/dist/src/utils/stringUtils.js +8 -0
  279. package/dist/src/utils/stringUtils.js.map +1 -0
  280. package/dist/src/utils/utils.js +267 -0
  281. package/dist/src/utils/utils.js.map +1 -0
  282. package/dist/tests/core/logging.js +33 -0
  283. package/dist/tests/core/logging.js.map +1 -0
  284. package/dist/tests/core/utilities/index.js +48 -0
  285. package/dist/tests/core/utilities/index.js.map +1 -0
  286. package/dist/tests/core/utilities/jestUtils.js +21 -0
  287. package/dist/tests/core/utilities/jestUtils.js.map +1 -0
  288. package/dist/tests/core/utilities/mocks/alerts.js +40 -0
  289. package/dist/tests/core/utilities/mocks/alerts.js.map +1 -0
  290. package/dist/tests/core/utilities/mocks/date.js +6 -0
  291. package/dist/tests/core/utilities/mocks/date.js.map +1 -0
  292. package/dist/tests/core/utilities/mocks/events.js +155 -0
  293. package/dist/tests/core/utilities/mocks/events.js.map +1 -0
  294. package/dist/tests/core/utilities/mocks/index.js +47 -0
  295. package/dist/tests/core/utilities/mocks/index.js.map +1 -0
  296. package/dist/tests/core/utilities/mocks/licenses.js +109 -0
  297. package/dist/tests/core/utilities/mocks/licenses.js.map +1 -0
  298. package/dist/tests/core/utilities/queue.js +21 -0
  299. package/dist/tests/core/utilities/queue.js.map +1 -0
  300. package/dist/tests/core/utilities/structures/Chance.js +21 -0
  301. package/dist/tests/core/utilities/structures/Chance.js.map +1 -0
  302. package/dist/tests/core/utilities/structures/accounts.js +43 -0
  303. package/dist/tests/core/utilities/structures/accounts.js.map +1 -0
  304. package/dist/tests/core/utilities/structures/apps.js +23 -0
  305. package/dist/tests/core/utilities/structures/apps.js.map +1 -0
  306. package/dist/tests/core/utilities/structures/common.js +11 -0
  307. package/dist/tests/core/utilities/structures/common.js.map +1 -0
  308. package/dist/tests/core/utilities/structures/db.js +15 -0
  309. package/dist/tests/core/utilities/structures/db.js.map +1 -0
  310. package/dist/tests/core/utilities/structures/documents/index.js +18 -0
  311. package/dist/tests/core/utilities/structures/documents/index.js.map +1 -0
  312. package/dist/tests/core/utilities/structures/documents/platform/index.js +38 -0
  313. package/dist/tests/core/utilities/structures/documents/platform/index.js.map +1 -0
  314. package/dist/tests/core/utilities/structures/documents/platform/installation.js +47 -0
  315. package/dist/tests/core/utilities/structures/documents/platform/installation.js.map +1 -0
  316. package/dist/tests/core/utilities/structures/generator.js +9 -0
  317. package/dist/tests/core/utilities/structures/generator.js.map +1 -0
  318. package/dist/tests/core/utilities/structures/index.js +56 -0
  319. package/dist/tests/core/utilities/structures/index.js.map +1 -0
  320. package/dist/tests/core/utilities/structures/koa.js +10 -0
  321. package/dist/tests/core/utilities/structures/koa.js.map +1 -0
  322. package/dist/tests/core/utilities/structures/licenses.js +157 -0
  323. package/dist/tests/core/utilities/structures/licenses.js.map +1 -0
  324. package/dist/tests/core/utilities/structures/plugins.js +22 -0
  325. package/dist/tests/core/utilities/structures/plugins.js.map +1 -0
  326. package/dist/tests/core/utilities/structures/quotas.js +73 -0
  327. package/dist/tests/core/utilities/structures/quotas.js.map +1 -0
  328. package/dist/tests/core/utilities/structures/scim.js +62 -0
  329. package/dist/tests/core/utilities/structures/scim.js.map +1 -0
  330. package/dist/tests/core/utilities/structures/sso.js +140 -0
  331. package/dist/tests/core/utilities/structures/sso.js.map +1 -0
  332. package/dist/tests/core/utilities/structures/tenants.js +8 -0
  333. package/dist/tests/core/utilities/structures/tenants.js.map +1 -0
  334. package/dist/tests/core/utilities/structures/userGroups.js +12 -0
  335. package/dist/tests/core/utilities/structures/userGroups.js.map +1 -0
  336. package/dist/tests/core/utilities/structures/users.js +53 -0
  337. package/dist/tests/core/utilities/structures/users.js.map +1 -0
  338. package/dist/tests/core/utilities/testContainerUtils.js +161 -0
  339. package/dist/tests/core/utilities/testContainerUtils.js.map +1 -0
  340. package/dist/tests/core/utilities/utils/index.js +39 -0
  341. package/dist/tests/core/utilities/utils/index.js.map +1 -0
  342. package/dist/tests/core/utilities/utils/queue.js +37 -0
  343. package/dist/tests/core/utilities/utils/queue.js.map +1 -0
  344. package/dist/tests/core/utilities/utils/time.js +7 -0
  345. package/dist/tests/core/utilities/utils/time.js.map +1 -0
  346. package/dist/tests/extra/DBTestConfiguration.js +65 -0
  347. package/dist/tests/extra/DBTestConfiguration.js.map +1 -0
  348. package/dist/tests/extra/index.js +43 -0
  349. package/dist/tests/extra/index.js.map +1 -0
  350. package/dist/tests/extra/testEnv.js +136 -0
  351. package/dist/tests/extra/testEnv.js.map +1 -0
  352. package/dist/tests/index.js +19 -0
  353. package/dist/tests/index.js.map +1 -0
  354. package/dist/tests/jestEnv.js +12 -0
  355. package/dist/tests/jestEnv.js.map +1 -0
  356. package/dist/tests/jestSetup.js +33 -0
  357. package/dist/tests/jestSetup.js.map +1 -0
  358. package/package.json +3 -3
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@budibase/backend-core",
3
- "version": "3.2.41",
3
+ "version": "3.2.43",
4
4
  "description": "Budibase backend core libraries used in server and worker",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/src/index.d.ts",
@@ -21,7 +21,7 @@
21
21
  "scripts": {
22
22
  "prebuild": "rimraf dist/",
23
23
  "prepack": "cp package.json dist",
24
- "build": "node ./scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null",
24
+ "build": "node ./scripts/build.js && tsc -p tsconfig.build.json --emitDeclarationOnly --paths null && tsc -p tsconfig.test.json --paths null",
25
25
  "build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
26
26
  "build:oss": "node ./scripts/build.js",
27
27
  "check:types": "tsc -p tsconfig.json --noEmit --paths null",
@@ -110,5 +110,5 @@
110
110
  }
111
111
  }
112
112
  },
113
- "gitHead": "53e10e4de05dd034dfae7e6b7e72a875b8ed99ea"
113
+ "gitHead": "2b3d6dd41e84027b07209fbe83876ecf51681f88"
114
114
  }
@@ -0,0 +1,83 @@
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.getStatus = exports.getAccountByTenantId = exports.getAccount = void 0;
16
+ const api_1 = __importDefault(require("./api"));
17
+ const environment_1 = __importDefault(require("../environment"));
18
+ const constants_1 = require("../constants");
19
+ const api = new api_1.default(environment_1.default.ACCOUNT_PORTAL_URL);
20
+ /**
21
+ * This client is intended to be used in a cloud hosted deploy only.
22
+ * Rather than relying on each consumer to perform the necessary environmental checks
23
+ * we use the following check to exit early with a undefined response which should be
24
+ * handled by the caller.
25
+ */
26
+ const EXIT_EARLY = environment_1.default.SELF_HOSTED || environment_1.default.DISABLE_ACCOUNT_PORTAL;
27
+ const getAccount = (email) => __awaiter(void 0, void 0, void 0, function* () {
28
+ if (EXIT_EARLY) {
29
+ return;
30
+ }
31
+ const payload = {
32
+ email,
33
+ };
34
+ const response = yield api.post(`/api/accounts/search`, {
35
+ body: payload,
36
+ headers: {
37
+ [constants_1.Header.API_KEY]: environment_1.default.ACCOUNT_PORTAL_API_KEY,
38
+ },
39
+ });
40
+ if (response.status !== 200) {
41
+ throw new Error(`Error getting account by email ${email}`);
42
+ }
43
+ const json = yield response.json();
44
+ return json[0];
45
+ });
46
+ exports.getAccount = getAccount;
47
+ const getAccountByTenantId = (tenantId) => __awaiter(void 0, void 0, void 0, function* () {
48
+ if (EXIT_EARLY) {
49
+ return;
50
+ }
51
+ const payload = {
52
+ tenantId,
53
+ };
54
+ const response = yield api.post(`/api/accounts/search`, {
55
+ body: payload,
56
+ headers: {
57
+ [constants_1.Header.API_KEY]: environment_1.default.ACCOUNT_PORTAL_API_KEY,
58
+ },
59
+ });
60
+ if (response.status !== 200) {
61
+ throw new Error(`Error getting account by tenantId ${tenantId}`);
62
+ }
63
+ const json = yield response.json();
64
+ return json[0];
65
+ });
66
+ exports.getAccountByTenantId = getAccountByTenantId;
67
+ const getStatus = () => __awaiter(void 0, void 0, void 0, function* () {
68
+ if (EXIT_EARLY) {
69
+ return;
70
+ }
71
+ const response = yield api.get(`/api/status`, {
72
+ headers: {
73
+ [constants_1.Header.API_KEY]: environment_1.default.ACCOUNT_PORTAL_API_KEY,
74
+ },
75
+ });
76
+ const json = yield response.json();
77
+ if (response.status !== 200) {
78
+ throw new Error(`Error getting status`);
79
+ }
80
+ return json;
81
+ });
82
+ exports.getStatus = getStatus;
83
+ //# sourceMappingURL=accounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/accounts/accounts.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,gDAAuB;AACvB,iEAAgC;AAChC,4CAAqC;AAGrC,MAAM,GAAG,GAAG,IAAI,aAAG,CAAC,qBAAG,CAAC,kBAAkB,CAAC,CAAA;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,GAAG,qBAAG,CAAC,WAAW,IAAI,qBAAG,CAAC,sBAAsB,CAAA;AAEzD,MAAM,UAAU,GAAG,CACxB,KAAa,EACsB,EAAE;IACrC,IAAI,UAAU,EAAE,CAAC;QACf,OAAM;IACR,CAAC;IACD,MAAM,OAAO,GAAG;QACd,KAAK;KACN,CAAA;IACD,MAAM,QAAQ,GAAG,MAAM,GAAG,CAAC,IAAI,CAAC,sBAAsB,EAAE;QACtD,IAAI,EAAE,OAAO;QACb,OAAO,EAAE;YACP,CAAC,kBAAM,CAAC,OAAO,CAAC,EAAE,qBAAG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AAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;IAElC,IAAI,QAAQ,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAA;IACzC,CAAC;IAED,OAAO,IAAI,CAAA;AACb,CAAC,CAAA,CAAA;AAlBY,QAAA,SAAS,aAkBrB"}
@@ -0,0 +1,102 @@
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
+ const node_fetch_1 = __importDefault(require("node-fetch"));
49
+ const logging = __importStar(require("../logging"));
50
+ class API {
51
+ constructor(host) {
52
+ this.host = host;
53
+ }
54
+ apiCall(method, url, options) {
55
+ return __awaiter(this, void 0, void 0, function* () {
56
+ if (!options.headers) {
57
+ options.headers = {};
58
+ }
59
+ if (!options.headers["Content-Type"]) {
60
+ options.headers = Object.assign({ "Content-Type": "application/json", Accept: "application/json" }, options.headers);
61
+ }
62
+ let json = options.headers["Content-Type"] === "application/json";
63
+ // add x-budibase-correlation-id header
64
+ logging.correlation.setHeader(options.headers);
65
+ const requestOptions = {
66
+ method: method,
67
+ body: json ? JSON.stringify(options.body) : options.body,
68
+ headers: options.headers,
69
+ // TODO: See if this is necessary
70
+ credentials: "include",
71
+ };
72
+ return yield (0, node_fetch_1.default)(`${this.host}${url}`, requestOptions);
73
+ });
74
+ }
75
+ post(url, options) {
76
+ return __awaiter(this, void 0, void 0, function* () {
77
+ return this.apiCall("POST", url, options);
78
+ });
79
+ }
80
+ get(url, options) {
81
+ return __awaiter(this, void 0, void 0, function* () {
82
+ return this.apiCall("GET", url, options);
83
+ });
84
+ }
85
+ patch(url, options) {
86
+ return __awaiter(this, void 0, void 0, function* () {
87
+ return this.apiCall("PATCH", url, options);
88
+ });
89
+ }
90
+ del(url, options) {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ return this.apiCall("DELETE", url, options);
93
+ });
94
+ }
95
+ put(url, options) {
96
+ return __awaiter(this, void 0, void 0, function* () {
97
+ return this.apiCall("PUT", url, options);
98
+ });
99
+ }
100
+ }
101
+ exports.default = API;
102
+ //# sourceMappingURL=api.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/accounts/api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA8B;AAC9B,oDAAqC;AAErC,MAAqB,GAAG;IAGtB,YAAY,IAAY;QACtB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;IAClB,CAAC;IAEK,OAAO,CAAC,MAAc,EAAE,GAAW,EAAE,OAAa;;YACtD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;gBACrB,OAAO,CAAC,OAAO,GAAG,EAAE,CAAA;YACtB,CAAC;YAED,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,CAAC;gBACrC,OAAO,CAAC,OAAO,mBACb,cAAc,EAAE,kBAAkB,EAClC,MAAM,EAAE,kBAAkB,IACvB,OAAO,CAAC,OAAO,CACnB,CAAA;YACH,CAAC;YAED,IAAI,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,kBAAkB,CAAA;YAEjE,uCAAuC;YACvC,OAAO,CAAC,WAAW,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;YAE9C,MAAM,cAAc,GAAG;gBACrB,MAAM,EAAE,MAAM;gBACd,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI;gBACxD,OAAO,EAAE,OAAO,CAAC,OAAO;gBACxB,iCAAiC;gBACjC,WAAW,EAAE,SAAS;aACvB,CAAA;YAED,OAAO,MAAM,IAAA,oBAAK,EAAC,GAAG,IAAI,CAAC,IAAI,GAAG,GAAG,EAAE,EAAE,cAAc,CAAC,CAAA;QAC1D,CAAC;KAAA;IAEK,IAAI,CAAC,GAAW,EAAE,OAAa;;YACnC,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QAC3C,CAAC;KAAA;IAEK,GAAG,CAAC,GAAW,EAAE,OAAa;;YAClC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QAC1C,CAAC;KAAA;IAEK,KAAK,CAAC,GAAW,EAAE,OAAa;;YACpC,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QAC5C,CAAC;KAAA;IAEK,GAAG,CAAC,GAAW,EAAE,OAAa;;YAClC,OAAO,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QAC7C,CAAC;KAAA;IAEK,GAAG,CAAC,GAAW,EAAE,OAAa;;YAClC,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,CAAC,CAAA;QAC1C,CAAC;KAAA;CACF;AAvDD,sBAuDC"}
@@ -0,0 +1,18 @@
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./accounts"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/accounts/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA0B"}
@@ -0,0 +1,96 @@
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
@@ -0,0 +1 @@
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,QAA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AAI,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,GAAG,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"}
@@ -0,0 +1,189 @@
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
@@ -0,0 +1 @@
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,qBA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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