@twin.org/dataspace-test-app 0.0.3-next.43 → 0.0.3-next.45
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/extension.js +4 -1
- package/dist/es/extension.js.map +1 -1
- package/dist/es/testDataspaceDataPlaneApp.js +7 -6
- package/dist/es/testDataspaceDataPlaneApp.js.map +1 -1
- package/dist/types/extension.d.ts +4 -1
- package/dist/types/testDataspaceDataPlaneApp.d.ts +7 -6
- package/docs/changelog.md +28 -0
- package/docs/reference/classes/TestDataspaceDataPlaneApp.md +8 -6
- package/docs/reference/functions/extensionInitialise.md +3 -1
- package/docs/reference/functions/extensionInitialiseEngine.md +2 -0
- package/docs/reference/functions/extensionInitialiseEngineServer.md +2 -0
- package/package.json +2 -2
package/dist/es/extension.js
CHANGED
|
@@ -3,9 +3,10 @@ import { DataspaceAppFactory } from "@twin.org/dataspace-models";
|
|
|
3
3
|
import { EngineTypeHelper } from "@twin.org/engine-types";
|
|
4
4
|
import { TestDataspaceDataPlaneApp } from "./testDataspaceDataPlaneApp.js";
|
|
5
5
|
/**
|
|
6
|
-
* Initialise the
|
|
6
|
+
* Initialise the extension.
|
|
7
7
|
* @param envVars The environment variables for the node.
|
|
8
8
|
* @param nodeEngineConfig The node engine config.
|
|
9
|
+
* @returns A promise that resolves when the test app component type has been registered in the engine config.
|
|
9
10
|
*/
|
|
10
11
|
export async function extensionInitialise(envVars, nodeEngineConfig) {
|
|
11
12
|
nodeEngineConfig.types.testAppComponent = [
|
|
@@ -22,6 +23,7 @@ export async function extensionInitialise(envVars, nodeEngineConfig) {
|
|
|
22
23
|
/**
|
|
23
24
|
* Initialise the engine for the extension.
|
|
24
25
|
* @param engineCore The engine core instance.
|
|
26
|
+
* @returns A promise that resolves when the type initialiser has been registered with the engine.
|
|
25
27
|
*/
|
|
26
28
|
export async function extensionInitialiseEngine(engineCore) {
|
|
27
29
|
engineCore.addTypeInitialiser("testAppComponent", "@twin.org/dataspace-test-app", "testAppInitialiser");
|
|
@@ -30,6 +32,7 @@ export async function extensionInitialiseEngine(engineCore) {
|
|
|
30
32
|
* Initialise the engine server for the extension.
|
|
31
33
|
* @param engineCore The engine core instance.
|
|
32
34
|
* @param engineServer The engine server instance.
|
|
35
|
+
* @returns A promise that resolves when the REST route generator has been registered with the engine server.
|
|
33
36
|
*/
|
|
34
37
|
export async function extensionInitialiseEngineServer(engineCore, engineServer) {
|
|
35
38
|
engineServer.addRestRouteGenerator("testAppComponent", "@twin.org/dataspace-test-app", "generateRestRoutes");
|
package/dist/es/extension.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/extension.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAQjE,OAAO,EAAsB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E
|
|
1
|
+
{"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/extension.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AACpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAQjE,OAAO,EAAsB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,OAA2C,EAC3C,gBAAmC;IAEnC,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,GAAG;QACzC;YACC,IAAI,EAAE,SAAS;YACf,OAAO,EAAE;gBACR,YAAY,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,mBAAmB,CAAC;oBACvD,CAAC,CAAC,OAAO,CAAC,mBAAmB;oBAC7B,CAAC,CAAC,SAAS;aACZ;SACD;KACD,CAAC;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,UAAuB;IACtE,UAAU,CAAC,kBAAkB,CAC5B,kBAAkB,EAClB,8BAA8B,EAC9B,oBAAoB,CACpB,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,+BAA+B,CACpD,UAAuB,EACvB,YAA2B;IAE3B,YAAY,CAAC,qBAAqB,CACjC,kBAAkB,EAClB,8BAA8B,EAC9B,oBAAoB,CACpB,CAAC;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,kBAAkB,CACjC,UAAsC,EACtC,OAA2B,EAC3B,cAAwE;IAExE,IAAI,gBAAoC,CAAC;IACzC,IAAI,eAAe,CAAC;IAEpB,IAAI,cAAc,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACvC,eAAe,GAAG,CAAC,YAAmC,EAAE,EAAE,CACzD,IAAI,yBAAyB,CAC5B,gBAAgB,CAAC,WAAW,CAC3B;YACC,oBAAoB,EAAE,UAAU,CAAC,yBAAyB,CAAC,kBAAkB,CAAC;SAC9E,EACD,YAAY,CAAC,OAAO,CACpB,CACD,CAAC;QACH,gBAAgB,GAAG,yBAAyB,CAAC,MAAM,CAAC;IACrD,CAAC;IAED,OAAO;QACN,gBAAgB;QAChB,OAAO,EAAE,mBAAmB;QAC5B,eAAe;KACf,CAAC;AACH,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,aAAqB,EAAE,aAAqB;IAC9E,OAAO,EAAE,CAAC;AACX,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IRestRoute } from \"@twin.org/api-models\";\nimport { Is } from \"@twin.org/core\";\nimport { DataspaceAppFactory } from \"@twin.org/dataspace-models\";\nimport type {\n\tEngineTypeInitialiserReturn,\n\tIEngineCore,\n\tIEngineCoreConfig,\n\tIEngineCoreContext,\n\tIEngineServer\n} from \"@twin.org/engine-models\";\nimport { type IEngineConfig, EngineTypeHelper } from \"@twin.org/engine-types\";\nimport type { ITestAppConstructorOptions } from \"./ITestAppConstructorOptions.js\";\nimport { TestDataspaceDataPlaneApp } from \"./testDataspaceDataPlaneApp.js\";\n\n/**\n * Initialise the extension.\n * @param envVars The environment variables for the node.\n * @param nodeEngineConfig The node engine config.\n * @returns A promise that resolves when the test app component type has been registered in the engine config.\n */\nexport async function extensionInitialise(\n\tenvVars: { [id: string]: string | unknown },\n\tnodeEngineConfig: IEngineCoreConfig\n): Promise<void> {\n\tnodeEngineConfig.types.testAppComponent = [\n\t\t{\n\t\t\ttype: \"service\",\n\t\t\toptions: {\n\t\t\t\tconsignments: Is.arrayValue(envVars.testAppConsignments)\n\t\t\t\t\t? envVars.testAppConsignments\n\t\t\t\t\t: undefined\n\t\t\t}\n\t\t}\n\t];\n}\n\n/**\n * Initialise the engine for the extension.\n * @param engineCore The engine core instance.\n * @returns A promise that resolves when the type initialiser has been registered with the engine.\n */\nexport async function extensionInitialiseEngine(engineCore: IEngineCore): Promise<void> {\n\tengineCore.addTypeInitialiser(\n\t\t\"testAppComponent\",\n\t\t\"@twin.org/dataspace-test-app\",\n\t\t\"testAppInitialiser\"\n\t);\n}\n\n/**\n * Initialise the engine server for the extension.\n * @param engineCore The engine core instance.\n * @param engineServer The engine server instance.\n * @returns A promise that resolves when the REST route generator has been registered with the engine server.\n */\nexport async function extensionInitialiseEngineServer(\n\tengineCore: IEngineCore,\n\tengineServer: IEngineServer\n): Promise<void> {\n\tengineServer.addRestRouteGenerator(\n\t\t\"testAppComponent\",\n\t\t\"@twin.org/dataspace-test-app\",\n\t\t\"generateRestRoutes\"\n\t);\n}\n\n/**\n * Test Dataspace Data Plane App initializer.\n * @param engineCore The engine core.\n * @param context The context for the engine.\n * @param instanceConfig The instance config.\n * @param instanceConfig.options The instance config options.\n * @param instanceConfig.type The instance type.\n * @returns The instance created and the factory for it.\n */\nexport function testAppInitialiser(\n\tengineCore: IEngineCore<IEngineConfig>,\n\tcontext: IEngineCoreContext,\n\tinstanceConfig: { type: \"service\"; options: ITestAppConstructorOptions }\n): EngineTypeInitialiserReturn<typeof instanceConfig, typeof DataspaceAppFactory> {\n\tlet instanceTypeName: string | undefined;\n\tlet createComponent;\n\n\tif (instanceConfig.type === \"service\") {\n\t\tcreateComponent = (createConfig: typeof instanceConfig) =>\n\t\t\tnew TestDataspaceDataPlaneApp(\n\t\t\t\tEngineTypeHelper.mergeConfig<ITestAppConstructorOptions>(\n\t\t\t\t\t{\n\t\t\t\t\t\tloggingComponentType: engineCore.getRegisteredInstanceType(\"loggingComponent\")\n\t\t\t\t\t},\n\t\t\t\t\tcreateConfig.options\n\t\t\t\t)\n\t\t\t);\n\t\tinstanceTypeName = TestDataspaceDataPlaneApp.APP_ID;\n\t}\n\n\treturn {\n\t\tinstanceTypeName,\n\t\tfactory: DataspaceAppFactory,\n\t\tcreateComponent\n\t};\n}\n\n/**\n * Generate the rest routes for the component.\n * @param baseRouteName The base route name.\n * @param componentName The component name.\n * @returns The rest routes.\n */\nexport function generateRestRoutes(baseRouteName: string, componentName: string): IRestRoute[] {\n\treturn [];\n}\n"]}
|
|
@@ -114,14 +114,15 @@ export class TestDataspaceDataPlaneApp {
|
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
116
|
* Supported query types.
|
|
117
|
-
* @returns
|
|
117
|
+
* @returns The query type identifiers supported by this app.
|
|
118
118
|
*/
|
|
119
119
|
supportedQueryTypes() {
|
|
120
120
|
return ["TestQueryType"];
|
|
121
121
|
}
|
|
122
122
|
/**
|
|
123
123
|
* Start method.
|
|
124
|
-
* @param nodeLoggingComponentType
|
|
124
|
+
* @param nodeLoggingComponentType The logging component type of such a node.
|
|
125
|
+
* @returns A promise that resolves when data type handlers are registered and the node identity is captured.
|
|
125
126
|
*/
|
|
126
127
|
async start(nodeLoggingComponentType) {
|
|
127
128
|
const contextIds = await ContextIdStore.getContextIds();
|
|
@@ -158,8 +159,8 @@ export class TestDataspaceDataPlaneApp {
|
|
|
158
159
|
}
|
|
159
160
|
/**
|
|
160
161
|
* Handle Activity.
|
|
161
|
-
* @param activity
|
|
162
|
-
* @returns
|
|
162
|
+
* @param activity The activity to handle.
|
|
163
|
+
* @returns The activity processing result produced by this app.
|
|
163
164
|
*/
|
|
164
165
|
async handleActivity(activity) {
|
|
165
166
|
Guards.object(TestDataspaceDataPlaneApp.CLASS_NAME, "activity", activity);
|
|
@@ -178,10 +179,10 @@ export class TestDataspaceDataPlaneApp {
|
|
|
178
179
|
}
|
|
179
180
|
/**
|
|
180
181
|
* Handles the Data Request.
|
|
181
|
-
* @param dataRequest The data request
|
|
182
|
+
* @param dataRequest The data request.
|
|
182
183
|
* @param cursor Cursor that points to the next item in the result set.
|
|
183
184
|
* @param limit Maximum number of entries retrieved or to be retrieved.
|
|
184
|
-
* @returns
|
|
185
|
+
* @returns The matching JSON-LD data and an optional next-page cursor.
|
|
185
186
|
*/
|
|
186
187
|
async handleDataRequest(dataRequest, cursor, limit) {
|
|
187
188
|
Guards.object(TestDataspaceDataPlaneApp.CLASS_NAME, "dataRequest", dataRequest);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"testDataspaceDataPlaneApp.js","sourceRoot":"","sources":["../../src/testDataspaceDataPlaneApp.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EACN,eAAe,EAMf,MAAM,4BAA4B,CAAC;AAMpC,wFAAwF;AACxF,kGAAkG;AAClG,MAAM,oBAAoB,GA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I,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAC7C,SAAS,CAAC,QAAQ,CAAE,CAAqB,CAAC,EAAE,IAAI,EAAE,CAAC,CACnD,CAAC;oBACF,OAAO,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAoB,EAAE,CAAC;gBACnF,CAAC;gBAED,IAAI,WAAW,CAAC,SAAS,CAAC,UAAU,KAAK,6CAA6C,EAAE,CAAC;oBACxF,OAAO;wBACN,IAAI,EAAE,IAAI,CAAC,aAA2C;qBACtD,CAAC;gBACH,CAAC;gBAED,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;YACrB,CAAC;YAED,KAAK,eAAe,CAAC,cAAc;gBAClC,OAAO,EAAE,IAAI,EAAE,gBAA8C,EAAE,CAAC;QAClE,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport { DataTypeHandlerFactory } from \"@twin.org/data-core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport {\n\tDataRequestType,\n\ttype IDataspaceActivity,\n\ttype IActivityQuery,\n\ttype IDataRequest,\n\ttype IDataspaceApp,\n\ttype IProcessingGroupOptions\n} from \"@twin.org/dataspace-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IActivityStreamsActivity } from \"@twin.org/standards-w3c-activity-streams\";\nimport type { ITestAppConstructorOptions } from \"./ITestAppConstructorOptions.js\";\n\n// Default consignments — two entries with different port locations for filtering tests.\n// Can be overridden via constructor options (e.g. loaded from a JSON file via @json: env syntax).\nconst DEFAULT_CONSIGNMENTS: IJsonLdDocument[] = [\n\t{\n\t\t\"@context\": \"https://vocabulary.uncefact.org/unece-context-D23B.jsonld\",\n\t\ttype: \"Consignment\",\n\t\tid: \"urn:ucr:24PLP051219453I002610799053311\",\n\t\tidentifier: \"M-Test0001\",\n\t\tglobalId: \"5-GB-IMPORT-Test0001\",\n\t\tdestinationCountry: {\n\t\t\ttype: \"Country\",\n\t\t\tcountryId: \"unece:CountryId#GB\"\n\t\t},\n\t\tloadingLocation: {\n\t\t\ttype: \"LogisticsLocation\",\n\t\t\tid: \"unece:LOCODE#NLRTM\",\n\t\t\tname: \"Rotterdam\"\n\t\t},\n\t\tunloadingLocation: {\n\t\t\ttype: \"LogisticsLocation\",\n\t\t\tid: \"unece:LOCODE#GBFXT\",\n\t\t\tname: \"Felixstowe\"\n\t\t}\n\t},\n\t{\n\t\t\"@context\": \"https://vocabulary.uncefact.org/unece-context-D23B.jsonld\",\n\t\ttype: \"Consignment\",\n\t\tid: \"urn:ucr:24PLP051219453I002710888164422\",\n\t\tidentifier: \"M-Test0002\",\n\t\tglobalId: \"5-GB-IMPORT-Test0002\",\n\t\tdestinationCountry: {\n\t\t\ttype: \"Country\",\n\t\t\tcountryId: \"unece:CountryId#GB\"\n\t\t},\n\t\tloadingLocation: {\n\t\t\ttype: \"LogisticsLocation\",\n\t\t\tid: \"unece:LOCODE#FRLEH\",\n\t\t\tname: \"Le Havre\"\n\t\t},\n\t\tunloadingLocation: {\n\t\t\ttype: \"LogisticsLocation\",\n\t\t\tid: \"unece:LOCODE#GBDVR\",\n\t\t\tname: \"Dover\"\n\t\t}\n\t}\n];\n\nconst DEFAULT_ENTITIES: IJsonLdDocument[] = [\n\tDEFAULT_CONSIGNMENTS[0],\n\t{\n\t\t\"@context\": \"https://vocabulary.uncefact.org/unece-context-D23B.jsonld\",\n\t\ttype: \"Document\",\n\t\tid: \"urn:document:a3456fddaa56\",\n\t\tdocumentTypeCode: \"unece:DocumentCodeList#853\"\n\t}\n];\n\n/**\n * Test App Activity Handler.\n */\nexport class TestDataspaceDataPlaneApp implements IDataspaceApp {\n\t/**\n\t * App Name.\n\t */\n\tpublic static readonly APP_ID = \"https://twin.example.org/app1\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<TestDataspaceDataPlaneApp>();\n\n\t/**\n\t * Logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * Consignment documents served by this app.\n\t * @internal\n\t */\n\tprivate readonly _consignments: IJsonLdDocument[];\n\n\t/**\n\t * Node Identity\n\t * @internal\n\t */\n\tprivate _nodeId?: string;\n\n\t/**\n\t * Create a new instance of TestDataspaceDataPlaneApp.\n\t * @param options The constructor options.\n\t */\n\tconstructor(options?: ITestAppConstructorOptions) {\n\t\tthis._logging = ComponentFactory.getIfExists<ILoggingComponent>(options?.loggingComponentType);\n\t\tthis._consignments = options?.consignments ?? DEFAULT_CONSIGNMENTS;\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 TestDataspaceDataPlaneApp.CLASS_NAME;\n\t}\n\n\t/**\n\t * The settings for the processing groups for tasks.\n\t * @returns The options for each process group.\n\t */\n\tpublic processingGroups(): {\n\t\t[id: string]: IProcessingGroupOptions;\n\t} {\n\t\treturn {\n\t\t\t\"test-default\": {\n\t\t\t\tconcurrentTasks: 2\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Supported query types.\n\t * @returns Types.\n\t */\n\tpublic supportedQueryTypes(): string[] {\n\t\treturn [\"TestQueryType\"];\n\t}\n\n\t/**\n\t * Start method.\n\t * @param nodeLoggingComponentType the logging component type of such a node.\n\t */\n\tpublic async start(nodeLoggingComponentType?: string): Promise<void> {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Node);\n\t\tthis._nodeId = contextIds[ContextIdKeys.Node];\n\n\t\tDataTypeHandlerFactory.register(\"https://twin.example.org/MyCreate\", () => ({\n\t\t\tnamespace: \"https://twin.example.org/\",\n\t\t\ttype: \"MyCreate\",\n\t\t\tdefaultValue: {},\n\t\t\tjsonSchema: async () => ({\n\t\t\t\ttype: \"object\"\n\t\t\t})\n\t\t}));\n\n\t\tDataTypeHandlerFactory.register(\"https://vocabulary.uncefact.org/Consignment\", () => ({\n\t\t\tnamespace: \"https://vocabulary.uncefact.org/\",\n\t\t\ttype: \"Consignment\",\n\t\t\tdefaultValue: {},\n\t\t\tjsonSchema: async () => ({\n\t\t\t\ttype: \"object\"\n\t\t\t})\n\t\t}));\n\t}\n\n\t/**\n\t * The activities handled by the App.\n\t * @returns The activities handled by the App.\n\t */\n\tpublic activitiesHandled(): IActivityQuery[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tobjectType: \"https://vocabulary.uncefact.org/Consignment\",\n\t\t\t\tprocessingGroupId: \"test-default\"\n\t\t\t}\n\t\t];\n\t}\n\n\t/**\n\t * Handle Activity.\n\t * @param activity Activity\n\t * @returns Activity processing result\n\t */\n\tpublic async handleActivity<T>(activity: IDataspaceActivity): Promise<T> {\n\t\tGuards.object<IActivityStreamsActivity>(\n\t\t\tTestDataspaceDataPlaneApp.CLASS_NAME,\n\t\t\tnameof(activity),\n\t\t\tactivity\n\t\t);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: TestDataspaceDataPlaneApp.CLASS_NAME,\n\t\t\tmessage: `App Called: ${TestDataspaceDataPlaneApp.APP_ID}`\n\t\t});\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: TestDataspaceDataPlaneApp.CLASS_NAME,\n\t\t\tmessage: `Node Identity: ${this._nodeId ?? \"\"}`\n\t\t});\n\n\t\tawait new Promise(resolve => setTimeout(resolve, 500));\n\t\treturn \"1234\" as T;\n\t}\n\n\t/**\n\t * Handles the Data Request.\n\t * @param dataRequest The data request\n\t * @param cursor Cursor that points to the next item in the result set.\n\t * @param limit Maximum number of entries retrieved or to be retrieved.\n\t * @returns the Data.\n\t */\n\tpublic async handleDataRequest(\n\t\tdataRequest: IDataRequest,\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{ data: IJsonLdDocument; cursor?: string }> {\n\t\tGuards.object<IDataRequest>(\n\t\t\tTestDataspaceDataPlaneApp.CLASS_NAME,\n\t\t\tnameof(dataRequest),\n\t\t\tdataRequest\n\t\t);\n\n\t\tswitch (dataRequest.type) {\n\t\t\tcase DataRequestType.DataAssetEntities: {\n\t\t\t\tif (dataRequest.entitySet.entityId) {\n\t\t\t\t\tconst entityIds = dataRequest.entitySet.entityId;\n\t\t\t\t\tconst matched = this._consignments.filter(c =>\n\t\t\t\t\t\tentityIds.includes((c as { id?: string }).id ?? \"\")\n\t\t\t\t\t);\n\t\t\t\t\treturn { data: (matched.length === 1 ? matched[0] : matched) as IJsonLdDocument };\n\t\t\t\t}\n\n\t\t\t\tif (dataRequest.entitySet.entityType === \"https://vocabulary.uncefact.org/Consignment\") {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdata: this._consignments as unknown as IJsonLdDocument\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn { data: [] };\n\t\t\t}\n\n\t\t\tcase DataRequestType.QueryDataAsset:\n\t\t\t\treturn { data: DEFAULT_ENTITIES as unknown as IJsonLdDocument };\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"testDataspaceDataPlaneApp.js","sourceRoot":"","sources":["../../src/testDataspaceDataPlaneApp.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnF,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EACN,eAAe,EAMf,MAAM,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G,WAAW,CAAC,SAAS,CAAC,QAAQ,CAAC;oBACjD,MAAM,OAAO,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAC7C,SAAS,CAAC,QAAQ,CAAE,CAAqB,CAAC,EAAE,IAAI,EAAE,CAAC,CACnD,CAAC;oBACF,OAAO,EAAE,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAoB,EAAE,CAAC;gBACnF,CAAC;gBAED,IAAI,WAAW,CAAC,SAAS,CAAC,UAAU,KAAK,6CAA6C,EAAE,CAAC;oBACxF,OAAO;wBACN,IAAI,EAAE,IAAI,CAAC,aAA2C;qBACtD,CAAC;gBACH,CAAC;gBAED,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;YACrB,CAAC;YAED,KAAK,eAAe,CAAC,cAAc;gBAClC,OAAO,EAAE,IAAI,EAAE,gBAA8C,EAAE,CAAC;QAClE,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { ContextIdHelper, ContextIdKeys, ContextIdStore } from \"@twin.org/context\";\nimport { ComponentFactory, Guards } from \"@twin.org/core\";\nimport { DataTypeHandlerFactory } from \"@twin.org/data-core\";\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\nimport {\n\tDataRequestType,\n\ttype IDataspaceActivity,\n\ttype IActivityQuery,\n\ttype IDataRequest,\n\ttype IDataspaceApp,\n\ttype IProcessingGroupOptions\n} from \"@twin.org/dataspace-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport type { IActivityStreamsActivity } from \"@twin.org/standards-w3c-activity-streams\";\nimport type { ITestAppConstructorOptions } from \"./ITestAppConstructorOptions.js\";\n\n// Default consignments — two entries with different port locations for filtering tests.\n// Can be overridden via constructor options (e.g. loaded from a JSON file via @json: env syntax).\nconst DEFAULT_CONSIGNMENTS: IJsonLdDocument[] = [\n\t{\n\t\t\"@context\": \"https://vocabulary.uncefact.org/unece-context-D23B.jsonld\",\n\t\ttype: \"Consignment\",\n\t\tid: \"urn:ucr:24PLP051219453I002610799053311\",\n\t\tidentifier: \"M-Test0001\",\n\t\tglobalId: \"5-GB-IMPORT-Test0001\",\n\t\tdestinationCountry: {\n\t\t\ttype: \"Country\",\n\t\t\tcountryId: \"unece:CountryId#GB\"\n\t\t},\n\t\tloadingLocation: {\n\t\t\ttype: \"LogisticsLocation\",\n\t\t\tid: \"unece:LOCODE#NLRTM\",\n\t\t\tname: \"Rotterdam\"\n\t\t},\n\t\tunloadingLocation: {\n\t\t\ttype: \"LogisticsLocation\",\n\t\t\tid: \"unece:LOCODE#GBFXT\",\n\t\t\tname: \"Felixstowe\"\n\t\t}\n\t},\n\t{\n\t\t\"@context\": \"https://vocabulary.uncefact.org/unece-context-D23B.jsonld\",\n\t\ttype: \"Consignment\",\n\t\tid: \"urn:ucr:24PLP051219453I002710888164422\",\n\t\tidentifier: \"M-Test0002\",\n\t\tglobalId: \"5-GB-IMPORT-Test0002\",\n\t\tdestinationCountry: {\n\t\t\ttype: \"Country\",\n\t\t\tcountryId: \"unece:CountryId#GB\"\n\t\t},\n\t\tloadingLocation: {\n\t\t\ttype: \"LogisticsLocation\",\n\t\t\tid: \"unece:LOCODE#FRLEH\",\n\t\t\tname: \"Le Havre\"\n\t\t},\n\t\tunloadingLocation: {\n\t\t\ttype: \"LogisticsLocation\",\n\t\t\tid: \"unece:LOCODE#GBDVR\",\n\t\t\tname: \"Dover\"\n\t\t}\n\t}\n];\n\nconst DEFAULT_ENTITIES: IJsonLdDocument[] = [\n\tDEFAULT_CONSIGNMENTS[0],\n\t{\n\t\t\"@context\": \"https://vocabulary.uncefact.org/unece-context-D23B.jsonld\",\n\t\ttype: \"Document\",\n\t\tid: \"urn:document:a3456fddaa56\",\n\t\tdocumentTypeCode: \"unece:DocumentCodeList#853\"\n\t}\n];\n\n/**\n * Test App Activity Handler.\n */\nexport class TestDataspaceDataPlaneApp implements IDataspaceApp {\n\t/**\n\t * App Name.\n\t */\n\tpublic static readonly APP_ID = \"https://twin.example.org/app1\";\n\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<TestDataspaceDataPlaneApp>();\n\n\t/**\n\t * Logging component.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * Consignment documents served by this app.\n\t * @internal\n\t */\n\tprivate readonly _consignments: IJsonLdDocument[];\n\n\t/**\n\t * Node Identity\n\t * @internal\n\t */\n\tprivate _nodeId?: string;\n\n\t/**\n\t * Create a new instance of TestDataspaceDataPlaneApp.\n\t * @param options The constructor options.\n\t */\n\tconstructor(options?: ITestAppConstructorOptions) {\n\t\tthis._logging = ComponentFactory.getIfExists<ILoggingComponent>(options?.loggingComponentType);\n\t\tthis._consignments = options?.consignments ?? DEFAULT_CONSIGNMENTS;\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 TestDataspaceDataPlaneApp.CLASS_NAME;\n\t}\n\n\t/**\n\t * The settings for the processing groups for tasks.\n\t * @returns The options for each process group.\n\t */\n\tpublic processingGroups(): {\n\t\t[id: string]: IProcessingGroupOptions;\n\t} {\n\t\treturn {\n\t\t\t\"test-default\": {\n\t\t\t\tconcurrentTasks: 2\n\t\t\t}\n\t\t};\n\t}\n\n\t/**\n\t * Supported query types.\n\t * @returns The query type identifiers supported by this app.\n\t */\n\tpublic supportedQueryTypes(): string[] {\n\t\treturn [\"TestQueryType\"];\n\t}\n\n\t/**\n\t * Start method.\n\t * @param nodeLoggingComponentType The logging component type of such a node.\n\t * @returns A promise that resolves when data type handlers are registered and the node identity is captured.\n\t */\n\tpublic async start(nodeLoggingComponentType?: string): Promise<void> {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tContextIdHelper.guard(contextIds, ContextIdKeys.Node);\n\t\tthis._nodeId = contextIds[ContextIdKeys.Node];\n\n\t\tDataTypeHandlerFactory.register(\"https://twin.example.org/MyCreate\", () => ({\n\t\t\tnamespace: \"https://twin.example.org/\",\n\t\t\ttype: \"MyCreate\",\n\t\t\tdefaultValue: {},\n\t\t\tjsonSchema: async () => ({\n\t\t\t\ttype: \"object\"\n\t\t\t})\n\t\t}));\n\n\t\tDataTypeHandlerFactory.register(\"https://vocabulary.uncefact.org/Consignment\", () => ({\n\t\t\tnamespace: \"https://vocabulary.uncefact.org/\",\n\t\t\ttype: \"Consignment\",\n\t\t\tdefaultValue: {},\n\t\t\tjsonSchema: async () => ({\n\t\t\t\ttype: \"object\"\n\t\t\t})\n\t\t}));\n\t}\n\n\t/**\n\t * The activities handled by the App.\n\t * @returns The activities handled by the App.\n\t */\n\tpublic activitiesHandled(): IActivityQuery[] {\n\t\treturn [\n\t\t\t{\n\t\t\t\tobjectType: \"https://vocabulary.uncefact.org/Consignment\",\n\t\t\t\tprocessingGroupId: \"test-default\"\n\t\t\t}\n\t\t];\n\t}\n\n\t/**\n\t * Handle Activity.\n\t * @param activity The activity to handle.\n\t * @returns The activity processing result produced by this app.\n\t */\n\tpublic async handleActivity<T>(activity: IDataspaceActivity): Promise<T> {\n\t\tGuards.object<IActivityStreamsActivity>(\n\t\t\tTestDataspaceDataPlaneApp.CLASS_NAME,\n\t\t\tnameof(activity),\n\t\t\tactivity\n\t\t);\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: TestDataspaceDataPlaneApp.CLASS_NAME,\n\t\t\tmessage: `App Called: ${TestDataspaceDataPlaneApp.APP_ID}`\n\t\t});\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: TestDataspaceDataPlaneApp.CLASS_NAME,\n\t\t\tmessage: `Node Identity: ${this._nodeId ?? \"\"}`\n\t\t});\n\n\t\tawait new Promise(resolve => setTimeout(resolve, 500));\n\t\treturn \"1234\" as T;\n\t}\n\n\t/**\n\t * Handles the Data Request.\n\t * @param dataRequest The data request.\n\t * @param cursor Cursor that points to the next item in the result set.\n\t * @param limit Maximum number of entries retrieved or to be retrieved.\n\t * @returns The matching JSON-LD data and an optional next-page cursor.\n\t */\n\tpublic async handleDataRequest(\n\t\tdataRequest: IDataRequest,\n\t\tcursor?: string,\n\t\tlimit?: number\n\t): Promise<{ data: IJsonLdDocument; cursor?: string }> {\n\t\tGuards.object<IDataRequest>(\n\t\t\tTestDataspaceDataPlaneApp.CLASS_NAME,\n\t\t\tnameof(dataRequest),\n\t\t\tdataRequest\n\t\t);\n\n\t\tswitch (dataRequest.type) {\n\t\t\tcase DataRequestType.DataAssetEntities: {\n\t\t\t\tif (dataRequest.entitySet.entityId) {\n\t\t\t\t\tconst entityIds = dataRequest.entitySet.entityId;\n\t\t\t\t\tconst matched = this._consignments.filter(c =>\n\t\t\t\t\t\tentityIds.includes((c as { id?: string }).id ?? \"\")\n\t\t\t\t\t);\n\t\t\t\t\treturn { data: (matched.length === 1 ? matched[0] : matched) as IJsonLdDocument };\n\t\t\t\t}\n\n\t\t\t\tif (dataRequest.entitySet.entityType === \"https://vocabulary.uncefact.org/Consignment\") {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdata: this._consignments as unknown as IJsonLdDocument\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\treturn { data: [] };\n\t\t\t}\n\n\t\t\tcase DataRequestType.QueryDataAsset:\n\t\t\t\treturn { data: DEFAULT_ENTITIES as unknown as IJsonLdDocument };\n\t\t}\n\t}\n}\n"]}
|
|
@@ -4,9 +4,10 @@ import type { EngineTypeInitialiserReturn, IEngineCore, IEngineCoreConfig, IEngi
|
|
|
4
4
|
import { type IEngineConfig } from "@twin.org/engine-types";
|
|
5
5
|
import type { ITestAppConstructorOptions } from "./ITestAppConstructorOptions.js";
|
|
6
6
|
/**
|
|
7
|
-
* Initialise the
|
|
7
|
+
* Initialise the extension.
|
|
8
8
|
* @param envVars The environment variables for the node.
|
|
9
9
|
* @param nodeEngineConfig The node engine config.
|
|
10
|
+
* @returns A promise that resolves when the test app component type has been registered in the engine config.
|
|
10
11
|
*/
|
|
11
12
|
export declare function extensionInitialise(envVars: {
|
|
12
13
|
[id: string]: string | unknown;
|
|
@@ -14,12 +15,14 @@ export declare function extensionInitialise(envVars: {
|
|
|
14
15
|
/**
|
|
15
16
|
* Initialise the engine for the extension.
|
|
16
17
|
* @param engineCore The engine core instance.
|
|
18
|
+
* @returns A promise that resolves when the type initialiser has been registered with the engine.
|
|
17
19
|
*/
|
|
18
20
|
export declare function extensionInitialiseEngine(engineCore: IEngineCore): Promise<void>;
|
|
19
21
|
/**
|
|
20
22
|
* Initialise the engine server for the extension.
|
|
21
23
|
* @param engineCore The engine core instance.
|
|
22
24
|
* @param engineServer The engine server instance.
|
|
25
|
+
* @returns A promise that resolves when the REST route generator has been registered with the engine server.
|
|
23
26
|
*/
|
|
24
27
|
export declare function extensionInitialiseEngineServer(engineCore: IEngineCore, engineServer: IEngineServer): Promise<void>;
|
|
25
28
|
/**
|
|
@@ -32,12 +32,13 @@ export declare class TestDataspaceDataPlaneApp implements IDataspaceApp {
|
|
|
32
32
|
};
|
|
33
33
|
/**
|
|
34
34
|
* Supported query types.
|
|
35
|
-
* @returns
|
|
35
|
+
* @returns The query type identifiers supported by this app.
|
|
36
36
|
*/
|
|
37
37
|
supportedQueryTypes(): string[];
|
|
38
38
|
/**
|
|
39
39
|
* Start method.
|
|
40
|
-
* @param nodeLoggingComponentType
|
|
40
|
+
* @param nodeLoggingComponentType The logging component type of such a node.
|
|
41
|
+
* @returns A promise that resolves when data type handlers are registered and the node identity is captured.
|
|
41
42
|
*/
|
|
42
43
|
start(nodeLoggingComponentType?: string): Promise<void>;
|
|
43
44
|
/**
|
|
@@ -47,16 +48,16 @@ export declare class TestDataspaceDataPlaneApp implements IDataspaceApp {
|
|
|
47
48
|
activitiesHandled(): IActivityQuery[];
|
|
48
49
|
/**
|
|
49
50
|
* Handle Activity.
|
|
50
|
-
* @param activity
|
|
51
|
-
* @returns
|
|
51
|
+
* @param activity The activity to handle.
|
|
52
|
+
* @returns The activity processing result produced by this app.
|
|
52
53
|
*/
|
|
53
54
|
handleActivity<T>(activity: IDataspaceActivity): Promise<T>;
|
|
54
55
|
/**
|
|
55
56
|
* Handles the Data Request.
|
|
56
|
-
* @param dataRequest The data request
|
|
57
|
+
* @param dataRequest The data request.
|
|
57
58
|
* @param cursor Cursor that points to the next item in the result set.
|
|
58
59
|
* @param limit Maximum number of entries retrieved or to be retrieved.
|
|
59
|
-
* @returns
|
|
60
|
+
* @returns The matching JSON-LD data and an optional next-page cursor.
|
|
60
61
|
*/
|
|
61
62
|
handleDataRequest(dataRequest: IDataRequest, cursor?: string, limit?: number): Promise<{
|
|
62
63
|
data: IJsonLdDocument;
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.45](https://github.com/iotaledger/twin-dataspace/compare/dataspace-test-app-v0.0.3-next.44...dataspace-test-app-v0.0.3-next.45) (2026-06-17)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Miscellaneous Chores
|
|
7
|
+
|
|
8
|
+
* **dataspace-test-app:** Synchronize repo versions
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Dependencies
|
|
12
|
+
|
|
13
|
+
* The following workspace dependencies were updated
|
|
14
|
+
* dependencies
|
|
15
|
+
* @twin.org/dataspace-models bumped from 0.0.3-next.44 to 0.0.3-next.45
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.44](https://github.com/iotaledger/twin-dataspace/compare/dataspace-test-app-v0.0.3-next.43...dataspace-test-app-v0.0.3-next.44) (2026-06-12)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Miscellaneous Chores
|
|
21
|
+
|
|
22
|
+
* **dataspace-test-app:** Synchronize repo versions
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
### Dependencies
|
|
26
|
+
|
|
27
|
+
* The following workspace dependencies were updated
|
|
28
|
+
* dependencies
|
|
29
|
+
* @twin.org/dataspace-models bumped from 0.0.3-next.43 to 0.0.3-next.44
|
|
30
|
+
|
|
3
31
|
## [0.0.3-next.43](https://github.com/iotaledger/twin-dataspace/compare/dataspace-test-app-v0.0.3-next.42...dataspace-test-app-v0.0.3-next.43) (2026-06-11)
|
|
4
32
|
|
|
5
33
|
|
|
@@ -90,7 +90,7 @@ Supported query types.
|
|
|
90
90
|
|
|
91
91
|
`string`[]
|
|
92
92
|
|
|
93
|
-
|
|
93
|
+
The query type identifiers supported by this app.
|
|
94
94
|
|
|
95
95
|
#### Implementation of
|
|
96
96
|
|
|
@@ -110,12 +110,14 @@ Start method.
|
|
|
110
110
|
|
|
111
111
|
`string`
|
|
112
112
|
|
|
113
|
-
|
|
113
|
+
The logging component type of such a node.
|
|
114
114
|
|
|
115
115
|
#### Returns
|
|
116
116
|
|
|
117
117
|
`Promise`\<`void`\>
|
|
118
118
|
|
|
119
|
+
A promise that resolves when data type handlers are registered and the node identity is captured.
|
|
120
|
+
|
|
119
121
|
#### Implementation of
|
|
120
122
|
|
|
121
123
|
`IDataspaceApp.start`
|
|
@@ -158,13 +160,13 @@ Handle Activity.
|
|
|
158
160
|
|
|
159
161
|
`IDataspaceActivity`
|
|
160
162
|
|
|
161
|
-
|
|
163
|
+
The activity to handle.
|
|
162
164
|
|
|
163
165
|
#### Returns
|
|
164
166
|
|
|
165
167
|
`Promise`\<`T`\>
|
|
166
168
|
|
|
167
|
-
|
|
169
|
+
The activity processing result produced by this app.
|
|
168
170
|
|
|
169
171
|
#### Implementation of
|
|
170
172
|
|
|
@@ -184,7 +186,7 @@ Handles the Data Request.
|
|
|
184
186
|
|
|
185
187
|
`IDataRequest`
|
|
186
188
|
|
|
187
|
-
The data request
|
|
189
|
+
The data request.
|
|
188
190
|
|
|
189
191
|
##### cursor?
|
|
190
192
|
|
|
@@ -202,7 +204,7 @@ Maximum number of entries retrieved or to be retrieved.
|
|
|
202
204
|
|
|
203
205
|
`Promise`\<\{ `data`: `IJsonLdDocument`; `cursor?`: `string`; \}\>
|
|
204
206
|
|
|
205
|
-
|
|
207
|
+
The matching JSON-LD data and an optional next-page cursor.
|
|
206
208
|
|
|
207
209
|
#### Implementation of
|
|
208
210
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
> **extensionInitialise**(`envVars`, `nodeEngineConfig`): `Promise`\<`void`\>
|
|
4
4
|
|
|
5
|
-
Initialise the
|
|
5
|
+
Initialise the extension.
|
|
6
6
|
|
|
7
7
|
## Parameters
|
|
8
8
|
|
|
@@ -19,3 +19,5 @@ The node engine config.
|
|
|
19
19
|
## Returns
|
|
20
20
|
|
|
21
21
|
`Promise`\<`void`\>
|
|
22
|
+
|
|
23
|
+
A promise that resolves when the test app component type has been registered in the engine config.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/dataspace-test-app",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.45",
|
|
4
4
|
"description": "Provides a sample dataspace app for local integration tests and development workflows.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"@twin.org/core": "next",
|
|
20
20
|
"@twin.org/data-core": "next",
|
|
21
21
|
"@twin.org/data-json-ld": "next",
|
|
22
|
-
"@twin.org/dataspace-models": "0.0.3-next.
|
|
22
|
+
"@twin.org/dataspace-models": "0.0.3-next.45",
|
|
23
23
|
"@twin.org/engine-models": "next",
|
|
24
24
|
"@twin.org/engine-types": "next",
|
|
25
25
|
"@twin.org/logging-models": "next",
|