@verdocs/js-sdk 2.0.15 → 2.0.17
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/Documents/Documents.d.ts +37 -3
- package/Documents/Documents.js +41 -2
- package/Documents/Types.d.ts +31 -4
- package/Templates/Validators.d.ts +2 -2
- package/Templates/Validators.js +5 -4
- package/Utils/Locales.d.ts +0 -1
- package/Utils/Locales.js +4 -4
- package/package.json +1 -1
package/Documents/Documents.d.ts
CHANGED
|
@@ -1,13 +1,47 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ICreateDocumentRequest, IDocumentsSearchResult, ISigningSessionRequest } from './Types';
|
|
2
|
+
import { IDocument, IDocumentsSummary, IRecipient, ISigningSession } from './Types';
|
|
2
3
|
import { TDocumentUpdateResult, IDocumentFieldSettings } from './Types';
|
|
3
4
|
import { VerdocsEndpoint } from '../VerdocsEndpoint';
|
|
5
|
+
/**
|
|
6
|
+
* Create a document
|
|
7
|
+
*
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import {Documents, ICreateDocumentRole, ICreateDocumentRequest} from '@verdocs/js-sdk/Documents';
|
|
10
|
+
*
|
|
11
|
+
* const role1: ICreateDocumentRole = {
|
|
12
|
+
* type: 'signer',
|
|
13
|
+
* name: 'Seller',
|
|
14
|
+
* full_name: 'Paige Turner',
|
|
15
|
+
* email: 'paige.turner@nomail.com',
|
|
16
|
+
* phone: '',
|
|
17
|
+
* sequence: 1,
|
|
18
|
+
* delegator: false,
|
|
19
|
+
* message: '',
|
|
20
|
+
* };
|
|
21
|
+
*
|
|
22
|
+
* const role2: ICreateDocumentRole = {
|
|
23
|
+
* type: 'signer',
|
|
24
|
+
* name: 'Buyer',
|
|
25
|
+
* full_name: 'Will Power',
|
|
26
|
+
* email: 'will.power@nomail.com',
|
|
27
|
+
* phone: '',
|
|
28
|
+
* sequence: 2,
|
|
29
|
+
* delegator: false,
|
|
30
|
+
* message: '',
|
|
31
|
+
* };
|
|
32
|
+
*
|
|
33
|
+
* const request: ICreateDocumentRequest = {template_id: 'd2338742-f3a1-465b-8592-806587413cc1', name: 'Bill of Sale', roles: [role1, role2]};
|
|
34
|
+
* const {id, recipients} = await Documents.createDocument(VerdocsEndpoint.getDefault(), request);
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare const createDocument: (endpoint: VerdocsEndpoint, request: ICreateDocumentRequest) => Promise<IDocument>;
|
|
4
38
|
/**
|
|
5
39
|
* Get a summary of currently active documents.
|
|
6
40
|
*
|
|
7
41
|
* ```typescript
|
|
8
42
|
* import {Documents} from '@verdocs/js-sdk/Documents';
|
|
9
43
|
*
|
|
10
|
-
* const {action_required, completed, waiting_on_others} = await Documents.getSummary();
|
|
44
|
+
* const {action_required, completed, waiting_on_others} = await Documents.getSummary(VerdocsEndpoint.getDefault());
|
|
11
45
|
* ```
|
|
12
46
|
*/
|
|
13
47
|
export declare const getSummary: (endpoint: VerdocsEndpoint, page: number) => Promise<IDocumentsSummary>;
|
|
@@ -17,7 +51,7 @@ export declare const getSummary: (endpoint: VerdocsEndpoint, page: number) => Pr
|
|
|
17
51
|
* ```typescript
|
|
18
52
|
* import {Documents} from '@verdocs/js-sdk/Documents';
|
|
19
53
|
*
|
|
20
|
-
* const {result, page, total} = await Documents.search({ ... });
|
|
54
|
+
* const {result, page, total} = await Documents.search(VerdocsEndpoint.getDefault(), { ... });
|
|
21
55
|
* ```
|
|
22
56
|
*/
|
|
23
57
|
export declare const searchDocuments: (endpoint: VerdocsEndpoint, params: any) => Promise<IDocumentsSearchResult>;
|
package/Documents/Documents.js
CHANGED
|
@@ -35,13 +35,52 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import { decodeAccessTokenBody } from '../Utils/Token';
|
|
38
|
+
/**
|
|
39
|
+
* Create a document
|
|
40
|
+
*
|
|
41
|
+
* ```typescript
|
|
42
|
+
* import {Documents, ICreateDocumentRole, ICreateDocumentRequest} from '@verdocs/js-sdk/Documents';
|
|
43
|
+
*
|
|
44
|
+
* const role1: ICreateDocumentRole = {
|
|
45
|
+
* type: 'signer',
|
|
46
|
+
* name: 'Seller',
|
|
47
|
+
* full_name: 'Paige Turner',
|
|
48
|
+
* email: 'paige.turner@nomail.com',
|
|
49
|
+
* phone: '',
|
|
50
|
+
* sequence: 1,
|
|
51
|
+
* delegator: false,
|
|
52
|
+
* message: '',
|
|
53
|
+
* };
|
|
54
|
+
*
|
|
55
|
+
* const role2: ICreateDocumentRole = {
|
|
56
|
+
* type: 'signer',
|
|
57
|
+
* name: 'Buyer',
|
|
58
|
+
* full_name: 'Will Power',
|
|
59
|
+
* email: 'will.power@nomail.com',
|
|
60
|
+
* phone: '',
|
|
61
|
+
* sequence: 2,
|
|
62
|
+
* delegator: false,
|
|
63
|
+
* message: '',
|
|
64
|
+
* };
|
|
65
|
+
*
|
|
66
|
+
* const request: ICreateDocumentRequest = {template_id: 'd2338742-f3a1-465b-8592-806587413cc1', name: 'Bill of Sale', roles: [role1, role2]};
|
|
67
|
+
* const {id, recipients} = await Documents.createDocument(VerdocsEndpoint.getDefault(), request);
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export var createDocument = function (endpoint, request) { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
|
+
return __generator(this, function (_a) {
|
|
72
|
+
return [2 /*return*/, endpoint.api //
|
|
73
|
+
.post('/documents', request)
|
|
74
|
+
.then(function (r) { return r.data; })];
|
|
75
|
+
});
|
|
76
|
+
}); };
|
|
38
77
|
/**
|
|
39
78
|
* Get a summary of currently active documents.
|
|
40
79
|
*
|
|
41
80
|
* ```typescript
|
|
42
81
|
* import {Documents} from '@verdocs/js-sdk/Documents';
|
|
43
82
|
*
|
|
44
|
-
* const {action_required, completed, waiting_on_others} = await Documents.getSummary();
|
|
83
|
+
* const {action_required, completed, waiting_on_others} = await Documents.getSummary(VerdocsEndpoint.getDefault());
|
|
45
84
|
* ```
|
|
46
85
|
*/
|
|
47
86
|
export var getSummary = function (endpoint, page) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -57,7 +96,7 @@ export var getSummary = function (endpoint, page) { return __awaiter(void 0, voi
|
|
|
57
96
|
* ```typescript
|
|
58
97
|
* import {Documents} from '@verdocs/js-sdk/Documents';
|
|
59
98
|
*
|
|
60
|
-
* const {result, page, total} = await Documents.search({ ... });
|
|
99
|
+
* const {result, page, total} = await Documents.search(VerdocsEndpoint.getDefault(), { ... });
|
|
61
100
|
* ```
|
|
62
101
|
*/
|
|
63
102
|
export var searchDocuments = function (endpoint, params) { return __awaiter(void 0, void 0, void 0, function () {
|
package/Documents/Types.d.ts
CHANGED
|
@@ -125,6 +125,7 @@ export interface IRecipient {
|
|
|
125
125
|
status: TRecipientStatus;
|
|
126
126
|
type: TRecipientType;
|
|
127
127
|
updated_at: string;
|
|
128
|
+
fields?: IDocumentField[];
|
|
128
129
|
}
|
|
129
130
|
export interface IDocumentAsset {
|
|
130
131
|
created_at: string;
|
|
@@ -135,6 +136,14 @@ export interface IDocumentAsset {
|
|
|
135
136
|
updated_at: string;
|
|
136
137
|
url: string;
|
|
137
138
|
}
|
|
139
|
+
export interface IDocumentFieldOptions {
|
|
140
|
+
id: string;
|
|
141
|
+
x: number;
|
|
142
|
+
y: number;
|
|
143
|
+
checked?: boolean;
|
|
144
|
+
selected?: boolean;
|
|
145
|
+
value: string;
|
|
146
|
+
}
|
|
138
147
|
export interface IDocumentFieldSettings {
|
|
139
148
|
type?: string;
|
|
140
149
|
x: number;
|
|
@@ -146,21 +155,24 @@ export interface IDocumentFieldSettings {
|
|
|
146
155
|
leading?: number;
|
|
147
156
|
alignment?: number;
|
|
148
157
|
upperCase?: boolean;
|
|
149
|
-
options?:
|
|
158
|
+
options?: IDocumentFieldOptions[];
|
|
150
159
|
base64?: string;
|
|
151
160
|
hash?: string;
|
|
152
161
|
ip_address?: string;
|
|
153
162
|
signature_id?: string;
|
|
154
163
|
signed_at?: string;
|
|
164
|
+
minimum_checked?: number;
|
|
165
|
+
maximum_checked?: number;
|
|
155
166
|
[key: string]: any;
|
|
156
167
|
}
|
|
168
|
+
export declare type TDocumentFieldType = 'signature' | 'initial' | 'checkbox_group' | 'radio_button_group' | 'textbox' | 'timestamp' | 'date' | 'dropdown' | 'textarea' | 'attachment' | 'payment';
|
|
157
169
|
export interface IDocumentField {
|
|
158
170
|
envelope_id: string;
|
|
159
|
-
label: string | null;
|
|
160
171
|
name: string;
|
|
172
|
+
label: string | null;
|
|
161
173
|
page: number;
|
|
162
174
|
recipient_role: string;
|
|
163
|
-
type:
|
|
175
|
+
type: TDocumentFieldType;
|
|
164
176
|
required: boolean;
|
|
165
177
|
settings?: IDocumentFieldSettings;
|
|
166
178
|
validator: string | null;
|
|
@@ -185,7 +197,7 @@ export interface IDocument {
|
|
|
185
197
|
certificate?: IDocumentAsset | null;
|
|
186
198
|
document?: IDocumentAsset | null;
|
|
187
199
|
fields?: IDocumentField[];
|
|
188
|
-
profile?: IProfile;
|
|
200
|
+
profile?: IProfile | null;
|
|
189
201
|
}
|
|
190
202
|
export declare type TDocumentUpdateResult = Omit<IDocument, 'histories' | 'recipients' | 'certificate' | 'document' | 'fields' | 'profile'>;
|
|
191
203
|
export interface IActivityEntry {
|
|
@@ -226,3 +238,18 @@ export interface IDocumentSearchOptions {
|
|
|
226
238
|
}
|
|
227
239
|
export declare type THistoryEvent = 'recipient:invited' | 'recipient:opened' | 'recipient:agreed' | 'recipient:signed' | 'recipient:submitted';
|
|
228
240
|
export declare type TEventDetail = 'in_app' | 'mail' | 'signer' | '';
|
|
241
|
+
export interface ICreateDocumentRole {
|
|
242
|
+
type: TRecipientType;
|
|
243
|
+
name: string;
|
|
244
|
+
full_name: string;
|
|
245
|
+
email?: string;
|
|
246
|
+
phone?: string;
|
|
247
|
+
sequence: number;
|
|
248
|
+
delegator: boolean;
|
|
249
|
+
message: string;
|
|
250
|
+
}
|
|
251
|
+
export interface ICreateDocumentRequest {
|
|
252
|
+
template_id: string;
|
|
253
|
+
roles: ICreateDocumentRole[];
|
|
254
|
+
name: string;
|
|
255
|
+
}
|
|
@@ -15,7 +15,7 @@ export interface IValidator {
|
|
|
15
15
|
*/
|
|
16
16
|
export declare const getValidators: (endpoint: VerdocsEndpoint) => Promise<IValidator[]>;
|
|
17
17
|
export declare const getValidator: (endpoint: VerdocsEndpoint, validatorName: string) => Promise<IValidator>;
|
|
18
|
-
export declare const isValidEmail: (
|
|
19
|
-
export declare const isValidPhone: (
|
|
18
|
+
export declare const isValidEmail: (email: string | undefined) => boolean;
|
|
19
|
+
export declare const isValidPhone: (phone: string | undefined) => boolean;
|
|
20
20
|
export declare const isValidRoleName: (value: string, roles: IRole[]) => boolean;
|
|
21
21
|
export declare const isValidTag: (value: string, tags: ITag[]) => boolean;
|
package/Templates/Validators.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { simpleE164Validator } from '../Utils/Locales';
|
|
2
1
|
/**
|
|
3
2
|
* Get all defined validators
|
|
4
3
|
*
|
|
@@ -18,9 +17,11 @@ export var getValidator = function (endpoint, validatorName) {
|
|
|
18
17
|
.get("/validators/".concat(validatorName))
|
|
19
18
|
.then(function (r) { return r.data; });
|
|
20
19
|
};
|
|
21
|
-
var
|
|
22
|
-
export var isValidEmail = function (
|
|
23
|
-
|
|
20
|
+
var EMAIL_REGEX = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
|
|
21
|
+
export var isValidEmail = function (email) { return !!email && EMAIL_REGEX.test(email); };
|
|
22
|
+
// @see https://www.regextester.com/1978
|
|
23
|
+
var PHONE_REGEX = /((?:\+|00)[17](?: |\-)?|(?:\+|00)[1-9]\d{0,2}(?: |\-)?|(?:\+|00)1\-\d{3}(?: |\-)?)?(0\d|\([0-9]{3}\)|[1-9]{0,3})(?:((?: |\-)[0-9]{2}){4}|((?:[0-9]{2}){4})|((?: |\-)[0-9]{3}(?: |\-)[0-9]{4})|([0-9]{7}))/;
|
|
24
|
+
export var isValidPhone = function (phone) { return !!phone && PHONE_REGEX.test(phone); };
|
|
24
25
|
export var isValidRoleName = function (value, roles) { return roles.findIndex(function (role) { return role.name === value; }) !== -1; };
|
|
25
26
|
var TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
|
|
26
27
|
export var isValidTag = function (value, tags) { return TagRegEx.test(value) || tags.findIndex(function (tag) { return tag.name === value; }) !== -1; };
|
package/Utils/Locales.d.ts
CHANGED
|
@@ -15,4 +15,3 @@ export declare function isAmericanSamoa(code: string): boolean;
|
|
|
15
15
|
export declare function isDominicanRepublic(code: string): boolean;
|
|
16
16
|
export declare function isPuertoRico(code: string): boolean;
|
|
17
17
|
export declare function getMatchingCountry(code: string, substrings: number): number;
|
|
18
|
-
export declare function simpleE164Validator(code: string): boolean;
|
package/Utils/Locales.js
CHANGED
|
@@ -1352,7 +1352,7 @@ export function getMatchingCountry(code, substrings) {
|
|
|
1352
1352
|
var toMatch = code.substring(0, substrings);
|
|
1353
1353
|
return Countries.filter(function (c) { return c.code === toMatch; }).length;
|
|
1354
1354
|
}
|
|
1355
|
-
|
|
1356
|
-
export function simpleE164Validator(code) {
|
|
1357
|
-
|
|
1358
|
-
}
|
|
1355
|
+
// const e164Regex = new RegExp(/\+[1-9]\d{6,14}/g);
|
|
1356
|
+
// export function simpleE164Validator(code: string) {
|
|
1357
|
+
// return (code !== null && code.length < 16 && code.length > 6 && e164Regex.test(code)) || code === '' || code === null;
|
|
1358
|
+
// }
|