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 CHANGED
@@ -67,6 +67,44 @@ var __assign = function() {
67
67
  return __assign.apply(this, arguments);
68
68
  };
69
69
 
70
+ function __awaiter(thisArg, _arguments, P, generator) {
71
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
72
+ return new (P || (P = Promise))(function (resolve, reject) {
73
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
74
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
75
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
76
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
77
+ });
78
+ }
79
+
80
+ function __generator(thisArg, body) {
81
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
82
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
83
+ function verb(n) { return function (v) { return step([n, v]); }; }
84
+ function step(op) {
85
+ if (f) throw new TypeError("Generator is already executing.");
86
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
87
+ 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;
88
+ if (y = 0, t) op = [op[0] & 2, t.value];
89
+ switch (op[0]) {
90
+ case 0: case 1: t = op; break;
91
+ case 4: _.label++; return { value: op[1], done: false };
92
+ case 5: _.label++; y = op[1]; op = [0]; continue;
93
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
94
+ default:
95
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
96
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
97
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
98
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
99
+ if (t[2]) _.ops.pop();
100
+ _.trys.pop(); continue;
101
+ }
102
+ op = body.call(thisArg, _);
103
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
104
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
105
+ }
106
+ }
107
+
70
108
  typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
71
109
  var e = new Error(message);
72
110
  return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
@@ -18686,6 +18724,8 @@ var UserRoutes = /** @class */ (function () {
18686
18724
  clearStripeAuth: { url: '/users/clearStripeAuth', method: HTTP_METHODS.DELETE },
18687
18725
  clearTikTokAuth: { url: '/users/clearTikTokAuth', method: HTTP_METHODS.DELETE },
18688
18726
  clearYoutubeAuth: { url: '/users/clearYoutubeAuth', method: HTTP_METHODS.DELETE },
18727
+ clearRedditAuth: { url: '/users/clearRedditAuth', method: HTTP_METHODS.DELETE },
18728
+ clearTwitterAuth: { url: '/users/clearTwitterAuth', method: HTTP_METHODS.DELETE },
18689
18729
  clearStreamElementsAuth: { url: '/users/clearStreamElementsAuth', method: HTTP_METHODS.DELETE },
18690
18730
  getTipsReceivedForMonth: { url: '/users/getTipsReceivedForMonth', method: HTTP_METHODS.GET },
18691
18731
  getTipsGivenForMonth: { url: '/users/getTipsGivenForMonth', method: HTTP_METHODS.GET },
@@ -18892,6 +18932,26 @@ var Users = /** @class */ (function () {
18892
18932
  Users.clearYoutubeAuth = function () {
18893
18933
  return Requests.processRoute(UserRoutes.routes.clearYoutubeAuth, {});
18894
18934
  };
18935
+ /**
18936
+ * Clear Reddit authentication information from the current user.
18937
+ *
18938
+ * @see https://api.glitch.fun/api/documentation#/Users%20Route/userCreateDonationPage
18939
+ *
18940
+ * @returns promise
18941
+ */
18942
+ Users.clearRedditAuth = function () {
18943
+ return Requests.processRoute(UserRoutes.routes.clearRedditAuth, {});
18944
+ };
18945
+ /**
18946
+ * Clear Twitter authentication information from the current user.
18947
+ *
18948
+ * @see https://api.glitch.fun/api/documentation#/Users%20Route/userCreateDonationPage
18949
+ *
18950
+ * @returns promise
18951
+ */
18952
+ Users.clearTwitterAuth = function () {
18953
+ return Requests.processRoute(UserRoutes.routes.clearTwitterAuth, {});
18954
+ };
18895
18955
  /**
18896
18956
  * Clear StreamElements authentication information from the current user.
18897
18957
  *
@@ -19858,6 +19918,68 @@ var Posts = /** @class */ (function () {
19858
19918
  Posts.createWithBlob = function (blob, data) {
19859
19919
  return Requests.uploadBlob(PostsRoute.routes.create.url, 'file', blob, data);
19860
19920
  };
19921
+ /**
19922
+ * Create a new post with a file divided into chunks.
19923
+ *
19924
+ * @param file The file object to upload.
19925
+ * @param chunkSize Size of each chunk in bytes. Default is 1MB.
19926
+ * @param data Any additional data to pass along to the upload.
19927
+ *
19928
+ * @returns Promise
19929
+ */
19930
+ /**
19931
+ * Create a new post with a file divided into chunks.
19932
+ *
19933
+ * @param file The file object to upload.
19934
+ * @param chunkSize Size of each chunk in bytes. Default is 1MB.
19935
+ * @param data Any additional data to pass along to the upload.
19936
+ *
19937
+ * @returns Promise
19938
+ */
19939
+ Posts.createWithFileInChunks = function (file, chunkSize, data) {
19940
+ if (chunkSize === void 0) { chunkSize = 1 * 1024 * 1024; }
19941
+ if (data === void 0) { data = {}; }
19942
+ return __awaiter(this, void 0, void 0, function () {
19943
+ var totalChunks, i, start, end, chunk, formData, key;
19944
+ return __generator(this, function (_a) {
19945
+ switch (_a.label) {
19946
+ case 0:
19947
+ totalChunks = Math.ceil(file.size / chunkSize);
19948
+ i = 0;
19949
+ _a.label = 1;
19950
+ case 1:
19951
+ if (!(i < totalChunks)) return [3 /*break*/, 6];
19952
+ start = i * chunkSize;
19953
+ end = start + chunkSize;
19954
+ chunk = file.slice(start, end);
19955
+ formData = new FormData();
19956
+ formData.append('file', chunk, "".concat(i, "-").concat(file.name)); // Naming chunks as index-filename for identification
19957
+ formData.append('totalChunks', totalChunks.toString());
19958
+ formData.append('currentChunk', i.toString());
19959
+ // merge any other data if provided
19960
+ for (key in data) {
19961
+ formData.append(key, data[key]);
19962
+ }
19963
+ if (!(i === totalChunks - 1)) return [3 /*break*/, 3];
19964
+ return [4 /*yield*/, Requests.uploadFile(PostsRoute.routes.create.url, 'file', chunk, formData)];
19965
+ case 2:
19966
+ _a.sent();
19967
+ return [3 /*break*/, 5];
19968
+ case 3: return [4 /*yield*/, Requests.uploadFile(PostsRoute.routes.create.url, 'file', chunk, formData)];
19969
+ case 4:
19970
+ _a.sent();
19971
+ _a.label = 5;
19972
+ case 5:
19973
+ i++;
19974
+ return [3 /*break*/, 1];
19975
+ case 6:
19976
+ {
19977
+ throw new Error("No response from the last chunk upload");
19978
+ }
19979
+ }
19980
+ });
19981
+ });
19982
+ };
19861
19983
  /**
19862
19984
  * Update a post.
19863
19985
  *