glitchgrab 1.64.0 → 1.65.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -2
- package/dist/server.d.mts +44 -15
- package/dist/server.d.ts +44 -15
- package/dist/server.js +22 -9
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +22 -9
- package/dist/server.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -406,7 +406,10 @@ A caller your key added is rung only on phones they confirmed with press 1 — n
|
|
|
406
406
|
If your product sells calling to its own customers (each CA firm on PracticeStacks), each customer gets its own number, rented under its own KYC — set up entirely from your product:
|
|
407
407
|
|
|
408
408
|
```ts
|
|
409
|
-
import {
|
|
409
|
+
import {
|
|
410
|
+
submitPhoneKyc, enableCalling, getPhoneLine, addLineCaller, placeCall, registerWebhook,
|
|
411
|
+
addRingNumber, listRingNumbers, testRingNumber, removeLineCaller,
|
|
412
|
+
} from "glitchgrab/server";
|
|
410
413
|
|
|
411
414
|
// once, at deploy: get call.* and phone.* events
|
|
412
415
|
await registerWebhook({ url: "https://you.com/glitchgrab", events: ["phone.kyc_status", "phone.line_ready", "call.completed"] });
|
|
@@ -419,6 +422,11 @@ await enableCalling({ ownerId: firm.id, agreedBy: owner.email, areaCode: "20" })
|
|
|
419
422
|
|
|
420
423
|
const status = await getPhoneLine({ ownerId: firm.id }); // { line, request: { kycStatus, kycReason, enabled, buyState } }
|
|
421
424
|
await addLineCaller({ email: staff.email, name: staff.name, ownerId: firm.id });
|
|
425
|
+
// everything about one person on a line takes { ownerId } as its last argument
|
|
426
|
+
await addRingNumber({ email: staff.email }, { phone: staff.phone }, { ownerId: firm.id }); // test-rings from the firm's number
|
|
427
|
+
await listRingNumbers({ email: staff.email }, { ownerId: firm.id });
|
|
428
|
+
await testRingNumber(numberId, { ownerId: firm.id }); // retry a failed test ring
|
|
429
|
+
await removeLineCaller(staff.email, { ownerId: firm.id }); // only this firm's seat
|
|
422
430
|
const r = await placeCall({
|
|
423
431
|
operator: { email: staff.email },
|
|
424
432
|
to: client.phone,
|
|
@@ -427,7 +435,7 @@ const r = await placeCall({
|
|
|
427
435
|
});
|
|
428
436
|
```
|
|
429
437
|
|
|
430
|
-
Check your own "may this person call" permission before `placeCall`; Glitchgrab only checks the line seat. Every `call.*` webhook (`call.started`, `call.answered`, `call.completed`, `call.recording_ready`, `call.summary_ready`) carries `refKey` and `ownerId`. `getCall(r.callId)` returns the recording.
|
|
438
|
+
Check your own "may this person call" permission before `placeCall`; Glitchgrab only checks the line seat. Every `call.*` webhook (`call.started`, `call.answered`, `call.completed`, `call.recording_ready`, `call.summary_ready`) carries `refKey` and `ownerId`. `getCall(r.callId)` returns the recording (fresh signed links; the webhook carries none).
|
|
431
439
|
|
|
432
440
|
### Call another number, and see who missed it
|
|
433
441
|
|
package/dist/server.d.mts
CHANGED
|
@@ -322,7 +322,8 @@ type DeleteCallResult = {
|
|
|
322
322
|
};
|
|
323
323
|
/**
|
|
324
324
|
* Calls shared with the client on the key's project, newest first. No links —
|
|
325
|
-
* open one with {@link getCall}.
|
|
325
|
+
* open one with {@link getCall}. Every {@link placeCall} call is shared from
|
|
326
|
+
* the start, firm lines (`ownerId`) included.
|
|
326
327
|
*
|
|
327
328
|
* ```ts
|
|
328
329
|
* // app/admin/calls/page.tsx — server component
|
|
@@ -342,6 +343,11 @@ declare function listCalls(options?: ListCallsOptions): Promise<CallListItem[]>;
|
|
|
342
343
|
* Links expire after `linksExpireInSeconds` — read the call when the page
|
|
343
344
|
* renders and never store them.
|
|
344
345
|
*
|
|
346
|
+
* A {@link placeCall} call is shared from the start, so `getCall(callId)` with
|
|
347
|
+
* the `callId` from `placeCall` or any `call.*` webhook plays its recording —
|
|
348
|
+
* firm lines (`ownerId`) included (#723). `call.recording_ready` carries no
|
|
349
|
+
* link on purpose: fetch a fresh one here when someone presses play.
|
|
350
|
+
*
|
|
345
351
|
* Returns `null` when the call does not exist, is not shared, and on any
|
|
346
352
|
* failure — call `notFound()` on it. Never throws.
|
|
347
353
|
*/
|
|
@@ -863,18 +869,28 @@ type OperatorRingNumbersResult = {
|
|
|
863
869
|
error: string;
|
|
864
870
|
code?: string;
|
|
865
871
|
};
|
|
872
|
+
/**
|
|
873
|
+
* Options for calls about one person on a line. `ownerId` = that customer's own
|
|
874
|
+
* line (#723 — one line per PracticeStacks firm, the same id you pass to
|
|
875
|
+
* {@link addLineCaller}): the person must sit on it, and test rings come from
|
|
876
|
+
* its number. Omitted = any of the project's lines.
|
|
877
|
+
*/
|
|
878
|
+
interface LineCallsOptions extends CallsOptions {
|
|
879
|
+
ownerId?: string;
|
|
880
|
+
}
|
|
866
881
|
/**
|
|
867
882
|
* The phones Glitchgrab can ring for one person on the project's phone line —
|
|
868
883
|
* for a "Ring me on: [Default ▾]" picker beside your Call button. Verified
|
|
869
884
|
* numbers only. `numbers: []` = dial will refuse with `NO_VERIFIED_NUMBER`;
|
|
870
|
-
* not on the line = `{ ok: false, code: "NOT_ON_LINE" }`.
|
|
885
|
+
* not on the line = `{ ok: false, code: "NOT_ON_LINE" }`. Pass `{ ownerId }`
|
|
886
|
+
* for someone on a customer's line. Never throws.
|
|
871
887
|
*
|
|
872
888
|
* ```ts
|
|
873
889
|
* const r = await getOperatorRingNumbers({ email: admin.email }); // GLITCHGRAB_CALLS_KEY=ggc_…
|
|
874
890
|
* if (r.ok) render(r.numbers); // pass the chosen phone to dialFollowUp(…, { ringPhone })
|
|
875
891
|
* ```
|
|
876
892
|
*/
|
|
877
|
-
declare function getOperatorRingNumbers(operator: FollowUpOperator, options?:
|
|
893
|
+
declare function getOperatorRingNumbers(operator: FollowUpOperator, options?: LineCallsOptions): Promise<OperatorRingNumbersResult>;
|
|
878
894
|
type LineCallerResult = {
|
|
879
895
|
ok: true;
|
|
880
896
|
created: boolean;
|
|
@@ -1006,6 +1022,7 @@ type PlaceCallResult = {
|
|
|
1006
1022
|
* same `ownerId`). `refKey` = your own key for what the call is about — every
|
|
1007
1023
|
* `call.*` webhook (`call.started`, `call.answered`, `call.completed`,
|
|
1008
1024
|
* `call.recording_ready`, `call.summary_ready`) carries it back with `ownerId`.
|
|
1025
|
+
* The recording plays through {@link getCall}(`callId`).
|
|
1009
1026
|
* Check your own permissions before calling this. Refusals carry `code`:
|
|
1010
1027
|
* `NOT_ON_LINE`, `NO_VERIFIED_NUMBER`, `RING_PHONE_NOT_YOURS`. Never throws.
|
|
1011
1028
|
*
|
|
@@ -1147,9 +1164,17 @@ declare function removeWebhook(id: string, options?: CallsOptions): Promise<{
|
|
|
1147
1164
|
/**
|
|
1148
1165
|
* Take a caller your key added off the line, with the phones kept for them —
|
|
1149
1166
|
* e.g. when they leave your admin team. Someone the line's owner added →
|
|
1150
|
-
* `code: "NOT_KEY_CALLER"`. Never throws.
|
|
1167
|
+
* `code: "NOT_KEY_CALLER"`; not on it → `code: "NOT_ON_LINE"`. Never throws.
|
|
1168
|
+
*
|
|
1169
|
+
* `{ ownerId }` = only their seat on that customer's line (#723): staff of two
|
|
1170
|
+
* firms keep the other one, and access + phones go with their last seat.
|
|
1171
|
+
* Omitted = off every line of the project.
|
|
1172
|
+
*
|
|
1173
|
+
* ```ts
|
|
1174
|
+
* await removeLineCaller(staff.email, { ownerId: firm.id });
|
|
1175
|
+
* ```
|
|
1151
1176
|
*/
|
|
1152
|
-
declare function removeLineCaller(email: string, options?:
|
|
1177
|
+
declare function removeLineCaller(email: string, options?: LineCallsOptions): Promise<RingNumberWriteResult>;
|
|
1153
1178
|
/** One saved ring number, verified or not — the management view (#654). */
|
|
1154
1179
|
interface RingNumber {
|
|
1155
1180
|
id: string;
|
|
@@ -1184,34 +1209,38 @@ type RingNumberWriteResult<T = object> = ({
|
|
|
1184
1209
|
* — for your "manage my phones" screen. Ring numbers are managed only from
|
|
1185
1210
|
* your product; Glitchgrab shows them read-only. A refusal carries `code`
|
|
1186
1211
|
* (`NOT_ON_LINE`), so "not on the line" reads differently from "network down".
|
|
1187
|
-
* Never throws.
|
|
1212
|
+
* `{ ownerId }` for someone on a customer's line. Never throws.
|
|
1188
1213
|
*/
|
|
1189
|
-
declare function listRingNumbers(operator: FollowUpOperator, options?:
|
|
1214
|
+
declare function listRingNumbers(operator: FollowUpOperator, options?: LineCallsOptions): Promise<RingNumberWriteResult<RingNumberList>>;
|
|
1190
1215
|
/**
|
|
1191
1216
|
* Save a phone for `operator` and place its test ring at once: the project's
|
|
1192
1217
|
* line calls it and whoever holds it presses 1. Never rung for a call until
|
|
1193
1218
|
* then; the line's owner is alerted when it is verified. Max 5 per person.
|
|
1194
1219
|
* `testRing: "failed"` = saved but not rung — retry with {@link testRingNumber}.
|
|
1220
|
+
* `{ ownerId }` = they sit on that customer's line, and its number test-rings.
|
|
1195
1221
|
*/
|
|
1196
1222
|
declare function addRingNumber(operator: FollowUpOperator, number: {
|
|
1197
1223
|
phone: string;
|
|
1198
1224
|
label?: string;
|
|
1199
|
-
}, options?:
|
|
1225
|
+
}, options?: LineCallsOptions): Promise<RingNumberWriteResult<{
|
|
1200
1226
|
id: string;
|
|
1201
1227
|
testRing: "ringing" | "failed";
|
|
1202
1228
|
verifyError: string | null;
|
|
1203
1229
|
}>>;
|
|
1204
|
-
/** Rename, make Default (verified only) or move one place up/down. Never throws. */
|
|
1230
|
+
/** Rename, make Default (verified only) or move one place up/down. `{ ownerId }` as in {@link LineCallsOptions}. Never throws. */
|
|
1205
1231
|
declare function updateRingNumber(id: string, change: {
|
|
1206
1232
|
label?: string | null;
|
|
1207
1233
|
makeDefault?: true;
|
|
1208
1234
|
move?: "up" | "down";
|
|
1209
|
-
}, options?:
|
|
1210
|
-
/** Remove one; the next verified number becomes Default. Never throws. */
|
|
1211
|
-
declare function removeRingNumber(id: string, options?:
|
|
1212
|
-
/**
|
|
1213
|
-
|
|
1235
|
+
}, options?: LineCallsOptions): Promise<RingNumberWriteResult>;
|
|
1236
|
+
/** Remove one; the next verified number becomes Default. `{ ownerId }` as in {@link LineCallsOptions}. Never throws. */
|
|
1237
|
+
declare function removeRingNumber(id: string, options?: LineCallsOptions): Promise<RingNumberWriteResult>;
|
|
1238
|
+
/**
|
|
1239
|
+
* Place the test ring again (6 per person, 30 per project an hour). `{ ownerId }`
|
|
1240
|
+
* = rings from that customer's line, e.g. retrying a firm caller's failed ring. Never throws.
|
|
1241
|
+
*/
|
|
1242
|
+
declare function testRingNumber(id: string, options?: LineCallsOptions): Promise<RingNumberWriteResult<{
|
|
1214
1243
|
verified: boolean;
|
|
1215
1244
|
}>>;
|
|
1216
1245
|
|
|
1217
|
-
export { type Booking, type BookingAnswer, type BookingClientNotice, type BookingMutationResult, type BookingNotifyRecipient, type BookingQuestion, type BookingQuestionInput, type BookingSettings, type BookingSettingsChanges, type BookingSettingsResult, type BookingSettingsState, type BookingWorkingHours, type Call, type CallAudio, type CallListItem, type CallMoment, type CallParticipant, type CallWebhook, type CallsOptions, type CaptureServerErrorsOptions, type DeleteCallResult, type FollowUp, type FollowUpBooking, type FollowUpCall, type FollowUpDetail, type FollowUpDue, type FollowUpNote, type FollowUpOperator, type FollowUpWriteResult, type GetCallOptions, type Guide, type GuideReadOptions, type GuideSummary, type Lead, type LineCallerResult, type LineRequestResult, type ListBookingsOptions, type ListCallsOptions, type ListLeadsOptions, type OperatorRingNumber, type OperatorRingNumbersResult, type PhoneLineInfo, type PhoneLineRequest, type PhoneLineStatus, type PhoneLineWebhook, type PlaceCallResult, type RegisteredWebhook, ReportResult, ReportSeverity, ReportType, type RingErrorCode, type RingNumber, type RingNumberList, type RingNumberWriteResult, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, addLineCaller, addRingNumber, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, disableCalling, discardBookingQuestionsDraft, editFollowUpNote, enableCalling, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, getOperatorRingNumbers, getPhoneLine, listBookings, listCalls, listFollowUps, listGuides, listLeads, listRingNumbers, listWebhooks, placeCall, publishBookingQuestions, registerWebhook, removeLineCaller, removeRingNumber, removeWebhook, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, submitPhoneKyc, testRingNumber, updateBookingSettings, updateRingNumber };
|
|
1246
|
+
export { type Booking, type BookingAnswer, type BookingClientNotice, type BookingMutationResult, type BookingNotifyRecipient, type BookingQuestion, type BookingQuestionInput, type BookingSettings, type BookingSettingsChanges, type BookingSettingsResult, type BookingSettingsState, type BookingWorkingHours, type Call, type CallAudio, type CallListItem, type CallMoment, type CallParticipant, type CallWebhook, type CallsOptions, type CaptureServerErrorsOptions, type DeleteCallResult, type FollowUp, type FollowUpBooking, type FollowUpCall, type FollowUpDetail, type FollowUpDue, type FollowUpNote, type FollowUpOperator, type FollowUpWriteResult, type GetCallOptions, type Guide, type GuideReadOptions, type GuideSummary, type Lead, type LineCallerResult, type LineCallsOptions, type LineRequestResult, type ListBookingsOptions, type ListCallsOptions, type ListLeadsOptions, type OperatorRingNumber, type OperatorRingNumbersResult, type PhoneLineInfo, type PhoneLineRequest, type PhoneLineStatus, type PhoneLineWebhook, type PlaceCallResult, type RegisteredWebhook, ReportResult, ReportSeverity, ReportType, type RingErrorCode, type RingNumber, type RingNumberList, type RingNumberWriteResult, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, addLineCaller, addRingNumber, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, disableCalling, discardBookingQuestionsDraft, editFollowUpNote, enableCalling, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, getOperatorRingNumbers, getPhoneLine, listBookings, listCalls, listFollowUps, listGuides, listLeads, listRingNumbers, listWebhooks, placeCall, publishBookingQuestions, registerWebhook, removeLineCaller, removeRingNumber, removeWebhook, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, submitPhoneKyc, testRingNumber, updateBookingSettings, updateRingNumber };
|
package/dist/server.d.ts
CHANGED
|
@@ -322,7 +322,8 @@ type DeleteCallResult = {
|
|
|
322
322
|
};
|
|
323
323
|
/**
|
|
324
324
|
* Calls shared with the client on the key's project, newest first. No links —
|
|
325
|
-
* open one with {@link getCall}.
|
|
325
|
+
* open one with {@link getCall}. Every {@link placeCall} call is shared from
|
|
326
|
+
* the start, firm lines (`ownerId`) included.
|
|
326
327
|
*
|
|
327
328
|
* ```ts
|
|
328
329
|
* // app/admin/calls/page.tsx — server component
|
|
@@ -342,6 +343,11 @@ declare function listCalls(options?: ListCallsOptions): Promise<CallListItem[]>;
|
|
|
342
343
|
* Links expire after `linksExpireInSeconds` — read the call when the page
|
|
343
344
|
* renders and never store them.
|
|
344
345
|
*
|
|
346
|
+
* A {@link placeCall} call is shared from the start, so `getCall(callId)` with
|
|
347
|
+
* the `callId` from `placeCall` or any `call.*` webhook plays its recording —
|
|
348
|
+
* firm lines (`ownerId`) included (#723). `call.recording_ready` carries no
|
|
349
|
+
* link on purpose: fetch a fresh one here when someone presses play.
|
|
350
|
+
*
|
|
345
351
|
* Returns `null` when the call does not exist, is not shared, and on any
|
|
346
352
|
* failure — call `notFound()` on it. Never throws.
|
|
347
353
|
*/
|
|
@@ -863,18 +869,28 @@ type OperatorRingNumbersResult = {
|
|
|
863
869
|
error: string;
|
|
864
870
|
code?: string;
|
|
865
871
|
};
|
|
872
|
+
/**
|
|
873
|
+
* Options for calls about one person on a line. `ownerId` = that customer's own
|
|
874
|
+
* line (#723 — one line per PracticeStacks firm, the same id you pass to
|
|
875
|
+
* {@link addLineCaller}): the person must sit on it, and test rings come from
|
|
876
|
+
* its number. Omitted = any of the project's lines.
|
|
877
|
+
*/
|
|
878
|
+
interface LineCallsOptions extends CallsOptions {
|
|
879
|
+
ownerId?: string;
|
|
880
|
+
}
|
|
866
881
|
/**
|
|
867
882
|
* The phones Glitchgrab can ring for one person on the project's phone line —
|
|
868
883
|
* for a "Ring me on: [Default ▾]" picker beside your Call button. Verified
|
|
869
884
|
* numbers only. `numbers: []` = dial will refuse with `NO_VERIFIED_NUMBER`;
|
|
870
|
-
* not on the line = `{ ok: false, code: "NOT_ON_LINE" }`.
|
|
885
|
+
* not on the line = `{ ok: false, code: "NOT_ON_LINE" }`. Pass `{ ownerId }`
|
|
886
|
+
* for someone on a customer's line. Never throws.
|
|
871
887
|
*
|
|
872
888
|
* ```ts
|
|
873
889
|
* const r = await getOperatorRingNumbers({ email: admin.email }); // GLITCHGRAB_CALLS_KEY=ggc_…
|
|
874
890
|
* if (r.ok) render(r.numbers); // pass the chosen phone to dialFollowUp(…, { ringPhone })
|
|
875
891
|
* ```
|
|
876
892
|
*/
|
|
877
|
-
declare function getOperatorRingNumbers(operator: FollowUpOperator, options?:
|
|
893
|
+
declare function getOperatorRingNumbers(operator: FollowUpOperator, options?: LineCallsOptions): Promise<OperatorRingNumbersResult>;
|
|
878
894
|
type LineCallerResult = {
|
|
879
895
|
ok: true;
|
|
880
896
|
created: boolean;
|
|
@@ -1006,6 +1022,7 @@ type PlaceCallResult = {
|
|
|
1006
1022
|
* same `ownerId`). `refKey` = your own key for what the call is about — every
|
|
1007
1023
|
* `call.*` webhook (`call.started`, `call.answered`, `call.completed`,
|
|
1008
1024
|
* `call.recording_ready`, `call.summary_ready`) carries it back with `ownerId`.
|
|
1025
|
+
* The recording plays through {@link getCall}(`callId`).
|
|
1009
1026
|
* Check your own permissions before calling this. Refusals carry `code`:
|
|
1010
1027
|
* `NOT_ON_LINE`, `NO_VERIFIED_NUMBER`, `RING_PHONE_NOT_YOURS`. Never throws.
|
|
1011
1028
|
*
|
|
@@ -1147,9 +1164,17 @@ declare function removeWebhook(id: string, options?: CallsOptions): Promise<{
|
|
|
1147
1164
|
/**
|
|
1148
1165
|
* Take a caller your key added off the line, with the phones kept for them —
|
|
1149
1166
|
* e.g. when they leave your admin team. Someone the line's owner added →
|
|
1150
|
-
* `code: "NOT_KEY_CALLER"`. Never throws.
|
|
1167
|
+
* `code: "NOT_KEY_CALLER"`; not on it → `code: "NOT_ON_LINE"`. Never throws.
|
|
1168
|
+
*
|
|
1169
|
+
* `{ ownerId }` = only their seat on that customer's line (#723): staff of two
|
|
1170
|
+
* firms keep the other one, and access + phones go with their last seat.
|
|
1171
|
+
* Omitted = off every line of the project.
|
|
1172
|
+
*
|
|
1173
|
+
* ```ts
|
|
1174
|
+
* await removeLineCaller(staff.email, { ownerId: firm.id });
|
|
1175
|
+
* ```
|
|
1151
1176
|
*/
|
|
1152
|
-
declare function removeLineCaller(email: string, options?:
|
|
1177
|
+
declare function removeLineCaller(email: string, options?: LineCallsOptions): Promise<RingNumberWriteResult>;
|
|
1153
1178
|
/** One saved ring number, verified or not — the management view (#654). */
|
|
1154
1179
|
interface RingNumber {
|
|
1155
1180
|
id: string;
|
|
@@ -1184,34 +1209,38 @@ type RingNumberWriteResult<T = object> = ({
|
|
|
1184
1209
|
* — for your "manage my phones" screen. Ring numbers are managed only from
|
|
1185
1210
|
* your product; Glitchgrab shows them read-only. A refusal carries `code`
|
|
1186
1211
|
* (`NOT_ON_LINE`), so "not on the line" reads differently from "network down".
|
|
1187
|
-
* Never throws.
|
|
1212
|
+
* `{ ownerId }` for someone on a customer's line. Never throws.
|
|
1188
1213
|
*/
|
|
1189
|
-
declare function listRingNumbers(operator: FollowUpOperator, options?:
|
|
1214
|
+
declare function listRingNumbers(operator: FollowUpOperator, options?: LineCallsOptions): Promise<RingNumberWriteResult<RingNumberList>>;
|
|
1190
1215
|
/**
|
|
1191
1216
|
* Save a phone for `operator` and place its test ring at once: the project's
|
|
1192
1217
|
* line calls it and whoever holds it presses 1. Never rung for a call until
|
|
1193
1218
|
* then; the line's owner is alerted when it is verified. Max 5 per person.
|
|
1194
1219
|
* `testRing: "failed"` = saved but not rung — retry with {@link testRingNumber}.
|
|
1220
|
+
* `{ ownerId }` = they sit on that customer's line, and its number test-rings.
|
|
1195
1221
|
*/
|
|
1196
1222
|
declare function addRingNumber(operator: FollowUpOperator, number: {
|
|
1197
1223
|
phone: string;
|
|
1198
1224
|
label?: string;
|
|
1199
|
-
}, options?:
|
|
1225
|
+
}, options?: LineCallsOptions): Promise<RingNumberWriteResult<{
|
|
1200
1226
|
id: string;
|
|
1201
1227
|
testRing: "ringing" | "failed";
|
|
1202
1228
|
verifyError: string | null;
|
|
1203
1229
|
}>>;
|
|
1204
|
-
/** Rename, make Default (verified only) or move one place up/down. Never throws. */
|
|
1230
|
+
/** Rename, make Default (verified only) or move one place up/down. `{ ownerId }` as in {@link LineCallsOptions}. Never throws. */
|
|
1205
1231
|
declare function updateRingNumber(id: string, change: {
|
|
1206
1232
|
label?: string | null;
|
|
1207
1233
|
makeDefault?: true;
|
|
1208
1234
|
move?: "up" | "down";
|
|
1209
|
-
}, options?:
|
|
1210
|
-
/** Remove one; the next verified number becomes Default. Never throws. */
|
|
1211
|
-
declare function removeRingNumber(id: string, options?:
|
|
1212
|
-
/**
|
|
1213
|
-
|
|
1235
|
+
}, options?: LineCallsOptions): Promise<RingNumberWriteResult>;
|
|
1236
|
+
/** Remove one; the next verified number becomes Default. `{ ownerId }` as in {@link LineCallsOptions}. Never throws. */
|
|
1237
|
+
declare function removeRingNumber(id: string, options?: LineCallsOptions): Promise<RingNumberWriteResult>;
|
|
1238
|
+
/**
|
|
1239
|
+
* Place the test ring again (6 per person, 30 per project an hour). `{ ownerId }`
|
|
1240
|
+
* = rings from that customer's line, e.g. retrying a firm caller's failed ring. Never throws.
|
|
1241
|
+
*/
|
|
1242
|
+
declare function testRingNumber(id: string, options?: LineCallsOptions): Promise<RingNumberWriteResult<{
|
|
1214
1243
|
verified: boolean;
|
|
1215
1244
|
}>>;
|
|
1216
1245
|
|
|
1217
|
-
export { type Booking, type BookingAnswer, type BookingClientNotice, type BookingMutationResult, type BookingNotifyRecipient, type BookingQuestion, type BookingQuestionInput, type BookingSettings, type BookingSettingsChanges, type BookingSettingsResult, type BookingSettingsState, type BookingWorkingHours, type Call, type CallAudio, type CallListItem, type CallMoment, type CallParticipant, type CallWebhook, type CallsOptions, type CaptureServerErrorsOptions, type DeleteCallResult, type FollowUp, type FollowUpBooking, type FollowUpCall, type FollowUpDetail, type FollowUpDue, type FollowUpNote, type FollowUpOperator, type FollowUpWriteResult, type GetCallOptions, type Guide, type GuideReadOptions, type GuideSummary, type Lead, type LineCallerResult, type LineRequestResult, type ListBookingsOptions, type ListCallsOptions, type ListLeadsOptions, type OperatorRingNumber, type OperatorRingNumbersResult, type PhoneLineInfo, type PhoneLineRequest, type PhoneLineStatus, type PhoneLineWebhook, type PlaceCallResult, type RegisteredWebhook, ReportResult, ReportSeverity, ReportType, type RingErrorCode, type RingNumber, type RingNumberList, type RingNumberWriteResult, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, addLineCaller, addRingNumber, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, disableCalling, discardBookingQuestionsDraft, editFollowUpNote, enableCalling, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, getOperatorRingNumbers, getPhoneLine, listBookings, listCalls, listFollowUps, listGuides, listLeads, listRingNumbers, listWebhooks, placeCall, publishBookingQuestions, registerWebhook, removeLineCaller, removeRingNumber, removeWebhook, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, submitPhoneKyc, testRingNumber, updateBookingSettings, updateRingNumber };
|
|
1246
|
+
export { type Booking, type BookingAnswer, type BookingClientNotice, type BookingMutationResult, type BookingNotifyRecipient, type BookingQuestion, type BookingQuestionInput, type BookingSettings, type BookingSettingsChanges, type BookingSettingsResult, type BookingSettingsState, type BookingWorkingHours, type Call, type CallAudio, type CallListItem, type CallMoment, type CallParticipant, type CallWebhook, type CallsOptions, type CaptureServerErrorsOptions, type DeleteCallResult, type FollowUp, type FollowUpBooking, type FollowUpCall, type FollowUpDetail, type FollowUpDue, type FollowUpNote, type FollowUpOperator, type FollowUpWriteResult, type GetCallOptions, type Guide, type GuideReadOptions, type GuideSummary, type Lead, type LineCallerResult, type LineCallsOptions, type LineRequestResult, type ListBookingsOptions, type ListCallsOptions, type ListLeadsOptions, type OperatorRingNumber, type OperatorRingNumbersResult, type PhoneLineInfo, type PhoneLineRequest, type PhoneLineStatus, type PhoneLineWebhook, type PlaceCallResult, type RegisteredWebhook, ReportResult, ReportSeverity, ReportType, type RingErrorCode, type RingNumber, type RingNumberList, type RingNumberWriteResult, type ServerReportOptions, type ServerReporterConfig, type ServerReporterIdentity, type SignSessionOptions, addFollowUpNote, addLineCaller, addRingNumber, cancelBooking, captureServerErrors, configureServerReporter, deleteCall, dialFollowUp, disableCalling, discardBookingQuestionsDraft, editFollowUpNote, enableCalling, escapeJsonForScript, getBookingSettings, getCall, getFollowUp, getGuide, getOperatorRingNumbers, getPhoneLine, listBookings, listCalls, listFollowUps, listGuides, listLeads, listRingNumbers, listWebhooks, placeCall, publishBookingQuestions, registerWebhook, removeLineCaller, removeRingNumber, removeWebhook, reportServerError, rescheduleBooking, resetServerReporter, setFollowUpBooking, signSession, submitPhoneKyc, testRingNumber, updateBookingSettings, updateRingNumber };
|
package/dist/server.js
CHANGED
|
@@ -896,12 +896,19 @@ function dialFollowUp(externalId, call, options = {}) {
|
|
|
896
896
|
ringNumbers: Array.isArray(d.ringNumbers) ? d.ringNumbers.filter((n) => typeof n === "string") : []
|
|
897
897
|
}));
|
|
898
898
|
}
|
|
899
|
+
function ownerQuery(options) {
|
|
900
|
+
return options.ownerId ? `?ownerId=${encodeURIComponent(options.ownerId)}` : "";
|
|
901
|
+
}
|
|
902
|
+
function operatorQuery(operator, options) {
|
|
903
|
+
const query = new URLSearchParams("email" in operator ? { email: operator.email } : { phone: operator.phone });
|
|
904
|
+
if (options.ownerId) query.set("ownerId", options.ownerId);
|
|
905
|
+
return query.toString();
|
|
906
|
+
}
|
|
899
907
|
async function getOperatorRingNumbers(operator, options = {}) {
|
|
900
908
|
try {
|
|
901
909
|
const key = callsKey(options);
|
|
902
910
|
if (!key) return { ok: false, error: NO_KEY_ERROR };
|
|
903
|
-
const
|
|
904
|
-
const { data, error, code } = await callSdkApi(`/api/v1/sdk/phone-lines/operator?${query.toString()}`, key, options, {
|
|
911
|
+
const { data, error, code } = await callSdkApi(`/api/v1/sdk/phone-lines/operator?${operatorQuery(operator, options)}`, key, options, {
|
|
905
912
|
cache: "no-store"
|
|
906
913
|
});
|
|
907
914
|
if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
|
|
@@ -1076,7 +1083,7 @@ async function removeWebhook(id, options = {}) {
|
|
|
1076
1083
|
}
|
|
1077
1084
|
function removeLineCaller(email, options = {}) {
|
|
1078
1085
|
return ringNumberWrite(
|
|
1079
|
-
`/api/v1/sdk/phone-lines/callers/${encodeURIComponent(email)}`,
|
|
1086
|
+
`/api/v1/sdk/phone-lines/callers/${encodeURIComponent(email)}${ownerQuery(options)}`,
|
|
1080
1087
|
"DELETE",
|
|
1081
1088
|
void 0,
|
|
1082
1089
|
options,
|
|
@@ -1101,8 +1108,7 @@ async function listRingNumbers(operator, options = {}) {
|
|
|
1101
1108
|
try {
|
|
1102
1109
|
const key = callsKey(options);
|
|
1103
1110
|
if (!key) return { ok: false, error: NO_KEY_ERROR };
|
|
1104
|
-
const
|
|
1105
|
-
const { data, error, code } = await callSdkApi(ringNumbersPath(`?${query.toString()}`), key, options, {
|
|
1111
|
+
const { data, error, code } = await callSdkApi(ringNumbersPath(`?${operatorQuery(operator, options)}`), key, options, {
|
|
1106
1112
|
cache: "no-store"
|
|
1107
1113
|
});
|
|
1108
1114
|
if (error !== null || !isRecord(data)) return { ok: false, error: error != null ? error : "Unexpected response", ...code ? { code } : {} };
|
|
@@ -1130,20 +1136,27 @@ async function listRingNumbers(operator, options = {}) {
|
|
|
1130
1136
|
}
|
|
1131
1137
|
}
|
|
1132
1138
|
function addRingNumber(operator, number, options = {}) {
|
|
1133
|
-
|
|
1139
|
+
const body = { operator, ...number, ...options.ownerId ? { ownerId: options.ownerId } : {} };
|
|
1140
|
+
return ringNumberWrite(ringNumbersPath(), "POST", body, options, (d) => ({
|
|
1134
1141
|
id: typeof d.id === "string" ? d.id : "",
|
|
1135
1142
|
testRing: d.testRing === "failed" ? "failed" : "ringing",
|
|
1136
1143
|
verifyError: stringOrNull(d.verifyError)
|
|
1137
1144
|
}));
|
|
1138
1145
|
}
|
|
1139
1146
|
function updateRingNumber(id, change, options = {}) {
|
|
1140
|
-
return ringNumberWrite(ringNumbersPath(`/${encodeURIComponent(id)}`), "PATCH", change, options, () => ({}));
|
|
1147
|
+
return ringNumberWrite(ringNumbersPath(`/${encodeURIComponent(id)}${ownerQuery(options)}`), "PATCH", change, options, () => ({}));
|
|
1141
1148
|
}
|
|
1142
1149
|
function removeRingNumber(id, options = {}) {
|
|
1143
|
-
return ringNumberWrite(
|
|
1150
|
+
return ringNumberWrite(
|
|
1151
|
+
ringNumbersPath(`/${encodeURIComponent(id)}${ownerQuery(options)}`),
|
|
1152
|
+
"DELETE",
|
|
1153
|
+
void 0,
|
|
1154
|
+
options,
|
|
1155
|
+
() => ({})
|
|
1156
|
+
);
|
|
1144
1157
|
}
|
|
1145
1158
|
function testRingNumber(id, options = {}) {
|
|
1146
|
-
return ringNumberWrite(ringNumbersPath(`/${encodeURIComponent(id)}/verify`), "POST", void 0, options, (d) => ({
|
|
1159
|
+
return ringNumberWrite(ringNumbersPath(`/${encodeURIComponent(id)}/verify${ownerQuery(options)}`), "POST", void 0, options, (d) => ({
|
|
1147
1160
|
verified: d.verified === true
|
|
1148
1161
|
}));
|
|
1149
1162
|
}
|