Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.
TypeScript acmeagentsai-agentscertificate-managementdevsecopsenvironment-variableskubernetesopen-sourcepampkipostgresprivate-caprivileged-access-managementsecret-managementsecret-managersecretssecrets-managementsecuritysecurity-toolsvault
feat: add job to send monthly email for users regarding deprecating native integrations
adilsonfc8bce943c54
diff --git a/backend/src/keystore/keystore.ts b/backend/src/keystore/keystore.tsindex 709e435365..6c8a2b531b 100644--- a/backend/src/keystore/keystore.ts+++ b/backend/src/keystore/keystore.ts@@ -165,7 +165,11 @@ export const KeyStorePrefixes = {TelemetryEventByBucketPattern: (event: string, bucketId: string) => `telemetry-event-${event}-${bucketId}-*` as const,AuditLogStreamFlushDebounce: (streamId: string) => `audit-log-stream:${streamId}:flush-debounce` as const,- AuditLogIngestConsumerLock: "audit-log-ingest:consumer-lock" as const+ AuditLogIngestConsumerLock: "audit-log-ingest:consumer-lock" as const,++ // period is a YYYY-MM stamp so the monthly notice can only go out once per org per month+ NativeIntegrationDeprecationNotice: (orgId: string, period: string) =>+ `native-integration-deprecation-notice:${orgId}:${period}` as const};export const KeyStoreTtls = {@@ -213,7 +217,8 @@ export const KeyStoreTtls = {SecretEtagInSeconds: 900, // 15 minutesPkiAcmeNonceInSeconds: 300, // 5 minutesGatewayRelayCredentialInSeconds: 600, // 10 minutes - TURN credential lifetime- SecretReplicationSuccessInSeconds: 10+ SecretReplicationSuccessInSeconds: 10,+ NativeIntegrationDeprecationNoticeInSeconds: 3888000 // 45 days - outlives one monthly cycle};type TDeleteItems = {diff --git a/backend/src/lib/cron/cron-job.ts b/backend/src/lib/cron/cron-job.tsindex 72d2faa26c..6261f941f7 100644--- a/backend/src/lib/cron/cron-job.ts+++ b/backend/src/lib/cron/cron-job.ts@@ -43,7 +43,8 @@ export const CronJobName = {AuditLogStreamOutboxCleanup: "audit-log-stream-outbox-cleanup",LicenseUsageFlush: "license-usage-flush",PamCredentialRotationQueueRotations: "pam-credential-rotation-queue-rotations",- InstanceUpdateCheck: "instance-update-check"+ InstanceUpdateCheck: "instance-update-check",+ MonthlyNativeIntegrationDeprecationNotice: "monthly-native-integration-deprecation-notice"} as const;// ── tuning constants ──────────────────────────────────────────────────────────diff --git a/backend/src/queue/queue-service.ts b/backend/src/queue/queue-service.tsindex 022287a3d3..40454f525c 100644--- a/backend/src/queue/queue-service.ts+++ b/backend/src/queue/queue-service.ts@@ -115,7 +115,8 @@ export enum QueueName {ProjectEnvHardDelete = "project-env-hard-delete",SignerAutoRenewal = "signer-auto-renewal",SecretBlindIndexMigration = "secret-blind-index-migration",- UsageEvent = "usage-event"+ UsageEvent = "usage-event",+ IntegrationDeprecationNotice = "integration-deprecation-notice"}export enum QueueJobs {@@ -194,7 +195,8 @@ export enum QueueJobs {ProjectEnvHardDelete = "project-env-hard-delete-job",SignerDailyAutoRenewal = "signer-daily-auto-renewal",SecretBlindIndexMigration = "secret-blind-index-migration",- UsageEvent = "usage-event-job"+ UsageEvent = "usage-event-job",+ SendIntegrationDeprecationNotice = "send-integration-deprecation-notice"}export enum JobState {@@ -561,6 +563,11 @@ export type TQueueJobTypes = {name: QueueJobs.UsageEvent;payload: { orgId: string; dimensionKey: string };};+ [QueueName.IntegrationDeprecationNotice]: {+ name: QueueJobs.SendIntegrationDeprecationNotice;+ // period is a YYYY-MM stamp computed once by the cron tick so every retry of the same fire is deduped alike+ payload: { orgId: string; period: string };+ };};const SECRET_SCANNING_QUEUES = [diff --git a/backend/src/server/routes/index.ts b/backend/src/server/routes/index.tsindex 5fde1d340c..7a5c113ae5 100644--- a/backend/src/server/routes/index.ts+++ b/backend/src/server/routes/index.ts@@ -374,6 +374,7 @@ import { identityV2DALFactory } from "@app/services/identity-v2/identity-dal";import { identityMembershipV2DALFactory } from "@app/services/identity-v2/identity-membership-dal";import { identityV2ServiceFactory } from "@app/services/identity-v2/identity-service";import { integrationDALFactory } from "@app/services/integration/integration-dal";+import { integrationDeprecationQueueFactory } from "@app/services/integration/integration-deprecation-queue";import { integrationServiceFactory } from "@app/services/integration/integration-service";import { integrationAuthDALFactory } from "@app/services/integration-auth/integration-auth-dal";import { integrationAuthServiceFactory } from "@app/services/integration-auth/integration-auth-service";@@ -2837,6 +2838,17 @@ export const registerRoutes = async (cronJob});+ const integrationDeprecationQueue = integrationDeprecationQueueFactory({+ integrationDAL,+ orgDAL,+ projectMembershipDAL,+ smtpService,+ notificationService,+ keyStore,+ queueService,+ cronJob+ });+const dailyExpiringPkiItemAlert = dailyExpiringPkiItemAlertQueueServiceFactory({cronJob,pkiAlertService@@ -3872,6 +3884,7 @@ export const registerRoutes = async (certificateAuthorityQueue.startCaCrlRebuildJob();pkiSubscriberQueue.startDailyAutoRenewalJob();pkiAlertV2Queue.init();+ integrationDeprecationQueue.init();certificateCleanupQueue.init();certificateV3Queue.init();digicertCaQueue.init();diff --git a/backend/src/services/integration/integration-dal.ts b/backend/src/services/integration/integration-dal.tsindex 6a66b5bf66..c25f94065d 100644--- a/backend/src/services/integration/integration-dal.ts+++ b/backend/src/services/integration/integration-dal.ts@@ -204,5 +204,70 @@ export const integrationDALFactory = (db: TDbClient) => {);};- return { ...integrationOrm, find, findOne, findById, findByProjectId, findByProjectIdV2 };+ // native integrations are deprecated in favour of secret syncs — the three helpers below back the monthly+ // deprecation notice, which enumerates every org still holding one.+ // filters Environment.deleteAfter AND Project.deleteAfter: an environment soft-delete does not imply a+ // project soft-delete, so a cross-project enumeration has to exclude both independently.+ const liveOrgIntegrationQuery = (conn: Knex) =>+ conn(TableName.Integration)+ .join(TableName.Environment, `${TableName.Integration}.envId`, `${TableName.Environment}.id`)+ .join(TableName.Project, `${TableName.Environment}.projectId`, `${TableName.Project}.id`)+ .whereNull(`${TableName.Environment}.deleteAfter`)+ .whereNull(`${TableName.Project}.deleteAfter`);++ const findOrgIdsWithIntegrations = async (tx?: Knex) => {+ try {+ const orgIds = await liveOrgIntegrationQuery(tx || db.replicaNode())+ .distinct(db.ref("orgId").withSchema(TableName.Project))+ .pluck<string[]>(`${TableName.Project}.orgId`);++ return orgIds;+ } catch (error) {+ throw new DatabaseError({ error, name: "FindOrgIdsWithIntegrations" });+ }+ };++ const findProjectIntegrationsByOrgId = async (orgId: string, tx?: Knex) => {+ try {+ const docs = await liveOrgIntegrationQuery(tx || db.replicaNode())+ .where(`${TableName.Project}.orgId`, orgId)+ .select(+ db.ref("id").withSchema(TableName.Project).as("projectId"),+ db.ref("name").withSchema(TableName.Project).as("projectName"),+ db.ref("integration").withSchema(TableName.Integration)+ )+ .orderBy(`${TableName.Project}.name` as "name");++ return docs;+ } catch (error) {+ throw new DatabaseError({ error, name: "FindProjectIntegrationsByOrgId" });+ }+ };++ const hasIntegrationsByOrgId = async (orgId: string, tx?: Knex): Promise<boolean> => {+ try {+ // primary, not the replica: this check exists to catch an integration deleted moments ago, so reading a+ // possibly stale replica would defeat its purpose+ const doc = await liveOrgIntegrationQuery(tx || db)+ .where(`${TableName.Project}.orgId`, orgId)+ .select(db.ref("id").withSchema(TableName.Integration))+ .first();++ return Boolean(doc);+ } catch (error) {+ throw new DatabaseError({ error, name: "HasIntegrationsByOrgId" });+ }+ };++ return {+ ...integrationOrm,+ find,+ findOne,+ findById,+ findByProjectId,+ findByProjectIdV2,+ findOrgIdsWithIntegrations,+ findProjectIntegrationsByOrgId,+ hasIntegrationsByOrgId+ };};diff --git a/backend/src/services/integration/integration-deprecation-fns.ts b/backend/src/services/integration/integration-deprecation-fns.tsnew file mode 100644index 0000000000..1437c504fc--- /dev/null+++ b/backend/src/services/integration/integration-deprecation-fns.ts@@ -0,0 +1,54 @@+import { groupBy, unique } from "@app/lib/fn";++export type TIntegrationProjectRow = {+ projectId: string;+ projectName: string;+ integration: string;+};++export type TIntegrationProjectSummary = {+ projectId: string;+ projectName: string;+ integrations: string[];+};++export type TNoticeRecipient = {+ userId: string;+ email: string;+};++/**+ * Collapses the flat (project x integration) rows from the DAL into one entry per project, resolving each+ * integration slug to its display name. Slugs with no matching option fall back to the raw slug so a newly+ * added integration never renders as a blank line.+ */+export const groupIntegrationsByProject = (+ rows: TIntegrationProjectRow[],+ integrationNameBySlug: Map<string, string>+): TIntegrationProjectSummary[] =>+ Object.values(groupBy(rows, (row) => row.projectId)).map((projectRows) => ({+ projectId: projectRows[0].projectId,+ projectName: projectRows[0].projectName,+ integrations: unique(+ projectRows.map(({ integration }) => integrationNameBySlug.get(integration) ?? integration)+ ).sort()+ }));++/**+ * Deep link to a project's native integrations tab — same URL the integration sync failure email builds.+ */+export const buildNativeIntegrationsUrl = (siteUrl: string, orgId: string, projectId: string) =>+ `${siteUrl}/organizations/${orgId}/projects/secret-management/${projectId}/integrations?selectedTab=native-integrations`;++/**+ * Turns membership rows into mailable recipients: drops members with no email, anyone already reached by another+ * email in the same run (project admins who are also org admins), and duplicate memberships for the same user.+ */+export const toRecipients = (+ members: { userId: string; email?: string | null }[],+ excludedUserIds: Set<string> = new Set()+): TNoticeRecipient[] =>+ unique(+ members.filter((member) => member.email && !excludedUserIds.has(member.userId)),+ (member) => member.userId+ ).map(({ userId, email }) => ({ userId, email: email as string }));diff --git a/backend/src/services/integration/integration-deprecation-queue.ts b/backend/src/services/integration/integration-deprecation-queue.tsnew file mode 100644index 0000000000..27efb3d066--- /dev/null+++ b/backend/src/services/integration/integration-deprecation-queue.ts@@ -0,0 +1,236 @@+import { OrgMembershipRole, OrgMembershipStatus, ProjectMembershipRole } from "@app/db/schemas";+import { KeyStorePrefixes, KeyStoreTtls, TKeyStoreFactory } from "@app/keystore/keystore";+import { getConfig } from "@app/lib/config/env";+import { CronJobName, TCronJobFactory } from "@app/lib/cron/cron-job";+import { groupBy } from "@app/lib/fn";+import { logger } from "@app/lib/logger";+import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";+import { getIntegrationOptions } from "@app/services/integration-auth/integration-list";+import { TNotificationServiceFactory } from "@app/services/notification/notification-service";+import { NotificationType } from "@app/services/notification/notification-types";+import { TOrgDALFactory } from "@app/services/org/org-dal";+import { TProjectMembershipDALFactory } from "@app/services/project-membership/project-membership-dal";+import { SmtpTemplates, TSmtpService } from "@app/services/smtp/smtp-service";++import { TIntegrationDALFactory } from "./integration-dal";+import {+ buildNativeIntegrationsUrl,+ groupIntegrationsByProject,+ TIntegrationProjectSummary,+ TNoticeRecipient,+ toRecipients+} from "./integration-deprecation-fns";++type TIntegrationDeprecationQueueFactoryDep = {+ integrationDAL: Pick<+ TIntegrationDALFactory,+ "findOrgIdsWithIntegrations" | "findProjectIntegrationsByOrgId" | "hasIntegrationsByOrgId"+ >;+ orgDAL: Pick<TOrgDALFactory, "findOrgMembersByRole" | "findById">;+ projectMembershipDAL: Pick<TProjectMembershipDALFactory, "findProjectMembersByProjectIds">;+ smtpService: Pick<TSmtpService, "sendMail">;+ notificationService: Pick<TNotificationServiceFactory, "createUserNotifications">;+ keyStore: Pick<TKeyStoreFactory, "setItemWithExpiryNX">;+ queueService: TQueueServiceFactory;+ cronJob: TCronJobFactory;+};++export type TIntegrationDeprecationQueueFactory = ReturnType<typeof integrationDeprecationQueueFactory>;++const NOTICE_SUBJECT = "Action recommended: native integrations are moving to Secret Syncs";+const NOTICE_BODY =+ "Native integrations are deprecated. Secret Syncs are the maintained replacement and cover the same third-party services.";++/**+ * Monthly nudge toward Secret Syncs for every org still holding native integrations.+ *+ * The cron tick only enumerates orgs and fans out one BullMQ job each; the worker does the mail. An org drops out+ * of the notice on its own as soon as it has migrated off native integrations.+ */+export const integrationDeprecationQueueFactory = ({+ integrationDAL,+ orgDAL,+ projectMembershipDAL,+ smtpService,+ notificationService,+ keyStore,+ queueService,+ cronJob+}: TIntegrationDeprecationQueueFactoryDep) => {+ const sendNotice = async ({+ orgId,+ orgName,+ projects,+ recipients,+ siteUrl,+ link+ }: {+ orgId: string;+ orgName: string;+ projects: TIntegrationProjectSummary[];+ recipients: TNoticeRecipient[];+ siteUrl: string;+ link?: string;+ }) => {+ if (!recipients.length || !projects.length) return;++ // the worker can run long after the tick enqueued this job, and the caller sends several notices in+ // sequence — re-check per notice so an org that migrated in the meantime stops hearing about it+ if (!(await integrationDAL.hasIntegrationsByOrgId(orgId))) {+ logger.info(`integrationDeprecationNotice: org no longer has native integrations, skipping [orgId=${orgId}]`);+ return;+ }++ try {+ await smtpService.sendMail({+ template: SmtpTemplates.NativeIntegrationDeprecation,+ subjectLine: NOTICE_SUBJECT,+ recipients: recipients.map((recipient) => recipient.email),+ substitutions: {+ orgName,+ projects: projects.map((project) => ({+ name: project.projectName,+ integrations: project.integrations,+ url: buildNativeIntegrationsUrl(siteUrl, orgId, project.projectId)+ }))+ }+ });+ } catch (error) {+ logger.error(error, `integrationDeprecationNotice: failed to send email [orgId=${orgId}]`);+ }++ try {+ await notificationService.createUserNotifications(+ recipients.map((recipient) => ({+ userId: recipient.userId,+ orgId,+ type: NotificationType.NATIVE_INTEGRATION_DEPRECATED,+ title: "Native integrations are moving to Secret Syncs",+ body: NOTICE_BODY,+ link+ }))+ );+ } catch (error) {+ logger.error(error, `integrationDeprecationNotice: failed to create notifications [orgId=${orgId}]`);+ }+ };++ const sendOrgNotices = async ({ orgId, period }: { orgId: string; period: string }) => {+ const appCfg = getConfig();+ if (!appCfg.SITE_URL) return;++ // set before sending: for a recurring nudge a missed month is cheaper than a duplicate blast to every admin+ const claimed = await keyStore.setItemWithExpiryNX(+ KeyStorePrefixes.NativeIntegrationDeprecationNotice(orgId, period),+ KeyStoreTtls.NativeIntegrationDeprecationNoticeInSeconds,+ "1"+ );+ if (!claimed) {+ logger.info(`integrationDeprecationNotice: already notified [orgId=${orgId}] [period=${period}]`);+ return;+ }++ const rows = await integrationDAL.findProjectIntegrationsByOrgId(orgId);+ if (!rows.length) return;++ const integrationOptions = await getIntegrationOptions();+ const integrationNameBySlug = new Map(integrationOptions.map((option) => [option.slug, option.name]));+ const projects = groupIntegrationsByProject(rows, integrationNameBySlug);++ const org = await orgDAL.findById(orgId);+ if (!org) return;++ const [orgAdmins, projectAdmins] = await Promise.all([+ // findOrgMembersByRole includes members who were invited but never accepted+ orgDAL.findOrgMembersByRole(orgId, OrgMembershipRole.Admin),+ projectMembershipDAL.findProjectMembersByProjectIds(+ projects.map((project) => project.projectId),+ { roles: [ProjectMembershipRole.Admin], orgId }+ )+ ]);++ const orgAdminRecipients = toRecipients(+ orgAdmins+ .filter((admin) => admin.status !== OrgMembershipStatus.Invited)+ .map((admin) => ({ userId: admin.user.id, email: admin.user.email }))+ );+ const orgAdminUserIds = new Set(orgAdminRecipients.map((recipient) => recipient.userId));+ // scope=project rows always carry a projectId; the ! only satisfies the nullable column type+ const projectAdminsByProjectId = groupBy(projectAdmins, (member) => member.projectId!);++ // every recipient list is resolved above; from here on it is only sending+ const { SITE_URL: siteUrl } = appCfg;+ const notify = (recipients: TNoticeRecipient[], noticeProjects: TIntegrationProjectSummary[], link?: string) =>+ sendNotice({ orgId, orgName: org.name, siteUrl, recipients, projects: noticeProjects, link });++ // org admins get one notice covering every affected project; a deep link only makes sense when there is a+ // single project to point at+ await notify(+ orgAdminRecipients,+ projects,+ projects.length === 1 ? buildNativeIntegrationsUrl(siteUrl, orgId, projects[0].projectId) : undefined+ );++ // then each project's admins get a notice scoped to their own project, minus anyone already reached above+ for await (const project of projects) {+ await notify(+ toRecipients(projectAdminsByProjectId[project.projectId] ?? [], orgAdminUserIds),+ [project],+ buildNativeIntegrationsUrl(siteUrl, orgId, project.projectId)+ );+ }++ logger.info(+ `integrationDeprecationNotice: notices sent [orgId=${orgId}] [period=${period}] [projectCount=${projects.length}]`+ );+ };++ const init = () => {+ const appCfg = getConfig();++ cronJob.register({+ name: CronJobName.MonthlyNativeIntegrationDeprecationNotice,+ pattern: "0 0 1 * *",+ runHashTtlS: 7 * 24 * 60 * 60,+ enabled: !appCfg.isSecondaryInstance,+ handler: async () => {+ if (!appCfg.SITE_URL) {+ logger.info("cron[monthly-native-integration-deprecation-notice]: skipped, SITE_URL is not configured");+ return;+ }++ // YYYY-MM (UTC) — scopes the per-org idempotency key so retries of this fire dedupe against each other+ const period = new Date().toISOString().slice(0, 7);+ const orgIds = await integrationDAL.findOrgIdsWithIntegrations();++ logger.info(+ `cron[monthly-native-integration-deprecation-notice]: enqueuing [orgCount=${orgIds.length}] [period=${period}]`+ );++ for await (const orgId of orgIds) {+ await queueService.queue(+ QueueName.IntegrationDeprecationNotice,+ QueueJobs.SendIntegrationDeprecationNotice,+ { orgId, period },+ {+ jobId: `integration-deprecation-notice-${orgId}-${period}`,+ removeOnComplete: true,+ removeOnFail: true+ }+ );+ }+ }+ });++ queueService.start(+ QueueName.IntegrationDeprecationNotice,+ async (job) => {+ await sendOrgNotices(job.data);+ },+ // caps how many orgs are processed at once; each job then sends its own notices sequentially+ { concurrency: 5, limiter: { max: 20, duration: 1000 } }+ );+ };++ return { init };+};diff --git a/backend/src/services/notification/notification-types.ts b/backend/src/services/notification/notification-types.tsindex ad347a7231..80146793f8 100644--- a/backend/src/services/notification/notification-types.ts+++ b/backend/src/services/notification/notification-types.ts@@ -22,7 +22,8 @@ export enum NotificationType {APPROVAL_REQUIRED = "approval-required",PKI_ALERT_CHANNEL_FAILED = "pki-alert-channel-failed",CREDENTIAL_ROTATION_FAILED = "credential-rotation-failed",- AUDIT_LOG_MIGRATION_RECOMMENDED = "audit-log-migration-recommended"+ AUDIT_LOG_MIGRATION_RECOMMENDED = "audit-log-migration-recommended",+ NATIVE_INTEGRATION_DEPRECATED = "native-integration-deprecated"}export interface TCreateUserNotificationDTO {diff --git a/backend/src/services/project-membership/project-membership-dal.ts b/backend/src/services/project-membership/project-membership-dal.tsindex 79d8325fc8..dfbb5fad46 100644--- a/backend/src/services/project-membership/project-membership-dal.ts+++ b/backend/src/services/project-membership/project-membership-dal.ts@@ -8,6 +8,21 @@ import { selectAllTableCols, sqlNestRelationships } from "@app/lib/knex";export type TProjectMembershipDALFactory = ReturnType<typeof projectMembershipDALFactory>;export const projectMembershipDALFactory = (db: TDbClient) => {+ // matches memberships holding any of the given roles, by built-in role name or custom role slug. Shared so the+ // single-project and batch lookups can never disagree about who holds a role.+ const whereHasAnyRole = (qb: Knex.QueryBuilder, roles: string[]) => {+ void qb.whereExists((subQuery) => {+ void subQuery+ .select("role")+ .from(TableName.MembershipRole)+ .leftJoin(TableName.Role, `${TableName.Role}.id`, `${TableName.MembershipRole}.customRoleId`)+ .whereRaw("??.?? = ??.??", [TableName.MembershipRole, "membershipId", TableName.Membership, "id"])+ .where((subQb) => {+ void subQb.whereIn(`${TableName.MembershipRole}.role`, roles).orWhereIn(`${TableName.Role}.slug`, roles);+ });+ });+ };+// special queryconst findAllProjectMembers = async (projectId: string,@@ -37,18 +52,7 @@ export const projectMembershipDALFactory = (db: TDbClient) => {void qb.where(`${TableName.Membership}.id`, filter.id);}if (filter.roles && filter.roles.length > 0) {- void qb.whereExists((subQuery) => {- void subQuery- .select("role")- .from(TableName.MembershipRole)- .leftJoin(TableName.Role, `${TableName.Role}.id`, `${TableName.MembershipRole}.customRoleId`)- .whereRaw("??.?? = ??.??", [TableName.MembershipRole, "membershipId", TableName.Membership, "id"])- .where((subQb) => {- void subQb- .whereIn(`${TableName.MembershipRole}.role`, filter.roles as string[])- .orWhereIn(`${TableName.Role}.slug`, filter.roles as string[]);- });- });+ whereHasAnyRole(qb, filter.roles);}}).join(TableName.MembershipRole, `${TableName.MembershipRole}.membershipId`, `${TableName.Membership}.id`)@@ -157,6 +161,41 @@ export const projectMembershipDALFactory = (db: TDbClient) => {}};+ const findProjectMembersByProjectIds = async (+ projectIds: string[],+ filter: { roles?: string[]; orgId?: string } = {}+ ) => {+ if (projectIds.length === 0) return [];++ try {+ const docs = await db+ .replicaNode()(TableName.Membership)+ .whereIn(`${TableName.Membership}.scopeProjectId`, projectIds)+ .where({ [`${TableName.Membership}.scope` as "scope"]: AccessScope.Project })+ .whereNotNull(`${TableName.Membership}.actorUserId`)+ .join(TableName.Project, `${TableName.Membership}.scopeProjectId`, `${TableName.Project}.id`)+ .join(TableName.Users, `${TableName.Membership}.actorUserId`, `${TableName.Users}.id`)+ .where({ isGhost: false })+ .where((qb) => {+ if (filter.orgId) {+ void qb.where(`${TableName.Project}.orgId`, filter.orgId);+ }+ if (filter.roles && filter.roles.length > 0) {+ whereHasAnyRole(qb, filter.roles);+ }+ })+ .select(+ db.ref("scopeProjectId").withSchema(TableName.Membership).as("projectId"),+ db.ref("id").withSchema(TableName.Users).as("userId"),+ db.ref("email").withSchema(TableName.Users)+ );++ return docs;+ } catch (error) {+ throw new DatabaseError({ error, name: "Find project members by project ids" });+ }+ };+const findProjectGhostUser = async (projectId: string, tx?: Knex) => {try {const ghostUser = await (tx || db.replicaNode())(TableName.Membership)@@ -425,6 +464,7 @@ export const projectMembershipDALFactory = (db: TDbClient) => {return {findAllProjectMembers,+ findProjectMembersByProjectIds,findProjectGhostUser,findMembershipsByUsername,findProjectMembershipsByUserId,diff --git a/backend/src/services/smtp/emails/NativeIntegrationDeprecationTemplate.tsx b/backend/src/services/smtp/emails/NativeIntegrationDeprecationTemplate.tsxnew file mode 100644index 0000000000..9ca1c77ae4--- /dev/null+++ b/backend/src/services/smtp/emails/NativeIntegrationDeprecationTemplate.tsx@@ -0,0 +1,99 @@+import { Heading, Section, Text } from "@react-email/components";++import { BaseButton } from "./BaseButton";+import { BaseEmailWrapper, BaseEmailWrapperProps } from "./BaseEmailWrapper";+import { BaseLink } from "./BaseLink";++const BENEFITS = [+ "Continuous, automatic syncing with no manual re-runs",+ "Reusable App Connections shared across syncs",+ "Actively maintained and supported"+];++interface NativeIntegrationDeprecationTemplateProps+ extends Omit<BaseEmailWrapperProps, "title" | "preview" | "children"> {+ orgName: string;+ // a single entry for the per-project email, every affected project for the org-wide email+ projects: { name: string; integrations: string[]; url: string }[];+}++export const NativeIntegrationDeprecationTemplate = ({+ siteUrl,+ orgName,+ projects+}: NativeIntegrationDeprecationTemplateProps) => {+ const isSingleProject = projects.length === 1;++ return (+ <BaseEmailWrapper+ title="Native Integrations Are Moving to Secret Syncs"+ preview="Native integrations are deprecated. Secret Syncs are the maintained replacement."+ siteUrl={siteUrl}+ >+ <Heading className="text-black text-[18px] leading-[28px] text-center font-normal p-0 mx-0">+ <strong>Native Integrations Are Moving to Secret Syncs</strong>+ </Heading>+ <Section className="px-[24px] mb-[28px] mt-[36px] pt-[12px] pb-[8px] border border-solid border-gray-200 rounded-md bg-gray-50">+ <Text className="text-black text-[14px] leading-[24px]">+ {isSingleProject ? (+ <>+ The <strong>{projects[0].name}</strong> project in <strong>{orgName}</strong> still uses native+ integrations.+ </>+ ) : (+ <>+ <strong>{projects.length}</strong> projects in <strong>{orgName}</strong> still use native integrations.+ </>+ )}{" "}+ Native integrations are deprecated. Secret Syncs are the maintained replacement and cover the same third-party+ services, so we recommend migrating.+ </Text>+ {BENEFITS.map((benefit) => (+ <Text key={benefit} className="text-black text-[14px] leading-[20px] my-[4px]">+ • {benefit}+ </Text>+ ))}+ </Section>+ <Section className="mb-[28px]">+ <Text className="text-[14px] font-semibold mb-[12px]">+ {isSingleProject ? "Integrations to migrate" : "Projects using native integrations"}+ </Text>+ {projects.map((project) => (+ <Section+ key={project.name}+ className="mb-[16px] p-[16px] border border-solid border-gray-200 rounded-md bg-gray-50"+ >+ <Text className="text-[14px] font-semibold m-0 mb-[4px]">+ <BaseLink href={project.url}>{project.name}</BaseLink>+ </Text>+ <Text className="text-[12px] text-gray-600 m-0">{project.integrations.join(", ")}</Text>+ </Section>+ ))}+ </Section>+ <Section className="text-center">+ <BaseButton href="https://infisical.com/docs/integrations/secret-syncs/overview">+ Explore Secret Syncs+ </BaseButton>+ </Section>+ </BaseEmailWrapper>+ );+};++export default NativeIntegrationDeprecationTemplate;++NativeIntegrationDeprecationTemplate.PreviewProps = {+ siteUrl: "https://infisical.com",+ orgName: "Example Organization",+ projects: [+ {+ name: "backend-api",+ integrations: ["GitHub", "AWS Parameter Store", "Vercel"],+ url: "https://infisical.com"+ },+ {+ name: "web-app",+ integrations: ["Netlify", "Cloudflare Pages"],+ url: "https://infisical.com"+ }+ ]+} as NativeIntegrationDeprecationTemplateProps;diff --git a/backend/src/services/smtp/emails/index.ts b/backend/src/services/smtp/emails/index.tsindex 08c62104b2..1f0e3a9d89 100644--- a/backend/src/services/smtp/emails/index.ts+++ b/backend/src/services/smtp/emails/index.ts@@ -17,6 +17,7 @@ export * from "./HealthAlertTemplate";export * from "./HoneyTokenTriggeredTemplate";export * from "./IntegrationSyncFailedTemplate";export * from "./MfaRecoveryCodeUsedTemplate";+export * from "./NativeIntegrationDeprecationTemplate";export * from "./NewDeviceLoginTemplate";export * from "./OAuthPasswordResetTemplate";export * from "./OrgAdminBreakglassAccessTemplate";diff --git a/backend/src/services/smtp/smtp-service.ts b/backend/src/services/smtp/smtp-service.tsindex 08e806d4de..03c63fbd2f 100644--- a/backend/src/services/smtp/smtp-service.ts+++ b/backend/src/services/smtp/smtp-service.ts@@ -27,6 +27,7 @@ import {HoneyTokenTriggeredTemplate,IntegrationSyncFailedTemplate,MfaRecoveryCodeUsedTemplate,+ NativeIntegrationDeprecationTemplate,NewDeviceLoginTemplate,OAuthPasswordResetTemplate,OrgAdminBreakglassAccessTemplate,@@ -92,6 +93,7 @@ export enum SmtpTemplates {SecretApprovalRequestNeedsReview = "secretApprovalRequestNeedsReview",// HistoricalSecretList = "historicalSecretLeakIncident", not used anymore?NewDeviceJoin = "newDevice",+ NativeIntegrationDeprecation = "nativeIntegrationDeprecation",OrgInvite = "organizationInvitation",SubOrgInvite = "subOrganizationInvitation",OrgAssignment = "organizationAssignment",@@ -140,6 +142,7 @@ const EmailTemplateMap: Record<SmtpTemplates, React.FC<any>> = {[SmtpTemplates.SubOrgInvite]: SubOrganizationInvitationTemplate,[SmtpTemplates.OrgAssignment]: OrganizationAssignmentTemplate,[SmtpTemplates.NewDeviceJoin]: NewDeviceLoginTemplate,+ [SmtpTemplates.NativeIntegrationDeprecation]: NativeIntegrationDeprecationTemplate,[SmtpTemplates.SignupEmailVerification]: SignupEmailVerificationTemplate,[SmtpTemplates.SignupExistingAccount]: SignupExistingAccountTemplate,[SmtpTemplates.EmailMfa]: EmailMfaTemplate,