mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 19:51:53 +00:00
add @types/qiniu
add qiniu definetion
This commit is contained in:
Vendored
+625
@@ -0,0 +1,625 @@
|
||||
// Type definitions for qiniu 6.1
|
||||
// Project: https://github.com/qiniu/nodejs-sdk
|
||||
// Definitions by: xialeistudio <https://github.com/xialeistudio>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
/**
|
||||
* * Licensed under:
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2016 unional
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
declare namespace qiniu {
|
||||
type onret = (e?: any, result?: any, res?: any) => void;
|
||||
class conf {
|
||||
/**
|
||||
* AccessKey
|
||||
* @see https://portal.qiniu.com/user/key
|
||||
*/
|
||||
static ACCESS_KEY: string;
|
||||
|
||||
/**
|
||||
* SecretKey.DO NOT SEND YOUR SECRET KEY TO ANYONE!
|
||||
*/
|
||||
static SECRET_KEY: string;
|
||||
|
||||
/**
|
||||
* @default 'QiniuNodejs/' + pkg.version + ' (' + os.type() + '; ' + os.platform() + '; ' + os.arch() + '; )';
|
||||
*/
|
||||
static USER_AGENT: string;
|
||||
|
||||
/**
|
||||
* @default 'http://upload.qiniu.com'
|
||||
*/
|
||||
static UP_HOST: string;
|
||||
|
||||
/**
|
||||
* @default 'http://rs.qbox.me'
|
||||
*/
|
||||
static RS_HOST: string;
|
||||
|
||||
/**
|
||||
* @default 'http://rsf.qbox.me'
|
||||
*/
|
||||
static RSF_HOST: string;
|
||||
|
||||
/**
|
||||
* @default 'http://api.qiniu.com'
|
||||
*/
|
||||
static API_HOST: string;
|
||||
|
||||
/**
|
||||
* @default 3600000 milliseconds
|
||||
*/
|
||||
static RPC_TIMEOUT: number;
|
||||
|
||||
/**
|
||||
* @default 'http://uc.qbox.me'
|
||||
*/
|
||||
static UC_HOST: string;
|
||||
|
||||
/**
|
||||
* @default 'https://up-z1.qbox.me'
|
||||
*/
|
||||
static UP_HTTPS_HOST: string;
|
||||
|
||||
/**
|
||||
* @default 'http'
|
||||
*/
|
||||
static SCHEME: string;
|
||||
|
||||
/**
|
||||
* get upload domain automatically
|
||||
* @default true
|
||||
*/
|
||||
static AUTOZONE: boolean;
|
||||
|
||||
/**
|
||||
* @default null
|
||||
*/
|
||||
static BUCKET: string | null;
|
||||
|
||||
/**
|
||||
* @default 0
|
||||
*/
|
||||
static EXPIRE: number;
|
||||
}
|
||||
namespace auth {
|
||||
class Mac {
|
||||
/**
|
||||
* @see config.ACCESS_KEY
|
||||
*/
|
||||
accessKey: string;
|
||||
|
||||
/**
|
||||
* @see config.SECRET_KEY
|
||||
*/
|
||||
secretKey: string;
|
||||
|
||||
/**
|
||||
* constructor a Mac
|
||||
* @param accessKey config.ACCESS_KEY
|
||||
* @param secretKey config.SECRET_KEY
|
||||
*/
|
||||
constructor(accessKey: string, secretKey: string);
|
||||
}
|
||||
}
|
||||
namespace io {
|
||||
/**
|
||||
* @default '?'
|
||||
*/
|
||||
const UNDEFINED_KEY: string;
|
||||
class PutExtra {
|
||||
params: any;
|
||||
mimeType?: string;
|
||||
crc32?: string;
|
||||
checkCrc?: number;
|
||||
|
||||
/**
|
||||
* contructor a PutExtra
|
||||
* @param params default {}
|
||||
* @param mimeType default null
|
||||
* @param crc32 default null
|
||||
* @param checkCrc default 0
|
||||
*/
|
||||
constructor(params?: any, mimeType?: string, crc32?: string, checkCrc?: number);
|
||||
}
|
||||
class PutRet {
|
||||
hash?: string;
|
||||
key?: string;
|
||||
/**
|
||||
* constructor a PutRet
|
||||
* @param hash resouce hash
|
||||
* @param key resource key
|
||||
*/
|
||||
constructor(hash?: string, key?: string);
|
||||
}
|
||||
|
||||
/**
|
||||
* upload a file streaming
|
||||
* @param uptoken upload token @see rs.PutPolicy.token()
|
||||
* @param key file key
|
||||
* @param rs file stream
|
||||
* @param extra upload options
|
||||
* @param onret callback
|
||||
*/
|
||||
function putReadable(uptoken: string, key?: string, rs?: any, extra?: any, onret?: onret): any;
|
||||
/**
|
||||
* upload binary data
|
||||
* @param uptoken upload token @see rs.PutPolicy.token()
|
||||
* @param key file key
|
||||
* @param body the data to upload
|
||||
* @param extra upload options
|
||||
* @param onret callback
|
||||
*/
|
||||
function put(uptoken: string, key?: string, body?: Buffer | string, extra?: any, onret?: onret): any;
|
||||
/**
|
||||
* upload binary data without a key
|
||||
* @param uptoken upload token @see rs.PutPolicy.token()
|
||||
* @param body Buffer or string
|
||||
* @param extra upload options
|
||||
* @param onret callback
|
||||
*/
|
||||
function putWithoutKey(uptoken: string, body?: Buffer | string, extra?: any, onret?: onret): any;
|
||||
/**
|
||||
* upload a file
|
||||
* @param uptoken upload token @see rs.PutPolicy.token()
|
||||
* @param key file key
|
||||
* @param localFile local file path to upload
|
||||
* @param extra upload options
|
||||
* @param onret callback
|
||||
*/
|
||||
function putFile(uptoken: string, key?: string, localFile?: string, extra?: any, onret?: onret): any;
|
||||
/**
|
||||
* upload a file without a key
|
||||
* @param uptoken upload token @see rs.PutPolicy.token()
|
||||
* @param localFile local file path to upload
|
||||
* @param extra upload options
|
||||
* @param onret callback
|
||||
*/
|
||||
function putFileWithoutKey(uptoken: string, localFile?: string, extra?: any, onret?: onret): any;
|
||||
}
|
||||
namespace util {
|
||||
/**
|
||||
* @param jsonFlags
|
||||
*/
|
||||
function urlsafeBase64Encode(jsonFlags: any): string;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param v
|
||||
*/
|
||||
function base64ToUrlSafe(v: string): string;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param encodedFlags
|
||||
* @param secretKey
|
||||
*/
|
||||
function hmacSha1(encodedFlags: any, secretKey: string): string;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param uri
|
||||
* @param body
|
||||
*/
|
||||
function generateAccessToken(uri: string, body?: any): string;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param path
|
||||
* @param body
|
||||
* @param callbackAuth
|
||||
*/
|
||||
function isQiniuCallback(path: string, body: any, callbackAuth: any): boolean;
|
||||
}
|
||||
namespace zone {
|
||||
/**
|
||||
*
|
||||
* @param uptoken
|
||||
* @param conf
|
||||
*/
|
||||
function up_host(uptoken: string, conf: conf): void;
|
||||
}
|
||||
namespace rsf {
|
||||
/**
|
||||
*
|
||||
* @param bucket
|
||||
* @param prefix
|
||||
* @param marker
|
||||
* @param limit
|
||||
* @param delimiter
|
||||
* @param onret
|
||||
*/
|
||||
function listPrefix(bucket: string, prefix?: string, marker?: any, limit?: any, delimiter?: any, onret?: onret): void;
|
||||
}
|
||||
namespace rpc {
|
||||
/**
|
||||
*
|
||||
* @param uri
|
||||
* @param form
|
||||
* @param onret
|
||||
*/
|
||||
function postMultipart(uri: string, form: any, onret?: onret): any;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param uri
|
||||
* @param form
|
||||
* @param token
|
||||
* @param onret
|
||||
*/
|
||||
function postWithForm(uri: string, form: any, token?: string, onret?: onret): any;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param uri
|
||||
* @param token
|
||||
* @param onret
|
||||
*/
|
||||
function postWithoutForm(uri: string, token?: string, onret?: onret): any;
|
||||
}
|
||||
namespace fop {
|
||||
class ImageView {
|
||||
mode: number;
|
||||
width: number;
|
||||
height: number;
|
||||
quality: number;
|
||||
format: any;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param mode
|
||||
* @param width
|
||||
* @param height
|
||||
* @param quality
|
||||
* @param format
|
||||
*/
|
||||
constructor(mode?: number, width?: number, height?: number, quality?: number, format?: any);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
makeRequest(url: string): string;
|
||||
}
|
||||
|
||||
class ImageInfo {
|
||||
/**
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
makeRequest(url: string): string;
|
||||
}
|
||||
class Exif {
|
||||
/**
|
||||
*
|
||||
* @param url
|
||||
*/
|
||||
makeRequest(url: string): string;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bucket
|
||||
* @param key
|
||||
* @param fops
|
||||
* @param opts
|
||||
* @param onret
|
||||
*/
|
||||
function pfop(bucket: string, key: string, fops: any, opts?: any, onret?: onret): void;
|
||||
}
|
||||
namespace rs {
|
||||
import Mac = qiniu.auth.Mac;
|
||||
class Client {
|
||||
client?: Client;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param client
|
||||
*/
|
||||
constructor(client?: Client);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param bucket
|
||||
* @param key
|
||||
* @param onret
|
||||
*/
|
||||
stat(bucket: string, key: string, onret?: onret): void;
|
||||
/**
|
||||
*
|
||||
* @param bucket
|
||||
* @param key
|
||||
* @param onret
|
||||
*/
|
||||
remove(bucket: string, key: string, onret?: onret): void;
|
||||
/**
|
||||
*
|
||||
* @param bucketSrc
|
||||
* @param keySrc
|
||||
* @param bucketDest
|
||||
* @param keyDest
|
||||
* @param onret
|
||||
*/
|
||||
move(bucketSrc: string, keySrc: string, bucketDest: string, keyDest: string, onret?: onret): void;
|
||||
/**
|
||||
*
|
||||
* @param bucketSrc
|
||||
* @param keySrc
|
||||
* @param bucketDest
|
||||
* @param keyDest
|
||||
* @param force
|
||||
* @param onret
|
||||
*/
|
||||
forceMove(bucketSrc: string, keySrc: string, bucketDest: string, keyDest: string, force: boolean, onret?: onret): void;
|
||||
/**
|
||||
*
|
||||
* @param bucketSrc
|
||||
* @param keySrc
|
||||
* @param bucketDest
|
||||
* @param keyDest
|
||||
* @param onret
|
||||
*/
|
||||
copy(bucketSrc: string, keySrc: string, bucketDest: string, keyDest: string, onret?: onret): void;
|
||||
/**
|
||||
*
|
||||
* @param bucketSrc
|
||||
* @param keySrc
|
||||
* @param bucketDest
|
||||
* @param keyDest
|
||||
* @param force
|
||||
* @param onret
|
||||
*/
|
||||
forceCopy(bucketSrc: string, keySrc: string, bucketDest: string, keyDest: string, force: boolean, onret?: onret): void;
|
||||
/**
|
||||
*
|
||||
* @param url
|
||||
* @param bucket
|
||||
* @param key
|
||||
* @param onret
|
||||
*/
|
||||
fetch(url: string, bucket: string, key: string, onret?: onret): void;
|
||||
/**
|
||||
*
|
||||
* @param entries
|
||||
* @param onret
|
||||
*/
|
||||
batchStat(entries: any[], onret?: onret): void;
|
||||
/**
|
||||
*
|
||||
* @param entries
|
||||
* @param onret
|
||||
*/
|
||||
batchDelete(entries: any[], onret?: onret): void;
|
||||
/**
|
||||
*
|
||||
* @param entries
|
||||
* @param onret
|
||||
*/
|
||||
batchMove(entries: any[], onret?: onret): void;
|
||||
/**
|
||||
*
|
||||
* @param entries
|
||||
* @param force
|
||||
* @param onret
|
||||
*/
|
||||
forceBatchMove(entries: any[], force: boolean, onret?: onret): void;
|
||||
/**
|
||||
*
|
||||
* @param entries
|
||||
* @param onret
|
||||
*/
|
||||
batchCopy(entries: any[], onret?: onret): void;
|
||||
/**
|
||||
*
|
||||
* @param entries
|
||||
* @param force
|
||||
* @param onret
|
||||
*/
|
||||
forceBatchCopy(entries: any[], force: boolean, onret?: onret): void;
|
||||
}
|
||||
class Entry {
|
||||
hash?: string;
|
||||
fsize?: number;
|
||||
putTime?: number;
|
||||
mimeType?: string;
|
||||
endUser?: any;
|
||||
/**
|
||||
*
|
||||
* @param hash
|
||||
* @param fsize
|
||||
* @param putTime
|
||||
* @param mimeType
|
||||
* @param endUser
|
||||
*/
|
||||
constructor(hash?: string, fsize?: number, putTime?: number, mimeType?: string, endUser?: any);
|
||||
}
|
||||
class EntryPath {
|
||||
bucket?: string;
|
||||
key?: string;
|
||||
/**
|
||||
*
|
||||
* @param bucket
|
||||
* @param key
|
||||
*/
|
||||
constructor(bucket?: string, key?: string);
|
||||
/**
|
||||
*
|
||||
*/
|
||||
encode(): string;
|
||||
/**
|
||||
*
|
||||
* @param op
|
||||
*/
|
||||
toStr(op: string): string;
|
||||
}
|
||||
class EntryPathPair {
|
||||
src?: string;
|
||||
dest?: string;
|
||||
/**
|
||||
*
|
||||
* @param src
|
||||
* @param desc
|
||||
*/
|
||||
constructor(src?: string, desc?: string);
|
||||
/**
|
||||
*
|
||||
* @param op
|
||||
* @param force
|
||||
*/
|
||||
toStr(op: string, force?: boolean): string;
|
||||
}
|
||||
class BatchItemRet {
|
||||
error?: any;
|
||||
code?: number;
|
||||
/**
|
||||
*
|
||||
* @param error
|
||||
* @param code
|
||||
*/
|
||||
constructor(error?: any, code?: number);
|
||||
}
|
||||
class BatchStatItemRet {
|
||||
data: any;
|
||||
error: any;
|
||||
code: number;
|
||||
/**
|
||||
*
|
||||
* @param data
|
||||
* @param error
|
||||
* @param code
|
||||
*/
|
||||
constructor(data: any, error: any, code: number);
|
||||
}
|
||||
class PutPolicy {
|
||||
scope?: string;
|
||||
callbackUrl?: string;
|
||||
callbackBody?: any;
|
||||
returnUrl?: string;
|
||||
returnBody?: any;
|
||||
endUser?: any;
|
||||
expires: number;
|
||||
persistentOps?: any;
|
||||
persistentNotifyUrl?: string;
|
||||
/**
|
||||
*
|
||||
* @param score
|
||||
* @param callbackUrl
|
||||
* @param callbackBody
|
||||
* @param returnUrl
|
||||
* @param returnBody
|
||||
* @param endUser
|
||||
* @param expires
|
||||
* @param persistentOps
|
||||
* @param persistentNotifyUrl
|
||||
*/
|
||||
constructor(score?: string, callbackUrl?: string, callbackBody?: any, returnUrl?: string, returnBody?: any, endUser?: any, expires?: number, persistentOps?: any, persistentNotifyUrl?: string);
|
||||
/**
|
||||
*
|
||||
* @param mac
|
||||
*/
|
||||
token(mac?: Mac): string;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
getFlags(): any;
|
||||
}
|
||||
interface putPolicyObj {
|
||||
scope?: string;
|
||||
expires?: number;
|
||||
insertOnly?: boolean;
|
||||
saveKey?: string;
|
||||
endUser?: any;
|
||||
returnUrl?: string;
|
||||
returnBody?: any;
|
||||
callbackUrl?: string;
|
||||
callbackHost?: string;
|
||||
callbackBody?: any;
|
||||
callbackBodyType?: string;
|
||||
callbackFetchKey?: string;
|
||||
persistentOps?: any;
|
||||
persistentNotifyUrl?: string;
|
||||
persistentPipeline?: string;
|
||||
fsizeLimit?: number;
|
||||
fsizeMin?: any;
|
||||
detectMime?: any;
|
||||
mimeLimit?: any;
|
||||
deleteAfterDays?: number;
|
||||
}
|
||||
class PutPolicy2 {
|
||||
scope?: string;
|
||||
expires: number;
|
||||
insertOnly?: boolean;
|
||||
saveKey?: string;
|
||||
endUser?: any;
|
||||
returnUrl?: string;
|
||||
returnBody?: any;
|
||||
callbackUrl?: string;
|
||||
callbackHost?: string;
|
||||
callbackBody?: any;
|
||||
callbackBodyType?: string;
|
||||
callbackFetchKey?: string;
|
||||
persistentOps?: any;
|
||||
persistentNotifyUrl?: string;
|
||||
persistentPipeline?: string;
|
||||
fsizeLimit?: number;
|
||||
fsizeMin?: any;
|
||||
detectMime?: any;
|
||||
mimeLimit?: any;
|
||||
deleteAfterDays?: number;
|
||||
/**
|
||||
*
|
||||
* @param putPolicyObj
|
||||
*/
|
||||
constructor(putPolicyObj: putPolicyObj);
|
||||
/**
|
||||
*
|
||||
* @param mac
|
||||
*/
|
||||
token(mac?: Mac): string;
|
||||
/**
|
||||
*
|
||||
*/
|
||||
getFlags(): any;
|
||||
}
|
||||
class GetPolicy {
|
||||
expires: number;
|
||||
/**
|
||||
*
|
||||
* @param expires
|
||||
*/
|
||||
constructor(expires?: number);
|
||||
/**
|
||||
*
|
||||
* @param baseUrl
|
||||
* @param mac
|
||||
*/
|
||||
makeRequest(baseUrl: string, mac?: Mac): string;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param domain
|
||||
* @param key
|
||||
* @param query
|
||||
*/
|
||||
function makeBaseUrl(domain: string, key: string, query?: string): string;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,149 @@
|
||||
/// <reference types="qiniu" />
|
||||
// test for qiniu.conf
|
||||
function testConf() {
|
||||
qiniu.conf.ACCESS_KEY = 'Access_Key';
|
||||
qiniu.conf.SECRET_KEY = 'Secret_Key';
|
||||
}
|
||||
// test for qiniu.auth
|
||||
function testAuth() {
|
||||
// test for auth.Mac
|
||||
var mac = new qiniu.auth.Mac(qiniu.conf.ACCESS_KEY, qiniu.conf.SECRET_KEY);
|
||||
}
|
||||
// test for qiniu.io
|
||||
function testIo() {
|
||||
// test for PutExtra
|
||||
var putExtra = new qiniu.io.PutExtra();
|
||||
// test for PutRet
|
||||
var putRet = new qiniu.io.PutRet();
|
||||
// test for putReadable
|
||||
qiniu.io.putReadable('xxx', null, null, null, function (e, result, res) {
|
||||
});
|
||||
// test for put
|
||||
qiniu.io.put('xxx', null, 'test-data', null, function (e, result, res) {
|
||||
});
|
||||
// test for putWithoutKey
|
||||
qiniu.io.putWithoutKey('xxx', 'test-data', null, function (e, result, res) {
|
||||
});
|
||||
// test for putFile
|
||||
qiniu.io.putFile('xxx', null, 'tslint.json', null, function (e, result, res) {
|
||||
});
|
||||
// test for putFileWithoutKey
|
||||
qiniu.io.putFileWithoutKey('xxx', 'tslint.json', null, function (e, result, res) {
|
||||
});
|
||||
}
|
||||
// test for qiniu.util
|
||||
function testUtil() {
|
||||
// test for urlsafeBase64Encode
|
||||
qiniu.util.urlsafeBase64Encode(null);
|
||||
// test for base64ToUrlSafe
|
||||
qiniu.util.base64ToUrlSafe('https://example.com');
|
||||
// test for hmacSha1
|
||||
qiniu.util.hmacSha1(null, 'test');
|
||||
// test for generateAccessToken
|
||||
qiniu.util.generateAccessToken('https://example.com');
|
||||
// test for isQiniuCallback
|
||||
qiniu.util.isQiniuCallback('/key', 'test-data', 'test-auth');
|
||||
}
|
||||
// test for qiniu.zone
|
||||
function testZone() {
|
||||
qiniu.zone.up_host('test', { ACCESS_KEY: 'xx', SECRET_KEY: 'ss' });
|
||||
}
|
||||
// test for qiniu.rsf
|
||||
function testRsf() {
|
||||
qiniu.rsf.listPrefix('test');
|
||||
}
|
||||
// test for qiniu.rpc
|
||||
function testRpc() {
|
||||
// test for postMultipart
|
||||
qiniu.rpc.postMultipart('https://up.qbox.me', 'test');
|
||||
// test for postWithForm
|
||||
qiniu.rpc.postWithForm('https://up.qbox.me', 'test');
|
||||
// test for postWithoutForm
|
||||
qiniu.rpc.postWithoutForm('https://up.qbox.me');
|
||||
}
|
||||
// test for qiniu.fop
|
||||
function testFop() {
|
||||
// test for ImageView
|
||||
var imageView = new qiniu.fop.ImageView(1, 1, 1, 1);
|
||||
imageView.makeRequest('https://up.qbox.me');
|
||||
// test for ImageInfo
|
||||
var imageInfo = new qiniu.fop.ImageInfo();
|
||||
imageInfo.makeRequest('https://up.qbox.me');
|
||||
// test for Exif
|
||||
var exif = new qiniu.fop.Exif();
|
||||
exif.makeRequest('https://up.qbox.me');
|
||||
// test for fop
|
||||
qiniu.fop.pfop('test', 'test', 'test');
|
||||
}
|
||||
// test for qiniu.rs
|
||||
function testRs() {
|
||||
// test for Client
|
||||
var client = new qiniu.rs.Client();
|
||||
// test for Client.stat
|
||||
client.stat('test', 'test', function (e, result, res) {
|
||||
});
|
||||
// test for Client.remove
|
||||
client.remove('test', 'test', function (e, result, res) {
|
||||
});
|
||||
// test for Client.move
|
||||
client.move('test-src', 'test-src', 'test-dest', 'test-dest', function (e, result, res) {
|
||||
});
|
||||
// test for Client.forceMove
|
||||
client.forceMove('test-src', 'test-src', 'test-dest', 'test-dest', true, function (e, result, res) {
|
||||
});
|
||||
// test for Client.copy
|
||||
client.copy('test-src', 'test-src', 'test-dest', 'test-dest', function (e, result, res) {
|
||||
});
|
||||
// test for Client.forceCopy
|
||||
client.forceCopy('test-src', 'test-src', 'test-dest', 'test-dest', true, function (e, result, res) {
|
||||
});
|
||||
// test for Client.fetch
|
||||
client.fetch('https://up.qbox.me', 'test', 'test', function (e, result, res) {
|
||||
});
|
||||
// test for Client.batchStat
|
||||
client.batchStat(['data'], function (e, result, res) {
|
||||
});
|
||||
// test for Client.batchDelete
|
||||
client.batchDelete(['data'], function (e, result, res) {
|
||||
});
|
||||
// test for Client.batchMove
|
||||
client.batchMove(['data'], function (e, result, res) {
|
||||
});
|
||||
// test for Client.forceBatchMove
|
||||
client.forceBatchMove(['data'], true, function (e, result, res) {
|
||||
});
|
||||
// test for Client.batchCopy
|
||||
client.batchCopy(['data'], function (e, result, res) {
|
||||
});
|
||||
// test for Client.forceBatchMove
|
||||
client.forceBatchCopy(['data'], true, function (e, result, res) {
|
||||
});
|
||||
// test for Entry
|
||||
var entry = new qiniu.rs.Entry('xx', 1, 1);
|
||||
// test for EntryPath
|
||||
var entryPath = new qiniu.rs.EntryPath('test', 'test');
|
||||
entryPath.encode();
|
||||
entryPath.toStr('x');
|
||||
// test for EntryPathPair
|
||||
var entryPathPair = new qiniu.rs.EntryPathPair('xxx', 'xxx');
|
||||
entryPathPair.toStr('x', false);
|
||||
// test for BatchItemRet
|
||||
var batchItemRet = new qiniu.rs.BatchItemRet('xx', 0);
|
||||
// test for BatchStatItemRet
|
||||
var batchStatItemRet = new qiniu.rs.BatchStatItemRet('xx', 'xxx', 0);
|
||||
// test for PutPolicy
|
||||
var putPolicy = new qiniu.rs.PutPolicy();
|
||||
putPolicy.token();
|
||||
putPolicy.getFlags();
|
||||
// test for PutPolicy2
|
||||
var putPolicy2 = new qiniu.rs.PutPolicy2({
|
||||
scope: 'xxx'
|
||||
});
|
||||
putPolicy2.token();
|
||||
putPolicy2.getFlags();
|
||||
// test for GetPolicy
|
||||
var getPolicy = new qiniu.rs.GetPolicy(10);
|
||||
getPolicy.makeRequest('https://up.qbox.me');
|
||||
// test for makeBaseUrl
|
||||
qiniu.rs.makeBaseUrl('up.qbox.me', 'test');
|
||||
}
|
||||
@@ -0,0 +1,175 @@
|
||||
/// <reference path="index.d.ts" />
|
||||
// test for qiniu.conf
|
||||
function testConf() {
|
||||
qiniu.conf.ACCESS_KEY = 'Access_Key';
|
||||
qiniu.conf.SECRET_KEY = 'Secret_Key';
|
||||
}
|
||||
|
||||
// test for qiniu.auth
|
||||
function testAuth() {
|
||||
// test for auth.Mac
|
||||
const mac = new qiniu.auth.Mac(qiniu.conf.ACCESS_KEY, qiniu.conf.SECRET_KEY);
|
||||
}
|
||||
|
||||
// test for qiniu.io
|
||||
function testIo() {
|
||||
// test for PutExtra
|
||||
const putExtra = new qiniu.io.PutExtra();
|
||||
// test for PutRet
|
||||
const putRet = new qiniu.io.PutRet();
|
||||
// test for putReadable
|
||||
qiniu.io.putReadable('xxx', null, null, null, (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for put
|
||||
qiniu.io.put('xxx', null, 'test-data', null, (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for putWithoutKey
|
||||
qiniu.io.putWithoutKey('xxx', 'test-data', null, (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for putFile
|
||||
qiniu.io.putFile('xxx', null, 'tslint.json', null, (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for putFileWithoutKey
|
||||
qiniu.io.putFileWithoutKey('xxx', 'tslint.json', null, (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
// test for qiniu.util
|
||||
function testUtil() {
|
||||
// test for urlsafeBase64Encode
|
||||
qiniu.util.urlsafeBase64Encode(null);
|
||||
// test for base64ToUrlSafe
|
||||
qiniu.util.base64ToUrlSafe('https://example.com');
|
||||
// test for hmacSha1
|
||||
qiniu.util.hmacSha1(null, 'test');
|
||||
// test for generateAccessToken
|
||||
qiniu.util.generateAccessToken('https://example.com');
|
||||
// test for isQiniuCallback
|
||||
qiniu.util.isQiniuCallback('/key', 'test-data', 'test-auth');
|
||||
}
|
||||
|
||||
// test for qiniu.zone
|
||||
function testZone() {
|
||||
qiniu.zone.up_host('test', {ACCESS_KEY: 'xx', SECRET_KEY: 'ss'});
|
||||
}
|
||||
|
||||
// test for qiniu.rsf
|
||||
function testRsf() {
|
||||
qiniu.rsf.listPrefix('test');
|
||||
}
|
||||
|
||||
// test for qiniu.rpc
|
||||
function testRpc() {
|
||||
// test for postMultipart
|
||||
qiniu.rpc.postMultipart('https://up.qbox.me', 'test');
|
||||
// test for postWithForm
|
||||
qiniu.rpc.postWithForm('https://up.qbox.me', 'test');
|
||||
// test for postWithoutForm
|
||||
qiniu.rpc.postWithoutForm('https://up.qbox.me');
|
||||
}
|
||||
|
||||
// test for qiniu.fop
|
||||
function testFop() {
|
||||
// test for ImageView
|
||||
const imageView = new qiniu.fop.ImageView(1, 1, 1, 1);
|
||||
imageView.makeRequest('https://up.qbox.me');
|
||||
// test for ImageInfo
|
||||
const imageInfo = new qiniu.fop.ImageInfo();
|
||||
imageInfo.makeRequest('https://up.qbox.me');
|
||||
// test for Exif
|
||||
const exif = new qiniu.fop.Exif();
|
||||
exif.makeRequest('https://up.qbox.me');
|
||||
// test for fop
|
||||
qiniu.fop.pfop('test', 'test', 'test');
|
||||
}
|
||||
|
||||
// test for qiniu.rs
|
||||
function testRs() {
|
||||
// test for Client
|
||||
const client = new qiniu.rs.Client();
|
||||
// test for Client.stat
|
||||
client.stat('test', 'test', (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for Client.remove
|
||||
client.remove('test', 'test', (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for Client.move
|
||||
client.move('test-src', 'test-src', 'test-dest', 'test-dest', (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for Client.forceMove
|
||||
client.forceMove('test-src', 'test-src', 'test-dest', 'test-dest', true, (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for Client.copy
|
||||
client.copy('test-src', 'test-src', 'test-dest', 'test-dest', (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for Client.forceCopy
|
||||
client.forceCopy('test-src', 'test-src', 'test-dest', 'test-dest', true, (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for Client.fetch
|
||||
client.fetch('https://up.qbox.me', 'test', 'test', (e?: any, result?: any, res?: any) => {
|
||||
|
||||
})
|
||||
// test for Client.batchStat
|
||||
client.batchStat(['data'], (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for Client.batchDelete
|
||||
client.batchDelete(['data'], (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for Client.batchMove
|
||||
client.batchMove(['data'], (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for Client.forceBatchMove
|
||||
client.forceBatchMove(['data'], true, (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for Client.batchCopy
|
||||
client.batchCopy(['data'], (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for Client.forceBatchMove
|
||||
client.forceBatchCopy(['data'], true, (e?: any, result?: any, res?: any) => {
|
||||
|
||||
});
|
||||
// test for Entry
|
||||
const entry = new qiniu.rs.Entry('xx', 1, 1);
|
||||
// test for EntryPath
|
||||
const entryPath = new qiniu.rs.EntryPath('test', 'test');
|
||||
entryPath.encode();
|
||||
entryPath.toStr('x');
|
||||
// test for EntryPathPair
|
||||
const entryPathPair = new qiniu.rs.EntryPathPair('xxx', 'xxx');
|
||||
entryPathPair.toStr('x', false);
|
||||
// test for BatchItemRet
|
||||
const batchItemRet = new qiniu.rs.BatchItemRet('xx', 0);
|
||||
// test for BatchStatItemRet
|
||||
const batchStatItemRet = new qiniu.rs.BatchStatItemRet('xx', 'xxx', 0);
|
||||
// test for PutPolicy
|
||||
const putPolicy = new qiniu.rs.PutPolicy();
|
||||
putPolicy.token();
|
||||
putPolicy.getFlags();
|
||||
// test for PutPolicy2
|
||||
const putPolicy2 = new qiniu.rs.PutPolicy2({
|
||||
scope: 'xxx'
|
||||
});
|
||||
putPolicy2.token();
|
||||
putPolicy2.getFlags();
|
||||
// test for GetPolicy
|
||||
const getPolicy = new qiniu.rs.GetPolicy(10);
|
||||
getPolicy.makeRequest('https://up.qbox.me');
|
||||
// test for makeBaseUrl
|
||||
qiniu.rs.makeBaseUrl('up.qbox.me', 'test');
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"qiniu-tests.ts"
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user