diff --git a/apps/api/src/chat/entities/contact.ts b/apps/api/src/chat/entities/contact.ts index 045458e..ffed9b8 100644 --- a/apps/api/src/chat/entities/contact.ts +++ b/apps/api/src/chat/entities/contact.ts @@ -31,6 +31,7 @@ export class Contact extends BaseEntity { @prop({ default: [], index: true }) tags: string[] + @Field(() => GraphQLJSONObject, { nullable: true }) @jsonProp() fields?: Record } diff --git a/apps/runner/src/utils/input.utils.ts b/apps/runner/src/utils/input.utils.ts index 117968f..346cde7 100644 --- a/apps/runner/src/utils/input.utils.ts +++ b/apps/runner/src/utils/input.utils.ts @@ -51,6 +51,13 @@ export function parseInput(input: unknown, outputs: Record { + console.log(`Unknown function ${name} called with arguments:`, args) + // You can return whatever you like here or throw an error + return null +} + /** * Replace references with their values and calculate expression * Example: @@ -60,7 +67,7 @@ export function parseInput(input: unknown, outputs: Record>): unknown { // each "[\w[\]]" group matches the allowed characters for variables, including array access (e.g. a.b[0].c) - const operatorsRegex = /[\w\s[\]]+(\.[\w\s[\]]+|\[\d+\])*/g + const operatorsRegex = /(\w+\[\w+\]|\w+)\.[\w\[\]]+(\.[\w\[\]]+)*/g const operators = [...input.matchAll(operatorsRegex)] @@ -100,6 +107,11 @@ export function calculateExpression(input: string, references: Record { + console.log(`get: ${str}`, params) + console.log(`references:`, references) + return _.get(references, `${str}[${params}]`) + }) parser.set('formatNumber', (value: number, locales?: Intl.LocalesArgument) => Number(value).toLocaleString(locales)) parser.set('lowercase', (str: string) => (str ? ('' + str).toLowerCase() : str)) parser.set('uppercase', (str: string) => (str ? ('' + str).toUpperCase() : str)) @@ -181,3 +193,7 @@ export function findOutputKeys(input: Record, key: string): string[ return matches } + +export function strToInterpolationKey(str: string): string { + return str.replace(/[^a-zA-Z0-9]/g, '_') +} diff --git a/generated/graphql.ts b/generated/graphql.ts index 3242c48..0620845 100644 --- a/generated/graphql.ts +++ b/generated/graphql.ts @@ -1060,6 +1060,7 @@ export interface Contact { createdAt: DateTime; address: string; tags?: Nullable; + fields?: Nullable; } export interface AccountCredential { @@ -1372,6 +1373,7 @@ export interface ContactDeleteResponse { createdAt?: Nullable; address?: Nullable; tags?: Nullable; + fields?: Nullable; } export interface ContactEdge { diff --git a/generated/schema.graphql b/generated/schema.graphql index 04836b1..fab6cfd 100644 --- a/generated/schema.graphql +++ b/generated/schema.graphql @@ -413,6 +413,7 @@ type Contact { createdAt: DateTime! address: String! tags: [String!] + fields: JSONObject } type AccountCredential { @@ -826,6 +827,7 @@ type ContactDeleteResponse { createdAt: DateTime address: String tags: [String!] + fields: JSONObject } type ContactEdge {