@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 {};
@@ -60,6 +60,7 @@ const accountsGateway = (initializer) => (configProvider) => {
60
60
  }
61
61
  });
62
62
  const searchUsers = async (payload) => request(routing_1.METHOD.GET, `users?${query_string_1.default.stringify(payload)}`, {});
63
+ const updateUser = async (token, body) => request(routing_1.METHOD.PUT, 'user', { body, token });
63
64
  const getPlatformUserId = (externalIds, platformId) => {
64
65
  for (const externalId of externalIds) {
65
66
  const [userPlatformId, userId] = externalId.split('/', 2);
@@ -112,6 +113,6 @@ const accountsGateway = (initializer) => (configProvider) => {
112
113
  }));
113
114
  return results;
114
115
  };
115
- return { findOrCreateUser, findUser, getUser, linkUser, mapUserUuids, searchUsers };
116
+ return { findOrCreateUser, findUser, getUser, linkUser, mapUserUuids, searchUsers, updateUser };
116
117
  };
117
118
  exports.accountsGateway = accountsGateway;
@@ -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;
@@ -30,7 +30,8 @@ const embeddedAuthProvider = (getUserData, { authQuery, window }) => {
30
30
  ...params,
31
31
  ...extraParams,
32
32
  ...(authQuery && authQuery.value ? { [authQuery.key]: authQuery.value } : { auth: 'embedded' }),
33
- [embeddedQueryKey]: embeddedQueryValue
33
+ [embeddedQueryKey]: embeddedQueryValue,
34
+ subcontent: 'true',
34
35
  });
35
36
  return url.href;
36
37
  };