@plitzi/sdk-shared 0.38.24 → 0.39.1
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 +153 -1
- package/dist/actions/functions.d.ts +22 -1
- package/dist/actions/functions.mjs +3 -3
- package/dist/actions/index.d.ts +1 -1
- package/dist/actions/index.mjs +7 -7
- package/dist/auth/failureChannel.mjs +1 -0
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.mjs +2 -2
- package/dist/auth/visitorRoles.d.ts +8 -0
- package/dist/auth/visitorRoles.mjs +5 -2
- package/dist/authoring/declare.d.ts +34 -1
- package/dist/authoring/elementCallbacks.d.ts +13 -0
- package/dist/authoring/elementCallbacks.mjs +11 -5
- package/dist/authoring/index.mjs +3 -3
- package/dist/authoring/paramSpec.d.ts +1 -0
- package/dist/dataSource/getBindingsDetails.d.ts +1 -1
- package/dist/dataSource/getBindingsDetails.mjs +1 -1
- package/dist/dataSource/globalSources.d.ts +1 -1
- package/dist/dataSource/index.d.ts +1 -2
- package/dist/dataSource/index.mjs +1 -1
- package/dist/dataSource/utility/arrayMap.mjs +1 -1
- package/dist/dataSource/utility/capitalize.mjs +1 -1
- package/dist/dataSource/utility/styleSelector.mjs +5 -3
- package/dist/dataSource/utility/styleVariant.mjs +17 -13
- package/dist/dataSource/variables/index.d.ts +2 -0
- package/dist/dataSource/variables/index.mjs +1 -0
- package/dist/dataSource/{resolveVariables.d.ts → variables/resolveVariables.d.ts} +1 -1
- package/dist/dataSource/{resolveVariables.mjs → variables/resolveVariables.mjs} +1 -1
- package/dist/devTools/chrome.d.ts +6 -0
- package/dist/devTools/chrome.mjs +2 -2
- package/dist/devTools/index.mjs +5 -5
- package/dist/devTools/sight/index.d.ts +1 -0
- package/dist/devTools/sight/index.mjs +1 -0
- package/dist/devTools/sight/sight.d.ts +28 -0
- package/dist/devTools/sight/sight.mjs +127 -0
- package/dist/devTools/utils/PlitziConsole.d.ts +14 -0
- package/dist/devTools/utils/PlitziConsole.mjs +20 -3
- package/dist/flags/flagsCookie.mjs +4 -4
- package/dist/flags/resolveFlags.d.ts +1 -1
- package/dist/helpers/index.mjs +19 -19
- package/dist/helpers/ruleEvaluator.d.ts +2 -0
- package/dist/helpers/ruleEvaluator.mjs +2 -2
- package/dist/helpers/scroll.d.ts +10 -0
- package/dist/helpers/scroll.mjs +2 -2
- package/dist/helpers/twigWrapper/Evaluator/Evaluator.mjs +90 -88
- package/dist/helpers/twigWrapper/Evaluator/helpers.d.ts +6 -0
- package/dist/helpers/twigWrapper/Evaluator/helpers.mjs +11 -2
- package/dist/helpers/twigWrapper/filters/arrays.d.ts +2 -0
- package/dist/helpers/twigWrapper/filters/arrays.mjs +66 -0
- package/dist/helpers/twigWrapper/filters/catalog/index.d.ts +17 -0
- package/dist/helpers/twigWrapper/filters/catalog/index.mjs +351 -0
- package/dist/helpers/twigWrapper/filters/dateParts.d.ts +25 -0
- package/dist/helpers/twigWrapper/filters/dateParts.mjs +56 -0
- package/dist/helpers/twigWrapper/filters/dates.d.ts +2 -0
- package/dist/helpers/twigWrapper/filters/dates.mjs +97 -0
- package/dist/helpers/twigWrapper/filters/filters.d.ts +3 -13
- package/dist/helpers/twigWrapper/filters/filters.mjs +25 -483
- package/dist/helpers/twigWrapper/filters/hashing.d.ts +3 -0
- package/dist/helpers/twigWrapper/filters/hashing.mjs +101 -0
- package/dist/helpers/twigWrapper/filters/index.mjs +4 -1
- package/dist/helpers/twigWrapper/filters/misc.d.ts +5 -0
- package/dist/helpers/twigWrapper/filters/misc.mjs +52 -0
- package/dist/helpers/twigWrapper/filters/numbers.d.ts +2 -0
- package/dist/helpers/twigWrapper/filters/numbers.mjs +36 -0
- package/dist/helpers/twigWrapper/filters/objects.d.ts +3 -0
- package/dist/helpers/twigWrapper/filters/objects.mjs +61 -0
- package/dist/helpers/twigWrapper/filters/raw.d.ts +8 -0
- package/dist/helpers/twigWrapper/filters/raw.mjs +7 -0
- package/dist/helpers/twigWrapper/filters/strings.d.ts +7 -0
- package/dist/helpers/twigWrapper/filters/strings.mjs +79 -0
- package/dist/helpers/twigWrapper/filters/types.d.ts +5 -0
- package/dist/helpers/twigWrapper/filters/types.mjs +4 -0
- package/dist/helpers/twigWrapper/filters/values.d.ts +12 -0
- package/dist/helpers/twigWrapper/filters/values.mjs +17 -0
- package/dist/helpers/twigWrapper/inspectTemplate.d.ts +5 -0
- package/dist/helpers/twigWrapper/inspectTemplate.mjs +39 -20
- package/dist/helpers/utils.d.ts +4 -0
- package/dist/helpers/utils.mjs +3 -5
- package/dist/navigation/index.d.ts +2 -0
- package/dist/navigation/index.mjs +2 -1
- package/dist/navigation/sitemap.d.ts +16 -0
- package/dist/navigation/sitemap.mjs +25 -0
- package/dist/network/entitlements.d.ts +101 -0
- package/dist/network/entitlements.mjs +4 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceRunE2eTestsMutation.d.ts +31 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceRunE2eTestsMutation.mjs +13 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceSetTestsMutation.d.ts +5 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceSetTestsMutation.mjs +11 -0
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSettingsMutation.d.ts +1 -1
- package/dist/network/graphql/builder/Mutations/Space/SpaceUpdateSettingsMutation.mjs +1 -1
- package/dist/network/graphql/builder/Mutations/index.d.ts +5 -0
- package/dist/network/graphql/builder/Mutations/index.mjs +150 -146
- package/dist/network/graphql/builder/Queries/Space/SpaceTestsQuery.d.ts +40 -0
- package/dist/network/graphql/builder/Queries/Space/SpaceTestsQuery.mjs +24 -0
- package/dist/network/graphql/builder/Queries/index.d.ts +3 -0
- package/dist/network/graphql/builder/Queries/index.mjs +44 -42
- package/dist/network/graphql/sdk/Queries/InitQuery.d.ts +3 -1
- package/dist/network/graphql/sdk/Queries/InitQuery.mjs +1 -1
- package/dist/network/index.d.ts +1 -0
- package/dist/network/index.mjs +9 -8
- package/dist/network/spaceEvents.d.ts +20 -1
- package/dist/network/spaceEvents.mjs +12 -0
- package/dist/project/index.mjs +8 -5
- package/dist/project/layout/check.d.ts +22 -0
- package/dist/project/layout/check.mjs +60 -0
- package/dist/project/{layout.d.ts → layout/codes.d.ts} +3 -66
- package/dist/project/layout/codes.mjs +108 -0
- package/dist/project/layout/contents.d.ts +10 -0
- package/dist/project/layout/contents.mjs +31 -0
- package/dist/project/layout/files.d.ts +31 -0
- package/dist/project/layout/files.mjs +49 -0
- package/dist/project/layout/folders.d.ts +4 -0
- package/dist/project/layout/folders.mjs +69 -0
- package/dist/project/layout/index.d.ts +16 -0
- package/dist/project/layout/index.mjs +5 -0
- package/dist/project/layout/plugins.d.ts +46 -0
- package/dist/project/layout/plugins.mjs +99 -0
- package/dist/project/layout/vendor.d.ts +15 -0
- package/dist/project/layout/vendor.mjs +34 -0
- package/dist/project/pages/index.d.ts +8 -0
- package/dist/project/pages/index.mjs +14 -0
- package/dist/project/paths/index.d.ts +52 -4
- package/dist/project/paths/index.mjs +2 -2
- package/dist/project/root.d.ts +6 -0
- package/dist/project/root.mjs +11 -10
- package/dist/realtime/client.mjs +104 -91
- package/dist/realtime/presence.d.ts +2 -2
- package/dist/realtime/presence.mjs +27 -21
- package/dist/runs/index.d.ts +73 -0
- package/dist/runs/index.mjs +6 -0
- package/dist/runs/report.d.ts +56 -0
- package/dist/runs/report.mjs +17 -0
- package/dist/schema/index.d.ts +6 -0
- package/dist/schema/index.mjs +18 -12
- package/dist/schema/motion.d.ts +25 -0
- package/dist/schema/motion.mjs +47 -19
- package/dist/schema/pageAccess.d.ts +6 -0
- package/dist/schema/pageAccess.mjs +8 -3
- package/dist/schema/pageHead.d.ts +64 -0
- package/dist/schema/pageHead.mjs +68 -0
- package/dist/schema/providerAnswer.d.ts +17 -0
- package/dist/schema/providerAnswer.mjs +4 -0
- package/dist/schema/providerWhen.d.ts +36 -0
- package/dist/schema/providerWhen.mjs +58 -0
- package/dist/schema/schemaSettings.d.ts +14 -0
- package/dist/schema/schemaSettings.mjs +4 -0
- package/dist/schema/serverElements.d.ts +20 -1
- package/dist/schema/serverElements.mjs +41 -28
- package/dist/schema/serverInput.d.ts +34 -0
- package/dist/schema/serverInput.mjs +60 -0
- package/dist/schema/serverQuery.d.ts +47 -0
- package/dist/schema/serverQuery.mjs +70 -0
- package/dist/server/index.mjs +5 -5
- package/dist/server/rsc/refreshRsc.d.ts +6 -2
- package/dist/server/rsc/refreshRsc.mjs +75 -59
- package/dist/server/rsc/useRscSync.mjs +22 -18
- package/dist/source/export.d.ts +1 -1
- package/dist/state/index.mjs +3 -3
- package/dist/state/paintedState.d.ts +20 -4
- package/dist/state/paintedState.mjs +13 -12
- package/dist/state/runtimeStatePersist.mjs +109 -48
- package/dist/store/renderSettings.d.ts +2 -0
- package/dist/store/renderSettings.mjs +13 -5
- package/dist/store/storeHooks.d.ts +45 -45
- package/dist/style/index.mjs +16 -16
- package/dist/style/styleConstants.d.ts +12 -2
- package/dist/style/styleConstants.mjs +20 -0
- package/dist/style/styleStates.d.ts +5 -0
- package/dist/style/styleStates.mjs +21 -5
- package/dist/types/ActionTypes.d.ts +26 -3
- package/dist/types/AuthTypes.d.ts +19 -1
- package/dist/types/CommonTypes.d.ts +3 -2
- package/dist/types/ElementTypes.d.ts +1 -1
- package/dist/types/InteractionTypes.d.ts +10 -1
- package/dist/types/JobTypes.d.ts +2 -1
- package/dist/types/OAuthTypes.d.ts +246 -0
- package/dist/types/OAuthTypes.mjs +0 -0
- package/dist/types/PluginTypes.d.ts +2 -0
- package/dist/types/PreviewTypes.d.ts +71 -0
- package/dist/types/PreviewTypes.mjs +0 -0
- package/dist/types/RealtimeTypes.d.ts +11 -0
- package/dist/types/SchemaTypes.d.ts +63 -0
- package/dist/types/ServerAdapterTypes.d.ts +345 -0
- package/dist/types/ServerAdapterTypes.mjs +0 -0
- package/dist/types/ServerConfigTypes.d.ts +527 -0
- package/dist/types/ServerConfigTypes.mjs +0 -0
- package/dist/types/ServerLogTypes.d.ts +119 -0
- package/dist/types/ServerLogTypes.mjs +0 -0
- package/dist/types/ServerTypes.d.ts +30 -1215
- package/dist/types/StoreTypes.d.ts +39 -1
- package/dist/types/TestTypes.d.ts +249 -0
- package/dist/types/TestTypes.mjs +0 -0
- package/dist/types/index.d.ts +6 -0
- package/eslint.config.mjs +3 -1
- package/package.json +2 -2
- package/setupTests.ts +4 -3
- package/dist/project/layout.mjs +0 -394
|
@@ -1,17 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Environment, ServerAuth } from './CommonTypes';
|
|
1
|
+
import { ActionRunSummary } from './ActionTypes';
|
|
3
2
|
import { PluginDeclaration } from './ComponentTypes';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { JobQueue } from './JobTypes';
|
|
8
|
-
import { SSRRealtimeConfig } from './RealtimeTypes';
|
|
9
|
-
import { Schema } from './SchemaTypes';
|
|
10
|
-
import { AnalyticsConfig, OfflineDataRaw } from './SdkTypes';
|
|
11
|
-
import { FontHead, Style } from './StyleTypes';
|
|
12
|
-
import { ActivityReader, SpaceActivityPage, SpaceActivityQuery } from '../activity/types';
|
|
13
|
-
import { FlagOverrides } from '../flags/resolveFlags';
|
|
3
|
+
import { OfflineDataRaw } from './SdkTypes';
|
|
4
|
+
import { SSRMeterDecision, SSRSpaceDeployment } from './ServerAdapterTypes';
|
|
5
|
+
import { FontHead } from './StyleTypes';
|
|
14
6
|
import { SpaceChange } from '../history/types';
|
|
7
|
+
import { PageHeadTags } from '../schema/pageHead';
|
|
15
8
|
import { IncomingHttpHeaders } from 'node:http';
|
|
16
9
|
import { FC } from 'react';
|
|
17
10
|
export type ServerEnvironment = 'development' | 'production' | 'staging' | 'local';
|
|
@@ -133,6 +126,11 @@ export type SSRTemplateProps = {
|
|
|
133
126
|
title?: string;
|
|
134
127
|
/** Meta description for the document, and the share-preview text derived from it. */
|
|
135
128
|
description?: string;
|
|
129
|
+
/**
|
|
130
|
+
* The head's tags besides the title and the JSON-LD — description, robots, Open Graph and card, the canonical
|
|
131
|
+
* address, the icon, the browser's colour, the language — as `pageHeadTags` decides them. The server's own.
|
|
132
|
+
*/
|
|
133
|
+
head?: PageHeadTags;
|
|
136
134
|
jsPath?: string;
|
|
137
135
|
cssPath?: string;
|
|
138
136
|
/** Font Awesome's rules, after `cssPath`; its fonts are files beside it, fetched only for a style the page uses. */
|
|
@@ -232,6 +230,14 @@ export type SSRGrant = {
|
|
|
232
230
|
/** For an `agent` grant, the application the member connected (`Claude`): what its writes are recorded and shown as. */
|
|
233
231
|
client?: string;
|
|
234
232
|
canWrite: boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Whether it may write and play the space's tests — every role that writes may, and a tester's role (`Can test`) may
|
|
235
|
+
* with nothing else: the MCP saves the tests alone through it, never another change.
|
|
236
|
+
*/
|
|
237
|
+
canTest?: boolean;
|
|
238
|
+
/** Why `canWrite` is false, in the consumer's words, said to the agent in place of the MCP's own: a role that views
|
|
239
|
+
* or edits only the content never had the right to change the design — it did not lose it. */
|
|
240
|
+
readOnlyReason?: string;
|
|
235
241
|
};
|
|
236
242
|
/** A page of a space's change history, newest first; `nextBefore` reads further back, null at the end. */
|
|
237
243
|
export type SSRChangePage = {
|
|
@@ -296,904 +302,10 @@ export type SSRUser = {
|
|
|
296
302
|
* person, and what a job keeps of whoever started it, for every slice it runs after their session is gone.
|
|
297
303
|
*/
|
|
298
304
|
export type RunUser = Pick<SSRUser, 'id' | 'username' | 'email' | 'verified' | 'permissions' | 'roles'>;
|
|
299
|
-
export type SSRSpaceDeployment = {
|
|
300
|
-
/** Who may put this space in an iframe, as CSP `frame-ancestors` sources (e.g. `'self'`, `https://acme.com`,
|
|
301
|
-
* or `*`). Resolved per space by the consumer, because only it knows the domains that space declares — a
|
|
302
|
-
* published space must not be framable from a site its owner never allowed. Omitted → the server's own
|
|
303
|
-
* `frameOptions` default stands. */
|
|
304
|
-
frameAncestors?: string[];
|
|
305
|
-
environment?: Environment;
|
|
306
|
-
credential?: SSRCredential;
|
|
307
|
-
spaceId?: number | null;
|
|
308
|
-
revision?: number;
|
|
309
|
-
/**
|
|
310
|
-
* What this space's feature flags are at, for a deployment that keeps them apart from its revisions — a hash that
|
|
311
|
-
* changes exactly when they do. Part of every cache key a render is kept under (the page, its server data, the space
|
|
312
|
-
* read for it), so a flag turned in production reaches the next request while the revision stays the same. Absent,
|
|
313
|
-
* the flags change only with the revision, and the revision alone keys the caches.
|
|
314
|
-
*/
|
|
315
|
-
flagsVersion?: string;
|
|
316
|
-
/**
|
|
317
|
-
* This render is an author looking at their own work — the builder's preview — rather than a visitor being
|
|
318
|
-
* served. Metering skips it: nobody should be billed for editing.
|
|
319
|
-
*
|
|
320
|
-
* It is a property of HOW the request resolved, not of the environment it renders. Those two look the same
|
|
321
|
-
* from the render's side and are not: a space's free preview sub-domain serves the live editing environment
|
|
322
|
-
* to the public, so "which environment" cannot tell an author apart from a visitor. Only the resolver knows,
|
|
323
|
-
* which is why it says so here.
|
|
324
|
-
*/
|
|
325
|
-
authoring?: boolean;
|
|
326
|
-
templateProps?: SSRTemplateProps;
|
|
327
|
-
pluginNames?: string[];
|
|
328
|
-
pluginSources?: Record<string, PluginSource>;
|
|
329
|
-
error?: {
|
|
330
|
-
code: number;
|
|
331
|
-
message: string;
|
|
332
|
-
};
|
|
333
|
-
};
|
|
334
305
|
export type SSRTemplateFn = (params: SSRTemplateProps & {
|
|
335
306
|
html: string;
|
|
336
307
|
offlineData: string;
|
|
337
308
|
}) => string;
|
|
338
|
-
export type SSRRscData = {
|
|
339
|
-
/** Per-element server data keyed by schema element ID. Each element reads its own slice via its id prop. */
|
|
340
|
-
serverData?: Record<string, unknown>;
|
|
341
|
-
};
|
|
342
|
-
/** Semantic + machine-readable metadata for one element type, so the MCP can tell an agent what the type DOES
|
|
343
|
-
* (not just that it exists) AND validate against it. `category` groups it (e.g. provider, structure, media);
|
|
344
|
-
* `custom` marks a plugin-provided type. The MCP keys strict-vs-lenient validation off `custom`: a `custom:false`
|
|
345
|
-
* (default sdk-elements) type is authoritative — an unknown attribute/setState key on it is an error — while a
|
|
346
|
-
* `custom:true` (plugin) type is best-effort (warnings only), since its metadata is a manifest snapshot. */
|
|
347
|
-
export type ComponentCatalogEntry = {
|
|
348
|
-
label?: string;
|
|
349
|
-
description?: string;
|
|
350
|
-
category?: string;
|
|
351
|
-
custom?: boolean;
|
|
352
|
-
/** The type's attribute/prop keys — the authoritative set for a default type (setState `key` when
|
|
353
|
-
* category="attribute", and type-prop validation). Absent when unknown (e.g. a plugin with no manifest). */
|
|
354
|
-
attributes?: string[];
|
|
355
|
-
/** The type's `definition.styleSelectors` keys (slots) — setState `key` when category="state" is
|
|
356
|
-
* `visibility` or `styleSelectors.<selector>`. */
|
|
357
|
-
styleSelectors?: string[];
|
|
358
|
-
/** The type's intrinsic base default CSS (its `defaultStyle.style.base.default`) — the declarations the element
|
|
359
|
-
* renders with before any class is attached, e.g. `text` defaults to `{ display: 'inline' }`. The MCP surfaces
|
|
360
|
-
* it so an agent styles against the real starting point instead of assuming `display: block`. */
|
|
361
|
-
defaultStyle?: Record<string, string>;
|
|
362
|
-
/** Binding targets the type exposes, from the plugin manifest's `defaultStyle.bindingsAllowed`. */
|
|
363
|
-
bindingsAllowed?: {
|
|
364
|
-
attributes?: string[];
|
|
365
|
-
initialState?: string[];
|
|
366
|
-
};
|
|
367
|
-
};
|
|
368
|
-
/** Element type → its semantic metadata, keyed by the `type` string used in the schema. Covers BOTH the default
|
|
369
|
-
* sdk-elements types (custom:false, authoritative) and the plugin (custom:true) element types installed on a
|
|
370
|
-
* space, so the MCP can validate types/attributes dynamically per space instead of against a hand-mirror. */
|
|
371
|
-
export type ComponentCatalog = Record<string, ComponentCatalogEntry>;
|
|
372
|
-
export type SSRAdapters = {
|
|
373
|
-
/** The space's render payload. Optional HERE and required by a page server (see {@link SSRPageAdapters}): a
|
|
374
|
-
* dedicated MCP server renders nothing, reads schema and style through its own adapters, and had to hand this
|
|
375
|
-
* one over anyway for the type to be satisfied — an adapter it never called. */
|
|
376
|
-
getOfflineData?: (spaceId: number, environment: string, revision?: number) => Promise<OfflineDataRaw | undefined>;
|
|
377
|
-
/**
|
|
378
|
-
* Which space, environment and revision a request resolves to. Optional here for the same reason as
|
|
379
|
-
* `getOfflineData`: MCP resolves its space from the request token (`getGrant`), never from the host.
|
|
380
|
-
*
|
|
381
|
-
* Asked on EVERY request, not only a page's: what the page fetches after it — `/_plitzi/space/<hash>.json`, `/_action`,
|
|
382
|
-
* `/fn/…`, `/_realtime` — is resolved again, and carries nothing of the page's address but its host (and the
|
|
383
|
-
* visitor's credentials). So a space is chosen by the host — a domain, a sub-domain (`wildcardSubdomain`) — or by a
|
|
384
|
-
* credential (`authoringPreview`): one chosen by the page's path or query is lost on the requests that follow it.
|
|
385
|
-
*/
|
|
386
|
-
getSpaceDeployment?: (req: SSRRequest) => Promise<SSRSpaceDeployment>;
|
|
387
|
-
/** Resolve the grant the MCP request operates under, from the verified `Authorization` bearer. The consumer
|
|
388
|
-
* owns the JWT secret and the authorization model, so it decides here; the MCP service stays stateless.
|
|
389
|
-
* Returns undefined when the token is missing or invalid. Required for the `mcp` service to serve any
|
|
390
|
-
* request. `canWrite` is what separates a read-only bearer from one that may change the space — the MCP
|
|
391
|
-
* refuses every write tool without it, and never infers the answer from the token itself. */
|
|
392
|
-
getGrant?: (req: SSRRequest) => Promise<SSRGrant | undefined>;
|
|
393
|
-
/** Read the element schema for the MCP tools. Separate from `getOfflineData` (which is SSR/RSC shaped and
|
|
394
|
-
* strips `style.platform`); the MCP style resource needs the full documents, so schema and style split. */
|
|
395
|
-
getSchema?: (spaceId: number, environment: Environment) => Promise<Schema | undefined>;
|
|
396
|
-
/** Read the full style document (with `platform`/`mode`, which the MCP definitions resource requires). */
|
|
397
|
-
getStyle?: (spaceId: number, environment: Environment) => Promise<Style | undefined>;
|
|
398
|
-
/** Read the semantic catalog of the space's PLUGIN (custom) element types — label/description/category from
|
|
399
|
-
* each installed plugin's manifest — so the MCP `plitzi://types` resource can explain what custom elements do.
|
|
400
|
-
* The MCP already knows the built-in types. When omitted, custom types surface with their observed label only. */
|
|
401
|
-
getComponentCatalog?: (spaceId: number, environment: Environment) => Promise<ComponentCatalog | undefined>;
|
|
402
|
-
/** Read every connector configured for the space, so the MCP can list them and author provider elements against
|
|
403
|
-
* them. Connectors are space-level (not per environment) server-side state: the manifests name endpoints and an
|
|
404
|
-
* auth scheme, so this must never feed a browser payload. When omitted, the MCP's connector resource is empty
|
|
405
|
-
* and a provider element cannot be checked against the connector it names. */
|
|
406
|
-
getConnectors?: (spaceId: number) => Promise<ConnectorEntry[] | undefined>;
|
|
407
|
-
/** Create or replace one connector, keyed by `entry.id`. When omitted, connector ops apply in memory only and
|
|
408
|
-
* `apply` reports `persisted: false`. */
|
|
409
|
-
saveConnector?: (spaceId: number, entry: ConnectorEntry) => Promise<void>;
|
|
410
|
-
/** Remove one connector by its identifier. Omitted alongside `saveConnector` for a read-only deployment. */
|
|
411
|
-
deleteConnector?: (spaceId: number, connectorId: string) => Promise<void>;
|
|
412
|
-
/** Read every server action configured for the space, so the MCP can list them and author flows against them.
|
|
413
|
-
* Space-level server-side state like connectors: the documents name credentials, connectors and steps, so this
|
|
414
|
-
* must never feed a browser payload. When omitted, the MCP's action resource is empty. */
|
|
415
|
-
getActions?: (spaceId: number) => Promise<ActionEntry[] | undefined>;
|
|
416
|
-
/** The server tasks a flow can be built from — what THIS deployment can run, which is the SDK's built-ins plus
|
|
417
|
-
* whatever tasks it registered. Shaped as `ActionTaskDescriptor` in `@plitzi/sdk-server/actions`. Without it an
|
|
418
|
-
* agent authoring an action is guessing at the step vocabulary. */
|
|
419
|
-
getActionTasks?: (spaceId: number) => Promise<ActionTaskDescriptor[] | undefined>;
|
|
420
|
-
/** Create or replace one action, keyed by `entry.id`. When omitted, action ops apply in memory only and `apply`
|
|
421
|
-
* reports `persisted: false`. */
|
|
422
|
-
saveAction?: (spaceId: number, entry: ActionEntry) => Promise<void>;
|
|
423
|
-
/** Remove one action by its identifier. Omitted alongside `saveAction` for a read-only deployment. */
|
|
424
|
-
deleteAction?: (spaceId: number, actionId: string) => Promise<void>;
|
|
425
|
-
/** The space's own functions: the draft's source files, which copy of them it is and what they declare.
|
|
426
|
-
* Server-side code like the actions it serves — never a browser payload. When omitted, the MCP offers no functions
|
|
427
|
-
* resource and refuses the function ops. */
|
|
428
|
-
getFunctions?: (spaceId: number) => Promise<FunctionsDraft | undefined>;
|
|
429
|
-
/** Save the draft's functions, whole. The deployment builds and checks them and answers what is wrong where it is;
|
|
430
|
-
* `base` is the version the agent read, and a draft that moved on since is refused rather than overwritten. */
|
|
431
|
-
saveFunctions?: (spaceId: number, files: Record<string, string>, base: string, write: SSRWriteContext) => Promise<FunctionsSaveResult>;
|
|
432
|
-
/** Run one task of the draft's functions in the sandbox for the person behind the agent — the builder's Try. */
|
|
433
|
-
tryFunction?: (spaceId: number, task: string, params: Record<string, unknown>, write: SSRWriteContext) => Promise<ActionRunReport>;
|
|
434
|
-
/** The space's own data: the draft's JSON files its server providers read (`/data/<file>`), and which copy they are.
|
|
435
|
-
* When omitted, the MCP offers no data resource and refuses the data ops. */
|
|
436
|
-
getData?: (spaceId: number) => Promise<DataDraft | undefined>;
|
|
437
|
-
/** Save the draft's data, whole: every file JSON at a plain path. `base` is the version the agent read, and data that
|
|
438
|
-
* moved on since is refused rather than overwritten. */
|
|
439
|
-
saveData?: (spaceId: number, files: Record<string, string>, base: string, write: SSRWriteContext) => Promise<DataSaveResult>;
|
|
440
|
-
/** Persist the element schema mutated by the MCP `apply` tool. When omitted, `apply` reports `persisted: false`. */
|
|
441
|
-
saveSchema?: (spaceId: number, environment: Environment, schema: Schema, write: SSRWriteContext) => Promise<void>;
|
|
442
|
-
/** Persist the style document mutated by the MCP `apply` tool — store it as given. `style.cache` arrives already
|
|
443
|
-
* compiled: the renderer serves that string and nothing else, so recomputing it is not a detail to delegate, and
|
|
444
|
-
* asking every deployment to remember it was one bug each of them could write alone. When omitted, `apply`
|
|
445
|
-
* reports `persisted: false`. */
|
|
446
|
-
saveStyle?: (spaceId: number, environment: Environment, style: Style, write: SSRWriteContext) => Promise<void>;
|
|
447
|
-
/** The space's change history, read-only: what every writer saved, and for whom. When omitted, the MCP offers no
|
|
448
|
-
* history resource. */
|
|
449
|
-
getChanges?: (spaceId: number, environment: Environment, query: SSRChangeQuery) => Promise<SSRChangePage>;
|
|
450
|
-
/** What happened on the space after a cursor — the draft changed, a version went out, an action failed — waiting up
|
|
451
|
-
* to `query.wait` seconds when nothing has yet. `reader` is who asks, so their own writes can be left out; `signal`
|
|
452
|
-
* ends the wait when the client goes. When omitted, the MCP offers no `plitzi_activity`. */
|
|
453
|
-
getActivity?: (spaceId: number, query: SpaceActivityQuery, reader: ActivityReader, signal?: AbortSignal) => Promise<SpaceActivityPage>;
|
|
454
|
-
/** Who this request carries, if anyone. The adapter reads the credential and resolves it; the cookie it arrived
|
|
455
|
-
* in was written by the server, from {@link SSRAuthCookie}. */
|
|
456
|
-
getUser?: (req: SSRRequest) => Promise<SSRUser | undefined>;
|
|
457
|
-
/**
|
|
458
|
-
* Verify credentials and mint a session — identity, and nothing else. The server writes the cookies, clears them,
|
|
459
|
-
* and keeps the readable hint in step, because those are properties of how sessions travel rather than of who
|
|
460
|
-
* anyone is. A deployment bringing its own user database implements this and gets the rest for free.
|
|
461
|
-
*
|
|
462
|
-
* Return undefined to refuse. Never throw for a wrong password.
|
|
463
|
-
*/
|
|
464
|
-
authenticate?: (credentials: Record<string, string>, req: SSRRequest) => Promise<SSRSession | undefined>;
|
|
465
|
-
/** Revoke whatever session this request carries, at the source. The cookies are the server's to clear. */
|
|
466
|
-
endSession?: (req: SSRRequest) => Promise<void>;
|
|
467
|
-
/**
|
|
468
|
-
* Turn a credential the browser obtained from an identity provider into a session here — see the exchange stage.
|
|
469
|
-
* Everything that decides whether it is any good lives in this adapter, because only the deployment knows:
|
|
470
|
-
*
|
|
471
|
-
* - which providers it trusts, and which one the space in question actually signs people in with;
|
|
472
|
-
* - that the token was minted for **this** application. Anyone who has signed into any other site with the same
|
|
473
|
-
* provider holds a valid token for that user, so accepting one merely because the provider recognises it lets
|
|
474
|
-
* that site sign in here as them. A provider that cannot prove it must be refused outright.
|
|
475
|
-
*/
|
|
476
|
-
exchangeCredential?: (provider: string, token: string, req: SSRRequest) => Promise<{
|
|
477
|
-
ok: true;
|
|
478
|
-
session: SSRSession;
|
|
479
|
-
user?: SSRUser;
|
|
480
|
-
} | {
|
|
481
|
-
ok: false;
|
|
482
|
-
error: string;
|
|
483
|
-
status?: number;
|
|
484
|
-
reason?: string;
|
|
485
|
-
}>;
|
|
486
|
-
/** Called by the RSC endpoint, and once per page render, to fetch server-side data for server components.
|
|
487
|
-
* See {@link SSRRscContext} for what it is given. */
|
|
488
|
-
getRscData?: (context: SSRRscContext) => Promise<SSRRscData>;
|
|
489
|
-
/**
|
|
490
|
-
* One billable server request. This is where a deployment meters usage, because these are the moments it
|
|
491
|
-
* actually spends bandwidth on a visitor and the ones a visitor cannot reach around: the browser is told
|
|
492
|
-
* what happened, never asked. Each runs before its cache is consulted, so a cached response still counts.
|
|
493
|
-
*
|
|
494
|
-
* What comes back shapes the response — degrade the free tier, hand the browser its reporting channel — and
|
|
495
|
-
* a deployment that meters nothing simply omits the adapter. Never throw from here: a metering outage must
|
|
496
|
-
* not take a site down, so failures should degrade to "served, uncounted".
|
|
497
|
-
*/
|
|
498
|
-
meter?: (event: SSRMeterEvent) => Promise<SSRMeterDecision | undefined>;
|
|
499
|
-
};
|
|
500
|
-
/**
|
|
501
|
-
* Which area of server work is being metered. One name per area, because that is the unit a deployment prices
|
|
502
|
-
* — a full page render does not cost what a partial data refresh costs, and both are cheaper when a cache
|
|
503
|
-
* answered them than when the origin did.
|
|
504
|
-
*/
|
|
505
|
-
export type MeteredKind = 'page_view' | 'rsc_query'
|
|
506
|
-
/** Reserved: nothing emits this yet. Server actions are not implemented — the area exists so wiring them
|
|
507
|
-
* later is a call site, not a schema change. */
|
|
508
|
-
| 'server_action';
|
|
509
|
-
/** The request being metered, for {@link SSRAdapters.meter}. */
|
|
510
|
-
export interface SSRMeterEvent {
|
|
511
|
-
kind: MeteredKind;
|
|
512
|
-
/**
|
|
513
|
-
* Whether a cache answered this instead of the origin. Reported rather than inferred: only the handler knows,
|
|
514
|
-
* it is the same fact the response puts on the wire as `X-Cache: HIT`, and what it is worth is the
|
|
515
|
-
* deployment's to decide — an area may price a hit lower, or not distinguish one at all.
|
|
516
|
-
*/
|
|
517
|
-
cached: boolean;
|
|
518
|
-
req: SSRRequest;
|
|
519
|
-
spaceId: number;
|
|
520
|
-
environment: Environment;
|
|
521
|
-
revision: number;
|
|
522
|
-
}
|
|
523
|
-
/** What the deployment decided about this request. */
|
|
524
|
-
export type SSRMeterDecision = {
|
|
525
|
-
/** This space is over the quota its plan allows and the render should say so — the "Made with Plitzi" badge
|
|
526
|
-
* on the free tier. Paid plans accrue overage instead and never set this. */
|
|
527
|
-
degrade?: boolean;
|
|
528
|
-
/** Client reporting channel, injected into the page bootstrap. Omitted → the page reports nothing. Only a
|
|
529
|
-
* page render has anywhere to put it; the other kinds answer data, not a document. */
|
|
530
|
-
analytics?: AnalyticsConfig;
|
|
531
|
-
};
|
|
532
|
-
/** What a server that RENDERS PAGES must answer: the two adapters every page request goes through, on top of the
|
|
533
|
-
* optional rest. Stated as its own type rather than by making them required for everyone, because "required" is
|
|
534
|
-
* a property of the surface being served and not of the adapter set — a dedicated MCP server has no page request
|
|
535
|
-
* to resolve, and the old shape made it hand over two adapters nothing would ever call. */
|
|
536
|
-
export type SSRPageAdapters = SSRAdapters & Required<Pick<SSRAdapters, 'getOfflineData' | 'getSpaceDeployment'>>;
|
|
537
|
-
/**
|
|
538
|
-
* Everything an RSC read is given: which space and revision, who is asking, and which elements want data.
|
|
539
|
-
*
|
|
540
|
-
* One object rather than six positional parameters, because the reason to add to it is exactly the reason the
|
|
541
|
-
* positional form failed — `loadOfflineData` is a seventh thing to know, and nobody should have to count commas to
|
|
542
|
-
* reach it, nor rewrite their adapter when an eighth arrives.
|
|
543
|
-
*/
|
|
544
|
-
export interface SSRRscContext {
|
|
545
|
-
req: SSRRequest;
|
|
546
|
-
spaceId: number;
|
|
547
|
-
environment: Environment;
|
|
548
|
-
revision: number;
|
|
549
|
-
/** Whoever the request carries, already resolved. */
|
|
550
|
-
user?: SSRUser;
|
|
551
|
-
/** On a partial refresh, the only element ids that want data. Absent means every one — the initial render. */
|
|
552
|
-
ids?: string[];
|
|
553
|
-
/**
|
|
554
|
-
* The space itself, read at most once per request however many times this is called.
|
|
555
|
-
*
|
|
556
|
-
* It is here because an adapter almost always needs the schema (to know which elements are server-rendered, or
|
|
557
|
-
* whether RSC is on at all) and the server is already loading it for the page — in parallel with this very call.
|
|
558
|
-
* Without a shared handle every deployment fetched it a second time, or wrote its own in-flight dedup to avoid
|
|
559
|
-
* doing so. Awaiting this joins the read already under way; it never starts a second one.
|
|
560
|
-
*/
|
|
561
|
-
loadOfflineData: () => Promise<OfflineDataRaw | undefined>;
|
|
562
|
-
/**
|
|
563
|
-
* What the layers above the space decide about its flags for this request: the server's own and, on a page allowed
|
|
564
|
-
* to debug, a tester's. An element gated off by a flag is not resolved — `resolveRscData` resolves the flags
|
|
565
|
-
* against the page it matched and skips it — so a feature that is off puts nothing in the payload.
|
|
566
|
-
*/
|
|
567
|
-
flagOverrides?: FlagOverrides;
|
|
568
|
-
/**
|
|
569
|
-
* Aborted when whoever asked stops waiting — a browser that hung up, a refresh superseded by a newer one, a STOP — so
|
|
570
|
-
* what it asked for stops being worked on, here and in the runs it started.
|
|
571
|
-
*/
|
|
572
|
-
signal?: AbortSignal;
|
|
573
|
-
}
|
|
574
|
-
/**
|
|
575
|
-
* Which published version of a space is asking.
|
|
576
|
-
*
|
|
577
|
-
* Absent means the live one — the document the builder edits. Present means a page PUBLISHED at that revision,
|
|
578
|
-
* which must read the private documents it was published against: a page shipped yesterday running whatever the
|
|
579
|
-
* action says today, or reading through a manifest since pointed at a different API, is the discrepancy
|
|
580
|
-
* versioning exists to remove.
|
|
581
|
-
*
|
|
582
|
-
* One type for actions and connectors, because it is one concept: a version of a space.
|
|
583
|
-
*/
|
|
584
|
-
export type SpaceRevision = {
|
|
585
|
-
environment: Environment;
|
|
586
|
-
revision: number;
|
|
587
|
-
};
|
|
588
|
-
/**
|
|
589
|
-
* How the server reaches a space's actions, and what it may run.
|
|
590
|
-
*
|
|
591
|
-
* Typed loosely for the same reason `ConnectorLookupsConfig` is — the document is executed by
|
|
592
|
-
* `@plitzi/sdk-server`'s actions module and the shared types stay free of its internals. Shaped as `ActionLookups`
|
|
593
|
-
* there.
|
|
594
|
-
*/
|
|
595
|
-
export type ActionLookupsConfig = {
|
|
596
|
-
getAction: (spaceId: number, actionId: string, at?: SpaceRevision) => Promise<unknown>;
|
|
597
|
-
listActions?: (spaceId: number, at?: SpaceRevision) => Promise<unknown[]>;
|
|
598
|
-
/** Which spaces have something scheduled — the periodic reconcile's safety net. See `ActionLookups`. */
|
|
599
|
-
listScheduledSpaces?: () => Promise<number[]>;
|
|
600
|
-
getCredential?: (spaceId: number, identifier: string) => Promise<Record<string, string> | undefined>;
|
|
601
|
-
getConnector?: (spaceId: number, connectorId: string, at?: SpaceRevision) => Promise<unknown>;
|
|
602
|
-
/** The space's own functions as of that revision — `SpaceFunctions` in `@plitzi/sdk-server/functions`. */
|
|
603
|
-
getFunctions?: (spaceId: number, at?: SpaceRevision) => Promise<unknown>;
|
|
604
|
-
/** The server halves of the plugins the space uses, by plugin type — a `SpaceFunctions` each. */
|
|
605
|
-
getPluginFunctions?: (spaceId: number, at?: SpaceRevision) => Promise<unknown>;
|
|
606
|
-
/**
|
|
607
|
-
* The space's own data as of that revision — what a project keeps in `src/data/`, kept privately and frozen with each
|
|
608
|
-
* publish — as its files' text by path (`products.json`). A provider resolved on the server whose `query` is
|
|
609
|
-
* `/data/<file>` reads it, and a function's `ctx.data`; no browser is answered it. Given none, `dataDir` is read.
|
|
610
|
-
*/
|
|
611
|
-
getData?: (spaceId: number, at?: SpaceRevision) => Promise<unknown>;
|
|
612
|
-
/** The feature flags the space declares as of that revision — what a flow reads as `{{ flags.<name> }}`. */
|
|
613
|
-
getFlags?: (spaceId: number, at?: SpaceRevision) => Promise<Schema['flags']>;
|
|
614
|
-
};
|
|
615
|
-
export type SSRActionConfig = {
|
|
616
|
-
/** URL path for the write endpoint, and the base for the action-addressed routes. Defaults to '/_action'. */
|
|
617
|
-
path?: string;
|
|
618
|
-
/**
|
|
619
|
-
* Supplying these is what turns server actions on: without a way to read a document there is nothing to run, and
|
|
620
|
-
* the endpoint keeps answering element-addressed connector writes alone.
|
|
621
|
-
*/
|
|
622
|
-
lookups?: ActionLookupsConfig;
|
|
623
|
-
/** Ceilings for every run this server accepts. A document may tighten them, never widen them. */
|
|
624
|
-
limits?: ActionLimits;
|
|
625
|
-
/**
|
|
626
|
-
* Concurrency ceilings.
|
|
627
|
-
*
|
|
628
|
-
* `perSpace`/`perProcess` count CALLS — a click, a webhook, a schedule — where one run is somebody asking for
|
|
629
|
-
* work and one space's callers must not starve another's. A `render` is counted only by `renderPerProcess`,
|
|
630
|
-
* because it arrives because people are reading the page: a ceiling per space there would refuse the five
|
|
631
|
-
* hundredth visitor of a page that is simply doing well.
|
|
632
|
-
*/
|
|
633
|
-
concurrency?: {
|
|
634
|
-
perSpace?: number;
|
|
635
|
-
perProcess?: number;
|
|
636
|
-
renderPerProcess?: number;
|
|
637
|
-
};
|
|
638
|
-
/** Inbound webhooks are public by construction, so they are counted per caller per minute. Default 60. */
|
|
639
|
-
rateLimit?: {
|
|
640
|
-
webhookPerMinute?: number;
|
|
641
|
-
};
|
|
642
|
-
/**
|
|
643
|
-
* Database engines a flow may reach, shaped as `ActionDbDriver` in `@plitzi/sdk-server/actions`.
|
|
644
|
-
*
|
|
645
|
-
* Omitted leaves the `db.query` task unregistered entirely. What a driver connects to is always a database the
|
|
646
|
-
* SPACE declared as a credential — never this deployment's own, which no credential a space holds can name.
|
|
647
|
-
*/
|
|
648
|
-
dbDrivers?: unknown[];
|
|
649
|
-
/**
|
|
650
|
-
* The limits on `email.send`, which sends through the SMTP credential a step names, and optionally how a message
|
|
651
|
-
* leaves. Omitted keeps the defaults: 200 messages per space per day, no SMTP host on a private network, and the
|
|
652
|
-
* server's own SMTP connection. See {@link ActionEmailConfig}.
|
|
653
|
-
*/
|
|
654
|
-
email?: ActionEmailConfig;
|
|
655
|
-
/**
|
|
656
|
-
* Called once per run that STARTED — completed, failed or aborted — for a deployment that keeps a record.
|
|
657
|
-
* Shaped as `ActionRunRecord` in `@plitzi/sdk-server/actions`.
|
|
658
|
-
*
|
|
659
|
-
* A refused request is not a run and is not reported here; it goes to {@link SSRActionConfig.onReject}.
|
|
660
|
-
*/
|
|
661
|
-
onRun?: (record: ActionRunRecord) => void | Promise<void>;
|
|
662
|
-
/**
|
|
663
|
-
* Called once per request that was REFUSED before it became a run — a webhook whose signature did not verify, a
|
|
664
|
-
* caller over the rate limit, an action nobody may start. Shaped as `ActionRejectRecord`.
|
|
665
|
-
*
|
|
666
|
-
* Its own hook because it answers a different question from `onRun`: runs are history, refusals are a fault
|
|
667
|
-
* report, and the one that matters most — a signature that does not match — is otherwise indistinguishable
|
|
668
|
-
* from the integration simply never firing. Everything is reported; which refusals are worth keeping (a
|
|
669
|
-
* duplicate delivery is a polite retry, not a fault) is the deployment's to decide.
|
|
670
|
-
*/
|
|
671
|
-
onReject?: (record: ActionRejectRecord) => void | Promise<void>;
|
|
672
|
-
/**
|
|
673
|
-
* Replaying a finished run's answer to a caller that asks again with the same key, for this many milliseconds.
|
|
674
|
-
*
|
|
675
|
-
* Off unless set, and it only ever applies to a key the CALLER named — an `idempotencyKey` on the call or the
|
|
676
|
-
* delivery id a webhook sender stamps. Single-flight already refuses a retry that arrives while the first run
|
|
677
|
-
* is going; this is for the one that arrives after it finished, which is how every provider retries.
|
|
678
|
-
*/
|
|
679
|
-
idempotency?: {
|
|
680
|
-
replayTtlMs?: number;
|
|
681
|
-
};
|
|
682
|
-
/**
|
|
683
|
-
* What each space's functions sign with (`ctx.sign` / `ctx.verify`): at least 32 characters, the same on every
|
|
684
|
-
* replica. Each space and environment signs with a key derived from it. Absent, spaces sign nothing.
|
|
685
|
-
*/
|
|
686
|
-
signingSecret?: string;
|
|
687
|
-
/**
|
|
688
|
-
* Where the `kv` tasks keep things — shaped as `ActionKvAdapter` in `@plitzi/sdk-server/actions`.
|
|
689
|
-
*
|
|
690
|
-
* Six operations over strings, with no rule to obey: Redis, Memcached, a table, whatever this deployment
|
|
691
|
-
* already runs. How a counter BEHAVES — the key prefixing, the JSON round trip, and the rule that a window's
|
|
692
|
-
* lifetime is set once by whoever created it — belongs to the server, not to the thing it writes into.
|
|
693
|
-
*
|
|
694
|
-
* Omitted leaves an in-process Map, which counts only its own replica. That is fine for one; for a cluster it is
|
|
695
|
-
* a rate limit that multiplies by the number of them, so a multi-replica deployment supplies a shared one.
|
|
696
|
-
*/
|
|
697
|
-
kv?: {
|
|
698
|
-
get: (key: string) => Promise<string | undefined>;
|
|
699
|
-
set: (key: string, value: string, ttlSeconds?: number) => Promise<void>;
|
|
700
|
-
delete: (key: string) => Promise<void>;
|
|
701
|
-
increment: (key: string, amount: number) => Promise<number>;
|
|
702
|
-
expire: (key: string, ttlSeconds: number) => Promise<void>;
|
|
703
|
-
/** Writes `next` only if the key holds `expected` (nothing, when undefined); answers whether it wrote. Atomic. */
|
|
704
|
-
swap: (key: string, expected: string | undefined, next: string, ttlSeconds?: number) => Promise<boolean>;
|
|
705
|
-
};
|
|
706
|
-
/**
|
|
707
|
-
* Scheduled runs: the durable queue they wait in, how many this replica runs at once, and whether it produces.
|
|
708
|
-
*
|
|
709
|
-
* On wherever `lookups.listActions` is answerable — a `schedule` trigger the editor offers is a trigger the
|
|
710
|
-
* server honours, which before this it only did if the deployment wrote a timer and a distributed lock of its
|
|
711
|
-
* own. With no `queue` it runs over this process's memory: right for one replica, and wrong for two, because
|
|
712
|
-
* each then keeps its own schedules and the nightly email goes out once per replica.
|
|
713
|
-
*
|
|
714
|
-
* `false` turns it off for a replica that must only serve pages.
|
|
715
|
-
*/
|
|
716
|
-
jobs?: SSRActionJobsConfig | false;
|
|
717
|
-
};
|
|
718
|
-
/**
|
|
719
|
-
* How this deployment runs what a clock starts.
|
|
720
|
-
*
|
|
721
|
-
* Every default here is a safe one for a single machine; the two a cluster has to think about are `queue` — which
|
|
722
|
-
* must be shared, or the replicas do not see each other's work — and `workers`, which is how fast a backlog
|
|
723
|
-
* drains. Nothing in this config is a clock: the queue's own is the only one the scheduling path reads, so
|
|
724
|
-
* replicas in different countries agree about what has run without agreeing about what time it is.
|
|
725
|
-
*/
|
|
726
|
-
export type SSRActionJobsConfig = {
|
|
727
|
-
/** Shaped as `JobQueue`. Omitted → this process's memory. */
|
|
728
|
-
queue?: JobQueue;
|
|
729
|
-
/** Jobs this replica runs at once. Default 4; `0` produces without consuming. */
|
|
730
|
-
workers?: number;
|
|
731
|
-
/** Whether this replica sweeps due schedules into the queue. Default true. */
|
|
732
|
-
produce?: boolean;
|
|
733
|
-
/** The spaces this server schedules for, when it serves a known few — the self-hosted shape. */
|
|
734
|
-
spaces?: number[];
|
|
735
|
-
/** How often a free worker looks for a job. Default 1s. */
|
|
736
|
-
pollMs?: number;
|
|
737
|
-
/** How often this replica looks for due schedules. Default 15s. */
|
|
738
|
-
schedulePollMs?: number;
|
|
739
|
-
/** How long a claim is held before another replica may take the job over — the failover window. Default 30s. */
|
|
740
|
-
leaseMs?: number;
|
|
741
|
-
/** Attempts a job gets before it is left for an operator as `dead`. Default 3. */
|
|
742
|
-
maxAttempts?: number;
|
|
743
|
-
/** First retry delay, doubling per attempt, up to `maxMs`. Defaults to 30s and 15 minutes. */
|
|
744
|
-
backoff?: {
|
|
745
|
-
baseMs?: number;
|
|
746
|
-
maxMs?: number;
|
|
747
|
-
};
|
|
748
|
-
/** Which environment scheduled runs execute in. Default `main`. */
|
|
749
|
-
environment?: Environment;
|
|
750
|
-
/** How often schedules are re-derived from documents. Default 15 minutes. */
|
|
751
|
-
reconcileMs?: number;
|
|
752
|
-
/** Names this replica in the job history. Defaults to the pid and a random suffix. */
|
|
753
|
-
workerId?: string;
|
|
754
|
-
onError?: (error: unknown) => void;
|
|
755
|
-
};
|
|
756
|
-
/**
|
|
757
|
-
* How the server reaches a space's connectors: the manifest that describes one, and the credential it authenticates
|
|
758
|
-
* with. Shaped as `ConnectorLookups` in `@plitzi/sdk-server`; typed loosely here so the shared types stay free of the
|
|
759
|
-
* server's internals.
|
|
760
|
-
*
|
|
761
|
-
* Top-level, and not under `action`, because BOTH directions need them. Supplying them is what makes the write
|
|
762
|
-
* endpoint able to authorize a write — a write can only be checked against a manifest — and it is also all the server
|
|
763
|
-
* needs to answer a server-driven element's READ, so `adapters.getRscData` is derived from them unless a deployment
|
|
764
|
-
* supplies its own. They lived under `action` when writes were the only caller, which left every deployment building
|
|
765
|
-
* that read half by hand out of `createConnectorResolver` and `resolveRscData` — from these very lookups, passed a
|
|
766
|
-
* second time.
|
|
767
|
-
*/
|
|
768
|
-
export type ConnectorLookupsConfig = {
|
|
769
|
-
getConnector: (spaceId: number, connectorId: string, at?: SpaceRevision) => Promise<unknown>;
|
|
770
|
-
getCredential?: (spaceId: number, identifier: string) => Promise<Record<string, string> | undefined>;
|
|
771
|
-
fetchImpl?: typeof fetch;
|
|
772
|
-
};
|
|
773
|
-
export type SSRHealthConfig = {
|
|
774
|
-
path?: string;
|
|
775
|
-
/** Replaces the identity payload entirely. `check` still merges over it. */
|
|
776
|
-
payload?: Record<string, unknown>;
|
|
777
|
-
name?: string;
|
|
778
|
-
version?: string;
|
|
779
|
-
role?: string;
|
|
780
|
-
/**
|
|
781
|
-
* Live state, read on every probe and merged over the payload — the stores this process depends on, a queue
|
|
782
|
-
* depth, whatever only this deployment can know. Returning `healthy: false` answers **503**, which is what turns
|
|
783
|
-
* the endpoint from a liveness check into a readiness one: an orchestrator stops routing to a replica whose
|
|
784
|
-
* database has gone, instead of sending it traffic it can only fail.
|
|
785
|
-
*
|
|
786
|
-
* A check that throws is itself an unhealthy answer, and is reported as one rather than as a 500.
|
|
787
|
-
*/
|
|
788
|
-
check?: () => Record<string, unknown> | Promise<Record<string, unknown>>;
|
|
789
|
-
};
|
|
790
|
-
/** Response compression. Every field has a default; supply only what this deployment wants different. */
|
|
791
|
-
export type SSRCompressionConfig = {
|
|
792
|
-
/**
|
|
793
|
-
* Which encodings this server will use, most preferred first — the first one the client accepts wins. Default
|
|
794
|
-
* `['br', 'gzip']`. `['gzip']` for a client or proxy that mishandles Brotli; `[]` disables compression, same as
|
|
795
|
-
* `compression: false`.
|
|
796
|
-
*/
|
|
797
|
-
encodings?: ('br' | 'gzip')[];
|
|
798
|
-
/** Responses smaller than this many bytes go out uncompressed. Default 1024. */
|
|
799
|
-
threshold?: number;
|
|
800
|
-
/**
|
|
801
|
-
* Brotli quality, 0–11, for a body compressed on every request — a page rendered for this request alone. Default 5:
|
|
802
|
-
* the first quality under gzip's size for the CPU gzip spends — 2 came out larger than gzip on a 220 KB page (36 KB
|
|
803
|
-
* against 31; 5: 29). On half a core it costs ~0.1 ms a page, 5–8% of the pages a second of a 6 KB page.
|
|
804
|
-
*/
|
|
805
|
-
brotliQuality?: number;
|
|
806
|
-
/**
|
|
807
|
-
* Brotli quality, 0–11, for a body compressed once and kept — a cached page, a static file such as the SDK bundle.
|
|
808
|
-
* Default 6: paid once, and every later response is that much smaller (the SDK bundle 10% under quality 4), for
|
|
809
|
-
* the same memory as 4. 9 needs ~40 MB more to compress the bundle, which a 128 MB server does not have; 10 and
|
|
810
|
-
* 11 cost seconds, which the request that fills the cache would wait for.
|
|
811
|
-
*/
|
|
812
|
-
keptBrotliQuality?: number;
|
|
813
|
-
/** Gzip level, 0–9. Default 6. */
|
|
814
|
-
gzipLevel?: number;
|
|
815
|
-
};
|
|
816
|
-
export type SSRRscConfig = {
|
|
817
|
-
/** Whether the RSC endpoint is active. Defaults to true when adapters.getRscData is provided. */
|
|
818
|
-
enabled?: boolean;
|
|
819
|
-
/** URL path for the RSC endpoint. Defaults to '/_rsc'. */
|
|
820
|
-
path?: string;
|
|
821
|
-
/** Server-side cache TTL for RSC responses in milliseconds. Defaults to 30 000. Set to 0 to disable. */
|
|
822
|
-
cacheTtlMs?: number;
|
|
823
|
-
/**
|
|
824
|
-
* How long ONE server element may take before the page is answered without it. Defaults to 5 000.
|
|
825
|
-
*
|
|
826
|
-
* It is the page's ceiling, and it wins over the producer's own: an action may be allowed ten seconds of its
|
|
827
|
-
* own (`action.limits.timeoutMs`) and still be cut off here, because a section is worth waiting for only as
|
|
828
|
-
* long as the visitor is. Whichever is tighter decides, and now that the budget CANCELS what it stops waiting
|
|
829
|
-
* for, being cut here ends the run rather than leaving it to finish for nobody.
|
|
830
|
-
*
|
|
831
|
-
* Raise it for a deployment whose sections are genuinely slow and worth the wait; lower it to keep a page fast
|
|
832
|
-
* at the cost of showing more empty sections when a provider is having a bad day.
|
|
833
|
-
*/
|
|
834
|
-
elementTimeoutMs?: number;
|
|
835
|
-
};
|
|
836
|
-
/** What every log event carries, whatever layer it came from. */
|
|
837
|
-
/**
|
|
838
|
-
* How much a server says, from least to most: each level includes every one above it. `error` is what a production
|
|
839
|
-
* server shows unless told otherwise — something went wrong — and `warn`, `info` (every request answered, every
|
|
840
|
-
* plugin built) and `debug` are asked for. `silent` says nothing at all.
|
|
841
|
-
*/
|
|
842
|
-
export type LogLevel = 'error' | 'warn' | 'info' | 'debug';
|
|
843
|
-
type ServerLogEventBase = {
|
|
844
|
-
/** Wall-clock duration of the work the event describes, in milliseconds. */
|
|
845
|
-
durationMs: number;
|
|
846
|
-
/** False when the work threw or answered an error status. */
|
|
847
|
-
ok: boolean;
|
|
848
|
-
/** The error message when `ok` is false — never the request payload. */
|
|
849
|
-
error?: string;
|
|
850
|
-
/** ISO-8601 timestamp of when the event was emitted. */
|
|
851
|
-
timestamp: string;
|
|
852
|
-
};
|
|
853
|
-
/** One HTTP request served by ANY Plitzi server — SSR pages, RSC, plugin assets, the preview endpoint, MCP —
|
|
854
|
-
* emitted by the dispatcher once the request is answered, including the ones that failed or were rejected. */
|
|
855
|
-
export type ServerRequestLogEvent = ServerLogEventBase & {
|
|
856
|
-
kind: 'request';
|
|
857
|
-
/** Which server answered — the dispatcher label, e.g. 'SSR' or 'MCP'. */
|
|
858
|
-
server: string;
|
|
859
|
-
method: string;
|
|
860
|
-
/** Request path with query VALUES stripped and only the keys kept, e.g. '/search?q&page'. */
|
|
861
|
-
path: string;
|
|
862
|
-
/** The operation inside the request, when the answering stage names one — e.g. the MCP JSON-RPC method. */
|
|
863
|
-
operation?: string;
|
|
864
|
-
/** The HTTP status the server answered with. */
|
|
865
|
-
status: number;
|
|
866
|
-
/** The client the request came from, resolved through the proxies the deployment sits behind. Empty when no
|
|
867
|
-
* address could be determined. It IS personal data — see the note on {@link ServerLogEvent}. */
|
|
868
|
-
clientIp?: string;
|
|
869
|
-
};
|
|
870
|
-
/** One plitzi_* tool call inside an MCP request. Reported separately from the request because a failing tool
|
|
871
|
-
* still answers HTTP 200 — the failure lives in the JSON-RPC payload, so only this event exposes it. */
|
|
872
|
-
export type McpToolLogEvent = ServerLogEventBase & {
|
|
873
|
-
kind: 'tool';
|
|
874
|
-
/** The tool name, e.g. 'plitzi_apply'. */
|
|
875
|
-
name: string;
|
|
876
|
-
/** A compact SHAPE summary of the arguments — keys, value types and array lengths, never values. Set
|
|
877
|
-
* `MCP_LOG_ARGS=1` to dump the real arguments instead; they may carry user content, so it stays opt-in. */
|
|
878
|
-
argsSummary?: string;
|
|
879
|
-
};
|
|
880
|
-
/** One plitzi:// resource read inside an MCP request, named by the URI the request asked for. */
|
|
881
|
-
export type McpResourceLogEvent = ServerLogEventBase & {
|
|
882
|
-
kind: 'resource';
|
|
883
|
-
/** The resource URI that was read, e.g. 'plitzi://element/hero_1'. */
|
|
884
|
-
name: string;
|
|
885
|
-
};
|
|
886
|
-
/** One server action run that STARTED — completed, failed or aborted.
|
|
887
|
-
*
|
|
888
|
-
* Its own event rather than a line on the request that triggered it, for the same reason a tool call is: the
|
|
889
|
-
* request is answered either way, and a run started by a schedule or a webhook has a request that says nothing
|
|
890
|
-
* about it. Where the request log answers "was this call served", this answers "what did the flow do".
|
|
891
|
-
*
|
|
892
|
-
* Carries the SHAPE of the run and never its data: which steps ran and how each ended, never what they
|
|
893
|
-
* returned. A refused run is absent by design — a 409 is not a run, and logging one buries the real ones under
|
|
894
|
-
* retries. */
|
|
895
|
-
export type ActionRunLogEvent = ServerLogEventBase & {
|
|
896
|
-
kind: 'run';
|
|
897
|
-
/** The action's identifier, as the space stores it. */
|
|
898
|
-
name: string;
|
|
899
|
-
spaceId: number;
|
|
900
|
-
environment: Environment;
|
|
901
|
-
/** What started it: a page call, a webhook, a schedule, a render, a trigger the deployment mounted. */
|
|
902
|
-
trigger: ActionTriggerType;
|
|
903
|
-
status: ActionRunStatus;
|
|
904
|
-
/** Who asked, when a session carried it. Absent for a webhook, a schedule or an anonymous visitor. */
|
|
905
|
-
userId?: number;
|
|
906
|
-
/** Each step as `action:status`, in order — enough to see where a flow stopped without keeping what it held. */
|
|
907
|
-
steps: string[];
|
|
908
|
-
};
|
|
909
|
-
/** One request that was REFUSED before it became a run — a webhook whose signature did not verify, a caller over
|
|
910
|
-
* its rate limit, an action nobody may start.
|
|
911
|
-
*
|
|
912
|
-
* Separate from {@link ActionRunLogEvent} because it is a different question: that one says what a flow did,
|
|
913
|
-
* this one says why a flow never happened. It is the only place an integration that is failing at the door
|
|
914
|
-
* shows up at all — the request log answers 401 and says nothing about which check refused it.
|
|
915
|
-
*
|
|
916
|
-
* `durationMs` is 0 and `ok` is always false: nothing ran, and a refusal is not a success on anybody's dashboard. */
|
|
917
|
-
export type ActionRejectLogEvent = ServerLogEventBase & {
|
|
918
|
-
kind: 'reject';
|
|
919
|
-
/** The action's identifier, as the request named it — it need not exist. */
|
|
920
|
-
name: string;
|
|
921
|
-
spaceId: number;
|
|
922
|
-
environment: Environment;
|
|
923
|
-
trigger: ActionTriggerType;
|
|
924
|
-
/** Which check refused it. */
|
|
925
|
-
reason: ActionRejectReason;
|
|
926
|
-
/** Who asked, as the transport identifies them — a session subject or an address. */
|
|
927
|
-
callerId?: string;
|
|
928
|
-
};
|
|
929
|
-
/** Everything a Plitzi server reports about the work it does, as ONE stream: the HTTP requests it answers, plus
|
|
930
|
-
* the MCP tool calls, resource reads and server-action runs that happen inside them. Wire a single sink via
|
|
931
|
-
* `SSRServerConfig.logger` and switch on `kind` — a consumer can render it, ship it to a dashboard or drop the
|
|
932
|
-
* kinds it does not want.
|
|
933
|
-
*
|
|
934
|
-
* Payload-free by construction: no headers, cookies, tokens nor request body ever reach an event, query values
|
|
935
|
-
* are stripped from paths, tool arguments are reduced to their shape and a run to its steps. Two fields are NOT
|
|
936
|
-
* anonymous and a consumer shipping these events must handle them accordingly: `clientIp` on a request event, and
|
|
937
|
-
* the request path, which is kept verbatim because it is what makes the log usable. */
|
|
938
|
-
/** Anything else the server has to say — a plugin rebuilt, a manifest that would not load — at its own level. */
|
|
939
|
-
export type ServerMessageLogEvent = {
|
|
940
|
-
kind: 'message';
|
|
941
|
-
level: LogLevel;
|
|
942
|
-
/** What is speaking: `SSR`, `RSC`, `Actions`, `auth`… — what a line used to start with in brackets. */
|
|
943
|
-
scope: string;
|
|
944
|
-
message: string;
|
|
945
|
-
ok: boolean;
|
|
946
|
-
error?: string;
|
|
947
|
-
timestamp: string;
|
|
948
|
-
};
|
|
949
|
-
export type ServerLogEvent = ServerRequestLogEvent | McpToolLogEvent | McpResourceLogEvent | ActionRunLogEvent | ActionRejectLogEvent | ServerMessageLogEvent;
|
|
950
|
-
/** The sink a consumer provides to receive every {@link ServerLogEvent} (see `SSRServerConfig.logger`). */
|
|
951
|
-
export type ServerLogger = (event: ServerLogEvent) => void;
|
|
952
|
-
export type SSRServerConfig = {
|
|
953
|
-
port?: number;
|
|
954
|
-
host?: string;
|
|
955
|
-
httpVersion?: 1 | 2 | 3;
|
|
956
|
-
tls?: {
|
|
957
|
-
key: Buffer | string;
|
|
958
|
-
cert: Buffer | string;
|
|
959
|
-
minVersion?: 'TLSv1' | 'TLSv1.1' | 'TLSv1.2' | 'TLSv1.3';
|
|
960
|
-
};
|
|
961
|
-
environment?: ServerEnvironment;
|
|
962
|
-
/** Served to anyone who asks, as it is: pictures, a favicon, what a page fetches in the browser. */
|
|
963
|
-
publicDir?: string;
|
|
964
|
-
/**
|
|
965
|
-
* The project's own data, never served as files: a provider resolved on the server (`runtime: 'server'`) whose
|
|
966
|
-
* `query` is `/data/<file>` reads `<dataDir>/<file>`, and the page arrives with it. Nobody downloads the folder; what
|
|
967
|
-
* a provider reads goes into the page it renders, though — data a page must not carry is a server action's to read,
|
|
968
|
-
* answering only what is shown: a function reads it with `ctx.data('<file>')`. It is the space's data lookup
|
|
969
|
-
* (`action.lookups.getData`) when the deployment gives none.
|
|
970
|
-
*/
|
|
971
|
-
dataDir?: string;
|
|
972
|
-
static?: Record<string, string>;
|
|
973
|
-
devMode?: boolean;
|
|
974
|
-
/**
|
|
975
|
-
* Every page this server renders listens for what changes under it: new documents for the space it shows, swapped
|
|
976
|
-
* where it stands (`updatePages`), or everything loaded again (`reloadPages`) — the edit loop of a project that
|
|
977
|
-
* authors its space in code, a page an agent keeps rewriting (`createAuthoringHost`). Off unless asked for, `devMode`
|
|
978
|
-
* included: each open page holds a connection to the server for it, which a server whose space never changes under
|
|
979
|
-
* it would only pay for.
|
|
980
|
-
*/
|
|
981
|
-
livePages?: boolean;
|
|
982
|
-
/** Authorizes debugging on the pages this server renders. An SSR page loads the very same SDK, so this is the
|
|
983
|
-
* server-side face of the SDK's `debugMode` prop: the page decides, and the visitor's 'plitzi_debug' cookie can
|
|
984
|
-
* only narrow it. Left unset, `devMode` authorizes it — a development server debugs without being told to — and
|
|
985
|
-
* so does a space whose settings switched `devTools` on. Set, it decides for every space: `false` is a refusal
|
|
986
|
-
* no space can turn around. */
|
|
987
|
-
debugMode?: boolean;
|
|
988
|
-
/**
|
|
989
|
-
* The feature flags this deployment decides, by name — the `server` layer: above what each space declares, below
|
|
990
|
-
* the SDK embedding a page and a tester with the dev tools. Only for flags a space declares; an override of one it
|
|
991
|
-
* does not is ignored, and the page says so in its console.
|
|
992
|
-
*
|
|
993
|
-
* A function when one server renders several spaces and they do not share their flags: it is asked per render.
|
|
994
|
-
*/
|
|
995
|
-
flags?: Record<string, boolean> | ((space: {
|
|
996
|
-
spaceId: number;
|
|
997
|
-
environment: Environment;
|
|
998
|
-
}) => Record<string, boolean>);
|
|
999
|
-
cacheTtlMs?: number;
|
|
1000
|
-
loginPath?: string | false;
|
|
1001
|
-
middlewares?: SSRMiddleware[];
|
|
1002
|
-
logoutPath?: string | false;
|
|
1003
|
-
/** Where a browser-obtained credential is handed over. Defaults to `/auth/exchange`; served only when the
|
|
1004
|
-
* `exchangeCredential` adapter is supplied. */
|
|
1005
|
-
exchangePath?: string | false;
|
|
1006
|
-
/**
|
|
1007
|
-
* Signing visitors in by redirect, through an OAuth 2.1 authorization server — see {@link SSRSignInConfig}. Served
|
|
1008
|
-
* only with the `exchangeCredential` adapter, which is what turns what comes back into a session on this host.
|
|
1009
|
-
*/
|
|
1010
|
-
signIn?: SSRSignInConfig;
|
|
1011
|
-
/**
|
|
1012
|
-
* The sign-in this server's pages are told about (`server.auth`), so a space that declares no `userProvider` signs
|
|
1013
|
-
* in with nothing to declare. `createServer({ auth })` fills it from the kernel's `basePath`; name it yourself when
|
|
1014
|
-
* the `/auth` flows are served by another host. The session hint cookie is added per request, named for the host.
|
|
1015
|
-
*/
|
|
1016
|
-
pageAuth?: Omit<ServerAuth, 'sessionHintCookie'>;
|
|
1017
|
-
/** Naming and scope of the session cookies this server writes. See {@link SSRAuthCookie}. */
|
|
1018
|
-
authCookie?: SSRAuthCookie;
|
|
1019
|
-
templateFn?: SSRTemplateFn;
|
|
1020
|
-
plugins?: Record<string, PluginSource>;
|
|
1021
|
-
/** Where the plugins it builds are kept. Default: `tmp/.sdk-plugins` under the working directory. */
|
|
1022
|
-
pluginsCacheDir?: string;
|
|
1023
|
-
pluginsTtlMs?: number;
|
|
1024
|
-
/** Auto-download and cache plugins declared in the schema's offlineData.plugins list. Default: true. */
|
|
1025
|
-
autoLoadSchemaPlugins?: boolean;
|
|
1026
|
-
/**
|
|
1027
|
-
* Whether a schema plugin may be read from a private address — `localhost`, the network this server runs in. A
|
|
1028
|
-
* plugin's address is typed by whoever edits a space and read from inside this server, so it answers to the rule
|
|
1029
|
-
* every authored request does and is refused there; turn this on only on a development machine whose bucket is on
|
|
1030
|
-
* localhost. Default: false.
|
|
1031
|
-
*/
|
|
1032
|
-
allowPrivatePluginHosts?: boolean;
|
|
1033
|
-
/** Where this deployment serves the font files a space uploaded — see {@link SSRFontsConfig}. */
|
|
1034
|
-
fonts?: SSRFontsConfig;
|
|
1035
|
-
/** Remote pictures resized by this server — see {@link SSRImagesConfig}. Absent, images keep their own `src`. */
|
|
1036
|
-
images?: SSRImagesConfig;
|
|
1037
|
-
/** Omit client-side JS from the rendered page — useful for verifying SSR HTML without hydration. Default: false. */
|
|
1038
|
-
ssrOnly?: boolean;
|
|
1039
|
-
/** Stream HTML to the client as React renders, reducing TTFB. Default: false. */
|
|
1040
|
-
streaming?: boolean;
|
|
1041
|
-
/** Controls iframe embedding via CSP frame-ancestors (and X-Frame-Options for legacy browsers).
|
|
1042
|
-
* 'DENY' — no site may embed this server (default).
|
|
1043
|
-
* 'SAMEORIGIN' — only the same origin may embed it.
|
|
1044
|
-
* string[] — explicit list of allowed origins, e.g. ['https://app.example.com', 'https://preview.example.com'].
|
|
1045
|
-
* false — no restriction; headers are omitted. */
|
|
1046
|
-
frameOptions?: 'DENY' | 'SAMEORIGIN' | string[] | false;
|
|
1047
|
-
/** RSC (React Server Components) endpoint configuration. */
|
|
1048
|
-
rsc?: SSRRscConfig;
|
|
1049
|
-
/** Write endpoint for server-driven providers. Absent means the server serves reads only. */
|
|
1050
|
-
action?: SSRActionConfig;
|
|
1051
|
-
/**
|
|
1052
|
-
* The server's code: its own (`native`), the server halves of the plugins it ships (`plugins`, by plugin type), the
|
|
1053
|
-
* runner the spaces' code runs on, and the ceilings. Built by `@plitzi/sdk-server/functions` (`loadFunctions`), and
|
|
1054
|
-
* checked as the server starts.
|
|
1055
|
-
*/
|
|
1056
|
-
functions?: {
|
|
1057
|
-
native?: unknown[];
|
|
1058
|
-
plugins?: Record<string, unknown>;
|
|
1059
|
-
runner?: unknown;
|
|
1060
|
-
limits?: Record<string, number>;
|
|
1061
|
-
/** What the spaces' jobs may spend, per space (its plan): see `FunctionJobLimits` in `@plitzi/sdk-server/functions`. */
|
|
1062
|
-
jobs?: {
|
|
1063
|
-
limitsFor?: (spaceId: number) => Promise<Record<string, unknown> | undefined>;
|
|
1064
|
-
};
|
|
1065
|
-
/** `ctx.oauth`: where providers send a visitor back — see `FunctionsConfig` in `@plitzi/sdk-server/functions`. */
|
|
1066
|
-
oauth?: {
|
|
1067
|
-
callbackOrigin?: string;
|
|
1068
|
-
};
|
|
1069
|
-
};
|
|
1070
|
-
/** Realtime channels the spaces declare — see {@link SSRRealtimeConfig}. On, in memory, when absent. */
|
|
1071
|
-
realtime?: SSRRealtimeConfig;
|
|
1072
|
-
/**
|
|
1073
|
-
* The writes a page of another origin may cause here. None, by default: a browser's POST, PUT, PATCH or DELETE that it
|
|
1074
|
-
* says a page of another origin caused (`Sec-Fetch-Site` `cross-site` or `same-site` — another port of this host, a
|
|
1075
|
-
* sibling sub-domain — or a foreign `Origin`) is refused 403 `reason: 'foreign'` —
|
|
1076
|
-
* a session cookie or none, because a server holding credentials of its own, or a tool nobody signs in to, acts for
|
|
1077
|
-
* whoever reaches it. A request with `Authorization`, and one that is not a browser's (a webhook, a script), are never
|
|
1078
|
-
* asked. With `auth`, the deployment's `identity.platformOrigins` count as its own too.
|
|
1079
|
-
*/
|
|
1080
|
-
crossSiteWrites?: {
|
|
1081
|
-
/** Origins whose pages may write here, exactly as a browser sends them — `https://app.example.com`. */
|
|
1082
|
-
origins?: string[];
|
|
1083
|
-
/** Paths any origin may post to: a form other sites embed by design. */
|
|
1084
|
-
paths?: (path: string) => boolean;
|
|
1085
|
-
};
|
|
1086
|
-
/** Connector manifest and credential lookups — see {@link ConnectorLookupsConfig}. They serve the RSC read path
|
|
1087
|
-
* and the `/_action` write endpoint alike; without them neither can reach a connector. */
|
|
1088
|
-
connectors?: ConnectorLookupsConfig;
|
|
1089
|
-
/** Receives a {@link ServerLogEvent} for every HTTP request this server answers — whatever stage answered it
|
|
1090
|
-
* and whatever the outcome — plus every MCP tool call and resource read inside those requests. Without it the
|
|
1091
|
-
* server reports nothing per request (the MCP events still reach the console when `MCP_DEBUG=1`). Everything
|
|
1092
|
-
* else the server has to say — a failure, a plugin rebuilt — comes here too as a `message` event, and goes to the
|
|
1093
|
-
* console when there is no logger. */
|
|
1094
|
-
logger?: ServerLogger;
|
|
1095
|
-
/**
|
|
1096
|
-
* The least severe thing worth saying — see {@link LogLevel}. `error` by default, `info` with `devMode`: a server
|
|
1097
|
-
* in production reports what went wrong and nothing else, unless asked. A request that was answered is `info`, one
|
|
1098
|
-
* that failed `error`; a refused action is `warn`. Below the level nothing is built, so a quiet server pays nothing
|
|
1099
|
-
* per request for the log it is not keeping.
|
|
1100
|
-
*/
|
|
1101
|
-
logLevel?: LogLevel | 'silent';
|
|
1102
|
-
/**
|
|
1103
|
-
* How responses are compressed. Omit for Brotli where the client takes it and gzip otherwise; `false` never
|
|
1104
|
-
* compresses, which is what to use when a proxy or CDN in front already does it.
|
|
1105
|
-
*/
|
|
1106
|
-
compression?: SSRCompressionConfig | false;
|
|
1107
|
-
/**
|
|
1108
|
-
* What to do when the server cannot take its port. Without it the server prints what went wrong, what to do about
|
|
1109
|
-
* it, and exits non-zero — because a process whose server never bound is not running, and the alternative is a raw
|
|
1110
|
-
* `EADDRINUSE` stack that says nothing about which port or which server.
|
|
1111
|
-
*
|
|
1112
|
-
* Supply this to keep the process alive and decide for yourself: an embedder that starts several servers, a
|
|
1113
|
-
* supervisor that retries, a test that asserts the failure. Handling it here replaces the exit entirely.
|
|
1114
|
-
*/
|
|
1115
|
-
onListenError?: (error: NodeJS.ErrnoException, context: {
|
|
1116
|
-
port: number;
|
|
1117
|
-
host: string;
|
|
1118
|
-
label: string;
|
|
1119
|
-
}) => void;
|
|
1120
|
-
/**
|
|
1121
|
-
* How many processes serve this port. Node runs JavaScript on one thread, so one process renders on one core however
|
|
1122
|
-
* many the machine has; each worker is a whole server of its own, and the connections are spread between them —
|
|
1123
|
-
* more requests a second, and less time waiting behind another render.
|
|
1124
|
-
*
|
|
1125
|
-
* `true` / `'auto'`: one per core the process may actually use (a container's CPU quota included). `false`: one
|
|
1126
|
-
* process. A number: that many, lowered to the cores there are (more only take turns on the same cores). Default: on
|
|
1127
|
-
* under `NODE_ENV=production`, off otherwise — a development server and a test runner stay one process. The
|
|
1128
|
-
* `SDK_SERVER_WORKERS` environment variable sets it when this does not.
|
|
1129
|
-
*
|
|
1130
|
-
* The workers are one server — one replica — and behave as one:
|
|
1131
|
-
*
|
|
1132
|
-
* - The stores kept in memory by default (an action's `kv`, the job queue, draft previews, the sign-in rate
|
|
1133
|
-
* limit) are the primary's, and each worker reaches them over the cluster channel. A store the deployment
|
|
1134
|
-
* supplies (Redis, a table) is used as it is.
|
|
1135
|
-
* - The scheduler and the job consumers run in one worker only, so a schedule fires once and `jobs.workers` is the
|
|
1136
|
-
* whole server's concurrency; if that worker dies, its replacement takes them over.
|
|
1137
|
-
* - `server.cache.invalidate()`, `server.plugins.register()` and `server.plugins.invalidate()` reach every worker,
|
|
1138
|
-
* whichever process calls them.
|
|
1139
|
-
*
|
|
1140
|
-
* Per worker: the rendered-page cache (each renders a page once), the plugin components, and the action run caps
|
|
1141
|
-
* (`action.concurrency`: `perSpace`, `perProcess`, `renderPerProcess`), which a cluster of replicas already counts
|
|
1142
|
-
* per replica. A plugin registered with a `component` stays in the process that registered it — register those
|
|
1143
|
-
* where the server is created.
|
|
1144
|
-
*/
|
|
1145
|
-
workers?: boolean | number | 'auto';
|
|
1146
|
-
adapters: SSRAdapters;
|
|
1147
|
-
/** Which request-handling services this server mounts: `ssr` on by default, `rsc` whenever
|
|
1148
|
-
* `adapters.getRscData` exists. Stages a companion package contributes are deliberately NOT flags here —
|
|
1149
|
-
* handing them over is the decision. Only createServer reads these as written; the surface factories pin what
|
|
1150
|
-
* their name promises (a page server serves pages; a dedicated MCP server serves MCP alone). */
|
|
1151
|
-
services?: ServerServices;
|
|
1152
|
-
/** Liveness/readiness endpoint for standalone servers (k8s probes). A stage always answers `path`
|
|
1153
|
-
* (default /health) with the generic identity payload built from `name`/`version`/`role`
|
|
1154
|
-
* ({ Server, Version, role }); pass an explicit `payload` to override it entirely, or `check` to add what can
|
|
1155
|
-
* only be known per request. See {@link SSRHealthConfig}. */
|
|
1156
|
-
health?: SSRHealthConfig;
|
|
1157
|
-
/** Cache-buster appended as ?v=<assetVersion> to all default SDK asset URLs (jsPath, cssPath, react vendor). Compute from file mtime or package version at startup. */
|
|
1158
|
-
assetVersion?: string;
|
|
1159
|
-
/** The draft-preview endpoint, and the store behind it. The draft is WRITTEN by an MCP tool and RENDERED here,
|
|
1160
|
-
* so this is the one piece of that feature the page server owns: `@plitzi/sdk-mcp` carries everything else in
|
|
1161
|
-
* its own options, and a deployment that never installs it leaves both unset.
|
|
1162
|
-
*
|
|
1163
|
-
* `preview` mounts the endpoint (off unless `enabled`); `draftStore` backs the tokens and defaults to an
|
|
1164
|
-
* in-memory store — inject a shared one (e.g. Redis) for multi-replica correctness. */
|
|
1165
|
-
preview?: SSRPreviewConfig;
|
|
1166
|
-
draftStore?: DraftStore;
|
|
1167
|
-
};
|
|
1168
|
-
/** The same config as seen by a server that serves PAGES: its adapters answer for a page request. This is what
|
|
1169
|
-
* `createServer` from `@plitzi/sdk-server` takes and what the SSR stages are handed, so a page stage reaches
|
|
1170
|
-
* `getOfflineData` without asking whether it is there — while a stage typed to the bare context (anything from
|
|
1171
|
-
* `@plitzi/sdk-mcp`, which also runs in servers that have neither) still has to check. */
|
|
1172
|
-
/**
|
|
1173
|
-
* A visitor signs in somewhere else and comes back signed in HERE: `GET <path>?return=/somewhere` sends them to the
|
|
1174
|
-
* authorization server, and `GET <path>/callback` takes the code it answers with, redeems it server to server and
|
|
1175
|
-
* hands the token to `exchangeCredential` — which is what makes the session, on this host, for this space.
|
|
1176
|
-
*
|
|
1177
|
-
* This server registers itself with the authorization server (RFC 7591) as the host the visitor is on, and proves the
|
|
1178
|
-
* exchange with PKCE. The state travels in a `__Host-` cookie, which no sibling host can set: a sign-in somebody else
|
|
1179
|
-
* started cannot be finished in this browser.
|
|
1180
|
-
*/
|
|
1181
|
-
export type SSRSignInConfig = {
|
|
1182
|
-
/** What `exchangeCredential` knows the tokens by. */
|
|
1183
|
-
provider: string;
|
|
1184
|
-
/** Where the visitor's browser is sent: the authorization server's `/authorize`, as the public reaches it. */
|
|
1185
|
-
authorizeUrl: string;
|
|
1186
|
-
/** Where this server registers itself and redeems codes — reachable from here, which may be a private address. */
|
|
1187
|
-
registerUrl: string;
|
|
1188
|
-
tokenUrl: string;
|
|
1189
|
-
/** What to ask for, for the space being signed into. */
|
|
1190
|
-
scope: (spaceId: number) => string;
|
|
1191
|
-
/** Where the flow answers. Default `/auth/sign-in`; the authorization server sends people back to `<path>/callback`. */
|
|
1192
|
-
path?: string;
|
|
1193
|
-
};
|
|
1194
|
-
export type SSRPageServerConfig = SSRServerConfig & {
|
|
1195
|
-
adapters: SSRPageAdapters;
|
|
1196
|
-
};
|
|
1197
309
|
/** Which surfaces a page server mounts. Only what the page pipeline itself owns: the MCP endpoint and
|
|
1198
310
|
* draft-preview are stages a companion package hands in, so they are not flags here. */
|
|
1199
311
|
export type ServerServices = {
|
|
@@ -1202,6 +314,8 @@ export type ServerServices = {
|
|
|
1202
314
|
};
|
|
1203
315
|
export type PluginRegistry = {
|
|
1204
316
|
register: (name: string, source: PluginSource) => void;
|
|
317
|
+
/** A plugin no longer there — its folder removed under a dev server: never built or served again. */
|
|
318
|
+
unregister: (name: string) => void;
|
|
1205
319
|
invalidate: (name?: string, version?: string) => Promise<void>;
|
|
1206
320
|
};
|
|
1207
321
|
export type CacheFilter = {
|
|
@@ -1227,6 +341,16 @@ export type SSRContext = {
|
|
|
1227
341
|
* refresh is done, and handed on only to a page whose debugging is authorized.
|
|
1228
342
|
*/
|
|
1229
343
|
actionRuns?: ActionRunSummary[];
|
|
344
|
+
/**
|
|
345
|
+
* This server previews a run of agents and answers its snapshot at `RUN_STATUS_PATH` (`plitzi run preview`): said to a
|
|
346
|
+
* page that may debug, so its dev tools ask for the run — and no other page's ask a server that has none.
|
|
347
|
+
*/
|
|
348
|
+
runStatus?: true;
|
|
349
|
+
/**
|
|
350
|
+
* This request renders a draft session minted for a test runner (`DraftEntry.inspected`): the page carries the
|
|
351
|
+
* space's state bridge, `window.__plitzi`, with no panel or badge.
|
|
352
|
+
*/
|
|
353
|
+
inspectedDraft?: true;
|
|
1230
354
|
/**
|
|
1231
355
|
* What a refresh of server data asked for beside the page's own address (`/_rsc?location=…&q=…`): a provider's
|
|
1232
356
|
* `input`, a page window. What the provider asks for this time, so it wins over the `input` the element was saved
|
|
@@ -1266,312 +390,3 @@ export type SSRServer = {
|
|
|
1266
390
|
setPlugin: (plugin: string, definition: unknown) => void;
|
|
1267
391
|
};
|
|
1268
392
|
};
|
|
1269
|
-
/** A key/value store with per-entry expiry, backing the OAuth layer's short-lived protocol state (registered
|
|
1270
|
-
* clients, authorization codes, refresh grants). Values are opaque strings the SDK serialises itself. A
|
|
1271
|
-
* multi-replica deployment MUST inject a shared implementation — a code minted on one replica is redeemed on
|
|
1272
|
-
* whichever replica the token request lands on. */
|
|
1273
|
-
export type OAuthStore = {
|
|
1274
|
-
put: (key: string, value: string, ttlSeconds: number) => void | Promise<void>;
|
|
1275
|
-
get: (key: string) => (string | undefined) | Promise<string | undefined>;
|
|
1276
|
-
drop: (key: string) => void | Promise<void>;
|
|
1277
|
-
};
|
|
1278
|
-
/** Someone who got through {@link OAuthAdapters.authenticate}. `id` is what the other adapters key off; `label`
|
|
1279
|
-
* is shown back on the consent screen so the user can see who they are about to grant access as. */
|
|
1280
|
-
export type OAuthUser = {
|
|
1281
|
-
id: string;
|
|
1282
|
-
label: string;
|
|
1283
|
-
};
|
|
1284
|
-
/** One thing the user may grant the client access to — a Plitzi space, or whatever else a deployment scopes its
|
|
1285
|
-
* tokens by. `value` is the opaque handle the SDK round-trips back to {@link OAuthAdapters.issueToken}; only the
|
|
1286
|
-
* consumer interprets it. A deployment whose public surface is useful on its own (plitzi_render needs no space)
|
|
1287
|
-
* can offer a target that grants nothing, so the user is never forced to pick one. */
|
|
1288
|
-
export type OAuthGrantTarget = {
|
|
1289
|
-
value: string;
|
|
1290
|
-
label: string;
|
|
1291
|
-
description?: string;
|
|
1292
|
-
};
|
|
1293
|
-
/** What the OAuth layer cannot resolve on its own: who the user is, what they may grant, and the bearer to mint
|
|
1294
|
-
* for them. The SDK owns the protocol (discovery, registration, PKCE, code exchange); the consumer owns identity
|
|
1295
|
-
* and issues a token its own `adapters.getGrant` will accept back. */
|
|
1296
|
-
export type OAuthAdapters = {
|
|
1297
|
-
/**
|
|
1298
|
-
* Who the browser making this request already is, from whatever session it carries.
|
|
1299
|
-
*
|
|
1300
|
-
* This server has no sign-in of its own: it reads an existing session and sends anyone it cannot identify to
|
|
1301
|
-
* {@link OAuthConfig.signInUrl}, which brings them back. That is what lets a deployment have ONE sign-in screen
|
|
1302
|
-
* for every surface — and it is what makes SSO somebody else's problem, because whatever established the
|
|
1303
|
-
* session is no longer this flow's business.
|
|
1304
|
-
*
|
|
1305
|
-
* It replaced a username/password form this server used to render and check itself. Two sign-ins against one
|
|
1306
|
-
* account store is two places to add a provider, to rate-limit, and to get a password check subtly wrong.
|
|
1307
|
-
*
|
|
1308
|
-
* Return undefined for "nobody is signed in". Never throw for that — an unreadable session is the ordinary
|
|
1309
|
-
* first visit.
|
|
1310
|
-
*/
|
|
1311
|
-
identify: (req: SSRRequest) => Promise<OAuthUser | undefined>;
|
|
1312
|
-
/**
|
|
1313
|
-
* What this user may grant access to. An empty list ends the flow with `access_denied`.
|
|
1314
|
-
*
|
|
1315
|
-
* `request.scope` is what the client asked for, so one deployment can offer different choices to different
|
|
1316
|
-
* clients — a native client signing in as the person, and the same client asking which space to work in.
|
|
1317
|
-
*/
|
|
1318
|
-
grantTargets: (user: OAuthUser, request: {
|
|
1319
|
-
scope?: string;
|
|
1320
|
-
}) => Promise<OAuthGrantTarget[]>;
|
|
1321
|
-
/**
|
|
1322
|
-
* End whatever session {@link OAuthAdapters.identify} was reading, so the person can connect as somebody else.
|
|
1323
|
-
*
|
|
1324
|
-
* Optional, and its absence is what takes the offer off the grant screen: a deployment that cannot end a session
|
|
1325
|
-
* from here should not show a button that pretends to. Clear the cookies on `res` and revoke at the source —
|
|
1326
|
-
* forgetting the cookie alone leaves the credential working for anyone who already copied it.
|
|
1327
|
-
*
|
|
1328
|
-
* Whoever reaches that screen arrived from another application, so this is the only way out of the wrong account
|
|
1329
|
-
* that does not mean abandoning the connection and starting over from the host.
|
|
1330
|
-
*/
|
|
1331
|
-
signOut?: (req: SSRRequest, res: SSRResponseHelpers) => void | Promise<void>;
|
|
1332
|
-
/** Mint the bearer the client will send on every request. Return undefined to deny the grant. */
|
|
1333
|
-
issueToken: (user: OAuthUser, target: OAuthGrantTarget, context: OAuthIssueContext) => Promise<{
|
|
1334
|
-
token: string;
|
|
1335
|
-
expiresInSeconds?: number;
|
|
1336
|
-
} | undefined>;
|
|
1337
|
-
/**
|
|
1338
|
-
* End a credential {@link OAuthAdapters.issueToken} minted, when its grant is revoked (RFC 7009).
|
|
1339
|
-
*
|
|
1340
|
-
* Optional, for a credential that ends on its own. Without it, revoking a grant stops it being RENEWED, and what
|
|
1341
|
-
* was already issued keeps working until it expires — which a person who just signed a device out reads as the
|
|
1342
|
-
* sign-out not having happened, because the device is still there in their list.
|
|
1343
|
-
*/
|
|
1344
|
-
revokeToken?: (credential: string) => Promise<void>;
|
|
1345
|
-
store: OAuthStore;
|
|
1346
|
-
};
|
|
1347
|
-
/**
|
|
1348
|
-
* Who a credential is being issued to, beyond the person: which application, from where, and — on a renewal — which
|
|
1349
|
-
* credential it takes the place of.
|
|
1350
|
-
*
|
|
1351
|
-
* This is what lets a deployment tell its user WHICH of their devices a credential lives on. The application names
|
|
1352
|
-
* itself when it registers (RFC 7591 `client_name`, `software_id`); the request is the one the credential is being
|
|
1353
|
-
* issued on — at consent, the person's browser, which for a loopback client is the same machine.
|
|
1354
|
-
*/
|
|
1355
|
-
export type OAuthIssueContext = {
|
|
1356
|
-
client: {
|
|
1357
|
-
clientId: string;
|
|
1358
|
-
/** What the application registered as: `Plitzi CLI on carlos-mbp`, `Claude`. */
|
|
1359
|
-
name: string;
|
|
1360
|
-
/** RFC 7591 `software_id`, when it sent one: a stable name for the SOFTWARE, the same on every machine. */
|
|
1361
|
-
softwareId?: string;
|
|
1362
|
-
};
|
|
1363
|
-
request?: {
|
|
1364
|
-
userAgent?: string;
|
|
1365
|
-
ip?: string;
|
|
1366
|
-
};
|
|
1367
|
-
/**
|
|
1368
|
-
* Where the code of THIS grant is sent: the `redirect_uri` of the authorization request, at consent. A deployment
|
|
1369
|
-
* whose credential is only good at certain addresses checks it here — registering a client is open to anybody, and
|
|
1370
|
-
* the address it names is the one thing that says who will receive what the person agreed to. Absent on a renewal.
|
|
1371
|
-
*/
|
|
1372
|
-
redirectUri?: string;
|
|
1373
|
-
/**
|
|
1374
|
-
* The credential this grant last issued, on a renewal. A deployment that keeps a row per credential updates that
|
|
1375
|
-
* row rather than adding one, so a device renewing every hour stays one device.
|
|
1376
|
-
*/
|
|
1377
|
-
replaces?: string;
|
|
1378
|
-
};
|
|
1379
|
-
/** A connection a visitor may take WITHOUT signing in, for a server whose public surface needs no identity — the
|
|
1380
|
-
* MCP App, the tool and resource listings, the guide. The consent screen offers it as a second button beside the
|
|
1381
|
-
* sign-in, and the grant is whatever `target` grants: point it at a target that carries no space, never at one
|
|
1382
|
-
* that does, since nobody proved who they are. */
|
|
1383
|
-
export type OAuthGuestConfig = {
|
|
1384
|
-
/** Handed straight to {@link OAuthAdapters.issueToken} when a visitor takes the guest connection. */
|
|
1385
|
-
target: OAuthGrantTarget;
|
|
1386
|
-
/** Button text. Defaults to 'Continue without an account'. */
|
|
1387
|
-
label?: string;
|
|
1388
|
-
/** Who the grant is issued as. Defaults to `{ id: 'guest', label: 'Guest' }`. */
|
|
1389
|
-
user?: OAuthUser;
|
|
1390
|
-
};
|
|
1391
|
-
/** What the grant screen shows around the form. */
|
|
1392
|
-
export type OAuthBranding = {
|
|
1393
|
-
/** Shown as the heading, e.g. 'Plitzi'. Defaults to 'Plitzi'. */
|
|
1394
|
-
productName?: string;
|
|
1395
|
-
/** Absolute or same-origin URL of a logo to show above the heading. */
|
|
1396
|
-
logoUrl?: string;
|
|
1397
|
-
/** Extra CSS appended to the page's own, for a deployment that wants its own look without replacing the page. */
|
|
1398
|
-
css?: string;
|
|
1399
|
-
};
|
|
1400
|
-
/**
|
|
1401
|
-
* Everything the GRANT screen needs to render itself.
|
|
1402
|
-
*
|
|
1403
|
-
* One screen, and deliberately only one: this server asks what to connect, never who somebody is. Signing in
|
|
1404
|
-
* happens on {@link OAuthConfig.signInUrl}, wherever the deployment keeps it.
|
|
1405
|
-
*/
|
|
1406
|
-
export type OAuthConsentView = {
|
|
1407
|
-
/** Where the form must POST to (the authorize endpoint). */
|
|
1408
|
-
action: string;
|
|
1409
|
-
/** Hidden fields the form MUST round-trip verbatim, or the flow cannot be resumed. */
|
|
1410
|
-
hidden: Record<string, string>;
|
|
1411
|
-
/** What this account may grant. Empty for a visitor who has not signed in, who is offered `guest` instead. */
|
|
1412
|
-
targets: OAuthGrantTarget[];
|
|
1413
|
-
/**
|
|
1414
|
-
* Offered when the deployment allows a guest connection. The form submits a `guest` field for it (any non-empty
|
|
1415
|
-
* value), which is what tells the server to grant the guest target rather than a chosen one.
|
|
1416
|
-
*
|
|
1417
|
-
* It is the reason an unidentified visitor is shown this screen at all rather than being sent straight to
|
|
1418
|
-
* sign-in: a guest has no session and never will, so a redirect they cannot come back from would take the
|
|
1419
|
-
* option away entirely.
|
|
1420
|
-
*/
|
|
1421
|
-
guest?: {
|
|
1422
|
-
label: string;
|
|
1423
|
-
description?: string;
|
|
1424
|
-
};
|
|
1425
|
-
/** Who is signed in. Absent for a visitor taking the guest connection. */
|
|
1426
|
-
user?: OAuthUser;
|
|
1427
|
-
/** Where to send somebody who wants to sign in first. Shown when `user` is absent. */
|
|
1428
|
-
signInUrl?: string;
|
|
1429
|
-
/**
|
|
1430
|
-
* Whether to offer "use another account" — shown only when the deployment can act on it, which means it supplied
|
|
1431
|
-
* {@link OAuthAdapters.signOut}.
|
|
1432
|
-
*
|
|
1433
|
-
* A submit BUTTON in the same form rather than a link, and that is not decoration. Ending a session is a state
|
|
1434
|
-
* change, so it may not hang off a URL anything can navigate to: a `<img src>` on any page on the internet would
|
|
1435
|
-
* then be able to sign a visitor out. Posting it here keeps it a same-origin form submission carrying the request
|
|
1436
|
-
* back, exactly like granting does.
|
|
1437
|
-
*/
|
|
1438
|
-
canSwitchUser?: boolean;
|
|
1439
|
-
/** A message to show the user. */
|
|
1440
|
-
error?: string;
|
|
1441
|
-
/**
|
|
1442
|
-
* Who is asking, and where the grant goes if the person says yes.
|
|
1443
|
-
*
|
|
1444
|
-
* Anybody can register a client, call it anything and send somebody this screen on the deployment's own domain, so
|
|
1445
|
-
* the name alone proves nothing. The host the code is sent back to is the one fact the requester cannot choose
|
|
1446
|
-
* freely, and it is what tells "the app I just opened" apart from a stranger's server.
|
|
1447
|
-
*/
|
|
1448
|
-
client: {
|
|
1449
|
-
/** What the client registered itself as. Chosen by the client, so it is shown as a claim. */
|
|
1450
|
-
name: string;
|
|
1451
|
-
/** The host of the `redirect_uri` the grant is delivered to. */
|
|
1452
|
-
redirectHost: string;
|
|
1453
|
-
/** The grant goes back to an app listening on this computer (RFC 8252 loopback), not to a server. */
|
|
1454
|
-
loopback: boolean;
|
|
1455
|
-
};
|
|
1456
|
-
branding: OAuthBranding;
|
|
1457
|
-
};
|
|
1458
|
-
/** OAuth 2.1 authorization for the MCP server (RFC 9728 discovery + RFC 7591 dynamic client registration +
|
|
1459
|
-
* authorization code with PKCE). ENTIRELY OPTIONAL: without this config no endpoint is mounted, discovery keeps
|
|
1460
|
-
* answering 404 and the server stays anonymous, which is a working setup — the public surface (handshake, tool
|
|
1461
|
-
* and resource listing, the guide, plitzi_render) never needed a token. Configure it only to let a remote host
|
|
1462
|
-
* that cannot send custom headers — Claude Desktop, ChatGPT — obtain a space-scoped one.
|
|
1463
|
-
*
|
|
1464
|
-
* Configuring it also protects the MCP endpoint: a JSON-RPC call that presents no verifiable bearer is answered
|
|
1465
|
-
* with RFC 6750's 401 challenge rather than the anonymous surface, because that 401 is the only thing a host runs
|
|
1466
|
-
* its flow off — it ignores a `WWW-Authenticate` header on a 200, and a server that never sends one is treated as
|
|
1467
|
-
* needing no authorization at all, leaving a completed grant with nowhere to attach. Offer a grant target that
|
|
1468
|
-
* carries no space ({@link OAuthGrantTarget}) so the public surface stays one consent away. */
|
|
1469
|
-
export type OAuthConfig = {
|
|
1470
|
-
adapters: OAuthAdapters;
|
|
1471
|
-
/** The issuer/resource identifier published in the metadata documents. Defaults to the origin the request came
|
|
1472
|
-
* in on, which is correct whenever the server owns its sub-domain; set it when a proxy rewrites the host. */
|
|
1473
|
-
issuer?: string;
|
|
1474
|
-
/** Scope names advertised and echoed back on the token. Defaults to ['plitzi']. */
|
|
1475
|
-
scopes?: string[];
|
|
1476
|
-
/** How long an authorization code stays redeemable, in seconds. Default 60 — codes are one-shot and redeemed
|
|
1477
|
-
* immediately. */
|
|
1478
|
-
codeTtlSeconds?: number;
|
|
1479
|
-
/** How long a refresh grant lives, in seconds. Default 30 days. Set 0 to issue no refresh tokens. */
|
|
1480
|
-
refreshTtlSeconds?: number;
|
|
1481
|
-
/** Offer a connection that needs no account — see {@link OAuthGuestConfig}. Omit to require sign-in. */
|
|
1482
|
-
guest?: OAuthGuestConfig;
|
|
1483
|
-
branding?: OAuthBranding;
|
|
1484
|
-
/**
|
|
1485
|
-
* The sign-in screen this server sends unidentified visitors to.
|
|
1486
|
-
*
|
|
1487
|
-
* The whole authorization request rides along as a `redirect` query param, so signing in is an ordinary
|
|
1488
|
-
* navigation that lands back on the `/authorize` it left — this server keeps no session of its own for a flow
|
|
1489
|
-
* that is one page long.
|
|
1490
|
-
*
|
|
1491
|
-
* Required, because {@link OAuthAdapters.identify} is: a server that does not check passwords and has nowhere
|
|
1492
|
-
* to send somebody who has not signed in cannot start the flow at all.
|
|
1493
|
-
*/
|
|
1494
|
-
signInUrl: string;
|
|
1495
|
-
/**
|
|
1496
|
-
* Hand the client the credential `issueToken` minted, instead of an opaque handle to it.
|
|
1497
|
-
*
|
|
1498
|
-
* Off by default, which is right whenever the credential is worth more than the connection — a space token
|
|
1499
|
-
* reaches the platform, and a client that never holds one cannot leak one. Turn it ON when the credential IS
|
|
1500
|
-
* what the client should hold: a native app granted the person's own session is holding exactly what a browser
|
|
1501
|
-
* holds, and wrapping it costs a store read on every request and gives a second thing to revoke.
|
|
1502
|
-
*/
|
|
1503
|
-
directTokens?: boolean;
|
|
1504
|
-
/**
|
|
1505
|
-
* Accept only loopback `redirect_uri`s (`http://127.0.0.1:<port>/…`, RFC 8252 §7.3), at registration and again at
|
|
1506
|
-
* `/authorize`.
|
|
1507
|
-
*
|
|
1508
|
-
* Turn it on when every client is a native app on the person's own machine — a CLI, a desktop app — and above all
|
|
1509
|
-
* with {@link directTokens}, where the grant IS the person's session. Registration is open to anybody, so with https
|
|
1510
|
-
* redirects allowed a stranger's server can register, send somebody the link, and collect what they approve.
|
|
1511
|
-
*/
|
|
1512
|
-
loopbackRedirectsOnly?: boolean;
|
|
1513
|
-
};
|
|
1514
|
-
/** A short-TTL, one-shot store for unsaved draft offline-data behind a preview token. The SDK ships an
|
|
1515
|
-
* in-memory default (fine for a single replica); a multi-replica deployment injects a shared (e.g. Redis)
|
|
1516
|
-
* implementation so a preview URL resolves on whichever replica the browser lands on. `take` consumes the
|
|
1517
|
-
* token so a preview URL is not replayable. */
|
|
1518
|
-
/**
|
|
1519
|
-
* How long a stashed draft lives, and whether looking at it uses it up.
|
|
1520
|
-
*
|
|
1521
|
-
* `reusable: false` is the capture path: one token, one render, gone — a URL that leaks buys nobody a second look.
|
|
1522
|
-
* `reusable: true` is somebody ITERATING: they reload, they open devtools, they navigate to the next page and back,
|
|
1523
|
-
* and a token consumed by the first of those turns the whole loop into "mint another one". Same store, same secret,
|
|
1524
|
-
* same expiry; the only difference is whether the read deletes it.
|
|
1525
|
-
*/
|
|
1526
|
-
export type DraftPutOptions = {
|
|
1527
|
-
ttlMs: number;
|
|
1528
|
-
reusable?: boolean;
|
|
1529
|
-
/** The space the draft was made from. It is only ever rendered for that space. */
|
|
1530
|
-
spaceId: number;
|
|
1531
|
-
};
|
|
1532
|
-
/** A stashed draft, and whether the read that resolved it left it there. */
|
|
1533
|
-
export type DraftEntry = {
|
|
1534
|
-
data: OfflineDataRaw;
|
|
1535
|
-
reusable: boolean;
|
|
1536
|
-
/** The space the draft was made from — see {@link DraftPutOptions.spaceId}. */
|
|
1537
|
-
spaceId: number;
|
|
1538
|
-
};
|
|
1539
|
-
export type DraftStore = {
|
|
1540
|
-
put: (token: string, data: OfflineDataRaw, options: DraftPutOptions) => void | Promise<void>;
|
|
1541
|
-
/**
|
|
1542
|
-
* Resolves a draft, consuming it unless it was stored as reusable.
|
|
1543
|
-
*
|
|
1544
|
-
* It answers WHICH it was, rather than leaving the caller to infer it from a second read: the render that resolved
|
|
1545
|
-
* a session is the one that has to remember it for the rest of the visit, and "did this token survive" is a fact
|
|
1546
|
-
* the store holds and nobody else does.
|
|
1547
|
-
*/
|
|
1548
|
-
take: (token: string) => (DraftEntry | undefined) | Promise<DraftEntry | undefined>;
|
|
1549
|
-
/** Ends a reusable draft before its TTL — what "stop previewing" does. A token that is not there is not an error. */
|
|
1550
|
-
drop: (token: string) => void | Promise<void>;
|
|
1551
|
-
};
|
|
1552
|
-
/** Draft-preview config for the MCP visual-preview tools. When enabled, an internal endpoint at `path`
|
|
1553
|
-
* (guarded by `secret`) applies unsaved edits to a clone, stashes the resulting offline-data under a
|
|
1554
|
-
* one-shot token, and the render path serves it back at `?__pt=<token>`. Off by default. */
|
|
1555
|
-
export type SSRPreviewConfig = {
|
|
1556
|
-
enabled?: boolean;
|
|
1557
|
-
/** Internal endpoint path that mints a preview token. Default '/__preview'. */
|
|
1558
|
-
path?: string;
|
|
1559
|
-
/**
|
|
1560
|
-
* Shared secret required in the `x-preview-secret` header; requests without it are rejected.
|
|
1561
|
-
*
|
|
1562
|
-
* Required for the endpoint to answer at all: the page server that hosts it is the one the public reaches, so an
|
|
1563
|
-
* enabled endpoint with no secret refuses every request rather than serving anyone.
|
|
1564
|
-
*/
|
|
1565
|
-
secret?: string;
|
|
1566
|
-
/** One-shot token time-to-live in milliseconds. Default 60000. */
|
|
1567
|
-
ttlMs?: number;
|
|
1568
|
-
/**
|
|
1569
|
-
* How long a REUSABLE draft session lives, in milliseconds. Default 900000 (fifteen minutes).
|
|
1570
|
-
*
|
|
1571
|
-
* Longer than a one-shot token because it is measured against a person's attention rather than an HTTP round trip,
|
|
1572
|
-
* and short anyway: a draft is unsaved work that only its author should be looking at, and every minute it stays
|
|
1573
|
-
* resolvable is a minute a copied URL keeps working.
|
|
1574
|
-
*/
|
|
1575
|
-
sessionTtlMs?: number;
|
|
1576
|
-
};
|
|
1577
|
-
export {};
|