@sendora/sdk 1.1.0 → 2.1.0

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 (69) hide show
  1. package/README.md +152 -70
  2. package/dist/account.d.ts +30 -0
  3. package/dist/account.d.ts.map +1 -0
  4. package/dist/account.js +25 -0
  5. package/dist/account.js.map +1 -0
  6. package/dist/client.d.ts +13 -16
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/client.js +11 -30
  9. package/dist/client.js.map +1 -1
  10. package/dist/domains.d.ts +1 -1
  11. package/dist/domains.d.ts.map +1 -1
  12. package/dist/domains.js +1 -1
  13. package/dist/domains.js.map +1 -1
  14. package/dist/error.d.ts +6 -3
  15. package/dist/error.d.ts.map +1 -1
  16. package/dist/error.js +22 -2
  17. package/dist/error.js.map +1 -1
  18. package/dist/inbound-domains.d.ts +36 -0
  19. package/dist/inbound-domains.d.ts.map +1 -0
  20. package/dist/inbound-domains.js +72 -0
  21. package/dist/inbound-domains.js.map +1 -0
  22. package/dist/inbound.d.ts +61 -0
  23. package/dist/inbound.d.ts.map +1 -0
  24. package/dist/inbound.js +106 -0
  25. package/dist/inbound.js.map +1 -0
  26. package/dist/index.d.ts +8 -1
  27. package/dist/index.d.ts.map +1 -1
  28. package/dist/index.js +3 -1
  29. package/dist/index.js.map +1 -1
  30. package/dist/options.d.ts +20 -0
  31. package/dist/options.d.ts.map +1 -0
  32. package/dist/options.js +34 -0
  33. package/dist/options.js.map +1 -0
  34. package/dist/servers.d.ts +64 -0
  35. package/dist/servers.d.ts.map +1 -0
  36. package/dist/servers.js +133 -0
  37. package/dist/servers.js.map +1 -0
  38. package/dist/transport.d.ts +2 -0
  39. package/dist/transport.d.ts.map +1 -1
  40. package/dist/transport.js +15 -5
  41. package/dist/transport.js.map +1 -1
  42. package/dist/types.d.ts +182 -5
  43. package/dist/types.d.ts.map +1 -1
  44. package/dist/version.d.ts +1 -1
  45. package/dist/version.js +1 -1
  46. package/dist/webhook-verify.d.ts +7 -5
  47. package/dist/webhook-verify.d.ts.map +1 -1
  48. package/dist/webhook-verify.js +38 -17
  49. package/dist/webhook-verify.js.map +1 -1
  50. package/dist/webhooks.d.ts +13 -1
  51. package/dist/webhooks.d.ts.map +1 -1
  52. package/dist/webhooks.js +26 -0
  53. package/dist/webhooks.js.map +1 -1
  54. package/package.json +4 -9
  55. package/skills/sendora/SKILL.md +19 -9
  56. package/src/account.ts +40 -0
  57. package/src/client.ts +20 -43
  58. package/src/domains.ts +1 -1
  59. package/src/error.ts +36 -3
  60. package/src/inbound-domains.ts +89 -0
  61. package/src/inbound.ts +135 -0
  62. package/src/index.ts +8 -1
  63. package/src/options.ts +51 -0
  64. package/src/servers.ts +166 -0
  65. package/src/transport.ts +26 -5
  66. package/src/types.ts +194 -5
  67. package/src/version.ts +1 -1
  68. package/src/webhook-verify.ts +39 -18
  69. package/src/webhooks.ts +29 -0
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,mBAAmB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEnF,mIAAmI;AACnI,MAAM,MAAM,gBAAgB,GACxB,iBAAiB,GACjB,cAAc,GACd,kBAAkB,GAClB,eAAe,GACf,mBAAmB,GACnB,uBAAuB,GACvB,oBAAoB,GACpB,WAAW,GACX,eAAe,GACf,gBAAgB,GAChB,eAAe,GACf,uBAAuB,GACvB,gBAAgB,GAChB,YAAY,GACZ,mBAAmB,GACnB,0BAA0B,GAC1B,kBAAkB,GAClB,iBAAiB,GACjB,eAAe,GACf,qBAAqB,GACrB,sBAAsB,GACtB,uBAAuB,GACvB,oBAAoB,GACpB,sBAAsB,GACtB,iCAAiC,GACjC,2BAA2B,GAC3B,sBAAsB,GACtB,0BAA0B,GAC1B,0BAA0B,GAC1B,cAAc,GACd,qBAAqB,GACrB,kBAAkB,GAClB,mBAAmB,GACnB,S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,GAAG,IAAI,CAAC;IACnC,yEAAyE;IACzE,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;IAClC,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,uEAAuE;IACvE,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,6DAA6D;IAC7D,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,qKAAqK;IACrK,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,uDAAuD;IACvD,QAAQ,CAAC,MAAM,EAAE,eAAe,EAAE,CAAC;IACnC,kEAAkE;IAClE,QAAQ,CAAC,UAAU,EAAE,mBAAmB,EAAE,CAAC;IAC3C,mFAAmF;IACnF,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,4MAA4M;IAC5M,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;gBAEvB,MAAM,EAAE,kBAAkB;IAiBtC,4JAA4J;IAC5J,IAAI,SAAS,IAAI,OAAO,CAQvB;IAED,MAAM,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAmBlC;AAED,sGAAsG;AACtG,wBAAgB,eAAe,CAC7B,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,OAAO,EACb,gBAAgB,EAAE,MAAM,GAAG,IAAI,GAC9B,YAAY,CA8Bd"}
package/dist/error.js CHANGED
@@ -1,6 +1,7 @@
1
1
  const apiCodes = new Set([
2
2
  'invalid_request',
3
3
  'unauthorized',
4
+ 'wrong_token_kind',
4
5
  'payment_required',
5
6
  'tenant_paused',
6
7
  'tenant_not_active',
@@ -8,11 +9,20 @@ const apiCodes = new Set([
8
9
  'unsubscribe_locked',
9
10
  'not_found',
10
11
  'domain_exists',
12
+ 'domain_reserved',
13
+ 'inbound_domain_exists',
11
14
  'webhook_exists',
12
15
  'stream_exists',
13
16
  'inbound_stream_exists',
14
17
  'default_stream',
15
18
  'last_token',
19
+ 'token_limit',
20
+ 'last_secret',
21
+ 'secret_limit',
22
+ 'server_exists',
23
+ 'server_limit',
24
+ 'server_reserved',
25
+ 'server_in_flight',
16
26
  'request_too_large',
17
27
  'from_domain_not_verified',
18
28
  'stream_not_found',
@@ -25,6 +35,8 @@ const apiCodes = new Set([
25
35
  'substitution_missing',
26
36
  'unsubscribe_placeholder_missing',
27
37
  'list_unsubscribe_reserved',
38
+ 'content_expired',
39
+ 'content_unreadable',
28
40
  'recipient_suppressed',
29
41
  'idempotency_key_mismatch',
30
42
  'idempotency_key_required',
@@ -64,13 +76,15 @@ export class SendoraError extends Error {
64
76
  used;
65
77
  /** When the month counter resets, on monthly_cap_reached. */
66
78
  resetsAt;
79
+ /** Live keys the server or the account may hold, on token_limit; servers the account may have, on server_limit; live secrets a webhook may hold, on secret_limit. */
80
+ max;
67
81
  /** One entry per invalid field, on invalid_request. */
68
82
  issues;
69
83
  /** The recipients the server refused, on recipient_suppressed. */
70
84
  suppressed;
71
85
  /** The stream whose suppression list refused the send, on recipient_suppressed. */
72
86
  streamId;
73
- /** The id of the domain, webhook or stream that already exists, on domain_exists, webhook_exists and stream_exists. */
87
+ /** The id of the domain, webhook or stream that already exists, on domain_exists, webhook_exists, stream_exists, inbound_stream_exists and, when the stream already has a domain, inbound_domain_exists. */
74
88
  existingId;
75
89
  constructor(fields) {
76
90
  super(fields.message, { cause: fields.cause });
@@ -82,6 +96,7 @@ export class SendoraError extends Error {
82
96
  this.cap = fields.cap ?? null;
83
97
  this.used = fields.used ?? null;
84
98
  this.resetsAt = fields.resetsAt ?? null;
99
+ this.max = fields.max ?? null;
85
100
  this.issues = fields.issues ?? [];
86
101
  this.suppressed = fields.suppressed ?? [];
87
102
  this.streamId = fields.streamId ?? null;
@@ -107,6 +122,7 @@ export class SendoraError extends Error {
107
122
  cap: this.cap,
108
123
  used: this.used,
109
124
  resetsAt: this.resetsAt,
125
+ max: this.max,
110
126
  issues: this.issues,
111
127
  suppressed: this.suppressed,
112
128
  streamId: this.streamId,
@@ -134,10 +150,14 @@ export function errorFromAnswer(status, body, retryAfterHeader) {
134
150
  cap: integerOf(answer.cap),
135
151
  used: integerOf(answer.used),
136
152
  resetsAt: typeof answer.resetsAt === 'string' ? answer.resetsAt : null,
153
+ max: integerOf(answer.max) ?? integerOf(answer.maxServers),
137
154
  issues,
138
155
  suppressed: Array.isArray(answer.suppressed) ? answer.suppressed.filter(isSuppressed) : [],
139
156
  streamId: code === 'recipient_suppressed' ? stringOf(answer.streamId) : null,
140
- existingId: stringOf(answer.domainId) ?? stringOf(answer.webhookId) ?? stringOf(answer.streamId),
157
+ existingId: stringOf(answer.domainId) ??
158
+ stringOf(answer.webhookId) ??
159
+ stringOf(answer.streamId) ??
160
+ stringOf(answer.inboundDomainId),
141
161
  });
142
162
  }
143
163
  function stringOf(value) {
package/dist/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AA0CA,MAAM,QAAQ,GAAwB,IAAI,GAAG,CAAmB;IAC9D,iBAAiB;IACjB,cAAc;IACd,kBAAkB;IAClB,eAAe;IACf,mBAAmB;IACnB,uBAAuB;IACvB,oBAAoB;IACpB,WAAW;IACX,eAAe;IACf,gBAAgB;IAChB,eAAe;IACf,uBAAuB;IACvB,gBAAgB;IAChB,YAAY;IACZ,mBAAmB;IACnB,0BAA0B;IAC1B,kBAAkB;IAClB,iBAAiB;IACjB,eAAe;IACf,qBAAqB;IACrB,sBAAsB;IACtB,uBAAuB;IACvB,oBAAoB;IACpB,sBAAsB;IACtB,iCAAiC;IACjC,2BAA2B;IAC3B,sBAAsB;IACtB,0BAA0B;IAC1B,0BAA0B;IAC1B,cAAc;IACd,qBAAqB;IACrB,kBAAkB;CACnB,CAAC,CAAC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AAC;AAED,SAAS,YAAY,CAAC,KAAc;IAClC,OAAO,CACL,QAAQ,CAAC,KAAK,CAAC;QACf,OAAO,KAAK,CAAC,OAAO,KAAK,QAAQ;QACjC,CAAC,KAAK,CAAC,MAAM,KAAK,aAAa;YAC7B,KAAK,CAAC,MAAM,KAAK,gBAAgB;YACjC,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,CAC7B,CAAC;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,KAAc;IAC/B,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;QACzD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QACrD,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACvB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { Transport } from './transport.ts';
2
+ import type { CreateInboundDomainRequest, InboundDomain, InboundDomainList, RequestOptions, VerifiedInboundDomain } from './types.ts';
3
+ /** The server's own domains for receiving: one per inbound stream, catch-all, with the two DNS records each one needs. */
4
+ export declare class InboundDomainsResource {
5
+ #private;
6
+ constructor(transport: Transport);
7
+ /**
8
+ * Claims a domain for an inbound stream and answers the two records to
9
+ * create: an MX that brings the domain's mail to Sendora and a TXT
10
+ * record that proves the claim. Mail is accepted once both are seen.
11
+ * `domain_reserved` is a name of Sendora's own; `inbound_domain_exists`
12
+ * is a stream that already has a domain (`existingId` names it) or a
13
+ * name another account holds verified.
14
+ *
15
+ * @example
16
+ * const domain = await sendora.inboundDomains.create({ streamId, domain: 'post.example.se' });
17
+ * console.log(domain.mx.host, domain.mx.value);
18
+ * console.log(domain.txt.host, domain.txt.value);
19
+ */
20
+ create(request: CreateInboundDomainRequest, options?: RequestOptions): Promise<InboundDomain>;
21
+ /** Every inbound domain of the token's server. */
22
+ list(options?: RequestOptions): Promise<InboundDomainList>;
23
+ /** One domain by id, with the state of its records. */
24
+ get(inboundDomainId: string, options?: RequestOptions): Promise<InboundDomain>;
25
+ /**
26
+ * Looks both records up now and answers the domain as it stands plus
27
+ * what each lookup found: `ok`, `missing`, `mismatch` or `dns_error`.
28
+ *
29
+ * @example
30
+ * const { verified, check } = await sendora.inboundDomains.verify(inboundDomainId);
31
+ */
32
+ verify(inboundDomainId: string, options?: RequestOptions): Promise<VerifiedInboundDomain>;
33
+ /** Removes the domain; mail to it is refused from then on, and the name is free for another claim. */
34
+ delete(inboundDomainId: string, options?: RequestOptions): Promise<void>;
35
+ }
36
+ //# sourceMappingURL=inbound-domains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound-domains.d.ts","sourceRoot":"","sources":["../src/inbound-domains.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EACV,0BAA0B,EAC1B,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,qBAAqB,EACtB,MAAM,YAAY,CAAC;AAEpB,0HAA0H;AAC1H,qBAAa,sBAAsB;;gBAGrB,SAAS,EAAE,SAAS;IAIhC;;;;;;;;;;;;OAYG;IACH,MAAM,CACJ,OAAO,EAAE,0BAA0B,EACnC,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,aAAa,CAAC;IAUzB,kDAAkD;IAClD,IAAI,CAAC,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAS9D,uDAAuD;IACvD,GAAG,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,aAAa,CAAC;IASlF;;;;;;OAMG;IACH,MAAM,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAS7F,sGAAsG;IACtG,MAAM,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;CAQ7E"}
@@ -0,0 +1,72 @@
1
+ /** The server's own domains for receiving: one per inbound stream, catch-all, with the two DNS records each one needs. */
2
+ export class InboundDomainsResource {
3
+ #transport;
4
+ constructor(transport) {
5
+ this.#transport = transport;
6
+ }
7
+ /**
8
+ * Claims a domain for an inbound stream and answers the two records to
9
+ * create: an MX that brings the domain's mail to Sendora and a TXT
10
+ * record that proves the claim. Mail is accepted once both are seen.
11
+ * `domain_reserved` is a name of Sendora's own; `inbound_domain_exists`
12
+ * is a stream that already has a domain (`existingId` names it) or a
13
+ * name another account holds verified.
14
+ *
15
+ * @example
16
+ * const domain = await sendora.inboundDomains.create({ streamId, domain: 'post.example.se' });
17
+ * console.log(domain.mx.host, domain.mx.value);
18
+ * console.log(domain.txt.host, domain.txt.value);
19
+ */
20
+ create(request, options = {}) {
21
+ return this.#transport.request({
22
+ method: 'POST',
23
+ path: '/v1/inbound/domains',
24
+ body: request,
25
+ idempotent: false,
26
+ signal: options.signal,
27
+ });
28
+ }
29
+ /** Every inbound domain of the token's server. */
30
+ list(options = {}) {
31
+ return this.#transport.request({
32
+ method: 'GET',
33
+ path: '/v1/inbound/domains',
34
+ idempotent: true,
35
+ signal: options.signal,
36
+ });
37
+ }
38
+ /** One domain by id, with the state of its records. */
39
+ get(inboundDomainId, options = {}) {
40
+ return this.#transport.request({
41
+ method: 'GET',
42
+ path: `/v1/inbound/domains/${encodeURIComponent(inboundDomainId)}`,
43
+ idempotent: true,
44
+ signal: options.signal,
45
+ });
46
+ }
47
+ /**
48
+ * Looks both records up now and answers the domain as it stands plus
49
+ * what each lookup found: `ok`, `missing`, `mismatch` or `dns_error`.
50
+ *
51
+ * @example
52
+ * const { verified, check } = await sendora.inboundDomains.verify(inboundDomainId);
53
+ */
54
+ verify(inboundDomainId, options = {}) {
55
+ return this.#transport.request({
56
+ method: 'POST',
57
+ path: `/v1/inbound/domains/${encodeURIComponent(inboundDomainId)}/verify`,
58
+ idempotent: true,
59
+ signal: options.signal,
60
+ });
61
+ }
62
+ /** Removes the domain; mail to it is refused from then on, and the name is free for another claim. */
63
+ delete(inboundDomainId, options = {}) {
64
+ return this.#transport.request({
65
+ method: 'DELETE',
66
+ path: `/v1/inbound/domains/${encodeURIComponent(inboundDomainId)}`,
67
+ idempotent: true,
68
+ signal: options.signal,
69
+ });
70
+ }
71
+ }
72
+ //# sourceMappingURL=inbound-domains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound-domains.js","sourceRoot":"","sources":["../src/inbound-domains.ts"],"names":[],"mappings":"AASA,0HAA0H;AAC1H,MAAM,OAAO,sBAAsB;IACxB,UAAU,CAAY;IAE/B,YAAY,SAAoB;QAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,MAAM,CACJ,OAAmC,EACnC,UAA0B,EAAE;QAE5B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAgB;YAC5C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,qBAAqB;YAC3B,IAAI,EAAE,OAAO;YACb,UAAU,EAAE,KAAK;YACjB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;IAED,kDAAkD;IAClD,IAAI,CAAC,UAA0B,EAAE;QAC/B,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAoB;YAChD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,qBAAqB;YAC3B,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;IAED,uDAAuD;IACvD,GAAG,CAAC,eAAuB,EAAE,UAA0B,EAAE;QACvD,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAgB;YAC5C,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,uBAAuB,kBAAkB,CAAC,eAAe,CAAC,EAAE;YAClE,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;IAED;;;;;;OAMG;IACH,MAAM,CAAC,eAAuB,EAAE,UAA0B,EAAE;QAC1D,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAwB;YACpD,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,uBAAuB,kBAAkB,CAAC,eAAe,CAAC,SAAS;YACzE,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;IAED,sGAAsG;IACtG,MAAM,CAAC,eAAuB,EAAE,UAA0B,EAAE;QAC1D,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAY;YACxC,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,uBAAuB,kBAAkB,CAAC,eAAe,CAAC,EAAE;YAClE,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,61 @@
1
+ import type { Transport } from './transport.ts';
2
+ import type { InboundMessage, InboundMessageDetail, InboundPage, InboundSearch, InboundSearchBody, RequestOptions } from './types.ts';
3
+ /** The mail the token's server has received on its inbound stream. */
4
+ export declare class InboundResource {
5
+ #private;
6
+ constructor(transport: Transport);
7
+ /**
8
+ * One received message: its envelope, parties, headers, text and HTML,
9
+ * and its attachments described. The attachment bytes and the raw
10
+ * message are downloads of their own. Once the stream's content window
11
+ * has passed, `contentAvailable` is false and the content fields are
12
+ * null.
13
+ *
14
+ * @example
15
+ * const message = await sendora.inbound.get(inboundMessageId);
16
+ * console.log(message.from?.address, message.subject, message.text);
17
+ */
18
+ get(inboundMessageId: string, options?: RequestOptions): Promise<InboundMessageDetail>;
19
+ /**
20
+ * One page of received messages, newest first. Every filter is
21
+ * optional; pass the page's `next` as `after` for the following page,
22
+ * or use `searchAll`.
23
+ *
24
+ * @example
25
+ * const page = await sendora.inbound.search({ from: 'anna@example.com', limit: 20 });
26
+ */
27
+ search(search?: InboundSearch, options?: RequestOptions): Promise<InboundPage>;
28
+ /**
29
+ * Every received message the filters match, page by page, for `for await`.
30
+ *
31
+ * @example
32
+ * for await (const message of sendora.inbound.searchAll({ recipient: address })) {
33
+ * console.log(message.receivedAt, message.subject);
34
+ * }
35
+ */
36
+ searchAll(search?: InboundSearch, options?: RequestOptions): AsyncIterable<InboundMessage>;
37
+ /**
38
+ * The message byte for byte as it was received, as `message/rfc822`.
39
+ * Throws `content_expired` once the stream's content window has passed.
40
+ *
41
+ * @example
42
+ * const raw = await sendora.inbound.raw(inboundMessageId);
43
+ * await writeFile(`${inboundMessageId}.eml`, raw);
44
+ */
45
+ raw(inboundMessageId: string, options?: RequestOptions): Promise<Uint8Array>;
46
+ /**
47
+ * An attachment's bytes, whatever the sender declared them to be; the
48
+ * name and the declared type are on the message. Throws
49
+ * `content_expired` once the stream's content window has passed.
50
+ *
51
+ * @example
52
+ * const message = await sendora.inbound.get(inboundMessageId);
53
+ * for (const attachment of message.attachments) {
54
+ * const bytes = await sendora.inbound.attachment(inboundMessageId, attachment.attachmentId);
55
+ * }
56
+ */
57
+ attachment(inboundMessageId: string, attachmentId: string, options?: RequestOptions): Promise<Uint8Array>;
58
+ }
59
+ /** The body as the API takes it: times as ISO 8601 strings. */
60
+ export declare function encodeInboundSearch(search: InboundSearch): InboundSearchBody;
61
+ //# sourceMappingURL=inbound.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound.d.ts","sourceRoot":"","sources":["../src/inbound.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EACV,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,aAAa,EACb,iBAAiB,EACjB,cAAc,EACf,MAAM,YAAY,CAAC;AAEpB,sEAAsE;AACtE,qBAAa,eAAe;;gBAGd,SAAS,EAAE,SAAS;IAIhC;;;;;;;;;;OAUG;IACH,GAAG,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAS1F;;;;;;;OAOG;IACH,MAAM,CAAC,MAAM,GAAE,aAAkB,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,WAAW,CAAC;IAUtF;;;;;;;OAOG;IACH,SAAS,CACP,MAAM,GAAE,aAAkB,EAC1B,OAAO,GAAE,cAAmB,GAC3B,aAAa,CAAC,cAAc,CAAC;IAShC;;;;;;;OAOG;IACH,GAAG,CAAC,gBAAgB,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,UAAU,CAAC;IAShF;;;;;;;;;;OAUG;IACH,UAAU,CACR,gBAAgB,EAAE,MAAM,EACxB,YAAY,EAAE,MAAM,EACpB,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,UAAU,CAAC;CAQvB;AAED,+DAA+D;AAC/D,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,GAAG,iBAAiB,CAU5E"}
@@ -0,0 +1,106 @@
1
+ import { paginate } from "./pagination.js";
2
+ /** The mail the token's server has received on its inbound stream. */
3
+ export class InboundResource {
4
+ #transport;
5
+ constructor(transport) {
6
+ this.#transport = transport;
7
+ }
8
+ /**
9
+ * One received message: its envelope, parties, headers, text and HTML,
10
+ * and its attachments described. The attachment bytes and the raw
11
+ * message are downloads of their own. Once the stream's content window
12
+ * has passed, `contentAvailable` is false and the content fields are
13
+ * null.
14
+ *
15
+ * @example
16
+ * const message = await sendora.inbound.get(inboundMessageId);
17
+ * console.log(message.from?.address, message.subject, message.text);
18
+ */
19
+ get(inboundMessageId, options = {}) {
20
+ return this.#transport.request({
21
+ method: 'GET',
22
+ path: `/v1/inbound/${encodeURIComponent(inboundMessageId)}`,
23
+ idempotent: true,
24
+ signal: options.signal,
25
+ });
26
+ }
27
+ /**
28
+ * One page of received messages, newest first. Every filter is
29
+ * optional; pass the page's `next` as `after` for the following page,
30
+ * or use `searchAll`.
31
+ *
32
+ * @example
33
+ * const page = await sendora.inbound.search({ from: 'anna@example.com', limit: 20 });
34
+ */
35
+ search(search = {}, options = {}) {
36
+ return this.#transport.request({
37
+ method: 'POST',
38
+ path: '/v1/inbound/search',
39
+ body: encodeInboundSearch(search),
40
+ idempotent: true,
41
+ signal: options.signal,
42
+ });
43
+ }
44
+ /**
45
+ * Every received message the filters match, page by page, for `for await`.
46
+ *
47
+ * @example
48
+ * for await (const message of sendora.inbound.searchAll({ recipient: address })) {
49
+ * console.log(message.receivedAt, message.subject);
50
+ * }
51
+ */
52
+ searchAll(search = {}, options = {}) {
53
+ return paginate((after) => this.search({ ...search, after }, options), (page) => page.messages, (page) => page.next, search.after);
54
+ }
55
+ /**
56
+ * The message byte for byte as it was received, as `message/rfc822`.
57
+ * Throws `content_expired` once the stream's content window has passed.
58
+ *
59
+ * @example
60
+ * const raw = await sendora.inbound.raw(inboundMessageId);
61
+ * await writeFile(`${inboundMessageId}.eml`, raw);
62
+ */
63
+ raw(inboundMessageId, options = {}) {
64
+ return this.#transport.requestBytes({
65
+ method: 'GET',
66
+ path: `/v1/inbound/${encodeURIComponent(inboundMessageId)}/raw`,
67
+ idempotent: true,
68
+ signal: options.signal,
69
+ });
70
+ }
71
+ /**
72
+ * An attachment's bytes, whatever the sender declared them to be; the
73
+ * name and the declared type are on the message. Throws
74
+ * `content_expired` once the stream's content window has passed.
75
+ *
76
+ * @example
77
+ * const message = await sendora.inbound.get(inboundMessageId);
78
+ * for (const attachment of message.attachments) {
79
+ * const bytes = await sendora.inbound.attachment(inboundMessageId, attachment.attachmentId);
80
+ * }
81
+ */
82
+ attachment(inboundMessageId, attachmentId, options = {}) {
83
+ return this.#transport.requestBytes({
84
+ method: 'GET',
85
+ path: `/v1/inbound/${encodeURIComponent(inboundMessageId)}/attachments/${encodeURIComponent(attachmentId)}`,
86
+ idempotent: true,
87
+ signal: options.signal,
88
+ });
89
+ }
90
+ }
91
+ /** The body as the API takes it: times as ISO 8601 strings. */
92
+ export function encodeInboundSearch(search) {
93
+ const { receivedFrom, receivedTo, ...fields } = search;
94
+ const body = { ...fields };
95
+ if (receivedFrom !== undefined) {
96
+ body.receivedFrom = isoOf(receivedFrom);
97
+ }
98
+ if (receivedTo !== undefined) {
99
+ body.receivedTo = isoOf(receivedTo);
100
+ }
101
+ return body;
102
+ }
103
+ function isoOf(value) {
104
+ return typeof value === 'string' ? value : value.toISOString();
105
+ }
106
+ //# sourceMappingURL=inbound.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inbound.js","sourceRoot":"","sources":["../src/inbound.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAW3C,sEAAsE;AACtE,MAAM,OAAO,eAAe;IACjB,UAAU,CAAY;IAE/B,YAAY,SAAoB;QAC9B,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;IAC9B,CAAC;IAED;;;;;;;;;;OAUG;IACH,GAAG,CAAC,gBAAwB,EAAE,UAA0B,EAAE;QACxD,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAuB;YACnD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,eAAe,kBAAkB,CAAC,gBAAgB,CAAC,EAAE;YAC3D,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,SAAwB,EAAE,EAAE,UAA0B,EAAE;QAC7D,OAAO,IAAI,CAAC,UAAU,CAAC,OAAO,CAAc;YAC1C,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,oBAAoB;YAC1B,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC;YACjC,UAAU,EAAE,IAAI;YAChB,MAAM,EAAE,OAAO,CAAC,MAAM;SACvB,CAAC,CAAC;IACL,CAAC;IA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,GAAG,KAAK,CAAC,YAAY,CAAC,CAAC;IAC1C,CAAC;IACD,IAAI,UAAU,KAAK,SAAS,EAAE,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC;IACtC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,KAAK,CAAC,KAAoB;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;AACjE,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,11 +1,18 @@
1
- export { DEFAULT_BASE_URL, Sendora } from './client.ts';
1
+ export { SendoraAccount } from './account.ts';
2
+ export type { SendoraAccountOptions } from './account.ts';
3
+ export { Sendora } from './client.ts';
2
4
  export type { SendoraOptions } from './client.ts';
3
5
  export type { BroadcastsResource } from './broadcasts.ts';
4
6
  export type { DomainsResource } from './domains.ts';
5
7
  export type { EmailResource } from './email.ts';
6
8
  export { SendoraError } from './error.ts';
7
9
  export type { SendoraErrorCode } from './error.ts';
10
+ export type { InboundResource } from './inbound.ts';
11
+ export type { InboundDomainsResource } from './inbound-domains.ts';
8
12
  export type { MessagesResource } from './messages.ts';
13
+ export { DEFAULT_BASE_URL } from './options.ts';
14
+ export type { ClientOptions } from './options.ts';
15
+ export type { ServersResource, ServerTokensResource } from './servers.ts';
9
16
  export type { StreamsResource } from './streams.ts';
10
17
  export type { SuppressionsResource } from './suppressions.ts';
11
18
  export type { TokensResource } from './tokens.ts';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACxD,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,YAAY,EAAE,eA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AY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,cAAc,CAAC;AAC1E,YAAY,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AACpD,YAAY,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,YAAY,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,mBAAmB,YAAY,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,YAAY,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,YAAY,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
- export { DEFAULT_BASE_URL, Sendora } from "./client.js";
1
+ export { SendoraAccount } from "./account.js";
2
+ export { Sendora } from "./client.js";
2
3
  export { SendoraError } from "./error.js";
4
+ export { DEFAULT_BASE_URL } from "./options.js";
3
5
  export { SDK_VERSION } from "./version.js";
4
6
  export { verifyWebhook } from "./webhook-verify.js";
5
7
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAKxD,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAO1C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAKtC,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAK1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOhD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { Transport } from './transport.ts';
2
+ export declare const DEFAULT_BASE_URL = "https://api.sendora.se";
3
+ /** What both clients take besides the key. */
4
+ export interface ClientOptions {
5
+ /** The API's origin; https://api.sendora.se unless you test against another. */
6
+ baseUrl?: string | undefined;
7
+ /** The fetch to use; the global one unless you need a proxy or a fake. */
8
+ fetch?: typeof fetch | undefined;
9
+ /** How long one attempt may take; 30 seconds by default. */
10
+ timeoutMs?: number | undefined;
11
+ /** How many times a failed call is repeated when repeating is safe; 2 by default, 0 turns retries off. */
12
+ maxRetries?: number | undefined;
13
+ }
14
+ /**
15
+ * The transport a client's resources share, built once at construction so
16
+ * a missing key or a nonsense option fails at startup rather than at the
17
+ * first call.
18
+ */
19
+ export declare function transportFor(token: string | undefined, options: ClientOptions, missingKey: string): Transport;
20
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAG3C,eAAO,MAAM,gBAAgB,2BAA2B,CAAC;AAGzD,8CAA8C;AAC9C,MAAM,WAAW,aAAa;IAC5B,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,0EAA0E;IAC1E,KAAK,CAAC,EAAE,OAAO,KAAK,GAAG,SAAS,CAAC;IACjC,4DAA4D;IAC5D,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC/B,0GAA0G;IAC1G,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,GAAG,SAAS,EACzB,OAAO,EAAE,aAAa,EACtB,UAAU,EAAE,MAAM,GACjB,SAAS,CAsBX"}
@@ -0,0 +1,34 @@
1
+ import { DEFAULT_MAX_RETRIES } from "./retry.js";
2
+ import { Transport } from "./transport.js";
3
+ import { SDK_VERSION } from "./version.js";
4
+ export const DEFAULT_BASE_URL = 'https://api.sendora.se';
5
+ const DEFAULT_TIMEOUT_MS = 30_000;
6
+ /**
7
+ * The transport a client's resources share, built once at construction so
8
+ * a missing key or a nonsense option fails at startup rather than at the
9
+ * first call.
10
+ */
11
+ export function transportFor(token, options, missingKey) {
12
+ if (token === undefined || token.trim() === '') {
13
+ throw new TypeError(missingKey);
14
+ }
15
+ const baseUrl = options.baseUrl ?? DEFAULT_BASE_URL;
16
+ new URL(baseUrl);
17
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
18
+ if (!(timeoutMs > 0)) {
19
+ throw new TypeError('timeoutMs must be a positive number of milliseconds.');
20
+ }
21
+ const maxRetries = options.maxRetries ?? DEFAULT_MAX_RETRIES;
22
+ if (!Number.isInteger(maxRetries) || maxRetries < 0) {
23
+ throw new TypeError('maxRetries must be a whole number of zero or more.');
24
+ }
25
+ return new Transport({
26
+ baseUrl,
27
+ token,
28
+ fetch: options.fetch ?? fetch,
29
+ timeoutMs,
30
+ maxRetries,
31
+ userAgent: `sendora-sdk/${SDK_VERSION}`,
32
+ });
33
+ }
34
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../src/options.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,MAAM,CAAC,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AACzD,MAAM,kBAAkB,GAAG,MAAM,CAAC;AAclC;;;;GAIG;AACH,MAAM,UAAU,YAAY,CAC1B,KAAyB,EACzB,OAAsB,EACtB,UAAkB;IAElB,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QAC/C,MAAM,IAAI,SAAS,CAAC,UAAU,CAAC,CAAC;IAClC,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC;IACpD,IAAI,GAAG,CAAC,OAAO,CAAC,CAAC;IACjB,MAAM,SAAS,GAAG,OAAO,CAAC,SAAS,IAAI,kBAAkB,CAAC;IAC1D,IAAI,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,SAAS,CAAC,sDAAsD,CAAC,CAAC;IAC9E,CAAC;IACD,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,mBAAmB,CAAC;IAC7D,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,UAAU,GAAG,CAAC,EAAE,CAAC;QACpD,MAAM,IAAI,SAAS,CAAC,oDAAoD,CAAC,CAAC;IAC5E,CAAC;IACD,OAAO,IAAI,SAAS,CAAC;QACnB,OAAO;QACP,KAAK;QACL,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,KAAK;QAC7B,SAAS;QACT,UAAU;QACV,SAAS,EAAE,eAAe,WAAW,EAAE;KACxC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,64 @@
1
+ import type { Transport } from './transport.ts';
2
+ import type { CreatedServer, CreatedToken, CreateServerRequest, CreateTokenRequest, RequestOptions, Server, ServerList, Token, TokenList, UpdateServerRequest } from './types.ts';
3
+ /**
4
+ * The keys of one server, managed with the account key. A server holds at
5
+ * most two live keys, so rotation is create, switch, revoke.
6
+ */
7
+ export declare class ServerTokensResource {
8
+ #private;
9
+ constructor(transport: Transport);
10
+ /**
11
+ * Creates another live key for the server and answers its value once; it
12
+ * is never shown again, so store it at once. A third live key is refused
13
+ * with `token_limit`.
14
+ *
15
+ * @example
16
+ * const { token } = await account.servers.tokens.create(serverId, { name: 'Fakturasystemet' });
17
+ */
18
+ create(serverId: string, request: CreateTokenRequest, options?: RequestOptions): Promise<CreatedToken>;
19
+ /** Every key of the server, revoked ones included. */
20
+ list(serverId: string, options?: RequestOptions): Promise<TokenList>;
21
+ /** One key by id; its value is never part of the answer. */
22
+ get(serverId: string, tokenId: string, options?: RequestOptions): Promise<Token>;
23
+ /**
24
+ * The key stops working at once. The last live key of a server cannot be
25
+ * revoked (`last_token`), so a server is never locked out.
26
+ *
27
+ * @example
28
+ * await account.servers.tokens.revoke(serverId, tokenId);
29
+ */
30
+ revoke(serverId: string, tokenId: string, options?: RequestOptions): Promise<void>;
31
+ }
32
+ /** The account's servers: each an isolation boundary with its own keys, streams, log, suppressions and webhooks. */
33
+ export declare class ServersResource {
34
+ #private;
35
+ /** The keys of each server. */
36
+ readonly tokens: ServerTokensResource;
37
+ constructor(transport: Transport);
38
+ /**
39
+ * Creates a server with its default transactional stream and its first
40
+ * key, whose value is answered this once. A taken name is
41
+ * `server_exists`; the account's cap is `server_limit` with `max`.
42
+ *
43
+ * @example
44
+ * const server = await account.servers.create({ name: 'Fakturering' });
45
+ * const sendora = new Sendora({ token: server.token.token });
46
+ */
47
+ create(request: CreateServerRequest, options?: RequestOptions): Promise<CreatedServer>;
48
+ /** Every server of the account, oldest first. */
49
+ list(options?: RequestOptions): Promise<ServerList>;
50
+ /** One server by id. */
51
+ get(serverId: string, options?: RequestOptions): Promise<Server>;
52
+ /** Renames the server; the id, the keys and everything it holds stay. A taken name is `server_exists`. */
53
+ update(serverId: string, request: UpdateServerRequest, options?: RequestOptions): Promise<Server>;
54
+ /**
55
+ * Removes the server with its keys, streams, messages, suppressions and
56
+ * webhooks. Refused with `server_in_flight` while its messages are still
57
+ * being delivered; try again once they have left.
58
+ *
59
+ * @example
60
+ * await account.servers.delete(serverId);
61
+ */
62
+ delete(serverId: string, options?: RequestOptions): Promise<void>;
63
+ }
64
+ //# sourceMappingURL=servers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"servers.d.ts","sourceRoot":"","sources":["../src/servers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,MAAM,EACN,UAAU,EACV,KAAK,EACL,SAAS,EACT,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAEpB;;;GAGG;AACH,qBAAa,oBAAoB;;gBAGnB,SAAS,EAAE,SAAS;IAIhC;;;;;;;OAOG;IACH,MAAM,CACJ,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,kBAAkB,EAC3B,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,YAAY,CAAC;IAUxB,sDAAsD;IACtD,IAAI,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,SAAS,CAAC;IASxE,4DAA4D;IAC5D,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,KAAK,CAAC;IASpF;;;;;;OAMG;IACH,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;CAQvF;AAED,oHAAoH;AACpH,qBAAa,eAAe;;IAE1B,+BAA+B;IAC/B,QAAQ,CAAC,MAAM,EAAE,oBAAoB,CAAC;gBAE1B,SAAS,EAAE,SAAS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