Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changeset/35424-all-docs-page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@objectstack/client': patch
'@object-ui/console': patch
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

feat(console): the 「All documentation」 page has the console's top bar, groups its books by app, and searches every article

Clause-②: yes (widening) — @objectstack/client `meta.getItems` takes an optional `include` (`'content' | 'grants'`, sent as `?include=`) and exports its options type `MetaItemsListOptions`; @object-ui/i18n adds nine help.* keys (two of them plural, with their per-locale forms); nothing removed
Metadata-protocol: none

- **The console's top bar on every portal page.** `/docs`, a book (`/docs/<book>`) and an article (`/docs/<book>/<article>`) are drawn in Home's frame, whose bar reads 「<product> / Documentation」 (the crumb links to the portal's index) and carries the search, the inbox, the assistant and the avatar menu, so the reader can go back to any app. The portal's own 「Documentation / <title>」 strip is gone.
- **Books grouped by app.** The page lists each app's books under the app's name, as the launcher names it: a book goes under the first app whose navigation links to it (a module's navigation contributions included), else under its package's app; books no app carries are listed last under 「Other documentation」. No card shows a package id; a package's docs with no authored book are named by their app. A platform package's books (`com.objectstack.*`, such as Setup's) are listed only under an app in the member's list that carries them, never under 「Other documentation」, so they are not listed for a member whose app list has no such app. This is what the page lists, not who may read a doc: the server's audience gate decides that, as before.
- **The subtitle and the counts read the session language** (「9 篇」, not 「9 articles」).
- **「Search all documentation」.** A search field on the page searches every listed article's title, summary and body, and lists the matches with the words marked in context; each opens the article in its own book. The bodies are asked once, the first time the reader searches (`GET /meta/doc?include=content`, through the same audience gate as the list). The query stays in the URL (`?q=`).
- **A hand-typed article URL whose book does not hold the article** (`/docs/<book A>/<article of book B>`) now opens the article in its own book; with no book that holds it, the article draws no previous/next pager instead of showing both ends at once. Inside an app, an article whose book is in no package now keeps its 「← Back to <app>」 link.

`@objectstack/client`: `client.meta.getItems(type, { include })` and the environment-scoped `meta.getItems` send `?include=`; leaving it out sends nothing, as before. `@object-ui/app-shell`: `AppHeader` takes a `docs` variant and `DefaultHomeLayout` a `variant` prop for it.
1 change: 1 addition & 0 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ await client.connect();
// Discovery & Metadata
await client.meta.getTypes(); // List metadata types
await client.meta.getItems('object'); // List all objects
await client.meta.getItems('doc', { include: 'content' }); // List docs WITH their bodies (the list omits them by default)
await client.meta.getItem('object', 'contact'); // Get specific object

// Data Operations
Expand Down
22 changes: 22 additions & 0 deletions packages/client/src/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,28 @@ describe('ObjectStackClient', () => {
]);
});

it('sends `include` as `?include=`, on the unscoped and the environment surface (the doc list keeps its bodies)', async () => {
const fetchMock = vi.fn().mockResolvedValue({
ok: true,
json: async () => ({ type: 'doc', items: [{ name: 'intro', content: '# Intro' }] }),
});
const client = new ObjectStackClient({ baseUrl: 'http://localhost:3000', fetch: fetchMock });

await client.meta.getItems('doc', { include: 'content' });
await client.meta.getItems('doc', { packageId: 'com.acme', include: 'content' });
await client.environment('env_1').meta.getItems('doc', { include: 'content' });
// Left out, nothing is sent: the list stays the slim default.
await client.meta.getItems('doc');

const urls = fetchMock.mock.calls.map((c) => String(c[0]));
expect(urls).toEqual([
'http://localhost:3000/api/v1/meta/doc?include=content',
'http://localhost:3000/api/v1/meta/doc?package=com.acme&include=content',
'http://localhost:3000/api/v1/environments/env_1/meta/doc?include=content',
'http://localhost:3000/api/v1/meta/doc',
]);
});

it('should get metadata item by type and name', async () => {
// The server's body is the spec-declared `GetMetaItemResponseSchema`
// envelope — `{ type, name, item }`, with the metadata document under
Expand Down
24 changes: 21 additions & 3 deletions packages/client/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,19 @@ export type { QualifiedAddressOptions } from './package-address';
*/
export type ApiRouteType = keyof ApiRoutes;

/**
* The options of `meta.getItems` (`GET /meta/:type`). `packageId` scopes the
* list to one package (`?package=`); `names` narrows it to those items in one
* request (`?names=a,b,c`); `include` asks for what the list omits by default
* (`?include=`): `'content'` keeps each `doc`'s body (ADR-0046), `'grants'`
* adds each `position`'s grants.
*/
export interface MetaItemsListOptions {
packageId?: string;
names?: readonly string[];
include?: 'content' | 'grants';
}

/**
* [#30205] `security.assignedWork.count`'s answer: per object and user field,
* how many records hold the user, as the caller can read them.
Expand Down Expand Up @@ -2083,12 +2096,16 @@ export class ObjectStackClient {
* (sent as `?names=a,b,c`). A name that matches no item is simply absent
* from the answer. An empty `names` array is sent as an empty filter,
* which the server refuses with `400`; leave `names` out to list every item.
* `include` asks for what the list leaves out by default (`?include=`):
* `'content'` keeps each `doc`'s body (ADR-0046), `'grants'` adds each
* `position`'s grants.
*/
getItems: async (type: string, options?: { packageId?: string; names?: readonly string[] }): Promise<GetMetaItemsResponse> => {
getItems: async (type: string, options?: MetaItemsListOptions): Promise<GetMetaItemsResponse> => {
const route = this.getRoute('metadata');
const params = new URLSearchParams();
if (options?.packageId) params.set('package', options.packageId);
if (options?.names !== undefined) params.set('names', options.names.join(','));
if (options?.include) params.set('include', options.include);
const qs = params.toString();
const url = `${this.baseUrl}${route}/${type}${qs ? `?${qs}` : ''}`;
const res = await this.fetch(url);
Expand Down Expand Up @@ -8696,11 +8713,12 @@ export class ScopedEnvironmentClient {
const res = await this.parent._fetch(this.metaUrl(''));
return this.parent._unwrap<GetMetaTypesResponse>(res);
},
/** The unscoped surface's `getItems`, `names` included (one `?names=a,b,c` request). */
getItems: async (type: string, options?: { packageId?: string; names?: readonly string[] }): Promise<GetMetaItemsResponse> => {
/** The unscoped surface's `getItems`, `names` and `include` included (one `?names=a,b,c` request). */
getItems: async (type: string, options?: MetaItemsListOptions): Promise<GetMetaItemsResponse> => {
const params = new URLSearchParams();
if (options?.packageId) params.set('package', options.packageId);
if (options?.names !== undefined) params.set('names', options.names.join(','));
if (options?.include) params.set('include', options.include);
const qs = params.toString();
const res = await this.parent._fetch(this.metaUrl(`/${type}${qs ? `?${qs}` : ''}`));
return this.parent._unwrap<GetMetaItemsResponse>(res);
Expand Down
53 changes: 33 additions & 20 deletions ui/apps/console/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,20 @@ function HomeRoute() {
);
}

/**
* The docs portal's frame (objectstack#35424): Home's layout with the docs bar,
* around the lazily loaded docs layout, so the bar is up while the portal's
* chunk loads.
*/
function DocsPortalRoute() {
const { user } = useAuth();
return (
<DefaultHomeLayout userId={user?.id} variant="docs">
<Suspense fallback={<LoadingScreen />}><DocsLayout /></Suspense>
</DefaultHomeLayout>
);
}

export function App() {
/**
* The console's ONE upload destination, mounted above `ConsoleShell` so it
Expand Down Expand Up @@ -351,26 +365,6 @@ export function App() {
* layer too late for a capability whose declared meaning is
* "Enter the Studio metadata-design surfaces". */}
{studioRoutes}
{/* Package documentation (ADR-0046): a platform-level portal
* lists every installed `doc` (grouped by package), and one
* viewer route renders any item; cross-references between docs
* resolve to that same viewer route. Both are app-independent. */}
{/* Docs portal (ADR-0046 §6). The layout fetches book + doc once
* and shares it with every child route via context. Children:
* index → book index
* :slug → a book landing, or a flat-doc permalink that
* redirects to its canonical /docs/<book>/<name>
* :slug/:name → in-book reader (doc identity stays single-
* coordinate; the book segment is derived nav). */}
<Route path="/docs" element={
<ProtectedRoute>
<Suspense fallback={<LoadingScreen />}><DocsLayout /></Suspense>
</ProtectedRoute>
}>
<Route index element={<Suspense fallback={<LoadingScreen />}><DocsIndex /></Suspense>} />
<Route path=":slug" element={<Suspense fallback={<LoadingScreen />}><DocsSlug /></Suspense>} />
<Route path=":slug/:name" element={<Suspense fallback={<LoadingScreen />}><DocPage /></Suspense>} />
</Route>
{/* objectui#12700 — Home and every app share ONE
* `/auth/me/permissions` source. A pathless layout route is their
* common ancestor: its element (auth, the shell, the permissions
Expand Down Expand Up @@ -419,6 +413,25 @@ export function App() {
</RequireOrganization>
}>
<Route path="/home" element={<HomeRoute />} />
{/* Package documentation (ADR-0046 §6): a platform-level portal
* lists every installed `doc` (grouped by the launcher's apps),
* and one viewer route renders any item; cross-references
* between docs resolve to that same viewer route. App-independent,
* so it is drawn in Home's frame with the docs bar (`docs`
* variant: 「PRODUCT / Documentation」), under this layout for
* the same `/auth/me/permissions` answer Home reads
* (objectstack#35424). The layout fetches book + doc once and
* shares it with every child route via context. Children:
* index → book index
* :slug → a book landing, or a flat-doc permalink that
* redirects to its canonical /docs/<book>/<name>
* :slug/:name → in-book reader (doc identity stays single-
* coordinate; the book segment is derived nav). */}
<Route path="/docs" element={<DocsPortalRoute />}>
<Route index element={<Suspense fallback={<LoadingScreen />}><DocsIndex /></Suspense>} />
<Route path=":slug" element={<Suspense fallback={<LoadingScreen />}><DocsSlug /></Suspense>} />
<Route path=":slug/:name" element={<Suspense fallback={<LoadingScreen />}><DocPage /></Suspense>} />
</Route>
<Route path="/apps/:appName/*" element={<AppContent />} />
{/* Internal authed form — same renderer as `/f/:slug`, different
* submit path, and (objectui#4109) rendered INSIDE the console
Expand Down
2 changes: 2 additions & 0 deletions ui/apps/console/src/__tests__/App.docsPortalLazy.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ vi.mock('@object-ui/app-shell', async (importOriginal) => ({
// is pinned by `packages/app-shell/src/chrome/RedirectWithSplash.test.tsx`.
RedirectWithSplash: stub('redirect-with-splash'),
RequireAiSurface: passthrough,
// objectstack#35424: `/docs` sits under the organization gate with `/home` and `/apps`.
RequireOrganization: passthrough,
SystemRedirect: () => null,
DefaultHomeLayout: passthrough,
DefaultHomePage: stub('home-page'),
Expand Down
6 changes: 3 additions & 3 deletions ui/apps/console/src/pages/BookPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ import { resolveBookTree, bookSlug, firstDoc } from './book-nav';
* beneath the heading. Shared by `DocsSlug` (a segment the member's lists do not
* answer) and `DocPage` (the reader).
*/
export function DocRefusal({ name, message }: { name?: string; message?: string }) {
export function DocRefusal({ message }: { message?: string }) {
return (
<DocShell breadcrumb={name}>
<DocShell>
<div className="mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center">
<Lock className="h-10 w-10 text-muted-foreground" />
<h1 className="text-lg font-semibold">You do not have access to this documentation</h1>
Expand Down Expand Up @@ -68,7 +68,7 @@ export default function BookPage() {

// Unknown book, or a book with no readable docs yet.
return (
<DocShell breadcrumb={found ? (found.label ?? slug) : slug}>
<DocShell>
<div className="mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center">
{found ? (
<>
Expand Down
31 changes: 24 additions & 7 deletions ui/apps/console/src/pages/DocPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import { DocsNav, type DocsNavBook } from './DocsNav';
import { DocRefusal } from './BookPage';
import { useBookData } from './use-book-data';
import { useActiveHeading } from './useActiveHeading';
import { articleNeighbours, type BookArticle } from './docs-reading';
import { articleNeighbours, bookHoldsArticle, type BookArticle } from './docs-reading';
import { resolveBookTree, bookSlug, bookNamedBy, homeBook, labelUncategorized, pkgOfBook, type ResolvedBook } from './book-nav';

interface DocItem {
Expand Down Expand Up @@ -282,11 +282,28 @@ export default function DocPage() {
// context. Only a segment NO book answers by slug is consulted, so every
// reader URL that finds its book today keeps its answer.
const namedBook = useMemo(() => (slug && !resolvedBook ? bookNamedBy(slug, books) : null), [slug, resolvedBook, books]);
// objectstack#35424 — a reader URL whose book does not hold its doc (a
// hand-typed `/docs/BOOK_A/DOC_OF_BOOK_B`) reads in the doc's own book: it is
// redirected there once the doc has loaded, so the column, the path above
// the article and the pager all describe the book the article is in. With
// no book that holds it, the page draws no pager (see below).
const inBook = resolvedBook ? bookHoldsArticle(resolvedBook, name) : false;
const ownBook = useMemo(() => {
if (state !== 'ready' || doc?.name !== name || !name || !resolvedBook || inBook) return null;
const home = homeBook(name, books, allDocs, appName);
if (!home || bookSlug(home) === slug) return null;
const resolved = resolveBookTree(home, allDocs, undefined, authoredBooks);
return bookHoldsArticle(resolved, name) ? home : null;
}, [state, doc, name, resolvedBook, inBook, books, allDocs, authoredBooks, appName, slug]);

if (namedBook && name) {
return <Navigate to={{ pathname: `${base}/${bookSlug(namedBook)}/${name}`, hash }} replace />;
}

if (ownBook && name) {
return <Navigate to={{ pathname: `${base}/${bookSlug(ownBook)}/${name}`, hash }} replace />;
}

if (state === 'loading') {
return (
<div className="flex h-full items-center justify-center p-10 text-muted-foreground">
Expand All @@ -297,7 +314,7 @@ export default function DocPage() {

if (state === 'missing') {
return (
<DocShell breadcrumb={name}>
<DocShell>
<div className="mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center">
<FileQuestion className="h-10 w-10 text-muted-foreground" />
<h1 className="text-lg font-semibold">Documentation not found</h1>
Expand All @@ -311,12 +328,12 @@ export default function DocPage() {
}

if (state === 'refused') {
return <DocRefusal name={name} message={errorMessage} />;
return <DocRefusal message={errorMessage} />;
}

if (state === 'conflict') {
return (
<DocShell breadcrumb={name}>
<DocShell>
<div className="mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center">
<Layers className="h-10 w-10 text-muted-foreground" />
<h1 className="text-lg font-semibold">
Expand Down Expand Up @@ -357,7 +374,7 @@ export default function DocPage() {

if (state === 'error') {
return (
<DocShell breadcrumb={name}>
<DocShell>
<div className="mx-auto flex max-w-3xl flex-col items-center gap-3 p-10 text-center">
<AlertCircle className="h-10 w-10 text-destructive" />
<h1 className="text-lg font-semibold">Failed to load documentation</h1>
Expand All @@ -381,7 +398,7 @@ export default function DocPage() {
const docsLabel = t('help.documentation', { defaultValue: 'Documentation' });

return (
<DocShell breadcrumb={doc?.label ?? name} backLink={false}>
<DocShell backLink={!docsNav}>
{/* objectstack#35424 — the docs column is the page's one navigation.
* Inside an app it sits where the app menu would, full height beside
* the article; on narrow screens it folds into a disclosure above it. */}
Expand Down Expand Up @@ -441,7 +458,7 @@ export default function DocPage() {
/>
</MermaidEnlargeContext.Provider>
</article>
{resolvedBook ? (
{resolvedBook && inBook ? (
<ArticlePager
previous={neighbours.previous}
next={neighbours.next}
Expand Down
Loading
Loading