UNPKG

watchtower-node-sdk

Version:

A TypeScript Node.js SDK for the Watchtower API, providing API key management, connection string generation, and more

46 lines 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ItemsEndpoint = void 0; const base_1 = require("../base"); const errors_1 = require("../../errors"); class ItemsEndpoint extends base_1.BaseEndpoint { constructor(client) { super(client, '/api/items'); } validateRequiredKeys(data) { if (!data.organization_apikey) { throw new errors_1.InvalidRequestError('organization_apikey is required'); } if (!data.app_apikey) { throw new errors_1.InvalidRequestError('app_apikey is required'); } } /** * List all items for an app/tenant * @param data - The list items request parameters * @returns Promise with the list items response * @throws {InvalidRequestError} If required fields are missing * @throws {AuthenticationError} If API keys are invalid * @throws {ServerError} If server encounters an error */ async listItems(data) { this.validateRequiredKeys(data); try { return await this.get('', { params: data }); } catch (error) { if (error.response?.status === 400) { throw new errors_1.InvalidRequestError(error.response.data?.message || 'Invalid request'); } if (error.response?.status === 401) { throw new errors_1.AuthenticationError('Invalid API keys'); } if (error.response?.status === 500) { throw new errors_1.ServerError('Internal server error'); } throw error; } } } exports.ItemsEndpoint = ItemsEndpoint; //# sourceMappingURL=handler.js.map