glitchgrab 1.65.2 → 1.66.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/dist/server.d.mts CHANGED
@@ -237,6 +237,8 @@ interface CallParticipant {
237
237
  /** One shared call as the list returns it — no transcript, no links. */
238
238
  interface CallListItem {
239
239
  id: string;
240
+ /** The call's Glitchgrab page (#765): call log, transcript, recording. Opens for a signed-in project member; the link itself grants nothing. Null from a server that predates it. */
241
+ pageUrl: string | null;
240
242
  title: string | null;
241
243
  startsAt: string | null;
242
244
  endsAt: string | null;
@@ -360,6 +362,33 @@ declare function getCall(id: string, options?: GetCallOptions): Promise<Call | n
360
362
  * showing ("The bot is still in this call — delete it after the call ends").
361
363
  */
362
364
  declare function deleteCall(id: string, options?: CallsOptions): Promise<DeleteCallResult>;
365
+ interface CallIssueSessionOptions extends CallsOptions {
366
+ /** Who is filing — shown as the issue's reporter. Defaults to "Project admin". */
367
+ reporter?: {
368
+ name: string;
369
+ email?: string | null;
370
+ };
371
+ }
372
+ type CallIssueSessionResult = {
373
+ ok: true;
374
+ token: string;
375
+ expiresInSeconds: number;
376
+ } | {
377
+ ok: false;
378
+ error: string;
379
+ };
380
+ /**
381
+ * Mint the token `<GlitchgrabCallIssue getToken />` needs, for one shared call.
382
+ * Resolves `{ ok: false, error }` instead of throwing.
383
+ *
384
+ * @example
385
+ * ```ts
386
+ * // app/api/admin/calls/[callId]/issue-session/route.ts
387
+ * const session = await createCallIssueSession(callId, { reporter: { name: admin.name } });
388
+ * return Response.json(session);
389
+ * ```
390
+ */
391
+ declare function createCallIssueSession(callId: string, options?: CallIssueSessionOptions): Promise<CallIssueSessionResult>;
363
392
  /** `{ "1": [["09:00", "17:00"]] }` — ISO weekday (1 = Monday) to opening ranges, in {@link BookingSettings.timezone}. */
364
393
  type BookingWorkingHours = Record<string, [string, string][]>;
365
394
  interface BookingSettings {
@@ -414,7 +443,11 @@ interface BookingSettings {
414
443
  */
415
444
  requireOtp: boolean;
416
445
  }
417
- /** One question asked before a demo is booked. The prospect taps one of `options`. */
446
+ /**
447
+ * One question asked before a demo is booked. A `"choice"` question is answered
448
+ * by tapping one of `options`; a `"text"` question by typing (up to 300
449
+ * characters, whitespace collapsed) and has no options.
450
+ */
418
451
  interface BookingQuestion {
419
452
  /**
420
453
  * Stable name for the question, e.g. `"language"` — lower case letters,
@@ -424,15 +457,21 @@ interface BookingQuestion {
424
457
  id: string;
425
458
  /** What is asked, up to 80 characters. */
426
459
  label: string;
427
- /** 2–9 choices, up to 40 characters each. */
460
+ /** `"choice"` (the default when a stored question has no type) or `"text"`. */
461
+ type: "choice" | "text";
462
+ /** 2–9 choices, up to 40 characters each. Empty for a `"text"` question. */
428
463
  options: string[];
429
464
  /** False lets the prospect skip it. */
430
465
  required: boolean;
431
466
  }
432
467
  /** A question as you send it: `id` and `required` may be left out on a new one. */
433
- type BookingQuestionInput = Omit<BookingQuestion, "id" | "required"> & {
468
+ type BookingQuestionInput = Omit<BookingQuestion, "id" | "required" | "type" | "options"> & {
434
469
  id?: string;
435
470
  required?: boolean;
471
+ /** Leave out for a choice question. */
472
+ type?: "choice" | "text";
473
+ /** Required for a choice question (2–9); ignored for a text one. */
474
+ options?: string[];
436
475
  };
437
476
  /** What {@link updateBookingSettings} accepts — any subset of the settings. */
438
477
  type BookingSettingsChanges = Partial<Omit<BookingSettings, "questions" | "draftQuestions">> & {
@@ -450,6 +489,8 @@ interface BookingAnswer {
450
489
  id: string;
451
490
  question: string;
452
491
  answer: string;
492
+ /** `"text"` when the prospect typed it; absent for a choice. */
493
+ type?: "text";
453
494
  }
454
495
  /** One extra person alerted when a demo is booked. */
455
496
  interface BookingNotifyRecipient {
@@ -706,6 +747,8 @@ interface FollowUpNote {
706
747
  }
707
748
  interface FollowUpCall {
708
749
  id: string;
750
+ /** The call's Glitchgrab page (#765): call log, transcript, recording. Opens for a signed-in project member; the link itself grants nothing. Null from a server that predates it. */
751
+ pageUrl: string | null;
709
752
  status: string | null;
710
753
  direction: string | null;
711
754
  at: string;
@@ -1243,4 +1286,4 @@ declare function testRingNumber(id: string, options?: LineCallsOptions): Promise
1243
1286
  verified: boolean;
1244
1287
  }>>;
1245
1288
 
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 };
1289
+ 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 CallIssueSessionOptions, type CallIssueSessionResult, 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, createCallIssueSession, 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
@@ -237,6 +237,8 @@ interface CallParticipant {
237
237
  /** One shared call as the list returns it — no transcript, no links. */
238
238
  interface CallListItem {
239
239
  id: string;
240
+ /** The call's Glitchgrab page (#765): call log, transcript, recording. Opens for a signed-in project member; the link itself grants nothing. Null from a server that predates it. */
241
+ pageUrl: string | null;
240
242
  title: string | null;
241
243
  startsAt: string | null;
242
244
  endsAt: string | null;
@@ -360,6 +362,33 @@ declare function getCall(id: string, options?: GetCallOptions): Promise<Call | n
360
362
  * showing ("The bot is still in this call — delete it after the call ends").
361
363
  */
362
364
  declare function deleteCall(id: string, options?: CallsOptions): Promise<DeleteCallResult>;
365
+ interface CallIssueSessionOptions extends CallsOptions {
366
+ /** Who is filing — shown as the issue's reporter. Defaults to "Project admin". */
367
+ reporter?: {
368
+ name: string;
369
+ email?: string | null;
370
+ };
371
+ }
372
+ type CallIssueSessionResult = {
373
+ ok: true;
374
+ token: string;
375
+ expiresInSeconds: number;
376
+ } | {
377
+ ok: false;
378
+ error: string;
379
+ };
380
+ /**
381
+ * Mint the token `<GlitchgrabCallIssue getToken />` needs, for one shared call.
382
+ * Resolves `{ ok: false, error }` instead of throwing.
383
+ *
384
+ * @example
385
+ * ```ts
386
+ * // app/api/admin/calls/[callId]/issue-session/route.ts
387
+ * const session = await createCallIssueSession(callId, { reporter: { name: admin.name } });
388
+ * return Response.json(session);
389
+ * ```
390
+ */
391
+ declare function createCallIssueSession(callId: string, options?: CallIssueSessionOptions): Promise<CallIssueSessionResult>;
363
392
  /** `{ "1": [["09:00", "17:00"]] }` — ISO weekday (1 = Monday) to opening ranges, in {@link BookingSettings.timezone}. */
364
393
  type BookingWorkingHours = Record<string, [string, string][]>;
365
394
  interface BookingSettings {
@@ -414,7 +443,11 @@ interface BookingSettings {
414
443
  */
415
444
  requireOtp: boolean;
416
445
  }
417
- /** One question asked before a demo is booked. The prospect taps one of `options`. */
446
+ /**
447
+ * One question asked before a demo is booked. A `"choice"` question is answered
448
+ * by tapping one of `options`; a `"text"` question by typing (up to 300
449
+ * characters, whitespace collapsed) and has no options.
450
+ */
418
451
  interface BookingQuestion {
419
452
  /**
420
453
  * Stable name for the question, e.g. `"language"` — lower case letters,
@@ -424,15 +457,21 @@ interface BookingQuestion {
424
457
  id: string;
425
458
  /** What is asked, up to 80 characters. */
426
459
  label: string;
427
- /** 2–9 choices, up to 40 characters each. */
460
+ /** `"choice"` (the default when a stored question has no type) or `"text"`. */
461
+ type: "choice" | "text";
462
+ /** 2–9 choices, up to 40 characters each. Empty for a `"text"` question. */
428
463
  options: string[];
429
464
  /** False lets the prospect skip it. */
430
465
  required: boolean;
431
466
  }
432
467
  /** A question as you send it: `id` and `required` may be left out on a new one. */
433
- type BookingQuestionInput = Omit<BookingQuestion, "id" | "required"> & {
468
+ type BookingQuestionInput = Omit<BookingQuestion, "id" | "required" | "type" | "options"> & {
434
469
  id?: string;
435
470
  required?: boolean;
471
+ /** Leave out for a choice question. */
472
+ type?: "choice" | "text";
473
+ /** Required for a choice question (2–9); ignored for a text one. */
474
+ options?: string[];
436
475
  };
437
476
  /** What {@link updateBookingSettings} accepts — any subset of the settings. */
438
477
  type BookingSettingsChanges = Partial<Omit<BookingSettings, "questions" | "draftQuestions">> & {
@@ -450,6 +489,8 @@ interface BookingAnswer {
450
489
  id: string;
451
490
  question: string;
452
491
  answer: string;
492
+ /** `"text"` when the prospect typed it; absent for a choice. */
493
+ type?: "text";
453
494
  }
454
495
  /** One extra person alerted when a demo is booked. */
455
496
  interface BookingNotifyRecipient {
@@ -706,6 +747,8 @@ interface FollowUpNote {
706
747
  }
707
748
  interface FollowUpCall {
708
749
  id: string;
750
+ /** The call's Glitchgrab page (#765): call log, transcript, recording. Opens for a signed-in project member; the link itself grants nothing. Null from a server that predates it. */
751
+ pageUrl: string | null;
709
752
  status: string | null;
710
753
  direction: string | null;
711
754
  at: string;
@@ -1243,4 +1286,4 @@ declare function testRingNumber(id: string, options?: LineCallsOptions): Promise
1243
1286
  verified: boolean;
1244
1287
  }>>;
1245
1288
 
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 };
1289
+ 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 CallIssueSessionOptions, type CallIssueSessionResult, 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, createCallIssueSession, 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
@@ -26,6 +26,7 @@ __export(server_exports, {
26
26
  cancelBooking: () => cancelBooking,
27
27
  captureServerErrors: () => captureServerErrors,
28
28
  configureServerReporter: () => configureServerReporter,
29
+ createCallIssueSession: () => createCallIssueSession,
29
30
  deleteCall: () => deleteCall,
30
31
  dialFollowUp: () => dialFollowUp,
31
32
  disableCalling: () => disableCalling,
@@ -424,6 +425,7 @@ function readCallListItem(value) {
424
425
  if (!isRecord(value) || typeof value.id !== "string") return null;
425
426
  return {
426
427
  id: value.id,
428
+ pageUrl: stringOrNull(value.pageUrl),
427
429
  title: stringOrNull(value.title),
428
430
  startsAt: stringOrNull(value.startsAt),
429
431
  endsAt: stringOrNull(value.endsAt),
@@ -509,6 +511,28 @@ async function deleteCall(id, options = {}) {
509
511
  return { deleted: false, error: "Could not delete the call" };
510
512
  }
511
513
  }
514
+ async function createCallIssueSession(callId, options = {}) {
515
+ try {
516
+ const wanted = typeof callId === "string" ? callId.trim() : "";
517
+ if (!wanted) return { ok: false, error: "No call id" };
518
+ const key = callsKey(options);
519
+ if (!key) return { ok: false, error: NO_KEY_ERROR };
520
+ const { data, error } = await callSdkApi("/api/v1/sdk/calls/issue-session", key, options, {
521
+ method: "POST",
522
+ body: { callId: wanted, ...options.reporter ? { reporter: options.reporter } : {} },
523
+ cache: "no-store"
524
+ });
525
+ if (error !== null) return { ok: false, error };
526
+ if (!isRecord(data) || typeof data.token !== "string") return { ok: false, error: "Unexpected response" };
527
+ return {
528
+ ok: true,
529
+ token: data.token,
530
+ expiresInSeconds: typeof data.expiresInSeconds === "number" ? data.expiresInSeconds : 900
531
+ };
532
+ } catch (e) {
533
+ return { ok: false, error: "Could not start the issue session" };
534
+ }
535
+ }
512
536
  var WEEKDAY = /^[1-7]$/;
513
537
  function readQuestionList(value) {
514
538
  if (!Array.isArray(value)) return null;
@@ -517,6 +541,7 @@ function readQuestionList(value) {
517
541
  return {
518
542
  id: (_a = stringOrNull(row.id)) != null ? _a : "",
519
543
  label: (_b = stringOrNull(row.label)) != null ? _b : "",
544
+ type: row.type === "text" ? "text" : "choice",
520
545
  options: Array.isArray(row.options) ? row.options.filter((option) => typeof option === "string") : [],
521
546
  required: row.required !== false
522
547
  };
@@ -619,7 +644,8 @@ function readBooking(value) {
619
644
  return {
620
645
  id: (_a2 = stringOrNull(row.id)) != null ? _a2 : "",
621
646
  question: (_b2 = stringOrNull(row.question)) != null ? _b2 : "",
622
- answer: (_c2 = stringOrNull(row.answer)) != null ? _c2 : ""
647
+ answer: (_c2 = stringOrNull(row.answer)) != null ? _c2 : "",
648
+ ...row.type === "text" ? { type: "text" } : {}
623
649
  };
624
650
  }).filter((row) => row.answer !== "") : [],
625
651
  status: (_f = stringOrNull(value.status)) != null ? _f : "CONFIRMED",
@@ -806,6 +832,7 @@ function readFollowUpDetail(value) {
806
832
  var _a2;
807
833
  return {
808
834
  id: c.id,
835
+ pageUrl: stringOrNull(c.pageUrl),
809
836
  status: stringOrNull(c.status),
810
837
  direction: stringOrNull(c.direction),
811
838
  at: (_a2 = stringOrNull(c.at)) != null ? _a2 : "",
@@ -1168,6 +1195,7 @@ function testRingNumber(id, options = {}) {
1168
1195
  cancelBooking,
1169
1196
  captureServerErrors,
1170
1197
  configureServerReporter,
1198
+ createCallIssueSession,
1171
1199
  deleteCall,
1172
1200
  dialFollowUp,
1173
1201
  disableCalling,