@byline/db-postgres 1.8.1 → 1.8.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.
@@ -20,8 +20,8 @@
20
20
  * to 1; bumped by write paths when needed).
21
21
  * - snake_case column names matching the rest of the Byline schema.
22
22
  *
23
- * See docs/analysis/AUTHN-AUTHZ-ANALYSIS.md for the full data model and
24
- * phased rollout.
23
+ * See docs/AUTHN-AUTHZ.md for the full data model and present-state
24
+ * reference.
25
25
  */
26
26
  import { relations } from 'drizzle-orm';
27
27
  import { boolean, index, integer, pgTable, primaryKey, text, timestamp, unique, uuid, varchar, } from 'drizzle-orm/pg-core';
@@ -154,9 +154,10 @@ export declare class DocumentQueries implements IDocumentQueries {
154
154
  /**
155
155
  * getCurrentVersionMetadata — narrow metadata fetch for the current version.
156
156
  *
157
- * Hits `current_documents` only; no field reconstruction, no meta fetch.
158
- * Used by lifecycle operations (status changes, delete checks) that need
159
- * `document_version_id` / `status` / `path` but not the document body.
157
+ * Hits `current_documents` only; no field reconstruction, no meta fetch,
158
+ * no path subquery. Used by lifecycle operations (status changes,
159
+ * restore, delete checks) that only need `document_version_id` /
160
+ * `status` / timestamps before mutating.
160
161
  */
161
162
  getCurrentVersionMetadata({ collection_id, document_id, }: {
162
163
  collection_id: string;
@@ -165,7 +166,6 @@ export declare class DocumentQueries implements IDocumentQueries {
165
166
  document_version_id: string;
166
167
  document_id: string;
167
168
  collection_id: string;
168
- path: string;
169
169
  status: string;
170
170
  created_at: Date;
171
171
  updated_at: Date;
@@ -430,12 +430,15 @@ export declare class DocumentQueries implements IDocumentQueries {
430
430
  * Build a comparison condition for a filter operator.
431
431
  */
432
432
  private buildFilterCondition;
433
- /**
434
- * Build a condition for a document-level column (status, path).
435
- */
436
- private buildDocumentLevelCondition;
437
433
  /**
438
434
  * Build an ORDER BY clause for a document-level column.
435
+ *
436
+ * `path` is intentionally not sortable here: it lives in
437
+ * `byline_document_paths` (locale-resolved per request) rather than on
438
+ * the version row, so a literal `d.path` reference would refer to a
439
+ * non-existent column. Sorting documents by URL slug has no meaningful
440
+ * call site today; reintroduce via `pathProjection` if a real need
441
+ * arrives.
439
442
  */
440
443
  private buildDocumentOrderClause;
441
444
  /**
@@ -249,9 +249,10 @@ export class DocumentQueries {
249
249
  /**
250
250
  * getCurrentVersionMetadata — narrow metadata fetch for the current version.
251
251
  *
252
- * Hits `current_documents` only; no field reconstruction, no meta fetch.
253
- * Used by lifecycle operations (status changes, delete checks) that need
254
- * `document_version_id` / `status` / `path` but not the document body.
252
+ * Hits `current_documents` only; no field reconstruction, no meta fetch,
253
+ * no path subquery. Used by lifecycle operations (status changes,
254
+ * restore, delete checks) that only need `document_version_id` /
255
+ * `status` / timestamps before mutating.
255
256
  */
256
257
  async getCurrentVersionMetadata({ collection_id, document_id, }) {
257
258
  const [row] = await this.db
@@ -259,10 +260,6 @@ export class DocumentQueries {
259
260
  document_version_id: currentDocumentsView.id,
260
261
  document_id: currentDocumentsView.document_id,
261
262
  collection_id: currentDocumentsView.collection_id,
262
- // Lifecycle metadata fetch — always reads the default-locale path.
263
- // This is internal lifecycle plumbing (status changes, delete checks),
264
- // not a user-facing read, so the request locale never applies.
265
- path: this.pathProjection(sql `${currentDocumentsView.document_id}`),
266
263
  status: currentDocumentsView.status,
267
264
  created_at: currentDocumentsView.created_at,
268
265
  updated_at: currentDocumentsView.updated_at,
@@ -276,7 +273,6 @@ export class DocumentQueries {
276
273
  document_version_id: row.document_version_id,
277
274
  document_id: row.document_id,
278
275
  collection_id: row.collection_id ?? '',
279
- path: row.path ?? '',
280
276
  status: row.status ?? 'draft',
281
277
  created_at: row.created_at ?? new Date(),
282
278
  updated_at: row.updated_at ?? new Date(),
@@ -1030,21 +1026,20 @@ export class DocumentQueries {
1030
1026
  }).log(getLogger());
1031
1027
  }
1032
1028
  }
1033
- /**
1034
- * Build a condition for a document-level column (status, path).
1035
- */
1036
- buildDocumentLevelCondition(column, operator, value) {
1037
- const col = sql.raw(column);
1038
- return this.buildFilterCondition(col, operator, value);
1039
- }
1040
1029
  /**
1041
1030
  * Build an ORDER BY clause for a document-level column.
1031
+ *
1032
+ * `path` is intentionally not sortable here: it lives in
1033
+ * `byline_document_paths` (locale-resolved per request) rather than on
1034
+ * the version row, so a literal `d.path` reference would refer to a
1035
+ * non-existent column. Sorting documents by URL slug has no meaningful
1036
+ * call site today; reintroduce via `pathProjection` if a real need
1037
+ * arrives.
1042
1038
  */
1043
1039
  buildDocumentOrderClause(orderBy, direction) {
1044
1040
  const columnMap = {
1045
1041
  created_at: 'd.created_at',
1046
1042
  updated_at: 'd.updated_at',
1047
- path: 'd.path',
1048
1043
  };
1049
1044
  const col = columnMap[orderBy] ?? 'd.created_at';
1050
1045
  return direction === 'desc' ? sql `${sql.raw(col)} DESC` : sql `${sql.raw(col)} ASC`;
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": "1.8.1",
5
+ "version": "1.8.2",
6
6
  "engines": {
7
7
  "node": ">=20.9.0"
8
8
  },
@@ -52,9 +52,9 @@
52
52
  "pg": "^8.20.0",
53
53
  "uuid": "^14.0.0",
54
54
  "zod": "^4.4.2",
55
- "@byline/auth": "1.8.1",
56
- "@byline/core": "1.8.1",
57
- "@byline/admin": "1.8.1"
55
+ "@byline/auth": "1.8.2",
56
+ "@byline/core": "1.8.2",
57
+ "@byline/admin": "1.8.2"
58
58
  },
59
59
  "devDependencies": {
60
60
  "@biomejs/biome": "2.4.14",