@twin.org/entity-storage-connector-postgresql 0.0.2-next.9 → 0.0.3-next.10
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/README.md +7 -12
- package/dist/es/index.js +6 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IPostgreSqlEntityStorageConnectorConfig.js +4 -0
- package/dist/es/models/IPostgreSqlEntityStorageConnectorConfig.js.map +1 -0
- package/dist/es/models/IPostgreSqlEntityStorageConnectorConstructorOptions.js +2 -0
- package/dist/es/models/IPostgreSqlEntityStorageConnectorConstructorOptions.js.map +1 -0
- package/dist/es/postgreSqlEntityStorageConnector.js +969 -0
- package/dist/es/postgreSqlEntityStorageConnector.js.map +1 -0
- package/dist/types/index.d.ts +3 -3
- package/dist/types/models/IPostgreSqlEntityStorageConnectorConstructorOptions.d.ts +5 -1
- package/dist/types/postgreSqlEntityStorageConnector.d.ts +47 -8
- package/docs/changelog.md +220 -31
- package/docs/examples.md +98 -1
- package/docs/reference/classes/PostgreSqlEntityStorageConnector.md +172 -22
- package/docs/reference/interfaces/IPostgreSqlEntityStorageConnectorConfig.md +7 -7
- package/docs/reference/interfaces/IPostgreSqlEntityStorageConnectorConstructorOptions.md +12 -4
- package/locales/en.json +17 -3
- package/package.json +15 -12
- package/dist/cjs/index.cjs +0 -523
- package/dist/esm/index.mjs +0 -521
|
@@ -34,19 +34,15 @@ The options for the connector.
|
|
|
34
34
|
|
|
35
35
|
## Properties
|
|
36
36
|
|
|
37
|
-
### CLASS\_NAME
|
|
37
|
+
### CLASS\_NAME {#class_name}
|
|
38
38
|
|
|
39
|
-
> `readonly` **CLASS\_NAME**: `string`
|
|
39
|
+
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
40
40
|
|
|
41
41
|
Runtime name for the class.
|
|
42
42
|
|
|
43
|
-
#### Implementation of
|
|
44
|
-
|
|
45
|
-
`IEntityStorageConnector.CLASS_NAME`
|
|
46
|
-
|
|
47
43
|
## Methods
|
|
48
44
|
|
|
49
|
-
### bootstrap()
|
|
45
|
+
### bootstrap() {#bootstrap}
|
|
50
46
|
|
|
51
47
|
> **bootstrap**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
|
|
52
48
|
|
|
@@ -72,7 +68,61 @@ A promise that resolves to a boolean indicating success.
|
|
|
72
68
|
|
|
73
69
|
***
|
|
74
70
|
|
|
75
|
-
###
|
|
71
|
+
### className() {#classname}
|
|
72
|
+
|
|
73
|
+
> **className**(): `string`
|
|
74
|
+
|
|
75
|
+
Returns the class name of the component.
|
|
76
|
+
|
|
77
|
+
#### Returns
|
|
78
|
+
|
|
79
|
+
`string`
|
|
80
|
+
|
|
81
|
+
The class name of the component.
|
|
82
|
+
|
|
83
|
+
#### Implementation of
|
|
84
|
+
|
|
85
|
+
`IEntityStorageConnector.className`
|
|
86
|
+
|
|
87
|
+
***
|
|
88
|
+
|
|
89
|
+
### health() {#health}
|
|
90
|
+
|
|
91
|
+
> **health**(): `Promise`\<`IHealth`[]\>
|
|
92
|
+
|
|
93
|
+
Get the health of the component.
|
|
94
|
+
|
|
95
|
+
#### Returns
|
|
96
|
+
|
|
97
|
+
`Promise`\<`IHealth`[]\>
|
|
98
|
+
|
|
99
|
+
The health of the component.
|
|
100
|
+
|
|
101
|
+
#### Implementation of
|
|
102
|
+
|
|
103
|
+
`IEntityStorageConnector.health`
|
|
104
|
+
|
|
105
|
+
***
|
|
106
|
+
|
|
107
|
+
### stop() {#stop}
|
|
108
|
+
|
|
109
|
+
> **stop**(): `Promise`\<`void`\>
|
|
110
|
+
|
|
111
|
+
The component needs to be stopped when the node is closed.
|
|
112
|
+
|
|
113
|
+
#### Returns
|
|
114
|
+
|
|
115
|
+
`Promise`\<`void`\>
|
|
116
|
+
|
|
117
|
+
Nothing.
|
|
118
|
+
|
|
119
|
+
#### Implementation of
|
|
120
|
+
|
|
121
|
+
`IEntityStorageConnector.stop`
|
|
122
|
+
|
|
123
|
+
***
|
|
124
|
+
|
|
125
|
+
### getSchema() {#getschema}
|
|
76
126
|
|
|
77
127
|
> **getSchema**(): `IEntitySchema`
|
|
78
128
|
|
|
@@ -90,9 +140,9 @@ The schema for the entities.
|
|
|
90
140
|
|
|
91
141
|
***
|
|
92
142
|
|
|
93
|
-
### get()
|
|
143
|
+
### get() {#get}
|
|
94
144
|
|
|
95
|
-
> **get**(`id`, `secondaryIndex?`, `conditions?`): `Promise`\<`
|
|
145
|
+
> **get**(`id`, `secondaryIndex?`, `conditions?`): `Promise`\<`T` \| `undefined`\>
|
|
96
146
|
|
|
97
147
|
Get an entity from PostgreSql.
|
|
98
148
|
|
|
@@ -118,7 +168,7 @@ The optional conditions to match for the entities.
|
|
|
118
168
|
|
|
119
169
|
#### Returns
|
|
120
170
|
|
|
121
|
-
`Promise`\<`
|
|
171
|
+
`Promise`\<`T` \| `undefined`\>
|
|
122
172
|
|
|
123
173
|
The object if it can be found or undefined.
|
|
124
174
|
|
|
@@ -128,7 +178,7 @@ The object if it can be found or undefined.
|
|
|
128
178
|
|
|
129
179
|
***
|
|
130
180
|
|
|
131
|
-
### set()
|
|
181
|
+
### set() {#set}
|
|
132
182
|
|
|
133
183
|
> **set**(`entity`, `conditions?`): `Promise`\<`void`\>
|
|
134
184
|
|
|
@@ -160,7 +210,51 @@ The id of the entity.
|
|
|
160
210
|
|
|
161
211
|
***
|
|
162
212
|
|
|
163
|
-
###
|
|
213
|
+
### setBatch() {#setbatch}
|
|
214
|
+
|
|
215
|
+
> **setBatch**(`entities`): `Promise`\<`void`\>
|
|
216
|
+
|
|
217
|
+
Set multiple entities in a batch.
|
|
218
|
+
|
|
219
|
+
#### Parameters
|
|
220
|
+
|
|
221
|
+
##### entities
|
|
222
|
+
|
|
223
|
+
`T`[]
|
|
224
|
+
|
|
225
|
+
The entities to set.
|
|
226
|
+
|
|
227
|
+
#### Returns
|
|
228
|
+
|
|
229
|
+
`Promise`\<`void`\>
|
|
230
|
+
|
|
231
|
+
Nothing.
|
|
232
|
+
|
|
233
|
+
#### Implementation of
|
|
234
|
+
|
|
235
|
+
`IEntityStorageConnector.setBatch`
|
|
236
|
+
|
|
237
|
+
***
|
|
238
|
+
|
|
239
|
+
### empty() {#empty}
|
|
240
|
+
|
|
241
|
+
> **empty**(): `Promise`\<`void`\>
|
|
242
|
+
|
|
243
|
+
Empty all the entities.
|
|
244
|
+
|
|
245
|
+
#### Returns
|
|
246
|
+
|
|
247
|
+
`Promise`\<`void`\>
|
|
248
|
+
|
|
249
|
+
Nothing.
|
|
250
|
+
|
|
251
|
+
#### Implementation of
|
|
252
|
+
|
|
253
|
+
`IEntityStorageConnector.empty`
|
|
254
|
+
|
|
255
|
+
***
|
|
256
|
+
|
|
257
|
+
### remove() {#remove}
|
|
164
258
|
|
|
165
259
|
> **remove**(`id`, `conditions?`): `Promise`\<`void`\>
|
|
166
260
|
|
|
@@ -192,9 +286,61 @@ Nothing.
|
|
|
192
286
|
|
|
193
287
|
***
|
|
194
288
|
|
|
195
|
-
###
|
|
289
|
+
### removeBatch() {#removebatch}
|
|
290
|
+
|
|
291
|
+
> **removeBatch**(`ids`): `Promise`\<`void`\>
|
|
292
|
+
|
|
293
|
+
Remove multiple entities by their primary key IDs.
|
|
294
|
+
|
|
295
|
+
#### Parameters
|
|
296
|
+
|
|
297
|
+
##### ids
|
|
298
|
+
|
|
299
|
+
`string`[]
|
|
300
|
+
|
|
301
|
+
The ids of the entities to remove.
|
|
302
|
+
|
|
303
|
+
#### Returns
|
|
304
|
+
|
|
305
|
+
`Promise`\<`void`\>
|
|
306
|
+
|
|
307
|
+
Nothing.
|
|
308
|
+
|
|
309
|
+
#### Implementation of
|
|
196
310
|
|
|
197
|
-
|
|
311
|
+
`IEntityStorageConnector.removeBatch`
|
|
312
|
+
|
|
313
|
+
***
|
|
314
|
+
|
|
315
|
+
### teardown() {#teardown}
|
|
316
|
+
|
|
317
|
+
> **teardown**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
|
|
318
|
+
|
|
319
|
+
Teardown the entity storage by dropping the table.
|
|
320
|
+
|
|
321
|
+
#### Parameters
|
|
322
|
+
|
|
323
|
+
##### nodeLoggingComponentType?
|
|
324
|
+
|
|
325
|
+
`string`
|
|
326
|
+
|
|
327
|
+
The node logging component type.
|
|
328
|
+
|
|
329
|
+
#### Returns
|
|
330
|
+
|
|
331
|
+
`Promise`\<`boolean`\>
|
|
332
|
+
|
|
333
|
+
True if the teardown process was successful.
|
|
334
|
+
|
|
335
|
+
#### Implementation of
|
|
336
|
+
|
|
337
|
+
`IEntityStorageConnector.teardown`
|
|
338
|
+
|
|
339
|
+
***
|
|
340
|
+
|
|
341
|
+
### query() {#query}
|
|
342
|
+
|
|
343
|
+
> **query**(`conditions?`, `sortProperties?`, `properties?`, `cursor?`, `limit?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
|
|
198
344
|
|
|
199
345
|
Find all the entities which match the conditions.
|
|
200
346
|
|
|
@@ -222,9 +368,9 @@ The optional properties to return, defaults to all.
|
|
|
222
368
|
|
|
223
369
|
`string`
|
|
224
370
|
|
|
225
|
-
The cursor to request the next
|
|
371
|
+
The cursor to request the next chunk of entities.
|
|
226
372
|
|
|
227
|
-
#####
|
|
373
|
+
##### limit?
|
|
228
374
|
|
|
229
375
|
`number`
|
|
230
376
|
|
|
@@ -243,14 +389,18 @@ and a cursor which can be used to request more entities.
|
|
|
243
389
|
|
|
244
390
|
***
|
|
245
391
|
|
|
246
|
-
###
|
|
392
|
+
### count() {#count}
|
|
247
393
|
|
|
248
|
-
> **
|
|
394
|
+
> **count**(): `Promise`\<`number`\>
|
|
249
395
|
|
|
250
|
-
|
|
396
|
+
Count all the entities which match the conditions.
|
|
251
397
|
|
|
252
398
|
#### Returns
|
|
253
399
|
|
|
254
|
-
`Promise`\<`
|
|
400
|
+
`Promise`\<`number`\>
|
|
255
401
|
|
|
256
|
-
|
|
402
|
+
The total count of entities in the storage.
|
|
403
|
+
|
|
404
|
+
#### Implementation of
|
|
405
|
+
|
|
406
|
+
`IEntityStorageConnector.count`
|
|
@@ -4,7 +4,7 @@ Configuration for the PostgreSql Entity Storage Connector.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### host
|
|
7
|
+
### host {#host}
|
|
8
8
|
|
|
9
9
|
> **host**: `string`
|
|
10
10
|
|
|
@@ -12,15 +12,15 @@ The host for the PostgreSql instance.
|
|
|
12
12
|
|
|
13
13
|
***
|
|
14
14
|
|
|
15
|
-
### port?
|
|
15
|
+
### port? {#port}
|
|
16
16
|
|
|
17
|
-
> `optional` **port
|
|
17
|
+
> `optional` **port?**: `number`
|
|
18
18
|
|
|
19
19
|
The port for the PostgreSql instance.
|
|
20
20
|
|
|
21
21
|
***
|
|
22
22
|
|
|
23
|
-
### user
|
|
23
|
+
### user {#user}
|
|
24
24
|
|
|
25
25
|
> **user**: `string`
|
|
26
26
|
|
|
@@ -28,7 +28,7 @@ The user for the PostgreSql instance.
|
|
|
28
28
|
|
|
29
29
|
***
|
|
30
30
|
|
|
31
|
-
### password
|
|
31
|
+
### password {#password}
|
|
32
32
|
|
|
33
33
|
> **password**: `string`
|
|
34
34
|
|
|
@@ -36,7 +36,7 @@ The password for the PostgreSql instance.
|
|
|
36
36
|
|
|
37
37
|
***
|
|
38
38
|
|
|
39
|
-
### database
|
|
39
|
+
### database {#database}
|
|
40
40
|
|
|
41
41
|
> **database**: `string`
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ The name of the database to be used.
|
|
|
44
44
|
|
|
45
45
|
***
|
|
46
46
|
|
|
47
|
-
### tableName
|
|
47
|
+
### tableName {#tablename}
|
|
48
48
|
|
|
49
49
|
> **tableName**: `string`
|
|
50
50
|
|
|
@@ -4,7 +4,7 @@ The options for the PostgreSql entity storage connector constructor.
|
|
|
4
4
|
|
|
5
5
|
## Properties
|
|
6
6
|
|
|
7
|
-
### entitySchema
|
|
7
|
+
### entitySchema {#entityschema}
|
|
8
8
|
|
|
9
9
|
> **entitySchema**: `string`
|
|
10
10
|
|
|
@@ -12,9 +12,17 @@ The schema for the entity.
|
|
|
12
12
|
|
|
13
13
|
***
|
|
14
14
|
|
|
15
|
-
###
|
|
15
|
+
### partitionContextIds? {#partitioncontextids}
|
|
16
16
|
|
|
17
|
-
> `optional` **
|
|
17
|
+
> `optional` **partitionContextIds?**: `string`[]
|
|
18
|
+
|
|
19
|
+
The keys to use from the context ids to create partitions.
|
|
20
|
+
|
|
21
|
+
***
|
|
22
|
+
|
|
23
|
+
### loggingComponentType? {#loggingcomponenttype}
|
|
24
|
+
|
|
25
|
+
> `optional` **loggingComponentType?**: `string`
|
|
18
26
|
|
|
19
27
|
The type of logging component to use.
|
|
20
28
|
|
|
@@ -26,7 +34,7 @@ logging
|
|
|
26
34
|
|
|
27
35
|
***
|
|
28
36
|
|
|
29
|
-
### config
|
|
37
|
+
### config {#config}
|
|
30
38
|
|
|
31
39
|
> **config**: [`IPostgreSqlEntityStorageConnectorConfig`](IPostgreSqlEntityStorageConnectorConfig.md)
|
|
32
40
|
|
package/locales/en.json
CHANGED
|
@@ -3,19 +3,33 @@
|
|
|
3
3
|
"postgreSqlEntityStorageConnector": {
|
|
4
4
|
"databaseCreating": "Database \"{databaseName}\" creating",
|
|
5
5
|
"databaseExists": "Database \"{databaseName}\" created or it already exists",
|
|
6
|
-
"
|
|
6
|
+
"tableCreating": "Table \"{tableName}\" creating",
|
|
7
|
+
"tableExists": "Table \"{tableName}\" created or it already exists",
|
|
8
|
+
"tableDropping": "Dropping table \"{tableName}\"",
|
|
9
|
+
"tableDropped": "Table \"{tableName}\" dropped"
|
|
7
10
|
}
|
|
8
11
|
},
|
|
9
12
|
"error": {
|
|
10
13
|
"postgreSqlEntityStorageConnector": {
|
|
14
|
+
"databaseCreateFailed": "Unable to create database \"{databaseName}\"",
|
|
11
15
|
"setFailed": "Unable to set entity \"{id}\"",
|
|
12
16
|
"getFailed": "Unable to get entity \"{id}\"",
|
|
13
17
|
"removeFailed": "Unable to remove entity \"{id}\"",
|
|
14
18
|
"queryFailed": "The query failed",
|
|
15
19
|
"comparisonNotSupported": "Comparison operator \"{comparison}\" is not supported",
|
|
16
20
|
"conditionalNotSupported": "Conditional operator \"{operator}\" is not supported",
|
|
17
|
-
"
|
|
18
|
-
"
|
|
21
|
+
"entitySchemaPropertiesUndefined": "The entity schema properties are undefined",
|
|
22
|
+
"setBatchFailed": "Unable to set batch of entities",
|
|
23
|
+
"countFailed": "Unable to count entities",
|
|
24
|
+
"emptyFailed": "Unable to empty entity storage",
|
|
25
|
+
"removeBatchFailed": "Unable to remove batch of entities",
|
|
26
|
+
"teardownFailed": "Unable to teardown entity storage"
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
"health": {
|
|
30
|
+
"postgreSqlEntityStorageConnector": {
|
|
31
|
+
"healthDescription": "Checks if the PostgreSQL connection is available",
|
|
32
|
+
"connectionFailed": "Failed to connect to PostgreSQL"
|
|
19
33
|
}
|
|
20
34
|
}
|
|
21
35
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/entity-storage-connector-postgresql",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.0.3-next.10",
|
|
4
|
+
"description": "PostgreSQL connector for relational persistence and advanced SQL features.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/iotaledger/entity-storage.git",
|
|
8
8
|
"directory": "packages/entity-storage-connector-postgresql"
|
|
9
9
|
},
|
|
10
10
|
"author": "adrian.sanchez.sequeira@iota.org",
|
|
@@ -14,27 +14,26 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"@twin.org/context": "next",
|
|
17
18
|
"@twin.org/core": "next",
|
|
18
19
|
"@twin.org/entity": "next",
|
|
19
|
-
"@twin.org/entity-storage-models": "0.0.
|
|
20
|
+
"@twin.org/entity-storage-models": "0.0.3-next.10",
|
|
20
21
|
"@twin.org/logging-models": "next",
|
|
21
22
|
"@twin.org/nameof": "next",
|
|
22
|
-
"postgres": "3.4.
|
|
23
|
+
"postgres": "3.4.8"
|
|
23
24
|
},
|
|
24
|
-
"main": "./dist/
|
|
25
|
-
"module": "./dist/esm/index.mjs",
|
|
25
|
+
"main": "./dist/es/index.js",
|
|
26
26
|
"types": "./dist/types/index.d.ts",
|
|
27
27
|
"exports": {
|
|
28
28
|
".": {
|
|
29
29
|
"types": "./dist/types/index.d.ts",
|
|
30
|
-
"
|
|
31
|
-
"
|
|
30
|
+
"import": "./dist/es/index.js",
|
|
31
|
+
"default": "./dist/es/index.js"
|
|
32
32
|
},
|
|
33
33
|
"./locales/*.json": "./locales/*.json"
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
|
-
"dist/
|
|
37
|
-
"dist/esm",
|
|
36
|
+
"dist/es",
|
|
38
37
|
"dist/types",
|
|
39
38
|
"locales",
|
|
40
39
|
"docs"
|
|
@@ -53,5 +52,9 @@
|
|
|
53
52
|
"connector",
|
|
54
53
|
"adapter",
|
|
55
54
|
"integration"
|
|
56
|
-
]
|
|
55
|
+
],
|
|
56
|
+
"bugs": {
|
|
57
|
+
"url": "git+https://github.com/iotaledger/entity-storage/issues"
|
|
58
|
+
},
|
|
59
|
+
"homepage": "https://twindev.org"
|
|
57
60
|
}
|