Skip to content

Commit

Permalink
chore(deps): update workspace deps (#67)
Browse files Browse the repository at this point in the history
* chore(deps): update actions/checkout action to v4

* chore(deps): update actions/setup-node action to v4

* chore(deps): update dependency @changesets/changelog-github to ^0.5.0

* chore(deps): update dependency vitest to v1

* chore(deps): update pnpm to v8.14.2

* chore: dedupe deps

* fix(event-factory): include `bootstrapServers` for msk

* style: fix formatting warnings

---------

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Cristian <[email protected]>
  • Loading branch information
3 people committed Jan 22, 2024
1 parent 875d97f commit 3dc5055
Show file tree
Hide file tree
Showing 15 changed files with 1,134 additions and 1,235 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: checkout code repository
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: install pnpm
uses: pnpm/[email protected]

- name: setup node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: 18
cache: 'pnpm'
Expand Down
32 changes: 16 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,28 +16,28 @@
"test": "turbo run test"
},
"devDependencies": {
"@changesets/changelog-github": "^0.4.7",
"@changesets/cli": "^2.25.2",
"@changesets/changelog-github": "^0.5.0",
"@changesets/cli": "^2.27.1",
"@faker-js/faker": "^8.0.2",
"@types/aws-lambda": "^8.10.109",
"@types/aws-lambda": "^8.10.131",
"@types/node": "^18.18.6",
"@typescript-eslint/eslint-plugin": "^6.8.0",
"@typescript-eslint/parser": "^6.8.0",
"eslint": "^8.51.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-import": "^2.28.1",
"eslint-plugin-prettier": "^5.0.1",
"@typescript-eslint/eslint-plugin": "^6.19.1",
"@typescript-eslint/parser": "^6.19.1",
"eslint": "^8.56.0",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-import": "^2.29.1",
"eslint-plugin-prettier": "^5.1.3",
"eslint-plugin-simple-import-sort": "^10.0.0",
"eslint-plugin-turbo": "^1.10.16",
"eslint-plugin-unicorn": "^48.0.1",
"eslint-plugin-vitest": "^0.3.3",
"eslint-plugin-turbo": "^1.11.3",
"eslint-plugin-unicorn": "^50.0.1",
"eslint-plugin-vitest": "^0.3.20",
"fishery": "^2.2.2",
"prettier": "^3.0.0",
"prettier": "^3.2.4",
"turbo": "^1.10.2",
"typescript": "^5.0.0",
"vitest": "^0.34.0"
"typescript": "^5.3.3",
"vitest": "^1.2.1"
},
"packageManager": "pnpm@8.9.2",
"packageManager": "pnpm@8.14.2+sha256.a2dd287205a53bb4322937530d4a17f86269f63fe00a62a03e9e458d3ad027ff",
"engines": {
"node": ">=18.18.2",
"pnpm": ">=8.9.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/aws-event-factory/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"peerDependencies": {
"@faker-js/faker": "^8.0.2",
"@types/aws-lambda": "^8.10.109",
"@types/aws-lambda": "^8.10.131",
"fishery": "^2.2.2"
},
"peerDependenciesMeta": {
Expand Down
6 changes: 4 additions & 2 deletions packages/aws-event-factory/src/msk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@ export const mskEventFactory = Factory.define<MSKEvent, { topic: string; partiti
eventSource: 'aws:kafka',
eventSourceArn:
'arn:aws:kafka:sa-east-1:123456789012:cluster/vpc-2priv-2pub/751d2973-a626-431c-9d4e-d7975eb44dd7-2',
bootstrapServers:
'b-2.demo-cluster-1.a1bcde.c1.kafka.us-east-1.amazonaws.com:9092,b-1.demo-cluster-1.a1bcde.c1.kafka.us-east-1.amazonaws.com:9092',
records: Object.fromEntries(
Array.from({ length: partitions }, (_v, partition) => [
`${topic}-${partition}`,
mskRecordFactory.buildList(1, { topic, partition }),
])
]),
),
};
}
},
);
2 changes: 1 addition & 1 deletion packages/lambda-batch-processor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@driimus/aws-event-factory": "workspace:*"
},
"peerDependencies": {
"@types/aws-lambda": "^8.10.109"
"@types/aws-lambda": "^8.10.131"
},
"peerDependenciesMeta": {
"@types/aws-lambda": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export type PermanentFailure<T extends ProcessableRecord = ProcessableRecord> =
export interface PermanentFailureHandler<T extends BatchEvent = BatchEvent> {
handleRejections: (
failures: PermanentFailure<ProcessableRecord<T>>[],
context?: Context
context?: Context,
) => Promise<void>;
}

Expand Down
4 changes: 2 additions & 2 deletions packages/lambda-batch-processor/src/processors/processor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export abstract class BatchProcessor<TEvent extends BatchEvent> {
nonRetryableErrors = [],
nonRetryableErrorHandler = new DefaultPermanentFailureHandler(),
logger,
}: BatchProcessorOptions<TEvent> = {}
}: BatchProcessorOptions<TEvent> = {},
) {
this.handler = handler;
this.suppressErrors = suppressErrors;
Expand All @@ -60,7 +60,7 @@ export abstract class BatchProcessor<TEvent extends BatchEvent> {

async process({ Records }: TEvent, context?: Context): Promise<BatchResponse> {
const results = await Promise.allSettled(
Records.map((record) => this.handler(record, context))
Records.map((record) => this.handler(record, context)),
);

const permanentFailures: PermanentFailure[] = [];
Expand Down
12 changes: 6 additions & 6 deletions packages/lambda-batch-processor/tests/batchProcessor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ describe('BatchProcessor', () => {
sqsRecordFactory.build({ body: 'retryable body' }),
sqsRecordFactory.build(),
],
})
}),
).resolves.toStrictEqual({
batchItemFailures: [
{
Expand All @@ -70,7 +70,7 @@ describe('BatchProcessor', () => {
sqsRecordFactory.build({ body: 'retryable body' }),
sqsRecordFactory.build(),
],
})
}),
).resolves.toStrictEqual({
batchItemFailures: expect.any(Array),
});
Expand All @@ -80,7 +80,7 @@ describe('BatchProcessor', () => {
await expect(
processor.process({
Records: [sqsRecordFactory.build(), sqsRecordFactory.build({ body: 'invalid body' })],
})
}),
).resolves.toStrictEqual({
batchItemFailures: [],
});
Expand All @@ -98,7 +98,7 @@ describe('BatchProcessor', () => {
await expect(
p.process({
Records: [sqsRecordFactory.build(), sqsRecordFactory.build({ body: 'invalid body' })],
})
}),
).resolves.toStrictEqual({
batchItemFailures: [
{
Expand All @@ -112,7 +112,7 @@ describe('BatchProcessor', () => {
await expect(
processor.process({
Records: [sqsRecordFactory.build({ body: 'retryable body' })],
})
}),
).rejects.toThrow(AggregateError);
});

Expand All @@ -130,7 +130,7 @@ describe('BatchProcessor', () => {
sqsRecordFactory.build({ body: 'invalid body' }),
sqsRecordFactory.build({ body: 'retryable body' }),
],
})
}),
).resolves.toStrictEqual({
batchItemFailures: expect.any(Array),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/lambda-batch-processor/tests/dynamodb.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ describe('DynamoDBBatchProcessor', () => {
await expect(
processor.process({
Records,
})
}),
).resolves.toStrictEqual({
batchItemFailures: failingRecords.map(({ dynamodb: { SequenceNumber } = {} }) => ({
itemIdentifier: SequenceNumber,
Expand Down
2 changes: 1 addition & 1 deletion packages/lambda-batch-processor/tests/kinesis.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ describe('KinesisBatchProcessor', () => {
await expect(
processor.process({
Records,
})
}),
).resolves.toStrictEqual({
batchItemFailures: failingRecords.map(({ kinesis: { sequenceNumber } }) => ({
itemIdentifier: sequenceNumber,
Expand Down
2 changes: 1 addition & 1 deletion packages/lambda-batch-processor/tests/sqs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('SQSBatchProcessor', () => {
await expect(
processor.process({
Records,
})
}),
).resolves.toStrictEqual({
batchItemFailures: failingRecords.map(({ messageId }) => ({ itemIdentifier: messageId })),
});
Expand Down
2 changes: 1 addition & 1 deletion packages/sqs-permanent-failure-dlq/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"peerDependencies": {
"@aws-sdk/client-sqs": "^3.226.0",
"@types/aws-lambda": "^8.10.109"
"@types/aws-lambda": "^8.10.131"
},
"peerDependenciesMeta": {
"@types/aws-lambda": {
Expand Down
7 changes: 5 additions & 2 deletions packages/sqs-permanent-failure-dlq/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ const MAX_BATCH_SIZE = 10;
export class PermanentFailureDLQHandler implements PermanentFailureHandler<SQSEvent> {
#client: SQSClient | undefined;

constructor(public readonly queueUrl: string, client?: SQSClient) {
constructor(
public readonly queueUrl: string,
client?: SQSClient,
) {
this.#client = client;
}

Expand All @@ -40,7 +43,7 @@ export class PermanentFailureDLQHandler implements PermanentFailureHandler<SQSEv
new SendMessageBatchCommand({
QueueUrl: this.queueUrl,
Entries: messages.slice(index, index + MAX_BATCH_SIZE),
})
}),
);
}
}
Expand Down
10 changes: 5 additions & 5 deletions packages/sqs-permanent-failure-dlq/tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ describe('PermanentFailureDLQHandler', () => {
await expect(toDLQHandler.handleRejections(failures)).resolves.toBeUndefined();
expect(mockSQS).toHaveReceivedCommandTimes(
SendMessageBatchCommand,
Math.ceil(failures.length / 10)
Math.ceil(failures.length / 10),
);
});

Expand All @@ -92,22 +92,22 @@ describe('PermanentFailureDLQHandler', () => {
{
nonRetryableErrorHandler: toDLQHandler,
nonRetryableErrors: [ValidationError],
}
},
);

const invalidRecord = sqsRecordFactory.build({ body: 'invalid body' });

await expect(
processor.process(
sqsEventFactory.build({ Records: [invalidRecord, ...sqsRecordFactory.buildList(2)] })
)
sqsEventFactory.build({ Records: [invalidRecord, ...sqsRecordFactory.buildList(2)] }),
),
).resolves.toStrictEqual({
batchItemFailures: [],
});
expect(failureHandlerSpy).toHaveBeenCalledTimes(1);
expect(failureHandlerSpy).toHaveBeenCalledWith(
[expect.objectContaining({ record: invalidRecord, reason: expect.any(ValidationError) })],
undefined
undefined,
);
});
});
Loading

0 comments on commit 3dc5055

Please sign in to comment.