@inkbox/sdk 0.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.
- package/README.md +369 -0
- package/dist/_http.d.ts +24 -0
- package/dist/_http.d.ts.map +1 -0
- package/dist/_http.js +90 -0
- package/dist/_http.js.map +1 -0
- package/dist/agent_identity.d.ts +184 -0
- package/dist/agent_identity.d.ts.map +1 -0
- package/dist/agent_identity.js +262 -0
- package/dist/agent_identity.js.map +1 -0
- package/dist/identities/resources/identities.d.ts +80 -0
- package/dist/identities/resources/identities.d.ts.map +1 -0
- package/dist/identities/resources/identities.js +103 -0
- package/dist/identities/resources/identities.js.map +1 -0
- package/dist/identities/types.d.ts +77 -0
- package/dist/identities/types.d.ts.map +1 -0
- package/dist/identities/types.js +44 -0
- package/dist/identities/types.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/inkbox.d.ts +92 -0
- package/dist/inkbox.d.ts.map +1 -0
- package/dist/inkbox.js +117 -0
- package/dist/inkbox.js.map +1 -0
- package/dist/mail/resources/mailboxes.d.ts +61 -0
- package/dist/mail/resources/mailboxes.d.ts.map +1 -0
- package/dist/mail/resources/mailboxes.js +83 -0
- package/dist/mail/resources/mailboxes.js.map +1 -0
- package/dist/mail/resources/messages.d.ts +100 -0
- package/dist/mail/resources/messages.d.ts.map +1 -0
- package/dist/mail/resources/messages.js +141 -0
- package/dist/mail/resources/messages.js.map +1 -0
- package/dist/mail/resources/threads.d.ts +36 -0
- package/dist/mail/resources/threads.d.ts.map +1 -0
- package/dist/mail/resources/threads.js +53 -0
- package/dist/mail/resources/threads.js.map +1 -0
- package/dist/mail/types.d.ts +113 -0
- package/dist/mail/types.d.ts.map +1 -0
- package/dist/mail/types.js +65 -0
- package/dist/mail/types.js.map +1 -0
- package/dist/phone/resources/calls.d.ts +45 -0
- package/dist/phone/resources/calls.d.ts.map +1 -0
- package/dist/phone/resources/calls.js +57 -0
- package/dist/phone/resources/calls.js.map +1 -0
- package/dist/phone/resources/numbers.d.ts +61 -0
- package/dist/phone/resources/numbers.d.ts.map +1 -0
- package/dist/phone/resources/numbers.js +85 -0
- package/dist/phone/resources/numbers.js.map +1 -0
- package/dist/phone/resources/transcripts.d.ts +19 -0
- package/dist/phone/resources/transcripts.d.ts.map +1 -0
- package/dist/phone/resources/transcripts.js +23 -0
- package/dist/phone/resources/transcripts.js.map +1 -0
- package/dist/phone/types.d.ts +108 -0
- package/dist/phone/types.d.ts.map +1 -0
- package/dist/phone/types.js +62 -0
- package/dist/phone/types.js.map +1 -0
- package/dist/signing_keys.d.ts +40 -0
- package/dist/signing_keys.d.ts.map +1 -0
- package/dist/signing_keys.js +59 -0
- package/dist/signing_keys.js.map +1 -0
- package/package.json +42 -0
package/dist/inkbox.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox/src/inkbox.ts
|
|
3
|
+
*
|
|
4
|
+
* Inkbox — org-level entry point for all Inkbox APIs.
|
|
5
|
+
*/
|
|
6
|
+
import { MailboxesResource } from "./mail/resources/mailboxes.js";
|
|
7
|
+
import { MessagesResource } from "./mail/resources/messages.js";
|
|
8
|
+
import { ThreadsResource } from "./mail/resources/threads.js";
|
|
9
|
+
import { SigningKeysResource } from "./signing_keys.js";
|
|
10
|
+
import type { SigningKey } from "./signing_keys.js";
|
|
11
|
+
import { PhoneNumbersResource } from "./phone/resources/numbers.js";
|
|
12
|
+
import { CallsResource } from "./phone/resources/calls.js";
|
|
13
|
+
import { TranscriptsResource } from "./phone/resources/transcripts.js";
|
|
14
|
+
import { IdentitiesResource } from "./identities/resources/identities.js";
|
|
15
|
+
import { AgentIdentity } from "./agent_identity.js";
|
|
16
|
+
import type { AgentIdentitySummary } from "./identities/types.js";
|
|
17
|
+
export interface InkboxOptions {
|
|
18
|
+
/** Your Inkbox API key (sent as `X-Service-Token`). */
|
|
19
|
+
apiKey: string;
|
|
20
|
+
/** Override the API base URL (useful for self-hosting or testing). */
|
|
21
|
+
baseUrl?: string;
|
|
22
|
+
/** Request timeout in milliseconds. Defaults to 30 000. */
|
|
23
|
+
timeoutMs?: number;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Org-level entry point for all Inkbox APIs.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { Inkbox } from "@inkbox/sdk";
|
|
31
|
+
*
|
|
32
|
+
* const inkbox = new Inkbox({ apiKey: process.env.INKBOX_API_KEY! });
|
|
33
|
+
*
|
|
34
|
+
* // Create an agent identity
|
|
35
|
+
* const identity = await inkbox.createIdentity("support-bot");
|
|
36
|
+
*
|
|
37
|
+
* // Create and link new channels
|
|
38
|
+
* const mailbox = await identity.createMailbox({ displayName: "Support Bot" });
|
|
39
|
+
* const phone = await identity.provisionPhoneNumber({ type: "toll_free" });
|
|
40
|
+
*
|
|
41
|
+
* // Send email directly from the identity
|
|
42
|
+
* await identity.sendEmail({
|
|
43
|
+
* to: ["customer@example.com"],
|
|
44
|
+
* subject: "Your order has shipped",
|
|
45
|
+
* bodyText: "Tracking number: 1Z999AA10123456784",
|
|
46
|
+
* });
|
|
47
|
+
* ```
|
|
48
|
+
*/
|
|
49
|
+
export declare class Inkbox {
|
|
50
|
+
readonly _mailboxes: MailboxesResource;
|
|
51
|
+
readonly _messages: MessagesResource;
|
|
52
|
+
readonly _threads: ThreadsResource;
|
|
53
|
+
readonly _signingKeys: SigningKeysResource;
|
|
54
|
+
readonly _numbers: PhoneNumbersResource;
|
|
55
|
+
readonly _calls: CallsResource;
|
|
56
|
+
readonly _transcripts: TranscriptsResource;
|
|
57
|
+
readonly _idsResource: IdentitiesResource;
|
|
58
|
+
constructor(options: InkboxOptions);
|
|
59
|
+
/** Org-level mailbox operations (list, get, create, update, delete). */
|
|
60
|
+
get mailboxes(): MailboxesResource;
|
|
61
|
+
/** Org-level phone number operations (list, get, provision, release). */
|
|
62
|
+
get phoneNumbers(): PhoneNumbersResource;
|
|
63
|
+
/**
|
|
64
|
+
* Create a new agent identity.
|
|
65
|
+
*
|
|
66
|
+
* @param agentHandle - Unique handle for this identity (e.g. `"sales-bot"`).
|
|
67
|
+
* @returns The created {@link AgentIdentity}.
|
|
68
|
+
*/
|
|
69
|
+
createIdentity(agentHandle: string): Promise<AgentIdentity>;
|
|
70
|
+
/**
|
|
71
|
+
* Get an existing agent identity by handle.
|
|
72
|
+
*
|
|
73
|
+
* @param agentHandle - Handle of the identity to fetch.
|
|
74
|
+
* @returns The {@link AgentIdentity}.
|
|
75
|
+
*/
|
|
76
|
+
getIdentity(agentHandle: string): Promise<AgentIdentity>;
|
|
77
|
+
/**
|
|
78
|
+
* List all agent identities for your organisation.
|
|
79
|
+
*
|
|
80
|
+
* @returns Array of {@link AgentIdentitySummary}.
|
|
81
|
+
*/
|
|
82
|
+
listIdentities(): Promise<AgentIdentitySummary[]>;
|
|
83
|
+
/**
|
|
84
|
+
* Create or rotate the org-level webhook signing key.
|
|
85
|
+
*
|
|
86
|
+
* The plaintext key is returned once — save it immediately.
|
|
87
|
+
*
|
|
88
|
+
* @returns The new {@link SigningKey}.
|
|
89
|
+
*/
|
|
90
|
+
createSigningKey(): Promise<SigningKey>;
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=inkbox.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inkbox.d.ts","sourceRoot":"","sources":["../src/inkbox.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,UAAU,EAAE,MA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,aAAa,CAAC;IAI9D;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC,oBAAoB,EAAE,CAAC;IAIvD;;;;;;OAMG;IACG,gBAAgB,IAAI,OAAO,CAAC,UAAU,CAAC;CAG9C"}
|
package/dist/inkbox.js
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox/src/inkbox.ts
|
|
3
|
+
*
|
|
4
|
+
* Inkbox — org-level entry point for all Inkbox APIs.
|
|
5
|
+
*/
|
|
6
|
+
import { HttpTransport } from "./_http.js";
|
|
7
|
+
import { MailboxesResource } from "./mail/resources/mailboxes.js";
|
|
8
|
+
import { MessagesResource } from "./mail/resources/messages.js";
|
|
9
|
+
import { ThreadsResource } from "./mail/resources/threads.js";
|
|
10
|
+
import { SigningKeysResource } from "./signing_keys.js";
|
|
11
|
+
import { PhoneNumbersResource } from "./phone/resources/numbers.js";
|
|
12
|
+
import { CallsResource } from "./phone/resources/calls.js";
|
|
13
|
+
import { TranscriptsResource } from "./phone/resources/transcripts.js";
|
|
14
|
+
import { IdentitiesResource } from "./identities/resources/identities.js";
|
|
15
|
+
import { AgentIdentity } from "./agent_identity.js";
|
|
16
|
+
const DEFAULT_BASE_URL = "https://api.inkbox.ai";
|
|
17
|
+
/**
|
|
18
|
+
* Org-level entry point for all Inkbox APIs.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { Inkbox } from "@inkbox/sdk";
|
|
23
|
+
*
|
|
24
|
+
* const inkbox = new Inkbox({ apiKey: process.env.INKBOX_API_KEY! });
|
|
25
|
+
*
|
|
26
|
+
* // Create an agent identity
|
|
27
|
+
* const identity = await inkbox.createIdentity("support-bot");
|
|
28
|
+
*
|
|
29
|
+
* // Create and link new channels
|
|
30
|
+
* const mailbox = await identity.createMailbox({ displayName: "Support Bot" });
|
|
31
|
+
* const phone = await identity.provisionPhoneNumber({ type: "toll_free" });
|
|
32
|
+
*
|
|
33
|
+
* // Send email directly from the identity
|
|
34
|
+
* await identity.sendEmail({
|
|
35
|
+
* to: ["customer@example.com"],
|
|
36
|
+
* subject: "Your order has shipped",
|
|
37
|
+
* bodyText: "Tracking number: 1Z999AA10123456784",
|
|
38
|
+
* });
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export class Inkbox {
|
|
42
|
+
_mailboxes;
|
|
43
|
+
_messages;
|
|
44
|
+
_threads;
|
|
45
|
+
_signingKeys;
|
|
46
|
+
_numbers;
|
|
47
|
+
_calls;
|
|
48
|
+
_transcripts;
|
|
49
|
+
_idsResource;
|
|
50
|
+
constructor(options) {
|
|
51
|
+
const apiRoot = `${(options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, "")}/api/v1`;
|
|
52
|
+
const ms = options.timeoutMs ?? 30_000;
|
|
53
|
+
const mailHttp = new HttpTransport(options.apiKey, `${apiRoot}/mail`, ms);
|
|
54
|
+
const phoneHttp = new HttpTransport(options.apiKey, `${apiRoot}/phone`, ms);
|
|
55
|
+
const idsHttp = new HttpTransport(options.apiKey, `${apiRoot}/identities`, ms);
|
|
56
|
+
const apiHttp = new HttpTransport(options.apiKey, apiRoot, ms);
|
|
57
|
+
this._mailboxes = new MailboxesResource(mailHttp);
|
|
58
|
+
this._messages = new MessagesResource(mailHttp);
|
|
59
|
+
this._threads = new ThreadsResource(mailHttp);
|
|
60
|
+
this._signingKeys = new SigningKeysResource(apiHttp);
|
|
61
|
+
this._numbers = new PhoneNumbersResource(phoneHttp);
|
|
62
|
+
this._calls = new CallsResource(phoneHttp);
|
|
63
|
+
this._transcripts = new TranscriptsResource(phoneHttp);
|
|
64
|
+
this._idsResource = new IdentitiesResource(idsHttp);
|
|
65
|
+
}
|
|
66
|
+
// ------------------------------------------------------------------
|
|
67
|
+
// Public resource accessors
|
|
68
|
+
// ------------------------------------------------------------------
|
|
69
|
+
/** Org-level mailbox operations (list, get, create, update, delete). */
|
|
70
|
+
get mailboxes() { return this._mailboxes; }
|
|
71
|
+
/** Org-level phone number operations (list, get, provision, release). */
|
|
72
|
+
get phoneNumbers() { return this._numbers; }
|
|
73
|
+
// ------------------------------------------------------------------
|
|
74
|
+
// Org-level operations
|
|
75
|
+
// ------------------------------------------------------------------
|
|
76
|
+
/**
|
|
77
|
+
* Create a new agent identity.
|
|
78
|
+
*
|
|
79
|
+
* @param agentHandle - Unique handle for this identity (e.g. `"sales-bot"`).
|
|
80
|
+
* @returns The created {@link AgentIdentity}.
|
|
81
|
+
*/
|
|
82
|
+
async createIdentity(agentHandle) {
|
|
83
|
+
await this._idsResource.create({ agentHandle });
|
|
84
|
+
// POST /identities returns summary (no channel fields); fetch detail so
|
|
85
|
+
// AgentIdentity has a fully-populated _AgentIdentityData.
|
|
86
|
+
const data = await this._idsResource.get(agentHandle);
|
|
87
|
+
return new AgentIdentity(data, this);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Get an existing agent identity by handle.
|
|
91
|
+
*
|
|
92
|
+
* @param agentHandle - Handle of the identity to fetch.
|
|
93
|
+
* @returns The {@link AgentIdentity}.
|
|
94
|
+
*/
|
|
95
|
+
async getIdentity(agentHandle) {
|
|
96
|
+
return new AgentIdentity(await this._idsResource.get(agentHandle), this);
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* List all agent identities for your organisation.
|
|
100
|
+
*
|
|
101
|
+
* @returns Array of {@link AgentIdentitySummary}.
|
|
102
|
+
*/
|
|
103
|
+
async listIdentities() {
|
|
104
|
+
return this._idsResource.list();
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Create or rotate the org-level webhook signing key.
|
|
108
|
+
*
|
|
109
|
+
* The plaintext key is returned once — save it immediately.
|
|
110
|
+
*
|
|
111
|
+
* @returns The new {@link SigningKey}.
|
|
112
|
+
*/
|
|
113
|
+
async createSigningKey() {
|
|
114
|
+
return this._signingKeys.createOrRotate();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
//# sourceMappingURL=ink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C,EAAE,WAAW,EAAE,CAAC,CAAC;QAChD,wEAAwE;QACxE,0DAA0D;QAC1D,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QACtD,OAAO,IAAI,aAAa,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,WAAW,CAAC,WAAmB;QACnC,OAAO,IAAI,aAAa,CAAC,MAAM,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,IAAI,CAAC,CAAC;IAC3E,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,cAAc;QAClB,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;IAClC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,gBAAgB;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC,cAAc,EAAE,CAAC;IAC5C,CAAC;CACF"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-mail/resources/mailboxes.ts
|
|
3
|
+
*
|
|
4
|
+
* Mailbox CRUD and full-text search.
|
|
5
|
+
*/
|
|
6
|
+
import { HttpTransport } from "../../_http.js";
|
|
7
|
+
import { Mailbox, Message } from "../types.js";
|
|
8
|
+
export declare class MailboxesResource {
|
|
9
|
+
private readonly http;
|
|
10
|
+
constructor(http: HttpTransport);
|
|
11
|
+
/**
|
|
12
|
+
* Create a new mailbox.
|
|
13
|
+
*
|
|
14
|
+
* The email address is automatically generated by the server.
|
|
15
|
+
*
|
|
16
|
+
* @param options.displayName - Optional human-readable name shown as the sender.
|
|
17
|
+
*/
|
|
18
|
+
create(options?: {
|
|
19
|
+
displayName?: string;
|
|
20
|
+
}): Promise<Mailbox>;
|
|
21
|
+
/** List all mailboxes for your organisation. */
|
|
22
|
+
list(): Promise<Mailbox[]>;
|
|
23
|
+
/**
|
|
24
|
+
* Get a mailbox by its email address.
|
|
25
|
+
*
|
|
26
|
+
* @param emailAddress - Full email address of the mailbox (e.g. `"abc-xyz@inkboxmail.com"`).
|
|
27
|
+
*/
|
|
28
|
+
get(emailAddress: string): Promise<Mailbox>;
|
|
29
|
+
/**
|
|
30
|
+
* Update mutable mailbox fields.
|
|
31
|
+
*
|
|
32
|
+
* Only provided fields are applied; omitted fields are left unchanged.
|
|
33
|
+
* Pass `webhookUrl: null` to unsubscribe from webhooks.
|
|
34
|
+
*
|
|
35
|
+
* @param emailAddress - Full email address of the mailbox to update.
|
|
36
|
+
* @param options.displayName - New human-readable sender name.
|
|
37
|
+
* @param options.webhookUrl - HTTPS URL to receive webhook events, or `null` to unsubscribe.
|
|
38
|
+
*/
|
|
39
|
+
update(emailAddress: string, options: {
|
|
40
|
+
displayName?: string;
|
|
41
|
+
webhookUrl?: string | null;
|
|
42
|
+
}): Promise<Mailbox>;
|
|
43
|
+
/**
|
|
44
|
+
* Delete a mailbox.
|
|
45
|
+
*
|
|
46
|
+
* @param emailAddress - Full email address of the mailbox to delete.
|
|
47
|
+
*/
|
|
48
|
+
delete(emailAddress: string): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Full-text search across messages in a mailbox.
|
|
51
|
+
*
|
|
52
|
+
* @param emailAddress - Full email address of the mailbox to search.
|
|
53
|
+
* @param options.q - Search query string.
|
|
54
|
+
* @param options.limit - Maximum number of results (1–100). Defaults to 50.
|
|
55
|
+
*/
|
|
56
|
+
search(emailAddress: string, options: {
|
|
57
|
+
q: string;
|
|
58
|
+
limit?: number;
|
|
59
|
+
}): Promise<Message[]>;
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=mailboxes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailboxes.d.ts","sourceRoot":"","sources":["../../../src/mail/resources/mailboxes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,OAAO,EACP,OAAO,EAMR,MAAM,aAAa,CAAC;AAIrB,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEhD;;;;;;OAMG;IACG,MAAM,CAAC,OAAO,GAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAStE,gDAAgD;IAC1C,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAKhC;;;;OAIG;IACG,GAAG,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAKjD;;;;;;;;;OASG;IACG,MAAM,CACV,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE;QAAE,WAAW,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAC5D,OAAO,CAAC,OAAO,CAAC;IAYnB;;;;OAIG;IACG,MAAM,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjD;;;;;;OAMG;IACG,MAAM,CACV,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GACrC,OAAO,CAAC,OAAO,EAAE,CAAC;CAOtB"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-mail/resources/mailboxes.ts
|
|
3
|
+
*
|
|
4
|
+
* Mailbox CRUD and full-text search.
|
|
5
|
+
*/
|
|
6
|
+
import { parseMailbox, parseMessage, } from "../types.js";
|
|
7
|
+
const BASE = "/mailboxes";
|
|
8
|
+
export class MailboxesResource {
|
|
9
|
+
http;
|
|
10
|
+
constructor(http) {
|
|
11
|
+
this.http = http;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Create a new mailbox.
|
|
15
|
+
*
|
|
16
|
+
* The email address is automatically generated by the server.
|
|
17
|
+
*
|
|
18
|
+
* @param options.displayName - Optional human-readable name shown as the sender.
|
|
19
|
+
*/
|
|
20
|
+
async create(options = {}) {
|
|
21
|
+
const body = {};
|
|
22
|
+
if (options.displayName !== undefined) {
|
|
23
|
+
body["display_name"] = options.displayName;
|
|
24
|
+
}
|
|
25
|
+
const data = await this.http.post(BASE, body);
|
|
26
|
+
return parseMailbox(data);
|
|
27
|
+
}
|
|
28
|
+
/** List all mailboxes for your organisation. */
|
|
29
|
+
async list() {
|
|
30
|
+
const data = await this.http.get(BASE);
|
|
31
|
+
return data.map(parseMailbox);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Get a mailbox by its email address.
|
|
35
|
+
*
|
|
36
|
+
* @param emailAddress - Full email address of the mailbox (e.g. `"abc-xyz@inkboxmail.com"`).
|
|
37
|
+
*/
|
|
38
|
+
async get(emailAddress) {
|
|
39
|
+
const data = await this.http.get(`${BASE}/${emailAddress}`);
|
|
40
|
+
return parseMailbox(data);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Update mutable mailbox fields.
|
|
44
|
+
*
|
|
45
|
+
* Only provided fields are applied; omitted fields are left unchanged.
|
|
46
|
+
* Pass `webhookUrl: null` to unsubscribe from webhooks.
|
|
47
|
+
*
|
|
48
|
+
* @param emailAddress - Full email address of the mailbox to update.
|
|
49
|
+
* @param options.displayName - New human-readable sender name.
|
|
50
|
+
* @param options.webhookUrl - HTTPS URL to receive webhook events, or `null` to unsubscribe.
|
|
51
|
+
*/
|
|
52
|
+
async update(emailAddress, options) {
|
|
53
|
+
const body = {};
|
|
54
|
+
if (options.displayName !== undefined) {
|
|
55
|
+
body["display_name"] = options.displayName;
|
|
56
|
+
}
|
|
57
|
+
if ("webhookUrl" in options) {
|
|
58
|
+
body["webhook_url"] = options.webhookUrl;
|
|
59
|
+
}
|
|
60
|
+
const data = await this.http.patch(`${BASE}/${emailAddress}`, body);
|
|
61
|
+
return parseMailbox(data);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Delete a mailbox.
|
|
65
|
+
*
|
|
66
|
+
* @param emailAddress - Full email address of the mailbox to delete.
|
|
67
|
+
*/
|
|
68
|
+
async delete(emailAddress) {
|
|
69
|
+
await this.http.delete(`${BASE}/${emailAddress}`);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Full-text search across messages in a mailbox.
|
|
73
|
+
*
|
|
74
|
+
* @param emailAddress - Full email address of the mailbox to search.
|
|
75
|
+
* @param options.q - Search query string.
|
|
76
|
+
* @param options.limit - Maximum number of results (1–100). Defaults to 50.
|
|
77
|
+
*/
|
|
78
|
+
async search(emailAddress, options) {
|
|
79
|
+
const data = await this.http.get(`${BASE}/${emailAddress}/search`, { q: options.q, limit: options.limit ?? 50 });
|
|
80
|
+
return data.items.map(parseMessage);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
//# sourceMappingURL=mailboxes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mailboxes.js","sourceRoot":"","sources":["../../../src/mail/resources/mailboxes.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAML,YAAY,EACZ,YAAY,GACb,MAAM,aAAa,CAAC;AAErB,MAAM,IAAI,GAAG,YAAY,CAAC;AAE1B,MAAM,OAAO,iBAAiB;IACC;IAA7B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAC,UAAoC,EAAE;QACjD,MAAM,IAAI,GAA4B,EAAE,CAAC;QACzC,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACtC,IAAI,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,WAAW,CAAC;QAC7C,CAAC;QACD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,IAAI,CA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C;QAEtC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAC9B,GAAG,IAAI,IAAI,YAAY,SAAS,EAChC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,IAAI,EAAE,EAAE,CAC7C,CAAC;QACF,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC;CACF"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-mail/resources/messages.ts
|
|
3
|
+
*
|
|
4
|
+
* Message operations: list (auto-paginated), get, send, flag updates, delete.
|
|
5
|
+
*/
|
|
6
|
+
import { HttpTransport } from "../../_http.js";
|
|
7
|
+
import { Message, MessageDetail } from "../types.js";
|
|
8
|
+
export declare class MessagesResource {
|
|
9
|
+
private readonly http;
|
|
10
|
+
constructor(http: HttpTransport);
|
|
11
|
+
/**
|
|
12
|
+
* Async iterator over all messages in a mailbox, newest first.
|
|
13
|
+
*
|
|
14
|
+
* Pagination is handled automatically — just iterate.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* for await (const msg of client.messages.list(emailAddress)) {
|
|
19
|
+
* console.log(msg.subject, msg.fromAddress);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
list(emailAddress: string, options?: {
|
|
24
|
+
pageSize?: number;
|
|
25
|
+
direction?: "inbound" | "outbound";
|
|
26
|
+
}): AsyncGenerator<Message>;
|
|
27
|
+
/**
|
|
28
|
+
* Get a message with full body content.
|
|
29
|
+
*
|
|
30
|
+
* @param emailAddress - Full email address of the owning mailbox.
|
|
31
|
+
* @param messageId - UUID of the message.
|
|
32
|
+
*/
|
|
33
|
+
get(emailAddress: string, messageId: string): Promise<MessageDetail>;
|
|
34
|
+
/**
|
|
35
|
+
* Send an email from a mailbox.
|
|
36
|
+
*
|
|
37
|
+
* @param emailAddress - Full email address of the sending mailbox.
|
|
38
|
+
* @param options.to - Primary recipient addresses (at least one required).
|
|
39
|
+
* @param options.subject - Email subject line.
|
|
40
|
+
* @param options.bodyText - Plain-text body.
|
|
41
|
+
* @param options.bodyHtml - HTML body.
|
|
42
|
+
* @param options.cc - Carbon-copy recipients.
|
|
43
|
+
* @param options.bcc - Blind carbon-copy recipients.
|
|
44
|
+
* @param options.inReplyToMessageId - RFC 5322 Message-ID of the message being
|
|
45
|
+
* replied to. Threads the reply automatically.
|
|
46
|
+
* @param options.attachments - Optional file attachments. Each entry must have
|
|
47
|
+
* `filename`, `contentType` (MIME type), and `contentBase64` (base64-encoded
|
|
48
|
+
* file content). Max total size: 25 MB. Blocked: `.exe`, `.bat`, `.scr`.
|
|
49
|
+
*/
|
|
50
|
+
send(emailAddress: string, options: {
|
|
51
|
+
to: string[];
|
|
52
|
+
subject: string;
|
|
53
|
+
bodyText?: string;
|
|
54
|
+
bodyHtml?: string;
|
|
55
|
+
cc?: string[];
|
|
56
|
+
bcc?: string[];
|
|
57
|
+
inReplyToMessageId?: string;
|
|
58
|
+
attachments?: Array<{
|
|
59
|
+
filename: string;
|
|
60
|
+
contentType: string;
|
|
61
|
+
contentBase64: string;
|
|
62
|
+
}>;
|
|
63
|
+
}): Promise<Message>;
|
|
64
|
+
/**
|
|
65
|
+
* Update read/starred flags on a message.
|
|
66
|
+
*
|
|
67
|
+
* Pass only the flags you want to change; omitted flags are left as-is.
|
|
68
|
+
*/
|
|
69
|
+
updateFlags(emailAddress: string, messageId: string, flags: {
|
|
70
|
+
isRead?: boolean;
|
|
71
|
+
isStarred?: boolean;
|
|
72
|
+
}): Promise<Message>;
|
|
73
|
+
/** Mark a message as read. */
|
|
74
|
+
markRead(emailAddress: string, messageId: string): Promise<Message>;
|
|
75
|
+
/** Mark a message as unread. */
|
|
76
|
+
markUnread(emailAddress: string, messageId: string): Promise<Message>;
|
|
77
|
+
/** Star a message. */
|
|
78
|
+
star(emailAddress: string, messageId: string): Promise<Message>;
|
|
79
|
+
/** Unstar a message. */
|
|
80
|
+
unstar(emailAddress: string, messageId: string): Promise<Message>;
|
|
81
|
+
/** Delete a message. */
|
|
82
|
+
delete(emailAddress: string, messageId: string): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Get a presigned URL for a message attachment.
|
|
85
|
+
*
|
|
86
|
+
* @param emailAddress - Full email address of the owning mailbox.
|
|
87
|
+
* @param messageId - UUID of the message.
|
|
88
|
+
* @param filename - Attachment filename.
|
|
89
|
+
* @param options.redirect - If `true`, follows the redirect. If `false` (default),
|
|
90
|
+
* returns `{ url, filename, expiresIn }`.
|
|
91
|
+
*/
|
|
92
|
+
getAttachment(emailAddress: string, messageId: string, filename: string, options?: {
|
|
93
|
+
redirect?: boolean;
|
|
94
|
+
}): Promise<{
|
|
95
|
+
url: string;
|
|
96
|
+
filename: string;
|
|
97
|
+
expiresIn: number;
|
|
98
|
+
}>;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/mail/resources/messages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EACL,OAAO,EACP,aAAa,EAKd,MAAM,aAAa,CAAC;AAIrB,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,aAAa;IAEhD;;;;;;;;;;;OAWG;IACI,IAAI,CACT,YAAY,EAAE,MAAM,EACpB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,SAAS,GAAG,UAAU,CAAA;KAAE,GAClE,cAAc,CAAC,OAAO,CAAC;IAmB1B;;;;;OAKG;IACG,GAAG,CAAC,YAAY,EAAE,MAAM,EAAE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C,YAAY,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE;;;;;;;;OAQG;IACG,aAAa,CACjB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,OAAO,CAAA;KAAE,GAC/B,OAAO,CAAC;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE,CAAC;CAMjE"}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-mail/resources/messages.ts
|
|
3
|
+
*
|
|
4
|
+
* Message operations: list (auto-paginated), get, send, flag updates, delete.
|
|
5
|
+
*/
|
|
6
|
+
import { parseMessage, parseMessageDetail, } from "../types.js";
|
|
7
|
+
const DEFAULT_PAGE_SIZE = 50;
|
|
8
|
+
export class MessagesResource {
|
|
9
|
+
http;
|
|
10
|
+
constructor(http) {
|
|
11
|
+
this.http = http;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Async iterator over all messages in a mailbox, newest first.
|
|
15
|
+
*
|
|
16
|
+
* Pagination is handled automatically — just iterate.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* for await (const msg of client.messages.list(emailAddress)) {
|
|
21
|
+
* console.log(msg.subject, msg.fromAddress);
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
async *list(emailAddress, options) {
|
|
26
|
+
const limit = options?.pageSize ?? DEFAULT_PAGE_SIZE;
|
|
27
|
+
let cursor;
|
|
28
|
+
while (true) {
|
|
29
|
+
const params = { limit, cursor };
|
|
30
|
+
if (options?.direction !== undefined)
|
|
31
|
+
params["direction"] = options.direction;
|
|
32
|
+
const page = await this.http.get(`/mailboxes/${emailAddress}/messages`, params);
|
|
33
|
+
for (const item of page.items) {
|
|
34
|
+
yield parseMessage(item);
|
|
35
|
+
}
|
|
36
|
+
if (!page.has_more)
|
|
37
|
+
break;
|
|
38
|
+
cursor = page.next_cursor ?? undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Get a message with full body content.
|
|
43
|
+
*
|
|
44
|
+
* @param emailAddress - Full email address of the owning mailbox.
|
|
45
|
+
* @param messageId - UUID of the message.
|
|
46
|
+
*/
|
|
47
|
+
async get(emailAddress, messageId) {
|
|
48
|
+
const data = await this.http.get(`/mailboxes/${emailAddress}/messages/${messageId}`);
|
|
49
|
+
return parseMessageDetail(data);
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Send an email from a mailbox.
|
|
53
|
+
*
|
|
54
|
+
* @param emailAddress - Full email address of the sending mailbox.
|
|
55
|
+
* @param options.to - Primary recipient addresses (at least one required).
|
|
56
|
+
* @param options.subject - Email subject line.
|
|
57
|
+
* @param options.bodyText - Plain-text body.
|
|
58
|
+
* @param options.bodyHtml - HTML body.
|
|
59
|
+
* @param options.cc - Carbon-copy recipients.
|
|
60
|
+
* @param options.bcc - Blind carbon-copy recipients.
|
|
61
|
+
* @param options.inReplyToMessageId - RFC 5322 Message-ID of the message being
|
|
62
|
+
* replied to. Threads the reply automatically.
|
|
63
|
+
* @param options.attachments - Optional file attachments. Each entry must have
|
|
64
|
+
* `filename`, `contentType` (MIME type), and `contentBase64` (base64-encoded
|
|
65
|
+
* file content). Max total size: 25 MB. Blocked: `.exe`, `.bat`, `.scr`.
|
|
66
|
+
*/
|
|
67
|
+
async send(emailAddress, options) {
|
|
68
|
+
const recipients = { to: options.to };
|
|
69
|
+
if (options.cc)
|
|
70
|
+
recipients["cc"] = options.cc;
|
|
71
|
+
if (options.bcc)
|
|
72
|
+
recipients["bcc"] = options.bcc;
|
|
73
|
+
const body = {
|
|
74
|
+
recipients,
|
|
75
|
+
subject: options.subject,
|
|
76
|
+
};
|
|
77
|
+
if (options.bodyText !== undefined)
|
|
78
|
+
body["body_text"] = options.bodyText;
|
|
79
|
+
if (options.bodyHtml !== undefined)
|
|
80
|
+
body["body_html"] = options.bodyHtml;
|
|
81
|
+
if (options.inReplyToMessageId !== undefined) {
|
|
82
|
+
body["in_reply_to_message_id"] = options.inReplyToMessageId;
|
|
83
|
+
}
|
|
84
|
+
if (options.attachments !== undefined) {
|
|
85
|
+
body["attachments"] = options.attachments.map((a) => ({
|
|
86
|
+
filename: a.filename,
|
|
87
|
+
content_type: a.contentType,
|
|
88
|
+
content_base64: a.contentBase64,
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
const data = await this.http.post(`/mailboxes/${emailAddress}/messages`, body);
|
|
92
|
+
return parseMessage(data);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Update read/starred flags on a message.
|
|
96
|
+
*
|
|
97
|
+
* Pass only the flags you want to change; omitted flags are left as-is.
|
|
98
|
+
*/
|
|
99
|
+
async updateFlags(emailAddress, messageId, flags) {
|
|
100
|
+
const body = {};
|
|
101
|
+
if (flags.isRead !== undefined)
|
|
102
|
+
body["is_read"] = flags.isRead;
|
|
103
|
+
if (flags.isStarred !== undefined)
|
|
104
|
+
body["is_starred"] = flags.isStarred;
|
|
105
|
+
const data = await this.http.patch(`/mailboxes/${emailAddress}/messages/${messageId}`, body);
|
|
106
|
+
return parseMessage(data);
|
|
107
|
+
}
|
|
108
|
+
/** Mark a message as read. */
|
|
109
|
+
async markRead(emailAddress, messageId) {
|
|
110
|
+
return this.updateFlags(emailAddress, messageId, { isRead: true });
|
|
111
|
+
}
|
|
112
|
+
/** Mark a message as unread. */
|
|
113
|
+
async markUnread(emailAddress, messageId) {
|
|
114
|
+
return this.updateFlags(emailAddress, messageId, { isRead: false });
|
|
115
|
+
}
|
|
116
|
+
/** Star a message. */
|
|
117
|
+
async star(emailAddress, messageId) {
|
|
118
|
+
return this.updateFlags(emailAddress, messageId, { isStarred: true });
|
|
119
|
+
}
|
|
120
|
+
/** Unstar a message. */
|
|
121
|
+
async unstar(emailAddress, messageId) {
|
|
122
|
+
return this.updateFlags(emailAddress, messageId, { isStarred: false });
|
|
123
|
+
}
|
|
124
|
+
/** Delete a message. */
|
|
125
|
+
async delete(emailAddress, messageId) {
|
|
126
|
+
await this.http.delete(`/mailboxes/${emailAddress}/messages/${messageId}`);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Get a presigned URL for a message attachment.
|
|
130
|
+
*
|
|
131
|
+
* @param emailAddress - Full email address of the owning mailbox.
|
|
132
|
+
* @param messageId - UUID of the message.
|
|
133
|
+
* @param filename - Attachment filename.
|
|
134
|
+
* @param options.redirect - If `true`, follows the redirect. If `false` (default),
|
|
135
|
+
* returns `{ url, filename, expiresIn }`.
|
|
136
|
+
*/
|
|
137
|
+
async getAttachment(emailAddress, messageId, filename, options) {
|
|
138
|
+
return this.http.get(`/mailboxes/${emailAddress}/messages/${messageId}/attachments/${filename}`, { redirect: options?.redirect ? "true" : "false" });
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.js","sourceRoot":"","sources":["../../../src/mail/resources/messages.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EAKL,YAAY,EACZ,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,MAAM,iBAAiB,GAAG,EAAE,CAAC;AAE7B,MAAM,OAAO,gBAAgB;IACE;IAA7B,YAA6B,IAAmB;QAAnB,SAAI,GAAJ,IAAI,CAAe;IAAG,CAAC;IAEpD;;;;;;;;;;;OAWG;IACH,KAAK,CAAC,CAAC,IAAI,CACT,YAAoB,EACpB,OAAmE;QAEnE,MAAM,KAAK,GAAG,OAAO,EAAE,QAAQ,IAAI,iBAAiB,CAAC;QACrD,IAAI,MAA0B,CAAC;QAE/B,OAAO,IAAI,EAAE,CA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 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* inkbox-mail/resources/threads.ts
|
|
3
|
+
*
|
|
4
|
+
* Thread operations: list (auto-paginated), get with messages, delete.
|
|
5
|
+
*/
|
|
6
|
+
import { HttpTransport } from "../../_http.js";
|
|
7
|
+
import { Thread, ThreadDetail } from "../types.js";
|
|
8
|
+
export declare class ThreadsResource {
|
|
9
|
+
private readonly http;
|
|
10
|
+
constructor(http: HttpTransport);
|
|
11
|
+
/**
|
|
12
|
+
* Async iterator over all threads in a mailbox, most recent activity first.
|
|
13
|
+
*
|
|
14
|
+
* Pagination is handled automatically — just iterate.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* for await (const thread of client.threads.list(emailAddress)) {
|
|
19
|
+
* console.log(thread.subject, thread.messageCount);
|
|
20
|
+
* }
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
list(emailAddress: string, options?: {
|
|
24
|
+
pageSize?: number;
|
|
25
|
+
}): AsyncGenerator<Thread>;
|
|
26
|
+
/**
|
|
27
|
+
* Get a thread with all its messages inlined.
|
|
28
|
+
*
|
|
29
|
+
* @param emailAddress - Full email address of the owning mailbox.
|
|
30
|
+
* @param threadId - UUID of the thread.
|
|
31
|
+
*/
|
|
32
|
+
get(emailAddress: string, threadId: string): Promise<ThreadDetail>;
|
|
33
|
+
/** Delete a thread. */
|
|
34
|
+
delete(emailAddress: string, threadId: string): Promise<void>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=threads.d.ts.map
|