@distilled.cloud/telegram 0.0.0 → 1.0.0-rc.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +78 -4
  3. package/lib/.lazy.json +1 -0
  4. package/lib/_bundle/lazy.js +4 -0
  5. package/lib/_bundle/sdk.js +2 -0
  6. package/lib/_bundle/sdk.js.map +1 -0
  7. package/lib/credentials.d.ts +36 -0
  8. package/lib/credentials.d.ts.map +1 -0
  9. package/lib/credentials.js +1 -0
  10. package/lib/errors.d.ts +41 -0
  11. package/lib/errors.d.ts.map +1 -0
  12. package/lib/errors.js +1 -0
  13. package/lib/index.d.ts +37 -0
  14. package/lib/index.d.ts.map +1 -0
  15. package/lib/index.js +6 -0
  16. package/lib/index.lazy.js +6 -0
  17. package/lib/index.lazy.js.map +1 -0
  18. package/lib/protocol.d.ts +28 -0
  19. package/lib/protocol.d.ts.map +1 -0
  20. package/lib/protocol.js +1 -0
  21. package/lib/retry.d.ts +50 -0
  22. package/lib/retry.d.ts.map +1 -0
  23. package/lib/retry.js +1 -0
  24. package/lib/services/index.d.ts +2 -0
  25. package/lib/services/index.d.ts.map +1 -0
  26. package/lib/services/index.js +1 -0
  27. package/lib/services/telegram.d.ts +9340 -0
  28. package/lib/services/telegram.d.ts.map +1 -0
  29. package/lib/services/telegram.js +251 -0
  30. package/lib/services/telegram.js.map +1 -0
  31. package/lib/services.lazy/index.js +3 -0
  32. package/lib/services.lazy/telegram.js +3 -0
  33. package/lib/traits.d.ts +10 -0
  34. package/lib/traits.d.ts.map +1 -0
  35. package/lib/traits.js +1 -0
  36. package/package.json +77 -2
  37. package/src/credentials.ts +109 -0
  38. package/src/errors.ts +54 -0
  39. package/src/index.ts +36 -0
  40. package/src/protocol.ts +146 -0
  41. package/src/retry.ts +69 -0
  42. package/src/services/index.ts +2 -0
  43. package/src/services/telegram.ts +17648 -0
  44. package/src/traits.ts +44 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,9 +1,83 @@
1
1
  # @distilled.cloud/telegram
2
2
 
3
- 🐣 This package name has been claimed with [fledgling](https://github.com/dmno-dev/fledgling) for [https://github.com/alchemy-run/distilled](https://github.com/alchemy-run/distilled), and a real release will land here soon.
3
+ Effect-native [Telegram Bot API](https://core.telegram.org/bots/api) SDK, generated from the
4
+ [Bot API reference](https://core.telegram.org/bots/api).
4
5
 
5
- This is a placeholder — there is nothing to install yet.
6
+ Telegram publishes no OpenAPI document. The spec mirror
7
+ (`distilled-mirror/spec-mirror-telegram`) saves the Markdown version of every
8
+ reference page (one per method, one per type), and
9
+ `scripts/docs-to-openapi.ts` reads their parameter and field tables into an
10
+ OpenAPI document. Where the reference is wrong or incomplete, a patch in
11
+ `patches/` holds the fix and its evidence.
6
12
 
7
- ---
13
+ Every method of the reference is an operation, with Telegram's own name
14
+ (`getMe`, `sendMessage`, `createForumTopic`, ...).
8
15
 
9
- Want to claim a name of your own? Run `npx fledgling add <name> --new --yes` — it reserves the name on npm and can set up token-less (OIDC trusted) publishing for when you are ready.
16
+ ## Installation
17
+
18
+ ```bash
19
+ npm install @distilled.cloud/telegram effect
20
+ ```
21
+
22
+ ## Quick start
23
+
24
+ Manage a forum supergroup: open a topic, make an invite link for it, and post
25
+ in it.
26
+
27
+ ```ts
28
+ import { Effect, Layer } from "effect";
29
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
30
+ import * as Telegram from "@distilled.cloud/telegram";
31
+
32
+ const chat_id = "@my_forum";
33
+
34
+ const program = Effect.gen(function* () {
35
+ const me = yield* Telegram.getMe({});
36
+ const topic = yield* Telegram.createForumTopic({ chat_id, name: "Releases" });
37
+ const invite = yield* Telegram.createChatInviteLink({ chat_id, name: "releases", member_limit: 50 });
38
+ yield* Telegram.sendMessage({
39
+ chat_id,
40
+ message_thread_id: topic.message_thread_id,
41
+ text: `Join with ${invite.invite_link}`,
42
+ });
43
+ return { bot: me.username, topic: topic.message_thread_id };
44
+ });
45
+
46
+ const Live = Layer.mergeAll(FetchHttpClient.layer, Telegram.CredentialsFromEnv);
47
+
48
+ program.pipe(Effect.provide(Live), Effect.runPromise).then(console.log);
49
+ ```
50
+
51
+ ## Auth
52
+
53
+ | Variable | Meaning |
54
+ | --- | --- |
55
+ | `TELEGRAM_BOT_TOKEN` | The bot token @BotFather issues (`123456789:AAH...`). |
56
+ | `TELEGRAM_API_BASE_URL` | Optional. Default `https://api.telegram.org`; set it to use a [local Bot API server](https://github.com/tdlib/telegram-bot-api). |
57
+
58
+ The Bot API takes the token in the path of every request
59
+ (`https://api.telegram.org/bot<token>/<method>`). The layer refuses a token
60
+ that is not a bot token when it is built, so a token can't change the path.
61
+ When a request fails in transport, the SDK replaces the token in the
62
+ `HttpClientError`'s URL with `<token>`, so the error does not leak it into logs.
63
+
64
+ `Telegram.credentials({ token: Redacted.make("...") })` builds the same layer
65
+ from a value.
66
+
67
+ ## Responses and errors
68
+
69
+ An operation returns the `result` of Telegram's `{ ok, result }` response. A
70
+ failure (`{ ok: false, error_code, description }`) fails with core's class for
71
+ its status: `BadRequest` ("Bad Request: chat not found"), `Unauthorized`,
72
+ `Forbidden` ("Forbidden: bot was blocked by the user"), `NotFound`,
73
+ `Conflict`, `TooManyRequests`. The `description` is the error's `message`,
74
+ and the whole envelope is its `body`. A `TooManyRequests` carries Telegram's
75
+ `retry_after` as `retryAfter`, and the default retry policy waits that long.
76
+
77
+ ## Files
78
+
79
+ A method with an `InputFile` parameter (`sendPhoto`, `sendDocument`,
80
+ `setChatPhoto`, ...) sends multipart/form-data. Pass a `Blob`, `Uint8Array` or
81
+ `ArrayBuffer` to upload, or a `file_id` or HTTP URL string to send a file
82
+ Telegram already has. Files nested in other parameters (`attach://<name>` in
83
+ `InputMedia`) are not supported yet.
package/lib/.lazy.json ADDED
@@ -0,0 +1 @@
1
+ {"serviceDirs":["services"],"twins":["index.js"]}
@@ -0,0 +1,4 @@
1
+ import*as $0 from"./sdk.js";
2
+ import{api$lazyService as L}from"@distilled.cloud/core/_bundle/base";
3
+ const u=import.meta.url,N=[$0];
4
+ export const $L=(s,k,a,l,x)=>L(u,s,k,a===void 0?void 0:x?N.concat(x):N,a,l);
@@ -0,0 +1,2 @@
1
+ import{api$D as e,api$call as t,api$named as n,api$op as r,category$withParseError as i,config$Redacted as ee,config$String as te,config$all as a,config$withDefault as o,retry$capped as s,retry$jittered as ne,retry$makeDefault as re,retry$throttlingFactory as ie,retry$throttlingOptions as ae,retry$transientFactory as oe,retry$transientOptions as se,schema_lite_typed$TaggedError as c,schema_lite_typed$Unknown as l,trait$Body as ce,trait$FormDataFile as le,trait$Header as u,trait$Http as d,trait$HttpBody as f,trait$KeyDictionary as p,trait$Label as m,trait$Query as h,trait$ResponseCode as g,trait$UnionCases as _,trait$applyErrorMatchers as v,trait$bodySymbol as y,trait$errorMatchersSymbol as b,trait$formDataFileSymbol as x,trait$getErrorMatchers as S,trait$headerSymbol as C,trait$httpBodySymbol as w,trait$httpSymbol as T,trait$keyDictionarySymbol as E,trait$labelSymbol as D,trait$querySymbol as O,trait$responseCodeSymbol as k,trait$unionCasesSymbol as A}from"@distilled.cloud/core/_bundle/base";import{errors$API_ERRORS as j,errors$BadGateway as M,errors$BadRequest as N,errors$ConfigError as P,errors$Conflict as F,errors$DEFAULT_ERRORS as I,errors$Forbidden as L,errors$GatewayTimeout as R,errors$HTTP_STATUS_MAP as z,errors$InternalServerError as B,errors$NotFound as V,errors$ServiceUnavailable as H,errors$TooManyRequests as U,errors$Unauthorized as W,errors$UnknownErrorFields as ue,errors$UnprocessableEntity as de,protocol_rest$RawResponse as fe,protocol_rest$RawResponseRoot as pe,protocol_rest$SensitiveValue as me,protocol_rest$rawResponseRootSymbol as he,protocol_rest$rawResponseSymbol as ge,protocol_rest$restProtocol as _e,protocol_rest$sensitiveValueSymbol as ve,protocol_rest$unknownErrorProps as ye,schema_lite$Array as be,schema_lite$Boolean as xe,schema_lite$Number as Se,schema_lite$String as Ce,schema_lite$Struct as we,schema_lite$Union as Te,schema_lite$Unknown as Ee,schema_lite$at as De,schema_lite$instanceOf as Oe,schema_lite$optional as ke,schema_lite$suspend as Ae}from"@distilled.cloud/core/_bundle/rest";import*as G from"effect/Context";import*as K from"effect/Effect";import*as q from"effect/Layer";import*as J from"effect/Redacted";import*as je from"effect/Duration";import*as Y from"effect/http/HttpClientError";import*as Me from"effect/http/HttpClientRequest";const X=`https://api.telegram.org`;var Credentials=class extends (/*@__PURE__*/ G.Service()(`TelegramCredentials`)){};const Ne=/^\d+:[A-Za-z0-9_-]+$/;const check=e=>{if(!Ne.test(J.value(e.token)))return K.fail(new P({message:`The Telegram bot token must look like 123456789:AAH... (the token @BotFather issues)`}));if(!/^https?:\/\/[^/?#]+(\/[^?#]*)?$/.test(e.apiBaseUrl))return K.fail(new P({message:`The Telegram API base URL must be an http(s) URL with no query, got "${e.apiBaseUrl}"`}));return K.succeed({token:e.token,apiBaseUrl:e.apiBaseUrl.replace(/\/+$/,``)})};const layer=e=>q.effect(Credentials,K.map(K.flatMap(e,check),e=>K.succeed(e)));const Pe=/*@__PURE__*/ a({token:/*@__PURE__*/ ee(`TELEGRAM_BOT_TOKEN`),apiBaseUrl:/*@__PURE__*/ te(`TELEGRAM_API_BASE_URL`).pipe(/*@__PURE__*/ o(X))});const Fe=/*@__PURE__*/ layer(/*@__PURE__*/ Pe.pipe(/*@__PURE__*/ K.mapError(()=>new P({message:`TELEGRAM_BOT_TOKEN environment variable is required`}))));const credentials=e=>layer(K.succeed({token:e.token,apiBaseUrl:e.apiBaseUrl??`https://api.telegram.org`}));var UnknownTelegramError=class extends (/*@__PURE__*/ c()(`UnknownTelegramError`,ue)){};var TelegramParseError=class extends (/*@__PURE__*/ c()(`TelegramParseError`,{body:l,cause:l}).pipe(i)){};const Ie=j;const isRecord=e=>typeof e===`object`&&e!==null&&!Array.isArray(e);const errorEnvelope=e=>{if(!isRecord(e))return void 0;return{code:typeof e.error_code===`number`?e.error_code:void 0,message:typeof e.description===`string`?e.description:void 0}};const rateLimited=e=>{if(e.status!==429||!isRecord(e.body)||!isRecord(e.body.parameters))return;const t=e.body.parameters.retry_after;if(typeof t!==`number`||!Number.isFinite(t)||t<0)return void 0;return new U({message:e.message,body:e.body,headers:Object.fromEntries(Object.entries(e.headers).filter(e=>e[1]!==void 0)),retryAfter:je.seconds(t)})};const Z=/*@__PURE__*/ _e({credentials:Credentials,baseUrl:e=>`${e.apiBaseUrl}/bot${J.value(e.token)}`,headers:()=>({}),errorEnvelope,classifyError:rateLimited,transformResponse:e=>isRecord(e)&&`result`in e?e.result:e,unknownError:e=>new UnknownTelegramError(ye(e)),parseError:({body:e,cause:t})=>new TelegramParseError({body:e,cause:t})});const Q=/\/bot[^/?#]+/;const withoutToken=e=>{const t=e.reason;const n=t.request.url;if(!Q.test(n))return e;const r={request:Me.setUrl(t.request,n.replace(Q,`/bot<token>`)),...`response`in t?{response:t.response}:{},...t.cause!==void 0?{cause:t.cause}:{},...t.description!==void 0?{description:t.description}:{}};const i=t.constructor;return new Y.HttpClientError({reason:new i(r)})};const call$1=(e,t)=>K.catchIf(Z.call(e,t),Y.isHttpClientError,e=>K.fail(withoutToken(e)));const Le={...Z,call:call$1};const $=Le;var Retry=class extends (/*@__PURE__*/ G.Service()(`TelegramRetry`)){};const policy=e=>K.provide(q.succeed(Retry,e));const Re=/*@__PURE__*/ K.provide(/*@__PURE__*/ q.succeed(Retry,{while:()=>false}));const ze=re;const Be=ne;const Ve=s;const He=ae;const Ue=/*@__PURE__*/ policy(ie);const We=se;const Ge=/*@__PURE__*/ policy(oe);export{De as Bc,Oe as Ec,ke as Gc,Ae as Hc,e as a,t as b,Credentials as credentials$Credentials,Fe as credentials$CredentialsFromEnv,X as credentials$DEFAULT_API_BASE_URL,check as credentials$check,credentials as credentials$credentials,j as errors$API_ERRORS,M as errors$BadGateway,N as errors$BadRequest,P as errors$ConfigError,F as errors$Conflict,I as errors$DEFAULT_ERRORS,L as errors$Forbidden,R as errors$GatewayTimeout,z as errors$HTTP_STATUS_MAP,B as errors$InternalServerError,V as errors$NotFound,H as errors$ServiceUnavailable,TelegramParseError as errors$TelegramParseError,Ie as errors$TelegramServiceErrors,U as errors$TooManyRequests,W as errors$Unauthorized,UnknownTelegramError as errors$UnknownTelegramError,de as errors$UnprocessableEntity,be as gc,xe as hc,n as l,r as n,$ as protocol$TelegramProtocol,Se as qc,Retry as retry$Retry,Ve as retry$capped,Be as retry$jittered,ze as retry$makeDefault,Re as retry$none,policy as retry$policy,Ue as retry$throttling,He as retry$throttlingOptions,Ge as retry$transient,We as retry$transientOptions,Ce as tc,ce as traits$Body,le as traits$FormDataFile,u as traits$Header,d as traits$Http,f as traits$HttpBody,p as traits$KeyDictionary,m as traits$Label,h as traits$Query,fe as traits$RawResponse,pe as traits$RawResponseRoot,g as traits$ResponseCode,me as traits$SensitiveValue,_ as traits$UnionCases,v as traits$applyErrorMatchers,y as traits$bodySymbol,b as traits$errorMatchersSymbol,x as traits$formDataFileSymbol,S as traits$getErrorMatchers,C as traits$headerSymbol,w as traits$httpBodySymbol,T as traits$httpSymbol,E as traits$keyDictionarySymbol,D as traits$labelSymbol,O as traits$querySymbol,he as traits$rawResponseRootSymbol,ge as traits$rawResponseSymbol,k as traits$responseCodeSymbol,ve as traits$sensitiveValueSymbol,A as traits$unionCasesSymbol,we as uc,Te as yc,Ee as zc};
2
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","names":["Schema.Unknown","Category.withParseError","call","Retries.makeDefault","Retries.jittered","Retries.capped","Retries.throttlingOptions","Retries.throttlingFactory","Retries.transientOptions","Retries.transientFactory","D","call","named","op","withParseError","Redacted$3","String$2","all$1","withDefault","capped$1","jittered$1","makeDefault$1","throttlingFactory","throttlingOptions$1","transientFactory","transientOptions$1","TaggedError$1","Unknown$1","Body","FormDataFile","Header","Http","HttpBody","KeyDictionary","Label","Query","ResponseCode","UnionCases","applyErrorMatchers","bodySymbol","errorMatchersSymbol","formDataFileSymbol","getErrorMatchers","headerSymbol","httpBodySymbol","httpSymbol","keyDictionarySymbol","labelSymbol","querySymbol","responseCodeSymbol","unionCasesSymbol","API_ERRORS","BadGateway","BadRequest","ConfigError","Conflict","DEFAULT_ERRORS","Forbidden","GatewayTimeout","HTTP_STATUS_MAP","InternalServerError","NotFound","ServiceUnavailable","TooManyRequests","Unauthorized","UnknownErrorFields","UnprocessableEntity","RawResponse","RawResponseRoot","SensitiveValue","rawResponseRootSymbol","rawResponseSymbol","restProtocol","sensitiveValueSymbol","unknownErrorProps","Array$1","Boolean","Number$1","String","Struct","Union","Unknown","at","instanceOf","optional","suspend","Context","Effect","Layer","Redacted","Duration","HttpClientError","HttpClientRequest","DEFAULT_API_BASE_URL","BOT_TOKEN","config","checked","envConfig","CredentialsFromEnv","TelegramServiceErrors","u","body","info","seconds","entry","RestProtocol","creds","TOKEN_SEGMENT","reason","error","url","props","Reason","input","telegramProtocolMethods","TelegramProtocol","optionsOrFactory","none","makeDefault","jittered","capped","throttlingOptions","throttling","transientOptions","transient"],"sources":["../../src/credentials.ts","../../src/errors.ts","../../src/protocol.ts","../../src/retry.ts"],"mappings":"owEAyBA,MAAa6F,EAAuB,2BAQpC,IAAa,YAAb,eACwB,gBAAQ,QAAqD,CAAC,CAClF,qBACF,EAAA,AAAE,CAAC,EAGL,MAAMC,GAAY,uBAQlB,MAAa,MAAS,GAAgE,CACpF,GAAI,CAACA,GAAU,KAAKL,EAAS,MAAMM,EAAO,KAAK,CAAC,EAC9C,OAAOR,EAAO,KACZ,IAAIjC,EAAY,CACd,QACE,sFACJ,CAAC,CACH,EAEF,GAAI,CAAC,kCAAkC,KAAKyC,EAAO,UAAU,EAC3D,OAAOR,EAAO,KACZ,IAAIjC,EAAY,CACd,QAAS,wEAAwEyC,EAAO,WAAW,EACrG,CAAC,CACH,EAGF,OAAOR,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AgB,gBAAgB,CAAE,OAAQ,IAAIqB,EAAOD,CAAK,CAAE,CAAC,CAC1E,EAIA,MAAM7G,QAAQ,EAAe,IAC3BqF,EAAO,QAELkB,EAAa,KAAM5F,EAAIoG,CAAK,EAC5BtB,EAAgB,kBACf,GAAUJ,EAAO,KAAK,aAAasB,CAAK,CAAC,CAC5C,EAEF,MAAMK,GAA0B,CAAE,GAAGT,EAAc,KAAA,MAAK,EAExD,MAAaU,EAA+DD,GCxH5E,IAAa,MAAb,eAAyC,gBAAQ,QAAuB,CAAC,CAAC,eAAe,EAAA,AAAE,CAAC,EAG5F,MAAa,OAOR,GAAwC3B,EAAO,QAAQC,EAAM,QAAQ,MAAO4B,CAAgB,CAAC,EAGlG,MAAaC,GAE+C,gBAAO,QACnD,gBAAM,QAAQ,MAAO,CAAE,UAAa,KAAM,CAAC,CAC3D,EAOA,MAAaC,GAAuBnH,GAEpC,MAAaoH,GAAWnH,GACxB,MAAaoH,GAASnH,EAGtB,MAAaoH,GAA6BnH,GAG1C,MAAaoH,GAE+C,qBAAOnH,EAAyB,EAG5F,MAAaoH,GAA4BnH,GAGzC,MAAaoH,GAE+C,qBAAOnH,EAAwB"}
@@ -0,0 +1,36 @@
1
+ import type { Checked } from "@distilled.cloud/core/config";
2
+ import { ConfigError } from "@distilled.cloud/core/errors";
3
+ import * as Context from "effect/Context";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Layer from "effect/Layer";
6
+ import * as Redacted from "effect/Redacted";
7
+ export declare const DEFAULT_API_BASE_URL = "https://api.telegram.org";
8
+ export interface Config {
9
+ readonly token: Redacted.Redacted<string>;
10
+ readonly apiBaseUrl: string;
11
+ }
12
+ declare const Credentials_base: Context.ServiceClass<Credentials, "TelegramCredentials", Effect.Effect<Checked<Config>, never, never>>;
13
+ /** What the service resolves: a {@link Config} that passed {@link check}. */
14
+ export declare class Credentials extends /*@__PURE__*/ Credentials_base {
15
+ }
16
+ /**
17
+ * Check `config`: fails with `ConfigError` for a token that is not a bot
18
+ * token (it goes into the request path, so a `/` or `?` in it would address
19
+ * another URL) and for a base URL that is not an http(s) URL. For a
20
+ * `Credentials` layer of your own.
21
+ */
22
+ export declare const check: (config: Config) => Effect.Effect<Checked<Config>, ConfigError>;
23
+ /**
24
+ * Credentials from `TELEGRAM_BOT_TOKEN` (required) and
25
+ * `TELEGRAM_API_BASE_URL` (optional, for a local Bot API server). The
26
+ * environment is read, and the values checked, once: when the layer is
27
+ * built.
28
+ */
29
+ export declare const CredentialsFromEnv: Layer.Layer<Credentials, ConfigError>;
30
+ /** Layer from a redacted bot token + optional base URL. */
31
+ export declare const credentials: (config: {
32
+ readonly token: Redacted.Redacted<string>;
33
+ readonly apiBaseUrl?: string;
34
+ }) => Layer.Layer<Credentials, ConfigError>;
35
+ export {};
36
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sources":["../src/credentials.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,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,6BAA6B,CAAC;AAE/D,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,6EAA6E;AAC7E,qBAAa,WACX,SAAQ,aAAa,CAAC,gBAErB;CAAG;AAKN;;;;;GAKG;AACH,eAAO,MAAM,KAAK,WAAY,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,WAAW,CAqBhF,CAAC;AAgBF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAMpE,CAAC;AAEF,2DAA2D;AAC3D,eAAO,MAAM,WAAW,WAAY;IAClC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,EAAE,WAAW,CAMrC,CAAC"}
@@ -0,0 +1 @@
1
+ export { credentials$Credentials as Credentials, credentials$CredentialsFromEnv as CredentialsFromEnv, credentials$DEFAULT_API_BASE_URL as DEFAULT_API_BASE_URL, credentials$check as check, credentials$credentials as credentials } from "./_bundle/sdk.js";
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Telegram-specific error types.
3
+ *
4
+ * The Bot API answers a failure with `{ ok: false, error_code, description }`
5
+ * and the HTTP status `error_code` names (400 "Bad Request: chat not found",
6
+ * 401, 403 "Forbidden: bot was blocked by the user", 409, 429, ...). The
7
+ * protocol maps the status to core's shared classes, which carry the
8
+ * `description` as their message and the whole envelope as `body`.
9
+ */
10
+ 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";
11
+ export type { DefaultErrors } from "@distilled.cloud/core/errors";
12
+ import * as Schema from "@distilled.cloud/core/schema-lite-typed";
13
+ declare const UnknownTelegramError_base: Schema.TaggedErrorClass<"UnknownTelegramError", {
14
+ status: import("effect/Schema").Number;
15
+ code: import("effect/Schema").optional<import("effect/Schema").String>;
16
+ message: import("effect/Schema").optional<import("effect/Schema").String>;
17
+ body: import("effect/Schema").Unknown;
18
+ }>;
19
+ /** Unknown Telegram error -- returned when nothing else matches the failure. */
20
+ export declare class UnknownTelegramError extends /*@__PURE__*/ UnknownTelegramError_base {
21
+ }
22
+ declare const TelegramParseError_base: Schema.TaggedErrorClass<"TelegramParseError", {
23
+ readonly body: import("effect/Schema").Unknown;
24
+ readonly cause: import("effect/Schema").Unknown;
25
+ }> & (new (...args: any[]) => {
26
+ "@distilled.cloud/error/categories": {
27
+ ParseError: true;
28
+ };
29
+ });
30
+ /** Schema parse error wrapper. */
31
+ export declare class TelegramParseError extends /*@__PURE__*/ TelegramParseError_base {
32
+ }
33
+ /**
34
+ * The errors declared on the Telegram service: any operation can return
35
+ * them, and every generated operation lists them as its `serviceErrors`.
36
+ * Today that is each of core's status classes (400, 401, 403, 404, 409,
37
+ * 429, the 5xx ...).
38
+ */
39
+ export declare const TelegramServiceErrors: readonly [typeof import("@distilled.cloud/core/errors").Unauthorized, typeof import("@distilled.cloud/core/errors").Forbidden, typeof import("@distilled.cloud/core/errors").NotFound, typeof import("@distilled.cloud/core/errors").BadRequest, typeof import("@distilled.cloud/core/errors").Conflict, typeof import("@distilled.cloud/core/errors").UnprocessableEntity, typeof import("@distilled.cloud/core/errors").TooManyRequests, typeof import("@distilled.cloud/core/errors").Locked, typeof import("@distilled.cloud/core/errors").InternalServerError, typeof import("@distilled.cloud/core/errors").BadGateway, typeof import("@distilled.cloud/core/errors").ServiceUnavailable, typeof import("@distilled.cloud/core/errors").GatewayTimeout];
40
+ export type TelegramServiceError = InstanceType<(typeof TelegramServiceErrors)[number]>;
41
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAIlE,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;;;;;;;AAElE,gFAAgF;AAChF,qBAAa,oBACX,SAAQ,aAAa,CAAC,yBAGrB;CAAG;;;;;;;;;AAEN,kCAAkC;AAClC,qBAAa,kBACX,SAAQ,aAAa,CAAC,uBAGU;CAAG;AAErC;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,+tBAAa,CAAC;AAChD,MAAM,MAAM,oBAAoB,GAAG,YAAY,CAAC,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC"}
package/lib/errors.js ADDED
@@ -0,0 +1 @@
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$TelegramParseError as TelegramParseError, errors$TelegramServiceErrors as TelegramServiceErrors, errors$TooManyRequests as TooManyRequests, errors$Unauthorized as Unauthorized, errors$UnknownTelegramError as UnknownTelegramError, errors$UnprocessableEntity as UnprocessableEntity } from "./_bundle/sdk.js";
package/lib/index.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ /**
2
+ * @distilled.cloud/telegram -- Telegram Bot API SDK for Effect.
3
+ *
4
+ * `./services` is generated by `scripts/generate.ts` from the Smithy model
5
+ * that `scripts/convert.ts` builds from the Telegram Bot API reference
6
+ * (its Markdown pages, saved in `specs/spec-mirror-telegram/specs/`;
7
+ * Telegram publishes no OpenAPI document). Everything else in this folder is
8
+ * hand-written.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import { Effect, Layer } from "effect";
13
+ * import * as FetchHttpClient from "effect/http/FetchHttpClient";
14
+ * import * as Telegram from "@distilled.cloud/telegram";
15
+ *
16
+ * const program = Effect.gen(function* () {
17
+ * const topic = yield* Telegram.createForumTopic({ chat_id: "@my_forum", name: "Releases" });
18
+ * return yield* Telegram.sendMessage({
19
+ * chat_id: "@my_forum",
20
+ * message_thread_id: topic.message_thread_id,
21
+ * text: "v1.0 is out",
22
+ * });
23
+ * });
24
+ *
25
+ * program.pipe(
26
+ * Effect.provide(Layer.mergeAll(FetchHttpClient.layer, Telegram.CredentialsFromEnv)),
27
+ * Effect.runPromise,
28
+ * );
29
+ * ```
30
+ */
31
+ export * from "./credentials.ts";
32
+ export * from "./errors.ts";
33
+ export * as T from "./traits.ts";
34
+ export { TelegramProtocol, type TelegramOpError, type TelegramOpContext } from "./protocol.ts";
35
+ export * as Retry from "./retry.ts";
36
+ export * from "./services/telegram.ts";
37
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,KAAK,eAAe,EAAE,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC/F,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,wBAAwB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./credentials.js";
2
+ export * from "./errors.js";
3
+ export * as T from "./traits.js";
4
+ export { TelegramProtocol } from "./protocol.js";
5
+ export * as Retry from "./retry.js";
6
+ export * from "./services/telegram.js";
@@ -0,0 +1,6 @@
1
+ export * from "./credentials.js";
2
+ export * from "./errors.js";
3
+ export * as T from "./traits.js";
4
+ export { TelegramProtocol } from "./protocol.js";
5
+ export * as Retry from "./retry.js";
6
+ export * from "./services.lazy/telegram.js";
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAgD,MAAM,eAAe,CAAC;AAC/F,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,wBAAwB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { TooManyRequests } from "@distilled.cloud/core/errors";
2
+ import type { ErrorOf, Operation, ProtocolOf } from "@distilled.cloud/core/protocol";
3
+ import * as Effect from "effect/Effect";
4
+ import type * as HttpClient from "effect/http/HttpClient";
5
+ import * as HttpClientError from "effect/http/HttpClientError";
6
+ import * as HttpClientRequest from "effect/http/HttpClientRequest";
7
+ import { Credentials } from "./credentials.ts";
8
+ import { TelegramParseError, UnknownTelegramError, type TelegramServiceError } from "./errors.ts";
9
+ /**
10
+ * What every generated Telegram operation fails with besides its own errors:
11
+ * the service's errors, the protocol's, and what resolving the credentials
12
+ * fails with. Generated service files annotate operations with
13
+ * `API.OperationMethod<I, O, TelegramOpError, TelegramOpContext>` explicitly
14
+ * so the compiler never infers these back out of the schema generics.
15
+ */
16
+ export type TelegramOpError = TelegramServiceError | ErrorOf<typeof TelegramProtocol>;
17
+ /** Context (requirements) shared by every generated Telegram operation. */
18
+ export type TelegramOpContext = Credentials | HttpClient.HttpClient;
19
+ declare const call: (op: Operation, input: unknown) => Effect.Effect<unknown, import("@distilled.cloud/core/protocol").DeclaredError | HttpClientError.HttpClientError | import("@distilled.cloud/core/errors").InternalServerError | import("@distilled.cloud/core/protocol-http").InvalidInput | import("@distilled.cloud/core/sdk-error").SdkError | TelegramParseError | TooManyRequests | UnknownTelegramError, Credentials>;
20
+ declare const telegramProtocolMethods: {
21
+ encode: (args: import("@distilled.cloud/core/protocol").EncodeArgs) => Effect.Effect<HttpClientRequest.HttpClientRequest, TelegramParseError | TooManyRequests | UnknownTelegramError | import("@distilled.cloud/core/protocol-rest").RestProtocolError, Credentials>;
22
+ decode: (args: import("@distilled.cloud/core/protocol").DecodeArgs) => Effect.Effect<unknown, import("@distilled.cloud/core/protocol").DeclaredError | TelegramParseError | TooManyRequests | UnknownTelegramError | import("@distilled.cloud/core/protocol-rest").RestProtocolError, Credentials>;
23
+ stream?: ((operation: Operation, input: unknown) => import("effect/Stream").Stream<unknown, import("@distilled.cloud/core/protocol").DeclaredError | TelegramParseError | TooManyRequests | UnknownTelegramError | import("@distilled.cloud/core/protocol-rest").RestProtocolError, Credentials>) | undefined;
24
+ call: typeof call;
25
+ };
26
+ export declare const TelegramProtocol: ProtocolOf<typeof telegramProtocolMethods>;
27
+ export {};
28
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAC/D,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAY,UAAU,EAAE,MAAM,gCAAgC,CAAC;AA6B/F,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,eAAe,MAAM,6BAA6B,CAAC;AAC/D,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AAGnE,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,KAAK,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAElG;;;;;;GAMG;AACH,MAAM,MAAM,eAAe,GAAG,oBAAoB,GAAG,OAAO,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEtF,2EAA2E;AAC3E,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAsFpE,QAAA,MAAM,IAAI,OAAQ,SAAS,SAAS,OAAO,+WAMxC,CAAC;AAEJ,QAAA,MAAM,uBAAuB;;;;;CAAiE,CAAC;AAE/F,eAAO,MAAM,gBAAgB,EAAE,UAAU,CAAC,OAAO,uBAAuB,CAA2B,CAAC"}
@@ -0,0 +1 @@
1
+ export { protocol$TelegramProtocol as TelegramProtocol } from "./_bundle/sdk.js";
package/lib/retry.d.ts ADDED
@@ -0,0 +1,50 @@
1
+ import * as Retries from "@distilled.cloud/core/retry";
2
+ /**
3
+ * Telegram retry surface -- a veneer over `@distilled.cloud/core/retry`.
4
+ *
5
+ * The `Retry` service tag is threaded into every generated operation via
6
+ * `API.make({ retry: Retry })`, so a caller-installed policy applies to all
7
+ * Telegram calls below it and core's `makeDefault` is the fallback when none is
8
+ * provided.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import * as Telegram from "@distilled.cloud/telegram";
13
+ *
14
+ * myEffect.pipe(Telegram.Retry.transient);
15
+ * ```
16
+ */
17
+ import * as Context from "effect/Context";
18
+ import * as Effect from "effect/Effect";
19
+ export type Options = Retries.Options;
20
+ export type Factory = Retries.Factory;
21
+ export type Policy = Retries.Policy;
22
+ declare const Retry_base: Context.ServiceClass<Retry, "TelegramRetry", Retries.Policy>;
23
+ /** Context tag for configuring retry behavior of Telegram API calls. */
24
+ export declare class Retry extends /*@__PURE__*/ Retry_base {
25
+ }
26
+ /** Provides a custom retry policy to every Telegram API call below it. */
27
+ export declare const policy: {
28
+ (options: Options): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
29
+ (factory: Factory): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
30
+ };
31
+ /** Disables all automatic retries. */
32
+ export declare const none: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
33
+ /**
34
+ * The default retry policy (core's): transient/throttling/retryable errors,
35
+ * capped exponential backoff with jitter, server `retryAfter` hints honored
36
+ * with precedence.
37
+ */
38
+ export declare const makeDefault: Factory;
39
+ export declare const jittered: <Error, Env>(self: import("effect/Schedule").Schedule<unknown, unknown, Error, Env>) => import("effect/Schedule").Schedule<unknown, unknown, Error, Env>;
40
+ export declare const capped: (max: import("effect/Duration").Duration) => <Error, Env>(self: import("effect/Schedule").Schedule<unknown, unknown, Error, Env>) => import("effect/Schedule").Schedule<unknown, unknown, Error, Env>;
41
+ /** Retry options that retry all throttling errors indefinitely. */
42
+ export declare const throttlingOptions: Options;
43
+ /** Retries all throttling errors indefinitely (honoring server hints). */
44
+ export declare const throttling: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
45
+ /** Retry options that retry all transient errors indefinitely. */
46
+ export declare const transientOptions: Options;
47
+ /** Retries all transient errors indefinitely. */
48
+ export declare const transient: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
49
+ export {};
50
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACtC,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACtC,MAAM,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;;AAEpC,wEAAwE;AACxE,qBAAa,KAAM,SAAQ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,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAmD,CAAC;AAE9F,kEAAkE;AAClE,eAAO,MAAM,gBAAgB,EAAE,OAAkC,CAAC;AAElE,iDAAiD;AACjD,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAkD,CAAC"}
package/lib/retry.js ADDED
@@ -0,0 +1 @@
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";
@@ -0,0 +1,2 @@
1
+ export * as telegram from "./telegram.ts";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sources":["../../src/services/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,QAAQ,MAAM,eAAe,CAAC"}
@@ -0,0 +1 @@
1
+ export * as telegram from "./telegram.js";