From 1d06e89300c341381e1827c972f45049b77aa3e6 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Mon, 16 Jan 2023 15:18:14 -0500 Subject: [PATCH 1/3] Add updateIdentity and org/node getters Signed-off-by: Andrew Richardson --- lib/firefly.ts | 36 ++++++++++++++++++++++++++++++++---- lib/http.ts | 34 ++++++++++++++++++++++++++-------- lib/interfaces.ts | 12 ++++++++---- package-lock.json | 4 ++-- package.json | 4 ++-- 5 files changed, 70 insertions(+), 20 deletions(-) diff --git a/lib/firefly.ts b/lib/firefly.ts index 552f58a..8e25714 100644 --- a/lib/firefly.ts +++ b/lib/firefly.ts @@ -73,6 +73,9 @@ import { FireFlyVerifierResolveResponse, FireFlyTokenApprovalRequest, FireFlyNamespaceResponse, + FireFlyUpdateIdentityRequest, + FireFlyReplaceOptions, + FireFlyUpdateOptions, } from './interfaces'; import { FireFlyWebSocket, FireFlyWebSocketCallback } from './websocket'; import HttpBase, { mapConfig } from './http'; @@ -93,10 +96,10 @@ export default class FireFly extends HttpBase { } getIdentity( - nameOrId: string, + id: string, options?: FireFlyGetOptions, ): Promise { - return this.getOne(`/identities/${nameOrId}`, options); + return this.getOne(`/identities/${id}`, options); } createIdentity( @@ -106,6 +109,14 @@ export default class FireFly extends HttpBase { return this.createOne(`/identities`, identity, options); } + updateIdentity( + id: string, + update: FireFlyUpdateIdentityRequest, + options?: FireFlyUpdateOptions, + ): Promise { + return this.updateOne(`/identities/${id}`, update, options); + } + getOrganizations( filter?: FireFlyOrganizationFilter, options?: FireFlyGetOptions, @@ -113,6 +124,13 @@ export default class FireFly extends HttpBase { return this.getMany('/network/organizations', filter, options); } + getOrganization( + nameOrId: string, + options?: FireFlyGetOptions, + ): Promise { + return this.getOne(`/network/organizations/${nameOrId}`, options); + } + getNodes( filter?: FireFlyNodeFilter, options?: FireFlyGetOptions, @@ -120,6 +138,13 @@ export default class FireFly extends HttpBase { return this.getMany('/network/nodes', filter, options); } + getNode( + nameOrId: string, + options?: FireFlyGetOptions, + ): Promise { + return this.getOne(`/network/nodes/${nameOrId}`, options); + } + getVerifiers( namespace?: string, filter?: FireFlyVerifierFilter, @@ -175,8 +200,11 @@ export default class FireFly extends HttpBase { return this.getMany('/subscriptions', filter, options); } - replaceSubscription(sub: FireFlySubscriptionRequest): Promise { - return this.replaceOne('/subscriptions', sub); + replaceSubscription( + sub: FireFlySubscriptionRequest, + options?: FireFlyReplaceOptions, + ): Promise { + return this.replaceOne('/subscriptions', sub, options); } async deleteSubscription(subId: string) { diff --git a/lib/http.ts b/lib/http.ts index fd11bda..a8beef5 100644 --- a/lib/http.ts +++ b/lib/http.ts @@ -5,6 +5,8 @@ import { FireFlyCreateOptions, FireFlyGetOptions, FireFlyError, + FireFlyReplaceOptions, + FireFlyUpdateOptions, } from './interfaces'; function isSuccess(status: number) { @@ -12,16 +14,27 @@ function isSuccess(status: number) { } export function mapConfig( - options: FireFlyGetOptions | FireFlyCreateOptions | undefined, + options: + | FireFlyGetOptions + | FireFlyUpdateOptions + | FireFlyReplaceOptions + | FireFlyCreateOptions + | undefined, params?: any, ): AxiosRequestConfig { - return { + const config: AxiosRequestConfig = { ...options?.requestConfig, - params: { - ...params, - confirm: options?.confirm, - }, + params, }; + if (options !== undefined) { + if ('confirm' in options) { + config.params = { + ...config.params, + confirm: options.confirm, + }; + } + } + return config; } export default class HttpBase { @@ -92,8 +105,13 @@ export default class HttpBase { return response.data; } - protected async replaceOne(url: string, data: any) { - const response = await this.wrapError(this.http.put(url, data)); + protected async updateOne(url: string, data: any, options?: FireFlyUpdateOptions) { + const response = await this.wrapError(this.http.patch(url, data, mapConfig(options))); + return response.data; + } + + protected async replaceOne(url: string, data: any, options?: FireFlyReplaceOptions) { + const response = await this.wrapError(this.http.put(url, data, mapConfig(options))); return response.data; } diff --git a/lib/interfaces.ts b/lib/interfaces.ts index 80b003a..91090f9 100644 --- a/lib/interfaces.ts +++ b/lib/interfaces.ts @@ -21,14 +21,16 @@ export class FireFlyError extends Error { } } -export interface FireFlyGetOptions { - confirm: undefined; +interface FireFlyBaseHttpOptions { requestConfig?: AxiosRequestConfig; } -export interface FireFlyCreateOptions { +export interface FireFlyGetOptions extends FireFlyBaseHttpOptions {} +export interface FireFlyUpdateOptions extends FireFlyBaseHttpOptions {} +export interface FireFlyReplaceOptions extends FireFlyBaseHttpOptions {} + +export interface FireFlyCreateOptions extends FireFlyBaseHttpOptions { confirm?: boolean; - requestConfig?: AxiosRequestConfig; } export interface FireFlyOptionsInput { @@ -80,6 +82,8 @@ export type FireFlyVerifierFilter = operations['getVerifiers']['parameters']['qu export type FireFlyIdentityRequest = operations['postNewIdentity']['requestBody']['content']['application/json']; +export type FireFlyUpdateIdentityRequest = + operations['patchUpdateIdentity']['requestBody']['content']['application/json']; export type FireFlyIdentityResponse = Required< operations['getIdentityByID']['responses']['200']['content']['application/json'] diff --git a/package-lock.json b/package-lock.json index 4d7988c..d8403d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@hyperledger/firefly-sdk", - "version": "1.2.4", + "version": "1.2.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@hyperledger/firefly-sdk", - "version": "1.2.4", + "version": "1.2.5", "license": "Apache-2.0", "dependencies": { "axios": "^0.26.1", diff --git a/package.json b/package.json index e36a11c..0c1a0fc 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@hyperledger/firefly-sdk", - "version": "1.2.4", + "version": "1.2.5", "description": "Client SDK for Hyperledger FireFly", "main": "dist/index.js", "types": "dist/index.d.ts", @@ -45,4 +45,4 @@ "form-data": "^4.0.0", "ws": "^8.5.0" } -} \ No newline at end of file +} From 1f989c6971b58513e10cbd60f8b5cb5dcceb5390 Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Mon, 16 Jan 2023 15:34:38 -0500 Subject: [PATCH 2/3] Update schemas Signed-off-by: Andrew Richardson --- lib/schema.ts | 734 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 724 insertions(+), 10 deletions(-) diff --git a/lib/schema.ts b/lib/schema.ts index a9f197e..dc1185e 100644 --- a/lib/schema.ts +++ b/lib/schema.ts @@ -107,6 +107,8 @@ export interface paths { "/data/{dataid}": { /** Gets a data item by its ID, including metadata about this item */ get: operations["getDataByID"]; + /** Deletes a data item by its ID, including metadata about this item */ + delete: operations["deleteData"]; }; "/data/{dataid}/blob": { /** Downloads the original file that was previously uploaded or received */ @@ -321,6 +323,8 @@ export interface paths { "/namespaces/{ns}/data/{dataid}": { /** Gets a data item by its ID, including metadata about this item */ get: operations["getDataByIDNamespace"]; + /** Deletes a data item by its ID, including metadata about this item */ + delete: operations["deleteDataNamespace"]; }; "/namespaces/{ns}/data/{dataid}/blob": { /** Downloads the original file that was previously uploaded or received */ @@ -1038,6 +1042,36 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** + * Format: uuid + * @description The UUID of the FFI error definition + */ + id?: string; + /** + * Format: uuid + * @description The UUID of the FFI smart contract definition that this error is part of + */ + interface?: string; + /** @description The name of the error */ + name?: string; + /** @description The namespace of the FFI */ + namespace?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + /** @description The unique name allocated to this error within the FFI for use on URL paths */ + pathname?: string; + /** @description The stringified signature of the error, as computed by the blockchain plugin */ + signature?: string; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -2254,6 +2288,36 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** + * Format: uuid + * @description The UUID of the FFI error definition + */ + id?: string; + /** + * Format: uuid + * @description The UUID of the FFI smart contract definition that this error is part of + */ + interface?: string; + /** @description The name of the error */ + name?: string; + /** @description The namespace of the FFI */ + namespace?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + /** @description The unique name allocated to this error within the FFI for use on URL paths */ + pathname?: string; + /** @description The stringified signature of the error, as computed by the blockchain plugin */ + signature?: string; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -2364,6 +2428,36 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** + * Format: uuid + * @description The UUID of the FFI error definition + */ + id?: string; + /** + * Format: uuid + * @description The UUID of the FFI smart contract definition that this error is part of + */ + interface?: string; + /** @description The name of the error */ + name?: string; + /** @description The namespace of the FFI */ + namespace?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + /** @description The unique name allocated to this error within the FFI for use on URL paths */ + pathname?: string; + /** @description The stringified signature of the error, as computed by the blockchain plugin */ + signature?: string; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -2459,6 +2553,20 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** @description The name of the error */ + name?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -2529,6 +2637,36 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** + * Format: uuid + * @description The UUID of the FFI error definition + */ + id?: string; + /** + * Format: uuid + * @description The UUID of the FFI smart contract definition that this error is part of + */ + interface?: string; + /** @description The name of the error */ + name?: string; + /** @description The namespace of the FFI */ + namespace?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + /** @description The unique name allocated to this error within the FFI for use on URL paths */ + pathname?: string; + /** @description The stringified signature of the error, as computed by the blockchain plugin */ + signature?: string; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -2645,6 +2783,36 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** + * Format: uuid + * @description The UUID of the FFI error definition + */ + id?: string; + /** + * Format: uuid + * @description The UUID of the FFI smart contract definition that this error is part of + */ + interface?: string; + /** @description The name of the error */ + name?: string; + /** @description The namespace of the FFI */ + namespace?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + /** @description The unique name allocated to this error within the FFI for use on URL paths */ + pathname?: string; + /** @description The stringified signature of the error, as computed by the blockchain plugin */ + signature?: string; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -2751,6 +2919,36 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** + * Format: uuid + * @description The UUID of the FFI error definition + */ + id?: string; + /** + * Format: uuid + * @description The UUID of the FFI smart contract definition that this error is part of + */ + interface?: string; + /** @description The name of the error */ + name?: string; + /** @description The namespace of the FFI */ + namespace?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + /** @description The unique name allocated to this error within the FFI for use on URL paths */ + pathname?: string; + /** @description The stringified signature of the error, as computed by the blockchain plugin */ + signature?: string; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -3004,6 +3202,20 @@ export interface operations { requestBody: { content: { "application/json": { + /** @description An in-line FFI errors definition for the method to invoke. Alternative to specifying FFI */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** @description The name of the error */ + name?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + }[]; /** @description An optional identifier to allow idempotent submission of requests. Stored on the transaction uniquely within a namespace */ idempotencyKey?: string; /** @description A map of named inputs. The name and type of each input must be compatible with the FFI description of the method, so that FireFly knows how to serialize it to the blockchain via the connector */ @@ -3401,6 +3613,20 @@ export interface operations { requestBody: { content: { "application/json": { + /** @description An in-line FFI errors definition for the method to invoke. Alternative to specifying FFI */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** @description The name of the error */ + name?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + }[]; /** @description An optional identifier to allow idempotent submission of requests. Stored on the transaction uniquely within a namespace */ idempotencyKey?: string; /** @description A map of named inputs. The name and type of each input must be compatible with the FFI description of the method, so that FireFly knows how to serialize it to the blockchain via the connector */ @@ -3721,11 +3947,33 @@ export interface operations { default: unknown; }; }; + /** Deletes a data item by its ID, including metadata about this item */ + deleteData: { + parameters: { + path: { + /** The data item ID */ + dataid: string; + }; + header: { + /** Server-side request timeout (milliseconds, or set a custom suffix like 10s) */ + "Request-Timeout"?: string; + }; + }; + responses: { + /** Success */ + 204: { + content: { + "application/json": unknown; + }; + }; + default: unknown; + }; + }; /** Downloads the original file that was previously uploaded or received */ getDataBlob: { parameters: { path: { - /** The blob ID */ + /** The data item ID */ dataid: string; }; header: { @@ -7344,6 +7592,36 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** + * Format: uuid + * @description The UUID of the FFI error definition + */ + id?: string; + /** + * Format: uuid + * @description The UUID of the FFI smart contract definition that this error is part of + */ + interface?: string; + /** @description The name of the error */ + name?: string; + /** @description The namespace of the FFI */ + namespace?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + /** @description The unique name allocated to this error within the FFI for use on URL paths */ + pathname?: string; + /** @description The stringified signature of the error, as computed by the blockchain plugin */ + signature?: string; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -7589,6 +7867,20 @@ export interface operations { requestBody: { content: { "application/json": { + /** @description An in-line FFI errors definition for the method to invoke. Alternative to specifying FFI */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** @description The name of the error */ + name?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + }[]; /** @description An optional identifier to allow idempotent submission of requests. Stored on the transaction uniquely within a namespace */ idempotencyKey?: string; /** @description A map of named inputs. The name and type of each input must be compatible with the FFI description of the method, so that FireFly knows how to serialize it to the blockchain via the connector */ @@ -7904,6 +8196,20 @@ export interface operations { requestBody: { content: { "application/json": { + /** @description An in-line FFI errors definition for the method to invoke. Alternative to specifying FFI */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** @description The name of the error */ + name?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + }[]; /** @description An optional identifier to allow idempotent submission of requests. Stored on the transaction uniquely within a namespace */ idempotencyKey?: string; /** @description A map of named inputs. The name and type of each input must be compatible with the FFI description of the method, so that FireFly knows how to serialize it to the blockchain via the connector */ @@ -8680,6 +8986,36 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** + * Format: uuid + * @description The UUID of the FFI error definition + */ + id?: string; + /** + * Format: uuid + * @description The UUID of the FFI smart contract definition that this error is part of + */ + interface?: string; + /** @description The name of the error */ + name?: string; + /** @description The namespace of the FFI */ + namespace?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + /** @description The unique name allocated to this error within the FFI for use on URL paths */ + pathname?: string; + /** @description The stringified signature of the error, as computed by the blockchain plugin */ + signature?: string; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -8794,6 +9130,36 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** + * Format: uuid + * @description The UUID of the FFI error definition + */ + id?: string; + /** + * Format: uuid + * @description The UUID of the FFI smart contract definition that this error is part of + */ + interface?: string; + /** @description The name of the error */ + name?: string; + /** @description The namespace of the FFI */ + namespace?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + /** @description The unique name allocated to this error within the FFI for use on URL paths */ + pathname?: string; + /** @description The stringified signature of the error, as computed by the blockchain plugin */ + signature?: string; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -8889,6 +9255,20 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** @description The name of the error */ + name?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -8961,6 +9341,36 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** + * Format: uuid + * @description The UUID of the FFI error definition + */ + id?: string; + /** + * Format: uuid + * @description The UUID of the FFI smart contract definition that this error is part of + */ + interface?: string; + /** @description The name of the error */ + name?: string; + /** @description The namespace of the FFI */ + namespace?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + /** @description The unique name allocated to this error within the FFI for use on URL paths */ + pathname?: string; + /** @description The stringified signature of the error, as computed by the blockchain plugin */ + signature?: string; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -9079,6 +9489,36 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** + * Format: uuid + * @description The UUID of the FFI error definition + */ + id?: string; + /** + * Format: uuid + * @description The UUID of the FFI smart contract definition that this error is part of + */ + interface?: string; + /** @description The name of the error */ + name?: string; + /** @description The namespace of the FFI */ + namespace?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + /** @description The unique name allocated to this error within the FFI for use on URL paths */ + pathname?: string; + /** @description The stringified signature of the error, as computed by the blockchain plugin */ + signature?: string; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -9189,6 +9629,36 @@ export interface operations { "application/json": { /** @description A description of the smart contract this FFI represents */ description?: string; + /** @description An array of smart contract error definitions */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** + * Format: uuid + * @description The UUID of the FFI error definition + */ + id?: string; + /** + * Format: uuid + * @description The UUID of the FFI smart contract definition that this error is part of + */ + interface?: string; + /** @description The name of the error */ + name?: string; + /** @description The namespace of the FFI */ + namespace?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + /** @description The unique name allocated to this error within the FFI for use on URL paths */ + pathname?: string; + /** @description The stringified signature of the error, as computed by the blockchain plugin */ + signature?: string; + }[]; /** @description An array of smart contract event definitions */ events?: { /** @description A description of the smart contract event */ @@ -9446,6 +9916,20 @@ export interface operations { requestBody: { content: { "application/json": { + /** @description An in-line FFI errors definition for the method to invoke. Alternative to specifying FFI */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** @description The name of the error */ + name?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + }[]; /** @description An optional identifier to allow idempotent submission of requests. Stored on the transaction uniquely within a namespace */ idempotencyKey?: string; /** @description A map of named inputs. The name and type of each input must be compatible with the FFI description of the method, so that FireFly knows how to serialize it to the blockchain via the connector */ @@ -9859,6 +10343,20 @@ export interface operations { requestBody: { content: { "application/json": { + /** @description An in-line FFI errors definition for the method to invoke. Alternative to specifying FFI */ + errors?: { + /** @description A description of the smart contract error */ + description?: string; + /** @description The name of the error */ + name?: string; + /** @description An array of error parameter/argument definitions */ + params?: { + /** @description The name of the parameter. Note that parameters must be ordered correctly on the FFI, according to the order in the blockchain smart contract */ + name?: string; + /** @description FireFly uses an extended subset of JSON Schema to describe parameters, similar to OpenAPI/Swagger. Converters are available for native blockchain interface definitions / type systems - such as an Ethereum ABI. See the documentation for more detail */ + schema?: any; + }[]; + }[]; /** @description An optional identifier to allow idempotent submission of requests. Stored on the transaction uniquely within a namespace */ idempotencyKey?: string; /** @description A map of named inputs. The name and type of each input must be compatible with the FFI description of the method, so that FireFly knows how to serialize it to the blockchain via the connector */ @@ -10189,11 +10687,35 @@ export interface operations { default: unknown; }; }; + /** Deletes a data item by its ID, including metadata about this item */ + deleteDataNamespace: { + parameters: { + path: { + /** The data item ID */ + dataid: string; + /** The namespace which scopes this request */ + ns: string; + }; + header: { + /** Server-side request timeout (milliseconds, or set a custom suffix like 10s) */ + "Request-Timeout"?: string; + }; + }; + responses: { + /** Success */ + 204: { + content: { + "application/json": unknown; + }; + }; + default: unknown; + }; + }; /** Downloads the original file that was previously uploaded or received */ getDataBlobNamespace: { parameters: { path: { - /** The blob ID */ + /** The data item ID */ dataid: string; /** The namespace which scopes this request */ ns: string; @@ -14824,6 +15346,10 @@ export interface operations { /** The namespace which scopes this request */ ns: string; }; + query: { + /** When set, the API will return additional status information if available */ + fetchstatus?: string; + }; header: { /** Server-side request timeout (milliseconds, or set a custom suffix like 10s) */ "Request-Timeout"?: string; @@ -16987,6 +17513,10 @@ export interface operations { /** Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^ */ id?: string; /** Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^ */ + interface?: string; + /** Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^ */ + interfaceformat?: string; + /** Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^ */ locator?: string; /** Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^ */ message?: string; @@ -17039,6 +17569,23 @@ export interface operations { id?: string; /** @description Token connector specific information about the pool. See your chosen token connector documentation for details */ info?: { [key: string]: any }; + /** @description A reference to an existing FFI, containing pre-registered type information for the token contract */ + interface?: { + /** + * Format: uuid + * @description The UUID of the FireFly interface + */ + id?: string; + /** @description The name of the FireFly interface */ + name?: string; + /** @description The version of the FireFly interface */ + version?: string; + }; + /** + * @description The interface encoding format supported by the connector for this token pool + * @enum {string} + */ + interfaceFormat?: "abi" | "ffi"; /** @description The signing key used to create the token pool. On input for token connectors that support on-chain deployment of new tokens (vs. only index existing ones) this determines the signing key used to create the token on-chain */ key?: string; /** @description A unique identifier for the pool, as provided by the token connector */ @@ -17048,6 +17595,8 @@ export interface operations { * @description The UUID of the broadcast message used to inform the network to index this pool */ message?: string; + /** @description The method definitions resolved by the token connector to be used by each token operation */ + methods?: any; /** @description The name of the token pool. Note the name is not validated against the description of the token on the blockchain */ name?: string; /** @description The namespace for the token pool */ @@ -17058,7 +17607,7 @@ export interface operations { * @description The current state of the token pool * @enum {string} */ - state?: "unknown" | "pending" | "confirmed"; + state?: "pending" | "confirmed"; /** @description The token symbol. If supplied on input for an existing on-chain token, this must match the on-chain information */ symbol?: string; /** @description Reference to the FireFly transaction used to create and broadcast this pool to the network */ @@ -17119,6 +17668,23 @@ export interface operations { id?: string; /** @description Token connector specific information about the pool. See your chosen token connector documentation for details */ info?: { [key: string]: any }; + /** @description A reference to an existing FFI, containing pre-registered type information for the token contract */ + interface?: { + /** + * Format: uuid + * @description The UUID of the FireFly interface + */ + id?: string; + /** @description The name of the FireFly interface */ + name?: string; + /** @description The version of the FireFly interface */ + version?: string; + }; + /** + * @description The interface encoding format supported by the connector for this token pool + * @enum {string} + */ + interfaceFormat?: "abi" | "ffi"; /** @description The signing key used to create the token pool. On input for token connectors that support on-chain deployment of new tokens (vs. only index existing ones) this determines the signing key used to create the token on-chain */ key?: string; /** @description A unique identifier for the pool, as provided by the token connector */ @@ -17128,6 +17694,8 @@ export interface operations { * @description The UUID of the broadcast message used to inform the network to index this pool */ message?: string; + /** @description The method definitions resolved by the token connector to be used by each token operation */ + methods?: any; /** @description The name of the token pool. Note the name is not validated against the description of the token on the blockchain */ name?: string; /** @description The namespace for the token pool */ @@ -17138,7 +17706,7 @@ export interface operations { * @description The current state of the token pool * @enum {string} */ - state?: "unknown" | "pending" | "confirmed"; + state?: "pending" | "confirmed"; /** @description The token symbol. If supplied on input for an existing on-chain token, this must match the on-chain information */ symbol?: string; /** @description Reference to the FireFly transaction used to create and broadcast this pool to the network */ @@ -17179,6 +17747,23 @@ export interface operations { id?: string; /** @description Token connector specific information about the pool. See your chosen token connector documentation for details */ info?: { [key: string]: any }; + /** @description A reference to an existing FFI, containing pre-registered type information for the token contract */ + interface?: { + /** + * Format: uuid + * @description The UUID of the FireFly interface + */ + id?: string; + /** @description The name of the FireFly interface */ + name?: string; + /** @description The version of the FireFly interface */ + version?: string; + }; + /** + * @description The interface encoding format supported by the connector for this token pool + * @enum {string} + */ + interfaceFormat?: "abi" | "ffi"; /** @description The signing key used to create the token pool. On input for token connectors that support on-chain deployment of new tokens (vs. only index existing ones) this determines the signing key used to create the token on-chain */ key?: string; /** @description A unique identifier for the pool, as provided by the token connector */ @@ -17188,6 +17773,8 @@ export interface operations { * @description The UUID of the broadcast message used to inform the network to index this pool */ message?: string; + /** @description The method definitions resolved by the token connector to be used by each token operation */ + methods?: any; /** @description The name of the token pool. Note the name is not validated against the description of the token on the blockchain */ name?: string; /** @description The namespace for the token pool */ @@ -17198,7 +17785,7 @@ export interface operations { * @description The current state of the token pool * @enum {string} */ - state?: "unknown" | "pending" | "confirmed"; + state?: "pending" | "confirmed"; /** @description The token symbol. If supplied on input for an existing on-chain token, this must match the on-chain information */ symbol?: string; /** @description Reference to the FireFly transaction used to create and broadcast this pool to the network */ @@ -17230,6 +17817,18 @@ export interface operations { connector?: string; /** @description An optional identifier to allow idempotent submission of requests. Stored on the transaction uniquely within a namespace */ idempotencyKey?: string; + /** @description A reference to an existing FFI, containing pre-registered type information for the token contract */ + interface?: { + /** + * Format: uuid + * @description The UUID of the FireFly interface + */ + id?: string; + /** @description The name of the FireFly interface */ + name?: string; + /** @description The version of the FireFly interface */ + version?: string; + }; /** @description The signing key used to create the token pool. On input for token connectors that support on-chain deployment of new tokens (vs. only index existing ones) this determines the signing key used to create the token on-chain */ key?: string; /** @description The name of the token pool. Note the name is not validated against the description of the token on the blockchain */ @@ -17280,6 +17879,23 @@ export interface operations { id?: string; /** @description Token connector specific information about the pool. See your chosen token connector documentation for details */ info?: { [key: string]: any }; + /** @description A reference to an existing FFI, containing pre-registered type information for the token contract */ + interface?: { + /** + * Format: uuid + * @description The UUID of the FireFly interface + */ + id?: string; + /** @description The name of the FireFly interface */ + name?: string; + /** @description The version of the FireFly interface */ + version?: string; + }; + /** + * @description The interface encoding format supported by the connector for this token pool + * @enum {string} + */ + interfaceFormat?: "abi" | "ffi"; /** @description The signing key used to create the token pool. On input for token connectors that support on-chain deployment of new tokens (vs. only index existing ones) this determines the signing key used to create the token on-chain */ key?: string; /** @description A unique identifier for the pool, as provided by the token connector */ @@ -17289,6 +17905,8 @@ export interface operations { * @description The UUID of the broadcast message used to inform the network to index this pool */ message?: string; + /** @description The method definitions resolved by the token connector to be used by each token operation */ + methods?: any; /** @description The name of the token pool. Note the name is not validated against the description of the token on the blockchain */ name?: string; /** @description The namespace for the token pool */ @@ -17299,7 +17917,7 @@ export interface operations { * @description The current state of the token pool * @enum {string} */ - state?: "unknown" | "pending" | "confirmed"; + state?: "pending" | "confirmed"; /** @description The token symbol. If supplied on input for an existing on-chain token, this must match the on-chain information */ symbol?: string; /** @description Reference to the FireFly transaction used to create and broadcast this pool to the network */ @@ -19474,6 +20092,10 @@ export interface operations { /** The operation ID key to get */ opid: string; }; + query: { + /** When set, the API will return additional status information if available */ + fetchstatus?: string; + }; header: { /** Server-side request timeout (milliseconds, or set a custom suffix like 10s) */ "Request-Timeout"?: string; @@ -21565,6 +22187,10 @@ export interface operations { /** Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^ */ id?: string; /** Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^ */ + interface?: string; + /** Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^ */ + interfaceformat?: string; + /** Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^ */ locator?: string; /** Data filter field. Prefixes supported: > >= < <= @ ^ ! !@ !^ */ message?: string; @@ -21617,6 +22243,23 @@ export interface operations { id?: string; /** @description Token connector specific information about the pool. See your chosen token connector documentation for details */ info?: { [key: string]: any }; + /** @description A reference to an existing FFI, containing pre-registered type information for the token contract */ + interface?: { + /** + * Format: uuid + * @description The UUID of the FireFly interface + */ + id?: string; + /** @description The name of the FireFly interface */ + name?: string; + /** @description The version of the FireFly interface */ + version?: string; + }; + /** + * @description The interface encoding format supported by the connector for this token pool + * @enum {string} + */ + interfaceFormat?: "abi" | "ffi"; /** @description The signing key used to create the token pool. On input for token connectors that support on-chain deployment of new tokens (vs. only index existing ones) this determines the signing key used to create the token on-chain */ key?: string; /** @description A unique identifier for the pool, as provided by the token connector */ @@ -21626,6 +22269,8 @@ export interface operations { * @description The UUID of the broadcast message used to inform the network to index this pool */ message?: string; + /** @description The method definitions resolved by the token connector to be used by each token operation */ + methods?: any; /** @description The name of the token pool. Note the name is not validated against the description of the token on the blockchain */ name?: string; /** @description The namespace for the token pool */ @@ -21636,7 +22281,7 @@ export interface operations { * @description The current state of the token pool * @enum {string} */ - state?: "unknown" | "pending" | "confirmed"; + state?: "pending" | "confirmed"; /** @description The token symbol. If supplied on input for an existing on-chain token, this must match the on-chain information */ symbol?: string; /** @description Reference to the FireFly transaction used to create and broadcast this pool to the network */ @@ -21693,6 +22338,23 @@ export interface operations { id?: string; /** @description Token connector specific information about the pool. See your chosen token connector documentation for details */ info?: { [key: string]: any }; + /** @description A reference to an existing FFI, containing pre-registered type information for the token contract */ + interface?: { + /** + * Format: uuid + * @description The UUID of the FireFly interface + */ + id?: string; + /** @description The name of the FireFly interface */ + name?: string; + /** @description The version of the FireFly interface */ + version?: string; + }; + /** + * @description The interface encoding format supported by the connector for this token pool + * @enum {string} + */ + interfaceFormat?: "abi" | "ffi"; /** @description The signing key used to create the token pool. On input for token connectors that support on-chain deployment of new tokens (vs. only index existing ones) this determines the signing key used to create the token on-chain */ key?: string; /** @description A unique identifier for the pool, as provided by the token connector */ @@ -21702,6 +22364,8 @@ export interface operations { * @description The UUID of the broadcast message used to inform the network to index this pool */ message?: string; + /** @description The method definitions resolved by the token connector to be used by each token operation */ + methods?: any; /** @description The name of the token pool. Note the name is not validated against the description of the token on the blockchain */ name?: string; /** @description The namespace for the token pool */ @@ -21712,7 +22376,7 @@ export interface operations { * @description The current state of the token pool * @enum {string} */ - state?: "unknown" | "pending" | "confirmed"; + state?: "pending" | "confirmed"; /** @description The token symbol. If supplied on input for an existing on-chain token, this must match the on-chain information */ symbol?: string; /** @description Reference to the FireFly transaction used to create and broadcast this pool to the network */ @@ -21753,6 +22417,23 @@ export interface operations { id?: string; /** @description Token connector specific information about the pool. See your chosen token connector documentation for details */ info?: { [key: string]: any }; + /** @description A reference to an existing FFI, containing pre-registered type information for the token contract */ + interface?: { + /** + * Format: uuid + * @description The UUID of the FireFly interface + */ + id?: string; + /** @description The name of the FireFly interface */ + name?: string; + /** @description The version of the FireFly interface */ + version?: string; + }; + /** + * @description The interface encoding format supported by the connector for this token pool + * @enum {string} + */ + interfaceFormat?: "abi" | "ffi"; /** @description The signing key used to create the token pool. On input for token connectors that support on-chain deployment of new tokens (vs. only index existing ones) this determines the signing key used to create the token on-chain */ key?: string; /** @description A unique identifier for the pool, as provided by the token connector */ @@ -21762,6 +22443,8 @@ export interface operations { * @description The UUID of the broadcast message used to inform the network to index this pool */ message?: string; + /** @description The method definitions resolved by the token connector to be used by each token operation */ + methods?: any; /** @description The name of the token pool. Note the name is not validated against the description of the token on the blockchain */ name?: string; /** @description The namespace for the token pool */ @@ -21772,7 +22455,7 @@ export interface operations { * @description The current state of the token pool * @enum {string} */ - state?: "unknown" | "pending" | "confirmed"; + state?: "pending" | "confirmed"; /** @description The token symbol. If supplied on input for an existing on-chain token, this must match the on-chain information */ symbol?: string; /** @description Reference to the FireFly transaction used to create and broadcast this pool to the network */ @@ -21804,6 +22487,18 @@ export interface operations { connector?: string; /** @description An optional identifier to allow idempotent submission of requests. Stored on the transaction uniquely within a namespace */ idempotencyKey?: string; + /** @description A reference to an existing FFI, containing pre-registered type information for the token contract */ + interface?: { + /** + * Format: uuid + * @description The UUID of the FireFly interface + */ + id?: string; + /** @description The name of the FireFly interface */ + name?: string; + /** @description The version of the FireFly interface */ + version?: string; + }; /** @description The signing key used to create the token pool. On input for token connectors that support on-chain deployment of new tokens (vs. only index existing ones) this determines the signing key used to create the token on-chain */ key?: string; /** @description The name of the token pool. Note the name is not validated against the description of the token on the blockchain */ @@ -21852,6 +22547,23 @@ export interface operations { id?: string; /** @description Token connector specific information about the pool. See your chosen token connector documentation for details */ info?: { [key: string]: any }; + /** @description A reference to an existing FFI, containing pre-registered type information for the token contract */ + interface?: { + /** + * Format: uuid + * @description The UUID of the FireFly interface + */ + id?: string; + /** @description The name of the FireFly interface */ + name?: string; + /** @description The version of the FireFly interface */ + version?: string; + }; + /** + * @description The interface encoding format supported by the connector for this token pool + * @enum {string} + */ + interfaceFormat?: "abi" | "ffi"; /** @description The signing key used to create the token pool. On input for token connectors that support on-chain deployment of new tokens (vs. only index existing ones) this determines the signing key used to create the token on-chain */ key?: string; /** @description A unique identifier for the pool, as provided by the token connector */ @@ -21861,6 +22573,8 @@ export interface operations { * @description The UUID of the broadcast message used to inform the network to index this pool */ message?: string; + /** @description The method definitions resolved by the token connector to be used by each token operation */ + methods?: any; /** @description The name of the token pool. Note the name is not validated against the description of the token on the blockchain */ name?: string; /** @description The namespace for the token pool */ @@ -21871,7 +22585,7 @@ export interface operations { * @description The current state of the token pool * @enum {string} */ - state?: "unknown" | "pending" | "confirmed"; + state?: "pending" | "confirmed"; /** @description The token symbol. If supplied on input for an existing on-chain token, this must match the on-chain information */ symbol?: string; /** @description Reference to the FireFly transaction used to create and broadcast this pool to the network */ From aa677abb41999ca05d694ddca0a4a93ddb1611da Mon Sep 17 00:00:00 2001 From: Andrew Richardson Date: Mon, 16 Jan 2023 15:34:51 -0500 Subject: [PATCH 3/3] Add method for deleteData Signed-off-by: Andrew Richardson --- lib/firefly.ts | 9 +++++++-- lib/http.ts | 6 ++++-- lib/interfaces.ts | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/firefly.ts b/lib/firefly.ts index 8e25714..5bbebff 100644 --- a/lib/firefly.ts +++ b/lib/firefly.ts @@ -76,6 +76,7 @@ import { FireFlyUpdateIdentityRequest, FireFlyReplaceOptions, FireFlyUpdateOptions, + FireFlyDeleteOptions, } from './interfaces'; import { FireFlyWebSocket, FireFlyWebSocketCallback } from './websocket'; import HttpBase, { mapConfig } from './http'; @@ -207,8 +208,8 @@ export default class FireFly extends HttpBase { return this.replaceOne('/subscriptions', sub, options); } - async deleteSubscription(subId: string) { - await this.deleteOne(`/subscriptions/${subId}`); + async deleteSubscription(subId: string, options?: FireFlyDeleteOptions) { + await this.deleteOne(`/subscriptions/${subId}`, options); } getData(id: string, options?: FireFlyGetOptions): Promise { @@ -276,6 +277,10 @@ export default class FireFly extends HttpBase { return this.createOne(`/data/${id}/blob/publish`, {}, options); } + async deleteData(id: string, options?: FireFlyDeleteOptions) { + await this.deleteOne(`/data/${id}`, options); + } + getBatches( filter?: FireFlyBatchFilter, options?: FireFlyGetOptions, diff --git a/lib/http.ts b/lib/http.ts index a8beef5..b055de5 100644 --- a/lib/http.ts +++ b/lib/http.ts @@ -7,6 +7,7 @@ import { FireFlyError, FireFlyReplaceOptions, FireFlyUpdateOptions, + FireFlyDeleteOptions, } from './interfaces'; function isSuccess(status: number) { @@ -19,6 +20,7 @@ export function mapConfig( | FireFlyUpdateOptions | FireFlyReplaceOptions | FireFlyCreateOptions + | FireFlyDeleteOptions | undefined, params?: any, ): AxiosRequestConfig { @@ -115,8 +117,8 @@ export default class HttpBase { return response.data; } - protected async deleteOne(url: string) { - await this.wrapError(this.http.delete(url)); + protected async deleteOne(url: string, options?: FireFlyDeleteOptions) { + await this.wrapError(this.http.delete(url, mapConfig(options))); } onError(handler: (err: FireFlyError) => void) { diff --git a/lib/interfaces.ts b/lib/interfaces.ts index 91090f9..9e7ad33 100644 --- a/lib/interfaces.ts +++ b/lib/interfaces.ts @@ -28,6 +28,7 @@ interface FireFlyBaseHttpOptions { export interface FireFlyGetOptions extends FireFlyBaseHttpOptions {} export interface FireFlyUpdateOptions extends FireFlyBaseHttpOptions {} export interface FireFlyReplaceOptions extends FireFlyBaseHttpOptions {} +export interface FireFlyDeleteOptions extends FireFlyBaseHttpOptions {} export interface FireFlyCreateOptions extends FireFlyBaseHttpOptions { confirm?: boolean;