@plitzi/sdk-server 0.38.3 → 0.38.5

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.
Files changed (125) hide show
  1. package/CHANGELOG.md +530 -0
  2. package/README.md +142 -24
  3. package/dist/actions.d.ts +8 -5
  4. package/dist/actions.js +3 -1
  5. package/dist/adapters/jsonAdapters.d.ts +1 -1
  6. package/dist/adapters/jsonAdapters.js +16 -3
  7. package/dist/core/configSeam.js +20 -4
  8. package/dist/core/createServer.js +3 -2
  9. package/dist/core/handlers/socialRouteHandlers.js +6 -1
  10. package/dist/core/http/stages/devReload.d.ts +11 -0
  11. package/dist/core/http/stages/devReload.js +17 -0
  12. package/dist/core/http/stages/images.js +1 -1
  13. package/dist/core/server/baseServer.d.ts +2 -0
  14. package/dist/core/server/baseServer.js +3 -0
  15. package/dist/core/server/pageServer.js +18 -0
  16. package/dist/core/services/registry.js +2 -0
  17. package/dist/core/services/rsc.js +1 -1
  18. package/dist/core/services/spaceDocument.d.ts +2 -0
  19. package/dist/core/services/spaceDocument.js +11 -0
  20. package/dist/functions-api.d.ts +6 -1
  21. package/dist/functionsRunner.d.ts +5 -0
  22. package/dist/functionsRunner.js +2 -1
  23. package/dist/helpers/hydrationPayload.d.ts +25 -4
  24. package/dist/helpers/hydrationPayload.js +36 -30
  25. package/dist/index.d.ts +2 -2
  26. package/dist/index.js +2 -2
  27. package/dist/modules/actions/index.d.ts +11 -2
  28. package/dist/modules/actions/index.js +29 -7
  29. package/dist/modules/actions/runtime/fileKv.d.ts +28 -0
  30. package/dist/modules/actions/runtime/fileKv.js +95 -0
  31. package/dist/modules/actions/runtime/fileKv.test.d.ts +1 -0
  32. package/dist/modules/actions/runtime/memoryKv.d.ts +23 -0
  33. package/dist/modules/actions/runtime/memoryKv.js +39 -24
  34. package/dist/modules/actions/runtime/namespaceKv.d.ts +2 -0
  35. package/dist/modules/actions/runtime/namespaceKv.js +5 -3
  36. package/dist/modules/actions/runtime/renderResolver.d.ts +3 -2
  37. package/dist/modules/actions/runtime/renderResolver.js +13 -9
  38. package/dist/modules/actions/runtime/renderShare.d.ts +7 -24
  39. package/dist/modules/actions/runtime/renderShare.js +47 -13
  40. package/dist/modules/actions/runtime/runAction.js +15 -1
  41. package/dist/modules/actions/runtime/scope.js +16 -1
  42. package/dist/modules/actions/runtime/signing.js +4 -1
  43. package/dist/modules/actions/runtime/taskContext.d.ts +7 -1
  44. package/dist/modules/actions/runtime/taskContext.js +6 -2
  45. package/dist/modules/actions/tasks/registry.d.ts +3 -1
  46. package/dist/modules/actions/tasks/registry.js +15 -1
  47. package/dist/modules/actions/types.d.ts +15 -2
  48. package/dist/modules/functions/config.d.ts +6 -0
  49. package/dist/modules/functions/context.d.ts +4 -2
  50. package/dist/modules/functions/context.js +43 -21
  51. package/dist/modules/functions/load.d.ts +8 -1
  52. package/dist/modules/functions/load.js +8 -4
  53. package/dist/modules/functions/manifest.d.ts +4 -1
  54. package/dist/modules/functions/manifest.js +14 -2
  55. package/dist/modules/functions/native.d.ts +2 -1
  56. package/dist/modules/functions/native.js +2 -2
  57. package/dist/modules/functions/plugins.test.d.ts +1 -0
  58. package/dist/modules/functions/routes.d.ts +8 -3
  59. package/dist/modules/functions/routes.js +41 -21
  60. package/dist/modules/functions/scope.d.ts +30 -0
  61. package/dist/modules/functions/scope.js +28 -0
  62. package/dist/modules/functions/space.d.ts +10 -5
  63. package/dist/modules/functions/space.js +37 -15
  64. package/dist/modules/images/imageProxy.js +19 -1
  65. package/dist/modules/rsc/connectorRscData.d.ts +3 -1
  66. package/dist/modules/rsc/connectorRscData.js +9 -5
  67. package/dist/modules/rsc/handler.d.ts +3 -16
  68. package/dist/modules/rsc/handler.js +10 -4
  69. package/dist/modules/rsc/publicFileResolver.d.ts +15 -9
  70. package/dist/modules/rsc/publicFileResolver.js +61 -23
  71. package/dist/modules/rsc/resolveRscData.d.ts +3 -1
  72. package/dist/modules/rsc/resolveRscData.js +8 -5
  73. package/dist/modules/runtime/bundle.d.ts +5 -0
  74. package/dist/modules/runtime/bundle.js +20 -5
  75. package/dist/modules/sqlite/kv.d.ts +34 -0
  76. package/dist/modules/sqlite/kv.js +99 -0
  77. package/dist/modules/sqlite/kv.test.d.ts +1 -0
  78. package/dist/modules/ssr/prepareRender.js +45 -6
  79. package/dist/modules/ssr/spaceDocument.d.ts +25 -0
  80. package/dist/modules/ssr/spaceDocument.js +72 -0
  81. package/dist/modules/ssr/spaceDocument.test.d.ts +1 -0
  82. package/dist/modules/ssr/testing/offlineData.d.ts +5 -0
  83. package/dist/modules/ssr/views/template.ejs +122 -20
  84. package/dist/plugins/compile.js +6 -21
  85. package/dist/plugins/compile.test.d.ts +1 -0
  86. package/dist/plugins/copy.d.ts +5 -0
  87. package/dist/plugins/copy.js +16 -1
  88. package/dist/plugins/copy.test.d.ts +1 -0
  89. package/dist/plugins/manager.d.ts +13 -0
  90. package/dist/plugins/manager.js +41 -12
  91. package/dist/plugins/watch.d.ts +12 -0
  92. package/dist/plugins/watch.js +79 -0
  93. package/dist/runtime.d.ts +1 -1
  94. package/dist/runtime.js +2 -2
  95. package/dist/sqlite.d.ts +17 -0
  96. package/dist/sqlite.js +2 -0
  97. package/package.json +8 -3
  98. package/skills/plitzi-authoring/CHEATSHEET.md +9 -5
  99. package/skills/plitzi-authoring/SKILL.md +24 -20
  100. package/skills/plitzi-authoring/recipes/accordion.ts +58 -0
  101. package/skills/plitzi-authoring/recipes/link-to-a-section.ts +1 -1
  102. package/skills/plitzi-authoring/recipes/plugin.ts +1 -1
  103. package/skills/plitzi-authoring/recipes/server-data.ts +65 -0
  104. package/skills/plitzi-authoring/recipes/show-data.ts +3 -2
  105. package/skills/plitzi-authoring/recipes/style-a-page.ts +1 -1
  106. package/skills/plitzi-authoring/recipes/typed-data.ts +1 -1
  107. package/skills/plitzi-authoring/reference/accessibility.md +6 -2
  108. package/skills/plitzi-authoring/reference/authoring-errors.md +16 -5
  109. package/skills/plitzi-authoring/reference/colours-and-motion.md +8 -2
  110. package/skills/plitzi-authoring/reference/data-and-visibility.md +38 -26
  111. package/skills/plitzi-authoring/reference/drawing.md +24 -0
  112. package/skills/plitzi-authoring/reference/efficiency.md +27 -1
  113. package/skills/plitzi-authoring/reference/elements-and-styles.md +5 -9
  114. package/skills/plitzi-authoring/reference/flows.md +3 -0
  115. package/skills/plitzi-authoring/reference/layouts.md +8 -23
  116. package/skills/plitzi-authoring/reference/lists.md +1 -1
  117. package/skills/plitzi-authoring/reference/performance.md +2 -2
  118. package/skills/plitzi-authoring/reference/plugins.md +51 -38
  119. package/skills/plitzi-authoring/reference/review-checklist.md +16 -2
  120. package/skills/plitzi-authoring/reference/snippets-and-export.md +2 -2
  121. package/skills/plitzi-authoring/reference/structure.md +32 -1
  122. package/skills/plitzi-authoring/reference/templates.md +6 -3
  123. package/skills/plitzi-authoring/reference/testing.md +10 -3
  124. package/skills/plitzi-authoring/reference/typed-sources.md +3 -1
  125. package/skills/plitzi-authoring/reference/validation.md +1 -1
@@ -6,7 +6,7 @@ Plitzi's templates are Twig, run by Plitzi's own interpreter. What a `{{ … }}`
6
6
 
7
7
  | Written in | What is evaluated | What it can read |
8
8
  | --- | --- | --- |
9
- | a binding's `twigTemplate` transformer | the whole template: conditions, filters, `{% set %}`, loops, tests | `source` (the bound value), `sourceTo`, the globals, the variables by bare name, and every source around the element |
9
+ | a binding's `twigTemplate` transformer | the whole template: conditions, filters, `{% set %}`, loops, tests | `source` (the bound value — undefined until it has one: `{{ source|default('…') }}`), `sourceTo` (the attribute's value before it), the globals, the variables by bare name, and every source around the element |
10
10
  | a flow step's params | the whole template | the trigger's payload and earlier steps by name, the globals, sources around the element |
11
11
  | an ATTRIBUTE (`href`, `src`, `content`…) | only `{{ name }}` tokens (a filter after the name is allowed) | the globals, the variables and the page's route params by bare name (`{{ apiUrl }}`, `{{ slug }}`), and every source around the element (`{{ list_games.item.slug }}`) |
12
12
 
@@ -26,7 +26,7 @@ characters. Only what you authored is interpolated.
26
26
 
27
27
  A binding's template renders TEXT by default. For an attribute that holds a list, a number or a flag — a list's
28
28
  `items` above all — hand over the VALUE with `returns: 'value'` (`returnMode: 'value'` on the transformer). The
29
- template must be a single `{{ expression }}`:
29
+ template must be a single `{{ expression }}`, after any `{% set %}` that name its parts:
30
30
 
31
31
  ```ts
32
32
  list({ id: 'shown', source: 'controlled',
@@ -63,7 +63,8 @@ outside the element that publishes it — each with the name it should have been
63
63
  `rows|sort((a, b) => b.score - a.score)`, `rows|filter(r => r.score >= min)`, `rows|map(r => r.name)`.
64
64
  - Tests: `is defined`, `is empty`, `is null`, `is iterable`, `is even`, `is odd`, `is same as(x)` (strict: `false` is
65
65
  not `'false'`, `0` or an unset value), `is divisible by(n)`, and their `is not` forms. `null` and `none` are literals.
66
- - Functions: `range`, `min`, `max`, `cycle`.
66
+ - Functions: `range`, `min`, `max`, `cycle`. `abs` is a filter (`x|abs`); floor and ceil are `x|round(0, 'floor')` and
67
+ `x|round(0, 'ceil')`; a clamp is `min(max(x, low), high)`.
67
68
  - **Not supported**: `matches` (no regular expressions are evaluated — use `starts with`, `ends with`, `in`), macros,
68
69
  `include`/`extends`, and any filter or function not listed here. `authorSpace` refuses them, and anything else the
69
70
  interpreter would read past, rather than letting a template render a value nobody wrote.
@@ -99,6 +100,8 @@ A lookup across two sources — a row joined to the stats around it:
99
100
  string stays a string however it looks — a password typed `1234` arrives as `"1234"`. Nothing is guessed from the
100
101
  text: to convert, declare the type where the value lands (`setState`'s `type`, the action's input field). Text around
101
102
  the tokens is text, unless it makes a JSON object or array — then it is that document (see `json_encode` above).
103
+ **One exception: a param that is only a JSON filter (`{{ rows|json_encode }}`) is the value it encodes** — the list,
104
+ not its text — so an action input receiving it is declared `json`; a `text` field refuses it (422).
102
105
 
103
106
  ## Dates
104
107
 
@@ -3,13 +3,20 @@
3
3
  ## One call: `inspectPage`
4
4
 
5
5
  ```ts
6
- import { authorSpace, inspectPage } from '@plitzi/sdk-authoring';
6
+ import { answerAction, authorSpace, inspectPage, openPage } from '@plitzi/sdk-authoring';
7
7
 
8
8
  const { handles } = authorSpace(space);
9
- await page.goto('/');
9
+ await openPage(page, '/');
10
10
  expect((await inspectPage(page, handles)).problems).toEqual([]);
11
11
  ```
12
12
 
13
+ `openPage` waits for the page to settle — loaded, and nothing asked for in half a second — counting no stream that
14
+ stays open: Playwright's `networkidle` never comes on a page with a realtime `channel`.
15
+
16
+ A test that would SAVE something answers that action itself, before opening the page, so it never writes the server's
17
+ `kv` the next test (or the developer) reads: `await answerAction(page, 'wall', { windows: [] })` — or a function of the
18
+ input. Every other call goes through.
19
+
13
20
  It checks the open page and returns EVERY problem at once, one sentence each, naming the element and the reason:
14
21
 
15
22
  - every element the page owes is present and visible — its own and those of the layouts around it
@@ -87,7 +94,7 @@ One code on one element; it comes back in `warnings` with the reason, and an ent
87
94
 
88
95
  ## What to check
89
96
 
90
- - **Every viewport and both themes.** Desktop, tablet (48–64rem) and mobile (below 48rem); `colorScheme: 'dark'` as well
97
+ - **Every viewport and both themes.** Desktop, tablet (48–64rem) and mobile (up to 48rem); `colorScheme: 'dark'` as well
91
98
  as light.
92
99
  - **No horizontal scroll on a phone.** A column child grows to its content unless its parent stretches it; a code
93
100
  block or a wide table is what finds out.
@@ -1,7 +1,7 @@
1
1
  # Data typed by a sample
2
2
 
3
3
  `source('site', home)` names a provider's source from a sample of its answer — the JSON file it reads, imported
4
- (`import home from '../../public/data/home.json' with { type: 'json' }`). Every path is then completed by the editor
4
+ (`import home from '../data/home.json' with { type: 'json' }` — `src/data/`, or `public/data/` with no server). Every path is then completed by the editor
5
5
  and checked: `site.data.hero.titel` is a type error, and refused `source-field-unknown` if it gets past the types.
6
6
 
7
7
  ```ts
@@ -18,3 +18,5 @@ apiContainer({ id: site.id, query: '/data/home.json', children: [
18
18
  type-checked lint refuses an object in one).
19
19
  - A list fed by a path hands its `row` the item typed: every field any item of the sample has.
20
20
  - An item of a list is read by position: `site.data.sections[1]`.
21
+ - A provider fed by a server action publishes the action's output at its root: `actionSource('feed', sample)` types
22
+ it — `feed.stories`, and `feed.data` is a type error — with a sample of what the action's last step answers.
@@ -33,7 +33,7 @@ bar.
33
33
  ```ts
34
34
  import { authorSpace } from '@plitzi/sdk-authoring';
35
35
 
36
- import { space } from './src/space.ts';
36
+ import { space } from './src/space/index.ts';
37
37
 
38
38
  try {
39
39
  const { schema, warnings, suggestions } = authorSpace(space, { plugins: [] /* your declarations */ });