@lowdefy/connection-knex 4.0.0-alpha.26 → 4.0.0-alpha.29

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lowdefy/connection-knex",
3
- "version": "4.0.0-alpha.26",
3
+ "version": "4.0.0-alpha.29",
4
4
  "license": "Apache-2.0",
5
5
  "description": "",
6
6
  "homepage": "https://lowdefy.com",
@@ -35,14 +35,13 @@
35
35
  "dist/*"
36
36
  ],
37
37
  "scripts": {
38
- "build": "yarn swc",
38
+ "build": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
39
39
  "clean": "rm -rf dist",
40
- "prepare": "yarn build",
41
- "swc": "swc src --out-dir dist --config-file ../../../../.swcrc --delete-dir-on-start --copy-files",
40
+ "prepublishOnly": "pnpm build",
42
41
  "test": "jest --coverage"
43
42
  },
44
43
  "dependencies": {
45
- "@lowdefy/helpers": "4.0.0-alpha.26",
44
+ "@lowdefy/helpers": "4.0.0-alpha.29",
46
45
  "knex": "1.0.7",
47
46
  "mssql": "8.1.2",
48
47
  "mysql": "2.18.1",
@@ -50,7 +49,7 @@
50
49
  "sqlite3": "5.0.8"
51
50
  },
52
51
  "devDependencies": {
53
- "@lowdefy/ajv": "4.0.0-alpha.26",
52
+ "@lowdefy/ajv": "4.0.0-alpha.29",
54
53
  "@swc/cli": "0.1.57",
55
54
  "@swc/core": "1.2.194",
56
55
  "@swc/jest": "0.2.21",
@@ -59,5 +58,5 @@
59
58
  "publishConfig": {
60
59
  "access": "public"
61
60
  },
62
- "gitHead": "ef60e34f87b95204d103db4a65e4ba3c54a5a1b5"
61
+ "gitHead": "621a191ebc0a1569ee6669dc74c12f8be5a8c7f3"
63
62
  }
@@ -1,24 +0,0 @@
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
- */ import KnexBuilder from './KnexBuilder/KnexBuilder.js';
16
- import KnexRaw from './KnexRaw/KnexRaw.js';
17
- import schema from './schema.js';
18
- export default {
19
- schema,
20
- requests: {
21
- KnexBuilder,
22
- KnexRaw
23
- }
24
- };
@@ -1,44 +0,0 @@
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
- */ import knex from 'knex';
16
- import { type } from '@lowdefy/helpers';
17
- import schema from './schema.js';
18
- async function KnexBuilder({ request , connection }) {
19
- let client = knex(connection);
20
- if (request.tableName) {
21
- client = client(request.tableName);
22
- }
23
- for (const method of request.query){
24
- if (Object.keys(method).length !== 1) {
25
- throw new Error(`Invalid query, more than one method defined in a method object, received ${JSON.stringify(Object.keys(method))}.`);
26
- }
27
- const methodName = Object.keys(method)[0];
28
- const methodArgs = method[methodName];
29
- if (!type.isArray(methodArgs)) {
30
- throw new Error(`Invalid query, method "${methodName}" arguments should be an array, received ${JSON.stringify(methodArgs)}.`);
31
- }
32
- if (!type.isFunction(client[methodName])) {
33
- throw new Error(`Invalid query builder method "${methodName}".`);
34
- }
35
- client = client[methodName](...methodArgs);
36
- }
37
- return client;
38
- }
39
- KnexBuilder.schema = schema;
40
- KnexBuilder.meta = {
41
- checkRead: false,
42
- checkWrite: false
43
- };
44
- export default KnexBuilder;
@@ -1,47 +0,0 @@
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,32 +0,0 @@
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
- */ import knex from 'knex';
16
- import schema from './schema.js';
17
- async function KnexRaw({ request , connection }) {
18
- const client = knex(connection);
19
- const res = await client.raw(request.query, request.parameters);
20
- Object.keys(res).forEach((key)=>{
21
- if (key.startsWith('_')) {
22
- delete res[key];
23
- }
24
- });
25
- return res;
26
- }
27
- KnexRaw.schema = schema;
28
- KnexRaw.meta = {
29
- checkRead: false,
30
- checkWrite: false
31
- };
32
- export default KnexRaw;
@@ -1,49 +0,0 @@
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
- };
@@ -1,63 +0,0 @@
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,15 +0,0 @@
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 as Knex } from './connections/Knex/Knex.js';
package/dist/types.js DELETED
@@ -1,19 +0,0 @@
1
- /* eslint-disable import/namespace */ /*
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
- */ 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)).flat()
19
- };