@lafken/queue 0.14.2 → 0.14.4
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,5 +1,7 @@
|
|
|
1
1
|
import type { ParamProps } from './event.types';
|
|
2
|
+
/** Reflect-metadata key prefix for queue field metadata. */
|
|
2
3
|
export declare const queueFieldKey: string;
|
|
4
|
+
/** Reflect-metadata key prefix for queue payload metadata. */
|
|
3
5
|
export declare const queuePayloadKey: string;
|
|
4
6
|
/**
|
|
5
7
|
* Class decorator that declares a class as an SQS message payload.
|
package/lib/main/event/event.js
CHANGED
|
@@ -3,7 +3,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.Event = exports.Field = exports.Param = exports.Payload = exports.queuePayloadKey = exports.queueFieldKey = void 0;
|
|
4
4
|
const common_1 = require("@lafken/common");
|
|
5
5
|
const queue_1 = require("../queue");
|
|
6
|
+
/** Reflect-metadata key prefix for queue field metadata. */
|
|
6
7
|
exports.queueFieldKey = (0, common_1.createFieldName)(queue_1.RESOURCE_TYPE, common_1.FieldProperties.field);
|
|
8
|
+
/** Reflect-metadata key prefix for queue payload metadata. */
|
|
7
9
|
exports.queuePayloadKey = (0, common_1.createFieldName)(queue_1.RESOURCE_TYPE, common_1.FieldProperties.payload);
|
|
8
10
|
/**
|
|
9
11
|
* Class decorator that declares a class as an SQS message payload.
|
|
@@ -95,26 +95,56 @@ export interface ParamRecordProps extends Omit<FieldProps, 'type' | 'name'> {
|
|
|
95
95
|
*/
|
|
96
96
|
type?: StringConstructor;
|
|
97
97
|
}
|
|
98
|
+
/**
|
|
99
|
+
* Union of all supported parameter source configurations for SQS queue decorators.
|
|
100
|
+
* Each variant defines how the parameter value is extracted from the SQS event.
|
|
101
|
+
*/
|
|
98
102
|
export type ParamProps = ParamAttributeProps | ParamBodyUnparsedProps | ParamBodyParsedProps | ParamRecordProps;
|
|
103
|
+
/**
|
|
104
|
+
* Extracted union of valid `source` values from {@link ParamProps}.
|
|
105
|
+
* Excludes `undefined` to represent concrete source discriminants.
|
|
106
|
+
*/
|
|
99
107
|
export type Source = Exclude<ParamProps['source'], undefined>;
|
|
108
|
+
/**
|
|
109
|
+
* Internal base shape for all resolved SQS queue parameter metadata.
|
|
110
|
+
* Discriminated by `source` to indicate where the value comes from.
|
|
111
|
+
*/
|
|
100
112
|
interface QueueParamBase {
|
|
101
113
|
source: Source;
|
|
102
114
|
parse: boolean;
|
|
103
115
|
}
|
|
116
|
+
/** Resolved metadata for a string-typed SQS parameter. */
|
|
104
117
|
export interface QueueStringParam extends StringField, QueueParamBase {
|
|
105
118
|
}
|
|
119
|
+
/** Resolved metadata for a number-typed SQS parameter. */
|
|
106
120
|
export interface QueueNumberParam extends NumberField, QueueParamBase {
|
|
107
121
|
}
|
|
122
|
+
/** Resolved metadata for a boolean-typed SQS parameter. */
|
|
108
123
|
export interface QueueBooleanParam extends BooleanField, QueueParamBase {
|
|
109
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Resolved metadata for an object-typed SQS parameter.
|
|
127
|
+
* Nested properties are recursively described as {@link QueueParamMetadata}.
|
|
128
|
+
*/
|
|
110
129
|
export interface QueueObjectParam extends Omit<ObjectField, 'properties'>, QueueParamBase {
|
|
111
130
|
properties: QueueParamMetadata[];
|
|
112
131
|
}
|
|
132
|
+
/**
|
|
133
|
+
* Resolved metadata for an array-typed SQS parameter.
|
|
134
|
+
* The element schema is described by a single {@link QueueParamMetadata} entry.
|
|
135
|
+
*/
|
|
113
136
|
export interface QueueArrayParam extends Omit<ArrayField, 'items'>, QueueParamBase {
|
|
114
137
|
items: QueueParamMetadata;
|
|
115
138
|
}
|
|
139
|
+
/**
|
|
140
|
+
* Resolved metadata for an SQS parameter that extracts a raw record field.
|
|
141
|
+
*/
|
|
116
142
|
export interface QueueRecordParam extends StringField, QueueParamBase {
|
|
117
143
|
source: 'record';
|
|
118
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Discriminated union of all resolved SQS queue parameter metadata types.
|
|
147
|
+
* Used by the resolver to build the Lambda handler parameter mapping.
|
|
148
|
+
*/
|
|
119
149
|
export type QueueParamMetadata = QueueStringParam | QueueNumberParam | QueueBooleanParam | QueueObjectParam | QueueArrayParam | QueueRecordParam;
|
|
120
150
|
export {};
|
|
@@ -137,6 +137,20 @@ export interface ExternalQueueProps extends SourceMappingProps {
|
|
|
137
137
|
/**
|
|
138
138
|
*
|
|
139
139
|
*/
|
|
140
|
+
/**
|
|
141
|
+
* Name or resolver function that resolves the name of the external SQS queue.
|
|
142
|
+
*
|
|
143
|
+
* Can be a literal queue name or a callback that receives `GetResourceProps`
|
|
144
|
+
* to dynamically resolve the queue identifier from another resource.
|
|
145
|
+
*
|
|
146
|
+
* @example
|
|
147
|
+
* // Literal name
|
|
148
|
+
* queueName: 'my-existing-queue'
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* // Dynamic reference
|
|
152
|
+
* queueName: (props) => props.getResourceValue('module::queue::name', 'id')
|
|
153
|
+
*/
|
|
140
154
|
queueName: string | ((props: GetResourceProps) => string);
|
|
141
155
|
/**
|
|
142
156
|
* Lambda configuration for processing messages from this queue.
|
|
@@ -156,8 +170,15 @@ export interface InternalFifoProps extends InternalStandardProps {
|
|
|
156
170
|
}
|
|
157
171
|
export type StandardProps = InternalStandardProps | ExternalQueueProps;
|
|
158
172
|
export type FifoProps = InternalFifoProps | ExternalQueueProps;
|
|
173
|
+
/**
|
|
174
|
+
* Resolved metadata for an SQS queue Lambda handler, used internally
|
|
175
|
+
* by the resolver to generate the Lambda function and event source mapping.
|
|
176
|
+
*/
|
|
159
177
|
export interface QueueLambdaMetadata extends LambdaMetadata, Omit<InternalFifoProps, 'queueName' | 'isExternal'> {
|
|
178
|
+
/** Resolved queue name (literal or callback). */
|
|
160
179
|
queueName: ExternalQueueProps['queueName'];
|
|
180
|
+
/** Whether this is a FIFO queue. */
|
|
161
181
|
isFifo: boolean;
|
|
182
|
+
/** Whether this queue references an externally managed SQS resource. */
|
|
162
183
|
isExternal: boolean;
|
|
163
184
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lafken/queue",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Define SQS queues and consumers using TypeScript decorators - automatic infrastructure generation with Lafken",
|
|
6
6
|
"keywords": [
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"dependencies": {
|
|
58
58
|
"@aws-sdk/client-sqs": "^3.1106.0",
|
|
59
59
|
"reflect-metadata": "^0.2.2",
|
|
60
|
-
"@lafken/resolver": "0.14.
|
|
60
|
+
"@lafken/resolver": "0.14.4"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@cdktn/provider-aws": "^25.0.0",
|
|
@@ -66,18 +66,18 @@
|
|
|
66
66
|
"@types/aws-lambda": "^8.10.162",
|
|
67
67
|
"@vitest/runner": "^4.1.10",
|
|
68
68
|
"cdktn": "^0.24.0",
|
|
69
|
-
"cdktn
|
|
69
|
+
"@cdktn/vitest": "^0.1.0",
|
|
70
70
|
"constructs": "^10.8.0",
|
|
71
71
|
"typescript": "7.0.2",
|
|
72
72
|
"unplugin-swc": "^1.5.10",
|
|
73
73
|
"vitest": "^4.1.10",
|
|
74
|
-
"@lafken/common": "0.14.
|
|
74
|
+
"@lafken/common": "0.14.4"
|
|
75
75
|
},
|
|
76
76
|
"peerDependencies": {
|
|
77
77
|
"@cdktn/provider-aws": ">=23.0.0",
|
|
78
78
|
"cdktn": ">=0.22.0",
|
|
79
79
|
"constructs": ">=10.7.0",
|
|
80
|
-
"@lafken/common": "0.14.
|
|
80
|
+
"@lafken/common": "0.14.4"
|
|
81
81
|
},
|
|
82
82
|
"engines": {
|
|
83
83
|
"node": ">=20.19"
|