@forgezero/providers 0.1.24 → 0.1.26

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/README.md CHANGED
@@ -5,7 +5,7 @@
5
5
  and commit the generator and rendered files together.
6
6
  -->
7
7
 
8
- # @forgezero/providers
8
+ # Service providers
9
9
 
10
10
  Send through whichever provider is up. Priority and failover, reordered live.
11
11
 
package/dist/billing.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.24";
339
+ var VERSION = "0.1.26";
340
340
 
341
341
  // src/billing.ts
342
342
  var PAYMENT_PROVIDER_KEYS = ["stripe:v1", "paypal:v1", "razorpay:v1"];
package/dist/database.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.24";
339
+ var VERSION = "0.1.26";
340
340
 
341
341
  // src/database.ts
342
342
  var pools = new Map;
package/dist/email.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.24";
339
+ var VERSION = "0.1.26";
340
340
 
341
341
  // src/email.ts
342
342
  var recipients = (to) => Array.isArray(to) ? [...to] : [to];
package/dist/git.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.24";
339
+ var VERSION = "0.1.26";
340
340
 
341
341
  // src/git.ts
342
342
  var githubAppConfigSchema = {
package/dist/http.d.ts CHANGED
@@ -2,12 +2,10 @@ import { ProviderError } from './index';
2
2
  /**
3
3
  * Outbound HTTP with a budget that is actually respected.
4
4
  *
5
- * Exchanges do not rate-limit requests; they rate-limit COST. Binance publishes
6
- * 6000 weight per minute per IP, and a single depth or klines call can cost 50
7
- * where a status call costs 1. A per-request limiter set to "6000 a minute" is
8
- * therefore wrong by more than an order of magnitude on exactly the endpoints
9
- * a trading system leans on, and the failure mode is a 418 and a temporary ban
10
- * rather than a slowdown.
5
+ * Some providers rate-limit cost rather than request count. A call may consume
6
+ * many units while a status probe consumes one, so a per-request limiter can be
7
+ * wrong by an order of magnitude. This generic ledger accepts the provider's
8
+ * reported cost without embedding a vendor-specific protocol in the package.
11
9
  *
12
10
  * ## The budget is per HOST, and shared
13
11
  *
@@ -24,7 +22,7 @@ import { ProviderError } from './index';
24
22
  */
25
23
  export interface HostBudget {
26
24
  host: string;
27
- /** Units per window. `weight` for Binance, `requests` for a simpler venue. */
25
+ /** Provider-defined units per window, or requests for a simpler API. */
28
26
  limit: number;
29
27
  windowMs: number;
30
28
  /** Assumed cost before the real one is known. */
@@ -58,9 +56,8 @@ export interface HttpConfig {
58
56
  baseUrl: string;
59
57
  budget: HostBudget;
60
58
  /**
61
- * Reads the true cost out of a response. Binance reports it in
62
- * `x-mbx-used-weight-1m` as a running total, so the adapter that knows the
63
- * venue owns this rather than the client guessing.
59
+ * Reads the true cost out of a response. The provider adapter owns the
60
+ * response-header contract rather than this generic client guessing.
64
61
  */
65
62
  costOf?: (response: Response) => number | undefined;
66
63
  fetch?: typeof globalThis.fetch;
@@ -94,7 +91,7 @@ export type HttpClient = ReturnType<typeof createHttpClient>;
94
91
  * that decides whether a retry helps or makes things worse.
95
92
  */
96
93
  export declare const http: import("./index").ProviderDefinition<Record<"request", import("./index").ProviderMethodSpec<HttpRequest, HttpResponse<unknown>>>>;
97
- /** Binance reports a running total for the window, not a per-call cost. */
98
- export declare const binanceWeight: (response: Response) => number | undefined;
94
+ /** Build a provider-specific response-cost reader without coupling this module to a vendor. */
95
+ export declare const responseHeaderCost: (headerName: string) => (response: Response) => number | undefined;
99
96
  export declare const httpProviders: readonly [import("./index").ProviderDefinition<Record<"request", import("./index").ProviderMethodSpec<HttpRequest, HttpResponse<unknown>>>>];
100
97
  export {};
package/dist/http.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.24";
339
+ var VERSION = "0.1.26";
340
340
 
341
341
  // src/http.ts
342
342
  class BudgetExhausted extends ProviderError {
@@ -465,8 +465,6 @@ var http = defineSingleMethodProvider({
465
465
  },
466
466
  classify(error) {
467
467
  const status = error.status;
468
- if (status === 418)
469
- return "backoff";
470
468
  if (status === 429)
471
469
  return "backoff";
472
470
  if (status === 400 || status === 422)
@@ -476,19 +474,22 @@ var http = defineSingleMethodProvider({
476
474
  return "retryable";
477
475
  }
478
476
  });
479
- var binanceWeight = (response) => {
480
- const header = response.headers.get("x-mbx-used-weight-1m");
481
- return header === null ? undefined : Number(header);
477
+ var responseHeaderCost = (headerName) => (response) => {
478
+ const header = response.headers.get(headerName);
479
+ if (header === null)
480
+ return;
481
+ const value = Number(header);
482
+ return Number.isFinite(value) && value >= 0 ? value : undefined;
482
483
  };
483
484
  var httpProviders = [http];
484
485
  export {
485
486
  spend,
486
487
  settle,
488
+ responseHeaderCost,
487
489
  resetBudgets,
488
490
  httpProviders,
489
491
  http,
490
492
  createHttpClient,
491
493
  budgetState,
492
- binanceWeight,
493
494
  BudgetExhausted
494
495
  };
package/dist/index.d.ts CHANGED
@@ -303,5 +303,5 @@ export interface EmailBatchResult {
303
303
  };
304
304
  results: readonly EmailBatchItemResult[];
305
305
  }
306
- export declare const VERSION = "0.1.24";
306
+ export declare const VERSION = "0.1.26";
307
307
  export {};
package/dist/index.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.24";
339
+ var VERSION = "0.1.26";
340
340
  export {
341
341
  staticConfig,
342
342
  serviceMethod,
package/dist/pool.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.24";
339
+ var VERSION = "0.1.26";
340
340
 
341
341
  // src/http.ts
342
342
  class BudgetExhausted extends ProviderError {
@@ -465,8 +465,6 @@ var http = defineSingleMethodProvider({
465
465
  },
466
466
  classify(error) {
467
467
  const status = error.status;
468
- if (status === 418)
469
- return "backoff";
470
468
  if (status === 429)
471
469
  return "backoff";
472
470
  if (status === 400 || status === 422)
@@ -476,9 +474,12 @@ var http = defineSingleMethodProvider({
476
474
  return "retryable";
477
475
  }
478
476
  });
479
- var binanceWeight = (response) => {
480
- const header = response.headers.get("x-mbx-used-weight-1m");
481
- return header === null ? undefined : Number(header);
477
+ var responseHeaderCost = (headerName) => (response) => {
478
+ const header = response.headers.get(headerName);
479
+ if (header === null)
480
+ return;
481
+ const value = Number(header);
482
+ return Number.isFinite(value) && value >= 0 ? value : undefined;
482
483
  };
483
484
  var httpProviders = [http];
484
485
 
package/dist/storage.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.24";
339
+ var VERSION = "0.1.26";
340
340
 
341
341
  // src/storage.ts
342
342
  var encoder = new TextEncoder;
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.24";
339
+ var VERSION = "0.1.26";
340
340
 
341
341
  // src/translation.ts
342
342
  var GOOGLE_ENDPOINT = "https://generativelanguage.googleapis.com/v1beta/models";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgezero/providers",
3
- "version": "0.1.24",
3
+ "version": "0.1.26",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -85,6 +85,6 @@
85
85
  "LICENSE"
86
86
  ],
87
87
  "dependencies": {
88
- "@forgezero/runtime": "^0.1.15"
88
+ "@forgezero/runtime": "^0.1.17"
89
89
  }
90
90
  }