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

Commit

Permalink
feat: add firehose schemas
Browse files Browse the repository at this point in the history
  • Loading branch information
pevisscher committed Nov 29, 2022
1 parent 2ba8f7b commit d55703c
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/lib/aws/firehose/firehose.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { $array, $integer, $object, $optional, $ref, $string, $validator } from '@skyleague/therefore'

export const firehoseRecordMetadata = $object({
shardId: $string,
partitionKey: $string,
approximateArrivalTimestamp: $integer,
sequenceNumber: $string,
subsequenceNumber: $string,
})

export const firehoseTransformationEventRecord = $validator(
$object({
recordId: $string,
approximateArrivalTimestamp: $integer,
// Base64 encoded
data: $string,
kinesisRecordMetadata: $optional($ref(firehoseRecordMetadata), 'explicit'),
})
)

export const firehoseTransformationEvent = $validator(
$object({
invocationId: $string,
deliveryStreamArn: $string,
sourceKinesisStreamArn: $optional($string, 'explicit'),
region: $string,
records: $array($ref(firehoseTransformationEventRecord)),
})
)
8 changes: 8 additions & 0 deletions src/lib/aws/firehose/firehose.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { FirehoseTransformationEvent } from './firehose.type'

import type { FirehoseTransformationEvent as LambdaFirehoseTransformationEvent } from 'aws-lambda'

test('type is compatible', () => {
const _test: FirehoseTransformationEvent = {} as unknown as LambdaFirehoseTransformationEvent
const _test2: LambdaFirehoseTransformationEvent = {} as unknown as FirehoseTransformationEvent
})
63 changes: 63 additions & 0 deletions src/lib/aws/firehose/firehose.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Generated by @skyleague/therefore@v1.0.0-local
* Do not manually touch this
*/
/* eslint-disable */
import AjvValidator from 'ajv'
import type { ValidateFunction } from 'ajv'

export interface FirehoseRecordMetadata {
shardId: string
partitionKey: string
approximateArrivalTimestamp: number
sequenceNumber: string
subsequenceNumber: string
}

export interface FirehoseTransformationEventRecord {
recordId: string
approximateArrivalTimestamp: number
data: string
kinesisRecordMetadata?: FirehoseRecordMetadata | undefined
}

export const FirehoseTransformationEventRecord = {
validate:
require('./schemas/firehose-transformation-event-record.schema.js') as ValidateFunction<FirehoseTransformationEventRecord>,
get schema() {
return FirehoseTransformationEventRecord.validate.schema
},
get errors() {
return FirehoseTransformationEventRecord.validate.errors ?? undefined
},
is: (o: unknown): o is FirehoseTransformationEventRecord => FirehoseTransformationEventRecord.validate(o) === true,
assert: (o: unknown) => {
if (!FirehoseTransformationEventRecord.validate(o)) {
throw new AjvValidator.ValidationError(FirehoseTransformationEventRecord.errors ?? [])
}
},
} as const

export interface FirehoseTransformationEvent {
invocationId: string
deliveryStreamArn: string
sourceKinesisStreamArn?: string | undefined
region: string
records: FirehoseTransformationEventRecord[]
}

export const FirehoseTransformationEvent = {
validate: require('./schemas/firehose-transformation-event.schema.js') as ValidateFunction<FirehoseTransformationEvent>,
get schema() {
return FirehoseTransformationEvent.validate.schema
},
get errors() {
return FirehoseTransformationEvent.validate.errors ?? undefined
},
is: (o: unknown): o is FirehoseTransformationEvent => FirehoseTransformationEvent.validate(o) === true,
assert: (o: unknown) => {
if (!FirehoseTransformationEvent.validate(o)) {
throw new AjvValidator.ValidationError(FirehoseTransformationEvent.errors ?? [])
}
},
} as const
1 change: 1 addition & 0 deletions src/lib/aws/firehose/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './firehose.type'

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

Loading

0 comments on commit d55703c

Please sign in to comment.