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,53 @@
|
|
|
1
|
+
import Response from "../util/Response";
|
|
2
|
+
import { AxiosPromise } from "axios";
|
|
3
|
+
declare class Posts {
|
|
4
|
+
/**
|
|
5
|
+
* List all the Posts.
|
|
6
|
+
*
|
|
7
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList
|
|
8
|
+
*
|
|
9
|
+
* @returns promise
|
|
10
|
+
*/
|
|
11
|
+
static list<T>(params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
12
|
+
/**
|
|
13
|
+
* Create a new post.
|
|
14
|
+
*
|
|
15
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/newPostResourceStorage
|
|
16
|
+
*
|
|
17
|
+
* @param data The data to be passed when creating a post.
|
|
18
|
+
*
|
|
19
|
+
* @returns Promise
|
|
20
|
+
*/
|
|
21
|
+
static create<T>(data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
22
|
+
/**
|
|
23
|
+
* Update a post.
|
|
24
|
+
*
|
|
25
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/updatePostStorage
|
|
26
|
+
*
|
|
27
|
+
* @param post_id The id of the post to update.
|
|
28
|
+
* @param data The data to update.
|
|
29
|
+
*
|
|
30
|
+
* @returns promise
|
|
31
|
+
*/
|
|
32
|
+
static update<T>(post_id: string, data: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
33
|
+
/**
|
|
34
|
+
* Retrieve the information for a single post.
|
|
35
|
+
*
|
|
36
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
|
|
37
|
+
*
|
|
38
|
+
* @param post_id The id fo the post to retrieve.
|
|
39
|
+
*
|
|
40
|
+
* @returns promise
|
|
41
|
+
*/
|
|
42
|
+
static view<T>(post_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
43
|
+
/**
|
|
44
|
+
* Deletes a post.
|
|
45
|
+
*
|
|
46
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage
|
|
47
|
+
*
|
|
48
|
+
* @param post_id The id of the post to delete.
|
|
49
|
+
* @returns promise
|
|
50
|
+
*/
|
|
51
|
+
static delete<T>(post_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
52
|
+
}
|
|
53
|
+
export default Posts;
|
package/dist/esm/api/index.d.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
|
export { Auth };
|
|
10
11
|
export { Competitions };
|
|
@@ -13,4 +14,5 @@ export { Users };
|
|
|
13
14
|
export { Events };
|
|
14
15
|
export { Teams };
|
|
15
16
|
export { Waitlists };
|
|
17
|
+
export { Posts };
|
|
16
18
|
export { Templates };
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Communities } from "./api";
|
|
|
5
5
|
import { Users } from "./api";
|
|
6
6
|
import { Events } from "./api";
|
|
7
7
|
import { Teams } from "./api";
|
|
8
|
+
import { Posts } from "./api";
|
|
8
9
|
import { Templates } from "./api";
|
|
9
10
|
import { Waitlists } from "./api";
|
|
10
11
|
import Requests from "./util/Requests";
|
|
@@ -12,6 +13,7 @@ import Parser from "./util/Parser";
|
|
|
12
13
|
import Session from "./util/Session";
|
|
13
14
|
import Storage from "./util/Storage";
|
|
14
15
|
import Data from './util/Data';
|
|
16
|
+
import LabelManager from "./util/LabelManager";
|
|
15
17
|
import { Modes } from "./constants/Modes";
|
|
16
18
|
import { Roles } from "./constants/Roles";
|
|
17
19
|
import { TeamJoinProcess } from "./constants/TeamJoinProcess";
|
|
@@ -30,6 +32,7 @@ declare class Glitch {
|
|
|
30
32
|
Users: typeof Users;
|
|
31
33
|
Events: typeof Events;
|
|
32
34
|
Teams: typeof Teams;
|
|
35
|
+
Posts: typeof Posts;
|
|
33
36
|
Templates: typeof Templates;
|
|
34
37
|
Waitlists: typeof Waitlists;
|
|
35
38
|
};
|
|
@@ -39,6 +42,7 @@ declare class Glitch {
|
|
|
39
42
|
Session: typeof Session;
|
|
40
43
|
Storage: typeof Storage;
|
|
41
44
|
Data: typeof Data;
|
|
45
|
+
LabelManager: typeof LabelManager;
|
|
42
46
|
};
|
|
43
47
|
static constants: {
|
|
44
48
|
AcceptanceStatus: Readonly<{
|
|
@@ -67,7 +71,23 @@ declare class Glitch {
|
|
|
67
71
|
SEMI_ROUND_ROBINS: 8;
|
|
68
72
|
EXTENDED: 9;
|
|
69
73
|
}>;
|
|
74
|
+
ContentStatus: Readonly<{
|
|
75
|
+
UNAPPROVED: 0;
|
|
76
|
+
APPROVED: 1;
|
|
77
|
+
IN_REVIEW: 2;
|
|
78
|
+
PENDING: 3;
|
|
79
|
+
FLAGGED: 4;
|
|
80
|
+
REMOVED: 5;
|
|
81
|
+
DELETED: 6;
|
|
82
|
+
}>;
|
|
70
83
|
Modes: typeof Modes;
|
|
84
|
+
PostTypes: Readonly<{
|
|
85
|
+
TEXT: "text";
|
|
86
|
+
LINK: "link";
|
|
87
|
+
POLL: "poll";
|
|
88
|
+
IMAGE: "image";
|
|
89
|
+
VIDEO: "video";
|
|
90
|
+
}>;
|
|
71
91
|
Roles: typeof Roles;
|
|
72
92
|
TeamJoinProcess: typeof TeamJoinProcess;
|
|
73
93
|
TicketTypes: typeof TicketTypes;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
var LabelManager = /** @class */ (function () {
|
|
2
|
+
function LabelManager() {
|
|
3
|
+
}
|
|
4
|
+
LabelManager.initialize = function (community) {
|
|
5
|
+
LabelManager.community = community;
|
|
6
|
+
};
|
|
7
|
+
LabelManager.getLabel = function (labelName, plural, capitalize) {
|
|
8
|
+
var label = LabelManager.community[labelName + (plural ? "_plural" : "_singular")];
|
|
9
|
+
if (capitalize) {
|
|
10
|
+
label = label.charAt(0).toUpperCase() + label.slice(1);
|
|
11
|
+
}
|
|
12
|
+
return label;
|
|
13
|
+
};
|
|
14
|
+
LabelManager.getUserLabel = function (plural, capitalize) {
|
|
15
|
+
return LabelManager.getLabel("label_users", plural, capitalize);
|
|
16
|
+
};
|
|
17
|
+
LabelManager.getCompetitionLabel = function (plural, capitalize) {
|
|
18
|
+
return LabelManager.getLabel("label_competitions", plural, capitalize);
|
|
19
|
+
};
|
|
20
|
+
LabelManager.getStreamLabel = function (plural, capitalize) {
|
|
21
|
+
return LabelManager.getLabel("label_streams", plural, capitalize);
|
|
22
|
+
};
|
|
23
|
+
LabelManager.getPostLabel = function (plural, capitalize) {
|
|
24
|
+
return LabelManager.getLabel("label_posts", plural, capitalize);
|
|
25
|
+
};
|
|
26
|
+
return LabelManager;
|
|
27
|
+
}());
|
|
28
|
+
|
|
1
29
|
/******************************************************************************
|
|
2
30
|
Copyright (c) Microsoft Corporation.
|
|
3
31
|
|
|
@@ -30094,6 +30122,7 @@ var Config = /** @class */ (function () {
|
|
|
30094
30122
|
Config.setCommunity = function (community) {
|
|
30095
30123
|
Config._community = community;
|
|
30096
30124
|
Requests.setCommunityID(community.id);
|
|
30125
|
+
LabelManager.initialize(community);
|
|
30097
30126
|
};
|
|
30098
30127
|
Object.defineProperty(Config, "baseUrl", {
|
|
30099
30128
|
/**
|
|
@@ -31946,6 +31975,83 @@ var Waitlists = /** @class */ (function () {
|
|
|
31946
31975
|
return Waitlists;
|
|
31947
31976
|
}());
|
|
31948
31977
|
|
|
31978
|
+
var PostsRoute = /** @class */ (function () {
|
|
31979
|
+
function PostsRoute() {
|
|
31980
|
+
}
|
|
31981
|
+
PostsRoute.routes = {
|
|
31982
|
+
list: { url: '/posts', method: HTTP_METHODS.GET },
|
|
31983
|
+
create: { url: '/posts', method: HTTP_METHODS.POST },
|
|
31984
|
+
view: { url: '/posts/{post_id}', method: HTTP_METHODS.GET },
|
|
31985
|
+
update: { url: '/posts/{post_id}', method: HTTP_METHODS.PUT },
|
|
31986
|
+
delete: { url: '/posts/{post_id}', method: HTTP_METHODS.DELETE },
|
|
31987
|
+
};
|
|
31988
|
+
return PostsRoute;
|
|
31989
|
+
}());
|
|
31990
|
+
|
|
31991
|
+
var Posts = /** @class */ (function () {
|
|
31992
|
+
function Posts() {
|
|
31993
|
+
}
|
|
31994
|
+
/**
|
|
31995
|
+
* List all the Posts.
|
|
31996
|
+
*
|
|
31997
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/resourcePostList
|
|
31998
|
+
*
|
|
31999
|
+
* @returns promise
|
|
32000
|
+
*/
|
|
32001
|
+
Posts.list = function (params) {
|
|
32002
|
+
return Requests.processRoute(PostsRoute.routes.list, undefined, undefined, params);
|
|
32003
|
+
};
|
|
32004
|
+
/**
|
|
32005
|
+
* Create a new post.
|
|
32006
|
+
*
|
|
32007
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/newPostResourceStorage
|
|
32008
|
+
*
|
|
32009
|
+
* @param data The data to be passed when creating a post.
|
|
32010
|
+
*
|
|
32011
|
+
* @returns Promise
|
|
32012
|
+
*/
|
|
32013
|
+
Posts.create = function (data, params) {
|
|
32014
|
+
return Requests.processRoute(PostsRoute.routes.create, data, undefined, params);
|
|
32015
|
+
};
|
|
32016
|
+
/**
|
|
32017
|
+
* Update a post.
|
|
32018
|
+
*
|
|
32019
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/updatePostStorage
|
|
32020
|
+
*
|
|
32021
|
+
* @param post_id The id of the post to update.
|
|
32022
|
+
* @param data The data to update.
|
|
32023
|
+
*
|
|
32024
|
+
* @returns promise
|
|
32025
|
+
*/
|
|
32026
|
+
Posts.update = function (post_id, data, params) {
|
|
32027
|
+
return Requests.processRoute(PostsRoute.routes.update, data, { post_id: post_id }, params);
|
|
32028
|
+
};
|
|
32029
|
+
/**
|
|
32030
|
+
* Retrieve the information for a single post.
|
|
32031
|
+
*
|
|
32032
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
|
|
32033
|
+
*
|
|
32034
|
+
* @param post_id The id fo the post to retrieve.
|
|
32035
|
+
*
|
|
32036
|
+
* @returns promise
|
|
32037
|
+
*/
|
|
32038
|
+
Posts.view = function (post_id, params) {
|
|
32039
|
+
return Requests.processRoute(PostsRoute.routes.view, {}, { post_id: post_id }, params);
|
|
32040
|
+
};
|
|
32041
|
+
/**
|
|
32042
|
+
* Deletes a post.
|
|
32043
|
+
*
|
|
32044
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/destoryPostStorage
|
|
32045
|
+
*
|
|
32046
|
+
* @param post_id The id of the post to delete.
|
|
32047
|
+
* @returns promise
|
|
32048
|
+
*/
|
|
32049
|
+
Posts.delete = function (post_id, params) {
|
|
32050
|
+
return Requests.processRoute(PostsRoute.routes.delete, {}, { post_id: post_id }, params);
|
|
32051
|
+
};
|
|
32052
|
+
return Posts;
|
|
32053
|
+
}());
|
|
32054
|
+
|
|
31949
32055
|
var TemplatesRoute = /** @class */ (function () {
|
|
31950
32056
|
function TemplatesRoute() {
|
|
31951
32057
|
}
|
|
@@ -32288,6 +32394,16 @@ var AddressLocationType = Object.freeze({
|
|
|
32288
32394
|
HYBRID: 3,
|
|
32289
32395
|
});
|
|
32290
32396
|
|
|
32397
|
+
var ContentStatus = Object.freeze({
|
|
32398
|
+
UNAPPROVED: 0,
|
|
32399
|
+
APPROVED: 1,
|
|
32400
|
+
IN_REVIEW: 2,
|
|
32401
|
+
PENDING: 3,
|
|
32402
|
+
FLAGGED: 4,
|
|
32403
|
+
REMOVED: 5,
|
|
32404
|
+
DELETED: 6,
|
|
32405
|
+
});
|
|
32406
|
+
|
|
32291
32407
|
var CompetitionTypes = Object.freeze({
|
|
32292
32408
|
SINGLE_ELIMINATION: 1,
|
|
32293
32409
|
DOUBLE_ELIMINATION: 2,
|
|
@@ -32307,6 +32423,14 @@ var Modes;
|
|
|
32307
32423
|
Modes[Modes["RTMP"] = 2] = "RTMP";
|
|
32308
32424
|
})(Modes || (Modes = {}));
|
|
32309
32425
|
|
|
32426
|
+
var PostTypes = Object.freeze({
|
|
32427
|
+
TEXT: 'text',
|
|
32428
|
+
LINK: 'link',
|
|
32429
|
+
POLL: 'poll',
|
|
32430
|
+
IMAGE: 'image',
|
|
32431
|
+
VIDEO: 'video',
|
|
32432
|
+
});
|
|
32433
|
+
|
|
32310
32434
|
var Roles;
|
|
32311
32435
|
(function (Roles) {
|
|
32312
32436
|
Roles[Roles["NONE"] = 0] = "NONE";
|
|
@@ -32383,6 +32507,7 @@ var Glitch = /** @class */ (function () {
|
|
|
32383
32507
|
Users: Users,
|
|
32384
32508
|
Events: Events,
|
|
32385
32509
|
Teams: Teams,
|
|
32510
|
+
Posts: Posts,
|
|
32386
32511
|
Templates: Templates,
|
|
32387
32512
|
Waitlists: Waitlists
|
|
32388
32513
|
};
|
|
@@ -32392,12 +32517,15 @@ var Glitch = /** @class */ (function () {
|
|
|
32392
32517
|
Session: Session,
|
|
32393
32518
|
Storage: Storage,
|
|
32394
32519
|
Data: Data,
|
|
32520
|
+
LabelManager: LabelManager,
|
|
32395
32521
|
};
|
|
32396
32522
|
Glitch.constants = {
|
|
32397
32523
|
AcceptanceStatus: AcceptanceStatus,
|
|
32398
32524
|
AddressLocationType: AddressLocationType,
|
|
32399
32525
|
CompetitionTypes: CompetitionTypes,
|
|
32526
|
+
ContentStatus: ContentStatus,
|
|
32400
32527
|
Modes: Modes,
|
|
32528
|
+
PostTypes: PostTypes,
|
|
32401
32529
|
Roles: Roles,
|
|
32402
32530
|
TeamJoinProcess: TeamJoinProcess,
|
|
32403
32531
|
TicketTypes: TicketTypes$1,
|