@kirimdev/sdk 1.0.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/LICENSE +21 -0
- package/README.md +63 -0
- package/dist/client.d.ts +52 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +75 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +70 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +167 -0
- package/dist/errors.js.map +1 -0
- package/dist/http.d.ts +71 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +197 -0
- package/dist/http.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +9 -0
- package/dist/index.js.map +1 -0
- package/dist/pagination.d.ts +36 -0
- package/dist/pagination.d.ts.map +1 -0
- package/dist/pagination.js +59 -0
- package/dist/pagination.js.map +1 -0
- package/dist/resources/contacts.d.ts +36 -0
- package/dist/resources/contacts.d.ts.map +1 -0
- package/dist/resources/contacts.js +68 -0
- package/dist/resources/contacts.js.map +1 -0
- package/dist/resources/conversations.d.ts +23 -0
- package/dist/resources/conversations.d.ts.map +1 -0
- package/dist/resources/conversations.js +43 -0
- package/dist/resources/conversations.js.map +1 -0
- package/dist/resources/labels.d.ts +17 -0
- package/dist/resources/labels.d.ts.map +1 -0
- package/dist/resources/labels.js +41 -0
- package/dist/resources/labels.js.map +1 -0
- package/dist/resources/messages.d.ts +19 -0
- package/dist/resources/messages.d.ts.map +1 -0
- package/dist/resources/messages.js +40 -0
- package/dist/resources/messages.js.map +1 -0
- package/dist/resources/templates.d.ts +10 -0
- package/dist/resources/templates.d.ts.map +1 -0
- package/dist/resources/templates.js +19 -0
- package/dist/resources/templates.js.map +1 -0
- package/dist/resources/webhook-deliveries.d.ts +19 -0
- package/dist/resources/webhook-deliveries.d.ts.map +1 -0
- package/dist/resources/webhook-deliveries.js +35 -0
- package/dist/resources/webhook-deliveries.js.map +1 -0
- package/dist/resources/webhook-subscriptions.d.ts +26 -0
- package/dist/resources/webhook-subscriptions.d.ts.map +1 -0
- package/dist/resources/webhook-subscriptions.js +60 -0
- package/dist/resources/webhook-subscriptions.js.map +1 -0
- package/dist/types.d.ts +55 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/webhooks.d.ts +100 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +65 -0
- package/dist/webhooks.js.map +1 -0
- package/openapi.json +6181 -0
- package/package.json +63 -0
package/dist/http.js
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal HTTP client. All resource methods funnel through here so retry,
|
|
3
|
+
* idempotency, timeout, and error mapping are implemented once.
|
|
4
|
+
*
|
|
5
|
+
* Design notes:
|
|
6
|
+
* - Uses Web Standard `fetch` only; no Node-only APIs. Works in Node 18+,
|
|
7
|
+
* Bun, Deno, and Web/edge runtimes.
|
|
8
|
+
* - Auto-injects `Idempotency-Key` on POST so retries are safe by default
|
|
9
|
+
* (matches `apps/api/src/middleware/idempotency.ts`). User-supplied
|
|
10
|
+
* keys override.
|
|
11
|
+
* - Retries on 429 + 502/503/504 + network errors with exponential
|
|
12
|
+
* backoff + jitter. Honors `Retry-After`.
|
|
13
|
+
* - Throws subclasses of `KirimError` for any non-2xx response.
|
|
14
|
+
*/
|
|
15
|
+
import { ConnectionError, fromHttpResponse, KirimError, } from './errors.js';
|
|
16
|
+
export class HttpClient {
|
|
17
|
+
config;
|
|
18
|
+
constructor(config) {
|
|
19
|
+
this.config = config;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Execute a request, parse the envelope, and unwrap `data`. Use this for
|
|
23
|
+
* single-resource endpoints. For paginated endpoints use `requestRaw`.
|
|
24
|
+
*/
|
|
25
|
+
async requestData(args) {
|
|
26
|
+
const body = await this.request(args);
|
|
27
|
+
if (body === null)
|
|
28
|
+
return undefined; // DELETE 204
|
|
29
|
+
const env = body;
|
|
30
|
+
return env.data;
|
|
31
|
+
}
|
|
32
|
+
/** Return the raw decoded body (envelope intact). For pagination. */
|
|
33
|
+
async requestRaw(args) {
|
|
34
|
+
return (await this.request(args));
|
|
35
|
+
}
|
|
36
|
+
async request(args) {
|
|
37
|
+
const opts = args.options ?? {};
|
|
38
|
+
const maxRetries = opts.maxRetries ?? this.config.maxRetries;
|
|
39
|
+
const idempotencyKey = args.method === 'POST'
|
|
40
|
+
? opts.idempotencyKey ?? generateIdempotencyKey()
|
|
41
|
+
: opts.idempotencyKey;
|
|
42
|
+
let attempt = 0;
|
|
43
|
+
let lastError;
|
|
44
|
+
// attempt counts include the first try; loop bound = 1 + retries
|
|
45
|
+
while (attempt <= maxRetries) {
|
|
46
|
+
try {
|
|
47
|
+
return await this.attemptOnce(args, opts, idempotencyKey);
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
lastError = err;
|
|
51
|
+
const decision = shouldRetry(err, attempt, maxRetries);
|
|
52
|
+
if (!decision.retry)
|
|
53
|
+
throw err;
|
|
54
|
+
await sleep(decision.delayMs);
|
|
55
|
+
attempt++;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
// Unreachable: loop either returns or throws. Re-throw last error to be safe.
|
|
59
|
+
throw lastError;
|
|
60
|
+
}
|
|
61
|
+
async attemptOnce(args, opts, idempotencyKey) {
|
|
62
|
+
const url = buildUrl(this.config.baseUrl, args.path, args.query);
|
|
63
|
+
const headers = new Headers({
|
|
64
|
+
Authorization: `Bearer ${this.config.apiKey}`,
|
|
65
|
+
'User-Agent': this.config.userAgent,
|
|
66
|
+
Accept: 'application/json',
|
|
67
|
+
});
|
|
68
|
+
if (args.body !== undefined)
|
|
69
|
+
headers.set('Content-Type', 'application/json');
|
|
70
|
+
if (idempotencyKey)
|
|
71
|
+
headers.set('Idempotency-Key', idempotencyKey);
|
|
72
|
+
if (opts.headers) {
|
|
73
|
+
for (const [k, v] of Object.entries(opts.headers))
|
|
74
|
+
headers.set(k, v);
|
|
75
|
+
}
|
|
76
|
+
const timeoutMs = opts.timeout ?? this.config.timeout;
|
|
77
|
+
const timeoutSignal = AbortSignal.timeout(timeoutMs);
|
|
78
|
+
const signal = opts.signal
|
|
79
|
+
? mergeSignals(opts.signal, timeoutSignal)
|
|
80
|
+
: timeoutSignal;
|
|
81
|
+
let res;
|
|
82
|
+
try {
|
|
83
|
+
res = await this.config.fetch(url, {
|
|
84
|
+
method: args.method,
|
|
85
|
+
headers,
|
|
86
|
+
body: args.body === undefined ? undefined : JSON.stringify(args.body),
|
|
87
|
+
signal,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
catch (err) {
|
|
91
|
+
throw new ConnectionError(err instanceof Error ? err.message : 'Network request failed', err);
|
|
92
|
+
}
|
|
93
|
+
const requestId = res.headers.get('x-request-id');
|
|
94
|
+
if (res.status === 204)
|
|
95
|
+
return null;
|
|
96
|
+
if (res.status === 302) {
|
|
97
|
+
// Media redirect endpoint — return Location-only envelope so the
|
|
98
|
+
// resource method can hand it back to callers.
|
|
99
|
+
return { url: res.headers.get('Location'), request_id: requestId };
|
|
100
|
+
}
|
|
101
|
+
let body = null;
|
|
102
|
+
const text = await res.text();
|
|
103
|
+
if (text) {
|
|
104
|
+
try {
|
|
105
|
+
body = JSON.parse(text);
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
body = { error: { message: text, type: 'api_error', code: 'invalid_response' } };
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
if (!res.ok) {
|
|
112
|
+
const retryAfter = parseRetryAfter(res.headers.get('retry-after'));
|
|
113
|
+
throw fromHttpResponse(res.status, body, requestId, retryAfter);
|
|
114
|
+
}
|
|
115
|
+
return body;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// ---------------------------------------------------------------------------
|
|
119
|
+
// Helpers
|
|
120
|
+
// ---------------------------------------------------------------------------
|
|
121
|
+
function buildUrl(baseUrl, path, query) {
|
|
122
|
+
const base = baseUrl.replace(/\/$/, '');
|
|
123
|
+
const suffix = path.startsWith('/') ? path : `/${path}`;
|
|
124
|
+
const url = new URL(base + suffix);
|
|
125
|
+
if (query) {
|
|
126
|
+
for (const [k, v] of Object.entries(query)) {
|
|
127
|
+
if (v === undefined || v === null)
|
|
128
|
+
continue;
|
|
129
|
+
url.searchParams.set(k, String(v));
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return url.toString();
|
|
133
|
+
}
|
|
134
|
+
/** crypto.randomUUID() is available in Node 18+, Bun, Deno, browsers. */
|
|
135
|
+
function generateIdempotencyKey() {
|
|
136
|
+
return crypto.randomUUID();
|
|
137
|
+
}
|
|
138
|
+
function parseRetryAfter(value) {
|
|
139
|
+
if (!value)
|
|
140
|
+
return null;
|
|
141
|
+
const asInt = Number(value);
|
|
142
|
+
if (Number.isFinite(asInt))
|
|
143
|
+
return Math.max(0, asInt);
|
|
144
|
+
const asDate = Date.parse(value);
|
|
145
|
+
if (Number.isFinite(asDate)) {
|
|
146
|
+
return Math.max(0, Math.ceil((asDate - Date.now()) / 1000));
|
|
147
|
+
}
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
function shouldRetry(err, attempt, maxRetries) {
|
|
151
|
+
if (attempt >= maxRetries)
|
|
152
|
+
return { retry: false, delayMs: 0 };
|
|
153
|
+
if (err instanceof ConnectionError) {
|
|
154
|
+
return { retry: true, delayMs: backoff(attempt) };
|
|
155
|
+
}
|
|
156
|
+
if (err instanceof KirimError) {
|
|
157
|
+
if (err.status === 429) {
|
|
158
|
+
const retryAfter = 'retryAfter' in err && typeof err.retryAfter === 'number'
|
|
159
|
+
? err.retryAfter * 1000
|
|
160
|
+
: null;
|
|
161
|
+
return { retry: true, delayMs: retryAfter ?? backoff(attempt) };
|
|
162
|
+
}
|
|
163
|
+
if (err.status === 502 || err.status === 503 || err.status === 504) {
|
|
164
|
+
return { retry: true, delayMs: backoff(attempt) };
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return { retry: false, delayMs: 0 };
|
|
168
|
+
}
|
|
169
|
+
/** Exponential backoff with full jitter; cap 8s. */
|
|
170
|
+
function backoff(attempt) {
|
|
171
|
+
const exp = Math.min(2 ** attempt * 500, 8_000);
|
|
172
|
+
return Math.floor(Math.random() * exp);
|
|
173
|
+
}
|
|
174
|
+
function sleep(ms) {
|
|
175
|
+
if (ms <= 0)
|
|
176
|
+
return Promise.resolve();
|
|
177
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
178
|
+
}
|
|
179
|
+
function mergeSignals(a, b) {
|
|
180
|
+
const any = AbortSignal.any;
|
|
181
|
+
if (typeof any === 'function')
|
|
182
|
+
return any([a, b]);
|
|
183
|
+
const controller = new AbortController();
|
|
184
|
+
const onAbort = (signal) => () => {
|
|
185
|
+
controller.abort(signal.reason);
|
|
186
|
+
};
|
|
187
|
+
if (a.aborted)
|
|
188
|
+
controller.abort(a.reason);
|
|
189
|
+
else
|
|
190
|
+
a.addEventListener('abort', onAbort(a), { once: true });
|
|
191
|
+
if (b.aborted)
|
|
192
|
+
controller.abort(b.reason);
|
|
193
|
+
else
|
|
194
|
+
b.addEventListener('abort', onAbort(b), { once: true });
|
|
195
|
+
return controller.signal;
|
|
196
|
+
}
|
|
197
|
+
//# sourceMappingURL=http.js.map
|
package/dist/http.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,UAAU,GACX,MAAM,aAAa,CAAA;AAkDpB,MAAM,OAAO,UAAU;IACQ;IAA7B,YAA6B,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAErD;;;OAGG;IACH,KAAK,CAAC,WAAW,CAAI,IAAiB;QACpC,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,OAAO,CA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KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAA;;QACpC,CAAC,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5D,OAAO,UAAU,CAAC,MAAM,CAAA;AAC1B,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for `@kirimdev/sdk`.
|
|
3
|
+
*
|
|
4
|
+
* Webhook utilities live in `@kirimdev/sdk/webhooks` to keep the main entry
|
|
5
|
+
* tree-shakable when a consumer only needs the REST client.
|
|
6
|
+
*/
|
|
7
|
+
export { Kirim, SDK_VERSION, type KirimOptions } from './client.js';
|
|
8
|
+
export type { Page, Paginator } from './pagination.js';
|
|
9
|
+
export type { RequestOptions } from './http.js';
|
|
10
|
+
export { KirimError, InvalidRequestError, AuthenticationError, PermissionError, NotFoundError, ConflictError, RateLimitError, ApiServerError, ConnectionError, type KirimErrorType, type KirimErrorPayload, } from './errors.js';
|
|
11
|
+
export type { MeContext, Message, MessageListItem, SendMessageParams, ListMessagesParams, MessageMediaRedirect, Template, TemplateListItem, ListTemplatesParams, RetrieveTemplateParams, Conversation, ConversationListItem, ListConversationsParams, UpdateConversationParams, AttachConversationLabelParams, Contact, ContactListItem, ListContactsParams, CreateContactParams, UpdateContactParams, AttachContactLabelParams, BulkLabelContactsParams, Label, LabelListItem, ListLabelsParams, CreateLabelParams, UpdateLabelParams, WebhookSubscription, WebhookSubscriptionListItem, CreateWebhookSubscriptionParams, UpdateWebhookSubscriptionParams, AddWebhookSecret, WebhookDelivery, WebhookDeliveryListItem, ListWebhookDeliveriesParams, BulkReplayParams, BulkReplayResult, } from './types.js';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAA;AAEnE,YAAY,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAA;AACtD,YAAY,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE/C,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,iBAAiB,GACvB,MAAM,aAAa,CAAA;AAEpB,YAAY,EACV,SAAS,EACT,OAAO,EACP,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,EACpB,QAAQ,EACR,gBAAgB,EAChB,mBAAmB,EACnB,sBAAsB,EACtB,YAAY,EACZ,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACxB,6BAA6B,EAC7B,OAAO,EACP,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,mBAAmB,EACnB,wBAAwB,EACxB,uBAAuB,EACvB,KAAK,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,iBAAiB,EACjB,mBAAmB,EACnB,2BAA2B,EAC3B,+BAA+B,EAC/B,+BAA+B,EAC/B,gBAAgB,EAChB,eAAe,EACf,uBAAuB,EACvB,2BAA2B,EAC3B,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public entry point for `@kirimdev/sdk`.
|
|
3
|
+
*
|
|
4
|
+
* Webhook utilities live in `@kirimdev/sdk/webhooks` to keep the main entry
|
|
5
|
+
* tree-shakable when a consumer only needs the REST client.
|
|
6
|
+
*/
|
|
7
|
+
export { Kirim, SDK_VERSION } from './client.js';
|
|
8
|
+
export { KirimError, InvalidRequestError, AuthenticationError, PermissionError, NotFoundError, ConflictError, RateLimitError, ApiServerError, ConnectionError, } from './errors.js';
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,KAAK,EAAE,WAAW,EAAqB,MAAM,aAAa,CAAA;AAKnE,OAAO,EACL,UAAU,EACV,mBAAmB,EACnB,mBAAmB,EACnB,eAAe,EACf,aAAa,EACb,aAAa,EACb,cAAc,EACd,cAAc,EACd,eAAe,GAGhB,MAAM,aAAa,CAAA"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async-iterable paginator for list endpoints.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* const it = kirim.messages.list({ limit: 50 })
|
|
6
|
+
* for await (const msg of it) { ... }
|
|
7
|
+
*
|
|
8
|
+
* // Or per-page:
|
|
9
|
+
* const page = await it.page() // { data, hasMore, nextCursor }
|
|
10
|
+
* const next = await it.next(page.nextCursor)
|
|
11
|
+
*
|
|
12
|
+
* `for await` exhausts every page until the API reports `has_more: false`.
|
|
13
|
+
* The iterator forwards `RequestOptions` to every page request (so the
|
|
14
|
+
* same retry/timeout/idempotency budget applies).
|
|
15
|
+
*/
|
|
16
|
+
import type { HttpClient, RequestArgs, RequestOptions } from './http.js';
|
|
17
|
+
export interface Page<T> {
|
|
18
|
+
data: T[];
|
|
19
|
+
hasMore: boolean;
|
|
20
|
+
nextCursor: string | null;
|
|
21
|
+
requestId: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class Paginator<T> implements AsyncIterable<T> {
|
|
24
|
+
private readonly http;
|
|
25
|
+
private readonly args;
|
|
26
|
+
private readonly initialOptions?;
|
|
27
|
+
constructor(http: HttpClient, args: Omit<RequestArgs, 'method'> & {
|
|
28
|
+
method?: 'GET';
|
|
29
|
+
}, initialOptions?: RequestOptions | undefined);
|
|
30
|
+
/** Fetch a single page starting at `cursor` (or the beginning if omitted). */
|
|
31
|
+
page(cursor?: string | null, options?: RequestOptions): Promise<Page<T>>;
|
|
32
|
+
/** Alias for `page(cursor)`. */
|
|
33
|
+
next(cursor?: string | null, options?: RequestOptions): Promise<Page<T>>;
|
|
34
|
+
[Symbol.asyncIterator](): AsyncIterator<T>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=pagination.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.d.ts","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,cAAc,EAAgB,MAAM,WAAW,CAAA;AAEtF,MAAM,WAAW,IAAI,CAAC,CAAC;IACrB,IAAI,EAAE,CAAC,EAAE,CAAA;IACT,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,qBAAa,SAAS,CAAC,CAAC,CAAE,YAAW,aAAa,CAAC,CAAC,CAAC;IAEjD,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC;gBAFf,IAAI,EAAE,UAAU,EAChB,IAAI,EAAE,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,GAAG;QAAE,MAAM,CAAC,EAAE,KAAK,CAAA;KAAE,EACtD,cAAc,CAAC,EAAE,cAAc,YAAA;IAGlD,8EAA8E;IACxE,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAoB9E,gCAAgC;IAChC,IAAI,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAIjE,CAAC,MAAM,CAAC,aAAa,CAAC,IAAI,aAAa,CAAC,CAAC,CAAC;CAQlD"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async-iterable paginator for list endpoints.
|
|
3
|
+
*
|
|
4
|
+
* Usage:
|
|
5
|
+
* const it = kirim.messages.list({ limit: 50 })
|
|
6
|
+
* for await (const msg of it) { ... }
|
|
7
|
+
*
|
|
8
|
+
* // Or per-page:
|
|
9
|
+
* const page = await it.page() // { data, hasMore, nextCursor }
|
|
10
|
+
* const next = await it.next(page.nextCursor)
|
|
11
|
+
*
|
|
12
|
+
* `for await` exhausts every page until the API reports `has_more: false`.
|
|
13
|
+
* The iterator forwards `RequestOptions` to every page request (so the
|
|
14
|
+
* same retry/timeout/idempotency budget applies).
|
|
15
|
+
*/
|
|
16
|
+
export class Paginator {
|
|
17
|
+
http;
|
|
18
|
+
args;
|
|
19
|
+
initialOptions;
|
|
20
|
+
constructor(http, args, initialOptions) {
|
|
21
|
+
this.http = http;
|
|
22
|
+
this.args = args;
|
|
23
|
+
this.initialOptions = initialOptions;
|
|
24
|
+
}
|
|
25
|
+
/** Fetch a single page starting at `cursor` (or the beginning if omitted). */
|
|
26
|
+
async page(cursor, options) {
|
|
27
|
+
const env = await this.http.requestRaw({
|
|
28
|
+
method: 'GET',
|
|
29
|
+
path: this.args.path,
|
|
30
|
+
query: {
|
|
31
|
+
...(this.args.query ?? {}),
|
|
32
|
+
...(cursor ? { cursor } : {}),
|
|
33
|
+
},
|
|
34
|
+
...(options ?? this.initialOptions
|
|
35
|
+
? { options: { ...(this.initialOptions ?? {}), ...(options ?? {}) } }
|
|
36
|
+
: {}),
|
|
37
|
+
});
|
|
38
|
+
return {
|
|
39
|
+
data: env.data,
|
|
40
|
+
hasMore: env.has_more,
|
|
41
|
+
nextCursor: env.next_cursor,
|
|
42
|
+
requestId: env.request_id,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/** Alias for `page(cursor)`. */
|
|
46
|
+
next(cursor, options) {
|
|
47
|
+
return this.page(cursor, options);
|
|
48
|
+
}
|
|
49
|
+
async *[Symbol.asyncIterator]() {
|
|
50
|
+
let cursor = undefined;
|
|
51
|
+
do {
|
|
52
|
+
const p = await this.page(cursor);
|
|
53
|
+
for (const item of p.data)
|
|
54
|
+
yield item;
|
|
55
|
+
cursor = p.nextCursor;
|
|
56
|
+
} while (cursor !== null && cursor !== undefined);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pagination.js","sourceRoot":"","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAWH,MAAM,OAAO,SAAS;IAED;IACA;IACA;IAHnB,YACmB,IAAgB,EAChB,IAAsD,EACtD,cAA+B;QAF/B,SAAI,GAAJ,IAAI,CAAY;QAChB,SAAI,GAAJ,IAAI,CAAkD;QACtD,mBAAc,GAAd,cAAc,CAAiB;IAC/C,CAAC;IAEJ,8EAA8E;IAC9E,KAAK,CAAC,IAAI,CAAC,MAAsB,EAAE,OAAwB;QACzD,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,CAAkB;YACtD,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,IAAI;YACpB,KAAK,EAAE;gBACL,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC;gBAC1B,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aAC9B;YACD,GAAG,CAAC,OAAO,IAAI,IAAI,CAAC,cAAc;gBAChC,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,cAAc,IAAI,EAAE,CAAC,EAAE,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC,EAAE,EAAE;gBACrE,CAAC,CAAC,EAAE,CAAC;SACR,CAAC,CAAA;QACF,OAAO;YACL,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,OAAO,EAAE,GAAG,CAAC,QAAQ;YACrB,UAAU,EAAE,GAAG,CAAC,WAAW;YAC3B,SAAS,EAAE,GAAG,CAAC,UAAU;SAC1B,CAAA;IACH,CAAC;IAED,gCAAgC;IAChC,IAAI,CAAC,MAAsB,EAAE,OAAwB;QACnD,OAAO,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IACnC,CAAC;IAED,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,aAAa,CAAC;QAC3B,IAAI,MAAM,GAA8B,SAAS,CAAA;QACjD,GAAG,CAAC;YACF,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YACjC,KAAK,MAAM,IAAI,IAAI,CAAC,CAAC,IAAI;gBAAE,MAAM,IAAI,CAAA;YACrC,MAAM,GAAG,CAAC,CAAC,UAAU,CAAA;QACvB,CAAC,QAAQ,MAAM,KAAK,IAAI,IAAI,MAAM,KAAK,SAAS,EAAC;IACnD,CAAC;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { HttpClient, RequestOptions } from '../http.js';
|
|
2
|
+
import { Paginator } from '../pagination.js';
|
|
3
|
+
import type { AttachContactLabelParams, BulkLabelContactsParams, Contact, ContactListItem, CreateContactParams, ListContactsParams, UpdateContactParams } from '../types.js';
|
|
4
|
+
export declare class ContactsResource {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
create(params: CreateContactParams, options?: RequestOptions): Promise<Contact>;
|
|
8
|
+
list(params?: ListContactsParams, options?: RequestOptions): Paginator<ContactListItem>;
|
|
9
|
+
retrieve(id: string, options?: RequestOptions): Promise<Contact>;
|
|
10
|
+
update(id: string, params: UpdateContactParams, options?: RequestOptions): Promise<Contact>;
|
|
11
|
+
/** DELETE /contacts/{id} */
|
|
12
|
+
del(id: string, options?: RequestOptions): Promise<{
|
|
13
|
+
id: string;
|
|
14
|
+
object: 'contact';
|
|
15
|
+
deleted: true;
|
|
16
|
+
}>;
|
|
17
|
+
/** POST /contacts/{id}/labels */
|
|
18
|
+
addLabel(contactId: string, params: AttachContactLabelParams, options?: RequestOptions): Promise<{
|
|
19
|
+
contact_id: string;
|
|
20
|
+
label_id: string;
|
|
21
|
+
attached: true;
|
|
22
|
+
}>;
|
|
23
|
+
/** DELETE /contacts/{id}/labels/{label_id} */
|
|
24
|
+
removeLabel(contactId: string, labelId: string, options?: RequestOptions): Promise<{
|
|
25
|
+
contact_id: string;
|
|
26
|
+
label_id: string;
|
|
27
|
+
attached: false;
|
|
28
|
+
}>;
|
|
29
|
+
/** POST /contacts/bulk_label */
|
|
30
|
+
bulkLabel(params: BulkLabelContactsParams, options?: RequestOptions): Promise<{
|
|
31
|
+
applied: number;
|
|
32
|
+
skipped_cross_org: number;
|
|
33
|
+
skipped_team_mismatch: number;
|
|
34
|
+
}>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=contacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contacts.d.ts","sourceRoot":"","sources":["../../src/resources/contacts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EACV,wBAAwB,EACxB,uBAAuB,EACvB,OAAO,EACP,eAAe,EACf,mBAAmB,EACnB,kBAAkB,EAClB,mBAAmB,EACpB,MAAM,aAAa,CAAA;AAEpB,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ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AAE,OAAO,EAAE,MAAM,CAAC;QAAC,iBAAiB,EAAE,MAAM,CAAC;QAAC,qBAAqB,EAAE,MAAM,CAAA;KAAE,CAAC;CAQ1F"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { Paginator } from '../pagination.js';
|
|
2
|
+
export class ContactsResource {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
create(params, options) {
|
|
8
|
+
return this.http.requestData({
|
|
9
|
+
method: 'POST',
|
|
10
|
+
path: '/contacts',
|
|
11
|
+
body: params,
|
|
12
|
+
...(options ? { options } : {}),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
list(params, options) {
|
|
16
|
+
return new Paginator(this.http, { path: '/contacts', ...(params ? { query: params } : {}) }, options);
|
|
17
|
+
}
|
|
18
|
+
retrieve(id, options) {
|
|
19
|
+
return this.http.requestData({
|
|
20
|
+
method: 'GET',
|
|
21
|
+
path: `/contacts/${encodeURIComponent(id)}`,
|
|
22
|
+
...(options ? { options } : {}),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
update(id, params, options) {
|
|
26
|
+
return this.http.requestData({
|
|
27
|
+
method: 'PATCH',
|
|
28
|
+
path: `/contacts/${encodeURIComponent(id)}`,
|
|
29
|
+
body: params,
|
|
30
|
+
...(options ? { options } : {}),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** DELETE /contacts/{id} */
|
|
34
|
+
del(id, options) {
|
|
35
|
+
return this.http.requestData({
|
|
36
|
+
method: 'DELETE',
|
|
37
|
+
path: `/contacts/${encodeURIComponent(id)}`,
|
|
38
|
+
...(options ? { options } : {}),
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
/** POST /contacts/{id}/labels */
|
|
42
|
+
addLabel(contactId, params, options) {
|
|
43
|
+
return this.http.requestData({
|
|
44
|
+
method: 'POST',
|
|
45
|
+
path: `/contacts/${encodeURIComponent(contactId)}/labels`,
|
|
46
|
+
body: params,
|
|
47
|
+
...(options ? { options } : {}),
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** DELETE /contacts/{id}/labels/{label_id} */
|
|
51
|
+
removeLabel(contactId, labelId, options) {
|
|
52
|
+
return this.http.requestData({
|
|
53
|
+
method: 'DELETE',
|
|
54
|
+
path: `/contacts/${encodeURIComponent(contactId)}/labels/${encodeURIComponent(labelId)}`,
|
|
55
|
+
...(options ? { options } : {}),
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
/** POST /contacts/bulk_label */
|
|
59
|
+
bulkLabel(params, options) {
|
|
60
|
+
return this.http.requestData({
|
|
61
|
+
method: 'POST',
|
|
62
|
+
path: '/contacts/bulk_label',
|
|
63
|
+
body: params,
|
|
64
|
+
...(options ? { options } : {}),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=contacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"contacts.js","sourceRoot":"","sources":["../../src/resources/contacts.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAW5C,MAAM,OAAO,gBAAgB;IACE;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,MAAM,CAAC,MAA2B,EAAE,OAAwB;QAC1D,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAU;YACpC,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,WAAW;YACjB,IAAI,EAAE,MAAM;YACZ,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;IAED,IAAI,CAAC,MAA2B,EAAE,OAAwB;QACxD,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,IAAI,EACT,EAAE,IAAI,EAAE,WA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AC,SAAS,CAAC,SAAS;YACzD,IAAI,EAAE,MAAM;YACZ,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;IAED,8CAA8C;IAC9C,WAAW,CACT,SAAiB,EACjB,OAAe,EACf,OAAwB;QAExB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;YAC3B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,aAAa,kBAAkB,CAAC,SAAS,CAAC,WAAW,kBAAkB,CAAC,OAAO,CAAC,EAAE;YACxF,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;IAED,gCAAgC;IAChC,SAAS,CACP,MAA+B,EAC/B,OAAwB;QAExB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;YAC3B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,sBAAsB;YAC5B,IAAI,EAAE,MAAM;YACZ,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { HttpClient, RequestOptions } from '../http.js';
|
|
2
|
+
import { Paginator } from '../pagination.js';
|
|
3
|
+
import type { AttachConversationLabelParams, Conversation, ConversationListItem, ListConversationsParams, UpdateConversationParams } from '../types.js';
|
|
4
|
+
export declare class ConversationsResource {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
list(params?: ListConversationsParams, options?: RequestOptions): Paginator<ConversationListItem>;
|
|
8
|
+
retrieve(id: string, options?: RequestOptions): Promise<Conversation>;
|
|
9
|
+
update(id: string, params: UpdateConversationParams, options?: RequestOptions): Promise<Conversation>;
|
|
10
|
+
/** POST /conversations/{id}/labels */
|
|
11
|
+
addLabel(conversationId: string, params: AttachConversationLabelParams, options?: RequestOptions): Promise<{
|
|
12
|
+
conversation_id: string;
|
|
13
|
+
label_id: string;
|
|
14
|
+
attached: true;
|
|
15
|
+
}>;
|
|
16
|
+
/** DELETE /conversations/{id}/labels/{label_id} */
|
|
17
|
+
removeLabel(conversationId: string, labelId: string, options?: RequestOptions): Promise<{
|
|
18
|
+
conversation_id: string;
|
|
19
|
+
label_id: string;
|
|
20
|
+
attached: false;
|
|
21
|
+
}>;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=conversations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversations.d.ts","sourceRoot":"","sources":["../../src/resources/conversations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EACV,6BAA6B,EAC7B,YAAY,EACZ,oBAAoB,EACpB,uBAAuB,EACvB,wBAAwB,EACzB,MAAM,aAAa,CAAA;AAEpB,qBAAa,qBAAqB;IACpB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,IAAI,CACF,MAAM,CAAC,EAAE,uBAAuB,EAChC,OAAO,CAAC,EAAE,cAAc,GACvB,SAAS,CAAC,oBAAoB,CAAC;IAQlC,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;IAQrE,MAAM,CACJ,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,wBAAwB,EAChC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC,YAAY,CAAC;IASxB,sCAAsC;IACtC,QAAQ,CACN,cAAc,EAAE,MAAM,EACtB,MAAM,EAAE,6BAA6B,EACrC,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,IAAI,CAAA;KAAE,CAAC;IASzE,mDAAmD;IACnD,WAAW,CACT,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC;QAAE,eAAe,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,KAAK,CAAA;KAAE,CAAC;CAO3E"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Paginator } from '../pagination.js';
|
|
2
|
+
export class ConversationsResource {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
list(params, options) {
|
|
8
|
+
return new Paginator(this.http, { path: '/conversations', ...(params ? { query: params } : {}) }, options);
|
|
9
|
+
}
|
|
10
|
+
retrieve(id, options) {
|
|
11
|
+
return this.http.requestData({
|
|
12
|
+
method: 'GET',
|
|
13
|
+
path: `/conversations/${encodeURIComponent(id)}`,
|
|
14
|
+
...(options ? { options } : {}),
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
update(id, params, options) {
|
|
18
|
+
return this.http.requestData({
|
|
19
|
+
method: 'PATCH',
|
|
20
|
+
path: `/conversations/${encodeURIComponent(id)}`,
|
|
21
|
+
body: params,
|
|
22
|
+
...(options ? { options } : {}),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
/** POST /conversations/{id}/labels */
|
|
26
|
+
addLabel(conversationId, params, options) {
|
|
27
|
+
return this.http.requestData({
|
|
28
|
+
method: 'POST',
|
|
29
|
+
path: `/conversations/${encodeURIComponent(conversationId)}/labels`,
|
|
30
|
+
body: params,
|
|
31
|
+
...(options ? { options } : {}),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/** DELETE /conversations/{id}/labels/{label_id} */
|
|
35
|
+
removeLabel(conversationId, labelId, options) {
|
|
36
|
+
return this.http.requestData({
|
|
37
|
+
method: 'DELETE',
|
|
38
|
+
path: `/conversations/${encodeURIComponent(conversationId)}/labels/${encodeURIComponent(labelId)}`,
|
|
39
|
+
...(options ? { options } : {}),
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=conversations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversations.js","sourceRoot":"","sources":["../../src/resources/conversations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAS5C,MAAM,OAAO,qBAAqB;IACH;IAA7B,YAA6B,IAAgB;QAAhB,SAAI,GAAJ,IAAI,CAAY;IAAG,CAAC;IAEjD,IAAI,CACF,MAAgC,EAChC,OAAwB;QAExB,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,IAAI,EACT,EAAE,IAAI,EAAE,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,MAAsE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAChI,OAAO,CACR,CAAA;IACH,CAAC;IAED,QAAQ,CAAC,EAAU,EAAE,OAAwB;QAC3C,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAe;YACzC,MAAM,EAAE,KAAK;YACb,IAAI,EAAE,kBAAkB,kBAAkB,CAAC,EAAE,CAAC,EAAE;YAChD,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;IAED,MAAM,CACJ,EAAU,EACV,MAAgC,EAChC,OAAwB;QAExB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAe;YACzC,MAAM,EAAE,OAAO;YACf,IAAI,EAAE,kBAAkB,kBAAkB,CAAC,EAAE,CAAC,EAAE;YAChD,IAAI,EAAE,MAAM;YACZ,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;IAED,sCAAsC;IACtC,QAAQ,CACN,cAAsB,EACtB,MAAqC,EACrC,OAAwB;QAExB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;YAC3B,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,kBAAkB,kBAAkB,CAAC,cAAc,CAAC,SAAS;YACnE,IAAI,EAAE,MAAM;YACZ,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;IAED,mDAAmD;IACnD,WAAW,CACT,cAAsB,EACtB,OAAe,EACf,OAAwB;QAExB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;YAC3B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,kBAAkB,kBAAkB,CAAC,cAAc,CAAC,WAAW,kBAAkB,CAAC,OAAO,CAAC,EAAE;YAClG,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { HttpClient, RequestOptions } from '../http.js';
|
|
2
|
+
import { Paginator } from '../pagination.js';
|
|
3
|
+
import type { CreateLabelParams, Label, LabelListItem, ListLabelsParams, UpdateLabelParams } from '../types.js';
|
|
4
|
+
export declare class LabelsResource {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
create(params: CreateLabelParams, options?: RequestOptions): Promise<Label>;
|
|
8
|
+
list(params?: ListLabelsParams, options?: RequestOptions): Paginator<LabelListItem>;
|
|
9
|
+
retrieve(id: string, options?: RequestOptions): Promise<Label>;
|
|
10
|
+
update(id: string, params: UpdateLabelParams, options?: RequestOptions): Promise<Label>;
|
|
11
|
+
del(id: string, options?: RequestOptions): Promise<{
|
|
12
|
+
id: string;
|
|
13
|
+
object: 'label';
|
|
14
|
+
deleted: true;
|
|
15
|
+
}>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=labels.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.d.ts","sourceRoot":"","sources":["../../src/resources/labels.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EACV,iBAAiB,EACjB,KAAK,EACL,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,aAAa,CAAA;AAEpB,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,MAAM,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC;IAS3E,IAAI,CAAC,MAAM,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC,aAAa,CAAC;IAQnF,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC;IAQ9D,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,KAAK,CAAC;IASvF,GAAG,CACD,EAAE,EAAE,MAAM,EACV,OAAO,CAAC,EAAE,cAAc,GACvB,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,OAAO,CAAC;QAAC,OAAO,EAAE,IAAI,CAAA;KAAE,CAAC;CAO3D"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Paginator } from '../pagination.js';
|
|
2
|
+
export class LabelsResource {
|
|
3
|
+
http;
|
|
4
|
+
constructor(http) {
|
|
5
|
+
this.http = http;
|
|
6
|
+
}
|
|
7
|
+
create(params, options) {
|
|
8
|
+
return this.http.requestData({
|
|
9
|
+
method: 'POST',
|
|
10
|
+
path: '/labels',
|
|
11
|
+
body: params,
|
|
12
|
+
...(options ? { options } : {}),
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
list(params, options) {
|
|
16
|
+
return new Paginator(this.http, { path: '/labels', ...(params ? { query: params } : {}) }, options);
|
|
17
|
+
}
|
|
18
|
+
retrieve(id, options) {
|
|
19
|
+
return this.http.requestData({
|
|
20
|
+
method: 'GET',
|
|
21
|
+
path: `/labels/${encodeURIComponent(id)}`,
|
|
22
|
+
...(options ? { options } : {}),
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
update(id, params, options) {
|
|
26
|
+
return this.http.requestData({
|
|
27
|
+
method: 'PATCH',
|
|
28
|
+
path: `/labels/${encodeURIComponent(id)}`,
|
|
29
|
+
body: params,
|
|
30
|
+
...(options ? { options } : {}),
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
del(id, options) {
|
|
34
|
+
return this.http.requestData({
|
|
35
|
+
method: 'DELETE',
|
|
36
|
+
path: `/labels/${encodeURIComponent(id)}`,
|
|
37
|
+
...(options ? { options } : {}),
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=labels.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"labels.js","sourceRoot":"","sources":["../../src/resources/labels.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAS5C,MAAM,OAAO,cAAc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D,EAAU,EACV,OAAwB;QAExB,OAAO,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC;YAC3B,MAAM,EAAE,QAAQ;YAChB,IAAI,EAAE,WAAW,kBAAkB,CAAC,EAAE,CAAC,EAAE;YACzC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChC,CAAC,CAAA;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { HttpClient, RequestOptions } from '../http.js';
|
|
2
|
+
import { Paginator } from '../pagination.js';
|
|
3
|
+
import type { ListMessagesParams, Message, MessageListItem, MessageMediaRedirect, SendMessageParams } from '../types.js';
|
|
4
|
+
export declare class MessagesResource {
|
|
5
|
+
private readonly http;
|
|
6
|
+
constructor(http: HttpClient);
|
|
7
|
+
/** POST /messages — send a WhatsApp message (any supported type). */
|
|
8
|
+
send(params: SendMessageParams, options?: RequestOptions): Promise<Message>;
|
|
9
|
+
/** GET /messages — list messages; async-iterable + per-page. */
|
|
10
|
+
list(params?: ListMessagesParams, options?: RequestOptions): Paginator<MessageListItem>;
|
|
11
|
+
/** GET /messages/{id} */
|
|
12
|
+
retrieve(id: string, options?: RequestOptions): Promise<Message>;
|
|
13
|
+
/**
|
|
14
|
+
* GET /messages/{id}/media — returns the signed URL the API redirects to
|
|
15
|
+
* (the SDK does NOT follow the redirect — you decide whether to stream).
|
|
16
|
+
*/
|
|
17
|
+
media(id: string, options?: RequestOptions): Promise<MessageMediaRedirect>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=messages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../src/resources/messages.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAA;AAC5D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAA;AAC5C,OAAO,KAAK,EACV,kBAAkB,EAClB,OAAO,EACP,eAAe,EACf,oBAAoB,EACpB,iBAAiB,EAClB,MAAM,aAAa,CAAA;AAEpB,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,qEAAqE;IACrE,IAAI,CAAC,MAAM,EAAE,iBAAiB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAS3E,gEAAgE;IAChE,IAAI,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,SAAS,CAAC,eAAe,CAAC;IAQvF,yBAAyB;IACzB,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;IAQhE;;;OAGG;IACH,KAAK,CAAC,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAO3E"}
|