@pageproof/sdk-pr 461.0.1660865393217 → 462.0.1661390350802
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +60 -68
- package/lib/adapters/WorkerThreadsCryptoAdapter.d.ts +17 -0
- package/lib/adapters/WorkerThreadsCryptoAdapter.js +1 -0
- package/lib/api/Proofs.d.ts +4 -10
- package/lib/api/Proofs.js +1 -1
- package/lib/models/Proof.d.ts +0 -8
- package/lib/models/Proof.js +1 -1
- package/lib/pageproof.js +1 -1
- package/lib/types/ProofForUpdateDefinition.d.ts +0 -4
- package/lib/util/Scheduler.js +1 -1
- package/lib/worker/WorkerThreadsWorker.d.ts +1 -0
- package/lib/worker/WorkerThreadsWorker.js +1 -0
- package/lib/worker-crypto-adapter.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.298
|
|
4
|
+
|
|
5
|
+
Released on the 25th of August 2022.
|
|
6
|
+
|
|
7
|
+
- [[PP-3723](https://goto.pageproof.dev/PP-3723)] Added a new crypto adapter for Node.js that makes use of `worker_threads`. See [WorkerThreadsCryptoAdapter](https://docs.pageproof.tech/@pageproof/sdk/beta/class/src/adapters/WorkerThreadsCryptoAdapter.js~WorkerThreadsCryptoAdapter.html).
|
|
8
|
+
|
|
3
9
|
## 2.0.0-beta.297
|
|
4
10
|
|
|
5
11
|
Released on the 17th of August 2022.
|
package/README.md
CHANGED
|
@@ -66,14 +66,14 @@ import XHRRequestAdapter from '@pageproof/sdk/lib/xhr-request-adapter';
|
|
|
66
66
|
// ...
|
|
67
67
|
|
|
68
68
|
new XHRRequestAdapter({
|
|
69
|
+
endpoint: 'https://api.pageproof.com',
|
|
69
70
|
applicationId: '3uQkbQXsinffvnNHPlplx4Uw1sVeWEab',
|
|
70
|
-
endpoint: 'https://managed-api.pageproof.com',
|
|
71
71
|
key: '104882dfa7c44330811612ea100dc7e6',
|
|
72
72
|
});
|
|
73
73
|
```
|
|
74
74
|
|
|
75
75
|
As you can see, the adapter takes an `endpoint` and a `key`. For 3rd party developers & integrating PageProof into your
|
|
76
|
-
own application, the endpoint is `https://
|
|
76
|
+
own application, the endpoint is `https://api.pageproof.com`, and the key is your application's subscription
|
|
77
77
|
key. In production, however, it's best to make your key an environment variable to make it easier to change it later.
|
|
78
78
|
|
|
79
79
|
#### Example: Low powered devices
|
|
@@ -90,11 +90,13 @@ import XHRRequestAdapter from '@pageproof/sdk/lib/xhr-request-adapter';
|
|
|
90
90
|
import WorkerCryptoAdapter from '@pageproof/sdk/lib/worker-crypto-adapter';
|
|
91
91
|
|
|
92
92
|
const client = new PageProof({
|
|
93
|
+
options: {
|
|
94
|
+
endpoint: 'https://api.pageproof.com',
|
|
95
|
+
applicationId: '3uQkbQXsinffvnNHPlplx4Uw1sVeWEab',
|
|
96
|
+
subscriptionKey: '104882dfa7c44330811612ea100dc7e6',
|
|
97
|
+
},
|
|
93
98
|
adapters: [
|
|
94
|
-
new XHRRequestAdapter(
|
|
95
|
-
endpoint: 'https://managed-api.pageproof.com',
|
|
96
|
-
key: '104882dfa7c44330811612ea100dc7e6',
|
|
97
|
-
}),
|
|
99
|
+
new XHRRequestAdapter(),
|
|
98
100
|
new WorkerCryptoAdapter({
|
|
99
101
|
url: 'https://example.com/dist/pageproof/sdk/lib',
|
|
100
102
|
limit: 1,
|
|
@@ -128,12 +130,13 @@ import XHRRequestAdapter from '@pageproof/sdk/lib/xhr-request-adapter';
|
|
|
128
130
|
import WorkerCryptoAdapter from '@pageproof/sdk/lib/worker-crypto-adapter';
|
|
129
131
|
|
|
130
132
|
const client = new PageProof({
|
|
133
|
+
options: {
|
|
134
|
+
endpoint: 'https://api.pageproof.com',
|
|
135
|
+
applicationId: '3uQkbQXsinffvnNHPlplx4Uw1sVeWEab',
|
|
136
|
+
subscriptionKey: '104882dfa7c44330811612ea100dc7e6',
|
|
137
|
+
},
|
|
131
138
|
adapters: [
|
|
132
|
-
new XHRRequestAdapter(
|
|
133
|
-
applicationId: '3uQkbQXsinffvnNHPlplx4Uw1sVeWEab',
|
|
134
|
-
endpoint: 'https://managed-api.pageproof.com',
|
|
135
|
-
key: '104882dfa7c44330811612ea100dc7e6',
|
|
136
|
-
}),
|
|
139
|
+
new XHRRequestAdapter(),
|
|
137
140
|
new WorkerCryptoAdapter({
|
|
138
141
|
url: 'https://example.com/dist/@pageproof/sdk/lib',
|
|
139
142
|
limit: navigator.hardwareConcurrency || 2,
|
|
@@ -256,21 +259,22 @@ request, but if we get enough demand for your JavaScript environment, it will be
|
|
|
256
259
|
|
|
257
260
|
We have a number of adapters, some intended for use within browsers, and some for Node.js.
|
|
258
261
|
|
|
259
|
-
Name |
|
|
262
|
+
Name | Supported Environment | Import Path | Supported
|
|
260
263
|
--- | --- | --- | ---
|
|
261
|
-
[
|
|
262
|
-
[NodeRequestAdapter](./class/src/adapters/NodeRequestAdapter.js~NodeRequestAdapter.html) | `@pageproof/sdk/lib/adapters/NodeRequestAdapter.js` |
|
|
263
|
-
[SyncCryptoAdapter](./class/src/adapters/SyncCryptoAdapter.js~SyncCryptoAdapter.html) | `@pageproof/sdk/lib/adapters/SyncCryptoAdapter.js` |
|
|
264
|
-
[WorkerCryptoAdapter](./class/src/adapters/WorkerCryptoAdapter.js~WorkerCryptoAdapter.html) | `@pageproof/sdk/lib/worker-crypto-adapter.js` |
|
|
265
|
-
[XHRRequestAdapter](./class/src/adapters/XHRRequestAdapter.js~XHRRequestAdapter.html) | `@pageproof/sdk/lib/xhr-request-adapter.js` |
|
|
266
|
-
[IndexedDBCacheAdapter](./class/src/adapters/IndexedDBCacheAdapter.js~IndexedDBCacheAdapter.html) | `@pageproof/sdk/lib/indexeddb-cache-adapter.js` |
|
|
267
|
-
[AngularEnhancementAdapter](./class/src/adapters/AngularEnhancementAdapter.js~AngularEnhancementAdapter.html) | `@pageproof/sdk/lib/angular-enhancement-adapter.js` |
|
|
268
|
-
[ProtobufAdapter](./class/src/adapters/ProtobufAdapter.js~ProtobufAdapter.html) | `@pageproof/sdk/lib/protobuf-adapter.js` |
|
|
269
|
-
[ProtobufAdapter](./class/src/adapters/ProtobufAdapter.js~ProtobufAdapter.html) | `@pageproof/sdk/lib/adapters/ProtobufAdapter.js` |
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
264
|
+
[WorkerThreadsCryptoAdapter](./class/src/adapters/WorkerThreadsCryptoAdapter.js~WorkerThreadsCryptoAdapter.html) | Node.js | `@pageproof/sdk/lib/adapters/WorkerThreadsCryptoAdapter.js` | ✔️
|
|
265
|
+
[NodeRequestAdapter](./class/src/adapters/NodeRequestAdapter.js~NodeRequestAdapter.html) | Node.js | `@pageproof/sdk/lib/adapters/NodeRequestAdapter.js` | ✔️
|
|
266
|
+
[SyncCryptoAdapter](./class/src/adapters/SyncCryptoAdapter.js~SyncCryptoAdapter.html) | Any | `@pageproof/sdk/lib/adapters/SyncCryptoAdapter.js` | \*
|
|
267
|
+
[WorkerCryptoAdapter](./class/src/adapters/WorkerCryptoAdapter.js~WorkerCryptoAdapter.html) | Browser | `@pageproof/sdk/lib/worker-crypto-adapter.js` | ✔️
|
|
268
|
+
[XHRRequestAdapter](./class/src/adapters/XHRRequestAdapter.js~XHRRequestAdapter.html) | Browser | `@pageproof/sdk/lib/xhr-request-adapter.js` | ✔️
|
|
269
|
+
[IndexedDBCacheAdapter](./class/src/adapters/IndexedDBCacheAdapter.js~IndexedDBCacheAdapter.html) | Browser | `@pageproof/sdk/lib/indexeddb-cache-adapter.js` | ✔️
|
|
270
|
+
[AngularEnhancementAdapter](./class/src/adapters/AngularEnhancementAdapter.js~AngularEnhancementAdapter.html) | Browser | `@pageproof/sdk/lib/angular-enhancement-adapter.js` |
|
|
271
|
+
[ProtobufAdapter](./class/src/adapters/ProtobufAdapter.js~ProtobufAdapter.html) | Browser | `@pageproof/sdk/lib/protobuf-adapter.js` |
|
|
272
|
+
[ProtobufAdapter](./class/src/adapters/ProtobufAdapter.js~ProtobufAdapter.html) | Node.js | `@pageproof/sdk/lib/adapters/ProtobufAdapter.js` |
|
|
273
|
+
[ClusterCryptoAdapter](./class/src/adapters/ClusterCryptoAdapter.js~ClusterCryptoAdapter.html) | Node.js | `@pageproof/sdk/lib/adapters/ClusterCryptoAdapter.js` | ✔️ \*\*
|
|
274
|
+
|
|
275
|
+
_\* The `SyncCryptoAdapter` should only be used if the environment you're running in does not support any of the other crypto adapters._
|
|
276
|
+
|
|
277
|
+
_\*\* The `ClusterCryptoAdapter` is not recommended. If you're already using the `ClusterCryptoAdapter`, we suggest swapping it out for `WorkerThreadsCryptoAdapter` as it uses less CPU, memory, and is 4x faster (on average) than `ClusterCryptoAdapter`. While it's still something we plan on supporting, it's not something we suggest using in new applications._
|
|
274
278
|
|
|
275
279
|
Also note, the browser adapters have a slightly different filename/path, this is because these files come pre-minified,
|
|
276
280
|
with UMD support (CommonJS, ES2015+ import/export, and `<script>`).
|
|
@@ -282,41 +286,41 @@ of our APIs are compartmentalized, to make it easier to find the API you're look
|
|
|
282
286
|
|
|
283
287
|
These are the different APIs we currently support through the SDK.
|
|
284
288
|
|
|
285
|
-
Name | Namespace | Description | Admin-only
|
|
286
|
-
--- | --- | --- | ---
|
|
287
|
-
[Accounts API](./class/src/api/Accounts.js~Accounts.html) | `accounts` | Used to create accounts, activate and login. |
|
|
288
|
-
[Accounts SSO API](./class/src/api/AccountsSSO.js~AccountsSSO.html) | `accounts.sso` | Used to login using a SSO provider. |
|
|
289
|
-
[Accounts MFA API](./class/src/api/AccountsMFA.js~AccountsMFA.html) | `accounts.mfa` | Used to activate, de-activate and enable user mfa login. |
|
|
290
|
-
[Comments API](./class/src/api/Comments.js~Comments.html) | `comments` | Used to load comments. |
|
|
291
|
-
[Dashboard API](./class/src/api/Dashboard.js~Dashboard.html) | `dashboard` | Used to load the authenticated user's dashboard & search for/filter proofs. |
|
|
292
|
-
[Dashboard Groups API](./class/src/api/DashboardGroups.js~DashboardGroups.html) | `dashboard.groups` | Used to load proof groups |
|
|
293
|
-
[Encryption API](./class/src/api/Encryption.js~Encryption.html) | `encryption` | Used for generic crypto operations. |
|
|
294
|
-
[Files API](./class/src/api/Files.js~Files.html) | `files` | Used to upload & manage files. |
|
|
295
|
-
[Preferences API](./class/src/api/Preferences.js~Preferences.html) | `preferences` | Manage your account preferences. |
|
|
296
|
-
[Profile API](./class/src/api/Profile.js~Profile.html) | `profile` | Manage your account details. |
|
|
297
|
-
[Proofs API](./class/src/api/Proofs.js~Proofs.html) | `proofs` | Used to create & manage proofs. |
|
|
298
|
-
[Proofs Groups API](./class/src/api/ProofsGroups.js~ProofsGroups.html) | `proofs.groups` | Used to manage groups of proofs. |
|
|
299
|
-
[Proofs Owners API](./class/src/api/ProofsOwners.js~ProofsOwners.html) | `proofs.owners` | Used to add & remove owners from proofs. |
|
|
300
|
-
[Proofs Versions API](./class/src/api/ProofsVersions.js~ProofsVersions.html) | `proofs.versions` | Used to manage proof versions. |
|
|
301
|
-
[Sessions API](./class/src/api/Sessions.js~Sessions.html) | `sessions` | Used to manage account sessions. |
|
|
302
|
-
[Users API](./class/src/api/Users.js~Users.html) | `users` | Used to invite and find users in the system. |
|
|
303
|
-
[Workflows API](./class/src/api/Workflows.js~Workflows.html) | `workflows` | Used to create & manage workflows and workflow templates. |
|
|
304
|
-
[Workflows Steps API](./class/src/api/WorkflowsSteps.js~WorkflowsSteps.html) | `workflows.steps` | Used to manage workflow steps in workflow templates. |
|
|
305
|
-
[Admin Team Users API](./class/src/api/admin/TeamUsers.js~TeamUsers.html) | `admin.team.users` | Administer users in a team or enterprise account. |
|
|
306
|
-
[Admin Team Dashboard API](./class/src/api/admin/TeamDashboard.js~TeamDashboard.html) | `admin.team.dashboard` | Used to load the authenticated user's team's dashboard & search for/filter proofs. |
|
|
307
|
-
[Admin Team Features API](./class/src/api/admin/TeamFeatures.js~TeamFeatures.html) | `admin.team.features` | Administer features in a team or enterprise account. |
|
|
308
|
-
[Proofs Editors API](./class/src/api/ProofsEditors.js~ProofsEditors.html) | `proofs.editors` | Used to add & remove editors from proofs. |
|
|
309
|
-
[Proofs Groups Owners API](./class/src/api/GroupsOwners.js~GroupsOwners.html) | `proofs.groups.owners` | Used to add owners to proofs in a group. |
|
|
310
|
-
[Proofs Groups Workflows API](./class/src/api/GroupsWorkflows.js~GroupsWorkflows.html) | `proofs.groups.workflows` | Used to add reviewers to proofs in a group. |
|
|
311
|
-
[Proofs Reminders API](./class/src/api/Reminders.js~Reminders.html) | `proofs.reminders` | Manage reminders on proof. |
|
|
312
|
-
[Proofs Audit API](./class/src/api/ProofsAudit.js~ProofsAudit.html) | `proofs.audit` | View audit reports/summary/timeline. |
|
|
313
|
-
[Proofs Custom Tools API](./class/src/api/ProofsCustomTools.js~ProofsCustomTools.html) | `proofs.customTools` | Validate, update and retrieve proof custom tools. |
|
|
314
|
-
[Admin Reports API](./class/src/api/Reports.js~Reports.html) | `admin.reports` | Request reports to be emailed to you. |
|
|
289
|
+
Name | Namespace | Description | Admin-only
|
|
290
|
+
--- | --- | --- | ---
|
|
291
|
+
[Accounts API](./class/src/api/Accounts.js~Accounts.html) | `accounts` | Used to create accounts, activate and login. |
|
|
292
|
+
[Accounts SSO API](./class/src/api/AccountsSSO.js~AccountsSSO.html) | `accounts.sso` | Used to login using a SSO provider. |
|
|
293
|
+
[Accounts MFA API](./class/src/api/AccountsMFA.js~AccountsMFA.html) | `accounts.mfa` | Used to activate, de-activate and enable user mfa login. |
|
|
294
|
+
[Comments API](./class/src/api/Comments.js~Comments.html) | `comments` | Used to load comments. |
|
|
295
|
+
[Dashboard API](./class/src/api/Dashboard.js~Dashboard.html) | `dashboard` | Used to load the authenticated user's dashboard & search for/filter proofs. |
|
|
296
|
+
[Dashboard Groups API](./class/src/api/DashboardGroups.js~DashboardGroups.html) | `dashboard.groups` | Used to load proof groups |
|
|
297
|
+
[Encryption API](./class/src/api/Encryption.js~Encryption.html) | `encryption` | Used for generic crypto operations. |
|
|
298
|
+
[Files API](./class/src/api/Files.js~Files.html) | `files` | Used to upload & manage files. |
|
|
299
|
+
[Preferences API](./class/src/api/Preferences.js~Preferences.html) | `preferences` | Manage your account preferences. |
|
|
300
|
+
[Profile API](./class/src/api/Profile.js~Profile.html) | `profile` | Manage your account details. |
|
|
301
|
+
[Proofs API](./class/src/api/Proofs.js~Proofs.html) | `proofs` | Used to create & manage proofs. |
|
|
302
|
+
[Proofs Groups API](./class/src/api/ProofsGroups.js~ProofsGroups.html) | `proofs.groups` | Used to manage groups of proofs. |
|
|
303
|
+
[Proofs Owners API](./class/src/api/ProofsOwners.js~ProofsOwners.html) | `proofs.owners` | Used to add & remove owners from proofs. |
|
|
304
|
+
[Proofs Versions API](./class/src/api/ProofsVersions.js~ProofsVersions.html) | `proofs.versions` | Used to manage proof versions. |
|
|
305
|
+
[Sessions API](./class/src/api/Sessions.js~Sessions.html) | `sessions` | Used to manage account sessions. |
|
|
306
|
+
[Users API](./class/src/api/Users.js~Users.html) | `users` | Used to invite and find users in the system. |
|
|
307
|
+
[Workflows API](./class/src/api/Workflows.js~Workflows.html) | `workflows` | Used to create & manage workflows and workflow templates. |
|
|
308
|
+
[Workflows Steps API](./class/src/api/WorkflowsSteps.js~WorkflowsSteps.html) | `workflows.steps` | Used to manage workflow steps in workflow templates. |
|
|
309
|
+
[Admin Team Users API](./class/src/api/admin/TeamUsers.js~TeamUsers.html) | `admin.team.users` | Administer users in a team or enterprise account. | ✔️
|
|
310
|
+
[Admin Team Dashboard API](./class/src/api/admin/TeamDashboard.js~TeamDashboard.html) | `admin.team.dashboard` | Used to load the authenticated user's team's dashboard & search for/filter proofs. | ✔️
|
|
311
|
+
[Admin Team Features API](./class/src/api/admin/TeamFeatures.js~TeamFeatures.html) | `admin.team.features` | Administer features in a team or enterprise account. | ✔️
|
|
312
|
+
[Proofs Editors API](./class/src/api/ProofsEditors.js~ProofsEditors.html) | `proofs.editors` | Used to add & remove editors from proofs. |
|
|
313
|
+
[Proofs Groups Owners API](./class/src/api/GroupsOwners.js~GroupsOwners.html) | `proofs.groups.owners` | Used to add owners to proofs in a group. |
|
|
314
|
+
[Proofs Groups Workflows API](./class/src/api/GroupsWorkflows.js~GroupsWorkflows.html) | `proofs.groups.workflows` | Used to add reviewers to proofs in a group. |
|
|
315
|
+
[Proofs Reminders API](./class/src/api/Reminders.js~Reminders.html) | `proofs.reminders` | Manage reminders on proof. |
|
|
316
|
+
[Proofs Audit API](./class/src/api/ProofsAudit.js~ProofsAudit.html) | `proofs.audit` | View audit reports/summary/timeline. |
|
|
317
|
+
[Proofs Custom Tools API](./class/src/api/ProofsCustomTools.js~ProofsCustomTools.html) | `proofs.customTools` | Validate, update and retrieve proof custom tools. |
|
|
318
|
+
[Admin Reports API](./class/src/api/Reports.js~Reports.html) | `admin.reports` | Request reports to be emailed to you. | ✔️
|
|
315
319
|
|
|
316
320
|
The "admin-only" APIs are exposed through the
|
|
317
321
|
[PageProof.admin](./class/src/core/PageProof.js~PageProof.html#instance-method-admin) method. These APIs are different
|
|
318
322
|
because the SDK only allows access to this subset of APIs if the current user is an administrator of a team/enterprise
|
|
319
|
-
account.
|
|
323
|
+
account.
|
|
320
324
|
|
|
321
325
|
To explain what the "namespace" is used for, take this example. You would like to find a user in PageProof with a
|
|
322
326
|
particular email. That would mean using the "Users API", which has a namespace of `users`. So that would look like this;
|
|
@@ -378,15 +382,3 @@ refreshes, we need to remind the client what the current session is.
|
|
|
378
382
|
Sharing the private keys with anybody, directly or even indirectly (over unencrypted traffic, for example), gives
|
|
379
383
|
anybody the ability to access & decrypt all proofs you have access to, including those you have been invited to.
|
|
380
384
|
|
|
381
|
-
### SDK development
|
|
382
|
-
Local development:
|
|
383
|
-
1. Node version <= 6
|
|
384
|
-
```sh
|
|
385
|
-
$ npm install
|
|
386
|
-
$ npm run dev
|
|
387
|
-
```
|
|
388
|
-
2. To test the SDK locally: switch to node version >=12, then
|
|
389
|
-
```sh
|
|
390
|
-
$ cd examples
|
|
391
|
-
$ node ./basic-node/index.js
|
|
392
|
-
```
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export default WorkerThreadsCryptoAdapter;
|
|
2
|
+
declare class WorkerThreadsCryptoAdapter extends SchedulerCryptoAdapter {
|
|
3
|
+
/**
|
|
4
|
+
* @param {object} [options]
|
|
5
|
+
* @param {number|null|undefined} [options.limit] The maximum number of worker threads that can be created for this instance of the adapter (defaults to the same number of CPUs as the host machine, as reported by Node.js).
|
|
6
|
+
* @param {boolean} [options.optimistic] Whether to immediately create the maximum number of worker threads (reduces cold start times).
|
|
7
|
+
*/
|
|
8
|
+
constructor(options?: {
|
|
9
|
+
limit?: number;
|
|
10
|
+
optimistic?: boolean;
|
|
11
|
+
});
|
|
12
|
+
options: {
|
|
13
|
+
limit?: number;
|
|
14
|
+
optimistic?: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
import SchedulerCryptoAdapter from "./SchedulerCryptoAdapter";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";exports.__esModule=true;var _worker_threads=require("worker_threads");var _os=require("os");var _os2=_interopRequireDefault(_os);var _path=require("path");var _path2=_interopRequireDefault(_path);var _EventEmitter2=require("../events/EventEmitter");var _EventEmitter3=_interopRequireDefault(_EventEmitter2);var _SchedulerCryptoAdapter=require("./SchedulerCryptoAdapter");var _SchedulerCryptoAdapter2=_interopRequireDefault(_SchedulerCryptoAdapter);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 workerPath=_path2.default.resolve(__dirname,"../worker/WorkerThreadsWorker.js");var WorkerThreadsWorker=function(_EventEmitter){_inherits(WorkerThreadsWorker,_EventEmitter);function WorkerThreadsWorker(){_classCallCheck(this,WorkerThreadsWorker);var _this=_possibleConstructorReturn(this,_EventEmitter.call(this));var worker=new _worker_threads.Worker(workerPath);worker.on("message",function(message){return _this.emit("message",message)});worker.on("exit",function(exitCode){return _this.emit("exit",exitCode)});_this.workerThread=worker;return _this}WorkerThreadsWorker.prototype.postMessage=function postMessage(message){this.workerThread.postMessage(message)};return WorkerThreadsWorker}(_EventEmitter3.default);var WorkerThreadsCryptoAdapter=function(_SchedulerCryptoAdapt){_inherits(WorkerThreadsCryptoAdapter,_SchedulerCryptoAdapt);function WorkerThreadsCryptoAdapter(){var options=arguments.length>0&&arguments[0]!==undefined?arguments[0]:{};_classCallCheck(this,WorkerThreadsCryptoAdapter);if(!_worker_threads.isMainThread){throw new Error("Cannot create a WorkerThreadsCryptoAdapter within a worker.")}var _this2=_possibleConstructorReturn(this,_SchedulerCryptoAdapt.call(this,{limit:options.limit||_os2.default.cpus().length,create:function create(){return new WorkerThreadsWorker}}));if(options.optimistic){_this2.scheduler.prime()}_this2.options=options;return _this2}return WorkerThreadsCryptoAdapter}(_SchedulerCryptoAdapter2.default);exports.default=WorkerThreadsCryptoAdapter;
|
package/lib/api/Proofs.d.ts
CHANGED
|
@@ -177,7 +177,7 @@ declare class Proofs extends API {
|
|
|
177
177
|
*
|
|
178
178
|
* @see {@link Proofs.start}
|
|
179
179
|
*
|
|
180
|
-
* @param {{ name: string, tags?: string[], dueDate?: Date | string, messageToReviewers?: string, workflow?: { id: string }, workflowTemplate?: { id: string }, checklist?: { templateId?: string, isRequiredForFinalApproval?: boolean, shouldOpenOnProofLoad?: boolean }, file?: { id: string }, group?: { id: string }, previousProof?: { id: string }, team?: { slug: string }, reference?: string, customTools?: any, integrationReferences?: any[], reminders?: Reminder[], owners?: { email?: string, id?: string }[],
|
|
180
|
+
* @param {{ name: string, tags?: string[], dueDate?: Date | string, messageToReviewers?: string, workflow?: { id: string }, workflowTemplate?: { id: string }, checklist?: { templateId?: string, isRequiredForFinalApproval?: boolean, shouldOpenOnProofLoad?: boolean }, file?: { id: string }, group?: { id: string }, previousProof?: { id: string }, team?: { slug: string }, reference?: string, customTools?: any, integrationReferences?: any[], reminders?: Reminder[], owners?: { email?: string, id?: string }[], canDownload?: boolean, start?: boolean }} options The options
|
|
181
181
|
*
|
|
182
182
|
* @param options.name The name of the proof
|
|
183
183
|
* @param [options.tags] The tags to add to the proof (defaults to no tags)
|
|
@@ -197,13 +197,12 @@ declare class Proofs extends API {
|
|
|
197
197
|
* @param [options.integrationReferences] The integration references to attach to the proof
|
|
198
198
|
* @param [options.reminders] The proof reminders to add the proof to (to nudge users)
|
|
199
199
|
* @param [options.owners] The users to assign as owners for the proof (if omitted and a new version, the previous version's owners are inherited, otherwise, the user creating the proof is assigned as the only owner)
|
|
200
|
-
* @param [options.emailSender] The user to assign as the email sender for the proof invitations and reminders
|
|
201
200
|
* @param [options.canDownload] Whether the file attached to the proof can be download
|
|
202
201
|
* @param [options.isPublic] Whether the proof is publicly accessible
|
|
203
202
|
* @param [options.start] Whether to immediately start the proof (sends invitation emails to reviewers in the workflow)
|
|
204
203
|
* @returns {Promise<Proof>}
|
|
205
204
|
*/
|
|
206
|
-
create({ name, tags, dueDate, messageToReviewers, workflow, workflowTemplate, checklist, file, group, previousProof, team, reference, customTools, integrationReferences, reminders, owners,
|
|
205
|
+
create({ name, tags, dueDate, messageToReviewers, workflow, workflowTemplate, checklist, file, group, previousProof, team, reference, customTools, integrationReferences, reminders, owners, canDownload, isPublic, start, }: {
|
|
207
206
|
name: string;
|
|
208
207
|
tags?: string[];
|
|
209
208
|
dueDate?: string | Date;
|
|
@@ -239,12 +238,7 @@ declare class Proofs extends API {
|
|
|
239
238
|
email?: string;
|
|
240
239
|
id?: string;
|
|
241
240
|
}[];
|
|
242
|
-
emailSender?: {
|
|
243
|
-
email?: string;
|
|
244
|
-
id?: string;
|
|
245
|
-
};
|
|
246
241
|
canDownload?: boolean;
|
|
247
|
-
isPublic?: boolean;
|
|
248
242
|
start?: boolean;
|
|
249
243
|
}): Promise<Proof>;
|
|
250
244
|
/**
|
|
@@ -484,7 +478,7 @@ declare class Proofs extends API {
|
|
|
484
478
|
/**
|
|
485
479
|
* Updates one or many proofs.
|
|
486
480
|
*
|
|
487
|
-
* Currently supported fields which can be updated
|
|
481
|
+
* Currently supported fields which can be updated are:
|
|
488
482
|
* * Due date
|
|
489
483
|
*
|
|
490
484
|
* @example <caption>Update due date of a proof</caption>
|
|
@@ -507,7 +501,7 @@ declare class Proofs extends API {
|
|
|
507
501
|
* ]);
|
|
508
502
|
*
|
|
509
503
|
* @since v2.0.0-beta.127
|
|
510
|
-
* @param {ProofForUpdateDefinition|Array<ProofForUpdateDefinition>} proofOrProofs The proof or list of proofs to update
|
|
504
|
+
* @param {ProofForUpdateDefinition|Array<ProofForUpdateDefinition>} proofOrProofs The proof or list of proofs to update due date
|
|
511
505
|
* @returns {Promise}
|
|
512
506
|
*/
|
|
513
507
|
update(proofOrProofs: ProofForUpdateDefinition | ProofForUpdateDefinition[]): Promise<any>;
|
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 _ProofsDecisions=require("./ProofsDecisions");var _ProofsDecisions2=_interopRequireDefault(_ProofsDecisions);var _Proof=require("../models/Proof");var _Proof2=_interopRequireDefault(_Proof);var _Reminders=require("./Reminders");var _Reminders2=_interopRequireDefault(_Reminders);var _whatwgURL=require("../util/whatwgURL");var _whatwgURL2=_interopRequireDefault(_whatwgURL);var _constants=require("../util/constants");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 VIDEO_URL_TOKEN_SEPARATOR="|";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);_this.decisions=new _ProofsDecisions2.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,checklist=_ref.checklist,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,emailSender=_ref.emailSender,canDownload=_ref.canDownload,isPublic=_ref.isPublic,_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?dueDate.toISOString():String(dueDate),messageToReviewers:messageToReviewers,workflowId:workflow&&workflow.id||undefined,workflowTemplateId:workflowTemplate&&workflowTemplate.id||undefined,checklist:checklist,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,emailSender:emailSender,canDownload:canDownload,isPublic:isPublic,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(proofIdOrIds){return this.client.request("proofs.return",{proofIds:[].concat(proofIdOrIds)}).then(function(response){return{proofIds:response.data.ProofIds,errors:response.data.Errors.map(function(error){return{proofId:error.ProofId,errorCode:error.ErrorCode,errorMessage:error.ErrorMessage}})}})};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.videoCredentials=function videoCredentials(proofId){var _this5=this;return this.client.cache.auto(_constants.VIDEO_CREDENTIALS_CACHE_PREFIX+proofId,function(){return _this5._videoCredentials(proofId)})};Proofs.prototype._videoCredentials=function _videoCredentials(proofId){var _this6=this;var bluffer=new _bluffer2.default;return this.client.request("proofs.video-credentials",{proofId:proofId}).then(function(response){return Promise.all([response.data.envelope.envelope,_this6.client.rawRequest({method:"GET",url:new _whatwgURL2.default(response.data.videoCredentials.url)}).then(function(videoCredentialsResponse){return videoCredentialsResponse.body})])}).then(function(_ref2){var envelope=_ref2[0],videoCredentials$=_ref2[1];return _this6.client.crypto().decryptImage(envelope+"-"+videoCredentials$,_this6.client.keyPairs.getPrivateKeyPEMs())}).then(function(videoCredentialsBase64){return bluffer.createBase64(videoCredentialsBase64).then(function(buffer){return bluffer.read(buffer)})}).then(function(videoCredentials){var _videoCredentials$spl=videoCredentials.split(VIDEO_URL_TOKEN_SEPARATOR),url=_videoCredentials$spl[0],bearerToken=_videoCredentials$spl[1];var manifestUrl=url.replace("http://","https://");manifestUrl+="/manifest";return{manifestUrl:manifestUrl,bearerToken:bearerToken}})};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,_ref3){var messageToOwners=_ref3.messageToOwners,_ref3$markCommentsAsT=_ref3.markCommentsAsTodo,markCommentsAsTodo=_ref3$markCommentsAsT===undefined?false:_ref3$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,checklist=_concat$.checklist,file=_concat$.file,reference=_concat$.reference,integrationReferences=_concat$.integrationReferences,reminders=_concat$.reminders,owners=_concat$.owners,emailSender=_concat$.emailSender,canDownload=_concat$.canDownload,isPublic=_concat$.isPublic,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,checklist:checklist,fileId:file&&file.id||undefined,reference:reference,integrationReferences:integrationReferences,reminders:reminders?[].concat(reminders):undefined,owners:owners,emailSender:emailSender,canDownload:canDownload,isPublic:isPublic,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)})};Proofs.prototype.addWorkflow=function addWorkflow(proofIdOrIds,workflowTemplateId){return this.client.request("proofs-workflow.add-bulk",{proofIds:[].concat(proofIdOrIds),workflowTemplateId:workflowTemplateId})};Proofs.prototype.sendShareLink=function sendShareLink(_ref4){var proofId=_ref4.proofId,message=_ref4.message,emailAddresses=_ref4.emailAddresses;return this.client.request("proofs.send-share-link",{proofId:proofId,message:message,emailAddresses:emailAddresses})};Proofs.prototype.getWorkflowMetrics=function getWorkflowMetrics(proofId){return this.client.request("proofs.get-workflow-metrics",{proofId:proofId}).then(function(response){if(response.data){return response.data.workflowMetrics}return null})};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 _ProofsIntegrationReferences=require("./ProofsIntegrationReferences");var _ProofsIntegrationReferences2=_interopRequireDefault(_ProofsIntegrationReferences);var _ProofsLinkCheck=require("./ProofsLinkCheck");var _ProofsLinkCheck2=_interopRequireDefault(_ProofsLinkCheck);var _ProofsDecisions=require("./ProofsDecisions");var _ProofsDecisions2=_interopRequireDefault(_ProofsDecisions);var _Proof=require("../models/Proof");var _Proof2=_interopRequireDefault(_Proof);var _Reminders=require("./Reminders");var _Reminders2=_interopRequireDefault(_Reminders);var _whatwgURL=require("../util/whatwgURL");var _whatwgURL2=_interopRequireDefault(_whatwgURL);var _constants=require("../util/constants");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 VIDEO_URL_TOKEN_SEPARATOR="|";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);_this.decisions=new _ProofsDecisions2.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,checklist=_ref.checklist,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,isPublic=_ref.isPublic,_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?dueDate.toISOString():String(dueDate),messageToReviewers:messageToReviewers,workflowId:workflow&&workflow.id||undefined,workflowTemplateId:workflowTemplate&&workflowTemplate.id||undefined,checklist:checklist,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,isPublic:isPublic,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(proofIdOrIds){return this.client.request("proofs.return",{proofIds:[].concat(proofIdOrIds)}).then(function(response){return{proofIds:response.data.ProofIds,errors:response.data.Errors.map(function(error){return{proofId:error.ProofId,errorCode:error.ErrorCode,errorMessage:error.ErrorMessage}})}})};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.videoCredentials=function videoCredentials(proofId){var _this5=this;return this.client.cache.auto(_constants.VIDEO_CREDENTIALS_CACHE_PREFIX+proofId,function(){return _this5._videoCredentials(proofId)})};Proofs.prototype._videoCredentials=function _videoCredentials(proofId){var _this6=this;var bluffer=new _bluffer2.default;return this.client.request("proofs.video-credentials",{proofId:proofId}).then(function(response){return Promise.all([response.data.envelope.envelope,_this6.client.rawRequest({method:"GET",url:new _whatwgURL2.default(response.data.videoCredentials.url)}).then(function(videoCredentialsResponse){return videoCredentialsResponse.body})])}).then(function(_ref2){var envelope=_ref2[0],videoCredentials$=_ref2[1];return _this6.client.crypto().decryptImage(envelope+"-"+videoCredentials$,_this6.client.keyPairs.getPrivateKeyPEMs())}).then(function(videoCredentialsBase64){return bluffer.createBase64(videoCredentialsBase64).then(function(buffer){return bluffer.read(buffer)})}).then(function(videoCredentials){var _videoCredentials$spl=videoCredentials.split(VIDEO_URL_TOKEN_SEPARATOR),url=_videoCredentials$spl[0],bearerToken=_videoCredentials$spl[1];var manifestUrl=url.replace("http://","https://");manifestUrl+="/manifest";return{manifestUrl:manifestUrl,bearerToken:bearerToken}})};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,_ref3){var messageToOwners=_ref3.messageToOwners,_ref3$markCommentsAsT=_ref3.markCommentsAsTodo,markCommentsAsTodo=_ref3$markCommentsAsT===undefined?false:_ref3$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,checklist=_concat$.checklist,file=_concat$.file,reference=_concat$.reference,integrationReferences=_concat$.integrationReferences,reminders=_concat$.reminders,owners=_concat$.owners,canDownload=_concat$.canDownload,isPublic=_concat$.isPublic,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,checklist:checklist,fileId:file&&file.id||undefined,reference:reference,integrationReferences:integrationReferences,reminders:reminders?[].concat(reminders):undefined,owners:owners,canDownload:canDownload,isPublic:isPublic,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)})};Proofs.prototype.addWorkflow=function addWorkflow(proofIdOrIds,workflowTemplateId){return this.client.request("proofs-workflow.add-bulk",{proofIds:[].concat(proofIdOrIds),workflowTemplateId:workflowTemplateId})};Proofs.prototype.sendShareLink=function sendShareLink(_ref4){var proofId=_ref4.proofId,message=_ref4.message,emailAddresses=_ref4.emailAddresses;return this.client.request("proofs.send-share-link",{proofId:proofId,message:message,emailAddresses:emailAddresses})};Proofs.prototype.getWorkflowMetrics=function getWorkflowMetrics(proofId){return this.client.request("proofs.get-workflow-metrics",{proofId:proofId}).then(function(response){if(response.data){return response.data.workflowMetrics}return null})};return Proofs}(_API3.default);exports.default=Proofs;
|
package/lib/models/Proof.d.ts
CHANGED
|
@@ -109,14 +109,6 @@ declare class Proof {
|
|
|
109
109
|
* @type {Array<User>}
|
|
110
110
|
*/
|
|
111
111
|
owners: Array<User>;
|
|
112
|
-
/**
|
|
113
|
-
* The user object of the email sender for the proof invitations and reminders.
|
|
114
|
-
*
|
|
115
|
-
* Note: The user object only contain partial details (id, email).
|
|
116
|
-
*
|
|
117
|
-
* @type {User|null}
|
|
118
|
-
*/
|
|
119
|
-
emailSender: User | null;
|
|
120
112
|
/**
|
|
121
113
|
* If a user has been assigned to make changes to the file (when to-dos have been requested), this is their user id.
|
|
122
114
|
*
|
package/lib/models/Proof.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _ProofState=require("../enum/ProofState");var _ProofState2=_interopRequireDefault(_ProofState);var _ProofStatus=require("../enum/ProofStatus");var _ProofStatus2=_interopRequireDefault(_ProofStatus);var _ProofType=require("../enum/ProofType");var _ProofType2=_interopRequireDefault(_ProofType);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _id=require("../util/id");var _getPercentage=require("../util/getPercentage");var _getPercentage2=_interopRequireDefault(_getPercentage);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _DecisionSummary=require("./DecisionSummary");var _DecisionSummary2=_interopRequireDefault(_DecisionSummary);var _ProofIntegrationReference=require("./ProofIntegrationReference");var _ProofIntegrationReference2=_interopRequireDefault(_ProofIntegrationReference);var _ProofChecklist=require("./ProofChecklist");var _ProofChecklist2=_interopRequireDefault(_ProofChecklist);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function isOverdue(){return this.dueDate&&this.dueDate.getTime()<Date.now()}var proofSchema={id:"ProofId",name:"Title",status:"Status",workflowId:"WorkflowId",version:"Version",dueDate:(0,_transform.date)("DueDate"),createdDate:(0,_transform.date)("CreateDate"),approvedDate:(0,_transform.date)("ApprovedDate"),isLocked:"Locked",isArchived:"Closed",isOverdue:isOverdue,uploaderUserId:"UserId",ownerUserIds:"OwnerIds",
|
|
1
|
+
"use strict";exports.__esModule=true;var _transform=require("./transform");var _transform2=_interopRequireDefault(_transform);var _ProofState=require("../enum/ProofState");var _ProofState2=_interopRequireDefault(_ProofState);var _ProofStatus=require("../enum/ProofStatus");var _ProofStatus2=_interopRequireDefault(_ProofStatus);var _ProofType=require("../enum/ProofType");var _ProofType2=_interopRequireDefault(_ProofType);var _FileStatus=require("../enum/FileStatus");var _FileStatus2=_interopRequireDefault(_FileStatus);var _id=require("../util/id");var _getPercentage=require("../util/getPercentage");var _getPercentage2=_interopRequireDefault(_getPercentage);var _User=require("./User");var _User2=_interopRequireDefault(_User);var _DecisionSummary=require("./DecisionSummary");var _DecisionSummary2=_interopRequireDefault(_DecisionSummary);var _ProofIntegrationReference=require("./ProofIntegrationReference");var _ProofIntegrationReference2=_interopRequireDefault(_ProofIntegrationReference);var _ProofChecklist=require("./ProofChecklist");var _ProofChecklist2=_interopRequireDefault(_ProofChecklist);function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj}}function _classCallCheck(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}}function isOverdue(){return this.dueDate&&this.dueDate.getTime()<Date.now()}var proofSchema={id:"ProofId",name:"Title",status:"Status",workflowId:"WorkflowId",version:"Version",dueDate:(0,_transform.date)("DueDate"),createdDate:(0,_transform.date)("CreateDate"),approvedDate:(0,_transform.date)("ApprovedDate"),isLocked:"Locked",isArchived:"Closed",isOverdue:isOverdue,uploaderUserId:"UserId",ownerUserIds:"OwnerIds",editorUserId:"EditorId",editorUserIds:"EditorIds",lockerUserId:"ProofLockerId",messageToReviewers:"Description",messageToOwners:"OwnerMessage",messageToEditor:"EditorMessage",fileId:"FileId",fileExtension:"Extension",fileStatus:"FileStatus",fileMessage:"FileStatusMessage",fileSize:"FileSize",pageCount:(0,_transform.number)("Pages"),commentCount:(0,_transform.number)("ParentComments"),canDownload:(0,_transform.truthy)("DownloadOriginal"),type:"Type",processStatus:"ProcessStatus",recipient:"Recipient",recipientEmail:"RecipientEmail",todoCommentCount:(0,_transform.number)("CountTodoComments"),doneCommentCount:(0,_transform.number)("CountDoneComments"),fileCategory:"FileCategory",isAdminOnProof:"IsAdminOnProof",groupId:"GroupId",canReupload:"CanReupload",hasEditors:"HasEditors",groupName:"GroupName",role:"Role",canOthersEditComments:"FeatureEditComments",canAddCommentReplies:"FeatureCanAddCommentReplies",canHaveGeneralComments:"FeatureGeneralComments",canAddChecklist:"FeatureCanAddChecklist",hasDecisionsEnabled:"FeatureDecisions",hasColorSeparations:"HasColorSeparations",reference:"Reference",integrationReferences:(0,_transform.each)("IntegrationReferences",function(data){return(new _ProofIntegrationReference2.default).fromProofIntegrationReference(data)}),checklist:function checklist(data){return data.Checklist&&(new _ProofChecklist2.default).fromProofChecklist(data.Checklist)},isReferenceEnabled:"FeatureProofReference",source:"Source",owners:(0,_transform.each)("Owners",function(ownerData){return(new _User2.default).fromUser(ownerData)}),decisionSummary:(0,_transform.each)("Decisions",function(decisionsData){return(new _DecisionSummary2.default).fromDecisionSummary(decisionsData)}),tags:(0,_transform.each)("Tags",function(tag){return tag.Value}),teamId:"TeamId",isPublic:"IsPublic",canBePublic:"FeaturePublicProofs",canSendShareLink:"FeatureSendShareLink",publicProofKeyPair:function publicProofKeyPair(data){return data.PublicProofKeyPair&&{publicKeyPEM:data.PublicProofKeyPair.PublicKey,privateKeyPEM:data.PublicProofKeyPair.PrivateKey}},canSendMessageToOwners:"FeatureMessageToOwners",workflowMetrics:"WorkflowMetrics"};var Proof=function(){function Proof(){_classCallCheck(this,Proof)}Proof.prototype.isUserAdminOfProofTeam=function isUserAdminOfProofTeam(user){return user.isAdmin&&this.teamId===user.teamId};Proof.prototype.getState=function getState(){var state=_ProofState2.default.ACTIVE;if(this.fileStatus===_FileStatus2.default.UPLOADING){state=_ProofState2.default.UPLOADING}else if(this.hasFileError()){state=_ProofState2.default.FILE_ERROR}else if(this.isProcessing()){state=_ProofState2.default.PROCESSING}else if(this.type===_ProofType2.default.BRIEF){switch(this.status){case _ProofStatus2.default.NEW:state=_ProofState2.default.SETUP_NEEDED;break;case _ProofStatus2.default.PROOFING:state=_ProofState2.default.BRIEFING;break;case _ProofStatus2.default.AWAITING_NEW_VERSION:state=_ProofState2.default.AWAITING_PROOF;break;case _ProofStatus2.default.HAS_NEW_VERSION:state=_ProofState2.default.HAS_NEW_VERSION;break;case _ProofStatus2.default.ARCHIVED:state=_ProofState2.default.ARCHIVED;break}}else if(this.status===_ProofStatus2.default.ARCHIVED){state=_ProofState2.default.ARCHIVED}else if(this.status===_ProofStatus2.default.TODOS_REQUESTED){state=_ProofState2.default.TODOS_REQUESTED}else if(this.status===_ProofStatus2.default.AWAITING_NEW_VERSION){state=_ProofState2.default.AWAITING_NEW_VERSION}else if(this.status===_ProofStatus2.default.HAS_NEW_VERSION){state=_ProofState2.default.HAS_NEW_VERSION}else if(this.status===_ProofStatus2.default.APPROVED){state=_ProofState2.default.APPROVED}else if(!this.hasWorkflow()){state=_ProofState2.default.PROOFERS_NEEDED}else if(!this.hasWorkflowStarted()){state=_ProofState2.default.NOT_STARTED}else if(this.isOverdue){state=_ProofState2.default.OVERDUE}return state};Proof.prototype.getVideoProcessingProgress=function getVideoProcessingProgress(){var percent=0;var message=String(this.fileMessage);if(message){var thumbMatch=/^Thumb-\w+\-([-+]?[0-9]*\.?[0-9]*)/g.exec(message);var videoMatch=/^Video-\w+\-([-+]?[0-9]*\.?[0-9]*)/g.exec(message);if(message.startsWith("Video-Scheduled-")){percent=0}else if(videoMatch){percent=(0,_getPercentage2.default)(parseFloat(videoMatch[1])/100,0,.2)}else if(thumbMatch){percent=(0,_getPercentage2.default)(parseFloat(thumbMatch[1])/100,.8,0)}}return percent};Proof.prototype.hasWorkflowStarted=function hasWorkflowStarted(){return this.hasWorkflow()&&this.status!==_ProofStatus2.default.NEW};Proof.prototype.isProcessing=function isProcessing(){return this.fileStatus===_FileStatus2.default.UPLOADING||this.fileStatus===_FileStatus2.default.QUEUED||this.fileStatus===_FileStatus2.default.RIPPING};Proof.prototype.isAwaitingFile=function isAwaitingFile(){return this.source&&this.fileStatus===_FileStatus2.default.CREATED};Proof.prototype.getProcessingProgress=function getProcessingProgress(){switch(this.fileStatus){case _FileStatus2.default.UPLOADING:return.1;case _FileStatus2.default.QUEUED:return.2;case _FileStatus2.default.RIPPING:if(this.fileCategory==="video"){return(0,_getPercentage2.default)(this.getVideoProcessingProgress(),.2,.1).toFixed(2)}return.6;default:return-1}};Proof.prototype.hasWorkflow=function hasWorkflow(){return(0,_id.isWorkflowId)(this.workflowId)};Proof.prototype.hasFile=function hasFile(){return(0,_id.isFileId)(this.fileId)};Proof.prototype.hasFileError=function hasFileError(){return this.fileStatus===_FileStatus2.default.ERROR||!this.fileStatus||!this.hasFile()};Proof.prototype.hasEditor=function hasEditor(){return(0,_id.isUserId)(this.editorUserId)};Proof.prototype.hasThumbnail=function hasThumbnail(){return this.fileStatus===_FileStatus2.default.OK};Proof.prototype.canUserUploadNewVersion=function canUserUploadNewVersion(userId){return this.getState()===_ProofState2.default.AWAITING_NEW_VERSION&&(this.isEditor(userId)||this.isOwner(userId))||this.getState()===_ProofState2.default.AWAITING_PROOF&&(this.isEditor(userId)||this.isRecipient(userId))};Proof.prototype.isOwner=function isOwner(userId){return this.ownerUserIds.indexOf(userId)!==-1};Proof.prototype.isEditor=function isEditor(userId){return this.editorUserIds.indexOf(userId)!==-1};Proof.prototype.isRecipient=function isRecipient(userId){return this.recipient===userId};Proof.prototype.calculateState=function calculateState(){this.state=this.getState()};Proof.prototype.fromProof=function fromProof(proofData){(0,_transform2.default)(this,proofSchema,proofData);this.calculateState();return this};return Proof}();exports.default=Proof;
|