@byline/core 1.11.1 → 1.11.2
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.
|
@@ -179,23 +179,6 @@ export interface CollectionAdminConfig<T = any> {
|
|
|
179
179
|
slug: string;
|
|
180
180
|
/** Group name for organising collections in the admin sidebar. */
|
|
181
181
|
group?: string;
|
|
182
|
-
/**
|
|
183
|
-
* When true, documents in this collection carry a fractional-index
|
|
184
|
-
* `order_key` and the list view sorts by it ascending by default, with
|
|
185
|
-
* drag-to-reorder enabled in the admin UI.
|
|
186
|
-
*
|
|
187
|
-
* Storage: `byline_documents.order_key` — admin metadata, never per-version
|
|
188
|
-
* and never EAV. Reordering writes the single column and does NOT mint a
|
|
189
|
-
* new document version.
|
|
190
|
-
*
|
|
191
|
-
* Backfill: existing rows in newly-`orderable` collections start with
|
|
192
|
-
* `order_key = NULL`. They sort to the bottom (NULLS LAST) until the
|
|
193
|
-
* editor drags them into position.
|
|
194
|
-
*
|
|
195
|
-
* Orthogonal to `hasMany` array order. Use this for top-level order
|
|
196
|
-
* inside a collection (bios, team members, FAQ items, sections).
|
|
197
|
-
*/
|
|
198
|
-
orderable?: boolean;
|
|
199
182
|
/** Column definitions for the collection list view. */
|
|
200
183
|
columns?: ColumnDefinition<T>[];
|
|
201
184
|
/**
|
|
@@ -725,6 +725,28 @@ export interface CollectionDefinition {
|
|
|
725
725
|
* on every landing-page load, so opt in deliberately.
|
|
726
726
|
*/
|
|
727
727
|
showStats?: boolean;
|
|
728
|
+
/**
|
|
729
|
+
* When `true`, documents in this collection carry a fractional-index
|
|
730
|
+
* `order_key` and the list view sorts by it ascending by default, with
|
|
731
|
+
* drag-to-reorder enabled in the admin UI.
|
|
732
|
+
*
|
|
733
|
+
* Storage: `byline_documents.order_key` — system metadata, never per-version
|
|
734
|
+
* and never EAV. Reordering writes the single column and does NOT mint a
|
|
735
|
+
* new document version.
|
|
736
|
+
*
|
|
737
|
+
* Backfill: existing rows in newly-`orderable` collections start with
|
|
738
|
+
* `order_key = NULL`. They sort to the bottom (NULLS LAST) until the
|
|
739
|
+
* editor drags them into position.
|
|
740
|
+
*
|
|
741
|
+
* Lives on the schema (not admin config) because it has structural
|
|
742
|
+
* consequences across layers — `document-lifecycle` appends a key on
|
|
743
|
+
* create, the reorder server fn gates on it, and the `@byline/client`
|
|
744
|
+
* SDK can default-sort on it without crossing into presentation config.
|
|
745
|
+
*
|
|
746
|
+
* Orthogonal to `hasMany` array order. Use this for top-level order
|
|
747
|
+
* inside a collection (bios, team members, FAQ items, sections).
|
|
748
|
+
*/
|
|
749
|
+
orderable?: boolean;
|
|
728
750
|
/**
|
|
729
751
|
* Optional explicit version pin. When omitted, the startup bootstrap
|
|
730
752
|
* auto-increments the collection's stored version any time the schema
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { isArrayField, isBlocksField, isGroupField, normalizeCollectionHook, } from '../@types/index.js';
|
|
9
9
|
import { assertActorCanPerform } from '../auth/assert-actor-can-perform.js';
|
|
10
|
-
import {
|
|
10
|
+
import { getCollectionDefinition } from '../config/config.js';
|
|
11
11
|
import { ERR_CONFLICT, ERR_INVALID_TRANSITION, ERR_NOT_FOUND, ERR_PATCH_FAILED, ERR_PATH_CONFLICT, ERR_VALIDATION, ErrorCodes, } from '../lib/errors.js';
|
|
12
12
|
import { generateKeyBetween } from '../lib/fractional-index.js';
|
|
13
13
|
import { withLogContext } from '../lib/logger.js';
|
|
@@ -31,15 +31,15 @@ async function invokeHook(hook, ctx) {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
|
-
* For collections with `orderable: true`
|
|
35
|
-
* append-at-end fractional-index key for a newly-inserted document.
|
|
36
|
-
* Returns `undefined` when the collection hasn't opted in (or has no
|
|
37
|
-
*
|
|
34
|
+
* For collections with `orderable: true` on their schema definition, compute
|
|
35
|
+
* an append-at-end fractional-index key for a newly-inserted document.
|
|
36
|
+
* Returns `undefined` when the collection hasn't opted in (or has no
|
|
37
|
+
* definition registered, e.g. in unit-test environments), so the storage row
|
|
38
38
|
* gets `order_key = NULL` and the existing "no ordering" behavior holds.
|
|
39
39
|
*/
|
|
40
40
|
async function maybeAppendOrderKey(ctx, collectionPath) {
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
41
|
+
const definition = getCollectionDefinition(collectionPath);
|
|
42
|
+
if (definition?.orderable !== true)
|
|
43
43
|
return undefined;
|
|
44
44
|
const last = await ctx.db.queries.documents.getLastOrderKey({
|
|
45
45
|
collection_id: ctx.collectionId,
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@byline/core",
|
|
3
3
|
"private": false,
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
|
-
"version": "1.11.
|
|
5
|
+
"version": "1.11.2",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.9.0"
|
|
8
8
|
},
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"sharp": "^0.34.5",
|
|
80
80
|
"uuid": "^14.0.0",
|
|
81
81
|
"zod": "^4.4.3",
|
|
82
|
-
"@byline/auth": "1.11.
|
|
82
|
+
"@byline/auth": "1.11.2"
|
|
83
83
|
},
|
|
84
84
|
"devDependencies": {
|
|
85
85
|
"@biomejs/biome": "2.4.15",
|