sdk-aws-lambda 0.1.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.
- package/dist/domain.objects/HttpStatusCode.d.ts +28 -0
- package/dist/domain.objects/HttpStatusCode.js +37 -0
- package/dist/domain.objects/HttpStatusCode.js.map +1 -0
- package/dist/domain.objects/LambdaEndpointContext.d.ts +6 -0
- package/dist/domain.objects/LambdaEndpointContext.js +3 -0
- package/dist/domain.objects/LambdaEndpointContext.js.map +1 -0
- package/dist/domain.objects/LambdaEndpointError.d.ts +51 -0
- package/dist/domain.objects/LambdaEndpointError.js +13 -0
- package/dist/domain.objects/LambdaEndpointError.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.d.ts +54 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js +76 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/cache/asCacheWithoutSet.d.ts +11 -0
- package/dist/domain.operations/askLambdaEndpoint/cache/asCacheWithoutSet.js +18 -0
- package/dist/domain.operations/askLambdaEndpoint/cache/asCacheWithoutSet.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/cache/asCachedExecutor.d.ts +18 -0
- package/dist/domain.operations/askLambdaEndpoint/cache/asCachedExecutor.js +31 -0
- package/dist/domain.operations/askLambdaEndpoint/cache/asCachedExecutor.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/cache/getAskLambdaCacheKey.d.ts +10 -0
- package/dist/domain.operations/askLambdaEndpoint/cache/getAskLambdaCacheKey.js +26 -0
- package/dist/domain.operations/askLambdaEndpoint/cache/getAskLambdaCacheKey.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/context/getAccessFromContext.d.ts +11 -0
- package/dist/domain.operations/askLambdaEndpoint/context/getAccessFromContext.js +21 -0
- package/dist/domain.operations/askLambdaEndpoint/context/getAccessFromContext.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/context/getExidFromContext.d.ts +16 -0
- package/dist/domain.operations/askLambdaEndpoint/context/getExidFromContext.js +20 -0
- package/dist/domain.operations/askLambdaEndpoint/context/getExidFromContext.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/context/getLogForExidExtraction.d.ts +27 -0
- package/dist/domain.operations/askLambdaEndpoint/context/getLogForExidExtraction.js +20 -0
- package/dist/domain.operations/askLambdaEndpoint/context/getLogForExidExtraction.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.d.ts +42 -0
- package/dist/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.js +21 -0
- package/dist/domain.operations/askLambdaEndpoint/error/getIsLambdaErrorResponse.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/error/getLambdaErrorMetadata.d.ts +16 -0
- package/dist/domain.operations/askLambdaEndpoint/error/getLambdaErrorMetadata.js +19 -0
- package/dist/domain.operations/askLambdaEndpoint/error/getLambdaErrorMetadata.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/error/getStackTraceString.d.ts +7 -0
- package/dist/domain.operations/askLambdaEndpoint/error/getStackTraceString.js +16 -0
- package/dist/domain.operations/askLambdaEndpoint/error/getStackTraceString.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/error/getStatusCodeHint.d.ts +5 -0
- package/dist/domain.operations/askLambdaEndpoint/error/getStatusCodeHint.js +34 -0
- package/dist/domain.operations/askLambdaEndpoint/error/getStatusCodeHint.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.d.ts +26 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js +60 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/genLambdaClient.d.ts +11 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/genLambdaClient.js +17 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/genLambdaClient.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/sdkLambdaInvoke.d.ts +19 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/sdkLambdaInvoke.js +21 -0
- package/dist/domain.operations/askLambdaEndpoint/invoke/sdkLambdaInvoke.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getDecodedPayload.d.ts +7 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getDecodedPayload.js +12 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getDecodedPayload.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getLambdaFunctionName.d.ts +9 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getLambdaFunctionName.js +12 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getLambdaFunctionName.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getLambdaPayload.d.ts +15 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getLambdaPayload.js +15 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getLambdaPayload.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedJson.d.ts +18 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedJson.js +22 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedJson.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.d.ts +15 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.js +99 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.d.ts +83 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js +99 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getCorsOrigin.d.ts +14 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getCorsOrigin.js +44 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getCorsOrigin.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV1ApiGatewayEvent.d.ts +6 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV1ApiGatewayEvent.js +16 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV1ApiGatewayEvent.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV2ApiGatewayEvent.d.ts +6 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV2ApiGatewayEvent.js +16 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV2ApiGatewayEvent.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.d.ts +32 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.js +90 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.d.ts +11 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js +22 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genZodBodyValidationMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.d.ts +80 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js +59 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.d.ts +11 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js +21 -0
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware.d.ts +23 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware.js +57 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.d.ts +13 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js +56 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genInternalServiceErrorMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.d.ts +16 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.js +44 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.d.ts +12 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js +51 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.d.ts +9 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js +26 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.d.ts +37 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.js +57 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsConstraintError.d.ts +11 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsConstraintError.js +54 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsConstraintError.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsWrappedPayload.d.ts +15 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsWrappedPayload.js +36 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getIsWrappedPayload.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.d.ts +13 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.js +25 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getUnwrappedEventWithExid.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.d.ts +9 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.js +19 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidatedOutput.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.d.ts +13 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js +17 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.d.ts +13 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.js +16 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.js.map +1 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +41 -0
- package/dist/index.js.map +1 -0
- package/license.md +21 -0
- package/package.json +115 -0
- package/readme.md +54 -0
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ConstraintError } from 'helpful-errors';
|
|
2
|
+
import type { ZodError } from 'zod';
|
|
3
|
+
import { type ZodIssueSummary } from './getZodIssuesSummary';
|
|
4
|
+
export interface ValidationErrorMetadata {
|
|
5
|
+
issues: ZodIssueSummary[];
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* .what = transforms zod validation error into ConstraintError
|
|
9
|
+
* .why = clients need friendly error messages for invalid input
|
|
10
|
+
*/
|
|
11
|
+
export declare const getValidationError: (input: {
|
|
12
|
+
error: ZodError;
|
|
13
|
+
}) => ConstraintError<ValidationErrorMetadata>;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getValidationError = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const getZodIssuesSummary_1 = require("./getZodIssuesSummary");
|
|
6
|
+
/**
|
|
7
|
+
* .what = transforms zod validation error into ConstraintError
|
|
8
|
+
* .why = clients need friendly error messages for invalid input
|
|
9
|
+
*/
|
|
10
|
+
const getValidationError = (input) => {
|
|
11
|
+
const issues = (0, getZodIssuesSummary_1.getZodIssuesSummary)({ issues: input.error.issues });
|
|
12
|
+
return new helpful_errors_1.ConstraintError('validation failed', {
|
|
13
|
+
issues,
|
|
14
|
+
});
|
|
15
|
+
};
|
|
16
|
+
exports.getValidationError = getValidationError;
|
|
17
|
+
//# sourceMappingURL=getValidationError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getValidationError.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getValidationError.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAGjD,+DAG+B;AAM/B;;;GAGG;AACI,MAAM,kBAAkB,GAAG,CAAC,KAElC,EAA4C,EAAE;IAC7C,MAAM,MAAM,GAAG,IAAA,yCAAmB,EAAC,EAAE,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IAEnE,OAAO,IAAI,gCAAe,CAA0B,mBAAmB,EAAE;QACvE,MAAM;KACP,CAAC,CAAC;AACL,CAAC,CAAC;AARW,QAAA,kBAAkB,sBAQ7B"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ZodIssue } from 'zod';
|
|
2
|
+
export interface ZodIssueSummary {
|
|
3
|
+
path: string;
|
|
4
|
+
message: string;
|
|
5
|
+
code: string;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* .what = transforms zod issues array into friendly summary format
|
|
9
|
+
* .why = standard zod error format across validation boundaries
|
|
10
|
+
*/
|
|
11
|
+
export declare const getZodIssuesSummary: (input: {
|
|
12
|
+
issues: ZodIssue[];
|
|
13
|
+
}) => ZodIssueSummary[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getZodIssuesSummary = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* .what = transforms zod issues array into friendly summary format
|
|
6
|
+
* .why = standard zod error format across validation boundaries
|
|
7
|
+
*/
|
|
8
|
+
const getZodIssuesSummary = (input) => {
|
|
9
|
+
return input.issues.map((issue) => ({
|
|
10
|
+
path: issue.path.join('.'),
|
|
11
|
+
message: issue.message,
|
|
12
|
+
code: issue.code,
|
|
13
|
+
}));
|
|
14
|
+
};
|
|
15
|
+
exports.getZodIssuesSummary = getZodIssuesSummary;
|
|
16
|
+
//# sourceMappingURL=getZodIssuesSummary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getZodIssuesSummary.js","sourceRoot":"","sources":["../../../../src/domain.operations/genLambdaEndpoint/middleware/getZodIssuesSummary.ts"],"names":[],"mappings":";;;AAQA;;;GAGG;AACI,MAAM,mBAAmB,GAAG,CAAC,KAEnC,EAAqB,EAAE;IACtB,OAAO,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QAClC,IAAI,EAAE,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;QAC1B,OAAO,EAAE,KAAK,CAAC,OAAO;QACtB,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC,CAAC;AACN,CAAC,CAAC;AARW,QAAA,mBAAmB,uBAQ9B"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* sdk-aws-lambda
|
|
3
|
+
*
|
|
4
|
+
* define endpoints, ask endpoints, auto-propagate trace-ids.
|
|
5
|
+
*/
|
|
6
|
+
export { BadRequestError } from 'helpful-errors';
|
|
7
|
+
export { HttpStatusCode } from './domain.objects/HttpStatusCode';
|
|
8
|
+
export { LambdaEndpointError } from './domain.objects/LambdaEndpointError';
|
|
9
|
+
export type { AskLambdaEndpointContext, AskLambdaEndpointInput, } from './domain.operations/askLambdaEndpoint/askLambdaEndpoint';
|
|
10
|
+
export { askLambdaEndpoint } from './domain.operations/askLambdaEndpoint/askLambdaEndpoint';
|
|
11
|
+
export { asCacheWithoutSet } from './domain.operations/askLambdaEndpoint/cache/asCacheWithoutSet';
|
|
12
|
+
export { getAskLambdaCacheKey } from './domain.operations/askLambdaEndpoint/cache/getAskLambdaCacheKey';
|
|
13
|
+
export type { CorsConfig, ForApiGatewayInput, } from './domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway';
|
|
14
|
+
export { forApiGateway } from './domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway';
|
|
15
|
+
export type { UnifiedApiGatewayEvent } from './domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware';
|
|
16
|
+
export { genApiGatewayEventNormalizationMiddleware } from './domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware';
|
|
17
|
+
export type { EndpointOperation, FlatPayload, GenLambdaEndpointContext, GenLambdaEndpointInput, LambdaHandlerInput, WrappedPayload, } from './domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint';
|
|
18
|
+
export { genLambdaEndpoint } from './domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint';
|
|
19
|
+
export { genZodEventValidationMiddleware } from './domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware';
|
|
20
|
+
export { genConstraintErrorMiddleware } from './domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware';
|
|
21
|
+
export type { IoLogTranslate } from './domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware';
|
|
22
|
+
export { genIoLoggerMiddleware } from './domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware';
|
|
23
|
+
export { genTrailMiddleware } from './domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware';
|
|
24
|
+
export { genZodOutputValidationMiddleware } from './domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* sdk-aws-lambda
|
|
4
|
+
*
|
|
5
|
+
* define endpoints, ask endpoints, auto-propagate trace-ids.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.genZodOutputValidationMiddleware = exports.genTrailMiddleware = exports.genIoLoggerMiddleware = exports.genConstraintErrorMiddleware = exports.genZodEventValidationMiddleware = exports.genLambdaEndpoint = exports.genApiGatewayEventNormalizationMiddleware = exports.forApiGateway = exports.getAskLambdaCacheKey = exports.asCacheWithoutSet = exports.askLambdaEndpoint = exports.LambdaEndpointError = exports.HttpStatusCode = exports.BadRequestError = void 0;
|
|
9
|
+
// re-export from helpful-errors for convenience
|
|
10
|
+
var helpful_errors_1 = require("helpful-errors");
|
|
11
|
+
Object.defineProperty(exports, "BadRequestError", { enumerable: true, get: function () { return helpful_errors_1.BadRequestError; } });
|
|
12
|
+
// domain objects
|
|
13
|
+
var HttpStatusCode_1 = require("./domain.objects/HttpStatusCode");
|
|
14
|
+
Object.defineProperty(exports, "HttpStatusCode", { enumerable: true, get: function () { return HttpStatusCode_1.HttpStatusCode; } });
|
|
15
|
+
var LambdaEndpointError_1 = require("./domain.objects/LambdaEndpointError");
|
|
16
|
+
Object.defineProperty(exports, "LambdaEndpointError", { enumerable: true, get: function () { return LambdaEndpointError_1.LambdaEndpointError; } });
|
|
17
|
+
// domain operations
|
|
18
|
+
var askLambdaEndpoint_1 = require("./domain.operations/askLambdaEndpoint/askLambdaEndpoint");
|
|
19
|
+
Object.defineProperty(exports, "askLambdaEndpoint", { enumerable: true, get: function () { return askLambdaEndpoint_1.askLambdaEndpoint; } });
|
|
20
|
+
var asCacheWithoutSet_1 = require("./domain.operations/askLambdaEndpoint/cache/asCacheWithoutSet");
|
|
21
|
+
Object.defineProperty(exports, "asCacheWithoutSet", { enumerable: true, get: function () { return asCacheWithoutSet_1.asCacheWithoutSet; } });
|
|
22
|
+
var getAskLambdaCacheKey_1 = require("./domain.operations/askLambdaEndpoint/cache/getAskLambdaCacheKey");
|
|
23
|
+
Object.defineProperty(exports, "getAskLambdaCacheKey", { enumerable: true, get: function () { return getAskLambdaCacheKey_1.getAskLambdaCacheKey; } });
|
|
24
|
+
var genLambdaEndpoint_forApiGateway_1 = require("./domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway");
|
|
25
|
+
Object.defineProperty(exports, "forApiGateway", { enumerable: true, get: function () { return genLambdaEndpoint_forApiGateway_1.forApiGateway; } });
|
|
26
|
+
var genApiGatewayEventNormalizationMiddleware_1 = require("./domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware");
|
|
27
|
+
Object.defineProperty(exports, "genApiGatewayEventNormalizationMiddleware", { enumerable: true, get: function () { return genApiGatewayEventNormalizationMiddleware_1.genApiGatewayEventNormalizationMiddleware; } });
|
|
28
|
+
var genLambdaEndpoint_forAskEndpoint_1 = require("./domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint");
|
|
29
|
+
Object.defineProperty(exports, "genLambdaEndpoint", { enumerable: true, get: function () { return genLambdaEndpoint_forAskEndpoint_1.genLambdaEndpoint; } });
|
|
30
|
+
var genZodEventValidationMiddleware_1 = require("./domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/middleware/genZodEventValidationMiddleware");
|
|
31
|
+
Object.defineProperty(exports, "genZodEventValidationMiddleware", { enumerable: true, get: function () { return genZodEventValidationMiddleware_1.genZodEventValidationMiddleware; } });
|
|
32
|
+
var genConstraintErrorMiddleware_1 = require("./domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware");
|
|
33
|
+
Object.defineProperty(exports, "genConstraintErrorMiddleware", { enumerable: true, get: function () { return genConstraintErrorMiddleware_1.genConstraintErrorMiddleware; } });
|
|
34
|
+
var genIoLoggerMiddleware_1 = require("./domain.operations/genLambdaEndpoint/middleware/genIoLoggerMiddleware");
|
|
35
|
+
Object.defineProperty(exports, "genIoLoggerMiddleware", { enumerable: true, get: function () { return genIoLoggerMiddleware_1.genIoLoggerMiddleware; } });
|
|
36
|
+
// middleware (for advanced use)
|
|
37
|
+
var genTrailMiddleware_1 = require("./domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware");
|
|
38
|
+
Object.defineProperty(exports, "genTrailMiddleware", { enumerable: true, get: function () { return genTrailMiddleware_1.genTrailMiddleware; } });
|
|
39
|
+
var genZodOutputValidationMiddleware_1 = require("./domain.operations/genLambdaEndpoint/middleware/genZodOutputValidationMiddleware");
|
|
40
|
+
Object.defineProperty(exports, "genZodOutputValidationMiddleware", { enumerable: true, get: function () { return genZodOutputValidationMiddleware_1.genZodOutputValidationMiddleware; } });
|
|
41
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAEH,gDAAgD;AAChD,iDAAiD;AAAxC,iHAAA,eAAe,OAAA;AAExB,iBAAiB;AACjB,kEAAiE;AAAxD,gHAAA,cAAc,OAAA;AACvB,4EAA2E;AAAlE,0HAAA,mBAAmB,OAAA;AAK5B,oBAAoB;AACpB,6FAA4F;AAAnF,sHAAA,iBAAiB,OAAA;AAC1B,mGAAkG;AAAzF,sHAAA,iBAAiB,OAAA;AAC1B,yGAAwG;AAA/F,4HAAA,oBAAoB,OAAA;AAK7B,yJAAsI;AAA7H,gIAAA,aAAa,OAAA;AAEtB,wLAAuL;AAA9K,sKAAA,yCAAyC,OAAA;AASlD,4JAA4I;AAAnI,qIAAA,iBAAiB,OAAA;AAC1B,qKAAoK;AAA3J,kJAAA,+BAA+B,OAAA;AACxC,8HAA6H;AAApH,4IAAA,4BAA4B,OAAA;AAErC,gHAA+G;AAAtG,8HAAA,qBAAqB,OAAA;AAC9B,gCAAgC;AAChC,0GAAyG;AAAhG,wHAAA,kBAAkB,OAAA;AAC3B,sIAAqI;AAA5H,oJAAA,gCAAgC,OAAA"}
|
package/license.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 ehmpathy
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sdk-aws-lambda",
|
|
3
|
+
"author": "ehmpathy",
|
|
4
|
+
"description": "a simple and opinionated sdk for aws lambda. define endpoints, ask endpoints, auto-propagate trace-ids.",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"repository": "ehmpathy/sdk-aws-lambda",
|
|
7
|
+
"homepage": "https://github.com/ehmpathy/sdk-aws-lambda",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"aws",
|
|
10
|
+
"lambda",
|
|
11
|
+
"handler",
|
|
12
|
+
"endpoint",
|
|
13
|
+
"client",
|
|
14
|
+
"invoke",
|
|
15
|
+
"trace",
|
|
16
|
+
"observability"
|
|
17
|
+
],
|
|
18
|
+
"bugs": "https://github.com/ehmpathy/sdk-aws-lambda/issues",
|
|
19
|
+
"license": "MIT",
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=8.0.0"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"/dist"
|
|
26
|
+
],
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@aws-sdk/client-lambda": "3.1045.0",
|
|
29
|
+
"@ehmpathy/error-fns": "^1.3.7",
|
|
30
|
+
"@middy/core": "4.7.0",
|
|
31
|
+
"@middy/http-cors": "4.7.0",
|
|
32
|
+
"@middy/http-json-body-parser": "4.7.0",
|
|
33
|
+
"@middy/http-response-serializer": "4.7.0",
|
|
34
|
+
"@middy/http-security-headers": "4.7.0",
|
|
35
|
+
"domain-objects": "0.31.10",
|
|
36
|
+
"helpful-errors": "1.7.3",
|
|
37
|
+
"sdk-logs": "0.9.0",
|
|
38
|
+
"simple-in-memory-cache": "0.4.0",
|
|
39
|
+
"with-simple-cache": "0.15.3",
|
|
40
|
+
"zod": "4.4.3"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@biomejs/biome": "2.3.8",
|
|
44
|
+
"@commitlint/cli": "19.5.0",
|
|
45
|
+
"@commitlint/config-conventional": "19.5.0",
|
|
46
|
+
"@swc/core": "1.15.3",
|
|
47
|
+
"@swc/jest": "0.2.39",
|
|
48
|
+
"@tsconfig/node20": "20.1.5",
|
|
49
|
+
"@tsconfig/strictest": "2.0.5",
|
|
50
|
+
"@types/archiver": "6.0.3",
|
|
51
|
+
"@types/aws-lambda": "8.10.161",
|
|
52
|
+
"@types/jest": "30.0.0",
|
|
53
|
+
"@types/node": "22.15.21",
|
|
54
|
+
"archiver": "8.0.0",
|
|
55
|
+
"cz-conventional-changelog": "3.3.0",
|
|
56
|
+
"declapract": "^0.13.18",
|
|
57
|
+
"declapract-typescript-ehmpathy": "^0.47.14",
|
|
58
|
+
"declastruct": "1.7.3",
|
|
59
|
+
"declastruct-aws": "^1.5.2",
|
|
60
|
+
"declastruct-github": "1.3.0",
|
|
61
|
+
"depcheck": "1.4.3",
|
|
62
|
+
"esbuild": "0.28.1",
|
|
63
|
+
"esbuild-register": "3.6.0",
|
|
64
|
+
"husky": "8.0.3",
|
|
65
|
+
"jest": "30.2.0",
|
|
66
|
+
"rhachet": "1.41.22",
|
|
67
|
+
"rhachet-brains-anthropic": "^0.4.1",
|
|
68
|
+
"rhachet-brains-fireworksai": "^0.1.2",
|
|
69
|
+
"rhachet-brains-xai": "^0.3.3",
|
|
70
|
+
"rhachet-roles-bhrain": "0.29.8",
|
|
71
|
+
"rhachet-roles-bhuild": "0.21.17",
|
|
72
|
+
"rhachet-roles-ehmpathy": "1.35.16",
|
|
73
|
+
"rhachet-roles-rhachet": "^0.1.7",
|
|
74
|
+
"test-fns": "1.15.8",
|
|
75
|
+
"tsc-alias": "1.8.10",
|
|
76
|
+
"tsx": "4.20.6",
|
|
77
|
+
"typescript": "5.4.5",
|
|
78
|
+
"yalc": "1.0.0-pre.53"
|
|
79
|
+
},
|
|
80
|
+
"config": {
|
|
81
|
+
"commitizen": {
|
|
82
|
+
"path": "./node_modules/cz-conventional-changelog"
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
"scripts": {
|
|
86
|
+
"build:ts": "tsc -p ./tsconfig.build.json",
|
|
87
|
+
"commit:with-cli": "npx cz",
|
|
88
|
+
"fix:format:biome": "biome check --write",
|
|
89
|
+
"fix:format": "npm run fix:format:biome",
|
|
90
|
+
"fix:lint": "biome check --write",
|
|
91
|
+
"fix": "npm run fix:format && npm run fix:lint",
|
|
92
|
+
"build:clean": "chmod -R u+w dist 2>/dev/null; rm -rf dist/",
|
|
93
|
+
"build:compile": "tsc -p ./tsconfig.build.json && tsc-alias -p ./tsconfig.build.json",
|
|
94
|
+
"build": "npm run build:clean && npm run build:compile && npm run build:complete --if-present",
|
|
95
|
+
"test:commits": "LAST_TAG=$(git describe --tags --abbrev=0 @^ 2> /dev/null || git rev-list --max-parents=0 HEAD) && npx commitlint --from $LAST_TAG --to HEAD --verbose",
|
|
96
|
+
"test:types": "tsc -p ./tsconfig.json --noEmit",
|
|
97
|
+
"test:format:biome": "biome format",
|
|
98
|
+
"test:format": "npm run test:format:biome",
|
|
99
|
+
"test:lint:deps": "npx depcheck -c ./.depcheckrc.yml",
|
|
100
|
+
"test:lint:biome": "biome check --diagnostic-level=error",
|
|
101
|
+
"test:lint:biome:all": "biome check",
|
|
102
|
+
"test:lint": "npm run test:lint:biome && npm run test:lint:deps",
|
|
103
|
+
"test:unit": "jest -c ./jest.unit.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
104
|
+
"test:integration": "jest -c ./jest.integration.config.ts --forceExit --verbose --passWithNoTests $([ -z $THOROUGH ] && echo '--changedSince=main') $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
105
|
+
"test:acceptance:locally": "npm run build && LOCALLY=true jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
106
|
+
"test": "npm run test:commits && npm run test:types && npm run test:format && npm run test:lint && npm run test:unit && npm run test:integration && npm run test:acceptance:locally",
|
|
107
|
+
"test:acceptance": "npm run build && jest -c ./jest.acceptance.config.ts --forceExit --verbose --runInBand --passWithNoTests $([ -n $RESNAP ] && echo '--updateSnapshot')",
|
|
108
|
+
"prepush": "npm run test && npm run build",
|
|
109
|
+
"prepublish": "npm run build",
|
|
110
|
+
"preversion": "npm run prepush",
|
|
111
|
+
"postversion": "git push origin HEAD --tags --no-verify",
|
|
112
|
+
"prepare:husky": "husky install && chmod ug+x .husky/*",
|
|
113
|
+
"prepare:rhachet": "rhachet init --hooks --roles mechanic behaver driver architect ergonomist reviewer dreamer dispatcher"
|
|
114
|
+
}
|
|
115
|
+
}
|
package/readme.md
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
# sdk-aws-lambda
|
|
2
|
+
|
|
3
|
+
a simple and opinionated sdk for aws lambda. define endpoints, ask endpoints, auto-propagate trace-ids.
|
|
4
|
+
|
|
5
|
+
# installation
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm install --save sdk-aws-lambda
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
# usage
|
|
12
|
+
|
|
13
|
+
## define an endpoint
|
|
14
|
+
|
|
15
|
+
```ts
|
|
16
|
+
import { genLambdaEndpoint } from 'sdk-aws-lambda';
|
|
17
|
+
|
|
18
|
+
export const handler = genLambdaEndpoint(
|
|
19
|
+
{
|
|
20
|
+
schema,
|
|
21
|
+
invoke: async ({ event }, { log }) => {
|
|
22
|
+
// log has trail context from caller
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{ log }, // optional, auto-generated otherwise
|
|
26
|
+
);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## ask an endpoint
|
|
30
|
+
|
|
31
|
+
```ts
|
|
32
|
+
import { askLambdaEndpoint } from 'sdk-aws-lambda';
|
|
33
|
+
|
|
34
|
+
const result = await askLambdaEndpoint<TRequest, TResponse>(
|
|
35
|
+
{
|
|
36
|
+
which: { service: 'svc-jobs', function: 'getJobByUuid' },
|
|
37
|
+
event: { uuid },
|
|
38
|
+
},
|
|
39
|
+
{ log, env }, // optional, trail auto-extracted and injected into event
|
|
40
|
+
);
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
# features
|
|
44
|
+
|
|
45
|
+
- **genLambdaEndpoint** — define lambda endpoints with validation, log capture, error classification
|
|
46
|
+
- `genLambdaEndpoint()` — direct invoke (default)
|
|
47
|
+
- `.for.apiGateway` — http via api gateway
|
|
48
|
+
- `.for.sqs` — sqs queue consumer
|
|
49
|
+
- **askLambdaEndpoint** — ask another lambda with typed request/response, automatic trail propagation
|
|
50
|
+
- **trace-id propagation** — pass `log` and trail.exid auto-threads through the call chain
|
|
51
|
+
|
|
52
|
+
# docs
|
|
53
|
+
|
|
54
|
+
see [vision](./.behavior/v2026_05_08.rename/1.vision.yield.md) for detailed contracts and design.
|