@cosmoops/connect-sdk 0.9.0 → 0.15.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.
Files changed (139) hide show
  1. package/CHANGELOG.md +497 -0
  2. package/README.md +111 -41
  3. package/dist/cjs/cli/doctor.js +3 -3
  4. package/dist/cjs/cli/init.js +3 -3
  5. package/dist/cjs/client/components/access-gate.js +20 -1
  6. package/dist/cjs/client/components/app-shell.js +75 -41
  7. package/dist/cjs/client/components/apps-grid.js +3 -2
  8. package/dist/cjs/client/components/ask-ai.js +20 -1
  9. package/dist/cjs/client/components/confirm-dialog.js +40 -0
  10. package/dist/cjs/client/components/cursor-pagination.js +22 -0
  11. package/dist/cjs/client/components/filter-tabs.js +24 -0
  12. package/dist/cjs/client/components/grievance-notice.js +30 -0
  13. package/dist/cjs/client/components/link-button.js +17 -10
  14. package/dist/cjs/client/components/logo.js +4 -3
  15. package/dist/cjs/client/components/nav.js +41 -0
  16. package/dist/cjs/client/components/plan-pricing.js +27 -0
  17. package/dist/cjs/client/components/plans.js +1 -1
  18. package/dist/cjs/client/components/platform-gate.js +48 -0
  19. package/dist/cjs/client/components/shell-context.js +149 -0
  20. package/dist/cjs/client/components/side-nav.js +49 -23
  21. package/dist/cjs/client/components/sidebar.js +127 -0
  22. package/dist/cjs/client/components/subscribe-dialog.js +2 -2
  23. package/dist/cjs/client/components/subscription.js +1 -1
  24. package/dist/cjs/client/components/user-menu.js +96 -37
  25. package/dist/cjs/client/components/workspace-switcher.js +100 -0
  26. package/dist/cjs/client/index.js +69 -2
  27. package/dist/cjs/client/provider.js +57 -2
  28. package/dist/cjs/client/use-checkout.js +9 -5
  29. package/dist/cjs/errors.js +1 -1
  30. package/dist/cjs/index.js +11 -1
  31. package/dist/cjs/next/index.js +2 -2
  32. package/dist/cjs/server/client.js +25 -2
  33. package/dist/cjs/server/handler.js +196 -18
  34. package/dist/cjs/server/http.js +6 -2
  35. package/dist/cjs/server/resources/acting-as.js +16 -0
  36. package/dist/cjs/server/resources/ai.js +15 -2
  37. package/dist/cjs/server/resources/data.js +374 -0
  38. package/dist/cjs/server/resources/identity.js +7 -3
  39. package/dist/cjs/server/resources/kv.js +84 -0
  40. package/dist/cjs/server/resources/platform.js +43 -0
  41. package/dist/cjs/server/resources/sessions.js +1 -1
  42. package/dist/cjs/server/resources/workspaces.js +74 -0
  43. package/dist/cjs/store.js +152 -0
  44. package/dist/cjs/ui/empty-state.js +28 -0
  45. package/dist/cjs/ui/index.js +44 -0
  46. package/dist/cjs/ui/page-header.js +27 -0
  47. package/dist/cjs/ui/page-shell.js +44 -0
  48. package/dist/cjs/ui/section.js +20 -0
  49. package/dist/cjs/ui/setting-row.js +14 -0
  50. package/dist/cjs/ui/status-chip.js +17 -0
  51. package/dist/esm/cli/doctor.js +3 -3
  52. package/dist/esm/cli/init.js +3 -3
  53. package/dist/esm/client/components/access-gate.js +20 -1
  54. package/dist/esm/client/components/app-shell.js +81 -47
  55. package/dist/esm/client/components/apps-grid.js +3 -2
  56. package/dist/esm/client/components/ask-ai.js +20 -1
  57. package/dist/esm/client/components/confirm-dialog.js +37 -0
  58. package/dist/esm/client/components/cursor-pagination.js +19 -0
  59. package/dist/esm/client/components/filter-tabs.js +21 -0
  60. package/dist/esm/client/components/grievance-notice.js +27 -0
  61. package/dist/esm/client/components/link-button.js +17 -10
  62. package/dist/esm/client/components/logo.js +4 -3
  63. package/dist/esm/client/components/nav.js +40 -0
  64. package/dist/esm/client/components/plan-pricing.js +25 -0
  65. package/dist/esm/client/components/plans.js +2 -2
  66. package/dist/esm/client/components/platform-gate.js +45 -0
  67. package/dist/esm/client/components/shell-context.js +141 -0
  68. package/dist/esm/client/components/side-nav.js +48 -21
  69. package/dist/esm/client/components/sidebar.js +120 -0
  70. package/dist/esm/client/components/subscribe-dialog.js +3 -3
  71. package/dist/esm/client/components/subscription.js +2 -2
  72. package/dist/esm/client/components/user-menu.js +95 -38
  73. package/dist/esm/client/components/workspace-switcher.js +97 -0
  74. package/dist/esm/client/index.js +46 -4
  75. package/dist/esm/client/provider.js +53 -2
  76. package/dist/esm/client/use-checkout.js +9 -5
  77. package/dist/esm/errors.js +1 -1
  78. package/dist/esm/index.js +1 -0
  79. package/dist/esm/next/index.js +2 -2
  80. package/dist/esm/server/client.js +25 -2
  81. package/dist/esm/server/handler.js +196 -18
  82. package/dist/esm/server/http.js +6 -2
  83. package/dist/esm/server/resources/acting-as.js +13 -0
  84. package/dist/esm/server/resources/ai.js +15 -2
  85. package/dist/esm/server/resources/data.js +369 -0
  86. package/dist/esm/server/resources/identity.js +7 -3
  87. package/dist/esm/server/resources/kv.js +80 -0
  88. package/dist/esm/server/resources/platform.js +39 -0
  89. package/dist/esm/server/resources/sessions.js +1 -1
  90. package/dist/esm/server/resources/workspaces.js +70 -0
  91. package/dist/esm/store.js +141 -0
  92. package/dist/esm/ui/empty-state.js +25 -0
  93. package/dist/esm/ui/index.js +34 -0
  94. package/dist/esm/ui/page-header.js +24 -0
  95. package/dist/esm/ui/page-shell.js +41 -0
  96. package/dist/esm/ui/section.js +17 -0
  97. package/dist/esm/ui/setting-row.js +11 -0
  98. package/dist/esm/ui/status-chip.js +14 -0
  99. package/dist/types/client/components/app-shell.d.ts +65 -27
  100. package/dist/types/client/components/apps-grid.d.ts +11 -2
  101. package/dist/types/client/components/confirm-dialog.d.ts +34 -0
  102. package/dist/types/client/components/cursor-pagination.d.ts +27 -0
  103. package/dist/types/client/components/filter-tabs.d.ts +26 -0
  104. package/dist/types/client/components/grievance-notice.d.ts +31 -0
  105. package/dist/types/client/components/link-button.d.ts +32 -9
  106. package/dist/types/client/components/logo.d.ts +18 -2
  107. package/dist/types/client/components/nav.d.ts +24 -0
  108. package/dist/types/client/components/plan-pricing.d.ts +10 -0
  109. package/dist/types/client/components/platform-gate.d.ts +53 -0
  110. package/dist/types/client/components/shell-context.d.ts +116 -0
  111. package/dist/types/client/components/side-nav.d.ts +27 -13
  112. package/dist/types/client/components/sidebar.d.ts +95 -0
  113. package/dist/types/client/components/user-menu.d.ts +68 -22
  114. package/dist/types/client/components/workspace-switcher.d.ts +49 -0
  115. package/dist/types/client/index.d.ts +27 -5
  116. package/dist/types/client/provider.d.ts +109 -6
  117. package/dist/types/client/use-checkout.d.ts +8 -4
  118. package/dist/types/errors.d.ts +1 -1
  119. package/dist/types/index.d.ts +2 -0
  120. package/dist/types/next/index.d.ts +1 -1
  121. package/dist/types/server/client.d.ts +25 -2
  122. package/dist/types/server/http.d.ts +8 -2
  123. package/dist/types/server/index.d.ts +4 -0
  124. package/dist/types/server/resources/acting-as.d.ts +11 -0
  125. package/dist/types/server/resources/ai.d.ts +9 -1
  126. package/dist/types/server/resources/data.d.ts +258 -0
  127. package/dist/types/server/resources/kv.d.ts +63 -0
  128. package/dist/types/server/resources/platform.d.ts +32 -0
  129. package/dist/types/server/resources/workspaces.d.ts +55 -0
  130. package/dist/types/store.d.ts +96 -0
  131. package/dist/types/types.d.ts +319 -15
  132. package/dist/types/ui/empty-state.d.ts +34 -0
  133. package/dist/types/ui/index.d.ts +40 -0
  134. package/dist/types/ui/page-header.d.ts +34 -0
  135. package/dist/types/ui/page-shell.d.ts +39 -0
  136. package/dist/types/ui/section.d.ts +26 -0
  137. package/dist/types/ui/setting-row.d.ts +18 -0
  138. package/dist/types/ui/status-chip.d.ts +36 -0
  139. package/package.json +6 -2
@@ -0,0 +1,40 @@
1
+ /**
2
+ * Page-composition primitives - the layer between HeroUI and your features.
3
+ *
4
+ * Deliberately **not** `"use client"`. Everything here is presentational, with
5
+ * no hooks and no state, so it renders in a Server Component and stays out of
6
+ * the browser bundle. That is the whole reason this is a separate entry point
7
+ * from `@cosmoops/connect-sdk/client`: that module's barrel carries a
8
+ * `"use client"` directive, so re-exporting a `<Card>` wrapper through it
9
+ * would turn every page shell in your app into a client boundary for no gain.
10
+ *
11
+ * The interactive counterparts - a confirm dialog, cursor pagination, filter
12
+ * tabs - hold state and live in `/client` alongside the rest of the browser
13
+ * half.
14
+ *
15
+ * ```tsx
16
+ * import { ConnectPageShell, ConnectSection } from "@cosmoops/connect-sdk/ui";
17
+ *
18
+ * export default function ContactsPage() {
19
+ * return (
20
+ * <ConnectPageShell title="Contacts" description="Everyone you do business with.">
21
+ * <ConnectPageShell.Async fallback={<TableSkeleton />}>
22
+ * <ContactsTable />
23
+ * </ConnectPageShell.Async>
24
+ * </ConnectPageShell>
25
+ * );
26
+ * }
27
+ * ```
28
+ */
29
+ export { ConnectPageShell } from "./page-shell.js";
30
+ export type { ConnectPageShellProps } from "./page-shell.js";
31
+ export { ConnectPageHeader } from "./page-header.js";
32
+ export type { ConnectPageHeaderProps } from "./page-header.js";
33
+ export { ConnectSection } from "./section.js";
34
+ export type { ConnectSectionProps } from "./section.js";
35
+ export { ConnectEmptyState } from "./empty-state.js";
36
+ export type { ConnectEmptyStateProps } from "./empty-state.js";
37
+ export { ConnectSettingRow } from "./setting-row.js";
38
+ export type { ConnectSettingRowProps } from "./setting-row.js";
39
+ export { ConnectStatusChip } from "./status-chip.js";
40
+ export type { ConnectStatusTone, ConnectStatusPresentation } from "./status-chip.js";
@@ -0,0 +1,34 @@
1
+ import type { ReactNode } from "react";
2
+ export interface ConnectPageHeaderProps {
3
+ title: ReactNode;
4
+ description?: ReactNode;
5
+ /**
6
+ * Rendered opposite the title. Keep it to one control - a page has one
7
+ * primary action, and a second here has nothing to align against.
8
+ */
9
+ action?: ReactNode;
10
+ /** Set `false` when the description carries a link that must stay readable on a phone. */
11
+ clamp?: boolean;
12
+ className?: string;
13
+ }
14
+ /**
15
+ * The title / description / action block a page opens with.
16
+ *
17
+ * The structure is the point, not the styling. The action is a peer of the
18
+ * **title**, not of the block, so nothing below the first line can move it -
19
+ * the common hand-rolled shape puts the action after the description, which
20
+ * makes the vertical position of a page's primary control a function of how
21
+ * long someone wrote the paragraph above it. On a phone that pushes it most of
22
+ * a thumb's reach down the screen.
23
+ *
24
+ * Mobile-first, and the two axes are separate decisions: the title row is a
25
+ * `justify-between` at every width (title left, action right, where a thumb
26
+ * expects it), while the description is clamped to two lines on a phone and
27
+ * released from `sm` up.
28
+ *
29
+ * An `h2`, because the document's `h1` is the application itself.
30
+ *
31
+ * No hooks and no state, so this renders from a Server Component - which is
32
+ * why it lives in `@cosmoops/connect-sdk/ui` rather than `/client`.
33
+ */
34
+ export declare function ConnectPageHeader({ title, description, action, clamp, className, }: Readonly<ConnectPageHeaderProps>): import("react").JSX.Element;
@@ -0,0 +1,39 @@
1
+ import { type ReactNode } from "react";
2
+ import { ConnectPageHeader } from "./page-header.js";
3
+ export interface ConnectPageShellProps {
4
+ title?: ReactNode;
5
+ description?: ReactNode;
6
+ action?: ReactNode;
7
+ clamp?: boolean;
8
+ /** Rendered above the header - a breadcrumb trail, a back link, a banner. */
9
+ above?: ReactNode;
10
+ children?: ReactNode;
11
+ }
12
+ /**
13
+ * The frame a page opens with: its vertical rhythm, its header, and the
14
+ * suspended regions beneath.
15
+ *
16
+ * **The header is a prop, so it renders in the static shell** - above and
17
+ * outside every `<Suspense>` boundary. That is the one bug this component
18
+ * exists to make unrepresentable: rendering the header inside the async child
19
+ * makes a page's own title wait on a data read, and under Next's partial
20
+ * prefetching the route's shared App Shell loses it as well. There is no
21
+ * arrangement of `children` that reaches the header slot.
22
+ *
23
+ * A detail route is the honest exception, and it has its own door:
24
+ * `ConnectPageShell.Header` renders the identical header from inside an async
25
+ * child, for a page whose title is data it does not have yet. Pair it with a
26
+ * skeleton header in the fallback. The rule is that a *static* title must
27
+ * never be made to wait, not that every title can be static.
28
+ *
29
+ * `space-y-5` is the page gap, owned here so it has exactly one definition.
30
+ */
31
+ export declare function ConnectPageShell({ title, description, action, clamp, above, children, }: Readonly<ConnectPageShellProps>): import("react").JSX.Element;
32
+ export declare namespace ConnectPageShell {
33
+ var Header: typeof ConnectPageHeader;
34
+ var Async: ({ fallback, children, }: Readonly<{
35
+ /** Omit where the region has nothing to draw while it waits. */
36
+ fallback?: ReactNode;
37
+ children: ReactNode;
38
+ }>) => import("react").JSX.Element;
39
+ }
@@ -0,0 +1,26 @@
1
+ import type { ReactNode } from "react";
2
+ export interface ConnectSectionProps {
3
+ title: ReactNode;
4
+ /** What the block is for. Omit when the title says everything. */
5
+ description?: ReactNode;
6
+ /** Rendered opposite the title. One control - a section has one action. */
7
+ action?: ReactNode;
8
+ /** Set to reference the heading from an `aria-labelledby` in the body. */
9
+ titleId?: string;
10
+ className?: string;
11
+ bodyClassName?: string;
12
+ children?: ReactNode;
13
+ }
14
+ /**
15
+ * One titled block inside a page: a card, its heading, what it is for, and the
16
+ * one control that acts on it.
17
+ *
18
+ * The heading is an `h3` - `ConnectPageHeader` renders the page title as an
19
+ * `h2`, so a block *inside* a page is a level below it. Hand-rolled sections
20
+ * reliably use `h2`, which makes every settings block a sibling of the page it
21
+ * sits in and flattens the outline a screen reader announces.
22
+ *
23
+ * As in the page header, the action is a peer of the title rather than of the
24
+ * block, so its position does not move with the length of the description.
25
+ */
26
+ export declare function ConnectSection({ title, description, action, titleId, className, bodyClassName, children, }: Readonly<ConnectSectionProps>): import("react").JSX.Element;
@@ -0,0 +1,18 @@
1
+ import type { ReactNode } from "react";
2
+ export interface ConnectSettingRowProps {
3
+ title: ReactNode;
4
+ description?: ReactNode;
5
+ /** The control this row is about - a switch, a button, a value with an edit link. */
6
+ action?: ReactNode;
7
+ /** Rendered under both, full width - a validation message, or a nested field the row reveals. */
8
+ children?: ReactNode;
9
+ className?: string;
10
+ }
11
+ /**
12
+ * One labelled setting inside a `ConnectSection`.
13
+ *
14
+ * Stacks on a phone and goes side-by-side from `sm` up, rather than shrinking
15
+ * a two-column row until neither column is readable. The control keeps its
16
+ * intrinsic width so truncation lands on the description.
17
+ */
18
+ export declare function ConnectSettingRow({ title, description, action, children, className, }: Readonly<ConnectSettingRowProps>): import("react").JSX.Element;
@@ -0,0 +1,36 @@
1
+ /**
2
+ * The closed set of tones a status may resolve to.
3
+ *
4
+ * Deliberately five, and deliberately narrower than HeroUI's `Chip` colour
5
+ * union: a status is either fine, needs attention, is broken, is in progress,
6
+ * or is inert. A sixth tone would have to mean one of those five again, which
7
+ * is where hand-written status chips start disagreeing with each other.
8
+ */
9
+ export type ConnectStatusTone = "success" | "warning" | "danger" | "accent" | "default";
10
+ /**
11
+ * How one domain's status union is presented: a tone and a human label per
12
+ * member.
13
+ *
14
+ * Both are **total** `Record`s, and that is the load-bearing property - adding
15
+ * a member to the status union fails the type gate until it has been given a
16
+ * presentation. A loose `Record<string, …>` map silently renders the new
17
+ * status as `undefined`.
18
+ */
19
+ export interface ConnectStatusPresentation<TStatus extends string> {
20
+ readonly tone: Readonly<Record<TStatus, ConnectStatusTone>>;
21
+ readonly label: Readonly<Record<TStatus, string>>;
22
+ }
23
+ /**
24
+ * One status, rendered the way every status should be.
25
+ *
26
+ * Domain knowledge stays in the domain: each caller exports its own
27
+ * `ConnectStatusPresentation` next to the union it describes, and this renders
28
+ * it. A status whose *rendering* carries real logic - a scheduled cancellation
29
+ * outranking a running trial, say - keeps its own component and calls this for
30
+ * the final chip. A map cannot express precedence.
31
+ */
32
+ export declare function ConnectStatusChip<TStatus extends string>({ status, presentation, className, }: Readonly<{
33
+ status: TStatus;
34
+ presentation: ConnectStatusPresentation<TStatus>;
35
+ className?: string;
36
+ }>): import("react").JSX.Element;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cosmoops/connect-sdk",
3
- "version": "0.9.0",
3
+ "version": "0.15.0",
4
4
  "description": "Official server-side SDK for the CosmoOps Connect platform API - Login with Connect, entitlements, billing and metering.",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "type": "commonjs",
@@ -36,6 +36,11 @@
36
36
  "import": "./dist/esm/client/index.js",
37
37
  "require": "./dist/cjs/client/index.js"
38
38
  },
39
+ "./ui": {
40
+ "types": "./dist/types/ui/index.d.ts",
41
+ "import": "./dist/esm/ui/index.js",
42
+ "require": "./dist/cjs/ui/index.js"
43
+ },
39
44
  "./theme.css": "./dist/theme.css",
40
45
  "./package.json": "./package.json"
41
46
  },
@@ -67,7 +72,6 @@
67
72
  "verify:pack": "bun run scripts/verify-pack.ts",
68
73
  "prepublishOnly": "bun run build && bun run verify:pack",
69
74
  "test": "bun test",
70
- "docs": "typedoc",
71
75
  "docs:md": "typedoc --options typedoc.markdown.json",
72
76
  "storybook": "storybook dev -p 6106",
73
77
  "build:storybook": "storybook build -o storybook-static"