Package Exports
- studio-helper
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (studio-helper) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Classes
- StudioHelper
Typedefs
- ResultObj :
Object - ProgressOptions
- FileHeaderSettings :
Object Key / value pairs of wanted header names and their values
- CreateFolderResult :
Object - FolderSettings :
Object - FolderUpdateSettings :
Object
StudioHelper
Kind: global class
- StudioHelper
- new StudioHelper(settings)
- .login(username, password, token, [longSession]) ⇒
Promise - .push(settings) ⇒
Array.<Object> - .createDirectoryFolders(folderData) ⇒
Array.<ResultObj> - .getLocalFolders(path) ⇒
Array.<string> - .getFiles(folderId) ⇒
Promise.<Array.<Object>> - .deleteFiles(files, options) ⇒
Promise.<Object> - .uploadFiles(files, folderId) ⇒
Promise.<Array.<Object>> - .replaceFiles(files, [options]) ⇒
Promise.<Array.<Object>> - .getFileHeaders(fileId) ⇒
ResultObj - .setFileHeaders(fileId, headerSettings, [options]) ⇒
ResultObj - .getUploadInformation(files, folderId) ⇒
Array.<Object> - .getReplaceInformation(files, options)
- .getFolders([parentId]) ⇒
Promise.<Object> - .createFolder(settings) ⇒
ResultObj - .deleteFolder(folderId) ⇒
Promise.<Object> - .deleteChildFolders(folderId) ⇒
Promise.<Object> - .getFolderSettings(folderId) ⇒
ResultObj - .updateFolderSettings(folderId, folderSettings, [options]) ⇒
ResultObj - .batchUpload(files) ⇒
Array.<object>
new StudioHelper(settings)
| Param | Type | Default | Description |
|---|---|---|---|
| settings | Object |
||
| settings.studio | string |
Studio host ('xyz.studio.crasman.fi') | |
| [settings.proxy] | string |
Proxy | |
| [settings.strictSSL] | boolean |
true |
Change to false if you're using self-signed certificate |
| [settings.loginPromptEnabled] | boolean |
true |
Show login prompt if authentication fails |
| [settings.credentialsFile] | string |
".studio-credentials" |
File in which credentials are saved |
| [settings.useCacheDir] | boolean |
false |
Store credentials file in Node modules cache dir |
| [settings.ignoreFile] | string |
".studio-ignore" |
Utilised by push method. Uses gitignore spec |
Example
var StudioHelper = require('studio-helper'),
studio = new StudioHelper({
studio: 'xyz.studio.crasman.fi',
proxy: 'http://xyz.intra:8080/'
});studioHelper.login(username, password, token, [longSession]) ⇒ Promise
Login
Kind: instance method of StudioHelper
| Param | Type | Default |
|---|---|---|
| username | string |
|
| password | string |
|
| token | string |
|
| [longSession] | int |
1 |
studioHelper.push(settings) ⇒ Array.<Object>
Push changes to Studio
Kind: instance method of StudioHelper
Returns: Array.<Object> - Array of objects with file upload information. Array has data property which contains additional information.
| Param | Type | Default | Description |
|---|---|---|---|
| settings | Object |
||
| settings.folders | Array.<Object> |
||
| settings.folders[].folderId | string |
Studio folder id | |
| settings.folders[].localFolder | string |
Local folder path | |
| [settings.folders[].createNewFileVersions] | boolean |
true |
Create new versions of uploaded / updated files. Use false to save disk space if you don't need version history. |
| [settings.folders[].includeSubFolders] | boolean |
false |
Create and upload sub folders |
| [settings.folders[].createdFolderSettings] | Object |
|
Object with paths (RegEx pattern) as keys and FolderUpdateSettings object as value. See example. |
| [settings.folders[].createdFileHeaders] | Object |
|
Object with file paths (RegEx pattern) as keys and FileHeaderSettings objcet as value. See example. |
Example
studio.push({
folders: [{
folderId: '568a7a2aadd4532b0f4f4f5b',
localFolder: 'dist/js'
}, {
folderId: '568a7a27add453aa1a4f4f58',
localFolder: 'dist/css'
}, {
folderId: '568a7a27add453aa1a4f4f58',
localFolder: 'dist/',
includeSubFolders: true,
createNewFileVersions: false,
createdFolderSettings: {
'dist/master': { // Regex match
cacheMaxAge: 64800
},
'dist/dev': { // Regex match
cacheMaxAge: 2
}
},
createdFileHeaders: {
'dist/master/service-worker.js': { // Regex match
'Service-Worker-Allowed': '/'
}
}
}]
}).then(function (res) {
console.log(res.length + 'files uploaded');
})studioHelper.createDirectoryFolders(folderData) ⇒ Array.<ResultObj>
Create folders found in local directory if not already created
Kind: instance method of StudioHelper
Returns: Array.<ResultObj> - ResultObj.result
| Param | Type | Default | Description |
|---|---|---|---|
| folderData | Object |
||
| folderData.folderId | string |
Studio folder id | |
| folderData.localFolder | string |
Local folder path | |
| [folderData.includeSubFolders] | boolean |
false |
Create sub folders |
| [folderData.cache] | boolean |
true |
Cache results |
| [folderData.logCreated] | boolean |
false |
Log successfully created folders |
studioHelper.getLocalFolders(path) ⇒ Array.<string>
Get local directory folders
Kind: instance method of StudioHelper
Returns: Array.<string> - folders
| Param | Type |
|---|---|
| path | string |
studioHelper.getFiles(folderId) ⇒ Promise.<Array.<Object>>
Get files of a folder
Kind: instance method of StudioHelper
| Param | Type | Description |
|---|---|---|
| folderId | string |
Studio folder id |
studioHelper.deleteFiles(files, options) ⇒ Promise.<Object>
Delete files
Kind: instance method of StudioHelper
| Param | Type | Default | Description |
|---|---|---|---|
| files | Array.<string> |
Array of file ids | |
| options | Object |
||
| [options.throttle] | number |
1 |
Number of concurrent delete file requests. Max 5 |
| [options.showProgress] | number |
false |
Number of concurrent delete file requests. Max 5 |
| [options.progressOptions] | ProgressOptions |
Progress bar options |
studioHelper.uploadFiles(files, folderId) ⇒ Promise.<Array.<Object>>
Upload files to a specified folder
Kind: instance method of StudioHelper
| Param | Type | Description |
|---|---|---|
| files | Array.<string> |
file with path |
| folderId | string |
Studio folder id |
studioHelper.replaceFiles(files, [options]) ⇒ Promise.<Array.<Object>>
Replace files
Kind: instance method of StudioHelper
| Param | Type | Default | Description |
|---|---|---|---|
| files | Array.<Object> |
||
| files[].fileId | string |
Studio file id | |
| files[].localFile | string |
Local file path | |
| [options] | Object |
||
| [options.createNewVersion] | boolean |
true |
Create new version of files |
studioHelper.getFileHeaders(fileId) ⇒ ResultObj
Get file headers
Kind: instance method of StudioHelper
| Param | Type |
|---|---|
| fileId | string |
studioHelper.setFileHeaders(fileId, headerSettings, [options]) ⇒ ResultObj
Update file headers
Kind: instance method of StudioHelper
| Param | Type | Default | Description |
|---|---|---|---|
| fileId | string |
||
| headerSettings | FileHeaderSettings |
key / value pairs | |
| [options] | Object |
||
| [options.log] | boolean |
false |
log results |
| [options.fileName] | string |
"''" |
used for logging |
studioHelper.getUploadInformation(files, folderId) ⇒ Array.<Object>
Get required information about files for upload
Kind: instance method of StudioHelper
Returns: Array.<Object> - Array of file information objects
| Param | Type | Description |
|---|---|---|
| files | Array.<string> |
files with paths |
| folderId | string |
Studio folder id |
studioHelper.getReplaceInformation(files, options)
Get required information about files for replacement
Kind: instance method of StudioHelper
| Param | Type | Default | Description |
|---|---|---|---|
| files | Array.<Object> |
||
| files[].fileId | string |
Studio file id | |
| files[].localFile | string |
Local file path | |
| options | Object |
||
| [options.createNewVersion] | boolean |
true |
Create new version of files |
studioHelper.getFolders([parentId]) ⇒ Promise.<Object>
Get folders
Kind: instance method of StudioHelper
| Param | Type | Description |
|---|---|---|
| [parentId] | string |
Parent folder id |
studioHelper.createFolder(settings) ⇒ ResultObj
Create folder
Kind: instance method of StudioHelper
Returns: ResultObj - ResultObj.result
| Param | Type | Default | Description |
|---|---|---|---|
| settings | Object |
||
| settings.name | string |
Name of the new folder | |
| [settings.parentId] | string |
Studio folder in which we want to create the new folder | |
| [settings.addIfExists] | boolean |
true |
Return the already created folder id if false |
| [settings.localFolder] | string |
local folder path | |
| [settings.logCreated] | boolean |
false |
log created folders |
| [settings.folderSettings] | FolderUpdateSettings |
folder settings to apply after creation |
studioHelper.deleteFolder(folderId) ⇒ Promise.<Object>
Delete folder
Kind: instance method of StudioHelper
| Param | Type |
|---|---|
| folderId | string |
studioHelper.deleteChildFolders(folderId) ⇒ Promise.<Object>
Delete child folders of a given folder
Kind: instance method of StudioHelper
| Param | Type |
|---|---|
| folderId | string |
studioHelper.getFolderSettings(folderId) ⇒ ResultObj
Get folder settings
Kind: instance method of StudioHelper
Returns: ResultObj - ResultObj.result
| Param | Type |
|---|---|
| folderId | string |
studioHelper.updateFolderSettings(folderId, folderSettings, [options]) ⇒ ResultObj
Update folder settings
Kind: instance method of StudioHelper
| Param | Type | Default | Description |
|---|---|---|---|
| folderId | string |
||
| folderSettings | FolderUpdateSettings |
settings | |
| [options] | Object |
||
| [options.log] | boolean |
false |
log results |
| [options.folderName] | string |
"''" |
used for logging |
studioHelper.batchUpload(files) ⇒ Array.<object>
Batch upload/replace files
Kind: instance method of StudioHelper
Returns: Array.<object> - result
| Param | Type |
|---|---|
| files | Array.<object> |
ResultObj : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| status | string |
"ok" or "error" |
| code | number |
0 for success |
| result | string | Object | Array | boolean |
Results |
ProgressOptions
Kind: global typedef
| Param | Type |
|---|---|
| title | string |
| total | number |
| options | ProgressOptions |
Properties
| Name | Type |
|---|---|
| complete | string |
| incomplete | string |
| width | number |
| clear | boolean |
| total | number |
FileHeaderSettings : Object
Key / value pairs of wanted header names and their values
CreateFolderResult : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| id | string |
Created folder id |
| name | string |
Local folder name, might be different in Studio |
| localFolder | string |
Local folder path |
FolderSettings : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| fileCacheMaxAge | number |
Cache time in seconds |
| fileCacheProtected | boolean |
Can cache time be changed |
| apiFolder | boolean |
API folders can not be modified in Studio GUI |
| noversioning | boolean |
|
| public | boolean |
Public folder |
FolderUpdateSettings : Object
Kind: global typedef
Properties
| Name | Type | Description |
|---|---|---|
| fileCacheMaxAge | number |
Cache time in seconds |
| fileCacheProtected | number |
Can cache time be changed (0 or 1) |
| apiFolder | number |
API folders can not be modified in Studio GUI (0 or 1) |
| noversioning | number |
(0 or 1) |
| public | number |
Public folder |