Socket
Socket
Sign inDemoInstall

twitter-api-v2

Package Overview
Dependencies
0
Maintainers
1
Versions
62
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.15.2 to 1.16.0

4

changelog.md

@@ -0,1 +1,5 @@

1.16.0
------
- feat: Add the ability to return whole media information while uploading #506 (@qedr @HapLifeMan)
1.15.2

@@ -2,0 +6,0 @@ ------

@@ -162,3 +162,6 @@ import { AccountProfileV1Params, AccountSettingsV1, AccountSettingsV1Params, AddOrRemoveListMembersV1Params, FriendshipCreateOrDestroyV1, FriendshipCreateV1Params, FriendshipDestroyV1Params, FriendshipUpdateV1Params, FriendshipV1, GetListV1Params, ListCreateV1Params, ListV1, MediaMetadataV1Params, MediaStatusV1Result, MediaSubtitleV1Param, ProfileBannerUpdateV1Params, ProfileImageUpdateV1Params, ReportSpamV1Params, SendTweetV1Params, TUploadableMedia, TweetV1, UpdateListV1Params, UploadMediaV1Params, UserV1 } from '../types';

* You must specify it if you send a media to use in DMs.
*
* @param returnFullMediaData If set to true, returns the whole media information instead of just the media_id
*/
uploadMedia(file: TUploadableMedia, options: Partial<UploadMediaV1Params>, returnFullMediaData: true): Promise<MediaStatusV1Result>;
uploadMedia(file: TUploadableMedia, options?: Partial<UploadMediaV1Params>): Promise<string>;

@@ -165,0 +168,0 @@ protected awaitForMediaProcessingCompletion(fullMediaData: MediaStatusV1Result): Promise<void>;

31

dist/cjs/v1/client.v1.write.js

@@ -274,25 +274,3 @@ "use strict";

}
/**
* Upload a media (JPG/PNG/GIF/MP4/MOV/WEBP) or subtitle (SRT) to Twitter and return the media_id to use in tweet/DM send.
*
* @param file If `string`, filename is supposed.
* A `Buffer` is a raw file.
* `fs.promises.FileHandle` or `number` are file pointers.
*
* @param options.type File type (Enum 'jpg' | 'longmp4' | 'mp4' | 'mov | 'png' | 'gif' | 'srt' | 'webp').
* If filename is given, it could be guessed with file extension, otherwise this parameter is mandatory.
* If type is not part of the enum, it will be used as mime type.
*
* Type `longmp4` is **required** is you try to upload a video higher than 140 seconds.
*
* @param options.chunkLength Maximum chunk length sent to Twitter. Default goes to 1 MB.
*
* @param options.additionalOwners Other user IDs allowed to use the returned media_id. Default goes to none.
*
* @param options.maxConcurrentUploads Maximum uploaded chunks in the same time. Default goes to 3.
*
* @param options.target Target type `tweet` or `dm`. Defaults to `tweet`.
* You must specify it if you send a media to use in DMs.
*/
async uploadMedia(file, options = {}) {
async uploadMedia(file, options = {}, returnFullMediaData = false) {
var _a;

@@ -324,3 +302,8 @@ const chunkLength = (_a = options.chunkLength) !== null && _a !== void 0 ? _a : (1024 * 1024);

// Video is ready, return media_id
return fullMediaData.media_id_string;
if (returnFullMediaData) {
return fullMediaData;
}
else {
return fullMediaData.media_id_string;
}
}

@@ -327,0 +310,0 @@ finally {

@@ -162,3 +162,6 @@ import { AccountProfileV1Params, AccountSettingsV1, AccountSettingsV1Params, AddOrRemoveListMembersV1Params, FriendshipCreateOrDestroyV1, FriendshipCreateV1Params, FriendshipDestroyV1Params, FriendshipUpdateV1Params, FriendshipV1, GetListV1Params, ListCreateV1Params, ListV1, MediaMetadataV1Params, MediaStatusV1Result, MediaSubtitleV1Param, ProfileBannerUpdateV1Params, ProfileImageUpdateV1Params, ReportSpamV1Params, SendTweetV1Params, TUploadableMedia, TweetV1, UpdateListV1Params, UploadMediaV1Params, UserV1 } from '../types';

* You must specify it if you send a media to use in DMs.
*
* @param returnFullMediaData If set to true, returns the whole media information instead of just the media_id
*/
uploadMedia(file: TUploadableMedia, options: Partial<UploadMediaV1Params>, returnFullMediaData: true): Promise<MediaStatusV1Result>;
uploadMedia(file: TUploadableMedia, options?: Partial<UploadMediaV1Params>): Promise<string>;

@@ -165,0 +168,0 @@ protected awaitForMediaProcessingCompletion(fullMediaData: MediaStatusV1Result): Promise<void>;

@@ -246,25 +246,3 @@ import * as fs from 'fs';

}
/**
* Upload a media (JPG/PNG/GIF/MP4/MOV/WEBP) or subtitle (SRT) to Twitter and return the media_id to use in tweet/DM send.
*
* @param file If `string`, filename is supposed.
* A `Buffer` is a raw file.
* `fs.promises.FileHandle` or `number` are file pointers.
*
* @param options.type File type (Enum 'jpg' | 'longmp4' | 'mp4' | 'mov | 'png' | 'gif' | 'srt' | 'webp').
* If filename is given, it could be guessed with file extension, otherwise this parameter is mandatory.
* If type is not part of the enum, it will be used as mime type.
*
* Type `longmp4` is **required** is you try to upload a video higher than 140 seconds.
*
* @param options.chunkLength Maximum chunk length sent to Twitter. Default goes to 1 MB.
*
* @param options.additionalOwners Other user IDs allowed to use the returned media_id. Default goes to none.
*
* @param options.maxConcurrentUploads Maximum uploaded chunks in the same time. Default goes to 3.
*
* @param options.target Target type `tweet` or `dm`. Defaults to `tweet`.
* You must specify it if you send a media to use in DMs.
*/
async uploadMedia(file, options = {}) {
async uploadMedia(file, options = {}, returnFullMediaData = false) {
var _a;

@@ -296,3 +274,8 @@ const chunkLength = (_a = options.chunkLength) !== null && _a !== void 0 ? _a : (1024 * 1024);

// Video is ready, return media_id
return fullMediaData.media_id_string;
if (returnFullMediaData) {
return fullMediaData;
}
else {
return fullMediaData.media_id_string;
}
}

@@ -299,0 +282,0 @@ finally {

{
"name": "twitter-api-v2",
"version": "1.15.2",
"version": "1.16.0",
"description": "Strongly typed, full-featured, light, versatile yet powerful Twitter API v1.1 and v2 client for Node.js.",

@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc