@qelos/sdk 2.0.22
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/.nvmrc +1 -0
- package/LICENSE +21 -0
- package/README.md +47 -0
- package/dist/administrator/drafts.d.ts +22 -0
- package/dist/administrator/drafts.js +34 -0
- package/dist/administrator/drafts.js.map +1 -0
- package/dist/administrator/events.d.ts +21 -0
- package/dist/administrator/events.js +21 -0
- package/dist/administrator/events.js.map +1 -0
- package/dist/administrator/index.d.ts +13 -0
- package/dist/administrator/index.js +19 -0
- package/dist/administrator/index.js.map +1 -0
- package/dist/administrator/layouts.d.ts +44 -0
- package/dist/administrator/layouts.js +29 -0
- package/dist/administrator/layouts.js.map +1 -0
- package/dist/administrator/users.d.ts +24 -0
- package/dist/administrator/users.js +49 -0
- package/dist/administrator/users.js.map +1 -0
- package/dist/administrator.d.ts +11 -0
- package/dist/administrator.js +16 -0
- package/dist/administrator.js.map +1 -0
- package/dist/authentication.d.ts +62 -0
- package/dist/authentication.js +88 -0
- package/dist/authentication.js.map +1 -0
- package/dist/base-gp-sdk.d.ts +8 -0
- package/dist/base-gp-sdk.js +26 -0
- package/dist/base-gp-sdk.js.map +1 -0
- package/dist/base-sdk.d.ts +8 -0
- package/dist/base-sdk.js +26 -0
- package/dist/base-sdk.js.map +1 -0
- package/dist/blocks.d.ts +18 -0
- package/dist/blocks.js +31 -0
- package/dist/blocks.js.map +1 -0
- package/dist/categories.d.ts +22 -0
- package/dist/categories.js +34 -0
- package/dist/categories.js.map +1 -0
- package/dist/configurations.d.ts +23 -0
- package/dist/configurations.js +19 -0
- package/dist/configurations.js.map +1 -0
- package/dist/drafts.d.ts +22 -0
- package/dist/drafts.js +34 -0
- package/dist/drafts.js.map +1 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +42 -0
- package/dist/index.js.map +1 -0
- package/dist/layouts.d.ts +44 -0
- package/dist/layouts.js +29 -0
- package/dist/layouts.js.map +1 -0
- package/dist/manage-layouts.d.ts +12 -0
- package/dist/manage-layouts.js +36 -0
- package/dist/manage-layouts.js.map +1 -0
- package/dist/menus.d.ts +36 -0
- package/dist/menus.js +31 -0
- package/dist/menus.js.map +1 -0
- package/dist/posts.d.ts +40 -0
- package/dist/posts.js +42 -0
- package/dist/posts.js.map +1 -0
- package/dist/types.d.ts +11 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/users.d.ts +24 -0
- package/dist/users.js +49 -0
- package/dist/users.js.map +1 -0
- package/package.json +18 -0
- package/src/administrator/drafts.ts +57 -0
- package/src/administrator/events.ts +40 -0
- package/src/administrator/index.ts +21 -0
- package/src/administrator/layouts.ts +56 -0
- package/src/administrator/users.ts +70 -0
- package/src/authentication.ts +139 -0
- package/src/base-sdk.ts +28 -0
- package/src/blocks.ts +49 -0
- package/src/categories.ts +62 -0
- package/src/configurations.ts +40 -0
- package/src/index.ts +45 -0
- package/src/manage-layouts.ts +48 -0
- package/src/menus.ts +67 -0
- package/src/posts.ts +91 -0
- package/src/types.ts +10 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { QelosSDKOptions } from "./types";
|
|
2
|
+
import BaseSDK from "./base-sdk";
|
|
3
|
+
import {ILayout, LayoutKind} from './administrator/layouts';
|
|
4
|
+
|
|
5
|
+
export default class GpManageLayouts extends BaseSDK {
|
|
6
|
+
private relativePath = "/api/layouts";
|
|
7
|
+
|
|
8
|
+
constructor(options: QelosSDKOptions) {
|
|
9
|
+
super(options);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
getLayout(kind: LayoutKind, extra?: Partial<RequestInit>) {
|
|
13
|
+
return this.callJsonApi<ILayout>(`${this.relativePath}/${kind}`, extra);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
getList(extra?: Partial<RequestInit>) {
|
|
17
|
+
return this.callJsonApi<ILayout[]>(this.relativePath, extra);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
remove(kind: LayoutKind, extra?: Partial<RequestInit>): Promise<any> {
|
|
21
|
+
return this.callApi(`${this.relativePath}/${kind}`, {
|
|
22
|
+
method: "delete",
|
|
23
|
+
...(extra || {}),
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
update(
|
|
28
|
+
kind: LayoutKind,
|
|
29
|
+
changes: Partial<ILayout>,
|
|
30
|
+
extra?: Partial<RequestInit>
|
|
31
|
+
): Promise<ILayout> {
|
|
32
|
+
return this.callJsonApi<ILayout>(`${this.relativePath}/${kind}`, {
|
|
33
|
+
method: "put",
|
|
34
|
+
headers: {'content-type': 'application/json'},
|
|
35
|
+
body: JSON.stringify(changes),
|
|
36
|
+
...(extra || {}),
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
create(layout: ILayout, extra?: Partial<RequestInit>): Promise<ILayout> {
|
|
41
|
+
return this.callJsonApi<ILayout>(this.relativePath, {
|
|
42
|
+
method: "post",
|
|
43
|
+
headers: {'content-type': 'application/json'},
|
|
44
|
+
body: JSON.stringify(layout),
|
|
45
|
+
...(extra || {}),
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
package/src/menus.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import {QelosSDKOptions} from './types';
|
|
2
|
+
import BaseSDK from './base-sdk';
|
|
3
|
+
|
|
4
|
+
export interface MenuLink {
|
|
5
|
+
_id?: string;
|
|
6
|
+
kind: 'category' | 'post' | 'http'
|
|
7
|
+
category?: {
|
|
8
|
+
name: string;
|
|
9
|
+
path: string;
|
|
10
|
+
};
|
|
11
|
+
post?: {
|
|
12
|
+
title: string;
|
|
13
|
+
path: string;
|
|
14
|
+
category: {
|
|
15
|
+
path: string;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
value?: {
|
|
19
|
+
text: string;
|
|
20
|
+
url: string;
|
|
21
|
+
newWindow: boolean;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface IMenu {
|
|
26
|
+
name: string;
|
|
27
|
+
links: MenuLink[];
|
|
28
|
+
|
|
29
|
+
[key: string]: any;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default class GpMenus extends BaseSDK {
|
|
33
|
+
private relativePath = '/api/menus';
|
|
34
|
+
|
|
35
|
+
constructor(options: QelosSDKOptions) {
|
|
36
|
+
super(options)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
getMenu(name: string) {
|
|
40
|
+
return this.callJsonApi<IMenu>(`${this.relativePath}/${encodeURI(name)}`)
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
getList() {
|
|
44
|
+
return this.callJsonApi<IMenu[]>(this.relativePath);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
remove(name: string): Promise<any> {
|
|
48
|
+
return this.callApi(`${this.relativePath}/${encodeURI(name)}`, {method: 'delete'});
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
update(name: string, changes: Partial<IMenu>): Promise<IMenu> {
|
|
52
|
+
return this.callJsonApi<IMenu>(
|
|
53
|
+
`${this.relativePath}/${encodeURI(name)}`, {
|
|
54
|
+
method: 'put',
|
|
55
|
+
headers: {'content-type': 'application/json'},
|
|
56
|
+
body: JSON.stringify(changes)
|
|
57
|
+
}
|
|
58
|
+
)
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
create(menu: IMenu): Promise<IMenu> {
|
|
62
|
+
return this.callJsonApi<IMenu>(this.relativePath, {
|
|
63
|
+
method: 'post',
|
|
64
|
+
headers: {'content-type': 'application/json'},
|
|
65
|
+
body: JSON.stringify(menu)})
|
|
66
|
+
}
|
|
67
|
+
}
|
package/src/posts.ts
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { QelosSDKOptions } from "./types";
|
|
2
|
+
import BaseSDK from "./base-sdk";
|
|
3
|
+
import { ICategory } from "./categories";
|
|
4
|
+
|
|
5
|
+
export enum PostContentState {
|
|
6
|
+
EDITOR = "editor",
|
|
7
|
+
HTML = "html",
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface IPost {
|
|
11
|
+
_id?: string;
|
|
12
|
+
title: string;
|
|
13
|
+
authors: any[];
|
|
14
|
+
thumbnail: string;
|
|
15
|
+
short: string;
|
|
16
|
+
contents: string[];
|
|
17
|
+
editorContentsStates: PostContentState[];
|
|
18
|
+
path: string;
|
|
19
|
+
tags: string[];
|
|
20
|
+
category: string | ICategory;
|
|
21
|
+
isPublic: boolean;
|
|
22
|
+
isPinned: boolean;
|
|
23
|
+
|
|
24
|
+
[key: string]: any;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export type GetPostsListOptions = {
|
|
28
|
+
target: "front" | "admin";
|
|
29
|
+
populate?: "string";
|
|
30
|
+
q?: string;
|
|
31
|
+
lean?: "true";
|
|
32
|
+
limit?: string;
|
|
33
|
+
offset?: string;
|
|
34
|
+
category: string;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default class GpPosts extends BaseSDK {
|
|
38
|
+
private relativePath = "/api/posts";
|
|
39
|
+
|
|
40
|
+
constructor(options: QelosSDKOptions) {
|
|
41
|
+
super(options);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
getByPath(
|
|
45
|
+
categoryPath: string,
|
|
46
|
+
postPath: string,
|
|
47
|
+
extra?: Partial<RequestInit>
|
|
48
|
+
) {
|
|
49
|
+
return this.callJsonApi<IPost>(
|
|
50
|
+
`${this.relativePath}/${encodeURI(categoryPath)}/${encodeURI(postPath)}`,
|
|
51
|
+
extra
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
getList(options: GetPostsListOptions, extra?: Partial<RequestInit>) {
|
|
56
|
+
const queryParams = new URLSearchParams(options);
|
|
57
|
+
return this.callJsonApi<IPost[]>(
|
|
58
|
+
`${this.relativePath}?${queryParams}`,
|
|
59
|
+
extra
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
remove(path: string, extra?: Partial<RequestInit>): Promise<Response> {
|
|
64
|
+
return this.callApi(`${this.relativePath}/${encodeURI(path)}`, {
|
|
65
|
+
method: "delete",
|
|
66
|
+
...(extra || {}),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
update(
|
|
71
|
+
path: string,
|
|
72
|
+
changes: Partial<IPost>,
|
|
73
|
+
extra?: Partial<RequestInit>
|
|
74
|
+
): Promise<IPost> {
|
|
75
|
+
return this.callJsonApi<IPost>(`${this.relativePath}/${encodeURI(path)}`, {
|
|
76
|
+
method: "put",
|
|
77
|
+
headers: {'content-type': 'application/json'},
|
|
78
|
+
body: JSON.stringify(changes),
|
|
79
|
+
...(extra || {}),
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
create(post: IPost, extra?: Partial<RequestInit>): Promise<IPost> {
|
|
84
|
+
return this.callJsonApi<IPost>(this.relativePath, {
|
|
85
|
+
method: "post",
|
|
86
|
+
headers: {'content-type': 'application/json'},
|
|
87
|
+
body: JSON.stringify(post),
|
|
88
|
+
...(extra || {}),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export type FetchLike = (input: RequestInfo, init?: RequestInit) => Promise<Response>;
|
|
2
|
+
|
|
3
|
+
export interface QelosSDKOptions {
|
|
4
|
+
appUrl: string;
|
|
5
|
+
fetch: FetchLike;
|
|
6
|
+
accessToken?: string;
|
|
7
|
+
refreshToken?: string;
|
|
8
|
+
getAccessToken?: () => undefined | string;
|
|
9
|
+
extraHeaders?: () => { [key: string]: string };
|
|
10
|
+
}
|