budibase/packages/server/specs/resources/application.js

102 lines
2.2 KiB
JavaScript
Raw Normal View History

const userResource = require("./user")
const { object } = require("./utils")
const Resource = require("./utils/Resource")
const application = {
_id: "app_metadata",
appId: "app_dev_957b12f943d348faa61db7e18e088d0f",
version: "1.0.58-alpha.0",
name: "App name",
url: "/app-url",
tenantId: "default",
updatedAt: "2022-02-22T13:00:54.035Z",
createdAt: "2022-02-11T18:02:26.961Z",
status: "development",
lockedBy: userResource.getExamples().user.value.user,
}
2022-02-28 12:29:48 +01:00
const base = {
name: {
description: "The name of the app.",
type: "string",
},
url: {
description:
"The URL by which the app is accessed, this must be URL encoded.",
type: "string",
},
}
const applicationSchema = object(base, { required: ["name", "url"] })
const applicationSchemaOutput = object(
2022-02-24 19:15:13 +01:00
{
2022-02-28 12:29:48 +01:00
...base,
status: {
description:
"The status of the app, stating it if is the development or published version.",
type: "string",
enum: ["development", "published"],
},
createdAt: {
description:
"States when the app was created, will be constant. Stored in ISO format.",
2022-02-24 19:15:13 +01:00
type: "string",
},
2022-02-28 12:29:48 +01:00
updatedAt: {
description:
"States the last time the app was updated - stored in ISO format.",
type: "string",
},
version: {
description:
"States the version of the Budibase client this app is currently based on.",
type: "string",
},
tenantId: {
description:
"In a multi-tenant environment this will state the tenant this app is within.",
type: "string",
},
lockedBy: {
description: "The user this app is currently being built by.",
type: "object",
},
appId: {
description: "The ID of the app.",
2022-02-24 19:15:13 +01:00
type: "string",
},
2022-02-24 16:13:14 +01:00
},
2022-02-28 12:29:48 +01:00
{
required: [
"name",
"url",
"status",
"createdAt",
"updatedAt",
"version",
"appId",
],
}
2022-02-24 19:15:13 +01:00
)
module.exports = new Resource()
.setExamples({
application: {
value: {
data: application,
},
},
applications: {
value: {
data: [application],
},
},
})
.setSchemas({
application: applicationSchema,
applicationOutput: object({
data: applicationSchemaOutput,
}),
})