@openstax/ts-utils 1.13.0 → 1.14.0

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.
@@ -1,7 +1,7 @@
1
1
  import { ConfigProviderForConfig } from '../../config';
2
2
  import { GenericFetch } from '../../fetch';
3
3
  import { JsonCompatibleStruct } from '../../routing';
4
- import { ApiUser } from '../authProvider';
4
+ import { ApiUser, ConsentPreferences } from '../authProvider';
5
5
  import { Logger } from '../logger';
6
6
  export declare type Config = {
7
7
  accountsBase: string;
@@ -60,6 +60,7 @@ export declare type SearchUsersResponse = {
60
60
  } & JsonCompatibleStruct>;
61
61
  total_count: number;
62
62
  };
63
+ export declare type UpdateUserPayload = ConsentPreferences;
63
64
  export declare type MappedUserInfo<T> = {
64
65
  data: T;
65
66
  fullName: string;
@@ -78,6 +79,7 @@ export declare const accountsGateway: <C extends string = "accounts">(initialize
78
79
  [uuid: string]: T;
79
80
  }, logger: Logger, platformId?: string | undefined) => Promise<MappedUserInfo<T>[]>;
80
81
  searchUsers: (payload: SearchUsersPayload) => Promise<SearchUsersResponse>;
82
+ updateUser: (token: string, body: UpdateUserPayload) => Promise<ApiUser & JsonCompatibleStruct>;
81
83
  };
82
84
  export declare type AccountsGateway = ReturnType<ReturnType<typeof accountsGateway>>;
83
85
  export {};
@@ -54,6 +54,7 @@ export const accountsGateway = (initializer) => (configProvider) => {
54
54
  }
55
55
  });
56
56
  const searchUsers = async (payload) => request(METHOD.GET, `users?${queryString.stringify(payload)}`, {});
57
+ const updateUser = async (token, body) => request(METHOD.PUT, 'user', { body, token });
57
58
  const getPlatformUserId = (externalIds, platformId) => {
58
59
  for (const externalId of externalIds) {
59
60
  const [userPlatformId, userId] = externalId.split('/', 2);
@@ -106,5 +107,5 @@ export const accountsGateway = (initializer) => (configProvider) => {
106
107
  }));
107
108
  return results;
108
109
  };
109
- return { findOrCreateUser, findUser, getUser, linkUser, mapUserUuids, searchUsers };
110
+ return { findOrCreateUser, findUser, getUser, linkUser, mapUserUuids, searchUsers, updateUser };
110
111
  };
@@ -1,6 +1,12 @@
1
1
  import type { FetchConfig } from '../../fetch';
2
2
  import type { HttpHeaders, QueryParams } from '../../routing';
3
- export interface TokenUser {
3
+ export declare type ConsentPreferences = {
4
+ consent_preferences: {
5
+ accepted: string[];
6
+ rejected: string[];
7
+ };
8
+ };
9
+ export declare type TokenUser = {
4
10
  id: number;
5
11
  name: string;
6
12
  first_name: string;
@@ -9,7 +15,7 @@ export interface TokenUser {
9
15
  uuid: string;
10
16
  faculty_status: string;
11
17
  is_administrator: boolean;
12
- }
18
+ } & Partial<ConsentPreferences>;
13
19
  export interface ApiUser extends TokenUser {
14
20
  contact_infos: Array<{
15
21
  type: string;
@@ -24,7 +24,8 @@ export const embeddedAuthProvider = (getUserData, { authQuery, window }) => {
24
24
  ...params,
25
25
  ...extraParams,
26
26
  ...(authQuery && authQuery.value ? { [authQuery.key]: authQuery.value } : { auth: 'embedded' }),
27
- [embeddedQueryKey]: embeddedQueryValue
27
+ [embeddedQueryKey]: embeddedQueryValue,
28
+ subcontent: 'true',
28
29
  });
29
30
  return url.href;
30
31
  };