@patientos/website-kit 0.2.4 → 0.2.6

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/README.md CHANGED
@@ -31,3 +31,42 @@ export function CertificateFunnel() {
31
31
 
32
32
  `publicApi.publishableKey` is public by design and is validated against the consuming
33
33
  site's origin by PatientOS. Never put server credentials or patient data in these props.
34
+
35
+ For a PatientOS clinic that explicitly registers `http://localhost:*`, the kit can carry a
36
+ verified patient session back to a dynamically allocated localhost dev server. The
37
+ one-time return credential is scrubbed from the URL and exchanged for a tab-scoped
38
+ bearer; deployed sites continue to use host-only patient cookies.
39
+
40
+ ## Store, cart and checkout
41
+
42
+ Use the runtime implementations in an ordinary hydrated React site:
43
+
44
+ ```tsx
45
+ import { StoreClient, CartClient, CheckoutClient } from '@patientos/website-kit/islands-impl'
46
+ import '@patientos/website-kit/website-kit.css'
47
+
48
+ const storeApiOrigin = 'https://my.example-clinic.com'
49
+
50
+ <StoreClient storeApiOrigin={storeApiOrigin} productHandle="vitamin-d" />
51
+ <CartClient storeApiOrigin={storeApiOrigin} />
52
+ <CheckoutClient
53
+ storeApiOrigin={storeApiOrigin}
54
+ ordersHref="/account/orders"
55
+ completionHref="/checkout/complete"
56
+ />
57
+ ```
58
+
59
+ Use `productHandle` for one exact product or `categoryHandle` for a category-filtered
60
+ catalogue; an exact product takes precedence when both are supplied.
61
+
62
+ Omit `storeApiOrigin` when PatientOS serves the clinic website and store on one origin.
63
+ For a separately deployed site it must be the clinic's verified patient/API origin, and
64
+ the site Origin must be registered on that clinic's active web-form channel. The client
65
+ always sends `credentials: 'include'` and `cache: 'no-store'`; checkout remains patient
66
+ sign-in-required.
67
+
68
+ The hosting clinic site owns `completionHref`. It defaults to `/checkout/complete`, must
69
+ resolve on that same origin, and receives the paid order ID as its `order` query parameter.
70
+ Cross-origin or malformed destinations safely fall back to the default. Cart lines carry
71
+ package-owned opaque IDs so paid reconciliation removes only the exact line generation
72
+ captured by that checkout attempt.
@@ -75,6 +75,10 @@ declare function BookingBlock({ appointmentTypeId, practitionerId, appointmentTy
75
75
  type StoreProps = {
76
76
  /** Show one category only. Omitted ⇒ the whole published catalogue. */
77
77
  categoryHandle?: string;
78
+ /** Show exactly one product by its stable handle. Takes precedence over category. */
79
+ productHandle?: string;
80
+ /** PatientOS patient/API origin. Omitted keeps the original same-origin contract. */
81
+ storeApiOrigin?: string;
78
82
  /** Heading rendered above the grid. */
79
83
  title?: string;
80
84
  /** Grid columns at the widest breakpoint. */
@@ -89,12 +93,15 @@ type StoreMarkerProps = StoreProps & {
89
93
  * itself is fetched at runtime (prices and stock must not be baked into a cached static
90
94
  * artifact), so the fallback is a prompt, not a product list.
91
95
  */
92
- declare function Store({ categoryHandle, title, columns, className, }: StoreMarkerProps): React.ReactElement;
96
+ declare function Store({ categoryHandle, productHandle, storeApiOrigin, title, columns, className, }: StoreMarkerProps): React.ReactElement;
93
97
 
94
98
  /** JSON-safe island configuration. Crosses the build→runtime boundary — see `./islands`. */
95
- type CartProps = Record<string, never>;
96
- /** Marker-only props: presentation the page controls (the cart itself takes no config). */
97
- type CartMarkerProps = {
99
+ type CartProps = {
100
+ /** PatientOS patient/API origin. Omitted keeps the original same-origin contract. */
101
+ storeApiOrigin?: string;
102
+ };
103
+ /** Marker-only props: runtime config plus presentation the page controls. */
104
+ type CartMarkerProps = CartProps & {
98
105
  className?: string;
99
106
  };
100
107
  /**
@@ -103,12 +110,19 @@ type CartMarkerProps = {
103
110
  * The fallback shows NO line items — the static artifact is served to every visitor and
104
111
  * is edge-cacheable, so it must never carry a patient's cart.
105
112
  */
106
- declare function Cart({ className }: CartMarkerProps): React.ReactElement;
113
+ declare function Cart({ storeApiOrigin, className }: CartMarkerProps): React.ReactElement;
107
114
 
108
115
  /** JSON-safe island configuration. Crosses the build→runtime boundary — see `./islands`. */
109
- type CheckoutProps = Record<string, never>;
110
- /** Marker-only props: presentation the page controls (checkout itself takes no config). */
111
- type CheckoutMarkerProps = {
116
+ type CheckoutProps = {
117
+ /** PatientOS patient/API origin. Omitted keeps the original same-origin contract. */
118
+ storeApiOrigin?: string;
119
+ /** Shopper-facing order history on the hosting site. */
120
+ ordersHref?: string;
121
+ /** Same-origin order confirmation route on the hosting clinic site. */
122
+ completionHref?: string;
123
+ };
124
+ /** Marker-only props: runtime config plus presentation the page controls. */
125
+ type CheckoutMarkerProps = CheckoutProps & {
112
126
  className?: string;
113
127
  };
114
128
  /**
@@ -117,6 +131,6 @@ type CheckoutMarkerProps = {
117
131
  * The fallback carries no order, no amount and no payment field: this document is a
118
132
  * static artifact served to every visitor.
119
133
  */
120
- declare function Checkout({ className }: CheckoutMarkerProps): React.ReactElement;
134
+ declare function Checkout({ storeApiOrigin, ordersHref, completionHref, className, }: CheckoutMarkerProps): React.ReactElement;
121
135
 
122
136
  export { BookingBlock as B, Cart as C, type FunnelPublicApi as F, Store as S, type BookingBlockMarkerProps as a, type BookingBlockProps as b, type BookingTypeOption as c, type CartMarkerProps as d, type CartProps as e, CertificateFunnel as f, type CertificateFunnelMarkerProps as g, type CertificateFunnelProps as h, Checkout as i, type CheckoutMarkerProps as j, type CheckoutProps as k, type FunnelServiceOption as l, type StoreMarkerProps as m, type StoreProps as n };