@@ -18,6 +18,13 @@ export const conditionDisplay: Record<CLM.ConditionType, string> = {
1818 [ CLM . ConditionType . GREATER_THAN_OR_EQUAL ] : '>=' ,
1919 [ CLM . ConditionType . LESS_THAN ] : '<' ,
2020 [ CLM . ConditionType . LESS_THAN_OR_EQUAL ] : '<=' ,
21+ [ CLM . ConditionType . STRING_EQUAL ] : 'Matches exactly'
22+ }
23+
24+ export const comparisonTypeDisplay : Record < CLM . ComparisonType , string > = {
25+ [ CLM . ComparisonType . NUMBER_OF_VALUES ] : 'Number of Items' ,
26+ [ CLM . ComparisonType . NUMERIC_VALUE ] : 'Numeric Value' ,
27+ [ CLM . ComparisonType . STRING ] : 'String' ,
2128}
2229
2330export const getEnumConditionName = ( entity : CLM . EntityBase , enumValue : CLM . EnumValue ) : string => {
@@ -28,6 +35,10 @@ export const getValueConditionName = (entity: CLM.EntityBase, condition: CLM.Con
2835 return `${ entity . entityName } ${ conditionDisplay [ condition . condition ] } ${ condition . value } `
2936}
3037
38+ export const getStringConditionName = ( entity : CLM . EntityBase , condition : CLM . Condition ) : string => {
39+ return `${ entity . entityName } ${ conditionDisplay [ condition . condition ] } "${ condition . stringValue } "`
40+ }
41+
3142export const convertConditionToConditionalTag = ( condition : CLM . Condition , entities : CLM . EntityBase [ ] ) : IConditionalTag => {
3243 const entity = entities . find ( e => e . entityId === condition . entityId )
3344 if ( ! entity ) {
@@ -57,7 +68,9 @@ export const convertConditionToConditionalTag = (condition: CLM.Condition, entit
5768 }
5869 }
5970 else {
60- const name = getValueConditionName ( entity , condition )
71+ const name = condition . value
72+ ? getValueConditionName ( entity , condition )
73+ : getStringConditionName ( entity , condition )
6174 const key = CLM . hashText ( name )
6275 conditionalTag = {
6376 key,
@@ -94,6 +107,22 @@ export const findNumberFromMemory = (memory: CLM.Memory, isMultivalue: boolean):
94107 : undefined
95108}
96109
110+ /**
111+ * Given memory value,
112+ * return the userText field of the given memory value, if it exists, or undefined otherwise.
113+ */
114+ export const findStringFromMemory = ( memory : CLM . Memory ) : string | undefined => {
115+ return ( memory ?. entityValues ?. [ 0 ] ?. userText ) ?? undefined
116+ }
117+
118+
119+ export const isStringConditionTrue = ( condition : CLM . Condition , stringValue : string | undefined ) : boolean => {
120+ if ( condition . stringValue ) {
121+ return condition . condition == CLM . ConditionType . STRING_EQUAL && stringValue === condition . stringValue
122+ }
123+ return false
124+ }
125+
97126export const isValueConditionTrue = ( condition : CLM . Condition , numberValue : number ) : boolean => {
98127 let isTrue = false
99128
0 commit comments