@verdocs/js-sdk 3.10.18 → 3.10.21

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.
@@ -117,6 +117,16 @@ export interface ITemplateCreateParams {
117
117
  * ```
118
118
  */
119
119
  export declare const createTemplate: (endpoint: VerdocsEndpoint, params: ITemplateCreateParams, onUploadProgress?: ((percent: number, loadedBytes: number, totalBytes: number) => void) | undefined) => Promise<ITemplate>;
120
+ /**
121
+ * Create a template.
122
+ *
123
+ * ```typescript
124
+ * import {Templates} from '@verdocs/js-sdk/Templates';
125
+ *
126
+ * const newTemplate = await Templates.createTemplatev2((VerdocsEndpoint.getDefault(), {...});
127
+ * ```
128
+ */
129
+ export declare const createTemplatev2: (endpoint: VerdocsEndpoint, params: ITemplateCreateParams, onUploadProgress?: ((percent: number, loadedBytes: number, totalBytes: number) => void) | undefined) => Promise<ITemplate>;
120
130
  export interface ITemplateCreateFromSharepointParams {
121
131
  /** Name for the template to create. */
122
132
  name: string;
@@ -153,6 +153,40 @@ export var createTemplate = function (endpoint, params, onUploadProgress) {
153
153
  return endpoint.api.post('/templates', params, options).then(function (r) { return r.data; });
154
154
  }
155
155
  };
156
+ /**
157
+ * Create a template.
158
+ *
159
+ * ```typescript
160
+ * import {Templates} from '@verdocs/js-sdk/Templates';
161
+ *
162
+ * const newTemplate = await Templates.createTemplatev2((VerdocsEndpoint.getDefault(), {...});
163
+ * ```
164
+ */
165
+ export var createTemplatev2 = function (endpoint, params, onUploadProgress) {
166
+ var options = {
167
+ timeout: 120000,
168
+ onUploadProgress: function (event) {
169
+ var total = event.total || 1;
170
+ var loaded = event.loaded || 0;
171
+ onUploadProgress === null || onUploadProgress === void 0 ? void 0 : onUploadProgress(Math.floor((loaded * 100) / (total || 1)), loaded, total || 1);
172
+ },
173
+ };
174
+ if (params.documents && params.documents[0] instanceof File) {
175
+ var formData_2 = new FormData();
176
+ ALLOWED_CREATE_FIELDS.forEach(function (allowedKey) {
177
+ if (params[allowedKey] !== undefined) {
178
+ formData_2.append(allowedKey, params[allowedKey]);
179
+ }
180
+ });
181
+ params.documents.forEach(function (file) {
182
+ formData_2.append('documents', file, file.name);
183
+ });
184
+ return endpoint.api.post('/v2/templates', formData_2, options).then(function (r) { return r.data; });
185
+ }
186
+ else {
187
+ return endpoint.api.post('/v2/templates', params, options).then(function (r) { return r.data; });
188
+ }
189
+ };
156
190
  /**
157
191
  * Create a template from a Sharepoint asset.
158
192
  *
@@ -31,6 +31,7 @@ var requestLogger = function (r) {
31
31
  * .setTimeout(5000);
32
32
  * ```
33
33
  */
34
+ // TODO: Research issue with Beta URL
34
35
  var VerdocsEndpoint = /** @class */ (function () {
35
36
  /**
36
37
  * Create a new VerdocsEndpoint to call Verdocs platform services.
@@ -43,7 +44,9 @@ var VerdocsEndpoint = /** @class */ (function () {
43
44
  function VerdocsEndpoint(options) {
44
45
  this.environment = 'verdocs';
45
46
  this.sessionType = 'user';
46
- this.baseURL = 'https://api.verdocs.com';
47
+ this.baseURL = (window.location.origin === 'https://beta.verdocs.com'
48
+ ? 'https://stage-api.verdocs.com'
49
+ : 'https://api.verdocs.com');
47
50
  this.baseURLv2 = 'https://api-v2.verdocs.com';
48
51
  this.clientID = 'not-set';
49
52
  this.timeout = 60000;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "3.10.18",
3
+ "version": "3.10.21",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",