@forgezero/providers 0.1.23 → 0.1.25

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/git.js CHANGED
@@ -336,7 +336,7 @@ function createService(definition, methods, options = {}) {
336
336
  }
337
337
  };
338
338
  }
339
- var VERSION = "0.1.23";
339
+ var VERSION = "0.1.25";
340
340
 
341
341
  // src/git.ts
342
342
  var githubAppConfigSchema = {
@@ -344,9 +344,11 @@ var githubAppConfigSchema = {
344
344
  properties: {
345
345
  clientId: { type: "string", minLength: 10, maxLength: 128 },
346
346
  appId: { type: "string", pattern: "^[1-9][0-9]{0,19}$" },
347
- slug: { type: "string", pattern: "^[a-z0-9][a-z0-9-]{0,99}$" }
347
+ slug: { type: "string", pattern: "^[a-z0-9][a-z0-9-]{0,99}$" },
348
+ providerVersion: { type: "string", pattern: "^github-app:[a-z0-9][a-z0-9.-]{0,31}$" },
349
+ verifiedAtTs: { type: "integer", minimum: 1 }
348
350
  },
349
- required: ["clientId", "appId", "slug"],
351
+ required: ["clientId", "appId", "slug", "providerVersion", "verifiedAtTs"],
350
352
  additionalProperties: false
351
353
  };
352
354
  var githubAppCredentialSchema = {
@@ -359,42 +361,62 @@ var githubAppCredentialSchema = {
359
361
  required: ["clientSecret", "privateKey", "webhookSecret"],
360
362
  additionalProperties: false
361
363
  };
364
+ var oauthServerService = defineService({
365
+ key: "oauth-server",
366
+ methods: {
367
+ beginUserAuthorization: serviceMethod(),
368
+ completeUserAuthorization: serviceMethod(),
369
+ readVerifiedIdentity: serviceMethod(),
370
+ refreshUserGrant: serviceMethod(),
371
+ revokeUserGrant: serviceMethod()
372
+ }
373
+ });
362
374
  var gitConnectService = defineService({
363
375
  key: "git-connect",
364
376
  methods: {
365
- listAccounts: serviceMethod(),
377
+ beginInstallation: serviceMethod(),
378
+ completeInstallation: serviceMethod(),
379
+ listInstallations: serviceMethod(),
366
380
  listRepositories: serviceMethod(),
367
381
  listBranches: serviceMethod(),
368
- ensureWebhook: serviceMethod(),
369
- cloneCredential: serviceMethod()
382
+ mintCloneCredential: serviceMethod(),
383
+ verifyWebhook: serviceMethod(),
384
+ disconnectInstallation: serviceMethod()
370
385
  }
371
386
  });
372
- function defineGitConnectProvider(args) {
387
+ function defineGitHubProvider(args) {
373
388
  const classify = args.classify ?? (() => "retryable");
374
389
  const branch = (invoke) => defineProviderMethodBranches({
375
390
  currentVersion: args.version,
376
- versions: {
377
- [args.version]: { version: args.version, lifecycle: "current", invoke, classify }
378
- }
391
+ versions: { [args.version]: { version: args.version, lifecycle: "current", invoke, classify } }
379
392
  });
380
393
  return defineProvider({
381
- id: args.id,
382
- label: args.label,
383
- multiInstance: true,
384
- credentials: args.credentials,
385
- config: args.config,
394
+ id: "github",
395
+ label: "GitHub App",
396
+ multiInstance: false,
397
+ credentials: githubAppCredentialSchema,
398
+ config: githubAppConfigSchema,
386
399
  methods: {
387
- listAccounts: branch(args.adapter.listAccounts),
400
+ beginUserAuthorization: branch(args.adapter.beginUserAuthorization),
401
+ completeUserAuthorization: branch(args.adapter.completeUserAuthorization),
402
+ readVerifiedIdentity: branch(args.adapter.readVerifiedIdentity),
403
+ refreshUserGrant: branch(args.adapter.refreshUserGrant),
404
+ revokeUserGrant: branch(args.adapter.revokeUserGrant),
405
+ beginInstallation: branch(args.adapter.beginInstallation),
406
+ completeInstallation: branch(args.adapter.completeInstallation),
407
+ listInstallations: branch(args.adapter.listInstallations),
388
408
  listRepositories: branch(args.adapter.listRepositories),
389
409
  listBranches: branch(args.adapter.listBranches),
390
- ensureWebhook: branch(args.adapter.ensureWebhook),
391
- cloneCredential: branch(args.adapter.cloneCredential)
410
+ mintCloneCredential: branch(args.adapter.mintCloneCredential),
411
+ verifyWebhook: branch(args.adapter.verifyWebhook),
412
+ disconnectInstallation: branch(args.adapter.disconnectInstallation)
392
413
  }
393
414
  });
394
415
  }
395
416
  export {
417
+ oauthServerService,
396
418
  githubAppCredentialSchema,
397
419
  githubAppConfigSchema,
398
420
  gitConnectService,
399
- defineGitConnectProvider
421
+ defineGitHubProvider
400
422
  };
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.23";
339
+ var VERSION = "0.1.25";
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.23";
306
+ export declare const VERSION = "0.1.25";
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.23";
339
+ var VERSION = "0.1.25";
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.23";
339
+ var VERSION = "0.1.25";
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.23";
339
+ var VERSION = "0.1.25";
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.23";
339
+ var VERSION = "0.1.25";
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.23",
3
+ "version": "0.1.25",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -15,10 +15,6 @@
15
15
  "types": "./dist/email.d.ts",
16
16
  "default": "./dist/email.js"
17
17
  },
18
- "./chain": {
19
- "types": "./dist/chain.d.ts",
20
- "default": "./dist/chain.js"
21
- },
22
18
  "./database": {
23
19
  "types": "./dist/database.d.ts",
24
20
  "default": "./dist/database.js"
@@ -35,10 +31,6 @@
35
31
  "types": "./dist/pool.d.ts",
36
32
  "default": "./dist/pool.js"
37
33
  },
38
- "./binance": {
39
- "types": "./dist/binance.d.ts",
40
- "default": "./dist/binance.js"
41
- },
42
34
  "./translation": {
43
35
  "types": "./dist/translation.d.ts",
44
36
  "default": "./dist/translation.js"
@@ -50,6 +42,10 @@
50
42
  "./git": {
51
43
  "types": "./dist/git.d.ts",
52
44
  "default": "./dist/git.js"
45
+ },
46
+ "./billing": {
47
+ "types": "./dist/billing.d.ts",
48
+ "default": "./dist/billing.js"
53
49
  }
54
50
  },
55
51
  "scripts": {
@@ -89,6 +85,6 @@
89
85
  "LICENSE"
90
86
  ],
91
87
  "dependencies": {
92
- "@forgezero/runtime": "^0.1.14"
88
+ "@forgezero/runtime": "^0.1.16"
93
89
  }
94
90
  }
package/dist/binance.d.ts DELETED
@@ -1,27 +0,0 @@
1
- import { VenueError, type VenueAdapter, type MarketType, type OrderStatus } from '@forgezero/runtime/finance/venues';
2
- export interface BinanceCredentials {
3
- apiKey: string;
4
- apiSecret: string;
5
- }
6
- export interface BinanceOptions {
7
- credentials: BinanceCredentials;
8
- /** Override for testnet, or for a test. */
9
- hosts?: Partial<Record<MarketType, string>>;
10
- fetch?: typeof globalThis.fetch;
11
- /**
12
- * How far a request may be delayed before Binance refuses it.
13
- *
14
- * 5s rather than the 60s maximum. A signed order that arrives a minute late
15
- * is an order placed into a market that has moved, and accepting it is worse
16
- * than being told to retry.
17
- */
18
- recvWindowMs?: number;
19
- now?: () => number;
20
- }
21
- /** Binance spells `BTC/USDT` as `BTCUSDT`. Denormalised here and nowhere else. */
22
- export declare const binanceSymbol: (symbol: string) => string;
23
- /** Binance statuses → ours. An unknown one is `rejected`, never silently `accepted`. */
24
- export declare function toOrderStatus(status: string): OrderStatus;
25
- export declare function createBinanceAdapter(options: BinanceOptions): VenueAdapter;
26
- /** Turn a Binance error into something that names the actual cause. */
27
- export declare function readBinanceError(error: unknown): VenueError | undefined;