@allthings/cloud-toolkit 5.0.0-next.1 → 5.1.0-beta.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.
package/README.md CHANGED
@@ -30,7 +30,7 @@ Standardizes the setup of aws, Datadog and other things
30
30
  | batchWriteItems | table<br/>items | Creates multiple item in a defined table |
31
31
  | deleteItem | table<br/>key<br/>options (optional) | Deletes database item from defined table by given key |
32
32
  | getItem | table<br/>key<br/>options (optional) | Returns item from Database by defined table and key |
33
- | putItem | table<br/>key | Creates one item in defined table |
33
+ | putItem | table<br/>item | Creates one item in defined table |
34
34
  | queryTable | table<br/>options (optional) | Returns result items of query |
35
35
  | scanTable | table<br/>options (optional) | Returns result items of scan |
36
36
  | updateItem | table<br/>key<br/>options (optional) | Updates item in database by provided table and given key |
@@ -42,7 +42,7 @@ Standardizes the setup of aws, Datadog and other things
42
42
  | deleteQueueItem | queueUrl<br/>receiptHandle | Deletes item from queue |
43
43
  | getQueueItems | queueUrl<br/>maxNumberOfMessages (optional) | Retrieves items from queue |
44
44
  | getQueueUrl | queueName | Returns queue url which is needed for all other requests |
45
- | sendMessage | queueUrl<br/>message<br/>messageAttributes(optional)<br/>messageDelay(optional) | Creates an item in the queue |
45
+ | sendMessage | queueUrl<br/>message<br/>fifoSettings(optional)<br/>messageAttributes(optional)<br/>messageDelay(optional) | Creates an item in the queue |
46
46
 
47
47
  ### logger
48
48
 
package/dist/lib.cjs.js CHANGED
@@ -703,6 +703,30 @@ const until = async (predicate, transformer, initialValue, iterationCount = 0) =
703
703
  ? transformed
704
704
  : until(predicate, transformer, transformed, iterationCount + 1);
705
705
  };
706
+ const partial = (function_, ...partialArguments) => (...arguments_) => function_(...partialArguments, ...arguments_);
707
+ const times = (function_, n) => Array.from({ length: n }, (_, index) => function_(index, index));
708
+ const deepFlatten = (arrayOfArrays) => arrayOfArrays.reduce((flatArray, currentArray) => [
709
+ ...flatArray,
710
+ ...(Array.isArray(currentArray)
711
+ ?
712
+ currentArray.some(Array.isArray)
713
+ ? deepFlatten(currentArray)
714
+ : currentArray
715
+ : [currentArray]),
716
+ ], []);
717
+ const flatten = (arrayOfArrays, depth = 1) => arrayOfArrays.reduce((flatArray, currentArray) => [
718
+ ...flatArray,
719
+ ...(Array.isArray(currentArray)
720
+ ?
721
+ currentArray.some(Array.isArray) && depth > 1
722
+ ? flatten(currentArray, depth - 1)
723
+ : currentArray
724
+ : [currentArray]),
725
+ ], []);
726
+ const asyncReduce = async (iterable, reducer, initialValue) => iterable.reduce(async (accumulatorPromise, value, index, array) => {
727
+ const accumulator = await accumulatorPromise;
728
+ return reducer(accumulator, value, index, array);
729
+ }, Promise.resolve(initialValue));
706
730
 
707
731
  const DEFAULT_BATCH_ITEMS_MAX_RETRIES = 50;
708
732
  let queue;
@@ -961,6 +985,19 @@ const getSecret = async (ssm, config, parameter_, defaultValue) => {
961
985
  return defaultValue;
962
986
  }
963
987
  };
988
+ const getSecureStringParameter = async (ssm, config, parameter_) => {
989
+ if (config.onlyDefault) {
990
+ throw new Error(`Cannot retrieve parameter ${parameter_}: getSecureStringParameter has no default value, but onlyDefault is enabled`);
991
+ }
992
+ const parameter = await ssm.send(new clientSsm.GetParameterCommand({
993
+ Name: `${config.prefix ?? ''}${parameter_}`,
994
+ WithDecryption: true,
995
+ }));
996
+ if (parameter?.Parameter?.Value === undefined) {
997
+ throw new Error(`Could not retrieve parameter ${parameter_} from AWS SSM parameter store`);
998
+ }
999
+ return parameter.Parameter.Value;
1000
+ };
964
1001
  const parameterStore = (userConfig) => {
965
1002
  const { clientConfig, ...config } = {
966
1003
  ...DEFAULT_CLIENT_CONFIG$1,
@@ -970,6 +1007,7 @@ const parameterStore = (userConfig) => {
970
1007
  return {
971
1008
  getSecret: (parameter, defaultValue = '') => getSecret(ssm, config, parameter, defaultValue),
972
1009
  getSecrets: (parameters, defaultValues = []) => getSecrets(ssm, config, parameters, defaultValues),
1010
+ getSecureStringParameter: (parameter) => getSecureStringParameter(ssm, config, parameter),
973
1011
  };
974
1012
  };
975
1013
 
@@ -1119,6 +1157,9 @@ const sqs = (userConfig) => {
1119
1157
  };
1120
1158
  };
1121
1159
 
1160
+ const btoa = (stringToEncode) => Buffer.from(stringToEncode).toString('base64');
1161
+ const atob = (stringToDecode) => Buffer.from(stringToDecode, 'base64').toString('utf8');
1162
+
1122
1163
  const logger = (config) => {
1123
1164
  const loggerConfig = {
1124
1165
  defaultMeta: {
@@ -1158,9 +1199,18 @@ exports.DEFAULT_PARAMETER_STORE_CLIENT_CONFIG = DEFAULT_CLIENT_CONFIG$1;
1158
1199
  exports.DEFAULT_SES_CLIENT_CONFIG = DEFAULT_CLIENT_CONFIG;
1159
1200
  exports.ServerError = ServerError;
1160
1201
  exports.alagarr = alagarr;
1202
+ exports.asyncReduce = asyncReduce;
1203
+ exports.atob = atob;
1204
+ exports.btoa = btoa;
1205
+ exports.deepFlatten = deepFlatten;
1161
1206
  exports.dynamodb = dynamodb;
1207
+ exports.flatten = flatten;
1162
1208
  exports.lambda = lambda;
1163
1209
  exports.logger = logger;
1164
1210
  exports.parameterStore = parameterStore;
1211
+ exports.partial = partial;
1165
1212
  exports.ses = ses;
1213
+ exports.splitEvery = splitEvery;
1166
1214
  exports.sqs = sqs;
1215
+ exports.times = times;
1216
+ exports.until = until;
package/dist/lib.esm.mjs CHANGED
@@ -7,7 +7,7 @@ import { DynamoDBClient } from '@aws-sdk/client-dynamodb';
7
7
  import { DynamoDBDocumentClient, UpdateCommand, ScanCommand, QueryCommand, PutCommand, GetCommand, DeleteCommand, BatchWriteCommand } from '@aws-sdk/lib-dynamodb';
8
8
  import Bottleneck from 'bottleneck';
9
9
  import { LambdaClient, InvokeCommand } from '@aws-sdk/client-lambda';
10
- import { SSMClient, GetParametersCommand, GetParameterCommand } from '@aws-sdk/client-ssm';
10
+ import { SSMClient, GetParameterCommand, GetParametersCommand } from '@aws-sdk/client-ssm';
11
11
  import { SESv2Client, SendEmailCommand } from '@aws-sdk/client-sesv2';
12
12
  import { createTransport } from 'nodemailer';
13
13
  import { SQSClient, SendMessageCommand, SendMessageBatchCommand, GetQueueUrlCommand, ReceiveMessageCommand, DeleteMessageCommand } from '@aws-sdk/client-sqs';
@@ -681,6 +681,30 @@ const until = async (predicate, transformer, initialValue, iterationCount = 0) =
681
681
  ? transformed
682
682
  : until(predicate, transformer, transformed, iterationCount + 1);
683
683
  };
684
+ const partial = (function_, ...partialArguments) => (...arguments_) => function_(...partialArguments, ...arguments_);
685
+ const times = (function_, n) => Array.from({ length: n }, (_, index) => function_(index, index));
686
+ const deepFlatten = (arrayOfArrays) => arrayOfArrays.reduce((flatArray, currentArray) => [
687
+ ...flatArray,
688
+ ...(Array.isArray(currentArray)
689
+ ?
690
+ currentArray.some(Array.isArray)
691
+ ? deepFlatten(currentArray)
692
+ : currentArray
693
+ : [currentArray]),
694
+ ], []);
695
+ const flatten = (arrayOfArrays, depth = 1) => arrayOfArrays.reduce((flatArray, currentArray) => [
696
+ ...flatArray,
697
+ ...(Array.isArray(currentArray)
698
+ ?
699
+ currentArray.some(Array.isArray) && depth > 1
700
+ ? flatten(currentArray, depth - 1)
701
+ : currentArray
702
+ : [currentArray]),
703
+ ], []);
704
+ const asyncReduce = async (iterable, reducer, initialValue) => iterable.reduce(async (accumulatorPromise, value, index, array) => {
705
+ const accumulator = await accumulatorPromise;
706
+ return reducer(accumulator, value, index, array);
707
+ }, Promise.resolve(initialValue));
684
708
 
685
709
  const DEFAULT_BATCH_ITEMS_MAX_RETRIES = 50;
686
710
  let queue;
@@ -939,6 +963,19 @@ const getSecret = async (ssm, config, parameter_, defaultValue) => {
939
963
  return defaultValue;
940
964
  }
941
965
  };
966
+ const getSecureStringParameter = async (ssm, config, parameter_) => {
967
+ if (config.onlyDefault) {
968
+ throw new Error(`Cannot retrieve parameter ${parameter_}: getSecureStringParameter has no default value, but onlyDefault is enabled`);
969
+ }
970
+ const parameter = await ssm.send(new GetParameterCommand({
971
+ Name: `${config.prefix ?? ''}${parameter_}`,
972
+ WithDecryption: true,
973
+ }));
974
+ if (parameter?.Parameter?.Value === undefined) {
975
+ throw new Error(`Could not retrieve parameter ${parameter_} from AWS SSM parameter store`);
976
+ }
977
+ return parameter.Parameter.Value;
978
+ };
942
979
  const parameterStore = (userConfig) => {
943
980
  const { clientConfig, ...config } = {
944
981
  ...DEFAULT_CLIENT_CONFIG$1,
@@ -948,6 +985,7 @@ const parameterStore = (userConfig) => {
948
985
  return {
949
986
  getSecret: (parameter, defaultValue = '') => getSecret(ssm, config, parameter, defaultValue),
950
987
  getSecrets: (parameters, defaultValues = []) => getSecrets(ssm, config, parameters, defaultValues),
988
+ getSecureStringParameter: (parameter) => getSecureStringParameter(ssm, config, parameter),
951
989
  };
952
990
  };
953
991
 
@@ -1097,6 +1135,9 @@ const sqs = (userConfig) => {
1097
1135
  };
1098
1136
  };
1099
1137
 
1138
+ const btoa = (stringToEncode) => Buffer.from(stringToEncode).toString('base64');
1139
+ const atob = (stringToDecode) => Buffer.from(stringToDecode, 'base64').toString('utf8');
1140
+
1100
1141
  const logger = (config) => {
1101
1142
  const loggerConfig = {
1102
1143
  defaultMeta: {
@@ -1127,4 +1168,4 @@ const logger = (config) => {
1127
1168
  });
1128
1169
  };
1129
1170
 
1130
- export { ClientError, DEFAULT_CLIENT_CONFIG$1 as DEFAULT_PARAMETER_STORE_CLIENT_CONFIG, DEFAULT_CLIENT_CONFIG as DEFAULT_SES_CLIENT_CONFIG, ServerError, alagarr, dynamodb, lambda, logger, parameterStore, ses, sqs };
1171
+ export { ClientError, DEFAULT_CLIENT_CONFIG$1 as DEFAULT_PARAMETER_STORE_CLIENT_CONFIG, DEFAULT_CLIENT_CONFIG as DEFAULT_SES_CLIENT_CONFIG, ServerError, alagarr, asyncReduce, atob, btoa, deepFlatten, dynamodb, flatten, lambda, logger, parameterStore, partial, ses, splitEvery, sqs, times, until };
@@ -1,5 +1,5 @@
1
1
  export { default as dynamodb, IDynamoDBConfig, IDynamoDBInstance, IUnprocessedItems, TBatchWriteItems, TDeleteItem, TGetItem, TPutItem, TQueryTable, TScanTable, TUpdateItem, } from './dynamodb';
2
2
  export { ILambda, ILambdaInstance, default as lambda, TInvokeLambda, } from './lambda';
3
- export { DEFAULT_CLIENT_CONFIG as DEFAULT_PARAMETER_STORE_CLIENT_CONFIG, IParameterStore, IParameterStoreInstance, default as parameterStore, TGetSecret, TGetSecrets, } from './parameterStore';
3
+ export { DEFAULT_CLIENT_CONFIG as DEFAULT_PARAMETER_STORE_CLIENT_CONFIG, IParameterStore, IParameterStoreInstance, default as parameterStore, TGetSecret, TGetSecrets, TGetSecureStringParameter, } from './parameterStore';
4
4
  export { DEFAULT_CLIENT_CONFIG as DEFAULT_SES_CLIENT_CONFIG, IEmailAttachment, IEmailOptions, ISES, ISESInstance, default as ses, TSendMail, } from './ses';
5
5
  export { ISQS, ISQSInstance, default as sqs, TDeleteQueueItem, TGetQueueItems, TGetQueueUrl, TSendMessage, } from './sqs';
@@ -13,10 +13,12 @@ interface IParameter {
13
13
  }
14
14
  export type TGetSecret = (parameter: string, defaultValue?: string) => Promise<string>;
15
15
  export type TGetSecrets = (parameters: string[], defaultValues?: IParameter[]) => Promise<IParameter[]>;
16
+ export type TGetSecureStringParameter = (parameter: string) => Promise<string>;
16
17
  export declare const DEFAULT_CLIENT_CONFIG: IParameterStore;
17
18
  export interface IParameterStoreInstance {
18
19
  getSecret: TGetSecret;
19
20
  getSecrets: TGetSecrets;
21
+ getSecureStringParameter: TGetSecureStringParameter;
20
22
  }
21
23
  declare const parameterStore: (userConfig: IParameterStore) => IParameterStoreInstance;
22
24
  export default parameterStore;
@@ -0,0 +1,2 @@
1
+ export declare const btoa: (stringToEncode: string) => string;
2
+ export declare const atob: (stringToDecode: string) => string;
@@ -1,5 +1,7 @@
1
1
  export { Alagarr, default as alagarr, ClientError, HandlerFunction, IInterfaceAlagarrOptions, IInterfaceHeaders, IInterfaceQueryParameters, IInterfaceRequest, IInterfaceResponse, ServerError, } from './alagarr';
2
- export { DEFAULT_PARAMETER_STORE_CLIENT_CONFIG, DEFAULT_SES_CLIENT_CONFIG, dynamodb, IDynamoDBConfig, IDynamoDBInstance, IEmailAttachment, IEmailOptions, ILambda, ILambdaInstance, IParameterStore, IParameterStoreInstance, ISES, ISESInstance, ISQS, ISQSInstance, IUnprocessedItems, lambda, parameterStore, ses, sqs, TBatchWriteItems, TDeleteItem, TDeleteQueueItem, TGetItem, TGetQueueItems, TGetQueueUrl, TGetSecret, TGetSecrets, TInvokeLambda, TPutItem, TQueryTable, TScanTable, TSendMail, TSendMessage, TUpdateItem, } from './aws';
2
+ export { DEFAULT_PARAMETER_STORE_CLIENT_CONFIG, DEFAULT_SES_CLIENT_CONFIG, dynamodb, IDynamoDBConfig, IDynamoDBInstance, IEmailAttachment, IEmailOptions, ILambda, ILambdaInstance, IParameterStore, IParameterStoreInstance, ISES, ISESInstance, ISQS, ISQSInstance, IUnprocessedItems, lambda, parameterStore, ses, sqs, TBatchWriteItems, TDeleteItem, TDeleteQueueItem, TGetItem, TGetQueueItems, TGetQueueUrl, TGetSecret, TGetSecrets, TGetSecureStringParameter, TInvokeLambda, TPutItem, TQueryTable, TScanTable, TSendMail, TSendMessage, TUpdateItem, } from './aws';
3
+ export { atob, btoa } from './base64';
3
4
  export { default as logger } from './logger/logger';
5
+ export { asyncReduce, deepFlatten, flatten, List, partial, splitEvery, times, until, } from './utils';
4
6
  export type { APIGatewayEvent, APIGatewayProxyEventV2, Context, } from 'aws-lambda';
5
7
  export { Logger } from 'winston';
@@ -1,2 +1,8 @@
1
+ export type List<T> = readonly T[];
1
2
  export declare const splitEvery: <T>(every: number, list: readonly T[]) => T[][];
2
3
  export declare const until: <A, B>(predicate: (value: B, iteration: number) => boolean | Promise<boolean>, transformer: (value: A | B | undefined, iteration: number) => B | Promise<B>, initialValue?: A | B, iterationCount?: number) => Promise<B>;
4
+ export declare const partial: (function_: (...arguments_: any[]) => any | Promise<any>, ...partialArguments: any[]) => (...arguments_: any[]) => any;
5
+ export declare const times: <T>(function_: (item: number, index: number) => T, n: number) => List<T>;
6
+ export declare const deepFlatten: <T>(arrayOfArrays: readonly (readonly T[])[]) => readonly T[];
7
+ export declare const flatten: <T>(arrayOfArrays: readonly (readonly T[])[], depth?: number) => readonly T[];
8
+ export declare const asyncReduce: <I, O>(iterable: List<I>, reducer: (previousValue: O, currentValue: I, currentIndex: number, iterable: List<I>) => Promise<O>, initialValue: O) => Promise<O>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allthings/cloud-toolkit",
3
- "version": "5.0.0-next.1",
3
+ "version": "5.1.0-beta.1",
4
4
  "description": "",
5
5
  "author": "Allthings GmbH",
6
6
  "keywords": [
@@ -17,7 +17,7 @@
17
17
  "node": ">=24",
18
18
  "npm": ">=10"
19
19
  },
20
- "packageManager": "yarn@4.17.1",
20
+ "packageManager": "yarn@4.18.0",
21
21
  "main": "dist/lib.cjs.js",
22
22
  "module": "dist/lib.esm.mjs",
23
23
  "types": "dist/src/index.d.ts",
@@ -76,22 +76,22 @@
76
76
  "winston": "^3.19.0"
77
77
  },
78
78
  "devDependencies": {
79
- "@allthings/eslint-config": "5.1.3",
80
- "@commitlint/cli": "21.2.1",
81
- "@commitlint/config-conventional": "21.2.0",
79
+ "@allthings/eslint-config": "5.2.0",
80
+ "@commitlint/cli": "21.2.2",
81
+ "@commitlint/config-conventional": "21.2.2",
82
82
  "@rollup/plugin-node-resolve": "16.0.3",
83
83
  "@types/node": "24.13.3",
84
84
  "@types/nodemailer": "8.0.1",
85
85
  "@vitest/coverage-v8": "4.1.10",
86
86
  "aws-sdk-client-mock": "4.1.0",
87
87
  "conventional-changelog-conventionalcommits": "9.3.1",
88
- "eslint": "10.7.0",
88
+ "eslint": "10.8.1",
89
89
  "husky": "9.1.7",
90
- "lint-staged": "17.1.0",
91
- "prettier": "3.9.5",
90
+ "lint-staged": "17.3.0",
91
+ "prettier": "3.9.6",
92
92
  "rimraf": "6.1.3",
93
- "rollup": "4.62.2",
94
- "semantic-release": "25.0.8",
93
+ "rollup": "4.62.4",
94
+ "semantic-release": "25.0.9",
95
95
  "typescript": "6.0.3",
96
96
  "vitest": "4.1.10"
97
97
  },