@forgezero/providers 0.1.20 → 0.1.22
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 +13 -159
- package/dist/binance.js +1 -1
- package/dist/chain.js +1 -1
- package/dist/database.js +1 -1
- package/dist/email.d.ts +4 -0
- package/dist/email.js +19 -5
- package/dist/http.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/pool.js +1 -1
- package/dist/storage.js +1 -1
- package/dist/translation.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -11,7 +11,7 @@ Send through whichever provider is up. Priority and failover, reordered live.
|
|
|
11
11
|
|
|
12
12
|
## Package overview
|
|
13
13
|
|
|
14
|
-
Anyone calling somebody else's API who needs the failure classified rather than guessed. Provider capabilities stay independent from application-owned services, which attach named methods by priority with health tracking. Supported runtimes: bun, node, workers, deno. Package root: @forgezero/providers.
|
|
14
|
+
Anyone calling somebody else's API who needs the failure classified rather than guessed. Provider capabilities stay independent from application-owned services, which attach named methods by priority with health tracking. Supported runtimes: bun, node, workers, deno. Package root: @forgezero/providers. Consumer documentation is curated with each module's explicit public flag; the complete internal/export inventory remains in the typed SSOT and declaration files.
|
|
15
15
|
|
|
16
16
|
```text
|
|
17
17
|
bun add @forgezero/providers
|
|
@@ -29,9 +29,9 @@ The five packages are installation boundaries. Choose a package by who installs
|
|
|
29
29
|
| @forgezero/runtime | Portable runtime primitives for queries, jobs, events, schemas and finance. | bun, node | [Open](https://www.forgezero.net/docs/runtime) |
|
|
30
30
|
| @forgezero/agent | Operator CLI and managed-node agent for bootstrap, deploy and lifecycle. | bun, node | [Open](https://www.forgezero.net/docs/agent) |
|
|
31
31
|
|
|
32
|
-
## @forgezero/providers
|
|
32
|
+
## @forgezero/providers supported imports and commands
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
These are supported consumer entry points, not every internal module shipped for ForgeZero managed installation. Each row links to its task-oriented usage.
|
|
35
35
|
|
|
36
36
|
| public entry | short description | runtime | details |
|
|
37
37
|
|---|---|---|---|
|
|
@@ -59,61 +59,11 @@ bun test
|
|
|
59
59
|
<a id="forgezero-providers"></a>
|
|
60
60
|
## @forgezero/providers
|
|
61
61
|
|
|
62
|
-
The registry: priority, health, and a terminal-versus-retryable verdict per failure. This
|
|
62
|
+
The registry: priority, health, and a terminal-versus-retryable verdict per failure. This is a supported entry point. Import only the named values used by the adjacent task example; the declaration file remains the complete API reference.
|
|
63
63
|
|
|
64
64
|
```text
|
|
65
65
|
import {
|
|
66
66
|
ProviderError,
|
|
67
|
-
STRIKES_TO_OFFLINE,
|
|
68
|
-
VERSION,
|
|
69
|
-
chainCredentials,
|
|
70
|
-
chainScopedCredentials,
|
|
71
|
-
createRegistry,
|
|
72
|
-
createService,
|
|
73
|
-
defineProvider,
|
|
74
|
-
defineProviderMethod,
|
|
75
|
-
defineProviderMethodBranches,
|
|
76
|
-
defineService,
|
|
77
|
-
defineSingleMethodProvider,
|
|
78
|
-
envCredentials,
|
|
79
|
-
nextHealth,
|
|
80
|
-
scopeCredentials,
|
|
81
|
-
serviceMethod,
|
|
82
|
-
staticConfig,
|
|
83
|
-
} from '@forgezero/providers';
|
|
84
|
-
|
|
85
|
-
import type {
|
|
86
|
-
AnyProviderMethod,
|
|
87
|
-
Attempt,
|
|
88
|
-
CallOptions,
|
|
89
|
-
CallResult,
|
|
90
|
-
ConfigSource,
|
|
91
|
-
CredentialSource,
|
|
92
|
-
DirectAttempt,
|
|
93
|
-
DirectCallResult,
|
|
94
|
-
DirectServiceAttachment,
|
|
95
|
-
DirectServiceConfig,
|
|
96
|
-
DirectServiceOptions,
|
|
97
|
-
EmailBatch,
|
|
98
|
-
EmailBatchItemResult,
|
|
99
|
-
EmailBatchResult,
|
|
100
|
-
EmailMessage,
|
|
101
|
-
FailureKind,
|
|
102
|
-
InvokeContext,
|
|
103
|
-
ProviderDefinition,
|
|
104
|
-
ProviderHealth,
|
|
105
|
-
ProviderInstanceConfig,
|
|
106
|
-
ProviderMethodBranches,
|
|
107
|
-
ProviderMethodEntry,
|
|
108
|
-
ProviderMethodSpec,
|
|
109
|
-
ProviderMethods,
|
|
110
|
-
RegistryOptions,
|
|
111
|
-
ScopedCredentialSource,
|
|
112
|
-
ServiceDefinition,
|
|
113
|
-
ServiceMethodAttachment,
|
|
114
|
-
ServiceMethodContract,
|
|
115
|
-
ServiceMethods,
|
|
116
|
-
StaticRegistryConfig,
|
|
117
67
|
} from '@forgezero/providers';
|
|
118
68
|
```
|
|
119
69
|
|
|
@@ -189,19 +139,11 @@ const credentials = chainScopedCredentials(
|
|
|
189
139
|
<a id="forgezero-providers-email"></a>
|
|
190
140
|
## @forgezero/providers/email
|
|
191
141
|
|
|
192
|
-
JetEmail (`send`, `sendBatch`), SMTP (`send` only), and the typed email service contract; SMTP transport is injected. This
|
|
142
|
+
JetEmail (`send`, `sendBatch`), SMTP (`send` only), and the typed email service contract; SMTP transport is injected. This is a supported entry point. Import only the named values used by the adjacent task example; the declaration file remains the complete API reference.
|
|
193
143
|
|
|
194
144
|
```text
|
|
195
145
|
import {
|
|
196
146
|
emailProviders,
|
|
197
|
-
emailService,
|
|
198
|
-
jetemail,
|
|
199
|
-
smtp,
|
|
200
|
-
} from '@forgezero/providers/email';
|
|
201
|
-
|
|
202
|
-
import type {
|
|
203
|
-
JetEmailConfig,
|
|
204
|
-
SmtpTransport,
|
|
205
147
|
} from '@forgezero/providers/email';
|
|
206
148
|
```
|
|
207
149
|
|
|
@@ -250,27 +192,11 @@ console.log(outcome.result, outcome.attempts);
|
|
|
250
192
|
<a id="forgezero-providers-database"></a>
|
|
251
193
|
## @forgezero/providers/database
|
|
252
194
|
|
|
253
|
-
ArangoDB in the registry for credential rotation and health — with failover off by default. This
|
|
195
|
+
ArangoDB in the registry for credential rotation and health — with failover off by default. This is a supported entry point. Import only the named values used by the adjacent task example; the declaration file remains the complete API reference.
|
|
254
196
|
|
|
255
197
|
```text
|
|
256
198
|
import {
|
|
257
199
|
ARANGO_COMMUNITY_VERSION,
|
|
258
|
-
ARANGO_SERVER_MODE_PATH,
|
|
259
|
-
MAX_ARANGO_COORDINATORS,
|
|
260
|
-
arangoCoordinatorUrls,
|
|
261
|
-
arangodb,
|
|
262
|
-
databaseProviders,
|
|
263
|
-
resetPools,
|
|
264
|
-
} from '@forgezero/providers/database';
|
|
265
|
-
|
|
266
|
-
import type {
|
|
267
|
-
ArangoConfig,
|
|
268
|
-
ArangoConnectOptions,
|
|
269
|
-
ArangoCoordinatorMember,
|
|
270
|
-
ArangoLike,
|
|
271
|
-
ArangoMembershipSnapshot,
|
|
272
|
-
ArangoMembershipVerifier,
|
|
273
|
-
Query,
|
|
274
200
|
} from '@forgezero/providers/database';
|
|
275
201
|
```
|
|
276
202
|
|
|
@@ -289,27 +215,11 @@ export const selectedCapability = ARANGO_COMMUNITY_VERSION;
|
|
|
289
215
|
<a id="forgezero-providers-http"></a>
|
|
290
216
|
## @forgezero/providers/http
|
|
291
217
|
|
|
292
|
-
Outbound HTTP with a per-host weight budget reserved before the call and settled from the response. This
|
|
218
|
+
Outbound HTTP with a per-host weight budget reserved before the call and settled from the response. This is a supported entry point. Import only the named values used by the adjacent task example; the declaration file remains the complete API reference.
|
|
293
219
|
|
|
294
220
|
```text
|
|
295
221
|
import {
|
|
296
222
|
BudgetExhausted,
|
|
297
|
-
binanceWeight,
|
|
298
|
-
budgetState,
|
|
299
|
-
createHttpClient,
|
|
300
|
-
http,
|
|
301
|
-
httpProviders,
|
|
302
|
-
resetBudgets,
|
|
303
|
-
settle,
|
|
304
|
-
spend,
|
|
305
|
-
} from '@forgezero/providers/http';
|
|
306
|
-
|
|
307
|
-
import type {
|
|
308
|
-
HostBudget,
|
|
309
|
-
HttpClient,
|
|
310
|
-
HttpConfig,
|
|
311
|
-
HttpRequest,
|
|
312
|
-
HttpResponse,
|
|
313
223
|
} from '@forgezero/providers/http';
|
|
314
224
|
```
|
|
315
225
|
|
|
@@ -328,20 +238,11 @@ export const selectedCapability = BudgetExhausted;
|
|
|
328
238
|
<a id="forgezero-providers-pool"></a>
|
|
329
239
|
## @forgezero/providers/pool
|
|
330
240
|
|
|
331
|
-
Which outbound address a request leaves by, sticky per key, over the same budget as everything else. This
|
|
241
|
+
Which outbound address a request leaves by, sticky per key, over the same budget as everything else. This is a supported entry point. Import only the named values used by the adjacent task example; the declaration file remains the complete API reference.
|
|
332
242
|
|
|
333
243
|
```text
|
|
334
244
|
import {
|
|
335
245
|
PoolEmpty,
|
|
336
|
-
PoolExhausted,
|
|
337
|
-
createAddressPool,
|
|
338
|
-
} from '@forgezero/providers/pool';
|
|
339
|
-
|
|
340
|
-
import type {
|
|
341
|
-
AddressPool,
|
|
342
|
-
Lease,
|
|
343
|
-
PoolAddress,
|
|
344
|
-
PoolOptions,
|
|
345
246
|
} from '@forgezero/providers/pool';
|
|
346
247
|
```
|
|
347
248
|
|
|
@@ -360,19 +261,12 @@ export const selectedCapability = PoolEmpty;
|
|
|
360
261
|
<a id="forgezero-providers-chain"></a>
|
|
361
262
|
## @forgezero/providers/chain
|
|
362
263
|
|
|
363
|
-
An EVM node behind the same failover as any other service: read logs, broadcast, and never stop scanning because one endpoint rate-limited. This
|
|
264
|
+
An EVM node behind the same failover as any other service: read logs, broadcast, and never stop scanning because one endpoint rate-limited. This is a supported entry point. Import only the named values used by the adjacent task example; the declaration file remains the complete API reference.
|
|
364
265
|
|
|
365
266
|
```text
|
|
366
267
|
import {
|
|
367
268
|
evmRpc,
|
|
368
269
|
} from '@forgezero/providers/chain';
|
|
369
|
-
|
|
370
|
-
import type {
|
|
371
|
-
ChainCall,
|
|
372
|
-
ChainLog,
|
|
373
|
-
ChainReceipt,
|
|
374
|
-
ChainResult,
|
|
375
|
-
} from '@forgezero/providers/chain';
|
|
376
270
|
```
|
|
377
271
|
|
|
378
272
|
## @forgezero/providers/chain — Use this entry point
|
|
@@ -390,19 +284,11 @@ export const selectedCapability = evmRpc;
|
|
|
390
284
|
<a id="forgezero-providers-binance"></a>
|
|
391
285
|
## @forgezero/providers/binance
|
|
392
286
|
|
|
393
|
-
Binance behind the venue adapter: three hosts, one weight budget, signed over the exact string that is sent. This
|
|
287
|
+
Binance behind the venue adapter: three hosts, one weight budget, signed over the exact string that is sent. This is a supported entry point. Import only the named values used by the adjacent task example; the declaration file remains the complete API reference.
|
|
394
288
|
|
|
395
289
|
```text
|
|
396
290
|
import {
|
|
397
291
|
binanceSymbol,
|
|
398
|
-
createBinanceAdapter,
|
|
399
|
-
readBinanceError,
|
|
400
|
-
toOrderStatus,
|
|
401
|
-
} from '@forgezero/providers/binance';
|
|
402
|
-
|
|
403
|
-
import type {
|
|
404
|
-
BinanceCredentials,
|
|
405
|
-
BinanceOptions,
|
|
406
292
|
} from '@forgezero/providers/binance';
|
|
407
293
|
```
|
|
408
294
|
|
|
@@ -421,29 +307,11 @@ export const selectedCapability = binanceSymbol;
|
|
|
421
307
|
<a id="forgezero-providers-storage"></a>
|
|
422
308
|
## @forgezero/providers/storage
|
|
423
309
|
|
|
424
|
-
S3-compatible object storage, SigV4 signed with Web Crypto and no vendor SDK. This
|
|
310
|
+
S3-compatible object storage, SigV4 signed with Web Crypto and no vendor SDK. This is a supported entry point. Import only the named values used by the adjacent task example; the declaration file remains the complete API reference.
|
|
425
311
|
|
|
426
312
|
```text
|
|
427
313
|
import {
|
|
428
314
|
MAX_SINGLE_PUT_BYTES,
|
|
429
|
-
StorageError,
|
|
430
|
-
amzDate,
|
|
431
|
-
createS3Client,
|
|
432
|
-
encodeSegment,
|
|
433
|
-
parseListXml,
|
|
434
|
-
s3,
|
|
435
|
-
signRequest,
|
|
436
|
-
storageProviders,
|
|
437
|
-
} from '@forgezero/providers/storage';
|
|
438
|
-
|
|
439
|
-
import type {
|
|
440
|
-
ObjectSummary,
|
|
441
|
-
PutObjectArgs,
|
|
442
|
-
S3Client,
|
|
443
|
-
S3Config,
|
|
444
|
-
S3Credentials,
|
|
445
|
-
SignedRequest,
|
|
446
|
-
StorageRequest,
|
|
447
315
|
} from '@forgezero/providers/storage';
|
|
448
316
|
```
|
|
449
317
|
|
|
@@ -462,20 +330,11 @@ export const selectedCapability = MAX_SINGLE_PUT_BYTES;
|
|
|
462
330
|
<a id="forgezero-providers-translation"></a>
|
|
463
331
|
## @forgezero/providers/translation
|
|
464
332
|
|
|
465
|
-
Google AI Studio translation with strict batch alignment and classified quota failures. This
|
|
333
|
+
Google AI Studio translation with strict batch alignment and classified quota failures. This is a supported entry point. Import only the named values used by the adjacent task example; the declaration file remains the complete API reference.
|
|
466
334
|
|
|
467
335
|
```text
|
|
468
336
|
import {
|
|
469
337
|
TranslationError,
|
|
470
|
-
googleAiStudio,
|
|
471
|
-
parseStrings,
|
|
472
|
-
translationProviders,
|
|
473
|
-
} from '@forgezero/providers/translation';
|
|
474
|
-
|
|
475
|
-
import type {
|
|
476
|
-
TranslateRequest,
|
|
477
|
-
TranslateResult,
|
|
478
|
-
TranslationProvider,
|
|
479
338
|
} from '@forgezero/providers/translation';
|
|
480
339
|
```
|
|
481
340
|
|
|
@@ -494,16 +353,11 @@ export const selectedCapability = TranslationError;
|
|
|
494
353
|
<a id="forgezero-providers-realtime"></a>
|
|
495
354
|
## @forgezero/providers/realtime
|
|
496
355
|
|
|
497
|
-
Cloudflare KV node-directory and Durable Object fan-out clients for project-defined realtime services. This
|
|
356
|
+
Cloudflare KV node-directory and Durable Object fan-out clients for project-defined realtime services. This is a supported entry point. Import only the named values used by the adjacent task example; the declaration file remains the complete API reference.
|
|
498
357
|
|
|
499
358
|
```text
|
|
500
359
|
import {
|
|
501
360
|
RealtimeProviderError,
|
|
502
|
-
cloudflareRealtime,
|
|
503
|
-
} from '@forgezero/providers/realtime';
|
|
504
|
-
|
|
505
|
-
import type {
|
|
506
|
-
RealtimeProviderOptions,
|
|
507
361
|
} from '@forgezero/providers/realtime';
|
|
508
362
|
```
|
|
509
363
|
|
package/dist/binance.js
CHANGED
package/dist/chain.js
CHANGED
package/dist/database.js
CHANGED
package/dist/email.d.ts
CHANGED
|
@@ -2,6 +2,10 @@ import { type EmailBatch, type EmailBatchResult, type EmailMessage } from './ind
|
|
|
2
2
|
export interface JetEmailConfig {
|
|
3
3
|
/** EU residency endpoint. */
|
|
4
4
|
eu?: boolean;
|
|
5
|
+
/** Bare sender mailbox. JetEmail's wire API receives it as `Name <mailbox>`. */
|
|
6
|
+
from?: string;
|
|
7
|
+
/** Optional display name. Defaults to the sender mailbox local part. */
|
|
8
|
+
fromName?: string;
|
|
5
9
|
endpoint?: string;
|
|
6
10
|
batchEndpoint?: string;
|
|
7
11
|
fetch?: typeof globalThis.fetch;
|
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.
|
|
339
|
+
var VERSION = "0.1.22";
|
|
340
340
|
|
|
341
341
|
// src/email.ts
|
|
342
342
|
var recipients = (to) => Array.isArray(to) ? [...to] : [to];
|
|
@@ -348,6 +348,19 @@ function assertMessage(message) {
|
|
|
348
348
|
throw new ProviderError("EMAIL_NO_BODY", "An email needs html, text, or both.");
|
|
349
349
|
}
|
|
350
350
|
}
|
|
351
|
+
var JETEMAIL_MAILBOX = /^[^\s<>@]+@[^\s<>@]+\.[^\s<>@]+$/;
|
|
352
|
+
function jetemailSender(config, override) {
|
|
353
|
+
const mailbox = (override ?? config.from ?? "").trim();
|
|
354
|
+
if (!JETEMAIL_MAILBOX.test(mailbox)) {
|
|
355
|
+
throw new ProviderError("JETEMAIL_FROM", "JetEmail needs a valid sender mailbox.");
|
|
356
|
+
}
|
|
357
|
+
const fallbackName = mailbox.slice(0, mailbox.indexOf("@"));
|
|
358
|
+
const name = (config.fromName ?? fallbackName).trim();
|
|
359
|
+
if (!name || /[\r\n<>]/.test(name)) {
|
|
360
|
+
throw new ProviderError("JETEMAIL_FROM_NAME", "JetEmail sender name must be non-empty and header-safe.");
|
|
361
|
+
}
|
|
362
|
+
return `${name} <${mailbox}>`;
|
|
363
|
+
}
|
|
351
364
|
var jetemailCredentials = {
|
|
352
365
|
type: "object",
|
|
353
366
|
additionalProperties: false,
|
|
@@ -366,7 +379,8 @@ var jetemailConfig = {
|
|
|
366
379
|
additionalProperties: false,
|
|
367
380
|
properties: {
|
|
368
381
|
eu: { type: "boolean", default: false, title: "EU residency" },
|
|
369
|
-
from: { type: "string", format: "email", title: "Default from address" }
|
|
382
|
+
from: { type: "string", format: "email", title: "Default from address" },
|
|
383
|
+
fromName: { type: "string", minLength: 1, maxLength: 120, title: "Sender name" }
|
|
370
384
|
}
|
|
371
385
|
};
|
|
372
386
|
var jetemailSend = defineProviderMethod({
|
|
@@ -386,7 +400,7 @@ var jetemailSend = defineProviderMethod({
|
|
|
386
400
|
...message.idempotencyKey ? { "idempotency-key": message.idempotencyKey } : {}
|
|
387
401
|
},
|
|
388
402
|
body: JSON.stringify({
|
|
389
|
-
from: message.from
|
|
403
|
+
from: jetemailSender(config, message.from),
|
|
390
404
|
to: recipients(message.to),
|
|
391
405
|
subject: message.subject,
|
|
392
406
|
html: message.html,
|
|
@@ -395,7 +409,7 @@ var jetemailSend = defineProviderMethod({
|
|
|
395
409
|
eu: config.eu ?? false
|
|
396
410
|
})
|
|
397
411
|
});
|
|
398
|
-
if (response.status === 201 || response.status === 202) {
|
|
412
|
+
if (response.status === 200 || response.status === 201 || response.status === 202) {
|
|
399
413
|
const payload = await response.json().catch(() => ({}));
|
|
400
414
|
return { id: payload.id ?? "" };
|
|
401
415
|
}
|
|
@@ -437,7 +451,7 @@ var jetemailSendBatch = defineProviderMethod({
|
|
|
437
451
|
},
|
|
438
452
|
body: JSON.stringify({
|
|
439
453
|
emails: batch.emails.map((message) => ({
|
|
440
|
-
from: message.from
|
|
454
|
+
from: jetemailSender(config, message.from),
|
|
441
455
|
to: recipients(message.to),
|
|
442
456
|
subject: message.subject,
|
|
443
457
|
html: message.html,
|
package/dist/http.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/pool.js
CHANGED
package/dist/storage.js
CHANGED
package/dist/translation.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@forgezero/providers",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
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.
|
|
88
|
+
"@forgezero/runtime": "^0.1.14"
|
|
89
89
|
}
|
|
90
90
|
}
|