@@ -2,7 +2,44 @@ import * as t from 'io-ts';
2
2
3
3
import { brandedType } from '../../util/io-ts' ;
4
4
import type { Brand } from '../../util/types' ;
5
+ import { defineIDModel } from '../util/id-model' ;
5
6
6
7
export type LocationId = Brand < number , { readonly s : unique symbol } , 'job.id' > ;
7
8
8
9
export const LOCATION_ID = brandedType < number , LocationId > ( t . number ) ;
10
+
11
+ const LOCATION_STATUS = {
12
+ active : null ,
13
+ expired : null ,
14
+ } ;
15
+
16
+ export default defineIDModel ( {
17
+ tableName : 'location' ,
18
+ fields : {
19
+ generated : {
20
+ id : { kind : 'branded-integer' , brand : LOCATION_ID } ,
21
+ } ,
22
+ optional : {
23
+ externalId : { kind : 'checked' , type : t . string } ,
24
+ name : { kind : 'checked' , type : t . string } ,
25
+ latitude : { kind : 'checked' , type : t . number } ,
26
+ longitude : { kind : 'checked' , type : t . number } ,
27
+ iso3 : { kind : 'checked' , type : t . string } ,
28
+ pcode : { kind : 'checked' , type : t . string } ,
29
+ // Even though this column is defined as int8, it is
30
+ // fetched as a string by knex, since it is bigint
31
+ validOn : { kind : 'checked' , type : t . string } ,
32
+ parentId : { kind : 'branded-integer' , brand : LOCATION_ID } ,
33
+ } ,
34
+ accidentallyOptional : {
35
+ adminLevel : { kind : 'checked' , type : t . number } ,
36
+ status : {
37
+ kind : 'enum' ,
38
+ values : LOCATION_STATUS ,
39
+ } ,
40
+ itosSync : { kind : 'checked' , type : t . boolean } ,
41
+ } ,
42
+ } ,
43
+ idField : 'id' ,
44
+ softDeletionEnabled : false ,
45
+ } ) ;
0 commit comments