@startsimpli/funnels 0.1.3 → 0.1.5

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 (151) hide show
  1. package/package.json +9 -31
  2. package/src/api/README.md +507 -0
  3. package/src/api/adapter.ts +106 -0
  4. package/src/api/client.test.ts +640 -0
  5. package/src/api/client.ts +385 -0
  6. package/src/api/default-adapter.ts +243 -0
  7. package/src/api/index.ts +24 -0
  8. package/src/components/FilterRuleEditor/ARCHITECTURE.md +354 -0
  9. package/src/components/FilterRuleEditor/FieldSelector.tsx +91 -0
  10. package/src/components/FilterRuleEditor/FilterRuleEditor.stories.tsx +462 -0
  11. package/src/components/FilterRuleEditor/FilterRuleEditor.test.tsx +520 -0
  12. package/src/components/FilterRuleEditor/FilterRuleEditor.tsx +225 -0
  13. package/src/components/FilterRuleEditor/LogicToggle.tsx +64 -0
  14. package/src/components/FilterRuleEditor/OperatorSelector.tsx +75 -0
  15. package/src/components/FilterRuleEditor/README.md +291 -0
  16. package/src/components/FilterRuleEditor/RuleRow.tsx +246 -0
  17. package/src/components/FilterRuleEditor/ValueInputs/BooleanValueInput.tsx +54 -0
  18. package/src/components/FilterRuleEditor/ValueInputs/ChoiceValueInput.tsx +83 -0
  19. package/src/components/FilterRuleEditor/ValueInputs/DateValueInput.tsx +70 -0
  20. package/src/components/FilterRuleEditor/ValueInputs/MultiChoiceValueInput.tsx +132 -0
  21. package/src/components/FilterRuleEditor/ValueInputs/NumberValueInput.tsx +73 -0
  22. package/src/components/FilterRuleEditor/ValueInputs/TextValueInput.tsx +50 -0
  23. package/src/components/FilterRuleEditor/ValueInputs/index.ts +12 -0
  24. package/src/components/FilterRuleEditor/constants.ts +64 -0
  25. package/src/components/FilterRuleEditor/index.ts +14 -0
  26. package/src/components/FunnelCard/DESIGN.md +447 -0
  27. package/src/components/FunnelCard/FunnelCard.stories.tsx +484 -0
  28. package/src/components/FunnelCard/FunnelCard.test.ts +257 -0
  29. package/src/components/FunnelCard/FunnelCard.test.tsx +336 -0
  30. package/src/components/FunnelCard/FunnelCard.tsx +204 -0
  31. package/src/components/FunnelCard/FunnelStats.tsx +68 -0
  32. package/src/components/FunnelCard/IMPLEMENTATION_SUMMARY.md +505 -0
  33. package/src/components/FunnelCard/INSTALLATION.md +304 -0
  34. package/src/components/FunnelCard/MatchBar.tsx +49 -0
  35. package/src/components/FunnelCard/README.md +294 -0
  36. package/src/components/FunnelCard/StageIndicator.tsx +62 -0
  37. package/src/components/FunnelCard/StatusBadge.tsx +52 -0
  38. package/src/components/FunnelCard/index.ts +14 -0
  39. package/src/components/FunnelPreview/EntityCard.tsx +72 -0
  40. package/src/components/FunnelPreview/FunnelPreview.stories.tsx +227 -0
  41. package/src/components/FunnelPreview/FunnelPreview.test.tsx +316 -0
  42. package/src/components/FunnelPreview/FunnelPreview.tsx +249 -0
  43. package/src/components/FunnelPreview/LoadingPreview.tsx +60 -0
  44. package/src/components/FunnelPreview/PreviewStats.tsx +78 -0
  45. package/src/components/FunnelPreview/README.md +337 -0
  46. package/src/components/FunnelPreview/StageBreakdown.tsx +94 -0
  47. package/src/components/FunnelPreview/example.tsx +286 -0
  48. package/src/components/FunnelPreview/index.ts +14 -0
  49. package/src/components/FunnelRunHistory/COMPONENT_SUMMARY.md +246 -0
  50. package/src/components/FunnelRunHistory/FunnelRunHistory.stories.tsx +272 -0
  51. package/src/components/FunnelRunHistory/FunnelRunHistory.test.tsx +323 -0
  52. package/src/components/FunnelRunHistory/FunnelRunHistory.tsx +329 -0
  53. package/src/components/FunnelRunHistory/README.md +325 -0
  54. package/src/components/FunnelRunHistory/RunActions.tsx +168 -0
  55. package/src/components/FunnelRunHistory/RunDetailsModal.tsx +221 -0
  56. package/src/components/FunnelRunHistory/RunFilters.tsx +128 -0
  57. package/src/components/FunnelRunHistory/RunRow.tsx +122 -0
  58. package/src/components/FunnelRunHistory/RunStatusBadge.tsx +75 -0
  59. package/src/components/FunnelRunHistory/StageBreakdownList.tsx +110 -0
  60. package/src/components/FunnelRunHistory/index.ts +51 -0
  61. package/src/components/FunnelRunHistory/types.ts +40 -0
  62. package/src/components/FunnelRunHistory/utils.test.ts +126 -0
  63. package/src/components/FunnelRunHistory/utils.ts +100 -0
  64. package/src/components/FunnelStageBuilder/AddStageButton.tsx +52 -0
  65. package/src/components/FunnelStageBuilder/FunnelStageBuilder.css +413 -0
  66. package/src/components/FunnelStageBuilder/FunnelStageBuilder.stories.tsx +312 -0
  67. package/src/components/FunnelStageBuilder/FunnelStageBuilder.test.tsx +304 -0
  68. package/src/components/FunnelStageBuilder/FunnelStageBuilder.tsx +321 -0
  69. package/src/components/FunnelStageBuilder/README.md +341 -0
  70. package/src/components/FunnelStageBuilder/StageActions.test.tsx +205 -0
  71. package/src/components/FunnelStageBuilder/StageActions.tsx +126 -0
  72. package/src/components/FunnelStageBuilder/StageCard.tsx +202 -0
  73. package/src/components/FunnelStageBuilder/StageForm.tsx +262 -0
  74. package/src/components/FunnelStageBuilder/TagInput.test.tsx +178 -0
  75. package/src/components/FunnelStageBuilder/TagInput.tsx +129 -0
  76. package/src/components/FunnelStageBuilder/index.ts +21 -0
  77. package/src/components/FunnelVisualFlow/FlowLegend.tsx +77 -0
  78. package/{dist/components/index.css → src/components/FunnelVisualFlow/FunnelVisualFlow.css} +89 -13
  79. package/src/components/FunnelVisualFlow/FunnelVisualFlow.stories.tsx +254 -0
  80. package/src/components/FunnelVisualFlow/FunnelVisualFlow.test.tsx +208 -0
  81. package/src/components/FunnelVisualFlow/FunnelVisualFlow.tsx +229 -0
  82. package/src/components/FunnelVisualFlow/README.md +323 -0
  83. package/src/components/FunnelVisualFlow/StageNode.tsx +188 -0
  84. package/src/components/FunnelVisualFlow/example.tsx +227 -0
  85. package/src/components/FunnelVisualFlow/index.ts +10 -0
  86. package/src/components/index.ts +102 -0
  87. package/src/core/README.md +307 -0
  88. package/src/core/engine.test.ts +1087 -0
  89. package/src/core/engine.ts +329 -0
  90. package/src/core/evaluator.example.ts +353 -0
  91. package/src/core/evaluator.test.ts +639 -0
  92. package/src/core/evaluator.ts +261 -0
  93. package/src/core/field-resolver.example.ts +175 -0
  94. package/src/core/field-resolver.test.ts +541 -0
  95. package/src/core/field-resolver.ts +247 -0
  96. package/src/core/index.ts +34 -0
  97. package/src/core/operators.test.ts +539 -0
  98. package/src/core/operators.ts +241 -0
  99. package/src/hooks/index.ts +5 -0
  100. package/src/hooks/useDebouncedValue.ts +28 -0
  101. package/src/index.ts +155 -0
  102. package/src/store/README.md +342 -0
  103. package/src/store/create-funnel-store.test.ts +686 -0
  104. package/src/store/create-funnel-store.ts +538 -0
  105. package/src/store/index.ts +9 -0
  106. package/src/store/types.ts +294 -0
  107. package/src/stories/CrossDomain.stories.tsx +149 -0
  108. package/src/stories/Welcome.stories.tsx +81 -0
  109. package/src/stories/demo-data/index.ts +3 -0
  110. package/src/stories/demo-data/investors.ts +216 -0
  111. package/src/stories/demo-data/leads.ts +223 -0
  112. package/src/stories/demo-data/recipes.ts +217 -0
  113. package/src/test/setup.ts +5 -0
  114. package/src/types/index.ts +843 -0
  115. package/dist/client-3ESO2NHy.d.ts +0 -310
  116. package/dist/client-CZu03ACp.d.cts +0 -310
  117. package/dist/components/index.cjs +0 -3243
  118. package/dist/components/index.cjs.map +0 -1
  119. package/dist/components/index.css.map +0 -1
  120. package/dist/components/index.d.cts +0 -726
  121. package/dist/components/index.d.ts +0 -726
  122. package/dist/components/index.js +0 -3196
  123. package/dist/components/index.js.map +0 -1
  124. package/dist/core/index.cjs +0 -500
  125. package/dist/core/index.cjs.map +0 -1
  126. package/dist/core/index.d.cts +0 -359
  127. package/dist/core/index.d.ts +0 -359
  128. package/dist/core/index.js +0 -486
  129. package/dist/core/index.js.map +0 -1
  130. package/dist/hooks/index.cjs +0 -21
  131. package/dist/hooks/index.cjs.map +0 -1
  132. package/dist/hooks/index.d.cts +0 -11
  133. package/dist/hooks/index.d.ts +0 -11
  134. package/dist/hooks/index.js +0 -19
  135. package/dist/hooks/index.js.map +0 -1
  136. package/dist/index-BGDEXbuz.d.cts +0 -434
  137. package/dist/index-BGDEXbuz.d.ts +0 -434
  138. package/dist/index.cjs +0 -4499
  139. package/dist/index.cjs.map +0 -1
  140. package/dist/index.css +0 -198
  141. package/dist/index.css.map +0 -1
  142. package/dist/index.d.cts +0 -99
  143. package/dist/index.d.ts +0 -99
  144. package/dist/index.js +0 -4421
  145. package/dist/index.js.map +0 -1
  146. package/dist/store/index.cjs +0 -391
  147. package/dist/store/index.cjs.map +0 -1
  148. package/dist/store/index.d.cts +0 -225
  149. package/dist/store/index.d.ts +0 -225
  150. package/dist/store/index.js +0 -388
  151. package/dist/store/index.js.map +0 -1
@@ -1,359 +0,0 @@
1
- import { h as FilterRule, R as RuleResult, O as Operator, j as FunnelResult, o as StageStats, i as Funnel } from '../index-BGDEXbuz.js';
2
-
3
- /**
4
- * @startsimpli/funnels - Field Resolver Utility
5
- *
6
- * Safely resolves and sets field values using dot-notation paths on arbitrary objects.
7
- * Used by rule evaluator and execution engine to access entity properties.
8
- *
9
- * Examples:
10
- * - resolveField({name: 'John'}, 'name') → 'John'
11
- * - resolveField({firm: {stage: 'Seed'}}, 'firm.stage') → 'Seed'
12
- * - resolveField({tags: ['a', 'b']}, 'tags[0]') → 'a'
13
- * - resolveField({investors: [{email: 'a@b.com'}]}, 'investors[0].email') → 'a@b.com'
14
- */
15
- /**
16
- * Resolve a field value from an entity using dot-notation path
17
- *
18
- * Features:
19
- * - Dot notation: 'firm.name', 'recipe.ingredients.name'
20
- * - Array access: 'tags[0]', 'investors[2].email'
21
- * - Nested paths: 'company.address.city.zipCode'
22
- * - Safe navigation: Returns undefined for missing paths (no errors)
23
- * - Type preservation: Maintains number/boolean/date types
24
- *
25
- * @param entity - The object to resolve the field from
26
- * @param fieldPath - Dot-notation path to the field
27
- * @returns The resolved value, or undefined if path doesn't exist
28
- *
29
- * @example
30
- * ```typescript
31
- * const investor = {
32
- * name: 'John Doe',
33
- * firm: { stage: 'Seed', aum: 100000000 },
34
- * tags: ['active', 'qualified'],
35
- * metadata: { score: 85 }
36
- * };
37
- *
38
- * resolveField(investor, 'name'); // 'John Doe'
39
- * resolveField(investor, 'firm.stage'); // 'Seed'
40
- * resolveField(investor, 'tags[0]'); // 'active'
41
- * resolveField(investor, 'metadata.score'); // 85
42
- * resolveField(investor, 'firm.missing'); // undefined
43
- * ```
44
- */
45
- declare function resolveField<T>(entity: T, fieldPath: string): any;
46
- /**
47
- * Set a field value on an entity using dot-notation path
48
- *
49
- * Features:
50
- * - Creates intermediate objects/arrays as needed
51
- * - Handles array index assignment
52
- * - Mutates the entity in place
53
- * - Safe for missing intermediate paths
54
- *
55
- * @param entity - The object to set the field on
56
- * @param fieldPath - Dot-notation path to the field
57
- * @param value - The value to set
58
- *
59
- * @example
60
- * ```typescript
61
- * const investor = { name: 'John' };
62
- *
63
- * setField(investor, 'firm.stage', 'Series A');
64
- * // investor = { name: 'John', firm: { stage: 'Series A' } }
65
- *
66
- * setField(investor, 'tags[0]', 'qualified');
67
- * // investor.tags = ['qualified']
68
- *
69
- * setField(investor, 'metadata.score', 85);
70
- * // investor.metadata = { score: 85 }
71
- * ```
72
- */
73
- declare function setField<T>(entity: T, fieldPath: string, value: any): void;
74
- /**
75
- * Check if a field path exists on an entity
76
- *
77
- * @param entity - The object to check
78
- * @param fieldPath - Dot-notation path to check
79
- * @returns true if the path exists and has a defined value
80
- *
81
- * @example
82
- * ```typescript
83
- * const investor = { name: 'John', firm: { stage: 'Seed' } };
84
- *
85
- * hasField(investor, 'name'); // true
86
- * hasField(investor, 'firm.stage'); // true
87
- * hasField(investor, 'firm.missing'); // false
88
- * hasField(investor, 'tags[0]'); // false
89
- * ```
90
- */
91
- declare function hasField<T>(entity: T, fieldPath: string): boolean;
92
- /**
93
- * Get multiple field values at once
94
- *
95
- * @param entity - The object to resolve fields from
96
- * @param fieldPaths - Array of field paths to resolve
97
- * @returns Object mapping field paths to their values
98
- *
99
- * @example
100
- * ```typescript
101
- * const investor = { name: 'John', firm: { stage: 'Seed' }, tags: ['active'] };
102
- *
103
- * getFields(investor, ['name', 'firm.stage', 'tags[0]']);
104
- * // { name: 'John', 'firm.stage': 'Seed', 'tags[0]': 'active' }
105
- * ```
106
- */
107
- declare function getFields<T>(entity: T, fieldPaths: string[]): Record<string, any>;
108
-
109
- /**
110
- * @startsimpli/funnels - Rule Evaluator
111
- *
112
- * BRUTALLY GENERIC rule evaluation engine.
113
- *
114
- * Evaluates FilterRule against ANY entity type by:
115
- * 1. Resolving field value from entity
116
- * 2. Applying operator comparison
117
- * 3. Handling negate flag
118
- * 4. Returning boolean result
119
- */
120
-
121
- /**
122
- * Evaluate a single filter rule against an entity
123
- *
124
- * @param entity - The entity to evaluate
125
- * @param rule - The filter rule to apply
126
- * @returns Whether the rule matches
127
- *
128
- * @example
129
- * ```typescript
130
- * const investor = { name: 'John', firm: { stage: 'Series A' } };
131
- *
132
- * evaluateRule(investor, {
133
- * field_path: 'firm.stage',
134
- * operator: 'eq',
135
- * value: 'Series A'
136
- * }); // true
137
- *
138
- * evaluateRule(investor, {
139
- * field_path: 'firm.stage',
140
- * operator: 'eq',
141
- * value: 'Seed',
142
- * negate: true
143
- * }); // true (negated: stage !== 'Seed')
144
- * ```
145
- */
146
- declare function evaluateRule<T>(entity: T, rule: FilterRule): boolean;
147
- /**
148
- * Evaluate a rule and return detailed result with diagnostics
149
- *
150
- * @param entity - The entity to evaluate
151
- * @param rule - The filter rule to apply
152
- * @returns Detailed rule result with actual value and match status
153
- *
154
- * @example
155
- * ```typescript
156
- * const result = evaluateRuleWithResult(investor, {
157
- * field_path: 'firm.stage',
158
- * operator: 'eq',
159
- * value: 'Series A'
160
- * });
161
- * // {
162
- * // field_path: 'firm.stage',
163
- * // operator: 'eq',
164
- * // value: 'Series A',
165
- * // actual_value: 'Series A',
166
- * // matched: true
167
- * // }
168
- * ```
169
- */
170
- declare function evaluateRuleWithResult<T>(entity: T, rule: FilterRule): RuleResult;
171
- /**
172
- * Evaluate multiple rules with AND logic
173
- *
174
- * @param entity - The entity to evaluate
175
- * @param rules - Array of filter rules
176
- * @returns Whether ALL rules match
177
- *
178
- * @example
179
- * ```typescript
180
- * const investor = { name: 'John', firm: { stage: 'Series A', aum: 100000000 } };
181
- *
182
- * evaluateRulesAND(investor, [
183
- * { field_path: 'firm.stage', operator: 'eq', value: 'Series A' },
184
- * { field_path: 'firm.aum', operator: 'gte', value: 50000000 }
185
- * ]); // true (both rules match)
186
- * ```
187
- */
188
- declare function evaluateRulesAND<T>(entity: T, rules: FilterRule[]): boolean;
189
- /**
190
- * Evaluate multiple rules with OR logic
191
- *
192
- * @param entity - The entity to evaluate
193
- * @param rules - Array of filter rules
194
- * @returns Whether AT LEAST ONE rule matches
195
- *
196
- * @example
197
- * ```typescript
198
- * const investor = { name: 'John', firm: { stage: 'Seed' } };
199
- *
200
- * evaluateRulesOR(investor, [
201
- * { field_path: 'firm.stage', operator: 'eq', value: 'Series A' },
202
- * { field_path: 'firm.stage', operator: 'eq', value: 'Seed' }
203
- * ]); // true (second rule matches)
204
- * ```
205
- */
206
- declare function evaluateRulesOR<T>(entity: T, rules: FilterRule[]): boolean;
207
- /**
208
- * Evaluate multiple rules with specified logic (AND/OR)
209
- *
210
- * @param entity - The entity to evaluate
211
- * @param rules - Array of filter rules
212
- * @param logic - Combination logic ('AND' or 'OR')
213
- * @returns Whether rules match based on logic
214
- *
215
- * @example
216
- * ```typescript
217
- * evaluateRules(investor, rules, 'AND'); // All must match
218
- * evaluateRules(investor, rules, 'OR'); // At least one must match
219
- * ```
220
- */
221
- declare function evaluateRules<T>(entity: T, rules: FilterRule[], logic?: 'AND' | 'OR'): boolean;
222
- /**
223
- * Evaluate rules and return detailed results for each rule
224
- *
225
- * @param entity - The entity to evaluate
226
- * @param rules - Array of filter rules
227
- * @param logic - Combination logic ('AND' or 'OR')
228
- * @returns Object with overall match status and per-rule results
229
- *
230
- * @example
231
- * ```typescript
232
- * const result = evaluateRulesWithResults(investor, [
233
- * { field_path: 'firm.stage', operator: 'eq', value: 'Series A' },
234
- * { field_path: 'firm.aum', operator: 'gte', value: 50000000 }
235
- * ], 'AND');
236
- * // {
237
- * // matched: true,
238
- * // logic: 'AND',
239
- * // rule_results: [
240
- * // { field_path: 'firm.stage', operator: 'eq', value: 'Series A', actual_value: 'Series A', matched: true },
241
- * // { field_path: 'firm.aum', operator: 'gte', value: 50000000, actual_value: 100000000, matched: true }
242
- * // ]
243
- * // }
244
- * ```
245
- */
246
- declare function evaluateRulesWithResults<T>(entity: T, rules: FilterRule[], logic?: 'AND' | 'OR'): {
247
- matched: boolean;
248
- logic: 'AND' | 'OR';
249
- rule_results: RuleResult[];
250
- };
251
- /**
252
- * Filter an array of entities using rules
253
- *
254
- * @param entities - Array of entities to filter
255
- * @param rules - Filter rules to apply
256
- * @param logic - Combination logic ('AND' or 'OR')
257
- * @returns Entities that match the rules
258
- *
259
- * @example
260
- * ```typescript
261
- * const investors = [
262
- * { name: 'John', firm: { stage: 'Seed' } },
263
- * { name: 'Jane', firm: { stage: 'Series A' } },
264
- * { name: 'Bob', firm: { stage: 'Series B' } }
265
- * ];
266
- *
267
- * filterEntities(investors, [
268
- * { field_path: 'firm.stage', operator: 'in', value: ['Series A', 'Series B'] }
269
- * ]);
270
- * // [
271
- * // { name: 'Jane', firm: { stage: 'Series A' } },
272
- * // { name: 'Bob', firm: { stage: 'Series B' } }
273
- * // ]
274
- * ```
275
- */
276
- declare function filterEntities<T>(entities: T[], rules: FilterRule[], logic?: 'AND' | 'OR'): T[];
277
-
278
- /**
279
- * @startsimpli/funnels - Operator Implementation
280
- *
281
- * BRUTALLY GENERIC operator logic that works with ANY data type.
282
- *
283
- * Each operator is a pure function: (actual, expected) => boolean
284
- */
285
-
286
- /**
287
- * Apply an operator to compare actual vs expected values
288
- *
289
- * @param operator - The comparison operator
290
- * @param actual - The actual value from entity
291
- * @param expected - The expected value from rule
292
- * @returns Whether the comparison passes
293
- */
294
- declare function applyOperator(operator: Operator, actual: any, expected: any): boolean;
295
-
296
- /**
297
- * @startsimpli/funnels - Core Funnel Execution Engine
298
- *
299
- * BRUTALLY GENERIC - Works for ANY entity type:
300
- * - Investors, firms, contacts, organizations
301
- * - Recipes, ingredients, users
302
- * - Leads, tasks, projects
303
- * - GitHub repos, pull requests, issues
304
- *
305
- * The engine processes entities through stages sequentially,
306
- * evaluating rules and applying actions based on match results.
307
- */
308
-
309
- /**
310
- * Complete result of funnel execution
311
- */
312
- interface ExecutionResult<T = any> {
313
- /** Entities that matched and are in output */
314
- matched: FunnelResult<T>[];
315
- /** Entities that were excluded */
316
- excluded: FunnelResult<T>[];
317
- /** Total entities processed */
318
- total_input: number;
319
- /** Total entities that matched */
320
- total_matched: number;
321
- /** Total entities excluded */
322
- total_excluded: number;
323
- /** Total entities tagged */
324
- total_tagged: number;
325
- /** Per-stage statistics */
326
- stage_stats: Record<string, StageStats>;
327
- /** Execution duration in milliseconds */
328
- duration_ms: number;
329
- /** Errors encountered (non-fatal) */
330
- errors?: string[];
331
- }
332
- /**
333
- * Core funnel execution engine
334
- *
335
- * Processes entities through stages sequentially, evaluating rules
336
- * and applying actions based on match results.
337
- *
338
- * Generic over entity type T - works with ANY data structure.
339
- */
340
- declare class FunnelEngine<T = any> {
341
- /**
342
- * Execute a funnel on a set of entities
343
- *
344
- * @param funnel - The funnel definition to execute
345
- * @param entities - Input entities to process
346
- * @returns ExecutionResult with matched/excluded entities and stats
347
- */
348
- execute(funnel: Funnel<T>, entities: T[]): ExecutionResult<T>;
349
- /**
350
- * Process a single entity through a stage
351
- *
352
- * @param stage - The stage to process
353
- * @param entity - The entity to evaluate
354
- * @returns StageResult with match status and actions taken
355
- */
356
- private processStage;
357
- }
358
-
359
- export { type ExecutionResult, FunnelEngine, applyOperator, evaluateRule, evaluateRuleWithResult, evaluateRules, evaluateRulesAND, evaluateRulesOR, evaluateRulesWithResults, filterEntities, getFields, hasField, resolveField, setField };