@distilled.cloud/slack 1.0.0-rc.16 → 1.0.0-rc.17
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.js +1 -58
- package/lib/errors.js +1 -59
- package/lib/index.js +0 -10
- package/lib/index.lazy.js +7 -0
- package/lib/pagination.js +1 -31
- package/lib/protocol.js +1 -233
- package/lib/retry.js +1 -46
- package/lib/services/admin.js +142 -311
- package/lib/services/admin.js.map +1 -0
- package/lib/services/agents.js +2 -54
- package/lib/services/agents.js.map +1 -0
- package/lib/services/api.js +2 -22
- package/lib/services/api.js.map +1 -0
- package/lib/services/apps.js +36 -91
- package/lib/services/apps.js.map +1 -0
- package/lib/services/assistant.js +2 -39
- package/lib/services/assistant.js.map +1 -0
- package/lib/services/auth.js +2 -29
- package/lib/services/auth.js.map +1 -0
- package/lib/services/blocks.js +2 -22
- package/lib/services/blocks.js.map +1 -0
- package/lib/services/bookmarks.js +2 -33
- package/lib/services/bookmarks.js.map +1 -0
- package/lib/services/bots.js +2 -23
- package/lib/services/bots.js.map +1 -0
- package/lib/services/calls.js +2 -41
- package/lib/services/calls.js.map +1 -0
- package/lib/services/canvases.js +2 -45
- package/lib/services/canvases.js.map +1 -0
- package/lib/services/chat.js +2 -66
- package/lib/services/chat.js.map +1 -0
- package/lib/services/conversations.js +41 -101
- package/lib/services/conversations.js.map +1 -0
- package/lib/services/dialog.js +2 -19
- package/lib/services/dialog.js.map +1 -0
- package/lib/services/dnd.js +2 -32
- package/lib/services/dnd.js.map +1 -0
- package/lib/services/emoji.js +2 -24
- package/lib/services/emoji.js.map +1 -0
- package/lib/services/entity.js +2 -35
- package/lib/services/entity.js.map +1 -0
- package/lib/services/files.js +2 -82
- package/lib/services/files.js.map +1 -0
- package/lib/services/functions.js +2 -51
- package/lib/services/functions.js.map +1 -0
- package/lib/services/index.js +0 -2
- package/lib/services/lists.js +2 -60
- package/lib/services/lists.js.map +1 -0
- package/lib/services/migration.js +2 -24
- package/lib/services/migration.js.map +1 -0
- package/lib/services/oauth.js +2 -40
- package/lib/services/oauth.js.map +1 -0
- package/lib/services/openid.js +2 -25
- package/lib/services/openid.js.map +1 -0
- package/lib/services/pins.js +2 -33
- package/lib/services/pins.js.map +1 -0
- package/lib/services/reactions.js +2 -37
- package/lib/services/reactions.js.map +1 -0
- package/lib/services/reminders.js +2 -39
- package/lib/services/reminders.js.map +1 -0
- package/lib/services/rtm.js +2 -28
- package/lib/services/rtm.js.map +1 -0
- package/lib/services/search.js +2 -34
- package/lib/services/search.js.map +1 -0
- package/lib/services/stars.js +2 -35
- package/lib/services/stars.js.map +1 -0
- package/lib/services/team.js +2 -52
- package/lib/services/team.js.map +1 -0
- package/lib/services/tooling.js +2 -21
- package/lib/services/tooling.js.map +1 -0
- package/lib/services/usergroups.js +2 -46
- package/lib/services/usergroups.js.map +1 -0
- package/lib/services/users.js +2 -61
- package/lib/services/users.js.map +1 -0
- package/lib/services/views.js +2 -34
- package/lib/services/views.js.map +1 -0
- package/lib/services/workflows.js +2 -43
- package/lib/services/workflows.js.map +1 -0
- package/lib/services.lazy/admin.js +3 -0
- package/lib/services.lazy/agents.js +1 -0
- package/lib/services.lazy/api.js +1 -0
- package/lib/services.lazy/apps.js +3 -0
- package/lib/services.lazy/assistant.js +1 -0
- package/lib/services.lazy/auth.js +1 -0
- package/lib/services.lazy/blocks.js +1 -0
- package/lib/services.lazy/bookmarks.js +1 -0
- package/lib/services.lazy/bots.js +1 -0
- package/lib/services.lazy/calls.js +1 -0
- package/lib/services.lazy/canvases.js +1 -0
- package/lib/services.lazy/chat.js +1 -0
- package/lib/services.lazy/conversations.js +3 -0
- package/lib/services.lazy/dialog.js +1 -0
- package/lib/services.lazy/dnd.js +1 -0
- package/lib/services.lazy/emoji.js +1 -0
- package/lib/services.lazy/entity.js +1 -0
- package/lib/services.lazy/files.js +1 -0
- package/lib/services.lazy/functions.js +1 -0
- package/lib/services.lazy/index.js +3 -0
- package/lib/services.lazy/lists.js +1 -0
- package/lib/services.lazy/migration.js +1 -0
- package/lib/services.lazy/oauth.js +1 -0
- package/lib/services.lazy/openid.js +1 -0
- package/lib/services.lazy/pins.js +1 -0
- package/lib/services.lazy/reactions.js +1 -0
- package/lib/services.lazy/reminders.js +1 -0
- package/lib/services.lazy/rtm.js +1 -0
- package/lib/services.lazy/search.js +1 -0
- package/lib/services.lazy/stars.js +1 -0
- package/lib/services.lazy/team.js +1 -0
- package/lib/services.lazy/tooling.js +1 -0
- package/lib/services.lazy/usergroups.js +1 -0
- package/lib/services.lazy/users.js +1 -0
- package/lib/services.lazy/views.js +1 -0
- package/lib/services.lazy/workflows.js +1 -0
- package/lib/traits.js +1 -12
- package/package.json +6 -8
- 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{api$D as e,api$Protocol as t,api$call as n,api$named as r,api$op as i,api$opPaginated as a,category$withParseError as o,category$withThrottlingError as s,config$String as c,config$all as l,config$orElse as ee,config$withDefault as te,pagination$paginateCursor as ne,response_validation$validateResponse as u,retry$capped as re,retry$jittered as ie,retry$makeDefault as ae,retry$throttlingFactory as d,retry$throttlingOptions as f,retry$transientFactory as p,retry$transientOptions as m,trait$Body as oe,trait$FormDataFile as se,trait$Header as ce,trait$Http as le,trait$HttpBody as ue,trait$KeyDictionary as de,trait$Label as fe,trait$Query as pe,trait$ResponseCode as h,trait$UnionCases as g,trait$applyErrorMatchers as _,trait$bodySymbol as v,trait$errorMatchersSymbol as y,trait$formDataFileSymbol as b,trait$getErrorMatchers as x,trait$headerSymbol as S,trait$httpBodySymbol as C,trait$httpSymbol as w,trait$keyDictionarySymbol as T,trait$labelSymbol as E,trait$querySymbol as D,trait$responseCodeSymbol as O,trait$unionCasesSymbol as k}from"@distilled.cloud/core/_bundle/base";import{debug$debugHttp as A,error_category$withCategory as j,errors$API_ERRORS as M,errors$BadGateway as N,errors$BadRequest as P,errors$ConfigError as F,errors$Conflict as I,errors$DEFAULT_ERRORS as L,errors$DurationSchema as R,errors$Forbidden as z,errors$GatewayTimeout as B,errors$HTTP_STATUS_MAP as V,errors$InternalServerError as H,errors$NotFound as me,errors$RETRYABLE as he,errors$ServiceUnavailable as U,errors$TooManyRequests as ge,errors$Unauthorized as W,errors$UnprocessableEntity as _e,protocol_http$buildRequest as ve,protocol_http$getAnn as ye,protocol_http$getProps as be,protocol_http$hasPropAnn as G,protocol_http$mapKeys as xe,protocol_http$matchTypedError as Se,protocol_rest$RawResponse as Ce,protocol_rest$RawResponseRoot as we,protocol_rest$SensitiveValue as Te,protocol_rest$rawResponseRootSymbol as Ee,protocol_rest$rawResponseSymbol as De,protocol_rest$sensitiveValueSymbol as Oe,protocol_rest$unwrapRedactedDeep as ke,protocol_rest$wrapSensitive as Ae,retry_after$parseRetryAfterForStatus as K,retry_after$parseServerRetryHint as je,schema_lite$Array as Me,schema_lite$Boolean as Ne,schema_lite$NullOr as Pe,schema_lite$Number as Fe,schema_lite$Record as Ie,schema_lite$String as Le,schema_lite$Struct as Re,schema_lite$Unknown as ze,schema_lite$at as Be,schema_lite$optional as Ve,schema_lite$suspend as He}from"@distilled.cloud/core/_bundle/rest";import*as q from"effect/Context";import*as J from"effect/Effect";import*as Y from"effect/Layer";import*as X from"effect/Redacted";import*as Z from"@distilled.cloud/core/schema-lite-typed";const Q=`https://slack.com/api`;var Credentials=class extends (/*@__PURE__*/ q.Service()(`SlackCredentials`)){};const Ue=/*@__PURE__*/ l({token:/*@__PURE__*/ c(`SLACK_BOT_TOKEN`).pipe(/*@__PURE__*/ ee(()=>c(`SLACK_TOKEN`))),apiBaseUrl:/*@__PURE__*/ c(`SLACK_API_URL`).pipe(/*@__PURE__*/ te(Q))});const We=/*@__PURE__*/ Y.succeed(Credentials,/*@__PURE__*/ Ue.pipe(/*@__PURE__*/ J.mapError(()=>new F({message:`SLACK_BOT_TOKEN (or SLACK_TOKEN) environment variable is required`})),/*@__PURE__*/ J.map(({token:e,apiBaseUrl:t})=>({token:X.make(e),apiBaseUrl:t})),J.orDie));const credentials=e=>Y.succeed(Credentials,J.succeed({token:e.token,apiBaseUrl:e.apiBaseUrl??`https://slack.com/api`}));var SlackError=class extends (/*@__PURE__*/ Z.TaggedError()(`SlackError`,{code:Z.String,message:/*@__PURE__*/ Z.optional(Z.String),needed:/*@__PURE__*/ Z.optional(Z.String),provided:/*@__PURE__*/ Z.optional(Z.String),messages:/*@__PURE__*/ Z.optional(/*@__PURE__*/ Z.Array(Z.String))})){};var SlackRateLimited=class extends (/*@__PURE__*/ Z.TaggedError()(`SlackRateLimited`,{code:Z.String,message:/*@__PURE__*/ Z.optional(Z.String),retryAfter:/*@__PURE__*/ Z.optional(R)}).pipe(/*@__PURE__*/ j(he),s)){};var SlackHttpError=class extends (/*@__PURE__*/ Z.TaggedError()(`SlackHttpError`,{status:Z.Number,message:Z.String,body:/*@__PURE__*/ Z.optional(Z.String)})){};var SlackParseError=class extends (/*@__PURE__*/ Z.TaggedError()(`SlackParseError`,{body:Z.Unknown,cause:Z.Unknown}).pipe(o)){};const slackPaginate=(e,t,n)=>ne(e,t,n);const fail=e=>J.fail(e);const Ge=/*@__PURE__*/ new Set([`not_authed`,`invalid_auth`,`account_inactive`,`token_revoked`,`token_expired`]);const $={internal_error:e=>new H({message:e}),fatal_error:e=>new H({message:e}),service_unavailable:e=>new U({message:e}),request_timeout:e=>new B({message:e})};const serializeForWire=(e,t)=>{if(e===null||typeof e!==`object`||Array.isArray(e))return e;const n=ye(t,w)?.contentType===`form-urlencoded`;const r=be(t);if(r.length===0)return e;let i;for(const t of r){const r=String(t.name);const a=e[r];if(a===null||typeof a!==`object`)continue;const o=G(t,D);if(Array.isArray(a)&&(o||n)){i??={...e};i[r]=a.every(e=>typeof e!==`object`||e===null)?a.join(`,`):JSON.stringify(a)}else if(n&&!o){i??={...e};i[r]=JSON.stringify(a)}}return i??e};const encode=({input:e,inputAst:t})=>J.gen(function*(){const n=yield*yield*Credentials;const r=X.value(n.token);return ve({input:serializeForWire(ke(e),t),inputAst:t,baseUrl:n.apiBaseUrl,headers:r===``?{}:{authorization:`Bearer ${r}`}})});const decode=({response:e,outputAst:t,errors:n})=>J.gen(function*(){const r=new Uint8Array(yield*e.arrayBuffer.pipe(J.orDie));const i=new TextDecoder().decode(r);if(A())console.error(`[distilled] <- ${e.status} ${i.slice(0,400)}`);let a;if(i.trim().length>0)try{const e=JSON.parse(i);if(e!==null&&typeof e===`object`)a=e}catch{}const o=e.status;const s=e.headers;if(o>=400||a?.ok===false){const e=typeof a?.error===`string`?a.error:void 0;const t=[...(a?.response_metadata)?.messages??[],...Array.isArray(a?.errors)?a.errors:[]].filter(e=>typeof e===`string`);const r=t[0]??e??(a===void 0&&i.trim()?i.trim():`HTTP ${o}`);const c=Se(n,o,[{message:r}],{body:a===void 0?i:a,headers:s});if(c!==void 0)return yield*fail(c);if(o===429||e===`rate_limited`||e===`ratelimited`)return yield*fail(new SlackRateLimited({code:e??`rate_limited`,message:r,retryAfter:je(s)}));if(e!==void 0&&Ge.has(e))return yield*fail(new W({message:e}));if(e!==void 0&&e in $)return yield*fail($[e](r));if(e!==void 0)return yield*fail(new SlackError({code:e,...r!==e?{message:r}:{},...typeof a?.needed===`string`?{needed:a.needed}:{},...typeof a?.provided===`string`?{provided:a.provided}:{},...t.length>0?{messages:t}:{}}));const l=V[o];if(l)return yield*fail(new l({message:r,retryAfter:K(o,s)}));if(o>=500)return yield*fail(new H({message:r,retryAfter:K(o,s)}));return yield*fail(new SlackHttpError({status:o,message:r,body:i.slice(0,2e3)}))}if(a===void 0)return yield*u(t,r,e=>new SlackParseError({body:i,cause:e})).pipe(J.catch(fail));const c=yield*u(t,xe(t,a,`decode`),e=>new SlackParseError({body:a,cause:e})).pipe(J.catch(fail));return Ae(t,c)});const Ke=/*@__PURE__*/ Y.succeed(t,/*@__PURE__*/ t.of({encode:e=>encode(e),decode}));var Retry=class extends (/*@__PURE__*/ q.Service()(`SlackRetry`)){};const policy=e=>J.provide(Y.succeed(Retry,e));const qe=/*@__PURE__*/ J.provide(/*@__PURE__*/ Y.succeed(Retry,{while:()=>false}));const Je=ae;const Ye=ie;const Xe=re;const Ze=f;const Qe=/*@__PURE__*/ policy(d);const $e=m;const et=/*@__PURE__*/ policy(p);export{Ie as a,ze as c,Credentials as credentials$Credentials,We as credentials$CredentialsFromEnv,Q as credentials$DEFAULT_API_BASE_URL,credentials as credentials$credentials,He as d,M as errors$API_ERRORS,N as errors$BadGateway,P as errors$BadRequest,F as errors$ConfigError,I as errors$Conflict,L as errors$DEFAULT_ERRORS,z as errors$Forbidden,B as errors$GatewayTimeout,V as errors$HTTP_STATUS_MAP,H as errors$InternalServerError,me as errors$NotFound,U as errors$ServiceUnavailable,SlackError as errors$SlackError,SlackHttpError as errors$SlackHttpError,SlackParseError as errors$SlackParseError,SlackRateLimited as errors$SlackRateLimited,ge as errors$TooManyRequests,W as errors$Unauthorized,_e as errors$UnprocessableEntity,e as f,a as g,i as h,Fe as i,Be as l,r as m,Ne as n,Le as o,n as p,slackPaginate as pagination$slackPaginate,Ke as protocol$SlackProtocol,Pe as r,Retry as retry$Retry,Xe as retry$capped,Ye as retry$jittered,Je as retry$makeDefault,qe as retry$none,policy as retry$policy,Qe as retry$throttling,Ze as retry$throttlingOptions,et as retry$transient,$e as retry$transientOptions,Re as s,Me as t,oe as traits$Body,se as traits$FormDataFile,ce as traits$Header,le as traits$Http,ue as traits$HttpBody,de as traits$KeyDictionary,fe as traits$Label,pe as traits$Query,Ce as traits$RawResponse,we as traits$RawResponseRoot,h as traits$ResponseCode,Te as traits$SensitiveValue,g as traits$UnionCases,_ as traits$applyErrorMatchers,v as traits$bodySymbol,y as traits$errorMatchersSymbol,b as traits$formDataFileSymbol,x as traits$getErrorMatchers,S as traits$headerSymbol,C as traits$httpBodySymbol,w as traits$httpSymbol,T as traits$keyDictionarySymbol,E as traits$labelSymbol,D as traits$querySymbol,Ee as traits$rawResponseRootSymbol,De as traits$rawResponseSymbol,O as traits$responseCodeSymbol,Oe as traits$sensitiveValueSymbol,k as traits$unionCasesSymbol,Ve as u};
|
|
2
|
+
//# sourceMappingURL=sdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdk.js","names":["EffectConfig.String","Category.withThrottlingError","Category.withParseError","Pagination.paginateCursor","API.Protocol","Retries.makeDefault","Retries.jittered","Retries.capped","Retries.throttlingOptions","Retries.throttlingFactory","Retries.transientOptions","Retries.transientFactory","D","Protocol","call","named","op","opPaginated","withParseError","withThrottlingError","String$2","all$1","orElse","withDefault","paginateCursor","validateResponse","capped$1","jittered$1","makeDefault$1","throttlingFactory","throttlingOptions$1","transientFactory","transientOptions$1","Body","FormDataFile","Header","Http","HttpBody","KeyDictionary","Label","Query","ResponseCode","UnionCases","applyErrorMatchers","bodySymbol","errorMatchersSymbol","formDataFileSymbol","getErrorMatchers","headerSymbol","httpBodySymbol","httpSymbol","keyDictionarySymbol","labelSymbol","querySymbol","responseCodeSymbol","unionCasesSymbol","debugHttp","withCategory","API_ERRORS","BadGateway","BadRequest","ConfigError","Conflict","DEFAULT_ERRORS","DurationSchema","Forbidden","GatewayTimeout","HTTP_STATUS_MAP","InternalServerError","NotFound","RETRYABLE","ServiceUnavailable","TooManyRequests","Unauthorized","UnprocessableEntity","buildRequest","getAnn","getProps","hasPropAnn","mapKeys","matchTypedError","RawResponse","RawResponseRoot","SensitiveValue","rawResponseRootSymbol","rawResponseSymbol","sensitiveValueSymbol","unwrapRedactedDeep","wrapSensitive","parseRetryAfterForStatus","parseServerRetryHint","Array$1","Boolean","NullOr","Number","Record","String$1","Struct","Unknown","at","optional","suspend","Context","Effect","Layer","Redacted","Schema","DEFAULT_API_BASE_URL","envConfig","CredentialsFromEnv","token","config","operation","input","pagination","AUTH_SLUGS","SERVER_SLUGS","isForm","inputAst","props","out","prop","key","value","isQuery","v","creds","errorClasses","bytes","response","text","json","parsed","status","headers","slug","detailMessages","m","message","typed","StatusErrorClass","outputAst","mapped","SlackProtocol","args","optionsOrFactory","none","makeDefault","jittered","capped","throttlingOptions","throttling","transientOptions","transient"],"sources":["../../src/credentials.ts","../../src/errors.ts","../../src/pagination.ts","../../src/protocol.ts","../../src/retry.ts"],"mappings":"+lFA8BA,MAAa2G,EAAuB,wBAOpC,IAAa,YAAb,eACwB,gBAAQ,QAA4C,CAAC,CAAC,kBAAkB,EAAA,AAAE,CAAC,EAEnG,MAAMC,GAA0B,gBAAiB,CAG/C,MAAqB,gBAAoB,iBAAiB,CAAC,CAAC,KAC5C,qBAA0B5G,EAAoB,aAAa,CAAC,CAC5E,EACA,WAA0B,gBAAoB,eAAe,CAAC,CAAC,KAC/C,iBAAyB2G,CAAoB,CAC7D,CACF,CAAC,EAED,MAAaE,GAAmC,gBAAM,QACpD,YACc,iBAAU,KACR,gBAAO,aAEjB,IAAIhD,EAAY,CACd,QAAS,mEACX,CAAC,CACL,EACc,gBAAO,KAAK,CAAE,QAAO,iBAAkB,CACnD,MAAO4C,EAAS,KAAKK,CAAK,EAC1B,YACF,EAAE,EACFP,EAAO,KACT,CACF,EAMA,MAAa,YAAe,GAI1BC,EAAM,QACJ,YACAD,EAAO,QAAQ,CACb,MAAOQ,EAAO,MACd,WAAYA,EAAO,YAAA,uBACrB,CAAC,CACH,ECxCF,IAAa,WAAb,eACwB,gBAAO,YAAwB,CAAC,CAAC,aAAc,CACnE,KAAML,EAAO,OACb,QAAuB,gBAAO,SAASA,EAAO,MAA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,MAAaC,GAAyD,gBAAM,QAC1E3I,EACc,gBAAa,GAAG,CAE5B,OAAS,GAAS,OAAO4I,CAAI,EAC7B,MACF,CAAC,CACH,EC3RA,IAAa,MAAb,eAAyC,gBAAQ,QAAuB,CAAC,CAAC,YAAY,EAAA,AAAE,CAAC,EAGzF,MAAa,OAOR,GAAwCzC,EAAO,QAAQC,EAAM,QAAQ,MAAOyC,CAAgB,CAAC,EAGlG,MAAaC,GAE+C,gBAAO,QACnD,gBAAM,QAAQ,MAAO,CAAE,UAAa,KAAM,CAAC,CAC3D,EAOA,MAAaC,GAAuB9I,GAEpC,MAAa+I,GAAW9I,GACxB,MAAa+I,GAAS9I,GAGtB,MAAa+I,GAA6B9I,EAG1C,MAAa+I,GAE+C,qBAAO9I,CAAyB,EAG5F,MAAa+I,GAA4B9I,EAGzC,MAAa+I,GAE+C,qBAAO9I,CAAwB"}
|
package/lib/credentials.js
CHANGED
|
@@ -1,58 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import * as EffectConfig from "@distilled.cloud/core/config";
|
|
21
|
-
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
22
|
-
import * as Context from "effect/Context";
|
|
23
|
-
import * as Effect from "effect/Effect";
|
|
24
|
-
import * as Layer from "effect/Layer";
|
|
25
|
-
import * as Redacted from "effect/Redacted";
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export const DEFAULT_API_BASE_URL = "https://slack.com/api";
|
|
31
|
-
export class Credentials extends /*@__PURE__*/ /*@__PURE__*/ Context.Service()("SlackCredentials") {
|
|
32
|
-
}
|
|
33
|
-
const envConfig = /*@__PURE__*/ EffectConfig.all({
|
|
34
|
-
// SLACK_BOT_TOKEN is the spelling Bolt and most hosting platforms use;
|
|
35
|
-
// SLACK_TOKEN is the fallback (the node SDK's CLI convention).
|
|
36
|
-
token: /*@__PURE__*/ EffectConfig.String("SLACK_BOT_TOKEN").pipe(
|
|
37
|
-
/*@__PURE__*/ EffectConfig.orElse(() => EffectConfig.String("SLACK_TOKEN"))),
|
|
38
|
-
apiBaseUrl: /*@__PURE__*/ EffectConfig.String("SLACK_API_URL").pipe(
|
|
39
|
-
/*@__PURE__*/ EffectConfig.withDefault(DEFAULT_API_BASE_URL)),
|
|
40
|
-
});
|
|
41
|
-
export const CredentialsFromEnv = /*@__PURE__*/ Layer.succeed(Credentials,
|
|
42
|
-
/*@__PURE__*/ envConfig.pipe(
|
|
43
|
-
/*@__PURE__*/ Effect.mapError(() => new ConfigError({
|
|
44
|
-
message: "SLACK_BOT_TOKEN (or SLACK_TOKEN) environment variable is required",
|
|
45
|
-
})),
|
|
46
|
-
/*@__PURE__*/ Effect.map(({ token, apiBaseUrl }) => ({
|
|
47
|
-
token: Redacted.make(token),
|
|
48
|
-
apiBaseUrl,
|
|
49
|
-
})), Effect.orDie));
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
export const credentials = (config) => Layer.succeed(Credentials, Effect.succeed({
|
|
55
|
-
token: config.token,
|
|
56
|
-
apiBaseUrl: config.apiBaseUrl ?? DEFAULT_API_BASE_URL,
|
|
57
|
-
}));
|
|
58
|
-
//# 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$credentials as credentials } from "./_bundle/sdk.js";
|
package/lib/errors.js
CHANGED
|
@@ -1,59 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
13
|
-
import * as Category from "@distilled.cloud/core/category";
|
|
14
|
-
import { withCategory } from "@distilled.cloud/core/error-category";
|
|
15
|
-
import { DurationSchema, RETRYABLE } from "@distilled.cloud/core/errors";
|
|
16
|
-
import * as Schema from "@distilled.cloud/core/schema-lite-typed";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
export class SlackError extends /*@__PURE__*/ /*@__PURE__*/ Schema.TaggedError()("SlackError", {
|
|
26
|
-
code: Schema.String,
|
|
27
|
-
message: /*@__PURE__*/ Schema.optional(Schema.String),
|
|
28
|
-
needed: /*@__PURE__*/ Schema.optional(Schema.String),
|
|
29
|
-
provided: /*@__PURE__*/ Schema.optional(Schema.String),
|
|
30
|
-
messages: /*@__PURE__*/ Schema.optional(/*@__PURE__*/ Schema.Array(Schema.String)),
|
|
31
|
-
}) {
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
export class SlackRateLimited extends /*@__PURE__*/ /*@__PURE__*/ Schema.TaggedError()("SlackRateLimited", {
|
|
38
|
-
code: Schema.String,
|
|
39
|
-
message: /*@__PURE__*/ Schema.optional(Schema.String),
|
|
40
|
-
retryAfter: /*@__PURE__*/ Schema.optional(DurationSchema),
|
|
41
|
-
}).pipe(/*@__PURE__*/ withCategory(RETRYABLE), Category.withThrottlingError) {
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
export class SlackHttpError extends /*@__PURE__*/ /*@__PURE__*/ Schema.TaggedError()("SlackHttpError", {
|
|
48
|
-
status: Schema.Number,
|
|
49
|
-
message: Schema.String,
|
|
50
|
-
body: /*@__PURE__*/ Schema.optional(Schema.String),
|
|
51
|
-
}) {
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export class SlackParseError extends /*@__PURE__*/ /*@__PURE__*/ Schema.TaggedError()("SlackParseError", {
|
|
55
|
-
body: Schema.Unknown,
|
|
56
|
-
cause: Schema.Unknown,
|
|
57
|
-
}).pipe(Category.withParseError) {
|
|
58
|
-
}
|
|
59
|
-
//# 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$NotFound as NotFound, errors$ServiceUnavailable as ServiceUnavailable, errors$SlackError as SlackError, errors$SlackHttpError as SlackHttpError, errors$SlackParseError as SlackParseError, errors$SlackRateLimited as SlackRateLimited, errors$TooManyRequests as TooManyRequests, errors$Unauthorized as Unauthorized, errors$UnprocessableEntity as UnprocessableEntity } from "./_bundle/sdk.js";
|
package/lib/index.js
CHANGED
|
@@ -1,12 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
1
|
export * from "./credentials.js";
|
|
11
2
|
export * from "./errors.js";
|
|
12
3
|
export * as T from "./traits.js";
|
|
@@ -14,4 +5,3 @@ export { SlackProtocol } from "./protocol.js";
|
|
|
14
5
|
export * as Retry from "./retry.js";
|
|
15
6
|
export * as Pagination from "./pagination.js";
|
|
16
7
|
export * from "./services/index.js";
|
|
17
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from "./credentials.js";
|
|
2
|
+
export * from "./errors.js";
|
|
3
|
+
export * as T from "./traits.js";
|
|
4
|
+
export { SlackProtocol } from "./protocol.js";
|
|
5
|
+
export * as Retry from "./retry.js";
|
|
6
|
+
export * as Pagination from "./pagination.js";
|
|
7
|
+
export * from "./services.lazy/index.js";
|
package/lib/pagination.js
CHANGED
|
@@ -1,31 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
import * as Pagination from "@distilled.cloud/core/pagination";
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
export const slackPaginate = (operation, input, pagination) => Pagination.paginateCursor(operation, input, pagination);
|
|
31
|
-
//# sourceMappingURL=pagination.js.map
|
|
1
|
+
export { pagination$slackPaginate as slackPaginate } from "./_bundle/sdk.js";
|
package/lib/protocol.js
CHANGED
|
@@ -1,233 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { debugHttp } from "@distilled.cloud/core/debug";
|
|
3
|
-
import { ConfigError, GatewayTimeout, HTTP_STATUS_MAP, InternalServerError, ServiceUnavailable, Unauthorized, } from "@distilled.cloud/core/errors";
|
|
4
|
-
import { buildRequest, getAnn, getProps, hasPropAnn, mapKeys, matchTypedError, } from "@distilled.cloud/core/protocol-http";
|
|
5
|
-
import { unwrapRedactedDeep, wrapSensitive } from "@distilled.cloud/core/protocol-rest";
|
|
6
|
-
import { validateResponse } from "@distilled.cloud/core/response-validation";
|
|
7
|
-
import { parseRetryAfterForStatus, parseServerRetryHint } from "@distilled.cloud/core/retry-after";
|
|
8
|
-
import { httpSymbol, querySymbol } from "@distilled.cloud/core/trait";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
import * as Effect from "effect/Effect";
|
|
36
|
-
import * as Layer from "effect/Layer";
|
|
37
|
-
import * as Redacted from "effect/Redacted";
|
|
38
|
-
import { Credentials } from "./credentials.js";
|
|
39
|
-
import { SlackError, SlackHttpError, SlackParseError, SlackRateLimited, } from "./errors.js";
|
|
40
|
-
// Bridge: Protocol.decode is typed as Effect<unknown> (no error channel), but
|
|
41
|
-
// Slack failures are real typed errors that an operation re-surfaces via its
|
|
42
|
-
// `errors: [...]` list. Fail with the instance and erase the error type here;
|
|
43
|
-
// `API.make`'s signature reintroduces it for callers.
|
|
44
|
-
const fail = (e) => Effect.fail(e);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const AUTH_SLUGS = /*@__PURE__*/ new Set([
|
|
53
|
-
"not_authed",
|
|
54
|
-
"invalid_auth",
|
|
55
|
-
"account_inactive",
|
|
56
|
-
"token_revoked",
|
|
57
|
-
"token_expired",
|
|
58
|
-
]);
|
|
59
|
-
|
|
60
|
-
const SERVER_SLUGS = {
|
|
61
|
-
internal_error: (message) => new InternalServerError({ message }),
|
|
62
|
-
fatal_error: (message) => new InternalServerError({ message }),
|
|
63
|
-
service_unavailable: (message) => new ServiceUnavailable({ message }),
|
|
64
|
-
request_timeout: (message) => new GatewayTimeout({ message }),
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
const serializeForWire = (input, inputAst) => {
|
|
79
|
-
if (input === null || typeof input !== "object" || Array.isArray(input)) {
|
|
80
|
-
return input;
|
|
81
|
-
}
|
|
82
|
-
const isForm = getAnn(inputAst, httpSymbol)?.contentType === "form-urlencoded";
|
|
83
|
-
const props = getProps(inputAst);
|
|
84
|
-
if (props.length === 0)
|
|
85
|
-
return input;
|
|
86
|
-
let out;
|
|
87
|
-
for (const prop of props) {
|
|
88
|
-
const key = String(prop.name);
|
|
89
|
-
const value = input[key];
|
|
90
|
-
if (value === null || typeof value !== "object")
|
|
91
|
-
continue;
|
|
92
|
-
const isQuery = hasPropAnn(prop, querySymbol);
|
|
93
|
-
if (Array.isArray(value) && (isQuery || isForm)) {
|
|
94
|
-
out ??= { ...input };
|
|
95
|
-
out[key] = value.every((v) => typeof v !== "object" || v === null)
|
|
96
|
-
? value.join(",")
|
|
97
|
-
: JSON.stringify(value);
|
|
98
|
-
}
|
|
99
|
-
else if (isForm && !isQuery) {
|
|
100
|
-
out ??= { ...input };
|
|
101
|
-
out[key] = JSON.stringify(value);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return out ?? input;
|
|
105
|
-
};
|
|
106
|
-
// The protocol layer is memoized per process by `API.make` (see
|
|
107
|
-
// `OperationConfig.protocol`), so the build must not capture credentials --
|
|
108
|
-
// `encode` resolves Credentials from the calling fiber's context on every
|
|
109
|
-
// request instead. Like the error channel above, the requirement is erased at
|
|
110
|
-
// this boundary (Protocol effects are typed with no requirements) and
|
|
111
|
-
// reintroduced for callers by the generated `SlackOpContext` annotations.
|
|
112
|
-
const encode = ({ input, inputAst }) => Effect.gen(function* () {
|
|
113
|
-
const resolveCredentials = yield* Credentials;
|
|
114
|
-
const creds = yield* resolveCredentials;
|
|
115
|
-
const token = Redacted.value(creds.token);
|
|
116
|
-
return buildRequest({
|
|
117
|
-
input: serializeForWire(unwrapRedactedDeep(input), inputAst),
|
|
118
|
-
inputAst,
|
|
119
|
-
baseUrl: creds.apiBaseUrl,
|
|
120
|
-
// An empty token means a credential-less call (the OAuth exchange
|
|
121
|
-
// methods) -- no Authorization header at all.
|
|
122
|
-
headers: token === "" ? {} : { authorization: `Bearer ${token}` },
|
|
123
|
-
});
|
|
124
|
-
});
|
|
125
|
-
const decode = ({ response, outputAst, errors: errorClasses, }) => Effect.gen(function* () {
|
|
126
|
-
// Read as BYTES first: the analytics export answers a successful call
|
|
127
|
-
// with a gzipped file, which a text read would corrupt. Everything else
|
|
128
|
-
// decodes from the same buffer.
|
|
129
|
-
const bytes = new Uint8Array(yield* response.arrayBuffer.pipe(Effect.orDie));
|
|
130
|
-
const text = new TextDecoder().decode(bytes);
|
|
131
|
-
if (debugHttp()) {
|
|
132
|
-
console.error(`[distilled] <- ${response.status} ${text.slice(0, 400)}`);
|
|
133
|
-
}
|
|
134
|
-
let json;
|
|
135
|
-
if (text.trim().length > 0) {
|
|
136
|
-
try {
|
|
137
|
-
const parsed = JSON.parse(text);
|
|
138
|
-
if (parsed !== null && typeof parsed === "object") {
|
|
139
|
-
json = parsed;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
catch {
|
|
143
|
-
// non-JSON -- a binary success payload or an HTML error page
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
const status = response.status;
|
|
147
|
-
const headers = response.headers;
|
|
148
|
-
// Slack reports failures as `ok: false`, usually WITH HTTP 200 -- a
|
|
149
|
-
// non-2xx status without an envelope (proxy pages) is also a failure.
|
|
150
|
-
const failed = status >= 400 || json?.ok === false;
|
|
151
|
-
if (failed) {
|
|
152
|
-
const slug = typeof json?.error === "string" ? json.error : undefined;
|
|
153
|
-
// `response_metadata.messages` carries per-field validation detail
|
|
154
|
-
// (e.g. `invalid_arguments`); some envelopes use a bare `errors` list.
|
|
155
|
-
const detailMessages = [
|
|
156
|
-
...(json?.response_metadata?.messages ?? []),
|
|
157
|
-
...(Array.isArray(json?.errors) ? json.errors : []),
|
|
158
|
-
].filter((m) => typeof m === "string");
|
|
159
|
-
const message = detailMessages[0] ??
|
|
160
|
-
slug ??
|
|
161
|
-
(json === undefined && text.trim() ? text.trim() : `HTTP ${status}`);
|
|
162
|
-
// 1. Per-operation typed error (matcher metadata on the class -- none
|
|
163
|
-
// are generated today, but model patches can add them). Slack's
|
|
164
|
-
// error codes are string slugs, and matcher `code`s are numeric --
|
|
165
|
-
// a patch-declared class matches on `status`/`message` instead
|
|
166
|
-
// (`message` is the slug when the envelope carries no detail).
|
|
167
|
-
const typed = matchTypedError(errorClasses, status, [{ message }], {
|
|
168
|
-
body: json === undefined ? text : json,
|
|
169
|
-
headers,
|
|
170
|
-
});
|
|
171
|
-
if (typed !== undefined)
|
|
172
|
-
return yield* fail(typed);
|
|
173
|
-
// 2. Throttling -- the 429 or its envelope spellings.
|
|
174
|
-
if (status === 429 || slug === "rate_limited" || slug === "ratelimited") {
|
|
175
|
-
return yield* fail(new SlackRateLimited({
|
|
176
|
-
code: slug ?? "rate_limited",
|
|
177
|
-
message,
|
|
178
|
-
retryAfter: parseServerRetryHint(headers),
|
|
179
|
-
}));
|
|
180
|
-
}
|
|
181
|
-
// 3. Infrastructure slugs: credential problems and Slack-side hiccups.
|
|
182
|
-
if (slug !== undefined && AUTH_SLUGS.has(slug)) {
|
|
183
|
-
return yield* fail(new Unauthorized({ message: slug }));
|
|
184
|
-
}
|
|
185
|
-
if (slug !== undefined && slug in SERVER_SLUGS) {
|
|
186
|
-
return yield* fail(SERVER_SLUGS[slug](message));
|
|
187
|
-
}
|
|
188
|
-
// 4. Any other envelope slug -> SlackError, the slug preserved.
|
|
189
|
-
if (slug !== undefined) {
|
|
190
|
-
return yield* fail(new SlackError({
|
|
191
|
-
code: slug,
|
|
192
|
-
...(message !== slug ? { message } : {}),
|
|
193
|
-
...(typeof json?.needed === "string" ? { needed: json.needed } : {}),
|
|
194
|
-
...(typeof json?.provided === "string" ? { provided: json.provided } : {}),
|
|
195
|
-
...(detailMessages.length > 0 ? { messages: detailMessages } : {}),
|
|
196
|
-
}));
|
|
197
|
-
}
|
|
198
|
-
// 5. No envelope at all: HTTP-status classes / retryable 5xx / raw.
|
|
199
|
-
const StatusErrorClass = HTTP_STATUS_MAP[status];
|
|
200
|
-
if (StatusErrorClass) {
|
|
201
|
-
return yield* fail(new StatusErrorClass({
|
|
202
|
-
message,
|
|
203
|
-
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
204
|
-
}));
|
|
205
|
-
}
|
|
206
|
-
if (status >= 500) {
|
|
207
|
-
return yield* fail(new InternalServerError({
|
|
208
|
-
message,
|
|
209
|
-
retryAfter: parseRetryAfterForStatus(status, headers),
|
|
210
|
-
}));
|
|
211
|
-
}
|
|
212
|
-
return yield* fail(new SlackHttpError({ status, message, body: text.slice(0, 2000) }));
|
|
213
|
-
}
|
|
214
|
-
// Successful non-JSON body: raw bytes (the analytics file download --
|
|
215
|
-
// modeled as a Document output, so the bytes pass through verbatim).
|
|
216
|
-
// Strict mode fails them for every other (struct) output.
|
|
217
|
-
if (json === undefined) {
|
|
218
|
-
return yield* validateResponse(outputAst, bytes, (cause) => new SlackParseError({ body: text, cause })).pipe(Effect.catch(fail));
|
|
219
|
-
}
|
|
220
|
-
// 2xx envelope: the body IS the payload (`ok` rides along as a modeled
|
|
221
|
-
// member). Wire->TS key mapping is schema-driven; sensitive members
|
|
222
|
-
// (OAuth access/refresh tokens) wrap in Redacted. Strict mode checks the
|
|
223
|
-
// mapped payload against the output schema first.
|
|
224
|
-
const mapped = yield* validateResponse(outputAst, mapKeys(outputAst, json, "decode"), (cause) => new SlackParseError({ body: json, cause })).pipe(Effect.catch(fail));
|
|
225
|
-
return wrapSensitive(outputAst, mapped);
|
|
226
|
-
});
|
|
227
|
-
export const SlackProtocol = /*@__PURE__*/ Layer.succeed(API.Protocol,
|
|
228
|
-
/*@__PURE__*/ API.Protocol.of({
|
|
229
|
-
// Erase encode's Credentials requirement (see comment above).
|
|
230
|
-
encode: (args) => encode(args),
|
|
231
|
-
decode,
|
|
232
|
-
}));
|
|
233
|
-
//# sourceMappingURL=protocol.js.map
|
|
1
|
+
export { protocol$SlackProtocol as SlackProtocol } from "./_bundle/sdk.js";
|
package/lib/retry.js
CHANGED
|
@@ -1,46 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
import * as Context from "effect/Context";
|
|
20
|
-
import * as Effect from "effect/Effect";
|
|
21
|
-
import * as Layer from "effect/Layer";
|
|
22
|
-
|
|
23
|
-
export class Retry extends /*@__PURE__*/ /*@__PURE__*/ Context.Service()("SlackRetry") {
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const policy = (optionsOrFactory) => Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
27
|
-
|
|
28
|
-
export const none = /*@__PURE__*/ Effect.provide(
|
|
29
|
-
/*@__PURE__*/ Layer.succeed(Retry, { while: () => false }));
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
export const makeDefault = Retries.makeDefault;
|
|
36
|
-
export const jittered = Retries.jittered;
|
|
37
|
-
export const capped = Retries.capped;
|
|
38
|
-
|
|
39
|
-
export const throttlingOptions = Retries.throttlingOptions;
|
|
40
|
-
|
|
41
|
-
export const throttling = /*@__PURE__*/ policy(Retries.throttlingFactory);
|
|
42
|
-
|
|
43
|
-
export const transientOptions = Retries.transientOptions;
|
|
44
|
-
|
|
45
|
-
export const transient = /*@__PURE__*/ policy(Retries.transientFactory);
|
|
46
|
-
//# 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$throttlingOptions as throttlingOptions, retry$transient as transient, retry$transientOptions as transientOptions } from "./_bundle/sdk.js";
|