@allthings/cloud-toolkit 2.2.1 → 2.3.0-dev.10
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/dist/lib.cjs.js +662 -2
- package/dist/lib.esm.js +658 -4
- package/dist/lib.umd.min.js +1 -1
- package/dist/src/alagarr/error-handler.d.ts +3 -0
- package/dist/src/alagarr/errors/clientError.d.ts +5 -0
- package/dist/src/alagarr/errors/serverError.d.ts +5 -0
- package/dist/src/alagarr/index.d.ts +6 -0
- package/dist/src/alagarr/index.test.d.ts +1 -0
- package/dist/src/alagarr/request/index.d.ts +4 -0
- package/dist/src/alagarr/request/index.test.d.ts +1 -0
- package/dist/src/alagarr/request/middleware/base64Body.d.ts +3 -0
- package/dist/src/alagarr/request/middleware/base64Body.test.d.ts +1 -0
- package/dist/src/alagarr/request/middleware/cookies.d.ts +6 -0
- package/dist/src/alagarr/request/middleware/cookies.test.d.ts +1 -0
- package/dist/src/alagarr/request/middleware/hostname.d.ts +3 -0
- package/dist/src/alagarr/request/middleware/hostname.test.d.ts +1 -0
- package/dist/src/alagarr/request/middleware/json-body.d.ts +3 -0
- package/dist/src/alagarr/request/middleware/json-body.test.d.ts +1 -0
- package/dist/src/alagarr/request/middleware/meta.d.ts +3 -0
- package/dist/src/alagarr/request/middleware/meta.test.d.ts +1 -0
- package/dist/src/alagarr/request/middleware/normalizeHeaders.d.ts +3 -0
- package/dist/src/alagarr/request/middleware/normalizeHeaders.test.d.ts +1 -0
- package/dist/src/alagarr/request/middleware/normalizeProgrammingModel.d.ts +3 -0
- package/dist/src/alagarr/request/middleware/normalizeProgrammingModel.test.d.ts +1 -0
- package/dist/src/alagarr/request/middleware/timestamp.d.ts +3 -0
- package/dist/src/alagarr/request/middleware/timestamp.test.d.ts +1 -0
- package/dist/src/alagarr/request/middleware/urlEncodedBody.d.ts +3 -0
- package/dist/src/alagarr/request/middleware/urlEncodedBody.test.d.ts +1 -0
- package/dist/src/alagarr/response/helpers/setHeader.d.ts +3 -0
- package/dist/src/alagarr/response/helpers/setHeader.test.d.ts +1 -0
- package/dist/src/alagarr/response/html.d.ts +3 -0
- package/dist/src/alagarr/response/html.test.d.ts +1 -0
- package/dist/src/alagarr/response/index.d.ts +3 -0
- package/dist/src/alagarr/response/index.test.d.ts +1 -0
- package/dist/src/alagarr/response/json.d.ts +3 -0
- package/dist/src/alagarr/response/json.test.d.ts +1 -0
- package/dist/src/alagarr/response/makeResponseObject.d.ts +3 -0
- package/dist/src/alagarr/response/makeResponseObject.test.d.ts +1 -0
- package/dist/src/alagarr/response/middleware/compress.d.ts +3 -0
- package/dist/src/alagarr/response/middleware/compress.test.d.ts +1 -0
- package/dist/src/alagarr/response/middleware/contentLength.d.ts +3 -0
- package/dist/src/alagarr/response/middleware/contentLength.test.d.ts +1 -0
- package/dist/src/alagarr/response/middleware/csp.d.ts +3 -0
- package/dist/src/alagarr/response/middleware/csp.test.d.ts +1 -0
- package/dist/src/alagarr/response/middleware/enforcedHeaders.d.ts +3 -0
- package/dist/src/alagarr/response/middleware/enforcedHeaders.test.d.ts +1 -0
- package/dist/src/alagarr/response/middleware/etag.d.ts +4 -0
- package/dist/src/alagarr/response/middleware/etag.test.d.ts +1 -0
- package/dist/src/alagarr/response/middleware/log.d.ts +4 -0
- package/dist/src/alagarr/response/redirect.d.ts +3 -0
- package/dist/src/alagarr/response/redirect.test.d.ts +1 -0
- package/dist/src/alagarr/response/respondTo.d.ts +3 -0
- package/dist/src/alagarr/response/respondTo.test.d.ts +1 -0
- package/dist/src/alagarr/response/text.d.ts +3 -0
- package/dist/src/alagarr/response/text.test.d.ts +1 -0
- package/dist/src/alagarr/types.d.ts +92 -0
- package/dist/src/alagarr/utils/applyMiddleware.d.ts +3 -0
- package/dist/src/alagarr/utils/applyMiddleware.test.d.ts +1 -0
- package/dist/src/index.d.ts +1 -0
- package/dist/test/fixtures/requests.d.ts +5 -0
- package/package.json +20 -13
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import ClientError from './errors/clientError';
|
|
2
|
+
import ServerError from './errors/serverError';
|
|
3
|
+
import { Alagarr, HandlerFunction, IInterfaceAlagarrOptions, IInterfaceHeaders, IInterfaceQueryParameters, IInterfaceRequest, IInterfaceRequestV2, IInterfaceResponse } from './types';
|
|
4
|
+
export { Alagarr, ClientError, HandlerFunction, IInterfaceAlagarrOptions, IInterfaceHeaders, IInterfaceQueryParameters, IInterfaceRequest, IInterfaceRequestV2, IInterfaceResponse, ServerError, };
|
|
5
|
+
declare const alagarr: (handler?: HandlerFunction, options?: IInterfaceAlagarrOptions) => Alagarr;
|
|
6
|
+
export default alagarr;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { APIGatewayProxyEvent, APIGatewayProxyEventV2, Context } from 'aws-lambda';
|
|
2
|
+
import { IInterfaceAlagarrOptions, IInterfaceRequest } from '../types';
|
|
3
|
+
declare const _default: (event: APIGatewayProxyEvent | APIGatewayProxyEventV2, context: Context, options?: IInterfaceAlagarrOptions) => Promise<IInterfaceRequest>;
|
|
4
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IInterfaceResponseData, IInterfaceResponseOptions } from '../types';
|
|
2
|
+
declare const makeResponseObject: (responseData?: IInterfaceResponseData, body?: string, statusCode?: number, { headers, ...options }?: IInterfaceResponseOptions, contentType?: string) => IInterfaceResponseData;
|
|
3
|
+
export default makeResponseObject;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IInterfaceAlagarrOptions, IInterfaceRequest, IInterfaceResponseData } from '../../types';
|
|
2
|
+
declare const enforcedHeaders: (response: IInterfaceResponseData, _: IInterfaceRequest, options: IInterfaceAlagarrOptions) => IInterfaceResponseData;
|
|
3
|
+
export default enforcedHeaders;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { IInterfaceAlagarrOptions, IInterfaceRequest, IInterfaceResponseData } from '../../types';
|
|
2
|
+
export declare const logger: (request: IInterfaceRequest, response: IInterfaceResponseData) => any;
|
|
3
|
+
declare const logResponse: (response: IInterfaceResponseData, request: IInterfaceRequest, options: IInterfaceAlagarrOptions) => IInterfaceResponseData;
|
|
4
|
+
export default logResponse;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { IInterfaceRequest, IInterfaceRespondToFormat, IInterfaceResponseData, IInterfaceResponseOptions } from '../types';
|
|
2
|
+
declare const respondTo: (responseData: IInterfaceResponseData, request: IInterfaceRequest, formats: IInterfaceRespondToFormat, statusCode?: number, options?: IInterfaceResponseOptions) => IInterfaceResponseData;
|
|
3
|
+
export default respondTo;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { APIGatewayEvent, APIGatewayProxyEventV2, Callback, Context } from 'aws-lambda';
|
|
2
|
+
export type Alagarr = (event: APIGatewayEvent | APIGatewayProxyEventV2, context: Context, callback: Callback) => void;
|
|
3
|
+
export type HandlerFunction = (request: any, response: any, context?: Context) => string | object | void | Promise<string | object | void>;
|
|
4
|
+
export type Logger = (request: any, response: any) => boolean;
|
|
5
|
+
export type ErrorHandler = (request: IInterfaceRequest, response: IInterfaceResponse, error: any) => void;
|
|
6
|
+
export interface IInterfaceAlagarrOptions {
|
|
7
|
+
readonly cspPolicies?: any;
|
|
8
|
+
readonly enableCompression?: boolean;
|
|
9
|
+
readonly enableContentLength?: boolean;
|
|
10
|
+
readonly enableCspHeaders?: boolean;
|
|
11
|
+
readonly enableETagHeader?: boolean;
|
|
12
|
+
readonly enableEnforcedHeaders?: boolean;
|
|
13
|
+
readonly enableLogger?: boolean;
|
|
14
|
+
readonly enableStrictTransportSecurity?: boolean;
|
|
15
|
+
readonly errorHandler?: ErrorHandler;
|
|
16
|
+
readonly headers?: object;
|
|
17
|
+
readonly logger?: Logger;
|
|
18
|
+
readonly requestMiddleware?: any;
|
|
19
|
+
readonly responseMiddleware?: any;
|
|
20
|
+
}
|
|
21
|
+
export interface IIndexSignature {
|
|
22
|
+
readonly [key: string]: any;
|
|
23
|
+
}
|
|
24
|
+
export interface IInterfaceCookie {
|
|
25
|
+
readonly [name: string]: string;
|
|
26
|
+
}
|
|
27
|
+
export interface IInterfaceHeaders {
|
|
28
|
+
readonly [name: string]: string;
|
|
29
|
+
}
|
|
30
|
+
export interface IInterfaceQueryParameters {
|
|
31
|
+
readonly [name: string]: string;
|
|
32
|
+
}
|
|
33
|
+
export interface IInterfaceRequest extends APIGatewayEvent {
|
|
34
|
+
readonly body: any;
|
|
35
|
+
readonly context: Context;
|
|
36
|
+
readonly cookies: IInterfaceCookie;
|
|
37
|
+
readonly headers: IInterfaceHeaders;
|
|
38
|
+
readonly hostname?: string;
|
|
39
|
+
readonly isBase64Encoded: boolean;
|
|
40
|
+
readonly meta: IIndexSignature;
|
|
41
|
+
readonly method: string;
|
|
42
|
+
readonly provider: string;
|
|
43
|
+
readonly query: IInterfaceQueryParameters;
|
|
44
|
+
readonly source: string;
|
|
45
|
+
readonly timestamp: number;
|
|
46
|
+
}
|
|
47
|
+
export interface IInterfaceRequestV2 extends APIGatewayProxyEventV2 {
|
|
48
|
+
readonly body: any;
|
|
49
|
+
readonly context: Context;
|
|
50
|
+
readonly headers: IInterfaceHeaders;
|
|
51
|
+
readonly hostname?: string;
|
|
52
|
+
readonly isBase64Encoded: boolean;
|
|
53
|
+
readonly meta: IIndexSignature;
|
|
54
|
+
readonly method: string;
|
|
55
|
+
readonly provider: string;
|
|
56
|
+
readonly query: IInterfaceQueryParameters;
|
|
57
|
+
readonly source: string;
|
|
58
|
+
readonly timestamp: number;
|
|
59
|
+
}
|
|
60
|
+
export type RequestMiddleware = (request: IInterfaceRequest) => IInterfaceRequest;
|
|
61
|
+
export interface IInterfaceResponseData {
|
|
62
|
+
readonly body: string;
|
|
63
|
+
readonly headers: any;
|
|
64
|
+
readonly isBase64Encoded?: boolean;
|
|
65
|
+
readonly statusCode: number;
|
|
66
|
+
}
|
|
67
|
+
export declare enum EnumDefaultRespondToFormat {
|
|
68
|
+
html = "html",
|
|
69
|
+
json = "json"
|
|
70
|
+
}
|
|
71
|
+
export interface IInterfaceRespondToFormat {
|
|
72
|
+
readonly default?: EnumDefaultRespondToFormat;
|
|
73
|
+
readonly html?: string;
|
|
74
|
+
readonly json?: any;
|
|
75
|
+
}
|
|
76
|
+
export interface IInterfaceResponseOptions {
|
|
77
|
+
readonly headers?: {
|
|
78
|
+
readonly [header: string]: boolean | number | string;
|
|
79
|
+
};
|
|
80
|
+
readonly isBase64Encoded?: boolean;
|
|
81
|
+
}
|
|
82
|
+
export interface IInterfaceResponse {
|
|
83
|
+
readonly html: (html: string, statusCode?: number, options?: IInterfaceResponseOptions) => void;
|
|
84
|
+
readonly json: (json: any, statusCode?: number, options?: IInterfaceResponseOptions) => void;
|
|
85
|
+
readonly raw: (error?: Error | null, result?: object | boolean | number | string) => void;
|
|
86
|
+
readonly redirect: (location: string, statusCode?: number, options?: IInterfaceResponseOptions) => void;
|
|
87
|
+
readonly respondTo: (formats: IInterfaceRespondToFormat, statusCode?: number, options?: IInterfaceResponseOptions) => void;
|
|
88
|
+
readonly setHeader: (key: string, value: string) => IInterfaceResponse;
|
|
89
|
+
readonly text: (text: string, statusCode?: number, options?: IInterfaceResponseOptions) => void;
|
|
90
|
+
}
|
|
91
|
+
export type ResponseHelper = (responseData: IInterfaceResponseData, request: IInterfaceRequest, body: any, statusCode?: number, options?: object) => IInterfaceResponseData;
|
|
92
|
+
export type ResponseMiddleware = (response: IInterfaceResponse, request: IInterfaceRequest) => IInterfaceResponse;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/src/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export { Alagarr, default as alagarr, ClientError, HandlerFunction, IInterfaceAlagarrOptions, IInterfaceHeaders, IInterfaceQueryParameters, IInterfaceRequest, IInterfaceResponse, ServerError, } from './alagarr';
|
|
1
2
|
export { DEFAULT_PARAMETER_STORE_CLIENT_CONFIG, DEFAULT_SES_CLIENT_CONFIG, dynamodb, IDynamoDBConfig, IEmailAttachment, IEmailOptions, ILambda, IParameterStore, ISES, ISQS, IUnprocessedItems, lambda, parameterStore, ses, sqs, TBatchWriteItems, TDeleteItem, TDeleteQueueItem, TGetItem, TGetQueueItems, TGetQueueUrl, TGetSecret, TGetSecrets, TInvokeLambda, TPutItem, TQueryTable, TScanTable, TSendMail, TSendMessage, TUpdateItem, } from './aws';
|
|
2
3
|
export { default as logger } from './logger/logger';
|
|
3
4
|
export { Logger } from 'winston';
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import AWSLambda from 'aws-lambda';
|
|
2
|
+
import { IInterfaceRequest } from '../../src/alagarr';
|
|
3
|
+
export declare const mockContext: AWSLambda.Context;
|
|
4
|
+
export declare const mockRequestContext: AWSLambda.APIGatewayEventRequestContext;
|
|
5
|
+
export declare const get: IInterfaceRequest;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@allthings/cloud-toolkit",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.0-dev.10",
|
|
4
4
|
"description": "",
|
|
5
5
|
"author": "Allthings GmbH",
|
|
6
6
|
"keywords": [
|
|
@@ -50,16 +50,16 @@
|
|
|
50
50
|
"serve": "npx serve -l 3333"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@aws-sdk/client-dynamodb": "3.
|
|
54
|
-
"@aws-sdk/client-lambda": "3.
|
|
55
|
-
"@aws-sdk/client-ses": "3.
|
|
56
|
-
"@aws-sdk/client-sqs": "3.
|
|
57
|
-
"@aws-sdk/client-ssm": "3.
|
|
58
|
-
"@aws-sdk/lib-dynamodb": "3.
|
|
53
|
+
"@aws-sdk/client-dynamodb": "3.799.0",
|
|
54
|
+
"@aws-sdk/client-lambda": "3.799.0",
|
|
55
|
+
"@aws-sdk/client-ses": "3.799.0",
|
|
56
|
+
"@aws-sdk/client-sqs": "3.799.0",
|
|
57
|
+
"@aws-sdk/client-ssm": "3.799.0",
|
|
58
|
+
"@aws-sdk/lib-dynamodb": "3.799.0",
|
|
59
59
|
"bottleneck": "2.19.5",
|
|
60
60
|
"cross-fetch": "4.1.0",
|
|
61
|
-
"nodemailer": "6.10.
|
|
62
|
-
"query-string": "9.1.
|
|
61
|
+
"nodemailer": "6.10.1",
|
|
62
|
+
"query-string": "9.1.2",
|
|
63
63
|
"winston": "3.17.0"
|
|
64
64
|
},
|
|
65
65
|
"devDependencies": {
|
|
@@ -71,20 +71,21 @@
|
|
|
71
71
|
"@rollup/plugin-node-resolve": "16.0.1",
|
|
72
72
|
"@rollup/plugin-replace": "6.0.2",
|
|
73
73
|
"@rollup/plugin-terser": "0.4.4",
|
|
74
|
+
"@types/aws-lambda": "8.10.149",
|
|
74
75
|
"@types/jest": "29.5.14",
|
|
75
|
-
"@types/node": "22.
|
|
76
|
+
"@types/node": "22.15.3",
|
|
76
77
|
"@types/nodemailer": "6.4.17",
|
|
77
78
|
"@types/query-string": "6.3.0",
|
|
78
79
|
"aws-sdk-client-mock": "4.1.0",
|
|
79
80
|
"eslint": "8.57.1",
|
|
80
81
|
"husky": "9.1.7",
|
|
81
82
|
"jest": "29.7.0",
|
|
82
|
-
"lint-staged": "15.5.
|
|
83
|
+
"lint-staged": "15.5.1",
|
|
83
84
|
"prettier": "3.5.3",
|
|
84
85
|
"rimraf": "5.0.10",
|
|
85
|
-
"rollup": "4.
|
|
86
|
+
"rollup": "4.40.1",
|
|
86
87
|
"semantic-release": "19.0.5",
|
|
87
|
-
"ts-jest": "29.3.
|
|
88
|
+
"ts-jest": "29.3.2",
|
|
88
89
|
"typescript": "5.8.3"
|
|
89
90
|
},
|
|
90
91
|
"prettier": {
|
|
@@ -141,6 +142,12 @@
|
|
|
141
142
|
"functions": 89,
|
|
142
143
|
"lines": 90,
|
|
143
144
|
"statements": 89
|
|
145
|
+
},
|
|
146
|
+
"src/alagarr/response/middleware": {
|
|
147
|
+
"branches": 70,
|
|
148
|
+
"functions": 75,
|
|
149
|
+
"lines": 75,
|
|
150
|
+
"statements": 75
|
|
144
151
|
}
|
|
145
152
|
},
|
|
146
153
|
"coveragePathIgnorePatterns": [
|