@plitzi/sdk-server 0.38.10 → 0.38.12
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 +287 -0
- package/README.md +3 -3
- package/dist/auth.js +1 -1
- package/dist/core/auth/createAuth.js +1 -1
- package/dist/core/http/stages/signInRoute.js +1 -1
- package/dist/core/server/baseServer.js +11 -6
- package/dist/core/server/fleet/stores.d.ts +7 -0
- package/dist/core/server/fleet/stores.js +16 -2
- package/dist/core/server/fleet/supervisor.d.ts +2 -0
- package/dist/core/server/fleet/supervisor.js +14 -2
- package/dist/core/server/pageServer.js +1 -1
- package/dist/functions-api.d.ts +47 -2
- package/dist/helpers/cache/cacheManager.d.ts +9 -2
- package/dist/helpers/cache/cacheManager.js +46 -22
- package/dist/helpers/cache/keys.d.ts +12 -5
- package/dist/helpers/cache/keys.js +56 -11
- package/dist/modules/actions/index.js +6 -2
- package/dist/modules/actions/jobs/later.d.ts +43 -0
- package/dist/modules/actions/jobs/later.js +66 -0
- package/dist/modules/actions/jobs/later.test.d.ts +1 -0
- package/dist/modules/actions/jobs/memoryQueue.js +14 -1
- package/dist/modules/actions/jobs/worker.js +2 -2
- package/dist/modules/actions/runtime/credentials.d.ts +10 -0
- package/dist/modules/actions/runtime/credentials.js +28 -0
- package/dist/modules/actions/runtime/credentials.test.d.ts +1 -0
- package/dist/modules/actions/runtime/fileKv.d.ts +8 -3
- package/dist/modules/actions/runtime/fileKv.js +79 -7
- package/dist/modules/actions/runtime/precheck.js +1 -1
- package/dist/modules/actions/runtime/rateLimit.d.ts +7 -0
- package/dist/modules/actions/runtime/rateLimit.js +7 -1
- package/dist/modules/actions/runtime/runAction.d.ts +4 -1
- package/dist/modules/actions/runtime/runAction.js +46 -11
- package/dist/modules/actions/runtime/taskContext.d.ts +4 -1
- package/dist/modules/actions/runtime/taskContext.js +7 -1
- package/dist/modules/actions/tasks/flow.js +113 -35
- package/dist/modules/actions/types.d.ts +8 -0
- package/dist/modules/functions/build.js +1 -1
- package/dist/modules/functions/capabilities.js +21 -0
- package/dist/modules/functions/context.js +9 -3
- package/dist/modules/functions/contract.d.ts +10 -0
- package/dist/modules/functions/driver.js +16 -4
- package/dist/modules/functions/local.d.ts +1 -1
- package/dist/modules/functions/local.js +2 -1
- package/dist/modules/functions/manifest.js +8 -3
- package/dist/modules/functions/protocol.d.ts +7 -0
- package/dist/modules/mongo/jobQueue.js +26 -0
- package/dist/modules/mysql/jobs/jobQueue.js +21 -2
- package/dist/modules/mysql/jobs/schema.d.ts +3 -2
- package/dist/modules/mysql/jobs/schema.js +24 -11
- package/dist/modules/project/plugins.d.ts +1 -1
- package/dist/modules/project/serveProject.js +29 -4
- package/dist/modules/realtime/handlers.d.ts +4 -1
- package/dist/modules/realtime/handlers.js +8 -4
- package/dist/modules/realtime/hub.d.ts +3 -1
- package/dist/modules/realtime/hub.js +8 -4
- package/dist/modules/ssr/prepareRender.js +1 -1
- package/package.json +3 -3
- package/skills/plitzi-authoring/CHEATSHEET.md +4 -2
- package/skills/plitzi-authoring/recipes/plugin.ts +9 -7
- package/skills/plitzi-authoring/recipes/style-a-page.ts +1 -1
- package/skills/plitzi-authoring/reference/accessibility.md +1 -0
- package/skills/plitzi-authoring/reference/authoring-errors.md +8 -4
- package/skills/plitzi-authoring/reference/data-and-visibility.md +11 -10
- package/skills/plitzi-authoring/reference/elements-and-styles.md +1 -1
- package/skills/plitzi-authoring/reference/flows.md +6 -5
- package/skills/plitzi-authoring/reference/layouts.md +1 -0
- package/skills/plitzi-authoring/reference/lists.md +1 -0
- package/skills/plitzi-authoring/reference/plugins.md +43 -37
- package/skills/plitzi-authoring/reference/realtime.md +4 -1
- package/skills/plitzi-authoring/reference/rules.md +1 -1
- package/skills/plitzi-authoring/reference/typed-sources.md +6 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,292 @@
|
|
|
1
1
|
# @plitzi/sdk-server
|
|
2
2
|
|
|
3
|
+
## 0.38.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 1301338: ## Builder
|
|
8
|
+
|
|
9
|
+
- **Icons in the canvas again** (`@plitzi/plitzi-builder`): the canvas inlined the SDK's Font Awesome sheet into its
|
|
10
|
+
`<style>`, where the sheet's `url(webfonts/…)` resolved against the editor's URL — a `srcdoc` frame takes it as its
|
|
11
|
+
base — so every icon was a 404 under `/spaces/<space>/webfonts/` and drew as an empty box. Only the Vite dev server,
|
|
12
|
+
which rewrites the URL, hid it. The canvas and the element preview now link the sheet from where the host serves it:
|
|
13
|
+
a new prop, `sdkIconsStylePath`, the one the host already gives the pages it renders
|
|
14
|
+
(`/sdk-assets/plitzi-sdk-icons.css` for sdk-server). Absent, the canvas links no icon sheet.
|
|
15
|
+
|
|
16
|
+
## Plugins
|
|
17
|
+
- **A plugin's other elements, hosted by `custom`** (`@plitzi/sdk-elements`): `custom({ renderType: 'jamDisc' })` on a
|
|
18
|
+
space with a plugin installed whose main element is another (`plitzi plugin pack` of several folders: the first is the
|
|
19
|
+
plugin, the rest go in it) rendered "Custom Component jamDisc Not Found" — the page registers only the plugin's main
|
|
20
|
+
element, and a `custom` host looked nowhere else. It now loads the type from the installed plugin that packs it, as
|
|
21
|
+
an element of the type itself always did, so the two ways the docs give to place a plugin's element are the same
|
|
22
|
+
everywhere: in a project `plitzi create` wrote, and once the project is on Plitzi.
|
|
23
|
+
- **One way to place a plugin's element** (`@plitzi/sdk-authoring`, `@plitzi/cli`, docs): from its declaration,
|
|
24
|
+
`const seatPicker = defineElement(declaration)` then `seatPicker({ id, … })` — typed by what it
|
|
25
|
+
declares, and the element the builder adds when somebody drops it. The welcome space `plitzi create` writes, the
|
|
26
|
+
plugin package's preview, `plitzi plugin add` and `plitzi explain` all write it so (the template's
|
|
27
|
+
`PluginHostOptions` now takes the plugin's `type` and `declaration: { from, attributes? }`; `custom`/`element` hosting
|
|
28
|
+
is gone). `pluginFolders(folder)` (`@plitzi/sdk-authoring/node`) reads each plugin with the folder it is in;
|
|
29
|
+
`pluginDeclarations` is built on it. A `custom({ renderType })` naming a plugin the space was handed the declaration
|
|
30
|
+
of is offered the declaration instead — suggestion `plugin-custom-host`. `custom` stays for a component registered
|
|
31
|
+
by name with no declaration. The skills, the CLI README, the MCP guide, `docs/en` and the website say the same.
|
|
32
|
+
- **`definePlugin`** (`@plitzi/sdk-authoring/plugin`, a new entry of 3 KB with nothing else in it): a plugin's
|
|
33
|
+
declaration written from what only it can say —
|
|
34
|
+
`definePlugin<SeatPickerAttributes>()({ type, label, attributes, triggers, callbacks })` — and every other field
|
|
35
|
+
at the default all plugins share (the builder's gestures, the catalogue entry, each attribute bindable, an empty
|
|
36
|
+
style). It answers the whole declaration, branded with its attributes, so `defineElement(declaration)` is typed
|
|
37
|
+
without a generic. `plitzi plugin add` and `create --plugin` write declarations with it (about a third of the lines).
|
|
38
|
+
- **`usePluginTrigger(declaration)`** (`@plitzi/plitzi-sdk`): fires a plugin's declared event on its element — the
|
|
39
|
+
event name and what each hands a flow typed off the declaration's `preview` — on a live page only. The hook every
|
|
40
|
+
plugin wrote for itself (and `plugin add` generated as `use<Name>Events`) is gone from the scaffold.
|
|
41
|
+
- **Attributes as the types their defaults are** (`@plitzi/sdk-elements`): a plugin's attribute bound from text — a
|
|
42
|
+
state, a row, a channel message — reaches its component as the number or the flag its declared default is (`'112'`
|
|
43
|
+
as 112, `'true'` as true). A plugin no longer types its props `number | string` and parses them.
|
|
44
|
+
|
|
45
|
+
## Server actions and functions
|
|
46
|
+
- **Task params with rules** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): a task declares `required`, a text's
|
|
47
|
+
`maxLength` and a number's `min`/`max`, and the runner refuses a call that breaks any of them — every rule broken at
|
|
48
|
+
once, in the words the page shows (`Title is required; Seconds is at most 300`) — before the code runs. A `text` param
|
|
49
|
+
bound to a number arrives as its digits. The manifest keeps the rules, so the platform's sandbox checks the same.
|
|
50
|
+
- **`taskAction(task, { trigger })`** (`@plitzi/sdk-authoring`): the action that runs one of the space's tasks and
|
|
51
|
+
answers its result, derived from the task — its id (`<namespace>-<action>`), name, description and input (the task's
|
|
52
|
+
params, once). An action of more than one step is still `defineAction`.
|
|
53
|
+
- **`ctx.rateLimit(bucket, { …, refuse })`**: past the limit the call is refused with those words instead of answering
|
|
54
|
+
`allowed: false` for the code to check — natively and in the sandbox.
|
|
55
|
+
|
|
56
|
+
## Authoring
|
|
57
|
+
- **`runServerActionOrNotify(id, params, fallback)`**: a server action run and the notice the visitor reads when it
|
|
58
|
+
fails — the action's own refusal, or the fallback — as two steps to spread into a flow.
|
|
59
|
+
- **`repeated-shape` reads what copies bind**: copies whose bindings read their data in different forms (a count, a
|
|
60
|
+
total of a quota) and copies holding a provider resolved on the server (found by its own id) are no longer offered
|
|
61
|
+
as one component.
|
|
62
|
+
- **`element-color-inherited`** (suggestion): `elements` giving a heading, a text, a link… `color: inherit` or the
|
|
63
|
+
page's own colour. **A link inherits the page's colour** (`@plitzi/plitzi-sdk`, `@plitzi/sdk-elements`) rather than
|
|
64
|
+
holding the SDK's grey — the same by default, and the space's palette inside a card that is a link. The template
|
|
65
|
+
every space starts from writes its colours once, on the page.
|
|
66
|
+
|
|
67
|
+
## Fixes
|
|
68
|
+
- **A dialog opened with an id** (`@plitzi/sdk-elements`): `openDialog('dialog', '{{ row.id }}')` reads the id as its
|
|
69
|
+
`content`, as `openModal` already did — a numeric id parsed as the number and the dialog's bindings read nothing.
|
|
70
|
+
- **A select's chevron** (`@plitzi/plitzi-sdk`): a drawn chevron in the field's own colour, sized by its type, in place
|
|
71
|
+
of the `▼` glyph — and laid out in the box, so it ends where the box's padding begins whatever that padding is, and
|
|
72
|
+
the chosen option stops short of it instead of running under it. A disabled select's is faded.
|
|
73
|
+
- **Every element has its settings** (`@plitzi/plitzi-builder`, `@plitzi/sdk-elements`): the builder found none for
|
|
74
|
+
`tabContainerHeader` (registered under a misspelt type), `themeToggle`, `dropdownPopup`, `loading` and `notFound`.
|
|
75
|
+
The theme toggle's panel sets its mode, its labels and whether it offers "System"; the registry is typed by element
|
|
76
|
+
type and must hold one for each.
|
|
77
|
+
- **A plugin's panel** (`@plitzi/cli`): `plitzi doctor` warns of a plugin with no `Settings.tsx`, or one its entry never
|
|
78
|
+
passes as `pluginSettings` (`plugin-settings-missing`); the example `create` writes has its panel, as every element
|
|
79
|
+
`plugin add` writes does, and the panels it generates are laid out as the project's Prettier lays them out.
|
|
80
|
+
- **A refused or failed run reaches `onFlowError` in every mode** (`@plitzi/sdk-interactions`): an awaited server
|
|
81
|
+
action the server refused fired no `onFlowError` on the element that started it, as `detached` and `stream` ones do
|
|
82
|
+
— a board rolling its edits back on a refusal never did; and a run answered `status: 'failed'` fired `onFlowEnd`
|
|
83
|
+
(detached) or nothing (awaited) rather than `onFlowError`.
|
|
84
|
+
- **A source renamed** (`@plitzi/sdk-shared`): the binding picker lists a provider, a form or a modal by the name its
|
|
85
|
+
element has now, not the one it had when it mounted.
|
|
86
|
+
- **A text's words in the builder** (`@plitzi/sdk-elements`): a `paragraph`, `text` or `heading` whose `content` is
|
|
87
|
+
`0` shows `0` while editing too, not its placeholder; one bound to nothing shows nothing rather than `null`.
|
|
88
|
+
- **Built-in declarations** (`@plitzi/sdk-shared`): `elementDeclaration` fills in what every element shares — the
|
|
89
|
+
builder's gestures, Plitzi's catalogue entry, a visible element with no bindings, its style named by its label —
|
|
90
|
+
from the defaults `definePlugin` uses; each element's declaration says only what is its own (a third of the lines).
|
|
91
|
+
|
|
92
|
+
## Typed for plugins and hosts
|
|
93
|
+
- **`usePlitzi()` and `PlitziProvider`** (`@plitzi/sdk-shared/hooks/usePlitzi`, `@plitzi/plitzi-sdk`): what were
|
|
94
|
+
`usePlitziServiceContext()` and `PlitziServiceProvider` (and `PlitziServiceContextValue`, now `PlitziContextValue`),
|
|
95
|
+
holding only what the host rendering a space knows — `settings`, `root`, `utils`. Its `contexts` and
|
|
96
|
+
`customContexts` are gone: every context it carried is a shared one already, imported from its own module
|
|
97
|
+
(`@plitzi/sdk-interactions/InteractionsContext`, `@plitzi/sdk-shared/network/NetworkContext`…), and
|
|
98
|
+
`PluginsContext` moves to `@plitzi/sdk-shared/plugins/PluginsContext` beside the others.
|
|
99
|
+
- **`InteractionsManagerApi`** (`@plitzi/sdk-shared`): the interactions manager as everything outside
|
|
100
|
+
`@plitzi/sdk-interactions` reaches it, declared where every package can name it and implemented by
|
|
101
|
+
`InteractionsManager`, so `use(InteractionsContext)` is typed — `interactionTrigger`, `createChildManager`… — where it
|
|
102
|
+
was `any`.
|
|
103
|
+
- **`getPathsFromObject`** (`@plitzi/sdk-shared/helpers/utils`), spelt right; `getPathsFromObeject` is gone.
|
|
104
|
+
- **`ElementWords` places itself** (`@plitzi/sdk-elements`): `contentPlacement` and the element's children, so a button
|
|
105
|
+
and a link write their words once.
|
|
106
|
+
|
|
107
|
+
- Updated dependencies [1301338]
|
|
108
|
+
- @plitzi/plitzi-sdk@0.38.12
|
|
109
|
+
- @plitzi/sdk-shared@0.38.12
|
|
110
|
+
|
|
111
|
+
## 0.38.11
|
|
112
|
+
|
|
113
|
+
### Patch Changes
|
|
114
|
+
|
|
115
|
+
- cadf70a: - **`server.cache.invalidate` drops what a page is rendered from** (`@plitzi/sdk-server`): the pages, the RSC answers
|
|
116
|
+
and the schema data they are rendered from go together. It dropped the pages alone, and the next request rendered
|
|
117
|
+
the same page again from the schema still cached under the same key — a publish that invalidated the space changed
|
|
118
|
+
nothing until the schema's TTL ran out. `clear()` and `size` cover the three. A filter on `hostname` drops the schema
|
|
119
|
+
data too, which belongs to no one host. `server.cache` is `null` only when nothing is cached (`cacheTtlMs: 0` and
|
|
120
|
+
`rsc.cacheTtlMs: 0`).
|
|
121
|
+
|
|
122
|
+
## Style inspector
|
|
123
|
+
- **Finds a property** (`@plitzi/sdk-style`): a search above the categories narrows them to the ones that edit what was
|
|
124
|
+
typed — a CSS name in any order of its words (`border radius` finds the four corners), a category's title, or a
|
|
125
|
+
common word for it (`bg`, `rounded`) — opens them, and shows the advanced rows when the match lives there. Escape
|
|
126
|
+
clears it. The categories' properties live in one list (`categoryKeys.ts`) that the dots, the advanced hint and the
|
|
127
|
+
search all read.
|
|
128
|
+
- **Rows that fit**: a section with more than two controls puts its label above them and lays them out in as many
|
|
129
|
+
columns as the panel is wide, instead of one row where every label was cut (`Appearan…`, `Cell Spaci…`, the five
|
|
130
|
+
scroll-snap controls). A row's label column is 80px.
|
|
131
|
+
- **Where a value comes from, said quietly**: the label's tint keeps its four meanings — set here, from a token, bound
|
|
132
|
+
to data, inherited — without the solid blocks of colour; hovering says which (an inherited one names its selector and
|
|
133
|
+
breakpoint) and that a click resets it, the click shows it by striking the label through. The footer's info icon
|
|
134
|
+
holds the legend, and its arrow folds every category.
|
|
135
|
+
- **What is being edited**: an "Editing … › Hover" line under the pickers whenever the rules being written are not the
|
|
136
|
+
selector's plain ones, with a button back to them. Ancestor, pseudo-element and condition fold behind a toggle —
|
|
137
|
+
never while one is in use.
|
|
138
|
+
- The class being edited is the panel's one strong mark (violet), the element's type defaults a softer one; the tools'
|
|
139
|
+
tabs fit the panel and are reachable from the keyboard.
|
|
140
|
+
|
|
141
|
+
- **Lists edited in a popover, all alike**: box and text shadows, transforms, transitions and filters share one row
|
|
142
|
+
(the CSS it writes, a swatch, a remove button) and one popover (a title, a close button, Escape, the focus moved
|
|
143
|
+
into it). What none of them could read is now kept and edited as text instead of being replaced with a default — a
|
|
144
|
+
token for the whole value, `drop-shadow(…)`, `url(#…)`.
|
|
145
|
+
- **Values read the way CSS writes them**: a shadow with two, three or four lengths and its color on either end;
|
|
146
|
+
`rgba(…)` inside text shadows and filters no longer split; negative shadow offsets accepted; a transition with any
|
|
147
|
+
of its parts left out; brightness, contrast and saturation past 1. Transition presets are written as CSS — the
|
|
148
|
+
preset names (`easeInQuad`) made the browser drop the whole declaration — the curve can be dragged into one of your
|
|
149
|
+
own, and the preview stops with the editor. `font-color` (not CSS) became `color`.
|
|
150
|
+
- **Background layers keep what they hold**: a repeating gradient (now a switch), a radial gradient's explicit size, a
|
|
151
|
+
token or `image-set()` as a layer (a "Custom (CSS)" layer), a one-value position read as CSS reads it (`20%` is
|
|
152
|
+
`20% center`), lists shorter than the layers repeated as CSS repeats them, an unset repeat read as tiling, two-position
|
|
153
|
+
stops, negative angles — every one of them was rewritten on the next edit of any layer. Defaults are no longer
|
|
154
|
+
written back, and "Token values" no longer bakes resolved tokens into the layers.
|
|
155
|
+
- **A layer's editor in two halves** — what it draws, then where it goes (size, position, tile, attachment, clip,
|
|
156
|
+
which now offers `text`). The gradient's stops sit on one bar, each a handle that drags or moves with the arrow keys;
|
|
157
|
+
the stop's color and position below it. Previews and swatches resolve the space's tokens.
|
|
158
|
+
- Spacing tells margin (dashed, outside) from padding; Border's sides are labelled and readable in the dark theme; a
|
|
159
|
+
class's menu says what each action does to whom; the Style Manager opens at a size that holds both columns.
|
|
160
|
+
|
|
161
|
+
## Builder
|
|
162
|
+
- **Shortcuts**: `?` shows every shortcut the builder answers to — the same list the "Nothing selected" card teaches
|
|
163
|
+
from — and ⌘\ / Ctrl+\ hides both side panels for the canvas alone and brings back the ones that were open. Both
|
|
164
|
+
work with the canvas focused.
|
|
165
|
+
- **Panels keep their width**: each side panel opens at the width it was left at; the right one starts at 380px.
|
|
166
|
+
- **Text no smaller than 11px** across the builder's panels (it went down to 10px in fifty places).
|
|
167
|
+
|
|
168
|
+
## Realtime
|
|
169
|
+
- **A page hears what it sent when it asks to** (`@plitzi/sdk-shared`, `@plitzi/sdk-server`, `@plitzi/sdk-elements`):
|
|
170
|
+
`publishOn('room', 'react', data, { echo: true })`, `useChannel().publish(type, data, { echo: true })` and the
|
|
171
|
+
channel's `publish` callback (`echo`) hand the message back to the page that sent it too, once the server took it —
|
|
172
|
+
stamped like everyone's, with `echo: true`, its `from` the channel's `me`. Without it a page still never hears its
|
|
173
|
+
own messages, and the docs said "every page on its topic hears it": they now say every OTHER page. Presence never
|
|
174
|
+
echoes.
|
|
175
|
+
- **A topic is opened only once it names one** (`@plitzi/sdk-elements`): `useChannel` — and so the `channel` element —
|
|
176
|
+
opens a topic only when a channel of the space covers it, by the same `matchChannel` the server decides by. A topic
|
|
177
|
+
written from data that has not arrived (`room:` while its provider loads, or its template still as text) asked the
|
|
178
|
+
server for both, was refused with a 403 and a console error on every load, and is now waited for.
|
|
179
|
+
- **Pages that watch** (`@plitzi/sdk-server`, `@plitzi/cli`): a connection whose page carries the `plitzi-observer`
|
|
180
|
+
cookie hears its topics and says nothing on them — no `$join`, no presence, its publishes taken and dropped.
|
|
181
|
+
`page check`, `page shot` and `verify` load pages that way, so checking a live site is no longer a visitor walking
|
|
182
|
+
into a room (`X walked in`, a member more in every picture). `--presence` takes part as a visitor does.
|
|
183
|
+
|
|
184
|
+
## Authoring
|
|
185
|
+
- **`template-in-value`** (refused): a `{{ }}` inside an attribute that is an object or a list — a provider's
|
|
186
|
+
`input`, a list's `items`, a plugin's settings — is never evaluated: only an attribute that is text is interpolated,
|
|
187
|
+
and the page server reads attributes as saved. A provider's `input` also replaced the route param of the same name
|
|
188
|
+
the action was already given, so `input: { room: '{{ navigation.routeParams.room }}' }` reached the task as `""` and
|
|
189
|
+
the page answered 404; its refusal says the action is handed the page's route and query params already. Anything
|
|
190
|
+
else is a binding on the attribute. `mockData`, a sample, is not held to it.
|
|
191
|
+
- **Rules on top of a class need no `id`** (`class: [card, { gap: '6px' }]`): they are named after the id the element
|
|
192
|
+
is given, written or not. `modifier-without-id` is gone; a one-off tweak no longer needs a name nothing reads.
|
|
193
|
+
- **Typed list rows have `inTemplate`**, as untyped ones do, and `bindTemplate`, `visibleWhen`, `hiddenWhen` and
|
|
194
|
+
`variantFrom` take a typed source's path as well as a name: turning a list typed broke every template of its rows.
|
|
195
|
+
- **`when({ field, operator: 'empty' })`** takes no `value` (nor `notEmpty`), as flows.md recommends; it did not
|
|
196
|
+
type-check.
|
|
197
|
+
- **Data-driven colours**: a style binding on a custom property (`{ to: '--who', category: 'style' }`) is written as
|
|
198
|
+
named — it was camel-cased into `who` — so a class reads `var(--who, var(--muted))`. A style binding's value carrying
|
|
199
|
+
`;` or braces is not written: the page server writes inline styles as text, and such a value added declarations of
|
|
200
|
+
its own. `binding-target-unknown` on `style` or a CSS property says to bind it in the `style` category.
|
|
201
|
+
- `unknown-attribute` for `decorative` on an `svg` or a `fontAwesome` says what it means: without a `label` it is
|
|
202
|
+
already hidden from screen readers.
|
|
203
|
+
|
|
204
|
+
- **A folder nobody declared says where to declare it**: `folder-undeclared` (a page, a layout, a folder's parent)
|
|
205
|
+
ends with `pageFolders: [{ id, name }]` on the space, and with the line of the `pageFamily` that wrote the page. A
|
|
206
|
+
folder starts its pages' addresses (`/docs/quickstart`), so a misspelt one is never declared on the author's behalf.
|
|
207
|
+
The skill's `pageFamily` example declares its folder.
|
|
208
|
+
- **A tag is an element**: a `subType` this element has not but another has — `container({ subType: 'ol' })` — names
|
|
209
|
+
that element (`list({ subType: 'ol' })`) instead of the value two letters away (`dl`). Read off the elements'
|
|
210
|
+
declarations, for every element and tag.
|
|
211
|
+
- **A `pageFamily`'s body is written once**: `repeated-shape` and `repeated-on-pages` no longer count the same part of
|
|
212
|
+
each page of one family as copies — they were offering a component for exactly what the docs recommend. Copies within
|
|
213
|
+
one page, or across pages written one by one, are still offered.
|
|
214
|
+
- **Colour emoji are not text to `page check`**: a character painted in its own colours (🎲, `❤️`, a keycap, a ZWJ
|
|
215
|
+
sequence) is left out of the contrast measure, which compared `color` with the tile behind it and failed `verify`
|
|
216
|
+
in the theme whose text colour was close to the tile. A symbol drawn as text (✓, ★) is still measured.
|
|
217
|
+
|
|
218
|
+
- **`declared-callback-target`** (refused): a value beside `on` in `declaredCallback(…, { on, date })` — written as
|
|
219
|
+
`openModal`'s target reads — was read nowhere, and the step ran without it. Refused, with the `params` it goes in
|
|
220
|
+
(`{ on: 'calendar', params: { date } }`) and whether it is one of the callback's declared params.
|
|
221
|
+
- The skill's list rows show the typed form beside the untyped one: with `items` typed by a sample, `r.item` is a path
|
|
222
|
+
(`from: r.item.title`), not text to put in a template string.
|
|
223
|
+
- **`slot-not-class`** (refused): rules written in place in a slot — `slots: { error: [fieldError, { color }] }`, past
|
|
224
|
+
the type in JavaScript or a spec rebuilt from JSON — were taken for a declaration with no rules, and `authorSpace`
|
|
225
|
+
failed later with `Cannot read properties of undefined (reading 'desktop')`, naming nothing. Refused where the slot
|
|
226
|
+
is written, naming the slot and the element, with the `styles()` declaration to hand instead.
|
|
227
|
+
|
|
228
|
+
## CLI
|
|
229
|
+
- **`page shot --click` (and `--clip`, `--wait-for`, `--scroll-to`, `--steps`) takes any selector**: a value that is
|
|
230
|
+
not an element's name (letters, digits, `-`, `_`) is a selector, CSS or Playwright's own (`button:has-text("Orbit")`).
|
|
231
|
+
It was wrapped as a name, and an invalid selector ended the command with Playwright's stack trace; it is now refused
|
|
232
|
+
with the reason.
|
|
233
|
+
|
|
234
|
+
- **`plitzi functions add <package>`**: a package the functions use comes with them, as a function carries its
|
|
235
|
+
dependencies. Installed in the project, it is bundled (web APIs only, minified, its licence kept) into
|
|
236
|
+
`src/functions/vendor/<package>.js`, with a `.d.ts` re-exporting the installed package's types, imported as
|
|
237
|
+
`./vendor/<package>.js` and pushed, built and run with the rest — nothing is resolved anywhere else, so the builder,
|
|
238
|
+
the sandbox and the push are unchanged. A package that reaches Node (`fs`, `node:*`) is refused, naming what it
|
|
239
|
+
reached; one past the functions' 1 MB is too; one that reads `process`/`Buffer` is warned about. The build's refusal
|
|
240
|
+
of a package import now names the command.
|
|
241
|
+
- **`page shot` targets**: a bare word is an element's name, or — no element named so — a tag (`textarea`); resolved on
|
|
242
|
+
the loaded page for `--click`, `--clip`, `--scroll-to`, `--wait-for` and `--steps`. In `--steps`, `type` takes a
|
|
243
|
+
quoted element with spaces (`type ".panel textarea" hola`) — it was cut at its first space and typed the rest — and
|
|
244
|
+
fails when the click leaves no field focused, rather than sending the keys to the page's shortcuts.
|
|
245
|
+
|
|
246
|
+
## Server
|
|
247
|
+
- **`server.listen()` resolves once the port answers** (`@plitzi/sdk-server`) — in a fleet, once the first worker
|
|
248
|
+
does. `serveProject` writes `tmp/dev-server.json` and says `pages on …` after it, not on the line after `listen`:
|
|
249
|
+
for about 0.4 s a tool trusting the line (CI, Playwright's `webServer`, `page check`) was refused. A port it cannot
|
|
250
|
+
take still ends the process, or goes to `onListenError`, and the promise is then never resolved.
|
|
251
|
+
- **Runs set for later** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`, `@plitzi/sdk-authoring`, `@plitzi/plitzi-builder`):
|
|
252
|
+
a turn that runs out, a bot's move, a hold that lapses — one run starting one of the space's actions in N seconds,
|
|
253
|
+
whether or not a page is still open. The action says it may be with a **`later` trigger** (no access rule: the run
|
|
254
|
+
that set it was let in); a flow sets it with `flow.later { action, in, input, key }`, a function with
|
|
255
|
+
`ctx.later({ … })`, and `flow.cancelLater` / `ctx.cancelLater(key)` drops it. A `key` names it: set again under the
|
|
256
|
+
same key, the one still waiting is replaced — the newer of two set at once, on every replica — and a running one is
|
|
257
|
+
left. It is a job of the queue schedules use: due by the store's clock (0 s to 30 days, about a second late at most),
|
|
258
|
+
once across replicas, retried, shown in Automations → Queue. Refused before anything is queued, with why: no `later`
|
|
259
|
+
trigger, one switched off, a time out of range, a key that is not one, a server with no jobs. A plugin's functions
|
|
260
|
+
set none. `ActionJobQueue` gains `cancelPending({ spaceId, key, olderThan? })` and jobs a `key`: the memory, Mongo
|
|
261
|
+
and MySQL queues implement it, and the shared contract tests it. **MySQL**: `action_jobs` gains `job_key` (and the
|
|
262
|
+
`action_jobs_key` index), added on first use; with `createTables: false`, run that statement of
|
|
263
|
+
`mysqlJobSchemaUpgrades()`. A queue of a deployment's own implements `cancelPending` (`09-schedules` shows one).
|
|
264
|
+
- **A project's `kv` file has one holder** (`@plitzi/sdk-server`): `createFileKv` takes `<file>.lock` with its pid;
|
|
265
|
+
a second process — another `npm start`, a `--watch` left running — is refused, naming the first (`the server of
|
|
266
|
+
"orbita", on port 8080`) instead of both writing their whole map over each other's changes, and a lock whose process
|
|
267
|
+
is gone is taken over. `close()` writes what is pending and lets go. A server with `workers` opens the file once, in
|
|
268
|
+
the primary, and its workers reach it through the fleet (`fleetKv`): each used to open a copy of its own.
|
|
269
|
+
- **A self-hosted project's credentials** (`@plitzi/sdk-server`, `@plitzi/cli`): `serveProject` answers
|
|
270
|
+
`getCredential` from `PLITZI_CREDENTIALS` in `.env` — one JSON object, credential id → its keys — so
|
|
271
|
+
`ctx.fetch({ credential })`, a connector and an `http.request` step work on the project's own server, not only in
|
|
272
|
+
`functions dev`. The same variable for both (it was `PLITZI_FUNCTIONS_CREDENTIALS`, read by the CLI alone); a value
|
|
273
|
+
that is not that object is refused with how to write it, instead of every credential going missing.
|
|
274
|
+
- **`HOST` beyond loopback says where to open it**: with `HOST=0.0.0.0`, `serveProject` prints the machine's network
|
|
275
|
+
addresses — what a tablet on the same Wi-Fi opens — and that anyone on that network can. `.env.example` names `HOST`
|
|
276
|
+
and `PLITZI_CREDENTIALS`.
|
|
277
|
+
|
|
278
|
+
## SDK
|
|
279
|
+
- **`useElementSize(ref)`** (`@plitzi/plitzi-sdk`): the size a plugin's own box is drawn at, followed as it changes —
|
|
280
|
+
what `useDisplayMode()` cannot say: a tablet held upright is `mobile` by the window and still a week wide by the
|
|
281
|
+
plugin's box. `undefined` until measured, so the server's page and the hydrated one agree. The breakpoints are
|
|
282
|
+
unchanged.
|
|
283
|
+
- The functions docs say how a task's `params` types (how the builder edits them: `codemirror-json`) and an action's
|
|
284
|
+
`input` types (what the value is: `json`) correspond.
|
|
285
|
+
|
|
286
|
+
- Updated dependencies [cadf70a]
|
|
287
|
+
- @plitzi/plitzi-sdk@0.38.11
|
|
288
|
+
- @plitzi/sdk-shared@0.38.11
|
|
289
|
+
|
|
3
290
|
## 0.38.10
|
|
4
291
|
|
|
5
292
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -610,7 +610,7 @@ Responses include an `X-Cache: HIT` or `X-Cache: MISS` header for observability.
|
|
|
610
610
|
|
|
611
611
|
### Cache manager
|
|
612
612
|
|
|
613
|
-
`server.cache` exposes programmatic cache control, useful when content changes and you need to invalidate entries without restarting the server.
|
|
613
|
+
`server.cache` exposes programmatic cache control, useful when content changes and you need to invalidate entries without restarting the server. It reaches every cache a render is kept in — the pages, the RSC answers and the schema data they are rendered from — so a page invalidated is rendered again from the space as it is now, never from the copy it was cached with.
|
|
614
614
|
|
|
615
615
|
```ts
|
|
616
616
|
const server = createServer({ cacheTtlMs: 300_000, adapters });
|
|
@@ -631,7 +631,7 @@ server.cache?.clear();
|
|
|
631
631
|
console.log(server.cache?.size);
|
|
632
632
|
```
|
|
633
633
|
|
|
634
|
-
`server.cache` is `null` when
|
|
634
|
+
`server.cache` is `null` when nothing is cached (`cacheTtlMs: 0` and `rsc.cacheTtlMs: 0`). `size` counts the entries of all three caches.
|
|
635
635
|
|
|
636
636
|
#### `CacheFilter`
|
|
637
637
|
|
|
@@ -641,7 +641,7 @@ console.log(server.cache?.size);
|
|
|
641
641
|
| `environment` | `string` | Match entries for this environment. |
|
|
642
642
|
| `hostname` | `string` | Match entries for this hostname. |
|
|
643
643
|
|
|
644
|
-
All fields are optional and combined with AND logic. Calling `invalidate()` with no filter (or an empty object) clears the entire cache.
|
|
644
|
+
All fields are optional and combined with AND logic. Calling `invalidate()` with no filter (or an empty object) clears the entire cache. The schema data belongs to no one host, so a filter on `hostname` drops it too — the host's pages are rendered from it — and it is read again on the next miss.
|
|
645
645
|
|
|
646
646
|
## Plugins
|
|
647
647
|
|
package/dist/auth.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { createCarriers, presentedOrigin } from "./core/auth/credentials.js";
|
|
1
2
|
import { appendCookies, clearFlowCookie, clearSessionCookies, createSessionCookies, isLocalHost, parseSessionHint, readFlowCookie, readRefreshToken, readSessionHint, readSessionToken, sessionCookieParams, sessionHintValue, sessionReturnTarget, writeFlowCookie, writeSessionCookies } from "./core/auth/session.js";
|
|
2
3
|
import { createCsrf, csrfFailureMessage } from "./core/auth/csrf.js";
|
|
3
4
|
import { applySessionOutcome, authPolicyRules, authRoutes } from "./core/auth/routes.js";
|
|
4
5
|
import { isDocumentNavigation, renewForNavigation } from "./core/auth/renewal.js";
|
|
5
|
-
import { createCarriers, presentedOrigin } from "./core/auth/credentials.js";
|
|
6
6
|
import { ANY_DOMAIN, corsOrigins, domainAllowed, frameAncestors, hostnameOf, normalizeDomain } from "./core/auth/domains.js";
|
|
7
7
|
import { checkPermission, checkSpaceAccess, createAuthorizer, requirementFor } from "./core/auth/authorize.js";
|
|
8
8
|
import { generateToken, hashPassword, verifyPassword } from "./core/auth/passwords.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { createCarriers, presentedOrigin } from "./credentials.js";
|
|
1
2
|
import { createSessionCookies, sessionCookieParams } from "./session.js";
|
|
2
3
|
import { createCsrf } from "./csrf.js";
|
|
3
4
|
import { applySessionOutcome, authPolicyRules, authRoutes } from "./routes.js";
|
|
4
|
-
import { createCarriers, presentedOrigin } from "./credentials.js";
|
|
5
5
|
import { createAuthorizer } from "./authorize.js";
|
|
6
6
|
import { createTokens } from "./tokens.js";
|
|
7
7
|
import { createAuthApi } from "./api.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { readCookies } from "../../auth/credentials.js";
|
|
1
2
|
import { requestOrigin } from "../../requestParser.js";
|
|
2
3
|
import { safeRedirectTarget } from "../navigation.js";
|
|
3
4
|
import { appendCookies, writeSessionCookies } from "../../auth/session.js";
|
|
4
|
-
import { readCookies } from "../../auth/credentials.js";
|
|
5
5
|
import { createHash, randomBytes } from "node:crypto";
|
|
6
6
|
//#region src/core/http/stages/signInRoute.ts
|
|
7
7
|
/**
|
|
@@ -40,18 +40,19 @@ var createHttpServer = (config, makeHandlerForPort, parts) => {
|
|
|
40
40
|
}) },
|
|
41
41
|
listen(port, host = "0.0.0.0") {
|
|
42
42
|
if (plan.requested !== void 0 && role !== "worker") serverLog.warn(label, `${plan.requested} workers asked for, ${plan.count} cores to run them on: starting ${plan.count}`);
|
|
43
|
-
if (role === "primary") {
|
|
43
|
+
if (role === "primary") return new Promise((resolve) => {
|
|
44
44
|
(parts.beforeFork?.() ?? Promise.resolve()).catch((error) => serverLog.error(label, "preparing for the workers failed", error)).then(async () => {
|
|
45
45
|
const { startFleet } = await import("./fleet/supervisor.js");
|
|
46
46
|
if (closed) return;
|
|
47
47
|
fleet = startFleet(plan.count, label);
|
|
48
48
|
serverLog.info(label, `${plan.count} workers on ${host}:${port}`);
|
|
49
|
+
await fleet.listening;
|
|
50
|
+
resolve();
|
|
49
51
|
}).catch((error) => {
|
|
50
52
|
serverLog.error(label, "the workers could not start", error);
|
|
51
53
|
process.exitCode = 1;
|
|
52
54
|
});
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
+
});
|
|
55
56
|
const handler = makeHandlerForPort(port);
|
|
56
57
|
({primary, h3} = buildTransport(config, handler, port, label));
|
|
57
58
|
connections = watchConnections(primary);
|
|
@@ -68,9 +69,13 @@ var createHttpServer = (config, makeHandlerForPort, parts) => {
|
|
|
68
69
|
process.exitCode = 1;
|
|
69
70
|
process.exit(1);
|
|
70
71
|
});
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
const bound = primary;
|
|
73
|
+
return new Promise((resolve) => {
|
|
74
|
+
bound.listen(port, host, () => {
|
|
75
|
+
serverLog.info(label, `${protoLabel(version, !!config.tls)} - listening on ${host}:${port}`);
|
|
76
|
+
parts.onListen?.();
|
|
77
|
+
resolve();
|
|
78
|
+
});
|
|
74
79
|
});
|
|
75
80
|
},
|
|
76
81
|
async close() {
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { HostedStore } from './channel';
|
|
2
2
|
import { FleetStoreName } from './link';
|
|
3
|
+
import { ActionKvAdapter } from '../../../modules/actions/types';
|
|
4
|
+
/**
|
|
5
|
+
* A `kv` the deployment makes — a file — opened by ONE process of a fleet and reached by the rest: made in the primary
|
|
6
|
+
* (or the single process there is), and in a worker the primary's, over the channel. Made in every worker instead,
|
|
7
|
+
* each would hold its own copy of the file and write it over the others'.
|
|
8
|
+
*/
|
|
9
|
+
export declare const fleetKv: (make: () => ActionKvAdapter) => ActionKvAdapter;
|
|
3
10
|
/**
|
|
4
11
|
* What the primary keeps for its workers: the same in-memory defaults a single server makes for itself, made here
|
|
5
12
|
* once — when a worker first asks — so the fleet has one of each rather than one per worker.
|
|
@@ -1,19 +1,33 @@
|
|
|
1
1
|
import { JOB_QUEUE_METHODS, createMemoryJobQueue } from "../../../modules/actions/jobs/memoryQueue.js";
|
|
2
2
|
import { hostable } from "./channel.js";
|
|
3
|
+
import { fleetStore } from "./link.js";
|
|
3
4
|
import { KV_METHODS, createMemoryKv } from "../../../modules/actions/runtime/memoryKv.js";
|
|
4
5
|
import { DRAFT_STORE_METHODS, createMemoryDraftStore } from "../../../modules/ssr/preview.js";
|
|
5
6
|
import { RATE_LIMIT_METHODS, createMemoryRateLimit } from "../../auth/throttle.js";
|
|
6
7
|
//#region src/core/server/fleet/stores.ts
|
|
8
|
+
/** The `kv` a deployment keeps somewhere of its own — a file, a database — when the primary is the one that opened it. */
|
|
9
|
+
var deploymentKv;
|
|
10
|
+
/**
|
|
11
|
+
* A `kv` the deployment makes — a file — opened by ONE process of a fleet and reached by the rest: made in the primary
|
|
12
|
+
* (or the single process there is), and in a worker the primary's, over the channel. Made in every worker instead,
|
|
13
|
+
* each would hold its own copy of the file and write it over the others'.
|
|
14
|
+
*/
|
|
15
|
+
var fleetKv = (make) => {
|
|
16
|
+
const remote = fleetStore("actions.kv", KV_METHODS);
|
|
17
|
+
if (remote) return remote;
|
|
18
|
+
deploymentKv = make();
|
|
19
|
+
return deploymentKv;
|
|
20
|
+
};
|
|
7
21
|
/**
|
|
8
22
|
* What the primary keeps for its workers: the same in-memory defaults a single server makes for itself, made here
|
|
9
23
|
* once — when a worker first asks — so the fleet has one of each rather than one per worker.
|
|
10
24
|
*/
|
|
11
25
|
var FLEET_STORES = {
|
|
12
|
-
"actions.kv": hostable(createMemoryKv, KV_METHODS),
|
|
26
|
+
"actions.kv": hostable(() => deploymentKv ?? createMemoryKv(), KV_METHODS),
|
|
13
27
|
"realtime.grants": hostable(createMemoryKv, KV_METHODS),
|
|
14
28
|
"actions.jobs": hostable(() => createMemoryJobQueue(), JOB_QUEUE_METHODS),
|
|
15
29
|
"ssr.drafts": hostable(createMemoryDraftStore, DRAFT_STORE_METHODS),
|
|
16
30
|
"auth.rateLimit": hostable(() => ({ check: createMemoryRateLimit() }), RATE_LIMIT_METHODS)
|
|
17
31
|
};
|
|
18
32
|
//#endregion
|
|
19
|
-
export { FLEET_STORES };
|
|
33
|
+
export { FLEET_STORES, fleetKv };
|
|
@@ -37,7 +37,10 @@ var startFleet = (count, label, exit = (code) => process.exit(code)) => {
|
|
|
37
37
|
if (shared.count !== count) throw new Error(`[${label}] this process already runs ${shared.count} workers; every server in it must ask for the same number`);
|
|
38
38
|
shared.servers += 1;
|
|
39
39
|
const state = shared;
|
|
40
|
-
return {
|
|
40
|
+
return {
|
|
41
|
+
listening: state.listening,
|
|
42
|
+
stop: () => leave(state)
|
|
43
|
+
};
|
|
41
44
|
}
|
|
42
45
|
const workers = /* @__PURE__ */ new Set();
|
|
43
46
|
const restarts = /* @__PURE__ */ new Set();
|
|
@@ -45,6 +48,10 @@ var startFleet = (count, label, exit = (code) => process.exit(code)) => {
|
|
|
45
48
|
let deaths = [];
|
|
46
49
|
let served = false;
|
|
47
50
|
let stopping = false;
|
|
51
|
+
let listened = () => void 0;
|
|
52
|
+
const listening = new Promise((resolve) => {
|
|
53
|
+
listened = resolve;
|
|
54
|
+
});
|
|
48
55
|
const stopAll = () => {
|
|
49
56
|
restarts.forEach((timer) => clearTimeout(timer));
|
|
50
57
|
restarts.clear();
|
|
@@ -62,6 +69,7 @@ var startFleet = (count, label, exit = (code) => process.exit(code)) => {
|
|
|
62
69
|
workers.add(worker);
|
|
63
70
|
worker.once("listening", () => {
|
|
64
71
|
served = true;
|
|
72
|
+
listened();
|
|
65
73
|
});
|
|
66
74
|
worker.once("exit", (code, signal) => {
|
|
67
75
|
workers.delete(worker);
|
|
@@ -89,13 +97,17 @@ var startFleet = (count, label, exit = (code) => process.exit(code)) => {
|
|
|
89
97
|
const state = {
|
|
90
98
|
count,
|
|
91
99
|
servers: 1,
|
|
100
|
+
listening,
|
|
92
101
|
stop: async () => {
|
|
93
102
|
stopping = true;
|
|
94
103
|
await stopAll();
|
|
95
104
|
}
|
|
96
105
|
};
|
|
97
106
|
shared = state;
|
|
98
|
-
return {
|
|
107
|
+
return {
|
|
108
|
+
listening,
|
|
109
|
+
stop: () => leave(state)
|
|
110
|
+
};
|
|
99
111
|
};
|
|
100
112
|
/** The workers stop when the last server of this process that started them closes. */
|
|
101
113
|
var leave = async (state) => {
|
|
@@ -37,7 +37,7 @@ var createPageServer = (config, services, extensions) => {
|
|
|
37
37
|
reportReactBuild(config.devMode);
|
|
38
38
|
if (config.preview?.enabled && !config.draftStore) config.draftStore = fleetStore("ssr.drafts", DRAFT_STORE_METHODS) ?? createMemoryDraftStore();
|
|
39
39
|
const caches = createServerCaches(htmlTtlMs, config.rsc?.cacheTtlMs ?? DEFAULT_TTL_MS.rsc);
|
|
40
|
-
const cache = caches.html ? buildCacheManager(caches
|
|
40
|
+
const cache = caches.html || caches.rsc ? buildCacheManager(caches) : null;
|
|
41
41
|
const renderFn = config.templateFn ?? compileTemplate();
|
|
42
42
|
const pluginManager = new PluginManager(normalizePlugins(config.plugins ?? {}), config.pluginsCacheDir, config.pluginsTtlMs, config.devMode);
|
|
43
43
|
const plugins = {
|
package/dist/functions-api.d.ts
CHANGED
|
@@ -94,6 +94,15 @@ export declare type FunctionContext = {
|
|
|
94
94
|
grant: (topic: string, ttlSeconds?: number) => Promise<string>;
|
|
95
95
|
/** Takes a grant back — or every grant for the topic, naming none. */
|
|
96
96
|
revoke: (topic: string, grant?: string) => Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Starts one of the space's actions — one with a `later` trigger — in so many seconds, on the server, whether or not a
|
|
99
|
+
* page is still open: a turn that runs out, a bot's move, a hold that lapses. A `key` names it: set again under the
|
|
100
|
+
* same key, the one still waiting is replaced. Answers the job and when it is due (epoch ms, by the queue's clock).
|
|
101
|
+
* `ctx.later({ action: 'game.timeout', in: 45, input: { room }, key: 'turn:' + room })`.
|
|
102
|
+
*/
|
|
103
|
+
later: (request: LaterRequest) => Promise<LaterAnswer>;
|
|
104
|
+
/** Drops what waits under `key` — the timer of a game that ended — and answers how many. */
|
|
105
|
+
cancelLater: (key: string) => Promise<number>;
|
|
97
106
|
/**
|
|
98
107
|
* One file of the space's data — a project's `src/data/<file>` — parsed, as of the version the run belongs to: what
|
|
99
108
|
* a page must not carry, read here and answered only as far as it is shown. Read-only. `ctx.data('products.json')`.
|
|
@@ -202,17 +211,28 @@ declare type InteractionCallbackParam<T extends Record<string, unknown> = Record
|
|
|
202
211
|
* space's credentials of that kind to pick from, rather than a text box somebody has to type an identifier into.
|
|
203
212
|
*/
|
|
204
213
|
credentialProvider?: SpaceCredentialProvider;
|
|
205
|
-
|
|
214
|
+
/**
|
|
215
|
+
* A space's task refuses to run without it — empty, or only spaces — saying so with the param's `label`, before its
|
|
216
|
+
* code runs: what a task otherwise checked by hand in its first lines.
|
|
217
|
+
*/
|
|
218
|
+
required?: boolean;
|
|
219
|
+
} &
|
|
220
|
+
/** Handed to a task as text, whatever was written or bound — a number as its digits — at most `maxLength` long. */
|
|
221
|
+
({
|
|
206
222
|
type: 'text';
|
|
207
223
|
defaultValue?: string | number;
|
|
224
|
+
maxLength?: number;
|
|
208
225
|
}
|
|
209
|
-
/** Written as text — a number or a template — and handed to the callback as a number
|
|
226
|
+
/** Written as text — a number or a template — and handed to the callback as a number, within `min` and `max`. */
|
|
210
227
|
| {
|
|
211
228
|
type: 'number';
|
|
212
229
|
defaultValue?: number;
|
|
230
|
+
min?: number;
|
|
231
|
+
max?: number;
|
|
213
232
|
} | {
|
|
214
233
|
type: 'textarea';
|
|
215
234
|
defaultValue?: string | number;
|
|
235
|
+
maxLength?: number;
|
|
216
236
|
} | {
|
|
217
237
|
type: 'codemirror-text';
|
|
218
238
|
defaultValue?: string;
|
|
@@ -293,6 +313,26 @@ declare type KvListRange = {
|
|
|
293
313
|
order?: 'asc' | 'desc';
|
|
294
314
|
};
|
|
295
315
|
|
|
316
|
+
/** The job it became, and when it is due — epoch ms, by the queue's clock. */
|
|
317
|
+
declare type LaterAnswer = {
|
|
318
|
+
id: string;
|
|
319
|
+
at: number;
|
|
320
|
+
};
|
|
321
|
+
|
|
322
|
+
/** What a run asks to start later: one of the space's actions, in so many seconds, with its input — and a name. */
|
|
323
|
+
declare type LaterRequest = {
|
|
324
|
+
/** The action, by its identifier. It says it may be started this way with a `later` trigger. */
|
|
325
|
+
action: string;
|
|
326
|
+
/** Seconds from now, by the queue's clock — whole or not, from 0 to a month. */
|
|
327
|
+
in: number;
|
|
328
|
+
input?: Record<string, unknown>;
|
|
329
|
+
/**
|
|
330
|
+
* What it is known by in this space: setting another under the same key replaces the one still waiting — a turn's
|
|
331
|
+
* timer moved on by a move — and `cancelLater(key)` drops it. The one already running is left be.
|
|
332
|
+
*/
|
|
333
|
+
key?: string;
|
|
334
|
+
};
|
|
335
|
+
|
|
296
336
|
/** Where a limit stands after counting one more: whether that one was within it, and how many are left. */
|
|
297
337
|
declare type RateCount = {
|
|
298
338
|
allowed: boolean;
|
|
@@ -305,6 +345,11 @@ declare type RateLimit = {
|
|
|
305
345
|
most: number;
|
|
306
346
|
perSeconds: number;
|
|
307
347
|
per?: 'caller' | 'everyone';
|
|
348
|
+
/**
|
|
349
|
+
* Over the limit, the call is refused with these words — the step's error, on the page — rather than answered
|
|
350
|
+
* `allowed: false` for the code to check: `ctx.rateLimit('make', { most: 5, perSeconds: 600, refuse: 'Wait ten minutes' })`.
|
|
351
|
+
*/
|
|
352
|
+
refuse?: string;
|
|
308
353
|
};
|
|
309
354
|
|
|
310
355
|
declare type SpaceCredentialProvider = 's3' | 'r2' | 'ssr' | 'custom' | 'smtp';
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ServerCaches } from './serverCaches';
|
|
2
2
|
import { CacheManager } from '@plitzi/sdk-shared';
|
|
3
|
-
|
|
3
|
+
/**
|
|
4
|
+
* `server.cache` over every cache a render is kept in: the pages, the RSC answers, and the space as read for both.
|
|
5
|
+
*
|
|
6
|
+
* All three, because they hold one change between them. Dropping the pages alone left the space they were rendered
|
|
7
|
+
* from, and the next request rendered the page that had just been dropped from it — an invalidation that cleared
|
|
8
|
+
* every page and changed none of them.
|
|
9
|
+
*/
|
|
10
|
+
export declare const buildCacheManager: ({ html, rsc, offlineData }: ServerCaches) => CacheManager;
|