@bifravst/aws-cdk-lambda-helpers 3.0.0 → 3.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.
@@ -0,0 +1,10 @@
1
+ import { aws_iam as IAM } from 'aws-cdk-lib';
2
+ import { Construct } from 'constructs';
3
+ /**
4
+ * Base role for IoT Actions that allows to publish to the 'errors' topic
5
+ */
6
+ export declare class IoTActionRole extends Construct {
7
+ readonly role: IAM.IRole;
8
+ readonly roleArn: string;
9
+ constructor(parent: Construct);
10
+ }
@@ -0,0 +1,6 @@
1
+ import { aws_logs as Logs } from 'aws-cdk-lib';
2
+ import { Construct } from 'constructs';
3
+ export declare class LambdaLogGroup extends Construct {
4
+ readonly logGroup: Logs.LogGroup;
5
+ constructor(parent: Construct, id: string, retention?: Logs.RetentionDays);
6
+ }
@@ -0,0 +1,7 @@
1
+ import { aws_lambda as Lambda } from 'aws-cdk-lib';
2
+ import { Construct } from 'constructs';
3
+ import type { PackedLambda } from './packLambda.ts';
4
+ export declare class LambdaSource extends Construct {
5
+ readonly code: Lambda.S3Code;
6
+ constructor(parent: Construct, packedLambda: Pick<PackedLambda, 'zipFilePath' | 'id' | 'hash'>);
7
+ }
@@ -0,0 +1,24 @@
1
+ import { aws_lambda as Lambda, type aws_logs as Logs } from 'aws-cdk-lib';
2
+ import { Construct } from 'constructs';
3
+ import type { PackedLambda } from './packLambda.ts';
4
+ /**
5
+ * Creates a Lambda function with useful defaults:
6
+ *
7
+ * - Code from a PackedLambda
8
+ * - Architecture: ARM64
9
+ * - Runtime: Node.js 20
10
+ * - timeout: 5 seconds
11
+ * - memorySize: 1792 MB
12
+ * - environment
13
+ * VERSION: set from the 'version' context
14
+ * NODE_NO_WARNINGS: disabled to get rid of Node.js warnings in the logs
15
+ * STACK_NAME: the current stack name
16
+ * DISABLE_METRICS: set to '1' of 'isTest'===true in the context
17
+ * - a LambdaLogGroup (if not provided)
18
+ * - policies that allow to access all SSM parameters below the current stack name
19
+ */
20
+ export declare class PackedLambdaFn extends Construct {
21
+ readonly fn: Lambda.Function;
22
+ readonly logGroup: Logs.ILogGroup;
23
+ constructor(parent: Construct, id: string, source: PackedLambda, props: Partial<Omit<Lambda.FunctionProps, 'code' | 'handler'>>);
24
+ }
@@ -0,0 +1,4 @@
1
+ export * from './IoTActionRole.ts';
2
+ export * from './LambdaLogGroup.ts';
3
+ export * from './LambdaSource.ts';
4
+ export * from './PackedLambdaFn.ts';
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Computes the combined checksum of the given files
3
+ */
4
+ export declare const checkSumOfFiles: (files: string[]) => Promise<string>;
5
+ export declare const checkSumOfStrings: (strings: string[]) => string;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Returns the common ancestor directory from a list of files
3
+ */
4
+ export declare const commonParent: (files: string[]) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Resolve project-level dependencies for the given file using TypeScript compiler API
3
+ */
4
+ export declare const findDependencies: (args: {
5
+ sourceFilePath: string;
6
+ imports?: string[];
7
+ visited?: string[];
8
+ packages?: Set<string>;
9
+ tsConfigFilePath?: string;
10
+ importsSubpathPatterns?: Record<string, string>;
11
+ }) => {
12
+ dependencies: string[];
13
+ /**
14
+ * A map of import subpath patterns to their resolved paths
15
+ * @see https://nodejs.org/api/packages.html#subpath-patterns
16
+ */
17
+ importsSubpathPatterns: Record<string, string>;
18
+ /**
19
+ * The external packages that the source file depends on
20
+ */
21
+ packages: Set<string>;
22
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { Construct } from 'constructs';
2
+ export declare const isTest: (construct: Construct) => boolean;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ export * from './packLambda.ts';
2
+ export * from './packLambdaFromPath.ts';
@@ -0,0 +1 @@
1
+ export * from './packLayer.ts';
@@ -0,0 +1,29 @@
1
+ export type PackedLambda = {
2
+ id: string;
3
+ zipFilePath: string;
4
+ handler: string;
5
+ hash: string;
6
+ };
7
+ /**
8
+ * In the bundle we only include code that's not in the layer.
9
+ */
10
+ export declare const packLambda: ({ sourceFilePath, zipFilePath, tsConfigFilePath, debug, progress, }: {
11
+ sourceFilePath: string;
12
+ zipFilePath: string;
13
+ /**
14
+ * Pass the path to the tsconfig.json file if you want to use paths from the tsconfig.json file.
15
+ */
16
+ tsConfigFilePath?: string;
17
+ debug?: (label: string, info: string) => void;
18
+ progress?: (label: string, info: string) => void;
19
+ }) => Promise<{
20
+ handler: string;
21
+ hash: string;
22
+ }>;
23
+ /**
24
+ * @see https://github.com/aws/aws-lambda-nodejs-runtime-interface-client/issues/93#issuecomment-2042201321
25
+ */
26
+ export declare class ImportFromFolderNameError extends Error {
27
+ readonly folderName: string;
28
+ constructor(folderName: string);
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,20 @@
1
+ import { type PackedLambda } from './packLambda.ts';
2
+ export declare const packLambdaFromPath: ({ id, sourceFilePath, handlerFunction: handlerFunctionArg, baseDir: baseDirArg, distDir: distDirArg, tsConfigFilePath, debug, progress, }: {
3
+ id: string;
4
+ sourceFilePath: string;
5
+ handlerFunction?: string;
6
+ /**
7
+ * @default process.cwd()
8
+ */
9
+ baseDir?: string;
10
+ /**
11
+ * @default ${baseDir}/dist/lambdas
12
+ */
13
+ distDir?: string;
14
+ /**
15
+ * Pass the path to the tsconfig.json file if you want to use paths from the tsconfig.json file.
16
+ */
17
+ tsConfigFilePath?: string;
18
+ debug?: (label: string, info: string) => void;
19
+ progress?: (label: string, info: string) => void;
20
+ }) => Promise<PackedLambda>;
@@ -0,0 +1,23 @@
1
+ export type PackedLayer = {
2
+ layerZipFilePath: string;
3
+ hash: string;
4
+ };
5
+ export declare const packLayer: ({ id, dependencies, baseDir, distDir, installCommand, }: {
6
+ id: string;
7
+ dependencies: string[];
8
+ /**
9
+ * @default process.cwd()
10
+ */
11
+ baseDir?: string;
12
+ /**
13
+ * @default ${baseDir}/dist/layers
14
+ */
15
+ distDir?: string;
16
+ /**
17
+ * Returns the command to run, the first element is the command (e.g. `npm`) and the rest are its arguments.
18
+ */
19
+ installCommand?: (args: {
20
+ packageFilePath: string;
21
+ packageLockFilePath: string;
22
+ }) => [string, ...Array<string>];
23
+ }) => Promise<PackedLayer>;
@@ -0,0 +1 @@
1
+ export declare const getFileFromZip: (zipFilePath: string, filename: string) => Promise<string>;
@@ -0,0 +1 @@
1
+ export declare const updateImports: (source: string) => string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export * from './checksumOfFiles.ts';
2
+ export * from './commonParent.ts';
3
+ export * from './findDependencies.ts';
4
+ export * from './isTest.ts';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifravst/aws-cdk-lambda-helpers",
3
- "version": "3.0.0",
3
+ "version": "3.0.1",
4
4
  "description": "Helper functions which simplify working with TypeScript lambdas for AWS CDK.",
5
5
  "exports": {
6
6
  ".": {
@@ -33,7 +33,7 @@
33
33
  "test": "node --experimental-strip-types --no-warnings --test ./src/*.spec.ts",
34
34
  "test:e2e": "node --experimental-strip-types --test e2e.spec.ts",
35
35
  "prepare": "husky",
36
- "prepublishOnly": "node --experimental-strip-types npm-compile.ts"
36
+ "prepublishOnly": "node --experimental-strip-types npm-compile.ts && npx tsc -P tsconfig.npm.json --outDir ./dist/src"
37
37
  },
38
38
  "repository": {
39
39
  "type": "git",