@budibase/types 2.0.39 → 2.0.40-alpha.0

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 (105) hide show
  1. package/dist/api/account/index.d.ts +1 -0
  2. package/dist/api/account/index.js +1 -0
  3. package/dist/api/account/index.js.map +1 -1
  4. package/dist/api/account/license.d.ts +9 -0
  5. package/dist/api/account/license.js +3 -0
  6. package/dist/api/account/license.js.map +1 -0
  7. package/dist/api/web/app/backup.d.ts +14 -0
  8. package/dist/api/web/app/backup.js +3 -0
  9. package/dist/api/web/app/backup.js.map +1 -0
  10. package/dist/api/web/app/index.d.ts +1 -0
  11. package/dist/api/web/app/index.js +18 -0
  12. package/dist/api/web/app/index.js.map +1 -0
  13. package/dist/api/web/index.d.ts +2 -0
  14. package/dist/api/web/index.js +2 -0
  15. package/dist/api/web/index.js.map +1 -1
  16. package/dist/api/web/schedule.d.ts +10 -0
  17. package/dist/api/web/schedule.js +3 -0
  18. package/dist/api/web/schedule.js.map +1 -0
  19. package/dist/api/web/user.d.ts +6 -0
  20. package/dist/documents/account/account.d.ts +2 -0
  21. package/dist/documents/account/account.js.map +1 -1
  22. package/dist/documents/app/automation.d.ts +32 -8
  23. package/dist/documents/app/automation.js +30 -1
  24. package/dist/documents/app/automation.js.map +1 -1
  25. package/dist/documents/app/backup.d.ts +62 -0
  26. package/dist/documents/app/backup.js +23 -0
  27. package/dist/documents/app/backup.js.map +1 -0
  28. package/dist/documents/app/index.d.ts +2 -0
  29. package/dist/documents/app/index.js +2 -0
  30. package/dist/documents/app/index.js.map +1 -1
  31. package/dist/documents/app/row.d.ts +7 -0
  32. package/dist/documents/app/table.d.ts +7 -0
  33. package/dist/documents/app/webhook.d.ts +13 -0
  34. package/dist/documents/app/webhook.js +8 -0
  35. package/dist/documents/app/webhook.js.map +1 -0
  36. package/dist/documents/global/index.d.ts +1 -0
  37. package/dist/documents/global/index.js +1 -0
  38. package/dist/documents/global/index.js.map +1 -1
  39. package/dist/documents/global/quotas.d.ts +56 -8
  40. package/dist/documents/global/quotas.js +17 -0
  41. package/dist/documents/global/quotas.js.map +1 -1
  42. package/dist/documents/global/schedule.d.ts +21 -0
  43. package/dist/documents/global/schedule.js +18 -0
  44. package/dist/documents/global/schedule.js.map +1 -0
  45. package/dist/sdk/datasources.d.ts +6 -0
  46. package/dist/sdk/datasources.js +1 -0
  47. package/dist/sdk/datasources.js.map +1 -1
  48. package/dist/sdk/db.d.ts +21 -0
  49. package/dist/sdk/db.js +9 -0
  50. package/dist/sdk/db.js.map +1 -0
  51. package/dist/sdk/events/backup.d.ts +6 -0
  52. package/dist/sdk/events/backup.js +3 -0
  53. package/dist/sdk/events/backup.js.map +1 -0
  54. package/dist/sdk/events/event.d.ts +2 -1
  55. package/dist/sdk/events/event.js +2 -0
  56. package/dist/sdk/events/event.js.map +1 -1
  57. package/dist/sdk/events/index.d.ts +1 -0
  58. package/dist/sdk/events/index.js +1 -0
  59. package/dist/sdk/events/index.js.map +1 -1
  60. package/dist/sdk/index.d.ts +2 -0
  61. package/dist/sdk/index.js +2 -0
  62. package/dist/sdk/index.js.map +1 -1
  63. package/dist/sdk/koa.d.ts +5 -2
  64. package/dist/sdk/licensing/feature.d.ts +2 -1
  65. package/dist/sdk/licensing/feature.js +1 -0
  66. package/dist/sdk/licensing/feature.js.map +1 -1
  67. package/dist/sdk/licensing/quota.d.ts +29 -15
  68. package/dist/sdk/licensing/quota.js +1 -0
  69. package/dist/sdk/licensing/quota.js.map +1 -1
  70. package/dist/sdk/locks.d.ts +33 -0
  71. package/dist/sdk/locks.js +17 -0
  72. package/dist/sdk/locks.js.map +1 -0
  73. package/dist/sdk/migrations.d.ts +1 -3
  74. package/dist/sdk/migrations.js +2 -3
  75. package/dist/sdk/migrations.js.map +1 -1
  76. package/dist/tsconfig.build.tsbuildinfo +1 -1
  77. package/package.json +3 -2
  78. package/src/api/account/index.ts +1 -0
  79. package/src/api/account/license.ts +11 -0
  80. package/src/api/web/app/backup.ts +17 -0
  81. package/src/api/web/app/index.ts +1 -0
  82. package/src/api/web/index.ts +2 -0
  83. package/src/api/web/schedule.ts +15 -0
  84. package/src/api/web/user.ts +7 -0
  85. package/src/documents/account/account.ts +10 -1
  86. package/src/documents/app/automation.ts +35 -8
  87. package/src/documents/app/backup.ts +70 -0
  88. package/src/documents/app/index.ts +2 -0
  89. package/src/documents/app/row.ts +8 -0
  90. package/src/documents/app/table.ts +3 -0
  91. package/src/documents/app/webhook.ts +15 -0
  92. package/src/documents/global/index.ts +1 -0
  93. package/src/documents/global/quotas.ts +73 -8
  94. package/src/documents/global/schedule.ts +32 -0
  95. package/src/sdk/datasources.ts +7 -0
  96. package/src/sdk/db.ts +24 -0
  97. package/src/sdk/events/backup.ts +7 -0
  98. package/src/sdk/events/event.ts +3 -0
  99. package/src/sdk/events/index.ts +1 -0
  100. package/src/sdk/index.ts +2 -0
  101. package/src/sdk/koa.ts +6 -2
  102. package/src/sdk/licensing/feature.ts +1 -0
  103. package/src/sdk/licensing/quota.ts +31 -14
  104. package/src/sdk/locks.ts +35 -0
  105. package/src/sdk/migrations.ts +2 -3
@@ -0,0 +1,17 @@
1
+ import { AppBackupTrigger, AppBackupType } from "../../../documents"
2
+
3
+ export interface SearchAppBackupsRequest {
4
+ trigger: AppBackupTrigger
5
+ type: AppBackupType
6
+ startDate: string
7
+ endDate: string
8
+ page?: string
9
+ }
10
+
11
+ export interface CreateAppBackupRequest {
12
+ name: string
13
+ }
14
+
15
+ export interface UpdateAppBackupRequest {
16
+ name: string
17
+ }
@@ -0,0 +1 @@
1
+ export * from "./backup"
@@ -1,3 +1,5 @@
1
1
  export * from "./analytics"
2
2
  export * from "./user"
3
3
  export * from "./errors"
4
+ export * from "./schedule"
5
+ export * from "./app"
@@ -0,0 +1,15 @@
1
+ import {
2
+ ScheduleMetadata,
3
+ ScheduleRepeatPeriod,
4
+ ScheduleType,
5
+ } from "../../documents"
6
+
7
+ export interface CreateScheduleRequest {
8
+ type: ScheduleType
9
+ name: string
10
+ startDate: string
11
+ repeat: ScheduleRepeatPeriod
12
+ metadata: ScheduleMetadata
13
+ }
14
+
15
+ export interface UpdateScheduleRequest extends CreateScheduleRequest {}
@@ -44,3 +44,10 @@ export interface InviteUsersResponse {
44
44
  successful: { email: string }[]
45
45
  unsuccessful: { email: string; reason: string }[]
46
46
  }
47
+
48
+ export interface SearchUsersRequest {
49
+ page?: string
50
+ email?: string
51
+ appId?: string
52
+ userIds?: string[]
53
+ }
@@ -1,4 +1,12 @@
1
- import { Feature, Hosting, PlanType, Quotas } from "../../sdk"
1
+ import {
2
+ Feature,
3
+ Hosting,
4
+ MonthlyQuotaName,
5
+ PlanType,
6
+ Quotas,
7
+ StaticQuotaName,
8
+ } from "../../sdk"
9
+ import { MonthlyUsage, QuotaUsage, StaticUsage } from "../global"
2
10
 
3
11
  export interface CreateAccount {
4
12
  email: string
@@ -42,6 +50,7 @@ export interface Account extends CreateAccount {
42
50
  licenseKey?: string
43
51
  licenseKeyActivatedAt?: number
44
52
  licenseOverrides?: LicenseOverrides
53
+ quotaUsage?: QuotaUsage
45
54
  }
46
55
 
47
56
  export interface PasswordAccount extends Account {
@@ -1,5 +1,34 @@
1
1
  import { Document } from "../document"
2
2
 
3
+ export enum AutomationTriggerStepId {
4
+ ROW_SAVED = "ROW_SAVED",
5
+ ROW_UPDATED = "ROW_UPDATED",
6
+ ROW_DELETED = "ROW_DELETED",
7
+ WEBHOOK = "WEBHOOK",
8
+ APP = "APP",
9
+ CRON = "CRON",
10
+ }
11
+
12
+ export enum AutomationActionStepId {
13
+ SEND_EMAIL_SMTP = "SEND_EMAIL_SMTP",
14
+ CREATE_ROW = "CREATE_ROW",
15
+ UPDATE_ROW = "UPDATE_ROW",
16
+ DELETE_ROW = "DELETE_ROW",
17
+ OUTGOING_WEBHOOK = "OUTGOING_WEBHOOK",
18
+ EXECUTE_SCRIPT = "EXECUTE_SCRIPT",
19
+ EXECUTE_QUERY = "EXECUTE_QUERY",
20
+ SERVER_LOG = "SERVER_LOG",
21
+ DELAY = "DELAY",
22
+ FILTER = "FILTER",
23
+ QUERY_ROWS = "QUERY_ROWS",
24
+ LOOP = "LOOP",
25
+ // these used to be lowercase step IDs, maintain for backwards compat
26
+ discord = "discord",
27
+ slack = "slack",
28
+ zapier = "zapier",
29
+ integromat = "integromat",
30
+ }
31
+
3
32
  export interface Automation extends Document {
4
33
  definition: {
5
34
  steps: AutomationStep[]
@@ -11,7 +40,7 @@ export interface Automation extends Document {
11
40
 
12
41
  export interface AutomationStep {
13
42
  id: string
14
- stepId: string
43
+ stepId: AutomationTriggerStepId | AutomationActionStepId
15
44
  inputs: {
16
45
  [key: string]: any
17
46
  }
@@ -19,15 +48,13 @@ export interface AutomationStep {
19
48
  inputs: {
20
49
  [key: string]: any
21
50
  }
51
+ outputs: {
52
+ [key: string]: any
53
+ }
22
54
  }
23
55
  }
24
56
 
25
- export interface AutomationTrigger {
26
- id: string
27
- stepId: string
28
- inputs: {
29
- [key: string]: any
30
- }
57
+ export interface AutomationTrigger extends AutomationStep {
31
58
  cronJobId?: string
32
59
  }
33
60
 
@@ -43,7 +70,7 @@ export interface AutomationResults {
43
70
  status?: AutomationStatus
44
71
  trigger?: any
45
72
  steps: {
46
- stepId: string
73
+ stepId: AutomationTriggerStepId | AutomationActionStepId
47
74
  inputs: {
48
75
  [key: string]: any
49
76
  }
@@ -0,0 +1,70 @@
1
+ import { Document } from "../document"
2
+ import { User } from "../../"
3
+
4
+ export enum AppBackupType {
5
+ BACKUP = "backup",
6
+ RESTORE = "restore",
7
+ }
8
+
9
+ export enum AppBackupStatus {
10
+ STARTED = "started",
11
+ PENDING = "pending",
12
+ COMPLETE = "complete",
13
+ FAILED = "failed",
14
+ }
15
+
16
+ export enum AppBackupTrigger {
17
+ PUBLISH = "publish",
18
+ MANUAL = "manual",
19
+ SCHEDULED = "scheduled",
20
+ RESTORING = "restoring",
21
+ }
22
+
23
+ export interface AppBackupContents {
24
+ datasources: string[]
25
+ screens: string[]
26
+ automations: string[]
27
+ }
28
+
29
+ export interface AppBackupMetadata {
30
+ appId: string
31
+ trigger?: AppBackupTrigger
32
+ type: AppBackupType
33
+ status: AppBackupStatus
34
+ name?: string
35
+ createdBy?: string | User
36
+ timestamp: string
37
+ finishedAt?: string
38
+ startedAt?: string
39
+ contents?: AppBackupContents
40
+ }
41
+
42
+ export interface AppBackup extends Document, AppBackupMetadata {
43
+ filename?: string
44
+ }
45
+
46
+ export type AppBackupFetchOpts = {
47
+ trigger?: AppBackupTrigger
48
+ type?: AppBackupType
49
+ limit?: number
50
+ page?: string
51
+ paginate?: boolean
52
+ startDate?: string
53
+ endDate?: string
54
+ }
55
+
56
+ export interface AppBackupQueueData {
57
+ appId: string
58
+ docId: string
59
+ docRev: string
60
+ export?: {
61
+ trigger: AppBackupTrigger
62
+ name?: string
63
+ createdBy?: string
64
+ }
65
+ import?: {
66
+ backupId: string
67
+ nameForBackup: string
68
+ createdBy?: string
69
+ }
70
+ }
@@ -10,3 +10,5 @@ export * from "./view"
10
10
  export * from "../document"
11
11
  export * from "./row"
12
12
  export * from "./user"
13
+ export * from "./backup"
14
+ export * from "./webhook"
@@ -16,6 +16,14 @@ export enum FieldType {
16
16
  INTERNAL = "internal",
17
17
  }
18
18
 
19
+ export interface RowAttachment {
20
+ size: number
21
+ name: string
22
+ url: string
23
+ extension: string
24
+ key: string
25
+ }
26
+
19
27
  export interface Row extends Document {
20
28
  type?: string
21
29
  tableId?: string
@@ -49,4 +49,7 @@ export interface Table extends Document {
49
49
  sourceId?: string
50
50
  relatedFormula?: string[]
51
51
  constrained?: string[]
52
+ sql?: boolean
53
+ indexes?: { [key: string]: any }
54
+ dataImport?: { [key: string]: any }
52
55
  }
@@ -0,0 +1,15 @@
1
+ import { Document } from "../document"
2
+
3
+ export enum WebhookActionType {
4
+ AUTOMATION = "automation",
5
+ }
6
+
7
+ export interface Webhook extends Document {
8
+ live: boolean
9
+ name: string
10
+ action: {
11
+ type: WebhookActionType
12
+ target: string
13
+ }
14
+ bodySchema?: any
15
+ }
@@ -3,3 +3,4 @@ export * from "./user"
3
3
  export * from "./userGroup"
4
4
  export * from "./plugin"
5
5
  export * from "./quotas"
6
+ export * from "./schedule"
@@ -1,15 +1,80 @@
1
1
  import { MonthlyQuotaName, StaticQuotaName } from "../../sdk"
2
2
 
3
- export interface QuotaUsage {
3
+ export enum BreakdownQuotaName {
4
+ ROW_QUERIES = "rowQueries",
5
+ DATASOURCE_QUERIES = "datasourceQueries",
6
+ AUTOMATIONS = "automations",
7
+ }
8
+
9
+ export const APP_QUOTA_NAMES = [
10
+ StaticQuotaName.ROWS,
11
+ MonthlyQuotaName.QUERIES,
12
+ MonthlyQuotaName.AUTOMATIONS,
13
+ ]
14
+
15
+ export const BREAKDOWN_QUOTA_NAMES = [
16
+ MonthlyQuotaName.QUERIES,
17
+ MonthlyQuotaName.AUTOMATIONS,
18
+ ]
19
+
20
+ export interface UsageBreakdown {
21
+ parent: MonthlyQuotaName
22
+ values: {
23
+ [key: string]: number
24
+ }
25
+ }
26
+
27
+ export type QuotaTriggers = {
28
+ [key: string]: string | undefined
29
+ }
30
+
31
+ export interface StaticUsage {
32
+ [StaticQuotaName.APPS]: number
33
+ [StaticQuotaName.PLUGINS]: number
34
+ [StaticQuotaName.USER_GROUPS]: number
35
+ [StaticQuotaName.ROWS]: number
36
+ triggers: {
37
+ [key in StaticQuotaName]?: QuotaTriggers
38
+ }
39
+ }
40
+
41
+ export interface MonthlyUsage {
42
+ [MonthlyQuotaName.QUERIES]: number
43
+ [MonthlyQuotaName.AUTOMATIONS]: number
44
+ [MonthlyQuotaName.DAY_PASSES]: number
45
+ triggers: {
46
+ [key in MonthlyQuotaName]?: QuotaTriggers
47
+ }
48
+ breakdown?: {
49
+ [key in BreakdownQuotaName]?: UsageBreakdown
50
+ }
51
+ }
52
+
53
+ export interface BaseQuotaUsage {
54
+ usageQuota: StaticUsage
55
+ monthly: {
56
+ [key: string]: MonthlyUsage
57
+ }
58
+ }
59
+
60
+ export interface QuotaUsage extends BaseQuotaUsage {
4
61
  _id: string
5
62
  _rev?: string
6
63
  quotaReset: string
7
- usageQuota: {
8
- [key in StaticQuotaName]: number
9
- }
10
- monthly: {
11
- [key: string]: {
12
- [key in MonthlyQuotaName]: number
13
- }
64
+ apps?: {
65
+ [key: string]: BaseQuotaUsage
14
66
  }
15
67
  }
68
+
69
+ export type SetUsageValues = {
70
+ total: number
71
+ app?: number
72
+ breakdown?: number
73
+ triggers?: QuotaTriggers
74
+ }
75
+
76
+ export type UsageValues = {
77
+ total: number
78
+ app?: number
79
+ breakdown?: number
80
+ }
@@ -0,0 +1,32 @@
1
+ import { Document } from "../document"
2
+
3
+ export enum ScheduleType {
4
+ APP_BACKUP = "app_backup",
5
+ }
6
+
7
+ export enum ScheduleRepeatPeriod {
8
+ DAILY = "daily",
9
+ WEEKLY = "weekly",
10
+ MONTHLY = "monthly",
11
+ }
12
+
13
+ export interface Schedule extends Document {
14
+ type: ScheduleType
15
+ name: string
16
+ startDate: string
17
+ repeat: ScheduleRepeatPeriod
18
+ metadata: ScheduleMetadata
19
+ }
20
+
21
+ export type ScheduleMetadata = AppBackupScheduleMetadata
22
+
23
+ export const isAppBackupMetadata = (
24
+ type: ScheduleType,
25
+ metadata: ScheduleMetadata
26
+ ): metadata is AppBackupScheduleMetadata => {
27
+ return type === ScheduleType.APP_BACKUP
28
+ }
29
+
30
+ export interface AppBackupScheduleMetadata {
31
+ apps: string[]
32
+ }
@@ -24,6 +24,7 @@ export enum QueryType {
24
24
 
25
25
  export enum DatasourceFieldType {
26
26
  STRING = "string",
27
+ CODE = "code",
27
28
  LONGFORM = "longForm",
28
29
  BOOLEAN = "boolean",
29
30
  NUMBER = "number",
@@ -70,6 +71,11 @@ export enum FilterType {
70
71
  ONE_OF = "oneOf",
71
72
  }
72
73
 
74
+ export interface StepDefinition {
75
+ key: string
76
+ template: string
77
+ }
78
+
73
79
  export interface QueryDefinition {
74
80
  type: QueryType
75
81
  displayName?: string
@@ -77,6 +83,7 @@ export interface QueryDefinition {
77
83
  customisable?: boolean
78
84
  fields?: object
79
85
  urlDisplay?: boolean
86
+ steps?: Array<StepDefinition>
80
87
  }
81
88
 
82
89
  export interface ExtraQueryConfig {
package/src/sdk/db.ts ADDED
@@ -0,0 +1,24 @@
1
+ import PouchDB from "pouchdb"
2
+
3
+ export type PouchOptions = {
4
+ inMemory: boolean
5
+ replication: boolean
6
+ onDisk: boolean
7
+ find: boolean
8
+ }
9
+
10
+ export enum SortOption {
11
+ ASCENDING = "asc",
12
+ DESCENDING = "desc",
13
+ }
14
+
15
+ export type CouchFindOptions = {
16
+ selector: PouchDB.Find.Selector
17
+ fields?: string[]
18
+ sort?: {
19
+ [key: string]: SortOption
20
+ }[]
21
+ limit?: number
22
+ skip?: number
23
+ bookmark?: string
24
+ }
@@ -0,0 +1,7 @@
1
+ import { BaseEvent } from "./event"
2
+
3
+ export interface AppBackupRestoreEvent extends BaseEvent {
4
+ appId: string
5
+ backupName: string
6
+ backupCreatedAt: string
7
+ }
@@ -168,6 +168,9 @@ export enum Event {
168
168
  PLUGIN_INIT = "plugin:init",
169
169
  PLUGIN_IMPORTED = "plugin:imported",
170
170
  PLUGIN_DELETED = "plugin:deleted",
171
+
172
+ // BACKUP
173
+ APP_BACKUP_RESTORED = "app:backup:restored",
171
174
  }
172
175
 
173
176
  // properties added at the final stage of the event pipeline
@@ -20,3 +20,4 @@ export * from "./backfill"
20
20
  export * from "./identification"
21
21
  export * from "./userGroup"
22
22
  export * from "./plugin"
23
+ export * from "./backup"
package/src/sdk/index.ts CHANGED
@@ -7,3 +7,5 @@ export * from "./datasources"
7
7
  export * from "./search"
8
8
  export * from "./koa"
9
9
  export * from "./auth"
10
+ export * from "./locks"
11
+ export * from "./db"
package/src/sdk/koa.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Context } from "koa"
1
+ import { Context, Request } from "koa"
2
2
  import { User } from "../documents"
3
3
  import { License } from "../sdk"
4
4
 
@@ -7,7 +7,11 @@ export interface ContextUser extends User {
7
7
  license: License
8
8
  }
9
9
 
10
+ export interface BBRequest extends Request {
11
+ body: any
12
+ }
13
+
10
14
  export interface BBContext extends Context {
15
+ request: BBRequest
11
16
  user?: ContextUser
12
- body: any
13
17
  }
@@ -1,3 +1,4 @@
1
1
  export enum Feature {
2
2
  USER_GROUPS = "userGroups",
3
+ APP_BACKUPS = "appBackups",
3
4
  }
@@ -25,8 +25,10 @@ export enum MonthlyQuotaName {
25
25
 
26
26
  export enum ConstantQuotaName {
27
27
  AUTOMATION_LOG_RETENTION_DAYS = "automationLogRetentionDays",
28
+ APP_BACKUPS_RETENTION_DAYS = "appBackupRetentionDays",
28
29
  }
29
30
 
31
+ export type MeteredQuotaName = StaticQuotaName | MonthlyQuotaName
30
32
  export type QuotaName = StaticQuotaName | MonthlyQuotaName | ConstantQuotaName
31
33
 
32
34
  export const isStaticQuota = (
@@ -60,26 +62,41 @@ export type PlanQuotas = {
60
62
  [PlanType.ENTERPRISE]: Quotas
61
63
  }
62
64
 
65
+ export type MonthlyQuotas = {
66
+ [MonthlyQuotaName.QUERIES]: Quota
67
+ [MonthlyQuotaName.AUTOMATIONS]: Quota
68
+ [MonthlyQuotaName.DAY_PASSES]: Quota
69
+ }
70
+
71
+ export type StaticQuotas = {
72
+ [StaticQuotaName.ROWS]: Quota
73
+ [StaticQuotaName.APPS]: Quota
74
+ [StaticQuotaName.USER_GROUPS]: Quota
75
+ [StaticQuotaName.PLUGINS]: Quota
76
+ }
77
+
78
+ export type ConstantQuotas = {
79
+ [ConstantQuotaName.AUTOMATION_LOG_RETENTION_DAYS]: Quota
80
+ [ConstantQuotaName.APP_BACKUPS_RETENTION_DAYS]: Quota
81
+ }
82
+
63
83
  export type Quotas = {
64
84
  [QuotaType.USAGE]: {
65
- [QuotaUsageType.MONTHLY]: {
66
- [MonthlyQuotaName.QUERIES]: Quota
67
- [MonthlyQuotaName.AUTOMATIONS]: Quota
68
- [MonthlyQuotaName.DAY_PASSES]: Quota
69
- }
70
- [QuotaUsageType.STATIC]: {
71
- [StaticQuotaName.ROWS]: Quota
72
- [StaticQuotaName.APPS]: Quota
73
- [StaticQuotaName.USER_GROUPS]: Quota
74
- [StaticQuotaName.PLUGINS]: Quota
75
- }
76
- }
77
- [QuotaType.CONSTANT]: {
78
- [ConstantQuotaName.AUTOMATION_LOG_RETENTION_DAYS]: Quota
85
+ [QuotaUsageType.MONTHLY]: MonthlyQuotas
86
+ [QuotaUsageType.STATIC]: StaticQuotas
79
87
  }
88
+ [QuotaType.CONSTANT]: ConstantQuotas
80
89
  }
81
90
 
82
91
  export interface Quota {
83
92
  name: string
84
93
  value: number
94
+ /**
95
+ * Array of whole numbers (1-100) that dictate the percentage that this quota should trigger
96
+ * at in relation to the corresponding usage inside budibase.
97
+ *
98
+ * Triggering results in a budibase installation sending a request to account-portal,
99
+ * which can have subsequent effects such as sending emails to users.
100
+ */
101
+ triggers: number[]
85
102
  }
@@ -0,0 +1,35 @@
1
+ export enum LockType {
2
+ /**
3
+ * If this lock is already held the attempted operation will not be performed.
4
+ * No retries will take place and no error will be thrown.
5
+ */
6
+ TRY_ONCE = "try_once",
7
+ }
8
+
9
+ export enum LockName {
10
+ MIGRATIONS = "migrations",
11
+ TRIGGER_QUOTA = "trigger_quota",
12
+ }
13
+
14
+ export interface LockOptions {
15
+ /**
16
+ * The lock type determines which client to use
17
+ */
18
+ type: LockType
19
+ /**
20
+ * The name for the lock
21
+ */
22
+ name: LockName
23
+ /**
24
+ * The ttl to auto-expire the lock if not unlocked manually
25
+ */
26
+ ttl: number
27
+ /**
28
+ * The suffix to add to the lock name for additional uniqueness
29
+ */
30
+ nameSuffix?: string
31
+ /**
32
+ * This is a system-wide lock - don't use tenancy in lock key
33
+ */
34
+ systemLock?: boolean
35
+ }
@@ -39,14 +39,13 @@ export interface MigrationOptions {
39
39
 
40
40
  export enum MigrationName {
41
41
  USER_EMAIL_VIEW_CASING = "user_email_view_casing",
42
- QUOTAS_1 = "quotas_1",
43
42
  APP_URLS = "app_urls",
44
43
  EVENT_APP_BACKFILL = "event_app_backfill",
45
44
  EVENT_GLOBAL_BACKFILL = "event_global_backfill",
46
45
  EVENT_INSTALLATION_BACKFILL = "event_installation_backfill",
47
46
  GLOBAL_INFO_SYNC_USERS = "global_info_sync_users",
48
- PLATFORM_USERS_EMAIL_CASING = "platform_users_email_casing",
49
- PLUGIN_COUNT = "plugin_count",
47
+ // increment this number to re-activate this migration
48
+ SYNC_QUOTAS = "sync_quotas_1",
50
49
  }
51
50
 
52
51
  export interface MigrationDefinition {