@plitzi/sdk-authoring 0.37.8 → 0.37.9
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 +232 -0
- package/dist/index.d.ts +159 -14
- package/dist/index.js +6490 -5771
- package/package.json +7 -7
- package/skills/plitzi-authoring/SKILL.md +11 -8
- package/skills/plitzi-authoring/reference/components.md +75 -0
- package/skills/plitzi-authoring/reference/flows.md +1 -1
- package/skills/plitzi-authoring/reference/plugins.md +12 -0
- package/skills/plitzi-authoring/reference/templates-and-export.md +6 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,237 @@
|
|
|
1
1
|
# @plitzi/sdk-authoring
|
|
2
2
|
|
|
3
|
+
## 0.37.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 3ae61a4: ## Components replace segments
|
|
8
|
+
|
|
9
|
+
- **What a component is:** a reusable block written once and placed anywhere as an instance. An edit to the component
|
|
10
|
+
is an edit to every instance.
|
|
11
|
+
- **Where it lives:** in the space document, as `schema.components`, one tree per component and never in
|
|
12
|
+
`schema.flat`. It is published, rolled back, copied by templates and exported with the space.
|
|
13
|
+
- **Props and slots:**
|
|
14
|
+
- A component declares props (`type`, `description`, `required`, `default`, `options`). An instance hands them in
|
|
15
|
+
as its own attributes, so templates and bindings reach them. Inside, they are read as `{{ props.<name> }}`.
|
|
16
|
+
- Slots are elements an instance fills; each child names its slot in `attributes.slot`.
|
|
17
|
+
- **A prop an instance leaves out prints nothing.** It is its `default`, or `null`. `props` is a settled source:
|
|
18
|
+
- `processTwig` takes `{ settled }` in place of `keepEmptyTokens: true`.
|
|
19
|
+
- Every other empty token is still kept for a later pass.
|
|
20
|
+
- `COMPONENT_PROPS_SOURCE` names the source.
|
|
21
|
+
- **Fixed: a flow in a list row or a component instance acts on its own copy.** A step's target resolves in the
|
|
22
|
+
replica the flow fired in first, then outwards. It used to reach whichever copy registered last.
|
|
23
|
+
- **Fixed: an instance's own `visible` hides it in preview.** The same goes for an element reference.
|
|
24
|
+
- **Fixed: a list row keeps its state with its record.** Rows are keyed by each record's unique `id`, so filtering no
|
|
25
|
+
longer moves one row's state onto another.
|
|
26
|
+
- **Closed scope:** inside, a component reads only its props and the globals. The validator, `lintSpace` and
|
|
27
|
+
`authorSpace` each refuse a read of the page around an instance. Components nest, and a cycle is refused.
|
|
28
|
+
- **Where to use them:**
|
|
29
|
+
- In code (`@plitzi/sdk-authoring`): `SpaceSpec.components` and `component(id, { props, children })`.
|
|
30
|
+
`specFromSpace` and `specToSource` read and write both.
|
|
31
|
+
- In the builder:
|
|
32
|
+
- a Components panel lists them, and an open component becomes the canvas;
|
|
33
|
+
- an element becomes a component with **Save as component**;
|
|
34
|
+
- in an instance's settings, an instance gets its props and slots, or is **detached** back into a copy.
|
|
35
|
+
- In the MCP: `upsertComponent` and `deleteComponent`. Element ops work inside a component through `pageRef`.
|
|
36
|
+
- **Schema helpers:** `@plitzi/sdk-schema` gains `addComponent`, `updateComponent`, `removeComponent`,
|
|
37
|
+
`detachInstance`, `renameElement`, `treeOf`, `flatMapOf` and `documentIds`.
|
|
38
|
+
- **GraphQL and live events:** `SpaceAddComponent`, `SpaceUpdateComponent`, `SpaceRemoveComponent` and
|
|
39
|
+
`SpaceDetachInstance`, each with a live event. History records a declaration change as a `component` entry.
|
|
40
|
+
- **Breaking: segments are removed.** This covers:
|
|
41
|
+
- `@plitzi/sdk-shared`'s segment types, queries, mutations, context and `SEGMENT_*` events;
|
|
42
|
+
- `referenceType: 'segment'`;
|
|
43
|
+
- the `Segments` builder module;
|
|
44
|
+
- `Space.segments` and the `Segment`/`Segments` queries;
|
|
45
|
+
- `CommonState.prevSchema`.
|
|
46
|
+
- **Breaking: `ElementLayout` and `LayoutBody` change shape.**
|
|
47
|
+
- `ElementLayout` is `{ slots, rootId, type }`; it was `{ containerId }`.
|
|
48
|
+
- `LayoutBody` takes `bodies` keyed by slot.
|
|
49
|
+
- `reference`'s `referenceContainer` attribute is removed.
|
|
50
|
+
- Guide: `docs/en/components.md`.
|
|
51
|
+
|
|
52
|
+
## Functions ask for the time they need
|
|
53
|
+
- **What changes:** a task can ask for more CPU or wall time than the default with `limits`, in milliseconds. Example:
|
|
54
|
+
`limits: { cpuMs: 1000, wallMs: 20_000 }`. `defineFunctions({ limits })` asks it for every task and route at once,
|
|
55
|
+
and a task's own limits win over those.
|
|
56
|
+
- **What a run is given:** what it asked for, or the default (100 ms of CPU, 10 s) when it asked for nothing. Never
|
|
57
|
+
above the space's plan or the deployment's ceiling.
|
|
58
|
+
- **Deployment ceilings:** `functions.limits` sets them. `DEFAULT_FUNCTION_CEILINGS` covers each unset one, at 2 s of
|
|
59
|
+
CPU and 30 s.
|
|
60
|
+
- **Asking for more than the ceiling** is a problem when the functions are saved; it is never quietly cut down.
|
|
61
|
+
- **Manifest:** carries what each task asked for, and the builder shows it beside the task.
|
|
62
|
+
|
|
63
|
+
## Functions answer under `/fn`, not `/api`
|
|
64
|
+
|
|
65
|
+
A space's routes are served at `/fn/<path>` (`FUNCTION_ROUTES_PREFIX`). `/api` is a slug a site wants for a page of its
|
|
66
|
+
own. A page under `/fn` is refused instead (`page-route-reserved`).
|
|
67
|
+
|
|
68
|
+
## The builder's Functions panel
|
|
69
|
+
|
|
70
|
+
Rebuilt around the code. The panel reads `defineFunctions` as it is typed and writes into it, so the code stays the one
|
|
71
|
+
place a function is declared.
|
|
72
|
+
|
|
73
|
+
- **Layout:** the tasks, routes and files on the left, the code in the middle, the selected task on the right.
|
|
74
|
+
- **Live list:** tasks and routes are listed as the code declares them, including tasks imported from another file.
|
|
75
|
+
A task you have written but not saved says so. Tasks built by calling something are counted, and listed once saved.
|
|
76
|
+
- **Code and panel follow each other:** clicking a task or a route opens its file at its line. Putting the cursor inside
|
|
77
|
+
a task's code selects that task.
|
|
78
|
+
- **New task:** + in Tasks asks for its namespace, action and title. The task is written into `defineFunctions` with a
|
|
79
|
+
`run` to start from, in the file's own quotes, and the editor opens on it.
|
|
80
|
+
- **Time limit:** each task gets a slider from 100 ms to 1 s of CPU per run, with presets. The value is written into
|
|
81
|
+
the task as `limits: { cpuMs }`. "Use default" takes it out. `DEFAULT_FUNCTION_TIME_LIMITS` in
|
|
82
|
+
`@plitzi/sdk-shared/actions` is the default both the panel and the server use.
|
|
83
|
+
- **Test:** fills a task's params the way its step does, from their defaults: a select, a switch or text. JSON stays a
|
|
84
|
+
toggle away. With unsaved changes, the button reads "Save & run": it saves, then runs. If the save fails, it says why.
|
|
85
|
+
- **Header:** shows Saved, Unsaved (and in how many files) or the number of problems the last save found. ⌘S saves.
|
|
86
|
+
**Discard** asks first, then puts every file back to what was last saved, or back to nothing for functions never
|
|
87
|
+
saved. Removing the functions is a quiet button beside Save.
|
|
88
|
+
- **Problems:** clicking one opens its file at its line.
|
|
89
|
+
- **Editor:** each file has its own editor and undo history. Opening another file no longer marks the one you left as
|
|
90
|
+
changed. Before this, it could also write the newly opened file's text into the one you left. The cause was in
|
|
91
|
+
`@plitzi/plitzi-ui`'s CodeMirror, fixed in 1.6.25, which every package now depends on. That release also sets code
|
|
92
|
+
editors (several lines) in a monospaced face again. Long lines scroll inside the editor, and the line numbers stay
|
|
93
|
+
in place.
|
|
94
|
+
|
|
95
|
+
## A space's own functions are their own category of steps
|
|
96
|
+
|
|
97
|
+
In the action editor's step picker, the space's own functions are listed under **Functions**, apart from the
|
|
98
|
+
platform's **Tasks**. The other headings now read Callbacks, Global callbacks and Utilities. The saved step is still a
|
|
99
|
+
`task` node.
|
|
100
|
+
|
|
101
|
+
- `@plitzi/sdk-server`: every registered task has an `origin`, `'deployment'` (shipped with the server or a native
|
|
102
|
+
function) or `'space'` (from the space's functions). `describeCatalog`, `/_action/catalog` and the builder's
|
|
103
|
+
`SpaceActionTasks` carry it (`ActionTaskDescriptor.origin`).
|
|
104
|
+
- `@plitzi/sdk-shared`: an `InteractionCallback` may name the `group` the picker lists it under.
|
|
105
|
+
|
|
106
|
+
## Fixed: preview no longer breaks a builder that is embedded in a page
|
|
107
|
+
|
|
108
|
+
When the builder is mounted inside a Plitzi page (the platform's `/spaces/:id/update`), going to preview with a page
|
|
109
|
+
that has SEO turned on left the builder unstyled. The previewed page wrote its title and description through a head
|
|
110
|
+
manager of the builder's own, and that manager rewrote the host page's head, removing the builder's own stylesheet.
|
|
111
|
+
|
|
112
|
+
- `@plitzi/sdk-shared`: a new render setting, `ownsHead`, says whether the page may write the document head. It is on
|
|
113
|
+
by default (`DEFAULT_RENDER_SETTINGS`).
|
|
114
|
+
- `@plitzi/sdk-elements`: `Page` writes its SEO only where `ownsHead` is on.
|
|
115
|
+
- Builder: sets `ownsHead: false` for its canvas. A page drawn there is in a frame, and the document head is the
|
|
116
|
+
editor's. The canvas's own `HelmetProvider` is gone.
|
|
117
|
+
|
|
118
|
+
## Fixed: the builder's plan usage panel shows the space being edited
|
|
119
|
+
- **The 404 is gone.** Opening Plan usage said "The account breakdown could not be read (The server answered 404.)".
|
|
120
|
+
The panel asked `/account/usage`, which went away when accounts became workspaces.
|
|
121
|
+
- **Only this space.** The panel listed every space of the workspace. It now reads `/spaces/:spaceId/usage`, which
|
|
122
|
+
now also answers the space's own `pages` (the heaviest ten), `pagesTotal` and `periodEndsAt`. The plan's ceilings
|
|
123
|
+
stay on top. Anyone who can edit the space can read it, including a guest of another workspace.
|
|
124
|
+
- **It scrolls.** A long breakdown scrolls inside the modal, where it used to overflow.
|
|
125
|
+
- **`getKeyDecoded(webKey, true)` reads the token's subject.** The function, in `@plitzi/sdk-shared`, looked for
|
|
126
|
+
`data.spaceId`, which space tokens no longer carry, so every space decoded as 0. The builder asked about space 0, and
|
|
127
|
+
the builder and the SDK kept every space's persisted state under the same key on a host. Pages served without a
|
|
128
|
+
`webKey` (SSR) still decode as 0, which is what their painted-state cookie is named after.
|
|
129
|
+
|
|
130
|
+
## Fixed: a remote plugin in the builder reads the canvas it sits in
|
|
131
|
+
|
|
132
|
+
The builder carries its own copy of the Plitzi runtime. A remote plugin imports `@plitzi/plitzi-sdk`, which the page's
|
|
133
|
+
import map resolves to the SDK's copy. Each copy made its own React contexts, so on the builder's canvas a plugin read
|
|
134
|
+
none of the canvas's providers. In the builder embedded in Plitzi's site, it read the site around the builder instead:
|
|
135
|
+
the site's element as its own, the site's live mode (so it stayed interactive while being edited), and the site's store
|
|
136
|
+
and interactions.
|
|
137
|
+
|
|
138
|
+
- `@plitzi/sdk-shared` gains `sharedContext(name, default)`: a context made once per page and handed to every copy of
|
|
139
|
+
the runtime that asks for it.
|
|
140
|
+
- The runtime's contexts now go through it, so a provider from any copy reaches a consumer from any copy:
|
|
141
|
+
- `@plitzi/sdk-shared`: service, component, schema, network, theme scope, dev tools, builder.
|
|
142
|
+
- `@plitzi/sdk-elements`: element, element parent, layout body.
|
|
143
|
+
- interactions, plugins, event bridge, auth, variables and style.
|
|
144
|
+
- The store's contexts need `@plitzi/nexus` 1.4.0, which does the same. Every `@plitzi/*` package now asks for
|
|
145
|
+
`^1.4.0`, which is published.
|
|
146
|
+
|
|
147
|
+
## The source of plugins and runtimes is kept on the space
|
|
148
|
+
|
|
149
|
+
What a plugin or a runtime is built from now goes up with it, so a space can be taken back out as a project
|
|
150
|
+
(`plitzi create --from`, below).
|
|
151
|
+
|
|
152
|
+
- `@plitzi/cli`:
|
|
153
|
+
- `plitzi pack plugin` writes the plugin's source beside its zip: every file of the project its elements import,
|
|
154
|
+
`import type` included, and the packages they need. `--source-root` names the project those paths are relative to.
|
|
155
|
+
- `plitzi upload plugin` and `plitzi runtime push` keep that source on the space, in its private bucket.
|
|
156
|
+
- `plitzi pack source` writes it to a file.
|
|
157
|
+
- A source that cannot be kept (a file outside the project, an undeclared package, a credential in the code) never
|
|
158
|
+
stops the upload or the push: they say why, and the artifact is kept built only.
|
|
159
|
+
- `@plitzi/sdk-shared/source`: the snapshot's format, the paths it may hold and the credential check, shared by the CLI
|
|
160
|
+
and the platform.
|
|
161
|
+
|
|
162
|
+
## `plitzi create --from` and `plitzi pull`: a space on Plitzi as a project of your own
|
|
163
|
+
|
|
164
|
+
The way back from everything the CLI puts on Plitzi. `plitzi create my-board --from pizarra` writes a server project
|
|
165
|
+
holding what the space is made of, and runs it with nothing of Plitzi's: neither its servers nor its CDN. `plitzi pull`
|
|
166
|
+
keeps it in step with the space. See `docs/en/projects-from-spaces.md`.
|
|
167
|
+
|
|
168
|
+
- **What lands in the project:**
|
|
169
|
+
- its pages as authoring code;
|
|
170
|
+
- its server actions as `defineAction` code — JSON, with the reason said, for one that would not read back exactly;
|
|
171
|
+
- its plugins and runtime as the source they were uploaded from, and its functions;
|
|
172
|
+
- its files, downloaded into `public/`, with every CDN address rewritten to the project's.
|
|
173
|
+
- **`src/main.ts`** serves all of it, the runtime in the same process.
|
|
174
|
+
- **`.env`** gets a key made for the project's actions to sign with, and the names of the variables and credentials
|
|
175
|
+
the space had. Their values stay on Plitzi.
|
|
176
|
+
- **Who may run it:** the person must be signed in and able to change the space (owner, administrator or writer).
|
|
177
|
+
- **Plugins** are rebuilt against the project's SDK. One uploaded before sources were kept runs as it was built, from
|
|
178
|
+
`vendor/plugins/`, and the report says to upload it again.
|
|
179
|
+
- **The end of `create`** says what came across differently, including a space whose visitors sign in with Plitzi.
|
|
180
|
+
- `--source cloud` keeps the pages on Plitzi and runs the rest locally.
|
|
181
|
+
- **Any version:** `--environment` and `--revision` take out a published snapshot — its latest, or one revision pinned
|
|
182
|
+
— instead of the draft, with the source its plugins and runtime were built from then. A cloud project serves that
|
|
183
|
+
revision pinned.
|
|
184
|
+
- **`plitzi pull`** writes what changed on the space, keeps what changed in the project, and writes nothing when a
|
|
185
|
+
file changed on both — naming them, with `--force` to take the space's copy. It never touches `.env`, only adds to
|
|
186
|
+
`package.json`, and keeps `plitzi functions push` working from the project. It follows the version the project was
|
|
187
|
+
made from, and `--environment`/`--revision` move it.
|
|
188
|
+
- `@plitzi/sdk-authoring`:
|
|
189
|
+
- `actionSpecFromEntry` reads an action document back into its `defineAction` declaration, only when the round trip
|
|
190
|
+
is exact, and `actionToSource` writes it as a module.
|
|
191
|
+
- `defineAction` takes `limits`.
|
|
192
|
+
- `specToSource` takes `importExtension: '.ts'`, for split files that Node imports as they are.
|
|
193
|
+
|
|
194
|
+
## The builder shows what a snapshot holds
|
|
195
|
+
|
|
196
|
+
**Make Snapshot** lists what it will freeze — pages, layouts and elements, server actions, connectors, functions, the
|
|
197
|
+
runtime and the plugins, each with whether its source is kept — and what no snapshot freezes: the space's files, its
|
|
198
|
+
variables and credentials. A space's components are part of its document, so they are frozen with its pages. **Publish Snapshot** lists what the chosen environment's snapshot holds.
|
|
199
|
+
|
|
200
|
+
## Fixed: a space read from Plitzi kept its server elements
|
|
201
|
+
- **What happened:** a page server reading its space from Plitzi (`createCloudAdapters`) never ran an element's
|
|
202
|
+
`render` action, and a browser-rendered space ignored `loadStrategy`. The space's GraphQL answered neither
|
|
203
|
+
`runtime` nor `loadStrategy` of an element, nor the space's `rsc` settings.
|
|
204
|
+
- **Now:** the platform answers them, and the SDK, the builder and the cloud adapters ask for them.
|
|
205
|
+
|
|
206
|
+
## A plugin the deployment registers is not looked for elsewhere
|
|
207
|
+
|
|
208
|
+
`@plitzi/sdk-server` used to fetch the manifest of every plugin the space lists on its CDN, even one the deployment
|
|
209
|
+
registers itself, and logged a warning when the CDN was out of reach. It now asks only for the ones it does not have.
|
|
210
|
+
|
|
211
|
+
## Fixed: inline code in Markdown carries nothing of the syntax tree
|
|
212
|
+
|
|
213
|
+
A `markdown` element wrote every inline `` `code` `` as `<code node="[object Object]">`: `react-markdown` hands its
|
|
214
|
+
renderers the syntax-tree node as a prop, and the inline branch spread it onto the tag. Fixed in
|
|
215
|
+
`@plitzi/plitzi-ui` 1.6.26 (with a test), which every package now asks for.
|
|
216
|
+
|
|
217
|
+
## Dev tools hear about the render run the page stopped waiting for
|
|
218
|
+
|
|
219
|
+
When a server element's action ran past the section's budget, the page was answered without it. The run ended a moment
|
|
220
|
+
later, after the page's runs had been sent, so the dev tools never showed the one run that needed debugging. It is now
|
|
221
|
+
told the moment the page stops waiting, as `aborted`, with the reason.
|
|
222
|
+
|
|
223
|
+
## Fixed: a tab you come back to no longer loses its session
|
|
224
|
+
- **What happened:** a page left in another tab past its access token's life signed its visitor out on return. A
|
|
225
|
+
reload put them right back in.
|
|
226
|
+
- **Why:** the browser drops the cookie carrying the access token the moment the token expires, and the background
|
|
227
|
+
tab's renewal timer had not run. The first check on return was told `missing`, which the client took as no
|
|
228
|
+
session at all.
|
|
229
|
+
- **Now:** a `missing` refusal is renewed instead whenever the browser can still renew, meaning it holds a refresh
|
|
230
|
+
token or a session hint whose renewal window is open. The session ends only if that renewal fails.
|
|
231
|
+
- **Requests made in that moment:** `reportAuthFailure` now answers whether it renewed the session. A read refused
|
|
232
|
+
as the tab came back is asked again, once, once the session is renewed. This covers an api container's read and a
|
|
233
|
+
server section's refresh, so they no longer show a 401 that only a reload cleared.
|
|
234
|
+
|
|
3
235
|
## 0.37.8
|
|
4
236
|
|
|
5
237
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -138,6 +138,34 @@ declare type ActionLimits = {
|
|
|
138
138
|
maxResponseBytes?: number;
|
|
139
139
|
};
|
|
140
140
|
|
|
141
|
+
/**
|
|
142
|
+
* A server action read back into the `defineAction` call that writes it: the other direction from {@link defineAction},
|
|
143
|
+
* as `specFromSpace` is for a space.
|
|
144
|
+
*
|
|
145
|
+
* Only when the round trip is exact. The spec read is authored again and compared with the document it came from —
|
|
146
|
+
* every step, every chain link, every param — and a document that would come back any different is not read at all:
|
|
147
|
+
* the reason is given instead, and the document stays the JSON it is. A builder can write flows code has no words for
|
|
148
|
+
* (a branch, a step titled by hand), and a decompiler that approximated them would hand back a different action.
|
|
149
|
+
*/
|
|
150
|
+
export declare type ActionReading = {
|
|
151
|
+
ok: true;
|
|
152
|
+
spec: ActionSpec;
|
|
153
|
+
} | {
|
|
154
|
+
ok: false;
|
|
155
|
+
reason: string;
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export declare type ActionSource = {
|
|
159
|
+
/** What the file exports the action as: its id in camelCase, `boardCreateAction`. */
|
|
160
|
+
exportName: string;
|
|
161
|
+
source: string;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
export declare interface ActionSourceOptions {
|
|
165
|
+
/** Where `defineAction` is imported from. */
|
|
166
|
+
packageName?: string;
|
|
167
|
+
}
|
|
168
|
+
|
|
141
169
|
export declare interface ActionSpec {
|
|
142
170
|
id: string;
|
|
143
171
|
name: string;
|
|
@@ -160,8 +188,19 @@ export declare interface ActionSpec {
|
|
|
160
188
|
* names. An unquoted token keeps its type (`{{ rate.total }}` is a number), a quoted one is text.
|
|
161
189
|
*/
|
|
162
190
|
output?: string;
|
|
191
|
+
/** Ceilings for one run, tighter than the deployment's own: a per-action value can only lower them. */
|
|
192
|
+
limits?: ActionLimits;
|
|
163
193
|
}
|
|
164
194
|
|
|
195
|
+
/**
|
|
196
|
+
* The declaration that writes this action, or why there is none. See the module's comment. The document is whatever
|
|
197
|
+
* JSON arrived — a platform's export, a file — and one without an action's shape is answered, never thrown on.
|
|
198
|
+
*/
|
|
199
|
+
export declare const actionSpecFromEntry: ({ id, document }: {
|
|
200
|
+
id: string;
|
|
201
|
+
document: unknown;
|
|
202
|
+
}) => ActionReading;
|
|
203
|
+
|
|
165
204
|
export declare interface ActionStepSpec {
|
|
166
205
|
/**
|
|
167
206
|
* What later steps and the output call this one by — `{{ rate.total }}` resolves only when the step that
|
|
@@ -183,6 +222,12 @@ export declare interface ActionStepSpec {
|
|
|
183
222
|
enabled?: boolean;
|
|
184
223
|
}
|
|
185
224
|
|
|
225
|
+
/**
|
|
226
|
+
* A declaration written out as the module that holds it. Valid but unformatted, as `specToSource`'s is: run it through
|
|
227
|
+
* the project's formatter.
|
|
228
|
+
*/
|
|
229
|
+
export declare const actionToSource: (spec: ActionSpec, { packageName }?: ActionSourceOptions) => ActionSource;
|
|
230
|
+
|
|
186
231
|
export declare type ActionTriggerSpec = (TriggerCommon & {
|
|
187
232
|
type: 'call';
|
|
188
233
|
access: AccessSpec;
|
|
@@ -995,6 +1040,74 @@ declare type Combinator = 'and' | 'or';
|
|
|
995
1040
|
/** Every observable way `actual` differs from `expected`. Empty means they render the same space. */
|
|
996
1041
|
export declare const compareSpaces: (expected: SpaceDocuments, actual: SpaceDocuments) => SpaceDifference[];
|
|
997
1042
|
|
|
1043
|
+
/**
|
|
1044
|
+
* An instance of one of the space's components (`SpaceSpec.components`): the component's tree, rendered here with
|
|
1045
|
+
* these props.
|
|
1046
|
+
*
|
|
1047
|
+
* ```ts
|
|
1048
|
+
* component('product-card', { props: { title: 'Lamp' }, children: { 'product-card-actions': [button('Buy')] } })
|
|
1049
|
+
* ```
|
|
1050
|
+
*
|
|
1051
|
+
* Checked when the space is written: a component the space does not declare, a prop it does not declare, a required
|
|
1052
|
+
* one left out, a value of the wrong kind and a slot it does not have are each refused, by name.
|
|
1053
|
+
*/
|
|
1054
|
+
export declare const component: (componentId: string, instance?: ComponentInstanceProps) => ElementSpec;
|
|
1055
|
+
|
|
1056
|
+
/** What an element inside a component can read besides its own tree: the globals, and what its instance hands in. */
|
|
1057
|
+
export declare const COMPONENT_SOURCES: string[];
|
|
1058
|
+
|
|
1059
|
+
/** How an instance is authored: what it hands in, what fills its slots, and the authoring fields any element takes. */
|
|
1060
|
+
export declare type ComponentInstanceProps = Pick<AuthoringProps, 'id' | 'class' | 'css' | 'states' | 'selector' | 'bind' | 'visible' | 'flows' | 'meta'> & {
|
|
1061
|
+
/** The props the component declares, by name. A prop is an attribute of the instance: `bind` can land on one too. */
|
|
1062
|
+
props?: Record<string, unknown>;
|
|
1063
|
+
/** What fills the slots: a list, for a component with one slot, or one list per slot it declares. */
|
|
1064
|
+
children?: ElementSpec[] | Record<string, ElementSpec[]>;
|
|
1065
|
+
};
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
* A prop a component declares, as the document stores it: the part of a `BuiltinParam` that survives JSON — no `when`
|
|
1069
|
+
* guard and no `builderType` worked out from other params, which are functions and only ever live in code.
|
|
1070
|
+
*/
|
|
1071
|
+
declare type ComponentProp = Pick<BuiltinParam, 'type' | 'description' | 'default' | 'options' | 'required' | 'label' | 'optionLabels' | 'elementType'>;
|
|
1072
|
+
|
|
1073
|
+
/**
|
|
1074
|
+
* A reusable subtree of the space: written once, placed anywhere with {@link component}, and published, versioned and
|
|
1075
|
+
* copied with the space because it is part of it.
|
|
1076
|
+
*
|
|
1077
|
+
* It is CLOSED. Inside, a binding or a template reads `props` — what each instance hands in, declared here — and the
|
|
1078
|
+
* globals, never the page an instance sits on: a component that read its surroundings would render differently
|
|
1079
|
+
* wherever it was placed, and could not be checked until it was. What it needs from there comes in as a prop.
|
|
1080
|
+
*
|
|
1081
|
+
* ```ts
|
|
1082
|
+
* components: [{
|
|
1083
|
+
* id: 'product-card',
|
|
1084
|
+
* props: { title: { type: 'text', description: 'The heading', required: true } },
|
|
1085
|
+
* slots: ['product-card-actions'],
|
|
1086
|
+
* root: container({ id: 'product-card-root', children: [
|
|
1087
|
+
* heading({ id: 'product-card-title', bind: { content: 'props.title' } }),
|
|
1088
|
+
* container({ id: 'product-card-actions' })
|
|
1089
|
+
* ] })
|
|
1090
|
+
* }]
|
|
1091
|
+
* ```
|
|
1092
|
+
*/
|
|
1093
|
+
export declare interface ComponentSpec {
|
|
1094
|
+
/** The name an instance places it by. */
|
|
1095
|
+
id: string;
|
|
1096
|
+
/** What the builder shows. Defaults to the id. */
|
|
1097
|
+
label?: string;
|
|
1098
|
+
/** The page folder the builder files it under. It routes nothing: a component has no URL of its own. */
|
|
1099
|
+
folder?: string;
|
|
1100
|
+
/**
|
|
1101
|
+
* What an instance hands in, each as an attribute of the instance and read inside as `{{ props.<name> }}`. Declared
|
|
1102
|
+
* as a step's params are — a type, what it is for, a default, whether it is required — and checked the same way.
|
|
1103
|
+
*/
|
|
1104
|
+
props?: Record<string, ComponentProp>;
|
|
1105
|
+
/** Elements of the tree an instance fills with its children, each child naming the one it goes in. */
|
|
1106
|
+
slots?: string[];
|
|
1107
|
+
/** The tree. Its root is what an instance renders, and ids inside it are names the whole space shares. */
|
|
1108
|
+
root: ElementSpec;
|
|
1109
|
+
}
|
|
1110
|
+
|
|
998
1111
|
export declare const container: {
|
|
999
1112
|
(props?: ElementProps<Partial<{
|
|
1000
1113
|
label?: string | undefined;
|
|
@@ -1252,7 +1365,7 @@ export declare const elementAttributeNames: {
|
|
|
1252
1365
|
readonly page: readonly ["layout", "layoutContainer", "seoEnabled", "seoPageDescription", "seoPageTitle"];
|
|
1253
1366
|
readonly pagination: readonly ["label", "loadMoreLabel", "mode", "nextLabel", "pageInfo", "pageParam", "previousLabel", "target", "windowSize"];
|
|
1254
1367
|
readonly paragraph: readonly ["content"];
|
|
1255
|
-
readonly reference: readonly ["
|
|
1368
|
+
readonly reference: readonly ["referenceId", "referenceType"];
|
|
1256
1369
|
readonly richText: readonly ["content", "format", "mediaBaseUrl"];
|
|
1257
1370
|
readonly tabContainer: readonly [];
|
|
1258
1371
|
readonly tabContainerBody: readonly [];
|
|
@@ -4435,12 +4548,11 @@ declare const elementDeclarations: {
|
|
|
4435
4548
|
readonly attributes: {
|
|
4436
4549
|
readonly referenceType: "element";
|
|
4437
4550
|
readonly referenceId: "";
|
|
4438
|
-
readonly referenceContainer: "";
|
|
4439
4551
|
};
|
|
4440
4552
|
readonly definition: {
|
|
4441
4553
|
readonly label: "Reference";
|
|
4442
4554
|
readonly type: "reference";
|
|
4443
|
-
readonly description: "
|
|
4555
|
+
readonly description: "Places one of the components of the space, or renders another of its elements by id, in place.";
|
|
4444
4556
|
readonly items: readonly [];
|
|
4445
4557
|
readonly bindings: {};
|
|
4446
4558
|
readonly styleSelectors: {
|
|
@@ -4480,9 +4592,8 @@ declare const elementDeclarations: {
|
|
|
4480
4592
|
readonly settings: {};
|
|
4481
4593
|
};
|
|
4482
4594
|
} & ElementAttributesBrand<Partial<{
|
|
4483
|
-
referenceType: ElementLayoutType;
|
|
4484
4595
|
referenceId: string;
|
|
4485
|
-
|
|
4596
|
+
referenceType: "element" | "component";
|
|
4486
4597
|
}>>;
|
|
4487
4598
|
readonly RichText: {
|
|
4488
4599
|
readonly type: "richText";
|
|
@@ -5048,8 +5159,6 @@ declare type ElementInteraction<T extends Record<string, unknown> = Record<strin
|
|
|
5048
5159
|
whileRunning?: WhileRunning;
|
|
5049
5160
|
};
|
|
5050
5161
|
|
|
5051
|
-
declare type ElementLayoutType = 'layout' | 'segment' | 'element' | 'reference';
|
|
5052
|
-
|
|
5053
5162
|
/**
|
|
5054
5163
|
* The types that hold no children — a heading, a text, an image, a form control.
|
|
5055
5164
|
*
|
|
@@ -5488,7 +5597,7 @@ declare type GoogleFont = FontBase & {
|
|
|
5488
5597
|
|
|
5489
5598
|
export declare const grid: (columns: string, gap: string, extra?: CssProps) => StyleRules;
|
|
5490
5599
|
|
|
5491
|
-
export declare const groupBindings: (path: string, bind: BindingsSpec, sources?: SourceIndex, where?: string) => Partial<Record<BindingCategory, ElementBinding[]>>;
|
|
5600
|
+
export declare const groupBindings: (path: string, bind: BindingsSpec, sources?: SourceIndex, where?: string, globals?: readonly string[]) => Partial<Record<BindingCategory, ElementBinding[]>>;
|
|
5492
5601
|
|
|
5493
5602
|
/** Whether any of these bindings decides the element's visibility — which makes it a condition, authored hidden. */
|
|
5494
5603
|
export declare const hasVisibilityBinding: (bindings: BindingSpec[] | undefined) => boolean;
|
|
@@ -5608,6 +5717,11 @@ declare type InteractionCallback<T extends Record<string, unknown> = Record<stri
|
|
|
5608
5717
|
action: string;
|
|
5609
5718
|
title: string;
|
|
5610
5719
|
type: InteractionCallbackType;
|
|
5720
|
+
/**
|
|
5721
|
+
* The heading the editor's picker lists it under, when that is not its type's: a space's own functions are tasks to
|
|
5722
|
+
* the run, and a category of their own to whoever picks a step.
|
|
5723
|
+
*/
|
|
5724
|
+
group?: string;
|
|
5611
5725
|
enabled?: boolean;
|
|
5612
5726
|
params: Record<keyof T, InteractionCallbackParam<T>> | ((params: InteractionCallbackParamValues<T>) => Record<keyof T, InteractionCallbackParam<T>>);
|
|
5613
5727
|
callback?: (params: InteractionCallbackParamValues<T>, context?: InteractionCallbackContext) => unknown;
|
|
@@ -6696,14 +6810,12 @@ export declare const reconcileParams: (params: Record<string, unknown>, spec: Pa
|
|
|
6696
6810
|
|
|
6697
6811
|
export declare const reference: {
|
|
6698
6812
|
(props?: ElementProps<Partial<{
|
|
6699
|
-
referenceType: ElementLayoutType;
|
|
6700
6813
|
referenceId: string;
|
|
6701
|
-
|
|
6814
|
+
referenceType: "element" | "component";
|
|
6702
6815
|
}>> | undefined): ElementSpec;
|
|
6703
6816
|
(children: ElementSpec[], props?: ElementProps<Partial<{
|
|
6704
|
-
referenceType: ElementLayoutType;
|
|
6705
6817
|
referenceId: string;
|
|
6706
|
-
|
|
6818
|
+
referenceType: "element" | "component";
|
|
6707
6819
|
}>> | undefined): ElementSpec;
|
|
6708
6820
|
};
|
|
6709
6821
|
|
|
@@ -6794,7 +6906,7 @@ export declare const resetForm: (target: string) => StepSpec;
|
|
|
6794
6906
|
* Both halves being wrong is the same failure and it is the quietest one this surface has: the binding resolves
|
|
6795
6907
|
* to nothing, the element renders its placeholder, and every layer below considers the document perfectly valid.
|
|
6796
6908
|
*/
|
|
6797
|
-
export declare const resolveSource: (source: string, index: SourceIndex, where: string) => string;
|
|
6909
|
+
export declare const resolveSource: (source: string, index: SourceIndex, where: string, globals?: readonly string[]) => string;
|
|
6798
6910
|
|
|
6799
6911
|
/** A selector's whole block per breakpoint, as it reaches the document. */
|
|
6800
6912
|
export declare type ResponsiveBlock = Partial<Record<DisplayMode, StyleBlock>>;
|
|
@@ -6996,6 +7108,7 @@ declare type Schema = {
|
|
|
6996
7108
|
rsc?: SchemaRsc;
|
|
6997
7109
|
pages: Element_2['id'][];
|
|
6998
7110
|
pageFolders: PageFolder[];
|
|
7111
|
+
components: Record<SpaceComponent['id'], SpaceComponent>;
|
|
6999
7112
|
};
|
|
7000
7113
|
|
|
7001
7114
|
/**
|
|
@@ -7015,10 +7128,13 @@ declare type SchemaValidationError = {
|
|
|
7015
7128
|
code: string;
|
|
7016
7129
|
message: string;
|
|
7017
7130
|
elementId?: string;
|
|
7131
|
+
/** The component whose tree the error is in; absent for the pages' tree. */
|
|
7132
|
+
componentId?: string;
|
|
7018
7133
|
details?: unknown;
|
|
7019
7134
|
};
|
|
7020
7135
|
|
|
7021
7136
|
declare type SchemaValidationOptions = {
|
|
7137
|
+
/** Validates `flat` as a fragment hung off this element — a component's tree — instead of as the pages' tree. */
|
|
7022
7138
|
baseElementId?: string;
|
|
7023
7139
|
/**
|
|
7024
7140
|
* Element type → the source name it publishes under.
|
|
@@ -7120,7 +7236,7 @@ export declare type SourceIndex = Map<string, string>;
|
|
|
7120
7236
|
export declare type SourceTypes = Record<string, string>;
|
|
7121
7237
|
|
|
7122
7238
|
/** The same guarantee for the space itself, in the order its fields are written. */
|
|
7123
|
-
export declare const SPACE_FIELDS: readonly ["name", "permanentUrl", "mode", "theme", "variables", "fonts", "elements", "classes", "schemaVariables", "settings", "computed", "channels", "customCss", "notifications", "rsc", "pageFolders", "layouts", "pages"];
|
|
7239
|
+
export declare const SPACE_FIELDS: readonly ["name", "permanentUrl", "mode", "theme", "variables", "fonts", "elements", "classes", "schemaVariables", "settings", "computed", "channels", "customCss", "notifications", "rsc", "pageFolders", "layouts", "components", "pages"];
|
|
7124
7240
|
|
|
7125
7241
|
/**
|
|
7126
7242
|
* The `space` source, which the SDK application registers rather than this package.
|
|
@@ -7132,6 +7248,28 @@ export declare const SPACE_FIELDS: readonly ["name", "permanentUrl", "mode", "th
|
|
|
7132
7248
|
*/
|
|
7133
7249
|
export declare const spaceCallbacks: Record<string, BuiltinGlobalCallback>;
|
|
7134
7250
|
|
|
7251
|
+
/**
|
|
7252
|
+
* A reusable subtree of the space: declared once, placed on any page as an instance (a `reference` element with
|
|
7253
|
+
* `referenceType: 'component'`), and versioned, published and copied with the space because it is part of it.
|
|
7254
|
+
*
|
|
7255
|
+
* Its tree is a `flat` of its own rather than roots inside `schema.flat`: that one is the tree of the pages, and a
|
|
7256
|
+
* component belongs to none. Ids are still one namespace across every tree, so an id alone says which tree it is in.
|
|
7257
|
+
*/
|
|
7258
|
+
declare type SpaceComponent = {
|
|
7259
|
+
/** The key it is stored under, and what an instance names in `referenceId`. */
|
|
7260
|
+
id: string;
|
|
7261
|
+
label?: string;
|
|
7262
|
+
/** The page folder the builder files it under. It routes nothing: a component has no URL of its own. */
|
|
7263
|
+
folder?: string;
|
|
7264
|
+
/** What an instance hands in, each as an attribute of the instance; read inside as `{{ props.<name> }}`. */
|
|
7265
|
+
props?: Record<string, ComponentProp>;
|
|
7266
|
+
/** Elements of `flat` an instance fills with its children, each child naming the one it goes in (`slot`). */
|
|
7267
|
+
slots?: Element_2['id'][];
|
|
7268
|
+
rootId: Element_2['id'];
|
|
7269
|
+
/** `rootId` with no parent, and everything under it. */
|
|
7270
|
+
flat: Record<Element_2['id'], Element_2>;
|
|
7271
|
+
};
|
|
7272
|
+
|
|
7135
7273
|
declare type SpaceCredentialProvider = 's3' | 'r2' | 'ssr' | 'custom' | 'smtp';
|
|
7136
7274
|
|
|
7137
7275
|
/**
|
|
@@ -7266,6 +7404,8 @@ export declare interface SpaceSpec {
|
|
|
7266
7404
|
pageFolders?: PageFolderSpec[];
|
|
7267
7405
|
/** Shells pages render inside. See {@link LayoutSpec}. */
|
|
7268
7406
|
layouts?: LayoutSpec[];
|
|
7407
|
+
/** Reusable subtrees, placed with {@link component}. See {@link ComponentSpec}. */
|
|
7408
|
+
components?: ComponentSpec[];
|
|
7269
7409
|
pages: PageSpec[];
|
|
7270
7410
|
}
|
|
7271
7411
|
|
|
@@ -7358,6 +7498,11 @@ export declare interface SpecSourceOptions {
|
|
|
7358
7498
|
* thousands of elements wants: a page is then something one can open.
|
|
7359
7499
|
*/
|
|
7360
7500
|
split?: boolean;
|
|
7501
|
+
/**
|
|
7502
|
+
* What a split file's import of another one ends in: nothing for a bundler, which resolves `./styles` itself; `.ts`
|
|
7503
|
+
* for a project Node runs by stripping the types, which imports a file by its name (`plitzi create --from`).
|
|
7504
|
+
*/
|
|
7505
|
+
importExtension?: '' | '.ts';
|
|
7361
7506
|
}
|
|
7362
7507
|
|
|
7363
7508
|
/** Writes a spec out as source files. See {@link SpecSourceOptions}. */
|