@twin.org/entity-storage-connector-file 0.0.3-next.2 → 0.0.3-next.21
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 +2 -2
- package/dist/es/fileEntityStorageConnector.js +316 -14
- package/dist/es/fileEntityStorageConnector.js.map +1 -1
- package/dist/es/models/IFileEntityStorageConnectorConfig.js.map +1 -1
- package/dist/types/fileEntityStorageConnector.d.ts +64 -1
- package/dist/types/models/IFileEntityStorageConnectorConfig.d.ts +10 -0
- package/docs/changelog.md +416 -43
- package/docs/examples.md +69 -1
- package/docs/reference/classes/FileEntityStorageConnector.md +270 -8
- package/docs/reference/interfaces/IFileEntityStorageConnectorConfig.md +19 -1
- package/docs/reference/interfaces/IFileEntityStorageConnectorConstructorOptions.md +4 -4
- package/locales/en.json +15 -2
- package/package.json +5 -5
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { type IContextIds } from "@twin.org/context";
|
|
2
|
+
import { type IHealth } from "@twin.org/core";
|
|
1
3
|
import { type EntityCondition, type IEntitySchema, type SortDirection } from "@twin.org/entity";
|
|
2
|
-
import type
|
|
4
|
+
import { type IEntityStorageConnector, type IMigrationOptions } from "@twin.org/entity-storage-models";
|
|
3
5
|
import type { IFileEntityStorageConnectorConstructorOptions } from "./models/IFileEntityStorageConnectorConstructorOptions.js";
|
|
4
6
|
/**
|
|
5
7
|
* Class for performing entity storage operations in file.
|
|
@@ -25,6 +27,11 @@ export declare class FileEntityStorageConnector<T = unknown> implements IEntityS
|
|
|
25
27
|
* @returns The class name of the component.
|
|
26
28
|
*/
|
|
27
29
|
className(): string;
|
|
30
|
+
/**
|
|
31
|
+
* Returns the health status of the component.
|
|
32
|
+
* @returns The health status of the component, can return multiple entries for elements within the component.
|
|
33
|
+
*/
|
|
34
|
+
health(): Promise<IHealth[]>;
|
|
28
35
|
/**
|
|
29
36
|
* Get the schema for the entities.
|
|
30
37
|
* @returns The schema for the entities.
|
|
@@ -51,6 +58,29 @@ export declare class FileEntityStorageConnector<T = unknown> implements IEntityS
|
|
|
51
58
|
property: keyof T;
|
|
52
59
|
value: unknown;
|
|
53
60
|
}[]): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Set multiple entities in a batch.
|
|
63
|
+
* @param entities The entities to set.
|
|
64
|
+
* @returns Nothing.
|
|
65
|
+
*/
|
|
66
|
+
setBatch(entities: T[]): Promise<void>;
|
|
67
|
+
/**
|
|
68
|
+
* Remove all entities from the storage.
|
|
69
|
+
* @returns Nothing.
|
|
70
|
+
*/
|
|
71
|
+
empty(): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Remove multiple entities by id.
|
|
74
|
+
* @param ids The ids of the entities to remove.
|
|
75
|
+
* @returns Nothing.
|
|
76
|
+
*/
|
|
77
|
+
removeBatch(ids: string[]): Promise<void>;
|
|
78
|
+
/**
|
|
79
|
+
* Teardown the storage by deleting the underlying store file.
|
|
80
|
+
* @param nodeLoggingComponentType The node logging component type.
|
|
81
|
+
* @returns True if the teardown process was successful.
|
|
82
|
+
*/
|
|
83
|
+
teardown(nodeLoggingComponentType?: string): Promise<boolean>;
|
|
54
84
|
/**
|
|
55
85
|
* Remove the entity.
|
|
56
86
|
* @param id The id of the entity to remove.
|
|
@@ -84,4 +114,37 @@ export declare class FileEntityStorageConnector<T = unknown> implements IEntityS
|
|
|
84
114
|
*/
|
|
85
115
|
cursor?: string;
|
|
86
116
|
}>;
|
|
117
|
+
/**
|
|
118
|
+
* Count all the entities which match the conditions.
|
|
119
|
+
* @param conditions The optional conditions to match for the entities.
|
|
120
|
+
* @returns The total count of entities in the storage.
|
|
121
|
+
*/
|
|
122
|
+
count(conditions?: EntityCondition<T>): Promise<number>;
|
|
123
|
+
/**
|
|
124
|
+
* Get a unique list of all the context ids from the storage.
|
|
125
|
+
* @returns The list of unique context ids.
|
|
126
|
+
*/
|
|
127
|
+
getPartitionContextIds(): Promise<IContextIds[]>;
|
|
128
|
+
/**
|
|
129
|
+
* Create the target connector for performing the migration it will use a temporary storage location.
|
|
130
|
+
* @param newEntitySchema The name of the new entity schema to create the connector for.
|
|
131
|
+
* @returns Connector for performing the migration.
|
|
132
|
+
*/
|
|
133
|
+
createTargetConnector<U>(newEntitySchema: string): Promise<IEntityStorageConnector<U>>;
|
|
134
|
+
/**
|
|
135
|
+
* Finalize the migration by tearing down the old connector and replacing it with the target connector.
|
|
136
|
+
* @param targetConnector The target connector to finalize the migration with.
|
|
137
|
+
* @param options The options to control how the migration is finalized.
|
|
138
|
+
* @param loggingComponentType The optional component type to use for logging the migration progress.
|
|
139
|
+
* @returns A promise that resolves when the migration is finalized.
|
|
140
|
+
*/
|
|
141
|
+
finalizeMigration<U>(targetConnector: FileEntityStorageConnector<U>, options?: IMigrationOptions<T, U>, loggingComponentType?: string): Promise<IEntityStorageConnector<U>>;
|
|
142
|
+
/**
|
|
143
|
+
* Cleanup the migration if a migration fails or needs to be aborted.
|
|
144
|
+
* @param targetConnector The target connector to cleanup the migration with.
|
|
145
|
+
* @param options The options to control how the migration is cleaned up.
|
|
146
|
+
* @param loggingComponentType The optional component type to use for logging the migration progress.
|
|
147
|
+
* @returns A promise that resolves when the migration is cleaned up.
|
|
148
|
+
*/
|
|
149
|
+
cleanupMigration<U>(targetConnector: IEntityStorageConnector<U> | undefined, options?: IMigrationOptions<T, U>, loggingComponentType?: string): Promise<void>;
|
|
87
150
|
}
|
|
@@ -6,4 +6,14 @@ export interface IFileEntityStorageConnectorConfig {
|
|
|
6
6
|
* The directory to use for storage.
|
|
7
7
|
*/
|
|
8
8
|
directory: string;
|
|
9
|
+
/**
|
|
10
|
+
* The number of free bytes below which the health check reports an error.
|
|
11
|
+
* Defaults to 100 MB.
|
|
12
|
+
*/
|
|
13
|
+
diskErrorThresholdBytes?: number;
|
|
14
|
+
/**
|
|
15
|
+
* The number of free bytes below which the health check reports a warning.
|
|
16
|
+
* Defaults to 500 MB.
|
|
17
|
+
*/
|
|
18
|
+
diskWarningThresholdBytes?: number;
|
|
9
19
|
}
|