@bifravst/aws-cdk-lambda-helpers 2.2.33 → 2.3.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.
@@ -1,11 +1,17 @@
1
1
  import { aws_logs as Logs, Names, RemovalPolicy, Stack } from 'aws-cdk-lib';
2
2
  import { Construct } from 'constructs';
3
+ import { isTest } from './isTest.js';
3
4
  export class LambdaLogGroup extends Construct {
4
5
  logGroup;
5
- constructor(parent, id, retention = Logs.RetentionDays.ONE_DAY) {
6
+ constructor(parent, id,
7
+ // Defaults to 30 days for production, 1 day for test
8
+ retention) {
6
9
  super(parent, id);
7
10
  this.logGroup = new Logs.LogGroup(this, 'logGroup', {
8
- retention,
11
+ retention: retention ??
12
+ (isTest(this)
13
+ ? Logs.RetentionDays.ONE_DAY
14
+ : Logs.RetentionDays.ONE_MONTH),
9
15
  logGroupName: `/${Stack.of(this).stackName}/fn/${id}-${Names.uniqueId(this)}`,
10
16
  logGroupClass: Logs.LogGroupClass.STANDARD, // INFREQUENT_ACCESS does not support custom metrics
11
17
  removalPolicy: this.node.getContext('isTest') === true
@@ -0,0 +1,2 @@
1
+ import type { Construct } from 'constructs';
2
+ export declare const isTest: (construct: Construct) => boolean;
@@ -0,0 +1 @@
1
+ export const isTest = (construct) => construct.node.tryGetContext('isTest') === true;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,16 @@
1
+ import assert from 'node:assert';
2
+ import { describe, it, mock } from 'node:test';
3
+ import { isTest } from './isTest.js';
4
+ void describe('isTest()', () => {
5
+ void it('should return true if the construct is a test', () => {
6
+ const construct = {
7
+ node: {
8
+ tryGetContext: mock.fn(() => true),
9
+ },
10
+ };
11
+ const result = isTest(construct);
12
+ assert.equal(result, true);
13
+ assert.equal(construct.node.tryGetContext.mock.calls.length, 1);
14
+ assert.equal(construct.node.tryGetContext.mock.calls[0]?.arguments[0], 'isTest');
15
+ });
16
+ });
@@ -1,3 +1,4 @@
1
1
  export * from './checksumOfFiles.js';
2
2
  export * from './commonParent.js';
3
3
  export * from './findDependencies.js';
4
+ export * from './isTest.js';
package/dist/src/util.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export * from './checksumOfFiles.js';
2
2
  export * from './commonParent.js';
3
3
  export * from './findDependencies.js';
4
+ export * from './isTest.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bifravst/aws-cdk-lambda-helpers",
3
- "version": "2.2.33",
3
+ "version": "2.3.1",
4
4
  "description": "Helper functions which simplify working with TypeScript lambdas for AWS CDK.",
5
5
  "exports": {
6
6
  ".": {
@@ -51,8 +51,8 @@
51
51
  "author": "Nordic Semiconductor ASA | nordicsemi.no",
52
52
  "license": "BSD-3-Clause",
53
53
  "devDependencies": {
54
- "@aws-sdk/client-cloudformation": "3.712.0",
55
- "@aws-sdk/client-dynamodb": "3.712.0",
54
+ "@aws-sdk/client-cloudformation": "3.713.0",
55
+ "@aws-sdk/client-dynamodb": "3.713.0",
56
56
  "@bifravst/cloudformation-helpers": "9.1.1",
57
57
  "@bifravst/eslint-config-typescript": "6.1.19",
58
58
  "@bifravst/from-env": "3.0.2",
@@ -62,7 +62,7 @@
62
62
  "@types/node": "22.10.2",
63
63
  "@types/yazl": "2.4.5",
64
64
  "cdk": "2.173.1",
65
- "commitlint": "19.6.0",
65
+ "commitlint": "19.6.1",
66
66
  "husky": "9.1.7",
67
67
  "id128": "1.6.6",
68
68
  "tsx": "4.19.2"
@@ -115,7 +115,7 @@
115
115
  "yazl": "3.3.1"
116
116
  },
117
117
  "peerDependencies": {
118
- "@bifravst/aws-ssm-settings-helpers": "^1.2.78",
118
+ "@bifravst/aws-ssm-settings-helpers": "^1.2.79",
119
119
  "aws-cdk-lib": "^2.173.1",
120
120
  "constructs": "^10.4.2"
121
121
  }