@quaillogistics/inbox 0.2.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/dist/client.d.ts +69 -0
  2. package/dist/client.d.ts.map +1 -0
  3. package/dist/client.js +68 -0
  4. package/dist/client.js.map +1 -0
  5. package/dist/error.d.ts +8 -0
  6. package/dist/error.d.ts.map +1 -0
  7. package/dist/error.js +26 -0
  8. package/dist/error.js.map +1 -0
  9. package/dist/http.d.ts +32 -0
  10. package/dist/http.d.ts.map +1 -0
  11. package/dist/http.js +105 -0
  12. package/dist/http.js.map +1 -0
  13. package/dist/index.d.ts +12 -0
  14. package/dist/index.d.ts.map +1 -0
  15. package/dist/index.js +9 -0
  16. package/dist/index.js.map +1 -0
  17. package/dist/query-keys.d.ts +56 -0
  18. package/dist/query-keys.d.ts.map +1 -0
  19. package/dist/query-keys.js +55 -0
  20. package/dist/query-keys.js.map +1 -0
  21. package/dist/resources/accounts.d.ts +41 -0
  22. package/dist/resources/accounts.d.ts.map +1 -0
  23. package/dist/resources/accounts.js +38 -0
  24. package/dist/resources/accounts.js.map +1 -0
  25. package/dist/resources/api-keys.d.ts +22 -0
  26. package/dist/resources/api-keys.d.ts.map +1 -0
  27. package/dist/resources/api-keys.js +24 -0
  28. package/dist/resources/api-keys.js.map +1 -0
  29. package/dist/resources/attachments.d.ts +18 -0
  30. package/dist/resources/attachments.d.ts.map +1 -0
  31. package/dist/resources/attachments.js +26 -0
  32. package/dist/resources/attachments.js.map +1 -0
  33. package/dist/resources/auth.d.ts +36 -0
  34. package/dist/resources/auth.d.ts.map +1 -0
  35. package/dist/resources/auth.js +29 -0
  36. package/dist/resources/auth.js.map +1 -0
  37. package/dist/resources/contacts.d.ts +14 -0
  38. package/dist/resources/contacts.d.ts.map +1 -0
  39. package/dist/resources/contacts.js +15 -0
  40. package/dist/resources/contacts.js.map +1 -0
  41. package/dist/resources/conversations.d.ts +65 -0
  42. package/dist/resources/conversations.d.ts.map +1 -0
  43. package/dist/resources/conversations.js +75 -0
  44. package/dist/resources/conversations.js.map +1 -0
  45. package/dist/resources/messages.d.ts +38 -0
  46. package/dist/resources/messages.d.ts.map +1 -0
  47. package/dist/resources/messages.js +30 -0
  48. package/dist/resources/messages.js.map +1 -0
  49. package/dist/resources/pipeline.d.ts +19 -0
  50. package/dist/resources/pipeline.d.ts.map +1 -0
  51. package/dist/resources/pipeline.js +21 -0
  52. package/dist/resources/pipeline.js.map +1 -0
  53. package/dist/resources/webhooks.d.ts +50 -0
  54. package/dist/resources/webhooks.d.ts.map +1 -0
  55. package/dist/resources/webhooks.js +40 -0
  56. package/dist/resources/webhooks.js.map +1 -0
  57. package/dist/types.d.ts +234 -0
  58. package/dist/types.d.ts.map +1 -0
  59. package/dist/types.js +3 -0
  60. package/dist/types.js.map +1 -0
  61. package/dist/webhooks/types.d.ts +111 -0
  62. package/dist/webhooks/types.d.ts.map +1 -0
  63. package/dist/webhooks/types.js +2 -0
  64. package/dist/webhooks/types.js.map +1 -0
  65. package/dist/webhooks/verify.d.ts +29 -0
  66. package/dist/webhooks/verify.d.ts.map +1 -0
  67. package/dist/webhooks/verify.js +48 -0
  68. package/dist/webhooks/verify.js.map +1 -0
  69. package/package.json +38 -0
@@ -0,0 +1,69 @@
1
+ import type { HealthStatus } from "./types.js";
2
+ import { AccountsResource } from "./resources/accounts.js";
3
+ import { ApiKeysResource } from "./resources/api-keys.js";
4
+ import { AttachmentsResource } from "./resources/attachments.js";
5
+ import { AuthResource } from "./resources/auth.js";
6
+ import { ContactsResource } from "./resources/contacts.js";
7
+ import { ConversationsResource } from "./resources/conversations.js";
8
+ import { MessagesResource } from "./resources/messages.js";
9
+ import { PipelineResource } from "./resources/pipeline.js";
10
+ import { WebhooksResource } from "./resources/webhooks.js";
11
+ export interface InboxClientConfig {
12
+ /** Base URL of the Inbox API (e.g. "https://inbox.example.com"). */
13
+ baseUrl: string;
14
+ /**
15
+ * API key for authentication (`ll_sk_...`).
16
+ * Can be omitted and set later via `setApiKey()` (e.g. after login).
17
+ */
18
+ apiKey?: string;
19
+ /**
20
+ * Custom fetch implementation. Defaults to `globalThis.fetch`.
21
+ * Useful for testing or environments without a native fetch.
22
+ */
23
+ fetch?: typeof globalThis.fetch;
24
+ /** Extra headers to include on every request. */
25
+ headers?: Record<string, string>;
26
+ }
27
+ /**
28
+ * Typed HTTP client for the Inbox API.
29
+ *
30
+ * @example
31
+ * import { InboxClient } from "@quaillogistics/inbox";
32
+ *
33
+ * const inbox = new InboxClient({
34
+ * baseUrl: "https://inbox.example.com",
35
+ * apiKey: "ll_sk_...",
36
+ * });
37
+ *
38
+ * const { items } = await inbox.conversations.list({ filter: "needs_review" });
39
+ */
40
+ export declare class InboxClient {
41
+ private readonly http;
42
+ /** Email account management (connect, list, sync). */
43
+ readonly accounts: AccountsResource;
44
+ /** API key management (create, list, revoke). */
45
+ readonly apiKeys: ApiKeysResource;
46
+ /** Attachment downloads. */
47
+ readonly attachments: AttachmentsResource;
48
+ /** Standalone user auth (register, login, me, logout). */
49
+ readonly auth: AuthResource;
50
+ /** Contact autocomplete. */
51
+ readonly contacts: ContactsResource;
52
+ /** Conversation triage, linking, and AI actions. */
53
+ readonly conversations: ConversationsResource;
54
+ /** Message listing, retrieval, reply, and send. */
55
+ readonly messages: MessagesResource;
56
+ /** AI pipeline configuration. */
57
+ readonly pipeline: PipelineResource;
58
+ /** Webhook subscription management and delivery history. */
59
+ readonly webhooks: WebhooksResource;
60
+ constructor(config: InboxClientConfig);
61
+ /**
62
+ * Update the API key used for subsequent requests.
63
+ * Useful when the key is obtained after construction (e.g. post-login).
64
+ */
65
+ setApiKey(key: string): void;
66
+ /** Check the health of the Inbox API and its dependencies. */
67
+ checkHealth(): Promise<HealthStatus>;
68
+ }
69
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,KA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AAqB,CAAC;IAC9C,mDAAmD;IACnD,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,iCAAiC;IACjC,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;IACpC,4DAA4D;IAC5D,QAAQ,CAAC,QAAQ,EAAE,gBAAgB,CAAC;gBAExB,MAAM,EAAE,iBAAiB;IAcrC;;;OAGG;IACH,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI5B,8DAA8D;IACxD,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC;CAG3C"}
package/dist/client.js ADDED
@@ -0,0 +1,68 @@
1
+ import { HttpClient } from "./http.js";
2
+ import { AccountsResource } from "./resources/accounts.js";
3
+ import { ApiKeysResource } from "./resources/api-keys.js";
4
+ import { AttachmentsResource } from "./resources/attachments.js";
5
+ import { AuthResource } from "./resources/auth.js";
6
+ import { ContactsResource } from "./resources/contacts.js";
7
+ import { ConversationsResource } from "./resources/conversations.js";
8
+ import { MessagesResource } from "./resources/messages.js";
9
+ import { PipelineResource } from "./resources/pipeline.js";
10
+ import { WebhooksResource } from "./resources/webhooks.js";
11
+ /**
12
+ * Typed HTTP client for the Inbox API.
13
+ *
14
+ * @example
15
+ * import { InboxClient } from "@quaillogistics/inbox";
16
+ *
17
+ * const inbox = new InboxClient({
18
+ * baseUrl: "https://inbox.example.com",
19
+ * apiKey: "ll_sk_...",
20
+ * });
21
+ *
22
+ * const { items } = await inbox.conversations.list({ filter: "needs_review" });
23
+ */
24
+ export class InboxClient {
25
+ http;
26
+ /** Email account management (connect, list, sync). */
27
+ accounts;
28
+ /** API key management (create, list, revoke). */
29
+ apiKeys;
30
+ /** Attachment downloads. */
31
+ attachments;
32
+ /** Standalone user auth (register, login, me, logout). */
33
+ auth;
34
+ /** Contact autocomplete. */
35
+ contacts;
36
+ /** Conversation triage, linking, and AI actions. */
37
+ conversations;
38
+ /** Message listing, retrieval, reply, and send. */
39
+ messages;
40
+ /** AI pipeline configuration. */
41
+ pipeline;
42
+ /** Webhook subscription management and delivery history. */
43
+ webhooks;
44
+ constructor(config) {
45
+ this.http = new HttpClient(config);
46
+ this.accounts = new AccountsResource(this.http);
47
+ this.apiKeys = new ApiKeysResource(this.http);
48
+ this.attachments = new AttachmentsResource(this.http);
49
+ this.auth = new AuthResource(this.http);
50
+ this.contacts = new ContactsResource(this.http);
51
+ this.conversations = new ConversationsResource(this.http);
52
+ this.messages = new MessagesResource(this.http);
53
+ this.pipeline = new PipelineResource(this.http);
54
+ this.webhooks = new WebhooksResource(this.http);
55
+ }
56
+ /**
57
+ * Update the API key used for subsequent requests.
58
+ * Useful when the key is obtained after construction (e.g. post-login).
59
+ */
60
+ setApiKey(key) {
61
+ this.http.setApiKey(key);
62
+ }
63
+ /** Check the health of the Inbox API and its dependencies. */
64
+ async checkHealth() {
65
+ return this.http.get("/health");
66
+ }
67
+ }
68
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AAGvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAmB3D;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,WAAW;IACL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AC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAED,8DAA8D;IAC9D,KAAK,CAAC,WAAW;QACf,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAe,SAAS,CAAC,CAAC;IAChD,CAAC;CACF"}
@@ -0,0 +1,8 @@
1
+ /** Thrown for all non-2xx HTTP responses from the Inbox API. */
2
+ export declare class InboxApiError extends Error {
3
+ readonly status: number;
4
+ readonly code: string | undefined;
5
+ constructor(status: number, message: string, code?: string);
6
+ static fromResponse(res: Response): Promise<InboxApiError>;
7
+ }
8
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,qBAAa,aAAc,SAAQ,KAAK;IACtC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEtB,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;WAO7C,YAAY,CAAC,GAAG,EAAE,QAAQ,GAAG,OAAO,CAAC,aAAa,CAAC;CAejE"}
package/dist/error.js ADDED
@@ -0,0 +1,26 @@
1
+ /** Thrown for all non-2xx HTTP responses from the Inbox API. */
2
+ export class InboxApiError extends Error {
3
+ status;
4
+ code;
5
+ constructor(status, message, code) {
6
+ super(message);
7
+ this.name = "InboxApiError";
8
+ this.status = status;
9
+ this.code = code;
10
+ }
11
+ static async fromResponse(res) {
12
+ let message = `HTTP ${res.status}`;
13
+ let code;
14
+ try {
15
+ const body = await res.json();
16
+ message = body.error ?? body.message ?? message;
17
+ code = body.code;
18
+ }
19
+ catch {
20
+ // Non-JSON error body — use the status text
21
+ message = res.statusText || message;
22
+ }
23
+ return new InboxApiError(res.status, message, code);
24
+ }
25
+ }
26
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,MAAM,OAAO,aAAc,SAAQ,KAAK;IAC7B,MAAM,CAAS;IACf,IAAI,CAAqB;IAElC,YAAY,MAAc,EAAE,OAAe,EAAE,IAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,YAAY,CAAC,GAAa;QACrC,IAAI,OAAO,GAAG,QAAQ,GAAG,CAAC,MAAM,EAAE,CAAC;QACnC,IAAI,IAAwB,CAAC;QAE7B,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAyD,CAAC;YACrF,OAAO,GAAG,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC;YAChD,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;QACnB,CAAC;QAAC,MAAM,CAAC;YACP,4CAA4C;YAC5C,OAAO,GAAG,GAAG,CAAC,UAAU,IAAI,OAAO,CAAC;QACtC,CAAC;QAED,OAAO,IAAI,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,IAAI,CAAC,CAAC;IACtD,CAAC;CACF"}
package/dist/http.d.ts ADDED
@@ -0,0 +1,32 @@
1
+ export interface HttpClientConfig {
2
+ baseUrl: string;
3
+ apiKey?: string;
4
+ /** Extra headers added to every request (e.g. for custom auth schemes). */
5
+ headers?: Record<string, string>;
6
+ fetch?: typeof globalThis.fetch;
7
+ }
8
+ /**
9
+ * Minimal fetch wrapper shared by all resource classes.
10
+ * Handles auth headers, JSON serialization, and error mapping.
11
+ */
12
+ export declare class HttpClient {
13
+ readonly baseUrl: string;
14
+ private apiKey;
15
+ private extraHeaders;
16
+ private fetchFn;
17
+ /** In session mode (no apiKey) we rely on cookies, so credentials must be included. */
18
+ private readonly credentials;
19
+ constructor(config: HttpClientConfig);
20
+ setApiKey(key: string): void;
21
+ private buildHeaders;
22
+ get<T>(path: string, params?: Record<string, string | number | boolean | undefined>): Promise<T>;
23
+ post<T>(path: string, body?: unknown): Promise<T>;
24
+ patch<T>(path: string, body?: unknown): Promise<T>;
25
+ put<T>(path: string, body?: unknown): Promise<T>;
26
+ delete<T>(path: string): Promise<T>;
27
+ /** For binary responses (attachments). Returns the raw Response. */
28
+ getRaw(path: string): Promise<Response>;
29
+ private buildUrl;
30
+ private handleResponse;
31
+ }
32
+ //# sourceMappingURL=http.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,2EAA2E;IAC3E,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;CACjC;AAED;;;GAGG;AACH,qBAAa,UAAU;IACrB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,YAAY,CAAyB;IAC7C,OAAO,CAAC,OAAO,CAA0B;IAEzC,uFAAuF;IACvF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAqB;gBAErC,MAAM,EAAE,gBAAgB;IAQpC,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI;IAI5B,OAAO,CAAC,YAAY;IAYd,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAUhG,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAOjD,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAOlD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAOhD,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IASzC,oEAAoE;IAC9D,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAY7C,OAAO,CAAC,QAAQ;YAaF,cAAc;CAQ7B"}
package/dist/http.js ADDED
@@ -0,0 +1,105 @@
1
+ import { InboxApiError } from "./error.js";
2
+ /**
3
+ * Minimal fetch wrapper shared by all resource classes.
4
+ * Handles auth headers, JSON serialization, and error mapping.
5
+ */
6
+ export class HttpClient {
7
+ baseUrl;
8
+ apiKey;
9
+ extraHeaders;
10
+ fetchFn;
11
+ /** In session mode (no apiKey) we rely on cookies, so credentials must be included. */
12
+ credentials;
13
+ constructor(config) {
14
+ this.baseUrl = config.baseUrl.replace(/\/$/, "");
15
+ this.apiKey = config.apiKey;
16
+ this.extraHeaders = config.headers ?? {};
17
+ this.fetchFn = (config.fetch ?? globalThis.fetch).bind(globalThis);
18
+ this.credentials = config.apiKey ? "same-origin" : "include";
19
+ }
20
+ setApiKey(key) {
21
+ this.apiKey = key;
22
+ }
23
+ buildHeaders(extra) {
24
+ const headers = {
25
+ "Content-Type": "application/json",
26
+ ...this.extraHeaders,
27
+ ...extra,
28
+ };
29
+ if (this.apiKey) {
30
+ headers["Authorization"] = `Bearer ${this.apiKey}`;
31
+ }
32
+ return headers;
33
+ }
34
+ async get(path, params) {
35
+ const url = this.buildUrl(path, params);
36
+ const res = await this.fetchFn(url, {
37
+ method: "GET",
38
+ headers: this.buildHeaders(),
39
+ credentials: this.credentials,
40
+ });
41
+ return this.handleResponse(res);
42
+ }
43
+ async post(path, body) {
44
+ const init = { method: "POST", headers: this.buildHeaders(), credentials: this.credentials };
45
+ if (body !== undefined)
46
+ init.body = JSON.stringify(body);
47
+ const res = await this.fetchFn(`${this.baseUrl}${path}`, init);
48
+ return this.handleResponse(res);
49
+ }
50
+ async patch(path, body) {
51
+ const init = { method: "PATCH", headers: this.buildHeaders(), credentials: this.credentials };
52
+ if (body !== undefined)
53
+ init.body = JSON.stringify(body);
54
+ const res = await this.fetchFn(`${this.baseUrl}${path}`, init);
55
+ return this.handleResponse(res);
56
+ }
57
+ async put(path, body) {
58
+ const init = { method: "PUT", headers: this.buildHeaders(), credentials: this.credentials };
59
+ if (body !== undefined)
60
+ init.body = JSON.stringify(body);
61
+ const res = await this.fetchFn(`${this.baseUrl}${path}`, init);
62
+ return this.handleResponse(res);
63
+ }
64
+ async delete(path) {
65
+ const res = await this.fetchFn(`${this.baseUrl}${path}`, {
66
+ method: "DELETE",
67
+ headers: this.buildHeaders(),
68
+ credentials: this.credentials,
69
+ });
70
+ return this.handleResponse(res);
71
+ }
72
+ /** For binary responses (attachments). Returns the raw Response. */
73
+ async getRaw(path) {
74
+ const res = await this.fetchFn(`${this.baseUrl}${path}`, {
75
+ method: "GET",
76
+ headers: this.buildHeaders({ "Content-Type": "" }),
77
+ credentials: this.credentials,
78
+ });
79
+ if (!res.ok) {
80
+ throw await InboxApiError.fromResponse(res);
81
+ }
82
+ return res;
83
+ }
84
+ buildUrl(path, params) {
85
+ if (!params)
86
+ return `${this.baseUrl}${path}`;
87
+ const qs = new URLSearchParams();
88
+ for (const [k, v] of Object.entries(params)) {
89
+ if (v !== undefined)
90
+ qs.set(k, String(v));
91
+ }
92
+ const qstr = qs.toString();
93
+ return `${this.baseUrl}${path}${qstr ? `?${qstr}` : ""}`;
94
+ }
95
+ async handleResponse(res) {
96
+ if (!res.ok) {
97
+ throw await InboxApiError.fromResponse(res);
98
+ }
99
+ // 204 No Content
100
+ if (res.status === 204)
101
+ return undefined;
102
+ return res.json();
103
+ }
104
+ }
105
+ //# sourceMappingURL=http.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAU3C;;;GAGG;AACH,MAAM,OAAO,UAAU;IACZ,OAAO,CAAS;IACjB,MAAM,CAAqB;IAC3B,YAAY,CAAyB;IACrC,OAAO,CAA0B;IAEzC,uFAAuF;IACtE,WAAW,CAAqB;IAEjD,YAAY,MAAwB;QAClC,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACjD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,YAAY,GAAG,MAAM,CAAC,OAAO,IAAI,EAAE,CAAC;QACzC,IAAI,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,KAAK,IAAI,UAAU,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QACnE,IAAI,CAAC,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC;IAC/D,CAAC;IAED,SAAS,CAAC,GAAW;QACnB,IAAI,CAAC,MAAM,GAAG,GAAG,CAAC;IACpB,CAAC;IAEO,YAAY,CAAC,KAA8B;QACjD,MAAM,OAAO,GAA2B;YACtC,cAAc,EAAE,kBAAkB;YAClC,GAAG,IAAI,CAAC,YAAY;YACpB,GAAG,KAAK;SACT,CAAC;QACF,IAAI,IAAI,CAAC,MAAM,EAAE,CAAC;YAChB,OAAO,CAAC,eAAe,CAAC,GAAG,UAA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,CAAC;YAClD,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B,CAAC,CAAC;QACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,MAAM,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QAC9C,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;IAEO,QAAQ,CACd,IAAY,EACZ,MAA8D;QAE9D,IAAI,CAAC,MAAM;YAAE,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,EAAE,CAAC;QAC7C,MAAM,EAAE,GAAG,IAAI,eAAe,EAAE,CAAC;QACjC,KAAK,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5C,IAAI,CAAC,KAAK,SAAS;gBAAE,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,CAAC;QACD,MAAM,IAAI,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC3B,OAAO,GAAG,IAAI,CAAC,OAAO,GAAG,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;IAC3D,CAAC;IAEO,KAAK,CAAC,cAAc,CAAI,GAAa;QAC3C,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;YACZ,MAAM,MAAM,aAAa,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;QAC9C,CAAC;QACD,iBAAiB;QACjB,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG;YAAE,OAAO,SAAc,CAAC;QAC9C,OAAO,GAAG,CAAC,IAAI,EAAgB,CAAC;IAClC,CAAC;CACF"}
@@ -0,0 +1,12 @@
1
+ export { InboxClient } from "./client.js";
2
+ export type { InboxClientConfig } from "./client.js";
3
+ export { InboxApiError } from "./error.js";
4
+ export type { ConnectAccountParams, AccountCallbackParams } from "./resources/accounts.js";
5
+ export type { SendParams, ReplyParams } from "./resources/messages.js";
6
+ export type { AttachmentDownload } from "./resources/attachments.js";
7
+ export type { CreateWebhookParams, UpdateWebhookParams, WebhookEvent, } from "./resources/webhooks.js";
8
+ export type { Provider, AccountStatus, TriageState, Priority, Direction, MessageStatus, WebhookStatus, DeliveryStatus, ApiKeyStatus, PipelineStep, ConversationFilter, Account, Conversation, ConversationWithMessages, ConversationTriageSummary, ConversationCounts, Message, MessageWithAttachments, Recipient, Recipients, Attachment, Contact, WebhookSubscription, WebhookDelivery, ApiKey, CreatedApiKey, User, PipelineConfig, PipelineCategory, PipelineActionType, HealthStatus, ConversationListParams, TriageParams, LinkParams, DraftParams, UpdatePipelineConfigParams, } from "./types.js";
9
+ export type { InboxWebhookEvent, WebhookEnvelope, ConversationCreatedEvent, ConversationCreatedPayload, ConversationClassifiedEvent, ConversationClassifiedPayload, ConversationSummarizedEvent, ConversationSummarizedPayload, ConversationUpdatedEvent, ConversationUpdatedPayload, ConversationLinkedEvent, ConversationLinkedPayload, ConversationUnlinkedEvent, ConversationUnlinkedPayload, MessageReceivedEvent, MessageReceivedPayload, MessageSentEvent, MessageSentPayload, MessageProcessedEvent, MessageProcessedPayload, AccountConnectedEvent, AccountConnectedPayload, AccountSyncCompletedEvent, AccountSyncCompletedPayload, AccountErrorEvent, AccountErrorPayload, TestEvent, TestPayload, } from "./webhooks/types.js";
10
+ export { verifyWebhookSignature } from "./webhooks/verify.js";
11
+ export { inboxKeys } from "./query-keys.js";
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGrD,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAG3C,YAAY,EA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EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,9 @@
1
+ // Main client
2
+ export { InboxClient } from "./client.js";
3
+ // Error
4
+ export { InboxApiError } from "./error.js";
5
+ // Webhook signature verification
6
+ export { verifyWebhookSignature } from "./webhooks/verify.js";
7
+ // TanStack Query key factories
8
+ export { inboxKeys } from "./query-keys.js";
9
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAG1C,QAAQ;AACR,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAuF3C,iCAAiC;AACjC,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC;AAE9D,+BAA+B;AAC/B,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { ConversationListParams } from "./types.js";
2
+ /**
3
+ * TanStack Query key factories for the Inbox SDK.
4
+ *
5
+ * Use these to get consistent, hierarchical cache keys across your app.
6
+ * Invalidating a parent key (e.g. `inboxKeys.conversations.all()`) will
7
+ * automatically invalidate all child keys (list, counts, detail, etc.).
8
+ *
9
+ * @example
10
+ * // In a component
11
+ * const { data } = useQuery({
12
+ * queryKey: inboxKeys.conversations.list({ filter: "needs_review" }),
13
+ * queryFn: () => inbox.conversations.list({ filter: "needs_review" }),
14
+ * });
15
+ *
16
+ * // After triaging, invalidate the list and counts
17
+ * queryClient.invalidateQueries({ queryKey: inboxKeys.conversations.all() });
18
+ */
19
+ export declare const inboxKeys: {
20
+ readonly all: readonly ["inbox"];
21
+ readonly health: () => readonly ["inbox", "health"];
22
+ readonly accounts: {
23
+ readonly all: () => readonly ["inbox", "accounts"];
24
+ readonly list: () => readonly ["inbox", "accounts", "list"];
25
+ readonly detail: (id: string) => readonly ["inbox", "accounts", "detail", string];
26
+ };
27
+ readonly conversations: {
28
+ readonly all: () => readonly ["inbox", "conversations"];
29
+ readonly list: (params?: ConversationListParams) => readonly ["inbox", "conversations", "list", ConversationListParams];
30
+ readonly counts: () => readonly ["inbox", "conversations", "counts"];
31
+ readonly detail: (id: string) => readonly ["inbox", "conversations", "detail", string];
32
+ readonly messages: (id: string) => readonly ["inbox", "conversations", "detail", string, "messages"];
33
+ };
34
+ readonly messages: {
35
+ readonly all: () => readonly ["inbox", "messages"];
36
+ readonly detail: (id: string) => readonly ["inbox", "messages", "detail", string];
37
+ };
38
+ readonly contacts: {
39
+ readonly all: () => readonly ["inbox", "contacts"];
40
+ readonly autocomplete: (q: string, limit?: number) => readonly ["inbox", "contacts", "autocomplete", string, number | undefined];
41
+ };
42
+ readonly webhooks: {
43
+ readonly all: () => readonly ["inbox", "webhooks"];
44
+ readonly list: () => readonly ["inbox", "webhooks", "list"];
45
+ readonly deliveries: (id: string, page?: number) => readonly ["inbox", "webhooks", string, "deliveries", number | undefined];
46
+ };
47
+ readonly pipeline: {
48
+ readonly all: () => readonly ["inbox", "pipeline"];
49
+ readonly config: () => readonly ["inbox", "pipeline", "config"];
50
+ };
51
+ readonly apiKeys: {
52
+ readonly all: () => readonly ["inbox", "api-keys"];
53
+ readonly list: () => readonly ["inbox", "api-keys", "list"];
54
+ };
55
+ };
56
+ //# sourceMappingURL=query-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-keys.d.ts","sourceRoot":"","sources":["../src/query-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEzD;;;;;;;;;;;;;;;;GAgBG;AACH,eAAO,MAAM,SAAS;;;;;;8BAQL,MAAM;;;;iCAKH,sBAAsB;;8BAGzB,MAAM;gCACJ,MAAM;;;;8BAMR,MAAM;;;;mCAKD,MAAM,UAAU,MAAM;;;;;kCAOvB,MAAM,SAAS,MAAM;;;;;;;;;;CAahC,CAAC"}
@@ -0,0 +1,55 @@
1
+ /**
2
+ * TanStack Query key factories for the Inbox SDK.
3
+ *
4
+ * Use these to get consistent, hierarchical cache keys across your app.
5
+ * Invalidating a parent key (e.g. `inboxKeys.conversations.all()`) will
6
+ * automatically invalidate all child keys (list, counts, detail, etc.).
7
+ *
8
+ * @example
9
+ * // In a component
10
+ * const { data } = useQuery({
11
+ * queryKey: inboxKeys.conversations.list({ filter: "needs_review" }),
12
+ * queryFn: () => inbox.conversations.list({ filter: "needs_review" }),
13
+ * });
14
+ *
15
+ * // After triaging, invalidate the list and counts
16
+ * queryClient.invalidateQueries({ queryKey: inboxKeys.conversations.all() });
17
+ */
18
+ export const inboxKeys = {
19
+ all: ["inbox"],
20
+ health: () => [...inboxKeys.all, "health"],
21
+ accounts: {
22
+ all: () => [...inboxKeys.all, "accounts"],
23
+ list: () => [...inboxKeys.accounts.all(), "list"],
24
+ detail: (id) => [...inboxKeys.accounts.all(), "detail", id],
25
+ },
26
+ conversations: {
27
+ all: () => [...inboxKeys.all, "conversations"],
28
+ list: (params) => [...inboxKeys.conversations.all(), "list", params ?? {}],
29
+ counts: () => [...inboxKeys.conversations.all(), "counts"],
30
+ detail: (id) => [...inboxKeys.conversations.all(), "detail", id],
31
+ messages: (id) => [...inboxKeys.conversations.detail(id), "messages"],
32
+ },
33
+ messages: {
34
+ all: () => [...inboxKeys.all, "messages"],
35
+ detail: (id) => [...inboxKeys.messages.all(), "detail", id],
36
+ },
37
+ contacts: {
38
+ all: () => [...inboxKeys.all, "contacts"],
39
+ autocomplete: (q, limit) => [...inboxKeys.contacts.all(), "autocomplete", q, limit],
40
+ },
41
+ webhooks: {
42
+ all: () => [...inboxKeys.all, "webhooks"],
43
+ list: () => [...inboxKeys.webhooks.all(), "list"],
44
+ deliveries: (id, page) => [...inboxKeys.webhooks.all(), id, "deliveries", page],
45
+ },
46
+ pipeline: {
47
+ all: () => [...inboxKeys.all, "pipeline"],
48
+ config: () => [...inboxKeys.pipeline.all(), "config"],
49
+ },
50
+ apiKeys: {
51
+ all: () => [...inboxKeys.all, "api-keys"],
52
+ list: () => [...inboxKeys.apiKeys.all(), "list"],
53
+ },
54
+ };
55
+ //# sourceMappingURL=query-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-keys.js","sourceRoot":"","sources":["../src/query-keys.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,GAAG,EAAE,CAAC,OAAO,CAAU;IAEvB,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,EAAE,QAAQ,CAAU;IAEnD,QAAQ,EAAE;QACR,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,EAAE,UAAU,CAAU;QAClD,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,MAAM,CAAU;QAC1D,MAAM,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,CAAU;KAC7E;IAED,aAAa,EAAE;QACb,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,EAAE,eAAe,CAAU;QACvD,IAAI,EAAE,CAAC,MAA+B,EAAE,EAAE,CACxC,CAAC,GAAG,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,MAAM,IAAI,EAAE,CAAU;QACnE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,QAAQ,CAAU;QACnE,MAAM,EAAE,CAAC,EAAU,EAAE,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,aAAa,CAAC,GAAG,EAAE,EAAE,QAAQ,EAAE,EAAE,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ACP,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,GAAG,EAAE,UAAU,CAAU;QAClD,IAAI,EAAE,GAAG,EAAE,CAAC,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,CAAU;KAC1D;CACO,CAAC"}
@@ -0,0 +1,41 @@
1
+ import type { HttpClient } from "../http.js";
2
+ import type { Account, Provider } from "../types.js";
3
+ export interface ConnectAccountParams {
4
+ provider: Provider;
5
+ redirect_uri: string;
6
+ }
7
+ export interface AccountCallbackParams {
8
+ provider: Provider;
9
+ code: string;
10
+ redirect_uri: string;
11
+ }
12
+ export declare class AccountsResource {
13
+ private readonly http;
14
+ constructor(http: HttpClient);
15
+ /**
16
+ * Start the OAuth flow for a new email account.
17
+ * Returns the provider's authorization URL to redirect the user to.
18
+ */
19
+ connect(params: ConnectAccountParams): Promise<{
20
+ auth_url: string;
21
+ }>;
22
+ /**
23
+ * Complete the OAuth flow after the provider redirects back.
24
+ * Exchange the code for tokens and store the connected account.
25
+ */
26
+ callback(params: AccountCallbackParams): Promise<Account>;
27
+ /** List all connected email accounts for the current owner. */
28
+ list(): Promise<Account[]>;
29
+ /** Get a single connected account by ID. */
30
+ get(id: string): Promise<Account>;
31
+ /** Disconnect and delete a connected account. */
32
+ delete(id: string): Promise<{
33
+ ok: boolean;
34
+ }>;
35
+ /** Trigger a manual sync for a connected account. */
36
+ sync(id: string): Promise<{
37
+ ok: boolean;
38
+ message: string;
39
+ }>;
40
+ }
41
+ //# sourceMappingURL=accounts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/resources/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,QAAQ,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,QAAQ,CAAC;IACnB,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;CACtB;AAED,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;OAGG;IACG,OAAO,CAAC,MAAM,EAAE,oBAAoB,GAAG,OAAO,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAI1E;;;OAGG;IACG,QAAQ,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,OAAO,CAAC;IAI/D,+DAA+D;IACzD,IAAI,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAKhC,4CAA4C;IACtC,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvC,iDAAiD;IAC3C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAA;KAAE,CAAC;IAIlD,qDAAqD;IAC/C,IAAI,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CAGlE"}
@@ -0,0 +1,38 @@
1
+ export class AccountsResource {
2
+ http;
3
+ constructor(http) {
4
+ this.http = http;
5
+ }
6
+ /**
7
+ * Start the OAuth flow for a new email account.
8
+ * Returns the provider's authorization URL to redirect the user to.
9
+ */
10
+ async connect(params) {
11
+ return this.http.post("/v1/accounts", params);
12
+ }
13
+ /**
14
+ * Complete the OAuth flow after the provider redirects back.
15
+ * Exchange the code for tokens and store the connected account.
16
+ */
17
+ async callback(params) {
18
+ return this.http.post("/v1/accounts/callback", params);
19
+ }
20
+ /** List all connected email accounts for the current owner. */
21
+ async list() {
22
+ const res = await this.http.get("/v1/accounts");
23
+ return res.accounts;
24
+ }
25
+ /** Get a single connected account by ID. */
26
+ async get(id) {
27
+ return this.http.get(`/v1/accounts/${id}`);
28
+ }
29
+ /** Disconnect and delete a connected account. */
30
+ async delete(id) {
31
+ return this.http.delete(`/v1/accounts/${id}`);
32
+ }
33
+ /** Trigger a manual sync for a connected account. */
34
+ async sync(id) {
35
+ return this.http.post(`/v1/accounts/${id}/sync`);
36
+ }
37
+ }
38
+ //# sourceMappingURL=accounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/resources/accounts.ts"],"names":[],"mappings":"AAcA,MAAM,OAAO,gBAAgB;IACE;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD;;;OAGG;IACH,KAAK,CAAC,OAAO,CAAC,MAA4B;QACxC,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAuB,cAAc,EAAE,MAAM,CAAC,CAAC;IACtE,CAAC;IAED;;;OAGG;IACH,KAAK,CAAC,QAAQ,CAAC,MAA6B;QAC1C,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAU,uBAAuB,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;IAED,+DAA+D;IAC/D,KAAK,CAAC,IAAI;QACR,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,GAAG,CAA0B,cAAc,CAAC,CAAC;QACzE,OAAO,GAAG,CAAC,QAAQ,CAAC;IACtB,CAAC;IAED,4CAA4C;IAC5C,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,OAAO,IAAI,CAAC,IAAI,CAAC,GAAG,CAAU,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACtD,CAAC;IAED,iDAAiD;IACjD,KAAK,CAAC,MAAM,CAAC,EAAU;QACrB,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,CAAkB,gBAAgB,EAAE,EAAE,CAAC,CAAC;IACjE,CAAC;IAED,qDAAqD;IACrD,KAAK,CAAC,IAAI,CAAC,EAAU;QACnB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAmC,gBAAgB,EAAE,OAAO,CAAC,CAAC;IACrF,CAAC;CACF"}
@@ -0,0 +1,22 @@
1
+ import type { HttpClient } from "../http.js";
2
+ import type { ApiKey, CreatedApiKey } from "../types.js";
3
+ export declare class ApiKeysResource {
4
+ private readonly http;
5
+ constructor(http: HttpClient);
6
+ /**
7
+ * Create a new API key.
8
+ * The raw key is returned **once** — store it immediately.
9
+ * Subsequent requests will only return the key prefix.
10
+ */
11
+ create(params?: {
12
+ label?: string;
13
+ expires_at?: string;
14
+ }): Promise<CreatedApiKey>;
15
+ /** List all API keys for the current owner (prefix and metadata only, no key values). */
16
+ list(): Promise<ApiKey[]>;
17
+ /** Revoke an API key by ID. Revoked keys cannot be re-activated. */
18
+ delete(id: string): Promise<{
19
+ ok: boolean;
20
+ }>;
21
+ }
22
+ //# sourceMappingURL=api-keys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-keys.d.ts","sourceRoot":"","sources":["../../src/resources/api-keys.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAEzD,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C;;;;OAIG;IACG,MAAM,CAAC,MAAM,GAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAO,GAAG,OAAO,CAAC,aAAa,CAAC;IAI1F,yFAAyF;IACnF,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAK/B,oEAAoE;IAC9D,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,EAAE,EAAE,OAAO,CAAA;KAAE,CAAC;CAGnD"}