@plitzi/sdk-server 0.38.23 → 0.39.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (233) hide show
  1. package/CHANGELOG.md +172 -1
  2. package/README.md +55 -9
  3. package/dist/actions.d.ts +4 -1
  4. package/dist/actions.js +3 -2
  5. package/dist/auth.d.ts +2 -2
  6. package/dist/auth.js +5 -4
  7. package/dist/core/auth/api/accounts.d.ts +11 -0
  8. package/dist/core/auth/api/accounts.js +175 -0
  9. package/dist/core/auth/api/admin.d.ts +41 -0
  10. package/dist/core/auth/api/admin.js +146 -0
  11. package/dist/core/auth/api/context.d.ts +119 -0
  12. package/dist/core/auth/api/context.js +262 -0
  13. package/dist/core/auth/api/factors.d.ts +31 -0
  14. package/dist/core/auth/api/factors.js +209 -0
  15. package/dist/core/auth/api/index.d.ts +94 -0
  16. package/dist/core/auth/api/index.js +43 -0
  17. package/dist/core/auth/api/profile.d.ts +43 -0
  18. package/dist/core/auth/api/profile.js +243 -0
  19. package/dist/core/auth/api/session.d.ts +62 -0
  20. package/dist/core/auth/api/session.js +312 -0
  21. package/dist/core/auth/{api.d.ts → api/types.d.ts} +41 -195
  22. package/dist/core/auth/api/values.d.ts +67 -0
  23. package/dist/core/auth/api/values.js +90 -0
  24. package/dist/core/auth/createAuth.d.ts +49 -39
  25. package/dist/core/auth/createAuth.js +21 -1
  26. package/dist/core/auth/oauth/client.d.ts +2 -2
  27. package/dist/core/auth/oauth/client.js +6 -1
  28. package/dist/core/auth/oauth/index.d.ts +30 -7
  29. package/dist/core/auth/oauth/index.js +33 -14
  30. package/dist/core/auth/oauth/providers/github.js +1 -1
  31. package/dist/core/auth/oauth/providers/google.js +1 -1
  32. package/dist/core/auth/oauth/providers/oidc.d.ts +40 -0
  33. package/dist/core/auth/oauth/providers/oidc.js +197 -0
  34. package/dist/core/auth/oauth/state.d.ts +2 -0
  35. package/dist/core/auth/oauth/state.js +2 -0
  36. package/dist/core/auth/oauth/types.d.ts +21 -3
  37. package/dist/core/auth/oauth/types.js +4 -1
  38. package/dist/core/auth/routes.js +1 -1
  39. package/dist/core/auth/tokens.d.ts +3 -1
  40. package/dist/core/auth/tokens.js +2 -1
  41. package/dist/core/configSeam.d.ts +0 -4
  42. package/dist/core/configSeam.js +12 -1
  43. package/dist/core/createServer.js +16 -4
  44. package/dist/core/freePort.d.ts +10 -0
  45. package/dist/core/freePort.js +39 -1
  46. package/dist/core/handlers/socialRouteHandlers.d.ts +9 -1
  47. package/dist/core/handlers/socialRouteHandlers.js +46 -12
  48. package/dist/core/health.d.ts +1 -0
  49. package/dist/core/health.js +2 -1
  50. package/dist/core/http/stages/authRoutes.d.ts +6 -0
  51. package/dist/core/http/stages/authRoutes.js +42 -1
  52. package/dist/core/http/stages/images.js +5 -3
  53. package/dist/core/http/stages/livePages.js +1 -1
  54. package/dist/core/server/fleet/relay.js +9 -1
  55. package/dist/core/server/fleet/stores.d.ts +7 -0
  56. package/dist/core/server/fleet/stores.js +15 -2
  57. package/dist/core/server/pageServer.js +5 -1
  58. package/dist/core/services/realtime.js +4 -2
  59. package/dist/core/services/registry.js +7 -1
  60. package/dist/core/services/robotsTxt.d.ts +16 -0
  61. package/dist/core/services/robotsTxt.js +50 -0
  62. package/dist/core/services/servedSpace.d.ts +8 -0
  63. package/dist/core/services/servedSpace.js +16 -0
  64. package/dist/core/services/sitemapXml.d.ts +7 -0
  65. package/dist/core/services/sitemapXml.js +37 -0
  66. package/dist/functions-api.d.ts +75 -2
  67. package/dist/helpers/fileStore.d.ts +60 -0
  68. package/dist/helpers/fileStore.js +127 -0
  69. package/dist/helpers/outboundGuard.d.ts +32 -3
  70. package/dist/helpers/outboundGuard.js +50 -5
  71. package/dist/hosts/project/agentRuns.d.ts +24 -0
  72. package/dist/hosts/project/agentRuns.js +107 -0
  73. package/dist/hosts/project/laterAsks.d.ts +41 -0
  74. package/dist/hosts/project/laterAsks.js +117 -0
  75. package/dist/hosts/project/plugins.js +11 -4
  76. package/dist/hosts/project/serveProject.d.ts +11 -3
  77. package/dist/hosts/project/serveProject.js +94 -36
  78. package/dist/hosts/project/spaceFailure.d.ts +4 -0
  79. package/dist/hosts/project/spaceFailure.js +10 -0
  80. package/dist/hosts/project/watchSpace.d.ts +5 -5
  81. package/dist/hosts/project/watchSpace.js +15 -6
  82. package/dist/index.js +2 -2
  83. package/dist/kernel.js +1 -1
  84. package/dist/modules/actions/connectorWrite.js +3 -1
  85. package/dist/modules/actions/index.js +1 -1
  86. package/dist/modules/actions/jobs/fileQueue.d.ts +34 -0
  87. package/dist/modules/actions/jobs/fileQueue.js +72 -0
  88. package/dist/modules/actions/jobs/index.js +3 -3
  89. package/dist/modules/actions/jobs/memoryQueue.js +6 -215
  90. package/dist/modules/actions/jobs/queueDocument.d.ts +14 -0
  91. package/dist/modules/actions/jobs/queueDocument.js +22 -0
  92. package/dist/modules/actions/jobs/queueRules.d.ts +39 -0
  93. package/dist/modules/actions/jobs/queueRules.js +270 -0
  94. package/dist/modules/actions/moduleFor.js +2 -0
  95. package/dist/modules/actions/runtime/fileKv.d.ts +3 -1
  96. package/dist/modules/actions/runtime/fileKv.js +12 -98
  97. package/dist/modules/actions/runtime/guards.d.ts +19 -1
  98. package/dist/modules/actions/runtime/guards.js +10 -1
  99. package/dist/modules/actions/runtime/kvChange.d.ts +40 -0
  100. package/dist/modules/actions/runtime/kvChange.js +23 -1
  101. package/dist/modules/actions/runtime/kvList.d.ts +4 -0
  102. package/dist/modules/actions/runtime/kvList.js +5 -1
  103. package/dist/modules/actions/runtime/kvStore.js +15 -1
  104. package/dist/modules/actions/runtime/namespaceKv.js +2 -0
  105. package/dist/modules/actions/runtime/renderResolver.js +31 -5
  106. package/dist/modules/actions/runtime/runAction.js +16 -6
  107. package/dist/modules/actions/runtime/scope.js +11 -0
  108. package/dist/modules/actions/runtime/taskContext.js +11 -32
  109. package/dist/modules/actions/tasks/auth.js +2 -0
  110. package/dist/modules/actions/tasks/connector.js +6 -2
  111. package/dist/modules/actions/tasks/flow.js +5 -0
  112. package/dist/modules/actions/tasks/http.js +2 -1
  113. package/dist/modules/actions/tasks/kv.js +5 -0
  114. package/dist/modules/actions/tasks/list.js +11 -2
  115. package/dist/modules/actions/tasks/transform.js +2 -0
  116. package/dist/modules/actions/transport/callHandler.js +25 -4
  117. package/dist/modules/actions/types.d.ts +46 -1
  118. package/dist/modules/connectors/engine.d.ts +7 -2
  119. package/dist/modules/connectors/engine.js +4 -4
  120. package/dist/modules/connectors/resolver.d.ts +2 -1
  121. package/dist/modules/connectors/resolver.js +3 -2
  122. package/dist/modules/functions/build.d.ts +7 -2
  123. package/dist/modules/functions/build.js +90 -6
  124. package/dist/modules/functions/capabilities.js +21 -0
  125. package/dist/modules/functions/context.js +6 -2
  126. package/dist/modules/functions/contract.d.ts +45 -1
  127. package/dist/modules/functions/driver.d.ts +2 -1
  128. package/dist/modules/functions/driver.js +39 -0
  129. package/dist/modules/functions/load.d.ts +1 -1
  130. package/dist/modules/functions/load.js +2 -2
  131. package/dist/modules/functions/manifest.js +7 -1
  132. package/dist/modules/functions/oauth.d.ts +3 -1
  133. package/dist/modules/functions/oauth.js +20 -7
  134. package/dist/modules/functions/protocol.d.ts +9 -0
  135. package/dist/modules/functions/sandbox/guest/bytes.d.ts +27 -0
  136. package/dist/modules/functions/sandbox/guest/bytes.js +108 -0
  137. package/dist/modules/functions/sandbox/guest/crypto.d.ts +47 -0
  138. package/dist/modules/functions/sandbox/guest/crypto.js +144 -0
  139. package/dist/modules/functions/sandbox/guest/events.d.ts +152 -0
  140. package/dist/modules/functions/sandbox/guest/events.js +143 -0
  141. package/dist/modules/functions/sandbox/guest/fetch.d.ts +305 -0
  142. package/dist/modules/functions/sandbox/guest/fetch.js +237 -0
  143. package/dist/modules/functions/sandbox/guest/index.d.ts +28 -0
  144. package/dist/modules/functions/sandbox/guest/index.js +130 -0
  145. package/dist/modules/functions/sandbox/{guest.d.ts → guest/types.d.ts} +5 -12
  146. package/dist/modules/functions/sandbox/isolate.js +20 -6
  147. package/dist/modules/functions/space.js +2 -8
  148. package/dist/modules/images/imageProxy.d.ts +3 -2
  149. package/dist/modules/images/imageProxy.js +2 -2
  150. package/dist/modules/mongo/jobQueue.js +0 -19
  151. package/dist/modules/mysql/accounts.js +12 -5
  152. package/dist/modules/mysql/jobs/index.d.ts +1 -1
  153. package/dist/modules/mysql/jobs/schema.d.ts +0 -6
  154. package/dist/modules/mysql/jobs/schema.js +2 -46
  155. package/dist/modules/mysql/schema.js +26 -1
  156. package/dist/modules/mysql/sessions.js +2 -1
  157. package/dist/modules/realtime/handlers.d.ts +9 -4
  158. package/dist/modules/realtime/handlers.js +20 -3
  159. package/dist/modules/realtime/hub.d.ts +4 -2
  160. package/dist/modules/realtime/hub.js +36 -4
  161. package/dist/modules/realtime/index.d.ts +14 -0
  162. package/dist/modules/realtime/index.js +14 -1
  163. package/dist/modules/realtime/presence.d.ts +33 -0
  164. package/dist/modules/realtime/presence.js +56 -0
  165. package/dist/modules/realtime/socket.d.ts +3 -1
  166. package/dist/modules/realtime/socket.js +2 -2
  167. package/dist/modules/rsc/connectorRscData.d.ts +6 -1
  168. package/dist/modules/rsc/connectorRscData.js +27 -6
  169. package/dist/modules/rsc/externalQueryReader.d.ts +28 -0
  170. package/dist/modules/rsc/externalQueryReader.js +43 -0
  171. package/dist/modules/rsc/handler.js +1 -1
  172. package/dist/modules/rsc/resolveRscData.d.ts +11 -1
  173. package/dist/modules/rsc/resolveRscData.js +86 -16
  174. package/dist/modules/runtime/inside.js +1 -1
  175. package/dist/modules/runtime/runner.js +2 -1
  176. package/dist/modules/sqlite/jobQueue.d.ts +35 -0
  177. package/dist/modules/sqlite/jobQueue.js +56 -0
  178. package/dist/modules/sqlite/kv.d.ts +1 -1
  179. package/dist/modules/sqlite/kv.js +2 -10
  180. package/dist/modules/sqlite/open.d.ts +3 -0
  181. package/dist/modules/sqlite/open.js +13 -0
  182. package/dist/modules/ssr/Component.d.ts +5 -1
  183. package/dist/modules/ssr/Component.js +3 -1
  184. package/dist/modules/ssr/applySSRResult.d.ts +8 -1
  185. package/dist/modules/ssr/applySSRResult.js +23 -3
  186. package/dist/modules/ssr/handler.js +30 -5
  187. package/dist/modules/ssr/prepareRender.js +27 -5
  188. package/dist/modules/ssr/preview.d.ts +2 -0
  189. package/dist/modules/ssr/preview.js +6 -3
  190. package/dist/modules/ssr/registerExternalPlugins.d.ts +2 -6
  191. package/dist/modules/ssr/registerExternalPlugins.js +2 -2
  192. package/dist/modules/ssr/resolvePageSeo.d.ts +11 -0
  193. package/dist/modules/ssr/resolvePageSeo.js +13 -2
  194. package/dist/modules/ssr/streamBody.js +2 -2
  195. package/dist/modules/ssr/views/template.ejs +21 -17
  196. package/dist/mysql.d.ts +1 -1
  197. package/dist/mysql.js +2 -2
  198. package/dist/plugins/manager.d.ts +5 -0
  199. package/dist/plugins/manager.js +9 -0
  200. package/dist/sqlite.d.ts +8 -1
  201. package/dist/sqlite.js +3 -1
  202. package/package.json +5 -5
  203. package/skills/plitzi-authoring/CHEATSHEET.md +6 -6
  204. package/skills/plitzi-authoring/SKILL.md +4 -2
  205. package/skills/plitzi-authoring/recipes/accordion.ts +2 -1
  206. package/skills/plitzi-authoring/recipes/carousel.ts +24 -3
  207. package/skills/plitzi-authoring/recipes/detail-page.ts +0 -1
  208. package/skills/plitzi-authoring/recipes/embed-and-svg.ts +3 -1
  209. package/skills/plitzi-authoring/recipes/filter-a-list.ts +0 -1
  210. package/skills/plitzi-authoring/recipes/show-data.ts +0 -1
  211. package/skills/plitzi-authoring/recipes/typed-data.ts +0 -1
  212. package/skills/plitzi-authoring/reference/accessibility.md +7 -2
  213. package/skills/plitzi-authoring/reference/auth.md +15 -4
  214. package/skills/plitzi-authoring/reference/authoring-errors.md +51 -10
  215. package/skills/plitzi-authoring/reference/colours-and-motion.md +7 -1
  216. package/skills/plitzi-authoring/reference/components.md +4 -1
  217. package/skills/plitzi-authoring/reference/data-and-visibility.md +31 -22
  218. package/skills/plitzi-authoring/reference/efficiency.md +2 -1
  219. package/skills/plitzi-authoring/reference/elements-and-styles.md +16 -15
  220. package/skills/plitzi-authoring/reference/flows.md +20 -8
  221. package/skills/plitzi-authoring/reference/kept-state.md +8 -0
  222. package/skills/plitzi-authoring/reference/layouts.md +18 -2
  223. package/skills/plitzi-authoring/reference/lists.md +20 -4
  224. package/skills/plitzi-authoring/reference/plugin-reach.md +12 -0
  225. package/skills/plitzi-authoring/reference/plugins.md +13 -2
  226. package/skills/plitzi-authoring/reference/realtime.md +8 -5
  227. package/skills/plitzi-authoring/reference/structure.md +17 -1
  228. package/skills/plitzi-authoring/reference/templates.md +11 -3
  229. package/skills/plitzi-authoring/reference/testing.md +82 -5
  230. package/skills/plitzi-authoring/reference/typed-sources.md +6 -0
  231. package/skills/plitzi-authoring/reference/validation.md +1 -1
  232. package/dist/core/auth/api.js +0 -1323
  233. package/dist/modules/functions/sandbox/guest.js +0 -662
@@ -1,22 +1,25 @@
1
1
  <!doctype html>
2
- <html lang="en"<% if (locals.themeClass) { %> class="<%= locals.themeClass %>"<% } %>>
2
+ <html lang="<%= (locals.head && locals.head.lang) || 'en' %>"<% if (locals.themeClass) { %> class="<%= locals.themeClass %>"<% } %>>
3
3
  <head>
4
4
  <meta charset="utf-8" />
5
5
  <title><%= locals.title || '' %></title>
6
- <% if (locals.description) { %>
7
- <meta name="description" content="<%= locals.description %>" />
8
- <% } %>
9
- <meta property="og:type" content="website" />
10
- <% if (locals.title) { %>
11
- <meta property="og:title" content="<%= locals.title %>" />
12
- <meta name="twitter:title" content="<%= locals.title %>" />
13
- <% } %>
14
- <% if (locals.description) { %>
15
- <meta property="og:description" content="<%= locals.description %>" />
16
- <meta name="twitter:description" content="<%= locals.description %>" />
17
- <% } %>
6
+ <%
7
+ /*
8
+ What a link preview, a search engine and the browser read of the page, as `pageHeadTags` (@plitzi/sdk-shared)
9
+ decides it — the page's description, robots, Open Graph and card with its picture, its canonical address, the
10
+ space's icon and colour. The page keeps them as it moves (`PageHead`) from the same definition.
11
+ */
12
+ %>
13
+ <% ((locals.head && locals.head.meta) || []).forEach(function (tag) { %>
14
+ <meta <%= tag.attribute %>="<%= tag.key %>" content="<%= tag.content %>"<% if (tag.media) { %> media="<%= tag.media %>"<% } %> />
15
+ <% }) %>
16
+ <% (locals.structuredData || []).forEach(function (json) { %>
17
+ <script type="application/ld+json"><%- json %></script>
18
+ <% }) %>
18
19
  <meta name="viewport" content="width=device-width, initial-scale=1" />
19
- <link rel="shortcut icon" href="https://cdn.plitzi.com/resources/img/favicon.svg" />
20
+ <% ((locals.head && locals.head.links) || []).forEach(function (link) { %>
21
+ <link rel="<%= link.rel %>" href="<%= link.href %>"<% if (link.type) { %> type="<%= link.type %>"<% } %> />
22
+ <% }) %>
20
23
 
21
24
  <%
22
25
  /*
@@ -34,10 +37,11 @@
34
37
 
35
38
  <%
36
39
  /*
37
- The one origin the document reaches for whatever the space declares: the favicon's. Named here so the space's
38
- own fonts can skip it rather than ask for it twice. A font host is preconnected only when the space uses one.
40
+ Plitzi's icon's origin, reached when the space names no icon of its own. Named here so the space's own fonts
41
+ can skip it rather than ask for it twice. A font host is preconnected only when the space uses one.
39
42
  */
40
- const staticOrigins = ['https://cdn.plitzi.com'];
43
+ const icon = ((locals.head && locals.head.links) || []).find(function (link) { return link.rel === 'icon'; });
44
+ const staticOrigins = icon && icon.href.indexOf('https://cdn.plitzi.com/') === 0 ? ['https://cdn.plitzi.com'] : [];
41
45
  %>
42
46
  <% for (const origin of staticOrigins) { %>
43
47
  <link rel="preconnect" href="<%= origin %>" crossorigin />
package/dist/mysql.d.ts CHANGED
@@ -31,7 +31,7 @@ export { createMysqlStore, mysqlSchemaStatements } from './modules/mysql';
31
31
  * createServer({ action: { lookups, kv: createMysqlKv({ pool }), jobs: { queue: createMysqlJobQueue({ pool }) } } });
32
32
  * ```
33
33
  */
34
- export { createMysqlJobQueue, createMysqlKv, mysqlJobSchemaStatements, mysqlJobSchemaUpgrades } from './modules/mysql/jobs';
34
+ export { createMysqlJobQueue, createMysqlKv, mysqlJobSchemaStatements } from './modules/mysql/jobs';
35
35
  export type { MysqlJobQueue, MysqlJobQueueOptions, MysqlKvOptions } from './modules/mysql/jobs';
36
36
  export { SCHEMA_VERSION, TABLE_NAMES, tableNames } from './modules/mysql';
37
37
  export type { AccountSeed, MysqlAdmin, MysqlConfig, IdentityStore, LinkedIdentity, MysqlStore, SessionStore, SessionSummary, SpaceTokenSeed, TableKey, Tables } from './modules/mysql';
package/dist/mysql.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { TABLE_NAMES, tableNames } from "./modules/mysql/config.js";
2
2
  import { SCHEMA_VERSION } from "./modules/mysql/schema.js";
3
3
  import { createMysqlStore, mysqlSchemaStatements } from "./modules/mysql/index.js";
4
- import { mysqlJobSchemaStatements, mysqlJobSchemaUpgrades } from "./modules/mysql/jobs/schema.js";
4
+ import { mysqlJobSchemaStatements } from "./modules/mysql/jobs/schema.js";
5
5
  import { createMysqlJobQueue } from "./modules/mysql/jobs/jobQueue.js";
6
6
  import { createMysqlKv } from "./modules/mysql/jobs/kv.js";
7
- export { SCHEMA_VERSION, TABLE_NAMES, createMysqlJobQueue, createMysqlKv, createMysqlStore, mysqlJobSchemaStatements, mysqlJobSchemaUpgrades, mysqlSchemaStatements, tableNames };
7
+ export { SCHEMA_VERSION, TABLE_NAMES, createMysqlJobQueue, createMysqlKv, createMysqlStore, mysqlJobSchemaStatements, mysqlSchemaStatements, tableNames };
@@ -27,6 +27,11 @@ export declare class PluginManager {
27
27
  rebuild(name: string): Promise<PluginEntry | null>;
28
28
  private remember;
29
29
  hasPlugin(name: string): boolean;
30
+ /**
31
+ * A plugin no longer there — its folder removed under a dev server: never built again, nothing of it remembered. A run's
32
+ * preview logged "build failed … Could not resolve" for a plugin a task had deleted, build after build.
33
+ */
34
+ unregister(name: string): void;
30
35
  register(name: string, source: PluginSource): void;
31
36
  /**
32
37
  * Keeps a source a render names, and returns the key to pass to getEntries(): `name@version+<identity>`, or
@@ -97,6 +97,15 @@ var PluginManager = class {
97
97
  hasPlugin(name) {
98
98
  return this.resolveKey(name) !== null;
99
99
  }
100
+ /**
101
+ * A plugin no longer there — its folder removed under a dev server: never built again, nothing of it remembered. A run's
102
+ * preview logged "build failed … Could not resolve" for a plugin a task had deleted, build after build.
103
+ */
104
+ unregister(name) {
105
+ const base = name.replace(/@[^@]*$/, "");
106
+ for (const key of Object.keys(this.plugins).filter((each) => each.replace(/@[^@]*$/, "") === base)) Reflect.deleteProperty(this.plugins, key);
107
+ this.forget(base);
108
+ }
100
109
  register(name, source) {
101
110
  this.plugins[name] = source;
102
111
  this.mem.delete(name);
package/dist/sqlite.d.ts CHANGED
@@ -1,4 +1,5 @@
1
- /** A key/value store in a SQLite file, for a deployment with no database. Import it as `@plitzi/sdk-server/sqlite`.
1
+ /** A key/value store and a job queue in a SQLite file, for a deployment with no database. Import it as
2
+ * `@plitzi/sdk-server/sqlite`.
2
3
  *
3
4
  * What server actions keep in `kv` — saved layouts, counters, the single-flight keys a run guard takes — lives in one
4
5
  * process's memory by default, and goes with it. `createFileKv` (`@plitzi/sdk-server/actions`) keeps it in a JSON
@@ -11,7 +12,13 @@
11
12
  * createServer({ adapters, action: { lookups, kv: createSqliteKv({ file: 'data/kv.sqlite' }) } });
12
13
  * ```
13
14
  *
15
+ * The job queue — what `ctx.later`, a schedule's fires and a function's jobs wait in — the same way:
16
+ * `jobs: { queue: createSqliteJobQueue({ db }) }`, beside `createFileJobQueue` (one process, a JSON file) and a
17
+ * database's own (`JobQueue`).
18
+ *
14
19
  * Its own entry because it loads `node:sqlite`, which needs Node 22.13 or later and prints an `ExperimentalWarning`
15
20
  * when it loads: a deployment that does not use it never loads it. */
21
+ export { createSqliteJobQueue } from './modules/sqlite/jobQueue';
16
22
  export { createSqliteKv } from './modules/sqlite/kv';
23
+ export type { SqliteJobQueueOptions } from './modules/sqlite/jobQueue';
17
24
  export type { SqliteKvOptions } from './modules/sqlite/kv';
package/dist/sqlite.js CHANGED
@@ -1 +1,3 @@
1
- export { createSqliteKv } from "./modules/sqlite/kv.js";
1
+ import { createSqliteJobQueue } from "./modules/sqlite/jobQueue.js";
2
+ import { createSqliteKv } from "./modules/sqlite/kv.js";
3
+ export { createSqliteJobQueue, createSqliteKv };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@plitzi/sdk-server",
3
- "version": "0.38.23",
3
+ "version": "0.39.0",
4
4
  "license": "AGPL-3.0",
5
5
  "files": [
6
6
  "dist",
@@ -108,19 +108,19 @@
108
108
  },
109
109
  "type": "module",
110
110
  "engines": {
111
- "node": ">=22.18"
111
+ "node": "^24.22.1 || >=26.12.1"
112
112
  },
113
113
  "sideEffects": [
114
114
  "./dist/env.js"
115
115
  ],
116
116
  "dependencies": {
117
- "@plitzi/plitzi-sdk": "0.38.23",
118
- "@plitzi/sdk-shared": "0.38.23",
117
+ "@plitzi/plitzi-sdk": "0.39.0",
118
+ "@plitzi/sdk-shared": "0.39.0",
119
119
  "ejs": "^7.0.2",
120
120
  "esbuild": "^0.28.2",
121
121
  "jsonwebtoken": "^9.0.3",
122
122
  "nodemailer": "^10.1.3",
123
- "undici": "^8.12.2",
123
+ "undici": "^8.12.3",
124
124
  "ws": "^8.22.0"
125
125
  },
126
126
  "peerDependencies": {
@@ -1,8 +1,8 @@
1
1
  # Plitzi authoring — cheatsheet
2
2
 
3
3
  What most changes need, on one page. Everything is imported from `@plitzi/sdk-authoring`. For the rest, ask by name —
4
- `npx @plitzi/cli explain navigate` (an element, a step, a trigger, a problem's code), `--list steps` for every one of a
5
- kind — rather than reading its `.d.ts`.
4
+ `npx @plitzi/cli explain navigate` (an element, step, server step, trigger, code, filter), `--list steps` for every one
5
+ of a kind — rather than reading its `.d.ts`.
6
6
 
7
7
  ## The space
8
8
 
@@ -49,10 +49,10 @@ carousel({ id: 'hero', items: 'p.data.slides', autoplay: 5000, row: 'slide-card'
49
49
  // rows follow their item's `id`, or `itemKey: 'slug'`
50
50
  apiContainer({ id: 'p', query: '/data/x.json', cache: true, children }) // publishes p.data; no box of its own
51
51
  apiContainer({ id: 'p', query: '/data/x.json', runtime: 'server', children }) // read by the page server: still p.data
52
- apiContainer({ id: 'p', action: 'report', runtime: 'server', children }) // the action's output at p's root: p.rows
52
+ apiContainer({ id: 'p', action: 'report', runtime: 'server', children }) // its output at p's root: p.rows
53
53
  // loadingSlot: 'p-skeleton' — a child shown until it answers
54
54
  form({ id, managedByInteractions: true, flows, children })
55
- formControl({ name: 'email', label: 'Email', subType: 'email', required: true }) // optional without required; select: options: [{ label, value }]
55
+ formControl({ name: 'email', label: 'Email', subType: 'email', required: true }) // optional without required; select: options: [{ label, value }]; number: min, max
56
56
  modalContainer({ id, visible: false, title, children })
57
57
  component('card', { props: { title }, children: { body: [ … ] } })
58
58
  const seats = defineElement(seatsDeclaration); seats({ id }) // a plugin
@@ -104,8 +104,8 @@ A flow is `[trigger, …steps]`, in an element's `flows`.
104
104
  [onClick(), setState({ key: 'saved', type: 'boolean', value: true })] // types: boolean, number, text, json
105
105
  [named('sent', onSubmit()), setState({ key: 'email', type: 'text', value: '{{ sent.values.email }}' })]
106
106
  [on('onChange'), …]; [on('onMouseEnter'), …]; [onPageLoad(), …]; [onKey('mod+k, escape'), …]
107
- [onInterval(5000), …] // every 5 s, while the tab is in view
108
- [onClick(), scrollBy('cards', { x: '80%' })]; scrollTo('cards', { x: 'end' }); scrollIntoView('answer')
107
+ [onInterval(5000), …] // every 5 s, the tab in view
108
+ [onClick(), scrollBy('cards', { x: '80%' })]; scrollTo('cards', { x: 'end' }); scrollIntoView('answer'); focus('field')
109
109
  [named('row', onScroll()), …] // { x, y, atStart, atEnd } of its own box
110
110
  [onClick(), toggleState({ key: 'menuOpen' })]
111
111
  [onClick(), cycleState({ key: 'slide', length: 3, by: -1 })] // goes round; stepState({ key, by, min, max }) stops
@@ -24,7 +24,8 @@ export const space = {
24
24
  };
25
25
  ```
26
26
 
27
- A space on Plitzi — edited in the builder — is edited through the Plitzi MCP server instead, never both on one space.
27
+ A change to a space on Plitzi itself — the builder's — is the Plitzi MCP server's instead. One taken out as a project
28
+ (`plitzi create --from`) and changed through the MCP meanwhile refuses `space push` until `space pull`.
28
29
 
29
30
  ## How to work
30
31
 
@@ -37,7 +38,8 @@ A space on Plitzi — edited in the builder — is edited through the Plitzi MCP
37
38
  4. **Before saying done:** `npm run lint:space` clean, and the [review checklist](reference/review-checklist.md).
38
39
 
39
40
  What a name means — an element, a step, a trigger, a code, any `@plitzi` export (`pageFamily`, `createServer`): `npx plitzi explain
40
- <name>`, in a few lines. Never read the `.d.ts`.
41
+ <name>`, in a few lines; whether there is a way at all — a field an element publishes, a state — `npx plitzi explain
42
+ --search "<words>"`. Never read the `.d.ts`.
41
43
 
42
44
  ## Five rules authoring cannot check for you
43
45
 
@@ -1,5 +1,6 @@
1
1
  /**
2
- * An accordion — questions whose answers open one at a time — written once and mapped over the questions: the open one
2
+ * An accordion — questions whose answers open one at a time, a disclosure that expands and collapses, as `<details>`
3
+ * would — written once and mapped over the questions: the open one
3
4
  * is a key in `state`, and each question reads it the same way. The button says whether its answer is open
4
5
  * (`ariaExpanded`) and which panel it opens (`controls`, by the panel's id), so a screen reader follows it; the panel is
5
6
  * revealed by the state, so it starts hidden.
@@ -1,7 +1,8 @@
1
1
  /**
2
2
  * Three carousels from one element: slides that change on their own with arrows and dots, a marquee of logos that
3
3
  * never ends, and a row of cards a visitor swipes. The slides, the dots and anything else inside read the carousel's
4
- * source — `carousel_<id>.index`, `.count`, `.item`, `.items` — and the arrows and dots are steps on it.
4
+ * source — `carousel_<id>.index`, `.count`, `.item`, `.items`, and `.atStart`, `.atEnd`, `.shown` for where it stands —
5
+ * and the arrows and dots are steps on it.
5
6
  */
6
7
  import {
7
8
  activeWhen,
@@ -40,6 +41,12 @@ const dots = styles('hero-dots', { display: 'flex', gap: 8, margin: '0px', paddi
40
41
  // Several slides at once: the carousel's class says how wide each is and the gap between them.
41
42
  const cards = styles('picks-row', { '--plitzi-carousel-slide-width': '240px', '--plitzi-carousel-gap': '16px' });
42
43
 
44
+ // An arrow with nowhere to go is hidden and passes the pointer on, as a shop's arrows do at a row's ends.
45
+ const arrow = styles('picks-arrow', {
46
+ css: { transition: 'opacity 0.2s' },
47
+ variants: { spent: { opacity: 0, pointerEvents: 'none' } }
48
+ });
49
+
43
50
  export const recipe: SpaceSpec = {
44
51
  name: 'Carousels',
45
52
  permanentUrl: 'carousels',
@@ -100,7 +107,8 @@ export const recipe: SpaceSpec = {
100
107
  items: ['Acme', 'Globex', 'Initech', 'Umbrella', 'Hooli'],
101
108
  row: r => text({ from: r.item, css: { padding: '0px 24px', fontWeight: 600 } })
102
109
  }),
103
- // A row that swipes on a phone and snaps to each card; the arrows move it a card at a time.
110
+ // A row that swipes on a phone and snaps to each card; the arrows move it a page — as many cards as it shows —
111
+ // and each hides at its end.
104
112
  carousel({
105
113
  id: 'picks',
106
114
  label: 'Picks',
@@ -109,7 +117,20 @@ export const recipe: SpaceSpec = {
109
117
  items: SLIDES,
110
118
  row: r => container({ class: slide, children: [text({ from: `${r.item}.title` })] }),
111
119
  children: [
112
- button({ content: '›', title: 'More picks', flows: [[onClick(), carouselNext('picks')]] }),
120
+ button({
121
+ content: '‹',
122
+ title: 'Earlier picks',
123
+ class: arrow,
124
+ bind: [activeWhen(arrow, '{{ carousel_picks.atStart }}', { variant: 'spent' })],
125
+ flows: [[onClick(), carouselPrevious('picks', 'page')]]
126
+ }),
127
+ button({
128
+ content: '›',
129
+ title: 'More picks',
130
+ class: arrow,
131
+ bind: [activeWhen(arrow, '{{ carousel_picks.atEnd }}', { variant: 'spent' })],
132
+ flows: [[onClick(), carouselNext('picks', 'page')]]
133
+ }),
113
134
  text({ from: 'picks.index', as: '{{ source + 1 }} of {{ carousel_picks.count }}' })
114
135
  ]
115
136
  })
@@ -1,4 +1,3 @@
1
- /* eslint-disable quotes -- templates quote their own strings, and read best in the other quotes */
2
1
  /**
3
2
  * A page per record: a card links to `/products/<slug>`, and the detail page narrows the same file to the product its
4
3
  * address names — with a message, not an empty page, when no product has that name, and status 404: the provider is
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * Something drawn elsewhere — a map, a video player — in an `embed`, and a drawing of your own in an `svg`.
3
3
  *
4
- * An embed says what it shows in `title`, which is what a screen reader announces, and loads lazily. An `svg` takes
4
+ * An embed says what it shows in `title`, which is what a screen reader announces, and loads lazily — and hidden (its
5
+ * `visible`, a player behind its poster) it loads nothing until it is first shown: no `src` binding to the play state
6
+ * is needed. An `svg` takes
5
7
  * the markup alone, checked to be an SVG and with anything that runs taken out; drawn with `currentColor`, it follows
6
8
  * the colour of its class in both themes. Without a `label` it is decoration, hidden from readers; with one it is an
7
9
  * image that says it.
@@ -1,4 +1,3 @@
1
- /* eslint-disable quotes -- templates quote their own strings, and read best in the other quotes */
2
1
  /**
3
2
  * Filter and sort a list: a select writes the chosen category to `state`, and the list is bound through a template
4
3
  * that hands over its VALUE — only the matching rows are rendered, with a count and an empty state over the same rows.
@@ -1,4 +1,3 @@
1
- /* eslint-disable quotes -- templates quote their own strings, and read best in the other quotes */
2
1
  /**
3
2
  * Show data with no backend, in a project with no server: a JSON file the browser fetches (`public/data/products.json`,
4
3
  * public), read by a provider — one card per product, a skeleton while it loads, a count, a computed value, and an
@@ -1,4 +1,3 @@
1
- /* eslint-disable quotes -- templates quote their own strings, and read best in the other quotes */
2
1
  /**
3
2
  * Data typed by a sample of it: `source()` turns the JSON the page reads into names the editor completes and checks —
4
3
  * `site.data.hero.titel` is a type error, not an empty heading. In a project the sample is the file itself:
@@ -19,7 +19,8 @@ button({ content: '', title: 'Close', icon: 'fa-solid fa-xmark' })
19
19
  // Words that do not say what it does — a key hint, a count: `label` is read in their place.
20
20
  button({ content: 'V', label: 'Select (V)', title: 'Select — V', icon: 'fa-solid fa-arrow-pointer' })
21
21
 
22
- // A link around a whole card: without `label` it is announced as every word inside the card.
22
+ // A link around a whole card: without `label` it is announced as every word inside the card — and around an
23
+ // `article`, Playwright reads no name at all (accname takes none from an article): name it, and a test finds it.
23
24
  link({ href: '/posts/field-notes', label: 'Read “Field notes”', children: [ /* cover, topic, title, byline */ ] })
24
25
 
25
26
  // A field whose design says what it is: the label stays, out of sight.
@@ -81,8 +82,12 @@ button({ content: 'Menu', bind: { ariaExpanded: 'state.menuOpen' }, flows: [[onC
81
82
 
82
83
  An "active" variant is for the eyes. `ariaPressed` and `ariaExpanded` are for everyone else. Use both. A button that
83
84
  opens a panel also names it — `controls: 'menu-panel'`, the panel's id (authoring gives the panel the anchor
84
- `aria-controls` needs; [recipes/accordion.ts](../recipes/accordion.ts)). Words that change while somebody is on the page
85
+ `aria-controls` needs; [recipes/accordion.ts](../recipes/accordion.ts)). In a list's row, both are the row's own: each
86
+ row's panel is drawn as `<id>-<row>`, and the row's button points at its own. Words that change while somebody is on the page
85
87
  — a count, a total, a status — sit in `container({ live: 'polite', … })`, so a screen reader says them when they change.
88
+ A part that opens and closes on its own — a question and its answer, many open at once — needs no state at all:
89
+ `container({ subType: 'details', children: [container({ subType: 'summary', children: [text('Question')] }), …] })`
90
+ (`open: true` to start open), the browser's own disclosure, announced as one. The accordion recipe is for one-at-a-time.
86
91
 
87
92
  ## The page has an outline
88
93
 
@@ -48,7 +48,8 @@ form({
48
48
  - What it answers: `ok`; when not, `reason` (`unverified`, `inactive`, `network`, `missing`…) and, for `reason: 'mfa'`,
49
49
  `mfaToken` — the challenge `mode: 'mfa'` completes. Test it on `<step>.ok` with `when`, never `whenSucceeded` /
50
50
  `whenFailed`, which are a server action's ([flows](flows.md)).
51
- - `authLogout()` ends the session; `authRefreshDetails()` reloads who is signed in.
51
+ - `authLogout()` ends the session; `authLogoutEverywhere('site' | 'all')` ends it on every device too — this space's
52
+ sessions, or every one of the account; `authRefreshDetails()` reloads who is signed in.
52
53
 
53
54
  ## Who is signed in
54
55
 
@@ -61,13 +62,23 @@ being found out), `{{ auth.details.username }}` — `details` carries `id`, `use
61
62
  A page's `accessLevel`: `'authenticated'` (signed in), `'public'` (signed OUT only — the sign-in page), or nothing
62
63
  (everybody). A lone `public` page vanishes the moment anyone signs in, so leave it out unless the page has a signed-in
63
64
  twin on the same slug. `unauthorizedRedirect` names where a visitor the page is not for goes — a page's id or slug
64
- (`''` is the home page), or a URL; without it they are answered 403.
65
+ (`''` is the home page), or a URL; without it they are answered 403. A visitor not signed in is sent with the address
66
+ they asked for as `?redirect=`. A `public` sign-in with `unauthorizedRedirect` sends whoever signs in on it there
67
+ itself — back to `?redirect=` when it is on this site, else to its `unauthorizedRedirect` — the moment `authLogin`
68
+ succeeds, so steps after the login race the page leaving: end the flow at the login (`login-then-leaves` says so). A
69
+ sign-in for everybody sends them back itself: `navigate({ urlType: 'external', url: "{{ navigation.queryParams.redirect | default('/') }}" })`.
70
+
71
+ Which page an address draws, and for whom, is the router's decision — a tool or a test asks it, never the pages' paths:
72
+ `pageAt(schema, '/sign-in', { signedIn: true })` (the page, or where it sends them), `audienceAt(schema, '/sign-in')`
73
+ (`everyone`, `gated` — one page drawn apart by sign-in —, `guests`, `members`, `both-apart`, `nobody`).
65
74
 
66
75
  A page for some permissions says so: `access: { permissions: ['postPublish'] }` — every one held, by a signed-in visitor
67
76
  (the permissions of their visitor roles; on Plitzi's own spaces, their account's). The server keeps it: anybody else is
68
77
  answered 401 or 403 and the page's refusal, and its content is never sent to them — not in the page, not in the space
69
- the browser fetches. Signed out, they go to `unauthorizedRedirect` when the page names one. Hiding a part of a page on
70
- `auth.details.permissions` is not this: the part was still sent.
78
+ the browser fetches. Signed out, they go to `unauthorizedRedirect` when the page names one. The refusal is a few words
79
+ of Plitzi's unless `settings.withheldPage` names a page of the space (id or slug, with no `access`): it is drawn
80
+ instead, in the same layout, with the same status — `auth.isAuthenticated` tells "sign in" from "not yours". Hiding a
81
+ part of a page on `auth.details.permissions` is not this: the part was still sent.
71
82
 
72
83
  ## What a visitor may do
73
84