@frontstackdev/cli 0.0.0-canary-20241122101833 → 0.0.0-canary-20241122125012

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.
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { ofetch } from 'ofetch'
7
- import type { BlockEndpoints, BlockParameters, BlockResponses, RequestOptions, BlockQueryFilters, BlockMode, Page } from './generated-types'
7
+ import type { BlockEndpoints, BlockParameters, BlockResponses, RequestOptions, BlockQueryFilters, BlockQuerySorts, BlockMode, Page } from './generated-types'
8
8
  import type { Query } from './query-types'
9
9
 
10
10
  type Method = 'GET' | 'POST' | 'PATCH' | 'DELETE'
@@ -63,7 +63,15 @@ const client = {
63
63
  * @param blockParameters The parameters to pass to the block
64
64
  * @example { key: '<variant-id>' }
65
65
  * @param config Further configuration options
66
- * @example { query: { filter: [{ type: 'equals', field: 'name', value: 'Blue Dress' }] } }
66
+ * @example {
67
+ * query: {
68
+ * filter: [{ type: 'equals', field: 'name', value: 'Red Dress' }],
69
+ * sort: [{
70
+ * 'order': 'asc',
71
+ * 'field': 'label'
72
+ * }]
73
+ * }
74
+ * }
67
75
  */
68
76
  block: async <BlockName extends keyof BlockEndpoints>(
69
77
  blockName: BlockName,
@@ -74,12 +82,12 @@ const client = {
74
82
  /**
75
83
  * Query parameters to pass to the block:
76
84
  * - `filter` accepts an array of filter objects to filter results
77
- * - `sort` accepts an array of sorting options to sort results
85
+ * - `sort` accepts a string or an array of sorting options to sort results
78
86
  * - `search` to perform a text search
79
87
  * - `limit` to limit the number of results returned
80
88
  * - `page` to paginate results
81
89
  */
82
- query?: Query<BlockQueryFilters[BlockName]>
90
+ query?: Query<BlockQueryFilters[BlockName], BlockQuerySorts[BlockName]>
83
91
  } : {}
84
92
  ) &
85
93
  {
@@ -106,25 +106,24 @@ export type LogicalFilter<T> = {
106
106
  export type SortField<T> = keyof T;
107
107
 
108
108
  /**
109
- * Sort results by a field and direction
109
+ * Sort results by a field and ordering direction
110
110
  *
111
111
  * @example
112
112
  * {
113
113
  * field: 'price',
114
- * direction: 'asc'
114
+ * order: 'asc'
115
115
  * }
116
116
  */
117
117
  export type Sort<T> = {
118
118
  field: SortField<T >;
119
- direction: 'asc' | 'desc';
119
+ order: 'asc' | 'desc';
120
120
  }
121
121
 
122
-
123
- export type Query<T> = {
122
+ export type Query<FilterType, SortType> = {
124
123
  /**
125
124
  * Filter results by a set of conditions
126
125
  */
127
- filter?: Filter<T>[];
126
+ filter?: Filter<FilterType>[];
128
127
  /**
129
128
  * Will search fields that are marked as searchable
130
129
  */
@@ -138,7 +137,7 @@ export type Query<T> = {
138
137
  * * An array of sort objects
139
138
  * * A single sort field
140
139
  */
141
- sort?: Sort<T> | Sort<T>[] | SortField<T>;
140
+ sort?: Sort<SortType> | Sort<SortType>[] | SortField<SortType>;
142
141
  /**
143
142
  * Limit the number of results returned
144
143
  */
@@ -99,6 +99,14 @@ type BlockQueryFilters = {
99
99
  {{/each}}
100
100
  }
101
101
 
102
+ type BlockQuerySorts = {
103
+ {{#each components.schemas}}
104
+ {{#if (contains tags "blocks")}}
105
+ {{@key}}: components['schemas']['{{@key}}QueryOptions']['sort']
106
+ {{/if}}
107
+ {{/each}}
108
+ }
109
+
102
110
  type BlockMode = {
103
111
  {{#each components.schemas}}
104
112
  {{#if (contains tags "blocks")}}
package/dist/version CHANGED
@@ -1 +1 @@
1
- 0.0.0-canary-20241122101833
1
+ 0.0.0-canary-20241122125012
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@frontstackdev/cli",
3
- "version": "0.0.0-canary-20241122101833",
3
+ "version": "0.0.0-canary-20241122125012",
4
4
  "description": "frontstack CLI for managing projects",
5
5
  "type": "module",
6
6
  "module": "dist/frontstack.mjs",