lambda-toolkit 1.1.0 → 1.1.1

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 (3) hide show
  1. package/README.md +1 -1
  2. package/dist/index.js +2044 -2041
  3. package/package.json +18 -17
package/dist/index.js CHANGED
@@ -1,44 +1,227 @@
1
1
  /******/ (() => { // webpackBootstrap
2
2
  /******/ var __webpack_modules__ = ({
3
3
 
4
- /***/ 44:
5
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
4
+ /***/ 8278
5
+ (module, __unused_webpack_exports, __webpack_require__) {
6
6
 
7
- const { LambdaApi } = __webpack_require__( 2705 );
8
- const array = __webpack_require__( 8278 );
9
- const aws = __webpack_require__( 4870 );
10
- const epoch = __webpack_require__( 3830 );
11
- const math = __webpack_require__( 943 );
12
- const object = __webpack_require__( 5762 );
13
- const redis = __webpack_require__( 4528 );
14
- const string = __webpack_require__( 268 );
15
- const utils = __webpack_require__( 6878 );
7
+ const joinUnique = __webpack_require__( 2836 );
8
+ const joinUniqueCustom = __webpack_require__( 536 );
9
+ const splitBatches = __webpack_require__( 4821 );
16
10
 
17
11
  module.exports = {
18
- array,
19
- aws,
20
- epoch,
21
- LambdaApi,
22
- math,
23
- object,
24
- redis,
25
- string,
26
- utils
12
+ joinUnique,
13
+ joinUniqueCustom,
14
+ splitBatches
27
15
  };
28
16
 
29
17
 
30
- /***/ }),
18
+ /***/ },
31
19
 
32
- /***/ 115:
33
- /***/ ((module) => {
20
+ /***/ 2836
21
+ (module) {
34
22
 
35
- module.exports = ( n, d = 2 ) => Math.round( n * ( 10 ** d ) ) / ( 10 ** d );
23
+ module.exports = ( ...args ) => [ ...new Set( args.filter( Array.isArray ).flat() ) ];
24
+
25
+
26
+ /***/ },
27
+
28
+ /***/ 536
29
+ (module) {
30
+
31
+ module.exports = ( { key, items } ) => [
32
+ ...items.filter( Array.isArray ).flat().reduce( ( map, v ) => {
33
+ const k = key( v );
34
+ if ( !map.has( k ) ) {
35
+ map.set( k, v );
36
+ }
37
+ return map;
38
+ }, new Map() ).values()
39
+ ];
40
+
41
+
42
+ /***/ },
43
+
44
+ /***/ 4821
45
+ (module) {
46
+
47
+ module.exports = ( items, size ) => items.reduce( ( arrs, item ) =>
48
+ ( arrs[0] && arrs[0].length < size ) ?
49
+ [ [ ...arrs[0], item ] ].concat( arrs.slice( 1 ) ) :
50
+ [ [ item ] ].concat( arrs )
51
+ , [] ).reverse();
52
+
53
+
54
+ /***/ },
55
+
56
+ /***/ 228
57
+ (module, __unused_webpack_exports, __webpack_require__) {
58
+
59
+ const { AthenaClient } = __webpack_require__( 3744 );
60
+ const clientProvider = __webpack_require__( 9039 );
61
+ const query = __webpack_require__( 140 );
62
+ const createInstance = __webpack_require__( 5438 );
63
+
64
+ const methods = {
65
+ query
66
+ };
67
+
68
+ module.exports = createInstance( clientProvider.bind( null, AthenaClient ), methods );
69
+
70
+
71
+ /***/ },
72
+
73
+ /***/ 7337
74
+ (module, __unused_webpack_exports, __webpack_require__) {
75
+
76
+ const { GetQueryExecutionCommand, GetQueryResultsCommand } = __webpack_require__( 3744 );
77
+ const parseResults = __webpack_require__( 834 );
78
+ const pollingDelay = __webpack_require__( 4127 );
79
+
80
+ const sleep = t => new Promise( r => setTimeout( () => r(), t ) );
81
+
82
+ const getQueryResults = async ( { client, queryExecutionId, maxResults, token } ) => {
83
+ const { NextToken: nextToken, ResultSet } = await client.send( new GetQueryResultsCommand( {
84
+ ...{ QueryExecutionId: queryExecutionId },
85
+ ...( maxResults ? { MaxResults: maxResults } : {} ),
86
+ ...( token ? { NextToken: token } : {} )
87
+ } ) );
88
+
89
+ return { nextToken, items: parseResults( ResultSet ) };
90
+ };
91
+ const getQueryResultsRecursive = async ( { client, queryExecutionId, token } ) => {
92
+ const { nextToken, items } = await getQueryResults( { client, queryExecutionId, token } );
93
+
94
+ if ( nextToken ) {
95
+ return { items: items.concat( ( await getQueryResultsRecursive( { client, queryExecutionId, token: nextToken } ) ).items ) };
96
+ }
97
+ return { items };
98
+ };
99
+
100
+ /**
101
+ * https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/athena/command/GetQueryResultsCommand/
102
+ * { client, recursive, queryExecutionId, maxResults, paginationToken }
103
+ */
104
+ const getResults = async ( { client, recursive, queryExecutionId, token, maxResults } ) => {
105
+ const { QueryExecution: { Status: status } } = await client.send( new GetQueryExecutionCommand( { QueryExecutionId: queryExecutionId } ) );
106
+
107
+ if ( status.State === 'FAILED' ) {
108
+ throw new Error( status.AthenaError?.ErrorMessage ?? status.StateChangeReason );
109
+ }
110
+
111
+ if ( status.State === 'SUCCEEDED' ) {
112
+ const fn = recursive ? getQueryResultsRecursive : getQueryResults;
113
+ return fn( { client, recursive, queryExecutionId, token, maxResults } );
114
+ }
115
+
116
+ // sleep an try again
117
+ await sleep( pollingDelay );
118
+ return getResults( { client, recursive, queryExecutionId, token, maxResults } );
119
+ };
120
+
121
+ module.exports = getResults;
122
+
123
+
124
+ /***/ },
125
+
126
+ /***/ 834
127
+ (module, __unused_webpack_exports, __webpack_require__) {
128
+
129
+ const parseValue = __webpack_require__( 9129 );
130
+
131
+ module.exports = resultSet => {
132
+ const columns = resultSet.ResultSetMetadata.ColumnInfo
133
+ .map( col => ( { name: col.Name, type: col.Type } ) );
134
+
135
+ // first data row contains the table field names
136
+ return resultSet.Rows.slice( 1 ).map( row => {
137
+ const values = row.Data.map( d => d.VarCharValue );
138
+ return columns.reduce( ( obj, p, i ) => Object.assign( obj, { [p.name]: parseValue( values[i], p.type ) } ), {} );
139
+ } );
140
+ };
36
141
 
37
142
 
38
- /***/ }),
143
+ /***/ },
39
144
 
40
- /***/ 140:
41
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
145
+ /***/ 9129
146
+ (module) {
147
+
148
+ /* eslint consistent-return: 0 */
149
+ const removeNullValues = ( o, isArray = Array.isArray( o ) ) =>
150
+ Object.entries( o ).reduce( ( newObj, [ k, v ] ) => {
151
+ if ( v === null && !isArray ) { return newObj; }
152
+ return Object.assign( newObj, { [k]: v?.constructor === Object ? removeNullValues( v ) : v } );
153
+ }, isArray ? [] : {} );
154
+
155
+ module.exports = ( v, type ) => {
156
+ if ( [ null, undefined ].includes( v ) ) {
157
+ return undefined;
158
+ }
159
+ if ( v === '' && type !== 'varchar' ) {
160
+ return undefined;
161
+ }
162
+ if ( type === 'boolean' ) {
163
+ return v === 'true';
164
+ }
165
+ if ( [ 'float', 'decimal', 'double' ].includes( type ) ) {
166
+ return parseFloat( v );
167
+ }
168
+ if ( [ 'tinyint', 'smallint', 'int', 'bigint' ].includes( type ) ) {
169
+ return parseInt( v );
170
+ }
171
+ if ( 'timestamp' === type ) {
172
+ return new Date( v ).getTime();
173
+ }
174
+ if ( [ 'row', 'array' ].includes( type ) ) {
175
+ const obj = v.replace( /(?<=(?:{|,\s)[\w-_]+)=/g, '@@DELIMITER@@' ) // replaces delimiter = with @@DELIMITER@@
176
+ .replace( /(?<={|,\s)([\w_-]+)(?=@@DELIMITER@@)/g, '"$1"' ) // wrap object keys
177
+ .replace( /(?<=@@DELIMITER@@)((?:(?!,\s|}|\[|{).)+)/g, '"$1"' ) // wrap object values
178
+ .replace( /(?<=\[|,\s)((?:(?!,\s|{|\]|").)+)/g, '"$1"' ) // wrap array values
179
+ .replace( /"null"/g, 'null' ) // convert "null" to null
180
+ .replace( /@@DELIMITER@@/g, ':' ); // replaces @@DELIMITER@@ for :
181
+
182
+ return removeNullValues( JSON.parse( obj ) );
183
+ }
184
+ if ( 'json' === type ) {
185
+ return JSON.parse( v );
186
+ }
187
+ return v;
188
+ };
189
+
190
+
191
+ /***/ },
192
+
193
+ /***/ 4127
194
+ (module) {
195
+
196
+ module.exports = 500;
197
+
198
+
199
+ /***/ },
200
+
201
+ /***/ 5723
202
+ (module, __unused_webpack_exports, __webpack_require__) {
203
+
204
+ const { randomBytes } = __webpack_require__( 6982 );
205
+ const { StartQueryExecutionCommand } = __webpack_require__( 3744 );
206
+
207
+ /**
208
+ * args : https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/athena/command/StartQueryExecutionCommand/
209
+ * A ClientRequestToken is created automatically
210
+ */
211
+ module.exports = async ( { client, ...args } ) => {
212
+ const cmd = new StartQueryExecutionCommand( {
213
+ ClientRequestToken: randomBytes( 16 ).toString( 'hex' ),
214
+ ...args
215
+ } );
216
+ const { QueryExecutionId: queryId } = await client.send( cmd );
217
+ return queryId;
218
+ };
219
+
220
+
221
+ /***/ },
222
+
223
+ /***/ 140
224
+ (module, __unused_webpack_exports, __webpack_require__) {
42
225
 
43
226
  const { encode, decode } = __webpack_require__( 5744 );
44
227
  const startQuery = __webpack_require__( 5723 );
@@ -81,851 +264,225 @@ module.exports = async ( client, nativeArgs, options ) => {
81
264
  };
82
265
 
83
266
 
84
- /***/ }),
85
-
86
- /***/ 228:
87
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
88
-
89
- const { AthenaClient } = __webpack_require__( 3744 );
90
- const clientProvider = __webpack_require__( 9039 );
91
- const query = __webpack_require__( 140 );
92
- const createInstance = __webpack_require__( 5438 );
93
-
94
- const methods = {
95
- query
96
- };
97
-
98
- module.exports = createInstance( clientProvider.bind( null, AthenaClient ), methods );
267
+ /***/ },
99
268
 
269
+ /***/ 4164
270
+ (module, __unused_webpack_exports, __webpack_require__) {
100
271
 
101
- /***/ }),
272
+ const cacheSym = Symbol.for( 'cache' );
273
+ const crypto = __webpack_require__( 6982 );
102
274
 
103
- /***/ 268:
104
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
275
+ const hash = text => crypto.createHash( 'md5' ).update( text ).digest( 'hex' );
105
276
 
106
- const camelize = __webpack_require__( 3914 );
107
- const capitalizeWords = __webpack_require__( 3258 );
108
- const snakelize = __webpack_require__( 3402 );
277
+ const propOpts = {
278
+ enumerable: false,
279
+ configurable: false,
280
+ writable: false
281
+ };
109
282
 
110
283
  module.exports = {
111
- camelize,
112
- capitalizeWords,
113
- snakelize
114
- };
284
+ set: ( key, value ) => {
285
+ const keySym = Symbol.for( hash( key ) );
115
286
 
287
+ if ( !global[cacheSym] ) {
288
+ Object.defineProperty( global, cacheSym, { ...propOpts, value: {} } );
289
+ }
116
290
 
117
- /***/ }),
291
+ Object.defineProperty( global[cacheSym], keySym, { ...propOpts, value } );
292
+ },
293
+ get: key => {
294
+ return global[cacheSym]?.[Symbol.for( hash( key ) )];
295
+ }
296
+ };
118
297
 
119
- /***/ 279:
120
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
121
298
 
122
- const { HeadObjectCommand } = __webpack_require__( 5725 );
299
+ /***/ },
123
300
 
124
- module.exports = async ( client, bucket, key ) =>
125
- client.send( new HeadObjectCommand( { Bucket: bucket, Key: key } ) );
301
+ /***/ 5438
302
+ (module) {
126
303
 
304
+ /**
305
+ * This is base object each AWS abstraction will provide
306
+ */
307
+ module.exports = ( providerFn, methods ) => {
308
+ // This creates the "instance",
309
+ // so calling the method as a function returns a copy of its client instantiated with the given args
310
+ // every method called from it will use this instance
311
+ const factory = args => {
312
+ const client = providerFn( args );
313
+ // return self, so it is possible use the native client
314
+ methods.getClient = () => client;
315
+ return Object.entries( methods ).reduce( ( o, [ k, v ] ) => Object.assign( o, { [k]: v.bind( null, client ) } ), { } );
316
+ };
127
317
 
128
- /***/ }),
318
+ // This is the singleton part;
319
+ // First add the static method to the factory;
320
+ Object.entries( methods ).forEach( ( [ key, value ] ) => factory[key] = value );
129
321
 
130
- /***/ 321:
131
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
322
+ // Then add the special method "getClient", so it is possible use the native client
323
+ factory.getClient = client => client;
132
324
 
133
- const validators = __webpack_require__( 8994 );
134
- const ApiResponse = __webpack_require__( 3119 );
135
- const Event = __webpack_require__( 329 );
136
- const Handler = __webpack_require__( 3109 );
137
- const Hook = __webpack_require__( 798 );
138
- const UserResponse = __webpack_require__( 8282 );
139
- const Text = __webpack_require__( 9760 );
140
-
141
- module.exports = class LambdaApi {
142
- #apiResponse = null;
143
- #handlers = [];
144
- #errorResponses = [];
145
- #beforeHooks = [];
146
- #afterHooks = [];
147
- #transformRequest = [];
148
-
149
- /**
150
- * Creates a new Lambda Api
151
- *
152
- * @param {Object} headers Any headers you want to be included in all responses
153
- */
154
- constructor( { headers = {}, transformRequest = false, transformResponse = false } = {} ) {
155
- validators.transformRequest( transformRequest );
156
- validators.transformResponse( transformResponse );
157
-
158
- this.#transformRequest = transformRequest;
159
- this.#apiResponse = new ApiResponse( { headers, transform: transformResponse } );
160
- }
161
-
162
- /**
163
- * Register a function that will run before the matching route (only if matches)
164
- *
165
- * @param {Object} args
166
- * @param {function} args.fn A function
167
- */
168
- addBeforeHook( { fn } = {} ) {
169
- this.#beforeHooks.push( new Hook( { fn } ) );
170
- }
171
-
172
- /**
173
- * Register a function that will run after the matching route (only if matches)
174
- *
175
- * @param {Object} args
176
- * @param {function} args.fn A function
177
- */
178
- addAfterHook( { fn } = {} ) {
179
- this.#afterHooks.push( new Hook( { fn } ) );
180
- }
181
-
182
- /**
183
- * Register a handler for a given request method and optionally a path
184
- *
185
- * @param {Object} args
186
- * @param {string} args.method The method to match this handler
187
- * @param {function} args.fn The handler function
188
- * @param {string} [args.route] A route to match this handler
189
- * @param {string} [args.routeIncludes] A part of the route to match this handler
190
- * @param {string} [args.routeNotIncludes] A part of the route to not match this handler
191
- * @param {RegExp} [args.routeMatches] A RegExp to match the route
192
- * @param {string} [args.path] A path to match this handler
193
- * @param {string} [args.pathIncludes] A part of the path to match this handler
194
- * @param {string} [args.pathNotIncludes] A part of the path to not match this handler
195
- * @param {RegExp} [args.pathMatches] A RegExp to match the path
196
- */
197
- addHandler( { method, fn, ...matchers } = {} ) {
198
- this.#handlers.push( new Handler( { method, fn, ...matchers } ) );
199
- }
200
-
201
- /**
202
- * Register an automatic error code response for given error class (constructor name)
203
- *
204
- * @param {Object} args
205
- * @param {string} args.code The HTTP status code to return
206
- * @param {class} args.errorType The error class
207
- * @param {string} [args.message=null] Optional message to return for the status code, if not present will default to Error.message
208
- * @param {message} [args.errorType] And optional message to display
209
- */
210
- addErrorHandler( { errorType, code, message = null } = {} ) {
211
- validators.statusCode( code );
212
- validators.errorType( errorType );
213
- this.#errorResponses.push( { errorType, code, message } );
214
- }
215
-
216
- /**
217
- * Init the flow using a given AWS Lambda APIGateway event (v2 syntax)
218
- *
219
- * @param {Object} ApiGatewayPayload The raw API Gateway event
220
- * @returns {Object} The http response with status, body and headers
221
- */
222
- async process( awsEvent ) {
223
- const event = new Event( { transform: this.#transformRequest } );
224
- event.parseFromAwsEvent( awsEvent );
225
-
226
- if ( event.method === 'HEAD' ) {
227
- return this.#apiResponse.setContent( 204 ).toJSON();
228
- }
229
-
230
- const handler = this.#handlers.find( h => h.match( event ) );
231
- if ( !handler ) {
232
- return this.#apiResponse.setContent( 405, Text.ERROR_405 ).toJSON();
233
- }
234
-
235
- const chain = [
236
- ...this.#beforeHooks.map( b => b.fn ),
237
- async ev => {
238
- const result = await handler.fn( ev );
239
- const response = new UserResponse( result );
240
- this.#apiResponse.setContent( ...response.values ).toJSON();
241
- },
242
- ...this.#afterHooks.map( a => a.fn )
243
- ];
244
-
245
- try {
246
- for ( const fn of chain ) {
247
- await fn( event );
248
- }
249
- return this.#apiResponse.toJSON();
250
-
251
- } catch ( error ) {
252
- console.error( 'Lambda API Error', { error, event } );
253
-
254
- const response = this.#errorResponses.find( e => error instanceof e.errorType );
255
- if ( response ) {
256
- return this.#apiResponse.setContent( response.code, response.message ?? error.message ).toJSON();
257
- }
258
- return this.#apiResponse.setContent( 500, Text.ERROR_500 ).toJSON();
259
- }
260
- }
261
- };
262
-
263
-
264
- /***/ }),
265
-
266
- /***/ 329:
267
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
268
-
269
- const { camelize, snakelize } = __webpack_require__( 5762 );
270
-
271
- const transformFns = {
272
- camelcase: camelize,
273
- snakecase: snakelize
274
- };
275
-
276
- const parseJson = content => {
277
- try {
278
- return JSON.parse( content );
279
- } catch {
280
- return content;
281
- }
282
- };
283
-
284
- module.exports = class Event {
285
- #transformFn;
286
- authorizer;
287
- body;
288
- headers;
289
- method;
290
- params;
291
- path;
292
- queryString;
293
- route;
294
-
295
- context = {};
296
-
297
- constructor( { transform = false } = {} ) {
298
- this.#transformFn = transformFns[transform] ?? ( v => v );
299
- }
300
-
301
- parseFromAwsEvent( awsEvent ) {
302
- this[`parseFromAwsEventV${awsEvent.version === '2.0' ? 2 : 1}`]( awsEvent );
303
- }
304
-
305
- parseFromAwsEventV1( awsEvent ) {
306
- const {
307
- body,
308
- path,
309
- resource,
310
- httpMethod,
311
- requestContext,
312
- pathParameters,
313
- headers,
314
- multiValueHeaders,
315
- queryStringParameters,
316
- multiValueQueryStringParameters: multiValueQueryString,
317
- isBase64Encoded
318
- } = awsEvent;
319
-
320
- const unifiedHeaders = {
321
- ...headers,
322
- ...Object.fromEntries( Object.entries( multiValueHeaders ?? {} ).map( ( [ k, v ] ) => [ k, Array.isArray( v ) ? v.join( ',' ) : k ] ) )
323
- };
324
-
325
- const unifiedQueryString = {
326
- ...queryStringParameters,
327
- ...Object.fromEntries( Object.entries( multiValueQueryString ?? {} ).map( ( [ k, v ] ) => [ k, Array.isArray( v ) ? v.join( ',' ) : k ] ) )
328
- };
329
-
330
- this.authorizer = requestContext?.authorizer;
331
- this.body = body ? this.#transformFn( parseJson( body ) ) : null;
332
- this.headers = unifiedHeaders ?? {};
333
- this.method = httpMethod;
334
- this.params = this.#transformFn( pathParameters ) ?? {};
335
- this.path = path;
336
- this.queryString = this.#transformFn( unifiedQueryString ) ?? {};
337
- this.route = resource;
338
- this.isBase64Encoded = isBase64Encoded ?? false;
339
- }
340
-
341
- parseFromAwsEventV2( awsEvent ) {
342
- const {
343
- body,
344
- routeKey,
345
- requestContext,
346
- pathParameters,
347
- headers,
348
- queryStringParameters,
349
- isBase64Encoded
350
- } = awsEvent;
351
-
352
- const { http: { method, path } } = requestContext;
353
-
354
- this.authorizer = requestContext?.authorizer;
355
- this.body = body ? this.#transformFn( parseJson( body ) ) : null;
356
- this.headers = headers ?? {};
357
- this.method = method;
358
- this.params = this.#transformFn( pathParameters ) ?? {};
359
- this.path = path;
360
- this.queryString = this.#transformFn( queryStringParameters ) ?? {};
361
- this.route = routeKey?.split( ' ' )[1].replace( /\/$/, '' );
362
- this.isBase64Encoded = isBase64Encoded ?? false;
363
- }
364
- };
365
-
366
-
367
- /***/ }),
368
-
369
- /***/ 345:
370
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
371
-
372
- const { GetObjectCommand } = __webpack_require__( 5725 );
373
-
374
- module.exports = async ( client, bucket, key, nativeArgs ) => {
375
- const response = await client.send( new GetObjectCommand( {
376
- ...nativeArgs,
377
- Bucket: bucket,
378
- Key: key
379
- } ) );
380
- const stream = response.Body;
381
- return Buffer.concat( await stream.toArray() ).toString( 'utf-8' );
382
- };
383
-
384
-
385
- /***/ }),
386
-
387
- /***/ 468:
388
- /***/ ((module) => {
389
-
390
- const parsePayload = payload => {
391
- try {
392
- return JSON.parse( Buffer.from( payload ).toString( 'utf-8' ) );
393
- } catch {
394
- return null;
395
- }
396
- };
397
-
398
- module.exports = class LambdaError extends Error {
399
- constructor( response ) {
400
- const { StatusCode: statusCode, Payload: rawPayload } = response;
401
- const payload = parsePayload( rawPayload );
402
- const lambdaErrorType = payload?.errorType ?? Error.name;
403
- const lambdaErrorMessage = payload?.errorMessage;
404
- if ( statusCode === 200 ) {
405
- super( `Invoked function threw "[${lambdaErrorType}]${lambdaErrorMessage ? ' ' + lambdaErrorMessage : ''}"` );
406
- } else {
407
- super( 'Error invoking the function' );
408
- }
409
- this.statusCode = statusCode;
410
- this.lambdaErrorType = lambdaErrorType;
411
- this.lambdaErrorMessage = lambdaErrorMessage;
412
- }
413
- };
414
-
415
-
416
- /***/ }),
417
-
418
- /***/ 536:
419
- /***/ ((module) => {
420
-
421
- module.exports = ( { key, items } ) => [
422
- ...items.filter( Array.isArray ).flat().reduce( ( map, v ) => {
423
- const k = key( v );
424
- if ( !map.has( k ) ) {
425
- map.set( k, v );
426
- }
427
- return map;
428
- }, new Map() ).values()
429
- ];
430
-
431
-
432
- /***/ }),
433
-
434
- /***/ 637:
435
- /***/ ((module) => {
436
-
437
- module.exports = ( n, d = 2 ) => {
438
- if ( !isFinite( n ) || typeof n !== 'number' ) { return NaN; }
439
-
440
- const m = Math.pow( 10, d );
441
- const num = +( n * m ).toFixed( 8 ); // Avoid rounding errors
442
- const i = Math.floor( num );
443
- const f = num - i;
444
- const e = 1e-8; // Allow for rounding errors in f
445
- const r = ( f > 0.5 - e && f < 0.5 + e ) ? // eslint-disable-line no-nested-ternary
446
- ( ( i % 2 === 0 ) ? i : i + 1 ) : Math.round( num );
447
- return r / m;
448
- };
449
-
450
-
451
- /***/ }),
452
-
453
- /***/ 645:
454
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
455
-
456
- const copy = __webpack_require__( 3936 );
457
- const download = __webpack_require__( 345 );
458
- const getSignedUrl = __webpack_require__( 3758 );
459
- const head = __webpack_require__( 279 );
460
- const upload = __webpack_require__( 9704 );
461
- const { S3Client } = __webpack_require__( 5725 );
462
- const clientProvider = __webpack_require__( 9039 );
463
- const createInstance = __webpack_require__( 5438 );
464
-
465
- const methods = {
466
- copy,
467
- download,
468
- getSignedUrl,
469
- head,
470
- upload
471
- };
472
-
473
- module.exports = createInstance( clientProvider.bind( null, S3Client ), methods );
474
-
475
-
476
- /***/ }),
477
-
478
- /***/ 739:
479
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
480
-
481
- const { GetQueryResultsCommand } = __webpack_require__( 7493 );
482
- const pollingDelay = __webpack_require__( 2549 );
483
- const sleep = t => new Promise( r => setTimeout( () => r(), t ) );
484
-
485
- const getResults = async ( { client, command } ) => {
486
- const { results, status } = await client.send( command );
487
-
488
- if ( [ 'Cancelled', 'Failed', 'Timeout', 'Unknown' ].includes( status ) ) {
489
- throw new Error( `Query status is "${status}"` );
490
- }
491
-
492
- if ( status === 'Complete' ) {
493
- return results;
494
- }
495
-
496
- // Running, Scheduled
497
- await sleep( pollingDelay );
498
- return getResults( { client, command } );
499
- };
500
-
501
- module.exports = async ( { client, queryId } ) => {
502
- const command = new GetQueryResultsCommand( { queryId } );
503
- return getResults( { client, command } );
504
- };
505
-
506
-
507
- /***/ }),
508
-
509
- /***/ 748:
510
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
511
-
512
- const select = __webpack_require__( 2157 );
513
-
514
- module.exports = async ( client, ...args ) => select( client, 'scan', ...args );
515
-
516
-
517
- /***/ }),
518
-
519
- /***/ 798:
520
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
521
-
522
- const validators = __webpack_require__( 8994 );
523
-
524
- module.exports = class Hook {
525
- #fn;
526
-
527
- constructor( { fn } ) {
528
- validators.function( fn );
529
- this.#fn = fn;
530
- }
531
-
532
- get fn() { return this.#fn; }
533
- };
534
-
535
-
536
- /***/ }),
537
-
538
- /***/ 809:
539
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
540
-
541
- const { DeleteSuppressedDestinationCommand } = __webpack_require__( 9556 );
542
-
543
- module.exports = ( client, address ) => client.send( new DeleteSuppressedDestinationCommand( { EmailAddress: address } ) );
544
-
545
-
546
- /***/ }),
547
-
548
- /***/ 834:
549
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
550
-
551
- const parseValue = __webpack_require__( 9129 );
552
-
553
- module.exports = resultSet => {
554
- const columns = resultSet.ResultSetMetadata.ColumnInfo
555
- .map( col => ( { name: col.Name, type: col.Type } ) );
556
-
557
- // first data row contains the table field names
558
- return resultSet.Rows.slice( 1 ).map( row => {
559
- const values = row.Data.map( d => d.VarCharValue );
560
- return columns.reduce( ( obj, p, i ) => Object.assign( obj, { [p.name]: parseValue( values[i], p.type ) } ), {} );
561
- } );
562
- };
563
-
564
-
565
- /***/ }),
566
-
567
- /***/ 943:
568
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
569
-
570
- const calcMean = __webpack_require__( 4124 );
571
- const calcMedian = __webpack_require__( 3187 );
572
- const calcMedianAbsDev = __webpack_require__( 4692 );
573
- const calcStdDevPopulation = __webpack_require__( 2736 );
574
- const calcStdDevSample = __webpack_require__( 6089 );
575
- const calcZScore = __webpack_require__( 4110 );
576
- const roundGaussian = __webpack_require__( 637 );
577
- const roundStandard = __webpack_require__( 115 );
578
-
579
- module.exports = {
580
- calcMean,
581
- calcMedian,
582
- calcMedianAbsDev,
583
- calcStdDevPopulation,
584
- calcStdDevSample,
585
- calcZScore,
586
- roundGaussian,
587
- roundStandard
588
- };
589
-
590
-
591
- /***/ }),
592
-
593
- /***/ 1417:
594
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
595
-
596
- const { GetCommand } = __webpack_require__( 3489 );
597
-
598
- const parseArgs = args => {
599
- // native args mode
600
- if ( args[0] instanceof Object ) {
601
- return args[0];
602
- }
603
- // sugar mode
604
- return {
605
- TableName: args[0],
606
- Key: args[1]
607
- };
608
- };
609
-
610
- module.exports = async ( client, ...args ) => {
611
- const response = await client.send( new GetCommand( parseArgs( args ) ) );
612
- return response.Item;
613
- };
614
-
615
-
616
- /***/ }),
617
-
618
- /***/ 1505:
619
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
620
-
621
- const documentClientProvider = __webpack_require__( 2966 );
622
- const get = __webpack_require__( 1417 );
623
- const put = __webpack_require__( 9628 );
624
- const putBatch = __webpack_require__( 5847 );
625
- const query = __webpack_require__( 5265 );
626
- const remove = __webpack_require__( 6777 );
627
- const removeBatch = __webpack_require__( 3862 );
628
- const scan = __webpack_require__( 748 );
629
- const smartUpdate = __webpack_require__( 2266 );
630
- const transactWrite = __webpack_require__( 1659 );
631
- const update = __webpack_require__( 4144 );
632
- const createInstance = __webpack_require__( 5438 );
633
-
634
- const methods = {
635
- get,
636
- put,
637
- putBatch,
638
- query,
639
- remove,
640
- removeBatch,
641
- scan,
642
- smartUpdate,
643
- transactWrite,
644
- update
325
+ // Finally makes the proxy which will allow each singleton method to use the client provider of the AWS service+
326
+ return new Proxy( factory, {
327
+ get( target, key ) {
328
+ const t = target[key];
329
+ return ( typeof t === 'function' ) ? t.bind( null, providerFn() ) : t;
330
+ }
331
+ } );
645
332
  };
646
333
 
647
- module.exports = createInstance( documentClientProvider, methods );
648
334
 
335
+ /***/ },
649
336
 
650
- /***/ }),
337
+ /***/ 5744
338
+ (module) {
651
339
 
652
- /***/ 1659:
653
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
340
+ module.exports = {
341
+ encode: k => {
342
+ if ( k === null || k === undefined ) { return k; }
654
343
 
655
- const { TransactWriteCommand } = __webpack_require__( 3489 );
344
+ return Buffer.from( JSON.stringify( k ) ).toString( 'base64' );
345
+ },
346
+ decode: k => {
347
+ if ( k === null || k === undefined ) { return k; }
656
348
 
657
- module.exports = async ( client, items ) => {
658
- const response = await client.send( new TransactWriteCommand( { TransactItems: items } ) );
659
- return response;
349
+ const result = Buffer.from( k, 'base64' ).toString( 'utf8' );
350
+ try {
351
+ return JSON.parse( result );
352
+ } catch {
353
+ return result;
354
+ }
355
+ }
660
356
  };
661
357
 
662
358
 
663
- /***/ }),
664
-
665
- /***/ 1671:
666
- /***/ ((module) => {
667
-
668
- "use strict";
669
- module.exports = require("@aws-sdk/client-timestream-query");
670
-
671
- /***/ }),
672
-
673
- /***/ 1783:
674
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
675
-
676
- const { SendEmailCommand } = __webpack_require__( 9556 );
677
-
678
- module.exports = ( client, { to = [], from, html, subject }, args ) =>
679
- client.send( new SendEmailCommand( {
680
- Destination: {
681
- ToAddresses: to
682
- },
683
- Content: {
684
- Simple: {
685
- Body: {
686
- Html: {
687
- Data: html,
688
- Charset: 'utf-8'
689
- }
690
- },
691
- Subject: {
692
- Data: subject
693
- }
694
- }
695
- },
696
- FromEmailAddress: from,
697
- ...args
698
- } ) );
699
-
700
-
701
- /***/ }),
702
-
703
- /***/ 1976:
704
- /***/ ((module) => {
705
-
706
- "use strict";
707
- module.exports = require("@aws-sdk/client-sqs");
708
-
709
- /***/ }),
710
-
711
- /***/ 2047:
712
- /***/ ((module) => {
713
-
714
- module.exports = o => Object.fromEntries( Object.entries( o ).filter( ( [ , v ] ) => !Array.isArray( v ) || v.length > 0 ) );
715
-
716
-
717
- /***/ }),
718
-
719
- /***/ 2157:
720
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
359
+ /***/ },
721
360
 
722
- const { encode, decode } = __webpack_require__( 5744 );
723
- const { ScanCommand, QueryCommand } = __webpack_require__( 3489 );
724
-
725
- const query = async ( { client, command, args, recursive, startKey, items = [], count = 0 } ) => {
726
- const response = await client.send( new command( {
727
- ...args,
728
- ...( startKey && { ExclusiveStartKey: startKey } )
729
- } ) );
730
-
731
- const isCount = args.Select === 'COUNT';
732
- const hasLimit = Number.isFinite( args.Limit );
733
-
734
- const result = {
735
- items: isCount ? null : items.concat( response.Items ),
736
- count: count + response.Count,
737
- startKey: response.LastEvaluatedKey
738
- };
739
-
740
- if ( !recursive ) {
741
- return { items: result.items, count: result.count, ...( result.startKey && { nextToken: encode( result.startKey ) } ) };
742
- }
743
-
744
- if ( result.startKey && ( isCount || ( hasLimit && result.items.length < args.Limit ) || ( !isCount && !hasLimit ) ) ) {
745
- return query( { client, command, args, recursive, ...result } );
746
- }
747
-
748
- if ( isCount ) {
749
- return { items: null, count: result.count };
750
- }
751
- const trimmedItems = result.items.slice( 0, args.Limit );
752
- return { items: trimmedItems, count: trimmedItems.length };
753
- };
361
+ /***/ 9039
362
+ (module, __unused_webpack_exports, __webpack_require__) {
754
363
 
755
- module.exports = async ( client, method, args, options = { recursive: false, paginationToken: null } ) => {
756
- const command = method === 'scan' ? ScanCommand : QueryCommand;
364
+ const cache = __webpack_require__( 4164 );
757
365
 
758
- return query( { client, command, args, recursive: options.recursive, startKey: decode( options.paginationToken ) } );
366
+ module.exports = ( constructor, args = [] ) => {
367
+ const cacheKey = `${constructor.name}(${args.map( arg => JSON.stringify( arg ) ).join( ',' )})`;
368
+ return cache.get( cacheKey ) ?? ( () => {
369
+ const client = Reflect.construct( constructor, args );
370
+ cache.set( cacheKey, client );
371
+ return client;
372
+ } )();
759
373
  };
760
374
 
761
375
 
762
- /***/ }),
376
+ /***/ },
763
377
 
764
- /***/ 2266:
765
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
378
+ /***/ 2710
379
+ (module, __unused_webpack_exports, __webpack_require__) {
766
380
 
767
- const { UpdateCommand } = __webpack_require__( 3489 );
381
+ const { CloudWatchLogsClient } = __webpack_require__( 7493 );
382
+ const clientProvider = __webpack_require__( 9039 );
383
+ const query = __webpack_require__( 4338 );
384
+ const createInstance = __webpack_require__( 5438 );
768
385
 
769
- module.exports = async ( client, tableName, key, keyValues ) => {
770
- const { updates, removals, names, values } = Object.entries( keyValues ).reduce( ( args, [ k, value ], index ) => {
771
- const isRemoval = value === undefined;
386
+ const methods = {
387
+ query
388
+ };
772
389
 
773
- const attrs = k.split( '.' ).map( ( attr, i ) => {
774
- const arrayPosition = attr.match( /\[(\d+)\]$/ )?.[1];
775
- return {
776
- key: `#${attr.replace( /\[\d+\]$|[^a-zA-Z0-9_]/g, '' )}${i}`,
777
- name: attr.replace( /\[\d+\]$/g, '' ),
778
- arrayPosition
779
- };
780
- } );
781
- const fullPath = attrs.map( attr => attr.key + ( attr.arrayPosition ? `[${attr.arrayPosition}]` : '' ) ).join( '.' );
782
- const valueId = `:v${index}`;
783
- const expAttrNames = attrs.reduce( ( obj, attr ) =>
784
- Object.assign( {}, obj, { [attr.key]: attr.name } )
785
- , {} );
390
+ module.exports = createInstance( clientProvider.bind( null, CloudWatchLogsClient ), methods );
786
391
 
787
- Object.assign( args.names, expAttrNames );
788
392
 
789
- if ( isRemoval ) {
790
- args.removals.push( fullPath );
791
- } else {
792
- args.updates.push( fullPath + ' = ' + valueId );
793
- Object.assign( args.values, { [valueId]: value } );
794
- }
393
+ /***/ },
795
394
 
796
- return args;
797
- }, { removals: [], updates: [], names: {}, values: {} } );
395
+ /***/ 739
396
+ (module, __unused_webpack_exports, __webpack_require__) {
798
397
 
799
- const conditionalExpressions = [];
800
- for ( const k of Object.keys( key ) ) {
801
- Object.assign( names, { [`#key_${k}`]: k } );
802
- conditionalExpressions.push( `attribute_exists(#key_${k})` );
803
- }
398
+ const { GetQueryResultsCommand } = __webpack_require__( 7493 );
399
+ const pollingDelay = __webpack_require__( 2549 );
400
+ const sleep = t => new Promise( r => setTimeout( () => r(), t ) );
804
401
 
805
- if ( updates.length + removals.length === 0 ) { return null; }
402
+ const getResults = async ( { client, command } ) => {
403
+ const { results, status } = await client.send( command );
806
404
 
807
- const expressions = [];
808
- if ( updates.length ) {
809
- expressions.push( 'SET ' + updates.join( ', ' ) );
810
- } if ( removals.length ) {
811
- expressions.push( 'REMOVE ' + removals.join( ', ' ) );
405
+ if ( [ 'Cancelled', 'Failed', 'Timeout', 'Unknown' ].includes( status ) ) {
406
+ throw new Error( `Query status is "${status}"` );
812
407
  }
813
408
 
814
- const statement = {
815
- TableName: tableName,
816
- ReturnValues: 'ALL_NEW',
817
- Key: key,
818
- ConditionExpression: conditionalExpressions.join( ' AND ' ),
819
- UpdateExpression: expressions.join( ' ' ),
820
- ExpressionAttributeNames: names
821
- };
822
- if ( Object.keys( values ).length > 0 ) {
823
- statement.ExpressionAttributeValues = values;
409
+ if ( status === 'Complete' ) {
410
+ return results;
824
411
  }
825
412
 
826
- try {
827
- const response = await client.send( new UpdateCommand( statement ) );
828
- return response.Attributes;
829
- } catch ( error ) {
830
- if ( error.constructor.name === 'ConditionalCheckFailedException' ) {
831
- console.info( 'Fail to update a record that was not found.' );
832
- return null;
833
- }
834
- throw error;
835
- }
413
+ // Running, Scheduled
414
+ await sleep( pollingDelay );
415
+ return getResults( { client, command } );
836
416
  };
837
417
 
838
-
839
- /***/ }),
840
-
841
- /***/ 2445:
842
- /***/ ((module) => {
843
-
844
- module.exports = t => new Promise( r => setTimeout( r, t ) );
845
-
846
-
847
- /***/ }),
848
-
849
- /***/ 2538:
850
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
851
-
852
- const writeRecords = __webpack_require__( 8936 );
853
- const { TimestreamWriteClient } = __webpack_require__( 8248 );
854
- const { Agent } = __webpack_require__( 5692 );
855
- const clientProvider = __webpack_require__( 9039 );
856
- const createInstance = __webpack_require__( 5438 );
857
-
858
- const methods = { writeRecords };
859
- const defaultArgs = {
860
- maxRetries: 10,
861
- httpOptions: { timeout: 60000, agent: new Agent( { maxSockets: 5000 } ) }
418
+ module.exports = async ( { client, queryId } ) => {
419
+ const command = new GetQueryResultsCommand( { queryId } );
420
+ return getResults( { client, command } );
862
421
  };
863
422
 
864
- module.exports = createInstance( args => clientProvider( TimestreamWriteClient, [ Object.assign( {}, defaultArgs, args ) ] ), methods );
865
-
866
-
867
- /***/ }),
868
423
 
869
- /***/ 2549:
870
- /***/ ((module) => {
424
+ /***/ },
871
425
 
872
- module.exports = 500;
873
-
874
-
875
- /***/ }),
876
-
877
- /***/ 2705:
878
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
879
-
880
- const LambdaApi = __webpack_require__( 321 );
881
-
882
- module.exports = { LambdaApi };
426
+ /***/ 4338
427
+ (module, __unused_webpack_exports, __webpack_require__) {
883
428
 
429
+ const startQuery = __webpack_require__( 3649 );
430
+ const getResults = __webpack_require__( 739 );
431
+ const parseResults = __webpack_require__( 9552 );
884
432
 
885
- /***/ }),
886
-
887
- /***/ 2710:
888
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
889
-
890
- const { CloudWatchLogsClient } = __webpack_require__( 7493 );
891
- const clientProvider = __webpack_require__( 9039 );
892
- const query = __webpack_require__( 4338 );
893
- const createInstance = __webpack_require__( 5438 );
433
+ /**
434
+ * @class Result
435
+ * @type {Object}
436
+ * @property {Object[]} items Each query result row, parsed to a camelized js object
437
+ * @property {Number} count Total number of results
438
+ */
894
439
 
895
- const methods = {
896
- query
440
+ /**
441
+ * Executes an Athena Query
442
+ * @param {*} client The native client
443
+ * @param {Object} nativeArgs The native args to start the Cloudwatch Query
444
+ * @param {Object=} options Extra options for this command
445
+ * @param {Object=} options.range Since the nativeArgs "startTime" and "endTime" are second based epochs, the "range" argument accepts milliseconds based epochs for convenience, thus overwriting the "nativeArgs"
446
+ * @param {Number} options.range.from The beginning of the time range to query, overwrites "startTime"
447
+ * @param {Number} options.range.to The end of the time range to query, overwrites "endTime"
448
+ * @returns {Result} The query result
449
+ */
450
+ module.exports = async ( client, nativeArgs, { range = {} } = {} ) => {
451
+ const queryId = await startQuery( { client, nativeArgs, range } );
452
+ const results = await getResults( { client, queryId } );
453
+ const items = parseResults( results );
454
+ return { items, count: items.length };
897
455
  };
898
456
 
899
- module.exports = createInstance( clientProvider.bind( null, CloudWatchLogsClient ), methods );
900
457
 
458
+ /***/ },
901
459
 
902
- /***/ }),
460
+ /***/ 9179
461
+ (module, __unused_webpack_exports, __webpack_require__) {
903
462
 
904
- /***/ 2736:
905
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
463
+ const parseValue = __webpack_require__( 2847 );
906
464
 
907
- const calcMean = __webpack_require__( 4124 );
465
+ module.exports = item =>
466
+ item.reduce( ( row, { field, value } ) =>
467
+ Object.assign( row, {
468
+ [field]: parseValue( value )
469
+ } ), {} );
908
470
 
909
- module.exports = values => {
910
- const mean = calcMean( values );
911
- const squareDiffs = values.map( value => Math.pow( value - mean, 2 ) );
912
- const avgSquareDiff = calcMean( squareDiffs );
913
- return Math.sqrt( avgSquareDiff );
914
- };
915
471
 
472
+ /***/ },
916
473
 
917
- /***/ }),
474
+ /***/ 9552
475
+ (module, __unused_webpack_exports, __webpack_require__) {
918
476
 
919
- /***/ 2836:
920
- /***/ ((module) => {
477
+ const parseItem = __webpack_require__( 9179 );
921
478
 
922
- module.exports = ( ...args ) => [ ...new Set( args.filter( Array.isArray ).flat() ) ];
479
+ module.exports = results => results.map( item => parseItem( item ) );
923
480
 
924
481
 
925
- /***/ }),
482
+ /***/ },
926
483
 
927
- /***/ 2847:
928
- /***/ ((module) => {
484
+ /***/ 2847
485
+ (module) {
929
486
 
930
487
  const parseInteger = value => {
931
488
  const number = parseInt( value, 10 );
@@ -973,10 +530,62 @@ module.exports = value => {
973
530
  };
974
531
 
975
532
 
976
- /***/ }),
533
+ /***/ },
534
+
535
+ /***/ 2549
536
+ (module) {
537
+
538
+ module.exports = 500;
539
+
540
+
541
+ /***/ },
542
+
543
+ /***/ 3649
544
+ (module, __unused_webpack_exports, __webpack_require__) {
545
+
546
+ const { StartQueryCommand } = __webpack_require__( 7493 );
547
+
548
+ module.exports = async ( { client, nativeArgs, range } ) => {
549
+ const startTime = range?.from ? Math.trunc( range.from / 1000 ) : nativeArgs.startTime;
550
+ const endTime = range?.to ? Math.trunc( range.to / 1000 ) : nativeArgs.endTime;
551
+
552
+ const { queryId } = await client.send( new StartQueryCommand( { ...nativeArgs, startTime, endTime } ) );
553
+ return queryId;
554
+ };
555
+
556
+
557
+ /***/ },
558
+
559
+ /***/ 8593
560
+ (module, __unused_webpack_exports, __webpack_require__) {
561
+
562
+ const { BatchWriteCommand } = __webpack_require__( 3489 );
563
+ const splitBatches = __webpack_require__( 4821 );
564
+
565
+ const batchSize = 25;
566
+
567
+ const getMapper = method => method === 'put' ? v => ( { PutRequest: { Item: v } } ) : v => ( { DeleteRequest: { Key: v } } );
568
+
569
+ const process = async ( { client, method, table, batches } ) => {
570
+ if ( batches.length === 0 ) { return true; }
571
+
572
+ const response = await client.send( new BatchWriteCommand( { RequestItems: { [table]: batches[0] } } ) );
573
+
574
+ const unprocessed = response.UnprocessedItems?.[table];
575
+ return process( {
576
+ client, method, table,
577
+ batches: unprocessed ? splitBatches( batches.slice( 1 ).flat().concat( unprocessed ), batchSize ) : batches.slice( 1 )
578
+ } );
579
+ };
580
+
581
+ module.exports = async ( client, method, table, items ) =>
582
+ process( { client, method, table, batches: splitBatches( items.map( getMapper( method ) ), batchSize ) } );
583
+
584
+
585
+ /***/ },
977
586
 
978
- /***/ 2966:
979
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
587
+ /***/ 2966
588
+ (module, __unused_webpack_exports, __webpack_require__) {
980
589
 
981
590
  const { DynamoDBClient } = __webpack_require__( 4671 );
982
591
  const { DynamoDBDocumentClient } = __webpack_require__( 3489 );
@@ -1011,426 +620,418 @@ module.exports = nativeArgs => {
1011
620
  };
1012
621
 
1013
622
 
1014
- /***/ }),
623
+ /***/ },
1015
624
 
1016
- /***/ 3099:
1017
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
625
+ /***/ 1417
626
+ (module, __unused_webpack_exports, __webpack_require__) {
1018
627
 
1019
- const publish = __webpack_require__( 8080 );
1020
- const publishBatch = __webpack_require__( 3531 );
1021
- const { SNSClient } = __webpack_require__( 7651 );
1022
- const clientProvider = __webpack_require__( 9039 );
1023
- const createInstance = __webpack_require__( 5438 );
628
+ const { GetCommand } = __webpack_require__( 3489 );
1024
629
 
1025
- const methods = {
1026
- publish,
1027
- publishBatch
630
+ const parseArgs = args => {
631
+ // native args mode
632
+ if ( args[0] instanceof Object ) {
633
+ return args[0];
634
+ }
635
+ // sugar mode
636
+ return {
637
+ TableName: args[0],
638
+ Key: args[1]
639
+ };
1028
640
  };
1029
641
 
1030
- module.exports = createInstance( clientProvider.bind( null, SNSClient ), methods );
642
+ module.exports = async ( client, ...args ) => {
643
+ const response = await client.send( new GetCommand( parseArgs( args ) ) );
644
+ return response.Item;
645
+ };
1031
646
 
1032
647
 
1033
- /***/ }),
648
+ /***/ },
1034
649
 
1035
- /***/ 3106:
1036
- /***/ ((module) => {
650
+ /***/ 1505
651
+ (module, __unused_webpack_exports, __webpack_require__) {
1037
652
 
1038
- "use strict";
1039
- module.exports = require("zlib");
653
+ const documentClientProvider = __webpack_require__( 2966 );
654
+ const get = __webpack_require__( 1417 );
655
+ const put = __webpack_require__( 9628 );
656
+ const putBatch = __webpack_require__( 5847 );
657
+ const query = __webpack_require__( 5265 );
658
+ const remove = __webpack_require__( 6777 );
659
+ const removeBatch = __webpack_require__( 3862 );
660
+ const scan = __webpack_require__( 748 );
661
+ const smartUpdate = __webpack_require__( 2266 );
662
+ const transactWrite = __webpack_require__( 1659 );
663
+ const update = __webpack_require__( 4144 );
664
+ const createInstance = __webpack_require__( 5438 );
1040
665
 
1041
- /***/ }),
666
+ const methods = {
667
+ get,
668
+ put,
669
+ putBatch,
670
+ query,
671
+ remove,
672
+ removeBatch,
673
+ scan,
674
+ smartUpdate,
675
+ transactWrite,
676
+ update
677
+ };
1042
678
 
1043
- /***/ 3109:
1044
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
679
+ module.exports = createInstance( documentClientProvider, methods );
1045
680
 
1046
- const validators = __webpack_require__( 8994 );
1047
681
 
1048
- module.exports = class Handler {
1049
- #method;
1050
- #fn;
1051
- #route;
1052
- #routeIncludes;
1053
- #routeNotIncludes;
1054
- #routeMatches;
1055
- #path;
1056
- #pathIncludes;
1057
- #pathNotIncludes;
1058
- #pathMatches;
682
+ /***/ },
1059
683
 
1060
- constructor( { method, fn, ...matchers } ) {
1061
- validators.httpMethod( method );
1062
- validators.function( fn );
1063
- validators.matcherRoute( matchers.route );
1064
- validators.matcherRouteIncludes( matchers.routeIncludes );
1065
- validators.matcherRouteNotIncludes( matchers.routeNotIncludes );
1066
- validators.matcherRouteMatch( matchers.routeMatch );
1067
- validators.matcherPath( matchers.path );
1068
- validators.matcherPathIncludes( matchers.pathIncludes );
1069
- validators.matcherPathNotIncludes( matchers.pathNotIncludes );
1070
- validators.matcherPathMatch( matchers.pathMatch );
684
+ /***/ 9628
685
+ (module, __unused_webpack_exports, __webpack_require__) {
1071
686
 
1072
- this.#method = method;
1073
- this.#fn = fn;
1074
- this.#route = matchers.route;
1075
- this.#routeIncludes = matchers.routeIncludes;
1076
- this.#routeNotIncludes = matchers.routeNotIncludes;
1077
- this.#routeMatches = matchers.routeMatches;
1078
- this.#path = matchers.path;
1079
- this.#pathIncludes = matchers.pathIncludes;
1080
- this.#pathNotIncludes = matchers.pathNotIncludes;
1081
- this.#pathMatches = matchers.pathMatches;
1082
- }
687
+ const { PutCommand } = __webpack_require__( 3489 );
1083
688
 
1084
- match( event ) {
1085
- if ( this.#method !== event.method ) {
1086
- return false;
1087
- }
1088
- if ( this.#route ) {
1089
- return this.#route === event.route;
1090
- }
1091
- if ( this.#path ) {
1092
- return this.#path === event.path;
1093
- }
1094
- if ( this.#routeIncludes && !event.route.includes( this.#routeIncludes ) ) {
1095
- return false;
1096
- }
1097
- if ( this.#routeNotIncludes && event.route.includes( this.#routeNotIncludes ) ) {
1098
- return false;
1099
- }
1100
- if ( this.#routeMatches && !this.#routeMatches.test( event.route ) ) {
1101
- return false;
1102
- }
1103
- if ( this.#pathIncludes && !event.path.includes( this.#pathIncludes ) ) {
1104
- return false;
1105
- }
1106
- if ( this.#pathNotIncludes && event.path.includes( this.#pathNotIncludes ) ) {
1107
- return false;
1108
- }
1109
- if ( this.#pathMatches && !this.#pathMatches.test( event.path ) ) {
1110
- return false;
1111
- }
1112
- return true;
689
+ const parseArgs = args => {
690
+ // native args mode
691
+ if ( args[0] instanceof Object ) {
692
+ return args[0];
1113
693
  }
694
+ // sugar mode
695
+ return {
696
+ TableName: args[0],
697
+ Item: args[1],
698
+ ReturnValues: 'NONE',
699
+ ReturnConsumedCapacity: 'NONE'
700
+ };
701
+ };
1114
702
 
1115
- get fn() { return this.#fn; }
703
+ /**
704
+ *
705
+ * @param {*} client
706
+ * @param {...any} args The args. either one object with the native args or two string args, tableName and item.
707
+ * @returns
708
+ */
709
+ module.exports = async ( client, ...args ) => {
710
+ const nativeArgs = parseArgs( args );
711
+ const response = await client.send( new PutCommand( nativeArgs ) );
712
+ return response.Attributes ?? nativeArgs.Item;
1116
713
  };
1117
714
 
1118
715
 
1119
- /***/ }),
716
+ /***/ },
1120
717
 
1121
- /***/ 3119:
1122
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
718
+ /***/ 5847
719
+ (module, __unused_webpack_exports, __webpack_require__) {
1123
720
 
1124
- const { snakelize, camelize } = __webpack_require__( 5762 );
1125
- const charset = 'utf-8';
721
+ const batchWrite = __webpack_require__( 8593 );
1126
722
 
1127
- const transformFns = {
1128
- camelcase: camelize,
1129
- snakecase: snakelize
1130
- };
723
+ module.exports = async ( client, ...args ) => batchWrite( client, 'put', ...args );
1131
724
 
1132
- module.exports = class ApiResponse {
1133
- #headers = null;
1134
- #statusCode = null;
1135
- #transformFn = false;
1136
- #isBase64Encoded = false;
1137
- #body = '';
1138
725
 
1139
- constructor( { headers = {}, transform } = {} ) {
1140
- this.#transformFn = transformFns[transform] ?? ( v => v );
1141
- this.#headers = Object.assign( {
1142
- 'Cache-Control': 'no-store',
1143
- 'Access-Control-Allow-Origin': '*'
1144
- }, headers );
1145
- }
726
+ /***/ },
1146
727
 
1147
- setContent( statusCode, body, headers = {}, isBase64Encoded = false ) {
1148
- this.#statusCode = statusCode;
1149
- this.#isBase64Encoded = isBase64Encoded;
1150
- if ( body?.length === 0 || [ null, undefined ].includes( body ) ) {
1151
- this.#body = '';
1152
- } else if ( typeof body === 'object' ) {
1153
- this.#body = JSON.stringify( this.#transformFn( body ) );
1154
- this.#headers['Content-Type'] = `application/json; charset=${charset}`;
1155
- } else {
1156
- this.#body = String( body );
1157
- this.#headers['Content-Type'] = `text/plain; charset=${charset}`;
1158
- }
1159
- this.#headers['Content-Length'] = this.#body.length;
1160
- Object.assign( this.#headers, headers ?? {} );
1161
- return this;
1162
- }
728
+ /***/ 5265
729
+ (module, __unused_webpack_exports, __webpack_require__) {
1163
730
 
1164
- toJSON() {
1165
- return {
1166
- isBase64Encoded: this.#isBase64Encoded,
1167
- statusCode: this.#statusCode,
1168
- body: this.#body,
1169
- headers: this.#headers
1170
- };
1171
- }
1172
- };
731
+ const select = __webpack_require__( 2157 );
1173
732
 
733
+ module.exports = async ( client, ...args ) => select( client, 'query', ...args );
1174
734
 
1175
- /***/ }),
1176
735
 
1177
- /***/ 3131:
1178
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
736
+ /***/ },
1179
737
 
1180
- const { SendMessageBatchCommand } = __webpack_require__( 1976 );
1181
- const sanitizeSqs = __webpack_require__( 8175 );
738
+ /***/ 6777
739
+ (module, __unused_webpack_exports, __webpack_require__) {
1182
740
 
1183
- module.exports = async ( client, queue, messages ) => {
1184
- if ( messages.length > 10 ) {
1185
- throw new Error( 'SQS.sendMessageBatch only accepts up to 10 messages.' );
1186
- }
1187
- const response = await client.send( new SendMessageBatchCommand( {
1188
- QueueUrl: queue,
1189
- Entries: messages.map( ( { body, id = null, nativeArgs }, index ) => ( {
1190
- Id: id ?? `message_${index}`,
1191
- MessageBody: sanitizeSqs( typeof body === 'string' ? body : JSON.stringify( body ) ),
1192
- ...nativeArgs
1193
- } ) )
741
+ const { DeleteCommand } = __webpack_require__( 3489 );
742
+
743
+ module.exports = async ( client, tableName, key ) => {
744
+ const { Attributes: item } = await client.send( new DeleteCommand( {
745
+ ReturnValues: 'ALL_OLD',
746
+ TableName: tableName,
747
+ Key: key
1194
748
  } ) );
1195
-
1196
- if ( response.Failed?.length > 0 ) {
1197
- const error = new Error( 'SQS.sendMessageBatch Failed. See error details' );
1198
- error.details = response.Failed;
1199
- throw error;
1200
- }
1201
- return response;
749
+ return item;
1202
750
  };
1203
751
 
1204
752
 
1205
- /***/ }),
753
+ /***/ },
1206
754
 
1207
- /***/ 3187:
1208
- /***/ ((module) => {
755
+ /***/ 3862
756
+ (module, __unused_webpack_exports, __webpack_require__) {
1209
757
 
1210
- module.exports = values => {
1211
- //Sort bug: https://www.tutorialrepublic.com/faq/how-to-sort-an-array-of-integers-correctly-in-javascript.php
1212
- const sorted = values.slice().sort( ( a, b ) => a - b );
1213
- const evenArray = values.length % 2 === 0;
1214
- const midIndex = Math.floor( values.length / 2 );
1215
- return evenArray ? ( sorted[midIndex - 1] + sorted[midIndex] ) / 2 : sorted[midIndex];
1216
- };
758
+ const batchWrite = __webpack_require__( 8593 );
1217
759
 
760
+ module.exports = async ( client, ...args ) => batchWrite( client, 'remove', ...args );
1218
761
 
1219
- /***/ }),
1220
762
 
1221
- /***/ 3258:
1222
- /***/ ((module) => {
763
+ /***/ },
1223
764
 
1224
- module.exports = input =>
1225
- // Break the string into sequences to rebuild later
1226
- !input ? input : input.split( /\s/ )
1227
- // ALL_CAPS terms are ignored
1228
- .map( term => [ term, term.charAt( 0 ).toUpperCase() + term.slice( 1 ).toLowerCase() ] )
1229
- // Rebuild the string replacing the converter terms keeping the original delimiters
1230
- .reduce( ( result, [ term, repl ] ) => result.replace( term, repl ), input );
765
+ /***/ 748
766
+ (module, __unused_webpack_exports, __webpack_require__) {
1231
767
 
768
+ const select = __webpack_require__( 2157 );
1232
769
 
1233
- /***/ }),
770
+ module.exports = async ( client, ...args ) => select( client, 'scan', ...args );
1234
771
 
1235
- /***/ 3340:
1236
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1237
772
 
1238
- const deleteMessage = __webpack_require__( 5637 );
1239
- const sendMessage = __webpack_require__( 6720 );
1240
- const sendMessageBatch = __webpack_require__( 3131 );
1241
- const { SQSClient } = __webpack_require__( 1976 );
1242
- const clientProvider = __webpack_require__( 9039 );
1243
- const createInstance = __webpack_require__( 5438 );
773
+ /***/ },
1244
774
 
1245
- const methods = {
1246
- deleteMessage,
1247
- sendMessage,
1248
- sendMessageBatch
1249
- };
775
+ /***/ 2157
776
+ (module, __unused_webpack_exports, __webpack_require__) {
1250
777
 
1251
- module.exports = createInstance( clientProvider.bind( null, SQSClient ), methods );
778
+ const { encode, decode } = __webpack_require__( 5744 );
779
+ const { ScanCommand, QueryCommand } = __webpack_require__( 3489 );
1252
780
 
781
+ const query = async ( { client, command, args, recursive, startKey, items = [], count = 0 } ) => {
782
+ const response = await client.send( new command( {
783
+ ...args,
784
+ ...( startKey && { ExclusiveStartKey: startKey } )
785
+ } ) );
1253
786
 
1254
- /***/ }),
787
+ const isCount = args.Select === 'COUNT';
788
+ const hasLimit = Number.isFinite( args.Limit );
1255
789
 
1256
- /***/ 3402:
1257
- /***/ ((module) => {
790
+ const result = {
791
+ items: isCount ? null : items.concat( response.Items ),
792
+ count: count + response.Count,
793
+ startKey: response.LastEvaluatedKey
794
+ };
1258
795
 
1259
- // convert a string to snake_case
1260
- module.exports = ( input, { keepAllCaps = false } = {} ) =>
1261
- // Break the string into sequences to rebuild later
1262
- !input ? input : input.split( /\s/ )
1263
- // ALL_CAPS terms are ignored
1264
- .map( term => [ term, keepAllCaps && /^[A-Z_]+$/g.test( term ) ? term : term
1265
- .replace( /-/g, '_' ) // replaces hyphen
1266
- .replace( /([a-z\d])([A-Z])/g, '$1_$2' ) // add _ between lower and upper case letters
1267
- .replace( /([A-Z])([A-Z])(?=[a-z\d])/g, '$1_$2' ).toLowerCase() // add _ between uppercase char and next uppercase char follow by lowercase
1268
- ] )
1269
- // Rebuild the string replacing the converter terms keeping the original delimiters
1270
- .reduce( ( result, [ term, repl ] ) => result.replace( term, repl ), input );
796
+ if ( !recursive ) {
797
+ return { items: result.items, count: result.count, ...( result.startKey && { nextToken: encode( result.startKey ) } ) };
798
+ }
799
+
800
+ if ( result.startKey && ( isCount || ( hasLimit && result.items.length < args.Limit ) || ( !isCount && !hasLimit ) ) ) {
801
+ return query( { client, command, args, recursive, ...result } );
802
+ }
803
+
804
+ if ( isCount ) {
805
+ return { items: null, count: result.count };
806
+ }
807
+ const trimmedItems = result.items.slice( 0, args.Limit );
808
+ return { items: trimmedItems, count: trimmedItems.length };
809
+ };
1271
810
 
811
+ module.exports = async ( client, method, args, options = { recursive: false, paginationToken: null } ) => {
812
+ const command = method === 'scan' ? ScanCommand : QueryCommand;
1272
813
 
1273
- /***/ }),
814
+ return query( { client, command, args, recursive: options.recursive, startKey: decode( options.paginationToken ) } );
815
+ };
1274
816
 
1275
- /***/ 3446:
1276
- /***/ ((module) => {
1277
817
 
1278
- module.exports = class LambdaApiValidationError extends Error {};
818
+ /***/ },
1279
819
 
820
+ /***/ 2266
821
+ (module, __unused_webpack_exports, __webpack_require__) {
1280
822
 
1281
- /***/ }),
823
+ const { UpdateCommand } = __webpack_require__( 3489 );
1282
824
 
1283
- /***/ 3489:
1284
- /***/ ((module) => {
825
+ module.exports = async ( client, tableName, key, keyValues ) => {
826
+ const { updates, removals, names, values } = Object.entries( keyValues ).reduce( ( args, [ k, value ], index ) => {
827
+ const isRemoval = value === undefined;
1285
828
 
1286
- "use strict";
1287
- module.exports = require("@aws-sdk/lib-dynamodb");
829
+ const attrs = k.split( '.' ).map( ( attr, i ) => {
830
+ const arrayPosition = attr.match( /\[(\d+)\]$/ )?.[1];
831
+ return {
832
+ key: `#${attr.replace( /\[\d+\]$|[^a-zA-Z0-9_]/g, '' )}${i}`,
833
+ name: attr.replace( /\[\d+\]$/g, '' ),
834
+ arrayPosition
835
+ };
836
+ } );
837
+ const fullPath = attrs.map( attr => attr.key + ( attr.arrayPosition ? `[${attr.arrayPosition}]` : '' ) ).join( '.' );
838
+ const valueId = `:v${index}`;
839
+ const expAttrNames = attrs.reduce( ( obj, attr ) =>
840
+ Object.assign( {}, obj, { [attr.key]: attr.name } )
841
+ , {} );
1288
842
 
1289
- /***/ }),
843
+ Object.assign( args.names, expAttrNames );
1290
844
 
1291
- /***/ 3531:
1292
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
845
+ if ( isRemoval ) {
846
+ args.removals.push( fullPath );
847
+ } else {
848
+ args.updates.push( fullPath + ' = ' + valueId );
849
+ Object.assign( args.values, { [valueId]: value } );
850
+ }
1293
851
 
1294
- const { PublishBatchCommand } = __webpack_require__( 7651 );
852
+ return args;
853
+ }, { removals: [], updates: [], names: {}, values: {} } );
1295
854
 
1296
- module.exports = async ( client, topic, messages ) => {
1297
- if ( messages.length > 10 ) {
1298
- throw new Error( 'SNS.publishBatch only accepts up to 10 messages.' );
855
+ const conditionalExpressions = [];
856
+ for ( const k of Object.keys( key ) ) {
857
+ Object.assign( names, { [`#key_${k}`]: k } );
858
+ conditionalExpressions.push( `attribute_exists(#key_${k})` );
1299
859
  }
1300
- const response = await client.send( new PublishBatchCommand( {
1301
- TopicArn: topic,
1302
- PublishBatchRequestEntries: messages.map( ( { body, id = null, nativeArgs }, index ) => ( {
1303
- Id: id ?? `message_${index}`,
1304
- Message: typeof body === 'string' ? body : JSON.stringify( body ),
1305
- ...nativeArgs
1306
- } ) )
1307
- } ) );
1308
860
 
1309
- if ( response.Failed?.length > 0 ) {
1310
- const error = new Error( 'SNS.publishBatch Failed. See error details' );
1311
- error.details = response.Failed;
861
+ if ( updates.length + removals.length === 0 ) { return null; }
862
+
863
+ const expressions = [];
864
+ if ( updates.length ) {
865
+ expressions.push( 'SET ' + updates.join( ', ' ) );
866
+ } if ( removals.length ) {
867
+ expressions.push( 'REMOVE ' + removals.join( ', ' ) );
868
+ }
869
+
870
+ const statement = {
871
+ TableName: tableName,
872
+ ReturnValues: 'ALL_NEW',
873
+ Key: key,
874
+ ConditionExpression: conditionalExpressions.join( ' AND ' ),
875
+ UpdateExpression: expressions.join( ' ' ),
876
+ ExpressionAttributeNames: names
877
+ };
878
+ if ( Object.keys( values ).length > 0 ) {
879
+ statement.ExpressionAttributeValues = values;
880
+ }
881
+
882
+ try {
883
+ const response = await client.send( new UpdateCommand( statement ) );
884
+ return response.Attributes;
885
+ } catch ( error ) {
886
+ if ( error.constructor.name === 'ConditionalCheckFailedException' ) {
887
+ console.info( 'Fail to update a record that was not found.' );
888
+ return null;
889
+ }
1312
890
  throw error;
1313
891
  }
1314
- return response;
1315
892
  };
1316
893
 
1317
894
 
1318
- /***/ }),
895
+ /***/ },
1319
896
 
1320
- /***/ 3544:
1321
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
897
+ /***/ 1659
898
+ (module, __unused_webpack_exports, __webpack_require__) {
1322
899
 
1323
- const invoke = __webpack_require__( 5894 );
1324
- const { LambdaClient } = __webpack_require__( 5892 );
1325
- const clientProvider = __webpack_require__( 9039 );
1326
- const createInstance = __webpack_require__( 5438 );
900
+ const { TransactWriteCommand } = __webpack_require__( 3489 );
1327
901
 
1328
- const methods = {
1329
- invoke
902
+ module.exports = async ( client, items ) => {
903
+ const response = await client.send( new TransactWriteCommand( { TransactItems: items } ) );
904
+ return response;
1330
905
  };
1331
906
 
1332
- module.exports = createInstance( clientProvider.bind( null, LambdaClient ), methods );
1333
907
 
908
+ /***/ },
1334
909
 
1335
- /***/ }),
910
+ /***/ 4144
911
+ (module, __unused_webpack_exports, __webpack_require__) {
1336
912
 
1337
- /***/ 3649:
1338
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
913
+ const { UpdateCommand } = __webpack_require__( 3489 );
1339
914
 
1340
- const { StartQueryCommand } = __webpack_require__( 7493 );
915
+ module.exports = async ( client, nativeArgs ) => {
916
+ const args = Object.assign( { ReturnValues: 'ALL_NEW' }, nativeArgs );
917
+ const response = await client.send( new UpdateCommand( args ) );
918
+ return response.Attributes;
919
+ };
1341
920
 
1342
- module.exports = async ( { client, nativeArgs, range } ) => {
1343
- const startTime = range?.from ? Math.trunc( range.from / 1000 ) : nativeArgs.startTime;
1344
- const endTime = range?.to ? Math.trunc( range.to / 1000 ) : nativeArgs.endTime;
1345
921
 
1346
- const { queryId } = await client.send( new StartQueryCommand( { ...nativeArgs, startTime, endTime } ) );
1347
- return queryId;
1348
- };
922
+ /***/ },
1349
923
 
924
+ /***/ 4870
925
+ (module, __unused_webpack_exports, __webpack_require__) {
1350
926
 
1351
- /***/ }),
927
+ const athena = __webpack_require__( 228 );
928
+ const cwLogs = __webpack_require__( 2710 );
929
+ const dynamo = __webpack_require__( 1505 );
930
+ const lambda = __webpack_require__( 3544 );
931
+ const s3 = __webpack_require__( 645 );
932
+ const ses = __webpack_require__( 5624 );
933
+ const sns = __webpack_require__( 3099 );
934
+ const sqs = __webpack_require__( 3340 );
935
+ const ssm = __webpack_require__( 5888 );
936
+ const timestreamQuery = __webpack_require__( 4225 );
937
+ const timestreamWrite = __webpack_require__( 2538 );
1352
938
 
1353
- /***/ 3744:
1354
- /***/ ((module) => {
939
+ module.exports = {
940
+ athena,
941
+ cwLogs,
942
+ dynamo,
943
+ lambda,
944
+ s3,
945
+ ses,
946
+ sns,
947
+ sqs,
948
+ ssm,
949
+ timestreamQuery,
950
+ timestreamWrite
951
+ };
1355
952
 
1356
- "use strict";
1357
- module.exports = require("@aws-sdk/client-athena");
1358
953
 
1359
- /***/ }),
954
+ /***/ },
1360
955
 
1361
- /***/ 3758:
1362
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
956
+ /***/ 3544
957
+ (module, __unused_webpack_exports, __webpack_require__) {
1363
958
 
1364
- const { getSignedUrl } = __webpack_require__( 4991 );
1365
- const { GetObjectCommand } = __webpack_require__( 5725 );
959
+ const invoke = __webpack_require__( 5894 );
960
+ const { LambdaClient } = __webpack_require__( 5892 );
961
+ const clientProvider = __webpack_require__( 9039 );
962
+ const createInstance = __webpack_require__( 5438 );
1366
963
 
1367
- module.exports = async ( client, bucket, key, expiration ) => {
1368
- const getObjectCmd = new GetObjectCommand( { Bucket: bucket, Key: key } );
1369
- const url = await getSignedUrl( client, getObjectCmd, { expiresIn: expiration } );
1370
- return url;
964
+ const methods = {
965
+ invoke
1371
966
  };
1372
967
 
968
+ module.exports = createInstance( clientProvider.bind( null, LambdaClient ), methods );
1373
969
 
1374
- /***/ }),
1375
970
 
1376
- /***/ 3830:
1377
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
971
+ /***/ },
1378
972
 
1379
- const days = __webpack_require__( 5263 );
1380
- const hours = __webpack_require__( 6961 );
1381
- const minutes = __webpack_require__( 6635 );
1382
- const months = __webpack_require__( 8119 );
1383
- const msToS = __webpack_require__( 7416 );
1384
- const round = __webpack_require__( 3990 );
1385
- const seconds = __webpack_require__( 7051 );
973
+ /***/ 5894
974
+ (module, __unused_webpack_exports, __webpack_require__) {
1386
975
 
1387
- module.exports = {
1388
- days,
1389
- hours,
1390
- minutes,
1391
- months,
1392
- msToS,
1393
- round,
1394
- seconds
1395
- };
976
+ const { InvokeCommand } = __webpack_require__( 5892 );
977
+ const AWSLambdaError = __webpack_require__( 468 );
1396
978
 
979
+ module.exports = async ( client, name, payload = {}, type = 'RequestResponse' ) => {
980
+ const response = await client.send( new InvokeCommand( {
981
+ FunctionName: name,
982
+ InvocationType: type,
983
+ Payload: Buffer.from( JSON.stringify( payload ) )
984
+ } ) );
1397
985
 
1398
- /***/ }),
986
+ if ( response.FunctionError ) {
987
+ throw new AWSLambdaError( response );
988
+ }
1399
989
 
1400
- /***/ 3862:
1401
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
990
+ if ( type !== 'RequestResponse' ) { return true; }
1402
991
 
1403
- const batchWrite = __webpack_require__( 8593 );
992
+ try {
993
+ return JSON.parse( Buffer.from( response.Payload ).toString() );
994
+ } catch {
995
+ return response.Payload;
996
+ }
997
+ };
1404
998
 
1405
- module.exports = async ( client, ...args ) => batchWrite( client, 'remove', ...args );
1406
999
 
1000
+ /***/ },
1407
1001
 
1408
- /***/ }),
1002
+ /***/ 468
1003
+ (module) {
1409
1004
 
1410
- /***/ 3914:
1411
- /***/ ((module) => {
1005
+ const parsePayload = payload => {
1006
+ try {
1007
+ return JSON.parse( Buffer.from( payload ).toString( 'utf-8' ) );
1008
+ } catch {
1009
+ return null;
1010
+ }
1011
+ };
1412
1012
 
1413
- // Convert a string to camelCase
1414
- module.exports = ( input, { keepAllCaps = false } = {} ) =>
1415
- // Break the string into sequences to rebuild later
1416
- !input ? input : input.split( /\s/ )
1417
- // ALL_CAPS terms are ignored
1418
- .map( term => [ term, keepAllCaps && /^[A-Z_]+$/g.test( term ) ? term : term
1419
- // Matches the penultimate letter in a sequence of upper case followed by lower case and convert it to lower case
1420
- // Effectively creating a word break eg: BDay => bDay
1421
- .replace( /[A-Z](?=[A-Z][a-z])/g, c => `${c[0].toLowerCase()}` )
1422
- .replace( /([A-Z])([A-Z]+)/g, c => `${c[0]}${c.slice( 1 ).toLowerCase()}` ) // Sequences of upper case
1423
- .replace( /([-_]\w)/g, c => c[1].toUpperCase() ) // first letter after hyphen and underline
1424
- .replace( /^([A-Z])/g, c => c[0].toLowerCase() ) // first letter
1425
- ] )
1426
- // Rebuild the string replacing the converter terms keeping the original delimiters
1427
- .reduce( ( result, [ term, repl ] ) => result.replace( term, repl ), input );
1013
+ module.exports = class LambdaError extends Error {
1014
+ constructor( response ) {
1015
+ const { StatusCode: statusCode, Payload: rawPayload } = response;
1016
+ const payload = parsePayload( rawPayload );
1017
+ const lambdaErrorType = payload?.errorType ?? Error.name;
1018
+ const lambdaErrorMessage = payload?.errorMessage;
1019
+ if ( statusCode === 200 ) {
1020
+ super( `Invoked function threw "[${lambdaErrorType}]${lambdaErrorMessage ? ' ' + lambdaErrorMessage : ''}"` );
1021
+ } else {
1022
+ super( 'Error invoking the function' );
1023
+ }
1024
+ this.statusCode = statusCode;
1025
+ this.lambdaErrorType = lambdaErrorType;
1026
+ this.lambdaErrorMessage = lambdaErrorMessage;
1027
+ }
1028
+ };
1428
1029
 
1429
1030
 
1430
- /***/ }),
1031
+ /***/ },
1431
1032
 
1432
- /***/ 3936:
1433
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1033
+ /***/ 3936
1034
+ (module, __unused_webpack_exports, __webpack_require__) {
1434
1035
 
1435
1036
  const { CopyObjectCommand } = __webpack_require__( 5725 );
1436
1037
 
@@ -1445,1076 +1046,1328 @@ module.exports = async ( client, bucket, key, source, nativeArgs ) => {
1445
1046
  };
1446
1047
 
1447
1048
 
1448
- /***/ }),
1449
-
1450
- /***/ 3990:
1451
- /***/ ((module) => {
1049
+ /***/ },
1452
1050
 
1453
- module.exports = ( time, interval ) => time - ( time % interval );
1051
+ /***/ 345
1052
+ (module, __unused_webpack_exports, __webpack_require__) {
1454
1053
 
1054
+ const { GetObjectCommand } = __webpack_require__( 5725 );
1455
1055
 
1456
- /***/ }),
1056
+ module.exports = async ( client, bucket, key, nativeArgs ) => {
1057
+ const response = await client.send( new GetObjectCommand( {
1058
+ ...nativeArgs,
1059
+ Bucket: bucket,
1060
+ Key: key
1061
+ } ) );
1062
+ const stream = response.Body;
1063
+ return Buffer.concat( await stream.toArray() ).toString( 'utf-8' );
1064
+ };
1457
1065
 
1458
- /***/ 4110:
1459
- /***/ ((module) => {
1460
1066
 
1461
- module.exports = ( sample, mean, stdDev ) => stdDev === 0 ? NaN : ( sample - mean ) / stdDev;
1067
+ /***/ },
1462
1068
 
1069
+ /***/ 3758
1070
+ (module, __unused_webpack_exports, __webpack_require__) {
1463
1071
 
1464
- /***/ }),
1072
+ const { getSignedUrl } = __webpack_require__( 4991 );
1073
+ const { GetObjectCommand } = __webpack_require__( 5725 );
1465
1074
 
1466
- /***/ 4124:
1467
- /***/ ((module) => {
1075
+ module.exports = async ( client, bucket, key, expiration ) => {
1076
+ const getObjectCmd = new GetObjectCommand( { Bucket: bucket, Key: key } );
1077
+ const url = await getSignedUrl( client, getObjectCmd, { expiresIn: expiration } );
1078
+ return url;
1079
+ };
1468
1080
 
1469
- module.exports = values => values.reduce( ( sum, value ) => sum + value, 0 ) / values.length;
1470
1081
 
1082
+ /***/ },
1471
1083
 
1472
- /***/ }),
1084
+ /***/ 279
1085
+ (module, __unused_webpack_exports, __webpack_require__) {
1473
1086
 
1474
- /***/ 4127:
1475
- /***/ ((module) => {
1087
+ const { HeadObjectCommand } = __webpack_require__( 5725 );
1476
1088
 
1477
- module.exports = 500;
1089
+ module.exports = async ( client, bucket, key ) =>
1090
+ client.send( new HeadObjectCommand( { Bucket: bucket, Key: key } ) );
1478
1091
 
1479
1092
 
1480
- /***/ }),
1093
+ /***/ },
1481
1094
 
1482
- /***/ 4144:
1483
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1095
+ /***/ 645
1096
+ (module, __unused_webpack_exports, __webpack_require__) {
1484
1097
 
1485
- const { UpdateCommand } = __webpack_require__( 3489 );
1098
+ const copy = __webpack_require__( 3936 );
1099
+ const download = __webpack_require__( 345 );
1100
+ const getSignedUrl = __webpack_require__( 3758 );
1101
+ const head = __webpack_require__( 279 );
1102
+ const upload = __webpack_require__( 9704 );
1103
+ const { S3Client } = __webpack_require__( 5725 );
1104
+ const clientProvider = __webpack_require__( 9039 );
1105
+ const createInstance = __webpack_require__( 5438 );
1486
1106
 
1487
- module.exports = async ( client, nativeArgs ) => {
1488
- const args = Object.assign( { ReturnValues: 'ALL_NEW' }, nativeArgs );
1489
- const response = await client.send( new UpdateCommand( args ) );
1490
- return response.Attributes;
1107
+ const methods = {
1108
+ copy,
1109
+ download,
1110
+ getSignedUrl,
1111
+ head,
1112
+ upload
1491
1113
  };
1492
1114
 
1115
+ module.exports = createInstance( clientProvider.bind( null, S3Client ), methods );
1493
1116
 
1494
- /***/ }),
1495
1117
 
1496
- /***/ 4164:
1497
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1118
+ /***/ },
1498
1119
 
1499
- const cacheSym = Symbol.for( 'cache' );
1500
- const crypto = __webpack_require__( 6982 );
1120
+ /***/ 9704
1121
+ (module, __unused_webpack_exports, __webpack_require__) {
1501
1122
 
1502
- const hash = text => crypto.createHash( 'md5' ).update( text ).digest( 'hex' );
1123
+ const { PutObjectCommand } = __webpack_require__( 5725 );
1503
1124
 
1504
- const propOpts = {
1505
- enumerable: false,
1506
- configurable: false,
1507
- writable: false
1508
- };
1125
+ module.exports = ( client, bucket, key, body, nativeArgs ) =>
1126
+ client.send( new PutObjectCommand( {
1127
+ ...nativeArgs,
1128
+ Bucket: bucket,
1129
+ Key: key,
1130
+ Body: typeof body === 'string' || Buffer.isBuffer( body ) ? body : JSON.stringify( body )
1131
+ } ) );
1509
1132
 
1510
- module.exports = {
1511
- set: ( key, value ) => {
1512
- const keySym = Symbol.for( hash( key ) );
1513
1133
 
1514
- if ( !global[cacheSym] ) {
1515
- Object.defineProperty( global, cacheSym, { ...propOpts, value: {} } );
1516
- }
1134
+ /***/ },
1517
1135
 
1518
- Object.defineProperty( global[cacheSym], keySym, { ...propOpts, value } );
1519
- },
1520
- get: key => {
1521
- return global[cacheSym]?.[Symbol.for( hash( key ) )];
1522
- }
1523
- };
1136
+ /***/ 809
1137
+ (module, __unused_webpack_exports, __webpack_require__) {
1524
1138
 
1139
+ const { DeleteSuppressedDestinationCommand } = __webpack_require__( 9556 );
1525
1140
 
1526
- /***/ }),
1141
+ module.exports = ( client, address ) => client.send( new DeleteSuppressedDestinationCommand( { EmailAddress: address } ) );
1527
1142
 
1528
- /***/ 4225:
1529
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1530
1143
 
1531
- const query = __webpack_require__( 6030 );
1532
- const { TimestreamQueryClient } = __webpack_require__( 1671 );
1533
- const { Agent } = __webpack_require__( 5692 );
1144
+ /***/ },
1145
+
1146
+ /***/ 5624
1147
+ (module, __unused_webpack_exports, __webpack_require__) {
1148
+
1149
+ const deleteSuppressedDestination = __webpack_require__( 809 );
1150
+ const sendEmail = __webpack_require__( 1783 );
1151
+ const { SESv2Client } = __webpack_require__( 9556 );
1534
1152
  const clientProvider = __webpack_require__( 9039 );
1535
1153
  const createInstance = __webpack_require__( 5438 );
1536
1154
 
1537
- const methods = { query };
1538
- const defaultArgs = {
1539
- maxRetries: 10,
1540
- httpOptions: { timeout: 60000, agent: new Agent( { maxSockets: 5000 } ) }
1155
+ const methods = {
1156
+ deleteSuppressedDestination,
1157
+ sendEmail
1541
1158
  };
1542
1159
 
1543
- module.exports = createInstance( args => clientProvider( TimestreamQueryClient, [ Object.assign( {}, defaultArgs, args ) ] ), methods );
1160
+ module.exports = createInstance( clientProvider.bind( null, SESv2Client ), methods );
1544
1161
 
1545
1162
 
1546
- /***/ }),
1163
+ /***/ },
1547
1164
 
1548
- /***/ 4243:
1549
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1165
+ /***/ 1783
1166
+ (module, __unused_webpack_exports, __webpack_require__) {
1550
1167
 
1551
- const sleep = __webpack_require__( 2445 );
1168
+ const { SendEmailCommand } = __webpack_require__( 9556 );
1552
1169
 
1553
- const execWithRetry = async ( closure, { limit, delay, retryHook, execCount = 0 } ) => {
1554
- if ( !( closure instanceof Function ) ) {
1555
- throw new Error( 'Closure is not a function' );
1556
- }
1170
+ module.exports = ( client, { to = [], from, html, subject }, args ) =>
1171
+ client.send( new SendEmailCommand( {
1172
+ Destination: {
1173
+ ToAddresses: to
1174
+ },
1175
+ Content: {
1176
+ Simple: {
1177
+ Body: {
1178
+ Html: {
1179
+ Data: html,
1180
+ Charset: 'utf-8'
1181
+ }
1182
+ },
1183
+ Subject: {
1184
+ Data: subject
1185
+ }
1186
+ }
1187
+ },
1188
+ FromEmailAddress: from,
1189
+ ...args
1190
+ } ) );
1557
1191
 
1558
- try {
1559
- return await closure();
1560
- } catch ( error ) {
1561
- // exhausted
1562
- if ( execCount === limit ) { throw error; }
1563
1192
 
1564
- // async retry hook to check if it should retry or give up and throw
1565
- if ( retryHook instanceof Function ) {
1566
- try {
1567
- const retry = await retryHook( error, execCount );
1568
- if ( retry === false ) { return false; }
1193
+ /***/ },
1569
1194
 
1570
- // Hook errors break the flow
1571
- } catch ( hookError ) {
1572
- console.debug( hookError );
1573
- throw hookError;
1574
- }
1575
- }
1195
+ /***/ 3099
1196
+ (module, __unused_webpack_exports, __webpack_require__) {
1576
1197
 
1577
- // if there is no hook back-off and retry
1578
- if ( delay > 0 ) {
1579
- await sleep( delay ** ( 1 + execCount ) );
1580
- }
1581
- return execWithRetry( closure, { limit, delay, retryHook, execCount: execCount + 1 } );
1582
- }
1198
+ const publish = __webpack_require__( 8080 );
1199
+ const publishBatch = __webpack_require__( 3531 );
1200
+ const { SNSClient } = __webpack_require__( 7651 );
1201
+ const clientProvider = __webpack_require__( 9039 );
1202
+ const createInstance = __webpack_require__( 5438 );
1203
+
1204
+ const methods = {
1205
+ publish,
1206
+ publishBatch
1583
1207
  };
1584
1208
 
1585
- /**
1586
- *
1587
- * @param {Function} closure A self contained function that will be invoked
1588
- * @param {Object} config
1589
- * @param {Number} limit The max number of retries
1590
- * @param {Number} delay The delay between each retry (it will be multiplied by the number of retries, so, it is linear back-off)
1591
- * @param {Function} retryHook A function to be called every-time a retry is needed.
1592
- * If this functions returns false, the retry error is raised
1593
- * If this functions throws error, the thrown error is raised
1594
- * @returns {Any} The closure result
1595
- */
1596
- module.exports = async ( closure, { limit = 0, delay = 0, retryHook = null } = {} ) =>
1597
- execWithRetry( closure, { limit, delay, retryHook } );
1209
+ module.exports = createInstance( clientProvider.bind( null, SNSClient ), methods );
1598
1210
 
1599
1211
 
1600
- /***/ }),
1212
+ /***/ },
1601
1213
 
1602
- /***/ 4338:
1603
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1214
+ /***/ 8080
1215
+ (module, __unused_webpack_exports, __webpack_require__) {
1604
1216
 
1605
- const startQuery = __webpack_require__( 3649 );
1606
- const getResults = __webpack_require__( 739 );
1607
- const parseResults = __webpack_require__( 9552 );
1217
+ const { PublishCommand } = __webpack_require__( 7651 );
1608
1218
 
1609
- /**
1610
- * @class Result
1611
- * @type {Object}
1612
- * @property {Object[]} items Each query result row, parsed to a camelized js object
1613
- * @property {Number} count Total number of results
1614
- */
1219
+ module.exports = async ( client, topic, message, args = {} ) => {
1220
+ const response = await client.send( new PublishCommand( {
1221
+ ...args,
1222
+ TopicArn: topic,
1223
+ Message: typeof message === 'string' ? message : JSON.stringify( message )
1224
+ } ) );
1225
+ return response.MessageId;
1226
+ };
1615
1227
 
1616
- /**
1617
- * Executes an Athena Query
1618
- * @param {*} client The native client
1619
- * @param {Object} nativeArgs The native args to start the Cloudwatch Query
1620
- * @param {Object=} options Extra options for this command
1621
- * @param {Object=} options.range Since the nativeArgs "startTime" and "endTime" are second based epochs, the "range" argument accepts milliseconds based epochs for convenience, thus overwriting the "nativeArgs"
1622
- * @param {Number} options.range.from The beginning of the time range to query, overwrites "startTime"
1623
- * @param {Number} options.range.to The end of the time range to query, overwrites "endTime"
1624
- * @returns {Result} The query result
1625
- */
1626
- module.exports = async ( client, nativeArgs, { range = {} } = {} ) => {
1627
- const queryId = await startQuery( { client, nativeArgs, range } );
1628
- const results = await getResults( { client, queryId } );
1629
- const items = parseResults( results );
1630
- return { items, count: items.length };
1228
+
1229
+ /***/ },
1230
+
1231
+ /***/ 3531
1232
+ (module, __unused_webpack_exports, __webpack_require__) {
1233
+
1234
+ const { PublishBatchCommand } = __webpack_require__( 7651 );
1235
+
1236
+ module.exports = async ( client, topic, messages ) => {
1237
+ if ( messages.length > 10 ) {
1238
+ throw new Error( 'SNS.publishBatch only accepts up to 10 messages.' );
1239
+ }
1240
+ const response = await client.send( new PublishBatchCommand( {
1241
+ TopicArn: topic,
1242
+ PublishBatchRequestEntries: messages.map( ( { body, id = null, nativeArgs }, index ) => ( {
1243
+ Id: id ?? `message_${index}`,
1244
+ Message: typeof body === 'string' ? body : JSON.stringify( body ),
1245
+ ...nativeArgs
1246
+ } ) )
1247
+ } ) );
1248
+
1249
+ if ( response.Failed?.length > 0 ) {
1250
+ const error = new Error( 'SNS.publishBatch Failed. See error details' );
1251
+ error.details = response.Failed;
1252
+ throw error;
1253
+ }
1254
+ return response;
1631
1255
  };
1632
1256
 
1633
1257
 
1634
- /***/ }),
1258
+ /***/ },
1635
1259
 
1636
- /***/ 4348:
1637
- /***/ ((module) => {
1260
+ /***/ 5637
1261
+ (module, __unused_webpack_exports, __webpack_require__) {
1638
1262
 
1639
- "use strict";
1640
- module.exports = require("@aws-sdk/client-ssm");
1263
+ const { DeleteMessageCommand } = __webpack_require__( 1976 );
1264
+
1265
+ module.exports = async ( client, queue, receiptHandle ) =>
1266
+ client.send( new DeleteMessageCommand( {
1267
+ QueueUrl: queue,
1268
+ ReceiptHandle: receiptHandle
1269
+ } ) );
1641
1270
 
1642
- /***/ }),
1643
1271
 
1644
- /***/ 4528:
1645
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1272
+ /***/ },
1646
1273
 
1647
- const createClient = __webpack_require__( 5422 );
1274
+ /***/ 3340
1275
+ (module, __unused_webpack_exports, __webpack_require__) {
1648
1276
 
1649
- module.exports = {
1650
- createClient
1277
+ const deleteMessage = __webpack_require__( 5637 );
1278
+ const sendMessage = __webpack_require__( 6720 );
1279
+ const sendMessageBatch = __webpack_require__( 3131 );
1280
+ const { SQSClient } = __webpack_require__( 1976 );
1281
+ const clientProvider = __webpack_require__( 9039 );
1282
+ const createInstance = __webpack_require__( 5438 );
1283
+
1284
+ const methods = {
1285
+ deleteMessage,
1286
+ sendMessage,
1287
+ sendMessageBatch
1651
1288
  };
1652
1289
 
1290
+ module.exports = createInstance( clientProvider.bind( null, SQSClient ), methods );
1291
+
1653
1292
 
1654
- /***/ }),
1293
+ /***/ },
1655
1294
 
1656
- /***/ 4671:
1657
- /***/ ((module) => {
1295
+ /***/ 8175
1296
+ (module) {
1658
1297
 
1659
- "use strict";
1660
- module.exports = require("@aws-sdk/client-dynamodb");
1298
+ /*
1299
+ References:
1300
+ - https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html
1301
+ - https://stackoverflow.com/questions/58809098/remove-invalid-characters-from-message-sent-to-aws-amazon-sqs
1302
+ */
1303
+ module.exports = v => v?.replace( /[^\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}]/ug, '' ) // eslint-disable-line
1661
1304
 
1662
- /***/ }),
1663
1305
 
1664
- /***/ 4692:
1665
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1306
+ /***/ },
1666
1307
 
1667
- const calcMedian = __webpack_require__( 3187 );
1308
+ /***/ 6720
1309
+ (module, __unused_webpack_exports, __webpack_require__) {
1668
1310
 
1669
- module.exports = pop => {
1670
- const center = calcMedian( pop );
1671
- return calcMedian( pop.map( v => Math.abs( v - center ) ) );
1311
+ const { SendMessageCommand } = __webpack_require__( 1976 );
1312
+ const sanitizeSqs = __webpack_require__( 8175 );
1313
+
1314
+ module.exports = async ( client, queue, body, args ) => {
1315
+ const response = await client.send( new SendMessageCommand( {
1316
+ ...args,
1317
+ MessageBody: sanitizeSqs( typeof body === 'string' ? body : JSON.stringify( body ) ),
1318
+ QueueUrl: queue
1319
+ } ) );
1320
+ return response.MessageId;
1672
1321
  };
1673
1322
 
1674
1323
 
1675
- /***/ }),
1324
+ /***/ },
1676
1325
 
1677
- /***/ 4821:
1678
- /***/ ((module) => {
1326
+ /***/ 3131
1327
+ (module, __unused_webpack_exports, __webpack_require__) {
1679
1328
 
1680
- module.exports = ( items, size ) => items.reduce( ( arrs, item ) =>
1681
- ( arrs[0] && arrs[0].length < size ) ?
1682
- [ [ ...arrs[0], item ] ].concat( arrs.slice( 1 ) ) :
1683
- [ [ item ] ].concat( arrs )
1684
- , [] ).reverse();
1329
+ const { SendMessageBatchCommand } = __webpack_require__( 1976 );
1330
+ const sanitizeSqs = __webpack_require__( 8175 );
1331
+
1332
+ module.exports = async ( client, queue, messages ) => {
1333
+ if ( messages.length > 10 ) {
1334
+ throw new Error( 'SQS.sendMessageBatch only accepts up to 10 messages.' );
1335
+ }
1336
+ const response = await client.send( new SendMessageBatchCommand( {
1337
+ QueueUrl: queue,
1338
+ Entries: messages.map( ( { body, id = null, nativeArgs }, index ) => ( {
1339
+ Id: id ?? `message_${index}`,
1340
+ MessageBody: sanitizeSqs( typeof body === 'string' ? body : JSON.stringify( body ) ),
1341
+ ...nativeArgs
1342
+ } ) )
1343
+ } ) );
1685
1344
 
1345
+ if ( response.Failed?.length > 0 ) {
1346
+ const error = new Error( 'SQS.sendMessageBatch Failed. See error details' );
1347
+ error.details = response.Failed;
1348
+ throw error;
1349
+ }
1350
+ return response;
1351
+ };
1686
1352
 
1687
- /***/ }),
1688
1353
 
1689
- /***/ 4870:
1690
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1354
+ /***/ },
1691
1355
 
1692
- const athena = __webpack_require__( 228 );
1693
- const cwLogs = __webpack_require__( 2710 );
1694
- const dynamo = __webpack_require__( 1505 );
1695
- const lambda = __webpack_require__( 3544 );
1696
- const s3 = __webpack_require__( 645 );
1697
- const ses = __webpack_require__( 5624 );
1698
- const sns = __webpack_require__( 3099 );
1699
- const sqs = __webpack_require__( 3340 );
1700
- const ssm = __webpack_require__( 5888 );
1701
- const timestreamQuery = __webpack_require__( 4225 );
1702
- const timestreamWrite = __webpack_require__( 2538 );
1356
+ /***/ 8660
1357
+ (module, __unused_webpack_exports, __webpack_require__) {
1703
1358
 
1704
- module.exports = {
1705
- athena,
1706
- cwLogs,
1707
- dynamo,
1708
- lambda,
1709
- s3,
1710
- ses,
1711
- sns,
1712
- sqs,
1713
- ssm,
1714
- timestreamQuery,
1715
- timestreamWrite
1359
+ const cacheStorage = __webpack_require__( 4164 );
1360
+ const { GetParameterCommand } = __webpack_require__( 4348 );
1361
+
1362
+ module.exports = async ( client, name ) => {
1363
+ const key = `SSM_${name}`;
1364
+ const cacheValue = cacheStorage.get( key );
1365
+ if ( cacheValue ) { return cacheValue; }
1366
+
1367
+ try {
1368
+ const response = await client.send( new GetParameterCommand( { Name: name, WithDecryption: true } ) );
1369
+ const value = response?.Parameter?.Value;
1370
+ cacheStorage.set( key, value );
1371
+ return value;
1372
+ } catch ( error ) {
1373
+ if ( error.constructor.name === 'ParameterNotFound' ) {
1374
+ return null;
1375
+ }
1376
+ throw error;
1377
+ }
1716
1378
  };
1717
1379
 
1718
1380
 
1719
- /***/ }),
1381
+ /***/ },
1720
1382
 
1721
- /***/ 4991:
1722
- /***/ ((module) => {
1383
+ /***/ 5888
1384
+ (module, __unused_webpack_exports, __webpack_require__) {
1723
1385
 
1724
- "use strict";
1725
- module.exports = require("@aws-sdk/s3-request-presigner");
1386
+ const get = __webpack_require__( 8660 );
1387
+ const { SSMClient } = __webpack_require__( 4348 );
1388
+ const clientProvider = __webpack_require__( 9039 );
1389
+ const createInstance = __webpack_require__( 5438 );
1726
1390
 
1727
- /***/ }),
1391
+ const methods = { get };
1728
1392
 
1729
- /***/ 5263:
1730
- /***/ ((module) => {
1393
+ module.exports = createInstance( clientProvider.bind( null, SSMClient ), methods );
1731
1394
 
1732
- module.exports = t => t * 24 * 60 * 60 * 1000;
1733
1395
 
1396
+ /***/ },
1734
1397
 
1735
- /***/ }),
1398
+ /***/ 4225
1399
+ (module, __unused_webpack_exports, __webpack_require__) {
1736
1400
 
1737
- /***/ 5265:
1738
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1401
+ const query = __webpack_require__( 6030 );
1402
+ const { TimestreamQueryClient } = __webpack_require__( 1671 );
1403
+ const { Agent } = __webpack_require__( 5692 );
1404
+ const clientProvider = __webpack_require__( 9039 );
1405
+ const createInstance = __webpack_require__( 5438 );
1739
1406
 
1740
- const select = __webpack_require__( 2157 );
1407
+ const methods = { query };
1408
+ const defaultArgs = {
1409
+ maxRetries: 10,
1410
+ httpOptions: { timeout: 60000, agent: new Agent( { maxSockets: 5000 } ) }
1411
+ };
1741
1412
 
1742
- module.exports = async ( client, ...args ) => select( client, 'query', ...args );
1413
+ module.exports = createInstance( args => clientProvider( TimestreamQueryClient, [ Object.assign( {}, defaultArgs, args ) ] ), methods );
1743
1414
 
1744
1415
 
1745
- /***/ }),
1416
+ /***/ },
1746
1417
 
1747
- /***/ 5422:
1748
- /***/ ((module) => {
1418
+ /***/ 7261
1419
+ (module, __unused_webpack_exports, __webpack_require__) {
1749
1420
 
1750
- global.__redisInstances = {};
1421
+ // https://docs.aws.amazon.com/timestream/latest/developerguide/API_query_Type.html
1422
+ // https://docs.aws.amazon.com/timestream/latest/developerguide/supported-data-types.html
1751
1423
 
1752
- /**
1753
- * Create a redis client instance
1754
- * @param {Object} redis Redis npm dependency
1755
- * @param {String} address Redis DB address (either RW or RO)
1756
- * @returns redisClient A new redis client instance connected to the database
1757
- */
1758
- module.exports = async ( { redis, address, protocol = 'rediss', port = 6379 } ) => {
1759
- if ( global.__redisInstances[address] ) {
1760
- try {
1761
- const r = await global.__redisInstances[address].ping();
1762
- if ( r === 'PONG' ) {
1763
- return global.__redisInstances[address];
1764
- } else {
1765
- delete global.__redisInstances[address];
1766
- }
1767
- } catch {
1768
- delete global.__redisInstances[address];
1769
- }
1424
+ const { ScalarType } = __webpack_require__( 1671 );
1425
+
1426
+ const parseBigInt = value => {
1427
+ const asInt = parseInt( value, 10 );
1428
+ return asInt <= Number.MAX_SAFE_INTEGER && asInt >= Number.MIN_SAFE_INTEGER ? asInt : value;
1429
+ };
1430
+
1431
+ const parseScalarValue = ( type, value ) => {
1432
+ switch ( type ) {
1433
+ case ScalarType.BOOLEAN:
1434
+ return value === 'true';
1435
+ case ScalarType.DOUBLE:
1436
+ return parseFloat( value );
1437
+ case ScalarType.TIMESTAMP:
1438
+ return new Date( `${value.replace( ' ', 'T' )}Z` );
1439
+ case ScalarType.INTEGER:
1440
+ return parseInt( value, 10 );
1441
+ case ScalarType.UNKNOWN: // is NULL
1442
+ return null;
1443
+ case ScalarType.BIGINT:
1444
+ return parseBigInt( value );
1445
+ case ScalarType.VARCHAR:
1446
+ case ScalarType.DATE:
1447
+ case ScalarType.TIME:
1448
+ case ScalarType.INTERVAL_DAY_TO_SECOND:
1449
+ case ScalarType.INTERVAL_YEAR_TO_MONTH:
1450
+ default:
1451
+ return value;
1770
1452
  }
1453
+ };
1771
1454
 
1772
- const client = redis.createClient( { url: `${protocol}://${address}:${port}`, socket: { keepAlive: 15000 } } );
1455
+ const parseValue = ( typeInfo, datum ) => {
1456
+ // value might be null
1457
+ if ( datum['NullValue'] === true ) {
1458
+ return null;
1459
+ }
1773
1460
 
1774
- await client.connect();
1461
+ // or a time series
1462
+ if ( Object.hasOwn( typeInfo, 'TimeSeriesMeasureValueColumnInfo' ) ) {
1463
+ return datum.TimeSeriesValue.map( v => ( {
1464
+ time: new Date( v.Time ),
1465
+ value: parseValue( typeInfo.TimeSeriesMeasureValueColumnInfo.Type, v.Value )
1466
+ } ) );
1467
+ }
1775
1468
 
1776
- global.__redisInstances[address] = client;
1777
- return client;
1469
+ // maybe an array
1470
+ if ( Object.hasOwn( typeInfo, 'ArrayColumnInfo' ) ) {
1471
+ return datum.ArrayValue.map( v => parseValue( typeInfo.ArrayColumnInfo.Type, v ) );
1472
+ }
1473
+
1474
+ // or even a row
1475
+ if ( Object.hasOwn( typeInfo, 'RowColumnInfo' ) ) {
1476
+ const rowColumnInfo = typeInfo.RowColumnInfo;
1477
+ return datum.RowValue.Data.reduce( ( object, value, index ) => {
1478
+ const { Name: name, Type: typeInfo } = rowColumnInfo[index];
1479
+ return Object.assign( object, { [name]: parseValue( typeInfo, value ) } );
1480
+ }, {} );
1481
+ }
1482
+
1483
+ // if none, it is scalar
1484
+ return parseScalarValue( typeInfo.ScalarType, datum['ScalarValue'] );
1778
1485
  };
1779
1486
 
1487
+ module.exports = response => {
1488
+ const { ColumnInfo: colInfo, Rows: rows } = response;
1489
+ return rows.map( row =>
1490
+ row.Data.reduce( ( entry, value, index ) => {
1491
+ const { Name: name, Type: typeInfo } = colInfo[index];
1492
+ return Object.assign( entry, { [name]: parseValue( typeInfo, value ) } );
1493
+ }, { } )
1494
+ );
1495
+ };
1780
1496
 
1781
- /***/ }),
1782
1497
 
1783
- /***/ 5438:
1784
- /***/ ((module) => {
1498
+ /***/ },
1785
1499
 
1786
- /**
1787
- * This is base object each AWS abstraction will provide
1788
- */
1789
- module.exports = ( providerFn, methods ) => {
1790
- // This creates the "instance",
1791
- // so calling the method as a function returns a copy of its client instantiated with the given args
1792
- // every method called from it will use this instance
1793
- const factory = args => {
1794
- const client = providerFn( args );
1795
- // return self, so it is possible use the native client
1796
- methods.getClient = () => client;
1797
- return Object.entries( methods ).reduce( ( o, [ k, v ] ) => Object.assign( o, { [k]: v.bind( null, client ) } ), { } );
1798
- };
1500
+ /***/ 6030
1501
+ (module, __unused_webpack_exports, __webpack_require__) {
1799
1502
 
1800
- // This is the singleton part;
1801
- // First add the static method to the factory;
1802
- Object.entries( methods ).forEach( ( [ key, value ] ) => factory[key] = value );
1503
+ const { QueryCommand } = __webpack_require__( 1671 );
1504
+ const { camelize } = __webpack_require__( 5762 );
1505
+ const parseItems = __webpack_require__( 7261 );
1803
1506
 
1804
- // Then add the special method "getClient", so it is possible use the native client
1805
- factory.getClient = client => client;
1507
+ const query = async ( client, queryString, { prevItems = [], recursive, paginationToken, maxRows, rawResponse } ) => {
1508
+ const response = await client.send( new QueryCommand( { QueryString: queryString, NextToken: paginationToken, MaxRows: maxRows } ) );
1509
+ if ( !recursive && rawResponse ) {
1510
+ return response;
1511
+ }
1806
1512
 
1807
- // Finally makes the proxy which will allow each singleton method to use the client provider of the AWS service+
1808
- return new Proxy( factory, {
1809
- get( target, key ) {
1810
- const t = target[key];
1811
- return ( typeof t === 'function' ) ? t.bind( null, providerFn() ) : t;
1812
- }
1813
- } );
1513
+ const nextToken = response.NextToken;
1514
+ if ( nextToken && recursive ) {
1515
+ return query( client, queryString, { prevItems: parseItems( response ), recursive, paginationToken: nextToken, maxRows } );
1516
+ }
1517
+
1518
+ const items = prevItems.concat( parseItems( response ) );
1519
+ return { nextToken, count: items.length, items, queryStatus: camelize( response.QueryStatus ) };
1814
1520
  };
1815
1521
 
1522
+ module.exports = async ( client, queryString, { recursive = false, paginationToken = undefined, maxRows = undefined, rawResponse = false } = {} ) =>
1523
+ query( client, queryString, { recursive, paginationToken, maxRows, rawResponse } );
1816
1524
 
1817
- /***/ }),
1818
1525
 
1819
- /***/ 5624:
1820
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1526
+ /***/ },
1821
1527
 
1822
- const deleteSuppressedDestination = __webpack_require__( 809 );
1823
- const sendEmail = __webpack_require__( 1783 );
1824
- const { SESv2Client } = __webpack_require__( 9556 );
1528
+ /***/ 2538
1529
+ (module, __unused_webpack_exports, __webpack_require__) {
1530
+
1531
+ const writeRecords = __webpack_require__( 8936 );
1532
+ const { TimestreamWriteClient } = __webpack_require__( 8248 );
1533
+ const { Agent } = __webpack_require__( 5692 );
1825
1534
  const clientProvider = __webpack_require__( 9039 );
1826
1535
  const createInstance = __webpack_require__( 5438 );
1827
1536
 
1828
- const methods = {
1829
- deleteSuppressedDestination,
1830
- sendEmail
1537
+ const methods = { writeRecords };
1538
+ const defaultArgs = {
1539
+ maxRetries: 10,
1540
+ httpOptions: { timeout: 60000, agent: new Agent( { maxSockets: 5000 } ) }
1831
1541
  };
1832
1542
 
1833
- module.exports = createInstance( clientProvider.bind( null, SESv2Client ), methods );
1543
+ module.exports = createInstance( args => clientProvider( TimestreamWriteClient, [ Object.assign( {}, defaultArgs, args ) ] ), methods );
1834
1544
 
1835
1545
 
1836
- /***/ }),
1546
+ /***/ },
1837
1547
 
1838
- /***/ 5637:
1839
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1548
+ /***/ 8936
1549
+ (module, __unused_webpack_exports, __webpack_require__) {
1840
1550
 
1841
- const { DeleteMessageCommand } = __webpack_require__( 1976 );
1551
+ const { WriteRecordsCommand } = __webpack_require__( 8248 );
1842
1552
 
1843
- module.exports = async ( client, queue, receiptHandle ) =>
1844
- client.send( new DeleteMessageCommand( {
1845
- QueueUrl: queue,
1846
- ReceiptHandle: receiptHandle
1847
- } ) );
1553
+ module.exports = async ( client, { database, table, records, ignoreRejections = false } ) => {
1554
+ try {
1555
+ const response = await client.send( new WriteRecordsCommand( {
1556
+ DatabaseName: database,
1557
+ TableName: table,
1558
+ Records: records
1559
+ } ) );
1560
+ return { recordsIngested: response.RecordsIngested };
1561
+ } catch ( error ) {
1562
+ if ( ignoreRejections && error.name === 'RejectedRecordsException' ) {
1563
+ return { rejectedRecords: error.RejectedRecords };
1564
+ }
1565
+ throw error;
1566
+ }
1567
+ };
1848
1568
 
1849
1569
 
1850
- /***/ }),
1570
+ /***/ },
1851
1571
 
1852
- /***/ 5692:
1853
- /***/ ((module) => {
1572
+ /***/ 5263
1573
+ (module) {
1854
1574
 
1855
- "use strict";
1856
- module.exports = require("https");
1575
+ module.exports = t => t * 24 * 60 * 60 * 1000;
1857
1576
 
1858
- /***/ }),
1859
1577
 
1860
- /***/ 5723:
1861
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1578
+ /***/ },
1862
1579
 
1863
- const { randomBytes } = __webpack_require__( 6982 );
1864
- const { StartQueryExecutionCommand } = __webpack_require__( 3744 );
1580
+ /***/ 6961
1581
+ (module) {
1865
1582
 
1866
- /**
1867
- * args : https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/athena/command/StartQueryExecutionCommand/
1868
- * A ClientRequestToken is created automatically
1869
- */
1870
- module.exports = async ( { client, ...args } ) => {
1871
- const cmd = new StartQueryExecutionCommand( {
1872
- ClientRequestToken: randomBytes( 16 ).toString( 'hex' ),
1873
- ...args
1874
- } );
1875
- const { QueryExecutionId: queryId } = await client.send( cmd );
1876
- return queryId;
1877
- };
1583
+ module.exports = t => t * 60 * 60 * 1000;
1878
1584
 
1879
1585
 
1880
- /***/ }),
1586
+ /***/ },
1881
1587
 
1882
- /***/ 5725:
1883
- /***/ ((module) => {
1588
+ /***/ 3830
1589
+ (module, __unused_webpack_exports, __webpack_require__) {
1884
1590
 
1885
- "use strict";
1886
- module.exports = require("@aws-sdk/client-s3");
1591
+ const days = __webpack_require__( 5263 );
1592
+ const hours = __webpack_require__( 6961 );
1593
+ const minutes = __webpack_require__( 6635 );
1594
+ const months = __webpack_require__( 8119 );
1595
+ const msToS = __webpack_require__( 7416 );
1596
+ const round = __webpack_require__( 3990 );
1597
+ const seconds = __webpack_require__( 7051 );
1887
1598
 
1888
- /***/ }),
1599
+ module.exports = {
1600
+ days,
1601
+ hours,
1602
+ minutes,
1603
+ months,
1604
+ msToS,
1605
+ round,
1606
+ seconds
1607
+ };
1889
1608
 
1890
- /***/ 5744:
1891
- /***/ ((module) => {
1892
1609
 
1893
- module.exports = {
1894
- encode: k => {
1895
- if ( k === null || k === undefined ) { return k; }
1610
+ /***/ },
1896
1611
 
1897
- return Buffer.from( JSON.stringify( k ) ).toString( 'base64' );
1898
- },
1899
- decode: k => {
1900
- if ( k === null || k === undefined ) { return k; }
1612
+ /***/ 6635
1613
+ (module) {
1901
1614
 
1902
- const result = Buffer.from( k, 'base64' ).toString( 'utf8' );
1903
- try {
1904
- return JSON.parse( result );
1905
- } catch {
1906
- return result;
1907
- }
1908
- }
1909
- };
1615
+ module.exports = t => t * 60 * 1000;
1910
1616
 
1911
1617
 
1912
- /***/ }),
1618
+ /***/ },
1913
1619
 
1914
- /***/ 5762:
1915
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1620
+ /***/ 8119
1621
+ (module) {
1916
1622
 
1917
- const camelize = __webpack_require__( 8256 );
1918
- const filterProps = __webpack_require__( 6451 );
1919
- const removeEmptyArrays = __webpack_require__( 2047 );
1920
- const snakelize = __webpack_require__( 7572 );
1623
+ module.exports = t => t * 30 * 24 * 60 * 60 * 1000;
1921
1624
 
1922
- module.exports = {
1923
- camelize,
1924
- filterProps,
1925
- removeEmptyArrays,
1926
- snakelize
1927
- };
1928
1625
 
1626
+ /***/ },
1929
1627
 
1930
- /***/ }),
1628
+ /***/ 7416
1629
+ (module) {
1931
1630
 
1932
- /***/ 5847:
1933
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1631
+ module.exports = v => Math.ceil( v / 1000 );
1934
1632
 
1935
- const batchWrite = __webpack_require__( 8593 );
1936
1633
 
1937
- module.exports = async ( client, ...args ) => batchWrite( client, 'put', ...args );
1634
+ /***/ },
1938
1635
 
1636
+ /***/ 3990
1637
+ (module) {
1939
1638
 
1940
- /***/ }),
1639
+ module.exports = ( time, interval ) => time - ( time % interval );
1941
1640
 
1942
- /***/ 5888:
1943
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1944
1641
 
1945
- const get = __webpack_require__( 8660 );
1946
- const { SSMClient } = __webpack_require__( 4348 );
1947
- const clientProvider = __webpack_require__( 9039 );
1948
- const createInstance = __webpack_require__( 5438 );
1642
+ /***/ },
1949
1643
 
1950
- const methods = { get };
1644
+ /***/ 7051
1645
+ (module) {
1951
1646
 
1952
- module.exports = createInstance( clientProvider.bind( null, SSMClient ), methods );
1647
+ module.exports = t => t * 1000;
1953
1648
 
1954
1649
 
1955
- /***/ }),
1650
+ /***/ },
1956
1651
 
1957
- /***/ 5892:
1958
- /***/ ((module) => {
1652
+ /***/ 44
1653
+ (module, __unused_webpack_exports, __webpack_require__) {
1959
1654
 
1960
- "use strict";
1961
- module.exports = require("@aws-sdk/client-lambda");
1655
+ const { LambdaApi } = __webpack_require__( 2705 );
1656
+ const array = __webpack_require__( 8278 );
1657
+ const aws = __webpack_require__( 4870 );
1658
+ const epoch = __webpack_require__( 3830 );
1659
+ const math = __webpack_require__( 943 );
1660
+ const object = __webpack_require__( 5762 );
1661
+ const redis = __webpack_require__( 4528 );
1662
+ const string = __webpack_require__( 268 );
1663
+ const utils = __webpack_require__( 6878 );
1962
1664
 
1963
- /***/ }),
1665
+ module.exports = {
1666
+ array,
1667
+ aws,
1668
+ epoch,
1669
+ LambdaApi,
1670
+ math,
1671
+ object,
1672
+ redis,
1673
+ string,
1674
+ utils
1675
+ };
1964
1676
 
1965
- /***/ 5894:
1966
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1967
1677
 
1968
- const { InvokeCommand } = __webpack_require__( 5892 );
1969
- const AWSLambdaError = __webpack_require__( 468 );
1678
+ /***/ },
1970
1679
 
1971
- module.exports = async ( client, name, payload = {}, type = 'RequestResponse' ) => {
1972
- const response = await client.send( new InvokeCommand( {
1973
- FunctionName: name,
1974
- InvocationType: type,
1975
- Payload: Buffer.from( JSON.stringify( payload ) )
1976
- } ) );
1680
+ /***/ 3119
1681
+ (module, __unused_webpack_exports, __webpack_require__) {
1977
1682
 
1978
- if ( response.FunctionError ) {
1979
- throw new AWSLambdaError( response );
1683
+ const { snakelize, camelize } = __webpack_require__( 5762 );
1684
+ const charset = 'utf-8';
1685
+
1686
+ const transformFns = {
1687
+ camelcase: camelize,
1688
+ snakecase: snakelize
1689
+ };
1690
+
1691
+ module.exports = class ApiResponse {
1692
+ #headers = null;
1693
+ #statusCode = null;
1694
+ #transformFn = false;
1695
+ #isBase64Encoded = false;
1696
+ #body = '';
1697
+
1698
+ constructor( { headers = {}, transform } = {} ) {
1699
+ this.#transformFn = transformFns[transform] ?? ( v => v );
1700
+ this.#headers = Object.assign( {
1701
+ 'Cache-Control': 'no-store',
1702
+ 'Access-Control-Allow-Origin': '*'
1703
+ }, headers );
1980
1704
  }
1981
1705
 
1982
- if ( type !== 'RequestResponse' ) { return true; }
1706
+ setContent( statusCode, body, headers = {}, isBase64Encoded = false ) {
1707
+ this.#statusCode = statusCode;
1708
+ this.#isBase64Encoded = isBase64Encoded;
1709
+ if ( body?.length === 0 || [ null, undefined ].includes( body ) ) {
1710
+ this.#body = '';
1711
+ } else if ( typeof body === 'object' ) {
1712
+ this.#body = JSON.stringify( this.#transformFn( body ) );
1713
+ this.#headers['Content-Type'] = `application/json; charset=${charset}`;
1714
+ } else {
1715
+ this.#body = String( body );
1716
+ this.#headers['Content-Type'] = `text/plain; charset=${charset}`;
1717
+ }
1718
+ this.#headers['Content-Length'] = this.#body.length;
1719
+ Object.assign( this.#headers, headers ?? {} );
1720
+ return this;
1721
+ }
1983
1722
 
1984
- try {
1985
- return JSON.parse( Buffer.from( response.Payload ).toString() );
1986
- } catch {
1987
- return response.Payload;
1723
+ toJSON() {
1724
+ return {
1725
+ isBase64Encoded: this.#isBase64Encoded,
1726
+ statusCode: this.#statusCode,
1727
+ body: this.#body,
1728
+ headers: this.#headers
1729
+ };
1988
1730
  }
1989
1731
  };
1990
1732
 
1991
1733
 
1992
- /***/ }),
1734
+ /***/ },
1993
1735
 
1994
- /***/ 6030:
1995
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1736
+ /***/ 329
1737
+ (module, __unused_webpack_exports, __webpack_require__) {
1996
1738
 
1997
- const { QueryCommand } = __webpack_require__( 1671 );
1998
- const { camelize } = __webpack_require__( 5762 );
1999
- const parseItems = __webpack_require__( 7261 );
1739
+ const { camelize, snakelize } = __webpack_require__( 5762 );
2000
1740
 
2001
- const query = async ( client, queryString, { prevItems = [], recursive, paginationToken, maxRows, rawResponse } ) => {
2002
- const response = await client.send( new QueryCommand( { QueryString: queryString, NextToken: paginationToken, MaxRows: maxRows } ) );
2003
- if ( !recursive && rawResponse ) {
2004
- return response;
2005
- }
1741
+ const transformFns = {
1742
+ camelcase: camelize,
1743
+ snakecase: snakelize
1744
+ };
2006
1745
 
2007
- const nextToken = response.NextToken;
2008
- if ( nextToken && recursive ) {
2009
- return query( client, queryString, { prevItems: parseItems( response ), recursive, paginationToken: nextToken, maxRows } );
1746
+ const parseJson = content => {
1747
+ try {
1748
+ return JSON.parse( content );
1749
+ } catch {
1750
+ return content;
2010
1751
  }
2011
-
2012
- const items = prevItems.concat( parseItems( response ) );
2013
- return { nextToken, count: items.length, items, queryStatus: camelize( response.QueryStatus ) };
2014
1752
  };
2015
1753
 
2016
- module.exports = async ( client, queryString, { recursive = false, paginationToken = undefined, maxRows = undefined, rawResponse = false } = {} ) =>
2017
- query( client, queryString, { recursive, paginationToken, maxRows, rawResponse } );
1754
+ module.exports = class Event {
1755
+ #transformFn;
1756
+ authorizer;
1757
+ body;
1758
+ rawBody;
1759
+ headers;
1760
+ method;
1761
+ params;
1762
+ path;
1763
+ queryString;
1764
+ route;
2018
1765
 
1766
+ context = {};
2019
1767
 
2020
- /***/ }),
1768
+ constructor( { transform = false } = {} ) {
1769
+ this.#transformFn = transformFns[transform] ?? ( v => v );
1770
+ }
2021
1771
 
2022
- /***/ 6089:
2023
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1772
+ parseFromAwsEvent( awsEvent ) {
1773
+ this[`parseFromAwsEventV${awsEvent.version === '2.0' ? 2 : 1}`]( awsEvent );
1774
+ }
2024
1775
 
2025
- const calcMean = __webpack_require__( 4124 );
1776
+ parseFromAwsEventV1( awsEvent ) {
1777
+ const {
1778
+ body,
1779
+ path,
1780
+ resource,
1781
+ httpMethod,
1782
+ requestContext,
1783
+ pathParameters,
1784
+ headers,
1785
+ multiValueHeaders,
1786
+ queryStringParameters,
1787
+ multiValueQueryStringParameters: multiValueQueryString,
1788
+ isBase64Encoded
1789
+ } = awsEvent;
2026
1790
 
2027
- module.exports = values => {
2028
- if ( values.length < 2 ) { return NaN; }
1791
+ const unifiedHeaders = {
1792
+ ...headers,
1793
+ ...Object.fromEntries( Object.entries( multiValueHeaders ?? {} ).map( ( [ k, v ] ) => [ k, Array.isArray( v ) ? v.join( ',' ) : k ] ) )
1794
+ };
2029
1795
 
2030
- const mean = calcMean( values );
2031
- const squareDiffs = values.map( value => Math.pow( value - mean, 2 ) );
2032
- const avgSquareDiff = squareDiffs.reduce( ( sum, v ) => sum + v, 0 ) / ( values.length - 1 );
2033
- return Math.sqrt( avgSquareDiff );
2034
- };
1796
+ const unifiedQueryString = {
1797
+ ...queryStringParameters,
1798
+ ...Object.fromEntries( Object.entries( multiValueQueryString ?? {} ).map( ( [ k, v ] ) => [ k, Array.isArray( v ) ? v.join( ',' ) : k ] ) )
1799
+ };
2035
1800
 
1801
+ this.authorizer = requestContext?.authorizer;
1802
+ this.rawBody = body ?? null;
1803
+ this.body = body ? this.#transformFn( parseJson( body ) ) : null;
1804
+ this.headers = unifiedHeaders ?? {};
1805
+ this.method = httpMethod;
1806
+ this.params = this.#transformFn( pathParameters ) ?? {};
1807
+ this.path = path;
1808
+ this.queryString = this.#transformFn( unifiedQueryString ) ?? {};
1809
+ this.route = resource;
1810
+ this.isBase64Encoded = isBase64Encoded ?? false;
1811
+ }
2036
1812
 
2037
- /***/ }),
1813
+ parseFromAwsEventV2( awsEvent ) {
1814
+ const {
1815
+ body,
1816
+ routeKey,
1817
+ requestContext,
1818
+ pathParameters,
1819
+ headers,
1820
+ queryStringParameters,
1821
+ isBase64Encoded
1822
+ } = awsEvent;
2038
1823
 
2039
- /***/ 6451:
2040
- /***/ ((module) => {
1824
+ const { http: { method, path } } = requestContext;
2041
1825
 
2042
- module.exports = ( obj, props ) => Object.fromEntries( Object.entries( obj ).filter( ( [ k ] ) => props.includes( k ) ) );
1826
+ this.authorizer = requestContext?.authorizer;
1827
+ this.rawBody = body ?? null;
1828
+ this.body = body ? this.#transformFn( parseJson( body ) ) : null;
1829
+ this.headers = headers ?? {};
1830
+ this.method = method;
1831
+ this.params = this.#transformFn( pathParameters ) ?? {};
1832
+ this.path = path;
1833
+ this.queryString = this.#transformFn( queryStringParameters ) ?? {};
1834
+ this.route = routeKey?.split( ' ' )[1].replace( /\/$/, '' );
1835
+ this.isBase64Encoded = isBase64Encoded ?? false;
1836
+ }
1837
+ };
2043
1838
 
2044
1839
 
2045
- /***/ }),
1840
+ /***/ },
2046
1841
 
2047
- /***/ 6635:
2048
- /***/ ((module) => {
1842
+ /***/ 3109
1843
+ (module, __unused_webpack_exports, __webpack_require__) {
2049
1844
 
2050
- module.exports = t => t * 60 * 1000;
1845
+ const validators = __webpack_require__( 8994 );
2051
1846
 
1847
+ module.exports = class Handler {
1848
+ #method;
1849
+ #fn;
1850
+ #route;
1851
+ #routeIncludes;
1852
+ #routeNotIncludes;
1853
+ #routeMatches;
1854
+ #path;
1855
+ #pathIncludes;
1856
+ #pathNotIncludes;
1857
+ #pathMatches;
2052
1858
 
2053
- /***/ }),
1859
+ constructor( { method, fn, ...matchers } ) {
1860
+ validators.httpMethod( method );
1861
+ validators.function( fn );
1862
+ validators.matcherRoute( matchers.route );
1863
+ validators.matcherRouteIncludes( matchers.routeIncludes );
1864
+ validators.matcherRouteNotIncludes( matchers.routeNotIncludes );
1865
+ validators.matcherRouteMatch( matchers.routeMatch );
1866
+ validators.matcherPath( matchers.path );
1867
+ validators.matcherPathIncludes( matchers.pathIncludes );
1868
+ validators.matcherPathNotIncludes( matchers.pathNotIncludes );
1869
+ validators.matcherPathMatch( matchers.pathMatch );
2054
1870
 
2055
- /***/ 6720:
2056
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1871
+ this.#method = method;
1872
+ this.#fn = fn;
1873
+ this.#route = matchers.route;
1874
+ this.#routeIncludes = matchers.routeIncludes;
1875
+ this.#routeNotIncludes = matchers.routeNotIncludes;
1876
+ this.#routeMatches = matchers.routeMatches;
1877
+ this.#path = matchers.path;
1878
+ this.#pathIncludes = matchers.pathIncludes;
1879
+ this.#pathNotIncludes = matchers.pathNotIncludes;
1880
+ this.#pathMatches = matchers.pathMatches;
1881
+ }
2057
1882
 
2058
- const { SendMessageCommand } = __webpack_require__( 1976 );
2059
- const sanitizeSqs = __webpack_require__( 8175 );
1883
+ match( event ) {
1884
+ if ( this.#method !== event.method ) {
1885
+ return false;
1886
+ }
1887
+ if ( this.#route ) {
1888
+ return this.#route === event.route;
1889
+ }
1890
+ if ( this.#path ) {
1891
+ return this.#path === event.path;
1892
+ }
1893
+ if ( this.#routeIncludes && !event.route.includes( this.#routeIncludes ) ) {
1894
+ return false;
1895
+ }
1896
+ if ( this.#routeNotIncludes && event.route.includes( this.#routeNotIncludes ) ) {
1897
+ return false;
1898
+ }
1899
+ if ( this.#routeMatches && !this.#routeMatches.test( event.route ) ) {
1900
+ return false;
1901
+ }
1902
+ if ( this.#pathIncludes && !event.path.includes( this.#pathIncludes ) ) {
1903
+ return false;
1904
+ }
1905
+ if ( this.#pathNotIncludes && event.path.includes( this.#pathNotIncludes ) ) {
1906
+ return false;
1907
+ }
1908
+ if ( this.#pathMatches && !this.#pathMatches.test( event.path ) ) {
1909
+ return false;
1910
+ }
1911
+ return true;
1912
+ }
2060
1913
 
2061
- module.exports = async ( client, queue, body, args ) => {
2062
- const response = await client.send( new SendMessageCommand( {
2063
- ...args,
2064
- MessageBody: sanitizeSqs( typeof body === 'string' ? body : JSON.stringify( body ) ),
2065
- QueueUrl: queue
2066
- } ) );
2067
- return response.MessageId;
1914
+ get fn() { return this.#fn; }
2068
1915
  };
2069
1916
 
2070
1917
 
2071
- /***/ }),
2072
-
2073
- /***/ 6777:
2074
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2075
-
2076
- const { DeleteCommand } = __webpack_require__( 3489 );
2077
-
2078
- module.exports = async ( client, tableName, key ) => {
2079
- const { Attributes: item } = await client.send( new DeleteCommand( {
2080
- ReturnValues: 'ALL_OLD',
2081
- TableName: tableName,
2082
- Key: key
2083
- } ) );
2084
- return item;
2085
- };
1918
+ /***/ },
2086
1919
 
1920
+ /***/ 798
1921
+ (module, __unused_webpack_exports, __webpack_require__) {
2087
1922
 
2088
- /***/ }),
1923
+ const validators = __webpack_require__( 8994 );
2089
1924
 
2090
- /***/ 6878:
2091
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1925
+ module.exports = class Hook {
1926
+ #fn;
2092
1927
 
2093
- const retryOnError = __webpack_require__( 4243 );
2094
- const sleep = __webpack_require__( 2445 );
2095
- const Timer = __webpack_require__( 9651 );
2096
- const untarJsonGz = __webpack_require__( 8233 );
1928
+ constructor( { fn } ) {
1929
+ validators.function( fn );
1930
+ this.#fn = fn;
1931
+ }
2097
1932
 
2098
- module.exports = {
2099
- retryOnError,
2100
- sleep,
2101
- Timer,
2102
- untarJsonGz
1933
+ get fn() { return this.#fn; }
2103
1934
  };
2104
1935
 
2105
1936
 
2106
- /***/ }),
1937
+ /***/ },
2107
1938
 
2108
- /***/ 6961:
2109
- /***/ ((module) => {
2110
-
2111
- module.exports = t => t * 60 * 60 * 1000;
2112
-
2113
-
2114
- /***/ }),
2115
-
2116
- /***/ 6982:
2117
- /***/ ((module) => {
2118
-
2119
- "use strict";
2120
- module.exports = require("crypto");
1939
+ /***/ 2705
1940
+ (module, __unused_webpack_exports, __webpack_require__) {
2121
1941
 
2122
- /***/ }),
1942
+ const LambdaApi = __webpack_require__( 321 );
2123
1943
 
2124
- /***/ 7051:
2125
- /***/ ((module) => {
1944
+ module.exports = { LambdaApi };
2126
1945
 
2127
- module.exports = t => t * 1000;
2128
1946
 
1947
+ /***/ },
2129
1948
 
2130
- /***/ }),
1949
+ /***/ 321
1950
+ (module, __unused_webpack_exports, __webpack_require__) {
2131
1951
 
2132
- /***/ 7261:
2133
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
1952
+ const validators = __webpack_require__( 8994 );
1953
+ const ApiResponse = __webpack_require__( 3119 );
1954
+ const Event = __webpack_require__( 329 );
1955
+ const Handler = __webpack_require__( 3109 );
1956
+ const Hook = __webpack_require__( 798 );
1957
+ const UserResponse = __webpack_require__( 8282 );
1958
+ const Text = __webpack_require__( 9760 );
2134
1959
 
2135
- // https://docs.aws.amazon.com/timestream/latest/developerguide/API_query_Type.html
2136
- // https://docs.aws.amazon.com/timestream/latest/developerguide/supported-data-types.html
1960
+ module.exports = class LambdaApi {
1961
+ #apiResponse = null;
1962
+ #handlers = [];
1963
+ #errorResponses = [];
1964
+ #beforeHooks = [];
1965
+ #afterHooks = [];
1966
+ #transformRequest = [];
2137
1967
 
2138
- const { ScalarType } = __webpack_require__( 1671 );
1968
+ /**
1969
+ * Creates a new Lambda Api
1970
+ *
1971
+ * @param {Object} headers Any headers you want to be included in all responses
1972
+ */
1973
+ constructor( { headers = {}, transformRequest = false, transformResponse = false } = {} ) {
1974
+ validators.transformRequest( transformRequest );
1975
+ validators.transformResponse( transformResponse );
2139
1976
 
2140
- const parseBigInt = value => {
2141
- const asInt = parseInt( value, 10 );
2142
- return asInt <= Number.MAX_SAFE_INTEGER && asInt >= Number.MIN_SAFE_INTEGER ? asInt : value;
2143
- };
1977
+ this.#transformRequest = transformRequest;
1978
+ this.#apiResponse = new ApiResponse( { headers, transform: transformResponse } );
1979
+ }
2144
1980
 
2145
- const parseScalarValue = ( type, value ) => {
2146
- switch ( type ) {
2147
- case ScalarType.BOOLEAN:
2148
- return value === 'true';
2149
- case ScalarType.DOUBLE:
2150
- return parseFloat( value );
2151
- case ScalarType.TIMESTAMP:
2152
- return new Date( `${value.replace( ' ', 'T' )}Z` );
2153
- case ScalarType.INTEGER:
2154
- return parseInt( value, 10 );
2155
- case ScalarType.UNKNOWN: // is NULL
2156
- return null;
2157
- case ScalarType.BIGINT:
2158
- return parseBigInt( value );
2159
- case ScalarType.VARCHAR:
2160
- case ScalarType.DATE:
2161
- case ScalarType.TIME:
2162
- case ScalarType.INTERVAL_DAY_TO_SECOND:
2163
- case ScalarType.INTERVAL_YEAR_TO_MONTH:
2164
- default:
2165
- return value;
1981
+ /**
1982
+ * Register a function that will run before the matching route (only if matches)
1983
+ *
1984
+ * @param {Object} args
1985
+ * @param {function} args.fn A function
1986
+ */
1987
+ addBeforeHook( { fn } = {} ) {
1988
+ this.#beforeHooks.push( new Hook( { fn } ) );
2166
1989
  }
2167
- };
2168
1990
 
2169
- const parseValue = ( typeInfo, datum ) => {
2170
- // value might be null
2171
- if ( datum['NullValue'] === true ) {
2172
- return null;
1991
+ /**
1992
+ * Register a function that will run after the matching route (only if matches)
1993
+ *
1994
+ * @param {Object} args
1995
+ * @param {function} args.fn A function
1996
+ */
1997
+ addAfterHook( { fn } = {} ) {
1998
+ this.#afterHooks.push( new Hook( { fn } ) );
2173
1999
  }
2174
2000
 
2175
- // or a time series
2176
- if ( Object.hasOwn( typeInfo, 'TimeSeriesMeasureValueColumnInfo' ) ) {
2177
- return datum.TimeSeriesValue.map( v => ( {
2178
- time: new Date( v.Time ),
2179
- value: parseValue( typeInfo.TimeSeriesMeasureValueColumnInfo.Type, v.Value )
2180
- } ) );
2001
+ /**
2002
+ * Register a handler for a given request method and optionally a path
2003
+ *
2004
+ * @param {Object} args
2005
+ * @param {string} args.method The method to match this handler
2006
+ * @param {function} args.fn The handler function
2007
+ * @param {string} [args.route] A route to match this handler
2008
+ * @param {string} [args.routeIncludes] A part of the route to match this handler
2009
+ * @param {string} [args.routeNotIncludes] A part of the route to not match this handler
2010
+ * @param {RegExp} [args.routeMatches] A RegExp to match the route
2011
+ * @param {string} [args.path] A path to match this handler
2012
+ * @param {string} [args.pathIncludes] A part of the path to match this handler
2013
+ * @param {string} [args.pathNotIncludes] A part of the path to not match this handler
2014
+ * @param {RegExp} [args.pathMatches] A RegExp to match the path
2015
+ */
2016
+ addHandler( { method, fn, ...matchers } = {} ) {
2017
+ this.#handlers.push( new Handler( { method, fn, ...matchers } ) );
2181
2018
  }
2182
2019
 
2183
- // maybe an array
2184
- if ( Object.hasOwn( typeInfo, 'ArrayColumnInfo' ) ) {
2185
- return datum.ArrayValue.map( v => parseValue( typeInfo.ArrayColumnInfo.Type, v ) );
2020
+ /**
2021
+ * Register an automatic error code response for given error class (constructor name)
2022
+ *
2023
+ * @param {Object} args
2024
+ * @param {string} args.code The HTTP status code to return
2025
+ * @param {class} args.errorType The error class
2026
+ * @param {string} [args.message=null] Optional message to return for the status code, if not present will default to Error.message
2027
+ * @param {message} [args.errorType] And optional message to display
2028
+ */
2029
+ addErrorHandler( { errorType, code, message = null } = {} ) {
2030
+ validators.statusCode( code );
2031
+ validators.errorType( errorType );
2032
+ this.#errorResponses.push( { errorType, code, message } );
2186
2033
  }
2187
2034
 
2188
- // or even a row
2189
- if ( Object.hasOwn( typeInfo, 'RowColumnInfo' ) ) {
2190
- const rowColumnInfo = typeInfo.RowColumnInfo;
2191
- return datum.RowValue.Data.reduce( ( object, value, index ) => {
2192
- const { Name: name, Type: typeInfo } = rowColumnInfo[index];
2193
- return Object.assign( object, { [name]: parseValue( typeInfo, value ) } );
2194
- }, {} );
2195
- }
2035
+ /**
2036
+ * Init the flow using a given AWS Lambda APIGateway event (v2 syntax)
2037
+ *
2038
+ * @param {Object} ApiGatewayPayload The raw API Gateway event
2039
+ * @returns {Object} The http response with status, body and headers
2040
+ */
2041
+ async process( awsEvent ) {
2042
+ const event = new Event( { transform: this.#transformRequest } );
2043
+ event.parseFromAwsEvent( awsEvent );
2196
2044
 
2197
- // if none, it is scalar
2198
- return parseScalarValue( typeInfo.ScalarType, datum['ScalarValue'] );
2199
- };
2045
+ if ( event.method === 'HEAD' ) {
2046
+ return this.#apiResponse.setContent( 204 ).toJSON();
2047
+ }
2200
2048
 
2201
- module.exports = response => {
2202
- const { ColumnInfo: colInfo, Rows: rows } = response;
2203
- return rows.map( row =>
2204
- row.Data.reduce( ( entry, value, index ) => {
2205
- const { Name: name, Type: typeInfo } = colInfo[index];
2206
- return Object.assign( entry, { [name]: parseValue( typeInfo, value ) } );
2207
- }, { } )
2208
- );
2209
- };
2049
+ const handler = this.#handlers.find( h => h.match( event ) );
2050
+ if ( !handler ) {
2051
+ return this.#apiResponse.setContent( 405, Text.ERROR_405 ).toJSON();
2052
+ }
2210
2053
 
2054
+ const chain = [
2055
+ ...this.#beforeHooks.map( b => b.fn ),
2056
+ async ev => {
2057
+ const result = await handler.fn( ev );
2058
+ const response = new UserResponse( result );
2059
+ this.#apiResponse.setContent( ...response.values ).toJSON();
2060
+ },
2061
+ ...this.#afterHooks.map( a => a.fn )
2062
+ ];
2211
2063
 
2212
- /***/ }),
2064
+ try {
2065
+ for ( const fn of chain ) {
2066
+ await fn( event );
2067
+ }
2068
+ return this.#apiResponse.toJSON();
2213
2069
 
2214
- /***/ 7337:
2215
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2070
+ } catch ( error ) {
2071
+ console.error( 'Lambda API Error', { error, event } );
2216
2072
 
2217
- const { GetQueryExecutionCommand, GetQueryResultsCommand } = __webpack_require__( 3744 );
2218
- const parseResults = __webpack_require__( 834 );
2219
- const pollingDelay = __webpack_require__( 4127 );
2073
+ const response = this.#errorResponses.find( e => error instanceof e.errorType );
2074
+ if ( response ) {
2075
+ return this.#apiResponse.setContent( response.code, response.message ?? error.message ).toJSON();
2076
+ }
2077
+ return this.#apiResponse.setContent( 500, Text.ERROR_500 ).toJSON();
2078
+ }
2079
+ }
2080
+ };
2220
2081
 
2221
- const sleep = t => new Promise( r => setTimeout( () => r(), t ) );
2222
2082
 
2223
- const getQueryResults = async ( { client, queryExecutionId, maxResults, token } ) => {
2224
- const { NextToken: nextToken, ResultSet } = await client.send( new GetQueryResultsCommand( {
2225
- ...{ QueryExecutionId: queryExecutionId },
2226
- ...( maxResults ? { MaxResults: maxResults } : {} ),
2227
- ...( token ? { NextToken: token } : {} )
2228
- } ) );
2083
+ /***/ },
2229
2084
 
2230
- return { nextToken, items: parseResults( ResultSet ) };
2231
- };
2232
- const getQueryResultsRecursive = async ( { client, queryExecutionId, token } ) => {
2233
- const { nextToken, items } = await getQueryResults( { client, queryExecutionId, token } );
2085
+ /***/ 3446
2086
+ (module) {
2234
2087
 
2235
- if ( nextToken ) {
2236
- return { items: items.concat( ( await getQueryResultsRecursive( { client, queryExecutionId, token: nextToken } ) ).items ) };
2237
- }
2238
- return { items };
2239
- };
2088
+ module.exports = class LambdaApiValidationError extends Error {};
2240
2089
 
2241
- /**
2242
- * https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/athena/command/GetQueryResultsCommand/
2243
- * { client, recursive, queryExecutionId, maxResults, paginationToken }
2244
- */
2245
- const getResults = async ( { client, recursive, queryExecutionId, token, maxResults } ) => {
2246
- const { QueryExecution: { Status: status } } = await client.send( new GetQueryExecutionCommand( { QueryExecutionId: queryExecutionId } ) );
2247
2090
 
2248
- if ( status.State === 'FAILED' ) {
2249
- throw new Error( status.AthenaError?.ErrorMessage ?? status.StateChangeReason );
2250
- }
2091
+ /***/ },
2251
2092
 
2252
- if ( status.State === 'SUCCEEDED' ) {
2253
- const fn = recursive ? getQueryResultsRecursive : getQueryResults;
2254
- return fn( { client, recursive, queryExecutionId, token, maxResults } );
2255
- }
2093
+ /***/ 9760
2094
+ (module) {
2256
2095
 
2257
- // sleep an try again
2258
- await sleep( pollingDelay );
2259
- return getResults( { client, recursive, queryExecutionId, token, maxResults } );
2096
+ module.exports = {
2097
+ ERROR_500: 'Internal Server Error',
2098
+ ERROR_405: 'Method Not Allowed',
2099
+ INVALID_ERROR_TYPE: 'Argument "errorType" must be a constructor Function',
2100
+ INVALID_FN: 'Argument "fn" must be of type function',
2101
+ INVALID_METHOD: 'Argument "method" must be one of the default HTTP methods',
2102
+ INVALID_STATUS_CODE: 'Argument "statusCode" must be valid HTTP Status Code',
2103
+ INVALID_TRANSFORM_REQUEST: 'Argument "transformRequest" must be either "camelize", "snakelize", false or null',
2104
+ INVALID_TRANSFORM_RESPONSE: 'Argument "transformResponse" must be either "camelize", "snakelize", false or null',
2105
+ INVALID_MATCHER_ROUTE: 'Argument "route" must be either undefined or an string with length greater than 0',
2106
+ INVALID_MATCHER_ROUTE_INCLUDES: 'Argument "routeIncludes" must be either undefined or an string with length greater than 0',
2107
+ INVALID_MATCHER_ROUTE_NOT_INCLUDES: 'Argument "routeNotIncludes" must be either undefined or an string with length greater than 0',
2108
+ INVALID_MATCHER_ROUTE_MATCH: 'Argument "routeMatch" must be either undefined or type RegExp',
2109
+ INVALID_MATCHER_PATH: 'Argument "path" must be either undefined or an string with length greater than 0',
2110
+ INVALID_MATCHER_PATH_INCLUDES: 'Argument "pathIncludes" must be either undefined or an string with length greater than 0',
2111
+ INVALID_MATCHER_PATH_NOT_INCLUDES: 'Argument "pathNotIncludes" must be either undefined or an string with length greater than 0',
2112
+ INVALID_MATCHER_PATH_MATCH: 'Argument "pathMatch" must be either undefined or type RegExp',
2113
+ INVALID_USER_RESPONSE: 'Function return must be a number, a string, an array (where p=0 is a number) or an object (where .statusCode is a number)'
2260
2114
  };
2261
2115
 
2262
- module.exports = getResults;
2263
2116
 
2117
+ /***/ },
2264
2118
 
2265
- /***/ }),
2119
+ /***/ 8282
2120
+ (module, __unused_webpack_exports, __webpack_require__) {
2266
2121
 
2267
- /***/ 7416:
2268
- /***/ ((module) => {
2122
+ const validators = __webpack_require__( 8994 );
2123
+ const LambdaApiValidationError = __webpack_require__( 3446 );
2124
+ const Text = __webpack_require__( 9760 );
2269
2125
 
2270
- module.exports = v => Math.ceil( v / 1000 );
2126
+ module.exports = class UserResponse {
2127
+ constructor( args ) {
2128
+ if ( args === undefined ) {
2129
+ this.values = [ 204 ];
2130
+ } else if ( typeof args === 'string' && args.length === 0 ) {
2131
+ this.values = [ 204 ];
2271
2132
 
2133
+ } else if ( typeof args === 'string' && args.length > 0 ) {
2134
+ this.values = [ 200, args ];
2272
2135
 
2273
- /***/ }),
2136
+ } else if ( typeof args === 'number' ) {
2137
+ validators.statusCode( args );
2138
+ this.values = [ args ];
2274
2139
 
2275
- /***/ 7493:
2276
- /***/ ((module) => {
2140
+ } else if ( Array.isArray( args ) ) {
2141
+ validators.statusCode( args[0] );
2142
+ this.values = args;
2277
2143
 
2278
- "use strict";
2279
- module.exports = require("@aws-sdk/client-cloudwatch-logs");
2144
+ } else if ( args.statusCode ) {
2145
+ validators.statusCode( args.statusCode );
2146
+ this.values = [ args.statusCode, args.body, args.headers, args.isBase64Encoded ];
2280
2147
 
2281
- /***/ }),
2148
+ } else if ( [ undefined, null ].includes( args ) ) {
2149
+ this.values = [ 200 ];
2150
+ } else {
2151
+ throw new LambdaApiValidationError( Text.INVALID_USER_RESPONSE );
2152
+ }
2153
+ }
2154
+ };
2282
2155
 
2283
- /***/ 7572:
2284
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2285
2156
 
2286
- const isSerializable = __webpack_require__( 8864 );
2287
- const snakelize = __webpack_require__( 3402 );
2157
+ /***/ },
2288
2158
 
2289
- const change = ( obj, keepAllCaps ) =>
2290
- !isSerializable( obj ) ? obj : Object.entries( obj ).reduce( ( transformed, [ key, value ] ) => {
2291
- delete transformed[key];
2292
- transformed[snakelize( key, { keepAllCaps } )] = typeof value === 'object' ? change( value, keepAllCaps ) : value;
2293
- return transformed;
2294
- }, Array.isArray( obj ) ? [] : {} );
2159
+ /***/ 8994
2160
+ (module, __unused_webpack_exports, __webpack_require__) {
2295
2161
 
2296
- module.exports = ( obj, { keepAllCaps = false } = {} ) => change( obj, keepAllCaps );
2162
+ const Text = __webpack_require__( 9760 );
2163
+ const LambdaApiValidationError = __webpack_require__( 3446 );
2297
2164
 
2165
+ const evaluate = ( condition, errorMessage ) => {
2166
+ if ( !condition ) { throw new LambdaApiValidationError( errorMessage ); }
2167
+ };
2298
2168
 
2299
- /***/ }),
2169
+ const isConstructor = v => {
2170
+ try {
2171
+ return !!Reflect.construct( new Proxy( v, {} ), [] );
2172
+ } catch {
2173
+ return false;
2174
+ }
2175
+ };
2300
2176
 
2301
- /***/ 7651:
2302
- /***/ ((module) => {
2177
+ module.exports = {
2178
+ errorType: v => evaluate( isConstructor( v ), Text.INVALID_ERROR_TYPE ),
2179
+ function: v => evaluate( typeof v === 'function', Text.INVALID_FN ),
2180
+ httpMethod: v => evaluate( [ 'DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT' ].includes( v ), Text.INVALID_METHOD ),
2181
+ matcherPath: v => evaluate( v === undefined || ( typeof v === 'string' && v.length > 0 ), Text.INVALID_MATCHER_PATH ),
2182
+ matcherPathIncludes: v => evaluate( v === undefined || ( typeof v === 'string' && v.length > 0 ), Text.INVALID_MATCHER_PATH_INCLUDES ),
2183
+ matcherPathMatch: v => evaluate( v === undefined || v?.constructor?.name === RegExp.name, Text.INVALID_MATCHER_PATH_MATCH ),
2184
+ matcherPathNotIncludes: v => evaluate( v === undefined || ( typeof v === 'string' && v.length > 0 ), Text.INVALID_MATCHER_PATH_NOT_INCLUDES ),
2185
+ matcherRoute: v => evaluate( v === undefined || ( typeof v === 'string' && v.length > 0 ), Text.INVALID_MATCHER_ROUTE ),
2186
+ matcherRouteIncludes: v => evaluate( v === undefined || ( typeof v === 'string' && v.length > 0 ), Text.INVALID_MATCHER_ROUTE_INCLUDES ),
2187
+ matcherRouteMatch: v => evaluate( v === undefined || v?.constructor?.name === RegExp.name, Text.INVALID_MATCHER_ROUTE_MATCH ),
2188
+ matcherRouteNotIncludes: v => evaluate( v === undefined || ( typeof v === 'string' && v.length > 0 ), Text.INVALID_MATCHER_ROUTE_NOT_INCLUDES ),
2189
+ statusCode: v => evaluate( typeof v === 'number' && /^[1-5]\d\d$/.test( String( v ) ), Text.INVALID_STATUS_CODE ),
2190
+ transformRequest: v => evaluate( [ 'camelcase', 'snakecase', null, false ].includes( v ), Text.INVALID_TRANSFORM_REQUEST ),
2191
+ transformResponse: v => evaluate( [ 'camelcase', 'snakecase', null, false ].includes( v ), Text.INVALID_TRANSFORM_RESPONSE )
2192
+ };
2303
2193
 
2304
- "use strict";
2305
- module.exports = require("@aws-sdk/client-sns");
2306
2194
 
2307
- /***/ }),
2195
+ /***/ },
2308
2196
 
2309
- /***/ 8080:
2310
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2197
+ /***/ 4124
2198
+ (module) {
2311
2199
 
2312
- const { PublishCommand } = __webpack_require__( 7651 );
2200
+ module.exports = values => values.reduce( ( sum, value ) => sum + value, 0 ) / values.length;
2313
2201
 
2314
- module.exports = async ( client, topic, message, args = {} ) => {
2315
- const response = await client.send( new PublishCommand( {
2316
- ...args,
2317
- TopicArn: topic,
2318
- Message: typeof message === 'string' ? message : JSON.stringify( message )
2319
- } ) );
2320
- return response.MessageId;
2321
- };
2322
2202
 
2203
+ /***/ },
2323
2204
 
2324
- /***/ }),
2205
+ /***/ 3187
2206
+ (module) {
2325
2207
 
2326
- /***/ 8119:
2327
- /***/ ((module) => {
2208
+ module.exports = values => {
2209
+ //Sort bug: https://www.tutorialrepublic.com/faq/how-to-sort-an-array-of-integers-correctly-in-javascript.php
2210
+ const sorted = values.slice().sort( ( a, b ) => a - b );
2211
+ const evenArray = values.length % 2 === 0;
2212
+ const midIndex = Math.floor( values.length / 2 );
2213
+ return evenArray ? ( sorted[midIndex - 1] + sorted[midIndex] ) / 2 : sorted[midIndex];
2214
+ };
2328
2215
 
2329
- module.exports = t => t * 30 * 24 * 60 * 60 * 1000;
2330
2216
 
2217
+ /***/ },
2331
2218
 
2332
- /***/ }),
2219
+ /***/ 4692
2220
+ (module, __unused_webpack_exports, __webpack_require__) {
2333
2221
 
2334
- /***/ 8175:
2335
- /***/ ((module) => {
2222
+ const calcMedian = __webpack_require__( 3187 );
2336
2223
 
2337
- /*
2338
- References:
2339
- - https://docs.aws.amazon.com/AWSSimpleQueueService/latest/APIReference/API_SendMessage.html
2340
- - https://stackoverflow.com/questions/58809098/remove-invalid-characters-from-message-sent-to-aws-amazon-sqs
2341
- */
2342
- module.exports = v => v?.replace( /[^\u0009\u000A\u000D\u0020-\uD7FF\uE000-\uFFFD\u{10000}-\u{10FFFF}]/ug, '' ) // eslint-disable-line
2224
+ module.exports = pop => {
2225
+ const center = calcMedian( pop );
2226
+ return calcMedian( pop.map( v => Math.abs( v - center ) ) );
2227
+ };
2343
2228
 
2344
2229
 
2345
- /***/ }),
2230
+ /***/ },
2346
2231
 
2347
- /***/ 8233:
2348
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2232
+ /***/ 2736
2233
+ (module, __unused_webpack_exports, __webpack_require__) {
2349
2234
 
2350
- const { unzipSync } = __webpack_require__( 3106 );
2235
+ const calcMean = __webpack_require__( 4124 );
2351
2236
 
2352
- const firstIndexOf = ( c, ...vars ) => Math.min( ...vars.map( v => c.indexOf( v ) ).filter( n => n > -1 ) );
2353
- const lastIndexOf = ( c, ...vars ) => Math.max( ...vars.map( v => c.lastIndexOf( v ) ) );
2237
+ module.exports = values => {
2238
+ const mean = calcMean( values );
2239
+ const squareDiffs = values.map( value => Math.pow( value - mean, 2 ) );
2240
+ const avgSquareDiff = calcMean( squareDiffs );
2241
+ return Math.sqrt( avgSquareDiff );
2242
+ };
2354
2243
 
2355
- /**
2356
- * Decompress JSON
2357
- *
2358
- * Reads a gzipped tarball (.tar.gz)
2359
- * 1. Unzip it
2360
- * 2. Convert all to utf-8
2361
- * 3. Split files using the \0star separator
2362
- * 4. Trim files until JSON markup start/end ({})
2363
- * 5. JSON parse
2364
- *
2365
- * Enjoy this 100% native tarball decompression!
2366
- */
2367
- module.exports = raw =>
2368
- unzipSync( raw )
2369
- .toString( 'utf-8' )
2370
- .split( '\0ustar' )
2371
- .slice( 1 )
2372
- .map( c =>
2373
- JSON.parse( c.substring( firstIndexOf( c, '{', '[' ), lastIndexOf( c, '}', ']' ) + 1 ) )
2374
- );
2375
2244
 
2245
+ /***/ },
2376
2246
 
2377
- /***/ }),
2247
+ /***/ 6089
2248
+ (module, __unused_webpack_exports, __webpack_require__) {
2378
2249
 
2379
- /***/ 8248:
2380
- /***/ ((module) => {
2250
+ const calcMean = __webpack_require__( 4124 );
2381
2251
 
2382
- "use strict";
2383
- module.exports = require("@aws-sdk/client-timestream-write");
2252
+ module.exports = values => {
2253
+ if ( values.length < 2 ) { return NaN; }
2384
2254
 
2385
- /***/ }),
2255
+ const mean = calcMean( values );
2256
+ const squareDiffs = values.map( value => Math.pow( value - mean, 2 ) );
2257
+ const avgSquareDiff = squareDiffs.reduce( ( sum, v ) => sum + v, 0 ) / ( values.length - 1 );
2258
+ return Math.sqrt( avgSquareDiff );
2259
+ };
2386
2260
 
2387
- /***/ 8256:
2388
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2389
2261
 
2390
- const isSerializable = __webpack_require__( 8864 );
2391
- const camelize = __webpack_require__( 3914 );
2262
+ /***/ },
2392
2263
 
2393
- const change = ( obj, keepAllCaps ) =>
2394
- !isSerializable( obj ) ? obj : Object.entries( obj ).reduce( ( transformed, [ key, value ] ) => {
2395
- delete transformed[key];
2396
- transformed[camelize( key, { keepAllCaps } )] = typeof value === 'object' ? change( value, keepAllCaps ) : value;
2397
- return transformed;
2398
- }, Array.isArray( obj ) ? [] : {} );
2264
+ /***/ 4110
2265
+ (module) {
2399
2266
 
2400
- module.exports = ( obj, { keepAllCaps = false } = {} ) => change( obj, keepAllCaps );
2267
+ module.exports = ( sample, mean, stdDev ) => stdDev === 0 ? NaN : ( sample - mean ) / stdDev;
2401
2268
 
2402
2269
 
2403
- /***/ }),
2270
+ /***/ },
2404
2271
 
2405
- /***/ 8278:
2406
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2272
+ /***/ 943
2273
+ (module, __unused_webpack_exports, __webpack_require__) {
2407
2274
 
2408
- const joinUnique = __webpack_require__( 2836 );
2409
- const joinUniqueCustom = __webpack_require__( 536 );
2410
- const splitBatches = __webpack_require__( 4821 );
2275
+ const calcMean = __webpack_require__( 4124 );
2276
+ const calcMedian = __webpack_require__( 3187 );
2277
+ const calcMedianAbsDev = __webpack_require__( 4692 );
2278
+ const calcStdDevPopulation = __webpack_require__( 2736 );
2279
+ const calcStdDevSample = __webpack_require__( 6089 );
2280
+ const calcZScore = __webpack_require__( 4110 );
2281
+ const roundGaussian = __webpack_require__( 637 );
2282
+ const roundStandard = __webpack_require__( 115 );
2411
2283
 
2412
2284
  module.exports = {
2413
- joinUnique,
2414
- joinUniqueCustom,
2415
- splitBatches
2285
+ calcMean,
2286
+ calcMedian,
2287
+ calcMedianAbsDev,
2288
+ calcStdDevPopulation,
2289
+ calcStdDevSample,
2290
+ calcZScore,
2291
+ roundGaussian,
2292
+ roundStandard
2416
2293
  };
2417
2294
 
2418
2295
 
2419
- /***/ }),
2296
+ /***/ },
2420
2297
 
2421
- /***/ 8282:
2422
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2298
+ /***/ 637
2299
+ (module) {
2423
2300
 
2424
- const validators = __webpack_require__( 8994 );
2425
- const LambdaApiValidationError = __webpack_require__( 3446 );
2426
- const Text = __webpack_require__( 9760 );
2427
-
2428
- module.exports = class UserResponse {
2429
- constructor( args ) {
2430
- if ( args === undefined ) {
2431
- this.values = [ 204 ];
2432
- } else if ( typeof args === 'string' && args.length === 0 ) {
2433
- this.values = [ 204 ];
2434
-
2435
- } else if ( typeof args === 'string' && args.length > 0 ) {
2436
- this.values = [ 200, args ];
2301
+ module.exports = ( n, d = 2 ) => {
2302
+ if ( !isFinite( n ) || typeof n !== 'number' ) { return NaN; }
2437
2303
 
2438
- } else if ( typeof args === 'number' ) {
2439
- validators.statusCode( args );
2440
- this.values = [ args ];
2304
+ const m = Math.pow( 10, d );
2305
+ const num = +( n * m ).toFixed( 8 ); // Avoid rounding errors
2306
+ const i = Math.floor( num );
2307
+ const f = num - i;
2308
+ const e = 1e-8; // Allow for rounding errors in f
2309
+ const r = ( f > 0.5 - e && f < 0.5 + e ) ? // eslint-disable-line no-nested-ternary
2310
+ ( ( i % 2 === 0 ) ? i : i + 1 ) : Math.round( num );
2311
+ return r / m;
2312
+ };
2441
2313
 
2442
- } else if ( Array.isArray( args ) ) {
2443
- validators.statusCode( args[0] );
2444
- this.values = args;
2445
2314
 
2446
- } else if ( args.statusCode ) {
2447
- validators.statusCode( args.statusCode );
2448
- this.values = [ args.statusCode, args.body, args.headers, args.isBase64Encoded ];
2315
+ /***/ },
2449
2316
 
2450
- } else if ( [ undefined, null ].includes( args ) ) {
2451
- this.values = [ 200 ];
2452
- } else {
2453
- throw new LambdaApiValidationError( Text.INVALID_USER_RESPONSE );
2454
- }
2455
- }
2456
- };
2317
+ /***/ 115
2318
+ (module) {
2457
2319
 
2320
+ module.exports = ( n, d = 2 ) => Math.round( n * ( 10 ** d ) ) / ( 10 ** d );
2458
2321
 
2459
- /***/ }),
2460
2322
 
2461
- /***/ 8593:
2462
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2323
+ /***/ },
2463
2324
 
2464
- const { BatchWriteCommand } = __webpack_require__( 3489 );
2465
- const splitBatches = __webpack_require__( 4821 );
2325
+ /***/ 8256
2326
+ (module, __unused_webpack_exports, __webpack_require__) {
2466
2327
 
2467
- const batchSize = 25;
2328
+ const isSerializable = __webpack_require__( 8864 );
2329
+ const camelize = __webpack_require__( 3914 );
2468
2330
 
2469
- const getMapper = method => method === 'put' ? v => ( { PutRequest: { Item: v } } ) : v => ( { DeleteRequest: { Key: v } } );
2331
+ const change = ( obj, keepAllCaps ) =>
2332
+ !isSerializable( obj ) ? obj : Object.entries( obj ).reduce( ( transformed, [ key, value ] ) => {
2333
+ delete transformed[key];
2334
+ transformed[camelize( key, { keepAllCaps } )] = typeof value === 'object' ? change( value, keepAllCaps ) : value;
2335
+ return transformed;
2336
+ }, Array.isArray( obj ) ? [] : {} );
2470
2337
 
2471
- const process = async ( { client, method, table, batches } ) => {
2472
- if ( batches.length === 0 ) { return true; }
2338
+ module.exports = ( obj, { keepAllCaps = false } = {} ) => change( obj, keepAllCaps );
2473
2339
 
2474
- const response = await client.send( new BatchWriteCommand( { RequestItems: { [table]: batches[0] } } ) );
2475
2340
 
2476
- const unprocessed = response.UnprocessedItems?.[table];
2477
- return process( {
2478
- client, method, table,
2479
- batches: unprocessed ? splitBatches( batches.slice( 1 ).flat().concat( unprocessed ), batchSize ) : batches.slice( 1 )
2480
- } );
2481
- };
2341
+ /***/ },
2482
2342
 
2483
- module.exports = async ( client, method, table, items ) =>
2484
- process( { client, method, table, batches: splitBatches( items.map( getMapper( method ) ), batchSize ) } );
2343
+ /***/ 6451
2344
+ (module) {
2485
2345
 
2346
+ module.exports = ( obj, props ) => Object.fromEntries( Object.entries( obj ).filter( ( [ k ] ) => props.includes( k ) ) );
2486
2347
 
2487
- /***/ }),
2488
2348
 
2489
- /***/ 8660:
2490
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2349
+ /***/ },
2491
2350
 
2492
- const cacheStorage = __webpack_require__( 4164 );
2493
- const { GetParameterCommand } = __webpack_require__( 4348 );
2351
+ /***/ 5762
2352
+ (module, __unused_webpack_exports, __webpack_require__) {
2494
2353
 
2495
- module.exports = async ( client, name ) => {
2496
- const key = `SSM_${name}`;
2497
- const cacheValue = cacheStorage.get( key );
2498
- if ( cacheValue ) { return cacheValue; }
2354
+ const camelize = __webpack_require__( 8256 );
2355
+ const filterProps = __webpack_require__( 6451 );
2356
+ const removeEmptyArrays = __webpack_require__( 2047 );
2357
+ const snakelize = __webpack_require__( 7572 );
2499
2358
 
2500
- try {
2501
- const response = await client.send( new GetParameterCommand( { Name: name, WithDecryption: true } ) );
2502
- const value = response?.Parameter?.Value;
2503
- cacheStorage.set( key, value );
2504
- return value;
2505
- } catch ( error ) {
2506
- if ( error.constructor.name === 'ParameterNotFound' ) {
2507
- return null;
2508
- }
2509
- throw error;
2510
- }
2359
+ module.exports = {
2360
+ camelize,
2361
+ filterProps,
2362
+ removeEmptyArrays,
2363
+ snakelize
2511
2364
  };
2512
2365
 
2513
2366
 
2514
- /***/ }),
2367
+ /***/ },
2515
2368
 
2516
- /***/ 8864:
2517
- /***/ ((module) => {
2369
+ /***/ 8864
2370
+ (module) {
2518
2371
 
2519
2372
  module.exports = obj =>
2520
2373
  typeof obj === 'object' &&
@@ -2525,203 +2378,235 @@ module.exports = obj =>
2525
2378
  !( obj instanceof Date );
2526
2379
 
2527
2380
 
2528
- /***/ }),
2381
+ /***/ },
2529
2382
 
2530
- /***/ 8936:
2531
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2383
+ /***/ 2047
2384
+ (module) {
2532
2385
 
2533
- const { WriteRecordsCommand } = __webpack_require__( 8248 );
2386
+ module.exports = o => Object.fromEntries( Object.entries( o ).filter( ( [ , v ] ) => !Array.isArray( v ) || v.length > 0 ) );
2534
2387
 
2535
- module.exports = async ( client, { database, table, records, ignoreRejections = false } ) => {
2536
- try {
2537
- const response = await client.send( new WriteRecordsCommand( {
2538
- DatabaseName: database,
2539
- TableName: table,
2540
- Records: records
2541
- } ) );
2542
- return { recordsIngested: response.RecordsIngested };
2543
- } catch ( error ) {
2544
- if ( ignoreRejections && error.name === 'RejectedRecordsException' ) {
2545
- return { rejectedRecords: error.RejectedRecords };
2546
- }
2547
- throw error;
2548
- }
2549
- };
2550
2388
 
2389
+ /***/ },
2551
2390
 
2552
- /***/ }),
2391
+ /***/ 7572
2392
+ (module, __unused_webpack_exports, __webpack_require__) {
2553
2393
 
2554
- /***/ 8994:
2555
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2394
+ const isSerializable = __webpack_require__( 8864 );
2395
+ const snakelize = __webpack_require__( 3402 );
2556
2396
 
2557
- const Text = __webpack_require__( 9760 );
2558
- const LambdaApiValidationError = __webpack_require__( 3446 );
2397
+ const change = ( obj, keepAllCaps ) =>
2398
+ !isSerializable( obj ) ? obj : Object.entries( obj ).reduce( ( transformed, [ key, value ] ) => {
2399
+ delete transformed[key];
2400
+ transformed[snakelize( key, { keepAllCaps } )] = typeof value === 'object' ? change( value, keepAllCaps ) : value;
2401
+ return transformed;
2402
+ }, Array.isArray( obj ) ? [] : {} );
2559
2403
 
2560
- const evaluate = ( condition, errorMessage ) => {
2561
- if ( !condition ) { throw new LambdaApiValidationError( errorMessage ); }
2562
- };
2404
+ module.exports = ( obj, { keepAllCaps = false } = {} ) => change( obj, keepAllCaps );
2563
2405
 
2564
- const isConstructor = v => {
2565
- try {
2566
- return !!Reflect.construct( new Proxy( v, {} ), [] );
2567
- } catch {
2568
- return false;
2406
+
2407
+ /***/ },
2408
+
2409
+ /***/ 5422
2410
+ (module) {
2411
+
2412
+ global.__redisInstances = {};
2413
+
2414
+ /**
2415
+ * Create a redis client instance
2416
+ * @param {Object} redis Redis npm dependency
2417
+ * @param {String} address Redis DB address (either RW or RO)
2418
+ * @returns redisClient A new redis client instance connected to the database
2419
+ */
2420
+ module.exports = async ( { redis, address, protocol = 'rediss', port = 6379 } ) => {
2421
+ if ( global.__redisInstances[address] ) {
2422
+ try {
2423
+ const r = await global.__redisInstances[address].ping();
2424
+ if ( r === 'PONG' ) {
2425
+ return global.__redisInstances[address];
2426
+ } else {
2427
+ delete global.__redisInstances[address];
2428
+ }
2429
+ } catch {
2430
+ delete global.__redisInstances[address];
2431
+ }
2569
2432
  }
2570
- };
2571
2433
 
2572
- module.exports = {
2573
- errorType: v => evaluate( isConstructor( v ), Text.INVALID_ERROR_TYPE ),
2574
- function: v => evaluate( typeof v === 'function', Text.INVALID_FN ),
2575
- httpMethod: v => evaluate( [ 'DELETE', 'GET', 'HEAD', 'PATCH', 'POST', 'PUT' ].includes( v ), Text.INVALID_METHOD ),
2576
- matcherPath: v => evaluate( v === undefined || ( typeof v === 'string' && v.length > 0 ), Text.INVALID_MATCHER_PATH ),
2577
- matcherPathIncludes: v => evaluate( v === undefined || ( typeof v === 'string' && v.length > 0 ), Text.INVALID_MATCHER_PATH_INCLUDES ),
2578
- matcherPathMatch: v => evaluate( v === undefined || v?.constructor?.name === RegExp.name, Text.INVALID_MATCHER_PATH_MATCH ),
2579
- matcherPathNotIncludes: v => evaluate( v === undefined || ( typeof v === 'string' && v.length > 0 ), Text.INVALID_MATCHER_PATH_NOT_INCLUDES ),
2580
- matcherRoute: v => evaluate( v === undefined || ( typeof v === 'string' && v.length > 0 ), Text.INVALID_MATCHER_ROUTE ),
2581
- matcherRouteIncludes: v => evaluate( v === undefined || ( typeof v === 'string' && v.length > 0 ), Text.INVALID_MATCHER_ROUTE_INCLUDES ),
2582
- matcherRouteMatch: v => evaluate( v === undefined || v?.constructor?.name === RegExp.name, Text.INVALID_MATCHER_ROUTE_MATCH ),
2583
- matcherRouteNotIncludes: v => evaluate( v === undefined || ( typeof v === 'string' && v.length > 0 ), Text.INVALID_MATCHER_ROUTE_NOT_INCLUDES ),
2584
- statusCode: v => evaluate( typeof v === 'number' && /^[1-5]\d\d$/.test( String( v ) ), Text.INVALID_STATUS_CODE ),
2585
- transformRequest: v => evaluate( [ 'camelcase', 'snakecase', null, false ].includes( v ), Text.INVALID_TRANSFORM_REQUEST ),
2586
- transformResponse: v => evaluate( [ 'camelcase', 'snakecase', null, false ].includes( v ), Text.INVALID_TRANSFORM_RESPONSE )
2434
+ const client = redis.createClient( { url: `${protocol}://${address}:${port}`, socket: { keepAlive: 15000 } } );
2435
+
2436
+ await client.connect();
2437
+
2438
+ global.__redisInstances[address] = client;
2439
+ return client;
2587
2440
  };
2588
2441
 
2589
2442
 
2590
- /***/ }),
2443
+ /***/ },
2591
2444
 
2592
- /***/ 9039:
2593
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2445
+ /***/ 4528
2446
+ (module, __unused_webpack_exports, __webpack_require__) {
2594
2447
 
2595
- const cache = __webpack_require__( 4164 );
2448
+ const createClient = __webpack_require__( 5422 );
2596
2449
 
2597
- module.exports = ( constructor, args = [] ) => {
2598
- const cacheKey = `${constructor.name}(${args.map( arg => JSON.stringify( arg ) ).join( ',' )})`;
2599
- return cache.get( cacheKey ) ?? ( () => {
2600
- const client = Reflect.construct( constructor, args );
2601
- cache.set( cacheKey, client );
2602
- return client;
2603
- } )();
2450
+ module.exports = {
2451
+ createClient
2604
2452
  };
2605
2453
 
2606
2454
 
2607
- /***/ }),
2455
+ /***/ },
2608
2456
 
2609
- /***/ 9129:
2610
- /***/ ((module) => {
2457
+ /***/ 3914
2458
+ (module) {
2611
2459
 
2612
- /* eslint consistent-return: 0 */
2613
- const removeNullValues = ( o, isArray = Array.isArray( o ) ) =>
2614
- Object.entries( o ).reduce( ( newObj, [ k, v ] ) => {
2615
- if ( v === null && !isArray ) { return newObj; }
2616
- return Object.assign( newObj, { [k]: v?.constructor === Object ? removeNullValues( v ) : v } );
2617
- }, isArray ? [] : {} );
2618
-
2619
- module.exports = ( v, type ) => {
2620
- if ( [ null, undefined ].includes( v ) ) {
2621
- return undefined;
2622
- }
2623
- if ( v === '' && type !== 'varchar' ) {
2624
- return undefined;
2625
- }
2626
- if ( type === 'boolean' ) {
2627
- return v === 'true';
2628
- }
2629
- if ( [ 'float', 'decimal', 'double' ].includes( type ) ) {
2630
- return parseFloat( v );
2631
- }
2632
- if ( [ 'tinyint', 'smallint', 'int', 'bigint' ].includes( type ) ) {
2633
- return parseInt( v );
2634
- }
2635
- if ( 'timestamp' === type ) {
2636
- return new Date( v ).getTime();
2637
- }
2638
- if ( [ 'row', 'array' ].includes( type ) ) {
2639
- const obj = v.replace( /(?<=(?:{|,\s)[\w-_]+)=/g, '@@DELIMITER@@' ) // replaces delimiter = with @@DELIMITER@@
2640
- .replace( /(?<={|,\s)([\w_-]+)(?=@@DELIMITER@@)/g, '"$1"' ) // wrap object keys
2641
- .replace( /(?<=@@DELIMITER@@)((?:(?!,\s|}|\[|{).)+)/g, '"$1"' ) // wrap object values
2642
- .replace( /(?<=\[|,\s)((?:(?!,\s|{|\]|").)+)/g, '"$1"' ) // wrap array values
2643
- .replace( /"null"/g, 'null' ) // convert "null" to null
2644
- .replace( /@@DELIMITER@@/g, ':' ); // replaces @@DELIMITER@@ for :
2460
+ // Convert a string to camelCase
2461
+ module.exports = ( input, { keepAllCaps = false } = {} ) =>
2462
+ // Break the string into sequences to rebuild later
2463
+ !input ? input : input.split( /\s/ )
2464
+ // ALL_CAPS terms are ignored
2465
+ .map( term => [ term, keepAllCaps && /^[A-Z_]+$/g.test( term ) ? term : term
2466
+ // Matches the penultimate letter in a sequence of upper case followed by lower case and convert it to lower case
2467
+ // Effectively creating a word break eg: BDay => bDay
2468
+ .replace( /[A-Z](?=[A-Z][a-z])/g, c => `${c[0].toLowerCase()}` )
2469
+ .replace( /([A-Z])([A-Z]+)/g, c => `${c[0]}${c.slice( 1 ).toLowerCase()}` ) // Sequences of upper case
2470
+ .replace( /([-_]\w)/g, c => c[1].toUpperCase() ) // first letter after hyphen and underline
2471
+ .replace( /^([A-Z])/g, c => c[0].toLowerCase() ) // first letter
2472
+ ] )
2473
+ // Rebuild the string replacing the converter terms keeping the original delimiters
2474
+ .reduce( ( result, [ term, repl ] ) => result.replace( term, repl ), input );
2645
2475
 
2646
- return removeNullValues( JSON.parse( obj ) );
2647
- }
2648
- if ( 'json' === type ) {
2649
- return JSON.parse( v );
2650
- }
2651
- return v;
2476
+
2477
+ /***/ },
2478
+
2479
+ /***/ 3258
2480
+ (module) {
2481
+
2482
+ module.exports = input =>
2483
+ // Break the string into sequences to rebuild later
2484
+ !input ? input : input.split( /\s/ )
2485
+ // ALL_CAPS terms are ignored
2486
+ .map( term => [ term, term.charAt( 0 ).toUpperCase() + term.slice( 1 ).toLowerCase() ] )
2487
+ // Rebuild the string replacing the converter terms keeping the original delimiters
2488
+ .reduce( ( result, [ term, repl ] ) => result.replace( term, repl ), input );
2489
+
2490
+
2491
+ /***/ },
2492
+
2493
+ /***/ 268
2494
+ (module, __unused_webpack_exports, __webpack_require__) {
2495
+
2496
+ const camelize = __webpack_require__( 3914 );
2497
+ const capitalizeWords = __webpack_require__( 3258 );
2498
+ const snakelize = __webpack_require__( 3402 );
2499
+
2500
+ module.exports = {
2501
+ camelize,
2502
+ capitalizeWords,
2503
+ snakelize
2652
2504
  };
2653
2505
 
2654
2506
 
2655
- /***/ }),
2507
+ /***/ },
2656
2508
 
2657
- /***/ 9179:
2658
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2509
+ /***/ 3402
2510
+ (module) {
2659
2511
 
2660
- const parseValue = __webpack_require__( 2847 );
2512
+ // convert a string to snake_case
2513
+ module.exports = ( input, { keepAllCaps = false } = {} ) =>
2514
+ // Break the string into sequences to rebuild later
2515
+ !input ? input : input.split( /\s/ )
2516
+ // ALL_CAPS terms are ignored
2517
+ .map( term => [ term, keepAllCaps && /^[A-Z_]+$/g.test( term ) ? term : term
2518
+ .replace( /-/g, '_' ) // replaces hyphen
2519
+ .replace( /([a-z\d])([A-Z])/g, '$1_$2' ) // add _ between lower and upper case letters
2520
+ .replace( /([A-Z])([A-Z])(?=[a-z\d])/g, '$1_$2' ).toLowerCase() // add _ between uppercase char and next uppercase char follow by lowercase
2521
+ ] )
2522
+ // Rebuild the string replacing the converter terms keeping the original delimiters
2523
+ .reduce( ( result, [ term, repl ] ) => result.replace( term, repl ), input );
2661
2524
 
2662
- module.exports = item =>
2663
- item.reduce( ( row, { field, value } ) =>
2664
- Object.assign( row, {
2665
- [field]: parseValue( value )
2666
- } ), {} );
2667
2525
 
2526
+ /***/ },
2668
2527
 
2669
- /***/ }),
2528
+ /***/ 6878
2529
+ (module, __unused_webpack_exports, __webpack_require__) {
2670
2530
 
2671
- /***/ 9552:
2672
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2531
+ const retryOnError = __webpack_require__( 4243 );
2532
+ const sleep = __webpack_require__( 2445 );
2533
+ const Timer = __webpack_require__( 9651 );
2534
+ const untarJsonGz = __webpack_require__( 8233 );
2673
2535
 
2674
- const parseItem = __webpack_require__( 9179 );
2536
+ module.exports = {
2537
+ retryOnError,
2538
+ sleep,
2539
+ Timer,
2540
+ untarJsonGz
2541
+ };
2675
2542
 
2676
- module.exports = results => results.map( item => parseItem( item ) );
2677
2543
 
2544
+ /***/ },
2678
2545
 
2679
- /***/ }),
2546
+ /***/ 4243
2547
+ (module, __unused_webpack_exports, __webpack_require__) {
2680
2548
 
2681
- /***/ 9556:
2682
- /***/ ((module) => {
2549
+ const sleep = __webpack_require__( 2445 );
2683
2550
 
2684
- "use strict";
2685
- module.exports = require("@aws-sdk/client-sesv2");
2551
+ const execWithRetry = async ( closure, { limit, delay, retryHook, execCount = 0 } ) => {
2552
+ if ( !( closure instanceof Function ) ) {
2553
+ throw new Error( 'Closure is not a function' );
2554
+ }
2686
2555
 
2687
- /***/ }),
2556
+ try {
2557
+ return await closure();
2558
+ } catch ( error ) {
2559
+ // exhausted
2560
+ if ( execCount === limit ) { throw error; }
2688
2561
 
2689
- /***/ 9628:
2690
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2562
+ // async retry hook to check if it should retry or give up and throw
2563
+ if ( retryHook instanceof Function ) {
2564
+ try {
2565
+ const retry = await retryHook( error, execCount );
2566
+ if ( retry === false ) { return false; }
2691
2567
 
2692
- const { PutCommand } = __webpack_require__( 3489 );
2568
+ // Hook errors break the flow
2569
+ } catch ( hookError ) {
2570
+ console.debug( hookError );
2571
+ throw hookError;
2572
+ }
2573
+ }
2693
2574
 
2694
- const parseArgs = args => {
2695
- // native args mode
2696
- if ( args[0] instanceof Object ) {
2697
- return args[0];
2575
+ // if there is no hook back-off and retry
2576
+ if ( delay > 0 ) {
2577
+ await sleep( delay ** ( 1 + execCount ) );
2578
+ }
2579
+ return execWithRetry( closure, { limit, delay, retryHook, execCount: execCount + 1 } );
2698
2580
  }
2699
- // sugar mode
2700
- return {
2701
- TableName: args[0],
2702
- Item: args[1],
2703
- ReturnValues: 'NONE',
2704
- ReturnConsumedCapacity: 'NONE'
2705
- };
2706
2581
  };
2707
2582
 
2708
2583
  /**
2709
2584
  *
2710
- * @param {*} client
2711
- * @param {...any} args The args. either one object with the native args or two string args, tableName and item.
2712
- * @returns
2585
+ * @param {Function} closure A self contained function that will be invoked
2586
+ * @param {Object} config
2587
+ * @param {Number} limit The max number of retries
2588
+ * @param {Number} delay The delay between each retry (it will be multiplied by the number of retries, so, it is linear back-off)
2589
+ * @param {Function} retryHook A function to be called every-time a retry is needed.
2590
+ * If this functions returns false, the retry error is raised
2591
+ * If this functions throws error, the thrown error is raised
2592
+ * @returns {Any} The closure result
2713
2593
  */
2714
- module.exports = async ( client, ...args ) => {
2715
- const nativeArgs = parseArgs( args );
2716
- const response = await client.send( new PutCommand( nativeArgs ) );
2717
- return response.Attributes ?? nativeArgs.Item;
2718
- };
2594
+ module.exports = async ( closure, { limit = 0, delay = 0, retryHook = null } = {} ) =>
2595
+ execWithRetry( closure, { limit, delay, retryHook } );
2596
+
2597
+
2598
+ /***/ },
2599
+
2600
+ /***/ 2445
2601
+ (module) {
2602
+
2603
+ module.exports = t => new Promise( r => setTimeout( r, t ) );
2719
2604
 
2720
2605
 
2721
- /***/ }),
2606
+ /***/ },
2722
2607
 
2723
- /***/ 9651:
2724
- /***/ ((module) => {
2608
+ /***/ 9651
2609
+ (module) {
2725
2610
 
2726
2611
  module.exports = class Timer {
2727
2612
  #startedAt;
@@ -2766,49 +2651,167 @@ module.exports = class Timer {
2766
2651
  };
2767
2652
 
2768
2653
 
2769
- /***/ }),
2654
+ /***/ },
2770
2655
 
2771
- /***/ 9704:
2772
- /***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2656
+ /***/ 8233
2657
+ (module, __unused_webpack_exports, __webpack_require__) {
2773
2658
 
2774
- const { PutObjectCommand } = __webpack_require__( 5725 );
2659
+ const { unzipSync } = __webpack_require__( 3106 );
2775
2660
 
2776
- module.exports = ( client, bucket, key, body, nativeArgs ) =>
2777
- client.send( new PutObjectCommand( {
2778
- ...nativeArgs,
2779
- Bucket: bucket,
2780
- Key: key,
2781
- Body: typeof body === 'string' || Buffer.isBuffer( body ) ? body : JSON.stringify( body )
2782
- } ) );
2661
+ const firstIndexOf = ( c, ...vars ) => Math.min( ...vars.map( v => c.indexOf( v ) ).filter( n => n > -1 ) );
2662
+ const lastIndexOf = ( c, ...vars ) => Math.max( ...vars.map( v => c.lastIndexOf( v ) ) );
2663
+
2664
+ /**
2665
+ * Decompress JSON
2666
+ *
2667
+ * Reads a gzipped tarball (.tar.gz)
2668
+ * 1. Unzip it
2669
+ * 2. Convert all to utf-8
2670
+ * 3. Split files using the \0star separator
2671
+ * 4. Trim files until JSON markup start/end ({})
2672
+ * 5. JSON parse
2673
+ *
2674
+ * Enjoy this 100% native tarball decompression!
2675
+ */
2676
+ module.exports = raw =>
2677
+ unzipSync( raw )
2678
+ .toString( 'utf-8' )
2679
+ .split( '\0ustar' )
2680
+ .slice( 1 )
2681
+ .map( c =>
2682
+ JSON.parse( c.substring( firstIndexOf( c, '{', '[' ), lastIndexOf( c, '}', ']' ) + 1 ) )
2683
+ );
2783
2684
 
2784
2685
 
2785
- /***/ }),
2686
+ /***/ },
2786
2687
 
2787
- /***/ 9760:
2788
- /***/ ((module) => {
2688
+ /***/ 3744
2689
+ (module) {
2789
2690
 
2790
- module.exports = {
2791
- ERROR_500: 'Internal Server Error',
2792
- ERROR_405: 'Method Not Allowed',
2793
- INVALID_ERROR_TYPE: 'Argument "errorType" must be a constructor Function',
2794
- INVALID_FN: 'Argument "fn" must be of type function',
2795
- INVALID_METHOD: 'Argument "method" must be one of the default HTTP methods',
2796
- INVALID_STATUS_CODE: 'Argument "statusCode" must be valid HTTP Status Code',
2797
- INVALID_TRANSFORM_REQUEST: 'Argument "transformRequest" must be either "camelize", "snakelize", false or null',
2798
- INVALID_TRANSFORM_RESPONSE: 'Argument "transformResponse" must be either "camelize", "snakelize", false or null',
2799
- INVALID_MATCHER_ROUTE: 'Argument "route" must be either undefined or an string with length greater than 0',
2800
- INVALID_MATCHER_ROUTE_INCLUDES: 'Argument "routeIncludes" must be either undefined or an string with length greater than 0',
2801
- INVALID_MATCHER_ROUTE_NOT_INCLUDES: 'Argument "routeNotIncludes" must be either undefined or an string with length greater than 0',
2802
- INVALID_MATCHER_ROUTE_MATCH: 'Argument "routeMatch" must be either undefined or type RegExp',
2803
- INVALID_MATCHER_PATH: 'Argument "path" must be either undefined or an string with length greater than 0',
2804
- INVALID_MATCHER_PATH_INCLUDES: 'Argument "pathIncludes" must be either undefined or an string with length greater than 0',
2805
- INVALID_MATCHER_PATH_NOT_INCLUDES: 'Argument "pathNotIncludes" must be either undefined or an string with length greater than 0',
2806
- INVALID_MATCHER_PATH_MATCH: 'Argument "pathMatch" must be either undefined or type RegExp',
2807
- INVALID_USER_RESPONSE: 'Function return must be a number, a string, an array (where p=0 is a number) or an object (where .statusCode is a number)'
2808
- };
2691
+ "use strict";
2692
+ module.exports = require("@aws-sdk/client-athena");
2693
+
2694
+ /***/ },
2695
+
2696
+ /***/ 7493
2697
+ (module) {
2698
+
2699
+ "use strict";
2700
+ module.exports = require("@aws-sdk/client-cloudwatch-logs");
2701
+
2702
+ /***/ },
2703
+
2704
+ /***/ 4671
2705
+ (module) {
2706
+
2707
+ "use strict";
2708
+ module.exports = require("@aws-sdk/client-dynamodb");
2809
2709
 
2710
+ /***/ },
2711
+
2712
+ /***/ 5892
2713
+ (module) {
2714
+
2715
+ "use strict";
2716
+ module.exports = require("@aws-sdk/client-lambda");
2717
+
2718
+ /***/ },
2719
+
2720
+ /***/ 5725
2721
+ (module) {
2722
+
2723
+ "use strict";
2724
+ module.exports = require("@aws-sdk/client-s3");
2725
+
2726
+ /***/ },
2727
+
2728
+ /***/ 9556
2729
+ (module) {
2730
+
2731
+ "use strict";
2732
+ module.exports = require("@aws-sdk/client-sesv2");
2733
+
2734
+ /***/ },
2735
+
2736
+ /***/ 7651
2737
+ (module) {
2738
+
2739
+ "use strict";
2740
+ module.exports = require("@aws-sdk/client-sns");
2741
+
2742
+ /***/ },
2743
+
2744
+ /***/ 1976
2745
+ (module) {
2746
+
2747
+ "use strict";
2748
+ module.exports = require("@aws-sdk/client-sqs");
2749
+
2750
+ /***/ },
2751
+
2752
+ /***/ 4348
2753
+ (module) {
2754
+
2755
+ "use strict";
2756
+ module.exports = require("@aws-sdk/client-ssm");
2757
+
2758
+ /***/ },
2759
+
2760
+ /***/ 1671
2761
+ (module) {
2762
+
2763
+ "use strict";
2764
+ module.exports = require("@aws-sdk/client-timestream-query");
2765
+
2766
+ /***/ },
2767
+
2768
+ /***/ 8248
2769
+ (module) {
2770
+
2771
+ "use strict";
2772
+ module.exports = require("@aws-sdk/client-timestream-write");
2773
+
2774
+ /***/ },
2775
+
2776
+ /***/ 3489
2777
+ (module) {
2778
+
2779
+ "use strict";
2780
+ module.exports = require("@aws-sdk/lib-dynamodb");
2781
+
2782
+ /***/ },
2783
+
2784
+ /***/ 4991
2785
+ (module) {
2786
+
2787
+ "use strict";
2788
+ module.exports = require("@aws-sdk/s3-request-presigner");
2789
+
2790
+ /***/ },
2791
+
2792
+ /***/ 6982
2793
+ (module) {
2794
+
2795
+ "use strict";
2796
+ module.exports = require("crypto");
2797
+
2798
+ /***/ },
2799
+
2800
+ /***/ 5692
2801
+ (module) {
2802
+
2803
+ "use strict";
2804
+ module.exports = require("https");
2805
+
2806
+ /***/ },
2807
+
2808
+ /***/ 3106
2809
+ (module) {
2810
+
2811
+ "use strict";
2812
+ module.exports = require("zlib");
2810
2813
 
2811
- /***/ })
2814
+ /***/ }
2812
2815
 
2813
2816
  /******/ });
2814
2817
  /************************************************************************/