@go-avro/avro-js 0.0.59 → 0.0.60

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[];
@@ -723,6 +736,20 @@ export declare class AvroQueryClient {
723
736
  amount_min?: number;
724
737
  amount_max?: number;
725
738
  }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
739
+ fetchPayouts(body?: {
740
+ amt?: number;
741
+ query?: string;
742
+ status?: string;
743
+ known_ids?: string[];
744
+ unknown_ids?: string[];
745
+ offset?: number;
746
+ created_from?: number;
747
+ created_to?: number;
748
+ arrival_from?: number;
749
+ arrival_to?: number;
750
+ amount_min?: number;
751
+ amount_max?: number;
752
+ }, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
726
753
  fetchRoutes(body?: {
727
754
  amt?: number;
728
755
  known_ids?: string[];
@@ -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');
@@ -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
+ };
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.60";
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.60';
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.60",
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"