@comicrelief/lambda-wrapper 1.10.1 → 2.0.0-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/README.md +172 -47
  2. package/dist/core/DependencyAwareClass.d.ts +15 -0
  3. package/dist/core/DependencyAwareClass.d.ts.map +1 -0
  4. package/dist/core/DependencyAwareClass.js +20 -0
  5. package/dist/core/DependencyAwareClass.js.map +1 -0
  6. package/dist/core/DependencyInjection.d.ts +62 -0
  7. package/dist/core/DependencyInjection.d.ts.map +1 -0
  8. package/dist/core/DependencyInjection.js +83 -0
  9. package/dist/core/DependencyInjection.js.map +1 -0
  10. package/dist/core/LambdaWrapper.d.ts +61 -0
  11. package/dist/core/LambdaWrapper.d.ts.map +1 -0
  12. package/dist/core/LambdaWrapper.js +126 -0
  13. package/dist/core/LambdaWrapper.js.map +1 -0
  14. package/dist/core/config.d.ts +20 -0
  15. package/dist/core/config.d.ts.map +1 -0
  16. package/dist/core/config.js +21 -0
  17. package/dist/core/config.js.map +1 -0
  18. package/dist/index.d.ts +28 -0
  19. package/dist/index.d.ts.map +1 -0
  20. package/dist/index.js +59 -162
  21. package/dist/index.js.map +1 -0
  22. package/dist/models/ResponseModel.d.ts +91 -0
  23. package/dist/models/ResponseModel.d.ts.map +1 -0
  24. package/dist/models/ResponseModel.js +100 -0
  25. package/dist/models/ResponseModel.js.map +1 -0
  26. package/dist/models/SQSMessageModel.d.ts +46 -0
  27. package/dist/models/SQSMessageModel.d.ts.map +1 -0
  28. package/dist/models/SQSMessageModel.js +65 -0
  29. package/dist/models/SQSMessageModel.js.map +1 -0
  30. package/dist/models/StatusModel.d.ts +40 -0
  31. package/dist/models/StatusModel.d.ts.map +1 -0
  32. package/dist/models/StatusModel.js +50 -0
  33. package/dist/models/StatusModel.js.map +1 -0
  34. package/dist/services/BaseConfigService.d.ts +101 -0
  35. package/dist/services/BaseConfigService.d.ts.map +1 -0
  36. package/dist/services/BaseConfigService.js +180 -0
  37. package/dist/services/BaseConfigService.js.map +1 -0
  38. package/dist/services/HTTPService.d.ts +29 -0
  39. package/dist/services/HTTPService.d.ts.map +1 -0
  40. package/dist/services/HTTPService.js +55 -0
  41. package/dist/services/HTTPService.js.map +1 -0
  42. package/dist/services/LoggerService.d.ts +102 -0
  43. package/dist/services/LoggerService.d.ts.map +1 -0
  44. package/dist/services/LoggerService.js +258 -0
  45. package/dist/services/LoggerService.js.map +1 -0
  46. package/dist/services/RequestService.d.ts +119 -0
  47. package/dist/services/RequestService.d.ts.map +1 -0
  48. package/dist/services/RequestService.js +293 -0
  49. package/dist/services/RequestService.js.map +1 -0
  50. package/dist/services/SQSService.d.ts +181 -0
  51. package/dist/services/SQSService.d.ts.map +1 -0
  52. package/dist/services/SQSService.js +366 -0
  53. package/dist/services/SQSService.js.map +1 -0
  54. package/dist/services/TimerService.d.ts +22 -0
  55. package/dist/services/TimerService.d.ts.map +1 -0
  56. package/dist/services/TimerService.js +40 -0
  57. package/dist/services/TimerService.js.map +1 -0
  58. package/dist/utils/LambdaTermination.d.ts +14 -0
  59. package/dist/utils/LambdaTermination.d.ts.map +1 -0
  60. package/dist/utils/LambdaTermination.js +23 -0
  61. package/dist/utils/LambdaTermination.js.map +1 -0
  62. package/dist/utils/PromisifiedDelay.d.ts +17 -0
  63. package/dist/utils/PromisifiedDelay.d.ts.map +1 -0
  64. package/dist/utils/PromisifiedDelay.js +48 -0
  65. package/dist/utils/PromisifiedDelay.js.map +1 -0
  66. package/package.json +29 -19
  67. package/.eslintrc.yml +0 -16
  68. package/.github/dependabot.yml +0 -11
  69. package/.github/workflows/main.yml +0 -74
  70. package/babel.config.js +0 -13
  71. package/dist/Config/Dependencies.js +0 -40
  72. package/dist/DependencyInjection/DependencyAware.class.js +0 -47
  73. package/dist/DependencyInjection/DependencyInjection.class.js +0 -131
  74. package/dist/Model/CloudEvent.model.js +0 -156
  75. package/dist/Model/Model.model.js +0 -45
  76. package/dist/Model/Response.model.js +0 -150
  77. package/dist/Model/SQS/MarketingPreference.constraints.json +0 -28
  78. package/dist/Model/SQS/MarketingPreference.model.js +0 -641
  79. package/dist/Model/SQS/Message.model.js +0 -104
  80. package/dist/Model/Status.model.js +0 -82
  81. package/dist/Service/BaseConfig.service.js +0 -225
  82. package/dist/Service/HTTP.service.js +0 -70
  83. package/dist/Service/Logger.service.js +0 -293
  84. package/dist/Service/Request.service.js +0 -341
  85. package/dist/Service/SQS.service.js +0 -420
  86. package/dist/Service/Timer.service.js +0 -55
  87. package/dist/Wrapper/LambdaTermination.js +0 -39
  88. package/dist/Wrapper/LambdaWrapper.js +0 -164
  89. package/dist/Wrapper/PromisifiedDelay.js +0 -59
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RequestService.js","sourceRoot":"","sources":["../../src/services/RequestService.ts"],"names":[],"mappings":";;;;;;AAAA,8DAAsC;AAGtC,0DAAkC;AAClC,oEAA4C;AAC5C,oDAA4B;AAE5B,wFAAgE;AAChE,4EAAoD;AACpD,oEAA4C;AAE/B,QAAA,aAAa,GAAG;IAC3B,MAAM,EAAE,QAAQ;IAChB,GAAG,EAAE,KAAK;IACV,IAAI,EAAE,MAAM;IACZ,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,OAAO;IACd,IAAI,EAAE,MAAM;IACZ,GAAG,EAAE,KAAK;CACX,CAAC;AAEW,QAAA,6BAA6B,GAAG;IAC3C,qBAAa,CAAC,MAAM;IACpB,qBAAa,CAAC,GAAG;IACjB,qBAAa,CAAC,IAAI;IAClB,qBAAa,CAAC,OAAO;CACtB,CAAC;AAEW,QAAA,0BAA0B,GAAG;IACxC,qBAAa,CAAC,KAAK;IACnB,qBAAa,CAAC,IAAI;IAClB,qBAAa,CAAC,GAAG;CAClB,CAAC;AAEF,qCAAqC;AACxB,QAAA,WAAW,GAAG;IACzB,gBAAgB,EAAE,IAAI,uBAAa,CAAC,EAAE,EAAE,GAAG,EAAE,6BAA6B,CAAC;CAC5E,CAAC;AASF;;G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M,CAAC;IAChB,CAAC;IAED;;OAEG;IACH,aAAa;QACX,MAAM,KAAK,GAAG,IAAI,CAAC,YAAY,EAAE,CAAC,QAAQ,EAAE,CAAC;QAC7C,MAAM,WAAW,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;QAEtD,IAAI,OAAO,KAAK,CAAC,OAAO,KAAK,WAAW,IAAI,OAAO,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,WAAW,IAAI,OAAO,WAAW,CAAC,WAAW,KAAK,WAAW,EAAE;YACrI,OAAO,WAAW,CAAC;SACpB;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,uBAAuB,CAAC,MAA0C,EAAE,GAAW;QACpF,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC;aACjC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,iBAAiB,EAAE,KAAK,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC;QAC9E,OAAO,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAC,KAA2B;QAC5C,OAAO,IAAI,CAAC,uBAAuB,CAAC,KAAK,CAAC,OAAO,EAAE,cAAc,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;IACtF,CAAC;CACF;AAtSD,iCAsSC"}
@@ -0,0 +1,181 @@
1
+ import AWS from 'aws-sdk';
2
+ import DependencyAwareClass from '../core/DependencyAwareClass';
3
+ import DependencyInjection from '../core/DependencyInjection';
4
+ import SQSMessageModel from '../models/SQSMessageModel';
5
+ export interface SQSServiceConfig {
6
+ /**
7
+ * Maps short friendly queue names to the full SQS queue name.
8
+ *
9
+ * Usually we define queue names in our `serverless.yml` and provide them to
10
+ * the application via environment variables. Example:
11
+ *
12
+ * ```ts
13
+ * {
14
+ * queues: {
15
+ * submissions: process.env.SQS_QUEUE_SUBMISSIONS,
16
+ * }
17
+ * }
18
+ * ```
19
+ */
20
+ queues?: Record<string, string>;
21
+ /**
22
+ * Maps short friendly queue names to the queue consumer function name, for
23
+ * use with offline SQS emulation. Example:
24
+ *
25
+ * ```ts
26
+ * {
27
+ * queueConsumers: {
28
+ * submissions: 'SubmissionConsumer',
29
+ * }
30
+ * }
31
+ * ```
32
+ *
33
+ * See the [SQSService docs](../../docs/services/SQSService.md) for details
34
+ * about how this works.
35
+ */
36
+ queueConsumers?: Record<string, string>;
37
+ }
38
+ export interface WithSQSServiceConfig {
39
+ sqs?: SQSServiceConfig;
40
+ }
41
+ /**
42
+ * Allowed values for `process.env.LAMBDA_WRAPPER_OFFLINE_SQS_MODE`.
43
+ */
44
+ export declare const SQS_OFFLINE_MODES: {
45
+ /**
46
+ * When running offline, messages will trigger the consumer function directly
47
+ * via a Lambda endpoint, set using `process.env.SERVICE_LAMBDA_URL`. This is
48
+ * the default.
49
+ */
50
+ DIRECT: string;
51
+ /**
52
+ * When running offline, send messages to an offline SQS service defined by
53
+ * `process.env.LAMBDA_WRAPPER_OFFLINE_SQS_HOST`.
54
+ */
55
+ LOCAL: string;
56
+ /**
57
+ * When running offline, send messages to AWS as normal.
58
+ */
59
+ AWS: string;
60
+ };
61
+ /**
62
+ * Defines the preferred behaviour for `SQSService.prototype.send` in case the
63
+ * AWS SQS call fails.
64
+ */
65
+ export declare const SQS_PUBLISH_FAILURE_MODES: {
66
+ /**
67
+ * Catch the exception and logs it.
68
+ *
69
+ * This is the default behaviour for Lambda Wrapper v1.8.0 and below and for
70
+ * Lambda Wrapper v1.8.2 and above.
71
+ */
72
+ readonly CATCH: "catch";
73
+ /**
74
+ * Throw the exception so that the caller can handle it directly.
75
+ */
76
+ readonly THROW: "throw";
77
+ };
78
+ /**
79
+ * Helper service for working with SQS.
80
+ *
81
+ * Config for this service goes in the `sqs` key of your Lambda Wrapper config.
82
+ * The `queues` key maps short friendly names to the full SQS queue name.
83
+ * Usually we define queue names in our `serverless.yml` and provide them to
84
+ * the application via environment variables.
85
+ *
86
+ * ```ts
87
+ * const lambdaWrapper = lw.configure({
88
+ * sqs: {
89
+ * queues: {
90
+ * // add an entry for each queue mapping to its AWS name
91
+ * submissions: process.env.SQS_QUEUE_SUBMISSIONS,
92
+ * },
93
+ * },
94
+ * });
95
+ * ```
96
+ *
97
+ * You can then send messages to a queue within your Lambda handler using the
98
+ * `publish` method.
99
+ *
100
+ * ```ts
101
+ * export default lambdaWrapper.wrap(async (di) => {
102
+ * const sqs = di.get(SQSService);
103
+ * const message = { data: 'Hello SQS!' };
104
+ * await sqs.publish('submissions', message);
105
+ * });
106
+ * ```
107
+ */
108
+ export default class SQSService extends DependencyAwareClass {
109
+ readonly queues: Record<string, string>;
110
+ readonly queueConsumers: Record<string, string>;
111
+ readonly queueUrls: Record<string, string>;
112
+ private $sqs?;
113
+ private $lambda?;
114
+ constructor(di: DependencyInjection);
115
+ /**
116
+ * Returns an SQS client instance
117
+ */
118
+ get sqs(): AWS.SQS;
119
+ /**
120
+ * Returns a Lambda client instance
121
+ */
122
+ get lambda(): AWS.Lambda;
123
+ /**
124
+ * Returns the mode to use for offline SQS.
125
+ *
126
+ * This is configured by `process.env.LAMBDA_WRAPPER_OFFLINE_SQS_MODE`. The
127
+ * default is `SQS_OFFLINE_MODES.LAMBDA`.
128
+ */
129
+ static get offlineMode(): string;
130
+ /**
131
+ * Batch delete messages.
132
+ *
133
+ * @param queue
134
+ * @param messageModels
135
+ */
136
+ batchDelete(queue: string, messageModels: SQSMessageModel[]): Promise<void>;
137
+ /**
138
+ * Check SQS status.
139
+ */
140
+ checkStatus(): Promise<unknown>;
141
+ /**
142
+ * Get the approximate number of messages in a queue.
143
+ *
144
+ * @param queue
145
+ */
146
+ getMessageCount(queue: string): Promise<number>;
147
+ /**
148
+ * Publish to message queue.
149
+ *
150
+ * When running within serverless-offline, messages can be published to a
151
+ * local Lambda or SQS service instead of to AWS, depending on the offline
152
+ * mode specified by `process.env.LAMBDA_WRAPPER_OFFLINE_SQS_MODE`.
153
+ *
154
+ * @param queue string
155
+ * @param messageObject object
156
+ * @param messageGroupId string
157
+ * @param failureMode Choose how failures are handled:
158
+ * - `catch`: errors will be caught and logged. This is the default.
159
+ * - `throw`: errors will be thrown, causing promise to reject.
160
+ */
161
+ publish(queue: string, messageObject: object, messageGroupId?: null, failureMode?: 'catch' | 'throw'): Promise<string | null>;
162
+ /**
163
+ * Sends a message to a queue consumer running in serverless-offline.
164
+ *
165
+ * This method invokes the consumer function directly instead of sending the
166
+ * message to SQS, which requires a real or emulated SQS service not provided
167
+ * by serverless-offline. This works very well for local testing.
168
+ *
169
+ * @param queue
170
+ * @param messageParameters
171
+ */
172
+ publishOffline(queue: string, messageParameters: AWS.SQS.SendMessageRequest): Promise<void>;
173
+ /**
174
+ * Receive from message queue
175
+ *
176
+ * @param queue string
177
+ * @param timeout number
178
+ */
179
+ receive(queue: string, timeout?: number): Promise<SQSMessageModel[]>;
180
+ }
181
+ //# sourceMappingURL=SQSService.d.ts.map
@@ -0,0 +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,CAAC;AAKxD,MAAM,WAAW,gBAAgB;IAC/B;;;;;;;;;;;;;OAaG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC;;;;;;;;;;;;;;OAcG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,EAAE,gBAAgB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ACH,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,SAAK,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CAgCjE"}
@@ -0,0 +1,366 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.SQS_PUBLISH_FAILURE_MODES = exports.SQS_OFFLINE_MODES = void 0;
30
+ const alai_1 = __importDefault(require("alai"));
31
+ const async_1 = require("async");
32
+ const aws_sdk_1 = __importDefault(require("aws-sdk"));
33
+ const uuid_1 = require("uuid");
34
+ const DependencyAwareClass_1 = __importDefault(require("../core/DependencyAwareClass"));
35
+ const SQSMessageModel_1 = __importDefault(require("../models/SQSMessageModel"));
36
+ const StatusModel_1 = __importStar(require("../models/StatusModel"));
37
+ const LoggerService_1 = __importDefault(require("./LoggerService"));
38
+ const TimerService_1 = __importDefault(require("./TimerService"));
39
+ /**
40
+ * Allowed values for `process.env.LAMBDA_WRAPPER_OFFLINE_SQS_MODE`.
41
+ */
42
+ exports.SQS_OFFLINE_MODES = {
43
+ /**
44
+ * When running offline, messages will trigger the consumer function directly
45
+ * via a Lambda endpoint, set using `process.env.SERVICE_LAMBDA_URL`. This is
46
+ * the default.
47
+ */
48
+ DIRECT: 'direct',
49
+ /**
50
+ * When running offline, send messages to an offline SQS service defined by
51
+ * `process.env.LAMBDA_WRAPPER_OFFLINE_SQS_HOST`.
52
+ */
53
+ LOCAL: 'local',
54
+ /**
55
+ * When running offline, send messages to AWS as normal.
56
+ */
57
+ AWS: 'aws',
58
+ };
59
+ /**
60
+ * Defines the preferred behaviour for `SQSService.prototype.send` in case the
61
+ * AWS SQS call fails.
62
+ */
63
+ exports.SQS_PUBLISH_FAILURE_MODES = {
64
+ /**
65
+ * Catch the exception and logs it.
66
+ *
67
+ * This is the default behaviour for Lambda Wrapper v1.8.0 and below and for
68
+ * Lambda Wrapper v1.8.2 and above.
69
+ */
70
+ CATCH: 'catch',
71
+ /**
72
+ * Throw the exception so that the caller can handle it directly.
73
+ */
74
+ THROW: 'throw',
75
+ };
76
+ /**
77
+ * Helper service for working with SQS.
78
+ *
79
+ * Config for this service goes in the `sqs` key of your Lambda Wrapper config.
80
+ * The `queues` key maps short friendly names to the full SQS queue name.
81
+ * Usually we define queue names in our `serverless.yml` and provide them to
82
+ * the application via environment variables.
83
+ *
84
+ * ```ts
85
+ * const lambdaWrapper = lw.configure({
86
+ * sqs: {
87
+ * queues: {
88
+ * // add an entry for each queue mapping to its AWS name
89
+ * submissions: process.env.SQS_QUEUE_SUBMISSIONS,
90
+ * },
91
+ * },
92
+ * });
93
+ * ```
94
+ *
95
+ * You can then send messages to a queue within your Lambda handler using the
96
+ * `publish` method.
97
+ *
98
+ * ```ts
99
+ * export default lambdaWrapper.wrap(async (di) => {
100
+ * const sqs = di.get(SQSService);
101
+ * const message = { data: 'Hello SQS!' };
102
+ * await sqs.publish('submissions', message);
103
+ * });
104
+ * ```
105
+ */
106
+ class SQSService extends DependencyAwareClass_1.default {
107
+ constructor(di) {
108
+ super(di);
109
+ const config = this.di.config.sqs;
110
+ this.queues = config?.queues || {};
111
+ this.queueConsumers = config?.queueConsumers || {};
112
+ const { LAMBDA_WRAPPER_OFFLINE_SQS_HOST: offlineHost = 'localhost', LAMBDA_WRAPPER_OFFLINE_SQS_PORT: offlinePort = '4576', LAMBDA_WRAPPER_OFFLINE_SQS_MODE: offlineMode = exports.SQS_OFFLINE_MODES.DIRECT, AWS_ACCOUNT_ID, REGION, } = process.env;
113
+ const accountId = (di.context.invokedFunctionArn && alai_1.default.parse(di.context))
114
+ || AWS_ACCOUNT_ID;
115
+ if (di.isOffline && !Object.values(exports.SQS_OFFLINE_MODES).includes(offlineMode)) {
116
+ throw new Error(`Invalid LAMBDA_WRAPPER_OFFLINE_SQS_MODE: ${offlineMode}\n`
117
+ + `Please use one of: ${Object.values(exports.SQS_OFFLINE_MODES).join(', ')}`);
118
+ }
119
+ const useLocalQueues = di.isOffline && offlineMode === exports.SQS_OFFLINE_MODES.LOCAL;
120
+ this.queueUrls = Object.fromEntries(Object.entries(this.queues).map((([key, queueName]) => [key, useLocalQueues
121
+ ? `http://${offlineHost}:${offlinePort}/queue/${queueName}`
122
+ : `https://sqs.${REGION}.amazonaws.com/${accountId}/${queueName}`])));
123
+ }
124
+ /**
125
+ * Returns an SQS client instance
126
+ */
127
+ get sqs() {
128
+ if (!this.$sqs) {
129
+ this.$sqs = new aws_sdk_1.default.SQS({
130
+ region: process.env.REGION,
131
+ httpOptions: {
132
+ // longest publish on NOTV took 5 seconds
133
+ connectTimeout: 8 * 1000,
134
+ timeout: 8 * 1000,
135
+ },
136
+ maxRetries: 3, // default is 3, we can change that
137
+ });
138
+ }
139
+ return this.$sqs;
140
+ }
141
+ /**
142
+ * Returns a Lambda client instance
143
+ */
144
+ get lambda() {
145
+ if (!this.$lambda) {
146
+ const endpoint = process.env.SERVICE_LAMBDA_URL;
147
+ if (!endpoint) {
148
+ throw new Error('process.env.SERVICE_LAMBDA_URL must be defined.');
149
+ }
150
+ // move to subprocess
151
+ this.$lambda = new aws_sdk_1.default.Lambda({
152
+ region: process.env.AWS_REGION,
153
+ endpoint,
154
+ });
155
+ }
156
+ return this.$lambda;
157
+ }
158
+ /**
159
+ * Returns the mode to use for offline SQS.
160
+ *
161
+ * This is configured by `process.env.LAMBDA_WRAPPER_OFFLINE_SQS_MODE`. The
162
+ * default is `SQS_OFFLINE_MODES.LAMBDA`.
163
+ */
164
+ static get offlineMode() {
165
+ return process.env.LAMBDA_WRAPPER_OFFLINE_SQS_MODE || exports.SQS_OFFLINE_MODES.DIRECT;
166
+ }
167
+ /**
168
+ * Batch delete messages.
169
+ *
170
+ * @param queue
171
+ * @param messageModels
172
+ */
173
+ batchDelete(queue, messageModels) {
174
+ const queueUrl = this.queueUrls[queue];
175
+ const logger = this.di.get(LoggerService_1.default);
176
+ const timer = this.di.get(TimerService_1.default);
177
+ const timerId = `sqs-batch-delete-${(0, uuid_1.v4)()} - Queue: '${queueUrl}'`;
178
+ return new Promise((resolve) => {
179
+ const messagesForDeletion = [];
180
+ timer.start(timerId);
181
+ // assuming openFiles is an array of file names
182
+ (0, async_1.each)(messageModels, (messageModel, callback) => {
183
+ if (messageModel instanceof SQSMessageModel_1.default && messageModel.isForDeletion() === true) {
184
+ messagesForDeletion.push({
185
+ Id: messageModel.getMessageId(),
186
+ ReceiptHandle: messageModel.getReceiptHandle(),
187
+ });
188
+ }
189
+ callback();
190
+ }, (loopError) => {
191
+ if (loopError) {
192
+ logger.error(loopError);
193
+ resolve();
194
+ }
195
+ this.sqs.deleteMessageBatch({
196
+ Entries: messagesForDeletion,
197
+ QueueUrl: queueUrl,
198
+ }, (error) => {
199
+ timer.stop(timerId);
200
+ if (error) {
201
+ logger.error(error);
202
+ }
203
+ resolve();
204
+ });
205
+ });
206
+ });
207
+ }
208
+ /**
209
+ * Check SQS status.
210
+ */
211
+ checkStatus() {
212
+ const logger = this.di.get(LoggerService_1.default);
213
+ const timer = this.di.get(TimerService_1.default);
214
+ const timerId = `sqs-list-queues-${(0, uuid_1.v4)()}`;
215
+ return new Promise((resolve) => {
216
+ timer.start(timerId);
217
+ this.sqs.listQueues({}, (error, data) => {
218
+ timer.stop(timerId);
219
+ const statusModel = new StatusModel_1.default('SQS', StatusModel_1.STATUS_TYPES.OK);
220
+ if (error) {
221
+ logger.error(error);
222
+ statusModel.setStatus(StatusModel_1.STATUS_TYPES.APPLICATION_FAILURE);
223
+ }
224
+ if (typeof data.QueueUrls === 'undefined' || data.QueueUrls.length === 0) {
225
+ statusModel.setStatus(StatusModel_1.STATUS_TYPES.APPLICATION_FAILURE);
226
+ }
227
+ resolve(statusModel);
228
+ });
229
+ });
230
+ }
231
+ /**
232
+ * Get the approximate number of messages in a queue.
233
+ *
234
+ * @param queue
235
+ */
236
+ getMessageCount(queue) {
237
+ const queueUrl = this.queueUrls[queue];
238
+ const logger = this.di.get(LoggerService_1.default);
239
+ const timer = this.di.get(TimerService_1.default);
240
+ const timerId = `sqs-get-queue-attributes-${(0, uuid_1.v4)()} - Queue: '${queueUrl}'`;
241
+ return new Promise((resolve) => {
242
+ timer.start(timerId);
243
+ this.sqs.getQueueAttributes({
244
+ AttributeNames: ['ApproximateNumberOfMessages'],
245
+ QueueUrl: queueUrl,
246
+ }, (error, data) => {
247
+ timer.stop(timerId);
248
+ if (error) {
249
+ logger.error(error);
250
+ resolve(0);
251
+ }
252
+ const messageCount = data.Attributes?.ApproximateNumberOfMessages || '0';
253
+ resolve(Number.parseInt(messageCount, 10));
254
+ });
255
+ });
256
+ }
257
+ /**
258
+ * Publish to message queue.
259
+ *
260
+ * When running within serverless-offline, messages can be published to a
261
+ * local Lambda or SQS service instead of to AWS, depending on the offline
262
+ * mode specified by `process.env.LAMBDA_WRAPPER_OFFLINE_SQS_MODE`.
263
+ *
264
+ * @param queue string
265
+ * @param messageObject object
266
+ * @param messageGroupId string
267
+ * @param failureMode Choose how failures are handled:
268
+ * - `catch`: errors will be caught and logged. This is the default.
269
+ * - `throw`: errors will be thrown, causing promise to reject.
270
+ */
271
+ async publish(queue, messageObject, messageGroupId = null, failureMode = exports.SQS_PUBLISH_FAILURE_MODES.CATCH) {
272
+ if (!Object.values(exports.SQS_PUBLISH_FAILURE_MODES).includes(failureMode)) {
273
+ throw new Error(`Invalid value for 'failureMode': ${failureMode}`);
274
+ }
275
+ const queueUrl = this.queueUrls[queue];
276
+ const timer = this.di.get(TimerService_1.default);
277
+ const timerId = `sqs-send-message-${(0, uuid_1.v4)()} - Queue: '${queueUrl}'`;
278
+ timer.start(timerId);
279
+ const messageParameters = {
280
+ MessageBody: JSON.stringify(messageObject),
281
+ QueueUrl: queueUrl,
282
+ };
283
+ if (queueUrl.includes('.fifo')) {
284
+ messageParameters.MessageDeduplicationId = (0, uuid_1.v4)();
285
+ messageParameters.MessageGroupId = messageGroupId !== null ? messageGroupId : (0, uuid_1.v4)();
286
+ }
287
+ try {
288
+ if (this.di.isOffline && SQSService.offlineMode === exports.SQS_OFFLINE_MODES.DIRECT) {
289
+ await this.publishOffline(queue, messageParameters);
290
+ }
291
+ else {
292
+ await this.sqs.sendMessage(messageParameters).promise();
293
+ }
294
+ }
295
+ catch (error) {
296
+ if (failureMode === exports.SQS_PUBLISH_FAILURE_MODES.CATCH) {
297
+ this.di.get(LoggerService_1.default).error(error);
298
+ return null;
299
+ }
300
+ throw error;
301
+ }
302
+ return queue;
303
+ }
304
+ /**
305
+ * Sends a message to a queue consumer running in serverless-offline.
306
+ *
307
+ * This method invokes the consumer function directly instead of sending the
308
+ * message to SQS, which requires a real or emulated SQS service not provided
309
+ * by serverless-offline. This works very well for local testing.
310
+ *
311
+ * @param queue
312
+ * @param messageParameters
313
+ */
314
+ async publishOffline(queue, messageParameters) {
315
+ if (!this.di.isOffline) {
316
+ throw new Error('Can only publishOffline while running serverless offline.');
317
+ }
318
+ const FunctionName = this.queueConsumers[queue];
319
+ if (!FunctionName) {
320
+ throw new Error(`Queue consumer for queue ${queue} was not found. Please add it to `
321
+ + 'the sqs.queueConsumers key in your Lambda Wrapper config.');
322
+ }
323
+ const InvocationType = 'RequestResponse';
324
+ const Payload = JSON.stringify({
325
+ Records: [
326
+ {
327
+ body: messageParameters.MessageBody,
328
+ },
329
+ ],
330
+ });
331
+ const parameters = { FunctionName, InvocationType, Payload };
332
+ await this.lambda.invoke(parameters).promise();
333
+ }
334
+ /**
335
+ * Receive from message queue
336
+ *
337
+ * @param queue string
338
+ * @param timeout number
339
+ */
340
+ receive(queue, timeout = 15) {
341
+ const queueUrl = this.queueUrls[queue];
342
+ const logger = this.di.get(LoggerService_1.default);
343
+ const timer = this.di.get(TimerService_1.default);
344
+ const timerId = `sqs-receive-message-${(0, uuid_1.v4)()} - Queue: '${queueUrl}'`;
345
+ return new Promise((resolve, reject) => {
346
+ timer.start(timerId);
347
+ this.sqs.receiveMessage({
348
+ QueueUrl: queueUrl,
349
+ VisibilityTimeout: timeout,
350
+ MaxNumberOfMessages: 10,
351
+ }, (error, data) => {
352
+ timer.stop(timerId);
353
+ if (error) {
354
+ logger.error(error);
355
+ return reject(error);
356
+ }
357
+ if (typeof data.Messages === 'undefined') {
358
+ return resolve([]);
359
+ }
360
+ return resolve(data.Messages.map((message) => new SQSMessageModel_1.default(message)));
361
+ });
362
+ });
363
+ }
364
+ }
365
+ exports.default = SQSService;
366
+ //# sourceMappingURL=SQSService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SQSService.js","sourceRoot":"","sources":["../../src/services/SQSService.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,gDAAwB;AACxB,iCAA6B;AAC7B,sDAA0B;AAC1B,+BAAkC;AAElC,wFAAgE;AAEhE,gFAAwD;AACxD,qEAAkE;AAClE,oEAA4C;AAC5C,kEAA0C;AAwC1C;;GAEG;AACU,QAAA,iBAAiB,GAAG;IAC/B;;;;OAI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CAAC,CAAC;YAErB,IAAI,CAAC,GAAG,CAAC,cAAc,CACrB;gBACE,QAAQ,EAAE,QAAQ;gBAClB,iBAAiB,EAAE,OAAO;gBAC1B,mBAAmB,EAAE,EAAE;aACxB,EACD,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE;gBACd,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;gBAEpB,IAAI,KAAK,EAAE;oBACT,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;oBACpB,OAAO,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;AArVD,6BAqVC"}
@@ -0,0 +1,22 @@
1
+ import DependencyAwareClass from '../core/DependencyAwareClass';
2
+ /**
3
+ * Timer helper that can be used to measure how long operations take.
4
+ */
5
+ export default class TimerService extends DependencyAwareClass {
6
+ timers: Record<string, number>;
7
+ /**
8
+ * Start a timer.
9
+ *
10
+ * To stop the timer, call `stop()` with the same `identifier`.
11
+ *
12
+ * @param identifier
13
+ */
14
+ start(identifier: string): void;
15
+ /**
16
+ * Stop a timer and log the elapsed time.
17
+ *
18
+ * @param identifier
19
+ */
20
+ stop(identifier: string): void;
21
+ }
22
+ //# sourceMappingURL=TimerService.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimerService.d.ts","sourceRoot":"","sources":["../../src/services/TimerService.ts"],"names":[],"mappings":"AAAA,OAAO,oBAAoB,MAAM,8BAA8B,CAAC;AAGhE;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,oBAAoB;IAC5D,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAM;IAEpC;;;;;;OAMG;IACH,KAAK,CAAC,UAAU,EAAE,MAAM;IAIxB;;;;OAIG;IACH,IAAI,CAAC,UAAU,EAAE,MAAM;CAOxB"}
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const DependencyAwareClass_1 = __importDefault(require("../core/DependencyAwareClass"));
7
+ const LoggerService_1 = __importDefault(require("./LoggerService"));
8
+ /**
9
+ * Timer helper that can be used to measure how long operations take.
10
+ */
11
+ class TimerService extends DependencyAwareClass_1.default {
12
+ constructor() {
13
+ super(...arguments);
14
+ this.timers = {};
15
+ }
16
+ /**
17
+ * Start a timer.
18
+ *
19
+ * To stop the timer, call `stop()` with the same `identifier`.
20
+ *
21
+ * @param identifier
22
+ */
23
+ start(identifier) {
24
+ this.timers[identifier] = Date.now();
25
+ }
26
+ /**
27
+ * Stop a timer and log the elapsed time.
28
+ *
29
+ * @param identifier
30
+ */
31
+ stop(identifier) {
32
+ if (identifier in this.timers) {
33
+ const logger = this.di.get(LoggerService_1.default);
34
+ const duration = Date.now() - this.timers[identifier];
35
+ logger.info(`Timing - ${identifier} took ${duration} ms to complete`);
36
+ }
37
+ }
38
+ }
39
+ exports.default = TimerService;
40
+ //# sourceMappingURL=TimerService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TimerService.js","sourceRoot":"","sources":["../../src/services/TimerService.ts"],"names":[],"mappings":";;;;;AAAA,wFAAgE;AAChE,oEAA4C;AAE5C;;GAEG;AACH,MAAqB,YAAa,SAAQ,8BAAoB;IAA9D;;QACE,WAAM,GAA2B,EAAE,CAAC;IAyBtC,CAAC;IAvBC;;;;;;OAMG;IACH,KAAK,CAAC,UAAkB;QACtB,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;IACvC,CAAC;IAED;;;;OAIG;IACH,IAAI,CAAC,UAAkB;QACrB,IAAI,UAAU,IAAI,IAAI,CAAC,MAAM,EAAE;YAC7B,MAAM,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,uBAAa,CAAC,CAAC;YAC1C,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YACtD,MAAM,CAAC,IAAI,CAAC,YAAY,UAAU,SAAS,QAAQ,iBAAiB,CAAC,CAAC;SACvE;IACH,CAAC;CACF;AA1BD,+BA0BC"}
@@ -0,0 +1,14 @@
1
+ /**
2
+ * An error that triggers a Lambda termination.
3
+ *
4
+ * Offers developer details (that are logged), a code for the Lambda and a
5
+ * front-facing consumer message.
6
+ */
7
+ export default class LambdaTermination extends Error {
8
+ readonly internal: object | string;
9
+ readonly code: number;
10
+ readonly body: object | string | null;
11
+ readonly details: string;
12
+ constructor(internal: object | string, code?: number, body?: object | string | null, details?: string);
13
+ }
14
+ //# sourceMappingURL=LambdaTermination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LambdaTermination.d.ts","sourceRoot":"","sources":["../../src/utils/LambdaTermination.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,iBAAkB,SAAQ,KAAK;IAEhD,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM;IAClC,QAAQ,CAAC,IAAI;IACb,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IACrC,QAAQ,CAAC,OAAO;gBAHP,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,IAAI,SAAM,EACV,IAAI,GAAE,MAAM,GAAG,MAAM,GAAG,IAAW,EACnC,OAAO,SAAkB;CAUrC"}