polyv-vod-api-sdk 0.0.0-stage → 0.1.0
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/README.md +139 -2
- package/dist/auth/signature.d.ts +67 -0
- package/dist/auth/signature.d.ts.map +1 -0
- package/dist/client.d.ts +37 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/errors/index.d.ts +39 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/index.cjs +1479 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +6275 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1438 -0
- package/dist/index.js.map +1 -0
- package/dist/services/callback.service.d.ts +24 -0
- package/dist/services/callback.service.d.ts.map +1 -0
- package/dist/services/category.service.d.ts +24 -0
- package/dist/services/category.service.d.ts.map +1 -0
- package/dist/services/index.d.ts +7 -0
- package/dist/services/index.d.ts.map +1 -0
- package/dist/services/playsafe.service.d.ts +19 -0
- package/dist/services/playsafe.service.d.ts.map +1 -0
- package/dist/services/statistics.service.d.ts +23 -0
- package/dist/services/statistics.service.d.ts.map +1 -0
- package/dist/services/upload.service.d.ts +48 -0
- package/dist/services/upload.service.d.ts.map +1 -0
- package/dist/services/video.service.d.ts +54 -0
- package/dist/services/video.service.d.ts.map +1 -0
- package/dist/types/category.d.ts +48 -0
- package/dist/types/category.d.ts.map +1 -0
- package/dist/types/client.d.ts +96 -0
- package/dist/types/client.d.ts.map +1 -0
- package/dist/types/generated/account.d.ts +37 -0
- package/dist/types/generated/account.d.ts.map +1 -0
- package/dist/types/generated/ad.d.ts +183 -0
- package/dist/types/generated/ad.d.ts.map +1 -0
- package/dist/types/generated/callback.d.ts +87 -0
- package/dist/types/generated/callback.d.ts.map +1 -0
- package/dist/types/generated/index.d.ts +19 -0
- package/dist/types/generated/index.d.ts.map +1 -0
- package/dist/types/generated/player.d.ts +127 -0
- package/dist/types/generated/player.d.ts.map +1 -0
- package/dist/types/generated/playsafe.d.ts +421 -0
- package/dist/types/generated/playsafe.d.ts.map +1 -0
- package/dist/types/generated/private.d.ts +99 -0
- package/dist/types/generated/private.d.ts.map +1 -0
- package/dist/types/generated/statistics.d.ts +978 -0
- package/dist/types/generated/statistics.d.ts.map +1 -0
- package/dist/types/generated/sub_account.d.ts +393 -0
- package/dist/types/generated/sub_account.d.ts.map +1 -0
- package/dist/types/generated/vert.d.ts +191 -0
- package/dist/types/generated/vert.d.ts.map +1 -0
- package/dist/types/generated/video_codec.d.ts +212 -0
- package/dist/types/generated/video_codec.d.ts.map +1 -0
- package/dist/types/generated/video_management.d.ts +1913 -0
- package/dist/types/generated/video_management.d.ts.map +1 -0
- package/dist/types/generated/video_upload.d.ts +150 -0
- package/dist/types/generated/video_upload.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/playsafe.d.ts +136 -0
- package/dist/types/playsafe.d.ts.map +1 -0
- package/dist/types/upload.d.ts +156 -0
- package/dist/types/upload.d.ts.map +1 -0
- package/dist/types/video.d.ts +185 -0
- package/dist/types/video.d.ts.map +1 -0
- package/dist/upload/checkpoint.d.ts +44 -0
- package/dist/upload/checkpoint.d.ts.map +1 -0
- package/dist/upload/chunked-uploader.d.ts +72 -0
- package/dist/upload/chunked-uploader.d.ts.map +1 -0
- package/dist/upload/direct-uploader.d.ts +52 -0
- package/dist/upload/direct-uploader.d.ts.map +1 -0
- package/dist/upload/object-storage.d.ts +75 -0
- package/dist/upload/object-storage.d.ts.map +1 -0
- package/dist/utils/file.d.ts +9 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/rate-limiter.d.ts +20 -0
- package/dist/utils/rate-limiter.d.ts.map +1 -0
- package/dist/version.d.ts +3 -0
- package/dist/version.d.ts.map +1 -0
- package/package.json +59 -4
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Video types.
|
|
3
|
+
*
|
|
4
|
+
* @module types/video
|
|
5
|
+
*/
|
|
6
|
+
export declare const PUBLISHED_STATUSES: readonly number[];
|
|
7
|
+
/**
|
|
8
|
+
* Statuses after which a video will not become playable.
|
|
9
|
+
*
|
|
10
|
+
* `40` and `51` are documented. `41` is not in the public docs: it was observed on files that
|
|
11
|
+
* are not valid videos (zero duration, no format, no transcoded files), and it did not change.
|
|
12
|
+
*/
|
|
13
|
+
export declare const FAILED_STATUSES: readonly number[];
|
|
14
|
+
/**
|
|
15
|
+
* Status codes of `basicInfo.status`.
|
|
16
|
+
*
|
|
17
|
+
* `6` (just uploaded), `41` and `61` are not in the public docs; they were observed on the live
|
|
18
|
+
* platform. `61` is a video that was restored from the recycle bin.
|
|
19
|
+
*/
|
|
20
|
+
export declare const VIDEO_STATUS_TEXT: Readonly<Record<number, string>>;
|
|
21
|
+
export declare function describeVideoStatus(status: number): string;
|
|
22
|
+
export declare function isPublished(status: number): boolean;
|
|
23
|
+
export declare function isTerminalFailure(status: number): boolean;
|
|
24
|
+
export type VideoSort = 'creationTimeAsc' | 'creationTimeDesc' | 'playTimesAsc' | 'playTimesDesc';
|
|
25
|
+
export type VideoFilter = 'basicInfo' | 'metaData' | 'transcodeInfo' | 'snapshotInfo';
|
|
26
|
+
export interface SearchVideosParams {
|
|
27
|
+
/** Sections to return. Default is the basic info only. */
|
|
28
|
+
filters?: VideoFilter[] | string;
|
|
29
|
+
cataId?: string | number;
|
|
30
|
+
/** Fuzzy match on title or vid. */
|
|
31
|
+
title?: string;
|
|
32
|
+
/** Fuzzy match on tag. */
|
|
33
|
+
tag?: string;
|
|
34
|
+
uploader?: string;
|
|
35
|
+
/** Status codes; any of `60`/`61` means published. Default is every status. */
|
|
36
|
+
status?: string;
|
|
37
|
+
/** Include sub-categories. Default true. */
|
|
38
|
+
containSubCate?: boolean;
|
|
39
|
+
/** 13-digit timestamps. */
|
|
40
|
+
startTime?: number;
|
|
41
|
+
endTime?: number;
|
|
42
|
+
startModifyTime?: number;
|
|
43
|
+
endModifyTime?: number;
|
|
44
|
+
encrypted?: boolean;
|
|
45
|
+
playAuthEnable?: boolean;
|
|
46
|
+
sort?: VideoSort;
|
|
47
|
+
/** Default 1. */
|
|
48
|
+
page?: number;
|
|
49
|
+
/** Default 10, max 1000. */
|
|
50
|
+
pageSize?: number;
|
|
51
|
+
}
|
|
52
|
+
export interface VideoBasicInfo {
|
|
53
|
+
title: string;
|
|
54
|
+
description: string;
|
|
55
|
+
/** Source duration in seconds. */
|
|
56
|
+
duration: number;
|
|
57
|
+
thumbnailURL: string;
|
|
58
|
+
coverURL: string;
|
|
59
|
+
miniCoverURL?: string;
|
|
60
|
+
largeCoverURL?: string;
|
|
61
|
+
audioUrl?: string;
|
|
62
|
+
/** `yyyy-MM-dd HH:mm:ss` */
|
|
63
|
+
creationTime: string;
|
|
64
|
+
updateTime: string;
|
|
65
|
+
/** Source file size in bytes. */
|
|
66
|
+
size: number;
|
|
67
|
+
status: number;
|
|
68
|
+
/** `1` is the root category ("默认分类"). */
|
|
69
|
+
cateId: number;
|
|
70
|
+
cateName: string;
|
|
71
|
+
tags: string;
|
|
72
|
+
uploader: string;
|
|
73
|
+
playTimes: number;
|
|
74
|
+
md5Checksum?: string;
|
|
75
|
+
courseId?: string;
|
|
76
|
+
}
|
|
77
|
+
export interface VideoMetaData {
|
|
78
|
+
size: number;
|
|
79
|
+
format: string;
|
|
80
|
+
duration: number;
|
|
81
|
+
bitrate: number;
|
|
82
|
+
fps: number;
|
|
83
|
+
height: number;
|
|
84
|
+
width: number;
|
|
85
|
+
codec: string;
|
|
86
|
+
}
|
|
87
|
+
export interface VideoTranscodeInfo {
|
|
88
|
+
playUrl: string;
|
|
89
|
+
/** `SOURCE`, `LD`, `SD`, `HD` */
|
|
90
|
+
definition: string;
|
|
91
|
+
bitrate: number;
|
|
92
|
+
duration: number;
|
|
93
|
+
encrypt: boolean;
|
|
94
|
+
format: string;
|
|
95
|
+
fps: number;
|
|
96
|
+
height: number;
|
|
97
|
+
width: number;
|
|
98
|
+
/** `normal` or `unavailable` */
|
|
99
|
+
status: string;
|
|
100
|
+
fileSize?: number;
|
|
101
|
+
}
|
|
102
|
+
export interface VideoSnapshotInfo {
|
|
103
|
+
imageUrl: string[];
|
|
104
|
+
bigImageUrl?: string[];
|
|
105
|
+
}
|
|
106
|
+
export interface VideoInfoItem {
|
|
107
|
+
vid: string;
|
|
108
|
+
basicInfo: VideoBasicInfo;
|
|
109
|
+
metaData?: VideoMetaData;
|
|
110
|
+
transcodeInfos?: VideoTranscodeInfo[];
|
|
111
|
+
snapshotInfo?: VideoSnapshotInfo;
|
|
112
|
+
}
|
|
113
|
+
export interface SearchVideosResult {
|
|
114
|
+
pageNumber: number;
|
|
115
|
+
totalPages: number;
|
|
116
|
+
pageSize: number;
|
|
117
|
+
contents: VideoInfoItem[];
|
|
118
|
+
totalItems: number;
|
|
119
|
+
}
|
|
120
|
+
export interface UpdateVideoInfoParams {
|
|
121
|
+
vid: string;
|
|
122
|
+
title?: string;
|
|
123
|
+
description?: string;
|
|
124
|
+
tag?: string;
|
|
125
|
+
/** First-publish URL outside the platform. */
|
|
126
|
+
publishUrl?: string;
|
|
127
|
+
}
|
|
128
|
+
export interface MoveVideosParams {
|
|
129
|
+
vids: string | string[];
|
|
130
|
+
cataId: string | number;
|
|
131
|
+
}
|
|
132
|
+
export interface SetForbiddenParams {
|
|
133
|
+
vids: string | string[];
|
|
134
|
+
/** `true` bans, `false` unbans. Only published videos can be banned and only banned ones unbanned. */
|
|
135
|
+
forbidden: boolean;
|
|
136
|
+
}
|
|
137
|
+
export interface DurationAndSizeParams {
|
|
138
|
+
/** Up to 500 vids. Takes precedence over `cataId`. */
|
|
139
|
+
vids?: string | string[];
|
|
140
|
+
/** Comma-separated category ids. */
|
|
141
|
+
cataId?: string;
|
|
142
|
+
}
|
|
143
|
+
/** Duration and size of one video. The sizes are the transcoded FLV files, in bytes. */
|
|
144
|
+
export interface DurationAndSizeVideo {
|
|
145
|
+
vid: string;
|
|
146
|
+
/** `hh:mm:ss` */
|
|
147
|
+
duration: string;
|
|
148
|
+
/** Clearness 1. */
|
|
149
|
+
filesize1: number;
|
|
150
|
+
filesize2?: number;
|
|
151
|
+
filesize3?: number;
|
|
152
|
+
}
|
|
153
|
+
export interface DurationAndSizeItem {
|
|
154
|
+
/** `null` when the query was by vids. */
|
|
155
|
+
cataid: number | null;
|
|
156
|
+
videos: DurationAndSizeVideo[];
|
|
157
|
+
}
|
|
158
|
+
export interface DeleteVideosOptions {
|
|
159
|
+
/** `1` moves to the recycle bin (default), `2` deletes permanently. */
|
|
160
|
+
deleteType?: 1 | 2;
|
|
161
|
+
/** Delete the vids the platform knows and list the others in `skipped`, instead of failing the whole batch. Default true. */
|
|
162
|
+
ignoreInvalidVids?: boolean;
|
|
163
|
+
}
|
|
164
|
+
export interface DeleteVideosResult {
|
|
165
|
+
/** Vids the platform left alone because it does not know them: a wrong id, or one deleted for good already. */
|
|
166
|
+
skipped: string[];
|
|
167
|
+
}
|
|
168
|
+
export interface WaitOptions {
|
|
169
|
+
/** Default 10 minutes; transcoding a small clip takes about 80 seconds. */
|
|
170
|
+
timeoutMs?: number;
|
|
171
|
+
/** Default 5 seconds. */
|
|
172
|
+
intervalMs?: number;
|
|
173
|
+
signal?: AbortSignal;
|
|
174
|
+
}
|
|
175
|
+
export type WaitResult = {
|
|
176
|
+
state: 'published';
|
|
177
|
+
info: VideoInfoItem;
|
|
178
|
+
} | {
|
|
179
|
+
state: 'failed';
|
|
180
|
+
info: VideoInfoItem;
|
|
181
|
+
} | {
|
|
182
|
+
state: 'timeout';
|
|
183
|
+
info: VideoInfoItem | undefined;
|
|
184
|
+
};
|
|
185
|
+
//# sourceMappingURL=video.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"video.d.ts","sourceRoot":"","sources":["../../src/types/video.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAAa,CAAC;A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storage upload id and the parts
|
|
5
|
+
* already stored, so an interrupted upload continues instead of starting over. The file holds no
|
|
6
|
+
* credentials: those are re-issued by the platform on resume.
|
|
7
|
+
*
|
|
8
|
+
* @module upload/checkpoint
|
|
9
|
+
*/
|
|
10
|
+
import { PolyVVodError } from '../errors/index.js';
|
|
11
|
+
import type { ObjectStorageKind, ObjectStoragePart } from './object-storage.js';
|
|
12
|
+
export interface UploadCheckpoint {
|
|
13
|
+
version: 1;
|
|
14
|
+
vid: string;
|
|
15
|
+
title?: string;
|
|
16
|
+
/** Object key the parts are written to. */
|
|
17
|
+
key: string;
|
|
18
|
+
storage: ObjectStorageKind;
|
|
19
|
+
uploadId: string;
|
|
20
|
+
fileSize: number;
|
|
21
|
+
fileModifiedMs: number;
|
|
22
|
+
partSize: number;
|
|
23
|
+
createdAt: number;
|
|
24
|
+
parts: ObjectStoragePart[];
|
|
25
|
+
}
|
|
26
|
+
export declare const defaultCheckpointDir: () => string;
|
|
27
|
+
/** Checkpoint file for a source file: its absolute path hashed, so the name is filesystem-safe. */
|
|
28
|
+
export declare function checkpointPath(checkpointDir: string, filePath: string): string;
|
|
29
|
+
/** Whether the checkpoint still describes this file (same size and modification time). */
|
|
30
|
+
export declare function isCheckpointFor(checkpoint: UploadCheckpoint, file: {
|
|
31
|
+
size: number;
|
|
32
|
+
mtimeMs: number;
|
|
33
|
+
}): boolean;
|
|
34
|
+
export declare function readCheckpoint(path: string): Promise<UploadCheckpoint | null>;
|
|
35
|
+
/**
|
|
36
|
+
* Writes atomically so an interrupted write never leaves a half-written checkpoint.
|
|
37
|
+
*
|
|
38
|
+
* Parallel part uploads each record their part, so the temporary name is unique per call:
|
|
39
|
+
* a shared one would be renamed away by the first writer and break the others.
|
|
40
|
+
*/
|
|
41
|
+
export declare function writeCheckpoint(path: string, checkpoint: UploadCheckpoint): Promise<void>;
|
|
42
|
+
export declare function removeCheckpoint(path: string): Promise<void>;
|
|
43
|
+
export declare function checkpointError(message: string, cause?: unknown): PolyVV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F;AAED,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMlE;AAMD,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,aAAa,CAE/E"}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chunked (resumable) upload.
|
|
3
|
+
*
|
|
4
|
+
* The protocol is not part of the public API docs; it follows the official Java SDK
|
|
5
|
+
* (`net.polyv.vod.v1.upload`) and was verified against the live platform:
|
|
6
|
+
*
|
|
7
|
+
* 1. `POST /v2/uploadvideo/{userid}/init` reserves a vid and returns temporary storage
|
|
8
|
+
* credentials plus the callback policy.
|
|
9
|
+
* 2. The file is uploaded as a multipart upload to Huawei OBS or Aliyun OSS.
|
|
10
|
+
* 3. The complete request carries the callback, through which the storage notifies the
|
|
11
|
+
* platform. The video record appears immediately with status 6.
|
|
12
|
+
*
|
|
13
|
+
* @module upload/chunked-uploader
|
|
14
|
+
*/
|
|
15
|
+
import type { PolyVVodClient } from '../client.js';
|
|
16
|
+
import type { ChunkedUploadInitResponse, StoragePreference, UploadFileOptions, UploadFileResult } from '../types/upload.js';
|
|
17
|
+
import { type ObjectStorageCredentials } from './object-storage.js';
|
|
18
|
+
export declare const CHUNKED_INIT_PATH = "/v2/uploadvideo/{userid}/init";
|
|
19
|
+
export declare const CHUNKED_TOKEN_PATH = "/v2/uploadvideo/{userid}/token";
|
|
20
|
+
/** Marker the platform uses to tell a new chunked upload from a resume. */
|
|
21
|
+
export declare const CHUNKED_UPLOAD_TYPE = "java_sdk_chunk_v1";
|
|
22
|
+
/** Response of the token call: fresh storage credentials, laid out like the init response minus the vid. */
|
|
23
|
+
export interface ChunkedUploadTokenResponse {
|
|
24
|
+
accessId?: string;
|
|
25
|
+
accessKey?: string;
|
|
26
|
+
token?: string;
|
|
27
|
+
host?: string;
|
|
28
|
+
bucketName?: string;
|
|
29
|
+
dir?: string;
|
|
30
|
+
endpoint?: string;
|
|
31
|
+
domain?: string;
|
|
32
|
+
validityTime?: number;
|
|
33
|
+
Expiration?: string;
|
|
34
|
+
hwObsInfo?: ChunkedUploadInitResponse['hwObsInfo'];
|
|
35
|
+
storageType?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface StorageSelection {
|
|
38
|
+
credentials: ObjectStorageCredentials;
|
|
39
|
+
/** Base64 callback policy sent on the complete request. */
|
|
40
|
+
callback: string;
|
|
41
|
+
/** Object-key prefix issued by the platform. */
|
|
42
|
+
dir: string;
|
|
43
|
+
}
|
|
44
|
+
/** What picking the storage reads: the credentials the platform issued for either storage. */
|
|
45
|
+
type StorageSource = ChunkedUploadTokenResponse & Pick<ChunkedUploadInitResponse, 'encodedCallback'>;
|
|
46
|
+
/**
|
|
47
|
+
* Picks the storage for the upload. Following the Java SDK, `auto` uses Huawei OBS whenever the
|
|
48
|
+
* platform issues OBS credentials; otherwise Aliyun OSS.
|
|
49
|
+
*/
|
|
50
|
+
export declare function selectStorage(source: StorageSource, preference?: StoragePreference): StorageSelection;
|
|
51
|
+
export declare function normalizePartSize(partSize?: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* Uploads a local file through the resumable protocol.
|
|
54
|
+
*
|
|
55
|
+
* An interrupted upload leaves a checkpoint in the checkpoint directory; calling this again
|
|
56
|
+
* with the same file continues from the parts the storage already holds.
|
|
57
|
+
*
|
|
58
|
+
* @throws {PolyVVodError} `validation`, `auth`, `api`, `network` or `upload`
|
|
59
|
+
*/
|
|
60
|
+
export declare function uploadFileChunked(client: PolyVVodClient, options: UploadFileOptions): Promise<UploadFileResult>;
|
|
61
|
+
/**
|
|
62
|
+
* Aborts an interrupted upload: discards the stored parts and the checkpoint.
|
|
63
|
+
* Resolves to false when there is nothing to abort.
|
|
64
|
+
*/
|
|
65
|
+
export declare function abortChunkedUpload(client: PolyVVodClient, options: {
|
|
66
|
+
filePath: string;
|
|
67
|
+
checkpointDir?: string;
|
|
68
|
+
storageFetch?: typeof globalThis.fetch;
|
|
69
|
+
signal?: AbortSignal;
|
|
70
|
+
}): Promise<boolean>;
|
|
71
|
+
export {};
|
|
72
|
+
//# sourceMappingURL=chunked-uploader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chunked-uploader.d.ts","sourceRoot":"","sources":["../../src/upload/chunked-uploader.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAKH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAEnD,OAAO,KAAK,EACV,yBAAyB,EACzB,iBAAiB,EACjB,iBAAiB,EACjB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAY5B,OAAO,EAGL,KAAK,wBAAwB,EAE9B,MAAM,qBAAqB,CAAC;AAE7B,eAAO,MAAM,iBAAiB,kCAAkC,CAAC;AACjE,eAAO,MAAM,kBAAkB,mCAAmC,CAAC;AACnE,2EAA2E;AAC3E,eAAO,MAAM,mBAAmB,sBAAsB,CAAC;AAIvD,4GAA4G;AAC5G,MAAM,WAAW,0BAA0B;IACzC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,yBAAyB,CAAC,WAAW,CAAC,CAAC;IACnD,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,gBAAgB;IAC/B,WAAW,EAAE,wBAAwB,CAAC;IACtC,2DAA2D;IAC3D,QAAQ,EAAE,MAAM,CAAC;IACjB,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;CACb;AAED,8FAA8F;AAC9F,KAAK,aAAa,GAAG,0BAA0B,GAAG,IAAI,CAAC,yBAAyB,EAAE,iBAAiB,CAAC,CAAC;AAErG;;;GAGG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,aAAa,EAAE,UAAU,GAAE,iBAA0B,GAAG,gBAAgB,CAsC7G;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAS3D;AAED;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAoJrH;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,cAAc,EACtB,OAAO,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,YAAY,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAAC,MAAM,CAAC,EAAE,WAAW,CAAA;CAAE,GAClH,OAAO,CAAC,OAAO,CAAC,CAgBlB"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Direct upload: one multipart POST authenticated with `writetoken`.
|
|
3
|
+
*
|
|
4
|
+
* Documented at `docs/vod/api/video_upload/upload_video.md`. The file streams from disk, so
|
|
5
|
+
* memory use does not grow with the file. The endpoint caps files at 2 GB; larger files go
|
|
6
|
+
* through the chunked upload.
|
|
7
|
+
*
|
|
8
|
+
* @module upload/direct-uploader
|
|
9
|
+
*/
|
|
10
|
+
import { Readable } from 'node:stream';
|
|
11
|
+
import type { PolyVVodClient } from '../client.js';
|
|
12
|
+
import type { UploadFileResult, UploadProgress } from '../types/upload.js';
|
|
13
|
+
export declare const DIRECT_UPLOAD_PATH = "/uc/services/rest?method=uploadfile";
|
|
14
|
+
/** Error codes the direct upload endpoint answers with. */
|
|
15
|
+
export declare const DIRECT_UPLOAD_ERRORS: Readonly<Record<string, string>>;
|
|
16
|
+
export interface DirectUploadOptions {
|
|
17
|
+
filePath: string;
|
|
18
|
+
/** Default: the file name without its extension. */
|
|
19
|
+
title?: string;
|
|
20
|
+
description?: string;
|
|
21
|
+
tag?: string;
|
|
22
|
+
cataId?: string | number;
|
|
23
|
+
/** Screen-recording optimisation (录屏优化). */
|
|
24
|
+
luping?: boolean;
|
|
25
|
+
/** Passed back in the upload callback. */
|
|
26
|
+
state?: string;
|
|
27
|
+
watermark?: string;
|
|
28
|
+
watermarkLocation?: 1 | 2 | 3 | 4;
|
|
29
|
+
/** Uppercase MD5 of the file. When given, the platform verifies the upload against it. */
|
|
30
|
+
fileMd5?: string;
|
|
31
|
+
/** Charset of the file name; `ISO-8859-1` avoids garbled non-ASCII names. */
|
|
32
|
+
fcharset?: string;
|
|
33
|
+
onProgress?: (progress: UploadProgress) => void;
|
|
34
|
+
signal?: AbortSignal;
|
|
35
|
+
}
|
|
36
|
+
interface MultipartPart {
|
|
37
|
+
name: string;
|
|
38
|
+
value?: string;
|
|
39
|
+
filename?: string;
|
|
40
|
+
contentType?: string;
|
|
41
|
+
stream?: Readable;
|
|
42
|
+
}
|
|
43
|
+
/** Builds the multipart body as a stream so the file is never held in memory as a whole. */
|
|
44
|
+
export declare function multipartStream(parts: MultipartPart[], boundary: string, onBytes: (count: number) => void): Readable;
|
|
45
|
+
/**
|
|
46
|
+
* Uploads a local file of up to 2 GB in a single request.
|
|
47
|
+
*
|
|
48
|
+
* @throws {PolyVVodError} `validation`, `auth` or `upload`
|
|
49
|
+
*/
|
|
50
|
+
export declare function uploadFileDirect(client: PolyVVodClient, options: DirectUploadOptions): Promise<UploadFileResult>;
|
|
51
|
+
export {};
|
|
52
|
+
//# sourceMappingURL=direct-uploader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"direct-uploader.d.ts","sourceRo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,CAAC;CACnB;AAED,4FAA4F;AAC5F,wBAAgB,eAAe,CAAC,KAAK,EAAE,aAAa,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,GAAG,QAAQ,CAsBpH;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,MAAM,EAAE,cAAc,EAAE,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAyEtH"}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Minimal multipart client for the object storages behind the chunked upload (Huawei OBS and
|
|
3
|
+
* Aliyun OSS), hand-signed so the SDK has no runtime dependency.
|
|
4
|
+
*
|
|
5
|
+
* Both storages use the same signature layout (verified against the live platform and the
|
|
6
|
+
* official `esdk-obs-nodejs` / `ali-oss` sources):
|
|
7
|
+
*
|
|
8
|
+
* ```
|
|
9
|
+
* METHOD\n Content-MD5\n Content-Type\n Date\n <sorted x-<vendor>-* headers> /bucket/object<sub-resources>
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* hashed with HMAC-SHA1 and sent as `Authorization: <VENDOR> accessKey:signature`. The temporary
|
|
13
|
+
* session token travels in `x-<vendor>-security-token` and takes part in the signature.
|
|
14
|
+
*
|
|
15
|
+
* @module upload/object-storage
|
|
16
|
+
*/
|
|
17
|
+
export type ObjectStorageKind = 'obs' | 'oss';
|
|
18
|
+
/** Temporary credentials for one multipart upload. Valid for an hour. Never log them. */
|
|
19
|
+
export interface ObjectStorageCredentials {
|
|
20
|
+
kind: ObjectStorageKind;
|
|
21
|
+
accessKey: string;
|
|
22
|
+
secretKey: string;
|
|
23
|
+
sessionToken: string;
|
|
24
|
+
bucket: string;
|
|
25
|
+
/**
|
|
26
|
+
* Origin requests are sent to. OBS requires the virtual-hosted form
|
|
27
|
+
* `https://{bucket}.{endpoint}` and rejects path-style URLs; OSS uses the virtual-hosted host
|
|
28
|
+
* the platform returns.
|
|
29
|
+
*/
|
|
30
|
+
origin: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ObjectStoragePart {
|
|
33
|
+
partNumber: number;
|
|
34
|
+
/** As returned by the storage, double quotes included. */
|
|
35
|
+
etag: string;
|
|
36
|
+
}
|
|
37
|
+
export interface CompleteMultipartResult {
|
|
38
|
+
/** 200: stored and the platform callback succeeded. 203: stored but the callback failed. */
|
|
39
|
+
status: number;
|
|
40
|
+
/** With a callback set, the callback server's response body. */
|
|
41
|
+
body: string;
|
|
42
|
+
}
|
|
43
|
+
export interface ObjectStorageClientOptions {
|
|
44
|
+
fetch?: typeof globalThis.fetch;
|
|
45
|
+
timeout?: number;
|
|
46
|
+
signal?: AbortSignal;
|
|
47
|
+
}
|
|
48
|
+
/** Whether a storage error means the temporary credentials expired and must be refreshed. */
|
|
49
|
+
export declare function isCredentialsExpired(error: unknown): boolean;
|
|
50
|
+
export interface StringToSignInput {
|
|
51
|
+
method: string;
|
|
52
|
+
headers: Record<string, string>;
|
|
53
|
+
vendor: 'obs' | 'oss';
|
|
54
|
+
/** `/bucket/object` */
|
|
55
|
+
resource: string;
|
|
56
|
+
/** Only sub-resources take part. An empty value means the name is sent without `=`. */
|
|
57
|
+
subResources: Record<string, string | undefined>;
|
|
58
|
+
}
|
|
59
|
+
/** Signature base shared by OBS and OSS. Sub-resource values are raw, never URL-encoded. */
|
|
60
|
+
export declare function buildStringToSign(input: StringToSignInput): string;
|
|
61
|
+
export declare class ObjectStorageClient {
|
|
62
|
+
readonly credentials: ObjectStorageCredentials;
|
|
63
|
+
private readonly options;
|
|
64
|
+
constructor(credentials: ObjectStorageCredentials, options?: ObjectStorageClientOptions);
|
|
65
|
+
/** Starts a multipart upload and returns its upload id. */
|
|
66
|
+
initiate(key: string): Promise<string>;
|
|
67
|
+
uploadPart(key: string, uploadId: string, partNumber: number, body: Buffer): Promise<string>;
|
|
68
|
+
/** Parts the storage already holds for this upload. */
|
|
69
|
+
listParts(key: string, uploadId: string): Promise<ObjectStoragePart[]>;
|
|
70
|
+
complete(key: string, uploadId: string, parts: ObjectStoragePart[], callbackBase64: string): Promise<CompleteMultipartResult>;
|
|
71
|
+
abort(key: string, uploadId: string): Promise<void>;
|
|
72
|
+
private request;
|
|
73
|
+
private failure;
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=object-storage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"object-storage.d.ts","sourceRoot":"","sources":["../../src/upload/object-storage.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAMH,MAAM,MAAM,iBAAiB,GAAG,KAAK,GAAG,KAAK,CAAC;AAE9C,yFAAyF;AACzF,MAAM,WAAW,wBAAwB;IACvC,IAAI,EAAE,iBAAiB,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,uBAAuB;IACtC,4FAA4F;IAC5F,MAAM,EAAE,MAAM,CAAC;IACf,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,0BAA0B;IACzC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAID,6FAA6F;AAC7F,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAE5D;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MA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stats, with an unreadable path reported as a validation error. */
|
|
8
|
+
export declare function fileStats(filePath: string): Promise<Stats>;
|
|
9
|
+
//# sourceMappingURL=file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file.d.ts","sourceRoot":"","sources":["../../src/utils/file.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAKrC,0EAA0E;AAC1E,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAOhE"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sliding-window rate limiter.
|
|
3
|
+
*
|
|
4
|
+
* `api.polyv.net` allows 500 requests per 10 seconds per IP; exceeding it blocks the IP for
|
|
5
|
+
* 5 minutes. The client keeps a configurable budget below that limit.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/rate-limiter
|
|
8
|
+
*/
|
|
9
|
+
export declare class RateLimiter {
|
|
10
|
+
readonly maxRequests: number;
|
|
11
|
+
readonly windowMs: number;
|
|
12
|
+
private readonly issuedAt;
|
|
13
|
+
constructor(maxRequests: number, windowMs: number);
|
|
14
|
+
/** Number of requests issued inside the current window. */
|
|
15
|
+
get used(): number;
|
|
16
|
+
/** Resolves once a request may be sent, waiting for the window to free up if needed. */
|
|
17
|
+
acquire(): Promise<void>;
|
|
18
|
+
private prune;
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=rate-limiter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limiter.d.ts","sourceRoot":"","sources":["../../src/utils/rate-limiter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,qBAAa,WAAW;IAIpB,QAAQ,CAAC,WAAW,EAAE,MAAM;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM;IAJ3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAgB;gBAG9B,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM;IAU3B,2DAA2D;IAC3D,IAAI,IAAI,IAAI,MAAM,CAGjB;IAED,wFAAwF;IAClF,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAa9B,OAAO,CAAC,KAAK;CAKd"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,61 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polyv-vod-api-sdk",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "PolyV VOD (video on-demand) API SDK for TypeScript/Node.js",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js",
|
|
12
|
+
"require": "./dist/index.cjs"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"scripts": {
|
|
16
|
+
"prebuild": "tsx scripts/generate-types.ts",
|
|
17
|
+
"build": "tsup && tsc --emitDeclarationOnly --declarationMap",
|
|
18
|
+
"types:generate": "tsx scripts/generate-types.ts",
|
|
19
|
+
"typecheck": "tsc --noEmit -p tsconfig.test.json",
|
|
20
|
+
"test": "vitest run",
|
|
21
|
+
"test:unit": "vitest run",
|
|
22
|
+
"test:coverage": "vitest run --coverage",
|
|
23
|
+
"test:integration": "vitest run --config vitest.config.integration.ts",
|
|
24
|
+
"prepublishOnly": "pnpm test:unit && pnpm build"
|
|
25
|
+
},
|
|
26
|
+
"keywords": [
|
|
27
|
+
"polyv",
|
|
28
|
+
"vod",
|
|
29
|
+
"video",
|
|
30
|
+
"on-demand",
|
|
31
|
+
"api",
|
|
32
|
+
"sdk"
|
|
33
|
+
],
|
|
34
|
+
"author": "PolyV",
|
|
35
|
+
"license": "MIT",
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "git+https://github.com/polyv/polyv-live-cli.git",
|
|
39
|
+
"directory": "packages/vod-sdk"
|
|
40
|
+
},
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"files": [
|
|
45
|
+
"dist",
|
|
46
|
+
"README.md",
|
|
47
|
+
"LICENSE"
|
|
48
|
+
],
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=18.0.0"
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/node": "^20.10.0",
|
|
54
|
+
"@vitest/coverage-v8": "^1.2.0",
|
|
55
|
+
"dotenv": "^17.3.1",
|
|
56
|
+
"tsup": "^8.0.2",
|
|
57
|
+
"tsx": "^4.7.0",
|
|
58
|
+
"typescript": "^5.3.3",
|
|
59
|
+
"vitest": "^1.2.0"
|
|
60
|
+
}
|
|
61
|
+
}
|