@klarna/nest-lambda-microservice 0.2.0-beta.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/client/lambda-microservice.client.d.ts +1 -1
- package/dist/ctx-host/lambda.context.d.ts +1 -1
- package/dist/decorators/use-partial-pattern-match.js +1 -2
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/interfaces/lambda-microservice.packet.d.ts +2 -2
- package/dist/lambda/index.d.ts +1 -1
- package/dist/lambda/index.js +1 -1
- package/dist/lambda/integrations/apigateway.d.ts +1 -1
- package/dist/record-builders/custom-response.builder.js +0 -1
- package/dist/record-builders/event-bridge-request.builder.d.ts +1 -1
- package/dist/server/__mocks__/lambda-microservice.broker.js +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/lambda-microservice.broker.d.ts +0 -1
- package/dist/server/lambda-microservice.broker.js +6 -2
- package/dist/server/lambda-microservice.server.d.ts +3 -3
- package/package.json +28 -27
- package/CHANGELOG.md +0 -16
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { ClientProxy, ReadPacket, WritePacket } from '@nestjs/microservices';
|
|
2
2
|
import { PacketId } from '@nestjs/microservices/interfaces/packet.interface';
|
|
3
3
|
import { Context } from 'aws-lambda';
|
|
4
|
+
import type { LambdaMicroserviceOptions, OutgoingRequest } from '../interfaces';
|
|
4
5
|
import { EventMapper } from '../lambda';
|
|
5
6
|
import { LambdaMicroserviceBroker } from '../server';
|
|
6
|
-
import type { LambdaMicroserviceOptions, OutgoingRequest } from '../interfaces';
|
|
7
7
|
export declare const ClientToken: unique symbol;
|
|
8
8
|
export declare class LambdaMicroserviceClient extends ClientProxy {
|
|
9
9
|
protected broker: LambdaMicroserviceBroker;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BaseRpcContext } from '@nestjs/microservices';
|
|
2
1
|
import { LoggerService } from '@nestjs/common/services/logger.service';
|
|
2
|
+
import { BaseRpcContext } from '@nestjs/microservices';
|
|
3
3
|
import { Context } from 'aws-lambda';
|
|
4
4
|
export type LambdaContextArgs = [context: Context];
|
|
5
5
|
export declare class LambdaContext<T extends LoggerService> extends BaseRpcContext<LambdaContextArgs> {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UsePartialPatternMatch =
|
|
3
|
+
exports.UsePartialPatternMatch = UsePartialPatternMatch;
|
|
4
4
|
const constants_1 = require("@nestjs/microservices/constants");
|
|
5
5
|
const server_1 = require("../server");
|
|
6
6
|
const getClassMethods = (target) => {
|
|
@@ -50,4 +50,3 @@ function UsePartialPatternMatch() {
|
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
|
-
exports.UsePartialPatternMatch = UsePartialPatternMatch;
|
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export * from './client';
|
|
|
2
2
|
export * from './ctx-host';
|
|
3
3
|
export * from './decorators';
|
|
4
4
|
export * from './errors';
|
|
5
|
-
export * from './lambda';
|
|
6
5
|
export * from './interfaces';
|
|
6
|
+
export * from './lambda';
|
|
7
7
|
export * from './record-builders';
|
|
8
8
|
export * from './server';
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ __exportStar(require("./client"), exports);
|
|
|
18
18
|
__exportStar(require("./ctx-host"), exports);
|
|
19
19
|
__exportStar(require("./decorators"), exports);
|
|
20
20
|
__exportStar(require("./errors"), exports);
|
|
21
|
-
__exportStar(require("./lambda"), exports);
|
|
22
21
|
__exportStar(require("./interfaces"), exports);
|
|
22
|
+
__exportStar(require("./lambda"), exports);
|
|
23
23
|
__exportStar(require("./record-builders"), exports);
|
|
24
24
|
__exportStar(require("./server"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ReadPacket, WritePacket
|
|
2
|
-
import {
|
|
1
|
+
import { PacketId, ReadPacket, WritePacket } from '@nestjs/microservices';
|
|
2
|
+
import { APIGatewayEvent, APIGatewayProxyEventV2, Context, EventBridgeEvent, S3EventRecord, SNSMessage, SQSRecord } from 'aws-lambda';
|
|
3
3
|
import { IncomingResponseError } from '../errors';
|
|
4
4
|
export interface ContextAware {
|
|
5
5
|
context: Context;
|
package/dist/lambda/index.d.ts
CHANGED
package/dist/lambda/index.js
CHANGED
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./integrations"), exports);
|
|
18
17
|
__exportStar(require("./event-mapper"), exports);
|
|
18
|
+
__exportStar(require("./integrations"), exports);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { APIGatewayEvent, APIGatewayProxyEventV2 } from 'aws-lambda';
|
|
2
2
|
export type AnyAPIGatewayEvent = APIGatewayEvent | APIGatewayProxyEventV2;
|
|
3
3
|
export declare const isApiGatewayEvent: (event: unknown) => event is AnyAPIGatewayEvent;
|
|
4
|
-
export declare const isApiGatewayEventV1: (event: unknown) => event is
|
|
4
|
+
export declare const isApiGatewayEventV1: (event: unknown) => event is APIGatewayEvent;
|
|
5
5
|
export declare const isApiGatewayEventV2: (event: unknown) => event is APIGatewayProxyEventV2;
|
|
@@ -8,7 +8,6 @@ class CustomResponseBuilder {
|
|
|
8
8
|
this.responseTuples = responseTuples;
|
|
9
9
|
}
|
|
10
10
|
build() {
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
12
11
|
for (const [_request, response] of this.responseTuples) {
|
|
13
12
|
if (response instanceof errors_1.IncomingResponseError) {
|
|
14
13
|
throw response.cause;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Context } from 'aws-lambda';
|
|
2
|
-
import { AnyEventBridgeEvent, JSONValue } from '../lambda';
|
|
3
2
|
import { OutgoingEventBridgeRequest, RequestBuilder } from '../interfaces';
|
|
3
|
+
import { AnyEventBridgeEvent, JSONValue } from '../lambda';
|
|
4
4
|
export interface EventBridgePattern {
|
|
5
5
|
source: string;
|
|
6
6
|
detailType: string;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LambdaMicroserviceBrokerFactory = exports.mockServerResponse = exports.close = exports.listen = exports.off = exports.once = exports.emit = exports.on = exports.sendRequest = void 0;
|
|
4
|
+
const globals_1 = require("@jest/globals");
|
|
4
5
|
const jest_mock_1 = require("jest-mock");
|
|
5
6
|
const rxjs_1 = require("rxjs");
|
|
6
|
-
const globals_1 = require("@jest/globals");
|
|
7
7
|
exports.sendRequest = globals_1.jest.fn();
|
|
8
8
|
exports.on = globals_1.jest.fn();
|
|
9
9
|
exports.emit = globals_1.jest.fn();
|
package/dist/server/index.d.ts
CHANGED
package/dist/server/index.js
CHANGED
|
@@ -14,5 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./lambda-microservice.server"), exports);
|
|
18
17
|
__exportStar(require("./lambda-microservice.broker"), exports);
|
|
18
|
+
__exportStar(require("./lambda-microservice.server"), exports);
|
|
@@ -11,12 +11,16 @@ exports.RequestEvent = Symbol('Request');
|
|
|
11
11
|
exports.ResponseEvent = Symbol('Response');
|
|
12
12
|
class LambdaMicroserviceBroker extends events_1.default {
|
|
13
13
|
listen(callbackFn) {
|
|
14
|
-
|
|
14
|
+
if (callbackFn) {
|
|
15
|
+
callbackFn();
|
|
16
|
+
}
|
|
15
17
|
}
|
|
16
18
|
close(callbackFn) {
|
|
17
19
|
this.removeAllListeners(exports.ResponseEvent);
|
|
18
20
|
this.removeAllListeners(exports.RequestEvent);
|
|
19
|
-
|
|
21
|
+
if (callbackFn) {
|
|
22
|
+
callbackFn();
|
|
23
|
+
}
|
|
20
24
|
}
|
|
21
25
|
sendRequest(outgoingRequest) {
|
|
22
26
|
const responseStream$ = new rxjs_1.ReplaySubject();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
2
|
import { Logger } from '@nestjs/common';
|
|
3
|
-
import { CustomTransportStrategy, MessageHandler,
|
|
3
|
+
import { CustomTransportStrategy, MessageHandler, Server } from '@nestjs/microservices';
|
|
4
4
|
import { IncomingRequest } from '../interfaces';
|
|
5
5
|
import { LambdaMicroserviceBroker } from './lambda-microservice.broker';
|
|
6
6
|
export interface LambdaMicroserviceServerOptions {
|
|
@@ -18,9 +18,9 @@ export declare class LambdaMicroserviceServer extends Server implements CustomTr
|
|
|
18
18
|
constructor(options: LambdaMicroserviceServerOptions);
|
|
19
19
|
listen(callback: (error?: unknown) => void): Promise<void>;
|
|
20
20
|
close(): void;
|
|
21
|
-
addHandler(pattern:
|
|
21
|
+
addHandler(pattern: unknown, callback: MessageHandler, isEventHandler?: boolean, extras?: Record<string, unknown>): void;
|
|
22
22
|
protected handleMessage: (payload: IncomingRequest) => Promise<void | import("rxjs").Subscription>;
|
|
23
23
|
protected trySerializeIncomingRequest(incomingRequest: IncomingRequest): string;
|
|
24
|
-
getHandlerByPattern(messagePattern:
|
|
24
|
+
getHandlerByPattern(messagePattern: unknown): MessageHandler | null;
|
|
25
25
|
performPatternMatch(handlerPatternPart: unknown, messagePatternPart: unknown, isPartialObjectMatchAllowed?: boolean): boolean;
|
|
26
26
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@klarna/nest-lambda-microservice",
|
|
3
|
-
"version": "0.2.0
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "NestJS based microservice for writing applications that run on AWS Lambda",
|
|
5
|
-
"private": false,
|
|
6
5
|
"repository": {
|
|
7
6
|
"type": "git",
|
|
8
7
|
"url": "git@github.com:klarna-incubator/nest-lambda-microservice.git"
|
|
@@ -16,44 +15,46 @@
|
|
|
16
15
|
"build:clean": "rm -rf dist",
|
|
17
16
|
"build:ts": "tsc -p tsconfig.build.json",
|
|
18
17
|
"build:watch": "tsc -p tsconfig.build.json --watch",
|
|
19
|
-
"lint": "eslint
|
|
18
|
+
"lint": "eslint '**/*.ts' --fix && prettier . --write --list-different --ignore-unknown && tsc -p tsconfig.json --noEmit",
|
|
20
19
|
"test": "yarn test:unit && yarn test:integration",
|
|
21
|
-
"test:unit": "jest --selectProjects unit --passWithNoTests --runInBand --detectOpenHandles
|
|
22
|
-
"test:integration": "jest --selectProjects integration --passWithNoTests --runInBand --detectOpenHandles
|
|
20
|
+
"test:unit": "jest --selectProjects unit --passWithNoTests --runInBand --detectOpenHandles",
|
|
21
|
+
"test:integration": "jest --selectProjects integration --passWithNoTests --runInBand --detectOpenHandles",
|
|
23
22
|
"prettier": "prettier 'src/**/*.ts'",
|
|
24
23
|
"prettier:fix": "prettier --write 'src/**/*.ts'"
|
|
25
24
|
},
|
|
26
25
|
"dependencies": {
|
|
27
|
-
"@nestjs/common": "10.
|
|
28
|
-
"@nestjs/core": "10.
|
|
29
|
-
"@nestjs/microservices": "10.
|
|
30
|
-
"reflect-metadata": "0.
|
|
26
|
+
"@nestjs/common": "10.4.1",
|
|
27
|
+
"@nestjs/core": "10.4.1",
|
|
28
|
+
"@nestjs/microservices": "10.4.1",
|
|
29
|
+
"reflect-metadata": "0.2.2",
|
|
31
30
|
"rxjs": "7.8.1",
|
|
32
|
-
"uuid": "
|
|
31
|
+
"uuid": "10.0.0"
|
|
33
32
|
},
|
|
34
33
|
"devDependencies": {
|
|
34
|
+
"@eslint/js": "^9.9.1",
|
|
35
35
|
"@jest/globals": "29.7.0",
|
|
36
|
-
"@nestjs/testing": "10.
|
|
37
|
-
"@tsconfig/
|
|
38
|
-
"@types/aws-lambda": "8.10.
|
|
39
|
-
"@types/node": "
|
|
40
|
-
"@types/uuid": "
|
|
41
|
-
"@typescript-eslint/eslint-plugin": "6.15.0",
|
|
42
|
-
"@typescript-eslint/parser": "6.15.0",
|
|
36
|
+
"@nestjs/testing": "10.4.1",
|
|
37
|
+
"@tsconfig/node20": "20.1.4",
|
|
38
|
+
"@types/aws-lambda": "8.10.145",
|
|
39
|
+
"@types/node": "20.16.2",
|
|
40
|
+
"@types/uuid": "10.0.0",
|
|
43
41
|
"class-transformer": "0.5.1",
|
|
44
|
-
"class-validator": "0.14.
|
|
45
|
-
"eslint": "
|
|
42
|
+
"class-validator": "0.14.1",
|
|
43
|
+
"eslint": "9.9.1",
|
|
46
44
|
"eslint-config-prettier": "9.1.0",
|
|
47
|
-
"eslint-plugin-
|
|
48
|
-
"eslint-plugin-
|
|
49
|
-
"eslint-plugin-prettier": "5.
|
|
45
|
+
"eslint-plugin-jest": "28.8.1",
|
|
46
|
+
"eslint-plugin-n": "^17.10.2",
|
|
47
|
+
"eslint-plugin-prettier": "5.2.1",
|
|
48
|
+
"eslint-plugin-simple-import-sort": "^12.1.1",
|
|
50
49
|
"jest": "29.7.0",
|
|
51
|
-
"prettier": "3.
|
|
52
|
-
"ts-jest": "29.
|
|
53
|
-
"typescript": "5.
|
|
50
|
+
"prettier": "3.3.3",
|
|
51
|
+
"ts-jest": "29.2.5",
|
|
52
|
+
"typescript": "5.5.4",
|
|
53
|
+
"typescript-eslint": "^8.3.0"
|
|
54
54
|
},
|
|
55
55
|
"volta": {
|
|
56
|
-
"node": "
|
|
56
|
+
"node": "20.17.0"
|
|
57
57
|
},
|
|
58
|
-
"license": "Apache-2.0"
|
|
58
|
+
"license": "Apache-2.0",
|
|
59
|
+
"packageManager": "yarn@4.4.1"
|
|
59
60
|
}
|
package/CHANGELOG.md
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# Changelog
|
|
2
|
-
|
|
3
|
-
All notable changes to this project will be documented in this file.
|
|
4
|
-
|
|
5
|
-
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
6
|
-
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
|
-
|
|
8
|
-
## Unreleased
|
|
9
|
-
|
|
10
|
-
## 0.2.0-beta.0 - 2024-08-26
|
|
11
|
-
### Added
|
|
12
|
-
- Initial library implementation
|
|
13
|
-
|
|
14
|
-
## 0.1.0-beta.0 - 2024-08-25
|
|
15
|
-
### Added
|
|
16
|
-
- Changelog
|