Skip to content

Commit 30997e9

Browse files
sdangoldreamorosi
authored andcommitted
Updated the documentation to reflect the simplified API
1 parent d09792d commit 30997e9

File tree

7 files changed

+14
-143
lines changed

7 files changed

+14
-143
lines changed

docs/features/batch.md

Lines changed: 6 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -395,15 +395,17 @@ sequenceDiagram
395395

396396
### Parser integration
397397

398-
You can define your own schema to parse your batch record payload via the **`schema`** parameter when initializing the **`BatchProcessor`**.
398+
You can define your own schema to parse your batch record payload via the parser configuration options when initializing the **`BatchProcessor`**.
399399

400400
#### Using inner payload schema
401401

402402
You can just define the schema of your internal payload and we will handle the parsing for you depending on the type of event that you are using.
403403

404+
You can specify any transformers needed to transform your payload before being used for parsing the inner payload.
405+
404406
=== "SQS - using inner payload"
405407

406-
```typescript hl_lines="9-12 14 17"
408+
```typescript hl_lines="9-12 14-17"
407409
--8<-- "examples/snippets/batch/parser-integration/sqsWithoutTransformer.ts"
408410
```
409411

@@ -415,7 +417,7 @@ You can just define the schema of your internal payload and we will handle the p
415417

416418
=== "Kinesis Data Streams - using inner payload"
417419

418-
```typescript hl_lines="9-12 14 17"
420+
```typescript hl_lines="9-12 14-17 21"
419421
--8<-- "examples/snippets/batch/parser-integration/kinesisWithoutTransformer.ts"
420422
```
421423

@@ -427,7 +429,7 @@ You can just define the schema of your internal payload and we will handle the p
427429

428430
=== "DynamoDB Streams - using inner payload"
429431

430-
```typescript hl_lines="9-12 14 17"
432+
```typescript hl_lines="9-12 14-17 21"
431433
--8<-- "examples/snippets/batch/parser-integration/dynamodbWithoutTransformer.ts"
432434
```
433435

@@ -437,46 +439,6 @@ You can just define the schema of your internal payload and we will handle the p
437439
--8<-- "examples/snippets/batch/samples/sampleDynamoDBStreamsEventForParser.json"
438440
```
439441

440-
#### Controlling the transformer
441-
442-
If you want more control over the transformer used for parsing the inner payload, you can provide your own transform helper function.
443-
444-
=== "SQS - using custom transformer"
445-
446-
```typescript hl_lines="10-13 15 18"
447-
--8<-- "examples/snippets/batch/parser-integration/sqsWithTransformer.ts"
448-
```
449-
450-
=== "SQS - Sample Event"
451-
452-
```json hl_lines="6 22"
453-
--8<-- "examples/snippets/batch/samples/sampleSQSEventForParser.json"
454-
```
455-
456-
=== "Kinesis Data Streams - using custom transformer"
457-
458-
```typescript hl_lines="10-13 15 18"
459-
--8<-- "examples/snippets/batch/parser-integration/kinesisWithTransformer.ts"
460-
```
461-
462-
=== "Kinesis - Sample Event"
463-
464-
```json hl_lines="6 22"
465-
--8<-- "examples/snippets/batch/samples/sampleKinesisEventForParser.json"
466-
```
467-
468-
=== "DynamoDB Streams - using custom transformer"
469-
470-
```typescript hl_lines="10-13 15 18"
471-
--8<-- "examples/snippets/batch/parser-integration/dynamodbWithTransformer.ts"
472-
```
473-
474-
=== "DynamoDB - Sample Event"
475-
476-
```json hl_lines="13-18 39-44"
477-
--8<-- "examples/snippets/batch/samples/sampleDynamoDBStreamsEventForParser.json"
478-
```
479-
480442
#### Extending the schema yourself
481443

482444
If you want to have full control, you can pass an extended schema with any transformers you need.

examples/snippets/batch/parser-integration/dynamoDBWithTransformer.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

examples/snippets/batch/parser-integration/dynamoDBWithoutTransformer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const customSchema = z.object({
1212
});
1313

1414
const processor = new BatchProcessor(EventType.DynamoDBStreams, {
15-
schema: customSchema,
15+
innerSchema: customSchema,
16+
transformer: 'unmarshall',
1617
});
1718

1819
const recordHandler = async ({

examples/snippets/batch/parser-integration/kinesisWithTransformer.ts

Lines changed: 0 additions & 34 deletions
This file was deleted.

examples/snippets/batch/parser-integration/kinesisWithoutTransformer.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ const customSchema = z.object({
1212
});
1313

1414
const processor = new BatchProcessor(EventType.KinesisDataStreams, {
15-
schema: customSchema,
15+
innerSchema: customSchema,
16+
transformer: 'base64',
1617
});
1718

1819
const recordHandler = async ({

examples/snippets/batch/parser-integration/sqsWithTransformer.ts

Lines changed: 0 additions & 28 deletions
This file was deleted.

examples/snippets/batch/parser-integration/sqsWithoutTransformer.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@ const customSchema = z.object({
1111
age: z.number(),
1212
});
1313

14-
const processor = new BatchProcessor(EventType.SQS, { schema: customSchema });
14+
const processor = new BatchProcessor(EventType.SQS, {
15+
innerSchema: customSchema,
16+
transformer: 'json',
17+
});
1518

1619
const recordHandler = async ({
1720
body: { name, age },

0 commit comments

Comments
 (0)