1.18.1 • Published 1 month ago

studio-helper v1.18.1

Weekly downloads
160
License
-
Repository
github
Last release
1 month ago

Classes

Typedefs

StudioHelper

Kind: global class

new StudioHelper(settings)

ParamTypeDefaultDescription
settingsObject
settings.studiostringStudio host ('xyz.studio.crasman.fi')
settings.proxystringProxy
settings.strictSSLbooleantrueChange to false if you're using self-signed certificate
settings.loginPromptEnabledbooleantrueShow login prompt if authentication fails
settings.credentialsFilestring".studio-credentials"File in which credentials are saved
settings.useCacheDirbooleanfalseStore credentials file in Node modules cache dir
settings.concurrentUploadsnumber1Max concurrent uploads when using batch methods. Defaul 1, Max 5.
settings.ignoreFilestring".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

ParamTypeDefault
usernamestring
passwordstring
tokenstring
longSessionint1

studioHelper.updateSessionSetting(setting, value)

Update a single setting for this session

See documentation for available settings.

Kind: instance method of StudioHelper
See: Documentation

ParamType
settingstring
valuestring

studioHelper.resetSessionSettings()

Reset all API settings to default values

Kind: instance method of StudioHelper

studioHelper.getAllFolders(limit, offset) ⇒ Promise.<ApiResponse.<Array.<{id: string, name: string, parentId: (null|string), createdAt: number, modifiedAt: number}>>>

Get all folders in Studio

Kind: instance method of StudioHelper

ParamTypeDefaultDescription
limitnumber1000Max number of folders to return. Max 1000, default 1000.
offsetnumber0Offset

studioHelper.getMetadataFields() ⇒ Promise.<ApiResponse.<Array.<{id: string, fields: {id: string, type: string, names: Object}, languages: Array.<string>}>>>

Get all metadata fields defined in Stage for this Studio

Kind: instance method of StudioHelper
Example
return value

// {
//   "status": "ok",
//   "result": [
//     {
//       "id": "my_table",
//       "fields": [
//         {
//           "id": "my_field",
//           "type": "st",
//           "names": {
//             "en": "My field"
//           }
//         }
//       ],
//       "languages": [
//         "en"
//       ]
//     }
//   ],
//   "code": 0
// }

studioHelper.getConversions() ⇒ Promise.<ApiResponse.<Array.<{id: string, name: string}>>>

Kind: instance method of StudioHelper
Example
return value

// {
//   "status": "ok",
//   "result": [
//     {
//       "id": "my_conversion",
//       "name": "My conversion",
//     }
//   ],
//   "code": 0
// }

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.

ParamTypeDefaultDescription
settingsObject
settings.foldersArray.<Object>
settings.folders[].folderIdstringStudio folder id
settings.folders[].localFolderstringLocal folder path
[settings.folders[].createNewFileVersions]booleantrueCreate new versions of uploaded / updated files. Use false to save disk space if you don't need version history.
[settings.folders[].includeSubFolders]booleanfalseCreate and upload sub folders
[settings.folders[].createdFolderSettings]ObjectObject with paths (RegEx pattern) as keys and FolderUpdateSettings object as value. See example.
[settings.folders[].createdFileHeaders]ObjectObject 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

ParamTypeDefaultDescription
folderDataObject
folderData.folderIdstringStudio folder id
folderData.localFolderstringLocal folder path
folderData.includeSubFoldersbooleanfalseCreate sub folders
folderData.cachebooleantrueCache results
folderData.logCreatedbooleanfalseLog successfully created folders

studioHelper.getLocalFolders(path) ⇒ Array.<string>

Get local directory folders

Kind: instance method of StudioHelper
Returns: Array.<string> - folders

ParamType
pathstring

studioHelper.getFiles(folderId) ⇒ Promise.<Array.<Object>>

Get files of a folder

Kind: instance method of StudioHelper

ParamTypeDescription
folderIdstringStudio folder id

studioHelper.deleteFiles(files, options) ⇒ Promise.<Object>

Delete files

Kind: instance method of StudioHelper

ParamTypeDefaultDescription
filesArray.<string>Array of file ids
optionsObject
options.throttlenumber1Number of concurrent delete file requests. Max 5
options.showProgressnumberfalseNumber of concurrent delete file requests. Max 5
options.progressOptionsProgressOptionsProgress bar options

studioHelper.uploadFiles(files, folderId) ⇒ Promise.<Array.<Object>>

Upload files to a specified folder

Kind: instance method of StudioHelper

ParamTypeDescription
filesArray.<string>file with path
folderIdstringStudio folder id

studioHelper.replaceFiles(files, options) ⇒ Promise.<Array.<Object>>

Replace files

Kind: instance method of StudioHelper

ParamTypeDefaultDescription
filesArray.<Object>
files[].fileIdstringStudio file id
files[].localFilestringLocal file path
optionsObject
options.createNewVersionbooleantrueCreate new version of files

studioHelper.getFileHeaders(fileId) ⇒ ResultObj

Get file headers

Kind: instance method of StudioHelper

ParamType
fileIdstring

studioHelper.setFileHeaders(fileId, headerSettings, options) ⇒ ResultObj

Update file headers

Kind: instance method of StudioHelper

ParamTypeDefaultDescription
fileIdstring
headerSettingsFileHeaderSettingskey / value pairs
optionsObject
options.logbooleanfalselog results
options.fileNamestring"''"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

ParamTypeDescription
filesArray.<string>files with paths
folderIdstringStudio folder id

studioHelper.getReplaceInformation(files, options)

Get required information about files for replacement

Kind: instance method of StudioHelper

ParamTypeDefaultDescription
filesArray.<Object>
files[].fileIdstringStudio file id
files[].localFilestringLocal file path
optionsObject
options.createNewVersionbooleantrueCreate new version of files

studioHelper.getFolders(parentId) ⇒ Promise.<Object>

Get folders

Kind: instance method of StudioHelper

ParamTypeDescription
parentIdstringParent folder id

studioHelper.createFolder(settings) ⇒ ResultObj

Create folder

Kind: instance method of StudioHelper
Returns: ResultObj - ResultObj.result

ParamTypeDefaultDescription
settingsObject
settings.namestringName of the new folder
settings.parentIdstringStudio folder in which we want to create the new folder
settings.addIfExistsbooleantrueReturn the already created folder id if false
settings.localFolderstringlocal folder path
settings.logCreatedbooleanfalselog created folders
settings.folderSettingsFolderUpdateSettingsfolder settings to apply after creation

studioHelper.deleteFolder(folderId) ⇒ Promise.<Object>

Delete folder

Kind: instance method of StudioHelper

ParamType
folderIdstring

studioHelper.deleteChildFolders(folderId) ⇒ Promise.<Object>

Delete child folders of a given folder

Kind: instance method of StudioHelper

ParamType
folderIdstring

studioHelper.getFolderSettings(folderId) ⇒ ResultObj

Get folder settings

Kind: instance method of StudioHelper
Returns: ResultObj - ResultObj.result

ParamType
folderIdstring

studioHelper.updateFolderSettings(folderId, folderSettings, options) ⇒ ResultObj

Update folder settings

Kind: instance method of StudioHelper

ParamTypeDefaultDescription
folderIdstring
folderSettingsFolderUpdateSettingssettings
optionsObject
options.logbooleanfalselog results
options.folderNamestring"''"used for logging

studioHelper.batchUpload(files) ⇒ Array.<object>

Batch upload/replace files

Kind: instance method of StudioHelper
Returns: Array.<object> - result

ParamType
filesArray.<object>

ApiResponse : Object

Kind: global typedef
Properties

NameTypeDescription
statusstring"ok" or "error"
codenumber0 for success
resultTResults

ResultObj : Object

Kind: global typedef
Properties

NameTypeDescription
statusstring"ok" or "error"
codenumber0 for success
resultstring | Object | Array | booleanResults

ProgressOptions

Kind: global typedef

ParamType
titlestring
totalnumber
optionsProgressOptions

Properties

NameType
completestring
incompletestring
widthnumber
clearboolean
totalnumber

FileHeaderSettings : Object

Key / value pairs of wanted header names and their values

Kind: global typedef

CreateFolderResult : Object

Kind: global typedef
Properties

NameTypeDescription
idstringCreated folder id
namestringLocal folder name, might be different in Studio
localFolderstringLocal folder path

FolderSettings : Object

Kind: global typedef
Properties

NameTypeDescription
fileCacheMaxAgenumberCache time in seconds
fileCacheProtectedbooleanCan cache time be changed
apiFolderbooleanAPI folders can not be modified in Studio GUI
noversioningboolean
publicbooleanPublic folder

FolderUpdateSettings : Object

Kind: global typedef
Properties

NameTypeDescription
fileCacheMaxAgenumberCache time in seconds
fileCacheProtectednumberCan cache time be changed (0 or 1)
apiFoldernumberAPI folders can not be modified in Studio GUI (0 or 1)
noversioningnumber(0 or 1)
publicnumberPublic folder
1.18.1

1 month ago

1.18.0

7 months ago

1.16.2

11 months ago

1.17.0

4 years ago

1.16.1

4 years ago

1.14.1

4 years ago

1.14.2

4 years ago

1.13.1

4 years ago

1.12.0

4 years ago

1.11.0

5 years ago

1.10.0

6 years ago

1.9.0

6 years ago

1.8.1

7 years ago

1.8.0

7 years ago

1.7.2

7 years ago

1.7.1

7 years ago

1.7.0

7 years ago

1.6.5

7 years ago

1.6.4

7 years ago

1.6.3

7 years ago

1.6.2

7 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.6

7 years ago

1.5.5

7 years ago

1.5.4

7 years ago

1.5.3

7 years ago

1.5.2

7 years ago

1.5.1

8 years ago

1.5.0

8 years ago

1.4.4

8 years ago

1.4.3

8 years ago

1.4.2

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.0

8 years ago

1.2.1

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago