@raystack/frontier 0.98.0 → 0.100.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raystack/frontier",
3
- "version": "0.98.0",
3
+ "version": "0.100.0",
4
4
  "description": "A js library for frontier",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -51,6 +51,12 @@
51
51
  "module": "./react/dist/index.mjs",
52
52
  "require": "./react/dist/index.js"
53
53
  },
54
+ "./client": {
55
+ "types": "./react/dist/client.d.ts",
56
+ "import": "./react/dist/client.mjs",
57
+ "module": "./react/dist/client.mjs",
58
+ "require": "./react/dist/client.js"
59
+ },
54
60
  "./hooks": {
55
61
  "types": "./hooks/dist/index.d.ts",
56
62
  "import": "./hooks/dist/index.mjs",
@@ -102,7 +108,7 @@
102
108
  "@connectrpc/connect-web": "2.1.1",
103
109
  "@hookform/resolvers": "^3.10.0",
104
110
  "@raystack/apsara-v1": "npm:@raystack/apsara@1.0.0-rc.2",
105
- "@raystack/proton": "0.1.0-432d98ce56451cd9461a755d8db4842ec4354669",
111
+ "@raystack/proton": "0.1.0-7523cfd3a676d3fb72d63c8c4f0476738a2217b3",
106
112
  "@tanstack/react-query": "^5.90.2",
107
113
  "@tanstack/react-router": "^1.168.3",
108
114
  "axios": "^1.9.0",
@@ -0,0 +1,423 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import React, { ComponentProps, ReactNode, ComponentPropsWithRef, Dispatch, SetStateAction } from 'react';
3
+ import { Flex } from '@raystack/apsara-v1';
4
+ import * as yup from 'yup';
5
+ import { Plan, Organization, Group, User, BillingAccount, Subscription, PaymentMethod, OrganizationKyc, BillingAccountDetails } from '@raystack/proton/frontier';
6
+ import { ThemeProviderProps } from '@raystack/apsara';
7
+ import { QueryClient, UseQueryResult, UseMutationResult } from '@tanstack/react-query';
8
+ import { ConnectError } from '@connectrpc/connect';
9
+ import { DescMessage, MessageShape, DescMethodUnary, MessageInitShape } from '@bufbuild/protobuf';
10
+ import { Timestamp } from '@bufbuild/protobuf/wkt';
11
+ import { Dayjs } from 'dayjs';
12
+
13
+ interface ImageUploadProps {
14
+ description?: string;
15
+ value?: string;
16
+ onChange?: (value: string) => void;
17
+ disabled?: boolean;
18
+ initials?: string;
19
+ 'data-test-id'?: string;
20
+ }
21
+ declare function ImageUpload({ description, value, onChange, disabled, initials, ...rest }: ImageUploadProps): react_jsx_runtime.JSX.Element;
22
+
23
+ interface ViewContainerProps extends ComponentProps<typeof Flex> {
24
+ contentProps?: Omit<ComponentProps<typeof Flex>, 'children'>;
25
+ }
26
+ declare function ViewContainer({ children, contentProps, className, ...props }: ViewContainerProps): react_jsx_runtime.JSX.Element;
27
+
28
+ interface ViewHeaderProps extends ComponentProps<typeof Flex> {
29
+ title: string;
30
+ description?: string;
31
+ /**
32
+ * When provided, renders a breadcrumb row above the title.
33
+ * `children` are placed alongside the breadcrumb (e.g. action buttons).
34
+ * Without breadcrumb, `children` render alongside the title (default layout).
35
+ */
36
+ breadcrumb?: ReactNode;
37
+ }
38
+ declare function ViewHeader({ title, description, breadcrumb, children, ...props }: ViewHeaderProps): react_jsx_runtime.JSX.Element;
39
+
40
+ type AuthContainerProps = ComponentPropsWithRef<'div'> & {
41
+ children?: ReactNode;
42
+ className?: string;
43
+ };
44
+ declare const AuthContainer: ({ children, style, className }: AuthContainerProps) => react_jsx_runtime.JSX.Element;
45
+
46
+ type AuthHeaderProps = ComponentPropsWithRef<'div'> & {
47
+ title?: string;
48
+ logo?: ReactNode;
49
+ };
50
+ declare const AuthHeader: ({ title, logo }: AuthHeaderProps) => react_jsx_runtime.JSX.Element;
51
+
52
+ type SignInViewProps = ComponentPropsWithRef<'div'> & AuthContainerProps & {
53
+ logo?: ReactNode;
54
+ title?: string;
55
+ excludes?: string[];
56
+ footer?: boolean;
57
+ };
58
+ declare const SignInView: ({ logo, title, excludes, footer, ...props }: SignInViewProps) => react_jsx_runtime.JSX.Element;
59
+
60
+ type SignUpViewProps = ComponentPropsWithRef<'div'> & AuthContainerProps & {
61
+ logo?: ReactNode;
62
+ title?: string;
63
+ excludes?: string[];
64
+ };
65
+ declare const SignUpView: ({ logo, title, excludes, ...props }: SignUpViewProps) => react_jsx_runtime.JSX.Element;
66
+
67
+ type MagicLinkViewProps = ComponentPropsWithRef<'div'> & AuthContainerProps & {
68
+ logo?: ReactNode;
69
+ title?: string;
70
+ open?: boolean;
71
+ inline?: boolean;
72
+ };
73
+ declare const MagicLinkView: ({ logo, title, open, inline, ...props }: MagicLinkViewProps) => react_jsx_runtime.JSX.Element;
74
+
75
+ type MagicLinkVerifyViewProps = ComponentPropsWithRef<'div'> & AuthContainerProps & {
76
+ logo?: ReactNode;
77
+ title?: string;
78
+ redirectURL?: string;
79
+ };
80
+ declare const MagicLinkVerifyView: ({ logo, title, redirectURL, ...props }: MagicLinkVerifyViewProps) => react_jsx_runtime.JSX.Element;
81
+
82
+ declare const schema$1: yup.ObjectSchema<{
83
+ name: string;
84
+ email: string;
85
+ contactNumber: string | null | undefined;
86
+ }, yup.AnyObject, {
87
+ name: undefined;
88
+ email: undefined;
89
+ contactNumber: undefined;
90
+ }, "">;
91
+ type FormData$1 = yup.InferType<typeof schema$1>;
92
+ type SubscribeViewProps = {
93
+ title?: string;
94
+ desc?: string;
95
+ activity?: string;
96
+ medium?: string;
97
+ source?: string;
98
+ confirmSection?: ReactNode;
99
+ onSubmit?: (data: FormData$1) => void;
100
+ };
101
+ declare const SubscribeView: ({ title, desc, activity, medium, source, confirmSection, onSubmit }: SubscribeViewProps) => react_jsx_runtime.JSX.Element;
102
+
103
+ declare const schema: yup.ObjectSchema<{
104
+ newsletter: boolean | undefined;
105
+ }, yup.AnyObject, {
106
+ newsletter: undefined;
107
+ }, "">;
108
+ type FormData = yup.InferType<typeof schema>;
109
+ type UpdatesViewProps = {
110
+ logo?: ReactNode;
111
+ title?: string;
112
+ preferenceTitle?: string;
113
+ preferenceDescription?: string;
114
+ onSubmit?: (data: FormData) => void;
115
+ };
116
+ declare const UpdatesView: ({ logo, title, preferenceTitle, preferenceDescription, onSubmit }: UpdatesViewProps) => react_jsx_runtime.JSX.Element;
117
+
118
+ interface GeneralViewProps {
119
+ onDeleteSuccess?: () => void;
120
+ urlPrefix?: string;
121
+ }
122
+ declare function GeneralView({ onDeleteSuccess, urlPrefix }?: GeneralViewProps): react_jsx_runtime.JSX.Element;
123
+
124
+ interface PreferencesViewProps {
125
+ children?: ReactNode;
126
+ }
127
+ declare function PreferencesView({ children }: PreferencesViewProps): react_jsx_runtime.JSX.Element;
128
+
129
+ interface PreferenceRowProps extends ComponentProps<typeof Flex> {
130
+ title: string;
131
+ description: string;
132
+ isLoading?: boolean;
133
+ contentProps?: ComponentProps<typeof Flex>;
134
+ }
135
+ declare function PreferenceRow({ title, description, isLoading, children, className, contentProps, ...props }: PreferenceRowProps): react_jsx_runtime.JSX.Element;
136
+
137
+ declare function ProfileView(): react_jsx_runtime.JSX.Element;
138
+
139
+ interface SessionsViewProps {
140
+ onLogout?: () => void;
141
+ onRevoke?: () => void;
142
+ }
143
+ declare function SessionsView({ onLogout, onRevoke }?: SessionsViewProps): react_jsx_runtime.JSX.Element;
144
+
145
+ interface MembersViewProps {
146
+ showTeamField?: boolean;
147
+ }
148
+ declare function MembersView({ showTeamField }: MembersViewProps): react_jsx_runtime.JSX.Element;
149
+
150
+ interface SecurityViewProps {
151
+ children?: ReactNode;
152
+ }
153
+ declare function SecurityView({ children }: SecurityViewProps): react_jsx_runtime.JSX.Element;
154
+
155
+ interface ProjectsViewProps {
156
+ title?: string;
157
+ description?: string;
158
+ onProjectClick?: (projectId: string) => void;
159
+ }
160
+ declare function ProjectsView({ title, description, onProjectClick }: ProjectsViewProps): react_jsx_runtime.JSX.Element;
161
+
162
+ interface ProjectDetailsViewProps {
163
+ projectId: string;
164
+ projectsLabel?: string;
165
+ onNavigateToProjects?: () => void;
166
+ onDeleteSuccess?: () => void;
167
+ }
168
+ declare function ProjectDetailsView({ projectId, projectsLabel, onNavigateToProjects, onDeleteSuccess }: ProjectDetailsViewProps): react_jsx_runtime.JSX.Element;
169
+
170
+ interface BillingViewProps {
171
+ onNavigateToPlans?: () => void;
172
+ }
173
+ declare function BillingView({ onNavigateToPlans }: BillingViewProps): react_jsx_runtime.JSX.Element;
174
+
175
+ declare function TokensView(): react_jsx_runtime.JSX.Element;
176
+
177
+ interface TeamsViewProps {
178
+ title?: string;
179
+ description?: string;
180
+ onTeamClick?: (teamId: string) => void;
181
+ }
182
+ declare function TeamsView({ title, description, onTeamClick }: TeamsViewProps): react_jsx_runtime.JSX.Element;
183
+
184
+ interface TeamDetailsViewProps {
185
+ teamId: string;
186
+ teamsLabel?: string;
187
+ onNavigateToTeams?: () => void;
188
+ onDeleteSuccess?: () => void;
189
+ }
190
+ declare function TeamDetailsView({ teamId, teamsLabel, onNavigateToTeams, onDeleteSuccess }: TeamDetailsViewProps): react_jsx_runtime.JSX.Element;
191
+
192
+ interface ServiceAccountsViewProps {
193
+ onServiceAccountClick?: (id: string) => void;
194
+ }
195
+ declare function ServiceAccountsView({ onServiceAccountClick }: ServiceAccountsViewProps): react_jsx_runtime.JSX.Element;
196
+
197
+ interface ServiceAccountDetailsViewProps {
198
+ serviceAccountId: string;
199
+ serviceAccountsLabel?: string;
200
+ onNavigateToServiceAccounts?: () => void;
201
+ onDeleteSuccess?: () => void;
202
+ }
203
+ declare function ServiceAccountDetailsView({ serviceAccountId, serviceAccountsLabel, onNavigateToServiceAccounts, onDeleteSuccess }: ServiceAccountDetailsViewProps): react_jsx_runtime.JSX.Element;
204
+
205
+ declare function PlansView(): react_jsx_runtime.JSX.Element;
206
+
207
+ interface PatsViewProps {
208
+ onPATClick?: (patId: string) => void;
209
+ }
210
+ declare function PatsView({ onPATClick }?: PatsViewProps): react_jsx_runtime.JSX.Element;
211
+
212
+ interface PATDetailsViewProps {
213
+ patId: string;
214
+ onNavigateToPats?: () => void;
215
+ onDeleteSuccess?: () => void;
216
+ }
217
+ declare function PATDetailsView({ patId, onNavigateToPats, onDeleteSuccess }: PATDetailsViewProps): react_jsx_runtime.JSX.Element;
218
+
219
+ type CreateOrganizationViewProps = ComponentPropsWithRef<'div'> & {
220
+ title?: string;
221
+ description?: string;
222
+ };
223
+ declare const CreateOrganizationView: ({ title, description, ...props }: CreateOrganizationViewProps) => react_jsx_runtime.JSX.Element;
224
+
225
+ interface BasePlan extends Omit<Plan, 'title'> {
226
+ features?: Record<string, string>;
227
+ title: string;
228
+ }
229
+
230
+ interface FrontierClientBillingOptions {
231
+ supportEmail?: string;
232
+ successUrl?: string;
233
+ cancelUrl?: string;
234
+ hideDecimals?: boolean;
235
+ cancelAfterTrial?: boolean;
236
+ showPerMonthPrice?: boolean;
237
+ tokenProductId?: string;
238
+ basePlan?: BasePlan;
239
+ }
240
+ interface EntityTerminologies {
241
+ singular: string;
242
+ plural: string;
243
+ }
244
+ interface FrontierClientCustomizationOptions {
245
+ terminology?: {
246
+ organization?: EntityTerminologies;
247
+ project?: EntityTerminologies;
248
+ team?: EntityTerminologies;
249
+ member?: EntityTerminologies;
250
+ user?: EntityTerminologies;
251
+ appName?: string;
252
+ };
253
+ messages?: {
254
+ billing?: {
255
+ plan_change?: Record<string, string>;
256
+ };
257
+ general?: Record<string, string>;
258
+ };
259
+ }
260
+ interface FrontierClientOptions {
261
+ locale?: string;
262
+ connectEndpoint?: string;
263
+ redirectSignup?: string;
264
+ redirectLogin?: string;
265
+ redirectMagicLinkVerify?: string;
266
+ callbackUrl?: string;
267
+ dateFormat?: string;
268
+ shortDateFormat?: string;
269
+ billing?: FrontierClientBillingOptions;
270
+ customization?: FrontierClientCustomizationOptions;
271
+ }
272
+ interface InitialState {
273
+ sessionId?: string | null;
274
+ }
275
+ type CustomHeaderValue = string | (() => string);
276
+ interface FrontierProviderProps {
277
+ config: FrontierClientOptions;
278
+ children: React.ReactNode;
279
+ initialState?: InitialState;
280
+ customHeaders?: Record<string, CustomHeaderValue>;
281
+ theme?: ThemeProviderProps;
282
+ renderToastProvider?: boolean;
283
+ renderThemeProvider?: boolean;
284
+ }
285
+
286
+ interface FrontierContextProviderProps {
287
+ config: FrontierClientOptions;
288
+ organizations: Organization[];
289
+ groups: Group[];
290
+ user: User | undefined;
291
+ activeOrganization: Organization | undefined;
292
+ setActiveOrganization: Dispatch<SetStateAction<Organization | undefined>>;
293
+ isActiveOrganizationLoading: boolean;
294
+ setIsActiveOrganizationLoading: Dispatch<SetStateAction<boolean>>;
295
+ isUserLoading: boolean;
296
+ billingAccount: BillingAccount | undefined;
297
+ isBillingAccountLoading: boolean;
298
+ trialSubscription: Subscription | undefined;
299
+ activeSubscription: Subscription | undefined;
300
+ subscriptions: Subscription[];
301
+ isActiveSubscriptionLoading: boolean;
302
+ trialPlan: Plan | undefined;
303
+ activePlan: Plan | undefined;
304
+ allPlans: Plan[];
305
+ isAllPlansLoading: boolean;
306
+ fetchActiveSubscription: () => Promise<Subscription | undefined>;
307
+ paymentMethod: PaymentMethod | undefined;
308
+ basePlan?: Plan;
309
+ organizationKyc: OrganizationKyc | undefined;
310
+ isOrganizationKycLoading: boolean;
311
+ billingDetails: BillingAccountDetails | undefined;
312
+ sessionMetadata: {
313
+ browser?: string;
314
+ operatingSystem?: string;
315
+ ipAddress?: string;
316
+ location?: {
317
+ city?: string;
318
+ country?: string;
319
+ latitude?: string;
320
+ longitude?: string;
321
+ };
322
+ } | undefined;
323
+ }
324
+ declare function useFrontier(): FrontierContextProviderProps;
325
+
326
+ declare const queryClient: QueryClient;
327
+ declare const FrontierProvider: {
328
+ (props: FrontierProviderProps): react_jsx_runtime.JSX.Element;
329
+ displayName: string;
330
+ };
331
+
332
+ interface CustomizationProviderProps {
333
+ children: ReactNode;
334
+ config?: FrontierClientCustomizationOptions;
335
+ }
336
+ declare const CustomizationProvider: React.FC<CustomizationProviderProps>;
337
+
338
+ interface TerminologyOptions {
339
+ plural?: boolean;
340
+ case?: "lower" | "upper" | "capital";
341
+ }
342
+ interface TerminologyEntity {
343
+ (options?: TerminologyOptions): string;
344
+ }
345
+ interface TerminologyMap {
346
+ organization: TerminologyEntity;
347
+ project: TerminologyEntity;
348
+ team: TerminologyEntity;
349
+ member: TerminologyEntity;
350
+ user: TerminologyEntity;
351
+ appName: TerminologyEntity;
352
+ }
353
+ declare const useTerminology: () => TerminologyMap;
354
+
355
+ interface UseTokensReturn {
356
+ tokenBalance: bigint;
357
+ isTokensLoading: boolean;
358
+ fetchTokenBalance: () => Promise<any>;
359
+ }
360
+ declare const useTokens: () => UseTokensReturn;
361
+
362
+ declare const useBillingPermission: () => {
363
+ isFetching: boolean;
364
+ isAllowed: boolean;
365
+ canSeeBilling: boolean;
366
+ };
367
+
368
+ type UseConnectQueryPollingResult<TData> = UseQueryResult<TData, ConnectError> & {
369
+ isPollingFailed: boolean;
370
+ };
371
+ declare function useConnectQueryPolling<I extends DescMessage, O extends DescMessage, SelectOutData = MessageShape<O>>(params: {
372
+ method: DescMethodUnary<I, O>;
373
+ input: MessageInitShape<I> | undefined;
374
+ enabled: boolean;
375
+ select: (data: MessageShape<O>) => SelectOutData;
376
+ isComplete: (data: SelectOutData) => boolean;
377
+ maxPoll?: number;
378
+ pollingInterval?: number;
379
+ }): UseConnectQueryPollingResult<SelectOutData>;
380
+
381
+ type Preference = {
382
+ name?: string;
383
+ value?: string;
384
+ scopeType?: string;
385
+ scopeId?: string;
386
+ [key: string]: any;
387
+ };
388
+ type Preferences = Record<string, Preference>;
389
+ interface UsePreferences {
390
+ preferences: Preferences;
391
+ isLoading: boolean;
392
+ isFetching: boolean;
393
+ status: 'idle' | 'fetching' | 'loading';
394
+ fetchPreferences: () => void;
395
+ updatePreferences: (preferences: Preference[]) => Promise<void>;
396
+ fetchPreferencesStatus: UseQueryResult['status'];
397
+ updatePreferencesStatus: UseMutationResult['status'];
398
+ }
399
+ declare function usePreferences({ autoFetch, scopeType, scopeId }?: {
400
+ autoFetch?: boolean;
401
+ scopeType?: string;
402
+ scopeId?: string;
403
+ }): UsePreferences;
404
+
405
+ declare const PREFERENCE_OPTIONS: {
406
+ readonly NEWSLETTER: "newsletter";
407
+ };
408
+
409
+ /**
410
+ * Converts a ConnectRPC Timestamp to a JavaScript Date
411
+ */
412
+ declare function timestampToDate(timestamp?: Timestamp): Date | null;
413
+ /**
414
+ * Converts a ConnectRPC Timestamp to a Dayjs object
415
+ */
416
+ declare function timestampToDayjs(timestamp?: Timestamp): Dayjs | null;
417
+ /**
418
+ * Checks if a ConnectRPC Timestamp is the null time (0001-01-01T00:00:00Z)
419
+ */
420
+ declare function isNullTimestamp(timestamp?: Timestamp): boolean;
421
+ type TimeStamp = Timestamp;
422
+
423
+ export { AuthContainer, AuthHeader, 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, isNullTimestamp, queryClient, timestampToDate, timestampToDayjs, useBillingPermission, useConnectQueryPolling, useFrontier, usePreferences, useTerminology, useTokens };