@platformatic/sql-openapi 3.39.0 → 3.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +1 -1
- package/lib/errors.js +5 -0
- package/lib/shared.js +4 -0
- package/package.json +5 -5
package/index.d.ts
CHANGED
|
@@ -24,7 +24,7 @@ export default plugin
|
|
|
24
24
|
/**
|
|
25
25
|
* All the errors thrown by the plugin.
|
|
26
26
|
*/
|
|
27
|
-
export
|
|
27
|
+
export namespace errors {
|
|
28
28
|
export const UnableToCreateTheRouteForTheReverseRelationshipError: () => FastifyError
|
|
29
29
|
export const UnableToCreateTheRouteForThePKColRelationshipError: () => FastifyError
|
|
30
30
|
export const UnableToParseCursorStrError: () => FastifyError
|
package/lib/errors.js
CHANGED
|
@@ -25,3 +25,8 @@ export const PrimaryKeyNotIncludedInOrderByInCursorPaginationError = createError
|
|
|
25
25
|
'At least one primary key must be included in orderBy clause in case of cursor pagination',
|
|
26
26
|
400
|
|
27
27
|
)
|
|
28
|
+
export const UnknownFieldError = createError(
|
|
29
|
+
`${ERROR_PREFIX}_UNKNOWN_FIELD`,
|
|
30
|
+
'Unknown field "%s" in where.or',
|
|
31
|
+
400
|
|
32
|
+
)
|
package/lib/shared.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { mapSQLTypeToOpenAPIType } from '@platformatic/sql-json-schema-mapper'
|
|
2
2
|
import { buildCursorUtils } from './cursor.js'
|
|
3
|
+
import * as errors from './errors.js'
|
|
3
4
|
|
|
4
5
|
export function generateArgs (entity, ignore) {
|
|
5
6
|
const sortedEntityFields = Object.keys(entity.fields).sort()
|
|
@@ -149,6 +150,9 @@ export function rootEntityRoutes (
|
|
|
149
150
|
.map(v => v.split('='))
|
|
150
151
|
.reduce((acc, [k, v]) => {
|
|
151
152
|
const [field, modifier] = k.split('.')
|
|
153
|
+
if (!entity.camelCasedFields[field]) {
|
|
154
|
+
throw new errors.UnknownFieldError(field)
|
|
155
|
+
}
|
|
152
156
|
if (modifier === 'in' || modifier === 'nin') {
|
|
153
157
|
// TODO handle escaping of ,
|
|
154
158
|
v = v.split(',')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@platformatic/sql-openapi",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.41.0",
|
|
4
4
|
"description": "Map a SQL database to OpenAPI, for Fastify",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"typescript": "^5.5.4",
|
|
27
27
|
"why-is-node-running": "^2.2.2",
|
|
28
28
|
"yaml": "^2.4.1",
|
|
29
|
-
"@platformatic/sql-mapper": "3.
|
|
29
|
+
"@platformatic/sql-mapper": "3.41.0"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"@fastify/deepmerge": "^2.0.0",
|
|
@@ -36,9 +36,9 @@
|
|
|
36
36
|
"camelcase": "^6.3.0",
|
|
37
37
|
"fastify-plugin": "^5.0.0",
|
|
38
38
|
"inflected": "^2.1.0",
|
|
39
|
-
"@platformatic/foundation": "3.
|
|
40
|
-
"@platformatic/scalar-theme": "3.
|
|
41
|
-
"@platformatic/sql-json-schema-mapper": "3.
|
|
39
|
+
"@platformatic/foundation": "3.41.0",
|
|
40
|
+
"@platformatic/scalar-theme": "3.41.0",
|
|
41
|
+
"@platformatic/sql-json-schema-mapper": "3.41.0"
|
|
42
42
|
},
|
|
43
43
|
"tsd": {
|
|
44
44
|
"directory": "test/types"
|