UNPKG

@fairmint/canton-node-sdk

Version:
84 lines 2.85 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SimpleApiOperation = exports.ApiOperation = void 0; const zod_1 = require("zod"); const errors_1 = require("../errors"); /** Abstract base class for API operations with parameter validation and request handling */ class ApiOperation { constructor(client) { this.client = client; } validateParams(params, schema) { try { return schema.parse(params); } catch (error) { if (error instanceof zod_1.z.ZodError) { throw new errors_1.ValidationError(`Parameter validation failed: ${error.issues.map(e => `${e.path.join('.')}: ${e.message}`).join(', ')}`); } throw error; } } async makeGetRequest(url, config = {}) { return this.client.makeGetRequest(url, config); } async makePostRequest(url, data, config = {}) { return this.client.makePostRequest(url, data, config); } async makeDeleteRequest(url, config = {}) { return this.client.makeDeleteRequest(url, config); } async makePatchRequest(url, data, config = {}) { return this.client.makePatchRequest(url, data, config); } getManagedParties() { return this.client.getManagedParties(); } getPartyId() { return this.client.getPartyId(); } getApiUrl() { return this.client.getApiUrl(); } buildPartyList(additionalParties = []) { return this.client.buildPartyList(additionalParties); } } exports.ApiOperation = ApiOperation; /** Abstract base class for simple API operations that don't require authentication */ class SimpleApiOperation { constructor(client) { this.client = client; } validateParams(params, schema) { try { return schema.parse(params); } catch (error) { if (error instanceof zod_1.z.ZodError) { throw new errors_1.ValidationError(`Parameter validation failed: ${error.issues.map(e => `${e.path.join('.')}: ${e.message}`).join(', ')}`); } throw error; } } async makeGetRequest(url, config = {}) { return this.client.makeGetRequest(url, config); } async makePostRequest(url, data, config = {}) { return this.client.makePostRequest(url, data, config); } async makeDeleteRequest(url, config = {}) { return this.client.makeDeleteRequest(url, config); } async makePatchRequest(url, data, config = {}) { return this.client.makePatchRequest(url, data, config); } getPartyId() { return this.client.getPartyId(); } getApiUrl() { return this.client.getApiUrl(); } } exports.SimpleApiOperation = SimpleApiOperation; //# sourceMappingURL=ApiOperation.js.map