@pramen/cms 0.0.54 → 0.0.55
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/index.d.ts +18 -2
- package/dist/index.js +26 -1
- package/package.json +2 -2
- package/src/index.ts +25 -1
package/dist/index.d.ts
CHANGED
|
@@ -925,7 +925,15 @@ export declare function createCmsHandlers(opts?: CmsHandlerOpts): {
|
|
|
925
925
|
getContentType: import("@pramen/server").Handler<{
|
|
926
926
|
id: string;
|
|
927
927
|
}, Record<string, unknown>>;
|
|
928
|
-
|
|
928
|
+
/** List pages, newest first. `contentType` (a content-type SLUG) narrows the list to one
|
|
929
|
+
* type — what an editor that gives each type its own tab needs, and the only way to stay
|
|
930
|
+
* correct once a deployment has more than `limit` entries in total: filtering the full
|
|
931
|
+
* list client-side would silently drop the tail of every type. Omitted ⇒ all types, the
|
|
932
|
+
* historical behaviour. An unknown slug returns nothing rather than everything, so a
|
|
933
|
+
* typo can never read as "here is the whole CMS". */
|
|
934
|
+
listPages: import("@pramen/server").Handler<{
|
|
935
|
+
contentType?: string;
|
|
936
|
+
}, Record<string, unknown>[]>;
|
|
929
937
|
/** Public: list published pages (slug, locale, updatedAt) for sitemap generation. The
|
|
930
938
|
* anonymous ACL scopes cms_pages reads to status=published, so this is safe to expose. */
|
|
931
939
|
listPublishedPages: import("@pramen/server").Handler<unknown, {
|
|
@@ -1293,7 +1301,15 @@ export declare const cmsHandlers: {
|
|
|
1293
1301
|
getContentType: import("@pramen/server").Handler<{
|
|
1294
1302
|
id: string;
|
|
1295
1303
|
}, Record<string, unknown>>;
|
|
1296
|
-
|
|
1304
|
+
/** List pages, newest first. `contentType` (a content-type SLUG) narrows the list to one
|
|
1305
|
+
* type — what an editor that gives each type its own tab needs, and the only way to stay
|
|
1306
|
+
* correct once a deployment has more than `limit` entries in total: filtering the full
|
|
1307
|
+
* list client-side would silently drop the tail of every type. Omitted ⇒ all types, the
|
|
1308
|
+
* historical behaviour. An unknown slug returns nothing rather than everything, so a
|
|
1309
|
+
* typo can never read as "here is the whole CMS". */
|
|
1310
|
+
listPages: import("@pramen/server").Handler<{
|
|
1311
|
+
contentType?: string;
|
|
1312
|
+
}, Record<string, unknown>[]>;
|
|
1297
1313
|
/** Public: list published pages (slug, locale, updatedAt) for sitemap generation. The
|
|
1298
1314
|
* anonymous ACL scopes cms_pages reads to status=published, so this is safe to expose. */
|
|
1299
1315
|
listPublishedPages: import("@pramen/server").Handler<unknown, {
|
package/dist/index.js
CHANGED
|
@@ -1300,7 +1300,32 @@ export function createCmsHandlers(opts = {}) {
|
|
|
1300
1300
|
},
|
|
1301
1301
|
}),
|
|
1302
1302
|
// ---- pages ----
|
|
1303
|
-
|
|
1303
|
+
/** List pages, newest first. `contentType` (a content-type SLUG) narrows the list to one
|
|
1304
|
+
* type — what an editor that gives each type its own tab needs, and the only way to stay
|
|
1305
|
+
* correct once a deployment has more than `limit` entries in total: filtering the full
|
|
1306
|
+
* list client-side would silently drop the tail of every type. Omitted ⇒ all types, the
|
|
1307
|
+
* historical behaviour. An unknown slug returns nothing rather than everything, so a
|
|
1308
|
+
* typo can never read as "here is the whole CMS". */
|
|
1309
|
+
listPages: query(async (ctx, input) => {
|
|
1310
|
+
const db = cdb(ctx);
|
|
1311
|
+
const order = { column: "createdAt", dir: "desc" };
|
|
1312
|
+
if (!input?.contentType)
|
|
1313
|
+
return db.find({ from: "cms_pages", orderBy: order, limit: 100 });
|
|
1314
|
+
const types = await db.find({ from: "cms_content_types", where: { slug: input.contentType }, limit: 1 });
|
|
1315
|
+
const typeId = types[0]?.id;
|
|
1316
|
+
if (typeId == null)
|
|
1317
|
+
return [];
|
|
1318
|
+
return db.find({ from: "cms_pages", where: { typeId }, orderBy: order, limit: 100 });
|
|
1319
|
+
}, {
|
|
1320
|
+
input: (raw) => {
|
|
1321
|
+
const o = asObj(raw);
|
|
1322
|
+
if (o.contentType === undefined || o.contentType === null)
|
|
1323
|
+
return {};
|
|
1324
|
+
if (typeof o.contentType !== "string")
|
|
1325
|
+
throw new BadRequest("contentType must be a string");
|
|
1326
|
+
return { contentType: o.contentType };
|
|
1327
|
+
},
|
|
1328
|
+
}),
|
|
1304
1329
|
/** Public: list published pages (slug, locale, updatedAt) for sitemap generation. The
|
|
1305
1330
|
* anonymous ACL scopes cms_pages reads to status=published, so this is safe to expose. */
|
|
1306
1331
|
listPublishedPages: query(async (ctx) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pramen/cms",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.55",
|
|
4
4
|
"description": "Optional block/page builder for pramen — Drupal-Paragraphs-style typed blocks in named regions, reusable blocks, scheduled publishing, built entirely from pramen primitives.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"access": "public"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@pramen/server": "0.0.
|
|
44
|
+
"@pramen/server": "0.0.55"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
47
|
"react": ">=18"
|
package/src/index.ts
CHANGED
|
@@ -1752,7 +1752,31 @@ export function createCmsHandlers(opts: CmsHandlerOpts = {}) {
|
|
|
1752
1752
|
}),
|
|
1753
1753
|
|
|
1754
1754
|
// ---- pages ----
|
|
1755
|
-
|
|
1755
|
+
/** List pages, newest first. `contentType` (a content-type SLUG) narrows the list to one
|
|
1756
|
+
* type — what an editor that gives each type its own tab needs, and the only way to stay
|
|
1757
|
+
* correct once a deployment has more than `limit` entries in total: filtering the full
|
|
1758
|
+
* list client-side would silently drop the tail of every type. Omitted ⇒ all types, the
|
|
1759
|
+
* historical behaviour. An unknown slug returns nothing rather than everything, so a
|
|
1760
|
+
* typo can never read as "here is the whole CMS". */
|
|
1761
|
+
listPages: query(
|
|
1762
|
+
async (ctx, input: { contentType?: string }) => {
|
|
1763
|
+
const db = cdb(ctx);
|
|
1764
|
+
const order = { column: "createdAt", dir: "desc" } as const;
|
|
1765
|
+
if (!input?.contentType) return db.find({ from: "cms_pages", orderBy: order, limit: 100 });
|
|
1766
|
+
const types = await db.find({ from: "cms_content_types", where: { slug: input.contentType }, limit: 1 });
|
|
1767
|
+
const typeId = types[0]?.id;
|
|
1768
|
+
if (typeId == null) return [];
|
|
1769
|
+
return db.find({ from: "cms_pages", where: { typeId }, orderBy: order, limit: 100 });
|
|
1770
|
+
},
|
|
1771
|
+
{
|
|
1772
|
+
input: (raw): { contentType?: string } => {
|
|
1773
|
+
const o = asObj(raw);
|
|
1774
|
+
if (o.contentType === undefined || o.contentType === null) return {};
|
|
1775
|
+
if (typeof o.contentType !== "string") throw new BadRequest("contentType must be a string");
|
|
1776
|
+
return { contentType: o.contentType };
|
|
1777
|
+
},
|
|
1778
|
+
},
|
|
1779
|
+
),
|
|
1756
1780
|
|
|
1757
1781
|
/** Public: list published pages (slug, locale, updatedAt) for sitemap generation. The
|
|
1758
1782
|
* anonymous ACL scopes cms_pages reads to status=published, so this is safe to expose. */
|