@lafken/common 0.11.8 → 0.11.9

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.
@@ -51,6 +51,43 @@ export interface AliasConfig {
51
51
  */
52
52
  provisionedExecutions?: number;
53
53
  }
54
+ export interface LoggingConfig {
55
+ /**
56
+ * Log format for the Lambda function.
57
+ *
58
+ * Controls the format of the log records written to CloudWatch.
59
+ * - `'Text'`: Unstructured text output (default Lambda behaviour).
60
+ * - `'JSON'`: Structured JSON records, enabling `applicationLogLevel`
61
+ * and `systemLogLevel`.
62
+ */
63
+ logFormat: 'text' | 'json';
64
+ /**
65
+ * Log retention period in days.
66
+ *
67
+ * Specifies the number of days to retain Lambda invocation logs
68
+ * in the CloudWatch Log Group before they are automatically deleted.
69
+ * When omitted, the log group never expires.
70
+ */
71
+ retentionInDays?: number;
72
+ /**
73
+ * Application-level log verbosity.
74
+ *
75
+ * Only valid when `logFormat` is `'json'`.
76
+ * Controls the level of logs emitted by your function code.
77
+ *
78
+ * Supported values: `'trace'` | `'debug'` | `'info'` | `'warn'` | `'error'` | `'fatal'`
79
+ */
80
+ applicationLogLevel?: 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
81
+ /**
82
+ * System-level log verbosity.
83
+ *
84
+ * Only valid when `logFormat` is `'json'`.
85
+ * Controls the level of logs emitted by the Lambda runtime itself.
86
+ *
87
+ * Supported values: `'debug'` | `'info'` | `'warn'`
88
+ */
89
+ systemLogLevel?: 'debug' | 'info' | 'warn';
90
+ }
54
91
  export interface LambdaProps {
55
92
  /**
56
93
  * Lambda execution timeout.
@@ -170,6 +207,20 @@ export interface LambdaProps {
170
207
  * { name: 'live', provisionedExecutions: 5 }
171
208
  */
172
209
  alias?: AliasConfig;
210
+ /**
211
+ * Logging configuration for the Lambda function.
212
+ *
213
+ * When provided, configures the CloudWatch logging behaviour for the
214
+ * Lambda function. If `logGroup` is specified, a `CloudwatchLogGroup`
215
+ * resource will be created and linked automatically.
216
+ *
217
+ * @example
218
+ * { logFormat: 'Text', logGroup: { name: '/aws/lambda/my-fn', retentionInDays: 30 } }
219
+ *
220
+ * @example
221
+ * { logFormat: 'JSON', applicationLogLevel: 'WARN', systemLogLevel: 'INFO' }
222
+ */
223
+ loggingConfig?: LoggingConfig;
173
224
  }
174
225
  export interface LambdaMetadata {
175
226
  name: string;
@@ -1,4 +1,4 @@
1
- export type OutputType = 'arn' | 'id';
1
+ export type OutputType = 'arn' | 'id' | (string & {});
2
2
  export type GetResourceValue<T = string, V = OutputType> = (value: T, type: V) => any;
3
3
  /**
4
4
  * Common fields shared by all resource output definitions.
@@ -1,39 +1,29 @@
1
- import type { ResourceIdentifiers, ScopedResourceNames } from './utilities.types';
2
- export type ModuleGlobalReferenceNames = 'api' | 'user-pool' | 'user-pool-client' | 'bucket' | 'dynamo' | 'event-bus' | 'resource';
3
- export interface ModulesAvailable {
4
- }
5
- export interface AuthAvailable {
6
- }
7
- export interface BucketAvailable {
8
- }
9
- export interface ApiRestAvailable {
10
- }
11
- export interface ApiAuthorizerAvailable {
12
- }
13
- export interface EventBusAvailable {
14
- }
15
- export interface DynamoTableAvailable {
16
- }
17
- export interface ResourceAvailable {
18
- }
19
- type ResourceNames<T> = keyof T | (string & {});
20
- type StackResourceName<T, S extends ModuleGlobalReferenceNames> = `${S}::${Extract<keyof T, string | number>}` | (string & {});
21
- export type ModuleNames = ResourceNames<ModulesAvailable>;
22
- export type AuthNames = ResourceNames<AuthAvailable>;
23
- export type UserPoolScopedNames = StackResourceName<AuthAvailable, 'user-pool'>;
24
- export type UserPoolClientScopedNames = StackResourceName<AuthAvailable, 'user-pool-client'>;
25
- export type BucketNames = ResourceNames<BucketAvailable>;
26
- export type ResourcesScopedNames = StackResourceName<ResourceAvailable, 'resource'>;
27
- export type BucketScopedNames = StackResourceName<BucketAvailable, 'bucket'>;
28
- export type ApiRestNames = ResourceNames<ApiRestAvailable>;
29
- export type ApiRestScopedNames = StackResourceName<ApiRestAvailable, 'api'>;
30
- export type ApiAuthorizerNames = ResourceNames<ApiAuthorizerAvailable>;
31
- export type EventBusNames = ResourceNames<EventBusAvailable>;
32
- export type EventBusScopedNames = StackResourceName<EventBusAvailable, 'event-bus'>;
33
- export type DynamoTableNames = ResourceNames<DynamoTableAvailable>;
34
- export type DynamoTableScopedNames = StackResourceName<DynamoTableAvailable, 'dynamo'>;
35
- export type StateMachineNames = ResourceIdentifiers<ModulesAvailable, 'StateMachine'> | (string & {});
36
- export type StateMachineScopedNames = ScopedResourceNames<ModulesAvailable, 'StateMachine', 'state-machine'> | (string & {});
37
- export type QueueNames = ResourceIdentifiers<ModulesAvailable, 'Queue'> | (string & {});
38
- export type QueueScopedNames = ScopedResourceNames<ModulesAvailable, 'Queue', 'queue'> | (string & {});
39
- export {};
1
+ export interface SharedResourceNames {
2
+ }
3
+ export interface SharedReferenceResources {
4
+ }
5
+ export type ResourceScopedKeys<T> = {
6
+ [Scope in keyof T]: `${Scope & string}::${T[Scope] & string}`;
7
+ }[keyof T];
8
+ export type ResourceScopeKeys<T, Scope extends string> = T extends Record<Scope, string> ? T[Scope] : string & {};
9
+ export type AvailableReference = [keyof SharedReferenceResources] extends [never] ? string : ResourceScopedKeys<SharedReferenceResources>;
10
+ export type ApiNames = ResourceScopeKeys<SharedResourceNames, 'api'>;
11
+ export type ApiReferenceNames = ResourceScopeKeys<SharedReferenceResources, 'api'>;
12
+ export type BucketNames = ResourceScopeKeys<SharedResourceNames, 'bucket'>;
13
+ export type BucketReferenceNames = ResourceScopeKeys<SharedReferenceResources, 'bucket'>;
14
+ export type DynamoTableNames = ResourceScopeKeys<SharedResourceNames, 'dynamo'>;
15
+ export type DynamoReferenceNames = ResourceScopeKeys<SharedReferenceResources, 'dynamo'>;
16
+ export type StateMachineNames = ResourceScopeKeys<SharedResourceNames, 'state-machine'>;
17
+ export type StateMachineReferenceNames = ResourceScopeKeys<SharedReferenceResources, 'state-machine'>;
18
+ export type EventBusNames = ResourceScopeKeys<SharedResourceNames, 'event-bus'>;
19
+ export type EventBusReferenceNames = ResourceScopeKeys<SharedReferenceResources, 'event-bus'>;
20
+ export type EventRuleReferenceNames = ResourceScopeKeys<SharedReferenceResources, 'event-rule'>;
21
+ export type QueueNames = ResourceScopeKeys<SharedResourceNames, 'queue'>;
22
+ export type QueueReferenceNames = ResourceScopeKeys<SharedReferenceResources, 'queue'>;
23
+ export type UserPoolNames = ResourceScopeKeys<SharedResourceNames, 'user-pool'>;
24
+ export type UserPoolReferenceNames = ResourceScopeKeys<SharedReferenceResources, 'user-pool'>;
25
+ export type UserPoolClientNames = ResourceScopeKeys<SharedResourceNames, 'user-pool-client'>;
26
+ export type UserPoolClientReferenceNames = ResourceScopeKeys<SharedReferenceResources, 'user-pool-client'>;
27
+ export type ApiAuthorizerNames = ResourceScopeKeys<SharedResourceNames, 'api-authorizer'>;
28
+ export type ScheduleReferenceNames = ResourceScopeKeys<SharedReferenceResources, 'schedule'>;
29
+ export type RegisterNamespaces = 'api' | 'bucket' | 'dynamo' | 'state-machine' | 'queue' | 'authentication' | 'api-authorizer' | 'user-pool' | 'user-pool-client' | 'schedule' | 'event-bus' | 'event-rule' | (string & {});
@@ -1,5 +1,5 @@
1
1
  import type { GetResourceValue } from './output.types';
2
- import type { ApiRestScopedNames, BucketScopedNames, DynamoTableScopedNames, EventBusScopedNames, QueueScopedNames, ResourcesScopedNames, StateMachineScopedNames, UserPoolClientScopedNames, UserPoolScopedNames } from './override-resources.types';
2
+ import type { AvailableReference } from './override-resources.types';
3
3
  export interface ClassResource {
4
4
  new (...args: any[]): {};
5
5
  }
@@ -272,7 +272,7 @@ export interface GetResourceProps {
272
272
  * // Get a bucket ARN
273
273
  * getResourceValue('bucket::uploads', 'arn')
274
274
  */
275
- getResourceValue: GetResourceValue<DynamoTableScopedNames | UserPoolScopedNames | UserPoolClientScopedNames | BucketScopedNames | ApiRestScopedNames | EventBusScopedNames | StateMachineScopedNames | QueueScopedNames | ResourcesScopedNames>;
275
+ getResourceValue: GetResourceValue<AvailableReference>;
276
276
  /**
277
277
  * Retrieves a value from AWS Systems Manager Parameter Store.
278
278
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lafken/common",
3
- "version": "0.11.8",
3
+ "version": "0.11.9",
4
4
  "private": false,
5
5
  "description": "Lafken utilities - TypeScript decorator factories and metadata reflection for infrastructure-as-code decorators",
6
6
  "keywords": [
@@ -31,13 +31,13 @@
31
31
  "reflect-metadata": "0.2.2"
32
32
  },
33
33
  "devDependencies": {
34
- "@swc/core": "^1.15.21",
35
- "@swc/helpers": "^0.5.20",
36
- "@vitest/runner": "^4.1.2",
34
+ "@swc/core": "^1.15.30",
35
+ "@swc/helpers": "^0.5.21",
36
+ "@vitest/runner": "^4.1.5",
37
37
  "cdktn-vitest": "^1.0.0",
38
- "typescript": "6.0.2",
38
+ "typescript": "6.0.3",
39
39
  "unplugin-swc": "^1.5.9",
40
- "vitest": "^4.1.2"
40
+ "vitest": "^4.1.5"
41
41
  },
42
42
  "engines": {
43
43
  "node": ">=20.19"