@go-avro/avro-js 0.0.59 → 0.0.61

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, RevenueInsightData, 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, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api';
5
5
  import { AuthState, Tokens } from '../types/auth';
6
6
  import { CancelToken, ClientId, RetryStrategy } from '../types/client';
7
7
  import { StandardError } from '../types/error';
@@ -118,6 +118,19 @@ declare module '../client/QueryClient' {
118
118
  amount_min?: number;
119
119
  amount_max?: number;
120
120
  }): UseInfiniteQueryResult<InfiniteData<Bill[], unknown>, StandardError>;
121
+ useGetPayouts(body: {
122
+ amt?: number;
123
+ query?: string;
124
+ status?: string;
125
+ known_ids?: string[];
126
+ unknown_ids?: string[];
127
+ created_from?: number;
128
+ created_to?: number;
129
+ arrival_from?: number;
130
+ arrival_to?: number;
131
+ amount_min?: number;
132
+ amount_max?: number;
133
+ }): UseInfiniteQueryResult<InfiniteData<Payout[], unknown>, StandardError>;
121
134
  useGetLabels(body: {
122
135
  amt?: number;
123
136
  known_ids?: string[];
@@ -679,6 +692,8 @@ export declare class AvroQueryClient {
679
692
  billed?: boolean;
680
693
  paid?: boolean;
681
694
  taskId?: string | null;
695
+ sort_by?: 'date' | 'amount' | 'name';
696
+ direction?: 'asc' | 'desc';
682
697
  }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
683
698
  fetchWaivers(body?: {
684
699
  amt?: number;
@@ -697,6 +712,8 @@ export declare class AvroQueryClient {
697
712
  billed?: boolean;
698
713
  paid?: boolean;
699
714
  job_id?: string | null;
715
+ sort_by?: 'date' | 'amount' | 'name';
716
+ direction?: 'asc' | 'desc';
700
717
  }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
701
718
  fetchMonths(body?: {
702
719
  amt?: number;
@@ -708,6 +725,8 @@ export declare class AvroQueryClient {
708
725
  billed?: boolean;
709
726
  paid?: boolean;
710
727
  jobId?: string | null;
728
+ sort_by?: 'date' | 'amount' | 'name';
729
+ direction?: 'asc' | 'desc';
711
730
  }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
712
731
  fetchBills(body?: {
713
732
  amt?: number;
@@ -722,6 +741,22 @@ export declare class AvroQueryClient {
722
741
  paid_to?: number;
723
742
  amount_min?: number;
724
743
  amount_max?: number;
744
+ sort_by?: 'date' | 'amount' | 'number';
745
+ direction?: 'asc' | 'desc';
746
+ }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
747
+ fetchPayouts(body?: {
748
+ amt?: number;
749
+ query?: string;
750
+ status?: string;
751
+ known_ids?: string[];
752
+ unknown_ids?: string[];
753
+ offset?: number;
754
+ created_from?: number;
755
+ created_to?: number;
756
+ arrival_from?: number;
757
+ arrival_to?: number;
758
+ amount_min?: number;
759
+ amount_max?: number;
725
760
  }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
726
761
  fetchRoutes(body?: {
727
762
  amt?: number;
@@ -988,6 +988,25 @@ export class AvroQueryClient {
988
988
  throw new StandardError(500, 'Failed to fetch bills');
989
989
  });
990
990
  }
991
+ fetchPayouts(body = {}, cancelToken, headers = {}) {
992
+ if (!this.companyId || this.companyId.trim() === '') {
993
+ throw new StandardError(400, 'Company ID is required');
994
+ }
995
+ return this._fetch('POST', `/company/${this.companyId}/payouts`, JSON.stringify(body), cancelToken, {
996
+ ...headers,
997
+ 'Content-Type': 'application/json',
998
+ })
999
+ .then((response) => {
1000
+ if (!response || !Array.isArray(response)) {
1001
+ throw new StandardError(400, 'Invalid payouts response');
1002
+ }
1003
+ return response;
1004
+ })
1005
+ .catch((err) => {
1006
+ console.error('Failed to fetch payouts:', err);
1007
+ throw new StandardError(500, 'Failed to fetch payouts');
1008
+ });
1009
+ }
991
1010
  fetchRoutes(body = {}, cancelToken, headers = {}) {
992
1011
  if (!this.companyId || this.companyId.trim() === '') {
993
1012
  throw new StandardError(400, 'Company ID is required');
@@ -16,6 +16,8 @@ AvroQueryClient.prototype.useGetBills = function (body) {
16
16
  body.paid_to ?? null,
17
17
  body.amount_min ?? null,
18
18
  body.amount_max ?? null,
19
+ body.sort_by ?? null,
20
+ body.direction ?? null,
19
21
  ],
20
22
  initialPageParam: 0,
21
23
  getNextPageParam: (lastPage, allPages) => {
@@ -19,6 +19,8 @@ AvroQueryClient.prototype.useGetEvents = function (body) {
19
19
  body.paid ?? true,
20
20
  body.jobId ?? '',
21
21
  body.enabled ?? true,
22
+ body.sort_by ?? null,
23
+ body.direction ?? null,
22
24
  ],
23
25
  initialPageParam: 0,
24
26
  getNextPageParam: (lastPage, allPages) => {
@@ -16,6 +16,8 @@ AvroQueryClient.prototype.useGetMonths = function (body) {
16
16
  body.paid ?? true,
17
17
  body.jobId ?? '',
18
18
  body.enabled ?? true,
19
+ body.sort_by ?? null,
20
+ body.direction ?? null,
19
21
  ],
20
22
  initialPageParam: 0,
21
23
  getNextPageParam: (lastPage, allPages) => {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,36 @@
1
+ import { useInfiniteQuery } from '@tanstack/react-query';
2
+ import { AvroQueryClient } from '../../client/QueryClient';
3
+ AvroQueryClient.prototype.useGetPayouts = function (body) {
4
+ const queryClient = this.getQueryClient();
5
+ const result = useInfiniteQuery({
6
+ queryKey: [
7
+ 'payouts',
8
+ this.companyId,
9
+ body.query ?? '',
10
+ body.status ?? '',
11
+ body.known_ids ?? [],
12
+ body.unknown_ids ?? [],
13
+ body.created_from ?? null,
14
+ body.created_to ?? null,
15
+ body.arrival_from ?? null,
16
+ body.arrival_to ?? null,
17
+ body.amount_min ?? null,
18
+ body.amount_max ?? null,
19
+ ],
20
+ initialPageParam: 0,
21
+ getNextPageParam: (lastPage, allPages) => {
22
+ if (lastPage.length < (body.amt ?? 50))
23
+ return undefined;
24
+ return allPages.flat().length; // next offset
25
+ },
26
+ queryFn: ({ pageParam = 0 }) => this.fetchPayouts({ ...body, offset: pageParam }),
27
+ });
28
+ if (result.data) {
29
+ result.data.pages.forEach((data_page) => {
30
+ data_page.forEach((payout) => {
31
+ queryClient.setQueryData(['payouts', payout.id], payout);
32
+ });
33
+ });
34
+ }
35
+ return result;
36
+ };
@@ -16,6 +16,8 @@ AvroQueryClient.prototype.useGetPrepayments = function (body) {
16
16
  body.paid ?? true,
17
17
  body.taskId ?? '',
18
18
  body.enabled ?? true,
19
+ body.sort_by ?? null,
20
+ body.direction ?? null,
19
21
  ],
20
22
  initialPageParam: 0,
21
23
  getNextPageParam: (lastPage, allPages) => {
package/dist/index.d.ts CHANGED
@@ -14,6 +14,7 @@ import './client/hooks/routes';
14
14
  import './client/hooks/events';
15
15
  import './client/hooks/months';
16
16
  import './client/hooks/bills';
17
+ import './client/hooks/payouts';
17
18
  import './client/hooks/companies';
18
19
  import './client/hooks/users';
19
20
  import './client/hooks/sessions';
package/dist/index.js CHANGED
@@ -12,6 +12,7 @@ import './client/hooks/routes';
12
12
  import './client/hooks/events';
13
13
  import './client/hooks/months';
14
14
  import './client/hooks/bills';
15
+ import './client/hooks/payouts';
15
16
  import './client/hooks/companies';
16
17
  import './client/hooks/users';
17
18
  import './client/hooks/sessions';
@@ -4,10 +4,13 @@ export interface BillPayment {
4
4
  avro_fees: number;
5
5
  stripe_fees: number;
6
6
  stripe_pi_id: string;
7
+ payout_id: string | null;
7
8
  bill_user_id: string;
8
9
  status: 'created' | 'processing' | 'succeeded' | 'failed' | 'canceled' | 'requires_action';
9
10
  type: 'us_bank_account' | 'card';
10
- action_required_at: number;
11
+ email_paid_by: string;
12
+ name_paid_by: string;
13
+ action_required_at: number | null;
11
14
  time_created: number;
12
15
  time_updated: number | null;
13
16
  }
@@ -0,0 +1,20 @@
1
+ import { BillPayment } from '../../types/api/BillPayment';
2
+ /**
3
+ * A Stripe payout — one bank deposit that batches many invoice payments
4
+ * net of fees. `payments` are the BillPayments that settled in this payout,
5
+ * letting a deposit be traced back to the exact invoices inside it.
6
+ *
7
+ * Amounts are integer cents; `arrival_date` / timestamps are unix seconds.
8
+ */
9
+ export interface Payout {
10
+ id: string;
11
+ stripe_payout_id: string;
12
+ amount: number;
13
+ currency: string;
14
+ status: string;
15
+ company_id: string;
16
+ arrival_date: number | null;
17
+ payments: BillPayment[];
18
+ time_created: number;
19
+ time_updated: number | null;
20
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -22,6 +22,7 @@ export * from '../types/api/Message';
22
22
  export * from '../types/api/PaymentMethod';
23
23
  export * from '../types/api/PaymentOption';
24
24
  export * from '../types/api/PaymentType';
25
+ export * from '../types/api/Payout';
25
26
  export * from '../types/api/Plan';
26
27
  export * from '../types/api/PlanPayment';
27
28
  export * from '../types/api/Prepayment';
package/dist/types/api.js CHANGED
@@ -21,6 +21,7 @@ export * from '../types/api/Message';
21
21
  export * from '../types/api/PaymentMethod';
22
22
  export * from '../types/api/PaymentOption';
23
23
  export * from '../types/api/PaymentType';
24
+ export * from '../types/api/Payout';
24
25
  export * from '../types/api/Plan';
25
26
  export * from '../types/api/PlanPayment';
26
27
  export * from '../types/api/Prepayment';
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AVRO_JS_VERSION = "0.0.59";
1
+ export declare const AVRO_JS_VERSION = "0.0.61";
package/dist/version.js CHANGED
@@ -1,3 +1,3 @@
1
1
  // AUTO-GENERATED by scripts/gen-version.js — do not edit by hand.
2
2
  // Regenerated from package.json by the `prebuild` npm hook.
3
- export const AVRO_JS_VERSION = '0.0.59';
3
+ export const AVRO_JS_VERSION = '0.0.61';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.59",
3
+ "version": "0.0.61",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -35,6 +35,7 @@
35
35
  "author": "Avro <info@goavro.com>",
36
36
  "license": "CC-BY-SA-4.0",
37
37
  "devDependencies": {
38
+ "@eslint/js": "^9.39.4",
38
39
  "@types/react": "^19.2.2",
39
40
  "@types/uuid": "^10.0.0",
40
41
  "@typescript-eslint/eslint-plugin": "^8.38.0",
@@ -43,12 +44,11 @@
43
44
  "eslint-plugin-import": "^2.32.0",
44
45
  "eslint-plugin-jsx-a11y": "^6.10.2",
45
46
  "eslint-plugin-react": "^7.37.5",
47
+ "globals": "^17.6.0",
46
48
  "prettier": "^3.8.3",
47
49
  "tsc-alias": "^1.8.17",
48
50
  "typescript": "^5.8.3",
49
- "typescript-eslint": "^8.38.0",
50
- "@eslint/js": "^9.39.4",
51
- "globals": "^17.6.0"
51
+ "typescript-eslint": "^8.38.0"
52
52
  },
53
53
  "files": [
54
54
  "dist"