@twin.org/entity-storage-service 0.0.2-next.8 → 0.0.3-next.1
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/dist/es/entityStorageRoutes.js +227 -0
- package/dist/es/entityStorageRoutes.js.map +1 -0
- package/dist/es/entityStorageService.js +122 -0
- package/dist/es/entityStorageService.js.map +1 -0
- package/dist/es/index.js +9 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/models/IEntityStorageRoutesExamples.js +2 -0
- package/dist/es/models/IEntityStorageRoutesExamples.js.map +1 -0
- package/dist/es/models/IEntityStorageServiceConfig.js +4 -0
- package/dist/es/models/IEntityStorageServiceConfig.js.map +1 -0
- package/dist/es/models/IEntityStorageServiceConstructorOptions.js +2 -0
- package/dist/es/models/IEntityStorageServiceConstructorOptions.js.map +1 -0
- package/dist/es/restEntryPoints.js +15 -0
- package/dist/es/restEntryPoints.js.map +1 -0
- package/dist/types/entityStorageRoutes.d.ts +1 -1
- package/dist/types/entityStorageService.d.ts +13 -12
- package/dist/types/index.d.ts +6 -6
- package/dist/types/models/IEntityStorageServiceConfig.d.ts +5 -0
- package/dist/types/models/IEntityStorageServiceConstructorOptions.d.ts +2 -2
- package/docs/changelog.md +61 -0
- package/docs/open-api/spec.json +14 -279
- package/docs/reference/classes/EntityStorageService.md +24 -34
- package/docs/reference/index.md +1 -1
- package/docs/reference/interfaces/IEntityStorageServiceConfig.md +3 -0
- package/docs/reference/interfaces/IEntityStorageServiceConstructorOptions.md +1 -1
- package/locales/en.json +1 -1
- package/package.json +26 -9
- package/dist/cjs/index.cjs +0 -421
- package/dist/esm/index.mjs +0 -412
- package/dist/types/models/IEntityStorageConfig.d.ts +0 -10
- package/docs/reference/interfaces/IEntityStorageConfig.md +0 -17
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { HttpParameterHelper } from "@twin.org/api-models";
|
|
4
|
+
import { Coerce, ComponentFactory, Guards, StringHelper } from "@twin.org/core";
|
|
5
|
+
import { HttpStatusCode } from "@twin.org/web";
|
|
6
|
+
/**
|
|
7
|
+
* The source used when communicating about these routes.
|
|
8
|
+
*/
|
|
9
|
+
const ROUTES_SOURCE = "entityStorageRoutes";
|
|
10
|
+
/**
|
|
11
|
+
* The tag to associate with the routes.
|
|
12
|
+
*/
|
|
13
|
+
export const tagsEntityStorage = [
|
|
14
|
+
{
|
|
15
|
+
name: "EntityStorage",
|
|
16
|
+
description: "Endpoints which are modelled to access an entity storage contract."
|
|
17
|
+
}
|
|
18
|
+
];
|
|
19
|
+
/**
|
|
20
|
+
* The REST routes for entity storage.
|
|
21
|
+
* @param baseRouteName Prefix to prepend to the paths.
|
|
22
|
+
* @param componentName The name of the component to use in the routes stored in the ComponentFactory.
|
|
23
|
+
* @param options Additional options for the routes.
|
|
24
|
+
* @param options.typeName Optional type name to use in the routes, defaults to Entity Storage.
|
|
25
|
+
* @param options.tagName Optional name to use in OpenAPI spec for tag.
|
|
26
|
+
* @param options.examples Optional examples to use in the routes.
|
|
27
|
+
* @returns The generated routes.
|
|
28
|
+
*/
|
|
29
|
+
export function generateRestRoutesEntityStorage(baseRouteName, componentName, options) {
|
|
30
|
+
const typeName = options?.typeName ?? "Entity Storage";
|
|
31
|
+
const lowerName = typeName.toLowerCase();
|
|
32
|
+
const camelTypeName = StringHelper.camelCase(typeName);
|
|
33
|
+
const setRoute = {
|
|
34
|
+
operationId: `${camelTypeName}Set`,
|
|
35
|
+
summary: `Set an entry in ${lowerName}.`,
|
|
36
|
+
tag: options?.tagName ?? tagsEntityStorage[0].name,
|
|
37
|
+
method: "POST",
|
|
38
|
+
path: `${baseRouteName}/`,
|
|
39
|
+
handler: async (httpRequestContext, request) => entityStorageSet(httpRequestContext, componentName, request),
|
|
40
|
+
requestType: {
|
|
41
|
+
type: "IEntityStorageSetRequest",
|
|
42
|
+
examples: options?.examples?.set?.requestExamples ?? [
|
|
43
|
+
{
|
|
44
|
+
id: `${camelTypeName}SetRequestExample`,
|
|
45
|
+
request: {
|
|
46
|
+
body: {
|
|
47
|
+
id: "12345",
|
|
48
|
+
name: "My Item"
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
responseType: [
|
|
55
|
+
{
|
|
56
|
+
type: "INoContentResponse"
|
|
57
|
+
}
|
|
58
|
+
]
|
|
59
|
+
};
|
|
60
|
+
const getRoute = {
|
|
61
|
+
operationId: `${camelTypeName}Get`,
|
|
62
|
+
summary: `Get an entry from ${lowerName}.`,
|
|
63
|
+
tag: options?.tagName ?? tagsEntityStorage[0].name,
|
|
64
|
+
method: "GET",
|
|
65
|
+
path: `${baseRouteName}/:id`,
|
|
66
|
+
handler: async (httpRequestContext, request) => entityStorageGet(httpRequestContext, componentName, request),
|
|
67
|
+
requestType: {
|
|
68
|
+
type: "IEntityStorageGetRequest",
|
|
69
|
+
examples: options?.examples?.get?.requestExamples ?? [
|
|
70
|
+
{
|
|
71
|
+
id: `${camelTypeName}GetRequestExample`,
|
|
72
|
+
request: {
|
|
73
|
+
pathParams: {
|
|
74
|
+
id: "12345"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
responseType: [
|
|
81
|
+
{
|
|
82
|
+
type: "IEntityStorageGetResponse",
|
|
83
|
+
examples: options?.examples?.get?.responseExamples ?? [
|
|
84
|
+
{
|
|
85
|
+
id: `${camelTypeName}GetResponseExample`,
|
|
86
|
+
response: {
|
|
87
|
+
body: {
|
|
88
|
+
id: "12345",
|
|
89
|
+
name: "My Item"
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
]
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
type: "INotFoundResponse"
|
|
97
|
+
}
|
|
98
|
+
]
|
|
99
|
+
};
|
|
100
|
+
const removeRoute = {
|
|
101
|
+
operationId: `${camelTypeName}Remove`,
|
|
102
|
+
summary: `Remove an entry from ${lowerName}.`,
|
|
103
|
+
tag: options?.tagName ?? tagsEntityStorage[0].name,
|
|
104
|
+
method: "DELETE",
|
|
105
|
+
path: `${baseRouteName}/:id`,
|
|
106
|
+
handler: async (httpRequestContext, request) => entityStorageRemove(httpRequestContext, componentName, request),
|
|
107
|
+
requestType: {
|
|
108
|
+
type: "IEntityStorageRemoveRequest",
|
|
109
|
+
examples: options?.examples?.remove?.requestExamples ?? [
|
|
110
|
+
{
|
|
111
|
+
id: `${camelTypeName}RemoveRequestExample`,
|
|
112
|
+
request: {
|
|
113
|
+
pathParams: {
|
|
114
|
+
id: "12345"
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
]
|
|
119
|
+
},
|
|
120
|
+
responseType: [
|
|
121
|
+
{
|
|
122
|
+
type: "INoContentResponse"
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
type: "INotFoundResponse"
|
|
126
|
+
}
|
|
127
|
+
]
|
|
128
|
+
};
|
|
129
|
+
const listRoute = {
|
|
130
|
+
operationId: `${camelTypeName}List`,
|
|
131
|
+
summary: `Query entries from ${lowerName}.`,
|
|
132
|
+
tag: options?.tagName ?? tagsEntityStorage[0].name,
|
|
133
|
+
method: "GET",
|
|
134
|
+
path: `${baseRouteName}/`,
|
|
135
|
+
handler: async (httpRequestContext, request) => entityStorageList(httpRequestContext, componentName, request),
|
|
136
|
+
requestType: {
|
|
137
|
+
type: "IEntityStorageListRequest",
|
|
138
|
+
examples: options?.examples?.list?.requestExamples ?? [
|
|
139
|
+
{
|
|
140
|
+
id: `${camelTypeName}ListRequestExample`,
|
|
141
|
+
request: {}
|
|
142
|
+
}
|
|
143
|
+
]
|
|
144
|
+
},
|
|
145
|
+
responseType: [
|
|
146
|
+
{
|
|
147
|
+
type: "IEntityStorageListResponse",
|
|
148
|
+
examples: options?.examples?.list?.responseExamples ?? [
|
|
149
|
+
{
|
|
150
|
+
id: `${camelTypeName}ListResponseExample`,
|
|
151
|
+
response: {
|
|
152
|
+
body: {
|
|
153
|
+
entities: [{ id: "12345", name: "My Item" }]
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
]
|
|
158
|
+
}
|
|
159
|
+
]
|
|
160
|
+
};
|
|
161
|
+
return [setRoute, getRoute, removeRoute, listRoute];
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Set the entry in entity storage.
|
|
165
|
+
* @param httpRequestContext The request context for the API.
|
|
166
|
+
* @param componentName The name of the component to use in the routes.
|
|
167
|
+
* @param request The request.
|
|
168
|
+
* @returns The response object with additional http response properties.
|
|
169
|
+
*/
|
|
170
|
+
export async function entityStorageSet(httpRequestContext, componentName, request) {
|
|
171
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
172
|
+
const component = ComponentFactory.get(componentName);
|
|
173
|
+
await component.set(request.body);
|
|
174
|
+
return {
|
|
175
|
+
statusCode: HttpStatusCode.noContent
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Get the entry from entity storage.
|
|
180
|
+
* @param httpRequestContext The request context for the API.
|
|
181
|
+
* @param componentName The name of the component to use in the routes.
|
|
182
|
+
* @param request The request.
|
|
183
|
+
* @returns The response object with additional http response properties.
|
|
184
|
+
*/
|
|
185
|
+
export async function entityStorageGet(httpRequestContext, componentName, request) {
|
|
186
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
187
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
188
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
189
|
+
const component = ComponentFactory.get(componentName);
|
|
190
|
+
const item = await component.get(request.pathParams.id, request.query?.secondaryIndex);
|
|
191
|
+
return {
|
|
192
|
+
body: item
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Remove the entry from entity storage.
|
|
197
|
+
* @param httpRequestContext The request context for the API.
|
|
198
|
+
* @param componentName The name of the component to use in the routes.
|
|
199
|
+
* @param request The request.
|
|
200
|
+
* @returns The response object with additional http response properties.
|
|
201
|
+
*/
|
|
202
|
+
export async function entityStorageRemove(httpRequestContext, componentName, request) {
|
|
203
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
204
|
+
Guards.object(ROUTES_SOURCE, "request.pathParams", request.pathParams);
|
|
205
|
+
Guards.stringValue(ROUTES_SOURCE, "request.pathParams.id", request.pathParams.id);
|
|
206
|
+
const component = ComponentFactory.get(componentName);
|
|
207
|
+
await component.remove(request.pathParams.id);
|
|
208
|
+
return {
|
|
209
|
+
statusCode: HttpStatusCode.noContent
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Query the entries from entity storage.
|
|
214
|
+
* @param httpRequestContext The request context for the API.
|
|
215
|
+
* @param componentName The name of the component to use in the routes.
|
|
216
|
+
* @param request The request.
|
|
217
|
+
* @returns The response object with additional http response properties.
|
|
218
|
+
*/
|
|
219
|
+
export async function entityStorageList(httpRequestContext, componentName, request) {
|
|
220
|
+
Guards.object(ROUTES_SOURCE, "request", request);
|
|
221
|
+
const component = ComponentFactory.get(componentName);
|
|
222
|
+
const result = await component.query(HttpParameterHelper.objectFromString(request.query?.conditions), request.query?.orderBy, request.query?.orderByDirection, HttpParameterHelper.objectFromString(request.query?.properties), request.query?.cursor, Coerce.number(request.query?.limit));
|
|
223
|
+
return {
|
|
224
|
+
body: result
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
//# sourceMappingURL=entityStorageRoutes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entityStorageRoutes.js","sourceRoot":"","sources":["../../src/entityStorageRoutes.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EACN,mBAAmB,EAMnB,MAAM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otFoundResponse,\n\ttype IHttpRequestContext,\n\ttype INoContentResponse,\n\ttype IRestRoute,\n\ttype ITag\n} from \"@twin.org/api-models\";\nimport { Coerce, ComponentFactory, Guards, StringHelper } from \"@twin.org/core\";\nimport type {\n\tIEntityStorageComponent,\n\tIEntityStorageGetRequest,\n\tIEntityStorageGetResponse,\n\tIEntityStorageListRequest,\n\tIEntityStorageListResponse,\n\tIEntityStorageRemoveRequest,\n\tIEntityStorageSetRequest\n} from \"@twin.org/entity-storage-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport { HttpStatusCode } from \"@twin.org/web\";\nimport type { IEntityStorageRoutesExamples } from \"./models/IEntityStorageRoutesExamples.js\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"entityStorageRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsEntityStorage: ITag[] = [\n\t{\n\t\tname: \"EntityStorage\",\n\t\tdescription: \"Endpoints which are modelled to access an entity storage contract.\"\n\t}\n];\n\n/**\n * The REST routes for entity storage.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @param options Additional options for the routes.\n * @param options.typeName Optional type name to use in the routes, defaults to Entity Storage.\n * @param options.tagName Optional name to use in OpenAPI spec for tag.\n * @param options.examples Optional examples to use in the routes.\n * @returns The generated routes.\n */\nexport function generateRestRoutesEntityStorage(\n\tbaseRouteName: string,\n\tcomponentName: string,\n\toptions?: {\n\t\ttypeName?: string;\n\t\ttagName?: string;\n\t\texamples?: IEntityStorageRoutesExamples;\n\t}\n): IRestRoute[] {\n\tconst typeName = options?.typeName ?? \"Entity Storage\";\n\tconst lowerName = typeName.toLowerCase();\n\tconst camelTypeName = StringHelper.camelCase(typeName);\n\n\tconst setRoute: IRestRoute<IEntityStorageSetRequest, INoContentResponse> = {\n\t\toperationId: `${camelTypeName}Set`,\n\t\tsummary: `Set an entry in ${lowerName}.`,\n\t\ttag: options?.tagName ?? tagsEntityStorage[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tentityStorageSet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IEntityStorageSetRequest>(),\n\t\t\texamples: options?.examples?.set?.requestExamples ?? [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}SetRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\tid: \"12345\",\n\t\t\t\t\t\t\tname: \"My Item\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst getRoute: IRestRoute<IEntityStorageGetRequest, IEntityStorageGetResponse> = {\n\t\toperationId: `${camelTypeName}Get`,\n\t\tsummary: `Get an entry from ${lowerName}.`,\n\t\ttag: options?.tagName ?? tagsEntityStorage[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tentityStorageGet(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IEntityStorageGetRequest>(),\n\t\t\texamples: options?.examples?.get?.requestExamples ?? [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}GetRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"12345\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IEntityStorageGetResponse>(),\n\t\t\t\texamples: options?.examples?.get?.responseExamples ?? [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}GetResponseExample`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tid: \"12345\",\n\t\t\t\t\t\t\t\tname: \"My Item\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst removeRoute: IRestRoute<IEntityStorageRemoveRequest, INoContentResponse> = {\n\t\toperationId: `${camelTypeName}Remove`,\n\t\tsummary: `Remove an entry from ${lowerName}.`,\n\t\ttag: options?.tagName ?? tagsEntityStorage[0].name,\n\t\tmethod: \"DELETE\",\n\t\tpath: `${baseRouteName}/:id`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tentityStorageRemove(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IEntityStorageRemoveRequest>(),\n\t\t\texamples: options?.examples?.remove?.requestExamples ?? [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}RemoveRequestExample`,\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tid: \"12345\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<INoContentResponse>()\n\t\t\t},\n\t\t\t{\n\t\t\t\ttype: nameof<INotFoundResponse>()\n\t\t\t}\n\t\t]\n\t};\n\n\tconst listRoute: IRestRoute<IEntityStorageListRequest, IEntityStorageListResponse> = {\n\t\toperationId: `${camelTypeName}List`,\n\t\tsummary: `Query entries from ${lowerName}.`,\n\t\ttag: options?.tagName ?? tagsEntityStorage[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tentityStorageList(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IEntityStorageListRequest>(),\n\t\t\texamples: options?.examples?.list?.requestExamples ?? [\n\t\t\t\t{\n\t\t\t\t\tid: `${camelTypeName}ListRequestExample`,\n\t\t\t\t\trequest: {}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IEntityStorageListResponse>(),\n\t\t\t\texamples: options?.examples?.list?.responseExamples ?? [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: `${camelTypeName}ListResponseExample`,\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\tentities: [{ id: \"12345\", name: \"My Item\" }]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [setRoute, getRoute, removeRoute, listRoute];\n}\n\n/**\n * Set the entry in entity storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function entityStorageSet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IEntityStorageSetRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IEntityStorageSetRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tconst component = ComponentFactory.get<IEntityStorageComponent>(componentName);\n\tawait component.set(request.body);\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Get the entry from entity storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function entityStorageGet(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IEntityStorageGetRequest\n): Promise<IEntityStorageGetResponse> {\n\tGuards.object<IEntityStorageGetRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IEntityStorageGetRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IEntityStorageComponent>(componentName);\n\tconst item = await component.get(\n\t\trequest.pathParams.id,\n\t\trequest.query?.secondaryIndex as keyof unknown\n\t);\n\treturn {\n\t\tbody: item\n\t};\n}\n\n/**\n * Remove the entry from entity storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function entityStorageRemove(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IEntityStorageRemoveRequest\n): Promise<INoContentResponse> {\n\tGuards.object<IEntityStorageRemoveRequest>(ROUTES_SOURCE, nameof(request), request);\n\tGuards.object<IEntityStorageRemoveRequest[\"pathParams\"]>(\n\t\tROUTES_SOURCE,\n\t\tnameof(request.pathParams),\n\t\trequest.pathParams\n\t);\n\tGuards.stringValue(ROUTES_SOURCE, nameof(request.pathParams.id), request.pathParams.id);\n\n\tconst component = ComponentFactory.get<IEntityStorageComponent>(componentName);\n\tawait component.remove(request.pathParams.id);\n\treturn {\n\t\tstatusCode: HttpStatusCode.noContent\n\t};\n}\n\n/**\n * Query the entries from entity storage.\n * @param httpRequestContext The request context for the API.\n * @param componentName The name of the component to use in the routes.\n * @param request The request.\n * @returns The response object with additional http response properties.\n */\nexport async function entityStorageList(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IEntityStorageListRequest\n): Promise<IEntityStorageListResponse> {\n\tGuards.object<IEntityStorageListRequest>(ROUTES_SOURCE, nameof(request), request);\n\n\tconst component = ComponentFactory.get<IEntityStorageComponent>(componentName);\n\tconst result = await component.query(\n\t\tHttpParameterHelper.objectFromString(request.query?.conditions),\n\t\trequest.query?.orderBy as keyof unknown,\n\t\trequest.query?.orderByDirection,\n\t\tHttpParameterHelper.objectFromString(request.query?.properties),\n\t\trequest.query?.cursor,\n\t\tCoerce.number(request.query?.limit)\n\t);\n\treturn {\n\t\tbody: result\n\t};\n}\n"]}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { Guards, Is, NotFoundError } from "@twin.org/core";
|
|
4
|
+
import { ComparisonOperator, EntitySchemaHelper, LogicalOperator, SortDirection } from "@twin.org/entity";
|
|
5
|
+
import { EntityStorageConnectorFactory } from "@twin.org/entity-storage-models";
|
|
6
|
+
/**
|
|
7
|
+
* Class for performing entity service operations.
|
|
8
|
+
*/
|
|
9
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
10
|
+
export class EntityStorageService {
|
|
11
|
+
/**
|
|
12
|
+
* Runtime name for the class.
|
|
13
|
+
*/
|
|
14
|
+
static CLASS_NAME = "EntityStorageService";
|
|
15
|
+
/**
|
|
16
|
+
* The entity storage for items.
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
_entityStorage;
|
|
20
|
+
/**
|
|
21
|
+
* Create a new instance of EntityStorageService.
|
|
22
|
+
* @param options The dependencies for the entity storage service.
|
|
23
|
+
*/
|
|
24
|
+
constructor(options) {
|
|
25
|
+
Guards.string(EntityStorageService.CLASS_NAME, "options.entityStorageType", options.entityStorageType);
|
|
26
|
+
this._entityStorage = EntityStorageConnectorFactory.get(options.entityStorageType);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns the class name of the component.
|
|
30
|
+
* @returns The class name of the component.
|
|
31
|
+
*/
|
|
32
|
+
className() {
|
|
33
|
+
return EntityStorageService.CLASS_NAME;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Set an entity.
|
|
37
|
+
* @param entity The entity to set.
|
|
38
|
+
* @returns The id of the entity.
|
|
39
|
+
*/
|
|
40
|
+
async set(entity) {
|
|
41
|
+
Guards.object(EntityStorageService.CLASS_NAME, "entity", entity);
|
|
42
|
+
return this._entityStorage.set(entity, undefined);
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Get an entity.
|
|
46
|
+
* @param id The id of the entity to get, or the index value if secondaryIndex is set.
|
|
47
|
+
* @param secondaryIndex Get the item using a secondary index.
|
|
48
|
+
* @returns The object if it can be found or undefined.
|
|
49
|
+
*/
|
|
50
|
+
async get(id, secondaryIndex) {
|
|
51
|
+
Guards.stringValue(EntityStorageService.CLASS_NAME, "id", id);
|
|
52
|
+
return this.internalGet(id, secondaryIndex);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Remove the entity.
|
|
56
|
+
* @param id The id of the entity to remove.
|
|
57
|
+
* @returns Nothing.
|
|
58
|
+
*/
|
|
59
|
+
async remove(id) {
|
|
60
|
+
Guards.stringValue(EntityStorageService.CLASS_NAME, "id", id);
|
|
61
|
+
await this._entityStorage.remove(id);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Query all the entities which match the conditions.
|
|
65
|
+
* @param conditions The conditions to match for the entities.
|
|
66
|
+
* @param orderBy The order for the results.
|
|
67
|
+
* @param orderByDirection The direction for the order, defaults to ascending.
|
|
68
|
+
* @param properties The optional properties to return, defaults to all.
|
|
69
|
+
* @param cursor The cursor to request the next chunk of entities.
|
|
70
|
+
* @param limit The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
|
|
71
|
+
* @returns All the entities for the storage matching the conditions,
|
|
72
|
+
* and a cursor which can be used to request more entities.
|
|
73
|
+
*/
|
|
74
|
+
async query(conditions, orderBy, orderByDirection, properties, cursor, limit) {
|
|
75
|
+
const result = await this._entityStorage.query(conditions, Is.stringValue(orderBy)
|
|
76
|
+
? [{ property: orderBy, sortDirection: orderByDirection ?? SortDirection.Ascending }]
|
|
77
|
+
: undefined, properties, cursor, limit);
|
|
78
|
+
return result;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Get an entity.
|
|
82
|
+
* @param id The id of the entity to get, or the index value if secondaryIndex is set.
|
|
83
|
+
* @param secondaryIndex Get the item using a secondary index.
|
|
84
|
+
* @returns The object if it can be found or throws.
|
|
85
|
+
* @internal
|
|
86
|
+
*/
|
|
87
|
+
async internalGet(id, secondaryIndex) {
|
|
88
|
+
const conditions = [];
|
|
89
|
+
if (Is.stringValue(secondaryIndex)) {
|
|
90
|
+
conditions.push({
|
|
91
|
+
property: secondaryIndex,
|
|
92
|
+
comparison: ComparisonOperator.Equals,
|
|
93
|
+
value: id
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
let entity;
|
|
97
|
+
if (conditions.length === 0) {
|
|
98
|
+
entity = await this._entityStorage.get(id, secondaryIndex);
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
if (!Is.stringValue(secondaryIndex)) {
|
|
102
|
+
const schema = this._entityStorage.getSchema();
|
|
103
|
+
const primaryKey = EntitySchemaHelper.getPrimaryKey(schema);
|
|
104
|
+
conditions.unshift({
|
|
105
|
+
property: primaryKey.property,
|
|
106
|
+
comparison: ComparisonOperator.Equals,
|
|
107
|
+
value: id
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
const results = await this._entityStorage.query({
|
|
111
|
+
conditions,
|
|
112
|
+
logicalOperator: LogicalOperator.And
|
|
113
|
+
}, undefined, undefined, undefined, 1);
|
|
114
|
+
entity = results.entities[0];
|
|
115
|
+
}
|
|
116
|
+
if (Is.empty(entity)) {
|
|
117
|
+
throw new NotFoundError(EntityStorageService.CLASS_NAME, "entityNotFound", id);
|
|
118
|
+
}
|
|
119
|
+
return entity;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
//# sourceMappingURL=entityStorageService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entityStorageService.js","sourceRoot":"","sources":["../../src/entityStorageService.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,aAAa,EAAE,MA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QAAQ;oBAC7B,UAAU,EAAE,kBAAkB,CAAC,MAAM;oBACrC,KAAK,EAAE,EAAE;iBACT,CAAC,CAAC;YACJ,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,CAC9C;gBACC,UAAU;gBACV,eAAe,EAAE,eAAe,CAAC,GAAG;aACpC,EACD,SAAS,EACT,SAAS,EACT,SAAS,EACT,CAAC,CACD,CAAC;YAEF,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAM,CAAC;QACnC,CAAC;QAED,IAAI,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,aAAa,CAAC,oBAAoB,CAAC,UAAU,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;QAChF,CAAC;QAED,OAAO,MAAM,CAAC;IACf,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { Guards, Is, NotFoundError } from \"@twin.org/core\";\nimport {\n\tComparisonOperator,\n\ttype EntityCondition,\n\tEntitySchemaHelper,\n\tLogicalOperator,\n\tSortDirection\n} from \"@twin.org/entity\";\nimport {\n\tEntityStorageConnectorFactory,\n\ttype IEntityStorageComponent,\n\ttype IEntityStorageConnector\n} from \"@twin.org/entity-storage-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IEntityStorageServiceConstructorOptions } from \"./models/IEntityStorageServiceConstructorOptions.js\";\n\n/**\n * Class for performing entity service operations.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport class EntityStorageService<T = any> implements IEntityStorageComponent<T> {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EntityStorageService>();\n\n\t/**\n\t * The entity storage for items.\n\t * @internal\n\t */\n\tprivate readonly _entityStorage: IEntityStorageConnector<T>;\n\n\t/**\n\t * Create a new instance of EntityStorageService.\n\t * @param options The dependencies for the entity storage service.\n\t */\n\tconstructor(options: IEntityStorageServiceConstructorOptions) {\n\t\tGuards.string(\n\t\t\tEntityStorageService.CLASS_NAME,\n\t\t\tnameof(options.entityStorageType),\n\t\t\toptions.entityStorageType\n\t\t);\n\t\tthis._entityStorage = EntityStorageConnectorFactory.get<IEntityStorageConnector<T>>(\n\t\t\toptions.entityStorageType\n\t\t);\n\t}\n\n\t/**\n\t * Returns the class name of the component.\n\t * @returns The class name of the component.\n\t */\n\tpublic className(): string {\n\t\treturn EntityStorageService.CLASS_NAME;\n\t}\n\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\tpublic async set(entity: T): Promise<void> {\n\t\tGuards.object(EntityStorageService.CLASS_NAME, nameof(entity), entity);\n\n\t\treturn this._entityStorage.set(entity, undefined);\n\t}\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\tpublic async get(id: string, secondaryIndex?: keyof T): Promise<T | undefined> {\n\t\tGuards.stringValue(EntityStorageService.CLASS_NAME, nameof(id), id);\n\n\t\treturn this.internalGet(id, secondaryIndex);\n\t}\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\tpublic async remove(id: string): Promise<void> {\n\t\tGuards.stringValue(EntityStorageService.CLASS_NAME, nameof(id), id);\n\n\t\tawait this._entityStorage.remove(id);\n\t}\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\tpublic async query(\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\t\tconst result = await this._entityStorage.query(\n\t\t\tconditions,\n\t\t\tIs.stringValue(orderBy)\n\t\t\t\t? [{ property: orderBy, sortDirection: orderByDirection ?? SortDirection.Ascending }]\n\t\t\t\t: undefined,\n\t\t\tproperties,\n\t\t\tcursor,\n\t\t\tlimit\n\t\t);\n\n\t\treturn result;\n\t}\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 throws.\n\t * @internal\n\t */\n\tprivate async internalGet(id: string, secondaryIndex?: keyof T): Promise<T> {\n\t\tconst conditions: EntityCondition<T>[] = [];\n\n\t\tif (Is.stringValue(secondaryIndex)) {\n\t\t\tconditions.push({\n\t\t\t\tproperty: secondaryIndex,\n\t\t\t\tcomparison: ComparisonOperator.Equals,\n\t\t\t\tvalue: id\n\t\t\t});\n\t\t}\n\n\t\tlet entity: T | undefined;\n\t\tif (conditions.length === 0) {\n\t\t\tentity = await this._entityStorage.get(id, secondaryIndex);\n\t\t} else {\n\t\t\tif (!Is.stringValue(secondaryIndex)) {\n\t\t\t\tconst schema = this._entityStorage.getSchema();\n\t\t\t\tconst primaryKey = EntitySchemaHelper.getPrimaryKey(schema);\n\n\t\t\t\tconditions.unshift({\n\t\t\t\t\tproperty: primaryKey.property,\n\t\t\t\t\tcomparison: ComparisonOperator.Equals,\n\t\t\t\t\tvalue: id\n\t\t\t\t});\n\t\t\t}\n\n\t\t\tconst results = await this._entityStorage.query(\n\t\t\t\t{\n\t\t\t\t\tconditions,\n\t\t\t\t\tlogicalOperator: LogicalOperator.And\n\t\t\t\t},\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\tundefined,\n\t\t\t\t1\n\t\t\t);\n\n\t\t\tentity = results.entities[0] as T;\n\t\t}\n\n\t\tif (Is.empty(entity)) {\n\t\t\tthrow new NotFoundError(EntityStorageService.CLASS_NAME, \"entityNotFound\", id);\n\t\t}\n\n\t\treturn entity;\n\t}\n}\n"]}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
export * from "./entityStorageRoutes.js";
|
|
4
|
+
export * from "./entityStorageService.js";
|
|
5
|
+
export * from "./models/IEntityStorageServiceConfig.js";
|
|
6
|
+
export * from "./models/IEntityStorageRoutesExamples.js";
|
|
7
|
+
export * from "./models/IEntityStorageServiceConstructorOptions.js";
|
|
8
|
+
export * from "./restEntryPoints.js";
|
|
9
|
+
//# 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,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yCAAyC,CAAC;AACxD,cAAc,0CAA0C,CAAC;AACzD,cAAc,qDAAqD,CAAC;AACpE,cAAc,sBAAsB,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./entityStorageRoutes.js\";\nexport * from \"./entityStorageService.js\";\nexport * from \"./models/IEntityStorageServiceConfig.js\";\nexport * from \"./models/IEntityStorageRoutesExamples.js\";\nexport * from \"./models/IEntityStorageServiceConstructorOptions.js\";\nexport * from \"./restEntryPoints.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageRoutesExamples.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageRoutesExamples.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteRequestExample, IRestRouteResponseExample } from \"@twin.org/api-models\";\nimport type {\n\tIEntityStorageGetRequest,\n\tIEntityStorageGetResponse,\n\tIEntityStorageListRequest,\n\tIEntityStorageListResponse,\n\tIEntityStorageRemoveRequest,\n\tIEntityStorageSetRequest\n} from \"@twin.org/entity-storage-models\";\n\n/**\n * Examples for the entity storage routes.\n */\nexport interface IEntityStorageRoutesExamples {\n\t/**\n\t * Examples for the set route.\n\t */\n\tset?: {\n\t\trequestExamples: IRestRouteRequestExample<IEntityStorageSetRequest>[];\n\t};\n\n\t/**\n\t * Examples for the get route.\n\t */\n\tget?: {\n\t\trequestExamples: IRestRouteRequestExample<IEntityStorageGetRequest>[];\n\t\tresponseExamples: IRestRouteResponseExample<IEntityStorageGetResponse>[];\n\t};\n\n\t/**\n\t * Examples for the remove route.\n\t */\n\tremove?: {\n\t\trequestExamples: IRestRouteRequestExample<IEntityStorageRemoveRequest>[];\n\t};\n\n\t/**\n\t * Examples for the list route.\n\t */\n\tlist?: {\n\t\trequestExamples: IRestRouteRequestExample<IEntityStorageListRequest>[];\n\t\tresponseExamples: IRestRouteResponseExample<IEntityStorageListResponse>[];\n\t};\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageServiceConfig.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageServiceConfig.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Configuration for the entity storage service.\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-interface\nexport interface IEntityStorageServiceConfig {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IEntityStorageServiceConstructorOptions.js","sourceRoot":"","sources":["../../../src/models/IEntityStorageServiceConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IEntityStorageServiceConfig } from \"./IEntityStorageServiceConfig.js\";\n\n/**\n * Options for the Entity Storage Service constructor.\n */\nexport interface IEntityStorageServiceConstructorOptions {\n\t/**\n\t * The type of the entity storage.\n\t */\n\tentityStorageType: string;\n\n\t/**\n\t * The configuration for the service.\n\t */\n\tconfig?: IEntityStorageServiceConfig;\n}\n"]}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { generateRestRoutesEntityStorage, tagsEntityStorage } from "./entityStorageRoutes.js";
|
|
2
|
+
/**
|
|
3
|
+
* These are dummy entry points for the entity storage service.
|
|
4
|
+
* In reality your application would create its own entry points based on the
|
|
5
|
+
* entity storage schema objects it wants to store, using a custom defaultBaseRoute.
|
|
6
|
+
*/
|
|
7
|
+
export const restEntryPoints = [
|
|
8
|
+
{
|
|
9
|
+
name: "entity-storage",
|
|
10
|
+
defaultBaseRoute: "entity-storage",
|
|
11
|
+
tags: tagsEntityStorage,
|
|
12
|
+
generateRoutes: generateRestRoutesEntityStorage
|
|
13
|
+
}
|
|
14
|
+
];
|
|
15
|
+
//# sourceMappingURL=restEntryPoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"restEntryPoints.js","sourceRoot":"","sources":["../../src/restEntryPoints.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,+BAA+B,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE9F;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAA2B;IACtD;QACC,IAAI,EAAE,gBAAgB;QACtB,gBAAgB,EAAE,gBAAgB;QAClC,IAAI,EAAE,iBAAiB;QACvB,cAAc,EAAE,+BAA+B;KAC/C;CACD,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRouteEntryPoint } from \"@twin.org/api-models\";\nimport { generateRestRoutesEntityStorage, tagsEntityStorage } from \"./entityStorageRoutes.js\";\n\n/**\n * These are dummy entry points for the entity storage service.\n * In reality your application would create its own entry points based on the\n * entity storage schema objects it wants to store, using a custom defaultBaseRoute.\n */\nexport const restEntryPoints: IRestRouteEntryPoint[] = [\n\t{\n\t\tname: \"entity-storage\",\n\t\tdefaultBaseRoute: \"entity-storage\",\n\t\ttags: tagsEntityStorage,\n\t\tgenerateRoutes: generateRestRoutesEntityStorage\n\t}\n];\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type IHttpRequestContext, type INoContentResponse, type IRestRoute, type ITag } from "@twin.org/api-models";
|
|
2
2
|
import type { IEntityStorageGetRequest, IEntityStorageGetResponse, IEntityStorageListRequest, IEntityStorageListResponse, IEntityStorageRemoveRequest, IEntityStorageSetRequest } from "@twin.org/entity-storage-models";
|
|
3
|
-
import type { IEntityStorageRoutesExamples } from "./models/IEntityStorageRoutesExamples";
|
|
3
|
+
import type { IEntityStorageRoutesExamples } from "./models/IEntityStorageRoutesExamples.js";
|
|
4
4
|
/**
|
|
5
5
|
* The tag to associate with the routes.
|
|
6
6
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type EntityCondition, SortDirection } from "@twin.org/entity";
|
|
2
2
|
import { type IEntityStorageComponent } from "@twin.org/entity-storage-models";
|
|
3
|
-
import type { IEntityStorageServiceConstructorOptions } from "./models/IEntityStorageServiceConstructorOptions";
|
|
3
|
+
import type { IEntityStorageServiceConstructorOptions } from "./models/IEntityStorageServiceConstructorOptions.js";
|
|
4
4
|
/**
|
|
5
5
|
* Class for performing entity service operations.
|
|
6
6
|
*/
|
|
@@ -8,47 +8,48 @@ export declare class EntityStorageService<T = any> implements IEntityStorageComp
|
|
|
8
8
|
/**
|
|
9
9
|
* Runtime name for the class.
|
|
10
10
|
*/
|
|
11
|
-
readonly CLASS_NAME: string;
|
|
11
|
+
static readonly CLASS_NAME: string;
|
|
12
12
|
/**
|
|
13
13
|
* Create a new instance of EntityStorageService.
|
|
14
14
|
* @param options The dependencies for the entity storage service.
|
|
15
15
|
*/
|
|
16
16
|
constructor(options: IEntityStorageServiceConstructorOptions);
|
|
17
|
+
/**
|
|
18
|
+
* Returns the class name of the component.
|
|
19
|
+
* @returns The class name of the component.
|
|
20
|
+
*/
|
|
21
|
+
className(): string;
|
|
17
22
|
/**
|
|
18
23
|
* Set an entity.
|
|
19
24
|
* @param entity The entity to set.
|
|
20
|
-
* @param userIdentity The user identity to use with storage operations.
|
|
21
25
|
* @returns The id of the entity.
|
|
22
26
|
*/
|
|
23
|
-
set(entity: T
|
|
27
|
+
set(entity: T): Promise<void>;
|
|
24
28
|
/**
|
|
25
29
|
* Get an entity.
|
|
26
30
|
* @param id The id of the entity to get, or the index value if secondaryIndex is set.
|
|
27
31
|
* @param secondaryIndex Get the item using a secondary index.
|
|
28
|
-
* @param userIdentity The user identity to use with storage operations.
|
|
29
32
|
* @returns The object if it can be found or undefined.
|
|
30
33
|
*/
|
|
31
|
-
get(id: string, secondaryIndex?: keyof T
|
|
34
|
+
get(id: string, secondaryIndex?: keyof T): Promise<T | undefined>;
|
|
32
35
|
/**
|
|
33
36
|
* Remove the entity.
|
|
34
37
|
* @param id The id of the entity to remove.
|
|
35
|
-
* @param userIdentity The user identity to use with storage operations.
|
|
36
38
|
* @returns Nothing.
|
|
37
39
|
*/
|
|
38
|
-
remove(id: string
|
|
40
|
+
remove(id: string): Promise<void>;
|
|
39
41
|
/**
|
|
40
42
|
* Query all the entities which match the conditions.
|
|
41
43
|
* @param conditions The conditions to match for the entities.
|
|
42
44
|
* @param orderBy The order for the results.
|
|
43
45
|
* @param orderByDirection The direction for the order, defaults to ascending.
|
|
44
46
|
* @param properties The optional properties to return, defaults to all.
|
|
45
|
-
* @param cursor The cursor to request the next
|
|
46
|
-
* @param
|
|
47
|
-
* @param userIdentity The user identity to use with storage operations.
|
|
47
|
+
* @param cursor The cursor to request the next chunk of entities.
|
|
48
|
+
* @param limit The suggested number of entities to return in each chunk, in some scenarios can return a different amount.
|
|
48
49
|
* @returns All the entities for the storage matching the conditions,
|
|
49
50
|
* and a cursor which can be used to request more entities.
|
|
50
51
|
*/
|
|
51
|
-
query(conditions?: EntityCondition<T>, orderBy?: keyof T, orderByDirection?: SortDirection, properties?: (keyof T)[], cursor?: string,
|
|
52
|
+
query(conditions?: EntityCondition<T>, orderBy?: keyof T, orderByDirection?: SortDirection, properties?: (keyof T)[], cursor?: string, limit?: number): Promise<{
|
|
52
53
|
/**
|
|
53
54
|
* The entities, which can be partial if a limited keys list was provided.
|
|
54
55
|
*/
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export * from "./entityStorageRoutes";
|
|
2
|
-
export * from "./entityStorageService";
|
|
3
|
-
export * from "./models/
|
|
4
|
-
export * from "./models/IEntityStorageRoutesExamples";
|
|
5
|
-
export * from "./models/IEntityStorageServiceConstructorOptions";
|
|
6
|
-
export * from "./restEntryPoints";
|
|
1
|
+
export * from "./entityStorageRoutes.js";
|
|
2
|
+
export * from "./entityStorageService.js";
|
|
3
|
+
export * from "./models/IEntityStorageServiceConfig.js";
|
|
4
|
+
export * from "./models/IEntityStorageRoutesExamples.js";
|
|
5
|
+
export * from "./models/IEntityStorageServiceConstructorOptions.js";
|
|
6
|
+
export * from "./restEntryPoints.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { IEntityStorageServiceConfig } from "./IEntityStorageServiceConfig.js";
|
|
2
2
|
/**
|
|
3
3
|
* Options for the Entity Storage Service constructor.
|
|
4
4
|
*/
|
|
@@ -10,5 +10,5 @@ export interface IEntityStorageServiceConstructorOptions {
|
|
|
10
10
|
/**
|
|
11
11
|
* The configuration for the service.
|
|
12
12
|
*/
|
|
13
|
-
config?:
|
|
13
|
+
config?: IEntityStorageServiceConfig;
|
|
14
14
|
}
|