@diagonal-hq/pages 0.3.2 → 0.3.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.
Files changed (2) hide show
  1. package/dist/index.d.ts +35 -2
  2. 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
- | (ResourceSortDescriptor | ResourceSortFieldDescriptor)[]
215
- | Record<string, ResourceSortDirection | number | string>;
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;
@@ -2899,6 +2904,7 @@ export type SdkSystemSettingsPage =
2899
2904
  | 'page-playground'
2900
2905
  | 'pages'
2901
2906
  | 'projects'
2907
+ | 'record-bindings'
2902
2908
  | 'redirects'
2903
2909
  | 'resources'
2904
2910
  | 'security'
@@ -2962,6 +2968,7 @@ export type SdkWorkspace = {
2962
2968
  fields: WorkspaceFieldDefinitionCatalog;
2963
2969
  /** @deprecated Load-time snapshot. Read live values with `Sdk.hooks.useWorkspaceValues`. */
2964
2970
  values: WorkspaceFieldCatalog | null;
2971
+ value_errors?: Record<string, string>;
2965
2972
  } | null;
2966
2973
 
2967
2974
  export type SdkWorkspaceField = {
@@ -4640,6 +4647,28 @@ export type SdkUtils = Omit<TaskUtils, 'workspace' | 'workflow' | 'tiptap'> & {
4640
4647
  * Sdk.utils.pluralize(2, 'item', 'items'); // '2 items'
4641
4648
  */
4642
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
+ };
4643
4672
  /**
4644
4673
  * Build URLs for published workflows by stable slug or ID.
4645
4674
  *
@@ -14562,6 +14591,10 @@ export declare const workspace: SdkInternal.FilePageSdk["workspace"];
14562
14591
 
14563
14592
  export type ResourceSortDirection = SdkInternal.ResourceSortDirection;
14564
14593
 
14594
+ export type ResourceSortMap = SdkInternal.ResourceSortMap;
14595
+
14596
+ export type ResourceSortDescriptorList = SdkInternal.ResourceSortDescriptorList;
14597
+
14565
14598
  export type ResourceSortInput = SdkInternal.ResourceSortInput;
14566
14599
 
14567
14600
  export type ResourceListParams<TRelations extends readonly string[] = readonly string[]> = SdkInternal.ResourceListParams<TRelations>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@diagonal-hq/pages",
3
- "version": "0.3.2",
3
+ "version": "0.3.4",
4
4
  "description": "The Page SDK for the pages of file-based Diagonal workspaces.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {