chain-db-ts 0.0.2 → 1.0.0-rc.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 (39) hide show
  1. package/CHANGELOG.md +110 -0
  2. package/dist/cjs/features/chain-db.d.ts +23 -64
  3. package/dist/cjs/features/chain-db.js +100 -263
  4. package/dist/cjs/features/constants.d.ts +11 -11
  5. package/dist/cjs/features/constants.js +22 -12
  6. package/dist/cjs/features/events.d.ts +28 -0
  7. package/dist/cjs/features/events.js +89 -0
  8. package/dist/cjs/features/table-doc.d.ts +37 -0
  9. package/dist/cjs/features/table-doc.js +135 -0
  10. package/dist/cjs/features/table.d.ts +81 -9
  11. package/dist/cjs/features/table.js +226 -70
  12. package/dist/cjs/features/types.d.ts +79 -21
  13. package/dist/cjs/features/types.js +30 -8
  14. package/dist/cjs/features/utils.d.ts +2 -1
  15. package/dist/cjs/features/utils.js +5 -2
  16. package/dist/cjs/index.d.ts +3 -2
  17. package/dist/cjs/index.js +8 -3
  18. package/features/chain-db.d.ts +23 -64
  19. package/features/chain-db.js +101 -241
  20. package/features/constants.d.ts +11 -11
  21. package/features/constants.js +14 -11
  22. package/features/events.d.ts +28 -0
  23. package/features/events.js +84 -0
  24. package/features/table-doc.d.ts +37 -0
  25. package/features/table-doc.js +129 -0
  26. package/features/table.d.ts +81 -9
  27. package/features/table.js +227 -69
  28. package/features/types.d.ts +79 -21
  29. package/features/types.js +29 -7
  30. package/features/utils.d.ts +2 -1
  31. package/features/utils.js +5 -2
  32. package/index.d.ts +3 -2
  33. package/index.js +3 -1
  34. package/package.json +5 -3
  35. package/readme.md +260 -132
  36. package/dist/cjs/features/access.d.ts +0 -6
  37. package/dist/cjs/features/access.js +0 -22
  38. package/features/access.d.ts +0 -6
  39. package/features/access.js +0 -16
package/features/types.js CHANGED
@@ -1,7 +1,29 @@
1
- export var TransactionType;
2
- (function (TransactionType) {
3
- TransactionType["NONE"] = "NONE";
4
- TransactionType["ACCOUNT"] = "ACCOUNT";
5
- TransactionType["CONTRACT"] = "CONTRACT";
6
- TransactionType["TRANSFER"] = "TRANSFER";
7
- })(TransactionType || (TransactionType = {}));
1
+ /**
2
+ * Operators for the advanced criteria
3
+ * @see https://docs.chaindb.com/docs/query-language/ (TODO)
4
+ */
5
+ export var Operators = {
6
+ // (==)
7
+ EQUAL: 'Eq',
8
+ // (!=)
9
+ NOT_EQUAL: 'Ne',
10
+ // (>)
11
+ GREATER_THAN: 'Gt',
12
+ // (>=)
13
+ GREATER_THAN_OR_EQUAL: 'Ge',
14
+ // (<)
15
+ LESS_THAN: 'Lt',
16
+ // (<=)
17
+ LESS_THAN_OR_EQUAL: 'Le',
18
+ // (for strings and arrays)
19
+ CONTAINS: 'Contains',
20
+ // (for strings)
21
+ STARTS_WITH: 'StartsWith',
22
+ // (for strings)
23
+ ENDS_WITH: 'EndsWith'
24
+ };
25
+ // Events
26
+ export var EventTypes = {
27
+ TABLE_PERSIST: 'TablePersist',
28
+ TABLE_UPDATE: 'TableUpdate'
29
+ };
@@ -1 +1,2 @@
1
- export declare const post: (url: string, body: any) => Promise<import("axios").AxiosResponse<any, any>>;
1
+ import { BasicResponse } from './types';
2
+ export declare const post: (url: string, body: any, auth?: string) => Promise<import("axios").AxiosResponse<BasicResponse<any>, any>>;
package/features/utils.js CHANGED
@@ -1,4 +1,7 @@
1
1
  import axios from 'axios';
2
- export var post = function (url, body) {
3
- return axios.post(url, body, { headers: { 'content-type': 'application/json' } });
2
+ export var post = function (url, body, auth) {
3
+ if (auth === void 0) { auth = ''; }
4
+ return axios.post(url, body, {
5
+ headers: { 'content-type': 'application/json', Authorization: "Basic ".concat(auth) }
6
+ });
4
7
  };
package/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { ChainDB, connect } from './features/chain-db';
2
- export { Access } from './features/access';
3
- export { BasicResponse, SignedUserAccount } from './features/types';
2
+ export { BasicResponse, Operators, CriteriaAdvanced, Criteria, TableDoc, EventTypes, EventData, EventCallback, } from './features/types';
3
+ export { default as Events } from './features/events';
4
+ export { TableDocImpl } from './features/table-doc';
package/index.js CHANGED
@@ -1,2 +1,4 @@
1
1
  export { ChainDB, connect } from './features/chain-db';
2
- export { Access } from './features/access';
2
+ export { Operators, EventTypes, } from './features/types';
3
+ export { default as Events } from './features/events';
4
+ export { TableDocImpl } from './features/table-doc';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "chain-db-ts",
3
- "version": "0.0.2",
3
+ "version": "1.0.0-rc.2",
4
4
  "description": "Chain DB Client for Javascript/Typescript Node apps.",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./index.js",
@@ -26,7 +26,7 @@
26
26
  "license": "MIT",
27
27
  "devDependencies": {
28
28
  "@types/node": "^18.15.5",
29
- "@types/sha256": "^0.2.0",
29
+ "@types/ws": "^8.5.14",
30
30
  "nodemon": "^3.0.1",
31
31
  "ts-node": "^10.9.1",
32
32
  "tslib": "^2.5.0",
@@ -35,6 +35,8 @@
35
35
  "repository": "git://github.com/wpdas/chain-db-ts.git",
36
36
  "dependencies": {
37
37
  "axios": "^1.4.0",
38
- "sha256": "^0.2.0"
38
+ "bufferutil": "^4.0.9",
39
+ "utf-8-validate": "^6.0.5",
40
+ "ws": "^8.18.1"
39
41
  }
40
42
  }
package/readme.md CHANGED
@@ -1,186 +1,314 @@
1
- # Chain DB - TS
1
+ # Chain DB TypeScript Client
2
2
 
3
- ChainDB TS is a library that allows the usage of the ChainDB database in TypeScript and JavaScript projects.
3
+ A TypeScript client for [Chain DB](https://github.com/wpdas/chain-db), a simple database that maintains a history of changes, allowing you to track how your data evolves over time.
4
4
 
5
- Chain DB is a Story-driven database. This new type of system uses some features used in blockchain technology. Each change generates a transaction that is saved in a block. The network works centrally, so persistent data is not decentralized.
5
+ ## Installation
6
6
 
7
- This database has some features by default, such as: create user account, get user account, transfer units and get transfer records as well as the main feature that is tables.
7
+ ```bash
8
+ npm install chain-db-ts
9
+ # or
10
+ yarn add chain-db-ts
11
+ ```
8
12
 
9
- The `unit` property present in each user's account can be anything the project wants, it can be a type of currency, item, resource.
13
+ ## Usage
10
14
 
11
- Visit the [Chain DB repository](https://github.com/wpdas/chain-db) to get to know more.
15
+ ### Connecting to Chain DB
12
16
 
13
- ## Install
17
+ ```typescript
18
+ import { connect } from 'chain-db-ts'
14
19
 
15
- Install using npm or yarn:
20
+ // Connect to Chain DB
21
+ // Parameters: server | database | user | password
22
+ // If the server parameter is null, "http://localhost:2818" will be used as default
23
+ const db = await connect({
24
+ server: 'http://localhost:2818',
25
+ database: 'my-database',
26
+ user: 'root',
27
+ password: '1234',
28
+ })
29
+ ```
16
30
 
17
- ```sh
18
- npm install chain-db-ts
31
+ ### Working with Tables
19
32
 
20
- # or
33
+ Define your table structure using TypeScript interfaces:
21
34
 
22
- yarn add chain-db-ts
35
+ ```typescript
36
+ // Define your table structure
37
+ interface GreetingTable {
38
+ greeting: string
39
+ }
40
+
41
+ // Define a more complex table
42
+ interface UserTable {
43
+ id: number
44
+ name: string
45
+ email: string
46
+ active: boolean
47
+ createdAt: string
48
+ }
23
49
  ```
24
50
 
25
- ## Usage examples
51
+ ### Getting a Table
26
52
 
27
- First of all, it's good to know that all requests return a `BasicResponse<D>` object that has the following structure:
53
+ ```typescript
54
+ // Get a table instance
55
+ // If the table already exists in the chain, its data will be loaded. (data from the last record stored in the table)
56
+ const greetingTable = await db.getTable<GreetingTable>('greeting')
28
57
 
29
- **success:** `boolean` (informs if the transaction was successful) <br/>
30
- **error_msg:** `string` (error message) <br/>
31
- **data:** `D` (any expected data type depending on the request) <br/>
58
+ // Access the current document data (the last record stored in the table)
59
+ console.log(greetingTable.currentDoc) // e.g., { greeting: 'Hello' }
60
+ ```
32
61
 
33
- Make sure you have the database running on your local machine or use the server link from where the database is running.
62
+ ### Modifying and Persisting Data
34
63
 
35
- ### Table
64
+ ```typescript
65
+ // Modify the current document data
66
+ greetingTable.currentDoc.greeting = 'Hello, Chain DB!'
36
67
 
37
- Tables must be simple class with default values, empty or not. This class will be used as a reference to create the table's fields.
68
+ // Persist changes to database (creates a new record with a new doc_id)
69
+ const result = await greetingTable.persist()
38
70
 
39
- When it's time to persist the table's data on the chain, just call the `persit` database function.
71
+ // The persist method returns the created document with its doc_id
72
+ console.log(result.doc_id) // e.g., '550e8400-e29b-41d4-a716-446655440000'
40
73
 
41
- ```ts
42
- // Greeting Table
43
- class GreetingTable {
44
- public greeting = 'Hi'
45
- }
74
+ // You can also access the current document's ID directly
75
+ const currentDocId = greetingTable.getCurrentDocId()
76
+ console.log(currentDocId) // Same as result.doc_id
46
77
  ```
47
78
 
48
- ```ts
49
- import { connect } from 'chain-db-ts'
50
- import { GreetingTable } from './tables'
51
-
52
- const main async () {
53
- // server | db-name | user | password
54
- // If the `server` parameter is empty(null), then "http://localhost:2818" will be used.
55
- const db = connect('http://localhost:2818', 'test-db', 'root', '1234')
79
+ ### Updating Item
56
80
 
57
- // Initialize the "greeting" table using the "GreetingTable"
58
- // class as a template. If there is already any data saved in
59
- // the chain, this data will be populated in the table instance.
60
- const greetingTable = await db.get_table('greeting', new GreetingTable())
61
- console.log(greetingTable.table) // { greeting: 'Hi' }
81
+ ```typescript
82
+ // To update a specific document, first get it by ID
83
+ const docId = '550e8400-e29b-41d4-a716-446655440000'
84
+ const specificDoc = await greetingTable.getDoc(docId)
62
85
 
63
- // Mutating data
64
- greetingTable.table.greeting = "Hello my dear!"
65
- await greetingTable.persist() // Data is persisted on the blockchain
66
-
67
- // See the most updated values of the table
68
- console.log(greetingTable.table) // { greeting: 'Hello my dear!' }
69
- }
70
- main()
86
+ // Then update its data
87
+ specificDoc.doc.greeting = 'Updated greeting'
88
+ await specificDoc.update()
71
89
  ```
72
90
 
73
- The next examples will not include the `db` implementation, ` import` lines and the `const main async () {}` block as this is implied.
91
+ ### Getting a Specific Document
74
92
 
75
- ### Create User Account
93
+ ```typescript
94
+ // Get a specific document by its ID (assuming we know a document ID)
95
+ // The document ID is generated by ChainDB when data is persisted
96
+ const docId = '550e8400-e29b-41d4-a716-446655440000' // Example ID
97
+ const specificDoc = await greetingTable.getDoc(docId)
76
98
 
77
- This is a default database feature that allows you to create user accounts within the database. As these are hashed accounts, the only data required is: Username and Password. This data is hashed, that is, only the user with the correct data can access the data.
99
+ // Access the document data
100
+ console.log(specificDoc.doc) // e.g., { greeting: 'Hello from specific doc', doc_id: '550e8400-e29b-41d4-a716-446655440000' }
78
101
 
79
- It is not possible to recover an account in which the user has forgotten access data.
102
+ // The doc_id is also available directly in the document object
103
+ console.log(specificDoc.doc.doc_id) // '550e8400-e29b-41d4-a716-446655440000'
80
104
 
81
- ```ts
82
- const user_name = 'wenderson.fake'
83
- const user_pass = '1234'
105
+ // Update the specific document
106
+ specificDoc.doc.greeting = 'Updated greeting for specific doc'
107
+ await specificDoc.update() // Updates only this specific document
84
108
 
85
- // Check if the given name is already in use
86
- const user_name_taken = await db.check_user_name(user_name)
87
- if (!user_name_taken.success) {
88
- // user name | password | units (optional) | password hint (optional - may be used in the future versions)
89
- const user = await db.create_user_account(user_name, user_pass, 2)
90
- console.log(user.data)
91
- // {
92
- // id: 'b2e4e7c15f733d8c18836ffd22051ed855226d9041fb9452f17f498fc2bcbce3',
93
- // user_name: 'wenderson.fake',
94
- // units: 2
95
- // }
96
- }
109
+ // Refetch the document data if it might have been updated elsewhere
110
+ await specificDoc.refetch()
111
+ console.log(specificDoc.doc) // Updated data from the database
112
+
113
+ // Get the table name this document belongs to
114
+ const tableName = specificDoc.getTableName() // 'greeting'
97
115
  ```
98
116
 
99
- ### Get User Account Info
117
+ Note: The `TableDoc` instance returned by `getDoc()` is a simplified version of a table that only allows updating the specific document. It cannot create new records with `persist()` or perform other table operations.
100
118
 
101
- This feature can be used for the "Login/Sign In" action.
119
+ ### Getting Table History
102
120
 
103
- ```ts
104
- const user_name = 'wenderson.fake'
105
- const user_pass = '1234'
106
- const user = await db.get_user_account(user_name, user_pass)
107
- console.log(user.data)
108
- // {
109
- // id: 'b2e4e7c15f733d8c18836ffd22051ed855226d9041fb9452f17f498fc2bcbce3',
110
- // user_name: 'wenderson.fake',
111
- // units: 2
112
- // }
121
+ ```typescript
122
+ // Get the last 100 changes to the table
123
+ const history = await greetingTable.getHistory(100)
124
+ console.log(history)
125
+ // Example output:
126
+ // [
127
+ // { greeting: 'Hello, Chain DB!' },
128
+ // { greeting: 'Hello' },
129
+ // { greeting: 'Hi there' },
130
+ // ...
131
+ // ]
113
132
  ```
114
133
 
115
- ### Get User Account Info By User Id
134
+ ### Real-time Events with WebSockets
135
+
136
+ Chain DB supports real-time updates through WebSockets. You can subscribe to table events to get notified when data changes:
116
137
 
117
- Just another way to fetch the user info.
138
+ ```typescript
139
+ import { EventTypes, EventData } from 'chain-db-ts'
118
140
 
119
- ```ts
120
- const wenderson_id = 'b2e4e7c15f733d8c18836ffd22051ed855226d9041fb9452f17f498fc2bcbce3'
121
- const user = await db.get_user_account_by_id(wenderson_id)
122
- console.log(user.data)
123
- // {
124
- // id: 'b2e4e7c15f733d8c18836ffd22051ed855226d9041fb9452f17f498fc2bcbce3',
125
- // user_name: 'wenderson.fake',
126
- // units: 2
127
- // }
141
+ // Subscribe to table update events
142
+ db.events().subscribe(EventTypes.TABLE_UPDATE, (eventData: EventData) => {
143
+ console.log('Table updated:', eventData.table)
144
+ console.log('New data:', eventData.data)
145
+ })
146
+
147
+ // Subscribe to new data persistence events
148
+ db.events().subscribe(EventTypes.TABLE_PERSIST, (eventData: EventData) => {
149
+ console.log('New data added to table:', eventData.table)
150
+ console.log('Data:', eventData.data)
151
+ })
152
+
153
+ // Unsubscribe from an event
154
+ const myCallback = (eventData: EventData) => {
155
+ // Handle event
156
+ }
157
+ db.events().subscribe(EventTypes.TABLE_UPDATE, myCallback)
158
+ // Later, when you want to unsubscribe:
159
+ db.events().unsubscribe(EventTypes.TABLE_UPDATE, myCallback)
160
+
161
+ // Close WebSocket connection when done
162
+ db.events().closeEvents()
128
163
  ```
129
164
 
130
- ### Transfer Units Between Two Users
165
+ The `EventData` object contains:
131
166
 
132
- As said before, `unit` property present in each user's account can be anything the project wants, it can be a type of currency, item, resource.
167
+ - `event_type`: The type of event (TableUpdate, TablePersist)
168
+ - `database`: The database name
169
+ - `table`: The table name
170
+ - `data`: The data associated with the event
171
+ - `timestamp`: When the event occurred
133
172
 
134
- Below is an example of user `wenderson` trying to send 2 units to `suly`:
173
+ ### Querying Data
135
174
 
136
- ```ts
137
- const wenderson_id = 'b2e4e7c15f733d8c18836ffd22051ed855226d9041fb9452f17f498fc2bcbce3'
138
- const suly_id = '136c406933d98e5c8bb4820f5145869bb5ad40647b768de4e9adb2a52d0dea2f'
175
+ #### Basic Queries
139
176
 
140
- const wenderson_data = await db.get_user_account_by_id(wenderson_id)
141
- const units_to_transfer = 2
177
+ ```typescript
178
+ // Find items with exact matches
179
+ const users = await userTable.findWhere(
180
+ { active: true, name: 'John' }, // criteria
181
+ 10, // limit (default: 1000)
182
+ true // reverse order (default: true)
183
+ )
184
+ ```
142
185
 
143
- if (wenderson_data.data!.units >= units_to_transfer) {
144
- const res = await db.transfer_units(wenderson_id, suly_id, units_to_transfer)
145
- console.log(res.success)
146
- // true / false
147
- }
186
+ #### Advanced Queries
187
+
188
+ ```typescript
189
+ import { Operators } from 'chain-db-ts'
190
+
191
+ // Find items with advanced criteria
192
+ const users = await userTable.findWhereAdvanced(
193
+ [
194
+ {
195
+ field: 'name',
196
+ operator: Operators.CONTAINS,
197
+ value: 'John',
198
+ },
199
+ {
200
+ field: 'age',
201
+ operator: Operators.GREATER_THAN,
202
+ value: 25,
203
+ },
204
+ ],
205
+ 10, // limit
206
+ true // reverse order
207
+ )
148
208
  ```
149
209
 
150
- ### Fetching the Latest Units Transfer Record
210
+ Available operators:
211
+
212
+ - `EQUAL` (==)
213
+ - `NOT_EQUAL` (!=)
214
+ - `GREATER_THAN` (>)
215
+ - `GREATER_THAN_OR_EQUAL` (>=)
216
+ - `LESS_THAN` (<)
217
+ - `LESS_THAN_OR_EQUAL` (<=)
218
+ - `CONTAINS` (for strings and arrays)
219
+ - `STARTS_WITH` (for strings)
220
+ - `ENDS_WITH` (for strings)
221
+
222
+ ### Other Table Methods
151
223
 
152
- Use this feature to get the last unit transfer record involving a user.
224
+ ```typescript
225
+ // Check if a table is empty
226
+ const isEmpty = greetingTable.isEmpty()
153
227
 
154
- ```ts
155
- const wenderson_id = 'b2e4e7c15f733d8c18836ffd22051ed855226d9041fb9452f17f498fc2bcbce3'
156
- const last_units_transference_record = await db.get_transfer_by_user_id(wenderson_id)
157
- console.log(last_units_transference_record.data)
158
- // {
159
- // from: 'b2e4e7c15f733d8c18836ffd22051ed855226d9041fb9452f17f498fc2bcbce3',
160
- // to: '136c406933d98e5c8bb4820f5145869bb5ad40647b768de4e9adb2a52d0dea2f',
161
- // units: 2
162
- // }
228
+ // Get the table name
229
+ const tableName = greetingTable.getName()
230
+
231
+ // Refetch the table data from the database
232
+ await greetingTable.refetch()
163
233
  ```
164
234
 
165
- ### Fetching All the Transfer of Units Records
235
+ ## Complete Example
166
236
 
167
- Use this feature to get the last unit transfer record involving a user.
237
+ ```typescript
238
+ import { connect, EventTypes, EventData } from 'chain-db-ts'
168
239
 
169
- ```ts
170
- const wenderson_id = 'b2e4e7c15f733d8c18836ffd22051ed855226d9041fb9452f17f498fc2bcbce3'
171
- const all_units_transfers_record = await db.get_all_transfers_by_user_id(wenderson_id)
172
- console.log(all_units_transfers_record.data)
173
- // [
174
- // {
175
- // from: 'b2e4e7c15f733d8c18836ffd22051ed855226d9041fb9452f17f498fc2bcbce3',
176
- // to: '136c406933d98e5c8bb4820f5145869bb5ad40647b768de4e9adb2a52d0dea2f',
177
- // units: 2
178
- // },
179
- // {
180
- // from: '136c406933d98e5c8bb4820f5145869bb5ad40647b768de4e9adb2a52d0dea2f',
181
- // to: 'b2e4e7c15f733d8c18836ffd22051ed855226d9041fb9452f17f498fc2bcbce3',
182
- // units: 6
183
- // },
184
- // ...
185
- // ]
240
+ // Define table structure
241
+ interface GreetingTable {
242
+ greeting: string
243
+ }
244
+
245
+ async function main() {
246
+ // Connect to Chain DB
247
+ const db = await connect({
248
+ server: 'http://localhost:2818',
249
+ database: 'test-db',
250
+ user: 'root',
251
+ password: '1234',
252
+ })
253
+
254
+ // Get the "greeting" table
255
+ const greetingTable = await db.getTable<GreetingTable>('greeting')
256
+ console.log(greetingTable.currentDoc) // e.g., { greeting: 'Hi' }
257
+
258
+ // Subscribe to table update events
259
+ db.events().subscribe(EventTypes.TABLE_UPDATE, (eventData: EventData) => {
260
+ if (eventData.table === 'greeting') {
261
+ console.log('Greeting table updated:', eventData.data)
262
+ }
263
+ })
264
+
265
+ // Modify and persist data
266
+ greetingTable.currentDoc.greeting = 'Hello my dear!'
267
+ const persistResult = await greetingTable.persist() // Data is persisted on database
268
+
269
+ // Get the doc_id of the newly created document
270
+ console.log('New document ID:', persistResult.doc_id)
271
+
272
+ // You can also get the current document ID directly from the table
273
+ const currentDocId = greetingTable.getCurrentDocId()
274
+ console.log('Current document ID:', currentDocId)
275
+
276
+ // See the updated values
277
+ console.log(greetingTable.currentDoc) // { greeting: 'Hello my dear!', doc_id: '...' }
278
+
279
+ // Get a specific document by its ID
280
+ // We can use the ID we just got from the persist operation
281
+ const specificDoc = await greetingTable.getDoc(currentDocId)
282
+
283
+ // Access the document data and ID
284
+ console.log(specificDoc.doc) // { greeting: 'Hello my dear!', doc_id: '...' }
285
+ console.log(specificDoc.doc.doc_id) // Same as currentDocId
286
+
287
+ // Update a specific document
288
+ specificDoc.doc.greeting = 'Updated specific document'
289
+ await specificDoc.update() // Updates only this specific document
290
+
291
+ // Refetch the document to get the latest data
292
+ await specificDoc.refetch()
293
+ console.log(specificDoc.doc) // Latest data from the database
294
+
295
+ // Get the last 100 changes
296
+ const greetingHistory = await greetingTable.getHistory(100)
297
+ console.log(greetingHistory)
298
+ // [
299
+ // { greeting: 'Updated specific document' },
300
+ // { greeting: 'Hello my dear!' },
301
+ // { greeting: 'Hi' },
302
+ // ...
303
+ // ]
304
+
305
+ // Close WebSocket connection when done
306
+ db.events().closeEvents()
307
+ }
308
+
309
+ main().catch(console.error)
186
310
  ```
311
+
312
+ ## License
313
+
314
+ MIT
@@ -1,6 +0,0 @@
1
- export declare class Access {
2
- user: string;
3
- password: string;
4
- constructor(user: string, password: string);
5
- parse: (data_base: string, table_name: string) => string;
6
- }
@@ -1,22 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- exports.__esModule = true;
6
- exports.Access = void 0;
7
- var sha256_1 = __importDefault(require("sha256"));
8
- var Access = /** @class */ (function () {
9
- function Access(user, password) {
10
- var _this = this;
11
- this.user = '';
12
- this.password = '';
13
- this.parse = function (data_base, table_name) {
14
- var access_info = "".concat(data_base).concat(table_name).concat(_this.user).concat(_this.password);
15
- return (0, sha256_1["default"])(access_info);
16
- };
17
- this.user = user;
18
- this.password = password;
19
- }
20
- return Access;
21
- }());
22
- exports.Access = Access;
@@ -1,6 +0,0 @@
1
- export declare class Access {
2
- user: string;
3
- password: string;
4
- constructor(user: string, password: string);
5
- parse: (data_base: string, table_name: string) => string;
6
- }
@@ -1,16 +0,0 @@
1
- import sha256 from 'sha256';
2
- var Access = /** @class */ (function () {
3
- function Access(user, password) {
4
- var _this = this;
5
- this.user = '';
6
- this.password = '';
7
- this.parse = function (data_base, table_name) {
8
- var access_info = "".concat(data_base).concat(table_name).concat(_this.user).concat(_this.password);
9
- return sha256(access_info);
10
- };
11
- this.user = user;
12
- this.password = password;
13
- }
14
- return Access;
15
- }());
16
- export { Access };