@byline/db-postgres 2.5.1 → 2.6.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.
|
@@ -293,6 +293,25 @@ export declare const adminUsers: import("drizzle-orm/pg-core").PgTableWithColumn
|
|
|
293
293
|
identity: undefined;
|
|
294
294
|
generated: undefined;
|
|
295
295
|
}, {}, {}>;
|
|
296
|
+
preferred_locale: import("drizzle-orm/pg-core").PgColumn<{
|
|
297
|
+
name: "preferred_locale";
|
|
298
|
+
tableName: "byline_admin_users";
|
|
299
|
+
dataType: "string";
|
|
300
|
+
columnType: "PgVarchar";
|
|
301
|
+
data: string;
|
|
302
|
+
driverParam: string;
|
|
303
|
+
notNull: false;
|
|
304
|
+
hasDefault: false;
|
|
305
|
+
isPrimaryKey: false;
|
|
306
|
+
isAutoincrement: false;
|
|
307
|
+
hasRuntimeDefault: false;
|
|
308
|
+
enumValues: [string, ...string[]];
|
|
309
|
+
baseColumn: never;
|
|
310
|
+
identity: undefined;
|
|
311
|
+
generated: undefined;
|
|
312
|
+
}, {}, {
|
|
313
|
+
length: 16;
|
|
314
|
+
}>;
|
|
296
315
|
};
|
|
297
316
|
dialect: "pg";
|
|
298
317
|
}>;
|
|
@@ -56,6 +56,13 @@ export const adminUsers = pgTable('byline_admin_users', {
|
|
|
56
56
|
*/
|
|
57
57
|
is_enabled: boolean('is_enabled').notNull().default(false),
|
|
58
58
|
is_email_verified: boolean('is_email_verified').notNull().default(false),
|
|
59
|
+
/**
|
|
60
|
+
* Per-user admin interface locale preference. Nullable — `null` means
|
|
61
|
+
* "use the detection cascade" (cookie → Accept-Language → defaultLocale).
|
|
62
|
+
* Stored as a BCP 47 code (`en`, `pt-BR`, `zh-Hans-CN`); validated at
|
|
63
|
+
* write time against the host's `i18n.interface.locales` set.
|
|
64
|
+
*/
|
|
65
|
+
preferred_locale: varchar('preferred_locale', { length: 16 }),
|
|
59
66
|
...timestamps,
|
|
60
67
|
}, (table) => [index('idx_byline_admin_users_email').on(table.email)]);
|
|
61
68
|
// ---------------------------------------------------------------------------
|
|
@@ -40,6 +40,7 @@ const PUBLIC_COLUMNS = {
|
|
|
40
40
|
is_super_admin: adminUsers.is_super_admin,
|
|
41
41
|
is_enabled: adminUsers.is_enabled,
|
|
42
42
|
is_email_verified: adminUsers.is_email_verified,
|
|
43
|
+
preferred_locale: adminUsers.preferred_locale,
|
|
43
44
|
created_at: adminUsers.created_at,
|
|
44
45
|
updated_at: adminUsers.updated_at,
|
|
45
46
|
};
|
|
@@ -66,6 +67,7 @@ export function createAdminUsersRepository(db) {
|
|
|
66
67
|
is_super_admin: input.is_super_admin ?? false,
|
|
67
68
|
is_enabled: input.is_enabled ?? false,
|
|
68
69
|
is_email_verified: input.is_email_verified ?? false,
|
|
70
|
+
preferred_locale: input.preferred_locale ?? null,
|
|
69
71
|
})
|
|
70
72
|
.returning(PUBLIC_COLUMNS);
|
|
71
73
|
if (!row)
|
|
@@ -146,6 +148,8 @@ export function createAdminUsersRepository(db) {
|
|
|
146
148
|
updateSet.is_email_verified = patch.is_email_verified;
|
|
147
149
|
if (patch.remember_me !== undefined)
|
|
148
150
|
updateSet.remember_me = patch.remember_me;
|
|
151
|
+
if (patch.preferred_locale !== undefined)
|
|
152
|
+
updateSet.preferred_locale = patch.preferred_locale;
|
|
149
153
|
const [row] = await db
|
|
150
154
|
.update(adminUsers)
|
|
151
155
|
.set(updateSet)
|
|
@@ -175,6 +179,12 @@ export function createAdminUsersRepository(db) {
|
|
|
175
179
|
.set({ is_enabled: enabled, updated_at: new Date(), vid: sql `${adminUsers.vid} + 1` })
|
|
176
180
|
.where(eq(adminUsers.id, id));
|
|
177
181
|
},
|
|
182
|
+
async setPreferredLocale(id, locale) {
|
|
183
|
+
await db
|
|
184
|
+
.update(adminUsers)
|
|
185
|
+
.set({ preferred_locale: locale, updated_at: new Date(), vid: sql `${adminUsers.vid} + 1` })
|
|
186
|
+
.where(eq(adminUsers.id, id));
|
|
187
|
+
},
|
|
178
188
|
async recordLoginSuccess(id, ip) {
|
|
179
189
|
await db
|
|
180
190
|
.update(adminUsers)
|
|
@@ -443,10 +443,10 @@ export declare class DocumentQueries implements IDocumentQueries {
|
|
|
443
443
|
*/
|
|
444
444
|
private buildCombinatorGroup;
|
|
445
445
|
/**
|
|
446
|
-
* Compile a `DocumentColumnFilter` against the outer scope's status
|
|
447
|
-
* path column. Plain comparison — no EXISTS — because the
|
|
448
|
-
* directly on the outer relation (
|
|
449
|
-
* EAV stores.
|
|
446
|
+
* Compile a `DocumentColumnFilter` against the outer scope's `status`,
|
|
447
|
+
* `path`, or `id` column. Plain comparison — no EXISTS — because the
|
|
448
|
+
* column lives directly on the outer relation (current-documents view),
|
|
449
|
+
* not in the EAV stores.
|
|
450
450
|
*/
|
|
451
451
|
private buildDocColumnFilter;
|
|
452
452
|
/**
|
|
@@ -296,6 +296,7 @@ export class DocumentQueries {
|
|
|
296
296
|
if (filters?.length) {
|
|
297
297
|
const outerScope = {
|
|
298
298
|
docVersionId: sql `${view.id}`,
|
|
299
|
+
documentId: sql `${view.document_id}`,
|
|
299
300
|
status: sql `${view.status}`,
|
|
300
301
|
path: this.pathProjection(sql `${view.document_id}`, locale),
|
|
301
302
|
};
|
|
@@ -363,6 +364,7 @@ export class DocumentQueries {
|
|
|
363
364
|
if (filters?.length) {
|
|
364
365
|
const outerScope = {
|
|
365
366
|
docVersionId: sql `${view.id}`,
|
|
367
|
+
documentId: sql `${view.document_id}`,
|
|
366
368
|
status: sql `${view.status}`,
|
|
367
369
|
path: this.pathProjection(sql `${view.document_id}`, locale),
|
|
368
370
|
};
|
|
@@ -496,6 +498,7 @@ export class DocumentQueries {
|
|
|
496
498
|
if (filters?.length) {
|
|
497
499
|
const outerScope = {
|
|
498
500
|
docVersionId: sql `${view.id}`,
|
|
501
|
+
documentId: sql `${view.document_id}`,
|
|
499
502
|
status: sql `${view.status}`,
|
|
500
503
|
path: this.pathProjection(sql `${view.document_id}`, filterLocale),
|
|
501
504
|
};
|
|
@@ -674,6 +677,7 @@ export class DocumentQueries {
|
|
|
674
677
|
if (filters?.length) {
|
|
675
678
|
const outerScope = {
|
|
676
679
|
docVersionId: sql `${currentDocumentsView.id}`,
|
|
680
|
+
documentId: sql `${currentDocumentsView.document_id}`,
|
|
677
681
|
status: sql `${currentDocumentsView.status}`,
|
|
678
682
|
path: this.pathProjection(sql `${currentDocumentsView.document_id}`, this.defaultContentLocale),
|
|
679
683
|
};
|
|
@@ -851,6 +855,7 @@ export class DocumentQueries {
|
|
|
851
855
|
for (const filter of filters) {
|
|
852
856
|
conditions.push(this.buildFilterExists(filter, locale, {
|
|
853
857
|
docVersionId: sql `d.id`,
|
|
858
|
+
documentId: sql `d.document_id`,
|
|
854
859
|
status: sql `d.status`,
|
|
855
860
|
path: this.pathProjection(sql `d.document_id`, locale),
|
|
856
861
|
}, readMode, 0));
|
|
@@ -980,13 +985,17 @@ export class DocumentQueries {
|
|
|
980
985
|
return sql `(${sql.join(childSql, joiner)})`;
|
|
981
986
|
}
|
|
982
987
|
/**
|
|
983
|
-
* Compile a `DocumentColumnFilter` against the outer scope's status
|
|
984
|
-
* path column. Plain comparison — no EXISTS — because the
|
|
985
|
-
* directly on the outer relation (
|
|
986
|
-
* EAV stores.
|
|
988
|
+
* Compile a `DocumentColumnFilter` against the outer scope's `status`,
|
|
989
|
+
* `path`, or `id` column. Plain comparison — no EXISTS — because the
|
|
990
|
+
* column lives directly on the outer relation (current-documents view),
|
|
991
|
+
* not in the EAV stores.
|
|
987
992
|
*/
|
|
988
993
|
buildDocColumnFilter(filter, outerScope) {
|
|
989
|
-
const column = filter.column === 'status'
|
|
994
|
+
const column = filter.column === 'status'
|
|
995
|
+
? outerScope.status
|
|
996
|
+
: filter.column === 'path'
|
|
997
|
+
? outerScope.path
|
|
998
|
+
: outerScope.documentId;
|
|
990
999
|
return this.buildFilterCondition(column, filter.operator, filter.value);
|
|
991
1000
|
}
|
|
992
1001
|
/**
|
|
@@ -1035,6 +1044,7 @@ export class DocumentQueries {
|
|
|
1035
1044
|
const tdAlias = sql.raw(`td${depth}`);
|
|
1036
1045
|
const innerScope = {
|
|
1037
1046
|
docVersionId: sql.raw(`td${depth}.id`),
|
|
1047
|
+
documentId: sql.raw(`td${depth}.document_id`),
|
|
1038
1048
|
status: sql.raw(`td${depth}.status`),
|
|
1039
1049
|
// `td${depth}.path` no longer exists on the view; resolve via the
|
|
1040
1050
|
// locale priority chain against byline_document_paths instead.
|
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": "2.
|
|
5
|
+
"version": "2.6.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/admin": "2.
|
|
61
|
-
"@byline/auth": "2.
|
|
62
|
-
"@byline/core": "2.
|
|
60
|
+
"@byline/admin": "2.6.0",
|
|
61
|
+
"@byline/auth": "2.6.0",
|
|
62
|
+
"@byline/core": "2.6.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@biomejs/biome": "2.4.15",
|