glitchgrab 1.65.2 → 1.66.1

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