Putting view mapping in place, updating openAPI spec.

This commit is contained in:
mike12345567 2024-10-30 14:08:03 +00:00
parent 3b14b9207b
commit dd0764eb60
9 changed files with 943 additions and 18 deletions

View File

@ -423,6 +423,62 @@
}, },
"metrics": { "metrics": {
"value": "# HELP budibase_os_uptime Time in seconds that the host operating system has been up.\n# TYPE budibase_os_uptime counter\nbudibase_os_uptime 54958\n# HELP budibase_os_free_mem Bytes of memory free for usage on the host operating system.\n# TYPE budibase_os_free_mem gauge\nbudibase_os_free_mem 804507648\n# HELP budibase_os_total_mem Total bytes of memory on the host operating system.\n# TYPE budibase_os_total_mem gauge\nbudibase_os_total_mem 16742404096\n# HELP budibase_os_used_mem Total bytes of memory in use on the host operating system.\n# TYPE budibase_os_used_mem gauge\nbudibase_os_used_mem 15937896448\n# HELP budibase_os_load1 Host operating system load average.\n# TYPE budibase_os_load1 gauge\nbudibase_os_load1 1.91\n# HELP budibase_os_load5 Host operating system load average.\n# TYPE budibase_os_load5 gauge\nbudibase_os_load5 1.75\n# HELP budibase_os_load15 Host operating system load average.\n# TYPE budibase_os_load15 gauge\nbudibase_os_load15 1.56\n# HELP budibase_tenant_user_count The number of users created.\n# TYPE budibase_tenant_user_count gauge\nbudibase_tenant_user_count 1\n# HELP budibase_tenant_app_count The number of apps created by a user.\n# TYPE budibase_tenant_app_count gauge\nbudibase_tenant_app_count 2\n# HELP budibase_tenant_production_app_count The number of apps a user has published.\n# TYPE budibase_tenant_production_app_count gauge\nbudibase_tenant_production_app_count 1\n# HELP budibase_tenant_dev_app_count The number of apps a user has unpublished in development.\n# TYPE budibase_tenant_dev_app_count gauge\nbudibase_tenant_dev_app_count 1\n# HELP budibase_tenant_db_count The number of couchdb databases including global tables such as _users.\n# TYPE budibase_tenant_db_count gauge\nbudibase_tenant_db_count 3\n# HELP budibase_quota_usage_apps The number of apps created.\n# TYPE budibase_quota_usage_apps gauge\nbudibase_quota_usage_apps 1\n# HELP budibase_quota_limit_apps The limit on the number of apps that can be created.\n# TYPE budibase_quota_limit_apps gauge\nbudibase_quota_limit_apps 9007199254740991\n# HELP budibase_quota_usage_rows The number of database rows used from the quota.\n# TYPE budibase_quota_usage_rows gauge\nbudibase_quota_usage_rows 0\n# HELP budibase_quota_limit_rows The limit on the number of rows that can be created.\n# TYPE budibase_quota_limit_rows gauge\nbudibase_quota_limit_rows 9007199254740991\n# HELP budibase_quota_usage_plugins The number of plugins in use.\n# TYPE budibase_quota_usage_plugins gauge\nbudibase_quota_usage_plugins 0\n# HELP budibase_quota_limit_plugins The limit on the number of plugins that can be created.\n# TYPE budibase_quota_limit_plugins gauge\nbudibase_quota_limit_plugins 9007199254740991\n# HELP budibase_quota_usage_user_groups The number of user groups created.\n# TYPE budibase_quota_usage_user_groups gauge\nbudibase_quota_usage_user_groups 0\n# HELP budibase_quota_limit_user_groups The limit on the number of user groups that can be created.\n# TYPE budibase_quota_limit_user_groups gauge\nbudibase_quota_limit_user_groups 9007199254740991\n# HELP budibase_quota_usage_queries The number of queries used in the current month.\n# TYPE budibase_quota_usage_queries gauge\nbudibase_quota_usage_queries 0\n# HELP budibase_quota_limit_queries The limit on the number of queries for the current month.\n# TYPE budibase_quota_limit_queries gauge\nbudibase_quota_limit_queries 9007199254740991\n# HELP budibase_quota_usage_automations The number of automations used in the current month.\n# TYPE budibase_quota_usage_automations gauge\nbudibase_quota_usage_automations 0\n# HELP budibase_quota_limit_automations The limit on the number of automations that can be created.\n# TYPE budibase_quota_limit_automations gauge\nbudibase_quota_limit_automations 9007199254740991\n" "value": "# HELP budibase_os_uptime Time in seconds that the host operating system has been up.\n# TYPE budibase_os_uptime counter\nbudibase_os_uptime 54958\n# HELP budibase_os_free_mem Bytes of memory free for usage on the host operating system.\n# TYPE budibase_os_free_mem gauge\nbudibase_os_free_mem 804507648\n# HELP budibase_os_total_mem Total bytes of memory on the host operating system.\n# TYPE budibase_os_total_mem gauge\nbudibase_os_total_mem 16742404096\n# HELP budibase_os_used_mem Total bytes of memory in use on the host operating system.\n# TYPE budibase_os_used_mem gauge\nbudibase_os_used_mem 15937896448\n# HELP budibase_os_load1 Host operating system load average.\n# TYPE budibase_os_load1 gauge\nbudibase_os_load1 1.91\n# HELP budibase_os_load5 Host operating system load average.\n# TYPE budibase_os_load5 gauge\nbudibase_os_load5 1.75\n# HELP budibase_os_load15 Host operating system load average.\n# TYPE budibase_os_load15 gauge\nbudibase_os_load15 1.56\n# HELP budibase_tenant_user_count The number of users created.\n# TYPE budibase_tenant_user_count gauge\nbudibase_tenant_user_count 1\n# HELP budibase_tenant_app_count The number of apps created by a user.\n# TYPE budibase_tenant_app_count gauge\nbudibase_tenant_app_count 2\n# HELP budibase_tenant_production_app_count The number of apps a user has published.\n# TYPE budibase_tenant_production_app_count gauge\nbudibase_tenant_production_app_count 1\n# HELP budibase_tenant_dev_app_count The number of apps a user has unpublished in development.\n# TYPE budibase_tenant_dev_app_count gauge\nbudibase_tenant_dev_app_count 1\n# HELP budibase_tenant_db_count The number of couchdb databases including global tables such as _users.\n# TYPE budibase_tenant_db_count gauge\nbudibase_tenant_db_count 3\n# HELP budibase_quota_usage_apps The number of apps created.\n# TYPE budibase_quota_usage_apps gauge\nbudibase_quota_usage_apps 1\n# HELP budibase_quota_limit_apps The limit on the number of apps that can be created.\n# TYPE budibase_quota_limit_apps gauge\nbudibase_quota_limit_apps 9007199254740991\n# HELP budibase_quota_usage_rows The number of database rows used from the quota.\n# TYPE budibase_quota_usage_rows gauge\nbudibase_quota_usage_rows 0\n# HELP budibase_quota_limit_rows The limit on the number of rows that can be created.\n# TYPE budibase_quota_limit_rows gauge\nbudibase_quota_limit_rows 9007199254740991\n# HELP budibase_quota_usage_plugins The number of plugins in use.\n# TYPE budibase_quota_usage_plugins gauge\nbudibase_quota_usage_plugins 0\n# HELP budibase_quota_limit_plugins The limit on the number of plugins that can be created.\n# TYPE budibase_quota_limit_plugins gauge\nbudibase_quota_limit_plugins 9007199254740991\n# HELP budibase_quota_usage_user_groups The number of user groups created.\n# TYPE budibase_quota_usage_user_groups gauge\nbudibase_quota_usage_user_groups 0\n# HELP budibase_quota_limit_user_groups The limit on the number of user groups that can be created.\n# TYPE budibase_quota_limit_user_groups gauge\nbudibase_quota_limit_user_groups 9007199254740991\n# HELP budibase_quota_usage_queries The number of queries used in the current month.\n# TYPE budibase_quota_usage_queries gauge\nbudibase_quota_usage_queries 0\n# HELP budibase_quota_limit_queries The limit on the number of queries for the current month.\n# TYPE budibase_quota_limit_queries gauge\nbudibase_quota_limit_queries 9007199254740991\n# HELP budibase_quota_usage_automations The number of automations used in the current month.\n# TYPE budibase_quota_usage_automations gauge\nbudibase_quota_usage_automations 0\n# HELP budibase_quota_limit_automations The limit on the number of automations that can be created.\n# TYPE budibase_quota_limit_automations gauge\nbudibase_quota_limit_automations 9007199254740991\n"
},
"view": {
"value": {
"data": {
"name": "peopleView",
"tableId": "ta_896a325f7e8147d2a2cda93c5d236511",
"schema": {
"name": {
"visible": true,
"readonly": false,
"order": 1,
"width": 300
},
"age": {
"visible": true,
"readonly": true,
"order": 2,
"width": 200
},
"salary": {
"visible": false,
"readonly": false
}
},
"primaryDisplay": "name"
}
}
},
"views": {
"value": {
"data": [
{
"name": "peopleView",
"tableId": "ta_896a325f7e8147d2a2cda93c5d236511",
"schema": {
"name": {
"visible": true,
"readonly": false,
"order": 1,
"width": 300
},
"age": {
"visible": true,
"readonly": true,
"order": 2,
"width": 200
},
"salary": {
"visible": false,
"readonly": false
}
},
"primaryDisplay": "name"
}
]
}
} }
}, },
"securitySchemes": { "securitySchemes": {
@ -831,8 +887,7 @@
"type": "string", "type": "string",
"enum": [ "enum": [
"static", "static",
"dynamic", "dynamic"
"ai"
], ],
"description": "Defines whether this is a static or dynamic formula." "description": "Defines whether this is a static or dynamic formula."
} }
@ -1042,8 +1097,7 @@
"type": "string", "type": "string",
"enum": [ "enum": [
"static", "static",
"dynamic", "dynamic"
"ai"
], ],
"description": "Defines whether this is a static or dynamic formula." "description": "Defines whether this is a static or dynamic formula."
} }
@ -1264,8 +1318,7 @@
"type": "string", "type": "string",
"enum": [ "enum": [
"static", "static",
"dynamic", "dynamic"
"ai"
], ],
"description": "Defines whether this is a static or dynamic formula." "description": "Defines whether this is a static or dynamic formula."
} }
@ -2024,6 +2077,161 @@
"required": [ "required": [
"data" "data"
] ]
},
"view": {
"description": "The view to be created/updated.",
"type": "object",
"required": [
"name",
"schema"
],
"properties": {
"name": {
"description": "The name of the view.",
"type": "string"
},
"primaryDisplay": {
"type": "string",
"description": "A column used to display rows from this view - usually used when rendered in tables."
},
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"visible": {
"type": "boolean",
"description": "Defines whether the column is visible or not - rows retrieved/updated through this view will not be able to access it."
},
"readonly": {
"type": "boolean",
"description": "When used in combination with 'visible: true' the column will be visible in row responses but cannot be updated."
},
"order": {
"type": "integer",
"description": "A number defining where the column shows up in tables, lowest being first."
},
"width": {
"type": "integer",
"description": "A width for the column, defined in pixels - this affects rendering in tables."
}
}
}
}
}
},
"viewOutput": {
"type": "object",
"properties": {
"data": {
"description": "The view to be created/updated.",
"type": "object",
"required": [
"name",
"schema",
"id"
],
"properties": {
"name": {
"description": "The name of the view.",
"type": "string"
},
"primaryDisplay": {
"type": "string",
"description": "A column used to display rows from this view - usually used when rendered in tables."
},
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"visible": {
"type": "boolean",
"description": "Defines whether the column is visible or not - rows retrieved/updated through this view will not be able to access it."
},
"readonly": {
"type": "boolean",
"description": "When used in combination with 'visible: true' the column will be visible in row responses but cannot be updated."
},
"order": {
"type": "integer",
"description": "A number defining where the column shows up in tables, lowest being first."
},
"width": {
"type": "integer",
"description": "A width for the column, defined in pixels - this affects rendering in tables."
}
}
}
},
"id": {
"description": "The ID of the view.",
"type": "string"
}
}
}
},
"required": [
"data"
]
},
"viewSearch": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"description": "The view to be created/updated.",
"type": "object",
"required": [
"name",
"schema",
"id"
],
"properties": {
"name": {
"description": "The name of the view.",
"type": "string"
},
"primaryDisplay": {
"type": "string",
"description": "A column used to display rows from this view - usually used when rendered in tables."
},
"schema": {
"type": "object",
"additionalProperties": {
"type": "object",
"properties": {
"visible": {
"type": "boolean",
"description": "Defines whether the column is visible or not - rows retrieved/updated through this view will not be able to access it."
},
"readonly": {
"type": "boolean",
"description": "When used in combination with 'visible: true' the column will be visible in row responses but cannot be updated."
},
"order": {
"type": "integer",
"description": "A number defining where the column shows up in tables, lowest being first."
},
"width": {
"type": "integer",
"description": "A width for the column, defined in pixels - this affects rendering in tables."
}
}
}
},
"id": {
"description": "The ID of the view.",
"type": "string"
}
}
}
}
},
"required": [
"data"
]
} }
} }
}, },
@ -3115,6 +3323,209 @@
} }
} }
} }
},
"/views": {
"post": {
"operationId": "viewCreate",
"summary": "Create a view",
"description": "Create a view, this can be against an internal or external table.",
"tags": [
"views"
],
"parameters": [
{
"$ref": "#/components/parameters/appId"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/view"
},
"examples": {
"view": {
"$ref": "#/components/examples/view"
}
}
}
}
},
"responses": {
"200": {
"description": "Returns the created view, including the ID which has been generated for it.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/viewOutput"
},
"examples": {
"view": {
"$ref": "#/components/examples/view"
}
}
}
}
}
}
}
},
"/views/{viewId}": {
"put": {
"operationId": "viewUpdate",
"summary": "Update a view",
"description": "Update a view, this can be against an internal or external table.",
"tags": [
"views"
],
"parameters": [
{
"$ref": "#/components/parameters/viewId"
},
{
"$ref": "#/components/parameters/appId"
}
],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/view"
},
"examples": {
"view": {
"$ref": "#/components/examples/view"
}
}
}
}
},
"responses": {
"200": {
"description": "Returns the updated view.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/viewOutput"
},
"examples": {
"view": {
"$ref": "#/components/examples/view"
}
}
}
}
}
}
},
"delete": {
"operationId": "viewDestroy",
"summary": "Delete a view",
"description": "Delete a view, this can be against an internal or external table.",
"tags": [
"views"
],
"parameters": [
{
"$ref": "#/components/parameters/viewId"
},
{
"$ref": "#/components/parameters/appId"
}
],
"responses": {
"200": {
"description": "Returns the deleted view.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/viewOutput"
},
"examples": {
"view": {
"$ref": "#/components/examples/view"
}
}
}
}
}
}
},
"get": {
"operationId": "viewGetById",
"summary": "Retrieve a view",
"description": "Lookup a view, this could be internal or external.",
"tags": [
"views"
],
"parameters": [
{
"$ref": "#/components/parameters/viewId"
},
{
"$ref": "#/components/parameters/appId"
}
],
"responses": {
"200": {
"description": "Returns the retrieved view.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/viewOutput"
},
"examples": {
"view": {
"$ref": "#/components/examples/view"
}
}
}
}
}
}
}
},
"/views/search": {
"post": {
"operationId": "viewSearch",
"summary": "Search for views",
"description": "Based on view properties (currently only name) search for views.",
"tags": [
"views"
],
"parameters": [
{
"$ref": "#/components/parameters/appId"
}
],
"requestBody": {
"required": true,
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/viewSearch"
}
}
}
},
"responses": {
"200": {
"description": "Returns the found views, based on the search parameters.",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/viewSearch"
},
"examples": {
"views": {
"$ref": "#/components/examples/views"
}
}
}
}
}
}
}
} }
}, },
"tags": [] "tags": []

View File

@ -442,6 +442,46 @@ components:
# TYPE budibase_quota_limit_automations gauge # TYPE budibase_quota_limit_automations gauge
budibase_quota_limit_automations 9007199254740991 budibase_quota_limit_automations 9007199254740991
view:
value:
data:
name: peopleView
tableId: ta_896a325f7e8147d2a2cda93c5d236511
schema:
name:
visible: true
readonly: false
order: 1
width: 300
age:
visible: true
readonly: true
order: 2
width: 200
salary:
visible: false
readonly: false
primaryDisplay: name
views:
value:
data:
- name: peopleView
tableId: ta_896a325f7e8147d2a2cda93c5d236511
schema:
name:
visible: true
readonly: false
order: 1
width: 300
age:
visible: true
readonly: true
order: 2
width: 200
salary:
visible: false
readonly: false
primaryDisplay: name
securitySchemes: securitySchemes:
ApiKeyAuth: ApiKeyAuth:
type: apiKey type: apiKey
@ -761,7 +801,6 @@ components:
enum: enum:
- static - static
- dynamic - dynamic
- ai
description: Defines whether this is a static or dynamic formula. description: Defines whether this is a static or dynamic formula.
- type: object - type: object
properties: properties:
@ -931,7 +970,6 @@ components:
enum: enum:
- static - static
- dynamic - dynamic
- ai
description: Defines whether this is a static or dynamic formula. description: Defines whether this is a static or dynamic formula.
- type: object - type: object
properties: properties:
@ -1108,7 +1146,6 @@ components:
enum: enum:
- static - static
- dynamic - dynamic
- ai
description: Defines whether this is a static or dynamic formula. description: Defines whether this is a static or dynamic formula.
- type: object - type: object
properties: properties:
@ -1704,6 +1741,134 @@ components:
- userIds - userIds
required: required:
- data - data
view:
description: The view to be created/updated.
type: object
required:
- name
- schema
properties:
name:
description: The name of the view.
type: string
primaryDisplay:
type: string
description: A column used to display rows from this view - usually used when
rendered in tables.
schema:
type: object
additionalProperties:
type: object
properties:
visible:
type: boolean
description: Defines whether the column is visible or not - rows
retrieved/updated through this view will not be able to access
it.
readonly:
type: boolean
description: "When used in combination with 'visible: true' the column will be
visible in row responses but cannot be updated."
order:
type: integer
description: A number defining where the column shows up in tables, lowest being
first.
width:
type: integer
description: A width for the column, defined in pixels - this affects rendering
in tables.
viewOutput:
type: object
properties:
data:
description: The view to be created/updated.
type: object
required:
- name
- schema
- id
properties:
name:
description: The name of the view.
type: string
primaryDisplay:
type: string
description: A column used to display rows from this view - usually used when
rendered in tables.
schema:
type: object
additionalProperties:
type: object
properties:
visible:
type: boolean
description: Defines whether the column is visible or not - rows
retrieved/updated through this view will not be able to
access it.
readonly:
type: boolean
description: "When used in combination with 'visible: true' the column will be
visible in row responses but cannot be updated."
order:
type: integer
description: A number defining where the column shows up in tables, lowest being
first.
width:
type: integer
description: A width for the column, defined in pixels - this affects rendering
in tables.
id:
description: The ID of the view.
type: string
required:
- data
viewSearch:
type: object
properties:
data:
type: array
items:
description: The view to be created/updated.
type: object
required:
- name
- schema
- id
properties:
name:
description: The name of the view.
type: string
primaryDisplay:
type: string
description: A column used to display rows from this view - usually used when
rendered in tables.
schema:
type: object
additionalProperties:
type: object
properties:
visible:
type: boolean
description: Defines whether the column is visible or not - rows
retrieved/updated through this view will not be able to
access it.
readonly:
type: boolean
description: "When used in combination with 'visible: true' the column will be
visible in row responses but cannot be updated."
order:
type: integer
description: A number defining where the column shows up in tables, lowest being
first.
width:
type: integer
description: A width for the column, defined in pixels - this affects rendering
in tables.
id:
description: The ID of the view.
type: string
required:
- data
security: security:
- ApiKeyAuth: [] - ApiKeyAuth: []
paths: paths:
@ -2359,4 +2524,123 @@ paths:
examples: examples:
users: users:
$ref: "#/components/examples/users" $ref: "#/components/examples/users"
/views:
post:
operationId: viewCreate
summary: Create a view
description: Create a view, this can be against an internal or external table.
tags:
- views
parameters:
- $ref: "#/components/parameters/appId"
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/view"
examples:
view:
$ref: "#/components/examples/view"
responses:
"200":
description: Returns the created view, including the ID which has been generated
for it.
content:
application/json:
schema:
$ref: "#/components/schemas/viewOutput"
examples:
view:
$ref: "#/components/examples/view"
"/views/{viewId}":
put:
operationId: viewUpdate
summary: Update a view
description: Update a view, this can be against an internal or external table.
tags:
- views
parameters:
- $ref: "#/components/parameters/viewId"
- $ref: "#/components/parameters/appId"
requestBody:
content:
application/json:
schema:
$ref: "#/components/schemas/view"
examples:
view:
$ref: "#/components/examples/view"
responses:
"200":
description: Returns the updated view.
content:
application/json:
schema:
$ref: "#/components/schemas/viewOutput"
examples:
view:
$ref: "#/components/examples/view"
delete:
operationId: viewDestroy
summary: Delete a view
description: Delete a view, this can be against an internal or external table.
tags:
- views
parameters:
- $ref: "#/components/parameters/viewId"
- $ref: "#/components/parameters/appId"
responses:
"200":
description: Returns the deleted view.
content:
application/json:
schema:
$ref: "#/components/schemas/viewOutput"
examples:
view:
$ref: "#/components/examples/view"
get:
operationId: viewGetById
summary: Retrieve a view
description: Lookup a view, this could be internal or external.
tags:
- views
parameters:
- $ref: "#/components/parameters/viewId"
- $ref: "#/components/parameters/appId"
responses:
"200":
description: Returns the retrieved view.
content:
application/json:
schema:
$ref: "#/components/schemas/viewOutput"
examples:
view:
$ref: "#/components/examples/view"
/views/search:
post:
operationId: viewSearch
summary: Search for views
description: Based on view properties (currently only name) search for views.
tags:
- views
parameters:
- $ref: "#/components/parameters/appId"
requestBody:
required: true
content:
application/json:
schema:
$ref: "#/components/schemas/viewSearch"
responses:
"200":
description: Returns the found views, based on the search parameters.
content:
application/json:
schema:
$ref: "#/components/schemas/viewSearch"
examples:
views:
$ref: "#/components/examples/views"
tags: [] tags: []

View File

@ -6,6 +6,7 @@ import user from "./user"
import metrics from "./metrics" import metrics from "./metrics"
import misc from "./misc" import misc from "./misc"
import roles from "./roles" import roles from "./roles"
import view from "./view"
export const examples = { export const examples = {
...application.getExamples(), ...application.getExamples(),
@ -15,6 +16,8 @@ export const examples = {
...user.getExamples(), ...user.getExamples(),
...misc.getExamples(), ...misc.getExamples(),
...metrics.getExamples(), ...metrics.getExamples(),
...roles.getExamples(),
...view.getExamples(),
} }
export const schemas = { export const schemas = {
@ -25,4 +28,5 @@ export const schemas = {
...user.getSchemas(), ...user.getSchemas(),
...misc.getSchemas(), ...misc.getSchemas(),
...roles.getSchemas(), ...roles.getSchemas(),
...view.getSchemas(),
} }

View File

@ -3,6 +3,7 @@ import applications from "./applications"
import users from "./users" import users from "./users"
import rows from "./rows" import rows from "./rows"
import queries from "./queries" import queries from "./queries"
import views from "./views"
export default { export default {
...tables, ...tables,
@ -10,4 +11,5 @@ export default {
...users, ...users,
...rows, ...rows,
...queries, ...queries,
...views,
} }

View File

@ -9,6 +9,9 @@ export type CreateApplicationParams = components["schemas"]["application"]
export type Table = components["schemas"]["tableOutput"]["data"] export type Table = components["schemas"]["tableOutput"]["data"]
export type CreateTableParams = components["schemas"]["table"] export type CreateTableParams = components["schemas"]["table"]
export type View = components["schemas"]["viewOutput"]["data"]
export type CreateViewParams = components["schemas"]["view"]
export type Row = components["schemas"]["rowOutput"]["data"] export type Row = components["schemas"]["rowOutput"]["data"]
export type RowSearch = components["schemas"]["searchOutput"] export type RowSearch = components["schemas"]["searchOutput"]
export type CreateRowParams = components["schemas"]["row"] export type CreateRowParams = components["schemas"]["row"]

View File

@ -0,0 +1,26 @@
import { View } from "./types"
function view(body: any): View {
return {
id: body.id,
name: body.name,
schema: body.schema,
primaryDisplay: body.primaryDisplay,
}
}
function mapView(ctx: any): { data: View } {
return {
data: view(ctx.body),
}
}
function mapViews(ctx: any): { data: View[] } {
const tables = ctx.body.map((body: any) => view(body))
return { data: tables }
}
export default {
mapView,
mapViews,
}

View File

@ -18,8 +18,7 @@ function fixView(view: ViewV2, params?: { viewId: string }) {
export async function search(ctx: UserCtx, next: Next) { export async function search(ctx: UserCtx, next: Next) {
const { name } = ctx.request.body const { name } = ctx.request.body
// TODO: need a view search endpoint await controller.v2.fetch(ctx)
// await controller.v2.fetch(ctx)
ctx.body = stringSearch(ctx.body, name) ctx.body = stringSearch(ctx.body, name)
await next() await next()
} }

View File

@ -1,9 +1,10 @@
import { Ctx } from "@budibase/types" import { Ctx } from "@budibase/types"
import mapping from "../../../controllers/public/mapping" import mapping from "../../../controllers/public/mapping"
enum Resources { enum Resource {
APPLICATION = "applications", APPLICATION = "applications",
TABLES = "tables", TABLES = "tables",
VIEWS = "views",
ROWS = "rows", ROWS = "rows",
USERS = "users", USERS = "users",
QUERIES = "queries", QUERIES = "queries",
@ -15,7 +16,7 @@ function isAttachment(ctx: Ctx) {
} }
function isArrayResponse(ctx: Ctx) { function isArrayResponse(ctx: Ctx) {
return ctx.url.endsWith(Resources.SEARCH) || Array.isArray(ctx.body) return ctx.url.endsWith(Resource.SEARCH) || Array.isArray(ctx.body)
} }
function noResponse(ctx: Ctx) { function noResponse(ctx: Ctx) {
@ -38,6 +39,14 @@ function processTables(ctx: Ctx) {
} }
} }
function processViews(ctx: Ctx) {
if (isArrayResponse(ctx)) {
return mapping.mapViews(ctx)
} else {
return mapping.mapView(ctx)
}
}
function processRows(ctx: Ctx) { function processRows(ctx: Ctx) {
if (isArrayResponse(ctx)) { if (isArrayResponse(ctx)) {
return mapping.mapRowSearch(ctx) return mapping.mapRowSearch(ctx)
@ -71,20 +80,27 @@ export default async (ctx: Ctx, next: any) => {
let body = {} let body = {}
switch (urlParts[0]) { switch (urlParts[0]) {
case Resources.APPLICATION: case Resource.APPLICATION:
body = processApplications(ctx) body = processApplications(ctx)
break break
case Resources.TABLES: case Resource.TABLES:
if (urlParts[2] === Resources.ROWS) { if (urlParts[2] === Resource.ROWS) {
body = processRows(ctx) body = processRows(ctx)
} else { } else {
body = processTables(ctx) body = processTables(ctx)
} }
break break
case Resources.USERS: case Resource.VIEWS:
if (urlParts[2] === Resource.ROWS) {
body = processRows(ctx)
} else {
body = processViews(ctx)
}
break
case Resource.USERS:
body = processUsers(ctx) body = processUsers(ctx)
break break
case Resources.QUERIES: case Resource.QUERIES:
body = processQueries(ctx) body = processQueries(ctx)
break break
} }

View File

@ -93,6 +93,22 @@ export interface paths {
/** Based on user properties (currently only name) search for users. */ /** Based on user properties (currently only name) search for users. */
post: operations["userSearch"]; post: operations["userSearch"];
}; };
"/views": {
/** Create a view, this can be against an internal or external table. */
post: operations["viewCreate"];
};
"/views/{viewId}": {
/** Lookup a view, this could be internal or external. */
get: operations["viewGetById"];
/** Update a view, this can be against an internal or external table. */
put: operations["viewUpdate"];
/** Delete a view, this can be against an internal or external table. */
delete: operations["viewDestroy"];
};
"/views/search": {
/** Based on view properties (currently only name) search for views. */
post: operations["viewSearch"];
};
} }
export interface components { export interface components {
@ -813,6 +829,70 @@ export interface components {
userIds: string[]; userIds: string[];
}; };
}; };
/** @description The view to be created/updated. */
view: {
/** @description The name of the view. */
name: string;
/** @description A column used to display rows from this view - usually used when rendered in tables. */
primaryDisplay?: string;
schema: {
[key: string]: {
/** @description Defines whether the column is visible or not - rows retrieved/updated through this view will not be able to access it. */
visible?: boolean;
/** @description When used in combination with 'visible: true' the column will be visible in row responses but cannot be updated. */
readonly?: boolean;
/** @description A number defining where the column shows up in tables, lowest being first. */
order?: number;
/** @description A width for the column, defined in pixels - this affects rendering in tables. */
width?: number;
};
};
};
viewOutput: {
/** @description The view to be created/updated. */
data: {
/** @description The name of the view. */
name: string;
/** @description A column used to display rows from this view - usually used when rendered in tables. */
primaryDisplay?: string;
schema: {
[key: string]: {
/** @description Defines whether the column is visible or not - rows retrieved/updated through this view will not be able to access it. */
visible?: boolean;
/** @description When used in combination with 'visible: true' the column will be visible in row responses but cannot be updated. */
readonly?: boolean;
/** @description A number defining where the column shows up in tables, lowest being first. */
order?: number;
/** @description A width for the column, defined in pixels - this affects rendering in tables. */
width?: number;
};
};
/** @description The ID of the view. */
id: string;
};
};
viewSearch: {
data: {
/** @description The name of the view. */
name: string;
/** @description A column used to display rows from this view - usually used when rendered in tables. */
primaryDisplay?: string;
schema: {
[key: string]: {
/** @description Defines whether the column is visible or not - rows retrieved/updated through this view will not be able to access it. */
visible?: boolean;
/** @description When used in combination with 'visible: true' the column will be visible in row responses but cannot be updated. */
readonly?: boolean;
/** @description A number defining where the column shows up in tables, lowest being first. */
order?: number;
/** @description A width for the column, defined in pixels - this affects rendering in tables. */
width?: number;
};
};
/** @description The ID of the view. */
id: string;
}[];
};
}; };
parameters: { parameters: {
/** @description The ID of the table which this request is targeting. */ /** @description The ID of the table which this request is targeting. */
@ -1409,6 +1489,106 @@ export interface operations {
}; };
}; };
}; };
/** Create a view, this can be against an internal or external table. */
viewCreate: {
parameters: {
header: {
/** The ID of the app which this request is targeting. */
"x-budibase-app-id": components["parameters"]["appId"];
};
};
responses: {
/** Returns the created view, including the ID which has been generated for it. */
200: {
content: {
"application/json": components["schemas"]["viewOutput"];
};
};
};
requestBody: {
content: {
"application/json": components["schemas"]["view"];
};
};
};
/** Lookup a view, this could be internal or external. */
viewGetById: {
parameters: {
header: {
/** The ID of the app which this request is targeting. */
"x-budibase-app-id": components["parameters"]["appId"];
};
};
responses: {
/** Returns the retrieved view. */
200: {
content: {
"application/json": components["schemas"]["viewOutput"];
};
};
};
};
/** Update a view, this can be against an internal or external table. */
viewUpdate: {
parameters: {
header: {
/** The ID of the app which this request is targeting. */
"x-budibase-app-id": components["parameters"]["appId"];
};
};
responses: {
/** Returns the updated view. */
200: {
content: {
"application/json": components["schemas"]["viewOutput"];
};
};
};
requestBody: {
content: {
"application/json": components["schemas"]["view"];
};
};
};
/** Delete a view, this can be against an internal or external table. */
viewDestroy: {
parameters: {
header: {
/** The ID of the app which this request is targeting. */
"x-budibase-app-id": components["parameters"]["appId"];
};
};
responses: {
/** Returns the deleted view. */
200: {
content: {
"application/json": components["schemas"]["viewOutput"];
};
};
};
};
/** Based on view properties (currently only name) search for views. */
viewSearch: {
parameters: {
header: {
/** The ID of the app which this request is targeting. */
"x-budibase-app-id": components["parameters"]["appId"];
};
};
responses: {
/** Returns the found views, based on the search parameters. */
200: {
content: {
"application/json": components["schemas"]["viewSearch"];
};
};
};
requestBody: {
content: {
"application/json": components["schemas"]["viewSearch"];
};
};
};
} }
export interface external {} export interface external {}