@knocklabs/client 0.16.4 → 0.17.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.
@@ -4,6 +4,9 @@ import { GenericData } from "@knocklabs/types";
4
4
  // Fetch guides API
5
5
  //
6
6
 
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ export type Any = any;
9
+
7
10
  export interface StepMessageState {
8
11
  id: string;
9
12
  seen_at: string | null;
@@ -13,30 +16,37 @@ export interface StepMessageState {
13
16
  link_clicked_at: string | null;
14
17
  }
15
18
 
16
- export interface GuideStepData {
19
+ export interface GuideStepData<TContent = Any> {
17
20
  ref: string;
18
21
  schema_key: string;
19
22
  schema_semver: string;
20
23
  schema_variant_key: string;
21
24
  message: StepMessageState;
22
- // eslint-disable-next-line
23
- content: any;
25
+ content: TContent;
24
26
  }
25
27
 
26
- interface GuideActivationLocationRuleData {
28
+ export interface GuideActivationUrlRuleData {
29
+ directive: "allow" | "block";
30
+ variable: "pathname";
31
+ operator: "equal_to" | "contains";
32
+ argument: string;
33
+ }
34
+
35
+ interface GuideActivationUrlPatternData {
27
36
  directive: "allow" | "block";
28
37
  pathname: string;
29
38
  }
30
39
 
31
- export interface GuideData {
40
+ export interface GuideData<TContent = Any> {
32
41
  __typename: "Guide";
33
42
  channel_id: string;
34
43
  id: string;
35
44
  key: string;
36
45
  type: string;
37
46
  semver: string;
38
- steps: GuideStepData[];
39
- activation_location_rules: GuideActivationLocationRuleData[];
47
+ steps: GuideStepData<TContent>[];
48
+ activation_url_rules: GuideActivationUrlRuleData[];
49
+ activation_url_patterns: GuideActivationUrlPatternData[];
40
50
  bypass_global_group_limit: boolean;
41
51
  inserted_at: string;
42
52
  updated_at: string;
@@ -57,6 +67,7 @@ export type GetGuidesQueryParams = {
57
67
  data?: string;
58
68
  tenant?: string;
59
69
  type?: string;
70
+ force_all_guides?: boolean;
60
71
  };
61
72
 
62
73
  export type GetGuidesResponse = {
@@ -103,7 +114,8 @@ type SocketEventType =
103
114
  | "guide.updated"
104
115
  | "guide.removed"
105
116
  | "guide_group.added"
106
- | "guide_group.updated";
117
+ | "guide_group.updated"
118
+ | "guide.live_preview_updated";
107
119
 
108
120
  type SocketEventPayload<E extends SocketEventType, D> = {
109
121
  topic: string;
@@ -136,32 +148,39 @@ export type GuideGroupUpdatedEvent = SocketEventPayload<
136
148
  { guide_group: GuideGroupData }
137
149
  >;
138
150
 
151
+ export type GuideLivePreviewUpdatedEvent = SocketEventPayload<
152
+ "guide.live_preview_updated",
153
+ { guide: GuideData; eligible: boolean }
154
+ >;
155
+
139
156
  export type GuideSocketEvent =
140
157
  | GuideAddedEvent
141
158
  | GuideUpdatedEvent
142
159
  | GuideRemovedEvent
143
160
  | GuideGroupAddedEvent
144
- | GuideGroupUpdatedEvent;
161
+ | GuideGroupUpdatedEvent
162
+ | GuideLivePreviewUpdatedEvent;
145
163
 
146
164
  //
147
165
  // Guide client
148
166
  //
149
167
 
150
- export interface KnockGuideStep extends GuideStepData {
168
+ export interface KnockGuideStep<TContent = Any>
169
+ extends GuideStepData<TContent> {
151
170
  markAsSeen: () => void;
152
171
  markAsInteracted: (params?: { metadata?: GenericData }) => void;
153
172
  markAsArchived: () => void;
154
173
  }
155
174
 
156
- interface KnockGuideActivationLocationRule
157
- extends GuideActivationLocationRuleData {
175
+ export interface KnockGuideActivationUrlPattern
176
+ extends GuideActivationUrlPatternData {
158
177
  pattern: URLPattern;
159
178
  }
160
179
 
161
- export interface KnockGuide extends GuideData {
162
- steps: KnockGuideStep[];
163
- activation_location_rules: KnockGuideActivationLocationRule[];
164
- getStep: () => KnockGuideStep | undefined;
180
+ export interface KnockGuide<TContent = Any> extends GuideData<TContent> {
181
+ steps: KnockGuideStep<TContent>[];
182
+ activation_url_patterns: KnockGuideActivationUrlPattern[];
183
+ getStep: () => KnockGuideStep<TContent> | undefined;
165
184
  }
166
185
 
167
186
  type QueryKey = string;
@@ -171,13 +190,20 @@ export type QueryStatus = {
171
190
  error?: Error;
172
191
  };
173
192
 
193
+ export type DebugState = {
194
+ forcedGuideKey?: string | null;
195
+ previewSessionId?: string | null;
196
+ };
197
+
174
198
  export type StoreState = {
175
199
  guideGroups: GuideGroupData[];
176
200
  guideGroupDisplayLogs: Record<GuideGroupData["key"], string>;
177
201
  guides: Record<KnockGuide["key"], KnockGuide>;
202
+ previewGuides: Record<KnockGuide["key"], KnockGuide>;
178
203
  queries: Record<QueryKey, QueryStatus>;
179
204
  location: string | undefined;
180
205
  counter: number;
206
+ debug: DebugState;
181
207
  };
182
208
 
183
209
  export type QueryFilterParams = Pick<GetGuidesQueryParams, "type">;