@go-avro/avro-js 0.0.71 → 0.0.72

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, ActiveSessionSummary, ApiInfo, Avro, Bill, BillInsightData, Break, Chat, CheckIn, Company, EventUpdatePayload, FinancialInsightData, RevenueInsightData, Job, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, RouteWritePayload, CatalogItem, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api';
4
+ import { _Event, ActiveSessionSummary, ApiInfo, Avro, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Break, Chat, CheckIn, Company, EventUpdatePayload, FinancialInsightData, RevenueInsightData, Job, EventInsightData, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, RouteWritePayload, 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';
@@ -453,6 +453,13 @@ declare module '../client/QueryClient' {
453
453
  billId: string;
454
454
  updates: Partial<Bill>;
455
455
  }>>;
456
+ useUpdateBillLineItemStatus(): ReturnType<typeof useMutation<{
457
+ msg: string;
458
+ status: BillStatus;
459
+ }, StandardError, {
460
+ billId: string;
461
+ items: BillLineItemStatusUpdate[];
462
+ }>>;
456
463
  useUpdateRoute(): ReturnType<typeof useMutation<{
457
464
  msg: string;
458
465
  }, StandardError, {
@@ -142,6 +142,33 @@ AvroQueryClient.prototype.useUpdateBill = function () {
142
142
  },
143
143
  });
144
144
  };
145
+ AvroQueryClient.prototype.useUpdateBillLineItemStatus = function () {
146
+ const queryClient = this.getQueryClient();
147
+ return useMutation({
148
+ mutationFn: async ({ billId, items, }) => {
149
+ return this.put({
150
+ path: `/bill/${billId}/line-items/status`,
151
+ data: JSON.stringify({ items }),
152
+ headers: {
153
+ 'Content-Type': 'application/json',
154
+ },
155
+ });
156
+ },
157
+ onSuccess: async (_result, { billId }) => {
158
+ await this._syncEntity(queryClient, {
159
+ action: 'update',
160
+ entityKey: 'bills',
161
+ id: billId,
162
+ fetchPath: `/bill/${billId}`,
163
+ });
164
+ // Item paid state also lives on the underlying events,
165
+ // service months and prepayments
166
+ await queryClient.invalidateQueries({ queryKey: ['events'] });
167
+ await queryClient.invalidateQueries({ queryKey: ['months'] });
168
+ await queryClient.invalidateQueries({ queryKey: ['prepayments'] });
169
+ },
170
+ });
171
+ };
145
172
  AvroQueryClient.prototype.useDeleteBill = function () {
146
173
  const queryClient = this.getQueryClient();
147
174
  return useMutation({
@@ -35,3 +35,11 @@ export interface Bill {
35
35
  due_date: number;
36
36
  pass_on_fees: boolean;
37
37
  }
38
+ /** Line-item kinds addressable by PUT /bill/<id>/line-items/status. */
39
+ export type BillLineItemStatusKind = 'event' | 'service_month' | 'prepayment' | 'line_item';
40
+ /** One per-line-item paid/unpaid marking on a bill. */
41
+ export interface BillLineItemStatusUpdate {
42
+ type: BillLineItemStatusKind;
43
+ id: string;
44
+ paid: boolean;
45
+ }
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AVRO_JS_VERSION = "0.0.71";
1
+ export declare const AVRO_JS_VERSION = "0.0.72";
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.71';
3
+ export const AVRO_JS_VERSION = '0.0.72';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.71",
3
+ "version": "0.0.72",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",