@limitly/limitly-nextjs
Version:
Official Next.js SDK for Limitly - API Key management, plans, users and request validation optimized for server-side
95 lines • 2.97 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.PlansModule = void 0;
/**
* Module for managing Plans
* Optimized for Next.js server-side rendering
*/
class PlansModule {
client;
constructor(client) {
this.client = client;
}
/**
* Lists all plans
* @param options - Request options including Next.js cache options
* @returns Promise with paginated plans
*/
async list(options) {
return this.client.get('/plans', options);
}
/**
* Creates a new plan
* @param data - Plan creation data
* @param options - Request options
* @returns Promise with created plan
*/
async create(data, options) {
return this.client.post('/plans', data, options);
}
/**
* Gets a specific plan by ID
* @param planId - The plan ID
* @param options - Request options including Next.js cache options
* @returns Promise with plan details
*/
async get(planId, options) {
return this.client.get(`/plans/${planId}`, options);
}
/**
* Updates an existing plan
* @param planId - The plan ID
* @param data - Update data
* @param options - Request options
* @returns Promise with updated plan
*/
async update(planId, data, options) {
return this.client.put(`/plans/${planId}`, data, options);
}
/**
* Deletes a plan
* @param planId - The plan ID
* @param options - Request options
* @returns Promise with deletion confirmation
*/
async delete(planId, options) {
return this.client.delete(`/plans/${planId}`, options);
}
/**
* Gets usage statistics for a plan
* @param planId - The plan ID
* @param options - Request options including Next.js cache options
* @returns Promise with plan usage statistics
*/
async getUsage(planId, options) {
return this.client.get(`/plans/${planId}/usage`, options);
}
/**
* Gets all users assigned to a plan
* @param planId - The plan ID
* @param options - Request options including Next.js cache options
* @returns Promise with plan users
*/
async getUsers(planId, options) {
return this.client.get(`/plans/${planId}/users`, options);
}
/**
* Gets all API Keys assigned to a plan
* @param planId - The plan ID
* @param options - Request options including Next.js cache options
* @returns Promise with plan API keys
*/
async getKeys(planId, options) {
return this.client.get(`/plans/${planId}/keys`, options);
}
/**
* Gets plans with usage statistics (optimized for Next.js)
* @param options - Request options
* @returns Promise with plans and their usage
*/
async listWithUsage(options) {
return this.client.get('/plans/with-usage', options);
}
}
exports.PlansModule = PlansModule;
//# sourceMappingURL=plans.js.map