Skip to content

Commit ec11d94

Browse files
committed
merge from main
2 parents d593a4d + 5490e02 commit ec11d94

12 files changed

+254
-89
lines changed

CHANGELOG.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
## [1.27.7](https://github.com/ocadotechnology/codeforlife-package-javascript/compare/v1.27.6...v1.27.7) (2024-06-03)
2+
3+
4+
### Bug Fixes
5+
6+
* api types ([#41](https://github.com/ocadotechnology/codeforlife-package-javascript/issues/41)) ([444a51f](https://github.com/ocadotechnology/codeforlife-package-javascript/commit/444a51f488863c0f23e0fb32a1b9d87c7bc76c34))
7+
18
## [1.27.6](https://github.com/ocadotechnology/codeforlife-package-javascript/compare/v1.27.5...v1.27.6) (2024-05-31)
29

310

lib/cjs/api/models.d.ts

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
}>;

lib/cjs/api/models.js

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });

lib/cjs/api/urls.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare const urls: Record<string, {
2+
list: string;
3+
detail: string;
4+
}>;
5+
export default urls;

lib/cjs/api/urls.js

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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;

lib/esm/api/models.d.ts

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
}>;

lib/esm/api/models.js

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export {};

lib/esm/api/urls.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
declare const urls: Record<string, {
2+
list: string;
3+
detail: string;
4+
}>;
5+
export default urls;

lib/esm/api/urls.js

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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;

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "codeforlife",
3-
"version": "1.27.6",
3+
"version": "1.27.7",
44
"private": true,
55
"description": "Common frontend code",
66
"main": "./lib/cjs/index.js",

src/api/index.ts

+7-8
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
import baseQuery from './baseQuery'
2-
import endpoints from './endpoints'
1+
import baseQuery from "./baseQuery"
2+
import endpoints from "./endpoints"
33
import type {
44
AuthFactor,
55
Class,
66
School,
77
Student,
88
Teacher,
9-
User
10-
} from './models'
11-
import tagTypes from './tagTypes'
12-
import urls from './urls'
9+
User,
10+
} from "./models"
11+
import tagTypes from "./tagTypes"
12+
import urls from "./urls"
1313

1414
export {
1515
baseQuery,
@@ -21,6 +21,5 @@ export {
2121
type School,
2222
type Student,
2323
type Teacher,
24-
type User
24+
type User,
2525
}
26-

0 commit comments

Comments
 (0)