@go-avro/avro-js 0.0.67 → 0.0.69

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, CatalogItem, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api';
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';
5
5
  import { AuthState, Tokens } from '../types/auth';
6
6
  import { CancelToken, ClientId, RetryStrategy } from '../types/client';
7
7
  import { StandardError } from '../types/error';
@@ -304,7 +304,7 @@ declare module '../client/QueryClient' {
304
304
  useCreateRoute(): ReturnType<typeof useMutation<{
305
305
  id: string;
306
306
  }, StandardError, {
307
- routeData: Partial<Route>;
307
+ routeData: RouteWritePayload;
308
308
  }>>;
309
309
  useCreateTeam(): ReturnType<typeof useMutation<{
310
310
  id: string;
@@ -457,7 +457,7 @@ declare module '../client/QueryClient' {
457
457
  msg: string;
458
458
  }, StandardError, {
459
459
  routeId: string;
460
- updates: Partial<Route>;
460
+ updates: RouteWritePayload;
461
461
  }>>;
462
462
  useUpdateEvents(): ReturnType<typeof useMutation<void, StandardError, {
463
463
  events: (_Event & {
@@ -107,13 +107,20 @@ const SOCKET_EVENT_CONFIG = {
107
107
  entityKey: 'companies',
108
108
  action: 'create',
109
109
  fetchPath: (id) => `/company/${id}`,
110
+ alsoInvalidate: [['/company/list']],
110
111
  },
111
112
  update_company: {
112
113
  entityKey: 'companies',
113
114
  action: 'update',
114
115
  fetchPath: (id) => `/company/${id}`,
116
+ alsoInvalidate: [['companies', 'current'], ['/company/list']],
117
+ },
118
+ delete_company: {
119
+ entityKey: 'companies',
120
+ action: 'delete',
121
+ fetchPath: null,
122
+ alsoInvalidate: [['companies', 'current'], ['/company/list']],
115
123
  },
116
- delete_company: { entityKey: 'companies', action: 'delete', fetchPath: null },
117
124
  // ── Users (no single-entity socket events) ──
118
125
  user_updated: { invalidateKeys: [['users'], ['user']] },
119
126
  update_users: { invalidateKeys: [['users'], ['user']] },
@@ -49,7 +49,7 @@ AvroQueryClient.prototype.useCreateRoute = function () {
49
49
  headers: { 'Content-Type': 'application/json' },
50
50
  });
51
51
  },
52
- onMutate: async ({ routeData }) => {
52
+ onMutate: async ({ routeData: { optimize: _optimize, ...routeData } }) => {
53
53
  await queryClient.cancelQueries({ queryKey: ['routes'] });
54
54
  const previousRoutes = queryClient.getQueryData(['routes']);
55
55
  queryClient.setQueriesData({ queryKey: ['routes'] }, (oldData) => {
@@ -113,14 +113,14 @@ AvroQueryClient.prototype.useScheduleRoutes = function () {
113
113
  AvroQueryClient.prototype.useUpdateRoute = function () {
114
114
  const queryClient = this.getQueryClient();
115
115
  return useMutation({
116
- mutationFn: async ({ routeId, updates }) => {
116
+ mutationFn: async ({ routeId, updates, }) => {
117
117
  return this.put({
118
118
  path: `/route/${routeId}`,
119
119
  data: JSON.stringify(updates),
120
120
  headers: { 'Content-Type': 'application/json' },
121
121
  });
122
122
  },
123
- onMutate: async ({ routeId, updates }) => {
123
+ onMutate: async ({ routeId, updates: { optimize: _optimize, ...updates } }) => {
124
124
  await queryClient.cancelQueries({ queryKey: ['routes', routeId] });
125
125
  await queryClient.cancelQueries({ queryKey: ['routes'] });
126
126
  const previousRoute = queryClient.getQueryData(['routes', routeId]);
@@ -1,5 +1,6 @@
1
1
  import { FrequencyType } from '..';
2
2
  import { _Event } from '../types/api/_Event';
3
+ import { Route } from '../types/api/Route';
3
4
  export * from '../types/api/_Event';
4
5
  export * from '../types/api/AdditionalCharge';
5
6
  export * from '../types/api/Avro';
@@ -241,6 +242,14 @@ export interface EventUserUpdate {
241
242
  time_started?: number | null;
242
243
  time_ended?: number | null;
243
244
  }
245
+ /**
246
+ * Route create/update payload. `optimize` explicitly requests an
247
+ * optimizer run on this save; `is_optimized` itself is server-owned
248
+ * (true only when the current order came from the optimizer).
249
+ */
250
+ export type RouteWritePayload = Partial<Omit<Route, 'is_optimized'>> & {
251
+ optimize?: boolean;
252
+ };
244
253
  /** Event update payload: _Event fields, but users use the wire shape. */
245
254
  export type EventUpdatePayload = Partial<Omit<_Event, 'users'>> & {
246
255
  users?: EventUserUpdate[];
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AVRO_JS_VERSION = "0.0.67";
1
+ export declare const AVRO_JS_VERSION = "0.0.69";
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.67';
3
+ export const AVRO_JS_VERSION = '0.0.69';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.67",
3
+ "version": "0.0.69",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",