glitch-javascript-sdk 0.3.1 → 0.3.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/dist/cjs/index.js +128 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Posts.d.ts +53 -0
- package/dist/esm/api/index.d.ts +2 -0
- package/dist/esm/constants/ContentStatus.d.ts +9 -0
- package/dist/esm/constants/PostTypes.d.ts +7 -0
- package/dist/esm/index.d.ts +20 -0
- package/dist/esm/index.js +128 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/PostsRoute.d.ts +7 -0
- package/dist/esm/util/LabelManager.d.ts +13 -0
- package/dist/index.d.ts +82 -0
- package/package.json +1 -1
- package/src/api/Posts.ts +77 -0
- package/src/api/index.ts +2 -0
- package/src/config/Config.ts +3 -0
- package/src/constants/ContentStatus.ts +9 -0
- package/src/constants/PostTypes.ts +7 -0
- package/src/index.ts +8 -0
- package/src/routes/PostsRoute.ts +16 -0
- package/src/util/LabelManager.ts +39 -0
- package/src/constants/api_routes.js +0 -397
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
interface CommunityLabels {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
}
|
|
4
|
+
declare class LabelManager {
|
|
5
|
+
private static community;
|
|
6
|
+
static initialize(community: CommunityLabels): void;
|
|
7
|
+
private static getLabel;
|
|
8
|
+
static getUserLabel(plural: boolean, capitalize: boolean): string;
|
|
9
|
+
static getCompetitionLabel(plural: boolean, capitalize: boolean): string;
|
|
10
|
+
static getStreamLabel(plural: boolean, capitalize: boolean): string;
|
|
11
|
+
static getPostLabel(plural: boolean, capitalize: boolean): string;
|
|
12
|
+
}
|
|
13
|
+
export default LabelManager;
|
package/dist/index.d.ts
CHANGED
|
@@ -1393,6 +1393,57 @@ declare class Waitlists {
|
|
|
1393
1393
|
static delete<T>(waitlist_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1394
1394
|
}
|
|
1395
1395
|
|
|
1396
|
+
declare class Posts {
|
|
1397
|
+
/**
|
|
1398
|
+
* List all the Posts.
|
|
1399
|
+
*
|
|
1400
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList
|
|
1401
|
+
*
|
|
1402
|
+
* @returns promise
|
|
1403
|
+
*/
|
|
1404
|
+
static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1405
|
+
/**
|
|
1406
|
+
* Create a new post.
|
|
1407
|
+
*
|
|
1408
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/newPostResourceStorage
|
|
1409
|
+
*
|
|
1410
|
+
* @param data The data to be passed when creating a post.
|
|
1411
|
+
*
|
|
1412
|
+
* @returns Promise
|
|
1413
|
+
*/
|
|
1414
|
+
static create<T>(data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1415
|
+
/**
|
|
1416
|
+
* Update a post.
|
|
1417
|
+
*
|
|
1418
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/updatePostStorage
|
|
1419
|
+
*
|
|
1420
|
+
* @param post_id The id of the post to update.
|
|
1421
|
+
* @param data The data to update.
|
|
1422
|
+
*
|
|
1423
|
+
* @returns promise
|
|
1424
|
+
*/
|
|
1425
|
+
static update<T>(post_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1426
|
+
/**
|
|
1427
|
+
* Retrieve the information for a single post.
|
|
1428
|
+
*
|
|
1429
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
|
|
1430
|
+
*
|
|
1431
|
+
* @param post_id The id fo the post to retrieve.
|
|
1432
|
+
*
|
|
1433
|
+
* @returns promise
|
|
1434
|
+
*/
|
|
1435
|
+
static view<T>(post_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1436
|
+
/**
|
|
1437
|
+
* Deletes a post.
|
|
1438
|
+
*
|
|
1439
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage
|
|
1440
|
+
*
|
|
1441
|
+
* @param post_id The id of the post to delete.
|
|
1442
|
+
* @returns promise
|
|
1443
|
+
*/
|
|
1444
|
+
static delete<T>(post_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
1445
|
+
}
|
|
1446
|
+
|
|
1396
1447
|
declare class Templates {
|
|
1397
1448
|
/**
|
|
1398
1449
|
* List all the templates.
|
|
@@ -1594,6 +1645,19 @@ declare class Data {
|
|
|
1594
1645
|
static convertToHHMMSS(time: string | undefined): string | undefined;
|
|
1595
1646
|
}
|
|
1596
1647
|
|
|
1648
|
+
interface CommunityLabels {
|
|
1649
|
+
[key: string]: string;
|
|
1650
|
+
}
|
|
1651
|
+
declare class LabelManager {
|
|
1652
|
+
private static community;
|
|
1653
|
+
static initialize(community: CommunityLabels): void;
|
|
1654
|
+
private static getLabel;
|
|
1655
|
+
static getUserLabel(plural: boolean, capitalize: boolean): string;
|
|
1656
|
+
static getCompetitionLabel(plural: boolean, capitalize: boolean): string;
|
|
1657
|
+
static getStreamLabel(plural: boolean, capitalize: boolean): string;
|
|
1658
|
+
static getPostLabel(plural: boolean, capitalize: boolean): string;
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1597
1661
|
declare enum Modes {
|
|
1598
1662
|
BROADCAST = 0,
|
|
1599
1663
|
OBS = 1,
|
|
@@ -1666,6 +1730,7 @@ declare class Glitch {
|
|
|
1666
1730
|
Users: typeof Users;
|
|
1667
1731
|
Events: typeof Events;
|
|
1668
1732
|
Teams: typeof Teams;
|
|
1733
|
+
Posts: typeof Posts;
|
|
1669
1734
|
Templates: typeof Templates;
|
|
1670
1735
|
Waitlists: typeof Waitlists;
|
|
1671
1736
|
};
|
|
@@ -1675,6 +1740,7 @@ declare class Glitch {
|
|
|
1675
1740
|
Session: typeof Session;
|
|
1676
1741
|
Storage: typeof Storage;
|
|
1677
1742
|
Data: typeof Data;
|
|
1743
|
+
LabelManager: typeof LabelManager;
|
|
1678
1744
|
};
|
|
1679
1745
|
static constants: {
|
|
1680
1746
|
AcceptanceStatus: Readonly<{
|
|
@@ -1703,7 +1769,23 @@ declare class Glitch {
|
|
|
1703
1769
|
SEMI_ROUND_ROBINS: 8;
|
|
1704
1770
|
EXTENDED: 9;
|
|
1705
1771
|
}>;
|
|
1772
|
+
ContentStatus: Readonly<{
|
|
1773
|
+
UNAPPROVED: 0;
|
|
1774
|
+
APPROVED: 1;
|
|
1775
|
+
IN_REVIEW: 2;
|
|
1776
|
+
PENDING: 3;
|
|
1777
|
+
FLAGGED: 4;
|
|
1778
|
+
REMOVED: 5;
|
|
1779
|
+
DELETED: 6;
|
|
1780
|
+
}>;
|
|
1706
1781
|
Modes: typeof Modes;
|
|
1782
|
+
PostTypes: Readonly<{
|
|
1783
|
+
TEXT: "text";
|
|
1784
|
+
LINK: "link";
|
|
1785
|
+
POLL: "poll";
|
|
1786
|
+
IMAGE: "image";
|
|
1787
|
+
VIDEO: "video";
|
|
1788
|
+
}>;
|
|
1707
1789
|
Roles: typeof Roles;
|
|
1708
1790
|
TeamJoinProcess: typeof TeamJoinProcess;
|
|
1709
1791
|
TicketTypes: typeof TicketTypes;
|
package/package.json
CHANGED
package/src/api/Posts.ts
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import PostsRoute from "../routes/PostsRoute";
|
|
2
|
+
import Requests from "../util/Requests";
|
|
3
|
+
import Response from "../util/Response";
|
|
4
|
+
import { AxiosPromise } from "axios";
|
|
5
|
+
|
|
6
|
+
class Posts {
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* List all the Posts.
|
|
10
|
+
*
|
|
11
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList
|
|
12
|
+
*
|
|
13
|
+
* @returns promise
|
|
14
|
+
*/
|
|
15
|
+
public static list<T>(params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
16
|
+
return Requests.processRoute(PostsRoute.routes.list, undefined, undefined, params);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Create a new post.
|
|
21
|
+
*
|
|
22
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/newPostResourceStorage
|
|
23
|
+
*
|
|
24
|
+
* @param data The data to be passed when creating a post.
|
|
25
|
+
*
|
|
26
|
+
* @returns Promise
|
|
27
|
+
*/
|
|
28
|
+
public static create<T>(data : object, params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
29
|
+
|
|
30
|
+
return Requests.processRoute(PostsRoute.routes.create, data, undefined, params);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Update a post.
|
|
35
|
+
*
|
|
36
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/updatePostStorage
|
|
37
|
+
*
|
|
38
|
+
* @param post_id The id of the post to update.
|
|
39
|
+
* @param data The data to update.
|
|
40
|
+
*
|
|
41
|
+
* @returns promise
|
|
42
|
+
*/
|
|
43
|
+
public static update<T>(post_id : string, data : object, params?: Record<string, any>) : AxiosPromise<Response<T>>{
|
|
44
|
+
|
|
45
|
+
return Requests.processRoute(PostsRoute.routes.update, data, {post_id : post_id}, params);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Retrieve the information for a single post.
|
|
50
|
+
*
|
|
51
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
|
|
52
|
+
*
|
|
53
|
+
* @param post_id The id fo the post to retrieve.
|
|
54
|
+
*
|
|
55
|
+
* @returns promise
|
|
56
|
+
*/
|
|
57
|
+
public static view<T>(post_id : string, params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
58
|
+
|
|
59
|
+
return Requests.processRoute(PostsRoute.routes.view, {}, {post_id : post_id}, params);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Deletes a post.
|
|
64
|
+
*
|
|
65
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage
|
|
66
|
+
*
|
|
67
|
+
* @param post_id The id of the post to delete.
|
|
68
|
+
* @returns promise
|
|
69
|
+
*/
|
|
70
|
+
public static delete<T>(post_id : string, params?: Record<string, any>) : AxiosPromise<Response<T>> {
|
|
71
|
+
|
|
72
|
+
return Requests.processRoute(PostsRoute.routes.delete, {}, {post_id : post_id}, params);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export default Posts;
|
package/src/api/index.ts
CHANGED
|
@@ -5,6 +5,7 @@ import Users from "./Users";
|
|
|
5
5
|
import Events from "./Events";
|
|
6
6
|
import Teams from "./Teams";
|
|
7
7
|
import Waitlists from "./Waitlist";
|
|
8
|
+
import Posts from "./Posts";
|
|
8
9
|
import Templates from "./Templates";
|
|
9
10
|
|
|
10
11
|
|
|
@@ -15,4 +16,5 @@ export {Users};
|
|
|
15
16
|
export {Events};
|
|
16
17
|
export {Teams};
|
|
17
18
|
export {Waitlists};
|
|
19
|
+
export {Posts};
|
|
18
20
|
export {Templates};
|
package/src/config/Config.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Community from "../models/community";
|
|
2
|
+
import LabelManager from "../util/LabelManager";
|
|
2
3
|
import Requests from "../util/Requests";
|
|
3
4
|
|
|
4
5
|
/**
|
|
@@ -70,6 +71,8 @@ class Config {
|
|
|
70
71
|
Config._community = community;
|
|
71
72
|
|
|
72
73
|
Requests.setCommunityID(community.id);
|
|
74
|
+
|
|
75
|
+
LabelManager.initialize(community);
|
|
73
76
|
}
|
|
74
77
|
|
|
75
78
|
/**
|
package/src/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {Communities} from "./api";
|
|
|
9
9
|
import { Users } from "./api";
|
|
10
10
|
import { Events } from "./api";
|
|
11
11
|
import { Teams } from "./api";
|
|
12
|
+
import { Posts } from "./api";
|
|
12
13
|
import {Templates} from "./api";
|
|
13
14
|
import { Waitlists } from "./api";
|
|
14
15
|
|
|
@@ -17,11 +18,14 @@ import Parser from "./util/Parser";
|
|
|
17
18
|
import Session from "./util/Session";
|
|
18
19
|
import Storage from "./util/Storage";
|
|
19
20
|
import Data from './util/Data';
|
|
21
|
+
import LabelManager from "./util/LabelManager";
|
|
20
22
|
|
|
21
23
|
import { AcceptanceStatus } from "./constants/AcceptanceStatus";
|
|
22
24
|
import AddressLocationType from "./constants/AddressLocationType";
|
|
25
|
+
import { ContentStatus } from "./constants/ContentStatus";
|
|
23
26
|
import { CompetitionTypes } from "./constants/CompetitionTypes";
|
|
24
27
|
import { Modes } from "./constants/Modes";
|
|
28
|
+
import { PostTypes } from "./constants/PostTypes";
|
|
25
29
|
import { Roles } from "./constants/Roles";
|
|
26
30
|
import { TeamJoinProcess } from "./constants/TeamJoinProcess";
|
|
27
31
|
import TicketTypes from "./constants/TicketTypes";
|
|
@@ -42,6 +46,7 @@ class Glitch {
|
|
|
42
46
|
Users: Users,
|
|
43
47
|
Events: Events,
|
|
44
48
|
Teams: Teams,
|
|
49
|
+
Posts: Posts,
|
|
45
50
|
Templates : Templates,
|
|
46
51
|
Waitlists: Waitlists
|
|
47
52
|
}
|
|
@@ -52,13 +57,16 @@ class Glitch {
|
|
|
52
57
|
Session: Session,
|
|
53
58
|
Storage : Storage,
|
|
54
59
|
Data : Data,
|
|
60
|
+
LabelManager : LabelManager,
|
|
55
61
|
}
|
|
56
62
|
|
|
57
63
|
public static constants = {
|
|
58
64
|
AcceptanceStatus : AcceptanceStatus,
|
|
59
65
|
AddressLocationType : AddressLocationType,
|
|
60
66
|
CompetitionTypes : CompetitionTypes,
|
|
67
|
+
ContentStatus : ContentStatus,
|
|
61
68
|
Modes : Modes,
|
|
69
|
+
PostTypes : PostTypes,
|
|
62
70
|
Roles: Roles,
|
|
63
71
|
TeamJoinProcess : TeamJoinProcess,
|
|
64
72
|
TicketTypes : TicketTypes,
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import Route from "./interface";
|
|
2
|
+
import HTTP_METHODS from "../constants/HttpMethods";
|
|
3
|
+
|
|
4
|
+
class PostsRoute {
|
|
5
|
+
|
|
6
|
+
public static routes: { [key: string]: Route } = {
|
|
7
|
+
list: { url: '/posts', method: HTTP_METHODS.GET },
|
|
8
|
+
create: { url: '/posts', method: HTTP_METHODS.POST },
|
|
9
|
+
view : { url: '/posts/{post_id}', method: HTTP_METHODS.GET },
|
|
10
|
+
update :{ url: '/posts/{post_id}', method: HTTP_METHODS.PUT },
|
|
11
|
+
delete : { url: '/posts/{post_id}', method: HTTP_METHODS.DELETE },
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default PostsRoute;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
interface CommunityLabels {
|
|
2
|
+
[key: string]: string;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
class LabelManager {
|
|
6
|
+
private static community: CommunityLabels;
|
|
7
|
+
|
|
8
|
+
static initialize(community: CommunityLabels) {
|
|
9
|
+
LabelManager.community = community;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
private static getLabel(labelName: string, plural: boolean, capitalize: boolean): string {
|
|
13
|
+
let label = LabelManager.community[labelName + (plural ? "_plural" : "_singular")];
|
|
14
|
+
|
|
15
|
+
if (capitalize) {
|
|
16
|
+
label = label.charAt(0).toUpperCase() + label.slice(1);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return label;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
static getUserLabel(plural: boolean, capitalize: boolean): string {
|
|
23
|
+
return LabelManager.getLabel("label_users", plural, capitalize);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
static getCompetitionLabel(plural: boolean, capitalize: boolean): string {
|
|
27
|
+
return LabelManager.getLabel("label_competitions", plural, capitalize);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
static getStreamLabel(plural: boolean, capitalize: boolean): string {
|
|
31
|
+
return LabelManager.getLabel("label_streams", plural, capitalize);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
static getPostLabel(plural: boolean, capitalize: boolean): string {
|
|
35
|
+
return LabelManager.getLabel("label_posts", plural, capitalize);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export default LabelManager;
|