@distilled.cloud/stripe 1.0.0-rc.1 → 1.0.0-rc.2

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.
@@ -0,0 +1,382 @@
1
+ /**
2
+ * StripeProtocol — hand-written.
3
+ *
4
+ * Speaks Stripe's REST protocol. The generic trait helpers live in
5
+ * `@distilled.cloud/core/protocol-http`; this module supplies what is
6
+ * Stripe's own (ported from the distilled v0 stripe client):
7
+ *
8
+ * request: credentials → `Authorization: Bearer <apiKey>` + API base URL;
9
+ * per-call {@link StripeRequestOptions} (resolved from the
10
+ * calling fiber via {@link RequestOptions}) → Idempotency-Key /
11
+ * Stripe-Account / Stripe-Context / Stripe-Version headers;
12
+ * GET inputs flatten body-bound members into the query string
13
+ * with Stripe bracket notation (`created[gte]`, `expand[]`);
14
+ * non-GET bodies encode as `application/x-www-form-urlencoded`
15
+ * with Stripe deepObject bracket expansion (`shipping[address]
16
+ * [city]=SF`, `expand[0]=data`) when the operation's `T.Http`
17
+ * trait says `contentType: "form-urlencoded"` (every /v1 op),
18
+ * as JSON otherwise (the /v2 ops), and as multipart form-data
19
+ * for `contentType: "multipart"` (POST /v1/files)
20
+ *
21
+ * response: 2xx JSON is the payload (no envelope) → wire→TS key mapping →
22
+ * Redacted wrapping of sensitive members; failures parse the
23
+ * `{ error: { type, code, message, … } }` envelope and dispatch
24
+ * by `error.type` first (card_error → CardError,
25
+ * idempotency_error → IdempotencyError, invalid_request_error →
26
+ * InvalidRequestError, api_error → ApiError), then the
27
+ * Stripe-specific status map (402 → PaymentError, 424 →
28
+ * ExternalDependencyFailed), then core's HTTP status map (with
29
+ * retryAfter hints), then UnknownStripeError.
30
+ */
31
+ import * as Context from "effect/Context";
32
+ import * as Effect from "effect/Effect";
33
+ import * as Layer from "effect/Layer";
34
+ import * as Option from "effect/Option";
35
+ import * as Redacted from "effect/Redacted";
36
+ import * as HttpBody from "effect/unstable/http/HttpBody";
37
+ import * as HttpClientRequest from "effect/unstable/http/HttpClientRequest";
38
+ import * as API from "@distilled.cloud/core/api";
39
+ import { buildRequest, getAnn, getProps, hasPropAnn, mapKeys, nameOf, } from "@distilled.cloud/core/protocol-http";
40
+ import { unwrapRedactedDeep, wrapSensitive, } from "@distilled.cloud/core/protocol-rest";
41
+ import { ConfigError, HTTP_STATUS_MAP, InternalServerError, BadRequest, Conflict, Forbidden, Locked, NotFound, UnprocessableEntity, } from "@distilled.cloud/core/errors";
42
+ import { parseRetryAfterForStatus } from "@distilled.cloud/core/retry-after";
43
+ import { Credentials } from "./credentials.js";
44
+ import { ApiError, CardError, ExternalDependencyFailed, IdempotencyError, InvalidRequestError, PaymentError, STRIPE_HTTP_STATUS_MAP, StripeParseError, UnknownStripeError, } from "./errors.js";
45
+ import { bodySymbol, headerSymbol, httpSymbol, labelSymbol, querySymbol, } from "./traits.js";
46
+ /**
47
+ * Per-call request options service. distilled v0 passed these as a second
48
+ * call argument; v1 operations take only their input, so options travel on
49
+ * the calling fiber's context instead — see {@link withRequestOptions}.
50
+ */
51
+ export class RequestOptions extends Context.Service()("StripeRequestOptions") {
52
+ }
53
+ /**
54
+ * Provide {@link StripeRequestOptions} to every Stripe API call below it.
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * yield* PostCharges({ amount: 2000, currency: "usd" }).pipe(
59
+ * Stripe.withRequestOptions({ idempotencyKey: "ch-create-1" }),
60
+ * );
61
+ * ```
62
+ */
63
+ export const withRequestOptions = (options) => Effect.provide(Layer.succeed(RequestOptions, options));
64
+ const stripeRequestHeaders = (options) => {
65
+ const headers = {};
66
+ if (options?.idempotencyKey !== undefined) {
67
+ headers["Idempotency-Key"] = options.idempotencyKey;
68
+ }
69
+ if (options?.stripeAccount !== undefined) {
70
+ headers["Stripe-Account"] = options.stripeAccount;
71
+ }
72
+ if (options?.stripeContext !== undefined) {
73
+ headers["Stripe-Context"] = options.stripeContext;
74
+ }
75
+ if (options?.apiVersion !== undefined) {
76
+ headers["Stripe-Version"] = options.apiVersion;
77
+ }
78
+ return headers;
79
+ };
80
+ // Bridge: Protocol.decode is typed as Effect<unknown> (no error channel), but
81
+ // Stripe failures are real typed errors that an operation re-surfaces via its
82
+ // `errors: [...]` list / StripeOpError annotation. Fail with the instance and
83
+ // erase the error type here; the generated annotations reintroduce it.
84
+ const fail = (e) => Effect.fail(e);
85
+ // =============================================================================
86
+ // Stripe query / form encoding (ported from distilled v0)
87
+ // =============================================================================
88
+ const BODYLESS = new Set(["GET", "HEAD"]);
89
+ const appendQueryValue = (query, key, value) => {
90
+ if (value === undefined || value === null)
91
+ return;
92
+ query.append(key, typeof value === "boolean" ? (value ? "true" : "false") : String(value));
93
+ };
94
+ /**
95
+ * Stripe GET-query bracket expansion (v0's `appendStripeQuery`): arrays as
96
+ * repeated `key[]` entries, nested objects as `key[nested]`, recursively.
97
+ */
98
+ const appendStripeQuery = (query, key, value) => {
99
+ if (value === undefined || value === null)
100
+ return;
101
+ if (Array.isArray(value)) {
102
+ for (const item of value)
103
+ appendQueryValue(query, `${key}[]`, item);
104
+ return;
105
+ }
106
+ if (typeof value === "object" && !(value instanceof Date)) {
107
+ for (const [nestedKey, nestedValue] of Object.entries(value)) {
108
+ appendStripeQuery(query, `${key}[${nestedKey}]`, nestedValue);
109
+ }
110
+ return;
111
+ }
112
+ appendQueryValue(query, key, value);
113
+ };
114
+ /**
115
+ * Recursively flatten a nested object into Stripe-style bracket notation
116
+ * for application/x-www-form-urlencoded encoding (v0's `flattenToFormPairs`).
117
+ *
118
+ * Examples:
119
+ * { amount: 2000 } -> "amount=2000"
120
+ * { shipping: { address: { city: "SF" } } } -> "shipping[address][city]=SF"
121
+ * { expand: ["data"] } -> "expand[0]=data"
122
+ * { metadata: { key: "val" } } -> "metadata[key]=val"
123
+ */
124
+ const flattenToFormPairs = (obj, prefix = "") => {
125
+ const pairs = [];
126
+ for (const [key, value] of Object.entries(obj)) {
127
+ if (value === undefined || value === null)
128
+ continue;
129
+ const fullKey = prefix ? `${prefix}[${key}]` : key;
130
+ if (Array.isArray(value)) {
131
+ for (let i = 0; i < value.length; i++) {
132
+ const item = value[i];
133
+ if (item !== null &&
134
+ item !== undefined &&
135
+ typeof item === "object" &&
136
+ !Array.isArray(item)) {
137
+ pairs.push(...flattenToFormPairs(item, `${fullKey}[${i}]`));
138
+ }
139
+ else if (item !== undefined && item !== null) {
140
+ pairs.push([`${fullKey}[${i}]`, String(item)]);
141
+ }
142
+ }
143
+ }
144
+ else if (typeof value === "object") {
145
+ pairs.push(...flattenToFormPairs(value, fullKey));
146
+ }
147
+ else if (typeof value === "boolean") {
148
+ pairs.push([fullKey, value ? "true" : "false"]);
149
+ }
150
+ else {
151
+ pairs.push([fullKey, String(value)]);
152
+ }
153
+ }
154
+ return pairs;
155
+ };
156
+ /** Build the urlencoded body from a nested object (Stripe deepObject style). */
157
+ const buildFormUrlEncoded = (body) => {
158
+ const params = new URLSearchParams();
159
+ for (const [key, value] of flattenToFormPairs(body)) {
160
+ params.append(key, value);
161
+ }
162
+ return params.toString();
163
+ };
164
+ // =============================================================================
165
+ // Request building
166
+ // =============================================================================
167
+ // The protocol layer is memoized per process by `API.make`, so the build
168
+ // must not capture credentials — `encode` resolves Credentials (and the
169
+ // per-call RequestOptions) from the calling fiber's context on every
170
+ // request. The requirement is erased at this boundary and reintroduced for
171
+ // callers by the generated `StripeOpContext` annotations.
172
+ const encode = ({ input, inputAst, }) => Effect.gen(function* () {
173
+ const resolveCredentials = yield* Credentials;
174
+ const creds = yield* resolveCredentials;
175
+ const options = Option.getOrUndefined(yield* Effect.serviceOption(RequestOptions));
176
+ const http = getAnn(inputAst, httpSymbol);
177
+ if (!http) {
178
+ throw new Error("operation input is missing the Http() trait");
179
+ }
180
+ const baseHeaders = {
181
+ Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
182
+ ...stripeRequestHeaders(options),
183
+ Accept: "application/json",
184
+ };
185
+ // Multipart (POST /v1/files): core's buildRequest speaks multipart
186
+ // form-data (file parts + JSON-encoded object parts) — same behavior as
187
+ // v0's buildFormData.
188
+ if (http.contentType === "multipart") {
189
+ return buildRequest({
190
+ input: unwrapRedactedDeep(input),
191
+ inputAst,
192
+ baseUrl: creds.apiBaseUrl,
193
+ headers: baseHeaders,
194
+ });
195
+ }
196
+ const inputObj = (unwrapRedactedDeep(input) ?? {});
197
+ const headers = { ...baseHeaders };
198
+ const body = {};
199
+ const query = new URLSearchParams();
200
+ let uri = http.uri;
201
+ const consumed = new Set();
202
+ for (const prop of getProps(inputAst)) {
203
+ const key = String(prop.name);
204
+ consumed.add(key);
205
+ const value = inputObj[key];
206
+ if (value === undefined)
207
+ continue;
208
+ if (hasPropAnn(prop, labelSymbol)) {
209
+ const token = nameOf(prop, labelSymbol);
210
+ uri = uri.replace(`{${token}}`, encodeURIComponent(String(value)));
211
+ }
212
+ else if (hasPropAnn(prop, headerSymbol)) {
213
+ headers[nameOf(prop, headerSymbol).toLowerCase()] = String(value);
214
+ }
215
+ else if (hasPropAnn(prop, querySymbol)) {
216
+ // Stripe bracket expansion, not dotted params (`created[gte]=1`).
217
+ appendStripeQuery(query, nameOf(prop, querySymbol), value);
218
+ }
219
+ else {
220
+ body[nameOf(prop, bodySymbol)] = mapKeys(prop.type, value, "encode");
221
+ }
222
+ }
223
+ // Input keys the schema doesn't know pass through as body fields — the
224
+ // generated schemas can lag the real API, and silently dropping them
225
+ // would break working callers.
226
+ for (const [key, value] of Object.entries(inputObj)) {
227
+ if (consumed.has(key) || value === undefined)
228
+ continue;
229
+ body[key] = value;
230
+ }
231
+ // v0's normalizeStripeGetQuery: GET inputs carry no body — flatten the
232
+ // body-bound members into the query string with bracket notation.
233
+ if (BODYLESS.has(http.method)) {
234
+ for (const [key, value] of Object.entries(body)) {
235
+ appendStripeQuery(query, key, value);
236
+ }
237
+ }
238
+ const qs = query.toString();
239
+ const url = `${creds.apiBaseUrl}${uri}${qs ? `?${qs}` : ""}`;
240
+ if (process.env.DISTILLED_DEBUG_HTTP) {
241
+ console.error(`[distilled] ${http.method} ${url}` +
242
+ (Object.keys(body).length && !BODYLESS.has(http.method)
243
+ ? ` body=${JSON.stringify(body).slice(0, 400)}`
244
+ : ""));
245
+ }
246
+ let request = HttpClientRequest.make(http.method)(url).pipe(HttpClientRequest.setHeaders(headers));
247
+ if (!BODYLESS.has(http.method) && Object.keys(body).length > 0) {
248
+ request =
249
+ http.contentType === "form-urlencoded"
250
+ ? request.pipe(HttpClientRequest.setBody(HttpBody.text(buildFormUrlEncoded(body), "application/x-www-form-urlencoded")))
251
+ : // The /v2/* operations are plain JSON.
252
+ request.pipe(HttpClientRequest.bodyJsonUnsafe(body));
253
+ }
254
+ return request;
255
+ });
256
+ // =============================================================================
257
+ // Response decoding / error matching (ported from v0's matchError)
258
+ // =============================================================================
259
+ const str = (v) => typeof v === "string" ? v : undefined;
260
+ // Structural views of the status maps for numeric lookup (the const objects'
261
+ // per-status class types don't unify without widening the constructor).
262
+ const stripeStatusMap = STRIPE_HTTP_STATUS_MAP;
263
+ const coreStatusMap = HTTP_STATUS_MAP;
264
+ /**
265
+ * Match a Stripe API error response to the appropriate error class.
266
+ *
267
+ * Stripe dispatches errors by:
268
+ * 1. The `error.type` field (card_error, idempotency_error,
269
+ * invalid_request_error, api_error)
270
+ * 2. HTTP status code (402/424 Stripe-specific, then the core status map)
271
+ */
272
+ const matchStripeError = (status, errorBody, headers) => {
273
+ const envelope = errorBody !== null && typeof errorBody === "object"
274
+ ? errorBody.error
275
+ : undefined;
276
+ const err = envelope !== null && typeof envelope === "object"
277
+ ? envelope
278
+ : undefined;
279
+ // v0 parity: an unparseable envelope (no `error.type` string) is an
280
+ // UnknownStripeError carrying the raw body.
281
+ if (!err || typeof err.type !== "string") {
282
+ return new UnknownStripeError({ body: errorBody });
283
+ }
284
+ const common = {
285
+ message: str(err.message),
286
+ code: str(err.code),
287
+ doc_url: str(err.doc_url),
288
+ request_log_url: str(err.request_log_url),
289
+ };
290
+ // Match by Stripe error type first for richer error info.
291
+ switch (err.type) {
292
+ case "card_error":
293
+ return new CardError({
294
+ ...common,
295
+ decline_code: str(err.decline_code),
296
+ charge: str(err.charge),
297
+ param: str(err.param),
298
+ advice_code: str(err.advice_code),
299
+ network_advice_code: str(err.network_advice_code),
300
+ network_decline_code: str(err.network_decline_code),
301
+ payment_method_type: str(err.payment_method_type),
302
+ });
303
+ case "idempotency_error":
304
+ return new IdempotencyError(common);
305
+ case "invalid_request_error":
306
+ return new InvalidRequestError({ ...common, param: str(err.param) });
307
+ case "api_error":
308
+ return new ApiError({ ...common, param: str(err.param) });
309
+ }
310
+ // Fall back to Stripe-specific HTTP status codes (402, 424).
311
+ const StripeErrorClass = stripeStatusMap[status];
312
+ if (StripeErrorClass) {
313
+ return new StripeErrorClass({
314
+ message: common.message,
315
+ code: common.code,
316
+ ...(str(err.decline_code) !== undefined
317
+ ? { decline_code: str(err.decline_code) }
318
+ : {}),
319
+ ...(str(err.charge) !== undefined ? { charge: str(err.charge) } : {}),
320
+ ...(str(err.param) !== undefined ? { param: str(err.param) } : {}),
321
+ ...(common.doc_url !== undefined ? { doc_url: common.doc_url } : {}),
322
+ ...(common.request_log_url !== undefined
323
+ ? { request_log_url: common.request_log_url }
324
+ : {}),
325
+ });
326
+ }
327
+ // Fall back to standard HTTP status errors (400, 401, 403, 404, …).
328
+ const CoreErrorClass = coreStatusMap[status];
329
+ if (CoreErrorClass) {
330
+ return new CoreErrorClass({
331
+ message: common.message ?? "",
332
+ retryAfter: parseRetryAfterForStatus(status, headers),
333
+ });
334
+ }
335
+ // Unmapped 5xx (e.g. proxy statuses) → retryable server error (v1
336
+ // convention; v0 fell through to UnknownStripeError here).
337
+ if (status >= 500) {
338
+ return new InternalServerError({
339
+ message: common.message ?? `HTTP ${status}`,
340
+ retryAfter: parseRetryAfterForStatus(status, headers),
341
+ });
342
+ }
343
+ return new UnknownStripeError({
344
+ type: str(err.type),
345
+ code: common.code,
346
+ message: common.message,
347
+ param: str(err.param),
348
+ body: errorBody,
349
+ });
350
+ };
351
+ const decode = ({ response, outputAst, }) => Effect.gen(function* () {
352
+ // Read as text and parse tolerantly — error pages can be non-JSON.
353
+ const text = (yield* response.text.pipe(Effect.orDie)) ?? "";
354
+ if (process.env.DISTILLED_DEBUG_HTTP) {
355
+ console.error(`[distilled] <- ${response.status} ${text.slice(0, 400)}`);
356
+ }
357
+ let json;
358
+ let nonJson = false;
359
+ if (text.trim().length > 0) {
360
+ try {
361
+ json = JSON.parse(text);
362
+ }
363
+ catch {
364
+ nonJson = true;
365
+ }
366
+ }
367
+ const status = response.status;
368
+ const headers = response.headers;
369
+ if (status >= 400) {
370
+ return yield* fail(matchStripeError(status, nonJson ? text : json, headers));
371
+ }
372
+ // 2xx: the response body IS the payload (no envelope). Wire→TS key
373
+ // mapping is schema-driven; sensitive members come back Redacted.
374
+ const body = nonJson ? text : (json ?? {});
375
+ return wrapSensitive(outputAst, mapKeys(outputAst, body, "decode"));
376
+ });
377
+ export const StripeProtocol = Layer.succeed(API.Protocol, API.Protocol.of({
378
+ // Erase encode's Credentials requirement (see comment above).
379
+ encode: (args) => encode(args),
380
+ decode,
381
+ }));
382
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAI5C,OAAO,KAAK,QAAQ,MAAM,+BAA+B,CAAC;AAC1D,OAAO,KAAK,iBAAiB,MAAM,wCAAwC,CAAC;AAE5E,OAAO,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACjD,OAAO,EACL,YAAY,EACZ,MAAM,EACN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ire into `API.make`. Callers can install a blanket retry policy at the
6
+ * layer level and have every Stripe API call below it pick it up:
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import * as Stripe from "@distilled.cloud/stripe";
11
+ *
12
+ * myEffect.pipe(Stripe.Retry.transient);
13
+ * Effect.provide(myEffect, Layer.succeed(Stripe.Retry.Retry, customPolicy));
14
+ * ```
15
+ */
16
+ import * as Context from "effect/Context";
17
+ import * as Effect from "effect/Effect";
18
+ import { type Policy } from "@distilled.cloud/core/retry";
19
+ export { type Options, type Factory, type Policy, makeDefault, jittered, capped, throttlingOptions, transientOptions, throttlingFactory, transientFactory, } from "@distilled.cloud/core/retry";
20
+ declare const Retry_base: Context.ServiceClass<Retry, "StripeRetry", Policy>;
21
+ /** Context tag for configuring retry behavior of Stripe API calls. */
22
+ export declare class Retry extends Retry_base {
23
+ }
24
+ /** Provides a custom retry policy to every Stripe API call below it. */
25
+ export declare const policy: (optionsOrFactory: Policy) => <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
26
+ /** Disables all automatic retries. */
27
+ export declare const none: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
28
+ /** Apply the throttling retry policy (retries throttling errors indefinitely). */
29
+ export declare const throttling: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
30
+ /** Apply the transient retry policy (retries all transient errors indefinitely). */
31
+ export declare const transient: <A, E, R>(self: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
32
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,EACL,KAAK,MAAM,EAGZ,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,OAAO,EACZ,KAAK,MAAM,EACX,WAAW,EACX,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;;AAErC,sEAAsE;AACtE,qBAAa,KAAM,SAAQ,UAA+C;CAAG;AAE7E,wEAAwE;AACxE,eAAO,MAAM,MAAM,qBAAsB,MAAM,sFACS,CAAC;AAEzD,sCAAsC;AACtC,eAAO,MAAM,IAAI,mFAEhB,CAAC;AAEF,kFAAkF;AAClF,eAAO,MAAM,UAAU,mFAA4B,CAAC;AAEpD,oFAAoF;AACpF,eAAO,MAAM,SAAS,mFAA2B,CAAC"}
package/lib/retry.js ADDED
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Stripe retry configuration.
3
+ *
4
+ * Defines the per-SDK `Retry` Context.Service tag that generated operations
5
+ * wire into `API.make`. Callers can install a blanket retry policy at the
6
+ * layer level and have every Stripe API call below it pick it up:
7
+ *
8
+ * @example
9
+ * ```ts
10
+ * import * as Stripe from "@distilled.cloud/stripe";
11
+ *
12
+ * myEffect.pipe(Stripe.Retry.transient);
13
+ * Effect.provide(myEffect, Layer.succeed(Stripe.Retry.Retry, customPolicy));
14
+ * ```
15
+ */
16
+ import * as Context from "effect/Context";
17
+ import * as Effect from "effect/Effect";
18
+ import * as Layer from "effect/Layer";
19
+ import { throttlingFactory, transientFactory, } from "@distilled.cloud/core/retry";
20
+ export { makeDefault, jittered, capped, throttlingOptions, transientOptions, throttlingFactory, transientFactory, } from "@distilled.cloud/core/retry";
21
+ /** Context tag for configuring retry behavior of Stripe API calls. */
22
+ export class Retry extends Context.Service()("StripeRetry") {
23
+ }
24
+ /** Provides a custom retry policy to every Stripe API call below it. */
25
+ export const policy = (optionsOrFactory) => Effect.provide(Layer.succeed(Retry, optionsOrFactory));
26
+ /** Disables all automatic retries. */
27
+ export const none = Effect.provide(Layer.succeed(Retry, { while: () => false }));
28
+ /** Apply the throttling retry policy (retries throttling errors indefinitely). */
29
+ export const throttling = policy(throttlingFactory);
30
+ /** Apply the transient retry policy (retries all transient errors indefinitely). */
31
+ export const transient = policy(transientFactory);
32
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,EAEL,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EAIL,WAAW,EACX,QAAQ,EACR,MAAM,EACN,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,6BAA6B,CAAC;AAErC,sEAAsE;AACtE,MAAM,OAAO,KAAM,SAAQ,OAAO,CAAC,OAAO,EAAiB,CAAC,aAAa,CAAC;CAAG;AAE7E,wEAAwE;AACxE,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,gBAAwB,EAAE,EAAE,CACjD,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC;AAEzD,sCAAsC;AACtC,MAAM,CAAC,MAAM,IAAI,GAAG,MAAM,CAAC,OAAO,CAChC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,CAAC,CAC7C,CAAC;AAEF,kFAAkF;AAClF,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,iBAAiB,CAAC,CAAC;AAEpD,oFAAoF;AACpF,MAAM,CAAC,MAAM,SAAS,GAAG,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * as stripe from "./stripe.ts";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ // AUTO-GENERATED by scripts/generate.ts. Do not edit.
2
+ export * as stripe from "./stripe.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/services/index.ts"],"names":[],"mappings":"AAAA,sDAAsD;AACtD,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC"}