Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Parse Targeted Messaging data files #2033

Merged
merged 10 commits into from
Oct 22, 2024
Merged

Conversation

hectorgomezv
Copy link
Member

@hectorgomezv hectorgomezv commented Oct 18, 2024

Summary

This PR introduces the functionality for parsing Targeted Messaging data files. These data files should be JSON files, and the source could be either Cloud Storage or Local Storage.

Changes

  • Adds OutreachFileProcessor, which dumps the data file contents to the database.
  • Add additional methods to ITargetedMessagingDatasource to allow the data file processing.
  • Adds AwsCloudStorageApiService (and @aws-sdk/client-s3 package) which facilitates file management through AWS S3.
  • Adds targetedMessaging configuration tree.
  • Adds a sample.json file with random safe_addresses and mock data, for testing/local development purposes.

@hectorgomezv hectorgomezv self-assigned this Oct 18, 2024
@hectorgomezv hectorgomezv linked an issue Oct 18, 2024 that may be closed by this pull request
@hectorgomezv hectorgomezv force-pushed the parse-outreach-definition-files branch from 37b491b to 461b614 Compare October 18, 2024 14:45
@hectorgomezv hectorgomezv marked this pull request as ready for review October 18, 2024 16:48
@hectorgomezv hectorgomezv requested a review from a team as a code owner October 18, 2024 16:48
@hectorgomezv hectorgomezv requested a review from iamacook October 21, 2024 14:30
Comment on lines +40 to +56
// Check for AWS_* fields in production and staging environments
['AWS_ACCESS_KEY_ID', 'AWS_SECRET_ACCESS_KEY', 'AWS_REGION'].forEach(
(field) => {
if (
config.CGW_ENV &&
config instanceof Object &&
['production', 'staging'].includes(config.CGW_ENV) &&
!(config as Record<string, unknown>)[field]
) {
ctx.addIssue({
code: z.ZodIssueCode.custom,
message: `is required in production and staging environments`,
path: [field],
});
}
},
),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to superRefine this? We could just remove optional() from the respective property.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought it would be nice to avoid enforcing these on the env.sample file and in the local development environments, as we have a local FileStorageType, the need to set those AWS_* env variables when the local FileStorageType is selected would be a bit weird IMO.

Using this superRefine approach, we could even apply it to other environment variables, to stop requiring placeholders in development environments and simplify the safe-infrastrastructure repository management. Wdyt? (Of course, I'd tackle that in a separate PR if you agree).

src/datasources/storage/aws-cloud-storage-api.service.ts Outdated Show resolved Hide resolved
@hectorgomezv hectorgomezv merged commit a26289b into main Oct 22, 2024
20 checks passed
@hectorgomezv hectorgomezv deleted the parse-outreach-definition-files branch October 22, 2024 15:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Targeted Messaging] Parse Outreach definition files
2 participants