@twin.org/dataspace-data-plane-socket-client 0.0.3-next.24 → 0.0.3-next.26
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/dataspaceDataPlaneSocketClient.js +1 -1
- package/dist/es/dataspaceDataPlaneSocketClient.js.map +1 -1
- package/dist/types/dataspaceDataPlaneSocketClient.d.ts +2 -2
- package/docs/changelog.md +28 -0
- package/docs/reference/classes/DataspaceDataPlaneSocketClient.md +3 -3
- package/package.json +2 -2
|
@@ -51,7 +51,7 @@ export class DataspaceDataPlaneSocketClient extends BaseSocketClient {
|
|
|
51
51
|
/**
|
|
52
52
|
* Notify an Activity to the Dataspace Activity Stream - implemented in REST Client.
|
|
53
53
|
* @param activity The Activity notified.
|
|
54
|
-
* @returns The
|
|
54
|
+
* @returns The activity's id or entry.
|
|
55
55
|
*/
|
|
56
56
|
async notifyActivity(activity) {
|
|
57
57
|
// This method is in the REST client
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dataspaceDataPlaneSocketClient.js","sourceRoot":"","sources":["../../src/dataspaceDataPlaneSocketClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EACN,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,MAAM,EAEN,EAAE,EACF,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAgBxB;;GAEG;AACH,MAAM,OAAO,8BACZ,SAAQ,gBAAgB;IAGxB;;OAEG;IACI,MAAM,CAAU,UAAU,oCAAoD;IAErF;;;OAGG;IACK,MAAM,CAAU,mBAAmB,GAAG,cAAc,CAAC;IAE7D;;OAEG;IACK,MAAM,CAAU,0BAA0B,GAAG,sBAAsB,CAAC;IAE5E;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACc,yBAAy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BACxB,KAAK,EAAE,OAAO;wBACd,MAAM,EAAE,8BAA8B,CAAC,UAAU;wBACjD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;wBACd,OAAO,EAAE,UAAU;wBACnB,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC;wBACjC,IAAI,EAAE;4BACL,cAAc;yBACd;qBACD,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseSocketClient } from \"@twin.org/api-core\";\nimport type { IHttpResponse } from \"@twin.org/api-models\";\nimport {\n\tBaseError,\n\tComponentFactory,\n\tConverter,\n\tGuards,\n\ttype IError,\n\tIs,\n\tNotImplementedError,\n\tNotSupportedError,\n\tRandomHelper\n} from \"@twin.org/core\";\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type {\n\tIActivityLogEntry,\n\tIActivityLogStatusNotification,\n\tIActivityLogStatusRequest,\n\tIDataAssetItemListResult,\n\tIDataspaceDataPlaneComponent,\n\tIEntitySet,\n\tIFilteringQuery\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 { IDataspaceDataPlaneSocketClientConstructorOptions } from \"./models/IDataspaceDataPlaneSocketClientConstructorOptions.js\";\n\n/**\n * Dataspace data plane client which publishes using REST API and websockets.\n */\nexport class DataspaceDataPlaneSocketClient\n\textends BaseSocketClient\n\timplements IDataspaceDataPlaneComponent\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataspaceDataPlaneSocketClient>();\n\n\t/**\n\t * The topic for activity log events.\n\t * @internal\n\t */\n\tprivate static readonly _ACTIVITY_LOG_TOPIC = \"activity-log\";\n\n\t/**\n\t * Activity processing details route.\n\t */\n\tprivate static readonly _ACTIVITY_LOG_STATUS_ROUTE = \"activity-logs/status\";\n\n\t/**\n\t * The logging service for information.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * Subscriptions to the events.\n\t * @internal\n\t */\n\tprivate readonly _activityLogSubscriptions: {\n\t\tsubscriptionId?: string;\n\t\tsubscriberCallbacks: {\n\t\t\t[subscriptionId: string]: (notification: IActivityLogStatusNotification) => Promise<void>;\n\t\t};\n\t};\n\n\t/**\n\t * Create a new instance of DataspaceDataPlaneSocketClient.\n\t * @param options Options for the client.\n\t */\n\tconstructor(options: IDataspaceDataPlaneSocketClientConstructorOptions) {\n\t\tsuper(nameof<DataspaceDataPlaneSocketClient>(), options?.config, \"dataspace-data-plane\");\n\n\t\tthis._activityLogSubscriptions = {\n\t\t\tsubscriberCallbacks: {}\n\t\t};\n\n\t\tthis._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? \"logging\");\n\n\t\tsuper.onEvent<IHttpResponse<IActivityLogStatusNotification>>(\"publish\", async data =>\n\t\t\tthis.incomingPublishActivityLog(data)\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 DataspaceDataPlaneSocketClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Notify an Activity to the Dataspace Activity Stream - implemented in REST Client.\n\t * @param activity The Activity notified.\n\t * @returns The Activity's identifier.\n\t */\n\tpublic async notifyActivity(activity: IActivityStreamsActivity): Promise<string> {\n\t\t// This method is in the REST client\n\t\tthrow new NotImplementedError(DataspaceDataPlaneSocketClient.CLASS_NAME, \"notifyActivity\");\n\t}\n\n\t/**\n\t * Subscribes to the activity log.\n\t * @param callback The callback to be called when Activity Log is called.\n\t * @param subscriptionId The subscription Id.\n\t * @returns The subscription Id.\n\t */\n\tpublic async subscribeToActivityLog(\n\t\tcallback: (notification: IActivityLogStatusNotification) => Promise<void>,\n\t\tsubscriptionId?: string\n\t): Promise<string> {\n\t\tGuards.function(DataspaceDataPlaneSocketClient.CLASS_NAME, nameof(callback), callback);\n\n\t\tlet needsConnect = false;\n\n\t\t// If we don't yet have an activity log subscription id then create one.\n\t\t// we will also need to connect to the socket.\n\t\tif (!Is.stringValue(this._activityLogSubscriptions.subscriptionId)) {\n\t\t\tthis._activityLogSubscriptions.subscriptionId = Converter.bytesToHex(\n\t\t\t\tRandomHelper.generate(16)\n\t\t\t);\n\t\t\tneedsConnect = true;\n\t\t}\n\n\t\t// Store the callback for the specific local subscription\n\t\tconst localSubscriptionId = subscriptionId ?? Converter.bytesToHex(RandomHelper.generate(16));\n\t\tthis._activityLogSubscriptions.subscriberCallbacks[localSubscriptionId] = callback;\n\n\t\t// If this the first subscription for the activity logs then send a subscribe to the socket.\n\t\tif (needsConnect && super.socketConnect()) {\n\t\t\tconst request: IActivityLogStatusRequest = {\n\t\t\t\tbody: {\n\t\t\t\t\toperation: \"subscribe\",\n\t\t\t\t\tsubscriptionId: this._activityLogSubscriptions.subscriptionId\n\t\t\t\t}\n\t\t\t};\n\t\t\tsuper.sendEvent(DataspaceDataPlaneSocketClient._ACTIVITY_LOG_STATUS_ROUTE, request);\n\t\t}\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceDataPlaneSocketClient.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"subscribeActivityLogs\",\n\t\t\tdata: {\n\t\t\t\ttopic: DataspaceDataPlaneSocketClient._ACTIVITY_LOG_TOPIC,\n\t\t\t\tsubscriptionId: this._activityLogSubscriptions.subscriptionId\n\t\t\t}\n\t\t});\n\n\t\treturn localSubscriptionId;\n\t}\n\n\t/**\n\t * Unsubscribes to the activity log.\n\t * @param subscriptionId The subscription Id.\n\t * @returns The subscription Id.\n\t */\n\tpublic async unSubscribeToActivityLog(subscriptionId: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tDataspaceDataPlaneSocketClient.CLASS_NAME,\n\t\t\tnameof(subscriptionId),\n\t\t\tsubscriptionId\n\t\t);\n\n\t\tif (this._activityLogSubscriptions.subscriberCallbacks[subscriptionId]) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceDataPlaneSocketClient.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"unsubscribeActivityLogs\",\n\t\t\t\tdata: {\n\t\t\t\t\tsubscriptionId\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// We found the subscription id so remove it.\n\t\t\tdelete this._activityLogSubscriptions.subscriberCallbacks[subscriptionId];\n\n\t\t\t// If there are no more subscriptions for the activity logs then send an unsubscribe to the socket.\n\t\t\tif (super.socketConnect() && Is.stringValue(this._activityLogSubscriptions.subscriptionId)) {\n\t\t\t\tconst request: IActivityLogStatusRequest = {\n\t\t\t\t\tbody: {\n\t\t\t\t\t\toperation: \"unsubscribe\",\n\t\t\t\t\t\tsubscriptionId: this._activityLogSubscriptions.subscriptionId\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tsuper.sendEvent(DataspaceDataPlaneSocketClient._ACTIVITY_LOG_STATUS_ROUTE, request);\n\t\t\t}\n\t\t}\n\n\t\t// There are no more subscriptions so disconnect the socket\n\t\tif (Is.empty(this._activityLogSubscriptions.subscriptionId)) {\n\t\t\tsuper.socketDisconnect();\n\t\t}\n\t}\n\n\t/**\n\t * Returns Activity Log Entry which contains the Activity processing details - implemented in REST Client.\n\t * @param logEntryId The Id of the Activity Log Entry (a URI).\n\t * @returns the Activity Log Entry with the processing details.\n\t * @throws NotFoundError if activity log entry is not known.\n\t */\n\tpublic async getActivityLogEntry(logEntryId: string): Promise<IActivityLogEntry> {\n\t\t// This method is in the REST client\n\t\tthrow new NotSupportedError(DataspaceDataPlaneSocketClient.CLASS_NAME, \"notSupportedOnClient\", {\n\t\t\tmethodName: \"getActivityLogEntry\"\n\t\t});\n\t}\n\n\t/**\n\t * Get Data Asset entities. Allows to retrieve entities by their type or id.\n\t * @param entitySet The set of entities to be retrieved.\n\t * @param entitySet.jsonLdContext The JSON-LD Context to be used to expand the referred entityType.\n\t * @param consumerPid The consumer Process ID from the DSP Transfer Process.\n\t * Used to resolve datasetId from the Transfer Process.\n\t * @param cursor Pagination details - cursor.\n\t * @param limit Pagination details - max number of entities.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The item list and optional cursor for pagination via Link headers.\n\t */\n\tpublic async getDataAssetEntities(\n\t\tentitySet: IEntitySet & {\n\t\t\tjsonLdContext?: IJsonLdContextDefinitionElement[];\n\t\t},\n\t\tconsumerPid: string,\n\t\tcursor?: string,\n\t\tlimit?: number,\n\t\ttrustPayload?: unknown\n\t): Promise<IDataAssetItemListResult> {\n\t\tthrow new NotSupportedError(DataspaceDataPlaneSocketClient.CLASS_NAME, \"notSupportedOnClient\", {\n\t\t\tmethodName: \"getDataAssetEntities\"\n\t\t});\n\t}\n\n\t/**\n\t * Queries a data asset controlled by this Dataspace App.\n\t * @param consumerPid The consumer Process ID from the DSP Transfer Process.\n\t * Used to resolve datasetId from the Transfer Process.\n\t * @param query The filtering query.\n\t * @param cursor Pagination details - cursor.\n\t * @param limit Pagination details - max number of entities.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The item list and optional cursor for pagination via Link headers.\n\t */\n\tpublic async queryDataAsset(\n\t\tconsumerPid: string,\n\t\tquery: IFilteringQuery,\n\t\tcursor?: string,\n\t\tlimit?: number,\n\t\ttrustPayload?: unknown\n\t): Promise<IDataAssetItemListResult> {\n\t\tthrow new NotSupportedError(DataspaceDataPlaneSocketClient.CLASS_NAME, \"notSupportedOnClient\", {\n\t\t\tmethodName: \"queryDataAsset\"\n\t\t});\n\t}\n\n\t/**\n\t * Handle the socket connection.\n\t */\n\tprotected async handleConnected(): Promise<void> {\n\t\t// The socket has reconnected so send subscribe requests\n\t\t// for all the current subscriptions\n\t\tif (\n\t\t\tObject.keys(this._activityLogSubscriptions.subscriberCallbacks).length > 0 &&\n\t\t\tIs.stringValue(this._activityLogSubscriptions.subscriptionId)\n\t\t) {\n\t\t\tconst subscribeEmit: IActivityLogStatusRequest = {\n\t\t\t\tbody: {\n\t\t\t\t\toperation: \"subscribe\",\n\t\t\t\t\tsubscriptionId: this._activityLogSubscriptions.subscriptionId\n\t\t\t\t}\n\t\t\t};\n\t\t\tsuper.sendEvent(DataspaceDataPlaneSocketClient._ACTIVITY_LOG_STATUS_ROUTE, subscribeEmit);\n\t\t}\n\t}\n\n\t/**\n\t * Handle an error.\n\t * @param err The error to handle.\n\t */\n\tprotected async handleError(err: IError): Promise<void> {\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"error\",\n\t\t\tsource: DataspaceDataPlaneSocketClient.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"socketConnect\",\n\t\t\terror: err\n\t\t});\n\t}\n\n\t/**\n\t * Handle an incoming publish event.\n\t * @param topic The incoming topic.\n\t * @param event The incoming data.\n\t * @internal\n\t */\n\tprivate async incomingPublishActivityLog(\n\t\tevent: IHttpResponse<IActivityLogStatusNotification>\n\t): Promise<void> {\n\t\tif (!Is.empty(event.body)) {\n\t\t\tfor (const subscriptionId in this._activityLogSubscriptions.subscriberCallbacks) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this._activityLogSubscriptions.subscriberCallbacks[subscriptionId](event.body);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait this._logging?.log({\n\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\tsource: DataspaceDataPlaneSocketClient.CLASS_NAME,\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"callback\",\n\t\t\t\t\t\terror: BaseError.fromError(error),\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\tsubscriptionId\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"]}
|
|
1
|
+
{"version":3,"file":"dataspaceDataPlaneSocketClient.js","sourceRoot":"","sources":["../../src/dataspaceDataPlaneSocketClient.ts"],"names":[],"mappings":"AAAA,gCAAgC;AAChC,uCAAuC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,EACN,SAAS,EACT,gBAAgB,EAChB,SAAS,EACT,MAAM,EAEN,EAAE,EACF,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EACZ,MAAM,gBAAgB,CAAC;AAgBxB;;GAEG;AACH,MAAM,OAAO,8BACZ,SAAQ,gBAAgB;IAGxB;;OAEG;IACI,MAAM,CAAU,UAAU,oCAAoD;IAErF;;;OAGG;IACK,MAAM,CAAU,mBAAmB,GAAG,cAAc,CAAC;IAE7D;;OAEG;IACK,MAAM,CAAU,0BAA0B,GAAG,sBAAsB,CAAC;IAE5E;;;OAGG;IACc,QAAQ,CAAqB;IAE9C;;;OAGG;IACc,yBAAyB,CAKxC;IAEF;;;OAGG;IACH,YAAY,OAA0D;QACrE,KAAK,mCAA2C,OAAO,EAAE,MAAM,EAAE,sBAAsB,CAAC,CAAC;QAEzF,IAAI,CAAC,yBAAyB,GAAG;YAChC,mBAAmB,EAAE,EAAE;SACvB,CAAC;QAEF,IAAI,CAAC,QAAQ,GAAG,gBAAgB,CAAC,WAAW,CAAC,OAAO,EAAE,oBAAoB,IAAI,SAAS,CAAC,CAAC;QAEzF,KAAK,CAAC,OAAO,CAAgD,SAAS,EAAE,KAAK,EAAC,IAAI,EAAC,EAAE,CACpF,IAAI,CAAC,0BAA0B,CAAC,IAAI,CAAC,CACrC,CAAC;IACH,CAAC;IAED;;;OAGG;IACI,SAAS;QACf,OAAO,8BAA8B,CAAC,UAAU,CAAC;IAClD,CAAC;IAED;;;;OAIG;IACI,KAAK,CAAC,cAAc,CAC1B,QAAkC;QAElC,oCAAoC;QACpC,MAAM,IAAI,mBAAmB,CAAC,8BAA8B,CAAC,UAAU,EAAE,gBAAgB,CA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K,EAAE,OAAO;YACd,MAAM,EAAE,8BAA8B,CAAC,UAAU;YACjD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;YACd,OAAO,EAAE,eAAe;YACxB,KAAK,EAAE,GAAG;SACV,CAAC,CAAC;IACJ,CAAC;IAED;;;;;OAKG;IACK,KAAK,CAAC,0BAA0B,CACvC,KAAoD;QAEpD,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,KAAK,MAAM,cAAc,IAAI,IAAI,CAAC,yBAAyB,CAAC,mBAAmB,EAAE,CAAC;gBACjF,IAAI,CAAC;oBACJ,MAAM,IAAI,CAAC,yBAAyB,CAAC,mBAAmB,CAAC,cAAc,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACtF,CAAC;gBAAC,OAAO,KAAK,EAAE,CAAC;oBAChB,MAAM,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC;wBACxB,KAAK,EAAE,OAAO;wBACd,MAAM,EAAE,8BAA8B,CAAC,UAAU;wBACjD,EAAE,EAAE,IAAI,CAAC,GAAG,EAAE;wBACd,OAAO,EAAE,UAAU;wBACnB,KAAK,EAAE,SAAS,CAAC,SAAS,CAAC,KAAK,CAAC;wBACjC,IAAI,EAAE;4BACL,cAAc;yBACd;qBACD,CAAC,CAAC;gBACJ,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC","sourcesContent":["// Copyright 2025 IOTA Stiftung.\n// SPDX-License-Identifier: Apache-2.0.\nimport { BaseSocketClient } from \"@twin.org/api-core\";\nimport type { IHttpResponse } from \"@twin.org/api-models\";\nimport {\n\tBaseError,\n\tComponentFactory,\n\tConverter,\n\tGuards,\n\ttype IError,\n\tIs,\n\tNotImplementedError,\n\tNotSupportedError,\n\tRandomHelper\n} from \"@twin.org/core\";\nimport type { IJsonLdContextDefinitionElement } from \"@twin.org/data-json-ld\";\nimport type {\n\tIActivityLogEntry,\n\tIActivityLogStatusNotification,\n\tIActivityLogStatusRequest,\n\tIDataAssetItemListResult,\n\tIDataspaceDataPlaneComponent,\n\tIEntitySet,\n\tIFilteringQuery\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 { IDataspaceDataPlaneSocketClientConstructorOptions } from \"./models/IDataspaceDataPlaneSocketClientConstructorOptions.js\";\n\n/**\n * Dataspace data plane client which publishes using REST API and websockets.\n */\nexport class DataspaceDataPlaneSocketClient\n\textends BaseSocketClient\n\timplements IDataspaceDataPlaneComponent\n{\n\t/**\n\t * Runtime name for the class.\n\t */\n\tpublic static readonly CLASS_NAME: string = nameof<DataspaceDataPlaneSocketClient>();\n\n\t/**\n\t * The topic for activity log events.\n\t * @internal\n\t */\n\tprivate static readonly _ACTIVITY_LOG_TOPIC = \"activity-log\";\n\n\t/**\n\t * Activity processing details route.\n\t */\n\tprivate static readonly _ACTIVITY_LOG_STATUS_ROUTE = \"activity-logs/status\";\n\n\t/**\n\t * The logging service for information.\n\t * @internal\n\t */\n\tprivate readonly _logging?: ILoggingComponent;\n\n\t/**\n\t * Subscriptions to the events.\n\t * @internal\n\t */\n\tprivate readonly _activityLogSubscriptions: {\n\t\tsubscriptionId?: string;\n\t\tsubscriberCallbacks: {\n\t\t\t[subscriptionId: string]: (notification: IActivityLogStatusNotification) => Promise<void>;\n\t\t};\n\t};\n\n\t/**\n\t * Create a new instance of DataspaceDataPlaneSocketClient.\n\t * @param options Options for the client.\n\t */\n\tconstructor(options: IDataspaceDataPlaneSocketClientConstructorOptions) {\n\t\tsuper(nameof<DataspaceDataPlaneSocketClient>(), options?.config, \"dataspace-data-plane\");\n\n\t\tthis._activityLogSubscriptions = {\n\t\t\tsubscriberCallbacks: {}\n\t\t};\n\n\t\tthis._logging = ComponentFactory.getIfExists(options?.loggingComponentType ?? \"logging\");\n\n\t\tsuper.onEvent<IHttpResponse<IActivityLogStatusNotification>>(\"publish\", async data =>\n\t\t\tthis.incomingPublishActivityLog(data)\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 DataspaceDataPlaneSocketClient.CLASS_NAME;\n\t}\n\n\t/**\n\t * Notify an Activity to the Dataspace Activity Stream - implemented in REST Client.\n\t * @param activity The Activity notified.\n\t * @returns The activity's id or entry.\n\t */\n\tpublic async notifyActivity(\n\t\tactivity: IActivityStreamsActivity\n\t): Promise<string | IActivityLogEntry> {\n\t\t// This method is in the REST client\n\t\tthrow new NotImplementedError(DataspaceDataPlaneSocketClient.CLASS_NAME, \"notifyActivity\");\n\t}\n\n\t/**\n\t * Subscribes to the activity log.\n\t * @param callback The callback to be called when Activity Log is called.\n\t * @param subscriptionId The subscription Id.\n\t * @returns The subscription Id.\n\t */\n\tpublic async subscribeToActivityLog(\n\t\tcallback: (notification: IActivityLogStatusNotification) => Promise<void>,\n\t\tsubscriptionId?: string\n\t): Promise<string> {\n\t\tGuards.function(DataspaceDataPlaneSocketClient.CLASS_NAME, nameof(callback), callback);\n\n\t\tlet needsConnect = false;\n\n\t\t// If we don't yet have an activity log subscription id then create one.\n\t\t// we will also need to connect to the socket.\n\t\tif (!Is.stringValue(this._activityLogSubscriptions.subscriptionId)) {\n\t\t\tthis._activityLogSubscriptions.subscriptionId = Converter.bytesToHex(\n\t\t\t\tRandomHelper.generate(16)\n\t\t\t);\n\t\t\tneedsConnect = true;\n\t\t}\n\n\t\t// Store the callback for the specific local subscription\n\t\tconst localSubscriptionId = subscriptionId ?? Converter.bytesToHex(RandomHelper.generate(16));\n\t\tthis._activityLogSubscriptions.subscriberCallbacks[localSubscriptionId] = callback;\n\n\t\t// If this the first subscription for the activity logs then send a subscribe to the socket.\n\t\tif (needsConnect && super.socketConnect()) {\n\t\t\tconst request: IActivityLogStatusRequest = {\n\t\t\t\tbody: {\n\t\t\t\t\toperation: \"subscribe\",\n\t\t\t\t\tsubscriptionId: this._activityLogSubscriptions.subscriptionId\n\t\t\t\t}\n\t\t\t};\n\t\t\tsuper.sendEvent(DataspaceDataPlaneSocketClient._ACTIVITY_LOG_STATUS_ROUTE, request);\n\t\t}\n\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"info\",\n\t\t\tsource: DataspaceDataPlaneSocketClient.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"subscribeActivityLogs\",\n\t\t\tdata: {\n\t\t\t\ttopic: DataspaceDataPlaneSocketClient._ACTIVITY_LOG_TOPIC,\n\t\t\t\tsubscriptionId: this._activityLogSubscriptions.subscriptionId\n\t\t\t}\n\t\t});\n\n\t\treturn localSubscriptionId;\n\t}\n\n\t/**\n\t * Unsubscribes to the activity log.\n\t * @param subscriptionId The subscription Id.\n\t * @returns The subscription Id.\n\t */\n\tpublic async unSubscribeToActivityLog(subscriptionId: string): Promise<void> {\n\t\tGuards.stringValue(\n\t\t\tDataspaceDataPlaneSocketClient.CLASS_NAME,\n\t\t\tnameof(subscriptionId),\n\t\t\tsubscriptionId\n\t\t);\n\n\t\tif (this._activityLogSubscriptions.subscriberCallbacks[subscriptionId]) {\n\t\t\tawait this._logging?.log({\n\t\t\t\tlevel: \"info\",\n\t\t\t\tsource: DataspaceDataPlaneSocketClient.CLASS_NAME,\n\t\t\t\tts: Date.now(),\n\t\t\t\tmessage: \"unsubscribeActivityLogs\",\n\t\t\t\tdata: {\n\t\t\t\t\tsubscriptionId\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// We found the subscription id so remove it.\n\t\t\tdelete this._activityLogSubscriptions.subscriberCallbacks[subscriptionId];\n\n\t\t\t// If there are no more subscriptions for the activity logs then send an unsubscribe to the socket.\n\t\t\tif (super.socketConnect() && Is.stringValue(this._activityLogSubscriptions.subscriptionId)) {\n\t\t\t\tconst request: IActivityLogStatusRequest = {\n\t\t\t\t\tbody: {\n\t\t\t\t\t\toperation: \"unsubscribe\",\n\t\t\t\t\t\tsubscriptionId: this._activityLogSubscriptions.subscriptionId\n\t\t\t\t\t}\n\t\t\t\t};\n\t\t\t\tsuper.sendEvent(DataspaceDataPlaneSocketClient._ACTIVITY_LOG_STATUS_ROUTE, request);\n\t\t\t}\n\t\t}\n\n\t\t// There are no more subscriptions so disconnect the socket\n\t\tif (Is.empty(this._activityLogSubscriptions.subscriptionId)) {\n\t\t\tsuper.socketDisconnect();\n\t\t}\n\t}\n\n\t/**\n\t * Returns Activity Log Entry which contains the Activity processing details - implemented in REST Client.\n\t * @param logEntryId The Id of the Activity Log Entry (a URI).\n\t * @returns the Activity Log Entry with the processing details.\n\t * @throws NotFoundError if activity log entry is not known.\n\t */\n\tpublic async getActivityLogEntry(logEntryId: string): Promise<IActivityLogEntry> {\n\t\t// This method is in the REST client\n\t\tthrow new NotSupportedError(DataspaceDataPlaneSocketClient.CLASS_NAME, \"notSupportedOnClient\", {\n\t\t\tmethodName: \"getActivityLogEntry\"\n\t\t});\n\t}\n\n\t/**\n\t * Get Data Asset entities. Allows to retrieve entities by their type or id.\n\t * @param entitySet The set of entities to be retrieved.\n\t * @param entitySet.jsonLdContext The JSON-LD Context to be used to expand the referred entityType.\n\t * @param consumerPid The consumer Process ID from the DSP Transfer Process.\n\t * Used to resolve datasetId from the Transfer Process.\n\t * @param cursor Pagination details - cursor.\n\t * @param limit Pagination details - max number of entities.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The item list and optional cursor for pagination via Link headers.\n\t */\n\tpublic async getDataAssetEntities(\n\t\tentitySet: IEntitySet & {\n\t\t\tjsonLdContext?: IJsonLdContextDefinitionElement[];\n\t\t},\n\t\tconsumerPid: string,\n\t\tcursor?: string,\n\t\tlimit?: number,\n\t\ttrustPayload?: unknown\n\t): Promise<IDataAssetItemListResult> {\n\t\tthrow new NotSupportedError(DataspaceDataPlaneSocketClient.CLASS_NAME, \"notSupportedOnClient\", {\n\t\t\tmethodName: \"getDataAssetEntities\"\n\t\t});\n\t}\n\n\t/**\n\t * Queries a data asset controlled by this Dataspace App.\n\t * @param consumerPid The consumer Process ID from the DSP Transfer Process.\n\t * Used to resolve datasetId from the Transfer Process.\n\t * @param query The filtering query.\n\t * @param cursor Pagination details - cursor.\n\t * @param limit Pagination details - max number of entities.\n\t * @param trustPayload Trust payload to verify the requesters identity.\n\t * @returns The item list and optional cursor for pagination via Link headers.\n\t */\n\tpublic async queryDataAsset(\n\t\tconsumerPid: string,\n\t\tquery: IFilteringQuery,\n\t\tcursor?: string,\n\t\tlimit?: number,\n\t\ttrustPayload?: unknown\n\t): Promise<IDataAssetItemListResult> {\n\t\tthrow new NotSupportedError(DataspaceDataPlaneSocketClient.CLASS_NAME, \"notSupportedOnClient\", {\n\t\t\tmethodName: \"queryDataAsset\"\n\t\t});\n\t}\n\n\t/**\n\t * Handle the socket connection.\n\t */\n\tprotected async handleConnected(): Promise<void> {\n\t\t// The socket has reconnected so send subscribe requests\n\t\t// for all the current subscriptions\n\t\tif (\n\t\t\tObject.keys(this._activityLogSubscriptions.subscriberCallbacks).length > 0 &&\n\t\t\tIs.stringValue(this._activityLogSubscriptions.subscriptionId)\n\t\t) {\n\t\t\tconst subscribeEmit: IActivityLogStatusRequest = {\n\t\t\t\tbody: {\n\t\t\t\t\toperation: \"subscribe\",\n\t\t\t\t\tsubscriptionId: this._activityLogSubscriptions.subscriptionId\n\t\t\t\t}\n\t\t\t};\n\t\t\tsuper.sendEvent(DataspaceDataPlaneSocketClient._ACTIVITY_LOG_STATUS_ROUTE, subscribeEmit);\n\t\t}\n\t}\n\n\t/**\n\t * Handle an error.\n\t * @param err The error to handle.\n\t */\n\tprotected async handleError(err: IError): Promise<void> {\n\t\tawait this._logging?.log({\n\t\t\tlevel: \"error\",\n\t\t\tsource: DataspaceDataPlaneSocketClient.CLASS_NAME,\n\t\t\tts: Date.now(),\n\t\t\tmessage: \"socketConnect\",\n\t\t\terror: err\n\t\t});\n\t}\n\n\t/**\n\t * Handle an incoming publish event.\n\t * @param topic The incoming topic.\n\t * @param event The incoming data.\n\t * @internal\n\t */\n\tprivate async incomingPublishActivityLog(\n\t\tevent: IHttpResponse<IActivityLogStatusNotification>\n\t): Promise<void> {\n\t\tif (!Is.empty(event.body)) {\n\t\t\tfor (const subscriptionId in this._activityLogSubscriptions.subscriberCallbacks) {\n\t\t\t\ttry {\n\t\t\t\t\tawait this._activityLogSubscriptions.subscriberCallbacks[subscriptionId](event.body);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tawait this._logging?.log({\n\t\t\t\t\t\tlevel: \"error\",\n\t\t\t\t\t\tsource: DataspaceDataPlaneSocketClient.CLASS_NAME,\n\t\t\t\t\t\tts: Date.now(),\n\t\t\t\t\t\tmessage: \"callback\",\n\t\t\t\t\t\terror: BaseError.fromError(error),\n\t\t\t\t\t\tdata: {\n\t\t\t\t\t\t\tsubscriptionId\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"]}
|
|
@@ -29,9 +29,9 @@ export declare class DataspaceDataPlaneSocketClient extends BaseSocketClient imp
|
|
|
29
29
|
/**
|
|
30
30
|
* Notify an Activity to the Dataspace Activity Stream - implemented in REST Client.
|
|
31
31
|
* @param activity The Activity notified.
|
|
32
|
-
* @returns The
|
|
32
|
+
* @returns The activity's id or entry.
|
|
33
33
|
*/
|
|
34
|
-
notifyActivity(activity: IActivityStreamsActivity): Promise<string>;
|
|
34
|
+
notifyActivity(activity: IActivityStreamsActivity): Promise<string | IActivityLogEntry>;
|
|
35
35
|
/**
|
|
36
36
|
* Subscribes to the activity log.
|
|
37
37
|
* @param callback The callback to be called when Activity Log is called.
|
package/docs/changelog.md
CHANGED
|
@@ -1,5 +1,33 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## [0.0.3-next.26](https://github.com/twinfoundation/dataspace/compare/dataspace-data-plane-socket-client-v0.0.3-next.25...dataspace-data-plane-socket-client-v0.0.3-next.26) (2026-04-14)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* add inline tasks and concurrent options ([#104](https://github.com/twinfoundation/dataspace/issues/104)) ([2227a21](https://github.com/twinfoundation/dataspace/commit/2227a212d906f58ba77850c79bb20bf2cb7195a8))
|
|
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.25 to 0.0.3-next.26
|
|
16
|
+
|
|
17
|
+
## [0.0.3-next.25](https://github.com/twinfoundation/dataspace/compare/dataspace-data-plane-socket-client-v0.0.3-next.24...dataspace-data-plane-socket-client-v0.0.3-next.25) (2026-04-10)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Miscellaneous Chores
|
|
21
|
+
|
|
22
|
+
* **dataspace-data-plane-socket-client:** 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.24 to 0.0.3-next.25
|
|
30
|
+
|
|
3
31
|
## [0.0.3-next.24](https://github.com/twinfoundation/dataspace/compare/dataspace-data-plane-socket-client-v0.0.3-next.23...dataspace-data-plane-socket-client-v0.0.3-next.24) (2026-03-31)
|
|
4
32
|
|
|
5
33
|
|
|
@@ -64,7 +64,7 @@ The class name of the component.
|
|
|
64
64
|
|
|
65
65
|
### notifyActivity() {#notifyactivity}
|
|
66
66
|
|
|
67
|
-
> **notifyActivity**(`activity`): `Promise`\<`string`\>
|
|
67
|
+
> **notifyActivity**(`activity`): `Promise`\<`string` \| `IActivityLogEntry`\>
|
|
68
68
|
|
|
69
69
|
Notify an Activity to the Dataspace Activity Stream - implemented in REST Client.
|
|
70
70
|
|
|
@@ -78,9 +78,9 @@ The Activity notified.
|
|
|
78
78
|
|
|
79
79
|
#### Returns
|
|
80
80
|
|
|
81
|
-
`Promise`\<`string`\>
|
|
81
|
+
`Promise`\<`string` \| `IActivityLogEntry`\>
|
|
82
82
|
|
|
83
|
-
The
|
|
83
|
+
The activity's id or entry.
|
|
84
84
|
|
|
85
85
|
#### Implementation of
|
|
86
86
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@twin.org/dataspace-data-plane-socket-client",
|
|
3
|
-
"version": "0.0.3-next.
|
|
3
|
+
"version": "0.0.3-next.26",
|
|
4
4
|
"description": "Provides a WebSocket client for subscribing to activity log status notifications.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"@twin.org/api-models": "next",
|
|
19
19
|
"@twin.org/core": "next",
|
|
20
20
|
"@twin.org/data-json-ld": "next",
|
|
21
|
-
"@twin.org/dataspace-models": "0.0.3-next.
|
|
21
|
+
"@twin.org/dataspace-models": "0.0.3-next.26",
|
|
22
22
|
"@twin.org/logging-models": "next",
|
|
23
23
|
"@twin.org/nameof": "next"
|
|
24
24
|
},
|