@budibase/worker 2.5.5 → 2.5.6-alpha.10

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.
package/tsconfig.json CHANGED
@@ -9,23 +9,13 @@
9
9
  "@budibase/types": ["../types/src"],
10
10
  "@budibase/backend-core": ["../backend-core/src"],
11
11
  "@budibase/backend-core/*": ["../backend-core/*"],
12
- "@budibase/pro": ["../../../budibase-pro/packages/pro/src"]
12
+ "@budibase/pro": ["../pro/packages/pro/src"]
13
13
  }
14
14
  },
15
15
  "ts-node": {
16
16
  "require": ["tsconfig-paths/register"],
17
17
  "swc": true
18
18
  },
19
- "references": [
20
- { "path": "../types" },
21
- { "path": "../backend-core" },
22
- { "path": "../../../budibase-pro/packages/pro" }
23
- ],
24
- "include": [
25
- "src/**/*",
26
- "package.json"
27
- ],
28
- "exclude": [
29
- "dist"
30
- ]
31
- }
19
+ "include": ["src/**/*", "package.json"],
20
+ "exclude": ["dist"]
21
+ }
package/src/elasticApm.ts DELETED
@@ -1,10 +0,0 @@
1
- import apm from "elastic-apm-node"
2
-
3
- // enable APM if configured
4
- if (process.env.ELASTIC_APM_ENABLED) {
5
- console.log("Starting elastic-apm-node")
6
- apm.start({
7
- serviceName: process.env.SERVICE,
8
- environment: process.env.BUDIBASE_ENVIRONMENT,
9
- })
10
- }
@@ -1,34 +0,0 @@
1
- export enum LogLevel {
2
- TRACE = "trace",
3
- DEBUG = "debug",
4
- INFO = "info",
5
- WARN = "warn",
6
- ERROR = "error",
7
- }
8
-
9
- const LOG_INDEX: { [key in LogLevel]: number } = {
10
- [LogLevel.TRACE]: 1,
11
- [LogLevel.DEBUG]: 2,
12
- [LogLevel.INFO]: 3,
13
- [LogLevel.WARN]: 4,
14
- [LogLevel.ERROR]: 5,
15
- }
16
-
17
- const setIndex = LOG_INDEX[process.env.LOG_LEVEL as LogLevel]
18
-
19
- if (setIndex > LOG_INDEX.trace) {
20
- global.console.trace = jest.fn()
21
- }
22
-
23
- if (setIndex > LOG_INDEX.debug) {
24
- global.console.debug = jest.fn()
25
- }
26
-
27
- if (setIndex > LOG_INDEX.info) {
28
- global.console.info = jest.fn()
29
- global.console.log = jest.fn()
30
- }
31
-
32
- if (setIndex > LOG_INDEX.warn) {
33
- global.console.warn = jest.fn()
34
- }
@@ -1,46 +0,0 @@
1
- import fetch from "node-fetch"
2
- import {
3
- constants,
4
- tenancy,
5
- logging,
6
- env as coreEnv,
7
- } from "@budibase/backend-core"
8
- import { checkSlashesInUrl } from "../utilities"
9
- import env from "../environment"
10
- import { SyncUserRequest, User } from "@budibase/types"
11
-
12
- async function makeAppRequest(url: string, method: string, body: any) {
13
- if (env.isTest()) {
14
- return
15
- }
16
- const request: any = { headers: {} }
17
- request.headers[constants.Header.API_KEY] = coreEnv.INTERNAL_API_KEY
18
- if (tenancy.isTenantIdSet()) {
19
- request.headers[constants.Header.TENANT_ID] = tenancy.getTenantId()
20
- }
21
- if (body) {
22
- request.headers["Content-Type"] = "application/json"
23
- request.body = JSON.stringify(body)
24
- }
25
- request.method = method
26
-
27
- // add x-budibase-correlation-id header
28
- logging.correlation.setHeader(request.headers)
29
-
30
- return fetch(checkSlashesInUrl(env.APPS_URL + url), request)
31
- }
32
-
33
- export async function syncUserInApps(userId: string, previousUser?: User) {
34
- const body: SyncUserRequest = {
35
- previousUser,
36
- }
37
-
38
- const response = await makeAppRequest(
39
- `/api/users/metadata/sync/${userId}`,
40
- "POST",
41
- body
42
- )
43
- if (response && response.status !== 200) {
44
- throw "Unable to sync user."
45
- }
46
- }