@rainfall-devkit/sdk 0.1.3 → 0.1.4

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/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AI, a as ApiError, b as ApiResponse, c as Articles, d as AuthenticationError, D as Data, I as Integrations, M as Memory, N as NetworkError, e as NotFoundError, R as Rainfall, f as RainfallClient, g as RainfallConfig, h as RainfallError, i as RateLimitError, j as RateLimitInfo, k as RequestOptions, S as ServerError, T as TimeoutError, l as ToolNotFoundError, m as ToolSchema, U as Utils, V as ValidationError, W as Web } from './errors-DdRTwxpT.mjs';
1
+ export { A as AI, a as ApiError, b as ApiResponse, c as Articles, d as AuthenticationError, D as Data, I as Integrations, M as Memory, N as NetworkError, e as NotFoundError, R as Rainfall, f as RainfallClient, g as RainfallConfig, h as RainfallError, i as RateLimitError, j as RateLimitInfo, k as RequestOptions, S as ServerError, T as TimeoutError, l as ToolNotFoundError, m as ToolSchema, U as Utils, V as ValidationError, W as Web } from './errors-COkXMRZk.mjs';
2
2
 
3
3
  /**
4
4
  * Rainfall SDK - Official SDK for Rainfall API
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AI, a as ApiError, b as ApiResponse, c as Articles, d as AuthenticationError, D as Data, I as Integrations, M as Memory, N as NetworkError, e as NotFoundError, R as Rainfall, f as RainfallClient, g as RainfallConfig, h as RainfallError, i as RateLimitError, j as RateLimitInfo, k as RequestOptions, S as ServerError, T as TimeoutError, l as ToolNotFoundError, m as ToolSchema, U as Utils, V as ValidationError, W as Web } from './errors-DdRTwxpT.js';
1
+ export { A as AI, a as ApiError, b as ApiResponse, c as Articles, d as AuthenticationError, D as Data, I as Integrations, M as Memory, N as NetworkError, e as NotFoundError, R as Rainfall, f as RainfallClient, g as RainfallConfig, h as RainfallError, i as RateLimitError, j as RateLimitInfo, k as RequestOptions, S as ServerError, T as TimeoutError, l as ToolNotFoundError, m as ToolSchema, U as Utils, V as ValidationError, W as Web } from './errors-COkXMRZk.js';
2
2
 
3
3
  /**
4
4
  * Rainfall SDK - Official SDK for Rainfall API
package/dist/index.js CHANGED
@@ -185,6 +185,7 @@ var RainfallClient = class {
185
185
  defaultRetries;
186
186
  defaultRetryDelay;
187
187
  lastRateLimitInfo;
188
+ subscriberId;
188
189
  constructor(config) {
189
190
  this.apiKey = config.apiKey;
190
191
  this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
@@ -215,7 +216,7 @@ var RainfallClient = class {
215
216
  const response = await fetch(url, {
216
217
  method,
217
218
  headers: {
218
- "Authorization": `Bearer ${this.apiKey}`,
219
+ "x-api-key": this.apiKey,
219
220
  "Content-Type": "application/json",
220
221
  "Accept": "application/json",
221
222
  "X-Rainfall-SDK-Version": "0.1.0",
@@ -275,7 +276,8 @@ var RainfallClient = class {
275
276
  * Execute a tool/node by ID
276
277
  */
277
278
  async executeTool(toolId, params, options) {
278
- return this.request(`/tools/${toolId}`, {
279
+ const subscriberId = await this.ensureSubscriberId();
280
+ return this.request(`/olympic/subscribers/${subscriberId}/nodes/${toolId}`, {
279
281
  method: "POST",
280
282
  body: params
281
283
  }, options);
@@ -284,19 +286,58 @@ var RainfallClient = class {
284
286
  * List all available tools
285
287
  */
286
288
  async listTools() {
287
- return this.request("/tools");
289
+ const subscriberId = await this.ensureSubscriberId();
290
+ const result = await this.request(`/olympic/subscribers/${subscriberId}/nodes/_utils/node-list`);
291
+ if (result.keys && Array.isArray(result.keys)) {
292
+ return result.keys.map((key) => ({
293
+ id: key,
294
+ name: key,
295
+ description: "",
296
+ category: "general"
297
+ }));
298
+ }
299
+ return result.nodes || [];
288
300
  }
289
301
  /**
290
302
  * Get tool schema/parameters
291
303
  */
292
304
  async getToolSchema(toolId) {
293
- return this.request(`/tools/${toolId}/schema`);
305
+ const subscriberId = await this.ensureSubscriberId();
306
+ return this.request(`/olympic/subscribers/${subscriberId}/nodes/${toolId}/params`);
294
307
  }
295
308
  /**
296
309
  * Get subscriber info
297
310
  */
298
311
  async getMe() {
299
- return this.request("/me");
312
+ const result = await this.request("/olympic/subscribers/me");
313
+ if (result.subscriber?.id) {
314
+ this.subscriberId = result.subscriber.id;
315
+ }
316
+ const subscriber = result.subscriber;
317
+ return {
318
+ id: subscriber.id,
319
+ name: subscriber.name,
320
+ email: subscriber.google_id,
321
+ billingStatus: subscriber.billing_status,
322
+ plan: subscriber.billing_status,
323
+ usage: {
324
+ callsThisMonth: subscriber.metadata?.usage?.callsThisMonth ?? 0,
325
+ callsLimit: subscriber.metadata?.usage?.callsLimit ?? 5e3
326
+ }
327
+ };
328
+ }
329
+ /**
330
+ * Ensure we have a subscriber ID, fetching it if necessary
331
+ */
332
+ async ensureSubscriberId() {
333
+ if (this.subscriberId) {
334
+ return this.subscriberId;
335
+ }
336
+ const me = await this.getMe();
337
+ if (!me.id) {
338
+ throw new RainfallError("Failed to get subscriber ID", "NO_SUBSCRIBER_ID");
339
+ }
340
+ return me.id;
300
341
  }
301
342
  sleep(ms) {
302
343
  return new Promise((resolve) => setTimeout(resolve, ms));
package/dist/index.mjs CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  TimeoutError,
11
11
  ToolNotFoundError,
12
12
  ValidationError
13
- } from "./chunk-UP45HOXN.mjs";
13
+ } from "./chunk-OT6N7K6Q.mjs";
14
14
 
15
15
  // src/index.ts
16
16
  var VERSION = "0.1.0";
package/dist/mcp.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { g as RainfallConfig, R as Rainfall } from './errors-DdRTwxpT.mjs';
2
- export { A as AI, a as ApiError, b as ApiResponse, c as Articles, d as AuthenticationError, D as Data, I as Integrations, M as Memory, N as NetworkError, e as NotFoundError, h as RainfallError, i as RateLimitError, j as RateLimitInfo, k as RequestOptions, S as ServerError, T as TimeoutError, l as ToolNotFoundError, m as ToolSchema, U as Utils, V as ValidationError, W as Web, p as parseErrorResponse } from './errors-DdRTwxpT.mjs';
1
+ import { g as RainfallConfig, R as Rainfall } from './errors-COkXMRZk.mjs';
2
+ export { A as AI, a as ApiError, b as ApiResponse, c as Articles, d as AuthenticationError, D as Data, I as Integrations, M as Memory, N as NetworkError, e as NotFoundError, h as RainfallError, i as RateLimitError, j as RateLimitInfo, k as RequestOptions, S as ServerError, T as TimeoutError, l as ToolNotFoundError, m as ToolSchema, U as Utils, V as ValidationError, W as Web, p as parseErrorResponse } from './errors-COkXMRZk.mjs';
3
3
 
4
4
  /**
5
5
  * MCP (Model Context Protocol) server export for Rainfall SDK
package/dist/mcp.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { g as RainfallConfig, R as Rainfall } from './errors-DdRTwxpT.js';
2
- export { A as AI, a as ApiError, b as ApiResponse, c as Articles, d as AuthenticationError, D as Data, I as Integrations, M as Memory, N as NetworkError, e as NotFoundError, h as RainfallError, i as RateLimitError, j as RateLimitInfo, k as RequestOptions, S as ServerError, T as TimeoutError, l as ToolNotFoundError, m as ToolSchema, U as Utils, V as ValidationError, W as Web, p as parseErrorResponse } from './errors-DdRTwxpT.js';
1
+ import { g as RainfallConfig, R as Rainfall } from './errors-COkXMRZk.js';
2
+ export { A as AI, a as ApiError, b as ApiResponse, c as Articles, d as AuthenticationError, D as Data, I as Integrations, M as Memory, N as NetworkError, e as NotFoundError, h as RainfallError, i as RateLimitError, j as RateLimitInfo, k as RequestOptions, S as ServerError, T as TimeoutError, l as ToolNotFoundError, m as ToolSchema, U as Utils, V as ValidationError, W as Web, p as parseErrorResponse } from './errors-COkXMRZk.js';
3
3
 
4
4
  /**
5
5
  * MCP (Model Context Protocol) server export for Rainfall SDK
package/dist/mcp.js CHANGED
@@ -185,6 +185,7 @@ var RainfallClient = class {
185
185
  defaultRetries;
186
186
  defaultRetryDelay;
187
187
  lastRateLimitInfo;
188
+ subscriberId;
188
189
  constructor(config) {
189
190
  this.apiKey = config.apiKey;
190
191
  this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
@@ -215,7 +216,7 @@ var RainfallClient = class {
215
216
  const response = await fetch(url, {
216
217
  method,
217
218
  headers: {
218
- "Authorization": `Bearer ${this.apiKey}`,
219
+ "x-api-key": this.apiKey,
219
220
  "Content-Type": "application/json",
220
221
  "Accept": "application/json",
221
222
  "X-Rainfall-SDK-Version": "0.1.0",
@@ -275,7 +276,8 @@ var RainfallClient = class {
275
276
  * Execute a tool/node by ID
276
277
  */
277
278
  async executeTool(toolId, params, options) {
278
- return this.request(`/tools/${toolId}`, {
279
+ const subscriberId = await this.ensureSubscriberId();
280
+ return this.request(`/olympic/subscribers/${subscriberId}/nodes/${toolId}`, {
279
281
  method: "POST",
280
282
  body: params
281
283
  }, options);
@@ -284,19 +286,58 @@ var RainfallClient = class {
284
286
  * List all available tools
285
287
  */
286
288
  async listTools() {
287
- return this.request("/tools");
289
+ const subscriberId = await this.ensureSubscriberId();
290
+ const result = await this.request(`/olympic/subscribers/${subscriberId}/nodes/_utils/node-list`);
291
+ if (result.keys && Array.isArray(result.keys)) {
292
+ return result.keys.map((key) => ({
293
+ id: key,
294
+ name: key,
295
+ description: "",
296
+ category: "general"
297
+ }));
298
+ }
299
+ return result.nodes || [];
288
300
  }
289
301
  /**
290
302
  * Get tool schema/parameters
291
303
  */
292
304
  async getToolSchema(toolId) {
293
- return this.request(`/tools/${toolId}/schema`);
305
+ const subscriberId = await this.ensureSubscriberId();
306
+ return this.request(`/olympic/subscribers/${subscriberId}/nodes/${toolId}/params`);
294
307
  }
295
308
  /**
296
309
  * Get subscriber info
297
310
  */
298
311
  async getMe() {
299
- return this.request("/me");
312
+ const result = await this.request("/olympic/subscribers/me");
313
+ if (result.subscriber?.id) {
314
+ this.subscriberId = result.subscriber.id;
315
+ }
316
+ const subscriber = result.subscriber;
317
+ return {
318
+ id: subscriber.id,
319
+ name: subscriber.name,
320
+ email: subscriber.google_id,
321
+ billingStatus: subscriber.billing_status,
322
+ plan: subscriber.billing_status,
323
+ usage: {
324
+ callsThisMonth: subscriber.metadata?.usage?.callsThisMonth ?? 0,
325
+ callsLimit: subscriber.metadata?.usage?.callsLimit ?? 5e3
326
+ }
327
+ };
328
+ }
329
+ /**
330
+ * Ensure we have a subscriber ID, fetching it if necessary
331
+ */
332
+ async ensureSubscriberId() {
333
+ if (this.subscriberId) {
334
+ return this.subscriberId;
335
+ }
336
+ const me = await this.getMe();
337
+ if (!me.id) {
338
+ throw new RainfallError("Failed to get subscriber ID", "NO_SUBSCRIBER_ID");
339
+ }
340
+ return me.id;
300
341
  }
301
342
  sleep(ms) {
302
343
  return new Promise((resolve) => setTimeout(resolve, ms));
package/dist/mcp.mjs CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  ToolNotFoundError,
11
11
  ValidationError,
12
12
  parseErrorResponse
13
- } from "./chunk-UP45HOXN.mjs";
13
+ } from "./chunk-OT6N7K6Q.mjs";
14
14
 
15
15
  // src/mcp.ts
16
16
  function createRainfallMCPServer(config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainfall-devkit/sdk",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "Official SDK for Rainfall API - 200+ tools for building AI-powered applications",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",