@go-avro/avro-js 0.0.2-beta.166 → 0.0.2-beta.168

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.
@@ -20,7 +20,7 @@ declare module '../client/QueryClient' {
20
20
  getDelay(strategy: RetryStrategy, attempt: number): number;
21
21
  sleep(ms: number): Promise<void>;
22
22
  useGetRoot(): UseQueryResult<ApiInfo, StandardError>;
23
- useGetJobs(params: {
23
+ useGetJobs(params?: {
24
24
  companyId?: string;
25
25
  numJobs?: number;
26
26
  onProgress?: (fraction: number) => void;
@@ -4,7 +4,7 @@ AvroQueryClient.prototype.useCreateCatalogItem = function () {
4
4
  const queryClient = this.getQueryClient();
5
5
  return useMutation({
6
6
  mutationFn: async ({ data }) => {
7
- return this.post(`/company/${this.companyId}/catalog`, JSON.stringify(data), undefined, { 'Content-Type': 'application/json' });
7
+ return this.post(`/company/${this.companyId}/catalog_item`, JSON.stringify(data), undefined, { 'Content-Type': 'application/json' });
8
8
  },
9
9
  onMutate: async () => {
10
10
  await queryClient.cancelQueries({ queryKey: ['catalog_items', this.companyId] });
@@ -9,19 +9,19 @@ AvroQueryClient.prototype.getJobsFromCache = function (queryClient) {
9
9
  AvroQueryClient.prototype.useGetJobs = function (params) {
10
10
  const queryClient = this.getQueryClient();
11
11
  const amt = 50;
12
- const company_id = params.companyId ?? this.companyId;
13
- const num_jobs = params.numJobs ?? this.company?.num_jobs ?? 0;
12
+ const company_id = params?.companyId ?? this.companyId;
13
+ const num_jobs = params?.numJobs ?? this.company?.num_jobs ?? 0;
14
14
  return useQuery({
15
15
  queryKey: ['jobs', company_id, num_jobs],
16
16
  queryFn: async () => {
17
- params.onProgress?.(0);
17
+ params?.onProgress?.(0);
18
18
  const pageCount = amt ? Math.ceil((num_jobs ?? 0) / amt) + 1 : 1;
19
19
  let completed = 0;
20
20
  const promises = Array.from({ length: pageCount }, (_, i) => this.fetchJobs({ offset: i * (amt ?? 1), amt }, company_id));
21
21
  const trackedPromises = promises.map((promise) => promise.then((result) => {
22
22
  completed++;
23
23
  const fraction = completed / pageCount;
24
- params.onProgress?.(fraction);
24
+ params?.onProgress?.(fraction);
25
25
  return result;
26
26
  }));
27
27
  const pages = await Promise.all(trackedPromises);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@go-avro/avro-js",
3
- "version": "0.0.2-beta.166",
3
+ "version": "0.0.2-beta.168",
4
4
  "description": "JS client for Avro backend integration.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",