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

Commit

Permalink
feat: add s3 batch schemas (#14)
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
  • Loading branch information
pevisscher authored Nov 30, 2022
1 parent 9ca2373 commit 7a8982a
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/lib/aws/s3-batch/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './s3.type'
23 changes: 23 additions & 0 deletions src/lib/aws/s3-batch/s3.schema.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { $array, $const, $object, $ref, $string, $union, $validator } from '@skyleague/therefore'

export const s3BatchEventTask = $validator(
$object({
taskId: $string,
s3Key: $string,
s3VersionId: $union([$string, $const(null)]),
s3BucketArn: $string,
})
)

export const s3BatchEventJob = $object({
id: $string,
})

export const s3BatchEvent = $validator(
$object({
invocationSchemaVersion: $string,
invocationId: $string,
job: $ref(s3BatchEventJob),
tasks: $array($ref(s3BatchEventTask)),
})
)
8 changes: 8 additions & 0 deletions src/lib/aws/s3-batch/s3.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { S3BatchEvent } from './s3.type'

import type { S3BatchEvent as LambdaS3BatchEvent } from 'aws-lambda'

test('type is compatible', () => {
const _test: S3BatchEvent = {} as unknown as LambdaS3BatchEvent
const _test2: LambdaS3BatchEvent = {} as unknown as S3BatchEvent
})
57 changes: 57 additions & 0 deletions src/lib/aws/s3-batch/s3.type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/**
* 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 S3BatchEventTask {
taskId: string
s3Key: string
s3VersionId: string | null
s3BucketArn: string
}

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

export interface S3BatchEventJob {
id: string
}

export interface S3BatchEvent {
invocationSchemaVersion: string
invocationId: string
job: S3BatchEventJob
tasks: S3BatchEventTask[]
}

export const S3BatchEvent = {
validate: require('./schemas/s3-batch-event.schema.js') as ValidateFunction<S3BatchEvent>,
get schema() {
return S3BatchEvent.validate.schema
},
get errors() {
return S3BatchEvent.validate.errors ?? undefined
},
is: (o: unknown): o is S3BatchEvent => S3BatchEvent.validate(o) === true,
assert: (o: unknown) => {
if (!S3BatchEvent.validate(o)) {
throw new AjvValidator.ValidationError(S3BatchEvent.errors ?? [])
}
},
} as const
5 changes: 5 additions & 0 deletions src/lib/aws/s3-batch/schemas/s3-batch-event-task.schema.js

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

5 changes: 5 additions & 0 deletions src/lib/aws/s3-batch/schemas/s3-batch-event.schema.js

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

0 comments on commit 7a8982a

Please sign in to comment.