@go-avro/avro-js 0.0.56 → 0.0.57
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.
|
@@ -3,7 +3,7 @@ import { InfiniteData, QueryClient, UseInfiniteQueryResult, useMutation, UseQuer
|
|
|
3
3
|
import { AuthManager } from '../auth/AuthManager';
|
|
4
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';
|
|
5
5
|
import { AuthState, Tokens } from '../types/auth';
|
|
6
|
-
import { CancelToken, RetryStrategy } from '../types/client';
|
|
6
|
+
import { CancelToken, ClientId, RetryStrategy } from '../types/client';
|
|
7
7
|
import { StandardError } from '../types/error';
|
|
8
8
|
import { CacheData } from '../types/cache';
|
|
9
9
|
import { Waiver } from '../types/api/Waiver';
|
|
@@ -23,6 +23,8 @@ export interface AvroQueryClientConfig {
|
|
|
23
23
|
maxRetries?: number;
|
|
24
24
|
retryStrategy?: RetryStrategy;
|
|
25
25
|
timeout?: number;
|
|
26
|
+
clientId?: ClientId;
|
|
27
|
+
clientVersion?: string;
|
|
26
28
|
}
|
|
27
29
|
declare module '../client/QueryClient' {
|
|
28
30
|
interface AvroQueryClient {
|
|
@@ -530,7 +532,7 @@ export declare function matchesBillsListQuery(queryKey: readonly unknown[], item
|
|
|
530
532
|
export declare function matchesJobsListQuery(queryKey: readonly unknown[], item: any): ListQueryMatch;
|
|
531
533
|
export declare function matchesRoutesListQuery(queryKey: readonly unknown[], _item: any): ListQueryMatch;
|
|
532
534
|
export declare class AvroQueryClient {
|
|
533
|
-
protected config: Required<AvroQueryClientConfig>;
|
|
535
|
+
protected config: Required<Omit<AvroQueryClientConfig, 'clientId' | 'clientVersion'>> & Pick<AvroQueryClientConfig, 'clientId' | 'clientVersion'>;
|
|
534
536
|
readonly socket: Socket;
|
|
535
537
|
_authState: AuthState;
|
|
536
538
|
companyId: string | undefined;
|
|
@@ -321,6 +321,8 @@ export class AvroQueryClient {
|
|
|
321
321
|
maxRetries: config.maxRetries ?? 3,
|
|
322
322
|
retryStrategy: config.retryStrategy ?? 'fixed',
|
|
323
323
|
timeout: config.timeout ?? 0,
|
|
324
|
+
clientId: config.clientId,
|
|
325
|
+
clientVersion: config.clientVersion,
|
|
324
326
|
};
|
|
325
327
|
this.socket = io(config.baseUrl, {
|
|
326
328
|
autoConnect: false,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
2
2
|
import { StandardError } from '../../types/error';
|
|
3
3
|
import { AuthState } from '../../types/auth';
|
|
4
|
+
import { AVRO_JS_VERSION } from '../../version';
|
|
4
5
|
AvroQueryClient.prototype._fetch = async function (method, path, body, cancelToken, headers = {}, isIdempotent = false, retryCount = 0) {
|
|
5
6
|
const checkCancelled = () => {
|
|
6
7
|
try {
|
|
@@ -21,6 +22,11 @@ AvroQueryClient.prototype._fetch = async function (method, path, body, cancelTok
|
|
|
21
22
|
const url = this.config.baseUrl + path;
|
|
22
23
|
const requestHeaders = {
|
|
23
24
|
Authorization: `Bearer ${token}`,
|
|
25
|
+
'X-Avro-Js-Version': AVRO_JS_VERSION,
|
|
26
|
+
...(this.config.clientId ? { 'X-Avro-Client-Id': this.config.clientId } : {}),
|
|
27
|
+
...(this.config.clientVersion
|
|
28
|
+
? { 'X-Avro-Client-Version': this.config.clientVersion }
|
|
29
|
+
: {}),
|
|
24
30
|
...headers,
|
|
25
31
|
};
|
|
26
32
|
const options = {
|
package/dist/client/core/xhr.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AvroQueryClient } from '../../client/QueryClient';
|
|
2
2
|
import { StandardError } from '../../types/error';
|
|
3
3
|
import { AuthState } from '../../types/auth';
|
|
4
|
+
import { AVRO_JS_VERSION } from '../../version';
|
|
4
5
|
AvroQueryClient.prototype._xhr = async function (method, path, body, cancelToken, headers = {}, isIdempotent = false, retryCount = 0, progressUpdateCallback) {
|
|
5
6
|
const checkCancelled = () => {
|
|
6
7
|
if (cancelToken?.isCancelled()) {
|
|
@@ -20,6 +21,13 @@ AvroQueryClient.prototype._xhr = async function (method, path, body, cancelToken
|
|
|
20
21
|
xhr.open(method, url, true);
|
|
21
22
|
if (token)
|
|
22
23
|
xhr.setRequestHeader('Authorization', `Bearer ${token}`);
|
|
24
|
+
xhr.setRequestHeader('X-Avro-Js-Version', AVRO_JS_VERSION);
|
|
25
|
+
if (this.config.clientId) {
|
|
26
|
+
xhr.setRequestHeader('X-Avro-Client-Id', this.config.clientId);
|
|
27
|
+
}
|
|
28
|
+
if (this.config.clientVersion) {
|
|
29
|
+
xhr.setRequestHeader('X-Avro-Client-Version', this.config.clientVersion);
|
|
30
|
+
}
|
|
23
31
|
Object.entries(headers).forEach(([key, value]) => xhr.setRequestHeader(key, value));
|
|
24
32
|
xhr.onload = () => {
|
|
25
33
|
if (xhr.status >= 200 && xhr.status < 300) {
|
package/dist/types/client.d.ts
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const AVRO_JS_VERSION = "0.0.57";
|
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@go-avro/avro-js",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.57",
|
|
4
4
|
"description": "JS client for Avro backend integration.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
|
+
"prebuild": "node scripts/gen-version.js",
|
|
8
9
|
"build": "tsc && tsc-alias",
|
|
9
10
|
"format": "prettier --write \"src/**/*.{ts,tsx,js,jsx,json,md,yaml,yml}\"",
|
|
11
|
+
"prelint": "node scripts/gen-version.js",
|
|
10
12
|
"lint": "eslint src && prettier --check \"src/**/*.{ts,tsx,js,jsx,json,md,yaml,yml}\" && tsc --noEmit",
|
|
11
13
|
"test": "jest",
|
|
12
14
|
"prepublishOnly": "npm run lint && npm run build"
|
|
@@ -42,9 +44,11 @@
|
|
|
42
44
|
"eslint-plugin-jsx-a11y": "^6.10.2",
|
|
43
45
|
"eslint-plugin-react": "^7.37.5",
|
|
44
46
|
"prettier": "^3.8.3",
|
|
45
|
-
"tsc-alias": "^1.8.
|
|
47
|
+
"tsc-alias": "^1.8.17",
|
|
46
48
|
"typescript": "^5.8.3",
|
|
47
|
-
"typescript-eslint": "^8.38.0"
|
|
49
|
+
"typescript-eslint": "^8.38.0",
|
|
50
|
+
"@eslint/js": "^9.39.4",
|
|
51
|
+
"globals": "^17.6.0"
|
|
48
52
|
},
|
|
49
53
|
"files": [
|
|
50
54
|
"dist"
|