2022-02-22 16:06:08 +01:00
|
|
|
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",
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2022-03-10 16:53:23 +01:00
|
|
|
const applicationSchema = object(base, { required: ["name"] })
|
2022-02-28 12:29:48 +01:00
|
|
|
|
2022-03-01 19:35:08 +01:00
|
|
|
const applicationOutputSchema = object(
|
2022-02-24 19:15:13 +01:00
|
|
|
{
|
2022-02-28 12:29:48 +01:00
|
|
|
...base,
|
2022-03-01 19:35:08 +01:00
|
|
|
_id: {
|
|
|
|
description: "The ID of the app.",
|
|
|
|
type: "string",
|
|
|
|
},
|
2022-02-28 12:29:48 +01:00
|
|
|
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",
|
|
|
|
},
|
2022-02-24 16:13:14 +01:00
|
|
|
},
|
2022-02-28 12:29:48 +01:00
|
|
|
{
|
|
|
|
required: [
|
2022-03-01 19:35:08 +01:00
|
|
|
"_id",
|
2022-02-28 12:29:48 +01:00
|
|
|
"name",
|
|
|
|
"url",
|
|
|
|
"status",
|
|
|
|
"createdAt",
|
|
|
|
"updatedAt",
|
|
|
|
"version",
|
|
|
|
],
|
|
|
|
}
|
2022-02-24 19:15:13 +01:00
|
|
|
)
|
2022-02-22 16:06:08 +01:00
|
|
|
|
|
|
|
module.exports = new Resource()
|
|
|
|
.setExamples({
|
|
|
|
application: {
|
|
|
|
value: {
|
2022-03-01 15:37:35 +01:00
|
|
|
data: application,
|
2022-02-22 16:06:08 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
applications: {
|
|
|
|
value: {
|
2022-03-01 15:37:35 +01:00
|
|
|
data: [application],
|
2022-02-22 16:06:08 +01:00
|
|
|
},
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.setSchemas({
|
|
|
|
application: applicationSchema,
|
|
|
|
applicationOutput: object({
|
2022-03-01 19:35:08 +01:00
|
|
|
data: applicationOutputSchema,
|
2022-02-22 16:06:08 +01:00
|
|
|
}),
|
2022-03-08 18:42:26 +01:00
|
|
|
applicationSearch: object({
|
|
|
|
data: {
|
|
|
|
type: "array",
|
|
|
|
items: applicationOutputSchema,
|
|
|
|
},
|
|
|
|
}),
|
2022-02-22 16:06:08 +01:00
|
|
|
})
|