@eventop/sdk 1.0.5 → 1.0.6

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.
Files changed (44) hide show
  1. package/dist/index.d.ts +259 -0
  2. package/dist/react/index.cjs +473 -0
  3. package/dist/react/index.d.ts +208 -0
  4. package/dist/react/index.js +467 -0
  5. package/package.json +1 -1
  6. package/dist/cjs/client.js +0 -54
  7. package/dist/cjs/errors.js +0 -28
  8. package/dist/cjs/index.js +0 -32
  9. package/dist/cjs/resources/checkout.js +0 -18
  10. package/dist/cjs/resources/customers.js +0 -1
  11. package/dist/cjs/resources/subscriptions.js +0 -18
  12. package/dist/cjs/resources/webhooks.js +0 -60
  13. package/dist/cjs/types.js +0 -2
  14. package/dist/client.js +0 -63
  15. package/dist/errors.js +0 -33
  16. package/dist/esm/client.js +0 -45
  17. package/dist/esm/errors.js +0 -26
  18. package/dist/esm/index.js +0 -14
  19. package/dist/esm/resources/checkout.js +0 -14
  20. package/dist/esm/resources/customers.js +0 -1
  21. package/dist/esm/resources/subscriptions.js +0 -14
  22. package/dist/esm/resources/webhooks.js +0 -23
  23. package/dist/esm/types.js +0 -1
  24. package/dist/resources/checkout.js +0 -33
  25. package/dist/resources/customers.js +0 -1
  26. package/dist/resources/subscriptions.js +0 -33
  27. package/dist/resources/webhooks.js +0 -60
  28. package/dist/types/client.d.ts +0 -9
  29. package/dist/types/client.d.ts.map +0 -1
  30. package/dist/types/errors.d.ts +0 -15
  31. package/dist/types/errors.d.ts.map +0 -1
  32. package/dist/types/index.d.ts +0 -13
  33. package/dist/types/index.d.ts.map +0 -1
  34. package/dist/types/resources/checkout.d.ts +0 -10
  35. package/dist/types/resources/checkout.d.ts.map +0 -1
  36. package/dist/types/resources/customers.d.ts +0 -1
  37. package/dist/types/resources/customers.d.ts.map +0 -1
  38. package/dist/types/resources/subscriptions.d.ts +0 -10
  39. package/dist/types/resources/subscriptions.d.ts.map +0 -1
  40. package/dist/types/resources/webhooks.d.ts +0 -9
  41. package/dist/types/resources/webhooks.d.ts.map +0 -1
  42. package/dist/types/types.d.ts +0 -44
  43. package/dist/types/types.d.ts.map +0 -1
  44. package/dist/types.js +0 -2
@@ -0,0 +1,259 @@
1
+ // ─── Step ────────────────────────────────────────────────────────────────────
2
+
3
+ export interface Step {
4
+ id?: string;
5
+ title: string;
6
+ text: string;
7
+ selector?: string;
8
+ position?: 'top' | 'bottom' | 'left' | 'right' | 'auto';
9
+ }
10
+
11
+ // ─── AdvanceOn ───────────────────────────────────────────────────────────────
12
+
13
+ export interface AdvanceOn {
14
+ /** CSS selector for the element to listen on. Defaults to the feature element. */
15
+ selector?: string;
16
+ /** DOM event name e.g. 'click', 'blur', 'change' */
17
+ event: string;
18
+ /** Milliseconds to wait before advancing (default: 300) */
19
+ delay?: number;
20
+ }
21
+
22
+ // ─── Flow step (multi-step feature) ──────────────────────────────────────────
23
+
24
+ export interface FlowStep {
25
+ /** CSS selector for this step's target element */
26
+ selector?: string;
27
+ /** Wait for this selector to appear in the DOM before showing the step */
28
+ waitFor?: string | null;
29
+ /** Auto-advance config */
30
+ advanceOn?: AdvanceOn | null;
31
+ }
32
+
33
+ // ─── Screen ──────────────────────────────────────────────────────────────────
34
+
35
+ export interface Screen {
36
+ /** Unique screen identifier */
37
+ id: string;
38
+ /** Returns true if the user is currently on this screen */
39
+ check: () => boolean;
40
+ /** Navigate to this screen. Can be async. */
41
+ navigate?: () => void | Promise<void>;
42
+ /** CSS selector to wait for after navigating */
43
+ waitFor?: string;
44
+ }
45
+
46
+ // ─── Feature ─────────────────────────────────────────────────────────────────
47
+
48
+ export interface Feature {
49
+ /** Unique feature id — referenced by the AI when building tour steps */
50
+ id: string;
51
+ /** Human-readable name the AI reads to understand the feature */
52
+ name: string;
53
+ /** What the feature does — AI uses this to match user intent */
54
+ description?: string;
55
+ /** CSS selector for the feature's primary DOM element */
56
+ selector: string;
57
+ /** Additional related selectors for context */
58
+ relatedSelectors?: Record<string, string>;
59
+ /** Auto-advance when this event fires */
60
+ advanceOn?: AdvanceOn | null;
61
+ /** Wait for this selector before showing the step */
62
+ waitFor?: string | null;
63
+ /**
64
+ * Multi-step flow. Each entry is a sequential sub-step.
65
+ * Developer lists selectors; AI generates the copy for each.
66
+ */
67
+ flow?: FlowStep[];
68
+ /**
69
+ * Screen this feature lives on.
70
+ * SDK navigates to the correct screen before showing the step.
71
+ */
72
+ screen?: Screen;
73
+ }
74
+
75
+ // ─── Theme ───────────────────────────────────────────────────────────────────
76
+
77
+ export interface ThemeTokens {
78
+ accent?: string;
79
+ accentSecondary?: string;
80
+ bg?: string;
81
+ surface?: string;
82
+ border?: string;
83
+ text?: string;
84
+ textDim?: string;
85
+ radius?: string;
86
+ fontFamily?: string;
87
+ }
88
+
89
+ export interface Theme {
90
+ /** 'auto' reads prefers-color-scheme. Default: 'auto' */
91
+ mode?: 'auto' | 'light' | 'dark';
92
+ /** Named preset. Overridden by tokens if both are provided. */
93
+ preset?: 'default' | 'minimal' | 'soft';
94
+ /** Override individual design tokens */
95
+ tokens?: ThemeTokens;
96
+ }
97
+
98
+ // ─── Position ────────────────────────────────────────────────────────────────
99
+
100
+ export interface Position {
101
+ /** Which corner to anchor the chat bubble. Default: 'bottom-right' */
102
+ corner?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
103
+ /** Horizontal offset in px. Default: 28 */
104
+ offsetX?: number;
105
+ /** Vertical offset in px. Default: 28 */
106
+ offsetY?: number;
107
+ }
108
+
109
+ // ─── Config ──────────────────────────────────────────────────────────────────
110
+
111
+ export interface Config {
112
+ /** Your app's display name. Required. */
113
+ appName: string;
114
+ /** Name shown in the chat header. Default: 'AI Guide' */
115
+ assistantName?: string;
116
+ /** Feature definitions the AI can reference. Required. */
117
+ features: Feature[];
118
+ /** Clickable suggestion chips shown on first open */
119
+ suggestions?: string[];
120
+ theme?: Theme;
121
+ position?: Position;
122
+ /** @internal — set by provider factories */
123
+ _providerName?: string;
124
+ }
125
+
126
+ // ─── Provider ────────────────────────────────────────────────────────────────
127
+
128
+ export interface ProviderArgs {
129
+ systemPrompt: string;
130
+ messages: Array<{ role: 'user' | 'assistant'; content: string }>;
131
+ }
132
+
133
+ export interface ProviderResult {
134
+ message: string;
135
+ steps: Step[];
136
+ }
137
+
138
+ export type ProviderFn = (args: ProviderArgs) => Promise<ProviderResult>;
139
+
140
+ export interface ClaudeOptions {
141
+ apiKey: string;
142
+ /** Default: 'claude-sonnet-4-20250514' */
143
+ model?: string;
144
+ }
145
+
146
+ export interface OpenAIOptions {
147
+ apiKey: string;
148
+ /** Default: 'gpt-4o' */
149
+ model?: string;
150
+ }
151
+
152
+ export interface GeminiOptions {
153
+ apiKey: string;
154
+ /** Default: 'gemini-2.5-flash' */
155
+ model?: string;
156
+ }
157
+
158
+ export interface Providers {
159
+ /**
160
+ * Anthropic Claude provider.
161
+ * @warning Never use apiKey in client-side code. Use providers.custom() in production.
162
+ */
163
+ claude(opts: ClaudeOptions): ProviderFn;
164
+ /**
165
+ * OpenAI provider.
166
+ * @warning Never use apiKey in client-side code. Use providers.custom() in production.
167
+ */
168
+ openai(opts: OpenAIOptions): ProviderFn;
169
+ /**
170
+ * Google Gemini provider.
171
+ * @warning Never use apiKey in client-side code. Use providers.custom() in production.
172
+ */
173
+ gemini(opts: GeminiOptions): ProviderFn;
174
+ /**
175
+ * Custom provider — proxy through your own server.
176
+ * Recommended for production. Keeps API keys off the browser.
177
+ *
178
+ * @example
179
+ * providers.custom(async ({ systemPrompt, messages }) => {
180
+ * const res = await fetch('/api/guide', {
181
+ * method: 'POST',
182
+ * headers: { 'Content-Type': 'application/json' },
183
+ * body: JSON.stringify({ systemPrompt, messages }),
184
+ * });
185
+ * return res.json();
186
+ * })
187
+ */
188
+ custom(fn: ProviderFn): ProviderFn;
189
+ }
190
+
191
+ // ─── Init options ─────────────────────────────────────────────────────────────
192
+
193
+ export interface InitOptions {
194
+ provider: ProviderFn;
195
+ config: Config;
196
+ }
197
+
198
+ // ─── Main SDK ────────────────────────────────────────────────────────────────
199
+
200
+ export interface EventopSDK {
201
+ providers: Providers;
202
+
203
+ /** Initialize the SDK. Must be called once before any other method. */
204
+ init(opts: InitOptions): void;
205
+
206
+ /** Open the chat panel */
207
+ open(): void;
208
+
209
+ /** Close the chat panel */
210
+ close(): void;
211
+
212
+ /**
213
+ * Run a tour manually, bypassing the AI.
214
+ * Useful for testing or hardcoded flows.
215
+ */
216
+ runTour(steps: Step[], options?: { showProgress?: boolean; waitTimeout?: number }): Promise<void>;
217
+
218
+ /**
219
+ * Hard cancel the active tour.
220
+ * Clears all pause state — no resume available after this.
221
+ */
222
+ cancelTour(): void;
223
+
224
+ /**
225
+ * Resume a paused tour from where the user left off.
226
+ * Called automatically by the resume button in the chat panel.
227
+ */
228
+ resumeTour(): void;
229
+
230
+ /**
231
+ * Advance the current tour step programmatically.
232
+ * Call after async validation succeeds.
233
+ *
234
+ * @example
235
+ * const ok = await validateEmail(email);
236
+ * if (ok) ShepherdAI.stepComplete();
237
+ */
238
+ stepComplete(): void;
239
+
240
+ /**
241
+ * Block tour advancement and show an inline error in the current step tooltip.
242
+ *
243
+ * @example
244
+ * ShepherdAI.stepFail('Please enter a valid email address.');
245
+ */
246
+ stepFail(message: string): void;
247
+
248
+ /** Returns true if a tour is currently running */
249
+ isActive(): boolean;
250
+
251
+ /** Returns true if a tour is paused (cancelled but resumable) */
252
+ isPaused(): boolean;
253
+
254
+ /** @internal — used by the React/Vue packages to sync live feature registry */
255
+ _updateConfig(partial: Partial<Config>): void;
256
+ }
257
+
258
+ declare const ShepherdAI: EventopSDK;
259
+ export default ShepherdAI;