@guidelytech/shared 0.5.0 → 0.6.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/{chunk-5IQVBZO6.js → chunk-OLWGMDRX.js} +71 -4
- package/dist/chunk-OLWGMDRX.js.map +1 -0
- package/dist/index.cjs +244 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +457 -7
- package/dist/index.d.ts +457 -7
- package/dist/index.js +175 -3
- package/dist/index.js.map +1 -1
- package/dist/runtime.cjs +85 -2
- package/dist/runtime.cjs.map +1 -1
- package/dist/runtime.d.cts +56 -3
- package/dist/runtime.d.ts +56 -3
- package/dist/runtime.js +33 -1
- package/package.json +1 -1
- package/dist/chunk-5IQVBZO6.js.map +0 -1
- package/dist/chunk-QUKMOTT4.js +0 -477
- package/dist/chunk-QUKMOTT4.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,15 +1,25 @@
|
|
|
1
1
|
import {
|
|
2
|
+
CAPTURE_PARAM,
|
|
3
|
+
CAPTURE_SCREENSHOT_MAX_BYTES,
|
|
2
4
|
DEFAULT_PLATFORMS,
|
|
3
5
|
EMBED_IFRAME_ATTRS,
|
|
6
|
+
FILE_LINK_CLASS,
|
|
4
7
|
GUIDELY_ID_ATTRIBUTE,
|
|
5
8
|
MAX_COLLECTION_DEPTH,
|
|
6
9
|
MAX_PROPERTY_BYTES,
|
|
7
10
|
MAX_STACK_FRAMES,
|
|
11
|
+
MEDIA_FILE_MAX_BYTES,
|
|
12
|
+
MEDIA_FILE_TYPES,
|
|
8
13
|
MEDIA_IMAGE_MAX_BYTES,
|
|
9
14
|
MEDIA_IMAGE_TYPES,
|
|
15
|
+
MEDIA_MAX_BYTES,
|
|
10
16
|
MEDIA_VIDEO_MAX_BYTES,
|
|
11
17
|
MEDIA_VIDEO_TYPES,
|
|
12
18
|
NETWORK_PLUGIN,
|
|
19
|
+
PATH_ID_PATTERN,
|
|
20
|
+
PDF_BLOCK_CLASS,
|
|
21
|
+
PDF_MAX_PAGES,
|
|
22
|
+
PDF_PAGES_CLASS,
|
|
13
23
|
PLATFORMS,
|
|
14
24
|
RULE_FIELDS,
|
|
15
25
|
RULE_OPERATORS,
|
|
@@ -30,13 +40,16 @@ import {
|
|
|
30
40
|
evaluateRule,
|
|
31
41
|
evaluateRules,
|
|
32
42
|
fingerprintError,
|
|
43
|
+
firstNameFromTraits,
|
|
33
44
|
fnv1a,
|
|
45
|
+
foldPathIds,
|
|
34
46
|
getPath,
|
|
35
47
|
guidePlatforms,
|
|
36
48
|
guidelyIdFromSelector,
|
|
37
49
|
isAllowedEmbedSrc,
|
|
38
50
|
isArticleListed,
|
|
39
51
|
isChecklistComplete,
|
|
52
|
+
isFileLink,
|
|
40
53
|
isMediaContentType,
|
|
41
54
|
isPlainObject,
|
|
42
55
|
isQuestionVisible,
|
|
@@ -45,9 +58,12 @@ import {
|
|
|
45
58
|
isVideoContentType,
|
|
46
59
|
matchUrlPattern,
|
|
47
60
|
matchesAudiences,
|
|
61
|
+
mediaKind,
|
|
48
62
|
mediaMaxBytes,
|
|
49
63
|
normalizeErrorMessage,
|
|
50
64
|
normalizeFrameFile,
|
|
65
|
+
pageLabel,
|
|
66
|
+
pageTerms,
|
|
51
67
|
parseStack,
|
|
52
68
|
randomId,
|
|
53
69
|
resourceCenterSections,
|
|
@@ -60,7 +76,7 @@ import {
|
|
|
60
76
|
supportsPlatform,
|
|
61
77
|
toEmbedUrl,
|
|
62
78
|
visibleArticleIds
|
|
63
|
-
} from "./chunk-
|
|
79
|
+
} from "./chunk-OLWGMDRX.js";
|
|
64
80
|
|
|
65
81
|
// src/targeting.ts
|
|
66
82
|
import { z } from "zod";
|
|
@@ -447,6 +463,14 @@ var PublishedGuideSchema = z4.object({
|
|
|
447
463
|
|
|
448
464
|
// src/messenger.ts
|
|
449
465
|
import { z as z5 } from "zod";
|
|
466
|
+
var REPLY_TIMES = ["minutes", "hour", "hours", "day"];
|
|
467
|
+
var STATUS_LEVELS = ["operational", "degraded", "outage", "maintenance"];
|
|
468
|
+
var MessengerPageRequestSchema = z5.object({
|
|
469
|
+
anonymousId: z5.string().min(1).max(128),
|
|
470
|
+
userId: z5.string().max(256).optional().nullable(),
|
|
471
|
+
/** Pathname only: query strings and fragments are never sent. */
|
|
472
|
+
path: z5.string().min(1).max(1e3)
|
|
473
|
+
});
|
|
450
474
|
var MESSAGE_AUTHORS = ["user", "scout", "agent", "system"];
|
|
451
475
|
var MAX_MESSAGE_LENGTH = 4e3;
|
|
452
476
|
var messageText = z5.string().trim().min(1).max(MAX_MESSAGE_LENGTH);
|
|
@@ -459,7 +483,11 @@ var StartConversationSchema = z5.object({
|
|
|
459
483
|
var ConversationLookupSchema = z5.object({
|
|
460
484
|
tokens: z5.array(z5.string().min(16).max(128)).max(50)
|
|
461
485
|
});
|
|
462
|
-
var PostMessageSchema = z5.object({
|
|
486
|
+
var PostMessageSchema = z5.object({
|
|
487
|
+
message: messageText,
|
|
488
|
+
/** The page the user is on now (omitted when URL collection is off and by older SDKs), so Scout answers for that page. */
|
|
489
|
+
pageUrl: z5.string().max(2e3).optional()
|
|
490
|
+
});
|
|
463
491
|
var ConversationRatingSchema = z5.object({
|
|
464
492
|
rating: z5.number().int().min(1).max(5),
|
|
465
493
|
comment: z5.string().max(1e3).optional()
|
|
@@ -692,17 +720,135 @@ function templateConfig(id) {
|
|
|
692
720
|
return { template: t, config: GuideConfigSchema.parse(t.config) };
|
|
693
721
|
}
|
|
694
722
|
|
|
723
|
+
// src/howto.ts
|
|
724
|
+
import { z as z7 } from "zod";
|
|
725
|
+
var HOWTO_STEP_KINDS = ["action", "text", "heading", "tip", "alert"];
|
|
726
|
+
var HOWTO_ACTIONS = ["click", "type", "select", "navigate"];
|
|
727
|
+
var NormalizedRectSchema = z7.object({
|
|
728
|
+
x: z7.number().min(0).max(1),
|
|
729
|
+
y: z7.number().min(0).max(1),
|
|
730
|
+
width: z7.number().min(0).max(1),
|
|
731
|
+
height: z7.number().min(0).max(1)
|
|
732
|
+
});
|
|
733
|
+
var CapturedElementSchema = z7.object({
|
|
734
|
+
/** Visible name: aria-label, associated label, text, placeholder, alt or title. */
|
|
735
|
+
label: z7.string().max(200).default(""),
|
|
736
|
+
/** button, link, tab, menuitem, checkbox, radio, field, dropdown, option, element… */
|
|
737
|
+
role: z7.string().max(40).default("element"),
|
|
738
|
+
tag: z7.string().max(40).default("")
|
|
739
|
+
});
|
|
740
|
+
var CaptureStepSchema = z7.object({
|
|
741
|
+
/** Random id from the SDK; a retried upload with the same id is stored once. */
|
|
742
|
+
clientId: z7.string().min(1).max(64),
|
|
743
|
+
action: z7.enum(HOWTO_ACTIONS),
|
|
744
|
+
url: z7.string().max(2e3),
|
|
745
|
+
pageTitle: z7.string().max(300).default(""),
|
|
746
|
+
element: CapturedElementSchema.optional(),
|
|
747
|
+
/** Typed text or chosen option; absent when it was sensitive (`valueRedacted`). */
|
|
748
|
+
value: z7.string().max(200).optional(),
|
|
749
|
+
valueRedacted: z7.boolean().default(false),
|
|
750
|
+
/** Selectors for the element, so the step can later become an interactive tour step. */
|
|
751
|
+
selectors: z7.array(SelectorStrategySchema).max(10).default([]),
|
|
752
|
+
/** Where the element sits in the screenshot. */
|
|
753
|
+
highlight: NormalizedRectSchema.optional(),
|
|
754
|
+
/** Number of regions the SDK blurred in the screenshot before upload. */
|
|
755
|
+
redactions: z7.number().int().min(0).max(1e3).default(0),
|
|
756
|
+
occurredAt: z7.string().datetime().optional()
|
|
757
|
+
});
|
|
758
|
+
function quoted(s) {
|
|
759
|
+
const t = (s ?? "").replace(/\s+/g, " ").trim();
|
|
760
|
+
return t.length > 60 ? `\u201C${t.slice(0, 57)}\u2026\u201D` : `\u201C${t}\u201D`;
|
|
761
|
+
}
|
|
762
|
+
function cleanLabel(label) {
|
|
763
|
+
const raw = (label ?? "").replace(/\s+/g, " ").trim();
|
|
764
|
+
const cleaned = raw.replace(/^[^\p{L}\p{N}“"'(]+/u, "").replace(/[\s:*]+$/u, "").replace(/[^\p{L}\p{N})”"'?!.%]+$/u, "").trim();
|
|
765
|
+
return cleaned || raw;
|
|
766
|
+
}
|
|
767
|
+
var SEPARATORS = /\s+[·|•–—-]\s+|\s*[|·•]\s*/;
|
|
768
|
+
var ID_SEGMENT = /^(?:\d+|[0-9a-f]{8,}(?:-[0-9a-f]{4,})*|[A-Za-z0-9_-]{20,})$/i;
|
|
769
|
+
function humanize(segment) {
|
|
770
|
+
const words = decodeURIComponent(segment).replace(/[-_+]+/g, " ").trim();
|
|
771
|
+
return words ? words.charAt(0).toUpperCase() + words.slice(1) : "";
|
|
772
|
+
}
|
|
773
|
+
function pageName(url, pageTitle) {
|
|
774
|
+
const title = (pageTitle ?? "").replace(/\s+/g, " ").trim();
|
|
775
|
+
const parts = title.split(SEPARATORS).map((p) => p.trim()).filter(Boolean);
|
|
776
|
+
if (parts.length > 1) return parts[0];
|
|
777
|
+
let segments = [];
|
|
778
|
+
try {
|
|
779
|
+
segments = new URL(url).pathname.split("/").filter((p) => p && !ID_SEGMENT.test(p));
|
|
780
|
+
} catch {
|
|
781
|
+
segments = [];
|
|
782
|
+
}
|
|
783
|
+
const fromPath = segments.slice(-2).map(humanize).filter(Boolean).join(" \u203A ");
|
|
784
|
+
if (!fromPath) return title || hostAndPath(url);
|
|
785
|
+
if (!title) return fromPath;
|
|
786
|
+
const lower = title.toLowerCase();
|
|
787
|
+
const mentionsPath = segments.some((seg) => humanize(seg).toLowerCase().split(" ").some((w) => w.length > 2 && lower.includes(w)));
|
|
788
|
+
return mentionsPath ? title : fromPath;
|
|
789
|
+
}
|
|
790
|
+
var ROLE_NOUN = { tab: "tab", menuitem: "menu item", field: "field", dropdown: "dropdown", option: "option" };
|
|
791
|
+
function describeCaptureStep(step) {
|
|
792
|
+
const label = cleanLabel(step.element?.label);
|
|
793
|
+
const role = step.element?.role ?? "";
|
|
794
|
+
switch (step.action) {
|
|
795
|
+
case "navigate": {
|
|
796
|
+
const where = pageName(step.url, step.pageTitle);
|
|
797
|
+
return where ? `Go to ${quoted(where)}` : "Open the page";
|
|
798
|
+
}
|
|
799
|
+
case "type": {
|
|
800
|
+
const field = label ? quoted(label) : "the field";
|
|
801
|
+
if (step.valueRedacted || !step.value) return `Fill in ${field}`;
|
|
802
|
+
return `Type ${quoted(step.value)} into ${field}`;
|
|
803
|
+
}
|
|
804
|
+
case "select":
|
|
805
|
+
if (step.value && label) return `Select ${quoted(step.value)} from ${quoted(label)}`;
|
|
806
|
+
if (step.value) return `Select ${quoted(step.value)}`;
|
|
807
|
+
return label ? `Choose an option in ${quoted(label)}` : "Choose an option";
|
|
808
|
+
case "click":
|
|
809
|
+
default:
|
|
810
|
+
if (role === "checkbox") return label ? `Check ${quoted(label)}` : "Check the box";
|
|
811
|
+
if (role === "switch") return label ? `Turn ${quoted(label)} on or off` : "Flip the switch";
|
|
812
|
+
if (role === "radio") return label ? `Select ${quoted(label)}` : "Select the option";
|
|
813
|
+
if (role === "menuitem") return label ? `Choose ${quoted(label)} from the menu` : "Choose the menu item";
|
|
814
|
+
if (role === "tab") return label ? `Open the ${quoted(label)} tab` : "Open the tab";
|
|
815
|
+
if (label) return `Click ${quoted(label)}`;
|
|
816
|
+
return ROLE_NOUN[role] ? `Click the ${ROLE_NOUN[role]}` : role === "link" ? "Click the link" : "Click the button";
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
function hostAndPath(url) {
|
|
820
|
+
try {
|
|
821
|
+
const u = new URL(url);
|
|
822
|
+
return `${u.host}${u.pathname === "/" ? "" : u.pathname}`;
|
|
823
|
+
} catch {
|
|
824
|
+
return url.slice(0, 80);
|
|
825
|
+
}
|
|
826
|
+
}
|
|
827
|
+
var NormalizedPointSchema = z7.object({ x: z7.number().min(0).max(1), y: z7.number().min(0).max(1) });
|
|
828
|
+
var ANNOTATION_COLORS = ["brand", "red", "amber", "green", "black", "white"];
|
|
829
|
+
var HowToAnnotationSchema = z7.discriminatedUnion("type", [
|
|
830
|
+
z7.object({ id: z7.string().min(1).max(32), type: z7.literal("arrow"), from: NormalizedPointSchema, to: NormalizedPointSchema, color: z7.enum(ANNOTATION_COLORS).default("brand") }),
|
|
831
|
+
z7.object({ id: z7.string().min(1).max(32), type: z7.literal("text"), at: NormalizedPointSchema, text: z7.string().trim().min(1).max(120), color: z7.enum(ANNOTATION_COLORS).default("brand") }),
|
|
832
|
+
z7.object({ id: z7.string().min(1).max(32), type: z7.literal("box"), rect: NormalizedRectSchema, color: z7.enum(ANNOTATION_COLORS).default("brand") })
|
|
833
|
+
]);
|
|
834
|
+
var MAX_ANNOTATIONS = 30;
|
|
835
|
+
|
|
695
836
|
// src/index.ts
|
|
696
837
|
var SDK_API_VERSION = "v1";
|
|
697
|
-
var SHARED_VERSION = "0.
|
|
838
|
+
var SHARED_VERSION = "0.6.1";
|
|
698
839
|
export {
|
|
699
840
|
ADVANCE_ON,
|
|
841
|
+
ANNOTATION_COLORS,
|
|
700
842
|
AUTOCAPTURE_EVENTS,
|
|
701
843
|
AppearanceSchema,
|
|
702
844
|
AuthoringPickSchema,
|
|
703
845
|
AutocaptureSettingsSchema,
|
|
704
846
|
BUTTON_ACTIONS,
|
|
705
847
|
ButtonSchema,
|
|
848
|
+
CAPTURE_PARAM,
|
|
849
|
+
CAPTURE_SCREENSHOT_MAX_BYTES,
|
|
850
|
+
CaptureStepSchema,
|
|
851
|
+
CapturedElementSchema,
|
|
706
852
|
ChecklistConfigSchema,
|
|
707
853
|
ChecklistProgressRequestSchema,
|
|
708
854
|
ChecklistTaskSchema,
|
|
@@ -714,6 +860,7 @@ export {
|
|
|
714
860
|
EVENT_NAMES,
|
|
715
861
|
ErrorTrackingSettingsSchema,
|
|
716
862
|
EventBatchSchema,
|
|
863
|
+
FILE_LINK_CLASS,
|
|
717
864
|
FrequencySchema,
|
|
718
865
|
GUIDELY_ID_ATTRIBUTE,
|
|
719
866
|
GUIDE_KINDS,
|
|
@@ -723,17 +870,31 @@ export {
|
|
|
723
870
|
GuideConfigSchema,
|
|
724
871
|
GuideStateUpdateSchema,
|
|
725
872
|
HEATMAP_VIEWPORTS,
|
|
873
|
+
HOWTO_ACTIONS,
|
|
874
|
+
HOWTO_STEP_KINDS,
|
|
875
|
+
HowToAnnotationSchema,
|
|
726
876
|
IdentifyRequestSchema,
|
|
877
|
+
MAX_ANNOTATIONS,
|
|
727
878
|
MAX_COLLECTION_DEPTH,
|
|
728
879
|
MAX_MESSAGE_LENGTH,
|
|
729
880
|
MAX_PROPERTY_BYTES,
|
|
730
881
|
MAX_STACK_FRAMES,
|
|
882
|
+
MEDIA_FILE_MAX_BYTES,
|
|
883
|
+
MEDIA_FILE_TYPES,
|
|
731
884
|
MEDIA_IMAGE_MAX_BYTES,
|
|
732
885
|
MEDIA_IMAGE_TYPES,
|
|
886
|
+
MEDIA_MAX_BYTES,
|
|
733
887
|
MEDIA_VIDEO_MAX_BYTES,
|
|
734
888
|
MEDIA_VIDEO_TYPES,
|
|
735
889
|
MESSAGE_AUTHORS,
|
|
890
|
+
MessengerPageRequestSchema,
|
|
736
891
|
NETWORK_PLUGIN,
|
|
892
|
+
NormalizedPointSchema,
|
|
893
|
+
NormalizedRectSchema,
|
|
894
|
+
PATH_ID_PATTERN,
|
|
895
|
+
PDF_BLOCK_CLASS,
|
|
896
|
+
PDF_MAX_PAGES,
|
|
897
|
+
PDF_PAGES_CLASS,
|
|
737
898
|
PLACEMENTS,
|
|
738
899
|
PLATFORMS,
|
|
739
900
|
PostMessageSchema,
|
|
@@ -741,6 +902,7 @@ export {
|
|
|
741
902
|
PublishedGuideSchema,
|
|
742
903
|
REPLAY_MAX_COMPRESSED_BYTES,
|
|
743
904
|
REPLAY_MAX_RAW_BYTES,
|
|
905
|
+
REPLY_TIMES,
|
|
744
906
|
RULE_FIELDS,
|
|
745
907
|
RULE_OPERATORS,
|
|
746
908
|
ReplayChunkSchema,
|
|
@@ -756,6 +918,7 @@ export {
|
|
|
756
918
|
SHARED_VERSION,
|
|
757
919
|
SOURCEMAP_MAX_FILES_PER_UPLOAD,
|
|
758
920
|
SOURCEMAP_MAX_FILE_BYTES,
|
|
921
|
+
STATUS_LEVELS,
|
|
759
922
|
STEP_TYPES,
|
|
760
923
|
SURVEY_QUESTION_TYPES,
|
|
761
924
|
SdkEventSchema,
|
|
@@ -773,22 +936,27 @@ export {
|
|
|
773
936
|
WS_MAX_MESSAGES_PER_SOCKET,
|
|
774
937
|
WS_MAX_MESSAGE_BYTES,
|
|
775
938
|
clamp,
|
|
939
|
+
cleanLabel,
|
|
776
940
|
compare,
|
|
777
941
|
compareVersions,
|
|
778
942
|
defaultGuideConfig,
|
|
779
943
|
defaultStep,
|
|
944
|
+
describeCaptureStep,
|
|
780
945
|
describeRule,
|
|
781
946
|
emptyRuleGroup,
|
|
782
947
|
evaluateRule,
|
|
783
948
|
evaluateRules,
|
|
784
949
|
fingerprintError,
|
|
950
|
+
firstNameFromTraits,
|
|
785
951
|
fnv1a,
|
|
952
|
+
foldPathIds,
|
|
786
953
|
getPath,
|
|
787
954
|
guidePlatforms,
|
|
788
955
|
guidelyIdFromSelector,
|
|
789
956
|
isAllowedEmbedSrc,
|
|
790
957
|
isArticleListed,
|
|
791
958
|
isChecklistComplete,
|
|
959
|
+
isFileLink,
|
|
792
960
|
isMediaContentType,
|
|
793
961
|
isPlainObject,
|
|
794
962
|
isQuestionVisible,
|
|
@@ -797,9 +965,13 @@ export {
|
|
|
797
965
|
isVideoContentType,
|
|
798
966
|
matchUrlPattern,
|
|
799
967
|
matchesAudiences,
|
|
968
|
+
mediaKind,
|
|
800
969
|
mediaMaxBytes,
|
|
801
970
|
normalizeErrorMessage,
|
|
802
971
|
normalizeFrameFile,
|
|
972
|
+
pageLabel,
|
|
973
|
+
pageName,
|
|
974
|
+
pageTerms,
|
|
803
975
|
parseStack,
|
|
804
976
|
randomId,
|
|
805
977
|
resolveCaptureSettings,
|