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.
- package/core/actions/dist/src/clean.js +2 -2
- package/core/actions/dist/src/lint/fix.js +4 -1
- package/core/actions/dist/src/upgrade.js +10 -7
- package/core/actions/package.json +1 -1
- package/core/actions/src/action.ts +18 -8
- package/core/actions/src/clean.ts +2 -2
- package/core/actions/src/dev/api.ts +1 -2
- package/core/actions/src/domains/add.ts +12 -27
- package/core/actions/src/lint/fix.ts +6 -1
- package/core/actions/src/migrate/dns.ts +1 -1
- package/core/actions/src/upgrade.ts +5 -2
- package/core/ai/package.json +2 -2
- package/core/alias/package.json +4 -4
- package/core/analytics/package.json +1 -1
- package/core/api/package.json +4 -4
- package/core/arrays/package.json +4 -4
- package/core/auth/package.json +1 -1
- package/core/buddy/dist/{chunk-7b24d1e3e585766e.js → chunk-6658b07ce4c24cac.js} +62 -1
- package/core/buddy/dist/cli.js +1 -1
- package/core/buddy/dist/index.js +1 -1
- package/core/buddy/package.json +1 -1
- package/core/buddy/src/commands/build.ts +25 -25
- package/core/buddy/src/commands/deploy.ts +1 -1
- package/core/buddy/src/commands/dev.ts +33 -34
- package/core/buddy/src/commands/upgrade.ts +23 -24
- package/core/build/package.json +1 -1
- package/core/bun-create/bud/package.json +1 -1
- package/core/bun-create/buddy/package.json +1 -1
- package/core/bun-create/stack/package.json +1 -1
- package/core/bun-create/stacks/package.json +1 -1
- package/core/bun-create/stx/package.json +1 -1
- package/core/bun-create/tmp.json +0 -0
- package/core/bun-plugin-yaml/package.json +4 -4
- package/core/cache/package.json +4 -4
- package/core/chat/package.json +10 -10
- package/core/cli/dist/index.js +27 -20
- package/core/cli/package.json +1 -1
- package/core/cli/src/console.ts +18 -18
- package/core/cli/src/exec.ts +9 -6
- package/core/cli/src/parse.ts +3 -3
- package/core/cloud/dist/index.js +2 -2
- package/core/cloud/package.json +2 -2
- package/core/cloud/src/cloud/aws-sdk-layer/nodejs/package.json +1 -1
- package/core/cloud/src/cloud/dashboard.ts +86 -85
- package/core/cloud/src/cloud/docs.ts +2 -2
- package/core/cloud/src/cloud/router-layer/nodejs/package.json +2 -2
- package/core/cloud/zip.ts +1 -1
- package/core/collections/package.json +2 -2
- package/core/collections/tmp.json +0 -0
- package/core/config/dist/index.js +3 -3
- package/core/config/package.json +1 -1
- package/core/config/src/defaults.ts +4 -2
- package/core/database/package.json +1 -1
- package/core/database/src/kysely-bun-worker/worker.ts +0 -1
- package/core/datetime/package.json +1 -1
- package/core/desktop/package.json +1 -1
- package/core/development/package.json +1 -1
- package/core/dns/package.json +13 -13
- package/core/docs/package.json +1 -1
- package/core/email/package.json +2 -1
- package/core/email/src/server/converter.ts +19 -19
- package/core/email/src/server/inbound.ts +24 -8
- package/core/email/src/server/outbound.ts +17 -17
- package/core/enums/package.json +1 -1
- package/core/env/dist/index.js +1 -1
- package/core/env/package.json +4 -4
- package/core/env/tmp.json +0 -0
- package/core/error-handling/package.json +1 -1
- package/core/eslint-config/build.ts +1 -1
- package/core/eslint-config/package.json +3 -1
- package/core/eslint-config/test/cli.spec.ts +2 -1
- package/core/eslint-config/tsconfig.json +2 -2
- package/core/events/package.json +1 -1
- package/core/faker/package.json +1 -1
- package/core/git/package.json +1 -1
- package/core/health/package.json +1 -1
- package/core/http/package.json +1 -1
- package/core/lint/package.json +1 -1
- package/core/logging/build.ts +1 -1
- package/core/logging/dist/index.js +13 -11043
- package/core/logging/package.json +5 -5
- package/core/notifications/package.json +1 -1
- package/core/objects/package.json +1 -1
- package/core/orm/package.json +8 -8
- package/core/path/dist/index.js +5 -0
- package/core/path/package.json +3 -3
- package/core/path/src/index.ts +5 -0
- package/core/path/tmp.json +0 -0
- package/core/payments/package.json +1 -1
- package/core/push/package.json +1 -1
- package/core/query-builder/package.json +1 -1
- package/core/queue/package.json +2 -2
- package/core/queue/tmp.json +0 -0
- package/core/raycast/package.json +1 -1
- package/core/raycast/tmp.json +0 -0
- package/core/realtime/package.json +1 -1
- package/core/repl/package.json +4 -4
- package/core/router/dist/index.js +4 -0
- package/core/router/package.json +1 -1
- package/core/scheduler/package.json +3 -2
- package/core/scheduler/tests/cron.test.ts +11 -9
- package/core/search-engine/package.json +1 -1
- package/core/security/package.json +9 -9
- package/core/server/package.json +1 -1
- package/core/signals/package.json +1 -1
- package/core/slug/package.json +1 -1
- package/core/sms/package.json +11 -11
- package/core/storage/package.json +13 -13
- package/core/strings/package.json +1 -1
- package/core/tables/package.json +6 -6
- package/core/testing/package.json +6 -4
- package/core/tinker/package.json +4 -4
- package/core/tunnel/package.json +1 -1
- package/core/types/package.json +1 -1
- package/core/types/src/app.ts +1 -1
- package/core/types/src/docs.ts +3 -3
- package/core/types/src/team.ts +1 -1
- package/core/ui/package.json +2 -2
- package/core/utils/dist/index.js +15 -13
- package/core/utils/package.json +21 -21
- package/core/utils/src/clean.ts +3 -3
- package/core/utils/src/hash.ts +9 -9
- package/core/validation/package.json +7 -7
- package/core/vite/dist/index.js +1 -1
- package/core/vite/package.json +1 -1
- package/core/vite/src/example-wc.ts +1 -4
- package/core/vite/src/plugin/auto-imports.ts +1 -2
- package/core/vite/src/plugin/components.ts +1 -2
- package/core/vite/src/plugin/docs.ts +1 -1
- package/core/whois/package.json +4 -4
- package/core/x-ray/package.json +4 -4
- package/core/zsh-buddy/package.json +3 -3
- package/ide/vscode/package.json +3 -4
- package/package.json +1 -1
- package/core/cloud/cdk.json +0 -62
- 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
|
-
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export class DashboardStack {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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": "
|
|
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 || "
|
|
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,
|
package/core/config/package.json
CHANGED
|
@@ -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',
|
package/core/dns/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/dns",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.58.
|
|
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": "
|
|
57
|
-
"@stacksjs/error-handling": "
|
|
58
|
-
"@stacksjs/path": "
|
|
59
|
-
"@stacksjs/storage": "
|
|
60
|
-
"@stacksjs/whois": "
|
|
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": "
|
|
66
|
-
"@stacksjs/error-handling": "
|
|
67
|
-
"@stacksjs/path": "
|
|
68
|
-
"@stacksjs/storage": "
|
|
69
|
-
"@stacksjs/strings": "
|
|
70
|
-
"@stacksjs/whois": "
|
|
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": "
|
|
74
|
+
"@stacksjs/development": "latest",
|
|
75
75
|
"aws-cdk-lib": "^2.127.0"
|
|
76
76
|
}
|
|
77
77
|
}
|
package/core/docs/package.json
CHANGED
package/core/email/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/email",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.58.
|
|
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
|
|
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
|
-
//
|
|
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<
|
|
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
|
-
|
|
240
|
-
|
|
241
|
-
.
|
|
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
|
-
|
|
244
|
-
|
|
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.
|