-
Notifications
You must be signed in to change notification settings - Fork 73
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
Conversation
37b491b
to
461b614
Compare
src/datasources/targeted-messaging/targeted-messaging.datasource.ts
Outdated
Show resolved
Hide resolved
// 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], | ||
}); | ||
} | ||
}, | ||
), |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
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
OutreachFileProcessor
, which dumps the data file contents to the database.ITargetedMessagingDatasource
to allow the data file processing.AwsCloudStorageApiService
(and@aws-sdk/client-s3
package) which facilitates file management through AWS S3.targetedMessaging
configuration tree.sample.json
file with randomsafe_addresses
and mock data, for testing/local development purposes.