@go-avro/avro-js 1.6.3 → 1.6.4
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.
- package/dist/client/QueryClient.d.ts +6 -1
- package/dist/client/hooks/users.js +29 -0
- package/dist/types/api/UserMerge.d.ts +18 -0
- package/dist/types/api/UserMerge.js +1 -0
- package/dist/types/api.d.ts +1 -0
- package/dist/types/api.js +1 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -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.js';
|
|
4
|
-
import { _Event, ActiveSessionSummary, AddressFeatureCollection, ApiInfo, Avro, StorageAnalytics, ClientErrorReport, ErrorLogEntry, PerformanceMetrics, AuditLogEntry, AuditQueryParams, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Break, Chat, CheckIn, Company, DelayEventCreatePayload, EventUpdatePayload, LineItemType, FinancialInsightData, RevenueInsightData, Job, JobUpdate, EventInsightData, AppleLoginResult, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, Skill, Group, Label, RouteScheduleConfig, RouteWritePayload, CatalogItem, Device, DeviceInfo, LocationServicesStatus, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api.js';
|
|
4
|
+
import { _Event, ActiveSessionSummary, AddressFeatureCollection, ApiInfo, Avro, StorageAnalytics, ClientErrorReport, ErrorLogEntry, PerformanceMetrics, AuditLogEntry, AuditQueryParams, Bill, BillInsightData, BillLineItemStatusUpdate, BillStatus, Break, Chat, CheckIn, Company, DelayEventCreatePayload, EventUpdatePayload, LineItemType, FinancialInsightData, RevenueInsightData, Job, JobUpdate, EventInsightData, AppleLoginResult, LoginResponse, Message, Plan, Route, ServiceMonth, Session, Team, User, UserCompanyAssociation, UserMergeSummary, Skill, Group, Label, RouteScheduleConfig, RouteWritePayload, CatalogItem, Device, DeviceInfo, LocationServicesStatus, Payout, Prepayment, Timecard, TimecardActionType, TimecardStatus } from '../types/api.js';
|
|
5
5
|
import { AuthState, Tokens } from '../types/auth.js';
|
|
6
6
|
import { CancelToken, ClientId, RetryStrategy } from '../types/client.js';
|
|
7
7
|
import { StandardError } from '../types/error.js';
|
|
@@ -277,6 +277,11 @@ declare module './QueryClient.js' {
|
|
|
277
277
|
cleared: number;
|
|
278
278
|
}, StandardError, void>>;
|
|
279
279
|
useSearchUsers(searchUsername: string): UseQueryResult<User[], StandardError>;
|
|
280
|
+
useMergeUsersPreview(keepId: string, duplicateId: string): UseQueryResult<UserMergeSummary, StandardError>;
|
|
281
|
+
useMergeUsers(): ReturnType<typeof useMutation<UserMergeSummary, StandardError, {
|
|
282
|
+
keepId: string;
|
|
283
|
+
duplicateId: string;
|
|
284
|
+
}>>;
|
|
280
285
|
useReviewProposal(proposal_id: string): ReturnType<typeof useMutation<{
|
|
281
286
|
msg: string;
|
|
282
287
|
bill_id?: string;
|
|
@@ -20,6 +20,35 @@ AvroQueryClient.prototype.useSearchUsers = function (searchUsername) {
|
|
|
20
20
|
enabled: Boolean(searchUsername),
|
|
21
21
|
});
|
|
22
22
|
};
|
|
23
|
+
/** Root only: what merging `duplicateId` into `keepId` would move. Changes nothing. */
|
|
24
|
+
AvroQueryClient.prototype.useMergeUsersPreview = function (keepId, duplicateId) {
|
|
25
|
+
return useQuery({
|
|
26
|
+
queryKey: ['users', 'merge', keepId, duplicateId],
|
|
27
|
+
queryFn: () => this.post({
|
|
28
|
+
path: `/user/${keepId}/merge`,
|
|
29
|
+
data: JSON.stringify({ duplicate: duplicateId, dry_run: true }),
|
|
30
|
+
headers: { 'Content-Type': 'application/json' },
|
|
31
|
+
idempotent: true,
|
|
32
|
+
}),
|
|
33
|
+
enabled: Boolean(keepId && duplicateId),
|
|
34
|
+
// A refusal (same account, root user) won't change on retry.
|
|
35
|
+
retry: false,
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
/** Root only: merge `duplicateId` into `keepId`, then delete the duplicate. */
|
|
39
|
+
AvroQueryClient.prototype.useMergeUsers = function () {
|
|
40
|
+
const queryClient = this.getQueryClient();
|
|
41
|
+
return useMutation({
|
|
42
|
+
mutationFn: ({ keepId, duplicateId }) => this.post({
|
|
43
|
+
path: `/user/${keepId}/merge`,
|
|
44
|
+
data: JSON.stringify({ duplicate: duplicateId, dry_run: false }),
|
|
45
|
+
headers: { 'Content-Type': 'application/json' },
|
|
46
|
+
}),
|
|
47
|
+
onSuccess: () => {
|
|
48
|
+
queryClient.invalidateQueries({ queryKey: ['users'] });
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
};
|
|
23
52
|
AvroQueryClient.prototype.useGetSelf = function () {
|
|
24
53
|
return useQuery({
|
|
25
54
|
queryKey: ['user'],
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What merging a duplicate account into another moves (`POST
|
|
3
|
+
* /user/{keepId}/merge`). The same shape answers the dry-run preview.
|
|
4
|
+
*/
|
|
5
|
+
export interface UserMergeSummary {
|
|
6
|
+
msg: string;
|
|
7
|
+
/** Rows moved per table, keyed by table name; tables with none are left out. */
|
|
8
|
+
rows: Record<string, number>;
|
|
9
|
+
/** Companies only the duplicate belonged to; the kept account joins them. */
|
|
10
|
+
companies_moved: string[];
|
|
11
|
+
/** Companies both belonged to; the duplicate's membership is folded in. */
|
|
12
|
+
companies_folded: string[];
|
|
13
|
+
/** Saved payment methods removed with the duplicate's Stripe customer. */
|
|
14
|
+
payment_methods_dropped: number;
|
|
15
|
+
/** `moved` to the kept account, or `revoked` because it already has one. */
|
|
16
|
+
apple_identity: 'moved' | 'revoked' | null;
|
|
17
|
+
microsoft_identity_moved: boolean;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/types/api.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ export * from './api/_Event.js';
|
|
|
5
5
|
export * from './api/AdditionalCharge.js';
|
|
6
6
|
export * from './api/DelayEvent.js';
|
|
7
7
|
export * from './api/Device.js';
|
|
8
|
+
export * from './api/UserMerge.js';
|
|
8
9
|
export * from './api/Address.js';
|
|
9
10
|
export * from './api/Avro.js';
|
|
10
11
|
export * from './api/AuditLog.js';
|
package/dist/types/api.js
CHANGED
|
@@ -2,6 +2,7 @@ export * from './api/_Event.js';
|
|
|
2
2
|
export * from './api/AdditionalCharge.js';
|
|
3
3
|
export * from './api/DelayEvent.js';
|
|
4
4
|
export * from './api/Device.js';
|
|
5
|
+
export * from './api/UserMerge.js';
|
|
5
6
|
export * from './api/Address.js';
|
|
6
7
|
export * from './api/Avro.js';
|
|
7
8
|
export * from './api/AuditLog.js';
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const AVRO_JS_VERSION = "1.6.
|
|
1
|
+
export declare const AVRO_JS_VERSION = "1.6.4";
|
package/dist/version.js
CHANGED