@verdocs/js-sdk 1.3.0 → 1.4.0

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/HTTP/Transport.js CHANGED
@@ -5,8 +5,8 @@
5
5
  *
6
6
  * @module
7
7
  */
8
- import globalThis from './globalThis';
9
8
  import { VerdocsEndpoint } from './VerdocsEndpoint';
9
+ import globalThis from './globalThis';
10
10
  // @credit https://derickbailey.com/2016/03/09/creating-a-true-singleton-in-node-js-with-es6-symbols/
11
11
  // Also see globalThis for comments about why we're doing this in the first place.
12
12
  var ENDPOINT_KEY = Symbol.for('verdocs-api-endpoint');
@@ -1,7 +1,32 @@
1
- import { ITag, ITags } from './Types';
2
- export declare const addTemplateTag: (templateId: string, params: any) => Promise<ITag>;
3
- export declare const getTemplateTags: (templateId: string) => Promise<ITag[]>;
1
+ /**
2
+ * A Tag is a user-specified label applied to a template. Tags help users organize and find Templates.
3
+ * recipients. Every Organization has a set of tags "owned" by that Organization and only visible inside it.
4
+ * Verdocs also provides a set of system-wide "featured" tags available to all Organizations.
5
+ *
6
+ * @module
7
+ */
8
+ import { ITemplateTag, ITag } from './Types';
9
+ /**
10
+ * Apply a tag to a template.
11
+ */
12
+ export declare const addTemplateTag: (templateId: string, params: ITag) => Promise<ITemplateTag>;
13
+ /**
14
+ * Get all tags for a template.
15
+ */
16
+ export declare const getTemplateTags: (templateId: string) => Promise<ITemplateTag[]>;
17
+ /**
18
+ * Remove a tag from a template.
19
+ */
4
20
  export declare const deleteTemplateTag: (templateId: string, tagName: string) => Promise<any>;
5
- export declare const createTag: (params: ITags) => Promise<ITags>;
6
- export declare const getTag: (tagName: string) => Promise<ITags>;
7
- export declare const getAllTags: (params: any) => Promise<ITags[]>;
21
+ /**
22
+ * Create an Organization-wide tag.
23
+ */
24
+ export declare const createTag: (name: string) => Promise<ITag>;
25
+ /**
26
+ * Get an Organization-wide tag.
27
+ */
28
+ export declare const getTag: (name: string) => Promise<ITag>;
29
+ /**
30
+ * Get all tags available for use by an Organization.
31
+ */
32
+ export declare const getAllTags: () => Promise<ITag[]>;
package/Templates/Tags.js CHANGED
@@ -1,31 +1,56 @@
1
+ /**
2
+ * A Tag is a user-specified label applied to a template. Tags help users organize and find Templates.
3
+ * recipients. Every Organization has a set of tags "owned" by that Organization and only visible inside it.
4
+ * Verdocs also provides a set of system-wide "featured" tags available to all Organizations.
5
+ *
6
+ * @module
7
+ */
1
8
  import { getEndpoint } from '../HTTP/Transport';
9
+ /**
10
+ * Apply a tag to a template.
11
+ */
2
12
  export var addTemplateTag = function (templateId, params) {
3
13
  return getEndpoint()
4
14
  .api.post("/templates/".concat(templateId, "/tags/"), params)
5
15
  .then(function (r) { return r.data; });
6
16
  };
17
+ /**
18
+ * Get all tags for a template.
19
+ */
7
20
  export var getTemplateTags = function (templateId) {
8
21
  return getEndpoint()
9
22
  .api.get("/templates/".concat(templateId, "/tags/"))
10
23
  .then(function (r) { return r.data; });
11
24
  };
25
+ /**
26
+ * Remove a tag from a template.
27
+ */
12
28
  export var deleteTemplateTag = function (templateId, tagName) {
13
29
  return getEndpoint()
14
30
  .api.post("/templates/".concat(templateId, "/tags/").concat(tagName))
15
31
  .then(function (r) { return r.data; });
16
32
  };
17
- export var createTag = function (params) {
33
+ /**
34
+ * Create an Organization-wide tag.
35
+ */
36
+ export var createTag = function (name) {
18
37
  return getEndpoint()
19
- .api.post('/tags', params)
38
+ .api.post('/tags', { tag_name: name })
20
39
  .then(function (r) { return r.data; });
21
40
  };
22
- export var getTag = function (tagName) {
41
+ /**
42
+ * Get an Organization-wide tag.
43
+ */
44
+ export var getTag = function (name) {
23
45
  return getEndpoint()
24
- .api.get("/tags/".concat(tagName))
46
+ .api.get("/tags/".concat(name))
25
47
  .then(function (r) { return r.data; });
26
48
  };
27
- export var getAllTags = function (params) {
49
+ /**
50
+ * Get all tags available for use by an Organization.
51
+ */
52
+ export var getAllTags = function () {
28
53
  return getEndpoint()
29
- .api.get('/tags', params)
54
+ .api.get('/tags')
30
55
  .then(function (r) { return r.data; });
31
56
  };
@@ -0,0 +1,46 @@
1
+ /**
2
+ * A TemplateDocument represents a PDF or other attachment in a Template.
3
+ *
4
+ * @module
5
+ */
6
+ import { ITemplateDocument } from './Types';
7
+ /**
8
+ * Get all the Template Documents associated to a particular Template.
9
+ *
10
+ * ```typescript
11
+ * import {TemplateDocument} from '@verdocs/js-sdk/Templates';
12
+ *
13
+ * await TemplateDocument.getDocuments(templateID);
14
+ * ```
15
+ */
16
+ export declare const getTemplateDocuments: (templateId: string) => Promise<ITemplateDocument[]>;
17
+ /**
18
+ * Create a Document for a particular Template.
19
+ *
20
+ * ```typescript
21
+ * import {TemplateDocument} from '@verdocs/js-sdk/Templates';
22
+ *
23
+ * await TemplateDocument.createDocument(templateID, params);
24
+ * ```
25
+ */
26
+ export declare const createTemplateDocument: (templateId: string, params: any) => Promise<ITemplateDocument>;
27
+ /**
28
+ * Get a specific Document.
29
+ *
30
+ * ```typescript
31
+ * import {TemplateDocument} from '@verdocs/js-sdk/Templates';
32
+ *
33
+ * await TemplateDocument.getDocument(templateID, documentID);
34
+ * ```
35
+ */
36
+ export declare const getTemplateDocument: (templateId: string, documentId: string) => Promise<ITemplateDocument>;
37
+ /**
38
+ * Delete a specific Document.
39
+ *
40
+ * ```typescript
41
+ * import {TemplateDocument} from '@verdocs/js-sdk/Templates';
42
+ *
43
+ * await TemplateDocument.deleteDocument(templateID, documentID);
44
+ * ```
45
+ */
46
+ export declare const deleteTemplateDocument: (templateId: string, documentId: string) => Promise<any>;
@@ -0,0 +1,62 @@
1
+ /**
2
+ * A TemplateDocument represents a PDF or other attachment in a Template.
3
+ *
4
+ * @module
5
+ */
6
+ import { getEndpoint } from '../HTTP/Transport';
7
+ /**
8
+ * Get all the Template Documents associated to a particular Template.
9
+ *
10
+ * ```typescript
11
+ * import {TemplateDocument} from '@verdocs/js-sdk/Templates';
12
+ *
13
+ * await TemplateDocument.getDocuments(templateID);
14
+ * ```
15
+ */
16
+ export var getTemplateDocuments = function (templateId) {
17
+ return getEndpoint()
18
+ .api.get("/templates/".concat(templateId, "/documents/"))
19
+ .then(function (r) { return r.data; });
20
+ };
21
+ /**
22
+ * Create a Document for a particular Template.
23
+ *
24
+ * ```typescript
25
+ * import {TemplateDocument} from '@verdocs/js-sdk/Templates';
26
+ *
27
+ * await TemplateDocument.createDocument(templateID, params);
28
+ * ```
29
+ */
30
+ export var createTemplateDocument = function (templateId, params) {
31
+ return getEndpoint()
32
+ .api.post("/templates/".concat(templateId, "/documents/"), params)
33
+ .then(function (r) { return r.data; });
34
+ };
35
+ /**
36
+ * Get a specific Document.
37
+ *
38
+ * ```typescript
39
+ * import {TemplateDocument} from '@verdocs/js-sdk/Templates';
40
+ *
41
+ * await TemplateDocument.getDocument(templateID, documentID);
42
+ * ```
43
+ */
44
+ export var getTemplateDocument = function (templateId, documentId) {
45
+ return getEndpoint()
46
+ .api.get("/templates/".concat(templateId, "/documents/").concat(documentId))
47
+ .then(function (r) { return r.data; });
48
+ };
49
+ /**
50
+ * Delete a specific Document.
51
+ *
52
+ * ```typescript
53
+ * import {TemplateDocument} from '@verdocs/js-sdk/Templates';
54
+ *
55
+ * await TemplateDocument.deleteDocument(templateID, documentID);
56
+ * ```
57
+ */
58
+ export var deleteTemplateDocument = function (templateId, documentId) {
59
+ return getEndpoint()
60
+ .api.delete("/templates/".concat(templateId, "/documents/").concat(documentId))
61
+ .then(function (r) { return r.data; });
62
+ };
@@ -1,13 +1,58 @@
1
+ /**
2
+ * A Template defines how a Verdocs signing flow will be performed, including attachments, signing fields, and
3
+ * recipients.
4
+ *
5
+ * @module
6
+ */
1
7
  import { ITemplate, ITemplatesSearchResult, ITemplatesSummary } from './Types';
2
8
  export interface IGetTemplatesParams {
3
9
  is_starred?: boolean;
4
10
  is_creator?: boolean;
5
11
  is_organization?: boolean;
6
12
  }
13
+ /**
14
+ * Get all templates accessible by the caller, with optional filters.
15
+ *
16
+ * ```typescript
17
+ * import {Templates} from '@verdocs/js-sdk/Templates';
18
+ *
19
+ * await Templates.getTemplates();
20
+ * await Templates.getTemplates({ is_starred: true });
21
+ * await Templates.getTemplates({ is_creator: true });
22
+ * await Templates.getTemplates({ is_organization: true });
23
+ * ```
24
+ */
7
25
  export declare const getTemplates: (params?: IGetTemplatesParams) => Promise<any[]>;
26
+ /**
27
+ * Get one template by its ID.
28
+ *
29
+ * ```typescript
30
+ * import {Templates} from '@verdocs/js-sdk/Templates';
31
+ *
32
+ * const template = await Templates.getTemplate('83da3d70-7857-4392-b876-c4592a304bc9');
33
+ * ```
34
+ */
8
35
  export declare const getTemplate: (templateId: string) => Promise<any>;
36
+ /**
37
+ * Create a template.
38
+ *
39
+ * ```typescript
40
+ * import {Templates} from '@verdocs/js-sdk/Templates';
41
+ *
42
+ * const newTemplate = await Templates.createTemplate({...});
43
+ * ```
44
+ */
9
45
  export declare const createTemplate: (params: any) => Promise<ITemplate>;
10
- export declare const editTemplate: (templateId: string, params: any) => Promise<ITemplate>;
46
+ /**
47
+ * Update a template.
48
+ *
49
+ * ```typescript
50
+ * import {Templates} from '@verdocs/js-sdk/Templates';
51
+ *
52
+ * const updatedTemplate = await Templates.updateTemplate('83da3d70-7857-4392-b876-c4592a304bc9', { name: 'New Name' });
53
+ * ```
54
+ */
55
+ export declare const updateTemplate: (templateId: string, params: any) => Promise<ITemplate>;
11
56
  /**
12
57
  * Search for templates matching various criteria.
13
58
  *
@@ -18,4 +63,13 @@ export declare const editTemplate: (templateId: string, params: any) => Promise<
18
63
  * ```
19
64
  */
20
65
  export declare const searchTemplates: (params: any) => Promise<ITemplatesSearchResult>;
66
+ /**
67
+ * Get a summary of template data, typically used to populate admin panel dashboard pages.
68
+ *
69
+ * ```typescript
70
+ * import {Templates} from '@verdocs/js-sdk/Templates';
71
+ *
72
+ * const summary = await Templates.getSummary(0);
73
+ * ```
74
+ */
21
75
  export declare const getSummary: (page: number) => Promise<ITemplatesSummary>;
@@ -1,3 +1,9 @@
1
+ /**
2
+ * A Template defines how a Verdocs signing flow will be performed, including attachments, signing fields, and
3
+ * recipients.
4
+ *
5
+ * @module
6
+ */
1
7
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
8
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
9
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,22 +41,61 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
41
  }
36
42
  };
37
43
  import { getEndpoint } from '../HTTP/Transport';
44
+ /**
45
+ * Get all templates accessible by the caller, with optional filters.
46
+ *
47
+ * ```typescript
48
+ * import {Templates} from '@verdocs/js-sdk/Templates';
49
+ *
50
+ * await Templates.getTemplates();
51
+ * await Templates.getTemplates({ is_starred: true });
52
+ * await Templates.getTemplates({ is_creator: true });
53
+ * await Templates.getTemplates({ is_organization: true });
54
+ * ```
55
+ */
38
56
  export var getTemplates = function (params) {
39
57
  return getEndpoint()
40
58
  .api.get('/templates/', { params: params })
41
59
  .then(function (r) { return r.data; });
42
60
  };
61
+ /**
62
+ * Get one template by its ID.
63
+ *
64
+ * ```typescript
65
+ * import {Templates} from '@verdocs/js-sdk/Templates';
66
+ *
67
+ * const template = await Templates.getTemplate('83da3d70-7857-4392-b876-c4592a304bc9');
68
+ * ```
69
+ */
43
70
  export var getTemplate = function (templateId) {
44
71
  return getEndpoint()
45
72
  .api.get("/templates/".concat(templateId))
46
73
  .then(function (r) { return r.data; });
47
74
  };
75
+ /**
76
+ * Create a template.
77
+ *
78
+ * ```typescript
79
+ * import {Templates} from '@verdocs/js-sdk/Templates';
80
+ *
81
+ * const newTemplate = await Templates.createTemplate({...});
82
+ * ```
83
+ */
48
84
  export var createTemplate = function (params) {
49
85
  return getEndpoint()
50
86
  .api.post('/templates/', params)
51
87
  .then(function (r) { return r.data; });
52
88
  };
53
- export var editTemplate = function (templateId, params) {
89
+ /**
90
+ * Update a template.
91
+ *
92
+ * ```typescript
93
+ * import {Templates} from '@verdocs/js-sdk/Templates';
94
+ *
95
+ * const updatedTemplate = await Templates.updateTemplate('83da3d70-7857-4392-b876-c4592a304bc9', { name: 'New Name' });
96
+ * ```
97
+ */
98
+ export var updateTemplate = function (templateId, params) {
54
99
  return getEndpoint()
55
100
  .api.put("/templates/".concat(templateId), params)
56
101
  .then(function (r) { return r.data; });
@@ -71,6 +116,15 @@ export var searchTemplates = function (params) { return __awaiter(void 0, void 0
71
116
  .then(function (r) { return r.data; })];
72
117
  });
73
118
  }); };
119
+ /**
120
+ * Get a summary of template data, typically used to populate admin panel dashboard pages.
121
+ *
122
+ * ```typescript
123
+ * import {Templates} from '@verdocs/js-sdk/Templates';
124
+ *
125
+ * const summary = await Templates.getSummary(0);
126
+ * ```
127
+ */
74
128
  export var getSummary = function (page) { return __awaiter(void 0, void 0, void 0, function () {
75
129
  return __generator(this, function (_a) {
76
130
  return [2 /*return*/, getEndpoint()
@@ -1,6 +1,6 @@
1
1
  import { IOrganization } from '../Organizations/Types';
2
2
  export interface ITemplate {
3
- template_document?: ITemplateAsset;
3
+ template_document?: ITemplateDocument;
4
4
  pages?: IPage[];
5
5
  roles?: IRole[];
6
6
  counter?: number;
@@ -110,13 +110,14 @@ export interface ITemplatesSearchResult {
110
110
  total: number;
111
111
  result: ITemplate[];
112
112
  }
113
- export interface ITag {
113
+ export interface ITemplateTag {
114
114
  tag_name: string;
115
115
  template_id: string;
116
116
  }
117
- export interface ITags {
117
+ export interface ITag {
118
118
  name: string;
119
119
  featured?: boolean;
120
+ organization_id?: string;
120
121
  created_at?: string;
121
122
  }
122
123
  export interface IStar {
@@ -136,7 +137,7 @@ export interface IRole {
136
137
  phone?: string;
137
138
  rgba?: string;
138
139
  }
139
- export interface ITemplateAsset {
140
+ export interface ITemplateDocument {
140
141
  url: string;
141
142
  name: string;
142
143
  page_numbers: number;
@@ -180,7 +181,7 @@ export interface IFieldSetting {
180
181
  export interface IPage {
181
182
  template_id: string;
182
183
  document_id: string;
183
- template_document?: ITemplateAsset;
184
+ template_document?: ITemplateDocument;
184
185
  sequence: number;
185
186
  page_number: number;
186
187
  thumbnail_url: string;
@@ -3,6 +3,15 @@ export interface IValidator {
3
3
  name: string;
4
4
  regex: string;
5
5
  }
6
+ /**
7
+ * Get all defined validators
8
+ *
9
+ * ```typescript
10
+ * import {Documents} from '@verdocs/js-sdk/Templates';
11
+ *
12
+ * await Documents.getDocuments(templateID);
13
+ * ```
14
+ */
6
15
  export declare const getValidators: () => Promise<IValidator[]>;
7
16
  export declare const getValidator: (validatorName: string) => Promise<IValidator>;
8
17
  export declare const isValidEmail: (value: string) => boolean;
@@ -1,5 +1,14 @@
1
1
  import { simpleE164Validator } from '../Utils/Locales';
2
2
  import { getEndpoint } from '../HTTP/Transport';
3
+ /**
4
+ * Get all defined validators
5
+ *
6
+ * ```typescript
7
+ * import {Documents} from '@verdocs/js-sdk/Templates';
8
+ *
9
+ * await Documents.getDocuments(templateID);
10
+ * ```
11
+ */
3
12
  export var getValidators = function () {
4
13
  return getEndpoint()
5
14
  .api.get('/validators')
@@ -16,5 +25,5 @@ export var isValidPhone = function (value) { return simpleE164Validator(value);
16
25
  export var isValidRoleName = function (value, roles) { return roles.findIndex(function (role) { return role.name === value; }) !== -1; };
17
26
  var TagRegEx = /^[a-zA-Z0-9-]{0,32}$/;
18
27
  export var isValidTag = function (value, tags) {
19
- return TagRegEx.test(value) || tags.findIndex(function (tag) { return tag.tag_name === value; }) !== -1;
28
+ return TagRegEx.test(value) || tags.findIndex(function (tag) { return tag.name === value; }) !== -1;
20
29
  };
@@ -1,4 +1,3 @@
1
- export * as Documents from './Documents';
2
1
  export * as Fields from './Fields';
3
2
  export * as Pages from './Pages';
4
3
  export * as Reminders from './Reminders';
@@ -6,5 +5,6 @@ export * as Roles from './Roles';
6
5
  export * as Stars from './Stars';
7
6
  export * as Tags from './Tags';
8
7
  export * as Templates from './Templates';
8
+ export * as TemplateDocuments from './TemplateDocuments';
9
9
  export * as Types from './Types';
10
10
  export * as Validators from './Validators';
@@ -1,4 +1,3 @@
1
- export * as Documents from './Documents';
2
1
  export * as Fields from './Fields';
3
2
  export * as Pages from './Pages';
4
3
  export * as Reminders from './Reminders';
@@ -6,5 +5,6 @@ export * as Roles from './Roles';
6
5
  export * as Stars from './Stars';
7
6
  export * as Tags from './Tags';
8
7
  export * as Templates from './Templates';
8
+ export * as TemplateDocuments from './TemplateDocuments';
9
9
  export * as Types from './Types';
10
10
  export * as Validators from './Validators';
package/Users/Auth.d.ts CHANGED
@@ -93,3 +93,8 @@ export declare const loadSession: (source: string) => IActiveSession | ISigningS
93
93
  * End the active session.
94
94
  */
95
95
  export declare const endSession: (source: string, persist?: boolean) => null;
96
+ export declare type SessionChangedListener = (source: string, session: IActiveSession | ISigningSession | null) => void;
97
+ /**
98
+ * Subscribe to session state change events.
99
+ */
100
+ export declare const onSessionChanged: (listener: SessionChangedListener) => () => void;
package/Users/Auth.js CHANGED
@@ -107,6 +107,7 @@ var clearSession = function (source, persist) {
107
107
  if (persist) {
108
108
  localStorage.removeItem(source);
109
109
  }
110
+ notifySessionListeners(source, null);
110
111
  return null;
111
112
  };
112
113
  /**
@@ -125,6 +126,7 @@ export var setSession = function (source, token, persist) {
125
126
  localStorage.setItem(source, token);
126
127
  }
127
128
  getEndpoint().setAuthorization(token);
129
+ notifySessionListeners(source, session);
128
130
  return session;
129
131
  };
130
132
  /**
@@ -144,6 +146,7 @@ export var loadSession = function (source) {
144
146
  return null;
145
147
  }
146
148
  getEndpoint().setAuthorization(token);
149
+ notifySessionListeners(source, session);
147
150
  return session;
148
151
  };
149
152
  /**
@@ -153,3 +156,27 @@ export var endSession = function (source, persist) {
153
156
  if (persist === void 0) { persist = false; }
154
157
  return clearSession(source, persist);
155
158
  };
159
+ var sessionChangedListeners = new Map();
160
+ var nextListenerId = 1;
161
+ /**
162
+ * Subscribe to session state change events.
163
+ */
164
+ export var onSessionChanged = function (listener) {
165
+ // There's no value in randomizing this so we don't
166
+ var listenerId = ++nextListenerId;
167
+ var listenerSymbol = Symbol.for('' + listenerId);
168
+ sessionChangedListeners.set(listenerSymbol, listener);
169
+ return function () {
170
+ sessionChangedListeners.delete(listenerSymbol);
171
+ };
172
+ };
173
+ var notifySessionListeners = function (source, session) {
174
+ sessionChangedListeners.forEach(function (listener) {
175
+ try {
176
+ listener(source, session);
177
+ }
178
+ catch (e) {
179
+ // NOOP
180
+ }
181
+ });
182
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",
@@ -51,15 +51,16 @@
51
51
  "typescript": "^4.7.3"
52
52
  },
53
53
  "devDependencies": {
54
- "@types/jest": "^28.1.1",
55
- "jest": "^28.1.1",
56
- "jest-mock-axios": "^4.6.1",
57
- "prettier": "^2.7.0",
54
+ "@jest/globals": "^28.1.2",
55
+ "@types/jest": "^28.1.4",
56
+ "axios-mock-adapter": "^1.21.1",
57
+ "jest": "^28.1.2",
58
+ "prettier": "^2.7.1",
58
59
  "ts-jest": "^28.0.5",
59
60
  "tslint": "^6.1.3",
60
61
  "tslint-config-prettier": "^1.18.0",
61
- "typedoc": "^0.22.17",
62
- "typedoc-plugin-markdown": "^3.12.1",
63
- "typescript": "^4.7.3"
62
+ "typedoc": "^0.23.9",
63
+ "typedoc-plugin-markdown": "^3.13.4",
64
+ "typescript": "^4.7.4"
64
65
  }
65
66
  }
@@ -1,41 +0,0 @@
1
- import { ITemplateAsset } from './Types';
2
- /**
3
- * Get all the Documents associated to a particular Template.
4
- *
5
- * ```typescript
6
- * import {Documents} from '@verdocs/js-sdk/Templates';
7
- *
8
- * await Documents.getDocuments(templateID);
9
- * ```
10
- */
11
- export declare const getDocuments: (templateId: string) => Promise<any>;
12
- /**
13
- * Create a Document for a particular Template.
14
- *
15
- * ```typescript
16
- * import {Documents} from '@verdocs/js-sdk/Templates';
17
- *
18
- * await Documents.createDocument(templateID, params);
19
- * ```
20
- */
21
- export declare const createDocument: (templateId: string, params: any) => Promise<ITemplateAsset>;
22
- /**
23
- * Get a specific Document.
24
- *
25
- * ```typescript
26
- * import {Documents} from '@verdocs/js-sdk/Templates';
27
- *
28
- * await Documents.getDocument(templateID, documentID);
29
- * ```
30
- */
31
- export declare const getDocument: (templateId: string, documentId: string) => Promise<ITemplateAsset>;
32
- /**
33
- * Delete a specific Document.
34
- *
35
- * ```typescript
36
- * import {Documents} from '@verdocs/js-sdk/Templates';
37
- *
38
- * await Documents.deleteDocument(templateID, documentID);
39
- * ```
40
- */
41
- export declare const deleteDocument: (templateId: string, documentId: string) => Promise<any>;
@@ -1,57 +0,0 @@
1
- import { getEndpoint } from '../HTTP/Transport';
2
- /**
3
- * Get all the Documents associated to a particular Template.
4
- *
5
- * ```typescript
6
- * import {Documents} from '@verdocs/js-sdk/Templates';
7
- *
8
- * await Documents.getDocuments(templateID);
9
- * ```
10
- */
11
- export var getDocuments = function (templateId) {
12
- return getEndpoint()
13
- .api.get("/templates/".concat(templateId, "/documents/"))
14
- .then(function (r) { return r.data; });
15
- };
16
- /**
17
- * Create a Document for a particular Template.
18
- *
19
- * ```typescript
20
- * import {Documents} from '@verdocs/js-sdk/Templates';
21
- *
22
- * await Documents.createDocument(templateID, params);
23
- * ```
24
- */
25
- export var createDocument = function (templateId, params) {
26
- return getEndpoint()
27
- .api.post("/templates/".concat(templateId, "/documents/"), params)
28
- .then(function (r) { return r.data; });
29
- };
30
- /**
31
- * Get a specific Document.
32
- *
33
- * ```typescript
34
- * import {Documents} from '@verdocs/js-sdk/Templates';
35
- *
36
- * await Documents.getDocument(templateID, documentID);
37
- * ```
38
- */
39
- export var getDocument = function (templateId, documentId) {
40
- return getEndpoint()
41
- .api.get("/templates/".concat(templateId, "/documents/").concat(documentId))
42
- .then(function (r) { return r.data; });
43
- };
44
- /**
45
- * Delete a specific Document.
46
- *
47
- * ```typescript
48
- * import {Documents} from '@verdocs/js-sdk/Templates';
49
- *
50
- * await Documents.deleteDocument(templateID, documentID);
51
- * ```
52
- */
53
- export var deleteDocument = function (templateId, documentId) {
54
- return getEndpoint()
55
- .api.delete("/templates/".concat(templateId, "/documents/").concat(documentId))
56
- .then(function (r) { return r.data; });
57
- };