new IMWS()
Members
-
config
-
Contains the configuration data for this instance.
The members of this object are automatically filled during authenticate.Properties:
Name Type Description imwsUrlString URL and port of IMatch WebServices. Set this before calling any endpoint
auth_tokenString The session auth_token
userObject User information retrieved during the authenticate call.
-
idlist :string
-
This enumeration defines the names of pre-defined idlists you can use in your code. These idlists are dynamic and automatically kept up-to-date by IMWS. You can use these names with the
idlistparameter in all endpoints which accept an idlist, e.g.,/files.Type:
- string
Properties:
Name Type Default Description allFilesstring @IMWS.allfiles This idlist contains all files in the database.
Example
// Retrieve the id and file name of the first page of 500 files in the database: IMWS.get('v1/files' { idlist: IMWS.allFiles, pagesize: 500, page: 0, fields: 'id,filename' }).then ... -
COLLECTIONS :Number
-
This enumeration lists the ids of all IMatch collections with static ids. To determine the ids of dynamically created collections (e.g., labels) use the /collections endpoint.
Type:
- Number
Properties:
Name Type Default Description bookmarksNumber 2 protectedFilesNumber 4 pendingWriteBackNumber 5 flagRootNumber 10 flagOnNumber 11 flagOffNumber 12 flagNoneNumber 13 dotRootNumber 30 dotRedNumber 31 dotGreenNumber 32 dotBlueNumber 33 dotNoneNumber 34 pinRootNumber 50 pinRedNumber 51 pinGreenNumber 52 pinBlueNumber 53 pinNoneNumber 54 addedRootNumber 70 addedTodayNumber 71 addedYesterdayNumber 72 addedThisWeekNumber 73 addedLastWeekNumber 74 addedThisMonthNumber 75 addedLastMonthNumber 76 addedThreeMonthNumber 77 updatedRootNumber 90 updatedTodayNumber 91 updatedYesterdayNumber 92 updatedThisWeekNumber 93 updatedLastWeekNumber 94 updatedThisMonthNumber 95 updatedLastMonthNumber 96 updatedThreeMonthNumber 97 viewedRootNumber 110 viewedTodayNumber 111 viewedYesterdayNumber 112 viewedThisWeekNumber 113 viewedLastWeekNumber 114 viewedThisMonthNumber 115 viewedLastMonthNumber 116 viewedThreeMonthNumber 117 ratingRootNumber 10000 rating1Number 10001 rating2Number 10002 rating3Number 10003 rating4Number 10004 rating5Number 10005 ratingNoneNumber 10006 ratingRejectNumber 10007 labelRootNumber 11000 labelNoneNumber 11001 labelItemNumber 11002 relationRootNumber 100000 relationMasterNumber 100001 relationVersionNumber 100002 relationItemNumber 100010 annoRootNumber 200000 -
ERROR_CODES :number
-
Enum for IMWS error messages. These error codes are returned in the JSON reponse as part of HTTP status codes <> 200 OK.
Note:Not all error responses contain additional JSON data. Always check for the existence of a JSON body via
error.responseJSON(if you use jQuery) or similar libraries.Type:
- number
Properties:
Name Type Default Description PTWS_ERR_CODE_MAINTENANCEMODEnumber 1000 Maintenance Mode active.
In maintenance mode only Admin users can access IMWS (login disabled) and several endpoints are disabled.PTWS_ERR_CODE_NOT_MAINTENANCEMODEnumber 1001 Maintenance Mode not active.
This endpoint can only be used in maintenance mode.PTWS_ERR_CODE_MAINTENANCEMODE_NOLOGINnumber 1002 Cannot log-in in maintenance mode.
PTWS_ERR_CODE_COMnumber 1003 Windows COM interface or method failed.
PTWS_ERR_CODE_CANCELnumber 1005 The endpoint was prematurely aborted by user or app request. This is mostly used with long-running file System operations and the
/cancel/*endpoint family.PTWS_ERR_CODE_UNSUPPORTEDnumber 1010 Unsupported endpoint / method.
PTWS_ERR_CODE_MISSING_PRIVILEGEnumber 1011 Insufficient privileges. The current user cannot use this function, e.g., deleting a file without the 'can delete files' permission.
Note: An app should check the privileges of the user before attempting to call an endpoint.
The/userinfoendpoint returns the privieleges for the current user.PTWS_ERR_CODE_INTERNAL_ERRORnumber 1100 Snap :-/ Internal error. Check the IMWS log file for additional information.
PTWS_ERR_CODE_UNKNOWN_METHODnumber 1101 Unknown or unsupported method.
PTWS_ERR_CODE_PARAM_INVALIDnumber 1102 Invalid parameter.
PTWS_ERR_CODE_PARAM_RANGEnumber 1103 Parameter out of range.
PTWS_ERR_CODE_PARAM_INVALID_REGEXPnumber 1104 Invalid regular expression.
PTWS_ERR_CODE_PROTECTED_FILEnumber 1105 This file is protected.
PTWS_ERR_CODE_ACL_RESTRICTIONnumber 1106 This file is not accessible because of ACL restrictions.
PTWS_ERR_CODE_NO_FILE_SPECIFIEDnumber 1107 No file specified. Usually you need to specify an id, idlist or path parameter to match one or more filex.
PTWS_ERR_CODE_PARAM_SETTING_NOTFOUNDnumber 1180 'data' endpoint. Setting not found.
PTWS_ERR_CODE_PARAM_SETTING_UPDATEFAILEDnumber 1181 'data' endpoint. Update of setting failed. Check the IMWS log file for more information.
PTWS_ERR_CODE_PARAM_SETTING_DELETEFAILEDnumber 1182 'data' endpoint. Deletion of setting failed. Check the IMWS log file for more information.
PTWS_ERR_CODE_SESSIONnumber 1200 Too many sessions. Session limit exceeded. Depends on the edition. Install additional CALS or reduce the number of concurrent users.
PTWS_ERR_CODE_IM_FILE_READnumber 1401 Error reading file. File does not exsit or is inaccessible.
PTWS_ERR_CODE_IM_FILE_WRITEnumber 1402 Error writing file. File does not exsit or is inaccessible.
PTWS_ERR_CODE_IM_FILE_EXISTSnumber 1403 A file already exists.
PTWS_ERR_CODE_IM_FOLDER_NOTFOUNDnumber 1410 Folder not found
PTWS_ERR_CODE_IM_FOLDER_EXISTSnumber 1411 Folder already exists
PTWS_ERR_CODE_IM_FILESYS_OP_FAILEDnumber 1450 Unspecified error during a file operation.
PTWS_ERR_CODE_DB_OP_FAILEDnumber 1501 PTWS_ERR_CODE_DB_TRANSACTIONnumber 1502 Database operation failed. Could not aquire a transaction within time-limit. Try again later.
PTWS_ERR_CODE_DB_COMMITnumber 1503 Database operation failed. Could not commit a transaction. Changes to the database rolled back.
PTWS_ERR_CODE_DB_READONLYnumber 1504 Database is read-only. The attempted operation cannot be performed on read-only databases.
PTWS_ERR_CODE_LOCK_FAILEDnumber 1600 One or more objects are currently locked by another session.
PTWS_ERR_CODE_LOCK_RELEASE_FAILEDnumber 1601 One or more locks could not be released.
PTWS_ERR_CODE_SQLITE_FAILEDnumber 1700 A SQLite operation failed
PTWS_ERR_CODE_UNAUTHORIZEDnumber 2000 Unauthorized access or session expired. This request needs to be authenticated with a valid auth_token.
PTWS_ERR_CODE_INVALIDUSERnumber 2010 Unknown id or invalid password.
Example
IMWS.get('v1/method').then(function(response) { ... },function(error) { if (error.responseJSON && (error.responseJSON.error.code == IMWS.ERROR_CODES.PTWS_ERR_CODE_NO_FILE_SPECIFIED)) { } }); -
EVENT_CODES
-
This enum describes the major (ma) and minor (mi) codes used when IMWS sends messages over the websocket.
IMWS will send other events as well, but these are for internal purposes and should be ignored by apps.Properties:
Name Type Default Description evAttributeDB5700 Attributes Database Events
All evSDB* event codes below are used as minor (mi) event codes.evSDBDomainAdded100 Attribute Set added
evSDBDomainUpdated110 Attribute Set updated, Param1 : id or 0
evSDBDomainDeleted120 Attribute Set removed, Param1 : Oid
evSDBDomainRenamed130 Attribute Set renamed, d1 : id, s1: OldName, s2: new name
evSDBAttributeAdded200 Attribute added, d1 : id
evSDBAttributeUpdated210 Attribute updated, d1 : id
evSDBAttributeDeleted220 Attribute removed, d1 : id
evSDBDataAdded300 Data added, d1 : id, d2 : Attribute id
evSDBDataUpdated310 Data updated, d1 : id, d2 : Attribute id
evSDBDataDeleted320 Data removed, d1 : Oid, d2 : Attribute id
evUpdateQueue500 Update Queue Events
All evUQ* event codes below are used as minor (mi) event codesevUQBusy1 Sent at intervals while the queue is processing.
evUQUpdated2 Entries were added or removed. d1: Number of entries in the queue.
evUQEmpty3 Queue is empty. Sent after the queue was processing something and is now empty again.
evUQImportComplete4 Update and Metadata read completed. This is sent after the queue has finished processing folder/file imports. There may be other pending entries (write back, relation updates).
evUQNoWICCodec5 No WIC codec installed for the given format (String 1 = Ext)
evUQDuplicateFilesFound6 Duplicate files were found during a scan operation (only when the user has enabled duplicate checks)
evIMWSBroadcast9000 IMWS Broadcast Event
This event is sent when an app uses the/messages/broadcastendpoint to send a broadcast message to all other apps.
s1contains the message sent by the app. The format is undefined and completely under the control of the sending app.evIMWSImageProcessor9005 IMWS Image Processor Event
This event is sent when one of the /imageprocess endpoints is used. It provides info about the progress.evIMWSIPProgress1 Files are processed.
Fields:
appid: The id of the initiating app.
percentage: total percentage.
id: File idevIMWSIPPackingProgress2 Files are packed into an archive.
Fields:
appid: The id of the initiating app.
percentage: total percentage.evEntityManager9500 Entity Manager Events. This messages are sent when the IMatch entity graph is manipulated.
All evEM* event codes below are used as the minor (mi) event code.evEMExportBegin50 Export begins
evEMExportComplete55 Export completed. d1: 1=success, 0=failure
evEMImportBegin60 Import begins
evEMImportComplete65 Import completed. d1: 1=success, 0=failure
evEMEntityAdded100 Entity added. d1: id, s1: entity name, s2: tag
evEMEntityUpdated101 Entity updated. d1: id, s1: entity name, s2: tag. Either id or tag is specified.
evEMEntityTagChanged102 Entity tag changed. d1: id, s1: entity name, s2: tag|newtag
evEMEntityDeleted103 Entity deleted. d1: id, s1: entity name, s2: tag
evEMEntityDeletedAll104 All entities in a schema deleted. s1: entity name
evEMEntitySchemaAdded200 Entity schema added. s1: entity name
evEMEntitySchemaUpdated201 Entity schema updated. s1: entity name
evEMEntitySchemaDeleted202 Entity schema deleted. s1: entity name. This also deletes all entity properties and entities and edges for this schema.
evEMEntityPropSchemaAdded300 Entity property schema added. s1: entity name, s2: property name.
evEMEntityPropSchemaUpdated301 Entity property schema updated. s1: entity name, s2: property name.
evEMEntityPropSchemaDeleted302 Entity property schema deleted. s1: entity name, s2: property name.
evEMEdgeSchemaAdded400 Edge schema added. s1: name.
evEMEdgeSchemaUpdated401 Edge schema updated. s1: name.
evEMEdgeSchemaDeleted402 Edge schema deleted. s1: name.
evEMEdgePropSchemaAdded500 Edge property schema added. s1: edge schema name, s2: property name.
evEMEdgePropSchemaUpdated501 Edge property schema updated. s1: edge schema name, s2: property name.
evEMEdgePropSchemaDeleted502 Edge property schema deleted. s1: edge schema name, s2: property name.
evEMEdgeAdded600 Edge added. d1: id.
evEMEdgeDeleted601 Edge deleted. d1: id.
evEMEdgePropsUpdated602 Edge properties updated. d1: id, s1: edge schema name.
evEMEdgePropsDeleted603 Edge properties deleted. d1: id, s1: edge schema name.
evEventManager9600 Event Manager Events. This messages are sent when event entities are manipulated.
All evEVM* event codes below are used as the minor (mi) event code.evEVMEventUpdated100 evPeopleManager9700 People Manager Events. This messages are sent when people entities are manipulated.
All evPMM* event codes below are used as the minor (mi) event code.evPMCoverFileChanged100 The cover file of a person was changed. d1: person id.
evPMPersonLinkedToFace110 A person was linked to a face. d1: person id, d2: face id.
evPMPersonUnlinkedFromFace111 A person was unlinked from a face. d1: person id, d2: face id.
evPMPersonLinkedToFile115 A person was linked to a face in a file. d1: person id, d2: file id
evPMPersonUnLinkedFromFile116 A person was unlinked from a face in a file. d1: person id, d2: file id
evPMReject120 A reject was set or reset. d1: person id, d2: face id. If d2 is 0, the reject was reset.
evPMSetFileData125 Face data was set for a file. This can mean many things. It is
usually sent during undo operations, file background processing
or similar taks.evPMPersonSortByChanged130 The "sort by" property of a person was changed. d1: person id.
evPMReclusterBegin150 Reclustering faces for a person in a background thread: begin. d1: Person id, d2: 1 if a file scope is used.
evPMReclusterEnd151 Reclustering faces for a person in a background thread: completed. d1: Person id, d2: 1 if a file scope is used.
evPMReclusterComplete155 All background recluster operations complete.
evPMAutoClusterP1Begin160 Auto clustering phase 1. Loading faces from database
evPMAutoClusterP1End161 Completed. d1: Number of faces to process
evPMAutoClusterP2Begin165 Auto clustering phase 2. Creating graph. SLOWEST part. Massive processoor utilization for extended periods.
evPMAutoClusterP2Progress166 Sent frequently while this phase runs
evPMAutoClusterP2End167 Completed. d1: Number of edges
evPMAutoClusterP3Begin170 Auto clustering phase 3. Analyzing graph and clustering faces.
evPMAutoClusterP3End171 Completed. d1: Number of persons to create
evPMAutoClusterP4Begin175 Auto clustering phase 4. Creating persons and assigning faces.
evPMAutoClusterP4End176 Completed. d1: 0 = success, 1 = aborted.
evPMFaceAdded500 A face was added. d1: face id
evPMFaceDeleted510 A face was deleted. d1: face id. This message is not sent when an entire file (which may contain any number of faces) is deleted.
evPMFaceIgnored520 A face was set to ignore. d1: face id.
evObjectUpdate10000 Database Objects Updated Events.
All evOU* event codes below are used as the minor (mi) event code.evOUFolderAdd100 A folder was added d1 : id
evOUFolderUpdate101 A folder was updated d1 : id, d2 : kind of update
evOUFolderRename102 A folder was renamed (only the name was changed). d1: id, s1: name
evOUFolderMove103 A folder was moved or relocated. d1: id, s1: name
evOUFolderRemove105 A folder was deleted. d1 : id
evOUFolderAddOrUpdate106 A folder was added or updated (e.g. during a Scan/Rescan). d1: id, d2: 0: existing folder, 1: new folder
evOULabelDefs110 XMP Label definitions changed
evOUFileAdd200 A file was added. d1: id, d2: folder id
evOUFileUpdate201 A file was updated. d1 : id
evOUFileRename202 A file was renamed. d1: id. s1: old name. s2: new name
evOUFileMove203 A file was moved. d1 : id, d2: new folder id.
evOUFileRemove205 A file was deleted. d1: id
evOUFileAttributeChange230 A file attribute has changed, e.g. read-only flag. d1 : id
evOUFilePendingChange235 The pending state of the file has changed. d1 : id, d2: 0:normal, 1: Metadata.
evOUTransformChange240 The transformations for a file have changed. d1 : id.
evOUThumbUpdate301 A thumbnail was updated. d1: id
evOUThumbDelete302 A thumbnail was deleted. d1: id
evOUThumbSetUpdate310 A thumbnail set was updated. d1: id
evOUThumbSetDelete311 A thumbnail set (e.g., videos) was deleted. d1: id, d2: type.
evOUCollectionUpdate400 A collection was updated. d1 : Collection id.
evOUCollectionLabelsChanged401 A label was added or removed.
evOUTimelineAddNode420 A timeline node was added. d1 : node id.
evOUTimelineUpdateNode421 A timeline node was updated. d1 : node id.
evOUTimelineRemoveNode422 A timeline node was removed. d1: node id.
evOUTimelineRebuildBegin423 Timeline rebuild begins.
evOUTimelineRebuildFinish424 Timeline rebuild completed. d1 : 0: Error, 1: OK.
evOUCategoryAdd500 A category was added. d1 : id
evOUCategoryUpdate501 A category was updated. d1 : id
evOUCategoryError502 The InError() state of a category has changed. d1 : id of category, d2 : 1 or 0
evOUCategoryRemove503 Sent after a category has been removed. d1: id
evOUCategoryMove504 Sent after a category has been moved. d1 : id of category, d2 : id of new parent (may be 0 if the category was moved under @All.
evDataGrouperExecuteBegin580 The data grouper starts to re-calculate a data-driven category. d1: category id
evDataGrouperExecuteFinish581 The data grouper finished to re-calculate a data-driven category. d1: category id, d2: runtime in ms.
evDataGrouperUpdateBegin585 A data-driven category is updated with new results. d1: category id
evDataGrouperUpdateFinish586 A data-driven category has finished updating with new results. d1: category id, dw: runtime in ms.
evOUMBFileValueUpdate600 Metadata* Values for a file were added or updated. d1 : id of file.
evOUMBFileValueDelete601 Values for a file were removed. d1 : id of file.
evOUMBLabelUpdate602 The label of a file was changed. Extra event because so frequent. d1: id of file.
evOUMBRatingUpdate603 The rating of a file was changed. Extra event because so frequent. d1: id of file.
evOUMBFileWriteBack650 The write-back for a file was completed. d1: file id.
evOUMBKeywordCategoryOpAdd660 Files were added to @Keywords. d1 : id of category which caused the change.
evOUMBKeywordCategoryOpRemove661 Files were removed from @Keywords. d1 : id of category which caused the change.
evOUMBKeywordCategoryOpUpdate662 Files were updated in @Keywords. d1 : id of category which caused the change.
evOUMBKeywordRemove665 A @Keyword category was removed, including all children and their associated keywords. d1 : id of category.
evOUSortArrayUpdate700 A sort array (custom sort order) was updated. d1 : id of array, d2 storage id of array.
evOUSortArrayDelete701 Sort array removed. d1 : id of the array. If 0, all entries were removed. d2 storage id.
evOUFavoriteSetAdd750 A favorite set was added. d1 : id.
evOUFavoriteSetUpdate751 A favorite set was updated. d1 : id, d2 : user data.
evOUFavoriteSetDelete752 A favorite set was deleted. d1 : id.
evOURelationDefAdd800 Relation Definition added. d1 : id of definition.
evOURelationDefUpdate801 Relation Definition updated. d1 : id of definition.
evOURelationDefRemove802 Relation Definition removed. d1 : id of definition.
evOURelationUpdate820 Relation updated. d1 : id of file. If 0, multiple files were updated.
evOURelationStackCreate830 A stack was created. d1 : id of file, d2 : relation type: 20: version, 30: regular stack.
evOURelationStackDelete831 A stack was deleted. d1 : id of file, d2 : relation type.
evOURelationStackCreateElement832 A stack elem was created. d1 : id of stack, d2 : id of file, d3 : relation type.
evOURelationStackDeleteElement833 A stack elem was created. d1 : id of stack or 0 if multiple stacks were processed. d2 : id of file, d3 : relation type.
evOURelationStackStateUpdate834 The stack state (expanded/contracted) changed, d1 : id of stack, d2 : relation type.
evOURelationStackTopUpdate835 The stack top was changed (d1 : id of stack, d2 : id of new top).
evOUFileHistoryAdd900 Added a history entry for a file (d1 : id of file, d2 : Type of event).
Event types:
1: File added
2: File updated
20: File moved
21: File copied
22: File renamed
50: Category assignment(s) changed
60: Metadata changed
70: Annotations changedTasks:
100: File viewed
101: File printed
102: File emailed
103: File editedUser Events:
1000: User-generated eventevOUFileHistoryUpdate901 Updated a history entry for a file. d1 : id of file, d2 : Type of event.
evOUFileHistoryDelete902 Deleted a history entry for a file. d1 : id of file, d2 : Type of event.
evOUFileHistoryPurge903 Purged the history for a file. d1 : id of file. If 0, general purge for all files.
evOUMDTUpdate950 Metadata Templates updated.
evOUGeoLocationsUpdate1000 Geo Locations updated.
evOUAnnoUpdate1100 Annotations for file updated. d1: id of file.
evOUAnnoRemove1101 Annotations for file removed. d1: id of file.
evOUAnnoCopy1102 Annotations copied. d1: source file id, d2: desitination file id.
evFileSystem300 File System Events.
These events are sent when changes in the file system are detected.evFSDeviceArrived1 evFSDeviceRemoved2 evFSCacheUpdated10 evFSFolderModified20 evFSFolderDeleted21 evFSFolderCreated22 evFSFolderRenamed23 evFSFileModifed30 evFSFileDeleted31 evFSFileCreated32 evFSFileRenamed33 evFileOp700 File System Operation Events
These events are sent during certain long-running batch operations like/folders/add,/folders/rescan,/folders/copyetc.
They are sent only to the app/session which triggered the operation (e.g. the app which used thefolders/copyendpoint).
Note that these events are sent while the endpoint call is still running. This enables an app to provide user feedback during long-running batch operations.evFOBatchBegin1 Batch operation starts. d1: operation type
evFOBatchEnd2 Batch operation completed. d1: operation type
evFOBatchError5 Error during batch operation. This event includes an
errorInfoobject which tries to provide as much info about hte error as possible.
errorId: FileOpUIError code:
errUnknown : 0,
errDeleteFile : 1,
errCopyFile : 2,
errCopyFileBuddiesDuplicates : 3,
errMoveFile : 4,
errRenameFile : 5,
errRenameFileDuplicateFileName : 6,
errDeleteFolder : 7,
errCopyFolder : 8,
errMoveFolder : 9,
errRenameFolder : 10
lastOSError: Windows error code
id1, id2: ids of involved objects
name1, name2: name of involved objectsevFOBatchAborted6 Batch operation aborted by user / app
efFOBatchProgress10 Progress feedback during batch operations. d1: operation type, d2: percentage of completion (0-100).
Methods
-
get(endpoint, parameters) → {Promise}
-
This method takes the name of an endpoint (without leading /) and an optional parameter object.
It perform a GET request on this endpoint with the given parameters and returns a promise.The method automatically performs authentication using
config.auth_token. You don't need to specify the auth_token parameter.Parameters:
Name Type Description endpointstring The endpoint to call. Include the version number as needed.
parametersobject Optionel parameters to send to IMWS.
Returns:
- A promise object that is resolved once the server has responded.
- Type
- Promise
Examples
// Calls the /info endpoint to retrieve information about IMWS and the database. IMWS.get('/info').then(...// Retrieves data for files using the /files endpoint. The files with the id 1,2,3 are queried // and for each file the fields id, name and size are to be returned. IMWS.get('v1/files',{ id: "1,2,3", fields: "id,name,size" }).then(function(response) { response.files.forEach(...) }); -
post(endpoint, parameters) → {Promise}
-
This method takes the name of an endpoint (without leading /) and an optional parameter object.
It perform a POST request on this endpoint with the given parameters and returns a promise.The method automatically performs authentication using
config.auth_token. You don't need to specify the auth_token parameter.Parameters:
Name Type Description endpointString parametersObject Optional object with parameters to send to the server.
Returns:
- A promise object that is resolved once the server has responded.
- Type
- Promise
Example
// Call an endpoint which requies the POST method: IMatch.post('name of endpoint', ...) -
delete(endpoint, parameters) → {Promise}
-
This method takes the name of an endpoint (without leading /) and an optional parameter object.
It perform a DELETE request on this endpoint with the given parameters and returns a promise.The method automatically performs authentication using
config.auth_token. You don't need to specify the auth_token parameter.Parameters:
Name Type Description endpointString parametersObject Optional object with parameters to send to the server.
Returns:
- A promise object that is resolved once the server has responded.
- Type
- Promise
Example
// Call an endpoint which requies the DELETE method: IMatch.delete('name of endpoint', ...) -
init(params)
-
Initialize this class.
Parameters:
Name Type Description paramsObject Properties
Name Type Description imwsUrlString The URL of the IMatch WebServices instance to use.
-
authenticate(params) → {Promise}
-
Endpoint: /authenticate.
Authenticate the current session.
This is the first method to call. It logs into IMWS and stores the
session token in the config member.Parameters:
Name Type Description paramsObject Login data
Properties
Name Type Description idString User name.
UseIMWS_DEFAULT_USERif the authentication in IMWS is disabled - unless a different default user name is configured on the server.passwordString password.
Use an empty password if authentication is disabled.appidString (Optional) The app id.
This is only needed when IMWS has been configured to accept only specific apps.Returns:
If it resolves, the log-in was successful.
- Type
- Promise
Example
// Log in user 'Tom' with password 'secret' IMWS.authenticate({ id: "Tom", password: "secret" }).then(function(response) { // Successfully logged in. The IMWS instance now has the auth_token and other user // data in the IMWS.config object. }); -
webSocket() → {WebSocket}
-
This function gives access to a web socket that allows your script to exchange messages with IMWS and to receive information about events or changes madeto the database.
The socket can been opened with IMWS#openWebSocket.
Returns:
The opened web socket or null if no web socket was opened.
- Type
- WebSocket
-
openWebSocket(url, authToken)
-
Open a web socket for the /imws url. The socket can then be used to send and receive messages from IMatch.
This method automatically authenticates the socket after creating it.Embedded
If this is called from an app running in IMatch you don't need to specify {@param url} or {@param authToken}.
Otherwise specifiy the full URL and port, e.g.,ws://127.0.0.1:50519and the authentication token.Parameters:
Name Type Description urlString Optional. The web socket URL.
authTokenString Optional. The authentication token received from the
/authenticateendpoint. -
dataGet(params) → {Promise}
-
Endpoint:
/v1/dataThis method retrieves previously stored data.
The /data endpoints are basically a small 'cloud' storage facility managed by IMWS. You can store arbitrary text data (including stringified JSON data) using these endpoints. This is an easy way to store script settings or user preferences.Each item is idenfied using a unique name (whatever you like).
Names starting with @ & or # are reserved for system usage.IMWS associates the data with the current user and application id (if one was provided during
/authenticate). Each user has its own isolated data store.
The maximum amount of data that can be stored per user is controlled via IMWS settings. By default, 1 MB of data can be stored per user, which is plenty.Embedded
If this is used from an app using the embedded IMWS in IMatch, the data is not associated with a specific user.
This allows you to store global and per-user settings, depending on what you need. If you want to store settings per-user, include the user name in the name parameter.
The embedded IMWS in IMatch enforces no storage limit.Parameters:
Name Type Description paramsObject Parameters to send to IMWS.
Properties
Name Type Argument Default Description nameString name of the data item to retrieve.
targetString <optional>
'global' Supported are 'global' (data stored in the settings database) and 'database' (data stored in the IMatch database).
encryptionBoolean <optional>
false Set this to true if the data was saved with encryption.
passwordBoolean <optional>
The password used to encrypt the data.
Returns:
- Type
- Promise
Example
// Retrieves the data item named 'myapp.note' IMWS.dataGet( {name: "myapp.note" }).then(function(response) { console.log(response.value); }); -
dataSet(params) → {Promise}
-
Endpoint:
/v1/dataThis method creates or updates a new data item.
Parameters:
Name Type Description paramsObject Parameters to send to IMWS.
Properties
Name Type Argument Default Description nameString name of the data item to create or update
valueString the value to set. Only text is allowed. Use JSON.stringify to store arbitrary JSON data.
targetString <optional>
'global' Where to store the data. Supported are 'global' (data is stored in the settings database) and 'database' (data is stored in the IMatch database).
encryptionBoolean <optional>
false If this is true, the data is encrypted using password before storing it. This can be used as an extra safety measure (don't hard-code the password in yoru app!).
passwordBoolean <optional>
The password to use when encryption is used. You should specify a fairly long and complex password (or let the user choose one).
Returns:
- Type
- Promise
Example
// Add/update the data item named 'myapp.note' IMWS.dataSet({ name: "myapp.note", value: "This is the new note I want to store." }); -
dataList(params) → {Promise}
-
Endpoint:
/v1/data/listThis method allows to query existing data objects.
Parameters:
Name Type Description paramsObject Parameters to send to IMWS.
Properties
Name Type Argument Default Description nameString PERL regular expression. Use .* to retireve a list of all stored items.
targetString <optional>
'global' Supported are 'global' (data stored in the settings database) and 'database' (data stored in the IMatch database).
Returns:
- Type
- Promise
-
dataDelete(params) → {Promise}
-
Endpoint:
/v1/dataDeletes a previously stored data item.
Parameters:
Name Type Description paramsObject Parameters to send to IMWS.
Properties
Name Type Argument Default Description nameString name of the data item to delete.
targetString <optional>
'global' Supported are 'global' (data stored in the settings database) and 'database' (data stored in the IMatch database).
Returns:
- Type
- Promise