-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
147 lines (136 loc) · 5.06 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
declare module scjs {
class ConManager {
/**
* A simple interface to Scala Content Manager web-services.
*
* This module is loosely modelled after the scws2 Python module, supporting the 2.x REST API.
*
* Example usage (set DEBUG=scjs for debug output):
*
* const { ConManager } = require('scjs');
*
* const baseurl = "http://localhost/ContentManager";
* const username = "user";
* const password = "pass";
* const cm = new ConManager(baseurl);
*
* (async () => {
* const resp = await cm.login(username, password);
*
* try {
* const players = await cm.get('players', { 'limit': 0, 'offset': 0, 'fields': 'id,name,enabled,active,type' });
* console.log(players.list);
*
* const media = await cm.get('media', { 'limit': 10, 'filters': '{"type":{"values":["IMAGE"]}}' });
*
* let items = [];
* for (const item of media.list) {
* items.push(cm.download(item.downloadPath, item.name));
* }
* await Promise.all(items);
*
* const item = await cm.upload('LocalFolder/MyPicture.jpg', 'RemoteFolder/MyPicture.jpg');
* console.log(item);
* } finally {
* await cm.post('auth/logout');
* }
* })().catch((e) => {
* console.log(e);
* });
*
* @param {string} baseurl - URL to Content Manager (http://server/ContentManager)
* @param {string} token_name - (optional) Alternative token name, mainly for older (<10.2) Content Manager releases where token had a different name (token)
* @return {function}
* @api public
*/
constructor(baseurl: string, token_name?: string);
/**
* Upload a Stream to Content Manager.
*
* @param {stream.Readable} rstream - Readable Stream
* @param {string} cmpath - Relative path to file on Content Manager
* @param {string} upload_type - (optional) Type of file upload (media_item|maint_item|auto) (defaults to auto)
* @return {Promise}
* @api public
*/
uploadStream(rstream: NodeJS.ReadableStream, cmpath: string, upload_type?: string): Promise<any>;
/**
* Upload file to Content Manager.
*
* @param {string} file - Full path to local file
* @param {string} cmpath - (optional) Relative path to file on Content Manager
* @param {string} upload_type - (optional) Type of file upload (media_item|maint_item|auto) (defaults to auto)
* @return {Promise}
* @api public
*/
upload(file: string, cmpath?: string, upload_type?: string): Promise<any>;
/**
* Download file from Content Manager as a Stream.
*
* @param {string} cmpath - Relative path to file on Content Manager
* @return {stream.Readable}
* @api public
*/
downloadStream(cmpath: string): NodeJS.ReadableStream;
/**
* Download file from Content Manager.
*
* @param {string} cmpath - Relative path to file on Content Manager
* @param {string} file - Local filename to store downloaded content in
* @return {Promise}
* @api public
*/
download(cmpath: string, file: string): Promise<any>;
/**
* Log in to Content Manager (will automatically log out previously logged in user).
*
* @param {string} username
* @param {string} password
* @return {Promise}
* @api public
*/
login(username: string, password: string): Promise<any>;
/**
* API GET request.
*
* @param {string} endpoint - Endpoint path
* @param {Object} data - (optional) Parameters
* @return {Promise}
* @api public
*/
get(endpoint: string, data?: any): Promise<any>;
/**
* API POST request.
*
* @param {string} endpoint - Endpoint path
* @param {Object} data - (optional) Parameters
* @return {Promise}
* @api public
*/
post(endpoint: string, data?: any): Promise<any>;
/**
* API PUT request.
*
* @param {string} endpoint - Endpoint path
* @param {Object} data - (optional) Parameters
* @return {Promise}
* @api public
*/
put(endpoint: string, data?: any): Promise<any>;
/**
* API DELETE request.
*
* @param {string} endpoint - Endpoint path
* @param {Object} data - (optional) Parameters
* @return {Promise}
* @api public
*/
delete(endpoint: string, data?: any): Promise<any>;
/**
* Cached login response object.
* @public
*/
login_response: any;
}
}
export = scjs;