@lowdefy/connection-knex 4.0.0-alpha.1 → 4.0.0-alpha.12
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/dist/connections/Knex/Knex.js +3 -4
- package/dist/connections/Knex/KnexBuilder/KnexBuilder.js +9 -3
- package/dist/connections/Knex/KnexBuilder/schema.js +47 -0
- package/dist/connections/Knex/KnexRaw/KnexRaw.js +9 -3
- package/dist/connections/Knex/KnexRaw/schema.js +49 -0
- package/dist/connections/Knex/schema.js +63 -0
- package/dist/{connections/Knex/KnexRaw/index.js → connections.js} +2 -11
- package/dist/{connections/Knex/KnexBuilder/index.js → types.js} +7 -11
- package/package.json +15 -14
- package/dist/connections/Knex/KnexBuilder/KnexBuilderSchema.json +0 -28
- package/dist/connections/Knex/KnexRaw/KnexRawSchema.json +0 -28
- package/dist/connections/Knex/KnexSchema.json +0 -43
- package/dist/index.js +0 -7
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -14,10 +14,9 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import KnexBuilder from './KnexBuilder/KnexBuilder.js';
|
|
16
16
|
import KnexRaw from './KnexRaw/KnexRaw.js';
|
|
17
|
+
import schema from './schema.js';
|
|
17
18
|
export default {
|
|
18
|
-
|
|
19
|
-
schema: 'connections/Knex/KnexSchema.json'
|
|
20
|
-
},
|
|
19
|
+
schema,
|
|
21
20
|
requests: {
|
|
22
21
|
KnexBuilder,
|
|
23
22
|
KnexRaw
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -14,7 +14,8 @@
|
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import knex from 'knex';
|
|
16
16
|
import { type } from '@lowdefy/helpers';
|
|
17
|
-
|
|
17
|
+
import schema from './schema.js';
|
|
18
|
+
async function KnexBuilder({ request , connection }) {
|
|
18
19
|
let client = knex(connection);
|
|
19
20
|
if (request.tableName) {
|
|
20
21
|
client = client(request.tableName);
|
|
@@ -35,4 +36,9 @@ async function knexBuilder({ request , connection }) {
|
|
|
35
36
|
}
|
|
36
37
|
return client;
|
|
37
38
|
}
|
|
38
|
-
|
|
39
|
+
KnexBuilder.schema = schema;
|
|
40
|
+
KnexBuilder.meta = {
|
|
41
|
+
checkRead: false,
|
|
42
|
+
checkWrite: false
|
|
43
|
+
};
|
|
44
|
+
export default KnexBuilder;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ export default {
|
|
16
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
+
title: 'Lowdefy Request Schema - KnexBuilder',
|
|
18
|
+
type: 'object',
|
|
19
|
+
required: [
|
|
20
|
+
'query'
|
|
21
|
+
],
|
|
22
|
+
properties: {
|
|
23
|
+
query: {
|
|
24
|
+
type: 'array',
|
|
25
|
+
description: 'SQL query builder array. An array of objects, with a single key which is the name of the knex builder function. The value should be an array of arguments to pass to the builder function.',
|
|
26
|
+
errorMessage: {
|
|
27
|
+
type: 'KnexBuilder request property "query" should be an array.'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
tableName: {
|
|
31
|
+
type: [
|
|
32
|
+
'string',
|
|
33
|
+
'object'
|
|
34
|
+
],
|
|
35
|
+
description: 'The name of the table to query from.',
|
|
36
|
+
errorMessage: {
|
|
37
|
+
type: 'KnexBuilder request property "tableName" should be a string or object'
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
errorMessage: {
|
|
42
|
+
type: 'KnexBuilder request properties should be an object.',
|
|
43
|
+
required: {
|
|
44
|
+
query: 'KnexBuilder request should have required property "query".'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
15
|
*/ import knex from 'knex';
|
|
16
|
-
|
|
16
|
+
import schema from './schema.js';
|
|
17
|
+
async function KnexRaw({ request , connection }) {
|
|
17
18
|
const client = knex(connection);
|
|
18
19
|
const res = await client.raw(request.query, request.parameters);
|
|
19
20
|
Object.keys(res).forEach((key)=>{
|
|
@@ -23,4 +24,9 @@ async function knexRaw({ request , connection }) {
|
|
|
23
24
|
});
|
|
24
25
|
return res;
|
|
25
26
|
}
|
|
26
|
-
|
|
27
|
+
KnexRaw.schema = schema;
|
|
28
|
+
KnexRaw.meta = {
|
|
29
|
+
checkRead: false,
|
|
30
|
+
checkWrite: false
|
|
31
|
+
};
|
|
32
|
+
export default KnexRaw;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ export default {
|
|
16
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
+
title: 'Lowdefy Request Schema - KnexRaw',
|
|
18
|
+
type: 'object',
|
|
19
|
+
required: [
|
|
20
|
+
'query'
|
|
21
|
+
],
|
|
22
|
+
properties: {
|
|
23
|
+
query: {
|
|
24
|
+
type: 'string',
|
|
25
|
+
description: 'SQL query string.',
|
|
26
|
+
errorMessage: {
|
|
27
|
+
type: 'KnexRaw request property "query" should be a string.'
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
parameters: {
|
|
31
|
+
type: [
|
|
32
|
+
'string',
|
|
33
|
+
'number',
|
|
34
|
+
'array',
|
|
35
|
+
'object'
|
|
36
|
+
],
|
|
37
|
+
description: 'SQL query parameters.',
|
|
38
|
+
errorMessage: {
|
|
39
|
+
type: 'KnexRaw request property "parameters" should be a string, number, array, or object.'
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
errorMessage: {
|
|
44
|
+
type: 'KnexRaw request properties should be an object.',
|
|
45
|
+
required: {
|
|
46
|
+
query: 'KnexRaw request should have required property "query".'
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
|
+
|
|
4
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
you may not use this file except in compliance with the License.
|
|
6
|
+
You may obtain a copy of the License at
|
|
7
|
+
|
|
8
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
|
|
10
|
+
Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
See the License for the specific language governing permissions and
|
|
14
|
+
limitations under the License.
|
|
15
|
+
*/ export default {
|
|
16
|
+
$schema: 'http://json-schema.org/draft-07/schema#',
|
|
17
|
+
title: 'Lowdefy Connection Schema - Knex',
|
|
18
|
+
type: 'object',
|
|
19
|
+
required: [
|
|
20
|
+
'client',
|
|
21
|
+
'connection'
|
|
22
|
+
],
|
|
23
|
+
properties: {
|
|
24
|
+
client: {
|
|
25
|
+
type: 'string',
|
|
26
|
+
description: 'SQL query string.',
|
|
27
|
+
errorMessage: {
|
|
28
|
+
type: 'Knex connection property "client" should be a string.'
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
connection: {
|
|
32
|
+
type: [
|
|
33
|
+
'string',
|
|
34
|
+
'object'
|
|
35
|
+
],
|
|
36
|
+
description: 'SQL query string.',
|
|
37
|
+
errorMessage: {
|
|
38
|
+
type: 'Knex connection property "connection" should be a string or object.'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
searchPath: {
|
|
42
|
+
type: 'string',
|
|
43
|
+
description: 'Set PostgreSQL search path.',
|
|
44
|
+
errorMessage: {
|
|
45
|
+
type: 'Knex connection property "searchPath" should be a string.'
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
version: {
|
|
49
|
+
type: 'string',
|
|
50
|
+
description: 'Set database version.',
|
|
51
|
+
errorMessage: {
|
|
52
|
+
type: 'Knex connection property "version" should be a string.'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
errorMessage: {
|
|
57
|
+
type: 'Knex connection properties should be an object.',
|
|
58
|
+
required: {
|
|
59
|
+
client: 'Knex connection should have required property "client".',
|
|
60
|
+
connection: 'Knex connection should have required property "connection".'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
Copyright 2020-
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,13 +12,4 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/ export default
|
|
16
|
-
import: {
|
|
17
|
-
path: 'connections/Knex/KnexRaw/KnexRaw.js',
|
|
18
|
-
schema: 'connections/Knex/KnexRaw/KnexRawSchema.json'
|
|
19
|
-
},
|
|
20
|
-
meta: {
|
|
21
|
-
checkRead: false,
|
|
22
|
-
checkWrite: false
|
|
23
|
-
}
|
|
24
|
-
};
|
|
15
|
+
*/ export { default as Knex } from './connections/Knex/Knex.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
/*
|
|
2
|
-
Copyright 2020-
|
|
1
|
+
/* eslint-disable import/namespace */ /*
|
|
2
|
+
Copyright 2020-2022 Lowdefy, Inc
|
|
3
3
|
|
|
4
4
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
5
|
you may not use this file except in compliance with the License.
|
|
@@ -12,13 +12,9 @@
|
|
|
12
12
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
See the License for the specific language governing permissions and
|
|
14
14
|
limitations under the License.
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
meta: {
|
|
21
|
-
checkRead: false,
|
|
22
|
-
checkWrite: false
|
|
23
|
-
}
|
|
15
|
+
*/ import * as connections from './connections.js';
|
|
16
|
+
export default {
|
|
17
|
+
connections: Object.keys(connections),
|
|
18
|
+
requests: Object.keys(connections).map((connection)=>Object.keys(connections[connection].requests)
|
|
19
|
+
).flat()
|
|
24
20
|
};
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lowdefy/connection-knex",
|
|
3
|
-
"version": "4.0.0-alpha.
|
|
3
|
+
"version": "4.0.0-alpha.12",
|
|
4
4
|
"licence": "Apache-2.0",
|
|
5
5
|
"description": "",
|
|
6
6
|
"homepage": "https://lowdefy.com",
|
|
7
7
|
"keywords": [
|
|
8
8
|
"lowdefy",
|
|
9
|
-
"lowdefy connection"
|
|
9
|
+
"lowdefy connection",
|
|
10
|
+
"lowdefy plugin"
|
|
10
11
|
],
|
|
11
12
|
"bugs": {
|
|
12
13
|
"url": "https://github.com/lowdefy/lowdefy/issues"
|
|
@@ -27,8 +28,8 @@
|
|
|
27
28
|
},
|
|
28
29
|
"type": "module",
|
|
29
30
|
"exports": {
|
|
30
|
-
"
|
|
31
|
-
"./
|
|
31
|
+
"./connections": "./dist/connections.js",
|
|
32
|
+
"./types": "./dist/types.js"
|
|
32
33
|
},
|
|
33
34
|
"files": [
|
|
34
35
|
"dist/*"
|
|
@@ -41,22 +42,22 @@
|
|
|
41
42
|
"test": "jest --coverage"
|
|
42
43
|
},
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@lowdefy/helpers": "4.0.0-alpha.
|
|
45
|
-
"knex": "0.
|
|
46
|
-
"mssql": "
|
|
45
|
+
"@lowdefy/helpers": "4.0.0-alpha.12",
|
|
46
|
+
"knex": "1.0.1",
|
|
47
|
+
"mssql": "8.0.1",
|
|
47
48
|
"mysql": "2.18.1",
|
|
48
49
|
"pg": "8.7.1",
|
|
49
|
-
"sqlite3": "5.0.
|
|
50
|
+
"sqlite3": "5.0.5"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
52
|
-
"@lowdefy/ajv": "4.0.0-alpha.
|
|
53
|
-
"@swc/cli": "0.1.
|
|
54
|
-
"@swc/core": "1.2.
|
|
55
|
-
"@swc/jest": "0.2.
|
|
56
|
-
"jest": "27.
|
|
53
|
+
"@lowdefy/ajv": "4.0.0-alpha.12",
|
|
54
|
+
"@swc/cli": "0.1.55",
|
|
55
|
+
"@swc/core": "1.2.135",
|
|
56
|
+
"@swc/jest": "0.2.17",
|
|
57
|
+
"jest": "27.5.1"
|
|
57
58
|
},
|
|
58
59
|
"publishConfig": {
|
|
59
60
|
"access": "public"
|
|
60
61
|
},
|
|
61
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "41b6138a81bee7da362dad06345bc9f87b2c2133"
|
|
62
63
|
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "Lowdefy Request Schema - KnexBuilder",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"required": ["query"],
|
|
6
|
-
"properties": {
|
|
7
|
-
"query": {
|
|
8
|
-
"type": "array",
|
|
9
|
-
"description": "SQL query builder array. An array of objects, with a single key which is the name of the knex builder function. The value should be an array of arguments to pass to the builder function.",
|
|
10
|
-
"errorMessage": {
|
|
11
|
-
"type": "KnexBuilder request property \"query\" should be an array."
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"tableName": {
|
|
15
|
-
"type": ["string", "object"],
|
|
16
|
-
"description": "The name of the table to query from.",
|
|
17
|
-
"errorMessage": {
|
|
18
|
-
"type": "KnexBuilder request property \"tableName\" should be a string or object"
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"errorMessage": {
|
|
23
|
-
"type": "KnexBuilder request properties should be an object.",
|
|
24
|
-
"required": {
|
|
25
|
-
"query": "KnexBuilder request should have required property \"query\"."
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "Lowdefy Request Schema - KnexRaw",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"required": ["query"],
|
|
6
|
-
"properties": {
|
|
7
|
-
"query": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "SQL query string.",
|
|
10
|
-
"errorMessage": {
|
|
11
|
-
"type": "KnexRaw request property \"query\" should be a string."
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"parameters": {
|
|
15
|
-
"type": ["string","number", "array", "object"],
|
|
16
|
-
"description": "SQL query parameters.",
|
|
17
|
-
"errorMessage": {
|
|
18
|
-
"type": "KnexRaw request property \"parameters\" should be a string, number, array, or object."
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
},
|
|
22
|
-
"errorMessage": {
|
|
23
|
-
"type": "KnexRaw request properties should be an object.",
|
|
24
|
-
"required": {
|
|
25
|
-
"query": "KnexRaw request should have required property \"query\"."
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
-
"title": "Lowdefy Connection Schema - Knex",
|
|
4
|
-
"type": "object",
|
|
5
|
-
"required": ["client", "connection"],
|
|
6
|
-
"properties": {
|
|
7
|
-
"client": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "SQL query string.",
|
|
10
|
-
"errorMessage": {
|
|
11
|
-
"type": "Knex connection property \"client\" should be a string."
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
"connection": {
|
|
15
|
-
"type": ["string", "object"],
|
|
16
|
-
"description": "SQL query string.",
|
|
17
|
-
"errorMessage": {
|
|
18
|
-
"type": "Knex connection property \"connection\" should be a string or object."
|
|
19
|
-
}
|
|
20
|
-
},
|
|
21
|
-
"searchPath": {
|
|
22
|
-
"type": "string",
|
|
23
|
-
"description": "Set PostgreSQL search path.",
|
|
24
|
-
"errorMessage": {
|
|
25
|
-
"type": "Knex connection property \"searchPath\" should be a string."
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
"version": {
|
|
29
|
-
"type": "string",
|
|
30
|
-
"description": "Set database version.",
|
|
31
|
-
"errorMessage": {
|
|
32
|
-
"type": "Knex connection property \"version\" should be a string."
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
},
|
|
36
|
-
"errorMessage": {
|
|
37
|
-
"type": "Knex connection properties should be an object.",
|
|
38
|
-
"required": {
|
|
39
|
-
"client": "Knex connection should have required property \"client\".",
|
|
40
|
-
"connection": "Knex connection should have required property \"connection\"."
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|