stacks 0.58.59 → 0.58.61

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.
Files changed (136) hide show
  1. package/core/actions/dist/src/clean.js +2 -2
  2. package/core/actions/dist/src/lint/fix.js +4 -1
  3. package/core/actions/dist/src/upgrade.js +10 -7
  4. package/core/actions/package.json +1 -1
  5. package/core/actions/src/action.ts +18 -8
  6. package/core/actions/src/clean.ts +2 -2
  7. package/core/actions/src/dev/api.ts +1 -2
  8. package/core/actions/src/domains/add.ts +12 -27
  9. package/core/actions/src/lint/fix.ts +6 -1
  10. package/core/actions/src/migrate/dns.ts +1 -1
  11. package/core/actions/src/upgrade.ts +5 -2
  12. package/core/ai/package.json +2 -2
  13. package/core/alias/package.json +4 -4
  14. package/core/analytics/package.json +1 -1
  15. package/core/api/package.json +4 -4
  16. package/core/arrays/package.json +4 -4
  17. package/core/auth/package.json +1 -1
  18. package/core/buddy/dist/{chunk-7b24d1e3e585766e.js → chunk-6658b07ce4c24cac.js} +62 -1
  19. package/core/buddy/dist/cli.js +1 -1
  20. package/core/buddy/dist/index.js +1 -1
  21. package/core/buddy/package.json +1 -1
  22. package/core/buddy/src/commands/build.ts +25 -25
  23. package/core/buddy/src/commands/deploy.ts +1 -1
  24. package/core/buddy/src/commands/dev.ts +33 -34
  25. package/core/buddy/src/commands/upgrade.ts +23 -24
  26. package/core/build/package.json +1 -1
  27. package/core/bun-create/bud/package.json +1 -1
  28. package/core/bun-create/buddy/package.json +1 -1
  29. package/core/bun-create/stack/package.json +1 -1
  30. package/core/bun-create/stacks/package.json +1 -1
  31. package/core/bun-create/stx/package.json +1 -1
  32. package/core/bun-create/tmp.json +0 -0
  33. package/core/bun-plugin-yaml/package.json +4 -4
  34. package/core/cache/package.json +4 -4
  35. package/core/chat/package.json +10 -10
  36. package/core/cli/dist/index.js +27 -20
  37. package/core/cli/package.json +1 -1
  38. package/core/cli/src/console.ts +18 -18
  39. package/core/cli/src/exec.ts +9 -6
  40. package/core/cli/src/parse.ts +3 -3
  41. package/core/cloud/dist/index.js +2 -2
  42. package/core/cloud/package.json +2 -2
  43. package/core/cloud/src/cloud/aws-sdk-layer/nodejs/package.json +1 -1
  44. package/core/cloud/src/cloud/dashboard.ts +86 -85
  45. package/core/cloud/src/cloud/docs.ts +2 -2
  46. package/core/cloud/src/cloud/router-layer/nodejs/package.json +2 -2
  47. package/core/cloud/zip.ts +1 -1
  48. package/core/collections/package.json +2 -2
  49. package/core/collections/tmp.json +0 -0
  50. package/core/config/dist/index.js +3 -3
  51. package/core/config/package.json +1 -1
  52. package/core/config/src/defaults.ts +4 -2
  53. package/core/database/package.json +1 -1
  54. package/core/database/src/kysely-bun-worker/worker.ts +0 -1
  55. package/core/datetime/package.json +1 -1
  56. package/core/desktop/package.json +1 -1
  57. package/core/development/package.json +1 -1
  58. package/core/dns/package.json +13 -13
  59. package/core/docs/package.json +1 -1
  60. package/core/email/package.json +2 -1
  61. package/core/email/src/server/converter.ts +19 -19
  62. package/core/email/src/server/inbound.ts +24 -8
  63. package/core/email/src/server/outbound.ts +17 -17
  64. package/core/enums/package.json +1 -1
  65. package/core/env/dist/index.js +1 -1
  66. package/core/env/package.json +4 -4
  67. package/core/env/tmp.json +0 -0
  68. package/core/error-handling/package.json +1 -1
  69. package/core/eslint-config/build.ts +1 -1
  70. package/core/eslint-config/package.json +3 -1
  71. package/core/eslint-config/test/cli.spec.ts +2 -1
  72. package/core/eslint-config/tsconfig.json +2 -2
  73. package/core/events/package.json +1 -1
  74. package/core/faker/package.json +1 -1
  75. package/core/git/package.json +1 -1
  76. package/core/health/package.json +1 -1
  77. package/core/http/package.json +1 -1
  78. package/core/lint/package.json +1 -1
  79. package/core/logging/build.ts +1 -1
  80. package/core/logging/dist/index.js +13 -11043
  81. package/core/logging/package.json +5 -5
  82. package/core/notifications/package.json +1 -1
  83. package/core/objects/package.json +1 -1
  84. package/core/orm/package.json +8 -8
  85. package/core/path/dist/index.js +5 -0
  86. package/core/path/package.json +3 -3
  87. package/core/path/src/index.ts +5 -0
  88. package/core/path/tmp.json +0 -0
  89. package/core/payments/package.json +1 -1
  90. package/core/push/package.json +1 -1
  91. package/core/query-builder/package.json +1 -1
  92. package/core/queue/package.json +2 -2
  93. package/core/queue/tmp.json +0 -0
  94. package/core/raycast/package.json +1 -1
  95. package/core/raycast/tmp.json +0 -0
  96. package/core/realtime/package.json +1 -1
  97. package/core/repl/package.json +4 -4
  98. package/core/router/dist/index.js +4 -0
  99. package/core/router/package.json +1 -1
  100. package/core/scheduler/package.json +3 -2
  101. package/core/scheduler/tests/cron.test.ts +11 -9
  102. package/core/search-engine/package.json +1 -1
  103. package/core/security/package.json +9 -9
  104. package/core/server/package.json +1 -1
  105. package/core/signals/package.json +1 -1
  106. package/core/slug/package.json +1 -1
  107. package/core/sms/package.json +11 -11
  108. package/core/storage/package.json +13 -13
  109. package/core/strings/package.json +1 -1
  110. package/core/tables/package.json +6 -6
  111. package/core/testing/package.json +6 -4
  112. package/core/tinker/package.json +4 -4
  113. package/core/tunnel/package.json +1 -1
  114. package/core/types/package.json +1 -1
  115. package/core/types/src/app.ts +1 -1
  116. package/core/types/src/docs.ts +3 -3
  117. package/core/types/src/team.ts +1 -1
  118. package/core/ui/package.json +2 -2
  119. package/core/utils/dist/index.js +15 -13
  120. package/core/utils/package.json +21 -21
  121. package/core/utils/src/clean.ts +3 -3
  122. package/core/utils/src/hash.ts +9 -9
  123. package/core/validation/package.json +7 -7
  124. package/core/vite/dist/index.js +1 -1
  125. package/core/vite/package.json +1 -1
  126. package/core/vite/src/example-wc.ts +1 -4
  127. package/core/vite/src/plugin/auto-imports.ts +1 -2
  128. package/core/vite/src/plugin/components.ts +1 -2
  129. package/core/vite/src/plugin/docs.ts +1 -1
  130. package/core/whois/package.json +4 -4
  131. package/core/x-ray/package.json +4 -4
  132. package/core/zsh-buddy/package.json +3 -3
  133. package/ide/vscode/package.json +3 -4
  134. package/package.json +1 -1
  135. package/core/cloud/cdk.json +0 -62
  136. package/core/cloud/deploy.ts +0 -85
@@ -1,85 +1,86 @@
1
- /* eslint-disable no-new */
2
- // TODO: finish this cloudwatch dashboard
3
- // import type { aws_lambda as lambda } from 'aws-cdk-lib'
4
- import { Aws, CfnOutput as Output, aws_cloudwatch as cloudwatch } from 'aws-cdk-lib'
5
- import type { Construct } from 'constructs'
6
- import type { NestedCloudProps } from '../types'
7
-
8
- export interface DashboardStackProps extends NestedCloudProps {
9
- dashboardName?: string
10
- }
11
-
12
- export class DashboardStack {
13
- // lambdaFunction: lambda.Function
14
- dashboard: cloudwatch.Dashboard
15
-
16
- constructor(scope: Construct, props: DashboardStackProps) {
17
- const dashboardName = props.dashboardName || 'StacksDashboard'
18
-
19
- // Create Sample Lambda Function which will create metrics
20
- // this.lambdaFunction = new Function(this, 'SampleLambda', {
21
- // handler: 'lambda-handler.handler',
22
- // runtime: Runtime.PYTHON_3_7,
23
- // code: new AssetCode(`./lambda`),
24
- // memorySize: 512,
25
- // timeout: Duration.seconds(10),
26
- // })
27
-
28
- // Create CloudWatch Dashboard
29
- this.dashboard = new cloudwatch.Dashboard(scope, 'SampleLambdaDashboard', {
30
- dashboardName,
31
- })
32
-
33
- // Create Title for Dashboard
34
- this.dashboard.addWidgets(new cloudwatch.TextWidget({
35
- markdown: `# Dashboard: ${this.lambdaFunction.functionName}`,
36
- height: 1,
37
- width: 24,
38
- }))
39
-
40
- // Create CloudWatch Dashboard Widgets: Errors, Invocations, Duration, Throttles
41
- this.dashboard.addWidgets(new cloudwatch.GraphWidget({
42
- title: 'Invocations',
43
- left: [this.lambdaFunction.metricInvocations()],
44
- width: 24,
45
- }))
46
-
47
- this.dashboard.addWidgets(new cloudwatch.GraphWidget({
48
- title: 'Errors',
49
- left: [this.lambdaFunction.metricErrors()],
50
- width: 24,
51
- }))
52
-
53
- this.dashboard.addWidgets(new cloudwatch.GraphWidget({
54
- title: 'Duration',
55
- left: [this.lambdaFunction.metricDuration()],
56
- width: 24,
57
- }))
58
-
59
- this.dashboard.addWidgets(new cloudwatch.GraphWidget({
60
- title: 'Throttles',
61
- left: [this.lambdaFunction.metricThrottles()],
62
- width: 24,
63
- }))
64
-
65
- // Create Widget to show last 20 Log Entries
66
- this.dashboard.addWidgets(new cloudwatch.LogQueryWidget({
67
- logGroupNames: [this.lambdaFunction.logGroup.logGroupName],
68
- queryLines: [
69
- 'fields @timestamp, @message',
70
- 'sort @timestamp desc',
71
- 'limit 20',
72
- ],
73
- width: 24,
74
- }))
75
-
76
- // Generate Output
77
- const cloudwatchDashboardURL = `https://${Aws.REGION}.console.aws.amazon.com/cloudwatch/home?region=${Aws.REGION}#dashboards:name=${dashboardName}`
78
-
79
- new Output(scope, 'DashboardOutput', {
80
- value: cloudwatchDashboardURL,
81
- description: 'The CloudWatch Dashboard URL',
82
- exportName: 'StacksDashboardURL',
83
- })
84
- }
85
- }
1
+ // /* eslint-disable no-new */
2
+ // // TODO: finish this cloudwatch dashboard
3
+ // // import type { aws_lambda as lambda } from 'aws-cdk-lib'
4
+ // import { Aws, CfnOutput as Output, aws_cloudwatch as cloudwatch } from 'aws-cdk-lib'
5
+ // import type { Construct } from 'constructs'
6
+ // import type { NestedCloudProps } from '../types'
7
+ //
8
+ // export interface DashboardStackProps extends NestedCloudProps {
9
+ // dashboardName?: string
10
+ // }
11
+ //
12
+ // export class DashboardStack {
13
+ // // lambdaFunction: lambda.Function
14
+ // dashboard: cloudwatch.Dashboard
15
+ //
16
+ // constructor(scope: Construct, props: DashboardStackProps) {
17
+ // const dashboardName = props.dashboardName || 'StacksDashboard'
18
+ //
19
+ // // Create Sample Lambda Function which will create metrics
20
+ // // this.lambdaFunction = new Function(this, 'SampleLambda', {
21
+ // // handler: 'lambda-handler.handler',
22
+ // // runtime: Runtime.PYTHON_3_7,
23
+ // // code: new AssetCode(`./lambda`),
24
+ // // memorySize: 512,
25
+ // // timeout: Duration.seconds(10),
26
+ // // })
27
+ //
28
+ // // Create CloudWatch Dashboard
29
+ // this.dashboard = new cloudwatch.Dashboard(scope, 'SampleLambdaDashboard', {
30
+ // dashboardName,
31
+ // })
32
+ //
33
+ // // Create Title for Dashboard
34
+ // this.dashboard.addWidgets(new cloudwatch.TextWidget({
35
+ // markdown: `# Dashboard: `,
36
+ // // markdown: `# Dashboard: ${this.lambdaFunction.functionName}`,
37
+ // height: 1,
38
+ // width: 24,
39
+ // }))
40
+ //
41
+ // // Create CloudWatch Dashboard Widgets: Errors, Invocations, Duration, Throttles
42
+ // this.dashboard.addWidgets(new cloudwatch.GraphWidget({
43
+ // title: 'Invocations',
44
+ // left: [this.lambdaFunction.metricInvocations()],
45
+ // width: 24,
46
+ // }))
47
+ //
48
+ // this.dashboard.addWidgets(new cloudwatch.GraphWidget({
49
+ // title: 'Errors',
50
+ // left: [this.lambdaFunction.metricErrors()],
51
+ // width: 24,
52
+ // }))
53
+ //
54
+ // this.dashboard.addWidgets(new cloudwatch.GraphWidget({
55
+ // title: 'Duration',
56
+ // left: [this.lambdaFunction.metricDuration()],
57
+ // width: 24,
58
+ // }))
59
+ //
60
+ // this.dashboard.addWidgets(new cloudwatch.GraphWidget({
61
+ // title: 'Throttles',
62
+ // left: [this.lambdaFunction.metricThrottles()],
63
+ // width: 24,
64
+ // }))
65
+ //
66
+ // // Create Widget to show last 20 Log Entries
67
+ // this.dashboard.addWidgets(new cloudwatch.LogQueryWidget({
68
+ // logGroupNames: [this.lambdaFunction.logGroup.logGroupName],
69
+ // queryLines: [
70
+ // 'fields @timestamp, @message',
71
+ // 'sort @timestamp desc',
72
+ // 'limit 20',
73
+ // ],
74
+ // width: 24,
75
+ // }))
76
+ //
77
+ // // Generate Output
78
+ // const cloudwatchDashboardURL = `https://${Aws.REGION}.console.aws.amazon.com/cloudwatch/home?region=${Aws.REGION}#dashboards:name=${dashboardName}`
79
+ //
80
+ // new Output(scope, 'DashboardOutput', {
81
+ // value: cloudwatchDashboardURL,
82
+ // description: 'The CloudWatch Dashboard URL',
83
+ // exportName: 'StacksDashboardURL',
84
+ // })
85
+ // }
86
+ // }
@@ -28,8 +28,8 @@ export class DocsStack {
28
28
  description: 'The Stacks Origin Request function that prettifies URLs',
29
29
  runtime: lambda.Runtime.NODEJS_18_X,
30
30
  handler: 'dist/origin-request.handler',
31
- code: lambda.Code.fromAsset(p.corePath('cloud/dist.zip'), {
32
- assetHash: originRequestFunctionHash,
31
+ code: lambda.Code.fromAsset(p.frameworkCloudPath('dist.zip'), {
32
+ assetHash: originRequestFunctionHash(),
33
33
  assetHashType: AssetHashType.CUSTOM,
34
34
  }),
35
35
  })
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "stacks-router-layer",
3
- "version": "0.58.59",
3
+ "version": "0.58.61",
4
4
  "description": "",
5
5
  "author": "",
6
6
  "license": "MIT",
@@ -10,6 +10,6 @@
10
10
  "test": "echo \"Error: no test specified\" && exit 1"
11
11
  },
12
12
  "dependencies": {
13
- "@stacksjs/router": "^0.58.58"
13
+ "@stacksjs/router": "^0.58.59"
14
14
  }
15
15
  }
package/core/cloud/zip.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { log, runCommand } from '@stacksjs/cli'
2
2
 
3
- const result = await runCommand('zip -r dist.zip dist/origin-request.js package.json', {
3
+ const result = await runCommand('zip -r ../../cloud/dist.zip dist/origin-request.js package.json', {
4
4
  cwd: import.meta.dir,
5
5
  })
6
6
 
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/collections",
3
3
  "type": "module",
4
- "version": "0.58.59",
4
+ "version": "0.58.61",
5
5
  "description": "The Stacks collections.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -53,6 +53,6 @@
53
53
  "collect.js": "^4.36.1"
54
54
  },
55
55
  "devDependencies": {
56
- "@stacksjs/development": "workspace:*"
56
+ "@stacksjs/development": "latest"
57
57
  }
58
58
  }
File without changes
@@ -657,9 +657,9 @@ var defaults_default = {
657
657
  },
658
658
  team: {
659
659
  name: "Stacks",
660
- members: [{
660
+ members: {
661
661
  "Chris Breuer": "chris@stacksjs.org"
662
- }]
662
+ }
663
663
  },
664
664
  ui: {
665
665
  shortcuts: [
@@ -707,7 +707,7 @@ import {env as env2} from "@stacksjs/env";
707
707
  var app_default = {
708
708
  name: env2.APP_NAME || "Stacks",
709
709
  description: "Stacks is a full-stack framework for building modern web applications.",
710
- env: env2.APP_ENV || "development",
710
+ env: env2.APP_ENV || "local",
711
711
  url: env2.APP_URL || "stacks.localhost",
712
712
  redirectUrls: ["stacksjs.com"],
713
713
  debug: env2.DEBUG || false,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/config",
3
3
  "type": "module",
4
- "version": "0.58.59",
4
+ "version": "0.58.61",
5
5
  "description": "The Stacks config helper methods.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -433,16 +433,18 @@ export default {
433
433
 
434
434
  team: {
435
435
  name: 'Stacks',
436
- members: [{
436
+ members: {
437
437
  'Chris Breuer': 'chris@stacksjs.org',
438
- }],
438
+ },
439
439
  },
440
440
 
441
441
  ui: {
442
442
  shortcuts: [
443
443
  ['btn', 'inline-flex items-center px-4 py-2 ml-2 border border-transparent shadow-sm text-base font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 cursor-pointer'],
444
444
  ],
445
+
445
446
  safelist: 'prose prose-sm m-auto text-left',
447
+
446
448
  trigger: ':stx:',
447
449
  classPrefix: 'stx-',
448
450
  reset: 'tailwind',
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/database",
3
3
  "type": "module",
4
- "version": "0.58.59",
4
+ "version": "0.58.61",
5
5
  "description": "The Stacks database integration.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -25,7 +25,6 @@ function run(mode: RunMode, sql: string, parameters?: readonly unknown[]): Query
25
25
  }
26
26
  }
27
27
 
28
- // @ts-expect-error bun worker
29
28
  onmessage = ({ data }: MessageEvent<MainMsg>) => {
30
29
  const ret: WorkerMsg = {
31
30
  type: data.type,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/datetime",
3
3
  "type": "module",
4
- "version": "0.58.59",
4
+ "version": "0.58.61",
5
5
  "description": "The Stacks datetime helpers.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/desktop",
3
3
  "type": "module",
4
- "version": "0.58.59",
4
+ "version": "0.58.61",
5
5
  "description": "The Stacks Desktop engine.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/development",
3
3
  "type": "module",
4
- "version": "0.58.59",
4
+ "version": "0.58.61",
5
5
  "description": "The Stacks development dependencies.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/dns",
3
3
  "type": "module",
4
- "version": "0.58.59",
4
+ "version": "0.58.61",
5
5
  "description": "Easily manage your DNS.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -53,25 +53,25 @@
53
53
  "peerDependencies": {
54
54
  "@aws-sdk/client-route-53": "^3.511.0",
55
55
  "@aws-sdk/client-route-53-domains": "^3.511.0",
56
- "@stacksjs/actions": "workspace:*",
57
- "@stacksjs/error-handling": "workspace:*",
58
- "@stacksjs/path": "workspace:*",
59
- "@stacksjs/storage": "workspace:*",
60
- "@stacksjs/whois": "workspace:*",
56
+ "@stacksjs/actions": "latest",
57
+ "@stacksjs/error-handling": "latest",
58
+ "@stacksjs/path": "latest",
59
+ "@stacksjs/storage": "latest",
60
+ "@stacksjs/whois": "latest",
61
61
  "aws-cdk-lib": "^2.127.0"
62
62
  },
63
63
  "dependencies": {
64
64
  "@aws-sdk/client-route-53": "^3.511.0",
65
- "@stacksjs/actions": "workspace:*",
66
- "@stacksjs/error-handling": "workspace:*",
67
- "@stacksjs/path": "workspace:*",
68
- "@stacksjs/storage": "workspace:*",
69
- "@stacksjs/strings": "workspace:*",
70
- "@stacksjs/whois": "workspace:*",
65
+ "@stacksjs/actions": "latest",
66
+ "@stacksjs/error-handling": "latest",
67
+ "@stacksjs/path": "latest",
68
+ "@stacksjs/storage": "latest",
69
+ "@stacksjs/strings": "latest",
70
+ "@stacksjs/whois": "latest",
71
71
  "aws-cdk-lib": "^2.127.0"
72
72
  },
73
73
  "devDependencies": {
74
- "@stacksjs/development": "workspace:*",
74
+ "@stacksjs/development": "latest",
75
75
  "aws-cdk-lib": "^2.127.0"
76
76
  }
77
77
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/docs",
3
3
  "type": "module",
4
- "version": "0.58.59",
4
+ "version": "0.58.61",
5
5
  "description": "The Stacks way to document.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stacksjs/email",
3
3
  "type": "module",
4
- "version": "0.58.59",
4
+ "version": "0.58.61",
5
5
  "description": "The Stacks Email integration. Painlessly create & manage your inboxes, templates, and send emails.",
6
6
  "author": "Chris Breuer",
7
7
  "license": "MIT",
@@ -71,6 +71,7 @@
71
71
  "@stacksjs/error-handling": "workspace:*",
72
72
  "@stacksjs/types": "workspace:*",
73
73
  "@types/mailparser": "^3.4.4",
74
+ "aws-sdk": "^2.1555.0",
74
75
  "mailparser": "^3.6.7",
75
76
  "mime": "^4.0.1",
76
77
  "moment": "^2.30.1",
@@ -12,7 +12,7 @@ const s3 = new AWS.S3({
12
12
 
13
13
  // This lambda will read RAW emails and convert them in easy to read formats
14
14
  // like: HTML and text
15
- exports.handler = (event) => {
15
+ exports.handler = (event: any) => {
16
16
  // 1. We need to process the path received by S3 since AWS dose escape the
17
17
  // string in a special way. They escape the string in a HTML style
18
18
  // but for whatever reason they convert spaces in to +ses.
@@ -57,7 +57,7 @@ exports.handler = (event) => {
57
57
  }
58
58
 
59
59
  // Load the email that triggered the function from S3
60
- function load_the_email(container) {
60
+ function load_the_email(container: any) {
61
61
  return new Promise((resolve, reject) => {
62
62
  console.info('load_the_email')
63
63
 
@@ -68,7 +68,7 @@ function load_the_email(container) {
68
68
  }
69
69
 
70
70
  // -> Execute the query
71
- s3.getObject(params, (error, data) => {
71
+ s3.getObject(params, (error: any, data: any) => {
72
72
  // 1. Check for internal errors
73
73
  if (error)
74
74
  return reject(error)
@@ -84,7 +84,7 @@ function load_the_email(container) {
84
84
 
85
85
  // Since the raw email is saved with an extension we need to remove it
86
86
  // before we can save other converted versions.
87
- function remove_extension(container) {
87
+ function remove_extension(container: any) {
88
88
  return new Promise((resolve, reject) => {
89
89
  console.info('remove_extension')
90
90
 
@@ -105,11 +105,11 @@ function remove_extension(container) {
105
105
  }
106
106
 
107
107
  // Convert the raw email in to HTML and Text, and extract also the attachments
108
- function parse_the_email(container) {
108
+ function parse_the_email(container: any) {
109
109
  return new Promise((resolve, reject) => {
110
- // 1. Parse the email and extract all the it necessary.
111
- parser(container.raw_email, (error, parsed) => {
112
- // 1. Check for internal errors.
110
+ // 1. Parse the email and extract all the necessary
111
+ parser(container.raw_email, (error: any, parsed: any) => {
112
+ // 1. Check for internal errors
113
113
  if (error)
114
114
  return reject(error)
115
115
 
@@ -125,7 +125,7 @@ function parse_the_email(container) {
125
125
  }
126
126
 
127
127
  // After the conversion we save the Text version to S3.
128
- function save_text(container) {
128
+ function save_text(container: any) {
129
129
  return new Promise((resolve, reject) => {
130
130
  console.info('save_text')
131
131
 
@@ -137,7 +137,7 @@ function save_text(container) {
137
137
  }
138
138
 
139
139
  // -> Execute the query.
140
- s3.putObject(params, (error, data) => {
140
+ s3.putObject(params, (error: any, data: any) => {
141
141
  // 1. Check for internal errors.
142
142
  if (error)
143
143
  return reject(error)
@@ -149,10 +149,10 @@ function save_text(container) {
149
149
  }
150
150
 
151
151
  // Then if we have a HTML version we try to save that.
152
- function save_html(container) {
152
+ function save_html(container: any) {
153
153
  return new Promise((resolve, reject) => {
154
154
  // <>> When the body of an email have only one version, meaning it
155
- // dose have only the pure text version and no HTML.
155
+ // does have only the pure text version and no HTML.
156
156
  // Nodemailer won't generate the HTML for you, it just grabs
157
157
  // what is in the Email body.
158
158
  // So, this value will be false, when there is no HTML content in
@@ -174,7 +174,7 @@ function save_html(container) {
174
174
  }
175
175
 
176
176
  // -> Execute the query.
177
- s3.putObject(params, (error, data) => {
177
+ s3.putObject(params, (error: any, data: any) => {
178
178
  // 1. Check for internal errors.
179
179
  if (error)
180
180
  return reject(error)
@@ -187,12 +187,12 @@ function save_html(container) {
187
187
 
188
188
  // Last thing to do is to save the attachments if there are any. If the
189
189
  // array is empty the loop will skip itself.
190
- function save_attachments(container) {
190
+ function save_attachments(container: any) {
191
191
  return new Promise((resolve, reject) => {
192
192
  console.info('save_attachments')
193
193
 
194
194
  // Start the loop which save all the attachments.
195
- loop(1, (error) => {
195
+ loop(1, (error: any) => {
196
196
  // <<> Check if there was an error.
197
197
  if (error) {
198
198
  // -> Stop everything and surface the error.
@@ -204,7 +204,7 @@ function save_attachments(container) {
204
204
  })
205
205
 
206
206
  // This loop will upload all the individual attachments found in a email
207
- function loop(count, callback) {
207
+ function loop(count: any, callback: any) {
208
208
  // 1. Pop the last element in the array if any.
209
209
  const file = container.parsed.attachments.pop()
210
210
 
@@ -213,7 +213,7 @@ function save_attachments(container) {
213
213
  return callback()
214
214
 
215
215
  // 3. Get the file name which also contain the file extension.
216
- file_name = file.filename
216
+ let file_name = file.filename
217
217
 
218
218
  // 4. An email attachment is not required to have a name, this
219
219
  // mean we need to check if we have a file name and, if not
@@ -258,7 +258,7 @@ function save_attachments(container) {
258
258
  }
259
259
 
260
260
  // 8. Then save the buffer of the attachment.
261
- file_body = file.content
261
+ const file_body = file.content
262
262
 
263
263
  // 9. Split the S3 Key (path) so we can remove the last element. Since
264
264
  // we don't want the object name, we care only about the path.
@@ -292,7 +292,7 @@ function save_attachments(container) {
292
292
  }
293
293
 
294
294
  // -> Execute the query.
295
- s3.putObject(params, (error, data) => {
295
+ s3.putObject(params, (error: any, data: any) => {
296
296
  // 1. Check for internal errors.
297
297
  if (error)
298
298
  return callback(error)
@@ -55,7 +55,7 @@ interface S3Event {
55
55
  }
56
56
 
57
57
  // This Lambda will filter all the incoming emails based on their From and To field
58
- export function handler(event: S3Event): Promise<boolean> {
58
+ export function handler(event: S3Event): Promise<any> {
59
59
  // if (!event.Records.length)
60
60
  // throw new Error('No records in the event')
61
61
 
@@ -96,6 +96,8 @@ export function handler(event: S3Event): Promise<boolean> {
96
96
 
97
97
  return false
98
98
  })
99
+
100
+ return Promise.resolve()
99
101
  }
100
102
 
101
103
  // List all the emails added to SES, so we can use them to decided where to
@@ -202,7 +204,8 @@ function parse_the_email(container: Container): Promise<Container> {
202
204
  // Save the parsed email for the next promise.
203
205
  container.date = data.date
204
206
  container.from = data.from?.value[0]?.address
205
- container.to = data.to?.value[0]?.address
207
+ // container.to = data.to?.value[0]?.address
208
+ container.to = data.from?.value[0]?.address
206
209
  container.subject = data.subject || 'No Subject'
207
210
  container.message_id = data.messageId
208
211
 
@@ -236,13 +239,26 @@ function extract_data(container: Container): Promise<Container> {
236
239
  // Since the email string can come in a form of:
237
240
  // Name Last <name@example.com>
238
241
  // We have to extract just the email address, and discard the rest
239
- const tmp_to = container.to
240
- .match(/(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x01-\x09\x0B\x0C\x0E-\x7F])*")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21-\x5A\x53-\x7F]|\\[\x01-\x09\x0B\x0C\x0E-\x7F])+)\])/gm)[0]
241
- .split('@')
242
+ let tmp_to
243
+ if (container?.to) {
244
+ const matchResult = container.to.match(/(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x01-\x09\x0B\x0C\x0E-\x7F])*")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21-\x5A\x53-\x7F]|\\[\x01-\x09\x0B\x0C\x0E-\x7F])+)\])/gm);
245
+ if (matchResult) {
246
+ tmp_to = matchResult[0].split('@');
247
+ // Continue with your logic using tmp_to
248
+ }
249
+ }
250
+
251
+ let tmp_from
252
+ if (container?.from) {
253
+ const matchResult = container.from.match(/(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x01-\x09\x0B\x0C\x0E-\x7F])*")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21-\x5A\x53-\x7F]|\\[\x01-\x09\x0B\x0C\x0E-\x7F])+)\])/gm)
254
+ if (matchResult) {
255
+ tmp_from = matchResult[0].split('@');
256
+ // Continue with your logic using tmp_to
257
+ }
258
+ }
242
259
 
243
- const tmp_from = container.from
244
- .match(/(?:[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+(?:\.[a-zA-Z0-9!#$%&'*+/=?^_`{|}~-]+)*|"(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21\x23-\x5B\x5D-\x7F]|\\[\x01-\x09\x0B\x0C\x0E-\x7F])*")@(?:(?:[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z0-9](?:[a-zA-Z0-9-]*[a-zA-Z0-9])?|\[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-zA-Z0-9-]*[a-zA-Z0-9]:(?:[\x01-\x08\x0B\x0C\x0E-\x1F\x21-\x5A\x53-\x7F]|\\[\x01-\x09\x0B\x0C\x0E-\x7F])+)\])/gm)[0]
245
- .split('@')
260
+ if (!tmp_to || !tmp_from)
261
+ return reject(Error('No To or From field in the email'))
246
262
 
247
263
  // Get the domain name of the receiving end, so we can group
248
264
  // emails by all the domain that were added to SES.