@comicrelief/lambda-wrapper 2.0.0-beta.1 → 2.0.0-beta.10
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/README.md +26 -3
- package/dist/core/DependencyAwareClass.d.ts +4 -3
- package/dist/core/DependencyAwareClass.d.ts.map +1 -1
- package/dist/core/DependencyAwareClass.js.map +1 -1
- package/dist/core/DependencyInjection.d.ts +6 -6
- package/dist/core/DependencyInjection.d.ts.map +1 -1
- package/dist/core/DependencyInjection.js +24 -2
- package/dist/core/DependencyInjection.js.map +1 -1
- package/dist/core/LambdaWrapper.d.ts +21 -9
- package/dist/core/LambdaWrapper.d.ts.map +1 -1
- package/dist/core/LambdaWrapper.js +55 -11
- package/dist/core/LambdaWrapper.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -4
- package/dist/index.js.map +1 -1
- package/dist/models/ResponseModel.d.ts +4 -22
- package/dist/models/ResponseModel.d.ts.map +1 -1
- package/dist/models/ResponseModel.js +2 -2
- package/dist/models/ResponseModel.js.map +1 -1
- package/dist/services/LoggerService.d.ts.map +1 -1
- package/dist/services/LoggerService.js +8 -17
- package/dist/services/LoggerService.js.map +1 -1
- package/dist/services/SQSService.d.ts +97 -15
- package/dist/services/SQSService.d.ts.map +1 -1
- package/dist/services/SQSService.js +74 -29
- package/dist/services/SQSService.js.map +1 -1
- package/dist/types/Status.d.ts +6 -0
- package/dist/types/Status.d.ts.map +1 -0
- package/dist/types/Status.js +3 -0
- package/dist/types/Status.js.map +1 -0
- package/package.json +17 -17
- package/dist/models/StatusModel.d.ts +0 -40
- package/dist/models/StatusModel.d.ts.map +0 -1
- package/dist/models/StatusModel.js +0 -50
- package/dist/models/StatusModel.js.map +0 -1
package/README.md
CHANGED
|
@@ -13,9 +13,9 @@ If you're coming from v1 and updating to v2, check out the [v2 migration guide](
|
|
|
13
13
|
Install via npm or Yarn:
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
npm i @comicrelief/lambda-wrapper
|
|
16
|
+
npm i @comicrelief/lambda-wrapper@beta
|
|
17
17
|
# or
|
|
18
|
-
yarn add @comicrelief/lambda-wrapper
|
|
18
|
+
yarn add @comicrelief/lambda-wrapper@beta
|
|
19
19
|
```
|
|
20
20
|
|
|
21
21
|
You can then wrap your Lambda handler functions like this:
|
|
@@ -186,7 +186,7 @@ When you go to configure your Lambda Wrapper, you can now include your dependenc
|
|
|
186
186
|
```ts
|
|
187
187
|
lambdaWrapper.configure<WithSQSServiceConfig>({
|
|
188
188
|
sqs: {
|
|
189
|
-
queues: 42 // Oops! This will be
|
|
189
|
+
queues: 42 // Oops! This will be flagged as a type error by TypeScript
|
|
190
190
|
},
|
|
191
191
|
});
|
|
192
192
|
```
|
|
@@ -204,6 +204,29 @@ lambdaWrapper.configure<WithSQSServiceConfig & WithOtherServiceConfig>({
|
|
|
204
204
|
});
|
|
205
205
|
```
|
|
206
206
|
|
|
207
|
+
## Monitoring
|
|
208
|
+
|
|
209
|
+
At Comic Relief we use [Lumigo](https://lumigo.io/) for monitoring and observability of our deployed services. Lambda Wrapper includes the Lumigo tracer to allow us to tag traces with custom labels and metrics ([execution tags](https://docs.lumigo.io/docs/execution-tags)).
|
|
210
|
+
|
|
211
|
+
Lumigo integration works out-of-the-box with Lumigo's [auto-trace feature](https://docs.lumigo.io/docs/serverless-applications#automatic-instrumentation). If you prefer manual tracing, enable it by setting `LUMIGO_TRACER_TOKEN` in your Lambda environment variables.
|
|
212
|
+
|
|
213
|
+
And if you don't use Lumigo, don't worry, their tracer will not be instantiated in your functions and no calls will be made to their servers unless `LUMIGO_TRACER_TOKEN` is set.
|
|
214
|
+
|
|
215
|
+
## Notes
|
|
216
|
+
|
|
217
|
+
Lambda Wrapper's dependency injection relies on class names being preserved. If your build process includes minifying or uglifying your code, you'll need to disable these transformations.
|
|
218
|
+
|
|
219
|
+
In many of our projects we use `serverless-webpack` to bundle service code prior to deployment. To disable name mangling, set `optimization.minimize` to `false` in your webpack config:
|
|
220
|
+
|
|
221
|
+
```js
|
|
222
|
+
// webpack.config.js
|
|
223
|
+
module.exports = {
|
|
224
|
+
// ...
|
|
225
|
+
optimization: {
|
|
226
|
+
minimize: false,
|
|
227
|
+
},
|
|
228
|
+
```
|
|
229
|
+
|
|
207
230
|
## Development
|
|
208
231
|
|
|
209
232
|
### Testing
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import DependencyInjection from './DependencyInjection';
|
|
2
|
+
import { LambdaWrapperConfig } from './config';
|
|
2
3
|
/**
|
|
3
4
|
* Base class for dependencies.
|
|
4
5
|
*/
|
|
5
|
-
export default class DependencyAwareClass {
|
|
6
|
-
readonly di: DependencyInjection
|
|
7
|
-
constructor(di: DependencyInjection);
|
|
6
|
+
export default class DependencyAwareClass<TConfig extends LambdaWrapperConfig = any> {
|
|
7
|
+
readonly di: DependencyInjection<TConfig>;
|
|
8
|
+
constructor(di: DependencyInjection<TConfig>);
|
|
8
9
|
/**
|
|
9
10
|
* Get dependency injection container.
|
|
10
11
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependencyAwareClass.d.ts","sourceRoot":"","sources":["../../src/core/DependencyAwareClass.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"DependencyAwareClass.d.ts","sourceRoot":"","sources":["../../src/core/DependencyAwareClass.ts"],"names":[],"mappings":"AAAA,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAE/C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,oBAAoB,CAAC,OAAO,SAAS,mBAAmB,GAAG,GAAG;IACrE,QAAQ,CAAC,EAAE,EAAE,mBAAmB,CAAC,OAAO,CAAC;gBAAhC,EAAE,EAAE,mBAAmB,CAAC,OAAO,CAAC;IAErD;;;;OAIG;IACH,YAAY,IAAI,mBAAmB;CAGpC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependencyAwareClass.js","sourceRoot":"","sources":["../../src/core/DependencyAwareClass.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"DependencyAwareClass.js","sourceRoot":"","sources":["../../src/core/DependencyAwareClass.ts"],"names":[],"mappings":";;AAGA;;GAEG;AACH,MAAqB,oBAAoB;IACvC,YAAqB,EAAgC;QAAhC,OAAE,GAAF,EAAE,CAA8B;IAAG,CAAC;IAEzD;;;;OAIG;IACH,YAAY;QACV,OAAO,IAAI,CAAC,EAAE,CAAC;IACjB,CAAC;CACF;AAXD,uCAWC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Context } from 'aws-lambda';
|
|
2
2
|
import DependencyAwareClass from './DependencyAwareClass';
|
|
3
3
|
import { LambdaWrapperConfig } from './config';
|
|
4
|
-
declare type Class<
|
|
4
|
+
declare type Class<TInstance, TConfig extends LambdaWrapperConfig> = new (di: DependencyInjection<TConfig>) => TInstance;
|
|
5
5
|
/**
|
|
6
6
|
* Dependency injection container.
|
|
7
7
|
*
|
|
8
8
|
* Dependencies (singleton instances of dependency-aware classes) are provided
|
|
9
9
|
* to the main Lambda handler and other dependencies via this class.
|
|
10
10
|
*/
|
|
11
|
-
export default class DependencyInjection {
|
|
12
|
-
readonly config:
|
|
11
|
+
export default class DependencyInjection<TConfig extends LambdaWrapperConfig = any> {
|
|
12
|
+
readonly config: TConfig;
|
|
13
13
|
readonly event: any;
|
|
14
14
|
readonly context: Context;
|
|
15
15
|
/**
|
|
@@ -20,13 +20,13 @@ export default class DependencyInjection {
|
|
|
20
20
|
* True until all dependencies have been constructed.
|
|
21
21
|
*/
|
|
22
22
|
private isConstructing;
|
|
23
|
-
constructor(config:
|
|
23
|
+
constructor(config: TConfig, event: any, context: Context);
|
|
24
24
|
/**
|
|
25
25
|
* Get the singleton instance of the given dependency.
|
|
26
26
|
*
|
|
27
27
|
* @param dependency
|
|
28
28
|
*/
|
|
29
|
-
get<T extends DependencyAwareClass>(dependency: Class<T>): T;
|
|
29
|
+
get<T extends DependencyAwareClass>(dependency: Class<T, TConfig>): T;
|
|
30
30
|
/**
|
|
31
31
|
* Get the event passed to AWS Lambda.
|
|
32
32
|
*
|
|
@@ -44,7 +44,7 @@ export default class DependencyInjection {
|
|
|
44
44
|
*
|
|
45
45
|
* @deprecated Use `di.config` instead.
|
|
46
46
|
*/
|
|
47
|
-
getConfiguration():
|
|
47
|
+
getConfiguration(): TConfig;
|
|
48
48
|
/**
|
|
49
49
|
* True if the function is being executed in `serverless-offline`.
|
|
50
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependencyInjection.d.ts","sourceRoot":"","sources":["../../src/core/DependencyInjection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,aAAK,KAAK,CAAC,
|
|
1
|
+
{"version":3,"file":"DependencyInjection.d.ts","sourceRoot":"","sources":["../../src/core/DependencyInjection.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,OAAO,oBAAoB,MAAM,wBAAwB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAG/C,aAAK,KAAK,CAAC,SAAS,EAAE,OAAO,SAAS,mBAAmB,IAAI,KAAK,EAAE,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC;AAEjH;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB,CAAC,OAAO,SAAS,mBAAmB,GAAG,GAAG;IAY9E,QAAQ,CAAC,MAAM,EAAE,OAAO;IACxB,QAAQ,CAAC,KAAK,EAAE,GAAG;IACnB,QAAQ,CAAC,OAAO,EAAE,OAAO;IAb3B;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,oBAAoB,CAAC,CAAC;IAE5D;;OAEG;IACH,OAAO,CAAC,cAAc,CAAQ;gBAGnB,MAAM,EAAE,OAAO,EACf,KAAK,EAAE,GAAG,EACV,OAAO,EAAE,OAAO;IAyC3B;;;;OAIG;IACH,GAAG,CAAC,CAAC,SAAS,oBAAoB,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC,GAAG,CAAC;IAsBrE;;;;OAIG;IACH,QAAQ;IAIR;;;;OAIG;IACH,UAAU;IAIV;;;;OAIG;IACH,gBAAgB;IAIhB;;;;;;;;;;OAUG;IACH,IAAI,SAAS,IAAI,OAAO,CAIvB;CACF"}
|
|
@@ -15,7 +15,29 @@ class DependencyInjection {
|
|
|
15
15
|
* True until all dependencies have been constructed.
|
|
16
16
|
*/
|
|
17
17
|
this.isConstructing = true;
|
|
18
|
-
|
|
18
|
+
// get unique dependency classes -- a class may be included several times,
|
|
19
|
+
// but should be instantiated only once
|
|
20
|
+
const classes = Array.from(new Set(Object.values(config.dependencies)));
|
|
21
|
+
// guard against duplicate keys
|
|
22
|
+
const countByName = classes
|
|
23
|
+
.map((Constructor) => Constructor.name)
|
|
24
|
+
.reduce((counts, name) => ({ ...counts, [name]: (counts[name] || 0) + 1 }), {});
|
|
25
|
+
if (Object.values(countByName).some((count) => count > 1)) {
|
|
26
|
+
const duplicateNames = Object.entries(countByName)
|
|
27
|
+
.filter(([, count]) => count > 1)
|
|
28
|
+
.map(([name]) => name);
|
|
29
|
+
// if all class names are single-letter, they're probably minified -- in
|
|
30
|
+
// this case, give a hint about how to fix it
|
|
31
|
+
const action = duplicateNames.every((it) => it.length === 1)
|
|
32
|
+
? "If you don't recognise the single-letter names listed above, your "
|
|
33
|
+
+ "bundler may be minifying your code. You'll need to disable this "
|
|
34
|
+
+ 'for Lambda Wrapper to work correctly. Please refer to the Notes '
|
|
35
|
+
+ 'section of the Lambda Wrapper readme:\n\n'
|
|
36
|
+
+ ' https://github.com/comicrelief/lambda-wrapper/tree/beta#notes'
|
|
37
|
+
: 'Please ensure that all dependency classes have a unique name.';
|
|
38
|
+
throw new Error(`Dependency names are not unique: ${duplicateNames.join(', ')}\n\n${action}`);
|
|
39
|
+
}
|
|
40
|
+
// instantiate all dependencies
|
|
19
41
|
this.dependencies = Object.fromEntries(classes.map((Constructor) => [Constructor.name, new Constructor(this)]));
|
|
20
42
|
this.isConstructing = false;
|
|
21
43
|
}
|
|
@@ -27,7 +49,7 @@ class DependencyInjection {
|
|
|
27
49
|
get(dependency) {
|
|
28
50
|
if (this.isConstructing) {
|
|
29
51
|
throw new Error('Dependencies are not available in dependency class constructors.\n\n'
|
|
30
|
-
+ 'To fix this, call `di.get` in the function where the dependency is'
|
|
52
|
+
+ 'To fix this, call `di.get` in the function where the dependency is '
|
|
31
53
|
+ 'used instead of inside your constructor.');
|
|
32
54
|
}
|
|
33
55
|
const name = dependency.name;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DependencyInjection.js","sourceRoot":"","sources":["../../src/core/DependencyInjection.ts"],"names":[],"mappings":";;AAQA;;;;;GAKG;AACH,MAAqB,mBAAmB;IAWtC,YACW,
|
|
1
|
+
{"version":3,"file":"DependencyInjection.js","sourceRoot":"","sources":["../../src/core/DependencyInjection.ts"],"names":[],"mappings":";;AAQA;;;;;GAKG;AACH,MAAqB,mBAAmB;IAWtC,YACW,MAAe,EACf,KAAU,EACV,OAAgB;QAFhB,WAAM,GAAN,MAAM,CAAS;QACf,UAAK,GAAL,KAAK,CAAK;QACV,YAAO,GAAP,OAAO,CAAS;QAR3B;;WAEG;QACK,mBAAc,GAAG,IAAI,CAAC;QAO5B,0EAA0E;QAC1E,uCAAuC;QACvC,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,MAA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CAAC,WAAW,CAAC,IAAI,EAAE,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CACxE,CAAC;QAEF,IAAI,CAAC,cAAc,GAAG,KAAK,CAAC;IAC9B,CAAC;IAED;;;;OAIG;IACH,GAAG,CAAiC,UAA6B;QAC/D,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,MAAM,IAAI,KAAK,CACb,sEAAsE;kBACpE,qEAAqE;kBACrE,0CAA0C,CAC7C,CAAC;SACH;QAED,MAAM,IAAI,GAAG,UAAU,CAAC,IAAI,CAAC;QAE7B,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE;YAC5B,MAAM,IAAI,KAAK,CACb,GAAG,IAAI,6CAA6C;kBAClD,6BAA6B,IAAI,qCAAqC;kBACtE,wBAAwB,CAC3B,CAAC;SACH;QAED,OAAO,IAAI,CAAC,YAAY,CAAC,IAAI,CAAM,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IAED;;;;;;;;;;OAUG;IACH,IAAI,SAAS;QACX,OAAO,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB;eAClC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,QAAQ,CAAC,SAAS,CAAC;eACnD,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,sBAAsB,CAAC;IAC5C,CAAC;CACF;AA7HD,sCA6HC"}
|
|
@@ -24,7 +24,24 @@ export default class LambdaWrapper<TConfig extends LambdaWrapperConfig = LambdaW
|
|
|
24
24
|
/**
|
|
25
25
|
* Wrap the given function.
|
|
26
26
|
*/
|
|
27
|
-
wrap<T>(handler: (di: DependencyInjection) => Promise<T>, options?: WrapOptions): (event: any, context: Context) => Promise<any>;
|
|
27
|
+
wrap<T>(handler: (di: DependencyInjection<TConfig>) => T | Promise<T>, options?: WrapOptions): (event: any, context: Context) => Promise<any>;
|
|
28
|
+
/**
|
|
29
|
+
* `true` if we will send traces to Lumigo.
|
|
30
|
+
*
|
|
31
|
+
* The `LUMIGO_TRACER_TOKEN` env var is present in both manually traced and
|
|
32
|
+
* auto-traced functions.
|
|
33
|
+
*/
|
|
34
|
+
static get isLumigoEnabled(): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* `true` if the Lambda function is already being traced by a higher-level
|
|
37
|
+
* Lumigo wrapper, in which case we don't need to manually wrap our handlers.
|
|
38
|
+
*
|
|
39
|
+
* There are two ways that this can be done, based on the documentation
|
|
40
|
+
* [here](https://docs.lumigo.io/docs/lambda-layers): using a Lambda runtime
|
|
41
|
+
* wrapper, or handler redirection. Each method can be detected via its
|
|
42
|
+
* environment variables. Auto-trace uses the runtime wrapper.
|
|
43
|
+
*/
|
|
44
|
+
static get isLumigoWrappingUs(): boolean;
|
|
28
45
|
/**
|
|
29
46
|
* Process the result once we have one.
|
|
30
47
|
*
|
|
@@ -33,11 +50,10 @@ export default class LambdaWrapper<TConfig extends LambdaWrapperConfig = LambdaW
|
|
|
33
50
|
*/
|
|
34
51
|
static handleSuccess(di: DependencyInjection, result: any): any;
|
|
35
52
|
/**
|
|
36
|
-
* Gracefully handles an error, logging in
|
|
53
|
+
* Gracefully handles an error, logging in Lumigo and generating a response
|
|
37
54
|
* reflecting the `code` of the error, if defined.
|
|
38
55
|
*
|
|
39
|
-
*
|
|
40
|
-
* Epsagon generates alerts for logs on level ERROR. This means that
|
|
56
|
+
* Lumigo generates alerts for logs on level ERROR. This means that
|
|
41
57
|
* `logger.error` will produce an alert. To avoid meaningless notifications,
|
|
42
58
|
* most likely coming from tests, we log INFO unless either:
|
|
43
59
|
*
|
|
@@ -50,11 +66,7 @@ export default class LambdaWrapper<TConfig extends LambdaWrapperConfig = LambdaW
|
|
|
50
66
|
*/
|
|
51
67
|
static handleError(di: DependencyInjection, error: Error, throwError?: boolean): {
|
|
52
68
|
statusCode: any;
|
|
53
|
-
headers:
|
|
54
|
-
'Content-Type': string;
|
|
55
|
-
'Access-Control-Allow-Origin': string;
|
|
56
|
-
'Access-Control-Allow-Credentials': boolean;
|
|
57
|
-
};
|
|
69
|
+
headers: Record<string, string>;
|
|
58
70
|
body: string;
|
|
59
71
|
} | Error;
|
|
60
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LambdaWrapper.d.ts","sourceRoot":"","sources":["../../src/core/LambdaWrapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAInC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAe,MAAM,UAAU,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,CAAC,OAAO,OAAO,aAAa,CAAC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB;IAC9E,QAAQ,CAAC,MAAM,EAAE,OAAO;gBAAf,MAAM,EAAE,OAAO;IAEpC;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,WAAW,GAAG,aAAa,CAAC,OAAO,GAAG,WAAW,CAAC;IAIpG;;OAEG;IACH,IAAI,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"LambdaWrapper.d.ts","sourceRoot":"","sources":["../../src/core/LambdaWrapper.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAInC,OAAO,mBAAmB,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAe,MAAM,UAAU,CAAC;AAE5D,MAAM,WAAW,WAAW;IAC1B;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,OAAO,CAAC;CAChC;AAED,MAAM,CAAC,OAAO,OAAO,aAAa,CAAC,OAAO,SAAS,mBAAmB,GAAG,mBAAmB;IAC9E,QAAQ,CAAC,MAAM,EAAE,OAAO;gBAAf,MAAM,EAAE,OAAO;IAEpC;;;;OAIG;IACH,SAAS,CAAC,WAAW,EAAE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,WAAW,GAAG,aAAa,CAAC,OAAO,GAAG,WAAW,CAAC;IAIpG;;OAEG;IACH,IAAI,CAAC,CAAC,EACJ,OAAO,EAAE,CAAC,EAAE,EAAE,mBAAmB,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAC7D,OAAO,CAAC,EAAE,WAAW,WAMO,GAAG,WAAW,OAAO;IAyDnD;;;;;OAKG;IACH,MAAM,KAAK,eAAe,IAAI,OAAO,CAEpC;IAED;;;;;;;;OAQG;IACH,MAAM,KAAK,kBAAkB,IAAI,OAAO,CAKvC;IAED;;;;;OAKG;IACH,MAAM,CAAC,aAAa,CAAC,EAAE,EAAE,mBAAmB,EAAE,MAAM,EAAE,GAAG;IASzD;;;;;;;;;;;;;;OAcG;IACH,MAAM,CAAC,WAAW,CAAC,EAAE,EAAE,mBAAmB,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,UAAQ;;;;;CA8B7E"}
|
|
@@ -1,9 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
2
25
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
27
|
};
|
|
5
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
29
|
+
const lumigo = __importStar(require("@lumigo/tracer"));
|
|
7
30
|
const ResponseModel_1 = __importDefault(require("../models/ResponseModel"));
|
|
8
31
|
const LoggerService_1 = __importDefault(require("../services/LoggerService"));
|
|
9
32
|
const RequestService_1 = __importDefault(require("../services/RequestService"));
|
|
@@ -63,16 +86,38 @@ class LambdaWrapper {
|
|
|
63
86
|
return handled;
|
|
64
87
|
}
|
|
65
88
|
};
|
|
66
|
-
// If
|
|
67
|
-
if (
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
wrapper =
|
|
89
|
+
// If Lumigo is enabled, wrap the handler in the Lumigo wrapper
|
|
90
|
+
if (LambdaWrapper.isLumigoEnabled && !LambdaWrapper.isLumigoWrappingUs) {
|
|
91
|
+
const tracer = lumigo.initTracer({ token: process.env.LUMIGO_TRACER_TOKEN });
|
|
92
|
+
// Lumigo's wrapper works with both callbacks or promises handlers, and
|
|
93
|
+
// the returned function behaves the same way as the original. For our
|
|
94
|
+
// promise-based handler we can safely coerce the type.
|
|
95
|
+
wrapper = tracer.trace(wrapper);
|
|
73
96
|
}
|
|
74
97
|
return wrapper;
|
|
75
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* `true` if we will send traces to Lumigo.
|
|
101
|
+
*
|
|
102
|
+
* The `LUMIGO_TRACER_TOKEN` env var is present in both manually traced and
|
|
103
|
+
* auto-traced functions.
|
|
104
|
+
*/
|
|
105
|
+
static get isLumigoEnabled() {
|
|
106
|
+
return !!process.env.LUMIGO_TRACER_TOKEN;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* `true` if the Lambda function is already being traced by a higher-level
|
|
110
|
+
* Lumigo wrapper, in which case we don't need to manually wrap our handlers.
|
|
111
|
+
*
|
|
112
|
+
* There are two ways that this can be done, based on the documentation
|
|
113
|
+
* [here](https://docs.lumigo.io/docs/lambda-layers): using a Lambda runtime
|
|
114
|
+
* wrapper, or handler redirection. Each method can be detected via its
|
|
115
|
+
* environment variables. Auto-trace uses the runtime wrapper.
|
|
116
|
+
*/
|
|
117
|
+
static get isLumigoWrappingUs() {
|
|
118
|
+
return this.isLumigoEnabled && (process.env.AWS_LAMBDA_EXEC_WRAPPER === '/opt/lumigo_wrapper'
|
|
119
|
+
|| !!process.env.LUMIGO_ORIGINAL_HANDLER);
|
|
120
|
+
}
|
|
76
121
|
/**
|
|
77
122
|
* Process the result once we have one.
|
|
78
123
|
*
|
|
@@ -86,11 +131,10 @@ class LambdaWrapper {
|
|
|
86
131
|
return result;
|
|
87
132
|
}
|
|
88
133
|
/**
|
|
89
|
-
* Gracefully handles an error, logging in
|
|
134
|
+
* Gracefully handles an error, logging in Lumigo and generating a response
|
|
90
135
|
* reflecting the `code` of the error, if defined.
|
|
91
136
|
*
|
|
92
|
-
*
|
|
93
|
-
* Epsagon generates alerts for logs on level ERROR. This means that
|
|
137
|
+
* Lumigo generates alerts for logs on level ERROR. This means that
|
|
94
138
|
* `logger.error` will produce an alert. To avoid meaningless notifications,
|
|
95
139
|
* most likely coming from tests, we log INFO unless either:
|
|
96
140
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LambdaWrapper.js","sourceRoot":"","sources":["../../src/core/LambdaWrapper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LambdaWrapper.js","sourceRoot":"","sources":["../../src/core/LambdaWrapper.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAyC;AAGzC,4EAAoD;AACpD,8EAAsD;AACtD,gFAAwD;AACxD,gFAAwD;AACxD,qCAA4D;AAc5D,MAAqB,aAAa;IAChC,YAAqB,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;IAAG,CAAC;IAExC;;;;OAIG;IACH,SAAS,CAAc,MAAsC;QAC3D,OAAO,IAAI,aAAa,CAAC,IAAA,oBAAW,EAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED;;OAEG;IACH,IAAI,CACF,OAA6D,EAC7D,OAAqB;QAErB,MAAM,EACJ,oBAAoB,GAAG,IAAI,GAC5B,GAAG,OAAO,IAAI,EAAE,CAAC;QAElB,IAAI,OAAO,GAAG,KAAK,EAAE,KAAU,EAAE,OAAgB,EAAE,EAAE;YACnD,MAAM,EAAE,GAAG,IAAI,6BAAmB,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;YAChE,MAAM,OAAO,GAAG,EAAE,CAAC,GAAG,CAAC,wBAAc,CAAC,CAAC;YACvC,MAAM,MAAM,GAAG,EAAE,CAAC,GAAG,CAAC,uBAAa,CAAC,CAAC;YAErC,OAAO,CAAC,8BAA8B,GAAG,KAAK,CAAC;YAE/C,8DAA8D;YAC9D,IAAI,KAAK,CAAC,MAAM,KAAK,0BAA0B,EAAE;gBAC/C,OAAO,iBAAiB,CAAC;aAC1B;YAED,8DAA8D;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YAAY,KAAK,EAAE;gBAC1B,OAAO,KAAK,CAAC;aACd;YAED,mEAAmE;YACnE,wEAAwE;YACxE,OAAO,IAAI,KAAK,CAAC,KAAK,CAAC,CAAC;SACzB;QAED,OAAO,uBAAa,CAAC,QAAQ,CAAC,IAAI,EAAE,IAAI,IAAI,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;CACF;AAtKD,gCAsKC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -14,15 +14,15 @@ export { LambdaWrapperConfig } from './core/config';
|
|
|
14
14
|
export { default as DependencyAwareClass } from './core/DependencyAwareClass';
|
|
15
15
|
export { default as DependencyInjection } from './core/DependencyInjection';
|
|
16
16
|
export { default as LambdaWrapper, WrapOptions } from './core/LambdaWrapper';
|
|
17
|
-
export { default as ResponseModel, } from './models/ResponseModel';
|
|
17
|
+
export { default as ResponseModel, RESPONSE_HEADERS, } from './models/ResponseModel';
|
|
18
18
|
export { default as SQSMessageModel, } from './models/SQSMessageModel';
|
|
19
|
-
export { default as StatusModel, STATUS_TYPES, } from './models/StatusModel';
|
|
20
19
|
export { default as BaseConfigService, } from './services/BaseConfigService';
|
|
21
20
|
export { default as HTTPService, COMICRELIEF_TEST_METADATA_HEADER, } from './services/HTTPService';
|
|
22
21
|
export { default as LoggerService, } from './services/LoggerService';
|
|
23
22
|
export { default as RequestService, REQUEST_TYPES, RequestFile, } from './services/RequestService';
|
|
24
|
-
export { default as SQSService, SQS_OFFLINE_MODES, SQS_PUBLISH_FAILURE_MODES, SQSServiceConfig, WithSQSServiceConfig, } from './services/SQSService';
|
|
23
|
+
export { default as SQSService, QueueName, SQS_OFFLINE_MODES, SQS_PUBLISH_FAILURE_MODES, SQSServiceConfig, WithSQSServiceConfig, } from './services/SQSService';
|
|
25
24
|
export { default as TimerService, } from './services/TimerService';
|
|
25
|
+
export { ServiceStatus, Status, } from './types/Status';
|
|
26
26
|
export { default as LambdaTermination } from './utils/LambdaTermination';
|
|
27
27
|
export { default as PromisifiedDelay } from './utils/PromisifiedDelay';
|
|
28
28
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGzE;;;;;GAKG;AACH,QAAA,MAAM,aAAa,2DAOjB,CAAC;AAEH,eAAe,aAAa,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EACL,OAAO,IAAI,aAAa,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,aAAa,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAGpD,OAAmB,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGzE;;;;;GAKG;AACH,QAAA,MAAM,aAAa,2DAOjB,CAAC;AAEH,eAAe,aAAa,CAAC;AAE7B,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,6BAA6B,CAAC;AAC9E,OAAO,EAAE,OAAO,IAAI,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAC5E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAE7E,OAAO,EACL,OAAO,IAAI,aAAa,EACxB,gBAAgB,GACjB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,OAAO,IAAI,eAAe,GAC3B,MAAM,0BAA0B,CAAC;AAElC,OAAO,EACL,OAAO,IAAI,iBAAiB,GAC7B,MAAM,8BAA8B,CAAC;AACtC,OAAO,EACL,OAAO,IAAI,WAAW,EACtB,gCAAgC,GACjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,OAAO,IAAI,aAAa,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,OAAO,IAAI,cAAc,EACzB,aAAa,EACb,WAAW,GACZ,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,OAAO,IAAI,UAAU,EACrB,SAAS,EACT,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,OAAO,IAAI,YAAY,GACxB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,EACL,aAAa,EACb,MAAM,GACP,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,0BAA0B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.PromisifiedDelay = exports.LambdaTermination = exports.TimerService = exports.SQS_PUBLISH_FAILURE_MODES = exports.SQS_OFFLINE_MODES = exports.SQSService = exports.REQUEST_TYPES = exports.RequestService = exports.LoggerService = exports.COMICRELIEF_TEST_METADATA_HEADER = exports.HTTPService = exports.BaseConfigService = exports.
|
|
6
|
+
exports.PromisifiedDelay = exports.LambdaTermination = exports.TimerService = exports.SQS_PUBLISH_FAILURE_MODES = exports.SQS_OFFLINE_MODES = exports.SQSService = exports.REQUEST_TYPES = exports.RequestService = exports.LoggerService = exports.COMICRELIEF_TEST_METADATA_HEADER = exports.HTTPService = exports.BaseConfigService = exports.SQSMessageModel = exports.RESPONSE_HEADERS = exports.ResponseModel = exports.LambdaWrapper = exports.DependencyInjection = exports.DependencyAwareClass = void 0;
|
|
7
7
|
const LambdaWrapper_1 = __importDefault(require("./core/LambdaWrapper"));
|
|
8
8
|
const LoggerService_1 = __importDefault(require("./services/LoggerService"));
|
|
9
9
|
const RequestService_1 = __importDefault(require("./services/RequestService"));
|
|
@@ -32,11 +32,9 @@ var LambdaWrapper_2 = require("./core/LambdaWrapper");
|
|
|
32
32
|
Object.defineProperty(exports, "LambdaWrapper", { enumerable: true, get: function () { return __importDefault(LambdaWrapper_2).default; } });
|
|
33
33
|
var ResponseModel_1 = require("./models/ResponseModel");
|
|
34
34
|
Object.defineProperty(exports, "ResponseModel", { enumerable: true, get: function () { return __importDefault(ResponseModel_1).default; } });
|
|
35
|
+
Object.defineProperty(exports, "RESPONSE_HEADERS", { enumerable: true, get: function () { return ResponseModel_1.RESPONSE_HEADERS; } });
|
|
35
36
|
var SQSMessageModel_1 = require("./models/SQSMessageModel");
|
|
36
37
|
Object.defineProperty(exports, "SQSMessageModel", { enumerable: true, get: function () { return __importDefault(SQSMessageModel_1).default; } });
|
|
37
|
-
var StatusModel_1 = require("./models/StatusModel");
|
|
38
|
-
Object.defineProperty(exports, "StatusModel", { enumerable: true, get: function () { return __importDefault(StatusModel_1).default; } });
|
|
39
|
-
Object.defineProperty(exports, "STATUS_TYPES", { enumerable: true, get: function () { return StatusModel_1.STATUS_TYPES; } });
|
|
40
38
|
var BaseConfigService_1 = require("./services/BaseConfigService");
|
|
41
39
|
Object.defineProperty(exports, "BaseConfigService", { enumerable: true, get: function () { return __importDefault(BaseConfigService_1).default; } });
|
|
42
40
|
var HTTPService_1 = require("./services/HTTPService");
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAiD;AAEjD,6EAAqD;AACrD,+EAAuD;AACvD,uEAAyE;AACzE,2EAAmD;AAEnD;;;;;GAKG;AACH,MAAM,aAAa,GAAG,IAAI,uBAAa,CAA6C;IAClF,YAAY,EAAE;QACZ,aAAa,EAAb,uBAAa;QACb,cAAc,EAAd,wBAAc;QACd,UAAU,EAAV,oBAAU;QACV,YAAY,EAAZ,sBAAY;KACb;CACF,CAAC,CAAC;AAEH,kBAAe,aAAa,CAAC;AAK7B,oEAA8E;AAArE,6IAAA,OAAO,OAAwB;AACxC,kEAA4E;AAAnE,2IAAA,OAAO,OAAuB;AACvC,sDAA6E;AAApE,+HAAA,OAAO,OAAiB;AAEjC,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;AAAA,yEAAiD;AAEjD,6EAAqD;AACrD,+EAAuD;AACvD,uEAAyE;AACzE,2EAAmD;AAEnD;;;;;GAKG;AACH,MAAM,aAAa,GAAG,IAAI,uBAAa,CAA6C;IAClF,YAAY,EAAE;QACZ,aAAa,EAAb,uBAAa;QACb,cAAc,EAAd,wBAAc;QACd,UAAU,EAAV,oBAAU;QACV,YAAY,EAAZ,sBAAY;KACb;CACF,CAAC,CAAC;AAEH,kBAAe,aAAa,CAAC;AAK7B,oEAA8E;AAArE,6IAAA,OAAO,OAAwB;AACxC,kEAA4E;AAAnE,2IAAA,OAAO,OAAuB;AACvC,sDAA6E;AAApE,+HAAA,OAAO,OAAiB;AAEjC,wDAGgC;AAF9B,+HAAA,OAAO,OAAiB;AACxB,iHAAA,gBAAgB,OAAA;AAElB,4DAEkC;AADhC,mIAAA,OAAO,OAAmB;AAG5B,kEAEsC;AADpC,uIAAA,OAAO,OAAqB;AAE9B,sDAGgC;AAF9B,2HAAA,OAAO,OAAe;AACtB,+HAAA,gCAAgC,OAAA;AAElC,0DAEkC;AADhC,+HAAA,OAAO,OAAiB;AAE1B,4DAImC;AAHjC,iIAAA,OAAO,OAAkB;AACzB,+GAAA,aAAa,OAAA;AAGf,oDAO+B;AAN7B,yHAAA,OAAO,OAAc;AAErB,+GAAA,iBAAiB,OAAA;AACjB,uHAAA,yBAAyB,OAAA;AAI3B,wDAEiC;AAD/B,6HAAA,OAAO,OAAgB;AAQzB,+DAAyE;AAAhE,uIAAA,OAAO,OAAqB;AACrC,6DAAuE;AAA9D,qIAAA,OAAO,OAAoB"}
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* HTTP headers to be included in
|
|
2
|
+
* HTTP headers to be included in `ResponseModel`.
|
|
3
3
|
*/
|
|
4
|
-
export declare const RESPONSE_HEADERS:
|
|
5
|
-
'Content-Type': string;
|
|
6
|
-
/** Required for CORS support to work */
|
|
7
|
-
'Access-Control-Allow-Origin': string;
|
|
8
|
-
/** Required for cookies, authorization headers with HTTPS */
|
|
9
|
-
'Access-Control-Allow-Credentials': boolean;
|
|
10
|
-
};
|
|
4
|
+
export declare const RESPONSE_HEADERS: Record<string, string>;
|
|
11
5
|
/**
|
|
12
6
|
* Default message provided as part of response.
|
|
13
7
|
*/
|
|
@@ -57,13 +51,7 @@ export default class ResponseModel {
|
|
|
57
51
|
*/
|
|
58
52
|
generate(): {
|
|
59
53
|
statusCode: any;
|
|
60
|
-
headers:
|
|
61
|
-
'Content-Type': string;
|
|
62
|
-
/** Required for CORS support to work */
|
|
63
|
-
'Access-Control-Allow-Origin': string;
|
|
64
|
-
/** Required for cookies, authorization headers with HTTPS */
|
|
65
|
-
'Access-Control-Allow-Credentials': boolean;
|
|
66
|
-
};
|
|
54
|
+
headers: Record<string, string>;
|
|
67
55
|
body: string;
|
|
68
56
|
};
|
|
69
57
|
/**
|
|
@@ -78,13 +66,7 @@ export default class ResponseModel {
|
|
|
78
66
|
*/
|
|
79
67
|
static generate(data?: any, code?: number, message?: string): {
|
|
80
68
|
statusCode: any;
|
|
81
|
-
headers:
|
|
82
|
-
'Content-Type': string;
|
|
83
|
-
/** Required for CORS support to work */
|
|
84
|
-
'Access-Control-Allow-Origin': string;
|
|
85
|
-
/** Required for cookies, authorization headers with HTTPS */
|
|
86
|
-
'Access-Control-Allow-Credentials': boolean;
|
|
87
|
-
};
|
|
69
|
+
headers: Record<string, string>;
|
|
88
70
|
body: string;
|
|
89
71
|
};
|
|
90
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseModel.d.ts","sourceRoot":"","sources":["../../src/models/ResponseModel.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,gBAAgB
|
|
1
|
+
{"version":3,"file":"ResponseModel.d.ts","sourceRoot":"","sources":["../../src/models/ResponseModel.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAMnD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,eAAe,YAAY,CAAC;AAEzC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,aAAa;IAChC,IAAI,EAAE,GAAG,CAAC;IAEV,IAAI,EAAE,GAAG,CAAC;gBAEE,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;IAQvD;;;;;OAKG;IACH,eAAe,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG;IAIvC;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB;;;;OAIG;IACH,OAAO,CAAC,IAAI,EAAE,MAAM;IAIpB;;OAEG;IACH,OAAO;IAIP;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM;IAI1B;;OAEG;IACH,UAAU;IAIV;;OAEG;IACH,QAAQ;;;;;IAQR;;;;;;;;;OASG;IACH,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM;;;;;CAI5D"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DEFAULT_MESSAGE = exports.RESPONSE_HEADERS = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* HTTP headers to be included in
|
|
5
|
+
* HTTP headers to be included in `ResponseModel`.
|
|
6
6
|
*/
|
|
7
7
|
exports.RESPONSE_HEADERS = {
|
|
8
8
|
'Content-Type': 'application/json',
|
|
9
9
|
/** Required for CORS support to work */
|
|
10
10
|
'Access-Control-Allow-Origin': '*',
|
|
11
11
|
/** Required for cookies, authorization headers with HTTPS */
|
|
12
|
-
'Access-Control-Allow-Credentials': true,
|
|
12
|
+
'Access-Control-Allow-Credentials': 'true',
|
|
13
13
|
};
|
|
14
14
|
/**
|
|
15
15
|
* Default message provided as part of response.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ResponseModel.js","sourceRoot":"","sources":["../../src/models/ResponseModel.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,gBAAgB,
|
|
1
|
+
{"version":3,"file":"ResponseModel.js","sourceRoot":"","sources":["../../src/models/ResponseModel.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACU,QAAA,gBAAgB,GAA2B;IACtD,cAAc,EAAE,kBAAkB;IAClC,wCAAwC;IACxC,6BAA6B,EAAE,GAAG;IAClC,6DAA6D;IAC7D,kCAAkC,EAAE,MAAM;CAC3C,CAAC;AAEF;;GAEG;AACU,QAAA,eAAe,GAAG,SAAS,CAAC;AAEzC;;GA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CACF;AAzFD,gCAyFC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggerService.d.ts","sourceRoot":"","sources":["../../src/services/LoggerService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"LoggerService.d.ts","sourceRoot":"","sources":["../../src/services/LoggerService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,cAAc,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AACnC,OAAO,OAAO,MAAM,SAAS,CAAC;AAE9B,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAChE,OAAO,mBAAmB,MAAM,6BAA6B,CAAC;AAc9D;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,oBAAoB;IAC7D,OAAO,CAAC,MAAM,CAAuB;IAErC,OAAO,CAAC,OAAO,CAAwB;gBAE3B,EAAE,EAAE,mBAAmB;IA6BnC;;;;;OAKG;IACH,SAAS;IA6BT;;;;;OAKG;IACH,IAAI,MAAM,mBAMT;IAED;;OAEG;IACH,SAAS;IAIT;;;;;;;;;;;OAWG;IACH,MAAM,CAAC,iBAAiB,CAAC,KAAK,EAAE,UAAU;IAkB1C;;;;OAIG;IACH,MAAM,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG;IAUlC;;;;;OAKG;IACH,KAAK,CAAC,KAAK,EAAE,GAAG,EAAE,OAAO,SAAK;IAc9B;;;;OAIG;IACH,IAAI,CAAC,OAAO,EAAE,GAAG;IAIjB;;;;;;;;;OASG;IACH,OAAO,CAAC,KAAK,EAAE,GAAG;IAUlB;;;;;OAKG;IACH,KAAK,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,UAAQ;IAUxC;;;;;;OAMG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,MAAM,UAAQ;IAUhE;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,KAAK,GAAE,OAAO,GAAG,SAAS,GAAG,MAAe;CASjF"}
|
|
@@ -26,10 +26,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
26
26
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
27
|
};
|
|
28
28
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
const lumigo = __importStar(require("@lumigo/tracer"));
|
|
29
30
|
const Sentry = __importStar(require("@sentry/node"));
|
|
30
|
-
const epsagon_1 = __importDefault(require("epsagon"));
|
|
31
31
|
const winston_1 = __importDefault(require("winston"));
|
|
32
32
|
const DependencyAwareClass_1 = __importDefault(require("../core/DependencyAwareClass"));
|
|
33
|
+
const LambdaWrapper_1 = __importDefault(require("../core/LambdaWrapper"));
|
|
33
34
|
const sentryIsAvailable = typeof process.env.RAVEN_DSN !== 'undefined' && typeof process.env.RAVEN_DSN === 'string' && process.env.RAVEN_DSN !== 'undefined';
|
|
34
35
|
// initialise the Sentry client if available
|
|
35
36
|
if (sentryIsAvailable) {
|
|
@@ -168,12 +169,8 @@ class LoggerService extends DependencyAwareClass_1.default {
|
|
|
168
169
|
if (sentryIsAvailable && error instanceof Error) {
|
|
169
170
|
Sentry.captureException(error);
|
|
170
171
|
}
|
|
171
|
-
if (
|
|
172
|
-
|
|
173
|
-
&& typeof process.env.EPSAGON_SERVICE_NAME === 'string'
|
|
174
|
-
&& process.env.EPSAGON_SERVICE_NAME !== 'undefined'
|
|
175
|
-
&& error instanceof Error) {
|
|
176
|
-
epsagon_1.default.setError(error);
|
|
172
|
+
if (LambdaWrapper_1.default.isLumigoEnabled && error instanceof Error) {
|
|
173
|
+
lumigo.error(message || error.message, { err: error });
|
|
177
174
|
}
|
|
178
175
|
this.logger.log('error', message, { error: LoggerService.processMessage(error) });
|
|
179
176
|
this.label('error', true);
|
|
@@ -211,11 +208,8 @@ class LoggerService extends DependencyAwareClass_1.default {
|
|
|
211
208
|
* @param silent If `false`, the label will also be logged. (default: false)
|
|
212
209
|
*/
|
|
213
210
|
label(descriptor, silent = false) {
|
|
214
|
-
if (
|
|
215
|
-
|
|
216
|
-
&& typeof process.env.EPSAGON_SERVICE_NAME === 'string'
|
|
217
|
-
&& process.env.EPSAGON_SERVICE_NAME !== 'undefined') {
|
|
218
|
-
epsagon_1.default.label(descriptor, true);
|
|
211
|
+
if (LambdaWrapper_1.default.isLumigoEnabled) {
|
|
212
|
+
lumigo.addExecutionTag(descriptor, true);
|
|
219
213
|
}
|
|
220
214
|
if (!silent) {
|
|
221
215
|
this.logger.log('info', `label - ${descriptor}`);
|
|
@@ -229,11 +223,8 @@ class LoggerService extends DependencyAwareClass_1.default {
|
|
|
229
223
|
* @param silent If `false`, the metric will also be logged. (default: false)
|
|
230
224
|
*/
|
|
231
225
|
metric(descriptor, stat, silent = false) {
|
|
232
|
-
if (
|
|
233
|
-
|
|
234
|
-
&& typeof process.env.EPSAGON_SERVICE_NAME === 'string'
|
|
235
|
-
&& process.env.EPSAGON_SERVICE_NAME !== 'undefined') {
|
|
236
|
-
epsagon_1.default.label(descriptor, stat);
|
|
226
|
+
if (LambdaWrapper_1.default.isLumigoEnabled) {
|
|
227
|
+
lumigo.addExecutionTag(descriptor, stat);
|
|
237
228
|
}
|
|
238
229
|
if (silent === false) {
|
|
239
230
|
this.logger.log('info', `metric - ${descriptor} - ${stat}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LoggerService.js","sourceRoot":"","sources":["../../src/services/LoggerService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AAEvC,sDAA8B;
|
|
1
|
+
{"version":3,"file":"LoggerService.js","sourceRoot":"","sources":["../../src/services/LoggerService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAAyC;AACzC,qDAAuC;AAEvC,sDAA8B;AAE9B,wFAAgE;AAEhE,0EAAkD;AAElD,MA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I,CAAC,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE;YACnD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;SAC3C;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAEhD,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,MAAM,MAAM,OAAO,GAAG,CAAC,CAAC;IAChD,CAAC;CACF;AAzOD,gCAyOC"}
|
|
@@ -1,23 +1,28 @@
|
|
|
1
1
|
import AWS from 'aws-sdk';
|
|
2
2
|
import DependencyAwareClass from '../core/DependencyAwareClass';
|
|
3
3
|
import DependencyInjection from '../core/DependencyInjection';
|
|
4
|
+
import { LambdaWrapperConfig } from '../core/config';
|
|
4
5
|
import SQSMessageModel from '../models/SQSMessageModel';
|
|
6
|
+
import { ServiceStatus } from '../types/Status';
|
|
5
7
|
export interface SQSServiceConfig {
|
|
6
8
|
/**
|
|
7
9
|
* Maps short friendly queue names to the full SQS queue name.
|
|
8
10
|
*
|
|
9
11
|
* Usually we define queue names in our `serverless.yml` and provide them to
|
|
10
|
-
* the application via environment variables.
|
|
12
|
+
* the application via environment variables. If you haven't defined types
|
|
13
|
+
* for your env vars, you'll need to coerce them to `string`.
|
|
14
|
+
*
|
|
15
|
+
* Example:
|
|
11
16
|
*
|
|
12
17
|
* ```ts
|
|
13
18
|
* {
|
|
14
19
|
* queues: {
|
|
15
|
-
* submissions: process.env.SQS_QUEUE_SUBMISSIONS,
|
|
20
|
+
* submissions: process.env.SQS_QUEUE_SUBMISSIONS as string,
|
|
16
21
|
* }
|
|
17
22
|
* }
|
|
18
23
|
* ```
|
|
19
24
|
*/
|
|
20
|
-
queues?:
|
|
25
|
+
queues?: object;
|
|
21
26
|
/**
|
|
22
27
|
* Maps short friendly queue names to the queue consumer function name, for
|
|
23
28
|
* use with offline SQS emulation. Example:
|
|
@@ -38,6 +43,17 @@ export interface SQSServiceConfig {
|
|
|
38
43
|
export interface WithSQSServiceConfig {
|
|
39
44
|
sqs?: SQSServiceConfig;
|
|
40
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* Type of a queue name taken from the Lambda Wrapper config type.
|
|
48
|
+
*
|
|
49
|
+
* If the `sqs` config key is absent, the resulting type is `never` (since no
|
|
50
|
+
* queues are defined).
|
|
51
|
+
*/
|
|
52
|
+
export declare type QueueName<TConfig extends WithSQSServiceConfig> = TConfig extends {
|
|
53
|
+
sqs: {
|
|
54
|
+
queues: Record<infer Key, string>;
|
|
55
|
+
};
|
|
56
|
+
} ? string & Key : never;
|
|
41
57
|
/**
|
|
42
58
|
* Allowed values for `process.env.LAMBDA_WRAPPER_OFFLINE_SQS_MODE`.
|
|
43
59
|
*/
|
|
@@ -88,7 +104,7 @@ export declare const SQS_PUBLISH_FAILURE_MODES: {
|
|
|
88
104
|
* sqs: {
|
|
89
105
|
* queues: {
|
|
90
106
|
* // add an entry for each queue mapping to its AWS name
|
|
91
|
-
* submissions: process.env.SQS_QUEUE_SUBMISSIONS,
|
|
107
|
+
* submissions: process.env.SQS_QUEUE_SUBMISSIONS as string,
|
|
92
108
|
* },
|
|
93
109
|
* },
|
|
94
110
|
* });
|
|
@@ -104,14 +120,80 @@ export declare const SQS_PUBLISH_FAILURE_MODES: {
|
|
|
104
120
|
* await sqs.publish('submissions', message);
|
|
105
121
|
* });
|
|
106
122
|
* ```
|
|
123
|
+
*
|
|
124
|
+
* When using TypeScript, queue names are inferred from your Lambda Wrapper
|
|
125
|
+
* config so that IntelliSense can provide hints and TypeScript will tell you
|
|
126
|
+
* at compile-time if you try to publish to an undefined queue.
|
|
127
|
+
*
|
|
128
|
+
* ```ts
|
|
129
|
+
* // ok
|
|
130
|
+
* await sqs.publish('submissions', message);
|
|
131
|
+
*
|
|
132
|
+
* // error: Argument of type '"submission"' is not assignable to parameter of
|
|
133
|
+
* // type '"submissions"'.
|
|
134
|
+
* await sqs.publish('submission', message);
|
|
135
|
+
* ```
|
|
136
|
+
*
|
|
137
|
+
* Note that if you're passing the queue name in as a variable, you'll need to
|
|
138
|
+
* ensure the variable type is specific enough and not simply `string`. If you
|
|
139
|
+
* have a list of queue names you will need to declare it `as const`. Otherwise,
|
|
140
|
+
* use string literal types, or the `QueueName` generic type which extracts the
|
|
141
|
+
* type of all queue names from your Lambda Wrapper config.
|
|
142
|
+
*
|
|
143
|
+
* ```ts
|
|
144
|
+
* const myQueues = ['queue1', 'queue2'];
|
|
145
|
+
* for (const queue of myQueues) {
|
|
146
|
+
* // won't compile because `queue` is of type `string`
|
|
147
|
+
* await sqs.publish(queue, message);
|
|
148
|
+
* }
|
|
149
|
+
*
|
|
150
|
+
* const myQueues = ['queue1', 'queue2'] as const;
|
|
151
|
+
* for (const queue of myQueues) {
|
|
152
|
+
* // ok now because `queue` is of type `"queue1" | "queue2"`
|
|
153
|
+
* await sqs.publish(queue, message);
|
|
154
|
+
* }
|
|
155
|
+
*
|
|
156
|
+
* // you can also simply use string literal types
|
|
157
|
+
* let queue: "queue1" | "queue2";
|
|
158
|
+
*
|
|
159
|
+
* // or accept any queue defined in the config using `QueueName`
|
|
160
|
+
* let queue: QueueName<typeof lambdaWrapper.config>;
|
|
161
|
+
* ```
|
|
162
|
+
*
|
|
163
|
+
* This is all pretty cool, but the current implementation has a caveat: the
|
|
164
|
+
* `WithSQSServiceConfig` type has to be a little vague about `sqs.queues` in
|
|
165
|
+
* order to get TypeScript to infer its keys. The following config will not
|
|
166
|
+
* raise any errors itself, but is invalid and will make the `QueueName` type
|
|
167
|
+
* `never`.
|
|
168
|
+
*
|
|
169
|
+
* ```ts
|
|
170
|
+
* lambdaWrapper.configure<WithSQSServiceConfig>({
|
|
171
|
+
* sqs: {
|
|
172
|
+
* queues: {
|
|
173
|
+
* good: 'good-queue',
|
|
174
|
+
* bad: 0, // oops, not a string, but no errors here!
|
|
175
|
+
* },
|
|
176
|
+
* },
|
|
177
|
+
* });
|
|
178
|
+
*
|
|
179
|
+
* // even though this is queue has valid config, the invalid one breaks it:
|
|
180
|
+
* // Argument of type 'string' is not assignable to parameter of type 'never'.
|
|
181
|
+
* await sqs.publish('good', message);
|
|
182
|
+
* ```
|
|
183
|
+
*
|
|
184
|
+
* If you start getting _not assignable to parameter of type 'never'_ errors on
|
|
185
|
+
* all your `SQSService` method calls, double-check that your config is correct.
|
|
186
|
+
* Be particularly careful with environment variables – by default they have
|
|
187
|
+
* type `string | undefined`. In the first example at the top of this page, a
|
|
188
|
+
* type assertion was used to coerce this to `string`.
|
|
107
189
|
*/
|
|
108
|
-
export default class SQSService extends DependencyAwareClass {
|
|
109
|
-
readonly queues: Record<
|
|
110
|
-
readonly queueConsumers: Record<
|
|
111
|
-
readonly queueUrls: Record<
|
|
190
|
+
export default class SQSService<TConfig extends LambdaWrapperConfig & WithSQSServiceConfig = any> extends DependencyAwareClass {
|
|
191
|
+
readonly queues: Record<QueueName<TConfig>, string>;
|
|
192
|
+
readonly queueConsumers: Record<QueueName<TConfig>, string>;
|
|
193
|
+
readonly queueUrls: Record<QueueName<TConfig>, string>;
|
|
112
194
|
private $sqs?;
|
|
113
195
|
private $lambda?;
|
|
114
|
-
constructor(di: DependencyInjection);
|
|
196
|
+
constructor(di: DependencyInjection<TConfig>);
|
|
115
197
|
/**
|
|
116
198
|
* Returns an SQS client instance
|
|
117
199
|
*/
|
|
@@ -133,17 +215,17 @@ export default class SQSService extends DependencyAwareClass {
|
|
|
133
215
|
* @param queue
|
|
134
216
|
* @param messageModels
|
|
135
217
|
*/
|
|
136
|
-
batchDelete(queue:
|
|
218
|
+
batchDelete(queue: QueueName<TConfig>, messageModels: SQSMessageModel[]): Promise<void>;
|
|
137
219
|
/**
|
|
138
220
|
* Check SQS status.
|
|
139
221
|
*/
|
|
140
|
-
checkStatus(): Promise<
|
|
222
|
+
checkStatus(): Promise<ServiceStatus>;
|
|
141
223
|
/**
|
|
142
224
|
* Get the approximate number of messages in a queue.
|
|
143
225
|
*
|
|
144
226
|
* @param queue
|
|
145
227
|
*/
|
|
146
|
-
getMessageCount(queue:
|
|
228
|
+
getMessageCount(queue: QueueName<TConfig>): Promise<number>;
|
|
147
229
|
/**
|
|
148
230
|
* Publish to message queue.
|
|
149
231
|
*
|
|
@@ -158,7 +240,7 @@ export default class SQSService extends DependencyAwareClass {
|
|
|
158
240
|
* - `catch`: errors will be caught and logged. This is the default.
|
|
159
241
|
* - `throw`: errors will be thrown, causing promise to reject.
|
|
160
242
|
*/
|
|
161
|
-
publish(queue:
|
|
243
|
+
publish(queue: QueueName<TConfig>, messageObject: object, messageGroupId?: null, failureMode?: 'catch' | 'throw'): Promise<QueueName<TConfig> | null>;
|
|
162
244
|
/**
|
|
163
245
|
* Sends a message to a queue consumer running in serverless-offline.
|
|
164
246
|
*
|
|
@@ -169,13 +251,13 @@ export default class SQSService extends DependencyAwareClass {
|
|
|
169
251
|
* @param queue
|
|
170
252
|
* @param messageParameters
|
|
171
253
|
*/
|
|
172
|
-
publishOffline(queue:
|
|
254
|
+
publishOffline(queue: QueueName<TConfig>, messageParameters: AWS.SQS.SendMessageRequest): Promise<void>;
|
|
173
255
|
/**
|
|
174
256
|
* Receive from message queue
|
|
175
257
|
*
|
|
176
258
|
* @param queue string
|
|
177
259
|
* @param timeout number
|
|
178
260
|
*/
|
|
179
|
-
receive(queue:
|
|
261
|
+
receive(queue: QueueName<TConfig>, timeout?: number): Promise<SQSMessageModel[]>;
|
|
180
262
|
}
|
|
181
263
|
//# sourceMappingURL=SQSService.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQSService.d.ts","sourceRoot":"","sources":["../../src/services/SQSService.ts"],"names":[],"mappings":"AAEA,OAAO,GAAG,MAAM,SAAS,CAAC;AAG1B,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAChE,OAAO,mBAAmB,MAAM,6BAA6B,CAAC;AAC9D,OAAO,eAAe,MAAM,2BAA2B,CA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eAAe,EAAE,CAAC;CAgC7E"}
|
|
@@ -1,27 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
@@ -33,7 +10,6 @@ const aws_sdk_1 = __importDefault(require("aws-sdk"));
|
|
|
33
10
|
const uuid_1 = require("uuid");
|
|
34
11
|
const DependencyAwareClass_1 = __importDefault(require("../core/DependencyAwareClass"));
|
|
35
12
|
const SQSMessageModel_1 = __importDefault(require("../models/SQSMessageModel"));
|
|
36
|
-
const StatusModel_1 = __importStar(require("../models/StatusModel"));
|
|
37
13
|
const LoggerService_1 = __importDefault(require("./LoggerService"));
|
|
38
14
|
const TimerService_1 = __importDefault(require("./TimerService"));
|
|
39
15
|
/**
|
|
@@ -86,7 +62,7 @@ exports.SQS_PUBLISH_FAILURE_MODES = {
|
|
|
86
62
|
* sqs: {
|
|
87
63
|
* queues: {
|
|
88
64
|
* // add an entry for each queue mapping to its AWS name
|
|
89
|
-
* submissions: process.env.SQS_QUEUE_SUBMISSIONS,
|
|
65
|
+
* submissions: process.env.SQS_QUEUE_SUBMISSIONS as string,
|
|
90
66
|
* },
|
|
91
67
|
* },
|
|
92
68
|
* });
|
|
@@ -102,6 +78,72 @@ exports.SQS_PUBLISH_FAILURE_MODES = {
|
|
|
102
78
|
* await sqs.publish('submissions', message);
|
|
103
79
|
* });
|
|
104
80
|
* ```
|
|
81
|
+
*
|
|
82
|
+
* When using TypeScript, queue names are inferred from your Lambda Wrapper
|
|
83
|
+
* config so that IntelliSense can provide hints and TypeScript will tell you
|
|
84
|
+
* at compile-time if you try to publish to an undefined queue.
|
|
85
|
+
*
|
|
86
|
+
* ```ts
|
|
87
|
+
* // ok
|
|
88
|
+
* await sqs.publish('submissions', message);
|
|
89
|
+
*
|
|
90
|
+
* // error: Argument of type '"submission"' is not assignable to parameter of
|
|
91
|
+
* // type '"submissions"'.
|
|
92
|
+
* await sqs.publish('submission', message);
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* Note that if you're passing the queue name in as a variable, you'll need to
|
|
96
|
+
* ensure the variable type is specific enough and not simply `string`. If you
|
|
97
|
+
* have a list of queue names you will need to declare it `as const`. Otherwise,
|
|
98
|
+
* use string literal types, or the `QueueName` generic type which extracts the
|
|
99
|
+
* type of all queue names from your Lambda Wrapper config.
|
|
100
|
+
*
|
|
101
|
+
* ```ts
|
|
102
|
+
* const myQueues = ['queue1', 'queue2'];
|
|
103
|
+
* for (const queue of myQueues) {
|
|
104
|
+
* // won't compile because `queue` is of type `string`
|
|
105
|
+
* await sqs.publish(queue, message);
|
|
106
|
+
* }
|
|
107
|
+
*
|
|
108
|
+
* const myQueues = ['queue1', 'queue2'] as const;
|
|
109
|
+
* for (const queue of myQueues) {
|
|
110
|
+
* // ok now because `queue` is of type `"queue1" | "queue2"`
|
|
111
|
+
* await sqs.publish(queue, message);
|
|
112
|
+
* }
|
|
113
|
+
*
|
|
114
|
+
* // you can also simply use string literal types
|
|
115
|
+
* let queue: "queue1" | "queue2";
|
|
116
|
+
*
|
|
117
|
+
* // or accept any queue defined in the config using `QueueName`
|
|
118
|
+
* let queue: QueueName<typeof lambdaWrapper.config>;
|
|
119
|
+
* ```
|
|
120
|
+
*
|
|
121
|
+
* This is all pretty cool, but the current implementation has a caveat: the
|
|
122
|
+
* `WithSQSServiceConfig` type has to be a little vague about `sqs.queues` in
|
|
123
|
+
* order to get TypeScript to infer its keys. The following config will not
|
|
124
|
+
* raise any errors itself, but is invalid and will make the `QueueName` type
|
|
125
|
+
* `never`.
|
|
126
|
+
*
|
|
127
|
+
* ```ts
|
|
128
|
+
* lambdaWrapper.configure<WithSQSServiceConfig>({
|
|
129
|
+
* sqs: {
|
|
130
|
+
* queues: {
|
|
131
|
+
* good: 'good-queue',
|
|
132
|
+
* bad: 0, // oops, not a string, but no errors here!
|
|
133
|
+
* },
|
|
134
|
+
* },
|
|
135
|
+
* });
|
|
136
|
+
*
|
|
137
|
+
* // even though this is queue has valid config, the invalid one breaks it:
|
|
138
|
+
* // Argument of type 'string' is not assignable to parameter of type 'never'.
|
|
139
|
+
* await sqs.publish('good', message);
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* If you start getting _not assignable to parameter of type 'never'_ errors on
|
|
143
|
+
* all your `SQSService` method calls, double-check that your config is correct.
|
|
144
|
+
* Be particularly careful with environment variables – by default they have
|
|
145
|
+
* type `string | undefined`. In the first example at the top of this page, a
|
|
146
|
+
* type assertion was used to coerce this to `string`.
|
|
105
147
|
*/
|
|
106
148
|
class SQSService extends DependencyAwareClass_1.default {
|
|
107
149
|
constructor(di) {
|
|
@@ -216,15 +258,18 @@ class SQSService extends DependencyAwareClass_1.default {
|
|
|
216
258
|
timer.start(timerId);
|
|
217
259
|
this.sqs.listQueues({}, (error, data) => {
|
|
218
260
|
timer.stop(timerId);
|
|
219
|
-
|
|
261
|
+
let status = 'OK';
|
|
220
262
|
if (error) {
|
|
221
263
|
logger.error(error);
|
|
222
|
-
|
|
264
|
+
status = 'APPLICATION_FAILURE';
|
|
223
265
|
}
|
|
224
266
|
if (typeof data.QueueUrls === 'undefined' || data.QueueUrls.length === 0) {
|
|
225
|
-
|
|
267
|
+
status = 'APPLICATION_FAILURE';
|
|
226
268
|
}
|
|
227
|
-
resolve(
|
|
269
|
+
resolve({
|
|
270
|
+
service: 'SQS',
|
|
271
|
+
status,
|
|
272
|
+
});
|
|
228
273
|
});
|
|
229
274
|
});
|
|
230
275
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SQSService.js","sourceRoot":"","sources":["../../src/services/SQSService.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"SQSService.js","sourceRoot":"","sources":["../../src/services/SQSService.ts"],"names":[],"mappings":";;;;;;AAAA,gDAAwB;AACxB,iCAA6B;AAC7B,sDAA0B;AAC1B,+BAAkC;AAElC,wFAAgE;AAGhE,gFAAwD;AAExD,oEAA4C;AAC5C,kEAA0C;AAsD1C;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B;;;;OAIG;IACH,MAAM,EAAE,QAAQ;IAEhB;;;OAGG;IACH,KAAK,EAAE,OAAO;IAEd;;OAEG;IACH,GAAG,EAAE,KAAK;CACX,CAAC;AAEF;;;GAGG;AACU,QAAA,yBAAyB,GAAG;IACvC;;;;;OAKG;IACH,KAAK,EAAE,OAAO;IAEd;;OAEG;IACH,KAAK,EAAE,OAAO;CACN,CAAC;AAEX;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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MAAM,CAAC,KAAK,CAAC,CAAC;iBACtB;gBAED,IAAI,OAAO,IAAI,CAAC,QAAQ,KAAK,WAAW,EAAE;oBACxC,OAAO,OAAO,CAAC,EAAE,CAAC,CAAC;iBACpB;gBAED,OAAO,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAI,yBAAe,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YAC/E,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AA1VD,6BA0VC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Status.d.ts","sourceRoot":"","sources":["../../src/types/Status.ts"],"names":[],"mappings":"AAAA,oBAAY,MAAM,GACd,IAAI,GACJ,oBAAoB,GACpB,qBAAqB,CAAC;AAE1B,oBAAY,aAAa,GAAG;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Status.js","sourceRoot":"","sources":["../../src/types/Status.ts"],"names":[],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@comicrelief/lambda-wrapper",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.10",
|
|
4
4
|
"description": "Lambda wrapper for all Comic Relief Serverless Projects",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"author": "Adam Clark",
|
|
@@ -23,40 +23,40 @@
|
|
|
23
23
|
"devDependencies": {
|
|
24
24
|
"@comicrelief/eslint-config": "^2.0.3",
|
|
25
25
|
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
|
26
|
-
"@types/async": "^3.2.
|
|
27
|
-
"@types/
|
|
28
|
-
"@types/jest": "^28.1.6",
|
|
26
|
+
"@types/async": "^3.2.20",
|
|
27
|
+
"@types/jest": "^29.5.4",
|
|
29
28
|
"@types/node": "14",
|
|
30
|
-
"@types/useragent": "^2.3.
|
|
31
|
-
"@types/uuid": "^
|
|
32
|
-
"@types/xml2js": "^0.4.
|
|
29
|
+
"@types/useragent": "^2.3.2",
|
|
30
|
+
"@types/uuid": "^9.0.3",
|
|
31
|
+
"@types/xml2js": "^0.4.12",
|
|
33
32
|
"@typescript-eslint/eslint-plugin": "^5.33.0",
|
|
34
33
|
"@typescript-eslint/parser": "^5.33.0",
|
|
35
|
-
"aws-sdk": "^2.
|
|
36
|
-
"eslint": "^8.
|
|
34
|
+
"aws-sdk": "^2.1456.0",
|
|
35
|
+
"eslint": "^8.49.0",
|
|
37
36
|
"eslint-plugin-import": "^2.25.2",
|
|
38
37
|
"eslint-plugin-jsdoc": "^39.3.2",
|
|
39
|
-
"jest": "^
|
|
38
|
+
"jest": "^29.7.0",
|
|
40
39
|
"nyc": "^15.1.0",
|
|
41
|
-
"semantic-release": "^19.0.
|
|
42
|
-
"ts-jest": "^
|
|
40
|
+
"semantic-release": "^19.0.5",
|
|
41
|
+
"ts-jest": "^29.1.1",
|
|
43
42
|
"ts-node": "^10.9.1",
|
|
44
|
-
"tsconfig-paths": "^4.
|
|
43
|
+
"tsconfig-paths": "^4.2.0",
|
|
45
44
|
"typescript": "^4.7.4"
|
|
46
45
|
},
|
|
47
46
|
"peerDependencies": {
|
|
48
47
|
"aws-sdk": "^2.831.0"
|
|
49
48
|
},
|
|
50
49
|
"dependencies": {
|
|
50
|
+
"@lumigo/tracer": "^1.87.0",
|
|
51
51
|
"@sentry/node": "^6.0.1",
|
|
52
|
+
"@types/aws-lambda": "^8.10.120",
|
|
52
53
|
"alai": "1.0.3",
|
|
53
54
|
"async": "^3.2.4",
|
|
54
55
|
"axios": "^0.27.2",
|
|
55
|
-
"epsagon": "^1.123.2",
|
|
56
56
|
"useragent": "2.3.0",
|
|
57
|
-
"uuid": "^
|
|
57
|
+
"uuid": "^9.0.1",
|
|
58
58
|
"validate.js": "0.13.1",
|
|
59
|
-
"winston": "^3.
|
|
60
|
-
"xml2js": "^0.
|
|
59
|
+
"winston": "^3.10.0",
|
|
60
|
+
"xml2js": "^0.6.2"
|
|
61
61
|
}
|
|
62
62
|
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
export declare const STATUS_TYPES: {
|
|
2
|
-
OK: string;
|
|
3
|
-
ACCEPTABLE_FAILURE: string;
|
|
4
|
-
APPLICATION_FAILURE: string;
|
|
5
|
-
};
|
|
6
|
-
/**
|
|
7
|
-
* Model for our status check endpoints.
|
|
8
|
-
*/
|
|
9
|
-
export default class StatusModel {
|
|
10
|
-
/**
|
|
11
|
-
* Service name.
|
|
12
|
-
*/
|
|
13
|
-
service: string;
|
|
14
|
-
/**
|
|
15
|
-
* One of the `STATUS_TYPES` values.
|
|
16
|
-
*/
|
|
17
|
-
status: string;
|
|
18
|
-
constructor(service: string, status: string);
|
|
19
|
-
/**
|
|
20
|
-
* Get the service name.
|
|
21
|
-
*/
|
|
22
|
-
getService(): string;
|
|
23
|
-
/**
|
|
24
|
-
* Set the service name.
|
|
25
|
-
*
|
|
26
|
-
* @param service
|
|
27
|
-
*/
|
|
28
|
-
setService(service: string): void;
|
|
29
|
-
/**
|
|
30
|
-
* Set the status.
|
|
31
|
-
*
|
|
32
|
-
* @param status
|
|
33
|
-
*/
|
|
34
|
-
setStatus(status: string): void;
|
|
35
|
-
/**
|
|
36
|
-
* Get the status.
|
|
37
|
-
*/
|
|
38
|
-
getStatus(): string;
|
|
39
|
-
}
|
|
40
|
-
//# sourceMappingURL=StatusModel.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StatusModel.d.ts","sourceRoot":"","sources":["../../src/models/StatusModel.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;CAIxB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;IAC9B;;OAEG;IACH,OAAO,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC;gBAEH,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IAK3C;;OAEG;IACH,UAAU,IAAI,MAAM;IAIpB;;;;OAIG;IACH,UAAU,CAAC,OAAO,EAAE,MAAM;IAI1B;;;;OAIG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM;IAQxB;;OAEG;IACH,SAAS,IAAI,MAAM;CAGpB"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.STATUS_TYPES = void 0;
|
|
4
|
-
exports.STATUS_TYPES = {
|
|
5
|
-
OK: 'OK',
|
|
6
|
-
ACCEPTABLE_FAILURE: 'ACCEPTABLE_FAILURE',
|
|
7
|
-
APPLICATION_FAILURE: 'APPLICATION_FAILURE',
|
|
8
|
-
};
|
|
9
|
-
/**
|
|
10
|
-
* Model for our status check endpoints.
|
|
11
|
-
*/
|
|
12
|
-
class StatusModel {
|
|
13
|
-
constructor(service, status) {
|
|
14
|
-
this.service = service;
|
|
15
|
-
this.status = status;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Get the service name.
|
|
19
|
-
*/
|
|
20
|
-
getService() {
|
|
21
|
-
return this.service;
|
|
22
|
-
}
|
|
23
|
-
/**
|
|
24
|
-
* Set the service name.
|
|
25
|
-
*
|
|
26
|
-
* @param service
|
|
27
|
-
*/
|
|
28
|
-
setService(service) {
|
|
29
|
-
this.service = service;
|
|
30
|
-
}
|
|
31
|
-
/**
|
|
32
|
-
* Set the status.
|
|
33
|
-
*
|
|
34
|
-
* @param status
|
|
35
|
-
*/
|
|
36
|
-
setStatus(status) {
|
|
37
|
-
if (!(status in exports.STATUS_TYPES)) {
|
|
38
|
-
throw new TypeError(`${StatusModel.name} - ${status} is not a valid status type`);
|
|
39
|
-
}
|
|
40
|
-
this.status = status;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Get the status.
|
|
44
|
-
*/
|
|
45
|
-
getStatus() {
|
|
46
|
-
return this.status;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
exports.default = StatusModel;
|
|
50
|
-
//# sourceMappingURL=StatusModel.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"StatusModel.js","sourceRoot":"","sources":["../../src/models/StatusModel.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IAC1B,EAAE,EAAE,IAAI;IACR,kBAAkB,EAAE,oBAAoB;IACxC,mBAAmB,EAAE,qBAAqB;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAqB,WAAW;IAW9B,YAAY,OAAe,EAAE,MAAc;QACzC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;;;OAIG;IACH,UAAU,CAAC,OAAe;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACH,SAAS,CAAC,MAAc;QACtB,IAAI,CAAC,CAAC,MAAM,IAAI,oBAAY,CAAC,EAAE;YAC7B,MAAM,IAAI,SAAS,CAAC,GAAG,WAAW,CAAC,IAAI,MAAM,MAAM,6BAA6B,CAAC,CAAC;SACnF;QAED,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;CACF;AAnDD,8BAmDC"}
|