@procore/saved-views 1.1.0-alpha.0 → 1.1.0-alpha.1

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.
@@ -11503,7 +11503,7 @@ var useApiRequest = (props, method, mutationKey) => {
11503
11503
  const queryClient2 = (0, import_react_query.useQueryClient)();
11504
11504
  const { locale: locale2 } = (0, import_core_react5.useI18nContext)();
11505
11505
  const basePath = getBasePath(companyId, projectId);
11506
- const queryKeyContext = projectId ?? companyId;
11506
+ const queryKey = ["savedViews", domain, tableName, companyId, projectId];
11507
11507
  return (0, import_react_query.useMutation)({
11508
11508
  mutationKey,
11509
11509
  mutationFn: async (savedView) => {
@@ -11529,36 +11529,28 @@ var useApiRequest = (props, method, mutationKey) => {
11529
11529
  onSuccess: (savedView) => {
11530
11530
  if (method === "DELETE" || method === "POST") {
11531
11531
  queryClient2.invalidateQueries({
11532
- queryKey: ["savedViews", domain, tableName, queryKeyContext]
11532
+ queryKey
11533
11533
  });
11534
11534
  return;
11535
11535
  } else {
11536
- const oldData = queryClient2.getQueryData([
11537
- "savedViews",
11538
- domain,
11539
- tableName,
11540
- queryKeyContext
11541
- ]);
11536
+ const oldData = queryClient2.getQueryData(queryKey);
11542
11537
  const oldView = oldData == null ? void 0 : oldData.find(
11543
11538
  (item) => item.share_token === savedView.share_token
11544
11539
  );
11545
11540
  if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
11546
11541
  queryClient2.invalidateQueries({
11547
- queryKey: ["savedViews", domain, tableName, queryKeyContext]
11542
+ queryKey
11548
11543
  });
11549
11544
  return;
11550
11545
  }
11551
11546
  }
11552
- queryClient2.setQueryData(
11553
- ["savedViews", domain, tableName, queryKeyContext],
11554
- (oldData) => {
11555
- if (!oldData)
11556
- return [savedView];
11557
- return oldData.map(
11558
- (item) => item.share_token === savedView.share_token ? savedView : item
11559
- );
11560
- }
11561
- );
11547
+ queryClient2.setQueryData(queryKey, (oldData) => {
11548
+ if (!oldData)
11549
+ return [savedView];
11550
+ return oldData.map(
11551
+ (item) => item.share_token === savedView.share_token ? savedView : item
11552
+ );
11553
+ });
11562
11554
  }
11563
11555
  });
11564
11556
  };
@@ -11585,7 +11577,7 @@ var useSavedViewsQuery = (props) => {
11585
11577
  const basePath = getBasePath2(companyId, projectId);
11586
11578
  const url = `${basePath}?table_name=${tableName}&permissions_domain=${domain}`;
11587
11579
  return (0, import_react_query2.useQuery)({
11588
- queryKey: ["savedViews", domain, tableName, projectId ?? companyId],
11580
+ queryKey: ["savedViews", domain, tableName, companyId, projectId],
11589
11581
  queryFn: async () => {
11590
11582
  const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
11591
11583
  const response = await requestJSON(getUrl2);
@@ -11598,7 +11590,7 @@ var useSavedViewsPermissions = (props) => {
11598
11590
  const basePath = getBasePath2(companyId, projectId);
11599
11591
  const url = `${basePath}/permissions?permissions_domain=${domain}`;
11600
11592
  return (0, import_react_query2.useQuery)({
11601
- queryKey: ["savedViewsConfig", domain, projectId ?? companyId],
11593
+ queryKey: ["savedViewsConfig", domain, companyId, projectId],
11602
11594
  queryFn: async () => {
11603
11595
  const response = await requestJSON(url);
11604
11596
  return response.data;
@@ -11625,7 +11617,7 @@ var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
11625
11617
  const basePath = getBasePath2(companyId, projectId);
11626
11618
  return (0, import_react_query2.useQuery)({
11627
11619
  enabled: enabled && Boolean(savedViewToken),
11628
- queryKey: ["savedView", savedViewToken, projectId ?? companyId],
11620
+ queryKey: ["savedView", savedViewToken, companyId, projectId],
11629
11621
  queryFn: async () => {
11630
11622
  const url = `${basePath}/${savedViewToken}?permissions_domain=${domain}`;
11631
11623
  const response = await requestJSON(url);
@@ -14921,7 +14913,7 @@ var SavedViewsContent = (props) => {
14921
14913
  const queryInput = {
14922
14914
  domain: props.domain,
14923
14915
  tableName: props.tableName,
14924
- projectId: projectId ?? void 0,
14916
+ projectId,
14925
14917
  companyId
14926
14918
  };
14927
14919
  const { data: savedViews } = useSavedViewsQuery(queryInput);
@@ -14953,7 +14945,7 @@ var SavedViewsContent = (props) => {
14953
14945
  domain: props.domain,
14954
14946
  tableName: props.tableName,
14955
14947
  userId: props.userId,
14956
- projectId: projectId ?? void 0,
14948
+ projectId,
14957
14949
  companyId,
14958
14950
  defaultView: props.defaultView,
14959
14951
  onSelect: props.onSelect
@@ -11499,7 +11499,7 @@ var useApiRequest = (props, method, mutationKey) => {
11499
11499
  const queryClient2 = useQueryClient();
11500
11500
  const { locale: locale2 } = useI18nContext3();
11501
11501
  const basePath = getBasePath(companyId, projectId);
11502
- const queryKeyContext = projectId ?? companyId;
11502
+ const queryKey = ["savedViews", domain, tableName, companyId, projectId];
11503
11503
  return useMutation({
11504
11504
  mutationKey,
11505
11505
  mutationFn: async (savedView) => {
@@ -11525,36 +11525,28 @@ var useApiRequest = (props, method, mutationKey) => {
11525
11525
  onSuccess: (savedView) => {
11526
11526
  if (method === "DELETE" || method === "POST") {
11527
11527
  queryClient2.invalidateQueries({
11528
- queryKey: ["savedViews", domain, tableName, queryKeyContext]
11528
+ queryKey
11529
11529
  });
11530
11530
  return;
11531
11531
  } else {
11532
- const oldData = queryClient2.getQueryData([
11533
- "savedViews",
11534
- domain,
11535
- tableName,
11536
- queryKeyContext
11537
- ]);
11532
+ const oldData = queryClient2.getQueryData(queryKey);
11538
11533
  const oldView = oldData == null ? void 0 : oldData.find(
11539
11534
  (item) => item.share_token === savedView.share_token
11540
11535
  );
11541
11536
  if ((oldView == null ? void 0 : oldView.name) !== savedView.name) {
11542
11537
  queryClient2.invalidateQueries({
11543
- queryKey: ["savedViews", domain, tableName, queryKeyContext]
11538
+ queryKey
11544
11539
  });
11545
11540
  return;
11546
11541
  }
11547
11542
  }
11548
- queryClient2.setQueryData(
11549
- ["savedViews", domain, tableName, queryKeyContext],
11550
- (oldData) => {
11551
- if (!oldData)
11552
- return [savedView];
11553
- return oldData.map(
11554
- (item) => item.share_token === savedView.share_token ? savedView : item
11555
- );
11556
- }
11557
- );
11543
+ queryClient2.setQueryData(queryKey, (oldData) => {
11544
+ if (!oldData)
11545
+ return [savedView];
11546
+ return oldData.map(
11547
+ (item) => item.share_token === savedView.share_token ? savedView : item
11548
+ );
11549
+ });
11558
11550
  }
11559
11551
  });
11560
11552
  };
@@ -11581,7 +11573,7 @@ var useSavedViewsQuery = (props) => {
11581
11573
  const basePath = getBasePath2(companyId, projectId);
11582
11574
  const url = `${basePath}?table_name=${tableName}&permissions_domain=${domain}`;
11583
11575
  return useQuery({
11584
- queryKey: ["savedViews", domain, tableName, projectId ?? companyId],
11576
+ queryKey: ["savedViews", domain, tableName, companyId, projectId],
11585
11577
  queryFn: async () => {
11586
11578
  const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
11587
11579
  const response = await requestJSON(getUrl2);
@@ -11594,7 +11586,7 @@ var useSavedViewsPermissions = (props) => {
11594
11586
  const basePath = getBasePath2(companyId, projectId);
11595
11587
  const url = `${basePath}/permissions?permissions_domain=${domain}`;
11596
11588
  return useQuery({
11597
- queryKey: ["savedViewsConfig", domain, projectId ?? companyId],
11589
+ queryKey: ["savedViewsConfig", domain, companyId, projectId],
11598
11590
  queryFn: async () => {
11599
11591
  const response = await requestJSON(url);
11600
11592
  return response.data;
@@ -11621,7 +11613,7 @@ var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
11621
11613
  const basePath = getBasePath2(companyId, projectId);
11622
11614
  return useQuery({
11623
11615
  enabled: enabled && Boolean(savedViewToken),
11624
- queryKey: ["savedView", savedViewToken, projectId ?? companyId],
11616
+ queryKey: ["savedView", savedViewToken, companyId, projectId],
11625
11617
  queryFn: async () => {
11626
11618
  const url = `${basePath}/${savedViewToken}?permissions_domain=${domain}`;
11627
11619
  const response = await requestJSON(url);
@@ -14965,7 +14957,7 @@ var SavedViewsContent = (props) => {
14965
14957
  const queryInput = {
14966
14958
  domain: props.domain,
14967
14959
  tableName: props.tableName,
14968
- projectId: projectId ?? void 0,
14960
+ projectId,
14969
14961
  companyId
14970
14962
  };
14971
14963
  const { data: savedViews } = useSavedViewsQuery(queryInput);
@@ -14997,7 +14989,7 @@ var SavedViewsContent = (props) => {
14997
14989
  domain: props.domain,
14998
14990
  tableName: props.tableName,
14999
14991
  userId: props.userId,
15000
- projectId: projectId ?? void 0,
14992
+ projectId,
15001
14993
  companyId,
15002
14994
  defaultView: props.defaultView,
15003
14995
  onSelect: props.onSelect
@@ -11500,7 +11500,7 @@ var useApiRequest = (props, method, mutationKey) => {
11500
11500
  const queryClient2 = (0, import_react_query.useQueryClient)();
11501
11501
  const { locale: locale2 } = (0, import_core_react5.useI18nContext)();
11502
11502
  const basePath = getBasePath(companyId, projectId);
11503
- const queryKeyContext = projectId ?? companyId;
11503
+ const queryKey = ["savedViews", domain, tableName, companyId, projectId];
11504
11504
  return (0, import_react_query.useMutation)({
11505
11505
  mutationKey,
11506
11506
  mutationFn: async (savedView) => {
@@ -11526,36 +11526,28 @@ var useApiRequest = (props, method, mutationKey) => {
11526
11526
  onSuccess: (savedView) => {
11527
11527
  if (method === "DELETE" || method === "POST") {
11528
11528
  queryClient2.invalidateQueries({
11529
- queryKey: ["savedViews", domain, tableName, queryKeyContext]
11529
+ queryKey
11530
11530
  });
11531
11531
  return;
11532
11532
  } else {
11533
- const oldData = queryClient2.getQueryData([
11534
- "savedViews",
11535
- domain,
11536
- tableName,
11537
- queryKeyContext
11538
- ]);
11533
+ const oldData = queryClient2.getQueryData(queryKey);
11539
11534
  const oldView = oldData?.find(
11540
11535
  (item) => item.share_token === savedView.share_token
11541
11536
  );
11542
11537
  if (oldView?.name !== savedView.name) {
11543
11538
  queryClient2.invalidateQueries({
11544
- queryKey: ["savedViews", domain, tableName, queryKeyContext]
11539
+ queryKey
11545
11540
  });
11546
11541
  return;
11547
11542
  }
11548
11543
  }
11549
- queryClient2.setQueryData(
11550
- ["savedViews", domain, tableName, queryKeyContext],
11551
- (oldData) => {
11552
- if (!oldData)
11553
- return [savedView];
11554
- return oldData.map(
11555
- (item) => item.share_token === savedView.share_token ? savedView : item
11556
- );
11557
- }
11558
- );
11544
+ queryClient2.setQueryData(queryKey, (oldData) => {
11545
+ if (!oldData)
11546
+ return [savedView];
11547
+ return oldData.map(
11548
+ (item) => item.share_token === savedView.share_token ? savedView : item
11549
+ );
11550
+ });
11559
11551
  }
11560
11552
  });
11561
11553
  };
@@ -11582,7 +11574,7 @@ var useSavedViewsQuery = (props) => {
11582
11574
  const basePath = getBasePath2(companyId, projectId);
11583
11575
  const url = `${basePath}?table_name=${tableName}&permissions_domain=${domain}`;
11584
11576
  return (0, import_react_query2.useQuery)({
11585
- queryKey: ["savedViews", domain, tableName, projectId ?? companyId],
11577
+ queryKey: ["savedViews", domain, tableName, companyId, projectId],
11586
11578
  queryFn: async () => {
11587
11579
  const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
11588
11580
  const response = await requestJSON(getUrl2);
@@ -11595,7 +11587,7 @@ var useSavedViewsPermissions = (props) => {
11595
11587
  const basePath = getBasePath2(companyId, projectId);
11596
11588
  const url = `${basePath}/permissions?permissions_domain=${domain}`;
11597
11589
  return (0, import_react_query2.useQuery)({
11598
- queryKey: ["savedViewsConfig", domain, projectId ?? companyId],
11590
+ queryKey: ["savedViewsConfig", domain, companyId, projectId],
11599
11591
  queryFn: async () => {
11600
11592
  const response = await requestJSON(url);
11601
11593
  return response.data;
@@ -11622,7 +11614,7 @@ var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
11622
11614
  const basePath = getBasePath2(companyId, projectId);
11623
11615
  return (0, import_react_query2.useQuery)({
11624
11616
  enabled: enabled && Boolean(savedViewToken),
11625
- queryKey: ["savedView", savedViewToken, projectId ?? companyId],
11617
+ queryKey: ["savedView", savedViewToken, companyId, projectId],
11626
11618
  queryFn: async () => {
11627
11619
  const url = `${basePath}/${savedViewToken}?permissions_domain=${domain}`;
11628
11620
  const response = await requestJSON(url);
@@ -14918,7 +14910,7 @@ var SavedViewsContent = (props) => {
14918
14910
  const queryInput = {
14919
14911
  domain: props.domain,
14920
14912
  tableName: props.tableName,
14921
- projectId: projectId ?? void 0,
14913
+ projectId,
14922
14914
  companyId
14923
14915
  };
14924
14916
  const { data: savedViews } = useSavedViewsQuery(queryInput);
@@ -14950,7 +14942,7 @@ var SavedViewsContent = (props) => {
14950
14942
  domain: props.domain,
14951
14943
  tableName: props.tableName,
14952
14944
  userId: props.userId,
14953
- projectId: projectId ?? void 0,
14945
+ projectId,
14954
14946
  companyId,
14955
14947
  defaultView: props.defaultView,
14956
14948
  onSelect: props.onSelect
@@ -11496,7 +11496,7 @@ var useApiRequest = (props, method, mutationKey) => {
11496
11496
  const queryClient2 = useQueryClient();
11497
11497
  const { locale: locale2 } = useI18nContext3();
11498
11498
  const basePath = getBasePath(companyId, projectId);
11499
- const queryKeyContext = projectId ?? companyId;
11499
+ const queryKey = ["savedViews", domain, tableName, companyId, projectId];
11500
11500
  return useMutation({
11501
11501
  mutationKey,
11502
11502
  mutationFn: async (savedView) => {
@@ -11522,36 +11522,28 @@ var useApiRequest = (props, method, mutationKey) => {
11522
11522
  onSuccess: (savedView) => {
11523
11523
  if (method === "DELETE" || method === "POST") {
11524
11524
  queryClient2.invalidateQueries({
11525
- queryKey: ["savedViews", domain, tableName, queryKeyContext]
11525
+ queryKey
11526
11526
  });
11527
11527
  return;
11528
11528
  } else {
11529
- const oldData = queryClient2.getQueryData([
11530
- "savedViews",
11531
- domain,
11532
- tableName,
11533
- queryKeyContext
11534
- ]);
11529
+ const oldData = queryClient2.getQueryData(queryKey);
11535
11530
  const oldView = oldData?.find(
11536
11531
  (item) => item.share_token === savedView.share_token
11537
11532
  );
11538
11533
  if (oldView?.name !== savedView.name) {
11539
11534
  queryClient2.invalidateQueries({
11540
- queryKey: ["savedViews", domain, tableName, queryKeyContext]
11535
+ queryKey
11541
11536
  });
11542
11537
  return;
11543
11538
  }
11544
11539
  }
11545
- queryClient2.setQueryData(
11546
- ["savedViews", domain, tableName, queryKeyContext],
11547
- (oldData) => {
11548
- if (!oldData)
11549
- return [savedView];
11550
- return oldData.map(
11551
- (item) => item.share_token === savedView.share_token ? savedView : item
11552
- );
11553
- }
11554
- );
11540
+ queryClient2.setQueryData(queryKey, (oldData) => {
11541
+ if (!oldData)
11542
+ return [savedView];
11543
+ return oldData.map(
11544
+ (item) => item.share_token === savedView.share_token ? savedView : item
11545
+ );
11546
+ });
11555
11547
  }
11556
11548
  });
11557
11549
  };
@@ -11578,7 +11570,7 @@ var useSavedViewsQuery = (props) => {
11578
11570
  const basePath = getBasePath2(companyId, projectId);
11579
11571
  const url = `${basePath}?table_name=${tableName}&permissions_domain=${domain}`;
11580
11572
  return useQuery({
11581
- queryKey: ["savedViews", domain, tableName, projectId ?? companyId],
11573
+ queryKey: ["savedViews", domain, tableName, companyId, projectId],
11582
11574
  queryFn: async () => {
11583
11575
  const getUrl2 = `${url}&per_page=${PAGE_SIZE}`;
11584
11576
  const response = await requestJSON(getUrl2);
@@ -11591,7 +11583,7 @@ var useSavedViewsPermissions = (props) => {
11591
11583
  const basePath = getBasePath2(companyId, projectId);
11592
11584
  const url = `${basePath}/permissions?permissions_domain=${domain}`;
11593
11585
  return useQuery({
11594
- queryKey: ["savedViewsConfig", domain, projectId ?? companyId],
11586
+ queryKey: ["savedViewsConfig", domain, companyId, projectId],
11595
11587
  queryFn: async () => {
11596
11588
  const response = await requestJSON(url);
11597
11589
  return response.data;
@@ -11618,7 +11610,7 @@ var useFetchSavedViewById = (savedViewToken, queryInput, enabled = true) => {
11618
11610
  const basePath = getBasePath2(companyId, projectId);
11619
11611
  return useQuery({
11620
11612
  enabled: enabled && Boolean(savedViewToken),
11621
- queryKey: ["savedView", savedViewToken, projectId ?? companyId],
11613
+ queryKey: ["savedView", savedViewToken, companyId, projectId],
11622
11614
  queryFn: async () => {
11623
11615
  const url = `${basePath}/${savedViewToken}?permissions_domain=${domain}`;
11624
11616
  const response = await requestJSON(url);
@@ -14962,7 +14954,7 @@ var SavedViewsContent = (props) => {
14962
14954
  const queryInput = {
14963
14955
  domain: props.domain,
14964
14956
  tableName: props.tableName,
14965
- projectId: projectId ?? void 0,
14957
+ projectId,
14966
14958
  companyId
14967
14959
  };
14968
14960
  const { data: savedViews } = useSavedViewsQuery(queryInput);
@@ -14994,7 +14986,7 @@ var SavedViewsContent = (props) => {
14994
14986
  domain: props.domain,
14995
14987
  tableName: props.tableName,
14996
14988
  userId: props.userId,
14997
- projectId: projectId ?? void 0,
14989
+ projectId,
14998
14990
  companyId,
14999
14991
  defaultView: props.defaultView,
15000
14992
  onSelect: props.onSelect
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@procore/saved-views",
3
- "version": "1.1.0-alpha.0",
3
+ "version": "1.1.0-alpha.1",
4
4
  "description": "Saved Views Component for Data Table",
5
5
  "author": "Procore Technologies, Inc",
6
6
  "repository": {