@pageproof/sdk-pr 527.0.1712030173316 → 528.0.1712547835918
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/CHANGELOG.md +42 -0
- package/lib/adapters/WorkerCryptoAdapter.d.ts +19 -2
- package/lib/adapters/WorkerCryptoAdapter.js +1 -1
- package/lib/api/Comments.d.ts +6 -1
- package/lib/api/Comments.js +1 -1
- package/lib/models/Comment.d.ts +8 -0
- package/lib/models/Comment.js +1 -1
- package/lib/models/Proof.d.ts +10 -0
- package/lib/models/Proof.js +1 -1
- package/lib/models/WorkflowStep.d.ts +8 -0
- package/lib/models/WorkflowStep.js +1 -1
- package/lib/models/WorkflowUser.d.ts +14 -2
- package/lib/models/WorkflowUser.js +1 -1
- package/lib/network/endpoints.json +1 -1
- package/lib/pageproof.js +1 -1
- package/lib/worker/WebWorker.js +1 -1
- package/lib/worker-crypto-adapter.js +1 -1
- package/lib/{worker.7bc1dbaf.js → worker.959d0daf.js} +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,47 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.325
|
|
4
|
+
|
|
5
|
+
Released on the 8th of April 2024.
|
|
6
|
+
|
|
7
|
+
- [[PP-6963](https://goto.pageproof.dev/PP-6963)] Added `visibleDate` and `completeDate` to the `WorkflowStep` model.
|
|
8
|
+
|
|
9
|
+
## 2.0.0-beta.324
|
|
10
|
+
|
|
11
|
+
Released on the 5th of April 2024.
|
|
12
|
+
|
|
13
|
+
- [[PP-7024](https://goto.pageproof.dev/PP-7024)] Changed the structure of proof video credentials (which are only used within the PageProof web-app).
|
|
14
|
+
|
|
15
|
+
## 2.0.0-beta.323
|
|
16
|
+
|
|
17
|
+
Released on the 15th of March 2024.
|
|
18
|
+
|
|
19
|
+
_This release contains changes only for internal use._
|
|
20
|
+
|
|
21
|
+
## 2.0.0-beta.322
|
|
22
|
+
|
|
23
|
+
Released on the 28th of February 2024.
|
|
24
|
+
|
|
25
|
+
- Added `firstViewedDate` and `decisionId` to the `WorkflowUser` model.
|
|
26
|
+
|
|
27
|
+
## 2.0.0-beta.321
|
|
28
|
+
|
|
29
|
+
Released on the 28th of February 2024.
|
|
30
|
+
|
|
31
|
+
- Added support for loading and creating private comments.
|
|
32
|
+
|
|
33
|
+
## 2.0.0-beta.320
|
|
34
|
+
|
|
35
|
+
Released on the 27th of February 2024.
|
|
36
|
+
|
|
37
|
+
- Added documentation to the `canHavePrivateComments` field on the Proof model.
|
|
38
|
+
|
|
39
|
+
## 2.0.0-beta.319
|
|
40
|
+
|
|
41
|
+
Released on the 27th of February 2024.
|
|
42
|
+
|
|
43
|
+
- Added the `canHavePrivateComments` field to the Proof model.
|
|
44
|
+
|
|
3
45
|
## 2.0.0-beta.318
|
|
4
46
|
|
|
5
47
|
Released on the 9th of February 2024.
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
export default WorkerCryptoAdapter;
|
|
2
2
|
declare class WorkerCryptoAdapter extends SchedulerCryptoAdapter {
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* @param {object} options
|
|
5
|
+
* @param {string} [options.url]
|
|
6
|
+
* @param {() => Worker} [options.create]
|
|
7
|
+
* @param {number} [options.limit]
|
|
8
|
+
* @param {boolean} [options.optimistic]
|
|
9
|
+
*/
|
|
10
|
+
constructor(options?: {
|
|
11
|
+
url?: string;
|
|
12
|
+
create?: () => Worker;
|
|
13
|
+
limit?: number;
|
|
14
|
+
optimistic?: boolean;
|
|
15
|
+
});
|
|
16
|
+
options: {
|
|
17
|
+
url?: string;
|
|
18
|
+
create?: () => Worker;
|
|
19
|
+
limit?: number;
|
|
20
|
+
optimistic?: boolean;
|
|
21
|
+
};
|
|
5
22
|
}
|
|
6
23
|
import SchedulerCryptoAdapter from "./SchedulerCryptoAdapter";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};var _SchedulerCryptoAdapter=require("./SchedulerCryptoAdapter");var _SchedulerCryptoAdapter2=_interopRequireDefault(_SchedulerCryptoAdapter);var _WebWorker=require("../worker/WebWorker");var _WebWorker2=_interopRequireDefault(_WebWorker);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var defaultOptions={url:null,limit:navigator.hardwareConcurrency||1,optimistic:false};var WorkerCryptoAdapter=function(_SchedulerCryptoAdapt){_inherits(WorkerCryptoAdapter,_SchedulerCryptoAdapt);function WorkerCryptoAdapter(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,WorkerCryptoAdapter);options=_extends({},defaultOptions,options);var _this=_possibleConstructorReturn(this,_SchedulerCryptoAdapt.call(this,{limit:options.limit,create:function
|
|
1
|
+
"use strict";exports.__esModule=true;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};var _SchedulerCryptoAdapter=require("./SchedulerCryptoAdapter");var _SchedulerCryptoAdapter2=_interopRequireDefault(_SchedulerCryptoAdapter);var _WebWorker=require("../worker/WebWorker");var _WebWorker2=_interopRequireDefault(_WebWorker);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var defaultOptions={url:null,limit:navigator.hardwareConcurrency||1,optimistic:false};var WorkerCryptoAdapter=function(_SchedulerCryptoAdapt){_inherits(WorkerCryptoAdapter,_SchedulerCryptoAdapt);function WorkerCryptoAdapter(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,WorkerCryptoAdapter);options=_extends({},defaultOptions,options);var _this=_possibleConstructorReturn(this,_SchedulerCryptoAdapt.call(this,{limit:options.limit,create:options.create||function(){__webpack_public_path__=options.url+"/";return new _WebWorker2.default}}));if(options.optimistic){_this.scheduler.prime()}_this.options=options;return _this}return WorkerCryptoAdapter}(_SchedulerCryptoAdapter2.default);exports.default=WorkerCryptoAdapter;
|
package/lib/api/Comments.d.ts
CHANGED
|
@@ -186,6 +186,7 @@ declare class Comments extends API {
|
|
|
186
186
|
* @property {{custom?: object}} [sourceMetadata] Additional metadata about the source of the comment
|
|
187
187
|
* @property {string} [state] For comments (not replies) - The state of the comment (currently only supports to-dos)
|
|
188
188
|
* @property {boolean} [autoState] Sets the state of the comment as to-do as long as the user is permitted to do so otherwise comment is unmarked.
|
|
189
|
+
* @property {boolean} [isPrivate] Whether the comment should be marked as private - making it only visible to other reviewers in the proof's team. This option is ignored if the current user isn't a member of the proof's team.
|
|
189
190
|
* @property {string} [creationToken] Only required if you're retrying (token can be extracted from the error object which is resolved (rejected, in this case) from the Promise)
|
|
190
191
|
*/
|
|
191
192
|
/**
|
|
@@ -244,7 +245,7 @@ declare class Comments extends API {
|
|
|
244
245
|
* @param {CreateCommentOptions} options The creation options
|
|
245
246
|
* @returns {Promise<Comment>}
|
|
246
247
|
*/
|
|
247
|
-
create({ raw, tokens, proofId, pageNumber, pin, pins, mediaTime, mediaDuration, parentCommentId, metadata, sourceMetadata, state, autoState, creationToken: retryCreationToken, }: {
|
|
248
|
+
create({ raw, tokens, proofId, pageNumber, pin, pins, mediaTime, mediaDuration, parentCommentId, metadata, sourceMetadata, state, autoState, isPrivate, creationToken: retryCreationToken, }: {
|
|
248
249
|
/**
|
|
249
250
|
* The comment text (plain text)
|
|
250
251
|
*/
|
|
@@ -299,6 +300,10 @@ declare class Comments extends API {
|
|
|
299
300
|
* Sets the state of the comment as to-do as long as the user is permitted to do so otherwise comment is unmarked.
|
|
300
301
|
*/
|
|
301
302
|
autoState?: boolean;
|
|
303
|
+
/**
|
|
304
|
+
* Whether the comment should be marked as private - making it only visible to other reviewers in the proof's team. This option is ignored if the current user isn't a member of the proof's team.
|
|
305
|
+
*/
|
|
306
|
+
isPrivate?: boolean;
|
|
302
307
|
/**
|
|
303
308
|
* Only required if you're retrying (token can be extracted from the error object which is resolved (rejected, in this case) from the Promise)
|
|
304
309
|
*/
|
package/lib/api/Comments.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Comment=require("../models/Comment");var _Comment2=_interopRequireDefault(_Comment);var _CommentState=require("../enum/CommentState");var _CommentState2=_interopRequireDefault(_CommentState);var _constants=require("../util/constants");var _sort=require("../util/sort");var _v=require("../util/comments/v2");var _extractMentions=require("../util/comments/extractMentions");var _extractMentions2=_interopRequireDefault(_extractMentions);var _parseComment=require("../util/comments/parseComment");var _parseComment2=_interopRequireDefault(_parseComment);var _creationToken=require("../util/creationToken");var _throttle=require("../util/throttle");var _throttle2=_interopRequireDefault(_throttle);var _getCommentState=require("../util/comments/getCommentState");var _getCommentState2=_interopRequireDefault(_getCommentState);var _serializePins=require("../util/pins/serializePins");var _CommentsImport=require("./CommentsImport");var _CommentsImport2=_interopRequireDefault(_CommentsImport);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}function getCommentDataFromPages(pages){var comments=[];Object.keys(pages).forEach(function(pageNumber){pages[pageNumber].Comments.forEach(function(commentData){comments.push(commentData)})});return comments}var _sortPages=(0,_sort.sortObjectsByKey)("pageNumber");var _sortCreatedDateDESC=(0,_sort.sortObjectsByKey)("createdDate",true);var _sortCreatedDateASC=(0,_sort.sortObjectsByKey)("createdDate",false);var sortComments=(0,_sort.combineSort)(_sortPages,_sortCreatedDateDESC);var sortReplies=(0,_sort.combineSort)(_sortPages,_sortCreatedDateASC);function mapComments(commentsData){var comments=[];var replies=[];commentsData.forEach(function(commentData){var entity=(new _Comment2.default).fromComment(commentData);if(entity.parentCommentId){replies.push(entity)}else{comments.push(entity)}});comments.sort(sortComments);var commentIds=comments.map(function(c){return c.id});var sortByParentCommentIndex=(0,_sort.sortObjectsBy)(function(r){return commentIds.indexOf(r.parentCommentId)},true);replies.sort((0,_sort.combineSort)(sortReplies,sortByParentCommentIndex));return comments.concat(replies)}var Comments=function(_API){_inherits(Comments,_API);function Comments(client){_classCallCheck(this,Comments);var _this=_possibleConstructorReturn(this,_API.call(this,client));_this.import=new _CommentsImport2.default(client);return _this}Comments.prototype._mark=function _mark(commentId,state,value){if(Object.keys(_CommentState2.default).map(function(key){return _CommentState2.default[key]}).indexOf(state)===-1){throw new Error('Cannot mark comment state "'+state+'".')}var TODO=_CommentState2.default.TODO,DONE=_CommentState2.default.DONE,UNMARKED=_CommentState2.default.UNMARKED;var data={commentId:commentId};switch(state){case UNMARKED:{data.change=0;data.done=0;break}case TODO:{data.change=value?1:0;data.done=0;break}case DONE:{data.done=value?1:0;break}}return this.client.request("comments.state.update",data).then(function(response){return(0,_getCommentState2.default)(response.data)})};Comments.prototype._markAll=function _markAll(proofId,commentIds,state,value){if(Object.keys(_CommentState2.default).map(function(key){return _CommentState2.default[key]}).indexOf(state)===-1){throw new Error('Cannot mark comment state "'+state+'".')}var TODO=_CommentState2.default.TODO,DONE=_CommentState2.default.DONE,UNMARKED=_CommentState2.default.UNMARKED;var data={proofId:proofId,commentIds:commentIds};switch(state){case UNMARKED:{data.change=0;data.done=0;break}case TODO:{data.change=value?1:0;data.done=0;break}case DONE:{data.done=value?1:0;break}}return this.client.request("comments.state.multiple-update",data).then(function(response){return response.data.map(function(comment){return{commentId:comment.CommentId,commentState:(0,_getCommentState2.default)(comment)}})})};Comments.prototype.mark=function mark(commentId,state){return this._mark(commentId,state,true)};Comments.prototype.unmark=function unmark(commentId,state){return this._mark(commentId,state,false)};Comments.prototype.markAll=function markAll(proofId,commentIds,state){return this._markAll(proofId,commentIds,state,true)};Comments.prototype.unmarkAll=function unmarkAll(proofId,commentIds,state){return this._markAll(proofId,commentIds,state,false)};Comments.prototype.delete=function _delete(commentId){return this.client.request("comments.delete",{commentId:commentId})};Comments.prototype.load=function load(_options){var _this2=this;var options=typeof _options==="string"?{proofId:_options}:_options;var proofId=options.proofId,_options$pageNumber=options.pageNumber,pageNumber=_options$pageNumber===undefined?null:_options$pageNumber,_options$sinceDate=options.sinceDate,sinceDate=_options$sinceDate===undefined?null:_options$sinceDate,_options$async=options.async,async=_options$async===undefined?false:_options$async,_options$decrypt=options.decrypt,decrypt=_options$decrypt===undefined?true:_options$decrypt,onDecryptComment=options.onDecryptComment,onDecryptComments=options.onDecryptComments,_options$onDecryptCom=options.onDecryptCommentsThrottleMs,onDecryptCommentsThrottleMs=_options$onDecryptCom===undefined?1e3:_options$onDecryptCom,onDecryptError=options.onDecryptError;var sinceDateISO=sinceDate?sinceDate.toISOString().match(_constants.ISO_REGEX)[0]:_constants.DEFAULT_ISO_DATE;var payload={proofId:proofId,page:pageNumber,timestamp:sinceDateISO};return this.client.request(pageNumber!==null?"comments.load-page":"comments.load-all",payload).then(function(response){var comments=mapComments(response.data.Pages?getCommentDataFromPages(response.data.Pages):response.data);var wait=Promise.resolve();if(decrypt){var scheduled=[];var pendingBatch=[];var scheduleOnDecryptComments=onDecryptComments?(0,_throttle2.default)(function(){if(pendingBatch.length){onDecryptComments(pendingBatch);pendingBatch=[]}},onDecryptCommentsThrottleMs):function(){};var cached=Promise.all(comments.map(function(comment){return _this2.client.cache.auto(_constants.COMMENT_CACHE_PREFIX+comment.comment$,function(resolve){scheduled.push({comment:comment,resolve:resolve})}).then(function(rawComment){if(rawComment){comment.fromRawComment(rawComment)}return comment})}));wait=wait.then(function(){return cached});wait=wait.then(function(){var decrypted=scheduled.map(function(_ref){var comment=_ref.comment,resolve=_ref.resolve;return _this2.client.crypto().decryptComment(comment.comment$,comment.envelope,_this2.client.keyPairs.getPrivateKeyPEMs()).then(function(rawComment){comment.fromRawComment(rawComment);resolve(rawComment);if(onDecryptComment){onDecryptComment(comment)}pendingBatch.push(comment);scheduleOnDecryptComments()}).catch(function(err){if(onDecryptError){onDecryptError(err,comment)}if(!async){return Promise.reject(err)}return undefined})});if(!async){return Promise.all(decrypted)}return null})}return wait.then(function(){return comments})})};Comments.prototype.create=function create(_ref2){var _this3=this;var raw=_ref2.raw,tokens=_ref2.tokens,proofId=_ref2.proofId,_ref2$pageNumber=_ref2.pageNumber,pageNumber=_ref2$pageNumber===undefined?1:_ref2$pageNumber,pin=_ref2.pin,pins=_ref2.pins,mediaTime=_ref2.mediaTime,mediaDuration=_ref2.mediaDuration,parentCommentId=_ref2.parentCommentId,metadata=_ref2.metadata,sourceMetadata=_ref2.sourceMetadata,state=_ref2.state,autoState=_ref2.autoState,retryCreationToken=_ref2.creationToken;var mentions=[];var serialized=raw||(0,_v.serialize)(tokens);{var parsed=tokens||(0,_parseComment2.default)(raw);mentions.push.apply(mentions,(0,_extractMentions2.default)(parsed))}var pinList=[];var boxFill=void 0;if(pins){pinList=pinList.concat(pins)}else if(pin){pinList.push(pin)}var primaryPin=pinList[0];if(primaryPin){if(primaryPin.fill)boxFill=primaryPin.fill;if(mediaTime)primaryPin.time=mediaTime;if(mediaDuration)primaryPin.duration=mediaDuration}var creationToken=retryCreationToken||(0,_creationToken.generateCreationToken)();return this.client.crypto().encryptComment(serialized,this.client.keyPairs.getPublicKeyPEMs()).then(function(_ref3){var envelope=_ref3.envelope,comment$=_ref3.comment$;return{proofId:proofId,page:parentCommentId?undefined:pageNumber,envelope:envelope,encryptedComment:comment$,xy:(0,_serializePins.serializePins)(pinList),boxFillImage:boxFill?boxFill.image:undefined,boxFillType:boxFill?boxFill.type:undefined,parent:parentCommentId||undefined,mentions:mentions,metadata:metadata?JSON.stringify(metadata):"{}",sourceMetadata:sourceMetadata,creationToken:creationToken,change:state===_CommentState2.default.TODO?"1":undefined,done:state===_CommentState2.default.DONE?"1":undefined,autoState:autoState}}).then(function(requestData){return _this3.client.request("comments.create",requestData).then(function(response){return(new _Comment2.default).fromComment(response.data).fromRawComment(serialized)})}).catch(function(err){if(err){err.creationToken=creationToken}return Promise.reject(err)})};return Comments}(_API3.default);exports.default=Comments;
|
|
1
|
+
"use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Comment=require("../models/Comment");var _Comment2=_interopRequireDefault(_Comment);var _CommentState=require("../enum/CommentState");var _CommentState2=_interopRequireDefault(_CommentState);var _constants=require("../util/constants");var _sort=require("../util/sort");var _v=require("../util/comments/v2");var _extractMentions=require("../util/comments/extractMentions");var _extractMentions2=_interopRequireDefault(_extractMentions);var _parseComment=require("../util/comments/parseComment");var _parseComment2=_interopRequireDefault(_parseComment);var _creationToken=require("../util/creationToken");var _throttle=require("../util/throttle");var _throttle2=_interopRequireDefault(_throttle);var _getCommentState=require("../util/comments/getCommentState");var _getCommentState2=_interopRequireDefault(_getCommentState);var _serializePins=require("../util/pins/serializePins");var _CommentsImport=require("./CommentsImport");var _CommentsImport2=_interopRequireDefault(_CommentsImport);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}function getCommentDataFromPages(pages){var comments=[];Object.keys(pages).forEach(function(pageNumber){pages[pageNumber].Comments.forEach(function(commentData){comments.push(commentData)})});return comments}var _sortPages=(0,_sort.sortObjectsByKey)("pageNumber");var _sortCreatedDateDESC=(0,_sort.sortObjectsByKey)("createdDate",true);var _sortCreatedDateASC=(0,_sort.sortObjectsByKey)("createdDate",false);var sortComments=(0,_sort.combineSort)(_sortPages,_sortCreatedDateDESC);var sortReplies=(0,_sort.combineSort)(_sortPages,_sortCreatedDateASC);function mapComments(commentsData){var comments=[];var replies=[];commentsData.forEach(function(commentData){var entity=(new _Comment2.default).fromComment(commentData);if(entity.parentCommentId){replies.push(entity)}else{comments.push(entity)}});comments.sort(sortComments);var commentIds=comments.map(function(c){return c.id});var sortByParentCommentIndex=(0,_sort.sortObjectsBy)(function(r){return commentIds.indexOf(r.parentCommentId)},true);replies.sort((0,_sort.combineSort)(sortReplies,sortByParentCommentIndex));return comments.concat(replies)}var Comments=function(_API){_inherits(Comments,_API);function Comments(client){_classCallCheck(this,Comments);var _this=_possibleConstructorReturn(this,_API.call(this,client));_this.import=new _CommentsImport2.default(client);return _this}Comments.prototype._mark=function _mark(commentId,state,value){if(Object.keys(_CommentState2.default).map(function(key){return _CommentState2.default[key]}).indexOf(state)===-1){throw new Error('Cannot mark comment state "'+state+'".')}var TODO=_CommentState2.default.TODO,DONE=_CommentState2.default.DONE,UNMARKED=_CommentState2.default.UNMARKED;var data={commentId:commentId};switch(state){case UNMARKED:{data.change=0;data.done=0;break}case TODO:{data.change=value?1:0;data.done=0;break}case DONE:{data.done=value?1:0;break}}return this.client.request("comments.state.update",data).then(function(response){return(0,_getCommentState2.default)(response.data)})};Comments.prototype._markAll=function _markAll(proofId,commentIds,state,value){if(Object.keys(_CommentState2.default).map(function(key){return _CommentState2.default[key]}).indexOf(state)===-1){throw new Error('Cannot mark comment state "'+state+'".')}var TODO=_CommentState2.default.TODO,DONE=_CommentState2.default.DONE,UNMARKED=_CommentState2.default.UNMARKED;var data={proofId:proofId,commentIds:commentIds};switch(state){case UNMARKED:{data.change=0;data.done=0;break}case TODO:{data.change=value?1:0;data.done=0;break}case DONE:{data.done=value?1:0;break}}return this.client.request("comments.state.multiple-update",data).then(function(response){return response.data.map(function(comment){return{commentId:comment.CommentId,commentState:(0,_getCommentState2.default)(comment)}})})};Comments.prototype.mark=function mark(commentId,state){return this._mark(commentId,state,true)};Comments.prototype.unmark=function unmark(commentId,state){return this._mark(commentId,state,false)};Comments.prototype.markAll=function markAll(proofId,commentIds,state){return this._markAll(proofId,commentIds,state,true)};Comments.prototype.unmarkAll=function unmarkAll(proofId,commentIds,state){return this._markAll(proofId,commentIds,state,false)};Comments.prototype.delete=function _delete(commentId){return this.client.request("comments.delete",{commentId:commentId})};Comments.prototype.load=function load(_options){var _this2=this;var options=typeof _options==="string"?{proofId:_options}:_options;var proofId=options.proofId,_options$pageNumber=options.pageNumber,pageNumber=_options$pageNumber===undefined?null:_options$pageNumber,_options$sinceDate=options.sinceDate,sinceDate=_options$sinceDate===undefined?null:_options$sinceDate,_options$async=options.async,async=_options$async===undefined?false:_options$async,_options$decrypt=options.decrypt,decrypt=_options$decrypt===undefined?true:_options$decrypt,onDecryptComment=options.onDecryptComment,onDecryptComments=options.onDecryptComments,_options$onDecryptCom=options.onDecryptCommentsThrottleMs,onDecryptCommentsThrottleMs=_options$onDecryptCom===undefined?1e3:_options$onDecryptCom,onDecryptError=options.onDecryptError;var sinceDateISO=sinceDate?sinceDate.toISOString().match(_constants.ISO_REGEX)[0]:_constants.DEFAULT_ISO_DATE;var payload={proofId:proofId,page:pageNumber,timestamp:sinceDateISO};return this.client.request(pageNumber!==null?"comments.load-page":"comments.load-all",payload).then(function(response){var comments=mapComments(response.data.Pages?getCommentDataFromPages(response.data.Pages):response.data);var wait=Promise.resolve();if(decrypt){var scheduled=[];var pendingBatch=[];var scheduleOnDecryptComments=onDecryptComments?(0,_throttle2.default)(function(){if(pendingBatch.length){onDecryptComments(pendingBatch);pendingBatch=[]}},onDecryptCommentsThrottleMs):function(){};var cached=Promise.all(comments.map(function(comment){return _this2.client.cache.auto(_constants.COMMENT_CACHE_PREFIX+comment.comment$,function(resolve){scheduled.push({comment:comment,resolve:resolve})}).then(function(rawComment){if(rawComment){comment.fromRawComment(rawComment)}return comment})}));wait=wait.then(function(){return cached});wait=wait.then(function(){var decrypted=scheduled.map(function(_ref){var comment=_ref.comment,resolve=_ref.resolve;return _this2.client.crypto().decryptComment(comment.comment$,comment.envelope,_this2.client.keyPairs.getPrivateKeyPEMs()).then(function(rawComment){comment.fromRawComment(rawComment);resolve(rawComment);if(onDecryptComment){onDecryptComment(comment)}pendingBatch.push(comment);scheduleOnDecryptComments()}).catch(function(err){if(onDecryptError){onDecryptError(err,comment)}if(!async){return Promise.reject(err)}return undefined})});if(!async){return Promise.all(decrypted)}return null})}return wait.then(function(){return comments})})};Comments.prototype.create=function create(_ref2){var _this3=this;var raw=_ref2.raw,tokens=_ref2.tokens,proofId=_ref2.proofId,_ref2$pageNumber=_ref2.pageNumber,pageNumber=_ref2$pageNumber===undefined?1:_ref2$pageNumber,pin=_ref2.pin,pins=_ref2.pins,mediaTime=_ref2.mediaTime,mediaDuration=_ref2.mediaDuration,parentCommentId=_ref2.parentCommentId,metadata=_ref2.metadata,sourceMetadata=_ref2.sourceMetadata,state=_ref2.state,autoState=_ref2.autoState,isPrivate=_ref2.isPrivate,retryCreationToken=_ref2.creationToken;var mentions=[];var serialized=raw||(0,_v.serialize)(tokens);{var parsed=tokens||(0,_parseComment2.default)(raw);mentions.push.apply(mentions,(0,_extractMentions2.default)(parsed))}var pinList=[];var boxFill=void 0;if(pins){pinList=pinList.concat(pins)}else if(pin){pinList.push(pin)}var primaryPin=pinList[0];if(primaryPin){if(primaryPin.fill)boxFill=primaryPin.fill;if(mediaTime)primaryPin.time=mediaTime;if(mediaDuration)primaryPin.duration=mediaDuration}var creationToken=retryCreationToken||(0,_creationToken.generateCreationToken)();return this.client.crypto().encryptComment(serialized,this.client.keyPairs.getPublicKeyPEMs()).then(function(_ref3){var envelope=_ref3.envelope,comment$=_ref3.comment$;return{proofId:proofId,page:parentCommentId?undefined:pageNumber,envelope:envelope,encryptedComment:comment$,xy:(0,_serializePins.serializePins)(pinList),boxFillImage:boxFill?boxFill.image:undefined,boxFillType:boxFill?boxFill.type:undefined,parent:parentCommentId||undefined,mentions:mentions,metadata:metadata?JSON.stringify(metadata):"{}",sourceMetadata:sourceMetadata,creationToken:creationToken,change:state===_CommentState2.default.TODO?"1":undefined,done:state===_CommentState2.default.DONE?"1":undefined,autoState:autoState,private:typeof isPrivate!=="undefined"?isPrivate?"1":"0":undefined}}).then(function(requestData){return _this3.client.request("comments.create",requestData).then(function(response){return(new _Comment2.default).fromComment(response.data).fromRawComment(serialized)})}).catch(function(err){if(err){err.creationToken=creationToken}return Promise.reject(err)})};return Comments}(_API3.default);exports.default=Comments;
|
package/lib/models/Comment.d.ts
CHANGED
|
@@ -176,6 +176,14 @@ declare class Comment {
|
|
|
176
176
|
* @type {number}
|
|
177
177
|
*/
|
|
178
178
|
mediaDuration: number;
|
|
179
|
+
/**
|
|
180
|
+
* Whether the comment is private.
|
|
181
|
+
*
|
|
182
|
+
* Note: Private comments are comments (or replies) that can only be viewed by reviewers who are members of the proof's team.
|
|
183
|
+
*
|
|
184
|
+
* @type {boolean}
|
|
185
|
+
*/
|
|
186
|
+
isPrivate: boolean;
|
|
179
187
|
/**
|
|
180
188
|
* @private
|
|
181
189
|
* @param {object} commentData The comment object from the server
|
package/lib/models/Comment.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _File=require("./File");var _File2=_interopRequireDefault(_File);var _parseComment=require("../util/comments/parseComment");var _parseComment2=_interopRequireDefault(_parseComment);var _getCommentState=require("../util/comments/getCommentState");var _getCommentState2=_interopRequireDefault(_getCommentState);var _parsePins=require("../util/pins/parsePins");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var commentSchema={id:"CommentId",proofId:"ProofId",pins:function pins(data){return(0,_parsePins.parsePins)(data.XY).map(function(pin,index){if(index===0&&data.BoxFillType){return _extends({},pin,{fill:data.BoxFillType&&{type:data.BoxFillType,image:data.BoxFillImage}})}return pin})},pin:function pin(){return this.pins[0]},user:function user(data){return(new _User2.default).fromUser(data)},comment$:"EncryptedComment",envelope:"Envelope",attachments:function attachments(data){if(data.Attachments){return data.Attachments.map(function(attachment){return(new _File2.default).fromCommentAttachment(_extends({CommentId:data.CommentId},attachment))})}return[]},agreeCount:function agreeCount(data){return data.Agrees.length},pageNumber:(0,_transform.number)("Page"),mediaTime:function mediaTime(){return this.pin&&this.pin.time},mediaDuration:function mediaDuration(){return this.pin&&this.pin.duration},createdDate:(0,_transform.date)("Timestamp"),updatedDate:(0,_transform.date)("Updated"),parentCommentId:(0,_transform.optional)("Parent"),metadata:(0,_transform.json)("Metadata",{}),sourceMetadata:"SourceMetadata",state:function state(data){return(0,_getCommentState2.default)(data)}};var Comment=function(){function Comment(){_classCallCheck(this,Comment)}Comment.prototype.fromComment=function fromComment(commentData){(0,_transform2.default)(this,commentSchema,commentData);return this};Comment.prototype.fromRawComment=function fromRawComment(rawComment){var parsed=(0,_parseComment2.default)(rawComment);this.raw=rawComment;this.tokens=parsed;return this};return Comment}();exports.default=Comment;
|
|
1
|
+
"use strict";exports.__esModule=true;var _extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _File=require("./File");var _File2=_interopRequireDefault(_File);var _parseComment=require("../util/comments/parseComment");var _parseComment2=_interopRequireDefault(_parseComment);var _getCommentState=require("../util/comments/getCommentState");var _getCommentState2=_interopRequireDefault(_getCommentState);var _parsePins=require("../util/pins/parsePins");function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var commentSchema={id:"CommentId",proofId:"ProofId",pins:function pins(data){return(0,_parsePins.parsePins)(data.XY).map(function(pin,index){if(index===0&&data.BoxFillType){return _extends({},pin,{fill:data.BoxFillType&&{type:data.BoxFillType,image:data.BoxFillImage}})}return pin})},pin:function pin(){return this.pins[0]},user:function user(data){return(new _User2.default).fromUser(data)},comment$:"EncryptedComment",envelope:"Envelope",attachments:function attachments(data){if(data.Attachments){return data.Attachments.map(function(attachment){return(new _File2.default).fromCommentAttachment(_extends({CommentId:data.CommentId},attachment))})}return[]},agreeCount:function agreeCount(data){return data.Agrees.length},pageNumber:(0,_transform.number)("Page"),mediaTime:function mediaTime(){return this.pin&&this.pin.time},mediaDuration:function mediaDuration(){return this.pin&&this.pin.duration},createdDate:(0,_transform.date)("Timestamp"),updatedDate:(0,_transform.date)("Updated"),parentCommentId:(0,_transform.optional)("Parent"),metadata:(0,_transform.json)("Metadata",{}),sourceMetadata:"SourceMetadata",state:function state(data){return(0,_getCommentState2.default)(data)},isPrivate:"Private"};var Comment=function(){function Comment(){_classCallCheck(this,Comment)}Comment.prototype.fromComment=function fromComment(commentData){(0,_transform2.default)(this,commentSchema,commentData);return this};Comment.prototype.fromRawComment=function fromRawComment(rawComment){var parsed=(0,_parseComment2.default)(rawComment);this.raw=rawComment;this.tokens=parsed;return this};return Comment}();exports.default=Comment;
|
package/lib/models/Proof.d.ts
CHANGED
|
@@ -337,6 +337,16 @@ declare class Proof {
|
|
|
337
337
|
* @type {boolean}
|
|
338
338
|
*/
|
|
339
339
|
canHaveGeneralComments: boolean;
|
|
340
|
+
/**
|
|
341
|
+
* Whether reviewers can add private comments.
|
|
342
|
+
*
|
|
343
|
+
* This field only tells you whether the proof _can_ have private comments, not whether the current user can create them.
|
|
344
|
+
*
|
|
345
|
+
* To check whether the current user can _create_ private comments: ensure they belong to the same team as the proof belongs to, on top of checking this field's value.
|
|
346
|
+
*
|
|
347
|
+
* @type {boolean}
|
|
348
|
+
*/
|
|
349
|
+
canHavePrivateComments: boolean;
|
|
340
350
|
/**
|
|
341
351
|
* The source of the proof if coming from an external system.
|
|
342
352
|
*
|
package/lib/models/Proof.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _ProofState=require("../enum/ProofState");var _ProofState2=_interopRequireDefault(_ProofState);var _ProofStatus=require("../enum/ProofStatus");var _ProofStatus2=_interopRequireDefault(_ProofStatus);var _ProofType=require("../enum/ProofType");var _ProofType2=_interopRequireDefault(_ProofType);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _id=require("../util/id");var _getPercentage=require("../util/getPercentage");var _getPercentage2=_interopRequireDefault(_getPercentage);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _DecisionSummary=require("./DecisionSummary");var _DecisionSummary2=_interopRequireDefault(_DecisionSummary);var _ProofIntegrationReference=require("./ProofIntegrationReference");var _ProofIntegrationReference2=_interopRequireDefault(_ProofIntegrationReference);var _ProofChecklist=require("./ProofChecklist");var _ProofChecklist2=_interopRequireDefault(_ProofChecklist);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function isOverdue(){return this.dueDate&&this.dueDate.getTime()<Date.now()}var proofSchema={id:"ProofId",name:"Title",status:"Status",workflowId:"WorkflowId",proofTemplateId:"ProofTemplateId",version:"Version",dueDate:(0,_transform.date)("DueDate"),createdDate:(0,_transform.date)("CreateDate"),approvedDate:(0,_transform.date)("ApprovedDate"),isLocked:"Locked",isArchived:"Closed",isOverdue:isOverdue,uploaderUserId:"UserId",ownerUserIds:"OwnerIds",editorUserId:"EditorId",editorUserIds:"EditorIds",lockerUserId:"ProofLockerId",messageToReviewers:"Description",messageToOwners:"OwnerMessage",messageToEditor:"EditorMessage",fileId:"FileId",fileExtension:"Extension",fileStatus:"FileStatus",fileMessage:"FileStatusMessage",fileSize:"FileSize",pageCount:(0,_transform.number)("Pages"),commentCount:(0,_transform.number)("ParentComments"),canDownload:(0,_transform.truthy)("DownloadOriginal"),type:"Type",processStatus:"ProcessStatus",recipient:"Recipient",recipientEmail:"RecipientEmail",todoCommentCount:(0,_transform.number)("CountTodoComments"),doneCommentCount:(0,_transform.number)("CountDoneComments"),fileCategory:"FileCategory",isAdminOnProof:"IsAdminOnProof",groupId:"GroupId",canReupload:"CanReupload",hasEditors:"HasEditors",groupName:"GroupName",role:"Role",canOthersEditComments:"FeatureEditComments",canAddCommentReplies:"FeatureCanAddCommentReplies",canHaveGeneralComments:"FeatureGeneralComments",canAddChecklist:"FeatureCanAddChecklist",hasDecisionsEnabled:"FeatureDecisions",hasColorSeparations:"HasColorSeparations",reference:"Reference",integrationReferences:(0,_transform.each)("IntegrationReferences",function(data){return(new _ProofIntegrationReference2.default).fromProofIntegrationReference(data)}),checklist:function checklist(data){return data.Checklist&&(new _ProofChecklist2.default).fromProofChecklist(data.Checklist)},isReferenceEnabled:"FeatureProofReference",source:"Source",owners:(0,_transform.each)("Owners",function(ownerData){return(new _User2.default).fromUser(ownerData)}),decisionSummary:(0,_transform.each)("Decisions",function(decisionsData){return(new _DecisionSummary2.default).fromDecisionSummary(decisionsData)}),tags:(0,_transform.each)("Tags",function(tag){return tag.Value}),teamId:"TeamId",isPublic:"IsPublic",canBePublic:"FeaturePublicProofs",usePreviousVersionDueDate:"FeatureUsePreviousVersionDueDate",canSendShareLink:"FeatureSendShareLink",publicProofKeyPair:function publicProofKeyPair(data){return data.PublicProofKeyPair&&{publicKeyPEM:data.PublicProofKeyPair.PublicKey,privateKeyPEM:data.PublicProofKeyPair.PrivateKey}},canSendMessageToOwners:"FeatureMessageToOwners",workflowMetrics:"WorkflowMetrics",commentVisibility:"CommentVisibility",canHaveCommentVisibility:"FeatureCommentVisibility"};var Proof=function(){function Proof(){_classCallCheck(this,Proof)}Proof.prototype.isUserAdminOfProofTeam=function isUserAdminOfProofTeam(user){return user.isAdmin&&this.teamId===user.teamId};Proof.prototype.getState=function getState(){var state=_ProofState2.default.ACTIVE;if(this.fileStatus===_FileStatus2.default.UPLOADING){state=_ProofState2.default.UPLOADING}else if(this.hasFileError()){state=_ProofState2.default.FILE_ERROR}else if(this.isProcessing()){state=_ProofState2.default.PROCESSING}else if(this.type===_ProofType2.default.BRIEF){switch(this.status){case _ProofStatus2.default.NEW:state=_ProofState2.default.SETUP_NEEDED;break;case _ProofStatus2.default.PROOFING:state=_ProofState2.default.BRIEFING;break;case _ProofStatus2.default.AWAITING_NEW_VERSION:state=_ProofState2.default.AWAITING_PROOF;break;case _ProofStatus2.default.HAS_NEW_VERSION:state=_ProofState2.default.HAS_NEW_VERSION;break;case _ProofStatus2.default.ARCHIVED:state=_ProofState2.default.ARCHIVED;break}}else if(this.status===_ProofStatus2.default.ARCHIVED){state=_ProofState2.default.ARCHIVED}else if(this.status===_ProofStatus2.default.TODOS_REQUESTED){state=_ProofState2.default.TODOS_REQUESTED}else if(this.status===_ProofStatus2.default.AWAITING_NEW_VERSION){state=_ProofState2.default.AWAITING_NEW_VERSION}else if(this.status===_ProofStatus2.default.HAS_NEW_VERSION){state=_ProofState2.default.HAS_NEW_VERSION}else if(this.status===_ProofStatus2.default.APPROVED){state=_ProofState2.default.APPROVED}else if(!this.hasWorkflow()){state=_ProofState2.default.PROOFERS_NEEDED}else if(!this.hasWorkflowStarted()){state=_ProofState2.default.NOT_STARTED}else if(this.isOverdue){state=_ProofState2.default.OVERDUE}return state};Proof.prototype.getVideoProcessingProgress=function getVideoProcessingProgress(){var percent=0;var message=String(this.fileMessage);if(message){var thumbMatch=/^Thumb-\w+\-([-+]?[0-9]*\.?[0-9]*)/g.exec(message);var videoMatch=/^Video-\w+\-([-+]?[0-9]*\.?[0-9]*)/g.exec(message);if(message.startsWith("Video-Scheduled-")){percent=0}else if(videoMatch){percent=(0,_getPercentage2.default)(parseFloat(videoMatch[1])/100,0,.2)}else if(thumbMatch){percent=(0,_getPercentage2.default)(parseFloat(thumbMatch[1])/100,.8,0)}}return percent};Proof.prototype.hasWorkflowStarted=function hasWorkflowStarted(){return this.hasWorkflow()&&this.status!==_ProofStatus2.default.NEW};Proof.prototype.isProcessing=function isProcessing(){return this.fileStatus===_FileStatus2.default.UPLOADING||this.fileStatus===_FileStatus2.default.QUEUED||this.fileStatus===_FileStatus2.default.RIPPING};Proof.prototype.isAwaitingFile=function isAwaitingFile(){return this.source&&this.fileStatus===_FileStatus2.default.CREATED};Proof.prototype.getProcessingProgress=function getProcessingProgress(){switch(this.fileStatus){case _FileStatus2.default.UPLOADING:return.1;case _FileStatus2.default.QUEUED:return.2;case _FileStatus2.default.RIPPING:if(this.fileCategory==="video"){return(0,_getPercentage2.default)(this.getVideoProcessingProgress(),.2,.1).toFixed(2)}return.6;default:return-1}};Proof.prototype.hasWorkflow=function hasWorkflow(){return(0,_id.isWorkflowId)(this.workflowId)};Proof.prototype.hasFile=function hasFile(){return(0,_id.isFileId)(this.fileId)};Proof.prototype.hasFileError=function hasFileError(){return this.fileStatus===_FileStatus2.default.ERROR||!this.fileStatus||!this.hasFile()};Proof.prototype.hasEditor=function hasEditor(){return(0,_id.isUserId)(this.editorUserId)};Proof.prototype.hasThumbnail=function hasThumbnail(){return this.fileStatus===_FileStatus2.default.OK};Proof.prototype.canUserUploadNewVersion=function canUserUploadNewVersion(userId){return this.getState()===_ProofState2.default.AWAITING_NEW_VERSION&&(this.isEditor(userId)||this.isOwner(userId))||this.getState()===_ProofState2.default.AWAITING_PROOF&&(this.isEditor(userId)||this.isRecipient(userId))};Proof.prototype.isOwner=function isOwner(userId){return this.ownerUserIds.indexOf(userId)!==-1};Proof.prototype.isEditor=function isEditor(userId){return this.editorUserIds.indexOf(userId)!==-1};Proof.prototype.isRecipient=function isRecipient(userId){return this.recipient===userId};Proof.prototype.calculateState=function calculateState(){this.state=this.getState()};Proof.prototype.fromProof=function fromProof(proofData){(0,_transform2.default)(this,proofSchema,proofData);this.calculateState();return this};return Proof}();exports.default=Proof;
|
|
1
|
+
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _ProofState=require("../enum/ProofState");var _ProofState2=_interopRequireDefault(_ProofState);var _ProofStatus=require("../enum/ProofStatus");var _ProofStatus2=_interopRequireDefault(_ProofStatus);var _ProofType=require("../enum/ProofType");var _ProofType2=_interopRequireDefault(_ProofType);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _id=require("../util/id");var _getPercentage=require("../util/getPercentage");var _getPercentage2=_interopRequireDefault(_getPercentage);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _DecisionSummary=require("./DecisionSummary");var _DecisionSummary2=_interopRequireDefault(_DecisionSummary);var _ProofIntegrationReference=require("./ProofIntegrationReference");var _ProofIntegrationReference2=_interopRequireDefault(_ProofIntegrationReference);var _ProofChecklist=require("./ProofChecklist");var _ProofChecklist2=_interopRequireDefault(_ProofChecklist);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function isOverdue(){return this.dueDate&&this.dueDate.getTime()<Date.now()}var proofSchema={id:"ProofId",name:"Title",status:"Status",workflowId:"WorkflowId",proofTemplateId:"ProofTemplateId",version:"Version",dueDate:(0,_transform.date)("DueDate"),createdDate:(0,_transform.date)("CreateDate"),approvedDate:(0,_transform.date)("ApprovedDate"),isLocked:"Locked",isArchived:"Closed",isOverdue:isOverdue,uploaderUserId:"UserId",ownerUserIds:"OwnerIds",editorUserId:"EditorId",editorUserIds:"EditorIds",lockerUserId:"ProofLockerId",messageToReviewers:"Description",messageToOwners:"OwnerMessage",messageToEditor:"EditorMessage",fileId:"FileId",fileExtension:"Extension",fileStatus:"FileStatus",fileMessage:"FileStatusMessage",fileSize:"FileSize",pageCount:(0,_transform.number)("Pages"),commentCount:(0,_transform.number)("ParentComments"),canDownload:(0,_transform.truthy)("DownloadOriginal"),type:"Type",processStatus:"ProcessStatus",recipient:"Recipient",recipientEmail:"RecipientEmail",todoCommentCount:(0,_transform.number)("CountTodoComments"),doneCommentCount:(0,_transform.number)("CountDoneComments"),fileCategory:"FileCategory",isAdminOnProof:"IsAdminOnProof",groupId:"GroupId",canReupload:"CanReupload",hasEditors:"HasEditors",groupName:"GroupName",role:"Role",canOthersEditComments:"FeatureEditComments",canAddCommentReplies:"FeatureCanAddCommentReplies",canHaveGeneralComments:"FeatureGeneralComments",canHavePrivateComments:"FeaturePrivateComments",canAddChecklist:"FeatureCanAddChecklist",hasDecisionsEnabled:"FeatureDecisions",hasColorSeparations:"HasColorSeparations",reference:"Reference",integrationReferences:(0,_transform.each)("IntegrationReferences",function(data){return(new _ProofIntegrationReference2.default).fromProofIntegrationReference(data)}),checklist:function checklist(data){return data.Checklist&&(new _ProofChecklist2.default).fromProofChecklist(data.Checklist)},isReferenceEnabled:"FeatureProofReference",source:"Source",owners:(0,_transform.each)("Owners",function(ownerData){return(new _User2.default).fromUser(ownerData)}),decisionSummary:(0,_transform.each)("Decisions",function(decisionsData){return(new _DecisionSummary2.default).fromDecisionSummary(decisionsData)}),tags:(0,_transform.each)("Tags",function(tag){return tag.Value}),teamId:"TeamId",isPublic:"IsPublic",canBePublic:"FeaturePublicProofs",usePreviousVersionDueDate:"FeatureUsePreviousVersionDueDate",canSendShareLink:"FeatureSendShareLink",publicProofKeyPair:function publicProofKeyPair(data){return data.PublicProofKeyPair&&{publicKeyPEM:data.PublicProofKeyPair.PublicKey,privateKeyPEM:data.PublicProofKeyPair.PrivateKey}},canSendMessageToOwners:"FeatureMessageToOwners",workflowMetrics:"WorkflowMetrics",commentVisibility:"CommentVisibility",canHaveCommentVisibility:"FeatureCommentVisibility"};var Proof=function(){function Proof(){_classCallCheck(this,Proof)}Proof.prototype.isUserAdminOfProofTeam=function isUserAdminOfProofTeam(user){return user.isAdmin&&this.teamId===user.teamId};Proof.prototype.getState=function getState(){var state=_ProofState2.default.ACTIVE;if(this.fileStatus===_FileStatus2.default.UPLOADING){state=_ProofState2.default.UPLOADING}else if(this.hasFileError()){state=_ProofState2.default.FILE_ERROR}else if(this.isProcessing()){state=_ProofState2.default.PROCESSING}else if(this.type===_ProofType2.default.BRIEF){switch(this.status){case _ProofStatus2.default.NEW:state=_ProofState2.default.SETUP_NEEDED;break;case _ProofStatus2.default.PROOFING:state=_ProofState2.default.BRIEFING;break;case _ProofStatus2.default.AWAITING_NEW_VERSION:state=_ProofState2.default.AWAITING_PROOF;break;case _ProofStatus2.default.HAS_NEW_VERSION:state=_ProofState2.default.HAS_NEW_VERSION;break;case _ProofStatus2.default.ARCHIVED:state=_ProofState2.default.ARCHIVED;break}}else if(this.status===_ProofStatus2.default.ARCHIVED){state=_ProofState2.default.ARCHIVED}else if(this.status===_ProofStatus2.default.TODOS_REQUESTED){state=_ProofState2.default.TODOS_REQUESTED}else if(this.status===_ProofStatus2.default.AWAITING_NEW_VERSION){state=_ProofState2.default.AWAITING_NEW_VERSION}else if(this.status===_ProofStatus2.default.HAS_NEW_VERSION){state=_ProofState2.default.HAS_NEW_VERSION}else if(this.status===_ProofStatus2.default.APPROVED){state=_ProofState2.default.APPROVED}else if(!this.hasWorkflow()){state=_ProofState2.default.PROOFERS_NEEDED}else if(!this.hasWorkflowStarted()){state=_ProofState2.default.NOT_STARTED}else if(this.isOverdue){state=_ProofState2.default.OVERDUE}return state};Proof.prototype.getVideoProcessingProgress=function getVideoProcessingProgress(){var percent=0;var message=String(this.fileMessage);if(message){var thumbMatch=/^Thumb-\w+\-([-+]?[0-9]*\.?[0-9]*)/g.exec(message);var videoMatch=/^Video-\w+\-([-+]?[0-9]*\.?[0-9]*)/g.exec(message);if(message.startsWith("Video-Scheduled-")){percent=0}else if(videoMatch){percent=(0,_getPercentage2.default)(parseFloat(videoMatch[1])/100,0,.2)}else if(thumbMatch){percent=(0,_getPercentage2.default)(parseFloat(thumbMatch[1])/100,.8,0)}}return percent};Proof.prototype.hasWorkflowStarted=function hasWorkflowStarted(){return this.hasWorkflow()&&this.status!==_ProofStatus2.default.NEW};Proof.prototype.isProcessing=function isProcessing(){return this.fileStatus===_FileStatus2.default.UPLOADING||this.fileStatus===_FileStatus2.default.QUEUED||this.fileStatus===_FileStatus2.default.RIPPING};Proof.prototype.isAwaitingFile=function isAwaitingFile(){return this.source&&this.fileStatus===_FileStatus2.default.CREATED};Proof.prototype.getProcessingProgress=function getProcessingProgress(){switch(this.fileStatus){case _FileStatus2.default.UPLOADING:return.1;case _FileStatus2.default.QUEUED:return.2;case _FileStatus2.default.RIPPING:if(this.fileCategory==="video"){return(0,_getPercentage2.default)(this.getVideoProcessingProgress(),.2,.1).toFixed(2)}return.6;default:return-1}};Proof.prototype.hasWorkflow=function hasWorkflow(){return(0,_id.isWorkflowId)(this.workflowId)};Proof.prototype.hasFile=function hasFile(){return(0,_id.isFileId)(this.fileId)};Proof.prototype.hasFileError=function hasFileError(){return this.fileStatus===_FileStatus2.default.ERROR||!this.fileStatus||!this.hasFile()};Proof.prototype.hasEditor=function hasEditor(){return(0,_id.isUserId)(this.editorUserId)};Proof.prototype.hasThumbnail=function hasThumbnail(){return this.fileStatus===_FileStatus2.default.OK};Proof.prototype.canUserUploadNewVersion=function canUserUploadNewVersion(userId){return this.getState()===_ProofState2.default.AWAITING_NEW_VERSION&&(this.isEditor(userId)||this.isOwner(userId))||this.getState()===_ProofState2.default.AWAITING_PROOF&&(this.isEditor(userId)||this.isRecipient(userId))};Proof.prototype.isOwner=function isOwner(userId){return this.ownerUserIds.indexOf(userId)!==-1};Proof.prototype.isEditor=function isEditor(userId){return this.editorUserIds.indexOf(userId)!==-1};Proof.prototype.isRecipient=function isRecipient(userId){return this.recipient===userId};Proof.prototype.calculateState=function calculateState(){this.state=this.getState()};Proof.prototype.fromProof=function fromProof(proofData){(0,_transform2.default)(this,proofSchema,proofData);this.calculateState();return this};return Proof}();exports.default=Proof;
|
|
@@ -37,6 +37,14 @@ declare class WorkflowStep {
|
|
|
37
37
|
* @type {Date|undefined}
|
|
38
38
|
*/
|
|
39
39
|
dueDate: Date | undefined;
|
|
40
|
+
/**
|
|
41
|
+
* The date that the step became visible.
|
|
42
|
+
*/
|
|
43
|
+
visibleDate: any;
|
|
44
|
+
/**
|
|
45
|
+
* The date that the step was completed.
|
|
46
|
+
*/
|
|
47
|
+
completeDate: any;
|
|
40
48
|
/**
|
|
41
49
|
* The number of the mandatory approvers, a step should be approved by, before moving to the next step.
|
|
42
50
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _WorkflowUser=require("./WorkflowUser");var _WorkflowUser2=_interopRequireDefault(_WorkflowUser);var _WorkflowStepState=require("../enum/WorkflowStepState");var _WorkflowStepState2=_interopRequireDefault(_WorkflowStepState);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var workflowStepSchema={id:"StepId",name:"Title",position:(0,_transform.number)("Position"),dueDate:(0,_transform.date)("DueDate"),mandatoryDecisionThreshold:"MandatoryDecisionThreshold",state:function state(stepData){if(stepData.Complete){return _WorkflowStepState2.default.COMPLETE}else if(stepData.Visible){return _WorkflowStepState2.default.VISIBLE}else{return _WorkflowStepState2.default.NOT_VISIBLE}},users:(0,_transform.each)("Users",function(userData,stepData){var user=(new _WorkflowUser2.default).fromWorkflowUser(userData);user._calculateState(userData,stepData);return user})};var WorkflowStep=function(){function WorkflowStep(){_classCallCheck(this,WorkflowStep)}WorkflowStep.prototype.fromWorkflowStep=function fromWorkflowStep(workflowStepData){(0,_transform2.default)(this,workflowStepSchema,workflowStepData);return this};return WorkflowStep}();exports.default=WorkflowStep;
|
|
1
|
+
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _WorkflowUser=require("./WorkflowUser");var _WorkflowUser2=_interopRequireDefault(_WorkflowUser);var _WorkflowStepState=require("../enum/WorkflowStepState");var _WorkflowStepState2=_interopRequireDefault(_WorkflowStepState);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var workflowStepSchema={id:"StepId",name:"Title",position:(0,_transform.number)("Position"),dueDate:(0,_transform.date)("DueDate"),visibleDate:(0,_transform.date)("VisibleDate"),completeDate:(0,_transform.date)("CompleteDate"),mandatoryDecisionThreshold:"MandatoryDecisionThreshold",state:function state(stepData){if(stepData.Complete){return _WorkflowStepState2.default.COMPLETE}else if(stepData.Visible){return _WorkflowStepState2.default.VISIBLE}else{return _WorkflowStepState2.default.NOT_VISIBLE}},users:(0,_transform.each)("Users",function(userData,stepData){var user=(new _WorkflowUser2.default).fromWorkflowUser(userData);user._calculateState(userData,stepData);return user})};var WorkflowStep=function(){function WorkflowStep(){_classCallCheck(this,WorkflowStep)}WorkflowStep.prototype.fromWorkflowStep=function fromWorkflowStep(workflowStepData){(0,_transform2.default)(this,workflowStepSchema,workflowStepData);return this};return WorkflowStep}();exports.default=WorkflowStep;
|
|
@@ -20,6 +20,12 @@ declare class WorkflowUser extends User {
|
|
|
20
20
|
* @type {WorkflowUserRole}
|
|
21
21
|
*/
|
|
22
22
|
role: WorkflowUserRole;
|
|
23
|
+
/**
|
|
24
|
+
* The date the user first viewed the proof the workflow is attached to.
|
|
25
|
+
*
|
|
26
|
+
* @type {Date | undefined}
|
|
27
|
+
*/
|
|
28
|
+
firstViewedDate: Date | undefined;
|
|
23
29
|
/**
|
|
24
30
|
* The date the user was most recently nudged in this step
|
|
25
31
|
*
|
|
@@ -29,9 +35,15 @@ declare class WorkflowUser extends User {
|
|
|
29
35
|
/**
|
|
30
36
|
* The date the reviewer left their decision.
|
|
31
37
|
*
|
|
32
|
-
* @type {Date}
|
|
38
|
+
* @type {Date | undefined}
|
|
39
|
+
*/
|
|
40
|
+
decisionDate: Date | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* The ID of the decision.
|
|
43
|
+
*
|
|
44
|
+
* @type {number}
|
|
33
45
|
*/
|
|
34
|
-
|
|
46
|
+
decisionId: number;
|
|
35
47
|
/**
|
|
36
48
|
* The current state of the user in the {@link WorkflowStep}.
|
|
37
49
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _User2=require("./User");var _User3=_interopRequireDefault(_User2);var _WorkflowUserState=require("../enum/WorkflowUserState");var _WorkflowUserState2=_interopRequireDefault(_WorkflowUserState);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var workflowUserSchema={id:"UserId",name:"Name",email:"Email",role:"Role",permissions:function permissions(userData){return{inviter:userData.IsInviter}},nudgedDate:(0,_transform.date)("NudgedInStep"),decisionDate:(0,_transform.date)("DecisionDate")};var WorkflowUser=function(_User){_inherits(WorkflowUser,_User);function WorkflowUser(){_classCallCheck(this,WorkflowUser);return _possibleConstructorReturn(this,_User.apply(this,arguments))}WorkflowUser.prototype._calculateState=function _calculateState(userData,workflowStepData){if(userData.SkippedInStep){this.state=_WorkflowUserState2.default.SKIPPED}else if(userData.CompleteInStep){this.state=_WorkflowUserState2.default.FINISHED}else if(userData.ViewedInStep){this.state=_WorkflowUserState2.default.SEEN}else if(workflowStepData.Visible){this.state=_WorkflowUserState2.default.VISIBLE}else{this.state=_WorkflowUserState2.default.NOT_VISIBLE}};WorkflowUser.prototype.fromWorkflowUser=function fromWorkflowUser(workflowUserData){this._calculateState({},{});(0,_transform2.default)(this,workflowUserSchema,workflowUserData);return this};return WorkflowUser}(_User3.default);exports.default=WorkflowUser;
|
|
1
|
+
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _User2=require("./User");var _User3=_interopRequireDefault(_User2);var _WorkflowUserState=require("../enum/WorkflowUserState");var _WorkflowUserState2=_interopRequireDefault(_WorkflowUserState);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function _possibleConstructorReturn(self,call){if(!self){throw new ReferenceError("this hasn't been initialised - super() hasn't been called")}return call&&(typeof call==="object"||typeof call==="function")?call:self}function _inherits(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)Object.setPrototypeOf?Object.setPrototypeOf(subClass,superClass):subClass.__proto__=superClass}var workflowUserSchema={id:"UserId",name:"Name",email:"Email",role:"Role",permissions:function permissions(userData){return{inviter:userData.IsInviter}},firstViewedDate:(0,_transform.date)("FirstViewedDate"),nudgedDate:(0,_transform.date)("NudgedInStep"),decisionDate:(0,_transform.date)("DecisionDate"),decisionId:"Decision"};var WorkflowUser=function(_User){_inherits(WorkflowUser,_User);function WorkflowUser(){_classCallCheck(this,WorkflowUser);return _possibleConstructorReturn(this,_User.apply(this,arguments))}WorkflowUser.prototype._calculateState=function _calculateState(userData,workflowStepData){if(userData.SkippedInStep){this.state=_WorkflowUserState2.default.SKIPPED}else if(userData.CompleteInStep){this.state=_WorkflowUserState2.default.FINISHED}else if(userData.ViewedInStep){this.state=_WorkflowUserState2.default.SEEN}else if(workflowStepData.Visible){this.state=_WorkflowUserState2.default.VISIBLE}else{this.state=_WorkflowUserState2.default.NOT_VISIBLE}};WorkflowUser.prototype.fromWorkflowUser=function fromWorkflowUser(workflowUserData){this._calculateState({},{});(0,_transform2.default)(this,workflowUserSchema,workflowUserData);return this};return WorkflowUser}(_User3.default);exports.default=WorkflowUser;
|
|
@@ -734,7 +734,7 @@
|
|
|
734
734
|
"version": 2,
|
|
735
735
|
"method": "POST",
|
|
736
736
|
"path": "/api/proofs/comment/create",
|
|
737
|
-
"body": ["proofId", "page", "envelope", "encryptedComment", "xy", "parent", "mentions", "metadata", "sourceMetadata", "creationToken", "change", "done", "boxFillImage", "boxFillType", "autoState"]
|
|
737
|
+
"body": ["proofId", "page", "envelope", "encryptedComment", "xy", "parent", "mentions", "metadata", "sourceMetadata", "creationToken", "change", "done", "boxFillImage", "boxFillType", "autoState", "private"]
|
|
738
738
|
},
|
|
739
739
|
"comments.delete": {
|
|
740
740
|
"method": "POST",
|