From 4de7749010e1aee41378a54a5eb3fe27c05e559d Mon Sep 17 00:00:00 2001 From: Chuck B Date: Fri, 20 Dec 2024 14:09:21 -0500 Subject: [PATCH] Up level SES package; fix migration --- typescript/widget-store/README.md | 2 +- .../migrations/001_initial_schema.js | 2 +- typescript/widget-store/package-lock.json | 26 +++++++++---------- typescript/widget-store/package.json | 2 +- typescript/widget-store/src/utilities.ts | 6 ++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/typescript/widget-store/README.md b/typescript/widget-store/README.md index c44e9480..4bb4e6fc 100644 --- a/typescript/widget-store/README.md +++ b/typescript/widget-store/README.md @@ -27,7 +27,7 @@ The Server Tools section give you an opportunity to crash the app. After crashin ## Nightly Sales Reports (Optional) -As per [this blog post](https://www.dbos.dev/blog/how-to-build-cloud-cron-jobs), the DBOS Widget Store can send out nightly email sales reports, illustrating [scheduled workflows](https://docs.dbos.dev/typescript/tutorials/scheduled-workflows) and an [email library](https://www.npmjs.com/package/@dbos-inc/communicator-email-ses). +As per [this blog post](https://www.dbos.dev/blog/how-to-build-cloud-cron-jobs), the DBOS Widget Store can send out nightly email sales reports, illustrating [scheduled workflows](https://docs.dbos.dev/typescript/tutorials/scheduled-workflows) and an [email library](https://www.npmjs.com/package/@dbos-inc/dbos-email-ses). To enable the features, set up your email accounts in [SES](https://us-east-2.console.aws.amazon.com/ses/home) and then set the following environment variables before launching the widget store: diff --git a/typescript/widget-store/migrations/001_initial_schema.js b/typescript/widget-store/migrations/001_initial_schema.js index db8552c2..f4edef7d 100644 --- a/typescript/widget-store/migrations/001_initial_schema.js +++ b/typescript/widget-store/migrations/001_initial_schema.js @@ -18,6 +18,6 @@ exports.up = async function(knex) { }; exports.down = async function(knex) { - await knex.schema.dropTable('products'); await knex.schema.dropTable('orders'); + await knex.schema.dropTable('products'); }; diff --git a/typescript/widget-store/package-lock.json b/typescript/widget-store/package-lock.json index 22897d98..23096f32 100644 --- a/typescript/widget-store/package-lock.json +++ b/typescript/widget-store/package-lock.json @@ -8,7 +8,7 @@ "name": "widget-store", "version": "0.0.1", "dependencies": { - "@dbos-inc/communicator-email-ses": "^1.24.15", + "@dbos-inc/dbos-email-ses": "^1.31.13-preview.g4f38e6e769", "@dbos-inc/dbos-sdk": "^1.30.13", "liquidjs": "^10.10.1", "ts-node": "^10.9.2", @@ -685,18 +685,6 @@ "@dbos-inc/dbos-sdk": "*" } }, - "node_modules/@dbos-inc/communicator-email-ses": { - "version": "1.24.15", - "resolved": "https://registry.npmjs.org/@dbos-inc/communicator-email-ses/-/communicator-email-ses-1.24.15.tgz", - "integrity": "sha512-efIXPG7jE6104soXOdHT+KRk8bL+k0Ah1KJ59cNh20Y4SwOotfGimkr0OWSJnLUoJj1UuJT4CrKgDfZAGpmQBg==", - "dependencies": { - "@aws-sdk/client-sesv2": "^3.574.0" - }, - "peerDependencies": { - "@dbos-inc/aws-config": "*", - "@dbos-inc/dbos-sdk": "*" - } - }, "node_modules/@dbos-inc/dbos-cloud": { "version": "1.29.15", "resolved": "https://registry.npmjs.org/@dbos-inc/dbos-cloud/-/dbos-cloud-1.29.15.tgz", @@ -725,6 +713,18 @@ "dbos-cloud": "dist/cli.js" } }, + "node_modules/@dbos-inc/dbos-email-ses": { + "version": "1.31.13-preview.g4f38e6e769", + "resolved": "https://registry.npmjs.org/@dbos-inc/dbos-email-ses/-/dbos-email-ses-1.31.13-preview.g4f38e6e769.tgz", + "integrity": "sha512-UsTjMXEAkWymzdCaJ25b36VKFyuMlBC0729x8EcW1r420wRjLI9EObfzOJXMG3UIScpMuSzKGz0YvXt/WRvmCw==", + "dependencies": { + "@aws-sdk/client-sesv2": "^3.574.0" + }, + "peerDependencies": { + "@dbos-inc/aws-config": "*", + "@dbos-inc/dbos-sdk": "*" + } + }, "node_modules/@dbos-inc/dbos-sdk": { "version": "1.30.13", "resolved": "https://registry.npmjs.org/@dbos-inc/dbos-sdk/-/dbos-sdk-1.30.13.tgz", diff --git a/typescript/widget-store/package.json b/typescript/widget-store/package.json index 02acd8d5..0643f196 100644 --- a/typescript/widget-store/package.json +++ b/typescript/widget-store/package.json @@ -19,7 +19,7 @@ "typescript": "^5.3.3" }, "dependencies": { - "@dbos-inc/communicator-email-ses": "^1.24.15", + "@dbos-inc/dbos-email-ses": "^1.31.13-preview.g4f38e6e769", "@dbos-inc/dbos-sdk": "^1.30.13", "liquidjs": "^10.10.1", "ts-node": "^10.9.2", diff --git a/typescript/widget-store/src/utilities.ts b/typescript/widget-store/src/utilities.ts index 59710aa9..d1e8173f 100644 --- a/typescript/widget-store/src/utilities.ts +++ b/typescript/widget-store/src/utilities.ts @@ -1,4 +1,4 @@ -import { SendEmailStep } from '@dbos-inc/communicator-email-ses'; +import { DBOS_SES } from '@dbos-inc/dbos-email-ses'; import { SchedulerMode, DBOS} from '@dbos-inc/dbos-sdk'; export enum OrderStatus { @@ -35,7 +35,7 @@ export interface OrderWithProduct { export const PRODUCT_ID = 1; const reportSes = (process.env['REPORT_EMAIL_TO_ADDRESS'] && process.env['REPORT_EMAIL_FROM_ADDRESS']) - ? DBOS.configureInstance(SendEmailStep, 'reportSES', {awscfgname: 'aws_config'}) + ? DBOS.configureInstance(DBOS_SES, 'reportSES', {awscfgname: 'aws_config'}) : undefined; export class ShopUtilities { @@ -176,7 +176,7 @@ export class ShopUtilities { static async sendStatusEmail(yd: Date, sales: SalesSummary) { if (!reportSes) return; - await DBOS.invoke(reportSes).sendEmail({ + await reportSes.sendEmail({ to: [process.env['REPORT_EMAIL_TO_ADDRESS']!], from: process.env['REPORT_EMAIL_FROM_ADDRESS']!, subject: `Daily report for ${yd.toDateString()}`,