@go-avro/avro-js 0.0.99 → 0.0.100

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, AddressFeatureCollection, ApiInfo, Avro, StorageAnalytics, ClientErrorReport, ErrorLogEntry, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Break, Chat, CheckIn, Company, DelayEventCreatePayload, EventUpdatePayload, LineItemType, FinancialInsightData, RevenueInsightData, Job, JobUpdate, 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, AddressFeatureCollection, ApiInfo, Avro, StorageAnalytics, ClientErrorReport, ErrorLogEntry, AuditLogEntry, AuditQueryParams, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Break, Chat, CheckIn, Company, DelayEventCreatePayload, EventUpdatePayload, LineItemType, FinancialInsightData, RevenueInsightData, Job, JobUpdate, 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';
@@ -33,6 +33,8 @@ declare module '../client/QueryClient' {
33
33
  getDelay(strategy: RetryStrategy, attempt: number): number;
34
34
  sleep(ms: number): Promise<void>;
35
35
  useGetRoot(): UseQueryResult<ApiInfo, StandardError>;
36
+ useJobAudit(jobId: string, params?: AuditQueryParams): UseQueryResult<AuditLogEntry[], StandardError>;
37
+ useCompanyAudit(params?: AuditQueryParams): UseQueryResult<AuditLogEntry[], StandardError>;
36
38
  useGetJobs(params?: {
37
39
  companyId?: string;
38
40
  numJobs?: number;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,58 @@
1
+ import { useQuery } from '@tanstack/react-query';
2
+ import { AvroQueryClient } from '../../client/QueryClient';
3
+ const buildQuery = (params) => {
4
+ const search = new URLSearchParams();
5
+ if (params?.q)
6
+ search.set('q', params.q);
7
+ if (params?.entityType)
8
+ search.set('entity_type', params.entityType);
9
+ if (params?.action)
10
+ search.set('action', params.action);
11
+ if (params?.limit !== undefined)
12
+ search.set('limit', String(params.limit));
13
+ const encoded = search.toString();
14
+ return encoded ? `?${encoded}` : '';
15
+ };
16
+ AvroQueryClient.prototype.useJobAudit = function (jobId, params) {
17
+ return useQuery({
18
+ queryKey: [
19
+ 'audit',
20
+ 'job',
21
+ jobId,
22
+ params?.q ?? '',
23
+ params?.entityType ?? '',
24
+ params?.action ?? '',
25
+ params?.limit ?? 200,
26
+ ],
27
+ enabled: Boolean(jobId),
28
+ staleTime: 30000,
29
+ queryFn: async () => {
30
+ const response = await this.get({
31
+ path: `/job/${jobId}/audit${buildQuery(params)}`,
32
+ });
33
+ return response.audit ?? [];
34
+ },
35
+ });
36
+ };
37
+ AvroQueryClient.prototype.useCompanyAudit = function (params) {
38
+ const companyId = this.companyId;
39
+ return useQuery({
40
+ queryKey: [
41
+ 'audit',
42
+ 'company',
43
+ companyId,
44
+ params?.q ?? '',
45
+ params?.entityType ?? '',
46
+ params?.action ?? '',
47
+ params?.limit ?? 200,
48
+ ],
49
+ enabled: Boolean(companyId),
50
+ staleTime: 30000,
51
+ queryFn: async () => {
52
+ const response = await this.get({
53
+ path: `/company/${companyId}/audit${buildQuery(params)}`,
54
+ });
55
+ return response.audit ?? [];
56
+ },
57
+ });
58
+ };
package/dist/index.d.ts CHANGED
@@ -11,6 +11,7 @@ import './client/core/utils';
11
11
  import './client/hooks/address';
12
12
  import './client/hooks/root';
13
13
  import './client/hooks/jobs';
14
+ import './client/hooks/audit';
14
15
  import './client/hooks/routes';
15
16
  import './client/hooks/events';
16
17
  import './client/hooks/months';
package/dist/index.js CHANGED
@@ -9,6 +9,7 @@ import './client/core/utils';
9
9
  import './client/hooks/address';
10
10
  import './client/hooks/root';
11
11
  import './client/hooks/jobs';
12
+ import './client/hooks/audit';
12
13
  import './client/hooks/routes';
13
14
  import './client/hooks/events';
14
15
  import './client/hooks/months';
@@ -0,0 +1,29 @@
1
+ /** One field-level change inside an audit entry. */
2
+ export interface AuditLogChange {
3
+ field: string;
4
+ old: unknown;
5
+ new: unknown;
6
+ }
7
+ /** One entry from a job or company audit history. */
8
+ export interface AuditLogEntry {
9
+ id: string | null;
10
+ log_type: 'job' | 'event' | 'bill' | 'company';
11
+ /** Epoch seconds. */
12
+ time: number | null;
13
+ actor: string;
14
+ actor_id: string | null;
15
+ entity_type: 'JOB' | 'TASK' | 'EVENT' | 'BILL' | 'COMPANY' | 'MEMBER' | 'GROUP';
16
+ entity_id: string | null;
17
+ entity_label: string;
18
+ action: 'CREATED' | 'UPDATED' | 'DELETED';
19
+ changes: AuditLogChange[];
20
+ description: string;
21
+ }
22
+ /** Filters accepted by the audit search endpoints. */
23
+ export interface AuditQueryParams {
24
+ /** Free-text search over description, entity label, and actor. */
25
+ q?: string;
26
+ entityType?: string;
27
+ action?: string;
28
+ limit?: number;
29
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -6,6 +6,7 @@ export * from '../types/api/AdditionalCharge';
6
6
  export * from '../types/api/DelayEvent';
7
7
  export * from '../types/api/Address';
8
8
  export * from '../types/api/Avro';
9
+ export * from '../types/api/AuditLog';
9
10
  export * from '../types/api/Bill';
10
11
  export * from '../types/api/BillPayment';
11
12
  export * from '../types/api/Refund';
package/dist/types/api.js CHANGED
@@ -3,6 +3,7 @@ export * from '../types/api/AdditionalCharge';
3
3
  export * from '../types/api/DelayEvent';
4
4
  export * from '../types/api/Address';
5
5
  export * from '../types/api/Avro';
6
+ export * from '../types/api/AuditLog';
6
7
  export * from '../types/api/Bill';
7
8
  export * from '../types/api/BillPayment';
8
9
  export * from '../types/api/Refund';
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const AVRO_JS_VERSION = "0.0.99";
1
+ export declare const AVRO_JS_VERSION = "0.0.100";
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.99';
3
+ export const AVRO_JS_VERSION = '0.0.100';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.99",
3
+ "version": "0.0.100",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",