@raystack/frontier 0.120.0 → 0.121.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.
@@ -1,7 +1,7 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React, { ComponentProps, ReactNode, ComponentPropsWithRef, Dispatch, SetStateAction } from 'react';
3
3
  import { Flex, ThemeProviderProps } from '@raystack/apsara';
4
- import { ConsentDocument, FlowIntent, Plan, ServiceUserToken, Organization, Group, User, BillingAccount, Subscription, PaymentMethod, OrganizationKyc, BillingAccountDetails } from '@raystack/proton/frontier';
4
+ import { Plan, ConsentDocument, FlowIntent, ServiceUserToken, Organization, Group, User, BillingAccount, Subscription, PaymentMethod, OrganizationKyc, BillingAccountDetails } from '@raystack/proton/frontier';
5
5
  import * as yup from 'yup';
6
6
  import { QueryClient, UseQueryResult, UseMutationResult } from '@tanstack/react-query';
7
7
  import { ConnectError } from '@connectrpc/connect';
@@ -48,6 +48,139 @@ type AuthHeaderProps = ComponentPropsWithRef<'div'> & {
48
48
  };
49
49
  declare const AuthHeader: ({ title, logo }: AuthHeaderProps) => react_jsx_runtime.JSX.Element;
50
50
 
51
+ interface BasePlan extends Omit<Plan, 'title'> {
52
+ features?: Record<string, string>;
53
+ title: string;
54
+ }
55
+
56
+ /**
57
+ * A render-prop slot: receives a context object (shape defined per view/slot)
58
+ * and returns the node to render. Lets a consumer override an internal element
59
+ * of a view while keeping the customisation on their side.
60
+ *
61
+ * @example
62
+ * interface ViewSlots {
63
+ * addButton?: Slot<{ onClick: () => void; disabled: boolean }>;
64
+ * }
65
+ */
66
+ type Slot<TContext> = (context: TContext) => React.ReactNode;
67
+ interface FrontierClientBillingOptions {
68
+ supportEmail?: string;
69
+ successUrl?: string;
70
+ cancelUrl?: string;
71
+ hideDecimals?: boolean;
72
+ cancelAfterTrial?: boolean;
73
+ showPerMonthPrice?: boolean;
74
+ tokenProductId?: string;
75
+ basePlan?: BasePlan;
76
+ }
77
+ interface EntityTerminologies {
78
+ singular: string;
79
+ plural: string;
80
+ }
81
+ interface FrontierClientCustomizationOptions {
82
+ terminology?: {
83
+ organization?: EntityTerminologies;
84
+ project?: EntityTerminologies;
85
+ team?: EntityTerminologies;
86
+ member?: EntityTerminologies;
87
+ user?: EntityTerminologies;
88
+ appName?: string;
89
+ };
90
+ messages?: {
91
+ billing?: {
92
+ plan_change?: Record<string, string>;
93
+ };
94
+ general?: Record<string, string>;
95
+ };
96
+ }
97
+ interface FrontierClientOptions {
98
+ locale?: string;
99
+ connectEndpoint?: string;
100
+ redirectSignup?: string;
101
+ redirectLogin?: string;
102
+ redirectMagicLinkVerify?: string;
103
+ callbackUrl?: string;
104
+ dateFormat?: string;
105
+ shortDateFormat?: string;
106
+ billing?: FrontierClientBillingOptions;
107
+ customization?: FrontierClientCustomizationOptions;
108
+ /**
109
+ * Check what blocks an organization, project or account delete when the
110
+ * delete button is clicked, and show the blockers in a dialog. The server
111
+ * must serve CheckOrganizationDelete, CheckProjectDelete and
112
+ * CheckCurrentUserDelete. Off by default: the delete button opens the
113
+ * confirm dialog directly, and the organization page checks on load and
114
+ * disables the button while blocked.
115
+ */
116
+ enableDeleteCheck?: boolean;
117
+ }
118
+ interface InitialState {
119
+ sessionId?: string | null;
120
+ }
121
+ type CustomHeaderValue = string | (() => string);
122
+ interface DeleteBlocker {
123
+ type: string;
124
+ subject: string;
125
+ count?: number;
126
+ }
127
+ type DeleteBlockedPayload = {
128
+ entity: 'organization' | 'project';
129
+ blockers: DeleteBlocker[];
130
+ } | {
131
+ entity: 'user';
132
+ organizationsToDelete: {
133
+ id: string;
134
+ title: string;
135
+ blockers: DeleteBlocker[];
136
+ }[];
137
+ soleOwnerOf: {
138
+ id: string;
139
+ title: string;
140
+ }[];
141
+ };
142
+ type DeleteBlockedContext = DeleteBlockedPayload & {
143
+ entityLabel: string;
144
+ close: () => void;
145
+ };
146
+ interface FrontierProviderSlots {
147
+ deleteBlockedDialog?: Slot<DeleteBlockedContext>;
148
+ }
149
+ interface FrontierProviderProps {
150
+ config: FrontierClientOptions;
151
+ children: React.ReactNode;
152
+ initialState?: InitialState;
153
+ customHeaders?: Record<string, CustomHeaderValue>;
154
+ theme?: ThemeProviderProps;
155
+ renderToastProvider?: boolean;
156
+ renderThemeProvider?: boolean;
157
+ slots?: FrontierProviderSlots;
158
+ }
159
+
160
+ interface DeleteBlockedDialogProps {
161
+ title?: string;
162
+ description?: string;
163
+ blockers?: DeleteBlocker[];
164
+ messages?: Record<string, string>;
165
+ }
166
+ declare function DeleteBlockedDialog({ title, description, blockers, messages }: DeleteBlockedDialogProps): react_jsx_runtime.JSX.Element;
167
+
168
+ interface DeleteUserDialogHandle {
169
+ open: () => void;
170
+ }
171
+ interface DeleteUserDialogProps {
172
+ trigger?: Slot<{
173
+ onClick: () => void;
174
+ loading: boolean;
175
+ }>;
176
+ handle?: DeleteUserDialogHandle;
177
+ onDeleted: () => void;
178
+ }
179
+ declare function DeleteUserDialog({ trigger, handle, onDeleted }: DeleteUserDialogProps): react_jsx_runtime.JSX.Element;
180
+ declare namespace DeleteUserDialog {
181
+ var createHandle: () => DeleteUserDialogHandle;
182
+ }
183
+
51
184
  type AuthRejection = {
52
185
  message: string;
53
186
  strategy?: string;
@@ -180,7 +313,11 @@ interface PreferenceRowProps extends ComponentProps<typeof Flex> {
180
313
  }
181
314
  declare function PreferenceRow({ title, description, isLoading, children, className, contentProps, ...props }: PreferenceRowProps): react_jsx_runtime.JSX.Element;
182
315
 
183
- declare function ProfileView(): react_jsx_runtime.JSX.Element;
316
+ interface ProfileViewProps {
317
+ enableUserDelete?: boolean;
318
+ onDeleteSuccess?: () => void;
319
+ }
320
+ declare function ProfileView({ enableUserDelete, onDeleteSuccess }?: ProfileViewProps): react_jsx_runtime.JSX.Element;
184
321
 
185
322
  interface SessionsViewProps {
186
323
  onLogout?: () => void;
@@ -235,78 +372,6 @@ interface TeamDetailsViewProps {
235
372
  }
236
373
  declare function TeamDetailsView({ teamId, teamsLabel, onNavigateToTeams, onDeleteSuccess }: TeamDetailsViewProps): react_jsx_runtime.JSX.Element;
237
374
 
238
- interface BasePlan extends Omit<Plan, 'title'> {
239
- features?: Record<string, string>;
240
- title: string;
241
- }
242
-
243
- /**
244
- * A render-prop slot: receives a context object (shape defined per view/slot)
245
- * and returns the node to render. Lets a consumer override an internal element
246
- * of a view while keeping the customisation on their side.
247
- *
248
- * @example
249
- * interface ViewSlots {
250
- * addButton?: Slot<{ onClick: () => void; disabled: boolean }>;
251
- * }
252
- */
253
- type Slot<TContext> = (context: TContext) => React.ReactNode;
254
- interface FrontierClientBillingOptions {
255
- supportEmail?: string;
256
- successUrl?: string;
257
- cancelUrl?: string;
258
- hideDecimals?: boolean;
259
- cancelAfterTrial?: boolean;
260
- showPerMonthPrice?: boolean;
261
- tokenProductId?: string;
262
- basePlan?: BasePlan;
263
- }
264
- interface EntityTerminologies {
265
- singular: string;
266
- plural: string;
267
- }
268
- interface FrontierClientCustomizationOptions {
269
- terminology?: {
270
- organization?: EntityTerminologies;
271
- project?: EntityTerminologies;
272
- team?: EntityTerminologies;
273
- member?: EntityTerminologies;
274
- user?: EntityTerminologies;
275
- appName?: string;
276
- };
277
- messages?: {
278
- billing?: {
279
- plan_change?: Record<string, string>;
280
- };
281
- general?: Record<string, string>;
282
- };
283
- }
284
- interface FrontierClientOptions {
285
- locale?: string;
286
- connectEndpoint?: string;
287
- redirectSignup?: string;
288
- redirectLogin?: string;
289
- redirectMagicLinkVerify?: string;
290
- callbackUrl?: string;
291
- dateFormat?: string;
292
- shortDateFormat?: string;
293
- billing?: FrontierClientBillingOptions;
294
- customization?: FrontierClientCustomizationOptions;
295
- }
296
- interface InitialState {
297
- sessionId?: string | null;
298
- }
299
- type CustomHeaderValue = string | (() => string);
300
- interface FrontierProviderProps {
301
- config: FrontierClientOptions;
302
- children: React.ReactNode;
303
- initialState?: InitialState;
304
- customHeaders?: Record<string, CustomHeaderValue>;
305
- theme?: ThemeProviderProps;
306
- renderToastProvider?: boolean;
307
- renderThemeProvider?: boolean;
308
- }
309
-
310
375
  interface ServiceAccountsViewProps {
311
376
  onServiceAccountClick?: (id: string) => void;
312
377
  slots?: {
@@ -361,6 +426,7 @@ declare const CreateOrganizationView: ({ title, description, ...props }: CreateO
361
426
 
362
427
  interface FrontierContextProviderProps {
363
428
  config: FrontierClientOptions;
429
+ slots: FrontierProviderSlots;
364
430
  organizations: Organization[];
365
431
  groups: Group[];
366
432
  user: User | undefined;
@@ -434,10 +500,7 @@ interface UseTokensReturn {
434
500
  isTokensFetching: boolean;
435
501
  fetchTokenBalance: () => Promise<any>;
436
502
  }
437
- interface UseTokensOptions {
438
- enabled?: boolean;
439
- }
440
- declare const useTokens: (options?: UseTokensOptions) => UseTokensReturn;
503
+ declare const useTokens: () => UseTokensReturn;
441
504
 
442
505
  declare const useBillingPermission: () => {
443
506
  isFetching: boolean;
@@ -500,4 +563,4 @@ declare function timestampToDayjs(timestamp?: Timestamp): Dayjs | null;
500
563
  declare function isNullTimestamp(timestamp?: Timestamp): boolean;
501
564
  type TimeStamp = Timestamp;
502
565
 
503
- export { AuthContainer, AuthHeader, AuthRejection, BillingView, CreateOrganizationView, CustomizationProvider, FrontierClientBillingOptions, FrontierClientCustomizationOptions, FrontierClientOptions, FrontierProvider, GeneralView, ImageUpload, MagicLinkVerifyView, MagicLinkView, MembersView, PATDetailsView, PREFERENCE_OPTIONS, PatsView, PlansView, PreferenceRow, PreferencesView, ProfileView, ProjectDetailsView, ProjectsView, SecurityView, ServiceAccountDetailsView, ServiceAccountsView, SessionsView, SignInView, SignUpView, SubscribeView, TeamDetailsView, TeamsView, TimeStamp, TokensView, UpdatesView, ViewContainer, ViewHeader, describeAuthError, isNullTimestamp, queryClient, timestampToDate, timestampToDayjs, useBillingPermission, useConnectQueryPolling, useFrontier, usePreferences, useTerminology, useTokens };
566
+ export { AuthContainer, AuthHeader, AuthRejection, BillingView, CreateOrganizationView, CustomizationProvider, DeleteBlockedContext, DeleteBlockedDialog, DeleteBlockedDialogProps, DeleteBlocker, DeleteUserDialog, DeleteUserDialogHandle, DeleteUserDialogProps, FrontierClientBillingOptions, FrontierClientCustomizationOptions, FrontierClientOptions, FrontierProvider, FrontierProviderSlots, GeneralView, ImageUpload, MagicLinkVerifyView, MagicLinkView, MembersView, PATDetailsView, PREFERENCE_OPTIONS, PatsView, PlansView, PreferenceRow, PreferencesView, ProfileView, ProjectDetailsView, ProjectsView, SecurityView, ServiceAccountDetailsView, ServiceAccountsView, SessionsView, SignInView, SignUpView, SubscribeView, TeamDetailsView, TeamsView, TimeStamp, TokensView, UpdatesView, ViewContainer, ViewHeader, describeAuthError, isNullTimestamp, queryClient, timestampToDate, timestampToDayjs, useBillingPermission, useConnectQueryPolling, useFrontier, usePreferences, useTerminology, useTokens };