@plitzi/sdk-schema 0.38.23 → 0.39.0

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 CHANGED
@@ -1,5 +1,176 @@
1
1
  # @plitzi/sdk-schema
2
2
 
3
+ ## 0.39.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 587c35b: A team of agents on one project (`plitzi run`, `plitzi task`), the page tools those agents measure with, tests kept in
8
+ the space, and what authoring and the elements learnt from the runs. Each command and option is in the CLI's README;
9
+ how the runs work, in `docs/en/agent-runs.md`.
10
+
11
+ ## To do when you upgrade
12
+ - **Node 24.** `engines` is `^24.22.1 || >=26.12.1`; Node 22 is no longer supported (`plitzi doctor` says it,
13
+ `doctor --fix` raises an older project's `engines`).
14
+ - **`createServer({ outbound: { privateOrigins } })` replaces `allowPrivatePluginHosts`:** a space's requests reach no
15
+ private address but the origins named (`privateOrigins: ['http://localhost:9000']`).
16
+ - **Job queues from 0.38.20 or before are recreated, not upgraded:** `createMongoJobQueue` / `createMysqlJobQueue` empty
17
+ or drop the old `action_jobs` / `action_kv` and make them again; `mysqlJobSchemaUpgrades` is gone.
18
+ - **`PLITZI_KV_FILE` is `PLITZI_STATE_DIR`**, a folder holding the server's `kv` and job queue.
19
+ - **A social provider's `fetchProfile` takes `{ accessToken, idToken, nonce }`**, and `createSocialAuth(...).start` is
20
+ async.
21
+ - **A `DraftStore` of a deployment's own keeps `inspected`** beside `reusable`, or a test session renders without the
22
+ state bridge.
23
+ - **`navigation.navigate(url, { external, replace })`** takes an object where it took `navigate(url, true)`.
24
+ - **`window.__plitzi.setSource` / `setAttribute` may answer `{ refused }`**: read it before treating the answer as written.
25
+ - **Renamed:** `stepText` → `e2eStepText` (a run's `said` is the step in words); `OverQuotaNotice` → `QuotaNotice` and
26
+ its classes `plitzi-quota-notice…`; `sightOf` / `sightText` come from `@plitzi/sdk-shared/devTools/sight`.
27
+ - **`SchemaVariables` and `StyleVariables` draw no add button of their own:** the holder passes `adding`, `onAddingEnd`
28
+ and optionally `empty`.
29
+ - **A page handed to `runE2eTest`** has `selectOption`, `position` in `click`/`hover` and `evaluate(fn, arg)`, as a
30
+ Playwright locator: a hand-written page adds them.
31
+ - **Journey steps play as the page commands do:** `scroll` with `dx`/`dy` scrolls the element's content, `waitFor`
32
+ waits 10 s, `type` replaces a field's value.
33
+ - **Authoring refuses more:** two flows of one element naming a step alike (`step-duplicate`), `visible` written as an
34
+ expression (`visible-expression`), a step condition naming a source by id alone (`condition-short-source`).
35
+ `navbar` / `navbarItem` are no longer read by `specFromSpace`.
36
+ - **`/robots.txt` ends naming its sitemap** unless the space's own text does.
37
+ - **The CLI's part of a project is `.plitzi/`** (it was split with `plitzi/`): `plitzi doctor --fix` moves it, and a
38
+ tsconfig names `.plitzi/**/*`.
39
+ - **`plitzi upgrade`** brings the new scripts (`start:preview`, the visual suite's server on 8400, `test`), the ignores
40
+ for `.plitzi/plitzi-reports/` and the skills. `test` runs the project's own tests, so red tests now fail
41
+ `plitzi verify` and a run's checks.
42
+ - **Reports to Plitzi live in `.plitzi/plitzi-reports/`**, committed: a run's in `runs/<run>/`, an agent's in
43
+ `agents/<date>/`. The old files are read no more.
44
+ - **The CLI's surface is smaller — one command for each thing.** Old names and flags are refused naming the new one;
45
+ `plitzi upgrade skills --write` updates the agents' skills. The main moves: `run plan` / `run rehearse` →
46
+ `run open --dry-run [--rehearse]`; `run extend` → `run open <stage>`; `run purge` → `run abort`; `task take` →
47
+ `task next <task>`; `task ask` / `block` / `note` → `task tell --ask | --blocked | --handoff`; `task wait` / `release`
48
+ → `task claim --wait | --release`; `task request` → `task propose --file`; `task check --before | --mutate` →
49
+ `task prove`; `run feedback` → `run report --plitzi`; `functions pull|push` → `space pull|push functions`;
50
+ `runtime push` → `space push runtime`; `page shot --live` / `--clip` → `--fresh` / `--within`; `PLITZI_TASK_TOKEN` →
51
+ `PLITZI_TOKEN`.
52
+ - **Research and reviews are cards on one board:** `task spike` and the separate UI review are gone; a card's `review`
53
+ names its roles in order. Runs opened before keep working.
54
+ - **Page commands:** `page check --expect` fails only on what it expects; every page command reads at 900 px tall
55
+ (`--height`); a page that sends a guest away is read signed in as the project's account (`--as`, `--guest`).
56
+ - **`create --from`** names page files by the page's name; a space's functions are pushed without their tests.
57
+
58
+ ## A space's tests (`@plitzi/sdk-authoring`, `@plitzi/sdk-shared`, `@plitzi/plitzi-builder`, `@plitzi/sdk-mcp`)
59
+ - **Tests are part of the space's document** (`Schema.tests`): unit tests (element checks) and journeys (what a visitor
60
+ does), authored in code, edited in the builder's Tests area, played on the canvas or the server. See
61
+ `docs/en/space-tests.md`.
62
+ - **Journeys play signed in as test accounts** (`tests.accounts`), carry tags, can be held and stopped
63
+ (`runE2eTest`'s `beforeStep`), and hold element checks (`e2e.expectCheck`).
64
+ - **`plitzi test [id…]`** runs a project's tests; **`plitzi_test`** lets an agent run them over the MCP. What a plan
65
+ allows (`journeysPerSpace`, `serverRunsPerMonth`) is in its entitlements; a `canTest` grant writes tests alone.
66
+
67
+ ## Several agents on one project (`@plitzi/cli`)
68
+ - **A run is a kanban:** a lead plans, reviews and closes; developers, testers, designers and scouts take cards with
69
+ `task next`, each in its own copy of the project; every card is reviewed by the roles it names, step by step.
70
+ Nothing reaches the project until a person applies the run (`run finish --apply`).
71
+ - **Files are owned by imports:** one agent per file, shared files taken by turns or changed by agreement
72
+ (`task propose`), merged line by line, checked on the whole result.
73
+ - **The run keeps itself going:** a keeper starts the agents work is waiting for, and holds
74
+ starts after the harness's limit or repeated quick exits until the lead allows them (`run hold`, `run allow`).
75
+ - **`run monitor`:** the run live in a terminal — board, flow, agents, spend, activity — with an emergency panel (`!`)
76
+ to pause, resume, hold or allow agents.
77
+ - **A change mid-run says what it reaches:** `run open <stage> --dry-run` and `run amend --dry-run` name the approved
78
+ tasks, tasks at work and tests each change touches, read off the import graph.
79
+ - **Reviews see what goes in:** a review taken says whether the task merges with the run's newer work and, if not, the
80
+ failing lines; `task show <file> --merged` and `task look --merged` read and serve the merge;
81
+ `task look --alone <element> --with '{…}'` draws a component or plugin no page places yet. A step's time stops while
82
+ its reviewer proves or looks.
83
+ - **Proofs:** `task prove --before` (what each acceptance line proves against the run before the task) and
84
+ `--mutate` (whether a task's tests catch a broken change, with a control run).
85
+ - **The finish:** `run finish` checks the whole result and stops at the first failing line; `--every-line` reports
86
+ them all. The run then leaves its reports in `.plitzi/plitzi-reports/runs/<run>/`.
87
+ - **A report to Plitzi holds nothing of the person or the project:** a run's `feedback.md` writes over names, emails,
88
+ addresses, IPs, the project's files, tasks and elements, leaves out what was said of the project alone, and lists
89
+ quoted passages for the person to read before sending. `plitzi feedback` carries no project name, asks the developer
90
+ before anything of the project goes in, and `plitzi feedback --check <file>` names what a filled report still holds.
91
+
92
+ ## Page tools (`@plitzi/cli`, `@plitzi/sdk-authoring`)
93
+ - **`page measure`** reads what an element draws (`--only drawn`, `box-*`, `attr:<name>`, `accessible-name`,
94
+ `scroll-*`, custom properties) and holds bounds and positions (`--expect "width<=44px"`, `"a.bottom + 8 <= b.top"`).
95
+ - **`page play`** plays steps — `drag … hold`, `scroll page 1500`, `click <el> 30%,60%` — reads what is drawn, not
96
+ what is in the DOM, and `--motion` plays animations moving. A press is made once and waits for the page to take it.
97
+ - **`page check`** says what a visitor cannot reach, text cut or spilling, canvases left blank, the server's error page
98
+ when the space does not author, and holds a text whole (`=`) or in part (`~`).
99
+ - **`page shot`** waits for canvases, pictures hovers (`--hover`, `--frames`) and parts (`--within`), and says what it
100
+ could not picture.
101
+ - **Every page command reads a page as one visitor from the same flags** (`--as`, `--guest`, `--width`, `--height`,
102
+ `--fresh`), with a browser driver of the CLI's own.
103
+
104
+ ## Authoring (`@plitzi/sdk-authoring`)
105
+ - **New checks:** a server provider the page server cannot read (`server-query-unresolved`) or that reads browser state
106
+ (`server-when-unknown`), an action without `runtime: 'server'` (`server-source-in-browser`), class overrides,
107
+ messages arriving while a flow runs, unused plugins.
108
+ - **New authoring:** `focus('field')`, a factory for every trigger, the scroll family's sides, `pagesIn(...)` to
109
+ register pages by folder, channel topics with a choice, a plugin's imported stylesheets read for its tokens.
110
+ - **An element drawn alone:** a server started with `PLITZI_PREVIEW_FILE` gets a page for one element at
111
+ `/plitzi-preview` (`withPreview`, `SpacePreviewError`) — what `task look --alone` uses.
112
+
113
+ ## Elements and the SDK (`@plitzi/sdk-elements`, `@plitzi/plitzi-sdk`, `@plitzi/sdk-shared`)
114
+ - **Navigation:** `navigate` can replace the address, and a navigation inside the site leaves the scroll as a page
115
+ load would.
116
+ - **Providers:** a `when` holds the same in the browser and on the page server; a server provider can read another
117
+ site's address while the page is built.
118
+ - **Plans and roles in the contract:** entitlements (`TSpaceEntitlements`), the space role (`TSpaceAccess`), the quota
119
+ warning at 80% (`render.quotaNear`) and the "Made with Plitzi" badge (`PlitziBadge`).
120
+ - **Fixes:** a binding's `sourceTo` is the previous value; an element with no tag and no `visible` draws nothing;
121
+ placeholder words never reach a page; notifications stay open for a visitor who asked for less motion.
122
+
123
+ ## Server (`@plitzi/sdk-server`, `@plitzi/sdk-auth`, `@plitzi/sdk-mcp`)
124
+ - **`/sitemap.xml`** for every space, and `/robots.txt` naming it.
125
+ - **Accounts:** terms accepted at sign-up (MySQL schema version 7), single sign-on with any OpenID Connect issuer
126
+ (`createOidcProvider`), providers resolved at run time, a password that may not sign in, `/auth/continue` with a step
127
+ of the deployment's own, a signed-out visitor never signed back in by a stale answer.
128
+ - **Policy adapters:** metering can hold a page back (503), decide the badge and `noindex`; the MCP can cap tool calls
129
+ and names the space's plan; realtime admits spaces per deployment.
130
+ - **Dev server:** a removed plugin folder is unregistered (`PluginRegistry.unregister`), and a space that does not
131
+ author is said whole, with no stack.
132
+
133
+ ## The builder (`@plitzi/plitzi-builder`)
134
+ - **A Tests area** with journeys played beside the page at the journey's device, and element checks.
135
+ - **One way to build a panel**, a header grouped by what its controls do, and the layout's mask dimming only what the
136
+ layout draws.
137
+ - **Plans and roles shown:** what the role allows (`useSpaceAccess`), what the plan leaves out shown locked, the plan
138
+ and its spend in the header; pages left out of the sitemap marked.
139
+
140
+ ## Dev tools (`@plitzi/sdk-dev-tools`)
141
+ - **`element(id).visible` is what a visitor sees** (`sightOf`), with why not; `element(id).resolved` says what each
142
+ binding gave; a refused server action is a `refused` step.
143
+ - **Report what you see** in the Run tab of a run's preview, and the panel docks at the bottom under 900 px.
144
+
145
+ ## The workspace
146
+ - **No file past 600 lines of code** (`max-lines`), and ESLint's `quotes` rule is gone — Prettier writes them.
147
+
148
+ ### Patch Changes
149
+
150
+ - Updated dependencies [587c35b]
151
+ - @plitzi/sdk-shared@0.39.0
152
+ - @plitzi/sdk-style@0.39.0
153
+
154
+ ## 0.38.24
155
+
156
+ ### Patch Changes
157
+
158
+ - 5858b9f: ## Server
159
+
160
+ - **`ctx.oauth.callbackUrl()`** (`@plitzi/sdk-server`) — PZ-161. The address providers send a visitor back to, as this
161
+ run's `connect` hands it to them: for a page that shows whoever sets up the app what to register, instead of
162
+ rebuilding the platform's rule. Refused in a run no visitor's request started when the deployment fixed no
163
+ `functions.oauth.callbackOrigin`.
164
+ - **In production the project's server fixes no OAuth callback** (`@plitzi/sdk-server`). 0.38.23's loopback default
165
+ applied wherever `PUBLIC_URL` was not HTTPS — a container behind a proxy sent providers to its own
166
+ `http://127.0.0.1:8080`. Now loopback is the default while developing only; in production the callback is on the
167
+ address each visitor's request came on (the site's domain, from `Host` and `X-Forwarded-Proto`), and the server says
168
+ to register that domain's `/fn/oauth/callback`.
169
+
170
+ - Updated dependencies [5858b9f]
171
+ - @plitzi/sdk-shared@0.38.24
172
+ - @plitzi/sdk-style@0.38.24
173
+
3
174
  ## 0.38.23
4
175
 
5
176
  ### Patch Changes
@@ -3589,7 +3760,7 @@ author`, `plitzi_validate`/`plitzi_apply`, `plitzi explain` and the builder's pr
3589
3760
  - **Devices are listed by device, not by session.** `GET /devices/sessions` groups sessions by what they were created
3590
3761
  from and answers this device apart; a browser that signed in forty times is one row saying "40 sessions". The list
3591
3762
  had shipped and drawn every session — 1,218 for one account a test suite signs in as — inside a box that scrolled.
3592
- - **Every device is named for what it is**: the application as it registered over OAuth (`Plitzi CLI on carlos-mbp`,
3763
+ - **Every device is named for what it is**: the application as it registered over OAuth (`Plitzi CLI on dev-laptop`,
3593
3764
  `Plitzi Desktop on studio`), a browser and its system, an automated client (Playwright, headless Chrome) — never a
3594
3765
  raw user agent. Sessions record their address and **when they were last used** (at most every five minutes, on the
3595
3766
  lookup a request already makes). A sign-in deletes the account's dead sessions.
@@ -1,5 +1,6 @@
1
1
  import { Element, PageFolder, Schema, SnippetStyle, SchemaFlag, SchemaVariable, DropPosition, SpaceComponent, SpaceComponentDeclaration } from '@plitzi/sdk-shared';
2
2
  import { ReducerActionOrigin } from '@plitzi/sdk-shared/helpers';
3
+ import { SchemaSettingValue } from '@plitzi/sdk-shared/schema';
3
4
  export declare const SchemaActions: {
4
5
  readonly SCHEMA_UPDATE: "SCHEMA_UPDATE";
5
6
  readonly SCHEMA_ADD_PAGE: "SCHEMA_ADD_PAGE";
@@ -105,7 +106,7 @@ export type SchemaReducerActions = SchemaReducerActionsBase & ({
105
106
  } | {
106
107
  type: 'SCHEMA_UPDATE_SETTINGS';
107
108
  path: string;
108
- value: string | number | boolean;
109
+ value: SchemaSettingValue;
109
110
  } | {
110
111
  type: 'SCHEMA_ADD_COMPONENT';
111
112
  component: SpaceComponent;
@@ -2,12 +2,13 @@ import e from "./helpers/FlatMap.mjs";
2
2
  import { addComponent as t, detachInstance as n, flatMapOf as r, removeComponent as i, renameElement as a, updateComponent as o } from "./helpers/components.mjs";
3
3
  import { get as s, has as c, set as l } from "@plitzi/plitzi-ui/helpers";
4
4
  import { produce as u } from "immer";
5
+ import { isSchemaSetting as d } from "@plitzi/sdk-shared/schema";
5
6
  //#region src/SchemaReducer.ts
6
- var d = (e, t) => {
7
+ var f = (e, t) => {
7
8
  if (t.length === 0) return;
8
9
  let n = t.filter((t) => e.variables && !e.variables.find((e) => e.name === t.name));
9
10
  l(e, "variables", [...e.variables ?? [], ...n]);
10
- }, f = {
11
+ }, p = {
11
12
  SCHEMA_UPDATE: "SCHEMA_UPDATE",
12
13
  SCHEMA_ADD_PAGE: "SCHEMA_ADD_PAGE",
13
14
  SCHEMA_HOME_PAGE: "SCHEMA_HOME_PAGE",
@@ -34,184 +35,184 @@ var d = (e, t) => {
34
35
  SCHEMA_UPDATE_COMPONENT: "SCHEMA_UPDATE_COMPONENT",
35
36
  SCHEMA_REMOVE_COMPONENT: "SCHEMA_REMOVE_COMPONENT",
36
37
  SCHEMA_DETACH_INSTANCE: "SCHEMA_DETACH_INSTANCE"
37
- }, p = (p, m) => {
38
- switch (m.type) {
39
- case f.SCHEMA_UPDATE: return {
40
- ...p,
41
- ...m.schema
38
+ }, m = (m, h) => {
39
+ switch (h.type) {
40
+ case p.SCHEMA_UPDATE: return {
41
+ ...m,
42
+ ...h.schema
42
43
  };
43
- case f.SCHEMA_ADD_PAGE: {
44
- let { page: e } = m;
45
- return u(p, (t) => {
44
+ case p.SCHEMA_ADD_PAGE: {
45
+ let { page: e } = h;
46
+ return u(m, (t) => {
46
47
  l(t, "flat", {
47
48
  ...t.flat,
48
49
  [e.id]: e
49
50
  }), t.pages.push(e.id);
50
51
  });
51
52
  }
52
- case f.SCHEMA_HOME_PAGE: {
53
- let { flat: e, pages: t } = p, { pageId: n } = m, r;
53
+ case p.SCHEMA_HOME_PAGE: {
54
+ let { flat: e, pages: t } = m, { pageId: n } = h, r;
54
55
  return t.forEach((t) => {
55
56
  if (r) return;
56
57
  let n = e[t];
57
58
  s(n, "attributes.default", !1) && (r = n);
58
- }), r ? u(p, (e) => {
59
+ }), r ? u(m, (e) => {
59
60
  l(e.flat, `${n}.attributes.default`, !0), l(e.flat, `${r.id}.attributes.default`, !1);
60
- }) : u(p, (e) => {
61
+ }) : u(m, (e) => {
61
62
  l(e.flat, `${n}.attributes.default`, !0);
62
63
  });
63
64
  }
64
- case f.SCHEMA_UPDATE_PAGE: {
65
- let { page: e } = m;
66
- return u(p, (t) => {
65
+ case p.SCHEMA_UPDATE_PAGE: {
66
+ let { page: e } = h;
67
+ return u(m, (t) => {
67
68
  l(t.flat, e.id, e);
68
69
  });
69
70
  }
70
- case f.SCHEMA_REMOVE_PAGE: {
71
- let { pageId: t } = m;
72
- return u(p, (n) => {
71
+ case p.SCHEMA_REMOVE_PAGE: {
72
+ let { pageId: t } = h;
73
+ return u(m, (n) => {
73
74
  e.removeElement(n.flat, t, !0), n.pages = n.pages.filter((e) => e !== t);
74
75
  });
75
76
  }
76
- case f.SCHEMA_ADD_PAGE_FOLDER: {
77
- let { pageFolder: e } = m;
78
- return u(p, (t) => {
77
+ case p.SCHEMA_ADD_PAGE_FOLDER: {
78
+ let { pageFolder: e } = h;
79
+ return u(m, (t) => {
79
80
  t.pageFolders.push(e);
80
81
  });
81
82
  }
82
- case f.SCHEMA_UPDATE_PAGE_FOLDER: {
83
- let { pageFolder: e } = m;
84
- return u(p, (t) => {
83
+ case p.SCHEMA_UPDATE_PAGE_FOLDER: {
84
+ let { pageFolder: e } = h;
85
+ return u(m, (t) => {
85
86
  let n = t.pageFolders.findIndex((t) => t.id === e.id);
86
87
  n !== -1 && (t.pageFolders[n] = e);
87
88
  });
88
89
  }
89
- case f.SCHEMA_REMOVE_PAGE_FOLDER: {
90
- let { pageFolderId: e } = m;
91
- return u(p, (t) => {
90
+ case p.SCHEMA_REMOVE_PAGE_FOLDER: {
91
+ let { pageFolderId: e } = h;
92
+ return u(m, (t) => {
92
93
  t.pageFolders = t.pageFolders.filter((t) => t.id !== e);
93
94
  });
94
95
  }
95
- case f.SCHEMA_ADD_VARIABLE: {
96
- let { variable: e } = m;
97
- return u(p, (t) => {
96
+ case p.SCHEMA_ADD_VARIABLE: {
97
+ let { variable: e } = h;
98
+ return u(m, (t) => {
98
99
  t.variables ||= [], t.variables.push(e);
99
100
  });
100
101
  }
101
- case f.SCHEMA_UPDATE_VARIABLE: {
102
- let { variable: e } = m;
103
- return p.variables ? u(p, (t) => {
102
+ case p.SCHEMA_UPDATE_VARIABLE: {
103
+ let { variable: e } = h;
104
+ return m.variables ? u(m, (t) => {
104
105
  let n = t.variables.findIndex((t) => t.name === e.name);
105
106
  t.variables[n] && (t.variables[n] = e);
106
- }) : p;
107
+ }) : m;
107
108
  }
108
- case f.SCHEMA_REMOVE_VARIABLE: {
109
- let { name: e } = m;
110
- return p.variables ? u(p, (t) => {
109
+ case p.SCHEMA_REMOVE_VARIABLE: {
110
+ let { name: e } = h;
111
+ return m.variables ? u(m, (t) => {
111
112
  t.variables = t.variables.filter((t) => t.name !== e);
112
- }) : p;
113
+ }) : m;
113
114
  }
114
- case f.SCHEMA_SET_FLAG: {
115
- let { name: e, flag: t } = m;
116
- return u(p, (n) => {
115
+ case p.SCHEMA_SET_FLAG: {
116
+ let { name: e, flag: t } = h;
117
+ return u(m, (n) => {
117
118
  n.flags = {
118
119
  ...n.flags,
119
120
  [e]: t
120
121
  };
121
122
  });
122
123
  }
123
- case f.SCHEMA_REMOVE_FLAG: {
124
- let { name: e } = m;
125
- return !p.flags || !Object.hasOwn(p.flags, e) ? p : u(p, (t) => {
124
+ case p.SCHEMA_REMOVE_FLAG: {
125
+ let { name: e } = h;
126
+ return !m.flags || !Object.hasOwn(m.flags, e) ? m : u(m, (t) => {
126
127
  let { [e]: n, ...r } = t.flags ?? {};
127
128
  t.flags = r;
128
129
  });
129
130
  }
130
- case f.SCHEMA_ADD_ELEMENT: {
131
- let { to: e, data: t, dropPosition: n, initialItems: i, variables: a = [] } = m;
132
- return u(p, (o) => {
133
- r(o, e)?.addElement(t, e, n, i), d(o, a);
131
+ case p.SCHEMA_ADD_ELEMENT: {
132
+ let { to: e, data: t, dropPosition: n, initialItems: i, variables: a = [] } = h;
133
+ return u(m, (o) => {
134
+ r(o, e)?.addElement(t, e, n, i), f(o, a);
134
135
  });
135
136
  }
136
- case f.SCHEMA_ADD_SNIPPET: {
137
- let { to: e, data: t, dropPosition: n, initialItems: i, variables: a = [] } = m;
138
- return u(p, (o) => {
137
+ case p.SCHEMA_ADD_SNIPPET: {
138
+ let { to: e, data: t, dropPosition: n, initialItems: i, variables: a = [] } = h;
139
+ return u(m, (o) => {
139
140
  let { [t.id]: s, ...c } = structuredClone({
140
141
  ...i,
141
142
  [t.id]: t
142
143
  });
143
- r(o, e)?.addElement(s, e, n, c) && d(o, a);
144
+ r(o, e)?.addElement(s, e, n, c) && f(o, a);
144
145
  });
145
146
  }
146
- case f.SCHEMA_REMOVE_ELEMENT: {
147
- let { elementId: e } = m;
148
- return u(p, (t) => {
147
+ case p.SCHEMA_REMOVE_ELEMENT: {
148
+ let { elementId: e } = h;
149
+ return u(m, (t) => {
149
150
  r(t, e)?.removeElement(e);
150
151
  });
151
152
  }
152
- case f.SCHEMA_MOVE_ELEMENT: {
153
- let { from: e, to: t, elementId: n, dropPosition: i } = m;
154
- return u(p, (a) => {
153
+ case p.SCHEMA_MOVE_ELEMENT: {
154
+ let { from: e, to: t, elementId: n, dropPosition: i } = h;
155
+ return u(m, (a) => {
155
156
  let o = r(a, n);
156
157
  o && Object.hasOwn(o.flat, t) && o.moveElement(e, t, n, i);
157
158
  });
158
159
  }
159
- case f.SCHEMA_CLONE_ELEMENT: {
160
- let { to: e, data: t, dropPosition: n, initialItems: i } = m;
161
- return u(p, (a) => {
160
+ case p.SCHEMA_CLONE_ELEMENT: {
161
+ let { to: e, data: t, dropPosition: n, initialItems: i } = h;
162
+ return u(m, (a) => {
162
163
  r(a, e)?.addElement(t, e, n, i);
163
164
  });
164
165
  }
165
- case f.SCHEMA_UPDATE_ELEMENT: {
166
- let { element: e } = m;
167
- return u(p, (t) => {
166
+ case p.SCHEMA_UPDATE_ELEMENT: {
167
+ let { element: e } = h;
168
+ return u(m, (t) => {
168
169
  r(t, e.id)?.updateElement(e);
169
170
  });
170
171
  }
171
- case f.SCHEMA_RENAME_ELEMENT: {
172
- let { elementId: e, id: t } = m;
173
- return u(p, (n) => {
172
+ case p.SCHEMA_RENAME_ELEMENT: {
173
+ let { elementId: e, id: t } = h;
174
+ return u(m, (n) => {
174
175
  a(n, e, t);
175
176
  });
176
177
  }
177
- case f.SCHEMA_UPDATE_ELEMENTS: {
178
- let { elements: e } = m;
179
- return u(p, (t) => {
178
+ case p.SCHEMA_UPDATE_ELEMENTS: {
179
+ let { elements: e } = h;
180
+ return u(m, (t) => {
180
181
  e.forEach((e) => r(t, e.id)?.updateElement(e));
181
182
  });
182
183
  }
183
- case f.SCHEMA_UPDATE_SETTINGS: {
184
- let { path: e, value: t } = m;
185
- return u(p, (n) => {
186
- e && c(p.settings, e) ? l(n.settings, e, t) : e || l(n, "settings", t);
184
+ case p.SCHEMA_UPDATE_SETTINGS: {
185
+ let { path: e, value: t } = h;
186
+ return u(m, (n) => {
187
+ e && (c(m.settings, e) || d(e.split(".")[0] ?? "")) ? l(n.settings, e, t) : e || l(n, "settings", t);
187
188
  });
188
189
  }
189
- case f.SCHEMA_ADD_COMPONENT: {
190
- let { component: e, from: n } = m;
191
- return u(p, (r) => {
190
+ case p.SCHEMA_ADD_COMPONENT: {
191
+ let { component: e, from: n } = h;
192
+ return u(m, (r) => {
192
193
  t(r, structuredClone(e), n);
193
194
  });
194
195
  }
195
- case f.SCHEMA_UPDATE_COMPONENT: {
196
- let { componentId: e, declaration: t } = m;
197
- return u(p, (n) => {
196
+ case p.SCHEMA_UPDATE_COMPONENT: {
197
+ let { componentId: e, declaration: t } = h;
198
+ return u(m, (n) => {
198
199
  o(n, e, t);
199
200
  });
200
201
  }
201
- case f.SCHEMA_REMOVE_COMPONENT: {
202
- let { componentId: e } = m;
203
- return u(p, (t) => {
202
+ case p.SCHEMA_REMOVE_COMPONENT: {
203
+ let { componentId: e } = h;
204
+ return u(m, (t) => {
204
205
  i(t, e);
205
206
  });
206
207
  }
207
- case f.SCHEMA_DETACH_INSTANCE: {
208
- let { instanceId: e } = m;
209
- return u(p, (t) => {
208
+ case p.SCHEMA_DETACH_INSTANCE: {
209
+ let { instanceId: e } = h;
210
+ return u(m, (t) => {
210
211
  n(t, e);
211
212
  });
212
213
  }
213
- default: return p;
214
+ default: return m;
214
215
  }
215
216
  };
216
217
  //#endregion
217
- export { f as SchemaActions, p as default };
218
+ export { p as SchemaActions, m as default };
@@ -0,0 +1,32 @@
1
+ import { ValidationContext } from './context';
2
+ /** What its elements read and do: variables, binding sources, bindings and interactions. */
3
+ export declare const validateVariables: ({ errors, warnings, variables }: ValidationContext) => void;
4
+ /**
5
+ * Every data-source name a binding reads must name an element that exists.
6
+ *
7
+ * A source is `<type>_<id>` optionally followed by `.<field…>` — the convention `repointIds` is built on. A typo
8
+ * in the id half is the most expensive silent failure a space can carry: the binding resolves to nothing, the
9
+ * element renders its placeholder, and no layer anywhere reports a missing name. Only heads whose type half is
10
+ * an element type actually present in this document are checked, so a flow node id or a bare `form` is left
11
+ * alone.
12
+ */
13
+ export declare const validateBindingSources: ({ errors, flat }: ValidationContext, sourceTypes?: Record<string, string>) => void;
14
+ /**
15
+ * The three fields that make a flow a flow.
16
+ *
17
+ * A flow is a linked list: each node names the one before and the one after, and every node carries the id of
18
+ * the first as its `flowId`. Any of the three pointing at a node that is not there produces a flow that half
19
+ * runs — the first steps fire, the rest never do — which reads exactly like an action that failed.
20
+ *
21
+ * An element-`callback` node also names the element it runs against, and that name is an element id: a global
22
+ * callback names its source module instead (`space`, `state`, `auth`) and a utility names nothing at all, so
23
+ * neither is resolved here.
24
+ */
25
+ export declare const validateInteractions: ({ errors, warnings, flat, getElement }: ValidationContext) => void;
26
+ /**
27
+ * A binding's id, which is element-local but still has to be one thing.
28
+ *
29
+ * Two bindings of one element sharing an id is what makes `patchBinding`/`deleteBinding` hit whichever the
30
+ * search found first — an edit that appears to work and lands on the wrong rule.
31
+ */
32
+ export declare const validateBindings: ({ errors, flat }: ValidationContext) => void;
@@ -0,0 +1,121 @@
1
+ import { isValidElementId as e } from "../elementId.mjs";
2
+ //#region src/helpers/schemaValidator/bindings.ts
3
+ var t = ({ errors: e, warnings: t, variables: n }) => {
4
+ let r = /* @__PURE__ */ new Set();
5
+ n.forEach((n, i) => {
6
+ n.name ? (r.has(n.name) && e.push({
7
+ code: "DUPLICATE_VARIABLE",
8
+ message: `Duplicate variable name "${n.name}"`,
9
+ details: { variableName: n.name }
10
+ }), r.add(n.name), n.type || t.push({
11
+ code: "MISSING_VARIABLE_TYPE",
12
+ message: `Variable "${n.name}" has no type`,
13
+ details: { variableName: n.name }
14
+ })) : e.push({
15
+ code: "INVALID_VARIABLE",
16
+ message: `Variable at index ${i} has no name`
17
+ });
18
+ });
19
+ }, n = ({ errors: e, flat: t }, n) => {
20
+ let r = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), a = /* @__PURE__ */ new Map();
21
+ Object.values(t).forEach((e) => {
22
+ if (!e) return;
23
+ r.add(e.id);
24
+ let t = n?.[e.definition.type];
25
+ t && a.set(e.id, t), i.add(e.definition.type);
26
+ }), Object.values(t).forEach((t) => {
27
+ t && t.definition.bindings && Object.entries(t.definition.bindings).forEach(([o, s]) => {
28
+ (s ?? []).forEach((s) => {
29
+ let c = s.source.split(".")[0], l = c.indexOf("_");
30
+ if (l === -1) return;
31
+ let u = c.slice(0, l), d = c.slice(l + 1), f = `Element "${t.id}" binds ${o}.${s.to} to "${s.source}"`;
32
+ if (!r.has(d)) {
33
+ (n || i.has(u)) && e.push({
34
+ code: "UNRESOLVED_BINDING_SOURCE",
35
+ message: `${f}, but no element answers to the name "${d}"`,
36
+ elementId: t.id,
37
+ missing: d,
38
+ details: {
39
+ source: s.source,
40
+ elementId: d
41
+ }
42
+ });
43
+ return;
44
+ }
45
+ let p = a.get(d);
46
+ p && p !== u && e.push({
47
+ code: "MISMATCHED_BINDING_SOURCE",
48
+ message: `${f}, but "${d}" publishes its source as "${p}_${d}"`,
49
+ elementId: t.id,
50
+ details: {
51
+ source: s.source,
52
+ elementId: d,
53
+ expected: `${p}_${d}`
54
+ }
55
+ });
56
+ });
57
+ });
58
+ });
59
+ }, r = ({ errors: t, warnings: n, flat: r, getElement: i }) => {
60
+ let a = new Set(Object.keys(r));
61
+ Object.values(r).forEach((r) => {
62
+ let o = r?.definition.interactions;
63
+ if (!o) return;
64
+ let s = Object.keys(o);
65
+ Object.entries(o).forEach(([o, c]) => {
66
+ e(o) || t.push({
67
+ code: "INVALID_INTERACTION_ID",
68
+ message: `Interaction "${o}" on element "${r.id}" has a name that must start with a letter, then letters, numbers, hyphens and underscores — a later step reads it as {{ ${o}.field }}`,
69
+ elementId: r.id
70
+ }), c.id !== o && t.push({
71
+ code: "INTERACTION_ID_MISMATCH",
72
+ message: `Interaction id "${c.id}" on element "${r.id}" doesn't match its key "${o}"`,
73
+ elementId: r.id
74
+ }), ["beforeNode", "afterNode"].forEach((e) => {
75
+ let n = c[e];
76
+ n && !s.includes(n) && t.push({
77
+ code: "BROKEN_FLOW_LINK",
78
+ message: `Interaction "${c.id}" on element "${r.id}" names ${e} "${n}", which is not a node of this flow`,
79
+ elementId: r.id
80
+ });
81
+ }), c.flowId && !s.includes(c.flowId) && t.push({
82
+ code: "BROKEN_FLOW_ID",
83
+ message: `Interaction "${c.id}" on element "${r.id}" belongs to flow "${c.flowId}", which is not a node of this flow`,
84
+ elementId: r.id
85
+ }), c.type === "callback" && c.elementId && !a.has(c.elementId) && t.push({
86
+ code: "UNRESOLVED_INTERACTION_TARGET",
87
+ message: `Interaction "${c.id}" on element "${r.id}" runs against "${c.elementId}", but no element answers to that name`,
88
+ elementId: r.id,
89
+ missing: c.elementId,
90
+ wantedBy: c.action
91
+ });
92
+ let l = c.type === "trigger" && c.action === "onSubmit" && c.enabled ? i(c.elementId ?? r.id) : void 0;
93
+ l?.definition.type === "form" && l.attributes.managedByInteractions !== !0 && n.push({
94
+ code: "FORM_SUBMIT_UNMANAGED",
95
+ message: `Form "${l.id}" has an onSubmit flow but is not managedByInteractions, so the browser submits it natively and the flow never runs — set managedByInteractions: true`,
96
+ elementId: l.id
97
+ });
98
+ });
99
+ });
100
+ }, i = ({ errors: e, flat: t }) => {
101
+ Object.values(t).forEach((t) => {
102
+ if (!t || !t.definition.bindings) return;
103
+ let n = /* @__PURE__ */ new Set();
104
+ Object.entries(t.definition.bindings).forEach(([r, i]) => {
105
+ (i ?? []).forEach((i) => {
106
+ i.id ? (n.has(i.id) && e.push({
107
+ code: "DUPLICATE_BINDING_ID",
108
+ message: `Element "${t.id}" has two bindings called "${i.id}"`,
109
+ elementId: t.id,
110
+ details: { bindingId: i.id }
111
+ }), n.add(i.id)) : e.push({
112
+ code: "MISSING_BINDING_ID",
113
+ message: `Element "${t.id}" has a ${r} binding to "${i.to}" with no id`,
114
+ elementId: t.id
115
+ });
116
+ });
117
+ });
118
+ });
119
+ };
120
+ //#endregion
121
+ export { n as validateBindingSources, i as validateBindings, r as validateInteractions, t as validateVariables };
@@ -0,0 +1,13 @@
1
+ import { ValidationContext } from './context';
2
+ import { SchemaValidationOptions, SchemaValidationResult } from './types';
3
+ import { Schema } from '@plitzi/sdk-shared';
4
+ /** Its components: their trees, props and slots, and instances that place none of them in itself. */
5
+ /**
6
+ * The components: each tree held to the same rules as the pages' — as a fragment hung off its root, which is what
7
+ * keeps a component closed (a binding or a step inside one resolves against its own tree, never the page it is
8
+ * placed on) — and what only the whole document can answer: that an id is in one tree only, that a declaration
9
+ * names elements its tree has, that every instance names a component, and that no component places itself.
10
+ */
11
+ export declare const validateComponents: ({ errors, warnings, flat, components, schema, options }: ValidationContext,
12
+ /** The validation a component's tree is held to, as a fragment of its own: the whole one, handed in. */
13
+ validateTree: (tree: Schema, treeOptions: SchemaValidationOptions) => SchemaValidationResult) => void;