@cosmoops/connect-sdk 0.3.0 → 0.7.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/CHANGELOG.md +125 -0
- package/README.md +215 -6
- package/dist/cjs/cli/doctor.js +3 -3
- package/dist/cjs/cli/init.js +3 -3
- package/dist/cjs/client/components/access-gate.js +162 -0
- package/dist/cjs/client/components/account-sessions.js +24 -22
- package/dist/cjs/client/components/app-shell.js +157 -0
- package/dist/cjs/client/components/apps-grid.js +4 -3
- package/dist/cjs/client/components/feature-gate.js +2 -2
- package/dist/cjs/client/components/integrations-modal.js +95 -0
- package/dist/cjs/client/components/logo.js +3 -3
- package/dist/cjs/client/components/motion.js +27 -0
- package/dist/cjs/client/components/nav.js +97 -0
- package/dist/cjs/client/components/plan-pricing.js +1 -1
- package/dist/cjs/client/components/plans.js +42 -40
- package/dist/cjs/client/components/readiness.js +6 -4
- package/dist/cjs/client/components/side-nav.js +58 -0
- package/dist/cjs/client/components/subscribe-dialog.js +2 -2
- package/dist/cjs/client/components/subscription.js +3 -2
- package/dist/cjs/client/components/surfaces.js +54 -0
- package/dist/cjs/client/components/usage-meter.js +4 -3
- package/dist/cjs/client/components/user-menu.js +33 -6
- package/dist/cjs/client/index.js +30 -2
- package/dist/cjs/client/mark.js +1 -1
- package/dist/cjs/client/provider.js +60 -8
- package/dist/cjs/client/use-active-path.js +77 -0
- package/dist/cjs/client/use-checkout.js +3 -3
- package/dist/cjs/errors.js +4 -4
- package/dist/cjs/helpers.js +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/next/index.js +96 -15
- package/dist/cjs/server/client.js +22 -14
- package/dist/cjs/server/handler.js +99 -16
- package/dist/cjs/server/http.js +1 -1
- package/dist/cjs/server/index.js +8 -1
- package/dist/cjs/server/resources/access.js +3 -3
- package/dist/cjs/server/resources/ai.js +1 -1
- package/dist/cjs/server/resources/analytics.js +66 -0
- package/dist/cjs/server/resources/apps.js +4 -4
- package/dist/cjs/server/resources/billing.js +5 -5
- package/dist/cjs/server/resources/drive.js +4 -4
- package/dist/cjs/server/resources/entitlements.js +7 -7
- package/dist/cjs/server/resources/identity.js +4 -4
- package/dist/cjs/server/resources/integrations.js +66 -0
- package/dist/cjs/server/resources/logs.js +3 -3
- package/dist/cjs/server/resources/sessions.js +6 -6
- package/dist/cjs/server/webhooks.js +127 -0
- package/dist/cjs/types.js +1 -1
- package/dist/esm/cli/doctor.js +3 -3
- package/dist/esm/cli/init.js +3 -3
- package/dist/esm/client/components/access-gate.js +158 -0
- package/dist/esm/client/components/account-sessions.js +24 -22
- package/dist/esm/client/components/app-shell.js +154 -0
- package/dist/esm/client/components/apps-grid.js +4 -3
- package/dist/esm/client/components/feature-gate.js +2 -2
- package/dist/esm/client/components/integrations-modal.js +92 -0
- package/dist/esm/client/components/logo.js +3 -3
- package/dist/esm/client/components/motion.js +21 -0
- package/dist/esm/client/components/nav.js +89 -0
- package/dist/esm/client/components/plan-pricing.js +1 -1
- package/dist/esm/client/components/plans.js +42 -40
- package/dist/esm/client/components/readiness.js +6 -4
- package/dist/esm/client/components/side-nav.js +53 -0
- package/dist/esm/client/components/subscribe-dialog.js +2 -2
- package/dist/esm/client/components/subscription.js +3 -2
- package/dist/esm/client/components/surfaces.js +51 -0
- package/dist/esm/client/components/usage-meter.js +4 -3
- package/dist/esm/client/components/user-menu.js +34 -7
- package/dist/esm/client/index.js +16 -2
- package/dist/esm/client/mark.js +1 -1
- package/dist/esm/client/provider.js +59 -8
- package/dist/esm/client/use-active-path.js +74 -0
- package/dist/esm/client/use-checkout.js +3 -3
- package/dist/esm/errors.js +4 -4
- package/dist/esm/helpers.js +1 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/next/index.js +95 -15
- package/dist/esm/server/client.js +22 -14
- package/dist/esm/server/handler.js +99 -16
- package/dist/esm/server/http.js +1 -1
- package/dist/esm/server/index.js +5 -0
- package/dist/esm/server/resources/access.js +3 -3
- package/dist/esm/server/resources/ai.js +1 -1
- package/dist/esm/server/resources/analytics.js +62 -0
- package/dist/esm/server/resources/apps.js +4 -4
- package/dist/esm/server/resources/billing.js +5 -5
- package/dist/esm/server/resources/drive.js +4 -4
- package/dist/esm/server/resources/entitlements.js +7 -7
- package/dist/esm/server/resources/identity.js +4 -4
- package/dist/esm/server/resources/integrations.js +62 -0
- package/dist/esm/server/resources/logs.js +3 -3
- package/dist/esm/server/resources/sessions.js +6 -6
- package/dist/esm/server/webhooks.js +123 -0
- package/dist/esm/types.js +1 -1
- package/dist/theme.css +28 -0
- package/dist/types/client/components/access-gate.d.ts +79 -0
- package/dist/types/client/components/account-sessions.d.ts +1 -1
- package/dist/types/client/components/app-shell.d.ts +115 -0
- package/dist/types/client/components/apps-grid.d.ts +1 -1
- package/dist/types/client/components/feature-gate.d.ts +1 -1
- package/dist/types/client/components/integrations-modal.d.ts +21 -0
- package/dist/types/client/components/logo.d.ts +5 -5
- package/dist/types/client/components/motion.d.ts +22 -0
- package/dist/types/client/components/nav.d.ts +110 -0
- package/dist/types/client/components/plan-pricing.d.ts +2 -2
- package/dist/types/client/components/readiness.d.ts +2 -2
- package/dist/types/client/components/side-nav.d.ts +31 -0
- package/dist/types/client/components/subscribe-dialog.d.ts +3 -3
- package/dist/types/client/components/surfaces.d.ts +51 -0
- package/dist/types/client/components/usage-meter.d.ts +1 -1
- package/dist/types/client/components/user-menu.d.ts +2 -2
- package/dist/types/client/index.d.ts +13 -2
- package/dist/types/client/mark.d.ts +1 -1
- package/dist/types/client/provider.d.ts +44 -9
- package/dist/types/client/use-active-path.d.ts +8 -0
- package/dist/types/client/use-checkout.d.ts +3 -3
- package/dist/types/errors.d.ts +4 -4
- package/dist/types/helpers.d.ts +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/next/index.d.ts +40 -0
- package/dist/types/server/client.d.ts +17 -11
- package/dist/types/server/handler.d.ts +2 -2
- package/dist/types/server/index.d.ts +7 -0
- package/dist/types/server/resources/access.d.ts +3 -3
- package/dist/types/server/resources/ai.d.ts +2 -2
- package/dist/types/server/resources/analytics.d.ts +31 -0
- package/dist/types/server/resources/apps.d.ts +4 -4
- package/dist/types/server/resources/billing.d.ts +4 -4
- package/dist/types/server/resources/drive.d.ts +4 -4
- package/dist/types/server/resources/entitlements.d.ts +4 -4
- package/dist/types/server/resources/identity.d.ts +14 -4
- package/dist/types/server/resources/integrations.d.ts +40 -0
- package/dist/types/server/resources/logs.d.ts +3 -3
- package/dist/types/server/resources/sessions.d.ts +5 -5
- package/dist/types/server/webhooks.d.ts +67 -0
- package/dist/types/types.d.ts +220 -39
- package/package.json +10 -4
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
export interface ConnectLogoProps {
|
|
3
3
|
/**
|
|
4
|
-
* This
|
|
4
|
+
* This application's name - rendered as the sub-brand beneath the `cosmo·ops`
|
|
5
5
|
* wordmark, in the house `cosmo·ops VOICE` treatment.
|
|
6
6
|
*/
|
|
7
7
|
name: string;
|
|
8
8
|
/**
|
|
9
|
-
* This
|
|
9
|
+
* This application's own glyph, drawn inside the accent badge. Any node - a
|
|
10
10
|
* `lucide-react` icon, an `<img>`, an inline `<svg>`. Paint it with
|
|
11
11
|
* `currentColor` and it inherits `--accent-foreground` from the badge, so it
|
|
12
12
|
* stays legible when a host app changes the accent.
|
|
@@ -19,10 +19,10 @@ export interface ConnectLogoProps {
|
|
|
19
19
|
className?: string;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* The shared platform lockup:
|
|
23
|
-
* `cosmo·ops` beside it, and the
|
|
22
|
+
* The shared platform lockup: an application's own glyph on the CosmoOps badge,
|
|
23
|
+
* `cosmo·ops` beside it, and the application name underneath.
|
|
24
24
|
*
|
|
25
|
-
* This is what makes a family of
|
|
25
|
+
* This is what makes a family of application platforms look like one product. Each
|
|
26
26
|
* platform passes only what differs - its `name` and its `icon` - and inherits
|
|
27
27
|
* the mark geometry, the wordmark treatment, the separator, and the accent from
|
|
28
28
|
* one place. Change the lockup here and every platform follows.
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export { m, AnimatePresence } from "motion/react";
|
|
3
|
+
/** HeroUI's --ease-out-quart, transcribed for motion transitions. */
|
|
4
|
+
export declare const EASE_OUT_QUART: readonly [0.165, 0.84, 0.44, 1];
|
|
5
|
+
export declare const ENTER: {
|
|
6
|
+
readonly duration: 0.3;
|
|
7
|
+
readonly ease: readonly [0.165, 0.84, 0.44, 1];
|
|
8
|
+
};
|
|
9
|
+
export declare const METER_SPRING: {
|
|
10
|
+
readonly type: "spring";
|
|
11
|
+
readonly stiffness: 170;
|
|
12
|
+
readonly damping: 26;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Per-component motion root. domAnimation keeps the feature bundle small,
|
|
16
|
+
* `strict` restricts rendering to `m.*` components, and reducedMotion="user"
|
|
17
|
+
* drops transform animation (keeping opacity) under prefers-reduced-motion -
|
|
18
|
+
* the same contract HeroUI's own `motion-reduce` styles follow.
|
|
19
|
+
*/
|
|
20
|
+
export declare function MotionProvider({ children }: Readonly<{
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
}>): import("react").JSX.Element;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/**
|
|
3
|
+
* One destination in the shell's sidebar.
|
|
4
|
+
*
|
|
5
|
+
* `href` is a path in *your* app, not a Connect URL - the shell never
|
|
6
|
+
* routes anywhere itself, it hands `href` to `renderLink` and lets your
|
|
7
|
+
* router do the work.
|
|
8
|
+
*/
|
|
9
|
+
export interface ConnectNavItem {
|
|
10
|
+
label: string;
|
|
11
|
+
href: string;
|
|
12
|
+
/**
|
|
13
|
+
* A pre-rendered glyph, e.g. `<LayoutDashboard className="size-5" />`.
|
|
14
|
+
* Required in practice for anything in the primary rail: the collapsed rail
|
|
15
|
+
* is icon-only, and an item with no icon collapses to an empty box.
|
|
16
|
+
*/
|
|
17
|
+
icon?: ReactNode;
|
|
18
|
+
/** Trailing content on the row - a count `<Chip>`, a status dot. Hidden while collapsed. */
|
|
19
|
+
badge?: ReactNode;
|
|
20
|
+
/**
|
|
21
|
+
* Match this route only when the path is exactly `href`, never as a prefix.
|
|
22
|
+
* `/` is always treated as exact regardless, since every path starts with it.
|
|
23
|
+
*/
|
|
24
|
+
exact?: boolean;
|
|
25
|
+
/** Opens in a new tab, with a trailing arrow. For docs, status pages, anything outside the app. */
|
|
26
|
+
external?: boolean;
|
|
27
|
+
/** One level of children, revealed beneath the parent when the parent or a child is active. */
|
|
28
|
+
items?: ConnectNavItem[];
|
|
29
|
+
/**
|
|
30
|
+
* Leave this route *outside* `ConnectAccessGate` - see
|
|
31
|
+
* `ConnectAppShellProps.gate`. Declared here, next to the route it applies
|
|
32
|
+
* to, rather than as a second list somewhere else that has to be kept in
|
|
33
|
+
* step with this one.
|
|
34
|
+
*/
|
|
35
|
+
gateExempt?: boolean;
|
|
36
|
+
}
|
|
37
|
+
/** A titled group of items. Untitled groups render as a plain divider-free block. */
|
|
38
|
+
export interface ConnectNavSection {
|
|
39
|
+
title?: string;
|
|
40
|
+
items: ConnectNavItem[];
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* What `ConnectAppShell`/`ConnectSideNav` accept for `nav`: a flat list of
|
|
44
|
+
* items, a list of sections, or a mix. Consecutive bare items fold into one
|
|
45
|
+
* untitled section, so the common case is just an array of items.
|
|
46
|
+
*/
|
|
47
|
+
export type ConnectNav = ReadonlyArray<ConnectNavItem | ConnectNavSection>;
|
|
48
|
+
/** Props the shell hands to `renderLink`. Spread them onto whatever your router's link component is. */
|
|
49
|
+
export interface ConnectNavLinkProps {
|
|
50
|
+
href: string;
|
|
51
|
+
className: string;
|
|
52
|
+
children: ReactNode;
|
|
53
|
+
onClick?: () => void;
|
|
54
|
+
"aria-current"?: "page";
|
|
55
|
+
/**
|
|
56
|
+
* Always set, and the only name the link has while the rail is collapsed -
|
|
57
|
+
* spread it through rather than dropping it, or an icon-only rail reads as
|
|
58
|
+
* a column of unlabelled links.
|
|
59
|
+
*/
|
|
60
|
+
"aria-label": string;
|
|
61
|
+
target?: string;
|
|
62
|
+
rel?: string;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* How this app renders a link.
|
|
66
|
+
*
|
|
67
|
+
* The SDK ships into any React app and cannot import `next/link`,
|
|
68
|
+
* `react-router` or anything else framework-specific, so routing is a prop.
|
|
69
|
+
* The default is a plain `<a>`, which is correct but costs a full page load;
|
|
70
|
+
* an app with a client router should pass its own:
|
|
71
|
+
*
|
|
72
|
+
* ```tsx
|
|
73
|
+
* renderLink={(props) => <Link {...props} />} // next/link
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
export type ConnectLinkRenderer = (props: ConnectNavLinkProps) => ReactNode;
|
|
77
|
+
/** Folds a mixed `ConnectNav` into sections, gathering consecutive bare items into one untitled group. */
|
|
78
|
+
export declare function normalizeNav(nav: ConnectNav): ConnectNavSection[];
|
|
79
|
+
/** Every item in the tree, parents and children alike, in render order. */
|
|
80
|
+
export declare function flattenNav(nav: ConnectNav): ConnectNavItem[];
|
|
81
|
+
/**
|
|
82
|
+
* `https://x.test/billing/?tab=1#top` -> `/billing`.
|
|
83
|
+
*
|
|
84
|
+
* Trailing slashes go too, so `/billing/` and `/billing` are the same route -
|
|
85
|
+
* they are, to every router, and treating them as different is how a nav item
|
|
86
|
+
* ends up unhighlighted on exactly one of the two URLs a user can arrive at.
|
|
87
|
+
*/
|
|
88
|
+
export declare function normalizePath(path: string): string;
|
|
89
|
+
/**
|
|
90
|
+
* The href of the nav item the current path belongs to, or `null`.
|
|
91
|
+
*
|
|
92
|
+
* Longest prefix wins, so `/settings/billing` lights up Billing and not also
|
|
93
|
+
* its parent Settings - a plain `startsWith` over an unordered list lights up
|
|
94
|
+
* both, and the sidebar grows two highlights.
|
|
95
|
+
*
|
|
96
|
+
* External items never match: they leave the app, so no path inside it is
|
|
97
|
+
* ever "on" them.
|
|
98
|
+
*/
|
|
99
|
+
export declare function resolveActivePath(pathname: string, nav: ConnectNav): string | null;
|
|
100
|
+
/**
|
|
101
|
+
* Whether `item` is the destination `resolveActivePath` picked.
|
|
102
|
+
*
|
|
103
|
+
* Not just `normalizePath(item.href) === activeHref`, which is the trap this
|
|
104
|
+
* exists to close: `normalizePath` strips the origin off an absolute URL, so
|
|
105
|
+
* an external item pointed at `https://docs.example.com` normalizes to `/` and
|
|
106
|
+
* lights up on every app's home route. External items are never active.
|
|
107
|
+
*/
|
|
108
|
+
export declare function isNavItemActive(item: ConnectNavItem, activeHref: string | null): boolean;
|
|
109
|
+
/** Hrefs declared `gateExempt` - the routes `ConnectAppShell` renders outside its `ConnectAccessGate`. */
|
|
110
|
+
export declare function gateExemptPaths(nav: ConnectNav): string[];
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* an upgrade while the card behind it said downgrade would be worse than
|
|
5
5
|
* either label being wrong on its own.
|
|
6
6
|
*
|
|
7
|
-
* Mirrors `packages/data/src/
|
|
7
|
+
* Mirrors `packages/data/src/applications/catalog.ts` and
|
|
8
8
|
* `packages/data/src/payments/plan-change.ts`, which are the copies Connect's
|
|
9
9
|
* own UI uses and which decide which use-case actually runs. The duplication
|
|
10
10
|
* is deliberate and load-bearing: this package carries no dependency on
|
|
@@ -81,7 +81,7 @@ export declare function groupPlansByTier(plans: readonly Plan[]): PlanTier[];
|
|
|
81
81
|
*/
|
|
82
82
|
export declare function annualSaving(monthly: Plan | null | undefined, annual: Plan | null | undefined): number | null;
|
|
83
83
|
/**
|
|
84
|
-
* What moving to `plan` would be, given what the
|
|
84
|
+
* What moving to `plan` would be, given what the workspace is on today.
|
|
85
85
|
*
|
|
86
86
|
* `switch-to-annual`/`switch-to-monthly` exist because a change of *cadence*
|
|
87
87
|
* is neither an upgrade nor a downgrade, and calling it one is not a wording
|
|
@@ -6,7 +6,7 @@ export interface ConnectReadinessBannerProps {
|
|
|
6
6
|
className?: string;
|
|
7
7
|
}
|
|
8
8
|
/**
|
|
9
|
-
* Every gate between this workspace and your
|
|
9
|
+
* Every gate between this workspace and your application, with the way out of each.
|
|
10
10
|
*
|
|
11
11
|
* This is the component that keeps a blocked customer from staring at a broken
|
|
12
12
|
* app. `getReadiness` resolves subscription state, KYC/KYB, a chargeable
|
|
@@ -14,7 +14,7 @@ export interface ConnectReadinessBannerProps {
|
|
|
14
14
|
* `resolveUrl` into the exact Connect screen that fixes it** - so being blocked
|
|
15
15
|
* comes with somewhere to go rather than a refusal.
|
|
16
16
|
*
|
|
17
|
-
* Render it high on any page your
|
|
17
|
+
* Render it high on any page your application gates. It draws nothing at all when
|
|
18
18
|
* the workspace is ready, so it is safe to leave mounted permanently.
|
|
19
19
|
*
|
|
20
20
|
* Two deliberate refusals:
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { type ConnectLinkRenderer, type ConnectNav } from "./nav.js";
|
|
2
|
+
/** A plain anchor - correct anywhere, and a full page load. See `ConnectLinkRenderer`. */
|
|
3
|
+
export declare const defaultRenderLink: ConnectLinkRenderer;
|
|
4
|
+
export interface ConnectSideNavProps {
|
|
5
|
+
/** Items, sections, or a mix - see `ConnectNav`. */
|
|
6
|
+
nav: ConnectNav;
|
|
7
|
+
/**
|
|
8
|
+
* The current path. Pass your router's own (`usePathname()` in Next) -
|
|
9
|
+
* without it the nav reads `window.location` and patches `history` to hear
|
|
10
|
+
* about client-side navigations, which works but is guesswork the router
|
|
11
|
+
* never has to do. See `useActivePath`.
|
|
12
|
+
*/
|
|
13
|
+
activePath?: string;
|
|
14
|
+
/** See `ConnectLinkRenderer`. Defaults to a plain `<a>`. */
|
|
15
|
+
renderLink?: ConnectLinkRenderer;
|
|
16
|
+
/** Icon-only rail. Labels move into tooltips and children are hidden. */
|
|
17
|
+
collapsed?: boolean;
|
|
18
|
+
/** Called after any nav link is pressed - the mobile drawer closes itself with this. */
|
|
19
|
+
onNavigate?: () => void;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The sidebar's nav column on its own - sections, items, one level of
|
|
24
|
+
* children, and the active highlight.
|
|
25
|
+
*
|
|
26
|
+
* `ConnectAppShell` renders this inside its rail and its mobile drawer, and it
|
|
27
|
+
* is exported for a host that wants the shell's navigation without its
|
|
28
|
+
* chrome: the same items, the same active resolution, dropped into a layout
|
|
29
|
+
* you already have.
|
|
30
|
+
*/
|
|
31
|
+
export declare function ConnectSideNav({ nav, activePath, renderLink, collapsed, onNavigate, className, }: ConnectSideNavProps): import("react").JSX.Element;
|
|
@@ -5,11 +5,11 @@ export interface ConnectSubscribeDialogProps {
|
|
|
5
5
|
plan: Plan | null;
|
|
6
6
|
/** Which of subscribe / upgrade / downgrade this is - decides the headline and what the notice says about money. */
|
|
7
7
|
action: PlanAction;
|
|
8
|
-
/** The
|
|
8
|
+
/** The workspace's live subscription, for the "from" side of a plan change. */
|
|
9
9
|
current: SubscriptionResponse | null;
|
|
10
10
|
/** Coupon typed into the plan grid, echoed here so it is visible before the hand-off carries it. */
|
|
11
11
|
coupon?: string;
|
|
12
|
-
/** Whether this
|
|
12
|
+
/** Whether this workspace's `plan.trialDays` still applies is Connect's call, not this component's - see the notice below. */
|
|
13
13
|
onClose(): void;
|
|
14
14
|
onConfirm(): void;
|
|
15
15
|
}
|
|
@@ -26,7 +26,7 @@ export interface ConnectSubscribeDialogProps {
|
|
|
26
26
|
* The authoritative price is computed by Connect against the real cart:
|
|
27
27
|
* proration is priced against the actual cycle, a coupon is validated
|
|
28
28
|
* against the plan it is being applied to, trial eligibility depends on
|
|
29
|
-
* whether this
|
|
29
|
+
* whether this workspace has ever subscribed to this application before, and
|
|
30
30
|
* an accumulated credit is deducted. None of that is knowable from the
|
|
31
31
|
* partner's origin, so this component states the list price and says where
|
|
32
32
|
* the final figure comes from rather than quietly guessing at one.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The one elevation model every panel inside a Connect modal follows.
|
|
3
|
+
*
|
|
4
|
+
* This exists because "just use `bg-surface`" is wrong here, and wrong in a
|
|
5
|
+
* way that is invisible until you look at the tokens. `Modal.Dialog` paints
|
|
6
|
+
* itself `bg-overlay`, and in the shared theme (`theme.css`) `--overlay` and
|
|
7
|
+
* `--surface` sit at the *same lightness* in both schemes - 100% against 100%
|
|
8
|
+
* in light, 21% against 21% in dark. A `bg-surface` panel dropped on a modal
|
|
9
|
+
* therefore has no fill contrast at all; only its border separates it from
|
|
10
|
+
* the dialog behind it.
|
|
11
|
+
*
|
|
12
|
+
* That is how the account modal ended up looking half-finished: the identity
|
|
13
|
+
* card used `bg-surface-secondary` and read as a solid block, while the
|
|
14
|
+
* destination tiles and the session list used `bg-surface` and read as
|
|
15
|
+
* hairline outlines floating on nothing. Same nesting depth, two different
|
|
16
|
+
* physical materials, for no reason a user could infer.
|
|
17
|
+
*
|
|
18
|
+
* Three levels, and nesting one inside another always steps the fill:
|
|
19
|
+
*
|
|
20
|
+
* - **L0 - the dialog itself.** `bg-overlay`, owned by HeroUI. Not ours.
|
|
21
|
+
* - **L1 - a panel on the dialog.** `PANEL_FILL` + `border-border`. The
|
|
22
|
+
* identity card, each destination tile, the session list.
|
|
23
|
+
* - **L2 - a medallion inside a panel.** `bg-surface`, which is L0's value
|
|
24
|
+
* and therefore reads as *inset* against L1 rather than raised. Light:
|
|
25
|
+
* white on grey. Dark: near-black on charcoal. Both directions legible.
|
|
26
|
+
*
|
|
27
|
+
* The inversion at L2 is deliberate and is why this is written down. Reaching
|
|
28
|
+
* for a "lighter" fill one step down works in light mode and quietly fails in
|
|
29
|
+
* dark; stepping *back to the dialog's own value* is the trick that reads in
|
|
30
|
+
* both, because the contrast comes from the gap between L1 and L0 rather than
|
|
31
|
+
* from a direction of travel.
|
|
32
|
+
*/
|
|
33
|
+
export declare const PANEL_FILL = "bg-surface-secondary";
|
|
34
|
+
/**
|
|
35
|
+
* The icon well shared by destination tiles and session rows: a 40px box
|
|
36
|
+
* holding a 20px glyph.
|
|
37
|
+
*
|
|
38
|
+
* Half the well, which is the point. Both surfaces used to run a `size-4`
|
|
39
|
+
* (16px) icon inside a `size-9` (36px) well - a 44% fill that reads as an
|
|
40
|
+
* icon someone forgot to finish, and the specific thing that made the
|
|
41
|
+
* Profile/Billing/Connect tiles look under-drawn. They also disagreed on
|
|
42
|
+
* shape (a circle in the tiles, a rounded square in the session rows) for
|
|
43
|
+
* what is the same component role, so the two surfaces never looked related.
|
|
44
|
+
*
|
|
45
|
+
* Pair with `ICON` on the glyph inside. Session rows override the well to
|
|
46
|
+
* `size-9` for density but keep the same `ICON`, so glyph size stays constant
|
|
47
|
+
* across the whole modal even where the well does not.
|
|
48
|
+
*/
|
|
49
|
+
export declare const MEDALLION = "size-10";
|
|
50
|
+
/** The glyph inside a `MEDALLION`. Constant across every well in the modal - see `MEDALLION`. */
|
|
51
|
+
export declare const ICON = "size-5";
|
|
@@ -11,7 +11,7 @@ export interface ConnectUsageMeterProps {
|
|
|
11
11
|
*
|
|
12
12
|
* Reads the balance Connect actually debits, so the number here and the number
|
|
13
13
|
* `consumeAddon` enforces cannot disagree. Before the `addons:read` endpoint
|
|
14
|
-
* existed this component was impossible to write honestly:
|
|
14
|
+
* existed this component was impossible to write honestly: an application could
|
|
15
15
|
* spend an allowance down on every request and the only thing the API exposed
|
|
16
16
|
* was the list of add-on *ids* on the subscription.
|
|
17
17
|
*
|
|
@@ -26,7 +26,7 @@ export interface ConnectUserMenuProps {
|
|
|
26
26
|
* in place, which is why it sits alone in the footer rather than as a fourth
|
|
27
27
|
* item in the same list as three navigations.
|
|
28
28
|
*
|
|
29
|
-
* The session list is account-wide, not scoped to this
|
|
29
|
+
* The session list is account-wide, not scoped to this application - see
|
|
30
30
|
* `ConnectUserSession`'s doc comment in `types.ts`. Appearance only renders
|
|
31
31
|
* when both `theme` and `onThemeChange` are supplied.
|
|
32
32
|
*
|
|
@@ -55,7 +55,7 @@ export declare function ConnectManageSubscriptionButton({ className }: Readonly<
|
|
|
55
55
|
* Invoices and payment history, on Connect.
|
|
56
56
|
*
|
|
57
57
|
* A deep link rather than a component that lists them, and that is not a
|
|
58
|
-
* placeholder: nothing in `/api/v1/
|
|
58
|
+
* placeholder: nothing in `/api/v1/application/*` exposes invoices, so an SDK-side
|
|
59
59
|
* list would have nothing to read. It is also the right answer regardless -
|
|
60
60
|
* a GST tax invoice is a legal document with a fixed format, downloadable and
|
|
61
61
|
* emailed from one place, and a partner-rendered copy of one would be a second
|
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Styling is HeroUI v3 semantic tokens only (`accent`, `muted`, `surface`,
|
|
9
9
|
* `separator`, ...), never a hardcoded colour - so these components inherit
|
|
10
|
-
* whatever theme the host
|
|
10
|
+
* whatever theme the host application platform already configured, and one theme
|
|
11
11
|
* change lands identically in all of them.
|
|
12
12
|
*/
|
|
13
|
-
export { ConnectProvider, useConnect, useConnectUser, useConnectEntitlements, useConnectPlans, useConnectApps, useConnectAddonUsage, useConnectSessions, useConnectResource, CONNECT_APP_URL, } from "./provider.js";
|
|
13
|
+
export { ConnectProvider, useConnect, useConnectUser, useConnectEntitlements, useConnectPlans, useConnectApps, useConnectAddonUsage, useConnectSessions, useConnectIntegrations, useConnectResource, CONNECT_APP_URL, } from "./provider.js";
|
|
14
14
|
export type { ConnectProviderProps, ConnectContextValue, ConnectSession } from "./provider.js";
|
|
15
15
|
export { blockingBlockers, normalizePlanFeatures } from "../helpers.js";
|
|
16
16
|
export type { WirePlanFeature } from "../helpers.js";
|
|
@@ -25,8 +25,17 @@ export { ConnectUserMenu, ConnectManageSubscriptionButton, ConnectInvoicesButton
|
|
|
25
25
|
export { ConnectAccountSessions } from "./components/account-sessions.js";
|
|
26
26
|
export type { ConnectAccountSessionsProps } from "./components/account-sessions.js";
|
|
27
27
|
export type { ConnectUserMenuProps } from "./components/user-menu.js";
|
|
28
|
+
export { ConnectAppShell } from "./components/app-shell.js";
|
|
29
|
+
export type { ConnectAppShellProps } from "./components/app-shell.js";
|
|
30
|
+
export { ConnectSideNav } from "./components/side-nav.js";
|
|
31
|
+
export type { ConnectSideNavProps } from "./components/side-nav.js";
|
|
32
|
+
export { useActivePath } from "./use-active-path.js";
|
|
33
|
+
export { normalizeNav, flattenNav, normalizePath, resolveActivePath, isNavItemActive, gateExemptPaths, } from "./components/nav.js";
|
|
34
|
+
export type { ConnectNav, ConnectNavItem, ConnectNavSection, ConnectNavLinkProps, ConnectLinkRenderer, } from "./components/nav.js";
|
|
28
35
|
export { ConnectAppsGrid } from "./components/apps-grid.js";
|
|
29
36
|
export type { ConnectAppsGridProps } from "./components/apps-grid.js";
|
|
37
|
+
export { ConnectIntegrationsModal } from "./components/integrations-modal.js";
|
|
38
|
+
export type { ConnectIntegrationsModalProps } from "./components/integrations-modal.js";
|
|
30
39
|
export { ConnectPlans } from "./components/plans.js";
|
|
31
40
|
export type { ConnectPlansProps } from "./components/plans.js";
|
|
32
41
|
export { ConnectSubscribeDialog } from "./components/subscribe-dialog.js";
|
|
@@ -35,6 +44,8 @@ export { ConnectSubscriptionGate, ConnectNoSubscriptionCard, ConnectSubscription
|
|
|
35
44
|
export type { ConnectSubscriptionGateProps, ConnectNoSubscriptionCardProps, ConnectSubscriptionCardProps, ConnectTrialBannerProps, ConnectSubscriptionState, } from "./components/subscription.js";
|
|
36
45
|
export { ConnectReadinessBanner, ConnectReadinessGate } from "./components/readiness.js";
|
|
37
46
|
export type { ConnectReadinessBannerProps, ConnectReadinessGateProps } from "./components/readiness.js";
|
|
47
|
+
export { ConnectAccessGate, useConnectAccessGate } from "./components/access-gate.js";
|
|
48
|
+
export type { ConnectAccessGateProps, ConnectAccessGateState, ConnectAccessGateResult, } from "./components/access-gate.js";
|
|
38
49
|
export { ConnectFeatureGate, useConnectFeature } from "./components/feature-gate.js";
|
|
39
50
|
export type { ConnectFeatureGateProps } from "./components/feature-gate.js";
|
|
40
51
|
export { ConnectUsageMeter } from "./components/usage-meter.js";
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* The Connect mark - concentric rings on a solid accent badge.
|
|
3
3
|
*
|
|
4
4
|
* Painted from `--accent` / `--accent-foreground`, the same HeroUI tokens the
|
|
5
|
-
* host app themes, so the badge tracks whatever palette
|
|
5
|
+
* host app themes, so the badge tracks whatever palette an application platform has
|
|
6
6
|
* configured rather than carrying a hardcoded CosmoOps green into someone
|
|
7
7
|
* else's brand.
|
|
8
8
|
*/
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { AddonUsageResponse, ConnectUser,
|
|
2
|
+
import type { AddonUsageResponse, ConnectUser, IntegrationsListResponse, WorkspaceApp, PlansResponse, ReadinessResponse, ApplicationRole, SessionsListResponse, SessionSubscription, SubscriptionResponse } from "../types.js";
|
|
3
3
|
export declare const CONNECT_APP_URL = "https://connect.cosmoops.com";
|
|
4
4
|
export interface ConnectSession {
|
|
5
5
|
user: ConnectUser | null;
|
|
6
6
|
subscription: SessionSubscription | null;
|
|
7
|
-
|
|
7
|
+
applicationRole: ApplicationRole | null;
|
|
8
8
|
}
|
|
9
9
|
export interface ConnectContextValue {
|
|
10
10
|
/**
|
|
@@ -61,7 +61,7 @@ export interface ConnectContextValue {
|
|
|
61
61
|
}
|
|
62
62
|
export interface ConnectProviderProps {
|
|
63
63
|
/**
|
|
64
|
-
* This
|
|
64
|
+
* This application's public `client_id`, from its Integration tab in Connect.
|
|
65
65
|
*
|
|
66
66
|
* Not needed for the default sign-in flow: `signIn()` with no `redirectUri`
|
|
67
67
|
* bounces the browser to your own `/signin` route, which already knows
|
|
@@ -87,6 +87,27 @@ export interface ConnectProviderProps {
|
|
|
87
87
|
* child effects.
|
|
88
88
|
*/
|
|
89
89
|
fetch?: (input: string, init?: RequestInit) => Promise<Response>;
|
|
90
|
+
/**
|
|
91
|
+
* Sign in a returning visitor automatically, with no click.
|
|
92
|
+
*
|
|
93
|
+
* When the first `/session` read comes back signed out, the browser is sent
|
|
94
|
+
* on one round trip to Connect with OIDC `prompt=none`. If they still have
|
|
95
|
+
* a Connect session and have authorised this app before, they come straight
|
|
96
|
+
* back signed in and never see a screen. If not, they come straight back
|
|
97
|
+
* signed out, with no error and nothing rendered differently - your normal
|
|
98
|
+
* signed-out UI just appears a beat later.
|
|
99
|
+
*
|
|
100
|
+
* **Off by default, and it is a real trade, not just caution.** It costs a
|
|
101
|
+
* full-page redirect on the first load of every signed-out visit - a brief
|
|
102
|
+
* flash on a marketing page, invisible on an app shell - so it belongs on
|
|
103
|
+
* apps whose visitors are overwhelmingly already Connect users. It is
|
|
104
|
+
* attempted at most once per tab (a `sessionStorage` marker), so a visitor
|
|
105
|
+
* who genuinely has no session does not bounce on every navigation.
|
|
106
|
+
*
|
|
107
|
+
* Requires `createConnectHandler` mounted at `basePath`; the redirect goes
|
|
108
|
+
* to your own `/signin`, which mints the `state` server-side.
|
|
109
|
+
*/
|
|
110
|
+
silentSignIn?: boolean;
|
|
90
111
|
children: ReactNode;
|
|
91
112
|
}
|
|
92
113
|
/**
|
|
@@ -103,7 +124,7 @@ export interface ConnectProviderProps {
|
|
|
103
124
|
* </ConnectProvider>
|
|
104
125
|
* ```
|
|
105
126
|
*/
|
|
106
|
-
export declare function ConnectProvider({ clientId, basePath, redirectUri, appUrl, fetch: fetchImpl, children, }: ConnectProviderProps): import("react").JSX.Element;
|
|
127
|
+
export declare function ConnectProvider({ clientId, basePath, redirectUri, appUrl, fetch: fetchImpl, silentSignIn, children, }: ConnectProviderProps): import("react").JSX.Element;
|
|
107
128
|
export declare function useConnect(): ConnectContextValue;
|
|
108
129
|
/** The signed-in user, or `null`. Sugar over `useConnect().session`. */
|
|
109
130
|
export declare function useConnectUser(): ConnectUser | null;
|
|
@@ -127,7 +148,7 @@ export declare function useConnectEntitlements(): {
|
|
|
127
148
|
/**
|
|
128
149
|
* What is left of every consumable add-on on this workspace's subscription.
|
|
129
150
|
*
|
|
130
|
-
* The read half of `client.billing.consumeAddon` -
|
|
151
|
+
* The read half of `client.billing.consumeAddon` - an application that meters its
|
|
131
152
|
* own end users had no way to show them what remained until this existed.
|
|
132
153
|
* Empty `addons` means there is nothing to meter, which is not an error.
|
|
133
154
|
*/
|
|
@@ -144,7 +165,7 @@ export declare function useConnectAddonUsage(): {
|
|
|
144
165
|
*/
|
|
145
166
|
refetch(): void;
|
|
146
167
|
};
|
|
147
|
-
/** This
|
|
168
|
+
/** This application's plan catalog. */
|
|
148
169
|
export declare function useConnectPlans(): {
|
|
149
170
|
data: PlansResponse | null;
|
|
150
171
|
isLoading: boolean;
|
|
@@ -158,10 +179,10 @@ export declare function useConnectPlans(): {
|
|
|
158
179
|
*/
|
|
159
180
|
refetch(): void;
|
|
160
181
|
};
|
|
161
|
-
/** The apps this
|
|
182
|
+
/** The apps this workspace can open. */
|
|
162
183
|
export declare function useConnectApps(): {
|
|
163
184
|
data: {
|
|
164
|
-
apps:
|
|
185
|
+
apps: WorkspaceApp[];
|
|
165
186
|
} | null;
|
|
166
187
|
isLoading: boolean;
|
|
167
188
|
error: string | null;
|
|
@@ -174,9 +195,23 @@ export declare function useConnectApps(): {
|
|
|
174
195
|
*/
|
|
175
196
|
refetch(): void;
|
|
176
197
|
};
|
|
198
|
+
/** Enabled Composio-hosted toolkits and this workspace's connection status for each. */
|
|
199
|
+
export declare function useConnectIntegrations(): {
|
|
200
|
+
data: IntegrationsListResponse | null;
|
|
201
|
+
isLoading: boolean;
|
|
202
|
+
error: string | null;
|
|
203
|
+
/**
|
|
204
|
+
* Forces a fresh read - the provider's cache clears the mutated path's
|
|
205
|
+
* entry on a successful `mutateResource` call, but nothing re-triggers
|
|
206
|
+
* this hook's own effect on its own (none of its dependencies change from
|
|
207
|
+
* a cache write nobody here observes). Call this right after a
|
|
208
|
+
* `mutateResource` you made against the same `path` completes.
|
|
209
|
+
*/
|
|
210
|
+
refetch(): void;
|
|
211
|
+
};
|
|
177
212
|
/**
|
|
178
213
|
* This Connect account's own login sessions - account-wide, not scoped to
|
|
179
|
-
* this
|
|
214
|
+
* this application, see `SessionsListResponse`'s doc comment. The component
|
|
180
215
|
* that calls this is also the one that must own any revoke actions and call
|
|
181
216
|
* the returned `refetch()` afterward - see `mutateResource`'s doc comment
|
|
182
217
|
* for why nothing does that automatically.
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The current path, from `activePath` when given and from the browser
|
|
3
|
+
* otherwise.
|
|
4
|
+
*
|
|
5
|
+
* Exported because a host building its own shell out of `ConnectSideNav`
|
|
6
|
+
* needs the same fallback the shell uses.
|
|
7
|
+
*/
|
|
8
|
+
export declare function useActivePath(activePath?: string): string;
|
|
@@ -57,7 +57,7 @@ export declare function useConnectCheckout(): ConnectCheckoutState & {
|
|
|
57
57
|
export interface CheckoutUrlOptions {
|
|
58
58
|
/** Connect's origin, from `useConnect().appUrl`. */
|
|
59
59
|
appUrl: string;
|
|
60
|
-
|
|
60
|
+
applicationId: string;
|
|
61
61
|
planId: string;
|
|
62
62
|
/**
|
|
63
63
|
* The live subscription's id, when there is one. Present means "change the
|
|
@@ -85,9 +85,9 @@ export declare function buildCancelUrl({ appUrl, subscriptionId }: {
|
|
|
85
85
|
* The Connect URL that completes a subscribe or a plan change.
|
|
86
86
|
*
|
|
87
87
|
* Both land on a modal Connect renders over the relevant page (an intercepted
|
|
88
|
-
* parallel route - `app/@modal/(.)
|
|
88
|
+
* parallel route - `app/@modal/(.)applications/...` and
|
|
89
89
|
* `app/@modal/(.)billing/...`), so the customer arrives already looking at the
|
|
90
90
|
* confirmation for the plan they picked here, not at a catalogue they have to
|
|
91
91
|
* find it in again.
|
|
92
92
|
*/
|
|
93
|
-
export declare function buildCheckoutUrl({ appUrl,
|
|
93
|
+
export declare function buildCheckoutUrl({ appUrl, applicationId, planId, subscriptionId, coupon, }: CheckoutUrlOptions): string;
|
package/dist/types/errors.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Every failure the Connect
|
|
2
|
+
* Every failure the Connect application API can report, as one class.
|
|
3
3
|
*
|
|
4
4
|
* The API speaks two error dialects and this collapses them: the
|
|
5
|
-
* `/api/v1/
|
|
5
|
+
* `/api/v1/application/*` endpoints use `{ error: { code, message } }`, while the
|
|
6
6
|
* three `/sso/*` ones use OAuth2's `{ error, error_description }` (RFC 6749
|
|
7
7
|
* §5.2). Both land here with `code` populated, so integrating code branches on
|
|
8
8
|
* one field either way.
|
|
@@ -40,7 +40,7 @@ export declare class ConnectError extends Error {
|
|
|
40
40
|
* Whether the user's Connect sign-in is over and they need to go back
|
|
41
41
|
* through `identity.authorizeUrl()`. Collapses every session-side failure,
|
|
42
42
|
* matching how the API reports them - unknown, expired, revoked, or issued
|
|
43
|
-
* to a different
|
|
43
|
+
* to a different application all arrive as one `invalid_token`.
|
|
44
44
|
*/
|
|
45
45
|
get isSessionExpired(): boolean;
|
|
46
46
|
/**
|
|
@@ -52,7 +52,7 @@ export declare class ConnectError extends Error {
|
|
|
52
52
|
* guessing keys. These two are the exception: reaching them required
|
|
53
53
|
* presenting a key whose hash matched, so you already hold it, and what you
|
|
54
54
|
* need to know is that no retry and no scope change will fix this - the key
|
|
55
|
-
* has to be reissued from the
|
|
55
|
+
* has to be reissued from the application's Integration tab.
|
|
56
56
|
*
|
|
57
57
|
* Worth alerting on. It is the one failure that will not resolve itself and
|
|
58
58
|
* takes down every call your integration makes.
|
package/dist/types/helpers.d.ts
CHANGED
|
@@ -21,7 +21,7 @@ export type WirePlanFeature = string | PlanFeature;
|
|
|
21
21
|
* Coerces either wire shape into `PlanFeature[]`.
|
|
22
22
|
*
|
|
23
23
|
* A bare key becomes `{ key, name: key, description: "" }` - the same
|
|
24
|
-
* fallback the server applies for a plan older than its
|
|
24
|
+
* fallback the server applies for a plan older than its application's feature
|
|
25
25
|
* catalog, so an un-upgraded Connect renders exactly what it always did
|
|
26
26
|
* rather than a column of blanks.
|
|
27
27
|
*
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `@cosmoops/connect-sdk` - the official client for the CosmoOps Connect
|
|
3
|
-
* **
|
|
3
|
+
* **application-partner API** (`/api/v1/application/*`).
|
|
4
4
|
*
|
|
5
5
|
* This root entry is the isomorphic surface: wire types, the error class, and
|
|
6
6
|
* pure helpers. It pulls in neither Node-only code nor React, so it is safe to
|
|
@@ -81,6 +81,9 @@ export { handle as GET, handle as POST };
|
|
|
81
81
|
* if (!session) redirect("/api/connect/signin?next=/dashboard");
|
|
82
82
|
* ```
|
|
83
83
|
*
|
|
84
|
+
* `requireConnectSession()` below is that exact check in one call, for the
|
|
85
|
+
* common case of "redirect if signed out."
|
|
86
|
+
*
|
|
84
87
|
* Pass a `Request` to use it somewhere `next/headers` does not exist - a
|
|
85
88
|
* framework-agnostic handler, a test, a custom server. Both forms take the
|
|
86
89
|
* same path afterwards; the argument is only how the cookie is found.
|
|
@@ -92,11 +95,48 @@ export { handle as GET, handle as POST };
|
|
|
92
95
|
*
|
|
93
96
|
* Returns `null` for every failure - an expired session and a missing one both
|
|
94
97
|
* mean "not signed in", and a page guard should not need a try/catch.
|
|
98
|
+
*
|
|
99
|
+
* **Memoized per request for the plain, zero-argument call** - the shape
|
|
100
|
+
* every page, layout and Server Action actually uses - via React's `cache()`.
|
|
101
|
+
* Passing an explicit `request`, `client` or `session` bypasses the cache
|
|
102
|
+
* and always makes a live call: those are for tests and non-ambient
|
|
103
|
+
* callers, where a fresh read every time is the point, not an oversight.
|
|
95
104
|
*/
|
|
96
105
|
export declare function getConnectSession(request?: Request, options?: {
|
|
97
106
|
client?: ConnectClient;
|
|
98
107
|
session?: ConnectSessionStore;
|
|
99
108
|
}): Promise<UserResponse | null>;
|
|
109
|
+
/**
|
|
110
|
+
* `getConnectSession()`, minus the boilerplate of checking it and redirecting
|
|
111
|
+
* yourself:
|
|
112
|
+
*
|
|
113
|
+
* ```tsx
|
|
114
|
+
* // app/dashboard/page.tsx
|
|
115
|
+
* const session = await requireConnectSession();
|
|
116
|
+
* ```
|
|
117
|
+
*
|
|
118
|
+
* Redirects to `/signin` under the same `basePath` as `getConnectSession`'s
|
|
119
|
+
* default (`/api/connect`) when signed out - pass `signInPath` if you mounted
|
|
120
|
+
* the bridge somewhere else, and `next` to send the visitor back to where
|
|
121
|
+
* they were once they're signed in. Only sensible in a Server Component,
|
|
122
|
+
* Route Handler or Server Action, the same three places `redirect()` from
|
|
123
|
+
* `next/navigation` itself works.
|
|
124
|
+
*
|
|
125
|
+
* A thin wrapper, not a framework of its own - reach for `getConnectSession`
|
|
126
|
+
* plus your own check when "not signed in" isn't "redirect to sign-in"
|
|
127
|
+
* (an API route returning 401, say). Role and entitlement checks stay
|
|
128
|
+
* outside this function on purpose: `session.applicationRole.granted` and
|
|
129
|
+
* `connect.entitlements.*` are one line each on top of the session this
|
|
130
|
+
* already gives you, and where that line redirects (a plans page, a
|
|
131
|
+
* "forbidden" screen) is a decision only your app can make - see
|
|
132
|
+
* "Authentication & authorization" for the pattern.
|
|
133
|
+
*/
|
|
134
|
+
export declare function requireConnectSession(request?: Request, options?: {
|
|
135
|
+
client?: ConnectClient;
|
|
136
|
+
session?: ConnectSessionStore;
|
|
137
|
+
signInPath?: string;
|
|
138
|
+
next?: string;
|
|
139
|
+
}): Promise<UserResponse>;
|
|
100
140
|
export { createConnectHandler } from "../server/handler.js";
|
|
101
141
|
export type { ConnectSessionStore } from "../server/handler.js";
|
|
102
142
|
export { ConnectClient } from "../server/client.js";
|