@byline/db-postgres 2.5.2 → 2.6.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.
|
@@ -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)
|
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.1",
|
|
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/
|
|
61
|
-
"@byline/
|
|
62
|
-
"@byline/
|
|
60
|
+
"@byline/admin": "2.6.1",
|
|
61
|
+
"@byline/core": "2.6.1",
|
|
62
|
+
"@byline/auth": "2.6.1"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@biomejs/biome": "2.4.15",
|