@planningcenter/chat-react-native 3.8.0-rc.1 → 3.8.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 +1 @@
1
- {"version":3,"file":"use_upload_client.d.ts","sourceRoot":"","sources":["../../src/hooks/use_upload_client.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEjC,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,eAAe,oBAiB3B,CAAA;AAED,cAAM,YAAa,SAAQ,MAAM;IACzB,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAkBvE;AAED,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE;QACV,eAAe,EAAE,MAAM,CAAA;QACvB,SAAS,EAAE,MAAM,CAAA;QACjB,GAAG,EAAE,MAAM,CAAA;QACX,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,MAAM,CAAA;QAClB,SAAS,EAAE,MAAM,CAAA;QACjB,IAAI,EAAE,MAAM,CAAA;QACZ,YAAY,EAAE,MAAM,CAAA;QACpB,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;CACF"}
1
+ {"version":3,"file":"use_upload_client.d.ts","sourceRoot":"","sources":["../../src/hooks/use_upload_client.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAGjC,MAAM,WAAW,mBAAmB;IAClC,GAAG,EAAE,MAAM,CAAA;IACX,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,eAAO,MAAM,eAAe,oBAiB3B,CAAA;AAED,cAAM,YAAa,SAAQ,MAAM;IACzB,UAAU,CAAC,IAAI,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAyBvE;AAED,UAAU,gBAAgB;IACxB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE;QACV,eAAe,EAAE,MAAM,CAAA;QACvB,SAAS,EAAE,MAAM,CAAA;QACjB,GAAG,EAAE,MAAM,CAAA;QACX,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,MAAM,CAAA;QAClB,SAAS,EAAE,MAAM,CAAA;QACjB,IAAI,EAAE,MAAM,CAAA;QACZ,YAAY,EAAE,MAAM,CAAA;QACpB,SAAS,EAAE,MAAM,CAAA;QACjB,QAAQ,EAAE,MAAM,CAAA;KACjB,CAAA;CACF"}
@@ -1,7 +1,7 @@
1
1
  import { useContext, useMemo } from 'react';
2
2
  import { ChatContext } from '../contexts/chat_context';
3
- import { UploadUri } from '../utils/upload_uri';
4
3
  import { Client } from '../utils';
4
+ import { UploadUri } from '../utils/upload_uri';
5
5
  export const useUploadClient = () => {
6
6
  const { session, onUnauthorizedResponse } = useContext(ChatContext);
7
7
  const uri = useMemo(() => new UploadUri({ session }), [session]);
@@ -16,10 +16,16 @@ export const useUploadClient = () => {
16
16
  class UploadClient extends Client {
17
17
  async uploadFile(file) {
18
18
  const formData = new FormData();
19
- formData.append('file', file);
19
+ formData.append('file', {
20
+ uri: file.uri,
21
+ name: file.name,
22
+ type: file.type,
23
+ });
24
+ const headers = { ...this.headers };
25
+ delete headers['Content-Type'];
20
26
  const response = await fetch(`${this.root}/v2/files`, {
21
27
  method: 'POST',
22
- headers: this.headers,
28
+ headers,
23
29
  body: formData,
24
30
  });
25
31
  if (!response.ok) {
@@ -1 +1 @@
1
- {"version":3,"file":"use_upload_client.js","sourceRoot":"","sources":["../../src/hooks/use_upload_client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UA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CAAC;QAED,MAAM,YAAY,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAE1C,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC7B,CAAC;CACF","sourcesContent":["import { useContext, useMemo } from 'react'\nimport { ChatContext } from '../contexts/chat_context'\nimport { UploadUri } from '../utils/upload_uri'\nimport { Client } from '../utils'\n\nexport interface FileForUploadClient {\n uri: string\n name: string\n type: string // Should be a MIME type\n}\n\nexport const useUploadClient = () => {\n const { session, onUnauthorizedResponse } = useContext(ChatContext)\n\n const uri = useMemo(() => new UploadUri({ session }), [session])\n\n const api = useMemo(\n () =>\n new UploadClient({\n version: '2025-05-16', // not really needed, but required by the Client constructor\n root: uri.baseUrl,\n defaultHeaders: uri.headers,\n onUnauthorizedResponse,\n }),\n [uri, onUnauthorizedResponse]\n )\n\n return api\n}\n\nclass UploadClient extends Client {\n async uploadFile(file: FileForUploadClient): Promise<UploadedResource> {\n const formData = new FormData()\n formData.append('file', file as unknown as Blob)\n\n const response = await fetch(`${this.root}/v2/files`, {\n method: 'POST',\n headers: this.headers,\n body: formData,\n })\n\n if (!response.ok) {\n return this.handleNotOk(response)\n }\n\n const jsonResponse = await response.json()\n\n return jsonResponse.data[0]\n }\n}\n\ninterface UploadedResource {\n id: string\n type: string\n attributes: {\n organization_id: string\n person_id: string\n md5: string\n created_at: string\n expires_at: string\n source_ip: string\n name: string\n content_type: string\n file_size: number\n location: string\n }\n}\n"]}
1
+ {"version":3,"file":"use_upload_client.js","sourceRoot":"","sources":["../../src/hooks/use_upload_client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AACjC,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAQ/C,MAAM,CAAC,MAA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AAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAE1C,OAAO,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;IAC7B,CAAC;CACF","sourcesContent":["import { useContext, useMemo } from 'react'\nimport { ChatContext } from '../contexts/chat_context'\nimport { Client } from '../utils'\nimport { UploadUri } from '../utils/upload_uri'\n\nexport interface FileForUploadClient {\n uri: string\n name: string\n type: string // Should be a MIME type\n}\n\nexport const useUploadClient = () => {\n const { session, onUnauthorizedResponse } = useContext(ChatContext)\n\n const uri = useMemo(() => new UploadUri({ session }), [session])\n\n const api = useMemo(\n () =>\n new UploadClient({\n version: '2025-05-16', // not really needed, but required by the Client constructor\n root: uri.baseUrl,\n defaultHeaders: uri.headers,\n onUnauthorizedResponse,\n }),\n [uri, onUnauthorizedResponse]\n )\n\n return api\n}\n\nclass UploadClient extends Client {\n async uploadFile(file: FileForUploadClient): Promise<UploadedResource> {\n const formData = new FormData()\n formData.append('file', {\n uri: file.uri,\n name: file.name,\n type: file.type,\n })\n\n const headers: RequestInit['headers'] = { ...this.headers }\n delete headers['Content-Type']\n\n const response = await fetch(`${this.root}/v2/files`, {\n method: 'POST',\n headers,\n body: formData,\n })\n\n if (!response.ok) {\n return this.handleNotOk(response)\n }\n\n const jsonResponse = await response.json()\n\n return jsonResponse.data[0]\n }\n}\n\ninterface UploadedResource {\n id: string\n type: string\n attributes: {\n organization_id: string\n person_id: string\n md5: string\n created_at: string\n expires_at: string\n source_ip: string\n name: string\n content_type: string\n file_size: number\n location: string\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "3.8.0-rc.1",
3
+ "version": "3.8.0",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -55,5 +55,5 @@
55
55
  "prettier": "^3.4.2",
56
56
  "typescript": "<5.6.0"
57
57
  },
58
- "gitHead": "e198458d56c08e1f4ef29f039ce13bfc34ec7214"
58
+ "gitHead": "0757d8a8be06cfa2e3dcb952900a06e3b3689367"
59
59
  }
@@ -1,7 +1,7 @@
1
1
  import { useContext, useMemo } from 'react'
2
2
  import { ChatContext } from '../contexts/chat_context'
3
- import { UploadUri } from '../utils/upload_uri'
4
3
  import { Client } from '../utils'
4
+ import { UploadUri } from '../utils/upload_uri'
5
5
 
6
6
  export interface FileForUploadClient {
7
7
  uri: string
@@ -31,11 +31,18 @@ export const useUploadClient = () => {
31
31
  class UploadClient extends Client {
32
32
  async uploadFile(file: FileForUploadClient): Promise<UploadedResource> {
33
33
  const formData = new FormData()
34
- formData.append('file', file as unknown as Blob)
34
+ formData.append('file', {
35
+ uri: file.uri,
36
+ name: file.name,
37
+ type: file.type,
38
+ })
39
+
40
+ const headers: RequestInit['headers'] = { ...this.headers }
41
+ delete headers['Content-Type']
35
42
 
36
43
  const response = await fetch(`${this.root}/v2/files`, {
37
44
  method: 'POST',
38
- headers: this.headers,
45
+ headers,
39
46
  body: formData,
40
47
  })
41
48