@diagonal-hq/pages 0.3.3 → 0.3.5
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/index.d.ts +57 -3
- package/dist/index.js +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -206,13 +206,18 @@ export type ResourceSortFieldDescriptor = {
|
|
|
206
206
|
|
|
207
207
|
export type ResourceSortDirection = 1 | -1 | 'asc' | 'desc';
|
|
208
208
|
|
|
209
|
+
export type ResourceSortMap = Record<string, ResourceSortDirection>;
|
|
210
|
+
|
|
211
|
+
export type ResourceSortDescriptorList = (ResourceSortDescriptor | ResourceSortFieldDescriptor)[];
|
|
212
|
+
|
|
209
213
|
export type ResourceSortInput =
|
|
210
214
|
| string
|
|
211
215
|
| string[]
|
|
212
216
|
| ResourceSortDescriptor
|
|
213
217
|
| ResourceSortFieldDescriptor
|
|
214
|
-
|
|
|
215
|
-
|
|
|
218
|
+
| ResourceSortDescriptorList
|
|
219
|
+
| ResourceSortMap
|
|
220
|
+
| Record<string, number | string>;
|
|
216
221
|
|
|
217
222
|
export type ResourceListParams<TRelations extends readonly string[] = readonly string[]> = {
|
|
218
223
|
page?: number;
|
|
@@ -4642,6 +4647,28 @@ export type SdkUtils = Omit<TaskUtils, 'workspace' | 'workflow' | 'tiptap'> & {
|
|
|
4642
4647
|
* Sdk.utils.pluralize(2, 'item', 'items'); // '2 items'
|
|
4643
4648
|
*/
|
|
4644
4649
|
pluralize: (count: number, one: string, other: string) => string;
|
|
4650
|
+
/**
|
|
4651
|
+
* Type a sort that is not written inline in the call that reads it: a variable, a
|
|
4652
|
+
* `useMemo` result, a `useState` initial value, or an entry of a lookup table.
|
|
4653
|
+
* TypeScript widens `'desc'` to `string` and `-1` to `number` in such a value, and
|
|
4654
|
+
* `Sdk.hooks.useRecords` and a resource `search` or `searchAll` then cannot check it. `Sdk.utils.resourceSortInput` checks each direction where the sort is
|
|
4655
|
+
* written and returns the same value with its sort type. A direction is `1`, `-1`,
|
|
4656
|
+
* `'asc'`, or `'desc'`. An invalid direction throws.
|
|
4657
|
+
*
|
|
4658
|
+
* @example
|
|
4659
|
+
* const newestFirst = Sdk.utils.resourceSortInput({ created_at: 'desc' });
|
|
4660
|
+
* const { data: records } = Sdk.hooks.useRecords(orders, { sort: newestFirst });
|
|
4661
|
+
*
|
|
4662
|
+
* @example
|
|
4663
|
+
* const [sort, setSort] = React.useState(Sdk.utils.resourceSortInput({ key: 'name', direction: 'asc' }));
|
|
4664
|
+
* const { data: records } = Sdk.hooks.useRecords(students, { sort });
|
|
4665
|
+
*/
|
|
4666
|
+
resourceSortInput: {
|
|
4667
|
+
(sort: ResourceSortDescriptor): ResourceSortDescriptor;
|
|
4668
|
+
(sort: ResourceSortFieldDescriptor): ResourceSortFieldDescriptor;
|
|
4669
|
+
(sort: ResourceSortDescriptorList): ResourceSortDescriptorList;
|
|
4670
|
+
(sort: ResourceSortMap): ResourceSortMap;
|
|
4671
|
+
};
|
|
4645
4672
|
/**
|
|
4646
4673
|
* Build URLs for published workflows by stable slug or ID.
|
|
4647
4674
|
*
|
|
@@ -7842,9 +7869,11 @@ export type SdkHooks = {
|
|
|
7842
7869
|
* @example
|
|
7843
7870
|
* ```tsx
|
|
7844
7871
|
* function ReserveButton({ slotId }) {
|
|
7872
|
+
* const slots = Sdk.hooks.useApi(['slots'], (api) => api.get('/api/slots'));
|
|
7845
7873
|
* const action = Sdk.hooks.useWorkflowAction({
|
|
7846
7874
|
* workflowId: 'reserve-slot',
|
|
7847
|
-
* idempotent: true
|
|
7875
|
+
* idempotent: true,
|
|
7876
|
+
* onSuccess: () => slots.invalidate()
|
|
7848
7877
|
* });
|
|
7849
7878
|
*
|
|
7850
7879
|
* return (
|
|
@@ -7874,8 +7903,28 @@ export type SdkHooks = {
|
|
|
7874
7903
|
params?: Record<string, any>;
|
|
7875
7904
|
/** Generate and manage the conventional `idempotency_key` input. */
|
|
7876
7905
|
idempotent?: boolean;
|
|
7906
|
+
/** Called with the parsed response after every successful run, including a run
|
|
7907
|
+
* that a later run replaced. Refresh the data that the workflow changed here. */
|
|
7908
|
+
onSuccess?: (response: SdkWorkflowResponse) => void;
|
|
7877
7909
|
}): UseWorkflowActionResult;
|
|
7878
7910
|
|
|
7911
|
+
/**
|
|
7912
|
+
* Returns a function that refreshes every data query on the page. Use it after a
|
|
7913
|
+
* write when the page cannot name the data that the write changed. Prefer the
|
|
7914
|
+
* `invalidate()` of each affected data hook, because a full refresh refetches
|
|
7915
|
+
* every query on the page.
|
|
7916
|
+
*
|
|
7917
|
+
* @example
|
|
7918
|
+
* ```tsx
|
|
7919
|
+
* const invalidateAll = Sdk.hooks.useInvalidateAll();
|
|
7920
|
+
* const importMembers = Sdk.hooks.useWorkflowAction({
|
|
7921
|
+
* workflowId: 'import-members',
|
|
7922
|
+
* onSuccess: () => invalidateAll()
|
|
7923
|
+
* });
|
|
7924
|
+
* ```
|
|
7925
|
+
*/
|
|
7926
|
+
useInvalidateAll(): () => Promise<void>;
|
|
7927
|
+
|
|
7879
7928
|
/**
|
|
7880
7929
|
* Reactive timelines of a record's schedule workflow runs, the data behind
|
|
7881
7930
|
* `Sdk.Components.RecordScheduleDisplay`, for pages that render a custom
|
|
@@ -14499,6 +14548,7 @@ export declare const useForm: SdkInternal.FilePageSdk["useForm"];
|
|
|
14499
14548
|
export declare const useHoldScheduledNotification: SdkInternal.FilePageSdk["hooks"]["useHoldScheduledNotification"];
|
|
14500
14549
|
export declare const useInfiniteRecords: SdkInternal.FilePageSdk["hooks"]["useInfiniteRecords"];
|
|
14501
14550
|
export declare const useInput: SdkInternal.FilePageSdk["helpers"]["useInput"];
|
|
14551
|
+
export declare const useInvalidateAll: SdkInternal.FilePageSdk["hooks"]["useInvalidateAll"];
|
|
14502
14552
|
export declare const useLocalStorage: SdkInternal.FilePageSdk["hooks"]["useLocalStorage"];
|
|
14503
14553
|
export declare const useMenu: SdkInternal.FilePageSdk["useMenu"];
|
|
14504
14554
|
export declare const useNewCalendarEvent: SdkInternal.FilePageSdk["hooks"]["useNewCalendarEvent"];
|
|
@@ -14564,6 +14614,10 @@ export declare const workspace: SdkInternal.FilePageSdk["workspace"];
|
|
|
14564
14614
|
|
|
14565
14615
|
export type ResourceSortDirection = SdkInternal.ResourceSortDirection;
|
|
14566
14616
|
|
|
14617
|
+
export type ResourceSortMap = SdkInternal.ResourceSortMap;
|
|
14618
|
+
|
|
14619
|
+
export type ResourceSortDescriptorList = SdkInternal.ResourceSortDescriptorList;
|
|
14620
|
+
|
|
14567
14621
|
export type ResourceSortInput = SdkInternal.ResourceSortInput;
|
|
14568
14622
|
|
|
14569
14623
|
export type ResourceListParams<TRelations extends readonly string[] = readonly string[]> = SdkInternal.ResourceListParams<TRelations>;
|
package/dist/index.js
CHANGED
|
@@ -180,6 +180,7 @@ export const useForm = undefined;
|
|
|
180
180
|
export const useHoldScheduledNotification = undefined;
|
|
181
181
|
export const useInfiniteRecords = undefined;
|
|
182
182
|
export const useInput = undefined;
|
|
183
|
+
export const useInvalidateAll = undefined;
|
|
183
184
|
export const useLocalStorage = undefined;
|
|
184
185
|
export const useMenu = undefined;
|
|
185
186
|
export const useNewCalendarEvent = undefined;
|