monetdb 2.0.0 → 2.0.2

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.
Files changed (59) hide show
  1. package/README.md +5 -4
  2. package/dist/PrepareStatement.d.ts +12 -0
  3. package/dist/PrepareStatement.js +29 -0
  4. package/dist/PrepareStatement.js.map +1 -0
  5. package/dist/QueryStream.d.ts +7 -0
  6. package/dist/QueryStream.js +13 -0
  7. package/dist/QueryStream.js.map +1 -0
  8. package/dist/connection.d.ts +25 -0
  9. package/dist/connection.js +104 -0
  10. package/dist/connection.js.map +1 -0
  11. package/dist/connections.d.ts +1 -0
  12. package/dist/connections.js +49 -0
  13. package/dist/connections.js.map +1 -0
  14. package/dist/defaults.d.ts +10 -0
  15. package/dist/defaults.js +13 -0
  16. package/dist/defaults.js.map +1 -0
  17. package/dist/file-transfer.d.ts +34 -0
  18. package/dist/file-transfer.js +194 -0
  19. package/dist/file-transfer.js.map +1 -0
  20. package/dist/index.d.ts +2 -0
  21. package/dist/index.js +9 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/mapi.d.ts +148 -0
  24. package/dist/mapi.js +851 -0
  25. package/dist/mapi.js.map +1 -0
  26. package/dist/monetize.d.ts +2 -0
  27. package/dist/monetize.js +57 -0
  28. package/dist/monetize.js.map +1 -0
  29. package/dist/tsconfig.tsbuildinfo +1 -0
  30. package/package.json +7 -2
  31. package/src/defaults.ts +7 -9
  32. package/src/mapi.ts +1 -1
  33. package/.github/workflows/Linux.yml +0 -45
  34. package/.github/workflows/docs.yml +0 -79
  35. package/.github/workflows/macos.yml +0 -43
  36. package/.github/workflows/monetdb-versions.yml +0 -43
  37. package/docs/components/alert.tsx +0 -10
  38. package/docs/components/info.tsx +0 -6
  39. package/docs/next.config.js +0 -24
  40. package/docs/package-lock.json +0 -5069
  41. package/docs/package.json +0 -22
  42. package/docs/pages/_app.js +0 -9
  43. package/docs/pages/_meta.json +0 -16
  44. package/docs/pages/apis/_meta.json +0 -4
  45. package/docs/pages/apis/connection.mdx +0 -60
  46. package/docs/pages/apis/result.mdx +0 -39
  47. package/docs/pages/index.mdx +0 -27
  48. package/docs/theme.config.js +0 -35
  49. package/docs/v0/README.v0.md +0 -138
  50. package/docs/v1/MapiConnection.md +0 -53
  51. package/docs/v1/README.md +0 -532
  52. package/docs/v1/v1-notes.md +0 -173
  53. package/test/connection.ts +0 -43
  54. package/test/exec-queries.ts +0 -100
  55. package/test/filetransfer.ts +0 -94
  56. package/test/prepare-statement.ts +0 -27
  57. package/test/query-stream.ts +0 -41
  58. package/test/tmp/.gitignore +0 -4
  59. package/tsconfig.json +0 -24
package/docs/package.json DELETED
@@ -1,22 +0,0 @@
1
- {
2
- "name": "docs",
3
- "version": "1.0.0",
4
- "description": "",
5
- "main": "next.config.js",
6
- "scripts": {
7
- "start": "next dev",
8
- "build": "next build"
9
- },
10
- "keywords": [],
11
- "author": {
12
- "name": "Svetlin Stalinov",
13
- "email": "svetlin.stalinov@monetdbsolutions.com"
14
- },
15
- "dependencies": {
16
- "next": "^14.0.1",
17
- "nextra": "^2.13.2",
18
- "nextra-theme-docs": "^2.13.2",
19
- "react": "^18.2.0",
20
- "react-dom": "^18.2.0"
21
- }
22
- }
@@ -1,9 +0,0 @@
1
- import 'nextra-theme-docs/style.css'
2
-
3
- export default function Nextra({ Component, pageProps }) {
4
- return (
5
- <>
6
- <Component {...pageProps} />
7
- </>
8
- )
9
- }
@@ -1,16 +0,0 @@
1
- {
2
- "index": "Getting Started",
3
- "apis": "API",
4
- "example": "Examples",
5
- "versions": {
6
- "title": "archive",
7
- "type": "menu",
8
- "items": {
9
- "v0": {
10
- "title": "v0",
11
- "href": "https://github.com/MonetDB/monetdb-nodejs/blob/master/docs/v0"},
12
- "v1": {
13
- "title": "v1",
14
- "href": "https://github.com/MonetDB/monetdb-nodejs/blob/master/docs/v1"}}
15
- }
16
- }
@@ -1,4 +0,0 @@
1
- {
2
- "connection": "Connecting",
3
- "result": "QueryResult"
4
- }
@@ -1,60 +0,0 @@
1
- ## Connecting
2
- ```ts
3
- const conn = new Connection(config: MapiConfig | string);
4
- ```
5
- , all the optional fields get default values if not specified.
6
- ### Using configuration options
7
- ```ts
8
- interface MapiConfig {
9
- database: string;
10
- username?: string;
11
- password?: string;
12
- language?: MAPI_LANGUAGE; // sql
13
- host?: string;
14
- port?: number;
15
- timeout?: number;
16
- autoCommit?: boolean;
17
- replySize?: number;
18
- }
19
-
20
- const defaults = {
21
- host: process.env.MAPI_HOST || 'localhost',
22
- port: process.env.MAPI_PORT || 50000,
23
- username: process.env.MAPI_USER || 'monetdb',
24
- password: process.env.MAPI_PASSWORD || 'monetdb',
25
- database: process.env.MAPI_DATABASE,
26
- autoCommit: false,
27
- replySize: 100,
28
- };
29
-
30
- const config: MapiConfig = {
31
- ...defaults
32
- database: 'test',
33
- }
34
- const conn = new Connection(config);
35
- ```
36
- ### Using URL
37
- ```ts
38
- const conn = new Connection('mapi:monetdb://<username>:<password>@<hostname>:<port>/<database>');
39
- ```
40
- ### Connection object
41
- ```ts
42
- declare class Connection extends EventEmitter {
43
- autoCommit?: boolean;
44
- replySize?: number;
45
- sizeHeader?: boolean;
46
- mapi: MapiConnection;
47
- constructor(params: MapiConfig | MAPI_URI);
48
- connect(callback?: ConnectCallback): Promise<boolean>;
49
- close(): Promise<boolean>;
50
- commit(): Promise<any>;
51
- private command;
52
- execute(sql: string, stream?: boolean): Promise<QueryResult|QueryStream>;
53
- prepare(sql: string): Promise<PrepareStatement>;
54
- setAutocommit(v: boolean): Promise<boolean>;
55
- setReplySize(v: number): Promise<number>;
56
- setSizeHeader(v: boolean): Promise<boolean>;
57
- setTimezone(sec: number): Promise<any>;
58
- rollback(): Promise<any>;
59
- }
60
- ```
@@ -1,39 +0,0 @@
1
- ## Query Result
2
- The result object returned from sucessful query execution.
3
- ```ts
4
- type QueryResult = {
5
- id?: number;
6
- type?: string;
7
- queryId?: number;
8
- rowCnt?: number;
9
- affectedRows?: number;
10
- columnCnt?: number;
11
- queryTime?: number;
12
- sqlOptimizerTime?: number;
13
- malOptimizerTime?: number;
14
- columns?: Column[];
15
- headers?: ResponseHeaders;
16
- data?: any[];
17
- };
18
- import { Connection } from 'monetdb';
19
- const conn = new Connection({database: 'test'});
20
- const ready = await conn.connect();
21
- const res: QueryResult = await conn.execute('select 1 as one, 2 as two');
22
- console.log(res);
23
- // {
24
- // type: '&1',
25
- // id: 1,
26
- // rowCnt: 1,
27
- // columnCnt: 2,
28
- // queryId: 37,
29
- // queryTime: 311,
30
- // malOptimizerTime: 129,
31
- // sqlOptimizerTime: 22,
32
- // columns: [
33
- // { table: '.', name: 'one', type: 'tinyint', index: 0 },
34
- // { table: '.', name: 'two', type: 'tinyint', index: 1 }
35
- // ],
36
- // data: [ [ 1, 2 ] ]
37
- // }
38
-
39
- ```
@@ -1,27 +0,0 @@
1
- ---
2
- title: Getting Started
3
- slug: /
4
- ---
5
-
6
- ## Installation
7
-
8
- ```bash
9
- $ npm install monetdb
10
- ```
11
-
12
- ## Usage
13
- The simplest way to connect is to use default connection options and pass only the database name.
14
-
15
- ```js
16
- import { Connection} from 'monetdb'
17
-
18
- const opt = {database: 'test'}
19
-
20
- const conn = new Connection(opt)
21
- const ready = await conn.connect();
22
- const res = conn.exec('select 42');
23
- console.log(res.data)
24
- await conn.close();
25
- ```
26
- , see [connection api](/apis/connection) for more details.
27
-
@@ -1,35 +0,0 @@
1
- // theme.config.js
2
- export default {
3
- project: {
4
- link: 'https://github.com/MonetDB/monetdb-nodejs',
5
- },
6
- docsRepositoryBase: 'https://github.com/MonetDB/monetdb-nodejs/blob/master/docs', // base URL for the docs repository
7
- darkMode: true,
8
- footer: true,
9
- navigation: {
10
- prev: true,
11
- next: true,
12
- },
13
- footer: {
14
- text: `Mozilla Public License, v.2.0 ${new Date().getFullYear()}`,
15
- },
16
- editLink: {
17
- text: 'Edit this page on GitHub',
18
- },
19
- logo: (
20
- <>
21
- <span>monetdb-nodejs</span>
22
- </>
23
- ),
24
- head: (
25
- <>
26
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
27
- <meta
28
- name="description"
29
- content="MonetDB Node.js connector"
30
- />
31
- <meta name="og:title" content="monetdb-nodejs" />
32
- <meta name="og:description" content="MonetDB Node.js driver" />
33
- </>
34
- ),
35
- }
@@ -1,138 +0,0 @@
1
- # Documentation for MonetDB NodeJS connector v0.\*
2
-
3
- > **The v0.\* version is no longer maintained. Therefore, we strongly encourage everyone using the v0.\* version to switch to the v1.\* version.**
4
- > For information on how to upgrade, see the [major changes](https://github.com/MonetDB/monetdb-nodejs#changes), and the [backward compatibility](#callbackwrapper).
5
-
6
- # Installation
7
- npm install [-g] monetdb
8
-
9
- # Example usage:
10
-
11
- ```
12
- var options = {
13
- host : 'localhost',
14
- port : 50000,
15
- dbname : 'mydb',
16
- user : 'monetdb',
17
- password : 'monetdb'
18
- };
19
-
20
- var conn = require('monetdb').connect(options , function(err) {
21
- if (!err) console.log('connected');
22
- });
23
-
24
- conn.query('SELECT 1', function(err, res) {
25
- if (!err) console.log(res);
26
- });
27
-
28
- conn.query('SELECT id FROM tables WHERE name=? and readonly=?',
29
- ['connections', false], function(err, res) {
30
- if (!err) console.log(res);
31
- });
32
-
33
- conn.close();
34
- ```
35
-
36
- # API
37
-
38
- #### <a name="connect"></a>connect(options, fn)
39
- Obtain a MonetDBConnection object that tries to connect to a MonetDB server process using the provided options.
40
-
41
- - options [object]: Options to use for this connection. Possible options are:
42
- - host [string]: hostname to connect to (default: localhost)
43
- - port [integer]: port on which the MonetDB server process is listening (default: 50000)
44
- - dbname [string]: name of the database to use (default: demo)
45
- - user [string]: username to use for logging in (default: monetdb)
46
- - password [string]: password to use for logging in (default: monetdb)
47
- - language [string]: query language to use (default: sql)
48
- - debug [boolean]: whether or not to initialize the connection in debug node (default: false)
49
- - q [function]: in case you want to use promises, you should pass in the result of require('q') in here. See [Q Integration](#q) for more information on our Q integration.
50
- - fn [function]: Callback function to call whenever the connection succeeds or fails. This function receives one argument, which contains an error string on failure or null on success. Note: this function might be called multiple times when the MonetDB connection fails after it first succeeded. In that case, the callback will first be called indicating success, and later again with an error message.
51
-
52
- Returns an instance of a MonetDBConnection object. Note that thanks to a queueing system, this object can immediately receive queries when it is returned, even if the connection is not established yet.
53
-
54
- ---
55
-
56
- #### <a name="query"></a>MonetDBConnection.query(query, [params], [raw], fn)
57
- Run a query against this MonetDBConnection
58
-
59
- - query [string]: A query string in the chosen language, where values may be replaced by question marks, in which case the params array must be set (note: when the params array is given, the MonetDBConnection.prepare will be used under the hood).
60
- - params [array]: In case question marks are given for some values in the query, this array supplies the query method with the values to fill in. (default: null)
61
- - raw [boolean]: If set to true, a raw query is expected, including an initial 's' and a trailing ';'. (default: false)
62
- - fn [function]: Callback function that will be called when the query completes. It then receives two arguments:
63
- - err: Error string if an error occurred, null if the query succeeded
64
- - result: The [query result](#result)
65
-
66
- ---
67
-
68
- #### <a name="result"></a>Query result
69
- A query returns a query result object. This object has the following properties:
70
-
71
- - data [array]: When a SELECT query was done, this array contains the resulting data from the database. It is passed as an array of arrays, where every inner array represents one data tuple.
72
- - col [object]: Object that maps column names to query result indices. So if you for example did SELECT a, b FROM ... you can access b in a tuple array by issuing tuple[result.col.b], which in this case would resolve to tuple[1].
73
- - rows [integer]: The number of rows in the result set
74
- - cols [integer]: The number of columns in the result set
75
- - structure [array]: An array containing an object for every column, with information about the column (like from which table it came, what its name is etc.)
76
- - queryid [integer]: A unique identifier for this query
77
- - type: The type of the result (currently only 'table' is supported)
78
-
79
- ---
80
-
81
- #### MonetDBConnection.prepare(query, fn)
82
- Prepares a query for repeated execution.
83
-
84
- - query [string]: The query that has to be prepared. In this query, actual values can be replaced by question marks.
85
- - fn [function]: Callback function that will be called when the preparation finished. It gets passed two arguments. The first argument is an error string or null on success, the second argument is an object with the following properties:
86
- - prepare: The [query result](#result) of the prepare statement
87
- - exec: A function that you can call if you want to execute your prepared statement. It takes two parameters, the first one is an array with the query parameters and the second is a callback that gets executed when the execution of the prepared statement finishes (same as callback to [MonetDBConnection.query](#query)).
88
- - release: A function that you can call when you want to free the resources used by your prepared statement. After calling this function, calls to the exec function will fail.
89
-
90
- ---
91
-
92
- #### MonetDBConnection.close(fn)
93
- Empty the query queue and then close the connection. Note that whenever queries arrive after the close has been issued, these queries will also be processed before the connection is closed. The connection really is not closed before it encounters an empty message queue.
94
- - fn [function]: Callback function that will be called when the connection is closed. Since failure never happens, it will always be called with its first argument set to null. The second argument is never given, since there is no result associated with closing the connection.
95
-
96
-
97
-
98
- # <a name="log"></a>Query logging
99
- Every time a query result is returned from the database, the callback function *conn.log_callback*, which defaults to null, will be executed right before the query callback function is executed (conn refers to a connection object returned by the [connect function](#connect)). If you have some general behavior that you want to be executed every time a query finishes, you can set *conn.log_callback* to a function with the following signature:
100
-
101
- function(query, err, res)
102
- - query: the SQL query that lead to this result (note: if you pass a params array to the [query function](#query), multiple queries are fired to the database, hence the log callback will be called multiple times)
103
- - err, res: Same as in the callback for the [query function](#query)
104
-
105
-
106
- # <a name="q"></a>Q Integration
107
- Due to the huge popularity of the [Q module for NodeJS](https://www.npmjs.org/package/q), we decided to add native Q support, that wraps our API in a promise returning API that exists on top of the original API, so you can use both interchangeably.
108
-
109
- We did not want to add Q as a dependency of our module and therefore, if you want to use the promise returning functions, you have to pass in the result of require('q') to the connection options when calling the [connect function](#connect).
110
-
111
- All of the promise returning functions take the same arguments as the original functions they wrap, except for the callback argument.
112
-
113
- The promise returning functions are:
114
- - connectQ: Gets resolved with the connection object when the connection has been successfully initialized and gets rejected if the connection could not be established. Note that, since promises can by definition only be resolved once, failure of the connection after the promise has been resolved can not be detected using this function (you can detect this with the [original connect function](#connect).
115
- - queryQ
116
- - prepareQ
117
- - closeQ
118
-
119
- ### Example usage of Q integration
120
- ```
121
- var conn = null;
122
- monetdb.connectQ({dbname:"blaeu"}).then(function(c) {
123
- conn = c;
124
- return conn.queryQ("CREATE TABLE coords (x INT, y INT)").then(function() {
125
- return conn.queryQ("INSERT INTO coords VALUES (1, 1), (2, 5), (9, 1)");
126
- }).then(function() {
127
- return conn.queryQ("SELECT * FROM coords WHERE x < ? AND y < ?", [4, 5]);
128
- }).then(function(data) {
129
- console.log(data);
130
- });
131
- }).fail(function(err) {
132
- console.log("Something went wrong: "+err);
133
- }).fin(function() {
134
- conn && conn.closeQ().then(function() {
135
- console.log("Connection successfully closed!");
136
- });
137
- }).done();
138
- ```
@@ -1,53 +0,0 @@
1
- # The MapiConnection object
2
-
3
- [![Build Status](https://travis-ci.org/MonetDB/monetdb-nodejs.svg)](https://travis-ci.org/MonetDB/monetdb-nodejs)
4
- [![Coverage Status](https://coveralls.io/repos/MonetDB/monetdb-nodejs/badge.svg?branch=master&service=github)](https://coveralls.io/github/MonetDB/monetdb-nodejs?branch=master)
5
- [![npm version](https://badge.fury.io/js/monetdb.svg)](https://badge.fury.io/js/monetdb)
6
- [![Dependency Status](https://david-dm.org/MonetDB/monetdb-nodejs.svg)](https://david-dm.org/MonetDB/monetdb-nodejs)
7
-
8
- The MapiConnection object manages the socket connection to the server, and communicates over this socket.
9
- It also contains the reconnect logic.
10
-
11
- The MonetDB NodeJS module does not expose the constructor of the MapiConnection directly, since for normal usage a
12
- MapiConnection object should be managed by a [MonetDBConnection object](https://github.com/MonetDB/monetdb-nodejs#mdbconnection).
13
- You can however use a MapiConnection object directly, since every MonetDBConnection object exposes one.
14
-
15
- If you insist, you could also include src/mapi-connection.js directly into your project to be able to construct one yourself.
16
-
17
- <a name="constructor"></a>
18
- ### MapiConnection(\[options\])
19
- Construct a MapiConnection object. For the available options in the options object, [see here](https://github.com/MonetDB/monetdb-nodejs#options).
20
-
21
- **Note: As opposed to the [MonetDBConnection object](#https://github.com/MonetDB/monetdb-nodejs#mdbconnection),
22
- the options are not checked for validity on constructing a MapiConnection object. This might cause unexpected behavior,
23
- since we do not test the creation of a MapiConnection object other than by a MonetDBConnection object.**
24
-
25
- <a name="connect"></a>
26
- ### .connect()
27
- This method is documented int the [MonetDBConnection object section](https://github.com/MonetDB/monetdb-nodejs#mdbconnection_connect).
28
-
29
- <a name="request"></a>
30
- ### .request(request)
31
- Adds a Mapi request to the queue. If you want to issue an SQL query this way, you should pack it in between an 's' and a ';':
32
-
33
- ```javascript
34
- mapiConn.request('sSELECT * FROM foo;');
35
- ```
36
-
37
- Returns a promise that resolves with a [query result](https://github.com/MonetDB/monetdb-nodejs#mdbconnection_query), or
38
- gets rejected with a proper error message.
39
-
40
- <a name="getstate"></a>
41
- ### .getState()
42
- This method is documented in the [MonetDBConnection object section](https://github.com/MonetDB/monetdb-nodejs#mdbconnection_getstate).
43
-
44
-
45
- <a name="close"></a>
46
- ### .close()
47
- This method is documented in the [MonetDBConnection object section](https://github.com/MonetDB/monetdb-nodejs#mdbconnection_close).
48
-
49
-
50
- <a name="destroy"></a>
51
- ### .destroy(\[msg\])
52
- This method is documented in the [MonetDBConnection object section](https://github.com/MonetDB/monetdb-nodejs#mdbconnection_destroy).
53
-