andoncloud-sdk 1.6.45 → 1.7.1

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.
Files changed (31) hide show
  1. package/dist/andoncloud-sdk.js +25 -25
  2. package/dist/andoncloud-sdk.js.map +1 -1
  3. package/dist/app/components/access/AccessBlocker.d.ts +10 -0
  4. package/dist/app/components/access/AccessBlocker.styles.d.ts +27 -0
  5. package/dist/app/components/access/AccessBlocker.test.d.ts +1 -0
  6. package/dist/app/components/access/AccessGuard.d.ts +8 -0
  7. package/dist/app/components/access/AccessGuard.test.d.ts +1 -0
  8. package/dist/app/components/access/AccessRequestModal.d.ts +7 -0
  9. package/dist/app/components/access/AccessRequestModal.styles.d.ts +31 -0
  10. package/dist/app/components/access/InternalProcedureScreen.d.ts +7 -0
  11. package/dist/app/components/access/InternalProcedureScreen.styles.d.ts +26 -0
  12. package/dist/app/components/access/InternalProcedureScreen.test.d.ts +1 -0
  13. package/dist/app/components/access/index.d.ts +3 -0
  14. package/dist/app/components/access/withAccessGuard.d.ts +6 -0
  15. package/dist/app/components/access/withAccessGuard.test.d.ts +1 -0
  16. package/dist/app/hooks/useAccess.d.ts +10 -0
  17. package/dist/app/hooks/useAccess.test.d.ts +1 -0
  18. package/dist/app/hooks/useFeatures.d.ts +6 -0
  19. package/dist/app/hooks/useFeatures.test.d.ts +1 -0
  20. package/dist/app/hooks/usePackages.d.ts +6 -0
  21. package/dist/app/hooks/usePackages.test.d.ts +1 -0
  22. package/dist/app/hooks/usePermissions.d.ts +13 -0
  23. package/dist/app/hooks/usePermissions.test.d.ts +1 -0
  24. package/dist/app/providers/store.d.ts +56 -2
  25. package/dist/app/stores/sessionStore.d.ts +28 -1
  26. package/dist/app/stores/userStore.d.ts +4 -0
  27. package/dist/app/testing/index.d.ts +1 -0
  28. package/dist/app/utils/stores.d.ts +16 -0
  29. package/dist/index.d.ts +141 -1
  30. package/dist/version.d.ts +1 -1
  31. package/package.json +1 -1
@@ -0,0 +1,10 @@
1
+ export default AccessBlocker;
2
+ declare function AccessBlocker({ accessState, buttons, daysSinceExpiry, featureKey, onTrialRequest, onFeatureRequest, }: {
3
+ accessState: any;
4
+ buttons?: any[] | undefined;
5
+ daysSinceExpiry: any;
6
+ featureKey: any;
7
+ onTrialRequest: any;
8
+ onFeatureRequest: any;
9
+ }): React.JSX.Element;
10
+ import React from "react";
@@ -0,0 +1,27 @@
1
+ export default makeStyles;
2
+ declare function makeStyles(accessState: any): {
3
+ container: {
4
+ display: string;
5
+ flexDirection: string;
6
+ alignItems: string;
7
+ justifyContent: string;
8
+ gap: number;
9
+ width: string;
10
+ height: string;
11
+ padding: number;
12
+ textAlign: string;
13
+ background: (theme: any) => any;
14
+ };
15
+ icon: {
16
+ fontSize: number;
17
+ color: any;
18
+ };
19
+ buttonsContainer: {
20
+ display: string;
21
+ gap: number;
22
+ };
23
+ primaryButton: {
24
+ backgroundColor: any;
25
+ };
26
+ secondaryButton: {};
27
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ export default AccessGuard;
2
+ declare function AccessGuard({ features: featuresProp, extraPermissions, onTrialRequest, onFeatureRequest, children, }: {
3
+ features?: any[] | undefined;
4
+ extraPermissions?: any[] | undefined;
5
+ onTrialRequest: any;
6
+ onFeatureRequest: any;
7
+ children: any;
8
+ }): any;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export default AccessRequestModal;
2
+ declare function AccessRequestModal({ open, onSubmitRequest, onClose }: {
3
+ open: any;
4
+ onSubmitRequest: any;
5
+ onClose: any;
6
+ }): React.JSX.Element;
7
+ import React from "react";
@@ -0,0 +1,31 @@
1
+ export default styles;
2
+ declare namespace styles {
3
+ const dialog: {
4
+ '.MuiPaper-root': {
5
+ borderRadius: string;
6
+ };
7
+ };
8
+ namespace dialogContent {
9
+ const padding: number;
10
+ }
11
+ namespace container {
12
+ export const display: string;
13
+ export const flexDirection: string;
14
+ export const alignItems: string;
15
+ export const gap: number;
16
+ const padding_1: number;
17
+ export { padding_1 as padding };
18
+ export function background(theme: any): any;
19
+ }
20
+ namespace stepper {
21
+ const width: string;
22
+ }
23
+ namespace disclaimer {
24
+ const marginTop: number;
25
+ const color: string;
26
+ }
27
+ namespace actions {
28
+ const marginTop_1: number;
29
+ export { marginTop_1 as marginTop };
30
+ }
31
+ }
@@ -0,0 +1,7 @@
1
+ export default InternalProcedureScreen;
2
+ declare function InternalProcedureScreen({ packageKey, onSubmitRequest, onClose }: {
3
+ packageKey: any;
4
+ onSubmitRequest: any;
5
+ onClose: any;
6
+ }): React.JSX.Element;
7
+ import React from "react";
@@ -0,0 +1,26 @@
1
+ export default styles;
2
+ declare namespace styles {
3
+ namespace container {
4
+ const display: string;
5
+ const flexDirection: string;
6
+ const alignItems: string;
7
+ const gap: number;
8
+ const width: number;
9
+ const maxWidth: string;
10
+ const padding: number;
11
+ const borderRadius: string;
12
+ function background(theme: any): any;
13
+ }
14
+ namespace stepper {
15
+ const width_1: string;
16
+ export { width_1 as width };
17
+ }
18
+ namespace disclaimer {
19
+ const marginTop: number;
20
+ const color: string;
21
+ }
22
+ namespace actions {
23
+ const marginTop_1: number;
24
+ export { marginTop_1 as marginTop };
25
+ }
26
+ }
@@ -0,0 +1,3 @@
1
+ export { default as AccessBlocker } from "./AccessBlocker";
2
+ export { default as AccessGuard } from "./AccessGuard";
3
+ export { default as withAccessGuard } from "./withAccessGuard";
@@ -0,0 +1,6 @@
1
+ export default withAccessGuard;
2
+ declare function withAccessGuard(featuresProp?: any[], options?: {}): (WrappedComponent: any) => {
3
+ (props: any): React.JSX.Element;
4
+ displayName: string;
5
+ };
6
+ import React from "react";
@@ -0,0 +1,10 @@
1
+ export default useAccess;
2
+ /**
3
+ * Hook for checking feature access based on features and permissions
4
+ * @param {string[]} features - Array of feature keys to check
5
+ * @param {{ extraPermissions?: string[] }} options - Additional options
6
+ * @returns {UseAccessResult}
7
+ */
8
+ declare function useAccess(features?: string[], options?: {
9
+ extraPermissions?: string[] | undefined;
10
+ }): UseAccessResult;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export default useFeatures;
2
+ declare function useFeatures(): {
3
+ getFeature: (featureKey: any) => null;
4
+ getFeatures: (featureKeys: any) => any;
5
+ featuresMap: null;
6
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,6 @@
1
+ export default usePackages;
2
+ declare function usePackages(): {
3
+ getPackage: (packageKey: any) => null;
4
+ getPackages: (packageKeys: any) => any;
5
+ packagesMap: null;
6
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,13 @@
1
+ export default usePermissions;
2
+ declare function usePermissions(): {
3
+ checkPermission: (permissionKey: any) => {
4
+ isAllowed: boolean;
5
+ denyReason: string | null;
6
+ };
7
+ checkPermissions: (permissionKeys: any) => {
8
+ allAllowed: boolean;
9
+ results: any;
10
+ deniedKeys: any;
11
+ };
12
+ permissionsMap: null;
13
+ };
@@ -0,0 +1 @@
1
+ export {};
@@ -25,7 +25,16 @@ export const StoreContext: React.Context<{
25
25
  username: any;
26
26
  email: any;
27
27
  name: any;
28
- permissions: any;
28
+ permissionsMap: any;
29
+ featuresMap: {
30
+ [k: string]: {
31
+ status: any;
32
+ entitlementType: any;
33
+ expiresAt: any;
34
+ daysSinceExpiry: any;
35
+ permissions: any;
36
+ } | null;
37
+ } | null;
29
38
  } | null>;
30
39
  signOut(token: any): Promise<void>;
31
40
  };
@@ -47,6 +56,24 @@ export const StoreContext: React.Context<{
47
56
  refresh(): Promise<null>;
48
57
  recover(): Promise<void>;
49
58
  logout(): Promise<void>;
59
+ refreshUserData(): Promise<{
60
+ id: any;
61
+ companyId: any;
62
+ roleId: any;
63
+ username: any;
64
+ email: any;
65
+ name: any;
66
+ permissionsMap: any;
67
+ featuresMap: {
68
+ [k: string]: {
69
+ status: any;
70
+ entitlementType: any;
71
+ expiresAt: any;
72
+ daysSinceExpiry: any;
73
+ permissions: any;
74
+ } | null;
75
+ } | null;
76
+ } | null>;
50
77
  storeSession(): Promise<void>;
51
78
  restoreSession(): Promise<void>;
52
79
  removeSession(): void;
@@ -79,7 +106,16 @@ export function useStore(): {
79
106
  username: any;
80
107
  email: any;
81
108
  name: any;
82
- permissions: any;
109
+ permissionsMap: any;
110
+ featuresMap: {
111
+ [k: string]: {
112
+ status: any;
113
+ entitlementType: any;
114
+ expiresAt: any;
115
+ daysSinceExpiry: any;
116
+ permissions: any;
117
+ } | null;
118
+ } | null;
83
119
  } | null>;
84
120
  signOut(token: any): Promise<void>;
85
121
  };
@@ -101,6 +137,24 @@ export function useStore(): {
101
137
  refresh(): Promise<null>;
102
138
  recover(): Promise<void>;
103
139
  logout(): Promise<void>;
140
+ refreshUserData(): Promise<{
141
+ id: any;
142
+ companyId: any;
143
+ roleId: any;
144
+ username: any;
145
+ email: any;
146
+ name: any;
147
+ permissionsMap: any;
148
+ featuresMap: {
149
+ [k: string]: {
150
+ status: any;
151
+ entitlementType: any;
152
+ expiresAt: any;
153
+ daysSinceExpiry: any;
154
+ permissions: any;
155
+ } | null;
156
+ } | null;
157
+ } | null>;
104
158
  storeSession(): Promise<void>;
105
159
  restoreSession(): Promise<void>;
106
160
  removeSession(): void;
@@ -25,6 +25,24 @@ declare class SessionStore {
25
25
  refresh(): Promise<null>;
26
26
  recover(): Promise<void>;
27
27
  logout(): Promise<void>;
28
+ refreshUserData(): Promise<{
29
+ id: any;
30
+ companyId: any;
31
+ roleId: any;
32
+ username: any;
33
+ email: any;
34
+ name: any;
35
+ permissionsMap: any;
36
+ featuresMap: {
37
+ [k: string]: {
38
+ status: any;
39
+ entitlementType: any;
40
+ expiresAt: any;
41
+ daysSinceExpiry: any;
42
+ permissions: any;
43
+ } | null;
44
+ } | null;
45
+ } | null>;
28
46
  storeSession(): Promise<void>;
29
47
  restoreSession(): Promise<void>;
30
48
  removeSession(): void;
@@ -48,7 +66,16 @@ declare class SessionAPI {
48
66
  username: any;
49
67
  email: any;
50
68
  name: any;
51
- permissions: any;
69
+ permissionsMap: any;
70
+ featuresMap: {
71
+ [k: string]: {
72
+ status: any;
73
+ entitlementType: any;
74
+ expiresAt: any;
75
+ daysSinceExpiry: any;
76
+ permissions: any;
77
+ } | null;
78
+ } | null;
52
79
  } | null>;
53
80
  signOut(token: any): Promise<void>;
54
81
  }
@@ -2,7 +2,11 @@ declare const _default: UserStore;
2
2
  export default _default;
3
3
  declare class UserStore {
4
4
  currentUser: null;
5
+ permissionsMap: null;
6
+ featuresMap: null;
5
7
  setCurrentUser(currentUser: any): void;
6
8
  removeCurrentUser(): void;
9
+ setPermissionsMap(permissionsMap: any): void;
10
+ setFeaturesMap(featuresMap: any): void;
7
11
  get getCurrentUserJS(): null;
8
12
  }
@@ -1 +1,2 @@
1
1
  export function render(node: any, options?: {}): import("@testing-library/react").RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
2
+ export function renderComponent(node: any, options?: {}): import("@testing-library/react").RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
@@ -0,0 +1,16 @@
1
+ export function convertFeatureInfoToCamelCase(featureInfo: any): {
2
+ status: any;
3
+ entitlementType: any;
4
+ expiresAt: any;
5
+ daysSinceExpiry: any;
6
+ permissions: any;
7
+ } | null;
8
+ export function convertFeaturesMapToCamelCase(featuresMap: any): {
9
+ [k: string]: {
10
+ status: any;
11
+ entitlementType: any;
12
+ expiresAt: any;
13
+ daysSinceExpiry: any;
14
+ permissions: any;
15
+ } | null;
16
+ } | null;
package/dist/index.d.ts CHANGED
@@ -151,6 +151,46 @@ declare module 'andoncloud-sdk' {
151
151
  }
152
152
  export const Container: React.FC<ContainerProps>;
153
153
 
154
+ // =============================================================================
155
+ // Access Control Types
156
+ // =============================================================================
157
+
158
+ type FeatureStatus =
159
+ | 'accessible'
160
+ | 'no_permission'
161
+ | 'not_purchased'
162
+ | 'trial_expired_recent'
163
+ | 'trial_expired_old'
164
+ | 'no_access';
165
+
166
+ type EntitlementType = 'trial' | 'purchased' | null;
167
+
168
+ type AccessState =
169
+ | 'no_permission'
170
+ | 'accessible'
171
+ | 'expired'
172
+ | 'not_purchased';
173
+
174
+ type DenyReason = 'MISSING_ROLE_PERMISSION' | 'EXPIRED_PLAN' | string;
175
+
176
+ type PermissionValue = 'ALLOW' | `DENY:${DenyReason}`;
177
+
178
+ interface PermissionsMap {
179
+ [permissionKey: string]: PermissionValue;
180
+ }
181
+
182
+ interface FeatureInfo {
183
+ status: FeatureStatus;
184
+ entitlementType: EntitlementType;
185
+ expiresAt: string | null;
186
+ daysSinceExpiry: number | null;
187
+ permissions: string[];
188
+ }
189
+
190
+ interface FeaturesMap {
191
+ [featureKey: string]: FeatureInfo;
192
+ }
193
+
154
194
  interface UserData {
155
195
  id: number;
156
196
  companyId: number;
@@ -158,9 +198,107 @@ declare module 'andoncloud-sdk' {
158
198
  username: string;
159
199
  email: string;
160
200
  name: string;
161
- permissions: string[];
201
+ permissionsMap: PermissionsMap | null;
202
+ featuresMap: FeaturesMap | null;
203
+ }
204
+
205
+ // Hook Results
206
+ interface PermissionCheckResult {
207
+ isAllowed: boolean;
208
+ denyReason: DenyReason | null;
209
+ }
210
+
211
+ interface UsePermissionsResult {
212
+ checkPermission: (permissionKey: string) => PermissionCheckResult;
213
+ checkPermissions: (permissionKeys: string[]) => {
214
+ allAllowed: boolean;
215
+ results: Record<string, PermissionCheckResult>;
216
+ deniedKeys: string[];
217
+ };
218
+ permissionsMap: PermissionsMap | null;
219
+ }
220
+
221
+ export const usePermissions: () => UsePermissionsResult;
222
+
223
+ interface UseFeaturesResult {
224
+ getFeature: (featureKey: string) => FeatureInfo | null;
225
+ getFeatures: (featureKeys: string[]) => Record<string, FeatureInfo | null>;
226
+ featuresMap: FeaturesMap | null;
162
227
  }
163
228
 
229
+ export const useFeatures: () => UseFeaturesResult;
230
+
231
+ interface UseAccessOptions {
232
+ extraPermissions?: string[];
233
+ }
234
+
235
+ export type AccessAction = 'start_trial' | 'request_access' | 'renew' | 'buy';
236
+
237
+ export type AccessRequestType = 'feature_access' | 'trial_expired' | 'purchase';
238
+
239
+ export interface AccessButton {
240
+ action: AccessAction;
241
+ requestType: AccessRequestType | null;
242
+ }
243
+
244
+ interface FeatureAccessDetail {
245
+ featureKey: string;
246
+ hasAccess: boolean;
247
+ accessState: AccessState;
248
+ daysSinceExpiry: number | null;
249
+ buttons: AccessButton[];
250
+ }
251
+
252
+ interface UseAccessResult {
253
+ hasAccess: boolean;
254
+ accessState: AccessState;
255
+ features: FeatureAccessDetail[];
256
+ buttons: AccessButton[];
257
+ missingPermissions: string[];
258
+ }
259
+
260
+ export const useAccess: (features?: string[], options?: UseAccessOptions) => UseAccessResult;
261
+
262
+ export interface FeatureRequestPayload {
263
+ featureKey: string;
264
+ requestType: AccessRequestType;
265
+ }
266
+
267
+ interface AccessBlockerProps {
268
+ accessState: 'no_permission' | 'expired' | 'not_purchased';
269
+ buttons: AccessButton[];
270
+ daysSinceExpiry?: number | null;
271
+ featureKey: string;
272
+ onTrialRequest: (featureKey: string) => void;
273
+ onFeatureRequest: (payload: FeatureRequestPayload) => void;
274
+ }
275
+
276
+ export const AccessBlocker: React.FC<AccessBlockerProps>;
277
+
278
+ interface AccessGuardProps {
279
+ features?: string[];
280
+ extraPermissions?: string[];
281
+ onTrialRequest: (featureKey: string) => void;
282
+ onFeatureRequest: (payload: FeatureRequestPayload) => void;
283
+ children: React.ReactNode;
284
+ }
285
+
286
+ export const AccessGuard: React.FC<AccessGuardProps>;
287
+
288
+ interface AccessGuardInjectedProps {
289
+ accessState: AccessState;
290
+ hasAccess: boolean;
291
+ missingPermissions: string[];
292
+ }
293
+
294
+ export function withAccessGuard<P extends object>(
295
+ features?: string[],
296
+ options?: UseAccessOptions
297
+ ): (Component: React.ComponentType<P & AccessGuardInjectedProps>) => React.FC<P & {
298
+ onTrialRequest: (featureKey: string) => void;
299
+ onFeatureRequest: (payload: FeatureRequestPayload) => void;
300
+ }>;
301
+
164
302
  export interface Session {
165
303
  user: UserData;
166
304
  accessToken: string;
@@ -218,6 +356,8 @@ declare module 'andoncloud-sdk' {
218
356
 
219
357
  export const logout: () => void;
220
358
 
359
+ export const refreshUserData: () => Promise<UserData | null>;
360
+
221
361
  export const setLocale: (lang: string) => void;
222
362
 
223
363
  export const getLocale: () => string;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const LIBRARY_VERSION = "1.6.45";
1
+ export declare const LIBRARY_VERSION = "1.7.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "andoncloud-sdk",
3
- "version": "1.6.45",
3
+ "version": "1.7.1",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "source": "src/index.js",