qstd 0.3.22 → 0.3.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Creates a plain text fallback from HTML email content.
3
+ *
4
+ * SES emails are sent as multipart/alternative with both HTML and text bodies.
5
+ * The text version is needed because some email clients don't render HTML
6
+ * (accessibility settings, security restrictions, older clients), and many
7
+ * clients show the plain text in inbox previews and notifications. Including
8
+ * both versions also improves deliverability/spam scores.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * stripHtml("<p>Hello <strong>world</strong></p>");
13
+ * // Returns: "Hello world"
14
+ * ```
15
+ */
16
+ export declare const stripHtml: (html: string) => string;
17
+ //# sourceMappingURL=fns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fns.d.ts","sourceRoot":"","sources":["../../../../src/server/aws/ses/fns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,SAAS,GAAI,MAAM,MAAM,KAAG,MAU9B,CAAC"}
@@ -0,0 +1,21 @@
1
+ import { SESClient } from "@aws-sdk/client-ses";
2
+ import * as _t from "./types";
3
+ export type * from "./types";
4
+ export declare const create: () => SESClient;
5
+ /**
6
+ * phone notifications: `<fromName> <subject>`
7
+ *
8
+ * email: `<fromName> <subject>`
9
+ *
10
+ * email opened:
11
+ *
12
+ * `<subject>` (as email title)
13
+ *
14
+ * From `<fromName> <from>`
15
+ *
16
+ * To `<to>`
17
+ *
18
+ * `<content>`
19
+ */
20
+ export declare const send: (ses: SESClient, email: _t.Email) => Promise<import("@aws-sdk/client-ses").SendEmailCommandOutput>;
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/server/aws/ses/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAoB,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAG9B,mBAAmB,SAAS,CAAC;AAE7B,eAAO,MAAM,MAAM,iBAAoD,CAAC;AAExE;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,IAAI,GAAI,KAAK,SAAS,EAAE,OAAO,EAAE,CAAC,KAAK,kEAsBnD,CAAC"}
@@ -0,0 +1,4 @@
1
+ export type Email = Record<"fromName" | "from" | "subject" | "content" | "to", string> & {
2
+ textContent?: string;
3
+ };
4
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/server/aws/ses/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,KAAK,GAAG,MAAM,CACxB,UAAU,GAAG,MAAM,GAAG,SAAS,GAAG,SAAS,GAAG,IAAI,EAClD,MAAM,CACP,GAAG;IAAE,WAAW,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
@@ -7,6 +7,7 @@ var libDynamodb = require('@aws-sdk/lib-dynamodb');
7
7
  var clientDynamodb = require('@aws-sdk/client-dynamodb');
8
8
  var clientSns = require('@aws-sdk/client-sns');
9
9
  var clientSqs = require('@aws-sdk/client-sqs');
10
+ var clientSes = require('@aws-sdk/client-ses');
10
11
  var clientS3 = require('@aws-sdk/client-s3');
11
12
  var s3RequestPresigner = require('@aws-sdk/s3-request-presigner');
12
13
  var s3PresignedPost = require('@aws-sdk/s3-presigned-post');
@@ -1427,11 +1428,43 @@ var send = (sqs, props) => sqs.client.send(
1427
1428
  })
1428
1429
  );
1429
1430
 
1431
+ // src/server/aws/ses/index.ts
1432
+ var ses_exports = {};
1433
+ __export(ses_exports, {
1434
+ create: () => create5,
1435
+ send: () => send2
1436
+ });
1437
+
1438
+ // src/server/aws/ses/fns.ts
1439
+ var stripHtml = (html) => html.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<[^>]+>/g, " ").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/\s+/g, " ").trim();
1440
+
1441
+ // src/server/aws/ses/index.ts
1442
+ var create5 = () => new clientSes.SESClient({ apiVersion: "2010-12-01" });
1443
+ var send2 = (ses, email) => {
1444
+ const Source = `"${email.fromName}" <${email.from}>`;
1445
+ console.log(`[ses] Sending email to ${email.to} from ${email.from}`);
1446
+ const Destination = { ToAddresses: [email.to] };
1447
+ const Body = {
1448
+ Html: { Charset: "UTF-8", Data: email.content },
1449
+ Text: {
1450
+ Charset: "UTF-8",
1451
+ Data: email.textContent || stripHtml(email.content)
1452
+ }
1453
+ };
1454
+ const Subject = { Charset: "UTF-8", Data: email.subject };
1455
+ const command = new clientSes.SendEmailCommand({
1456
+ Message: { Subject, Body },
1457
+ Destination,
1458
+ Source
1459
+ });
1460
+ return ses.send(command);
1461
+ };
1462
+
1430
1463
  // src/server/aws/s3/index.ts
1431
1464
  var s3_exports = {};
1432
1465
  __export(s3_exports, {
1433
1466
  bucketHandle: () => bucketHandle,
1434
- create: () => create5,
1467
+ create: () => create6,
1435
1468
  createSignedUrl: () => createSignedUrl,
1436
1469
  deleteFile: () => deleteFile,
1437
1470
  getFile: () => getFile,
@@ -1452,7 +1485,7 @@ var getBucketNameOrThrow = (...candidates) => {
1452
1485
  };
1453
1486
 
1454
1487
  // src/server/aws/s3/domain.ts
1455
- var create5 = (props = {}) => {
1488
+ var create6 = (props = {}) => {
1456
1489
  const { cdn } = props;
1457
1490
  const client = new clientS3.S3Client({});
1458
1491
  const bucketName = getBucketNameOrThrow(props.bucketName);
@@ -1611,6 +1644,7 @@ exports.Log = log_exports;
1611
1644
  exports.Money = money_exports;
1612
1645
  exports.Random = random_exports;
1613
1646
  exports.S3 = s3_exports;
1647
+ exports.SES = ses_exports;
1614
1648
  exports.SNS = sns_exports;
1615
1649
  exports.SQS = sqs_exports;
1616
1650
  exports.Str = str_exports;
@@ -12,5 +12,6 @@ export * as Lambda from "./aws/lambda";
12
12
  export * as DDB from "./aws/ddb";
13
13
  export * as SNS from "./aws/sns";
14
14
  export * as SQS from "./aws/sqs";
15
+ export * as SES from "./aws/ses";
15
16
  export * as S3 from "./aws/s3";
16
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAGrC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,iBAAiB,CAAC;AACzC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,IAAI,MAAM,gBAAgB,CAAC;AACvC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAC3C,OAAO,KAAK,GAAG,MAAM,eAAe,CAAC;AAGrC,OAAO,KAAK,IAAI,MAAM,QAAQ,CAAC;AAC/B,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,GAAG,MAAM,WAAW,CAAC;AACjC,OAAO,KAAK,EAAE,MAAM,UAAU,CAAC"}
@@ -5,6 +5,7 @@ import { DynamoDBDocumentClient, ScanCommand, QueryCommand, DeleteCommand, PutCo
5
5
  import { DynamoDBClient, DeleteTableCommand, DescribeTableCommand, DynamoDBServiceException } from '@aws-sdk/client-dynamodb';
6
6
  import { SNSClient, PublishCommand } from '@aws-sdk/client-sns';
7
7
  import { SQSClient, SendMessageCommand } from '@aws-sdk/client-sqs';
8
+ import { SESClient, SendEmailCommand } from '@aws-sdk/client-ses';
8
9
  import { S3Client, GetObjectCommand, PutObjectCommand, DeleteObjectCommand, HeadObjectCommand, CreateBucketCommand, DeleteBucketCommand, HeadBucketCommand, ListObjectsV2Command, CopyObjectCommand } from '@aws-sdk/client-s3';
9
10
  import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
10
11
  import { createPresignedPost } from '@aws-sdk/s3-presigned-post';
@@ -1425,11 +1426,43 @@ var send = (sqs, props) => sqs.client.send(
1425
1426
  })
1426
1427
  );
1427
1428
 
1429
+ // src/server/aws/ses/index.ts
1430
+ var ses_exports = {};
1431
+ __export(ses_exports, {
1432
+ create: () => create5,
1433
+ send: () => send2
1434
+ });
1435
+
1436
+ // src/server/aws/ses/fns.ts
1437
+ var stripHtml = (html) => html.replace(/<style[^>]*>[\s\S]*?<\/style>/gi, "").replace(/<script[^>]*>[\s\S]*?<\/script>/gi, "").replace(/<[^>]+>/g, " ").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/\s+/g, " ").trim();
1438
+
1439
+ // src/server/aws/ses/index.ts
1440
+ var create5 = () => new SESClient({ apiVersion: "2010-12-01" });
1441
+ var send2 = (ses, email) => {
1442
+ const Source = `"${email.fromName}" <${email.from}>`;
1443
+ console.log(`[ses] Sending email to ${email.to} from ${email.from}`);
1444
+ const Destination = { ToAddresses: [email.to] };
1445
+ const Body = {
1446
+ Html: { Charset: "UTF-8", Data: email.content },
1447
+ Text: {
1448
+ Charset: "UTF-8",
1449
+ Data: email.textContent || stripHtml(email.content)
1450
+ }
1451
+ };
1452
+ const Subject = { Charset: "UTF-8", Data: email.subject };
1453
+ const command = new SendEmailCommand({
1454
+ Message: { Subject, Body },
1455
+ Destination,
1456
+ Source
1457
+ });
1458
+ return ses.send(command);
1459
+ };
1460
+
1428
1461
  // src/server/aws/s3/index.ts
1429
1462
  var s3_exports = {};
1430
1463
  __export(s3_exports, {
1431
1464
  bucketHandle: () => bucketHandle,
1432
- create: () => create5,
1465
+ create: () => create6,
1433
1466
  createSignedUrl: () => createSignedUrl,
1434
1467
  deleteFile: () => deleteFile,
1435
1468
  getFile: () => getFile,
@@ -1450,7 +1483,7 @@ var getBucketNameOrThrow = (...candidates) => {
1450
1483
  };
1451
1484
 
1452
1485
  // src/server/aws/s3/domain.ts
1453
- var create5 = (props = {}) => {
1486
+ var create6 = (props = {}) => {
1454
1487
  const { cdn } = props;
1455
1488
  const client = new S3Client({});
1456
1489
  const bucketName = getBucketNameOrThrow(props.bucketName);
@@ -1598,4 +1631,4 @@ var recordsFromSqs = (body) => {
1598
1631
  }
1599
1632
  };
1600
1633
 
1601
- export { ddb_exports as DDB, dict_exports as Dict, file_exports as File, flow_exports as Flow, int_exports as Int, lambda_exports as Lambda, list_exports as List, log_exports as Log, money_exports as Money, random_exports as Random, s3_exports as S3, sns_exports as SNS, sqs_exports as SQS, str_exports as Str, time_exports as Time };
1634
+ export { ddb_exports as DDB, dict_exports as Dict, file_exports as File, flow_exports as Flow, int_exports as Int, lambda_exports as Lambda, list_exports as List, log_exports as Log, money_exports as Money, random_exports as Random, s3_exports as S3, ses_exports as SES, sns_exports as SNS, sqs_exports as SQS, str_exports as Str, time_exports as Time };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "qstd",
3
- "version": "0.3.22",
3
+ "version": "0.3.24",
4
4
  "description": "Standard Block component and utilities library with Panda CSS",
5
5
  "author": "malin1",
6
6
  "license": "MIT",
@@ -49,6 +49,7 @@
49
49
  "dependencies": {
50
50
  "@aws-sdk/client-dynamodb": "latest",
51
51
  "@aws-sdk/client-s3": "latest",
52
+ "@aws-sdk/client-ses": "latest",
52
53
  "@aws-sdk/client-sns": "latest",
53
54
  "@aws-sdk/client-sqs": "latest",
54
55
  "@aws-sdk/lib-dynamodb": "latest",