@verdocs/js-sdk 3.6.7 → 3.6.9

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.
@@ -49,3 +49,4 @@ export declare const userCanAct: (email: string, recipientsWithActions: IRecipie
49
49
  * Returns true if the user can act.
50
50
  */
51
51
  export declare const userCanSignNow: (session: TSession, envelope: IEnvelope) => boolean | undefined;
52
+ export declare const getNextRecipient: (envelope: IEnvelope) => IRecipient;
@@ -75,3 +75,7 @@ export var userCanSignNow = function (session, envelope) {
75
75
  userIsEnvelopeRecipient(session, envelope) &&
76
76
  recipientCanAct(myRecipient, recipientsWithActions));
77
77
  };
78
+ export var getNextRecipient = function (envelope) {
79
+ var recipientsWithActions = getRecipientsWithActions(envelope);
80
+ return recipientsWithActions === null || recipientsWithActions === void 0 ? void 0 : recipientsWithActions[0];
81
+ };
@@ -0,0 +1,26 @@
1
+ import { ITemplate, ITemplateSummaryEntry } from './Types';
2
+ import { TSession } from '../Sessions/Types';
3
+ export declare enum TemplateSenderTypes {
4
+ CREATOR = "creator",
5
+ ORGANIZATION_MEMBER = "organization_member",
6
+ ORGANIZATION_MEMBER_AS_CREATOR = "organization_member_as_creator",
7
+ EVERYONE = "everyone",
8
+ EVERYONE_AS_CREATOR = "everyone_as_creator"
9
+ }
10
+ export declare enum TemplatePermissions {
11
+ TEMPLATE_CREATOR_CREATE_PUBLIC = "template:creator:create:public",
12
+ TEMPLATE_CREATOR_CREATE_ORG = "template:creator:create:org",
13
+ TEMPLATE_CREATOR_CREATE_PERSONAL = "template:creator:create:personal",
14
+ TEMPLATE_CREATOR_DELETE = "template:creator:delete",
15
+ TEMPLATE_CREATOR_VISIBILITY = "template:creator:visibility",
16
+ TEMPLATE_MEMBER_READ = "template:member:read",
17
+ TEMPLATE_MEMBER_WRITE = "template:member:write",
18
+ TEMPLATE_MEMBER_DELETE = "template:member:delete",
19
+ TEMPLATE_MEMBER_VISIBILITY = "template:member:visibility"
20
+ }
21
+ export type TTemplateActions = 'create_personal' | 'create_org' | 'create_public' | 'read' | 'write' | 'delete' | 'change_visibility_personal' | 'change_visibility_org' | 'change_visibility_public';
22
+ export declare const canPerformTemplateAction: (session: TSession, action: TTemplateActions, template?: ITemplate | ITemplateSummaryEntry) => {
23
+ canPerform: boolean;
24
+ message: string;
25
+ };
26
+ export declare const hasRequiredPermissions: (session: TSession, permissions: string[]) => boolean;
@@ -0,0 +1,104 @@
1
+ export var TemplateSenderTypes;
2
+ (function (TemplateSenderTypes) {
3
+ TemplateSenderTypes["CREATOR"] = "creator";
4
+ TemplateSenderTypes["ORGANIZATION_MEMBER"] = "organization_member";
5
+ TemplateSenderTypes["ORGANIZATION_MEMBER_AS_CREATOR"] = "organization_member_as_creator";
6
+ TemplateSenderTypes["EVERYONE"] = "everyone";
7
+ TemplateSenderTypes["EVERYONE_AS_CREATOR"] = "everyone_as_creator";
8
+ })(TemplateSenderTypes || (TemplateSenderTypes = {}));
9
+ export var TemplatePermissions;
10
+ (function (TemplatePermissions) {
11
+ TemplatePermissions["TEMPLATE_CREATOR_CREATE_PUBLIC"] = "template:creator:create:public";
12
+ TemplatePermissions["TEMPLATE_CREATOR_CREATE_ORG"] = "template:creator:create:org";
13
+ TemplatePermissions["TEMPLATE_CREATOR_CREATE_PERSONAL"] = "template:creator:create:personal";
14
+ TemplatePermissions["TEMPLATE_CREATOR_DELETE"] = "template:creator:delete";
15
+ TemplatePermissions["TEMPLATE_CREATOR_VISIBILITY"] = "template:creator:visibility";
16
+ TemplatePermissions["TEMPLATE_MEMBER_READ"] = "template:member:read";
17
+ TemplatePermissions["TEMPLATE_MEMBER_WRITE"] = "template:member:write";
18
+ TemplatePermissions["TEMPLATE_MEMBER_DELETE"] = "template:member:delete";
19
+ TemplatePermissions["TEMPLATE_MEMBER_VISIBILITY"] = "template:member:visibility";
20
+ })(TemplatePermissions || (TemplatePermissions = {}));
21
+ export var canPerformTemplateAction = function (session, action, template) {
22
+ var _a, _b;
23
+ if (!template && !action.includes('create')) {
24
+ return { canPerform: false, message: 'Missing required template object' };
25
+ }
26
+ // We use BOGUS here to force the option-chain in things like template?.profile_id to NOT match profile?.profile_id because if both
27
+ // were undefined, they would actually match.
28
+ var profile_id = (session === null || session === void 0 ? void 0 : session.profile_id) || 'BOGUS';
29
+ var organization_id = (session === null || session === void 0 ? void 0 : session.organization_id) || 'BOGUS';
30
+ if (!profile_id) {
31
+ return { canPerform: false, message: 'Active session required' };
32
+ }
33
+ var isCreator = (template === null || template === void 0 ? void 0 : template.profile_id) === profile_id;
34
+ var isSameOrg = (template === null || template === void 0 ? void 0 : template.organization_id) === organization_id;
35
+ var isPersonal = (_a = template === null || template === void 0 ? void 0 : template.is_personal) !== null && _a !== void 0 ? _a : false;
36
+ var isPublic = (_b = template === null || template === void 0 ? void 0 : template.is_public) !== null && _b !== void 0 ? _b : false;
37
+ var permissionsRequired = [];
38
+ switch (action) {
39
+ case 'create_personal':
40
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_CREATOR_CREATE_PERSONAL);
41
+ break;
42
+ case 'create_org':
43
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_CREATOR_CREATE_ORG);
44
+ break;
45
+ case 'create_public':
46
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_CREATOR_CREATE_PUBLIC);
47
+ break;
48
+ case 'read':
49
+ if (!isCreator) {
50
+ if ((!isPersonal && isSameOrg) || !isPublic) {
51
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_MEMBER_READ);
52
+ }
53
+ }
54
+ break;
55
+ case 'write':
56
+ if (!isCreator) {
57
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_MEMBER_READ);
58
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_MEMBER_WRITE);
59
+ }
60
+ break;
61
+ case 'change_visibility_personal':
62
+ if (isCreator) {
63
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_CREATOR_CREATE_PERSONAL);
64
+ }
65
+ else {
66
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_MEMBER_VISIBILITY);
67
+ }
68
+ break;
69
+ case 'change_visibility_org':
70
+ if (isCreator) {
71
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_CREATOR_CREATE_ORG);
72
+ }
73
+ else {
74
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_MEMBER_VISIBILITY);
75
+ }
76
+ break;
77
+ case 'change_visibility_public':
78
+ if (isCreator) {
79
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_CREATOR_CREATE_PUBLIC);
80
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_CREATOR_VISIBILITY);
81
+ }
82
+ else {
83
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_MEMBER_VISIBILITY);
84
+ }
85
+ break;
86
+ case 'delete':
87
+ if (isCreator) {
88
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_CREATOR_DELETE);
89
+ }
90
+ else {
91
+ permissionsRequired.push(TemplatePermissions.TEMPLATE_MEMBER_DELETE);
92
+ }
93
+ break;
94
+ default:
95
+ return { canPerform: false, message: 'Action is not defined' };
96
+ }
97
+ if (hasRequiredPermissions(session, permissionsRequired)) {
98
+ return { canPerform: true, message: '' };
99
+ }
100
+ return { canPerform: false, message: "Insufficient access to perform '".concat(action, "'. Needed permissions: ").concat(permissionsRequired.toString()) };
101
+ };
102
+ export var hasRequiredPermissions = function (session, permissions) {
103
+ return permissions.every(function (perm) { return ((session === null || session === void 0 ? void 0 : session.permissions) || []).includes(perm); });
104
+ };
@@ -155,6 +155,7 @@ export interface IGetTemplateSummaryParams {
155
155
  last_used_at?: ISearchTimeRange;
156
156
  is_personal?: boolean;
157
157
  is_public?: boolean;
158
+ is_starred?: boolean;
158
159
  sort_by?: IGetTemplateSummarySortBy;
159
160
  ascending?: boolean;
160
161
  row?: number;
@@ -1,3 +1,4 @@
1
+ export * as Actions from './Actions';
1
2
  export * as Fields from './Fields';
2
3
  export * as Pages from './Pages';
3
4
  export * as Reminders from './Reminders';
@@ -1,3 +1,4 @@
1
+ export * as Actions from './Actions';
1
2
  export * as Fields from './Fields';
2
3
  export * as Pages from './Pages';
3
4
  export * as Reminders from './Reminders';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@verdocs/js-sdk",
3
- "version": "3.6.7",
3
+ "version": "3.6.9",
4
4
  "private": false,
5
5
  "homepage": "https://github.com/Verdocs/js-sdk",
6
6
  "description": "Verdocs JS SDK",