@budibase/backend-core 3.2.5 → 3.2.7

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 (276) hide show
  1. package/dist/index.js +7 -1
  2. package/dist/index.js.map +2 -2
  3. package/dist/index.js.meta.json +1 -1
  4. package/dist/package.json +11 -4
  5. package/dist/plugins.js.meta.json +1 -1
  6. package/dist/src/environment.d.ts +1 -0
  7. package/dist/src/environment.js +6 -1
  8. package/dist/src/environment.js.map +1 -1
  9. package/package.json +11 -4
  10. package/src/accounts/accounts.ts +0 -82
  11. package/src/accounts/api.ts +0 -59
  12. package/src/accounts/index.ts +0 -1
  13. package/src/auth/auth.ts +0 -210
  14. package/src/auth/index.ts +0 -1
  15. package/src/auth/tests/auth.spec.ts +0 -14
  16. package/src/blacklist/blacklist.ts +0 -54
  17. package/src/blacklist/index.ts +0 -1
  18. package/src/blacklist/tests/blacklist.spec.ts +0 -46
  19. package/src/cache/appMetadata.ts +0 -88
  20. package/src/cache/base/index.ts +0 -150
  21. package/src/cache/docWritethrough.ts +0 -105
  22. package/src/cache/generic.ts +0 -33
  23. package/src/cache/index.ts +0 -8
  24. package/src/cache/invite.ts +0 -86
  25. package/src/cache/passwordReset.ts +0 -49
  26. package/src/cache/tests/docWritethrough.spec.ts +0 -296
  27. package/src/cache/tests/user.spec.ts +0 -145
  28. package/src/cache/tests/writethrough.spec.ts +0 -139
  29. package/src/cache/user.ts +0 -154
  30. package/src/cache/writethrough.ts +0 -133
  31. package/src/configs/configs.ts +0 -263
  32. package/src/configs/index.ts +0 -1
  33. package/src/configs/tests/configs.spec.ts +0 -184
  34. package/src/constants/db.ts +0 -75
  35. package/src/constants/index.ts +0 -2
  36. package/src/constants/misc.ts +0 -36
  37. package/src/context/Context.ts +0 -14
  38. package/src/context/identity.ts +0 -58
  39. package/src/context/index.ts +0 -3
  40. package/src/context/mainContext.ts +0 -422
  41. package/src/context/tests/index.spec.ts +0 -255
  42. package/src/context/types.ts +0 -26
  43. package/src/db/Replication.ts +0 -94
  44. package/src/db/couch/DatabaseImpl.ts +0 -511
  45. package/src/db/couch/connections.ts +0 -89
  46. package/src/db/couch/index.ts +0 -4
  47. package/src/db/couch/pouchDB.ts +0 -97
  48. package/src/db/couch/pouchDump.ts +0 -0
  49. package/src/db/couch/tests/DatabaseImpl.spec.ts +0 -118
  50. package/src/db/couch/utils.ts +0 -55
  51. package/src/db/db.ts +0 -34
  52. package/src/db/errors.ts +0 -14
  53. package/src/db/index.ts +0 -12
  54. package/src/db/instrumentation.ts +0 -199
  55. package/src/db/lucene.ts +0 -721
  56. package/src/db/searchIndexes/index.ts +0 -1
  57. package/src/db/searchIndexes/searchIndexes.ts +0 -62
  58. package/src/db/tests/DatabaseImpl.spec.ts +0 -55
  59. package/src/db/tests/connections.spec.ts +0 -22
  60. package/src/db/tests/index.spec.ts +0 -32
  61. package/src/db/tests/lucene.spec.ts +0 -400
  62. package/src/db/tests/pouch.spec.js +0 -62
  63. package/src/db/tests/utils.spec.ts +0 -63
  64. package/src/db/utils.ts +0 -208
  65. package/src/db/views.ts +0 -245
  66. package/src/docIds/conversions.ts +0 -60
  67. package/src/docIds/ids.ts +0 -126
  68. package/src/docIds/index.ts +0 -2
  69. package/src/docIds/newid.ts +0 -5
  70. package/src/docIds/params.ts +0 -189
  71. package/src/docUpdates/index.ts +0 -24
  72. package/src/environment.ts +0 -293
  73. package/src/errors/errors.ts +0 -119
  74. package/src/errors/index.ts +0 -1
  75. package/src/events/analytics.ts +0 -6
  76. package/src/events/asyncEvents/index.ts +0 -2
  77. package/src/events/asyncEvents/publisher.ts +0 -12
  78. package/src/events/asyncEvents/queue.ts +0 -22
  79. package/src/events/backfill.ts +0 -183
  80. package/src/events/documentId.ts +0 -56
  81. package/src/events/events.ts +0 -47
  82. package/src/events/identification.ts +0 -311
  83. package/src/events/index.ts +0 -15
  84. package/src/events/processors/AnalyticsProcessor.ts +0 -64
  85. package/src/events/processors/AuditLogsProcessor.ts +0 -92
  86. package/src/events/processors/LoggingProcessor.ts +0 -36
  87. package/src/events/processors/Processors.ts +0 -52
  88. package/src/events/processors/async/DocumentUpdateProcessor.ts +0 -38
  89. package/src/events/processors/index.ts +0 -19
  90. package/src/events/processors/posthog/PosthogProcessor.ts +0 -118
  91. package/src/events/processors/posthog/index.ts +0 -3
  92. package/src/events/processors/posthog/rateLimiting.ts +0 -106
  93. package/src/events/processors/posthog/tests/PosthogProcessor.spec.ts +0 -164
  94. package/src/events/processors/types.ts +0 -1
  95. package/src/events/publishers/account.ts +0 -41
  96. package/src/events/publishers/ai.ts +0 -21
  97. package/src/events/publishers/app.ts +0 -168
  98. package/src/events/publishers/auditLog.ts +0 -26
  99. package/src/events/publishers/auth.ts +0 -73
  100. package/src/events/publishers/automation.ts +0 -110
  101. package/src/events/publishers/backfill.ts +0 -74
  102. package/src/events/publishers/backup.ts +0 -42
  103. package/src/events/publishers/datasource.ts +0 -48
  104. package/src/events/publishers/email.ts +0 -17
  105. package/src/events/publishers/environmentVariable.ts +0 -38
  106. package/src/events/publishers/group.ts +0 -99
  107. package/src/events/publishers/index.ts +0 -25
  108. package/src/events/publishers/installation.ts +0 -38
  109. package/src/events/publishers/layout.ts +0 -26
  110. package/src/events/publishers/license.ts +0 -84
  111. package/src/events/publishers/org.ts +0 -37
  112. package/src/events/publishers/plugin.ts +0 -47
  113. package/src/events/publishers/query.ts +0 -89
  114. package/src/events/publishers/role.ts +0 -62
  115. package/src/events/publishers/rows.ts +0 -29
  116. package/src/events/publishers/screen.ts +0 -36
  117. package/src/events/publishers/serve.ts +0 -43
  118. package/src/events/publishers/table.ts +0 -70
  119. package/src/events/publishers/user.ts +0 -202
  120. package/src/events/publishers/view.ts +0 -107
  121. package/src/features/features.ts +0 -277
  122. package/src/features/index.ts +0 -2
  123. package/src/features/tests/features.spec.ts +0 -267
  124. package/src/features/tests/utils.ts +0 -64
  125. package/src/helpers.ts +0 -9
  126. package/src/index.ts +0 -59
  127. package/src/installation.ts +0 -115
  128. package/src/logging/alerts.ts +0 -26
  129. package/src/logging/correlation/correlation.ts +0 -15
  130. package/src/logging/correlation/index.ts +0 -1
  131. package/src/logging/correlation/middleware.ts +0 -18
  132. package/src/logging/index.ts +0 -4
  133. package/src/logging/pino/logger.ts +0 -239
  134. package/src/logging/pino/middleware.ts +0 -48
  135. package/src/logging/system.ts +0 -81
  136. package/src/logging/tests/system.spec.ts +0 -61
  137. package/src/middleware/adminOnly.ts +0 -9
  138. package/src/middleware/auditLog.ts +0 -6
  139. package/src/middleware/authenticated.ts +0 -247
  140. package/src/middleware/builderOnly.ts +0 -21
  141. package/src/middleware/builderOrAdmin.ts +0 -21
  142. package/src/middleware/contentSecurityPolicy.ts +0 -113
  143. package/src/middleware/csrf.ts +0 -81
  144. package/src/middleware/errorHandling.ts +0 -43
  145. package/src/middleware/index.ts +0 -24
  146. package/src/middleware/internalApi.ts +0 -23
  147. package/src/middleware/ip.ts +0 -12
  148. package/src/middleware/joi-validator.ts +0 -58
  149. package/src/middleware/matchers.ts +0 -39
  150. package/src/middleware/passport/datasource/google.ts +0 -102
  151. package/src/middleware/passport/local.ts +0 -54
  152. package/src/middleware/passport/sso/google.ts +0 -77
  153. package/src/middleware/passport/sso/oidc.ts +0 -152
  154. package/src/middleware/passport/sso/sso.ts +0 -138
  155. package/src/middleware/passport/sso/tests/google.spec.ts +0 -68
  156. package/src/middleware/passport/sso/tests/oidc.spec.ts +0 -144
  157. package/src/middleware/passport/sso/tests/sso.spec.ts +0 -197
  158. package/src/middleware/passport/utils.ts +0 -38
  159. package/src/middleware/querystringToBody.ts +0 -28
  160. package/src/middleware/tenancy.ts +0 -36
  161. package/src/middleware/tests/builder.spec.ts +0 -181
  162. package/src/middleware/tests/contentSecurityPolicy.spec.ts +0 -75
  163. package/src/middleware/tests/matchers.spec.ts +0 -100
  164. package/src/migrations/definitions.ts +0 -40
  165. package/src/migrations/index.ts +0 -2
  166. package/src/migrations/migrations.ts +0 -186
  167. package/src/migrations/tests/__snapshots__/migrations.spec.ts.snap +0 -11
  168. package/src/migrations/tests/migrations.spec.ts +0 -64
  169. package/src/objectStore/buckets/app.ts +0 -53
  170. package/src/objectStore/buckets/global.ts +0 -29
  171. package/src/objectStore/buckets/index.ts +0 -3
  172. package/src/objectStore/buckets/plugins.ts +0 -71
  173. package/src/objectStore/buckets/tests/app.spec.ts +0 -161
  174. package/src/objectStore/buckets/tests/global.spec.ts +0 -74
  175. package/src/objectStore/buckets/tests/plugins.spec.ts +0 -111
  176. package/src/objectStore/cloudfront.ts +0 -41
  177. package/src/objectStore/index.ts +0 -3
  178. package/src/objectStore/objectStore.ts +0 -585
  179. package/src/objectStore/utils.ts +0 -113
  180. package/src/platform/index.ts +0 -3
  181. package/src/platform/platformDb.ts +0 -6
  182. package/src/platform/tenants.ts +0 -101
  183. package/src/platform/tests/tenants.spec.ts +0 -26
  184. package/src/platform/users.ts +0 -129
  185. package/src/plugin/index.ts +0 -1
  186. package/src/plugin/tests/validation.spec.ts +0 -209
  187. package/src/plugin/utils.ts +0 -175
  188. package/src/queue/constants.ts +0 -8
  189. package/src/queue/inMemoryQueue.ts +0 -189
  190. package/src/queue/index.ts +0 -2
  191. package/src/queue/listeners.ts +0 -199
  192. package/src/queue/queue.ts +0 -84
  193. package/src/redis/index.ts +0 -6
  194. package/src/redis/init.ts +0 -118
  195. package/src/redis/redis.ts +0 -358
  196. package/src/redis/redlockImpl.ts +0 -155
  197. package/src/redis/tests/redis.spec.ts +0 -207
  198. package/src/redis/tests/redlockImpl.spec.ts +0 -105
  199. package/src/redis/utils.ts +0 -128
  200. package/src/security/auth.ts +0 -24
  201. package/src/security/encryption.ts +0 -185
  202. package/src/security/index.ts +0 -1
  203. package/src/security/permissions.ts +0 -166
  204. package/src/security/roles.ts +0 -655
  205. package/src/security/secrets.ts +0 -20
  206. package/src/security/sessions.ts +0 -123
  207. package/src/security/tests/auth.spec.ts +0 -45
  208. package/src/security/tests/encryption.spec.ts +0 -31
  209. package/src/security/tests/permissions.spec.ts +0 -146
  210. package/src/security/tests/secrets.spec.ts +0 -35
  211. package/src/security/tests/sessions.spec.ts +0 -12
  212. package/src/sql/designDoc.ts +0 -17
  213. package/src/sql/index.ts +0 -5
  214. package/src/sql/sql.ts +0 -1854
  215. package/src/sql/sqlTable.ts +0 -319
  216. package/src/sql/utils.ts +0 -193
  217. package/src/tenancy/db.ts +0 -6
  218. package/src/tenancy/index.ts +0 -2
  219. package/src/tenancy/tenancy.ts +0 -148
  220. package/src/tenancy/tests/tenancy.spec.ts +0 -184
  221. package/src/timers/index.ts +0 -1
  222. package/src/timers/timers.ts +0 -22
  223. package/src/users/db.ts +0 -582
  224. package/src/users/events.ts +0 -176
  225. package/src/users/index.ts +0 -4
  226. package/src/users/lookup.ts +0 -99
  227. package/src/users/test/db.spec.ts +0 -188
  228. package/src/users/test/utils.spec.ts +0 -67
  229. package/src/users/users.ts +0 -353
  230. package/src/users/utils.ts +0 -81
  231. package/src/utils/Duration.ts +0 -56
  232. package/src/utils/hashing.ts +0 -15
  233. package/src/utils/index.ts +0 -4
  234. package/src/utils/stringUtils.ts +0 -8
  235. package/src/utils/tests/Duration.spec.ts +0 -19
  236. package/src/utils/tests/utils.spec.ts +0 -204
  237. package/src/utils/utils.ts +0 -249
  238. package/tests/core/logging.ts +0 -34
  239. package/tests/core/users/users.spec.js +0 -53
  240. package/tests/core/utilities/index.ts +0 -7
  241. package/tests/core/utilities/jestUtils.ts +0 -33
  242. package/tests/core/utilities/mocks/alerts.ts +0 -4
  243. package/tests/core/utilities/mocks/date.ts +0 -3
  244. package/tests/core/utilities/mocks/events.ts +0 -132
  245. package/tests/core/utilities/mocks/index.ts +0 -9
  246. package/tests/core/utilities/mocks/licenses.ts +0 -119
  247. package/tests/core/utilities/queue.ts +0 -9
  248. package/tests/core/utilities/structures/Chance.ts +0 -20
  249. package/tests/core/utilities/structures/accounts.ts +0 -80
  250. package/tests/core/utilities/structures/apps.ts +0 -21
  251. package/tests/core/utilities/structures/common.ts +0 -7
  252. package/tests/core/utilities/structures/db.ts +0 -12
  253. package/tests/core/utilities/structures/documents/index.ts +0 -1
  254. package/tests/core/utilities/structures/documents/platform/index.ts +0 -1
  255. package/tests/core/utilities/structures/documents/platform/installation.ts +0 -12
  256. package/tests/core/utilities/structures/generator.ts +0 -3
  257. package/tests/core/utilities/structures/index.ts +0 -15
  258. package/tests/core/utilities/structures/koa.ts +0 -16
  259. package/tests/core/utilities/structures/licenses.ts +0 -190
  260. package/tests/core/utilities/structures/plugins.ts +0 -19
  261. package/tests/core/utilities/structures/quotas.ts +0 -72
  262. package/tests/core/utilities/structures/scim.ts +0 -80
  263. package/tests/core/utilities/structures/sso.ts +0 -118
  264. package/tests/core/utilities/structures/tenants.ts +0 -5
  265. package/tests/core/utilities/structures/userGroups.ts +0 -10
  266. package/tests/core/utilities/structures/users.ts +0 -89
  267. package/tests/core/utilities/testContainerUtils.ts +0 -165
  268. package/tests/core/utilities/utils/index.ts +0 -2
  269. package/tests/core/utilities/utils/queue.ts +0 -27
  270. package/tests/core/utilities/utils/time.ts +0 -3
  271. package/tests/extra/DBTestConfiguration.ts +0 -36
  272. package/tests/extra/index.ts +0 -2
  273. package/tests/extra/testEnv.ts +0 -95
  274. package/tests/index.ts +0 -2
  275. package/tests/jestEnv.ts +0 -10
  276. package/tests/jestSetup.ts +0 -36
@@ -1,132 +0,0 @@
1
- beforeAll(async () => {
2
- const processors = await import("../../../../src/events/processors")
3
- const events = await import("../../../../src/events")
4
- jest.spyOn(processors.analyticsProcessor, "processEvent")
5
-
6
- jest.spyOn(events.identification, "identifyTenantGroup")
7
- jest.spyOn(events.identification, "identifyUser")
8
-
9
- jest.spyOn(events.backfill, "appSucceeded")
10
- jest.spyOn(events.backfill, "tenantSucceeded")
11
-
12
- jest.spyOn(events.account, "created")
13
- jest.spyOn(events.account, "deleted")
14
- jest.spyOn(events.account, "verified")
15
-
16
- jest.spyOn(events.app, "created")
17
- jest.spyOn(events.app, "updated")
18
- jest.spyOn(events.app, "duplicated")
19
- jest.spyOn(events.app, "deleted")
20
- jest.spyOn(events.app, "published")
21
- jest.spyOn(events.app, "unpublished")
22
- jest.spyOn(events.app, "templateImported")
23
- jest.spyOn(events.app, "fileImported")
24
- jest.spyOn(events.app, "versionUpdated")
25
- jest.spyOn(events.app, "versionReverted")
26
- jest.spyOn(events.app, "reverted")
27
- jest.spyOn(events.app, "exported")
28
-
29
- jest.spyOn(events.auth, "login")
30
- jest.spyOn(events.auth, "logout")
31
- jest.spyOn(events.auth, "SSOCreated")
32
- jest.spyOn(events.auth, "SSOUpdated")
33
- jest.spyOn(events.auth, "SSOActivated")
34
- jest.spyOn(events.auth, "SSODeactivated")
35
-
36
- jest.spyOn(events.automation, "created")
37
- jest.spyOn(events.automation, "deleted")
38
- jest.spyOn(events.automation, "tested")
39
- jest.spyOn(events.automation, "stepCreated")
40
- jest.spyOn(events.automation, "stepDeleted")
41
- jest.spyOn(events.automation, "triggerUpdated")
42
-
43
- jest.spyOn(events.datasource, "created")
44
- jest.spyOn(events.datasource, "updated")
45
- jest.spyOn(events.datasource, "deleted")
46
-
47
- jest.spyOn(events.email, "SMTPCreated")
48
- jest.spyOn(events.email, "SMTPUpdated")
49
-
50
- jest.spyOn(events.layout, "created")
51
- jest.spyOn(events.layout, "deleted")
52
-
53
- jest.spyOn(events.org, "nameUpdated")
54
- jest.spyOn(events.org, "logoUpdated")
55
- jest.spyOn(events.org, "platformURLUpdated")
56
- jest.spyOn(events.org, "analyticsOptOut")
57
-
58
- jest.spyOn(events.installation, "versionChecked")
59
-
60
- jest.spyOn(events.query, "created")
61
- jest.spyOn(events.query, "updated")
62
- jest.spyOn(events.query, "deleted")
63
- jest.spyOn(events.query, "imported")
64
- jest.spyOn(events.query, "previewed")
65
-
66
- jest.spyOn(events.role, "created")
67
- jest.spyOn(events.role, "updated")
68
- jest.spyOn(events.role, "deleted")
69
- jest.spyOn(events.role, "assigned")
70
- jest.spyOn(events.role, "unassigned")
71
-
72
- jest.spyOn(events.rows, "imported")
73
- jest.spyOn(events.rows, "created")
74
-
75
- jest.spyOn(events.screen, "created")
76
- jest.spyOn(events.screen, "deleted")
77
-
78
- jest.spyOn(events.user, "created")
79
- jest.spyOn(events.user, "updated")
80
- jest.spyOn(events.user, "deleted")
81
- jest.spyOn(events.user, "permissionAdminAssigned")
82
- jest.spyOn(events.user, "permissionAdminRemoved")
83
- jest.spyOn(events.user, "permissionBuilderAssigned")
84
- jest.spyOn(events.user, "permissionBuilderRemoved")
85
- jest.spyOn(events.user, "invited")
86
- jest.spyOn(events.user, "inviteAccepted")
87
- jest.spyOn(events.user, "passwordForceReset")
88
- jest.spyOn(events.user, "passwordUpdated")
89
- jest.spyOn(events.user, "passwordResetRequested")
90
- jest.spyOn(events.user, "passwordReset")
91
-
92
- jest.spyOn(events.group, "created")
93
- jest.spyOn(events.group, "updated")
94
- jest.spyOn(events.group, "deleted")
95
- jest.spyOn(events.group, "usersAdded")
96
- jest.spyOn(events.group, "usersDeleted")
97
- jest.spyOn(events.group, "createdOnboarding")
98
- jest.spyOn(events.group, "permissionsEdited")
99
-
100
- jest.spyOn(events.serve, "servedBuilder")
101
- jest.spyOn(events.serve, "servedApp")
102
- jest.spyOn(events.serve, "servedAppPreview")
103
-
104
- jest.spyOn(events.table, "created")
105
- jest.spyOn(events.table, "updated")
106
- jest.spyOn(events.table, "deleted")
107
- jest.spyOn(events.table, "exported")
108
- jest.spyOn(events.table, "imported")
109
-
110
- jest.spyOn(events.view, "created")
111
- jest.spyOn(events.view, "updated")
112
- jest.spyOn(events.view, "deleted")
113
- jest.spyOn(events.view, "exported")
114
- jest.spyOn(events.view, "filterCreated")
115
- jest.spyOn(events.view, "filterUpdated")
116
- jest.spyOn(events.view, "filterDeleted")
117
- jest.spyOn(events.view, "calculationCreated")
118
- jest.spyOn(events.view, "calculationUpdated")
119
- jest.spyOn(events.view, "calculationDeleted")
120
-
121
- jest.spyOn(events.plugin, "init")
122
- jest.spyOn(events.plugin, "imported")
123
- jest.spyOn(events.plugin, "deleted")
124
-
125
- jest.spyOn(events.license, "planChanged")
126
- jest.spyOn(events.license, "activated")
127
- jest.spyOn(events.license, "checkoutOpened")
128
- jest.spyOn(events.license, "checkoutSuccess")
129
- jest.spyOn(events.license, "portalOpened")
130
- jest.spyOn(events.license, "paymentFailed")
131
- jest.spyOn(events.license, "paymentRecovered")
132
- })
@@ -1,9 +0,0 @@
1
- jest.mock("../../../../src/accounts")
2
- import * as _accounts from "../../../../src/accounts"
3
-
4
- export const accounts = jest.mocked(_accounts)
5
-
6
- export * as date from "./date"
7
- export * as licenses from "./licenses"
8
- export * from "./alerts"
9
- import "./events"
@@ -1,119 +0,0 @@
1
- import { Feature, License, Quotas } from "@budibase/types"
2
- import cloneDeep from "lodash/cloneDeep"
3
-
4
- let CLOUD_FREE_LICENSE: License
5
- let UNLIMITED_LICENSE: License
6
- let getCachedLicense: any
7
-
8
- // init for the packages other than pro
9
- export function init(proPkg: any) {
10
- initInternal({
11
- CLOUD_FREE_LICENSE: proPkg.constants.licenses.CLOUD_FREE_LICENSE,
12
- UNLIMITED_LICENSE: proPkg.constants.licenses.UNLIMITED_LICENSE,
13
- getCachedLicense: proPkg.licensing.cache.getCachedLicense,
14
- })
15
- }
16
-
17
- // init for the pro package
18
- export function initInternal(opts: {
19
- CLOUD_FREE_LICENSE: License
20
- UNLIMITED_LICENSE: License
21
- getCachedLicense: any
22
- }) {
23
- CLOUD_FREE_LICENSE = opts.CLOUD_FREE_LICENSE
24
- UNLIMITED_LICENSE = opts.UNLIMITED_LICENSE
25
- getCachedLicense = opts.getCachedLicense
26
- }
27
-
28
- export interface UseLicenseOpts {
29
- features?: Feature[]
30
- quotas?: Quotas
31
- }
32
-
33
- // LICENSES
34
-
35
- export const useLicense = (license: License, opts?: UseLicenseOpts) => {
36
- if (opts) {
37
- if (opts.features) {
38
- license.features.push(...opts.features)
39
- }
40
- if (opts.quotas) {
41
- license.quotas = opts.quotas
42
- }
43
- }
44
-
45
- getCachedLicense.mockReturnValue(license)
46
-
47
- return license
48
- }
49
-
50
- export const useUnlimited = (opts?: UseLicenseOpts) => {
51
- return useLicense(UNLIMITED_LICENSE, opts)
52
- }
53
-
54
- export const useCloudFree = () => {
55
- return useLicense(CLOUD_FREE_LICENSE)
56
- }
57
-
58
- // FEATURES
59
-
60
- const useFeature = (feature: Feature) => {
61
- const license = cloneDeep(getCachedLicense() || UNLIMITED_LICENSE)
62
- const opts: UseLicenseOpts = {
63
- features: [feature],
64
- }
65
-
66
- return useLicense(license, opts)
67
- }
68
-
69
- export const useBackups = () => {
70
- return useFeature(Feature.APP_BACKUPS)
71
- }
72
-
73
- export const useEnforceableSSO = () => {
74
- return useFeature(Feature.ENFORCEABLE_SSO)
75
- }
76
-
77
- export const useGroups = () => {
78
- return useFeature(Feature.USER_GROUPS)
79
- }
80
-
81
- export const useEnvironmentVariables = () => {
82
- return useFeature(Feature.ENVIRONMENT_VARIABLES)
83
- }
84
-
85
- export const useAuditLogs = () => {
86
- return useFeature(Feature.AUDIT_LOGS)
87
- }
88
-
89
- export const useExpandedPublicApi = () => {
90
- return useFeature(Feature.EXPANDED_PUBLIC_API)
91
- }
92
-
93
- export const useScimIntegration = () => {
94
- return useFeature(Feature.SCIM)
95
- }
96
-
97
- export const useSyncAutomations = () => {
98
- return useFeature(Feature.SYNC_AUTOMATIONS)
99
- }
100
-
101
- export const useAppBuilders = () => {
102
- return useFeature(Feature.APP_BUILDERS)
103
- }
104
-
105
- export const useBudibaseAI = () => {
106
- return useFeature(Feature.BUDIBASE_AI)
107
- }
108
-
109
- export const useAICustomConfigs = () => {
110
- return useFeature(Feature.AI_CUSTOM_CONFIGS)
111
- }
112
-
113
- // QUOTAS
114
-
115
- export const setAutomationLogsQuota = (value: number) => {
116
- const license = cloneDeep(UNLIMITED_LICENSE)
117
- license.quotas.constant.automationLogRetentionDays.value = value
118
- return useLicense(license)
119
- }
@@ -1,9 +0,0 @@
1
- import { Queue } from "bull"
2
-
3
- export async function processMessages(queue: Queue) {
4
- do {
5
- await queue.whenCurrentJobsFinished()
6
- } while (await queue.count())
7
-
8
- await queue.whenCurrentJobsFinished()
9
- }
@@ -1,20 +0,0 @@
1
- import Chance from "chance"
2
-
3
- export default class CustomChance extends Chance {
4
- arrayOf<T>(
5
- generateFn: () => T,
6
- opts: { min?: number; max?: number } = {}
7
- ): T[] {
8
- const itemCount = this.integer({
9
- min: opts.min != null ? opts.min : 1,
10
- max: opts.max != null ? opts.max : 50,
11
- })
12
-
13
- const items = []
14
- for (let i = 0; i < itemCount; i++) {
15
- items.push(generateFn())
16
- }
17
-
18
- return items
19
- }
20
- }
@@ -1,80 +0,0 @@
1
- import { generator, quotas, uuid } from "."
2
- import { generateGlobalUserID } from "../../../../src/docIds"
3
- import {
4
- Account,
5
- AccountSSOProvider,
6
- AccountSSOProviderType,
7
- AuthType,
8
- CloudAccount,
9
- Hosting,
10
- SSOAccount,
11
- } from "@budibase/types"
12
- import sample from "lodash/sample"
13
-
14
- export const account = (partial: Partial<Account> = {}): Account => {
15
- return {
16
- accountId: uuid(),
17
- tenantId: generator.word(),
18
- email: generator.email({ domain: "example.com" }),
19
- accountName: generator.word(),
20
- tenantName: generator.word(),
21
- hosting: Hosting.SELF,
22
- createdAt: Date.now(),
23
- verified: true,
24
- verificationSent: true,
25
- authType: AuthType.PASSWORD,
26
- name: generator.name(),
27
- size: "10+",
28
- profession: "Software Engineer",
29
- quotaUsage: quotas.usage(),
30
- ...partial,
31
- }
32
- }
33
-
34
- export function selfHostAccount() {
35
- return account()
36
- }
37
-
38
- export const cloudAccount = (): CloudAccount => {
39
- return {
40
- ...account(),
41
- hosting: Hosting.CLOUD,
42
- budibaseUserId: generateGlobalUserID(),
43
- }
44
- }
45
-
46
- function providerType(): AccountSSOProviderType {
47
- return sample(Object.values(AccountSSOProviderType)) as AccountSSOProviderType
48
- }
49
-
50
- function provider(): AccountSSOProvider {
51
- return sample(Object.values(AccountSSOProvider)) as AccountSSOProvider
52
- }
53
-
54
- export function ssoAccount(account: Account = cloudAccount()): SSOAccount {
55
- return {
56
- ...account,
57
- authType: AuthType.SSO,
58
- oauth2: {
59
- accessToken: generator.string(),
60
- refreshToken: generator.string(),
61
- },
62
- provider: provider(),
63
- providerType: providerType(),
64
- }
65
- }
66
-
67
- export function verifiableSsoAccount(
68
- account: Account = cloudAccount()
69
- ): SSOAccount {
70
- return {
71
- ...account,
72
- authType: AuthType.SSO,
73
- oauth2: {
74
- accessToken: generator.string(),
75
- refreshToken: generator.string(),
76
- },
77
- provider: AccountSSOProvider.MICROSOFT,
78
- providerType: AccountSSOProviderType.MICROSOFT,
79
- }
80
- }
@@ -1,21 +0,0 @@
1
- import { generator } from "."
2
- import { App } from "@budibase/types"
3
- import { DEFAULT_TENANT_ID, DocumentType } from "../../../../src/constants"
4
-
5
- export function app(id: string): App {
6
- return {
7
- _id: DocumentType.APP_METADATA,
8
- appId: id,
9
- type: "",
10
- version: "0.0.1",
11
- componentLibraries: [],
12
- name: generator.name(),
13
- url: `/custom-url`,
14
- instance: {
15
- _id: id,
16
- },
17
- tenantId: DEFAULT_TENANT_ID,
18
- status: "",
19
- template: undefined,
20
- }
21
- }
@@ -1,7 +0,0 @@
1
- import { v4 as uuid } from "uuid"
2
-
3
- export { v4 as uuid } from "uuid"
4
-
5
- export const email = () => {
6
- return `${uuid()}@example.com`
7
- }
@@ -1,12 +0,0 @@
1
- import { generator } from "./generator"
2
- import { newid } from "../../../../src/docIds/newid"
3
-
4
- export function id() {
5
- return `db_${newid()}`
6
- }
7
-
8
- export function rev() {
9
- return `${generator.character({
10
- numeric: true,
11
- })}-${generator.guid().replace(/-/, "")}`
12
- }
@@ -1 +0,0 @@
1
- export * from "./platform"
@@ -1 +0,0 @@
1
- export * as installation from "./installation"
@@ -1,12 +0,0 @@
1
- import { generator } from "../../generator"
2
- import { Installation } from "@budibase/types"
3
- import * as db from "../../db"
4
-
5
- export function install(): Installation {
6
- return {
7
- _id: "install",
8
- _rev: db.rev(),
9
- installId: generator.guid(),
10
- version: generator.string(),
11
- }
12
- }
@@ -1,3 +0,0 @@
1
- import Chance from "./Chance"
2
-
3
- export const generator = new Chance()
@@ -1,15 +0,0 @@
1
- export * from "./common"
2
- export * as accounts from "./accounts"
3
- export * as apps from "./apps"
4
- export * as db from "./db"
5
- export * as docs from "./documents"
6
- export * as koa from "./koa"
7
- export * as licenses from "./licenses"
8
- export * as plugins from "./plugins"
9
- export * as sso from "./sso"
10
- export * as tenant from "./tenants"
11
- export * as users from "./users"
12
- export * as userGroups from "./userGroups"
13
- export { generator } from "./generator"
14
- export * as scim from "./scim"
15
- export * as quotas from "./quotas"
@@ -1,16 +0,0 @@
1
- import { createMockContext, createMockCookies } from "@shopify/jest-koa-mocks"
2
- import { BBContext } from "@budibase/types"
3
-
4
- export const newContext = (): BBContext => {
5
- const ctx = createMockContext() as any
6
- return {
7
- ...ctx,
8
- path: "/",
9
- cookies: createMockCookies(),
10
- request: {
11
- ...ctx.request,
12
- headers: {},
13
- body: {},
14
- },
15
- }
16
- }
@@ -1,190 +0,0 @@
1
- import {
2
- Billing,
3
- Customer,
4
- Feature,
5
- License,
6
- OfflineIdentifier,
7
- OfflineLicense,
8
- PlanModel,
9
- PlanType,
10
- PriceDuration,
11
- PurchasedPlan,
12
- PurchasedPrice,
13
- Quotas,
14
- Subscription,
15
- } from "@budibase/types"
16
- import { generator } from "./generator"
17
-
18
- export function price(): PurchasedPrice {
19
- return {
20
- amount: 10000,
21
- amountMonthly: 10000,
22
- currency: "usd",
23
- duration: PriceDuration.MONTHLY,
24
- priceId: "price_123",
25
- dayPasses: undefined,
26
- isPerUser: true,
27
- }
28
- }
29
-
30
- export const plan = (type: PlanType = PlanType.FREE): PurchasedPlan => {
31
- return {
32
- type,
33
- usesInvoicing: false,
34
- model: PlanModel.PER_USER,
35
- price: type !== PlanType.FREE ? price() : undefined,
36
- }
37
- }
38
-
39
- export function quotas(): Quotas {
40
- return {
41
- usage: {
42
- monthly: {
43
- queries: {
44
- name: "Queries",
45
- value: 1,
46
- triggers: [],
47
- },
48
- automations: {
49
- name: "Queries",
50
- value: 1,
51
- triggers: [],
52
- },
53
- dayPasses: {
54
- name: "Queries",
55
- value: 1,
56
- triggers: [],
57
- },
58
- budibaseAICredits: {
59
- name: "Budibase AI Credits",
60
- value: 1,
61
- triggers: [],
62
- },
63
- },
64
- static: {
65
- rows: {
66
- name: "Rows",
67
- value: 1,
68
- triggers: [],
69
- },
70
- apps: {
71
- name: "Apps",
72
- value: 1,
73
- triggers: [],
74
- },
75
- users: {
76
- name: "Users",
77
- value: 1,
78
- triggers: [],
79
- },
80
- creators: {
81
- name: "Creators",
82
- value: 1,
83
- triggers: [],
84
- },
85
- userGroups: {
86
- name: "User Groups",
87
- value: 1,
88
- triggers: [],
89
- },
90
- plugins: {
91
- name: "Plugins",
92
- value: 1,
93
- triggers: [],
94
- },
95
- aiCustomConfigs: {
96
- name: "Plugins",
97
- value: 1,
98
- triggers: [],
99
- },
100
- },
101
- },
102
- constant: {
103
- automationLogRetentionDays: {
104
- name: "Automation Logs",
105
- value: 1,
106
- triggers: [],
107
- },
108
- appBackupRetentionDays: {
109
- name: "Backups",
110
- value: 1,
111
- triggers: [],
112
- },
113
- },
114
- }
115
- }
116
-
117
- export function billing(
118
- opts: { customer?: Customer; subscription?: Subscription } = {}
119
- ): Billing {
120
- return {
121
- customer: opts.customer || customer(),
122
- subscription: opts.subscription || subscription(),
123
- }
124
- }
125
-
126
- export function customer(): Customer {
127
- return {
128
- balance: 0,
129
- currency: "usd",
130
- }
131
- }
132
-
133
- export function subscription(): Subscription {
134
- return {
135
- amount: 10000,
136
- amounts: {
137
- user: 10000,
138
- creator: 0,
139
- },
140
- cancelAt: undefined,
141
- currency: "usd",
142
- currentPeriodEnd: 0,
143
- currentPeriodStart: 0,
144
- downgradeAt: 0,
145
- duration: PriceDuration.MONTHLY,
146
- pastDueAt: undefined,
147
- quantity: 0,
148
- quantities: {
149
- user: 0,
150
- creator: 0,
151
- },
152
- status: "active",
153
- }
154
- }
155
-
156
- interface GenerateLicenseOpts {
157
- quotas?: Quotas
158
- plan?: PurchasedPlan
159
- planType?: PlanType
160
- features?: Feature[]
161
- billing?: Billing
162
- }
163
-
164
- export const license = (opts: GenerateLicenseOpts = {}): License => {
165
- return {
166
- features: opts.features || [],
167
- quotas: opts.quotas || quotas(),
168
- plan: opts.plan || plan(opts.planType),
169
- billing: opts.billing || billing(),
170
- }
171
- }
172
-
173
- export function offlineLicense(opts: GenerateLicenseOpts = {}): OfflineLicense {
174
- const base = license(opts)
175
- return {
176
- ...base,
177
- expireAt: new Date().toISOString(),
178
- identifier: offlineIdentifier(),
179
- }
180
- }
181
-
182
- export function offlineIdentifier(
183
- installId: string = generator.guid(),
184
- tenantId: string = generator.guid()
185
- ): OfflineIdentifier {
186
- return {
187
- installId,
188
- tenantId,
189
- }
190
- }
@@ -1,19 +0,0 @@
1
- import { generator } from "."
2
- import { Plugin, PluginSource, PluginType } from "@budibase/types"
3
-
4
- export function plugin(): Plugin {
5
- return {
6
- description: generator.word(),
7
- name: generator.word(),
8
- version: "1.0.0",
9
- source: PluginSource.FILE,
10
- package: {
11
- name: generator.word,
12
- },
13
- hash: generator.hash(),
14
- schema: {
15
- type: PluginType.DATASOURCE,
16
- },
17
- iconFileName: "icon.svg",
18
- }
19
- }