@flaredev/cli 0.8.0 → 0.8.1
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@flaredev/cli",
|
|
3
|
-
"version": "0.8.
|
|
3
|
+
"version": "0.8.1",
|
|
4
4
|
"description": "The flare command-line tool: create, generate, migrate, and deploy Flare apps",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Muke Johnbaptist",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"jiti": "^2.7.0",
|
|
42
42
|
"jsonc-parser": "^3.3.1",
|
|
43
43
|
"picocolors": "^1.1.1",
|
|
44
|
-
"@flaredev/core": "0.8.
|
|
44
|
+
"@flaredev/core": "0.8.1"
|
|
45
45
|
},
|
|
46
46
|
"engines": {
|
|
47
47
|
"node": ">=22"
|
|
@@ -122,7 +122,9 @@ export async function exportRecordsAction(resourceName: string, query: string):
|
|
|
122
122
|
const params = new URLSearchParams(query);
|
|
123
123
|
params.set("page", String(page));
|
|
124
124
|
params.set("perPage", String(EXPORT_PAGE));
|
|
125
|
-
|
|
125
|
+
// A bigger page than a request from outside may ask for: this is the server
|
|
126
|
+
// paging through everything on purpose, and 500 round trips would be absurd.
|
|
127
|
+
const result = await store.list(params, { maxPerPage: EXPORT_PAGE });
|
|
126
128
|
if (!result.ok) return result;
|
|
127
129
|
rows.push(...result.data.data);
|
|
128
130
|
if (page >= result.data.meta.totalPages) break;
|
|
@@ -93,7 +93,19 @@ function coerce(def: StoredField, raw: string): string | number | boolean | null
|
|
|
93
93
|
* resource. Only fields the descriptor marks sortable/filterable/searchable are
|
|
94
94
|
* accepted, so clients can't probe arbitrary columns.
|
|
95
95
|
*/
|
|
96
|
-
export function parseListQuery(
|
|
96
|
+
export function parseListQuery(
|
|
97
|
+
resource: Resource,
|
|
98
|
+
params: URLSearchParams,
|
|
99
|
+
/**
|
|
100
|
+
* The largest page this caller may ask for.
|
|
101
|
+
*
|
|
102
|
+
* The cap exists to stop a request from the outside asking for ten thousand rows at
|
|
103
|
+
* once. Server-side callers that page through everything deliberately — the CSV
|
|
104
|
+
* export — pass their own, which is why this is an argument rather than a constant
|
|
105
|
+
* everything obeys.
|
|
106
|
+
*/
|
|
107
|
+
options: { maxPerPage?: number } = {},
|
|
108
|
+
): { query: ListQuery } | { issues: QueryIssue[] } {
|
|
97
109
|
const issues: QueryIssue[] = [];
|
|
98
110
|
const fields = new Map(storedFields(resource));
|
|
99
111
|
|
|
@@ -109,7 +121,7 @@ export function parseListQuery(resource: Resource, params: URLSearchParams): { q
|
|
|
109
121
|
};
|
|
110
122
|
|
|
111
123
|
const page = positiveInt("page", 1);
|
|
112
|
-
const perPage = positiveInt("perPage", resource.perPage, MAX_PER_PAGE);
|
|
124
|
+
const perPage = positiveInt("perPage", resource.perPage, options.maxPerPage ?? MAX_PER_PAGE);
|
|
113
125
|
|
|
114
126
|
let sort = resource.defaultSort;
|
|
115
127
|
const rawSort = params.get("sort");
|
|
@@ -206,8 +206,8 @@ export function createResourceStore(options: ResourceStoreOptions) {
|
|
|
206
206
|
resource,
|
|
207
207
|
|
|
208
208
|
/** `params`: page, perPage, sort, q, filter[field], cursor (as parsed by parseListQuery). */
|
|
209
|
-
async list(params: URLSearchParams): Promise<Result<ListResult>> {
|
|
210
|
-
const parsed = parseListQuery(resource, params);
|
|
209
|
+
async list(params: URLSearchParams, options: { maxPerPage?: number } = {}): Promise<Result<ListResult>> {
|
|
210
|
+
const parsed = parseListQuery(resource, params, options);
|
|
211
211
|
if ("issues" in parsed) return fail(400, "Invalid query.", { queryIssues: parsed.issues });
|
|
212
212
|
const { page, perPage, sort, q, filters, cursor } = parsed.query;
|
|
213
213
|
|
|
@@ -120,7 +120,9 @@ export async function exportRecordsAction(resourceName: string, query: string):
|
|
|
120
120
|
const params = new URLSearchParams(query);
|
|
121
121
|
params.set("page", String(page));
|
|
122
122
|
params.set("perPage", String(EXPORT_PAGE));
|
|
123
|
-
|
|
123
|
+
// A bigger page than a request from outside may ask for: this is the server
|
|
124
|
+
// paging through everything on purpose, and 500 round trips would be absurd.
|
|
125
|
+
const result = await store.list(params, { maxPerPage: EXPORT_PAGE });
|
|
124
126
|
if (!result.ok) return result;
|
|
125
127
|
rows.push(...result.data.data);
|
|
126
128
|
if (page >= result.data.meta.totalPages) break;
|