lambder 6.0.2 → 7.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 +2316 -0
- package/README.md +60 -33
- package/dist/api/LambderApiAnswer.d.ts +40 -0
- package/dist/api/LambderApiAnswer.js +19 -0
- package/dist/api/LambderApiCallContext.d.ts +38 -0
- package/dist/api/LambderApiCallContext.js +13 -0
- package/dist/api/LambderApiDefinition.d.ts +18 -0
- package/dist/api/LambderApiDefinition.js +1 -0
- package/dist/api/LambderApiEnvelope.d.ts +67 -0
- package/dist/api/LambderApiEnvelope.js +180 -0
- package/dist/api/LambderApiGuards.d.ts +302 -0
- package/dist/api/LambderApiGuards.js +134 -0
- package/dist/api/LambderApiIdempotency.d.ts +122 -0
- package/dist/api/LambderApiIdempotency.js +330 -0
- package/dist/api/LambderApiPipeline.d.ts +134 -0
- package/dist/api/LambderApiPipeline.js +221 -0
- package/dist/api/LambderApiPolicyEngine.d.ts +36 -0
- package/dist/api/LambderApiPolicyEngine.js +77 -0
- package/dist/api/LambderApiRateLimits.d.ts +206 -0
- package/dist/api/LambderApiRateLimits.js +239 -0
- package/dist/api/LambderApiRequest.d.ts +101 -0
- package/dist/api/LambderApiRequest.js +129 -0
- package/dist/api/LambderApiValidationRefusal.d.ts +32 -0
- package/dist/api/LambderApiValidationRefusal.js +40 -0
- package/dist/client/LambderCaller.d.ts +62 -55
- package/dist/client/LambderCaller.js +147 -90
- package/dist/client/lambderFetchTransport.d.ts +9 -0
- package/dist/client/lambderFetchTransport.js +71 -0
- package/dist/client.d.ts +20 -10
- package/dist/client.js +11 -5
- package/dist/core/Lambder.d.ts +117 -253
- package/dist/core/Lambder.js +374 -341
- package/dist/core/LambderContext.d.ts +54 -44
- package/dist/core/LambderContext.js +41 -110
- package/dist/core/LambderCreateOptions.d.ts +285 -0
- package/dist/core/LambderCreateOptions.js +44 -0
- package/dist/core/LambderFiles.d.ts +1 -45
- package/dist/core/LambderFiles.js +18 -38
- package/dist/core/LambderIndexHtml.d.ts +37 -0
- package/dist/core/LambderIndexHtml.js +87 -0
- package/dist/core/LambderPolicyBuilders.d.ts +17 -0
- package/dist/core/LambderPolicyBuilders.js +16 -0
- package/dist/core/LambderPublicFiles.d.ts +5 -2
- package/dist/core/LambderPublicFiles.js +7 -2
- package/dist/core/LambderResolver.d.ts +8 -6
- package/dist/core/LambderResponse.d.ts +29 -11
- package/dist/core/LambderResponse.js +96 -49
- package/dist/core/LambderResponseBuilder.d.ts +18 -14
- package/dist/core/LambderResponseBuilder.js +19 -25
- package/dist/core/LambderRouting.d.ts +18 -7
- package/dist/core/LambderRouting.js +17 -7
- package/dist/core/LambderTemplatingEngine.d.ts +0 -62
- package/dist/core/LambderTemplatingEngine.js +7 -3
- package/dist/index.d.ts +85 -32
- package/dist/index.js +44 -16
- package/dist/invoke/LambderInvokeCaller.d.ts +46 -139
- package/dist/invoke/LambderInvokeCaller.js +140 -335
- package/dist/invoke/LambderInvokeOutcome.d.ts +165 -0
- package/dist/invoke/LambderInvokeOutcome.js +129 -0
- package/dist/invoke/LambderLambdaEvent.d.ts +81 -0
- package/dist/invoke/LambderLambdaEvent.js +187 -0
- package/dist/invoke/lambderHandlerTransport.d.ts +36 -0
- package/dist/invoke/lambderHandlerTransport.js +89 -0
- package/dist/mock/LambderMockApp.d.ts +352 -0
- package/dist/mock/LambderMockApp.js +815 -0
- package/dist/mock/LambderMockBrowserCookies.d.ts +55 -0
- package/dist/mock/LambderMockBrowserCookies.js +76 -0
- package/dist/mock/LambderMockCallRecorder.d.ts +85 -0
- package/dist/mock/LambderMockCallRecorder.js +183 -0
- package/dist/mock/LambderMockCreateOptions.d.ts +161 -0
- package/dist/mock/LambderMockCreateOptions.js +9 -0
- package/dist/mock/LambderMockEntryRegistry.d.ts +52 -0
- package/dist/mock/LambderMockEntryRegistry.js +126 -0
- package/dist/mock/LambderMockFailureInjector.d.ts +60 -0
- package/dist/mock/LambderMockFailureInjector.js +138 -0
- package/dist/mock/LambderMockTypes.d.ts +421 -0
- package/dist/mock/LambderMockTypes.js +8 -0
- package/dist/mock/lambderMockConsoleLogger.d.ts +16 -0
- package/dist/mock/lambderMockConsoleLogger.js +35 -0
- package/dist/mock/lambderMockInvokeTransport.d.ts +50 -0
- package/dist/mock/lambderMockInvokeTransport.js +52 -0
- package/dist/mock/lambderMockMswHandler.d.ts +99 -0
- package/dist/mock/lambderMockMswHandler.js +126 -0
- package/dist/mock.d.ts +34 -0
- package/dist/mock.js +27 -0
- package/dist/session/LambderSessionController.d.ts +199 -30
- package/dist/session/LambderSessionController.js +396 -82
- package/dist/session/LambderSessionCrypto.d.ts +66 -0
- package/dist/session/LambderSessionCrypto.js +101 -0
- package/dist/session/LambderSessionManager.d.ts +118 -80
- package/dist/session/LambderSessionManager.js +212 -184
- package/dist/shared/LambderI18n.d.ts +6 -6
- package/dist/shared/LambderI18n.js +1 -1
- package/dist/shared/contracts/LambderFileSource.d.ts +33 -0
- package/dist/shared/contracts/LambderFileSource.js +19 -0
- package/dist/shared/contracts/LambderIdempotencyStore.d.ts +66 -0
- package/dist/shared/contracts/LambderIdempotencyStore.js +12 -0
- package/dist/shared/contracts/LambderRateLimiter.d.ts +71 -0
- package/dist/shared/contracts/LambderRateLimiter.js +24 -0
- package/dist/shared/contracts/LambderSessionStore.d.ts +72 -0
- package/dist/shared/contracts/LambderSessionStore.js +13 -0
- package/dist/shared/transport/LambderApiTransport.d.ts +139 -0
- package/dist/shared/transport/LambderApiTransport.js +65 -0
- package/dist/shared/transport/LambderCookieJar.d.ts +121 -0
- package/dist/shared/transport/LambderCookieJar.js +246 -0
- package/dist/shared/transport/lambderCookieJarTransport.d.ts +30 -0
- package/dist/shared/transport/lambderCookieJarTransport.js +60 -0
- package/dist/shared/util/LambderBase64.d.ts +10 -0
- package/dist/shared/util/LambderBase64.js +27 -0
- package/dist/shared/util/LambderCallAbort.d.ts +62 -0
- package/dist/shared/util/LambderCallAbort.js +80 -0
- package/dist/shared/util/LambderClientIp.d.ts +32 -0
- package/dist/shared/util/LambderClientIp.js +56 -0
- package/dist/shared/util/LambderExpiringMap.d.ts +119 -0
- package/dist/shared/util/LambderExpiringMap.js +217 -0
- package/dist/shared/util/LambderKeyFields.d.ts +32 -0
- package/dist/shared/util/LambderKeyFields.js +34 -0
- package/dist/shared/util/LambderNodeModules.d.ts +9 -0
- package/dist/shared/util/LambderNodeModules.js +39 -0
- package/dist/shared/util/LambderOptionChecks.d.ts +17 -0
- package/dist/shared/util/LambderOptionChecks.js +33 -0
- package/dist/shared/util/LambderResponseBrand.d.ts +20 -0
- package/dist/shared/util/LambderResponseBrand.js +18 -0
- package/dist/shared/util/LambderTextDigest.d.ts +17 -0
- package/dist/shared/util/LambderTextDigest.js +34 -0
- package/dist/shared/util/LambderTypeUtilities.d.ts +33 -0
- package/dist/shared/util/LambderTypeUtilities.js +8 -0
- package/dist/shared/wire/LambderAnswerHeaders.d.ts +60 -0
- package/dist/shared/wire/LambderAnswerHeaders.js +94 -0
- package/dist/shared/wire/LambderApiContract.d.ts +129 -0
- package/dist/shared/wire/LambderApiOptionValues.d.ts +39 -0
- package/dist/shared/wire/LambderApiOptionValues.js +11 -0
- package/dist/shared/wire/LambderApiOutcome.d.ts +128 -0
- package/dist/shared/{LambderApiOutcome.js → wire/LambderApiOutcome.js} +16 -9
- package/dist/shared/{LambderApiError.d.ts → wire/LambderApiRefusal.d.ts} +48 -26
- package/dist/shared/{LambderApiError.js → wire/LambderApiRefusal.js} +13 -11
- package/dist/shared/wire/LambderCallOptions.d.ts +171 -0
- package/dist/shared/wire/LambderCallOptions.js +17 -0
- package/dist/shared/{LambderCompressionCodec.d.ts → wire/LambderCompressionCodec.d.ts} +10 -6
- package/dist/shared/{LambderCompressionCodec.js → wire/LambderCompressionCodec.js} +67 -23
- package/dist/shared/{LambderCompressionOption.d.ts → wire/LambderCompressionOption.d.ts} +1 -1
- package/dist/shared/{LambderCompressionOption.js → wire/LambderCompressionOption.js} +3 -4
- package/dist/shared/{LambderCrashDetail.d.ts → wire/LambderCrashDetail.d.ts} +10 -0
- package/dist/shared/{LambderCrashDetail.js → wire/LambderCrashDetail.js} +30 -0
- package/dist/shared/wire/LambderHttpStatus.d.ts +12 -0
- package/dist/shared/wire/LambderHttpStatus.js +1 -0
- package/dist/shared/{LambderRequestPayload.d.ts → wire/LambderRequestPayload.d.ts} +25 -17
- package/dist/shared/{LambderRequestPayload.js → wire/LambderRequestPayload.js} +29 -52
- package/dist/shared/wire/LambderSessionCookieNames.d.ts +9 -0
- package/dist/shared/wire/LambderSessionCookieNames.js +9 -0
- package/dist/stores/LambderDdbCache.d.ts +12 -9
- package/dist/stores/LambderDdbCache.js +56 -47
- package/dist/stores/{LambderDdbIdempotency.d.ts → LambderDdbIdempotencyStore.d.ts} +41 -31
- package/dist/stores/LambderDdbIdempotencyStore.js +319 -0
- package/dist/stores/LambderDdbRateLimiter.d.ts +30 -49
- package/dist/stores/LambderDdbRateLimiter.js +47 -45
- package/dist/stores/LambderDdbSdk.d.ts +83 -6
- package/dist/stores/LambderDdbSdk.js +83 -2
- package/dist/stores/LambderDdbSessionStore.d.ts +65 -0
- package/dist/stores/LambderDdbSessionStore.js +161 -0
- package/dist/stores/LambderHttpFileSource.d.ts +1 -1
- package/dist/stores/LambderHttpFileSource.js +10 -1
- package/dist/stores/LambderLocalFileSource.d.ts +15 -0
- package/dist/stores/LambderLocalFileSource.js +28 -0
- package/dist/stores/LambderMemoryIdempotencyStore.d.ts +63 -0
- package/dist/stores/LambderMemoryIdempotencyStore.js +113 -0
- package/dist/stores/LambderMemoryRateLimiter.d.ts +34 -0
- package/dist/stores/LambderMemoryRateLimiter.js +64 -0
- package/dist/stores/LambderMemorySessionStore.d.ts +48 -0
- package/dist/stores/LambderMemorySessionStore.js +74 -0
- package/dist/stores/LambderS3FileSource.d.ts +1 -1
- package/dist/stores/LambderS3FileSource.js +1 -1
- package/package.json +21 -19
- package/dist/client/LambderMSW.d.ts +0 -69
- package/dist/client/LambderMSW.js +0 -121
- package/dist/policies/LambderApiGuards.d.ts +0 -256
- package/dist/policies/LambderApiGuards.js +0 -94
- package/dist/policies/LambderApiIdempotency.d.ts +0 -58
- package/dist/policies/LambderApiIdempotency.js +0 -219
- package/dist/policies/LambderApiPolicies.d.ts +0 -42
- package/dist/policies/LambderApiPolicies.js +0 -52
- package/dist/policies/LambderApiRateLimits.d.ts +0 -132
- package/dist/policies/LambderApiRateLimits.js +0 -119
- package/dist/shared/LambderApiContract.d.ts +0 -57
- package/dist/shared/LambderApiOutcome.d.ts +0 -69
- package/dist/shared/LambderCallOptions.d.ts +0 -71
- package/dist/shared/LambderCallOptions.js +0 -16
- package/dist/shared/node-polyfills.d.ts +0 -4
- package/dist/shared/node-polyfills.js +0 -58
- package/dist/stores/LambderDdbIdempotency.js +0 -229
- package/dist/testing.d.ts +0 -9
- package/dist/testing.js +0 -8
- /package/dist/shared/{LambderApiContract.js → wire/LambderApiContract.js} +0 -0
- /package/dist/{core → shared/wire}/LambderCookie.d.ts +0 -0
- /package/dist/{core → shared/wire}/LambderCookie.js +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,56 +1,109 @@
|
|
|
1
1
|
import Lambder from './core/Lambder.js';
|
|
2
2
|
export default Lambder;
|
|
3
3
|
export { initLambder } from './core/Lambder.js';
|
|
4
|
+
export type { LambderCreatedHook } from './core/Lambder.js';
|
|
4
5
|
export { default as LambderCaller } from "./client/LambderCaller.js";
|
|
5
|
-
export type { LambderApiOutcome, LambderApiFailureReason, LambderValidationError, LambderCallOptions, LambderCallerOptions, LambderGuardInputsProvider, LambderProvidedGuardInputs, LambderIdempotencyKeyScope } from "./client/LambderCaller.js";
|
|
6
|
-
export {
|
|
7
|
-
export
|
|
8
|
-
export {
|
|
9
|
-
export type {
|
|
10
|
-
export {
|
|
11
|
-
export
|
|
6
|
+
export type { LambderApiOutcome, LambderApiFailureReason, LambderValidationError, LambderCallOptions, LambderCallerOptions, LambderGuardInputsProvider, LambderProvidedGuardInputs, LambderIdempotencyKeyScope, LambderLogListHandler } from "./client/LambderCaller.js";
|
|
7
|
+
export { lambderFetchTransport } from "./client/lambderFetchTransport.js";
|
|
8
|
+
export { buildTransportEnvelope, LambderTransportFailure, isLambderTransportFailure } from "./shared/transport/LambderApiTransport.js";
|
|
9
|
+
export { lambderCookieJarTransport } from "./shared/transport/lambderCookieJarTransport.js";
|
|
10
|
+
export type { LambderApiTransport, LambderApiTransportRequest, LambderTransportFailureReason } from "./shared/transport/LambderApiTransport.js";
|
|
11
|
+
export { LambderCookieJar, parseSetCookie } from "./shared/transport/LambderCookieJar.js";
|
|
12
|
+
export { LambderExpiringMap, LambderExpiringMapFullError } from "./shared/util/LambderExpiringMap.js";
|
|
13
|
+
export type { LambderStoredCookie } from "./shared/transport/LambderCookieJar.js";
|
|
14
|
+
export { lambderHandlerTransport } from "./invoke/lambderHandlerTransport.js";
|
|
15
|
+
export type { LambderHandlerTransportOptions } from "./invoke/lambderHandlerTransport.js";
|
|
16
|
+
export { synthesizeLambdaHttpEvent, decodeLambdaHttpResult, localLambdaContext, LAMBDER_INVOKE_HEADER, LAMBDER_INVOKED_BY_HEADER, LAMBDER_INVOKE_PROTOCOL, } from "./invoke/LambderLambdaEvent.js";
|
|
17
|
+
export type { LambderSynthesizedRequest, LambderLambdaHttpResult, LambderInvokeSession } from "./invoke/LambderLambdaEvent.js";
|
|
18
|
+
export { LambderApiPipeline } from "./api/LambderApiPipeline.js";
|
|
19
|
+
export type { LambderApiPipelineOptions, LambderApiSessionsConfig, LambderApiInputRefusal, LambderApiRunResult, LambderApiExec } from "./api/LambderApiPipeline.js";
|
|
20
|
+
export { readApiEnvelope, restoreCompressedPayload } from "./api/LambderApiRequest.js";
|
|
21
|
+
export type { LambderApiRequest, LambderApiRequestInfo, LambderCompressedPayloadFields, LambderRestorePayloadResult } from "./api/LambderApiRequest.js";
|
|
22
|
+
export { toHttpAnswer } from "./api/LambderApiAnswer.js";
|
|
23
|
+
export type { LambderApiAnswer } from "./api/LambderApiAnswer.js";
|
|
24
|
+
export { LambderAnswerHeaders, getAnswerHeader, setAnswerHeader, addAnswerHeader } from "./shared/wire/LambderAnswerHeaders.js";
|
|
25
|
+
export { createApiCallContext } from "./api/LambderApiCallContext.js";
|
|
26
|
+
export type { LambderApiCallContext, LambderApiCallTrace } from "./api/LambderApiCallContext.js";
|
|
27
|
+
export type { LambderApiDefinition } from "./api/LambderApiDefinition.js";
|
|
28
|
+
export { buildApiEnvelope, envelopeAnswer, refusalAnswer, validationAnswer, apiNotFoundAnswer, sessionExpiredAnswer, versionExpiredAnswer, invalidPayloadAnswer, crashAnswer, API_ANSWER_CONTENT_TYPE, } from "./api/LambderApiEnvelope.js";
|
|
29
|
+
export type { LambderApiEnvelopeConfig, LambderValidationAnswerBody } from "./api/LambderApiEnvelope.js";
|
|
30
|
+
export { LambderApiValidationRefusal, isLambderApiValidationRefusal } from "./api/LambderApiValidationRefusal.js";
|
|
31
|
+
export { LambderInvokeError, isLambderInvokeError } from "./invoke/LambderInvokeOutcome.js";
|
|
32
|
+
export type { LambderInvokeOutcome, LambderInvokeFailure, LambderInvokeValidationFailure, LambderInvokeCrashFailure, LambderInvokePayloadTooLargeFailure, LambderInvokeEnvelopeFailure, LambderInvokeDeliveryFailure, LambderInvokeFailureReason, LambderInvokeFunctionError, } from "./invoke/LambderInvokeOutcome.js";
|
|
33
|
+
export { default as LambderInvokeCaller, LAMBDER_INVOKE_MAX_EVENT_BYTES, } from "./invoke/LambderInvokeCaller.js";
|
|
34
|
+
export type { LambderInvokeCallerOptions, LambderInvokeCallOptions, LambderInvokeFailureHandler, LambderInvokeLogListHandler, LambderInvokeTransport, LambderInvokeTransportResult, LambderInvokeRequestInit, LambderInvokeEventInit, } from "./invoke/LambderInvokeCaller.js";
|
|
35
|
+
export { describeCrash, errorFromCrashDetail } from "./shared/wire/LambderCrashDetail.js";
|
|
36
|
+
export type { LambderCrashDetail, LambderCrashCause } from "./shared/wire/LambderCrashDetail.js";
|
|
37
|
+
export { LambderApiRefusal, isLambderApiRefusal, refuse, LAMBDER_REFUSAL_CODES } from "./shared/wire/LambderApiRefusal.js";
|
|
38
|
+
export type { LambderApiRefusalOptions, LambderRefusalMessage, LambderAppRefusalMessage, LambderRefusalCode, LambderRefuseOptions } from "./shared/wire/LambderApiRefusal.js";
|
|
12
39
|
export { default as LambderResponseBuilder } from "./core/LambderResponseBuilder.js";
|
|
13
40
|
export { default as LambderResolver } from "./core/LambderResolver.js";
|
|
14
41
|
export { default as LambderSessionManager } from "./session/LambderSessionManager.js";
|
|
42
|
+
export type { LambderSessionManagerOptions } from "./session/LambderSessionManager.js";
|
|
15
43
|
export { default as LambderSessionController } from "./session/LambderSessionController.js";
|
|
16
|
-
export {
|
|
44
|
+
export { DEFAULT_SESSION_TOKEN_COOKIE_KEY, DEFAULT_SESSION_CSRF_COOKIE_KEY } from "./shared/wire/LambderSessionCookieNames.js";
|
|
45
|
+
export type { LambderSessionControllerOptions, LambderSessionRequestInfo } from "./session/LambderSessionController.js";
|
|
46
|
+
export type { LambderSessionStore, LambderSessionRecord } from "./shared/contracts/LambderSessionStore.js";
|
|
47
|
+
export { LambderMemorySessionStore } from "./stores/LambderMemorySessionStore.js";
|
|
48
|
+
export { LambderWebCrypto, LambderPlainSessionCrypto, isWebCryptoAvailable } from "./session/LambderSessionCrypto.js";
|
|
49
|
+
export type { LambderSessionCrypto } from "./session/LambderSessionCrypto.js";
|
|
50
|
+
export { LambderDdbSessionStore } from "./stores/LambderDdbSessionStore.js";
|
|
51
|
+
export type { LambderDdbSessionStoreOptions } from "./stores/LambderDdbSessionStore.js";
|
|
52
|
+
export { LambderResponse, finalizeResponse, answerFromResponse, responseFromAnswer, type LambderHttpResponse, type LambderHeadersInput, type LambderFinalizeOptions, type LambderResponseCompressionSettings, type LambderResponseCompressionOption, } from "./core/LambderResponse.js";
|
|
53
|
+
export type { LambderHttpStatusCode } from "./shared/wire/LambderHttpStatus.js";
|
|
17
54
|
export { html, xml, raw, jsonScript, escapeHtml, renderHtmlValue, LambderSafeHtml, type LambderHtmlValue } from "./shared/LambderHtml.js";
|
|
18
55
|
export { LambderTemplatingEngine } from "./core/LambderTemplatingEngine.js";
|
|
19
56
|
export type { LambderTemplateData, LambderTemplatingEngineOptions } from "./core/LambderTemplatingEngine.js";
|
|
20
|
-
export type { LambderResponseOptions, LambderRawResponseInit,
|
|
21
|
-
export type { LambderRouteMatcher,
|
|
22
|
-
export {
|
|
57
|
+
export type { LambderResponseOptions, LambderRawResponseInit, LambderResolverApiMethod, } from "./core/LambderResponseBuilder.js";
|
|
58
|
+
export type { LambderRouteMatcher, LambderRouteConditionFn, LambderRouteCondition, LambderPathParamsOf, LambderRoutePath } from "./core/LambderRouting.js";
|
|
59
|
+
export type { LambderCorsConfig } from "./core/LambderCors.js";
|
|
60
|
+
export type { LambderCreateOptions, LambderSessionOptions, LambderActionTools, LambderHandler, } from "./core/LambderCreateOptions.js";
|
|
61
|
+
export type { LambderIndexHtmlOptions } from "./core/LambderIndexHtml.js";
|
|
62
|
+
export type { LambderRouteHandler, LambderSessionRouteHandler, LambderActionHandler, LambderActionFilter, LambderHookEvent, LambderBeforeRenderHook, LambderAfterRenderHook, LambderFallbackHook, LambderGlobalErrorHandler, LambderFallbackHandler, LambderInputValidationHandler, } from "./core/LambderCreateOptions.js";
|
|
23
63
|
export type { LambderPublicFilesOptions } from "./core/LambderPublicFiles.js";
|
|
24
|
-
export { LambderFiles
|
|
25
|
-
export type {
|
|
64
|
+
export { LambderFiles } from "./core/LambderFiles.js";
|
|
65
|
+
export type { LambderFilesOption, LambderFileMemoryCacheOption, LambderReadFile } from "./core/LambderFiles.js";
|
|
66
|
+
export { LambderLocalFileSource } from "./stores/LambderLocalFileSource.js";
|
|
67
|
+
export type { LambderFileSource, LambderFile } from "./shared/contracts/LambderFileSource.js";
|
|
26
68
|
export { LambderS3FileSource } from "./stores/LambderS3FileSource.js";
|
|
27
69
|
export type { LambderS3FileSourceOptions } from "./stores/LambderS3FileSource.js";
|
|
28
70
|
export { LambderHttpFileSource } from "./stores/LambderHttpFileSource.js";
|
|
29
71
|
export type { LambderHttpFileSourceOptions } from "./stores/LambderHttpFileSource.js";
|
|
30
72
|
export type { LambderSessionCookieOptions } from "./session/LambderSessionController.js";
|
|
31
|
-
export type {
|
|
32
|
-
export { resolveCompressionOption, LAMBDER_ENCODINGS } from "./shared/LambderCompressionOption.js";
|
|
33
|
-
export type { LambderCompressionOption, LambderCompressionSettings, LambderCompressionSettingsBase, LambderEncoding, } from "./shared/LambderCompressionOption.js";
|
|
34
|
-
export { compressText, restoreBytes, restoreText, LambderCompressionError, LAMBDER_RESTORE_FAILURES, } from "./shared/LambderCompressionCodec.js";
|
|
35
|
-
export type { LambderRestoreFailure, LambderRestoreBound } from "./shared/LambderCompressionCodec.js";
|
|
73
|
+
export type { LambderCreatedSession, LambderSessionDataRefreshConfig } from "./session/LambderSessionManager.js";
|
|
74
|
+
export { resolveCompressionOption, LAMBDER_ENCODINGS } from "./shared/wire/LambderCompressionOption.js";
|
|
75
|
+
export type { LambderCompressionOption, LambderCompressionSettings, LambderCompressionSettingsBase, LambderEncoding, } from "./shared/wire/LambderCompressionOption.js";
|
|
76
|
+
export { compressText, restoreBytes, restoreText, LambderCompressionError, LAMBDER_RESTORE_FAILURES, } from "./shared/wire/LambderCompressionCodec.js";
|
|
77
|
+
export type { LambderRestoreFailure, LambderRestoreBound } from "./shared/wire/LambderCompressionCodec.js";
|
|
36
78
|
export { LambderSessionDataRefreshError, LambderSessionReadError } from "./session/LambderSessionManager.js";
|
|
79
|
+
export { LambderSessionNotFoundError, LambderSessionAmbiguousError } from "./session/LambderSessionController.js";
|
|
37
80
|
export { LambderDdbCache } from "./stores/LambderDdbCache.js";
|
|
38
81
|
export type { LambderCacheKey, LambderDdbCacheOptions, LambderDdbCacheSetOptions, LambderDdbCacheGetOrSetOptions, LambderDdbCacheListOptions, } from "./stores/LambderDdbCache.js";
|
|
82
|
+
export { RATE_LIMIT_WINDOWS } from "./shared/contracts/LambderRateLimiter.js";
|
|
83
|
+
export type { LambderRateLimiter, LambderRateLimitWindow, LambderRateLimitPolicy, LambderRateLimitExceeded, LambderRateLimitResult, } from "./shared/contracts/LambderRateLimiter.js";
|
|
39
84
|
export { LambderDdbRateLimiter } from "./stores/LambderDdbRateLimiter.js";
|
|
40
|
-
export type { LambderDdbRateLimiterOptions
|
|
41
|
-
export {
|
|
42
|
-
export type {
|
|
43
|
-
export {
|
|
44
|
-
export type {
|
|
45
|
-
export {
|
|
46
|
-
export
|
|
47
|
-
export
|
|
85
|
+
export type { LambderDdbRateLimiterOptions } from "./stores/LambderDdbRateLimiter.js";
|
|
86
|
+
export { LambderMemoryRateLimiter } from "./stores/LambderMemoryRateLimiter.js";
|
|
87
|
+
export type { LambderIdempotencyStore, LambderIdempotencyBeginResult, LambderIdempotencyDoneRecord, } from "./shared/contracts/LambderIdempotencyStore.js";
|
|
88
|
+
export { LambderDdbIdempotencyStore } from "./stores/LambderDdbIdempotencyStore.js";
|
|
89
|
+
export type { LambderDdbIdempotencyStoreOptions } from "./stores/LambderDdbIdempotencyStore.js";
|
|
90
|
+
export { LambderMemoryIdempotencyStore } from "./stores/LambderMemoryIdempotencyStore.js";
|
|
91
|
+
export { lambderGuard, lambderRateLimitKey } from "./core/LambderPolicyBuilders.js";
|
|
92
|
+
export { lambderGuardBuilder } from "./api/LambderApiGuards.js";
|
|
93
|
+
export type { LambderGuardBuilder, LambderApiGuard, LambderGuardMeta, LambderGuardMetaMap, LambderAllowedGuardNames, LambderParamlessGuardNames, LambderGuardsOption, LambderGuardDataOf, LambderGuardInputsOf, } from "./api/LambderApiGuards.js";
|
|
94
|
+
export { lambderRateLimitKeyBuilder, rateLimitRefusal, DEFAULT_RATE_LIMIT_REFUSAL } from "./api/LambderApiRateLimits.js";
|
|
95
|
+
export type { LambderRateLimitKeyBuilder } from "./api/LambderApiRateLimits.js";
|
|
96
|
+
export type { LambderRateLimitKeyFn, LambderRateLimitPer, LambderRateLimitBudget, LambderApiRateLimitPolicyConfig, LambderApiRateLimitsConfig, LambderAllowedPolicyNames, LambderRateLimitOption, } from "./api/LambderApiRateLimits.js";
|
|
97
|
+
export type { LambderApiIdempotencyConfig } from "./api/LambderApiIdempotency.js";
|
|
98
|
+
export type { LambderGuardsOptionValue, LambderRateLimitOverride, LambderRateLimitOptionValue, LambderApiIdempotencyOption, } from "./shared/wire/LambderApiOptionValues.js";
|
|
48
99
|
export { createLambderI18n } from "./shared/LambderI18n.js";
|
|
49
100
|
export type { LambderLanguageMeta, LambderI18nConfig, LambderI18nInstance, LambderI18nTranslator, LambderI18nExtractParams, LambderI18nCodes, LambderI18nKeys, LambderI18nTranslatorFor, } from "./shared/LambderI18n.js";
|
|
50
|
-
export {
|
|
51
|
-
export type { LambderRenderContext, LambderSessionRenderContext, LambderHttpEvent } from "./core/LambderContext.js";
|
|
101
|
+
export type { LambderApiContractShape, LambderApiMode, LambderApiEnvelopeBody, LambderApiResponseConfig, LambderApiNullAnswerConfig, LambderContractEntry, LambderMergeContract, LambderGuardNamesIn, LambderContractMode, LambderContractKeysWithMode, LambderContractGuardsOf, LambderContractGuardNames, LambderContractGuardInputsOf, LambderContractGuardInput, LambderContractGuardInputNames, LambderContractRateLimitOf, LambderContractIdempotencyOf, } from "./shared/wire/LambderApiContract.js";
|
|
102
|
+
export type { LambderRenderContext, LambderSessionRenderContext, LambderHttpEvent, LambderHttpEventFormat } from "./core/LambderContext.js";
|
|
103
|
+
export type { LambderApiAnswerOutcome, LambderApiSuccessOutcome, LambderApiCallFailure, LambderApiValidationFailure, LambderApiEnvelopeFailure, LambderApiHttpAnswer, } from "./shared/wire/LambderApiOutcome.js";
|
|
104
|
+
export { resolveApiOutcome } from "./shared/wire/LambderApiOutcome.js";
|
|
52
105
|
export { createContext, isV2HttpEvent } from "./core/LambderContext.js";
|
|
53
|
-
export { COMPRESSED_PAYLOAD_GZ_FIELD, COMPRESSED_PAYLOAD_BR_FIELD, COMPRESSED_PAYLOAD_BYTES_FIELD, DEFAULT_REQUEST_COMPRESSION_SETTINGS, DEFAULT_MAX_RESTORED_PAYLOAD_BYTES, } from "./shared/LambderRequestPayload.js";
|
|
54
|
-
export type { LambderCompressedGzipPayload, LambderCompressedBrotliPayload, LambderRequestCompressionOption, LambderRequestCompressionSettings, } from "./shared/LambderRequestPayload.js";
|
|
55
|
-
export { serializeCookie, serializeClearCookie, resolveCookieDomain } from "./
|
|
56
|
-
export type { LambderCookieOptions, LambderClearCookieOptions, LambderCookieDomain } from "./
|
|
106
|
+
export { COMPRESSED_PAYLOAD_GZ_FIELD, COMPRESSED_PAYLOAD_BR_FIELD, COMPRESSED_PAYLOAD_BYTES_FIELD, DEFAULT_REQUEST_COMPRESSION_SETTINGS, DEFAULT_MAX_RESTORED_PAYLOAD_BYTES, DEFAULT_INVOKE_REQUEST_COMPRESSION_SETTINGS, compressPayloadBrotli, } from "./shared/wire/LambderRequestPayload.js";
|
|
107
|
+
export type { LambderCompressedGzipPayload, LambderCompressedBrotliPayload, LambderRequestCompressionOption, LambderRequestCompressionSettings, } from "./shared/wire/LambderRequestPayload.js";
|
|
108
|
+
export { serializeCookie, serializeClearCookie, resolveCookieDomain } from "./shared/wire/LambderCookie.js";
|
|
109
|
+
export type { LambderCookieOptions, LambderClearCookieOptions, LambderCookieDomain } from "./shared/wire/LambderCookie.js";
|
package/dist/index.js
CHANGED
|
@@ -2,47 +2,75 @@ import Lambder from './core/Lambder.js';
|
|
|
2
2
|
export default Lambder;
|
|
3
3
|
export { initLambder } from './core/Lambder.js';
|
|
4
4
|
export { default as LambderCaller } from "./client/LambderCaller.js";
|
|
5
|
+
// Transports: how a caller reaches a server (fetch in production, a handler in-process for tests, a cookie jar over either)
|
|
6
|
+
export { lambderFetchTransport } from "./client/lambderFetchTransport.js";
|
|
7
|
+
export { buildTransportEnvelope, LambderTransportFailure, isLambderTransportFailure } from "./shared/transport/LambderApiTransport.js";
|
|
8
|
+
export { lambderCookieJarTransport } from "./shared/transport/lambderCookieJarTransport.js";
|
|
9
|
+
export { LambderCookieJar, parseSetCookie } from "./shared/transport/LambderCookieJar.js";
|
|
10
|
+
export { LambderExpiringMap, LambderExpiringMapFullError } from "./shared/util/LambderExpiringMap.js";
|
|
11
|
+
export { lambderHandlerTransport } from "./invoke/lambderHandlerTransport.js";
|
|
12
|
+
export { synthesizeLambdaHttpEvent, decodeLambdaHttpResult, localLambdaContext, LAMBDER_INVOKE_HEADER, LAMBDER_INVOKED_BY_HEADER, LAMBDER_INVOKE_PROTOCOL, } from "./invoke/LambderLambdaEvent.js";
|
|
13
|
+
// The API core: the request, answer, envelope and pipeline both the server and the mock runtime run
|
|
14
|
+
export { LambderApiPipeline } from "./api/LambderApiPipeline.js";
|
|
15
|
+
export { readApiEnvelope, restoreCompressedPayload } from "./api/LambderApiRequest.js";
|
|
16
|
+
export { toHttpAnswer } from "./api/LambderApiAnswer.js";
|
|
17
|
+
export { LambderAnswerHeaders, getAnswerHeader, setAnswerHeader, addAnswerHeader } from "./shared/wire/LambderAnswerHeaders.js";
|
|
18
|
+
export { createApiCallContext } from "./api/LambderApiCallContext.js";
|
|
19
|
+
export { buildApiEnvelope, envelopeAnswer, refusalAnswer, validationAnswer, apiNotFoundAnswer, sessionExpiredAnswer, versionExpiredAnswer, invalidPayloadAnswer, crashAnswer, API_ANSWER_CONTENT_TYPE, } from "./api/LambderApiEnvelope.js";
|
|
20
|
+
export { LambderApiValidationRefusal, isLambderApiValidationRefusal } from "./api/LambderApiValidationRefusal.js";
|
|
5
21
|
// Calling a Lambder app from another lambda (server-only: the Lambda SDK, zlib)
|
|
6
|
-
export {
|
|
22
|
+
export { LambderInvokeError, isLambderInvokeError } from "./invoke/LambderInvokeOutcome.js";
|
|
23
|
+
export { default as LambderInvokeCaller, LAMBDER_INVOKE_MAX_EVENT_BYTES, } from "./invoke/LambderInvokeCaller.js";
|
|
7
24
|
// A crash described for a caller allowed to see it (the envelope's `crash` field)
|
|
8
|
-
export { describeCrash, errorFromCrashDetail } from "./shared/LambderCrashDetail.js";
|
|
25
|
+
export { describeCrash, errorFromCrashDetail } from "./shared/wire/LambderCrashDetail.js";
|
|
9
26
|
// Typed API refusals (isomorphic: shared code may throw them from anywhere)
|
|
10
|
-
export {
|
|
27
|
+
export { LambderApiRefusal, isLambderApiRefusal, refuse, LAMBDER_REFUSAL_CODES } from "./shared/wire/LambderApiRefusal.js";
|
|
11
28
|
export { default as LambderResponseBuilder } from "./core/LambderResponseBuilder.js";
|
|
12
29
|
export { default as LambderResolver } from "./core/LambderResolver.js";
|
|
13
30
|
export { default as LambderSessionManager } from "./session/LambderSessionManager.js";
|
|
14
31
|
export { default as LambderSessionController } from "./session/LambderSessionController.js";
|
|
32
|
+
export { DEFAULT_SESSION_TOKEN_COOKIE_KEY, DEFAULT_SESSION_CSRF_COOKIE_KEY } from "./shared/wire/LambderSessionCookieNames.js";
|
|
33
|
+
export { LambderMemorySessionStore } from "./stores/LambderMemorySessionStore.js";
|
|
34
|
+
export { LambderWebCrypto, LambderPlainSessionCrypto, isWebCryptoAvailable } from "./session/LambderSessionCrypto.js";
|
|
35
|
+
export { LambderDdbSessionStore } from "./stores/LambderDdbSessionStore.js";
|
|
15
36
|
// Response model
|
|
16
|
-
export { LambderResponse, finalizeResponse,
|
|
37
|
+
export { LambderResponse, finalizeResponse, answerFromResponse, responseFromAnswer, } from "./core/LambderResponse.js";
|
|
17
38
|
// Type-safe templating (tagged templates with auto-escaping)
|
|
18
39
|
export { html, xml, raw, jsonScript, escapeHtml, renderHtmlValue, LambderSafeHtml } from "./shared/LambderHtml.js";
|
|
19
40
|
// Comment-based HTML templating engine (build-pipeline-safe slots and conditionals, standalone)
|
|
20
41
|
export { LambderTemplatingEngine } from "./core/LambderTemplatingEngine.js";
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
export { LambderFiles, LambderLocalFileSource } from "./core/LambderFiles.js";
|
|
42
|
+
export { LambderFiles } from "./core/LambderFiles.js";
|
|
43
|
+
export { LambderLocalFileSource } from "./stores/LambderLocalFileSource.js";
|
|
24
44
|
export { LambderS3FileSource } from "./stores/LambderS3FileSource.js";
|
|
25
45
|
export { LambderHttpFileSource } from "./stores/LambderHttpFileSource.js";
|
|
26
46
|
// Compression: the option every site shares, and the one codec behind them all.
|
|
27
|
-
export { resolveCompressionOption, LAMBDER_ENCODINGS } from "./shared/LambderCompressionOption.js";
|
|
47
|
+
export { resolveCompressionOption, LAMBDER_ENCODINGS } from "./shared/wire/LambderCompressionOption.js";
|
|
28
48
|
// Brotli/gzip plus the bounded, length-verified restore every compressed
|
|
29
49
|
// value in Lambder (records at rest, request payloads) goes through.
|
|
30
|
-
export { compressText, restoreBytes, restoreText, LambderCompressionError, LAMBDER_RESTORE_FAILURES, } from "./shared/LambderCompressionCodec.js";
|
|
50
|
+
export { compressText, restoreBytes, restoreText, LambderCompressionError, LAMBDER_RESTORE_FAILURES, } from "./shared/wire/LambderCompressionCodec.js";
|
|
31
51
|
export { LambderSessionDataRefreshError, LambderSessionReadError } from "./session/LambderSessionManager.js";
|
|
52
|
+
export { LambderSessionNotFoundError, LambderSessionAmbiguousError } from "./session/LambderSessionController.js";
|
|
32
53
|
// DynamoDB-backed compressed cache (standalone, server-only)
|
|
33
54
|
export { LambderDdbCache } from "./stores/LambderDdbCache.js";
|
|
34
|
-
//
|
|
55
|
+
// Fixed-window rate limiting: the shared vocabulary, the DynamoDB limiter and the in-memory one
|
|
56
|
+
export { RATE_LIMIT_WINDOWS } from "./shared/contracts/LambderRateLimiter.js";
|
|
35
57
|
export { LambderDdbRateLimiter } from "./stores/LambderDdbRateLimiter.js";
|
|
36
|
-
|
|
37
|
-
export {
|
|
58
|
+
export { LambderMemoryRateLimiter } from "./stores/LambderMemoryRateLimiter.js";
|
|
59
|
+
export { LambderDdbIdempotencyStore } from "./stores/LambderDdbIdempotencyStore.js";
|
|
60
|
+
export { LambderMemoryIdempotencyStore } from "./stores/LambderMemoryIdempotencyStore.js";
|
|
38
61
|
// Declarative per-API policies: guards
|
|
39
|
-
export { lambderGuard } from "./
|
|
62
|
+
export { lambderGuard, lambderRateLimitKey } from "./core/LambderPolicyBuilders.js";
|
|
63
|
+
export { lambderGuardBuilder } from "./api/LambderApiGuards.js";
|
|
40
64
|
// Declarative per-API policies: rate limits
|
|
41
|
-
export {
|
|
65
|
+
export { lambderRateLimitKeyBuilder, rateLimitRefusal, DEFAULT_RATE_LIMIT_REFUSAL } from "./api/LambderApiRateLimits.js";
|
|
42
66
|
// Typed translations (standalone, isomorphic)
|
|
43
67
|
export { createLambderI18n } from "./shared/LambderI18n.js";
|
|
68
|
+
export { resolveApiOutcome } from "./shared/wire/LambderApiOutcome.js";
|
|
44
69
|
export { createContext, isV2HttpEvent } from "./core/LambderContext.js";
|
|
45
70
|
// Request payload compression: the wire format LambderCaller and the server share.
|
|
46
|
-
export { COMPRESSED_PAYLOAD_GZ_FIELD, COMPRESSED_PAYLOAD_BR_FIELD, COMPRESSED_PAYLOAD_BYTES_FIELD, DEFAULT_REQUEST_COMPRESSION_SETTINGS, DEFAULT_MAX_RESTORED_PAYLOAD_BYTES,
|
|
71
|
+
export { COMPRESSED_PAYLOAD_GZ_FIELD, COMPRESSED_PAYLOAD_BR_FIELD, COMPRESSED_PAYLOAD_BYTES_FIELD, DEFAULT_REQUEST_COMPRESSION_SETTINGS, DEFAULT_MAX_RESTORED_PAYLOAD_BYTES,
|
|
72
|
+
// The Brotli twin of the browser's compressPayloadGzip, beside it now
|
|
73
|
+
// rather than inside LambderInvokeCaller; the root entry's name is unchanged.
|
|
74
|
+
DEFAULT_INVOKE_REQUEST_COMPRESSION_SETTINGS, compressPayloadBrotli, } from "./shared/wire/LambderRequestPayload.js";
|
|
47
75
|
// Cookies (res.setCookie / res.clearCookie build on these; exported for code holding a LambderResponse)
|
|
48
|
-
export { serializeCookie, serializeClearCookie, resolveCookieDomain } from "./
|
|
76
|
+
export { serializeCookie, serializeClearCookie, resolveCookieDomain } from "./shared/wire/LambderCookie.js";
|
|
@@ -21,106 +21,18 @@
|
|
|
21
21
|
* tests.
|
|
22
22
|
*/
|
|
23
23
|
import type { APIGatewayProxyEventV2, Context } from "aws-lambda";
|
|
24
|
+
import { type LambderInvokeFailure, type LambderInvokeOutcome } from "./LambderInvokeOutcome.js";
|
|
24
25
|
import type { LambdaClient, LambdaClientConfig } from "@aws-sdk/client-lambda";
|
|
25
|
-
import type {
|
|
26
|
-
import { type
|
|
27
|
-
import { type
|
|
28
|
-
import { type
|
|
29
|
-
import { type LambderCompressionOption, type LambderCompressionSettings } from "../shared/LambderCompressionOption.js";
|
|
30
|
-
import { type LambderCompressedBrotliPayload } from "../shared/LambderRequestPayload.js";
|
|
31
|
-
/** Marks a synthesized request as an invoke, for guards and hooks that want to tell. Not an authorization. */
|
|
32
|
-
export declare const LAMBDER_INVOKE_HEADER = "x-lambder-invoke";
|
|
33
|
-
/** The invoking function's name, when the caller runs in Lambda; for the callee's logs. */
|
|
34
|
-
export declare const LAMBDER_INVOKED_BY_HEADER = "x-lambder-invoked-by";
|
|
35
|
-
/** The value of the marker header; a future incompatible event shape would bump it. */
|
|
36
|
-
export declare const LAMBDER_INVOKE_PROTOCOL = "1";
|
|
26
|
+
import type { LambderApiContractShape } from "../shared/wire/LambderApiContract.js";
|
|
27
|
+
import { type LambderCallArgs, type LambderContractOutputOf, type LambderGuardInputsProviderOption, type LambderSharedCallOptions } from "../shared/wire/LambderCallOptions.js";
|
|
28
|
+
import { type LambderCompressionOption } from "../shared/wire/LambderCompressionOption.js";
|
|
29
|
+
import { type LambderInvokeSession, type LambderLambdaHttpResult } from "./LambderLambdaEvent.js";
|
|
37
30
|
/**
|
|
38
31
|
* Lambda caps a synchronous invoke's request and its response at about 6MB;
|
|
39
32
|
* the same guard threshold finalizeResponse applies to an answer, applied
|
|
40
33
|
* here to the event before it is sent.
|
|
41
34
|
*/
|
|
42
35
|
export declare const LAMBDER_INVOKE_MAX_EVENT_BYTES = 5500000;
|
|
43
|
-
/** Request Brotli when `requestCompression: true`: the HTTP request threshold, at the quality every other Lambder site uses. */
|
|
44
|
-
export declare const DEFAULT_INVOKE_REQUEST_COMPRESSION_SETTINGS: LambderCompressionSettings;
|
|
45
|
-
export type LambderInvokeFailureReason = LambderApiFailureReason | 'crash' | 'protocol' | 'payloadTooLarge';
|
|
46
|
-
/** Lambda's own error payload for a FunctionError invocation. */
|
|
47
|
-
export type LambderInvokeFunctionError = {
|
|
48
|
-
errorType?: string;
|
|
49
|
-
errorMessage?: string;
|
|
50
|
-
trace?: string[];
|
|
51
|
-
};
|
|
52
|
-
export type LambderInvokeFailure = {
|
|
53
|
-
ok: false;
|
|
54
|
-
reason: LambderInvokeFailureReason;
|
|
55
|
-
/** HTTP status, when the callee answered. */
|
|
56
|
-
status?: number;
|
|
57
|
-
/** Envelope errorMessage, when the callee provided one. */
|
|
58
|
-
errorMessage?: any;
|
|
59
|
-
/** Seconds to wait before retrying, from the answer's Retry-After header. */
|
|
60
|
-
retryAfterSeconds?: number;
|
|
61
|
-
/** Always present: the error api() throws for this failure, with the callee's error as its cause when one is known. */
|
|
62
|
-
error: LambderInvokeError;
|
|
63
|
-
/** Zod issue detail for 'validation'. */
|
|
64
|
-
zodError?: LambderValidationError;
|
|
65
|
-
/** The parsed envelope, when one came back. */
|
|
66
|
-
response?: LambderApiResponse<any>;
|
|
67
|
-
/** The callee's crash detail, when its global error handler sent one (the envelope's `crash` field). */
|
|
68
|
-
crash?: LambderCrashDetail;
|
|
69
|
-
/** Lambda's error payload for reason 'crash'. */
|
|
70
|
-
functionError?: LambderInvokeFunctionError;
|
|
71
|
-
/** The answer's logList; empty when no envelope came back. */
|
|
72
|
-
logList: unknown[];
|
|
73
|
-
/** For 'payloadTooLarge': the event's byte size. */
|
|
74
|
-
bytes?: number;
|
|
75
|
-
};
|
|
76
|
-
export type LambderInvokeOutcome<T> = {
|
|
77
|
-
ok: true;
|
|
78
|
-
payload: T;
|
|
79
|
-
response: LambderApiResponse<T>;
|
|
80
|
-
logList: unknown[];
|
|
81
|
-
} | LambderInvokeFailure;
|
|
82
|
-
type LambderInvokeErrorInit = {
|
|
83
|
-
message: string;
|
|
84
|
-
reason: LambderInvokeFailureReason;
|
|
85
|
-
apiName: string;
|
|
86
|
-
functionName: string;
|
|
87
|
-
status?: number;
|
|
88
|
-
errorMessage?: any;
|
|
89
|
-
crash?: LambderCrashDetail;
|
|
90
|
-
functionError?: LambderInvokeFunctionError;
|
|
91
|
-
logList: unknown[];
|
|
92
|
-
zodError?: LambderValidationError;
|
|
93
|
-
retryAfterSeconds?: number;
|
|
94
|
-
bytes?: number;
|
|
95
|
-
cause?: unknown;
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* What api() throws. Its message names the function, the API and the reason,
|
|
99
|
-
* so an error reporter that fingerprints on the message groups one broken
|
|
100
|
-
* API into one row; its cause is the callee's own error rebuilt from the
|
|
101
|
-
* crash detail (or Lambda's FunctionError, or the SDK's rejection), so a
|
|
102
|
-
* reporter that walks causes stores the callee's stack.
|
|
103
|
-
*/
|
|
104
|
-
export declare class LambderInvokeError extends Error {
|
|
105
|
-
/** Brand for detection across duplicate lambder installs, like LambderApiError. */
|
|
106
|
-
readonly isLambderInvokeError = true;
|
|
107
|
-
readonly reason: LambderInvokeFailureReason;
|
|
108
|
-
readonly apiName: string;
|
|
109
|
-
readonly functionName: string;
|
|
110
|
-
readonly status?: number;
|
|
111
|
-
readonly errorMessage?: any;
|
|
112
|
-
readonly crash?: LambderCrashDetail;
|
|
113
|
-
readonly functionError?: LambderInvokeFunctionError;
|
|
114
|
-
readonly logList: unknown[];
|
|
115
|
-
readonly zodError?: LambderValidationError;
|
|
116
|
-
readonly retryAfterSeconds?: number;
|
|
117
|
-
readonly bytes?: number;
|
|
118
|
-
/** The full failure outcome; it carries this error and this error carries it. */
|
|
119
|
-
outcome: LambderInvokeFailure;
|
|
120
|
-
constructor(init: LambderInvokeErrorInit);
|
|
121
|
-
}
|
|
122
|
-
/** Brand-based type guard (see LambderInvokeError.isLambderInvokeError). */
|
|
123
|
-
export declare const isLambderInvokeError: (err: unknown) => err is LambderInvokeError;
|
|
124
36
|
/** What a transport hands back: Lambda's FunctionError marker (null when the function returned normally) and the parsed JSON it returned. */
|
|
125
37
|
export type LambderInvokeTransportResult = {
|
|
126
38
|
functionError: string | null;
|
|
@@ -144,35 +56,39 @@ export type LambderInvokeFailureHandler = (failure: LambderInvokeFailure, info:
|
|
|
144
56
|
apiName: string;
|
|
145
57
|
functionName: string;
|
|
146
58
|
}) => void | Promise<void>;
|
|
147
|
-
/**
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
export type LambderInvokeCallOptions = {
|
|
153
|
-
/**
|
|
154
|
-
timeoutMs?: number;
|
|
155
|
-
/** External abort signal, combined with the timeout when both are set. */
|
|
156
|
-
signal?: AbortSignal;
|
|
157
|
-
/** Overrides the constructor's requestCompression for this call: false sends the payload plainly, true compresses it regardless of the threshold. Either way it is only sent compressed when that is smaller. */
|
|
158
|
-
compressRequest?: boolean;
|
|
159
|
-
/** Forwarded as X-Forwarded-For, so ctx.ip on the callee is the end user's address rather than nothing. */
|
|
59
|
+
/**
|
|
60
|
+
* Per-call options: the request extras both callers share (see
|
|
61
|
+
* LambderSharedCallOptions; a timeout here bounds the wait only, since the
|
|
62
|
+
* callee keeps running regardless) plus the two an invoke has of its own.
|
|
63
|
+
*/
|
|
64
|
+
export type LambderInvokeCallOptions = LambderSharedCallOptions & {
|
|
65
|
+
/** The address the callee sees as ctx.ip: it becomes the synthesized event's requestContext.http.sourceIp. Empty when the call supplies none. */
|
|
160
66
|
clientIp?: string;
|
|
161
|
-
/** Extra request headers the callee sees. */
|
|
162
|
-
headers?: Record<string, string>;
|
|
163
|
-
/** Values for the API's guardInput-mode guards, keyed by guard name; the contract makes this REQUIRED for APIs that declare such guards, except those a guardInputsProvider covers. */
|
|
164
|
-
guardInputs?: Record<string, unknown>;
|
|
165
|
-
/** Replay-protection key for APIs declared idempotent on the callee. Same rules as LambderCaller: unguessable, at least 16 characters, one per logical operation. */
|
|
166
|
-
idempotencyKey?: string;
|
|
167
67
|
/** A user's session, so a session API on the callee runs on their behalf. */
|
|
168
68
|
session?: LambderInvokeSession;
|
|
169
69
|
};
|
|
170
70
|
type LambderInvokeCallerBaseOptions = {
|
|
171
71
|
/** Function name or ARN. */
|
|
172
72
|
functionName: string;
|
|
173
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* A ready client, e.g. one shared with the rest of the app. It keeps
|
|
75
|
+
* whatever `maxAttempts` it was built with, which is the SDK's own 3
|
|
76
|
+
* unless the app said otherwise: `clientConfig` below is not consulted
|
|
77
|
+
* for a client this caller did not create, and a retry at that layer
|
|
78
|
+
* re-executes a callee whose response was merely lost. Build it with
|
|
79
|
+
* `{ maxAttempts: 1 }`, or send an `idempotencyKey` and let the callee
|
|
80
|
+
* settle the repeat.
|
|
81
|
+
*/
|
|
174
82
|
client?: LambdaClient;
|
|
175
|
-
/**
|
|
83
|
+
/**
|
|
84
|
+
* Otherwise the client is created from this on the first call (region,
|
|
85
|
+
* credentials, maxAttempts). `maxAttempts` defaults to 1 here rather than
|
|
86
|
+
* to the SDK's 3: a RequestResponse invoke whose response is lost has
|
|
87
|
+
* already run the callee, so a retry at this layer executes the operation
|
|
88
|
+
* a second time, and the transport contract says one call is one delivery
|
|
89
|
+
* attempt. Raise it deliberately if the callee is idempotent, or send an
|
|
90
|
+
* `idempotencyKey` and let the callee settle it.
|
|
91
|
+
*/
|
|
176
92
|
clientConfig?: LambdaClientConfig;
|
|
177
93
|
/** Must match the callee's apiPath. Default: "/api". */
|
|
178
94
|
apiPath?: string;
|
|
@@ -207,15 +123,6 @@ type LambderInvokeCallerBaseOptions = {
|
|
|
207
123
|
};
|
|
208
124
|
/** Constructor options: the base options plus guardInputsProvider, mandatory once TProvided names guards. */
|
|
209
125
|
export type LambderInvokeCallerOptions<TContract, TProvided extends string = never> = LambderInvokeCallerBaseOptions & LambderGuardInputsProviderOption<TContract, TProvided>;
|
|
210
|
-
/** The decoded HTTP answer of request(): status, lowercased headers, cookies and the body bytes (decompressed when the callee compressed them). */
|
|
211
|
-
export type LambderInvokeHttpResult = {
|
|
212
|
-
statusCode: number;
|
|
213
|
-
headers: Record<string, string>;
|
|
214
|
-
cookies: string[];
|
|
215
|
-
body: Buffer;
|
|
216
|
-
text: () => string;
|
|
217
|
-
json: () => unknown;
|
|
218
|
-
};
|
|
219
126
|
export type LambderInvokeRequestInit = {
|
|
220
127
|
/** Default: GET. */
|
|
221
128
|
method?: string;
|
|
@@ -246,18 +153,11 @@ export type LambderInvokeEventInit = {
|
|
|
246
153
|
session?: LambderInvokeSession;
|
|
247
154
|
sessionTokenCookieKey?: string;
|
|
248
155
|
};
|
|
249
|
-
/**
|
|
250
|
-
* Brotli one payload's JSON for sending, or null when the plain JSON should
|
|
251
|
-
* go instead: the browser's compressPayloadGzip with Brotli, because both
|
|
252
|
-
* ends are Node. The threshold and the only-when-smaller rule are
|
|
253
|
-
* compressPayloadWith's, shared with the gzip side.
|
|
254
|
-
*/
|
|
255
|
-
export declare const compressPayloadBrotli: (json: string, minBytes: number, quality: number) => Promise<LambderCompressedBrotliPayload | null>;
|
|
256
156
|
/**
|
|
257
157
|
* @typeParam TContract - The callee's API contract (`typeof lambder.ApiContract`, imported type-only), for typed names, payloads, results and guard inputs.
|
|
258
158
|
* @typeParam TProvidedGuards - Guard names guardInputsProvider covers; those APIs' options argument becomes optional.
|
|
259
159
|
*/
|
|
260
|
-
export default class LambderInvokeCaller<TContract extends
|
|
160
|
+
export default class LambderInvokeCaller<TContract extends LambderApiContractShape = any, TProvidedGuards extends string = never> {
|
|
261
161
|
private readonly functionName;
|
|
262
162
|
private readonly apiPath;
|
|
263
163
|
private readonly apiVersion?;
|
|
@@ -283,24 +183,31 @@ export default class LambderInvokeCaller<TContract extends ApiContractShape = an
|
|
|
283
183
|
* A transport that runs a callee's handler in this process, the way
|
|
284
184
|
* Lambda would: a thrown error becomes a FunctionError payload. For
|
|
285
185
|
* tests that want the real handlers behind the real envelope.
|
|
186
|
+
*
|
|
187
|
+
* It honours the signal the way lambderHandlerTransport does, by ending
|
|
188
|
+
* the wait: a function call in this process cannot be cancelled, so the
|
|
189
|
+
* handler runs to completion regardless and what a timeout buys is the
|
|
190
|
+
* caller's answer. Ignoring it made timeoutMs a no-op here.
|
|
286
191
|
*/
|
|
287
192
|
static localTransport(handler: (event: APIGatewayProxyEventV2, context: Context) => Promise<unknown>, context?: Partial<Context>): LambderInvokeTransport;
|
|
288
193
|
private loadSdk;
|
|
289
194
|
private invokeThroughSdk;
|
|
290
|
-
/** Delivers one event, serialized exactly once; a rejected transport
|
|
291
|
-
private
|
|
292
|
-
/** The function's answer as an HTTP result; throws when it is not one, or its compressed body cannot be restored. */
|
|
293
|
-
private decodeHttpResult;
|
|
195
|
+
/** Delivers one event, serialized exactly once; an event over the invoke cap, a rejected transport, or one that answered after the call was given up on, is a failure. */
|
|
196
|
+
private deliverEvent;
|
|
294
197
|
/** Builds the failure and its error, reports it once, and hands it back. */
|
|
295
|
-
private
|
|
198
|
+
private failureOutcome;
|
|
296
199
|
private surfaceLogs;
|
|
297
200
|
/** One call, one outcome. Never throws; api() is what throws. */
|
|
298
201
|
private dispatch;
|
|
299
202
|
/**
|
|
300
203
|
* Full-fidelity call: resolves to a discriminated LambderInvokeOutcome
|
|
301
204
|
* instead of throwing. Never throws; for sites that degrade gracefully.
|
|
205
|
+
*
|
|
206
|
+
* The output is computed from the contract in the return type rather than
|
|
207
|
+
* taken as a type parameter, so a call site cannot replace it by
|
|
208
|
+
* annotating what it assigns to.
|
|
302
209
|
*/
|
|
303
|
-
apiOutcome<TApiName extends keyof TContract & string = string
|
|
210
|
+
apiOutcome<TApiName extends keyof TContract & string = string>(apiName: TApiName, ...rest: LambderCallArgs<TContract, TApiName, TProvidedGuards, LambderInvokeCallOptions>): Promise<LambderInvokeOutcome<LambderContractOutputOf<TContract, TApiName>>>;
|
|
304
211
|
/**
|
|
305
212
|
* The declared output, or a thrown LambderInvokeError carrying the
|
|
306
213
|
* outcome. A failed dependency is a failed request: the throw reaches the
|
|
@@ -310,13 +217,13 @@ export default class LambderInvokeCaller<TContract extends ApiContractShape = an
|
|
|
310
217
|
* reason (LambderApiAnswer), so a nullable output is the one place null
|
|
311
218
|
* arrives.
|
|
312
219
|
*/
|
|
313
|
-
api<TApiName extends keyof TContract & string = string
|
|
220
|
+
api<TApiName extends keyof TContract & string = string>(apiName: TApiName, ...rest: LambderCallArgs<TContract, TApiName, TProvidedGuards, LambderInvokeCallOptions>): Promise<LambderContractOutputOf<TContract, TApiName>>;
|
|
314
221
|
/**
|
|
315
222
|
* Any route of the callee, untyped: the synthesized request and the
|
|
316
223
|
* decoded answer, whatever its status. Throws a LambderInvokeError only
|
|
317
224
|
* when no HTTP answer came back (a rejected invoke, a FunctionError, a
|
|
318
225
|
* non-HTTP answer); those go through onFailure like an API call's.
|
|
319
226
|
*/
|
|
320
|
-
request(init: LambderInvokeRequestInit): Promise<
|
|
227
|
+
request(init: LambderInvokeRequestInit): Promise<LambderLambdaHttpResult>;
|
|
321
228
|
}
|
|
322
229
|
export {};
|