@anzusystems/common-admin 1.47.0-beta.dev-1789897769 → 1.47.0-beta.dev-1789936376

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/labs.d.ts CHANGED
@@ -1156,9 +1156,11 @@ declare type FetchItemsMinimalType = (pagination: Ref<Pagination>, filterData: F
1156
1156
 
1157
1157
  declare type FetchItemsMinimalType_2 = (pagination: Ref<Pagination>, filterData: FilterData, filterConfig: FilterConfig) => Promise<any[]>;
1158
1158
 
1159
- export declare type FetchItemsParams = {
1159
+ export declare type FetchItemsParams<B = never> = {
1160
1160
  urlTemplate?: string;
1161
1161
  urlParams?: UrlParams;
1162
+ /** `null` omits the body, as everywhere in this family. */
1163
+ body?: B;
1162
1164
  /** Stops this one call, leaving the instance's other calls alone. */
1163
1165
  signal?: AbortSignal;
1164
1166
  };
@@ -1296,6 +1298,9 @@ export declare const isLogType: (value: unknown) => value is LogTypeType;
1296
1298
  /** Whether `router.push({ hash })` would leave the hash intact — see `buildFilterHash`. */
1297
1299
  export declare const isRouterSafeHash: (hash: string) => boolean;
1298
1300
 
1301
+ /** Which of the two shapes a list arrives in. */
1302
+ export declare type ItemsShape = 'envelope' | 'array';
1303
+
1299
1304
  declare const JOB_RESOURCE_USER_DATA_DELETE = "jobUserDataDelete";
1300
1305
 
1301
1306
  declare interface JobBase<T extends JobBaseResource = JobBaseResource> extends AnzuUserAndTimeTrackingAware {
@@ -2581,16 +2586,28 @@ export declare type UseApiFetchByIdsReturnType<T> = {
2581
2586
  /**
2582
2587
  * True while this instance has a request in flight, false once the last one settles.
2583
2588
  *
2584
- * It is here so a caller does not have to keep its own: the hand-rolled version is a ref cleared
2585
- * in a `finally`, and that `finally` belongs to whichever call ended -- including one that
2589
+ * It is here so a caller does not have to keep its own: the hand-rolled version is a ref cleared in
2590
+ * a `finally`, and that `finally` belongs to whichever call ended -- including one that
2586
2591
  * `cancelPrevious` just superseded, which turns the spinner off while the call the user is waiting
2587
2592
  * for is still running. This one never dips between a superseded call and the one that replaced it.
2593
+ *
2594
+ * Two things to know before replacing a hand-rolled flag with it.
2595
+ *
2596
+ * It covers what this helper does and nothing the caller does afterwards. A flag that also spans a
2597
+ * follow-up cached fetch, a mapping pass or a second endpoint is not the same flag, and swapping it
2598
+ * for this one turns the spinner off too early. Keep your own where it means more than "this helper
2599
+ * is working".
2600
+ *
2601
+ * It belongs to the instance, so it is only reachable if you hold the instance. A factory that
2602
+ * builds one per call and hands back the promise alone -- `const { execute } = useX()` inside the
2603
+ * function that calls it -- cannot expose `loading`, `abort` or `cancelPrevious` at all. Hoist the
2604
+ * instance to where the caller lives first.
2588
2605
  */
2589
2606
  loading: Ref<boolean>;
2590
2607
  };
2591
2608
 
2592
2609
  /**
2593
- * A list read from an endpoint the caller has already written the query for, with no pagination.
2610
+ * A list from an endpoint the caller has already written the query for, with no pagination.
2594
2611
  *
2595
2612
  * It exists because the fleet kept doing this through `useApiRequest<ApiResponseList<T[]>>`: build a
2596
2613
  * query by hand -- an order, a limit, a fixed filter -- bake it into the url, and read `.data` off
@@ -2603,10 +2620,18 @@ export declare type UseApiFetchByIdsReturnType<T> = {
2603
2620
  * not the user's to change. So this is that helper with the pagination taken out: same core, same
2604
2621
  * error mapping, same list-body check, and it answers with the items rather than the envelope.
2605
2622
  *
2623
+ * Read is the usual case, not the only one: a filter too big for a url goes out as a POST, and a
2624
+ * mutation can answer with the list it just changed. The helper is about what comes back.
2625
+ *
2626
+ * Which shape it comes back in is declared, not guessed. `shape` picks the reader and the reader
2627
+ * refuses the other shape, the way `optionalBody` makes a caller declare a body instead of leaving
2628
+ * the helper to accept whatever turns up. A wrong declaration therefore fails loudly on the first
2629
+ * run, which is what makes having a default safe at all.
2630
+ *
2606
2631
  * It writes no metadata. An endpoint whose paging the user drives is `useApiFetchList`; a list read
2607
2632
  * page by page to the end is `useApiFetchListBatch`.
2608
2633
  */
2609
- export declare const useApiFetchItems: <T>(params: UseApiFetchItemsParams) => UseApiFetchItemsReturnType<T>;
2634
+ export declare const useApiFetchItems: <T, B = never>(params: UseApiFetchItemsParams) => UseApiFetchItemsReturnType<T, B>;
2610
2635
 
2611
2636
  export declare type UseApiFetchItemsParams = {
2612
2637
  client: AxiosClientFn;
@@ -2625,18 +2650,45 @@ export declare type UseApiFetchItemsParams = {
2625
2650
  /** Anything axios takes except what this helper decides: the method, the url, the body and the signal. */
2626
2651
  options?: Omit<AxiosRequestConfig, 'method' | 'url' | 'data' | 'signal'>;
2627
2652
  cancelPrevious?: boolean;
2653
+ /**
2654
+ * Default `GET`, which is what 17 of the fleet's list reads and every existing caller here use.
2655
+ *
2656
+ * The others are here because a list is not only ever the answer to a read: a filter too big for a
2657
+ * url goes out as a POST, and a mutation can answer with the list it just changed -- a swap, a
2658
+ * shift, an upsert-all. What this helper is about is the answer, not the verb.
2659
+ */
2660
+ method?: 'GET' | 'POST' | 'PUT' | 'PATCH';
2661
+ /**
2662
+ * Default `'envelope'`, because that is the fleet's norm and the exception is what gets declared.
2663
+ *
2664
+ * Leaving it out cannot go wrong quietly: the reader refuses the shape that was not declared, so a
2665
+ * forgotten `'array'` fails on the first run rather than handing back something that is not a list.
2666
+ */
2667
+ shape?: ItemsShape;
2628
2668
  };
2629
2669
 
2630
- export declare type UseApiFetchItemsReturnType<T> = {
2631
- execute: (params?: FetchItemsParams) => Promise<T[]>;
2670
+ export declare type UseApiFetchItemsReturnType<T, B = never> = {
2671
+ execute: (params?: FetchItemsParams<B>) => Promise<T[]>;
2632
2672
  abort: () => void;
2633
2673
  /**
2634
2674
  * True while this instance has a request in flight, false once the last one settles.
2635
2675
  *
2636
- * It is here so a caller does not have to keep its own: the hand-rolled version is a ref cleared
2637
- * in a `finally`, and that `finally` belongs to whichever call ended -- including one that
2676
+ * It is here so a caller does not have to keep its own: the hand-rolled version is a ref cleared in
2677
+ * a `finally`, and that `finally` belongs to whichever call ended -- including one that
2638
2678
  * `cancelPrevious` just superseded, which turns the spinner off while the call the user is waiting
2639
2679
  * for is still running. This one never dips between a superseded call and the one that replaced it.
2680
+ *
2681
+ * Two things to know before replacing a hand-rolled flag with it.
2682
+ *
2683
+ * It covers what this helper does and nothing the caller does afterwards. A flag that also spans a
2684
+ * follow-up cached fetch, a mapping pass or a second endpoint is not the same flag, and swapping it
2685
+ * for this one turns the spinner off too early. Keep your own where it means more than "this helper
2686
+ * is working".
2687
+ *
2688
+ * It belongs to the instance, so it is only reachable if you hold the instance. A factory that
2689
+ * builds one per call and hands back the promise alone -- `const { execute } = useX()` inside the
2690
+ * function that calls it -- cannot expose `loading`, `abort` or `cancelPrevious` at all. Hoist the
2691
+ * instance to where the caller lives first.
2640
2692
  */
2641
2693
  loading: Ref<boolean>;
2642
2694
  };
@@ -2660,12 +2712,27 @@ export declare type UseApiFetchListBatchReturnType<T> = {
2660
2712
  execute: (filterData: FilterData<any>, filterConfig: FilterConfig<any>, params?: FetchListBatchParams) => Promise<T[]>;
2661
2713
  abort: () => void;
2662
2714
  /**
2663
- * True while this instance has a request in flight, false once the last one settles.
2715
+ * True while this instance is working, false once it stops.
2716
+ *
2717
+ * Here that is the whole walk, not one request: a batch reads every page, and the flag stays up
2718
+ * across the gaps between them and across the reading of each answer.
2664
2719
  *
2665
- * It is here so a caller does not have to keep its own: the hand-rolled version is a ref cleared
2666
- * in a `finally`, and that `finally` belongs to whichever call ended -- including one that
2720
+ * It is here so a caller does not have to keep its own: the hand-rolled version is a ref cleared in
2721
+ * a `finally`, and that `finally` belongs to whichever call ended -- including one that
2667
2722
  * `cancelPrevious` just superseded, which turns the spinner off while the call the user is waiting
2668
2723
  * for is still running. This one never dips between a superseded call and the one that replaced it.
2724
+ *
2725
+ * Two things to know before replacing a hand-rolled flag with it.
2726
+ *
2727
+ * It covers what this helper does and nothing the caller does afterwards. A flag that also spans a
2728
+ * follow-up cached fetch, a mapping pass or a second endpoint is not the same flag, and swapping it
2729
+ * for this one turns the spinner off too early. Keep your own where it means more than "this helper
2730
+ * is working".
2731
+ *
2732
+ * It belongs to the instance, so it is only reachable if you hold the instance. A factory that
2733
+ * builds one per call and hands back the promise alone -- `const { execute } = useX()` inside the
2734
+ * function that calls it -- cannot expose `loading`, `abort` or `cancelPrevious` at all. Hoist the
2735
+ * instance to where the caller lives first.
2669
2736
  */
2670
2737
  loading: Ref<boolean>;
2671
2738
  };
@@ -2687,10 +2754,22 @@ export declare type UseApiFetchListReturnType<T> = {
2687
2754
  /**
2688
2755
  * True while this instance has a request in flight, false once the last one settles.
2689
2756
  *
2690
- * It is here so a caller does not have to keep its own: the hand-rolled version is a ref cleared
2691
- * in a `finally`, and that `finally` belongs to whichever call ended -- including one that
2757
+ * It is here so a caller does not have to keep its own: the hand-rolled version is a ref cleared in
2758
+ * a `finally`, and that `finally` belongs to whichever call ended -- including one that
2692
2759
  * `cancelPrevious` just superseded, which turns the spinner off while the call the user is waiting
2693
2760
  * for is still running. This one never dips between a superseded call and the one that replaced it.
2761
+ *
2762
+ * Two things to know before replacing a hand-rolled flag with it.
2763
+ *
2764
+ * It covers what this helper does and nothing the caller does afterwards. A flag that also spans a
2765
+ * follow-up cached fetch, a mapping pass or a second endpoint is not the same flag, and swapping it
2766
+ * for this one turns the spinner off too early. Keep your own where it means more than "this helper
2767
+ * is working".
2768
+ *
2769
+ * It belongs to the instance, so it is only reachable if you hold the instance. A factory that
2770
+ * builds one per call and hands back the promise alone -- `const { execute } = useX()` inside the
2771
+ * function that calls it -- cannot expose `loading`, `abort` or `cancelPrevious` at all. Hoist the
2772
+ * instance to where the caller lives first.
2694
2773
  */
2695
2774
  loading: Ref<boolean>;
2696
2775
  };
@@ -2755,10 +2834,22 @@ export declare type UseApiRequestReturnType<R, B> = {
2755
2834
  /**
2756
2835
  * True while this instance has a request in flight, false once the last one settles.
2757
2836
  *
2758
- * It is here so a caller does not have to keep its own: the hand-rolled version is a ref cleared
2759
- * in a `finally`, and that `finally` belongs to whichever call ended -- including one that
2837
+ * It is here so a caller does not have to keep its own: the hand-rolled version is a ref cleared in
2838
+ * a `finally`, and that `finally` belongs to whichever call ended -- including one that
2760
2839
  * `cancelPrevious` just superseded, which turns the spinner off while the call the user is waiting
2761
2840
  * for is still running. This one never dips between a superseded call and the one that replaced it.
2841
+ *
2842
+ * Two things to know before replacing a hand-rolled flag with it.
2843
+ *
2844
+ * It covers what this helper does and nothing the caller does afterwards. A flag that also spans a
2845
+ * follow-up cached fetch, a mapping pass or a second endpoint is not the same flag, and swapping it
2846
+ * for this one turns the spinner off too early. Keep your own where it means more than "this helper
2847
+ * is working".
2848
+ *
2849
+ * It belongs to the instance, so it is only reachable if you hold the instance. A factory that
2850
+ * builds one per call and hands back the promise alone -- `const { execute } = useX()` inside the
2851
+ * function that calls it -- cannot expose `loading`, `abort` or `cancelPrevious` at all. Hoist the
2852
+ * instance to where the caller lives first.
2762
2853
  */
2763
2854
  loading: Ref<boolean>;
2764
2855
  };