@gramio/files
Advanced tools
Comparing version 0.0.10 to 0.0.11
@@ -24,4 +24,4 @@ /** | ||
export * from "./utils"; | ||
export { isFile, MEDIA_METHODS } from "./media-methods-helper"; | ||
export { isBlob, MEDIA_METHODS } from "./media-methods-helper"; | ||
export * from "./media-input"; | ||
export * from "./media-upload"; |
@@ -39,8 +39,8 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MEDIA_METHODS = exports.isFile = void 0; | ||
exports.MEDIA_METHODS = exports.isBlob = void 0; | ||
__exportStar(require("./utils"), exports); | ||
var media_methods_helper_1 = require("./media-methods-helper"); | ||
Object.defineProperty(exports, "isFile", { enumerable: true, get: function () { return media_methods_helper_1.isFile; } }); | ||
Object.defineProperty(exports, "isBlob", { enumerable: true, get: function () { return media_methods_helper_1.isBlob; } }); | ||
Object.defineProperty(exports, "MEDIA_METHODS", { enumerable: true, get: function () { return media_methods_helper_1.MEDIA_METHODS; } }); | ||
__exportStar(require("./media-input"), exports); | ||
__exportStar(require("./media-upload"), exports); |
@@ -13,4 +13,4 @@ import type { APIMethodParams, APIMethods, TelegramInputFile } from "@gramio/types"; | ||
}; | ||
/** Guard for check is it {@link File} or {@link Promise} */ | ||
export declare function isFile(file?: TelegramInputFile | object | string): boolean; | ||
/** Guard for check is it {@link Blob} or {@link Promise} */ | ||
export declare function isBlob(blob?: TelegramInputFile | object | string): boolean; | ||
/** | ||
@@ -17,0 +17,0 @@ * A set of methods with the function of checking whether a {@link File} has been passed in the parameters |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.MEDIA_METHODS = void 0; | ||
exports.isFile = isFile; | ||
/** Guard for check is it {@link File} or {@link Promise} */ | ||
function isFile(file) { | ||
if (!file || typeof file !== "object") | ||
exports.isBlob = isBlob; | ||
/** Guard for check is it {@link Blob} or {@link Promise} */ | ||
function isBlob(blob) { | ||
if (!blob || typeof blob !== "object") | ||
return false; | ||
return file instanceof File || file instanceof Promise; | ||
return blob instanceof Blob || blob instanceof Promise; | ||
} | ||
@@ -17,27 +17,27 @@ /** | ||
exports.MEDIA_METHODS = { | ||
setWebhook: [(params) => isFile(params.certificate), null], | ||
sendPhoto: [(params) => isFile(params.photo), null], | ||
setWebhook: [(params) => isBlob(params.certificate), null], | ||
sendPhoto: [(params) => isBlob(params.photo), null], | ||
sendAudio: [ | ||
(params) => isFile(params.audio) || isFile(params.thumbnail), | ||
(params) => isBlob(params.audio) || isBlob(params.thumbnail), | ||
null, | ||
], | ||
sendDocument: [ | ||
(params) => isFile(params.document) || isFile(params.thumbnail), | ||
(params) => isBlob(params.document) || isBlob(params.thumbnail), | ||
null, | ||
], | ||
sendVideo: [ | ||
(params) => isFile(params.video) || isFile(params.thumbnail), | ||
(params) => isBlob(params.video) || isBlob(params.thumbnail), | ||
null, | ||
], | ||
sendAnimation: [ | ||
(params) => isFile(params.animation) || isFile(params.thumbnail), | ||
(params) => isBlob(params.animation) || isBlob(params.thumbnail), | ||
null, | ||
], | ||
sendVoice: [(params) => isFile(params.voice), null], | ||
sendVoice: [(params) => isBlob(params.voice), null], | ||
sendVideoNote: [ | ||
(params) => isFile(params.video_note) || isFile(params.thumbnail), | ||
(params) => isBlob(params.video_note) || isBlob(params.thumbnail), | ||
null, | ||
], | ||
sendPaidMedia: [ | ||
(params) => params.media.some((x) => "media" in x && isFile(x.media)), | ||
(params) => params.media.some((x) => "media" in x && isBlob(x.media)), | ||
[ | ||
@@ -52,4 +52,4 @@ { | ||
sendMediaGroup: [ | ||
(params) => params.media.some((x) => "media" in x && isFile(x.media)) || | ||
params.media.some((x) => "thumbnail" in x && isFile(x.thumbnail)), | ||
(params) => params.media.some((x) => "media" in x && isBlob(x.media)) || | ||
params.media.some((x) => "thumbnail" in x && isBlob(x.thumbnail)), | ||
[ | ||
@@ -68,6 +68,6 @@ { | ||
], | ||
setChatPhoto: [(params) => isFile(params.photo), null], | ||
setChatPhoto: [(params) => isBlob(params.photo), null], | ||
editMessageMedia: [ | ||
(params) => ("media" in params.media && isFile(params.media.media)) || | ||
("thumbnail" in params.media && isFile(params.media.thumbnail)), | ||
(params) => ("media" in params.media && isBlob(params.media.media)) || | ||
("thumbnail" in params.media && isBlob(params.media.thumbnail)), | ||
[ | ||
@@ -86,6 +86,6 @@ { | ||
], | ||
sendSticker: [(params) => isFile(params.sticker), null], | ||
uploadStickerFile: [(params) => isFile(params.sticker), null], | ||
sendSticker: [(params) => isBlob(params.sticker), null], | ||
uploadStickerFile: [(params) => isBlob(params.sticker), null], | ||
createNewStickerSet: [ | ||
(params) => params.stickers.some((x) => "sticker" in x && isFile(x.sticker)), | ||
(params) => params.stickers.some((x) => "sticker" in x && isBlob(x.sticker)), | ||
[ | ||
@@ -99,5 +99,5 @@ { | ||
], | ||
addStickerToSet: [(params) => isFile(params.sticker.sticker), null], | ||
replaceStickerInSet: [(params) => isFile(params.sticker.sticker), null], | ||
setStickerSetThumbnail: [(params) => isFile(params.thumbnail), null], | ||
addStickerToSet: [(params) => isBlob(params.sticker.sticker), null], | ||
replaceStickerInSet: [(params) => isBlob(params.sticker.sticker), null], | ||
setStickerSetThumbnail: [(params) => isBlob(params.thumbnail), null], | ||
}; |
{ | ||
"name": "@gramio/files", | ||
"main": "./dist/index.js", | ||
"version": "0.0.10", | ||
"type": "commonjs", | ||
"description": "Set of utils for work with files and Telegram Bot API", | ||
"keywords": [ | ||
"gramio", | ||
"telegram", | ||
"file", | ||
"files", | ||
"upload" | ||
], | ||
"scripts": { | ||
"generate": "bun scripts/generate.ts", | ||
"prepublishOnly": "tsc", | ||
"lint": "bunx @biomejs/biome check ./src", | ||
"lint:fix": "bun lint --apply", | ||
"jsr": "bun scripts/release-jsr.ts" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "1.7.3", | ||
"@types/bun": "^1.1.6", | ||
"@types/node": "^20.14.9", | ||
"prettier": "^3.3.2", | ||
"typescript": "^5.5.3" | ||
}, | ||
"dependencies": { | ||
"@gramio/types": "^7.6.0" | ||
}, | ||
"files": [ | ||
"dist" | ||
] | ||
"name": "@gramio/files", | ||
"main": "./dist/index.js", | ||
"version": "0.0.11", | ||
"type": "commonjs", | ||
"description": "Set of utils for work with files and Telegram Bot API", | ||
"keywords": [ | ||
"gramio", | ||
"telegram", | ||
"file", | ||
"files", | ||
"upload" | ||
], | ||
"scripts": { | ||
"generate": "bun scripts/generate.ts", | ||
"prepublishOnly": "tsc", | ||
"lint": "bunx @biomejs/biome check ./src", | ||
"lint:fix": "bun lint --apply", | ||
"jsr": "bun scripts/release-jsr.ts" | ||
}, | ||
"devDependencies": { | ||
"@biomejs/biome": "1.7.3", | ||
"@types/bun": "^1.1.6", | ||
"@types/node": "^20.14.10", | ||
"prettier": "^3.3.2", | ||
"typescript": "^5.5.3" | ||
}, | ||
"dependencies": { | ||
"@gramio/types": "^7.7.0" | ||
}, | ||
"files": [ | ||
"dist" | ||
] | ||
} |
18441
Updated@gramio/types@^7.7.0