@verdocs/js-sdk 1.1.8 → 1.1.12

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.
@@ -1,4 +1,5 @@
1
1
  import { ISigningSession, ISigningSessionRequest } from './Types';
2
+ import { IFieldSetting } from '../Templates/Types';
2
3
  export declare type TDocumentStatus = 'complete' | 'pending' | 'in progress' | 'declined' | 'canceled';
3
4
  export declare type TRecipientStatus = 'invited' | 'opened' | 'signed' | 'submitted' | 'canceled' | 'pending' | 'declined';
4
5
  export declare type TRecipientType = 'signer' | 'cc' | 'approver';
@@ -63,6 +64,28 @@ export interface IRecipient {
63
64
  type: TRecipientType;
64
65
  updated_at: string;
65
66
  }
67
+ export interface IDocumentAsset {
68
+ created_at: string;
69
+ id: string;
70
+ mime: string;
71
+ name: string;
72
+ page_numbers: number;
73
+ updated_at: string;
74
+ url: string;
75
+ }
76
+ export interface IDocumentField {
77
+ envelope_id: string;
78
+ label: string | null;
79
+ name: string;
80
+ page: number;
81
+ recipient_role: string;
82
+ type: string;
83
+ required: boolean;
84
+ settings?: IFieldSetting;
85
+ setting?: IFieldSetting;
86
+ validator: string | null;
87
+ prepared?: boolean;
88
+ }
66
89
  export interface IDocument {
67
90
  id: string;
68
91
  created_at: string;
@@ -79,6 +102,9 @@ export interface IDocument {
79
102
  template_id: string;
80
103
  updated_at: string;
81
104
  organization_id: string | null;
105
+ certificate?: IDocumentAsset | null;
106
+ document?: IDocumentAsset | null;
107
+ fields?: IDocumentField[];
82
108
  }
83
109
  export interface IActivityEntry {
84
110
  id: string;
@@ -150,3 +176,4 @@ export declare const getSigningSession: (params: ISigningSessionRequest) => Prom
150
176
  export declare const getDocumentRecipients: (documentId: string) => Promise<IRecipient[]>;
151
177
  export declare const getDocument: (documentId: string) => Promise<IDocument>;
152
178
  export declare const getDocumentFile: (documentId: string, envelopeDocumentId: string) => Promise<string>;
179
+ export declare const updateDocumentField: (documentId: string, fieldName: string, value: any) => Promise<IFieldSetting>;
@@ -108,3 +108,10 @@ export var getDocumentFile = function (documentId, envelopeDocumentId) { return
108
108
  .then(function (r) { return Buffer.from(r.data, 'binary').toString('base64'); })];
109
109
  });
110
110
  }); };
111
+ export var updateDocumentField = function (documentId, fieldName, value) { return __awaiter(void 0, void 0, void 0, function () {
112
+ return __generator(this, function (_a) {
113
+ return [2 /*return*/, getEndpoint()
114
+ .api.put("/documents/".concat(documentId, "/fields/").concat(fieldName), value)
115
+ .then(function (r) { return r.data; })];
116
+ });
117
+ }); };
@@ -0,0 +1,14 @@
1
+ export interface IInitials {
2
+ id?: string;
3
+ profile_id: string;
4
+ url: string;
5
+ created_at?: Date;
6
+ updated_at?: Date;
7
+ }
8
+ /**
9
+ * Create an initials block. In a typical signing workflow, the user is asked at the beginning of the process to "adopt"
10
+ * an initials block to be used for all initials fields in the document. Thus, this is typically called one time to
11
+ * create and store an initials block. Thereafter, the ID of the initials block may be re-used for each initials field
12
+ * to be "stamped" by the user.
13
+ */
14
+ export declare const createInitials: (name: string, initials: string | Blob) => Promise<IInitials>;
@@ -0,0 +1,14 @@
1
+ import { getEndpoint } from '../HTTP/Transport';
2
+ /**
3
+ * Create an initials block. In a typical signing workflow, the user is asked at the beginning of the process to "adopt"
4
+ * an initials block to be used for all initials fields in the document. Thus, this is typically called one time to
5
+ * create and store an initials block. Thereafter, the ID of the initials block may be re-used for each initials field
6
+ * to be "stamped" by the user.
7
+ */
8
+ export var createInitials = function (name, initials) {
9
+ var data = new FormData();
10
+ data.append('initial', initials, name);
11
+ return getEndpoint()
12
+ .api.post("/initials", data)
13
+ .then(function (r) { return r.data; });
14
+ };
@@ -5,7 +5,13 @@ export interface ISignature {
5
5
  created_at?: Date;
6
6
  updated_at?: Date;
7
7
  }
8
- export declare const createSignature: (params: any) => Promise<ISignature>;
8
+ /**
9
+ * Create a signature block. In a typical signing workflow, the user is asked at the beginning of the process to "adopt"
10
+ * a signature block to be used for all signature fields in the document. Thus, this is typically called one time to
11
+ * create and store a signature block. Thereafter, the ID of the signature block may be re-used for each signature field
12
+ * to be "stamped" by the user.
13
+ */
14
+ export declare const createSignature: (name: string, signature: string | Blob) => Promise<ISignature>;
9
15
  export declare const getSignatures: () => Promise<ISignature[]>;
10
16
  export declare const getSignature: (signatureId: string) => Promise<any>;
11
17
  export declare const deleteSignature: (signatureId: string) => Promise<any>;
@@ -1,7 +1,15 @@
1
1
  import { getEndpoint } from '../HTTP/Transport';
2
- export var createSignature = function (params) {
2
+ /**
3
+ * Create a signature block. In a typical signing workflow, the user is asked at the beginning of the process to "adopt"
4
+ * a signature block to be used for all signature fields in the document. Thus, this is typically called one time to
5
+ * create and store a signature block. Thereafter, the ID of the signature block may be re-used for each signature field
6
+ * to be "stamped" by the user.
7
+ */
8
+ export var createSignature = function (name, signature) {
9
+ var data = new FormData();
10
+ data.append('signature', signature, name);
3
11
  return getEndpoint()
4
- .api.post('/signatures', params)
12
+ .api.post("/signatures", data)
5
13
  .then(function (r) { return r.data; });
6
14
  };
7
15
  export var getSignatures = function () {
@@ -2,4 +2,5 @@ export * as Documents from './Documents';
2
2
  export * as Recipients from './Recipients';
3
3
  export * as Stars from './Stars';
4
4
  export * as Signatures from './Signatures';
5
+ export * as Initials from './Initials';
5
6
  export * as Types from './Types';
@@ -2,4 +2,5 @@ export * as Documents from './Documents';
2
2
  export * as Recipients from './Recipients';
3
3
  export * as Stars from './Stars';
4
4
  export * as Signatures from './Signatures';
5
+ export * as Initials from './Initials';
5
6
  export * as Types from './Types';
@@ -57,6 +57,18 @@ export declare class VerdocsEndpoint {
57
57
  * ```
58
58
  */
59
59
  setAuthorization(accessToken: string | null): void;
60
+ /**
61
+ * Set the auth token used for signing sessions. Separating user from signing auth allows the same endpoint to be
62
+ * used for multiple operations, although it is recommended that a separate endpoint be created for each operation.
63
+ *
64
+ * ```typescript
65
+ * import {Endpoint} from '@verdocs/js-sdk/HTTP';
66
+ *
67
+ * const endpoint = new Endpoint();
68
+ * endpoint.setSigningAuthorization(accessToken);
69
+ * ```
70
+ */
71
+ setSigningAuthorization(accessToken: string | null): void;
60
72
  /**
61
73
  * Set the base URL for API calls. May also be set via the constructor.
62
74
  *
@@ -75,6 +75,25 @@ var VerdocsEndpoint = /** @class */ (function () {
75
75
  delete this.api.defaults.headers.Authorization;
76
76
  }
77
77
  };
78
+ /**
79
+ * Set the auth token used for signing sessions. Separating user from signing auth allows the same endpoint to be
80
+ * used for multiple operations, although it is recommended that a separate endpoint be created for each operation.
81
+ *
82
+ * ```typescript
83
+ * import {Endpoint} from '@verdocs/js-sdk/HTTP';
84
+ *
85
+ * const endpoint = new Endpoint();
86
+ * endpoint.setSigningAuthorization(accessToken);
87
+ * ```
88
+ */
89
+ VerdocsEndpoint.prototype.setSigningAuthorization = function (accessToken) {
90
+ if (accessToken) {
91
+ this.api.defaults.headers.signer = "Bearer ".concat(accessToken);
92
+ }
93
+ else {
94
+ delete this.api.defaults.headers.signer;
95
+ }
96
+ };
78
97
  /**
79
98
  * Set the base URL for API calls. May also be set via the constructor.
80
99
  *
@@ -1,4 +1,4 @@
1
- import { IDocument } from './Types';
1
+ import { ITemplateAsset } from './Types';
2
2
  /**
3
3
  * Get all the Documents associated to a particular Template.
4
4
  *
@@ -18,7 +18,7 @@ export declare const getDocuments: (templateId: string) => Promise<any>;
18
18
  * await Documents.createDocument(templateID, params);
19
19
  * ```
20
20
  */
21
- export declare const createDocument: (templateId: string, params: any) => Promise<IDocument>;
21
+ export declare const createDocument: (templateId: string, params: any) => Promise<ITemplateAsset>;
22
22
  /**
23
23
  * Get a specific Document.
24
24
  *
@@ -28,7 +28,7 @@ export declare const createDocument: (templateId: string, params: any) => Promis
28
28
  * await Documents.getDocument(templateID, documentID);
29
29
  * ```
30
30
  */
31
- export declare const getDocument: (templateId: string, documentId: string) => Promise<IDocument>;
31
+ export declare const getDocument: (templateId: string, documentId: string) => Promise<ITemplateAsset>;
32
32
  /**
33
33
  * Delete a specific Document.
34
34
  *
@@ -1,4 +1,4 @@
1
- import { IField } from './Types';
2
- export declare const createField: (templateId: string, params: IField) => Promise<IField>;
3
- export declare const editField: (templateId: string, fieldName: string, params: IField) => Promise<IField>;
1
+ import { ITemplateField } from './Types';
2
+ export declare const createField: (templateId: string, params: ITemplateField) => Promise<ITemplateField>;
3
+ export declare const editField: (templateId: string, fieldName: string, params: ITemplateField) => Promise<ITemplateField>;
4
4
  export declare const deleteField: (templateId: string, fieldName: string) => Promise<any>;
@@ -1,8 +1,8 @@
1
- import { IField, IRole } from './Types';
1
+ import { ITemplateField, IRole } from './Types';
2
2
  export declare const createRole: (templateId: string, params: IRole) => Promise<IRole>;
3
3
  export declare const getRoles: (templateId: string) => Promise<IRole[]>;
4
4
  export declare const getRole: (templateId: string, roleName: string) => Promise<IRole>;
5
5
  export declare const editRole: (templateId: string, roleName: string, params: IRole) => Promise<IRole>;
6
6
  export declare const deleteRole: (templateId: string, roleName: string) => Promise<any>;
7
- export declare const getRoleFields: (templateId: string, roleName: string) => Promise<IField[]>;
7
+ export declare const getRoleFields: (templateId: string, roleName: string) => Promise<ITemplateField[]>;
8
8
  export declare const deleteSequence: (templateId: string) => Promise<IRole[]>;
@@ -1,5 +1,5 @@
1
1
  export interface ITemplate {
2
- template_document?: IDocument;
2
+ template_document?: ITemplateAsset;
3
3
  pages?: IPage[];
4
4
  roles?: IRole[];
5
5
  counter?: number;
@@ -128,13 +128,13 @@ export interface IRole {
128
128
  email?: string;
129
129
  type: string;
130
130
  sequence: number;
131
- fields?: IField[];
131
+ fields?: ITemplateField[];
132
132
  delegator?: boolean;
133
133
  message?: string;
134
134
  phone?: string;
135
135
  rgba?: string;
136
136
  }
137
- export interface IDocument {
137
+ export interface ITemplateAsset {
138
138
  url: string;
139
139
  name: string;
140
140
  page_numbers: number;
@@ -145,36 +145,39 @@ export interface IDocument {
145
145
  mime: string;
146
146
  thumbnail_url: string;
147
147
  }
148
- export interface IField {
148
+ export interface ITemplateField {
149
149
  name: string;
150
150
  role_name: string;
151
151
  template_id: string;
152
152
  type: string;
153
153
  required: boolean;
154
- setting?: ISetting;
154
+ setting?: IFieldSetting;
155
155
  page_sequence: number;
156
156
  validator?: string;
157
157
  label?: string;
158
- prepared?: boolean;
159
158
  }
160
- export interface ISetting {
159
+ export interface IFieldSetting {
161
160
  x?: number;
162
161
  y?: number;
163
162
  width?: number;
164
163
  height?: number;
165
- result?: string;
164
+ result?: any;
166
165
  type?: string;
167
- options?: any[];
168
166
  value?: string;
167
+ leading?: number;
168
+ alignment?: number;
169
+ upperCase?: boolean;
170
+ options?: any[];
171
+ [key: string]: any;
169
172
  }
170
173
  export interface IPage {
171
174
  template_id: string;
172
175
  document_id: string;
173
- template_document?: IDocument;
176
+ template_document?: ITemplateAsset;
174
177
  sequence: number;
175
178
  page_number: number;
176
179
  thumbnail_url: string;
177
- fields?: IField[];
180
+ fields?: ITemplateField[];
178
181
  }
179
182
  export interface IReminder {
180
183
  id?: string;
@@ -16,7 +16,7 @@ export var TemplateSenderTypes;
16
16
  TemplateSenderTypes["ORGANIZATION_MEMBER"] = "organization_member";
17
17
  TemplateSenderTypes["ORGANIZATION_MEMBER_AS_CREATOR"] = "organization_member_as_creator";
18
18
  TemplateSenderTypes["EVERYONE"] = "everyone";
19
- TemplateSenderTypes["EVERYONE_AS_CREATOR"] = "everyone_as_creator"; // Creator would be sender of envelope no matter who creates the envelope
19
+ TemplateSenderTypes["EVERYONE_AS_CREATOR"] = "everyone_as_creator";
20
20
  })(TemplateSenderTypes || (TemplateSenderTypes = {}));
21
21
  export var TemplateActions;
22
22
  (function (TemplateActions) {
package/Utils/Fields.d.ts CHANGED
@@ -1,12 +1,11 @@
1
- import { IField } from '../Templates/Types';
2
- export declare function getHeight(field: IField): number;
3
- export declare function getWidth(field: IField): number;
1
+ import { IDocumentField } from '../Documents/Documents';
2
+ export declare function getHeight(field: IDocumentField): number;
3
+ export declare function getWidth(field: IDocumentField): number;
4
4
  export declare function getRTop(y: number, fieldHeight: number, iTextHeight: number, yRatio: number): number;
5
5
  export declare function getRLeft(x: number, ratio: number): number;
6
6
  export declare function getRValue(y: number, ratio: number): number;
7
- export declare function getStyle(field: IField): Record<string, string>;
8
7
  export declare function blobToBase64(image: Blob): Promise<unknown>;
9
- export declare function getInputStyle(field: IField, mode: string, browserType: string): Record<string, string>;
8
+ export declare function getInputStyle(field: IDocumentField, mode: string, browserType: string): Record<string, string>;
10
9
  export declare function getCheckboxLabelStyle(required: boolean): Record<string, any>;
11
10
  export declare function getLetterSpacing(browserType: string): -0.0018 | -0.23594210526315787 | -0.0019;
12
11
  export declare function rescale(r: number, n: number): number;
package/Utils/Fields.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export function getHeight(field) {
2
- var _a;
2
+ var settings = field.settings || field.setting || {};
3
3
  switch (field.type) {
4
4
  case 'signature':
5
5
  case 'initial':
@@ -12,10 +12,10 @@ export function getHeight(field) {
12
12
  case 'payment':
13
13
  return 24;
14
14
  }
15
- return ((_a = field.setting) === null || _a === void 0 ? void 0 : _a.height) || 0;
15
+ return settings.height || 0;
16
16
  }
17
17
  export function getWidth(field) {
18
- var _a, _b;
18
+ var settings = field.settings || field.setting || {};
19
19
  switch (field.type) {
20
20
  case 'signature':
21
21
  case 'initial':
@@ -30,9 +30,9 @@ export function getWidth(field) {
30
30
  case 'date':
31
31
  return 64;
32
32
  case 'dropdown':
33
- return ((_a = field.setting) === null || _a === void 0 ? void 0 : _a.width) || 64;
33
+ return (settings === null || settings === void 0 ? void 0 : settings.width) || 64;
34
34
  }
35
- return ((_b = field.setting) === null || _b === void 0 ? void 0 : _b.width) || 0;
35
+ return (settings === null || settings === void 0 ? void 0 : settings.width) || 0;
36
36
  }
37
37
  export function getRTop(y, fieldHeight, iTextHeight, yRatio) {
38
38
  return iTextHeight - (y + fieldHeight) * yRatio;
@@ -43,44 +43,6 @@ export function getRLeft(x, ratio) {
43
43
  export function getRValue(y, ratio) {
44
44
  return y * ratio;
45
45
  }
46
- export function getStyle(field) {
47
- var _a, _b, _c;
48
- var height = getHeight(field);
49
- var style = {
50
- left: (((_a = field.setting) === null || _a === void 0 ? void 0 : _a.x) || 0) + 'px',
51
- bottom: (((_b = field.setting) === null || _b === void 0 ? void 0 : _b.y) || 0) + 'px',
52
- height: '100%',
53
- width: '100%',
54
- };
55
- switch (field.type) {
56
- case 'textbox':
57
- case 'date':
58
- case 'timestamp':
59
- case 'placeholder':
60
- case 'dropdown':
61
- style.maxHeight = height + 'px';
62
- style.maxWidth = (((_c = field.setting) === null || _c === void 0 ? void 0 : _c.width) || 0) + 'px';
63
- break;
64
- case 'checkbox':
65
- case 'checkbox_group':
66
- case 'radio_button_group':
67
- style.maxHeight = 13.5 + 'px';
68
- style.maxWidth = 13.5 + 'px';
69
- break;
70
- case 'attachment':
71
- case 'payment':
72
- style.maxHeight = 24 + 'px';
73
- style.maxWidth = 24 + 'px';
74
- break;
75
- case 'signature':
76
- case 'initial':
77
- style.maxHeight = 36 + 'px';
78
- style.maxWidth = 82.63636363636 + 'px';
79
- style['line-height'] = 36 + 'px';
80
- break;
81
- }
82
- return style;
83
- }
84
46
  export function blobToBase64(image) {
85
47
  var fileReader = new FileReader();
86
48
  return new Promise(function (resolve, reject) {
@@ -94,14 +56,14 @@ export function blobToBase64(image) {
94
56
  });
95
57
  }
96
58
  export function getInputStyle(field, mode, browserType) {
97
- var fontSize = 11;
98
- var _a = field.setting, setting = _a === void 0 ? {} : _a;
59
+ var settings = field.settings || field.setting || {};
60
+ var fontSize = (settings === null || settings === void 0 ? void 0 : settings.font_size) || 11;
99
61
  var style = {
100
62
  height: '100%',
101
63
  width: '100%',
102
64
  background: 'none',
103
65
  };
104
- if (setting.font_size ||
66
+ if (settings.font_size ||
105
67
  field.type === 'date' ||
106
68
  field.type === 'signature' ||
107
69
  field.type === 'initial' ||
@@ -123,14 +85,14 @@ export function getInputStyle(field, mode, browserType) {
123
85
  if ((field === null || field === void 0 ? void 0 : field.prepared) === true && mode !== 'prepareview') {
124
86
  style.visibility = 'hidden';
125
87
  }
126
- if (setting.color) {
127
- style.color = setting.color;
88
+ if (settings.color) {
89
+ style.color = settings.color;
128
90
  }
129
- if (setting.upperCase) {
91
+ if (settings.upperCase) {
130
92
  style.textTransform = 'uppercase';
131
93
  }
132
- if (setting.leading > 0) {
133
- style.lineHeight = "".concat(rescale(1, setting.leading + 0.5), "px");
94
+ if (settings.leading) {
95
+ style.lineHeight = "".concat(rescale(1, settings.leading + 0.5), "px");
134
96
  }
135
97
  return style;
136
98
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "1.1.8",
3
+ "version": "1.1.12",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",