@fayz-ai/plugin-reputation 0.2.3 → 0.2.4

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 (42) hide show
  1. package/dist/components/ReviewsList.d.ts +10 -0
  2. package/dist/components/ReviewsList.d.ts.map +1 -0
  3. package/dist/context.d.ts +11 -0
  4. package/dist/context.d.ts.map +1 -0
  5. package/dist/data/index.d.ts +5 -0
  6. package/dist/data/index.d.ts.map +1 -0
  7. package/dist/data/mock.d.ts +12 -0
  8. package/dist/data/mock.d.ts.map +1 -0
  9. package/dist/data/supabase.d.ts +3 -0
  10. package/dist/data/supabase.d.ts.map +1 -0
  11. package/dist/data/types.d.ts +10 -0
  12. package/dist/data/types.d.ts.map +1 -0
  13. package/dist/hooks/index.d.ts +5 -0
  14. package/dist/hooks/index.d.ts.map +1 -0
  15. package/dist/hooks/useReviewSummary.d.ts +9 -0
  16. package/dist/hooks/useReviewSummary.d.ts.map +1 -0
  17. package/dist/hooks/useReviews.d.ts +9 -0
  18. package/dist/hooks/useReviews.d.ts.map +1 -0
  19. package/dist/index.cjs.map +1 -1
  20. package/dist/index.d.ts.map +1 -1
  21. package/dist/index.js.map +1 -1
  22. package/dist/public/index.cjs +196 -0
  23. package/dist/public/index.cjs.map +1 -0
  24. package/dist/public/index.d.ts +33 -0
  25. package/dist/public/index.d.ts.map +1 -0
  26. package/dist/public/index.js +187 -0
  27. package/dist/public/index.js.map +1 -0
  28. package/dist/types.d.ts +30 -0
  29. package/dist/types.d.ts.map +1 -0
  30. package/package.json +8 -5
  31. package/src/components/ReviewsList.tsx +69 -0
  32. package/src/context.tsx +20 -0
  33. package/src/data/index.ts +4 -0
  34. package/src/data/mock.ts +45 -0
  35. package/src/data/supabase.ts +24 -0
  36. package/src/data/types.ts +10 -0
  37. package/src/hooks/index.ts +4 -0
  38. package/src/hooks/useReviewSummary.ts +41 -0
  39. package/src/hooks/useReviews.ts +44 -0
  40. package/src/index.ts +4 -0
  41. package/src/public/index.tsx +82 -0
  42. package/src/types.ts +34 -0
@@ -0,0 +1,82 @@
1
+ import { createElement, type FC, type ReactNode } from 'react'
2
+ import type { PluginManifest, PluginScope, VerticalId } from '@fayz-ai/core'
3
+ import { createSafeDataProvider } from '@fayz-ai/core'
4
+ import { createMockReputationProvider, type ReputationSeed } from '../data/mock'
5
+ import { createSupabaseReputationProvider } from '../data/supabase'
6
+ import { ReputationProvider, type ReputationContextValue } from '../context'
7
+ import { ReviewsList } from '../components/ReviewsList'
8
+ import type { ReputationDataProvider } from '../data/types'
9
+
10
+ // ---------------------------------------------------------------------------
11
+ // @fayz-ai/plugin-reputation/public — website reviews surface.
12
+ //
13
+ // Lean entry (no admin ReputationHome / @fayz-ai/ui). Returns a { manifest,
14
+ // Provider } bundle the host reads uniformly: the Provider wraps the app root so
15
+ // useReviews()/useReviewSummary() power the host's own review markup, and
16
+ // manifest.routes ships an optional /reviews page.
17
+ // ---------------------------------------------------------------------------
18
+
19
+ export interface ReputationWebsiteOptions {
20
+ /** Base path for the optional public "all reviews" page. Default '/reviews'. */
21
+ basePath?: string
22
+ /** Seed reviews + summary for the mock provider (used until a real backend is wired). */
23
+ seed?: ReputationSeed
24
+ /** Inject a custom provider. Overrides the safe mock/Supabase resolver. */
25
+ dataProvider?: ReputationDataProvider
26
+ /** Heading for the optional /reviews screen. */
27
+ heading?: string
28
+ scope?: PluginScope
29
+ verticalId?: VerticalId
30
+ }
31
+
32
+ export interface ReputationWebsitePlugin {
33
+ manifest: PluginManifest
34
+ Provider: FC<{ children: ReactNode }>
35
+ dataProvider: ReputationDataProvider
36
+ }
37
+
38
+ export function createReputationWebsite(options?: ReputationWebsiteOptions): ReputationWebsitePlugin {
39
+ const basePath = options?.basePath ?? '/reviews'
40
+ const heading = options?.heading ?? 'O que os pacientes dizem'
41
+ const provider =
42
+ options?.dataProvider ??
43
+ createSafeDataProvider(
44
+ () => createSupabaseReputationProvider(),
45
+ () => createMockReputationProvider({ seed: options?.seed }),
46
+ )
47
+
48
+ const value: ReputationContextValue = { provider }
49
+ const Provider: FC<{ children: ReactNode }> = ({ children }) =>
50
+ createElement(ReputationProvider, { value, children })
51
+ Provider.displayName = 'ReputationWebsiteProvider'
52
+
53
+ const ReviewsScreen: FC<unknown> = () => createElement(ReviewsList, { heading })
54
+ ReviewsScreen.displayName = 'ReviewsScreen'
55
+
56
+ const manifest: PluginManifest = {
57
+ id: 'reputation',
58
+ name: 'Reviews',
59
+ icon: 'Star',
60
+ version: '0.1.0',
61
+ scope: options?.scope ?? 'universal',
62
+ verticalId: options?.verticalId,
63
+ scaffolds: ['website', 'landing_page'],
64
+ defaultEnabled: true,
65
+ dependencies: [],
66
+ navigation: [],
67
+ routes: [{ path: basePath, component: ReviewsScreen, guard: 'public' }],
68
+ widgets: [],
69
+ }
70
+
71
+ return { manifest, Provider, dataProvider: provider }
72
+ }
73
+
74
+ // Public API — website surface
75
+ export type { Review, ReviewSummary, ReviewSource, ReviewListQuery } from '../types'
76
+ export type { ReputationDataProvider } from '../data/types'
77
+ export { createMockReputationProvider, createSupabaseReputationProvider } from '../data'
78
+ export type { ReputationSeed } from '../data/mock'
79
+ export { ReputationProvider, useReputationContext } from '../context'
80
+ export type { ReputationContextValue } from '../context'
81
+ export { useReviews, useReviewSummary } from '../hooks'
82
+ export { ReviewsList } from '../components/ReviewsList'
package/src/types.ts ADDED
@@ -0,0 +1,34 @@
1
+ // ---------------------------------------------------------------------------
2
+ // Reputation domain types (shared by the admin M1 view and the website surface).
3
+ // Presentation-agnostic: a host site maps these into its own review-card markup.
4
+ // ---------------------------------------------------------------------------
5
+
6
+ export type ReviewSource = 'Google' | 'Facebook' | 'Instagram' | 'Website' | (string & {})
7
+
8
+ export interface Review {
9
+ id: string
10
+ /** Reviewer display name. */
11
+ author: string
12
+ rating: number
13
+ text: string
14
+ /** Human-readable date (e.g. "Janeiro 2025"). */
15
+ date: string
16
+ source?: ReviewSource
17
+ /** Whether the business has replied (admin surface). */
18
+ replied?: boolean
19
+ }
20
+
21
+ export interface ReviewSummary {
22
+ /** Average rating, e.g. 4.8. */
23
+ average: number
24
+ /** Total number of ratings, e.g. 123. */
25
+ count: number
26
+ /** Optional star distribution (5→1). */
27
+ distribution?: Array<{ stars: number; count: number }>
28
+ }
29
+
30
+ export interface ReviewListQuery {
31
+ limit?: number
32
+ /** Minimum rating to include. */
33
+ minRating?: number
34
+ }