cdk-nuxt 2.3.0 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +10 -2
  2. package/index.d.ts +1 -0
  3. package/index.js +4 -2
  4. package/lib/functions/access-logs-analysis/group-by-date/build/app/index.js.map +1 -1
  5. package/lib/functions/access-logs-analysis/group-by-date/package.json +7 -6
  6. package/lib/functions/access-logs-analysis/group-by-date/yarn.lock +1117 -1067
  7. package/lib/functions/access-logs-analysis/partitioning/build/app/create-partition.js.map +1 -1
  8. package/lib/functions/access-logs-analysis/partitioning/build/app/transform-partition.js.map +1 -1
  9. package/lib/functions/access-logs-analysis/partitioning/build/app/util.js.map +1 -1
  10. package/lib/functions/access-logs-analysis/partitioning/package.json +7 -6
  11. package/lib/functions/access-logs-analysis/partitioning/yarn.lock +876 -818
  12. package/lib/functions/assets-cleanup/build/app/index.js.map +1 -1
  13. package/lib/functions/assets-cleanup/package.json +7 -6
  14. package/lib/functions/assets-cleanup/yarn.lock +1156 -870
  15. package/lib/stack/NuxtAppStackProps.d.ts +1 -1
  16. package/lib/stack/NuxtAppStackProps.js +1 -1
  17. package/lib/stack/NuxtAppStackProps.ts +1 -1
  18. package/lib/stack/access-logs-analysis/AccessLogsAnalysis.d.ts +3 -3
  19. package/lib/stack/access-logs-analysis/AccessLogsAnalysis.js +1 -1
  20. package/lib/stack/access-logs-analysis/AccessLogsAnalysis.ts +5 -5
  21. package/lib/stack/access-logs-analysis/AccessLogsParquetTable.d.ts +1 -1
  22. package/lib/stack/access-logs-analysis/AccessLogsParquetTable.js +1 -1
  23. package/lib/stack/access-logs-analysis/AccessLogsParquetTable.ts +1 -1
  24. package/lib/stack/access-logs-analysis/AccessLogsTableConfig.d.ts +1 -1
  25. package/lib/stack/access-logs-analysis/AccessLogsTableConfig.js +1 -1
  26. package/lib/stack/access-logs-analysis/AccessLogsTableConfig.ts +1 -1
  27. package/lib/stack/access-logs-analysis/CloudFrontAccessLogsAnalysis.d.ts +3 -3
  28. package/lib/stack/access-logs-analysis/CloudFrontAccessLogsAnalysis.js +1 -1
  29. package/lib/stack/access-logs-analysis/CloudFrontAccessLogsAnalysis.ts +3 -3
  30. package/lib/stack/access-logs-analysis/CloudFrontAccessLogsByDateTable.d.ts +1 -1
  31. package/lib/stack/access-logs-analysis/CloudFrontAccessLogsByDateTable.js +1 -1
  32. package/lib/stack/access-logs-analysis/CloudFrontAccessLogsByDateTable.ts +1 -1
  33. package/lib/stack/server/NuxtServerAppStack.d.ts +1 -1
  34. package/lib/stack/server/NuxtServerAppStack.js +3 -3
  35. package/lib/stack/server/NuxtServerAppStack.ts +8 -8
  36. package/lib/stack/server/NuxtServerAppStackProps.d.ts +1 -1
  37. package/lib/stack/server/NuxtServerAppStackProps.js +1 -1
  38. package/lib/stack/server/NuxtServerAppStackProps.ts +1 -1
  39. package/lib/templates/stack-index-server.ts +7 -2
  40. package/package.json +10 -10
@@ -1 +1 @@
1
- {"version":3,"file":"create-partition.js","sourceRoot":"/","sources":["create-partition.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,8BAA8B;AAC9B,0DAAkE;AAClE,iCAA+C;AAE/C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxC,IAAI,CAAC,SAAS,EAAE;IACd,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;CACrE;AACD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AACtC,IAAI,CAAC,QAAQ,EAAE;IACb,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;CACpE;AACD,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC;AAChC,IAAI,CAAC,KAAK,EAAE;IACV,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;CACjE;AAED,MAAM,eAAe,GAAG,KAAK,IAAI,EAAE;IACjC,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aws-samples/amazon-cloudfront-access-logs-queries/blob/mainline/functions/createPartitions.js.\n */\n// noinspection DuplicatedCode\nimport {StartQueryExecutionCommand} from '@aws-sdk/client-athena';\nimport {executeAndAwaitResponse} from './util';\n\nconst workgroup = process.env.WORKGROUP;\nif (!workgroup) {\n throw new Error('Required environment variable WORKGROUP missing!');\n}\nconst database = process.env.DATABASE;\nif (!database) {\n throw new Error('Required environment variable DATABASE missing!');\n}\nconst table = process.env.TABLE;\nif (!table) {\n throw new Error('Required environment variable TABLE missing!');\n}\n\nconst internalHandler = async () => {\n try {\n const nextHour = new Date(Date.now() + 60 * 60 * 1000);\n const year = nextHour.getUTCFullYear();\n const month = (nextHour.getUTCMonth() + 1).toString().padStart(2, '0');\n const day = nextHour\n .getUTCDate()\n .toString()\n .padStart(2, '0');\n const hour = nextHour\n .getUTCHours()\n .toString()\n .padStart(2, '0');\n\n console.log('creating partition', {year, month, day, hour});\n\n const command = new StartQueryExecutionCommand({\n QueryString: `\n ALTER TABLE ${database}.${table}\n ADD IF NOT EXISTS\n PARTITION (\n year = '${year}',\n month = '${month}',\n day = '${day}',\n hour = '${hour}' );`,\n WorkGroup: workgroup,\n QueryExecutionContext: {Database: database},\n });\n\n await executeAndAwaitResponse(command, true);\n console.log('partition successfully created');\n } catch (error) {\n console.error('### unexpected runtime error ###', error);\n }\n};\n\nexport const handler = internalHandler;\n"]}
1
+ {"version":3,"file":"create-partition.js","sourceRoot":"/","sources":["create-partition.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,8BAA8B;AAC9B,0DAAkE;AAClE,iCAA+C;AAE/C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxC,IAAI,CAAC,SAAS,EAAE,CAAC;IACf,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACtE,CAAC;AACD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AACtC,IAAI,CAAC,QAAQ,EA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,IAAI,CAAC,CAAC;QAC7C,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC,CAAC;AAEW,QAAA,OAAO,GAAG,eAAe,CAAC","sourcesContent":["/**\n * This script creates a partition for the upcoming hour.\n * Taken and adjusted from https://github.com/aws-samples/amazon-cloudfront-access-logs-queries/blob/mainline/functions/createPartitions.js.\n */\n// noinspection DuplicatedCode\nimport {StartQueryExecutionCommand} from '@aws-sdk/client-athena';\nimport {executeAndAwaitResponse} from './util';\n\nconst workgroup = process.env.WORKGROUP;\nif (!workgroup) {\n throw new Error('Required environment variable WORKGROUP missing!');\n}\nconst database = process.env.DATABASE;\nif (!database) {\n throw new Error('Required environment variable DATABASE missing!');\n}\nconst table = process.env.TABLE;\nif (!table) {\n throw new Error('Required environment variable TABLE missing!');\n}\n\nconst internalHandler = async () => {\n try {\n const nextHour = new Date(Date.now() + 60 * 60 * 1000);\n const year = nextHour.getUTCFullYear();\n const month = (nextHour.getUTCMonth() + 1).toString().padStart(2, '0');\n const day = nextHour\n .getUTCDate()\n .toString()\n .padStart(2, '0');\n const hour = nextHour\n .getUTCHours()\n .toString()\n .padStart(2, '0');\n\n console.log('creating partition', {year, month, day, hour});\n\n const command = new StartQueryExecutionCommand({\n QueryString: `\n ALTER TABLE ${database}.${table}\n ADD IF NOT EXISTS\n PARTITION (\n year = '${year}',\n month = '${month}',\n day = '${day}',\n hour = '${hour}' );`,\n WorkGroup: workgroup,\n QueryExecutionContext: {Database: database},\n });\n\n await executeAndAwaitResponse(command, true);\n console.log('partition successfully created');\n } catch (error) {\n console.error('### unexpected runtime error ###', error);\n }\n};\n\nexport const handler = internalHandler;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"transform-partition.js","sourceRoot":"/","sources":["transform-partition.ts"],"names":[],"m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GAAG,CAAC,oCAAoC,EAAE,EAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAC,CAAC,CAAC;SAC7E;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;KAC1D;AACH,CAAC,CAAC;AAEW,QAAA,OAAO,GAAG,eAAe,CAAC","sourcesContent":["/**\n * This script transforms the access log partition of two hours ago into the Apache parquet format.\n * Taken and adjusted from https://github.com/aws-samples/amazon-cloudfront-access-logs-queries/blob/mainline/functions/transformPartition.js.\n */\nimport {StartQueryExecutionCommand} from '@aws-sdk/client-athena';\nimport {executeAndAwaitResponse} from './util';\nimport type {ColumnTransformationRules, TransformPartitionEvent} from './types';\n\nconst workgroup = process.env.WORKGROUP;\nif (!workgroup) {\n throw new Error('Required environment variable WORKGROUP missing!');\n}\nconst database = process.env.DATABASE;\nif (!database) {\n throw new Error('Required environment variable DATABASE missing!');\n}\nconst sourceTable = process.env.SOURCE_TABLE;\nif (!sourceTable) {\n throw new Error('Required environment variable SOURCE_TABLE missing!');\n}\nconst targetTable = process.env.TARGET_TABLE;\nif (!targetTable) {\n throw new Error('Required environment variable TARGET_TABLE missing!');\n}\n\n/**\n * Reducer, that computes the column statements for the insert command. Columns are either selected by their name, or\n * are computed by an expression specified in `columnTransformations`.\n */\nconst buildQueryColumns = (\n columnTransformations: ColumnTransformationRules,\n previous: string,\n current: string\n): string => {\n const columnExpression = Object.keys(columnTransformations).includes(current)\n ? `${columnTransformations[current]} AS ${current}`\n : current;\n return previous.length === 0 ? columnExpression : `${previous}, ${columnExpression}`;\n};\n\n/**\n * Entrypoint\n */\nconst internalHandler = async (event: TransformPartitionEvent) => {\n try {\n const partitionHour = new Date(Date.now() - 120 * 60 * 1000);\n const year = partitionHour.getUTCFullYear();\n const month = (partitionHour.getUTCMonth() + 1).toString().padStart(2, '0');\n const day = partitionHour.getUTCDate().toString().padStart(2, '0');\n const hour = partitionHour.getUTCHours().toString().padStart(2, '0');\n\n console.log('transforming partition', {year, month, day, hour});\n\n // apply transformations on certain columns:\n // - obfuscate IPs\n // - optionally filter cookies\n const selectExpr = event.columnNames.reduce(\n (previous, current) => buildQueryColumns(event.columnTransformations, previous, current),\n ''\n );\n\n const command = new StartQueryExecutionCommand({\n QueryString: `\n INSERT INTO ${database}.${targetTable} (${event.columnNames.join(',')})\n SELECT ${selectExpr}\n FROM ${database}.${sourceTable}\n WHERE year = '${year}'\n AND month = '${month}'\n AND day = '${day}'\n AND hour = '${hour}';`,\n WorkGroup: workgroup,\n QueryExecutionContext: {Database: database},\n });\n\n if (await executeAndAwaitResponse(command, false)) {\n console.log('successfully transformed partition', {year, month, day, hour});\n }\n } catch (error) {\n console.error('### unexpected runtime error ###', error);\n }\n};\n\nexport const handler = internalHandler;\n"]}
1
+ {"version":3,"file":"transform-partition.js","sourceRoot":"/","sources":["transform-partition.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,0DAAkE;AAClE,iCAA+C;AAG/C,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACxC,IAAI,CAAC,SAAS,EAAE,CAAC;IACf,MAAM,IAAI,KAAK,CAAC,kDAAkD,CAAC,CAAC;AACtE,CAAC;AACD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AACtC,IAAI,CAAC,QAAQ,EAAE,CAAC;IACd,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;AACrE,CAAC;AACD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAC7C,IAAI,CAAC,WAAW,EAAE,CAAC;IACjB,MAAM,IAAI,KAAK,CAAC,qDAAqD,CAAC,CAAC;AACzE,CAAC;AACD,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAC7C,IAAI,CAAC,WAAW,EAAE,CAAC;IACjB,MAAM,IAAI,KAAK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C,kBAAkB;QAClB,8BAA8B;QAC9B,MAAM,UAAU,GAAG,KAAK,CAAC,WAAW,CAAC,MAAM,CACzC,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,CAAC,qBAAqB,EAAE,QAAQ,EAAE,OAAO,CAAC,EACxF,EAAE,CACH,CAAC;QAEF,MAAM,OAAO,GAAG,IAAI,0CAA0B,CAAC;YAC7C,WAAW,EAAE;sBACG,QAAQ,IAAI,WAAW,KAAK,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC;iBAC5D,UAAU;eACZ,QAAQ,IAAI,WAAW;wBACd,IAAI;yBACH,KAAK;uBACP,GAAG;wBACF,IAAI,IAAI;YAC1B,SAAS,EAAE,SAAS;YACpB,qBAAqB,EAAE,EAAC,QAAQ,EAAE,QAAQ,EAAC;SAC5C,CAAC,CAAC;QAEH,IAAI,MAAM,IAAA,8BAAuB,EAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC;YAClD,OAAO,CAAC,GAAG,CAAC,oCAAoC,EAAE,EAAC,IAAI,EAAE,KAAK,EAAE,GAAG,EAAE,IAAI,EAAC,CAAC,CAAC;QAC9E,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,kCAAkC,EAAE,KAAK,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC,CAAC;AAEW,QAAA,OAAO,GAAG,eAAe,CAAC","sourcesContent":["/**\n * This script transforms the access log partition of two hours ago into the Apache parquet format.\n * Taken and adjusted from https://github.com/aws-samples/amazon-cloudfront-access-logs-queries/blob/mainline/functions/transformPartition.js.\n */\nimport {StartQueryExecutionCommand} from '@aws-sdk/client-athena';\nimport {executeAndAwaitResponse} from './util';\nimport type {ColumnTransformationRules, TransformPartitionEvent} from './types';\n\nconst workgroup = process.env.WORKGROUP;\nif (!workgroup) {\n throw new Error('Required environment variable WORKGROUP missing!');\n}\nconst database = process.env.DATABASE;\nif (!database) {\n throw new Error('Required environment variable DATABASE missing!');\n}\nconst sourceTable = process.env.SOURCE_TABLE;\nif (!sourceTable) {\n throw new Error('Required environment variable SOURCE_TABLE missing!');\n}\nconst targetTable = process.env.TARGET_TABLE;\nif (!targetTable) {\n throw new Error('Required environment variable TARGET_TABLE missing!');\n}\n\n/**\n * Reducer, that computes the column statements for the insert command. Columns are either selected by their name, or\n * are computed by an expression specified in `columnTransformations`.\n */\nconst buildQueryColumns = (\n columnTransformations: ColumnTransformationRules,\n previous: string,\n current: string\n): string => {\n const columnExpression = Object.keys(columnTransformations).includes(current)\n ? `${columnTransformations[current]} AS ${current}`\n : current;\n return previous.length === 0 ? columnExpression : `${previous}, ${columnExpression}`;\n};\n\n/**\n * Entrypoint\n */\nconst internalHandler = async (event: TransformPartitionEvent) => {\n try {\n const partitionHour = new Date(Date.now() - 120 * 60 * 1000);\n const year = partitionHour.getUTCFullYear();\n const month = (partitionHour.getUTCMonth() + 1).toString().padStart(2, '0');\n const day = partitionHour.getUTCDate().toString().padStart(2, '0');\n const hour = partitionHour.getUTCHours().toString().padStart(2, '0');\n\n console.log('transforming partition', {year, month, day, hour});\n\n // apply transformations on certain columns:\n // - obfuscate IPs\n // - optionally filter cookies\n const selectExpr = event.columnNames.reduce(\n (previous, current) => buildQueryColumns(event.columnTransformations, previous, current),\n ''\n );\n\n const command = new StartQueryExecutionCommand({\n QueryString: `\n INSERT INTO ${database}.${targetTable} (${event.columnNames.join(',')})\n SELECT ${selectExpr}\n FROM ${database}.${sourceTable}\n WHERE year = '${year}'\n AND month = '${month}'\n AND day = '${day}'\n AND hour = '${hour}';`,\n WorkGroup: workgroup,\n QueryExecutionContext: {Database: database},\n });\n\n if (await executeAndAwaitResponse(command, false)) {\n console.log('successfully transformed partition', {year, month, day, hour});\n }\n } catch (error) {\n console.error('### unexpected runtime error ###', error);\n }\n};\n\nexport const handler = internalHandler;\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceR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CAAC,CAAC;KAC/B;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC;KAC7B;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AArCW,QAAA,uBAAuB,2BAqClC","sourcesContent":["import {\n AthenaClient,\n GetQueryExecutionCommand,\n QueryExecutionState,\n StartQueryExecutionCommand,\n} from '@aws-sdk/client-athena';\n\n/**\n * Executes the given command and waits up to 10s for the command to complete.\n * @param failOnTimeout <code>true</code> in order to throw an exception,\n * or <code>false</code> to just log the error to the console\n * @return <code>true</code> on success or <code>false</code> if the command timed out and\n * <code>failOnTimeout</code> was set to false\n */\nexport const executeAndAwaitResponse = async (\n command: StartQueryExecutionCommand,\n failOnTimeout: boolean\n): Promise<boolean> => {\n console.log('executing command ', command.input.QueryString, '...');\n\n const athena = new AthenaClient({});\n const response = await athena.send(command);\n\n // wait up to 10s for completion\n const checkStatus = new GetQueryExecutionCommand({\n QueryExecutionId: response.QueryExecutionId,\n });\n\n for (let i = 1; i <= 50; i++) {\n const state = await athena.send(checkStatus);\n switch (state.QueryExecution!.Status!.State) {\n case QueryExecutionState.SUCCEEDED:\n console.log('command completed successfully');\n return true;\n case QueryExecutionState.CANCELLED:\n case QueryExecutionState.FAILED:\n // noinspection TypeScriptUnresolvedFunction\n throw new Error('Command execution failed! Query:\\n' + command.input.QueryString);\n }\n\n await new Promise(resolve => setTimeout(resolve, 200));\n }\n\n const errorMessage = 'Status of partition creation unknown - waited for 10s but command did not complete';\n if (failOnTimeout) {\n // noinspection TypeScriptUnresolvedFunction\n throw new Error(errorMessage);\n } else {\n console.error(errorMessage);\n }\n return false;\n};\n"]}
1
+ {"version":3,"file":"util.js","sourceRoot":"/","sources":["util.ts"],"names":[],"mappings":";;;AAAA,0DAKgC;AAEhC;;;;;;GAMG;AACI,MAAM,uBAAuB,GAAG,KAAK,EAC1C,OAAmC,EACnC,aAAsB,EACJ,EAAE;IACpB,OAAO,CAAC,GAAG,CAAC,oBAAoB,EAA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AuB,2BAqClC","sourcesContent":["import {\n AthenaClient,\n GetQueryExecutionCommand,\n QueryExecutionState,\n StartQueryExecutionCommand,\n} from '@aws-sdk/client-athena';\n\n/**\n * Executes the given command and waits up to 10s for the command to complete.\n * @param failOnTimeout <code>true</code> in order to throw an exception,\n * or <code>false</code> to just log the error to the console\n * @return <code>true</code> on success or <code>false</code> if the command timed out and\n * <code>failOnTimeout</code> was set to false\n */\nexport const executeAndAwaitResponse = async (\n command: StartQueryExecutionCommand,\n failOnTimeout: boolean\n): Promise<boolean> => {\n console.log('executing command ', command.input.QueryString, '...');\n\n const athena = new AthenaClient({});\n const response = await athena.send(command);\n\n // wait up to 10s for completion\n const checkStatus = new GetQueryExecutionCommand({\n QueryExecutionId: response.QueryExecutionId,\n });\n\n for (let i = 1; i <= 50; i++) {\n const state = await athena.send(checkStatus);\n switch (state.QueryExecution!.Status!.State) {\n case QueryExecutionState.SUCCEEDED:\n console.log('command completed successfully');\n return true;\n case QueryExecutionState.CANCELLED:\n case QueryExecutionState.FAILED:\n // noinspection TypeScriptUnresolvedFunction\n throw new Error('Command execution failed! Query:\\n' + command.input.QueryString);\n }\n\n await new Promise(resolve => setTimeout(resolve, 200));\n }\n\n const errorMessage = 'Status of partition creation unknown - waited for 10s but command did not complete';\n if (failOnTimeout) {\n // noinspection TypeScriptUnresolvedFunction\n throw new Error(errorMessage);\n } else {\n console.error(errorMessage);\n }\n return false;\n};\n"]}
@@ -9,12 +9,13 @@
9
9
  "build": "tsc --project ./tsconfig.json"
10
10
  },
11
11
  "devDependencies": {
12
- "@types/aws-lambda": "^8.10.101",
13
- "@types/node": "^16.11.0",
14
- "ts-node": "^10.9.1",
15
- "typescript": "^4.7.4"
12
+ "@aws-sdk/client-athena": "^3.687.0",
13
+ "@types/aws-lambda": "^8.10.145",
14
+ "@types/node": "^20.10",
15
+ "ts-node": "^10.9.2",
16
+ "typescript": "^5.6.3"
16
17
  },
17
- "dependencies": {
18
- "@aws-sdk/client-athena": "^3.131.0"
18
+ "peerDependencies": {
19
+ "@aws-sdk/client-athena": "^3"
19
20
  }
20
21
  }