talizen 0.1.2 → 0.1.3
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/README.md +11 -0
- package/cms.d.ts +6 -1
- package/cms.js +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -66,6 +66,17 @@ interface Blog extends BaseCmsItem {
|
|
|
66
66
|
const blog = await getContent<Blog>("blogs", "hello-world")
|
|
67
67
|
```
|
|
68
68
|
|
|
69
|
+
### Get CMS collection metadata
|
|
70
|
+
|
|
71
|
+
```ts
|
|
72
|
+
import { getContentCollection } from "talizen/cms"
|
|
73
|
+
|
|
74
|
+
const collection = await getContentCollection("blogs")
|
|
75
|
+
|
|
76
|
+
console.log(collection?.title)
|
|
77
|
+
console.log(collection?.jsonSchema)
|
|
78
|
+
```
|
|
79
|
+
|
|
69
80
|
### Submit a form
|
|
70
81
|
|
|
71
82
|
```ts
|
package/cms.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export interface BaseCmsItem {
|
|
|
7
7
|
}
|
|
8
8
|
export interface GetContentListFilterCondition {
|
|
9
9
|
fieldId?: string;
|
|
10
|
-
operator?:
|
|
10
|
+
operator?: "eq" | "neq" | "contains" | "not_contains";
|
|
11
11
|
value?: any;
|
|
12
12
|
}
|
|
13
13
|
export interface GetContentListFilter {
|
|
@@ -37,10 +37,15 @@ export interface ContentWithPrevNext<T extends BaseCmsItem> {
|
|
|
37
37
|
next?: T;
|
|
38
38
|
prev?: T;
|
|
39
39
|
}
|
|
40
|
+
export interface ContentCollection {
|
|
41
|
+
jsonSchema?: Record<string, unknown>;
|
|
42
|
+
title?: string;
|
|
43
|
+
}
|
|
40
44
|
export interface ListResponse<T> {
|
|
41
45
|
list?: T[];
|
|
42
46
|
total?: number;
|
|
43
47
|
}
|
|
48
|
+
export declare function getContentCollection(key: string, options?: TalizenRequestOptions): Promise<ContentCollection | null>;
|
|
44
49
|
export declare function listContents<T extends BaseCmsItem>(key: T["__cmsKey"], params?: ListContentParams, options?: TalizenRequestOptions): Promise<ListResponse<T>>;
|
|
45
50
|
export declare function getContent<T extends BaseCmsItem>(key: T["__cmsKey"], slug: string, params?: GetContentParams, options?: TalizenRequestOptions): Promise<T>;
|
|
46
51
|
export declare function getContentWithPrevNext<T extends BaseCmsItem>(key: T["__cmsKey"], slug: string, params?: GetContentWithPrevNextParams, options?: TalizenRequestOptions): Promise<ContentWithPrevNext<T>>;
|
package/cms.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { requestJson } from "./core.js";
|
|
2
|
+
export async function getContentCollection(key, options) {
|
|
3
|
+
return requestJson(`/cms/${key}`, undefined, options);
|
|
4
|
+
}
|
|
2
5
|
export async function listContents(key, params = {}, options) {
|
|
3
6
|
const response = await requestJson(`/cms/${key}/content_list`, {
|
|
4
7
|
method: "POST",
|