@verdocs/js-sdk 2.0.8 → 2.0.11

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;
@@ -184,6 +192,26 @@ export declare const getDocumentRecipients: (endpoint: VerdocsEndpoint, document
184
192
  * Get all metadata for a Document.
185
193
  */
186
194
  export declare const getDocument: (endpoint: VerdocsEndpoint, documentId: string) => Promise<IDocument>;
195
+ /**
196
+ * Cancel a Document.
197
+ */
198
+ export declare const cancelDocument: (endpoint: VerdocsEndpoint, documentId: string) => Promise<IDocument>;
199
+ /**
200
+ * Returns true if the recipient has a pending action. Note that this does not necessarily mean the recipient can act (yet).
201
+ */
202
+ export declare const recipientHasAction: (recipient: IRecipient) => boolean;
203
+ /**
204
+ * Returns the recipients who still have a pending action. Note that not all of these recipients may be able to act (yet).
205
+ */
206
+ export declare const getRecipientsWithActions: (document: IDocument) => IRecipient[];
207
+ /**
208
+ * Returns true if the recipient can act.
209
+ */
210
+ export declare const recipientCanAct: (recipient: IRecipient, recipientsWithActions: IRecipient[]) => boolean;
211
+ /**
212
+ * Returns true if the user can act.
213
+ */
214
+ export declare const userCanAct: (email: string, recipientsWithActions: IRecipient[]) => boolean | undefined;
187
215
  /**
188
216
  * Get (binary download) a file attached to a Document.
189
217
  */
@@ -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
  */
@@ -18,7 +18,17 @@ import { VerdocsEndpoint } from '../VerdocsEndpoint';
18
18
  * const groups = await Groups.getGroups(ORGID);
19
19
  * ```
20
20
  */
21
- export declare const getGroups: (endpoint: VerdocsEndpoint, organizationId: string, name?: string) => Promise<IGroup[]>;
21
+ export declare const getGroups: (endpoint: VerdocsEndpoint, organizationId: string) => Promise<IGroup[]>;
22
+ /**
23
+ * Get a single group by name. Returns a detail record.
24
+ *
25
+ * ```typescript
26
+ * import {Groups} from '@verdocs/js-sdk/Organizations';
27
+ *
28
+ * const groups = await Groups.getGroups(ORGID);
29
+ * ```
30
+ */
31
+ export declare const getGroupByName: (endpoint: VerdocsEndpoint, organizationId: string, name?: string) => Promise<IGroupDetail>;
22
32
  /**
23
33
  * Get the details for a group.
24
34
  *
@@ -16,7 +16,21 @@
16
16
  * const groups = await Groups.getGroups(ORGID);
17
17
  * ```
18
18
  */
19
- export var getGroups = function (endpoint, organizationId, name) {
19
+ export var getGroups = function (endpoint, organizationId) {
20
+ return endpoint.api //
21
+ .get("/organizations/".concat(organizationId, "/groups"))
22
+ .then(function (r) { return r.data; });
23
+ };
24
+ /**
25
+ * Get a single group by name. Returns a detail record.
26
+ *
27
+ * ```typescript
28
+ * import {Groups} from '@verdocs/js-sdk/Organizations';
29
+ *
30
+ * const groups = await Groups.getGroups(ORGID);
31
+ * ```
32
+ */
33
+ export var getGroupByName = function (endpoint, organizationId, name) {
20
34
  return endpoint.api //
21
35
  .get("/organizations/".concat(organizationId, "/groups"), { params: { name: name } })
22
36
  .then(function (r) { return r.data; });
@@ -41,6 +41,8 @@ export interface IGroup {
41
41
  name: string;
42
42
  organization_id: string;
43
43
  /** For future expansion. In the future, Verdocs may support group hierarchies. Until then this field is always null. */
44
+ parent: IGroup | null;
45
+ /** For future expansion. In the future, Verdocs may support group hierarchies. Until then this field is always null. */
44
46
  parent_id: string | null;
45
47
  /** Some operations will additionally return a list of permissions. */
46
48
  permissions?: TPermission[];
@@ -49,8 +51,25 @@ export interface IGroup {
49
51
  /** Some operations will additionally return a list of profiles. */
50
52
  profiles?: IProfile[];
51
53
  }
52
- export interface IGroupDetail extends IGroup {
53
- permissions: TPermission[];
54
- 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[];
55
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;
56
75
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "2.0.8",
3
+ "version": "2.0.11",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",