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.
- package/ARCHITECTURE-v2.md +225 -0
- package/dist/sdk.iife.js +348 -0
- package/package.json +22 -0
- package/src/__tests__/day1.test.ts +37 -0
- package/src/__tests__/day2.test.ts +447 -0
- package/src/__tests__/day3.test.ts +110 -0
- package/src/__tests__/day4.test.ts +115 -0
- package/src/__tests__/day5.test.ts +102 -0
- package/src/__tests__/snapshot-dom-collector.test.ts +153 -0
- package/src/__tests__/snapshot-sender.test.ts +111 -0
- package/src/__tests__/v2-integration.test.ts +305 -0
- package/src/__tests__/v2-positioner.test.ts +115 -0
- package/src/__tests__/v2-renderer.test.ts +189 -0
- package/src/__tests__/v2-types.test.ts +74 -0
- package/src/__tests__/week2-day1.test.ts +62 -0
- package/src/__tests__/week2-day2.test.ts +128 -0
- package/src/__tests__/week2-day3.test.ts +128 -0
- package/src/__tests__/week2-day4.test.ts +177 -0
- package/src/__tests__/week2-day5.test.ts +294 -0
- package/src/__tests__/week3-day1.test.ts +169 -0
- package/src/__tests__/week3-day2.test.ts +267 -0
- package/src/__tests__/week3-day3.test.ts +213 -0
- package/src/__tests__/week3-day4.test.ts +213 -0
- package/src/__tests__/week3-day5.test.ts +350 -0
- package/src/__tests__/week4-day1.test.ts +277 -0
- package/src/__tests__/week4-day2.test.ts +227 -0
- package/src/__tests__/week4-day3.test.ts +323 -0
- package/src/__tests__/week4-day4.test.ts +210 -0
- package/src/__tests__/week4-day5.test.ts +503 -0
- package/src/__tests__/week5-day1.test.ts +152 -0
- package/src/__tests__/week5-day2.test.ts +222 -0
- package/src/__tests__/week5-day3.test.ts +297 -0
- package/src/__tests__/week5-day4.test.ts +306 -0
- package/src/__tests__/week5-day5.test.ts +345 -0
- package/src/__tests__/week7-day5-api-flows.test.ts +353 -0
- package/src/auto-generate/context-collector.ts +47 -0
- package/src/auto-generate/flow-generator-client.ts +97 -0
- package/src/browser.ts +5 -0
- package/src/components/celebration.ts +44 -0
- package/src/components/checklist-css.ts +159 -0
- package/src/components/checklist.ts +295 -0
- package/src/components/modal-css.ts +96 -0
- package/src/components/modal.ts +171 -0
- package/src/components/shadow-host.ts +30 -0
- package/src/core/api-client.ts +39 -0
- package/src/core/api-flows.ts +204 -0
- package/src/core/config.ts +37 -0
- package/src/core/event-batcher.ts +169 -0
- package/src/core/sdk.ts +301 -0
- package/src/detection/user-detection.ts +55 -0
- package/src/index.ts +95 -0
- package/src/snapshot/dom-collector.ts +193 -0
- package/src/snapshot/sender.ts +105 -0
- package/src/storage/event-listener.ts +59 -0
- package/src/storage/progress-tracker.ts +78 -0
- package/src/styles/checklist-css.ts +159 -0
- package/src/styles/checklist.css +166 -0
- package/src/styles/modal-css.ts +96 -0
- package/src/styles/modal.css +102 -0
- package/src/utils/dom.ts +49 -0
- package/src/utils/fingerprint.ts +20 -0
- package/src/utils/logger.ts +17 -0
- package/src/v2/positioner.ts +105 -0
- package/src/v2/renderer.ts +287 -0
- package/src/v2/styles.ts +89 -0
- package/src/v2/types.ts +53 -0
- package/tsconfig.json +11 -0
- package/vite.config.ts +28 -0
- package/vitest.config.ts +7 -0
package/src/v2/types.ts
ADDED
|
@@ -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
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
|
+
});
|