Choose and build SDKs
Choose packages by runtime and capability. Existing @mosaic-base identifiers remain current interfaces; the product is Mosaic Base.
Packages and responsibilities
- @mosaic-base/shell resolves runtime SDKs by mapping. client-sdk contains domain MF implementations/types; applications do not statically bundle a default SDK.
- The selected Auth MF provides auth.client with separate browser/request-scoped Node instances. AuthUI receives that explicit instance.
- @mosaic-base/server-sdk: Node identity, introspection and service calls. @mosaic-base/platform-client: server-side uploads, short links and environment capabilities.
- @mosaic-base/admin-embed: delegated administration handshake, context changes and short-lived identity renewal.
Current installation source
Use workspace packages inside the repository, or actual tarballs, declarations and bootstrap from the developer kit outside it. Relative files and parent-scoped overrides resolve internal dependencies; each project creates its own lockfile. These Mosaic versions are not public npm releases, and platform-client is outside the first kit.
Terminal
pnpm --version # pinned: 9.15.4
pnpm install --frozen-lockfile
pnpm --filter @mosaic-base/common build
pnpm --filter @mosaic-base/brand build
pnpm --filter @mosaic-base/permission build
pnpm --filter @mosaic-base/server-sdk build
pnpm --filter @mosaic-base/site-contract build
pnpm --filter @mosaic-base/shell build:mf
pnpm --filter @mosaic-base/client-sdk build:mf
pnpm --filter @mosaic-base/auth-sdk build:mf
pnpm --filter @mosaic-base/auth-ui build
pnpm --filter @mosaic-base/permission build
pnpm --filter @mosaic-base/server-sdk build
pnpm --filter @mosaic-base/platform-client buildBrowser and server
Browsers use same-origin /api. SSR needs an absolute API URL. Public readers carry no visitor Cookie, while authenticated clients are created per request. Service secrets and server-sdk/platform-client stay out of browser bundles.
TypeScript
import type { Shell } from '@mosaic-base/shell';
import type { ArticleSDK, SiteSDK, I18nSDK } from '@mosaic-base/client-sdk';
import type { AuthClient, ServerAuthClient } from '@mosaic-base/auth-sdk';
// Declare once in your application's type contract, never import SDK implementations.
declare module '@mosaic-base/shell/contracts' {
interface SdkRegistry {
'site.config': Pick<SiteSDK, 'getConfig'>;
'content.articles': Pick<ArticleSDK, 'list' | 'getBySlug' | 'getPreview' | 'search'>;
'i18n.messages': Pick<I18nSDK, 'load' | 't' | 'clearCache' | 'refresh'>;
'auth.client': AuthClient | ServerAuthClient;
}
}
import type { Bootstrap } from '@mosaic-base/shell';
import { startShell } from '@mosaic-base/shell/bootstrap';
import { createNodeModuleLoader } from '@mosaic-base/shell/node';
const loader = createNodeModuleLoader(); // modules may be shared, user SDK instances may not
export function createPublicReader(bootstrap: Bootstrap, apiBaseUrl: string) {
return startShell({ bootstrap, loader, host: { apiBaseUrl,
capabilityOptions: { 'i18n.messages': { cacheTtlMs: 0 } } } });
}
// Read protected Node bootstrap with server-sdk and explicit grant/owner.
// Create/dispose one Shell per SSR operation/request; public HTTP omits Cookie.
// Pass that startup configuration's browser projection to hydration.