@cognior/iap-sdk 0.0.2

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.
@@ -0,0 +1,113 @@
1
+ /**
2
+ * User interface - follows DAP standard user model
3
+ */
4
+ interface DapUser {
5
+ id: string;
6
+ role?: string;
7
+ email?: string;
8
+ attributes?: Record<string, string>;
9
+ }
10
+
11
+ /** Logical operators for composite triggers */
12
+ type LogicalOperator = "And" | "Or";
13
+ /** Rule operators for condition evaluation */
14
+ type RuleOperator = "Equals" | "NotEquals" | "Contains" | "NotContains" | "StartsWith" | "EndsWith" | "GreaterThan" | "LessThan" | "GreaterThanOrEqual" | "LessThanOrEqual" | "In" | "NotIn" | "Regex" | "Empty";
15
+ /** Trigger types */
16
+ type TriggerType = "Single" | "Composite";
17
+ /** Trigger condition kinds */
18
+ type TriggerConditionKind = "Dom" | "Lifecycle" | "Input" | "Time" | "Media" | "System";
19
+ /** Flow execution modes */
20
+ type FlowExecutionMode = "Linear" | "AnyOrder";
21
+ /** Individual trigger condition */
22
+ interface TriggerCondition {
23
+ kind: TriggerConditionKind;
24
+ event: string;
25
+ selector?: string;
26
+ operator?: RuleOperator;
27
+ value?: any;
28
+ debounceMs?: number;
29
+ }
30
+ /** Step-level trigger definition */
31
+ interface TriggerDefinition {
32
+ type: TriggerType;
33
+ operator: LogicalOperator;
34
+ once: boolean;
35
+ conditions: TriggerCondition[];
36
+ }
37
+
38
+ /**
39
+ * Enhanced step interface with trigger support
40
+ */
41
+ interface EnhancedStepData {
42
+ stepId: string;
43
+ stepOrder: number;
44
+ stepType: string;
45
+ trigger?: TriggerDefinition;
46
+ uxExperience?: {
47
+ uxExperienceType: string;
48
+ elementSelector?: string;
49
+ elementTrigger?: string;
50
+ elementLocation?: string;
51
+ position?: {
52
+ x: string;
53
+ y: string;
54
+ };
55
+ content: any;
56
+ modalContent?: any;
57
+ };
58
+ conditionRuleBlocks?: any[];
59
+ userInputSelector?: string | null;
60
+ }
61
+
62
+ interface FlowData {
63
+ flowId: string;
64
+ flowName: string;
65
+ steps: EnhancedStepData[];
66
+ execution?: {
67
+ mode?: FlowExecutionMode;
68
+ multiPage?: boolean;
69
+ frequency?: {
70
+ type: 'OneTime' | 'Daily' | 'Weekly' | 'Monthly';
71
+ maxRuns: number;
72
+ };
73
+ frequencyType?: string;
74
+ };
75
+ }
76
+
77
+ /**
78
+ * Initialize DAP SDK with optional user context
79
+ */
80
+ declare function init(opts: {
81
+ configUrl: string;
82
+ debug?: boolean;
83
+ screenId?: string;
84
+ user?: DapUser;
85
+ }): Promise<void>;
86
+ /**
87
+ * Set user context and trigger flow re-evaluation
88
+ */
89
+ declare function setUser(user: DapUser): void;
90
+ /**
91
+ * Update existing user context
92
+ */
93
+ declare function updateUser(partialUser: Partial<DapUser>): void;
94
+ /**
95
+ * Get current user context
96
+ */
97
+ declare function getUser(): DapUser | null;
98
+ /**
99
+ * Clear user context
100
+ */
101
+ declare function clearUser(): void;
102
+ declare function runModalSequence(): void;
103
+ declare function executeFlow(flow: any): Promise<void>;
104
+ /**
105
+ * Register a flow for later execution by ID
106
+ */
107
+ declare function registerFlow(flowData: FlowData): void;
108
+ /**
109
+ * Start a flow by ID (from registered flows or backend)
110
+ */
111
+ declare function startFlow(flowId: string): Promise<void>;
112
+
113
+ export { type DapUser, clearUser, executeFlow, getUser, init, registerFlow, runModalSequence, setUser, startFlow, updateUser };