Updating summaries, adding descriptions, wrapping responses with generic wrapper 'data'.

This commit is contained in:
mike12345567 2022-03-01 14:37:35 +00:00
parent c958e93aed
commit 8680faa3da
20 changed files with 239 additions and 293 deletions

View File

@ -75,7 +75,7 @@
"examples": {
"application": {
"value": {
"application": {
"data": {
"_id": "app_metadata",
"appId": "app_dev_957b12f943d348faa61db7e18e088d0f",
"version": "1.0.58-alpha.0",
@ -84,38 +84,13 @@
"tenantId": "default",
"updatedAt": "2022-02-22T13:00:54.035Z",
"createdAt": "2022-02-11T18:02:26.961Z",
"status": "development",
"lockedBy": {
"_id": "us_693a73206518477283a8d5ae31103252",
"email": "test@test.com",
"roles": {
"app_957b12f943d348faa61db7e18e088d0f": "BASIC"
},
"builder": {
"global": false
},
"admin": {
"global": true
},
"tenantId": "default",
"status": "active",
"budibaseAccess": true,
"csrfToken": "9c70291d-7137-48f9-9166-99ab5473a3d4",
"userId": "us_693a73206518477283a8d5ae31103252",
"roleId": "ADMIN",
"role": {
"_id": "ADMIN",
"name": "Admin",
"permissionId": "admin",
"inherits": "POWER"
}
}
"status": "development"
}
}
},
"applications": {
"value": {
"applications": [
"data": [
{
"_id": "app_metadata",
"appId": "app_dev_957b12f943d348faa61db7e18e088d0f",
@ -125,32 +100,7 @@
"tenantId": "default",
"updatedAt": "2022-02-22T13:00:54.035Z",
"createdAt": "2022-02-11T18:02:26.961Z",
"status": "development",
"lockedBy": {
"_id": "us_693a73206518477283a8d5ae31103252",
"email": "test@test.com",
"roles": {
"app_957b12f943d348faa61db7e18e088d0f": "BASIC"
},
"builder": {
"global": false
},
"admin": {
"global": true
},
"tenantId": "default",
"status": "active",
"budibaseAccess": true,
"csrfToken": "9c70291d-7137-48f9-9166-99ab5473a3d4",
"userId": "us_693a73206518477283a8d5ae31103252",
"roleId": "ADMIN",
"role": {
"_id": "ADMIN",
"name": "Admin",
"permissionId": "admin",
"inherits": "POWER"
}
}
"status": "development"
}
]
}
@ -169,7 +119,7 @@
},
"row": {
"value": {
"row": {
"data": {
"_id": "ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4",
"type": "row",
"tableId": "ta_5b1649e42a5b41dea4ef7742a36a7a70",
@ -186,7 +136,7 @@
},
"enrichedRow": {
"value": {
"row": {
"data": {
"_id": "ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4",
"name": "eg",
"tableId": "ta_5b1649e42a5b41dea4ef7742a36a7a70",
@ -209,7 +159,7 @@
},
"rows": {
"value": {
"rows": [
"data": [
{
"_id": "ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4",
"type": "row",
@ -230,7 +180,7 @@
},
"table": {
"value": {
"table": {
"data": {
"_id": "ta_5b1649e42a5b41dea4ef7742a36a7a70",
"name": "People",
"schema": {
@ -255,7 +205,7 @@
},
"tables": {
"value": {
"tables": [
"data": [
{
"_id": "ta_5b1649e42a5b41dea4ef7742a36a7a70",
"name": "People",
@ -282,7 +232,7 @@
},
"query": {
"value": {
"query": {
"data": {
"_id": "query_datasource_plus_4d8be0c506b9465daf4bf84d890fdab6_454854487c574d45bc4029b1e153219e",
"datasourceId": "datasource_plus_4d8be0c506b9465daf4bf84d890fdab6",
"parameters": [],
@ -320,7 +270,7 @@
},
"queries": {
"value": {
"queries": [
"data": [
{
"_id": "query_datasource_plus_4d8be0c506b9465daf4bf84d890fdab6_454854487c574d45bc4029b1e153219e",
"datasourceId": "datasource_plus_4d8be0c506b9465daf4bf84d890fdab6",
@ -396,7 +346,7 @@
},
"user": {
"value": {
"user": {
"data": {
"_id": "us_693a73206518477283a8d5ae31103252",
"email": "test@test.com",
"roles": {
@ -425,7 +375,7 @@
},
"users": {
"value": {
"users": [
"data": [
{
"_id": "us_693a73206518477283a8d5ae31103252",
"email": "test@test.com",
@ -484,7 +434,7 @@
"applicationOutput": {
"type": "object",
"properties": {
"application": {
"data": {
"type": "object",
"properties": {
"name": {
@ -540,7 +490,7 @@
}
},
"required": [
"application"
"data"
]
},
"row": {
@ -579,7 +529,7 @@
"rowOutput": {
"type": "object",
"properties": {
"row": {
"data": {
"description": "The row to be created/updated, based on the table schema.",
"type": "object",
"properties": {
@ -614,7 +564,7 @@
}
},
"required": [
"row"
"data"
]
},
"table": {
@ -819,7 +769,7 @@
"tableOutput": {
"type": "object",
"properties": {
"table": {
"data": {
"description": "The table to be created/updated.",
"type": "object",
"required": [
@ -1020,7 +970,7 @@
}
},
"required": [
"table"
"data"
]
},
"query": {
@ -1113,7 +1063,7 @@
"userOutput": {
"type": "object",
"properties": {
"user": {
"data": {
"type": "object",
"properties": {
"email": {
@ -1179,7 +1129,7 @@
}
},
"required": [
"user"
"data"
]
},
"nameSearch": {
@ -1204,7 +1154,7 @@
"paths": {
"/applications": {
"post": {
"summary": "Create a new application.",
"summary": "Create an application",
"tags": [
"applications"
],
@ -1244,7 +1194,7 @@
},
"/applications/{appId}": {
"put": {
"summary": "Update an existing application by its ID.",
"summary": "Update an application",
"tags": [
"applications"
],
@ -1282,7 +1232,7 @@
}
},
"delete": {
"summary": "Delete an existing application by its ID.",
"summary": "Delete an application",
"tags": [
"applications"
],
@ -1310,7 +1260,7 @@
}
},
"get": {
"summary": "Retrieve a single application by its ID.",
"summary": "Retrieve an application",
"tags": [
"applications"
],
@ -1340,7 +1290,8 @@
},
"/applications/search": {
"post": {
"summary": "Search for an application based on its app name.",
"summary": "Search for applications",
"description": "Based on application properties (currently only name) search for applications.",
"tags": [
"applications"
],
@ -1367,10 +1318,10 @@
"schema": {
"type": "object",
"required": [
"applications"
"data"
],
"properties": {
"applications": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/application"
@ -1391,10 +1342,8 @@
},
"/queries/{queryId}": {
"post": {
"summary": "Execute a query and retrieve its response.",
"tags": [
"queries"
],
"summary": "Execute a query",
"description": "Queries which have been created within a Budibase app can be executed using this, - queries",
"parameters": [
{
"$ref": "#/components/parameters/queryId"
@ -1455,7 +1404,8 @@
},
"/queries/search": {
"post": {
"summary": "Search for a query based on its name.",
"summary": "Search for queries",
"description": "Based on query properties (currently only name) search for queries.",
"tags": [
"queries"
],
@ -1482,10 +1432,10 @@
"schema": {
"type": "object",
"required": [
"queries"
"data"
],
"properties": {
"queries": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/query"
@ -1506,7 +1456,8 @@
},
"/tables/{tableId}/rows": {
"post": {
"summary": "Creates a new row within a specified table.",
"summary": "Create a row",
"description": "Creates a row within the specified table.",
"tags": [
"rows"
],
@ -1554,7 +1505,8 @@
},
"/tables/{tableId}/rows/{rowId}": {
"put": {
"summary": "Update a single row within a specified table.",
"summary": "Update a row",
"description": "Updates a row within the specified table.",
"tags": [
"rows"
],
@ -1603,7 +1555,8 @@
}
},
"delete": {
"summary": "Delete a single row from the specified table.",
"summary": "Delete a row",
"description": "Deletes a row within the specified table.",
"tags": [
"rows"
],
@ -1637,7 +1590,7 @@
}
},
"get": {
"summary": "Get a single row from the specified table.",
"summary": "Retrieve a row",
"description": "This gets a single row, it will be enriched with the full related rows, rather than the squashed \"primaryDisplay\" format returned by the search endpoint.",
"tags": [
"rows"
@ -1674,7 +1627,7 @@
},
"/tables/{tableId}/rows/search": {
"post": {
"summary": "Used to search for rows within a table.",
"summary": "Search for rows",
"tags": [
"rows"
],
@ -1808,10 +1761,10 @@
"schema": {
"type": "object",
"required": [
"rows"
"data"
],
"properties": {
"rows": {
"data": {
"description": "An array of rows, these will each contain an _id field which can be used to update or delete them.",
"type": "array",
"items": {
@ -1848,7 +1801,8 @@
},
"/tables": {
"post": {
"summary": "Create a new table.",
"summary": "Create a table",
"description": "Create a table, this could be internal or external.",
"tags": [
"tables"
],
@ -1892,7 +1846,8 @@
},
"/tables/{tableId}": {
"put": {
"summary": "Update the specified table.",
"summary": "Update a table",
"description": "Update a table, this could be internal or external.",
"tags": [
"tables"
],
@ -1937,7 +1892,8 @@
}
},
"delete": {
"summary": "Delete a single table and all of its data.",
"summary": "Delete a table",
"description": "Delete a table, this could be internal or external.",
"tags": [
"tables"
],
@ -1968,7 +1924,8 @@
}
},
"get": {
"summary": "Gets a single table by its ID.",
"summary": "Retrieve a table",
"description": "Lookup a table, this could be internal or external.",
"tags": [
"tables"
],
@ -2001,7 +1958,8 @@
},
"/tables/search": {
"post": {
"summary": "Search internal and external tables based on their name.",
"summary": "Search for tables",
"description": "Based on table properties (currently only name) search for tables. This could be an internal or an external table.",
"tags": [
"tables"
],
@ -2028,10 +1986,10 @@
"schema": {
"type": "object",
"required": [
"tables"
"data"
],
"properties": {
"tables": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/table"
@ -2052,7 +2010,7 @@
},
"/users": {
"post": {
"summary": "Create a new user in the Budibase portal.",
"summary": "Create a user",
"tags": [
"users"
],
@ -2087,7 +2045,7 @@
},
"/users/{userId}": {
"put": {
"summary": "Update an existing user by their ID.",
"summary": "Update a user",
"tags": [
"users"
],
@ -2125,7 +2083,7 @@
}
},
"delete": {
"summary": "Delete an existing user by their ID.",
"summary": "Delete a user",
"tags": [
"users"
],
@ -2153,7 +2111,7 @@
}
},
"get": {
"summary": "Retrieve a single user by their ID.",
"summary": "Retrieve a user",
"tags": [
"users"
],
@ -2183,7 +2141,8 @@
},
"/users/search": {
"post": {
"summary": "Search for a user based on their email/username.",
"summary": "Search for users",
"description": "Based on user properties (currently only name) search for users.",
"tags": [
"users"
],
@ -2205,10 +2164,10 @@
"schema": {
"type": "object",
"required": [
"users"
"data"
],
"properties": {
"users": {
"data": {
"type": "array",
"items": {
"$ref": "#/components/schemas/user"

View File

@ -55,7 +55,7 @@ components:
examples:
application:
value:
application:
data:
_id: app_metadata
appId: app_dev_957b12f943d348faa61db7e18e088d0f
version: 1.0.58-alpha.0
@ -65,29 +65,9 @@ components:
updatedAt: 2022-02-22T13:00:54.035Z
createdAt: 2022-02-11T18:02:26.961Z
status: development
lockedBy:
_id: us_693a73206518477283a8d5ae31103252
email: test@test.com
roles:
app_957b12f943d348faa61db7e18e088d0f: BASIC
builder:
global: false
admin:
global: true
tenantId: default
status: active
budibaseAccess: true
csrfToken: 9c70291d-7137-48f9-9166-99ab5473a3d4
userId: us_693a73206518477283a8d5ae31103252
roleId: ADMIN
role:
_id: ADMIN
name: Admin
permissionId: admin
inherits: POWER
applications:
value:
applications:
data:
- _id: app_metadata
appId: app_dev_957b12f943d348faa61db7e18e088d0f
version: 1.0.58-alpha.0
@ -97,26 +77,6 @@ components:
updatedAt: 2022-02-22T13:00:54.035Z
createdAt: 2022-02-11T18:02:26.961Z
status: development
lockedBy:
_id: us_693a73206518477283a8d5ae31103252
email: test@test.com
roles:
app_957b12f943d348faa61db7e18e088d0f: BASIC
builder:
global: false
admin:
global: true
tenantId: default
status: active
budibaseAccess: true
csrfToken: 9c70291d-7137-48f9-9166-99ab5473a3d4
userId: us_693a73206518477283a8d5ae31103252
roleId: ADMIN
role:
_id: ADMIN
name: Admin
permissionId: admin
inherits: POWER
inputRow:
value:
_id: ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4
@ -128,7 +88,7 @@ components:
- ro_ta_...
row:
value:
row:
data:
_id: ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4
type: row
tableId: ta_5b1649e42a5b41dea4ef7742a36a7a70
@ -139,7 +99,7 @@ components:
_id: ro_ta_...
enrichedRow:
value:
row:
data:
_id: ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4
name: eg
tableId: ta_5b1649e42a5b41dea4ef7742a36a7a70
@ -153,7 +113,7 @@ components:
primaryDisplay: eg
rows:
value:
rows:
data:
- _id: ro_ta_5b1649e42a5b41dea4ef7742a36a7a70_e6dc7e38cf1343b2b56760265201cda4
type: row
tableId: ta_5b1649e42a5b41dea4ef7742a36a7a70
@ -166,7 +126,7 @@ components:
bookmark: 10
table:
value:
table:
data:
_id: ta_5b1649e42a5b41dea4ef7742a36a7a70
name: People
schema:
@ -184,7 +144,7 @@ components:
relationshipType: many-to-many
tables:
value:
tables:
data:
- _id: ta_5b1649e42a5b41dea4ef7742a36a7a70
name: People
schema:
@ -202,7 +162,7 @@ components:
relationshipType: many-to-many
query:
value:
query:
data:
_id: query_datasource_plus_4d8be0c506b9465daf4bf84d890fdab6_454854487c574d45bc4029b1e153219e
datasourceId: datasource_plus_4d8be0c506b9465daf4bf84d890fdab6
parameters: []
@ -230,7 +190,7 @@ components:
readable: true
queries:
value:
queries:
data:
- _id: query_datasource_plus_4d8be0c506b9465daf4bf84d890fdab6_454854487c574d45bc4029b1e153219e
datasourceId: datasource_plus_4d8be0c506b9465daf4bf84d890fdab6
parameters: []
@ -280,7 +240,7 @@ components:
city: Dublin
user:
value:
user:
data:
_id: us_693a73206518477283a8d5ae31103252
email: test@test.com
roles:
@ -302,7 +262,7 @@ components:
inherits: POWER
users:
value:
users:
data:
- _id: us_693a73206518477283a8d5ae31103252
email: test@test.com
roles:
@ -345,7 +305,7 @@ components:
applicationOutput:
type: object
properties:
application:
data:
type: object
properties:
name:
@ -391,7 +351,7 @@ components:
- version
- appId
required:
- application
- data
row:
description: The row to be created/updated, based on the table schema.
type: object
@ -412,7 +372,7 @@ components:
rowOutput:
type: object
properties:
row:
data:
description: The row to be created/updated, based on the table schema.
type: object
properties:
@ -430,7 +390,7 @@ components:
- type: array
- type: boolean
required:
- row
- data
table:
description: The table to be created/updated.
type: object
@ -592,7 +552,7 @@ components:
tableOutput:
type: object
properties:
table:
data:
description: The table to be created/updated.
type: object
required:
@ -751,7 +711,7 @@ components:
type: boolean
description: Defines whether the column is automatically generated.
required:
- table
- data
query:
description: The query body must contain the required parameters for the query,
this depends on query type, setup and bindings.
@ -818,7 +778,7 @@ components:
userOutput:
type: object
properties:
user:
data:
type: object
properties:
email:
@ -871,7 +831,7 @@ components:
- email
- roles
required:
- user
- data
nameSearch:
type: object
properties:
@ -886,7 +846,7 @@ security:
paths:
/applications:
post:
summary: Create a new application.
summary: Create an application
tags:
- applications
parameters:
@ -909,7 +869,7 @@ paths:
$ref: "#/components/examples/application"
"/applications/{appId}":
put:
summary: Update an existing application by its ID.
summary: Update an application
tags:
- applications
parameters:
@ -931,7 +891,7 @@ paths:
application:
$ref: "#/components/examples/application"
delete:
summary: Delete an existing application by its ID.
summary: Delete an application
tags:
- applications
parameters:
@ -947,7 +907,7 @@ paths:
application:
$ref: "#/components/examples/application"
get:
summary: Retrieve a single application by its ID.
summary: Retrieve an application
tags:
- applications
parameters:
@ -964,7 +924,9 @@ paths:
$ref: "#/components/examples/application"
/applications/search:
post:
summary: Search for an application based on its app name.
summary: Search for applications
description: Based on application properties (currently only name) search for
applications.
tags:
- applications
parameters:
@ -984,9 +946,9 @@ paths:
schema:
type: object
required:
- applications
- data
properties:
applications:
data:
type: array
items:
$ref: "#/components/schemas/application"
@ -995,9 +957,9 @@ paths:
$ref: "#/components/examples/applications"
"/queries/{queryId}":
post:
summary: Execute a query and retrieve its response.
tags:
- queries
summary: Execute a query
description: Queries which have been created within a Budibase app can be
executed using this, - queries
parameters:
- $ref: "#/components/parameters/queryId"
- $ref: "#/components/parameters/appId"
@ -1036,7 +998,8 @@ paths:
$ref: "#/components/examples/sqlResponse"
/queries/search:
post:
summary: Search for a query based on its name.
summary: Search for queries
description: Based on query properties (currently only name) search for queries.
tags:
- queries
parameters:
@ -1055,9 +1018,9 @@ paths:
schema:
type: object
required:
- queries
- data
properties:
queries:
data:
type: array
items:
$ref: "#/components/schemas/query"
@ -1066,7 +1029,8 @@ paths:
$ref: "#/components/examples/queries"
"/tables/{tableId}/rows":
post:
summary: Creates a new row within a specified table.
summary: Create a row
description: Creates a row within the specified table.
tags:
- rows
parameters:
@ -1095,7 +1059,8 @@ paths:
$ref: "#/components/examples/row"
"/tables/{tableId}/rows/{rowId}":
put:
summary: Update a single row within a specified table.
summary: Update a row
description: Updates a row within the specified table.
tags:
- rows
parameters:
@ -1123,7 +1088,8 @@ paths:
row:
$ref: "#/components/examples/row"
delete:
summary: Delete a single row from the specified table.
summary: Delete a row
description: Deletes a row within the specified table.
tags:
- rows
parameters:
@ -1142,7 +1108,7 @@ paths:
row:
$ref: "#/components/examples/row"
get:
summary: Get a single row from the specified table.
summary: Retrieve a row
description: This gets a single row, it will be enriched with the full related
rows, rather than the squashed "primaryDisplay" format returned by the
search endpoint.
@ -1164,7 +1130,7 @@ paths:
$ref: "#/components/examples/enrichedRow"
"/tables/{tableId}/rows/search":
post:
summary: Used to search for rows within a table.
summary: Search for rows
tags:
- rows
parameters:
@ -1269,9 +1235,9 @@ paths:
schema:
type: object
required:
- rows
- data
properties:
rows:
data:
description: An array of rows, these will each contain an _id field which can be
used to update or delete them.
type: array
@ -1291,7 +1257,8 @@ paths:
$ref: "#/components/examples/rows"
/tables:
post:
summary: Create a new table.
summary: Create a table
description: Create a table, this could be internal or external.
tags:
- tables
parameters:
@ -1317,7 +1284,8 @@ paths:
$ref: "#/components/examples/table"
"/tables/{tableId}":
put:
summary: Update the specified table.
summary: Update a table
description: Update a table, this could be internal or external.
tags:
- tables
parameters:
@ -1342,7 +1310,8 @@ paths:
table:
$ref: "#/components/examples/table"
delete:
summary: Delete a single table and all of its data.
summary: Delete a table
description: Delete a table, this could be internal or external.
tags:
- tables
parameters:
@ -1359,7 +1328,8 @@ paths:
table:
$ref: "#/components/examples/table"
get:
summary: Gets a single table by its ID.
summary: Retrieve a table
description: Lookup a table, this could be internal or external.
tags:
- tables
parameters:
@ -1377,7 +1347,9 @@ paths:
$ref: "#/components/examples/table"
/tables/search:
post:
summary: Search internal and external tables based on their name.
summary: Search for tables
description: Based on table properties (currently only name) search for tables.
This could be an internal or an external table.
tags:
- tables
parameters:
@ -1396,9 +1368,9 @@ paths:
schema:
type: object
required:
- tables
- data
properties:
tables:
data:
type: array
items:
$ref: "#/components/schemas/table"
@ -1407,7 +1379,7 @@ paths:
$ref: "#/components/examples/tables"
/users:
post:
summary: Create a new user in the Budibase portal.
summary: Create a user
tags:
- users
requestBody:
@ -1428,7 +1400,7 @@ paths:
$ref: "#/components/examples/user"
"/users/{userId}":
put:
summary: Update an existing user by their ID.
summary: Update a user
tags:
- users
parameters:
@ -1450,7 +1422,7 @@ paths:
user:
$ref: "#/components/examples/user"
delete:
summary: Delete an existing user by their ID.
summary: Delete a user
tags:
- users
parameters:
@ -1466,7 +1438,7 @@ paths:
user:
$ref: "#/components/examples/user"
get:
summary: Retrieve a single user by their ID.
summary: Retrieve a user
tags:
- users
parameters:
@ -1483,7 +1455,8 @@ paths:
$ref: "#/components/examples/user"
/users/search:
post:
summary: Search for a user based on their email/username.
summary: Search for users
description: Based on user properties (currently only name) search for users.
tags:
- users
requestBody:
@ -1500,9 +1473,9 @@ paths:
schema:
type: object
required:
- users
- data
properties:
users:
data:
type: array
items:
$ref: "#/components/schemas/user"

View File

@ -84,18 +84,18 @@ module.exports = new Resource()
.setExamples({
application: {
value: {
application: application,
data: application,
},
},
applications: {
value: {
applications: [application],
data: [application],
},
},
})
.setSchemas({
application: applicationSchema,
applicationOutput: object({
application: applicationSchemaOutput,
data: applicationSchemaOutput,
}),
})

View File

@ -92,12 +92,12 @@ module.exports = new Resource()
.setExamples({
query: {
value: {
query: query,
data: query,
},
},
queries: {
value: {
queries: [query],
data: [query],
},
},
restResponse,

View File

@ -75,17 +75,17 @@ module.exports = new Resource()
},
row: {
value: {
row: row,
data: row,
},
},
enrichedRow: {
value: {
row: enrichedRow,
data: enrichedRow,
},
},
rows: {
value: {
rows: [row],
data: [row],
hasNextPage: true,
bookmark: 10,
},
@ -94,6 +94,6 @@ module.exports = new Resource()
.setSchemas({
row: rowSchema,
rowOutput: object({
row: rowSchema,
data: rowSchema,
}),
})

View File

@ -162,18 +162,18 @@ module.exports = new Resource()
.setExamples({
table: {
value: {
table: table,
data: table,
},
},
tables: {
value: {
tables: [table],
data: [table],
},
},
})
.setSchemas({
table: tableSchema,
tableOutput: object({
table: tableSchema,
data: tableSchema,
}),
})

View File

@ -97,18 +97,18 @@ module.exports = new Resource()
.setExamples({
user: {
value: {
user: user,
data: user,
},
},
users: {
value: {
users: [user],
data: [user],
},
},
})
.setSchemas({
user: userSchema,
userOutput: object({
user: userSchema,
data: userSchema,
}),
})

View File

@ -1,6 +1,6 @@
const { getAllApps } = require("@budibase/backend-core/db")
const { updateAppId } = require("@budibase/backend-core/context")
import { search as stringSearch } from "./utils"
import { search as stringSearch, wrapResponse } from "./utils"
import { default as controller } from "../application"
import { Application } from "../../../definitions/common"
@ -19,14 +19,15 @@ async function setResponseApp(ctx: any) {
ctx.params = { appId: ctx.body.appId }
}
await controller.fetchAppPackage(ctx)
// for now remove everything else
wrapResponse(ctx, (input: any) => input.application)
}
export async function search(ctx: any) {
const { name } = ctx.request.body
const apps = await getAllApps({ all: true })
ctx.body = {
applications: stringSearch(apps, name),
}
ctx.body = stringSearch(apps, name)
wrapResponse(ctx)
}
export async function create(ctx: any) {

View File

@ -1,16 +1,16 @@
import { search as stringSearch } from "./utils"
import { search as stringSearch, wrapResponse } from "./utils"
import { default as queryController } from "../query"
export async function search(ctx: any) {
await queryController.fetch(ctx)
const { name } = ctx.request.body
ctx.body = {
queries: stringSearch(ctx.body, name),
}
ctx.body = stringSearch(ctx.body, name)
wrapResponse(ctx)
}
export async function execute(ctx: any) {
await queryController.executeV2(ctx)
wrapResponse(ctx)
}
export default {

View File

@ -1,5 +1,5 @@
import { default as rowController } from "../row"
import { addRev } from "./utils"
import { addRev, wrapResponse } from "./utils"
import { Row } from "../../../definitions/common"
// makes sure that the user doesn't need to pass in the type, tableId or _id params for
@ -36,23 +36,25 @@ export async function search(ctx: any) {
query,
}
await rowController.search(ctx)
ctx.body.data = ctx.body.rows
delete ctx.body.rows
}
export async function create(ctx: any) {
ctx.request.body = fixRow(ctx.request.body, ctx.params)
await rowController.save(ctx)
ctx.body = { row: ctx.body }
wrapResponse(ctx)
}
export async function read(ctx: any) {
await rowController.fetchEnrichedRow(ctx)
ctx.body = { row: ctx.body }
wrapResponse(ctx)
}
export async function update(ctx: any) {
ctx.request.body = await addRev(fixRow(ctx.request.body, ctx.params.tableId))
await rowController.save(ctx)
ctx.body = { row: ctx.body }
wrapResponse(ctx)
}
export async function destroy(ctx: any) {
@ -63,7 +65,7 @@ export async function destroy(ctx: any) {
await rowController.destroy(ctx)
// destroy controller doesn't currently return the row as the body, need to adjust this
// in the public API to be correct
ctx.body = { row: ctx.row }
wrapResponse(ctx)
}
export default {

View File

@ -1,4 +1,4 @@
import { search as stringSearch, addRev } from "./utils"
import { search as stringSearch, addRev, wrapResponse } from "./utils"
import { default as controller } from "../table"
import { Table } from "../../../definitions/common"
@ -15,19 +15,18 @@ function fixTable(table: Table, params: any) {
export async function search(ctx: any) {
const { name } = ctx.request.body
await controller.fetch(ctx)
ctx.body = {
tables: stringSearch(ctx.body, name),
}
ctx.body = stringSearch(ctx.body, name)
wrapResponse(ctx)
}
export async function create(ctx: any) {
await controller.save(ctx)
ctx.body = { table: ctx.body }
wrapResponse(ctx)
}
export async function read(ctx: any) {
await controller.find(ctx)
ctx.body = { table: ctx.body }
wrapResponse(ctx)
}
export async function update(ctx: any) {
@ -36,12 +35,13 @@ export async function update(ctx: any) {
ctx.params.tableId
)
await controller.save(ctx)
ctx.body = { table: ctx.body }
wrapResponse(ctx)
}
export async function destroy(ctx: any) {
await controller.destroy(ctx)
ctx.body = { table: ctx.table }
ctx.body = ctx.table
wrapResponse(ctx)
}
export default {

View File

@ -1,10 +1,11 @@
import {
allGlobalUsers,
deleteGlobalUser,
readGlobalUser,
saveGlobalUser,
deleteGlobalUser,
} from "../../../utilities/workerRequests"
import { search as stringSearch } from "./utils"
import { search as stringSearch, wrapResponse } from "./utils"
const { getProdAppID } = require("@budibase/backend-core/db")
function fixUser(ctx: any) {
@ -37,29 +38,21 @@ function getUser(ctx: any, userId?: string) {
}
export async function search(ctx: any) {
try {
const { name } = ctx.request.body
const users = await allGlobalUsers(ctx)
ctx.body = {
users: stringSearch(users, name, "email"),
}
} catch (err) {
console.log(err)
}
const { name } = ctx.request.body
const users = await allGlobalUsers(ctx)
ctx.body = stringSearch(users, name, "email")
wrapResponse(ctx)
}
export async function create(ctx: any) {
const response = await saveGlobalUser(fixUser(ctx))
ctx.body = {
user: await getUser(ctx, response._id),
}
ctx.body = await getUser(ctx, response._id)
wrapResponse(ctx)
}
export async function read(ctx: any) {
const response = await readGlobalUser(ctx)
ctx.body = {
user: response,
}
ctx.body = await readGlobalUser(ctx)
wrapResponse(ctx)
}
export async function update(ctx: any) {
@ -69,17 +62,15 @@ export async function update(ctx: any) {
_rev: user._rev,
}
const response = await saveGlobalUser(fixUser(ctx))
ctx.body = {
user: await getUser(ctx, response._id),
}
ctx.body = await getUser(ctx, response._id)
wrapResponse(ctx)
}
export async function destroy(ctx: any) {
const user = await getUser(ctx)
await deleteGlobalUser(ctx)
ctx.body = {
user,
}
ctx.body = user
wrapResponse(ctx)
}
export default {

View File

@ -36,3 +36,11 @@ export function search(docs: any[], value: any, key = "name") {
}
return filtered
}
export function wrapResponse(ctx: any, map?: (input: any) => object) {
let data = ctx.body
if (map) {
data = map(data)
}
ctx.body = { data }
}

View File

@ -9,7 +9,7 @@ const read = [],
* @openapi
* /applications:
* post:
* summary: Create a new application.
* summary: Create an application
* tags:
* - applications
* parameters:
@ -41,7 +41,7 @@ write.push(
* @openapi
* /applications/{appId}:
* put:
* summary: Update an existing application by its ID.
* summary: Update an application
* tags:
* - applications
* parameters:
@ -73,7 +73,7 @@ write.push(
* @openapi
* /applications/{appId}:
* delete:
* summary: Delete an existing application by its ID.
* summary: Delete an application
* tags:
* - applications
* parameters:
@ -95,7 +95,7 @@ write.push(new Endpoint("delete", "/applications/:appId", controller.destroy))
* @openapi
* /applications/{appId}:
* get:
* summary: Retrieve a single application by its ID.
* summary: Retrieve an application
* tags:
* - applications
* parameters:
@ -117,7 +117,8 @@ read.push(new Endpoint("get", "/applications/:appId", controller.read))
* @openapi
* /applications/search:
* post:
* summary: Search for an application based on its app name.
* summary: Search for applications
* description: Based on application properties (currently only name) search for applications.
* tags:
* - applications
* parameters:
@ -136,9 +137,9 @@ read.push(new Endpoint("get", "/applications/:appId", controller.read))
* schema:
* type: object
* required:
* - applications
* - data
* properties:
* applications:
* data:
* type: array
* items:
* $ref: '#/components/schemas/application'

View File

@ -9,8 +9,8 @@ const read = [],
* @openapi
* /queries/{queryId}:
* post:
* summary: Execute a query and retrieve its response.
* tags:
* summary: Execute a query
* description: Queries which have been created within a Budibase app can be executed using this,
* - queries
* parameters:
* - $ref: '#/components/parameters/queryId'
@ -56,7 +56,8 @@ write.push(new Endpoint("post", "/queries/:queryId", controller.execute))
* @openapi
* /queries/search:
* post:
* summary: Search for a query based on its name.
* summary: Search for queries
* description: Based on query properties (currently only name) search for queries.
* tags:
* - queries
* parameters:
@ -75,9 +76,9 @@ write.push(new Endpoint("post", "/queries/:queryId", controller.execute))
* schema:
* type: object
* required:
* - queries
* - data
* properties:
* queries:
* data:
* type: array
* items:
* $ref: '#/components/schemas/query'

View File

@ -9,7 +9,8 @@ const read = [],
* @openapi
* /tables/{tableId}/rows:
* post:
* summary: Creates a new row within a specified table.
* summary: Create a row
* description: Creates a row within the specified table.
* tags:
* - rows
* parameters:
@ -42,7 +43,8 @@ write.push(new Endpoint("post", "/tables/:tableId/rows", controller.create))
* @openapi
* /tables/{tableId}/rows/{rowId}:
* put:
* summary: Update a single row within a specified table.
* summary: Update a row
* description: Updates a row within the specified table.
* tags:
* - rows
* parameters:
@ -77,7 +79,8 @@ write.push(
* @openapi
* /tables/{tableId}/rows/{rowId}:
* delete:
* summary: Delete a single row from the specified table.
* summary: Delete a row
* description: Deletes a row within the specified table.
* tags:
* - rows
* parameters:
@ -103,7 +106,7 @@ write.push(
* @openapi
* /tables/{tableId}/rows/{rowId}:
* get:
* summary: Get a single row from the specified table.
* summary: Retrieve a row
* description: This gets a single row, it will be enriched with the full related rows, rather than
* the squashed "primaryDisplay" format returned by the search endpoint.
* tags:
@ -129,7 +132,7 @@ read.push(new Endpoint("get", "/tables/:tableId/rows/:rowId", controller.read))
* @openapi
* /tables/{tableId}/rows/search:
* post:
* summary: Used to search for rows within a table.
* summary: Search for rows
* tags:
* - rows
* parameters:
@ -225,9 +228,9 @@ read.push(new Endpoint("get", "/tables/:tableId/rows/:rowId", controller.read))
* schema:
* type: object
* required:
* - rows
* - data
* properties:
* rows:
* data:
* description: An array of rows, these will each contain an _id field which can be used
* to update or delete them.
* type: array

View File

@ -9,7 +9,8 @@ const read = [],
* @openapi
* /tables:
* post:
* summary: Create a new table.
* summary: Create a table
* description: Create a table, this could be internal or external.
* tags:
* - tables
* parameters:
@ -44,7 +45,8 @@ write.push(
* @openapi
* /tables/{tableId}:
* put:
* summary: Update the specified table.
* summary: Update a table
* description: Update a table, this could be internal or external.
* tags:
* - tables
* parameters:
@ -79,7 +81,8 @@ write.push(
* @openapi
* /tables/{tableId}:
* delete:
* summary: Delete a single table and all of its data.
* summary: Delete a table
* description: Delete a table, this could be internal or external.
* tags:
* - tables
* parameters:
@ -102,7 +105,8 @@ write.push(new Endpoint("delete", "/tables/:tableId", controller.destroy))
* @openapi
* /tables/{tableId}:
* get:
* summary: Gets a single table by its ID.
* summary: Retrieve a table
* description: Lookup a table, this could be internal or external.
* tags:
* - tables
* parameters:
@ -125,7 +129,9 @@ read.push(new Endpoint("get", "/tables/:tableId", controller.read))
* @openapi
* /tables/search:
* post:
* summary: Search internal and external tables based on their name.
* summary: Search for tables
* description: Based on table properties (currently only name) search for tables. This could be
* an internal or an external table.
* tags:
* - tables
* parameters:
@ -144,9 +150,9 @@ read.push(new Endpoint("get", "/tables/:tableId", controller.read))
* schema:
* type: object
* required:
* - tables
* - data
* properties:
* tables:
* data:
* type: array
* items:
* $ref: '#/components/schemas/table'

View File

@ -125,7 +125,7 @@ describe("check the rows endpoints", () => {
name: "test row",
})
expect(res).toSatisfyApiSpec()
row = res.body.row
row = res.body.data
})
it("should allow updating a row", async () => {

View File

@ -9,7 +9,7 @@ const read = [],
* @openapi
* /users:
* post:
* summary: Create a new user in the Budibase portal.
* summary: Create a user
* tags:
* - users
* requestBody:
@ -35,7 +35,7 @@ write.push(new Endpoint("post", "/users", controller.create))
* @openapi
* /users/{userId}:
* put:
* summary: Update an existing user by their ID.
* summary: Update a user
* tags:
* - users
* parameters:
@ -63,7 +63,7 @@ write.push(new Endpoint("put", "/users/:userId", controller.update))
* @openapi
* /users/{userId}:
* delete:
* summary: Delete an existing user by their ID.
* summary: Delete a user
* tags:
* - users
* parameters:
@ -85,7 +85,7 @@ write.push(new Endpoint("delete", "/users/:userId", controller.destroy))
* @openapi
* /users/{userId}:
* get:
* summary: Retrieve a single user by their ID.
* summary: Retrieve a user
* tags:
* - users
* parameters:
@ -107,7 +107,8 @@ read.push(new Endpoint("get", "/users/:userId", controller.read))
* @openapi
* /users/search:
* post:
* summary: Search for a user based on their email/username.
* summary: Search for users
* description: Based on user properties (currently only name) search for users.
* tags:
* - users
* requestBody:
@ -124,9 +125,9 @@ read.push(new Endpoint("get", "/users/:userId", controller.read))
* schema:
* type: object
* required:
* - users
* - data
* properties:
* users:
* data:
* type: array
* items:
* $ref: '#/components/schemas/user'

View File