Skip to content
This repository has been archived by the owner on Dec 10, 2024. It is now read-only.

Commit

Permalink
feat: add sqs schemas (#17)
Browse files Browse the repository at this point in the history
* chore: upgrade dependencies

* feat: add apigateway schemas

* feat: add eventbridge schemas

* feat: add firehose schemas

* feat: add lambda schemas

* feat: add kinesis schemas

* feat: add s3 schemas

* feat: add s3 batch schemas

* feat: add secret rotation schemas

* feat: add sns schemas

* feat: add sqs schemas
  • Loading branch information
pevisscher authored Nov 30, 2022
1 parent d8aea06 commit 3aa8b77
Show file tree
Hide file tree
Showing 7 changed files with 145 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/lib/aws/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export * from './apigateway'
export * from './eventbridge'
export * from './firehose'
export * from './kinesis'
export * from './lambda'
export * from './s3'
export * from './s3-batch'
export * from './secret-rotation'
export * from './sns'
export * from './sqs'
1 change: 1 addition & 0 deletions src/lib/aws/sqs/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './sqs.type'
5 changes: 5 additions & 0 deletions src/lib/aws/sqs/schemas/sqs-event.schema.js

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions src/lib/aws/sqs/schemas/sqs-record.schema.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions src/lib/aws/sqs/sqs.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { $array, $dict, $enum, $object, $optional, $ref, $string, $validator, $union } from '@skyleague/therefore'

export const SQSMessageAttribute = $object({
stringValue: $optional($string, 'explicit'),
binaryValue: $optional($string, 'explicit'),
stringListValues: $optional($array($string), 'explicit'),
binaryListValues: $optional($array($string), 'explicit'),
dataType: $union([$enum(['String', 'Number', 'Binary']), $string]),
})

export const SQSMessageAttributes = $dict($ref(SQSMessageAttribute))

export const SQSRecordAttributes = $object({
AWSTraceHeader: $optional($string, 'explicit'),
ApproximateReceiveCount: $string,
SentTimestamp: $string,
SenderId: $string,
ApproximateFirstReceiveTimestamp: $string,
SequenceNumber: $optional($string, 'explicit'),
MessageGroupId: $optional($string, 'explicit'),
MessageDeduplicationId: $optional($string, 'explicit'),
})

export const SQSRecord = $validator(
$object({
messageId: $string,
receiptHandle: $string,
body: $string,
attributes: $ref(SQSRecordAttributes),
messageAttributes: $ref(SQSMessageAttributes),
md5OfBody: $string,
eventSource: $string,
eventSourceARN: $string,
awsRegion: $string,
})
)

export const SQSEvent = $validator($object({ Records: $array($ref(SQSRecord)) }))
8 changes: 8 additions & 0 deletions src/lib/aws/sqs/sqs.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { SQSRecord } from './sqs.type'

import type { SQSRecord as LambdaSqsRecord } from 'aws-lambda'

test('type is compatible', () => {
const _test: SQSRecord = {} as unknown as LambdaSqsRecord
// const _test2: LambdaSqsRecord = {} as unknown as SQSRecord
})
Loading

0 comments on commit 3aa8b77

Please sign in to comment.