@diagonal-hq/cli 0.22.2 → 0.22.4
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/cli.mjs +4 -2
- package/dist/sdk-contract.d.ts +31 -2
- package/package.json +1 -1
package/dist/sdk-contract.d.ts
CHANGED
|
@@ -138,13 +138,18 @@ type ResourceSortFieldDescriptor = {
|
|
|
138
138
|
|
|
139
139
|
type ResourceSortDirection = 1 | -1 | 'asc' | 'desc';
|
|
140
140
|
|
|
141
|
+
type ResourceSortMap = Record<string, ResourceSortDirection>;
|
|
142
|
+
|
|
143
|
+
type ResourceSortDescriptorList = (ResourceSortDescriptor | ResourceSortFieldDescriptor)[];
|
|
144
|
+
|
|
141
145
|
type ResourceSortInput =
|
|
142
146
|
| string
|
|
143
147
|
| string[]
|
|
144
148
|
| ResourceSortDescriptor
|
|
145
149
|
| ResourceSortFieldDescriptor
|
|
146
|
-
|
|
|
147
|
-
|
|
|
150
|
+
| ResourceSortDescriptorList
|
|
151
|
+
| ResourceSortMap
|
|
152
|
+
| Record<string, number | string>;
|
|
148
153
|
|
|
149
154
|
type ResourceListParams<TRelations extends readonly string[] = readonly string[]> = {
|
|
150
155
|
page?: number;
|
|
@@ -4580,6 +4585,28 @@ type SdkUtils = Omit<TaskUtils, 'workspace' | 'workflow' | 'tiptap'> & {
|
|
|
4580
4585
|
* Sdk.utils.pluralize(2, 'item', 'items'); // '2 items'
|
|
4581
4586
|
*/
|
|
4582
4587
|
pluralize: (count: number, one: string, other: string) => string;
|
|
4588
|
+
/**
|
|
4589
|
+
* Type a sort that is not written inline in the call that reads it: a variable, a
|
|
4590
|
+
* `useMemo` result, a `useState` initial value, or an entry of a lookup table.
|
|
4591
|
+
* TypeScript widens `'desc'` to `string` and `-1` to `number` in such a value, and
|
|
4592
|
+
* `Sdk.hooks.useRecords` and a resource `search` or `searchAll` then cannot check it. `Sdk.utils.resourceSortInput` checks each direction where the sort is
|
|
4593
|
+
* written and returns the same value with its sort type. A direction is `1`, `-1`,
|
|
4594
|
+
* `'asc'`, or `'desc'`. An invalid direction throws.
|
|
4595
|
+
*
|
|
4596
|
+
* @example
|
|
4597
|
+
* const newestFirst = Sdk.utils.resourceSortInput({ created_at: 'desc' });
|
|
4598
|
+
* const { data: records } = Sdk.hooks.useRecords(orders, { sort: newestFirst });
|
|
4599
|
+
*
|
|
4600
|
+
* @example
|
|
4601
|
+
* const [sort, setSort] = React.useState(Sdk.utils.resourceSortInput({ key: 'name', direction: 'asc' }));
|
|
4602
|
+
* const { data: records } = Sdk.hooks.useRecords(students, { sort });
|
|
4603
|
+
*/
|
|
4604
|
+
resourceSortInput: {
|
|
4605
|
+
(sort: ResourceSortDescriptor): ResourceSortDescriptor;
|
|
4606
|
+
(sort: ResourceSortFieldDescriptor): ResourceSortFieldDescriptor;
|
|
4607
|
+
(sort: ResourceSortDescriptorList): ResourceSortDescriptorList;
|
|
4608
|
+
(sort: ResourceSortMap): ResourceSortMap;
|
|
4609
|
+
};
|
|
4583
4610
|
/**
|
|
4584
4611
|
* Build URLs for published workflows by stable slug or ID.
|
|
4585
4612
|
*
|
|
@@ -14269,6 +14296,8 @@ declare namespace Sdk {
|
|
|
14269
14296
|
export type ResourceSortDescriptor = import("diagonal:sdk-internal").ResourceSortDescriptor;
|
|
14270
14297
|
export type ResourceSortFieldDescriptor = import("diagonal:sdk-internal").ResourceSortFieldDescriptor;
|
|
14271
14298
|
export type ResourceSortDirection = import("diagonal:sdk-internal").ResourceSortDirection;
|
|
14299
|
+
export type ResourceSortMap = import("diagonal:sdk-internal").ResourceSortMap;
|
|
14300
|
+
export type ResourceSortDescriptorList = import("diagonal:sdk-internal").ResourceSortDescriptorList;
|
|
14272
14301
|
export type ResourceSortInput = import("diagonal:sdk-internal").ResourceSortInput;
|
|
14273
14302
|
export type ResourceListParams<TRelations extends readonly string[] = readonly string[]> = import("diagonal:sdk-internal").ResourceListParams<TRelations>;
|
|
14274
14303
|
export type ResourceSearchBody<TRelations extends readonly string[] = readonly string[]> = import("diagonal:sdk-internal").ResourceSearchBody<TRelations>;
|