glitch-javascript-sdk 0.6.0 → 0.6.2
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 +122 -0
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/api/Posts.d.ts +21 -0
- package/dist/esm/api/SocialPosts.d.ts +31 -0
- package/dist/esm/api/Users.d.ts +16 -0
- package/dist/esm/api/index.d.ts +2 -0
- package/dist/esm/index.js +122 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/routes/SocialPostsRoute.d.ts +7 -0
- package/dist/esm/util/Requests.d.ts +1 -1
- package/dist/index.d.ts +38 -1
- package/package.json +1 -1
- package/src/api/Posts.ts +77 -22
- package/src/api/SocialPosts.ts +46 -0
- package/src/api/Users.ts +24 -0
- package/src/api/index.ts +3 -1
- package/src/index.ts +2 -0
- package/src/routes/SocialPostsRoute.ts +14 -0
- package/src/routes/UserRoutes.ts +2 -0
- package/src/util/Requests.ts +1 -1
package/dist/esm/api/Posts.d.ts
CHANGED
|
@@ -41,6 +41,27 @@ declare class Posts {
|
|
|
41
41
|
* @returns promise
|
|
42
42
|
*/
|
|
43
43
|
static createWithBlob<T>(blob: Blob, data?: object): AxiosPromise<Response<T>>;
|
|
44
|
+
/**
|
|
45
|
+
* Create a new post with a file divided into chunks.
|
|
46
|
+
*
|
|
47
|
+
* @param file The file object to upload.
|
|
48
|
+
* @param chunkSize Size of each chunk in bytes. Default is 1MB.
|
|
49
|
+
* @param data Any additional data to pass along to the upload.
|
|
50
|
+
*
|
|
51
|
+
* @returns Promise
|
|
52
|
+
*/
|
|
53
|
+
/**
|
|
54
|
+
* Create a new post with a file divided into chunks.
|
|
55
|
+
*
|
|
56
|
+
* @param file The file object to upload.
|
|
57
|
+
* @param chunkSize Size of each chunk in bytes. Default is 1MB.
|
|
58
|
+
* @param data Any additional data to pass along to the upload.
|
|
59
|
+
*
|
|
60
|
+
* @returns Promise
|
|
61
|
+
*/
|
|
62
|
+
static createWithFileInChunks<T>(file: File, chunkSize?: number, data?: {
|
|
63
|
+
[key: string]: any;
|
|
64
|
+
}): Promise<AxiosPromise<Response<T>>>;
|
|
44
65
|
/**
|
|
45
66
|
* Update a post.
|
|
46
67
|
*
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Response from "../util/Response";
|
|
2
|
+
import { AxiosPromise } from "axios";
|
|
3
|
+
declare class SocialPosts {
|
|
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
|
+
* Give a tip to another user
|
|
14
|
+
*
|
|
15
|
+
* @see https://api.glitch.fun/api/documentation#/Authentication%20Route/authLogin
|
|
16
|
+
*
|
|
17
|
+
* @returns A promise
|
|
18
|
+
*/
|
|
19
|
+
static create<T>(data?: object, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieve the information for a single post.
|
|
22
|
+
*
|
|
23
|
+
* @see https://api.glitch.fun/api/documentation#/Post%20Route/showPostStorage
|
|
24
|
+
*
|
|
25
|
+
* @param post_id The id fo the post to retrieve.
|
|
26
|
+
*
|
|
27
|
+
* @returns promise
|
|
28
|
+
*/
|
|
29
|
+
static view<T>(post_id: string, params?: Record<string, any>): AxiosPromise<Response<T>>;
|
|
30
|
+
}
|
|
31
|
+
export default SocialPosts;
|
package/dist/esm/api/Users.d.ts
CHANGED
|
@@ -159,6 +159,22 @@ declare class Users {
|
|
|
159
159
|
* @returns promise
|
|
160
160
|
*/
|
|
161
161
|
static clearYoutubeAuth<T>(): AxiosPromise<Response<T>>;
|
|
162
|
+
/**
|
|
163
|
+
* Clear Reddit authentication information from the current user.
|
|
164
|
+
*
|
|
165
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/userCreateDonationPage
|
|
166
|
+
*
|
|
167
|
+
* @returns promise
|
|
168
|
+
*/
|
|
169
|
+
static clearRedditAuth<T>(): AxiosPromise<Response<T>>;
|
|
170
|
+
/**
|
|
171
|
+
* Clear Twitter authentication information from the current user.
|
|
172
|
+
*
|
|
173
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/userCreateDonationPage
|
|
174
|
+
*
|
|
175
|
+
* @returns promise
|
|
176
|
+
*/
|
|
177
|
+
static clearTwitterAuth<T>(): AxiosPromise<Response<T>>;
|
|
162
178
|
/**
|
|
163
179
|
* Clear StreamElements authentication information from the current user.
|
|
164
180
|
*
|
package/dist/esm/api/index.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import Tips from "./Tips";
|
|
|
13
13
|
import TipEmojis from "./TipEmojis";
|
|
14
14
|
import TipPackages from "./TipPackages";
|
|
15
15
|
import TipPackagePurchases from "./TipPackagePurchases";
|
|
16
|
+
import SocialPosts from "./SocialPosts";
|
|
16
17
|
export { Auth };
|
|
17
18
|
export { Competitions };
|
|
18
19
|
export { Communities };
|
|
@@ -28,3 +29,4 @@ export { Tips };
|
|
|
28
29
|
export { TipEmojis };
|
|
29
30
|
export { TipPackages };
|
|
30
31
|
export { TipPackagePurchases };
|
|
32
|
+
export { SocialPosts };
|
package/dist/esm/index.js
CHANGED
|
@@ -54,6 +54,44 @@ var __assign = function() {
|
|
|
54
54
|
return __assign.apply(this, arguments);
|
|
55
55
|
};
|
|
56
56
|
|
|
57
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
58
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
59
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
60
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
61
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
62
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
63
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function __generator(thisArg, body) {
|
|
68
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
69
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
70
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
71
|
+
function step(op) {
|
|
72
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
73
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
74
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
75
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
76
|
+
switch (op[0]) {
|
|
77
|
+
case 0: case 1: t = op; break;
|
|
78
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
79
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
80
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
81
|
+
default:
|
|
82
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
83
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
84
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
85
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
86
|
+
if (t[2]) _.ops.pop();
|
|
87
|
+
_.trys.pop(); continue;
|
|
88
|
+
}
|
|
89
|
+
op = body.call(thisArg, _);
|
|
90
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
91
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
57
95
|
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
58
96
|
var e = new Error(message);
|
|
59
97
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
@@ -32330,6 +32368,8 @@ var UserRoutes = /** @class */ (function () {
|
|
|
32330
32368
|
clearStripeAuth: { url: '/users/clearStripeAuth', method: HTTP_METHODS.DELETE },
|
|
32331
32369
|
clearTikTokAuth: { url: '/users/clearTikTokAuth', method: HTTP_METHODS.DELETE },
|
|
32332
32370
|
clearYoutubeAuth: { url: '/users/clearYoutubeAuth', method: HTTP_METHODS.DELETE },
|
|
32371
|
+
clearRedditAuth: { url: '/users/clearRedditAuth', method: HTTP_METHODS.DELETE },
|
|
32372
|
+
clearTwitterAuth: { url: '/users/clearTwitterAuth', method: HTTP_METHODS.DELETE },
|
|
32333
32373
|
clearStreamElementsAuth: { url: '/users/clearStreamElementsAuth', method: HTTP_METHODS.DELETE },
|
|
32334
32374
|
getTipsReceivedForMonth: { url: '/users/getTipsReceivedForMonth', method: HTTP_METHODS.GET },
|
|
32335
32375
|
getTipsGivenForMonth: { url: '/users/getTipsGivenForMonth', method: HTTP_METHODS.GET },
|
|
@@ -32536,6 +32576,26 @@ var Users = /** @class */ (function () {
|
|
|
32536
32576
|
Users.clearYoutubeAuth = function () {
|
|
32537
32577
|
return Requests.processRoute(UserRoutes.routes.clearYoutubeAuth, {});
|
|
32538
32578
|
};
|
|
32579
|
+
/**
|
|
32580
|
+
* Clear Reddit authentication information from the current user.
|
|
32581
|
+
*
|
|
32582
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/userCreateDonationPage
|
|
32583
|
+
*
|
|
32584
|
+
* @returns promise
|
|
32585
|
+
*/
|
|
32586
|
+
Users.clearRedditAuth = function () {
|
|
32587
|
+
return Requests.processRoute(UserRoutes.routes.clearRedditAuth, {});
|
|
32588
|
+
};
|
|
32589
|
+
/**
|
|
32590
|
+
* Clear Twitter authentication information from the current user.
|
|
32591
|
+
*
|
|
32592
|
+
* @see https://api.glitch.fun/api/documentation#/Users%20Route/userCreateDonationPage
|
|
32593
|
+
*
|
|
32594
|
+
* @returns promise
|
|
32595
|
+
*/
|
|
32596
|
+
Users.clearTwitterAuth = function () {
|
|
32597
|
+
return Requests.processRoute(UserRoutes.routes.clearTwitterAuth, {});
|
|
32598
|
+
};
|
|
32539
32599
|
/**
|
|
32540
32600
|
* Clear StreamElements authentication information from the current user.
|
|
32541
32601
|
*
|
|
@@ -33502,6 +33562,68 @@ var Posts = /** @class */ (function () {
|
|
|
33502
33562
|
Posts.createWithBlob = function (blob, data) {
|
|
33503
33563
|
return Requests.uploadBlob(PostsRoute.routes.create.url, 'file', blob, data);
|
|
33504
33564
|
};
|
|
33565
|
+
/**
|
|
33566
|
+
* Create a new post with a file divided into chunks.
|
|
33567
|
+
*
|
|
33568
|
+
* @param file The file object to upload.
|
|
33569
|
+
* @param chunkSize Size of each chunk in bytes. Default is 1MB.
|
|
33570
|
+
* @param data Any additional data to pass along to the upload.
|
|
33571
|
+
*
|
|
33572
|
+
* @returns Promise
|
|
33573
|
+
*/
|
|
33574
|
+
/**
|
|
33575
|
+
* Create a new post with a file divided into chunks.
|
|
33576
|
+
*
|
|
33577
|
+
* @param file The file object to upload.
|
|
33578
|
+
* @param chunkSize Size of each chunk in bytes. Default is 1MB.
|
|
33579
|
+
* @param data Any additional data to pass along to the upload.
|
|
33580
|
+
*
|
|
33581
|
+
* @returns Promise
|
|
33582
|
+
*/
|
|
33583
|
+
Posts.createWithFileInChunks = function (file, chunkSize, data) {
|
|
33584
|
+
if (chunkSize === void 0) { chunkSize = 1 * 1024 * 1024; }
|
|
33585
|
+
if (data === void 0) { data = {}; }
|
|
33586
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
33587
|
+
var totalChunks, i, start, end, chunk, formData, key;
|
|
33588
|
+
return __generator(this, function (_a) {
|
|
33589
|
+
switch (_a.label) {
|
|
33590
|
+
case 0:
|
|
33591
|
+
totalChunks = Math.ceil(file.size / chunkSize);
|
|
33592
|
+
i = 0;
|
|
33593
|
+
_a.label = 1;
|
|
33594
|
+
case 1:
|
|
33595
|
+
if (!(i < totalChunks)) return [3 /*break*/, 6];
|
|
33596
|
+
start = i * chunkSize;
|
|
33597
|
+
end = start + chunkSize;
|
|
33598
|
+
chunk = file.slice(start, end);
|
|
33599
|
+
formData = new FormData();
|
|
33600
|
+
formData.append('file', chunk, "".concat(i, "-").concat(file.name)); // Naming chunks as index-filename for identification
|
|
33601
|
+
formData.append('totalChunks', totalChunks.toString());
|
|
33602
|
+
formData.append('currentChunk', i.toString());
|
|
33603
|
+
// merge any other data if provided
|
|
33604
|
+
for (key in data) {
|
|
33605
|
+
formData.append(key, data[key]);
|
|
33606
|
+
}
|
|
33607
|
+
if (!(i === totalChunks - 1)) return [3 /*break*/, 3];
|
|
33608
|
+
return [4 /*yield*/, Requests.uploadFile(PostsRoute.routes.create.url, 'file', chunk, formData)];
|
|
33609
|
+
case 2:
|
|
33610
|
+
_a.sent();
|
|
33611
|
+
return [3 /*break*/, 5];
|
|
33612
|
+
case 3: return [4 /*yield*/, Requests.uploadFile(PostsRoute.routes.create.url, 'file', chunk, formData)];
|
|
33613
|
+
case 4:
|
|
33614
|
+
_a.sent();
|
|
33615
|
+
_a.label = 5;
|
|
33616
|
+
case 5:
|
|
33617
|
+
i++;
|
|
33618
|
+
return [3 /*break*/, 1];
|
|
33619
|
+
case 6:
|
|
33620
|
+
{
|
|
33621
|
+
throw new Error("No response from the last chunk upload");
|
|
33622
|
+
}
|
|
33623
|
+
}
|
|
33624
|
+
});
|
|
33625
|
+
});
|
|
33626
|
+
};
|
|
33505
33627
|
/**
|
|
33506
33628
|
* Update a post.
|
|
33507
33629
|
*
|