@twin.org/dataspace-test-app 0.0.3-next.21 → 0.0.3-next.23

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.
@@ -1,4 +1,2 @@
1
- // Copyright 2025 IOTA Stiftung.
2
- // SPDX-License-Identifier: Apache-2.0.
3
1
  export {};
4
2
  //# sourceMappingURL=ITestAppConstructorOptions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ITestAppConstructorOptions.js","sourceRoot":"","sources":["../../src/ITestAppConstructorOptions.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\n\n/**\n * Test App Constructor options.\n */\nexport interface ITestAppConstructorOptions {\n\t/**\n\t * Logging component type.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n}\n"]}
1
+ {"version":3,"file":"ITestAppConstructorOptions.js","sourceRoot":"","sources":["../../src/ITestAppConstructorOptions.ts"],"names":[],"mappings":"","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type { IJsonLdDocument } from \"@twin.org/data-json-ld\";\n\n/**\n * Test App Constructor options.\n */\nexport interface ITestAppConstructorOptions {\n\t/**\n\t * Logging component type.\n\t * @default logging\n\t */\n\tloggingComponentType?: string;\n\n\t/**\n\t * List of consignment documents to serve.\n\t * Can be loaded from a JSON file via the `@json:` env var syntax.\n\t * Falls back to built-in default consignments if not provided.\n\t */\n\tconsignments?: IJsonLdDocument[];\n}\n"]}
@@ -1,3 +1,4 @@
1
+ import { Is } from "@twin.org/core";
1
2
  import { DataspaceAppFactory } from "@twin.org/dataspace-models";
2
3
  import { EngineTypeHelper } from "@twin.org/engine-types";
3
4
  import { TestDataspaceDataPlaneApp } from "./testDataspaceDataPlaneApp.js";
@@ -10,7 +11,11 @@ export async function extensionInitialise(envVars, nodeEngineConfig) {
10
11
  nodeEngineConfig.types.testAppComponent = [
11
12
  {
12
13
  type: "service",
13
- options: {}
14
+ options: {
15
+ consignments: Is.arrayValue(envVars.testAppConsignments)
16
+ ? envVars.testAppConsignments
17
+ : undefined
18
+ }
14
19
  }
15
20
  ];
16
21
  }
@@ -1 +1 @@
1
- {"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/extension.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAQjE,OAAO,EAAsB,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE9E,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACxC,OAAiC,EACjC,gBAAmC;IAEnC,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,GAAG;QACzC;YACC,IAAI,EAAE,SAAS;YACf,OAAO,EAAE,EAAE;SACX;KACD,CAAC;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAAC,UAAuB;IACtE,UAAU,CAAC,kBAAkB,CAC5B,kBAAkB,EAClB,8BAA8B,EAC9B,oBAAoB,CACpB,CAAC;AACH,CAAC;AAED;;;;GAIG;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,EAAE,eAAsE;KACvF,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 type { IComponent } 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 */\nexport async function extensionInitialise(\n\tenvVars: { [id: string]: string },\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}\n\t];\n}\n\n/**\n * Initialise the engine for the extension.\n * @param engineCore The engine core instance.\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 */\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: createComponent as (createConfig: typeof instanceConfig) => IComponent\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"]}
1
+ {"version":3,"file":"extension.js","sourceRoot":"","sources":["../../src/extension.ts"],"names":[],"mappings":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kB,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,EAAE,eAAsE;KACvF,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, type IComponent } 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 */\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 */\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 */\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: createComponent as (createConfig: typeof instanceConfig) => IComponent\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"]}
@@ -6,18 +6,54 @@ import { DataTypeHandlerFactory } from "@twin.org/data-core";
6
6
  import { DataRequestType } from "@twin.org/dataspace-models";
7
7
  import { DataspaceProtocolContexts } from "@twin.org/standards-dataspace-protocol";
8
8
  import { DublinCoreContexts } from "@twin.org/standards-dublin-core";
9
- // Dummy Data
10
- const id = "urn:ucr:24PLP051219453I002610799053311";
11
- const entities = [
9
+ // Default consignments — two entries with different port locations for filtering tests.
10
+ // Can be overridden via constructor options (e.g. loaded from a JSON file via @json: env syntax).
11
+ const DEFAULT_CONSIGNMENTS = [
12
12
  {
13
13
  "@context": "https://vocabulary.uncefact.org/unece-context-D23B.jsonld",
14
14
  type: "Consignment",
15
- id,
15
+ id: "urn:ucr:24PLP051219453I002610799053311",
16
+ identifier: "M-Test0001",
17
+ globalId: "5-GB-IMPORT-Test0001",
16
18
  destinationCountry: {
17
19
  type: "Country",
18
20
  countryId: "unece:CountryId#GB"
21
+ },
22
+ loadingLocation: {
23
+ type: "LogisticsLocation",
24
+ id: "unece:LOCODE#NLRTM",
25
+ name: "Rotterdam"
26
+ },
27
+ unloadingLocation: {
28
+ type: "LogisticsLocation",
29
+ id: "unece:LOCODE#GBFXT",
30
+ name: "Felixstowe"
19
31
  }
20
32
  },
33
+ {
34
+ "@context": "https://vocabulary.uncefact.org/unece-context-D23B.jsonld",
35
+ type: "Consignment",
36
+ id: "urn:ucr:24PLP051219453I002710888164422",
37
+ identifier: "M-Test0002",
38
+ globalId: "5-GB-IMPORT-Test0002",
39
+ destinationCountry: {
40
+ type: "Country",
41
+ countryId: "unece:CountryId#GB"
42
+ },
43
+ loadingLocation: {
44
+ type: "LogisticsLocation",
45
+ id: "unece:LOCODE#FRLEH",
46
+ name: "Le Havre"
47
+ },
48
+ unloadingLocation: {
49
+ type: "LogisticsLocation",
50
+ id: "unece:LOCODE#GBDVR",
51
+ name: "Dover"
52
+ }
53
+ }
54
+ ];
55
+ const DEFAULT_ENTITIES = [
56
+ DEFAULT_CONSIGNMENTS[0],
21
57
  {
22
58
  "@context": "https://vocabulary.uncefact.org/unece-context-D23B.jsonld",
23
59
  type: "Document",
@@ -42,6 +78,11 @@ export class TestDataspaceDataPlaneApp {
42
78
  * @internal
43
79
  */
44
80
  _logging;
81
+ /**
82
+ * Consignment documents served by this app.
83
+ * @internal
84
+ */
85
+ _consignments;
45
86
  /**
46
87
  * Node Identity
47
88
  * @internal
@@ -53,6 +94,7 @@ export class TestDataspaceDataPlaneApp {
53
94
  */
54
95
  constructor(options) {
55
96
  this._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? "logging");
97
+ this._consignments = options?.consignments ?? DEFAULT_CONSIGNMENTS;
56
98
  }
57
99
  /**
58
100
  * Returns the class name of the component.
@@ -91,12 +133,14 @@ export class TestDataspaceDataPlaneApp {
91
133
  ]
92
134
  }
93
135
  ],
94
- distribution: {
95
- "@id": "https://twin.example.org/distribution-1",
96
- "@type": "Distribution",
97
- accessService: "https://twin.example.org/data-service-1",
98
- format: "Http-Pull-Query-Format"
99
- },
136
+ distribution: [
137
+ {
138
+ "@id": "https://twin.example.org/distribution-1",
139
+ "@type": "Distribution",
140
+ accessService: "https://twin.example.org/data-service-1",
141
+ format: "Http-Pull-Query-Format"
142
+ }
143
+ ],
100
144
  "dcterms:type": "https://vocabulary.uncefact.org/Consignment"
101
145
  }
102
146
  ];
@@ -171,20 +215,20 @@ export class TestDataspaceDataPlaneApp {
171
215
  Guards.object(TestDataspaceDataPlaneApp.CLASS_NAME, "dataRequest", dataRequest);
172
216
  switch (dataRequest.type) {
173
217
  case DataRequestType.DataAssetEntities: {
174
- if (dataRequest.entitySet.entityType === "https://vocabulary.uncefact.org/Consignment") {
175
- return {
176
- data: [entities[0]]
177
- };
218
+ if (dataRequest.entitySet.entityId) {
219
+ const entityIds = dataRequest.entitySet.entityId;
220
+ const matched = this._consignments.filter(c => entityIds.includes(c.id ?? ""));
221
+ return { data: (matched.length === 1 ? matched[0] : matched) };
178
222
  }
179
- if (dataRequest.entitySet.entityId?.includes(id)) {
223
+ if (dataRequest.entitySet.entityType === "https://vocabulary.uncefact.org/Consignment") {
180
224
  return {
181
- data: entities[0]
225
+ data: this._consignments
182
226
  };
183
227
  }
184
228
  return { data: [] };
185
229
  }
186
230
  case DataRequestType.QueryDataAsset:
187
- return { data: entities };
231
+ return { data: DEFAULT_ENTITIES };
188
232
  }
189
233
  }
190
234
  }
@@ -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,EAKf,MAAM,4BAA4B,CAAC;AAGpC,OAAO,EACN,yBAAyB,EAEzB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iCAAiC,CAAC;AAIrE,aAAa;AACb,MAAM,EAAE,GAAG,wCAAwC,CAAC;AACpD,MAAM,QAAQ,GAAG;IAChB;QACC,UAAU,EAAE,2DAA2D;QACvE,IAAI,EAAE,aAAa;QACnB,EAAE;QACF,kBAAkB,EAAE;YACnB,IAAI,EAAE,SAAS;YACf,SAAS,EAAE,oBAAoB;SAC/B;KACD;IACD;QACC,UAAU,EAAE,2DAA2D;QACvE,IAAI,EAAE,UAAU;QAChB,EAAE,EAAE,2BAA2B;QAC/B,gBAAgB,EAAE,4BAA4B;KAC9C;CACD,CAAC;AAEF;;GAEG;AACH,MAAM,OAAO,yBAAyB;IACrC;;OAEG;IACI,MAAM,CAAU,MAAM,GAAG,+BAA+B,CAAC;IAEhE;;OAEG;IACI,MAAM,CAAU,UAAU,+BAA+C;IAEhF;;;OAGG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,EAAE,kBAAkB,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE;SAC/C,CAAC,CAAC;QAEH,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;QACvD,OAAO,MAAW,CAAC;IACpB,CAAC;IAED;;;;;;OAMG;IACI,KAAK,CAAC,iBAAiB,CAC7B,WAAyB,EACzB,MAAe,EACf,KAAc;QAEd,MAAM,CAAC,MAAM,CACZ,yBAAyB,CAAC,UAAU,iBAEpC,WAAW,CACX,CAAC;QAEF,QAAQ,WAAW,CAAC,IAAI,EAAE,CAAC;YAC1B,KAAK,eAAe,CAAC,iBAAiB,CAAC,CAAC,CAAC;gBACxC,IAAI,WAAW,CAAC,SAAS,CAAC,UAAU,KAAK,6CAA6C,EAAE,CAAC;oBACxF,OAAO;wBACN,IAAI,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;qBACnB,CAAC;gBACH,CAAC;gBAED,IAAI,WAAW,CAAC,SAAS,CAAC,QAAQ,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,CAAC;oBAClD,OAAO;wBACN,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC;qBACjB,CAAC;gBACH,CAAC;gBACD,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC;YACrB,CAAC;YAED,KAAK,eAAe,CAAC,cAAc;gBAClC,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;QAC5B,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} from \"@twin.org/dataspace-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDataspaceProtocolContexts,\n\ttype IDataspaceProtocolDataset\n} from \"@twin.org/standards-dataspace-protocol\";\nimport { DublinCoreContexts } from \"@twin.org/standards-dublin-core\";\nimport type { IActivityStreamsActivity } from \"@twin.org/standards-w3c-activity-streams\";\nimport type { ITestAppConstructorOptions } from \"./ITestAppConstructorOptions.js\";\n\n// Dummy Data\nconst id = \"urn:ucr:24PLP051219453I002610799053311\";\nconst entities = [\n\t{\n\t\t\"@context\": \"https://vocabulary.uncefact.org/unece-context-D23B.jsonld\",\n\t\ttype: \"Consignment\",\n\t\tid,\n\t\tdestinationCountry: {\n\t\t\ttype: \"Country\",\n\t\t\tcountryId: \"unece:CountryId#GB\"\n\t\t}\n\t},\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 * 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>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\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 TestDataspaceDataPlaneApp.CLASS_NAME;\n\t}\n\n\t/**\n\t * Datasets handled by the App.\n\t * @returns Dataspace Protocol compliant datasets\n\t */\n\tpublic async datasetsHandled(): Promise<IDataspaceProtocolDataset[]> {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst organizationId =\n\t\t\tcontextIds?.[ContextIdKeys.Organization] ?? contextIds?.[ContextIdKeys.Node] ?? \"\";\n\t\treturn [\n\t\t\t{\n\t\t\t\t\"@context\": [\n\t\t\t\t\tDataspaceProtocolContexts.Context,\n\t\t\t\t\t{\n\t\t\t\t\t\tdcterms: DublinCoreContexts.NamespaceTerms\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"@id\": \"https://twin.example.org/data-service-1\",\n\t\t\t\t\"@type\": \"Dataset\",\n\t\t\t\t\"dcterms:publisher\": organizationId,\n\t\t\t\thasPolicy: [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"@id\": \"urn:policy:test-offer-read-consignment\",\n\t\t\t\t\t\t\"@type\": \"Offer\",\n\t\t\t\t\t\tassigner: organizationId,\n\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\taction: \"read\"\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\tdistribution: {\n\t\t\t\t\t\"@id\": \"https://twin.example.org/distribution-1\",\n\t\t\t\t\t\"@type\": \"Distribution\",\n\t\t\t\t\taccessService: \"https://twin.example.org/data-service-1\",\n\t\t\t\t\tformat: \"Http-Pull-Query-Format\"\n\t\t\t\t},\n\t\t\t\t\"dcterms:type\": \"https://vocabulary.uncefact.org/Consignment\"\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 [{ objectType: \"https://vocabulary.uncefact.org/Consignment\" }];\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.entityType === \"https://vocabulary.uncefact.org/Consignment\") {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdata: [entities[0]]\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tif (dataRequest.entitySet.entityId?.includes(id)) {\n\t\t\t\t\treturn {\n\t\t\t\t\t\tdata: entities[0]\n\t\t\t\t\t};\n\t\t\t\t}\n\t\t\t\treturn { data: [] };\n\t\t\t}\n\n\t\t\tcase DataRequestType.QueryDataAsset:\n\t\t\t\treturn { data: entities };\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,OAA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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} from \"@twin.org/dataspace-models\";\nimport type { ILoggingComponent } from \"@twin.org/logging-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDataspaceProtocolContexts,\n\ttype IDataspaceProtocolDataset\n} from \"@twin.org/standards-dataspace-protocol\";\nimport { DublinCoreContexts } from \"@twin.org/standards-dublin-core\";\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>(\n\t\t\toptions?.loggingComponentType ?? \"logging\"\n\t\t);\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 * Datasets handled by the App.\n\t * @returns Dataspace Protocol compliant datasets\n\t */\n\tpublic async datasetsHandled(): Promise<IDataspaceProtocolDataset[]> {\n\t\tconst contextIds = await ContextIdStore.getContextIds();\n\t\tconst organizationId =\n\t\t\tcontextIds?.[ContextIdKeys.Organization] ?? contextIds?.[ContextIdKeys.Node] ?? \"\";\n\t\treturn [\n\t\t\t{\n\t\t\t\t\"@context\": [\n\t\t\t\t\tDataspaceProtocolContexts.Context,\n\t\t\t\t\t{\n\t\t\t\t\t\tdcterms: DublinCoreContexts.NamespaceTerms\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"@id\": \"https://twin.example.org/data-service-1\",\n\t\t\t\t\"@type\": \"Dataset\",\n\t\t\t\t\"dcterms:publisher\": organizationId,\n\t\t\t\thasPolicy: [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"@id\": \"urn:policy:test-offer-read-consignment\",\n\t\t\t\t\t\t\"@type\": \"Offer\",\n\t\t\t\t\t\tassigner: organizationId,\n\t\t\t\t\t\tpermission: [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\taction: \"read\"\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\tdistribution: [\n\t\t\t\t\t{\n\t\t\t\t\t\t\"@id\": \"https://twin.example.org/distribution-1\",\n\t\t\t\t\t\t\"@type\": \"Distribution\",\n\t\t\t\t\t\taccessService: \"https://twin.example.org/data-service-1\",\n\t\t\t\t\t\tformat: \"Http-Pull-Query-Format\"\n\t\t\t\t\t}\n\t\t\t\t],\n\t\t\t\t\"dcterms:type\": \"https://vocabulary.uncefact.org/Consignment\"\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 [{ objectType: \"https://vocabulary.uncefact.org/Consignment\" }];\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,3 +1,4 @@
1
+ import type { IJsonLdDocument } from "@twin.org/data-json-ld";
1
2
  /**
2
3
  * Test App Constructor options.
3
4
  */
@@ -7,4 +8,10 @@ export interface ITestAppConstructorOptions {
7
8
  * @default logging
8
9
  */
9
10
  loggingComponentType?: string;
11
+ /**
12
+ * List of consignment documents to serve.
13
+ * Can be loaded from a JSON file via the `@json:` env var syntax.
14
+ * Falls back to built-in default consignments if not provided.
15
+ */
16
+ consignments?: IJsonLdDocument[];
10
17
  }
@@ -9,7 +9,7 @@ import type { ITestAppConstructorOptions } from "./ITestAppConstructorOptions.js
9
9
  * @param nodeEngineConfig The node engine config.
10
10
  */
11
11
  export declare function extensionInitialise(envVars: {
12
- [id: string]: string;
12
+ [id: string]: string | unknown;
13
13
  }, nodeEngineConfig: IEngineCoreConfig): Promise<void>;
14
14
  /**
15
15
  * Initialise the engine for the extension.
package/docs/changelog.md CHANGED
@@ -1,5 +1,33 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.23](https://github.com/twinfoundation/dataspace/compare/dataspace-test-app-v0.0.3-next.22...dataspace-test-app-v0.0.3-next.23) (2026-03-25)
4
+
5
+
6
+ ### Features
7
+
8
+ * extend test app with multi-consignment data using UNECE vocabulary ([#92](https://github.com/twinfoundation/dataspace/issues/92)) ([2f69566](https://github.com/twinfoundation/dataspace/commit/2f695668ec03e50c89ddb1437f2be39c047e3268))
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.22 to 0.0.3-next.23
16
+
17
+ ## [0.0.3-next.22](https://github.com/twinfoundation/dataspace/compare/dataspace-test-app-v0.0.3-next.21...dataspace-test-app-v0.0.3-next.22) (2026-03-20)
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.21 to 0.0.3-next.22
30
+
3
31
  ## [0.0.3-next.21](https://github.com/twinfoundation/dataspace/compare/dataspace-test-app-v0.0.3-next.20...dataspace-test-app-v0.0.3-next.21) (2026-03-17)
4
32
 
5
33
 
@@ -6,6 +6,22 @@ Test App Constructor options.
6
6
 
7
7
  ### loggingComponentType? {#loggingcomponenttype}
8
8
 
9
- > `optional` **loggingComponentType**: `string`
9
+ > `optional` **loggingComponentType?**: `string`
10
10
 
11
11
  Logging component type.
12
+
13
+ #### Default
14
+
15
+ ```ts
16
+ logging
17
+ ```
18
+
19
+ ***
20
+
21
+ ### consignments? {#consignments}
22
+
23
+ > `optional` **consignments?**: `IJsonLdDocument`[]
24
+
25
+ List of consignment documents to serve.
26
+ Can be loaded from a JSON file via the `@json:` env var syntax.
27
+ Falls back to built-in default consignments if not provided.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/dataspace-test-app",
3
- "version": "0.0.3-next.21",
3
+ "version": "0.0.3-next.23",
4
4
  "description": "Provides a sample dataspace app for local integration tests and development workflows.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,7 +18,8 @@
18
18
  "@twin.org/context": "next",
19
19
  "@twin.org/core": "next",
20
20
  "@twin.org/data-core": "next",
21
- "@twin.org/dataspace-models": "0.0.3-next.21",
21
+ "@twin.org/data-json-ld": "next",
22
+ "@twin.org/dataspace-models": "0.0.3-next.23",
22
23
  "@twin.org/engine-models": "next",
23
24
  "@twin.org/engine-types": "next",
24
25
  "@twin.org/logging-models": "next",