@verdocs/js-sdk 2.0.16 → 2.0.18

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.
@@ -93,7 +93,9 @@ export declare const recipientCanAct: (recipient: IRecipient, recipientsWithActi
93
93
  */
94
94
  export declare const userCanAct: (email: string, recipientsWithActions: IRecipient[]) => boolean | undefined;
95
95
  /**
96
- * Get (binary download) a file attached to a Document.
96
+ * Get (binary download) a file attached to a Document. It is important to use this method
97
+ * rather than a direct A HREF or similar link to set the authorization headers for the
98
+ * request.
97
99
  */
98
100
  export declare const getDocumentFile: (endpoint: VerdocsEndpoint, documentId: string, envelopeDocumentId: string) => Promise<string>;
99
101
  /**
@@ -174,7 +174,9 @@ export var userCanAct = function (email, recipientsWithActions) {
174
174
  return recipient && recipient.sequence === ((_a = recipientsWithActions === null || recipientsWithActions === void 0 ? void 0 : recipientsWithActions[0]) === null || _a === void 0 ? void 0 : _a.sequence);
175
175
  };
176
176
  /**
177
- * Get (binary download) a file attached to a Document.
177
+ * Get (binary download) a file attached to a Document. It is important to use this method
178
+ * rather than a direct A HREF or similar link to set the authorization headers for the
179
+ * request.
178
180
  */
179
181
  export var getDocumentFile = function (endpoint, documentId, envelopeDocumentId) { return __awaiter(void 0, void 0, void 0, function () {
180
182
  return __generator(this, function (_a) {
@@ -8,7 +8,7 @@ export interface IUpdateRecipientParams {
8
8
  /**
9
9
  * Update a recipient's status block
10
10
  */
11
- export declare const updateRecipientStatus: (endpoint: VerdocsEndpoint, documentId: string, roleName: string, action: TRecipientAction, params?: IUpdateRecipientParams) => Promise<IRecipient>;
11
+ export declare const updateRecipientStatus: (endpoint: VerdocsEndpoint, documentId: string, roleName: string, action: TRecipientAction, params?: IUpdateRecipientParams | undefined) => Promise<IRecipient>;
12
12
  export interface ISignerTokenResponse {
13
13
  recipient: IRecipient;
14
14
  envelope: IDocument;
@@ -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<IGroupDetail>;
31
+ export declare const getGroupByName: (endpoint: VerdocsEndpoint, organizationId: string, name?: string | undefined) => Promise<IGroupDetail>;
32
32
  /**
33
33
  * Get the details for a group.
34
34
  *
@@ -45,3 +45,15 @@ export declare const getTemplateDocument: (endpoint: VerdocsEndpoint, templateId
45
45
  * ```
46
46
  */
47
47
  export declare const deleteTemplateDocument: (endpoint: VerdocsEndpoint, templateId: string, documentId: string) => Promise<any>;
48
+ /**
49
+ * Get (binary download) a file attached to a Template. It is important to use this method
50
+ * rather than a direct A HREF or similar link to set the authorization headers for the
51
+ * request.
52
+ */
53
+ export declare const getTemplateDocumentFile: (endpoint: VerdocsEndpoint, templateId: string, documentId: string) => Promise<string>;
54
+ /**
55
+ * Get (binary download) a file attached to a Template. It is important to use this method
56
+ * rather than a direct A HREF or similar link to set the authorization headers for the
57
+ * request.
58
+ */
59
+ export declare const getTemplateDocumentThumbnail: (endpoint: VerdocsEndpoint, templateId: string, documentId: string) => Promise<string>;
@@ -3,6 +3,42 @@
3
3
  *
4
4
  * @module
5
5
  */
6
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
7
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
8
+ return new (P || (P = Promise))(function (resolve, reject) {
9
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
10
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
11
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
12
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
13
+ });
14
+ };
15
+ var __generator = (this && this.__generator) || function (thisArg, body) {
16
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
17
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
18
+ function verb(n) { return function (v) { return step([n, v]); }; }
19
+ function step(op) {
20
+ if (f) throw new TypeError("Generator is already executing.");
21
+ while (_) try {
22
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
23
+ if (y = 0, t) op = [op[0] & 2, t.value];
24
+ switch (op[0]) {
25
+ case 0: case 1: t = op; break;
26
+ case 4: _.label++; return { value: op[1], done: false };
27
+ case 5: _.label++; y = op[1]; op = [0]; continue;
28
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
29
+ default:
30
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
31
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
32
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
33
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
34
+ if (t[2]) _.ops.pop();
35
+ _.trys.pop(); continue;
36
+ }
37
+ op = body.call(thisArg, _);
38
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
39
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
40
+ }
41
+ };
6
42
  /**
7
43
  * Get all the Template Documents associated to a particular Template.
8
44
  *
@@ -59,3 +95,31 @@ export var deleteTemplateDocument = function (endpoint, templateId, documentId)
59
95
  .delete("/templates/".concat(templateId, "/documents/").concat(documentId))
60
96
  .then(function (r) { return r.data; });
61
97
  };
98
+ /**
99
+ * Get (binary download) a file attached to a Template. It is important to use this method
100
+ * rather than a direct A HREF or similar link to set the authorization headers for the
101
+ * request.
102
+ */
103
+ export var getTemplateDocumentFile = function (endpoint, templateId, documentId) { return __awaiter(void 0, void 0, void 0, function () {
104
+ return __generator(this, function (_a) {
105
+ return [2 /*return*/, endpoint.api //
106
+ .get("/templates/".concat(templateId, "/documents/").concat(documentId, "?file=true"), {
107
+ responseType: 'arraybuffer',
108
+ })
109
+ .then(function (r) { return Buffer.from(r.data, 'binary').toString('base64'); })];
110
+ });
111
+ }); };
112
+ /**
113
+ * Get (binary download) a file attached to a Template. It is important to use this method
114
+ * rather than a direct A HREF or similar link to set the authorization headers for the
115
+ * request.
116
+ */
117
+ export var getTemplateDocumentThumbnail = function (endpoint, templateId, documentId) { return __awaiter(void 0, void 0, void 0, function () {
118
+ return __generator(this, function (_a) {
119
+ return [2 /*return*/, endpoint.api //
120
+ .get("/templates/".concat(templateId, "/documents/").concat(documentId, "?thumbnail=true"), {
121
+ responseType: 'arraybuffer',
122
+ })
123
+ .then(function (r) { return Buffer.from(r.data, 'binary').toString('base64'); })];
124
+ });
125
+ }); };
@@ -23,7 +23,7 @@ export interface IGetTemplatesParams {
23
23
  * await Templates.getTemplates({ is_organization: true });
24
24
  * ```
25
25
  */
26
- export declare const getTemplates: (endpoint: VerdocsEndpoint, params?: IGetTemplatesParams) => Promise<ITemplate[]>;
26
+ export declare const getTemplates: (endpoint: VerdocsEndpoint, params?: IGetTemplatesParams | undefined) => Promise<ITemplate[]>;
27
27
  /**
28
28
  * Get one template by its ID.
29
29
  *
@@ -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: (value: string) => boolean;
19
- export declare const isValidPhone: (value: string) => boolean;
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;
@@ -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 EmailRegEx = /^(([^<>()\[\]\\.,;:\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,}))$/;
22
- export var isValidEmail = function (value) { return EmailRegEx.test(value); };
23
- export var isValidPhone = function (value) { return simpleE164Validator(value); };
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; };
@@ -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
- var e164Regex = new RegExp(/\+[1-9]\d{6,14}/g);
1356
- export function simpleE164Validator(code) {
1357
- return (code !== null && code.length < 16 && code.length > 6 && e164Regex.test(code)) || code === '' || code === null;
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
+ // }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "2.0.16",
3
+ "version": "2.0.18",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",