glitch-javascript-sdk 0.8.2 → 0.8.4

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
@@ -18637,7 +18637,7 @@ var Requests = /** @class */ (function () {
18637
18637
  // Method adapted for browser environments
18638
18638
  Requests.uploadFileInChunks = function (file, uploadUrl, onProgress, data, chunkSize) {
18639
18639
  return __awaiter(this, void 0, void 0, function () {
18640
- var fileSize, totalChunks, currentChunkIndex, totalUploaded, array, identifier, start, end, chunk, formData, key, fullUploadUrl, headers;
18640
+ var fileSize, totalChunks, currentChunkIndex, array, identifier, _loop_1;
18641
18641
  return __generator(this, function (_a) {
18642
18642
  switch (_a.label) {
18643
18643
  case 0:
@@ -18647,48 +18647,57 @@ var Requests = /** @class */ (function () {
18647
18647
  fileSize = file.size;
18648
18648
  totalChunks = Math.ceil(fileSize / chunkSize);
18649
18649
  currentChunkIndex = 0;
18650
- totalUploaded = 0;
18651
18650
  array = new Uint32Array(4);
18652
18651
  window.crypto.getRandomValues(array);
18653
18652
  identifier = Array.from(array, function (dec) { return ('0' + dec.toString(16)).substr(-2); }).join('');
18653
+ _loop_1 = function () {
18654
+ var start, end, chunk, formData, key, fullUploadUrl, headers;
18655
+ return __generator(this, function (_b) {
18656
+ switch (_b.label) {
18657
+ case 0:
18658
+ start = currentChunkIndex * chunkSize;
18659
+ end = Math.min(start + chunkSize, fileSize);
18660
+ chunk = file.slice(start, end);
18661
+ formData = new FormData();
18662
+ formData.append('video', chunk, file.name);
18663
+ formData.append('chunkIndex', currentChunkIndex.toString());
18664
+ formData.append('totalChunks', totalChunks.toString());
18665
+ formData.append('identifier', identifier);
18666
+ // If there's additional data, append each key-value pair to the formData
18667
+ if (data) {
18668
+ for (key in data) {
18669
+ formData.append(key, data[key]);
18670
+ }
18671
+ }
18672
+ fullUploadUrl = "".concat(Requests.baseUrl).concat(uploadUrl);
18673
+ headers = {};
18674
+ if (Requests.authToken) {
18675
+ headers['Authorization'] = "Bearer ".concat(Requests.authToken);
18676
+ }
18677
+ // Perform the upload
18678
+ return [4 /*yield*/, axios$1.post(fullUploadUrl, formData, {
18679
+ headers: headers,
18680
+ onUploadProgress: function (progressEvent) {
18681
+ progressEvent.loaded; // Bytes uploaded of the current chunk
18682
+ if (onProgress) {
18683
+ onProgress(fileSize, end);
18684
+ }
18685
+ }
18686
+ })];
18687
+ case 1:
18688
+ // Perform the upload
18689
+ _b.sent();
18690
+ currentChunkIndex++;
18691
+ return [2 /*return*/];
18692
+ }
18693
+ });
18694
+ };
18654
18695
  _a.label = 1;
18655
18696
  case 1:
18656
18697
  if (!(currentChunkIndex <= totalChunks)) return [3 /*break*/, 3];
18657
- start = currentChunkIndex * chunkSize;
18658
- end = Math.min(start + chunkSize, fileSize);
18659
- chunk = file.slice(start, end);
18660
- formData = new FormData();
18661
- formData.append('video', chunk, file.name);
18662
- formData.append('chunkIndex', currentChunkIndex.toString());
18663
- formData.append('totalChunks', totalChunks.toString());
18664
- formData.append('identifier', identifier);
18665
- // If there's additional data, append each key-value pair to the formData
18666
- if (data) {
18667
- for (key in data) {
18668
- formData.append(key, data[key]);
18669
- }
18670
- }
18671
- fullUploadUrl = "".concat(Requests.baseUrl).concat(uploadUrl);
18672
- headers = {};
18673
- if (Requests.authToken) {
18674
- headers['Authorization'] = "Bearer ".concat(Requests.authToken);
18675
- }
18676
- // Perform the upload
18677
- return [4 /*yield*/, axios$1.post(fullUploadUrl, formData, {
18678
- headers: headers,
18679
- onUploadProgress: function (progressEvent) {
18680
- var currentChunkProgress = progressEvent.loaded; // Bytes uploaded of the current chunk
18681
- // Calculate the total uploaded size including previous chunks and the current chunk's progress
18682
- var totalProgress = totalUploaded + currentChunkProgress;
18683
- if (onProgress) {
18684
- onProgress(fileSize, totalProgress);
18685
- }
18686
- }
18687
- })];
18698
+ return [5 /*yield**/, _loop_1()];
18688
18699
  case 2:
18689
- // Perform the upload
18690
18700
  _a.sent();
18691
- currentChunkIndex++;
18692
18701
  return [3 /*break*/, 1];
18693
18702
  case 3: return [2 /*return*/];
18694
18703
  }
@@ -22037,6 +22046,11 @@ var CampaignsRoute = /** @class */ (function () {
22037
22046
  markInfluencerCampaignComplete: { url: '/campaigns/{campaign_id}/influencers/{user_id}/setComplete', method: HTTP_METHODS.POST },
22038
22047
  markInfluencerCampaignIncomplete: { url: '/campaigns/{campaign_id}/influencers/{user_id}/setIncomplete', method: HTTP_METHODS.POST },
22039
22048
  listInfluencerCampaignLinks: { url: '/campaigns/{campaign_id}/influencers/{user_id}/links', method: HTTP_METHODS.GET },
22049
+ listCampaignMentions: { url: '/campaigns/{campaign_id}/mentions', method: HTTP_METHODS.GET },
22050
+ createCampaignMention: { url: '/campaigns/{campaign_id}/mentions', method: HTTP_METHODS.POST },
22051
+ getCampaignMention: { url: '/campaigns/{campaign_id}/mentions/{mention_id}', method: HTTP_METHODS.GET },
22052
+ updateCampaignMention: { url: '/campaigns/{campaign_id}/mentions/{mention_id}', method: HTTP_METHODS.PUT },
22053
+ deleteCampaignMention: { url: '/campaigns/{campaign_id}/mentions/{mention_id}', method: HTTP_METHODS.PUT },
22040
22054
  };
22041
22055
  return CampaignsRoute;
22042
22056
  }());
@@ -22230,6 +22244,65 @@ var Campaigns = /** @class */ (function () {
22230
22244
  Campaigns.listInfluencerCampaignLinks = function (campaign_id, user_id, params) {
22231
22245
  return Requests.processRoute(CampaignsRoute.routes.listInfluencerCampaignLinks, undefined, { campaign_id: campaign_id, user_id: user_id }, params);
22232
22246
  };
22247
+ /**
22248
+ * List all the campaign mentions.
22249
+ *
22250
+ * @see https://api.glitch.fun/api/documentation#/Campaigns/getCampaignLinks
22251
+ *
22252
+ * @returns promise
22253
+ */
22254
+ Campaigns.listCampaignMentions = function (campaign_id, params) {
22255
+ return Requests.processRoute(CampaignsRoute.routes.listCampaignMentions, undefined, { campaign_id: campaign_id }, params);
22256
+ };
22257
+ /**
22258
+ * Create a new campaign mention.
22259
+ *
22260
+ * @see https://api.glitch.fun/api/documentation#/Campaigns/storeCampaignLink
22261
+ *
22262
+ * @param data The data to be passed when creating a campaign.
22263
+ *
22264
+ * @returns Promise
22265
+ */
22266
+ Campaigns.createCampaignMention = function (campaign_id, data, params) {
22267
+ return Requests.processRoute(CampaignsRoute.routes.createCampaignMention, data, { campaign_id: campaign_id }, params);
22268
+ };
22269
+ /**
22270
+ * Update a campaign mention.
22271
+ *
22272
+ * @see https://api.glitch.fun/api/documentation#/Campaigns/1bb1492981b4529693604b03aade8bf6
22273
+ *
22274
+ * @param campaign_id The id of the campaign to update.
22275
+ * @param data The data to update.
22276
+ *
22277
+ * @returns promise
22278
+ */
22279
+ Campaigns.updateCampaignMention = function (campaign_id, mention_id, data, params) {
22280
+ return Requests.processRoute(CampaignsRoute.routes.updateCampaignMention, data, { campaign_id: campaign_id, mention_id: mention_id }, params);
22281
+ };
22282
+ /**
22283
+ * Retrieve the information for a single campaign mention.
22284
+ *
22285
+ * @see https://api.glitch.fun/api/documentation#/Campaigns/getCampaignLink
22286
+ *
22287
+ * @param campaign_id The id fo the campaign to retrieve.
22288
+ *
22289
+ * @returns promise
22290
+ */
22291
+ Campaigns.getCampaignMention = function (campaign_id, mention_id, params) {
22292
+ return Requests.processRoute(CampaignsRoute.routes.getCampaignMention, {}, { campaign_id: campaign_id, mention_id: mention_id }, params);
22293
+ };
22294
+ /**
22295
+ * Delete the information for a single campaign mention.
22296
+ *
22297
+ * @see https://api.glitch.fun/api/documentation#/Campaigns/getCampaignLink
22298
+ *
22299
+ * @param campaign_id The id fo the campaign to retrieve.
22300
+ *
22301
+ * @returns promise
22302
+ */
22303
+ Campaigns.deleteCampaignMention = function (campaign_id, mention_id, params) {
22304
+ return Requests.processRoute(CampaignsRoute.routes.deleteCampaignMention, {}, { campaign_id: campaign_id, mention_id: mention_id }, params);
22305
+ };
22233
22306
  return Campaigns;
22234
22307
  }());
22235
22308