Skip to content

Commit

Permalink
Merge branch 'master' into automations-fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aptkingston authored Dec 9, 2024
2 parents 6d60745 + d725d49 commit 7008723
Show file tree
Hide file tree
Showing 51 changed files with 470 additions and 237 deletions.
10 changes: 1 addition & 9 deletions packages/backend-core/src/cache/invite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,10 @@ import { Duration } from "../utils"
import env from "../environment"
import { getTenantId } from "../context"
import * as redis from "../redis/init"
import { Invite, InviteWithCode } from "@budibase/types"

const TTL_SECONDS = Duration.fromDays(7).toSeconds()

interface Invite {
email: string
info: any
}

interface InviteWithCode extends Invite {
code: string
}

/**
* Given an invite code and invite body, allow the update an existing/valid invite in redis
* @param code The invite code for an invite in redis
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@
.map(table => format.table(table, $datasources.list))
.sort((a, b) => {
// sort tables alphabetically, grouped by datasource
const dsComparison = a.datasourceName.localeCompare(b.datasourceName)
const dsA = a.datasourceName ?? ""
const dsB = b.datasourceName ?? ""
const dsComparison = dsA.localeCompare(dsB)
if (dsComparison !== 0) {
return dsComparison
}
Expand Down
4 changes: 2 additions & 2 deletions packages/server/src/api/controllers/templates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ import { downloadTemplate as dlTemplate } from "../../utilities/fileSystem"
import env from "../../environment"
import {
DownloadTemplateResponse,
FetchTemplateResponse,
FetchGlobalTemplateResponse,
UserCtx,
} from "@budibase/types"

// development flag, can be used to test against templates exported locally
const DEFAULT_TEMPLATES_BUCKET =
"prod-budi-templates.s3-eu-west-1.amazonaws.com"

export async function fetch(ctx: UserCtx<void, FetchTemplateResponse>) {
export async function fetch(ctx: UserCtx<void, FetchGlobalTemplateResponse>) {
let type = env.TEMPLATE_REPOSITORY
let response,
error = false
Expand Down
14 changes: 14 additions & 0 deletions packages/types/src/api/web/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,28 @@ export interface LoginRequest {
password: string
}

export interface LogoutResponse {
message: string
}

export interface SetInitInfoRequest extends Record<string, any> {}

export interface GetInitInfoResponse extends Record<string, any> {}

export interface PasswordResetRequest {
email: string
}
export interface PasswordResetResponse {
message: string
}

export interface PasswordResetUpdateRequest {
resetCode: string
password: string
}
export interface PasswordResetUpdateResponse {
message: string
}

export interface UpdateSelfRequest {
firstName?: string
Expand Down
39 changes: 38 additions & 1 deletion packages/types/src/api/web/global/configs.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
import { SettingsConfig, SettingsInnerConfig } from "../../../documents"
import {
Config,
ConfigType,
SettingsBrandingConfig,
SettingsConfig,
SettingsInnerConfig,
} from "../../../documents"

/**
* Settings that aren't stored in the database - enriched at runtime.
Expand All @@ -22,3 +28,34 @@ export interface PublicOIDCConfig {
}

export type GetPublicOIDCConfigResponse = PublicOIDCConfig[]

export interface SaveConfigRequest extends Config {}
export interface SaveConfigResponse {
type: ConfigType
_id: string
_rev: string
}

export interface DeleteConfigResponse {
message: string
}

interface ChecklistItem {
checked: boolean
label: string
link: string
}
export interface ConfigChecklistResponse {
apps: ChecklistItem
smtp: ChecklistItem
adminUser: ChecklistItem
sso: ChecklistItem
branding: SettingsBrandingConfig
}

export type FindConfigResponse = Config | {}

export interface UploadConfigFileResponse {
message: string
url: string
}
28 changes: 28 additions & 0 deletions packages/types/src/api/web/global/email.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { EmailAttachment, EmailInvite } from "../../../documents"

export enum EmailTemplatePurpose {
CORE = "core",
BASE = "base",
PASSWORD_RECOVERY = "password_recovery",
INVITATION = "invitation",
WELCOME = "welcome",
CUSTOM = "custom",
}

export interface SendEmailRequest {
workspaceId?: string
email: string
userId: string
purpose: EmailTemplatePurpose
contents?: string
from?: string
subject: string
cc?: boolean
bcc?: boolean
automation?: boolean
invite?: EmailInvite
attachments?: EmailAttachment[]
}
export interface SendEmailResponse extends Record<string, any> {
message: string
}
4 changes: 4 additions & 0 deletions packages/types/src/api/web/global/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ export * from "./configs"
export * from "./scim"
export * from "./license"
export * from "./oldMigration"
export * from "./email"
export * from "./role"
export * from "./self"
export * from "./template"
4 changes: 4 additions & 0 deletions packages/types/src/api/web/global/license.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// LICENSE KEY

import { QuotaUsage } from "../../../documents"

export interface ActivateLicenseKeyRequest {
licenseKey: string
}
Expand All @@ -23,3 +25,5 @@ export interface GetOfflineLicenseTokenResponse {
export interface GetOfflineIdentifierResponse {
identifierBase64: string
}

export interface GetQuotaUsageResponse extends QuotaUsage {}
17 changes: 17 additions & 0 deletions packages/types/src/api/web/global/role.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { Role } from "../../../documents"

interface GlobalRoleResponse {
roles: Role[]
name: string
version: string
url?: string
}

export interface FetchGlobalRolesResponse
extends Record<string, GlobalRoleResponse> {}

export interface FindGlobalRoleResponse extends GlobalRoleResponse {}

export interface RemoveAppRoleResponse {
message: string
}
12 changes: 12 additions & 0 deletions packages/types/src/api/web/global/self.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { DevInfo, User } from "../../../documents"

export interface GenerateAPIKeyRequest {
userId: string
}
export interface GenerateAPIKeyResponse extends DevInfo {}

export interface FetchAPIKeyResponse extends DevInfo {}

export interface GetGlobalSelfResponse extends User {
flags?: Record<string, string>
}
30 changes: 30 additions & 0 deletions packages/types/src/api/web/global/template.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { Template } from "../../../documents"

export interface GlobalTemplateDefinition {
name: string
description: string
category: string
}

export interface GlobalTemplateBinding {
name: string
description: string
}

export interface FetchGlobalTemplateDefinitionResponse {
info: Record<string, GlobalTemplateDefinition>
bindings: Record<string, GlobalTemplateBinding[]>
}

export interface SaveGlobalTemplateRequest extends Template {}
export interface SaveGlobalTemplateResponse extends Template {}

export type FetchGlobalTemplateResponse = Template[]
export type FetchGlobalTemplateByTypeResponse = Template[]
export type FetchGlobalTemplateByOwnerIDResponse = Template[]

export interface FindGlobalTemplateResponse extends Template {}

export interface DeleteGlobalTemplateResponse {
message: string
}
4 changes: 4 additions & 0 deletions packages/types/src/api/web/system/account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import { Account, AccountMetadata } from "../../../documents"

export interface SaveAccountRequest extends Account {}
export interface SaveAccountResponse extends AccountMetadata {}
7 changes: 5 additions & 2 deletions packages/types/src/api/web/system/environment.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
export interface GetEnvironmentResponse {
multiTenancy: boolean
offlineMode: boolean
cloud: boolean
accountPortalUrl: string
baseUrl: string
accountPortalUrl?: string
disableAccountPortal: boolean
baseUrl?: string
isDev: boolean
maintenance: { type: string }[]
passwordMinLength?: string
}
5 changes: 5 additions & 0 deletions packages/types/src/api/web/system/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
export * from "./environment"
export * from "./status"
export * from "./ops"
export * from "./account"
export * from "./log"
export * from "./migration"
export * from "./restore"
export * from "./tenant"
1 change: 1 addition & 0 deletions packages/types/src/api/web/system/log.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export type GetLogResponse = Buffer
5 changes: 5 additions & 0 deletions packages/types/src/api/web/system/migration.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { MigrationDefinition, MigrationOptions } from "../../../sdk"

export interface RunGlobalMigrationRequest extends MigrationOptions {}

export type FetchMigrationDefinitionsResponse = MigrationDefinition[]
3 changes: 3 additions & 0 deletions packages/types/src/api/web/system/restore.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface SystemRestoreResponse {
message: string
}
3 changes: 3 additions & 0 deletions packages/types/src/api/web/system/tenant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export interface GetTenantInfoResponse {
exists: boolean
}
55 changes: 54 additions & 1 deletion packages/types/src/api/web/user.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
import { User } from "../../documents"
import { AccountMetadata, PlatformUser, User } from "../../documents"
import { SearchFilters } from "../../sdk"

export interface Invite {
email: string
info: any
}

export interface InviteWithCode extends Invite {
code: string
}

export interface SaveUserResponse {
_id: string
_rev: string
Expand Down Expand Up @@ -47,13 +56,21 @@ export interface InviteUserRequest {
email: string
userInfo: any
}
export interface InviteUserResponse {
message: string
successful: { email: string }[]
unsuccessful: { email: string; reason: string }[]
}

export interface DeleteInviteUserRequest {
code: string
}

export type InviteUsersRequest = InviteUserRequest[]
export type DeleteInviteUsersRequest = DeleteInviteUserRequest[]
export interface DeleteInviteUsersResponse {
message: string
}

export interface InviteUsersResponse {
successful: { email: string }[]
Expand All @@ -68,6 +85,17 @@ export interface SearchUsersRequest {
limit?: number
paginate?: boolean
}
export interface SearchUsersResponse {
data: User[]
hasNextPage?: boolean
nextPage?: string
}

export type FetchUsersResponse = User[]

export interface FindUserResponse extends User {}

export type LookupTenantUserResponse = PlatformUser

export interface CreateAdminUserRequest {
email: string
Expand Down Expand Up @@ -106,3 +134,28 @@ export interface AcceptUserInviteResponse {
export interface SyncUserRequest {
previousUser?: User
}

export interface DeleteUserResponse {
message: string
}

export interface CountUserResponse {
userCount: number
}

export interface CheckInviteResponse {
email: string
}

export type GetUserInvitesResponse = InviteWithCode[]

export interface UpdateInviteRequest extends Omit<Invite, "email"> {
email?: string
builder?: {
apps: string[]
}
apps: string[]
}
export interface UpdateInviteResponse extends Invite {}

export type LookupAccountHolderResponse = AccountMetadata | null
6 changes: 6 additions & 0 deletions packages/types/src/documents/global/devInfo.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { Document } from "../document"

export interface DevInfo extends Document {
userId: string
apiKey?: string
}
1 change: 1 addition & 0 deletions packages/types/src/documents/global/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ export * from "./templates"
export * from "./environmentVariables"
export * from "./auditLogs"
export * from "./apikeys"
export * from "./devInfo"
Loading

0 comments on commit 7008723

Please sign in to comment.