Merge branch 'master' of github.com:Budibase/budibase into develop
This commit is contained in:
commit
7050ffc2cb
|
@ -93,6 +93,10 @@ spec:
|
|||
value: {{ .Values.globals.selfHosted | quote }}
|
||||
- name: SENTRY_DSN
|
||||
value: {{ .Values.globals.sentryDSN }}
|
||||
- name: ENABLE_ANALYTICS
|
||||
value: {{ .Values.globals.enableAnalytics | quote }}
|
||||
- name: POSTHOG_TOKEN
|
||||
value: {{ .Values.globals.posthogToken }}
|
||||
- name: ACCOUNT_PORTAL_URL
|
||||
value: {{ .Values.globals.accountPortalUrl | quote }}
|
||||
- name: ACCOUNT_PORTAL_API_KEY
|
||||
|
|
|
@ -89,7 +89,7 @@ affinity: {}
|
|||
globals:
|
||||
appVersion: "latest"
|
||||
budibaseEnv: PRODUCTION
|
||||
enableAnalytics: true
|
||||
enableAnalytics: "1"
|
||||
sentryDSN: ""
|
||||
posthogToken: "phc_fg5I3nDOf6oJVMHSaycEhpPdlgS8rzXG2r6F2IpxCHS"
|
||||
logLevel: info
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "1.0.200-alpha.3",
|
||||
"version": "1.0.206",
|
||||
"npmClient": "yarn",
|
||||
"packages": [
|
||||
"packages/*"
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/backend-core",
|
||||
"version": "1.0.200-alpha.3",
|
||||
"version": "1.0.206",
|
||||
"description": "Budibase backend core libraries used in server and worker",
|
||||
"main": "dist/src/index.js",
|
||||
"types": "dist/src/index.d.ts",
|
||||
|
@ -13,6 +13,7 @@
|
|||
"license": "GPL-3.0",
|
||||
"scripts": {
|
||||
"prebuild": "rimraf dist/",
|
||||
"prepack": "cp package.json dist",
|
||||
"build": "tsc -p tsconfig.build.json",
|
||||
"build:dev": "yarn prebuild && tsc --build --watch --preserveWatchOutput",
|
||||
"test": "jest",
|
||||
|
@ -56,7 +57,7 @@
|
|||
]
|
||||
},
|
||||
"devDependencies": {
|
||||
"@budibase/types": "^1.0.200-alpha.3",
|
||||
"@budibase/types": "^1.0.206",
|
||||
"@shopify/jest-koa-mocks": "3.1.5",
|
||||
"@types/jest": "27.5.1",
|
||||
"@types/koa": "2.0.52",
|
||||
|
|
|
@ -14,7 +14,6 @@ import {
|
|||
CloudAccount,
|
||||
UserIdentity,
|
||||
InstallationGroup,
|
||||
isSelfHostAccount,
|
||||
UserContext,
|
||||
Group,
|
||||
} from "@budibase/types"
|
||||
|
@ -36,6 +35,7 @@ const pkg = require("../../package.json")
|
|||
*/
|
||||
export const getCurrentIdentity = async (): Promise<Identity> => {
|
||||
let identityContext = identityCtx.getIdentity()
|
||||
const environment = getDeploymentEnvironment()
|
||||
|
||||
let identityType
|
||||
|
||||
|
@ -47,36 +47,47 @@ export const getCurrentIdentity = async (): Promise<Identity> => {
|
|||
|
||||
if (identityType === IdentityType.INSTALLATION) {
|
||||
const installationId = await getInstallationId()
|
||||
const hosting = getHostingFromEnv()
|
||||
return {
|
||||
id: formatDistinctId(installationId, identityType),
|
||||
hosting,
|
||||
type: identityType,
|
||||
installationId,
|
||||
environment,
|
||||
}
|
||||
} else if (identityType === IdentityType.TENANT) {
|
||||
const installationId = await getInstallationId()
|
||||
const tenantId = await getEventTenantId(context.getTenantId())
|
||||
const hosting = getHostingFromEnv()
|
||||
|
||||
return {
|
||||
id: formatDistinctId(tenantId, identityType),
|
||||
type: identityType,
|
||||
hosting,
|
||||
installationId,
|
||||
tenantId,
|
||||
environment,
|
||||
}
|
||||
} else if (identityType === IdentityType.USER) {
|
||||
const userContext = identityContext as UserContext
|
||||
const tenantId = await getEventTenantId(context.getTenantId())
|
||||
let installationId: string | undefined
|
||||
const installationId = await getInstallationId()
|
||||
|
||||
// self host account users won't have installation
|
||||
if (!userContext.account || !isSelfHostAccount(userContext.account)) {
|
||||
installationId = await getInstallationId()
|
||||
const account = userContext.account
|
||||
let hosting
|
||||
if (account) {
|
||||
hosting = account.hosting
|
||||
} else {
|
||||
hosting = getHostingFromEnv()
|
||||
}
|
||||
|
||||
return {
|
||||
id: userContext._id,
|
||||
type: identityType,
|
||||
hosting,
|
||||
installationId,
|
||||
tenantId,
|
||||
environment,
|
||||
}
|
||||
} else {
|
||||
throw new Error("Unknown identity type")
|
||||
|
@ -91,12 +102,14 @@ export const identifyInstallationGroup = async (
|
|||
const type = IdentityType.INSTALLATION
|
||||
const hosting = getHostingFromEnv()
|
||||
const version = pkg.version
|
||||
const environment = getDeploymentEnvironment()
|
||||
|
||||
const group: InstallationGroup = {
|
||||
id,
|
||||
type,
|
||||
hosting,
|
||||
version,
|
||||
environment,
|
||||
}
|
||||
|
||||
await identifyGroup(group, timestamp)
|
||||
|
@ -112,6 +125,8 @@ export const identifyTenantGroup = async (
|
|||
): Promise<void> => {
|
||||
const id = await getEventTenantId(tenantId)
|
||||
const type = IdentityType.TENANT
|
||||
const installationId = await getInstallationId()
|
||||
const environment = getDeploymentEnvironment()
|
||||
|
||||
let hosting: Hosting
|
||||
let profession: string | undefined
|
||||
|
@ -129,6 +144,8 @@ export const identifyTenantGroup = async (
|
|||
id,
|
||||
type,
|
||||
hosting,
|
||||
environment,
|
||||
installationId,
|
||||
profession,
|
||||
companySize,
|
||||
}
|
||||
|
@ -154,10 +171,13 @@ export const identifyUser = async (
|
|||
const verified =
|
||||
account && account?.budibaseUserId === user._id ? account.verified : false
|
||||
const installationId = await getInstallationId()
|
||||
const hosting = account ? account.hosting : getHostingFromEnv()
|
||||
const environment = getDeploymentEnvironment()
|
||||
|
||||
const identity: UserIdentity = {
|
||||
id,
|
||||
type,
|
||||
hosting,
|
||||
installationId,
|
||||
tenantId,
|
||||
verified,
|
||||
|
@ -165,6 +185,7 @@ export const identifyUser = async (
|
|||
providerType,
|
||||
builder,
|
||||
admin,
|
||||
environment,
|
||||
}
|
||||
|
||||
await identify(identity, timestamp)
|
||||
|
@ -177,6 +198,9 @@ export const identifyAccount = async (account: Account) => {
|
|||
let providerType = isSSOAccount(account) ? account.providerType : undefined
|
||||
const verified = account.verified
|
||||
const accountHolder = true
|
||||
const hosting = account.hosting
|
||||
const installationId = await getInstallationId()
|
||||
const environment = getDeploymentEnvironment()
|
||||
|
||||
if (isCloudAccount(account)) {
|
||||
if (account.budibaseUserId) {
|
||||
|
@ -188,10 +212,13 @@ export const identifyAccount = async (account: Account) => {
|
|||
const identity: UserIdentity = {
|
||||
id,
|
||||
type,
|
||||
hosting,
|
||||
installationId,
|
||||
tenantId,
|
||||
providerType,
|
||||
verified,
|
||||
accountHolder,
|
||||
environment,
|
||||
}
|
||||
|
||||
await identify(identity)
|
||||
|
@ -211,6 +238,14 @@ export const identifyGroup = async (
|
|||
await processors.identifyGroup(group, timestamp)
|
||||
}
|
||||
|
||||
const getDeploymentEnvironment = () => {
|
||||
if (env.isDev()) {
|
||||
return "development"
|
||||
} else {
|
||||
return env.DEPLOYMENT_ENVIRONMENT
|
||||
}
|
||||
}
|
||||
|
||||
const getHostingFromEnv = () => {
|
||||
return env.SELF_HOSTED ? Hosting.SELF : Hosting.CLOUD
|
||||
}
|
||||
|
|
|
@ -7,14 +7,17 @@ import PosthogProcessor from "./PosthogProcessor"
|
|||
/**
|
||||
* Events that are always captured.
|
||||
*/
|
||||
const EVENT_WHITELIST = [Event.VERSION_UPGRADED, Event.VERSION_DOWNGRADED]
|
||||
const EVENT_WHITELIST = [
|
||||
Event.INSTALLATION_VERSION_UPGRADED,
|
||||
Event.INSTALLATION_VERSION_DOWNGRADED,
|
||||
]
|
||||
const IDENTITY_WHITELIST = [IdentityType.INSTALLATION, IdentityType.TENANT]
|
||||
|
||||
export default class AnalyticsProcessor implements EventProcessor {
|
||||
posthog: PosthogProcessor | undefined
|
||||
|
||||
constructor() {
|
||||
if (env.POSTHOG_TOKEN) {
|
||||
if (env.POSTHOG_TOKEN && !env.isTest()) {
|
||||
this.posthog = new PosthogProcessor(env.POSTHOG_TOKEN)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,8 @@ export default class PosthogProcessor implements EventProcessor {
|
|||
): Promise<void> {
|
||||
properties.version = pkg.version
|
||||
properties.service = env.SERVICE
|
||||
properties.environment = env.DEPLOYMENT_ENVIRONMENT
|
||||
properties.environment = identity.environment
|
||||
properties.hosting = identity.hosting
|
||||
|
||||
const appId = context.getAppId()
|
||||
if (appId) {
|
||||
|
|
|
@ -15,5 +15,5 @@ export * as table from "./table"
|
|||
export * as serve from "./serve"
|
||||
export * as user from "./user"
|
||||
export * as view from "./view"
|
||||
export * as version from "./version"
|
||||
export * as installation from "./installation"
|
||||
export * as backfill from "./backfill"
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import { publishEvent } from "../events"
|
||||
import { Event, VersionCheckedEvent, VersionChangeEvent } from "@budibase/types"
|
||||
|
||||
export async function checked(version: string) {
|
||||
export async function versionChecked(version: string) {
|
||||
const properties: VersionCheckedEvent = {
|
||||
currentVersion: version,
|
||||
}
|
||||
await publishEvent(Event.VERSION_CHECKED, properties)
|
||||
await publishEvent(Event.INSTALLATION_VERSION_CHECKED, properties)
|
||||
}
|
||||
|
||||
export async function upgraded(from: string, to: string) {
|
||||
|
@ -14,7 +14,7 @@ export async function upgraded(from: string, to: string) {
|
|||
to,
|
||||
}
|
||||
|
||||
await publishEvent(Event.VERSION_UPGRADED, properties)
|
||||
await publishEvent(Event.INSTALLATION_VERSION_UPGRADED, properties)
|
||||
}
|
||||
|
||||
export async function downgraded(from: string, to: string) {
|
||||
|
@ -22,5 +22,10 @@ export async function downgraded(from: string, to: string) {
|
|||
from,
|
||||
to,
|
||||
}
|
||||
await publishEvent(Event.VERSION_DOWNGRADED, properties)
|
||||
await publishEvent(Event.INSTALLATION_VERSION_DOWNGRADED, properties)
|
||||
}
|
||||
|
||||
export async function firstStartup() {
|
||||
const properties = {}
|
||||
await publishEvent(Event.INSTALLATION_FIRST_STARTUP, properties)
|
||||
}
|
|
@ -84,9 +84,9 @@ export const checkInstallVersion = async (): Promise<void> => {
|
|||
},
|
||||
async () => {
|
||||
if (isUpgrade) {
|
||||
await events.version.upgraded(currentVersion, newVersion)
|
||||
await events.installation.upgraded(currentVersion, newVersion)
|
||||
} else if (isDowngrade) {
|
||||
await events.version.downgraded(currentVersion, newVersion)
|
||||
await events.installation.downgraded(currentVersion, newVersion)
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
@ -55,7 +55,7 @@ jest.spyOn(events.org, "logoUpdated")
|
|||
jest.spyOn(events.org, "platformURLUpdated")
|
||||
jest.spyOn(events.org, "analyticsOptOut")
|
||||
|
||||
jest.spyOn(events.version, "checked")
|
||||
jest.spyOn(events.installation, "versionChecked")
|
||||
|
||||
jest.spyOn(events.query, "created")
|
||||
jest.spyOn(events.query, "updated")
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@budibase/bbui",
|
||||
"description": "A UI solution used in the different Budibase projects.",
|
||||
"version": "1.0.200-alpha.3",
|
||||
"version": "1.0.206",
|
||||
"license": "MPL-2.0",
|
||||
"svelte": "src/index.js",
|
||||
"module": "dist/bbui.es.js",
|
||||
|
@ -38,7 +38,7 @@
|
|||
],
|
||||
"dependencies": {
|
||||
"@adobe/spectrum-css-workflow-icons": "^1.2.1",
|
||||
"@budibase/string-templates": "^1.0.200-alpha.3",
|
||||
"@budibase/string-templates": "^1.0.206",
|
||||
"@spectrum-css/actionbutton": "^1.0.1",
|
||||
"@spectrum-css/actiongroup": "^1.0.1",
|
||||
"@spectrum-css/avatar": "^3.0.2",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/builder",
|
||||
"version": "1.0.200-alpha.3",
|
||||
"version": "1.0.206",
|
||||
"license": "GPL-3.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
@ -69,10 +69,10 @@
|
|||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"@budibase/bbui": "^1.0.200-alpha.3",
|
||||
"@budibase/client": "^1.0.200-alpha.3",
|
||||
"@budibase/frontend-core": "^1.0.200-alpha.3",
|
||||
"@budibase/string-templates": "^1.0.200-alpha.3",
|
||||
"@budibase/bbui": "^1.0.206",
|
||||
"@budibase/client": "^1.0.206",
|
||||
"@budibase/frontend-core": "^1.0.206",
|
||||
"@budibase/string-templates": "^1.0.206",
|
||||
"@sentry/browser": "5.19.1",
|
||||
"@spectrum-css/page": "^3.0.1",
|
||||
"@spectrum-css/vars": "^3.0.1",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/cli",
|
||||
"version": "1.0.200-alpha.3",
|
||||
"version": "1.0.206",
|
||||
"description": "Budibase CLI, for developers, self hosting and migrations.",
|
||||
"main": "src/index.js",
|
||||
"bin": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/client",
|
||||
"version": "1.0.200-alpha.3",
|
||||
"version": "1.0.206",
|
||||
"license": "MPL-2.0",
|
||||
"module": "dist/budibase-client.js",
|
||||
"main": "dist/budibase-client.js",
|
||||
|
@ -19,9 +19,9 @@
|
|||
"dev:builder": "rollup -cw"
|
||||
},
|
||||
"dependencies": {
|
||||
"@budibase/bbui": "^1.0.200-alpha.3",
|
||||
"@budibase/frontend-core": "^1.0.200-alpha.3",
|
||||
"@budibase/string-templates": "^1.0.200-alpha.3",
|
||||
"@budibase/bbui": "^1.0.206",
|
||||
"@budibase/frontend-core": "^1.0.206",
|
||||
"@budibase/string-templates": "^1.0.206",
|
||||
"@spectrum-css/button": "^3.0.3",
|
||||
"@spectrum-css/card": "^3.0.3",
|
||||
"@spectrum-css/divider": "^1.0.3",
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "@budibase/frontend-core",
|
||||
"version": "1.0.200-alpha.3",
|
||||
"version": "1.0.206",
|
||||
"description": "Budibase frontend core libraries used in builder and client",
|
||||
"author": "Budibase",
|
||||
"license": "MPL-2.0",
|
||||
"svelte": "src/index.js",
|
||||
"dependencies": {
|
||||
"@budibase/bbui": "^1.0.200-alpha.3",
|
||||
"@budibase/bbui": "^1.0.206",
|
||||
"lodash": "^4.17.21",
|
||||
"svelte": "^3.46.2"
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@budibase/server",
|
||||
"email": "hi@budibase.com",
|
||||
"version": "1.0.200-alpha.3",
|
||||
"version": "1.0.206",
|
||||
"description": "Budibase Web Server",
|
||||
"main": "src/index.ts",
|
||||
"repository": {
|
||||
|
@ -77,10 +77,10 @@
|
|||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@apidevtools/swagger-parser": "10.0.3",
|
||||
"@budibase/backend-core": "^1.0.200-alpha.3",
|
||||
"@budibase/client": "^1.0.200-alpha.3",
|
||||
"@budibase/pro": "1.0.200-alpha.3",
|
||||
"@budibase/string-templates": "^1.0.200-alpha.3",
|
||||
"@budibase/backend-core": "^1.0.206",
|
||||
"@budibase/client": "^1.0.206",
|
||||
"@budibase/pro": "1.0.206",
|
||||
"@budibase/string-templates": "^1.0.206",
|
||||
"@bull-board/api": "3.7.0",
|
||||
"@bull-board/koa": "3.9.4",
|
||||
"@elastic/elasticsearch": "7.10.0",
|
||||
|
@ -151,7 +151,7 @@
|
|||
"@babel/core": "7.17.4",
|
||||
"@babel/preset-env": "7.16.11",
|
||||
"@budibase/standard-components": "^0.9.139",
|
||||
"@budibase/types": "^1.0.200-alpha.3",
|
||||
"@budibase/types": "^1.0.206",
|
||||
"@jest/test-sequencer": "24.9.0",
|
||||
"@types/apidoc": "0.50.0",
|
||||
"@types/bson": "4.2.0",
|
||||
|
|
|
@ -131,5 +131,5 @@ exports.getBudibaseVersion = async ctx => {
|
|||
ctx.body = {
|
||||
version,
|
||||
}
|
||||
await events.version.checked(version)
|
||||
await events.installation.versionChecked(version)
|
||||
}
|
||||
|
|
|
@ -17,7 +17,6 @@ const { attachmentsRelativeURL } = require("../../../utilities")
|
|||
const { DocumentTypes, isDevAppID } = require("../../../db/utils")
|
||||
const { getAppDB, getAppId } = require("@budibase/backend-core/context")
|
||||
const AWS = require("aws-sdk")
|
||||
const AWS_REGION = env.AWS_REGION ? env.AWS_REGION : "eu-west-1"
|
||||
const { events } = require("@budibase/backend-core")
|
||||
|
||||
async function prepareUpload({ s3Key, bucket, metadata, file }) {
|
||||
|
@ -42,7 +41,9 @@ async function prepareUpload({ s3Key, bucket, metadata, file }) {
|
|||
exports.serveBuilder = async function (ctx) {
|
||||
let builderPath = resolve(TOP_LEVEL_PATH, "builder")
|
||||
await send(ctx, ctx.file, { root: builderPath })
|
||||
await events.serve.servedBuilder()
|
||||
if (!ctx.file.includes("assets/")) {
|
||||
await events.serve.servedBuilder()
|
||||
}
|
||||
}
|
||||
|
||||
exports.uploadFile = async function (ctx) {
|
||||
|
@ -128,6 +129,7 @@ exports.getSignedUploadURL = async function (ctx) {
|
|||
// Determine type of datasource and generate signed URL
|
||||
let signedUrl
|
||||
let publicUrl
|
||||
const awsRegion = datasource?.config?.region || "eu-west-1"
|
||||
if (datasource.source === "S3") {
|
||||
const { bucket, key } = ctx.request.body || {}
|
||||
if (!bucket || !key) {
|
||||
|
@ -136,7 +138,7 @@ exports.getSignedUploadURL = async function (ctx) {
|
|||
}
|
||||
try {
|
||||
const s3 = new AWS.S3({
|
||||
region: AWS_REGION,
|
||||
region: awsRegion,
|
||||
accessKeyId: datasource?.config?.accessKeyId,
|
||||
secretAccessKey: datasource?.config?.secretAccessKey,
|
||||
apiVersion: "2006-03-01",
|
||||
|
@ -144,7 +146,7 @@ exports.getSignedUploadURL = async function (ctx) {
|
|||
})
|
||||
const params = { Bucket: bucket, Key: key }
|
||||
signedUrl = s3.getSignedUrl("putObject", params)
|
||||
publicUrl = `https://${bucket}.s3.${AWS_REGION}.amazonaws.com/${key}`
|
||||
publicUrl = `https://${bucket}.s3.${awsRegion}.amazonaws.com/${key}`
|
||||
} catch (error) {
|
||||
ctx.throw(400, error)
|
||||
}
|
||||
|
|
|
@ -33,8 +33,8 @@ describe("/dev", () => {
|
|||
.expect(200)
|
||||
|
||||
expect(res.body.version).toBe(version)
|
||||
expect(events.version.checked).toBeCalledTimes(1)
|
||||
expect(events.version.checked).toBeCalledWith(version)
|
||||
expect(events.installation.versionChecked).toBeCalledTimes(1)
|
||||
expect(events.installation.versionChecked).toBeCalledWith(version)
|
||||
})
|
||||
})
|
||||
})
|
|
@ -72,7 +72,7 @@ exports.run = async function ({ inputs, appId, emitter }) {
|
|||
})
|
||||
|
||||
try {
|
||||
await queryController.executeV1(ctx)
|
||||
await queryController.executeV2(ctx)
|
||||
const { data, ...rest } = ctx.body
|
||||
return {
|
||||
response: data,
|
||||
|
|
|
@ -66,7 +66,6 @@ module Firebase {
|
|||
"==",
|
||||
"<",
|
||||
"<=",
|
||||
"==",
|
||||
"!=",
|
||||
">=",
|
||||
">",
|
||||
|
|
|
@ -20,6 +20,7 @@ const handleError = (e: any, errors?: any) => {
|
|||
}
|
||||
return
|
||||
}
|
||||
console.trace(e)
|
||||
throw e
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,23 @@ export const backfill = async (appDb: any, timestamp: string | number) => {
|
|||
const queries: Query[] = await getQueries(appDb)
|
||||
|
||||
for (const query of queries) {
|
||||
const datasource: Datasource = await getDatasource(
|
||||
appDb,
|
||||
query.datasourceId
|
||||
)
|
||||
let datasource: Datasource
|
||||
|
||||
try {
|
||||
datasource = await getDatasource(appDb, query.datasourceId)
|
||||
} catch (e: any) {
|
||||
// handle known bug where a datasource has been deleted
|
||||
// and the query has not
|
||||
if (e.status === 404) {
|
||||
datasource = {
|
||||
_id: query.datasourceId,
|
||||
source: "unknown",
|
||||
}
|
||||
} else {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
await events.query.created(datasource, query, timestamp)
|
||||
}
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ import {
|
|||
App,
|
||||
TenantBackfillSucceededEvent,
|
||||
Event,
|
||||
User,
|
||||
} from "@budibase/types"
|
||||
import env from "../../../environment"
|
||||
import { DEFAULT_TIMESTAMP } from "."
|
||||
|
@ -94,8 +95,24 @@ export const run = async (db: any) => {
|
|||
const totals: any = {}
|
||||
const errors: any = []
|
||||
|
||||
let allUsers: User[] = []
|
||||
try {
|
||||
const installTimestamp = await getInstallTimestamp(db)
|
||||
allUsers = await users.getUsers(db)
|
||||
} catch (e: any) {
|
||||
handleError(e, errors)
|
||||
}
|
||||
|
||||
if (!allUsers || allUsers.length === 0) {
|
||||
// first time startup - we don't need to backfill anything
|
||||
// tenant will be identified when admin user is created
|
||||
if (env.SELF_HOSTED) {
|
||||
await events.installation.firstStartup()
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
const installTimestamp = await getInstallTimestamp(db, allUsers)
|
||||
if (installTimestamp) {
|
||||
timestamp = installTimestamp
|
||||
}
|
||||
|
@ -175,20 +192,25 @@ export const isComplete = async (): Promise<boolean> => {
|
|||
}
|
||||
|
||||
export const getInstallTimestamp = async (
|
||||
globalDb: any
|
||||
globalDb: any,
|
||||
allUsers?: User[]
|
||||
): Promise<number | undefined> => {
|
||||
const allUsers = await users.getUsers(globalDb)
|
||||
if (!allUsers) {
|
||||
allUsers = await users.getUsers(globalDb)
|
||||
}
|
||||
|
||||
// get the oldest user timestamp
|
||||
const timestamps = allUsers
|
||||
.map(user => user.createdAt)
|
||||
.filter(timestamp => !!timestamp)
|
||||
.sort(
|
||||
(a, b) =>
|
||||
new Date(a as number).getTime() - new Date(b as number).getTime()
|
||||
)
|
||||
if (allUsers) {
|
||||
const timestamps = allUsers
|
||||
.map(user => user.createdAt)
|
||||
.filter(timestamp => !!timestamp)
|
||||
.sort(
|
||||
(a, b) =>
|
||||
new Date(a as number).getTime() - new Date(b as number).getTime()
|
||||
)
|
||||
|
||||
if (timestamps.length) {
|
||||
return timestamps[0]
|
||||
if (timestamps.length) {
|
||||
return timestamps[0]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,7 +104,6 @@ export const migrate = async (options?: MigrationOptions) => {
|
|||
|
||||
const migrateWithLock = async (options?: MigrationOptions) => {
|
||||
// get a new lock client
|
||||
|
||||
const redlock = await redis.clients.getMigrationsRedlock()
|
||||
// lock for 15 minutes
|
||||
const ttl = 1000 * 60 * 15
|
||||
|
|
|
@ -23,6 +23,8 @@ const clearMigrations = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
jest.setTimeout(10000)
|
||||
|
||||
describe("migrations", () => {
|
||||
const config = new TestConfig()
|
||||
|
||||
|
|
|
@ -1094,10 +1094,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@budibase/backend-core@1.0.200-alpha.0":
|
||||
version "1.0.200-alpha.0"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.200-alpha.0.tgz#2fd1e1cc71c07891fd66e37ceaab2cffb0df1106"
|
||||
integrity sha512-CZPPuj+WIDTxLVbrv/B4J4rQiNnkRBs3ZWK2AvlVlY9knWuM034MKHPK3YaeQdVofZqkTOfWKZp6KFRroC304g==
|
||||
"@budibase/backend-core@1.0.201-alpha.4":
|
||||
version "1.0.201-alpha.4"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.201-alpha.4.tgz#51fda5838e9c51c88c85204ad867811e49b7d34c"
|
||||
integrity sha512-5oQMfKPDMpB4x5MzGgOtWFIPzc7RG/uu+rSe65PVwWfp77bDa3kxtCtC1p6vtJuPlb4GYrHqGLtr7WePbJf4fA==
|
||||
dependencies:
|
||||
"@techpass/passport-openidconnect" "0.3.2"
|
||||
aws-sdk "2.1030.0"
|
||||
|
@ -1175,12 +1175,12 @@
|
|||
svelte-flatpickr "^3.2.3"
|
||||
svelte-portal "^1.0.0"
|
||||
|
||||
"@budibase/pro@1.0.200-alpha.0":
|
||||
version "1.0.200-alpha.0"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.200-alpha.0.tgz#68adc9a61a1b975a990e1a4d4ddf5dba69fc038c"
|
||||
integrity sha512-GxIxvBjCO7kQxFwASKtGC57C2cAN3oiHU+tTCb57qKtp63GdP1z+iqDLtUEOIXXume9bC1xxTD/LSBMziTrHKg==
|
||||
"@budibase/pro@1.0.201-alpha.4":
|
||||
version "1.0.201-alpha.4"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.201-alpha.4.tgz#5b92dc7a4bb2004bcd43339c863430ea640e0b74"
|
||||
integrity sha512-fsDlE8O4Y4JpZI3NwBoN8udX4cEx7/ebZ41Q7qD5VwA6Q2niapRcX0MvDmGdjDSVECG+NJU1uqCdg5cDq1Odxw==
|
||||
dependencies:
|
||||
"@budibase/backend-core" "1.0.200-alpha.0"
|
||||
"@budibase/backend-core" "1.0.201-alpha.4"
|
||||
node-fetch "^2.6.1"
|
||||
|
||||
"@budibase/standard-components@^0.9.139":
|
||||
|
@ -14327,4 +14327,4 @@ z-schema@^5.0.1:
|
|||
zlib@1.0.5:
|
||||
version "1.0.5"
|
||||
resolved "https://registry.yarnpkg.com/zlib/-/zlib-1.0.5.tgz#6e7c972fc371c645a6afb03ab14769def114fcc0"
|
||||
integrity sha1-bnyXL8NxxkWmr7A6sUdp3vEU/MA=
|
||||
integrity sha512-40fpE2II+Cd3k8HWTWONfeKE2jL+P42iWJ1zzps5W51qcTsOUKM5Q5m2PFb0CLxlmFAaUuUdJGc3OfZy947v0w==
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/string-templates",
|
||||
"version": "1.0.200-alpha.3",
|
||||
"version": "1.0.206",
|
||||
"description": "Handlebars wrapper for Budibase templating.",
|
||||
"main": "src/index.cjs",
|
||||
"module": "dist/bundle.mjs",
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@budibase/types",
|
||||
"version": "1.0.200-alpha.3",
|
||||
"version": "1.0.206",
|
||||
"description": "Budibase types",
|
||||
"main": "dist/index.js",
|
||||
"types": "dist/index.d.ts",
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import { Hosting } from "../hosting"
|
||||
|
||||
export enum Event {
|
||||
// USER
|
||||
USER_CREATED = "user:created",
|
||||
|
@ -37,10 +39,11 @@ export enum Event {
|
|||
ORG_LOGO_UPDATED = "org:info:logo:updated",
|
||||
ORG_PLATFORM_URL_UPDATED = "org:platformurl:updated",
|
||||
|
||||
// VERSIONS
|
||||
VERSION_CHECKED = "version:checked",
|
||||
VERSION_UPGRADED = "version:upgraded",
|
||||
VERSION_DOWNGRADED = "version:downgraded",
|
||||
// INSTALLATION
|
||||
INSTALLATION_VERSION_CHECKED = "installation:version:checked",
|
||||
INSTALLATION_VERSION_UPGRADED = "installation:version:upgraded",
|
||||
INSTALLATION_VERSION_DOWNGRADED = "installation:version:downgraded",
|
||||
INSTALLATION_FIRST_STARTUP = "installation:firstStartup",
|
||||
|
||||
// ORG / ANALYTICS
|
||||
ANALYTICS_OPT_OUT = "analytics:opt:out",
|
||||
|
@ -157,6 +160,7 @@ export interface BaseEvent {
|
|||
appId?: string
|
||||
installationId?: string
|
||||
tenantId?: string
|
||||
hosting?: Hosting
|
||||
}
|
||||
|
||||
export type RowImportFormat = "csv"
|
||||
|
|
|
@ -10,6 +10,8 @@ export enum GroupType {
|
|||
export interface Group {
|
||||
id: string
|
||||
type: IdentityType
|
||||
environment: string
|
||||
hosting: Hosting
|
||||
}
|
||||
|
||||
export interface TenantGroup extends Group {
|
||||
|
@ -17,12 +19,11 @@ export interface TenantGroup extends Group {
|
|||
// as we don't have this at the user level
|
||||
profession?: string // only available in cloud
|
||||
companySize?: string // only available in cloud
|
||||
hosting: Hosting // need hosting at the tenant level for cloud self host accounts
|
||||
installationId: string
|
||||
}
|
||||
|
||||
export interface InstallationGroup extends Group {
|
||||
version: string
|
||||
hosting: Hosting
|
||||
}
|
||||
|
||||
// IDENTITIES
|
||||
|
@ -36,6 +37,8 @@ export enum IdentityType {
|
|||
export interface Identity {
|
||||
id: string
|
||||
type: IdentityType
|
||||
hosting: Hosting
|
||||
environment: string
|
||||
installationId?: string
|
||||
tenantId?: string
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "@budibase/worker",
|
||||
"email": "hi@budibase.com",
|
||||
"version": "1.0.200-alpha.3",
|
||||
"version": "1.0.206",
|
||||
"description": "Budibase background service",
|
||||
"main": "src/index.ts",
|
||||
"repository": {
|
||||
|
@ -34,9 +34,9 @@
|
|||
"author": "Budibase",
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@budibase/backend-core": "^1.0.200-alpha.3",
|
||||
"@budibase/pro": "1.0.200-alpha.3",
|
||||
"@budibase/string-templates": "^1.0.200-alpha.3",
|
||||
"@budibase/backend-core": "^1.0.206",
|
||||
"@budibase/pro": "1.0.206",
|
||||
"@budibase/string-templates": "^1.0.206",
|
||||
"@koa/router": "8.0.8",
|
||||
"@sentry/node": "6.17.7",
|
||||
"@techpass/passport-openidconnect": "0.3.2",
|
||||
|
@ -66,7 +66,7 @@
|
|||
"server-destroy": "1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@budibase/types": "^1.0.200-alpha.3",
|
||||
"@budibase/types": "^1.0.206",
|
||||
"@types/jest": "26.0.23",
|
||||
"@types/koa": "2.13.4",
|
||||
"@types/koa-router": "7.4.4",
|
||||
|
|
|
@ -291,10 +291,10 @@
|
|||
resolved "https://registry.yarnpkg.com/@bcoe/v8-coverage/-/v8-coverage-0.2.3.tgz#75a2e8b51cb758a7553d6804a5932d7aace75c39"
|
||||
integrity sha512-0hYQ8SB4Db5zvZB4axdMHGwEaQjkZzFjQiN9LVYvIFB2nSUHW9tYpxWriPrWDASIxiaXax83REcLxuSdnGPZtw==
|
||||
|
||||
"@budibase/backend-core@1.0.200-alpha.0":
|
||||
version "1.0.200-alpha.0"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.200-alpha.0.tgz#2fd1e1cc71c07891fd66e37ceaab2cffb0df1106"
|
||||
integrity sha512-CZPPuj+WIDTxLVbrv/B4J4rQiNnkRBs3ZWK2AvlVlY9knWuM034MKHPK3YaeQdVofZqkTOfWKZp6KFRroC304g==
|
||||
"@budibase/backend-core@1.0.201-alpha.4":
|
||||
version "1.0.201-alpha.4"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/backend-core/-/backend-core-1.0.201-alpha.4.tgz#51fda5838e9c51c88c85204ad867811e49b7d34c"
|
||||
integrity sha512-5oQMfKPDMpB4x5MzGgOtWFIPzc7RG/uu+rSe65PVwWfp77bDa3kxtCtC1p6vtJuPlb4GYrHqGLtr7WePbJf4fA==
|
||||
dependencies:
|
||||
"@techpass/passport-openidconnect" "0.3.2"
|
||||
aws-sdk "2.1030.0"
|
||||
|
@ -322,12 +322,12 @@
|
|||
uuid "8.3.2"
|
||||
zlib "1.0.5"
|
||||
|
||||
"@budibase/pro@1.0.200-alpha.0":
|
||||
version "1.0.200-alpha.0"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.200-alpha.0.tgz#68adc9a61a1b975a990e1a4d4ddf5dba69fc038c"
|
||||
integrity sha512-GxIxvBjCO7kQxFwASKtGC57C2cAN3oiHU+tTCb57qKtp63GdP1z+iqDLtUEOIXXume9bC1xxTD/LSBMziTrHKg==
|
||||
"@budibase/pro@1.0.201-alpha.4":
|
||||
version "1.0.201-alpha.4"
|
||||
resolved "https://registry.yarnpkg.com/@budibase/pro/-/pro-1.0.201-alpha.4.tgz#5b92dc7a4bb2004bcd43339c863430ea640e0b74"
|
||||
integrity sha512-fsDlE8O4Y4JpZI3NwBoN8udX4cEx7/ebZ41Q7qD5VwA6Q2niapRcX0MvDmGdjDSVECG+NJU1uqCdg5cDq1Odxw==
|
||||
dependencies:
|
||||
"@budibase/backend-core" "1.0.200-alpha.0"
|
||||
"@budibase/backend-core" "1.0.201-alpha.4"
|
||||
node-fetch "^2.6.1"
|
||||
|
||||
"@cspotcode/source-map-consumer@0.8.0":
|
||||
|
|
Loading…
Reference in New Issue