@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.
Files changed (80) hide show
  1. package/.nvmrc +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +47 -0
  4. package/dist/administrator/drafts.d.ts +22 -0
  5. package/dist/administrator/drafts.js +34 -0
  6. package/dist/administrator/drafts.js.map +1 -0
  7. package/dist/administrator/events.d.ts +21 -0
  8. package/dist/administrator/events.js +21 -0
  9. package/dist/administrator/events.js.map +1 -0
  10. package/dist/administrator/index.d.ts +13 -0
  11. package/dist/administrator/index.js +19 -0
  12. package/dist/administrator/index.js.map +1 -0
  13. package/dist/administrator/layouts.d.ts +44 -0
  14. package/dist/administrator/layouts.js +29 -0
  15. package/dist/administrator/layouts.js.map +1 -0
  16. package/dist/administrator/users.d.ts +24 -0
  17. package/dist/administrator/users.js +49 -0
  18. package/dist/administrator/users.js.map +1 -0
  19. package/dist/administrator.d.ts +11 -0
  20. package/dist/administrator.js +16 -0
  21. package/dist/administrator.js.map +1 -0
  22. package/dist/authentication.d.ts +62 -0
  23. package/dist/authentication.js +88 -0
  24. package/dist/authentication.js.map +1 -0
  25. package/dist/base-gp-sdk.d.ts +8 -0
  26. package/dist/base-gp-sdk.js +26 -0
  27. package/dist/base-gp-sdk.js.map +1 -0
  28. package/dist/base-sdk.d.ts +8 -0
  29. package/dist/base-sdk.js +26 -0
  30. package/dist/base-sdk.js.map +1 -0
  31. package/dist/blocks.d.ts +18 -0
  32. package/dist/blocks.js +31 -0
  33. package/dist/blocks.js.map +1 -0
  34. package/dist/categories.d.ts +22 -0
  35. package/dist/categories.js +34 -0
  36. package/dist/categories.js.map +1 -0
  37. package/dist/configurations.d.ts +23 -0
  38. package/dist/configurations.js +19 -0
  39. package/dist/configurations.js.map +1 -0
  40. package/dist/drafts.d.ts +22 -0
  41. package/dist/drafts.js +34 -0
  42. package/dist/drafts.js.map +1 -0
  43. package/dist/index.d.ts +20 -0
  44. package/dist/index.js +42 -0
  45. package/dist/index.js.map +1 -0
  46. package/dist/layouts.d.ts +44 -0
  47. package/dist/layouts.js +29 -0
  48. package/dist/layouts.js.map +1 -0
  49. package/dist/manage-layouts.d.ts +12 -0
  50. package/dist/manage-layouts.js +36 -0
  51. package/dist/manage-layouts.js.map +1 -0
  52. package/dist/menus.d.ts +36 -0
  53. package/dist/menus.js +31 -0
  54. package/dist/menus.js.map +1 -0
  55. package/dist/posts.d.ts +40 -0
  56. package/dist/posts.js +42 -0
  57. package/dist/posts.js.map +1 -0
  58. package/dist/types.d.ts +11 -0
  59. package/dist/types.js +2 -0
  60. package/dist/types.js.map +1 -0
  61. package/dist/users.d.ts +24 -0
  62. package/dist/users.js +49 -0
  63. package/dist/users.js.map +1 -0
  64. package/package.json +18 -0
  65. package/src/administrator/drafts.ts +57 -0
  66. package/src/administrator/events.ts +40 -0
  67. package/src/administrator/index.ts +21 -0
  68. package/src/administrator/layouts.ts +56 -0
  69. package/src/administrator/users.ts +70 -0
  70. package/src/authentication.ts +139 -0
  71. package/src/base-sdk.ts +28 -0
  72. package/src/blocks.ts +49 -0
  73. package/src/categories.ts +62 -0
  74. package/src/configurations.ts +40 -0
  75. package/src/index.ts +45 -0
  76. package/src/manage-layouts.ts +48 -0
  77. package/src/menus.ts +67 -0
  78. package/src/posts.ts +91 -0
  79. package/src/types.ts +10 -0
  80. 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
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "ESNext",
4
+ "target": "esnext",
5
+ "outDir": "./dist",
6
+ "sourceMap": true,
7
+ "declaration": true,
8
+ "skipLibCheck": true
9
+ },
10
+ "exclude": [
11
+ "node_modules",
12
+ "dist"
13
+ ]
14
+ }