@go-avro/avro-js 0.0.2-beta.67 → 0.0.2-beta.69

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  import { Socket } from 'socket.io-client';
2
2
  import { InfiniteData, UseInfiniteQueryResult, useMutation, UseQueryResult } from '@tanstack/react-query';
3
3
  import { AuthManager } from '../auth/AuthManager';
4
- import { _Event, ApiInfo, Bill, Break, Chat, Company, Job, LineItem, LoginResponse, Message, Route, ServiceMonth, Session, User, UserCompanyAssociation } from '../types/api';
4
+ import { _Event, ApiInfo, Avro, Bill, Break, Chat, Company, Job, LineItem, LoginResponse, Message, Plan, Route, ServiceMonth, Session, User, UserCompanyAssociation } from '../types/api';
5
5
  import { Tokens } from '../types/auth';
6
6
  import { CancelToken, RetryStrategy } from '../types/client';
7
7
  import { StandardError } from '../types/error';
@@ -69,10 +69,12 @@ declare module '../client/QueryClient' {
69
69
  query?: string;
70
70
  paid?: boolean;
71
71
  }): UseInfiniteQueryResult<InfiniteData<Bill[], unknown>, StandardError>;
72
+ useGetPlans(code: string): UseQueryResult<Plan[], StandardError>;
72
73
  useGetCompanies(options?: {}): UseQueryResult<{
73
74
  name: string;
74
75
  id: string;
75
76
  }[], StandardError>;
77
+ useGetAnalytics(): UseQueryResult<any, StandardError>;
76
78
  useGetCompany(companyId: string): UseQueryResult<Company, StandardError>;
77
79
  useGetJob(jobId: string): UseQueryResult<Job, StandardError>;
78
80
  useGetEvent(eventId: string): UseQueryResult<_Event, StandardError>;
@@ -82,6 +84,8 @@ declare module '../client/QueryClient' {
82
84
  useGetRoute(routeId: string): UseQueryResult<Route, StandardError>;
83
85
  useGetChat(chatId: string): UseQueryResult<Chat, StandardError>;
84
86
  useGetUserSessions(): UseQueryResult<Session[], StandardError>;
87
+ useGetAvro(): UseQueryResult<Avro, StandardError>;
88
+ useSearchUsers(searchUsername: string): UseQueryResult<User[], StandardError>;
85
89
  useCreateEvent(): ReturnType<typeof useMutation<{
86
90
  id: string;
87
91
  }, StandardError, {
@@ -215,6 +219,11 @@ declare module '../client/QueryClient' {
215
219
  useDeleteSelf(): ReturnType<typeof useMutation<{
216
220
  msg: string;
217
221
  }, StandardError, void>>;
222
+ useDeleteCompany(): ReturnType<typeof useMutation<{
223
+ msg: string;
224
+ }, StandardError, {
225
+ companyId: string;
226
+ }>>;
218
227
  }
219
228
  }
220
229
  export declare class AvroQueryClient {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,10 @@
1
+ import { useQuery, useQueryClient } from "@tanstack/react-query";
2
+ import { AvroQueryClient } from "../../client/QueryClient";
3
+ AvroQueryClient.prototype.useGetAnalytics = function () {
4
+ const queryClient = useQueryClient();
5
+ return useQuery({
6
+ queryKey: ['analytics'],
7
+ queryFn: () => this.post('/avro/analytics', null),
8
+ enabled: true,
9
+ });
10
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { useQuery } from "@tanstack/react-query";
2
+ import { AvroQueryClient } from "../../client/QueryClient";
3
+ AvroQueryClient.prototype.useGetAvro = function () {
4
+ return useQuery({
5
+ queryKey: ['avro'],
6
+ queryFn: () => this.get('/avro'),
7
+ enabled: true,
8
+ });
9
+ };
@@ -49,3 +49,31 @@ AvroQueryClient.prototype.useUpdateCompany = function () {
49
49
  },
50
50
  });
51
51
  };
52
+ AvroQueryClient.prototype.useDeleteCompany = function () {
53
+ const queryClient = useQueryClient();
54
+ return useMutation({
55
+ mutationFn: async ({ companyId }) => {
56
+ return this.delete(`/company/${companyId}`);
57
+ },
58
+ onMutate: async ({ companyId }) => {
59
+ await queryClient.cancelQueries({ queryKey: ['/company/list'] });
60
+ await queryClient.cancelQueries({ queryKey: ['company', companyId] });
61
+ const previousCompanyList = queryClient.getQueryData(['/company/list']);
62
+ queryClient.setQueryData(['/company/list'], (oldList) => {
63
+ if (!oldList)
64
+ return oldList;
65
+ return oldList.filter((company) => company.id !== companyId);
66
+ });
67
+ return { previousCompanyList };
68
+ },
69
+ onError: (err, companyId, context) => {
70
+ if (context?.previousCompanyList) {
71
+ queryClient.setQueryData(['/company/list'], context.previousCompanyList);
72
+ }
73
+ },
74
+ onSettled: (_data, _error, companyId) => {
75
+ queryClient.invalidateQueries({ queryKey: ['/company/list'] });
76
+ queryClient.invalidateQueries({ queryKey: ['company', companyId] });
77
+ },
78
+ });
79
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { AvroQueryClient } from "../../client/QueryClient";
2
+ import { useQuery, useQueryClient } from "@tanstack/react-query";
3
+ AvroQueryClient.prototype.useGetPlans = function (code) {
4
+ const queryClient = useQueryClient();
5
+ return useQuery({
6
+ queryKey: ['plans', code],
7
+ queryFn: async () => this.get(`/plans${code ? `?code=${code}` : ''}`),
8
+ });
9
+ };
@@ -7,6 +7,17 @@ AvroQueryClient.prototype.useGetUser = function (userId) {
7
7
  enabled: Boolean(userId),
8
8
  });
9
9
  };
10
+ AvroQueryClient.prototype.useSearchUsers = function (searchUsername) {
11
+ return useQuery({
12
+ queryKey: ['user', 'search', searchUsername],
13
+ queryFn: () => {
14
+ if (!searchUsername)
15
+ return Promise.resolve([]);
16
+ return this.get(`/user/search/${searchUsername}`);
17
+ },
18
+ enabled: Boolean(searchUsername),
19
+ });
20
+ };
10
21
  AvroQueryClient.prototype.useGetSelf = function () {
11
22
  return useQuery({
12
23
  queryKey: ['user'],
package/dist/index.d.ts CHANGED
@@ -15,6 +15,9 @@ import './client/hooks/users';
15
15
  import './client/hooks/sessions';
16
16
  import './client/hooks/chats';
17
17
  import './client/hooks/messages';
18
+ import './client/hooks/plans';
19
+ import './client/hooks/analytics';
20
+ import './client/hooks/avro';
18
21
  export * from './types/api';
19
22
  export * from './types/auth';
20
23
  export * from './types/error';
package/dist/index.js CHANGED
@@ -15,6 +15,9 @@ import './client/hooks/users';
15
15
  import './client/hooks/sessions';
16
16
  import './client/hooks/chats';
17
17
  import './client/hooks/messages';
18
+ import './client/hooks/plans';
19
+ import './client/hooks/analytics';
20
+ import './client/hooks/avro';
18
21
  export * from './types/api';
19
22
  export * from './types/auth';
20
23
  export * from './types/error';
@@ -176,6 +176,8 @@ export interface Plan {
176
176
  trial_period_days: number;
177
177
  time_created: number;
178
178
  time_updated: number;
179
+ available_to_new_companies?: boolean;
180
+ available_to?: string[];
179
181
  }
180
182
  export interface BillPayment {
181
183
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.2-beta.67",
3
+ "version": "0.0.2-beta.69",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",