@go-avro/avro-js 0.0.13-beta.0 → 0.0.14

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, QueryClient, UseInfiniteQueryResult, useMutation, UseQueryResult } from '@tanstack/react-query';
3
3
  import { AuthManager } from '../auth/AuthManager';
4
- import { _Event, ApiInfo, Avro, Bill, Break, Chat, Company, FinancialInsightData, Job, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, CatalogItem, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api';
4
+ import { _Event, ApiInfo, Avro, Bill, Break, Chat, Company, FinancialInsightData, RevenueInsightData, Job, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, CatalogItem, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api';
5
5
  import { AuthState, Tokens } from '../types/auth';
6
6
  import { CancelToken, RetryStrategy } from '../types/client';
7
7
  import { StandardError } from '../types/error';
@@ -142,6 +142,9 @@ declare module '../client/QueryClient' {
142
142
  useEventAnalytics({ periods }: {
143
143
  periods: number[][];
144
144
  }): UseQueryResult<EventInsightData[], StandardError>;
145
+ useRevenueAnalytics({ periods }: {
146
+ periods: number[][];
147
+ }): UseQueryResult<RevenueInsightData[], StandardError>;
145
148
  useGetCompany(companyId: string): UseQueryResult<Company, StandardError>;
146
149
  useGetCurrentCompany(): UseQueryResult<Company, StandardError>;
147
150
  useGetJob(jobId: string): UseQueryResult<Job, StandardError>;
@@ -34,3 +34,16 @@ AvroQueryClient.prototype.useEventAnalytics = function ({ periods }) {
34
34
  enabled: Boolean(this.companyId),
35
35
  });
36
36
  };
37
+ AvroQueryClient.prototype.useRevenueAnalytics = function ({ periods }) {
38
+ return useQuery({
39
+ queryKey: ['analytics', 'revenue', this.companyId, periods],
40
+ queryFn: () => this.post({
41
+ path: `/company/${this.companyId}/analytics/revenue`,
42
+ data: JSON.stringify({ periods }),
43
+ headers: {
44
+ 'Content-Type': 'application/json',
45
+ }
46
+ }),
47
+ enabled: Boolean(this.companyId),
48
+ });
49
+ };
@@ -18,6 +18,7 @@ declare module '../../types/api/_Event' {
18
18
  additional_charges: AdditionalCharge[];
19
19
  users: UserEvent[];
20
20
  autostart: boolean;
21
+ team_id: string | null;
21
22
  }
22
23
  }
23
24
  export declare class _Event extends LineItem {
@@ -219,3 +219,26 @@ export interface EventInsightData {
219
219
  }[];
220
220
  total_events: number;
221
221
  }
222
+ export interface RevenueByTeam {
223
+ team_id: string | null;
224
+ team_name: string;
225
+ revenue: number;
226
+ event_count: number;
227
+ }
228
+ export interface RevenueByUser {
229
+ user_id: string | null;
230
+ user_name: string;
231
+ revenue: number;
232
+ event_count: number;
233
+ }
234
+ export interface UserSeconds {
235
+ user_id: string | null;
236
+ seconds: number;
237
+ }
238
+ export interface RevenueInsightData {
239
+ start: number;
240
+ end: number;
241
+ by_team: RevenueByTeam[];
242
+ by_user: RevenueByUser[];
243
+ user_seconds: UserSeconds[];
244
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.13-beta.0",
3
+ "version": "0.0.14",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",