@planningcenter/chat-react-native 3.0.0 → 3.1.0-rc.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.
Files changed (62) hide show
  1. package/build/hooks/use_conversation_messages.d.ts.map +1 -1
  2. package/build/hooks/use_conversation_messages.js +5 -0
  3. package/build/hooks/use_conversation_messages.js.map +1 -1
  4. package/build/hooks/use_conversation_messages_jolt_events.d.ts +7 -0
  5. package/build/hooks/use_conversation_messages_jolt_events.d.ts.map +1 -0
  6. package/build/hooks/use_conversation_messages_jolt_events.js +36 -0
  7. package/build/hooks/use_conversation_messages_jolt_events.js.map +1 -0
  8. package/build/hooks/use_current_person.d.ts +2 -2
  9. package/build/hooks/use_current_person.d.ts.map +1 -1
  10. package/build/hooks/use_current_person.js.map +1 -1
  11. package/build/types/jolt_events/conversation_events.d.ts +38 -0
  12. package/build/types/jolt_events/conversation_events.d.ts.map +1 -0
  13. package/build/types/jolt_events/conversation_events.js +2 -0
  14. package/build/types/jolt_events/conversation_events.js.map +1 -0
  15. package/build/types/jolt_events/index.d.ts +10 -0
  16. package/build/types/jolt_events/index.d.ts.map +1 -0
  17. package/build/types/jolt_events/index.js +2 -0
  18. package/build/types/jolt_events/index.js.map +1 -0
  19. package/build/types/jolt_events/message_events.d.ts +32 -0
  20. package/build/types/jolt_events/message_events.d.ts.map +1 -0
  21. package/build/types/jolt_events/message_events.js +2 -0
  22. package/build/types/jolt_events/message_events.js.map +1 -0
  23. package/build/types/jolt_events/reaction_events.d.ts +25 -0
  24. package/build/types/jolt_events/reaction_events.d.ts.map +1 -0
  25. package/build/types/jolt_events/reaction_events.js +2 -0
  26. package/build/types/jolt_events/reaction_events.js.map +1 -0
  27. package/build/types/jolt_events/typing_events.d.ts +15 -0
  28. package/build/types/jolt_events/typing_events.d.ts.map +1 -0
  29. package/build/types/jolt_events/typing_events.js +2 -0
  30. package/build/types/jolt_events/typing_events.js.map +1 -0
  31. package/build/types/resources/denormalized_attachment_resource.d.ts +88 -0
  32. package/build/types/resources/denormalized_attachment_resource.d.ts.map +1 -0
  33. package/build/types/resources/denormalized_attachment_resource.js +6 -0
  34. package/build/types/resources/denormalized_attachment_resource.js.map +1 -0
  35. package/build/types/resources/message.d.ts +4 -1
  36. package/build/types/resources/message.d.ts.map +1 -1
  37. package/build/types/resources/message.js.map +1 -1
  38. package/build/types/resources/person.d.ts +2 -0
  39. package/build/types/resources/person.d.ts.map +1 -1
  40. package/build/types/resources/person.js.map +1 -1
  41. package/build/utils/deepCamelCaseKeys.d.ts +4 -0
  42. package/build/utils/deepCamelCaseKeys.d.ts.map +1 -0
  43. package/build/utils/deepCamelCaseKeys.js +11 -0
  44. package/build/utils/deepCamelCaseKeys.js.map +1 -0
  45. package/build/utils/jolt/transform_message_event_data_to_message_resource.d.ts +7 -0
  46. package/build/utils/jolt/transform_message_event_data_to_message_resource.d.ts.map +1 -0
  47. package/build/utils/jolt/transform_message_event_data_to_message_resource.js +22 -0
  48. package/build/utils/jolt/transform_message_event_data_to_message_resource.js.map +1 -0
  49. package/package.json +2 -2
  50. package/src/hooks/use_conversation_messages.ts +6 -0
  51. package/src/hooks/use_conversation_messages_jolt_events.ts +51 -0
  52. package/src/hooks/use_current_person.ts +2 -2
  53. package/src/types/jolt_events/conversation_events.ts +41 -0
  54. package/src/types/jolt_events/index.ts +28 -0
  55. package/src/types/jolt_events/message_events.ts +34 -0
  56. package/src/types/jolt_events/reaction_events.ts +26 -0
  57. package/src/types/jolt_events/typing_events.ts +16 -0
  58. package/src/types/resources/denormalized_attachment_resource.ts +101 -0
  59. package/src/types/resources/message.ts +4 -1
  60. package/src/types/resources/person.ts +3 -0
  61. package/src/utils/deepCamelCaseKeys.ts +15 -0
  62. package/src/utils/jolt/transform_message_event_data_to_message_resource.ts +31 -0
@@ -1 +1 @@
1
- {"version":3,"file":"use_conversation_messages.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation_messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC1C,OAAO,EAEL,wBAAwB,EAEzB,MAAM,oBAAoB,CAAA;AAE3B,eAAO,MAAM,uBAAuB,wBACb;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,SACzC,wBAAwB;;;;;;CAUhC,CAAA;AAED,eAAO,MAAM,sBAAsB,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;CAoBrF,CAAA;AAEF,eAAO,MAAM,mBAAmB,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,iDAGnF,CAAA"}
1
+ {"version":3,"file":"use_conversation_messages.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation_messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAE1C,OAAO,EAEL,wBAAwB,EAEzB,MAAM,oBAAoB,CAAA;AAE3B,eAAO,MAAM,uBAAuB,wBACb;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,SACzC,wBAAwB;;;;;;CAehC,CAAA;AAED,eAAO,MAAM,sBAAsB,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;CAoBrF,CAAA;AAEF,eAAO,MAAM,mBAAmB,wBAAyB;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,iDAGnF,CAAA"}
@@ -1,8 +1,13 @@
1
+ import { useConversationMessagesJoltEvents } from './use_conversation_messages_jolt_events';
1
2
  import { getRequestQueryKey, useSuspensePaginator, } from './use_suspense_api';
2
3
  export const useConversationMessages = ({ conversation_id }, opts) => {
3
4
  const { data, refetch, isRefetching, fetchNextPage } = useSuspensePaginator(getMessagesRequestArgs({ conversation_id }), opts);
4
5
  const queryKey = getMessagesQueryKey({ conversation_id });
5
6
  const messages = data.sort((a, b) => -a.id.localeCompare(b.id));
7
+ useConversationMessagesJoltEvents({
8
+ conversationId: conversation_id,
9
+ refetchMessages: refetch,
10
+ });
6
11
  return { messages, refetch, isRefetching, fetchNextPage, queryKey };
7
12
  };
8
13
  export const getMessagesRequestArgs = ({ conversation_id }) => ({
@@ -1 +1 @@
1
- {"version":3,"file":"use_conversation_messages.js","sourceRoot":"","sources":["../../src/hooks/use_conversation_messages.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAElB,oBAAoB,GACrB,MAAM,oBAAoB,CAAA;AAE3B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,EAAE,eAAe,EAA+B,EAChD,IAA+B,EAC/B,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,oBAAoB,CACzE,sBAAsB,CAAC,EAAE,eAAe,EAAE,CAAC,EAC3C,IAAI,CACL,CAAA;IACD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,EAAE,eAAe,EAAE,CAAC,CAAA;IACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAE/D,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AACrE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAE,eAAe,EAA+B,EAAE,EAAE,CAAC,CAAC;IAC3F,GAAG,EAAE,qBAAqB,eAAe,WAAW;IACpD,IAAI,EAAE;QACJ,OAAO,EAAE,EAAE;QACX,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,MAAM;gBACN,gBAAgB;gBAChB,MAAM;gBACN,aAAa;gBACb,YAAY;gBACZ,YAAY;gBACZ,QAAQ;gBACR,iBAAiB;aAClB;YACD,MAAM,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;YAC1B,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC;SACtE;QACD,OAAO,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC;KACvC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,eAAe,EAA+B,EAAE,EAAE;IACtF,MAAM,WAAW,GAAG,sBAAsB,CAAC,EAAE,eAAe,EAAE,CAAC,CAAA;IAC/D,OAAO,kBAAkB,CAAC,WAAW,CAAC,CAAA;AACxC,CAAC,CAAA","sourcesContent":["import { MessageResource } from '../types'\nimport {\n getRequestQueryKey,\n SuspensePaginatorOptions,\n useSuspensePaginator,\n} from './use_suspense_api'\n\nexport const useConversationMessages = (\n { conversation_id }: { conversation_id: string },\n opts?: SuspensePaginatorOptions\n) => {\n const { data, refetch, isRefetching, fetchNextPage } = useSuspensePaginator<MessageResource>(\n getMessagesRequestArgs({ conversation_id }),\n opts\n )\n const queryKey = getMessagesQueryKey({ conversation_id })\n const messages = data.sort((a, b) => -a.id.localeCompare(b.id))\n\n return { messages, refetch, isRefetching, fetchNextPage, queryKey }\n}\n\nexport const getMessagesRequestArgs = ({ conversation_id }: { conversation_id: string }) => ({\n url: `/me/conversations/${conversation_id}/messages`,\n data: {\n perPage: 25,\n fields: {\n Message: [\n 'text',\n 'text_edited_at',\n 'mine',\n 'attachments',\n 'created_at',\n 'deleted_at',\n 'author',\n 'reaction_counts',\n ],\n Person: ['name', 'avatar'],\n ReactionCount: ['value', 'count', 'mine', 'message_id', 'author_ids'],\n },\n include: ['author', 'reaction_counts'],\n },\n})\n\nexport const getMessagesQueryKey = ({ conversation_id }: { conversation_id: string }) => {\n const requestArgs = getMessagesRequestArgs({ conversation_id })\n return getRequestQueryKey(requestArgs)\n}\n"]}
1
+ {"version":3,"file":"use_conversation_messages.js","sourceRoot":"","sources":["../../src/hooks/use_conversation_messages.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iCAAiC,EAAE,MAAM,yCAAyC,CAAA;AAC3F,OAAO,EACL,kBAAkB,EAElB,oBAAoB,GACrB,MAAM,oBAAoB,CAAA;AAE3B,MAAM,CAAC,MAAM,uBAAuB,GAAG,CACrC,EAAE,eAAe,EAA+B,EAChD,IAA+B,EAC/B,EAAE;IACF,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,oBAAoB,CACzE,sBAAsB,CAAC,EAAE,eAAe,EAAE,CAAC,EAC3C,IAAI,CACL,CAAA;IACD,MAAM,QAAQ,GAAG,mBAAmB,CAAC,EAAE,eAAe,EAAE,CAAC,CAAA;IACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IAE/D,iCAAiC,CAAC;QAChC,cAAc,EAAE,eAAe;QAC/B,eAAe,EAAE,OAAO;KACzB,CAAC,CAAA;IAEF,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAA;AACrE,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,EAAE,eAAe,EAA+B,EAAE,EAAE,CAAC,CAAC;IAC3F,GAAG,EAAE,qBAAqB,eAAe,WAAW;IACpD,IAAI,EAAE;QACJ,OAAO,EAAE,EAAE;QACX,MAAM,EAAE;YACN,OAAO,EAAE;gBACP,MAAM;gBACN,gBAAgB;gBAChB,MAAM;gBACN,aAAa;gBACb,YAAY;gBACZ,YAAY;gBACZ,QAAQ;gBACR,iBAAiB;aAClB;YACD,MAAM,EAAE,CAAC,MAAM,EAAE,QAAQ,CAAC;YAC1B,aAAa,EAAE,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,CAAC;SACtE;QACD,OAAO,EAAE,CAAC,QAAQ,EAAE,iBAAiB,CAAC;KACvC;CACF,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,EAAE,eAAe,EAA+B,EAAE,EAAE;IACtF,MAAM,WAAW,GAAG,sBAAsB,CAAC,EAAE,eAAe,EAAE,CAAC,CAAA;IAC/D,OAAO,kBAAkB,CAAC,WAAW,CAAC,CAAA;AACxC,CAAC,CAAA","sourcesContent":["import { MessageResource } from '../types'\nimport { useConversationMessagesJoltEvents } from './use_conversation_messages_jolt_events'\nimport {\n getRequestQueryKey,\n SuspensePaginatorOptions,\n useSuspensePaginator,\n} from './use_suspense_api'\n\nexport const useConversationMessages = (\n { conversation_id }: { conversation_id: string },\n opts?: SuspensePaginatorOptions\n) => {\n const { data, refetch, isRefetching, fetchNextPage } = useSuspensePaginator<MessageResource>(\n getMessagesRequestArgs({ conversation_id }),\n opts\n )\n const queryKey = getMessagesQueryKey({ conversation_id })\n const messages = data.sort((a, b) => -a.id.localeCompare(b.id))\n\n useConversationMessagesJoltEvents({\n conversationId: conversation_id,\n refetchMessages: refetch,\n })\n\n return { messages, refetch, isRefetching, fetchNextPage, queryKey }\n}\n\nexport const getMessagesRequestArgs = ({ conversation_id }: { conversation_id: string }) => ({\n url: `/me/conversations/${conversation_id}/messages`,\n data: {\n perPage: 25,\n fields: {\n Message: [\n 'text',\n 'text_edited_at',\n 'mine',\n 'attachments',\n 'created_at',\n 'deleted_at',\n 'author',\n 'reaction_counts',\n ],\n Person: ['name', 'avatar'],\n ReactionCount: ['value', 'count', 'mine', 'message_id', 'author_ids'],\n },\n include: ['author', 'reaction_counts'],\n },\n})\n\nexport const getMessagesQueryKey = ({ conversation_id }: { conversation_id: string }) => {\n const requestArgs = getMessagesRequestArgs({ conversation_id })\n return getRequestQueryKey(requestArgs)\n}\n"]}
@@ -0,0 +1,7 @@
1
+ interface Props {
2
+ conversationId: string;
3
+ refetchMessages?: () => void;
4
+ }
5
+ export declare function useConversationMessagesJoltEvents({ conversationId, refetchMessages }: Props): void;
6
+ export {};
7
+ //# sourceMappingURL=use_conversation_messages_jolt_events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_conversation_messages_jolt_events.d.ts","sourceRoot":"","sources":["../../src/hooks/use_conversation_messages_jolt_events.ts"],"names":[],"mappings":"AAUA,UAAU,KAAK;IACb,cAAc,EAAE,MAAM,CAAA;IACtB,eAAe,CAAC,EAAE,MAAM,IAAI,CAAA;CAC7B;AAED,wBAAgB,iCAAiC,CAAC,EAAE,cAAc,EAAE,eAAe,EAAE,EAAE,KAAK,QAiC3F"}
@@ -0,0 +1,36 @@
1
+ import { useJoltChannel, useJoltEvent } from './use_jolt';
2
+ import { updateRecordInPagesData } from '../utils';
3
+ import { useQueryClient } from '@tanstack/react-query';
4
+ import { useCurrentPerson } from './use_current_person';
5
+ import { transformMessageEventDataToMessageResource } from '../utils/jolt/transform_message_event_data_to_message_resource';
6
+ import { getMessagesRequestArgs } from './use_conversation_messages';
7
+ import { getRequestQueryKey } from './use_suspense_api';
8
+ export function useConversationMessagesJoltEvents({ conversationId, refetchMessages }) {
9
+ const queryClient = useQueryClient();
10
+ const currentPerson = useCurrentPerson();
11
+ const joltChannel = useJoltChannel(`chat.conversations.${conversationId}`);
12
+ const messagesRequestArgs = getMessagesRequestArgs({ conversation_id: conversationId });
13
+ const messagesQueryKey = getRequestQueryKey(messagesRequestArgs);
14
+ const handleMessageJoltEvent = async () => {
15
+ refetchMessages?.();
16
+ };
17
+ const handleMessageUpdateOrCreate = async (e) => {
18
+ const { data } = e.data;
19
+ const message = transformMessageEventDataToMessageResource({
20
+ data,
21
+ currentPersonId: currentPerson.id,
22
+ });
23
+ queryClient.setQueryData(messagesQueryKey, prev => updateRecordInPagesData({
24
+ data: prev,
25
+ record: message,
26
+ processRecord: (record, current) => {
27
+ return { ...current, ...record };
28
+ },
29
+ }));
30
+ };
31
+ useJoltEvent(joltChannel, 'message.created', handleMessageUpdateOrCreate);
32
+ useJoltEvent(joltChannel, 'message.updated', handleMessageUpdateOrCreate);
33
+ useJoltEvent(joltChannel, 'message.deleted', handleMessageJoltEvent);
34
+ useJoltEvent(joltChannel, 'reaction.*', handleMessageJoltEvent);
35
+ }
36
+ //# sourceMappingURL=use_conversation_messages_jolt_events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use_conversation_messages_jolt_events.js","sourceRoot":"","sources":["../../src/hooks/use_conversation_messages_jolt_events.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AACzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,UAAU,CAAA;AAElD,OAAO,EAAgB,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AACvD,OAAO,EAAE,0CAA0C,EAAE,MAAM,gEAAgE,CAAA;AAC3H,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AACpE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAOvD,MAAM,UAAU,iCAAiC,CAAC,EAAE,cAAc,EAAE,eAAe,EAAS;IAC1F,MAAM,WAAW,GAAG,cAAc,EAAE,CAAA;IACpC,MAAM,aAAa,GAAG,gBAAgB,EAAE,CAAA;IACxC,MAAM,WAAW,GAAG,cAAc,CAAC,sBAAsB,cAAc,EAAE,CAAC,CAAA;IAC1E,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,EAAE,eAAe,EAAE,cAAc,EAAE,CAAC,CAAA;IACvF,MAAM,gBAAgB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;IAEhE,MAAM,sBAAsB,GAAG,KAAK,IAAI,EAAE;QACxC,eAAe,EAAE,EAAE,CAAA;IACrB,CAAC,CAAA;IAED,MAAM,2BAA2B,GAAG,KAAK,EAAE,CAAsB,EAAE,EAAE;QACnE,MAAM,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,CAAA;QACvB,MAAM,OAAO,GAAG,0CAA0C,CAAC;YACzD,IAAI;YACJ,eAAe,EAAE,aAAa,CAAC,EAAE;SAClC,CAAC,CAAA;QAEF,WAAW,CAAC,YAAY,CAAY,gBAAgB,EAAE,IAAI,CAAC,EAAE,CAC3D,uBAAuB,CAAC;YACtB,IAAI,EAAE,IAAI;YACV,MAAM,EAAE,OAAO;YACf,aAAa,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,EAAE;gBACjC,OAAO,EAAE,GAAG,OAAO,EAAE,GAAG,MAAM,EAAE,CAAA;YAClC,CAAC;SACF,CAAC,CACH,CAAA;IACH,CAAC,CAAA;IAED,YAAY,CAAC,WAAW,EAAE,iBAAiB,EAAE,2BAA2B,CAAC,CAAA;IACzE,YAAY,CAAC,WAAW,EAAE,iBAAiB,EAAE,2BAA2B,CAAC,CAAA;IACzE,YAAY,CAAC,WAAW,EAAE,iBAAiB,EAAE,sBAAsB,CAAC,CAAA;IACpE,YAAY,CAAC,WAAW,EAAE,YAAY,EAAE,sBAAsB,CAAC,CAAA;AACjE,CAAC","sourcesContent":["import { ApiCollection, MessageResource } from '../types'\nimport { useJoltChannel, useJoltEvent } from './use_jolt'\nimport { updateRecordInPagesData } from '../utils'\nimport { MessageCreatedEvent } from '../types/jolt_events/message_events'\nimport { InfiniteData, useQueryClient } from '@tanstack/react-query'\nimport { useCurrentPerson } from './use_current_person'\nimport { transformMessageEventDataToMessageResource } from '../utils/jolt/transform_message_event_data_to_message_resource'\nimport { getMessagesRequestArgs } from './use_conversation_messages'\nimport { getRequestQueryKey } from './use_suspense_api'\n\ninterface Props {\n conversationId: string\n refetchMessages?: () => void\n}\n\nexport function useConversationMessagesJoltEvents({ conversationId, refetchMessages }: Props) {\n const queryClient = useQueryClient()\n const currentPerson = useCurrentPerson()\n const joltChannel = useJoltChannel(`chat.conversations.${conversationId}`)\n const messagesRequestArgs = getMessagesRequestArgs({ conversation_id: conversationId })\n const messagesQueryKey = getRequestQueryKey(messagesRequestArgs)\n\n const handleMessageJoltEvent = async () => {\n refetchMessages?.()\n }\n\n const handleMessageUpdateOrCreate = async (e: MessageCreatedEvent) => {\n const { data } = e.data\n const message = transformMessageEventDataToMessageResource({\n data,\n currentPersonId: currentPerson.id,\n })\n\n queryClient.setQueryData<QueryData>(messagesQueryKey, prev =>\n updateRecordInPagesData({\n data: prev,\n record: message,\n processRecord: (record, current) => {\n return { ...current, ...record }\n },\n })\n )\n }\n\n useJoltEvent(joltChannel, 'message.created', handleMessageUpdateOrCreate)\n useJoltEvent(joltChannel, 'message.updated', handleMessageUpdateOrCreate)\n useJoltEvent(joltChannel, 'message.deleted', handleMessageJoltEvent)\n useJoltEvent(joltChannel, 'reaction.*', handleMessageJoltEvent)\n}\n\ntype QueryData = InfiniteData<ApiCollection<MessageResource>>\n"]}
@@ -1,3 +1,3 @@
1
- import { PersonResource } from '../types';
2
- export declare const useCurrentPerson: () => PersonResource;
1
+ import { CurrentPersonResource } from '../types';
2
+ export declare const useCurrentPerson: () => CurrentPersonResource;
3
3
  //# sourceMappingURL=use_current_person.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"use_current_person.d.ts","sourceRoot":"","sources":["../../src/hooks/use_current_person.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAGzC,eAAO,MAAM,gBAAgB,sBAW5B,CAAA"}
1
+ {"version":3,"file":"use_current_person.d.ts","sourceRoot":"","sources":["../../src/hooks/use_current_person.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,UAAU,CAAA;AAGhD,eAAO,MAAM,gBAAgB,6BAW5B,CAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"use_current_person.js","sourceRoot":"","sources":["../../src/hooks/use_current_person.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,cAAc,CAAiB;QACtD,GAAG,EAAE,KAAK;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,CAAC;aACrE;SACF;KACF,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { PersonResource } from '../types'\nimport { useSuspenseGet } from './use_suspense_api'\n\nexport const useCurrentPerson = () => {\n const { data: person } = useSuspenseGet<PersonResource>({\n url: '/me',\n data: {\n fields: {\n Person: ['id', 'name', 'avatar', 'unread_count', 'pco_chat_enabled'],\n },\n },\n })\n\n return person\n}\n"]}
1
+ {"version":3,"file":"use_current_person.js","sourceRoot":"","sources":["../../src/hooks/use_current_person.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAEnD,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,EAAE;IACnC,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,cAAc,CAAwB;QAC7D,GAAG,EAAE,KAAK;QACV,IAAI,EAAE;YACJ,MAAM,EAAE;gBACN,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,kBAAkB,CAAC;aACrE;SACF;KACF,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC,CAAA","sourcesContent":["import { CurrentPersonResource } from '../types'\nimport { useSuspenseGet } from './use_suspense_api'\n\nexport const useCurrentPerson = () => {\n const { data: person } = useSuspenseGet<CurrentPersonResource>({\n url: '/me',\n data: {\n fields: {\n Person: ['id', 'name', 'avatar', 'unread_count', 'pco_chat_enabled'],\n },\n },\n })\n\n return person\n}\n"]}
@@ -0,0 +1,38 @@
1
+ import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection';
2
+ type DateString = string;
3
+ interface BaseConversationEventData extends Record<string, unknown> {
4
+ data: {
5
+ id: number;
6
+ archived_at: DateString;
7
+ created_at: DateString;
8
+ last_message_author_id?: number;
9
+ last_message_author_name?: string;
10
+ last_message_created_at?: DateString;
11
+ last_message_sort_key?: string;
12
+ last_message_text_preview?: string;
13
+ latest_read_message_sort_key?: string;
14
+ organization_id: number;
15
+ replies_disabled: boolean;
16
+ subtitle?: string;
17
+ title: string;
18
+ updated_at: DateString;
19
+ };
20
+ }
21
+ export interface ConversationCreatedEvent extends CustomMessage {
22
+ event: 'conversation.created';
23
+ data: BaseConversationEventData;
24
+ }
25
+ export interface ConversationUpdatedEvent extends CustomMessage {
26
+ event: 'conversation.updated';
27
+ data: BaseConversationEventData;
28
+ }
29
+ export interface ConversationDeletedEvent extends CustomMessage {
30
+ event: 'conversation.destroyed';
31
+ data: BaseConversationEventData;
32
+ }
33
+ export interface ConversationReadEvent extends CustomMessage {
34
+ event: 'conversation.read';
35
+ data: BaseConversationEventData;
36
+ }
37
+ export {};
38
+ //# sourceMappingURL=conversation_events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation_events.d.ts","sourceRoot":"","sources":["../../../src/types/jolt_events/conversation_events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uDAAuD,CAAA;AAE1F,KAAK,UAAU,GAAG,MAAM,CAAA;AACxB,UAAU,yBAA0B,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACjE,IAAI,EAAE;QACJ,EAAE,EAAE,MAAM,CAAA;QACV,WAAW,EAAE,UAAU,CAAA;QACvB,UAAU,EAAE,UAAU,CAAA;QACtB,sBAAsB,CAAC,EAAE,MAAM,CAAA;QAC/B,wBAAwB,CAAC,EAAE,MAAM,CAAA;QACjC,uBAAuB,CAAC,EAAE,UAAU,CAAA;QACpC,qBAAqB,CAAC,EAAE,MAAM,CAAA;QAC9B,yBAAyB,CAAC,EAAE,MAAM,CAAA;QAClC,4BAA4B,CAAC,EAAE,MAAM,CAAA;QACrC,eAAe,EAAE,MAAM,CAAA;QACvB,gBAAgB,EAAE,OAAO,CAAA;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,KAAK,EAAE,MAAM,CAAA;QACb,UAAU,EAAE,UAAU,CAAA;KACvB,CAAA;CACF;AAED,MAAM,WAAW,wBAAyB,SAAQ,aAAa;IAC7D,KAAK,EAAE,sBAAsB,CAAA;IAC7B,IAAI,EAAE,yBAAyB,CAAA;CAChC;AAED,MAAM,WAAW,wBAAyB,SAAQ,aAAa;IAC7D,KAAK,EAAE,sBAAsB,CAAA;IAC7B,IAAI,EAAE,yBAAyB,CAAA;CAChC;AAED,MAAM,WAAW,wBAAyB,SAAQ,aAAa;IAC7D,KAAK,EAAE,wBAAwB,CAAA;IAC/B,IAAI,EAAE,yBAAyB,CAAA;CAChC;AAED,MAAM,WAAW,qBAAsB,SAAQ,aAAa;IAC1D,KAAK,EAAE,mBAAmB,CAAA;IAC1B,IAAI,EAAE,yBAAyB,CAAA;CAChC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=conversation_events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"conversation_events.js","sourceRoot":"","sources":["../../../src/types/jolt_events/conversation_events.ts"],"names":[],"mappings":"","sourcesContent":["import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'\n\ntype DateString = string\ninterface BaseConversationEventData extends Record<string, unknown> {\n data: {\n id: number\n archived_at: DateString\n created_at: DateString\n last_message_author_id?: number\n last_message_author_name?: string\n last_message_created_at?: DateString\n last_message_sort_key?: string\n last_message_text_preview?: string\n latest_read_message_sort_key?: string\n organization_id: number\n replies_disabled: boolean\n subtitle?: string\n title: string\n updated_at: DateString\n }\n}\n\nexport interface ConversationCreatedEvent extends CustomMessage {\n event: 'conversation.created'\n data: BaseConversationEventData\n}\n\nexport interface ConversationUpdatedEvent extends CustomMessage {\n event: 'conversation.updated'\n data: BaseConversationEventData\n}\n\nexport interface ConversationDeletedEvent extends CustomMessage {\n event: 'conversation.destroyed'\n data: BaseConversationEventData\n}\n\nexport interface ConversationReadEvent extends CustomMessage {\n event: 'conversation.read'\n data: BaseConversationEventData\n}\n"]}
@@ -0,0 +1,10 @@
1
+ import type { ConversationCreatedEvent, ConversationDeletedEvent, ConversationUpdatedEvent, ConversationReadEvent } from './conversation_events';
2
+ import type { MessageCreatedEvent, MessageDeletedEvent, MessageUpdatedEvent } from './message_events';
3
+ import type { ReactionCreatedEvent, ReactionDeletedEvent } from './reaction_events';
4
+ import type { TypingBroadcastEvent } from './typing_events';
5
+ export type JoltConversationEvent = ConversationCreatedEvent | ConversationUpdatedEvent | ConversationDeletedEvent | ConversationReadEvent;
6
+ export type JoltMessageEvent = MessageCreatedEvent | MessageUpdatedEvent | MessageDeletedEvent;
7
+ export type JoltReactionEvent = ReactionCreatedEvent | ReactionDeletedEvent;
8
+ export type JoltTypingEvent = TypingBroadcastEvent;
9
+ export type CustomJoltEvent = JoltConversationEvent | JoltMessageEvent | JoltReactionEvent | JoltTypingEvent;
10
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/jolt_events/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,uBAAuB,CAAA;AAC9B,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,kBAAkB,CAAA;AACzB,OAAO,KAAK,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAA;AACnF,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAA;AAE3D,MAAM,MAAM,qBAAqB,GAC7B,wBAAwB,GACxB,wBAAwB,GACxB,wBAAwB,GACxB,qBAAqB,CAAA;AACzB,MAAM,MAAM,gBAAgB,GAAG,mBAAmB,GAAG,mBAAmB,GAAG,mBAAmB,CAAA;AAC9F,MAAM,MAAM,iBAAiB,GAAG,oBAAoB,GAAG,oBAAoB,CAAA;AAC3E,MAAM,MAAM,eAAe,GAAG,oBAAoB,CAAA;AAElD,MAAM,MAAM,eAAe,GACvB,qBAAqB,GACrB,gBAAgB,GAChB,iBAAiB,GACjB,eAAe,CAAA"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/types/jolt_events/index.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n ConversationCreatedEvent,\n ConversationDeletedEvent,\n ConversationUpdatedEvent,\n ConversationReadEvent,\n} from './conversation_events'\nimport type {\n MessageCreatedEvent,\n MessageDeletedEvent,\n MessageUpdatedEvent,\n} from './message_events'\nimport type { ReactionCreatedEvent, ReactionDeletedEvent } from './reaction_events'\nimport type { TypingBroadcastEvent } from './typing_events'\n\nexport type JoltConversationEvent =\n | ConversationCreatedEvent\n | ConversationUpdatedEvent\n | ConversationDeletedEvent\n | ConversationReadEvent\nexport type JoltMessageEvent = MessageCreatedEvent | MessageUpdatedEvent | MessageDeletedEvent\nexport type JoltReactionEvent = ReactionCreatedEvent | ReactionDeletedEvent\nexport type JoltTypingEvent = TypingBroadcastEvent\n\nexport type CustomJoltEvent =\n | JoltConversationEvent\n | JoltMessageEvent\n | JoltReactionEvent\n | JoltTypingEvent\n"]}
@@ -0,0 +1,32 @@
1
+ import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection';
2
+ import { DenormalizedAttachmentResource } from '../resources/denormalized_attachment_resource';
3
+ interface BaseMessageEventData extends Record<string, unknown> {
4
+ data: {
5
+ author_avatar: string;
6
+ author_id: number;
7
+ author_name: string;
8
+ conversation_id: number;
9
+ created_at: string;
10
+ deleted_at: string | null;
11
+ organization_id: number | null;
12
+ sort_key: string;
13
+ text: string;
14
+ text_edited_at: string | null;
15
+ html: string;
16
+ attachments: DenormalizedAttachmentResource[];
17
+ };
18
+ }
19
+ export interface MessageCreatedEvent extends CustomMessage {
20
+ event: 'message.created';
21
+ data: BaseMessageEventData;
22
+ }
23
+ export interface MessageUpdatedEvent extends CustomMessage {
24
+ event: 'message.updated';
25
+ data: BaseMessageEventData;
26
+ }
27
+ export interface MessageDeletedEvent extends CustomMessage {
28
+ event: 'message.destroyed';
29
+ data: BaseMessageEventData;
30
+ }
31
+ export {};
32
+ //# sourceMappingURL=message_events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message_events.d.ts","sourceRoot":"","sources":["../../../src/types/jolt_events/message_events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uDAAuD,CAAA;AAC1F,OAAO,EAAE,8BAA8B,EAAE,MAAM,+CAA+C,CAAA;AAE9F,UAAU,oBAAqB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC5D,IAAI,EAAE;QACJ,aAAa,EAAE,MAAM,CAAA;QACrB,SAAS,EAAE,MAAM,CAAA;QACjB,WAAW,EAAE,MAAM,CAAA;QACnB,eAAe,EAAE,MAAM,CAAA;QACvB,UAAU,EAAE,MAAM,CAAA;QAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;QACzB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;QAC9B,QAAQ,EAAE,MAAM,CAAA;QAChB,IAAI,EAAE,MAAM,CAAA;QACZ,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;QAC7B,IAAI,EAAE,MAAM,CAAA;QACZ,WAAW,EAAE,8BAA8B,EAAE,CAAA;KAC9C,CAAA;CACF;AAED,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,KAAK,EAAE,iBAAiB,CAAA;IACxB,IAAI,EAAE,oBAAoB,CAAA;CAC3B;AAED,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,KAAK,EAAE,iBAAiB,CAAA;IACxB,IAAI,EAAE,oBAAoB,CAAA;CAC3B;AAED,MAAM,WAAW,mBAAoB,SAAQ,aAAa;IACxD,KAAK,EAAE,mBAAmB,CAAA;IAC1B,IAAI,EAAE,oBAAoB,CAAA;CAC3B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=message_events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"message_events.js","sourceRoot":"","sources":["../../../src/types/jolt_events/message_events.ts"],"names":[],"mappings":"","sourcesContent":["import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'\nimport { DenormalizedAttachmentResource } from '../resources/denormalized_attachment_resource'\n\ninterface BaseMessageEventData extends Record<string, unknown> {\n data: {\n author_avatar: string\n author_id: number\n author_name: string\n conversation_id: number\n created_at: string\n deleted_at: string | null\n organization_id: number | null\n sort_key: string\n text: string\n text_edited_at: string | null\n html: string\n attachments: DenormalizedAttachmentResource[]\n }\n}\n\nexport interface MessageCreatedEvent extends CustomMessage {\n event: 'message.created'\n data: BaseMessageEventData\n}\n\nexport interface MessageUpdatedEvent extends CustomMessage {\n event: 'message.updated'\n data: BaseMessageEventData\n}\n\nexport interface MessageDeletedEvent extends CustomMessage {\n event: 'message.destroyed'\n data: BaseMessageEventData\n}\n"]}
@@ -0,0 +1,25 @@
1
+ import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection';
2
+ import { ReactionCountResource } from '../resources/reaction';
3
+ interface BaseReactionEventData extends Record<string, unknown> {
4
+ data: {
5
+ author_id: number;
6
+ conversation_id: number;
7
+ message_sort_key: string;
8
+ created_at: string;
9
+ organization_id: number;
10
+ value: ReactionCountResource['value'];
11
+ author_name?: string;
12
+ author_avatar?: string;
13
+ count: number;
14
+ };
15
+ }
16
+ export interface ReactionCreatedEvent extends CustomMessage {
17
+ event: 'reaction.created';
18
+ data: BaseReactionEventData;
19
+ }
20
+ export interface ReactionDeletedEvent extends CustomMessage {
21
+ event: 'reaction.destroyed';
22
+ data: BaseReactionEventData;
23
+ }
24
+ export {};
25
+ //# sourceMappingURL=reaction_events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reaction_events.d.ts","sourceRoot":"","sources":["../../../src/types/jolt_events/reaction_events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uDAAuD,CAAA;AAC1F,OAAO,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAA;AAE7D,UAAU,qBAAsB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC7D,IAAI,EAAE;QACJ,SAAS,EAAE,MAAM,CAAA;QACjB,eAAe,EAAE,MAAM,CAAA;QACvB,gBAAgB,EAAE,MAAM,CAAA;QACxB,UAAU,EAAE,MAAM,CAAA;QAClB,eAAe,EAAE,MAAM,CAAA;QACvB,KAAK,EAAE,qBAAqB,CAAC,OAAO,CAAC,CAAA;QACrC,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,aAAa,CAAC,EAAE,MAAM,CAAA;QACtB,KAAK,EAAE,MAAM,CAAA;KACd,CAAA;CACF;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,KAAK,EAAE,kBAAkB,CAAA;IACzB,IAAI,EAAE,qBAAqB,CAAA;CAC5B;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,KAAK,EAAE,oBAAoB,CAAA;IAC3B,IAAI,EAAE,qBAAqB,CAAA;CAC5B"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=reaction_events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"reaction_events.js","sourceRoot":"","sources":["../../../src/types/jolt_events/reaction_events.ts"],"names":[],"mappings":"","sourcesContent":["import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'\nimport { ReactionCountResource } from '../resources/reaction'\n\ninterface BaseReactionEventData extends Record<string, unknown> {\n data: {\n author_id: number\n conversation_id: number\n message_sort_key: string\n created_at: string\n organization_id: number\n value: ReactionCountResource['value']\n author_name?: string\n author_avatar?: string\n count: number\n }\n}\n\nexport interface ReactionCreatedEvent extends CustomMessage {\n event: 'reaction.created'\n data: BaseReactionEventData\n}\n\nexport interface ReactionDeletedEvent extends CustomMessage {\n event: 'reaction.destroyed'\n data: BaseReactionEventData\n}\n"]}
@@ -0,0 +1,15 @@
1
+ import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection';
2
+ interface TypingBroadcastData extends Record<string, unknown> {
3
+ data: TypingBroadcastDataAttributes;
4
+ }
5
+ export interface TypingBroadcastEvent extends CustomMessage {
6
+ event: 'typing.broadcast';
7
+ data: TypingBroadcastData;
8
+ }
9
+ export interface TypingBroadcastDataAttributes {
10
+ author_id: number;
11
+ author_name: string;
12
+ id: string;
13
+ }
14
+ export {};
15
+ //# sourceMappingURL=typing_events.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typing_events.d.ts","sourceRoot":"","sources":["../../../src/types/jolt_events/typing_events.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uDAAuD,CAAA;AAE1F,UAAU,mBAAoB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC3D,IAAI,EAAE,6BAA6B,CAAA;CACpC;AAED,MAAM,WAAW,oBAAqB,SAAQ,aAAa;IACzD,KAAK,EAAE,kBAAkB,CAAA;IACzB,IAAI,EAAE,mBAAmB,CAAA;CAC1B;AAED,MAAM,WAAW,6BAA6B;IAC5C,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,EAAE,EAAE,MAAM,CAAA;CACX"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=typing_events.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"typing_events.js","sourceRoot":"","sources":["../../../src/types/jolt_events/typing_events.ts"],"names":[],"mappings":"","sourcesContent":["import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'\n\ninterface TypingBroadcastData extends Record<string, unknown> {\n data: TypingBroadcastDataAttributes\n}\n\nexport interface TypingBroadcastEvent extends CustomMessage {\n event: 'typing.broadcast'\n data: TypingBroadcastData\n}\n\nexport interface TypingBroadcastDataAttributes {\n author_id: number\n author_name: string\n id: string\n}\n"]}
@@ -0,0 +1,88 @@
1
+ /**
2
+ * This is the type of message attachment that is denormalized onto the message resource.
3
+ * It is what we receive from `MessageVertex#attachments`.
4
+ */
5
+ export type DenormalizedAttachmentResource = DenormalizedMessageAttachmentResource | DenormalizedGiphyAttachmentResource | DenormalizedExpandedLinkAttachmentResource;
6
+ export type DenormalizedAttachmentResourceForCreate = DenormalizedMessageAttachmentResourceForCreate | DenormalizedGiphyAttachmentResourceForCreate | DenormalizedExpandedLinkAttachmentResource;
7
+ interface GenericAttachmentResource {
8
+ type: string;
9
+ id?: string;
10
+ [key: string]: unknown;
11
+ }
12
+ export interface DenormalizedMessageAttachmentResource extends GenericAttachmentResource {
13
+ type: 'MessageAttachment';
14
+ id: string;
15
+ attributes: {
16
+ filename: string;
17
+ key: string;
18
+ contentType: string;
19
+ byteSize: number;
20
+ checksum: string;
21
+ metadata?: {
22
+ width?: number;
23
+ height?: number;
24
+ analyzed?: boolean;
25
+ identified?: boolean;
26
+ };
27
+ url: string;
28
+ urlMedium?: string;
29
+ };
30
+ }
31
+ export interface DenormalizedMessageAttachmentResourceForCreate extends GenericAttachmentResource {
32
+ type: 'MessageAttachment';
33
+ id: string;
34
+ }
35
+ export interface DenormalizedGiphyAttachmentResource extends GenericAttachmentResource {
36
+ type: 'giphy';
37
+ id: string;
38
+ title: string;
39
+ originalGiphyTitle?: string;
40
+ titleLink: string;
41
+ thumbUrl: string;
42
+ giphy: {
43
+ original: GiphyVariant;
44
+ fixedHeight: GiphyVariant;
45
+ fixedHeightStill: GiphyVariant;
46
+ fixedHeightDownsampled: GiphyVariant;
47
+ fixedWidth: GiphyVariant;
48
+ fixedWidthStill: GiphyVariant;
49
+ fixedWidthDownsampled: GiphyVariant;
50
+ };
51
+ }
52
+ export interface DenormalizedGiphyAttachmentResourceForCreate extends GenericAttachmentResource {
53
+ type: 'giphy';
54
+ id: string;
55
+ title: string;
56
+ original_giphy_title: string;
57
+ title_link: string;
58
+ thumb_url: string;
59
+ giphy: {
60
+ original: GiphyVariant;
61
+ fixed_height: GiphyVariant;
62
+ fixed_height_still: GiphyVariant;
63
+ fixed_height_downsampled: GiphyVariant;
64
+ fixed_width: GiphyVariant;
65
+ fixed_width_still: GiphyVariant;
66
+ fixed_width_downsampled: GiphyVariant;
67
+ };
68
+ }
69
+ interface GiphyVariant {
70
+ url: string;
71
+ width: number;
72
+ height: number;
73
+ size: string;
74
+ frames: string;
75
+ }
76
+ export interface DenormalizedExpandedLinkAttachmentResource extends GenericAttachmentResource {
77
+ type: 'ExpandedLink';
78
+ attributes: {
79
+ url: string;
80
+ title?: string;
81
+ description?: string;
82
+ imageUrl?: string;
83
+ imageHeight?: number;
84
+ imageWidth?: number;
85
+ };
86
+ }
87
+ export {};
88
+ //# sourceMappingURL=denormalized_attachment_resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"denormalized_attachment_resource.d.ts","sourceRoot":"","sources":["../../../src/types/resources/denormalized_attachment_resource.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,MAAM,8BAA8B,GACtC,qCAAqC,GACrC,mCAAmC,GACnC,0CAA0C,CAAA;AAE9C,MAAM,MAAM,uCAAuC,GAC/C,8CAA8C,GAC9C,4CAA4C,GAC5C,0CAA0C,CAAA;AAE9C,UAAU,yBAAyB;IACjC,IAAI,EAAE,MAAM,CAAA;IACZ,EAAE,CAAC,EAAE,MAAM,CAAA;IACX,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CACvB;AAED,MAAM,WAAW,qCAAsC,SAAQ,yBAAyB;IACtF,IAAI,EAAE,mBAAmB,CAAA;IACzB,EAAE,EAAE,MAAM,CAAA;IACV,UAAU,EAAE;QACV,QAAQ,EAAE,MAAM,CAAA;QAChB,GAAG,EAAE,MAAM,CAAA;QACX,WAAW,EAAE,MAAM,CAAA;QACnB,QAAQ,EAAE,MAAM,CAAA;QAChB,QAAQ,EAAE,MAAM,CAAA;QAChB,QAAQ,CAAC,EAAE;YACT,KAAK,CAAC,EAAE,MAAM,CAAA;YACd,MAAM,CAAC,EAAE,MAAM,CAAA;YACf,QAAQ,CAAC,EAAE,OAAO,CAAA;YAClB,UAAU,CAAC,EAAE,OAAO,CAAA;SACrB,CAAA;QACD,GAAG,EAAE,MAAM,CAAA;QACX,SAAS,CAAC,EAAE,MAAM,CAAA;KACnB,CAAA;CACF;AAED,MAAM,WAAW,8CAA+C,SAAQ,yBAAyB;IAC/F,IAAI,EAAE,mBAAmB,CAAA;IACzB,EAAE,EAAE,MAAM,CAAA;CACX;AAED,MAAM,WAAW,mCAAoC,SAAQ,yBAAyB;IACpF,IAAI,EAAE,OAAO,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,kBAAkB,CAAC,EAAE,MAAM,CAAA;IAC3B,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;IAChB,KAAK,EAAE;QACL,QAAQ,EAAE,YAAY,CAAA;QACtB,WAAW,EAAE,YAAY,CAAA;QACzB,gBAAgB,EAAE,YAAY,CAAA;QAC9B,sBAAsB,EAAE,YAAY,CAAA;QACpC,UAAU,EAAE,YAAY,CAAA;QACxB,eAAe,EAAE,YAAY,CAAA;QAC7B,qBAAqB,EAAE,YAAY,CAAA;KACpC,CAAA;CACF;AAED,MAAM,WAAW,4CAA6C,SAAQ,yBAAyB;IAC7F,IAAI,EAAE,OAAO,CAAA;IACb,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,oBAAoB,EAAE,MAAM,CAAA;IAC5B,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,CAAA;IACjB,KAAK,EAAE;QACL,QAAQ,EAAE,YAAY,CAAA;QACtB,YAAY,EAAE,YAAY,CAAA;QAC1B,kBAAkB,EAAE,YAAY,CAAA;QAChC,wBAAwB,EAAE,YAAY,CAAA;QACtC,WAAW,EAAE,YAAY,CAAA;QACzB,iBAAiB,EAAE,YAAY,CAAA;QAC/B,uBAAuB,EAAE,YAAY,CAAA;KACtC,CAAA;CACF;AAED,UAAU,YAAY;IACpB,GAAG,EAAE,MAAM,CAAA;IACX,KAAK,EAAE,MAAM,CAAA;IACb,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,0CAA2C,SAAQ,yBAAyB;IAC3F,IAAI,EAAE,cAAc,CAAA;IACpB,UAAU,EAAE;QACV,GAAG,EAAE,MAAM,CAAA;QACX,KAAK,CAAC,EAAE,MAAM,CAAA;QACd,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAA;QACjB,WAAW,CAAC,EAAE,MAAM,CAAA;QACpB,UAAU,CAAC,EAAE,MAAM,CAAA;KACpB,CAAA;CACF"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * This is the type of message attachment that is denormalized onto the message resource.
3
+ * It is what we receive from `MessageVertex#attachments`.
4
+ */
5
+ export {};
6
+ //# sourceMappingURL=denormalized_attachment_resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"denormalized_attachment_resource.js","sourceRoot":"","sources":["../../../src/types/resources/denormalized_attachment_resource.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This is the type of message attachment that is denormalized onto the message resource.\n * It is what we receive from `MessageVertex#attachments`.\n */\n\nexport type DenormalizedAttachmentResource =\n | DenormalizedMessageAttachmentResource\n | DenormalizedGiphyAttachmentResource\n | DenormalizedExpandedLinkAttachmentResource\n\nexport type DenormalizedAttachmentResourceForCreate =\n | DenormalizedMessageAttachmentResourceForCreate\n | DenormalizedGiphyAttachmentResourceForCreate\n | DenormalizedExpandedLinkAttachmentResource\n\ninterface GenericAttachmentResource {\n type: string\n id?: string\n [key: string]: unknown\n}\n\nexport interface DenormalizedMessageAttachmentResource extends GenericAttachmentResource {\n type: 'MessageAttachment'\n id: string\n attributes: {\n filename: string\n key: string\n contentType: string\n byteSize: number\n checksum: string\n metadata?: {\n width?: number\n height?: number\n analyzed?: boolean\n identified?: boolean\n }\n url: string\n urlMedium?: string\n }\n}\n\nexport interface DenormalizedMessageAttachmentResourceForCreate extends GenericAttachmentResource {\n type: 'MessageAttachment'\n id: string\n}\n\nexport interface DenormalizedGiphyAttachmentResource extends GenericAttachmentResource {\n type: 'giphy'\n id: string\n title: string\n originalGiphyTitle?: string\n titleLink: string\n thumbUrl: string\n giphy: {\n original: GiphyVariant\n fixedHeight: GiphyVariant\n fixedHeightStill: GiphyVariant\n fixedHeightDownsampled: GiphyVariant\n fixedWidth: GiphyVariant\n fixedWidthStill: GiphyVariant\n fixedWidthDownsampled: GiphyVariant\n }\n}\n\nexport interface DenormalizedGiphyAttachmentResourceForCreate extends GenericAttachmentResource {\n type: 'giphy'\n id: string\n title: string\n original_giphy_title: string\n title_link: string\n thumb_url: string\n giphy: {\n original: GiphyVariant\n fixed_height: GiphyVariant\n fixed_height_still: GiphyVariant\n fixed_height_downsampled: GiphyVariant\n fixed_width: GiphyVariant\n fixed_width_still: GiphyVariant\n fixed_width_downsampled: GiphyVariant\n }\n}\n\ninterface GiphyVariant {\n url: string\n width: number\n height: number\n size: string\n frames: string\n}\n\nexport interface DenormalizedExpandedLinkAttachmentResource extends GenericAttachmentResource {\n type: 'ExpandedLink'\n attributes: {\n url: string\n title?: string\n description?: string\n imageUrl?: string\n imageHeight?: number\n imageWidth?: number\n }\n}\n"]}
@@ -1,13 +1,16 @@
1
+ import { DenormalizedAttachmentResource } from './denormalized_attachment_resource';
1
2
  import type { PersonResource } from './person';
2
3
  import type { ReactionCountResource } from './reaction';
3
4
  export interface MessageResource {
4
5
  type: 'Message';
5
6
  id: string;
6
7
  text: string;
8
+ html: string;
7
9
  createdAt: string;
10
+ deletedAt: string | null;
8
11
  textEditedAt: string | null;
9
12
  mine: boolean;
10
- attachments: unknown[];
13
+ attachments: DenormalizedAttachmentResource[];
11
14
  author: PersonResource;
12
15
  reactionCounts: ReactionCountResource[];
13
16
  renderAuthor?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/types/resources/message.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAA;IACf,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,OAAO,EAAE,CAAA;IACtB,MAAM,EAAE,cAAc,CAAA;IACtB,cAAc,EAAE,qBAAqB,EAAE,CAAA;IAGvC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB"}
1
+ {"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../../src/types/resources/message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,oCAAoC,CAAA;AACnF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAC9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAA;AAEvD,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,SAAS,CAAA;IACf,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,IAAI,EAAE,OAAO,CAAA;IACb,WAAW,EAAE,8BAA8B,EAAE,CAAA;IAC7C,MAAM,EAAE,cAAc,CAAA;IACtB,cAAc,EAAE,qBAAqB,EAAE,CAAA;IAGvC,YAAY,CAAC,EAAE,OAAO,CAAA;IACtB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB"}
@@ -1 +1 @@
1
- {"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/types/resources/message.ts"],"names":[],"mappings":"","sourcesContent":["import type { PersonResource } from './person'\nimport type { ReactionCountResource } from './reaction'\n\nexport interface MessageResource {\n type: 'Message'\n id: string\n text: string\n createdAt: string\n textEditedAt: string | null\n mine: boolean\n attachments: unknown[]\n author: PersonResource\n reactionCounts: ReactionCountResource[]\n\n // Custom Local Properties we set for rendering\n renderAuthor?: boolean\n renderTime?: boolean\n}\n"]}
1
+ {"version":3,"file":"message.js","sourceRoot":"","sources":["../../../src/types/resources/message.ts"],"names":[],"mappings":"","sourcesContent":["import { DenormalizedAttachmentResource } from './denormalized_attachment_resource'\nimport type { PersonResource } from './person'\nimport type { ReactionCountResource } from './reaction'\n\nexport interface MessageResource {\n type: 'Message'\n id: string\n text: string\n html: string\n createdAt: string\n deletedAt: string | null\n textEditedAt: string | null\n mine: boolean\n attachments: DenormalizedAttachmentResource[]\n author: PersonResource\n reactionCounts: ReactionCountResource[]\n\n // Custom Local Properties we set for rendering\n renderAuthor?: boolean\n renderTime?: boolean\n}\n"]}
@@ -2,6 +2,8 @@ import { ResourceObject } from '../api_primitives';
2
2
  export interface PersonResource extends ResourceObject {
3
3
  name: string;
4
4
  avatar: string;
5
+ }
6
+ export interface CurrentPersonResource extends PersonResource {
5
7
  canChat: boolean;
6
8
  unreadCount: number;
7
9
  pcoChatEnabled: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"person.d.ts","sourceRoot":"","sources":["../../../src/types/resources/person.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,OAAO,CAAA;CACxB"}
1
+ {"version":3,"file":"person.d.ts","sourceRoot":"","sources":["../../../src/types/resources/person.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAElD,MAAM,WAAW,cAAe,SAAQ,cAAc;IACpD,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,OAAO,EAAE,OAAO,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,OAAO,CAAA;CACxB"}
@@ -1 +1 @@
1
- {"version":3,"file":"person.js","sourceRoot":"","sources":["../../../src/types/resources/person.ts"],"names":[],"mappings":"","sourcesContent":["import { ResourceObject } from '../api_primitives'\n\nexport interface PersonResource extends ResourceObject {\n name: string\n avatar: string\n canChat: boolean\n unreadCount: number\n pcoChatEnabled: boolean\n}\n"]}
1
+ {"version":3,"file":"person.js","sourceRoot":"","sources":["../../../src/types/resources/person.ts"],"names":[],"mappings":"","sourcesContent":["import { ResourceObject } from '../api_primitives'\n\nexport interface PersonResource extends ResourceObject {\n name: string\n avatar: string\n}\n\nexport interface CurrentPersonResource extends PersonResource {\n canChat: boolean\n unreadCount: number\n pcoChatEnabled: boolean\n}\n"]}
@@ -0,0 +1,4 @@
1
+ type ObjType = Record<string, unknown> | unknown[] | unknown;
2
+ export declare function deepCamelCaseKeys<T extends ObjType>(obj: T): T;
3
+ export {};
4
+ //# sourceMappingURL=deepCamelCaseKeys.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepCamelCaseKeys.d.ts","sourceRoot":"","sources":["../../src/utils/deepCamelCaseKeys.ts"],"names":[],"mappings":"AAEA,KAAK,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,EAAE,GAAG,OAAO,CAAA;AAE5D,wBAAgB,iBAAiB,CAAC,CAAC,SAAS,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,CAU9D"}
@@ -0,0 +1,11 @@
1
+ import { camelCase, isArray, isObject, mapKeys, mapValues } from 'lodash';
2
+ export function deepCamelCaseKeys(obj) {
3
+ if (isArray(obj)) {
4
+ return obj.map(deepCamelCaseKeys);
5
+ }
6
+ else if (isObject(obj)) {
7
+ return mapValues(mapKeys(obj, (_value, key) => camelCase(key)), deepCamelCaseKeys);
8
+ }
9
+ return obj;
10
+ }
11
+ //# sourceMappingURL=deepCamelCaseKeys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepCamelCaseKeys.js","sourceRoot":"","sources":["../../src/utils/deepCamelCaseKeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAA;AAIzE,MAAM,UAAU,iBAAiB,CAAoB,GAAM;IACzD,IAAI,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC;QACjB,OAAQ,GAAiB,CAAC,GAAG,CAAC,iBAAiB,CAAM,CAAA;IACvD,CAAC;SAAM,IAAI,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;QACzB,OAAO,SAAS,CACd,OAAO,CAAC,GAAG,EAAE,CAAC,MAAM,EAAE,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,EAC7C,iBAAiB,CACb,CAAA;IACR,CAAC;IACD,OAAO,GAAG,CAAA;AACZ,CAAC","sourcesContent":["import { camelCase, isArray, isObject, mapKeys, mapValues } from 'lodash'\n\ntype ObjType = Record<string, unknown> | unknown[] | unknown\n\nexport function deepCamelCaseKeys<T extends ObjType>(obj: T): T {\n if (isArray(obj)) {\n return (obj as T & any[]).map(deepCamelCaseKeys) as T\n } else if (isObject(obj)) {\n return mapValues(\n mapKeys(obj, (_value, key) => camelCase(key)),\n deepCamelCaseKeys\n ) as T\n }\n return obj\n}\n"]}
@@ -0,0 +1,7 @@
1
+ import { MessageResource } from '../../types';
2
+ import { MessageCreatedEvent } from '../../types/jolt_events/message_events';
3
+ export declare function transformMessageEventDataToMessageResource({ data, currentPersonId, }: {
4
+ data: MessageCreatedEvent['data']['data'];
5
+ currentPersonId: string;
6
+ }): MessageResource;
7
+ //# sourceMappingURL=transform_message_event_data_to_message_resource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform_message_event_data_to_message_resource.d.ts","sourceRoot":"","sources":["../../../src/utils/jolt/transform_message_event_data_to_message_resource.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AAI5E,wBAAgB,0CAA0C,CAAC,EACzD,IAAI,EACJ,eAAe,GAChB,EAAE;IACD,IAAI,EAAE,mBAAmB,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAA;IACzC,eAAe,EAAE,MAAM,CAAA;CACxB,GAAG,eAAe,CAmBlB"}
@@ -0,0 +1,22 @@
1
+ import { deepCamelCaseKeys } from '../deepCamelCaseKeys';
2
+ export function transformMessageEventDataToMessageResource({ data, currentPersonId, }) {
3
+ return {
4
+ type: 'Message',
5
+ id: data.sort_key,
6
+ text: data.text,
7
+ html: data.html,
8
+ createdAt: data.created_at,
9
+ deletedAt: data.deleted_at,
10
+ textEditedAt: data.text_edited_at,
11
+ mine: data.author_id.toString() === currentPersonId.toString(),
12
+ attachments: deepCamelCaseKeys(data.attachments) || [],
13
+ author: {
14
+ type: 'Person',
15
+ id: data.author_id.toString(),
16
+ name: data.author_name,
17
+ avatar: data.author_avatar,
18
+ },
19
+ reactionCounts: [],
20
+ };
21
+ }
22
+ //# sourceMappingURL=transform_message_event_data_to_message_resource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transform_message_event_data_to_message_resource.js","sourceRoot":"","sources":["../../../src/utils/jolt/transform_message_event_data_to_message_resource.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAExD,MAAM,UAAU,0CAA0C,CAAC,EACzD,IAAI,EACJ,eAAe,GAIhB;IACC,OAAO;QACL,IAAI,EAAE,SAAS;QACf,EAAE,EAAE,IAAI,CAAC,QAAQ;QACjB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,SAAS,EAAE,IAAI,CAAC,UAAU;QAC1B,SAAS,EAAE,IAAI,CAAC,UAAU;QAC1B,YAAY,EAAE,IAAI,CAAC,cAAc;QACjC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,KAAK,eAAe,CAAC,QAAQ,EAAE;QAC9D,WAAW,EAAE,iBAAiB,CAAmC,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE;QACxF,MAAM,EAAE;YACN,IAAI,EAAE,QAAQ;YACd,EAAE,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE;YAC7B,IAAI,EAAE,IAAI,CAAC,WAAW;YACtB,MAAM,EAAE,IAAI,CAAC,aAAa;SAC3B;QACD,cAAc,EAAE,EAAE;KACnB,CAAA;AACH,CAAC","sourcesContent":["import { MessageResource } from '../../types'\nimport { MessageCreatedEvent } from '../../types/jolt_events/message_events'\nimport { DenormalizedAttachmentResource } from '../../types/resources/denormalized_attachment_resource'\nimport { deepCamelCaseKeys } from '../deepCamelCaseKeys'\n\nexport function transformMessageEventDataToMessageResource({\n data,\n currentPersonId,\n}: {\n data: MessageCreatedEvent['data']['data']\n currentPersonId: string\n}): MessageResource {\n return {\n type: 'Message',\n id: data.sort_key,\n text: data.text,\n html: data.html,\n createdAt: data.created_at,\n deletedAt: data.deleted_at,\n textEditedAt: data.text_edited_at,\n mine: data.author_id.toString() === currentPersonId.toString(),\n attachments: deepCamelCaseKeys<DenormalizedAttachmentResource[]>(data.attachments) || [],\n author: {\n type: 'Person',\n id: data.author_id.toString(),\n name: data.author_name,\n avatar: data.author_avatar,\n },\n reactionCounts: [],\n }\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@planningcenter/chat-react-native",
3
- "version": "3.0.0",
3
+ "version": "3.1.0-rc.0",
4
4
  "description": "",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -52,5 +52,5 @@
52
52
  "prettier": "^3.4.2",
53
53
  "typescript": "<5.6.0"
54
54
  },
55
- "gitHead": "9ba41b63c9b41a8a118a36b4d14019fe90fe3368"
55
+ "gitHead": "9ad31b21b6e7d01e019075611435562dd394b486"
56
56
  }
@@ -1,4 +1,5 @@
1
1
  import { MessageResource } from '../types'
2
+ import { useConversationMessagesJoltEvents } from './use_conversation_messages_jolt_events'
2
3
  import {
3
4
  getRequestQueryKey,
4
5
  SuspensePaginatorOptions,
@@ -16,6 +17,11 @@ export const useConversationMessages = (
16
17
  const queryKey = getMessagesQueryKey({ conversation_id })
17
18
  const messages = data.sort((a, b) => -a.id.localeCompare(b.id))
18
19
 
20
+ useConversationMessagesJoltEvents({
21
+ conversationId: conversation_id,
22
+ refetchMessages: refetch,
23
+ })
24
+
19
25
  return { messages, refetch, isRefetching, fetchNextPage, queryKey }
20
26
  }
21
27
 
@@ -0,0 +1,51 @@
1
+ import { ApiCollection, MessageResource } from '../types'
2
+ import { useJoltChannel, useJoltEvent } from './use_jolt'
3
+ import { updateRecordInPagesData } from '../utils'
4
+ import { MessageCreatedEvent } from '../types/jolt_events/message_events'
5
+ import { InfiniteData, useQueryClient } from '@tanstack/react-query'
6
+ import { useCurrentPerson } from './use_current_person'
7
+ import { transformMessageEventDataToMessageResource } from '../utils/jolt/transform_message_event_data_to_message_resource'
8
+ import { getMessagesRequestArgs } from './use_conversation_messages'
9
+ import { getRequestQueryKey } from './use_suspense_api'
10
+
11
+ interface Props {
12
+ conversationId: string
13
+ refetchMessages?: () => void
14
+ }
15
+
16
+ export function useConversationMessagesJoltEvents({ conversationId, refetchMessages }: Props) {
17
+ const queryClient = useQueryClient()
18
+ const currentPerson = useCurrentPerson()
19
+ const joltChannel = useJoltChannel(`chat.conversations.${conversationId}`)
20
+ const messagesRequestArgs = getMessagesRequestArgs({ conversation_id: conversationId })
21
+ const messagesQueryKey = getRequestQueryKey(messagesRequestArgs)
22
+
23
+ const handleMessageJoltEvent = async () => {
24
+ refetchMessages?.()
25
+ }
26
+
27
+ const handleMessageUpdateOrCreate = async (e: MessageCreatedEvent) => {
28
+ const { data } = e.data
29
+ const message = transformMessageEventDataToMessageResource({
30
+ data,
31
+ currentPersonId: currentPerson.id,
32
+ })
33
+
34
+ queryClient.setQueryData<QueryData>(messagesQueryKey, prev =>
35
+ updateRecordInPagesData({
36
+ data: prev,
37
+ record: message,
38
+ processRecord: (record, current) => {
39
+ return { ...current, ...record }
40
+ },
41
+ })
42
+ )
43
+ }
44
+
45
+ useJoltEvent(joltChannel, 'message.created', handleMessageUpdateOrCreate)
46
+ useJoltEvent(joltChannel, 'message.updated', handleMessageUpdateOrCreate)
47
+ useJoltEvent(joltChannel, 'message.deleted', handleMessageJoltEvent)
48
+ useJoltEvent(joltChannel, 'reaction.*', handleMessageJoltEvent)
49
+ }
50
+
51
+ type QueryData = InfiniteData<ApiCollection<MessageResource>>
@@ -1,8 +1,8 @@
1
- import { PersonResource } from '../types'
1
+ import { CurrentPersonResource } from '../types'
2
2
  import { useSuspenseGet } from './use_suspense_api'
3
3
 
4
4
  export const useCurrentPerson = () => {
5
- const { data: person } = useSuspenseGet<PersonResource>({
5
+ const { data: person } = useSuspenseGet<CurrentPersonResource>({
6
6
  url: '/me',
7
7
  data: {
8
8
  fields: {
@@ -0,0 +1,41 @@
1
+ import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'
2
+
3
+ type DateString = string
4
+ interface BaseConversationEventData extends Record<string, unknown> {
5
+ data: {
6
+ id: number
7
+ archived_at: DateString
8
+ created_at: DateString
9
+ last_message_author_id?: number
10
+ last_message_author_name?: string
11
+ last_message_created_at?: DateString
12
+ last_message_sort_key?: string
13
+ last_message_text_preview?: string
14
+ latest_read_message_sort_key?: string
15
+ organization_id: number
16
+ replies_disabled: boolean
17
+ subtitle?: string
18
+ title: string
19
+ updated_at: DateString
20
+ }
21
+ }
22
+
23
+ export interface ConversationCreatedEvent extends CustomMessage {
24
+ event: 'conversation.created'
25
+ data: BaseConversationEventData
26
+ }
27
+
28
+ export interface ConversationUpdatedEvent extends CustomMessage {
29
+ event: 'conversation.updated'
30
+ data: BaseConversationEventData
31
+ }
32
+
33
+ export interface ConversationDeletedEvent extends CustomMessage {
34
+ event: 'conversation.destroyed'
35
+ data: BaseConversationEventData
36
+ }
37
+
38
+ export interface ConversationReadEvent extends CustomMessage {
39
+ event: 'conversation.read'
40
+ data: BaseConversationEventData
41
+ }
@@ -0,0 +1,28 @@
1
+ import type {
2
+ ConversationCreatedEvent,
3
+ ConversationDeletedEvent,
4
+ ConversationUpdatedEvent,
5
+ ConversationReadEvent,
6
+ } from './conversation_events'
7
+ import type {
8
+ MessageCreatedEvent,
9
+ MessageDeletedEvent,
10
+ MessageUpdatedEvent,
11
+ } from './message_events'
12
+ import type { ReactionCreatedEvent, ReactionDeletedEvent } from './reaction_events'
13
+ import type { TypingBroadcastEvent } from './typing_events'
14
+
15
+ export type JoltConversationEvent =
16
+ | ConversationCreatedEvent
17
+ | ConversationUpdatedEvent
18
+ | ConversationDeletedEvent
19
+ | ConversationReadEvent
20
+ export type JoltMessageEvent = MessageCreatedEvent | MessageUpdatedEvent | MessageDeletedEvent
21
+ export type JoltReactionEvent = ReactionCreatedEvent | ReactionDeletedEvent
22
+ export type JoltTypingEvent = TypingBroadcastEvent
23
+
24
+ export type CustomJoltEvent =
25
+ | JoltConversationEvent
26
+ | JoltMessageEvent
27
+ | JoltReactionEvent
28
+ | JoltTypingEvent
@@ -0,0 +1,34 @@
1
+ import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'
2
+ import { DenormalizedAttachmentResource } from '../resources/denormalized_attachment_resource'
3
+
4
+ interface BaseMessageEventData extends Record<string, unknown> {
5
+ data: {
6
+ author_avatar: string
7
+ author_id: number
8
+ author_name: string
9
+ conversation_id: number
10
+ created_at: string
11
+ deleted_at: string | null
12
+ organization_id: number | null
13
+ sort_key: string
14
+ text: string
15
+ text_edited_at: string | null
16
+ html: string
17
+ attachments: DenormalizedAttachmentResource[]
18
+ }
19
+ }
20
+
21
+ export interface MessageCreatedEvent extends CustomMessage {
22
+ event: 'message.created'
23
+ data: BaseMessageEventData
24
+ }
25
+
26
+ export interface MessageUpdatedEvent extends CustomMessage {
27
+ event: 'message.updated'
28
+ data: BaseMessageEventData
29
+ }
30
+
31
+ export interface MessageDeletedEvent extends CustomMessage {
32
+ event: 'message.destroyed'
33
+ data: BaseMessageEventData
34
+ }
@@ -0,0 +1,26 @@
1
+ import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'
2
+ import { ReactionCountResource } from '../resources/reaction'
3
+
4
+ interface BaseReactionEventData extends Record<string, unknown> {
5
+ data: {
6
+ author_id: number
7
+ conversation_id: number
8
+ message_sort_key: string
9
+ created_at: string
10
+ organization_id: number
11
+ value: ReactionCountResource['value']
12
+ author_name?: string
13
+ author_avatar?: string
14
+ count: number
15
+ }
16
+ }
17
+
18
+ export interface ReactionCreatedEvent extends CustomMessage {
19
+ event: 'reaction.created'
20
+ data: BaseReactionEventData
21
+ }
22
+
23
+ export interface ReactionDeletedEvent extends CustomMessage {
24
+ event: 'reaction.destroyed'
25
+ data: BaseReactionEventData
26
+ }
@@ -0,0 +1,16 @@
1
+ import type { CustomMessage } from '@planningcenter/jolt-client/dist/types/JoltConnection'
2
+
3
+ interface TypingBroadcastData extends Record<string, unknown> {
4
+ data: TypingBroadcastDataAttributes
5
+ }
6
+
7
+ export interface TypingBroadcastEvent extends CustomMessage {
8
+ event: 'typing.broadcast'
9
+ data: TypingBroadcastData
10
+ }
11
+
12
+ export interface TypingBroadcastDataAttributes {
13
+ author_id: number
14
+ author_name: string
15
+ id: string
16
+ }
@@ -0,0 +1,101 @@
1
+ /**
2
+ * This is the type of message attachment that is denormalized onto the message resource.
3
+ * It is what we receive from `MessageVertex#attachments`.
4
+ */
5
+
6
+ export type DenormalizedAttachmentResource =
7
+ | DenormalizedMessageAttachmentResource
8
+ | DenormalizedGiphyAttachmentResource
9
+ | DenormalizedExpandedLinkAttachmentResource
10
+
11
+ export type DenormalizedAttachmentResourceForCreate =
12
+ | DenormalizedMessageAttachmentResourceForCreate
13
+ | DenormalizedGiphyAttachmentResourceForCreate
14
+ | DenormalizedExpandedLinkAttachmentResource
15
+
16
+ interface GenericAttachmentResource {
17
+ type: string
18
+ id?: string
19
+ [key: string]: unknown
20
+ }
21
+
22
+ export interface DenormalizedMessageAttachmentResource extends GenericAttachmentResource {
23
+ type: 'MessageAttachment'
24
+ id: string
25
+ attributes: {
26
+ filename: string
27
+ key: string
28
+ contentType: string
29
+ byteSize: number
30
+ checksum: string
31
+ metadata?: {
32
+ width?: number
33
+ height?: number
34
+ analyzed?: boolean
35
+ identified?: boolean
36
+ }
37
+ url: string
38
+ urlMedium?: string
39
+ }
40
+ }
41
+
42
+ export interface DenormalizedMessageAttachmentResourceForCreate extends GenericAttachmentResource {
43
+ type: 'MessageAttachment'
44
+ id: string
45
+ }
46
+
47
+ export interface DenormalizedGiphyAttachmentResource extends GenericAttachmentResource {
48
+ type: 'giphy'
49
+ id: string
50
+ title: string
51
+ originalGiphyTitle?: string
52
+ titleLink: string
53
+ thumbUrl: string
54
+ giphy: {
55
+ original: GiphyVariant
56
+ fixedHeight: GiphyVariant
57
+ fixedHeightStill: GiphyVariant
58
+ fixedHeightDownsampled: GiphyVariant
59
+ fixedWidth: GiphyVariant
60
+ fixedWidthStill: GiphyVariant
61
+ fixedWidthDownsampled: GiphyVariant
62
+ }
63
+ }
64
+
65
+ export interface DenormalizedGiphyAttachmentResourceForCreate extends GenericAttachmentResource {
66
+ type: 'giphy'
67
+ id: string
68
+ title: string
69
+ original_giphy_title: string
70
+ title_link: string
71
+ thumb_url: string
72
+ giphy: {
73
+ original: GiphyVariant
74
+ fixed_height: GiphyVariant
75
+ fixed_height_still: GiphyVariant
76
+ fixed_height_downsampled: GiphyVariant
77
+ fixed_width: GiphyVariant
78
+ fixed_width_still: GiphyVariant
79
+ fixed_width_downsampled: GiphyVariant
80
+ }
81
+ }
82
+
83
+ interface GiphyVariant {
84
+ url: string
85
+ width: number
86
+ height: number
87
+ size: string
88
+ frames: string
89
+ }
90
+
91
+ export interface DenormalizedExpandedLinkAttachmentResource extends GenericAttachmentResource {
92
+ type: 'ExpandedLink'
93
+ attributes: {
94
+ url: string
95
+ title?: string
96
+ description?: string
97
+ imageUrl?: string
98
+ imageHeight?: number
99
+ imageWidth?: number
100
+ }
101
+ }
@@ -1,3 +1,4 @@
1
+ import { DenormalizedAttachmentResource } from './denormalized_attachment_resource'
1
2
  import type { PersonResource } from './person'
2
3
  import type { ReactionCountResource } from './reaction'
3
4
 
@@ -5,10 +6,12 @@ export interface MessageResource {
5
6
  type: 'Message'
6
7
  id: string
7
8
  text: string
9
+ html: string
8
10
  createdAt: string
11
+ deletedAt: string | null
9
12
  textEditedAt: string | null
10
13
  mine: boolean
11
- attachments: unknown[]
14
+ attachments: DenormalizedAttachmentResource[]
12
15
  author: PersonResource
13
16
  reactionCounts: ReactionCountResource[]
14
17
 
@@ -3,6 +3,9 @@ import { ResourceObject } from '../api_primitives'
3
3
  export interface PersonResource extends ResourceObject {
4
4
  name: string
5
5
  avatar: string
6
+ }
7
+
8
+ export interface CurrentPersonResource extends PersonResource {
6
9
  canChat: boolean
7
10
  unreadCount: number
8
11
  pcoChatEnabled: boolean
@@ -0,0 +1,15 @@
1
+ import { camelCase, isArray, isObject, mapKeys, mapValues } from 'lodash'
2
+
3
+ type ObjType = Record<string, unknown> | unknown[] | unknown
4
+
5
+ export function deepCamelCaseKeys<T extends ObjType>(obj: T): T {
6
+ if (isArray(obj)) {
7
+ return (obj as T & any[]).map(deepCamelCaseKeys) as T
8
+ } else if (isObject(obj)) {
9
+ return mapValues(
10
+ mapKeys(obj, (_value, key) => camelCase(key)),
11
+ deepCamelCaseKeys
12
+ ) as T
13
+ }
14
+ return obj
15
+ }
@@ -0,0 +1,31 @@
1
+ import { MessageResource } from '../../types'
2
+ import { MessageCreatedEvent } from '../../types/jolt_events/message_events'
3
+ import { DenormalizedAttachmentResource } from '../../types/resources/denormalized_attachment_resource'
4
+ import { deepCamelCaseKeys } from '../deepCamelCaseKeys'
5
+
6
+ export function transformMessageEventDataToMessageResource({
7
+ data,
8
+ currentPersonId,
9
+ }: {
10
+ data: MessageCreatedEvent['data']['data']
11
+ currentPersonId: string
12
+ }): MessageResource {
13
+ return {
14
+ type: 'Message',
15
+ id: data.sort_key,
16
+ text: data.text,
17
+ html: data.html,
18
+ createdAt: data.created_at,
19
+ deletedAt: data.deleted_at,
20
+ textEditedAt: data.text_edited_at,
21
+ mine: data.author_id.toString() === currentPersonId.toString(),
22
+ attachments: deepCamelCaseKeys<DenormalizedAttachmentResource[]>(data.attachments) || [],
23
+ author: {
24
+ type: 'Person',
25
+ id: data.author_id.toString(),
26
+ name: data.author_name,
27
+ avatar: data.author_avatar,
28
+ },
29
+ reactionCounts: [],
30
+ }
31
+ }