sdk-aws-lambda 0.1.1 → 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 +14 -12
- 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
package/readme.md
CHANGED
|
@@ -33,21 +33,81 @@ import { askLambdaEndpoint } from 'sdk-aws-lambda';
|
|
|
33
33
|
|
|
34
34
|
const result = await askLambdaEndpoint<TRequest, TResponse>(
|
|
35
35
|
{
|
|
36
|
-
which: { service: 'svc-jobs', function: 'getJobByUuid' },
|
|
36
|
+
which: { service: 'svc-jobs', access: 'prep', function: 'getJobByUuid' },
|
|
37
37
|
event: { uuid },
|
|
38
38
|
},
|
|
39
|
-
{ log
|
|
39
|
+
{ log }, // trail auto-extracted and injected into event; env optional (region)
|
|
40
40
|
);
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
+
## introspection
|
|
44
|
+
|
|
45
|
+
endpoints with zod schemas support runtime introspection. send `{ introspect: 'schema' }` to get the json-schema:
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
import { askLambdaEndpoint } from 'sdk-aws-lambda';
|
|
49
|
+
|
|
50
|
+
// get schema from any endpoint
|
|
51
|
+
const schema = await askLambdaEndpoint(
|
|
52
|
+
{
|
|
53
|
+
which: { service: 'svc-user', access: 'prep', function: 'getUser' },
|
|
54
|
+
event: { introspect: 'schema' },
|
|
55
|
+
},
|
|
56
|
+
{ log },
|
|
57
|
+
);
|
|
58
|
+
// returns: { input: {...jsonSchema}, output: {...jsonSchema} }
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
introspection requires `env.access === 'prep'`. in prod, throws ConstraintError.
|
|
62
|
+
|
|
63
|
+
### define an endpoint with introspection
|
|
64
|
+
|
|
65
|
+
```ts
|
|
66
|
+
import { genLambdaEndpoint } from 'sdk-aws-lambda';
|
|
67
|
+
import { z } from 'zod';
|
|
68
|
+
|
|
69
|
+
const inputSchema = z.object({ userId: z.string().uuid() });
|
|
70
|
+
const outputSchema = z.object({ name: z.string(), email: z.string() });
|
|
71
|
+
|
|
72
|
+
export const handler = genLambdaEndpoint(
|
|
73
|
+
{
|
|
74
|
+
schema: { input: inputSchema, output: outputSchema },
|
|
75
|
+
invoke: async ({ event }) => {
|
|
76
|
+
return { name: 'alice', email: 'alice@example.com' };
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{ env: { access: 'prep' } }, // or env: async () => getEnvConfig()
|
|
80
|
+
);
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### contract discovery (for sdk generation)
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { getAllLambdaContracts, getOneLambdaContract } from 'sdk-aws-lambda';
|
|
87
|
+
|
|
88
|
+
// get schema for one endpoint
|
|
89
|
+
const contract = await getOneLambdaContract(
|
|
90
|
+
{ which: { service: 'svc-user', access: 'prep', function: 'getUser' } },
|
|
91
|
+
{ env: { region: 'us-east-1' } },
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
// get schemas for all endpoints in a service (keyed by bare function name)
|
|
95
|
+
const contracts = await getAllLambdaContracts(
|
|
96
|
+
{ which: { service: 'svc-user', access: 'prep' } },
|
|
97
|
+
{ env: { region: 'us-east-1' } },
|
|
98
|
+
);
|
|
99
|
+
// returns: { getUser: {...schema}, getSettings: {...schema} }
|
|
100
|
+
```
|
|
101
|
+
|
|
43
102
|
# features
|
|
44
103
|
|
|
45
104
|
- **genLambdaEndpoint** — define lambda endpoints with validation, log capture, error classification
|
|
46
105
|
- `genLambdaEndpoint()` — direct invoke (default)
|
|
47
|
-
-
|
|
48
|
-
- `.for.sqs` — sqs queue consumer
|
|
106
|
+
- `forApiGateway()` — http via api gateway
|
|
49
107
|
- **askLambdaEndpoint** — ask another lambda with typed request/response, automatic trail propagation
|
|
50
108
|
- **trace-id propagation** — pass `log` and trail.exid auto-threads through the call chain
|
|
109
|
+
- **introspection** — expose json-schema via `{ introspect: 'schema' }` (prep only)
|
|
110
|
+
- **contract discovery** — `getOneLambdaContract`, `getAllLambdaContracts` for sdk generation
|
|
51
111
|
|
|
52
112
|
# docs
|
|
53
113
|
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .what = extracts access level from context
|
|
3
|
-
* .why = named transformer for clear narrative in orchestrator
|
|
4
|
-
*
|
|
5
|
-
* .note = throws if access is not provided — no fallbacks
|
|
6
|
-
*/
|
|
7
|
-
export declare const getAccessFromContext: (input: {
|
|
8
|
-
env: {
|
|
9
|
-
access: string | null;
|
|
10
|
-
} | null;
|
|
11
|
-
}) => string;
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getAccessFromContext = void 0;
|
|
4
|
-
const helpful_errors_1 = require("helpful-errors");
|
|
5
|
-
/**
|
|
6
|
-
* .what = extracts access level from context
|
|
7
|
-
* .why = named transformer for clear narrative in orchestrator
|
|
8
|
-
*
|
|
9
|
-
* .note = throws if access is not provided — no fallbacks
|
|
10
|
-
*/
|
|
11
|
-
const getAccessFromContext = (input) => {
|
|
12
|
-
// require explicit access from context
|
|
13
|
-
if (input.env?.access)
|
|
14
|
-
return input.env.access;
|
|
15
|
-
// fail loud: no fallbacks
|
|
16
|
-
throw new helpful_errors_1.MalfunctionError('access not provided: context.env.access is required', {
|
|
17
|
-
hint: 'pass env.access in context (test | prep | prod)',
|
|
18
|
-
});
|
|
19
|
-
};
|
|
20
|
-
exports.getAccessFromContext = getAccessFromContext;
|
|
21
|
-
//# sourceMappingURL=getAccessFromContext.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getAccessFromContext.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/context/getAccessFromContext.ts"],"names":[],"mappings":";;;AAAA,mDAAkD;AAElD;;;;;GAKG;AACI,MAAM,oBAAoB,GAAG,CAAC,KAEpC,EAAU,EAAE;IACX,uCAAuC;IACvC,IAAI,KAAK,CAAC,GAAG,EAAE,MAAM;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC;IAE/C,0BAA0B;IAC1B,MAAM,IAAI,iCAAgB,CACxB,qDAAqD,EACrD;QACE,IAAI,EAAE,iDAAiD;KACxD,CACF,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,oBAAoB,wBAa/B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"genLambdaClient.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/invoke/genLambdaClient.ts"],"names":[],"mappings":";;;AAAA,0DAAsD;AAEtD;;;GAGG;AACI,MAAM,eAAe,GAAG,CAAC,KAG/B,EAAgB,EAAE;IACjB,qCAAqC;IACrC,IAAI,KAAK,CAAC,GAAG;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC;IAEhC,iEAAiE;IACjE,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,eAAe,mBAW1B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sdkLambdaInvoke.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/invoke/sdkLambdaInvoke.ts"],"names":[],"mappings":";;;AAAA,0DAA0E;AAY1E;;;GAGG;AACI,MAAM,eAAe,GAAG,KAAK,EAAE,KAIrC,EAAiC,EAAE;IAClC,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CACpC,IAAI,6BAAa,CAAC;QAChB,YAAY,EAAE,KAAK,CAAC,YAAY;QAChC,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;AAjBW,QAAA,eAAe,mBAiB1B"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* .what = transforms service, access, and function into aws lambda function name
|
|
3
|
-
* .why = aws lambda name convention follows ${service}-${access}-${function} pattern
|
|
4
|
-
*/
|
|
5
|
-
export declare const getLambdaFunctionName: (input: {
|
|
6
|
-
service: string;
|
|
7
|
-
access: string;
|
|
8
|
-
function: string;
|
|
9
|
-
}) => string;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLambdaFunctionName = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* .what = transforms service, access, and function into aws lambda function name
|
|
6
|
-
* .why = aws lambda name convention follows ${service}-${access}-${function} pattern
|
|
7
|
-
*/
|
|
8
|
-
const getLambdaFunctionName = (input) => {
|
|
9
|
-
return `${input.service}-${input.access}-${input.function}`;
|
|
10
|
-
};
|
|
11
|
-
exports.getLambdaFunctionName = getLambdaFunctionName;
|
|
12
|
-
//# sourceMappingURL=getLambdaFunctionName.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"getLambdaFunctionName.js","sourceRoot":"","sources":["../../../../src/domain.operations/askLambdaEndpoint/serde/getLambdaFunctionName.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACI,MAAM,qBAAqB,GAAG,CAAC,KAIrC,EAAU,EAAE;IACX,OAAO,GAAG,KAAK,CAAC,OAAO,IAAI,KAAK,CAAC,MAAM,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;AAC9D,CAAC,CAAC;AANW,QAAA,qBAAqB,yBAMhC"}
|