@twin.org/entity-storage-connector-file 0.0.1-next.3 → 0.0.1-next.30

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.
@@ -39,8 +39,6 @@ class FileEntityStorageConnector {
39
39
  /**
40
40
  * Create a new instance of FileEntityStorageConnector.
41
41
  * @param options The options for the connector.
42
- * @param options.entitySchema The name of the entity schema.
43
- * @param options.config The configuration for the connector.
44
42
  */
45
43
  constructor(options) {
46
44
  core.Guards.object(this.CLASS_NAME, "options", options);
@@ -103,52 +101,59 @@ class FileEntityStorageConnector {
103
101
  }
104
102
  return true;
105
103
  }
104
+ /**
105
+ * Get the schema for the entities.
106
+ * @returns The schema for the entities.
107
+ */
108
+ getSchema() {
109
+ return this._entitySchema;
110
+ }
106
111
  /**
107
112
  * Get an entity.
108
113
  * @param id The id of the entity to get, or the index value if secondaryIndex is set.
109
114
  * @param secondaryIndex Get the item using a secondary index.
115
+ * @param conditions The optional conditions to match for the entities.
110
116
  * @returns The object if it can be found or undefined.
111
117
  */
112
- async get(id, secondaryIndex) {
118
+ async get(id, secondaryIndex, conditions) {
113
119
  core.Guards.stringValue(this.CLASS_NAME, "id", id);
114
- const lookupKey = secondaryIndex ?? this._primaryKey.property;
115
120
  const store = await this.readStore();
116
- const found = store?.find(entity => entity[lookupKey] === id);
117
- if (found) {
118
- return found;
119
- }
120
- return undefined;
121
+ const foundIndex = this.findItem(store, id, secondaryIndex, conditions);
122
+ return foundIndex === -1 ? undefined : store[foundIndex];
121
123
  }
122
124
  /**
123
125
  * Set an entity.
124
126
  * @param entity The entity to set.
127
+ * @param conditions The optional conditions to match for the entities.
125
128
  * @returns The id of the entity.
126
129
  */
127
- async set(entity) {
128
- core.Guards.object(this.CLASS_NAME, "entity", entity);
130
+ async set(entity$1, conditions) {
131
+ core.Guards.object(this.CLASS_NAME, "entity", entity$1);
132
+ entity.EntitySchemaHelper.validateEntity(entity$1, this.getSchema());
129
133
  const store = await this.readStore();
130
- const existingIndex = store.findIndex(e => e[this._primaryKey.property] === entity[this._primaryKey.property]);
134
+ const existingIndex = this.findItem(store, entity$1[this._primaryKey.property], undefined, conditions);
131
135
  if (existingIndex >= 0) {
132
- store[existingIndex] = entity;
136
+ store[existingIndex] = entity$1;
133
137
  }
134
138
  else {
135
- store.push(entity);
139
+ store.push(entity$1);
136
140
  }
137
141
  await this.writeStore(store);
138
142
  }
139
143
  /**
140
144
  * Remove the entity.
141
145
  * @param id The id of the entity to remove.
146
+ * @param conditions The optional conditions to match for the entities.
142
147
  * @returns Nothing.
143
148
  */
144
- async remove(id) {
149
+ async remove(id, conditions) {
145
150
  core.Guards.stringValue(this.CLASS_NAME, "id", id);
146
151
  const store = await this.readStore();
147
- const index = store.findIndex(e => e[this._primaryKey.property] === id);
152
+ const index = this.findItem(store, id, undefined, conditions);
148
153
  if (index >= 0) {
149
154
  store.splice(index, 1);
155
+ await this.writeStore(store);
150
156
  }
151
- await this.writeStore(store);
152
157
  }
153
158
  /**
154
159
  * Find all the entities which match the conditions.
@@ -173,7 +178,10 @@ class FileEntityStorageConnector {
173
178
  if (entity.EntityConditions.check(allEntities[i], conditions) && entities.length < finalPageSize) {
174
179
  entities.push(core.ObjectHelper.pick(allEntities[i], properties));
175
180
  if (entities.length >= finalPageSize) {
176
- nextCursor = (i + 1).toString();
181
+ if (i < allEntities.length - 1) {
182
+ nextCursor = (i + 1).toString();
183
+ }
184
+ break;
177
185
  }
178
186
  }
179
187
  }
@@ -226,6 +234,51 @@ class FileEntityStorageConnector {
226
234
  return false;
227
235
  }
228
236
  }
237
+ /**
238
+ * Find the item in the store.
239
+ * @param store The store to search.
240
+ * @param id The id to search for.
241
+ * @param secondaryIndex The secondary index to search for.
242
+ * @param conditions The optional conditions to match for the entities.
243
+ * @returns The index of the item if found or -1.
244
+ * @internal
245
+ */
246
+ findItem(store, id, secondaryIndex, conditions) {
247
+ const finalConditions = [];
248
+ if (!core.Is.empty(secondaryIndex)) {
249
+ finalConditions.push({
250
+ property: secondaryIndex,
251
+ comparison: entity.ComparisonOperator.Equals,
252
+ value: id
253
+ });
254
+ }
255
+ if (core.Is.arrayValue(conditions)) {
256
+ // If we haven't added a secondary index condition we need to add the primary key condition.
257
+ if (finalConditions.length === 0) {
258
+ finalConditions.push({
259
+ property: this._primaryKey.property,
260
+ comparison: entity.ComparisonOperator.Equals,
261
+ value: id
262
+ });
263
+ }
264
+ finalConditions.push(...conditions.map(c => ({
265
+ property: c.property,
266
+ comparison: entity.ComparisonOperator.Equals,
267
+ value: c.value
268
+ })));
269
+ }
270
+ if (finalConditions.length > 0) {
271
+ for (let i = 0; i < store.length; i++) {
272
+ if (entity.EntityConditions.check(store[i], { conditions: finalConditions })) {
273
+ return i;
274
+ }
275
+ }
276
+ }
277
+ else {
278
+ return store.findIndex(e => e[this._primaryKey.property] === id);
279
+ }
280
+ return -1;
281
+ }
229
282
  }
230
283
 
231
284
  exports.FileEntityStorageConnector = FileEntityStorageConnector;
@@ -1,7 +1,7 @@
1
1
  import { mkdir, readFile, writeFile, access } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
- import { Guards, BaseError, Coerce, ObjectHelper } from '@twin.org/core';
4
- import { EntitySchemaFactory, EntitySchemaHelper, EntitySorter, EntityConditions } from '@twin.org/entity';
3
+ import { Guards, BaseError, Coerce, ObjectHelper, Is } from '@twin.org/core';
4
+ import { EntitySchemaFactory, EntitySchemaHelper, EntitySorter, EntityConditions, ComparisonOperator } from '@twin.org/entity';
5
5
  import { LoggingConnectorFactory } from '@twin.org/logging-models';
6
6
 
7
7
  // Copyright 2024 IOTA Stiftung.
@@ -37,8 +37,6 @@ class FileEntityStorageConnector {
37
37
  /**
38
38
  * Create a new instance of FileEntityStorageConnector.
39
39
  * @param options The options for the connector.
40
- * @param options.entitySchema The name of the entity schema.
41
- * @param options.config The configuration for the connector.
42
40
  */
43
41
  constructor(options) {
44
42
  Guards.object(this.CLASS_NAME, "options", options);
@@ -101,31 +99,37 @@ class FileEntityStorageConnector {
101
99
  }
102
100
  return true;
103
101
  }
102
+ /**
103
+ * Get the schema for the entities.
104
+ * @returns The schema for the entities.
105
+ */
106
+ getSchema() {
107
+ return this._entitySchema;
108
+ }
104
109
  /**
105
110
  * Get an entity.
106
111
  * @param id The id of the entity to get, or the index value if secondaryIndex is set.
107
112
  * @param secondaryIndex Get the item using a secondary index.
113
+ * @param conditions The optional conditions to match for the entities.
108
114
  * @returns The object if it can be found or undefined.
109
115
  */
110
- async get(id, secondaryIndex) {
116
+ async get(id, secondaryIndex, conditions) {
111
117
  Guards.stringValue(this.CLASS_NAME, "id", id);
112
- const lookupKey = secondaryIndex ?? this._primaryKey.property;
113
118
  const store = await this.readStore();
114
- const found = store?.find(entity => entity[lookupKey] === id);
115
- if (found) {
116
- return found;
117
- }
118
- return undefined;
119
+ const foundIndex = this.findItem(store, id, secondaryIndex, conditions);
120
+ return foundIndex === -1 ? undefined : store[foundIndex];
119
121
  }
120
122
  /**
121
123
  * Set an entity.
122
124
  * @param entity The entity to set.
125
+ * @param conditions The optional conditions to match for the entities.
123
126
  * @returns The id of the entity.
124
127
  */
125
- async set(entity) {
128
+ async set(entity, conditions) {
126
129
  Guards.object(this.CLASS_NAME, "entity", entity);
130
+ EntitySchemaHelper.validateEntity(entity, this.getSchema());
127
131
  const store = await this.readStore();
128
- const existingIndex = store.findIndex(e => e[this._primaryKey.property] === entity[this._primaryKey.property]);
132
+ const existingIndex = this.findItem(store, entity[this._primaryKey.property], undefined, conditions);
129
133
  if (existingIndex >= 0) {
130
134
  store[existingIndex] = entity;
131
135
  }
@@ -137,16 +141,17 @@ class FileEntityStorageConnector {
137
141
  /**
138
142
  * Remove the entity.
139
143
  * @param id The id of the entity to remove.
144
+ * @param conditions The optional conditions to match for the entities.
140
145
  * @returns Nothing.
141
146
  */
142
- async remove(id) {
147
+ async remove(id, conditions) {
143
148
  Guards.stringValue(this.CLASS_NAME, "id", id);
144
149
  const store = await this.readStore();
145
- const index = store.findIndex(e => e[this._primaryKey.property] === id);
150
+ const index = this.findItem(store, id, undefined, conditions);
146
151
  if (index >= 0) {
147
152
  store.splice(index, 1);
153
+ await this.writeStore(store);
148
154
  }
149
- await this.writeStore(store);
150
155
  }
151
156
  /**
152
157
  * Find all the entities which match the conditions.
@@ -171,7 +176,10 @@ class FileEntityStorageConnector {
171
176
  if (EntityConditions.check(allEntities[i], conditions) && entities.length < finalPageSize) {
172
177
  entities.push(ObjectHelper.pick(allEntities[i], properties));
173
178
  if (entities.length >= finalPageSize) {
174
- nextCursor = (i + 1).toString();
179
+ if (i < allEntities.length - 1) {
180
+ nextCursor = (i + 1).toString();
181
+ }
182
+ break;
175
183
  }
176
184
  }
177
185
  }
@@ -224,6 +232,51 @@ class FileEntityStorageConnector {
224
232
  return false;
225
233
  }
226
234
  }
235
+ /**
236
+ * Find the item in the store.
237
+ * @param store The store to search.
238
+ * @param id The id to search for.
239
+ * @param secondaryIndex The secondary index to search for.
240
+ * @param conditions The optional conditions to match for the entities.
241
+ * @returns The index of the item if found or -1.
242
+ * @internal
243
+ */
244
+ findItem(store, id, secondaryIndex, conditions) {
245
+ const finalConditions = [];
246
+ if (!Is.empty(secondaryIndex)) {
247
+ finalConditions.push({
248
+ property: secondaryIndex,
249
+ comparison: ComparisonOperator.Equals,
250
+ value: id
251
+ });
252
+ }
253
+ if (Is.arrayValue(conditions)) {
254
+ // If we haven't added a secondary index condition we need to add the primary key condition.
255
+ if (finalConditions.length === 0) {
256
+ finalConditions.push({
257
+ property: this._primaryKey.property,
258
+ comparison: ComparisonOperator.Equals,
259
+ value: id
260
+ });
261
+ }
262
+ finalConditions.push(...conditions.map(c => ({
263
+ property: c.property,
264
+ comparison: ComparisonOperator.Equals,
265
+ value: c.value
266
+ })));
267
+ }
268
+ if (finalConditions.length > 0) {
269
+ for (let i = 0; i < store.length; i++) {
270
+ if (EntityConditions.check(store[i], { conditions: finalConditions })) {
271
+ return i;
272
+ }
273
+ }
274
+ }
275
+ else {
276
+ return store.findIndex(e => e[this._primaryKey.property] === id);
277
+ }
278
+ return -1;
279
+ }
227
280
  }
228
281
 
229
282
  export { FileEntityStorageConnector };
@@ -1,6 +1,6 @@
1
- import { type EntityCondition, type SortDirection } from "@twin.org/entity";
1
+ import { type EntityCondition, type IEntitySchema, type SortDirection } from "@twin.org/entity";
2
2
  import type { IEntityStorageConnector } from "@twin.org/entity-storage-models";
3
- import type { IFileEntityStorageConnectorConfig } from "./models/IFileEntityStorageConnectorConfig";
3
+ import type { IFileEntityStorageConnectorConstructorOptions } from "./models/IFileEntityStorageConnectorConstructorOptions";
4
4
  /**
5
5
  * Class for performing entity storage operations in file.
6
6
  */
@@ -12,38 +12,50 @@ export declare class FileEntityStorageConnector<T = unknown> implements IEntityS
12
12
  /**
13
13
  * Create a new instance of FileEntityStorageConnector.
14
14
  * @param options The options for the connector.
15
- * @param options.entitySchema The name of the entity schema.
16
- * @param options.config The configuration for the connector.
17
15
  */
18
- constructor(options: {
19
- entitySchema: string;
20
- config: IFileEntityStorageConnectorConfig;
21
- });
16
+ constructor(options: IFileEntityStorageConnectorConstructorOptions);
22
17
  /**
23
18
  * Bootstrap the connector by creating and initializing any resources it needs.
24
19
  * @param nodeLoggingConnectorType The node logging connector type, defaults to "node-logging".
25
20
  * @returns True if the bootstrapping process was successful.
26
21
  */
27
22
  bootstrap(nodeLoggingConnectorType?: string): Promise<boolean>;
23
+ /**
24
+ * Get the schema for the entities.
25
+ * @returns The schema for the entities.
26
+ */
27
+ getSchema(): IEntitySchema;
28
28
  /**
29
29
  * Get an entity.
30
30
  * @param id The id of the entity to get, or the index value if secondaryIndex is set.
31
31
  * @param secondaryIndex Get the item using a secondary index.
32
+ * @param conditions The optional conditions to match for the entities.
32
33
  * @returns The object if it can be found or undefined.
33
34
  */
34
- get(id: string, secondaryIndex?: keyof T): Promise<T | undefined>;
35
+ get(id: string, secondaryIndex?: keyof T, conditions?: {
36
+ property: keyof T;
37
+ value: unknown;
38
+ }[]): Promise<T | undefined>;
35
39
  /**
36
40
  * Set an entity.
37
41
  * @param entity The entity to set.
42
+ * @param conditions The optional conditions to match for the entities.
38
43
  * @returns The id of the entity.
39
44
  */
40
- set(entity: T): Promise<void>;
45
+ set(entity: T, conditions?: {
46
+ property: keyof T;
47
+ value: unknown;
48
+ }[]): Promise<void>;
41
49
  /**
42
50
  * Remove the entity.
43
51
  * @param id The id of the entity to remove.
52
+ * @param conditions The optional conditions to match for the entities.
44
53
  * @returns Nothing.
45
54
  */
46
- remove(id: string): Promise<void>;
55
+ remove(id: string, conditions?: {
56
+ property: keyof T;
57
+ value: unknown;
58
+ }[]): Promise<void>;
47
59
  /**
48
60
  * Find all the entities which match the conditions.
49
61
  * @param conditions The conditions to match for the entities.
@@ -1,2 +1,3 @@
1
1
  export * from "./fileEntityStorageConnector";
2
2
  export * from "./models/IFileEntityStorageConnectorConfig";
3
+ export * from "./models/IFileEntityStorageConnectorConstructorOptions";
@@ -0,0 +1,14 @@
1
+ import type { IFileEntityStorageConnectorConfig } from "./IFileEntityStorageConnectorConfig";
2
+ /**
3
+ * Options for the File Entity Storage Connector constructor.
4
+ */
5
+ export interface IFileEntityStorageConnectorConstructorOptions {
6
+ /**
7
+ * The name of the entity schema.
8
+ */
9
+ entitySchema: string;
10
+ /**
11
+ * The configuration for the connector.
12
+ */
13
+ config: IFileEntityStorageConnectorConfig;
14
+ }
package/docs/changelog.md CHANGED
@@ -1,5 +1,69 @@
1
1
  # @twin.org/entity-storage-connector-file - Changelog
2
2
 
3
- ## v0.0.1-next.3
3
+ ## [0.0.1-next.30](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-file-v0.0.1-next.29...entity-storage-connector-file-v0.0.1-next.30) (2025-06-12)
4
+
5
+
6
+ ### Features
7
+
8
+ * update dependencies ([7ccc0c4](https://github.com/twinfoundation/entity-storage/commit/7ccc0c429125d073dc60b3de6cf101abc8cc6cba))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/entity-storage-models bumped from 0.0.1-next.29 to 0.0.1-next.30
16
+ * devDependencies
17
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.1-next.29 to 0.0.1-next.30
18
+
19
+ ## [0.0.1-next.29](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-file-v0.0.1-next.28...entity-storage-connector-file-v0.0.1-next.29) (2025-04-17)
20
+
21
+
22
+ ### Features
23
+
24
+ * use shared store mechanism ([#34](https://github.com/twinfoundation/entity-storage/issues/34)) ([68b6b71](https://github.com/twinfoundation/entity-storage/commit/68b6b71e7a96d7d016cd57bfff36775b56bf3f93))
25
+
26
+
27
+ ### Dependencies
28
+
29
+ * The following workspace dependencies were updated
30
+ * dependencies
31
+ * @twin.org/entity-storage-models bumped from 0.0.1-next.28 to 0.0.1-next.29
32
+ * devDependencies
33
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.1-next.28 to 0.0.1-next.29
34
+
35
+ ## [0.0.1-next.28](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-file-v0.0.1-next.27...entity-storage-connector-file-v0.0.1-next.28) (2025-04-09)
36
+
37
+
38
+ ### Miscellaneous Chores
39
+
40
+ * **entity-storage-connector-file:** Synchronize repo versions
41
+
42
+
43
+ ### Dependencies
44
+
45
+ * The following workspace dependencies were updated
46
+ * dependencies
47
+ * @twin.org/entity-storage-models bumped from 0.0.1-next.27 to 0.0.1-next.28
48
+ * devDependencies
49
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.1-next.27 to 0.0.1-next.28
50
+
51
+ ## [0.0.1-next.27](https://github.com/twinfoundation/entity-storage/compare/entity-storage-connector-file-v0.0.1-next.26...entity-storage-connector-file-v0.0.1-next.27) (2025-03-28)
52
+
53
+
54
+ ### Miscellaneous Chores
55
+
56
+ * **entity-storage-connector-file:** Synchronize repo versions
57
+
58
+
59
+ ### Dependencies
60
+
61
+ * The following workspace dependencies were updated
62
+ * dependencies
63
+ * @twin.org/entity-storage-models bumped from 0.0.1-next.26 to 0.0.1-next.27
64
+ * devDependencies
65
+ * @twin.org/entity-storage-connector-memory bumped from 0.0.1-next.26 to 0.0.1-next.27
66
+
67
+ ## v0.0.1-next.26
4
68
 
5
69
  - Initial Release
@@ -4,7 +4,9 @@ Class for performing entity storage operations in file.
4
4
 
5
5
  ## Type Parameters
6
6
 
7
- **T** = `unknown`
7
+ ### T
8
+
9
+ `T` = `unknown`
8
10
 
9
11
  ## Implements
10
12
 
@@ -12,29 +14,23 @@ Class for performing entity storage operations in file.
12
14
 
13
15
  ## Constructors
14
16
 
15
- ### new FileEntityStorageConnector()
17
+ ### Constructor
16
18
 
17
- > **new FileEntityStorageConnector**\<`T`\>(`options`): [`FileEntityStorageConnector`](FileEntityStorageConnector.md)\<`T`\>
19
+ > **new FileEntityStorageConnector**\<`T`\>(`options`): `FileEntityStorageConnector`\<`T`\>
18
20
 
19
21
  Create a new instance of FileEntityStorageConnector.
20
22
 
21
23
  #### Parameters
22
24
 
23
- **options**
24
-
25
- The options for the connector.
26
-
27
- • **options.entitySchema**: `string`
28
-
29
- The name of the entity schema.
25
+ ##### options
30
26
 
31
- • **options.config**: [`IFileEntityStorageConnectorConfig`](../interfaces/IFileEntityStorageConnectorConfig.md)
27
+ [`IFileEntityStorageConnectorConstructorOptions`](../interfaces/IFileEntityStorageConnectorConstructorOptions.md)
32
28
 
33
- The configuration for the connector.
29
+ The options for the connector.
34
30
 
35
31
  #### Returns
36
32
 
37
- [`FileEntityStorageConnector`](FileEntityStorageConnector.md)\<`T`\>
33
+ `FileEntityStorageConnector`\<`T`\>
38
34
 
39
35
  ## Properties
40
36
 
@@ -52,13 +48,15 @@ Runtime name for the class.
52
48
 
53
49
  ### bootstrap()
54
50
 
55
- > **bootstrap**(`nodeLoggingConnectorType`?): `Promise`\<`boolean`\>
51
+ > **bootstrap**(`nodeLoggingConnectorType?`): `Promise`\<`boolean`\>
56
52
 
57
53
  Bootstrap the connector by creating and initializing any resources it needs.
58
54
 
59
55
  #### Parameters
60
56
 
61
- **nodeLoggingConnectorType?**: `string`
57
+ ##### nodeLoggingConnectorType?
58
+
59
+ `string`
62
60
 
63
61
  The node logging connector type, defaults to "node-logging".
64
62
 
@@ -74,22 +72,50 @@ True if the bootstrapping process was successful.
74
72
 
75
73
  ***
76
74
 
75
+ ### getSchema()
76
+
77
+ > **getSchema**(): `IEntitySchema`
78
+
79
+ Get the schema for the entities.
80
+
81
+ #### Returns
82
+
83
+ `IEntitySchema`
84
+
85
+ The schema for the entities.
86
+
87
+ #### Implementation of
88
+
89
+ `IEntityStorageConnector.getSchema`
90
+
91
+ ***
92
+
77
93
  ### get()
78
94
 
79
- > **get**(`id`, `secondaryIndex`?): `Promise`\<`undefined` \| `T`\>
95
+ > **get**(`id`, `secondaryIndex?`, `conditions?`): `Promise`\<`undefined` \| `T`\>
80
96
 
81
97
  Get an entity.
82
98
 
83
99
  #### Parameters
84
100
 
85
- **id**: `string`
101
+ ##### id
102
+
103
+ `string`
86
104
 
87
105
  The id of the entity to get, or the index value if secondaryIndex is set.
88
106
 
89
- **secondaryIndex?**: keyof `T`
107
+ ##### secondaryIndex?
108
+
109
+ keyof `T`
90
110
 
91
111
  Get the item using a secondary index.
92
112
 
113
+ ##### conditions?
114
+
115
+ `object`[]
116
+
117
+ The optional conditions to match for the entities.
118
+
93
119
  #### Returns
94
120
 
95
121
  `Promise`\<`undefined` \| `T`\>
@@ -104,16 +130,24 @@ The object if it can be found or undefined.
104
130
 
105
131
  ### set()
106
132
 
107
- > **set**(`entity`): `Promise`\<`void`\>
133
+ > **set**(`entity`, `conditions?`): `Promise`\<`void`\>
108
134
 
109
135
  Set an entity.
110
136
 
111
137
  #### Parameters
112
138
 
113
- **entity**: `T`
139
+ ##### entity
140
+
141
+ `T`
114
142
 
115
143
  The entity to set.
116
144
 
145
+ ##### conditions?
146
+
147
+ `object`[]
148
+
149
+ The optional conditions to match for the entities.
150
+
117
151
  #### Returns
118
152
 
119
153
  `Promise`\<`void`\>
@@ -128,16 +162,24 @@ The id of the entity.
128
162
 
129
163
  ### remove()
130
164
 
131
- > **remove**(`id`): `Promise`\<`void`\>
165
+ > **remove**(`id`, `conditions?`): `Promise`\<`void`\>
132
166
 
133
167
  Remove the entity.
134
168
 
135
169
  #### Parameters
136
170
 
137
- **id**: `string`
171
+ ##### id
172
+
173
+ `string`
138
174
 
139
175
  The id of the entity to remove.
140
176
 
177
+ ##### conditions?
178
+
179
+ `object`[]
180
+
181
+ The optional conditions to match for the entities.
182
+
141
183
  #### Returns
142
184
 
143
185
  `Promise`\<`void`\>
@@ -152,51 +194,49 @@ Nothing.
152
194
 
153
195
  ### query()
154
196
 
155
- > **query**(`conditions`?, `sortProperties`?, `properties`?, `cursor`?, `pageSize`?): `Promise`\<`object`\>
197
+ > **query**(`conditions?`, `sortProperties?`, `properties?`, `cursor?`, `pageSize?`): `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
156
198
 
157
199
  Find all the entities which match the conditions.
158
200
 
159
201
  #### Parameters
160
202
 
161
- **conditions?**: `EntityCondition`\<`T`\>
203
+ ##### conditions?
204
+
205
+ `EntityCondition`\<`T`\>
162
206
 
163
207
  The conditions to match for the entities.
164
208
 
165
- **sortProperties?**: `object`[]
209
+ ##### sortProperties?
210
+
211
+ `object`[]
166
212
 
167
213
  The optional sort order.
168
214
 
169
- **properties?**: keyof `T`[]
215
+ ##### properties?
216
+
217
+ keyof `T`[]
170
218
 
171
219
  The optional properties to return, defaults to all.
172
220
 
173
- **cursor?**: `string`
221
+ ##### cursor?
222
+
223
+ `string`
174
224
 
175
225
  The cursor to request the next page of entities.
176
226
 
177
- **pageSize?**: `number`
227
+ ##### pageSize?
228
+
229
+ `number`
178
230
 
179
231
  The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
180
232
 
181
233
  #### Returns
182
234
 
183
- `Promise`\<`object`\>
235
+ `Promise`\<\{ `entities`: `Partial`\<`T`\>[]; `cursor?`: `string`; \}\>
184
236
 
185
237
  All the entities for the storage matching the conditions,
186
238
  and a cursor which can be used to request more entities.
187
239
 
188
- ##### entities
189
-
190
- > **entities**: `Partial`\<`T`\>[]
191
-
192
- The entities, which can be partial if a limited keys list was provided.
193
-
194
- ##### cursor?
195
-
196
- > `optional` **cursor**: `string`
197
-
198
- An optional cursor, when defined can be used to call find to get more entities.
199
-
200
240
  #### Implementation of
201
241
 
202
242
  `IEntityStorageConnector.query`
@@ -7,3 +7,4 @@
7
7
  ## Interfaces
8
8
 
9
9
  - [IFileEntityStorageConnectorConfig](interfaces/IFileEntityStorageConnectorConfig.md)
10
+ - [IFileEntityStorageConnectorConstructorOptions](interfaces/IFileEntityStorageConnectorConstructorOptions.md)
@@ -0,0 +1,19 @@
1
+ # Interface: IFileEntityStorageConnectorConstructorOptions
2
+
3
+ Options for the File Entity Storage Connector constructor.
4
+
5
+ ## Properties
6
+
7
+ ### entitySchema
8
+
9
+ > **entitySchema**: `string`
10
+
11
+ The name of the entity schema.
12
+
13
+ ***
14
+
15
+ ### config
16
+
17
+ > **config**: [`IFileEntityStorageConnectorConfig`](IFileEntityStorageConnectorConfig.md)
18
+
19
+ The configuration for the connector.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/entity-storage-connector-file",
3
- "version": "0.0.1-next.3",
3
+ "version": "0.0.1-next.30",
4
4
  "description": "Entity Storage connector implementation using file storage",
5
5
  "repository": {
6
6
  "type": "git",
@@ -13,54 +13,23 @@
13
13
  "engines": {
14
14
  "node": ">=20.0.0"
15
15
  },
16
- "scripts": {
17
- "clean": "rimraf dist coverage docs/reference",
18
- "build": "tspc",
19
- "test": "vitest --run --config ./vitest.config.ts --no-cache",
20
- "coverage": "vitest --run --coverage --config ./vitest.config.ts --no-cache",
21
- "bundle:esm": "rollup --config rollup.config.mjs --environment MODULE:esm",
22
- "bundle:cjs": "rollup --config rollup.config.mjs --environment MODULE:cjs",
23
- "bundle": "npm run bundle:esm && npm run bundle:cjs",
24
- "docs:clean": "rimraf docs/reference",
25
- "docs:generate": "typedoc",
26
- "docs": "npm run docs:clean && npm run docs:generate",
27
- "dist": "npm run clean && npm run build && npm run test && npm run bundle && npm run docs"
28
- },
29
16
  "dependencies": {
30
17
  "@twin.org/core": "next",
31
18
  "@twin.org/entity": "next",
32
- "@twin.org/entity-storage-models": "0.0.1-next.3",
19
+ "@twin.org/entity-storage-models": "0.0.1-next.30",
33
20
  "@twin.org/logging-models": "next",
34
21
  "@twin.org/nameof": "next"
35
22
  },
36
- "devDependencies": {
37
- "@twin.org/entity-storage-connector-memory": "0.0.1-next.3",
38
- "@twin.org/logging-connector-entity-storage": "next",
39
- "@twin.org/nameof-transformer": "next",
40
- "@types/node": "22.5.5",
41
- "@vitest/coverage-v8": "2.1.1",
42
- "copyfiles": "2.4.1",
43
- "dotenv": "16.4.5",
44
- "rimraf": "6.0.1",
45
- "rollup": "4.21.3",
46
- "rollup-plugin-copy": "3.5.0",
47
- "rollup-plugin-typescript2": "0.36.0",
48
- "ts-patch": "3.2.1",
49
- "typedoc": "0.26.7",
50
- "typedoc-plugin-markdown": "4.2.7",
51
- "typescript": "5.6.2",
52
- "vitest": "2.1.1"
53
- },
54
23
  "main": "./dist/cjs/index.cjs",
55
24
  "module": "./dist/esm/index.mjs",
56
25
  "types": "./dist/types/index.d.ts",
57
26
  "exports": {
58
27
  ".": {
28
+ "types": "./dist/types/index.d.ts",
59
29
  "require": "./dist/cjs/index.cjs",
60
- "import": "./dist/esm/index.mjs",
61
- "types": "./dist/types/index.d.ts"
30
+ "import": "./dist/esm/index.mjs"
62
31
  },
63
- "./locales": "./locales"
32
+ "./locales/*.json": "./locales/*.json"
64
33
  },
65
34
  "files": [
66
35
  "dist/cjs",