lambder 8.3.1 → 9.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +72 -0
- package/README.md +15 -24
- package/dist/api/LambderApiCallContext.d.ts +31 -1
- package/dist/api/LambderApiCallContext.js +8 -0
- package/dist/api/LambderApiDefinition.d.ts +2 -2
- package/dist/api/LambderApiEnvelope.d.ts +1 -1
- package/dist/api/LambderApiEnvelope.js +3 -4
- package/dist/api/LambderApiIdempotency.js +5 -7
- package/dist/client/LambderCaller.d.ts +0 -4
- package/dist/client/LambderCaller.js +1 -9
- package/dist/core/Lambder.d.ts +50 -12
- package/dist/core/Lambder.js +47 -38
- package/dist/core/LambderContext.d.ts +9 -6
- package/dist/core/LambderContext.js +2 -1
- package/dist/core/LambderResolver.d.ts +6 -12
- package/dist/core/LambderResolver.js +2 -14
- package/dist/core/LambderResponseBuilder.d.ts +15 -70
- package/dist/core/LambderResponseBuilder.js +15 -99
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/invoke/LambderInvokeCaller.js +3 -4
- package/dist/mock/LambderMockApp.js +2 -3
- package/dist/mock/LambderMockCreateOptions.d.ts +2 -2
- package/dist/mock/LambderMockTypes.d.ts +2 -11
- package/dist/shared/util/LambderTypeUtilities.d.ts +18 -0
- package/dist/shared/wire/LambderAnswerHeaders.d.ts +3 -2
- package/dist/shared/wire/LambderAnswerHeaders.js +3 -2
- package/dist/shared/wire/LambderApiContract.d.ts +9 -14
- package/dist/shared/wire/LambderApiRefusal.d.ts +3 -4
- package/dist/shared/wire/LambderApiRefusal.js +3 -4
- package/package.json +1 -1
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
* Contracts are built via method chaining and inferred using typeof lambder.ApiContract
|
|
5
5
|
*/
|
|
6
6
|
import type { LambderCrashDetail } from "./LambderCrashDetail.js";
|
|
7
|
-
import type { LambderNonEmptyOptionMap } from "../util/LambderTypeUtilities.js";
|
|
8
7
|
import type { LambderAppRefusalMessage } from "./LambderApiRefusal.js";
|
|
9
8
|
import type { LambderApiIdempotencyOption, LambderGuardsOptionValue, LambderRateLimitOptionValue } from "./LambderApiOptionValues.js";
|
|
10
9
|
/** Whether an endpoint runs without a session or requires one (addApi versus addSessionApi). */
|
|
@@ -32,15 +31,18 @@ export type LambderApiContractShape = Record<string, {
|
|
|
32
31
|
/** Present when the API declares idempotency: the `idempotency` option exactly as written. */
|
|
33
32
|
idempotency?: LambderApiIdempotencyOption;
|
|
34
33
|
}>;
|
|
35
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Envelope flags and channels beside (or instead of) the payload: what a
|
|
36
|
+
* refusal, the pipeline's own answers, a hook or an error handler set. An API
|
|
37
|
+
* handler sets none of them itself: it returns its output or refuses.
|
|
38
|
+
*/
|
|
36
39
|
export type LambderApiResponseConfig = {
|
|
37
40
|
versionExpired?: boolean;
|
|
38
41
|
sessionExpired?: boolean;
|
|
39
42
|
notAuthorized?: boolean;
|
|
40
|
-
message?: any;
|
|
41
43
|
/**
|
|
42
|
-
* A refusal message, or a plain string when writing
|
|
43
|
-
* (`res.api(null, { errorMessage
|
|
44
|
+
* A refusal message, or a plain string when writing (a refusal thrown
|
|
45
|
+
* with refuse(), or an error handler's `res.api(null, { errorMessage })`): the envelope goes out with
|
|
44
46
|
* the message object either way. Read off the wire it can still be a
|
|
45
47
|
* string, or no message at all, wherever a Lambder server did not write
|
|
46
48
|
* the body (a hand-built mock answer, a proxy); refusalMessageOf reads
|
|
@@ -58,15 +60,8 @@ export type LambderApiResponseConfig = {
|
|
|
58
60
|
crash?: LambderCrashDetail;
|
|
59
61
|
};
|
|
60
62
|
/**
|
|
61
|
-
* The
|
|
62
|
-
*
|
|
63
|
-
* message reaches the caller as a success whose payload is null, which is
|
|
64
|
-
* indistinguishable from an endpoint that answered nothing on purpose.
|
|
65
|
-
*/
|
|
66
|
-
export type LambderApiNullAnswerConfig = LambderNonEmptyOptionMap<Pick<LambderApiResponseConfig, "versionExpired" | "sessionExpired" | "notAuthorized" | "errorMessage" | "message">> & LambderApiResponseConfig;
|
|
67
|
-
/**
|
|
68
|
-
* The API wire envelope both sides speak: res.api() emits it, LambderCaller
|
|
69
|
-
* parses it. `apiVersion` is always there (null when the server set none):
|
|
63
|
+
* The API wire envelope both sides speak: the server writes it around a
|
|
64
|
+
* handler's output or a refusal, LambderCaller parses it. `apiVersion` is always there (null when the server set none):
|
|
70
65
|
* it is how a reader tells a Lambder envelope from another JSON answer, such
|
|
71
66
|
* as API Gateway's own `{ "message": ... }` errors, so an answer without it
|
|
72
67
|
* reads as a server failure.
|
|
@@ -26,10 +26,9 @@ export type LambderApiRefusalOptions = {
|
|
|
26
26
|
/**
|
|
27
27
|
* A typed refusal: "this request is denied/invalid" as opposed to "the server
|
|
28
28
|
* crashed". Throw it from anywhere in an API call's call stack (handlers,
|
|
29
|
-
* hooks, or nested helpers
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* of routing it through setGlobalErrorHandler, so refusals never reach crash
|
|
29
|
+
* hooks, guards or nested helpers) and the render pipeline maps it onto the
|
|
30
|
+
* structured API envelope (its errorMessage, notAuthorized and
|
|
31
|
+
* sessionExpired) instead of routing it through setGlobalErrorHandler, so refusals never reach crash
|
|
33
32
|
* logging and clients receive a parseable response.
|
|
34
33
|
*
|
|
35
34
|
* Thrown outside an API call (e.g. in a route handler) it behaves like any
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* A typed refusal: "this request is denied/invalid" as opposed to "the server
|
|
3
3
|
* crashed". Throw it from anywhere in an API call's call stack (handlers,
|
|
4
|
-
* hooks, or nested helpers
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* of routing it through setGlobalErrorHandler, so refusals never reach crash
|
|
4
|
+
* hooks, guards or nested helpers) and the render pipeline maps it onto the
|
|
5
|
+
* structured API envelope (its errorMessage, notAuthorized and
|
|
6
|
+
* sessionExpired) instead of routing it through setGlobalErrorHandler, so refusals never reach crash
|
|
8
7
|
* logging and clients receive a parseable response.
|
|
9
8
|
*
|
|
10
9
|
* Thrown outside an API call (e.g. in a route handler) it behaves like any
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lambder",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "9.0.1",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"description": "Opinionated serverless web framework for TypeScript on AWS Lambda: type-safe APIs from Zod schemas, DynamoDB sessions, and declarative rate limits, authorization guards and idempotency.",
|
|
6
6
|
"keywords": [
|