@connectedxm/client 0.5.7 → 0.5.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -66,6 +66,7 @@ __export(src_exports, {
66
66
  CacheIndividualQueries: () => CacheIndividualQueries,
67
67
  CancelEventRegistration: () => CancelEventRegistration,
68
68
  CancelGroupInvitation: () => CancelGroupInvitation,
69
+ CancelGroupRequest: () => CancelGroupRequest,
69
70
  CancelSubscription: () => CancelSubscription,
70
71
  CancelTransfer: () => CancelTransfer,
71
72
  CaptureInvoicePayment: () => CaptureInvoicePayment,
@@ -125,7 +126,10 @@ __export(src_exports, {
125
126
  EventSource: () => EventSource,
126
127
  EventType: () => EventType,
127
128
  FollowAccount: () => FollowAccount,
129
+ GROUPS_FEATURED_QUERY_KEY: () => GROUPS_FEATURED_QUERY_KEY,
130
+ GROUPS_INVITED_QUERY_KEY: () => GROUPS_INVITED_QUERY_KEY,
128
131
  GROUPS_QUERY_KEY: () => GROUPS_QUERY_KEY,
132
+ GROUPS_REQUESTED_QUERY_KEY: () => GROUPS_REQUESTED_QUERY_KEY,
129
133
  GROUP_ACTIVITIES_QUERY_KEY: () => GROUP_ACTIVITIES_QUERY_KEY,
130
134
  GROUP_ANNOUNCEMENTS_QUERY_KEY: () => GROUP_ANNOUNCEMENTS_QUERY_KEY,
131
135
  GROUP_EVENTS_QUERY_KEY: () => GROUP_EVENTS_QUERY_KEY,
@@ -189,6 +193,9 @@ __export(src_exports, {
189
193
  GetGroupRequests: () => GetGroupRequests,
190
194
  GetGroupSponsors: () => GetGroupSponsors,
191
195
  GetGroups: () => GetGroups,
196
+ GetGroupsFeatured: () => GetGroupsFeatured,
197
+ GetGroupsInvited: () => GetGroupsInvited,
198
+ GetGroupsRequested: () => GetGroupsRequested,
192
199
  GetInterests: () => GetInterests,
193
200
  GetInvoice: () => GetInvoice,
194
201
  GetLevel: () => GetLevel,
@@ -484,6 +491,7 @@ __export(src_exports, {
484
491
  useAddSelfInterests: () => useAddSelfInterests,
485
492
  useCancelEventRegistration: () => useCancelEventRegistration,
486
493
  useCancelGroupInvitation: () => useCancelGroupInvitation,
494
+ useCancelGroupRequest: () => useCancelGroupRequest,
487
495
  useCancelSubscription: () => useCancelSubscription,
488
496
  useCancelTransfer: () => useCancelTransfer,
489
497
  useCaptureInvoicePayment: () => useCaptureInvoicePayment,
@@ -570,6 +578,9 @@ __export(src_exports, {
570
578
  useGetGroupRequests: () => useGetGroupRequests,
571
579
  useGetGroupSponsors: () => useGetGroupSponsors,
572
580
  useGetGroups: () => useGetGroups,
581
+ useGetGroupsFeatured: () => useGetGroupsFeatured,
582
+ useGetGroupsInvited: () => useGetGroupsInvited,
583
+ useGetGroupsRequested: () => useGetGroupsRequested,
573
584
  useGetInterests: () => useGetInterests,
574
585
  useGetInvoice: () => useGetInvoice,
575
586
  useGetLevel: () => useGetLevel,
@@ -626,10 +637,10 @@ __export(src_exports, {
626
637
  useGetSeries: () => useGetSeries,
627
638
  useGetSeriesEvents: () => useGetSeriesEvents,
628
639
  useGetSeriesList: () => useGetSeriesList,
640
+ useGroupStatus: () => useGroupStatus,
629
641
  useIsAccountFollowing: () => useIsAccountFollowing,
630
642
  useIsChannelSubscribed: () => useIsChannelSubscribed,
631
643
  useIsEventRegistered: () => useIsEventRegistered,
632
- useIsGroupMember: () => useIsGroupMember,
633
644
  useJoinGroup: () => useJoinGroup,
634
645
  useLeaveGroup: () => useLeaveGroup,
635
646
  useLeaveSelfChatChannel: () => useLeaveSelfChatChannel,
@@ -753,20 +764,15 @@ var useIsAccountFollowing = (accountId) => {
753
764
  return relationships?.data.accounts[accountId] || false;
754
765
  };
755
766
 
756
- // src/hooks/useIsGroupMember.ts
757
- var useIsGroupMember = (groupId, role) => {
767
+ // src/hooks/useGroupStatus.ts
768
+ var useGroupStatus = (groupId) => {
758
769
  const { data: relationships } = useGetSelfRelationships();
759
770
  if (!groupId)
760
771
  return false;
761
772
  if (!isUUID(groupId)) {
762
773
  throw new Error("Invalid groupId. Did you pass in the slug?");
763
774
  }
764
- const _role = relationships?.data.groups[groupId];
765
- if (role) {
766
- return _role === role;
767
- } else {
768
- return _role === "member" || _role === "moderator";
769
- }
775
+ return relationships?.data.groups[groupId] || false;
770
776
  };
771
777
 
772
778
  // src/hooks/useIsEventRegistered.ts
@@ -1634,7 +1640,12 @@ var useGetAccountByShareCode = (shareCode = "", options = {}) => {
1634
1640
  };
1635
1641
 
1636
1642
  // src/queries/groups/useGetGroups.ts
1637
- var GROUPS_QUERY_KEY = () => ["GROUPS"];
1643
+ var GROUPS_QUERY_KEY = (access) => {
1644
+ const keys = ["GROUPS"];
1645
+ if (access)
1646
+ keys.push(access);
1647
+ return keys;
1648
+ };
1638
1649
  var SET_GROUPS_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
1639
1650
  client.setQueryData(
1640
1651
  [
@@ -1649,18 +1660,11 @@ var GetGroups = async ({
1649
1660
  pageSize,
1650
1661
  orderBy,
1651
1662
  search,
1652
- privateGroups,
1663
+ access,
1653
1664
  queryClient,
1654
1665
  clientApiParams,
1655
1666
  locale
1656
1667
  }) => {
1657
- if (privateGroups) {
1658
- return {
1659
- status: "ok",
1660
- message: "Groups retreived",
1661
- data: []
1662
- };
1663
- }
1664
1668
  const clientApi = await GetClientAPI(clientApiParams);
1665
1669
  const { data } = await clientApi.get(`/groups`, {
1666
1670
  params: {
@@ -1668,7 +1672,7 @@ var GetGroups = async ({
1668
1672
  pageSize: pageSize || void 0,
1669
1673
  orderBy: orderBy || void 0,
1670
1674
  search: search || void 0,
1671
- privateGroups: privateGroups || void 0
1675
+ access: access || void 0
1672
1676
  }
1673
1677
  });
1674
1678
  if (queryClient && data.status === "ok") {
@@ -1681,10 +1685,10 @@ var GetGroups = async ({
1681
1685
  }
1682
1686
  return data;
1683
1687
  };
1684
- var useGetGroups = (params = {}, options = {}) => {
1688
+ var useGetGroups = (access, params = {}, options = {}) => {
1685
1689
  return useConnectedInfiniteQuery(
1686
- GROUPS_QUERY_KEY(),
1687
- (params2) => GetGroups({ ...params2 }),
1690
+ GROUPS_QUERY_KEY(access),
1691
+ (params2) => GetGroups({ access, ...params2 }),
1688
1692
  params,
1689
1693
  options
1690
1694
  );
@@ -2531,6 +2535,129 @@ var useGetGroupInvitations = (groupId = "", status, params = {}, options = {}) =
2531
2535
  );
2532
2536
  };
2533
2537
 
2538
+ // src/queries/groups/useGetGroupsFeatured.ts
2539
+ var GROUPS_FEATURED_QUERY_KEY = () => {
2540
+ return [...GROUPS_QUERY_KEY(), "FEATURED"];
2541
+ };
2542
+ var GetGroupsFeatured = async ({
2543
+ pageParam,
2544
+ pageSize,
2545
+ orderBy,
2546
+ search,
2547
+ queryClient,
2548
+ clientApiParams,
2549
+ locale
2550
+ }) => {
2551
+ const clientApi = await GetClientAPI(clientApiParams);
2552
+ const { data } = await clientApi.get(`/groups/featured`, {
2553
+ params: {
2554
+ page: pageParam || void 0,
2555
+ pageSize: pageSize || void 0,
2556
+ orderBy: orderBy || void 0,
2557
+ search: search || void 0
2558
+ }
2559
+ });
2560
+ if (queryClient && data.status === "ok") {
2561
+ CacheIndividualQueries(
2562
+ data,
2563
+ queryClient,
2564
+ (groupId) => GROUP_QUERY_KEY(groupId),
2565
+ locale
2566
+ );
2567
+ }
2568
+ return data;
2569
+ };
2570
+ var useGetGroupsFeatured = (params = {}, options = {}) => {
2571
+ return useConnectedInfiniteQuery(
2572
+ GROUPS_FEATURED_QUERY_KEY(),
2573
+ (params2) => GetGroupsFeatured({ ...params2 }),
2574
+ params,
2575
+ options
2576
+ );
2577
+ };
2578
+
2579
+ // src/queries/groups/useGetGroupsInvited.ts
2580
+ var GROUPS_INVITED_QUERY_KEY = () => {
2581
+ return [...GROUPS_QUERY_KEY(), "INVITED"];
2582
+ };
2583
+ var GetGroupsInvited = async ({
2584
+ pageParam,
2585
+ pageSize,
2586
+ orderBy,
2587
+ search,
2588
+ queryClient,
2589
+ clientApiParams,
2590
+ locale
2591
+ }) => {
2592
+ const clientApi = await GetClientAPI(clientApiParams);
2593
+ const { data } = await clientApi.get(`/groups/invited`, {
2594
+ params: {
2595
+ page: pageParam || void 0,
2596
+ pageSize: pageSize || void 0,
2597
+ orderBy: orderBy || void 0,
2598
+ search: search || void 0
2599
+ }
2600
+ });
2601
+ if (queryClient && data.status === "ok") {
2602
+ CacheIndividualQueries(
2603
+ data,
2604
+ queryClient,
2605
+ (groupId) => GROUP_QUERY_KEY(groupId),
2606
+ locale
2607
+ );
2608
+ }
2609
+ return data;
2610
+ };
2611
+ var useGetGroupsInvited = (params = {}, options = {}) => {
2612
+ return useConnectedInfiniteQuery(
2613
+ GROUPS_INVITED_QUERY_KEY(),
2614
+ (params2) => GetGroupsInvited({ ...params2 }),
2615
+ params,
2616
+ options
2617
+ );
2618
+ };
2619
+
2620
+ // src/queries/groups/useGetGroupsRequested.ts
2621
+ var GROUPS_REQUESTED_QUERY_KEY = () => {
2622
+ return [...GROUPS_QUERY_KEY(), "REQUESTED"];
2623
+ };
2624
+ var GetGroupsRequested = async ({
2625
+ pageParam,
2626
+ pageSize,
2627
+ orderBy,
2628
+ search,
2629
+ queryClient,
2630
+ clientApiParams,
2631
+ locale
2632
+ }) => {
2633
+ const clientApi = await GetClientAPI(clientApiParams);
2634
+ const { data } = await clientApi.get(`/groups/requested`, {
2635
+ params: {
2636
+ page: pageParam || void 0,
2637
+ pageSize: pageSize || void 0,
2638
+ orderBy: orderBy || void 0,
2639
+ search: search || void 0
2640
+ }
2641
+ });
2642
+ if (queryClient && data.status === "ok") {
2643
+ CacheIndividualQueries(
2644
+ data,
2645
+ queryClient,
2646
+ (groupId) => GROUP_QUERY_KEY(groupId),
2647
+ locale
2648
+ );
2649
+ }
2650
+ return data;
2651
+ };
2652
+ var useGetGroupsRequested = (params = {}, options = {}) => {
2653
+ return useConnectedInfiniteQuery(
2654
+ GROUPS_REQUESTED_QUERY_KEY(),
2655
+ (params2) => GetGroupsRequested({ ...params2 }),
2656
+ params,
2657
+ options
2658
+ );
2659
+ };
2660
+
2534
2661
  // src/queries/contents/useGetContents.ts
2535
2662
  var CONTENTS_QUERY_KEY = () => ["CONTENTS"];
2536
2663
  var SET_CONTENTS_QUERY_DATA = (client, keyParams, response, baseKeys = ["en"]) => {
@@ -7427,13 +7554,12 @@ var useCreateTeamAccount = (options = {}) => {
7427
7554
  // src/mutations/groups/useAcceptGroupInvitation.ts
7428
7555
  var AcceptGroupInvitation = async ({
7429
7556
  groupId,
7430
- invitationId,
7431
7557
  clientApiParams,
7432
7558
  queryClient
7433
7559
  }) => {
7434
7560
  const clientApi = await GetClientAPI(clientApiParams);
7435
7561
  const { data } = await clientApi.post(
7436
- `/groups/${groupId}/invitations/${invitationId}`
7562
+ `/groups/${groupId}/invitations/accept`
7437
7563
  );
7438
7564
  if (queryClient && data.status === "ok") {
7439
7565
  queryClient.invalidateQueries({
@@ -7442,6 +7568,13 @@ var AcceptGroupInvitation = async ({
7442
7568
  queryClient.invalidateQueries({
7443
7569
  queryKey: SELF_NOTIFICATION_COUNT_QUERY_KEY("")
7444
7570
  });
7571
+ ADD_SELF_RELATIONSHIP(
7572
+ queryClient,
7573
+ [clientApiParams.locale],
7574
+ "groups",
7575
+ groupId,
7576
+ "member"
7577
+ );
7445
7578
  }
7446
7579
  return data;
7447
7580
  };
@@ -7457,8 +7590,8 @@ var AcceptGroupRequest = async ({
7457
7590
  queryClient
7458
7591
  }) => {
7459
7592
  const clientApi = await GetClientAPI(clientApiParams);
7460
- const { data } = await clientApi.post(
7461
- `/groups/${groupId}/requests/${requestId}`
7593
+ const { data } = await clientApi.put(
7594
+ `/groups/${groupId}/requests/${requestId}/accept`
7462
7595
  );
7463
7596
  if (queryClient && data.status === "ok") {
7464
7597
  queryClient.invalidateQueries({
@@ -7474,6 +7607,30 @@ var useAcceptGroupRequest = (options = {}) => {
7474
7607
  return useConnectedMutation_default(AcceptGroupRequest, options);
7475
7608
  };
7476
7609
 
7610
+ // src/mutations/groups/useCancelGroupRequest.ts
7611
+ var CancelGroupRequest = async ({
7612
+ groupId,
7613
+ clientApiParams,
7614
+ queryClient
7615
+ }) => {
7616
+ const clientApi = await GetClientAPI(clientApiParams);
7617
+ const { data } = await clientApi.put(
7618
+ `/groups/${groupId}/requests/cancel`
7619
+ );
7620
+ if (queryClient && data.status === "ok") {
7621
+ REMOVE_SELF_RELATIONSHIP(
7622
+ queryClient,
7623
+ [clientApiParams.locale],
7624
+ "groups",
7625
+ groupId
7626
+ );
7627
+ }
7628
+ return data;
7629
+ };
7630
+ var useCancelGroupRequest = (options = {}) => {
7631
+ return useConnectedMutation_default(CancelGroupRequest, options);
7632
+ };
7633
+
7477
7634
  // src/mutations/groups/useCreateGroup.ts
7478
7635
  var CreateGroup = async ({
7479
7636
  group,
@@ -7536,12 +7693,22 @@ var useCreateGroupInvitations = (options = {}) => {
7536
7693
  // src/mutations/groups/useCreateGroupRequest.ts
7537
7694
  var CreateGroupRequest = async ({
7538
7695
  groupId,
7539
- clientApiParams
7696
+ clientApiParams,
7697
+ queryClient
7540
7698
  }) => {
7541
7699
  const clientApi = await GetClientAPI(clientApiParams);
7542
7700
  const { data } = await clientApi.post(
7543
7701
  `/groups/${groupId}/requests`
7544
7702
  );
7703
+ if (queryClient && data.status === "ok") {
7704
+ ADD_SELF_RELATIONSHIP(
7705
+ queryClient,
7706
+ [clientApiParams.locale],
7707
+ "groups",
7708
+ groupId,
7709
+ "requested"
7710
+ );
7711
+ }
7545
7712
  return data;
7546
7713
  };
7547
7714
  var useCreateGroupRequest = (options = {}) => {
@@ -7584,7 +7751,7 @@ var CancelGroupInvitation = async ({
7584
7751
  }) => {
7585
7752
  const clientApi = await GetClientAPI(clientApiParams);
7586
7753
  const { data } = await clientApi.delete(
7587
- `/groups/${groupId}/invitations/${invitationId}`
7754
+ `/groups/${groupId}/invitations/${invitationId}/cancel`
7588
7755
  );
7589
7756
  if (queryClient && data.status === "ok") {
7590
7757
  queryClient.invalidateQueries({
@@ -7682,13 +7849,19 @@ var RejectGroupRequest = async ({
7682
7849
  }) => {
7683
7850
  const clientApi = await GetClientAPI(clientApiParams);
7684
7851
  const { data } = await clientApi.put(
7685
- `/groups/${groupId}/requests/${requestId}`
7852
+ `/groups/${groupId}/requests/${requestId}/reject`
7686
7853
  );
7687
7854
  if (queryClient && data.status === "ok") {
7688
7855
  SET_GROUP_REQUEST_QUERY_DATA(queryClient, [groupId, data.data.id], data);
7689
7856
  queryClient.invalidateQueries({
7690
7857
  queryKey: GROUP_REQUESTS_QUERY_KEY(groupId)
7691
7858
  });
7859
+ REMOVE_SELF_RELATIONSHIP(
7860
+ queryClient,
7861
+ [clientApiParams.locale],
7862
+ "groups",
7863
+ groupId
7864
+ );
7692
7865
  }
7693
7866
  return data;
7694
7867
  };
@@ -7829,7 +8002,7 @@ var ReinviteGroupInvitation = async ({
7829
8002
  queryClient
7830
8003
  }) => {
7831
8004
  const clientApi = await GetClientAPI(clientApiParams);
7832
- const { data } = await clientApi.post(
8005
+ const { data } = await clientApi.put(
7833
8006
  `/groups/${groupId}/invitations/${invitationId}/reinvite`
7834
8007
  );
7835
8008
  if (queryClient && data.status === "ok") {
@@ -7849,13 +8022,12 @@ var useReinviteGroupInvitation = (options = {}) => {
7849
8022
  // src/mutations/groups/useRejectGroupInvitation.ts
7850
8023
  var RejectGroupInvitation = async ({
7851
8024
  groupId,
7852
- invitationId,
7853
8025
  clientApiParams,
7854
8026
  queryClient
7855
8027
  }) => {
7856
8028
  const clientApi = await GetClientAPI(clientApiParams);
7857
8029
  const { data } = await clientApi.put(
7858
- `/groups/${groupId}/invitations/${invitationId}`
8030
+ `/groups/${groupId}/invitations/reject`
7859
8031
  );
7860
8032
  if (queryClient && data.status === "ok") {
7861
8033
  queryClient.invalidateQueries({
@@ -7864,6 +8036,12 @@ var RejectGroupInvitation = async ({
7864
8036
  queryClient.invalidateQueries({
7865
8037
  queryKey: SELF_NOTIFICATION_COUNT_QUERY_KEY("")
7866
8038
  });
8039
+ REMOVE_SELF_RELATIONSHIP(
8040
+ queryClient,
8041
+ [clientApiParams.locale],
8042
+ "groups",
8043
+ groupId
8044
+ );
7867
8045
  }
7868
8046
  return data;
7869
8047
  };
@@ -8413,6 +8591,7 @@ var useRemoveListingCoHost = (options = {}) => {
8413
8591
  CacheIndividualQueries,
8414
8592
  CancelEventRegistration,
8415
8593
  CancelGroupInvitation,
8594
+ CancelGroupRequest,
8416
8595
  CancelSubscription,
8417
8596
  CancelTransfer,
8418
8597
  CaptureInvoicePayment,
@@ -8472,7 +8651,10 @@ var useRemoveListingCoHost = (options = {}) => {
8472
8651
  EventSource,
8473
8652
  EventType,
8474
8653
  FollowAccount,
8654
+ GROUPS_FEATURED_QUERY_KEY,
8655
+ GROUPS_INVITED_QUERY_KEY,
8475
8656
  GROUPS_QUERY_KEY,
8657
+ GROUPS_REQUESTED_QUERY_KEY,
8476
8658
  GROUP_ACTIVITIES_QUERY_KEY,
8477
8659
  GROUP_ANNOUNCEMENTS_QUERY_KEY,
8478
8660
  GROUP_EVENTS_QUERY_KEY,
@@ -8536,6 +8718,9 @@ var useRemoveListingCoHost = (options = {}) => {
8536
8718
  GetGroupRequests,
8537
8719
  GetGroupSponsors,
8538
8720
  GetGroups,
8721
+ GetGroupsFeatured,
8722
+ GetGroupsInvited,
8723
+ GetGroupsRequested,
8539
8724
  GetInterests,
8540
8725
  GetInvoice,
8541
8726
  GetLevel,
@@ -8831,6 +9016,7 @@ var useRemoveListingCoHost = (options = {}) => {
8831
9016
  useAddSelfInterests,
8832
9017
  useCancelEventRegistration,
8833
9018
  useCancelGroupInvitation,
9019
+ useCancelGroupRequest,
8834
9020
  useCancelSubscription,
8835
9021
  useCancelTransfer,
8836
9022
  useCaptureInvoicePayment,
@@ -8917,6 +9103,9 @@ var useRemoveListingCoHost = (options = {}) => {
8917
9103
  useGetGroupRequests,
8918
9104
  useGetGroupSponsors,
8919
9105
  useGetGroups,
9106
+ useGetGroupsFeatured,
9107
+ useGetGroupsInvited,
9108
+ useGetGroupsRequested,
8920
9109
  useGetInterests,
8921
9110
  useGetInvoice,
8922
9111
  useGetLevel,
@@ -8973,10 +9162,10 @@ var useRemoveListingCoHost = (options = {}) => {
8973
9162
  useGetSeries,
8974
9163
  useGetSeriesEvents,
8975
9164
  useGetSeriesList,
9165
+ useGroupStatus,
8976
9166
  useIsAccountFollowing,
8977
9167
  useIsChannelSubscribed,
8978
9168
  useIsEventRegistered,
8979
- useIsGroupMember,
8980
9169
  useJoinGroup,
8981
9170
  useLeaveGroup,
8982
9171
  useLeaveSelfChatChannel,