@pageproof/sdk-pr 383.0.1638413664742 → 384.0.1638160092292
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 +1 -90
- package/lib/api/Comments.d.ts +24 -73
- package/lib/api/Comments.js +1 -1
- package/lib/api/Workflows.d.ts +20 -0
- package/lib/api/Workflows.js +1 -1
- package/lib/models/Comment.d.ts +4 -33
- package/lib/models/Comment.js +1 -1
- package/lib/models/Pin.d.ts +43 -0
- package/lib/models/Pin.js +1 -0
- package/lib/models/PinFill.d.ts +16 -0
- package/lib/models/PinFill.js +1 -0
- package/lib/models/Workflow.d.ts +6 -0
- package/lib/models/Workflow.js +1 -1
- package/lib/models/index.d.ts +2 -1
- package/lib/models/index.js +1 -1
- package/lib/network/endpoints.json +10 -0
- package/lib/pageproof.js +1 -1
- package/lib/util/exports.d.ts +0 -6
- package/lib/util/exports.js +1 -1
- package/package.json +1 -1
- package/lib/types/Pin.d.ts +0 -33
- package/lib/types/Pin.js +0 -1
- package/lib/util/pins/parsePins.d.ts +0 -1
- package/lib/util/pins/parsePins.js +0 -78
- package/lib/util/pins/serializePins.d.ts +0 -1
- package/lib/util/pins/serializePins.js +0 -51
- package/lib/util/pins/utils.d.ts +0 -3
- package/lib/util/pins/utils.js +0 -18
package/CHANGELOG.md
CHANGED
|
@@ -1,96 +1,7 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
##
|
|
5
|
-
|
|
6
|
-
Released on the xxXX of December 2021.
|
|
7
|
-
|
|
8
|
-
This release introduces support for comments with multiple pins. This means it's now possible to create a comment that has more than one pin (previously the limit). Because of this, we've made some changes that you'll want to know about, to ensure your transition to this version (and subsequent versions) are as seamless as possible.
|
|
9
|
-
|
|
10
|
-
We've made the following improvements:
|
|
11
|
-
- Serialization of pin data has been improved to take up less overall storage.
|
|
12
|
-
- It's now possible to create a comment that does not have any pins. This functionality is not currently exposed to PageProof users - but is something we have ensured presents correctly within the app.
|
|
13
|
-
|
|
14
|
-
We've removed the following things:
|
|
15
|
-
- The `Pin` and `PinFill` models have been removed. The objects you get by accessing pin fields now return a plain JavaScript object instead of an instance of the `Pin` class. The fields on this object are no different than before - but if you were previously checking the prototype of these objects, these checks will now produce a false-negative.
|
|
16
|
-
|
|
17
|
-
We're pretty confident that this change should have little to no impact on your integration with PageProof. And if you currently use the SDK sidecar, absolutely no impact whatsoever. This is highly edge-case.
|
|
18
|
-
|
|
19
|
-
We've deprecated a few model properties:
|
|
20
|
-
- The `Comment` model
|
|
21
|
-
- The `pin` property has been replaced by the new `pins` property. This property is an array of pins attached to the comment. As mentioned above, the objects you get from this array is a plain JavaScript object - but contains all the same properties. Accessing the deprecated `pin` property will yield the first pin attached to the comment - for backwards compatibility reasons only. The `pin` property will be removed in a later release.
|
|
22
|
-
|
|
23
|
-
> Change any code like `comment.pin` to `comment.pins[0]`. Ideally, also change your code to have support for multiple pins (this change may be more complex than the example).
|
|
24
|
-
- The `mediaTime` property has been replaced by the `time` property on the pin object. This change means it's possible for video and auto proofs to have pins added at different times along the timeline. This is not currently something we support in PageProof, but is making way for that functionality to be implemented in the future. Accessing the deprecated `mediaTime` property will yield the first pin's time - for backwards compatibility reasons only. The `mediaTime` property will be removed in a later release.
|
|
25
|
-
|
|
26
|
-
> Change any code like `comment.mediaTime` to `comment.pins[0].time`. And again, ideally you'd also want to change your code to have support for multiple pins.
|
|
27
|
-
- The `mediaDuration` property has been replaced by the `duration` property on the pin object. This change has been made for the same reasons as the change to the `mediaTime` property (above). Accessing the deprecated `mediaDuration` property will yield the first pin's duration - for backwards compatibility reasons only. The `mediaDuration` property will be removed in a later release.
|
|
28
|
-
|
|
29
|
-
> Change any code like `comment.mediaDuration` to `comment.pins[0].duration`. And again, ideally you'd also want to change your code to have support for multiple pins.
|
|
30
|
-
|
|
31
|
-
We've deprecated a few API options:
|
|
32
|
-
- The `Comments.create()` method
|
|
33
|
-
- The `pin` option has been replaced by the new `pins` option. This property is array of pins to attach to the comment. Providing this option behaves exactly as it did in earlier versions of the SDK, but it is recommended you switch to using the `pins` option, as we plan on removing the `pin` option in the future.
|
|
34
|
-
- The `mediaTime` option has been replaced by the `time` property on the pin object(s). Providing this option automatically assigns the first pin with the `time` property - but we recommend that you switch to manually specifying the `time` property, as we plan on removing the `mediaTime` option in the future.
|
|
35
|
-
- The `mediaDuration` option has been replaced by the `duration` property on the pin object(s). Providing this option automatically assigns the first pin with the `duration` property - but we recommend that you switch to manually specifying the `duration` property, as we plan on removing the `mediaDuration` option in the future.
|
|
36
|
-
|
|
37
|
-
### TL;DR
|
|
38
|
-
|
|
39
|
-
Here are a couple of code snippets of code that you may have in your PageProof integration code. If you're in a rush - here's a quick example of the changes you'll want to make.
|
|
40
|
-
|
|
41
|
-
**Creating comments**
|
|
42
|
-
|
|
43
|
-
Before (deprecated):
|
|
44
|
-
```js
|
|
45
|
-
await client.comments.create({
|
|
46
|
-
proofId: 'PR4G1XDX6W4QC579',
|
|
47
|
-
raw: 'Hello World',
|
|
48
|
-
pin: {
|
|
49
|
-
x: 0.024566473,
|
|
50
|
-
y: 0.756634520,
|
|
51
|
-
},
|
|
52
|
-
mediaTime: 17.3605,
|
|
53
|
-
mediaDuration: 1.5,
|
|
54
|
-
});
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
After (recommended, and the way forward):
|
|
58
|
-
```js
|
|
59
|
-
await client.comments.create({
|
|
60
|
-
proofId: 'PR4G1XDX6W4QC579',
|
|
61
|
-
raw: 'Hello World',
|
|
62
|
-
pins: [
|
|
63
|
-
{
|
|
64
|
-
x: 0.024566473,
|
|
65
|
-
y: 0.756634520,
|
|
66
|
-
time: 17.3605,
|
|
67
|
-
duration: 1.5,
|
|
68
|
-
},
|
|
69
|
-
],
|
|
70
|
-
});
|
|
71
|
-
```
|
|
72
|
-
|
|
73
|
-
**Loading & accessing comment/pin info**
|
|
74
|
-
|
|
75
|
-
Before (deprecated):
|
|
76
|
-
```js
|
|
77
|
-
const comments = await client.comments.load('PR4G1XDX6W4QC579');
|
|
78
|
-
comments[0].pin.x === 0.024566473;
|
|
79
|
-
comments[0].pin.y === 0.756634520;
|
|
80
|
-
comments[0].mediaTime === 17.3605;
|
|
81
|
-
comments[0].mediaDuration === 1.5;
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
After (recommended, and the way forward):
|
|
85
|
-
```js
|
|
86
|
-
const comments = await client.comments.load('PR4G1XDX6W4QC579');
|
|
87
|
-
comments[0].pins[0].x === 0.024566473;
|
|
88
|
-
comments[0].pins[0].y === 0.756634520;
|
|
89
|
-
comments[0].pins[0].time === 17.3605;
|
|
90
|
-
comments[0].pins[0].duration === 1.5;
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
## 2.0.0-beta.277
|
|
4
|
+
## 2.0.0-beta.177
|
|
94
5
|
|
|
95
6
|
Released on the 28th of October 2021.
|
|
96
7
|
|
package/lib/api/Comments.d.ts
CHANGED
|
@@ -164,21 +164,6 @@ declare class Comments extends API {
|
|
|
164
164
|
* @returns {Promise<Array<Comment>>}
|
|
165
165
|
*/
|
|
166
166
|
load(_options: any): Promise<Comment[]>;
|
|
167
|
-
/**
|
|
168
|
-
* @typedef {object} CreateCommentOptions The options for creating a new comment
|
|
169
|
-
* @property {string} [raw] The comment text (plain text)
|
|
170
|
-
* @property {object} [tokens] The comment tokens (rich text)
|
|
171
|
-
* @property {string} [proofId] The proof ID the comment should be attached to
|
|
172
|
-
* @property {number} [pageNumber=1] For comments (not replies) - the page number the comment was placed on
|
|
173
|
-
* @property {Pin} [pin] For comments (not replies) - the comment's pin coordinates (deprecated: provide an array of pins instead)
|
|
174
|
-
* @property {Pin[]} [pins] For comments (not replies) - the comment's pin(s) coordinates
|
|
175
|
-
* @property {number} [mediaTime] For audio/video proofs - the time (in seconds) that the pin was placed (deprecated: set the time within the pin object)
|
|
176
|
-
* @property {number} [mediaDuration] For audio/video proofs - the duration (in seconds) that the pin spans (deprecated: set the duration within the pin object)
|
|
177
|
-
* @property {string} [parentCommentId] For replies - the parent comment ID
|
|
178
|
-
* @property {object} [metadata] For web proofs - additional metadata relating to the comment snapshot. It is recommended that you do not provide metadata through the SDK currently, as the format for the metadata is not documented (and is subject to change).
|
|
179
|
-
* @property {string} [state] For comments (not replies) - The state of the comment (currently only supports to-dos)
|
|
180
|
-
* @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)
|
|
181
|
-
*/
|
|
182
167
|
/**
|
|
183
168
|
* Creates a new comment (or reply).
|
|
184
169
|
*
|
|
@@ -199,12 +184,10 @@ declare class Comments extends API {
|
|
|
199
184
|
* await client.comments.create({
|
|
200
185
|
* proofId: 'PPTMHIVPYMB2XRTK',
|
|
201
186
|
* raw: 'Hello World!',
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* },
|
|
207
|
-
* ],
|
|
187
|
+
* pin: {
|
|
188
|
+
* x: 0, // add the pin to the center of the proof
|
|
189
|
+
* y: 0,
|
|
190
|
+
* },
|
|
208
191
|
* });
|
|
209
192
|
*
|
|
210
193
|
* @example <caption>Single retry logic</caption>
|
|
@@ -212,7 +195,7 @@ declare class Comments extends API {
|
|
|
212
195
|
* await client.comments.create({
|
|
213
196
|
* proofId: 'PPTMHIVPYMB2XRTK',
|
|
214
197
|
* raw: 'Hello World!',
|
|
215
|
-
*
|
|
198
|
+
* pin: { x: 0, y: 0 },
|
|
216
199
|
* creationToken: retryCreationToken,
|
|
217
200
|
* });
|
|
218
201
|
* }
|
|
@@ -232,59 +215,27 @@ declare class Comments extends API {
|
|
|
232
215
|
* }
|
|
233
216
|
*
|
|
234
217
|
* @since v2.0.0-beta.46
|
|
235
|
-
* @param {
|
|
218
|
+
* @param {Comment} comment
|
|
219
|
+
* @param {string} [comment.raw] The raw comment text (rich text is not supported)
|
|
220
|
+
* @param {object} [comment.tokens] The comment tokens (with rich-text support). If you are creating legacy-style comments (just plain text) then use the "raw" option. Please note that while PageProof will continue to support plain text comments for the foreseeable future, it's recommended that you use the new "tokenized" comments.
|
|
221
|
+
* @param {string} comment.proofId The proof id the comment should be attached to
|
|
222
|
+
* @param {number} [comment.pageNumber=1] For comments (not replies) - the page number the comment should be attached to
|
|
223
|
+
* @param {Pin} [comment.pin] For comments (not replies) - the comment's pin coordinates
|
|
224
|
+
* @param {number} [comment.pin.x] The pin's x coordinate
|
|
225
|
+
* @param {number} [comment.pin.y] The pin's y coordinate
|
|
226
|
+
* @param {number} [comment.pin.x2] For boxes or lines - the pin's x2 coordinate
|
|
227
|
+
* @param {number} [comment.pin.y2] For boxes or lines - the pin's y2 coordinate
|
|
228
|
+
* @param {string} [comment.pin.fill.image] For pin fill images - the pin's fill image if pin is different then a dot or box type (like draw or text)
|
|
229
|
+
* @param {string} [comment.pin.fill.type] For pin fill images - the pin's fill image type
|
|
230
|
+
* @param {number} [comment.mediaTime] For video & audio - the start time
|
|
231
|
+
* @param {number} [comment.mediaDuration] For video & audio - the duration
|
|
232
|
+
* @param {string} [comment.parentCommentId] For replies - the parent comment id
|
|
233
|
+
* @param {object} [comment.metadata] For web proofs - additional metadata relating to the comment snapshot. It is recommended that you do not provide metadata through the SDK currently, as the format for the metadata is not documented (and is subject to change).
|
|
234
|
+
* @param {CommentState} [comment.state] For comments (not replies) - The state of the comment (currently only supports to-dos)
|
|
235
|
+
* @param {string} [comment.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)
|
|
236
236
|
* @returns {Promise<Comment>}
|
|
237
237
|
*/
|
|
238
|
-
create({ raw, tokens, proofId, pageNumber, pin,
|
|
239
|
-
/**
|
|
240
|
-
* The comment text (plain text)
|
|
241
|
-
*/
|
|
242
|
-
raw?: string;
|
|
243
|
-
/**
|
|
244
|
-
* The comment tokens (rich text)
|
|
245
|
-
*/
|
|
246
|
-
tokens?: any;
|
|
247
|
-
/**
|
|
248
|
-
* The proof ID the comment should be attached to
|
|
249
|
-
*/
|
|
250
|
-
proofId?: string;
|
|
251
|
-
/**
|
|
252
|
-
* For comments (not replies) - the page number the comment was placed on
|
|
253
|
-
*/
|
|
254
|
-
pageNumber?: number;
|
|
255
|
-
/**
|
|
256
|
-
* For comments (not replies) - the comment's pin coordinates (deprecated: provide an array of pins instead)
|
|
257
|
-
*/
|
|
258
|
-
pin?: Pin;
|
|
259
|
-
/**
|
|
260
|
-
* For comments (not replies) - the comment's pin(s) coordinates
|
|
261
|
-
*/
|
|
262
|
-
pins?: Pin[];
|
|
263
|
-
/**
|
|
264
|
-
* For audio/video proofs - the time (in seconds) that the pin was placed (deprecated: set the time within the pin object)
|
|
265
|
-
*/
|
|
266
|
-
mediaTime?: number;
|
|
267
|
-
/**
|
|
268
|
-
* For audio/video proofs - the duration (in seconds) that the pin spans (deprecated: set the duration within the pin object)
|
|
269
|
-
*/
|
|
270
|
-
mediaDuration?: number;
|
|
271
|
-
/**
|
|
272
|
-
* For replies - the parent comment ID
|
|
273
|
-
*/
|
|
274
|
-
parentCommentId?: string;
|
|
275
|
-
/**
|
|
276
|
-
* For web proofs - additional metadata relating to the comment snapshot. It is recommended that you do not provide metadata through the SDK currently, as the format for the metadata is not documented (and is subject to change).
|
|
277
|
-
*/
|
|
278
|
-
metadata?: any;
|
|
279
|
-
/**
|
|
280
|
-
* For comments (not replies) - The state of the comment (currently only supports to-dos)
|
|
281
|
-
*/
|
|
282
|
-
state?: string;
|
|
283
|
-
/**
|
|
284
|
-
* Only required if you're retrying (token can be extracted from the error object which is resolved (rejected, in this case) from the Promise)
|
|
285
|
-
*/
|
|
286
|
-
creationToken?: string;
|
|
287
|
-
}): Promise<Comment>;
|
|
238
|
+
create({ raw, tokens, proofId, pageNumber, pin, mediaTime, mediaDuration, parentCommentId, metadata, state, creationToken: retryCreationToken, }: Comment): Promise<Comment>;
|
|
288
239
|
}
|
|
289
240
|
import API from "./API";
|
|
290
241
|
import Comment from "../models/Comment";
|
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);
|
|
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);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(){_classCallCheck(this,Comments);return _possibleConstructorReturn(this,_API.apply(this,arguments))}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,mediaTime=_ref2.mediaTime,mediaDuration=_ref2.mediaDuration,parentCommentId=_ref2.parentCommentId,metadata=_ref2.metadata,state=_ref2.state,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 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:JSON.stringify({x:pin&&typeof pin.x==="number"?pin.x:null,y:pin&&typeof pin.y==="number"?pin.y:null,x2:pin&&typeof pin.x2==="number"?pin.x2:null,y2:pin&&typeof pin.y2==="number"?pin.y2:null,time:typeof mediaTime==="number"?mediaTime:null,duration:typeof mediaDuration==="number"?mediaDuration:null}),boxFillImage:pin.fill?pin.fill.image:undefined,boxFillType:pin.fill?pin.fill.type:undefined,parent:parentCommentId||undefined,mentions:mentions,metadata:metadata?JSON.stringify(metadata):"{}",creationToken:creationToken,change:state===_CommentState2.default.TODO?"1":undefined,done:state===_CommentState2.default.DONE?"1":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/api/Workflows.d.ts
CHANGED
|
@@ -392,6 +392,26 @@ declare class Workflows extends API {
|
|
|
392
392
|
* @returns {Promise<string|null>}
|
|
393
393
|
*/
|
|
394
394
|
getNudgeMessage(workflowId: string, userId: string): Promise<string>;
|
|
395
|
+
/**
|
|
396
|
+
* Set a workflow template as favorite.
|
|
397
|
+
*
|
|
398
|
+
* @example <caption>Set workflow template as favorite</caption>
|
|
399
|
+
* await client.workflows.favorite('W8VN0H4UYFVV1VQL');
|
|
400
|
+
*
|
|
401
|
+
* @param {string} workflowId The workflow id
|
|
402
|
+
* @returns {Promise}
|
|
403
|
+
*/
|
|
404
|
+
favorite(workflowId: string): Promise<any>;
|
|
405
|
+
/**
|
|
406
|
+
* Unfavorite a workflow template.
|
|
407
|
+
*
|
|
408
|
+
* @example <caption>Unfavorite a workflow template</caption>
|
|
409
|
+
* await client.workflows.unfavorite('W8VN0H4UYFVV1VQL');
|
|
410
|
+
*
|
|
411
|
+
* @param {string} workflowId The workflow id
|
|
412
|
+
* @returns {Promise}
|
|
413
|
+
*/
|
|
414
|
+
unfavorite(workflowId: string): Promise<any>;
|
|
395
415
|
/** @private */
|
|
396
416
|
_duplicateWorkflow(workflowId: any, options: any): any;
|
|
397
417
|
/** @private */
|
package/lib/api/Workflows.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Workflow=require("../models/Workflow");var _Workflow2=_interopRequireDefault(_Workflow);var _WorkflowStep=require("../models/WorkflowStep");var _WorkflowStep2=_interopRequireDefault(_WorkflowStep);var _WorkflowUser=require("../models/WorkflowUser");var _WorkflowUser2=_interopRequireDefault(_WorkflowUser);var _id=require("../util/id");var _WorkflowsSteps=require("./WorkflowsSteps");var _WorkflowsSteps2=_interopRequireDefault(_WorkflowsSteps);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 hasEnoughUserDetails(workflowUser){return workflowUser&&((0,_id.isUserId)(workflowUser.id)||workflowUser.email)}function transformWorkflows(workflows){return(workflows||[]).map(function(workflowData){return(new _Workflow2.default).fromWorkflow(workflowData)})}var Workflows=function(_API){_inherits(Workflows,_API);function Workflows(client){_classCallCheck(this,Workflows);var _this=_possibleConstructorReturn(this,_API.call(this,client));_this.steps=new _WorkflowsSteps2.default(client);return _this}Workflows.prototype.create=function create(_ref){var _this2=this;var _ref$save=_ref.save,save=_ref$save===undefined?false:_ref$save,name=_ref.name,_ref$steps=_ref.steps,_steps=_ref$steps===undefined?[]:_ref$steps,reviewers=_ref.reviewers,approver=_ref.approver,owners=_ref.owners,_ref$isOwnedByTeam=_ref.isOwnedByTeam,isOwnedByTeam=_ref$isOwnedByTeam===undefined?false:_ref$isOwnedByTeam;if(approver&&!hasEnoughUserDetails(approver)){return Promise.reject(Error("Please provide an approver id or email address."))}if(save&&!name){return Promise.reject(Error("A workflow must have a name when saving it as a workflow template."))}var steps=_steps;if(reviewers&&reviewers.length){steps.splice(0,0,{users:reviewers})}if(approver){steps.push({position:1e3,users:[approver],start:approver.start})}var largestPosition=0;for(var i=0;i<steps.length;i++){var step=steps[i];step.users=step.users||[];if(!step.position||step.position<largestPosition){step.position=largestPosition+1}largestPosition=Math.max(largestPosition,step.position);for(var ii=0;ii<step.users.length;ii++){var user=step.users[ii];if(!hasEnoughUserDetails(user)){return Promise.reject(Error("A user id or email address must be provided for a workflow user."))}}}var workflowId=void 0;return this._createWorkflow(name,isOwnedByTeam).then(function(workflow){workflowId=workflow.id;return Promise.all([workflow,Promise.all(steps.map(function(step){var workflowStep=workflow.getStepByPosition(step.position);return workflowStep?Promise.resolve(step.dueDate&&_this2.steps.update(workflowStep.id,{dueDate:step.dueDate}).then(function(updatedWorkflowStep){workflowStep.dueDate=updatedWorkflowStep.dueDate})).then(function(){return _this2._setWorkflowStepUsersMutate(workflow.id,workflowStep,step.users,step.start)}):_this2._addWorkflowStepAndUsers(workflow.id,step,step.start)})),owners&&Promise.all(owners.map(function(owner){return _this2._addProofOwnerToWorkflowTemplate(workflowId,owner)}))])}).then(function(_ref2){var workflow=_ref2[0],workflowSteps=_ref2[1];workflow.steps=workflowSteps;return workflow}).then(function(workflow){if(save){return _this2._duplicateWorkflow(workflowId)}return workflow}).catch(function(err){return Promise.resolve(workflowId&&_this2._deleteWorkflow(workflowId)).then(function(){return Promise.reject(err)})})};Workflows.prototype.load=function load(workflowId){return this.client.request("workflows.load",{workflowId:workflowId}).then(function(response){return(new _Workflow2.default).fromWorkflow(response.data)})};Workflows.prototype.use=function use(workflowId,options){return this.duplicate(workflowId,options)};Workflows.prototype.duplicate=function duplicate(workflowId,options){return this._duplicateWorkflow(workflowId,options)};Workflows.prototype.delete=function _delete(workflowId){return this._deleteWorkflow(workflowId)};Workflows.prototype.all=function all(){return Promise.all([this.owned(),this.shared()]).then(function(_ref3){var owned=_ref3[0],shared=_ref3[1];return[].concat(owned,shared)})};Workflows.prototype.owned=function owned(){return this.client.request("workflows.owned").then(function(response){return transformWorkflows(response.data)})};Workflows.prototype.shared=function shared(){return this.client.request("workflows.shared").then(function(response){return transformWorkflows(response.data)})};Workflows.prototype.setApprover=function setApprover(workflowId,user){return this.client.request("workflows.users.set",{workflowId:workflowId,position:1e3,users:[user]})};Workflows.prototype.skipAll=function skipAll(workflowId){return this.client.request("workflows.users.skip-all",{workflowId:workflowId})};Workflows.prototype.nudgeUser=function nudgeUser(workflowId,userId){var message=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return this.client.request("workflows.user.nudge",{workflowId:workflowId,userId:userId,message:message})};Workflows.prototype.nudgeAll=function nudgeAll(workflowId){var message=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;return this.client.request("workflows.nudge-all",{workflowId:workflowId,message:message})};Workflows.prototype.setStartingStep=function setStartingStep(workflowId,stepId){return this.client.request("workflows.set-starting-step",{workflowId:workflowId,stepId:stepId})};Workflows.prototype.replaceApprover=function replaceApprover(workflowIdOrIds,user){return this.client.request("workflows.replace-approver",{workflowIds:[].concat(workflowIdOrIds),user:user})};Workflows.prototype.update=function update(workflowId,_ref4){var name=_ref4.name,isOwnedByTeam=_ref4.isOwnedByTeam;return this.client.request("workflows.update",{workflowId:workflowId,title:name,ownedByTeam:isOwnedByTeam}).then(function(response){return(new _Workflow2.default).fromWorkflow(response.data)})};Workflows.prototype.getNudgeAllMessage=function getNudgeAllMessage(workflowId){return this.client.request("workflows.nudge-message",{workflowId:workflowId}).then(function(response){return response.data.Message})};Workflows.prototype.getNudgeMessage=function getNudgeMessage(workflowId,userId){return this.client.request("workflows.nudge-message",{workflowId:workflowId,userId:userId}).then(function(response){return response.data.Message})};Workflows.prototype._duplicateWorkflow=function _duplicateWorkflow(workflowId,options){var _this3=this;return this.client.request("workflows.duplicate",{workflowId:workflowId,noOwners:options&&options.includeOwners===false?true:undefined,excludeStepDueDates:options&&options.includeStepDueDates===false?true:undefined,includeOwnedByTeam:options&&options.includeOwnedByTeam===true||undefined,includeSharedUsers:options&&options.includeSharedUsers===true||undefined}).then(function(response){var duplicatedWorkflowId=response.data.WorkflowId;return _this3.load(duplicatedWorkflowId)})};Workflows.prototype._deleteWorkflow=function _deleteWorkflow(workflowId){return this.client.request("workflows.delete",{workflowId:workflowId})};Workflows.prototype._createWorkflow=function _createWorkflow(name,isOwnedByTeam){return this.client.request("workflows.create",{title:name,ownedByTeam:isOwnedByTeam}).then(function(response){return(new _Workflow2.default).fromWorkflow(response.data)})};Workflows.prototype._addWorkflowStepAndUsers=function _addWorkflowStepAndUsers(workflowId,step,start){var _this4=this;return this.client.request("workflows.steps.add",{workflowId:workflowId,title:step.name,position:step.position,dueDate:step.dueDate}).then(function(response){var workflowStep=(new _WorkflowStep2.default).fromWorkflowStep(response.data);return _this4._setWorkflowStepUsersMutate(workflowId,workflowStep,step.users,start)})};Workflows.prototype._setWorkflowStepUsersMutate=function _setWorkflowStepUsersMutate(workflowId,workflowStep,users,start){var _this5=this;return this.client.request("workflows.users.set",{workflowId:workflowId,stepId:workflowStep.id,users:users.map(function(user){return{email:user.email,userId:user.id,role:user.role,permissions:user.permissions&&{inviter:!!user.permissions.inviter}}})}).then(function(response){var workflowUsers=response.data.map(function(user){return(new _WorkflowUser2.default).fromWorkflowUser(user)});workflowStep.users=workflowUsers}).then(function(){if(start===true){return _this5.setStartingStep(workflowId,workflowStep.id).then(function(){return workflowStep})}return workflowStep})};Workflows.prototype._addProofOwnerToWorkflowTemplate=function _addProofOwnerToWorkflowTemplate(workflowId,user){return this.client.request("workflows.proof-owners.add",{relatedId:workflowId,workflowCopyToProof:1,userId:user.id,email:user.email})};return Workflows}(_API3.default);exports.default=Workflows;
|
|
1
|
+
"use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _Workflow=require("../models/Workflow");var _Workflow2=_interopRequireDefault(_Workflow);var _WorkflowStep=require("../models/WorkflowStep");var _WorkflowStep2=_interopRequireDefault(_WorkflowStep);var _WorkflowUser=require("../models/WorkflowUser");var _WorkflowUser2=_interopRequireDefault(_WorkflowUser);var _id=require("../util/id");var _WorkflowsSteps=require("./WorkflowsSteps");var _WorkflowsSteps2=_interopRequireDefault(_WorkflowsSteps);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 hasEnoughUserDetails(workflowUser){return workflowUser&&((0,_id.isUserId)(workflowUser.id)||workflowUser.email)}function transformWorkflows(workflows){return(workflows||[]).map(function(workflowData){return(new _Workflow2.default).fromWorkflow(workflowData)})}var Workflows=function(_API){_inherits(Workflows,_API);function Workflows(client){_classCallCheck(this,Workflows);var _this=_possibleConstructorReturn(this,_API.call(this,client));_this.steps=new _WorkflowsSteps2.default(client);return _this}Workflows.prototype.create=function create(_ref){var _this2=this;var _ref$save=_ref.save,save=_ref$save===undefined?false:_ref$save,name=_ref.name,_ref$steps=_ref.steps,_steps=_ref$steps===undefined?[]:_ref$steps,reviewers=_ref.reviewers,approver=_ref.approver,owners=_ref.owners,_ref$isOwnedByTeam=_ref.isOwnedByTeam,isOwnedByTeam=_ref$isOwnedByTeam===undefined?false:_ref$isOwnedByTeam;if(approver&&!hasEnoughUserDetails(approver)){return Promise.reject(Error("Please provide an approver id or email address."))}if(save&&!name){return Promise.reject(Error("A workflow must have a name when saving it as a workflow template."))}var steps=_steps;if(reviewers&&reviewers.length){steps.splice(0,0,{users:reviewers})}if(approver){steps.push({position:1e3,users:[approver],start:approver.start})}var largestPosition=0;for(var i=0;i<steps.length;i++){var step=steps[i];step.users=step.users||[];if(!step.position||step.position<largestPosition){step.position=largestPosition+1}largestPosition=Math.max(largestPosition,step.position);for(var ii=0;ii<step.users.length;ii++){var user=step.users[ii];if(!hasEnoughUserDetails(user)){return Promise.reject(Error("A user id or email address must be provided for a workflow user."))}}}var workflowId=void 0;return this._createWorkflow(name,isOwnedByTeam).then(function(workflow){workflowId=workflow.id;return Promise.all([workflow,Promise.all(steps.map(function(step){var workflowStep=workflow.getStepByPosition(step.position);return workflowStep?Promise.resolve(step.dueDate&&_this2.steps.update(workflowStep.id,{dueDate:step.dueDate}).then(function(updatedWorkflowStep){workflowStep.dueDate=updatedWorkflowStep.dueDate})).then(function(){return _this2._setWorkflowStepUsersMutate(workflow.id,workflowStep,step.users,step.start)}):_this2._addWorkflowStepAndUsers(workflow.id,step,step.start)})),owners&&Promise.all(owners.map(function(owner){return _this2._addProofOwnerToWorkflowTemplate(workflowId,owner)}))])}).then(function(_ref2){var workflow=_ref2[0],workflowSteps=_ref2[1];workflow.steps=workflowSteps;return workflow}).then(function(workflow){if(save){return _this2._duplicateWorkflow(workflowId)}return workflow}).catch(function(err){return Promise.resolve(workflowId&&_this2._deleteWorkflow(workflowId)).then(function(){return Promise.reject(err)})})};Workflows.prototype.load=function load(workflowId){return this.client.request("workflows.load",{workflowId:workflowId}).then(function(response){return(new _Workflow2.default).fromWorkflow(response.data)})};Workflows.prototype.use=function use(workflowId,options){return this.duplicate(workflowId,options)};Workflows.prototype.duplicate=function duplicate(workflowId,options){return this._duplicateWorkflow(workflowId,options)};Workflows.prototype.delete=function _delete(workflowId){return this._deleteWorkflow(workflowId)};Workflows.prototype.all=function all(){return Promise.all([this.owned(),this.shared()]).then(function(_ref3){var owned=_ref3[0],shared=_ref3[1];return[].concat(owned,shared)})};Workflows.prototype.owned=function owned(){return this.client.request("workflows.owned").then(function(response){return transformWorkflows(response.data)})};Workflows.prototype.shared=function shared(){return this.client.request("workflows.shared").then(function(response){return transformWorkflows(response.data)})};Workflows.prototype.setApprover=function setApprover(workflowId,user){return this.client.request("workflows.users.set",{workflowId:workflowId,position:1e3,users:[user]})};Workflows.prototype.skipAll=function skipAll(workflowId){return this.client.request("workflows.users.skip-all",{workflowId:workflowId})};Workflows.prototype.nudgeUser=function nudgeUser(workflowId,userId){var message=arguments.length>2&&arguments[2]!==undefined?arguments[2]:null;return this.client.request("workflows.user.nudge",{workflowId:workflowId,userId:userId,message:message})};Workflows.prototype.nudgeAll=function nudgeAll(workflowId){var message=arguments.length>1&&arguments[1]!==undefined?arguments[1]:null;return this.client.request("workflows.nudge-all",{workflowId:workflowId,message:message})};Workflows.prototype.setStartingStep=function setStartingStep(workflowId,stepId){return this.client.request("workflows.set-starting-step",{workflowId:workflowId,stepId:stepId})};Workflows.prototype.replaceApprover=function replaceApprover(workflowIdOrIds,user){return this.client.request("workflows.replace-approver",{workflowIds:[].concat(workflowIdOrIds),user:user})};Workflows.prototype.update=function update(workflowId,_ref4){var name=_ref4.name,isOwnedByTeam=_ref4.isOwnedByTeam;return this.client.request("workflows.update",{workflowId:workflowId,title:name,ownedByTeam:isOwnedByTeam}).then(function(response){return(new _Workflow2.default).fromWorkflow(response.data)})};Workflows.prototype.getNudgeAllMessage=function getNudgeAllMessage(workflowId){return this.client.request("workflows.nudge-message",{workflowId:workflowId}).then(function(response){return response.data.Message})};Workflows.prototype.getNudgeMessage=function getNudgeMessage(workflowId,userId){return this.client.request("workflows.nudge-message",{workflowId:workflowId,userId:userId}).then(function(response){return response.data.Message})};Workflows.prototype.favorite=function favorite(workflowId){return this.client.request("workflows.favorite",{workflowId:workflowId})};Workflows.prototype.unfavorite=function unfavorite(workflowId){return this.client.request("workflows.unfavorite",{workflowId:workflowId})};Workflows.prototype._duplicateWorkflow=function _duplicateWorkflow(workflowId,options){var _this3=this;return this.client.request("workflows.duplicate",{workflowId:workflowId,noOwners:options&&options.includeOwners===false?true:undefined,excludeStepDueDates:options&&options.includeStepDueDates===false?true:undefined,includeOwnedByTeam:options&&options.includeOwnedByTeam===true||undefined,includeSharedUsers:options&&options.includeSharedUsers===true||undefined}).then(function(response){var duplicatedWorkflowId=response.data.WorkflowId;return _this3.load(duplicatedWorkflowId)})};Workflows.prototype._deleteWorkflow=function _deleteWorkflow(workflowId){return this.client.request("workflows.delete",{workflowId:workflowId})};Workflows.prototype._createWorkflow=function _createWorkflow(name,isOwnedByTeam){return this.client.request("workflows.create",{title:name,ownedByTeam:isOwnedByTeam}).then(function(response){return(new _Workflow2.default).fromWorkflow(response.data)})};Workflows.prototype._addWorkflowStepAndUsers=function _addWorkflowStepAndUsers(workflowId,step,start){var _this4=this;return this.client.request("workflows.steps.add",{workflowId:workflowId,title:step.name,position:step.position,dueDate:step.dueDate}).then(function(response){var workflowStep=(new _WorkflowStep2.default).fromWorkflowStep(response.data);return _this4._setWorkflowStepUsersMutate(workflowId,workflowStep,step.users,start)})};Workflows.prototype._setWorkflowStepUsersMutate=function _setWorkflowStepUsersMutate(workflowId,workflowStep,users,start){var _this5=this;return this.client.request("workflows.users.set",{workflowId:workflowId,stepId:workflowStep.id,users:users.map(function(user){return{email:user.email,userId:user.id,role:user.role,permissions:user.permissions&&{inviter:!!user.permissions.inviter}}})}).then(function(response){var workflowUsers=response.data.map(function(user){return(new _WorkflowUser2.default).fromWorkflowUser(user)});workflowStep.users=workflowUsers}).then(function(){if(start===true){return _this5.setStartingStep(workflowId,workflowStep.id).then(function(){return workflowStep})}return workflowStep})};Workflows.prototype._addProofOwnerToWorkflowTemplate=function _addProofOwnerToWorkflowTemplate(workflowId,user){return this.client.request("workflows.proof-owners.add",{relatedId:workflowId,workflowCopyToProof:1,userId:user.id,email:user.email})};return Workflows}(_API3.default);exports.default=Workflows;
|
package/lib/models/Comment.d.ts
CHANGED
|
@@ -17,37 +17,9 @@ declare class Comment {
|
|
|
17
17
|
*
|
|
18
18
|
* This field is null for replies, as replies do not have a location on the proof.
|
|
19
19
|
*
|
|
20
|
-
* @type {
|
|
21
|
-
*/
|
|
22
|
-
pin:
|
|
23
|
-
x: number;
|
|
24
|
-
y: number;
|
|
25
|
-
x2: number | null;
|
|
26
|
-
y2: number | null;
|
|
27
|
-
time: number | null;
|
|
28
|
-
duration: number | null;
|
|
29
|
-
fill: {
|
|
30
|
-
type: string;
|
|
31
|
-
image: string;
|
|
32
|
-
} | null;
|
|
33
|
-
} | null;
|
|
34
|
-
/**
|
|
35
|
-
* The pins associated with the comment (not replies).
|
|
36
|
-
*
|
|
37
|
-
* @type {{ x: number, y: number, x2: number | null, y2: number | null, time: number | null, duration: number | null, fill: { type: string, image: string } | null }[]}
|
|
38
|
-
*/
|
|
39
|
-
pins: {
|
|
40
|
-
x: number;
|
|
41
|
-
y: number;
|
|
42
|
-
x2: number | null;
|
|
43
|
-
y2: number | null;
|
|
44
|
-
time: number | null;
|
|
45
|
-
duration: number | null;
|
|
46
|
-
fill: {
|
|
47
|
-
type: string;
|
|
48
|
-
image: string;
|
|
49
|
-
} | null;
|
|
50
|
-
}[];
|
|
20
|
+
* @type {Pin}
|
|
21
|
+
*/
|
|
22
|
+
pin: Pin;
|
|
51
23
|
/**
|
|
52
24
|
* The user who created the comment.
|
|
53
25
|
*
|
|
@@ -153,7 +125,6 @@ declare class Comment {
|
|
|
153
125
|
*
|
|
154
126
|
* On all other kinds of proofs this field is set to `undefined`.
|
|
155
127
|
*
|
|
156
|
-
* @deprecated Please use the time property on the pin object. This property will be removed in a future release.
|
|
157
128
|
* @since v2.0.0-beta.37
|
|
158
129
|
* @type {number}
|
|
159
130
|
*/
|
|
@@ -163,7 +134,6 @@ declare class Comment {
|
|
|
163
134
|
*
|
|
164
135
|
* On all other kinds of proofs this field is set to `undefined`.
|
|
165
136
|
*
|
|
166
|
-
* @deprecated Please use the duration property on the pin object. This property will be removed in a future release.
|
|
167
137
|
* @since v2.0.0-beta.37
|
|
168
138
|
* @type {number}
|
|
169
139
|
*/
|
|
@@ -181,5 +151,6 @@ declare class Comment {
|
|
|
181
151
|
*/
|
|
182
152
|
fromRawComment(rawComment: string): Comment;
|
|
183
153
|
}
|
|
154
|
+
import Pin from "./Pin";
|
|
184
155
|
import User from "./User";
|
|
185
156
|
import File from "./File";
|
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);
|
|
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 _Pin=require("./Pin");var _Pin2=_interopRequireDefault(_Pin);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);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={__prepare:function __prepare(data){data._XY=_Pin2.default.parseValue(data.XY,data.BoxFillImage,data.BoxFillType)},id:"CommentId",proofId:"ProofId",pin:function pin(data){return(new _Pin2.default).fromPin(data._XY)},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(data){return data._XY.time==null?undefined:data._XY.time},mediaDuration:function mediaDuration(data){return data._XY.duration==null?undefined:data._XY.duration},createdDate:(0,_transform.date)("Timestamp"),updatedDate:(0,_transform.date)("Updated"),parentCommentId:(0,_transform.optional)("Parent"),metadata:(0,_transform.json)("Metadata",{}),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;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
export default Pin;
|
|
2
|
+
declare class Pin {
|
|
3
|
+
/**
|
|
4
|
+
* @private
|
|
5
|
+
* @param {string} pinValue
|
|
6
|
+
* @param {string} image The pin fill image
|
|
7
|
+
* @param {string} type The pin fill type (like text, draw)
|
|
8
|
+
*/
|
|
9
|
+
static parseValue(pinValue: string, image: string, type: string): {
|
|
10
|
+
x: any;
|
|
11
|
+
y: any;
|
|
12
|
+
x2: any;
|
|
13
|
+
y2: any;
|
|
14
|
+
time: any;
|
|
15
|
+
duration: any;
|
|
16
|
+
fill: any;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* @type {number}
|
|
20
|
+
*/
|
|
21
|
+
x: number;
|
|
22
|
+
/**
|
|
23
|
+
* @type {number}
|
|
24
|
+
*/
|
|
25
|
+
y: number;
|
|
26
|
+
/**
|
|
27
|
+
* @type {number}
|
|
28
|
+
*/
|
|
29
|
+
x2: number;
|
|
30
|
+
/**
|
|
31
|
+
* @type {number}
|
|
32
|
+
*/
|
|
33
|
+
y2: number;
|
|
34
|
+
/**
|
|
35
|
+
* @type {object}
|
|
36
|
+
*/
|
|
37
|
+
fill: object;
|
|
38
|
+
/**
|
|
39
|
+
* @private
|
|
40
|
+
* @param {object} pinData
|
|
41
|
+
*/
|
|
42
|
+
fromPin(pinData: any): Pin;
|
|
43
|
+
}
|
|
@@ -0,0 +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 _PinFill=require("./PinFill");var _PinFill2=_interopRequireDefault(_PinFill);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 pinSchema={x:"x",y:"y",x2:(0,_transform.optional)("x2"),y2:(0,_transform.optional)("y2"),fill:function fill(data){if(data.fill){return(new _PinFill2.default).fromPinFill(data.fill)}return null}};var Pin=function(){function Pin(){_classCallCheck(this,Pin)}Pin.prototype.fromPin=function fromPin(pinData){(0,_transform2.default)(this,pinSchema,pinData);return this};Pin.parseValue=function parseValue(pinValue,image,type){var obj={x:null,y:null,x2:null,y2:null,time:null,duration:null,fill:null};if(pinValue[0]==="{"){var json=JSON.parse(pinValue);obj=_extends({},obj,json)}else if(pinValue.indexOf(",")!==-1){var _pinValue$split=pinValue.split(","),x=_pinValue$split[0],y=_pinValue$split[1];obj.x=parseFloat(x);obj.y=parseFloat(y)}if(image&&type){obj.fill={type:type,image:image}}return obj};return Pin}();exports.default=Pin;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export default PinFill;
|
|
2
|
+
declare class PinFill {
|
|
3
|
+
/**
|
|
4
|
+
* @type {string}
|
|
5
|
+
*/
|
|
6
|
+
image: string;
|
|
7
|
+
/**
|
|
8
|
+
* @type {string}
|
|
9
|
+
*/
|
|
10
|
+
type: string;
|
|
11
|
+
/**
|
|
12
|
+
* @private
|
|
13
|
+
* @param {object} pinFillData
|
|
14
|
+
*/
|
|
15
|
+
fromPinFill(pinFillData: any): PinFill;
|
|
16
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);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 pinFillSchema={image:"image",type:"type"};var PinFill=function(){function PinFill(){_classCallCheck(this,PinFill)}PinFill.prototype.fromPinFill=function fromPinFill(pinFillData){(0,_transform2.default)(this,pinFillSchema,pinFillData);return this};return PinFill}();exports.default=PinFill;
|
package/lib/models/Workflow.d.ts
CHANGED
|
@@ -47,6 +47,12 @@ declare class Workflow {
|
|
|
47
47
|
* @type {string}
|
|
48
48
|
*/
|
|
49
49
|
startFrom: string;
|
|
50
|
+
/**
|
|
51
|
+
* Whether a workflow is favorite.
|
|
52
|
+
*
|
|
53
|
+
* @type {boolean}
|
|
54
|
+
*/
|
|
55
|
+
isFavorite: boolean;
|
|
50
56
|
/**
|
|
51
57
|
* Returns a {@link WorkflowStep} by it's position within the workflow.
|
|
52
58
|
*
|
package/lib/models/Workflow.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _WorkflowStep=require("./WorkflowStep");var _WorkflowStep2=_interopRequireDefault(_WorkflowStep);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 workflowSchema={id:"WorkflowId",name:"Title",isOwnedByTeam:"OwnedByTeam",teamId:"TeamId",ownerId:"UserId",startFrom:"StartFrom",steps:(0,_transform.each)("WorkflowSteps",function(stepData){return(new _WorkflowStep2.default).fromWorkflowStep(stepData)})};var Workflow=function(){function Workflow(){_classCallCheck(this,Workflow)}Workflow.prototype.getStepByPosition=function getStepByPosition(position){var length=this.steps.length;for(var i=0;i<length;i+=1){var step=this.steps[i];if(step.position===position){return step}}return null};Workflow.prototype.getOrderedSteps=function getOrderedSteps(){return this.steps.sort(function(a,b){if(a.position<b.position)return-1;if(a.position>b.position)return 1;return 0})};Workflow.prototype.getApproverStep=function getApproverStep(){return this.getStepByPosition(1e3)};Workflow.prototype.fromWorkflow=function fromWorkflow(workflowData){(0,_transform2.default)(this,workflowSchema,workflowData);return this};return Workflow}();exports.default=Workflow;
|
|
1
|
+
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _WorkflowStep=require("./WorkflowStep");var _WorkflowStep2=_interopRequireDefault(_WorkflowStep);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 workflowSchema={id:"WorkflowId",name:"Title",isOwnedByTeam:"OwnedByTeam",teamId:"TeamId",ownerId:"UserId",startFrom:"StartFrom",isFavorite:"IsFavorite",steps:(0,_transform.each)("WorkflowSteps",function(stepData){return(new _WorkflowStep2.default).fromWorkflowStep(stepData)})};var Workflow=function(){function Workflow(){_classCallCheck(this,Workflow)}Workflow.prototype.getStepByPosition=function getStepByPosition(position){var length=this.steps.length;for(var i=0;i<length;i+=1){var step=this.steps[i];if(step.position===position){return step}}return null};Workflow.prototype.getOrderedSteps=function getOrderedSteps(){return this.steps.sort(function(a,b){if(a.position<b.position)return-1;if(a.position>b.position)return 1;return 0})};Workflow.prototype.getApproverStep=function getApproverStep(){return this.getStepByPosition(1e3)};Workflow.prototype.fromWorkflow=function fromWorkflow(workflowData){(0,_transform2.default)(this,workflowSchema,workflowData);return this};return Workflow}();exports.default=Workflow;
|
package/lib/models/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import Comment from "./Comment";
|
|
2
2
|
import File from "./File";
|
|
3
|
+
import Pin from "./Pin";
|
|
3
4
|
import Proof from "./Proof";
|
|
4
5
|
import ProofGroup from "./ProofGroup";
|
|
5
6
|
import ProofVersion from "./ProofVersion";
|
|
@@ -8,4 +9,4 @@ import User from "./User";
|
|
|
8
9
|
import Workflow from "./Workflow";
|
|
9
10
|
import WorkflowStep from "./WorkflowStep";
|
|
10
11
|
import WorkflowUser from "./WorkflowUser";
|
|
11
|
-
export { Comment, File, Proof, ProofGroup, ProofVersion, Session, User, Workflow, WorkflowStep, WorkflowUser };
|
|
12
|
+
export { Comment, File, Pin, Proof, ProofGroup, ProofVersion, Session, User, Workflow, WorkflowStep, WorkflowUser };
|
package/lib/models/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;exports.WorkflowUser=exports.WorkflowStep=exports.Workflow=exports.User=exports.Session=exports.ProofVersion=exports.ProofGroup=exports.Proof=exports.File=exports.Comment=undefined;var _Comment=require("./Comment");var _Comment2=_interopRequireDefault(_Comment);var _File=require("./File");var _File2=_interopRequireDefault(_File);var _Proof=require("./Proof");var _Proof2=_interopRequireDefault(_Proof);var _ProofGroup=require("./ProofGroup");var _ProofGroup2=_interopRequireDefault(_ProofGroup);var _ProofVersion=require("./ProofVersion");var _ProofVersion2=_interopRequireDefault(_ProofVersion);var _Session=require("./Session");var _Session2=_interopRequireDefault(_Session);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _Workflow=require("./Workflow");var _Workflow2=_interopRequireDefault(_Workflow);var _WorkflowStep=require("./WorkflowStep");var _WorkflowStep2=_interopRequireDefault(_WorkflowStep);var _WorkflowUser=require("./WorkflowUser");var _WorkflowUser2=_interopRequireDefault(_WorkflowUser);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.Comment=_Comment2.default;exports.File=_File2.default;exports.Proof=_Proof2.default;exports.ProofGroup=_ProofGroup2.default;exports.ProofVersion=_ProofVersion2.default;exports.Session=_Session2.default;exports.User=_User2.default;exports.Workflow=_Workflow2.default;exports.WorkflowStep=_WorkflowStep2.default;exports.WorkflowUser=_WorkflowUser2.default;
|
|
1
|
+
"use strict";exports.__esModule=true;exports.WorkflowUser=exports.WorkflowStep=exports.Workflow=exports.User=exports.Session=exports.ProofVersion=exports.ProofGroup=exports.Proof=exports.Pin=exports.File=exports.Comment=undefined;var _Comment=require("./Comment");var _Comment2=_interopRequireDefault(_Comment);var _File=require("./File");var _File2=_interopRequireDefault(_File);var _Pin=require("./Pin");var _Pin2=_interopRequireDefault(_Pin);var _Proof=require("./Proof");var _Proof2=_interopRequireDefault(_Proof);var _ProofGroup=require("./ProofGroup");var _ProofGroup2=_interopRequireDefault(_ProofGroup);var _ProofVersion=require("./ProofVersion");var _ProofVersion2=_interopRequireDefault(_ProofVersion);var _Session=require("./Session");var _Session2=_interopRequireDefault(_Session);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _Workflow=require("./Workflow");var _Workflow2=_interopRequireDefault(_Workflow);var _WorkflowStep=require("./WorkflowStep");var _WorkflowStep2=_interopRequireDefault(_WorkflowStep);var _WorkflowUser=require("./WorkflowUser");var _WorkflowUser2=_interopRequireDefault(_WorkflowUser);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}exports.Comment=_Comment2.default;exports.File=_File2.default;exports.Pin=_Pin2.default;exports.Proof=_Proof2.default;exports.ProofGroup=_ProofGroup2.default;exports.ProofVersion=_ProofVersion2.default;exports.Session=_Session2.default;exports.User=_User2.default;exports.Workflow=_Workflow2.default;exports.WorkflowStep=_WorkflowStep2.default;exports.WorkflowUser=_WorkflowUser2.default;
|
|
@@ -571,6 +571,16 @@
|
|
|
571
571
|
"path": "/api/v2/workflows/create",
|
|
572
572
|
"body": ["title", "ownedByTeam"]
|
|
573
573
|
},
|
|
574
|
+
"workflows.favorite": {
|
|
575
|
+
"method": "POST",
|
|
576
|
+
"path": "/api/workflows/favorite",
|
|
577
|
+
"body": ["workflowId"]
|
|
578
|
+
},
|
|
579
|
+
"workflows.unfavorite": {
|
|
580
|
+
"method": "POST",
|
|
581
|
+
"path": "/api/workflows/unfavorite",
|
|
582
|
+
"body": ["workflowId"]
|
|
583
|
+
},
|
|
574
584
|
"workflows.update": {
|
|
575
585
|
"method": "POST",
|
|
576
586
|
"path": "/api/workflows/update",
|