Add document and api types
This commit is contained in:
parent
12a0af23c2
commit
89e057802b
|
@ -0,0 +1,15 @@
|
|||
import { AppBackupTrigger } from "../../../documents"
|
||||
|
||||
export interface SearchAppBackupsRequest {
|
||||
trigger: AppBackupTrigger
|
||||
startDate: string
|
||||
endDate: string
|
||||
}
|
||||
|
||||
export interface CreateAppBackupRequest {
|
||||
name: string
|
||||
}
|
||||
|
||||
export interface UpdateAppBackupRequest {
|
||||
name: string
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export * from "./backup"
|
|
@ -1,3 +1,5 @@
|
|||
export * from "./analytics"
|
||||
export * from "./user"
|
||||
export * from "./errors"
|
||||
export * from "./schedule"
|
||||
export * from "./app"
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import {
|
||||
ScheduleMetadata,
|
||||
ScheduleRepeatPeriod,
|
||||
ScheduleType,
|
||||
} from "../../documents"
|
||||
|
||||
export interface CreateScheduleRequest {
|
||||
type: ScheduleType
|
||||
name: string
|
||||
startDate: string
|
||||
repeat: ScheduleRepeatPeriod
|
||||
metadata: ScheduleMetadata
|
||||
}
|
||||
|
||||
export interface UpdateScheduleRequest extends CreateScheduleRequest {}
|
|
@ -44,3 +44,10 @@ export interface InviteUsersResponse {
|
|||
successful: { email: string }[]
|
||||
unsuccessful: { email: string; reason: string }[]
|
||||
}
|
||||
|
||||
export interface SearchUsersRequest {
|
||||
page?: string
|
||||
email?: string
|
||||
appId?: string
|
||||
userIds?: string[]
|
||||
}
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
import { Document } from "../document"
|
||||
|
||||
export enum AppBackupTrigger {
|
||||
PUBLISH = "publish",
|
||||
MANUAL = "manual",
|
||||
SCHEDULED = "scheduled",
|
||||
}
|
||||
|
||||
export interface AppBackupContents {
|
||||
datasources: string[]
|
||||
screens: string[]
|
||||
automations: string[]
|
||||
}
|
||||
|
||||
export interface AppBackup extends Document {
|
||||
trigger: AppBackupTrigger
|
||||
name: string
|
||||
date: string
|
||||
userId: string
|
||||
contents: AppBackupContents
|
||||
}
|
|
@ -10,3 +10,4 @@ export * from "./view"
|
|||
export * from "../document"
|
||||
export * from "./row"
|
||||
export * from "./user"
|
||||
export * from "./backup"
|
||||
|
|
|
@ -3,4 +3,4 @@ export * from "./user"
|
|||
export * from "./userGroup"
|
||||
export * from "./plugin"
|
||||
export * from "./quotas"
|
||||
export * from "./schedules"
|
||||
export * from "./schedule"
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
import { Document } from "../document"
|
||||
|
||||
export enum ScheduleType {
|
||||
APP_BACKUP = "app_backup",
|
||||
}
|
||||
|
||||
export enum ScheduleRepeatPeriod {
|
||||
DAILY = "daily",
|
||||
WEEKLY = "weekly",
|
||||
MONTHLY = "monthly",
|
||||
}
|
||||
|
||||
export interface Schedule extends Document {
|
||||
type: ScheduleType
|
||||
name: string
|
||||
startDate: string
|
||||
repeat: ScheduleRepeatPeriod
|
||||
metadata: ScheduleMetadata
|
||||
}
|
||||
|
||||
export type ScheduleMetadata = AppBackupScheduleMetadata
|
||||
|
||||
export const isAppBackupMetadata = (
|
||||
type: ScheduleType,
|
||||
metadata: ScheduleMetadata
|
||||
): metadata is AppBackupScheduleMetadata => {
|
||||
return type === ScheduleType.APP_BACKUP
|
||||
}
|
||||
|
||||
export interface AppBackupScheduleMetadata {
|
||||
apps: string[]
|
||||
}
|
|
@ -1,9 +0,0 @@
|
|||
export enum ScheduleType {
|
||||
APP_BACKUP = "app_backup",
|
||||
}
|
||||
|
||||
export enum ScheduleRepeatPeriod {
|
||||
DAILY = "daily",
|
||||
WEEKLY = "weekly",
|
||||
MONTHLY = "monthly",
|
||||
}
|
|
@ -7,6 +7,7 @@ import {
|
|||
CloudAccount,
|
||||
InviteUserRequest,
|
||||
InviteUsersRequest,
|
||||
SearchUsersRequest,
|
||||
User,
|
||||
} from "@budibase/types"
|
||||
import {
|
||||
|
@ -144,7 +145,8 @@ export const destroy = async (ctx: any) => {
|
|||
}
|
||||
|
||||
export const search = async (ctx: any) => {
|
||||
const paginated = await sdk.users.paginatedUsers(ctx.request.body)
|
||||
const body = ctx.request.body as SearchUsersRequest
|
||||
const paginated = await sdk.users.paginatedUsers(body)
|
||||
// user hashed password shouldn't ever be returned
|
||||
for (let user of paginated.data) {
|
||||
if (user) {
|
||||
|
|
|
@ -27,6 +27,7 @@ import {
|
|||
MigrationType,
|
||||
PlatformUserByEmail,
|
||||
RowResponse,
|
||||
SearchUsersRequest,
|
||||
User,
|
||||
} from "@budibase/types"
|
||||
import { sendEmail } from "../../utilities/email"
|
||||
|
@ -56,7 +57,8 @@ export const paginatedUsers = async ({
|
|||
page,
|
||||
email,
|
||||
appId,
|
||||
}: { page?: string; email?: string; appId?: string } = {}) => {
|
||||
userIds,
|
||||
}: SearchUsersRequest = {}) => {
|
||||
const db = tenancy.getGlobalDB()
|
||||
// get one extra document, to have the next page
|
||||
const opts: any = {
|
||||
|
@ -77,6 +79,9 @@ export const paginatedUsers = async ({
|
|||
} else if (email) {
|
||||
userList = await usersCore.searchGlobalUsersByEmail(email, opts)
|
||||
property = "email"
|
||||
}
|
||||
if (userIds) {
|
||||
// TODO: search users by userIds
|
||||
} else {
|
||||
// no search, query allDocs
|
||||
const response = await db.allDocs(dbUtils.getGlobalUserParams(null, opts))
|
||||
|
|
Loading…
Reference in New Issue