@byline/db-postgres 3.1.0 → 3.2.0
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.
|
@@ -100,8 +100,9 @@ export declare class DocumentQueries implements IDocumentQueries {
|
|
|
100
100
|
/**
|
|
101
101
|
* Batch-fetch the version-locale availability sets from the
|
|
102
102
|
* `byline_document_version_locales` ledger. For each version returns the
|
|
103
|
-
* concrete locales its content is complete in (`availableLocales`,
|
|
104
|
-
* or `localeAgnostic: true` when the
|
|
103
|
+
* concrete locales its content is complete in (`availableLocales`, in
|
|
104
|
+
* configured content-locale order), or `localeAgnostic: true` when the
|
|
105
|
+
* version carries only the `'all'`
|
|
105
106
|
* sentinel (no localized content → renders identically in every locale).
|
|
106
107
|
* Drives the `_availableVersionLocales` read metadata. One indexed query per call.
|
|
107
108
|
*/
|
|
@@ -109,8 +110,9 @@ export declare class DocumentQueries implements IDocumentQueries {
|
|
|
109
110
|
/**
|
|
110
111
|
* Batch-fetch the editorial advertised-locale sets from
|
|
111
112
|
* `byline_document_available_locales` (document-grain). For each logical
|
|
112
|
-
* document returns the
|
|
113
|
-
*
|
|
113
|
+
* document returns the set of locales the editor has elected to advertise,
|
|
114
|
+
* in configured content-locale order. Surfaced on reads as
|
|
115
|
+
* `availableLocales` — the deliberate
|
|
114
116
|
* counterpart to the version-grain `_availableVersionLocales` ledger fact;
|
|
115
117
|
* the public advertised set is their intersection. One indexed query per
|
|
116
118
|
* call. See docs/I18N.md.
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
// constructs query/command classes before initBylineCore() wires up the Pino
|
|
10
10
|
// logger. A future refactor could inject the logger at construction time by
|
|
11
11
|
// either deferring adapter construction or accepting a lazy logger parameter.
|
|
12
|
-
import { ERR_DATABASE, ERR_NOT_FOUND, getLogger } from '@byline/core';
|
|
12
|
+
import { ERR_DATABASE, ERR_NOT_FOUND, getLogger, orderByContentLocale } from '@byline/core';
|
|
13
13
|
import { and, desc, eq, inArray, isNotNull, sql } from 'drizzle-orm';
|
|
14
14
|
import { collections, currentDocumentsView, currentPublishedDocumentsView, documentAvailableLocales, documentPaths, documents, documentVersionLocales, documentVersions, metaStore, } from '../../database/schema/index.js';
|
|
15
15
|
import { extractFlattenedFieldValue, restoreFieldSetData } from './storage-restore.js';
|
|
@@ -133,8 +133,9 @@ export class DocumentQueries {
|
|
|
133
133
|
/**
|
|
134
134
|
* Batch-fetch the version-locale availability sets from the
|
|
135
135
|
* `byline_document_version_locales` ledger. For each version returns the
|
|
136
|
-
* concrete locales its content is complete in (`availableLocales`,
|
|
137
|
-
* or `localeAgnostic: true` when the
|
|
136
|
+
* concrete locales its content is complete in (`availableLocales`, in
|
|
137
|
+
* configured content-locale order), or `localeAgnostic: true` when the
|
|
138
|
+
* version carries only the `'all'`
|
|
138
139
|
* sentinel (no localized content → renders identically in every locale).
|
|
139
140
|
* Drives the `_availableVersionLocales` read metadata. One indexed query per call.
|
|
140
141
|
*/
|
|
@@ -160,15 +161,20 @@ export class DocumentQueries {
|
|
|
160
161
|
else
|
|
161
162
|
entry.availableLocales.push(row.locale);
|
|
162
163
|
}
|
|
163
|
-
|
|
164
|
-
|
|
164
|
+
// Stable, config-driven order — `_availableVersionLocales` is a set
|
|
165
|
+
// consumed via membership, so this just keeps its array order canonical
|
|
166
|
+
// (matching `availableLocales`). Falls back to a–z when no config.
|
|
167
|
+
for (const entry of result.values()) {
|
|
168
|
+
entry.availableLocales = orderByContentLocale(entry.availableLocales);
|
|
169
|
+
}
|
|
165
170
|
return result;
|
|
166
171
|
}
|
|
167
172
|
/**
|
|
168
173
|
* Batch-fetch the editorial advertised-locale sets from
|
|
169
174
|
* `byline_document_available_locales` (document-grain). For each logical
|
|
170
|
-
* document returns the
|
|
171
|
-
*
|
|
175
|
+
* document returns the set of locales the editor has elected to advertise,
|
|
176
|
+
* in configured content-locale order. Surfaced on reads as
|
|
177
|
+
* `availableLocales` — the deliberate
|
|
172
178
|
* counterpart to the version-grain `_availableVersionLocales` ledger fact;
|
|
173
179
|
* the public advertised set is their intersection. One indexed query per
|
|
174
180
|
* call. See docs/I18N.md.
|
|
@@ -192,8 +198,12 @@ export class DocumentQueries {
|
|
|
192
198
|
}
|
|
193
199
|
arr.push(row.locale);
|
|
194
200
|
}
|
|
195
|
-
|
|
196
|
-
|
|
201
|
+
// Project `availableLocales` in configured content-locale order (the set
|
|
202
|
+
// is order-insensitive). Read-time only — nothing persisted changes, and
|
|
203
|
+
// unknown/removed codes sort last rather than throwing. Falls back to a–z
|
|
204
|
+
// when no server config is registered (e.g. isolated storage tests).
|
|
205
|
+
for (const [did, arr] of result)
|
|
206
|
+
result.set(did, orderByContentLocale(arr));
|
|
197
207
|
return result;
|
|
198
208
|
}
|
|
199
209
|
/**
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@byline/db-postgres",
|
|
3
3
|
"private": false,
|
|
4
4
|
"license": "MPL-2.0",
|
|
5
|
-
"version": "3.
|
|
5
|
+
"version": "3.2.0",
|
|
6
6
|
"engines": {
|
|
7
7
|
"node": ">=20.9.0"
|
|
8
8
|
},
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"pg": "^8.21.0",
|
|
58
58
|
"uuid": "^14.0.0",
|
|
59
59
|
"zod": "^4.4.3",
|
|
60
|
-
"@byline/core": "3.
|
|
61
|
-
"@byline/
|
|
62
|
-
"@byline/
|
|
60
|
+
"@byline/core": "3.2.0",
|
|
61
|
+
"@byline/admin": "3.2.0",
|
|
62
|
+
"@byline/auth": "3.2.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@biomejs/biome": "2.4.15",
|