@bitblit/ratchet-aws-node-only 4.0.80-alpha
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/dist/cjs/athena/alb-athena-log-ratchet.js +158 -0
- package/dist/cjs/athena/athena-ratchet.js +159 -0
- package/dist/cjs/build/ratchet-aws-node-only-info.js +18 -0
- package/dist/cjs/cli/dynamo-exporter.js +81 -0
- package/dist/cjs/cli/ratchet-cli-handler.js +19 -0
- package/dist/cjs/cli/site-uploader/site-uploader.js +117 -0
- package/dist/cjs/cli/start-instance-and-ssh.js +67 -0
- package/dist/cjs/index.js +11 -0
- package/dist/cjs/mail/inbound/inbound-email-ratchet.js +54 -0
- package/dist/es/athena/alb-athena-log-ratchet.js +153 -0
- package/dist/es/athena/athena-ratchet.js +154 -0
- package/dist/es/build/ratchet-aws-node-only-info.js +14 -0
- package/dist/es/cli/dynamo-exporter.js +76 -0
- package/dist/es/cli/ratchet-cli-handler.js +15 -0
- package/dist/es/cli/site-uploader/site-uploader.js +112 -0
- package/dist/es/cli/start-instance-and-ssh.js +62 -0
- package/dist/es/index.js +8 -0
- package/dist/es/mail/inbound/inbound-email-ratchet.js +49 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/tsconfig.es.tsbuildinfo +1 -0
- package/dist/tsconfig.types.tsbuildinfo +1 -0
- package/dist/types/athena/alb-athena-log-ratchet.d.ts +57 -0
- package/dist/types/athena/athena-ratchet.d.ts +16 -0
- package/dist/types/build/ratchet-aws-node-only-info.d.ts +5 -0
- package/dist/types/cli/dynamo-exporter.d.ts +13 -0
- package/dist/types/cli/ratchet-cli-handler.d.ts +6 -0
- package/dist/types/cli/site-uploader/site-uploader.d.ts +12 -0
- package/dist/types/cli/start-instance-and-ssh.d.ts +12 -0
- package/dist/types/index.d.ts +11 -0
- package/dist/types/mail/inbound/inbound-email-ratchet.d.ts +18 -0
- package/includes/cli.js +12 -0
- package/package.json +97 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { simpleParser } from 'mailparser';
|
|
2
|
+
import { Readable } from 'stream';
|
|
3
|
+
import { Logger, RequireRatchet } from '@bitblit/ratchet-common';
|
|
4
|
+
export class InboundEmailRatchet {
|
|
5
|
+
constructor(cache) {
|
|
6
|
+
this.cache = cache;
|
|
7
|
+
RequireRatchet.notNullOrUndefined(this.cache, 'cache');
|
|
8
|
+
RequireRatchet.notNullOrUndefined(this.cache.getDefaultBucket(), 'cache.defaultBucket');
|
|
9
|
+
}
|
|
10
|
+
async processEmailFromS3(key) {
|
|
11
|
+
const rval = false;
|
|
12
|
+
if (await this.cache.fileExists(key)) {
|
|
13
|
+
const data = await this.cache.fetchCacheFileAsString(key);
|
|
14
|
+
return this.processEmailFromBuffer(new Buffer(data));
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
Logger.warn('Cannot process inbound email - no such key : %s', key);
|
|
18
|
+
}
|
|
19
|
+
return rval;
|
|
20
|
+
}
|
|
21
|
+
async processEmailFromBuffer(buf) {
|
|
22
|
+
const rval = false;
|
|
23
|
+
RequireRatchet.notNullOrUndefined(buf, 'buf');
|
|
24
|
+
Logger.info('Processing inbound email - size %d bytes', buf.length);
|
|
25
|
+
const message = await simpleParser(buf);
|
|
26
|
+
Logger.info('Found mail from "%s" subject "%s" with %d attachments', message.from.text, message.subject, message.attachments.length);
|
|
27
|
+
if (!!message &&
|
|
28
|
+
!!message.subject &&
|
|
29
|
+
message.subject.toLowerCase().startsWith('reach inventory') &&
|
|
30
|
+
!!message.attachments &&
|
|
31
|
+
message.attachments.length === 1 &&
|
|
32
|
+
message.attachments[0].contentType.toLowerCase() === 'application/zip') {
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
Logger.info('Unrecognized email - not processing');
|
|
36
|
+
}
|
|
37
|
+
return rval;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
export class MultiStream extends Readable {
|
|
41
|
+
constructor(object, options = {}) {
|
|
42
|
+
super(object instanceof Buffer || typeof object === 'string' ? options : { objectMode: true });
|
|
43
|
+
this._object = object;
|
|
44
|
+
}
|
|
45
|
+
_read() {
|
|
46
|
+
this.push(this._object);
|
|
47
|
+
this._object = null;
|
|
48
|
+
}
|
|
49
|
+
}
|