@verdocs/js-sdk 3.8.1 → 3.8.3

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.
@@ -168,6 +168,14 @@ export declare const updateEnvelopeFieldSignature: (endpoint: VerdocsEndpoint, e
168
168
  * signature for a Recipient, then call `Documents.updateDocumentFieldSignature()` to attach it to a field.
169
169
  */
170
170
  export declare const updateEnvelopeFieldInitials: (endpoint: VerdocsEndpoint, envelopeId: string, fieldName: string, initialId: string) => Promise<IEnvelopeFieldSettings>;
171
+ /**
172
+ * Upload an attachment.
173
+ */
174
+ export declare const uploadEnvelopeFieldAttachment: (endpoint: VerdocsEndpoint, envelopeId: string, fieldName: string, file: File, onUploadProgress?: ((percent: number, loadedBytes: number, totalBytes: number) => void) | undefined) => Promise<IEnvelopeFieldSettings>;
175
+ /**
176
+ * Delete an attachment.
177
+ */
178
+ export declare const deleteEnvelopeFieldAttachment: (endpoint: VerdocsEndpoint, envelopeId: string, fieldName: string, file: File, onUploadProgress?: ((percent: number, loadedBytes: number, totalBytes: number) => void) | undefined) => Promise<IEnvelopeFieldSettings>;
171
179
  /**
172
180
  * Get the attached file for an attachment field (if any)
173
181
  */
@@ -207,6 +207,46 @@ export var updateEnvelopeFieldInitials = function (endpoint, envelopeId, fieldNa
207
207
  .then(function (r) { return r.data; })];
208
208
  });
209
209
  }); };
210
+ /**
211
+ * Upload an attachment.
212
+ */
213
+ export var uploadEnvelopeFieldAttachment = function (endpoint, envelopeId, fieldName, file, onUploadProgress) { return __awaiter(void 0, void 0, void 0, function () {
214
+ var formData;
215
+ return __generator(this, function (_a) {
216
+ formData = new FormData();
217
+ formData.append('document', file, file.name);
218
+ return [2 /*return*/, endpoint.api //
219
+ .put("/envelopes/".concat(envelopeId, "/fields/").concat(fieldName), formData, {
220
+ timeout: 120000,
221
+ onUploadProgress: function (event) {
222
+ var total = event.total || 1;
223
+ var loaded = event.loaded || 0;
224
+ onUploadProgress === null || onUploadProgress === void 0 ? void 0 : onUploadProgress(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
225
+ },
226
+ })
227
+ .then(function (r) { return r.data; })];
228
+ });
229
+ }); };
230
+ /**
231
+ * Delete an attachment.
232
+ */
233
+ export var deleteEnvelopeFieldAttachment = function (endpoint, envelopeId, fieldName, file, onUploadProgress) { return __awaiter(void 0, void 0, void 0, function () {
234
+ var formData;
235
+ return __generator(this, function (_a) {
236
+ formData = new FormData();
237
+ // Omitting file is the trigger here
238
+ return [2 /*return*/, endpoint.api //
239
+ .put("/envelopes/".concat(envelopeId, "/fields/").concat(fieldName), formData, {
240
+ timeout: 120000,
241
+ onUploadProgress: function (event) {
242
+ var total = event.total || 1;
243
+ var loaded = event.loaded || 0;
244
+ onUploadProgress === null || onUploadProgress === void 0 ? void 0 : onUploadProgress(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
245
+ },
246
+ })
247
+ .then(function (r) { return r.data; })];
248
+ });
249
+ }); };
210
250
  /**
211
251
  * Get the attached file for an attachment field (if any)
212
252
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "3.8.1",
3
+ "version": "3.8.3",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",