@twin.org/entity-storage-connector-mysql 0.0.3-next.9 → 0.9.0
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/es/models/IMySqlEntityStorageConnectorConstructorOptions.js.map +1 -1
- package/dist/es/mysqlEntityStorageConnector.js +368 -66
- package/dist/es/mysqlEntityStorageConnector.js.map +1 -1
- package/dist/types/models/IMySqlEntityStorageConnectorConstructorOptions.d.ts +0 -1
- package/dist/types/mysqlEntityStorageConnector.d.ts +61 -14
- package/docs/changelog.md +635 -64
- package/docs/reference/classes/MySqlEntityStorageConnector.md +268 -18
- package/docs/reference/interfaces/IMySqlEntityStorageConnectorConstructorOptions.md +0 -6
- package/locales/en.json +17 -2
- package/package.json +11 -11
|
@@ -10,7 +10,7 @@ Class for performing entity storage operations using MySql.
|
|
|
10
10
|
|
|
11
11
|
## Implements
|
|
12
12
|
|
|
13
|
-
- `
|
|
13
|
+
- `IEntityStorageMigrationConnector`\<`T`\>
|
|
14
14
|
|
|
15
15
|
## Constructors
|
|
16
16
|
|
|
@@ -56,7 +56,25 @@ The class name of the component.
|
|
|
56
56
|
|
|
57
57
|
#### Implementation of
|
|
58
58
|
|
|
59
|
-
`
|
|
59
|
+
`IEntityStorageMigrationConnector.className`
|
|
60
|
+
|
|
61
|
+
***
|
|
62
|
+
|
|
63
|
+
### health() {#health}
|
|
64
|
+
|
|
65
|
+
> **health**(): `Promise`\<`IHealth`[]\>
|
|
66
|
+
|
|
67
|
+
Get the health of the component.
|
|
68
|
+
|
|
69
|
+
#### Returns
|
|
70
|
+
|
|
71
|
+
`Promise`\<`IHealth`[]\>
|
|
72
|
+
|
|
73
|
+
The health of the component.
|
|
74
|
+
|
|
75
|
+
#### Implementation of
|
|
76
|
+
|
|
77
|
+
`IEntityStorageMigrationConnector.health`
|
|
60
78
|
|
|
61
79
|
***
|
|
62
80
|
|
|
@@ -74,7 +92,7 @@ The schema for the entities.
|
|
|
74
92
|
|
|
75
93
|
#### Implementation of
|
|
76
94
|
|
|
77
|
-
`
|
|
95
|
+
`IEntityStorageMigrationConnector.getSchema`
|
|
78
96
|
|
|
79
97
|
***
|
|
80
98
|
|
|
@@ -100,7 +118,7 @@ A promise that resolves to a boolean indicating success.
|
|
|
100
118
|
|
|
101
119
|
#### Implementation of
|
|
102
120
|
|
|
103
|
-
`
|
|
121
|
+
`IEntityStorageMigrationConnector.bootstrap`
|
|
104
122
|
|
|
105
123
|
***
|
|
106
124
|
|
|
@@ -126,7 +144,7 @@ Nothing.
|
|
|
126
144
|
|
|
127
145
|
#### Implementation of
|
|
128
146
|
|
|
129
|
-
`
|
|
147
|
+
`IEntityStorageMigrationConnector.stop`
|
|
130
148
|
|
|
131
149
|
***
|
|
132
150
|
|
|
@@ -164,7 +182,7 @@ The object if it can be found or undefined.
|
|
|
164
182
|
|
|
165
183
|
#### Implementation of
|
|
166
184
|
|
|
167
|
-
`
|
|
185
|
+
`IEntityStorageMigrationConnector.get`
|
|
168
186
|
|
|
169
187
|
***
|
|
170
188
|
|
|
@@ -196,7 +214,51 @@ The id of the entity.
|
|
|
196
214
|
|
|
197
215
|
#### Implementation of
|
|
198
216
|
|
|
199
|
-
`
|
|
217
|
+
`IEntityStorageMigrationConnector.set`
|
|
218
|
+
|
|
219
|
+
***
|
|
220
|
+
|
|
221
|
+
### setBatch() {#setbatch}
|
|
222
|
+
|
|
223
|
+
> **setBatch**(`entities`): `Promise`\<`void`\>
|
|
224
|
+
|
|
225
|
+
Set multiple entities in a batch.
|
|
226
|
+
|
|
227
|
+
#### Parameters
|
|
228
|
+
|
|
229
|
+
##### entities
|
|
230
|
+
|
|
231
|
+
`T`[]
|
|
232
|
+
|
|
233
|
+
The entities to set.
|
|
234
|
+
|
|
235
|
+
#### Returns
|
|
236
|
+
|
|
237
|
+
`Promise`\<`void`\>
|
|
238
|
+
|
|
239
|
+
Nothing.
|
|
240
|
+
|
|
241
|
+
#### Implementation of
|
|
242
|
+
|
|
243
|
+
`IEntityStorageMigrationConnector.setBatch`
|
|
244
|
+
|
|
245
|
+
***
|
|
246
|
+
|
|
247
|
+
### empty() {#empty}
|
|
248
|
+
|
|
249
|
+
> **empty**(): `Promise`\<`void`\>
|
|
250
|
+
|
|
251
|
+
Empty the entity storage.
|
|
252
|
+
|
|
253
|
+
#### Returns
|
|
254
|
+
|
|
255
|
+
`Promise`\<`void`\>
|
|
256
|
+
|
|
257
|
+
Nothing.
|
|
258
|
+
|
|
259
|
+
#### Implementation of
|
|
260
|
+
|
|
261
|
+
`IEntityStorageMigrationConnector.empty`
|
|
200
262
|
|
|
201
263
|
***
|
|
202
264
|
|
|
@@ -228,7 +290,59 @@ Nothing.
|
|
|
228
290
|
|
|
229
291
|
#### Implementation of
|
|
230
292
|
|
|
231
|
-
`
|
|
293
|
+
`IEntityStorageMigrationConnector.remove`
|
|
294
|
+
|
|
295
|
+
***
|
|
296
|
+
|
|
297
|
+
### teardown() {#teardown}
|
|
298
|
+
|
|
299
|
+
> **teardown**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
|
|
300
|
+
|
|
301
|
+
Teardown the entity storage by dropping the table.
|
|
302
|
+
|
|
303
|
+
#### Parameters
|
|
304
|
+
|
|
305
|
+
##### nodeLoggingComponentType?
|
|
306
|
+
|
|
307
|
+
`string`
|
|
308
|
+
|
|
309
|
+
The node logging component type.
|
|
310
|
+
|
|
311
|
+
#### Returns
|
|
312
|
+
|
|
313
|
+
`Promise`\<`boolean`\>
|
|
314
|
+
|
|
315
|
+
True if the teardown process was successful.
|
|
316
|
+
|
|
317
|
+
#### Implementation of
|
|
318
|
+
|
|
319
|
+
`IEntityStorageMigrationConnector.teardown`
|
|
320
|
+
|
|
321
|
+
***
|
|
322
|
+
|
|
323
|
+
### removeBatch() {#removebatch}
|
|
324
|
+
|
|
325
|
+
> **removeBatch**(`ids`): `Promise`\<`void`\>
|
|
326
|
+
|
|
327
|
+
Remove multiple entities by their primary key IDs.
|
|
328
|
+
|
|
329
|
+
#### Parameters
|
|
330
|
+
|
|
331
|
+
##### ids
|
|
332
|
+
|
|
333
|
+
`string`[]
|
|
334
|
+
|
|
335
|
+
The ids of the entities to remove.
|
|
336
|
+
|
|
337
|
+
#### Returns
|
|
338
|
+
|
|
339
|
+
`Promise`\<`void`\>
|
|
340
|
+
|
|
341
|
+
Nothing.
|
|
342
|
+
|
|
343
|
+
#### Implementation of
|
|
344
|
+
|
|
345
|
+
`IEntityStorageMigrationConnector.removeBatch`
|
|
232
346
|
|
|
233
347
|
***
|
|
234
348
|
|
|
@@ -279,35 +393,171 @@ and a cursor which can be used to request more entities.
|
|
|
279
393
|
|
|
280
394
|
#### Implementation of
|
|
281
395
|
|
|
282
|
-
`
|
|
396
|
+
`IEntityStorageMigrationConnector.query`
|
|
283
397
|
|
|
284
398
|
***
|
|
285
399
|
|
|
286
|
-
###
|
|
400
|
+
### count() {#count}
|
|
401
|
+
|
|
402
|
+
> **count**(`conditions?`): `Promise`\<`number`\>
|
|
287
403
|
|
|
288
|
-
|
|
404
|
+
Count all the entities which match the conditions.
|
|
289
405
|
|
|
290
|
-
|
|
406
|
+
#### Parameters
|
|
407
|
+
|
|
408
|
+
##### conditions?
|
|
409
|
+
|
|
410
|
+
`EntityCondition`\<`T`\>
|
|
411
|
+
|
|
412
|
+
The optional conditions to match for the entities.
|
|
291
413
|
|
|
292
414
|
#### Returns
|
|
293
415
|
|
|
294
|
-
`Promise`\<`
|
|
416
|
+
`Promise`\<`number`\>
|
|
295
417
|
|
|
296
|
-
|
|
418
|
+
The total count of entities in the storage.
|
|
419
|
+
|
|
420
|
+
#### Implementation of
|
|
421
|
+
|
|
422
|
+
`IEntityStorageMigrationConnector.count`
|
|
423
|
+
|
|
424
|
+
***
|
|
425
|
+
|
|
426
|
+
### getPartitionContextIds() {#getpartitioncontextids}
|
|
427
|
+
|
|
428
|
+
> **getPartitionContextIds**(): `Promise`\<`IContextIds`[]\>
|
|
429
|
+
|
|
430
|
+
Get all unique partition context ids present in the table.
|
|
431
|
+
|
|
432
|
+
#### Returns
|
|
433
|
+
|
|
434
|
+
`Promise`\<`IContextIds`[]\>
|
|
435
|
+
|
|
436
|
+
An array of context id objects, one per unique partition.
|
|
437
|
+
|
|
438
|
+
#### Implementation of
|
|
439
|
+
|
|
440
|
+
`IEntityStorageMigrationConnector.getPartitionContextIds`
|
|
441
|
+
|
|
442
|
+
***
|
|
443
|
+
|
|
444
|
+
### createTargetConnector() {#createtargetconnector}
|
|
445
|
+
|
|
446
|
+
> **createTargetConnector**\<`U`\>(`newEntitySchema`): `Promise`\<`IEntityStorageConnector`\<`U`\>\>
|
|
447
|
+
|
|
448
|
+
Create the target connector for performing the migration using a temporary table.
|
|
449
|
+
|
|
450
|
+
#### Type Parameters
|
|
451
|
+
|
|
452
|
+
##### U
|
|
453
|
+
|
|
454
|
+
`U`
|
|
455
|
+
|
|
456
|
+
#### Parameters
|
|
457
|
+
|
|
458
|
+
##### newEntitySchema
|
|
459
|
+
|
|
460
|
+
`string`
|
|
461
|
+
|
|
462
|
+
The name of the new entity schema to create the connector for.
|
|
463
|
+
|
|
464
|
+
#### Returns
|
|
465
|
+
|
|
466
|
+
`Promise`\<`IEntityStorageConnector`\<`U`\>\>
|
|
467
|
+
|
|
468
|
+
Connector for performing the migration.
|
|
469
|
+
|
|
470
|
+
#### Implementation of
|
|
471
|
+
|
|
472
|
+
`IEntityStorageMigrationConnector.createTargetConnector`
|
|
473
|
+
|
|
474
|
+
***
|
|
475
|
+
|
|
476
|
+
### finalizeMigration() {#finalizemigration}
|
|
477
|
+
|
|
478
|
+
> **finalizeMigration**\<`U`\>(`targetConnector`, `options?`, `loggingComponentType?`): `Promise`\<`MySqlEntityStorageConnector`\<`U`\>\>
|
|
479
|
+
|
|
480
|
+
Finalize the migration by dropping the source table and renaming the migration table to the original name.
|
|
481
|
+
|
|
482
|
+
#### Type Parameters
|
|
483
|
+
|
|
484
|
+
##### U
|
|
485
|
+
|
|
486
|
+
`U`
|
|
487
|
+
|
|
488
|
+
#### Parameters
|
|
489
|
+
|
|
490
|
+
##### targetConnector
|
|
491
|
+
|
|
492
|
+
`MySqlEntityStorageConnector`\<`U`\>
|
|
493
|
+
|
|
494
|
+
The connector holding the migrated data in a temporary table.
|
|
495
|
+
|
|
496
|
+
##### options?
|
|
497
|
+
|
|
498
|
+
`IMigrationOptions`
|
|
499
|
+
|
|
500
|
+
The options to control how the migration is finalized.
|
|
501
|
+
|
|
502
|
+
##### loggingComponentType?
|
|
503
|
+
|
|
504
|
+
`string`
|
|
505
|
+
|
|
506
|
+
The logging component type to use during finalization.
|
|
507
|
+
|
|
508
|
+
#### Returns
|
|
509
|
+
|
|
510
|
+
`Promise`\<`MySqlEntityStorageConnector`\<`U`\>\>
|
|
511
|
+
|
|
512
|
+
The final connector using the original table name with the new schema.
|
|
513
|
+
|
|
514
|
+
#### Implementation of
|
|
515
|
+
|
|
516
|
+
`IEntityStorageMigrationConnector.finalizeMigration`
|
|
297
517
|
|
|
298
518
|
***
|
|
299
519
|
|
|
300
|
-
###
|
|
520
|
+
### cleanupMigration() {#cleanupmigration}
|
|
521
|
+
|
|
522
|
+
> **cleanupMigration**\<`U`\>(`targetConnector`, `options?`, `loggingComponentType?`): `Promise`\<`void`\>
|
|
523
|
+
|
|
524
|
+
Cleanup a failed or aborted migration by dropping the temporary migration table.
|
|
525
|
+
|
|
526
|
+
#### Type Parameters
|
|
527
|
+
|
|
528
|
+
##### U
|
|
529
|
+
|
|
530
|
+
`U`
|
|
531
|
+
|
|
532
|
+
#### Parameters
|
|
533
|
+
|
|
534
|
+
##### targetConnector
|
|
301
535
|
|
|
302
|
-
|
|
536
|
+
`IEntityStorageConnector`\<`U`\> \| `undefined`
|
|
303
537
|
|
|
304
|
-
|
|
538
|
+
The target connector to cleanup.
|
|
539
|
+
|
|
540
|
+
##### options?
|
|
541
|
+
|
|
542
|
+
`IMigrationOptions`
|
|
543
|
+
|
|
544
|
+
The options to control how the migration is cleaned up.
|
|
545
|
+
|
|
546
|
+
##### loggingComponentType?
|
|
547
|
+
|
|
548
|
+
`string`
|
|
549
|
+
|
|
550
|
+
The optional component type to use for logging.
|
|
305
551
|
|
|
306
552
|
#### Returns
|
|
307
553
|
|
|
308
554
|
`Promise`\<`void`\>
|
|
309
555
|
|
|
310
|
-
|
|
556
|
+
A promise that resolves when the cleanup is complete.
|
|
557
|
+
|
|
558
|
+
#### Implementation of
|
|
559
|
+
|
|
560
|
+
`IEntityStorageMigrationConnector.cleanupMigration`
|
|
311
561
|
|
|
312
562
|
***
|
|
313
563
|
|
package/locales/en.json
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
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"
|
|
7
|
+
"tableExists": "Table \"{tableName}\" created or it already exists",
|
|
8
|
+
"tableDropping": "Dropping table \"{tableName}\"",
|
|
9
|
+
"tableDropped": "Table \"{tableName}\" dropped"
|
|
8
10
|
}
|
|
9
11
|
},
|
|
10
12
|
"error": {
|
|
@@ -16,7 +18,20 @@
|
|
|
16
18
|
"comparisonNotSupported": "Comparison operator \"{comparison}\" is not supported",
|
|
17
19
|
"conditionalNotSupported": "Conditional operator \"{operator}\" is not supported",
|
|
18
20
|
"entitySchemaPropertiesUndefined": "The entity schema properties are undefined",
|
|
19
|
-
"databaseCreateFailed": "Unable to create database \"{databaseName}\""
|
|
21
|
+
"databaseCreateFailed": "Unable to create database \"{databaseName}\"",
|
|
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
|
+
"getPartitionContextIdsFailed": "Unable to get partition context ids",
|
|
28
|
+
"finalizeMigrationFailedBootstrap": "Finalizing migration failed during bootstrap phase"
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"health": {
|
|
32
|
+
"mySqlEntityStorageConnector": {
|
|
33
|
+
"healthDescription": "Checks if the MySQL table \"{tableName}\" in database \"{database}\" is available",
|
|
34
|
+
"connectionFailed": "Failed to connect to MySQL table \"{tableName}\" in database \"{database}\""
|
|
20
35
|
}
|
|
21
36
|
}
|
|
22
37
|
}
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/entity-storage-connector-mysql",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "MySQL connector for relational persistence with SQL querying.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
|
-
"url": "git+https://github.com/
|
|
7
|
+
"url": "git+https://github.com/iotaledger/twin-entity-storage.git",
|
|
8
8
|
"directory": "packages/entity-storage-connector-mysql"
|
|
9
9
|
},
|
|
10
10
|
"author": "adrian.sanchez.sequeira@iota.org",
|
|
@@ -14,14 +14,14 @@
|
|
|
14
14
|
"node": ">=20.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@twin.org/context": "
|
|
18
|
-
"@twin.org/core": "
|
|
19
|
-
"@twin.org/data-json-ld": "
|
|
20
|
-
"@twin.org/entity": "
|
|
21
|
-
"@twin.org/entity-storage-models": "0.0
|
|
22
|
-
"@twin.org/logging-models": "
|
|
23
|
-
"@twin.org/nameof": "
|
|
24
|
-
"mysql2": "3.
|
|
17
|
+
"@twin.org/context": "^0.9.0",
|
|
18
|
+
"@twin.org/core": "^0.9.0",
|
|
19
|
+
"@twin.org/data-json-ld": "^0.9.0",
|
|
20
|
+
"@twin.org/entity": "^0.9.0",
|
|
21
|
+
"@twin.org/entity-storage-models": "^0.9.0",
|
|
22
|
+
"@twin.org/logging-models": "^0.9.0",
|
|
23
|
+
"@twin.org/nameof": "^0.9.0",
|
|
24
|
+
"mysql2": "3.22.5"
|
|
25
25
|
},
|
|
26
26
|
"main": "./dist/es/index.js",
|
|
27
27
|
"types": "./dist/types/index.d.ts",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"integration"
|
|
56
56
|
],
|
|
57
57
|
"bugs": {
|
|
58
|
-
"url": "git+https://github.com/
|
|
58
|
+
"url": "git+https://github.com/iotaledger/twin-entity-storage/issues"
|
|
59
59
|
},
|
|
60
60
|
"homepage": "https://twindev.org"
|
|
61
61
|
}
|