File tree 18 files changed +872
-135
lines changed
18 files changed +872
-135
lines changed Original file line number Diff line number Diff line change
1
+ ## [ 1.27.6] ( https://github.com/ocadotechnology/codeforlife-package-javascript/compare/v1.27.5...v1.27.6 ) (2024-05-31)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * import ([ 9ba872b] ( https://github.com/ocadotechnology/codeforlife-package-javascript/commit/9ba872bc948f23059bc504c95e01b31c47cdb734 ) )
7
+ * linting errors ([ 23fbb17] ( https://github.com/ocadotechnology/codeforlife-package-javascript/commit/23fbb1724d3d99fd700c2fdc9dfad758e058fadf ) )
8
+ * rtk helpers ([ #40 ] ( https://github.com/ocadotechnology/codeforlife-package-javascript/issues/40 ) ) ([ 3b7c90a] ( https://github.com/ocadotechnology/codeforlife-package-javascript/commit/3b7c90a73eb68399160a58e5995c588da95cc5d0 ) )
9
+
1
10
## [ 1.27.5] ( https://github.com/ocadotechnology/codeforlife-package-javascript/compare/v1.27.4...v1.27.5 ) (2023-10-24)
2
11
3
12
Original file line number Diff line number Diff line change
1
+ import { COUNTRY_ISO_CODES , UK_COUNTIES } from '../helpers/general' ;
2
+ import type { Model } from '../helpers/rtkQuery' ;
3
+ export type User = Model < number , {
4
+ password : string ;
5
+ last_login ?: Date ;
6
+ first_name : string ;
7
+ last_name ?: string ;
8
+ email ?: string ;
9
+ is_staff : boolean ;
10
+ is_active : boolean ;
11
+ date_joined : Date ;
12
+ requesting_to_join_class ?: string ;
13
+ teacher ?: Teacher ;
14
+ student ?: Student ;
15
+ } > ;
16
+ export type Teacher = Model < number , {
17
+ user : number ;
18
+ school ?: number ;
19
+ is_admin : boolean ;
20
+ } > ;
21
+ export type Student = Model < number , {
22
+ user : number ;
23
+ school : number ;
24
+ klass : string ;
25
+ } > ;
26
+ export type School = Model < number , {
27
+ name : string ;
28
+ country ?: ( typeof COUNTRY_ISO_CODES ) [ number ] ;
29
+ uk_county ?: ( typeof UK_COUNTIES ) [ number ] ;
30
+ } > ;
31
+ export type Class = Model < string , {
32
+ name : string ;
33
+ teacher : number ;
34
+ school : number ;
35
+ read_classmates_data : boolean ;
36
+ receive_requests_until ?: Date ;
37
+ } > ;
38
+ export type AuthFactor = Model < number , {
39
+ user : number ;
40
+ type : 'otp' ;
41
+ } > ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
Original file line number Diff line number Diff line change
1
+ declare const urls : Record < string , {
2
+ list : string ;
3
+ detail : string ;
4
+ } > ;
5
+ export default urls ;
Original file line number Diff line number Diff line change
1
+ "use strict" ;
2
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
3
+ var urls = {
4
+ user : {
5
+ list : 'users/' ,
6
+ detail : 'users/<id>/'
7
+ } ,
8
+ teacher : {
9
+ list : 'users/teachers/' ,
10
+ detail : 'users/teachers/<id>/'
11
+ } ,
12
+ student : {
13
+ list : 'users/students/' ,
14
+ detail : 'users/students/<id>/'
15
+ } ,
16
+ school : {
17
+ list : 'schools/' ,
18
+ detail : 'schools/<id>/'
19
+ } ,
20
+ class : {
21
+ list : 'classes/' ,
22
+ detail : 'classes/<id>/'
23
+ } ,
24
+ otpBypassToken : {
25
+ list : 'otp-bypass-tokens/' ,
26
+ detail : 'otp-bypass-tokens/<id>/'
27
+ } ,
28
+ authFactor : {
29
+ list : 'auth-factors/' ,
30
+ detail : 'auth-factors/<id>/'
31
+ }
32
+ } ;
33
+ exports . default = urls ;
Original file line number Diff line number Diff line change
1
+ import { COUNTRY_ISO_CODES , UK_COUNTIES } from '../helpers/general' ;
2
+ import type { Model } from '../helpers/rtkQuery' ;
3
+ export type User = Model < number , {
4
+ password : string ;
5
+ last_login ?: Date ;
6
+ first_name : string ;
7
+ last_name ?: string ;
8
+ email ?: string ;
9
+ is_staff : boolean ;
10
+ is_active : boolean ;
11
+ date_joined : Date ;
12
+ requesting_to_join_class ?: string ;
13
+ teacher ?: Teacher ;
14
+ student ?: Student ;
15
+ } > ;
16
+ export type Teacher = Model < number , {
17
+ user : number ;
18
+ school ?: number ;
19
+ is_admin : boolean ;
20
+ } > ;
21
+ export type Student = Model < number , {
22
+ user : number ;
23
+ school : number ;
24
+ klass : string ;
25
+ } > ;
26
+ export type School = Model < number , {
27
+ name : string ;
28
+ country ?: ( typeof COUNTRY_ISO_CODES ) [ number ] ;
29
+ uk_county ?: ( typeof UK_COUNTIES ) [ number ] ;
30
+ } > ;
31
+ export type Class = Model < string , {
32
+ name : string ;
33
+ teacher : number ;
34
+ school : number ;
35
+ read_classmates_data : boolean ;
36
+ receive_requests_until ?: Date ;
37
+ } > ;
38
+ export type AuthFactor = Model < number , {
39
+ user : number ;
40
+ type : 'otp' ;
41
+ } > ;
Original file line number Diff line number Diff line change
1
+ export { } ;
Original file line number Diff line number Diff line change
1
+ declare const urls : Record < string , {
2
+ list : string ;
3
+ detail : string ;
4
+ } > ;
5
+ export default urls ;
Original file line number Diff line number Diff line change
1
+ var urls = {
2
+ user : {
3
+ list : 'users/' ,
4
+ detail : 'users/<id>/'
5
+ } ,
6
+ teacher : {
7
+ list : 'users/teachers/' ,
8
+ detail : 'users/teachers/<id>/'
9
+ } ,
10
+ student : {
11
+ list : 'users/students/' ,
12
+ detail : 'users/students/<id>/'
13
+ } ,
14
+ school : {
15
+ list : 'schools/' ,
16
+ detail : 'schools/<id>/'
17
+ } ,
18
+ class : {
19
+ list : 'classes/' ,
20
+ detail : 'classes/<id>/'
21
+ } ,
22
+ otpBypassToken : {
23
+ list : 'otp-bypass-tokens/' ,
24
+ detail : 'otp-bypass-tokens/<id>/'
25
+ } ,
26
+ authFactor : {
27
+ list : 'auth-factors/' ,
28
+ detail : 'auth-factors/<id>/'
29
+ }
30
+ } ;
31
+ export default urls ;
Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " codeforlife" ,
3
- "version" : " 1.27.5 " ,
3
+ "version" : " 1.27.6 " ,
4
4
"private" : true ,
5
5
"description" : " Common frontend code" ,
6
6
"main" : " ./lib/cjs/index.js" ,
Original file line number Diff line number Diff line change @@ -112,6 +112,7 @@ export function parseResponseBody(data: unknown): void {
112
112
snakeCaseToCamelCase ( data )
113
113
}
114
114
115
+ // TODO: https://redux-toolkit.js.org/rtk-query/usage/customizing-queries#implementing-a-custom-basequery
115
116
const baseQuery : FetchBaseQuery = async ( args , api , extraOptions ) => {
116
117
await injectCsrfToken ( fetch , args , api )
117
118
Original file line number Diff line number Diff line change @@ -23,12 +23,12 @@ export default function endpoints<ReducerPath extends string>(
23
23
const _build = build as EndpointBuilder < FetchBaseQuery , TagTypes , ReducerPath >
24
24
25
25
return {
26
+ // TODO: https://redux-toolkit.js.org/rtk-query/usage/customizing-queries#implementing-a-queryfn
26
27
logout : _build . mutation < LogoutResult , LogoutQuery > ( {
27
28
query : ( ) => ( {
28
- url : "session/logout/" ,
29
- method : "GET" ,
30
- } ) ,
31
- invalidatesTags : [ "private" ] ,
32
- } ) ,
33
- }
29
+ url : 'session/logout/' ,
30
+ method : 'GET'
31
+ } )
32
+ } )
33
+ } ;
34
34
}
Original file line number Diff line number Diff line change 1
- import baseQuery from "./baseQuery"
2
- import endpoints from "./endpoints"
3
- import tagTypes from "./tagTypes"
1
+ import baseQuery from './baseQuery'
2
+ import endpoints from './endpoints'
3
+ import type {
4
+ AuthFactor ,
5
+ Class ,
6
+ School ,
7
+ Student ,
8
+ Teacher ,
9
+ User
10
+ } from './models'
11
+ import tagTypes from './tagTypes'
12
+ import urls from './urls'
13
+
14
+ export {
15
+ baseQuery ,
16
+ endpoints ,
17
+ tagTypes ,
18
+ urls ,
19
+ type AuthFactor ,
20
+ type Class ,
21
+ type School ,
22
+ type Student ,
23
+ type Teacher ,
24
+ type User
25
+ }
4
26
5
- export { baseQuery , endpoints , tagTypes }
Original file line number Diff line number Diff line change
1
+ import { COUNTRY_ISO_CODES , UK_COUNTIES } from '../helpers/general' ;
2
+ import type { Model } from '../helpers/rtkQuery' ;
3
+
4
+ export type User = Model <
5
+ number ,
6
+ {
7
+ password : string ;
8
+ last_login ?: Date ;
9
+ first_name : string ;
10
+ last_name ?: string ;
11
+ email ?: string ;
12
+ is_staff : boolean ;
13
+ is_active : boolean ;
14
+ date_joined : Date ;
15
+ requesting_to_join_class ?: string ;
16
+ teacher ?: Teacher ;
17
+ student ?: Student ;
18
+ }
19
+ > ;
20
+
21
+ export type Teacher = Model <
22
+ number ,
23
+ {
24
+ user : number ;
25
+ school ?: number ;
26
+ is_admin : boolean ;
27
+ }
28
+ > ;
29
+
30
+ export type Student = Model <
31
+ number ,
32
+ {
33
+ user : number ;
34
+ school : number ;
35
+ klass : string ;
36
+ }
37
+ > ;
38
+
39
+ export type School = Model <
40
+ number ,
41
+ {
42
+ name : string ;
43
+ country ?: ( typeof COUNTRY_ISO_CODES ) [ number ] ;
44
+ uk_county ?: ( typeof UK_COUNTIES ) [ number ] ;
45
+ }
46
+ > ;
47
+
48
+ export type Class = Model <
49
+ string ,
50
+ {
51
+ name : string ;
52
+ teacher : number ;
53
+ school : number ;
54
+ read_classmates_data : boolean ;
55
+ receive_requests_until ?: Date ;
56
+ }
57
+ > ;
58
+
59
+ export type AuthFactor = Model <
60
+ number ,
61
+ {
62
+ user : number ;
63
+ type : 'otp' ;
64
+ }
65
+ > ;
Original file line number Diff line number Diff line change 1
1
const tagTypes = [
2
- // A special tag used to mark data as private.
3
- // Private data will be invalidated on logout.
4
- "private" ,
5
-
6
2
// These are the tags for the common models used throughout our system.
7
3
// https://github.com/ocadotechnology/codeforlife-package-python/tree/main/codeforlife/user/models
8
- "user" ,
9
- "school" ,
10
- "class" ,
11
- "teacher" ,
12
- "student" ,
13
- ] as const
4
+ // NOTE: Don't use the "Teacher" and "Student" tags. Use "User" instead.
5
+ 'User' ,
6
+ 'School' ,
7
+ 'Class' ,
8
+ 'AuthFactor'
9
+ ] as const ;
14
10
15
11
export default tagTypes
16
12
export type TagTypes = ( typeof tagTypes ) [ number ]
Original file line number Diff line number Diff line change
1
+ const urls : Record <
2
+ string ,
3
+ {
4
+ list : string ;
5
+ detail : string ;
6
+ }
7
+ > = {
8
+ user : {
9
+ list : 'users/' ,
10
+ detail : 'users/<id>/'
11
+ } ,
12
+ teacher : {
13
+ list : 'users/teachers/' ,
14
+ detail : 'users/teachers/<id>/'
15
+ } ,
16
+ student : {
17
+ list : 'users/students/' ,
18
+ detail : 'users/students/<id>/'
19
+ } ,
20
+ school : {
21
+ list : 'schools/' ,
22
+ detail : 'schools/<id>/'
23
+ } ,
24
+ class : {
25
+ list : 'classes/' ,
26
+ detail : 'classes/<id>/'
27
+ } ,
28
+ otpBypassToken : {
29
+ list : 'otp-bypass-tokens/' ,
30
+ detail : 'otp-bypass-tokens/<id>/'
31
+ } ,
32
+ authFactor : {
33
+ list : 'auth-factors/' ,
34
+ detail : 'auth-factors/<id>/'
35
+ }
36
+ } ;
37
+
38
+ export default urls ;
You can’t perform that action at this time.
0 commit comments