@lafken/common 0.14.3 → 0.15.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/README.md CHANGED
@@ -107,7 +107,7 @@ class NotificationService {
107
107
  | ------------- | ------------------- | --------------------------------------------- |
108
108
  | `timeout` | `number` | Execution timeout in seconds |
109
109
  | `memory` | `number` | Memory allocation in MB |
110
- | `runtime` | `24 \| 22 \| 20` | Node.js runtime version |
110
+ | `runtime` | `24 \| 22` | Node.js runtime version |
111
111
  | `services` | `ServicesValues` | IAM service permissions |
112
112
  | `env` | `EnvironmentValue` | Environment variables (static or dynamic) |
113
113
  | `tags` | `Record<string, string>` | Resource tags |
@@ -76,6 +76,7 @@ const getFieldMetadata = (props) => {
76
76
  let items;
77
77
  if (arrayPrimitiveType) {
78
78
  items = {
79
+ ...fieldProps.overrideItems,
79
80
  type: arrayPrimitiveType,
80
81
  name: arrayPrimitiveType,
81
82
  destinationName: arrayPrimitiveType,
@@ -110,6 +111,15 @@ const getFieldMetadata = (props) => {
110
111
  type: 'Any',
111
112
  };
112
113
  };
114
+ /**
115
+ * Drops the fields resolved by `getFieldMetadata` so a decorator's own metadata
116
+ * can be applied last without overwriting them, along with `overrideItems`,
117
+ * which is a directive rather than metadata.
118
+ */
119
+ const omitResolvedFields = (metadata) => {
120
+ const { type, name, destinationName, items, overrideItems, ...rest } = metadata;
121
+ return rest;
122
+ };
113
123
  const createFieldDecorator = ({ prefix, enableInLambdaInvocation, disablePropertiesValidation, getMetadata, }) => (props) => (target, destinationName) => {
114
124
  if (!(0, build_env_utils_1.isBuildEnvironment)() && !enableInLambdaInvocation) {
115
125
  return;
@@ -117,21 +127,23 @@ const createFieldDecorator = ({ prefix, enableInLambdaInvocation, disablePropert
117
127
  const filedKey = (0, exports.createFieldName)(prefix, field_types_1.FieldProperties.field);
118
128
  const fields = (0, utils_1.getMetadataByKey)(target, filedKey) || [];
119
129
  const propertyType = Reflect.getMetadata('design:type', target, destinationName).name;
120
- const parentMetadata = getMetadata(props);
130
+ const declaredMetadata = getMetadata(props);
131
+ const parentMetadata = omitResolvedFields(declaredMetadata);
121
132
  const metadata = [
122
133
  ...fields,
123
134
  {
124
- ...parentMetadata,
125
135
  ...getFieldMetadata({
126
136
  destinationName,
127
137
  type: propertyType,
128
138
  fieldProps: {
129
139
  ...props,
130
140
  type: parentMetadata.forceType ?? props?.type,
141
+ overrideItems: declaredMetadata.overrideItems,
131
142
  },
132
143
  prefix,
133
144
  disablePropertiesValidation,
134
145
  }),
146
+ ...parentMetadata,
135
147
  },
136
148
  ];
137
149
  Reflect.defineMetadata(filedKey, metadata, target);
@@ -65,12 +65,25 @@ export interface CreateFieldDecoratorProps<P extends FieldProps, M> {
65
65
  disablePropertiesValidation?: boolean;
66
66
  getMetadata: (props?: P) => Omit<M, keyof FieldMetadata> & {
67
67
  forceType?: any;
68
+ /**
69
+ * Declared metadata for the elements of an array field, forwarded to
70
+ * `getFieldMetadata` as `overrideItems`. The resolved element identity
71
+ * always wins over it.
72
+ */
73
+ overrideItems?: Record<string, unknown>;
68
74
  };
69
75
  }
70
76
  export interface GetFieldMetadataProps {
71
77
  type: string;
72
78
  prefix: string;
73
79
  destinationName: string;
74
- fieldProps?: FieldProps;
80
+ fieldProps?: FieldProps & {
81
+ /**
82
+ * Declared metadata for the elements of an array field. Merged under the
83
+ * resolved element identity, which always wins, so a decorator can describe
84
+ * its items without overwriting the type derived from the declaration.
85
+ */
86
+ overrideItems?: Record<string, unknown>;
87
+ };
75
88
  disablePropertiesValidation?: boolean;
76
89
  }
@@ -115,9 +115,8 @@ export interface LambdaProps {
115
115
  * Supported values:
116
116
  * - `24` → Node.js 24
117
117
  * - `22` → Node.js 22
118
- * - `20` → Node.js 20
119
118
  */
120
- runtime?: 24 | 22 | 20;
119
+ runtime?: 24 | 22;
121
120
  /**
122
121
  * Lambda services.
123
122
  *
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lafken/common",
3
- "version": "0.14.3",
3
+ "version": "0.15.0",
4
4
  "private": false,
5
5
  "description": "Lafken utilities - TypeScript decorator factories and metadata reflection for infrastructure-as-code decorators",
6
6
  "keywords": [
@@ -35,13 +35,13 @@
35
35
  "@swc/core": "^1.15.47",
36
36
  "@swc/helpers": "^0.5.23",
37
37
  "@vitest/runner": "^4.1.10",
38
- "cdktn-vitest": "^1.0.0",
38
+ "@cdktn/vitest": "^0.1.0",
39
39
  "typescript": "7.0.2",
40
40
  "unplugin-swc": "^1.5.10",
41
41
  "vitest": "^4.1.10"
42
42
  },
43
43
  "engines": {
44
- "node": ">=20.19"
44
+ "node": ">=22.13"
45
45
  },
46
46
  "publishConfig": {
47
47
  "access": "public"
File without changes