Skip to content

Commit d3314ce

Browse files
committed
Merge branch 'docs/parser-integration-batch' of github.com:aws-powertools/powertools-lambda-typescript into docs/parser-integration-batch
2 parents d501e77 + 0f11562 commit d3314ce

File tree

15 files changed

+1104
-75
lines changed

15 files changed

+1104
-75
lines changed

.github/workflows/ossf_scorecard.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,6 @@ jobs:
4343

4444
# Upload the results to GitHub's code scanning dashboard.
4545
- name: "Upload to code-scanning"
46-
uses: github/codeql-action/upload-sarif@2d92b76c45b91eb80fc44c74ce3fce0ee94e8f9d # v3.29.5
46+
uses: github/codeql-action/upload-sarif@f1f6e5f6af878fb37288ce1c627459e94dbf7d01 # v3.29.5
4747
with:
4848
sarif_file: results.sarif

examples/snippets/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
"zod": "^4.1.5"
4747
},
4848
"dependencies": {
49-
"arktype": "^2.1.21",
49+
"arktype": "^2.1.22",
5050
"valibot": "^1.1.0"
5151
}
5252
}

package-lock.json

Lines changed: 51 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
"packages/tracer",
1111
"packages/parameters",
1212
"packages/idempotency",
13+
"packages/parser",
1314
"packages/batch",
1415
"packages/testing",
15-
"packages/parser",
1616
"examples/snippets",
1717
"layers",
1818
"examples/app",
@@ -50,7 +50,7 @@
5050
},
5151
"homepage": "https://github.com/aws-powertools/powertools-lambda-typescript#readme",
5252
"devDependencies": {
53-
"@biomejs/biome": "^2.2.2",
53+
"@biomejs/biome": "^2.2.3",
5454
"@types/aws-lambda": "^8.10.152",
5555
"@types/node": "^24.3.1",
5656
"@vitest/coverage-v8": "^3.2.4",

packages/batch/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
"nodejs"
7474
],
7575
"devDependencies": {
76-
"@aws-lambda-powertools/testing-utils": "file:../testing"
76+
"@aws-lambda-powertools/testing-utils": "file:../testing",
77+
"@aws-lambda-powertools/parser": "2.25.2"
7778
}
7879
}

packages/batch/src/BasePartialBatchProcessor.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { StandardSchemaV1 } from '@standard-schema/spec';
12
import type {
23
DynamoDBRecord,
34
KinesisStreamRecord,
@@ -11,6 +12,7 @@ import {
1112
} from './constants.js';
1213
import { FullBatchFailureError } from './errors.js';
1314
import type {
15+
BasePartialBatchProcessorConfig,
1416
EventSourceDataClassTypes,
1517
PartialItemFailureResponse,
1618
PartialItemFailures,
@@ -42,12 +44,20 @@ abstract class BasePartialBatchProcessor extends BasePartialProcessor {
4244
*/
4345
public eventType: keyof typeof EventType;
4446

47+
/**
48+
* The schema of the body of the event record for parsing
49+
*/
50+
protected schema?: StandardSchemaV1;
51+
4552
/**
4653
* Initializes base batch processing class
4754
*
4855
* @param eventType The type of event to process (SQS, Kinesis, DynamoDB)
4956
*/
50-
public constructor(eventType: keyof typeof EventType) {
57+
public constructor(
58+
eventType: keyof typeof EventType,
59+
config?: BasePartialBatchProcessorConfig
60+
) {
5161
super();
5262
this.eventType = eventType;
5363
this.batchResponse = DEFAULT_RESPONSE;
@@ -56,6 +66,9 @@ abstract class BasePartialBatchProcessor extends BasePartialProcessor {
5666
[EventType.KinesisDataStreams]: () => this.collectKinesisFailures(),
5767
[EventType.DynamoDBStreams]: () => this.collectDynamoDBFailures(),
5868
};
69+
if (config) {
70+
this.schema = config.schema;
71+
}
5972
}
6073

6174
/**

packages/batch/src/BasePartialProcessor.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ abstract class BasePartialProcessor {
7474
* This method should be called when a record fails processing so that
7575
* the processor can keep track of the error and the record that failed.
7676
*
77-
* @param record Record that failed processing
78-
* @param error Error that was thrown
77+
* @param record - Record that failed processing
78+
* @param error - Error that was thrown
7979
*/
8080
public failureHandler(
8181
record: EventSourceDataClassTypes,
@@ -131,7 +131,7 @@ abstract class BasePartialProcessor {
131131
* This is to ensure that the processor keeps track of the results and the records
132132
* that succeeded and failed processing.
133133
*
134-
* @param record Record to be processed
134+
* @param record - Record to be processed
135135
*/
136136
public abstract processRecord(
137137
record: BaseRecord
@@ -149,7 +149,7 @@ abstract class BasePartialProcessor {
149149
* This is to ensure that the processor keeps track of the results and the records
150150
* that succeeded and failed processing.
151151
*
152-
* @param record Record to be processed
152+
* @param record - Record to be processed
153153
*/
154154
public abstract processRecordSync(
155155
record: BaseRecord
@@ -198,9 +198,9 @@ abstract class BasePartialProcessor {
198198
* to allow for reusing the processor instance across multiple invocations
199199
* by instantiating the processor outside of the Lambda function handler.
200200
*
201-
* @param records Array of records to be processed
202-
* @param handler CallableFunction to process each record from the batch
203-
* @param options Options to be used during processing (optional)
201+
* @param records - Array of records to be processed
202+
* @param handler - CallableFunction to process each record from the batch
203+
* @param options - Options to be used during processing (optional)
204204
*/
205205
public register(
206206
records: BaseRecord[],
@@ -223,8 +223,8 @@ abstract class BasePartialProcessor {
223223
* This method should be called when a record succeeds processing so that
224224
* the processor can keep track of the result and the record that succeeded.
225225
*
226-
* @param record Record that succeeded processing
227-
* @param result Result from record handler
226+
* @param record - Record that succeeded processing
227+
* @param result - Result from record handler
228228
*/
229229
public successHandler(
230230
record: EventSourceDataClassTypes,

0 commit comments

Comments
 (0)