-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: move some more complex schemas to separate file
- Loading branch information
Showing
2 changed files
with
50 additions
and
46 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
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,46 @@ | ||
import { Type } from '@sinclair/typebox' | ||
|
||
const HEX_REGEX_32_BYTES = '^[0-9a-fA-F]{64}$' | ||
export const HEX_STRING_32_BYTES = Type.String({ pattern: HEX_REGEX_32_BYTES }) | ||
|
||
const dateTimeString = Type.String({ format: 'date-time' }) | ||
const latitude = Type.Number({ minimum: -90, maximum: 90 }) | ||
const longitude = Type.Number({ minimum: -180, maximum: 180 }) | ||
|
||
export const projectToAdd = Type.Object({ | ||
projectName: Type.String({ minLength: 1 }), | ||
projectKey: HEX_STRING_32_BYTES, | ||
encryptionKeys: Type.Object({ | ||
auth: HEX_STRING_32_BYTES, | ||
config: HEX_STRING_32_BYTES, | ||
data: HEX_STRING_32_BYTES, | ||
blobIndex: HEX_STRING_32_BYTES, | ||
blob: HEX_STRING_32_BYTES, | ||
}), | ||
}) | ||
|
||
export const observationToAdd = Type.Object({ | ||
docId: Type.String(), | ||
createdAt: dateTimeString, | ||
updatedAt: dateTimeString, | ||
deleted: Type.Boolean(), | ||
lat: Type.Optional(latitude), | ||
lon: Type.Optional(longitude), | ||
attachments: Type.Array( | ||
Type.Object({ | ||
url: Type.String(), | ||
}), | ||
), | ||
tags: Type.Record( | ||
Type.String(), | ||
Type.Union([ | ||
Type.Boolean(), | ||
Type.Number(), | ||
Type.String(), | ||
Type.Null(), | ||
Type.Array( | ||
Type.Union([Type.Boolean(), Type.Number(), Type.String(), Type.Null()]), | ||
), | ||
]), | ||
), | ||
}) |