andoncloud-sdk 1.7.1 → 1.7.2

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,9 +1,11 @@
1
1
  export default AccessBlocker;
2
- declare function AccessBlocker({ accessState, buttons, daysSinceExpiry, featureKey, onTrialRequest, onFeatureRequest, }: {
2
+ declare function AccessBlocker({ accessState, buttons, daysSinceExpiry, featureKey, workplaceId, cooldownInfo, onTrialRequest, onFeatureRequest, }: {
3
3
  accessState: any;
4
4
  buttons?: any[] | undefined;
5
5
  daysSinceExpiry: any;
6
6
  featureKey: any;
7
+ workplaceId: any;
8
+ cooldownInfo?: {} | undefined;
7
9
  onTrialRequest: any;
8
10
  onFeatureRequest: any;
9
11
  }): React.JSX.Element;
@@ -18,10 +18,17 @@ declare function makeStyles(accessState: any): {
18
18
  };
19
19
  buttonsContainer: {
20
20
  display: string;
21
+ flexWrap: string;
22
+ alignItems: string;
23
+ justifyContent: string;
21
24
  gap: number;
22
25
  };
23
26
  primaryButton: {
24
27
  backgroundColor: any;
25
28
  };
26
29
  secondaryButton: {};
30
+ linkButton: {
31
+ cursor: string;
32
+ color: string;
33
+ };
27
34
  };
@@ -1,7 +1,8 @@
1
1
  export default AccessGuard;
2
- declare function AccessGuard({ features: featuresProp, extraPermissions, onTrialRequest, onFeatureRequest, children, }: {
2
+ declare function AccessGuard({ features: featuresProp, extraPermissions, workplaceId, onTrialRequest, onFeatureRequest, children, }: {
3
3
  features?: any[] | undefined;
4
4
  extraPermissions?: any[] | undefined;
5
+ workplaceId: any;
5
6
  onTrialRequest: any;
6
7
  onFeatureRequest: any;
7
8
  children: any;
@@ -1,6 +1,7 @@
1
1
  export default AccessRequestModal;
2
- declare function AccessRequestModal({ open, onSubmitRequest, onClose }: {
2
+ declare function AccessRequestModal({ open, requestType, onSubmitRequest, onClose }: {
3
3
  open: any;
4
+ requestType: any;
4
5
  onSubmitRequest: any;
5
6
  onClose: any;
6
7
  }): React.JSX.Element;
@@ -0,0 +1,7 @@
1
+ export default CooldownModal;
2
+ declare function CooldownModal({ open, daysRemaining, onClose }: {
3
+ open: any;
4
+ daysRemaining: any;
5
+ onClose: any;
6
+ }): React.JSX.Element;
7
+ import React from "react";
@@ -0,0 +1,30 @@
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 content {
21
+ const marginTop: number;
22
+ const marginBottom: number;
23
+ const textAlign: string;
24
+ }
25
+ namespace actions {
26
+ const display_1: string;
27
+ export { display_1 as display };
28
+ export const justifyContent: string;
29
+ }
30
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,7 @@
1
+ export function getAccessState(status: string): 'accessible' | 'no_permission' | 'expired' | 'not_purchased';
2
+ export namespace ACCESS_STATE_PRIORITY {
3
+ const no_permission: number;
4
+ const expired: number;
5
+ const not_purchased: number;
6
+ const accessible: number;
7
+ }
@@ -0,0 +1,5 @@
1
+ export function deriveButtons(status: string, daysSinceExpiry: number | null): Array<{
2
+ action: string;
3
+ requestType: string | null;
4
+ variant: 'primary' | 'secondary' | 'link';
5
+ }>;
@@ -0,0 +1,11 @@
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[], workplaceId?: string }} options - Additional options
6
+ * @returns {UseAccessResult}
7
+ */
8
+ declare function useAccess(features?: string[], options?: {
9
+ extraPermissions?: string[] | undefined;
10
+ workplaceId?: string | undefined;
11
+ }): UseAccessResult;
@@ -35,6 +35,7 @@ export const StoreContext: React.Context<{
35
35
  permissions: any;
36
36
  } | null;
37
37
  } | null;
38
+ featuresRequestsMap: {} | null;
38
39
  } | null>;
39
40
  signOut(token: any): Promise<void>;
40
41
  };
@@ -73,6 +74,7 @@ export const StoreContext: React.Context<{
73
74
  permissions: any;
74
75
  } | null;
75
76
  } | null;
77
+ featuresRequestsMap: {} | null;
76
78
  } | null>;
77
79
  storeSession(): Promise<void>;
78
80
  restoreSession(): Promise<void>;
@@ -116,6 +118,7 @@ export function useStore(): {
116
118
  permissions: any;
117
119
  } | null;
118
120
  } | null;
121
+ featuresRequestsMap: {} | null;
119
122
  } | null>;
120
123
  signOut(token: any): Promise<void>;
121
124
  };
@@ -154,6 +157,7 @@ export function useStore(): {
154
157
  permissions: any;
155
158
  } | null;
156
159
  } | null;
160
+ featuresRequestsMap: {} | null;
157
161
  } | null>;
158
162
  storeSession(): Promise<void>;
159
163
  restoreSession(): Promise<void>;
@@ -42,6 +42,7 @@ declare class SessionStore {
42
42
  permissions: any;
43
43
  } | null;
44
44
  } | null;
45
+ featuresRequestsMap: {} | null;
45
46
  } | null>;
46
47
  storeSession(): Promise<void>;
47
48
  restoreSession(): Promise<void>;
@@ -76,6 +77,7 @@ declare class SessionAPI {
76
77
  permissions: any;
77
78
  } | null;
78
79
  } | null;
80
+ featuresRequestsMap: {} | null;
79
81
  } | null>;
80
82
  signOut(token: any): Promise<void>;
81
83
  }
@@ -4,9 +4,11 @@ declare class UserStore {
4
4
  currentUser: null;
5
5
  permissionsMap: null;
6
6
  featuresMap: null;
7
+ featuresRequestsMap: null;
7
8
  setCurrentUser(currentUser: any): void;
8
9
  removeCurrentUser(): void;
9
10
  setPermissionsMap(permissionsMap: any): void;
10
11
  setFeaturesMap(featuresMap: any): void;
12
+ setFeaturesRequestsMap(featuresRequestsMap: any): void;
11
13
  get getCurrentUserJS(): null;
12
14
  }
@@ -14,3 +14,9 @@ export function convertFeaturesMapToCamelCase(featuresMap: any): {
14
14
  permissions: any;
15
15
  } | null;
16
16
  } | null;
17
+ export function convertFeaturesRequestsMapToCamelCase(featuresRequestsMap: any): {} | null;
18
+ export function getCooldownStatus(featuresRequestsMap: object | null, featureKey: string, requestType: string, workplaceId: string | undefined): {
19
+ isInCooldown: boolean;
20
+ daysRemaining: number;
21
+ };
22
+ export function getCooldownInfo(featuresRequestsMap: object | null, featureKey: string, buttons: any[], workplaceId: string | undefined): object;
@@ -0,0 +1 @@
1
+ export function toCamelCase(str: any): any;
package/dist/index.d.ts CHANGED
@@ -151,10 +151,6 @@ declare module 'andoncloud-sdk' {
151
151
  }
152
152
  export const Container: React.FC<ContainerProps>;
153
153
 
154
- // =============================================================================
155
- // Access Control Types
156
- // =============================================================================
157
-
158
154
  type FeatureStatus =
159
155
  | 'accessible'
160
156
  | 'no_permission'
@@ -165,11 +161,7 @@ declare module 'andoncloud-sdk' {
165
161
 
166
162
  type EntitlementType = 'trial' | 'purchased' | null;
167
163
 
168
- type AccessState =
169
- | 'no_permission'
170
- | 'accessible'
171
- | 'expired'
172
- | 'not_purchased';
164
+ type AccessState = 'no_permission' | 'accessible' | 'expired' | 'not_purchased';
173
165
 
174
166
  type DenyReason = 'MISSING_ROLE_PERMISSION' | 'EXPIRED_PLAN' | string;
175
167
 
@@ -191,6 +183,28 @@ declare module 'andoncloud-sdk' {
191
183
  [featureKey: string]: FeatureInfo;
192
184
  }
193
185
 
186
+ interface RequestInfo {
187
+ lastRequestedAt: string;
188
+ daysRemaining: number;
189
+ }
190
+
191
+ interface FeaturesRequestsMap {
192
+ [workplaceIdOrCompany: string]: {
193
+ [featureKey: string]: {
194
+ [requestType: string]: RequestInfo;
195
+ };
196
+ };
197
+ }
198
+
199
+ interface CooldownStatus {
200
+ isInCooldown: boolean;
201
+ daysRemaining: number;
202
+ }
203
+
204
+ interface CooldownInfo {
205
+ [requestType: string]: CooldownStatus;
206
+ }
207
+
194
208
  interface UserData {
195
209
  id: number;
196
210
  companyId: number;
@@ -200,9 +214,9 @@ declare module 'andoncloud-sdk' {
200
214
  name: string;
201
215
  permissionsMap: PermissionsMap | null;
202
216
  featuresMap: FeaturesMap | null;
217
+ featuresRequestsMap: FeaturesRequestsMap | null;
203
218
  }
204
219
 
205
- // Hook Results
206
220
  interface PermissionCheckResult {
207
221
  isAllowed: boolean;
208
222
  denyReason: DenyReason | null;
@@ -230,15 +244,19 @@ declare module 'andoncloud-sdk' {
230
244
 
231
245
  interface UseAccessOptions {
232
246
  extraPermissions?: string[];
247
+ workplaceId?: string;
233
248
  }
234
249
 
235
- export type AccessAction = 'start_trial' | 'request_access' | 'renew' | 'buy';
250
+ export type AccessAction = 'start_trial' | 'request_access' | 'renew' | 'buy' | 'wishlist';
251
+
252
+ export type AccessRequestType = 'feature_access' | 'trial_expired' | 'purchase' | 'wishlist';
236
253
 
237
- export type AccessRequestType = 'feature_access' | 'trial_expired' | 'purchase';
254
+ export type ButtonVariant = 'primary' | 'secondary' | 'link';
238
255
 
239
256
  export interface AccessButton {
240
257
  action: AccessAction;
241
258
  requestType: AccessRequestType | null;
259
+ variant: ButtonVariant;
242
260
  }
243
261
 
244
262
  interface FeatureAccessDetail {
@@ -254,6 +272,7 @@ declare module 'andoncloud-sdk' {
254
272
  accessState: AccessState;
255
273
  features: FeatureAccessDetail[];
256
274
  buttons: AccessButton[];
275
+ cooldownInfo: CooldownInfo;
257
276
  missingPermissions: string[];
258
277
  }
259
278
 
@@ -262,29 +281,37 @@ declare module 'andoncloud-sdk' {
262
281
  export interface FeatureRequestPayload {
263
282
  featureKey: string;
264
283
  requestType: AccessRequestType;
284
+ workplaceId?: string;
265
285
  }
266
286
 
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
287
  interface AccessGuardProps {
279
288
  features?: string[];
280
289
  extraPermissions?: string[];
281
- onTrialRequest: (featureKey: string) => void;
282
- onFeatureRequest: (payload: FeatureRequestPayload) => void;
290
+ workplaceId?: string;
291
+ onTrialRequest: (featureKey: string) => Promise<boolean>;
292
+ onFeatureRequest: (payload: FeatureRequestPayload) => Promise<boolean>;
283
293
  children: React.ReactNode;
284
294
  }
285
295
 
286
296
  export const AccessGuard: React.FC<AccessGuardProps>;
287
297
 
298
+ /**
299
+ * @note AccessBlocker is exported for demo/preview purposes only.
300
+ * For production use, prefer AccessGuard or withAccessGuard.
301
+ */
302
+ interface AccessBlockerProps {
303
+ accessState: AccessState;
304
+ buttons: AccessButton[];
305
+ featureKey: string;
306
+ daysSinceExpiry?: number;
307
+ workplaceId?: string;
308
+ cooldownInfo?: CooldownInfo;
309
+ onTrialRequest: (featureKey: string) => Promise<boolean>;
310
+ onFeatureRequest: (payload: FeatureRequestPayload) => Promise<boolean>;
311
+ }
312
+
313
+ export const AccessBlocker: React.FC<AccessBlockerProps>;
314
+
288
315
  interface AccessGuardInjectedProps {
289
316
  accessState: AccessState;
290
317
  hasAccess: boolean;
@@ -293,11 +320,13 @@ declare module 'andoncloud-sdk' {
293
320
 
294
321
  export function withAccessGuard<P extends object>(
295
322
  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
- }>;
323
+ options?: UseAccessOptions,
324
+ ): (Component: React.ComponentType<P & AccessGuardInjectedProps>) => React.FC<
325
+ P & {
326
+ onTrialRequest: (featureKey: string) => Promise<boolean>;
327
+ onFeatureRequest: (payload: FeatureRequestPayload) => Promise<boolean>;
328
+ }
329
+ >;
301
330
 
302
331
  export interface Session {
303
332
  user: UserData;
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const LIBRARY_VERSION = "1.7.1";
1
+ export declare const LIBRARY_VERSION = "1.7.2";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "andoncloud-sdk",
3
- "version": "1.7.1",
3
+ "version": "1.7.2",
4
4
  "license": "MIT",
5
5
  "private": false,
6
6
  "source": "src/index.js",