@helpai/elements 1.4.1 → 1.5.4

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/index.d.ts CHANGED
@@ -41,7 +41,7 @@ interface ClientStorage {
41
41
  * populated {@link Strings} map. UI components then read `strings.send` as a
42
42
  * normal property access — no per-render lookup, no per-render allocation.
43
43
  */
44
- type StringKey = 'launcherOpen' | 'launcherLabel' | 'panelTitle' | 'composerPlaceholder' | 'send' | 'stop' | 'queueMessage' | 'removeQueuedMessage' | 'compactingContext' | 'attach' | 'micStart' | 'micStop' | 'micUnsupported' | 'expand' | 'collapse' | 'fullscreen' | 'exitFullscreen' | 'popOut' | 'resizeHandle' | 'scrollToBottom' | 'close' | 'moreActions' | 'soundOn' | 'soundOff' | 'language' | 'theme' | 'themeAuto' | 'themeLight' | 'themeDark' | 'textSize' | 'textSizeSmall' | 'textSizeNormal' | 'textSizeLarge' | 'history' | 'historyTitle' | 'historyEmpty' | 'historyLoading' | 'historyBack' | 'historyContinue' | 'loadMoreConversations' | 'conversationLoading' | 'loadPreviousMessages' | 'conversationClosed' | 'startNewConversation' | 'talkToOperator' | 'connectingOperator' | 'noOperatorAvailable' | 'chattingWithOperator' | 'cancelOperatorRequest' | 'dateToday' | 'dateYesterday' | 'dateLastWeek' | 'dateOlder' | 'newConversation' | 'dropZone' | 'attachmentTooLarge' | 'attachmentTooMany' | 'attachmentMimeRejected' | 'errorRetry' | 'errorGeneric' | 'errorRateLimited' | 'loading' | 'visualPreparing' | 'visualError' | 'thinking' | 'thoughts' | 'toolResult' | 'sources' | 'feedbackUp' | 'feedbackDown' | 'feedbackThanks' | 'copy' | 'copied' | 'collapseSidebar' | 'expandSidebar' | 'formSubmit' | 'formSkip' | 'formSubmitted' | 'formSkipped' | 'formFillOut' | 'formRequired' | 'formInvalidEmail' | 'formInvalidTel' | 'formInvalidUrl' | 'formInvalidNumber' | 'formTooShort' | 'formTooLong' | 'formNumberTooSmall' | 'formNumberTooLarge' | 'formPatternMismatch' | 'formChooseAtLeast' | 'formChooseAtMost' | 'formOther' | 'formOtherPlaceholder' | 'inputRequired' | 'inputBadge' | 'inputAnswered' | 'inputSkipped' | 'inputSubmit' | 'inputSubmitHint' | 'inputSkip' | 'showOptions' | 'hideOptions' | 'qtypeText' | 'qtypeEmail' | 'qtypePhone' | 'qtypeNumber' | 'qtypeDate' | 'qtypeChooseOne' | 'qtypeChooseAny' | 'qtypeBoolean' | 'confirmYes' | 'confirmNo' | 'approve' | 'reject' | 'approvalPrompt' | 'approvalBody' | 'approvalYourResponse' | 'approvalEditHint' | 'approvalSubmitting' | 'edit' | 'toolParameters' | 'statusAwaiting' | 'statusResponded' | 'statusCompleted' | 'statusDenied' | 'statusError' | 'statusRunning' | 'statusSuperseded' | 'tabHome' | 'tabConversations' | 'tabHelp' | 'tabNews' | 'modulesEmpty' | 'moduleBack' | 'contentLoading' | 'homeGreeting' | 'homeGreetingNamed' | 'homeGreetingLead' | 'homeSearchPlaceholder' | 'homeContentTitle' | 'homeStatus' | 'helpTitle' | 'helpSearchPlaceholder' | 'helpEmpty' | 'helpLoading' | 'helpSearchEmpty' | 'newsTitle' | 'newsEmpty' | 'newsLoading' | 'newsBack' | 'newsPublishedAt';
44
+ type StringKey = 'launcherOpen' | 'launcherLabel' | 'panelTitle' | 'composerPlaceholder' | 'send' | 'stop' | 'queueMessage' | 'removeQueuedMessage' | 'compactingContext' | 'attach' | 'micStart' | 'micStop' | 'micUnsupported' | 'expand' | 'collapse' | 'fullscreen' | 'exitFullscreen' | 'popOut' | 'resizeHandle' | 'scrollToBottom' | 'close' | 'moreActions' | 'soundOn' | 'soundOff' | 'language' | 'theme' | 'themeAuto' | 'themeLight' | 'themeDark' | 'textSize' | 'textSizeSmall' | 'textSizeNormal' | 'textSizeLarge' | 'history' | 'historyTitle' | 'historyEmpty' | 'historyLoading' | 'historyBack' | 'historyContinue' | 'loadMoreConversations' | 'conversationLoading' | 'loadPreviousMessages' | 'conversationClosed' | 'startNewConversation' | 'talkToOperator' | 'connectingOperator' | 'noOperatorAvailable' | 'chattingWithOperator' | 'cancelOperatorRequest' | 'dateToday' | 'dateYesterday' | 'dateLastWeek' | 'dateOlder' | 'newConversation' | 'dropZone' | 'attachmentTooLarge' | 'attachmentTooMany' | 'attachmentMimeRejected' | 'errorRetry' | 'errorGeneric' | 'errorRateLimited' | 'loading' | 'visualPreparing' | 'visualError' | 'visualPartial' | 'thinking' | 'thoughts' | 'toolResult' | 'sources' | 'feedbackUp' | 'feedbackDown' | 'feedbackThanks' | 'copy' | 'copied' | 'collapseSidebar' | 'expandSidebar' | 'formSubmit' | 'formSkip' | 'formSubmitted' | 'formSkipped' | 'formFillOut' | 'formRequired' | 'formInvalidEmail' | 'formInvalidTel' | 'formInvalidUrl' | 'formInvalidNumber' | 'formTooShort' | 'formTooLong' | 'formNumberTooSmall' | 'formNumberTooLarge' | 'formPatternMismatch' | 'formChooseAtLeast' | 'formChooseAtMost' | 'formOther' | 'formOtherPlaceholder' | 'inputRequired' | 'inputBadge' | 'inputAnswered' | 'inputSkipped' | 'inputSubmit' | 'inputSubmitHint' | 'inputSkip' | 'showOptions' | 'hideOptions' | 'qtypeText' | 'qtypeEmail' | 'qtypePhone' | 'qtypeNumber' | 'qtypeDate' | 'qtypeChooseOne' | 'qtypeChooseAny' | 'qtypeBoolean' | 'confirmYes' | 'confirmNo' | 'approve' | 'reject' | 'approvalPrompt' | 'approvalBody' | 'approvalYourResponse' | 'approvalEditHint' | 'approvalSubmitting' | 'edit' | 'toolParameters' | 'statusAwaiting' | 'statusResponded' | 'statusCompleted' | 'statusDenied' | 'statusError' | 'statusRunning' | 'statusSuperseded' | 'tabHome' | 'tabConversations' | 'tabHelp' | 'tabNews' | 'modulesEmpty' | 'moduleBack' | 'contentLoading' | 'contentHelpful' | 'homeGreeting' | 'homeGreetingNamed' | 'homeGreetingLead' | 'homeSearchPlaceholder' | 'homeContentTitle' | 'homeStatus' | 'helpTitle' | 'helpSearchPlaceholder' | 'helpEmpty' | 'helpLoading' | 'helpSearchEmpty' | 'newsTitle' | 'newsEmpty' | 'newsLoading' | 'newsBack' | 'newsPublishedAt';
45
45
  /** A partial map for one locale — what overrides look like on the wire. */
46
46
  type LocaleStrings = Partial<Record<StringKey, string>>;
47
47
  /**
@@ -167,7 +167,7 @@ interface FeatureFlags {
167
167
  */
168
168
  disableFileUpload?: boolean;
169
169
  /**
170
- * Opt IN operator control — exposes the "Talk to an operator" affordance + connected-to-operator
170
+ * Opt IN operator control — exposes the "Talk to a person" affordance + connected-to-operator
171
171
  * states. Positive opt-in (unlike the `disable*` flags) for a new capability; default off.
172
172
  */
173
173
  enableOperatorRequest?: boolean;
@@ -400,7 +400,7 @@ interface FormDef {
400
400
  *
401
401
  * The data module trims `FormDef.translations` to the requested `?locale=` (≤1
402
402
  * entry) on read; the widget overlays that entry onto the default fields. Mirror
403
- * of `module-data-api` `DynamicFormTranslation`.
403
+ * of `module-data-api` `FormTranslation`.
404
404
  */
405
405
  interface FieldOptionTranslation {
406
406
  /** The canonical option `value` this localizes. */
@@ -525,9 +525,9 @@ interface LauncherOptions {
525
525
  * `src/schema/widget/modules.ts`. The IIFE runtime path has no Zod, so
526
526
  * these plain interfaces are what the resolver + UI consume.
527
527
  *
528
- * `modules` is an ordered list of tabs; each picks a UI `layout`, optional
529
- * content `contentTags` (the scope passed as the `tags` filter to
530
- * `GET /content`), and a translatable `label`.
528
+ * `modules` is an ordered list of tabs; each picks a UI `layout`, the content
529
+ * collections it shows (`contentCollectionIds` — the filter on `GET /pai/content`),
530
+ * and a translatable `label`.
531
531
  */
532
532
  /** The UI layouts a tab can render with. `chat` is the conversation; the rest render content. */
533
533
  type ModuleLayout = 'chat' | 'home' | 'help' | 'news';
@@ -557,7 +557,8 @@ interface ModuleStatus {
557
557
  /**
558
558
  * `home` layout config — flat feature flags (no block authoring). The Home tab
559
559
  * is assembled from these in a fixed order: greeting → search → recent conversation
560
- * → status → a content list (from the tab's `contentTags`, titled `contentBlockTitle`).
560
+ * → status → a content list (the pinned items of the tab's `contentCollectionIds`,
561
+ * titled `contentBlockTitle`).
561
562
  */
562
563
  interface HomeConfig {
563
564
  brandName?: string;
@@ -573,8 +574,8 @@ interface HomeConfig {
573
574
  interface ModuleOptions extends HomeConfig {
574
575
  label: string;
575
576
  layout: ModuleLayout;
576
- /** Content tags to scope this tab to (matches content tagged with ANY of them). */
577
- contentTags?: string[];
577
+ /** Content collections this tab shows, in order (max 20). */
578
+ contentCollectionIds?: string[];
578
579
  id?: string;
579
580
  }
580
581
  /** The `modules` block is an ordered list of tabs (max 4). */
@@ -585,13 +586,13 @@ type ModulesOptions = ModuleOptions[];
585
586
  * `hide*` once, so no render site does `!hide…`. Present only for `home` tabs.
586
587
  */
587
588
  interface ResolvedModule extends Omit<HomeConfig, 'hideGreeting' | 'hideSearchBar' | 'hideRecentConversations'> {
588
- /** Stable id for nav + last-tab persistence (`id` ?? first `contentTags` ?? `layout`, deduped). */
589
+ /** Stable id for nav + last-tab persistence (`id` ?? first `contentCollectionIds` ?? `layout`, deduped). */
589
590
  id: string;
590
591
  /** i18n key or literal — resolved at render via the i18n strings. */
591
592
  label: string;
592
593
  layout: ModuleLayout;
593
- /** Content tag scope — the `tags` filter (omitted for `chat`). */
594
- contentTags?: string[];
594
+ /** The collections this tab shows, in order — the `contentCollectionIds` filter (omitted for `chat`). */
595
+ contentCollectionIds?: string[];
595
596
  showGreeting?: boolean;
596
597
  showSearchBar?: boolean;
597
598
  showRecentConversations?: boolean;
@@ -1109,39 +1110,8 @@ interface ResolvedOptions {
1109
1110
  onError?: ChatWidgetOptions['onError'];
1110
1111
  }
1111
1112
  //#endregion
1112
- //#region src/core/logger.d.ts
1113
- /**
1114
- * Comprehensive logger for the widget runtime.
1115
- *
1116
- * Designed for "I have a customer reporting a weird bug on their
1117
- * site, I want every relevant detail without rebuilding" debugging:
1118
- *
1119
- * • Five levels (off / error / warn / info / debug / trace) that
1120
- * gate output. Default `warn` — errors + warnings always go
1121
- * through, info / debug / trace stay silent until opted in.
1122
- * • Scoped child loggers — `logger.scope("transport")` returns a
1123
- * logger that tags every line `[helpai:transport] …`. Every
1124
- * subsystem has its own scope so the console transcript reads
1125
- * like a flight recorder.
1126
- * • Structured payloads — every call accepts an object as the
1127
- * second arg; the browser console renders it inline, expandable.
1128
- * • Remote toggle — `chat.setDebug("trace")`, `HelpAI.setDebug(…)`,
1129
- * `?helpai-debug=trace`, or the `options.debug` mount param all
1130
- * converge on the same internal level. Persisted to
1131
- * `localStorage["helpai.debug"]` so a refresh keeps visibility.
1132
- * • Co-hosted safety — every signal (query, global key, log tag) is
1133
- * brand-prefixed so two widgets on the same page don't fight over
1134
- * flags or pollute each other's transcripts.
1135
- */
1136
- type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
1137
- /** One structured line, as forwarded to an external {@link setLogSink} sink. */
1138
- interface LogEntry {
1139
- level: LogLevel;
1140
- /** Subsystem tag, e.g. `"transport"` or `"core:hooks"`. */
1141
- scope: string;
1142
- message: string;
1143
- payload?: unknown;
1144
- }
1113
+ //#region src/ui/host-mode.d.ts
1114
+ type HostMode = 'page' | 'standalone' | 'inline' | 'modal' | 'drawer' | 'fullscreen' | 'expanded' | 'open' | 'closed';
1145
1115
  //#endregion
1146
1116
  //#region src/schema/primitives.d.ts
1147
1117
  /** A single image asset (logo, hero, icon). */
@@ -1482,7 +1452,7 @@ declare const widgetSettingsSchema: z.ZodObject<{
1482
1452
  home: "home";
1483
1453
  news: "news";
1484
1454
  }>;
1485
- contentTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
1455
+ contentCollectionIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
1486
1456
  id: z.ZodOptional<z.ZodString>;
1487
1457
  brandName: z.ZodOptional<z.ZodString>;
1488
1458
  hideGreeting: z.ZodOptional<z.ZodBoolean>;
@@ -1817,7 +1787,7 @@ declare const widgetConfigSchema: z.ZodObject<{
1817
1787
  home: "home";
1818
1788
  news: "news";
1819
1789
  }>;
1820
- contentTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
1790
+ contentCollectionIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
1821
1791
  id: z.ZodOptional<z.ZodString>;
1822
1792
  brandName: z.ZodOptional<z.ZodString>;
1823
1793
  hideGreeting: z.ZodOptional<z.ZodBoolean>;
@@ -2153,7 +2123,7 @@ declare const widgetConfigPartialSchema: z.ZodObject<{
2153
2123
  home: "home";
2154
2124
  news: "news";
2155
2125
  }>;
2156
- contentTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
2126
+ contentCollectionIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
2157
2127
  id: z.ZodOptional<z.ZodString>;
2158
2128
  brandName: z.ZodOptional<z.ZodString>;
2159
2129
  hideGreeting: z.ZodOptional<z.ZodBoolean>;
@@ -2451,7 +2421,7 @@ declare const widgetSettingsPartialSchema: z.ZodObject<{
2451
2421
  home: "home";
2452
2422
  news: "news";
2453
2423
  }>;
2454
- contentTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
2424
+ contentCollectionIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
2455
2425
  id: z.ZodOptional<z.ZodString>;
2456
2426
  brandName: z.ZodOptional<z.ZodString>;
2457
2427
  hideGreeting: z.ZodOptional<z.ZodBoolean>;
@@ -2728,7 +2698,7 @@ declare const serverConfigSchema: z.ZodObject<{
2728
2698
  home: "home";
2729
2699
  news: "news";
2730
2700
  }>;
2731
- contentTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
2701
+ contentCollectionIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
2732
2702
  id: z.ZodOptional<z.ZodString>;
2733
2703
  brandName: z.ZodOptional<z.ZodString>;
2734
2704
  hideGreeting: z.ZodOptional<z.ZodBoolean>;
@@ -3016,7 +2986,7 @@ declare const handshakeResponseSchema: z.ZodObject<{
3016
2986
  home: "home";
3017
2987
  news: "news";
3018
2988
  }>;
3019
- contentTags: z.ZodOptional<z.ZodArray<z.ZodString>>;
2989
+ contentCollectionIds: z.ZodOptional<z.ZodArray<z.ZodUUID>>;
3020
2990
  id: z.ZodOptional<z.ZodString>;
3021
2991
  brandName: z.ZodOptional<z.ZodString>;
3022
2992
  hideGreeting: z.ZodOptional<z.ZodBoolean>;
@@ -3177,13 +3147,12 @@ interface EventMap {
3177
3147
  /** A content list (news / help / home block) rendered. */
3178
3148
  contentView: {
3179
3149
  section: string;
3180
- tags?: string;
3181
3150
  count: number;
3182
3151
  };
3183
- /** An article / content item was opened. */
3152
+ /** An article / content item was opened — with the collection it belongs to. */
3184
3153
  contentOpen: {
3185
3154
  contentId: string;
3186
- tags?: string;
3155
+ contentCollectionId: string;
3187
3156
  };
3188
3157
  /** The help search ran. Length + hit count only — never the query text. */
3189
3158
  contentSearch: {
@@ -3243,9 +3212,6 @@ interface EventMap {
3243
3212
  }
3244
3213
  type EventName = keyof EventMap;
3245
3214
  //#endregion
3246
- //#region src/ui/host-mode.d.ts
3247
- type HostMode = 'page' | 'standalone' | 'inline' | 'modal' | 'drawer' | 'fullscreen' | 'expanded' | 'open' | 'closed';
3248
- //#endregion
3249
3215
  //#region src/boot.d.ts
3250
3216
  /**
3251
3217
  * Determine what `data-mode` the host should start at — matching what App's
@@ -3278,6 +3244,40 @@ export declare const HOOK_WILDCARD = "*";
3278
3244
  */
3279
3245
  type HookListener = (instance: ChatWidgetInstance, event: EventName, data: unknown) => void;
3280
3246
  //#endregion
3247
+ //#region src/core/logger.d.ts
3248
+ /**
3249
+ * Comprehensive logger for the widget runtime.
3250
+ *
3251
+ * Designed for "I have a customer reporting a weird bug on their
3252
+ * site, I want every relevant detail without rebuilding" debugging:
3253
+ *
3254
+ * • Five levels (off / error / warn / info / debug / trace) that
3255
+ * gate output. Default `warn` — errors + warnings always go
3256
+ * through, info / debug / trace stay silent until opted in.
3257
+ * • Scoped child loggers — `logger.scope("transport")` returns a
3258
+ * logger that tags every line `[helpai:transport] …`. Every
3259
+ * subsystem has its own scope so the console transcript reads
3260
+ * like a flight recorder.
3261
+ * • Structured payloads — every call accepts an object as the
3262
+ * second arg; the browser console renders it inline, expandable.
3263
+ * • Remote toggle — `chat.setDebug("trace")`, `HelpAI.setDebug(…)`,
3264
+ * `?helpai-debug=trace`, or the `options.debug` mount param all
3265
+ * converge on the same internal level. Persisted to
3266
+ * `localStorage["helpai.debug"]` so a refresh keeps visibility.
3267
+ * • Co-hosted safety — every signal (query, global key, log tag) is
3268
+ * brand-prefixed so two widgets on the same page don't fight over
3269
+ * flags or pollute each other's transcripts.
3270
+ */
3271
+ type LogLevel = 'off' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
3272
+ /** One structured line, as forwarded to an external {@link setLogSink} sink. */
3273
+ interface LogEntry {
3274
+ level: LogLevel;
3275
+ /** Subsystem tag, e.g. `"transport"` or `"core:hooks"`. */
3276
+ scope: string;
3277
+ message: string;
3278
+ payload?: unknown;
3279
+ }
3280
+ //#endregion
3281
3281
  //#region src/index.d.ts
3282
3282
  /**
3283
3283
  * Handle returned by {@link mount} / {@link init}. All methods are safe to call