@plitzi/sdk-shared 0.38.15 → 0.38.17
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 +102 -0
- package/dist/actions/cron.mjs +5 -9
- package/dist/actions/validateDocument.mjs +24 -50
- 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/connectors/validateManifest.mjs +28 -73
- package/dist/dataSource/helpers/index.mjs +1 -2
- package/dist/dataSource/index.d.ts +1 -1
- package/dist/dataSource/index.mjs +6 -8
- package/dist/dataSource/utility/index.d.ts +1 -0
- package/dist/dataSource/utility/index.mjs +16 -15
- package/dist/devTools/utils/PlitziConsole.mjs +8 -12
- package/dist/elements/index.mjs +1 -2
- package/dist/flags/index.d.ts +2 -0
- package/dist/flags/index.mjs +2 -1
- package/dist/flags/useFlagResolution.mjs +6 -6
- package/dist/helpers/index.d.ts +8 -0
- package/dist/helpers/index.mjs +21 -13
- package/dist/helpers/keys.mjs +4 -8
- package/dist/helpers/twigWrapper/Evaluator/index.mjs +1 -2
- package/dist/helpers/twigWrapper/Parser/ExpressionParser.mjs +12 -26
- package/dist/helpers/twigWrapper/Parser/index.mjs +1 -2
- package/dist/helpers/twigWrapper/TemplateCache/index.mjs +1 -2
- package/dist/helpers/twigWrapper/charClass.mjs +2 -6
- package/dist/helpers/twigWrapper/filters/index.mjs +1 -2
- package/dist/helpers/twigWrapper/templateRoots.mjs +3 -8
- package/dist/hooks/useNetwork.mjs +1 -4
- package/dist/index.d.ts +5 -18
- package/dist/index.mjs +3 -96
- package/dist/network/graphql/builder/Mutations/index.d.ts +1 -0
- package/dist/network/graphql/builder/Mutations/index.mjs +148 -148
- package/dist/network/graphql/builder/Queries/index.mjs +4 -4
- package/dist/network/index.mjs +8 -8
- package/dist/plugins/{bundle.mjs → bundle/bundle.mjs} +1 -1
- package/dist/plugins/bundle/index.d.ts +2 -0
- package/dist/plugins/bundle/index.mjs +1 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/plugins/index.mjs +3 -0
- package/dist/project/index.d.ts +8 -0
- package/dist/project/index.mjs +5 -0
- package/dist/project/layout.mjs +4 -4
- package/dist/queries/queryCache.mjs +1 -7
- package/dist/realtime/client.mjs +3 -12
- package/dist/schema/index.d.ts +5 -0
- package/dist/schema/index.mjs +12 -7
- package/dist/server/actions/useActionsSync.mjs +1 -1
- package/dist/server/actions/useImagesSync.mjs +1 -1
- package/dist/server/actions/useRealtimeSync.mjs +1 -1
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.mjs +8 -4
- package/dist/server/rsc/refreshRsc.mjs +11 -11
- package/dist/server/rsc/useRscSync.mjs +1 -1
- package/dist/server/usePluginRoute.mjs +1 -1
- package/dist/state/runtimeStatePersist.mjs +9 -15
- package/dist/store/index.d.ts +1 -193
- package/dist/store/index.mjs +6 -9
- package/dist/store/renderSettings.mjs +1 -1
- package/dist/store/storeHooks.d.ts +193 -0
- package/dist/store/storeHooks.mjs +5 -0
- package/dist/store/tracing/tracingCollector.mjs +1 -5
- package/dist/style/fonts.mjs +17 -25
- package/dist/style/index.d.ts +4 -0
- package/dist/style/index.mjs +19 -15
- package/dist/style/stylePseudos.mjs +2 -5
- package/dist/style/styleTarget.mjs +6 -6
- package/dist/theme/ThemeProvider.mjs +1 -1
- package/dist/theme/index.d.ts +1 -0
- package/dist/theme/index.mjs +4 -4
- package/dist/types/BuilderTypes.d.ts +8 -0
- package/dist/types/SchemaTypes.d.ts +2 -1
- package/dist/types/ServerTypes.d.ts +10 -1
- package/dist/websockets/index.mjs +1 -2
- package/package.json +21 -1587
- package/vite.config.ts +20 -4
- package/dist/auth/authFailureLink.d.ts +0 -9
- package/dist/auth/authFailureLink.mjs +0 -20
- package/dist/dataSource/hooks/index.d.ts +0 -4
- package/dist/dataSource/hooks/index.mjs +0 -3
- package/dist/dataSource/hooks/useRegisterSource.d.ts +0 -9
- package/dist/dataSource/hooks/useRegisterSource.mjs +0 -40
- package/dist/dataSource/hooks/useResolvedVariables.d.ts +0 -12
- package/dist/dataSource/hooks/useResolvedVariables.mjs +0 -28
- package/dist/helpers/stripTypename.d.ts +0 -15
- package/dist/helpers/stripTypename.mjs +0 -41
- /package/dist/plugins/{bundle.d.ts → bundle/bundle.d.ts} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,107 @@
|
|
|
1
1
|
# @plitzi/sdk-shared
|
|
2
2
|
|
|
3
|
+
## 0.38.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4f8dc37: ## Packages
|
|
8
|
+
|
|
9
|
+
- **A library package is imported by its root and its folders, never by a file** (`@plitzi/sdk-shared`, `sdk-schema`,
|
|
10
|
+
`sdk-style`, `sdk-elements`, `sdk-interactions`, `sdk-auth`, `sdk-dev-tools`, `sdk-event-bridge`, `sdk-navigation`,
|
|
11
|
+
`sdk-plugins`, `sdk-variables`): each `exports` is now `"."` and `"./*"`, the latter a folder's `index`.
|
|
12
|
+
`@plitzi/sdk-shared/helpers/isRecord` becomes `import { isRecord } from '@plitzi/sdk-shared/helpers'`, and a default
|
|
13
|
+
export by the name its folder gives it — almost always its file's (`import usePlitzi from '…/hooks/usePlitzi'` →
|
|
14
|
+
`import { usePlitzi } from '@plitzi/sdk-shared/hooks'`). A file-level specifier now fails with `ERR_MODULE_NOT_FOUND`.
|
|
15
|
+
New entries where a folder barrel would have brought more than was asked for: `@plitzi/sdk-shared/project` and
|
|
16
|
+
`@plitzi/sdk-shared/plugins/bundle` (Node only), `@plitzi/sdk-interactions/declarations` (the global callbacks and
|
|
17
|
+
utility specs, without React), and `@plitzi/sdk-elements/elements/declarations`, which now also carries the
|
|
18
|
+
declarations' attribute types and the constants they are checked with. `RuleGroup` is exported by `@plitzi/sdk-shared`
|
|
19
|
+
with the document types that use it. `plitzi upgrade migrations` names every such import in a project, with the folder to
|
|
20
|
+
import it from instead.
|
|
21
|
+
- **`@plitzi/sdk-shared`'s root exports the document types, and only them** (`@plitzi/sdk-shared`): what the package
|
|
22
|
+
does is imported from its folder — `formatDate` from `@plitzi/sdk-shared/helpers`, `ThemeProvider` from
|
|
23
|
+
`@plitzi/sdk-shared/theme`, a GraphQL operation's types from `@plitzi/sdk-shared/network/graphql` — so a module that
|
|
24
|
+
imports a type from the root no longer loads every area of the package.
|
|
25
|
+
- **What one package alone used lives in that package** (`@plitzi/sdk-shared`, `@plitzi/sdk-elements`): the data
|
|
26
|
+
source hooks moved from `@plitzi/sdk-shared/dataSource/hooks` to `@plitzi/sdk-elements/dataSource`
|
|
27
|
+
(`useRegisterSource`, `useResolvedVariables`), and the Apollo links the builder's client is built with into the
|
|
28
|
+
builder.
|
|
29
|
+
- **The builder's panels are an entry of their own** (`@plitzi/sdk-style`, `@plitzi/sdk-variables`,
|
|
30
|
+
`@plitzi/sdk-elements`): the style inspector, the advanced style editor and `BuilderStyleContextProvider` are imported
|
|
31
|
+
from `@plitzi/sdk-style/builder`; the variables' lists and forms from `@plitzi/sdk-variables/builder`; the elements'
|
|
32
|
+
settings panels (`defaultElementsSettings`) from `@plitzi/sdk-elements/builder`. Each package's root keeps what a page
|
|
33
|
+
and a server use — `generateCache` no longer loads the inspector, on a server 227 modules down to 21.
|
|
34
|
+
|
|
35
|
+
## CLI
|
|
36
|
+
- **`plitzi upgrade`'s `renames` part is now `migrations`** (`@plitzi/cli`): what a version changed that a project's
|
|
37
|
+
own source must follow, one file per change in the CLI's `src/migrations/changes/` with the version it shipped in —
|
|
38
|
+
rewritten with `--write` when it has one right answer, said otherwise. The `--json` report carries `migrations` (each
|
|
39
|
+
with its `migration`, `since`, `file`, `line`, `what` and whether it was `written`) in place of `renames` and
|
|
40
|
+
`changes`. The changes of 0.38.0 (`canTemplate` → `canSnippet`, the `*Template` authoring names), 0.38.9 (a
|
|
41
|
+
`formControl` without `required` is optional) and 0.38.12 (`usePlitziServiceContext` → `usePlitzi`) are no longer
|
|
42
|
+
looked for: a project still on one of those versions makes them by hand.
|
|
43
|
+
|
|
44
|
+
## 0.38.16
|
|
45
|
+
|
|
46
|
+
### Patch Changes
|
|
47
|
+
|
|
48
|
+
- 9cfdccb: ## Security
|
|
49
|
+
|
|
50
|
+
- **A site's credential reads nothing of the space over MCP** (`@plitzi/sdk-mcp`): the `render` token every published
|
|
51
|
+
page embeds — and a self-hosting `host` key — resolved to a grant naming the space, and the MCP served every read
|
|
52
|
+
under it: the unpublished draft, the change history with who made each change and every value before and after, the
|
|
53
|
+
functions' source, the space's private data, its action documents and connectors. Only an `agent` grant attaches a
|
|
54
|
+
space now; any other is a connection with no space (`plitzi_render` and the public guides), told so in the words
|
|
55
|
+
`NO_SPACE_ATTACHED` already uses. A deployment whose `getGrant` answered other scopes for reading must issue agent
|
|
56
|
+
grants for them.
|
|
57
|
+
|
|
58
|
+
## Agents
|
|
59
|
+
- **`plitzi space watch`** (`@plitzi/cli`): the space read again on every save of `src/space/`, `src/plugins/`,
|
|
60
|
+
`src/data/` or `public/data/`, and only what changed said — what the save did to the space element by element, the
|
|
61
|
+
findings and warnings it brought and fixed (one that only moved down its file is the same one), a save that changed
|
|
62
|
+
nothing, or that the space stopped authoring and why. `--json` is one event a line (`ready`, `pass`, `refused`,
|
|
63
|
+
`error`), for an agent to run in the background instead of `author` and `space lint` after every edit. Each pass reads
|
|
64
|
+
the space in a process of its own (`space watch-pass`, hidden). `space lint`'s reading is `spaceFindings`, shared.
|
|
65
|
+
- **A space's activity, followed** (`@plitzi/sdk-shared`, `@plitzi/sdk-mcp`, `@plitzi/cli`): what happened on a space
|
|
66
|
+
after a cursor — its draft changed (a person in the builder, an agent, the autofix), a version went out, a server
|
|
67
|
+
action failed or was refused — and, with nothing yet, waited for, up to 50 s. One vocabulary,
|
|
68
|
+
`@plitzi/sdk-shared/activity` (`SpaceActivity`, `SpaceActivityPage`, `activityLine`, `isSpaceActivityPage`, the
|
|
69
|
+
limits); the reader's own writes left out and counted (`skippedMine`), `mine` keeps them.
|
|
70
|
+
- **`plitzi_activity { after, wait, limit, mine }`** (`@plitzi/sdk-mcp`), on the new `getActivity` adapter
|
|
71
|
+
(`SSRAdapters`). The listing budget is 78k (was 77k) for it.
|
|
72
|
+
- **`plitzi space activity [--follow] [--after <cursor>] [--mine] [--limit <n>] [--json]`** (`@plitzi/cli`), over
|
|
73
|
+
the platform's `GET /spaces/:spaceId/activity`; `--follow` stays, one page a line with `--json`, and asks again
|
|
74
|
+
when the platform does not answer.
|
|
75
|
+
- **The people in the builder see the agent work** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`, `@plitzi/sdk-mcp`,
|
|
76
|
+
`@plitzi/plitzi-builder`): an agent grant carries the application the member connected (`Grant.client`,
|
|
77
|
+
`StoredSpaceToken.client`, `SSRGrant.client`), and every MCP write `SSRWriteContext.client` — the history's
|
|
78
|
+
`client` for an agent, which was never set. A collaborator may be an agent (`SubscriptionCollaborator.agent`): the
|
|
79
|
+
builder draws it as a robot, names it `Claude · for ana` (`collaboratorTitle`) in the header, on the canvas and in
|
|
80
|
+
its notices. The deployment announces it — Plitzi's joins it on a write, selects what it changed, and lets it go
|
|
81
|
+
after a minute of nothing. `activityLine` names it the same way (`Claude for ana over the MCP, …`), so
|
|
82
|
+
`plitzi space activity` says which application wrote.
|
|
83
|
+
- A tool may declare `documents: false` (`ToolSpec`): the host loads none of the space for it, and passes the call's
|
|
84
|
+
abort signal through `ToolContext.activity`.
|
|
85
|
+
|
|
86
|
+
## Authoring
|
|
87
|
+
- **A file that does not parse is said at its line under any loader** (`@plitzi/sdk-authoring`): `moduleProblem` read
|
|
88
|
+
the first line of the error, and an esbuild transform (tsx, vitest) puts only `Transform failed with 1 error:` there
|
|
89
|
+
— the file, line and what is wrong are on the next. A line of the message that points at a file of the project is
|
|
90
|
+
now the problem (`src/space/hero.ts:139: Expected "}" but found ";"`), the project's root matched as given and as it
|
|
91
|
+
is on disk (`/var/…` and `/private/var/…` on macOS).
|
|
92
|
+
|
|
93
|
+
## Testing
|
|
94
|
+
- **`unusedPort` is chosen where the system never hands one out** (`@plitzi/sdk-server`): it answered a port the system
|
|
95
|
+
had just handed out (`listen(0)`), from the ephemeral range every outgoing connection takes its local port from — so
|
|
96
|
+
another worker's request could take it before the test listened, and CI failed `runtime.test.ts` with `EADDRINUSE`
|
|
97
|
+
(the page server then ends the process). It is a free port below that range now, at random, checked first.
|
|
98
|
+
|
|
99
|
+
## Docs
|
|
100
|
+
- **A self-hosted runtime's endpoints go in `data`**, as 0.38.15 moved them: `docs/en/runtimes.md`, the
|
|
101
|
+
`10-runtime` example and the website still put `served.stage` in `preAuth`, before the cross-site guard.
|
|
102
|
+
- New: `docs/en/activity.md`; `space watch` in `docs/en/agent-tooling.md`'s loop; the CLI README, the CLI skill, the
|
|
103
|
+
generated project's `AGENTS.md`, the MCP guide and README.
|
|
104
|
+
|
|
3
105
|
## 0.38.15
|
|
4
106
|
|
|
5
107
|
### Patch Changes
|
package/dist/actions/cron.mjs
CHANGED
|
@@ -79,16 +79,12 @@ var e = [
|
|
|
79
79
|
for (let e = o; e <= c;) {
|
|
80
80
|
let t = new Date(e), n = a(t);
|
|
81
81
|
if (!n) return;
|
|
82
|
-
if (!s(i, n))
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
if (!s(i, n)) e += (1440 - n.hour * 60 - n.minute) * d;
|
|
83
|
+
else if (!p.has(n.hour)) e += (60 - n.minute) * d;
|
|
84
|
+
else {
|
|
85
|
+
if (u.has(n.minute)) return t;
|
|
86
|
+
e += d;
|
|
85
87
|
}
|
|
86
|
-
if (!p.has(n.hour)) {
|
|
87
|
-
e += (60 - n.minute) * d;
|
|
88
|
-
continue;
|
|
89
|
-
}
|
|
90
|
-
if (u.has(n.minute)) return t;
|
|
91
|
-
e += d;
|
|
92
88
|
}
|
|
93
89
|
}, m = (e, t, n, r, i = 1e3) => {
|
|
94
90
|
let a = 0, o = new Date(t.getTime() + d);
|
|
@@ -38,29 +38,19 @@ var s = [
|
|
|
38
38
|
return;
|
|
39
39
|
}
|
|
40
40
|
}, h = (e, t, n) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
Object.entries(e).forEach(([e, i]) => {
|
|
50
|
-
if (!r(i) || !p(i.type)) {
|
|
51
|
-
n.push({
|
|
52
|
-
path: `${t}.${e}`,
|
|
53
|
-
message: "must declare a type"
|
|
54
|
-
});
|
|
55
|
-
return;
|
|
56
|
-
}
|
|
57
|
-
s.includes(i.type) || n.push({
|
|
58
|
-
path: `${t}.${e}.type`,
|
|
59
|
-
message: `unknown field type "${i.type}"`,
|
|
60
|
-
hint: `one of ${s.join(", ")}`
|
|
61
|
-
});
|
|
41
|
+
e !== void 0 && (r(e) ? Object.entries(e).forEach(([e, i]) => {
|
|
42
|
+
!r(i) || !p(i.type) ? n.push({
|
|
43
|
+
path: `${t}.${e}`,
|
|
44
|
+
message: "must declare a type"
|
|
45
|
+
}) : s.includes(i.type) || n.push({
|
|
46
|
+
path: `${t}.${e}.type`,
|
|
47
|
+
message: `unknown field type "${i.type}"`,
|
|
48
|
+
hint: `one of ${s.join(", ")}`
|
|
62
49
|
});
|
|
63
|
-
}
|
|
50
|
+
}) : n.push({
|
|
51
|
+
path: t,
|
|
52
|
+
message: "must be an object of field definitions"
|
|
53
|
+
}));
|
|
64
54
|
}, g = (n, s, d, f) => {
|
|
65
55
|
let g = `nodes.${n}`, _ = s.action;
|
|
66
56
|
if (!p(_) || !l.includes(_)) {
|
|
@@ -164,36 +154,20 @@ var s = [
|
|
|
164
154
|
});
|
|
165
155
|
}), o.forEach(([t, n]) => {
|
|
166
156
|
let o = `nodes.${t}`;
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
return;
|
|
173
|
-
}
|
|
174
|
-
if (n.type === "trigger") {
|
|
175
|
-
g(t, n, i, a);
|
|
176
|
-
return;
|
|
177
|
-
}
|
|
178
|
-
if (n.type !== "task") {
|
|
179
|
-
i.push({
|
|
180
|
-
path: `${o}.type`,
|
|
181
|
-
message: `"${String(n.type)}" steps run in the browser and cannot run on the server`,
|
|
182
|
-
hint: "a server action is made of task steps"
|
|
183
|
-
});
|
|
184
|
-
return;
|
|
185
|
-
}
|
|
186
|
-
if (!p(n.action) || !f.test(n.action)) {
|
|
187
|
-
i.push({
|
|
188
|
-
path: `${o}.action`,
|
|
189
|
-
message: "must name a task as <namespace>.<action>",
|
|
190
|
-
hint: "for example flow.output or http.request"
|
|
191
|
-
});
|
|
192
|
-
return;
|
|
193
|
-
}
|
|
194
|
-
p(n.afterNode) && !Object.hasOwn(e, n.afterNode) && i.push({
|
|
157
|
+
r(n) ? n.type === "trigger" ? g(t, n, i, a) : n.type === "task" ? !p(n.action) || !f.test(n.action) ? i.push({
|
|
158
|
+
path: `${o}.action`,
|
|
159
|
+
message: "must name a task as <namespace>.<action>",
|
|
160
|
+
hint: "for example flow.output or http.request"
|
|
161
|
+
}) : p(n.afterNode) && !Object.hasOwn(e, n.afterNode) && i.push({
|
|
195
162
|
path: `${o}.afterNode`,
|
|
196
163
|
message: `points at "${n.afterNode}", which is not a step here`
|
|
164
|
+
}) : i.push({
|
|
165
|
+
path: `${o}.type`,
|
|
166
|
+
message: `"${String(n.type)}" steps run in the browser and cannot run on the server`,
|
|
167
|
+
hint: "a server action is made of task steps"
|
|
168
|
+
}) : i.push({
|
|
169
|
+
path: o,
|
|
170
|
+
message: "must be an object"
|
|
197
171
|
});
|
|
198
172
|
}), o.forEach(([e]) => {
|
|
199
173
|
d.has(e) && i.push({
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SpaceActivity } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* One activity, in a line a person scans: who did what, and where — the same words the builder's history and activity
|
|
4
|
+
* use. Its time is the reader's to add, in the zone it shows times in.
|
|
5
|
+
*/
|
|
6
|
+
export declare const activityLine: (activity: SpaceActivity) => string;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
//#region src/activity/describe.ts
|
|
2
|
+
var e = {
|
|
3
|
+
builder: "in the builder",
|
|
4
|
+
mcp: "over the MCP",
|
|
5
|
+
autofix: "by the autofix",
|
|
6
|
+
api: "through the API",
|
|
7
|
+
system: "by the platform"
|
|
8
|
+
}, t = (e) => e || "somebody", n = (e) => {
|
|
9
|
+
let t = e.split("\n").filter((e) => e.trim() !== "");
|
|
10
|
+
return t.length === 0 ? "changed it" : t.length === 1 ? t[0] : `${t[0]} (+${String(t.length - 1)} more)`;
|
|
11
|
+
}, r = (r) => {
|
|
12
|
+
switch (r.kind) {
|
|
13
|
+
case "change": return `${r.origin === "mcp" && r.client ? `${r.client} for ${t(r.author.name)}` : t(r.author.name)} ${e[r.origin] ?? r.origin}, ${r.document} #${String(r.seq)}: ${n(r.summary)}`;
|
|
14
|
+
case "publish": return r.message;
|
|
15
|
+
case "action": {
|
|
16
|
+
let e = r.reason ?? r.error;
|
|
17
|
+
return `action ${r.actionId} (${r.trigger}) ${r.status}${e ? `: ${e}` : ""}`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
};
|
|
21
|
+
//#endregion
|
|
22
|
+
export { r as activityLine };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { SpaceActivityPage } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Whether a reply is a page of activity — what a client checks the platform's answer against before reading it, an
|
|
4
|
+
* answer from a server of another version included.
|
|
5
|
+
*/
|
|
6
|
+
export declare const isSpaceActivityPage: (value: unknown) => value is SpaceActivityPage;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isRecord as e } from "../helpers/isRecord.mjs";
|
|
2
|
+
//#region src/activity/guard.ts
|
|
3
|
+
var t = (t) => {
|
|
4
|
+
if (!e(t) || typeof t.at != "number") return !1;
|
|
5
|
+
switch (t.kind) {
|
|
6
|
+
case "change": return typeof t.seq == "number" && typeof t.summary == "string" && typeof t.origin == "string" && e(t.author) && Array.isArray(t.touched);
|
|
7
|
+
case "publish": return typeof t.message == "string" && e(t.author);
|
|
8
|
+
case "action": return typeof t.actionId == "string" && typeof t.status == "string";
|
|
9
|
+
default: return !1;
|
|
10
|
+
}
|
|
11
|
+
}, n = (n) => e(n) && Array.isArray(n.activity) && n.activity.every(t) && typeof n.cursor == "string" && typeof n.more == "boolean" && typeof n.waitedMs == "number" && typeof n.skippedMine == "number";
|
|
12
|
+
//#endregion
|
|
13
|
+
export { n as isSpaceActivityPage };
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { activityLine as e } from "./describe.mjs";
|
|
2
|
+
import { isSpaceActivityPage as t } from "./guard.mjs";
|
|
3
|
+
import { ACTIVITY_LIMIT_DEFAULT as n, ACTIVITY_LIMIT_MAX as r, ACTIVITY_TOUCHED_MAX as i, ACTIVITY_WAIT_DEFAULT_SECONDS as a, ACTIVITY_WAIT_MAX_SECONDS as o } from "./types.mjs";
|
|
4
|
+
export { n as ACTIVITY_LIMIT_DEFAULT, r as ACTIVITY_LIMIT_MAX, i as ACTIVITY_TOUCHED_MAX, a as ACTIVITY_WAIT_DEFAULT_SECONDS, o as ACTIVITY_WAIT_MAX_SECONDS, e as activityLine, t as isSpaceActivityPage };
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { ChangeAuthor, ChangeDocument, ChangeOrigin } from '../history/types';
|
|
2
|
+
/**
|
|
3
|
+
* What happened on a space, as an agent or a person following it reads it: the draft changed, a version went out, an
|
|
4
|
+
* action failed. One vocabulary for the three surfaces that read it — the MCP's `plitzi_activity`, the CLI's
|
|
5
|
+
* `plitzi space activity` and the platform's `GET /spaces/:spaceId/activity` — so none of them describes it again.
|
|
6
|
+
*
|
|
7
|
+
* Each kind is read off a record the platform already keeps — the change history, the space's log, the action runs —
|
|
8
|
+
* so the activity is never a second copy that could disagree with them.
|
|
9
|
+
*/
|
|
10
|
+
/** The draft changed: one save, by whoever made it, through whichever channel. */
|
|
11
|
+
export type ChangeActivity = {
|
|
12
|
+
kind: 'change';
|
|
13
|
+
/** Milliseconds, UTC. */
|
|
14
|
+
at: number;
|
|
15
|
+
/** Its place in the draft's change history: what `plitzi://changes/main/{seq}` reads whole. */
|
|
16
|
+
seq: number;
|
|
17
|
+
document: ChangeDocument;
|
|
18
|
+
author: ChangeAuthor;
|
|
19
|
+
origin: ChangeOrigin;
|
|
20
|
+
/** The MCP client's name, or the builder tab's instance id. */
|
|
21
|
+
client?: string;
|
|
22
|
+
/** One line per thing it did, as the builder's history says it. */
|
|
23
|
+
summary: string;
|
|
24
|
+
/** What it touched, by id — elements, selectors, tokens, files — at most {@link ACTIVITY_TOUCHED_MAX}. */
|
|
25
|
+
touched: string[];
|
|
26
|
+
/** How many more it touched than `touched` lists. */
|
|
27
|
+
moreTouched?: number;
|
|
28
|
+
};
|
|
29
|
+
/** A version of the space went out: published to an environment, its flags published, or deployed. */
|
|
30
|
+
export type PublishActivity = {
|
|
31
|
+
kind: 'publish';
|
|
32
|
+
at: number;
|
|
33
|
+
author: ChangeAuthor;
|
|
34
|
+
/** `publish` — a version or its flags — or `deployment`, to a CDN. */
|
|
35
|
+
what: 'publish' | 'deployment';
|
|
36
|
+
environment?: string;
|
|
37
|
+
/** The space's log line, as the builder's activity shows it. */
|
|
38
|
+
message: string;
|
|
39
|
+
};
|
|
40
|
+
/** A server action did not complete, or a call to one was refused. A run that completed is not news. */
|
|
41
|
+
export type ActionActivity = {
|
|
42
|
+
kind: 'action';
|
|
43
|
+
at: number;
|
|
44
|
+
actionId: string;
|
|
45
|
+
trigger: string;
|
|
46
|
+
/** `refused`, or how a run that did not complete ended. */
|
|
47
|
+
status: string;
|
|
48
|
+
environment?: string;
|
|
49
|
+
/** The run, for `GET /spaces/:spaceId/actions/runs/:runId`. Absent on a refusal. */
|
|
50
|
+
runId?: string;
|
|
51
|
+
/** Why it failed, or the refusal's detail — redacted before it was recorded. */
|
|
52
|
+
error?: string;
|
|
53
|
+
/** Why it was refused. */
|
|
54
|
+
reason?: string;
|
|
55
|
+
};
|
|
56
|
+
export type SpaceActivity = ChangeActivity | PublishActivity | ActionActivity;
|
|
57
|
+
export type SpaceActivityKind = SpaceActivity['kind'];
|
|
58
|
+
/** What to read: everything after a cursor, waiting for it when there is nothing yet. */
|
|
59
|
+
export type SpaceActivityQuery = {
|
|
60
|
+
/**
|
|
61
|
+
* The `cursor` of the last page read. Left out: the latest activity, and the cursor to follow it from — never a
|
|
62
|
+
* wait, since there is nothing yet to wait after.
|
|
63
|
+
*/
|
|
64
|
+
after?: string;
|
|
65
|
+
/** How long to wait for something when nothing is there yet, in seconds, up to {@link ACTIVITY_WAIT_MAX_SECONDS}. */
|
|
66
|
+
wait?: number;
|
|
67
|
+
/** At most this many, up to {@link ACTIVITY_LIMIT_MAX}. */
|
|
68
|
+
limit?: number;
|
|
69
|
+
/** Include the reader's own changes: those made by the same person through the channel it reads from. */
|
|
70
|
+
mine?: boolean;
|
|
71
|
+
};
|
|
72
|
+
/** Who reads, so their own writes can be told apart: the person, and the channel their writes are recorded under. */
|
|
73
|
+
export type ActivityReader = {
|
|
74
|
+
userId?: number;
|
|
75
|
+
origin: ChangeOrigin;
|
|
76
|
+
};
|
|
77
|
+
/** A page of activity, oldest first. */
|
|
78
|
+
export type SpaceActivityPage = {
|
|
79
|
+
activity: SpaceActivity[];
|
|
80
|
+
/** Pass as `after` to read what comes next. It moves past what was left out too. */
|
|
81
|
+
cursor: string;
|
|
82
|
+
/** More was there than one page holds: read again at once. */
|
|
83
|
+
more: boolean;
|
|
84
|
+
/** How long it waited before answering, in milliseconds: 0 when something was already there. */
|
|
85
|
+
waitedMs: number;
|
|
86
|
+
/** The reader's own changes it left out (`mine` includes them), so leaving them out is never silent. */
|
|
87
|
+
skippedMine: number;
|
|
88
|
+
};
|
|
89
|
+
/** Long enough to be worth a call, short enough for every client and gateway in between: most cut a request at 60 s. */
|
|
90
|
+
export declare const ACTIVITY_WAIT_MAX_SECONDS = 50;
|
|
91
|
+
export declare const ACTIVITY_WAIT_DEFAULT_SECONDS = 45;
|
|
92
|
+
export declare const ACTIVITY_LIMIT_DEFAULT = 20;
|
|
93
|
+
export declare const ACTIVITY_LIMIT_MAX = 100;
|
|
94
|
+
export declare const ACTIVITY_TOUCHED_MAX = 20;
|
|
@@ -35,50 +35,30 @@ var i = [
|
|
|
35
35
|
});
|
|
36
36
|
}, p = (t, n, r, i) => {
|
|
37
37
|
if (n !== void 0) {
|
|
38
|
-
if (!e(n))
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
for (let [e, a] of Object.entries(n)) {
|
|
43
|
-
if (typeof a != "string") {
|
|
44
|
-
d(t, `${r}.${e}`, "Must be a string", "Values are Twig templates the server renders per request");
|
|
45
|
-
continue;
|
|
46
|
-
}
|
|
47
|
-
t.templates.push({
|
|
38
|
+
if (!e(n)) d(t, r, "Must be an object of string values", "Each entry is one name and its templated value");
|
|
39
|
+
else {
|
|
40
|
+
for (let [e, a] of Object.entries(n)) typeof a == "string" ? t.templates.push({
|
|
48
41
|
path: `${r}.${e}`,
|
|
49
42
|
value: a,
|
|
50
43
|
scope: i
|
|
51
|
-
});
|
|
44
|
+
}) : d(t, `${r}.${e}`, "Must be a string", "Values are Twig templates the server renders per request");
|
|
45
|
+
return n;
|
|
52
46
|
}
|
|
53
|
-
return n;
|
|
54
47
|
}
|
|
55
48
|
}, m = (e, t, r, i) => {
|
|
56
|
-
if (t === void 0) {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
60
|
-
if (typeof t != "string" || !n.includes(t)) {
|
|
61
|
-
d(e, r, `"${c(t)}" is not an HTTP method`, `One of ${n.join(", ")}`);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
|
-
return t;
|
|
49
|
+
if (t === void 0) i && d(e, r, "A write endpoint must declare its method", `One of ${n.join(", ")}`);
|
|
50
|
+
else if (typeof t != "string" || !n.includes(t)) d(e, r, `"${c(t)}" is not an HTTP method`, `One of ${n.join(", ")}`);
|
|
51
|
+
else return t;
|
|
65
52
|
}, h = (e, t, n, r) => {
|
|
66
|
-
|
|
67
|
-
d(e, `${n}.path`, "An endpoint needs a path", "It is appended to baseUrl, e.g. \"/api/{{resource}}\"");
|
|
68
|
-
return;
|
|
69
|
-
}
|
|
70
|
-
e.templates.push({
|
|
53
|
+
s(t.path) ? e.templates.push({
|
|
71
54
|
path: `${n}.path`,
|
|
72
55
|
value: t.path,
|
|
73
56
|
scope: r
|
|
74
|
-
});
|
|
57
|
+
}) : d(e, `${n}.path`, "An endpoint needs a path", "It is appended to baseUrl, e.g. \"/api/{{resource}}\"");
|
|
75
58
|
}, g = (e, t, n) => {
|
|
76
59
|
if (t !== void 0) {
|
|
77
|
-
if (typeof t != "string" || !i.includes(t)) {
|
|
78
|
-
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
return t;
|
|
60
|
+
if (typeof t != "string" || !i.includes(t)) d(e, n, `"${c(t)}" is not a paging style`, `One of ${i.join(", ")}`);
|
|
61
|
+
else return t;
|
|
82
62
|
}
|
|
83
63
|
}, _ = (n, r, i, a) => {
|
|
84
64
|
let o = `endpoints.read.${r}`;
|
|
@@ -103,60 +83,35 @@ var i = [
|
|
|
103
83
|
v !== void 0 && !_.includes(v) && f(n, `${o}.query`, `"${r}" pages by ${u} but never uses ${v}, so every page resolves to the first one`, `Put ${v} in the query (or the path) this endpoint sends`);
|
|
104
84
|
}, v = (t, n, r) => {
|
|
105
85
|
let i = `endpoints.write.${n}`;
|
|
106
|
-
|
|
107
|
-
d(t, i, "A write endpoint must be an object", "It declares at least a method and a path");
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
h(t, r, i, "write"), m(t, r.method, `${i}.method`, !0), p(t, r.query, `${i}.query`, "write"), p(t, r.headers, `${i}.headers`, "write"), r.bodyPath !== void 0 && typeof r.bodyPath != "string" && d(t, `${i}.bodyPath`, "Must be a string", "It names where to nest the values, e.g. \"data\"");
|
|
86
|
+
e(r) ? (h(t, r, i, "write"), m(t, r.method, `${i}.method`, !0), p(t, r.query, `${i}.query`, "write"), p(t, r.headers, `${i}.headers`, "write"), r.bodyPath !== void 0 && typeof r.bodyPath != "string" && d(t, `${i}.bodyPath`, "Must be a string", "It names where to nest the values, e.g. \"data\"")) : d(t, i, "A write endpoint must be an object", "It declares at least a method and a path");
|
|
111
87
|
}, y = (t, n, r) => {
|
|
112
|
-
if (!e(n))
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if (!e(n.write)) {
|
|
120
|
-
d(t, "endpoints.write", "Must be an object of endpoints keyed by name", "Omit it for a read-only connector");
|
|
121
|
-
return;
|
|
88
|
+
if (!e(n)) d(t, "endpoints", "A connector must declare its endpoints", "At least one read endpoint, usually \"list\"");
|
|
89
|
+
else {
|
|
90
|
+
if (!e(n.read) || Object.keys(n.read).length === 0) d(t, "endpoints.read", "A connector needs at least one read endpoint", "Name it \"list\" — that is the one a provider element addresses when it names none");
|
|
91
|
+
else for (let [e, i] of Object.entries(n.read)) _(t, e, i, r);
|
|
92
|
+
if (n.write !== void 0) {
|
|
93
|
+
if (!e(n.write)) d(t, "endpoints.write", "Must be an object of endpoints keyed by name", "Omit it for a read-only connector");
|
|
94
|
+
else for (let [e, r] of Object.entries(n.write)) v(t, e, r);
|
|
122
95
|
}
|
|
123
|
-
for (let [e, r] of Object.entries(n.write)) v(t, e, r);
|
|
124
96
|
}
|
|
125
97
|
}, b = (t, n) => {
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
if (n.in !== "header" && n.in !== "query" && d(t, "auth.in", "Auth travels in a header or a query parameter", "One of header, query"), s(n.name) || d(t, "auth.name", "Auth needs the name it is sent under", "e.g. \"Authorization\" for a bearer token"), typeof n.value != "string") {
|
|
132
|
-
d(t, "auth.value", "Must be a string", "A template, e.g. \"Bearer {{credential.token}}\"");
|
|
133
|
-
return;
|
|
134
|
-
}
|
|
135
|
-
t.templates.push({
|
|
136
|
-
path: "auth.value",
|
|
137
|
-
value: n.value,
|
|
138
|
-
scope: "request"
|
|
139
|
-
});
|
|
140
|
-
}
|
|
98
|
+
n !== void 0 && (e(n) ? (n.in !== "header" && n.in !== "query" && d(t, "auth.in", "Auth travels in a header or a query parameter", "One of header, query"), s(n.name) || d(t, "auth.name", "Auth needs the name it is sent under", "e.g. \"Authorization\" for a bearer token"), typeof n.value == "string" ? t.templates.push({
|
|
99
|
+
path: "auth.value",
|
|
100
|
+
value: n.value,
|
|
101
|
+
scope: "request"
|
|
102
|
+
}) : d(t, "auth.value", "Must be a string", "A template, e.g. \"Bearer {{credential.token}}\"")) : d(t, "auth", "Must be an object", "Shape: { in, name, value }"));
|
|
141
103
|
}, x = (e, t) => {
|
|
142
104
|
let n = p(e, t, "operators", "filter");
|
|
143
105
|
if (n) for (let [t, r] of Object.entries(n)) typeof r == "string" && !r.includes("=") && d(e, `operators.${t}`, `Operator "${t}" renders no "key=value" pair, so a filter using it is dropped`, "Write the full query entry, e.g. \"filters[{{field}}][$eq]={{value}}\"");
|
|
144
106
|
}, S = (t, n) => {
|
|
145
107
|
if (n !== void 0) {
|
|
146
|
-
if (!e(n)) {
|
|
147
|
-
|
|
148
|
-
return;
|
|
149
|
-
}
|
|
150
|
-
for (let [e, r] of Object.entries(n)) (typeof r != "string" || !a.includes(r)) && d(t, `fields.${e}`, `"${c(r)}" is not a field type`, `One of ${a.join(", ")}`);
|
|
108
|
+
if (!e(n)) d(t, "fields", "Must be an object of field name → type", `Types: ${a.join(", ")}`);
|
|
109
|
+
else for (let [e, r] of Object.entries(n)) (typeof r != "string" || !a.includes(r)) && d(t, `fields.${e}`, `"${c(r)}" is not a field type`, `One of ${a.join(", ")}`);
|
|
151
110
|
}
|
|
152
111
|
}, C = (e, t) => {
|
|
153
112
|
let n = !1;
|
|
154
113
|
for (let t of e.templates) for (let i of l(t.value)) i.startsWith("credential.") && (n = !0), u(i, t.scope) || f(e, t.path, `{{${i}}} is not a value the engine binds here, so it renders empty`, `Tokens available in this position: ${r.filter((e) => e.scopes.includes(t.scope)).map((e) => e.value).join(", ")}`);
|
|
155
|
-
|
|
156
|
-
f(e, "credential", "This manifest reads {{credential.…}} but names no credential, so every request goes unauthenticated", "The connector still saves. Ask the space owner to create the credential and attach it — the secret is never part of the manifest.");
|
|
157
|
-
return;
|
|
158
|
-
}
|
|
159
|
-
!n && s(t) && f(e, "credential", "A credential is attached but no template reads {{credential.…}}, so it is never sent", "Reference it where the provider expects it, e.g. auth.value = \"Bearer {{credential.token}}\"");
|
|
114
|
+
n && !s(t) ? f(e, "credential", "This manifest reads {{credential.…}} but names no credential, so every request goes unauthenticated", "The connector still saves. Ask the space owner to create the credential and attach it — the secret is never part of the manifest.") : !n && s(t) && f(e, "credential", "A credential is attached but no template reads {{credential.…}}, so it is never sent", "Reference it where the provider expects it, e.g. auth.value = \"Bearer {{credential.token}}\"");
|
|
160
115
|
}, w = (t) => {
|
|
161
116
|
let n = {
|
|
162
117
|
errors: [],
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { e as getSourceName };
|
|
1
|
+
export { default as getSourceName } from "./getSourceName.mjs";
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
export * from './hooks';
|
|
2
1
|
export * from './helpers';
|
|
3
2
|
export { evaluateComputed, liveSources } from './computed';
|
|
4
3
|
export { GLOBAL_SOURCES, COMPUTED_GLOBALS } from './globalSources';
|
|
@@ -7,3 +6,4 @@ export { default as getBindingsDetails } from './getBindingsDetails';
|
|
|
7
6
|
export { default as resolveVariables } from './resolveVariables';
|
|
8
7
|
export type { VariableScope } from './resolveVariables';
|
|
9
8
|
export { default as utility, utilityOptions } from './utility';
|
|
9
|
+
export * from './globalSources';
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { COMPUTED_GLOBALS as e, GLOBAL_SOURCES as t } from "./globalSources.mjs";
|
|
2
|
-
import { evaluateComputed as
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import c from "./hooks/useRegisterSource.mjs";
|
|
1
|
+
import { COMPUTED_GLOBALS as e, GLOBAL_SOURCES as t, GLOBAL_SOURCE_FIELDS as n } from "./globalSources.mjs";
|
|
2
|
+
import { evaluateComputed as r, liveSources as i } from "./computed.mjs";
|
|
3
|
+
import a, { utilityOptions as o } from "./utility/index.mjs";
|
|
4
|
+
import s from "./getBindingsDetails.mjs";
|
|
5
|
+
import c from "./helpers/getSourceName.mjs";
|
|
7
6
|
import l from "./resolveVariables.mjs";
|
|
8
|
-
|
|
9
|
-
export { e as COMPUTED_GLOBALS, t as GLOBAL_SOURCES, n as evaluateComputed, o as getBindingsDetails, s as getSourceName, r as liveSources, l as resolveVariables, c as useRegisterSource, u as useResolvedVariables, i as utility, a as utilityOptions };
|
|
7
|
+
export { e as COMPUTED_GLOBALS, t as GLOBAL_SOURCES, n as GLOBAL_SOURCE_FIELDS, r as evaluateComputed, s as getBindingsDetails, c as getSourceName, i as liveSources, l as resolveVariables, a as utility, o as utilityOptions };
|
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import e from "./arrayMap.mjs";
|
|
2
2
|
import t from "./capitalize.mjs";
|
|
3
3
|
import n from "./dateConverter.mjs";
|
|
4
|
-
import r from "./
|
|
5
|
-
import i from "./
|
|
6
|
-
import a from "./
|
|
7
|
-
import o from "./
|
|
8
|
-
import s from "./
|
|
9
|
-
import c from "./
|
|
4
|
+
import { isTrue as r } from "./truthiness.mjs";
|
|
5
|
+
import i from "./not.mjs";
|
|
6
|
+
import a from "./staticValue.mjs";
|
|
7
|
+
import o from "./stringToArray.mjs";
|
|
8
|
+
import s from "./styleSelector.mjs";
|
|
9
|
+
import c from "./styleVariant.mjs";
|
|
10
|
+
import l from "./twigTemplate.mjs";
|
|
10
11
|
//#region src/dataSource/utility/index.ts
|
|
11
|
-
var
|
|
12
|
-
twigTemplate:
|
|
12
|
+
var u = {
|
|
13
|
+
twigTemplate: l,
|
|
13
14
|
dateConverter: n,
|
|
14
|
-
staticValue:
|
|
15
|
+
staticValue: a,
|
|
15
16
|
capitalize: t,
|
|
16
17
|
arrayMap: e,
|
|
17
|
-
stringToArray:
|
|
18
|
-
not:
|
|
19
|
-
styleSelector:
|
|
20
|
-
styleVariant:
|
|
21
|
-
},
|
|
18
|
+
stringToArray: o,
|
|
19
|
+
not: i,
|
|
20
|
+
styleSelector: s,
|
|
21
|
+
styleVariant: c
|
|
22
|
+
}, d = Object.values(u).map(({ title: e, action: t }) => ({
|
|
22
23
|
label: e,
|
|
23
24
|
value: t
|
|
24
25
|
}));
|
|
25
26
|
//#endregion
|
|
26
|
-
export {
|
|
27
|
+
export { u as default, r as isTrue, d as utilityOptions };
|