@scalemule/nextjs 0.0.41 → 0.1.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/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
2
+ import { ReactNode, ReactElement } from 'react';
3
3
  import { MoneyClient } from '@scalemule/money';
4
4
  export { MoneyClient, MoneyClientConfig, createMoneyClient } from '@scalemule/money';
5
5
  import { RealtimeService } from '@scalemule/sdk';
@@ -346,6 +346,106 @@ interface UseShareReturn {
346
346
  }
347
347
  declare function useShare(options?: UseShareOptions): UseShareReturn;
348
348
 
349
+ /**
350
+ * Public types for the feedback hook + widget.
351
+ *
352
+ * Mirrors the JSON shape returned by `scalemule-feedback`'s public endpoints
353
+ * (`/v1/feedback/submit`, `/v1/feedback/items`). Dashboard/admin shapes live
354
+ * server-side and are not exported here — customer apps interact with the
355
+ * SDK only through the end-user surface.
356
+ */
357
+ type FeedbackType = 'bug_report' | 'feature_request' | 'improvement' | 'other';
358
+ type FeedbackStatus = 'new' | 'reviewed' | 'planned' | 'in_progress' | 'completed' | 'declined';
359
+ type FeedbackPriority = 'low' | 'medium' | 'high' | 'urgent';
360
+ /**
361
+ * The end-user-visible shape of a feedback item. Excludes staff-only fields
362
+ * (assigned_to, internal_notes, email of OTHER users, etc.) that the service
363
+ * never returns through `/items`.
364
+ */
365
+ interface FeedbackItem {
366
+ id: string;
367
+ type: FeedbackType;
368
+ title: string;
369
+ description: string;
370
+ status: FeedbackStatus;
371
+ priority: FeedbackPriority;
372
+ tags: string[] | null;
373
+ created_at: string;
374
+ updated_at: string;
375
+ }
376
+ /**
377
+ * Body for `POST /v1/feedback/submit`.
378
+ *
379
+ * `email` is required when no end-user session is present — the gateway omits
380
+ * `x-user-id` in that case and the service rejects with 400 unless email is
381
+ * given. When a session exists, email is optional.
382
+ */
383
+ interface FeedbackItemInput {
384
+ type: FeedbackType;
385
+ title: string;
386
+ description: string;
387
+ email?: string;
388
+ tags?: string[];
389
+ }
390
+
391
+ interface UseFeedbackOptions {
392
+ /** Optional status filter applied to the list call. */
393
+ status?: FeedbackStatus;
394
+ /** Optional type filter. */
395
+ type?: FeedbackType;
396
+ /** When false, suppress the initial list fetch (the widget submits without listing). */
397
+ enabled?: boolean;
398
+ }
399
+ interface UseFeedbackResult {
400
+ /** End-user's own feedback items for the current tenant. Empty when not signed in. */
401
+ items: FeedbackItem[];
402
+ loading: boolean;
403
+ error: ApiError | null;
404
+ /** Submit a new feedback item. Returns the persisted item on success. */
405
+ submit: (input: FeedbackItemInput) => Promise<FeedbackItem>;
406
+ /** Re-fetch the list. */
407
+ refresh: () => Promise<void>;
408
+ }
409
+ /**
410
+ * Hook for end-user feedback submission and read-own.
411
+ *
412
+ * Calls go through `client` from `ScaleMuleProvider`, which attaches the
413
+ * configured API key and (when present) the user session token. Tenancy
414
+ * (`x-app-id`) is derived by the gateway from the API key — never set
415
+ * client-side.
416
+ */
417
+ declare function useFeedback(options?: UseFeedbackOptions): UseFeedbackResult;
418
+
419
+ interface FeedbackWidgetProps {
420
+ /** Floating-button corner. Default `bottom-right`. */
421
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
422
+ /** Default selected type when the modal opens. Default `feature_request`. */
423
+ defaultType?: FeedbackType;
424
+ /** Restrict the type select to this subset. Default: all four types. */
425
+ allowedTypes?: FeedbackType[];
426
+ /** Trigger button label. Default `Feedback`. */
427
+ triggerLabel?: string;
428
+ /** `light`/`dark`/`auto` (matches OS). Default `auto`. */
429
+ theme?: 'light' | 'dark' | 'auto';
430
+ /** Optional class for the trigger button (use to override styling). */
431
+ className?: string;
432
+ /** Called after a successful submit. */
433
+ onSubmitted?: (item: FeedbackItem) => void;
434
+ }
435
+ /**
436
+ * Floating feedback widget. Renders nothing until the trigger is clicked,
437
+ * then opens a small modal with type / title / description fields. Submits
438
+ * via `useFeedback().submit()` — inherits identity from `ScaleMuleProvider`.
439
+ *
440
+ * If the end-user is not signed in, the widget shows an additional `email`
441
+ * field (required by the service for anonymous submissions).
442
+ *
443
+ * Tenant must have `feedback_app_config.enabled = TRUE` for `/submit` to
444
+ * accept submissions; otherwise the service responds with 404
445
+ * `FEEDBACK_DISABLED` and the widget surfaces the error message.
446
+ */
447
+ declare function FeedbackWidget(props: FeedbackWidgetProps): ReactElement | null;
448
+
349
449
  /**
350
450
  * Client-side validation helpers
351
451
  *
@@ -504,4 +604,4 @@ declare function createSafeLogger(prefix: string): {
504
604
  error: (message: string, data?: unknown) => void;
505
605
  };
506
606
 
507
- export { ApiError, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, ListFilesParams, LoginResponse, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleProvider, type ScaleMuleProviderProps, UseAnalyticsOptions, UseAnalyticsReturn, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, UseUserReturn, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useUser, validateForm, validators };
607
+ export { ApiError, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, type FeedbackItem, type FeedbackItemInput, type FeedbackPriority, type FeedbackStatus, type FeedbackType, FeedbackWidget, type FeedbackWidgetProps, ListFilesParams, LoginResponse, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleProvider, type ScaleMuleProviderProps, UseAnalyticsOptions, UseAnalyticsReturn, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeedbackOptions, type UseFeedbackResult, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, UseUserReturn, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useUser, validateForm, validators };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
2
+ import { ReactNode, ReactElement } from 'react';
3
3
  import { MoneyClient } from '@scalemule/money';
4
4
  export { MoneyClient, MoneyClientConfig, createMoneyClient } from '@scalemule/money';
5
5
  import { RealtimeService } from '@scalemule/sdk';
@@ -346,6 +346,106 @@ interface UseShareReturn {
346
346
  }
347
347
  declare function useShare(options?: UseShareOptions): UseShareReturn;
348
348
 
349
+ /**
350
+ * Public types for the feedback hook + widget.
351
+ *
352
+ * Mirrors the JSON shape returned by `scalemule-feedback`'s public endpoints
353
+ * (`/v1/feedback/submit`, `/v1/feedback/items`). Dashboard/admin shapes live
354
+ * server-side and are not exported here — customer apps interact with the
355
+ * SDK only through the end-user surface.
356
+ */
357
+ type FeedbackType = 'bug_report' | 'feature_request' | 'improvement' | 'other';
358
+ type FeedbackStatus = 'new' | 'reviewed' | 'planned' | 'in_progress' | 'completed' | 'declined';
359
+ type FeedbackPriority = 'low' | 'medium' | 'high' | 'urgent';
360
+ /**
361
+ * The end-user-visible shape of a feedback item. Excludes staff-only fields
362
+ * (assigned_to, internal_notes, email of OTHER users, etc.) that the service
363
+ * never returns through `/items`.
364
+ */
365
+ interface FeedbackItem {
366
+ id: string;
367
+ type: FeedbackType;
368
+ title: string;
369
+ description: string;
370
+ status: FeedbackStatus;
371
+ priority: FeedbackPriority;
372
+ tags: string[] | null;
373
+ created_at: string;
374
+ updated_at: string;
375
+ }
376
+ /**
377
+ * Body for `POST /v1/feedback/submit`.
378
+ *
379
+ * `email` is required when no end-user session is present — the gateway omits
380
+ * `x-user-id` in that case and the service rejects with 400 unless email is
381
+ * given. When a session exists, email is optional.
382
+ */
383
+ interface FeedbackItemInput {
384
+ type: FeedbackType;
385
+ title: string;
386
+ description: string;
387
+ email?: string;
388
+ tags?: string[];
389
+ }
390
+
391
+ interface UseFeedbackOptions {
392
+ /** Optional status filter applied to the list call. */
393
+ status?: FeedbackStatus;
394
+ /** Optional type filter. */
395
+ type?: FeedbackType;
396
+ /** When false, suppress the initial list fetch (the widget submits without listing). */
397
+ enabled?: boolean;
398
+ }
399
+ interface UseFeedbackResult {
400
+ /** End-user's own feedback items for the current tenant. Empty when not signed in. */
401
+ items: FeedbackItem[];
402
+ loading: boolean;
403
+ error: ApiError | null;
404
+ /** Submit a new feedback item. Returns the persisted item on success. */
405
+ submit: (input: FeedbackItemInput) => Promise<FeedbackItem>;
406
+ /** Re-fetch the list. */
407
+ refresh: () => Promise<void>;
408
+ }
409
+ /**
410
+ * Hook for end-user feedback submission and read-own.
411
+ *
412
+ * Calls go through `client` from `ScaleMuleProvider`, which attaches the
413
+ * configured API key and (when present) the user session token. Tenancy
414
+ * (`x-app-id`) is derived by the gateway from the API key — never set
415
+ * client-side.
416
+ */
417
+ declare function useFeedback(options?: UseFeedbackOptions): UseFeedbackResult;
418
+
419
+ interface FeedbackWidgetProps {
420
+ /** Floating-button corner. Default `bottom-right`. */
421
+ position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
422
+ /** Default selected type when the modal opens. Default `feature_request`. */
423
+ defaultType?: FeedbackType;
424
+ /** Restrict the type select to this subset. Default: all four types. */
425
+ allowedTypes?: FeedbackType[];
426
+ /** Trigger button label. Default `Feedback`. */
427
+ triggerLabel?: string;
428
+ /** `light`/`dark`/`auto` (matches OS). Default `auto`. */
429
+ theme?: 'light' | 'dark' | 'auto';
430
+ /** Optional class for the trigger button (use to override styling). */
431
+ className?: string;
432
+ /** Called after a successful submit. */
433
+ onSubmitted?: (item: FeedbackItem) => void;
434
+ }
435
+ /**
436
+ * Floating feedback widget. Renders nothing until the trigger is clicked,
437
+ * then opens a small modal with type / title / description fields. Submits
438
+ * via `useFeedback().submit()` — inherits identity from `ScaleMuleProvider`.
439
+ *
440
+ * If the end-user is not signed in, the widget shows an additional `email`
441
+ * field (required by the service for anonymous submissions).
442
+ *
443
+ * Tenant must have `feedback_app_config.enabled = TRUE` for `/submit` to
444
+ * accept submissions; otherwise the service responds with 404
445
+ * `FEEDBACK_DISABLED` and the widget surfaces the error message.
446
+ */
447
+ declare function FeedbackWidget(props: FeedbackWidgetProps): ReactElement | null;
448
+
349
449
  /**
350
450
  * Client-side validation helpers
351
451
  *
@@ -504,4 +604,4 @@ declare function createSafeLogger(prefix: string): {
504
604
  error: (message: string, data?: unknown) => void;
505
605
  };
506
606
 
507
- export { ApiError, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, ListFilesParams, LoginResponse, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleProvider, type ScaleMuleProviderProps, UseAnalyticsOptions, UseAnalyticsReturn, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, UseUserReturn, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useUser, validateForm, validators };
607
+ export { ApiError, type FeatureFlagEvaluation, type FeatureFlagEvaluation as FeatureFlagResult, type FeedbackItem, type FeedbackItemInput, type FeedbackPriority, type FeedbackStatus, type FeedbackType, FeedbackWidget, type FeedbackWidgetProps, ListFilesParams, LoginResponse, type PasswordValidationResult, type PhoneCountry, type PhoneValidationResult, type RealtimeEvent, type RealtimeMessage, type RealtimeStatus, ScaleMuleClient, ScaleMuleConfig, ScaleMuleProvider, type ScaleMuleProviderProps, UseAnalyticsOptions, UseAnalyticsReturn, UseAuthReturn, UseBillingReturn, UseContentReturn, type UseFeatureFlagsOptions, type UseFeatureFlagsReturn, type UseFeedbackOptions, type UseFeedbackResult, type UseFeatureFlagsOptions as UseFlagsOptions, type UseFeatureFlagsReturn as UseFlagsReturn, type UsePushNotificationsOptions, type UsePushNotificationsReturn, type UseRealtimeOptions, type UseRealtimeReturn, type UseShareOptions, type UseShareReturn, UseUserReturn, User, type UsernameValidationResult, composePhone, createSafeLogger, normalizePhone, phoneCountries, sanitizeForLog, useAnalytics, useAuth, useBilling, useContent, useFeatureFlags, useFeedback, useMoney, useMoneyClient, usePushNotifications, useRealtime, useScaleMule, useScaleMuleClient, useShare, useUser, validateForm, validators };