@agentcash/router 1.2.5 → 1.2.6

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.cjs CHANGED
@@ -2301,7 +2301,7 @@ function deriveTag(routeKey) {
2301
2301
  return routeKey.split("/")[0].split("-").map((w) => w[0].toUpperCase() + w.slice(1)).join(" ");
2302
2302
  }
2303
2303
  function buildOperation(routeKey, entry, tag) {
2304
- const protocols = entry.protocols.length > 0 ? entry.protocols : void 0;
2304
+ const protocols = entry.protocols.length > 0 ? entry.protocols.map(toProtocolObject) : void 0;
2305
2305
  const paymentRequired = Boolean(entry.pricing) || entry.authMode === "paid";
2306
2306
  const requiresSiwxScheme = entry.authMode === "siwx" || Boolean(entry.siwxEnabled);
2307
2307
  const requiresApiKeyScheme = Boolean(entry.apiKeyResolver) && entry.authMode !== "siwx";
@@ -2361,19 +2361,27 @@ function buildOperation(routeKey, entry, tag) {
2361
2361
  requiresApiKeyScheme
2362
2362
  };
2363
2363
  }
2364
+ function toProtocolObject(protocol) {
2365
+ if (protocol === "mpp") {
2366
+ return { mpp: { method: "", intent: "", currency: "" } };
2367
+ }
2368
+ return { [protocol]: {} };
2369
+ }
2364
2370
  function buildPricingInfo(entry) {
2365
2371
  if (!entry.pricing) return void 0;
2366
2372
  if (typeof entry.pricing === "string") {
2367
2373
  return {
2368
- pricingMode: "fixed",
2369
- price: entry.pricing
2374
+ price: { mode: "fixed", currency: "USD", amount: entry.pricing }
2370
2375
  };
2371
2376
  }
2372
2377
  if (typeof entry.pricing === "function") {
2373
2378
  return {
2374
- pricingMode: "quote",
2375
- ...entry.minPrice ? { minPrice: entry.minPrice } : {},
2376
- ...entry.maxPrice ? { maxPrice: entry.maxPrice } : {}
2379
+ price: {
2380
+ mode: "dynamic",
2381
+ currency: "USD",
2382
+ min: entry.minPrice ?? "0",
2383
+ max: entry.maxPrice ?? "0"
2384
+ }
2377
2385
  };
2378
2386
  }
2379
2387
  if ("tiers" in entry.pricing) {
@@ -2383,19 +2391,20 @@ function buildPricingInfo(entry) {
2383
2391
  if (Number.isFinite(min) && Number.isFinite(max)) {
2384
2392
  if (min === max) {
2385
2393
  return {
2386
- pricingMode: "fixed",
2387
- price: String(min)
2394
+ price: { mode: "fixed", currency: "USD", amount: String(min) }
2388
2395
  };
2389
2396
  }
2390
2397
  return {
2391
- pricingMode: "range",
2392
- minPrice: String(min),
2393
- maxPrice: String(max)
2398
+ price: { mode: "dynamic", currency: "USD", min: String(min), max: String(max) }
2394
2399
  };
2395
2400
  }
2396
2401
  return {
2397
- pricingMode: "quote",
2398
- ...entry.maxPrice ? { maxPrice: entry.maxPrice } : {}
2402
+ price: {
2403
+ mode: "dynamic",
2404
+ currency: "USD",
2405
+ min: "0",
2406
+ max: entry.maxPrice ?? "0"
2407
+ }
2399
2408
  };
2400
2409
  }
2401
2410
  return void 0;
package/dist/index.js CHANGED
@@ -2262,7 +2262,7 @@ function deriveTag(routeKey) {
2262
2262
  return routeKey.split("/")[0].split("-").map((w) => w[0].toUpperCase() + w.slice(1)).join(" ");
2263
2263
  }
2264
2264
  function buildOperation(routeKey, entry, tag) {
2265
- const protocols = entry.protocols.length > 0 ? entry.protocols : void 0;
2265
+ const protocols = entry.protocols.length > 0 ? entry.protocols.map(toProtocolObject) : void 0;
2266
2266
  const paymentRequired = Boolean(entry.pricing) || entry.authMode === "paid";
2267
2267
  const requiresSiwxScheme = entry.authMode === "siwx" || Boolean(entry.siwxEnabled);
2268
2268
  const requiresApiKeyScheme = Boolean(entry.apiKeyResolver) && entry.authMode !== "siwx";
@@ -2322,19 +2322,27 @@ function buildOperation(routeKey, entry, tag) {
2322
2322
  requiresApiKeyScheme
2323
2323
  };
2324
2324
  }
2325
+ function toProtocolObject(protocol) {
2326
+ if (protocol === "mpp") {
2327
+ return { mpp: { method: "", intent: "", currency: "" } };
2328
+ }
2329
+ return { [protocol]: {} };
2330
+ }
2325
2331
  function buildPricingInfo(entry) {
2326
2332
  if (!entry.pricing) return void 0;
2327
2333
  if (typeof entry.pricing === "string") {
2328
2334
  return {
2329
- pricingMode: "fixed",
2330
- price: entry.pricing
2335
+ price: { mode: "fixed", currency: "USD", amount: entry.pricing }
2331
2336
  };
2332
2337
  }
2333
2338
  if (typeof entry.pricing === "function") {
2334
2339
  return {
2335
- pricingMode: "quote",
2336
- ...entry.minPrice ? { minPrice: entry.minPrice } : {},
2337
- ...entry.maxPrice ? { maxPrice: entry.maxPrice } : {}
2340
+ price: {
2341
+ mode: "dynamic",
2342
+ currency: "USD",
2343
+ min: entry.minPrice ?? "0",
2344
+ max: entry.maxPrice ?? "0"
2345
+ }
2338
2346
  };
2339
2347
  }
2340
2348
  if ("tiers" in entry.pricing) {
@@ -2344,19 +2352,20 @@ function buildPricingInfo(entry) {
2344
2352
  if (Number.isFinite(min) && Number.isFinite(max)) {
2345
2353
  if (min === max) {
2346
2354
  return {
2347
- pricingMode: "fixed",
2348
- price: String(min)
2355
+ price: { mode: "fixed", currency: "USD", amount: String(min) }
2349
2356
  };
2350
2357
  }
2351
2358
  return {
2352
- pricingMode: "range",
2353
- minPrice: String(min),
2354
- maxPrice: String(max)
2359
+ price: { mode: "dynamic", currency: "USD", min: String(min), max: String(max) }
2355
2360
  };
2356
2361
  }
2357
2362
  return {
2358
- pricingMode: "quote",
2359
- ...entry.maxPrice ? { maxPrice: entry.maxPrice } : {}
2363
+ price: {
2364
+ mode: "dynamic",
2365
+ currency: "USD",
2366
+ min: "0",
2367
+ max: entry.maxPrice ?? "0"
2368
+ }
2360
2369
  };
2361
2370
  }
2362
2371
  return void 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agentcash/router",
3
- "version": "1.2.5",
3
+ "version": "1.2.6",
4
4
  "description": "Unified route builder for Next.js App Router APIs with x402, MPP, SIWX, and API key auth",
5
5
  "type": "module",
6
6
  "exports": {