@botonic/plugin-flow-builder 0.50.2-alpha.0 → 0.51.0-alpha.0
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/lib/cjs/content-fields/custom-conditional-v2-evaluators.d.ts +15 -0
- package/lib/cjs/content-fields/custom-conditional-v2-evaluators.js +71 -0
- package/lib/cjs/content-fields/custom-conditional-v2-evaluators.js.map +1 -0
- package/lib/cjs/content-fields/custom-conditional-v2-resolver.d.ts +8 -0
- package/lib/cjs/content-fields/custom-conditional-v2-resolver.js +48 -0
- package/lib/cjs/content-fields/custom-conditional-v2-resolver.js.map +1 -0
- package/lib/cjs/content-fields/flow-custom-condition-v2.d.ts +16 -0
- package/lib/cjs/content-fields/flow-custom-condition-v2.js +76 -0
- package/lib/cjs/content-fields/flow-custom-condition-v2.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/custom-conditional-v2.d.ts +56 -0
- package/lib/cjs/content-fields/hubtype-fields/custom-conditional-v2.js +36 -0
- package/lib/cjs/content-fields/hubtype-fields/custom-conditional-v2.js.map +1 -0
- package/lib/cjs/content-fields/hubtype-fields/index.d.ts +1 -0
- package/lib/cjs/content-fields/hubtype-fields/index.js +1 -0
- package/lib/cjs/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.d.ts +2 -1
- package/lib/cjs/content-fields/hubtype-fields/node-types.js +1 -0
- package/lib/cjs/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/cjs/content-fields/hubtype-fields/nodes.d.ts +2 -1
- package/lib/cjs/content-fields/index.d.ts +3 -2
- package/lib/cjs/content-fields/index.js +3 -1
- package/lib/cjs/content-fields/index.js.map +1 -1
- package/lib/cjs/flow-factory.js +2 -0
- package/lib/cjs/flow-factory.js.map +1 -1
- package/lib/esm/content-fields/custom-conditional-v2-evaluators.d.ts +15 -0
- package/lib/esm/content-fields/custom-conditional-v2-evaluators.js +71 -0
- package/lib/esm/content-fields/custom-conditional-v2-evaluators.js.map +1 -0
- package/lib/esm/content-fields/custom-conditional-v2-resolver.d.ts +8 -0
- package/lib/esm/content-fields/custom-conditional-v2-resolver.js +48 -0
- package/lib/esm/content-fields/custom-conditional-v2-resolver.js.map +1 -0
- package/lib/esm/content-fields/flow-custom-condition-v2.d.ts +16 -0
- package/lib/esm/content-fields/flow-custom-condition-v2.js +76 -0
- package/lib/esm/content-fields/flow-custom-condition-v2.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/custom-conditional-v2.d.ts +56 -0
- package/lib/esm/content-fields/hubtype-fields/custom-conditional-v2.js +36 -0
- package/lib/esm/content-fields/hubtype-fields/custom-conditional-v2.js.map +1 -0
- package/lib/esm/content-fields/hubtype-fields/index.d.ts +1 -0
- package/lib/esm/content-fields/hubtype-fields/index.js +1 -0
- package/lib/esm/content-fields/hubtype-fields/index.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.d.ts +2 -1
- package/lib/esm/content-fields/hubtype-fields/node-types.js +1 -0
- package/lib/esm/content-fields/hubtype-fields/node-types.js.map +1 -1
- package/lib/esm/content-fields/hubtype-fields/nodes.d.ts +2 -1
- package/lib/esm/content-fields/index.d.ts +3 -2
- package/lib/esm/content-fields/index.js +3 -1
- package/lib/esm/content-fields/index.js.map +1 -1
- package/lib/esm/flow-factory.js +2 -0
- package/lib/esm/flow-factory.js.map +1 -1
- package/package.json +2 -2
- package/src/content-fields/custom-conditional-v2-evaluators.ts +124 -0
- package/src/content-fields/custom-conditional-v2-resolver.ts +77 -0
- package/src/content-fields/flow-custom-condition-v2.tsx +133 -0
- package/src/content-fields/hubtype-fields/custom-conditional-v2.ts +68 -0
- package/src/content-fields/hubtype-fields/index.ts +1 -0
- package/src/content-fields/hubtype-fields/node-types.ts +1 -0
- package/src/content-fields/hubtype-fields/nodes.ts +2 -0
- package/src/content-fields/index.ts +3 -0
- package/src/flow-factory.ts +7 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BooleanConditionOperator, type HtBooleanCondition, type HtNumberCondition, type HtStringCondition, NumberConditionOperator, StringConditionOperator } from './hubtype-fields';
|
|
2
|
+
type StringEvaluator = (variable: string, value: string) => boolean;
|
|
3
|
+
type NumberEvaluator = (variable: number, value: number, condition: HtNumberCondition) => boolean;
|
|
4
|
+
type BooleanEvaluator = (variable: boolean) => boolean;
|
|
5
|
+
export declare function getMinAndMax(condition: HtNumberCondition): {
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const STRING_CONDITION_EVALUATORS: Record<StringConditionOperator, StringEvaluator>;
|
|
10
|
+
export declare const NUMBER_CONDITION_EVALUATORS: Record<NumberConditionOperator, NumberEvaluator>;
|
|
11
|
+
export declare const BOOLEAN_CONDITION_EVALUATORS: Record<BooleanConditionOperator, BooleanEvaluator>;
|
|
12
|
+
export declare function evaluateStringCondition(variable: string, condition: HtStringCondition): boolean;
|
|
13
|
+
export declare function evaluateNumberCondition(variable: number, condition: HtNumberCondition): boolean;
|
|
14
|
+
export declare function evaluateBooleanCondition(variable: boolean, condition: HtBooleanCondition): boolean;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BOOLEAN_CONDITION_EVALUATORS = exports.NUMBER_CONDITION_EVALUATORS = exports.STRING_CONDITION_EVALUATORS = void 0;
|
|
4
|
+
exports.getMinAndMax = getMinAndMax;
|
|
5
|
+
exports.evaluateStringCondition = evaluateStringCondition;
|
|
6
|
+
exports.evaluateNumberCondition = evaluateNumberCondition;
|
|
7
|
+
exports.evaluateBooleanCondition = evaluateBooleanCondition;
|
|
8
|
+
const hubtype_fields_1 = require("./hubtype-fields");
|
|
9
|
+
function getMinAndMax(condition) {
|
|
10
|
+
if (condition.min !== undefined && condition.max !== undefined) {
|
|
11
|
+
return { min: condition.min, max: condition.max };
|
|
12
|
+
}
|
|
13
|
+
throw new Error(`Min or max not found for number condition ${condition.operator}`);
|
|
14
|
+
}
|
|
15
|
+
exports.STRING_CONDITION_EVALUATORS = {
|
|
16
|
+
[hubtype_fields_1.StringConditionOperator.Contains]: (variable, value) => variable.includes(value),
|
|
17
|
+
[hubtype_fields_1.StringConditionOperator.NotContains]: (variable, value) => !variable.includes(value),
|
|
18
|
+
[hubtype_fields_1.StringConditionOperator.EqualsTo]: (variable, value) => variable === value,
|
|
19
|
+
[hubtype_fields_1.StringConditionOperator.NotEqualsTo]: (variable, value) => variable !== value,
|
|
20
|
+
[hubtype_fields_1.StringConditionOperator.StartsWith]: (variable, value) => variable.startsWith(value),
|
|
21
|
+
[hubtype_fields_1.StringConditionOperator.NotStartsWith]: (variable, value) => !variable.startsWith(value),
|
|
22
|
+
[hubtype_fields_1.StringConditionOperator.EndsWith]: (variable, value) => variable.endsWith(value),
|
|
23
|
+
[hubtype_fields_1.StringConditionOperator.NotEndsWith]: (variable, value) => !variable.endsWith(value),
|
|
24
|
+
};
|
|
25
|
+
exports.NUMBER_CONDITION_EVALUATORS = {
|
|
26
|
+
[hubtype_fields_1.NumberConditionOperator.EqualsTo]: (variable, value) => variable === value,
|
|
27
|
+
[hubtype_fields_1.NumberConditionOperator.NotEqualsTo]: (variable, value) => variable !== value,
|
|
28
|
+
[hubtype_fields_1.NumberConditionOperator.GreaterThan]: (variable, value) => variable > value,
|
|
29
|
+
[hubtype_fields_1.NumberConditionOperator.LessThan]: (variable, value) => variable < value,
|
|
30
|
+
[hubtype_fields_1.NumberConditionOperator.GreaterThanOrEqualTo]: (variable, value) => variable >= value,
|
|
31
|
+
[hubtype_fields_1.NumberConditionOperator.LessThanOrEqualTo]: (variable, value) => variable <= value,
|
|
32
|
+
[hubtype_fields_1.NumberConditionOperator.Between]: (variable, _value, condition) => {
|
|
33
|
+
const { min, max } = getMinAndMax(condition);
|
|
34
|
+
return variable >= min && variable <= max;
|
|
35
|
+
},
|
|
36
|
+
[hubtype_fields_1.NumberConditionOperator.NotBetween]: (variable, _value, condition) => {
|
|
37
|
+
const { min, max } = getMinAndMax(condition);
|
|
38
|
+
return variable < min || variable > max;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
exports.BOOLEAN_CONDITION_EVALUATORS = {
|
|
42
|
+
[hubtype_fields_1.BooleanConditionOperator.IsTruthy]: variable => !!variable,
|
|
43
|
+
};
|
|
44
|
+
function evaluateStringCondition(variable, condition) {
|
|
45
|
+
if (condition.value === undefined) {
|
|
46
|
+
throw new Error(`Value not found for string condition ${condition.operator}`);
|
|
47
|
+
}
|
|
48
|
+
const evaluator = exports.STRING_CONDITION_EVALUATORS[condition.operator];
|
|
49
|
+
if (!evaluator) {
|
|
50
|
+
throw new Error(`Invalid string condition operator ${condition.operator}`);
|
|
51
|
+
}
|
|
52
|
+
return evaluator(variable, condition.value);
|
|
53
|
+
}
|
|
54
|
+
function evaluateNumberCondition(variable, condition) {
|
|
55
|
+
if (condition.value === undefined) {
|
|
56
|
+
throw new Error(`Value not found for number condition ${condition.operator}`);
|
|
57
|
+
}
|
|
58
|
+
const evaluator = exports.NUMBER_CONDITION_EVALUATORS[condition.operator];
|
|
59
|
+
if (!evaluator) {
|
|
60
|
+
throw new Error(`Invalid number condition operator ${condition.operator}`);
|
|
61
|
+
}
|
|
62
|
+
return evaluator(variable, condition.value, condition);
|
|
63
|
+
}
|
|
64
|
+
function evaluateBooleanCondition(variable, condition) {
|
|
65
|
+
const evaluator = exports.BOOLEAN_CONDITION_EVALUATORS[condition.operator];
|
|
66
|
+
if (!evaluator) {
|
|
67
|
+
throw new Error(`Invalid boolean condition operator ${condition.operator}`);
|
|
68
|
+
}
|
|
69
|
+
return evaluator(variable);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=custom-conditional-v2-evaluators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-conditional-v2-evaluators.js","sourceRoot":"","sources":["../../../src/content-fields/custom-conditional-v2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CAAC;AAED,SAAgB,wBAAwB,CACtC,QAAiB,EACjB,SAA6B;IAE7B,MAAM,SAAS,GAAG,oCAA4B,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAA;IAClE,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,MAAM,IAAI,KAAK,CAAC,sCAAsC,SAAS,CAAC,QAAQ,EAAE,CAAC,CAAA;IAC7E,CAAC;IACD,OAAO,SAAS,CAAC,QAAQ,CAAC,CAAA;AAC5B,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type HtCondition, type HtNodeLink, VariableFormat } from './hubtype-fields';
|
|
2
|
+
export type ConditionMatch = {
|
|
3
|
+
customResult: string;
|
|
4
|
+
target: HtNodeLink;
|
|
5
|
+
};
|
|
6
|
+
export declare function getConditionCustomResult(condition: HtCondition, variableFormat: VariableFormat): string;
|
|
7
|
+
export declare function findLastMatchingCondition<T extends HtCondition>(conditions: T[], variable: unknown, variableFormat: VariableFormat, evaluate: (variable: unknown, condition: T) => boolean): ConditionMatch | undefined;
|
|
8
|
+
export declare function resolveWithDefaultTarget(match: ConditionMatch | undefined, defaultTarget: HtNodeLink, nodeCode: string, defaultCustomResult?: string): ConditionMatch;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getConditionCustomResult = getConditionCustomResult;
|
|
4
|
+
exports.findLastMatchingCondition = findLastMatchingCondition;
|
|
5
|
+
exports.resolveWithDefaultTarget = resolveWithDefaultTarget;
|
|
6
|
+
const hubtype_fields_1 = require("./hubtype-fields");
|
|
7
|
+
function getConditionCustomResult(condition, variableFormat) {
|
|
8
|
+
switch (variableFormat) {
|
|
9
|
+
case hubtype_fields_1.VariableFormat.String:
|
|
10
|
+
return String(condition.value);
|
|
11
|
+
case hubtype_fields_1.VariableFormat.Number:
|
|
12
|
+
return String(condition.value);
|
|
13
|
+
case hubtype_fields_1.VariableFormat.Boolean:
|
|
14
|
+
// Only reached after evaluateBooleanCondition succeeds; today that is isTruthy → 'true'
|
|
15
|
+
return 'true';
|
|
16
|
+
default:
|
|
17
|
+
throw new Error(`Invalid variable format ${variableFormat}`);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function findLastMatchingCondition(conditions, variable, variableFormat, evaluate) {
|
|
21
|
+
let lastMatch;
|
|
22
|
+
for (const condition of conditions) {
|
|
23
|
+
if (!evaluate(variable, condition)) {
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
if (!condition.target) {
|
|
27
|
+
continue;
|
|
28
|
+
}
|
|
29
|
+
lastMatch = {
|
|
30
|
+
customResult: getConditionCustomResult(condition, variableFormat),
|
|
31
|
+
target: condition.target,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
return lastMatch;
|
|
35
|
+
}
|
|
36
|
+
function resolveWithDefaultTarget(match, defaultTarget, nodeCode, defaultCustomResult = 'default') {
|
|
37
|
+
if (match) {
|
|
38
|
+
return match;
|
|
39
|
+
}
|
|
40
|
+
if (!defaultTarget) {
|
|
41
|
+
throw new Error(`Default target not found for custom condition node ${nodeCode}`);
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
customResult: defaultCustomResult,
|
|
45
|
+
target: defaultTarget,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=custom-conditional-v2-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-conditional-v2-resolver.js","sourceRoot":"","sources":["../../../src/content-fields/custom-conditional-v2-resolver.ts"],"names":[],"mappings":";;AAaA,4DAeC;AAED,8DAwBC;AAED,4DAoBC;AA5ED,qDAMyB;AAOzB,SAAgB,wBAAwB,CACtC,SAAsB,EACtB,cAA8B;IAE9B,QAAQ,cAAc,EAAE,CAAC;QACvB,KAAK,+BAAc,CAAC,MAAM;YACxB,OAAO,MAAM,CAAE,SAA+B,CAAC,KAAK,CAAC,CAAA;QACvD,KAAK,+BAAc,CAAC,MAAM;YACxB,OAAO,MAAM,CAAE,SAA+B,CAAC,KAAK,CAAC,CAAA;QACvD,KAAK,+BAAc,CAAC,OAAO;YACzB,wFAAwF;YACxF,OAAO,MAAM,CAAA;QACf;YACE,MAAM,IAAI,KAAK,CAAC,2BAA2B,cAAc,EAAE,CAAC,CAAA;IAChE,CAAC;AACH,CAAC;AAED,SAAgB,yBAAyB,CACvC,UAAe,EACf,QAAiB,EACjB,cAA8B,EAC9B,QAAsD;IAEtD,IAAI,SAAqC,CAAA;IAEzC,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACnC,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,EAAE,CAAC;YACnC,SAAQ;QACV,CAAC;QAED,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YACtB,SAAQ;QACV,CAAC;QAED,SAAS,GAAG;YACV,YAAY,EAAE,wBAAwB,CAAC,SAAS,EAAE,cAAc,CAAC;YACjE,MAAM,EAAE,SAAS,CAAC,MAAM;SACzB,CAAA;IACH,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAgB,wBAAwB,CACtC,KAAiC,EACjC,aAAyB,EACzB,QAAgB,EAChB,sBAA8B,SAAS;IAEvC,IAAI,KAAK,EAAE,CAAC;QACV,OAAO,KAAK,CAAA;IACd,CAAC;IAED,IAAI,CAAC,aAAa,EAAE,CAAC;QACnB,MAAM,IAAI,KAAK,CACb,sDAAsD,QAAQ,EAAE,CACjE,CAAA;IACH,CAAC;IAED,OAAO;QACL,YAAY,EAAE,mBAAmB;QACjC,MAAM,EAAE,aAAa;KACtB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { type BotContext } from '@botonic/core';
|
|
2
|
+
import { ContentFieldsBase } from './content-fields-base';
|
|
3
|
+
import { type HtCondition, type HtCustomConditionalV2Node, type HtNodeLink, VariableFormat } from './hubtype-fields';
|
|
4
|
+
export declare class FlowCustomConditionalV2 extends ContentFieldsBase {
|
|
5
|
+
variableFormat: VariableFormat;
|
|
6
|
+
keyPath: string;
|
|
7
|
+
conditions: HtCondition[];
|
|
8
|
+
defaultTarget: HtNodeLink;
|
|
9
|
+
customResult: string;
|
|
10
|
+
static fromHubtypeCMS(component: HtCustomConditionalV2Node, botContext: BotContext): FlowCustomConditionalV2;
|
|
11
|
+
private setFollowUp;
|
|
12
|
+
private evaluateConditions;
|
|
13
|
+
trackFlow(botContext: BotContext): Promise<void>;
|
|
14
|
+
processContent(botContext: BotContext): Promise<void>;
|
|
15
|
+
toBotonic(): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FlowCustomConditionalV2 = void 0;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const core_1 = require("@botonic/core");
|
|
6
|
+
const tracking_1 = require("../tracking");
|
|
7
|
+
const content_fields_base_1 = require("./content-fields-base");
|
|
8
|
+
const custom_conditional_v2_evaluators_1 = require("./custom-conditional-v2-evaluators");
|
|
9
|
+
const custom_conditional_v2_resolver_1 = require("./custom-conditional-v2-resolver");
|
|
10
|
+
const hubtype_fields_1 = require("./hubtype-fields");
|
|
11
|
+
class FlowCustomConditionalV2 extends content_fields_base_1.ContentFieldsBase {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.customResult = '';
|
|
15
|
+
}
|
|
16
|
+
static fromHubtypeCMS(component, botContext) {
|
|
17
|
+
const newCustomConditionalV2 = new FlowCustomConditionalV2(component.id);
|
|
18
|
+
newCustomConditionalV2.code = component.code;
|
|
19
|
+
newCustomConditionalV2.variableFormat = component.content.type;
|
|
20
|
+
newCustomConditionalV2.keyPath = component.content.key_path;
|
|
21
|
+
newCustomConditionalV2.conditions = component.content.conditions;
|
|
22
|
+
newCustomConditionalV2.defaultTarget = component.content.default_target;
|
|
23
|
+
newCustomConditionalV2.setFollowUp(botContext);
|
|
24
|
+
return newCustomConditionalV2;
|
|
25
|
+
}
|
|
26
|
+
setFollowUp(botContext) {
|
|
27
|
+
const botVariable = this.getValueFromKeyPath(botContext, this.keyPath);
|
|
28
|
+
const resolved = this.evaluateConditions(botVariable);
|
|
29
|
+
this.customResult = resolved.customResult;
|
|
30
|
+
this.followUp = resolved.target;
|
|
31
|
+
}
|
|
32
|
+
evaluateConditions(botVariable) {
|
|
33
|
+
switch (this.variableFormat) {
|
|
34
|
+
case hubtype_fields_1.VariableFormat.String: {
|
|
35
|
+
const match = (0, custom_conditional_v2_resolver_1.findLastMatchingCondition)(this.conditions, botVariable, this.variableFormat, (variable, condition) => (0, custom_conditional_v2_evaluators_1.evaluateStringCondition)(variable, condition));
|
|
36
|
+
return (0, custom_conditional_v2_resolver_1.resolveWithDefaultTarget)(match, this.defaultTarget, this.code);
|
|
37
|
+
}
|
|
38
|
+
case hubtype_fields_1.VariableFormat.Number: {
|
|
39
|
+
const match = (0, custom_conditional_v2_resolver_1.findLastMatchingCondition)(this.conditions, botVariable, this.variableFormat, (variable, condition) => (0, custom_conditional_v2_evaluators_1.evaluateNumberCondition)(variable, condition));
|
|
40
|
+
return (0, custom_conditional_v2_resolver_1.resolveWithDefaultTarget)(match, this.defaultTarget, this.code);
|
|
41
|
+
}
|
|
42
|
+
case hubtype_fields_1.VariableFormat.Boolean: {
|
|
43
|
+
const match = (0, custom_conditional_v2_resolver_1.findLastMatchingCondition)(this.conditions, botVariable, this.variableFormat, (variable, condition) => (0, custom_conditional_v2_evaluators_1.evaluateBooleanCondition)(variable, condition));
|
|
44
|
+
return (0, custom_conditional_v2_resolver_1.resolveWithDefaultTarget)(match, this.defaultTarget, this.code, 'false');
|
|
45
|
+
}
|
|
46
|
+
default:
|
|
47
|
+
throw new Error(`Invalid variable format ${this.variableFormat} for custom condition node ${this.code}`);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async trackFlow(botContext) {
|
|
51
|
+
const { flowThreadId, flowId, flowName, flowNodeId, flowNodeContentId } = (0, tracking_1.getCommonFlowContentEventArgsForContentId)(botContext, this.id);
|
|
52
|
+
const eventCustomConditional = {
|
|
53
|
+
action: core_1.EventAction.ConditionalCustom,
|
|
54
|
+
flowThreadId,
|
|
55
|
+
flowId,
|
|
56
|
+
flowName,
|
|
57
|
+
flowNodeId,
|
|
58
|
+
flowNodeContentId,
|
|
59
|
+
flowNodeIsMeaningful: false,
|
|
60
|
+
conditionalVariable: this.customResult,
|
|
61
|
+
variableFormat: this.variableFormat,
|
|
62
|
+
};
|
|
63
|
+
const { action, ...eventArgs } = eventCustomConditional;
|
|
64
|
+
await (0, tracking_1.trackEvent)(botContext, action, eventArgs);
|
|
65
|
+
}
|
|
66
|
+
async processContent(botContext) {
|
|
67
|
+
await this.filterContent(botContext, this);
|
|
68
|
+
await this.trackFlow(botContext);
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
toBotonic() {
|
|
72
|
+
return (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {});
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.FlowCustomConditionalV2 = FlowCustomConditionalV2;
|
|
76
|
+
//# sourceMappingURL=flow-custom-condition-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"flow-custom-condition-v2.js","sourceRoot":"","sources":["../../../src/content-fields/flow-custom-condition-v2.tsx"],"names":[],"mappings":";;;;AAAA,wCAIsB;AACtB,0CAGoB;AACpB,+DAAyD;AACzD,yFAI2C;AAC3C,qFAIyC;AACzC,qDAQyB;AAEzB,MAAa,uBAAwB,SAAQ,uCAAiB;IAA9D;;QAKS,iBAAY,GAAG,EAAE,CAAA;IAiG1B,CAAC;IA/FC,MAAM,CAAC,cAAc,CACnB,SAAoC,EACpC,UAAsB;QAEtB,MAAM,sBAAsB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,EAAE,IAAI,CAAC,YAAY;YACtC,cAAc,EAAE,IAAI,CAAC,cAAc;SACpC,CAAA;QACD,MAAM,EAAE,MAAM,EAAE,GAAG,SAAS,EAAE,GAAG,sBAAsB,CAAA;QACvD,MAAM,IAAA,qBAAU,EAAC,UAAU,EAAE,MAAM,EAAE,SAAS,CAAC,CAAA;IACjD,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,UAAsB;QACzC,MAAM,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,CAAA;QAC1C,MAAM,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAA;QAChC,OAAM;IACR,CAAC;IAED,SAAS;QACP,OAAO,kDAAK,CAAA;IACd,CAAC;CACF;AAtGD,0DAsGC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { HtBaseNode, HtNodeLink } from './common';
|
|
2
|
+
import type { HtNodeWithContentType } from './node-types';
|
|
3
|
+
export declare enum VariableFormat {
|
|
4
|
+
Boolean = "boolean",
|
|
5
|
+
Number = "number",
|
|
6
|
+
String = "string"
|
|
7
|
+
}
|
|
8
|
+
export declare enum StringConditionOperator {
|
|
9
|
+
Contains = "contains",
|
|
10
|
+
NotContains = "notContains",
|
|
11
|
+
EqualsTo = "equalsTo",
|
|
12
|
+
NotEqualsTo = "notEqualsTo",
|
|
13
|
+
StartsWith = "startsWith",
|
|
14
|
+
NotStartsWith = "notStartsWith",
|
|
15
|
+
EndsWith = "endsWith",
|
|
16
|
+
NotEndsWith = "notEndsWith"
|
|
17
|
+
}
|
|
18
|
+
export interface HtStringCondition {
|
|
19
|
+
operator: StringConditionOperator;
|
|
20
|
+
value?: string;
|
|
21
|
+
target?: HtNodeLink;
|
|
22
|
+
}
|
|
23
|
+
export declare enum NumberConditionOperator {
|
|
24
|
+
EqualsTo = "equalsTo",
|
|
25
|
+
NotEqualsTo = "notEqualsTo",
|
|
26
|
+
GreaterThan = "greaterThan",
|
|
27
|
+
LessThan = "lessThan",
|
|
28
|
+
GreaterThanOrEqualTo = "greaterThanOrEqualTo",
|
|
29
|
+
LessThanOrEqualTo = "lessThanOrEqualTo",
|
|
30
|
+
Between = "between",
|
|
31
|
+
NotBetween = "notBetween"
|
|
32
|
+
}
|
|
33
|
+
export interface HtNumberCondition {
|
|
34
|
+
operator: NumberConditionOperator;
|
|
35
|
+
value?: number;
|
|
36
|
+
min?: number;
|
|
37
|
+
max?: number;
|
|
38
|
+
target?: HtNodeLink;
|
|
39
|
+
}
|
|
40
|
+
export declare enum BooleanConditionOperator {
|
|
41
|
+
IsTruthy = "isTruthy"
|
|
42
|
+
}
|
|
43
|
+
export interface HtBooleanCondition {
|
|
44
|
+
operator: BooleanConditionOperator;
|
|
45
|
+
target?: HtNodeLink;
|
|
46
|
+
}
|
|
47
|
+
export type HtCondition = HtStringCondition | HtNumberCondition | HtBooleanCondition;
|
|
48
|
+
export interface HtCustomConditionalV2Node extends HtBaseNode {
|
|
49
|
+
type: HtNodeWithContentType.CUSTOM_CONDITION;
|
|
50
|
+
content: {
|
|
51
|
+
type: VariableFormat;
|
|
52
|
+
key_path: string;
|
|
53
|
+
conditions: HtCondition[];
|
|
54
|
+
default_target: HtNodeLink;
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BooleanConditionOperator = exports.NumberConditionOperator = exports.StringConditionOperator = exports.VariableFormat = void 0;
|
|
4
|
+
var VariableFormat;
|
|
5
|
+
(function (VariableFormat) {
|
|
6
|
+
VariableFormat["Boolean"] = "boolean";
|
|
7
|
+
VariableFormat["Number"] = "number";
|
|
8
|
+
VariableFormat["String"] = "string";
|
|
9
|
+
})(VariableFormat || (exports.VariableFormat = VariableFormat = {}));
|
|
10
|
+
var StringConditionOperator;
|
|
11
|
+
(function (StringConditionOperator) {
|
|
12
|
+
StringConditionOperator["Contains"] = "contains";
|
|
13
|
+
StringConditionOperator["NotContains"] = "notContains";
|
|
14
|
+
StringConditionOperator["EqualsTo"] = "equalsTo";
|
|
15
|
+
StringConditionOperator["NotEqualsTo"] = "notEqualsTo";
|
|
16
|
+
StringConditionOperator["StartsWith"] = "startsWith";
|
|
17
|
+
StringConditionOperator["NotStartsWith"] = "notStartsWith";
|
|
18
|
+
StringConditionOperator["EndsWith"] = "endsWith";
|
|
19
|
+
StringConditionOperator["NotEndsWith"] = "notEndsWith";
|
|
20
|
+
})(StringConditionOperator || (exports.StringConditionOperator = StringConditionOperator = {}));
|
|
21
|
+
var NumberConditionOperator;
|
|
22
|
+
(function (NumberConditionOperator) {
|
|
23
|
+
NumberConditionOperator["EqualsTo"] = "equalsTo";
|
|
24
|
+
NumberConditionOperator["NotEqualsTo"] = "notEqualsTo";
|
|
25
|
+
NumberConditionOperator["GreaterThan"] = "greaterThan";
|
|
26
|
+
NumberConditionOperator["LessThan"] = "lessThan";
|
|
27
|
+
NumberConditionOperator["GreaterThanOrEqualTo"] = "greaterThanOrEqualTo";
|
|
28
|
+
NumberConditionOperator["LessThanOrEqualTo"] = "lessThanOrEqualTo";
|
|
29
|
+
NumberConditionOperator["Between"] = "between";
|
|
30
|
+
NumberConditionOperator["NotBetween"] = "notBetween";
|
|
31
|
+
})(NumberConditionOperator || (exports.NumberConditionOperator = NumberConditionOperator = {}));
|
|
32
|
+
var BooleanConditionOperator;
|
|
33
|
+
(function (BooleanConditionOperator) {
|
|
34
|
+
BooleanConditionOperator["IsTruthy"] = "isTruthy";
|
|
35
|
+
})(BooleanConditionOperator || (exports.BooleanConditionOperator = BooleanConditionOperator = {}));
|
|
36
|
+
//# sourceMappingURL=custom-conditional-v2.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-conditional-v2.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/custom-conditional-v2.ts"],"names":[],"mappings":";;;AAGA,IAAY,cAIX;AAJD,WAAY,cAAc;IACxB,qCAAmB,CAAA;IACnB,mCAAiB,CAAA;IACjB,mCAAiB,CAAA;AACnB,CAAC,EAJW,cAAc,8BAAd,cAAc,QAIzB;AAED,IAAY,uBASX;AATD,WAAY,uBAAuB;IACjC,gDAAqB,CAAA;IACrB,sDAA2B,CAAA;IAC3B,gDAAqB,CAAA;IACrB,sDAA2B,CAAA;IAC3B,oDAAyB,CAAA;IACzB,0DAA+B,CAAA;IAC/B,gDAAqB,CAAA;IACrB,sDAA2B,CAAA;AAC7B,CAAC,EATW,uBAAuB,uCAAvB,uBAAuB,QASlC;AAQD,IAAY,uBASX;AATD,WAAY,uBAAuB;IACjC,gDAAqB,CAAA;IACrB,sDAA2B,CAAA;IAC3B,sDAA2B,CAAA;IAC3B,gDAAqB,CAAA;IACrB,wEAA6C,CAAA;IAC7C,kEAAuC,CAAA;IACvC,8CAAmB,CAAA;IACnB,oDAAyB,CAAA;AAC3B,CAAC,EATW,uBAAuB,uCAAvB,uBAAuB,QASlC;AAUD,IAAY,wBAEX;AAFD,WAAY,wBAAwB;IAClC,iDAAqB,CAAA;AACvB,CAAC,EAFW,wBAAwB,wCAAxB,wBAAwB,QAEnC"}
|
|
@@ -8,6 +8,7 @@ tslib_1.__exportStar(require("./button"), exports);
|
|
|
8
8
|
tslib_1.__exportStar(require("./capture-user-input"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./carousel"), exports);
|
|
10
10
|
tslib_1.__exportStar(require("./common"), exports);
|
|
11
|
+
tslib_1.__exportStar(require("./custom-conditional-v2"), exports);
|
|
11
12
|
tslib_1.__exportStar(require("./fallback"), exports);
|
|
12
13
|
tslib_1.__exportStar(require("./function"), exports);
|
|
13
14
|
tslib_1.__exportStar(require("./go-to-flow"), exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,4DAAiC;AACjC,uDAA4B;AAC5B,mDAAwB;AACxB,+DAAoC;AACpC,qDAA0B;AAC1B,mDAAwB;AACxB,qDAA0B;AAC1B,qDAA0B;AAC1B,uDAA4B;AAC5B,oDAAyB;AACzB,kDAAuB;AACvB,oDAAyB;AACzB,2DAAgC;AAChC,uDAA4B;AAC5B,kDAAuB;AACvB,oDAAyB;AACzB,mDAAwB;AACxB,yDAA8B;AAC9B,iDAAsB;AACtB,gDAAqB;AACrB,kDAAuB;AACvB,oDAAyB;AACzB,iEAAsC;AACtC,oEAAyC;AACzC,8DAAmC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,4DAAiC;AACjC,uDAA4B;AAC5B,mDAAwB;AACxB,+DAAoC;AACpC,qDAA0B;AAC1B,mDAAwB;AACxB,kEAAuC;AACvC,qDAA0B;AAC1B,qDAA0B;AAC1B,uDAA4B;AAC5B,oDAAyB;AACzB,kDAAuB;AACvB,oDAAyB;AACzB,2DAAgC;AAChC,uDAA4B;AAC5B,kDAAuB;AACvB,oDAAyB;AACzB,mDAAwB;AACxB,yDAA8B;AAC9B,iDAAsB;AACtB,gDAAqB;AACrB,kDAAuB;AACvB,oDAAyB;AACzB,iEAAsC;AACtC,oEAAyC;AACzC,8DAAmC"}
|
|
@@ -18,7 +18,8 @@ export declare enum HtNodeWithContentType {
|
|
|
18
18
|
RATING = "rating",
|
|
19
19
|
WEBVIEW = "webview",
|
|
20
20
|
GO_TO_FLOW = "go-to-flow",
|
|
21
|
-
CAPTURE_USER_INPUT = "capture-user-input"
|
|
21
|
+
CAPTURE_USER_INPUT = "capture-user-input",
|
|
22
|
+
CUSTOM_CONDITION = "custom-condition"
|
|
22
23
|
}
|
|
23
24
|
export declare enum HtNodeWithoutContentType {
|
|
24
25
|
URL = "url",
|
|
@@ -23,6 +23,7 @@ var HtNodeWithContentType;
|
|
|
23
23
|
HtNodeWithContentType["WEBVIEW"] = "webview";
|
|
24
24
|
HtNodeWithContentType["GO_TO_FLOW"] = "go-to-flow";
|
|
25
25
|
HtNodeWithContentType["CAPTURE_USER_INPUT"] = "capture-user-input";
|
|
26
|
+
HtNodeWithContentType["CUSTOM_CONDITION"] = "custom-condition";
|
|
26
27
|
})(HtNodeWithContentType || (exports.HtNodeWithContentType = HtNodeWithContentType = {}));
|
|
27
28
|
var HtNodeWithoutContentType;
|
|
28
29
|
(function (HtNodeWithoutContentType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node-types.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/node-types.ts"],"names":[],"mappings":";;;AAAA,IAAY,
|
|
1
|
+
{"version":3,"file":"node-types.js","sourceRoot":"","sources":["../../../../src/content-fields/hubtype-fields/node-types.ts"],"names":[],"mappings":";;;AAAA,IAAY,qBAsBX;AAtBD,WAAY,qBAAqB;IAC/B,8CAAqB,CAAA;IACrB,4CAAmB,CAAA;IACnB,wCAAe,CAAA;IACf,sCAAa,CAAA;IACb,4CAAmB,CAAA;IACnB,sDAA6B,CAAA;IAC7B,8CAAqB,CAAA;IACrB,8CAAqB,CAAA;IACrB,wCAAe,CAAA;IACf,sEAA6C,CAAA;IAC7C,4EAAmD,CAAA;IACnD,gEAAuC,CAAA;IACvC,0DAAiC,CAAA;IACjC,kDAAyB,CAAA;IACzB,8CAAqB,CAAA;IACrB,4DAAmC,CAAA;IACnC,0CAAiB,CAAA;IACjB,4CAAmB,CAAA;IACnB,kDAAyB,CAAA;IACzB,kEAAyC,CAAA;IACzC,8DAAqC,CAAA;AACvC,CAAC,EAtBW,qBAAqB,qCAArB,qBAAqB,QAsBhC;AAED,IAAY,wBAGX;AAHD,WAAY,wBAAwB;IAClC,uCAAW,CAAA;IACX,+CAAmB,CAAA;AACrB,CAAC,EAHW,wBAAwB,wCAAxB,wBAAwB,QAGnC;AAED,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,4CAA2B,CAAA;AAC7B,CAAC,EAHW,aAAa,6BAAb,aAAa,QAGxB"}
|
|
@@ -3,6 +3,7 @@ import type { HtAiAgentRouterNode } from './ai-agent-router';
|
|
|
3
3
|
import type { HtBotActionNode } from './bot-action';
|
|
4
4
|
import type { HtCaptureUserInputNode } from './capture-user-input';
|
|
5
5
|
import type { HtCarouselNode } from './carousel';
|
|
6
|
+
import type { HtCustomConditionalV2Node } from './custom-conditional-v2';
|
|
6
7
|
import type { HtFallbackNode } from './fallback';
|
|
7
8
|
import type { HtFunctionNode } from './function';
|
|
8
9
|
import type { HtGoToFlow } from './go-to-flow';
|
|
@@ -20,6 +21,6 @@ import type { HtWebviewNode } from './webview';
|
|
|
20
21
|
import type { HtWhatsappButtonListNode } from './whatsapp-button-list';
|
|
21
22
|
import type { HtWhatsappCTAUrlButtonNode } from './whatsapp-cta-url-button';
|
|
22
23
|
import type { HtWhatsappTemplateNode } from './whatsapp-template';
|
|
23
|
-
export type HtNodeWithContent = HtTextNode | HtImageNode | HtVideoNode | HtCarouselNode | HtHandoffNode | HtKeywordNode | HtFunctionNode | HtFallbackNode | HtWhatsappButtonListNode | HtWhatsappCTAUrlButtonNode | HtSmartIntentNode | HtKnowledgeBaseNode | HtBotActionNode | HtAiAgentNode | HtAiAgentRouterNode | HtRatingNode | HtWebviewNode | HtGoToFlow | HtWhatsappTemplateNode | HtCaptureUserInputNode;
|
|
24
|
+
export type HtNodeWithContent = HtTextNode | HtImageNode | HtVideoNode | HtCarouselNode | HtHandoffNode | HtKeywordNode | HtFunctionNode | HtFallbackNode | HtWhatsappButtonListNode | HtWhatsappCTAUrlButtonNode | HtSmartIntentNode | HtKnowledgeBaseNode | HtBotActionNode | HtAiAgentNode | HtAiAgentRouterNode | HtRatingNode | HtWebviewNode | HtGoToFlow | HtWhatsappTemplateNode | HtCaptureUserInputNode | HtCustomConditionalV2Node;
|
|
24
25
|
export type HtNodeWithoutContent = HtUrlNode | HtPayloadNode;
|
|
25
26
|
export type HtNodeComponent = HtNodeWithContent | HtNodeWithoutContent;
|
|
@@ -5,6 +5,7 @@ import { FlowCaptureUserInput } from './flow-capture-user-input';
|
|
|
5
5
|
import { FlowCarousel } from './flow-carousel';
|
|
6
6
|
import { FlowChannelConditional } from './flow-channel-conditional';
|
|
7
7
|
import { FlowCountryConditional } from './flow-country-conditional';
|
|
8
|
+
import { FlowCustomConditionalV2 } from './flow-custom-condition-v2';
|
|
8
9
|
import { FlowCustomConditional } from './flow-custom-conditional';
|
|
9
10
|
import { FlowGoToFlow } from './flow-go-to-flow';
|
|
10
11
|
import { FlowHandoff } from './flow-handoff';
|
|
@@ -20,6 +21,6 @@ import { FlowWhatsappButtonList } from './whatsapp-button-list/flow-whatsapp-but
|
|
|
20
21
|
export { ContentFieldsBase } from './content-fields-base';
|
|
21
22
|
export { FlowButton } from './flow-button';
|
|
22
23
|
export { FlowElement } from './flow-element';
|
|
23
|
-
export { FlowAiAgentRouter, FlowAiAgent, FlowBotAction, FlowCaptureUserInput, FlowCarousel, FlowChannelConditional, FlowCountryConditional, FlowCustomConditional, FlowGoToFlow, FlowHandoff, FlowImage, FlowKnowledgeBase, FlowQueueStatusConditional, FlowRating, FlowText, FlowVideo, FlowWhatsappButtonList, FlowWhatsappCtaUrlButtonNode, FlowWhatsappTemplate, };
|
|
24
|
-
export type FlowContent = FlowCarousel | FlowImage | FlowText | FlowVideo | FlowWhatsappButtonList | FlowWhatsappCtaUrlButtonNode | FlowWhatsappTemplate | FlowHandoff | FlowKnowledgeBase | FlowBotAction | FlowAiAgent | FlowRating | FlowCountryConditional | FlowChannelConditional | FlowQueueStatusConditional | FlowCustomConditional | FlowGoToFlow | FlowCaptureUserInput | FlowAiAgentRouter;
|
|
24
|
+
export { FlowAiAgentRouter, FlowAiAgent, FlowBotAction, FlowCaptureUserInput, FlowCarousel, FlowChannelConditional, FlowCountryConditional, FlowCustomConditional, FlowGoToFlow, FlowHandoff, FlowImage, FlowKnowledgeBase, FlowQueueStatusConditional, FlowRating, FlowText, FlowVideo, FlowWhatsappButtonList, FlowWhatsappCtaUrlButtonNode, FlowWhatsappTemplate, FlowCustomConditionalV2, };
|
|
25
|
+
export type FlowContent = FlowCarousel | FlowImage | FlowText | FlowVideo | FlowWhatsappButtonList | FlowWhatsappCtaUrlButtonNode | FlowWhatsappTemplate | FlowHandoff | FlowKnowledgeBase | FlowBotAction | FlowAiAgent | FlowRating | FlowCountryConditional | FlowChannelConditional | FlowQueueStatusConditional | FlowCustomConditional | FlowGoToFlow | FlowCaptureUserInput | FlowAiAgentRouter | FlowCustomConditionalV2;
|
|
25
26
|
export { DISABLED_MEMORY_LENGTH };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DISABLED_MEMORY_LENGTH = exports.FlowWhatsappTemplate = exports.FlowWhatsappCtaUrlButtonNode = exports.FlowWhatsappButtonList = exports.FlowVideo = exports.FlowText = exports.FlowRating = exports.FlowQueueStatusConditional = exports.FlowKnowledgeBase = exports.FlowImage = exports.FlowHandoff = exports.FlowGoToFlow = exports.FlowCustomConditional = exports.FlowCountryConditional = exports.FlowChannelConditional = exports.FlowCarousel = exports.FlowCaptureUserInput = exports.FlowBotAction = exports.FlowAiAgent = exports.FlowAiAgentRouter = exports.FlowElement = exports.FlowButton = exports.ContentFieldsBase = void 0;
|
|
3
|
+
exports.DISABLED_MEMORY_LENGTH = exports.FlowCustomConditionalV2 = exports.FlowWhatsappTemplate = exports.FlowWhatsappCtaUrlButtonNode = exports.FlowWhatsappButtonList = exports.FlowVideo = exports.FlowText = exports.FlowRating = exports.FlowQueueStatusConditional = exports.FlowKnowledgeBase = exports.FlowImage = exports.FlowHandoff = exports.FlowGoToFlow = exports.FlowCustomConditional = exports.FlowCountryConditional = exports.FlowChannelConditional = exports.FlowCarousel = exports.FlowCaptureUserInput = exports.FlowBotAction = exports.FlowAiAgent = exports.FlowAiAgentRouter = exports.FlowElement = exports.FlowButton = exports.ContentFieldsBase = void 0;
|
|
4
4
|
const flow_ai_agent_1 = require("./flow-ai-agent");
|
|
5
5
|
Object.defineProperty(exports, "FlowAiAgent", { enumerable: true, get: function () { return flow_ai_agent_1.FlowAiAgent; } });
|
|
6
6
|
const flow_ai_agent_router_1 = require("./flow-ai-agent-router");
|
|
@@ -15,6 +15,8 @@ const flow_channel_conditional_1 = require("./flow-channel-conditional");
|
|
|
15
15
|
Object.defineProperty(exports, "FlowChannelConditional", { enumerable: true, get: function () { return flow_channel_conditional_1.FlowChannelConditional; } });
|
|
16
16
|
const flow_country_conditional_1 = require("./flow-country-conditional");
|
|
17
17
|
Object.defineProperty(exports, "FlowCountryConditional", { enumerable: true, get: function () { return flow_country_conditional_1.FlowCountryConditional; } });
|
|
18
|
+
const flow_custom_condition_v2_1 = require("./flow-custom-condition-v2");
|
|
19
|
+
Object.defineProperty(exports, "FlowCustomConditionalV2", { enumerable: true, get: function () { return flow_custom_condition_v2_1.FlowCustomConditionalV2; } });
|
|
18
20
|
const flow_custom_conditional_1 = require("./flow-custom-conditional");
|
|
19
21
|
Object.defineProperty(exports, "FlowCustomConditional", { enumerable: true, get: function () { return flow_custom_conditional_1.FlowCustomConditional; } });
|
|
20
22
|
const flow_go_to_flow_1 = require("./flow-go-to-flow");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-fields/index.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-fields/index.ts"],"names":[],"mappings":";;;AAAA,mDAA6C;AA6B3C,4FA7BO,2BAAW,OA6BP;AA5Bb,iEAA0D;AA2BxD,kGA3BO,wCAAiB,OA2BP;AA1BnB,uDAAiD;AA4B/C,8FA5BO,+BAAa,OA4BP;AA3Bf,uEAAgE;AA4B9D,qGA5BO,8CAAoB,OA4BP;AA3BtB,mDAA8C;AA4B5C,6FA5BO,4BAAY,OA4BP;AA3Bd,yEAAmE;AA4BjE,uGA5BO,iDAAsB,OA4BP;AA3BxB,yEAAmE;AA4BjE,uGA5BO,iDAAsB,OA4BP;AA3BxB,yEAAoE;AAwClE,wGAxCO,kDAAuB,OAwCP;AAvCzB,uEAAiE;AA2B/D,sGA3BO,+CAAqB,OA2BP;AA1BvB,uDAAgD;AA2B9C,6FA3BO,8BAAY,OA2BP;AA1Bd,iDAA4C;AA2B1C,4FA3BO,0BAAW,OA2BP;AA1Bb,6CAAwC;AA2BtC,0FA3BO,sBAAS,OA2BP;AA1BX,+DAG8B;AAyDrB,uGA3DP,4CAAsB,OA2DO;AAjC7B,kGAzBA,uCAAiB,OAyBA;AAvBnB,mFAA4E;AAwB1E,2GAxBO,0DAA0B,OAwBP;AAvB5B,+CAA0C;AAwBxC,2FAxBO,wBAAU,OAwBP;AAvBZ,2CAAsC;AAwBpC,yFAxBO,oBAAQ,OAwBP;AAvBV,6CAAwC;AAwBtC,0FAxBO,sBAAS,OAwBP;AAvBX,iFAA6E;AAyB3E,6GAzBO,2DAA4B,OAyBP;AAxB9B,qEAA+D;AAyB7D,qGAzBO,6CAAoB,OAyBP;AAxBtB,gGAAyF;AAsBvF,uGAtBO,kDAAsB,OAsBP;AApBxB,6DAAyD;AAAhD,wHAAA,iBAAiB,OAAA;AAC1B,6CAA0C;AAAjC,yGAAA,UAAU,OAAA;AACnB,+CAA4C;AAAnC,2GAAA,WAAW,OAAA"}
|
package/lib/cjs/flow-factory.js
CHANGED
|
@@ -44,6 +44,8 @@ class FlowFactory {
|
|
|
44
44
|
return content_fields_1.FlowWhatsappTemplate.fromHubtypeCMS(hubtypeContent, this.locale);
|
|
45
45
|
case hubtype_fields_1.HtNodeWithContentType.CAPTURE_USER_INPUT:
|
|
46
46
|
return flow_capture_user_input_1.FlowCaptureUserInput.fromHubtypeCMS(hubtypeContent);
|
|
47
|
+
case hubtype_fields_1.HtNodeWithContentType.CUSTOM_CONDITION:
|
|
48
|
+
return content_fields_1.FlowCustomConditionalV2.fromHubtypeCMS(hubtypeContent, this.botContext);
|
|
47
49
|
default:
|
|
48
50
|
return undefined;
|
|
49
51
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow-factory.js","sourceRoot":"","sources":["../../src/flow-factory.ts"],"names":[],"mappings":";;;AAGA,
|
|
1
|
+
{"version":3,"file":"flow-factory.js","sourceRoot":"","sources":["../../src/flow-factory.ts"],"names":[],"mappings":";;;AAGA,qDAqByB;AACzB,sFAA+E;AAC/E,oEAIwC;AAExC,MAAa,WAAW;IAKtB,YAAY,UAAsB,EAAE,MAAsB,EAAE,MAAc;QACxE,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAED,KAAK,CAAC,cAAc,CAClB,cAA+B;QAE/B,QAAQ,cAAc,CAAC,IAAI,EAAE,CAAC;YAC5B,KAAK,sCAAqB,CAAC,IAAI;gBAC7B,OAAO,yBAAQ,CAAC,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;YAC1E,KAAK,sCAAqB,CAAC,KAAK;gBAC9B,OAAO,0BAAS,CAAC,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;YAC9D,KAAK,sCAAqB,CAAC,QAAQ;gBACjC,OAAO,6BAAY,CAAC,cAAc,CAChC,cAAc,EACd,IAAI,CAAC,MAAM,EACX,IAAI,CAAC,MAAM,CACZ,CAAA;YACH,KAAK,sCAAqB,CAAC,KAAK;gBAC9B,OAAO,0BAAS,CAAC,cAAc,CAAC,cAAc,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;YAC9D,KAAK,sCAAqB,CAAC,oBAAoB;gBAC7C,OAAO,uCAAsB,CAAC,cAAc,CAC1C,cAAc,EACd,IAAI,CAAC,MAAM,EAC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AAoB,CAAC,cAAc,CAAC,cAAc,CAAC,CAAA;YAE5D,KAAK,sCAAqB,CAAC,gBAAgB;gBACzC,OAAO,wCAAuB,CAAC,cAAc,CAC3C,cAAc,EACd,IAAI,CAAC,UAAU,CAChB,CAAA;YAEH;gBACE,OAAO,SAAS,CAAA;QACpB,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,0BAA0B,CACtC,cAA8B;QAE9B,QAAQ,cAAc,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACtC,KAAK,eAAe;gBAClB,OAAO,uCAAsB,CAAC,cAAc,CAC1C,cAAc,EACd,IAAI,CAAC,UAAU,CAChB,CAAA;YACH,KAAK,kBAAkB;gBACrB,OAAO,uCAAsB,CAAC,cAAc,CAC1C,cAAc,EACd,IAAI,CAAC,UAAU,CAChB,CAAA;YACH,KAAK,oBAAoB;gBACvB,OAAO,2CAA0B,CAAC,cAAc,CAC9C,cAAc,EACd,IAAI,CAAC,MAAM,CACZ,CAAA;YACH,KAAK,oBAAoB;gBACvB,OAAO,sCAAqB,CAAC,cAAc,CACzC,cAAc,EACd,IAAI,CAAC,UAAU,CAChB,CAAA;YACH;gBACE,OAAO,SAAS,CAAA;QACpB,CAAC;IACH,CAAC;CACF;AAhHD,kCAgHC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BooleanConditionOperator, type HtBooleanCondition, type HtNumberCondition, type HtStringCondition, NumberConditionOperator, StringConditionOperator } from './hubtype-fields';
|
|
2
|
+
type StringEvaluator = (variable: string, value: string) => boolean;
|
|
3
|
+
type NumberEvaluator = (variable: number, value: number, condition: HtNumberCondition) => boolean;
|
|
4
|
+
type BooleanEvaluator = (variable: boolean) => boolean;
|
|
5
|
+
export declare function getMinAndMax(condition: HtNumberCondition): {
|
|
6
|
+
min: number;
|
|
7
|
+
max: number;
|
|
8
|
+
};
|
|
9
|
+
export declare const STRING_CONDITION_EVALUATORS: Record<StringConditionOperator, StringEvaluator>;
|
|
10
|
+
export declare const NUMBER_CONDITION_EVALUATORS: Record<NumberConditionOperator, NumberEvaluator>;
|
|
11
|
+
export declare const BOOLEAN_CONDITION_EVALUATORS: Record<BooleanConditionOperator, BooleanEvaluator>;
|
|
12
|
+
export declare function evaluateStringCondition(variable: string, condition: HtStringCondition): boolean;
|
|
13
|
+
export declare function evaluateNumberCondition(variable: number, condition: HtNumberCondition): boolean;
|
|
14
|
+
export declare function evaluateBooleanCondition(variable: boolean, condition: HtBooleanCondition): boolean;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BOOLEAN_CONDITION_EVALUATORS = exports.NUMBER_CONDITION_EVALUATORS = exports.STRING_CONDITION_EVALUATORS = void 0;
|
|
4
|
+
exports.getMinAndMax = getMinAndMax;
|
|
5
|
+
exports.evaluateStringCondition = evaluateStringCondition;
|
|
6
|
+
exports.evaluateNumberCondition = evaluateNumberCondition;
|
|
7
|
+
exports.evaluateBooleanCondition = evaluateBooleanCondition;
|
|
8
|
+
const hubtype_fields_1 = require("./hubtype-fields");
|
|
9
|
+
function getMinAndMax(condition) {
|
|
10
|
+
if (condition.min !== undefined && condition.max !== undefined) {
|
|
11
|
+
return { min: condition.min, max: condition.max };
|
|
12
|
+
}
|
|
13
|
+
throw new Error(`Min or max not found for number condition ${condition.operator}`);
|
|
14
|
+
}
|
|
15
|
+
exports.STRING_CONDITION_EVALUATORS = {
|
|
16
|
+
[hubtype_fields_1.StringConditionOperator.Contains]: (variable, value) => variable.includes(value),
|
|
17
|
+
[hubtype_fields_1.StringConditionOperator.NotContains]: (variable, value) => !variable.includes(value),
|
|
18
|
+
[hubtype_fields_1.StringConditionOperator.EqualsTo]: (variable, value) => variable === value,
|
|
19
|
+
[hubtype_fields_1.StringConditionOperator.NotEqualsTo]: (variable, value) => variable !== value,
|
|
20
|
+
[hubtype_fields_1.StringConditionOperator.StartsWith]: (variable, value) => variable.startsWith(value),
|
|
21
|
+
[hubtype_fields_1.StringConditionOperator.NotStartsWith]: (variable, value) => !variable.startsWith(value),
|
|
22
|
+
[hubtype_fields_1.StringConditionOperator.EndsWith]: (variable, value) => variable.endsWith(value),
|
|
23
|
+
[hubtype_fields_1.StringConditionOperator.NotEndsWith]: (variable, value) => !variable.endsWith(value),
|
|
24
|
+
};
|
|
25
|
+
exports.NUMBER_CONDITION_EVALUATORS = {
|
|
26
|
+
[hubtype_fields_1.NumberConditionOperator.EqualsTo]: (variable, value) => variable === value,
|
|
27
|
+
[hubtype_fields_1.NumberConditionOperator.NotEqualsTo]: (variable, value) => variable !== value,
|
|
28
|
+
[hubtype_fields_1.NumberConditionOperator.GreaterThan]: (variable, value) => variable > value,
|
|
29
|
+
[hubtype_fields_1.NumberConditionOperator.LessThan]: (variable, value) => variable < value,
|
|
30
|
+
[hubtype_fields_1.NumberConditionOperator.GreaterThanOrEqualTo]: (variable, value) => variable >= value,
|
|
31
|
+
[hubtype_fields_1.NumberConditionOperator.LessThanOrEqualTo]: (variable, value) => variable <= value,
|
|
32
|
+
[hubtype_fields_1.NumberConditionOperator.Between]: (variable, _value, condition) => {
|
|
33
|
+
const { min, max } = getMinAndMax(condition);
|
|
34
|
+
return variable >= min && variable <= max;
|
|
35
|
+
},
|
|
36
|
+
[hubtype_fields_1.NumberConditionOperator.NotBetween]: (variable, _value, condition) => {
|
|
37
|
+
const { min, max } = getMinAndMax(condition);
|
|
38
|
+
return variable < min || variable > max;
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
exports.BOOLEAN_CONDITION_EVALUATORS = {
|
|
42
|
+
[hubtype_fields_1.BooleanConditionOperator.IsTruthy]: variable => !!variable,
|
|
43
|
+
};
|
|
44
|
+
function evaluateStringCondition(variable, condition) {
|
|
45
|
+
if (condition.value === undefined) {
|
|
46
|
+
throw new Error(`Value not found for string condition ${condition.operator}`);
|
|
47
|
+
}
|
|
48
|
+
const evaluator = exports.STRING_CONDITION_EVALUATORS[condition.operator];
|
|
49
|
+
if (!evaluator) {
|
|
50
|
+
throw new Error(`Invalid string condition operator ${condition.operator}`);
|
|
51
|
+
}
|
|
52
|
+
return evaluator(variable, condition.value);
|
|
53
|
+
}
|
|
54
|
+
function evaluateNumberCondition(variable, condition) {
|
|
55
|
+
if (condition.value === undefined) {
|
|
56
|
+
throw new Error(`Value not found for number condition ${condition.operator}`);
|
|
57
|
+
}
|
|
58
|
+
const evaluator = exports.NUMBER_CONDITION_EVALUATORS[condition.operator];
|
|
59
|
+
if (!evaluator) {
|
|
60
|
+
throw new Error(`Invalid number condition operator ${condition.operator}`);
|
|
61
|
+
}
|
|
62
|
+
return evaluator(variable, condition.value, condition);
|
|
63
|
+
}
|
|
64
|
+
function evaluateBooleanCondition(variable, condition) {
|
|
65
|
+
const evaluator = exports.BOOLEAN_CONDITION_EVALUATORS[condition.operator];
|
|
66
|
+
if (!evaluator) {
|
|
67
|
+
throw new Error(`Invalid boolean condition operator ${condition.operator}`);
|
|
68
|
+
}
|
|
69
|
+
return evaluator(variable);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=custom-conditional-v2-evaluators.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-conditional-v2-evaluators.js","sourceRoot":"","sources":["../../../src/content-fields/custom-conditional-v2-evaluators.ts"],"names":[],"mappings":";;;AAmBA,oCAUC;AAqDD,0DAcC;AAED,0DAcC;AAED,4DASC;AA3HD,qDAOyB;AAYzB,SAAgB,YAAY,CAAC,SAA4B;IAIvD,IAAI,SAAS,CAAC,GAAG,KAAK,SAAS,IAAI,SAAS,CAAC,GAAG,KAAK,SAAS,EAAE,CAAC;QAC/D,OAAO,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,SAAS,CAAC,GAAG,EAAE,CAAA;IACnD,CAAC;IACD,MAAM,IAAI,KAAK,CACb,6CAA6C,SAAS,CAAC,QAAQ,EAAE,CAClE,CAAA;AACH,C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ch = {
|
|
3
|
+
customResult: string;
|
|
4
|
+
target: HtNodeLink;
|
|
5
|
+
};
|
|
6
|
+
export declare function getConditionCustomResult(condition: HtCondition, variableFormat: VariableFormat): string;
|
|
7
|
+
export declare function findLastMatchingCondition<T extends HtCondition>(conditions: T[], variable: unknown, variableFormat: VariableFormat, evaluate: (variable: unknown, condition: T) => boolean): ConditionMatch | undefined;
|
|
8
|
+
export declare function resolveWithDefaultTarget(match: ConditionMatch | undefined, defaultTarget: HtNodeLink, nodeCode: string, defaultCustomResult?: string): ConditionMatch;
|