@xleddyl/nuxt-cms 0.9.3 → 0.9.4

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/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xleddyl/nuxt-cms",
3
3
  "configKey": "cms",
4
- "version": "0.9.3",
4
+ "version": "0.9.4",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "unknown"
@@ -8,6 +8,7 @@ import { listOrderBy, listWhere, readListFilters } from "../utils/list-query.js"
8
8
  import { readPages } from "../utils/page-storage.js";
9
9
  import { attachManyToMany, relationTitles } from "../utils/relations.js";
10
10
  import { requireAdmin } from "../utils/require-admin.js";
11
+ import { singleRowFirst } from "../utils/single-row.js";
11
12
  const querySchema = z.object({
12
13
  limit: z.coerce.number().int().min(1).max(100).default(50),
13
14
  offset: z.coerce.number().int().min(0).default(0),
@@ -21,7 +22,7 @@ export default defineEventHandler(async (event) => {
21
22
  const { name, entry, table } = getRegistryEntry(event);
22
23
  const db = useDb();
23
24
  if (entry.kind === "single") {
24
- const rows = await db.select().from(table).limit(1);
25
+ const rows = await db.select().from(table).orderBy(singleRowFirst(idColumn(table), entry.id)).limit(1);
25
26
  await attachManyToMany(db, name, entry, rows);
26
27
  return decodeRows(entry, rows)[0] ?? null;
27
28
  }
@@ -51,6 +51,7 @@ import {
51
51
  listFilterValues
52
52
  } from "./list-filter.js";
53
53
  import { getContentI18n, resolveTable, tableColumns } from "./registry.js";
54
+ import { singleRowFirst } from "./single-row.js";
54
55
  import { visibilityConditions } from "./visibility.js";
55
56
  const MAX_LIMIT = 100;
56
57
  const DEFAULT_LIMIT = 50;
@@ -383,7 +384,7 @@ export function buildCmsSchema() {
383
384
  const locale = resolveLocaleArg(args.locale);
384
385
  const table = tableFor(name);
385
386
  const published = publishedFilter(entry, table);
386
- const [row] = await useDb().select().from(table).where(published.length ? and(...published) : void 0).limit(1);
387
+ const [row] = await useDb().select().from(table).where(published.length ? and(...published) : void 0).orderBy(singleRowFirst(tableColumns(table).id, entry.id)).limit(1);
387
388
  return row ? localizeRow(entry, row, locale) : null;
388
389
  };
389
390
  continue;
@@ -0,0 +1,3 @@
1
+ import type { SQL } from 'drizzle-orm';
2
+ import type { AnySQLiteColumn } from 'drizzle-orm/sqlite-core';
3
+ export declare function singleRowFirst(idColumn: AnySQLiteColumn, id: string): SQL;
@@ -0,0 +1,4 @@
1
+ import { sql } from "drizzle-orm";
2
+ export function singleRowFirst(idColumn, id) {
3
+ return sql`case when ${idColumn} = ${id} then 0 else 1 end`;
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xleddyl/nuxt-cms",
3
- "version": "0.9.3",
3
+ "version": "0.9.4",
4
4
  "description": "Lightweight CMS that ships with your Nuxt app: runs on the Nitro server, content types defined in code, /cms admin panel, GraphQL API, SQLite or Postgres. No external CMS needed!",
5
5
  "license": "MIT",
6
6
  "author": "Edoardo Alberti (https://github.com/xleddyl)",
@@ -69,7 +69,7 @@
69
69
  "@tiptap/pm": "^3.32.0",
70
70
  "@tiptap/starter-kit": "^3.32.0",
71
71
  "@tiptap/vue-3": "^3.32.0",
72
- "@xleddyl/443-components-vue": "^0.16.51",
72
+ "@xleddyl/443-components-vue": "^0.16.88",
73
73
  "aws4fetch": "^1.0.20",
74
74
  "drizzle-kit": "^0.31.0",
75
75
  "drizzle-orm": "^0.44.0",