@flaredev/core 0.7.2 → 0.7.3
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 +8 -0
- package/dist/server.js +8 -2
- 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.7.
|
|
532
|
+
declare const FLARE_VERSION = "0.7.3";
|
|
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
|
@@ -39,6 +39,14 @@ interface RowsQuery {
|
|
|
39
39
|
value: unknown;
|
|
40
40
|
id: string;
|
|
41
41
|
greaterThan: boolean;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the sort column holds a date.
|
|
44
|
+
*
|
|
45
|
+
* A cursor travels through a URL, so a Date arrives back as a number. SQLite stores
|
|
46
|
+
* dates as milliseconds and wants that number; Postgres wants a Date. Neither
|
|
47
|
+
* adapter can tell which a column is, and the store can — so it says.
|
|
48
|
+
*/
|
|
49
|
+
isDate?: boolean;
|
|
42
50
|
};
|
|
43
51
|
limit: number;
|
|
44
52
|
/** Offset paging, for the page-number case. Never combined with a cursor. */
|
package/dist/server.js
CHANGED
|
@@ -1453,6 +1453,11 @@ function createResourceStore(options) {
|
|
|
1453
1453
|
const parsed = parseListQuery(resource, params);
|
|
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
|
+
const isDateField = (key) => {
|
|
1457
|
+
if (key === "createdAt" || key === "updatedAt") return true;
|
|
1458
|
+
const def = fields.find(([name]) => name === key)?.[1];
|
|
1459
|
+
return def?.kind === "date" || def?.kind === "datetime";
|
|
1460
|
+
};
|
|
1456
1461
|
const searchable = fields.filter(([, def]) => isSearchable(def)).map(([key]) => key);
|
|
1457
1462
|
const matching = { search: q ? { term: q, fields: searchable } : void 0, filters };
|
|
1458
1463
|
const backwards = cursor?.direction === "before";
|
|
@@ -1462,7 +1467,7 @@ function createResourceStore(options) {
|
|
|
1462
1467
|
rows.find({
|
|
1463
1468
|
...matching,
|
|
1464
1469
|
sort: { field: sort.field, direction: descending ? "desc" : "asc" },
|
|
1465
|
-
cursor: cursor ? { field: sort.field, value: cursor.value, id: cursor.id, greaterThan: !descending } : void 0,
|
|
1470
|
+
cursor: cursor ? { field: sort.field, value: cursor.value, id: cursor.id, greaterThan: !descending, isDate: isDateField(sort.field) } : void 0,
|
|
1466
1471
|
limit: perPage + 1,
|
|
1467
1472
|
offset: cursor ? void 0 : (page - 1) * perPage
|
|
1468
1473
|
}),
|
|
@@ -1680,8 +1685,9 @@ function prismaRows(delegate, client) {
|
|
|
1680
1685
|
async find(query) {
|
|
1681
1686
|
const where = matching(query);
|
|
1682
1687
|
if (query.cursor) {
|
|
1683
|
-
const { field,
|
|
1688
|
+
const { field, id, greaterThan, isDate } = query.cursor;
|
|
1684
1689
|
const op = greaterThan ? "gt" : "lt";
|
|
1690
|
+
const value = isDate && (typeof query.cursor.value === "number" || typeof query.cursor.value === "string") ? new Date(query.cursor.value) : query.cursor.value;
|
|
1685
1691
|
const keyset = [{ [field]: { [op]: value } }, { AND: [{ [field]: value }, { id: { [op]: id } }] }];
|
|
1686
1692
|
where.AND = [...where.AND ?? [], { OR: keyset }];
|
|
1687
1693
|
}
|