This repository has been archived by the owner on Dec 10, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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
- Loading branch information
1 parent
d7f9039
commit 9ca2373
Showing
6 changed files
with
166 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from './s3.type' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { $array, $integer, $object, $optional, $ref, $string, $validator } from '@skyleague/therefore' | ||
|
||
export const s3EventRecordGlacierEventData = $object({ | ||
restoreEventData: $object({ | ||
lifecycleRestorationExpiryTime: $string, | ||
lifecycleRestoreStorageClass: $string, | ||
}), | ||
}) | ||
|
||
export const s3EventRecord = $validator( | ||
$object({ | ||
eventVersion: $string, | ||
eventSource: $string, | ||
awsRegion: $string, | ||
eventTime: $string, | ||
eventName: $string, | ||
userIdentity: $object({ | ||
principalId: $string, | ||
}), | ||
requestParameters: $object({ | ||
sourceIPAddress: $string, | ||
}), | ||
responseElements: $object({ | ||
'x-amz-request-id': $string, | ||
'x-amz-id-2': $string, | ||
}), | ||
s3: $object({ | ||
s3SchemaVersion: $string, | ||
configurationId: $string, | ||
bucket: $object({ | ||
name: $string, | ||
ownerIdentity: $object({ | ||
principalId: $string, | ||
}), | ||
arn: $string, | ||
}), | ||
object: $object({ | ||
key: $string, | ||
size: $integer, | ||
eTag: $string, | ||
versionId: $optional($string, 'explicit'), | ||
sequencer: $string, | ||
}), | ||
}), | ||
glacierEventData: $optional(s3EventRecordGlacierEventData, 'explicit'), | ||
}) | ||
) | ||
|
||
export const s3Event = $validator( | ||
$object({ | ||
Records: $array($ref(s3EventRecord)), | ||
}) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { S3Event } from './s3.type' | ||
|
||
import type { S3Event as LambdaS3Event } from 'aws-lambda' | ||
|
||
test('type is compatible', () => { | ||
const _test: S3Event = {} as unknown as LambdaS3Event | ||
const _test2: LambdaS3Event = {} as unknown as S3Event | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/** | ||
* 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 S3EventRecordGlacierEventData { | ||
restoreEventData: { | ||
lifecycleRestorationExpiryTime: string | ||
lifecycleRestoreStorageClass: string | ||
} | ||
} | ||
|
||
export interface S3EventRecord { | ||
eventVersion: string | ||
eventSource: string | ||
awsRegion: string | ||
eventTime: string | ||
eventName: string | ||
userIdentity: { | ||
principalId: string | ||
} | ||
requestParameters: { | ||
sourceIPAddress: string | ||
} | ||
responseElements: { | ||
'x-amz-request-id': string | ||
'x-amz-id-2': string | ||
} | ||
s3: { | ||
s3SchemaVersion: string | ||
configurationId: string | ||
bucket: { | ||
name: string | ||
ownerIdentity: { | ||
principalId: string | ||
} | ||
arn: string | ||
} | ||
object: { | ||
key: string | ||
size: number | ||
eTag: string | ||
versionId?: string | undefined | ||
sequencer: string | ||
} | ||
} | ||
glacierEventData?: | ||
| { | ||
restoreEventData: { | ||
lifecycleRestorationExpiryTime: string | ||
lifecycleRestoreStorageClass: string | ||
} | ||
} | ||
| undefined | ||
} | ||
|
||
export const S3EventRecord = { | ||
validate: require('./schemas/s3-event-record.schema.js') as ValidateFunction<S3EventRecord>, | ||
get schema() { | ||
return S3EventRecord.validate.schema | ||
}, | ||
get errors() { | ||
return S3EventRecord.validate.errors ?? undefined | ||
}, | ||
is: (o: unknown): o is S3EventRecord => S3EventRecord.validate(o) === true, | ||
assert: (o: unknown) => { | ||
if (!S3EventRecord.validate(o)) { | ||
throw new AjvValidator.ValidationError(S3EventRecord.errors ?? []) | ||
} | ||
}, | ||
} as const | ||
|
||
export interface S3Event { | ||
Records: S3EventRecord[] | ||
} | ||
|
||
export const S3Event = { | ||
validate: require('./schemas/s3-event.schema.js') as ValidateFunction<S3Event>, | ||
get schema() { | ||
return S3Event.validate.schema | ||
}, | ||
get errors() { | ||
return S3Event.validate.errors ?? undefined | ||
}, | ||
is: (o: unknown): o is S3Event => S3Event.validate(o) === true, | ||
assert: (o: unknown) => { | ||
if (!S3Event.validate(o)) { | ||
throw new AjvValidator.ValidationError(S3Event.errors ?? []) | ||
} | ||
}, | ||
} as const |
Oops, something went wrong.