@verdocs/js-sdk 3.0.15 → 3.0.16

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.
@@ -191,9 +191,7 @@ export var userCanAct = function (email, recipientsWithActions) {
191
191
  export var getEnvelopeFile = function (endpoint, envelopeId, documentId) { return __awaiter(void 0, void 0, void 0, function () {
192
192
  return __generator(this, function (_a) {
193
193
  return [2 /*return*/, endpoint.api //
194
- .get("/envelopes/".concat(envelopeId, "/envelope_documents/").concat(documentId, "?file=true"), {
195
- responseType: 'arraybuffer',
196
- })
194
+ .get("/envelopes/".concat(envelopeId, "/envelope_documents/").concat(documentId, "?file=true"), { responseType: 'blob' })
197
195
  .then(function (r) { return Buffer.from(r.data, 'binary').toString('base64'); })];
198
196
  });
199
197
  }); };
@@ -112,9 +112,7 @@ export var deleteTemplateDocument = function (endpoint, templateId, documentId)
112
112
  export var getTemplateDocumentFile = function (endpoint, templateId, documentId) { return __awaiter(void 0, void 0, void 0, function () {
113
113
  return __generator(this, function (_a) {
114
114
  return [2 /*return*/, endpoint.api //
115
- .get("/templates/".concat(templateId, "/documents/").concat(documentId, "?file=true"), {
116
- responseType: 'arraybuffer',
117
- })
115
+ .get("/templates/".concat(templateId, "/documents/").concat(documentId, "?file=true"), { responseType: 'blob' })
118
116
  .then(function (r) { return Buffer.from(r.data, 'binary').toString('base64'); })];
119
117
  });
120
118
  }); };
@@ -126,9 +124,7 @@ export var getTemplateDocumentFile = function (endpoint, templateId, documentId)
126
124
  export var getTemplateDocumentThumbnail = function (endpoint, templateId, documentId) { return __awaiter(void 0, void 0, void 0, function () {
127
125
  return __generator(this, function (_a) {
128
126
  return [2 /*return*/, endpoint.api //
129
- .get("/templates/".concat(templateId, "/documents/").concat(documentId, "?thumbnail=true"), {
130
- responseType: 'arraybuffer',
131
- })
127
+ .get("/templates/".concat(templateId, "/documents/").concat(documentId, "?thumbnail=true"), { responseType: 'blob' })
132
128
  .then(function (r) { return Buffer.from(r.data, 'binary').toString('base64'); })];
133
129
  });
134
130
  }); };
package/Utils/Files.d.ts CHANGED
@@ -10,3 +10,7 @@ export interface FileWithData {
10
10
  * includes the MIME type of the file, e.g. "data:image/jpeg;base64,iVBORw0K......"
11
11
  */
12
12
  export declare const fileToDataUrl: (file: File) => Promise<FileWithData>;
13
+ /**
14
+ * Trigger a download dialog to save a blob as a file on disk.
15
+ */
16
+ export declare const downloadBlob: (blob: Blob, name?: string) => void;
package/Utils/Files.js CHANGED
@@ -23,3 +23,20 @@ export var fileToDataUrl = function (file) {
23
23
  }
24
24
  });
25
25
  };
26
+ /**
27
+ * Trigger a download dialog to save a blob as a file on disk.
28
+ */
29
+ export var downloadBlob = function (blob, name) {
30
+ if (name === void 0) { name = 'file.pdf'; }
31
+ var blobUrl = URL.createObjectURL(blob);
32
+ var link = document.createElement('a');
33
+ link.href = blobUrl;
34
+ link.download = name;
35
+ document.body.appendChild(link);
36
+ link.dispatchEvent(new MouseEvent('click', {
37
+ bubbles: true,
38
+ cancelable: true,
39
+ view: window,
40
+ }));
41
+ document.body.removeChild(link);
42
+ };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Create an array containing a sequence of integers, e.g. [START, START+1, START+2, ...] This is frequently useful
3
+ * in rendering operations when there is no source array to .map() across.
4
+ */
5
+ export declare const integerSequence: (start: number, count: number) => number[];
6
+ /**
7
+ * Generate suggested initials for a full name, e.g. "John Doe" will yield "JD".
8
+ */
9
+ export declare const fullNameToInitials: (name: string) => string;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Create an array containing a sequence of integers, e.g. [START, START+1, START+2, ...] This is frequently useful
3
+ * in rendering operations when there is no source array to .map() across.
4
+ */
5
+ export var integerSequence = function (start, count) {
6
+ return Array(count)
7
+ .fill(1)
8
+ .map(function (_, index) { return index + start; });
9
+ };
10
+ /**
11
+ * Generate suggested initials for a full name, e.g. "John Doe" will yield "JD".
12
+ */
13
+ export var fullNameToInitials = function (name) {
14
+ return name
15
+ .split(' ')
16
+ .map(function (word) { return word[0]; })
17
+ .join('');
18
+ };
package/Utils/index.d.ts CHANGED
@@ -3,4 +3,5 @@ export * as DateTime from './DateTime';
3
3
  export * as Fields from './Fields';
4
4
  export * as Files from './Files';
5
5
  export * as Locales from './Locales';
6
+ export * as Primitives from './Primitives';
6
7
  export * as Token from './Token';
package/Utils/index.js CHANGED
@@ -3,4 +3,5 @@ export * as DateTime from './DateTime';
3
3
  export * as Fields from './Fields';
4
4
  export * as Files from './Files';
5
5
  export * as Locales from './Locales';
6
+ export * as Primitives from './Primitives';
6
7
  export * as Token from './Token';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "3.0.15",
3
+ "version": "3.0.16",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",