@twin.org/entity-storage-connector-file 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 in file.
10
10
 
11
11
  ## Implements
12
12
 
13
- - `IEntityStorageConnector`\<`T`\>
13
+ - `IEntityStorageMigrationConnector`\<`T`\>
14
14
 
15
15
  ## Constructors
16
16
 
@@ -64,7 +64,7 @@ True if the bootstrapping process was successful.
64
64
 
65
65
  #### Implementation of
66
66
 
67
- `IEntityStorageConnector.bootstrap`
67
+ `IEntityStorageMigrationConnector.bootstrap`
68
68
 
69
69
  ***
70
70
 
@@ -82,7 +82,25 @@ The class name of the component.
82
82
 
83
83
  #### Implementation of
84
84
 
85
- `IEntityStorageConnector.className`
85
+ `IEntityStorageMigrationConnector.className`
86
+
87
+ ***
88
+
89
+ ### health() {#health}
90
+
91
+ > **health**(): `Promise`\<`IHealth`[]\>
92
+
93
+ Returns the health status of the component.
94
+
95
+ #### Returns
96
+
97
+ `Promise`\<`IHealth`[]\>
98
+
99
+ The health status of the component, can return multiple entries for elements within the component.
100
+
101
+ #### Implementation of
102
+
103
+ `IEntityStorageMigrationConnector.health`
86
104
 
87
105
  ***
88
106
 
@@ -100,7 +118,7 @@ The schema for the entities.
100
118
 
101
119
  #### Implementation of
102
120
 
103
- `IEntityStorageConnector.getSchema`
121
+ `IEntityStorageMigrationConnector.getSchema`
104
122
 
105
123
  ***
106
124
 
@@ -138,7 +156,7 @@ The object if it can be found or undefined.
138
156
 
139
157
  #### Implementation of
140
158
 
141
- `IEntityStorageConnector.get`
159
+ `IEntityStorageMigrationConnector.get`
142
160
 
143
161
  ***
144
162
 
@@ -170,7 +188,103 @@ The id of the entity.
170
188
 
171
189
  #### Implementation of
172
190
 
173
- `IEntityStorageConnector.set`
191
+ `IEntityStorageMigrationConnector.set`
192
+
193
+ ***
194
+
195
+ ### setBatch() {#setbatch}
196
+
197
+ > **setBatch**(`entities`): `Promise`\<`void`\>
198
+
199
+ Set multiple entities in a batch.
200
+
201
+ #### Parameters
202
+
203
+ ##### entities
204
+
205
+ `T`[]
206
+
207
+ The entities to set.
208
+
209
+ #### Returns
210
+
211
+ `Promise`\<`void`\>
212
+
213
+ Nothing.
214
+
215
+ #### Implementation of
216
+
217
+ `IEntityStorageMigrationConnector.setBatch`
218
+
219
+ ***
220
+
221
+ ### empty() {#empty}
222
+
223
+ > **empty**(): `Promise`\<`void`\>
224
+
225
+ Remove all entities from the storage.
226
+
227
+ #### Returns
228
+
229
+ `Promise`\<`void`\>
230
+
231
+ Nothing.
232
+
233
+ #### Implementation of
234
+
235
+ `IEntityStorageMigrationConnector.empty`
236
+
237
+ ***
238
+
239
+ ### removeBatch() {#removebatch}
240
+
241
+ > **removeBatch**(`ids`): `Promise`\<`void`\>
242
+
243
+ Remove multiple entities by id.
244
+
245
+ #### Parameters
246
+
247
+ ##### ids
248
+
249
+ `string`[]
250
+
251
+ The ids of the entities to remove.
252
+
253
+ #### Returns
254
+
255
+ `Promise`\<`void`\>
256
+
257
+ Nothing.
258
+
259
+ #### Implementation of
260
+
261
+ `IEntityStorageMigrationConnector.removeBatch`
262
+
263
+ ***
264
+
265
+ ### teardown() {#teardown}
266
+
267
+ > **teardown**(`nodeLoggingComponentType?`): `Promise`\<`boolean`\>
268
+
269
+ Teardown the storage by deleting the underlying store file.
270
+
271
+ #### Parameters
272
+
273
+ ##### nodeLoggingComponentType?
274
+
275
+ `string`
276
+
277
+ The node logging component type.
278
+
279
+ #### Returns
280
+
281
+ `Promise`\<`boolean`\>
282
+
283
+ True if the teardown process was successful.
284
+
285
+ #### Implementation of
286
+
287
+ `IEntityStorageMigrationConnector.teardown`
174
288
 
175
289
  ***
176
290
 
@@ -202,7 +316,7 @@ Nothing.
202
316
 
203
317
  #### Implementation of
204
318
 
205
- `IEntityStorageConnector.remove`
319
+ `IEntityStorageMigrationConnector.remove`
206
320
 
207
321
  ***
208
322
 
@@ -253,4 +367,168 @@ and a cursor which can be used to request more entities.
253
367
 
254
368
  #### Implementation of
255
369
 
256
- `IEntityStorageConnector.query`
370
+ `IEntityStorageMigrationConnector.query`
371
+
372
+ ***
373
+
374
+ ### count() {#count}
375
+
376
+ > **count**(`conditions?`): `Promise`\<`number`\>
377
+
378
+ Count all the entities which match the conditions.
379
+
380
+ #### Parameters
381
+
382
+ ##### conditions?
383
+
384
+ `EntityCondition`\<`T`\>
385
+
386
+ The optional conditions to match for the entities.
387
+
388
+ #### Returns
389
+
390
+ `Promise`\<`number`\>
391
+
392
+ The total count of entities in the storage.
393
+
394
+ #### Implementation of
395
+
396
+ `IEntityStorageMigrationConnector.count`
397
+
398
+ ***
399
+
400
+ ### getPartitionContextIds() {#getpartitioncontextids}
401
+
402
+ > **getPartitionContextIds**(): `Promise`\<`IContextIds`[]\>
403
+
404
+ Get a unique list of all the context ids from the storage.
405
+
406
+ #### Returns
407
+
408
+ `Promise`\<`IContextIds`[]\>
409
+
410
+ The list of unique context ids.
411
+
412
+ #### Implementation of
413
+
414
+ `IEntityStorageMigrationConnector.getPartitionContextIds`
415
+
416
+ ***
417
+
418
+ ### createTargetConnector() {#createtargetconnector}
419
+
420
+ > **createTargetConnector**\<`U`\>(`newEntitySchema`): `Promise`\<`IEntityStorageConnector`\<`U`\>\>
421
+
422
+ Create the target connector for performing the migration it will use a temporary storage location.
423
+
424
+ #### Type Parameters
425
+
426
+ ##### U
427
+
428
+ `U`
429
+
430
+ #### Parameters
431
+
432
+ ##### newEntitySchema
433
+
434
+ `string`
435
+
436
+ The name of the new entity schema to create the connector for.
437
+
438
+ #### Returns
439
+
440
+ `Promise`\<`IEntityStorageConnector`\<`U`\>\>
441
+
442
+ Connector for performing the migration.
443
+
444
+ #### Implementation of
445
+
446
+ `IEntityStorageMigrationConnector.createTargetConnector`
447
+
448
+ ***
449
+
450
+ ### finalizeMigration() {#finalizemigration}
451
+
452
+ > **finalizeMigration**\<`U`\>(`targetConnector`, `options?`, `loggingComponentType?`): `Promise`\<`IEntityStorageConnector`\<`U`\>\>
453
+
454
+ Finalize the migration by tearing down the old connector and replacing it with the target connector.
455
+
456
+ #### Type Parameters
457
+
458
+ ##### U
459
+
460
+ `U`
461
+
462
+ #### Parameters
463
+
464
+ ##### targetConnector
465
+
466
+ `FileEntityStorageConnector`\<`U`\>
467
+
468
+ The target connector to finalize the migration with.
469
+
470
+ ##### options?
471
+
472
+ `IMigrationOptions`
473
+
474
+ The options to control how the migration is finalized.
475
+
476
+ ##### loggingComponentType?
477
+
478
+ `string`
479
+
480
+ The optional component type to use for logging the migration progress.
481
+
482
+ #### Returns
483
+
484
+ `Promise`\<`IEntityStorageConnector`\<`U`\>\>
485
+
486
+ A promise that resolves when the migration is finalized.
487
+
488
+ #### Implementation of
489
+
490
+ `IEntityStorageMigrationConnector.finalizeMigration`
491
+
492
+ ***
493
+
494
+ ### cleanupMigration() {#cleanupmigration}
495
+
496
+ > **cleanupMigration**\<`U`\>(`targetConnector`, `options?`, `loggingComponentType?`): `Promise`\<`void`\>
497
+
498
+ Cleanup the migration if a migration fails or needs to be aborted.
499
+
500
+ #### Type Parameters
501
+
502
+ ##### U
503
+
504
+ `U`
505
+
506
+ #### Parameters
507
+
508
+ ##### targetConnector
509
+
510
+ `IEntityStorageConnector`\<`U`\> \| `undefined`
511
+
512
+ The target connector to cleanup the migration with.
513
+
514
+ ##### options?
515
+
516
+ `IMigrationOptions`
517
+
518
+ The options to control how the migration is cleaned up.
519
+
520
+ ##### loggingComponentType?
521
+
522
+ `string`
523
+
524
+ The optional component type to use for logging the migration progress.
525
+
526
+ #### Returns
527
+
528
+ `Promise`\<`void`\>
529
+
530
+ A promise that resolves when the migration is cleaned up.
531
+
532
+ #### Implementation of
533
+
534
+ `IEntityStorageMigrationConnector.cleanupMigration`
@@ -9,3 +9,29 @@ Configuration for the File Entity Storage Connector.
9
9
  > **directory**: `string`
10
10
 
11
11
  The directory to use for storage.
12
+
13
+ ***
14
+
15
+ ### diskErrorThresholdBytes? {#diskerrorthresholdbytes}
16
+
17
+ > `optional` **diskErrorThresholdBytes?**: `number`
18
+
19
+ The number of free bytes below which the health check reports an error.
20
+ Defaults to 100 MB.
21
+
22
+ ***
23
+
24
+ ### diskWarningThresholdBytes? {#diskwarningthresholdbytes}
25
+
26
+ > `optional` **diskWarningThresholdBytes?**: `number`
27
+
28
+ The number of free bytes below which the health check reports a warning.
29
+ Defaults to 500 MB.
30
+
31
+ ***
32
+
33
+ ### mutexTimeoutMs? {#mutextimeoutms}
34
+
35
+ > `optional` **mutexTimeoutMs?**: `number`
36
+
37
+ Maximum milliseconds to wait for the per-directory write lock before throwing.
package/locales/en.json CHANGED
@@ -3,12 +3,28 @@
3
3
  "fileEntityStorageConnector": {
4
4
  "directoryCreating": "Creating directory \"{directory}\"",
5
5
  "directoryCreated": "Created directory \"{directory}\"",
6
- "directoryExists": "Skipping create directory \"{directory}\" as it already exists"
6
+ "directoryExists": "Skipping create directory \"{directory}\" as it already exists",
7
+ "storeTearingDown": "Tearing down entity storage",
8
+ "storeTornDown": "Entity storage torn down"
7
9
  }
8
10
  },
9
11
  "error": {
10
12
  "fileEntityStorageConnector": {
11
- "directoryCreateFailed": "Creating directory \"{directory}\" failed"
13
+ "directoryCreateFailed": "Creating directory \"{directory}\" failed",
14
+ "emptyFailed": "Unable to empty entity storage",
15
+ "readStoreCorrupt": "The entity storage store file in directory \"{directory}\" contains corrupt JSON",
16
+ "readStoreFailed": "Unable to read the entity storage store file in directory \"{directory}\"",
17
+ "removeBatchFailed": "Unable to remove batch of entities",
18
+ "teardownFailed": "Unable to teardown entity storage",
19
+ "writeStoreFailed": "Unable to write the entity storage store file in directory \"{directory}\""
20
+ }
21
+ },
22
+ "health": {
23
+ "fileEntityStorageConnector": {
24
+ "healthDescription": "Checks if there is sufficient disk space in directory \"{directory}\" for the file entity storage connector to operate properly",
25
+ "diskSpaceError": "Disk space critically low in directory \"{directory}\", {freeBytes} bytes free, threshold is {thresholdBytes} bytes",
26
+ "diskSpaceCheckFailed": "Failed to check disk space in directory \"{directory}\"",
27
+ "diskSpaceWarning": "Disk space low in directory \"{directory}\", {freeBytes} bytes free, threshold is {thresholdBytes} bytes"
12
28
  }
13
29
  }
14
30
  }
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "@twin.org/entity-storage-connector-file",
3
- "version": "0.0.3-next.9",
3
+ "version": "0.9.0",
4
4
  "description": "File-based connector that stores entities on disk for straightforward deployments.",
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-file"
9
9
  },
10
10
  "author": "martyn.janes@iota.org",
@@ -14,12 +14,12 @@
14
14
  "node": ">=20.0.0"
15
15
  },
16
16
  "dependencies": {
17
- "@twin.org/context": "next",
18
- "@twin.org/core": "next",
19
- "@twin.org/entity": "next",
20
- "@twin.org/entity-storage-models": "0.0.3-next.9",
21
- "@twin.org/logging-models": "next",
22
- "@twin.org/nameof": "next"
17
+ "@twin.org/context": "^0.9.0",
18
+ "@twin.org/core": "^0.9.0",
19
+ "@twin.org/entity": "^0.9.0",
20
+ "@twin.org/entity-storage-models": "^0.9.0",
21
+ "@twin.org/logging-models": "^0.9.0",
22
+ "@twin.org/nameof": "^0.9.0"
23
23
  },
24
24
  "main": "./dist/es/index.js",
25
25
  "types": "./dist/types/index.d.ts",
@@ -53,7 +53,7 @@
53
53
  "integration"
54
54
  ],
55
55
  "bugs": {
56
- "url": "git+https://github.com/twinfoundation/entity-storage/issues"
56
+ "url": "git+https://github.com/iotaledger/twin-entity-storage/issues"
57
57
  },
58
58
  "homepage": "https://twindev.org"
59
59
  }