@budibase/backend-core 2.9.19 → 2.9.20

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 (241) hide show
  1. package/dist/package.json +19 -4
  2. package/dist/src/security/permissions.d.ts +1 -1
  3. package/package.json +19 -4
  4. package/dist/tsconfig.build.tsbuildinfo +0 -1
  5. package/src/accounts/accounts.ts +0 -82
  6. package/src/accounts/api.ts +0 -59
  7. package/src/accounts/index.ts +0 -1
  8. package/src/auth/auth.ts +0 -208
  9. package/src/auth/index.ts +0 -1
  10. package/src/auth/tests/auth.spec.ts +0 -14
  11. package/src/blacklist/blacklist.ts +0 -54
  12. package/src/blacklist/index.ts +0 -1
  13. package/src/blacklist/tests/blacklist.spec.ts +0 -46
  14. package/src/cache/appMetadata.ts +0 -88
  15. package/src/cache/base/index.ts +0 -92
  16. package/src/cache/generic.ts +0 -30
  17. package/src/cache/index.ts +0 -5
  18. package/src/cache/tests/writethrough.spec.ts +0 -138
  19. package/src/cache/user.ts +0 -69
  20. package/src/cache/writethrough.ts +0 -133
  21. package/src/configs/configs.ts +0 -257
  22. package/src/configs/index.ts +0 -1
  23. package/src/configs/tests/configs.spec.ts +0 -184
  24. package/src/constants/db.ts +0 -63
  25. package/src/constants/index.ts +0 -2
  26. package/src/constants/misc.ts +0 -50
  27. package/src/context/Context.ts +0 -14
  28. package/src/context/identity.ts +0 -58
  29. package/src/context/index.ts +0 -3
  30. package/src/context/mainContext.ts +0 -310
  31. package/src/context/tests/index.spec.ts +0 -147
  32. package/src/context/types.ts +0 -11
  33. package/src/db/Replication.ts +0 -84
  34. package/src/db/constants.ts +0 -10
  35. package/src/db/couch/DatabaseImpl.ts +0 -238
  36. package/src/db/couch/connections.ts +0 -77
  37. package/src/db/couch/index.ts +0 -5
  38. package/src/db/couch/pouchDB.ts +0 -97
  39. package/src/db/couch/pouchDump.ts +0 -0
  40. package/src/db/couch/utils.ts +0 -50
  41. package/src/db/db.ts +0 -39
  42. package/src/db/errors.ts +0 -14
  43. package/src/db/index.ts +0 -12
  44. package/src/db/lucene.ts +0 -732
  45. package/src/db/searchIndexes/index.ts +0 -1
  46. package/src/db/searchIndexes/searchIndexes.ts +0 -62
  47. package/src/db/tests/index.spec.js +0 -25
  48. package/src/db/tests/lucene.spec.ts +0 -298
  49. package/src/db/tests/pouch.spec.js +0 -62
  50. package/src/db/tests/utils.spec.ts +0 -63
  51. package/src/db/utils.ts +0 -207
  52. package/src/db/views.ts +0 -241
  53. package/src/docIds/conversions.ts +0 -59
  54. package/src/docIds/ids.ts +0 -113
  55. package/src/docIds/index.ts +0 -2
  56. package/src/docIds/newid.ts +0 -5
  57. package/src/docIds/params.ts +0 -174
  58. package/src/docUpdates/index.ts +0 -29
  59. package/src/environment.ts +0 -201
  60. package/src/errors/errors.ts +0 -119
  61. package/src/errors/index.ts +0 -1
  62. package/src/events/analytics.ts +0 -6
  63. package/src/events/asyncEvents/index.ts +0 -2
  64. package/src/events/asyncEvents/publisher.ts +0 -12
  65. package/src/events/asyncEvents/queue.ts +0 -22
  66. package/src/events/backfill.ts +0 -183
  67. package/src/events/documentId.ts +0 -56
  68. package/src/events/events.ts +0 -40
  69. package/src/events/identification.ts +0 -310
  70. package/src/events/index.ts +0 -14
  71. package/src/events/processors/AnalyticsProcessor.ts +0 -64
  72. package/src/events/processors/AuditLogsProcessor.ts +0 -93
  73. package/src/events/processors/LoggingProcessor.ts +0 -37
  74. package/src/events/processors/Processors.ts +0 -52
  75. package/src/events/processors/async/DocumentUpdateProcessor.ts +0 -43
  76. package/src/events/processors/index.ts +0 -19
  77. package/src/events/processors/posthog/PosthogProcessor.ts +0 -118
  78. package/src/events/processors/posthog/index.ts +0 -2
  79. package/src/events/processors/posthog/rateLimiting.ts +0 -106
  80. package/src/events/processors/posthog/tests/PosthogProcessor.spec.ts +0 -168
  81. package/src/events/processors/types.ts +0 -1
  82. package/src/events/publishers/account.ts +0 -35
  83. package/src/events/publishers/app.ts +0 -155
  84. package/src/events/publishers/auditLog.ts +0 -26
  85. package/src/events/publishers/auth.ts +0 -73
  86. package/src/events/publishers/automation.ts +0 -110
  87. package/src/events/publishers/backfill.ts +0 -74
  88. package/src/events/publishers/backup.ts +0 -42
  89. package/src/events/publishers/datasource.ts +0 -48
  90. package/src/events/publishers/email.ts +0 -17
  91. package/src/events/publishers/environmentVariable.ts +0 -38
  92. package/src/events/publishers/group.ts +0 -99
  93. package/src/events/publishers/index.ts +0 -24
  94. package/src/events/publishers/installation.ts +0 -38
  95. package/src/events/publishers/layout.ts +0 -26
  96. package/src/events/publishers/license.ts +0 -84
  97. package/src/events/publishers/org.ts +0 -37
  98. package/src/events/publishers/plugin.ts +0 -47
  99. package/src/events/publishers/query.ts +0 -88
  100. package/src/events/publishers/role.ts +0 -62
  101. package/src/events/publishers/rows.ts +0 -29
  102. package/src/events/publishers/screen.ts +0 -36
  103. package/src/events/publishers/serve.ts +0 -43
  104. package/src/events/publishers/table.ts +0 -70
  105. package/src/events/publishers/user.ts +0 -202
  106. package/src/events/publishers/view.ts +0 -107
  107. package/src/featureFlags/index.ts +0 -77
  108. package/src/featureFlags/tests/featureFlags.spec.ts +0 -85
  109. package/src/helpers.ts +0 -9
  110. package/src/index.ts +0 -53
  111. package/src/installation.ts +0 -107
  112. package/src/logging/alerts.ts +0 -26
  113. package/src/logging/correlation/correlation.ts +0 -13
  114. package/src/logging/correlation/index.ts +0 -1
  115. package/src/logging/correlation/middleware.ts +0 -17
  116. package/src/logging/index.ts +0 -4
  117. package/src/logging/pino/logger.ts +0 -232
  118. package/src/logging/pino/middleware.ts +0 -45
  119. package/src/logging/system.ts +0 -81
  120. package/src/logging/tests/system.spec.ts +0 -61
  121. package/src/middleware/adminOnly.ts +0 -9
  122. package/src/middleware/auditLog.ts +0 -6
  123. package/src/middleware/authenticated.ts +0 -193
  124. package/src/middleware/builderOnly.ts +0 -20
  125. package/src/middleware/builderOrAdmin.ts +0 -20
  126. package/src/middleware/csrf.ts +0 -81
  127. package/src/middleware/errorHandling.ts +0 -29
  128. package/src/middleware/index.ts +0 -21
  129. package/src/middleware/internalApi.ts +0 -23
  130. package/src/middleware/joi-validator.ts +0 -45
  131. package/src/middleware/matchers.ts +0 -47
  132. package/src/middleware/passport/datasource/google.ts +0 -95
  133. package/src/middleware/passport/local.ts +0 -54
  134. package/src/middleware/passport/sso/google.ts +0 -77
  135. package/src/middleware/passport/sso/oidc.ts +0 -154
  136. package/src/middleware/passport/sso/sso.ts +0 -165
  137. package/src/middleware/passport/sso/tests/google.spec.ts +0 -67
  138. package/src/middleware/passport/sso/tests/oidc.spec.ts +0 -152
  139. package/src/middleware/passport/sso/tests/sso.spec.ts +0 -197
  140. package/src/middleware/passport/utils.ts +0 -38
  141. package/src/middleware/querystringToBody.ts +0 -28
  142. package/src/middleware/tenancy.ts +0 -36
  143. package/src/middleware/tests/builder.spec.ts +0 -180
  144. package/src/middleware/tests/matchers.spec.ts +0 -134
  145. package/src/migrations/definitions.ts +0 -40
  146. package/src/migrations/index.ts +0 -2
  147. package/src/migrations/migrations.ts +0 -191
  148. package/src/migrations/tests/__snapshots__/migrations.spec.ts.snap +0 -11
  149. package/src/migrations/tests/migrations.spec.ts +0 -64
  150. package/src/objectStore/buckets/app.ts +0 -40
  151. package/src/objectStore/buckets/global.ts +0 -29
  152. package/src/objectStore/buckets/index.ts +0 -3
  153. package/src/objectStore/buckets/plugins.ts +0 -71
  154. package/src/objectStore/buckets/tests/app.spec.ts +0 -171
  155. package/src/objectStore/buckets/tests/global.spec.ts +0 -74
  156. package/src/objectStore/buckets/tests/plugins.spec.ts +0 -111
  157. package/src/objectStore/cloudfront.ts +0 -41
  158. package/src/objectStore/index.ts +0 -3
  159. package/src/objectStore/objectStore.ts +0 -440
  160. package/src/objectStore/utils.ts +0 -27
  161. package/src/platform/index.ts +0 -3
  162. package/src/platform/platformDb.ts +0 -6
  163. package/src/platform/tenants.ts +0 -101
  164. package/src/platform/tests/tenants.spec.ts +0 -26
  165. package/src/platform/users.ts +0 -90
  166. package/src/plugin/index.ts +0 -1
  167. package/src/plugin/tests/validation.spec.ts +0 -83
  168. package/src/plugin/utils.ts +0 -156
  169. package/src/queue/constants.ts +0 -6
  170. package/src/queue/inMemoryQueue.ts +0 -141
  171. package/src/queue/index.ts +0 -2
  172. package/src/queue/listeners.ts +0 -195
  173. package/src/queue/queue.ts +0 -54
  174. package/src/redis/index.ts +0 -6
  175. package/src/redis/init.ts +0 -86
  176. package/src/redis/redis.ts +0 -308
  177. package/src/redis/redlockImpl.ts +0 -139
  178. package/src/redis/utils.ts +0 -117
  179. package/src/security/encryption.ts +0 -179
  180. package/src/security/permissions.ts +0 -159
  181. package/src/security/roles.ts +0 -420
  182. package/src/security/sessions.ts +0 -120
  183. package/src/security/tests/encryption.spec.ts +0 -31
  184. package/src/security/tests/permissions.spec.ts +0 -145
  185. package/src/security/tests/sessions.spec.ts +0 -12
  186. package/src/tenancy/db.ts +0 -6
  187. package/src/tenancy/index.ts +0 -2
  188. package/src/tenancy/tenancy.ts +0 -140
  189. package/src/tenancy/tests/tenancy.spec.ts +0 -184
  190. package/src/timers/index.ts +0 -1
  191. package/src/timers/timers.ts +0 -22
  192. package/src/users/db.ts +0 -460
  193. package/src/users/events.ts +0 -176
  194. package/src/users/index.ts +0 -4
  195. package/src/users/lookup.ts +0 -102
  196. package/src/users/users.ts +0 -276
  197. package/src/users/utils.ts +0 -55
  198. package/src/utils/hashing.ts +0 -14
  199. package/src/utils/index.ts +0 -3
  200. package/src/utils/stringUtils.ts +0 -8
  201. package/src/utils/tests/utils.spec.ts +0 -191
  202. package/src/utils/utils.ts +0 -239
  203. package/tests/core/logging.ts +0 -34
  204. package/tests/core/utilities/index.ts +0 -6
  205. package/tests/core/utilities/jestUtils.ts +0 -30
  206. package/tests/core/utilities/mocks/alerts.ts +0 -3
  207. package/tests/core/utilities/mocks/date.ts +0 -2
  208. package/tests/core/utilities/mocks/events.ts +0 -131
  209. package/tests/core/utilities/mocks/fetch.ts +0 -17
  210. package/tests/core/utilities/mocks/index.ts +0 -10
  211. package/tests/core/utilities/mocks/licenses.ts +0 -107
  212. package/tests/core/utilities/mocks/posthog.ts +0 -7
  213. package/tests/core/utilities/structures/Chance.ts +0 -20
  214. package/tests/core/utilities/structures/accounts.ts +0 -115
  215. package/tests/core/utilities/structures/apps.ts +0 -21
  216. package/tests/core/utilities/structures/common.ts +0 -7
  217. package/tests/core/utilities/structures/db.ts +0 -12
  218. package/tests/core/utilities/structures/documents/index.ts +0 -1
  219. package/tests/core/utilities/structures/documents/platform/index.ts +0 -1
  220. package/tests/core/utilities/structures/documents/platform/installation.ts +0 -12
  221. package/tests/core/utilities/structures/generator.ts +0 -2
  222. package/tests/core/utilities/structures/index.ts +0 -15
  223. package/tests/core/utilities/structures/koa.ts +0 -16
  224. package/tests/core/utilities/structures/licenses.ts +0 -167
  225. package/tests/core/utilities/structures/plugins.ts +0 -19
  226. package/tests/core/utilities/structures/quotas.ts +0 -67
  227. package/tests/core/utilities/structures/scim.ts +0 -80
  228. package/tests/core/utilities/structures/shared.ts +0 -19
  229. package/tests/core/utilities/structures/sso.ts +0 -119
  230. package/tests/core/utilities/structures/tenants.ts +0 -5
  231. package/tests/core/utilities/structures/userGroups.ts +0 -10
  232. package/tests/core/utilities/structures/users.ts +0 -73
  233. package/tests/core/utilities/testContainerUtils.ts +0 -98
  234. package/tests/core/utilities/utils/index.ts +0 -1
  235. package/tests/core/utilities/utils/time.ts +0 -3
  236. package/tests/extra/DBTestConfiguration.ts +0 -36
  237. package/tests/extra/index.ts +0 -2
  238. package/tests/extra/testEnv.ts +0 -95
  239. package/tests/index.ts +0 -1
  240. package/tests/jestEnv.ts +0 -6
  241. package/tests/jestSetup.ts +0 -28
@@ -1,115 +0,0 @@
1
- import { generator, uuid, quotas } from "."
2
- import { generateGlobalUserID } from "../../../../src/docIds"
3
- import {
4
- Account,
5
- AccountSSOProvider,
6
- AccountSSOProviderType,
7
- AuthType,
8
- CloudAccount,
9
- Hosting,
10
- SSOAccount,
11
- CreateAccount,
12
- CreatePassswordAccount,
13
- } from "@budibase/types"
14
- import sample from "lodash/sample"
15
-
16
- export const account = (partial: Partial<Account> = {}): Account => {
17
- return {
18
- accountId: uuid(),
19
- tenantId: generator.word(),
20
- email: generator.email(),
21
- tenantName: generator.word(),
22
- hosting: Hosting.SELF,
23
- createdAt: Date.now(),
24
- verified: true,
25
- verificationSent: true,
26
- tier: "FREE", // DEPRECATED
27
- authType: AuthType.PASSWORD,
28
- name: generator.name(),
29
- size: "10+",
30
- profession: "Software Engineer",
31
- quotaUsage: quotas.usage(),
32
- ...partial,
33
- }
34
- }
35
-
36
- export function selfHostAccount() {
37
- return account()
38
- }
39
-
40
- export const cloudAccount = (): CloudAccount => {
41
- return {
42
- ...account(),
43
- hosting: Hosting.CLOUD,
44
- budibaseUserId: generateGlobalUserID(),
45
- }
46
- }
47
-
48
- function providerType(): AccountSSOProviderType {
49
- return sample(Object.values(AccountSSOProviderType)) as AccountSSOProviderType
50
- }
51
-
52
- function provider(): AccountSSOProvider {
53
- return sample(Object.values(AccountSSOProvider)) as AccountSSOProvider
54
- }
55
-
56
- export function ssoAccount(account: Account = cloudAccount()): SSOAccount {
57
- return {
58
- ...account,
59
- authType: AuthType.SSO,
60
- oauth2: {
61
- accessToken: generator.string(),
62
- refreshToken: generator.string(),
63
- },
64
- pictureUrl: generator.url(),
65
- provider: provider(),
66
- providerType: providerType(),
67
- thirdPartyProfile: {},
68
- }
69
- }
70
-
71
- export const cloudCreateAccount: CreatePassswordAccount = {
72
- email: "cloud@budibase.com",
73
- tenantId: "cloud",
74
- hosting: Hosting.CLOUD,
75
- authType: AuthType.PASSWORD,
76
- password: "Password123!",
77
- tenantName: "cloud",
78
- name: "Budi Armstrong",
79
- size: "10+",
80
- profession: "Software Engineer",
81
- }
82
-
83
- export const cloudSSOCreateAccount: CreateAccount = {
84
- email: "cloud-sso@budibase.com",
85
- tenantId: "cloud-sso",
86
- hosting: Hosting.CLOUD,
87
- authType: AuthType.SSO,
88
- tenantName: "cloudsso",
89
- name: "Budi Armstrong",
90
- size: "10+",
91
- profession: "Software Engineer",
92
- }
93
-
94
- export const selfCreateAccount: CreatePassswordAccount = {
95
- email: "self@budibase.com",
96
- tenantId: "self",
97
- hosting: Hosting.SELF,
98
- authType: AuthType.PASSWORD,
99
- password: "Password123!",
100
- tenantName: "self",
101
- name: "Budi Armstrong",
102
- size: "10+",
103
- profession: "Software Engineer",
104
- }
105
-
106
- export const selfSSOCreateAccount: CreateAccount = {
107
- email: "self-sso@budibase.com",
108
- tenantId: "self-sso",
109
- hosting: Hosting.SELF,
110
- authType: AuthType.SSO,
111
- tenantName: "selfsso",
112
- name: "Budi Armstrong",
113
- size: "10+",
114
- profession: "Software Engineer",
115
- }
@@ -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()}@test.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,2 +0,0 @@
1
- import Chance from "./Chance"
2
- 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()
6
- return {
7
- ...ctx,
8
- path: "/",
9
- cookies: createMockCookies(),
10
- request: {
11
- ...ctx.request,
12
- headers: {},
13
- body: {},
14
- },
15
- }
16
- }
@@ -1,167 +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
- },
59
- static: {
60
- rows: {
61
- name: "Rows",
62
- value: 1,
63
- triggers: [],
64
- },
65
- apps: {
66
- name: "Apps",
67
- value: 1,
68
- triggers: [],
69
- },
70
- users: {
71
- name: "Users",
72
- value: 1,
73
- triggers: [],
74
- },
75
- userGroups: {
76
- name: "User Groups",
77
- value: 1,
78
- triggers: [],
79
- },
80
- plugins: {
81
- name: "Plugins",
82
- value: 1,
83
- triggers: [],
84
- },
85
- },
86
- },
87
- constant: {
88
- automationLogRetentionDays: {
89
- name: "Automation Logs",
90
- value: 1,
91
- triggers: [],
92
- },
93
- appBackupRetentionDays: {
94
- name: "Backups",
95
- value: 1,
96
- triggers: [],
97
- },
98
- },
99
- }
100
- }
101
-
102
- export function billing(
103
- opts: { customer?: Customer; subscription?: Subscription } = {}
104
- ): Billing {
105
- return {
106
- customer: opts.customer || customer(),
107
- subscription: opts.subscription || subscription(),
108
- }
109
- }
110
-
111
- export function customer(): Customer {
112
- return {
113
- balance: 0,
114
- currency: "usd",
115
- }
116
- }
117
-
118
- export function subscription(): Subscription {
119
- return {
120
- amount: 10000,
121
- cancelAt: undefined,
122
- currency: "usd",
123
- currentPeriodEnd: 0,
124
- currentPeriodStart: 0,
125
- downgradeAt: 0,
126
- duration: PriceDuration.MONTHLY,
127
- pastDueAt: undefined,
128
- quantity: 0,
129
- status: "active",
130
- }
131
- }
132
-
133
- interface GenerateLicenseOpts {
134
- quotas?: Quotas
135
- plan?: PurchasedPlan
136
- planType?: PlanType
137
- features?: Feature[]
138
- billing?: Billing
139
- }
140
-
141
- export const license = (opts: GenerateLicenseOpts = {}): License => {
142
- return {
143
- features: opts.features || [],
144
- quotas: opts.quotas || quotas(),
145
- plan: opts.plan || plan(opts.planType),
146
- billing: opts.billing || billing(),
147
- }
148
- }
149
-
150
- export function offlineLicense(opts: GenerateLicenseOpts = {}): OfflineLicense {
151
- const base = license(opts)
152
- return {
153
- ...base,
154
- expireAt: new Date().toISOString(),
155
- identifier: offlineIdentifier(),
156
- }
157
- }
158
-
159
- export function offlineIdentifier(
160
- installId: string = generator.guid(),
161
- tenantId: string = generator.guid()
162
- ): OfflineIdentifier {
163
- return {
164
- installId,
165
- tenantId,
166
- }
167
- }
@@ -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
- }
@@ -1,67 +0,0 @@
1
- import { MonthlyQuotaName, QuotaUsage } from "@budibase/types"
2
-
3
- export const usage = (): QuotaUsage => {
4
- return {
5
- _id: "usage_quota",
6
- quotaReset: new Date().toISOString(),
7
- apps: {
8
- app_1: {
9
- // @ts-ignore - the apps definition doesn't match up to actual usage
10
- usageQuota: {
11
- rows: 0,
12
- },
13
- },
14
- },
15
- monthly: {
16
- "01-2023": {
17
- automations: 0,
18
- dayPasses: 0,
19
- queries: 0,
20
- triggers: {},
21
- breakdown: {
22
- rowQueries: {
23
- parent: MonthlyQuotaName.QUERIES,
24
- values: {
25
- row_1: 0,
26
- row_2: 0,
27
- },
28
- },
29
- datasourceQueries: {
30
- parent: MonthlyQuotaName.QUERIES,
31
- values: {
32
- ds_1: 0,
33
- ds_2: 0,
34
- },
35
- },
36
- automations: {
37
- parent: MonthlyQuotaName.AUTOMATIONS,
38
- values: {
39
- auto_1: 0,
40
- auto_2: 0,
41
- },
42
- },
43
- },
44
- },
45
- "02-2023": {
46
- automations: 0,
47
- dayPasses: 0,
48
- queries: 0,
49
- triggers: {},
50
- },
51
- current: {
52
- automations: 0,
53
- dayPasses: 0,
54
- queries: 0,
55
- triggers: {},
56
- },
57
- },
58
- usageQuota: {
59
- apps: 0,
60
- plugins: 0,
61
- users: 0,
62
- userGroups: 0,
63
- rows: 0,
64
- triggers: {},
65
- },
66
- }
67
- }
@@ -1,80 +0,0 @@
1
- import { ScimCreateGroupRequest, ScimCreateUserRequest } from "@budibase/types"
2
- import { uuid } from "./common"
3
- import { generator } from "./generator"
4
-
5
- interface CreateUserRequestFields {
6
- externalId: string
7
- email: string
8
- firstName: string
9
- lastName: string
10
- username: string
11
- }
12
-
13
- export function createUserRequest(userData?: Partial<CreateUserRequestFields>) {
14
- const defaultValues = {
15
- externalId: uuid(),
16
- email: generator.email(),
17
- firstName: generator.first(),
18
- lastName: generator.last(),
19
- username: generator.name(),
20
- }
21
-
22
- const { externalId, email, firstName, lastName, username } = {
23
- ...defaultValues,
24
- ...userData,
25
- }
26
-
27
- let user: ScimCreateUserRequest = {
28
- schemas: [
29
- "urn:ietf:params:scim:schemas:core:2.0:User",
30
- "urn:ietf:params:scim:schemas:extension:enterprise:2.0:User",
31
- ],
32
- externalId,
33
- userName: username,
34
- active: true,
35
- emails: [
36
- {
37
- primary: true,
38
- type: "work",
39
- value: email,
40
- },
41
- ],
42
- meta: {
43
- resourceType: "User",
44
- },
45
- roles: [],
46
- }
47
-
48
- if (firstName || lastName) {
49
- user.name = {
50
- formatted: [firstName, lastName].filter(s => s).join(" "),
51
- familyName: lastName,
52
- givenName: firstName,
53
- }
54
- }
55
-
56
- return user
57
- }
58
-
59
- export function createGroupRequest(groupData?: {
60
- externalId?: string
61
- displayName?: string
62
- }) {
63
- const { externalId = uuid(), displayName = generator.word() } =
64
- groupData || {}
65
-
66
- const group: ScimCreateGroupRequest = {
67
- schemas: [
68
- "urn:ietf:params:scim:schemas:core:2.0:Group",
69
- "http://schemas.microsoft.com/2006/11/ResourceManagement/ADSCIM/2.0/Group",
70
- ],
71
- externalId: externalId,
72
- displayName: displayName,
73
- meta: {
74
- resourceType: "Group",
75
- created: new Date(),
76
- lastModified: new Date(),
77
- },
78
- }
79
- return group
80
- }
@@ -1,19 +0,0 @@
1
- import { User } from "@budibase/types"
2
- import { generator } from "./generator"
3
- import { uuid } from "./common"
4
-
5
- export const newEmail = () => {
6
- return `${uuid()}@test.com`
7
- }
8
-
9
- export const user = (userProps?: any): User => {
10
- return {
11
- email: newEmail(),
12
- password: "test",
13
- roles: { app_test: "admin" },
14
- firstName: generator.first(),
15
- lastName: generator.last(),
16
- pictureUrl: "http://test.com",
17
- ...userProps,
18
- }
19
- }
@@ -1,119 +0,0 @@
1
- import {
2
- ConfigType,
3
- GoogleConfig,
4
- GoogleInnerConfig,
5
- JwtClaims,
6
- OAuth2,
7
- OIDCInnerConfig,
8
- OIDCWellKnownConfig,
9
- SSOAuthDetails,
10
- SSOProfile,
11
- SSOProviderType,
12
- User,
13
- } from "@budibase/types"
14
- import { generator } from "./generator"
15
- import { email, uuid } from "./common"
16
- import * as shared from "./shared"
17
- import { user } from "./shared"
18
- import sample from "lodash/sample"
19
-
20
- export function OAuth(): OAuth2 {
21
- return {
22
- refreshToken: generator.string(),
23
- accessToken: generator.string(),
24
- }
25
- }
26
-
27
- export function authDetails(userDoc?: User): SSOAuthDetails {
28
- if (!userDoc) {
29
- userDoc = user()
30
- }
31
-
32
- const userId = userDoc._id || uuid()
33
- const provider = generator.string()
34
-
35
- const profile = ssoProfile(userDoc)
36
- profile.provider = provider
37
- profile.id = userId
38
-
39
- return {
40
- email: userDoc.email,
41
- oauth2: OAuth(),
42
- profile,
43
- provider,
44
- providerType: providerType(),
45
- userId,
46
- }
47
- }
48
-
49
- export function providerType(): SSOProviderType {
50
- return sample(Object.values(SSOProviderType)) as SSOProviderType
51
- }
52
-
53
- export function ssoProfile(user?: User): SSOProfile {
54
- if (!user) {
55
- user = shared.user()
56
- }
57
- return {
58
- id: user._id!,
59
- name: {
60
- givenName: user.firstName,
61
- familyName: user.lastName,
62
- },
63
- _json: {
64
- email: user.email,
65
- picture: "http://test.com",
66
- },
67
- provider: generator.string(),
68
- }
69
- }
70
-
71
- // OIDC
72
-
73
- export function oidcConfig(): OIDCInnerConfig {
74
- return {
75
- uuid: uuid(),
76
- activated: true,
77
- logo: "",
78
- name: generator.string(),
79
- configUrl: "http://someconfigurl",
80
- clientID: generator.string(),
81
- clientSecret: generator.string(),
82
- scopes: [],
83
- }
84
- }
85
-
86
- // response from .well-known/openid-configuration
87
- export function oidcWellKnownConfig(): OIDCWellKnownConfig {
88
- return {
89
- issuer: generator.string(),
90
- authorization_endpoint: generator.url(),
91
- token_endpoint: generator.url(),
92
- userinfo_endpoint: generator.url(),
93
- }
94
- }
95
-
96
- export function jwtClaims(): JwtClaims {
97
- return {
98
- email: email(),
99
- preferred_username: email(),
100
- }
101
- }
102
-
103
- // GOOGLE
104
-
105
- export function googleConfig(): GoogleInnerConfig {
106
- return {
107
- activated: true,
108
- clientID: generator.string(),
109
- clientSecret: generator.string(),
110
- }
111
- }
112
-
113
- export function googleConfigDoc(): GoogleConfig {
114
- return {
115
- _id: "config_google",
116
- type: ConfigType.GOOGLE,
117
- config: googleConfig(),
118
- }
119
- }
@@ -1,5 +0,0 @@
1
- import { newid } from "../../../../src/docIds/newid"
2
-
3
- export function id() {
4
- return `tenant-${newid()}`
5
- }