@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/cli/index.js CHANGED
@@ -149,6 +149,7 @@ var RainfallClient = class {
149
149
  defaultRetries;
150
150
  defaultRetryDelay;
151
151
  lastRateLimitInfo;
152
+ subscriberId;
152
153
  constructor(config) {
153
154
  this.apiKey = config.apiKey;
154
155
  this.baseUrl = config.baseUrl || DEFAULT_BASE_URL;
@@ -179,7 +180,7 @@ var RainfallClient = class {
179
180
  const response = await fetch(url, {
180
181
  method,
181
182
  headers: {
182
- "Authorization": `Bearer ${this.apiKey}`,
183
+ "x-api-key": this.apiKey,
183
184
  "Content-Type": "application/json",
184
185
  "Accept": "application/json",
185
186
  "X-Rainfall-SDK-Version": "0.1.0",
@@ -239,7 +240,8 @@ var RainfallClient = class {
239
240
  * Execute a tool/node by ID
240
241
  */
241
242
  async executeTool(toolId, params, options) {
242
- return this.request(`/tools/${toolId}`, {
243
+ const subscriberId = await this.ensureSubscriberId();
244
+ return this.request(`/olympic/subscribers/${subscriberId}/nodes/${toolId}`, {
243
245
  method: "POST",
244
246
  body: params
245
247
  }, options);
@@ -248,19 +250,58 @@ var RainfallClient = class {
248
250
  * List all available tools
249
251
  */
250
252
  async listTools() {
251
- return this.request("/tools");
253
+ const subscriberId = await this.ensureSubscriberId();
254
+ const result = await this.request(`/olympic/subscribers/${subscriberId}/nodes/_utils/node-list`);
255
+ if (result.keys && Array.isArray(result.keys)) {
256
+ return result.keys.map((key) => ({
257
+ id: key,
258
+ name: key,
259
+ description: "",
260
+ category: "general"
261
+ }));
262
+ }
263
+ return result.nodes || [];
252
264
  }
253
265
  /**
254
266
  * Get tool schema/parameters
255
267
  */
256
268
  async getToolSchema(toolId) {
257
- return this.request(`/tools/${toolId}/schema`);
269
+ const subscriberId = await this.ensureSubscriberId();
270
+ return this.request(`/olympic/subscribers/${subscriberId}/nodes/${toolId}/params`);
258
271
  }
259
272
  /**
260
273
  * Get subscriber info
261
274
  */
262
275
  async getMe() {
263
- return this.request("/me");
276
+ const result = await this.request("/olympic/subscribers/me");
277
+ if (result.subscriber?.id) {
278
+ this.subscriberId = result.subscriber.id;
279
+ }
280
+ const subscriber = result.subscriber;
281
+ return {
282
+ id: subscriber.id,
283
+ name: subscriber.name,
284
+ email: subscriber.google_id,
285
+ billingStatus: subscriber.billing_status,
286
+ plan: subscriber.billing_status,
287
+ usage: {
288
+ callsThisMonth: subscriber.metadata?.usage?.callsThisMonth ?? 0,
289
+ callsLimit: subscriber.metadata?.usage?.callsLimit ?? 5e3
290
+ }
291
+ };
292
+ }
293
+ /**
294
+ * Ensure we have a subscriber ID, fetching it if necessary
295
+ */
296
+ async ensureSubscriberId() {
297
+ if (this.subscriberId) {
298
+ return this.subscriberId;
299
+ }
300
+ const me = await this.getMe();
301
+ if (!me.id) {
302
+ throw new RainfallError("Failed to get subscriber ID", "NO_SUBSCRIBER_ID");
303
+ }
304
+ return me.id;
264
305
  }
265
306
  sleep(ms) {
266
307
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -796,9 +837,9 @@ async function authLogin(args) {
796
837
  const rainfall = new Rainfall({ apiKey });
797
838
  const me = await rainfall.getMe();
798
839
  saveConfig({ apiKey });
799
- console.log(`\u2713 Authenticated as ${me.email}`);
800
- console.log(` Plan: ${me.plan}`);
801
- console.log(` Usage: ${me.usage.callsThisMonth.toLocaleString()} / ${me.usage.callsLimit.toLocaleString()} calls this month`);
840
+ console.log(`\u2713 Authenticated as ${me.name || me.email || "Unknown"}`);
841
+ console.log(` Plan: ${me.billingStatus || me.plan || "N/A"}`);
842
+ console.log(` Usage: ${me.usage?.callsThisMonth?.toLocaleString() || 0} / ${me.usage?.callsLimit?.toLocaleString() || "Unlimited"} calls this month`);
802
843
  } catch (error) {
803
844
  console.error("Error: Invalid API key");
804
845
  process.exit(1);
@@ -818,9 +859,9 @@ async function authStatus() {
818
859
  try {
819
860
  const rainfall = new Rainfall({ apiKey: config.apiKey });
820
861
  const me = await rainfall.getMe();
821
- console.log(`Authenticated as ${me.email}`);
822
- console.log(`Plan: ${me.plan}`);
823
- console.log(`Usage: ${me.usage.callsThisMonth.toLocaleString()} / ${me.usage.callsLimit.toLocaleString()} calls this month`);
862
+ console.log(`Authenticated as ${me.name || me.email || "Unknown"}`);
863
+ console.log(`Plan: ${me.billingStatus || me.plan || "N/A"}`);
864
+ console.log(`Usage: ${me.usage?.callsThisMonth?.toLocaleString() || 0} / ${me.usage?.callsLimit?.toLocaleString() || "Unlimited"} calls this month`);
824
865
  } catch (error) {
825
866
  console.log("Authentication expired or invalid");
826
867
  console.log("Run: rainfall auth login <api-key>");
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  Rainfall
4
- } from "../chunk-UP45HOXN.mjs";
4
+ } from "../chunk-OT6N7K6Q.mjs";
5
5
 
6
6
  // src/cli/index.ts
7
7
  import { readFileSync, existsSync, writeFileSync, mkdirSync } from "fs";
@@ -86,9 +86,9 @@ async function authLogin(args) {
86
86
  const rainfall = new Rainfall({ apiKey });
87
87
  const me = await rainfall.getMe();
88
88
  saveConfig({ apiKey });
89
- console.log(`\u2713 Authenticated as ${me.email}`);
90
- console.log(` Plan: ${me.plan}`);
91
- console.log(` Usage: ${me.usage.callsThisMonth.toLocaleString()} / ${me.usage.callsLimit.toLocaleString()} calls this month`);
89
+ console.log(`\u2713 Authenticated as ${me.name || me.email || "Unknown"}`);
90
+ console.log(` Plan: ${me.billingStatus || me.plan || "N/A"}`);
91
+ console.log(` Usage: ${me.usage?.callsThisMonth?.toLocaleString() || 0} / ${me.usage?.callsLimit?.toLocaleString() || "Unlimited"} calls this month`);
92
92
  } catch (error) {
93
93
  console.error("Error: Invalid API key");
94
94
  process.exit(1);
@@ -108,9 +108,9 @@ async function authStatus() {
108
108
  try {
109
109
  const rainfall = new Rainfall({ apiKey: config.apiKey });
110
110
  const me = await rainfall.getMe();
111
- console.log(`Authenticated as ${me.email}`);
112
- console.log(`Plan: ${me.plan}`);
113
- console.log(`Usage: ${me.usage.callsThisMonth.toLocaleString()} / ${me.usage.callsLimit.toLocaleString()} calls this month`);
111
+ console.log(`Authenticated as ${me.name || me.email || "Unknown"}`);
112
+ console.log(`Plan: ${me.billingStatus || me.plan || "N/A"}`);
113
+ console.log(`Usage: ${me.usage?.callsThisMonth?.toLocaleString() || 0} / ${me.usage?.callsLimit?.toLocaleString() || "Unlimited"} calls this month`);
114
114
  } catch (error) {
115
115
  console.log("Authentication expired or invalid");
116
116
  console.log("Run: rainfall auth login <api-key>");