@nemphi/sdk 0.8.6854 → 0.8.6887
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/dist/block-kit-state.d.ts +3 -3
- package/dist/block-kit-state.d.ts.map +1 -1
- package/dist/block-kit-state.js +33 -17
- package/dist/block-kit-state.js.map +1 -1
- package/dist/block-kit.d.ts +46 -46
- package/dist/block-kit.d.ts.map +1 -1
- package/dist/block-kit.js +10 -5
- package/dist/block-kit.js.map +1 -1
- package/dist/index.d.ts +622 -622
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +179 -113
- package/dist/index.js.map +1 -1
- package/dist/reactions.d.ts +1 -1
- package/dist/reactions.d.ts.map +1 -1
- package/dist/reactions.js +10 -5
- package/dist/reactions.js.map +1 -1
- package/dist/ui-spec.d.ts +3 -3
- package/dist/ui-spec.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -55,7 +55,7 @@ const realtimeEventOf = (data) => frameOf(data, isRealtimeEvent);
|
|
|
55
55
|
/** One frame of a thread's stream; anything else is left out. */
|
|
56
56
|
const threadStreamEventOf = (data) => frameOf(data, isThreadStreamEvent);
|
|
57
57
|
/** The first wait before a dropped stream is opened again; it doubles to `STREAM_RETRY_MAX_MS`. */
|
|
58
|
-
const STREAM_RETRY_MS =
|
|
58
|
+
const STREAM_RETRY_MS = 1000;
|
|
59
59
|
/** The longest wait between attempts to open a stream again. */
|
|
60
60
|
const STREAM_RETRY_MAX_MS = 30_000;
|
|
61
61
|
/** The wait before attempt `failures` + 1, with jitter so many clients do not return at once. */
|
|
@@ -120,35 +120,96 @@ export class ApiError extends Error {
|
|
|
120
120
|
/** The input an error envelope names, read where the envelope is parsed. */
|
|
121
121
|
function fieldRefusalOf(error) {
|
|
122
122
|
const { field, reason, params: given } = error;
|
|
123
|
-
if (!isJsonText(field) || !isJsonText(reason))
|
|
123
|
+
if (!isJsonText(field) || !isJsonText(reason)) {
|
|
124
124
|
return null;
|
|
125
|
+
}
|
|
125
126
|
const params = {};
|
|
126
127
|
if (isJsonMap(given)) {
|
|
127
128
|
for (const [name, value] of Object.entries(given)) {
|
|
128
|
-
if (isJsonText(value))
|
|
129
|
+
if (isJsonText(value)) {
|
|
129
130
|
params[name] = value;
|
|
131
|
+
}
|
|
130
132
|
}
|
|
131
133
|
}
|
|
132
134
|
return { field, reason, params };
|
|
133
135
|
}
|
|
134
136
|
/** A guest's seat in a standalone call: the base of the public room routes. */
|
|
135
137
|
const publicCallSeatPath = (token, participantId) => `/v1/public/calls/${encodeURIComponent(token)}/participants/${encodeURIComponent(participantId)}`;
|
|
138
|
+
/** Turns a non-2xx (or bodyless) stream response into an ApiError. */
|
|
139
|
+
async function streamError(res) {
|
|
140
|
+
const body = await parsedBody(res);
|
|
141
|
+
const error = isJsonObject(body) ? body : {};
|
|
142
|
+
throw new ApiError(res.status, isJsonText(error.code) ? error.code : "unknown", isJsonText(error.error) ? error.error : `stream failed with status ${res.status}`, body, fieldRefusalOf(error));
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Decodes an SSE body into `{ event, data }` frames. Comment lines
|
|
146
|
+
* (keepalives) and frames without a data payload are skipped.
|
|
147
|
+
*/
|
|
148
|
+
async function* sseFrames(body) {
|
|
149
|
+
const reader = body.getReader();
|
|
150
|
+
const decoder = new TextDecoder();
|
|
151
|
+
let buf = "";
|
|
152
|
+
try {
|
|
153
|
+
for (;;) {
|
|
154
|
+
const { done, value } = await reader.read();
|
|
155
|
+
if (done) {
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
buf += decoder.decode(value, { stream: true });
|
|
159
|
+
// SSE frames are separated by a blank line.
|
|
160
|
+
for (let idx = buf.indexOf("\n\n"); idx !== -1; idx = buf.indexOf("\n\n")) {
|
|
161
|
+
const frame = buf.slice(0, idx);
|
|
162
|
+
buf = buf.slice(idx + 2);
|
|
163
|
+
const lines = frame.split("\n");
|
|
164
|
+
const event = lines
|
|
165
|
+
.find((line) => line.startsWith("event:"))
|
|
166
|
+
?.slice(6)
|
|
167
|
+
.trim() ?? "";
|
|
168
|
+
const data = lines
|
|
169
|
+
.filter((line) => line.startsWith("data:"))
|
|
170
|
+
.map((line) => line.slice(5).trimStart())
|
|
171
|
+
.join("\n");
|
|
172
|
+
if (data) {
|
|
173
|
+
yield { event, data };
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
finally {
|
|
179
|
+
reader.releaseLock();
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
/** `?from=…&to=…`, omitting whichever the caller left out. */
|
|
183
|
+
const bookingWindow = (window) => {
|
|
184
|
+
const params = new URLSearchParams();
|
|
185
|
+
if (window?.from) {
|
|
186
|
+
params.set("from", window.from);
|
|
187
|
+
}
|
|
188
|
+
if (window?.to) {
|
|
189
|
+
params.set("to", window.to);
|
|
190
|
+
}
|
|
191
|
+
const query = params.toString();
|
|
192
|
+
return query === "" ? "" : `?${query}`;
|
|
193
|
+
};
|
|
136
194
|
export function createClient(options) {
|
|
137
195
|
const baseUrl = options.baseUrl.replace(/\/+$/, "");
|
|
138
196
|
const fetchFn = options.fetch ?? fetch;
|
|
139
197
|
function buildHeaders(init, isJson = true) {
|
|
140
198
|
const headers = { ...options.headers };
|
|
141
|
-
if (isJson)
|
|
199
|
+
if (isJson) {
|
|
142
200
|
headers["Content-Type"] = "application/json";
|
|
201
|
+
}
|
|
143
202
|
const extra = init?.headers;
|
|
144
203
|
if (extra) {
|
|
145
204
|
// SAFETY: SDK callers pass a string record, not a Headers instance.
|
|
146
205
|
Object.assign(headers, extra);
|
|
147
206
|
}
|
|
148
|
-
if (options.token)
|
|
207
|
+
if (options.token) {
|
|
149
208
|
headers["Authorization"] = `Bearer ${options.token}`;
|
|
150
|
-
|
|
209
|
+
}
|
|
210
|
+
if (options.tenantId) {
|
|
151
211
|
headers["X-Tenant-Id"] = options.tenantId;
|
|
212
|
+
}
|
|
152
213
|
return headers;
|
|
153
214
|
}
|
|
154
215
|
async function request(path, init) {
|
|
@@ -169,77 +230,28 @@ export function createClient(options) {
|
|
|
169
230
|
// the server is broken; the SDK does not re-validate it.
|
|
170
231
|
return body;
|
|
171
232
|
}
|
|
172
|
-
/** `?from=…&to=…`, omitting whichever the caller left out. */
|
|
173
|
-
const bookingWindow = (window) => {
|
|
174
|
-
const params = new URLSearchParams();
|
|
175
|
-
if (window?.from)
|
|
176
|
-
params.set("from", window.from);
|
|
177
|
-
if (window?.to)
|
|
178
|
-
params.set("to", window.to);
|
|
179
|
-
const query = params.toString();
|
|
180
|
-
return query === "" ? "" : `?${query}`;
|
|
181
|
-
};
|
|
182
233
|
const post = (path, input, headers) => request(path, { method: "POST", body: JSON.stringify(input ?? {}), headers });
|
|
183
234
|
const invoke = async (tool, input, opts) => {
|
|
184
235
|
const headers = {};
|
|
185
|
-
if (opts?.idempotencyKey)
|
|
236
|
+
if (opts?.idempotencyKey) {
|
|
186
237
|
headers["Idempotency-Key"] = opts.idempotencyKey;
|
|
238
|
+
}
|
|
187
239
|
const res = await post(`/v1/tools/${encodeURIComponent(tool)}:invoke`, input, headers);
|
|
188
240
|
return res.output;
|
|
189
241
|
};
|
|
190
|
-
/**
|
|
191
|
-
* Decodes an SSE body into `{ event, data }` frames. Comment lines
|
|
192
|
-
* (keepalives) and frames without a data payload are skipped.
|
|
193
|
-
*/
|
|
194
|
-
async function* sseFrames(body) {
|
|
195
|
-
const reader = body.getReader();
|
|
196
|
-
const decoder = new TextDecoder();
|
|
197
|
-
let buf = "";
|
|
198
|
-
try {
|
|
199
|
-
for (;;) {
|
|
200
|
-
const { done, value } = await reader.read();
|
|
201
|
-
if (done)
|
|
202
|
-
break;
|
|
203
|
-
buf += decoder.decode(value, { stream: true });
|
|
204
|
-
// SSE frames are separated by a blank line.
|
|
205
|
-
for (let idx = buf.indexOf("\n\n"); idx !== -1; idx = buf.indexOf("\n\n")) {
|
|
206
|
-
const frame = buf.slice(0, idx);
|
|
207
|
-
buf = buf.slice(idx + 2);
|
|
208
|
-
const lines = frame.split("\n");
|
|
209
|
-
const event = lines
|
|
210
|
-
.find((line) => line.startsWith("event:"))
|
|
211
|
-
?.slice(6)
|
|
212
|
-
.trim() ?? "";
|
|
213
|
-
const data = lines
|
|
214
|
-
.filter((line) => line.startsWith("data:"))
|
|
215
|
-
.map((line) => line.slice(5).trimStart())
|
|
216
|
-
.join("\n");
|
|
217
|
-
if (data)
|
|
218
|
-
yield { event, data };
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
finally {
|
|
223
|
-
reader.releaseLock();
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
/** Turns a non-2xx (or bodyless) stream response into an ApiError. */
|
|
227
|
-
async function streamError(res) {
|
|
228
|
-
const body = await parsedBody(res);
|
|
229
|
-
const error = isJsonObject(body) ? body : {};
|
|
230
|
-
throw new ApiError(res.status, isJsonText(error.code) ? error.code : "unknown", isJsonText(error.error) ? error.error : `stream failed with status ${res.status}`, body, fieldRefusalOf(error));
|
|
231
|
-
}
|
|
232
242
|
async function* streamEvents(opts) {
|
|
233
243
|
const res = await fetchFn(`${baseUrl}/v1/events/stream`, {
|
|
234
244
|
headers: buildHeaders(undefined, false),
|
|
235
245
|
signal: opts?.signal,
|
|
236
246
|
});
|
|
237
|
-
if (!res.ok || !res.body)
|
|
247
|
+
if (!res.ok || !res.body) {
|
|
238
248
|
await streamError(res);
|
|
249
|
+
}
|
|
239
250
|
for await (const frame of sseFrames(res.body)) {
|
|
240
251
|
const event = realtimeEventOf(frame.data);
|
|
241
|
-
if (event !== undefined)
|
|
252
|
+
if (event !== undefined) {
|
|
242
253
|
yield event;
|
|
254
|
+
}
|
|
243
255
|
}
|
|
244
256
|
}
|
|
245
257
|
const openRealtimeSocket = (options) => {
|
|
@@ -253,26 +265,31 @@ export function createClient(options) {
|
|
|
253
265
|
headers: buildHeaders(undefined, false),
|
|
254
266
|
signal: controller.signal,
|
|
255
267
|
});
|
|
256
|
-
if (!res.ok || !res.body)
|
|
268
|
+
if (!res.ok || !res.body) {
|
|
257
269
|
await streamError(res);
|
|
270
|
+
}
|
|
258
271
|
open = true;
|
|
259
272
|
failures = 0;
|
|
260
273
|
options.onOpen?.();
|
|
261
274
|
for await (const frame of sseFrames(res.body)) {
|
|
262
275
|
const event = realtimeEventOf(frame.data);
|
|
263
|
-
if (event !== undefined)
|
|
276
|
+
if (event !== undefined) {
|
|
264
277
|
options.onEvent(event);
|
|
278
|
+
}
|
|
265
279
|
}
|
|
266
280
|
}
|
|
267
281
|
catch {
|
|
268
282
|
// A refusal or a dropped connection: either way, try again.
|
|
269
283
|
}
|
|
270
|
-
if (controller.signal.aborted)
|
|
284
|
+
if (controller.signal.aborted) {
|
|
271
285
|
return;
|
|
272
|
-
|
|
286
|
+
}
|
|
287
|
+
if (open) {
|
|
273
288
|
options.onClose?.();
|
|
274
|
-
|
|
289
|
+
}
|
|
290
|
+
else {
|
|
275
291
|
failures += 1;
|
|
292
|
+
}
|
|
276
293
|
// Back off to half a minute; a workspace switch or sign-out closes for good.
|
|
277
294
|
await pause(streamRetryDelay(failures), controller.signal);
|
|
278
295
|
}
|
|
@@ -301,8 +318,9 @@ export function createClient(options) {
|
|
|
301
318
|
try {
|
|
302
319
|
for await (const frame of sseFrames(res.body)) {
|
|
303
320
|
const event = threadStreamEventOf(frame.data);
|
|
304
|
-
if (event?.thread_id === threadId)
|
|
321
|
+
if (event?.thread_id === threadId) {
|
|
305
322
|
yield event;
|
|
323
|
+
}
|
|
306
324
|
}
|
|
307
325
|
}
|
|
308
326
|
catch {
|
|
@@ -313,8 +331,9 @@ export function createClient(options) {
|
|
|
313
331
|
failures += 1;
|
|
314
332
|
await res?.body?.cancel();
|
|
315
333
|
}
|
|
316
|
-
if (signal?.aborted)
|
|
334
|
+
if (signal?.aborted) {
|
|
317
335
|
return;
|
|
336
|
+
}
|
|
318
337
|
await pause(streamRetryDelay(failures), signal);
|
|
319
338
|
}
|
|
320
339
|
}
|
|
@@ -371,10 +390,12 @@ export function createClient(options) {
|
|
|
371
390
|
updateMe: (input) => request("/v1/me", { method: "PATCH", body: JSON.stringify(input) }),
|
|
372
391
|
uploadMyAvatar: (file, opts) => {
|
|
373
392
|
const form = new FormData();
|
|
374
|
-
if (opts?.filename)
|
|
393
|
+
if (opts?.filename) {
|
|
375
394
|
form.append("file", file, opts.filename);
|
|
376
|
-
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
377
397
|
form.append("file", file);
|
|
398
|
+
}
|
|
378
399
|
return request("/v1/me/avatar", {
|
|
379
400
|
method: "POST",
|
|
380
401
|
body: form,
|
|
@@ -392,10 +413,12 @@ export function createClient(options) {
|
|
|
392
413
|
getDefinitionAvatar: (slug) => request(`/v1/agents/definition/${encodeURIComponent(slug)}/avatar`),
|
|
393
414
|
uploadAgentAvatar: (agentId, file, opts) => {
|
|
394
415
|
const form = new FormData();
|
|
395
|
-
if (opts?.filename)
|
|
416
|
+
if (opts?.filename) {
|
|
396
417
|
form.append("file", file, opts.filename);
|
|
397
|
-
|
|
418
|
+
}
|
|
419
|
+
else {
|
|
398
420
|
form.append("file", file);
|
|
421
|
+
}
|
|
399
422
|
return request(`/v1/agents/${encodeURIComponent(agentId)}/avatar`, {
|
|
400
423
|
method: "POST",
|
|
401
424
|
body: form,
|
|
@@ -471,10 +494,12 @@ export function createClient(options) {
|
|
|
471
494
|
composeEmail: (input) => invoke("email.compose", input),
|
|
472
495
|
uploadEmailAttachment: async (file, opts) => {
|
|
473
496
|
const form = new FormData();
|
|
474
|
-
if (opts?.filename)
|
|
497
|
+
if (opts?.filename) {
|
|
475
498
|
form.append("file", file, opts.filename);
|
|
476
|
-
|
|
499
|
+
}
|
|
500
|
+
else {
|
|
477
501
|
form.append("file", file);
|
|
502
|
+
}
|
|
478
503
|
return request("/v1/email/attachments", {
|
|
479
504
|
method: "POST",
|
|
480
505
|
body: form,
|
|
@@ -573,8 +598,9 @@ export function createClient(options) {
|
|
|
573
598
|
listEmailCampaigns: (input) => invoke("marketing.list_email_campaigns", input ?? {}),
|
|
574
599
|
getEmailCampaign: (campaignId, recipientsLimit) => {
|
|
575
600
|
const input = { campaign_id: campaignId };
|
|
576
|
-
if (recipientsLimit !== undefined)
|
|
601
|
+
if (recipientsLimit !== undefined) {
|
|
577
602
|
input.recipients_limit = recipientsLimit;
|
|
603
|
+
}
|
|
578
604
|
return invoke("marketing.get_email_campaign", input);
|
|
579
605
|
},
|
|
580
606
|
listEmailUnsubscribes: async (input) => {
|
|
@@ -677,10 +703,12 @@ export function createClient(options) {
|
|
|
677
703
|
cancelMarketingPost: (postId) => invoke("marketing.cancel_post", { post_id: postId }),
|
|
678
704
|
uploadMarketingMedia: (file, opts) => {
|
|
679
705
|
const form = new FormData();
|
|
680
|
-
if (opts?.filename)
|
|
706
|
+
if (opts?.filename) {
|
|
681
707
|
form.append("file", file, opts.filename);
|
|
682
|
-
|
|
708
|
+
}
|
|
709
|
+
else {
|
|
683
710
|
form.append("file", file);
|
|
711
|
+
}
|
|
684
712
|
return request("/v1/marketing/media", { method: "POST", body: form });
|
|
685
713
|
},
|
|
686
714
|
listMarketingConversations: async (input) => {
|
|
@@ -799,8 +827,9 @@ export function createClient(options) {
|
|
|
799
827
|
const response = await fetchFn(`${baseUrl}/v1/callcenter/recordings/${encodeURIComponent(recordingId)}`, {
|
|
800
828
|
headers: buildHeaders(range ? { headers: { Range: range } } : undefined, false),
|
|
801
829
|
});
|
|
802
|
-
if (!response.ok && response.status !== 416)
|
|
830
|
+
if (!response.ok && response.status !== 416) {
|
|
803
831
|
return streamError(response);
|
|
832
|
+
}
|
|
804
833
|
return response;
|
|
805
834
|
},
|
|
806
835
|
listWhatsAppTemplates: async (channelId) => {
|
|
@@ -840,7 +869,9 @@ export function createClient(options) {
|
|
|
840
869
|
myWork: (input) => invoke("projects.my_work", input ?? {}),
|
|
841
870
|
listEmailMessages: (input) => invoke("email.list_messages", input ?? {}),
|
|
842
871
|
emailSenderLogos: async (domains) => {
|
|
843
|
-
const res = await invoke("email.sender_logos", {
|
|
872
|
+
const res = await invoke("email.sender_logos", {
|
|
873
|
+
domains,
|
|
874
|
+
});
|
|
844
875
|
return res.logos ?? [];
|
|
845
876
|
},
|
|
846
877
|
listEmailTags: async () => {
|
|
@@ -868,10 +899,12 @@ export function createClient(options) {
|
|
|
868
899
|
listTools: async (opts) => {
|
|
869
900
|
const names = (opts?.names ?? []).filter(Boolean);
|
|
870
901
|
const params = new URLSearchParams();
|
|
871
|
-
if (names.length > 0)
|
|
902
|
+
if (names.length > 0) {
|
|
872
903
|
params.set("names", names.join(","));
|
|
873
|
-
|
|
904
|
+
}
|
|
905
|
+
if (opts?.callable) {
|
|
874
906
|
params.set("callable", "true");
|
|
907
|
+
}
|
|
875
908
|
const query = params.toString();
|
|
876
909
|
const res = await request(`/v1/tools${query === "" ? "" : `?${query}`}`);
|
|
877
910
|
return res.tools ?? [];
|
|
@@ -970,7 +1003,9 @@ export function createClient(options) {
|
|
|
970
1003
|
const res = await invoke("bank.payment_runs", input ?? {});
|
|
971
1004
|
return res.runs ?? [];
|
|
972
1005
|
},
|
|
973
|
-
getPaymentRun: (runId) => invoke("bank.payment_run", {
|
|
1006
|
+
getPaymentRun: (runId) => invoke("bank.payment_run", {
|
|
1007
|
+
run_id: runId,
|
|
1008
|
+
}),
|
|
974
1009
|
createPaymentRun: (input, opts) => invoke("bank.create_payment_run", input, opts),
|
|
975
1010
|
exportPaymentRun: (input, opts) => invoke("bank.export_payment_run", input, opts),
|
|
976
1011
|
settlePaymentRun: (input, opts) => invoke("bank.settle_payment_run", input, opts),
|
|
@@ -1027,22 +1062,30 @@ export function createClient(options) {
|
|
|
1027
1062
|
},
|
|
1028
1063
|
uploadDocument: (file, opts) => {
|
|
1029
1064
|
const form = new FormData();
|
|
1030
|
-
if (opts?.filename)
|
|
1065
|
+
if (opts?.filename) {
|
|
1031
1066
|
form.append("file", file, opts.filename);
|
|
1032
|
-
|
|
1067
|
+
}
|
|
1068
|
+
else {
|
|
1033
1069
|
form.append("file", file);
|
|
1034
|
-
|
|
1070
|
+
}
|
|
1071
|
+
if (opts?.kind) {
|
|
1035
1072
|
form.append("kind", opts.kind);
|
|
1036
|
-
|
|
1073
|
+
}
|
|
1074
|
+
if (opts?.partyId) {
|
|
1037
1075
|
form.append("party_id", opts.partyId);
|
|
1038
|
-
|
|
1076
|
+
}
|
|
1077
|
+
if (opts?.place?.space) {
|
|
1039
1078
|
form.append("space", opts.place.space);
|
|
1040
|
-
|
|
1079
|
+
}
|
|
1080
|
+
if (opts?.place?.folder_id) {
|
|
1041
1081
|
form.append("folder_id", opts.place.folder_id);
|
|
1042
|
-
|
|
1082
|
+
}
|
|
1083
|
+
if (opts?.place?.title) {
|
|
1043
1084
|
form.append("title", opts.place.title);
|
|
1044
|
-
|
|
1085
|
+
}
|
|
1086
|
+
if (opts?.generatedFor) {
|
|
1045
1087
|
form.append("generated_for", opts.generatedFor);
|
|
1088
|
+
}
|
|
1046
1089
|
return request("/v1/documents", { method: "POST", body: form });
|
|
1047
1090
|
},
|
|
1048
1091
|
beginUpload: (input) => request("/v1/uploads", { method: "POST", body: JSON.stringify(input) }),
|
|
@@ -1060,10 +1103,12 @@ export function createClient(options) {
|
|
|
1060
1103
|
},
|
|
1061
1104
|
uploadCompanyLogo: (file, opts) => {
|
|
1062
1105
|
const form = new FormData();
|
|
1063
|
-
if (opts?.filename)
|
|
1106
|
+
if (opts?.filename) {
|
|
1064
1107
|
form.append("file", file, opts.filename);
|
|
1065
|
-
|
|
1108
|
+
}
|
|
1109
|
+
else {
|
|
1066
1110
|
form.append("file", file);
|
|
1111
|
+
}
|
|
1067
1112
|
return request("/v1/company/logo", { method: "POST", body: form });
|
|
1068
1113
|
},
|
|
1069
1114
|
getCompanyLogo: () => request("/v1/company/logo"),
|
|
@@ -1144,10 +1189,12 @@ export function createClient(options) {
|
|
|
1144
1189
|
}),
|
|
1145
1190
|
uploadLiveDocumentAsset: (id, file, opts) => {
|
|
1146
1191
|
const form = new FormData();
|
|
1147
|
-
if (opts?.filename)
|
|
1192
|
+
if (opts?.filename) {
|
|
1148
1193
|
form.append("file", file, opts.filename);
|
|
1149
|
-
|
|
1194
|
+
}
|
|
1195
|
+
else {
|
|
1150
1196
|
form.append("file", file);
|
|
1197
|
+
}
|
|
1151
1198
|
return request(`/v1/live-documents/${encodeURIComponent(id)}/assets`, {
|
|
1152
1199
|
method: "POST",
|
|
1153
1200
|
body: form,
|
|
@@ -1155,30 +1202,35 @@ export function createClient(options) {
|
|
|
1155
1202
|
},
|
|
1156
1203
|
fetchLiveDocumentAsset: async (id, asset) => {
|
|
1157
1204
|
const response = await fetchFn(`${baseUrl}/v1/live-documents/${encodeURIComponent(id)}/assets/${encodeURIComponent(asset)}`, { headers: buildHeaders(undefined, false) });
|
|
1158
|
-
if (!response.ok)
|
|
1205
|
+
if (!response.ok) {
|
|
1159
1206
|
return streamError(response);
|
|
1207
|
+
}
|
|
1160
1208
|
return response;
|
|
1161
1209
|
},
|
|
1162
1210
|
downloadDocument: async (id) => {
|
|
1163
1211
|
const response = await fetchFn(`${baseUrl}/v1/documents/${encodeURIComponent(id)}/content`, {
|
|
1164
1212
|
headers: buildHeaders(undefined, false),
|
|
1165
1213
|
});
|
|
1166
|
-
if (!response.ok)
|
|
1214
|
+
if (!response.ok) {
|
|
1167
1215
|
return streamError(response);
|
|
1216
|
+
}
|
|
1168
1217
|
return response;
|
|
1169
1218
|
},
|
|
1170
1219
|
fileSyncChanges: (cursor, limit) => {
|
|
1171
1220
|
const input = {};
|
|
1172
|
-
if (cursor)
|
|
1221
|
+
if (cursor) {
|
|
1173
1222
|
input.cursor = cursor;
|
|
1174
|
-
|
|
1223
|
+
}
|
|
1224
|
+
if (limit !== undefined) {
|
|
1175
1225
|
input.limit = limit;
|
|
1226
|
+
}
|
|
1176
1227
|
return invoke("filesync.changes", input);
|
|
1177
1228
|
},
|
|
1178
1229
|
downloadFileSyncContent: async (id) => {
|
|
1179
1230
|
const response = await fetchFn(`${baseUrl}/v1/filesync/items/${encodeURIComponent(id)}/content`, { headers: buildHeaders(undefined, false) });
|
|
1180
|
-
if (!response.ok)
|
|
1231
|
+
if (!response.ok) {
|
|
1181
1232
|
return streamError(response);
|
|
1233
|
+
}
|
|
1182
1234
|
return response;
|
|
1183
1235
|
},
|
|
1184
1236
|
replaceFileSyncContent: (id, contentVersion, body) => request(`/v1/filesync/items/${encodeURIComponent(id)}/content`, {
|
|
@@ -1199,10 +1251,12 @@ export function createClient(options) {
|
|
|
1199
1251
|
id,
|
|
1200
1252
|
base_version: baseVersion,
|
|
1201
1253
|
};
|
|
1202
|
-
if (change.parentId)
|
|
1254
|
+
if (change.parentId) {
|
|
1203
1255
|
input.parent_id = change.parentId;
|
|
1204
|
-
|
|
1256
|
+
}
|
|
1257
|
+
if (change.name) {
|
|
1205
1258
|
input.name = change.name;
|
|
1259
|
+
}
|
|
1206
1260
|
return invoke("filesync.move", input);
|
|
1207
1261
|
},
|
|
1208
1262
|
deleteFileSyncItem: (id, baseVersion) => invoke("filesync.delete", {
|
|
@@ -1220,15 +1274,17 @@ export function createClient(options) {
|
|
|
1220
1274
|
downloadPublicTransferItem: async (token, item, key) => {
|
|
1221
1275
|
const query = key ? `?key=${encodeURIComponent(key)}` : "";
|
|
1222
1276
|
const response = await fetchFn(`${baseUrl}/v1/public/transfers/${encodeURIComponent(token)}/items/${encodeURIComponent(item)}${query}`, { headers: buildHeaders(undefined, false) });
|
|
1223
|
-
if (!response.ok)
|
|
1277
|
+
if (!response.ok) {
|
|
1224
1278
|
return streamError(response);
|
|
1279
|
+
}
|
|
1225
1280
|
return response;
|
|
1226
1281
|
},
|
|
1227
1282
|
downloadPublicTransferZip: async (token, key) => {
|
|
1228
1283
|
const query = key ? `?key=${encodeURIComponent(key)}` : "";
|
|
1229
1284
|
const response = await fetchFn(`${baseUrl}/v1/public/transfers/${encodeURIComponent(token)}/zip${query}`, { headers: buildHeaders(undefined, false) });
|
|
1230
|
-
if (!response.ok)
|
|
1285
|
+
if (!response.ok) {
|
|
1231
1286
|
return streamError(response);
|
|
1287
|
+
}
|
|
1232
1288
|
return response;
|
|
1233
1289
|
},
|
|
1234
1290
|
listDriveAccounts: async () => (await invoke("drives.list", {})).accounts,
|
|
@@ -1238,14 +1294,18 @@ export function createClient(options) {
|
|
|
1238
1294
|
disconnectDriveAccount: (id) => invoke("drives.disconnect", { account_id: id }),
|
|
1239
1295
|
listActions: (opts) => {
|
|
1240
1296
|
const params = new URLSearchParams();
|
|
1241
|
-
if (opts?.before !== undefined)
|
|
1297
|
+
if (opts?.before !== undefined) {
|
|
1242
1298
|
params.set("before", String(opts.before));
|
|
1243
|
-
|
|
1299
|
+
}
|
|
1300
|
+
else if (opts?.after !== undefined) {
|
|
1244
1301
|
params.set("after", String(opts.after));
|
|
1245
|
-
|
|
1302
|
+
}
|
|
1303
|
+
if (opts?.limit !== undefined) {
|
|
1246
1304
|
params.set("limit", String(opts.limit));
|
|
1247
|
-
|
|
1305
|
+
}
|
|
1306
|
+
if (opts?.actor_id) {
|
|
1248
1307
|
params.set("actor_id", opts.actor_id);
|
|
1308
|
+
}
|
|
1249
1309
|
const qs = params.toString();
|
|
1250
1310
|
return request(`/v1/actions${qs ? `?${qs}` : ""}`);
|
|
1251
1311
|
},
|
|
@@ -1428,10 +1488,12 @@ export function createClient(options) {
|
|
|
1428
1488
|
listMembers: async (opts) => {
|
|
1429
1489
|
const params = new URLSearchParams();
|
|
1430
1490
|
const q = opts?.q?.trim();
|
|
1431
|
-
if (q)
|
|
1491
|
+
if (q) {
|
|
1432
1492
|
params.set("q", q);
|
|
1433
|
-
|
|
1493
|
+
}
|
|
1494
|
+
if (opts?.limit !== null && opts?.limit !== undefined) {
|
|
1434
1495
|
params.set("limit", String(opts.limit));
|
|
1496
|
+
}
|
|
1435
1497
|
const qs = params.toString();
|
|
1436
1498
|
const res = await request(`/v1/members${qs ? `?${qs}` : ""}`);
|
|
1437
1499
|
return res.members ?? [];
|
|
@@ -1470,8 +1532,9 @@ export function createClient(options) {
|
|
|
1470
1532
|
const response = await fetchFn(`${baseUrl}/v1/call-recordings/${encodeURIComponent(recordingId)}`, {
|
|
1471
1533
|
headers: buildHeaders(range ? { headers: { Range: range } } : undefined, false),
|
|
1472
1534
|
});
|
|
1473
|
-
if (!response.ok && response.status !== 416)
|
|
1535
|
+
if (!response.ok && response.status !== 416) {
|
|
1474
1536
|
return streamError(response);
|
|
1537
|
+
}
|
|
1475
1538
|
return response;
|
|
1476
1539
|
},
|
|
1477
1540
|
listCalls: async () => {
|
|
@@ -1510,8 +1573,9 @@ export function createClient(options) {
|
|
|
1510
1573
|
const response = await fetchFn(`${baseUrl}/v1/public/calls/${encodeURIComponent(token)}/logo`, {
|
|
1511
1574
|
headers: buildHeaders(undefined, false),
|
|
1512
1575
|
});
|
|
1513
|
-
if (!response.ok)
|
|
1576
|
+
if (!response.ok) {
|
|
1514
1577
|
return streamError(response);
|
|
1578
|
+
}
|
|
1515
1579
|
return response;
|
|
1516
1580
|
},
|
|
1517
1581
|
getPublicCallCenterQueue: async (key) => (await request(`/v1/public/callcenter/${encodeURIComponent(key)}`)).queue,
|
|
@@ -1532,16 +1596,18 @@ export function createClient(options) {
|
|
|
1532
1596
|
postCallMessage: (input, opts) => invoke("calls.post_message", input, opts),
|
|
1533
1597
|
listCallMessages: async (callId, after) => {
|
|
1534
1598
|
const input = { call_id: callId };
|
|
1535
|
-
if (after)
|
|
1599
|
+
if (after) {
|
|
1536
1600
|
input.after = after;
|
|
1601
|
+
}
|
|
1537
1602
|
const res = await invoke("calls.list_messages", input);
|
|
1538
1603
|
return res.messages ?? [];
|
|
1539
1604
|
},
|
|
1540
1605
|
recordCallTranscript: (input, opts) => invoke("calls.record_transcript", input, opts),
|
|
1541
1606
|
listCallTranscript: async (callId, after) => {
|
|
1542
1607
|
const input = { call_id: callId };
|
|
1543
|
-
if (after)
|
|
1608
|
+
if (after) {
|
|
1544
1609
|
input.after = after;
|
|
1610
|
+
}
|
|
1545
1611
|
const res = await invoke("calls.list_transcript", input);
|
|
1546
1612
|
return res.segments ?? [];
|
|
1547
1613
|
},
|