@verdocs/js-sdk 2.0.9 → 2.0.12

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.
@@ -8,9 +8,17 @@ export declare type TRecipientType = 'signer' | 'cc' | 'approver';
8
8
  export interface IDocumentsSearchResultEntry {
9
9
  id: string;
10
10
  canceled_at: string;
11
+ certificate_document_id: string;
11
12
  created_at: string;
13
+ envelope_document_id: string;
14
+ histories: IHistory[];
15
+ indexed_at: string;
12
16
  name: string;
17
+ no_contact: boolean;
18
+ organization_id: string;
13
19
  profile_id: string;
20
+ recipients: IRecipient[];
21
+ reminder_id: string | null;
14
22
  status: TDocumentStatus;
15
23
  next_recipient: {
16
24
  claimed: boolean;
@@ -109,6 +117,7 @@ export interface IDocument {
109
117
  fields?: IDocumentField[];
110
118
  profile?: IProfile;
111
119
  }
120
+ export declare type TDocumentUpdateResult = Omit<IDocument, 'histories' | 'recipients' | 'certificate' | 'document' | 'fields' | 'profile'>;
112
121
  export interface IActivityEntry {
113
122
  id: string;
114
123
  name: string;
@@ -184,6 +193,26 @@ export declare const getDocumentRecipients: (endpoint: VerdocsEndpoint, document
184
193
  * Get all metadata for a Document.
185
194
  */
186
195
  export declare const getDocument: (endpoint: VerdocsEndpoint, documentId: string) => Promise<IDocument>;
196
+ /**
197
+ * Cancel a Document.
198
+ */
199
+ export declare const cancelDocument: (endpoint: VerdocsEndpoint, documentId: string) => Promise<TDocumentUpdateResult>;
200
+ /**
201
+ * Returns true if the recipient has a pending action. Note that this does not necessarily mean the recipient can act (yet).
202
+ */
203
+ export declare const recipientHasAction: (recipient: IRecipient) => boolean;
204
+ /**
205
+ * Returns the recipients who still have a pending action. Note that not all of these recipients may be able to act (yet).
206
+ */
207
+ export declare const getRecipientsWithActions: (document: IDocument) => IRecipient[];
208
+ /**
209
+ * Returns true if the recipient can act.
210
+ */
211
+ export declare const recipientCanAct: (recipient: IRecipient, recipientsWithActions: IRecipient[]) => boolean;
212
+ /**
213
+ * Returns true if the user can act.
214
+ */
215
+ export declare const userCanAct: (email: string, recipientsWithActions: IRecipient[]) => boolean | undefined;
187
216
  /**
188
217
  * Get (binary download) a file attached to a Document.
189
218
  */
@@ -104,6 +104,36 @@ export var getDocument = function (endpoint, documentId) { return __awaiter(void
104
104
  .then(function (r) { return r.data; })];
105
105
  });
106
106
  }); };
107
+ /**
108
+ * Cancel a Document.
109
+ */
110
+ export var cancelDocument = function (endpoint, documentId) { return __awaiter(void 0, void 0, void 0, function () {
111
+ return __generator(this, function (_a) {
112
+ return [2 /*return*/, endpoint.api //
113
+ .put("/documents/".concat(documentId), { action: 'cancel' })
114
+ .then(function (r) { return r.data; })];
115
+ });
116
+ }); };
117
+ /**
118
+ * Returns true if the recipient has a pending action. Note that this does not necessarily mean the recipient can act (yet).
119
+ */
120
+ export var recipientHasAction = function (recipient) { return !['submitted', 'canceled', 'declined'].includes(recipient.status); };
121
+ /**
122
+ * Returns the recipients who still have a pending action. Note that not all of these recipients may be able to act (yet).
123
+ */
124
+ export var getRecipientsWithActions = function (document) { return ((document === null || document === void 0 ? void 0 : document.recipients) || []).filter(recipientHasAction); };
125
+ /**
126
+ * Returns true if the recipient can act.
127
+ */
128
+ export var recipientCanAct = function (recipient, recipientsWithActions) { var _a; return recipient.sequence === ((_a = recipientsWithActions === null || recipientsWithActions === void 0 ? void 0 : recipientsWithActions[0]) === null || _a === void 0 ? void 0 : _a.sequence); };
129
+ /**
130
+ * Returns true if the user can act.
131
+ */
132
+ export var userCanAct = function (email, recipientsWithActions) {
133
+ var _a;
134
+ var recipient = recipientsWithActions.find(function (r) { return r.email === email; });
135
+ return recipient && recipient.sequence === ((_a = recipientsWithActions === null || recipientsWithActions === void 0 ? void 0 : recipientsWithActions[0]) === null || _a === void 0 ? void 0 : _a.sequence);
136
+ };
107
137
  /**
108
138
  * Get (binary download) a file attached to a Document.
109
139
  */
@@ -1,6 +1,6 @@
1
- import { IRecipient } from './Documents';
1
+ import { IInPersonAccessKey, TRecipientAction } from './Types';
2
2
  import { VerdocsEndpoint } from '../VerdocsEndpoint';
3
- export declare type TRecipientAction = 'submit' | 'decline' | 'prepare' | 'update';
3
+ import { IDocument, IRecipient } from './Documents';
4
4
  export interface IUpdateRecipientParams {
5
5
  new_full_name?: string;
6
6
  agreed?: boolean;
@@ -9,3 +9,10 @@ export interface IUpdateRecipientParams {
9
9
  * Update a recipient's status block
10
10
  */
11
11
  export declare const updateRecipientStatus: (endpoint: VerdocsEndpoint, documentId: string, roleName: string, action: TRecipientAction, params?: IUpdateRecipientParams) => Promise<IRecipient>;
12
+ export interface ISignerTokenResponse {
13
+ recipient: IRecipient;
14
+ envelope: IDocument;
15
+ signerToken: string;
16
+ inPersonAccessKey: IInPersonAccessKey;
17
+ }
18
+ export declare const getSignerToken: (endpoint: VerdocsEndpoint, documentId: string, roleName: string) => Promise<import("axios").AxiosResponse<ISignerTokenResponse, any>>;
@@ -55,3 +55,7 @@ export var updateRecipientStatus = function (endpoint, documentId, roleName, act
55
55
  .then(function (r) { return r.data; })];
56
56
  });
57
57
  }); };
58
+ export var getSignerToken = function (endpoint, documentId, roleName) {
59
+ return endpoint.api //
60
+ .get("/documents/".concat(documentId, "/recipients/").concat(encodeURIComponent(roleName), "/signer-token"));
61
+ };
@@ -1,3 +1,4 @@
1
+ export declare type TRecipientAction = 'submit' | 'decline' | 'prepare' | 'update';
1
2
  export interface ITemplateSummaryEntry {
2
3
  id: string;
3
4
  name: string;
@@ -41,3 +42,14 @@ export interface ISigningSession {
41
42
  iat: number;
42
43
  [key: string]: any;
43
44
  }
45
+ export interface IInPersonAccessKey {
46
+ id: string;
47
+ created_at: string;
48
+ recipient_name: string;
49
+ envelope_id: string;
50
+ type: 'in_person_link';
51
+ key: string;
52
+ expiration_date: string | null;
53
+ first_used: string | null;
54
+ last_used: string | null;
55
+ }
@@ -28,7 +28,7 @@ export declare const getGroups: (endpoint: VerdocsEndpoint, organizationId: stri
28
28
  * const groups = await Groups.getGroups(ORGID);
29
29
  * ```
30
30
  */
31
- export declare const getGroupByName: (endpoint: VerdocsEndpoint, organizationId: string, name?: string) => Promise<IGroup>;
31
+ export declare const getGroupByName: (endpoint: VerdocsEndpoint, organizationId: string, name?: string) => Promise<IGroupDetail>;
32
32
  /**
33
33
  * Get the details for a group.
34
34
  *
@@ -51,8 +51,25 @@ export interface IGroup {
51
51
  /** Some operations will additionally return a list of profiles. */
52
52
  profiles?: IProfile[];
53
53
  }
54
- export interface IGroupDetail extends IGroup {
55
- permissions: TPermission[];
56
- roles: TRole[];
54
+ export interface IPermissionDetail {
55
+ id: string;
56
+ name: string;
57
+ client_id: string;
58
+ }
59
+ export interface IRoleDetail {
60
+ id: string;
61
+ name: string;
62
+ client_id: string;
63
+ }
64
+ export interface IGroupDetail {
65
+ id: string;
66
+ name: string;
67
+ organization_id: string;
68
+ permissions: IPermissionDetail[];
69
+ roles: IRoleDetail[];
57
70
  profiles: IProfile[];
71
+ /** For future expansion. In the future, Verdocs may support group hierarchies. Until then this field is always null. */
72
+ parent: IGroup | null;
73
+ /** For future expansion. In the future, Verdocs may support group hierarchies. Until then this field is always null. */
74
+ parent_id: string | null;
58
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "2.0.9",
3
+ "version": "2.0.12",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",