@plitzi/sdk-shared 0.38.14 → 0.38.16
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 +163 -0
- package/dist/activity/describe.d.ts +6 -0
- package/dist/activity/describe.mjs +22 -0
- package/dist/activity/guard.d.ts +6 -0
- package/dist/activity/guard.mjs +13 -0
- package/dist/activity/index.d.ts +3 -0
- package/dist/activity/index.mjs +4 -0
- package/dist/activity/types.d.ts +94 -0
- package/dist/activity/types.mjs +4 -0
- package/dist/authoring/declare.d.ts +2 -1
- package/dist/authoring/index.mjs +2 -2
- package/dist/authoring/spaceCallbacks.d.ts +29 -0
- package/dist/authoring/spaceCallbacks.mjs +41 -20
- package/dist/index.d.ts +1 -0
- package/dist/index.mjs +98 -95
- package/dist/realtime/topics.mjs +3 -3
- package/dist/store/index.d.ts +11 -11
- package/dist/types/ActionTypes.d.ts +38 -0
- package/dist/types/BuilderTypes.d.ts +8 -0
- package/dist/types/RealtimeTypes.d.ts +12 -0
- package/dist/types/ServerTypes.d.ts +32 -3
- package/package.json +21 -1
|
@@ -17,6 +17,43 @@ export type ActionField = {
|
|
|
17
17
|
/** Shown in the builder, and read by the MCP agent when it wires a call. */
|
|
18
18
|
label?: string;
|
|
19
19
|
};
|
|
20
|
+
/** What a caller sends for a field of a type: text for `text`, `date` and `file`, anything parseable for `json`. */
|
|
21
|
+
type ActionFieldValue<T extends ActionFieldType> = T extends 'number' ? number : T extends 'boolean' ? boolean : T extends 'json' ? unknown : string;
|
|
22
|
+
/** The input a caller hands an action, from the fields it declares: those `required: true` must be there. */
|
|
23
|
+
export type ActionInputOf<Fields extends Readonly<Record<string, ActionField>>> = {
|
|
24
|
+
-readonly [K in keyof Fields as Fields[K]['required'] extends true ? K : never]: ActionFieldValue<Fields[K]['type']>;
|
|
25
|
+
} & {
|
|
26
|
+
-readonly [K in keyof Fields as Fields[K]['required'] extends true ? never : K]?: ActionFieldValue<Fields[K]['type']>;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* The key a typed action's input and output ride under, in its type only — nothing holds it at run time. Exported so a
|
|
30
|
+
* package that emits declarations can name the type of an action it exports (`export const actions = [defineAction(…)]`):
|
|
31
|
+
* a symbol it cannot import is one its `.d.ts` cannot write (TS4023).
|
|
32
|
+
*/
|
|
33
|
+
export declare const CALL_TYPES: unique symbol;
|
|
34
|
+
/**
|
|
35
|
+
* An action whose `call` way in is known to the types — what it takes and what it answers: what `defineAction` and
|
|
36
|
+
* `taskAction` answer, so a page that runs it (`useServerAction<typeof saveHabit>('save-habit')`) is held to the input
|
|
37
|
+
* it declares and handed the output typed. Nothing of it exists at run time — the action is the same document.
|
|
38
|
+
*/
|
|
39
|
+
export type TypedActionEntry<Input, Output = unknown> = ActionEntry & {
|
|
40
|
+
readonly [CALL_TYPES]?: {
|
|
41
|
+
input: Input;
|
|
42
|
+
output: Output;
|
|
43
|
+
};
|
|
44
|
+
};
|
|
45
|
+
/** The input an action's `call` way in takes, from its type — any object, for an action whose type does not say. */
|
|
46
|
+
export type CallInputOf<Action> = Action extends {
|
|
47
|
+
readonly [CALL_TYPES]?: {
|
|
48
|
+
input: infer Input;
|
|
49
|
+
};
|
|
50
|
+
} ? unknown extends Input ? Record<string, unknown> : Input : Record<string, unknown>;
|
|
51
|
+
/** What an action answers, from its type — `unknown` for one whose type does not say. */
|
|
52
|
+
export type CallOutputOf<Action> = Action extends {
|
|
53
|
+
readonly [CALL_TYPES]?: {
|
|
54
|
+
output: infer Output;
|
|
55
|
+
};
|
|
56
|
+
} ? Output : unknown;
|
|
20
57
|
/**
|
|
21
58
|
* Who may start a run through ONE way in. Resolved against the auth kernel — never re-implemented here.
|
|
22
59
|
*
|
|
@@ -709,3 +746,4 @@ export type ActionJobQueue = {
|
|
|
709
746
|
olderThan?: string;
|
|
710
747
|
}) => Promise<number>;
|
|
711
748
|
};
|
|
749
|
+
export {};
|
|
@@ -20,4 +20,12 @@ export type SubscriptionCollaborator = {
|
|
|
20
20
|
};
|
|
21
21
|
instanceId: string;
|
|
22
22
|
elementState?: SubscriptionCollaboratorElementState;
|
|
23
|
+
/**
|
|
24
|
+
* Present when the collaborator is an agent writing over the MCP — `user.firstName` is then the application
|
|
25
|
+
* (`Claude`) and `for` the member it acts for. It has no cursor: what it changed last is what it has selected, and it
|
|
26
|
+
* leaves once it has written nothing for a while.
|
|
27
|
+
*/
|
|
28
|
+
agent?: {
|
|
29
|
+
for: string;
|
|
30
|
+
};
|
|
23
31
|
};
|
|
@@ -22,6 +22,13 @@ export type ChannelDeclaration = {
|
|
|
22
22
|
* a locked board.
|
|
23
23
|
*/
|
|
24
24
|
grant?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the server keeps the latest message of each type on a topic, and hands them to every page that joins: state
|
|
27
|
+
* all the screens share — a dashboard's lists, a board's settings — said once by the server (`ctx.publish`, a flow's
|
|
28
|
+
* `realtime.publish`) and there for a page that opens later, as `<channel>.retained.<type>`. Kept until the next of
|
|
29
|
+
* its type; `null` forgets it. Only on a channel the server alone publishes on (`publish: 'server'`).
|
|
30
|
+
*/
|
|
31
|
+
retain?: boolean;
|
|
25
32
|
/** The largest `data` a page may send, as JSON bytes. 4 KB when absent. */
|
|
26
33
|
maxMessageBytes?: number;
|
|
27
34
|
/** How many messages one connection may send a second. 30 when absent. */
|
|
@@ -55,6 +62,11 @@ export type RealtimeMessage = RealtimeSender & {
|
|
|
55
62
|
* knows it for its own by `from` — its channel's `me`. Without it, a page never hears what it sent.
|
|
56
63
|
*/
|
|
57
64
|
echo?: true;
|
|
65
|
+
/**
|
|
66
|
+
* Kept by the server: on a `retain: true` channel, the latest message of its type — sent as it is said, and again to
|
|
67
|
+
* every page that joins. The newest of a type is the one that holds; `null` data forgets it.
|
|
68
|
+
*/
|
|
69
|
+
retained?: true;
|
|
58
70
|
};
|
|
59
71
|
/** What a page asks of a publish beyond the message itself. */
|
|
60
72
|
export type RealtimePublishOptions = {
|
|
@@ -8,6 +8,7 @@ import { SSRRealtimeConfig } from './RealtimeTypes';
|
|
|
8
8
|
import { Schema } from './SchemaTypes';
|
|
9
9
|
import { AnalyticsConfig, OfflineDataRaw } from './SdkTypes';
|
|
10
10
|
import { FontHead, Style } from './StyleTypes';
|
|
11
|
+
import { ActivityReader, SpaceActivityPage, SpaceActivityQuery } from '../activity/types';
|
|
11
12
|
import { FlagOverrides } from '../flags/resolveFlags';
|
|
12
13
|
import { SpaceChange } from '../history/types';
|
|
13
14
|
import { IncomingHttpHeaders } from 'node:http';
|
|
@@ -223,6 +224,8 @@ export type SSRGrant = {
|
|
|
223
224
|
spaceId: number;
|
|
224
225
|
scope: SpaceScope;
|
|
225
226
|
userId?: number;
|
|
227
|
+
/** For an `agent` grant, the application the member connected (`Claude`): what its writes are recorded and shown as. */
|
|
228
|
+
client?: string;
|
|
226
229
|
canWrite: boolean;
|
|
227
230
|
};
|
|
228
231
|
/** A page of a space's change history, newest first; `nextBefore` reads further back, null at the end. */
|
|
@@ -237,10 +240,12 @@ export type SSRChangeQuery = {
|
|
|
237
240
|
limit: number;
|
|
238
241
|
};
|
|
239
242
|
/** Who a write is made for and which request made it, for a consumer that records its changes. Every document one
|
|
240
|
-
* request writes shares its `batch`: one `plitzi_apply`, read back as one change.
|
|
243
|
+
* request writes shares its `batch`: one `plitzi_apply`, read back as one change. `client` is the application that
|
|
244
|
+
* wrote it for them (`SSRGrant.client`). */
|
|
241
245
|
export type SSRWriteContext = {
|
|
242
246
|
userId?: number;
|
|
243
247
|
batch: string;
|
|
248
|
+
client?: string;
|
|
244
249
|
};
|
|
245
250
|
/**
|
|
246
251
|
* A session, as the thing that issued it describes it. Deliberately free of transport: whoever mints one says what
|
|
@@ -359,8 +364,15 @@ export type SSRAdapters = {
|
|
|
359
364
|
* dedicated MCP server renders nothing, reads schema and style through its own adapters, and had to hand this
|
|
360
365
|
* one over anyway for the type to be satisfied — an adapter it never called. */
|
|
361
366
|
getOfflineData?: (spaceId: number, environment: string, revision?: number) => Promise<OfflineDataRaw | undefined>;
|
|
362
|
-
/**
|
|
363
|
-
*
|
|
367
|
+
/**
|
|
368
|
+
* Which space, environment and revision a request resolves to. Optional here for the same reason as
|
|
369
|
+
* `getOfflineData`: MCP resolves its space from the request token (`getGrant`), never from the host.
|
|
370
|
+
*
|
|
371
|
+
* Asked on EVERY request, not only a page's: what the page fetches after it — `/_plitzi/space/<hash>.json`, `/_action`,
|
|
372
|
+
* `/fn/…`, `/_realtime` — is resolved again, and carries nothing of the page's address but its host (and the
|
|
373
|
+
* visitor's credentials). So a space is chosen by the host — a domain, a sub-domain (`wildcardSubdomain`) — or by a
|
|
374
|
+
* credential (`authoringPreview`): one chosen by the page's path or query is lost on the requests that follow it.
|
|
375
|
+
*/
|
|
364
376
|
getSpaceDeployment?: (req: SSRRequest) => Promise<SSRSpaceDeployment>;
|
|
365
377
|
/** Resolve the grant the MCP request operates under, from the verified `Authorization` bearer. The consumer
|
|
366
378
|
* owns the JWT secret and the authorization model, so it decides here; the MCP service stays stateless.
|
|
@@ -425,6 +437,10 @@ export type SSRAdapters = {
|
|
|
425
437
|
/** The space's change history, read-only: what every writer saved, and for whom. When omitted, the MCP offers no
|
|
426
438
|
* history resource. */
|
|
427
439
|
getChanges?: (spaceId: number, environment: Environment, query: SSRChangeQuery) => Promise<SSRChangePage>;
|
|
440
|
+
/** What happened on the space after a cursor — the draft changed, a version went out, an action failed — waiting up
|
|
441
|
+
* to `query.wait` seconds when nothing has yet. `reader` is who asks, so their own writes can be left out; `signal`
|
|
442
|
+
* ends the wait when the client goes. When omitted, the MCP offers no `plitzi_activity`. */
|
|
443
|
+
getActivity?: (spaceId: number, query: SpaceActivityQuery, reader: ActivityReader, signal?: AbortSignal) => Promise<SpaceActivityPage>;
|
|
428
444
|
/** Who this request carries, if anyone. The adapter reads the credential and resolves it; the cookie it arrived
|
|
429
445
|
* in was written by the server, from {@link SSRAuthCookie}. */
|
|
430
446
|
getUser?: (req: SSRRequest) => Promise<SSRUser | undefined>;
|
|
@@ -1033,6 +1049,19 @@ export type SSRServerConfig = {
|
|
|
1033
1049
|
};
|
|
1034
1050
|
/** Realtime channels the spaces declare — see {@link SSRRealtimeConfig}. On, in memory, when absent. */
|
|
1035
1051
|
realtime?: SSRRealtimeConfig;
|
|
1052
|
+
/**
|
|
1053
|
+
* The writes a page on another site may cause here. None, by default: a browser's POST, PUT, PATCH or DELETE that it
|
|
1054
|
+
* says another site caused (`Sec-Fetch-Site: cross-site`, or a foreign `Origin`) is refused 403 `reason: 'foreign'` —
|
|
1055
|
+
* a session cookie or none, because a server holding credentials of its own, or a tool nobody signs in to, acts for
|
|
1056
|
+
* whoever reaches it. A request with `Authorization`, and one that is not a browser's (a webhook, a script), are never
|
|
1057
|
+
* asked. With `auth`, the deployment's `identity.platformOrigins` count as its own too.
|
|
1058
|
+
*/
|
|
1059
|
+
crossSiteWrites?: {
|
|
1060
|
+
/** Origins whose pages may write here, exactly as a browser sends them — `https://app.example.com`. */
|
|
1061
|
+
origins?: string[];
|
|
1062
|
+
/** Paths any site may post to: a form other sites embed by design. */
|
|
1063
|
+
paths?: (path: string) => boolean;
|
|
1064
|
+
};
|
|
1036
1065
|
/** Connector manifest and credential lookups — see {@link ConnectorLookupsConfig}. They serve the RSC read path
|
|
1037
1066
|
* and the `/_action` write endpoint alike; without them neither can reach a connector. */
|
|
1038
1067
|
connectors?: ConnectorLookupsConfig;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-shared",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.16",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -54,6 +54,26 @@
|
|
|
54
54
|
"types": "./dist/actions/validateDocument.d.ts",
|
|
55
55
|
"import": "./dist/actions/validateDocument.mjs"
|
|
56
56
|
},
|
|
57
|
+
"./activity": {
|
|
58
|
+
"types": "./dist/activity/index.d.ts",
|
|
59
|
+
"import": "./dist/activity/index.mjs"
|
|
60
|
+
},
|
|
61
|
+
"./activity/describe": {
|
|
62
|
+
"types": "./dist/activity/describe.d.ts",
|
|
63
|
+
"import": "./dist/activity/describe.mjs"
|
|
64
|
+
},
|
|
65
|
+
"./activity/guard": {
|
|
66
|
+
"types": "./dist/activity/guard.d.ts",
|
|
67
|
+
"import": "./dist/activity/guard.mjs"
|
|
68
|
+
},
|
|
69
|
+
"./activity/index": {
|
|
70
|
+
"types": "./dist/activity/index.d.ts",
|
|
71
|
+
"import": "./dist/activity/index.mjs"
|
|
72
|
+
},
|
|
73
|
+
"./activity/types": {
|
|
74
|
+
"types": "./dist/activity/types.d.ts",
|
|
75
|
+
"import": "./dist/activity/types.mjs"
|
|
76
|
+
},
|
|
57
77
|
"./auth": {
|
|
58
78
|
"types": "./dist/auth/index.d.ts",
|
|
59
79
|
"import": "./dist/auth/index.mjs"
|