@byline/db-postgres 3.7.0 → 3.8.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.
- package/dist/modules/admin/admin-users-repository.js +6 -1
- package/dist/modules/storage/storage-commands.d.ts +2 -0
- package/dist/modules/storage/storage-commands.js +5 -2
- package/dist/modules/storage/storage-queries.d.ts +8 -0
- package/dist/modules/storage/storage-queries.js +10 -0
- package/package.json +4 -4
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* Copyright (c) Infonomic Company Limited
|
|
7
7
|
*/
|
|
8
8
|
import { ERR_ADMIN_USER_VERSION_CONFLICT, } from '@byline/admin/admin-users';
|
|
9
|
-
import { and, asc, desc, eq, ilike, or, sql } from 'drizzle-orm';
|
|
9
|
+
import { and, asc, desc, eq, ilike, inArray, or, sql } from 'drizzle-orm';
|
|
10
10
|
import { v7 as uuidv7 } from 'uuid';
|
|
11
11
|
import { adminUsers } from '../../database/schema/auth.js';
|
|
12
12
|
/**
|
|
@@ -78,6 +78,11 @@ export function createAdminUsersRepository(db) {
|
|
|
78
78
|
const [row] = await db.select(PUBLIC_COLUMNS).from(adminUsers).where(eq(adminUsers.id, id));
|
|
79
79
|
return row ?? null;
|
|
80
80
|
},
|
|
81
|
+
async getByIds(ids) {
|
|
82
|
+
if (ids.length === 0)
|
|
83
|
+
return [];
|
|
84
|
+
return db.select(PUBLIC_COLUMNS).from(adminUsers).where(inArray(adminUsers.id, ids));
|
|
85
|
+
},
|
|
81
86
|
async getByEmail(email) {
|
|
82
87
|
const [row] = await db
|
|
83
88
|
.select(PUBLIC_COLUMNS)
|
|
@@ -245,6 +245,7 @@ export declare class DocumentCommands implements IDocumentCommands {
|
|
|
245
245
|
documentId: string;
|
|
246
246
|
locale: string;
|
|
247
247
|
status?: string;
|
|
248
|
+
createdBy?: string;
|
|
248
249
|
}): Promise<{
|
|
249
250
|
newVersionId: string;
|
|
250
251
|
previousVersionId: string;
|
|
@@ -268,6 +269,7 @@ export declare class DocumentCommands implements IDocumentCommands {
|
|
|
268
269
|
documentId: string;
|
|
269
270
|
targetLocale: string;
|
|
270
271
|
dryRun?: boolean;
|
|
272
|
+
createdBy?: string;
|
|
271
273
|
}): Promise<ReAnchorResult>;
|
|
272
274
|
/**
|
|
273
275
|
* reAnchorDocuments
|
|
@@ -111,6 +111,7 @@ export class DocumentCommands {
|
|
|
111
111
|
collection_version: params.collectionVersion,
|
|
112
112
|
event_type: params.action ?? 'create',
|
|
113
113
|
status: params.status ?? 'draft',
|
|
114
|
+
created_by: params.createdBy ?? null,
|
|
114
115
|
})
|
|
115
116
|
.returning()
|
|
116
117
|
.then(getFirstOrThrow('Failed to create document version'));
|
|
@@ -498,7 +499,7 @@ export class DocumentCommands {
|
|
|
498
499
|
* existence first, so this is a guard).
|
|
499
500
|
*/
|
|
500
501
|
async deleteDocumentLocale(params) {
|
|
501
|
-
const { documentId, locale, status } = params;
|
|
502
|
+
const { documentId, locale, status, createdBy } = params;
|
|
502
503
|
return this.db.transaction(async (tx) => {
|
|
503
504
|
// 1. Current (latest, non-deleted) version + the document's anchor.
|
|
504
505
|
const current = await tx
|
|
@@ -529,6 +530,7 @@ export class DocumentCommands {
|
|
|
529
530
|
event_type: 'delete_locale',
|
|
530
531
|
status: status ?? 'draft',
|
|
531
532
|
change_summary: `deleted content locale ${locale}`,
|
|
533
|
+
created_by: createdBy ?? null,
|
|
532
534
|
});
|
|
533
535
|
await this.copyAllVersionStoreRows(tx, current.versionId, newVersionId, locale);
|
|
534
536
|
// 3. Recompute the new version's availability ledger against the source
|
|
@@ -553,7 +555,7 @@ export class DocumentCommands {
|
|
|
553
555
|
* docs/I18N.md.
|
|
554
556
|
*/
|
|
555
557
|
async reAnchorDocument(params) {
|
|
556
|
-
const { documentId, targetLocale, dryRun = false } = params;
|
|
558
|
+
const { documentId, targetLocale, dryRun = false, createdBy } = params;
|
|
557
559
|
return this.db.transaction(async (tx) => {
|
|
558
560
|
// 1. Current (latest, non-deleted) version + the document's anchor.
|
|
559
561
|
const current = await tx
|
|
@@ -613,6 +615,7 @@ export class DocumentCommands {
|
|
|
613
615
|
event_type: 'update',
|
|
614
616
|
status: current.status ?? 'draft',
|
|
615
617
|
change_summary: `re-anchored content source locale ${fromLocale} → ${targetLocale}`,
|
|
618
|
+
created_by: createdBy ?? null,
|
|
616
619
|
});
|
|
617
620
|
await this.copyAllVersionStoreRows(tx, current.versionId, newVersionId);
|
|
618
621
|
// 6. Ledger for the new version, computed against the new source locale.
|
|
@@ -256,8 +256,10 @@ export declare class DocumentQueries implements IDocumentQueries {
|
|
|
256
256
|
path: string;
|
|
257
257
|
source_locale: string;
|
|
258
258
|
status: string | null;
|
|
259
|
+
event_type: string;
|
|
259
260
|
created_at: Date;
|
|
260
261
|
updated_at: Date;
|
|
262
|
+
created_by: string | null;
|
|
261
263
|
fields: any;
|
|
262
264
|
availableLocales: string[];
|
|
263
265
|
_availableVersionLocales: string[];
|
|
@@ -268,8 +270,10 @@ export declare class DocumentQueries implements IDocumentQueries {
|
|
|
268
270
|
path: string;
|
|
269
271
|
source_locale: string;
|
|
270
272
|
status: string | null;
|
|
273
|
+
event_type: string;
|
|
271
274
|
created_at: Date;
|
|
272
275
|
updated_at: Date;
|
|
276
|
+
created_by: string | null;
|
|
273
277
|
fields: FlattenedStore[];
|
|
274
278
|
} | null>;
|
|
275
279
|
getDocumentByPath({ collection_id, path, locale, reconstruct, readMode, filters, onMissingLocale, }: {
|
|
@@ -286,8 +290,10 @@ export declare class DocumentQueries implements IDocumentQueries {
|
|
|
286
290
|
path: string;
|
|
287
291
|
source_locale: string;
|
|
288
292
|
status: string | null;
|
|
293
|
+
event_type: string;
|
|
289
294
|
created_at: Date;
|
|
290
295
|
updated_at: Date;
|
|
296
|
+
created_by: string | null;
|
|
291
297
|
fields: any;
|
|
292
298
|
availableLocales: string[];
|
|
293
299
|
_availableVersionLocales: string[];
|
|
@@ -298,8 +304,10 @@ export declare class DocumentQueries implements IDocumentQueries {
|
|
|
298
304
|
path: string;
|
|
299
305
|
source_locale: string;
|
|
300
306
|
status: string | null;
|
|
307
|
+
event_type: string;
|
|
301
308
|
created_at: Date;
|
|
302
309
|
updated_at: Date;
|
|
310
|
+
created_by: string | null;
|
|
303
311
|
fields: FlattenedStore[];
|
|
304
312
|
availableLocales?: undefined;
|
|
305
313
|
_availableVersionLocales?: undefined;
|
|
@@ -531,8 +531,10 @@ export class DocumentQueries {
|
|
|
531
531
|
path: document.path ?? '',
|
|
532
532
|
source_locale: document.source_locale ?? null,
|
|
533
533
|
status: document.status,
|
|
534
|
+
event_type: document.event_type,
|
|
534
535
|
created_at: document.created_at,
|
|
535
536
|
updated_at: document.updated_at,
|
|
537
|
+
created_by: document.created_by ?? null,
|
|
536
538
|
fields,
|
|
537
539
|
availableLocales: advertised ?? [],
|
|
538
540
|
_availableVersionLocales: availability?.availableLocales ?? [],
|
|
@@ -548,8 +550,10 @@ export class DocumentQueries {
|
|
|
548
550
|
path: document.path ?? '',
|
|
549
551
|
source_locale: document.source_locale ?? null,
|
|
550
552
|
status: document.status,
|
|
553
|
+
event_type: document.event_type,
|
|
551
554
|
created_at: document.created_at,
|
|
552
555
|
updated_at: document.updated_at,
|
|
556
|
+
created_by: document.created_by ?? null,
|
|
553
557
|
fields: fieldValues,
|
|
554
558
|
};
|
|
555
559
|
}
|
|
@@ -612,8 +616,10 @@ export class DocumentQueries {
|
|
|
612
616
|
path: document.path ?? '',
|
|
613
617
|
source_locale: document.source_locale ?? null,
|
|
614
618
|
status: document.status,
|
|
619
|
+
event_type: document.event_type,
|
|
615
620
|
created_at: document.created_at,
|
|
616
621
|
updated_at: document.updated_at,
|
|
622
|
+
created_by: document.created_by ?? null,
|
|
617
623
|
fields,
|
|
618
624
|
availableLocales: advertised ?? [],
|
|
619
625
|
_availableVersionLocales: availability?.availableLocales ?? [],
|
|
@@ -628,8 +634,10 @@ export class DocumentQueries {
|
|
|
628
634
|
path: document.path ?? '',
|
|
629
635
|
source_locale: document.source_locale ?? null,
|
|
630
636
|
status: document.status,
|
|
637
|
+
event_type: document.event_type,
|
|
631
638
|
created_at: document.created_at,
|
|
632
639
|
updated_at: document.updated_at,
|
|
640
|
+
created_by: document.created_by ?? null,
|
|
633
641
|
fields: fieldValues,
|
|
634
642
|
};
|
|
635
643
|
}
|
|
@@ -999,8 +1007,10 @@ export class DocumentQueries {
|
|
|
999
1007
|
path: doc.path ?? '',
|
|
1000
1008
|
source_locale: doc.source_locale ?? null,
|
|
1001
1009
|
status: doc.status,
|
|
1010
|
+
event_type: doc.event_type,
|
|
1002
1011
|
created_at: doc.created_at,
|
|
1003
1012
|
updated_at: doc.updated_at,
|
|
1013
|
+
created_by: doc.created_by ?? null,
|
|
1004
1014
|
fields: trimmedFields,
|
|
1005
1015
|
};
|
|
1006
1016
|
result.push(documentWithFields);
|
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.8.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": "3.
|
|
61
|
-
"@byline/auth": "3.
|
|
62
|
-
"@byline/core": "3.
|
|
60
|
+
"@byline/admin": "3.8.0",
|
|
61
|
+
"@byline/auth": "3.8.0",
|
|
62
|
+
"@byline/core": "3.8.0"
|
|
63
63
|
},
|
|
64
64
|
"devDependencies": {
|
|
65
65
|
"@biomejs/biome": "2.4.15",
|