@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,168 +0,0 @@
1
- import { publishEvent } from "../events"
2
- import {
3
- Event,
4
- App,
5
- AppCreatedEvent,
6
- AppUpdatedEvent,
7
- AppDeletedEvent,
8
- AppPublishedEvent,
9
- AppUnpublishedEvent,
10
- AppFileImportedEvent,
11
- AppTemplateImportedEvent,
12
- AppVersionUpdatedEvent,
13
- AppVersionRevertedEvent,
14
- AppRevertedEvent,
15
- AppExportedEvent,
16
- AppDuplicatedEvent,
17
- } from "@budibase/types"
18
-
19
- const created = async (app: App, timestamp?: string | number) => {
20
- const properties: AppCreatedEvent = {
21
- appId: app.appId,
22
- version: app.version,
23
- audited: {
24
- name: app.name,
25
- },
26
- }
27
- await publishEvent(Event.APP_CREATED, properties, timestamp)
28
- }
29
-
30
- async function updated(app: App) {
31
- const properties: AppUpdatedEvent = {
32
- appId: app.appId,
33
- version: app.version,
34
- audited: {
35
- name: app.name,
36
- },
37
- }
38
- await publishEvent(Event.APP_UPDATED, properties)
39
- }
40
-
41
- async function deleted(app: App) {
42
- const properties: AppDeletedEvent = {
43
- appId: app.appId,
44
- audited: {
45
- name: app.name,
46
- },
47
- }
48
- await publishEvent(Event.APP_DELETED, properties)
49
- }
50
-
51
- async function published(app: App, timestamp?: string | number) {
52
- const properties: AppPublishedEvent = {
53
- appId: app.appId,
54
- audited: {
55
- name: app.name,
56
- },
57
- }
58
- await publishEvent(Event.APP_PUBLISHED, properties, timestamp)
59
- }
60
-
61
- async function unpublished(app: App) {
62
- const properties: AppUnpublishedEvent = {
63
- appId: app.appId,
64
- audited: {
65
- name: app.name,
66
- },
67
- }
68
- await publishEvent(Event.APP_UNPUBLISHED, properties)
69
- }
70
-
71
- async function fileImported(app: App) {
72
- const properties: AppFileImportedEvent = {
73
- appId: app.appId,
74
- audited: {
75
- name: app.name,
76
- },
77
- }
78
- await publishEvent(Event.APP_FILE_IMPORTED, properties)
79
- }
80
-
81
- async function duplicated(app: App, duplicateAppId: string) {
82
- const properties: AppDuplicatedEvent = {
83
- duplicateAppId,
84
- appId: app.appId,
85
- audited: {
86
- name: app.name,
87
- },
88
- }
89
- await publishEvent(Event.APP_DUPLICATED, properties)
90
- }
91
-
92
- async function templateImported(app: App, templateKey: string) {
93
- const properties: AppTemplateImportedEvent = {
94
- appId: app.appId,
95
- templateKey,
96
- audited: {
97
- name: app.name,
98
- },
99
- }
100
- await publishEvent(Event.APP_TEMPLATE_IMPORTED, properties)
101
- }
102
-
103
- async function versionUpdated(
104
- app: App,
105
- currentVersion: string,
106
- updatedToVersion: string
107
- ) {
108
- const properties: AppVersionUpdatedEvent = {
109
- appId: app.appId,
110
- currentVersion,
111
- updatedToVersion,
112
- audited: {
113
- name: app.name,
114
- },
115
- }
116
- await publishEvent(Event.APP_VERSION_UPDATED, properties)
117
- }
118
-
119
- async function versionReverted(
120
- app: App,
121
- currentVersion: string,
122
- revertedToVersion: string
123
- ) {
124
- const properties: AppVersionRevertedEvent = {
125
- appId: app.appId,
126
- currentVersion,
127
- revertedToVersion,
128
- audited: {
129
- name: app.name,
130
- },
131
- }
132
- await publishEvent(Event.APP_VERSION_REVERTED, properties)
133
- }
134
-
135
- async function reverted(app: App) {
136
- const properties: AppRevertedEvent = {
137
- appId: app.appId,
138
- audited: {
139
- name: app.name,
140
- },
141
- }
142
- await publishEvent(Event.APP_REVERTED, properties)
143
- }
144
-
145
- async function exported(app: App) {
146
- const properties: AppExportedEvent = {
147
- appId: app.appId,
148
- audited: {
149
- name: app.name,
150
- },
151
- }
152
- await publishEvent(Event.APP_EXPORTED, properties)
153
- }
154
-
155
- export default {
156
- created,
157
- updated,
158
- deleted,
159
- published,
160
- unpublished,
161
- fileImported,
162
- duplicated,
163
- templateImported,
164
- versionUpdated,
165
- versionReverted,
166
- reverted,
167
- exported,
168
- }
@@ -1,26 +0,0 @@
1
- import {
2
- Event,
3
- AuditLogSearchParams,
4
- AuditLogFilteredEvent,
5
- AuditLogDownloadedEvent,
6
- } from "@budibase/types"
7
- import { publishEvent } from "../events"
8
-
9
- async function filtered(search: AuditLogSearchParams) {
10
- const properties: AuditLogFilteredEvent = {
11
- filters: search,
12
- }
13
- await publishEvent(Event.AUDIT_LOGS_FILTERED, properties)
14
- }
15
-
16
- async function downloaded(search: AuditLogSearchParams) {
17
- const properties: AuditLogDownloadedEvent = {
18
- filters: search,
19
- }
20
- await publishEvent(Event.AUDIT_LOGS_DOWNLOADED, properties)
21
- }
22
-
23
- export default {
24
- filtered,
25
- downloaded,
26
- }
@@ -1,73 +0,0 @@
1
- import { publishEvent } from "../events"
2
- import {
3
- Event,
4
- LoginEvent,
5
- LoginSource,
6
- LogoutEvent,
7
- SSOActivatedEvent,
8
- SSOCreatedEvent,
9
- SSODeactivatedEvent,
10
- SSOType,
11
- SSOUpdatedEvent,
12
- } from "@budibase/types"
13
- import { identification } from ".."
14
-
15
- async function login(source: LoginSource, email: string) {
16
- const identity = await identification.getCurrentIdentity()
17
- const properties: LoginEvent = {
18
- userId: identity.id,
19
- source,
20
- audited: {
21
- email,
22
- },
23
- }
24
- await publishEvent(Event.AUTH_LOGIN, properties)
25
- }
26
-
27
- async function logout(email?: string) {
28
- const identity = await identification.getCurrentIdentity()
29
- const properties: LogoutEvent = {
30
- userId: identity.id,
31
- audited: {
32
- email,
33
- },
34
- }
35
- await publishEvent(Event.AUTH_LOGOUT, properties)
36
- }
37
-
38
- async function SSOCreated(type: SSOType, timestamp?: string | number) {
39
- const properties: SSOCreatedEvent = {
40
- type,
41
- }
42
- await publishEvent(Event.AUTH_SSO_CREATED, properties, timestamp)
43
- }
44
-
45
- async function SSOUpdated(type: SSOType) {
46
- const properties: SSOUpdatedEvent = {
47
- type,
48
- }
49
- await publishEvent(Event.AUTH_SSO_UPDATED, properties)
50
- }
51
-
52
- async function SSOActivated(type: SSOType, timestamp?: string | number) {
53
- const properties: SSOActivatedEvent = {
54
- type,
55
- }
56
- await publishEvent(Event.AUTH_SSO_ACTIVATED, properties, timestamp)
57
- }
58
-
59
- async function SSODeactivated(type: SSOType) {
60
- const properties: SSODeactivatedEvent = {
61
- type,
62
- }
63
- await publishEvent(Event.AUTH_SSO_DEACTIVATED, properties)
64
- }
65
-
66
- export default {
67
- login,
68
- logout,
69
- SSOCreated,
70
- SSOUpdated,
71
- SSOActivated,
72
- SSODeactivated,
73
- }
@@ -1,110 +0,0 @@
1
- import { publishEvent } from "../events"
2
- import {
3
- Automation,
4
- Event,
5
- AutomationStep,
6
- AutomationCreatedEvent,
7
- AutomationDeletedEvent,
8
- AutomationTestedEvent,
9
- AutomationStepCreatedEvent,
10
- AutomationStepDeletedEvent,
11
- AutomationTriggerUpdatedEvent,
12
- AutomationsRunEvent,
13
- } from "@budibase/types"
14
-
15
- async function created(automation: Automation, timestamp?: string | number) {
16
- const properties: AutomationCreatedEvent = {
17
- appId: automation.appId,
18
- automationId: automation._id as string,
19
- triggerId: automation.definition?.trigger?.id,
20
- triggerType: automation.definition?.trigger?.stepId,
21
- audited: {
22
- name: automation.name,
23
- },
24
- }
25
- await publishEvent(Event.AUTOMATION_CREATED, properties, timestamp)
26
- }
27
-
28
- async function triggerUpdated(automation: Automation) {
29
- const properties: AutomationTriggerUpdatedEvent = {
30
- appId: automation.appId,
31
- automationId: automation._id as string,
32
- triggerId: automation.definition?.trigger?.id,
33
- triggerType: automation.definition?.trigger?.stepId,
34
- }
35
- await publishEvent(Event.AUTOMATION_TRIGGER_UPDATED, properties)
36
- }
37
-
38
- async function deleted(automation: Automation) {
39
- const properties: AutomationDeletedEvent = {
40
- appId: automation.appId,
41
- automationId: automation._id as string,
42
- triggerId: automation.definition?.trigger?.id,
43
- triggerType: automation.definition?.trigger?.stepId,
44
- audited: {
45
- name: automation.name,
46
- },
47
- }
48
- await publishEvent(Event.AUTOMATION_DELETED, properties)
49
- }
50
-
51
- async function tested(automation: Automation) {
52
- const properties: AutomationTestedEvent = {
53
- appId: automation.appId,
54
- automationId: automation._id as string,
55
- triggerId: automation.definition?.trigger?.id,
56
- triggerType: automation.definition?.trigger?.stepId,
57
- }
58
- await publishEvent(Event.AUTOMATION_TESTED, properties)
59
- }
60
-
61
- const run = async (count: number, timestamp?: string | number) => {
62
- const properties: AutomationsRunEvent = {
63
- count,
64
- }
65
- await publishEvent(Event.AUTOMATIONS_RUN, properties, timestamp)
66
- }
67
-
68
- async function stepCreated(
69
- automation: Automation,
70
- step: AutomationStep,
71
- timestamp?: string | number
72
- ) {
73
- const properties: AutomationStepCreatedEvent = {
74
- appId: automation.appId,
75
- automationId: automation._id as string,
76
- triggerId: automation.definition?.trigger?.id,
77
- triggerType: automation.definition?.trigger?.stepId,
78
- stepId: step.id!,
79
- stepType: step.stepId,
80
- audited: {
81
- name: automation.name,
82
- },
83
- }
84
- await publishEvent(Event.AUTOMATION_STEP_CREATED, properties, timestamp)
85
- }
86
-
87
- async function stepDeleted(automation: Automation, step: AutomationStep) {
88
- const properties: AutomationStepDeletedEvent = {
89
- appId: automation.appId,
90
- automationId: automation._id as string,
91
- triggerId: automation.definition?.trigger?.id,
92
- triggerType: automation.definition?.trigger?.stepId,
93
- stepId: step.id!,
94
- stepType: step.stepId,
95
- audited: {
96
- name: automation.name,
97
- },
98
- }
99
- await publishEvent(Event.AUTOMATION_STEP_DELETED, properties)
100
- }
101
-
102
- export default {
103
- created,
104
- triggerUpdated,
105
- deleted,
106
- tested,
107
- run,
108
- stepCreated,
109
- stepDeleted,
110
- }
@@ -1,74 +0,0 @@
1
- import { publishEvent } from "../events"
2
- import {
3
- Event,
4
- AppBackfillSucceededEvent,
5
- AppBackfillFailedEvent,
6
- TenantBackfillSucceededEvent,
7
- TenantBackfillFailedEvent,
8
- InstallationBackfillSucceededEvent,
9
- InstallationBackfillFailedEvent,
10
- } from "@budibase/types"
11
- import env from "../../environment"
12
-
13
- const shouldSkip = !env.SELF_HOSTED && !env.isDev()
14
-
15
- async function appSucceeded(properties: AppBackfillSucceededEvent) {
16
- if (shouldSkip) {
17
- return
18
- }
19
- await publishEvent(Event.APP_BACKFILL_SUCCEEDED, properties)
20
- }
21
-
22
- async function appFailed(error: any) {
23
- if (shouldSkip) {
24
- return
25
- }
26
- const properties: AppBackfillFailedEvent = {
27
- error: JSON.stringify(error, Object.getOwnPropertyNames(error)),
28
- }
29
- await publishEvent(Event.APP_BACKFILL_FAILED, properties)
30
- }
31
-
32
- async function tenantSucceeded(properties: TenantBackfillSucceededEvent) {
33
- if (shouldSkip) {
34
- return
35
- }
36
- await publishEvent(Event.TENANT_BACKFILL_SUCCEEDED, properties)
37
- }
38
-
39
- async function tenantFailed(error: any) {
40
- if (shouldSkip) {
41
- return
42
- }
43
- const properties: TenantBackfillFailedEvent = {
44
- error: JSON.stringify(error, Object.getOwnPropertyNames(error)),
45
- }
46
- await publishEvent(Event.TENANT_BACKFILL_FAILED, properties)
47
- }
48
-
49
- async function installationSucceeded() {
50
- if (shouldSkip) {
51
- return
52
- }
53
- const properties: InstallationBackfillSucceededEvent = {}
54
- await publishEvent(Event.INSTALLATION_BACKFILL_SUCCEEDED, properties)
55
- }
56
-
57
- async function installationFailed(error: any) {
58
- if (shouldSkip) {
59
- return
60
- }
61
- const properties: InstallationBackfillFailedEvent = {
62
- error: JSON.stringify(error, Object.getOwnPropertyNames(error)),
63
- }
64
- await publishEvent(Event.INSTALLATION_BACKFILL_FAILED, properties)
65
- }
66
-
67
- export default {
68
- appSucceeded,
69
- appFailed,
70
- tenantSucceeded,
71
- tenantFailed,
72
- installationSucceeded,
73
- installationFailed,
74
- }
@@ -1,42 +0,0 @@
1
- import {
2
- AppBackup,
3
- AppBackupRestoreEvent,
4
- AppBackupTriggeredEvent,
5
- AppBackupTrigger,
6
- AppBackupType,
7
- Event,
8
- } from "@budibase/types"
9
- import { publishEvent } from "../events"
10
-
11
- async function appBackupRestored(backup: AppBackup) {
12
- const properties: AppBackupRestoreEvent = {
13
- appId: backup.appId,
14
- restoreId: backup._id!,
15
- backupCreatedAt: backup.timestamp,
16
- name: backup.name as string,
17
- }
18
-
19
- await publishEvent(Event.APP_BACKUP_RESTORED, properties)
20
- }
21
-
22
- async function appBackupTriggered(
23
- appId: string,
24
- backupId: string,
25
- type: AppBackupType,
26
- trigger: AppBackupTrigger,
27
- name: string
28
- ) {
29
- const properties: AppBackupTriggeredEvent = {
30
- appId: appId,
31
- backupId,
32
- type,
33
- trigger,
34
- name,
35
- }
36
- await publishEvent(Event.APP_BACKUP_TRIGGERED, properties)
37
- }
38
-
39
- export default {
40
- appBackupRestored,
41
- appBackupTriggered,
42
- }
@@ -1,48 +0,0 @@
1
- import { publishEvent } from "../events"
2
- import {
3
- Event,
4
- Datasource,
5
- DatasourceCreatedEvent,
6
- DatasourceUpdatedEvent,
7
- DatasourceDeletedEvent,
8
- SourceName,
9
- } from "@budibase/types"
10
-
11
- function isCustom(datasource: Datasource) {
12
- const sources = Object.values(SourceName)
13
- // if not in the base source list, then it must be custom
14
- return !sources.includes(datasource.source)
15
- }
16
-
17
- async function created(datasource: Datasource, timestamp?: string | number) {
18
- const properties: DatasourceCreatedEvent = {
19
- datasourceId: datasource._id as string,
20
- source: datasource.source,
21
- custom: isCustom(datasource),
22
- }
23
- await publishEvent(Event.DATASOURCE_CREATED, properties, timestamp)
24
- }
25
-
26
- async function updated(datasource: Datasource) {
27
- const properties: DatasourceUpdatedEvent = {
28
- datasourceId: datasource._id as string,
29
- source: datasource.source,
30
- custom: isCustom(datasource),
31
- }
32
- await publishEvent(Event.DATASOURCE_UPDATED, properties)
33
- }
34
-
35
- async function deleted(datasource: Datasource) {
36
- const properties: DatasourceDeletedEvent = {
37
- datasourceId: datasource._id as string,
38
- source: datasource.source,
39
- custom: isCustom(datasource),
40
- }
41
- await publishEvent(Event.DATASOURCE_DELETED, properties)
42
- }
43
-
44
- export default {
45
- created,
46
- updated,
47
- deleted,
48
- }
@@ -1,17 +0,0 @@
1
- import { publishEvent } from "../events"
2
- import { Event, SMTPCreatedEvent, SMTPUpdatedEvent } from "@budibase/types"
3
-
4
- async function SMTPCreated(timestamp?: string | number) {
5
- const properties: SMTPCreatedEvent = {}
6
- await publishEvent(Event.EMAIL_SMTP_CREATED, properties, timestamp)
7
- }
8
-
9
- async function SMTPUpdated() {
10
- const properties: SMTPUpdatedEvent = {}
11
- await publishEvent(Event.EMAIL_SMTP_UPDATED, properties)
12
- }
13
-
14
- export default {
15
- SMTPCreated,
16
- SMTPUpdated,
17
- }
@@ -1,38 +0,0 @@
1
- import {
2
- Event,
3
- EnvironmentVariableCreatedEvent,
4
- EnvironmentVariableDeletedEvent,
5
- EnvironmentVariableUpgradePanelOpenedEvent,
6
- } from "@budibase/types"
7
- import { publishEvent } from "../events"
8
-
9
- async function created(name: string, environments: string[]) {
10
- const properties: EnvironmentVariableCreatedEvent = {
11
- name,
12
- environments,
13
- }
14
- await publishEvent(Event.ENVIRONMENT_VARIABLE_CREATED, properties)
15
- }
16
-
17
- async function deleted(name: string) {
18
- const properties: EnvironmentVariableDeletedEvent = {
19
- name,
20
- }
21
- await publishEvent(Event.ENVIRONMENT_VARIABLE_DELETED, properties)
22
- }
23
-
24
- async function upgradePanelOpened(userId: string) {
25
- const properties: EnvironmentVariableUpgradePanelOpenedEvent = {
26
- userId,
27
- }
28
- await publishEvent(
29
- Event.ENVIRONMENT_VARIABLE_UPGRADE_PANEL_OPENED,
30
- properties
31
- )
32
- }
33
-
34
- export default {
35
- created,
36
- deleted,
37
- upgradePanelOpened,
38
- }
@@ -1,99 +0,0 @@
1
- import { publishEvent } from "../events"
2
- import {
3
- Event,
4
- UserGroup,
5
- GroupCreatedEvent,
6
- GroupDeletedEvent,
7
- GroupUpdatedEvent,
8
- GroupUsersAddedEvent,
9
- GroupUsersDeletedEvent,
10
- GroupAddedOnboardingEvent,
11
- GroupPermissionsEditedEvent,
12
- } from "@budibase/types"
13
- import { isScim } from "../../context"
14
-
15
- async function created(group: UserGroup, timestamp?: number) {
16
- const properties: GroupCreatedEvent = {
17
- groupId: group._id as string,
18
- viaScim: isScim(),
19
- audited: {
20
- name: group.name,
21
- },
22
- }
23
- await publishEvent(Event.USER_GROUP_CREATED, properties, timestamp)
24
- }
25
-
26
- async function updated(group: UserGroup) {
27
- const properties: GroupUpdatedEvent = {
28
- groupId: group._id as string,
29
- viaScim: isScim(),
30
- audited: {
31
- name: group.name,
32
- },
33
- }
34
- await publishEvent(Event.USER_GROUP_UPDATED, properties)
35
- }
36
-
37
- async function deleted(group: UserGroup) {
38
- const properties: GroupDeletedEvent = {
39
- groupId: group._id as string,
40
- viaScim: isScim(),
41
- audited: {
42
- name: group.name,
43
- },
44
- }
45
- await publishEvent(Event.USER_GROUP_DELETED, properties)
46
- }
47
-
48
- async function usersAdded(count: number, group: UserGroup) {
49
- const properties: GroupUsersAddedEvent = {
50
- count,
51
- groupId: group._id as string,
52
- viaScim: isScim(),
53
- audited: {
54
- name: group.name,
55
- },
56
- }
57
- await publishEvent(Event.USER_GROUP_USERS_ADDED, properties)
58
- }
59
-
60
- async function usersDeleted(count: number, group: UserGroup) {
61
- const properties: GroupUsersDeletedEvent = {
62
- count,
63
- groupId: group._id as string,
64
- viaScim: isScim(),
65
- audited: {
66
- name: group.name,
67
- },
68
- }
69
- await publishEvent(Event.USER_GROUP_USERS_REMOVED, properties)
70
- }
71
-
72
- async function createdOnboarding(groupId: string) {
73
- const properties: GroupAddedOnboardingEvent = {
74
- groupId: groupId,
75
- onboarding: true,
76
- }
77
- await publishEvent(Event.USER_GROUP_ONBOARDING, properties)
78
- }
79
-
80
- async function permissionsEdited(group: UserGroup) {
81
- const properties: GroupPermissionsEditedEvent = {
82
- permissions: group.roles!,
83
- groupId: group._id as string,
84
- audited: {
85
- name: group.name,
86
- },
87
- }
88
- await publishEvent(Event.USER_GROUP_PERMISSIONS_EDITED, properties)
89
- }
90
-
91
- export default {
92
- created,
93
- updated,
94
- deleted,
95
- usersAdded,
96
- usersDeleted,
97
- createdOnboarding,
98
- permissionsEdited,
99
- }