@flaredev/core 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/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/server.d.ts +18 -3
- package/dist/server.js +4 -4
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -529,6 +529,6 @@ interface SeedContext {
|
|
|
529
529
|
type Seed = (context: SeedContext) => void | Promise<void>;
|
|
530
530
|
declare function defineSeed(seed: Seed): Seed;
|
|
531
531
|
|
|
532
|
-
declare const FLARE_VERSION = "0.8.
|
|
532
|
+
declare const FLARE_VERSION = "0.8.1";
|
|
533
533
|
|
|
534
534
|
export { type BelongsToRelation, type Country, CreateInput, FLARE_VERSION, type Fake, Field, type FormValues, type FormatOptions, type HasManyRelation, type InsertMany, type MailMessage, type MailResult, type Mailer, type MailerOptions, PBKDF2_ITERATIONS, type ReadUrlOptions, RelationError, type RelationGraph, Resource, type ResourceRelations, type ResourceValidators, SNIFF_BYTES, SUBSCRIPTION_STATUSES, type Seed, type SeedContext, type Storage, type StorageBucket, type StorageOptions, StoredField, type SubscriptionLike, type SubscriptionState, type SubscriptionStatus, type Tone, type TransactionalEmail, UpdateInput, type UploadUrlOptions, camelCase, checkoutPaid, countries, countryName, createFake, createMailer, createObjectKey, createStorage, createValidators, currentPeriodEnd, defineSeed, fake, fieldSchema, fileKeyPrefix, flagEmoji, formValuesToInput, formatPhone, formatValue, grantsAccess, hashPassword, humanize, importSigningKey, initialFormValues, isColor, isCountryCode, isDomain, isLiveSubscription, isPhoneNumber, isSlug, issuesByField, kebabCase, matchesContentType, normalizeDomain, optionLabel, parseMultiValue, pascalCase, pluralize, randomLetters, relationGraph, renderTransactionalEmail, shouldApplySubscription, signToken, slugify, snakeCase, sniffMatches, splitPhone, statusTone, subscriptionPriceId, subscriptionState, toE164, toSubscriptionStatus, verifyPassword, verifyToken, words };
|
package/dist/index.js
CHANGED
package/dist/server.d.ts
CHANGED
|
@@ -122,7 +122,18 @@ declare function isSearchable(def: StoredField): boolean;
|
|
|
122
122
|
* resource. Only fields the descriptor marks sortable/filterable/searchable are
|
|
123
123
|
* accepted, so clients can't probe arbitrary columns.
|
|
124
124
|
*/
|
|
125
|
-
declare function parseListQuery(resource: Resource, params: URLSearchParams
|
|
125
|
+
declare function parseListQuery(resource: Resource, params: URLSearchParams,
|
|
126
|
+
/**
|
|
127
|
+
* The largest page this caller may ask for.
|
|
128
|
+
*
|
|
129
|
+
* The cap exists to stop a request from the outside asking for ten thousand rows at
|
|
130
|
+
* once. Server-side callers that page through everything deliberately — the CSV
|
|
131
|
+
* export — pass their own, which is why this is an argument rather than a constant
|
|
132
|
+
* everything obeys.
|
|
133
|
+
*/
|
|
134
|
+
options?: {
|
|
135
|
+
maxPerPage?: number;
|
|
136
|
+
}): {
|
|
126
137
|
query: ListQuery;
|
|
127
138
|
} | {
|
|
128
139
|
issues: QueryIssue[];
|
|
@@ -215,7 +226,9 @@ declare function createResourceStore(options: ResourceStoreOptions): {
|
|
|
215
226
|
resource: Resource<Record<string, Field>>;
|
|
216
227
|
table: SQLiteTable<drizzle_orm_sqlite_core.TableConfig> | undefined;
|
|
217
228
|
/** `params`: page, perPage, sort, q, filter[field], cursor (as parsed by parseListQuery). */
|
|
218
|
-
list(params: URLSearchParams
|
|
229
|
+
list(params: URLSearchParams, options?: {
|
|
230
|
+
maxPerPage?: number;
|
|
231
|
+
}): Promise<Result<ListResult>>;
|
|
219
232
|
get(id: string): Promise<Result<Record<string, unknown>>>;
|
|
220
233
|
/** Title-field values for a set of ids (for showing relations). Missing ids are omitted. */
|
|
221
234
|
titles(ids: string[]): Promise<Record<string, string>>;
|
|
@@ -271,7 +284,9 @@ declare function createResourceHandlers(options: ResourceHandlerOptions): {
|
|
|
271
284
|
store: {
|
|
272
285
|
resource: Resource<Record<string, Field>>;
|
|
273
286
|
table: SQLiteTable<drizzle_orm_sqlite_core.TableConfig> | undefined;
|
|
274
|
-
list(params: URLSearchParams
|
|
287
|
+
list(params: URLSearchParams, options?: {
|
|
288
|
+
maxPerPage?: number;
|
|
289
|
+
}): Promise<Result<ListResult>>;
|
|
275
290
|
get(id: string): Promise<Result<Record<string, unknown>>>;
|
|
276
291
|
titles(ids: string[]): Promise<Record<string, string>>;
|
|
277
292
|
create(raw: unknown): Promise<Result<Record<string, unknown>>>;
|
package/dist/server.js
CHANGED
|
@@ -1319,7 +1319,7 @@ function coerce(def, raw) {
|
|
|
1319
1319
|
return raw;
|
|
1320
1320
|
}
|
|
1321
1321
|
}
|
|
1322
|
-
function parseListQuery(resource, params) {
|
|
1322
|
+
function parseListQuery(resource, params, options = {}) {
|
|
1323
1323
|
const issues = [];
|
|
1324
1324
|
const fields = new Map(storedFields(resource));
|
|
1325
1325
|
const positiveInt = (name, fallback, max = Number.MAX_SAFE_INTEGER) => {
|
|
@@ -1333,7 +1333,7 @@ function parseListQuery(resource, params) {
|
|
|
1333
1333
|
return value;
|
|
1334
1334
|
};
|
|
1335
1335
|
const page = positiveInt("page", 1);
|
|
1336
|
-
const perPage = positiveInt("perPage", resource.perPage, MAX_PER_PAGE);
|
|
1336
|
+
const perPage = positiveInt("perPage", resource.perPage, options.maxPerPage ?? MAX_PER_PAGE);
|
|
1337
1337
|
let sort = resource.defaultSort;
|
|
1338
1338
|
const rawSort = params.get("sort");
|
|
1339
1339
|
if (rawSort) {
|
|
@@ -1449,8 +1449,8 @@ function createResourceStore(options) {
|
|
|
1449
1449
|
resource,
|
|
1450
1450
|
table,
|
|
1451
1451
|
/** `params`: page, perPage, sort, q, filter[field], cursor (as parsed by parseListQuery). */
|
|
1452
|
-
async list(params) {
|
|
1453
|
-
const parsed = parseListQuery(resource, params);
|
|
1452
|
+
async list(params, options2 = {}) {
|
|
1453
|
+
const parsed = parseListQuery(resource, params, options2);
|
|
1454
1454
|
if ("issues" in parsed) return fail(400, "Invalid query.", { queryIssues: parsed.issues });
|
|
1455
1455
|
const { page, perPage, sort, q, filters, cursor } = parsed.query;
|
|
1456
1456
|
const isDateField = (key) => {
|