includio-cms 0.0.10 → 0.0.11

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.
@@ -55,6 +55,7 @@ function generateAPI(config) {
55
55
 
56
56
  interface GetEntryQueryOptions<T extends { data: Record<string, unknown> }> {
57
57
  id?: string;
58
+ status?: 'draft' | 'published' | 'archived';
58
59
  dataValues?: Partial<T['data']>;
59
60
  }
60
61
 
@@ -1,7 +1,7 @@
1
1
  import { drizzle } from 'drizzle-orm/postgres-js';
2
2
  import postgres from 'postgres';
3
3
  import * as schema from './schema/index.js';
4
- import { eq, and, inArray, getTableColumns, sql } from 'drizzle-orm';
4
+ import { eq, and, inArray, getTableColumns, sql, isNull } from 'drizzle-orm';
5
5
  // Helper function to build JSON path conditions
6
6
  function buildJsonConditions(dataValue) {
7
7
  const conditions = [];
@@ -85,7 +85,9 @@ export function pg(config) {
85
85
  })
86
86
  .from(schema.entriesTable);
87
87
  if (options.data) {
88
- query.where(and(options.data.type ? eq(schema.entriesTable.type, options.data.type) : undefined, options.data.slug ? eq(schema.entriesTable.slug, options.data.slug) : undefined, options.data.ids ? inArray(schema.entriesTable.id, options.data.ids) : undefined, options.data.status ? eq(schema.entriesTable.status, options.data.status) : undefined));
88
+ query.where(and(options.data.type ? eq(schema.entriesTable.type, options.data.type) : undefined, options.data.slug ? eq(schema.entriesTable.slug, options.data.slug) : undefined, options.data.ids ? inArray(schema.entriesTable.id, options.data.ids) : undefined, options.data.status ? eq(schema.entriesTable.status, options.data.status) : undefined,
89
+ // Do not include deleted entries
90
+ isNull(schema.entriesTable.deletedAt)));
89
91
  if (options.data.ids) {
90
92
  query.where(inArray(schema.entriesTable.id, options.data.ids));
91
93
  }
@@ -104,7 +106,9 @@ export function pg(config) {
104
106
  options.data.type ? eq(schema.entriesTable.type, options.data.type) : undefined,
105
107
  options.data.slug ? eq(schema.entriesTable.slug, options.data.slug) : undefined,
106
108
  options.data.id ? eq(schema.entriesTable.id, options.data.id) : undefined,
107
- options.data.status ? eq(schema.entriesTable.status, options.data.status) : undefined
109
+ options.data.status ? eq(schema.entriesTable.status, options.data.status) : undefined,
110
+ // Do not include deleted entries
111
+ isNull(schema.entriesTable.deletedAt)
108
112
  ].filter(Boolean);
109
113
  // Add JSON data conditions if dataValue is provided
110
114
  const jsonConditions = options.data.dataValues
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "includio-cms",
3
- "version": "0.0.10",
3
+ "version": "0.0.11",
4
4
  "scripts": {
5
5
  "dev": "vite dev",
6
6
  "build": "vite build && npm run prepack",