Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(parser): add parser subpath exports to package.json #2179

Merged
merged 9 commits into from
Mar 11, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6,188 changes: 3,872 additions & 2,316 deletions package-lock.json

Large diffs are not rendered by default.

32 changes: 32 additions & 0 deletions packages/parser/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,38 @@
"types": "./lib/esm/index.d.ts",
"default": "./lib/esm/index.js"
}
},
"./middleware": {
"require": "./lib/cjs/middleware/parser.js",
"import": "./lib/esm/middleware/parser.js"
},
"./schemas": {
"require": "./lib/cjs/schemas/index.js",
"import": "./lib/esm/schemas/index.js"
},
"./envelopes": {
"require": "./lib/cjs/index.js",
am29d marked this conversation as resolved.
Show resolved Hide resolved
"import": "./lib/esm/index.js"
}
am29d marked this conversation as resolved.
Show resolved Hide resolved
},
"typesVersions": {
"*": {
"types": [
"./lib/cjs/types/index.d.ts",
"./lib/esm/types/index.d.ts"
],
"middleware": [
"./lib/cjs/middleware/parser.d.ts",
"./lib/esm/middleware/parser.d.ts"
],
"schemas": [
"./lib/cjs/schemas/index.d.ts",
"./lib/esm/schemas/index.d.ts"
],
"envelopes": [
"./lib/cjs/envelopes/index.d.ts",
"./lib/esm/envelopes/index.d.ts"
]
}
},
"main": "./lib/cjs/index.js",
Expand Down
14 changes: 14 additions & 0 deletions packages/parser/src/envelopes/index.ts
am29d marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
export * from './apigw.js';
export * from './apigwv2.js';
export * from './cloudwatch.js';
export * from './dynamodb.js';
export * from './envelope.js';
export * from './event-bridge.js';
export * from './kafka.js';
export * from './kinesis.js';
export * from './kinesis-firehose.js';
export * from './lambda.js';
export * from './sns.js';
export * from './sqs.js';
export * from './vpc-lattice.js';
export * from './vpc-latticev2.js';
1 change: 1 addition & 0 deletions packages/parser/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { parser } from './parser.js';
4 changes: 1 addition & 3 deletions packages/parser/src/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { type ParserOptions } from './types/ParserOptions.js';
*
* @param options
*/
const parser = <S extends ZodSchema>(
export const parser = <S extends ZodSchema>(
options: ParserOptions<S>
): HandlerMethodDecorator => {
return (_target, _propertyKey, descriptor) => {
Expand All @@ -55,5 +55,3 @@ const parser = <S extends ZodSchema>(
return descriptor;
};
};

export { parser };
17 changes: 17 additions & 0 deletions packages/parser/src/schemas/index.ts
am29d marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export * from './alb.js';
export * from './apigw.js';
export * from './apigwv2.js';
export * from './cloudformation-custom-resource.js';
export * from './cloudwatch.js';
export * from './dynamodb.js';
export * from './eventbridge.js';
export * from './kafka.js';
export * from './kinesis.js';
export * from './kinesis-firehose.js';
export * from './lambda.js';
export * from './s3.js';
export * from './ses.js';
export * from './sns.js';
export * from './sqs.js';
export * from './vpc-lattice.js';
export * from './vpc-latticev2.js';
4 changes: 1 addition & 3 deletions packages/parser/src/types/ParserOptions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import type { ZodSchema } from 'zod';
import { Envelope } from './envelope.js';

type ParserOptions<S extends ZodSchema> = {
export type ParserOptions<S extends ZodSchema> = {
schema: S;
envelope?: Envelope;
};

export { type ParserOptions };
3 changes: 3 additions & 0 deletions packages/parser/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export type { ParserOptions } from './ParserOptions.js';
export type { Envelope } from './envelope.js';
export * from './schema.js';
am29d marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 3 additions & 3 deletions packages/parser/tests/unit/parser.decorator.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

import { LambdaInterface } from '@aws-lambda-powertools/commons/lib/esm/types';
am29d marked this conversation as resolved.
Show resolved Hide resolved
import { Context, EventBridgeEvent } from 'aws-lambda';
import { parser } from '../../src/parser';
import { parser } from '../../src/index.js';
import { TestSchema, TestEvents } from './schema/utils';
import { generateMock } from '@anatine/zod-mock';
import { eventBridgeEnvelope } from '../../src/envelopes/event-bridge';
import { EventBridgeSchema } from '../../src/schemas/eventbridge';
import { eventBridgeEnvelope } from '../../src/envelopes/index.js';
import { EventBridgeSchema } from '../../src/schemas/index.js';
import { z } from 'zod';

describe('Parser Decorator', () => {
Expand Down
4 changes: 2 additions & 2 deletions packages/parser/tests/unit/parser.middy.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import middy from '@middy/core';
import { Context } from 'aws-lambda';
import { parser } from '../../src/middleware/parser.js';
import { generateMock } from '@anatine/zod-mock';
import { SqsSchema } from '../../src/schemas/sqs.js';
import { SqsSchema } from '../../src/schemas/index.js';
import { z, type ZodSchema } from 'zod';
import { sqsEnvelope } from '../../src/envelopes/sqs';
import { sqsEnvelope } from '../../src/envelopes/index.js';
import { TestSchema } from './schema/utils';

describe('Middleware: parser', () => {
Expand Down