@go-avro/avro-js 0.0.10-beta.2 → 0.0.10-beta.3

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 } from '../types/api';
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';
5
5
  import { AuthState, Tokens } from '../types/auth';
6
6
  import { CancelToken, RetryStrategy } from '../types/client';
7
7
  import { StandardError } from '../types/error';
@@ -153,6 +153,14 @@ declare module '../client/QueryClient' {
153
153
  useGetChat(chatId: string): UseQueryResult<Chat, StandardError>;
154
154
  useGetCatalogItem(catalogItemId: string): UseQueryResult<CatalogItem, StandardError>;
155
155
  useGetUserSessions(): UseQueryResult<Session[], StandardError>;
156
+ useGetCompanyTimecards(params?: {
157
+ companyId?: string;
158
+ periodStart?: number;
159
+ userCompanyId?: string;
160
+ status?: TimecardStatus;
161
+ enabled?: boolean;
162
+ }): UseQueryResult<Timecard[], StandardError>;
163
+ useGetTimecard(timecardId?: string, enabled?: boolean): UseQueryResult<Timecard, StandardError>;
156
164
  useGetAvro(): UseQueryResult<Avro, StandardError>;
157
165
  useSearchUsers(searchUsername: string): UseQueryResult<User[], StandardError>;
158
166
  useAcceptProposal(proposal_id: string): ReturnType<typeof useMutation<{
@@ -207,6 +215,18 @@ declare module '../client/QueryClient' {
207
215
  }, StandardError, {
208
216
  sessionData: Partial<Session>;
209
217
  }>>;
218
+ useCreateTimecard(): ReturnType<typeof useMutation<{
219
+ msg: string;
220
+ id: string;
221
+ }, StandardError, {
222
+ companyId?: string;
223
+ data: {
224
+ user_company_id?: string;
225
+ period_start?: number;
226
+ status?: TimecardStatus;
227
+ details?: string;
228
+ };
229
+ }>>;
210
230
  useCreateBill(): ReturnType<typeof useMutation<{
211
231
  id: string;
212
232
  invoice_id: number;
@@ -293,6 +313,19 @@ declare module '../client/QueryClient' {
293
313
  sessionId: string;
294
314
  updates: Partial<Session>;
295
315
  }>>;
316
+ useUpdateTimecard(): ReturnType<typeof useMutation<{
317
+ msg: string;
318
+ timecard: Timecard;
319
+ }, StandardError, {
320
+ timecardId: string;
321
+ updates: {
322
+ status?: TimecardStatus;
323
+ start?: number;
324
+ end?: number;
325
+ details?: string;
326
+ action_type?: TimecardActionType;
327
+ };
328
+ }>>;
296
329
  useUpdateGroup(): ReturnType<typeof useMutation<{
297
330
  msg: string;
298
331
  }, StandardError, {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,76 @@
1
+ import { useMutation, useQuery } from "@tanstack/react-query";
2
+ import { AvroQueryClient } from "../../client/QueryClient";
3
+ AvroQueryClient.prototype.useGetCompanyTimecards = function (params = {}) {
4
+ const companyId = params.companyId ?? this.companyId;
5
+ return useQuery({
6
+ queryKey: [
7
+ "timecards",
8
+ companyId,
9
+ params.periodStart ?? null,
10
+ params.userCompanyId ?? null,
11
+ params.status ?? null,
12
+ ],
13
+ queryFn: async () => {
14
+ const search = new URLSearchParams();
15
+ if (typeof params.periodStart === "number") {
16
+ search.set("period_start", String(params.periodStart));
17
+ }
18
+ if (params.userCompanyId) {
19
+ search.set("user_company_id", params.userCompanyId);
20
+ }
21
+ if (params.status) {
22
+ search.set("status", params.status);
23
+ }
24
+ const query = search.toString();
25
+ const rsp = await this.get({
26
+ path: `/company/${companyId}/timecards${query ? `?${query}` : ""}`,
27
+ });
28
+ return rsp.timecards ?? [];
29
+ },
30
+ enabled: Boolean(companyId) && Boolean(params.enabled ?? true),
31
+ });
32
+ };
33
+ AvroQueryClient.prototype.useGetTimecard = function (timecardId, enabled = true) {
34
+ return useQuery({
35
+ queryKey: ["timecard", timecardId],
36
+ queryFn: async () => {
37
+ const rsp = await this.get({
38
+ path: `/timecard/${timecardId}`,
39
+ });
40
+ return rsp.timecard;
41
+ },
42
+ enabled: Boolean(timecardId) && enabled,
43
+ });
44
+ };
45
+ AvroQueryClient.prototype.useCreateTimecard = function () {
46
+ const queryClient = this.getQueryClient();
47
+ return useMutation({
48
+ mutationFn: ({ companyId, data, }) => {
49
+ const targetCompanyId = companyId ?? this.companyId;
50
+ return this.post({
51
+ path: `/company/${targetCompanyId}/timecard`,
52
+ data: JSON.stringify(data),
53
+ headers: { "Content-Type": "application/json" },
54
+ });
55
+ },
56
+ onSettled: async () => {
57
+ await queryClient.invalidateQueries({ queryKey: ["timecards"] });
58
+ },
59
+ });
60
+ };
61
+ AvroQueryClient.prototype.useUpdateTimecard = function () {
62
+ const queryClient = this.getQueryClient();
63
+ return useMutation({
64
+ mutationFn: ({ timecardId, updates, }) => {
65
+ return this.put({
66
+ path: `/timecard/${timecardId}`,
67
+ data: JSON.stringify(updates),
68
+ headers: { "Content-Type": "application/json" },
69
+ });
70
+ },
71
+ onSettled: async (_data, _err, variables) => {
72
+ await queryClient.invalidateQueries({ queryKey: ["timecards"] });
73
+ await queryClient.invalidateQueries({ queryKey: ["timecard", variables.timecardId] });
74
+ },
75
+ });
76
+ };
package/dist/index.d.ts CHANGED
@@ -26,6 +26,7 @@ import './client/hooks/labels';
26
26
  import './client/hooks/groups';
27
27
  import './client/hooks/skills';
28
28
  import './client/hooks/proposal';
29
+ import './client/hooks/timecards';
29
30
  import './client/hooks/waivers';
30
31
  export * from './types/api';
31
32
  export * from './types/auth';
package/dist/index.js CHANGED
@@ -26,6 +26,7 @@ import './client/hooks/labels';
26
26
  import './client/hooks/groups';
27
27
  import './client/hooks/skills';
28
28
  import './client/hooks/proposal';
29
+ import './client/hooks/timecards';
29
30
  import './client/hooks/waivers';
30
31
  export * from './types/api';
31
32
  export * from './types/auth';
@@ -55,4 +55,6 @@ export interface Company {
55
55
  payment_methods: PaymentMethod[];
56
56
  intuit_connected: boolean;
57
57
  next_payment_due: number | null;
58
+ timecard_base: number;
59
+ timecard_length: number;
58
60
  }
@@ -1,13 +1,19 @@
1
1
  import { Break } from "../../types/api/Break";
2
- export interface Session {
3
- id: string;
4
- user_id: string;
5
- company_id: string;
6
- time_started: number;
7
- time_ended: number;
8
- break_id: string;
9
- is_paused: boolean;
10
- team_id: string;
11
- route_id: string;
12
- breaks: Break[];
2
+ declare module "../../types/api/Session" {
3
+ interface Session {
4
+ id: string;
5
+ user_id: string;
6
+ company_id: string;
7
+ time_started: number;
8
+ time_ended: number | null;
9
+ break_id: string | null;
10
+ is_paused: boolean;
11
+ team_id: string | null;
12
+ route_id: string | null;
13
+ current_route_id?: string | null;
14
+ breaks: Break[];
15
+ }
16
+ }
17
+ export declare class Session {
18
+ constructor(init?: Partial<Session>);
13
19
  }
@@ -1 +1,5 @@
1
- export {};
1
+ export class Session {
2
+ constructor(init) {
3
+ Object.assign(this, init);
4
+ }
5
+ }
@@ -0,0 +1,20 @@
1
+ import { TimecardAction } from "../../types/api/TimecardAction";
2
+ export declare const TimecardStatus: {
3
+ readonly OPEN: "open";
4
+ readonly PENDING: "pending";
5
+ readonly APPROVED: "approved";
6
+ readonly REJECTED: "rejected";
7
+ };
8
+ export type TimecardStatus = typeof TimecardStatus[keyof typeof TimecardStatus];
9
+ export interface Timecard {
10
+ id: string;
11
+ user_company_id: string;
12
+ session_ids: string[];
13
+ submitted_at: number | null;
14
+ start: number | null;
15
+ end: number | null;
16
+ status: TimecardStatus;
17
+ actions: TimecardAction[];
18
+ time_created: number | null;
19
+ time_updated: number | null;
20
+ }
@@ -0,0 +1,6 @@
1
+ export const TimecardStatus = {
2
+ OPEN: "open",
3
+ PENDING: "pending",
4
+ APPROVED: "approved",
5
+ REJECTED: "rejected",
6
+ };
@@ -0,0 +1,18 @@
1
+ export declare const TimecardActionType: {
2
+ readonly CREATED: "created";
3
+ readonly SUBMITTED: "submitted";
4
+ readonly COMMENTED: "commented";
5
+ readonly APPROVED: "approved";
6
+ readonly REJECTED: "rejected";
7
+ readonly EDITED: "edited";
8
+ };
9
+ export type TimecardActionType = typeof TimecardActionType[keyof typeof TimecardActionType];
10
+ export interface TimecardAction {
11
+ id: string;
12
+ action_type: TimecardActionType;
13
+ first_name: string | null;
14
+ last_name: string | null;
15
+ details: string | null;
16
+ time_created: number | null;
17
+ time_updated: number | null;
18
+ }
@@ -0,0 +1,8 @@
1
+ export const TimecardActionType = {
2
+ CREATED: "created",
3
+ SUBMITTED: "submitted",
4
+ COMMENTED: "commented",
5
+ APPROVED: "approved",
6
+ REJECTED: "rejected",
7
+ EDITED: "edited",
8
+ };
@@ -59,6 +59,15 @@ export interface UserCompanyAssociation {
59
59
  id: string;
60
60
  user: User;
61
61
  company: string;
62
+ hourly_rate: number;
63
+ salary_rate: number;
64
+ bill_rate: number;
65
+ pto_rate: number;
66
+ sick_rate: number;
67
+ accrued_pto: number;
68
+ accrued_sick: number;
69
+ pto_accrual_rate: number;
70
+ sick_accrual_rate: number;
62
71
  permissions: Permission[];
63
72
  effective_permissions: Permission[];
64
73
  time_created: number | null;
@@ -32,6 +32,8 @@ export * from "../types/api/Session";
32
32
  export * from "../types/api/Skill";
33
33
  export * from "../types/api/Subscription";
34
34
  export * from "../types/api/Task";
35
+ export * from "../types/api/Timecard";
36
+ export * from "../types/api/TimecardAction";
35
37
  export * from "../types/api/User";
36
38
  export * from "../types/api/UserCompanyAssociation";
37
39
  export * from "../types/api/UserEvent";
package/dist/types/api.js CHANGED
@@ -31,6 +31,8 @@ export * from "../types/api/Session";
31
31
  export * from "../types/api/Skill";
32
32
  export * from "../types/api/Subscription";
33
33
  export * from "../types/api/Task";
34
+ export * from "../types/api/Timecard";
35
+ export * from "../types/api/TimecardAction";
34
36
  export * from "../types/api/User";
35
37
  export * from "../types/api/UserCompanyAssociation";
36
38
  export * from "../types/api/UserEvent";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.10-beta.2",
3
+ "version": "0.0.10-beta.3",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",