@verdocs/js-sdk 2.0.2 → 2.0.5

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,6 +1,7 @@
1
1
  import { ISigningSession, ISigningSessionRequest } from './Types';
2
2
  import { VerdocsEndpoint } from '../VerdocsEndpoint';
3
3
  import { IFieldSetting } from '../Templates/Types';
4
+ import { IProfile } from '../Users/Types';
4
5
  export declare type TDocumentStatus = 'complete' | 'pending' | 'in progress' | 'declined' | 'canceled';
5
6
  export declare type TRecipientStatus = 'invited' | 'opened' | 'signed' | 'submitted' | 'canceled' | 'pending' | 'declined';
6
7
  export declare type TRecipientType = 'signer' | 'cc' | 'approver';
@@ -106,6 +107,7 @@ export interface IDocument {
106
107
  certificate?: IDocumentAsset | null;
107
108
  document?: IDocumentAsset | null;
108
109
  fields?: IDocumentField[];
110
+ profile?: IProfile;
109
111
  }
110
112
  export interface IActivityEntry {
111
113
  id: string;
@@ -1,4 +1,5 @@
1
- import { ICreateProfileRequest, IUpdateProfileRequest } from './Types';
1
+ import { ICreateProfileRequest, IPermission, IProfile, IRole, ISwitchProfileResponse, IUpdateProfileRequest } from './Types';
2
+ import { IGroup } from '../Organizations/Types';
2
3
  import { VerdocsEndpoint } from '../VerdocsEndpoint';
3
4
  /**
4
5
  * Get the user's available profiles. The current profile will be marked with `current: true`.
@@ -9,7 +10,17 @@ import { VerdocsEndpoint } from '../VerdocsEndpoint';
9
10
  * const profiles = await Profiles.getProfiles()
10
11
  * ```
11
12
  */
12
- export declare const getProfiles: (endpoint: VerdocsEndpoint) => Promise<any>;
13
+ export declare const getProfiles: (endpoint: VerdocsEndpoint) => Promise<IProfile[]>;
14
+ /**
15
+ * Get the user's available profiles. The current profile will be marked with `current: true`.
16
+ *
17
+ * ```typescript
18
+ * import {Profiles} from '@verdocs/js-sdk/Users';
19
+ *
20
+ * const profiles = await Profiles.getCurrentProfile()
21
+ * ```
22
+ */
23
+ export declare const getCurrentProfile: (endpoint: VerdocsEndpoint) => Promise<IProfile | undefined>;
13
24
  /**
14
25
  * Get a list of system roles.
15
26
  *
@@ -19,7 +30,7 @@ export declare const getProfiles: (endpoint: VerdocsEndpoint) => Promise<any>;
19
30
  * const roles = await Profiles.getRoles();
20
31
  * ```
21
32
  */
22
- export declare const getRoles: (endpoint: VerdocsEndpoint) => Promise<any>;
33
+ export declare const getRoles: (endpoint: VerdocsEndpoint) => Promise<IRole[]>;
23
34
  /**
24
35
  * Get a list of system roles.
25
36
  *
@@ -39,7 +50,7 @@ export declare const getPermissions: (endpoint: VerdocsEndpoint) => Promise<any>
39
50
  * const newProfile = await Profiles.createProfile({ first_name: 'FIRST', last_name: 'LAST', email: 'EMAIL' });
40
51
  * ```
41
52
  */
42
- export declare const createProfile: (endpoint: VerdocsEndpoint, params: ICreateProfileRequest) => Promise<any>;
53
+ export declare const createProfile: (endpoint: VerdocsEndpoint, params: ICreateProfileRequest) => Promise<IProfile>;
43
54
  /**
44
55
  * Get a profile. The caller must have admin access to the given profile.
45
56
  * TODO: Add a "public" profile endpoint for public pages
@@ -50,7 +61,7 @@ export declare const createProfile: (endpoint: VerdocsEndpoint, params: ICreateP
50
61
  * const profile = await Profiles.getProfile('PROFILEID');
51
62
  * ```
52
63
  */
53
- export declare const getProfile: (endpoint: VerdocsEndpoint, profileId: string) => Promise<any>;
64
+ export declare const getProfile: (endpoint: VerdocsEndpoint, profileId: string) => Promise<IProfile>;
54
65
  /**
55
66
  * Get a profile's permissions. The caller must have admin access to the given profile.
56
67
  *
@@ -60,7 +71,7 @@ export declare const getProfile: (endpoint: VerdocsEndpoint, profileId: string)
60
71
  * const permissions = await Profiles.getProfilePermissions('PROFILEID');
61
72
  * ```
62
73
  */
63
- export declare const getProfilePermissions: (endpoint: VerdocsEndpoint, profileId: string) => Promise<any>;
74
+ export declare const getProfilePermissions: (endpoint: VerdocsEndpoint, profileId: string) => Promise<IPermission[]>;
64
75
  /**
65
76
  * Get a profile's groups.
66
77
  *
@@ -70,7 +81,7 @@ export declare const getProfilePermissions: (endpoint: VerdocsEndpoint, profileI
70
81
  * const groups = await Profiles.getProfileGroups('PROFILEID');
71
82
  * ```
72
83
  */
73
- export declare const getProfileGroups: (endpoint: VerdocsEndpoint, profileId: string) => Promise<any>;
84
+ export declare const getProfileGroups: (endpoint: VerdocsEndpoint, profileId: string) => Promise<IGroup[]>;
74
85
  /**
75
86
  * Switch the caller's "current" profile. The current profile is used for permissions checking and profile_id field settings
76
87
  * for most operations in Verdocs. It is important to select the appropropriate profile before calling other API functions.
@@ -81,7 +92,7 @@ export declare const getProfileGroups: (endpoint: VerdocsEndpoint, profileId: st
81
92
  * const newProfile = await Profiles.switchProfile('PROFILEID');
82
93
  * ```
83
94
  */
84
- export declare const switchProfile: (endpoint: VerdocsEndpoint, profileId: string) => Promise<any>;
95
+ export declare const switchProfile: (endpoint: VerdocsEndpoint, profileId: string) => Promise<ISwitchProfileResponse>;
85
96
  /**
86
97
  * Update a profile. For future expansion, the profile ID to update is required, but currently this must also be the
87
98
  * "current" profile for the caller.
@@ -92,7 +103,7 @@ export declare const switchProfile: (endpoint: VerdocsEndpoint, profileId: strin
92
103
  * const newProfile = await Profiles.updateProfile('PROFILEID');
93
104
  * ```
94
105
  */
95
- export declare const updateProfile: (endpoint: VerdocsEndpoint, profileId: string, params: IUpdateProfileRequest) => Promise<any>;
106
+ export declare const updateProfile: (endpoint: VerdocsEndpoint, profileId: string, params: IUpdateProfileRequest) => Promise<IProfile>;
96
107
  /**
97
108
  * Delete a profile. If the requested profile is the caller's curent profile, the next available profile will be selected.
98
109
  *
package/Users/Profiles.js CHANGED
@@ -12,6 +12,20 @@ export var getProfiles = function (endpoint) {
12
12
  .get('/profiles')
13
13
  .then(function (r) { return r.data; });
14
14
  };
15
+ /**
16
+ * Get the user's available profiles. The current profile will be marked with `current: true`.
17
+ *
18
+ * ```typescript
19
+ * import {Profiles} from '@verdocs/js-sdk/Users';
20
+ *
21
+ * const profiles = await Profiles.getCurrentProfile()
22
+ * ```
23
+ */
24
+ export var getCurrentProfile = function (endpoint) {
25
+ return endpoint.api //
26
+ .get('/profiles')
27
+ .then(function (r) { return (r.data || []).find(function (profile) { return profile.current; }); });
28
+ };
15
29
  /**
16
30
  * Get a list of system roles.
17
31
  *
package/Users/Types.d.ts CHANGED
@@ -30,7 +30,7 @@ export interface IProfile {
30
30
  /** If true, this is the caller's "currently selected" profile. All operations will performed "as" this profile. */
31
31
  current: boolean;
32
32
  /** The organization */
33
- organization: IOrganization;
33
+ organization?: IOrganization;
34
34
  /** The permissions assigned to the profilel _NOTE: Only present in the "current" profile._ */
35
35
  permissions?: TPermission[];
36
36
  /** The roles assigned to the profilel _NOTE: Only present in the "current" profile._ */
@@ -5,7 +5,7 @@ import * as Documents from './Documents';
5
5
  export declare type TEnvironment = 'verdocs' | 'verdocs-stage';
6
6
  export declare type TSessionType = 'user' | 'signing';
7
7
  export declare type TSession = IActiveSession | ISigningSession | null;
8
- export declare type TSessionChangedListener = (endpoint: VerdocsEndpoint, session: IActiveSession | ISigningSession | null) => void;
8
+ export declare type TSessionChangedListener = (endpoint: VerdocsEndpoint, session: TSession) => void;
9
9
  export interface VerdocsEndpointOptions {
10
10
  baseURL?: string;
11
11
  timeout?: number;
@@ -62,7 +62,7 @@ export declare class VerdocsEndpoint {
62
62
  */
63
63
  constructor(options?: VerdocsEndpointOptions);
64
64
  setDefault(): void;
65
- static getDefault(): any;
65
+ static getDefault(): VerdocsEndpoint;
66
66
  /**
67
67
  * Get the current environment.
68
68
  */
@@ -175,6 +175,11 @@ export declare class VerdocsEndpoint {
175
175
  * ```
176
176
  */
177
177
  setToken(token: string | null): VerdocsEndpoint;
178
+ /**
179
+ * Retrieves the current session token, if any. Tokens should rarely be used for direct actions, but this is
180
+ * required by the `<VerdocsView>` and other components to authorize requests to raw PDF files.
181
+ */
182
+ getToken(): string | null;
178
183
  private sessionStorageKey;
179
184
  /**
180
185
  * Clear the active session.
@@ -230,6 +230,13 @@ var VerdocsEndpoint = /** @class */ (function () {
230
230
  this.notifySessionListeners();
231
231
  return this;
232
232
  };
233
+ /**
234
+ * Retrieves the current session token, if any. Tokens should rarely be used for direct actions, but this is
235
+ * required by the `<VerdocsView>` and other components to authorize requests to raw PDF files.
236
+ */
237
+ VerdocsEndpoint.prototype.getToken = function () {
238
+ return this.token;
239
+ };
233
240
  VerdocsEndpoint.prototype.sessionStorageKey = function () {
234
241
  return "verdocs-session-".concat(this.getSessionType(), "-").concat(this.getEnvironment());
235
242
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "2.0.2",
3
+ "version": "2.0.5",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",
@@ -39,7 +39,7 @@
39
39
  "docs": "npm run docs-md && npm run docs-html",
40
40
  "clear-docs": "aws --profile=verdocs cloudfront create-invalidation --distribution-id E29UFGU4KEH1GQ --paths \"/*\"",
41
41
  "deploy-docs": "npm run docs && aws --profile=verdocs s3 sync --acl public-read --delete docs-html s3://verdocs-developers-js-sdk/ && yarn clear-docs",
42
- "clean": "rm -rf Documents HTTP Organizations Search Templates Users Utils index.js index.d.ts docs docs-html"
42
+ "clean": "rm -rf Documents HTTP Organizations Search Templates Users Utils index.js index.d.ts VerdocsEndpoint.* docs docs-html"
43
43
  },
44
44
  "publishConfig": {
45
45
  "access": "public"