@sparkvault/sdk-js 16.4.0 → 16.5.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.
@@ -1,19 +1,36 @@
1
1
  import type { HelpDeskClient } from './client';
2
+ /** A refusal of files read under the composer, hidden until there is one. */
3
+ export declare function createNotice(): HTMLParagraphElement;
4
+ /** Show a notice's refusal, or hide it with null. It is an alert only while it shows, as a field's error is. */
5
+ export declare function setNotice(notice: HTMLParagraphElement, text: string | null): void;
2
6
  export interface FormUploadContext {
3
7
  draftId: string;
4
8
  expectedSessionToken: string;
5
9
  }
6
- /** The picker owns each file's transfer; it publishes only IDs whose Forge receipt has confirmed storage. */
7
- export declare function createFormAttachments(client: HelpDeskClient, prefix: string, context: () => Promise<FormUploadContext | null>): {
8
- element: HTMLDivElement;
10
+ /** The form's one attachment pipeline: picked, pasted and dropped files all enter through `add`. */
11
+ export interface FormAttachments {
12
+ /** The Attach button, which opens the picker, with the policy hint that describes it. */
13
+ readonly toolbar: HTMLDivElement;
14
+ /** Each file as a chip: its name, status or progress, and its Remove and Retry. */
15
+ readonly list: HTMLUListElement;
16
+ /** The refusal of files past the per-message count. */
17
+ readonly notice: HTMLParagraphElement;
18
+ /** Whether a file handed over now joins: not while a send locks the files or picking is off. */
19
+ readonly accepting: boolean;
9
20
  readonly attachmentIds: string[];
10
21
  readonly unresolved: boolean;
11
22
  readonly hasEntries: boolean;
12
- readonly busy: boolean;
23
+ add(files: ArrayLike<File>): void;
13
24
  start(): Promise<void>;
14
25
  lock(value: boolean): void;
15
26
  disablePicking(value: boolean): void;
16
27
  renewSession(previousToken: string, nextToken: string): void;
17
- clear: (preserveComplete?: boolean) => void;
28
+ clear(preserveComplete?: boolean): void;
18
29
  destroy(preserveComplete?: boolean): void;
19
- };
30
+ }
31
+ /**
32
+ * The picker owns each file's transfer; it publishes only IDs whose Forge
33
+ * receipt has confirmed storage. `onEntriesChange` hears each file the
34
+ * customer adds or removes.
35
+ */
36
+ export declare function createFormAttachments(client: HelpDeskClient, prefix: string, context: () => Promise<FormUploadContext | null>, onEntriesChange: () => void): FormAttachments;
@@ -0,0 +1,34 @@
1
+ import { type FormAttachments } from './form-attachments';
2
+ export interface FormComposer {
3
+ /** The bordered frame: the text, then the Attach toolbar and the file chips when the desk takes files. */
4
+ readonly frame: HTMLDivElement;
5
+ /** The refusal of a file the composer cannot take, read under the frame. */
6
+ readonly notice: HTMLParagraphElement;
7
+ clearNotice(): void;
8
+ destroy(): void;
9
+ }
10
+ export interface ComposerOptions {
11
+ /** The contact form: a file brought anywhere over it is the composer's to take or refuse. */
12
+ form: HTMLFormElement;
13
+ /** The summary, where a pasted file joins as it does in the details. */
14
+ summary: HTMLInputElement;
15
+ /** The details, which the composer frames. */
16
+ textarea: HTMLTextAreaElement;
17
+ /** The form's attachment pipeline; absent when the form takes no files. */
18
+ attachments: FormAttachments | undefined;
19
+ /** The desk takes no files from customers, so a file brought to the request is refused in words. */
20
+ deskRefusesFiles: boolean;
21
+ /** Whether the request step shows: files join the request only there. */
22
+ onRequestStep: () => boolean;
23
+ }
24
+ /**
25
+ * The details field as a composer. A file pasted into the summary or the
26
+ * details, or dropped anywhere on the request step, joins the form's one
27
+ * attachment pipeline (`attachments.add`), under the same limits and
28
+ * refusals as a picked one; the drop target shows only over the composer. A
29
+ * paste or drag of text alone stays the browser's. A file brought over the
30
+ * form is never the browser's to open in place of the unsent request: on the
31
+ * reply-to step, or while the form takes no files, it is refused outright,
32
+ * and a desk that takes no files says so when the file is dropped.
33
+ */
34
+ export declare function createComposer(options: ComposerOptions): FormComposer;
@@ -16,12 +16,21 @@ type Composition = {
16
16
  subject: string;
17
17
  body: string;
18
18
  };
19
+ /** A signed-out customer's request saved before a reload, with the support question it was filled from: '' for one filled from none. */
20
+ export interface AnonymousFormDraft extends Composition {
21
+ composedFrom: string;
22
+ }
19
23
  /** The question before sign-in is tab-local and contains no customer identity. */
20
24
  export declare function clearSupportIssue(deskId: string): void;
21
25
  export declare function readSupportIssue(deskId: string): string | null;
22
- export declare function readAnonymousFormDraft(deskId: string): Composition | null;
26
+ export declare function readAnonymousFormDraft(deskId: string): AnonymousFormDraft | null;
23
27
  export declare function saveSupportIssue(deskId: string, issue: string): void;
24
- export declare function saveAnonymousFormDraft(deskId: string, composition: Composition): void;
28
+ /**
29
+ * Save a signed-out customer's request beside the tab's question, with the
30
+ * question it was filled from when the support wizard filled it. A question
31
+ * too long to keep is left out, so the request reads as the customer's own.
32
+ */
33
+ export declare function saveAnonymousFormDraft(deskId: string, composition: Composition, composedFrom?: string): void;
25
34
  export declare function removeFormDraft(deskId: string, requesterId: string): void;
26
35
  export declare function readFormDraft(deskId: string, requesterId: string): HelpDeskFormDraft | null;
27
36
  export declare function saveFormDraft(deskId: string, requesterId: string, value: HelpDeskFormDraft): void;
@@ -1,20 +1,37 @@
1
1
  import type { HelpDeskCustomer, HelpDeskSession, HelpDeskTicketCreated } from './types';
2
- /** Internal adapter used by the KB-first widget; legacy forms retain their existing verification flow. */
2
+ /** Internal adapter used by the KB-first support widget; a standalone form verifies the customer itself. */
3
3
  export interface HelpDeskWidgetFormIdentity {
4
4
  customer: HelpDeskCustomer | null;
5
+ /** A desk that signs in with SparkVault Identity sends the email alone: its sign-in window asks a missing name itself. */
5
6
  signIn(input: {
6
7
  email: string;
7
- givenName: string;
8
- familyName: string;
8
+ givenName?: string;
9
+ familyName?: string;
9
10
  }): Promise<HelpDeskSession>;
10
11
  switchAccount(composition: {
11
12
  subject: string;
12
13
  body: string;
13
14
  } | null): void;
15
+ /**
16
+ * Present when the host bridges its website account: sign in with it again,
17
+ * carrying the request, or, `recovering`, a website-account customer's
18
+ * hidden saved request, which the next form keeps hidden while the website
19
+ * gives no account back.
20
+ */
14
21
  useWebsiteAccount?: (composition: {
15
22
  subject: string;
16
23
  body: string;
17
- } | null) => void;
24
+ } | null, recovering?: boolean) => void;
25
+ /** Keep a website-account customer's saved request hidden from the start, as the form this one replaces did; `websiteSignedOut` when the website just gave no account back. */
26
+ recovering?: {
27
+ websiteSignedOut: boolean;
28
+ };
29
+ /** Offer Use website account beside the request: the customer switched away from the website's account. */
30
+ offerWebsiteAccount: boolean;
31
+ /** A previous customer's request left the form: forget their question, in view and in storage. */
32
+ forgetIssue(): void;
33
+ /** The form left a hidden saved request for a new one: fill it from the question as the customer last wrote it. */
34
+ followIssue(): void;
18
35
  }
19
36
  /** The injected form's state; uncertain sends keep an exact snapshot until recovered. */
20
37
  export type HelpDeskFormState = 'authenticating' | 'editing' | 'verifying' | 'submitting' | 'uncertain' | 'success' | 'destroyed';
@@ -29,8 +46,16 @@ export interface HelpDeskFormOptions {
29
46
  attachments?: boolean;
30
47
  /** Keep this tab's verified requester's draft for 30 minutes, including uncertain-send recovery. Defaults to false. */
31
48
  persist?: boolean;
49
+ /** @internal The issue the support wizard fills the form from, in place of `subject` and `body`; a field holding it stays free for a rewritten issue. */
50
+ issue?: string;
32
51
  /** @internal The support controller owns account transitions and native Identity. */
33
52
  widgetIdentity?: HelpDeskWidgetFormIdentity;
53
+ /** @internal The support wizard is inline on the host's page (any `target`): that page asks before it unloads while the request holds unsent work. */
54
+ pageLayout?: boolean;
55
+ /** @internal The form's controls changed in place: it moved between its steps, or its actions changed as it left a hidden saved request. */
56
+ onScreenChange?: () => void;
57
+ /** @internal The host page already shows "Secured by SparkVault", so the form leaves its own out. */
58
+ hostShowsAttribution?: boolean;
34
59
  /** @internal Server-minted, content-free assistance correlation. */
35
60
  assistanceContext?: () => {
36
61
  assistance_attempt_id: string;
@@ -23,19 +23,38 @@ export interface HelpDeskFormController extends HelpDeskFormHandle {
23
23
  body: string;
24
24
  }): void;
25
25
  /**
26
- * Fill the form with newer text: each field the customer has not written
27
- * in, blank or still reading what the form was filled with, takes it, and
28
- * a field holding their own text keeps it. The newer text is then what the
29
- * form was filled with; files, name and email stay. Refused (false, nothing
30
- * changed) while a send is under way, unanswered or done.
26
+ * Follow a rewritten issue. A field is free while it is blank or holds what
27
+ * the form was filled with, and the customer's once they write in it; a
28
+ * refill never changes the customer's. With both fields free the issue lands
29
+ * as contact starts (`composeIssue`). With one free, that field takes the
30
+ * whole issue, except that the summary holds only one line of at most
31
+ * MAX_SUBJECT_LEN characters and is emptied for any other: a free field never
32
+ * keeps an earlier issue. The issue is then what the form was filled with;
33
+ * files, name and email stay. Refused (false, nothing changed) while a send
34
+ * is under way, unanswered or done.
31
35
  */
32
- refill(composition: {
33
- subject: string;
34
- body: string;
35
- }): boolean;
36
+ refill(issue: string): boolean;
36
37
  /** Clear a resolved access-gate error without changing a draft or uncertain send. */
37
38
  resumeAfterAccess(): void;
39
+ /**
40
+ * Go back from the reply-to step to the request, as the support wizard's
41
+ * Back does there. False on the request step, where Back is the wizard's.
42
+ */
43
+ returnToRequest(): boolean;
44
+ /**
45
+ * Focus where the customer goes on: the field the step in view asks for
46
+ * (`stepField`), on the request step the end of the details once the
47
+ * summary holds text, or the step's heading while that field cannot be
48
+ * edited. False only once the form is destroyed or hidden.
49
+ */
50
+ focusEntry(focusOptions?: FocusOptions): boolean;
38
51
  }
52
+ /**
53
+ * A ticket's body: the details the customer wrote, or, when they wrote none,
54
+ * the summary, since every ticket carries a message. The one place the two
55
+ * fields become the body that is checked against the limit and sent.
56
+ */
57
+ export declare function ticketBody(summary: string, details: string): string;
39
58
  /**
40
59
  * Inject a ticket form using only the requester's customer API. Authentication
41
60
  * is the desk's email-code flow or an explicit host-provided customer session.
@@ -46,5 +65,9 @@ export interface HelpDeskFormController extends HelpDeskFormHandle {
46
65
  * line carries the flow (a code sent, a send in progress or uncertain, a
47
66
  * changed sign-in, a server error). Closing with unsent work asks first.
48
67
  * A confirmed send replaces the form with its confirmation.
68
+ *
69
+ * The request is a summary and optional details, in a composer that also
70
+ * takes files. A signed-out widget customer writes it as step 1 of 2; step 2
71
+ * asks who the reply goes to and proves it in the native sign-in window.
49
72
  */
50
73
  export declare function mountHelpDeskForm(client: HelpDeskClient, options: HelpDeskFormOptions): HelpDeskFormController;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The help desk's bare outline glyphs, shared by the support wizard and the
3
+ * ticket form: stroked in `currentColor`, so the stylesheet that sizes them
4
+ * also colors them, and hidden from assistive technology, since the control
5
+ * that holds one names it.
6
+ */
7
+ declare const PATHS: {
8
+ readonly back: "m14.5 6-6 6 6 6";
9
+ readonly close: "m6 6 12 12M18 6 6 18";
10
+ readonly external: "M14 4h6v6m0-6L10 14M11 5H5a1 1 0 0 0-1 1v13a1 1 0 0 0 1 1h13a1 1 0 0 0 1-1v-6";
11
+ readonly check: "m5 12 4 4L19 6";
12
+ readonly article: "M14 3H6a1 1 0 0 0-1 1v16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8Zm0 0v5h5M8 12h8M8 16h6";
13
+ readonly chevron: "m9 6 6 6-6 6";
14
+ readonly thumbUp: "M7 10v11H3V10Zm0 1 5-8c2 0 3 1 2 4l-1 3h6a2 2 0 0 1 2 2l-2 7a2 2 0 0 1-2 2H7";
15
+ readonly thumbDown: "M7 14V3H3v11Zm0-1 5 8c2 0 3-1 2-4l-1-3h6a2 2 0 0 0 2-2l-2-7a2 2 0 0 0-2-2H7";
16
+ readonly paperclip: "m21 11-8.6 8.6a5.5 5.5 0 0 1-7.8-7.8l8.6-8.6a3.7 3.7 0 0 1 5.2 5.2l-8.6 8.6a1.8 1.8 0 0 1-2.6-2.6L15 6.6";
17
+ readonly info: "M12 21a9 9 0 1 0 0-18 9 9 0 0 0 0 18Zm0-10v5m0-8h.01";
18
+ };
19
+ export type HelpDeskIconName = keyof typeof PATHS;
20
+ export declare function helpDeskIcon(name: HelpDeskIconName): SVGSVGElement;
21
+ export {};
@@ -12,6 +12,8 @@ export interface HelpDeskSupportLauncherOptions {
12
12
  export interface HelpDeskSupportOptions extends HelpDeskConnectOptions {
13
13
  /** Render the same support journey in this page element. Omit for the floating widget. */
14
14
  target?: string | HTMLElement;
15
+ /** @internal The host page already shows "Secured by SparkVault", so the contact form leaves its own out. */
16
+ hostShowsAttribution?: boolean;
15
17
  /** Keep recoverable composition in this browser tab through navigation and reload. Defaults to false. */
16
18
  persist?: boolean;
17
19
  /** Observe the customer session the journey proves or clears. */
@@ -55,6 +55,8 @@ export interface SupportViewActions {
55
55
  onUnlockTicketAccess?: (password?: string) => void;
56
56
  onRestart?: () => void;
57
57
  onCancelIdentity?: () => void;
58
+ /** Focus the mounted contact form where the customer goes on; false when it has nothing to focus. */
59
+ onFocusContact?: (focusOptions: FocusOptions) => boolean;
58
60
  onBrowserBack?: () => void;
59
61
  onBrowserForward?: () => void;
60
62
  }
@@ -113,7 +115,6 @@ export declare class SupportView {
113
115
  private readonly receiptTicket;
114
116
  private readonly receiptMessage;
115
117
  private readonly toolbar;
116
- private readonly live;
117
118
  private readonly identityNotice;
118
119
  private readonly restart;
119
120
  private readonly media;
@@ -130,11 +131,16 @@ export declare class SupportView {
130
131
  private ticketGateSignature;
131
132
  private readonly toastCleanups;
132
133
  private destroyed;
134
+ private screenChanges;
135
+ private pressedAt;
136
+ private readonly onPress;
133
137
  constructor(actions: SupportViewActions, target?: HTMLElement | undefined);
134
138
  render(next: SupportViewState): void;
139
+ /** A new contact form, or one whose controls changed in place: a change of screen, as a new stage is. */
140
+ contactScreenChanged(): void;
135
141
  /** Programmatic close invalidates Forward restoration even after neutral Back. */
136
142
  deactivateHistory(): void;
137
- /** Focus the shared form after its controller has mounted it. */
143
+ /** Focus the shared form where the customer goes on, else its heading, after its controller has mounted it. */
138
144
  focusContact(): void;
139
145
  /** Hydrate only the current reader's matching authorized publication assets. */
140
146
  setArticleAsset(path: string, blobUrl: string): void;
@@ -43,7 +43,6 @@ export declare class IdentityRenderer {
43
43
  private readonly offeredWithoutReference;
44
44
  private untouchedStep;
45
45
  private statusRegion;
46
- private statusTimer;
47
46
  constructor(container: Container, api: IdentityApi, options: VerifyOptions, callbacks: RendererCallbacks, federationReturn?: FederationReturn | null);
48
47
  /**
49
48
  * Seed the verification identity from the render options, deriving the
@@ -215,12 +214,6 @@ export declare class IdentityRenderer {
215
214
  private render;
216
215
  /** Place the empty live region beside the flow content, once per container. */
217
216
  private placeStatusRegion;
218
- /**
219
- * Put `words` in the live region, a moment after the view that says them
220
- * is in place, so they never land in the same change as the region or the
221
- * view that holds them; empty words clear it at once.
222
- */
223
- private announce;
224
217
  private destroyCurrentView;
225
218
  /**
226
219
  * Replace the mounted view with a Google-style height morph: the flow region
@@ -3,10 +3,10 @@
3
3
  *
4
4
  * Bare outline glyphs per the SparkVault design system: stroke `currentColor`
5
5
  * so the stylesheet drives color, no tinted container backgrounds, round
6
- * caps/joins. The sign-in providers' marks are the one exception: each is its
7
- * owner's filled logo, in the owner's colors, or in `currentColor` where the
8
- * owner's mark is one-color (Apple, GitHub). Uses proper DOM element creation
9
- * for security.
6
+ * caps/joins. The sign-in providers' marks are their owners' filled logos,
7
+ * drawn from `@sparkvault/app-sdk/brand-marks` in their owners' colors, a
8
+ * one-color logo (Apple, GitHub) in `currentColor`. Uses proper DOM element
9
+ * creation for security.
10
10
  */
11
11
  /**
12
12
  * Checkmark icon for benefit lists