@twin.org/engine 0.0.2-next.26 → 0.0.2-next.27
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/data/coreTypeInitialisers.json +267 -0
- package/dist/es/engine.js +31 -0
- package/dist/es/engine.js.map +1 -0
- package/dist/es/index.js +5 -0
- package/dist/es/index.js.map +1 -0
- package/dist/es/utils/engineConfigHelper.js +40 -0
- package/dist/es/utils/engineConfigHelper.js.map +1 -0
- package/dist/types/index.d.ts +2 -2
- package/dist/types/utils/engineConfigHelper.d.ts +2 -5
- package/docs/reference/classes/Engine.md +520 -0
- package/docs/reference/classes/EngineConfigHelper.md +4 -8
- package/package.json +35 -7
- package/dist/cjs/index.cjs +0 -340
- package/dist/esm/index.mjs +0 -337
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"type": "loggingConnector",
|
|
4
|
+
"module": "@twin.org/engine-types",
|
|
5
|
+
"method": "initialiseLoggingConnector"
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
"type": "loggingComponent",
|
|
9
|
+
"module": "@twin.org/engine-types",
|
|
10
|
+
"method": "initialiseLoggingComponent"
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"type": "backgroundTaskConnector",
|
|
14
|
+
"module": "@twin.org/engine-types",
|
|
15
|
+
"method": "initialiseBackgroundTaskConnector"
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"type": "taskSchedulerComponent",
|
|
19
|
+
"module": "@twin.org/engine-types",
|
|
20
|
+
"method": "initialiseTaskSchedulerComponent"
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"type": "eventBusConnector",
|
|
24
|
+
"module": "@twin.org/engine-types",
|
|
25
|
+
"method": "initialiseEventBusConnector"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"type": "eventBusComponent",
|
|
29
|
+
"module": "@twin.org/engine-types",
|
|
30
|
+
"method": "initialiseEventBusComponent"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"type": "telemetryConnector",
|
|
34
|
+
"module": "@twin.org/engine-types",
|
|
35
|
+
"method": "initialiseTelemetryConnector"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"type": "telemetryComponent",
|
|
39
|
+
"module": "@twin.org/engine-types",
|
|
40
|
+
"method": "initialiseTelemetryComponent"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"type": "messagingEmailConnector",
|
|
44
|
+
"module": "@twin.org/engine-types",
|
|
45
|
+
"method": "initialiseMessagingEmailConnector"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"type": "messagingSmsConnector",
|
|
49
|
+
"module": "@twin.org/engine-types",
|
|
50
|
+
"method": "initialiseMessagingSmsConnector"
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"type": "messagingPushNotificationConnector",
|
|
54
|
+
"module": "@twin.org/engine-types",
|
|
55
|
+
"method": "initialiseMessagingPushNotificationConnector"
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"type": "messagingAdminComponent",
|
|
59
|
+
"module": "@twin.org/engine-types",
|
|
60
|
+
"method": "initialiseMessagingAdminComponent"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"type": "messagingComponent",
|
|
64
|
+
"module": "@twin.org/engine-types",
|
|
65
|
+
"method": "initialiseMessagingComponent"
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"type": "entityStorageComponent",
|
|
69
|
+
"module": "@twin.org/engine-types",
|
|
70
|
+
"method": "initialiseEntityStorageComponent"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"type": "vaultConnector",
|
|
74
|
+
"module": "@twin.org/engine-types",
|
|
75
|
+
"method": "initialiseVaultConnector"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"type": "blobStorageConnector",
|
|
79
|
+
"module": "@twin.org/engine-types",
|
|
80
|
+
"method": "initialiseBlobStorageConnector"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"type": "blobStorageComponent",
|
|
84
|
+
"module": "@twin.org/engine-types",
|
|
85
|
+
"method": "initialiseBlobStorageComponent"
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"type": "verifiableStorageConnector",
|
|
89
|
+
"module": "@twin.org/engine-types",
|
|
90
|
+
"method": "initialiseVerifiableStorageConnector"
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"type": "verifiableStorageComponent",
|
|
94
|
+
"module": "@twin.org/engine-types",
|
|
95
|
+
"method": "initialiseVerifiableStorageComponent"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"type": "faucetConnector",
|
|
99
|
+
"module": "@twin.org/engine-types",
|
|
100
|
+
"method": "initialiseFaucetConnector"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"type": "walletConnector",
|
|
104
|
+
"module": "@twin.org/engine-types",
|
|
105
|
+
"method": "initialiseWalletConnector"
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"type": "identityConnector",
|
|
109
|
+
"module": "@twin.org/engine-types",
|
|
110
|
+
"method": "initialiseIdentityConnector"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"type": "identityComponent",
|
|
114
|
+
"module": "@twin.org/engine-types",
|
|
115
|
+
"method": "initialiseIdentityComponent"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"type": "identityResolverConnector",
|
|
119
|
+
"module": "@twin.org/engine-types",
|
|
120
|
+
"method": "initialiseIdentityResolverConnector"
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"type": "identityResolverComponent",
|
|
124
|
+
"module": "@twin.org/engine-types",
|
|
125
|
+
"method": "initialiseIdentityResolverComponent"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"type": "identityProfileConnector",
|
|
129
|
+
"module": "@twin.org/engine-types",
|
|
130
|
+
"method": "initialiseIdentityProfileConnector"
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"type": "identityProfileComponent",
|
|
134
|
+
"module": "@twin.org/engine-types",
|
|
135
|
+
"method": "initialiseIdentityProfileComponent"
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"type": "nftConnector",
|
|
139
|
+
"module": "@twin.org/engine-types",
|
|
140
|
+
"method": "initialiseNftConnector"
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"type": "nftComponent",
|
|
144
|
+
"module": "@twin.org/engine-types",
|
|
145
|
+
"method": "initialiseNftComponent"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"type": "immutableProofComponent",
|
|
149
|
+
"module": "@twin.org/engine-types",
|
|
150
|
+
"method": "initialiseImmutableProofComponent"
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"type": "attestationConnector",
|
|
154
|
+
"module": "@twin.org/engine-types",
|
|
155
|
+
"method": "initialiseAttestationConnector"
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"type": "attestationComponent",
|
|
159
|
+
"module": "@twin.org/engine-types",
|
|
160
|
+
"method": "initialiseAttestationComponent"
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"type": "auditableItemGraphComponent",
|
|
164
|
+
"module": "@twin.org/engine-types",
|
|
165
|
+
"method": "initialiseAuditableItemGraphComponent"
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"type": "auditableItemStreamComponent",
|
|
169
|
+
"module": "@twin.org/engine-types",
|
|
170
|
+
"method": "initialiseAuditableItemStreamComponent"
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"type": "dataConverterConnector",
|
|
174
|
+
"module": "@twin.org/engine-types",
|
|
175
|
+
"method": "initialiseDataConverterConnector"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
"type": "dataExtractorConnector",
|
|
179
|
+
"module": "@twin.org/engine-types",
|
|
180
|
+
"method": "initialiseDataExtractorConnector"
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
"type": "dataProcessingComponent",
|
|
184
|
+
"module": "@twin.org/engine-types",
|
|
185
|
+
"method": "initialiseDataProcessingComponent"
|
|
186
|
+
},
|
|
187
|
+
{
|
|
188
|
+
"type": "documentManagementComponent",
|
|
189
|
+
"module": "@twin.org/engine-types",
|
|
190
|
+
"method": "initialiseDocumentManagementComponent"
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
"type": "authenticationGeneratorComponent",
|
|
194
|
+
"module": "@twin.org/engine-types",
|
|
195
|
+
"method": "initialiseAuthenticationGeneratorComponent"
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
"type": "rightsManagementPapComponent",
|
|
199
|
+
"module": "@twin.org/engine-types",
|
|
200
|
+
"method": "initialiseRightsManagementPapComponent"
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
"type": "rightsManagementPmpComponent",
|
|
204
|
+
"module": "@twin.org/engine-types",
|
|
205
|
+
"method": "initialiseRightsManagementPmpComponent"
|
|
206
|
+
},
|
|
207
|
+
{
|
|
208
|
+
"type": "rightsManagementPxpComponent",
|
|
209
|
+
"module": "@twin.org/engine-types",
|
|
210
|
+
"method": "initialiseRightsManagementPxpComponent"
|
|
211
|
+
},
|
|
212
|
+
{
|
|
213
|
+
"type": "rightsManagementPipComponent",
|
|
214
|
+
"module": "@twin.org/engine-types",
|
|
215
|
+
"method": "initialiseRightsManagementPipComponent"
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
"type": "rightsManagementPdpComponent",
|
|
219
|
+
"module": "@twin.org/engine-types",
|
|
220
|
+
"method": "initialiseRightsManagementPdpComponent"
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
"type": "rightsManagementPepComponent",
|
|
224
|
+
"module": "@twin.org/engine-types",
|
|
225
|
+
"method": "initialiseRightsManagementPepComponent"
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
"type": "rightsManagementPnapComponent",
|
|
229
|
+
"module": "@twin.org/engine-types",
|
|
230
|
+
"method": "initialiseRightsManagementPnapComponent"
|
|
231
|
+
},
|
|
232
|
+
{
|
|
233
|
+
"type": "rightsManagementPnpComponent",
|
|
234
|
+
"module": "@twin.org/engine-types",
|
|
235
|
+
"method": "initialiseRightsManagementPnpComponent"
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
"type": "rightsManagementDapComponent",
|
|
239
|
+
"module": "@twin.org/engine-types",
|
|
240
|
+
"method": "initialiseRightsManagementDapComponent"
|
|
241
|
+
},
|
|
242
|
+
{
|
|
243
|
+
"type": "rightsManagementDarpComponent",
|
|
244
|
+
"module": "@twin.org/engine-types",
|
|
245
|
+
"method": "initialiseRightsManagementDarpComponent"
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
"type": "synchronisedStorageComponent",
|
|
249
|
+
"module": "@twin.org/engine-types",
|
|
250
|
+
"method": "initialiseSynchronisedStorageComponent"
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
"type": "federatedCatalogueComponent",
|
|
254
|
+
"module": "@twin.org/engine-types",
|
|
255
|
+
"method": "initialiseFederatedCatalogueComponent"
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
"type": "dataSpaceConnectorComponent",
|
|
259
|
+
"module": "@twin.org/engine-types",
|
|
260
|
+
"method": "initialiseDataSpaceConnectorComponent"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"type": "tenantAdminComponent",
|
|
264
|
+
"module": "@twin.org/engine-types",
|
|
265
|
+
"method": "initialiseTenantAdminComponent"
|
|
266
|
+
}
|
|
267
|
+
]
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { EngineCore } from "@twin.org/engine-core";
|
|
4
|
+
import coreTypeInitialisers from "./data/coreTypeInitialisers.json" with { type: "json" };
|
|
5
|
+
/**
|
|
6
|
+
* The engine with built in types.
|
|
7
|
+
*/
|
|
8
|
+
export class Engine extends EngineCore {
|
|
9
|
+
/**
|
|
10
|
+
* Runtime name for the class.
|
|
11
|
+
*/
|
|
12
|
+
static CLASS_NAME = "Engine";
|
|
13
|
+
/**
|
|
14
|
+
* Create a new instance of Engine.
|
|
15
|
+
* @param options The options for the engine.
|
|
16
|
+
*/
|
|
17
|
+
constructor(options) {
|
|
18
|
+
super(options);
|
|
19
|
+
this.addCoreTypeInitialisers();
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Add the core type initializers.
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
addCoreTypeInitialisers() {
|
|
26
|
+
for (const initializer of coreTypeInitialisers) {
|
|
27
|
+
this.addTypeInitialiser(initializer.type, initializer.module, initializer.method);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engine.js","sourceRoot":"","sources":["../../src/engine.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,UAAU,EAA2B,MAAM,uBAAuB,CAAC;AAI5E,OAAO,oBAAoB,MAAM,kCAAkC,CAAC,OAAO,IAAI,EAAE,MAAM,EAAE,CAAC;AAE1F;;GAEG;AACH,MAAM,OAAO,MAGX,SAAQ,UAAgB;IACzB;;OAEG;IACI,MAAM,CAAU,UAAU,YAA4B;IAE7D;;;OAGG;IACH,YAAY,OAAkC;QAC7C,KAAK,CAAC,OAAO,CAAC,CAAC;QAEf,IAAI,CAAC,uBAAuB,EAAE,CAAC;IAChC,CAAC;IAED;;;OAGG;IACK,uBAAuB;QAC9B,KAAK,MAAM,WAAW,IAAI,oBAAoB,EAAE,CAAC;YAChD,IAAI,CAAC,kBAAkB,CAAC,WAAW,CAAC,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;QACnF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { EngineCore, type IEngineCoreOptions } from \"@twin.org/engine-core\";\nimport type { IEngineState } from \"@twin.org/engine-models\";\nimport type { IEngineConfig } from \"@twin.org/engine-types\";\nimport { nameof } from \"@twin.org/nameof\";\nimport coreTypeInitialisers from \"./data/coreTypeInitialisers.json\" with { type: \"json\" };\n\n/**\n * The engine with built in types.\n */\nexport class Engine<\n\tC extends IEngineConfig = IEngineConfig,\n\tS extends IEngineState = IEngineState\n> extends EngineCore<C, S> {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<Engine>();\n\n\t/**\n\t * Create a new instance of Engine.\n\t * @param options The options for the engine.\n\t */\n\tconstructor(options?: IEngineCoreOptions<C, S>) {\n\t\tsuper(options);\n\n\t\tthis.addCoreTypeInitialisers();\n\t}\n\n\t/**\n\t * Add the core type initializers.\n\t * @internal\n\t */\n\tprivate addCoreTypeInitialisers(): void {\n\t\tfor (const initializer of coreTypeInitialisers) {\n\t\t\tthis.addTypeInitialiser(initializer.type, initializer.module, initializer.method);\n\t\t}\n\t}\n}\n"]}
|
package/dist/es/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,cAAc,aAAa,CAAC;AAC5B,cAAc,+BAA+B,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nexport * from \"./engine.js\";\nexport * from \"./utils/engineConfigHelper.js\";\n"]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// Copyright 2024 IOTA Stiftung.
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0.
|
|
3
|
+
import { ContextIdKeys } from "@twin.org/context";
|
|
4
|
+
import { Guards, Is, StringHelper } from "@twin.org/core";
|
|
5
|
+
import { EntityStorageComponentType } from "@twin.org/engine-types";
|
|
6
|
+
import { EntitySchemaFactory } from "@twin.org/entity";
|
|
7
|
+
/**
|
|
8
|
+
* Helper methods for engine config.
|
|
9
|
+
*/
|
|
10
|
+
export class EngineConfigHelper {
|
|
11
|
+
/**
|
|
12
|
+
* Runtime name for the class.
|
|
13
|
+
*/
|
|
14
|
+
static CLASS_NAME = "EngineConfigHelper";
|
|
15
|
+
/**
|
|
16
|
+
* Add a custom entity storage to the engine configuration.
|
|
17
|
+
* @param engineConfig The engine configuration.
|
|
18
|
+
* @param entityTypeName The entity type name.
|
|
19
|
+
* @param entitySchema The entity schema.
|
|
20
|
+
* @param restPath The rest path to serve the entity storage from, leave undefined for no endpoints.
|
|
21
|
+
* @param partitionContextIds The context ids to use for partitioning.
|
|
22
|
+
*/
|
|
23
|
+
static addCustomEntityStorage(engineConfig, entityTypeName, entitySchema, restPath, partitionContextIds) {
|
|
24
|
+
Guards.object(EngineConfigHelper.CLASS_NAME, "engineConfig", engineConfig);
|
|
25
|
+
Guards.stringValue(EngineConfigHelper.CLASS_NAME, "entityTypeName", entityTypeName);
|
|
26
|
+
Guards.object(EngineConfigHelper.CLASS_NAME, "entitySchema", entitySchema);
|
|
27
|
+
engineConfig.types.entityStorageComponent ??= [];
|
|
28
|
+
EntitySchemaFactory.register(entityTypeName, () => entitySchema);
|
|
29
|
+
engineConfig.types.entityStorageComponent.push({
|
|
30
|
+
type: EntityStorageComponentType.Service,
|
|
31
|
+
options: {
|
|
32
|
+
entityStorageType: entityTypeName,
|
|
33
|
+
partitionContextIds: partitionContextIds ?? [ContextIdKeys.Node, ContextIdKeys.Tenant]
|
|
34
|
+
},
|
|
35
|
+
overrideInstanceType: StringHelper.kebabCase(entityTypeName),
|
|
36
|
+
restPath: Is.stringValue(restPath) ? restPath : undefined
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=engineConfigHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"engineConfigHelper.js","sourceRoot":"","sources":["../../../src/utils/engineConfigHelper.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAsB,MAAM,wBAAwB,CAAC;AACxF,OAAO,EAAE,mBAAmB,EAAsB,MAAM,kBAAkB,CAAC;AAG3E;;GAEG;AACH,MAAM,OAAO,kBAAkB;IAC9B;;OAEG;IACI,MAAM,CAAU,UAAU,wBAAwC;IAEzE;;;;;;;OAOG;IACI,MAAM,CAAC,sBAAsB,CACnC,YAA2B,EAC3B,cAAsB,EACtB,YAA8B,EAC9B,QAAiB,EACjB,mBAA8B;QAE9B,MAAM,CAAC,MAAM,CAAgB,kBAAkB,CAAC,UAAU,kBAAwB,YAAY,CAAC,CAAC;QAChG,MAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,UAAU,oBAA0B,cAAc,CAAC,CAAC;QAC1F,MAAM,CAAC,MAAM,CAAgB,kBAAkB,CAAC,UAAU,kBAAwB,YAAY,CAAC,CAAC;QAEhG,YAAY,CAAC,KAAK,CAAC,sBAAsB,KAAK,EAAE,CAAC;QAEjD,mBAAmB,CAAC,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE,CAAC,YAAY,CAAC,CAAC;QAEjE,YAAY,CAAC,KAAK,CAAC,sBAAsB,CAAC,IAAI,CAAC;YAC9C,IAAI,EAAE,0BAA0B,CAAC,OAAO;YACxC,OAAO,EAAE;gBACR,iBAAiB,EAAE,cAAc;gBACjC,mBAAmB,EAAE,mBAAmB,IAAI,CAAC,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC;aACtF;YACD,oBAAoB,EAAE,YAAY,CAAC,SAAS,CAAC,cAAc,CAAC;YAC5D,QAAQ,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS;SACzD,CAAC,CAAC;IACJ,CAAC","sourcesContent":["// Copyright 2024 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ContextIdKeys } from \"@twin.org/context\";\nimport { Guards, Is, StringHelper } from \"@twin.org/core\";\nimport { EntityStorageComponentType, type IEngineConfig } from \"@twin.org/engine-types\";\nimport { EntitySchemaFactory, type IEntitySchema } from \"@twin.org/entity\";\nimport { nameof } from \"@twin.org/nameof\";\n\n/**\n * Helper methods for engine config.\n */\nexport class EngineConfigHelper {\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<EngineConfigHelper>();\n\n\t/**\n\t * Add a custom entity storage to the engine configuration.\n\t * @param engineConfig The engine configuration.\n\t * @param entityTypeName The entity type name.\n\t * @param entitySchema The entity schema.\n\t * @param restPath The rest path to serve the entity storage from, leave undefined for no endpoints.\n\t * @param partitionContextIds The context ids to use for partitioning.\n\t */\n\tpublic static addCustomEntityStorage<T>(\n\t\tengineConfig: IEngineConfig,\n\t\tentityTypeName: string,\n\t\tentitySchema: IEntitySchema<T>,\n\t\trestPath?: string,\n\t\tpartitionContextIds?: string[]\n\t): void {\n\t\tGuards.object<IEngineConfig>(EngineConfigHelper.CLASS_NAME, nameof(engineConfig), engineConfig);\n\t\tGuards.stringValue(EngineConfigHelper.CLASS_NAME, nameof(entityTypeName), entityTypeName);\n\t\tGuards.object<IEntitySchema>(EngineConfigHelper.CLASS_NAME, nameof(entitySchema), entitySchema);\n\n\t\tengineConfig.types.entityStorageComponent ??= [];\n\n\t\tEntitySchemaFactory.register(entityTypeName, () => entitySchema);\n\n\t\tengineConfig.types.entityStorageComponent.push({\n\t\t\ttype: EntityStorageComponentType.Service,\n\t\t\toptions: {\n\t\t\t\tentityStorageType: entityTypeName,\n\t\t\t\tpartitionContextIds: partitionContextIds ?? [ContextIdKeys.Node, ContextIdKeys.Tenant]\n\t\t\t},\n\t\t\toverrideInstanceType: StringHelper.kebabCase(entityTypeName),\n\t\t\trestPath: Is.stringValue(restPath) ? restPath : undefined\n\t\t});\n\t}\n}\n"]}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from "./engine";
|
|
2
|
-
export * from "./utils/engineConfigHelper";
|
|
1
|
+
export * from "./engine.js";
|
|
2
|
+
export * from "./utils/engineConfigHelper.js";
|
|
@@ -14,10 +14,7 @@ export declare class EngineConfigHelper {
|
|
|
14
14
|
* @param entityTypeName The entity type name.
|
|
15
15
|
* @param entitySchema The entity schema.
|
|
16
16
|
* @param restPath The rest path to serve the entity storage from, leave undefined for no endpoints.
|
|
17
|
-
* @param
|
|
18
|
-
* @param options.partitionPerUser Whether to partition the user identity in the data, defaults to false.
|
|
17
|
+
* @param partitionContextIds The context ids to use for partitioning.
|
|
19
18
|
*/
|
|
20
|
-
static addCustomEntityStorage<T>(engineConfig: IEngineConfig, entityTypeName: string, entitySchema: IEntitySchema<T>, restPath?: string,
|
|
21
|
-
partitionPerUser?: boolean;
|
|
22
|
-
}): void;
|
|
19
|
+
static addCustomEntityStorage<T>(engineConfig: IEngineConfig, entityTypeName: string, entitySchema: IEntitySchema<T>, restPath?: string, partitionContextIds?: string[]): void;
|
|
23
20
|
}
|