@planningcenter/chat-react-native 3.21.2-rc.1 → 3.21.2-rc.2
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/build/contexts/chat_context.d.ts +3 -2
- package/build/contexts/chat_context.d.ts.map +1 -1
- package/build/contexts/chat_context.js.map +1 -1
- package/build/hooks/services/use_team_members_for_new_conversation.d.ts +14 -14
- package/build/hooks/use_api.d.ts +41 -41
- package/build/hooks/use_api.d.ts.map +1 -1
- package/build/hooks/use_api.js.map +1 -1
- package/build/hooks/use_chat_permissions.d.ts +14 -14
- package/build/hooks/use_conversation.d.ts +3 -3
- package/build/hooks/use_groups.d.ts +26 -26
- package/build/hooks/use_groups_groups.d.ts +26 -26
- package/build/hooks/use_organization.d.ts +3 -3
- package/build/hooks/use_suspense_api.d.ts +5 -5
- package/build/hooks/use_suspense_api.d.ts.map +1 -1
- package/build/hooks/use_suspense_api.js.map +1 -1
- package/build/hooks/use_teams.d.ts +26 -26
- package/build/screens/conversation_filter_recipients/hooks/use_service_types_with_teams.d.ts +14 -14
- package/build/screens/conversation_filters/hooks/filters.d.ts +40 -40
- package/build/types/api_primitives.d.ts +1 -1
- package/build/types/api_primitives.d.ts.map +1 -1
- package/build/types/api_primitives.js.map +1 -1
- package/build/utils/client/client.d.ts +3 -6
- package/build/utils/client/client.d.ts.map +1 -1
- package/build/utils/client/client.js +2 -2
- package/build/utils/client/client.js.map +1 -1
- package/build/utils/response_error.d.ts +4 -4
- package/build/utils/response_error.d.ts.map +1 -1
- package/build/utils/response_error.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/utils/client.ts +2 -2
- package/src/contexts/chat_context.tsx +3 -2
- package/src/hooks/use_api.ts +3 -3
- package/src/hooks/use_suspense_api.ts +4 -4
- package/src/types/api_primitives.ts +1 -1
- package/src/utils/client/client.ts +7 -11
- package/src/utils/response_error.ts +5 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ApiCollection,
|
|
1
|
+
import { ApiCollection, ApiResource, FailedResponse } from '../../types'
|
|
2
2
|
import {
|
|
3
3
|
concatRecords,
|
|
4
4
|
ensureNoQueryParamsInDev,
|
|
@@ -10,11 +10,7 @@ import {
|
|
|
10
10
|
|
|
11
11
|
import { DeleteRequest, GetRequest, PatchRequest, PostRequest, WalkRequest } from './types'
|
|
12
12
|
|
|
13
|
-
export
|
|
14
|
-
errors: ApiError['errors']
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type OnUnauthorizedResponse = (_response: ResponseError) => void
|
|
13
|
+
export type OnUnauthorizedResponse = (_response: FailedResponse) => void
|
|
18
14
|
|
|
19
15
|
type ClientArgs = {
|
|
20
16
|
version: string
|
|
@@ -112,19 +108,19 @@ export class Client {
|
|
|
112
108
|
|
|
113
109
|
handleNotOk = async (response: Response) => {
|
|
114
110
|
if (response.status === 401) {
|
|
115
|
-
const
|
|
111
|
+
const errorData = await this.parseErrorResponse(response)
|
|
116
112
|
this.onUnauthorizedResponse?.({
|
|
117
113
|
...response,
|
|
118
|
-
errors: errors || [],
|
|
119
|
-
})
|
|
114
|
+
errors: errorData.errors || [],
|
|
115
|
+
} as FailedResponse)
|
|
120
116
|
}
|
|
121
117
|
|
|
122
118
|
return Promise.reject(response)
|
|
123
119
|
}
|
|
124
120
|
|
|
125
|
-
parseErrorResponse = async (response: Response): Promise<Partial<
|
|
121
|
+
parseErrorResponse = async (response: Response): Promise<Partial<FailedResponse>> => {
|
|
126
122
|
try {
|
|
127
|
-
return (await response.clone().json()) as
|
|
123
|
+
return (await response.clone().json()) as FailedResponse
|
|
128
124
|
} catch {
|
|
129
125
|
return {}
|
|
130
126
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FailedResponse } from '../types/api_primitives'
|
|
2
2
|
|
|
3
3
|
export class ResponseError extends Error {
|
|
4
4
|
status: number
|
|
5
5
|
statusText: string
|
|
6
|
-
errors:
|
|
7
|
-
response:
|
|
6
|
+
errors: FailedResponse['errors']
|
|
7
|
+
response: FailedResponse
|
|
8
8
|
|
|
9
|
-
constructor(response:
|
|
9
|
+
constructor(response: FailedResponse) {
|
|
10
10
|
super(`ResponseError: ${response?.status} ${response?.statusText}`)
|
|
11
11
|
this.name = 'ResponseError'
|
|
12
12
|
this.status = response?.status
|
|
@@ -18,7 +18,7 @@ export class ResponseError extends Error {
|
|
|
18
18
|
|
|
19
19
|
export const throwResponseError = (error: unknown) => {
|
|
20
20
|
if (error instanceof Response) {
|
|
21
|
-
throw new ResponseError(error as
|
|
21
|
+
throw new ResponseError(error as FailedResponse)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
return Promise.reject(error)
|