@go-avro/avro-js 0.0.2-beta.104 → 0.0.2-beta.106

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.
@@ -225,6 +225,12 @@ declare module '../client/QueryClient' {
225
225
  logo: File | null;
226
226
  }>;
227
227
  }>>;
228
+ useRemoveUserCompany(): ReturnType<typeof useMutation<{
229
+ msg: string;
230
+ }, StandardError, {
231
+ companyId: string;
232
+ userId: string;
233
+ }>>;
228
234
  useDeleteEvent(): ReturnType<typeof useMutation<{
229
235
  msg: string;
230
236
  }, StandardError, {
@@ -60,6 +60,37 @@ AvroQueryClient.prototype.useUpdateCompany = function () {
60
60
  },
61
61
  });
62
62
  };
63
+ AvroQueryClient.prototype.useRemoveUserCompany = function () {
64
+ const queryClient = useQueryClient();
65
+ return useMutation({
66
+ mutationFn: async ({ companyId, userId }) => {
67
+ return this.delete(`/company/${companyId}/user/${userId}`);
68
+ },
69
+ onMutate: async ({ companyId, userId }) => {
70
+ await queryClient.cancelQueries({ queryKey: ['company', companyId] });
71
+ const previousCompany = queryClient.getQueryData(['company', companyId]);
72
+ queryClient.setQueryData(['company', companyId], (oldData) => {
73
+ if (!oldData)
74
+ return oldData;
75
+ return {
76
+ ...oldData,
77
+ users: oldData.users.filter((user) => user.id !== userId),
78
+ };
79
+ });
80
+ return { previousCompany };
81
+ },
82
+ onError: (err, variables, context) => {
83
+ const { companyId } = variables;
84
+ if (context?.previousCompany) {
85
+ queryClient.setQueryData(['company', companyId], context.previousCompany);
86
+ }
87
+ },
88
+ onSettled: (_data, _error, variables) => {
89
+ const { companyId } = variables;
90
+ queryClient.invalidateQueries({ queryKey: ['company', companyId] });
91
+ },
92
+ });
93
+ };
63
94
  AvroQueryClient.prototype.useDeleteCompany = function () {
64
95
  const queryClient = useQueryClient();
65
96
  return useMutation({
@@ -142,14 +142,14 @@ AvroQueryClient.prototype.useUpdateEvent = function () {
142
142
  if (previousJob) {
143
143
  const updatedJob = {
144
144
  ...previousJob,
145
- last_event: previousEvent ? { ...previousEvent, ...updates } : previousJob.last_event,
145
+ current_event: previousEvent ? { ...previousEvent, ...updates } : previousJob.current_event,
146
146
  last_completed_event: (updates.time_ended ?? -1) > -1 && previousEvent ? { ...previousEvent, ...updates } : previousJob.last_completed_event,
147
147
  };
148
148
  updatedJob.tasks = previousJob.tasks.map((task) => {
149
149
  if (updates.tasks?.includes(task.id)) {
150
150
  return {
151
151
  ...task,
152
- last_event: previousEvent ? { ...previousEvent, ...updates } : task.last_event,
152
+ current_event: previousEvent ? { ...previousEvent, ...updates } : task.current_event,
153
153
  last_completed_event: (updates.time_ended ?? -1) > -1 ? (previousEvent ? { ...previousEvent, ...updates } : task.last_completed_event) : task.last_completed_event,
154
154
  overdue_time: -task.frequency - task.delay,
155
155
  };
@@ -22,8 +22,8 @@ AvroQueryClient.prototype.useGetJobs = function (body, total = 0, onProgress) {
22
22
  if (result.data) {
23
23
  result.data.pages.forEach((data_page) => {
24
24
  data_page.forEach((job) => {
25
- job.last_event = (job.tasks || []).reduce((latest, task) => {
26
- return task.last_event && (!latest || task.last_event.time_started > (latest.time_started ?? 0)) ? task.last_event : latest;
25
+ job.current_event = (job.tasks || []).reduce((latest, task) => {
26
+ return task.current_event && (!latest || task.current_event.time_started > (latest.time_started ?? 0)) ? task.current_event : latest;
27
27
  }, null);
28
28
  job.last_completed_event = (job.tasks || []).reduce((latest, task) => {
29
29
  return task.last_completed_event && (!latest || task.last_completed_event.time_started > (latest.time_created ?? 0)) ? task.last_completed_event : latest;
@@ -445,7 +445,7 @@ export interface Job {
445
445
  manual_emails: string[][];
446
446
  overdue_time: number;
447
447
  last_completed_event: _Event | null;
448
- last_event: _Event | null;
448
+ current_event: _Event | null;
449
449
  labels: string[];
450
450
  owner: string;
451
451
  }
@@ -467,7 +467,7 @@ export interface Task {
467
467
  overdueness: number | null;
468
468
  overdue_time: number;
469
469
  last_completed_event: _Event | null;
470
- last_event: _Event | null;
470
+ current_event: _Event | null;
471
471
  delay: number;
472
472
  skills: string[];
473
473
  service: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.2-beta.104",
3
+ "version": "0.0.2-beta.106",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",