@startsimpli/funnels 0.1.4 → 0.1.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.
- package/package.json +9 -31
- package/src/api/README.md +507 -0
- package/src/api/adapter.ts +106 -0
- package/src/api/client.test.ts +640 -0
- package/src/api/client.ts +385 -0
- package/src/api/default-adapter.ts +243 -0
- package/src/api/index.ts +24 -0
- package/src/components/FilterRuleEditor/ARCHITECTURE.md +354 -0
- package/src/components/FilterRuleEditor/FieldSelector.tsx +91 -0
- package/src/components/FilterRuleEditor/FilterRuleEditor.stories.tsx +462 -0
- package/src/components/FilterRuleEditor/FilterRuleEditor.test.tsx +520 -0
- package/src/components/FilterRuleEditor/FilterRuleEditor.tsx +225 -0
- package/src/components/FilterRuleEditor/LogicToggle.tsx +64 -0
- package/src/components/FilterRuleEditor/OperatorSelector.tsx +75 -0
- package/src/components/FilterRuleEditor/README.md +291 -0
- package/src/components/FilterRuleEditor/RuleRow.tsx +246 -0
- package/src/components/FilterRuleEditor/ValueInputs/BooleanValueInput.tsx +54 -0
- package/src/components/FilterRuleEditor/ValueInputs/ChoiceValueInput.tsx +83 -0
- package/src/components/FilterRuleEditor/ValueInputs/DateValueInput.tsx +70 -0
- package/src/components/FilterRuleEditor/ValueInputs/MultiChoiceValueInput.tsx +132 -0
- package/src/components/FilterRuleEditor/ValueInputs/NumberValueInput.tsx +73 -0
- package/src/components/FilterRuleEditor/ValueInputs/TextValueInput.tsx +50 -0
- package/src/components/FilterRuleEditor/ValueInputs/index.ts +12 -0
- package/src/components/FilterRuleEditor/constants.ts +64 -0
- package/src/components/FilterRuleEditor/index.ts +14 -0
- package/src/components/FunnelCard/DESIGN.md +447 -0
- package/src/components/FunnelCard/FunnelCard.stories.tsx +484 -0
- package/src/components/FunnelCard/FunnelCard.test.ts +257 -0
- package/src/components/FunnelCard/FunnelCard.test.tsx +336 -0
- package/src/components/FunnelCard/FunnelCard.tsx +204 -0
- package/src/components/FunnelCard/FunnelStats.tsx +68 -0
- package/src/components/FunnelCard/IMPLEMENTATION_SUMMARY.md +505 -0
- package/src/components/FunnelCard/INSTALLATION.md +304 -0
- package/src/components/FunnelCard/MatchBar.tsx +49 -0
- package/src/components/FunnelCard/README.md +294 -0
- package/src/components/FunnelCard/StageIndicator.tsx +62 -0
- package/src/components/FunnelCard/StatusBadge.tsx +52 -0
- package/src/components/FunnelCard/index.ts +14 -0
- package/src/components/FunnelPreview/EntityCard.tsx +72 -0
- package/src/components/FunnelPreview/FunnelPreview.stories.tsx +227 -0
- package/src/components/FunnelPreview/FunnelPreview.test.tsx +316 -0
- package/src/components/FunnelPreview/FunnelPreview.tsx +249 -0
- package/src/components/FunnelPreview/LoadingPreview.tsx +60 -0
- package/src/components/FunnelPreview/PreviewStats.tsx +78 -0
- package/src/components/FunnelPreview/README.md +337 -0
- package/src/components/FunnelPreview/StageBreakdown.tsx +94 -0
- package/src/components/FunnelPreview/example.tsx +286 -0
- package/src/components/FunnelPreview/index.ts +14 -0
- package/src/components/FunnelRunHistory/COMPONENT_SUMMARY.md +246 -0
- package/src/components/FunnelRunHistory/FunnelRunHistory.stories.tsx +272 -0
- package/src/components/FunnelRunHistory/FunnelRunHistory.test.tsx +323 -0
- package/src/components/FunnelRunHistory/FunnelRunHistory.tsx +329 -0
- package/src/components/FunnelRunHistory/README.md +325 -0
- package/src/components/FunnelRunHistory/RunActions.tsx +168 -0
- package/src/components/FunnelRunHistory/RunDetailsModal.tsx +221 -0
- package/src/components/FunnelRunHistory/RunFilters.tsx +128 -0
- package/src/components/FunnelRunHistory/RunRow.tsx +122 -0
- package/src/components/FunnelRunHistory/RunStatusBadge.tsx +75 -0
- package/src/components/FunnelRunHistory/StageBreakdownList.tsx +110 -0
- package/src/components/FunnelRunHistory/index.ts +51 -0
- package/src/components/FunnelRunHistory/types.ts +40 -0
- package/src/components/FunnelRunHistory/utils.test.ts +126 -0
- package/src/components/FunnelRunHistory/utils.ts +100 -0
- package/src/components/FunnelStageBuilder/AddStageButton.tsx +52 -0
- package/src/components/FunnelStageBuilder/FunnelStageBuilder.css +413 -0
- package/src/components/FunnelStageBuilder/FunnelStageBuilder.stories.tsx +312 -0
- package/src/components/FunnelStageBuilder/FunnelStageBuilder.test.tsx +304 -0
- package/src/components/FunnelStageBuilder/FunnelStageBuilder.tsx +321 -0
- package/src/components/FunnelStageBuilder/README.md +341 -0
- package/src/components/FunnelStageBuilder/StageActions.test.tsx +205 -0
- package/src/components/FunnelStageBuilder/StageActions.tsx +126 -0
- package/src/components/FunnelStageBuilder/StageCard.tsx +202 -0
- package/src/components/FunnelStageBuilder/StageForm.tsx +262 -0
- package/src/components/FunnelStageBuilder/TagInput.test.tsx +178 -0
- package/src/components/FunnelStageBuilder/TagInput.tsx +129 -0
- package/src/components/FunnelStageBuilder/index.ts +21 -0
- package/src/components/FunnelVisualFlow/FlowLegend.tsx +77 -0
- package/{dist/components/index.css → src/components/FunnelVisualFlow/FunnelVisualFlow.css} +89 -13
- package/src/components/FunnelVisualFlow/FunnelVisualFlow.stories.tsx +254 -0
- package/src/components/FunnelVisualFlow/FunnelVisualFlow.test.tsx +208 -0
- package/src/components/FunnelVisualFlow/FunnelVisualFlow.tsx +229 -0
- package/src/components/FunnelVisualFlow/README.md +323 -0
- package/src/components/FunnelVisualFlow/StageNode.tsx +188 -0
- package/src/components/FunnelVisualFlow/example.tsx +227 -0
- package/src/components/FunnelVisualFlow/index.ts +10 -0
- package/src/components/index.ts +102 -0
- package/src/core/README.md +307 -0
- package/src/core/engine.test.ts +1087 -0
- package/src/core/engine.ts +329 -0
- package/src/core/evaluator.example.ts +353 -0
- package/src/core/evaluator.test.ts +639 -0
- package/src/core/evaluator.ts +261 -0
- package/src/core/field-resolver.example.ts +175 -0
- package/src/core/field-resolver.test.ts +541 -0
- package/src/core/field-resolver.ts +247 -0
- package/src/core/index.ts +34 -0
- package/src/core/operators.test.ts +539 -0
- package/src/core/operators.ts +241 -0
- package/src/hooks/index.ts +5 -0
- package/src/hooks/useDebouncedValue.ts +28 -0
- package/src/index.ts +155 -0
- package/src/store/README.md +342 -0
- package/src/store/create-funnel-store.test.ts +686 -0
- package/src/store/create-funnel-store.ts +538 -0
- package/src/store/index.ts +9 -0
- package/src/store/types.ts +294 -0
- package/src/stories/CrossDomain.stories.tsx +149 -0
- package/src/stories/Welcome.stories.tsx +81 -0
- package/src/stories/demo-data/index.ts +3 -0
- package/src/stories/demo-data/investors.ts +216 -0
- package/src/stories/demo-data/leads.ts +223 -0
- package/src/stories/demo-data/recipes.ts +217 -0
- package/src/test/setup.ts +5 -0
- package/src/types/index.ts +843 -0
- package/dist/client-3ESO2NHy.d.ts +0 -310
- package/dist/client-CZu03ACp.d.cts +0 -310
- package/dist/components/index.cjs +0 -3241
- package/dist/components/index.cjs.map +0 -1
- package/dist/components/index.css.map +0 -1
- package/dist/components/index.d.cts +0 -726
- package/dist/components/index.d.ts +0 -726
- package/dist/components/index.js +0 -3194
- package/dist/components/index.js.map +0 -1
- package/dist/core/index.cjs +0 -500
- package/dist/core/index.cjs.map +0 -1
- package/dist/core/index.d.cts +0 -359
- package/dist/core/index.d.ts +0 -359
- package/dist/core/index.js +0 -486
- package/dist/core/index.js.map +0 -1
- package/dist/hooks/index.cjs +0 -20
- package/dist/hooks/index.cjs.map +0 -1
- package/dist/hooks/index.d.cts +0 -11
- package/dist/hooks/index.d.ts +0 -11
- package/dist/hooks/index.js +0 -18
- package/dist/hooks/index.js.map +0 -1
- package/dist/index-BGDEXbuz.d.cts +0 -434
- package/dist/index-BGDEXbuz.d.ts +0 -434
- package/dist/index.cjs +0 -4499
- package/dist/index.cjs.map +0 -1
- package/dist/index.css +0 -198
- package/dist/index.css.map +0 -1
- package/dist/index.d.cts +0 -99
- package/dist/index.d.ts +0 -99
- package/dist/index.js +0 -4421
- package/dist/index.js.map +0 -1
- package/dist/store/index.cjs +0 -389
- package/dist/store/index.cjs.map +0 -1
- package/dist/store/index.d.cts +0 -225
- package/dist/store/index.d.ts +0 -225
- package/dist/store/index.js +0 -386
- package/dist/store/index.js.map +0 -1
package/dist/core/index.d.cts
DELETED
|
@@ -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.cjs';
|
|
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 };
|