@verdocs/js-sdk 2.0.0 → 2.0.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.
@@ -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
  *
@@ -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 SessionChangedListener = (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;
@@ -40,11 +40,16 @@ export declare class VerdocsEndpoint {
40
40
  private baseURL;
41
41
  private clientID;
42
42
  private timeout;
43
- private session;
44
43
  private token;
45
44
  private nextListenerId;
46
45
  private sessionListeners;
47
46
  private requestLoggerId;
47
+ /**
48
+ * The current user session, or null if not authenticated. May be either a User or Signing session. If set, the
49
+ * presence of the `document_id` field can be used to differentiate the types. Only signing sessions are associated
50
+ * with Documents.
51
+ */
52
+ session: TSession;
48
53
  api: AxiosInstance;
49
54
  Documents: typeof Documents;
50
55
  /**
@@ -57,7 +62,7 @@ export declare class VerdocsEndpoint {
57
62
  */
58
63
  constructor(options?: VerdocsEndpointOptions);
59
64
  setDefault(): void;
60
- static getDefault(): any;
65
+ static getDefault(): VerdocsEndpoint;
61
66
  /**
62
67
  * Get the current environment.
63
68
  */
@@ -179,10 +184,10 @@ export declare class VerdocsEndpoint {
179
184
  /**
180
185
  * Subscribe to session state change events.
181
186
  */
182
- onSessionChanged(listener: SessionChangedListener): () => void;
187
+ onSessionChanged(listener: TSessionChangedListener): () => void;
183
188
  /**
184
189
  * Load a persisted session from localStorage. Typically called once after the endpoint is configured when the app
185
190
  * or component starts.
186
191
  */
187
- loadSession(source: string): VerdocsEndpoint;
192
+ loadSession(): VerdocsEndpoint;
188
193
  }
@@ -43,11 +43,16 @@ var VerdocsEndpoint = /** @class */ (function () {
43
43
  this.baseURL = 'https://api.verdocs.com';
44
44
  this.clientID = 'not-set';
45
45
  this.timeout = 3000;
46
- this.session = null;
47
46
  this.token = null;
48
47
  this.nextListenerId = 0;
49
48
  this.sessionListeners = new Map();
50
49
  this.requestLoggerId = null;
50
+ /**
51
+ * The current user session, or null if not authenticated. May be either a User or Signing session. If set, the
52
+ * presence of the `document_id` field can be used to differentiate the types. Only signing sessions are associated
53
+ * with Documents.
54
+ */
55
+ this.session = null;
51
56
  this.Documents = Documents;
52
57
  this.baseURL = (options === null || options === void 0 ? void 0 : options.baseURL) || 'https://api.verdocs.com';
53
58
  this.timeout = (options === null || options === void 0 ? void 0 : options.timeout) || 3000;
@@ -267,7 +272,7 @@ var VerdocsEndpoint = /** @class */ (function () {
267
272
  * Load a persisted session from localStorage. Typically called once after the endpoint is configured when the app
268
273
  * or component starts.
269
274
  */
270
- VerdocsEndpoint.prototype.loadSession = function (source) {
275
+ VerdocsEndpoint.prototype.loadSession = function () {
271
276
  var token = localStorage.getItem(this.sessionStorageKey());
272
277
  if (!token) {
273
278
  return this.clearSession();
package/index.d.ts CHANGED
@@ -4,6 +4,7 @@
4
4
  * - Documents - An individual document to be signed. Documents are created from templates.
5
5
  * - HTTP - General support functionality for Verdocs' REST endpoints. Typically not used directly.
6
6
  * - Organizations - An Organization is a container for user profiles, templates, documents, billing, and other related objects.
7
+ * - Search - Various methods used to retrieve lists of documents and templtes.
7
8
  * - Templates - A template for a document containing a PDF file, metadata for signature fields, and other information.
8
9
  * - Users - All operations related to authentication and user-related operations.
9
10
  * - Utils - General support functions used by the other modules and exported for convenience.
@@ -13,6 +14,7 @@
13
14
  export * as Documents from './Documents';
14
15
  export * as Templates from './Templates';
15
16
  export * as Organizations from './Organizations';
17
+ export * as Search from './Search';
16
18
  export * as Users from './Users';
17
19
  export * as Utils from './Utils';
18
20
  export * from './VerdocsEndpoint';
package/index.js CHANGED
@@ -4,6 +4,7 @@
4
4
  * - Documents - An individual document to be signed. Documents are created from templates.
5
5
  * - HTTP - General support functionality for Verdocs' REST endpoints. Typically not used directly.
6
6
  * - Organizations - An Organization is a container for user profiles, templates, documents, billing, and other related objects.
7
+ * - Search - Various methods used to retrieve lists of documents and templtes.
7
8
  * - Templates - A template for a document containing a PDF file, metadata for signature fields, and other information.
8
9
  * - Users - All operations related to authentication and user-related operations.
9
10
  * - Utils - General support functions used by the other modules and exported for convenience.
@@ -13,6 +14,7 @@
13
14
  export * as Documents from './Documents';
14
15
  export * as Templates from './Templates';
15
16
  export * as Organizations from './Organizations';
17
+ export * as Search from './Search';
16
18
  export * as Users from './Users';
17
19
  export * as Utils from './Utils';
18
20
  export * from './VerdocsEndpoint';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "2.0.0",
3
+ "version": "2.0.3",
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"