@pageproof/sdk-pr 272.0.1607911885307 → 274.0.1600210974294

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +0 -105
  2. package/README.md +0 -13
  3. package/lib/adapters/AngularEnhancementAdapter.d.ts +0 -2
  4. package/lib/adapters/IEnhancementAdapter.d.ts +30 -129
  5. package/lib/adapters/IEnhancementAdapter.js +1 -1
  6. package/lib/angular-enhancement-adapter.js +1 -1
  7. package/lib/api/Files.d.ts +0 -1
  8. package/lib/api/Files.js +1 -1
  9. package/lib/api/Preferences.d.ts +1 -3
  10. package/lib/api/Profile.d.ts +0 -8
  11. package/lib/api/Profile.js +1 -1
  12. package/lib/api/Proofs.d.ts +1 -10
  13. package/lib/api/Proofs.js +1 -1
  14. package/lib/api/ProofsAssetsExtractedText.js +1 -1
  15. package/lib/api/ProofsCustomTools.d.ts +5 -6
  16. package/lib/api/ProofsGroups.d.ts +3 -4
  17. package/lib/api/ProofsGroups.js +1 -1
  18. package/lib/api/Workflows.d.ts +2 -24
  19. package/lib/api/Workflows.js +1 -1
  20. package/lib/api/admin/Team.d.ts +4 -18
  21. package/lib/api/admin/Team.js +4 -29
  22. package/lib/api/admin/TeamDashboard.d.ts +0 -8
  23. package/lib/api/admin/TeamDashboard.js +2 -19
  24. package/lib/api/admin/TeamFeatures.d.ts +0 -9
  25. package/lib/api/admin/TeamFeatures.js +1 -9
  26. package/lib/api/admin/TeamIntegrations.d.ts +10 -0
  27. package/lib/api/admin/{TeamWorkflows.js → TeamIntegrations.js} +16 -32
  28. package/lib/api/admin/TeamMondayDotCom.d.ts +15 -0
  29. package/lib/api/admin/{TeamCustomTools.js → TeamMondayDotCom.js} +18 -29
  30. package/lib/core/PageProof.d.ts +1 -8
  31. package/lib/core/PageProof.js +1 -1
  32. package/lib/enum/Preference.d.ts +1 -2
  33. package/lib/enum/Preference.js +1 -1
  34. package/lib/models/Proof.d.ts +1 -30
  35. package/lib/models/Proof.js +1 -1
  36. package/lib/models/ProofGroup.d.ts +8 -22
  37. package/lib/models/ProofGroup.js +1 -1
  38. package/lib/models/TeamCommentFeatures.d.ts +0 -7
  39. package/lib/models/TeamCommentFeatures.js +1 -1
  40. package/lib/models/TeamEmailFeatures.d.ts +1 -8
  41. package/lib/models/TeamEmailFeatures.js +1 -1
  42. package/lib/models/TeamFeatures.d.ts +0 -8
  43. package/lib/models/TeamFeatures.js +1 -1
  44. package/lib/models/User.d.ts +0 -7
  45. package/lib/models/User.js +1 -1
  46. package/lib/models/Workflow.d.ts +0 -21
  47. package/lib/models/Workflow.js +1 -1
  48. package/lib/network/Request.js +1 -1
  49. package/lib/network/endpoints.json +6 -88
  50. package/lib/pageproof.js +1 -1
  51. package/package.json +1 -1
  52. package/lib/api/Integrations.d.ts +0 -67
  53. package/lib/api/Integrations.js +0 -1
  54. package/lib/api/ProofsIntegrationReferences.d.ts +0 -42
  55. package/lib/api/ProofsIntegrationReferences.js +0 -1
  56. package/lib/api/ProofsLinkCheck.d.ts +0 -33
  57. package/lib/api/ProofsLinkCheck.js +0 -1
  58. package/lib/api/admin/TeamCustomTools.d.ts +0 -22
  59. package/lib/api/admin/TeamDashboardGroups.d.ts +0 -49
  60. package/lib/api/admin/TeamDashboardGroups.js +0 -112
  61. package/lib/api/admin/TeamWorkflows.d.ts +0 -19
  62. package/lib/models/ProofIntegrationReference.d.ts +0 -33
  63. package/lib/models/ProofIntegrationReference.js +0 -1
  64. package/lib/models/TeamAccountFeatures.d.ts +0 -26
  65. package/lib/models/TeamAccountFeatures.js +0 -1
  66. package/lib/types/LinkCheckLinkResult.d.ts +0 -22
  67. package/lib/types/LinkCheckLinkResult.js +0 -1
  68. package/lib/types/LinkCheckPageResult.d.ts +0 -18
  69. package/lib/types/LinkCheckPageResult.js +0 -1
  70. package/lib/types/LinkCheckPageSummary.d.ts +0 -18
  71. package/lib/types/LinkCheckPageSummary.js +0 -1
  72. package/lib/types/LinkCheckResults.d.ts +0 -15
  73. package/lib/types/LinkCheckResults.js +0 -1
package/CHANGELOG.md CHANGED
@@ -1,110 +1,5 @@
1
1
  # Changelog
2
2
 
3
- ## 2.0.0-beta.153
4
-
5
- Released on the 14th of December 2020.
6
-
7
- - [[#272](https://github.com/PageProofCom/sdk/pull/272)] Team administrators can now load their team's groups - see [TeamDashboardGroups](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/admin/TeamDashboardGroups.js~TeamDashboardGroups.html).
8
- - The Proof model now contains the team ID, it belongs to ([Proof.teamId](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/models/Proof.js~Proof.html#instance-member-teamId)).
9
-
10
- ## 2.0.0-beta.152
11
-
12
- Released on the 11th of December 2020.
13
-
14
- - [[#294](https://github.com/PageProofCom/sdk/pull/294)]
15
- - Support for allowing to disabling replies on comments (by reviewers) in statuses. See [TeamCommentFeatures.disableReplyingToCommentsInStatuses](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/models/TeamCommentFeatures.js~TeamCommentFeatures.html#instance-member-disableReplyingToCommentsInStatuses).
16
- - Added `canAddCommentReplies` to proof model, to tell if replies are disabled on comments (by reviewers). See [Proofs.canAddCommentReplies](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/models/Proof.js~Proof.html#instance-member-canAddCommentReplies).
17
-
18
- ## 2.0.0-beta.151
19
-
20
- Released on the 11th of December 2020.
21
-
22
- - Minor improvement around user preferences reset method.
23
-
24
- ## 2.0.0-beta.150
25
-
26
- Released on the 8th of December 2020.
27
-
28
- - [[#296](https://github.com/PageProofCom/sdk/pull/296)] Adds support for colors user preferences. See [Preferences](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/Preferences.js~Preferences.html).
29
-
30
- ## 2.0.0-beta.149
31
-
32
- Released on the 24th of November 2020.
33
-
34
- - [[#239](https://github.com/PageProofCom/sdk/pull/239)] Adds support for a `onFileDetails` callback option when uploading files. See [Files.upload](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/Files.js~Files.html#instance-method-upload).
35
-
36
- ## 2.0.0-beta.148
37
-
38
- Released on the 24th of November 2020.
39
-
40
- - [[#289](https://github.com/PageProofCom/sdk/pull/289)] Adds support for default reminder user preferences. See [Preferences](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/Preferences.js~Preferences.html).
41
- - Adds support for updating the configuration of integrations.
42
-
43
- ## 2.0.0-beta.147
44
-
45
- Released on the 23rd of November 2020.
46
-
47
- - Allowed including parameters when retrieving options for proof integration references.
48
-
49
- ## 2.0.0-beta.146
50
-
51
- Released on the 20th of November 2020.
52
-
53
- - Improved support for the enhancement adapter interface.
54
-
55
- ## 2.0.0-beta.145
56
-
57
- Released on the 2nd of November 2020.
58
-
59
- - [[#279](https://github.com/PageProofCom/sdk/pull/279)] Added Support for sharing a workflow template with team. See [Workflows.create](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/Workflows.js~Workflows.html#instance-method-create) and [Workflows.update](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/Workflows.js~Workflows.html#instance-method-update).
60
- - Added support for team admin to get team owned workflow templates [TeamWorkflows.owned](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/admin/TeamWorkflows.js~TeamWorkflows.html#instance-method-owned).
61
-
62
- ## 2.0.0-beta.144
63
-
64
- Released on the 30th of October 2020.
65
-
66
- - Support for integration references.
67
-
68
- ## 2.0.0-beta.143
69
-
70
- Released on the 27th of October 2020.
71
-
72
- - [[#283](https://github.com/PageProofCom/sdk/pull/283)]
73
- - Support for updating whether using the team name should be used, instead of "PageProof Team" as the from name in emails. See [TeamEmailFeatures](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/models/TeamEmailFeatures.js~TeamEmailFeatures.html).
74
- - Support for team account information in team admin API. see [TeamAccountFeatures](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/models/TeamAccountFeatures.js~TeamAccountFeatures.html).
75
-
76
- ## 2.0.0-beta.142
77
-
78
- Released on the 22nd of October 2020.
79
-
80
- - Support for team-level custom tools.
81
-
82
- ## 2.0.0-beta.141
83
-
84
- Released on the 19th of October 2020.
85
-
86
- - [[#270](https://github.com/PageProofCom/sdk/pull/270)] Support for retrieving configurations for services integrated with PageProof.
87
-
88
-
89
- ## 2.0.0-beta.140
90
-
91
- Released on the 9th of October 2020.
92
-
93
- - Minor bug fixes related to extracted text.
94
-
95
- ## 2.0.0-beta.139
96
-
97
- Released on the 30th of September 2020.
98
-
99
- - [[#251](https://github.com/PageProofCom/sdk/pull/251)] Support for fetching results of link checking on email proofs and re-checking links. See [Proofs.linkCheck](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/ProofsLinkCheck.js~ProofsLinkCheck.html).
100
-
101
-
102
- ## 2.0.0-beta.138
103
-
104
- Released on the 18th of September 2020.
105
-
106
- - [[#274](https://github.com/PageProofCom/sdk/pull/274)] Support for sharing a group with team. See [ProofGroup.isOwnedByTeam](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/models/ProofGroup.js~ProofGroup.html#instance-member-isOwnedByTeam) [ProofsGroups.create](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/ProofsGroups.js~ProofsGroups.html#instance-method-create) [ProofsGroups.update](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/api/ProofsGroups.js~ProofsGroups.html#instance-method-update)
107
-
108
3
  ## 2.0.0-beta.137
109
4
 
110
5
  Released on the 10th of September 2020.
package/README.md CHANGED
@@ -376,16 +376,3 @@ refreshes, we need to remind the client what the current session is.
376
376
  [Session](./class/src/models/Session.js~Session.html) object contains the user's private keys.
377
377
  Sharing the private keys with anybody, directly or even indirectly (over unencrypted traffic, for example), gives
378
378
  anybody the ability to access & decrypt all proofs you have access to, including those you have been invited to.
379
-
380
- ### SDK development
381
- Local development:
382
- 1. Node version <= 6
383
- ```sh
384
- $ npm install
385
- $ npm run dev
386
- ```
387
- 2. To test the SDK locally: switch to node version >=12, then
388
- ```sh
389
- $ cd examples
390
- $ node ./basic-node/index.js
391
- ```
@@ -64,8 +64,6 @@ declare class AngularEnhancementAdapter extends IEnhancementAdapter {
64
64
  /** @private */
65
65
  $exceptionHandler: any;
66
66
  /** @private */
67
- onMethodFinally(): void;
68
- /** @private */
69
67
  onMethodReject({ rejected }: {
70
68
  rejected: any;
71
69
  }): void;
@@ -3,133 +3,34 @@ declare class IEnhancementAdapter {
3
3
  static __adapter__: string;
4
4
  /** @private */
5
5
  onClientReady(client: any): void;
6
- /**
7
- * Called before the method is enhanced.
8
- *
9
- * @abstract
10
- * @param {{ api: API, namespace: string, name: string, displayName: string }} ctx
11
- */
12
- onMethodEnhance(ctx: {
13
- api: any;
14
- namespace: string;
15
- name: string;
16
- displayName: string;
17
- }): void;
18
- /**
19
- * Called before the method is invoked.
20
- *
21
- * @abstract
22
- * @param {{ api: API, namespace: string, name: string, displayName: string }} ctx
23
- */
24
- onMethodBefore(ctx: {
25
- api: any;
26
- namespace: string;
27
- name: string;
28
- displayName: string;
29
- }): void;
30
- /**
31
- * Called after the method has been invoked.
32
- *
33
- * @abstract
34
- * @param {{ api: API, namespace: string, name: string, displayName: string }} ctx
35
- */
36
- onMethodAfter(ctx: {
37
- api: any;
38
- namespace: string;
39
- name: string;
40
- displayName: string;
41
- }): void;
42
- /**
43
- * Called if the method returns a rejected promise.
44
- *
45
- * @abstract
46
- * @param {{ api: API, namespace: string, name: string, displayName: string }} ctx
47
- */
48
- onMethodReject(ctx: {
49
- api: any;
50
- namespace: string;
51
- name: string;
52
- displayName: string;
53
- }): void;
54
- /**
55
- * Called if the method returns a resolved promise.
56
- *
57
- * @abstract
58
- * @param {{ api: API, namespace: string, name: string, displayName: string }} ctx
59
- */
60
- onMethodResolve(ctx: {
61
- api: any;
62
- namespace: string;
63
- name: string;
64
- displayName: string;
65
- }): void;
66
- /**
67
- * Called after the method's promise has either resolved or rejected.
68
- *
69
- * @abstract
70
- * @param {{ api: API, namespace: string, name: string, displayName: string }} ctx
71
- */
72
- onMethodFinally(ctx: {
73
- api: any;
74
- namespace: string;
75
- name: string;
76
- displayName: string;
77
- }): void;
78
- /**
79
- * Called if the method throws an error synchronously.
80
- *
81
- * @abstract
82
- * @param {{ api: API, namespace: string, name: string, displayName: string }} ctx
83
- */
84
- onMethodThrown(ctx: {
85
- api: any;
86
- namespace: string;
87
- name: string;
88
- displayName: string;
89
- }): void;
90
- /**
91
- * @abstract
92
- * @param {any} event
93
- */
94
- onRequestBefore(event: any): void;
95
- /**
96
- * @abstract
97
- * @param {any} event
98
- */
99
- onRequestAfter(event: any): void;
100
- /**
101
- * @abstract
102
- * @param {any} event
103
- */
104
- onRequestReject(event: any): void;
105
- /**
106
- * @abstract
107
- * @param {any} event
108
- */
109
- onRequestThrottled(event: any): void;
110
- /**
111
- * @abstract
112
- * @param {any} event
113
- */
114
- onRequestRetry(event: any): void;
115
- /**
116
- * @abstract
117
- * @param {any} event
118
- */
119
- onRequestUnauthorized(event: any): void;
120
- /**
121
- * @abstract
122
- * @param {any} event
123
- */
124
- onRequestDeprecated(event: any): void;
125
- /**
126
- * @abstract
127
- * @param {any} event
128
- */
129
- onRequestResolve(event: any): void;
130
- /**
131
- * @abstract
132
- * @param {any} event
133
- */
134
- onRequestFinally(event: any): void;
6
+ /** @abstract */
7
+ onMethodBefore(): void;
8
+ /** @abstract */
9
+ onMethodAfter(): void;
10
+ /** @abstract */
11
+ onMethodReject(): void;
12
+ /** @abstract */
13
+ onMethodResolve(): void;
14
+ /** @abstract */
15
+ onMethodFinally(): void;
16
+ /** @abstract */
17
+ onMethodThrown(): void;
18
+ /** @abstract */
19
+ onRequestBefore(): void;
20
+ /** @abstract */
21
+ onRequestAfter(): void;
22
+ /** @abstract */
23
+ onRequestReject(): void;
24
+ /** @abstract */
25
+ onRequestThrottled(): void;
26
+ /** @abstract */
27
+ onRequestRetry(): void;
28
+ /** @abstract */
29
+ onRequestUnauthorized(): void;
30
+ /** @private */
31
+ onRequestDeprecated(): void;
32
+ /** @abstract */
33
+ onRequestResolve(): void;
34
+ /** @abstract */
35
+ onRequestFinally(): void;
135
36
  }
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _class,_temp;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var IEnhancementAdapter=(_temp=_class=function(){function IEnhancementAdapter(){_classCallCheck(this,IEnhancementAdapter)}IEnhancementAdapter.prototype.onClientReady=function onClientReady(client){var _this=this;var methods=getNestedMethods(client);methods.forEach(function(definition){var ctx={api:definition.api,namespace:definition.namespace,name:definition.name,displayName:definition.namespace+"."+definition.name};_this.onMethodEnhance(ctx);enhance(definition.api,definition.name,function(callback){_this.onMethodBefore(ctx);return function(){var value=void 0;try{value=callback()}catch(err){ctx.error=err;_this.onMethodThrown(ctx);throw err}finally{ctx.value=value;_this.onMethodAfter(ctx);if(value&&typeof value.then==="function"){value.then(function(resolved){ctx.resolved=resolved;_this.onMethodResolve(ctx)},function(rejected){ctx.rejected=rejected;_this.onMethodReject(ctx)}).then(function(){_this.onMethodFinally(ctx)})}}return value}})});client.on("experimental.request.before",function(event){return _this.onRequestBefore(event.data)});client.on("experimental.request.after",function(event){return _this.onRequestAfter(event.data)});client.on("error.response",function(event){return _this.onRequestReject(event.data)});client.on("error.throttled",function(event){return _this.onRequestThrottled(event.data)});client.on("experimental.request.retry",function(event){return _this.onRequestRetry(event.data)});client.on("error.unauthorized",function(event){return _this.onRequestUnauthorized(event.data)});client.on("error.deprecated",function(event){return _this.onRequestDeprecated(event.data)});client.on("experimental.request.resolve",function(event){return _this.onRequestResolve(event.data)});client.on("experimental.request.finally",function(event){return _this.onRequestFinally(event.data)})};IEnhancementAdapter.prototype.onMethodEnhance=function onMethodEnhance(ctx){};IEnhancementAdapter.prototype.onMethodBefore=function onMethodBefore(ctx){};IEnhancementAdapter.prototype.onMethodAfter=function onMethodAfter(ctx){};IEnhancementAdapter.prototype.onMethodReject=function onMethodReject(ctx){};IEnhancementAdapter.prototype.onMethodResolve=function onMethodResolve(ctx){};IEnhancementAdapter.prototype.onMethodFinally=function onMethodFinally(ctx){};IEnhancementAdapter.prototype.onMethodThrown=function onMethodThrown(ctx){};IEnhancementAdapter.prototype.onRequestBefore=function onRequestBefore(event){};IEnhancementAdapter.prototype.onRequestAfter=function onRequestAfter(event){};IEnhancementAdapter.prototype.onRequestReject=function onRequestReject(event){};IEnhancementAdapter.prototype.onRequestThrottled=function onRequestThrottled(event){};IEnhancementAdapter.prototype.onRequestRetry=function onRequestRetry(event){};IEnhancementAdapter.prototype.onRequestUnauthorized=function onRequestUnauthorized(event){};IEnhancementAdapter.prototype.onRequestDeprecated=function onRequestDeprecated(event){};IEnhancementAdapter.prototype.onRequestResolve=function onRequestResolve(event){};IEnhancementAdapter.prototype.onRequestFinally=function onRequestFinally(event){};return IEnhancementAdapter}(),_class.__adapter__="IEnhancementAdapter",_temp);function enhance(obj,name,factory){var original=obj[name];obj[name]=function enhanced(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}var bound=original.bind.apply(original,[this].concat(args));var replacement=factory(bound,this,args);var value=replacement.apply(this,args);return value}}function getNestedMethods(client){var includeTop=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var definitions=[];function scan(api){var prefix=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var children=Object.getOwnPropertyNames(api).filter(function(name){return api[name].client===client});var proto=Object.getPrototypeOf(api);var methods=Object.keys(proto).filter(function(name){return typeof proto[name]==="function"&&name.indexOf("_")!==0});if(prefix.length||includeTop){var namespace=prefix.join(".");if(namespace.indexOf("__")===0){namespace=namespace.substring(2)}methods.forEach(function(name){definitions.push({namespace:namespace,name:name,api:api})})}children.forEach(function(name){scan(api[name],prefix.concat(name))})}scan(client);return definitions}exports.default=IEnhancementAdapter;
1
+ "use strict";exports.__esModule=true;var _class,_temp;function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}var IEnhancementAdapter=(_temp=_class=function(){function IEnhancementAdapter(){_classCallCheck(this,IEnhancementAdapter)}IEnhancementAdapter.prototype.onClientReady=function onClientReady(client){var _this=this;var methods=getNestedMethods(client);methods.forEach(function(definition){enhance(definition.api,definition.name,function(callback){var ctx={api:definition.api,namespace:definition.namespace,name:definition.name,displayName:definition.namespace+"."+definition.name};_this.onMethodBefore(ctx);return function(){var value=void 0;try{value=callback()}catch(err){ctx.error=err;_this.onMethodThrown(ctx);throw err}finally{ctx.value=value;_this.onMethodAfter(ctx);if(value&&typeof value.then==="function"){value.then(function(resolved){ctx.resolved=resolved;_this.onMethodResolve(ctx)},function(rejected){ctx.rejected=rejected;_this.onMethodReject(ctx)}).then(function(){_this.onMethodFinally(ctx)})}}return value}})});client.on("experimental.request.before",function(event){return _this.onRequestBefore(event.data)});client.on("experimental.request.after",function(event){return _this.onRequestAfter(event.data)});client.on("error.response",function(event){return _this.onRequestReject(event.data)});client.on("error.throttled",function(event){return _this.onRequestThrottled(event.data)});client.on("experimental.request.retry",function(event){return _this.onRequestRetry(event.data)});client.on("error.unauthorized",function(event){return _this.onRequestUnauthorized(event.data)});client.on("error.deprecated",function(event){return _this.onRequestDeprecated(event.data)});client.on("experimental.request.resolve",function(event){return _this.onRequestResolve(event.data)});client.on("experimental.request.finally",function(event){return _this.onRequestFinally(event.data)})};IEnhancementAdapter.prototype.onMethodBefore=function onMethodBefore(){};IEnhancementAdapter.prototype.onMethodAfter=function onMethodAfter(){};IEnhancementAdapter.prototype.onMethodReject=function onMethodReject(){};IEnhancementAdapter.prototype.onMethodResolve=function onMethodResolve(){};IEnhancementAdapter.prototype.onMethodFinally=function onMethodFinally(){};IEnhancementAdapter.prototype.onMethodThrown=function onMethodThrown(){};IEnhancementAdapter.prototype.onRequestBefore=function onRequestBefore(){};IEnhancementAdapter.prototype.onRequestAfter=function onRequestAfter(){};IEnhancementAdapter.prototype.onRequestReject=function onRequestReject(){};IEnhancementAdapter.prototype.onRequestThrottled=function onRequestThrottled(){};IEnhancementAdapter.prototype.onRequestRetry=function onRequestRetry(){};IEnhancementAdapter.prototype.onRequestUnauthorized=function onRequestUnauthorized(){};IEnhancementAdapter.prototype.onRequestDeprecated=function onRequestDeprecated(){};IEnhancementAdapter.prototype.onRequestResolve=function onRequestResolve(){};IEnhancementAdapter.prototype.onRequestFinally=function onRequestFinally(){};return IEnhancementAdapter}(),_class.__adapter__="IEnhancementAdapter",_temp);function enhance(obj,name,factory){var original=obj[name];obj[name]=function enhanced(){for(var _len=arguments.length,args=Array(_len),_key=0;_key<_len;_key++){args[_key]=arguments[_key]}var bound=original.bind.apply(original,[this].concat(args));var replacement=factory(bound,this,args);var value=replacement.apply(this,args);return value}}function getNestedMethods(client){var includeTop=arguments.length>1&&arguments[1]!==undefined?arguments[1]:false;var definitions=[];function scan(api){var prefix=arguments.length>1&&arguments[1]!==undefined?arguments[1]:[];var children=Object.getOwnPropertyNames(api).filter(function(name){return api[name].client===client});var proto=Object.getPrototypeOf(api);var methods=Object.keys(proto).filter(function(name){return typeof proto[name]==="function"&&name.indexOf("_")!==0});if(prefix.length||includeTop){methods.forEach(function(name){definitions.push({namespace:prefix.join("."),name:name,api:api})})}children.forEach(function(name){scan(api[name],prefix.concat(name))})}scan(client);return definitions}exports.default=IEnhancementAdapter;
@@ -1,2 +1,2 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PageProofAngularEnhancementAdapter=t():e.PageProofAngularEnhancementAdapter=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},c=n(1),a=function(e){return e&&e.__esModule?e:{default:e}}(c),p=n(2)("AngularEnhancementAdapter"),f={$scope:null,$exceptionHandler:null,module:null},s=function(e){function t(n){o(this,t);var i=r(this,e.call(this));return i.options=u({},f,n),i.$scope=i.options.$scope,i.$exceptionHandler=i.options.$exceptionHandler,i.options.module&&i.options.module.run(["$rootScope","$exceptionHandler",function(e,t){p("Extracting the $rootScope and $exceptionHandler from Angular module"),i.$scope=i.$scope||e,i.$exceptionHandler=i.$exceptionHandler||t}]),i}return i(t,e),t.prototype.onMethodFinally=function(){this.$scope&&!this.$scope.$$phase&&this.$scope.$apply(),this.$scope||p("Unable to tell $scope to re-digest, either module hasn't booted, or no $scope was provided")},t.prototype.onMethodReject=function(e){var t=e.rejected;this.$exceptionHandler?this.$exceptionHandler(t):p("Unable to invoke $exceptionHandler of rejected Promise, check configuration")},t.prototype.onMethodThrown=function(e){var t=e.error;this.$exceptionHandler?this.$exceptionHandler(t):p("Unable to invoke $exceptionHandler of uncaught error, check configuration")},t}(a.default);t.default=s},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t,n){var o=e[t];e[t]=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=o.bind.apply(o,[this].concat(t));return n(i,this,t).apply(this,t)}}function i(e){function t(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],u=Object.getOwnPropertyNames(r).filter(function(t){return r[t].client===e}),c=Object.getPrototypeOf(r),a=Object.keys(c).filter(function(e){return"function"==typeof c[e]&&0!==e.indexOf("_")});if(i.length||n){var p=i.join(".");0===p.indexOf("__")&&(p=p.substring(2)),a.forEach(function(e){o.push({namespace:p,name:e,api:r})})}u.forEach(function(e){t(r[e],i.concat(e))})}var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=[];return t(e),o}t.__esModule=!0;var u,c,a=(c=u=function(){function e(){o(this,e)}return e.prototype.onClientReady=function(e){var t=this;i(e).forEach(function(e){var n={api:e.api,namespace:e.namespace,name:e.name,displayName:e.namespace+"."+e.name};t.onMethodEnhance(n),r(e.api,e.name,function(e){return t.onMethodBefore(n),function(){var o=void 0;try{o=e()}catch(e){throw n.error=e,t.onMethodThrown(n),e}finally{n.value=o,t.onMethodAfter(n),o&&"function"==typeof o.then&&o.then(function(e){n.resolved=e,t.onMethodResolve(n)},function(e){n.rejected=e,t.onMethodReject(n)}).then(function(){t.onMethodFinally(n)})}return o}})}),e.on("experimental.request.before",function(e){return t.onRequestBefore(e.data)}),e.on("experimental.request.after",function(e){return t.onRequestAfter(e.data)}),e.on("error.response",function(e){return t.onRequestReject(e.data)}),e.on("error.throttled",function(e){return t.onRequestThrottled(e.data)}),e.on("experimental.request.retry",function(e){return t.onRequestRetry(e.data)}),e.on("error.unauthorized",function(e){return t.onRequestUnauthorized(e.data)}),e.on("error.deprecated",function(e){return t.onRequestDeprecated(e.data)}),e.on("experimental.request.resolve",function(e){return t.onRequestResolve(e.data)}),e.on("experimental.request.finally",function(e){return t.onRequestFinally(e.data)})},e.prototype.onMethodEnhance=function(e){},e.prototype.onMethodBefore=function(e){},e.prototype.onMethodAfter=function(e){},e.prototype.onMethodReject=function(e){},e.prototype.onMethodResolve=function(e){},e.prototype.onMethodFinally=function(e){},e.prototype.onMethodThrown=function(e){},e.prototype.onRequestBefore=function(e){},e.prototype.onRequestAfter=function(e){},e.prototype.onRequestReject=function(e){},e.prototype.onRequestThrottled=function(e){},e.prototype.onRequestRetry=function(e){},e.prototype.onRequestUnauthorized=function(e){},e.prototype.onRequestDeprecated=function(e){},e.prototype.onRequestResolve=function(e){},e.prototype.onRequestFinally=function(e){},e}(),u.__adapter__="IEnhancementAdapter",c);t.default=a},function(e,t,n){"use strict";e.exports=function e(){return e}}])});
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.PageProofAngularEnhancementAdapter=t():e.PageProofAngularEnhancementAdapter=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=0)}([function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}function i(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}t.__esModule=!0;var u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},c=n(1),a=function(e){return e&&e.__esModule?e:{default:e}}(c),p=n(2)("AngularEnhancementAdapter"),f={$scope:null,$exceptionHandler:null,module:null},s=function(e){function t(n){o(this,t);var i=r(this,e.call(this));return i.options=u({},f,n),i.$scope=i.options.$scope,i.$exceptionHandler=i.options.$exceptionHandler,i.options.module&&i.options.module.run(["$rootScope","$exceptionHandler",function(e,t){p("Extracting the $rootScope and $exceptionHandler from Angular module"),i.$scope=i.$scope||e,i.$exceptionHandler=i.$exceptionHandler||t}]),i}return i(t,e),t.prototype.onMethodFinally=function(){this.$scope&&!this.$scope.$$phase&&this.$scope.$apply(),this.$scope||p("Unable to tell $scope to re-digest, either module hasn't booted, or no $scope was provided")},t.prototype.onMethodReject=function(e){var t=e.rejected;this.$exceptionHandler?this.$exceptionHandler(t):p("Unable to invoke $exceptionHandler of rejected Promise, check configuration")},t.prototype.onMethodThrown=function(e){var t=e.error;this.$exceptionHandler?this.$exceptionHandler(t):p("Unable to invoke $exceptionHandler of uncaught error, check configuration")},t}(a.default);t.default=s},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e,t,n){var o=e[t];e[t]=function(){for(var e=arguments.length,t=Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=o.bind.apply(o,[this].concat(t));return n(i,this,t).apply(this,t)}}function i(e){function t(r){var i=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[],u=Object.getOwnPropertyNames(r).filter(function(t){return r[t].client===e}),c=Object.getPrototypeOf(r),a=Object.keys(c).filter(function(e){return"function"==typeof c[e]&&0!==e.indexOf("_")});(i.length||n)&&a.forEach(function(e){o.push({namespace:i.join("."),name:e,api:r})}),u.forEach(function(e){t(r[e],i.concat(e))})}var n=arguments.length>1&&void 0!==arguments[1]&&arguments[1],o=[];return t(e),o}t.__esModule=!0;var u,c,a=(c=u=function(){function e(){o(this,e)}return e.prototype.onClientReady=function(e){var t=this;i(e).forEach(function(e){r(e.api,e.name,function(n){var o={api:e.api,namespace:e.namespace,name:e.name,displayName:e.namespace+"."+e.name};return t.onMethodBefore(o),function(){var e=void 0;try{e=n()}catch(e){throw o.error=e,t.onMethodThrown(o),e}finally{o.value=e,t.onMethodAfter(o),e&&"function"==typeof e.then&&e.then(function(e){o.resolved=e,t.onMethodResolve(o)},function(e){o.rejected=e,t.onMethodReject(o)}).then(function(){t.onMethodFinally(o)})}return e}})}),e.on("experimental.request.before",function(e){return t.onRequestBefore(e.data)}),e.on("experimental.request.after",function(e){return t.onRequestAfter(e.data)}),e.on("error.response",function(e){return t.onRequestReject(e.data)}),e.on("error.throttled",function(e){return t.onRequestThrottled(e.data)}),e.on("experimental.request.retry",function(e){return t.onRequestRetry(e.data)}),e.on("error.unauthorized",function(e){return t.onRequestUnauthorized(e.data)}),e.on("error.deprecated",function(e){return t.onRequestDeprecated(e.data)}),e.on("experimental.request.resolve",function(e){return t.onRequestResolve(e.data)}),e.on("experimental.request.finally",function(e){return t.onRequestFinally(e.data)})},e.prototype.onMethodBefore=function(){},e.prototype.onMethodAfter=function(){},e.prototype.onMethodReject=function(){},e.prototype.onMethodResolve=function(){},e.prototype.onMethodFinally=function(){},e.prototype.onMethodThrown=function(){},e.prototype.onRequestBefore=function(){},e.prototype.onRequestAfter=function(){},e.prototype.onRequestReject=function(){},e.prototype.onRequestThrottled=function(){},e.prototype.onRequestRetry=function(){},e.prototype.onRequestUnauthorized=function(){},e.prototype.onRequestDeprecated=function(){},e.prototype.onRequestResolve=function(){},e.prototype.onRequestFinally=function(){},e}(),u.__adapter__="IEnhancementAdapter",c);t.default=a},function(e,t,n){"use strict";e.exports=function e(){return e}}])});
2
2
  //# sourceMappingURL=angular-enhancement-adapter.js.map
@@ -195,7 +195,6 @@ declare class Files extends API {
195
195
  * @param {boolean} [file.download=false] Whether the file should be available for download
196
196
  * @param {boolean} [file.async=true] Whether to upload the file independently of the Promise
197
197
  * @param {function} [file.onProgress] A callback for tracking the upload percentage
198
- * @param {function} [file.onFileDetails] A callback option which provides you with the {@link File} object - before it starts uploading. The File object currently only includes the `id` field.
199
198
  * @param {object} [options]
200
199
  * @param {number} [options.progressDecimalPlaces] Sets the number of decimal places in the progress events. This can dramatically reduce the frequency the `file.onProgress` callback is invoked.
201
200
  * @param {number} [options.concurrent=6] The number of concurrent chunks to encrypt & upload at once.
package/lib/api/Files.js CHANGED
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _File=require("../models/File");var _File2=_interopRequireDefault(_File);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _ImportProvider=require("../enum/ImportProvider");var _ImportProvider2=_interopRequireDefault(_ImportProvider);var _streamBlocks=require("../util/streamBlocks");var _streamBlocks2=_interopRequireDefault(_streamBlocks);var _bluffer=require("../bluffer");var _bluffer2=_interopRequireDefault(_bluffer);var _getContentLength=require("../util/getContentLength");var _getContentLength2=_interopRequireDefault(_getContentLength);var _constants=require("../util/constants");var _throttle=require("../util/throttle");var _throttle2=_interopRequireDefault(_throttle);var _concurrent=require("../util/concurrent");var _concurrent2=_interopRequireDefault(_concurrent);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target}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 parseFilename(filename){var extensionIndex=filename.lastIndexOf(".");var name=filename.substring(0,extensionIndex);var extension=filename.substring(extensionIndex+1);return{name:name,extension:extension}}function containPercentage(percent,left,right){var total=1-(left+right);return total*percent+left}var Files=function(_API){_inherits(Files,_API);function Files(){_classCallCheck(this,Files);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Files.prototype.generateToken=function generateToken(assignedTo,assignedType){if(assignedTo&&!assignedType){return Promise.reject(Error('The "assignedType" option is required when specifying the "assignedTo" option.'))}if(!assignedTo&&assignedType){return Promise.reject(Error('The "assignedTo" option is required when specifying the "assignedType" option.'))}return this.client.request("files.legacy.generate-token",{relatedId:assignedTo,fileType:assignedType}).then(function(response){return response.data.Token})};Files.prototype.setCanDownload=function setCanDownload(fileId,canDownload){return this.client.request("files.can-download.update",{fileId:fileId,downloadOriginal:canDownload?1:0})};Files.prototype._waitFileProcessed=function _waitFileProcessed(id){var _this2=this;return new Promise(function(resolve,reject){var checkTimeout=null;var timeoutTimeout=null;var check=function check(){_this2.details(id).then(function(file){checkTimeout=null;switch(file.status){case _FileStatus2.default.OK:{resolve(file);break}case _FileStatus2.default.ERROR:{reject(new Error("File "+id+" encountered a processing error: "+file.message));break}default:{checkTimeout=setTimeout(check,5e3);break}}if(!checkTimeout||file.status===_FileStatus2.default.RIPPING){clearTimeout(timeoutTimeout)}}).catch(reject)};check();timeoutTimeout=setTimeout(function(){clearTimeout(checkTimeout);reject(new Error("File did not finish processing within specified duration."))},3e4)})};Files.prototype._createWebsiteFile=function _createWebsiteFile(url){var _this3=this;return this._generateKeyIVEnvelope().then(function(_ref){var envelope=_ref.envelope;return _this3.client.request("files.import.web",{url:url,envelope:envelope})}).then(function(response){return response.data})};Files.prototype._importFileFromUrl=function _importFileFromUrl(_ref2){var _this4=this;var name=_ref2.name,url=_ref2.url,provider=_ref2.provider,auth=_ref2.auth,download=_ref2.download;var endpoint=provider;if(provider===_ImportProvider2.default.NONE){endpoint="generic"}var _parseFilename=parseFilename(name),filename=_parseFilename.name,extension=_parseFilename.extension;return this._generateKeyIVEnvelope().then(function(_ref3){var envelope=_ref3.envelope;return _this4.client.request("files.import."+endpoint,{extn:extension,filename:filename,url:url,envelope:envelope,accessToken:auth,storeOriginal:download})}).then(function(response){return response.data})};Files.prototype.import=function _import(_ref4){var _this5=this;var name=_ref4.name,url=_ref4.url,_ref4$provider=_ref4.provider,provider=_ref4$provider===undefined?_ImportProvider2.default.NONE:_ref4$provider,auth=_ref4.auth,_ref4$download=_ref4.download,download=_ref4$download===undefined?false:_ref4$download,_ref4$process=_ref4.process,process=_ref4$process===undefined?false:_ref4$process;var providerSupported=Object.keys(_ImportProvider2.default).some(function(key){return _ImportProvider2.default[key]===provider});if(!providerSupported){return Promise.reject(new Error('Unsupported provider "'+provider+'"'))}return(provider===_ImportProvider2.default.WEBSITE?this._createWebsiteFile(url):this._importFileFromUrl({name:name,url:url,provider:provider,auth:auth,download:download})).then(function(token){if(process){return _this5._waitFileProcessed(token)}else{var file=new _File2.default;file.id=token;return file}})};Files.prototype.email=function email(){return this.client.request("files.create-email").then(function(response){return response.data})};Files.prototype._generateKeyIVEnvelope=function _generateKeyIVEnvelope(){var _this6=this;return this.client.crypto().generateKeyIV().then(function(keyIV){return Promise.all([keyIV,_this6.client.crypto().envelopeSeal(keyIV.keyIV,[_this6.client.session.serverPublicKeyPEM,_this6.client.session.publicKeyPEM])])}).then(function(_ref5){var keyIV=_ref5[0],envelope=_ref5[1];return{keyIV:keyIV,envelope:envelope}})};Files.prototype.upload=function upload(){return this.upload__v2.apply(this,arguments)};Files.prototype.upload__v2=function upload__v2(files){var _this7=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var _options$concurrent=options.concurrent,concurrency=_options$concurrent===undefined?6:_options$concurrent,opts=_objectWithoutProperties(options,["concurrent"]);var scheduleChunk=(0,_concurrent2.default)(concurrency);var scheduleDone=(0,_concurrent2.default)(1);var doneFiles=[];var multipleFiles=Array.isArray(files);var filesList=multipleFiles?files:[files];var done=function done(result){doneFiles.push(result);return scheduleDone(function(){if(doneFiles.length){var _doneFiles=doneFiles.slice();doneFiles.length=0;return _this7.client.request("files.v2.upload-complete",{files:_doneFiles})}return null})};return this.client.request("files.v2.generate-credentials",{supports:{providers:["abs","custom"]},files:filesList.map(function(file){var name=void 0;var extension=void 0;if(file.extension){var _ref6=[file.name,file.extension];name=_ref6[0];extension=_ref6[1]}else{var parsed=parseFilename(file.name);var _ref7=[parsed.name,parsed.extension];name=_ref7[0];extension=_ref7[1]}var size=(0,_getContentLength2.default)(file.contents);var chunks=Math.ceil(size/_constants.BYTES_PER_BLOCK);if(file.onProgress){file.onProgress(0)}return{name:name,extension:extension,chunks:chunks,size:size,hash:null,adobeExportData:file.adobeExportData?JSON.stringify(file.adobeExportData):null,assignedTo:file.assignedTo,assignedType:file.assignedType,canDownload:typeof file.download!=="undefined"?!!file.download:true}})}).then(function(response){return Promise.all(filesList.map(function(file,index){var definition=response.data[index];if(file.onProgress){file.onProgress(1)}var entity=new _File2.default;entity.id=definition.FileId;if(file.onFileDetails){file.onFileDetails(entity)}return _this7._upload__v2(file,definition,opts,scheduleChunk,done).then(function(){return entity})}))}).then(function(results){return multipleFiles?results:results[0]})};Files.prototype._upload__v2=function _upload__v2(file,definition,options,schedule,done){var _this8=this;return this._generateKeyIVEnvelope().then(function(_ref8){var keyIV=_ref8.keyIV,envelope=_ref8.envelope;return new Promise(function(resolve){var fileId=definition.FileId,uploadCredentials=definition.UploadCredentials;var bluffer=new _bluffer2.default;var complete=false;var index=0;var blocks=(0,_streamBlocks2.default)(file.contents,function(b){return bluffer.readBase64(b)});var tasks=[];var count=Math.ceil((0,_getContentLength2.default)(file.contents)/_constants.BYTES_PER_BLOCK);var percent=new Array(count);var lastPercent=1;var onUploadProgress=function onUploadProgress(){};var onProgress=file.onProgress;if(onProgress){onUploadProgress=function onUploadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);var totalPercent=containPercentage(percent.reduce(function(a,b){return a+(b||0)},0)/count/100,.01,.01)*100;if(typeof options.progressDecimalPlaces!=="undefined"){totalPercent=+totalPercent.toFixed(options.progressDecimalPlaces)}if(lastPercent!==totalPercent){onProgress(totalPercent);lastPercent=totalPercent}}}function handle(block,blockIndex){var task=encryptAndUpload(block,blockIndex);tasks.push(task);return task}var abs=function abs(block,blockIndex){return _this8.client.rawRequest({method:"PUT",host:uploadCredentials.url,path:"/"+fileId+"/"+blockIndex,query:uploadCredentials.sas,body:block,headers:{"x-ms-blob-type":"BlockBlob"}},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})};var custom=function custom(block,blockIndex){var values={"file.id":fileId,"chunk.index":blockIndex};var interpolate=function interpolate(str){var map=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(a){return a};return str.replace(/\{([\w\.]+)\}/g,function(_,key){return map(values[key])})};var interpolatedHeaders={};Object.keys(uploadCredentials.headers).forEach(function(name){var value=interpolate(uploadCredentials.headers[name]);interpolatedHeaders[interpolate(name)]=value});return _this8.client.rawRequest({method:uploadCredentials.method,host:interpolate(uploadCredentials.host),path:interpolate(uploadCredentials.path,encodeURIComponent),query:interpolate(uploadCredentials.query,encodeURIComponent),body:block,headers:interpolatedHeaders},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})};var uploadData={abs:abs,custom:custom}[uploadCredentials.type];var encryptAndUpload=function encryptAndUpload(block,blockIndex){return _this8.client.crypto().encryptFileBlock(keyIV,block,true).then(function(block$_){return bluffer.createBase64(block$_)}).then(function(block$){return uploadData(block$,blockIndex)})};var finish=function finish(){return done({fileId:fileId,envelope:envelope}).then(function(){if(onProgress)onProgress(100)})};function next(){if(complete){return}schedule(function(){return blocks().then(function(data){if(data){next();return handle(data,index++)}else if(!complete){complete=true;var final=Promise.all(tasks).then(finish);resolve(final)}})})}next();if(file.async!==false){resolve()}})})};Files.prototype.upload__legacy=function upload__legacy(_ref9){var _this9=this;var name=_ref9.name,contents=_ref9.contents,adobeExportData=_ref9.adobeExportData,assignedTo=_ref9.assignedTo,assignedType=_ref9.assignedType,_ref9$download=_ref9.download,download=_ref9$download===undefined?false:_ref9$download,_ref9$async=_ref9.async,async=_ref9$async===undefined?true:_ref9$async,onProgress=_ref9.onProgress,onError=_ref9.onError;return this.generateToken(assignedTo,assignedType).then(function(token){return Promise.all([token,_this9._generateKeyIVEnvelope()])}).then(function(_ref10){var token=_ref10[0],_ref10$=_ref10[1],keyIV=_ref10$.keyIV,envelope=_ref10$.envelope;var process=_this9._upload__legacy({name:name,contents:contents,adobeExportData:adobeExportData,download:download,token:token,keyIV:keyIV,envelope:envelope,onProgress:onProgress,onError:onError});if(async){process=Promise.resolve()}return process.then(function(){return token})}).then(function(token){var file=new _File2.default;file.id=token;return file})};Files.prototype._upload__legacy=function _upload__legacy(_ref11){var _this10=this;var name=_ref11.name,contents=_ref11.contents,adobeExportData=_ref11.adobeExportData,download=_ref11.download,token=_ref11.token,keyIV=_ref11.keyIV,envelope=_ref11.envelope,onProgress=_ref11.onProgress;return new Promise(function(resolve){var concurrent=4;var _parseFilename2=parseFilename(name),filename=_parseFilename2.name,extension=_parseFilename2.extension;var blocks=(0,_streamBlocks2.default)(contents);var chain=Promise.resolve();var index=0;var end=false;var count=Math.ceil((0,_getContentLength2.default)(contents)/_constants.BYTES_PER_BLOCK);var percent=new Array(count);var onUploadProgress=function onUploadProgress(){};if(onProgress){onUploadProgress=function onUploadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);onProgress(percent.reduce(function(a,b){return a+(b||0)},0)/count*.99)}}var process=function process(block,blockIndex){return _this10.client.crypto().encryptFileBlock(keyIV,block).then(function(block$){return _this10.client.request("files.legacy.upload-block",{block:blockIndex,part:1,token:token,data:block$},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})})};function next(){blocks().then(function(block){if(end)return;if(block===null){end=true;resolve(chain.then(complete))}else{var handle=process(block,index++);chain=chain.then(function(){return handle});handle.then(next)}})}var complete=function complete(){return _this10.client.request("files.legacy.upload-complete",{block:0,blockCount:index,part:0,token:token,extn:extension,pages:1,filename:filename,storeoriginal:download?1:0,adobeExportData:adobeExportData?JSON.stringify(adobeExportData):null,envelope:envelope}).then(function(){return onProgress&&onProgress(100)})};while(concurrent--){next()}})};Files.prototype.download=function download(_options){var _this11=this;var options=typeof _options==="string"?{fileId:_options}:_options;var fileId=options.fileId,onFileDetails=options.onFileDetails;return this.details(fileId).then(function(file){if(!file.downloadable){throw new Error("File "+fileId+" is not downloadable.")}if(file.status!==_FileStatus2.default.OK){throw new Error("File "+fileId+" cannot be download. The file may still be uploading, processing or has errored.")}if(!file.blocks){throw new Error("File "+fileId+" is empty.")}if(onFileDetails){onFileDetails(file)}return _this11._downloadFile(file,options)})};Files.prototype._downloadFile=function _downloadFile(file,options){var _this12=this;return new Promise(function(resolve){var concurrent=4;var bluffer=new _bluffer2.default;var count=file.blocks;var blocks=new Array(count);var chain=Promise.resolve();var onData=options.onData||function onData(block,index){blocks[index]=block};var onDownloadProgress=function onDownloadProgress(){};if(options.onProgress){var percent=new Array(count);onDownloadProgress=function onDownloadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);options.onProgress(percent.reduce(function(a,b){return a+(b||0)},0)/count*.99)}}var process=function process(blockIndex){return _this12.client.request("files.download-block",{proofId:file.assignedTo,fileId:file.id,block:blockIndex+1},{onDownloadProgress:onDownloadProgress.bind(null,blockIndex)}).then(function(response){return _this12.client.crypto().decryptFileBlock(response.data,_this12.client.session.privateKeyPEM).then(function(blockBase64){return bluffer.createBase64(blockBase64)})})};var index=0;var end=false;function next(){if(end)return;if(index<blocks.length){var blockIndex=index++;var block=process(blockIndex);chain=chain.then(function(){return block.then(function(data){return onData(data,blockIndex,count)})});block.then(next)}else{end=true;resolve(chain.then(complete))}}var complete=function complete(){if(options.onProgress){options.onProgress(100)}if(!options.onData){return bluffer.combine.apply(bluffer,blocks)}return null};while(concurrent--){next()}})};Files.prototype.details=function details(fileId){return this.client.request("files.details",{fileId:fileId}).then(function(response){return(new _File2.default).fromFile(response.data)})};Files.prototype.thumbnail=function thumbnail(fileId){var _this13=this;return this.client.cache.auto(_constants.THUMBNAIL_CACHE_PREFIX+fileId,function(){return _this13._thumbnail(fileId)})};Files.prototype._thumbnail=function _thumbnail(fileId){var _this14=this;return this.client.request("files.thumbnail",{fileId:fileId}).then(function(response){return _this14.client.crypto().decryptImage(response.data,_this14.client.session.privateKeyPEM)}).then(function(imageBase64){var bluffer=new _bluffer2.default;return bluffer.createBase64(imageBase64)})};Files.prototype.thumbnails=function thumbnails(fileIds,_ref12){var _this15=this;var _ref12$async=_ref12.async,async=_ref12$async===undefined?false:_ref12$async,onLoadThumbnail=_ref12.onLoadThumbnail,onLoadThumbnails=_ref12.onLoadThumbnails,_ref12$onLoadThumbnai=_ref12.onLoadThumbnailsThrottleMs,onLoadThumbnailsThrottleMs=_ref12$onLoadThumbnai===undefined?1e3:_ref12$onLoadThumbnai,onLoadError=_ref12.onLoadError;var scheduled=[];var pendingBatch={};var scheduleOnLoadThumbnails=onLoadThumbnails?(0,_throttle2.default)(function(){if(Object.keys(pendingBatch).length){onLoadThumbnails(pendingBatch);pendingBatch={}}},onLoadThumbnailsThrottleMs):function(){};return Promise.all(fileIds.map(function(fileId){return _this15.client.cache.auto(_constants.THUMBNAIL_CACHE_PREFIX+fileId,function(resolve){scheduled.push({fileId:fileId,resolve:resolve})}).then(function(thumbnail){var _ref13;return thumbnail&&(_ref13={},_ref13[fileId]=thumbnail,_ref13)})})).then(function(entries){var more=Promise.all(scheduled.map(function(_ref14){var fileId=_ref14.fileId,resolve=_ref14.resolve;return _this15._thumbnail(fileId).then(function(thumbnail){var _ref15;resolve(thumbnail);if(onLoadThumbnail){var _onLoadThumbnail;onLoadThumbnail((_onLoadThumbnail={},_onLoadThumbnail[fileId]=thumbnail,_onLoadThumbnail))}pendingBatch[fileId]=thumbnail;scheduleOnLoadThumbnails();return _ref15={},_ref15[fileId]=thumbnail,_ref15}).catch(function(err){if(onLoadError){onLoadError(err,fileId)}if(!async){return Promise.reject(err)}return{}})}));if(async){return entries}else{return more.then(function(moreEntries){return[].concat(entries,moreEntries)})}}).then(function(entries){return Object.assign.apply(Object,[{}].concat(entries))})};return Files}(_API3.default);exports.default=Files;
1
+ "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _File=require("../models/File");var _File2=_interopRequireDefault(_File);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _ImportProvider=require("../enum/ImportProvider");var _ImportProvider2=_interopRequireDefault(_ImportProvider);var _streamBlocks=require("../util/streamBlocks");var _streamBlocks2=_interopRequireDefault(_streamBlocks);var _bluffer=require("../bluffer");var _bluffer2=_interopRequireDefault(_bluffer);var _getContentLength=require("../util/getContentLength");var _getContentLength2=_interopRequireDefault(_getContentLength);var _constants=require("../util/constants");var _throttle=require("../util/throttle");var _throttle2=_interopRequireDefault(_throttle);var _concurrent=require("../util/concurrent");var _concurrent2=_interopRequireDefault(_concurrent);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _objectWithoutProperties(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target}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 parseFilename(filename){var extensionIndex=filename.lastIndexOf(".");var name=filename.substring(0,extensionIndex);var extension=filename.substring(extensionIndex+1);return{name:name,extension:extension}}function containPercentage(percent,left,right){var total=1-(left+right);return total*percent+left}var Files=function(_API){_inherits(Files,_API);function Files(){_classCallCheck(this,Files);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Files.prototype.generateToken=function generateToken(assignedTo,assignedType){if(assignedTo&&!assignedType){return Promise.reject(Error('The "assignedType" option is required when specifying the "assignedTo" option.'))}if(!assignedTo&&assignedType){return Promise.reject(Error('The "assignedTo" option is required when specifying the "assignedType" option.'))}return this.client.request("files.legacy.generate-token",{relatedId:assignedTo,fileType:assignedType}).then(function(response){return response.data.Token})};Files.prototype.setCanDownload=function setCanDownload(fileId,canDownload){return this.client.request("files.can-download.update",{fileId:fileId,downloadOriginal:canDownload?1:0})};Files.prototype._waitFileProcessed=function _waitFileProcessed(id){var _this2=this;return new Promise(function(resolve,reject){var checkTimeout=null;var timeoutTimeout=null;var check=function check(){_this2.details(id).then(function(file){checkTimeout=null;switch(file.status){case _FileStatus2.default.OK:{resolve(file);break}case _FileStatus2.default.ERROR:{reject(new Error("File "+id+" encountered a processing error: "+file.message));break}default:{checkTimeout=setTimeout(check,5e3);break}}if(!checkTimeout||file.status===_FileStatus2.default.RIPPING){clearTimeout(timeoutTimeout)}}).catch(reject)};check();timeoutTimeout=setTimeout(function(){clearTimeout(checkTimeout);reject(new Error("File did not finish processing within specified duration."))},3e4)})};Files.prototype._createWebsiteFile=function _createWebsiteFile(url){var _this3=this;return this._generateKeyIVEnvelope().then(function(_ref){var envelope=_ref.envelope;return _this3.client.request("files.import.web",{url:url,envelope:envelope})}).then(function(response){return response.data})};Files.prototype._importFileFromUrl=function _importFileFromUrl(_ref2){var _this4=this;var name=_ref2.name,url=_ref2.url,provider=_ref2.provider,auth=_ref2.auth,download=_ref2.download;var endpoint=provider;if(provider===_ImportProvider2.default.NONE){endpoint="generic"}var _parseFilename=parseFilename(name),filename=_parseFilename.name,extension=_parseFilename.extension;return this._generateKeyIVEnvelope().then(function(_ref3){var envelope=_ref3.envelope;return _this4.client.request("files.import."+endpoint,{extn:extension,filename:filename,url:url,envelope:envelope,accessToken:auth,storeOriginal:download})}).then(function(response){return response.data})};Files.prototype.import=function _import(_ref4){var _this5=this;var name=_ref4.name,url=_ref4.url,_ref4$provider=_ref4.provider,provider=_ref4$provider===undefined?_ImportProvider2.default.NONE:_ref4$provider,auth=_ref4.auth,_ref4$download=_ref4.download,download=_ref4$download===undefined?false:_ref4$download,_ref4$process=_ref4.process,process=_ref4$process===undefined?false:_ref4$process;var providerSupported=Object.keys(_ImportProvider2.default).some(function(key){return _ImportProvider2.default[key]===provider});if(!providerSupported){return Promise.reject(new Error('Unsupported provider "'+provider+'"'))}return(provider===_ImportProvider2.default.WEBSITE?this._createWebsiteFile(url):this._importFileFromUrl({name:name,url:url,provider:provider,auth:auth,download:download})).then(function(token){if(process){return _this5._waitFileProcessed(token)}else{var file=new _File2.default;file.id=token;return file}})};Files.prototype.email=function email(){return this.client.request("files.create-email").then(function(response){return response.data})};Files.prototype._generateKeyIVEnvelope=function _generateKeyIVEnvelope(){var _this6=this;return this.client.crypto().generateKeyIV().then(function(keyIV){return Promise.all([keyIV,_this6.client.crypto().envelopeSeal(keyIV.keyIV,[_this6.client.session.serverPublicKeyPEM,_this6.client.session.publicKeyPEM])])}).then(function(_ref5){var keyIV=_ref5[0],envelope=_ref5[1];return{keyIV:keyIV,envelope:envelope}})};Files.prototype.upload=function upload(){return this.upload__v2.apply(this,arguments)};Files.prototype.upload__v2=function upload__v2(files){var _this7=this;var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};var _options$concurrent=options.concurrent,concurrency=_options$concurrent===undefined?6:_options$concurrent,opts=_objectWithoutProperties(options,["concurrent"]);var scheduleChunk=(0,_concurrent2.default)(concurrency);var scheduleDone=(0,_concurrent2.default)(1);var doneFiles=[];var multipleFiles=Array.isArray(files);var filesList=multipleFiles?files:[files];var done=function done(result){doneFiles.push(result);return scheduleDone(function(){if(doneFiles.length){var _doneFiles=doneFiles.slice();doneFiles.length=0;return _this7.client.request("files.v2.upload-complete",{files:_doneFiles})}return null})};return this.client.request("files.v2.generate-credentials",{supports:{providers:["abs","custom"]},files:filesList.map(function(file){var name=void 0;var extension=void 0;if(file.extension){var _ref6=[file.name,file.extension];name=_ref6[0];extension=_ref6[1]}else{var parsed=parseFilename(file.name);var _ref7=[parsed.name,parsed.extension];name=_ref7[0];extension=_ref7[1]}var size=(0,_getContentLength2.default)(file.contents);var chunks=Math.ceil(size/_constants.BYTES_PER_BLOCK);if(file.onProgress){file.onProgress(0)}return{name:name,extension:extension,chunks:chunks,size:size,hash:null,adobeExportData:file.adobeExportData?JSON.stringify(file.adobeExportData):null,assignedTo:file.assignedTo,assignedType:file.assignedType,canDownload:typeof file.download!=="undefined"?!!file.download:true}})}).then(function(response){return Promise.all(filesList.map(function(file,index){var definition=response.data[index];if(file.onProgress){file.onProgress(1)}return _this7._upload__v2(file,definition,opts,scheduleChunk,done).then(function(){var entity=new _File2.default;entity.id=definition.FileId;return entity})}))}).then(function(results){return multipleFiles?results:results[0]})};Files.prototype._upload__v2=function _upload__v2(file,definition,options,schedule,done){var _this8=this;return this._generateKeyIVEnvelope().then(function(_ref8){var keyIV=_ref8.keyIV,envelope=_ref8.envelope;return new Promise(function(resolve){var fileId=definition.FileId,uploadCredentials=definition.UploadCredentials;var bluffer=new _bluffer2.default;var complete=false;var index=0;var blocks=(0,_streamBlocks2.default)(file.contents,function(b){return bluffer.readBase64(b)});var tasks=[];var count=Math.ceil((0,_getContentLength2.default)(file.contents)/_constants.BYTES_PER_BLOCK);var percent=new Array(count);var lastPercent=1;var onUploadProgress=function onUploadProgress(){};var onProgress=file.onProgress;if(onProgress){onUploadProgress=function onUploadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);var totalPercent=containPercentage(percent.reduce(function(a,b){return a+(b||0)},0)/count/100,.01,.01)*100;if(typeof options.progressDecimalPlaces!=="undefined"){totalPercent=+totalPercent.toFixed(options.progressDecimalPlaces)}if(lastPercent!==totalPercent){onProgress(totalPercent);lastPercent=totalPercent}}}function handle(block,blockIndex){var task=encryptAndUpload(block,blockIndex);tasks.push(task);return task}var abs=function abs(block,blockIndex){return _this8.client.rawRequest({method:"PUT",host:uploadCredentials.url,path:"/"+fileId+"/"+blockIndex,query:uploadCredentials.sas,body:block,headers:{"x-ms-blob-type":"BlockBlob"}},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})};var custom=function custom(block,blockIndex){var values={"file.id":fileId,"chunk.index":blockIndex};var interpolate=function interpolate(str){var map=arguments.length>1&&arguments[1]!==undefined?arguments[1]:function(a){return a};return str.replace(/\{([\w\.]+)\}/g,function(_,key){return map(values[key])})};var interpolatedHeaders={};Object.keys(uploadCredentials.headers).forEach(function(name){var value=interpolate(uploadCredentials.headers[name]);interpolatedHeaders[interpolate(name)]=value});return _this8.client.rawRequest({method:uploadCredentials.method,host:interpolate(uploadCredentials.host),path:interpolate(uploadCredentials.path,encodeURIComponent),query:interpolate(uploadCredentials.query,encodeURIComponent),body:block,headers:interpolatedHeaders},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})};var uploadData={abs:abs,custom:custom}[uploadCredentials.type];var encryptAndUpload=function encryptAndUpload(block,blockIndex){return _this8.client.crypto().encryptFileBlock(keyIV,block,true).then(function(block$_){return bluffer.createBase64(block$_)}).then(function(block$){return uploadData(block$,blockIndex)})};var finish=function finish(){return done({fileId:fileId,envelope:envelope}).then(function(){if(onProgress)onProgress(100)})};function next(){if(complete){return}schedule(function(){return blocks().then(function(data){if(data){next();return handle(data,index++)}else if(!complete){complete=true;var final=Promise.all(tasks).then(finish);resolve(final)}})})}next();if(file.async!==false){resolve()}})})};Files.prototype.upload__legacy=function upload__legacy(_ref9){var _this9=this;var name=_ref9.name,contents=_ref9.contents,adobeExportData=_ref9.adobeExportData,assignedTo=_ref9.assignedTo,assignedType=_ref9.assignedType,_ref9$download=_ref9.download,download=_ref9$download===undefined?false:_ref9$download,_ref9$async=_ref9.async,async=_ref9$async===undefined?true:_ref9$async,onProgress=_ref9.onProgress,onError=_ref9.onError;return this.generateToken(assignedTo,assignedType).then(function(token){return Promise.all([token,_this9._generateKeyIVEnvelope()])}).then(function(_ref10){var token=_ref10[0],_ref10$=_ref10[1],keyIV=_ref10$.keyIV,envelope=_ref10$.envelope;var process=_this9._upload__legacy({name:name,contents:contents,adobeExportData:adobeExportData,download:download,token:token,keyIV:keyIV,envelope:envelope,onProgress:onProgress,onError:onError});if(async){process=Promise.resolve()}return process.then(function(){return token})}).then(function(token){var file=new _File2.default;file.id=token;return file})};Files.prototype._upload__legacy=function _upload__legacy(_ref11){var _this10=this;var name=_ref11.name,contents=_ref11.contents,adobeExportData=_ref11.adobeExportData,download=_ref11.download,token=_ref11.token,keyIV=_ref11.keyIV,envelope=_ref11.envelope,onProgress=_ref11.onProgress;return new Promise(function(resolve){var concurrent=4;var _parseFilename2=parseFilename(name),filename=_parseFilename2.name,extension=_parseFilename2.extension;var blocks=(0,_streamBlocks2.default)(contents);var chain=Promise.resolve();var index=0;var end=false;var count=Math.ceil((0,_getContentLength2.default)(contents)/_constants.BYTES_PER_BLOCK);var percent=new Array(count);var onUploadProgress=function onUploadProgress(){};if(onProgress){onUploadProgress=function onUploadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);onProgress(percent.reduce(function(a,b){return a+(b||0)},0)/count*.99)}}var process=function process(block,blockIndex){return _this10.client.crypto().encryptFileBlock(keyIV,block).then(function(block$){return _this10.client.request("files.legacy.upload-block",{block:blockIndex,part:1,token:token,data:block$},{onUploadProgress:onUploadProgress.bind(null,blockIndex)})})};function next(){blocks().then(function(block){if(end)return;if(block===null){end=true;resolve(chain.then(complete))}else{var handle=process(block,index++);chain=chain.then(function(){return handle});handle.then(next)}})}var complete=function complete(){return _this10.client.request("files.legacy.upload-complete",{block:0,blockCount:index,part:0,token:token,extn:extension,pages:1,filename:filename,storeoriginal:download?1:0,adobeExportData:adobeExportData?JSON.stringify(adobeExportData):null,envelope:envelope}).then(function(){return onProgress&&onProgress(100)})};while(concurrent--){next()}})};Files.prototype.download=function download(_options){var _this11=this;var options=typeof _options==="string"?{fileId:_options}:_options;var fileId=options.fileId,onFileDetails=options.onFileDetails;return this.details(fileId).then(function(file){if(!file.downloadable){throw new Error("File "+fileId+" is not downloadable.")}if(file.status!==_FileStatus2.default.OK){throw new Error("File "+fileId+" cannot be download. The file may still be uploading, processing or has errored.")}if(!file.blocks){throw new Error("File "+fileId+" is empty.")}if(onFileDetails){onFileDetails(file)}return _this11._downloadFile(file,options)})};Files.prototype._downloadFile=function _downloadFile(file,options){var _this12=this;return new Promise(function(resolve){var concurrent=4;var bluffer=new _bluffer2.default;var count=file.blocks;var blocks=new Array(count);var chain=Promise.resolve();var onData=options.onData||function onData(block,index){blocks[index]=block};var onDownloadProgress=function onDownloadProgress(){};if(options.onProgress){var percent=new Array(count);onDownloadProgress=function onDownloadProgress(blockIndex,progress){percent[blockIndex]=Math.max(progress,percent[blockIndex]||0);options.onProgress(percent.reduce(function(a,b){return a+(b||0)},0)/count*.99)}}var process=function process(blockIndex){return _this12.client.request("files.download-block",{proofId:file.assignedTo,fileId:file.id,block:blockIndex+1},{onDownloadProgress:onDownloadProgress.bind(null,blockIndex)}).then(function(response){return _this12.client.crypto().decryptFileBlock(response.data,_this12.client.session.privateKeyPEM).then(function(blockBase64){return bluffer.createBase64(blockBase64)})})};var index=0;var end=false;function next(){if(end)return;if(index<blocks.length){var blockIndex=index++;var block=process(blockIndex);chain=chain.then(function(){return block.then(function(data){return onData(data,blockIndex,count)})});block.then(next)}else{end=true;resolve(chain.then(complete))}}var complete=function complete(){if(options.onProgress){options.onProgress(100)}if(!options.onData){return bluffer.combine.apply(bluffer,blocks)}return null};while(concurrent--){next()}})};Files.prototype.details=function details(fileId){return this.client.request("files.details",{fileId:fileId}).then(function(response){return(new _File2.default).fromFile(response.data)})};Files.prototype.thumbnail=function thumbnail(fileId){var _this13=this;return this.client.cache.auto(_constants.THUMBNAIL_CACHE_PREFIX+fileId,function(){return _this13._thumbnail(fileId)})};Files.prototype._thumbnail=function _thumbnail(fileId){var _this14=this;return this.client.request("files.thumbnail",{fileId:fileId}).then(function(response){return _this14.client.crypto().decryptImage(response.data,_this14.client.session.privateKeyPEM)}).then(function(imageBase64){var bluffer=new _bluffer2.default;return bluffer.createBase64(imageBase64)})};Files.prototype.thumbnails=function thumbnails(fileIds,_ref12){var _this15=this;var _ref12$async=_ref12.async,async=_ref12$async===undefined?false:_ref12$async,onLoadThumbnail=_ref12.onLoadThumbnail,onLoadThumbnails=_ref12.onLoadThumbnails,_ref12$onLoadThumbnai=_ref12.onLoadThumbnailsThrottleMs,onLoadThumbnailsThrottleMs=_ref12$onLoadThumbnai===undefined?1e3:_ref12$onLoadThumbnai,onLoadError=_ref12.onLoadError;var scheduled=[];var pendingBatch={};var scheduleOnLoadThumbnails=onLoadThumbnails?(0,_throttle2.default)(function(){if(Object.keys(pendingBatch).length){onLoadThumbnails(pendingBatch);pendingBatch={}}},onLoadThumbnailsThrottleMs):function(){};return Promise.all(fileIds.map(function(fileId){return _this15.client.cache.auto(_constants.THUMBNAIL_CACHE_PREFIX+fileId,function(resolve){scheduled.push({fileId:fileId,resolve:resolve})}).then(function(thumbnail){var _ref13;return thumbnail&&(_ref13={},_ref13[fileId]=thumbnail,_ref13)})})).then(function(entries){var more=Promise.all(scheduled.map(function(_ref14){var fileId=_ref14.fileId,resolve=_ref14.resolve;return _this15._thumbnail(fileId).then(function(thumbnail){var _ref15;resolve(thumbnail);if(onLoadThumbnail){var _onLoadThumbnail;onLoadThumbnail((_onLoadThumbnail={},_onLoadThumbnail[fileId]=thumbnail,_onLoadThumbnail))}pendingBatch[fileId]=thumbnail;scheduleOnLoadThumbnails();return _ref15={},_ref15[fileId]=thumbnail,_ref15}).catch(function(err){if(onLoadError){onLoadError(err,fileId)}if(!async){return Promise.reject(err)}return{}})}));if(async){return entries}else{return more.then(function(moreEntries){return[].concat(entries,moreEntries)})}}).then(function(entries){return Object.assign.apply(Object,[{}].concat(entries))})};return Files}(_API3.default);exports.default=Files;
@@ -25,10 +25,8 @@ declare class Preferences extends API {
25
25
  * PageProof.Enum.Preference.DEFAULT_DUE_DATE,
26
26
  * PageProof.Enum.Preference.DEFAULT_DUE_TIME,
27
27
  * PageProof.Enum.Preference.DEFAULT_MESSAGE_TO_REVIEWERS,
28
- * PageProof.Enum.Preference.COLORS,
29
- * PageProof.Enum.Preference.DEFAULT_REMINDER,
30
28
  * ]);
31
- * const [dueDate, dueTime, messageToReviewers, colors, proofReminders] = preferences;
29
+ * const [dueDate, dueTime, messageToReviewers] = preferences;
32
30
  * console.log(messageToReviewers.getValueOrDefault());
33
31
  *
34
32
  * @example <caption>Retrieving a single preference</caption>
@@ -1,13 +1,6 @@
1
1
  export default Profile;
2
2
  declare class Profile extends API {
3
- /** @private */
4
3
  constructor(client: any);
5
- /**
6
- * The Integrations API.
7
- *
8
- * @type {Integrations}
9
- */
10
- integrations: Integrations;
11
4
  /**
12
5
  * Uploads the avatar for the current user.
13
6
  *
@@ -83,4 +76,3 @@ declare class Profile extends API {
83
76
  clearStatus(): Promise<any>;
84
77
  }
85
78
  import API from "./API";
86
- import Integrations from "./Integrations";
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _bluffer=require("../bluffer");var _bluffer2=_interopRequireDefault(_bluffer);var _Integrations=require("./Integrations");var _Integrations2=_interopRequireDefault(_Integrations);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 Profile=function(_API){_inherits(Profile,_API);function Profile(client){_classCallCheck(this,Profile);var _this=_possibleConstructorReturn(this,_API.call(this,client));_this.integrations=new _Integrations2.default(client,"user");return _this}Profile.prototype.uploadAvatar=function uploadAvatar(file){var _this2=this;var bluffer=new _bluffer2.default;return bluffer.readBase64(file).then(function(base64){return _this2.client.request("profile.upload-avatar",{uploadedImage:"data:image/png;base64,"+base64})})};Profile.prototype.changePassword=function changePassword(currentPassword,password){var _this3=this;var crypto=this.client.crypto();return Promise.all([crypto.generatePasswordHash(currentPassword),crypto.generatePasswordHash(password),crypto.encryptPrivateKey(this.client.session.privateKeyPEM,password)]).then(function(_ref){var oldPassword=_ref[0],newPassword=_ref[1],newPrivateKey=_ref[2];return _this3.client.request("profile.change-password",{oldPassword:oldPassword,newPassword:newPassword,newPrivateKey:newPrivateKey})})};Profile.prototype.getStatus=function getStatus(){return this.client.request("profile.status").then(function(response){return response.data.status})};Profile.prototype.setStatus=function setStatus(status){return this.client.request("profile.set-status",status)};Profile.prototype.clearStatus=function clearStatus(){return this.client.request("profile.clear-status")};return Profile}(_API3.default);exports.default=Profile;
1
+ "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _bluffer=require("../bluffer");var _bluffer2=_interopRequireDefault(_bluffer);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 Profile=function(_API){_inherits(Profile,_API);function Profile(){_classCallCheck(this,Profile);return _possibleConstructorReturn(this,_API.apply(this,arguments))}Profile.prototype.uploadAvatar=function uploadAvatar(file){var _this2=this;var bluffer=new _bluffer2.default;return bluffer.readBase64(file).then(function(base64){return _this2.client.request("profile.upload-avatar",{uploadedImage:"data:image/png;base64,"+base64})})};Profile.prototype.changePassword=function changePassword(currentPassword,password){var _this3=this;var crypto=this.client.crypto();return Promise.all([crypto.generatePasswordHash(currentPassword),crypto.generatePasswordHash(password),crypto.encryptPrivateKey(this.client.session.privateKeyPEM,password)]).then(function(_ref){var oldPassword=_ref[0],newPassword=_ref[1],newPrivateKey=_ref[2];return _this3.client.request("profile.change-password",{oldPassword:oldPassword,newPassword:newPassword,newPrivateKey:newPrivateKey})})};Profile.prototype.getStatus=function getStatus(){return this.client.request("profile.status").then(function(response){return response.data.status})};Profile.prototype.setStatus=function setStatus(status){return this.client.request("profile.set-status",status)};Profile.prototype.clearStatus=function clearStatus(){return this.client.request("profile.clear-status")};return Profile}(_API3.default);exports.default=Profile;
@@ -56,13 +56,6 @@ declare class Proofs extends API {
56
56
  * @type {ProofsCustomTools}
57
57
  */
58
58
  customTools: ProofsCustomTools;
59
- /**
60
- * The Proofs Integration References API.
61
- *
62
- * @type {ProofsIntegrationReferences}
63
- */
64
- integrationReferences: ProofsIntegrationReferences;
65
- linkCheck: ProofLinkCheck;
66
59
  /**
67
60
  * Assigns a workflow to a proof.
68
61
  *
@@ -190,7 +183,7 @@ declare class Proofs extends API {
190
183
  * @param {boolean} [options.start=true] Whether to immediately start the proof (sends invitation emails to reviewers in the workflow)
191
184
  * @returns {Promise<Proof>}
192
185
  */
193
- create({ name, tags, dueDate, messageToReviewers, workflow, workflowTemplate, file, group, previousProof, team, reference, customTools, integrationReferences, reminders, owners, canDownload, start, }: {
186
+ create({ name, tags, dueDate, messageToReviewers, workflow, workflowTemplate, file, group, previousProof, team, reference, customTools, reminders, owners, canDownload, start, }: {
194
187
  name: string;
195
188
  tags?: string[];
196
189
  dueDate?: Date;
@@ -464,6 +457,4 @@ import ProofsGroups from "./ProofsGroups";
464
457
  import ProofsAudit from "./ProofsAudit";
465
458
  import ProofsAssets from "./ProofsAssets";
466
459
  import ProofsCustomTools from "./ProofsCustomTools";
467
- import ProofsIntegrationReferences from "./ProofsIntegrationReferences";
468
- import ProofLinkCheck from "./ProofsLinkCheck";
469
460
  import Proof from "../models/Proof";
package/lib/api/Proofs.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 _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _ProofsOwners=require("./ProofsOwners");var _ProofsOwners2=_interopRequireDefault(_ProofsOwners);var _ProofsEditors=require("./ProofsEditors");var _ProofsEditors2=_interopRequireDefault(_ProofsEditors);var _ProofsReviewers=require("./ProofsReviewers");var _ProofsReviewers2=_interopRequireDefault(_ProofsReviewers);var _ProofsVersions=require("./ProofsVersions");var _ProofsVersions2=_interopRequireDefault(_ProofsVersions);var _ProofsGroups=require("./ProofsGroups");var _ProofsGroups2=_interopRequireDefault(_ProofsGroups);var _ProofsAudit=require("./ProofsAudit");var _ProofsAudit2=_interopRequireDefault(_ProofsAudit);var _ProofsAssets=require("./ProofsAssets");var _ProofsAssets2=_interopRequireDefault(_ProofsAssets);var _ProofsCustomTools=require("./ProofsCustomTools");var _ProofsCustomTools2=_interopRequireDefault(_ProofsCustomTools);var _ProofsIntegrationReferences=require("./ProofsIntegrationReferences");var _ProofsIntegrationReferences2=_interopRequireDefault(_ProofsIntegrationReferences);var _ProofsLinkCheck=require("./ProofsLinkCheck");var _ProofsLinkCheck2=_interopRequireDefault(_ProofsLinkCheck);var _Proof=require("../models/Proof");var _Proof2=_interopRequireDefault(_Proof);var _Reminders=require("./Reminders");var _Reminders2=_interopRequireDefault(_Reminders);var _constants=require("../util/constants");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 transformProofsForUpdate(proofs){var proofsArrForUpdate=[].concat(proofs);proofsArrForUpdate.forEach(function(proof){proof.proofId=proof.id;delete proof.id});return proofsArrForUpdate}var Proofs=function(_API){_inherits(Proofs,_API);function Proofs(client){_classCallCheck(this,Proofs);var _this=_possibleConstructorReturn(this,_API.call(this,client));_this.owners=new _ProofsOwners2.default(client);_this.editors=new _ProofsEditors2.default(client);_this.reviewers=new _ProofsReviewers2.default(client);_this.versions=new _ProofsVersions2.default(client);_this.groups=new _ProofsGroups2.default(client);_this.reminders=new _Reminders2.default(client);_this.audit=new _ProofsAudit2.default(client);_this.assets=new _ProofsAssets2.default(client);_this.customTools=new _ProofsCustomTools2.default(client);_this.integrationReferences=new _ProofsIntegrationReferences2.default(client);_this.linkCheck=new _ProofsLinkCheck2.default(client);return _this}Proofs.prototype.setWorkflow=function setWorkflow(proofId,workflowId){var _this2=this;return this.client.request("proofs.normalize-workflow",{proofId:proofId,workflowId:workflowId}).then(function(){return _this2.client.request("proofs.set-workflow",{proofId:proofId,workflowId:workflowId})})};Proofs.prototype.setTags=function setTags(proofId,tags){return this.client.request("proofs.set-tags",{relatedId:proofId,tag:tags.join(",")})};Proofs.prototype.deleteTag=function deleteTag(proofId,tag){return this.client.request("proofs.tag-delete",{relatedId:proofId,tag:tag})};Proofs.prototype.setFile=function setFile(proofId,fileId){var _this3=this;return this.client.request("proofs.set-file",{proofId:proofId,fileId:fileId}).then(function(){return _this3.client.request("proofs.distribute-file",{proofId:proofId})})};Proofs.prototype.create=function create(_ref){var _this4=this;var name=_ref.name,_ref$tags=_ref.tags,tags=_ref$tags===undefined?[]:_ref$tags,_ref$dueDate=_ref.dueDate,dueDate=_ref$dueDate===undefined?new Date(Date.now()+3*_constants.DAY_IN_MS):_ref$dueDate,messageToReviewers=_ref.messageToReviewers,workflow=_ref.workflow,workflowTemplate=_ref.workflowTemplate,file=_ref.file,group=_ref.group,previousProof=_ref.previousProof,team=_ref.team,reference=_ref.reference,customTools=_ref.customTools,integrationReferences=_ref.integrationReferences,_ref$reminders=_ref.reminders,reminders=_ref$reminders===undefined?[]:_ref$reminders,owners=_ref.owners,canDownload=_ref.canDownload,_ref$start=_ref.start,start=_ref$start===undefined?true:_ref$start;return this.client.request("proofs.create",{proof:{name:name,tags:tags,dueDate:dueDate.toISOString(),messageToReviewers:messageToReviewers,workflowId:workflow&&workflow.id||undefined,workflowTemplateId:workflowTemplate&&workflowTemplate.id||undefined,fileId:file&&file.id||undefined,groupId:group&&group.id||undefined,previousProofId:previousProof&&previousProof.id||undefined,teamSlug:team&&team.slug||undefined,reference:reference,integrationReferences:integrationReferences,reminders:[].concat(reminders),owners:owners,canDownload:canDownload,start:start}}).then(function(response){var proof=(new _Proof2.default).fromProof(response.data);proof.calculateState();if(customTools&&!previousProof){return _this4.customTools.update(proof.id,customTools).then(function(){return proof})}return proof})};Proofs.prototype.archive=function archive(proofIdOrIds){return this.client.request("proofs.archive",{proofIds:proofIdOrIds})};Proofs.prototype.unarchive=function unarchive(proofId){return this.client.request("proofs.unarchive",{proofId:proofId})};Proofs.prototype.delete=function _delete(proofId){return this.client.request("proofs.delete",{proofId:proofId})};Proofs.prototype.finish=function finish(proofId,decision){return this.client.request("proofs.finish",{proofId:proofId,decision:decision})};Proofs.prototype.approve=function approve(proofId,message){return this.client.request("proofs.manual-approval",{proofId:proofId,message:message})};Proofs.prototype.withdrawApproval=function withdrawApproval(proofId,messageToSender){return this.client.request("proofs.withdraw-approval",{proofId:proofId,messageToSender:messageToSender})};Proofs.prototype.generateEmail=function generateEmail(proofId){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return this.client.request("email.proofs.generate",_extends({proofId:proofId},options)).then(function(response){return response.data})};Proofs.prototype.return=function _return(proofId){return this.client.request("proofs.return",{proofId:proofId})};Proofs.prototype.start=function start(proofId){return this.client.request("proofs.start",{proofId:proofId})};Proofs.prototype.removeEditor=function removeEditor(id){return this.client.request("proofs.remove-editor",{proofId:id})};Proofs.prototype.load=function load(proofId){return this.client.request("proofs.load",{proofId:proofId}).then(function(response){return(new _Proof2.default).fromProof(response.data)})};Proofs.prototype.lock=function lock(proofId){return this.client.request("proofs.lock",{proofId:proofId})};Proofs.prototype.unlock=function unlock(proofId){return this.client.request("proofs.unlock",{proofId:proofId})};Proofs.prototype.requestUnlock=function requestUnlock(proofId){return this.client.request("proofs.request-unlock",{proofId:proofId})};Proofs.prototype.requestAccess=function requestAccess(proofId){return this.client.request("proofs.request-access",{proofId:proofId})};Proofs.prototype.images=function images(proofId){return this.client.request("proofs.images",{proofId:proofId}).then(function(response){return response.data.proof.file})};Proofs.prototype.setMessageToReviewers=function setMessageToReviewers(proofId,messageToReviewers){return this.client.request("proofs.set-reviewers-message",{proofId:proofId,messageToReviewers:messageToReviewers})};Proofs.prototype.returnTodos=function returnTodos(proofIdOrIds,_ref2){var messageToOwners=_ref2.messageToOwners,_ref2$markCommentsAsT=_ref2.markCommentsAsTodo,markCommentsAsTodo=_ref2$markCommentsAsT===undefined?false:_ref2$markCommentsAsT;return this.client.request("proofs.return-todos",{proofIds:[].concat(proofIdOrIds),messageToOwners:messageToOwners,markCommentAsTodo:markCommentsAsTodo})};Proofs.prototype.updateDecision=function updateDecision(proofId,decision){return this.client.request("proofs.update-decision",{proofId:proofId,decision:decision})};Proofs.prototype.update=function update(proofOrProofs){if(proofOrProofs.length===1||typeof proofOrProofs.length==="undefined"){var _concat$=[].concat(proofOrProofs)[0],id=_concat$.id,name=_concat$.name,tags=_concat$.tags,dueDate=_concat$.dueDate,messageToReviewers=_concat$.messageToReviewers,workflow=_concat$.workflow,file=_concat$.file,reference=_concat$.reference,integrationReferences=_concat$.integrationReferences,reminders=_concat$.reminders,owners=_concat$.owners,canDownload=_concat$.canDownload,start=_concat$.start;return this.client.request("proofs.update",{proof:{id:id,name:name,tags:tags,dueDate:dueDate?dueDate.toISOString():undefined,messageToReviewers:messageToReviewers,workflowId:workflow&&workflow.id||undefined,fileId:file&&file.id||undefined,reference:reference,integrationReferences:integrationReferences,reminders:reminders?[].concat(reminders):undefined,owners:owners,canDownload:canDownload,start:start}}).then(function(response){var proof=(new _Proof2.default).fromProof(response.data);proof.calculateState();return proof})}return this.client.request("proofs.bulk-update",{proofs:transformProofsForUpdate(proofOrProofs)})};Proofs.prototype.next=function next(proofId){return this.client.request("proofs.next",{proofId:proofId}).then(function(response){return(new _Proof2.default).fromProof(response.data)})};return Proofs}(_API3.default);exports.default=Proofs;
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 _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _ProofsOwners=require("./ProofsOwners");var _ProofsOwners2=_interopRequireDefault(_ProofsOwners);var _ProofsEditors=require("./ProofsEditors");var _ProofsEditors2=_interopRequireDefault(_ProofsEditors);var _ProofsReviewers=require("./ProofsReviewers");var _ProofsReviewers2=_interopRequireDefault(_ProofsReviewers);var _ProofsVersions=require("./ProofsVersions");var _ProofsVersions2=_interopRequireDefault(_ProofsVersions);var _ProofsGroups=require("./ProofsGroups");var _ProofsGroups2=_interopRequireDefault(_ProofsGroups);var _ProofsAudit=require("./ProofsAudit");var _ProofsAudit2=_interopRequireDefault(_ProofsAudit);var _ProofsAssets=require("./ProofsAssets");var _ProofsAssets2=_interopRequireDefault(_ProofsAssets);var _ProofsCustomTools=require("./ProofsCustomTools");var _ProofsCustomTools2=_interopRequireDefault(_ProofsCustomTools);var _Proof=require("../models/Proof");var _Proof2=_interopRequireDefault(_Proof);var _Reminders=require("./Reminders");var _Reminders2=_interopRequireDefault(_Reminders);var _constants=require("../util/constants");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 transformProofsForUpdate(proofs){var proofsArrForUpdate=[].concat(proofs);proofsArrForUpdate.forEach(function(proof){proof.proofId=proof.id;delete proof.id});return proofsArrForUpdate}var Proofs=function(_API){_inherits(Proofs,_API);function Proofs(client){_classCallCheck(this,Proofs);var _this=_possibleConstructorReturn(this,_API.call(this,client));_this.owners=new _ProofsOwners2.default(client);_this.editors=new _ProofsEditors2.default(client);_this.reviewers=new _ProofsReviewers2.default(client);_this.versions=new _ProofsVersions2.default(client);_this.groups=new _ProofsGroups2.default(client);_this.reminders=new _Reminders2.default(client);_this.audit=new _ProofsAudit2.default(client);_this.assets=new _ProofsAssets2.default(client);_this.customTools=new _ProofsCustomTools2.default(client);return _this}Proofs.prototype.setWorkflow=function setWorkflow(proofId,workflowId){var _this2=this;return this.client.request("proofs.normalize-workflow",{proofId:proofId,workflowId:workflowId}).then(function(){return _this2.client.request("proofs.set-workflow",{proofId:proofId,workflowId:workflowId})})};Proofs.prototype.setTags=function setTags(proofId,tags){return this.client.request("proofs.set-tags",{relatedId:proofId,tag:tags.join(",")})};Proofs.prototype.deleteTag=function deleteTag(proofId,tag){return this.client.request("proofs.tag-delete",{relatedId:proofId,tag:tag})};Proofs.prototype.setFile=function setFile(proofId,fileId){var _this3=this;return this.client.request("proofs.set-file",{proofId:proofId,fileId:fileId}).then(function(){return _this3.client.request("proofs.distribute-file",{proofId:proofId})})};Proofs.prototype.create=function create(_ref){var _this4=this;var name=_ref.name,_ref$tags=_ref.tags,tags=_ref$tags===undefined?[]:_ref$tags,_ref$dueDate=_ref.dueDate,dueDate=_ref$dueDate===undefined?new Date(Date.now()+3*_constants.DAY_IN_MS):_ref$dueDate,messageToReviewers=_ref.messageToReviewers,workflow=_ref.workflow,workflowTemplate=_ref.workflowTemplate,file=_ref.file,group=_ref.group,previousProof=_ref.previousProof,team=_ref.team,reference=_ref.reference,customTools=_ref.customTools,_ref$reminders=_ref.reminders,reminders=_ref$reminders===undefined?[]:_ref$reminders,owners=_ref.owners,canDownload=_ref.canDownload,_ref$start=_ref.start,start=_ref$start===undefined?true:_ref$start;return this.client.request("proofs.create",{proof:{name:name,tags:tags,dueDate:dueDate.toISOString(),messageToReviewers:messageToReviewers,workflowId:workflow&&workflow.id||undefined,workflowTemplateId:workflowTemplate&&workflowTemplate.id||undefined,fileId:file&&file.id||undefined,groupId:group&&group.id||undefined,previousProofId:previousProof&&previousProof.id||undefined,teamSlug:team&&team.slug||undefined,reference:reference,reminders:[].concat(reminders),owners:owners,canDownload:canDownload,start:start}}).then(function(response){var proof=(new _Proof2.default).fromProof(response.data);proof.calculateState();if(customTools&&!previousProof){return _this4.customTools.update(proof.id,customTools).then(function(){return proof})}return proof})};Proofs.prototype.archive=function archive(proofIdOrIds){return this.client.request("proofs.archive",{proofIds:proofIdOrIds})};Proofs.prototype.unarchive=function unarchive(proofId){return this.client.request("proofs.unarchive",{proofId:proofId})};Proofs.prototype.delete=function _delete(proofId){return this.client.request("proofs.delete",{proofId:proofId})};Proofs.prototype.finish=function finish(proofId,decision){return this.client.request("proofs.finish",{proofId:proofId,decision:decision})};Proofs.prototype.approve=function approve(proofId,message){return this.client.request("proofs.manual-approval",{proofId:proofId,message:message})};Proofs.prototype.withdrawApproval=function withdrawApproval(proofId,messageToSender){return this.client.request("proofs.withdraw-approval",{proofId:proofId,messageToSender:messageToSender})};Proofs.prototype.generateEmail=function generateEmail(proofId){var options=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{};return this.client.request("email.proofs.generate",_extends({proofId:proofId},options)).then(function(response){return response.data})};Proofs.prototype.return=function _return(proofId){return this.client.request("proofs.return",{proofId:proofId})};Proofs.prototype.start=function start(proofId){return this.client.request("proofs.start",{proofId:proofId})};Proofs.prototype.removeEditor=function removeEditor(id){return this.client.request("proofs.remove-editor",{proofId:id})};Proofs.prototype.load=function load(proofId){return this.client.request("proofs.load",{proofId:proofId}).then(function(response){return(new _Proof2.default).fromProof(response.data)})};Proofs.prototype.lock=function lock(proofId){return this.client.request("proofs.lock",{proofId:proofId})};Proofs.prototype.unlock=function unlock(proofId){return this.client.request("proofs.unlock",{proofId:proofId})};Proofs.prototype.requestUnlock=function requestUnlock(proofId){return this.client.request("proofs.request-unlock",{proofId:proofId})};Proofs.prototype.requestAccess=function requestAccess(proofId){return this.client.request("proofs.request-access",{proofId:proofId})};Proofs.prototype.images=function images(proofId){return this.client.request("proofs.images",{proofId:proofId}).then(function(response){return response.data.proof.file})};Proofs.prototype.setMessageToReviewers=function setMessageToReviewers(proofId,messageToReviewers){return this.client.request("proofs.set-reviewers-message",{proofId:proofId,messageToReviewers:messageToReviewers})};Proofs.prototype.returnTodos=function returnTodos(proofIdOrIds,_ref2){var messageToOwners=_ref2.messageToOwners,_ref2$markCommentsAsT=_ref2.markCommentsAsTodo,markCommentsAsTodo=_ref2$markCommentsAsT===undefined?false:_ref2$markCommentsAsT;return this.client.request("proofs.return-todos",{proofIds:[].concat(proofIdOrIds),messageToOwners:messageToOwners,markCommentAsTodo:markCommentsAsTodo})};Proofs.prototype.updateDecision=function updateDecision(proofId,decision){return this.client.request("proofs.update-decision",{proofId:proofId,decision:decision})};Proofs.prototype.update=function update(proofOrProofs){if(proofOrProofs.length===1||typeof proofOrProofs.length==="undefined"){var _concat$=[].concat(proofOrProofs)[0],id=_concat$.id,name=_concat$.name,tags=_concat$.tags,dueDate=_concat$.dueDate,messageToReviewers=_concat$.messageToReviewers,workflow=_concat$.workflow,file=_concat$.file,reference=_concat$.reference,reminders=_concat$.reminders,owners=_concat$.owners,canDownload=_concat$.canDownload,start=_concat$.start;return this.client.request("proofs.update",{proof:{id:id,name:name,tags:tags,dueDate:dueDate?dueDate.toISOString():undefined,messageToReviewers:messageToReviewers,workflowId:workflow&&workflow.id||undefined,fileId:file&&file.id||undefined,reference:reference,reminders:reminders?[].concat(reminders):undefined,owners:owners,canDownload:canDownload,start:start}}).then(function(response){var proof=(new _Proof2.default).fromProof(response.data);proof.calculateState();return proof})}return this.client.request("proofs.bulk-update",{proofs:transformProofsForUpdate(proofOrProofs)})};Proofs.prototype.next=function next(proofId){return this.client.request("proofs.next",{proofId:proofId}).then(function(response){return(new _Proof2.default).fromProof(response.data)})};return Proofs}(_API3.default);exports.default=Proofs;
@@ -1 +1 @@
1
- "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _whatwgURL=require("../util/whatwgURL");var _whatwgURL2=_interopRequireDefault(_whatwgURL);var _bluffer=require("../bluffer");var _bluffer2=_interopRequireDefault(_bluffer);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 ProofsAssetsExtractedText=function(_API){_inherits(ProofsAssetsExtractedText,_API);function ProofsAssetsExtractedText(){_classCallCheck(this,ProofsAssetsExtractedText);return _possibleConstructorReturn(this,_API.apply(this,arguments))}ProofsAssetsExtractedText.prototype.resources=function resources(proofId){return this.client.request("proofs.assets.extracted-text",{proofId:proofId}).then(function(response){return response.data.result}).catch(function(err){if(err&&err.response&&err.response.code===400)return;throw err})};ProofsAssetsExtractedText.prototype.download=function download(resources,pageNumber){var _this2=this;var matchingPages=resources.pages.filter(function(page){return page.number===pageNumber});if(!matchingPages||!matchingPages.length){return Promise.reject(new Error("Page does not contain any text."))}var envelope=resources.envelope;var url=new _whatwgURL2.default(matchingPages[0].chunks[0].url);var bluffer=new _bluffer2.default;return this.client.rawRequest({method:"GET",url:url},{bluffer:true}).then(function(response){return response.body}).then(function(buffer){return bluffer.readBase64(buffer)}).then(function(buffer){return _this2.client.crypto().decryptBytes(buffer,envelope,_this2.client.session.privateKeyPEM,[],["unzip"])}).then(function(base64){return bluffer.createBase64(base64)}).then(function(buffer){return bluffer.readArrayBuffer(buffer)}).then(function(ab){return _this2.client.protobuf().ExtractedText(ab)})};return ProofsAssetsExtractedText}(_API3.default);exports.default=ProofsAssetsExtractedText;
1
+ "use strict";exports.__esModule=true;var _API2=require("./API");var _API3=_interopRequireDefault(_API2);var _whatwgURL=require("../util/whatwgURL");var _whatwgURL2=_interopRequireDefault(_whatwgURL);var _bluffer=require("../bluffer");var _bluffer2=_interopRequireDefault(_bluffer);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 ProofsAssetsExtractedText=function(_API){_inherits(ProofsAssetsExtractedText,_API);function ProofsAssetsExtractedText(){_classCallCheck(this,ProofsAssetsExtractedText);return _possibleConstructorReturn(this,_API.apply(this,arguments))}ProofsAssetsExtractedText.prototype.resources=function resources(proofId){return this.client.request("proofs.assets.extracted-text",{proofId:proofId}).then(function(response){return response.data.result})};ProofsAssetsExtractedText.prototype.download=function download(resources,pageNumber){var _this2=this;var matchingPages=resources.pages.filter(function(page){return page.number===pageNumber});if(!matchingPages||!matchingPages.length){return Promise.reject(new Error("Page does not contain any text."))}var envelope=resources.envelope;var url=new _whatwgURL2.default(matchingPages[0].chunks[0].url);var bluffer=new _bluffer2.default;return this.client.rawRequest({method:"GET",url:url},{bluffer:true}).then(function(response){return response.body}).then(function(buffer){return bluffer.readBase64(buffer)}).then(function(buffer){return _this2.client.crypto().decryptBytes(buffer,envelope,_this2.client.session.privateKeyPEM,[],["unzip"])}).then(function(base64){return bluffer.createBase64(base64)}).then(function(buffer){return bluffer.readArrayBuffer(buffer)}).then(function(ab){return _this2.client.protobuf().ExtractedText(ab)})};return ProofsAssetsExtractedText}(_API3.default);exports.default=ProofsAssetsExtractedText;
@@ -42,17 +42,16 @@ declare class ProofsCustomTools extends API {
42
42
  /**
43
43
  * Loads the custom tools definition for a proof.
44
44
  *
45
- * @param {string} proofId The proof ID
46
- * @returns {Promise<any>}
45
+ * @param {string} proofId
46
+ * @returns {any}
47
47
  */
48
- load(proofId: string): Promise<any>;
48
+ load(proofId: string): any;
49
49
  /**
50
50
  * Updates a custom tools definition for a proof.
51
51
  *
52
- * @param {string} proofId The proof ID
52
+ * @param {string} proofId
53
53
  * @param {any} updates
54
- * @returns {Promise<any>}
55
54
  */
56
- update(proofId: string, updates: any): Promise<any>;
55
+ update(proofId: string, updates: any): any;
57
56
  }
58
57
  import API from "./API";