@planningcenter/chat-react-native 1.4.1 → 1.4.2-rc.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.
@@ -0,0 +1,3 @@
1
+ export * from './conversations';
2
+ export * from './error_boundary';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './conversations';
2
+ export * from './error_boundary';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/components/index.tsx"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,kBAAkB,CAAA","sourcesContent":["export * from './conversations'\nexport * from './error_boundary'\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"api_provider.d.ts","sourceRoot":"","sources":["../../src/contexts/api_provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiC,MAAM,uBAAuB,CAAA;AAClF,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,GAAG,EAAW,MAAM,kBAAkB,CAAA;AA0B/C,eAAO,MAAM,WAAW,aAMtB,CAAA;AAEF,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,GAAkB,EAClB,KAAK,EACL,cAAc,GACf,EAAE,SAAS,GAAG;IAAE,GAAG,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAAC,cAAc,EAAE,MAAM,IAAI,CAAA;CAAE,qBAM3E"}
1
+ {"version":3,"file":"api_provider.d.ts","sourceRoot":"","sources":["../../src/contexts/api_provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAiC,MAAM,uBAAuB,CAAA;AAClF,OAAO,KAAoB,MAAM,OAAO,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACrC,OAAO,EAAE,GAAG,EAAW,MAAM,kBAAkB,CAAA;AA0B/C,eAAO,MAAM,WAAW,aAMtB,CAAA;AAEF,wBAAgB,WAAW,CAAC,EAC1B,QAAQ,EACR,GAAkB,EAClB,KAAK,EACL,cAAc,GACf,EAAE,SAAS,GAAG;IAAE,GAAG,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,UAAU,CAAC;IAAC,cAAc,EAAE,MAAM,IAAI,CAAA;CAAE,qBAU3E"}
@@ -1,5 +1,5 @@
1
1
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
2
- import React from 'react';
2
+ import React, { useEffect } from 'react';
3
3
  import { session } from '../utils/session';
4
4
  let handleTokenExpired;
5
5
  const defaultQueryFn = ({ queryKey }) => {
@@ -32,6 +32,9 @@ export function ApiProvider({ children, env = 'production', token, onTokenExpire
32
32
  session.env = env;
33
33
  session.token = token;
34
34
  handleTokenExpired = onTokenExpired;
35
+ useEffect(() => {
36
+ queryClient.invalidateQueries();
37
+ }, [env, token]);
35
38
  return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;
36
39
  }
37
40
  const validateResponse = (response) => {
@@ -1 +1 @@
1
- {"version":3,"file":"api_provider.js","sourceRoot":"","sources":["../../src/contexts/api_provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAY,MAAM,uBAAuB,CAAA;AAClF,OAAO,KAAK,MAAM,OAAO,CAAA;AAGzB,OAAO,EAAO,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE/C,IAAI,kBAA8B,CAAA;AAElC,MAAM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GAAG,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAA;IAEzC,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA","sourcesContent":["import { QueryClient, QueryClientProvider, QueryKey } from '@tanstack/react-query'\nimport React from 'react'\nimport { ViewProps } from 'react-native'\nimport { OAuthToken } from '../types'\nimport { ENV, session } from '../utils/session'\n\nlet handleTokenExpired: () => void\n\nconst defaultQueryFn = ({ queryKey }: { queryKey: QueryKey }) => {\n if (!session.token) {\n throw new Error('No token present')\n }\n\n const url = `${session.baseUrl}${queryKey[0]}`\n\n return fetch(url, {\n headers: {\n Authorization: `Bearer ${session.token?.access_token}`,\n },\n })\n .then(validateResponse)\n .then(response => response.json())\n .catch(error => {\n if (error.message === 'Token expired') {\n handleTokenExpired()\n }\n return null\n })\n}\n\nexport const queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n queryFn: defaultQueryFn,\n },\n },\n})\n\nexport function ApiProvider({\n children,\n env = 'production',\n token,\n onTokenExpired,\n}: ViewProps & { env?: ENV; token?: OAuthToken; onTokenExpired: () => void }) {\n session.env = env\n session.token = token\n handleTokenExpired = onTokenExpired\n\n return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>\n}\n\nconst validateResponse = (response: Response) => {\n const isExpired = response.status === 401\n\n if (isExpired) {\n throw new Error('Token expired')\n }\n\n return response\n}\n"]}
1
+ {"version":3,"file":"api_provider.js","sourceRoot":"","sources":["../../src/contexts/api_provider.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,mBAAmB,EAAY,MAAM,uBAAuB,CAAA;AAClF,OAAO,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAA;AAGxC,OAAO,EAAO,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAE/C,IAAI,kBAA8B,CAAA;AAElC,MAAM,cAAc,GAAG,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,CAAC,EAAE,mBAAmB,CAAC,CAAA;AACnF,CAAC;AAED,MAAM,gBAAgB,GAAG,CAAC,QAAkB,EAAE,EAAE;IAC9C,MAAM,SAAS,GAAG,QAAQ,CAAC,MAAM,KAAK,GAAG,CAAA;IAEzC,IAAI,SAAS,EAAE,CAAC;QACd,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAA;IAClC,CAAC;IAED,OAAO,QAAQ,CAAA;AACjB,CAAC,CAAA","sourcesContent":["import { QueryClient, QueryClientProvider, QueryKey } from '@tanstack/react-query'\nimport React, { useEffect } from 'react'\nimport { ViewProps } from 'react-native'\nimport { OAuthToken } from '../types'\nimport { ENV, session } from '../utils/session'\n\nlet handleTokenExpired: () => void\n\nconst defaultQueryFn = ({ queryKey }: { queryKey: QueryKey }) => {\n if (!session.token) {\n throw new Error('No token present')\n }\n\n const url = `${session.baseUrl}${queryKey[0]}`\n\n return fetch(url, {\n headers: {\n Authorization: `Bearer ${session.token?.access_token}`,\n },\n })\n .then(validateResponse)\n .then(response => response.json())\n .catch(error => {\n if (error.message === 'Token expired') {\n handleTokenExpired()\n }\n return null\n })\n}\n\nexport const queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n queryFn: defaultQueryFn,\n },\n },\n})\n\nexport function ApiProvider({\n children,\n env = 'production',\n token,\n onTokenExpired,\n}: ViewProps & { env?: ENV; token?: OAuthToken; onTokenExpired: () => void }) {\n session.env = env\n session.token = token\n handleTokenExpired = onTokenExpired\n\n useEffect(() => {\n queryClient.invalidateQueries()\n }, [env, token])\n\n return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>\n}\n\nconst validateResponse = (response: Response) => {\n const isExpired = response.status === 401\n\n if (isExpired) {\n throw new Error('Token expired')\n }\n\n return response\n}\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './api_provider';
2
+ export * from './chat_context';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './api_provider';
2
+ export * from './chat_context';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contexts/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAA;AAC9B,cAAc,gBAAgB,CAAA","sourcesContent":["export * from './api_provider'\nexport * from './chat_context'\n"]}
@@ -1,2 +1,3 @@
1
- export { useTheme } from './use_theme';
1
+ export * from './use_async_storage';
2
+ export * from './use_theme';
2
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA"}
@@ -1,2 +1,3 @@
1
- export { useTheme } from './use_theme';
1
+ export * from './use_async_storage';
2
+ export * from './use_theme';
2
3
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA","sourcesContent":["export { useTheme } from './use_theme'\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAA;AACnC,cAAc,aAAa,CAAA","sourcesContent":["export * from './use_async_storage'\nexport * from './use_theme'\n"]}
package/build/index.d.ts CHANGED
@@ -1,8 +1,6 @@
1
- import { Conversations } from './components/conversations';
2
- import { ChatContext, ChatProvider } from './contexts/chat_context';
3
- import { OAuthToken } from './types';
4
- import { baseUrlMap, uploadUrlMap } from './utils/session';
5
- import { TemporaryDefaultColorsType } from './utils/theme';
1
+ export * from './components';
2
+ export * from './contexts';
3
+ export * from './hooks';
6
4
  export * from './screens';
7
- export { baseUrlMap, ChatContext, ChatProvider, Conversations, OAuthToken, TemporaryDefaultColorsType, uploadUrlMap, };
5
+ export * from './utils';
8
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAA;AACpC,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC1D,OAAO,EAAE,0BAA0B,EAAE,MAAM,eAAe,CAAA;AAC1D,cAAc,WAAW,CAAA;AAEzB,OAAO,EACL,UAAU,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EACb,UAAU,EACV,0BAA0B,EAC1B,YAAY,GACb,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
package/build/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import { Conversations } from './components/conversations';
2
- import { ChatContext, ChatProvider } from './contexts/chat_context';
3
- import { baseUrlMap, uploadUrlMap } from './utils/session';
1
+ export * from './components';
2
+ export * from './contexts';
3
+ export * from './hooks';
4
4
  export * from './screens';
5
- export { baseUrlMap, ChatContext, ChatProvider, Conversations, uploadUrlMap, };
5
+ export * from './utils';
6
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAA;AAEnE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAE1D,cAAc,WAAW,CAAA;AAEzB,OAAO,EACL,UAAU,EACV,WAAW,EACX,YAAY,EACZ,aAAa,EAGb,YAAY,GACb,CAAA","sourcesContent":["import { Conversations } from './components/conversations'\nimport { ChatContext, ChatProvider } from './contexts/chat_context'\nimport { OAuthToken } from './types'\nimport { baseUrlMap, uploadUrlMap } from './utils/session'\nimport { TemporaryDefaultColorsType } from './utils/theme'\nexport * from './screens'\n\nexport {\n baseUrlMap,\n ChatContext,\n ChatProvider,\n Conversations,\n OAuthToken,\n TemporaryDefaultColorsType,\n uploadUrlMap,\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA;AACvB,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA","sourcesContent":["export * from './components'\nexport * from './contexts'\nexport * from './hooks'\nexport * from './screens'\nexport * from './utils'\n\n"]}
@@ -0,0 +1,3 @@
1
+ export * from './session';
2
+ export * from './theme';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA"}
@@ -0,0 +1,3 @@
1
+ export * from './session';
2
+ export * from './theme';
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA","sourcesContent":["export * from './session'\nexport * from './theme'\n"]}
@@ -26,6 +26,8 @@ export declare class Session {
26
26
  get isAuthenticated(): boolean;
27
27
  get baseUrl(): string;
28
28
  get uploadUrl(): string;
29
+ toString(): string;
30
+ static hydrate(sessionString: string): Session;
29
31
  }
30
32
  export declare const session: Session;
31
33
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/utils/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,MAAM,MAAM,GAAG,GAAG,YAAY,GAAG,SAAS,GAAG,aAAa,CAAA;AAE1D,eAAO,MAAM,UAAU;;;;CAItB,CAAA;AAED,eAAO,MAAM,YAAY;;;;CAIxB,CAAA;AAED,KAAK,YAAY,GAAG;IAAE,GAAG,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,UAAU,CAAA;CAAE,GAAG,SAAS,CAAA;AAEjE;;;;GAIG;AACH,qBAAa,OAAO;IAClB,GAAG,EAAE,GAAG,CAAA;IACR,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;gBAEjB,KAAK,CAAC,EAAE,YAAY;IAMhC,IAAI,eAAe,YAElB;IAED,IAAI,OAAO,WAEV;IAED,IAAI,SAAS,WAEZ;CACF;AAED,eAAO,MAAM,OAAO,SAAsC,CAAA"}
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/utils/session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AAErC,MAAM,MAAM,GAAG,GAAG,YAAY,GAAG,SAAS,GAAG,aAAa,CAAA;AAE1D,eAAO,MAAM,UAAU;;;;CAItB,CAAA;AAED,eAAO,MAAM,YAAY;;;;CAIxB,CAAA;AAED,KAAK,YAAY,GAAG;IAAE,GAAG,CAAC,EAAE,GAAG,CAAC;IAAC,KAAK,CAAC,EAAE,UAAU,CAAA;CAAE,GAAG,SAAS,CAAA;AAEjE;;;;GAIG;AACH,qBAAa,OAAO;IAClB,GAAG,EAAE,GAAG,CAAA;IACR,KAAK,EAAE,UAAU,GAAG,SAAS,CAAA;gBAEjB,KAAK,CAAC,EAAE,YAAY;IAMhC,IAAI,eAAe,YAElB;IAED,IAAI,OAAO,WAEV;IAED,IAAI,SAAS,WAEZ;IAED,QAAQ;IAIR,MAAM,CAAC,OAAO,CAAC,aAAa,EAAE,MAAM;CAQrC;AAED,eAAO,MAAM,OAAO,SAAsC,CAAA"}
@@ -30,6 +30,18 @@ export class Session {
30
30
  get uploadUrl() {
31
31
  return uploadUrlMap[this.env];
32
32
  }
33
+ toString() {
34
+ return JSON.stringify({ env: this.env, token: this.token });
35
+ }
36
+ static hydrate(sessionString) {
37
+ try {
38
+ const props = JSON.parse(sessionString);
39
+ return new Session(props);
40
+ }
41
+ catch (error) {
42
+ return new Session();
43
+ }
44
+ }
33
45
  }
34
46
  export const session = new Session({ env: 'development' });
35
47
  //# sourceMappingURL=session.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/utils/session.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,UAAU,EAAE,sCAAsC;IAClD,OAAO,EAAE,8CAA8C;IACvD,WAAW,EAAE,qBAAqB;CACnC,CAAA;AAED,MAAM,CAAC,MAAM,YAAY,GAAG;IAC1B,UAAU,EAAE,kDAAkD;IAC9D,OAAO,EAAE,0DAA0D;IACnE,WAAW,EAAE,kDAAkD;CAChE,CAAA;AAID;;;;GAIG;AACH,MAAM,OAAO,OAAO;IAClB,GAAG,CAAK;IACR,KAAK,CAAwB;IAE7B,YAAY,KAAoB;QAC9B,MAAM,EAAE,GAAG,GAAG,aAAa,EAAE,KAAK,EAAE,GAAG,KAAK,IAAI,EAAE,CAAA;QAClD,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;IACpB,CAAC;IAED,IAAI,eAAe;QACjB,OAAO,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;IAC5B,CAAC;IAED,IAAI,OAAO;QACT,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC7B,CAAC;IAED,IAAI,SAAS;QACX,OAAO,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;IAC/B,CAAC;CACF;AAED,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,GAAG,EAAE,aAAa,EAAE,CAAC,CAAA","sourcesContent":["import { OAuthToken } from '../types'\n\nexport type ENV = 'production' | 'staging' | 'development'\n\nexport const baseUrlMap = {\n production: 'https://api.planningcenteronline.com',\n staging: 'https://api-staging.planningcenteronline.com',\n development: 'http://api.pco.test',\n}\n\nexport const uploadUrlMap = {\n production: 'https://upload.planningcenteronline.com/v2/files',\n staging: 'https://upload-staging.planningcenteronline.com/v2/files',\n development: 'https://upload.planningcenteronline.com/v2/files',\n}\n\ntype SessionProps = { env?: ENV; token?: OAuthToken } | undefined\n\n/**\n * Session class to track the environment and token\n * Not intended to make network requests or handle authentication\n * - returns urls for convenience only\n */\nexport class Session {\n env: ENV\n token: OAuthToken | undefined\n\n constructor(props?: SessionProps) {\n const { env = 'development', token } = props || {}\n this.env = env\n this.token = token\n }\n\n get isAuthenticated() {\n return Boolean(this.token)\n }\n\n get baseUrl() {\n return baseUrlMap[this.env]\n }\n\n get uploadUrl() {\n return uploadUrlMap[this.env]\n }\n}\n\nexport const session = new Session({ env: 'development' })\n"]}
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/utils/session.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,UAAU,EAAE,sCAAsC;IAClD,OAAO,EAAE,8CAA8C;IACvD,WAAW,EAAE,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 'production' | 'staging' | 'development'\n\nexport const baseUrlMap = {\n production: 'https://api.planningcenteronline.com',\n staging: 'https://api-staging.planningcenteronline.com',\n development: 'http://api.pco.test',\n}\n\nexport const uploadUrlMap = {\n production: 'https://upload.planningcenteronline.com/v2/files',\n staging: 'https://upload-staging.planningcenteronline.com/v2/files',\n development: 'https://upload.planningcenteronline.com/v2/files',\n}\n\ntype SessionProps = { env?: ENV; token?: OAuthToken } | undefined\n\n/**\n * Session class to track the environment and token\n * Not intended to make network requests or handle authentication\n * - returns urls for convenience only\n */\nexport class Session {\n env: ENV\n token: OAuthToken | undefined\n\n constructor(props?: SessionProps) {\n const { env = 'development', token } = props || {}\n this.env = env\n this.token = token\n }\n\n get isAuthenticated() {\n return Boolean(this.token)\n }\n\n get baseUrl() {\n return baseUrlMap[this.env]\n }\n\n get uploadUrl() {\n return uploadUrlMap[this.env]\n }\n\n toString() {\n return JSON.stringify({ env: this.env, token: this.token })\n }\n\n static hydrate(sessionString: string) {\n try {\n const props = JSON.parse(sessionString)\n return new Session(props)\n } catch (error) {\n return new Session()\n }\n }\n}\n\nexport const session = new Session({ env: 'development' })\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "1.4.1",
3
+ "version": "1.4.2-rc.1",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -38,5 +38,5 @@
38
38
  "prettier": "^3.4.2",
39
39
  "react-native": "0.74.5"
40
40
  },
41
- "gitHead": "469ceadce649e0dfa29e5c61281d1ed4821786cd"
41
+ "gitHead": "bffd2651f686d7894cc0c8bfb4c0d7ae0dc2643e"
42
42
  }
@@ -1,6 +1,15 @@
1
1
  import { OAuthToken } from '../types'
2
2
  import { Session } from '../utils/session'
3
3
 
4
+ const token: OAuthToken = {
5
+ access_token: 'access_token',
6
+ refresh_token: 'refresh_token',
7
+ token_type: undefined,
8
+ created_at: 0,
9
+ expires_in: undefined,
10
+ scope: '',
11
+ }
12
+
4
13
  describe('Session', () => {
5
14
  describe('constructor', () => {
6
15
  it('should track the environment', () => {
@@ -10,14 +19,6 @@ describe('Session', () => {
10
19
  })
11
20
 
12
21
  it('should track the token', () => {
13
- const token: OAuthToken = {
14
- access_token: 'access_token',
15
- refresh_token: 'refresh_token',
16
- token_type: undefined,
17
- created_at: 0,
18
- expires_in: undefined,
19
- scope: '',
20
- }
21
22
  const session = new Session({ token })
22
23
  expect(session.token).toEqual(token)
23
24
  expect(session.isAuthenticated).toEqual(true)
@@ -43,4 +44,38 @@ describe('Session', () => {
43
44
  expect(session.uploadUrl).toBe('https://upload-staging.planningcenteronline.com/v2/files')
44
45
  })
45
46
  })
47
+
48
+ describe('hydrate', () => {
49
+ describe('success', () => {
50
+ it('should return a hydrated Session instance', () => {
51
+ const session = new Session({ token })
52
+ expect(session.token).toEqual(token)
53
+ expect(session.isAuthenticated).toEqual(true)
54
+
55
+ const sessionString = session.toString()
56
+ const hydratedSession = Session.hydrate(sessionString)
57
+ expect(hydratedSession.token).toEqual(token)
58
+ expect(hydratedSession.isAuthenticated).toEqual(true)
59
+ })
60
+
61
+ it('should store the environment of hydrated Session instance', () => {
62
+ const env = 'production'
63
+ const session = new Session({ token, env })
64
+
65
+ const sessionString = session.toString()
66
+ const hydratedSession = Session.hydrate(sessionString)
67
+ expect(hydratedSession.env).toEqual(env)
68
+ expect(hydratedSession.token).toEqual(token)
69
+ expect(hydratedSession.isAuthenticated).toEqual(true)
70
+ })
71
+ })
72
+
73
+ describe('failure', () => {
74
+ it('should return a new Session instance', () => {
75
+ const session = Session.hydrate('')
76
+ expect(session.env).toBe('development')
77
+ expect(session.isAuthenticated).toBe(false)
78
+ })
79
+ })
80
+ })
46
81
  })
@@ -0,0 +1,2 @@
1
+ export * from './conversations'
2
+ export * from './error_boundary'
@@ -1,5 +1,5 @@
1
1
  import { QueryClient, QueryClientProvider, QueryKey } from '@tanstack/react-query'
2
- import React from 'react'
2
+ import React, { useEffect } from 'react'
3
3
  import { ViewProps } from 'react-native'
4
4
  import { OAuthToken } from '../types'
5
5
  import { ENV, session } from '../utils/session'
@@ -46,6 +46,10 @@ export function ApiProvider({
46
46
  session.token = token
47
47
  handleTokenExpired = onTokenExpired
48
48
 
49
+ useEffect(() => {
50
+ queryClient.invalidateQueries()
51
+ }, [env, token])
52
+
49
53
  return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>
50
54
  }
51
55
 
@@ -0,0 +1,2 @@
1
+ export * from './api_provider'
2
+ export * from './chat_context'
@@ -1 +1,2 @@
1
- export { useTheme } from './use_theme'
1
+ export * from './use_async_storage'
2
+ export * from './use_theme'
package/src/index.tsx CHANGED
@@ -1,16 +1,6 @@
1
- import { Conversations } from './components/conversations'
2
- import { ChatContext, ChatProvider } from './contexts/chat_context'
3
- import { OAuthToken } from './types'
4
- import { baseUrlMap, uploadUrlMap } from './utils/session'
5
- import { TemporaryDefaultColorsType } from './utils/theme'
1
+ export * from './components'
2
+ export * from './contexts'
3
+ export * from './hooks'
6
4
  export * from './screens'
5
+ export * from './utils'
7
6
 
8
- export {
9
- baseUrlMap,
10
- ChatContext,
11
- ChatProvider,
12
- Conversations,
13
- OAuthToken,
14
- TemporaryDefaultColorsType,
15
- uploadUrlMap,
16
- }
@@ -0,0 +1,2 @@
1
+ export * from './session'
2
+ export * from './theme'
@@ -42,6 +42,19 @@ export class Session {
42
42
  get uploadUrl() {
43
43
  return uploadUrlMap[this.env]
44
44
  }
45
+
46
+ toString() {
47
+ return JSON.stringify({ env: this.env, token: this.token })
48
+ }
49
+
50
+ static hydrate(sessionString: string) {
51
+ try {
52
+ const props = JSON.parse(sessionString)
53
+ return new Session(props)
54
+ } catch (error) {
55
+ return new Session()
56
+ }
57
+ }
45
58
  }
46
59
 
47
60
  export const session = new Session({ env: 'development' })