@@ -2,7 +2,7 @@ import DynamoDB from 'aws-sdk/clients/dynamodb';
2
2
import { Request } from 'express' ;
3
3
import { isValidEmail } from './users/model' ;
4
4
import { assert } from 'console' ;
5
- import { getOfficeId , isValidOfficeId } from './getOffices' ;
5
+ import { isValidOfficeId } from './getOffices' ;
6
6
import { Arrays } from 'collection-fns' ;
7
7
import { UserType } from 'aws-sdk/clients/cognitoidentityserviceprovider' ;
8
8
@@ -19,7 +19,7 @@ type CognitoAuthConfig = {
19
19
region : string ;
20
20
} ;
21
21
22
- type OfficeQuotaConfig = { id ? : string ; name : string ; quota : number ; parkingQuota ?: number } ;
22
+ type OfficeQuotaConfig = { id : string ; name : string ; quota : number ; parkingQuota ?: number } ;
23
23
export type OfficeQuota = Required < OfficeQuotaConfig > ;
24
24
25
25
const isOfficeQuotaConfigs = ( input : any ) : input is OfficeQuotaConfig [ ] =>
@@ -30,7 +30,7 @@ const isOfficeQuotaConfigs = (input: any): input is OfficeQuotaConfig[] =>
30
30
o !== null &&
31
31
typeof o . name === 'string' &&
32
32
typeof o . quota === 'number' &&
33
- ( typeof o . id === 'undefined' || typeof o . id === ' string') &&
33
+ typeof o . id === 'string' &&
34
34
( typeof o . parkingQuota === 'undefined' || typeof o . parkingQuota === 'number' )
35
35
) ;
36
36
@@ -54,14 +54,13 @@ export type Config = {
54
54
readonly ?: boolean ;
55
55
} ;
56
56
57
- const parseOfficeQuotas = ( OFFICE_QUOTAS : string ) => {
57
+ const parseOfficeQuotas = ( OFFICE_QUOTAS : string ) : OfficeQuota [ ] => {
58
58
const officeQuotaConfigs = JSON . parse ( OFFICE_QUOTAS ) ;
59
59
if ( ! isOfficeQuotaConfigs ( officeQuotaConfigs ) ) {
60
60
throw new Error ( 'Invalid office quotas in OFFICE_QUOTAS' ) ;
61
61
}
62
62
const officeQuotas = officeQuotaConfigs . map ( ( o ) => ( {
63
63
...o ,
64
- id : o . id ?? getOfficeId ( o . name ) ,
65
64
parkingQuota : o . parkingQuota ?? 0 ,
66
65
} ) ) ;
67
66
const invalidIds = officeQuotas . map ( ( o ) => o . id ) . filter ( ( id ) => ! isValidOfficeId ( id ) ) ;
0 commit comments