@twin.org/entity-storage-models 0.0.2-next.9 → 0.0.3-next.10
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/{esm/index.mjs → es/factories/entityStorageConnectorFactory.js} +3 -5
- package/dist/es/factories/entityStorageConnectorFactory.js.map +1 -0
- package/dist/es/index.js +17 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IEntityStorageComponent.js +2 -0
- package/dist/es/models/IEntityStorageComponent.js.map +1 -0
- package/dist/es/models/IEntityStorageConnector.js +2 -0
- package/dist/es/models/IEntityStorageConnector.js.map +1 -0
- package/dist/es/models/api/IEntityStorageCountRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageCountRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageCountResponse.js +4 -0
- package/dist/es/models/api/IEntityStorageCountResponse.js.map +1 -0
- package/dist/es/models/api/IEntityStorageEmptyRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageEmptyRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageGetRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageGetRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageGetResponse.js +4 -0
- package/dist/es/models/api/IEntityStorageGetResponse.js.map +1 -0
- package/dist/es/models/api/IEntityStorageListRequest.js +2 -0
- package/dist/es/models/api/IEntityStorageListRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageListResponse.js +4 -0
- package/dist/es/models/api/IEntityStorageListResponse.js.map +1 -0
- package/dist/es/models/api/IEntityStorageRemoveBatchRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageRemoveBatchRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageRemoveRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageRemoveRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageSetBatchRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageSetBatchRequest.js.map +1 -0
- package/dist/es/models/api/IEntityStorageSetRequest.js +4 -0
- package/dist/es/models/api/IEntityStorageSetRequest.js.map +1 -0
- package/dist/types/factories/entityStorageConnectorFactory.d.ts +1 -1
- package/dist/types/index.d.ts +14 -9
- package/dist/types/models/IEntityStorageComponent.d.ts +28 -10
- package/dist/types/models/IEntityStorageConnector.d.ts +25 -3
- package/dist/types/models/api/IEntityStorageCountRequest.d.ts +5 -0
- package/dist/types/models/api/IEntityStorageCountResponse.d.ts +14 -0
- package/dist/types/models/api/IEntityStorageEmptyRequest.d.ts +5 -0
- package/dist/types/models/api/IEntityStorageListRequest.d.ts +2 -2
- package/dist/types/models/api/IEntityStorageRemoveBatchRequest.d.ts +9 -0
- package/dist/types/models/api/IEntityStorageSetBatchRequest.d.ts +9 -0
- package/docs/changelog.md +119 -30
- package/docs/examples.md +87 -1
- package/docs/reference/index.md +5 -0
- package/docs/reference/interfaces/IEntityStorageComponent.md +78 -30
- package/docs/reference/interfaces/IEntityStorageConnector.md +82 -10
- package/docs/reference/interfaces/IEntityStorageCountRequest.md +3 -0
- package/docs/reference/interfaces/IEntityStorageCountResponse.md +17 -0
- package/docs/reference/interfaces/IEntityStorageEmptyRequest.md +3 -0
- package/docs/reference/interfaces/IEntityStorageGetRequest.md +4 -4
- package/docs/reference/interfaces/IEntityStorageGetResponse.md +1 -1
- package/docs/reference/interfaces/IEntityStorageListRequest.md +10 -10
- package/docs/reference/interfaces/IEntityStorageListResponse.md +2 -2
- package/docs/reference/interfaces/IEntityStorageRemoveBatchRequest.md +11 -0
- package/docs/reference/interfaces/IEntityStorageRemoveRequest.md +1 -1
- package/docs/reference/interfaces/IEntityStorageSetBatchRequest.md +11 -0
- package/docs/reference/interfaces/IEntityStorageSetRequest.md +1 -1
- package/package.json +12 -10
- package/dist/cjs/index.cjs +0 -13
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Entity Storage Models
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
This package defines the shared domain models that standardise storage contracts, requests, responses and connector capabilities. It is designed to work with the wider storage ecosystem so applications can keep behaviour consistent across connectors and environments.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { Factory } from '@twin.org/core';
|
|
2
|
-
|
|
3
1
|
// Copyright 2024 IOTA Stiftung.
|
|
4
2
|
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { Factory } from "@twin.org/core";
|
|
5
4
|
/**
|
|
6
5
|
* Factory for creating entity storage connectors.
|
|
7
6
|
*/
|
|
8
7
|
// eslint-disable-next-line @typescript-eslint/naming-convention
|
|
9
|
-
const EntityStorageConnectorFactory = Factory.createFactory("entity-storage");
|
|
10
|
-
|
|
11
|
-
export { EntityStorageConnectorFactory };
|
|
8
|
+
export const EntityStorageConnectorFactory = Factory.createFactory("entity-storage");
|
|
9
|
+
//# sourceMappingURL=entityStorageConnectorFactory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entityStorageConnectorFactory.js","sourceRoot":"","sources":["../../../src/factories/entityStorageConnectorFactory.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAGzC;;GAEG;AACH,gEAAgE;AAChE,MAAM,CAAC,MAAM,6BAA6B,GACzC,OAAO,CAAC,aAAa,CAA0B,gBAAgB,CAAC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Factory } from \"@twin.org/core\";\nimport type { IEntityStorageConnector } from \"../models/IEntityStorageConnector.js\";\n\n/**\n * Factory for creating entity storage connectors.\n */\n// eslint-disable-next-line @typescript-eslint/naming-convention\nexport const EntityStorageConnectorFactory =\n\tFactory.createFactory<IEntityStorageConnector>(\"entity-storage\");\n"]}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
export * from "./factories/entityStorageConnectorFactory.js";
|
|
4
|
+
export * from "./models/api/IEntityStorageCountRequest.js";
|
|
5
|
+
export * from "./models/api/IEntityStorageEmptyRequest.js";
|
|
6
|
+
export * from "./models/api/IEntityStorageCountResponse.js";
|
|
7
|
+
export * from "./models/api/IEntityStorageGetRequest.js";
|
|
8
|
+
export * from "./models/api/IEntityStorageGetResponse.js";
|
|
9
|
+
export * from "./models/api/IEntityStorageListRequest.js";
|
|
10
|
+
export * from "./models/api/IEntityStorageListResponse.js";
|
|
11
|
+
export * from "./models/api/IEntityStorageRemoveBatchRequest.js";
|
|
12
|
+
export * from "./models/api/IEntityStorageRemoveRequest.js";
|
|
13
|
+
export * from "./models/api/IEntityStorageSetBatchRequest.js";
|
|
14
|
+
export * from "./models/api/IEntityStorageSetRequest.js";
|
|
15
|
+
export * from "./models/IEntityStorageComponent.js";
|
|
16
|
+
export * from "./models/IEntityStorageConnector.js";
|
|
17
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,8CAA8C,CAAC;AAC7D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,6CAA6C,CAAC;AAC5D,cAAc,0CAA0C,CAAC;AACzD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,2CAA2C,CAAC;AAC1D,cAAc,4CAA4C,CAAC;AAC3D,cAAc,kDAAkD,CAAC;AACjE,cAAc,6CAA6C,CAAC;AAC5D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,0CAA0C,CAAC;AACzD,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./factories/entityStorageConnectorFactory.js\";\nexport * from \"./models/api/IEntityStorageCountRequest.js\";\nexport * from \"./models/api/IEntityStorageEmptyRequest.js\";\nexport * from \"./models/api/IEntityStorageCountResponse.js\";\nexport * from \"./models/api/IEntityStorageGetRequest.js\";\nexport * from \"./models/api/IEntityStorageGetResponse.js\";\nexport * from \"./models/api/IEntityStorageListRequest.js\";\nexport * from \"./models/api/IEntityStorageListResponse.js\";\nexport * from \"./models/api/IEntityStorageRemoveBatchRequest.js\";\nexport * from \"./models/api/IEntityStorageRemoveRequest.js\";\nexport * from \"./models/api/IEntityStorageSetBatchRequest.js\";\nexport * from \"./models/api/IEntityStorageSetRequest.js\";\nexport * from \"./models/IEntityStorageComponent.js\";\nexport * from \"./models/IEntityStorageConnector.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageComponent.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageComponent.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { EntityCondition, SortDirection } from \"@twin.org/entity\";\n\n/**\n * Interface describing an entity storage component.\n */\nexport interface IEntityStorageComponent<T = unknown> extends IComponent {\n\t/**\n\t * Set an entity.\n\t * @param entity The entity to set.\n\t * @returns The id of the entity.\n\t */\n\tset(entity: T): Promise<void>;\n\n\t/**\n\t * Set multiple entities in a batch.\n\t * @param entities The entities to set.\n\t * @returns Nothing.\n\t */\n\tsetBatch(entities: T[]): Promise<void>;\n\n\t/**\n\t * Get an entity.\n\t * @param id The id of the entity to get, or the index value if secondaryIndex is set.\n\t * @param secondaryIndex Get the item using a secondary index.\n\t * @returns The object if it can be found or undefined.\n\t */\n\tget(id: string, secondaryIndex?: keyof T): Promise<T | undefined>;\n\n\t/**\n\t * Remove the entity.\n\t * @param id The id of the entity to remove.\n\t * @returns Nothing.\n\t */\n\tremove(id: string): Promise<void>;\n\n\t/**\n\t * Remove multiple entities by id.\n\t * @param ids The ids of the entities to remove.\n\t * @returns Nothing.\n\t */\n\tremoveBatch(ids: string[]): Promise<void>;\n\n\t/**\n\t * Query all the entities which match the conditions.\n\t * @param conditions The conditions to match for the entities.\n\t * @param orderBy The order for the results.\n\t * @param orderByDirection The direction for the order, defaults to ascending.\n\t * @param properties The optional properties to return, defaults to all.\n\t * @param cursor The cursor to request the next chunk of entities.\n\t * @param limit The suggested number of entities to return in each chunk, in some scenarios can return a different amount.\n\t * @returns All the entities for the storage matching the conditions,\n\t * and a cursor which can be used to request more entities.\n\t */\n\tquery(\n\t\tconditions?: EntityCondition<T>,\n\t\torderBy?: keyof T,\n\t\torderByDirection?: SortDirection,\n\t\tproperties?: (keyof T)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The entities, which can be partial if a limited keys list was provided.\n\t\t */\n\t\tentities: Partial<T>[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}>;\n\n\t/**\n\t * Remove all entities from the storage.\n\t * @returns Nothing.\n\t */\n\tempty(): Promise<void>;\n\n\t/**\n\t * Count all the entities which match the conditions.\n\t * @returns The total count of entities in the storage.\n\t */\n\tcount(): Promise<number>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageConnector.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageConnector.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IComponent } from \"@twin.org/core\";\nimport type { EntityCondition, IEntitySchema, SortDirection } from \"@twin.org/entity\";\n\n/**\n * Interface describing an entity storage connector.\n */\nexport interface IEntityStorageConnector<T = unknown> extends IComponent {\n\t/**\n\t * Get the schema for the entities.\n\t * @returns The schema for the entities.\n\t */\n\tgetSchema(): IEntitySchema;\n\n\t/**\n\t * Set an entity.\n\t * @param entity The entity to set.\n\t * @param conditions The optional conditions to match for the entities.\n\t * @returns The id of the entity.\n\t */\n\tset(entity: T, conditions?: { property: keyof T; value: unknown }[]): Promise<void>;\n\n\t/**\n\t * Set multiple entities in a batch.\n\t * @param entities The entities to set.\n\t * @returns Nothing.\n\t */\n\tsetBatch(entities: T[]): Promise<void>;\n\n\t/**\n\t * Get an entity.\n\t * @param id The id of the entity to get, or the index value if secondaryIndex is set.\n\t * @param secondaryIndex Get the item using a secondary index.\n\t * @param conditions The optional conditions to match for the entities.\n\t * @returns The object if it can be found or undefined.\n\t */\n\tget(\n\t\tid: string,\n\t\tsecondaryIndex?: keyof T,\n\t\tconditions?: { property: keyof T; value: unknown }[]\n\t): Promise<T | undefined>;\n\n\t/**\n\t * Remove the entity.\n\t * @param id The id of the entity to remove.\n\t * @param conditions The optional conditions to match for the entities.\n\t * @returns Nothing.\n\t */\n\tremove(id: string, conditions?: { property: keyof T; value: unknown }[]): Promise<void>;\n\n\t/**\n\t * Remove multiple entities by id.\n\t * @param ids The ids of the entities to remove.\n\t * @returns Nothing.\n\t */\n\tremoveBatch(ids: string[]): Promise<void>;\n\n\t/**\n\t * Query all the entities which match the conditions.\n\t * @param conditions The conditions to match for the entities.\n\t * @param sortProperties The optional sort order.\n\t * @param properties The optional properties to return, defaults to all.\n\t * @param cursor The cursor to request the next chunk of entities.\n\t * @param limit The suggested number of entities to return in each chunk, in some scenarios can return a different amount.\n\t * @returns All the entities for the storage matching the conditions,\n\t * and a cursor which can be used to request more entities.\n\t */\n\tquery(\n\t\tconditions?: EntityCondition<T>,\n\t\tsortProperties?: {\n\t\t\tproperty: keyof T;\n\t\t\tsortDirection: SortDirection;\n\t\t}[],\n\t\tproperties?: (keyof T)[],\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{\n\t\t/**\n\t\t * The entities, which can be partial if a limited keys list was provided.\n\t\t */\n\t\tentities: Partial<T>[];\n\t\t/**\n\t\t * An optional cursor, when defined can be used to call find to get more entities.\n\t\t */\n\t\tcursor?: string;\n\t}>;\n\n\t/**\n\t * Remove all entities from the storage.\n\t * @returns Nothing.\n\t */\n\tempty(): Promise<void>;\n\n\t/**\n\t * Count all the entities which match the conditions.\n\t * @returns The total count of entities in the storage.\n\t */\n\tcount(): Promise<number>;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageCountRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IEntityStorageCountRequest.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Count the entries in entity storage.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IEntityStorageCountRequest {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageCountResponse.js","sourceRoot":"","sources":["../../../../src/models/api/IEntityStorageCountResponse.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * The response for counting entries in entity storage.\n */\nexport interface IEntityStorageCountResponse {\n\t/**\n\t * The body of the response.\n\t */\n\tbody: {\n\t\t/**\n\t\t * The total count of entities.\n\t\t */\n\t\tcount: number;\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageEmptyRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IEntityStorageEmptyRequest.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Remove all entries from entity storage.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IEntityStorageEmptyRequest {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageGetRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IEntityStorageGetRequest.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Get an entry from entity storage.\n */\nexport interface IEntityStorageGetRequest {\n\t/**\n\t * The parameters from the path.\n\t */\n\tpathParams: {\n\t\t/**\n\t\t * The id of the entity to get.\n\t\t */\n\t\tid: string;\n\t};\n\n\t/**\n\t * The query parameters.\n\t */\n\tquery?: {\n\t\t/**\n\t\t * The secondary index to query with the id.\n\t\t */\n\t\tsecondaryIndex?: string;\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageGetResponse.js","sourceRoot":"","sources":["../../../../src/models/api/IEntityStorageGetResponse.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Get an entry from entity storage.\n */\nexport interface IEntityStorageGetResponse {\n\t/**\n\t * The data for the requested entity.\n\t */\n\tbody: unknown;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageListRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IEntityStorageListRequest.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { SortDirection } from \"@twin.org/entity\";\n\n/**\n * Query the entries from entity storage.\n */\nexport interface IEntityStorageListRequest {\n\t/**\n\t * The parameters from the query.\n\t */\n\tquery?: {\n\t\t/**\n\t\t * The condition for the query as JSON version of EntityCondition type.\n\t\t */\n\t\tconditions?: string;\n\n\t\t/**\n\t\t * The order property for the results.\n\t\t */\n\t\torderBy?: string;\n\n\t\t/**\n\t\t * The direction for the order, defaults to desc.\n\t\t */\n\t\torderByDirection?: SortDirection;\n\n\t\t/**\n\t\t * The properties to return in the response as a comma separated list, by default returns all properties.\n\t\t */\n\t\tproperties?: string;\n\n\t\t/**\n\t\t * Limit the number of entities to return.\n\t\t */\n\t\tlimit?: string;\n\n\t\t/**\n\t\t * The cursor to get next chunk of data, returned in previous response.\n\t\t */\n\t\tcursor?: string;\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageListResponse.js","sourceRoot":"","sources":["../../../../src/models/api/IEntityStorageListResponse.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Response to getting the list of entries from a query.\n */\nexport interface IEntityStorageListResponse {\n\t/**\n\t * The list of entries from the query.\n\t */\n\tbody: {\n\t\t/**\n\t\t * The entities from the query.\n\t\t */\n\t\tentities: unknown[];\n\n\t\t/**\n\t\t * The cursor for the next page.\n\t\t */\n\t\tcursor?: string;\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageRemoveBatchRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IEntityStorageRemoveBatchRequest.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Remove multiple entries from entity storage by id.\n */\nexport interface IEntityStorageRemoveBatchRequest {\n\t/**\n\t * The ids of the entities to remove.\n\t */\n\tbody: string[];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageRemoveRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IEntityStorageRemoveRequest.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Remove an entry from entity storage.\n */\nexport interface IEntityStorageRemoveRequest {\n\t/**\n\t * The parameters from the path.\n\t */\n\tpathParams: {\n\t\t/**\n\t\t * The id of the entity to remove.\n\t\t */\n\t\tid: string;\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageSetBatchRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IEntityStorageSetBatchRequest.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Set multiple entries in entity storage.\n */\nexport interface IEntityStorageSetBatchRequest {\n\t/**\n\t * The entities to set.\n\t */\n\tbody: unknown[];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageSetRequest.js","sourceRoot":"","sources":["../../../../src/models/api/IEntityStorageSetRequest.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Set an entry in entity storage.\n */\nexport interface IEntityStorageSetRequest {\n\t/**\n\t * The data to be used in the entity.\n\t */\n\tbody: unknown;\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Factory } from "@twin.org/core";
|
|
2
|
-
import type { IEntityStorageConnector } from "../models/IEntityStorageConnector";
|
|
2
|
+
import type { IEntityStorageConnector } from "../models/IEntityStorageConnector.js";
|
|
3
3
|
/**
|
|
4
4
|
* Factory for creating entity storage connectors.
|
|
5
5
|
*/
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,9 +1,14 @@
|
|
|
1
|
-
export * from "./factories/entityStorageConnectorFactory";
|
|
2
|
-
export * from "./models/api/
|
|
3
|
-
export * from "./models/api/
|
|
4
|
-
export * from "./models/api/
|
|
5
|
-
export * from "./models/api/
|
|
6
|
-
export * from "./models/api/
|
|
7
|
-
export * from "./models/api/
|
|
8
|
-
export * from "./models/
|
|
9
|
-
export * from "./models/
|
|
1
|
+
export * from "./factories/entityStorageConnectorFactory.js";
|
|
2
|
+
export * from "./models/api/IEntityStorageCountRequest.js";
|
|
3
|
+
export * from "./models/api/IEntityStorageEmptyRequest.js";
|
|
4
|
+
export * from "./models/api/IEntityStorageCountResponse.js";
|
|
5
|
+
export * from "./models/api/IEntityStorageGetRequest.js";
|
|
6
|
+
export * from "./models/api/IEntityStorageGetResponse.js";
|
|
7
|
+
export * from "./models/api/IEntityStorageListRequest.js";
|
|
8
|
+
export * from "./models/api/IEntityStorageListResponse.js";
|
|
9
|
+
export * from "./models/api/IEntityStorageRemoveBatchRequest.js";
|
|
10
|
+
export * from "./models/api/IEntityStorageRemoveRequest.js";
|
|
11
|
+
export * from "./models/api/IEntityStorageSetBatchRequest.js";
|
|
12
|
+
export * from "./models/api/IEntityStorageSetRequest.js";
|
|
13
|
+
export * from "./models/IEntityStorageComponent.js";
|
|
14
|
+
export * from "./models/IEntityStorageConnector.js";
|
|
@@ -7,38 +7,46 @@ export interface IEntityStorageComponent<T = unknown> extends IComponent {
|
|
|
7
7
|
/**
|
|
8
8
|
* Set an entity.
|
|
9
9
|
* @param entity The entity to set.
|
|
10
|
-
* @param userIdentity The user identity to use with storage operations.
|
|
11
10
|
* @returns The id of the entity.
|
|
12
11
|
*/
|
|
13
|
-
set(entity: T
|
|
12
|
+
set(entity: T): Promise<void>;
|
|
13
|
+
/**
|
|
14
|
+
* Set multiple entities in a batch.
|
|
15
|
+
* @param entities The entities to set.
|
|
16
|
+
* @returns Nothing.
|
|
17
|
+
*/
|
|
18
|
+
setBatch(entities: T[]): Promise<void>;
|
|
14
19
|
/**
|
|
15
20
|
* Get an entity.
|
|
16
21
|
* @param id The id of the entity to get, or the index value if secondaryIndex is set.
|
|
17
22
|
* @param secondaryIndex Get the item using a secondary index.
|
|
18
|
-
* @param userIdentity The user identity to use with storage operations.
|
|
19
23
|
* @returns The object if it can be found or undefined.
|
|
20
24
|
*/
|
|
21
|
-
get(id: string, secondaryIndex?: keyof T
|
|
25
|
+
get(id: string, secondaryIndex?: keyof T): Promise<T | undefined>;
|
|
22
26
|
/**
|
|
23
27
|
* Remove the entity.
|
|
24
28
|
* @param id The id of the entity to remove.
|
|
25
|
-
* @param userIdentity The user identity to use with storage operations.
|
|
26
29
|
* @returns Nothing.
|
|
27
30
|
*/
|
|
28
|
-
remove(id: string
|
|
31
|
+
remove(id: string): Promise<void>;
|
|
32
|
+
/**
|
|
33
|
+
* Remove multiple entities by id.
|
|
34
|
+
* @param ids The ids of the entities to remove.
|
|
35
|
+
* @returns Nothing.
|
|
36
|
+
*/
|
|
37
|
+
removeBatch(ids: string[]): Promise<void>;
|
|
29
38
|
/**
|
|
30
39
|
* Query all the entities which match the conditions.
|
|
31
40
|
* @param conditions The conditions to match for the entities.
|
|
32
41
|
* @param orderBy The order for the results.
|
|
33
42
|
* @param orderByDirection The direction for the order, defaults to ascending.
|
|
34
43
|
* @param properties The optional properties to return, defaults to all.
|
|
35
|
-
* @param cursor The cursor to request the next
|
|
36
|
-
* @param
|
|
37
|
-
* @param userIdentity The user identity to use with storage operations.
|
|
44
|
+
* @param cursor The cursor to request the next chunk of entities.
|
|
45
|
+
* @param limit The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
|
|
38
46
|
* @returns All the entities for the storage matching the conditions,
|
|
39
47
|
* and a cursor which can be used to request more entities.
|
|
40
48
|
*/
|
|
41
|
-
query(conditions?: EntityCondition<T>, orderBy?: keyof T, orderByDirection?: SortDirection, properties?: (keyof T)[], cursor?: string,
|
|
49
|
+
query(conditions?: EntityCondition<T>, orderBy?: keyof T, orderByDirection?: SortDirection, properties?: (keyof T)[], cursor?: string, limit?: number): Promise<{
|
|
42
50
|
/**
|
|
43
51
|
* The entities, which can be partial if a limited keys list was provided.
|
|
44
52
|
*/
|
|
@@ -48,4 +56,14 @@ export interface IEntityStorageComponent<T = unknown> extends IComponent {
|
|
|
48
56
|
*/
|
|
49
57
|
cursor?: string;
|
|
50
58
|
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Remove all entities from the storage.
|
|
61
|
+
* @returns Nothing.
|
|
62
|
+
*/
|
|
63
|
+
empty(): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Count all the entities which match the conditions.
|
|
66
|
+
* @returns The total count of entities in the storage.
|
|
67
|
+
*/
|
|
68
|
+
count(): Promise<number>;
|
|
51
69
|
}
|
|
@@ -19,6 +19,12 @@ export interface IEntityStorageConnector<T = unknown> extends IComponent {
|
|
|
19
19
|
property: keyof T;
|
|
20
20
|
value: unknown;
|
|
21
21
|
}[]): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Set multiple entities in a batch.
|
|
24
|
+
* @param entities The entities to set.
|
|
25
|
+
* @returns Nothing.
|
|
26
|
+
*/
|
|
27
|
+
setBatch(entities: T[]): Promise<void>;
|
|
22
28
|
/**
|
|
23
29
|
* Get an entity.
|
|
24
30
|
* @param id The id of the entity to get, or the index value if secondaryIndex is set.
|
|
@@ -40,20 +46,26 @@ export interface IEntityStorageConnector<T = unknown> extends IComponent {
|
|
|
40
46
|
property: keyof T;
|
|
41
47
|
value: unknown;
|
|
42
48
|
}[]): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Remove multiple entities by id.
|
|
51
|
+
* @param ids The ids of the entities to remove.
|
|
52
|
+
* @returns Nothing.
|
|
53
|
+
*/
|
|
54
|
+
removeBatch(ids: string[]): Promise<void>;
|
|
43
55
|
/**
|
|
44
56
|
* Query all the entities which match the conditions.
|
|
45
57
|
* @param conditions The conditions to match for the entities.
|
|
46
58
|
* @param sortProperties The optional sort order.
|
|
47
59
|
* @param properties The optional properties to return, defaults to all.
|
|
48
|
-
* @param cursor The cursor to request the next
|
|
49
|
-
* @param
|
|
60
|
+
* @param cursor The cursor to request the next chunk of entities.
|
|
61
|
+
* @param limit The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
|
|
50
62
|
* @returns All the entities for the storage matching the conditions,
|
|
51
63
|
* and a cursor which can be used to request more entities.
|
|
52
64
|
*/
|
|
53
65
|
query(conditions?: EntityCondition<T>, sortProperties?: {
|
|
54
66
|
property: keyof T;
|
|
55
67
|
sortDirection: SortDirection;
|
|
56
|
-
}[], properties?: (keyof T)[], cursor?: string,
|
|
68
|
+
}[], properties?: (keyof T)[], cursor?: string, limit?: number): Promise<{
|
|
57
69
|
/**
|
|
58
70
|
* The entities, which can be partial if a limited keys list was provided.
|
|
59
71
|
*/
|
|
@@ -63,4 +75,14 @@ export interface IEntityStorageConnector<T = unknown> extends IComponent {
|
|
|
63
75
|
*/
|
|
64
76
|
cursor?: string;
|
|
65
77
|
}>;
|
|
78
|
+
/**
|
|
79
|
+
* Remove all entities from the storage.
|
|
80
|
+
* @returns Nothing.
|
|
81
|
+
*/
|
|
82
|
+
empty(): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Count all the entities which match the conditions.
|
|
85
|
+
* @returns The total count of entities in the storage.
|
|
86
|
+
*/
|
|
87
|
+
count(): Promise<number>;
|
|
66
88
|
}
|
|
@@ -24,9 +24,9 @@ export interface IEntityStorageListRequest {
|
|
|
24
24
|
*/
|
|
25
25
|
properties?: string;
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Limit the number of entities to return.
|
|
28
28
|
*/
|
|
29
|
-
|
|
29
|
+
limit?: string;
|
|
30
30
|
/**
|
|
31
31
|
* The cursor to get next chunk of data, returned in previous response.
|
|
32
32
|
*/
|