@totoday/quinn-sdk 0.2.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -68,11 +68,11 @@ class Quinn {
68
68
  this.organizations = new organizations_1.OrganizationsService(this.http, this.assertMutationAllowed);
69
69
  this.knowledge = new knowledge_1.KnowledgeService(this.http);
70
70
  this.members = new members_1.MembersService(this.http, this.assertMutationAllowed);
71
- this.roles = new roles_1.RolesService(this.http);
71
+ this.roles = new roles_1.RolesService(this.http, this.assertMutationAllowed);
72
72
  this.levels = new levels_1.LevelsService(this.http);
73
- this.competencies = new competencies_1.CompetenciesService(this.http);
74
- this.courses = new courses_1.CoursesService(this.http);
75
- this.groups = new groups_1.GroupsService(this.http);
73
+ this.competencies = new competencies_1.CompetenciesService(this.http, this.assertMutationAllowed);
74
+ this.courses = new courses_1.CoursesService(this.http, this.assertMutationAllowed);
75
+ this.groups = new groups_1.GroupsService(this.http, this.assertMutationAllowed);
76
76
  this.programs = new programs_1.ProgramsService(this.http);
77
77
  this.progress = new progress_1.ProgressService(this.http);
78
78
  this.endorsements = new endorsements_1.EndorsementsService(this.http, this.assertMutationAllowed);
@@ -1,10 +1,14 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { CompetenciesListQuery, Competency, Course, PagedResult } from '../types';
2
+ import { CompetenciesCreateInput, CompetenciesListQuery, CompetenciesUpdateInput, Competency, Course, PagedResult } from '../types';
3
3
  export declare class CompetenciesService {
4
4
  private readonly http;
5
- constructor(http: AxiosInstance);
5
+ private readonly assertMutationAllowed;
6
+ constructor(http: AxiosInstance, assertMutationAllowed: (operation: string) => void);
6
7
  list(query: CompetenciesListQuery): Promise<PagedResult<Competency>>;
7
8
  get(id: string): Promise<Competency | null>;
8
9
  batchGet(ids: string[]): Promise<Competency[]>;
9
10
  listCourses(id: string): Promise<Course[]>;
11
+ create(input: CompetenciesCreateInput): Promise<Competency | null>;
12
+ update(input: CompetenciesUpdateInput): Promise<Competency | null>;
13
+ delete(competencyId: string): Promise<void>;
10
14
  }
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CompetenciesService = void 0;
4
4
  class CompetenciesService {
5
5
  http;
6
- constructor(http) {
6
+ assertMutationAllowed;
7
+ constructor(http, assertMutationAllowed) {
7
8
  this.http = http;
9
+ this.assertMutationAllowed = assertMutationAllowed;
8
10
  }
9
11
  async list(query) {
10
12
  const resp = await this.http.get('/competencies', { params: query });
@@ -22,5 +24,25 @@ class CompetenciesService {
22
24
  const resp = await this.http.get(`/competencies/${id}/courses`);
23
25
  return resp.data.items;
24
26
  }
27
+ async create(input) {
28
+ this.assertMutationAllowed('competencies.create');
29
+ const resp = await this.http.post('/competencies', input);
30
+ return resp.data.item;
31
+ }
32
+ async update(input) {
33
+ this.assertMutationAllowed('competencies.update');
34
+ const resp = await this.http.patch(`/competencies/${input.competencyId}`, {
35
+ name: input.name,
36
+ description: input.description,
37
+ roleId: input.roleId,
38
+ levelIds: input.levelIds,
39
+ settings: input.settings,
40
+ });
41
+ return resp.data.item;
42
+ }
43
+ async delete(competencyId) {
44
+ this.assertMutationAllowed('competencies.delete');
45
+ await this.http.delete(`/competencies/${competencyId}`);
46
+ }
25
47
  }
26
48
  exports.CompetenciesService = CompetenciesService;
@@ -1,12 +1,17 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { Course, PagedResult } from '../types';
2
+ import { AssignedUser, Course, CoursesAssignToGroupsInput, CoursesAssignToUsersInput, CoursesUnassignFromGroupInput, CoursesUnassignFromUserInput, PagedResult } from '../types';
3
3
  export declare class CoursesService {
4
4
  private readonly http;
5
- constructor(http: AxiosInstance);
5
+ private readonly assertMutationAllowed;
6
+ constructor(http: AxiosInstance, assertMutationAllowed: (operation: string) => void);
6
7
  list(query?: {
7
8
  limit?: number;
8
9
  token?: string;
9
10
  }): Promise<PagedResult<Course>>;
10
11
  get(id: string): Promise<Course | null>;
11
12
  batchGet(ids: string[]): Promise<Course[]>;
13
+ assignToUsers(input: CoursesAssignToUsersInput): Promise<AssignedUser[]>;
14
+ assignToGroups(input: CoursesAssignToGroupsInput): Promise<void>;
15
+ unassignFromUser(input: CoursesUnassignFromUserInput): Promise<void>;
16
+ unassignFromGroup(input: CoursesUnassignFromGroupInput): Promise<void>;
12
17
  }
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CoursesService = void 0;
4
4
  class CoursesService {
5
5
  http;
6
- constructor(http) {
6
+ assertMutationAllowed;
7
+ constructor(http, assertMutationAllowed) {
7
8
  this.http = http;
9
+ this.assertMutationAllowed = assertMutationAllowed;
8
10
  }
9
11
  async list(query = {}) {
10
12
  const resp = await this.http.get('/courses', { params: query });
@@ -18,5 +20,28 @@ class CoursesService {
18
20
  const resp = await this.http.post('/courses/batch', { ids });
19
21
  return resp.data.items;
20
22
  }
23
+ async assignToUsers(input) {
24
+ this.assertMutationAllowed('courses.assignToUsers');
25
+ const resp = await this.http.post(`/courses/${input.courseId}/assign/users`, {
26
+ userIds: input.userIds,
27
+ dueDateConfig: input.dueDateConfig,
28
+ });
29
+ return resp.data.assignedUsers;
30
+ }
31
+ async assignToGroups(input) {
32
+ this.assertMutationAllowed('courses.assignToGroups');
33
+ await this.http.post(`/courses/${input.courseId}/assign/groups`, {
34
+ groupIds: input.groupIds,
35
+ dueDateConfig: input.dueDateConfig,
36
+ });
37
+ }
38
+ async unassignFromUser(input) {
39
+ this.assertMutationAllowed('courses.unassignFromUser');
40
+ await this.http.delete(`/courses/${input.courseId}/users/${input.userId}`);
41
+ }
42
+ async unassignFromGroup(input) {
43
+ this.assertMutationAllowed('courses.unassignFromGroup');
44
+ await this.http.delete(`/courses/${input.courseId}/groups/${input.groupId}`);
45
+ }
21
46
  }
22
47
  exports.CoursesService = CoursesService;
@@ -1,10 +1,16 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { Group, GroupMember } from '../types';
2
+ import { AssignedUser, Group, GroupMember, GroupsAddMembersInput, GroupsCreateInput, GroupsCreateResult, GroupsRemoveMemberInput, GroupsUpdateNameInput } from '../types';
3
3
  export declare class GroupsService {
4
4
  private readonly http;
5
- constructor(http: AxiosInstance);
5
+ private readonly assertMutationAllowed;
6
+ constructor(http: AxiosInstance, assertMutationAllowed: (operation: string) => void);
6
7
  list(): Promise<Group[]>;
7
8
  get(id: string): Promise<Group | null>;
8
9
  batchGet(ids: string[]): Promise<Group[]>;
9
10
  listMembers(groupId: string): Promise<GroupMember[]>;
11
+ create(input: GroupsCreateInput): Promise<GroupsCreateResult>;
12
+ updateName(input: GroupsUpdateNameInput): Promise<Group | null>;
13
+ delete(groupId: string): Promise<void>;
14
+ addMembers(input: GroupsAddMembersInput): Promise<AssignedUser[]>;
15
+ removeMember(input: GroupsRemoveMemberInput): Promise<void>;
10
16
  }
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.GroupsService = void 0;
4
4
  class GroupsService {
5
5
  http;
6
- constructor(http) {
6
+ assertMutationAllowed;
7
+ constructor(http, assertMutationAllowed) {
7
8
  this.http = http;
9
+ this.assertMutationAllowed = assertMutationAllowed;
8
10
  }
9
11
  async list() {
10
12
  const resp = await this.http.get('/groups');
@@ -22,5 +24,30 @@ class GroupsService {
22
24
  const resp = await this.http.get(`/groups/${groupId}/members`);
23
25
  return resp.data.items;
24
26
  }
27
+ async create(input) {
28
+ this.assertMutationAllowed('groups.create');
29
+ const resp = await this.http.post('/groups', input);
30
+ return resp.data;
31
+ }
32
+ async updateName(input) {
33
+ this.assertMutationAllowed('groups.updateName');
34
+ const resp = await this.http.put(`/groups/${input.groupId}/name`, { name: input.name });
35
+ return resp.data.item;
36
+ }
37
+ async delete(groupId) {
38
+ this.assertMutationAllowed('groups.delete');
39
+ await this.http.delete(`/groups/${groupId}`);
40
+ }
41
+ async addMembers(input) {
42
+ this.assertMutationAllowed('groups.addMembers');
43
+ const resp = await this.http.post(`/groups/${input.groupId}/members`, {
44
+ userIds: input.userIds,
45
+ });
46
+ return resp.data.assignedUsers;
47
+ }
48
+ async removeMember(input) {
49
+ this.assertMutationAllowed('groups.removeMember');
50
+ await this.http.delete(`/groups/${input.groupId}/members/${input.userId}`);
51
+ }
25
52
  }
26
53
  exports.GroupsService = GroupsService;
@@ -1,5 +1,5 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { PagedResult, Program } from '../types';
2
+ import { Course, PagedResult, Program } from '../types';
3
3
  export declare class ProgramsService {
4
4
  private readonly http;
5
5
  constructor(http: AxiosInstance);
@@ -9,4 +9,5 @@ export declare class ProgramsService {
9
9
  }): Promise<PagedResult<Program>>;
10
10
  get(id: string): Promise<Program | null>;
11
11
  batchGet(ids: string[]): Promise<Program[]>;
12
+ listCourses(id: string): Promise<Course[]>;
12
13
  }
@@ -18,5 +18,9 @@ class ProgramsService {
18
18
  const resp = await this.http.post('/programs/batch', { ids });
19
19
  return resp.data.items;
20
20
  }
21
+ async listCourses(id) {
22
+ const resp = await this.http.get(`/programs/${id}/courses`);
23
+ return resp.data.items;
24
+ }
21
25
  }
22
26
  exports.ProgramsService = ProgramsService;
@@ -1,9 +1,14 @@
1
1
  import { AxiosInstance } from 'axios';
2
- import { Role } from '../types';
2
+ import { Role, RolesCreateInput, RolesUpdateInput, RolesUpdateLevelsInput, Level } from '../types';
3
3
  export declare class RolesService {
4
4
  private readonly http;
5
- constructor(http: AxiosInstance);
5
+ private readonly assertMutationAllowed;
6
+ constructor(http: AxiosInstance, assertMutationAllowed: (operation: string) => void);
6
7
  list(): Promise<Role[]>;
7
8
  get(id: string): Promise<Role | null>;
8
9
  batchGet(ids: string[]): Promise<Role[]>;
10
+ create(input: RolesCreateInput): Promise<Role | null>;
11
+ update(input: RolesUpdateInput): Promise<Role | null>;
12
+ delete(roleId: string): Promise<void>;
13
+ updateLevels(input: RolesUpdateLevelsInput): Promise<Level[]>;
9
14
  }
@@ -3,8 +3,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RolesService = void 0;
4
4
  class RolesService {
5
5
  http;
6
- constructor(http) {
6
+ assertMutationAllowed;
7
+ constructor(http, assertMutationAllowed) {
7
8
  this.http = http;
9
+ this.assertMutationAllowed = assertMutationAllowed;
8
10
  }
9
11
  async list() {
10
12
  const resp = await this.http.get('/roles');
@@ -18,5 +20,24 @@ class RolesService {
18
20
  const resp = await this.http.post('/roles/batch', { ids });
19
21
  return resp.data.items;
20
22
  }
23
+ async create(input) {
24
+ this.assertMutationAllowed('roles.create');
25
+ const resp = await this.http.post('/roles', input);
26
+ return resp.data.item;
27
+ }
28
+ async update(input) {
29
+ this.assertMutationAllowed('roles.update');
30
+ const resp = await this.http.patch(`/roles/${input.roleId}`, { label: input.label });
31
+ return resp.data.item;
32
+ }
33
+ async delete(roleId) {
34
+ this.assertMutationAllowed('roles.delete');
35
+ await this.http.delete(`/roles/${roleId}`);
36
+ }
37
+ async updateLevels(input) {
38
+ this.assertMutationAllowed('roles.updateLevels');
39
+ const resp = await this.http.put(`/roles/${input.roleId}/levels`, { levels: input.levels });
40
+ return resp.data.items;
41
+ }
21
42
  }
22
43
  exports.RolesService = RolesService;
package/dist/types.d.ts CHANGED
@@ -18,13 +18,6 @@ export interface Organization {
18
18
  }
19
19
  export interface OrganizationDetails {
20
20
  organization: Organization | null;
21
- stats: {
22
- members: number;
23
- managers: number;
24
- roles: number;
25
- levels: number;
26
- competencies: number;
27
- };
28
21
  }
29
22
  export interface OrganizationUpdateInput {
30
23
  name?: string;
@@ -40,7 +33,6 @@ export interface Member {
40
33
  managerUid: string | null;
41
34
  roleIds: string[];
42
35
  createdAt: string;
43
- activatedAt: string | null;
44
36
  phoneNumber: string | null;
45
37
  }
46
38
  export interface MembersListQuery extends PaginationQuery {
@@ -86,6 +78,21 @@ export interface Role {
86
78
  createdAt: string;
87
79
  updatedAt: string;
88
80
  }
81
+ export interface RolesCreateInput {
82
+ label: string;
83
+ }
84
+ export interface RolesUpdateInput {
85
+ roleId: string;
86
+ label?: string;
87
+ }
88
+ export interface RoleLevelInput {
89
+ id?: string;
90
+ name: string;
91
+ }
92
+ export interface RolesUpdateLevelsInput {
93
+ roleId: string;
94
+ levels: RoleLevelInput[];
95
+ }
89
96
  export interface Level {
90
97
  id: string;
91
98
  roleId: string;
@@ -105,12 +112,32 @@ export interface LevelsListQuery extends PaginationQuery {
105
112
  export interface Competency {
106
113
  id: string;
107
114
  name: string;
115
+ description: string;
108
116
  creatorUid: string;
109
117
  createdAt: string;
110
118
  settings?: {
111
119
  managerOnlyEndorsement: boolean;
112
120
  };
113
121
  }
122
+ export interface CompetenciesCreateInput {
123
+ name: string;
124
+ description?: string;
125
+ roleId: string;
126
+ levelIds: string[];
127
+ settings?: {
128
+ managerOnlyEndorsement?: boolean;
129
+ };
130
+ }
131
+ export interface CompetenciesUpdateInput {
132
+ competencyId: string;
133
+ name?: string;
134
+ description?: string;
135
+ roleId?: string;
136
+ levelIds?: string[];
137
+ settings?: {
138
+ managerOnlyEndorsement?: boolean;
139
+ };
140
+ }
114
141
  export interface CompetenciesListQuery extends PaginationQuery {
115
142
  roleId: string;
116
143
  levelId: string;
@@ -122,6 +149,36 @@ export interface Course {
122
149
  creatorUid: string;
123
150
  createdAt: string;
124
151
  }
152
+ export type DueDateType = 'fixed' | 'relative';
153
+ export interface AssignmentDueConfig {
154
+ type: DueDateType;
155
+ fixedDate?: string;
156
+ timezone?: string;
157
+ relativeDays?: number;
158
+ }
159
+ export interface AssignedUser {
160
+ email: string;
161
+ userId: string;
162
+ assigned: boolean;
163
+ }
164
+ export interface CoursesAssignToUsersInput {
165
+ courseId: string;
166
+ userIds: string[];
167
+ dueDateConfig?: AssignmentDueConfig;
168
+ }
169
+ export interface CoursesAssignToGroupsInput {
170
+ courseId: string;
171
+ groupIds: string[];
172
+ dueDateConfig?: AssignmentDueConfig;
173
+ }
174
+ export interface CoursesUnassignFromUserInput {
175
+ courseId: string;
176
+ userId: string;
177
+ }
178
+ export interface CoursesUnassignFromGroupInput {
179
+ courseId: string;
180
+ groupId: string;
181
+ }
125
182
  export interface KnowledgeSearchInput {
126
183
  query: string;
127
184
  folderId?: string;
@@ -131,6 +188,9 @@ export interface KnowledgeSearchHit {
131
188
  id: string;
132
189
  type: string;
133
190
  text: string;
191
+ documentId?: string | null;
192
+ courseId?: string | null;
193
+ blockId?: string | null;
134
194
  metadata?: Record<string, unknown>;
135
195
  }
136
196
  export interface KnowledgeDocument {
@@ -183,14 +243,32 @@ export interface GroupMember {
183
243
  addedByUid: string;
184
244
  addedAt: string;
185
245
  }
246
+ export interface GroupsCreateInput {
247
+ name: string;
248
+ userIds?: string[];
249
+ }
250
+ export interface GroupsCreateResult {
251
+ group: Group;
252
+ assignedUsers: AssignedUser[];
253
+ }
254
+ export interface GroupsUpdateNameInput {
255
+ groupId: string;
256
+ name: string;
257
+ }
258
+ export interface GroupsAddMembersInput {
259
+ groupId: string;
260
+ userIds: string[];
261
+ }
262
+ export interface GroupsRemoveMemberInput {
263
+ groupId: string;
264
+ userId: string;
265
+ }
186
266
  export interface Program {
187
267
  id: string;
188
268
  name: string;
269
+ description: string;
189
270
  creatorUid: string;
190
271
  createdAt: string;
191
- settings?: {
192
- managerOnlyEndorsement: boolean;
193
- };
194
272
  }
195
273
  export interface Progress {
196
274
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totoday/quinn-sdk",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [