sdk-aws-lambda 0.1.0 → 0.2.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.operations/askLambdaEndpoint/invoke/genLambdaClient.d.ts → access/sdks/lambda/genLambdaSdk.d.ts} +2 -2
- package/dist/{domain.operations/askLambdaEndpoint/invoke/genLambdaClient.js → access/sdks/lambda/genLambdaSdk.js} +7 -7
- package/dist/access/sdks/lambda/genLambdaSdk.js.map +1 -0
- package/dist/{domain.operations/askLambdaEndpoint/invoke → access/sdks/lambda}/sdkLambdaInvoke.d.ts +6 -2
- package/dist/{domain.operations/askLambdaEndpoint/invoke → access/sdks/lambda}/sdkLambdaInvoke.js +6 -3
- package/dist/access/sdks/lambda/sdkLambdaInvoke.js.map +1 -0
- package/dist/domain.objects/ContextAwsLambdaCaller.d.ts +25 -0
- package/dist/domain.objects/ContextAwsLambdaCaller.js +3 -0
- package/dist/domain.objects/ContextAwsLambdaCaller.js.map +1 -0
- package/dist/domain.objects/ContextAwsLambdaServer.d.ts +30 -0
- package/dist/domain.objects/ContextAwsLambdaServer.js +3 -0
- package/dist/domain.objects/ContextAwsLambdaServer.js.map +1 -0
- package/dist/domain.objects/HttpStatusCode.d.ts +2 -2
- package/dist/domain.objects/HttpStatusCode.js +3 -3
- package/dist/domain.objects/LambdaEndpoint.d.ts +35 -0
- package/dist/domain.objects/LambdaEndpoint.js +10 -0
- package/dist/domain.objects/LambdaEndpoint.js.map +1 -0
- package/dist/domain.objects/LambdaEndpointError.d.ts +5 -8
- package/dist/domain.objects/LambdaEndpointError.js.map +1 -1
- package/dist/domain.objects/LambdaEndpointSchema.d.ts +9 -0
- package/dist/domain.objects/LambdaEndpointSchema.js +3 -0
- package/dist/domain.objects/LambdaEndpointSchema.js.map +1 -0
- package/dist/domain.objects/LambdaFunctionNotFoundError.d.ts +10 -0
- package/dist/domain.objects/LambdaFunctionNotFoundError.js +15 -0
- package/dist/domain.objects/LambdaFunctionNotFoundError.js.map +1 -0
- package/dist/domain.objects/LambdaIntrospectionBlockedError.d.ts +10 -0
- package/dist/domain.objects/LambdaIntrospectionBlockedError.js +15 -0
- package/dist/domain.objects/LambdaIntrospectionBlockedError.js.map +1 -0
- package/dist/domain.objects/LambdaIntrospectionNotSupportedError.d.ts +18 -0
- package/dist/domain.objects/LambdaIntrospectionNotSupportedError.js +15 -0
- package/dist/domain.objects/LambdaIntrospectionNotSupportedError.js.map +1 -0
- package/dist/domain.objects/LambdaServiceNotFoundError.d.ts +10 -0
- package/dist/domain.objects/LambdaServiceNotFoundError.js +15 -0
- package/dist/domain.objects/LambdaServiceNotFoundError.js.map +1 -0
- package/dist/domain.operations/asLambdaEndpoint/asLambdaEndpoint.d.ts +20 -0
- package/dist/domain.operations/asLambdaEndpoint/asLambdaEndpoint.js +47 -0
- package/dist/domain.operations/asLambdaEndpoint/asLambdaEndpoint.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.d.ts +2 -12
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js +13 -22
- package/dist/domain.operations/askLambdaEndpoint/askLambdaEndpoint.js.map +1 -1
- package/dist/domain.operations/askLambdaEndpoint/cache/asCachedExecutor.d.ts +2 -2
- package/dist/domain.operations/askLambdaEndpoint/cache/asCachedExecutor.js.map +1 -1
- package/dist/domain.operations/askLambdaEndpoint/cache/getAskLambdaCacheKey.d.ts +3 -4
- package/dist/domain.operations/askLambdaEndpoint/cache/getAskLambdaCacheKey.js +17 -5
- package/dist/domain.operations/askLambdaEndpoint/cache/getAskLambdaCacheKey.js.map +1 -1
- package/dist/domain.operations/askLambdaEndpoint/error/getStatusCodeHint.d.ts +1 -1
- package/dist/domain.operations/askLambdaEndpoint/error/getStatusCodeHint.js +3 -3
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.d.ts +13 -8
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js +20 -19
- package/dist/domain.operations/askLambdaEndpoint/invoke/executeLambdaInvocation.js.map +1 -1
- package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.d.ts +13 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.js +26 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/asUnprefixedErrorMessage.js.map +1 -0
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.d.ts +2 -2
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.js +15 -14
- package/dist/domain.operations/askLambdaEndpoint/serde/getParsedResponse.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.d.ts +15 -8
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js +16 -9
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/genLambdaEndpoint.forApiGateway.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getCorsOrigin.d.ts +3 -3
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getCorsOrigin.js +5 -5
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV2ApiGatewayEvent.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/getIsV2ApiGatewayEvent.js +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.js +88 -63
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forApiGateway/middleware/genApiGatewayEventNormalizationMiddleware.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.d.ts +7 -9
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js +14 -11
- package/dist/domain.operations/genLambdaEndpoint/genLambdaEndpoint.forAskEndpoint/genLambdaEndpoint.forAskEndpoint.js.map +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genConstraintErrorMiddleware.js +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.d.ts +22 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.d.ts +7 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.js +13 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.getJsonSchemaFromZod.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionPayload.d.ts +5 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionPayload.js +16 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.isIntrospectionPayload.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.js +53 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genIntrospectionMiddleware.js.map +1 -0
- package/dist/domain.operations/genLambdaEndpoint/middleware/genTrailMiddleware.js +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getErrorResponseBody.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.d.ts +1 -1
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js +12 -4
- package/dist/domain.operations/genLambdaEndpoint/middleware/getValidationError.js.map +1 -1
- package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.d.ts +33 -0
- package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.js +89 -0
- package/dist/domain.operations/getAllLambdaContracts/getAllLambdaContracts.js.map +1 -0
- package/dist/domain.operations/getAllLambdaContracts/lambdaContract/asContractRecord.d.ts +6 -0
- package/dist/domain.operations/getAllLambdaContracts/lambdaContract/asContractRecord.js +12 -0
- package/dist/domain.operations/getAllLambdaContracts/lambdaContract/asContractRecord.js.map +1 -0
- package/dist/domain.operations/getAllLambdaContracts/lambdaFunction/getAllLambdaFunctionsByPrefix.d.ts +15 -0
- package/dist/domain.operations/getAllLambdaContracts/lambdaFunction/getAllLambdaFunctionsByPrefix.js +44 -0
- package/dist/domain.operations/getAllLambdaContracts/lambdaFunction/getAllLambdaFunctionsByPrefix.js.map +1 -0
- package/dist/domain.operations/getAllLambdaContracts/lambdaFunction/sdkLambdaGetAllFunctions.d.ts +16 -0
- package/dist/domain.operations/getAllLambdaContracts/lambdaFunction/sdkLambdaGetAllFunctions.js +26 -0
- package/dist/domain.operations/getAllLambdaContracts/lambdaFunction/sdkLambdaGetAllFunctions.js.map +1 -0
- package/dist/domain.operations/getOneLambdaContract/asLambdaEndpointSchema.d.ts +16 -0
- package/dist/domain.operations/getOneLambdaContract/asLambdaEndpointSchema.js +76 -0
- package/dist/domain.operations/getOneLambdaContract/asLambdaEndpointSchema.js.map +1 -0
- package/dist/domain.operations/getOneLambdaContract/getOneLambdaContract.d.ts +32 -0
- package/dist/domain.operations/getOneLambdaContract/getOneLambdaContract.js +112 -0
- package/dist/domain.operations/getOneLambdaContract/getOneLambdaContract.js.map +1 -0
- package/dist/index.d.ts +14 -1
- package/dist/index.js +24 -2
- package/dist/index.js.map +1 -1
- package/package.json +45 -41
- package/readme.md +64 -4
- package/dist/domain.operations/askLambdaEndpoint/context/getAccessFromContext.d.ts +0 -11
- package/dist/domain.operations/askLambdaEndpoint/context/getAccessFromContext.js +0 -21
- package/dist/domain.operations/askLambdaEndpoint/context/getAccessFromContext.js.map +0 -1
- package/dist/domain.operations/askLambdaEndpoint/invoke/genLambdaClient.js.map +0 -1
- package/dist/domain.operations/askLambdaEndpoint/invoke/sdkLambdaInvoke.js.map +0 -1
- package/dist/domain.operations/askLambdaEndpoint/serde/getLambdaFunctionName.d.ts +0 -9
- package/dist/domain.operations/askLambdaEndpoint/serde/getLambdaFunctionName.js +0 -12
- package/dist/domain.operations/askLambdaEndpoint/serde/getLambdaFunctionName.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { LambdaClient } from '@aws-sdk/client-lambda';
|
|
2
2
|
/**
|
|
3
|
-
* .what = returns the injected
|
|
3
|
+
* .what = returns the injected LambdaClient or creates a new one
|
|
4
4
|
* .why = named transformer for clear narrative in orchestrator
|
|
5
5
|
*/
|
|
6
|
-
export declare const
|
|
6
|
+
export declare const genLambdaSdk: (input: {
|
|
7
7
|
sdk?: LambdaClient;
|
|
8
8
|
env?: {
|
|
9
9
|
region?: string;
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.genLambdaSdk = void 0;
|
|
4
4
|
const client_lambda_1 = require("@aws-sdk/client-lambda");
|
|
5
5
|
/**
|
|
6
|
-
* .what = returns the injected
|
|
6
|
+
* .what = returns the injected LambdaClient or creates a new one
|
|
7
7
|
* .why = named transformer for clear narrative in orchestrator
|
|
8
8
|
*/
|
|
9
|
-
const
|
|
10
|
-
// return injected
|
|
9
|
+
const genLambdaSdk = (input) => {
|
|
10
|
+
// return injected LambdaClient if provided
|
|
11
11
|
if (input.sdk)
|
|
12
12
|
return input.sdk;
|
|
13
|
-
// create
|
|
13
|
+
// create LambdaClient, let sdk infer region unless explicitly provided
|
|
14
14
|
return new client_lambda_1.LambdaClient(input.env?.region ? { region: input.env.region } : {});
|
|
15
15
|
};
|
|
16
|
-
exports.
|
|
17
|
-
//# sourceMappingURL=
|
|
16
|
+
exports.genLambdaSdk = genLambdaSdk;
|
|
17
|
+
//# sourceMappingURL=genLambdaSdk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"genLambdaSdk.js","sourceRoot":"","sources":["../../../../src/access/sdks/lambda/genLambdaSdk.ts"],"names":[],"mappings":";;;AAAA,0DAAsD;AAEtD;;;GAGG;AACI,MAAM,YAAY,GAAG,CAAC,KAG5B,EAAgB,EAAE;IACjB,2CAA2C;IAC3C,IAAI,KAAK,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IAEhC,uEAAuE;IACvE,OAAO,IAAI,4BAAY,CACrB,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,GAAG,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CACtD,CAAC;AACJ,CAAC,CAAC;AAXW,QAAA,YAAY,gBAWvB"}
|
package/dist/{domain.operations/askLambdaEndpoint/invoke → access/sdks/lambda}/sdkLambdaInvoke.d.ts
RENAMED
|
@@ -11,9 +11,13 @@ export interface LambdaInvokeResponse {
|
|
|
11
11
|
/**
|
|
12
12
|
* .what = invoke a lambda function via aws sdk
|
|
13
13
|
* .why = communicator encapsulates raw aws sdk i/o at boundary
|
|
14
|
+
*
|
|
15
|
+
* .note = input.slug is the endpoint slug = the aws function name (wire id);
|
|
16
|
+
* sdkLambda (the client dependency) is injected via context
|
|
14
17
|
*/
|
|
15
18
|
export declare const sdkLambdaInvoke: (input: {
|
|
16
|
-
|
|
17
|
-
functionName: string;
|
|
19
|
+
slug: string;
|
|
18
20
|
payload: unknown;
|
|
21
|
+
}, context: {
|
|
22
|
+
sdkLambda: LambdaClient;
|
|
19
23
|
}) => Promise<LambdaInvokeResponse>;
|
package/dist/{domain.operations/askLambdaEndpoint/invoke → access/sdks/lambda}/sdkLambdaInvoke.js
RENAMED
|
@@ -5,10 +5,13 @@ const client_lambda_1 = require("@aws-sdk/client-lambda");
|
|
|
5
5
|
/**
|
|
6
6
|
* .what = invoke a lambda function via aws sdk
|
|
7
7
|
* .why = communicator encapsulates raw aws sdk i/o at boundary
|
|
8
|
+
*
|
|
9
|
+
* .note = input.slug is the endpoint slug = the aws function name (wire id);
|
|
10
|
+
* sdkLambda (the client dependency) is injected via context
|
|
8
11
|
*/
|
|
9
|
-
const sdkLambdaInvoke = async (input) => {
|
|
10
|
-
const result = await
|
|
11
|
-
FunctionName: input.
|
|
12
|
+
const sdkLambdaInvoke = async (input, context) => {
|
|
13
|
+
const result = await context.sdkLambda.send(new client_lambda_1.InvokeCommand({
|
|
14
|
+
FunctionName: input.slug,
|
|
12
15
|
Payload: Buffer.from(JSON.stringify(input.payload)),
|
|
13
16
|
}));
|
|
14
17
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sdkLambdaInvoke.js","sourceRoot":"","sources":["../../../../src/access/sdks/lambda/sdkLambdaInvoke.ts"],"names":[],"mappings":";;;AAAA,0DAA0E;AAY1E;;;;;;GAMG;AACI,MAAM,eAAe,GAAG,KAAK,EAClC,KAGC,EACD,OAEC,EAC8B,EAAE;IACjC,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,SAAS,CAAC,IAAI,CACzC,IAAI,6BAAa,CAAC;QAChB,YAAY,EAAE,KAAK,CAAC,IAAI;QACxB,OAAO,EAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;KACpD,CAAC,CACH,CAAC;IAEF,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,aAAa,EAAE,MAAM,CAAC,aAAa;QACnC,OAAO,EAAE,MAAM,CAAC,OAAO;KACxB,CAAC;AACJ,CAAC,CAAC;AArBW,QAAA,eAAe,mBAqB1B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { LambdaClient } from '@aws-sdk/client-lambda';
|
|
2
|
+
import type { EnvironmentAccessTier } from 'sdk-environment';
|
|
3
|
+
import type { ContextLogTrail } from 'sdk-logs';
|
|
4
|
+
/**
|
|
5
|
+
* .what = caller-side context to invoke lambda endpoints
|
|
6
|
+
* .why = the context for code that INVOKES a lambda
|
|
7
|
+
* (askLambdaEndpoint, getOneLambdaContract, getAllLambdaContracts share it)
|
|
8
|
+
*
|
|
9
|
+
* - log: required (extends ContextLogTrail) for trail propagation + observability
|
|
10
|
+
* - env: the caller's ambient runtime; access is required (no default) per
|
|
11
|
+
* rule.require.env-access-in-context. access is the canonical
|
|
12
|
+
* EnvironmentAccessTier (test | prep | prod) from sdk-environment
|
|
13
|
+
* - aws: injectable sdk client (dependency injection: test seams, reuse)
|
|
14
|
+
*/
|
|
15
|
+
export interface ContextAwsLambdaCaller extends ContextLogTrail {
|
|
16
|
+
env: {
|
|
17
|
+
access: EnvironmentAccessTier;
|
|
18
|
+
region?: string;
|
|
19
|
+
};
|
|
20
|
+
aws?: {
|
|
21
|
+
lambda?: {
|
|
22
|
+
sdk?: LambdaClient;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextAwsLambdaCaller.js","sourceRoot":"","sources":["../../src/domain.objects/ContextAwsLambdaCaller.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { EnvironmentAccessTier } from 'sdk-environment';
|
|
2
|
+
import type { LogMethods } from 'sdk-logs';
|
|
3
|
+
/**
|
|
4
|
+
* .what = env access level for the introspection gate
|
|
5
|
+
* .why = constrains a handler's declared access to valid values; the canonical
|
|
6
|
+
* access tier from sdk-environment (test | prep | prod)
|
|
7
|
+
*/
|
|
8
|
+
export type EnvAccess = EnvironmentAccessTier;
|
|
9
|
+
/**
|
|
10
|
+
* .what = handler env config — static or async access extraction
|
|
11
|
+
* .why = a deployed handler declares its own access (sync or via async lookup)
|
|
12
|
+
* so the introspection middleware can gate on env.access === 'prep'
|
|
13
|
+
*/
|
|
14
|
+
export type EnvConfig = {
|
|
15
|
+
access: EnvAccess;
|
|
16
|
+
} | (() => Promise<{
|
|
17
|
+
access: EnvAccess;
|
|
18
|
+
}>);
|
|
19
|
+
/**
|
|
20
|
+
* .what = server-side context for lambda handler generators
|
|
21
|
+
* .why = the context for code that DEFINES a lambda handler
|
|
22
|
+
* (genLambdaEndpoint, forApiGateway, and future forXyz variants share it)
|
|
23
|
+
*
|
|
24
|
+
* - env: the handler declares its own access for the introspection gate
|
|
25
|
+
* - log: optional gen-time override; the trail middleware injects log at runtime
|
|
26
|
+
*/
|
|
27
|
+
export interface ContextAwsLambdaServer {
|
|
28
|
+
env?: EnvConfig;
|
|
29
|
+
log?: LogMethods;
|
|
30
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ContextAwsLambdaServer.js","sourceRoot":"","sources":["../../src/domain.objects/ContextAwsLambdaServer.ts"],"names":[],"mappings":""}
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.HttpStatusCode = void 0;
|
|
4
4
|
/**
|
|
5
|
-
* .what =
|
|
6
|
-
* .why = provides typed status codes for
|
|
5
|
+
* .what = http status codes enum
|
|
6
|
+
* .why = provides typed status codes for api responses
|
|
7
7
|
*
|
|
8
8
|
* ref: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
|
|
9
9
|
*/
|
|
@@ -18,7 +18,7 @@ var HttpStatusCode;
|
|
|
18
18
|
HttpStatusCode[HttpStatusCode["MOVED_PERMANENTLY_301"] = 301] = "MOVED_PERMANENTLY_301";
|
|
19
19
|
HttpStatusCode[HttpStatusCode["FOUND_302"] = 302] = "FOUND_302";
|
|
20
20
|
HttpStatusCode[HttpStatusCode["NOT_MODIFIED_304"] = 304] = "NOT_MODIFIED_304";
|
|
21
|
-
//
|
|
21
|
+
// caller error
|
|
22
22
|
HttpStatusCode[HttpStatusCode["BAD_REQUEST_400"] = 400] = "BAD_REQUEST_400";
|
|
23
23
|
HttpStatusCode[HttpStatusCode["UNAUTHORIZED_401"] = 401] = "UNAUTHORIZED_401";
|
|
24
24
|
HttpStatusCode[HttpStatusCode["FORBIDDEN_403"] = 403] = "FORBIDDEN_403";
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { DomainEntity } from 'domain-objects';
|
|
2
|
+
/**
|
|
3
|
+
* .what = the domain entity for a callable lambda endpoint
|
|
4
|
+
* .why = a single ubiquitous concept to address a lambda, instead of a flat
|
|
5
|
+
* functionName string + loose service/function fields
|
|
6
|
+
*
|
|
7
|
+
* .keys
|
|
8
|
+
* - primary = ['slug'] — serialized natural key; also the aws function name
|
|
9
|
+
* - unique = ['service', 'access', 'function'] — the natural key
|
|
10
|
+
*
|
|
11
|
+
* .slug = '{service}-{access}-{function}' e.g. 'svc-invoice-prep-getInvoice'
|
|
12
|
+
*/
|
|
13
|
+
export interface LambdaEndpoint {
|
|
14
|
+
/**
|
|
15
|
+
* .what = the owner service, in svc-$noun form
|
|
16
|
+
*/
|
|
17
|
+
service: string;
|
|
18
|
+
/**
|
|
19
|
+
* .what = the env access level (test | prep | prod)
|
|
20
|
+
*/
|
|
21
|
+
access: string;
|
|
22
|
+
/**
|
|
23
|
+
* .what = the function (the "bare" name, no service/access prefix)
|
|
24
|
+
*/
|
|
25
|
+
function: string;
|
|
26
|
+
/**
|
|
27
|
+
* .what = the serialized key '{service}-{access}-{function}'
|
|
28
|
+
* .why = the aws lambda function name; doubles as the wire identifier
|
|
29
|
+
*/
|
|
30
|
+
slug: string;
|
|
31
|
+
}
|
|
32
|
+
export declare class LambdaEndpoint extends DomainEntity<LambdaEndpoint> implements LambdaEndpoint {
|
|
33
|
+
static primary: readonly ["slug"];
|
|
34
|
+
static unique: readonly ["service", "access", "function"];
|
|
35
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LambdaEndpoint = void 0;
|
|
4
|
+
const domain_objects_1 = require("domain-objects");
|
|
5
|
+
class LambdaEndpoint extends domain_objects_1.DomainEntity {
|
|
6
|
+
}
|
|
7
|
+
exports.LambdaEndpoint = LambdaEndpoint;
|
|
8
|
+
LambdaEndpoint.primary = ['slug'];
|
|
9
|
+
LambdaEndpoint.unique = ['service', 'access', 'function'];
|
|
10
|
+
//# sourceMappingURL=LambdaEndpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LambdaEndpoint.js","sourceRoot":"","sources":["../../src/domain.objects/LambdaEndpoint.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAoC9C,MAAa,cACX,SAAQ,6BAA4B;;AADtC,wCAMC;AAFe,sBAAO,GAAG,CAAC,MAAM,CAAU,CAAC;AAC5B,qBAAM,GAAG,CAAC,SAAS,EAAE,QAAQ,EAAE,UAAU,CAAU,CAAC"}
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
import { HelpfulError } from 'helpful-errors';
|
|
2
|
+
import type { LambdaEndpoint } from './LambdaEndpoint';
|
|
2
3
|
/**
|
|
3
4
|
* .what = error for failed lambda invocations via askLambdaEndpoint
|
|
4
|
-
* .why = provides rich context for debug:
|
|
5
|
+
* .why = provides rich context for debug: endpoint, exid, cause
|
|
5
6
|
*/
|
|
6
7
|
export interface LambdaEndpointErrorMetadata {
|
|
7
8
|
/**
|
|
8
|
-
* the
|
|
9
|
+
* the endpoint that was invoked (service, access, function, slug)
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* the lambda function name that was invoked
|
|
13
|
-
*/
|
|
14
|
-
function: string;
|
|
11
|
+
endpoint: LambdaEndpoint;
|
|
15
12
|
/**
|
|
16
13
|
* the exid (execution id) for trail correlation
|
|
17
14
|
*/
|
|
@@ -21,7 +18,7 @@ export interface LambdaEndpointErrorMetadata {
|
|
|
21
18
|
*/
|
|
22
19
|
errorType?: string;
|
|
23
20
|
/**
|
|
24
|
-
* the
|
|
21
|
+
* the http status code from the lambda invocation
|
|
25
22
|
* non-200 indicates invocation itself failed (throttle, permission, not found)
|
|
26
23
|
*/
|
|
27
24
|
statusCode?: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LambdaEndpointError.js","sourceRoot":"","sources":["../../src/domain.objects/LambdaEndpointError.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;
|
|
1
|
+
{"version":3,"file":"LambdaEndpointError.js","sourceRoot":"","sources":["../../src/domain.objects/LambdaEndpointError.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAmD9C,MAAa,mBAAoB,SAAQ,6BAAyC;IAGhF,YAAY,OAAe,EAAE,QAAqC;QAChE,KAAK,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;QACzB,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;;AANH,kDAOC;AANe,wBAAI,GAAG,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,uBAAuB,EAAW,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { JSONSchema } from 'zod/v4/core/json-schema';
|
|
2
|
+
/**
|
|
3
|
+
* .what = the schema of a lambda endpoint's input and output
|
|
4
|
+
* .why = enables runtime introspection of endpoint contracts for sdk generation
|
|
5
|
+
*/
|
|
6
|
+
export interface LambdaEndpointSchema {
|
|
7
|
+
input: JSONSchema;
|
|
8
|
+
output: JSONSchema;
|
|
9
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LambdaEndpointSchema.js","sourceRoot":"","sources":["../../src/domain.objects/LambdaEndpointSchema.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConstraintError } from 'helpful-errors';
|
|
2
|
+
/**
|
|
3
|
+
* .what = error when a lambda function does not exist
|
|
4
|
+
* .why = clear error that names the absent function per criteria
|
|
5
|
+
*
|
|
6
|
+
* .note = bare subclass per helpful-errors convention; pass message + metadata
|
|
7
|
+
* at the throw site via `new LambdaFunctionNotFoundError(message, { ... })`
|
|
8
|
+
*/
|
|
9
|
+
export declare class LambdaFunctionNotFoundError extends ConstraintError {
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LambdaFunctionNotFoundError = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
/**
|
|
6
|
+
* .what = error when a lambda function does not exist
|
|
7
|
+
* .why = clear error that names the absent function per criteria
|
|
8
|
+
*
|
|
9
|
+
* .note = bare subclass per helpful-errors convention; pass message + metadata
|
|
10
|
+
* at the throw site via `new LambdaFunctionNotFoundError(message, { ... })`
|
|
11
|
+
*/
|
|
12
|
+
class LambdaFunctionNotFoundError extends helpful_errors_1.ConstraintError {
|
|
13
|
+
}
|
|
14
|
+
exports.LambdaFunctionNotFoundError = LambdaFunctionNotFoundError;
|
|
15
|
+
//# sourceMappingURL=LambdaFunctionNotFoundError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LambdaFunctionNotFoundError.js","sourceRoot":"","sources":["../../src/domain.objects/LambdaFunctionNotFoundError.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD;;;;;;GAMG;AACH,MAAa,2BAA4B,SAAQ,gCAAe;CAAG;AAAnE,kEAAmE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConstraintError } from 'helpful-errors';
|
|
2
|
+
/**
|
|
3
|
+
* .what = error when introspection is blocked (non-prep environment)
|
|
4
|
+
* .why = clear error when introspection attempted outside prep
|
|
5
|
+
*
|
|
6
|
+
* .note = bare subclass per helpful-errors convention; pass message + metadata
|
|
7
|
+
* at the throw site via `new LambdaIntrospectionBlockedError(message, { ... })`
|
|
8
|
+
*/
|
|
9
|
+
export declare class LambdaIntrospectionBlockedError extends ConstraintError {
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LambdaIntrospectionBlockedError = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
/**
|
|
6
|
+
* .what = error when introspection is blocked (non-prep environment)
|
|
7
|
+
* .why = clear error when introspection attempted outside prep
|
|
8
|
+
*
|
|
9
|
+
* .note = bare subclass per helpful-errors convention; pass message + metadata
|
|
10
|
+
* at the throw site via `new LambdaIntrospectionBlockedError(message, { ... })`
|
|
11
|
+
*/
|
|
12
|
+
class LambdaIntrospectionBlockedError extends helpful_errors_1.ConstraintError {
|
|
13
|
+
}
|
|
14
|
+
exports.LambdaIntrospectionBlockedError = LambdaIntrospectionBlockedError;
|
|
15
|
+
//# sourceMappingURL=LambdaIntrospectionBlockedError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LambdaIntrospectionBlockedError.js","sourceRoot":"","sources":["../../src/domain.objects/LambdaIntrospectionBlockedError.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD;;;;;;GAMG;AACH,MAAa,+BAAgC,SAAQ,gCAAe;CAAG;AAAvE,0EAAuE"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ConstraintError } from 'helpful-errors';
|
|
2
|
+
/**
|
|
3
|
+
* .what = the distinct reasons a lambda does not support introspection
|
|
4
|
+
* .why = lets the error state WHY introspection failed, not just that it did
|
|
5
|
+
* - handler-error = the handler threw on the introspect payload
|
|
6
|
+
* - empty-payload = the invoke returned no payload
|
|
7
|
+
* - non-schema-payload = the payload was not a json-schema envelope
|
|
8
|
+
*/
|
|
9
|
+
export type LambdaIntrospectionNotSupportedReason = 'handler-error' | 'empty-payload' | 'non-schema-payload';
|
|
10
|
+
/**
|
|
11
|
+
* .what = error when a lambda does not support introspection
|
|
12
|
+
* .why = clear error to separate "no support" from "not found"
|
|
13
|
+
*
|
|
14
|
+
* .note = bare subclass per helpful-errors convention; pass message + metadata
|
|
15
|
+
* (incl. the `reason`) at the throw site
|
|
16
|
+
*/
|
|
17
|
+
export declare class LambdaIntrospectionNotSupportedError extends ConstraintError {
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LambdaIntrospectionNotSupportedError = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
/**
|
|
6
|
+
* .what = error when a lambda does not support introspection
|
|
7
|
+
* .why = clear error to separate "no support" from "not found"
|
|
8
|
+
*
|
|
9
|
+
* .note = bare subclass per helpful-errors convention; pass message + metadata
|
|
10
|
+
* (incl. the `reason`) at the throw site
|
|
11
|
+
*/
|
|
12
|
+
class LambdaIntrospectionNotSupportedError extends helpful_errors_1.ConstraintError {
|
|
13
|
+
}
|
|
14
|
+
exports.LambdaIntrospectionNotSupportedError = LambdaIntrospectionNotSupportedError;
|
|
15
|
+
//# sourceMappingURL=LambdaIntrospectionNotSupportedError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LambdaIntrospectionNotSupportedError.js","sourceRoot":"","sources":["../../src/domain.objects/LambdaIntrospectionNotSupportedError.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAcjD;;;;;;GAMG;AACH,MAAa,oCAAqC,SAAQ,gCAAe;CAAG;AAA5E,oFAA4E"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ConstraintError } from 'helpful-errors';
|
|
2
|
+
/**
|
|
3
|
+
* .what = error when a service has no lambda functions
|
|
4
|
+
* .why = clear error that names the absent service per criteria
|
|
5
|
+
*
|
|
6
|
+
* .note = bare subclass per helpful-errors convention; pass message + metadata
|
|
7
|
+
* at the throw site via `new LambdaServiceNotFoundError(message, { ... })`
|
|
8
|
+
*/
|
|
9
|
+
export declare class LambdaServiceNotFoundError extends ConstraintError {
|
|
10
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LambdaServiceNotFoundError = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
/**
|
|
6
|
+
* .what = error when a service has no lambda functions
|
|
7
|
+
* .why = clear error that names the absent service per criteria
|
|
8
|
+
*
|
|
9
|
+
* .note = bare subclass per helpful-errors convention; pass message + metadata
|
|
10
|
+
* at the throw site via `new LambdaServiceNotFoundError(message, { ... })`
|
|
11
|
+
*/
|
|
12
|
+
class LambdaServiceNotFoundError extends helpful_errors_1.ConstraintError {
|
|
13
|
+
}
|
|
14
|
+
exports.LambdaServiceNotFoundError = LambdaServiceNotFoundError;
|
|
15
|
+
//# sourceMappingURL=LambdaServiceNotFoundError.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LambdaServiceNotFoundError.js","sourceRoot":"","sources":["../../src/domain.objects/LambdaServiceNotFoundError.ts"],"names":[],"mappings":";;;AAAA,mDAAiD;AAEjD;;;;;;GAMG;AACH,MAAa,0BAA2B,SAAQ,gCAAe;CAAG;AAAlE,gEAAkE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { LambdaEndpoint } from '../../domain.objects/LambdaEndpoint';
|
|
2
|
+
/**
|
|
3
|
+
* .what = builds a LambdaEndpoint from either its natural-key parts or its slug
|
|
4
|
+
* .why = one boundary transformer for the endpoint concept; parse the slug string
|
|
5
|
+
* exactly once here, pass the structured entity everywhere else
|
|
6
|
+
*
|
|
7
|
+
* .forms
|
|
8
|
+
* - asLambdaEndpoint({ service, access, function }) → computes slug
|
|
9
|
+
* - asLambdaEndpoint({ slug }) → strict-parses slug into parts
|
|
10
|
+
*
|
|
11
|
+
* .throws UnexpectedCodePathError — slug does not match '{service}-{access}-{function}'
|
|
12
|
+
* (exact 3-part shape; no partial match)
|
|
13
|
+
*/
|
|
14
|
+
export declare const asLambdaEndpoint: (input: {
|
|
15
|
+
service: string;
|
|
16
|
+
access: string;
|
|
17
|
+
function: string;
|
|
18
|
+
} | {
|
|
19
|
+
slug: string;
|
|
20
|
+
}) => LambdaEndpoint;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.asLambdaEndpoint = void 0;
|
|
4
|
+
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
+
const LambdaEndpoint_1 = require("../../domain.objects/LambdaEndpoint");
|
|
6
|
+
/**
|
|
7
|
+
* .what = builds a LambdaEndpoint from either its natural-key parts or its slug
|
|
8
|
+
* .why = one boundary transformer for the endpoint concept; parse the slug string
|
|
9
|
+
* exactly once here, pass the structured entity everywhere else
|
|
10
|
+
*
|
|
11
|
+
* .forms
|
|
12
|
+
* - asLambdaEndpoint({ service, access, function }) → computes slug
|
|
13
|
+
* - asLambdaEndpoint({ slug }) → strict-parses slug into parts
|
|
14
|
+
*
|
|
15
|
+
* .throws UnexpectedCodePathError — slug does not match '{service}-{access}-{function}'
|
|
16
|
+
* (exact 3-part shape; no partial match)
|
|
17
|
+
*/
|
|
18
|
+
const asLambdaEndpoint = (input) => {
|
|
19
|
+
// form 1: parts → entity (compute slug)
|
|
20
|
+
if ('service' in input) {
|
|
21
|
+
return new LambdaEndpoint_1.LambdaEndpoint({
|
|
22
|
+
service: input.service,
|
|
23
|
+
access: input.access,
|
|
24
|
+
function: input.function,
|
|
25
|
+
slug: `${input.service}-${input.access}-${input.function}`,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
// form 2: slug → entity (strict parse)
|
|
29
|
+
// slug shape: 'svc-{noun}-{access}-{function}' where service is 'svc-{noun}'
|
|
30
|
+
// so the first two dash-parts form the service, the third is access, the rest
|
|
31
|
+
// (joined) is the function — which may itself contain dashes
|
|
32
|
+
const parts = input.slug.split('-');
|
|
33
|
+
if (parts.length < 4 || parts[0] !== 'svc') {
|
|
34
|
+
throw new helpful_errors_1.UnexpectedCodePathError(`slug does not match expected '{service}-{access}-{function}' shape`, { slug: input.slug });
|
|
35
|
+
}
|
|
36
|
+
const service = `${parts[0]}-${parts[1]}`;
|
|
37
|
+
const access = parts[2];
|
|
38
|
+
const func = parts.slice(3).join('-');
|
|
39
|
+
return new LambdaEndpoint_1.LambdaEndpoint({
|
|
40
|
+
service,
|
|
41
|
+
access,
|
|
42
|
+
function: func,
|
|
43
|
+
slug: input.slug,
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
exports.asLambdaEndpoint = asLambdaEndpoint;
|
|
47
|
+
//# sourceMappingURL=asLambdaEndpoint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"asLambdaEndpoint.js","sourceRoot":"","sources":["../../../src/domain.operations/asLambdaEndpoint/asLambdaEndpoint.ts"],"names":[],"mappings":";;;AAAA,mDAAyD;AAEzD,wEAAqE;AAErE;;;;;;;;;;;GAWG;AACI,MAAM,gBAAgB,GAAG,CAC9B,KAEoB,EACJ,EAAE;IAClB,wCAAwC;IACxC,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;QACvB,OAAO,IAAI,+BAAc,CAAC;YACxB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,QAAQ,EAAE,KAAK,CAAC,QAAQ;YACxB,IAAI,EAAE,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE;SAC3D,CAAC,CAAC;IACL,CAAC;IAED,uCAAuC;IACvC,6EAA6E;IAC7E,8EAA8E;IAC9E,6DAA6D;IAC7D,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACpC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,KAAK,EAAE,CAAC;QAC3C,MAAM,IAAI,wCAAuB,CAC/B,oEAAoE,EACpE,EAAE,IAAI,EAAE,KAAK,CAAC,IAAI,EAAE,CACrB,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1C,MAAM,MAAM,GAAG,KAAK,CAAC,CAAC,CAAW,CAAC;IAClC,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAEtC,OAAO,IAAI,+BAAc,CAAC;QACxB,OAAO;QACP,MAAM;QACN,QAAQ,EAAE,IAAI;QACd,IAAI,EAAE,KAAK,CAAC,IAAI;KACjB,CAAC,CAAC;AACL,CAAC,CAAC;AArCW,QAAA,gBAAgB,oBAqC3B"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import type { LambdaClient } from '@aws-sdk/client-lambda';
|
|
2
|
-
import type { ContextLogTrail } from 'sdk-logs';
|
|
3
1
|
import type { SimpleInMemoryCache } from 'simple-in-memory-cache';
|
|
4
2
|
import type { SimpleCache } from 'with-simple-cache';
|
|
3
|
+
import type { ContextAwsLambdaCaller } from '../../domain.objects/ContextAwsLambdaCaller';
|
|
5
4
|
/**
|
|
6
5
|
* .what = invokes a lambda endpoint with trail propagation
|
|
7
6
|
* .why = enables service-to-service calls with observability
|
|
@@ -27,16 +26,7 @@ export declare const askLambdaEndpoint: <TRequest, TResponse>(input: {
|
|
|
27
26
|
*/
|
|
28
27
|
payload?: 'ancient' | 'contemp';
|
|
29
28
|
};
|
|
30
|
-
}, context:
|
|
31
|
-
env: {
|
|
32
|
-
access: string;
|
|
33
|
-
region?: string;
|
|
34
|
-
};
|
|
35
|
-
aws?: {
|
|
36
|
-
lambda?: {
|
|
37
|
-
sdk?: LambdaClient;
|
|
38
|
-
};
|
|
39
|
-
};
|
|
29
|
+
}, context: ContextAwsLambdaCaller & {
|
|
40
30
|
cache?: {
|
|
41
31
|
response?: SimpleCache<TResponse>;
|
|
42
32
|
dedupe?: SimpleInMemoryCache<TResponse>;
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.askLambdaEndpoint = void 0;
|
|
4
|
+
const genLambdaSdk_1 = require("../../access/sdks/lambda/genLambdaSdk");
|
|
5
|
+
const asLambdaEndpoint_1 = require("../asLambdaEndpoint/asLambdaEndpoint");
|
|
4
6
|
const asCachedExecutor_1 = require("./cache/asCachedExecutor");
|
|
5
7
|
const getAskLambdaCacheKey_1 = require("./cache/getAskLambdaCacheKey");
|
|
6
|
-
const getAccessFromContext_1 = require("./context/getAccessFromContext");
|
|
7
8
|
const getExidFromContext_1 = require("./context/getExidFromContext");
|
|
8
9
|
const getLogForExidExtraction_1 = require("./context/getLogForExidExtraction");
|
|
9
|
-
const genLambdaClient_1 = require("./invoke/genLambdaClient");
|
|
10
|
-
const getLambdaFunctionName_1 = require("./serde/getLambdaFunctionName");
|
|
11
10
|
const getLambdaPayload_1 = require("./serde/getLambdaPayload");
|
|
12
11
|
/**
|
|
13
12
|
* .what = invokes a lambda endpoint with trail propagation
|
|
@@ -29,12 +28,10 @@ const askLambdaEndpoint = async (input, context) => {
|
|
|
29
28
|
note: 'no trail exid in context, generated new one',
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
|
-
//
|
|
33
|
-
const
|
|
34
|
-
// build function name
|
|
35
|
-
const functionName = (0, getLambdaFunctionName_1.getLambdaFunctionName)({
|
|
31
|
+
// build the endpoint from the selector + ambient access (computes slug)
|
|
32
|
+
const endpoint = (0, asLambdaEndpoint_1.asLambdaEndpoint)({
|
|
36
33
|
service: input.which.service,
|
|
37
|
-
access,
|
|
34
|
+
access: context.env.access,
|
|
38
35
|
function: input.which.function,
|
|
39
36
|
});
|
|
40
37
|
// build payload (ancient handlers expect flat event, contemp expect wrapped)
|
|
@@ -42,26 +39,20 @@ const askLambdaEndpoint = async (input, context) => {
|
|
|
42
39
|
const payload = structOfPayload === 'ancient'
|
|
43
40
|
? input.event
|
|
44
41
|
: (0, getLambdaPayload_1.getLambdaPayload)({ event: input.event, trail: { exid } });
|
|
45
|
-
// get or create
|
|
46
|
-
const
|
|
42
|
+
// get or create LambdaClient
|
|
43
|
+
const sdkLambda = (0, genLambdaSdk_1.genLambdaSdk)({
|
|
47
44
|
sdk: context.aws?.lambda?.sdk,
|
|
48
45
|
env: { region: context.env.region },
|
|
49
46
|
});
|
|
50
|
-
// prepare invocation
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
exid,
|
|
55
|
-
service: input.which.service,
|
|
56
|
-
function: input.which.function,
|
|
57
|
-
lambdaClient,
|
|
47
|
+
// prepare invocation input + context
|
|
48
|
+
const invocationInput = { endpoint, payload, exid };
|
|
49
|
+
const invocationContext = {
|
|
50
|
+
sdkLambda,
|
|
58
51
|
log: context.log,
|
|
59
52
|
};
|
|
60
53
|
// build cache key generator
|
|
61
54
|
const getCacheKey = () => (0, getAskLambdaCacheKey_1.getAskLambdaCacheKey)({
|
|
62
|
-
|
|
63
|
-
function: input.which.function,
|
|
64
|
-
access,
|
|
55
|
+
endpoint,
|
|
65
56
|
event: input.event,
|
|
66
57
|
});
|
|
67
58
|
// get executor with cache wrapper
|
|
@@ -70,7 +61,7 @@ const askLambdaEndpoint = async (input, context) => {
|
|
|
70
61
|
getCacheKey,
|
|
71
62
|
});
|
|
72
63
|
// execute invocation
|
|
73
|
-
return execute(
|
|
64
|
+
return execute(invocationInput, invocationContext);
|
|
74
65
|
};
|
|
75
66
|
exports.askLambdaEndpoint = askLambdaEndpoint;
|
|
76
67
|
//# sourceMappingURL=askLambdaEndpoint.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"askLambdaEndpoint.js","sourceRoot":"","sources":["../../../src/domain.operations/askLambdaEndpoint/askLambdaEndpoint.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"askLambdaEndpoint.js","sourceRoot":"","sources":["../../../src/domain.operations/askLambdaEndpoint/askLambdaEndpoint.ts"],"names":[],"mappings":";;;AAGA,wEAAqE;AAErE,2EAAwE;AACxE,+DAA4D;AAC5D,uEAAoE;AACpE,qEAAkE;AAClE,+EAA4E;AAK5E,+DAA4D;AAE5D;;;;;;GAMG;AACI,MAAM,iBAAiB,GAAG,KAAK,EACpC,KAkBC,EACD,OAKC,EACmB,EAAE;IACtB,iCAAiC;IACjC,MAAM,oBAAoB,GAAG,IAAA,iDAAuB,EAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;IAC3E,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,GAAG,IAAA,uCAAkB,EAAC;QACtD,GAAG,EAAE,oBAAoB;KAC1B,CAAC,CAAC;IAEH,+EAA+E;IAC/E,IAAI,UAAU,KAAK,WAAW,EAAE,CAAC;QAC/B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,sBAAsB,EAAE;YACxC,IAAI;YACJ,IAAI,EAAE,6CAA6C;SACpD,CAAC,CAAC;IACL,CAAC;IAED,wEAAwE;IACxE,MAAM,QAAQ,GAAG,IAAA,mCAAgB,EAAC;QAChC,OAAO,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO;QAC5B,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM;QAC1B,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,QAAQ;KAC/B,CAAC,CAAC;IAEH,6EAA6E;IAC7E,MAAM,eAAe,GAAG,KAAK,CAAC,MAAM,EAAE,OAAO,IAAI,SAAS,CAAC;IAC3D,MAAM,OAAO,GACX,eAAe,KAAK,SAAS;QAC3B,CAAC,CAAC,KAAK,CAAC,KAAK;QACb,CAAC,CAAC,IAAA,mCAAgB,EAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC;IAEhE,6BAA6B;IAC7B,MAAM,SAAS,GAAG,IAAA,2BAAY,EAAC;QAC7B,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,GAAG;QAC7B,GAAG,EAAE,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE;KACpC,CAAC,CAAC;IAEH,qCAAqC;IACrC,MAAM,eAAe,GAAoB,EAAE,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACrE,MAAM,iBAAiB,GAAsB;QAC3C,SAAS;QACT,GAAG,EAAE,OAAO,CAAC,GAAG;KACjB,CAAC;IAEF,4BAA4B;IAC5B,MAAM,WAAW,GAAG,GAAW,EAAE,CAC/B,IAAA,2CAAoB,EAAC;QACnB,QAAQ;QACR,KAAK,EAAE,KAAK,CAAC,KAAgC;KAC9C,CAAC,CAAC;IAEL,kCAAkC;IAClC,MAAM,OAAO,GAAG,IAAA,mCAAgB,EAAY;QAC1C,GAAG,OAAO,CAAC,KAAK;QAChB,WAAW;KACZ,CAAC,CAAC;IAEH,qBAAqB;IACrB,OAAO,OAAO,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AACrD,CAAC,CAAC;AAnFW,QAAA,iBAAiB,qBAmF5B"}
|