lambda-toolkit 1.1.1 → 2.0.0-dev.1

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