forked from tsai/budibase
27 changed files with 228 additions and 40 deletions
@ -1,8 +0,0 @@ |
|||
import { events } from "@budibase/backend-core" |
|||
import { Row } from "@budibase/types" |
|||
|
|||
export const backfill = async (appDb: any) => { |
|||
const rows: Row[] = [] |
|||
const count = rows.length |
|||
events.rows.created(count) |
|||
} |
|||
@ -1 +1,22 @@ |
|||
// SCREEN_CREATED = "screen:created",
|
|||
import { events, db } from "@budibase/backend-core" |
|||
import { getScreenParams } from "../../../../db/utils" |
|||
import { Screen } from "@budibase/types" |
|||
|
|||
const getScreens = async (appDb: any): Promise<Screen[]> => { |
|||
const response = await appDb.allDocs( |
|||
getScreenParams(null, { |
|||
include_docs: true, |
|||
}) |
|||
) |
|||
return response.rows.map((row: any) => row.doc) |
|||
} |
|||
|
|||
export const backfill = async (appDb: any) => { |
|||
if (db.isDevAppID(appDb.name)) { |
|||
const screens = await getScreens(appDb) |
|||
|
|||
for (const screen of screens) { |
|||
events.screen.created(screen) |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ -1,3 +0,0 @@ |
|||
// VIEW_CREATED = "view:created",
|
|||
// VIEW_FILTER_CREATED = "view:filter:created",
|
|||
// VIEW_CALCULATION_CREATED = "view:calculation:created",
|
|||
@ -0,0 +1,14 @@ |
|||
import { events, db } from "@budibase/backend-core" |
|||
import { Row } from "@budibase/types" |
|||
import { getUniqueRows } from "../../../../utilities/usageQuota/rows" |
|||
|
|||
// Rows is a special circumstance where we get rows across all apps
|
|||
// therefore migration is performed at the global level
|
|||
|
|||
export const backfill = async () => { |
|||
const allApps = await db.getAllApps({ all: true }) |
|||
const appIds = allApps ? allApps.map((app: { appId: any }) => app.appId) : [] |
|||
const rows: Row[] = await getUniqueRows(appIds) |
|||
const rowCount = rows ? rows.length : 0 |
|||
events.rows.created(rowCount) |
|||
} |
|||
@ -1 +1,3 @@ |
|||
export interface Datasource {} |
|||
import { Document } from "./document" |
|||
|
|||
export interface Datasource extends Document {} |
|||
|
|||
@ -1,6 +1,6 @@ |
|||
export interface Document { |
|||
_id: string |
|||
_id?: string |
|||
_rev?: string |
|||
createdAt: string |
|||
updatedAt: string |
|||
createdAt?: string |
|||
updatedAt?: string |
|||
} |
|||
|
|||
@ -1 +1,3 @@ |
|||
export interface Layout {} |
|||
import { Document } from "./document" |
|||
|
|||
export interface Layout extends Document {} |
|||
|
|||
@ -1,3 +1,44 @@ |
|||
export interface Query { |
|||
import { Document } from "./document" |
|||
|
|||
export interface Query extends Document { |
|||
datasourceId: string |
|||
name: string |
|||
parameters: QueryParameter[] |
|||
fields: RestQueryFields | any |
|||
transformer: string | null |
|||
schema: any |
|||
readable: boolean |
|||
queryVerb: string |
|||
} |
|||
|
|||
export interface QueryParameter { |
|||
name: string |
|||
default: string |
|||
} |
|||
|
|||
export interface RestQueryFields { |
|||
path: string |
|||
queryString?: string |
|||
headers: { [key: string]: any } |
|||
disabledHeaders: { [key: string]: any } |
|||
requestBody: any |
|||
bodyType: string |
|||
json: object |
|||
method: string |
|||
authConfigId: string |
|||
pagination: PaginationConfig | null |
|||
paginationValues: PaginationValues | null |
|||
} |
|||
|
|||
export interface PaginationConfig { |
|||
type: string |
|||
location: string |
|||
pageParam: string |
|||
sizeParam: string | null |
|||
responseParam: string | null |
|||
} |
|||
|
|||
export interface PaginationValues { |
|||
page: string | number | null |
|||
limit: number | null |
|||
} |
|||
|
|||
@ -1 +1,3 @@ |
|||
export interface Row {} |
|||
import { Document } from "./document" |
|||
|
|||
export interface Row extends Document {} |
|||
|
|||
@ -1 +1,3 @@ |
|||
export interface Screen {} |
|||
import { Document } from "./document" |
|||
|
|||
export interface Screen extends Document {} |
|||
|
|||
@ -1 +1,6 @@ |
|||
export interface Table {} |
|||
import { Document } from "./document" |
|||
import { View } from "./view" |
|||
|
|||
export interface Table extends Document { |
|||
views: { [key: string]: View } |
|||
} |
|||
|
|||
@ -1,3 +1,5 @@ |
|||
export interface UserMetadata { |
|||
import { Document } from "./document" |
|||
|
|||
export interface UserMetadata extends Document { |
|||
roleId: string |
|||
} |
|||
|
|||
@ -1 +1,43 @@ |
|||
export interface View {} |
|||
export interface View { |
|||
name: string |
|||
tableId: string |
|||
field?: string |
|||
filters: ViewFilter[] |
|||
schema: ViewSchema |
|||
calculation?: ViewCalculation |
|||
} |
|||
|
|||
export type ViewSchema = ViewCountOrSumSchema | ViewStatisticsSchema |
|||
|
|||
export interface ViewCountOrSumSchema { |
|||
field: string |
|||
value: string |
|||
} |
|||
|
|||
/** |
|||
e.g: |
|||
"min": { |
|||
"type": "number" |
|||
}, |
|||
"max": { |
|||
"type": "number" |
|||
} |
|||
*/ |
|||
export interface ViewStatisticsSchema { |
|||
[key: string]: { |
|||
type: string |
|||
} |
|||
} |
|||
|
|||
export interface ViewFilter { |
|||
value: any |
|||
condition: string |
|||
key: string |
|||
conjunction?: string |
|||
} |
|||
|
|||
export enum ViewCalculation { |
|||
SUM = "sum", |
|||
COUNT = "count", |
|||
STATISTICS = "stats", |
|||
} |
|||
|
|||
Loading…
Reference in new issue