@lafken/common 0.12.4 → 0.12.5
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.
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
import type { ClassResource } from '../types';
|
|
2
|
-
type InstanceMethod<T extends ClassResource, M extends keyof InstanceType<T>> = InstanceType<T>[M] extends (...args: any[]) => any ? InstanceType<T>[M] : never;
|
|
3
|
-
interface ExecuteLambdaProps<T extends ClassResource, M extends keyof InstanceType<T>> {
|
|
2
|
+
export type InstanceMethod<T extends ClassResource, M extends keyof InstanceType<T>> = InstanceType<T>[M] extends (...args: any[]) => any ? InstanceType<T>[M] : never;
|
|
3
|
+
export interface ExecuteLambdaProps<T extends ClassResource, M extends keyof InstanceType<T>> {
|
|
4
4
|
method: M;
|
|
5
5
|
params?: Parameters<InstanceMethod<T, M>>;
|
|
6
6
|
}
|
|
7
|
+
export interface ExecuteLambdaWithEventProps<T extends ClassResource, M extends keyof InstanceType<T>> {
|
|
8
|
+
method: M;
|
|
9
|
+
event: unknown;
|
|
10
|
+
context?: unknown;
|
|
11
|
+
}
|
|
7
12
|
export declare const executeLambda: <T extends ClassResource, M extends keyof InstanceType<T>>(classResource: T, props: ExecuteLambdaProps<T, M>) => Promise<Awaited<ReturnType<InstanceMethod<T, M>>>>;
|
|
8
|
-
export
|
|
13
|
+
export declare const executeLambdaWithEvent: <T extends ClassResource, M extends keyof InstanceType<T>>(classResource: T, props: ExecuteLambdaWithEventProps<T, M>) => Promise<Awaited<ReturnType<InstanceMethod<T, M>>>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.executeLambda = void 0;
|
|
3
|
+
exports.executeLambdaWithEvent = exports.executeLambda = void 0;
|
|
4
4
|
const decorators_1 = require("../decorators");
|
|
5
5
|
const build_env_utils_1 = require("./build-env.utils");
|
|
6
6
|
const executeLambda = async (classResource, props) => {
|
|
@@ -26,3 +26,13 @@ const executeLambda = async (classResource, props) => {
|
|
|
26
26
|
return instance[methodName](event, context);
|
|
27
27
|
};
|
|
28
28
|
exports.executeLambda = executeLambda;
|
|
29
|
+
const executeLambdaWithEvent = async (classResource, props) => {
|
|
30
|
+
if (!(0, build_env_utils_1.isBuildEnvironment)()) {
|
|
31
|
+
throw new Error('executeLambda: Build environment is not enabled. ' +
|
|
32
|
+
'Call enableBuildEnvVariable() before defining decorated classes.');
|
|
33
|
+
}
|
|
34
|
+
const instance = new classResource();
|
|
35
|
+
const methodName = props.method;
|
|
36
|
+
return instance[methodName](props.event, props.context);
|
|
37
|
+
};
|
|
38
|
+
exports.executeLambdaWithEvent = executeLambdaWithEvent;
|
package/package.json
CHANGED