onboardme-sdk 0.0.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.
Files changed (69) hide show
  1. package/ARCHITECTURE-v2.md +225 -0
  2. package/dist/sdk.iife.js +348 -0
  3. package/package.json +22 -0
  4. package/src/__tests__/day1.test.ts +37 -0
  5. package/src/__tests__/day2.test.ts +447 -0
  6. package/src/__tests__/day3.test.ts +110 -0
  7. package/src/__tests__/day4.test.ts +115 -0
  8. package/src/__tests__/day5.test.ts +102 -0
  9. package/src/__tests__/snapshot-dom-collector.test.ts +153 -0
  10. package/src/__tests__/snapshot-sender.test.ts +111 -0
  11. package/src/__tests__/v2-integration.test.ts +305 -0
  12. package/src/__tests__/v2-positioner.test.ts +115 -0
  13. package/src/__tests__/v2-renderer.test.ts +189 -0
  14. package/src/__tests__/v2-types.test.ts +74 -0
  15. package/src/__tests__/week2-day1.test.ts +62 -0
  16. package/src/__tests__/week2-day2.test.ts +128 -0
  17. package/src/__tests__/week2-day3.test.ts +128 -0
  18. package/src/__tests__/week2-day4.test.ts +177 -0
  19. package/src/__tests__/week2-day5.test.ts +294 -0
  20. package/src/__tests__/week3-day1.test.ts +169 -0
  21. package/src/__tests__/week3-day2.test.ts +267 -0
  22. package/src/__tests__/week3-day3.test.ts +213 -0
  23. package/src/__tests__/week3-day4.test.ts +213 -0
  24. package/src/__tests__/week3-day5.test.ts +350 -0
  25. package/src/__tests__/week4-day1.test.ts +277 -0
  26. package/src/__tests__/week4-day2.test.ts +227 -0
  27. package/src/__tests__/week4-day3.test.ts +323 -0
  28. package/src/__tests__/week4-day4.test.ts +210 -0
  29. package/src/__tests__/week4-day5.test.ts +503 -0
  30. package/src/__tests__/week5-day1.test.ts +152 -0
  31. package/src/__tests__/week5-day2.test.ts +222 -0
  32. package/src/__tests__/week5-day3.test.ts +297 -0
  33. package/src/__tests__/week5-day4.test.ts +306 -0
  34. package/src/__tests__/week5-day5.test.ts +345 -0
  35. package/src/__tests__/week7-day5-api-flows.test.ts +353 -0
  36. package/src/auto-generate/context-collector.ts +47 -0
  37. package/src/auto-generate/flow-generator-client.ts +97 -0
  38. package/src/browser.ts +5 -0
  39. package/src/components/celebration.ts +44 -0
  40. package/src/components/checklist-css.ts +159 -0
  41. package/src/components/checklist.ts +295 -0
  42. package/src/components/modal-css.ts +96 -0
  43. package/src/components/modal.ts +171 -0
  44. package/src/components/shadow-host.ts +30 -0
  45. package/src/core/api-client.ts +39 -0
  46. package/src/core/api-flows.ts +204 -0
  47. package/src/core/config.ts +37 -0
  48. package/src/core/event-batcher.ts +169 -0
  49. package/src/core/sdk.ts +301 -0
  50. package/src/detection/user-detection.ts +55 -0
  51. package/src/index.ts +95 -0
  52. package/src/snapshot/dom-collector.ts +193 -0
  53. package/src/snapshot/sender.ts +105 -0
  54. package/src/storage/event-listener.ts +59 -0
  55. package/src/storage/progress-tracker.ts +78 -0
  56. package/src/styles/checklist-css.ts +159 -0
  57. package/src/styles/checklist.css +166 -0
  58. package/src/styles/modal-css.ts +96 -0
  59. package/src/styles/modal.css +102 -0
  60. package/src/utils/dom.ts +49 -0
  61. package/src/utils/fingerprint.ts +20 -0
  62. package/src/utils/logger.ts +17 -0
  63. package/src/v2/positioner.ts +105 -0
  64. package/src/v2/renderer.ts +287 -0
  65. package/src/v2/styles.ts +89 -0
  66. package/src/v2/types.ts +53 -0
  67. package/tsconfig.json +11 -0
  68. package/vite.config.ts +28 -0
  69. package/vitest.config.ts +7 -0
@@ -0,0 +1,53 @@
1
+ // v2 schema types for the SDK renderer (Architecture v2 — Phase F).
2
+ //
3
+ // Mirrors the API validator at apps/api/src/services/flow-validator.service.ts
4
+ // and the dashboard editor at apps/dashboard/src/components/flow-editor/types.ts.
5
+ // Three places need to agree on this shape — the API rejects malformed configs
6
+ // at publish time, the dashboard guides the PM to valid edits, and the SDK
7
+ // renders only what these types describe.
8
+
9
+ export type V2StepType = 'tooltip' | 'modal' | 'highlight'
10
+ export type V2Placement = 'top' | 'bottom' | 'left' | 'right' | 'center'
11
+ export type V2ActionType = 'next' | 'skip' | 'complete'
12
+
13
+ export interface V2Action {
14
+ type: V2ActionType
15
+ label: string
16
+ }
17
+
18
+ export interface V2Position {
19
+ selector: string
20
+ placement: V2Placement
21
+ }
22
+
23
+ export interface V2Step {
24
+ id: string
25
+ title: string
26
+ description: string
27
+ type: V2StepType
28
+ position: V2Position
29
+ action: V2Action
30
+ }
31
+
32
+ export interface V2FlowConfig {
33
+ steps: V2Step[]
34
+ }
35
+
36
+ // Detector: a flow is v2 if its first step has a v2-shaped `position` object
37
+ // AND a v2-shaped `action` object. Legacy flows have neither — they use
38
+ // `body`, `targetSelector`, `primaryCta`. This is structural (not a version
39
+ // flag) so flows generated by Phase D are recognised regardless of their
40
+ // id/version metadata.
41
+ export function isV2FlowConfig(config: unknown): config is V2FlowConfig {
42
+ if (!config || typeof config !== 'object') return false
43
+ const c = config as { steps?: unknown }
44
+ if (!Array.isArray(c.steps) || c.steps.length === 0) return false
45
+ const first = c.steps[0] as Record<string, unknown> | null
46
+ if (!first) return false
47
+ const position = first.position as Record<string, unknown> | undefined
48
+ const action = first.action as Record<string, unknown> | undefined
49
+ if (!position || typeof position.selector !== 'string') return false
50
+ if (typeof position.placement !== 'string') return false
51
+ if (!action || typeof action.type !== 'string' || typeof action.label !== 'string') return false
52
+ return true
53
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "outDir": "./dist",
5
+ "noEmit": true,
6
+ "paths": {
7
+ "@onboardme/types": ["../types/src/index.ts"]
8
+ }
9
+ },
10
+ "include": ["src/**/*", "vite.config.ts"]
11
+ }
package/vite.config.ts ADDED
@@ -0,0 +1,28 @@
1
+ import { defineConfig } from 'vitest/config';
2
+ import { resolve } from 'path';
3
+
4
+ export default defineConfig({
5
+ resolve: {
6
+ alias: {
7
+ '@onboardme/types': resolve(__dirname, '../types/src/index.ts'),
8
+ },
9
+ },
10
+ build: {
11
+ lib: {
12
+ entry: resolve(__dirname, 'src/browser.ts'),
13
+ name: 'OnboardMe',
14
+ fileName: 'sdk',
15
+ formats: ['iife'],
16
+ },
17
+ outDir: 'dist',
18
+ minify: true,
19
+ rollupOptions: {
20
+ output: {
21
+ entryFileNames: 'sdk.iife.js',
22
+ },
23
+ },
24
+ },
25
+ test: {
26
+ environment: 'node',
27
+ },
28
+ });
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from 'vitest/config';
2
+
3
+ export default defineConfig({
4
+ test: {
5
+ environment: 'jsdom',
6
+ },
7
+ });