@forgezero/providers 0.1.11 → 0.1.12

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
@@ -112,11 +112,14 @@ import * as api from '@forgezero/providers/realtime';
112
112
  The service owns send/sendBatch. Attach provider methods directly in priority arrays; SMTP is never presented as batch-capable.
113
113
 
114
114
  ```text
115
- import { createService } from '@forgezero/providers';
116
- import { emailService, jetemail, smtp } from '@forgezero/providers/email';
115
+ import { createService, type EmailMessage } from '@forgezero/providers';
116
+ import { emailService, jetemail, smtp, type SmtpTransport } from '@forgezero/providers/email';
117
117
  import { createVault } from '@forgezero/vault';
118
118
  import { vaultCredentials } from '@forgezero/vault/providers';
119
119
 
120
+ // Adapt Nodemailer, Bun, or an HTTP SMTP relay once at the host boundary.
121
+ declare const transport: SmtpTransport;
122
+
120
123
  const vault = createVault({ project: 'my-project', environment: 'production' });
121
124
  const email = createService(emailService, {
122
125
  send: [
@@ -128,7 +131,10 @@ const email = createService(emailService, {
128
131
  ]
129
132
  });
130
133
 
134
+ const message: EmailMessage = { to: 'user@example.com', subject: 'Hello', text: 'Sent by ForgeZero' };
131
135
  const outcome = await email.call('send', message);
136
+ if (!outcome.ok) throw outcome.error;
137
+ console.log(outcome.result, outcome.attempts);
132
138
  ```
133
139
 
134
140
  ## Extend with a custom provider and service
@@ -136,9 +142,26 @@ const outcome = await email.call('send', message);
136
142
  Public consumers define provider capabilities and application services independently, then attach them with the same ordered-array API.
137
143
 
138
144
  ```text
139
- const postmark = defineProvider({
140
- id: 'postmark', label: 'Postmark',
141
- methods: { deliver: defineProviderMethod({ invoke, classify }) }
145
+ import { createService, defineService, defineSingleMethodProvider, serviceMethod } from '@forgezero/providers';
146
+ import { createVault } from '@forgezero/vault';
147
+ import { vaultCredentials } from '@forgezero/vault/providers';
148
+
149
+ type Notice = { text: string };
150
+ type Receipt = { id: string };
151
+ const vault = createVault({ project: 'my-project', environment: 'production' });
152
+
153
+ const postmark = defineSingleMethodProvider({
154
+ id: 'postmark', label: 'Postmark', method: 'deliver',
155
+ async invoke(context, notice: Notice): Promise<Receipt> {
156
+ const response = await fetch('https://api.postmarkapp.com/email', {
157
+ method: 'POST', signal: context.signal,
158
+ headers: { 'x-postmark-server-token': await context.secret('apiKey') },
159
+ body: JSON.stringify(notice)
160
+ });
161
+ if (!response.ok) throw new Error(`Postmark returned ${response.status}`);
162
+ return { id: response.headers.get('x-message-id') ?? crypto.randomUUID() };
163
+ },
164
+ classify: () => 'retryable'
142
165
  });
143
166
  const notifications = defineService({
144
167
  key: 'notifications', methods: { deliver: serviceMethod<Notice, Receipt>() }
@@ -153,6 +176,11 @@ const service = createService(notifications, {
153
176
  Bootstrap tries the scoped Vault entry first and the identically named systemd credential second. If neither exists, the provider call fails.
154
177
 
155
178
  ```text
179
+ import { chainScopedCredentials, scopeCredentials } from '@forgezero/providers';
180
+ import { createVault, systemdCredentials } from '@forgezero/vault';
181
+ import { vaultCredentials } from '@forgezero/vault/providers';
182
+
183
+ const vault = createVault({ project: 'my-project', environment: 'production' });
156
184
  const credentials = chainScopedCredentials(
157
185
  vaultCredentials(vault, 'jetemail'),
158
186
  scopeCredentials(systemdCredentials({
package/dist/binance.js CHANGED
@@ -298,7 +298,7 @@ function createService(definition, methods, options = {}) {
298
298
  }
299
299
  };
300
300
  }
301
- var VERSION = "0.1.11";
301
+ var VERSION = "0.1.12";
302
302
 
303
303
  // src/http.ts
304
304
  class BudgetExhausted extends ProviderError {
package/dist/chain.js CHANGED
@@ -298,7 +298,7 @@ function createService(definition, methods, options = {}) {
298
298
  }
299
299
  };
300
300
  }
301
- var VERSION = "0.1.11";
301
+ var VERSION = "0.1.12";
302
302
 
303
303
  // src/chain.ts
304
304
  var hexToNumber = (value) => Number(BigInt(value));
package/dist/database.js CHANGED
@@ -298,7 +298,7 @@ function createService(definition, methods, options = {}) {
298
298
  }
299
299
  };
300
300
  }
301
- var VERSION = "0.1.11";
301
+ var VERSION = "0.1.12";
302
302
 
303
303
  // src/database.ts
304
304
  var pools = new Map;
package/dist/email.js CHANGED
@@ -298,7 +298,7 @@ function createService(definition, methods, options = {}) {
298
298
  }
299
299
  };
300
300
  }
301
- var VERSION = "0.1.11";
301
+ var VERSION = "0.1.12";
302
302
 
303
303
  // src/email.ts
304
304
  var recipients = (to) => Array.isArray(to) ? [...to] : [to];
package/dist/http.js CHANGED
@@ -298,7 +298,7 @@ function createService(definition, methods, options = {}) {
298
298
  }
299
299
  };
300
300
  }
301
- var VERSION = "0.1.11";
301
+ var VERSION = "0.1.12";
302
302
 
303
303
  // src/http.ts
304
304
  class BudgetExhausted extends ProviderError {
package/dist/index.d.ts CHANGED
@@ -285,5 +285,5 @@ export interface EmailBatchResult {
285
285
  };
286
286
  results: readonly EmailBatchItemResult[];
287
287
  }
288
- export declare const VERSION = "0.1.11";
288
+ export declare const VERSION = "0.1.12";
289
289
  export {};
package/dist/index.js CHANGED
@@ -298,7 +298,7 @@ function createService(definition, methods, options = {}) {
298
298
  }
299
299
  };
300
300
  }
301
- var VERSION = "0.1.11";
301
+ var VERSION = "0.1.12";
302
302
  export {
303
303
  staticConfig,
304
304
  serviceMethod,
package/dist/pool.js CHANGED
@@ -298,7 +298,7 @@ function createService(definition, methods, options = {}) {
298
298
  }
299
299
  };
300
300
  }
301
- var VERSION = "0.1.11";
301
+ var VERSION = "0.1.12";
302
302
 
303
303
  // src/http.ts
304
304
  class BudgetExhausted extends ProviderError {
package/dist/storage.js CHANGED
@@ -298,7 +298,7 @@ function createService(definition, methods, options = {}) {
298
298
  }
299
299
  };
300
300
  }
301
- var VERSION = "0.1.11";
301
+ var VERSION = "0.1.12";
302
302
 
303
303
  // src/storage.ts
304
304
  var encoder = new TextEncoder;
@@ -298,7 +298,7 @@ function createService(definition, methods, options = {}) {
298
298
  }
299
299
  };
300
300
  }
301
- var VERSION = "0.1.11";
301
+ var VERSION = "0.1.12";
302
302
 
303
303
  // src/translation.ts
304
304
  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.11",
3
+ "version": "0.1.12",
4
4
  "type": "module",
5
5
  "publishConfig": {
6
6
  "access": "public",
@@ -86,6 +86,6 @@
86
86
  "LICENSE"
87
87
  ],
88
88
  "dependencies": {
89
- "@forgezero/runtime": "^0.1.6"
89
+ "@forgezero/runtime": "^0.1.7"
90
90
  }
91
91
  }