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