Add log export for audit logs and SCIM events
Route audit-log and SCIM-event exports through export_jobs with typed arguments, an iam BuildAndUploadExport/SendExportEmail implementation, and a concurrent export-job worker with stale recovery. Stream JSONL via page.WalkAll into S3, and expose the request flow on console, connect, MCP, and CLI. Co-authored-by: Bryan Frimin <bryan@getprobo.com> Signed-off-by: Sacha Al Himdani <sacha@probo.com>
This commit is contained in:
@@ -113,6 +113,8 @@ const (
|
||||
subjectMailingListSubscription = "%s – Confirm Your Compliance Updates Subscription"
|
||||
subjectMailingListUnsubscription = "%s – You've been unsubscribed"
|
||||
subjectMailingListUpdates = "%s – %s"
|
||||
subjectAuditLogExport = "Your audit log export is ready"
|
||||
subjectSCIMEventExport = "Your SCIM event export is ready"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -144,6 +146,8 @@ var (
|
||||
mailingListUnsubscriptionTextTemplate = texttemplate.Must(texttemplate.ParseFS(Templates, "dist/mailing-list-unsubscription.txt.tmpl"))
|
||||
mailingListUpdatesHTMLTemplate = htmltemplate.Must(htmltemplate.ParseFS(Templates, "dist/mailing-list-updates.html.tmpl"))
|
||||
mailingListUpdatesTextTemplate = texttemplate.Must(texttemplate.ParseFS(Templates, "dist/mailing-list-updates.txt.tmpl"))
|
||||
logExportHTMLTemplate = htmltemplate.Must(htmltemplate.ParseFS(Templates, "dist/log-export.html.tmpl"))
|
||||
logExportTextTemplate = texttemplate.Must(texttemplate.ParseFS(Templates, "dist/log-export.txt.tmpl"))
|
||||
)
|
||||
|
||||
func (p *Presenter) getCommonVariables() (*CommonVariables, error) {
|
||||
@@ -334,6 +338,37 @@ func (p *Presenter) RenderFrameworkExport(ctx context.Context, downloadUrl strin
|
||||
return subjectFrameworkExport, textBody, htmlBody, err
|
||||
}
|
||||
|
||||
func (p *Presenter) RenderLogExport(ctx context.Context, downloadUrl string, isSCIMEvent bool) (subject string, textBody string, htmlBody *string, err error) {
|
||||
vars, err := p.getCommonVariables()
|
||||
if err != nil {
|
||||
return "", "", nil, fmt.Errorf("cannot get common variables: %w", err)
|
||||
}
|
||||
|
||||
subject = subjectAuditLogExport
|
||||
exportLabel := "audit log"
|
||||
|
||||
if isSCIMEvent {
|
||||
subject = subjectSCIMEventExport
|
||||
exportLabel = "SCIM event"
|
||||
}
|
||||
|
||||
data := struct {
|
||||
*CommonVariables
|
||||
Subject string
|
||||
ExportLabel string
|
||||
DownloadUrl string
|
||||
}{
|
||||
CommonVariables: vars,
|
||||
Subject: subject,
|
||||
ExportLabel: exportLabel,
|
||||
DownloadUrl: downloadUrl,
|
||||
}
|
||||
|
||||
textBody, htmlBody, err = renderEmail(logExportTextTemplate, logExportHTMLTemplate, data)
|
||||
|
||||
return subject, textBody, htmlBody, err
|
||||
}
|
||||
|
||||
func (p *Presenter) RenderCompliancePortalAccess(ctx context.Context, organizationName string) (subject string, textBody string, htmlBody *string, err error) {
|
||||
vars, err := p.getCommonVariables()
|
||||
if err != nil {
|
||||
|
||||
@@ -37,6 +37,7 @@ import CompliancePortalDocumentAccessRejected from "../src/CompliancePortalDocum
|
||||
import ElectronicSignatureCertificate from "../src/ElectronicSignatureCertificate";
|
||||
import MailingListSubscription from "../src/MailingListSubscription";
|
||||
import MailingListUnsubscription from "../src/MailingListUnsubscription";
|
||||
import LogExport from "../src/LogExport";
|
||||
import MagicLink from "../src/MagicLink";
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
@@ -104,6 +105,10 @@ const templates: TemplateConfig[] = [
|
||||
name: "mailing-list-updates",
|
||||
render: () => MailingListUpdates(),
|
||||
},
|
||||
{
|
||||
name: "log-export",
|
||||
render: () => LogExport(),
|
||||
},
|
||||
];
|
||||
|
||||
async function build() {
|
||||
|
||||
41
packages/emails/src/LogExport.tsx
Normal file
41
packages/emails/src/LogExport.tsx
Normal file
@@ -0,0 +1,41 @@
|
||||
// Copyright (c) 2026 Probo Inc <hello@probo.com>.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in
|
||||
// all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
|
||||
import { Button, Section, Text } from 'react-email';
|
||||
import * as React from 'react';
|
||||
import EmailLayout, { bodyText, button, buttonContainer } from './components/EmailLayout';
|
||||
|
||||
export const LogExport = () => {
|
||||
return (
|
||||
<EmailLayout subject={'{{.Subject}}'}>
|
||||
<Text style={bodyText}>
|
||||
Your {'{{.ExportLabel}}'} export has been completed successfully. Click the button below to download it:
|
||||
</Text>
|
||||
|
||||
<Section style={buttonContainer}>
|
||||
<Button style={button} href={'{{.DownloadUrl}}'}>
|
||||
Download Export
|
||||
</Button>
|
||||
</Section>
|
||||
</EmailLayout>
|
||||
);
|
||||
};
|
||||
|
||||
export default LogExport;
|
||||
10
packages/emails/templates/log-export.txt
Normal file
10
packages/emails/templates/log-export.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
Probo
|
||||
|
||||
Hi {{.RecipientFullName}},
|
||||
|
||||
Your {{.ExportLabel}} export has been completed successfully. Click the link below to download it:
|
||||
|
||||
{{.DownloadUrl}}
|
||||
|
||||
{{.SenderCompanyHeadquarterAddress}}
|
||||
Powered By Probo
|
||||
Reference in New Issue
Block a user