import { ISSUE_UPDATE_ACTIVITY_METADATA_KEYS, LOW_SIGNAL_ISSUE_UPDATE_ACTIVITY_FIELDS, } from "@rudderhq/shared";
import { sql } from "drizzle-orm";
const LOW_SIGNAL_ISSUE_UPDATE_ALLOWED_KEYS = [
    ...LOW_SIGNAL_ISSUE_UPDATE_ACTIVITY_FIELDS,
    ...ISSUE_UPDATE_ACTIVITY_METADATA_KEYS,
];
export function issueLowSignalContentOnlyActivitySql(alias) {
    const lowSignalFieldPresent = sql.join(LOW_SIGNAL_ISSUE_UPDATE_ACTIVITY_FIELDS.map((key) => sql `${sql.raw(`${alias}.details`)} ? ${key}`), sql ` or `);
    return sql `(
    ${sql.raw(`${alias}.action`)} = 'issue.updated'
    and jsonb_typeof(${sql.raw(`${alias}.details`)}) = 'object'
    and (${lowSignalFieldPresent})
    and not exists (
      select 1
      from jsonb_object_keys(${sql.raw(`${alias}.details`)}) as detail_key(key)
      where detail_key.key not in (${sql.join(LOW_SIGNAL_ISSUE_UPDATE_ALLOWED_KEYS.map((key) => sql `${key}`), sql `, `)})
    )
  )`;
}
export function issueMaterialUpdateActivitySql(alias) {
    return sql `(
    ${sql.raw(`${alias}.action`)} = 'issue.updated'
    and jsonb_typeof(${sql.raw(`${alias}.details`)}) = 'object'
    and exists (
      select 1
      from jsonb_object_keys(${sql.raw(`${alias}.details`)}) as detail_key(key)
      where detail_key.key not in (${sql.join(LOW_SIGNAL_ISSUE_UPDATE_ALLOWED_KEYS.map((key) => sql `${key}`), sql `, `)})
    )
  )`;
}
//# sourceMappingURL=issue-activity-filters.js.map