@distilled.cloud/resend 1.0.0-rc.16 → 1.0.0-rc.18
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/lib/.lazy.json +1 -0
- package/lib/_bundle/lazy.js +4 -0
- package/lib/_bundle/sdk.js +2 -0
- package/lib/_bundle/sdk.js.map +1 -0
- package/lib/credentials.d.ts +2 -1
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +1 -35
- package/lib/errors.js +1 -26
- package/lib/index.d.ts +3 -3
- package/lib/index.js +0 -19
- package/lib/index.lazy.js +8 -0
- package/lib/pagination.js +1 -48
- package/lib/protocol.d.ts +2 -2
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +1 -50
- package/lib/retry.js +1 -33
- package/lib/services/index.js +0 -2
- package/lib/services/resend.d.ts.map +1 -1
- package/lib/services/resend.js +105 -245
- package/lib/services/resend.js.map +1 -0
- package/lib/services.lazy/index.js +3 -0
- package/lib/services.lazy/resend.js +3 -0
- package/lib/traits.js +1 -11
- package/package.json +9 -10
- package/src/credentials.ts +2 -2
- package/src/index.ts +3 -3
- package/src/protocol.ts +3 -2
- package/src/services/resend.ts +171 -0
- package/lib/credentials.js.map +0 -1
- package/lib/errors.js.map +0 -1
- package/lib/pagination.js.map +0 -1
- package/lib/protocol.js.map +0 -1
- package/lib/retry.js.map +0 -1
- package/lib/services/index.js.map +0 -1
- package/lib/traits.js.map +0 -1
- /package/lib/{index.js.map → index.lazy.js.map} +0 -0
package/lib/.lazy.json
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"serviceDirs":["services"],"twins":["index.js"]}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{errors$API_ERRORS as e,errors$BadGateway as t,errors$BadRequest as n,errors$ConfigError as r,errors$Conflict as i,errors$DEFAULT_ERRORS as a,errors$Forbidden as o,errors$GatewayTimeout as s,errors$HTTP_STATUS_MAP as c,errors$InternalServerError as l,errors$Locked as u,errors$NotFound as d,errors$ServiceUnavailable as ee,errors$TooManyRequests as f,errors$Unauthorized as p,errors$UnprocessableEntity as m,protocol_rest$RawResponse as h,protocol_rest$RawResponseRoot as g,protocol_rest$SensitiveValue as _,protocol_rest$makeRestProtocol as te,protocol_rest$rawResponseRootSymbol as ne,protocol_rest$rawResponseSymbol as re,protocol_rest$sensitiveValueSymbol as ie,schema_lite$Array as ae,schema_lite$Boolean as v,schema_lite$NullOr as y,schema_lite$Number as b,schema_lite$Record as x,schema_lite$String as S,schema_lite$Struct as C,schema_lite$Unknown as w,schema_lite$at as T,schema_lite$optional as E,schema_lite$suspend as D}from"@distilled.cloud/core/_bundle/rest";import{api$D as O,api$call as k,api$named as A,api$op as j,api$opPaginated as M,category$withParseError as N,category$withServerError as P,pagination$getItems as F,pagination$getPath as I,retry$capped as L,retry$jittered as R,retry$makeDefault as z,retry$throttlingFactory as B,retry$throttlingOptions as V,retry$transientFactory as H,retry$transientOptions as U,schema_lite_typed$String as W,schema_lite_typed$TaggedError as G,schema_lite_typed$Unknown as K,schema_lite_typed$optional as q,trait$Body as J,trait$FormDataFile as oe,trait$Header as se,trait$Http as ce,trait$HttpBody as le,trait$KeyDictionary as ue,trait$Label as de,trait$Query as fe,trait$ResponseCode as pe,trait$UnionCases as me,trait$applyErrorMatchers as he,trait$bodySymbol as ge,trait$errorMatchersSymbol as _e,trait$formDataFileSymbol as ve,trait$getErrorMatchers as ye,trait$headerSymbol as be,trait$httpBodySymbol as xe,trait$httpSymbol as Se,trait$keyDictionarySymbol as Ce,trait$labelSymbol as we,trait$querySymbol as Te,trait$responseCodeSymbol as Ee,trait$unionCasesSymbol as De}from"@distilled.cloud/core/_bundle/base";import*as Y from"effect/Context";import*as X from"effect/Effect";import*as Z from"effect/Layer";import*as Q from"effect/Redacted";import*as $ from"effect/Stream";const Oe=`https://api.resend.com`;var Credentials=class extends (/*@__PURE__*/ Y.Service()(`ResendCredentials`)){};const fromApiKey=e=>Z.succeed(Credentials,X.succeed({apiKey:e.apiKey,apiBaseUrl:e.apiBaseUrl??`https://api.resend.com`}));const ke=/*@__PURE__*/ Z.succeed(Credentials,/*@__PURE__*/ X.gen(function*(){const e=process.env.RESEND_API_KEY;if(!e)return yield*new r({message:`RESEND_API_KEY environment variable is required`});return{apiKey:Q.make(e),apiBaseUrl:process.env.RESEND_API_BASE_URL??`https://api.resend.com`}}));var UnknownResendError=class extends (/*@__PURE__*/ G()(`UnknownResendError`,{code:/*@__PURE__*/ q(W),message:/*@__PURE__*/ q(W),body:K}).pipe(P)){};var ResendParseError=class extends (/*@__PURE__*/ G()(`ResendParseError`,{body:K,cause:K}).pipe(N)){};const paginateResend=(e,t,n)=>{const r=n.inputToken;if(!r)return $.die(/* @__PURE__ */ new Error(`Resend cursor pagination requires inputToken`));const i=n.hasNextPage??`has_more`;const a=n.items??`data`;const o=typeof t[r]===`string`?t[r]:void 0;return $.unfold({cursor:o,done:false},n=>X.gen(function*(){if(n.done)return void 0;const o=yield*e({...t,...n.cursor?{[r]:n.cursor}:{}});const s=F(o,a).at(-1);const c=typeof s?.id===`string`?s.id:void 0;const l=I(o,i)===true;const u=n.cursor!==void 0&&c===n.cursor;return[o,{cursor:c,done:!l||c===void 0||u}]}))};const Ae=/*@__PURE__*/ te({credentials:/*@__PURE__*/ X.flatMap(Credentials,e=>e),baseUrl:e=>e.apiBaseUrl,headers:e=>({Authorization:`Bearer ${Q.value(e.apiKey)}`}),errorEnvelope:e=>{if(e===null||typeof e!==`object`)return void 0;const t=e;const n=typeof t.name===`string`?t.name:typeof t.code===`string`?t.code:void 0;const r=typeof t.message===`string`?t.message:void 0;if(n===void 0&&r===void 0)return void 0;return{code:n,message:r}},unknownError:({code:e,message:t,body:n})=>new UnknownResendError({code:typeof e===`string`?e:e!==void 0?String(e):void 0,message:t,body:n}),parseError:({body:e,cause:t})=>new ResendParseError({body:e,cause:t})});var Retry=class extends (/*@__PURE__*/ Y.Service()(`ResendRetry`)){};const policy=e=>X.provide(Z.succeed(Retry,e));const je=/*@__PURE__*/ X.provide(/*@__PURE__*/ Z.succeed(Retry,{while:()=>false}));const Me=/*@__PURE__*/ policy(B);const Ne=/*@__PURE__*/ policy(H);export{ae as Xb,v as Yb,O as a,k as c,Credentials as credentials$Credentials,ke as credentials$CredentialsFromEnv,Oe as credentials$DEFAULT_API_BASE_URL,fromApiKey as credentials$fromApiKey,y as ec,e as errors$API_ERRORS,t as errors$BadGateway,n as errors$BadRequest,r as errors$ConfigError,i as errors$Conflict,a as errors$DEFAULT_ERRORS,o as errors$Forbidden,s as errors$GatewayTimeout,c as errors$HTTP_STATUS_MAP,l as errors$InternalServerError,u as errors$Locked,d as errors$NotFound,ResendParseError as errors$ResendParseError,ee as errors$ServiceUnavailable,f as errors$TooManyRequests,p as errors$Unauthorized,UnknownResendError as errors$UnknownResendError,m as errors$UnprocessableEntity,b as fc,x as gc,S as ic,A as j,C as jc,j as l,M as m,w as oc,paginateResend as pagination$paginateResend,Ae as protocol$ResendProtocol,T as qc,Retry as retry$Retry,L as retry$capped,R as retry$jittered,z as retry$makeDefault,je as retry$none,policy as retry$policy,Me as retry$throttling,B as retry$throttlingFactory,V as retry$throttlingOptions,Ne as retry$transient,H as retry$transientFactory,U as retry$transientOptions,J as traits$Body,oe as traits$FormDataFile,se as traits$Header,ce as traits$Http,le as traits$HttpBody,ue as traits$KeyDictionary,de as traits$Label,fe as traits$Query,h as traits$RawResponse,g as traits$RawResponseRoot,pe as traits$ResponseCode,_ as traits$SensitiveValue,me as traits$UnionCases,he as traits$applyErrorMatchers,ge as traits$bodySymbol,_e as traits$errorMatchersSymbol,ve as traits$formDataFileSymbol,ye as traits$getErrorMatchers,be as traits$headerSymbol,xe as traits$httpBodySymbol,Se as traits$httpSymbol,Ce as traits$keyDictionarySymbol,we as traits$labelSymbol,Te as traits$querySymbol,ne as traits$rawResponseRootSymbol,re as traits$rawResponseSymbol,Ee as traits$responseCodeSymbol,ie as traits$sensitiveValueSymbol,De as traits$unionCasesSymbol,E as vc,D as wc};
|
|
2
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.js","names":["Schema.String","Schema.Unknown","Category.withServerError","Category.withParseError","Pagination.getItems","Pagination.getPath","API_ERRORS","BadGateway","BadRequest","ConfigError","Conflict","DEFAULT_ERRORS","Forbidden","GatewayTimeout","HTTP_STATUS_MAP","InternalServerError","Locked","NotFound","ServiceUnavailable","TooManyRequests","Unauthorized","UnprocessableEntity","RawResponse","RawResponseRoot","SensitiveValue","makeRestProtocol","rawResponseRootSymbol","rawResponseSymbol","sensitiveValueSymbol","Array","Boolean","NullOr","Number","Record","String$1","Struct","Unknown","at","optional","suspend","D","call","named","op","opPaginated","withParseError","withServerError","getItems","getPath","capped","jittered","makeDefault","throttlingFactory","throttlingOptions","transientFactory","transientOptions","String$2","TaggedError$1","Unknown$1","optional$1","Body","FormDataFile","Header","Http","HttpBody","KeyDictionary","Label","Query","ResponseCode","UnionCases","applyErrorMatchers","bodySymbol","errorMatchersSymbol","formDataFileSymbol","getErrorMatchers","headerSymbol","httpBodySymbol","httpSymbol","keyDictionarySymbol","labelSymbol","querySymbol","responseCodeSymbol","unionCasesSymbol","Context","Effect","Layer","Redacted","Stream","DEFAULT_API_BASE_URL","config","CredentialsFromEnv","apiKey","inputToken","pagination","hasNextPath","itemsPath","startCursor","input","state","response","operation","last","nextCursor","hasNext","stuckCursor","ResendProtocol","resolve","creds","body","rec","code","message","optionsOrFactory","none","throttling","transient"],"sources":["../../src/credentials.ts","../../src/errors.ts","../../src/pagination.ts","../../src/protocol.ts","../../src/retry.ts"],"mappings":"isEAaA,MAAawF,GAAuB,yBAOpC,IAAa,YAAb,eACwB,gBAAQ,QAAyD,CAAC,CACtF,mBACF,EAAA,AAAE,CAAC,EAGL,MAAa,WAAc,GAIzBH,EAAM,QACJ,YACAD,EAAO,QAAQ,CACb,OAAQK,EAAO,OACf,WAAYA,EAAO,YAAA,wBACrB,CAAC,C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AAE,UAAa,KAAM,CAAC,CAC3D,EAGA,MAAaC,GAA2B,qBAAO9D,CAAiB,EAGhE,MAAa+D,GAA0B,qBAAO7D,CAAgB"}
|
package/lib/credentials.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
1
2
|
/**
|
|
2
3
|
* Resend credentials -- hand-written.
|
|
3
4
|
*
|
|
@@ -14,7 +15,7 @@ export interface Config {
|
|
|
14
15
|
readonly apiKey: Redacted.Redacted<string>;
|
|
15
16
|
readonly apiBaseUrl: string;
|
|
16
17
|
}
|
|
17
|
-
declare const Credentials_base: Context.ServiceClass<Credentials, "ResendCredentials", Effect.Effect<Config,
|
|
18
|
+
declare const Credentials_base: Context.ServiceClass<Credentials, "ResendCredentials", Effect.Effect<Config, ConfigError, never>>;
|
|
18
19
|
export declare class Credentials extends /*@__PURE__*/ Credentials_base {
|
|
19
20
|
}
|
|
20
21
|
/** Layer from a redacted API key + optional base URL. */
|
package/lib/credentials.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D;;;;;;GAMG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAE5C,eAAO,MAAM,oBAAoB,2BAA2B,CAAC;AAE7D,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WACX,SAAQ,aAAa,CAAC,gBAErB;CAAG;AAEN,yDAAyD;AACzD,eAAO,MAAM,UAAU,WAAY;IACjC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAOxB,CAAC;AAEJ,0EAA0E;AAC1E,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,CAgBvD,CAAC"}
|
package/lib/credentials.js
CHANGED
|
@@ -1,35 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
import * as Context from "effect/Context";
|
|
10
|
-
import * as Effect from "effect/Effect";
|
|
11
|
-
import * as Layer from "effect/Layer";
|
|
12
|
-
import * as Redacted from "effect/Redacted";
|
|
13
|
-
export const DEFAULT_API_BASE_URL = "https://api.resend.com";
|
|
14
|
-
export class Credentials extends /*@__PURE__*/ /*@__PURE__*/ Context.Service()("ResendCredentials") {
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export const fromApiKey = (config) => Layer.succeed(Credentials, Effect.succeed({
|
|
18
|
-
apiKey: config.apiKey,
|
|
19
|
-
apiBaseUrl: config.apiBaseUrl ?? DEFAULT_API_BASE_URL,
|
|
20
|
-
}));
|
|
21
|
-
|
|
22
|
-
export const CredentialsFromEnv = /*@__PURE__*/ Layer.succeed(Credentials,
|
|
23
|
-
/*@__PURE__*/ Effect.gen(function* () {
|
|
24
|
-
const apiKey = process.env.RESEND_API_KEY;
|
|
25
|
-
if (!apiKey) {
|
|
26
|
-
return yield* new ConfigError({
|
|
27
|
-
message: "RESEND_API_KEY environment variable is required",
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
return {
|
|
31
|
-
apiKey: Redacted.make(apiKey),
|
|
32
|
-
apiBaseUrl: process.env.RESEND_API_BASE_URL ?? DEFAULT_API_BASE_URL,
|
|
33
|
-
};
|
|
34
|
-
}).pipe(Effect.orDie));
|
|
35
|
-
//# sourceMappingURL=credentials.js.map
|
|
1
|
+
export { credentials$Credentials as Credentials, credentials$CredentialsFromEnv as CredentialsFromEnv, credentials$DEFAULT_API_BASE_URL as DEFAULT_API_BASE_URL, credentials$fromApiKey as fromApiKey } from "./_bundle/sdk.js";
|
package/lib/errors.js
CHANGED
|
@@ -1,26 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
11
|
-
import * as Category from "@distilled.cloud/core/category";
|
|
12
|
-
import * as Schema from "@distilled.cloud/core/schema-lite-typed";
|
|
13
|
-
|
|
14
|
-
export class UnknownResendError extends /*@__PURE__*/ /*@__PURE__*/ Schema.TaggedError()("UnknownResendError", {
|
|
15
|
-
code: /*@__PURE__*/ Schema.optional(Schema.String),
|
|
16
|
-
message: /*@__PURE__*/ Schema.optional(Schema.String),
|
|
17
|
-
body: Schema.Unknown,
|
|
18
|
-
}).pipe(Category.withServerError) {
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export class ResendParseError extends /*@__PURE__*/ /*@__PURE__*/ Schema.TaggedError()("ResendParseError", {
|
|
22
|
-
body: Schema.Unknown,
|
|
23
|
-
cause: Schema.Unknown,
|
|
24
|
-
}).pipe(Category.withParseError) {
|
|
25
|
-
}
|
|
26
|
-
//# sourceMappingURL=errors.js.map
|
|
1
|
+
export { errors$API_ERRORS as API_ERRORS, errors$BadGateway as BadGateway, errors$BadRequest as BadRequest, errors$ConfigError as ConfigError, errors$Conflict as Conflict, errors$DEFAULT_ERRORS as DEFAULT_ERRORS, errors$Forbidden as Forbidden, errors$GatewayTimeout as GatewayTimeout, errors$HTTP_STATUS_MAP as HTTP_STATUS_MAP, errors$InternalServerError as InternalServerError, errors$Locked as Locked, errors$NotFound as NotFound, errors$ResendParseError as ResendParseError, errors$ServiceUnavailable as ServiceUnavailable, errors$TooManyRequests as TooManyRequests, errors$Unauthorized as Unauthorized, errors$UnknownResendError as UnknownResendError, errors$UnprocessableEntity as UnprocessableEntity } from "./_bundle/sdk.js";
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @distilled.cloud/resend -- Resend SDK for Effect.
|
|
3
3
|
*
|
|
4
|
-
* `./services` is generated by `scripts/generate.ts` from the Smithy model
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* `./services` is generated by `scripts/generate.ts` from the Smithy model that
|
|
5
|
+
* `scripts/convert.ts` converts from the OpenAPI spec. Everything else in this
|
|
6
|
+
* folder is hand-written.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* ```ts
|
package/lib/index.js
CHANGED
|
@@ -1,17 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
1
|
export * from "./credentials.js";
|
|
16
2
|
export * from "./errors.js";
|
|
17
3
|
export * as T from "./traits.js";
|
|
@@ -19,9 +5,4 @@ export { ResendProtocol } from "./protocol.js";
|
|
|
19
5
|
export { paginateResend } from "./pagination.js";
|
|
20
6
|
export * as Retry from "./retry.js";
|
|
21
7
|
export * as Services from "./services/index.js";
|
|
22
|
-
// Operations (and their request/response types) are importable straight off
|
|
23
|
-
// the package root. The OpenAPI document does not declare per-status error
|
|
24
|
-
// bodies, so typed error classes are not generated -- failures ride
|
|
25
|
-
// ResendOpError / the shared HTTP-status map.
|
|
26
8
|
export * from "./services/resend.js";
|
|
27
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from "./credentials.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * as T from "./traits.js";
|
|
4
|
+
export { ResendProtocol } from "./protocol.js";
|
|
5
|
+
export { paginateResend } from "./pagination.js";
|
|
6
|
+
export * as Retry from "./retry.js";
|
|
7
|
+
export * as Services from "./services.lazy/index.js";
|
|
8
|
+
export * from "./services.lazy/resend.js";
|
package/lib/pagination.js
CHANGED
|
@@ -1,48 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import * as Effect from "effect/Effect";
|
|
12
|
-
import * as Stream from "effect/Stream";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
export const paginateResend = (operation, input, pagination) => {
|
|
19
|
-
const inputToken = pagination.inputToken;
|
|
20
|
-
if (!inputToken) {
|
|
21
|
-
return Stream.die(new Error("Resend cursor pagination requires inputToken"));
|
|
22
|
-
}
|
|
23
|
-
const hasNextPath = pagination.hasNextPage ?? "has_more";
|
|
24
|
-
const itemsPath = pagination.items ?? "data";
|
|
25
|
-
const startCursor = typeof input[inputToken] === "string" ? input[inputToken] : undefined;
|
|
26
|
-
return Stream.unfold({ cursor: startCursor, done: false }, (state) => Effect.gen(function* () {
|
|
27
|
-
if (state.done)
|
|
28
|
-
return undefined;
|
|
29
|
-
const requestPayload = {
|
|
30
|
-
...input,
|
|
31
|
-
...(state.cursor ? { [inputToken]: state.cursor } : {}),
|
|
32
|
-
};
|
|
33
|
-
const response = yield* operation(requestPayload);
|
|
34
|
-
const items = Pagination.getItems(response, itemsPath);
|
|
35
|
-
const last = items.at(-1);
|
|
36
|
-
const nextCursor = typeof last?.id === "string" ? last.id : undefined;
|
|
37
|
-
const hasNext = Pagination.getPath(response, hasNextPath) === true;
|
|
38
|
-
const stuckCursor = state.cursor !== undefined && nextCursor === state.cursor;
|
|
39
|
-
return [
|
|
40
|
-
response,
|
|
41
|
-
{
|
|
42
|
-
cursor: nextCursor,
|
|
43
|
-
done: !hasNext || nextCursor === undefined || stuckCursor,
|
|
44
|
-
},
|
|
45
|
-
];
|
|
46
|
-
}));
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=pagination.js.map
|
|
1
|
+
export { pagination$paginateResend as paginateResend } from "./_bundle/sdk.js";
|
package/lib/protocol.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as API from "@distilled.cloud/core/api";
|
|
2
|
-
import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
|
|
2
|
+
import type { API_ERRORS, ConfigError, InvalidInput } from "@distilled.cloud/core/errors";
|
|
3
3
|
import type * as HttpClient from "effect/http/HttpClient";
|
|
4
4
|
import type * as HttpClientError from "effect/http/HttpClientError";
|
|
5
5
|
import type * as Layer from "effect/Layer";
|
|
@@ -11,7 +11,7 @@ import { UnknownResendError, ResendParseError } from "./errors.ts";
|
|
|
11
11
|
* ResendOpContext>` explicitly so the compiler never infers these back out of
|
|
12
12
|
* the schema generics.
|
|
13
13
|
*/
|
|
14
|
-
export type ResendOpError = InstanceType<(typeof API_ERRORS)[number]> | UnknownResendError | ConfigError | HttpClientError.HttpClientError | ResendParseError;
|
|
14
|
+
export type ResendOpError = InstanceType<(typeof API_ERRORS)[number]> | UnknownResendError | ConfigError | HttpClientError.HttpClientError | ResendParseError | InvalidInput;
|
|
15
15
|
/** Context (requirements) shared by every generated Resend operation. */
|
|
16
16
|
export type ResendOpContext = Credentials | HttpClient.HttpClient;
|
|
17
17
|
export declare const ResendProtocol: Layer.Layer<API.Protocol>;
|
package/lib/protocol.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAmB1F,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,KAAK,eAAe,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAEnE;;;;;GAKG;AACH,MAAM,MAAM,aAAa,GACrB,YAAY,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GACzC,kBAAkB,GAClB,WAAW,GACX,eAAe,CAAC,eAAe,GAC/B,gBAAgB,GAChB,YAAY,CAAC;AAEjB,yEAAyE;AACzE,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAElE,eAAO,MAAM,cAAc,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CA2BnD,CAAC"}
|
package/lib/protocol.js
CHANGED
|
@@ -1,50 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
import * as Effect from "effect/Effect";
|
|
19
|
-
import * as Redacted from "effect/Redacted";
|
|
20
|
-
import { Credentials } from "./credentials.js";
|
|
21
|
-
import { UnknownResendError, ResendParseError } from "./errors.js";
|
|
22
|
-
export const ResendProtocol = /*@__PURE__*/ makeRestProtocol({
|
|
23
|
-
// The Credentials service holds an effect -- resolving it here (per
|
|
24
|
-
// request, on the calling fiber) picks up context-provided credentials.
|
|
25
|
-
credentials: /*@__PURE__*/ Effect.flatMap(Credentials, (resolve) => resolve),
|
|
26
|
-
baseUrl: (creds) => creds.apiBaseUrl,
|
|
27
|
-
headers: (creds) => ({
|
|
28
|
-
Authorization: `Bearer ${Redacted.value(creds.apiKey)}`,
|
|
29
|
-
}),
|
|
30
|
-
// Resend's error body is `{ name?: string, message: string, statusCode?: number }`.
|
|
31
|
-
// The factory's default lenient envelope covers `{ code, message }`; `name`
|
|
32
|
-
// is the machine-readable code Resend actually sends.
|
|
33
|
-
errorEnvelope: (body) => {
|
|
34
|
-
if (body === null || typeof body !== "object")
|
|
35
|
-
return undefined;
|
|
36
|
-
const rec = body;
|
|
37
|
-
const code = typeof rec.name === "string" ? rec.name : typeof rec.code === "string" ? rec.code : undefined;
|
|
38
|
-
const message = typeof rec.message === "string" ? rec.message : undefined;
|
|
39
|
-
if (code === undefined && message === undefined)
|
|
40
|
-
return undefined;
|
|
41
|
-
return { code, message };
|
|
42
|
-
},
|
|
43
|
-
unknownError: ({ code, message, body }) => new UnknownResendError({
|
|
44
|
-
code: typeof code === "string" ? code : code !== undefined ? String(code) : undefined,
|
|
45
|
-
message,
|
|
46
|
-
body,
|
|
47
|
-
}),
|
|
48
|
-
parseError: ({ body, cause }) => new ResendParseError({ body, cause }),
|
|
49
|
-
});
|
|
50
|
-
//# sourceMappingURL=protocol.js.map
|
|
1
|
+
export { protocol$ResendProtocol as ResendProtocol } from "./_bundle/sdk.js";
|
package/lib/retry.js
CHANGED
|
@@ -1,33 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
import * as Context from "effect/Context";
|
|
18
|
-
import * as Effect from "effect/Effect";
|
|
19
|
-
import * as Layer from "effect/Layer";
|
|
20
|
-
export { makeDefault, jittered, capped, throttlingOptions, transientOptions, throttlingFactory, transientFactory, } from "@distilled.cloud/core/retry";
|
|
21
|
-
|
|
22
|
-
export class Retry extends /*@__PURE__*/ /*@__PURE__*/ Context.Service()("ResendRetry") {
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export const policy = (optionsOrFactory) => Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
26
|
-
|
|
27
|
-
export const none = /*@__PURE__*/ Effect.provide(
|
|
28
|
-
/*@__PURE__*/ Layer.succeed(Retry, { while: () => false }));
|
|
29
|
-
|
|
30
|
-
export const throttling = /*@__PURE__*/ policy(throttlingFactory);
|
|
31
|
-
|
|
32
|
-
export const transient = /*@__PURE__*/ policy(transientFactory);
|
|
33
|
-
//# sourceMappingURL=retry.js.map
|
|
1
|
+
export { retry$Retry as Retry, retry$capped as capped, retry$jittered as jittered, retry$makeDefault as makeDefault, retry$none as none, retry$policy as policy, retry$throttling as throttling, retry$throttlingFactory as throttlingFactory, retry$throttlingOptions as throttlingOptions, retry$transient as transient, retry$transientFactory as transientFactory, retry$transientOptions as transientOptions } from "./_bundle/sdk.js";
|
package/lib/services/index.js
CHANGED