Skip to content

Commit 4f5f140

Browse files
author
priyanshu.solanki
committed
creating boolean, number and date tags with different equality matchings
1 parent de330d8 commit 4f5f140

7 files changed

Lines changed: 766 additions & 15 deletions

File tree

apps/sim/lib/knowledge/constants.ts

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,82 @@ export const TAG_SLOT_CONFIG = {
33
slots: ['tag1', 'tag2', 'tag3', 'tag4', 'tag5', 'tag6', 'tag7'] as const,
44
maxSlots: 7,
55
},
6+
number: {
7+
slots: ['number1', 'number2', 'number3'] as const,
8+
maxSlots: 3,
9+
},
10+
date: {
11+
slots: ['date1', 'date2'] as const,
12+
maxSlots: 2,
13+
},
14+
boolean: {
15+
slots: ['boolean1', 'boolean2'] as const,
16+
maxSlots: 2,
17+
},
618
} as const
719

820
export const SUPPORTED_FIELD_TYPES = Object.keys(TAG_SLOT_CONFIG) as Array<
921
keyof typeof TAG_SLOT_CONFIG
1022
>
1123

24+
/** Text tag slots (for backwards compatibility) */
1225
export const TAG_SLOTS = TAG_SLOT_CONFIG.text.slots
1326

27+
/** All tag slots across all field types */
28+
export const ALL_TAG_SLOTS = [
29+
...TAG_SLOT_CONFIG.text.slots,
30+
...TAG_SLOT_CONFIG.number.slots,
31+
...TAG_SLOT_CONFIG.date.slots,
32+
...TAG_SLOT_CONFIG.boolean.slots,
33+
] as const
34+
1435
export const MAX_TAG_SLOTS = TAG_SLOT_CONFIG.text.maxSlots
1536

37+
/** Type for text tag slots (for backwards compatibility) */
1638
export type TagSlot = (typeof TAG_SLOTS)[number]
1739

40+
/** Type for all tag slots */
41+
export type AllTagSlot = (typeof ALL_TAG_SLOTS)[number]
42+
43+
/** Type for number tag slots */
44+
export type NumberTagSlot = (typeof TAG_SLOT_CONFIG.number.slots)[number]
45+
46+
/** Type for date tag slots */
47+
export type DateTagSlot = (typeof TAG_SLOT_CONFIG.date.slots)[number]
48+
49+
/** Type for boolean tag slots */
50+
export type BooleanTagSlot = (typeof TAG_SLOT_CONFIG.boolean.slots)[number]
51+
52+
/**
53+
* Get the available slots for a field type
54+
*/
1855
export function getSlotsForFieldType(fieldType: string): readonly string[] {
1956
const config = TAG_SLOT_CONFIG[fieldType as keyof typeof TAG_SLOT_CONFIG]
2057
if (!config) {
2158
return []
2259
}
2360
return config.slots
2461
}
62+
63+
/**
64+
* Get the field type for a tag slot
65+
*/
66+
export function getFieldTypeForSlot(tagSlot: string): keyof typeof TAG_SLOT_CONFIG | null {
67+
for (const [fieldType, config] of Object.entries(TAG_SLOT_CONFIG)) {
68+
if ((config.slots as readonly string[]).includes(tagSlot)) {
69+
return fieldType as keyof typeof TAG_SLOT_CONFIG
70+
}
71+
}
72+
return null
73+
}
74+
75+
/**
76+
* Check if a slot is valid for a given field type
77+
*/
78+
export function isValidSlotForFieldType(tagSlot: string, fieldType: string): boolean {
79+
const config = TAG_SLOT_CONFIG[fieldType as keyof typeof TAG_SLOT_CONFIG]
80+
if (!config) {
81+
return false
82+
}
83+
return (config.slots as readonly string[]).includes(tagSlot)
84+
}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './types'
2+
export * from './query-builder'

0 commit comments

Comments
 (0)