@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.
@@ -10,7 +10,7 @@ Class for performing entity storage operations using MySql.
10
10
 
11
11
  ## Implements
12
12
 
13
- - `IEntityStorageConnector`\<`T`\>
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
- `IEntityStorageConnector.className`
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
- `IEntityStorageConnector.getSchema`
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
- `IEntityStorageConnector.bootstrap`
121
+ `IEntityStorageMigrationConnector.bootstrap`
104
122
 
105
123
  ***
106
124
 
@@ -126,7 +144,7 @@ Nothing.
126
144
 
127
145
  #### Implementation of
128
146
 
129
- `IEntityStorageConnector.stop`
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
- `IEntityStorageConnector.get`
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
- `IEntityStorageConnector.set`
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
- `IEntityStorageConnector.remove`
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
- `IEntityStorageConnector.query`
396
+ `IEntityStorageMigrationConnector.query`
283
397
 
284
398
  ***
285
399
 
286
- ### tableDrop() {#tabledrop}
400
+ ### count() {#count}
401
+
402
+ > **count**(`conditions?`): `Promise`\<`number`\>
287
403
 
288
- > **tableDrop**(): `Promise`\<`void`\>
404
+ Count all the entities which match the conditions.
289
405
 
290
- Drop the table.
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`\<`void`\>
416
+ `Promise`\<`number`\>
295
417
 
296
- Nothing.
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
- ### tableEmpty() {#tableempty}
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
- > **tableEmpty**(): `Promise`\<`void`\>
536
+ `IEntityStorageConnector`\<`U`\> \| `undefined`
303
537
 
304
- Empty the table.
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
- Nothing.
556
+ A promise that resolves when the cleanup is complete.
557
+
558
+ #### Implementation of
559
+
560
+ `IEntityStorageMigrationConnector.cleanupMigration`
311
561
 
312
562
  ***
313
563
 
@@ -26,12 +26,6 @@ The keys to use from the context ids to create partitions.
26
26
 
27
27
  The type of logging component to use.
28
28
 
29
- #### Default
30
-
31
- ```ts
32
- logging
33
- ```
34
-
35
29
  ***
36
30
 
37
31
  ### config {#config}
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-next.9",
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/twinfoundation/entity-storage.git",
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": "next",
18
- "@twin.org/core": "next",
19
- "@twin.org/data-json-ld": "next",
20
- "@twin.org/entity": "next",
21
- "@twin.org/entity-storage-models": "0.0.3-next.9",
22
- "@twin.org/logging-models": "next",
23
- "@twin.org/nameof": "next",
24
- "mysql2": "3.20.0"
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/twinfoundation/entity-storage/issues"
58
+ "url": "git+https://github.com/iotaledger/twin-entity-storage/issues"
59
59
  },
60
60
  "homepage": "https://twindev.org"
61
61
  }