@twin.org/federated-catalogue-service 0.0.3-next.13 → 0.0.3-next.14

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,7 +1,7 @@
1
1
  import { Coerce, ComponentFactory, Guards, Is } from "@twin.org/core";
2
2
  import { DataspaceProtocolCatalogTypes, DataspaceProtocolContexts } from "@twin.org/standards-dataspace-protocol";
3
3
  import { DcatClasses } from "@twin.org/standards-w3c-dcat";
4
- import { PolicyType } from "@twin.org/standards-w3c-odrl";
4
+ import { OdrlPolicyType } from "@twin.org/standards-w3c-odrl";
5
5
  import { HeaderHelper, HeaderTypes, HttpStatusCode } from "@twin.org/web";
6
6
  import { transformErrorToStatusCode, transformToCatalogError } from "./utils/catalogErrorUtils.js";
7
7
  /**
@@ -77,21 +77,25 @@ export function generateRestRoutesFederatedCatalogue(baseRouteName, componentNam
77
77
  "@type": "Dataset",
78
78
  "dcterms:title": "Energy Consumption Data",
79
79
  "dcterms:description": "Historical energy consumption data",
80
- hasPolicy: {
81
- "@id": "urn:uuid:policy-456",
82
- "@type": PolicyType.Offer,
83
- assigner: "did:example:data-provider-789"
84
- },
85
- distribution: {
86
- "@id": "urn:uuid:distribution-789",
87
- "@type": "Distribution",
88
- format: "application/json",
89
- accessService: {
90
- "@id": "urn:uuid:access-service-321",
91
- "@type": "DataService",
92
- endpointURL: "https://example.com/data-access"
80
+ hasPolicy: [
81
+ {
82
+ "@id": "urn:uuid:policy-456",
83
+ "@type": OdrlPolicyType.Offer,
84
+ assigner: "did:example:data-provider-789"
93
85
  }
94
- }
86
+ ],
87
+ distribution: [
88
+ {
89
+ "@id": "urn:uuid:distribution-789",
90
+ "@type": "Distribution",
91
+ format: "application/json",
92
+ accessService: {
93
+ "@id": "urn:uuid:access-service-321",
94
+ "@type": "DataService",
95
+ endpointURL: "https://example.com/data-access"
96
+ }
97
+ }
98
+ ]
95
99
  }
96
100
  ]
97
101
  }
@@ -1 +1 @@
1
-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C,WAAW,CACjB,aAAa,kCAEb,OAAO,CAAC,UAAU,CAAC,SAAS,CAC5B,CAAC;QAEF,MAAM,SAAS,GAAiC,gBAAgB,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAEpF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,GAAG,CAAC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;QAEjE,OAAO;YACN,UAAU,EAAE,0BAA0B,CAAC,MAAM,CAAC;YAC9C,IAAI,EAAE,MAAM;SACZ,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QAChB,MAAM,YAAY,GAAG,uBAAuB,CAAC,KAAK,CAAC,CAAC;QACpD,OAAO;YACN,UAAU,EAAE,0BAA0B,CAAC,YAAY,CAAC,IAAI,cAAc,CAAC,UAAU;YACjF,IAAI,EAAE,YAAY;SAClB,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIHostingComponent,\n\tIHttpRequestContext,\n\tIRestRoute,\n\tITag\n} from \"@twin.org/api-models\";\nimport { Coerce, ComponentFactory, Guards, Is } from \"@twin.org/core\";\nimport type {\n\tICatalogRequestRequest,\n\tICatalogRequestResponse,\n\tIFederatedCatalogueComponent,\n\tIGetDatasetRequest,\n\tIGetDatasetResponse\n} from \"@twin.org/federated-catalogue-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDataspaceProtocolCatalogTypes,\n\tDataspaceProtocolContexts\n} from \"@twin.org/standards-dataspace-protocol\";\nimport { DcatClasses, type DcatContextType } from \"@twin.org/standards-w3c-dcat\";\nimport { PolicyType } from \"@twin.org/standards-w3c-odrl\";\nimport { HeaderHelper, HeaderTypes, HttpStatusCode } from \"@twin.org/web\";\nimport { transformErrorToStatusCode, transformToCatalogError } from \"./utils/catalogErrorUtils.js\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"federatedCatalogueRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsFederatedCatalogue: ITag[] = [\n\t{\n\t\tname: \"Federated Catalogue\",\n\t\tdescription:\n\t\t\t\"Service providing Dataspace Protocol-compliant catalogue endpoints for dataset discovery and query.\"\n\t}\n];\n\n/**\n * The REST routes for federated catalogue.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesFederatedCatalogue(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst catalogRequestRoute: IRestRoute<ICatalogRequestRequest, ICatalogRequestResponse> = {\n\t\toperationId: \"catalogRequest\",\n\t\tsummary: \"Query the federated catalogue for datasets\",\n\t\ttag: tagsFederatedCatalogue[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/request`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tcatalogRequest(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<ICatalogRequestRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"catalogRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\t\t\t\"@type\": DataspaceProtocolCatalogTypes.CatalogRequestMessage,\n\t\t\t\t\t\t\tfilter: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"dcterms:title\": \"Energy Consumption Data\"\n\t\t\t\t\t\t\t\t}\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\t{\n\t\t\t\t\tid: \"catalogRequestNoFilterExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\t\t\t\"@type\": DataspaceProtocolCatalogTypes.CatalogRequestMessage\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ICatalogRequestResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"catalogRequestResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\t\t\t\t\"@id\":\n\t\t\t\t\t\t\t\t\t\"urn:x-catalog:a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2\",\n\t\t\t\t\t\t\t\t\"@type\": \"Catalog\",\n\t\t\t\t\t\t\t\tparticipantId: \"did:example:node-identity-123\",\n\t\t\t\t\t\t\t\tdataset: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"@id\": \"urn:uuid:dataset-123\",\n\t\t\t\t\t\t\t\t\t\t\"@type\": \"Dataset\",\n\t\t\t\t\t\t\t\t\t\t\"dcterms:title\": \"Energy Consumption Data\",\n\t\t\t\t\t\t\t\t\t\t\"dcterms:description\": \"Historical energy consumption data\",\n\t\t\t\t\t\t\t\t\t\thasPolicy: {\n\t\t\t\t\t\t\t\t\t\t\t\"@id\": \"urn:uuid:policy-456\",\n\t\t\t\t\t\t\t\t\t\t\t\"@type\": PolicyType.Offer,\n\t\t\t\t\t\t\t\t\t\t\tassigner: \"did:example:data-provider-789\"\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\tdistribution: {\n\t\t\t\t\t\t\t\t\t\t\t\"@id\": \"urn:uuid:distribution-789\",\n\t\t\t\t\t\t\t\t\t\t\t\"@type\": \"Distribution\",\n\t\t\t\t\t\t\t\t\t\t\tformat: \"application/json\",\n\t\t\t\t\t\t\t\t\t\t\taccessService: {\n\t\t\t\t\t\t\t\t\t\t\t\t\"@id\": \"urn:uuid:access-service-321\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"@type\": \"DataService\",\n\t\t\t\t\t\t\t\t\t\t\t\tendpointURL: \"https://example.com/data-access\"\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst getDatasetRoute: IRestRoute<IGetDatasetRequest, IGetDatasetResponse> = {\n\t\toperationId: \"getDataset\",\n\t\tsummary: \"Retrieve a specific dataset by ID\",\n\t\ttag: tagsFederatedCatalogue[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/datasets/:datasetId`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tgetDataset(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IGetDatasetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"getDatasetRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tdatasetId: \"urn:uuid:dataset-123\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IGetDatasetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"getDatasetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": DataspaceProtocolContexts.Context as unknown as DcatContextType,\n\t\t\t\t\t\t\t\t\"@id\": \"urn:uuid:dataset-123\",\n\t\t\t\t\t\t\t\t\"@type\": DcatClasses.Dataset,\n\t\t\t\t\t\t\t\t\"dcterms:title\": \"Energy Consumption Data\",\n\t\t\t\t\t\t\t\t\"dcterms:description\": \"Historical energy consumption data\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [catalogRequestRoute, getDatasetRoute];\n}\n\n/**\n * Handle the catalog request operation.\n * @param httpRequestContext The request context for the operation.\n * @param componentName The name of the component to use.\n * @param request The request.\n * @returns The response.\n */\nasync function catalogRequest(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ICatalogRequestRequest\n): Promise<ICatalogRequestResponse> {\n\ttry {\n\t\tGuards.object<ICatalogRequestRequest>(ROUTES_SOURCE, nameof(request), request);\n\t\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\t\tGuards.stringValue(ROUTES_SOURCE, \"@type\", request.body[\"@type\"]);\n\n\t\tconst hostingComponent = ComponentFactory.get<IHostingComponent>(\n\t\t\thttpRequestContext.hostingComponentType ?? \"hosting\"\n\t\t);\n\n\t\tconst component: IFederatedCatalogueComponent = ComponentFactory.get(componentName);\n\n\t\tconst result = await component.query(\n\t\t\trequest.body.filter,\n\t\t\trequest.query?.cursor,\n\t\t\tCoerce.integer(request.query?.limit)\n\t\t);\n\n\t\tconst headers: ICatalogRequestResponse[\"headers\"] = {};\n\n\t\tif (Is.stringValue(result.cursor)) {\n\t\t\theaders[HeaderTypes.Link] = HeaderHelper.createLinkHeader(\n\t\t\t\tawait hostingComponent.buildPublicUrl(httpRequestContext.serverRequest.url),\n\t\t\t\t{ cursor: result.cursor },\n\t\t\t\t\"next\"\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\theaders,\n\t\t\tstatusCode: transformErrorToStatusCode(result.result),\n\t\t\tbody: result.result\n\t\t};\n\t} catch (error) {\n\t\tconst catalogError = transformToCatalogError(error);\n\t\treturn {\n\t\t\tstatusCode: transformErrorToStatusCode(catalogError) ?? HttpStatusCode.badRequest,\n\t\t\tbody: catalogError\n\t\t};\n\t}\n}\n\n/**\n * Handle the get dataset operation.\n * @param httpRequestContext The request context for the operation.\n * @param componentName The name of the component to use.\n * @param request The request.\n * @returns The response.\n */\nasync function getDataset(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IGetDatasetRequest\n): Promise<IGetDatasetResponse> {\n\ttry {\n\t\tGuards.object<IGetDatasetRequest>(ROUTES_SOURCE, nameof(request), request);\n\t\tGuards.object(ROUTES_SOURCE, nameof(request.pathParams), request.pathParams);\n\t\tGuards.stringValue(\n\t\t\tROUTES_SOURCE,\n\t\t\tnameof(request.pathParams.datasetId),\n\t\t\trequest.pathParams.datasetId\n\t\t);\n\n\t\tconst component: IFederatedCatalogueComponent = ComponentFactory.get(componentName);\n\n\t\tconst result = await component.get(request.pathParams.datasetId);\n\n\t\treturn {\n\t\t\tstatusCode: transformErrorToStatusCode(result),\n\t\t\tbody: result\n\t\t};\n\t} catch (error) {\n\t\tconst catalogError = transformToCatalogError(error);\n\t\treturn {\n\t\t\tstatusCode: transformErrorToStatusCode(catalogError) ?? HttpStatusCode.badRequest,\n\t\t\tbody: catalogError\n\t\t};\n\t}\n}\n"]}
1
+ {"version":3,"file":"federatedCatalogueRoutes.js","sourceRoot":"","sources":["../../src/federatedCatalogueRoutes.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,gBAAgB,CAAC;AAStE,OAAO,EACN,6BAA6B,EAC7B,yBAAyB,EACzB,MAAM,wCAAwC,CAAC;AAChD,OAAO,EAAE,WAAW,EAAwB,MAAM,8BAA8B,CAAC;AACjF,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC1E,OAAO,EAAE,0BAA0B,EAAE,uBAAuB,EAAE,MAAM,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,UAAU,EAAE,0BAA0B,CAAC,YAAY,CAAC,IAAI,cAAc,CAAC,UAAU;YACjF,IAAI,EAAE,YAAY;SAClB,CAAC;IACH,CAAC;AACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport type {\n\tIHostingComponent,\n\tIHttpRequestContext,\n\tIRestRoute,\n\tITag\n} from \"@twin.org/api-models\";\nimport { Coerce, ComponentFactory, Guards, Is } from \"@twin.org/core\";\nimport type {\n\tICatalogRequestRequest,\n\tICatalogRequestResponse,\n\tIFederatedCatalogueComponent,\n\tIGetDatasetRequest,\n\tIGetDatasetResponse\n} from \"@twin.org/federated-catalogue-models\";\nimport { nameof } from \"@twin.org/nameof\";\nimport {\n\tDataspaceProtocolCatalogTypes,\n\tDataspaceProtocolContexts\n} from \"@twin.org/standards-dataspace-protocol\";\nimport { DcatClasses, type DcatContextType } from \"@twin.org/standards-w3c-dcat\";\nimport { OdrlPolicyType } from \"@twin.org/standards-w3c-odrl\";\nimport { HeaderHelper, HeaderTypes, HttpStatusCode } from \"@twin.org/web\";\nimport { transformErrorToStatusCode, transformToCatalogError } from \"./utils/catalogErrorUtils.js\";\n\n/**\n * The source used when communicating about these routes.\n */\nconst ROUTES_SOURCE = \"federatedCatalogueRoutes\";\n\n/**\n * The tag to associate with the routes.\n */\nexport const tagsFederatedCatalogue: ITag[] = [\n\t{\n\t\tname: \"Federated Catalogue\",\n\t\tdescription:\n\t\t\t\"Service providing Dataspace Protocol-compliant catalogue endpoints for dataset discovery and query.\"\n\t}\n];\n\n/**\n * The REST routes for federated catalogue.\n * @param baseRouteName Prefix to prepend to the paths.\n * @param componentName The name of the component to use in the routes stored in the ComponentFactory.\n * @returns The generated routes.\n */\nexport function generateRestRoutesFederatedCatalogue(\n\tbaseRouteName: string,\n\tcomponentName: string\n): IRestRoute[] {\n\tconst catalogRequestRoute: IRestRoute<ICatalogRequestRequest, ICatalogRequestResponse> = {\n\t\toperationId: \"catalogRequest\",\n\t\tsummary: \"Query the federated catalogue for datasets\",\n\t\ttag: tagsFederatedCatalogue[0].name,\n\t\tmethod: \"POST\",\n\t\tpath: `${baseRouteName}/request`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tcatalogRequest(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<ICatalogRequestRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"catalogRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\t\t\t\"@type\": DataspaceProtocolCatalogTypes.CatalogRequestMessage,\n\t\t\t\t\t\t\tfilter: [\n\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\"dcterms:title\": \"Energy Consumption Data\"\n\t\t\t\t\t\t\t\t}\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\t{\n\t\t\t\t\tid: \"catalogRequestNoFilterExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\t\t\t\"@type\": DataspaceProtocolCatalogTypes.CatalogRequestMessage\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<ICatalogRequestResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"catalogRequestResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": [DataspaceProtocolContexts.Context],\n\t\t\t\t\t\t\t\t\"@id\":\n\t\t\t\t\t\t\t\t\t\"urn:x-catalog:a1b2c3d4e5f6g7h8i9j0k1l2m3n4o5p6q7r8s9t0u1v2w3x4y5z6a7b8c9d0e1f2\",\n\t\t\t\t\t\t\t\t\"@type\": \"Catalog\",\n\t\t\t\t\t\t\t\tparticipantId: \"did:example:node-identity-123\",\n\t\t\t\t\t\t\t\tdataset: [\n\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\"@id\": \"urn:uuid:dataset-123\",\n\t\t\t\t\t\t\t\t\t\t\"@type\": \"Dataset\",\n\t\t\t\t\t\t\t\t\t\t\"dcterms:title\": \"Energy Consumption Data\",\n\t\t\t\t\t\t\t\t\t\t\"dcterms:description\": \"Historical energy consumption data\",\n\t\t\t\t\t\t\t\t\t\thasPolicy: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\"@id\": \"urn:uuid:policy-456\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"@type\": OdrlPolicyType.Offer,\n\t\t\t\t\t\t\t\t\t\t\t\tassigner: \"did:example:data-provider-789\"\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t],\n\t\t\t\t\t\t\t\t\t\tdistribution: [\n\t\t\t\t\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\t\t\t\t\t\"@id\": \"urn:uuid:distribution-789\",\n\t\t\t\t\t\t\t\t\t\t\t\t\"@type\": \"Distribution\",\n\t\t\t\t\t\t\t\t\t\t\t\tformat: \"application/json\",\n\t\t\t\t\t\t\t\t\t\t\t\taccessService: {\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"@id\": \"urn:uuid:access-service-321\",\n\t\t\t\t\t\t\t\t\t\t\t\t\t\"@type\": \"DataService\",\n\t\t\t\t\t\t\t\t\t\t\t\t\tendpointURL: \"https://example.com/data-access\"\n\t\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t]\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\tconst getDatasetRoute: IRestRoute<IGetDatasetRequest, IGetDatasetResponse> = {\n\t\toperationId: \"getDataset\",\n\t\tsummary: \"Retrieve a specific dataset by ID\",\n\t\ttag: tagsFederatedCatalogue[0].name,\n\t\tmethod: \"GET\",\n\t\tpath: `${baseRouteName}/datasets/:datasetId`,\n\t\thandler: async (httpRequestContext, request) =>\n\t\t\tgetDataset(httpRequestContext, componentName, request),\n\t\trequestType: {\n\t\t\ttype: nameof<IGetDatasetRequest>(),\n\t\t\texamples: [\n\t\t\t\t{\n\t\t\t\t\tid: \"getDatasetRequestExample\",\n\t\t\t\t\trequest: {\n\t\t\t\t\t\tpathParams: {\n\t\t\t\t\t\t\tdatasetId: \"urn:uuid:dataset-123\"\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t]\n\t\t},\n\t\tresponseType: [\n\t\t\t{\n\t\t\t\ttype: nameof<IGetDatasetResponse>(),\n\t\t\t\texamples: [\n\t\t\t\t\t{\n\t\t\t\t\t\tid: \"getDatasetResponseExample\",\n\t\t\t\t\t\tresponse: {\n\t\t\t\t\t\t\tbody: {\n\t\t\t\t\t\t\t\t\"@context\": DataspaceProtocolContexts.Context as unknown as DcatContextType,\n\t\t\t\t\t\t\t\t\"@id\": \"urn:uuid:dataset-123\",\n\t\t\t\t\t\t\t\t\"@type\": DcatClasses.Dataset,\n\t\t\t\t\t\t\t\t\"dcterms:title\": \"Energy Consumption Data\",\n\t\t\t\t\t\t\t\t\"dcterms:description\": \"Historical energy consumption data\"\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t]\n\t\t\t}\n\t\t]\n\t};\n\n\treturn [catalogRequestRoute, getDatasetRoute];\n}\n\n/**\n * Handle the catalog request operation.\n * @param httpRequestContext The request context for the operation.\n * @param componentName The name of the component to use.\n * @param request The request.\n * @returns The response.\n */\nasync function catalogRequest(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: ICatalogRequestRequest\n): Promise<ICatalogRequestResponse> {\n\ttry {\n\t\tGuards.object<ICatalogRequestRequest>(ROUTES_SOURCE, nameof(request), request);\n\t\tGuards.object(ROUTES_SOURCE, nameof(request.body), request.body);\n\t\tGuards.stringValue(ROUTES_SOURCE, \"@type\", request.body[\"@type\"]);\n\n\t\tconst hostingComponent = ComponentFactory.get<IHostingComponent>(\n\t\t\thttpRequestContext.hostingComponentType ?? \"hosting\"\n\t\t);\n\n\t\tconst component: IFederatedCatalogueComponent = ComponentFactory.get(componentName);\n\n\t\tconst result = await component.query(\n\t\t\trequest.body.filter,\n\t\t\trequest.query?.cursor,\n\t\t\tCoerce.integer(request.query?.limit)\n\t\t);\n\n\t\tconst headers: ICatalogRequestResponse[\"headers\"] = {};\n\n\t\tif (Is.stringValue(result.cursor)) {\n\t\t\theaders[HeaderTypes.Link] = HeaderHelper.createLinkHeader(\n\t\t\t\tawait hostingComponent.buildPublicUrl(httpRequestContext.serverRequest.url),\n\t\t\t\t{ cursor: result.cursor },\n\t\t\t\t\"next\"\n\t\t\t);\n\t\t}\n\n\t\treturn {\n\t\t\theaders,\n\t\t\tstatusCode: transformErrorToStatusCode(result.result),\n\t\t\tbody: result.result\n\t\t};\n\t} catch (error) {\n\t\tconst catalogError = transformToCatalogError(error);\n\t\treturn {\n\t\t\tstatusCode: transformErrorToStatusCode(catalogError) ?? HttpStatusCode.badRequest,\n\t\t\tbody: catalogError\n\t\t};\n\t}\n}\n\n/**\n * Handle the get dataset operation.\n * @param httpRequestContext The request context for the operation.\n * @param componentName The name of the component to use.\n * @param request The request.\n * @returns The response.\n */\nasync function getDataset(\n\thttpRequestContext: IHttpRequestContext,\n\tcomponentName: string,\n\trequest: IGetDatasetRequest\n): Promise<IGetDatasetResponse> {\n\ttry {\n\t\tGuards.object<IGetDatasetRequest>(ROUTES_SOURCE, nameof(request), request);\n\t\tGuards.object(ROUTES_SOURCE, nameof(request.pathParams), request.pathParams);\n\t\tGuards.stringValue(\n\t\t\tROUTES_SOURCE,\n\t\t\tnameof(request.pathParams.datasetId),\n\t\t\trequest.pathParams.datasetId\n\t\t);\n\n\t\tconst component: IFederatedCatalogueComponent = ComponentFactory.get(componentName);\n\n\t\tconst result = await component.get(request.pathParams.datasetId);\n\n\t\treturn {\n\t\t\tstatusCode: transformErrorToStatusCode(result),\n\t\t\tbody: result\n\t\t};\n\t} catch (error) {\n\t\tconst catalogError = transformToCatalogError(error);\n\t\treturn {\n\t\t\tstatusCode: transformErrorToStatusCode(catalogError) ?? HttpStatusCode.badRequest,\n\t\t\tbody: catalogError\n\t\t};\n\t}\n}\n"]}
package/docs/changelog.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-next.14](https://github.com/twinfoundation/federated-catalogue/compare/federated-catalogue-service-v0.0.3-next.13...federated-catalogue-service-v0.0.3-next.14) (2026-03-20)
4
+
5
+
6
+ ### Features
7
+
8
+ * update to use new schemas ([41dae8d](https://github.com/twinfoundation/federated-catalogue/commit/41dae8d401dcea830b435aa35590e9c90a11eb1f))
9
+
10
+
11
+ ### Dependencies
12
+
13
+ * The following workspace dependencies were updated
14
+ * dependencies
15
+ * @twin.org/federated-catalogue-models bumped from 0.0.3-next.13 to 0.0.3-next.14
16
+
3
17
  ## [0.0.3-next.13](https://github.com/twinfoundation/federated-catalogue/compare/federated-catalogue-service-v0.0.3-next.12...federated-catalogue-service-v0.0.3-next.13) (2026-03-12)
4
18
 
5
19
 
@@ -89,7 +89,7 @@
89
89
  },
90
90
  "responses": {
91
91
  "200": {
92
- "description": "The response payload for the catalog request method. Returns a DS Protocol compliant Catalog with participantId, or CatalogError if no datasets found.",
92
+ "description": "The response payload for the catalog request method.\nReturns a DS Protocol compliant Catalog with participantId, or CatalogError if no datasets found.",
93
93
  "content": {
94
94
  "application/json": {
95
95
  "schema": {
@@ -110,21 +110,25 @@
110
110
  "@type": "Dataset",
111
111
  "dcterms:title": "Energy Consumption Data",
112
112
  "dcterms:description": "Historical energy consumption data",
113
- "hasPolicy": {
114
- "@id": "urn:uuid:policy-456",
115
- "@type": "Offer",
116
- "assigner": "did:example:data-provider-789"
117
- },
118
- "distribution": {
119
- "@id": "urn:uuid:distribution-789",
120
- "@type": "Distribution",
121
- "format": "application/json",
122
- "accessService": {
123
- "@id": "urn:uuid:access-service-321",
124
- "@type": "DataService",
125
- "endpointURL": "https://example.com/data-access"
113
+ "hasPolicy": [
114
+ {
115
+ "@id": "urn:uuid:policy-456",
116
+ "@type": "Offer",
117
+ "assigner": "did:example:data-provider-789"
126
118
  }
127
- }
119
+ ],
120
+ "distribution": [
121
+ {
122
+ "@id": "urn:uuid:distribution-789",
123
+ "@type": "Distribution",
124
+ "format": "application/json",
125
+ "accessService": {
126
+ "@id": "urn:uuid:access-service-321",
127
+ "@type": "DataService",
128
+ "endpointURL": "https://example.com/data-access"
129
+ }
130
+ }
131
+ ]
128
132
  }
129
133
  ]
130
134
  }
@@ -312,9 +316,10 @@
312
316
  "$ref": "https://schema.twindev.org/dataspace-protocol/DataspaceProtocolCatalogError"
313
317
  }
314
318
  ],
315
- "description": "The response payload containing the DS Protocol compliant catalog with participantId, or a CatalogError if no datasets are found (404). Per DS Protocol: Single participant returns flat catalog, multiple participants return nested catalogs."
319
+ "description": "The response payload containing the DS Protocol compliant catalog with participantId,\nor a CatalogError if no datasets are found (404).\nPer DS Protocol: Single participant returns flat catalog, multiple participants return nested catalogs."
316
320
  },
317
321
  "Error": {
322
+ "description": "Model to describe serialized error.",
318
323
  "type": "object",
319
324
  "properties": {
320
325
  "name": {
@@ -345,8 +350,7 @@
345
350
  "required": [
346
351
  "name",
347
352
  "message"
348
- ],
349
- "description": "Model to describe serialized error."
353
+ ]
350
354
  },
351
355
  "GetDatasetResponse": {
352
356
  "anyOf": [
@@ -16,7 +16,7 @@ the full IDcatDataset JSON-LD structure.
16
16
 
17
17
  ## Properties
18
18
 
19
- ### id
19
+ ### id {#id}
20
20
 
21
21
  > **id**: `string`
22
22
 
@@ -24,7 +24,7 @@ The unique identifier for the dataset (mapped from JSON-LD identifier).
24
24
 
25
25
  ***
26
26
 
27
- ### nodeIdentity
27
+ ### nodeIdentity {#nodeidentity}
28
28
 
29
29
  > **nodeIdentity**: `string`
30
30
 
@@ -32,7 +32,7 @@ The identity of the node that owns this entity (required for sync).
32
32
 
33
33
  ***
34
34
 
35
- ### dateModified
35
+ ### dateModified {#datemodified}
36
36
 
37
37
  > **dateModified**: `string`
38
38
 
@@ -40,7 +40,7 @@ The date the entity was last modified (required for sync).
40
40
 
41
41
  ***
42
42
 
43
- ### @context
43
+ ### @context {#context}
44
44
 
45
45
  > **@context**: `DcatContextType`
46
46
 
@@ -48,7 +48,7 @@ The JSON-LD context for the dataset.
48
48
 
49
49
  ***
50
50
 
51
- ### @type
51
+ ### @type {#type}
52
52
 
53
53
  > **@type**: `"dcat:Dataset"` \| `"dcat:Catalog"` \| `"dcat:DatasetSeries"`
54
54
 
@@ -56,216 +56,216 @@ The type of the resource (typically "Dataset").
56
56
 
57
57
  ***
58
58
 
59
- ### dcterms:title?
59
+ ### dcterms:title? {#dctermstitle}
60
60
 
61
- > `optional` **dcterms:title**: `DcatLiteralType`
61
+ > `optional` **dcterms:title?**: `ObjectOrArray`\<`string`\>
62
62
 
63
63
  A name given to the resource.
64
64
 
65
65
  ***
66
66
 
67
- ### dcterms:description?
67
+ ### dcterms:description? {#dctermsdescription}
68
68
 
69
- > `optional` **dcterms:description**: `DcatLiteralType`
69
+ > `optional` **dcterms:description?**: `ObjectOrArray`\<`string`\>
70
70
 
71
71
  A free-text account of the resource.
72
72
 
73
73
  ***
74
74
 
75
- ### dcterms:identifier?
75
+ ### dcterms:identifier? {#dctermsidentifier}
76
76
 
77
- > `optional` **dcterms:identifier**: `DcatLiteralType`
77
+ > `optional` **dcterms:identifier?**: `ObjectOrArray`\<`string`\>
78
78
 
79
79
  A unique identifier of the resource.
80
80
 
81
81
  ***
82
82
 
83
- ### dcterms:issued?
83
+ ### dcterms:issued? {#dctermsissued}
84
84
 
85
- > `optional` **dcterms:issued**: `string`
85
+ > `optional` **dcterms:issued?**: `string`
86
86
 
87
87
  Date of formal issuance (publication) of the resource.
88
88
 
89
89
  ***
90
90
 
91
- ### dcterms:modified?
91
+ ### dcterms:modified? {#dctermsmodified}
92
92
 
93
- > `optional` **dcterms:modified**: `string`
93
+ > `optional` **dcterms:modified?**: `string`
94
94
 
95
95
  Most recent date on which the resource was changed, updated or modified.
96
96
 
97
97
  ***
98
98
 
99
- ### dcterms:language?
99
+ ### dcterms:language? {#dctermslanguage}
100
100
 
101
- > `optional` **dcterms:language**: `string` \| `string`[]
101
+ > `optional` **dcterms:language?**: `ObjectOrArray`\<`string`\>
102
102
 
103
103
  A language of the resource.
104
104
 
105
105
  ***
106
106
 
107
- ### dcterms:publisher?
107
+ ### dcterms:publisher? {#dctermspublisher}
108
108
 
109
- > `optional` **dcterms:publisher**: `string` \| `IFoafAgentWithAliases`
109
+ > `optional` **dcterms:publisher?**: `string` \| `IFoafAgentWithAliases`
110
110
 
111
111
  An entity responsible for making the resource available.
112
112
 
113
113
  ***
114
114
 
115
- ### dcterms:creator?
115
+ ### dcterms:creator? {#dctermscreator}
116
116
 
117
- > `optional` **dcterms:creator**: `string` \| `IFoafAgentWithAliases`
117
+ > `optional` **dcterms:creator?**: `string` \| `IFoafAgentWithAliases`
118
118
 
119
119
  An entity responsible for producing the resource.
120
120
 
121
121
  ***
122
122
 
123
- ### dcterms:accessRights?
123
+ ### dcterms:accessRights? {#dctermsaccessrights}
124
124
 
125
- > `optional` **dcterms:accessRights**: `string` \| `IJsonLdNodeObject`
125
+ > `optional` **dcterms:accessRights?**: `string` \| `IJsonLdNodeObject`
126
126
 
127
127
  Information about who can access the resource or an indication of its security status.
128
128
 
129
129
  ***
130
130
 
131
- ### dcterms:license?
131
+ ### dcterms:license? {#dctermslicense}
132
132
 
133
- > `optional` **dcterms:license**: `string` \| `IJsonLdNodeObject`
133
+ > `optional` **dcterms:license?**: `string` \| `IJsonLdNodeObject`
134
134
 
135
135
  A legal document under which the resource is made available.
136
136
 
137
137
  ***
138
138
 
139
- ### dcterms:rights?
139
+ ### dcterms:rights? {#dctermsrights}
140
140
 
141
- > `optional` **dcterms:rights**: `string` \| `IJsonLdNodeObject`
141
+ > `optional` **dcterms:rights?**: `string` \| `IJsonLdNodeObject`
142
142
 
143
143
  Information about rights held in and over the resource.
144
144
 
145
145
  ***
146
146
 
147
- ### dcterms:conformsTo?
147
+ ### dcterms:conformsTo? {#dctermsconformsto}
148
148
 
149
- > `optional` **dcterms:conformsTo**: `string` \| `string`[]
149
+ > `optional` **dcterms:conformsTo?**: `ObjectOrArray`\<`string`\>
150
150
 
151
151
  An established standard to which the resource conforms.
152
152
 
153
153
  ***
154
154
 
155
- ### dcterms:type?
155
+ ### dcterms:type? {#dctermstype}
156
156
 
157
- > `optional` **dcterms:type**: `string`
157
+ > `optional` **dcterms:type?**: `string`
158
158
 
159
159
  The nature or genre of the resource.
160
160
 
161
161
  ***
162
162
 
163
- ### dcat:contactPoint?
163
+ ### dcat:contactPoint? {#dcatcontactpoint}
164
164
 
165
- > `optional` **dcat:contactPoint**: `string` \| `IJsonLdNodeObject`
165
+ > `optional` **dcat:contactPoint?**: `string` \| `IJsonLdNodeObject`
166
166
 
167
167
  Relevant contact information for the catalogued resource.
168
168
 
169
169
  ***
170
170
 
171
- ### dcat:keyword?
171
+ ### dcat:keyword? {#dcatkeyword}
172
172
 
173
- > `optional` **dcat:keyword**: `DcatLiteralType`
173
+ > `optional` **dcat:keyword?**: `ObjectOrArray`\<`string`\>
174
174
 
175
175
  A keyword or tag describing the resource.
176
176
 
177
177
  ***
178
178
 
179
- ### dcat:theme?
179
+ ### dcat:theme? {#dcattheme}
180
180
 
181
- > `optional` **dcat:theme**: `string` \| `string`[]
181
+ > `optional` **dcat:theme?**: `ObjectOrArray`\<`string`\>
182
182
 
183
183
  A main category of the resource. A resource can have multiple themes.
184
184
 
185
185
  ***
186
186
 
187
- ### dcat:landingPage?
187
+ ### dcat:landingPage? {#dcatlandingpage}
188
188
 
189
- > `optional` **dcat:landingPage**: `string` \| `string`[]
189
+ > `optional` **dcat:landingPage?**: `ObjectOrArray`\<`string`\>
190
190
 
191
191
  A Web page that can be navigated to gain access to the resource.
192
192
 
193
193
  ***
194
194
 
195
- ### dcat:qualifiedRelation?
195
+ ### dcat:qualifiedRelation? {#dcatqualifiedrelation}
196
196
 
197
- > `optional` **dcat:qualifiedRelation**: `string` \| `IDcatRelationship`
197
+ > `optional` **dcat:qualifiedRelation?**: `string` \| `IDcatRelationship`
198
198
 
199
199
  Link to a description of a relationship with another resource.
200
200
 
201
201
  ***
202
202
 
203
- ### odrl:hasPolicy?
203
+ ### odrl:hasPolicy? {#odrlhaspolicy}
204
204
 
205
- > `optional` **odrl:hasPolicy**: `IOdrlPolicy`
205
+ > `optional` **odrl:hasPolicy?**: `IOdrlPolicy`
206
206
 
207
207
  An ODRL conformant policy expressing the rights associated with the resource.
208
208
 
209
209
  ***
210
210
 
211
- ### dcat:distribution?
211
+ ### dcat:distribution? {#dcatdistribution}
212
212
 
213
- > `optional` **dcat:distribution**: `DistributionOptionalContext` \| `DistributionOptionalContext`[]
213
+ > `optional` **dcat:distribution?**: `ObjectOrArray`\<`IDcatDistributionBase`\>
214
214
 
215
215
  An available distribution of the dataset.
216
216
 
217
217
  ***
218
218
 
219
- ### dcterms:accrualPeriodicity?
219
+ ### dcterms:accrualPeriodicity? {#dctermsaccrualperiodicity}
220
220
 
221
- > `optional` **dcterms:accrualPeriodicity**: `string`
221
+ > `optional` **dcterms:accrualPeriodicity?**: `string`
222
222
 
223
223
  The frequency at which the dataset is published.
224
224
 
225
225
  ***
226
226
 
227
- ### dcat:inSeries?
227
+ ### dcat:inSeries? {#dcatinseries}
228
228
 
229
- > `optional` **dcat:inSeries**: `string`
229
+ > `optional` **dcat:inSeries?**: `string`
230
230
 
231
231
  A dataset series of which the dataset is part.
232
232
 
233
233
  ***
234
234
 
235
- ### dcterms:spatial?
235
+ ### dcterms:spatial? {#dctermsspatial}
236
236
 
237
- > `optional` **dcterms:spatial**: `string` \| `string`[] \| `IJsonLdNodeObject`
237
+ > `optional` **dcterms:spatial?**: `string` \| `string`[] \| `IJsonLdNodeObject`
238
238
 
239
239
  The geographical area covered by the dataset.
240
240
 
241
241
  ***
242
242
 
243
- ### dcat:spatialResolutionInMeters?
243
+ ### dcat:spatialResolutionInMeters? {#dcatspatialresolutioninmeters}
244
244
 
245
- > `optional` **dcat:spatialResolutionInMeters**: `number`
245
+ > `optional` **dcat:spatialResolutionInMeters?**: `number`
246
246
 
247
247
  Minimum spatial separation resolvable in a dataset, measured in meters.
248
248
 
249
249
  ***
250
250
 
251
- ### dcterms:temporal?
251
+ ### dcterms:temporal? {#dctermstemporal}
252
252
 
253
- > `optional` **dcterms:temporal**: `IDublinCorePeriodOfTime`
253
+ > `optional` **dcterms:temporal?**: `IDublinCorePeriodOfTime`
254
254
 
255
255
  The temporal period that the dataset covers.
256
256
 
257
257
  ***
258
258
 
259
- ### dcat:temporalResolution?
259
+ ### dcat:temporalResolution? {#dcattemporalresolution}
260
260
 
261
- > `optional` **dcat:temporalResolution**: `string`
261
+ > `optional` **dcat:temporalResolution?**: `string`
262
262
 
263
263
  Minimum time period resolvable in the dataset.
264
264
 
265
265
  ***
266
266
 
267
- ### prov:wasGeneratedBy?
267
+ ### prov:wasGeneratedBy? {#provwasgeneratedby}
268
268
 
269
- > `optional` **prov:wasGeneratedBy**: `string` \| `IJsonLdNodeObject`
269
+ > `optional` **prov:wasGeneratedBy?**: `string` \| `IJsonLdNodeObject`
270
270
 
271
271
  An activity that generated, or provides the business context for, the creation of the dataset.
@@ -29,7 +29,7 @@ The options for the service.
29
29
 
30
30
  ## Properties
31
31
 
32
- ### CLASS\_NAME
32
+ ### CLASS\_NAME {#class_name}
33
33
 
34
34
  > `readonly` `static` **CLASS\_NAME**: `string`
35
35
 
@@ -37,7 +37,7 @@ Runtime name for the class.
37
37
 
38
38
  ## Methods
39
39
 
40
- ### className()
40
+ ### className() {#classname}
41
41
 
42
42
  > **className**(): `string`
43
43
 
@@ -55,7 +55,7 @@ The class name of the component.
55
55
 
56
56
  ***
57
57
 
58
- ### start()
58
+ ### start() {#start}
59
59
 
60
60
  > **start**(): `Promise`\<`void`\>
61
61
 
@@ -73,7 +73,7 @@ Nothing.
73
73
 
74
74
  ***
75
75
 
76
- ### get()
76
+ ### get() {#get}
77
77
 
78
78
  > **get**(`dataSetId`): `Promise`\<`IDataspaceProtocolCatalogError` \| `IDcatDataset`\>
79
79
 
@@ -99,7 +99,7 @@ The dataset if found, or a CatalogError if not found or an error occurs.
99
99
 
100
100
  ***
101
101
 
102
- ### set()
102
+ ### set() {#set}
103
103
 
104
104
  > **set**(`dataSet`): `Promise`\<`void`\>
105
105
 
@@ -124,7 +124,7 @@ The dataset to store.
124
124
 
125
125
  ***
126
126
 
127
- ### query()
127
+ ### query() {#query}
128
128
 
129
129
  > **query**(`filter?`, `cursor?`, `limit?`): `Promise`\<\{ `result`: `IDataspaceProtocolCatalogError` \| `IDataspaceProtocolCatalog`; `cursor?`: `string`; \}\>
130
130
 
@@ -171,7 +171,7 @@ or CatalogError if validation fails or an error occurs.
171
171
 
172
172
  ***
173
173
 
174
- ### remove()
174
+ ### remove() {#remove}
175
175
 
176
176
  > **remove**(`dataSetId`): `Promise`\<`void`\>
177
177
 
@@ -9,9 +9,9 @@ Maps entity.id back to model["@id"] and strips sync-only fields.
9
9
 
10
10
  ### entity
11
11
 
12
- The dataset entity from storage (may be partial from query results).
12
+ [`Dataset`](../classes/Dataset.md) \| `Partial`\<[`Dataset`](../classes/Dataset.md)\>
13
13
 
14
- [`Dataset`](../classes/Dataset.md) | `Partial`\<[`Dataset`](../classes/Dataset.md)\>
14
+ The dataset entity from storage (may be partial from query results).
15
15
 
16
16
  ## Returns
17
17
 
@@ -4,16 +4,22 @@ Options for the FederatedCatalogueService constructor.
4
4
 
5
5
  ## Properties
6
6
 
7
- ### datasetEntityStorageType?
7
+ ### datasetEntityStorageType? {#datasetentitystoragetype}
8
8
 
9
- > `optional` **datasetEntityStorageType**: `string`
9
+ > `optional` **datasetEntityStorageType?**: `string`
10
10
 
11
11
  The entity storage for datasets.
12
12
 
13
+ #### Default
14
+
15
+ ```ts
16
+ dataset
17
+ ```
18
+
13
19
  ***
14
20
 
15
- ### loggingComponentType?
21
+ ### loggingComponentType? {#loggingcomponenttype}
16
22
 
17
- > `optional` **loggingComponentType**: `string`
23
+ > `optional` **loggingComponentType?**: `string`
18
24
 
19
25
  The logging component for the service.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twin.org/federated-catalogue-service",
3
- "version": "0.0.3-next.13",
3
+ "version": "0.0.3-next.14",
4
4
  "description": "Federated Catalogue contract implementation and REST endpoint definitions",
5
5
  "repository": {
6
6
  "type": "git",
@@ -20,7 +20,7 @@
20
20
  "@twin.org/data-json-ld": "next",
21
21
  "@twin.org/entity": "next",
22
22
  "@twin.org/entity-storage-models": "next",
23
- "@twin.org/federated-catalogue-models": "0.0.3-next.13",
23
+ "@twin.org/federated-catalogue-models": "0.0.3-next.14",
24
24
  "@twin.org/logging-models": "next",
25
25
  "@twin.org/nameof": "next",
26
26
  "@twin.org/standards-dataspace-protocol": "next",