@plitzi/sdk-server 0.38.15 → 0.38.17
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 +110 -0
- package/README.md +8 -8
- package/dist/adapters/cloudAdapters.js +2 -2
- package/dist/core/auth/identity.d.ts +4 -0
- package/dist/core/auth/identity.js +1 -0
- package/dist/core/configSeam.js +1 -1
- package/dist/core/freePort.d.ts +4 -0
- package/dist/core/freePort.js +4 -4
- package/dist/core/http/stages/images.js +1 -1
- package/dist/core/server/fleet/channel.js +1 -1
- package/dist/core/server/fleet/relay.js +1 -1
- package/dist/core/unusedPort.d.ts +7 -3
- package/dist/core/unusedPort.js +33 -15
- package/dist/helpers/flagOverrides.d.ts +2 -1
- package/dist/helpers/paintedCookie.js +2 -2
- package/dist/{modules → hosts}/authoringHost/index.js +2 -2
- package/dist/{modules → hosts}/project/plugins.d.ts +1 -1
- package/dist/{modules → hosts}/project/plugins.js +4 -5
- package/dist/{modules → hosts}/project/serveProject.d.ts +1 -1
- package/dist/{modules → hosts}/project/serveProject.js +10 -13
- package/dist/{modules → hosts}/project/spaceFailure.js +1 -1
- package/dist/{modules → hosts}/project/watchSpace.js +3 -3
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/layers.test.d.ts +1 -0
- package/dist/modules/actions/jobs/later.js +1 -1
- package/dist/modules/actions/runtime/credentials.js +1 -1
- package/dist/modules/actions/runtime/kvList.js +1 -1
- package/dist/modules/actions/runtime/runAction.js +1 -1
- package/dist/modules/connectors/resolver.js +1 -1
- package/dist/modules/functions/capabilities.js +1 -1
- package/dist/modules/functions/load.js +1 -1
- package/dist/modules/functions/manifest.js +2 -2
- package/dist/modules/functions/routes.js +1 -1
- package/dist/modules/functions/runner/messages.js +1 -1
- package/dist/modules/functions/scope.js +1 -1
- package/dist/modules/images/imageProxy.js +1 -1
- package/dist/modules/rsc/publicFileResolver.js +1 -1
- package/dist/modules/rsc/resolveRscData.d.ts +2 -1
- package/dist/modules/rsc/resolveRscData.js +1 -1
- package/dist/modules/runtime/bundle.js +1 -1
- package/dist/modules/ssr/prepareRender.js +3 -4
- package/dist/modules/ssr/resolvePageSeo.js +1 -1
- package/dist/plugins/compile.js +1 -1
- package/dist/plugins/copy.js +1 -1
- package/dist/project.d.ts +4 -4
- package/dist/project.js +1 -2
- package/dist/sqlite.js +1 -2
- package/package.json +30 -15
- /package/dist/{modules → hosts}/authoringHost/index.d.ts +0 -0
- /package/dist/{modules → hosts}/authoringHost/index.test.d.ts +0 -0
- /package/dist/{modules → hosts}/project/serveProject.test.d.ts +0 -0
- /package/dist/{modules → hosts}/project/spaceFailure.d.ts +0 -0
- /package/dist/{modules → hosts}/project/watchSpace.d.ts +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,115 @@
|
|
|
1
1
|
# @plitzi/sdk-server
|
|
2
2
|
|
|
3
|
+
## 0.38.17
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 4f8dc37: ## Packages
|
|
8
|
+
|
|
9
|
+
- **A library package is imported by its root and its folders, never by a file** (`@plitzi/sdk-shared`, `sdk-schema`,
|
|
10
|
+
`sdk-style`, `sdk-elements`, `sdk-interactions`, `sdk-auth`, `sdk-dev-tools`, `sdk-event-bridge`, `sdk-navigation`,
|
|
11
|
+
`sdk-plugins`, `sdk-variables`): each `exports` is now `"."` and `"./*"`, the latter a folder's `index`.
|
|
12
|
+
`@plitzi/sdk-shared/helpers/isRecord` becomes `import { isRecord } from '@plitzi/sdk-shared/helpers'`, and a default
|
|
13
|
+
export by the name its folder gives it — almost always its file's (`import usePlitzi from '…/hooks/usePlitzi'` →
|
|
14
|
+
`import { usePlitzi } from '@plitzi/sdk-shared/hooks'`). A file-level specifier now fails with `ERR_MODULE_NOT_FOUND`.
|
|
15
|
+
New entries where a folder barrel would have brought more than was asked for: `@plitzi/sdk-shared/project` and
|
|
16
|
+
`@plitzi/sdk-shared/plugins/bundle` (Node only), `@plitzi/sdk-interactions/declarations` (the global callbacks and
|
|
17
|
+
utility specs, without React), and `@plitzi/sdk-elements/elements/declarations`, which now also carries the
|
|
18
|
+
declarations' attribute types and the constants they are checked with. `RuleGroup` is exported by `@plitzi/sdk-shared`
|
|
19
|
+
with the document types that use it. `plitzi upgrade migrations` names every such import in a project, with the folder to
|
|
20
|
+
import it from instead.
|
|
21
|
+
- **`@plitzi/sdk-shared`'s root exports the document types, and only them** (`@plitzi/sdk-shared`): what the package
|
|
22
|
+
does is imported from its folder — `formatDate` from `@plitzi/sdk-shared/helpers`, `ThemeProvider` from
|
|
23
|
+
`@plitzi/sdk-shared/theme`, a GraphQL operation's types from `@plitzi/sdk-shared/network/graphql` — so a module that
|
|
24
|
+
imports a type from the root no longer loads every area of the package.
|
|
25
|
+
- **What one package alone used lives in that package** (`@plitzi/sdk-shared`, `@plitzi/sdk-elements`): the data
|
|
26
|
+
source hooks moved from `@plitzi/sdk-shared/dataSource/hooks` to `@plitzi/sdk-elements/dataSource`
|
|
27
|
+
(`useRegisterSource`, `useResolvedVariables`), and the Apollo links the builder's client is built with into the
|
|
28
|
+
builder.
|
|
29
|
+
- **The builder's panels are an entry of their own** (`@plitzi/sdk-style`, `@plitzi/sdk-variables`,
|
|
30
|
+
`@plitzi/sdk-elements`): the style inspector, the advanced style editor and `BuilderStyleContextProvider` are imported
|
|
31
|
+
from `@plitzi/sdk-style/builder`; the variables' lists and forms from `@plitzi/sdk-variables/builder`; the elements'
|
|
32
|
+
settings panels (`defaultElementsSettings`) from `@plitzi/sdk-elements/builder`. Each package's root keeps what a page
|
|
33
|
+
and a server use — `generateCache` no longer loads the inspector, on a server 227 modules down to 21.
|
|
34
|
+
|
|
35
|
+
## CLI
|
|
36
|
+
- **`plitzi upgrade`'s `renames` part is now `migrations`** (`@plitzi/cli`): what a version changed that a project's
|
|
37
|
+
own source must follow, one file per change in the CLI's `src/migrations/changes/` with the version it shipped in —
|
|
38
|
+
rewritten with `--write` when it has one right answer, said otherwise. The `--json` report carries `migrations` (each
|
|
39
|
+
with its `migration`, `since`, `file`, `line`, `what` and whether it was `written`) in place of `renames` and
|
|
40
|
+
`changes`. The changes of 0.38.0 (`canTemplate` → `canSnippet`, the `*Template` authoring names), 0.38.9 (a
|
|
41
|
+
`formControl` without `required` is optional) and 0.38.12 (`usePlitziServiceContext` → `usePlitzi`) are no longer
|
|
42
|
+
looked for: a project still on one of those versions makes them by hand.
|
|
43
|
+
|
|
44
|
+
- Updated dependencies [4f8dc37]
|
|
45
|
+
- @plitzi/plitzi-sdk@0.38.17
|
|
46
|
+
- @plitzi/sdk-shared@0.38.17
|
|
47
|
+
|
|
48
|
+
## 0.38.16
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- 9cfdccb: ## Security
|
|
53
|
+
|
|
54
|
+
- **A site's credential reads nothing of the space over MCP** (`@plitzi/sdk-mcp`): the `render` token every published
|
|
55
|
+
page embeds — and a self-hosting `host` key — resolved to a grant naming the space, and the MCP served every read
|
|
56
|
+
under it: the unpublished draft, the change history with who made each change and every value before and after, the
|
|
57
|
+
functions' source, the space's private data, its action documents and connectors. Only an `agent` grant attaches a
|
|
58
|
+
space now; any other is a connection with no space (`plitzi_render` and the public guides), told so in the words
|
|
59
|
+
`NO_SPACE_ATTACHED` already uses. A deployment whose `getGrant` answered other scopes for reading must issue agent
|
|
60
|
+
grants for them.
|
|
61
|
+
|
|
62
|
+
## Agents
|
|
63
|
+
- **`plitzi space watch`** (`@plitzi/cli`): the space read again on every save of `src/space/`, `src/plugins/`,
|
|
64
|
+
`src/data/` or `public/data/`, and only what changed said — what the save did to the space element by element, the
|
|
65
|
+
findings and warnings it brought and fixed (one that only moved down its file is the same one), a save that changed
|
|
66
|
+
nothing, or that the space stopped authoring and why. `--json` is one event a line (`ready`, `pass`, `refused`,
|
|
67
|
+
`error`), for an agent to run in the background instead of `author` and `space lint` after every edit. Each pass reads
|
|
68
|
+
the space in a process of its own (`space watch-pass`, hidden). `space lint`'s reading is `spaceFindings`, shared.
|
|
69
|
+
- **A space's activity, followed** (`@plitzi/sdk-shared`, `@plitzi/sdk-mcp`, `@plitzi/cli`): what happened on a space
|
|
70
|
+
after a cursor — its draft changed (a person in the builder, an agent, the autofix), a version went out, a server
|
|
71
|
+
action failed or was refused — and, with nothing yet, waited for, up to 50 s. One vocabulary,
|
|
72
|
+
`@plitzi/sdk-shared/activity` (`SpaceActivity`, `SpaceActivityPage`, `activityLine`, `isSpaceActivityPage`, the
|
|
73
|
+
limits); the reader's own writes left out and counted (`skippedMine`), `mine` keeps them.
|
|
74
|
+
- **`plitzi_activity { after, wait, limit, mine }`** (`@plitzi/sdk-mcp`), on the new `getActivity` adapter
|
|
75
|
+
(`SSRAdapters`). The listing budget is 78k (was 77k) for it.
|
|
76
|
+
- **`plitzi space activity [--follow] [--after <cursor>] [--mine] [--limit <n>] [--json]`** (`@plitzi/cli`), over
|
|
77
|
+
the platform's `GET /spaces/:spaceId/activity`; `--follow` stays, one page a line with `--json`, and asks again
|
|
78
|
+
when the platform does not answer.
|
|
79
|
+
- **The people in the builder see the agent work** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`, `@plitzi/sdk-mcp`,
|
|
80
|
+
`@plitzi/plitzi-builder`): an agent grant carries the application the member connected (`Grant.client`,
|
|
81
|
+
`StoredSpaceToken.client`, `SSRGrant.client`), and every MCP write `SSRWriteContext.client` — the history's
|
|
82
|
+
`client` for an agent, which was never set. A collaborator may be an agent (`SubscriptionCollaborator.agent`): the
|
|
83
|
+
builder draws it as a robot, names it `Claude · for ana` (`collaboratorTitle`) in the header, on the canvas and in
|
|
84
|
+
its notices. The deployment announces it — Plitzi's joins it on a write, selects what it changed, and lets it go
|
|
85
|
+
after a minute of nothing. `activityLine` names it the same way (`Claude for ana over the MCP, …`), so
|
|
86
|
+
`plitzi space activity` says which application wrote.
|
|
87
|
+
- A tool may declare `documents: false` (`ToolSpec`): the host loads none of the space for it, and passes the call's
|
|
88
|
+
abort signal through `ToolContext.activity`.
|
|
89
|
+
|
|
90
|
+
## Authoring
|
|
91
|
+
- **A file that does not parse is said at its line under any loader** (`@plitzi/sdk-authoring`): `moduleProblem` read
|
|
92
|
+
the first line of the error, and an esbuild transform (tsx, vitest) puts only `Transform failed with 1 error:` there
|
|
93
|
+
— the file, line and what is wrong are on the next. A line of the message that points at a file of the project is
|
|
94
|
+
now the problem (`src/space/hero.ts:139: Expected "}" but found ";"`), the project's root matched as given and as it
|
|
95
|
+
is on disk (`/var/…` and `/private/var/…` on macOS).
|
|
96
|
+
|
|
97
|
+
## Testing
|
|
98
|
+
- **`unusedPort` is chosen where the system never hands one out** (`@plitzi/sdk-server`): it answered a port the system
|
|
99
|
+
had just handed out (`listen(0)`), from the ephemeral range every outgoing connection takes its local port from — so
|
|
100
|
+
another worker's request could take it before the test listened, and CI failed `runtime.test.ts` with `EADDRINUSE`
|
|
101
|
+
(the page server then ends the process). It is a free port below that range now, at random, checked first.
|
|
102
|
+
|
|
103
|
+
## Docs
|
|
104
|
+
- **A self-hosted runtime's endpoints go in `data`**, as 0.38.15 moved them: `docs/en/runtimes.md`, the
|
|
105
|
+
`10-runtime` example and the website still put `served.stage` in `preAuth`, before the cross-site guard.
|
|
106
|
+
- New: `docs/en/activity.md`; `space watch` in `docs/en/agent-tooling.md`'s loop; the CLI README, the CLI skill, the
|
|
107
|
+
generated project's `AGENTS.md`, the MCP guide and README.
|
|
108
|
+
|
|
109
|
+
- Updated dependencies [9cfdccb]
|
|
110
|
+
- @plitzi/plitzi-sdk@0.38.16
|
|
111
|
+
- @plitzi/sdk-shared@0.38.16
|
|
112
|
+
|
|
3
113
|
## 0.38.15
|
|
4
114
|
|
|
5
115
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -167,7 +167,7 @@ runtime, and its files into `public/` — a draft, or any published snapshot (`-
|
|
|
167
167
|
A project `npx @plitzi/cli create --mode server` writes runs this server through `serveProject`, from
|
|
168
168
|
`@plitzi/sdk-server/project` — its own entry, so a server that is not such a project never loads it. The project's
|
|
169
169
|
`src/main.ts` hands it what is the project's, and `serveProject` wires everything else from where the project keeps it
|
|
170
|
-
(the layout is `@plitzi/sdk-shared/project
|
|
170
|
+
(the layout is `@plitzi/sdk-shared/project`'s):
|
|
171
171
|
|
|
172
172
|
```ts
|
|
173
173
|
import { serveProject } from '@plitzi/sdk-server/project';
|
|
@@ -182,19 +182,19 @@ await serveProject({ space: authorProjectSpace, actions, connectors, serverOptio
|
|
|
182
182
|
|
|
183
183
|
`space` is called once the project's root and layout are checked: `authorProjectSpace` reads `src/space/index.ts`'s
|
|
184
184
|
`space` — `dist/space/index.js` when the server runs what `build` emitted (`projectModule` of
|
|
185
|
-
`@plitzi/sdk-shared/project
|
|
185
|
+
`@plitzi/sdk-shared/project`, the rule the runtime is found by too) — and authors it with `projectAuthoring()`. A
|
|
186
186
|
module that exports no `space` is refused saying what to export (`ProjectSpaceError`), and a space that does not author
|
|
187
187
|
with every problem (`SpaceRefusedError`): each printed as the report it is, and the process exits with 1.
|
|
188
188
|
|
|
189
189
|
The project is the working directory — where every script of its `package.json` runs it, and where a deployment runs
|
|
190
190
|
`node dist/main.js` — never worked out from where a file is: `serveProject` and `authorProjectSpace` refuse to start
|
|
191
|
-
anywhere else, naming what is missing (`package.json`, `src/`; `projectRoot` of `@plitzi/sdk-shared/project
|
|
191
|
+
anywhere else, naming what is missing (`package.json`, `src/`; `projectRoot` of `@plitzi/sdk-shared/project`, one
|
|
192
192
|
check for both). Its settings are in `process.env` before any module loads: the scripts start Node with
|
|
193
193
|
`--env-file-if-exists=.env`, and no file of the project reads `.env`. `start:dev`, which Node watches, preloads it
|
|
194
194
|
instead — `node --import @plitzi/sdk-server/env --watch-path=… src/main.ts` — since Node, handed an env file under
|
|
195
195
|
`--watch-path`, watches the folder it is in and restarts on every write there: the server's own `tmp/`, from boot.
|
|
196
196
|
|
|
197
|
-
Both hold the project to its layout before anything else (`assertProjectLayout` of `@plitzi/sdk-shared/project
|
|
197
|
+
Both hold the project to its layout before anything else (`assertProjectLayout` of `@plitzi/sdk-shared/project`,
|
|
198
198
|
what `plitzi doctor` says too): a part where the server would read nothing — a plugin folder with no `index.ts` (or
|
|
199
199
|
`index.tsx`), code in `src/plugin/`, `.env` in `src/`, a built plugin with no manifest — stops the boot with every error
|
|
200
200
|
at once (`ProjectLayoutError`, each with its fix; `findings` holds them as data), and what works and should not stay —
|
|
@@ -450,10 +450,10 @@ Beside the page adapters it offers `getSchema` and `getStyle`, read from the sam
|
|
|
450
450
|
path, or a function that may answer one — `saveSchema` and `saveStyle`, each writing its document back into the file. So an MCP server
|
|
451
451
|
([`@plitzi/sdk-mcp`](../mcp/README.md#adapters)) can run over it, with a `getGrant` of yours beside it.
|
|
452
452
|
|
|
453
|
-
In a test, listen on `await unusedPort()`: a port the system
|
|
454
|
-
system
|
|
455
|
-
|
|
456
|
-
people expect.)
|
|
453
|
+
In a test, listen on `await unusedPort()`: a free port below the system's ephemeral range, never a fixed number nor
|
|
454
|
+
one the system hands out (`listen(0)`) — a port of that range can be taken by any outgoing connection of a test running
|
|
455
|
+
beside it between the moment it is chosen and the listen, which fails with `EADDRINUSE` on a run with nothing wrong.
|
|
456
|
+
(`freePort(8080)` is the development server's: the next free one from a port people expect.)
|
|
457
457
|
|
|
458
458
|
### `JsonAdaptersConfig`
|
|
459
459
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { serverLog } from "../helpers/serverLog.js";
|
|
2
|
-
import { isRecord } from "@plitzi/sdk-shared/helpers
|
|
3
|
-
import { schemaFromWire } from "@plitzi/sdk-shared/schema
|
|
2
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
3
|
+
import { schemaFromWire } from "@plitzi/sdk-shared/schema";
|
|
4
4
|
//#region src/adapters/cloudAdapters.ts
|
|
5
5
|
/**
|
|
6
6
|
* A space fetched from Plitzi, for a server that is not Plitzi's.
|
|
@@ -23,6 +23,8 @@ export interface Grant {
|
|
|
23
23
|
spaceId: number;
|
|
24
24
|
scope: SpaceScope;
|
|
25
25
|
userId?: number;
|
|
26
|
+
/** For an `agent` grant, the application the member connected, as it registered (`Claude`): who writes for them. */
|
|
27
|
+
client?: string;
|
|
26
28
|
origins: string[];
|
|
27
29
|
}
|
|
28
30
|
/** What an account may do inside ONE space. */
|
|
@@ -37,6 +39,8 @@ export interface StoredSpaceToken {
|
|
|
37
39
|
spaceId: number;
|
|
38
40
|
scope: SpaceScope;
|
|
39
41
|
userId?: number;
|
|
42
|
+
/** For an `agent` grant, the application the member connected (`Claude`). */
|
|
43
|
+
client?: string;
|
|
40
44
|
}
|
|
41
45
|
/**
|
|
42
46
|
* What identity resolution cannot work out on its own: where accounts, space tokens and memberships are kept. This
|
|
@@ -63,6 +63,7 @@ var createIdentity = ({ tokens, carriers, adapters, config = {}, presentedOrigin
|
|
|
63
63
|
spaceId,
|
|
64
64
|
scope,
|
|
65
65
|
userId: stored.userId,
|
|
66
|
+
...stored.client === void 0 ? {} : { client: stored.client },
|
|
66
67
|
origins
|
|
67
68
|
};
|
|
68
69
|
if (scope === "render" && host !== void 0 && !domainAllowed(host, origins, platformHosts)) {
|
package/dist/core/configSeam.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { serverLog } from "../helpers/serverLog.js";
|
|
2
2
|
import { isActionDocument, validateActionDocument } from "@plitzi/sdk-shared/actions";
|
|
3
3
|
import { isConnectorManifestDraft, validateConnectorManifest } from "@plitzi/sdk-shared/connectors";
|
|
4
|
-
import { isRecord } from "@plitzi/sdk-shared/helpers
|
|
4
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
5
5
|
//#region src/core/configSeam.ts
|
|
6
6
|
/**
|
|
7
7
|
* A guard that checks each object once: a deployment that caches what it reads hands back the same object on every
|
package/dist/core/freePort.d.ts
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
/** Whether something already answers at `port` — the one test that sees a listener on every address, not just `host`. */
|
|
2
|
+
export declare const portAnswers: (port: number, host: string) => Promise<boolean>;
|
|
3
|
+
/** Whether this process could listen at `port` on `host`. */
|
|
4
|
+
export declare const portBindable: (port: number, host: string) => Promise<boolean>;
|
|
1
5
|
/**
|
|
2
6
|
* The first port from `preferred` up that nothing uses — for a development server, which should start beside
|
|
3
7
|
* whatever else is running rather than refuse to.
|
package/dist/core/freePort.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { connect, createServer } from "node:net";
|
|
2
2
|
//#region src/core/freePort.ts
|
|
3
3
|
/** Whether something already answers at `port` — the one test that sees a listener on every address, not just `host`. */
|
|
4
|
-
var
|
|
4
|
+
var portAnswers = (port, host) => new Promise((resolve) => {
|
|
5
5
|
const socket = connect({
|
|
6
6
|
port,
|
|
7
7
|
host
|
|
@@ -13,7 +13,7 @@ var answers = (port, host) => new Promise((resolve) => {
|
|
|
13
13
|
socket.once("error", () => resolve(false));
|
|
14
14
|
});
|
|
15
15
|
/** Whether this process could listen at `port` on `host`. */
|
|
16
|
-
var
|
|
16
|
+
var portBindable = (port, host) => new Promise((resolve) => {
|
|
17
17
|
const probe = createServer();
|
|
18
18
|
probe.once("error", () => resolve(false));
|
|
19
19
|
probe.once("listening", () => probe.close(() => resolve(true)));
|
|
@@ -29,8 +29,8 @@ var bindable = (port, host) => new Promise((resolve) => {
|
|
|
29
29
|
* this: a fixed port that is taken is an error worth stopping for.
|
|
30
30
|
*/
|
|
31
31
|
var freePort = async (preferred, host = "127.0.0.1", attempts = 20) => {
|
|
32
|
-
for (let port = preferred; port < preferred + attempts; port += 1) if (!await
|
|
32
|
+
for (let port = preferred; port < preferred + attempts; port += 1) if (!await portAnswers(port, host) && await portBindable(port, host)) return port;
|
|
33
33
|
throw new Error(`No free port between ${preferred} and ${preferred + attempts - 1} on ${host}. Set PORT to one.`);
|
|
34
34
|
};
|
|
35
35
|
//#endregion
|
|
36
|
-
export { freePort };
|
|
36
|
+
export { freePort, portAnswers, portBindable };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { serverLog } from "../../../helpers/serverLog.js";
|
|
2
2
|
import { createImageProxy } from "../../../modules/images/imageProxy.js";
|
|
3
3
|
import { loadSharpTransform } from "../../../modules/images/transform.js";
|
|
4
|
+
import { IMAGE_PATH } from "@plitzi/sdk-shared/helpers";
|
|
4
5
|
import path from "node:path";
|
|
5
|
-
import { IMAGE_PATH } from "@plitzi/sdk-shared/helpers/images";
|
|
6
6
|
//#region src/core/http/stages/images.ts
|
|
7
7
|
/** Where pictures are resized, when this server resizes them: published to the SDK, which builds every `srcset` on it. */
|
|
8
8
|
var imagesPathOf = (config) => config.images && config.images.domains.length > 0 ? IMAGE_PATH : void 0;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRecord } from "@plitzi/sdk-shared/helpers
|
|
1
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
2
2
|
//#region src/core/server/fleet/channel.ts
|
|
3
3
|
/** The channel is shared with `node:cluster` and anything else the deployment sends: only these are ours. */
|
|
4
4
|
var isFleetMessage = (value) => {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { serverLog } from "../../../helpers/serverLog.js";
|
|
2
2
|
import { broadcast, onBroadcast } from "./link.js";
|
|
3
|
-
import { isRecord } from "@plitzi/sdk-shared/helpers
|
|
3
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
4
4
|
//#region src/core/server/fleet/relay.ts
|
|
5
5
|
/**
|
|
6
6
|
* `server.cache` and `server.plugins` in a fleet, whose workers each keep their own: what one process is told, every
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* A port
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* A port nobody holds, for a test to listen on — chosen where the system never hands one out by itself.
|
|
3
|
+
*
|
|
4
|
+
* Not one the system hands out (`listen(0)`): that range is the one every outgoing connection takes its local port
|
|
5
|
+
* from, so between the moment a port is handed out and the moment the test listens on it, a request of a test running
|
|
6
|
+
* beside it — another worker's `fetch`, a database connection — can take it, and the listen fails with `EADDRINUSE` on
|
|
7
|
+
* a run that has nothing wrong with it. Below that range only a port somebody chose explicitly is ever taken, and it is
|
|
8
|
+
* looked at first: one that answers, or that this process may not listen on, is passed over.
|
|
5
9
|
*/
|
|
6
10
|
export declare const unusedPort: (host?: string) => Promise<number>;
|
package/dist/core/unusedPort.js
CHANGED
|
@@ -1,20 +1,38 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { portAnswers, portBindable } from "./freePort.js";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
2
3
|
//#region src/core/unusedPort.ts
|
|
4
|
+
/** The lowest port handed out: above the well-known and the registered ones most local services sit on. */
|
|
5
|
+
var LOWEST = 1e4;
|
|
6
|
+
/** Below it, as far as a system lets a port be chosen for nobody: Linux's default, and below macOS's and Windows's. */
|
|
7
|
+
var EPHEMERAL_DEFAULT = 32768;
|
|
8
|
+
var ATTEMPTS = 50;
|
|
3
9
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* and the listen fails with `EADDRINUSE` on a run that has nothing wrong with it.
|
|
10
|
+
* Where the system starts handing out ports by itself — to every outgoing connection and every `listen(0)`. Linux says
|
|
11
|
+
* where in `/proc`; macOS and Windows start at 49152, above Linux's default.
|
|
7
12
|
*/
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
var ephemeralStart = () => {
|
|
14
|
+
try {
|
|
15
|
+
const [low] = readFileSync("/proc/sys/net/ipv4/ip_local_port_range", "utf-8").trim().split(/\s+/).map(Number);
|
|
16
|
+
if (Number.isInteger(low) && low > 10050) return Math.min(low, EPHEMERAL_DEFAULT);
|
|
17
|
+
} catch {}
|
|
18
|
+
return EPHEMERAL_DEFAULT;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* A port nobody holds, for a test to listen on — chosen where the system never hands one out by itself.
|
|
22
|
+
*
|
|
23
|
+
* Not one the system hands out (`listen(0)`): that range is the one every outgoing connection takes its local port
|
|
24
|
+
* from, so between the moment a port is handed out and the moment the test listens on it, a request of a test running
|
|
25
|
+
* beside it — another worker's `fetch`, a database connection — can take it, and the listen fails with `EADDRINUSE` on
|
|
26
|
+
* a run that has nothing wrong with it. Below that range only a port somebody chose explicitly is ever taken, and it is
|
|
27
|
+
* looked at first: one that answers, or that this process may not listen on, is passed over.
|
|
28
|
+
*/
|
|
29
|
+
var unusedPort = async (host = "127.0.0.1") => {
|
|
30
|
+
const span = ephemeralStart() - LOWEST;
|
|
31
|
+
for (let attempt = 0; attempt < ATTEMPTS; attempt += 1) {
|
|
32
|
+
const port = LOWEST + Math.floor(Math.random() * span);
|
|
33
|
+
if (!await portAnswers(port, host) && await portBindable(port, host)) return port;
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`No free port between ${String(LOWEST)} and ${String(LOWEST + span)} on ${host} after ${String(ATTEMPTS)} tries`);
|
|
36
|
+
};
|
|
19
37
|
//#endregion
|
|
20
38
|
export { unusedPort };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Environment,
|
|
1
|
+
import { Environment, SSRServerConfig } from '@plitzi/sdk-shared';
|
|
2
|
+
import { FlagOverrides } from '@plitzi/sdk-shared/flags';
|
|
2
3
|
/** The deployment's own layer for one space: `config.flags`, asked per space when it is a function. */
|
|
3
4
|
export declare const serverFlagsFor: (config: Pick<SSRServerConfig, "flags">, space: {
|
|
4
5
|
spaceId: number;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getKeyDecoded } from "@plitzi/sdk-shared/helpers
|
|
2
|
-
import { paintedStateCookieName } from "@plitzi/sdk-shared/state
|
|
1
|
+
import { getKeyDecoded } from "@plitzi/sdk-shared/helpers";
|
|
2
|
+
import { paintedStateCookieName } from "@plitzi/sdk-shared/state";
|
|
3
3
|
//#region src/helpers/paintedCookie.ts
|
|
4
4
|
/**
|
|
5
5
|
* The name the painted state of a server-rendered page is kept under, for this request's host.
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { serverLog } from "../../helpers/serverLog.js";
|
|
2
2
|
import { PREVIEW_TOKEN_PARAM, readDraftToken } from "../../core/previewToken.js";
|
|
3
3
|
import { createServer } from "../../core/createServer.js";
|
|
4
|
-
import { isRecord } from "@plitzi/sdk-shared/helpers
|
|
4
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
5
5
|
import { randomBytes } from "node:crypto";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { mkdirSync, readFileSync, readdirSync, rmSync, writeFileSync } from "node:fs";
|
|
8
|
-
//#region src/
|
|
8
|
+
//#region src/hosts/authoringHost/index.ts
|
|
9
9
|
/** The one space the host serves, which every page is a draft of. */
|
|
10
10
|
var SPACE_ID = 1;
|
|
11
11
|
/** An id is a file's name and a query's value: nothing that could be read as a path or need escaping. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { FunctionsDefinition } from '
|
|
1
|
+
import { FunctionsDefinition } from '../../modules/functions/contract';
|
|
2
2
|
import { PluginSource, SSRServer } from '@plitzi/sdk-shared';
|
|
3
3
|
/**
|
|
4
4
|
* A project's plugins, as its server registers them: every folder of `src/plugins` built from its source, and every
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import { loadFunctions, loadFunctionsSource } from "
|
|
1
|
+
import { loadFunctions, loadFunctionsSource } from "../../modules/functions/load.js";
|
|
2
2
|
import { PLUGIN_FUNCTIONS_SOURCE } from "@plitzi/sdk-shared/actions";
|
|
3
|
-
import { isRecord } from "@plitzi/sdk-shared/helpers
|
|
3
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { existsSync, readFileSync, readdirSync, watch } from "node:fs";
|
|
6
|
-
import { checkPluginFolder, layoutFindingText, pluginEntry, pluginTypeOf, readVendorPlugin } from "@plitzi/sdk-shared/project
|
|
7
|
-
|
|
8
|
-
//#region src/modules/project/plugins.ts
|
|
6
|
+
import { PLUGINS_DIR, PLUGIN_FUNCTIONS_DIR, VENDOR_PLUGINS_DIR, checkPluginFolder, layoutFindingText, pluginEntry, pluginTypeOf, readVendorPlugin } from "@plitzi/sdk-shared/project";
|
|
7
|
+
//#region src/hosts/project/plugins.ts
|
|
9
8
|
/**
|
|
10
9
|
* `action: 'compile'` is what makes a folder's plugin SERVER-rendered: the server builds the entry with esbuild, keeps
|
|
11
10
|
* React external so the plugin runs on the one copy the page already has, serves the bundle to the browser AND
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AuthoredDocuments } from './watchSpace';
|
|
2
2
|
import { ServerConfig } from '../../core/createServer';
|
|
3
|
-
import { ConnectorManifest } from '
|
|
3
|
+
import { ConnectorManifest } from '../../modules/connectors';
|
|
4
4
|
import { ActionEntry, SSRServer } from '@plitzi/sdk-shared';
|
|
5
5
|
/** What `serveProject` sets itself, from the project's layout — so never the project's options'. */
|
|
6
6
|
type SetByProject = 'port' | 'health' | 'adapters' | 'plugins' | 'publicDir' | 'dataDir' | 'functions' | 'action';
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { consoleLogger } from "../../helpers/serverLog.js";
|
|
2
2
|
import { isFleetWorker } from "../../core/server/fleet/role.js";
|
|
3
|
-
import { loadFunctions } from "
|
|
3
|
+
import { loadFunctions } from "../../modules/functions/load.js";
|
|
4
4
|
import { createServer as createServer$1 } from "../../core/createServer.js";
|
|
5
5
|
import { closeOnSignals } from "../../core/server/closeOnSignals.js";
|
|
6
6
|
import { freePort } from "../../core/freePort.js";
|
|
7
7
|
import { createCloudAdapters } from "../../adapters/cloudAdapters.js";
|
|
8
8
|
import { createJsonAdapters } from "../../adapters/jsonAdapters.js";
|
|
9
|
-
import { createFileKv } from "
|
|
10
|
-
import { credentialsFromEnv } from "
|
|
11
|
-
import { reachOwnServer } from "
|
|
12
|
-
import { loadRuntime, loadRuntimeModule } from "
|
|
13
|
-
import { serveRuntime } from "
|
|
9
|
+
import { createFileKv } from "../../modules/actions/runtime/fileKv.js";
|
|
10
|
+
import { credentialsFromEnv } from "../../modules/actions/runtime/credentials.js";
|
|
11
|
+
import { reachOwnServer } from "../../modules/runtime/inside.js";
|
|
12
|
+
import { loadRuntime, loadRuntimeModule } from "../../modules/runtime/bundle.js";
|
|
13
|
+
import { serveRuntime } from "../../modules/runtime/stages.js";
|
|
14
14
|
import { projectPlugins, watchProjectPlugins } from "./plugins.js";
|
|
15
15
|
import { createSpaceFailure } from "./spaceFailure.js";
|
|
16
16
|
import { watchSpace } from "./watchSpace.js";
|
|
@@ -19,14 +19,11 @@ import { X509Certificate } from "node:crypto";
|
|
|
19
19
|
import { hostname, networkInterfaces } from "node:os";
|
|
20
20
|
import { isIP } from "node:net";
|
|
21
21
|
import path from "node:path";
|
|
22
|
+
import { EMPTY_SCHEMA } from "@plitzi/sdk-shared/schema";
|
|
22
23
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "node:fs";
|
|
23
|
-
import {
|
|
24
|
-
import { localNetworkName, networkAddresses } from "@plitzi/sdk-shared/project
|
|
25
|
-
|
|
26
|
-
import { projectModule, projectRoot } from "@plitzi/sdk-shared/project/root";
|
|
27
|
-
import { EMPTY_SCHEMA } from "@plitzi/sdk-shared/schema/schemaConstants";
|
|
28
|
-
import { EMPTY_STYLE_SCHEMA } from "@plitzi/sdk-shared/style/styleConstants";
|
|
29
|
-
//#region src/modules/project/serveProject.ts
|
|
24
|
+
import { EMPTY_STYLE_SCHEMA } from "@plitzi/sdk-shared/style";
|
|
25
|
+
import { DATA_DIR, DEV_SERVER_FILE, FUNCTIONS_DIR, KV_FILE, PROJECT_TMP, PUBLIC_DIR, RUNTIME_BUNDLE, RUNTIME_ENTRY, assertProjectLayout, layoutFindingText, localNetworkName, networkAddresses, projectModule, projectRoot } from "@plitzi/sdk-shared/project";
|
|
26
|
+
//#region src/hosts/project/serveProject.ts
|
|
30
27
|
/**
|
|
31
28
|
* The errors whose message is the whole report — every problem, where it is and what to write instead — and whose
|
|
32
29
|
* stack would only point inside the SDK: the project's root, its layout, a space module with no space, a space that does
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DEV_RELOAD_PATH } from "../../core/http/stages/devReload.js";
|
|
2
2
|
import { escapeHtml } from "../../helpers/escapeHtml.js";
|
|
3
|
-
//#region src/
|
|
3
|
+
//#region src/hosts/project/spaceFailure.ts
|
|
4
4
|
/**
|
|
5
5
|
* The page a project's server answers with while its space does not author — while developing only.
|
|
6
6
|
*
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { isRecord } from "@plitzi/sdk-shared/helpers
|
|
1
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { watch } from "node:fs";
|
|
4
|
-
import { AUTHOR_FILE, SOURCE_DIR } from "@plitzi/sdk-shared/project
|
|
4
|
+
import { AUTHOR_FILE, SOURCE_DIR } from "@plitzi/sdk-shared/project";
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
6
|
-
//#region src/
|
|
6
|
+
//#region src/hosts/project/watchSpace.ts
|
|
7
7
|
/**
|
|
8
8
|
* What the author script sent: its own `{ schema, style }`, which `authorSpace` built and checked — the message is
|
|
9
9
|
* looked at only for its shape, so a stray one from a script that is not the CLI's is not served.
|
package/dist/index.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export { createAuthAdapters } from './adapters/authAdapters';
|
|
|
12
12
|
export { authoringPreview, createMemoryCache, createSpaceAdapters, fixedSpace, presentsCredential, refuse, verifiedDomain, wildcardSubdomain } from './adapters/space';
|
|
13
13
|
export { createLocalFontStore, hostedPathsOf } from './core/fontStore';
|
|
14
14
|
export { createMemoryDraftStore, takeDraftOverride } from './modules/ssr/preview';
|
|
15
|
-
export { createAuthoringHost } from './
|
|
15
|
+
export { createAuthoringHost } from './hosts/authoringHost';
|
|
16
16
|
export { createMemoryPubSub } from './modules/realtime/memoryPubSub';
|
|
17
17
|
export { createRedisPubSub } from './modules/realtime/redisPubSub';
|
|
18
18
|
export { PREVIEW_TOKEN_PARAM } from './core/previewToken';
|
|
@@ -28,6 +28,6 @@ export type { FontStore, StoredFont } from './core/fontStore';
|
|
|
28
28
|
export type { PubSubAdapter, SSRRealtimeConfig } from '@plitzi/sdk-shared';
|
|
29
29
|
export type { RedisPubSubClients } from './modules/realtime/redisPubSub';
|
|
30
30
|
export type { ResolvedServices, ServerConfig } from './core/createServer';
|
|
31
|
-
export type { AuthoringHost, AuthoringHostConfig } from './
|
|
31
|
+
export type { AuthoringHost, AuthoringHostConfig } from './hosts/authoringHost';
|
|
32
32
|
export type { Closable, CloseOnSignalsOptions } from './core/server/closeOnSignals';
|
|
33
33
|
export type { BaseContext, PipelineExtensions, SSRContext, Stage } from './core/http/types';
|
package/dist/index.js
CHANGED
|
@@ -19,6 +19,6 @@ import { createMemoryCache, refuse } from "./adapters/space/types.js";
|
|
|
19
19
|
import { authoringPreview, fixedSpace, presentsCredential, verifiedDomain, wildcardSubdomain } from "./adapters/space/resolvers.js";
|
|
20
20
|
import { createSpaceAdapters } from "./adapters/space/index.js";
|
|
21
21
|
import { createLocalFontStore, hostedPathsOf } from "./core/fontStore.js";
|
|
22
|
-
import { createAuthoringHost } from "./
|
|
22
|
+
import { createAuthoringHost } from "./hosts/authoringHost/index.js";
|
|
23
23
|
import { createRedisPubSub } from "./modules/realtime/redisPubSub.js";
|
|
24
24
|
export { PREVIEW_TOKEN_PARAM, authoringPreview, buildHealthPayload, closeOnSignals, consoleLogger, createAuthAdapters, createAuthoringHost, createCloudAdapters, createConnectorResolver, createJsonAdapters, createLocalFontStore, createMemoryCache, createMemoryDraftStore, createMemoryPubSub, createRedisPubSub, createServer, createSpaceAdapters, fetchConnectorRecords, fixedSpace, freePort, hostedPathsOf, isLogged, loadFunctions, loadFunctionsSource, logLevelOf, presentsCredential, readFunctionsDir, rebaseMedia, refuse, registerHealthCheck, renderLogEvent, resolveRscData, resolveServices, serverLog, takeDraftOverride, unusedPort, verifiedDomain, wildcardSubdomain, writeConnectorRecord };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { findTriggerNode } from "../runtime/triggers.js";
|
|
2
|
-
import { isRecord } from "@plitzi/sdk-shared/helpers
|
|
2
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
3
3
|
import { randomUUID } from "node:crypto";
|
|
4
4
|
//#region src/modules/actions/jobs/later.ts
|
|
5
5
|
/** A month: past it, a run set for later is a schedule, and a cron says it better. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRecord } from "@plitzi/sdk-shared/helpers
|
|
1
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
2
2
|
//#region src/modules/actions/runtime/credentials.ts
|
|
3
3
|
/** Where a project's server — and `plitzi functions dev` — reads the credentials its space's code names. */
|
|
4
4
|
var CREDENTIALS_ENV = "PLITZI_CREDENTIALS";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRecord } from "@plitzi/sdk-shared/helpers
|
|
1
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
2
2
|
//#region src/modules/actions/runtime/kvList.ts
|
|
3
3
|
/**
|
|
4
4
|
* The most a list holds. A list is one value of the store, read and written whole, so it is for what a page shows at
|
|
@@ -13,7 +13,7 @@ import { createSigning } from "./signing.js";
|
|
|
13
13
|
import { createRunFetch, taskContextFor } from "./taskContext.js";
|
|
14
14
|
import onAbort from "../../../helpers/onAbort.js";
|
|
15
15
|
import { FAILURE_HANDLER_TASK } from "@plitzi/sdk-shared/actions";
|
|
16
|
-
import { evaluateRuleGroup } from "@plitzi/sdk-shared/helpers
|
|
16
|
+
import { evaluateRuleGroup } from "@plitzi/sdk-shared/helpers";
|
|
17
17
|
import { resolveStepParam } from "@plitzi/sdk-shared/helpers/twigWrapper";
|
|
18
18
|
//#region src/modules/actions/runtime/runAction.ts
|
|
19
19
|
/** How often a run asks the shared store whether it has been cancelled. Once a second is far finer than the
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { fetchConnectorRecords } from "./engine.js";
|
|
2
2
|
import { collectBoundPaths, projectSlice } from "./projection.js";
|
|
3
|
-
import getSourceName from "@plitzi/sdk-shared/dataSource/helpers
|
|
3
|
+
import { getSourceName } from "@plitzi/sdk-shared/dataSource/helpers";
|
|
4
4
|
//#region src/modules/connectors/resolver.ts
|
|
5
5
|
var DEFAULT_PAGE_PARAM = "page";
|
|
6
6
|
var toLimit = (limit, singleRecord) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isRecord } from "@plitzi/sdk-shared/helpers
|
|
1
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
2
2
|
//#region src/modules/functions/capabilities.ts
|
|
3
3
|
var TEXTUAL = /^(text\/|application\/([\w.+-]*\+)?(json|xml|javascript|x-www-form-urlencoded))/i;
|
|
4
4
|
/** A body as the wire carries it: as text when its type says it is text, base64 otherwise. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { buildFunctions } from "./build.js";
|
|
2
2
|
import { readFunctionsSource } from "@plitzi/sdk-shared/actions";
|
|
3
|
-
import { isRecord } from "@plitzi/sdk-shared/helpers
|
|
3
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
4
4
|
import { readFile, readdir } from "node:fs/promises";
|
|
5
5
|
import { fileURLToPath } from "node:url";
|
|
6
6
|
//#region src/modules/functions/load.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { pluginTaskProblem } from "./scope.js";
|
|
2
2
|
import { taskName, taskNameProblem } from "../actions/tasks/registry.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { PLUGIN_ROUTES_SEGMENT } from "@plitzi/sdk-shared/actions";
|
|
4
|
+
import { isRecord } from "@plitzi/sdk-shared/helpers";
|
|
5
5
|
//#region src/modules/functions/manifest.ts
|
|
6
6
|
var ROUTE_METHODS = [
|
|
7
7
|
"GET",
|
|
@@ -6,8 +6,8 @@ import { functionLimitsFor } from "./config.js";
|
|
|
6
6
|
import { parseRouteKey, reservedRouteProblem } from "./manifest.js";
|
|
7
7
|
import { answerCall, readCall, responseOf, wireRequestOf, wireResponseFrom } from "./capabilities.js";
|
|
8
8
|
import { FunctionFailure } from "./protocol.js";
|
|
9
|
+
import { PLUGIN_ROUTES_SEGMENT } from "@plitzi/sdk-shared/actions";
|
|
9
10
|
import { randomUUID } from "node:crypto";
|
|
10
|
-
import { PLUGIN_ROUTES_SEGMENT } from "@plitzi/sdk-shared/actions/functions";
|
|
11
11
|
//#region src/modules/functions/routes.ts
|
|
12
12
|
/** A route key's params from a path it answers, or nothing when it does not answer it. */
|
|
13
13
|
var matchKey = (key, method, path) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PLUGIN_ROUTES_SEGMENT } from "@plitzi/sdk-shared/actions
|
|
1
|
+
import { PLUGIN_ROUTES_SEGMENT } from "@plitzi/sdk-shared/actions";
|
|
2
2
|
//#region src/modules/functions/scope.ts
|
|
3
3
|
/** Where a plugin's routes answer, under `/fn`: `/fn/plugins/<type>/…`. */
|
|
4
4
|
var PLUGIN_ROUTES = `/${PLUGIN_ROUTES_SEGMENT}/`;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { fetchOutbound } from "../../helpers/outboundGuard.js";
|
|
2
2
|
import { writeFileAtomic } from "../../helpers/atomicFile.js";
|
|
3
3
|
import { isAllowedImageHost } from "./allowlist.js";
|
|
4
|
+
import { IMAGE_WIDTHS, isImageWidth } from "@plitzi/sdk-shared/helpers";
|
|
4
5
|
import { createHash } from "node:crypto";
|
|
5
6
|
import fs from "node:fs/promises";
|
|
6
7
|
import path from "node:path";
|
|
7
|
-
import { IMAGE_WIDTHS, isImageWidth } from "@plitzi/sdk-shared/helpers/images";
|
|
8
8
|
//#region src/modules/images/imageProxy.ts
|
|
9
9
|
/** The formats a picture may arrive in, as the file extension it is kept under. SVG is not one: served from this
|
|
10
10
|
* origin, an SVG is a document that can run script. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import path from "node:path";
|
|
3
|
-
import { PROJECT_DATA_PREFIX } from "@plitzi/sdk-shared/server
|
|
3
|
+
import { PROJECT_DATA_PREFIX } from "@plitzi/sdk-shared/server";
|
|
4
4
|
//#region src/modules/rsc/publicFileResolver.ts
|
|
5
5
|
/** Where a provider's `query` is a path: a URL, a protocol-relative one or one with `{{tokens}}` is not. */
|
|
6
6
|
var pathOf = (query) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Element, Environment,
|
|
1
|
+
import { Element, Environment, Schema, SSRRequest, SSRRscData, SSRUser } from '@plitzi/sdk-shared';
|
|
2
|
+
import { FlagOverrides } from '@plitzi/sdk-shared/flags';
|
|
2
3
|
/** Everything an element resolver needs to turn one `runtime: 'server'` element into its data slice. */
|
|
3
4
|
export type RscResolveContext = {
|
|
4
5
|
element: Element;
|
|
@@ -2,7 +2,7 @@ import { serverLog } from "../../helpers/serverLog.js";
|
|
|
2
2
|
import onAbort from "../../helpers/onAbort.js";
|
|
3
3
|
import { matchRscPage } from "./matchRscPage.js";
|
|
4
4
|
import { flagUserFromSSR, flagValues, resolveFlags } from "@plitzi/sdk-shared/flags";
|
|
5
|
-
import { collectServerElements } from "@plitzi/sdk-shared/schema
|
|
5
|
+
import { collectServerElements } from "@plitzi/sdk-shared/schema";
|
|
6
6
|
//#region src/modules/rsc/resolveRscData.ts
|
|
7
7
|
var DEFAULT_ELEMENT_TIMEOUT_MS = 5e3;
|
|
8
8
|
/**
|
|
@@ -21,13 +21,12 @@ import { sdkAssetVersion } from "../../core/sdkAssets.js";
|
|
|
21
21
|
import { buildServerInfo } from "../../helpers/buildServerInfo.js";
|
|
22
22
|
import { resolveDebugMode } from "../../helpers/resolveDebugMode.js";
|
|
23
23
|
import { flagUserFromSSR, flagValues, resolveFlags } from "@plitzi/sdk-shared/flags";
|
|
24
|
-
import { collectServerElements, notFoundProvider, pageNotFound, pageServerContext } from "@plitzi/sdk-shared/schema
|
|
24
|
+
import { collectServerElements, notFoundProvider, pageElementTypes, pageNotFound, pageServerContext } from "@plitzi/sdk-shared/schema";
|
|
25
25
|
import { debugCookieName } from "@plitzi/sdk-shared/devTools";
|
|
26
26
|
import { themeFromCookies } from "@plitzi/sdk-shared/theme";
|
|
27
|
-
import { paintedKeys, paintedStateFor } from "@plitzi/sdk-shared/state
|
|
27
|
+
import { paintedKeys, paintedStateFor } from "@plitzi/sdk-shared/state";
|
|
28
28
|
import { fontUrlResolver, fontsToHead } from "@plitzi/sdk-shared/style";
|
|
29
|
-
import { pluginDeclarationOf, pluginTypesOf } from "@plitzi/sdk-shared/plugins
|
|
30
|
-
import { pageElementTypes } from "@plitzi/sdk-shared/schema/pageElements";
|
|
29
|
+
import { pluginDeclarationOf, pluginTypesOf } from "@plitzi/sdk-shared/plugins";
|
|
31
30
|
//#region src/modules/ssr/prepareRender.tsx
|
|
32
31
|
/** Last resort only: used for a page that declares no SEO title and a deployment that supplies none either. */
|
|
33
32
|
var DEFAULT_TITLE = "Plitzi App";
|
package/dist/plugins/compile.js
CHANGED
|
@@ -3,7 +3,7 @@ import fs from "node:fs/promises";
|
|
|
3
3
|
import path from "node:path";
|
|
4
4
|
import esbuild from "esbuild";
|
|
5
5
|
import { pluginAssetLoaders, pluginImportQueries } from "@plitzi/sdk-shared/plugins/bundle";
|
|
6
|
-
import { inPluginLayer } from "@plitzi/sdk-shared/style
|
|
6
|
+
import { inPluginLayer } from "@plitzi/sdk-shared/style";
|
|
7
7
|
//#region src/plugins/compile.ts
|
|
8
8
|
var EXTERNAL = [
|
|
9
9
|
"react",
|
package/dist/plugins/copy.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { copyFileAtomic, writeFileAtomic } from "../helpers/atomicFile.js";
|
|
2
2
|
import fs from "node:fs/promises";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import { inPluginLayer } from "@plitzi/sdk-shared/style
|
|
4
|
+
import { inPluginLayer } from "@plitzi/sdk-shared/style";
|
|
5
5
|
//#region src/plugins/copy.ts
|
|
6
6
|
var copyPlugin = async (src, destDir, filename) => {
|
|
7
7
|
const dest = path.join(destDir, filename);
|
package/dist/project.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The server of a project `@plitzi/cli` writes: its `src/main.ts` hands `serveProject` the space, its actions and its
|
|
3
3
|
* options, and the rest — the port, the plugins, the functions, the runtime, the files, the reloads while developing —
|
|
4
|
-
* comes from where the project keeps each part (`@plitzi/sdk-shared/project
|
|
4
|
+
* comes from where the project keeps each part (`@plitzi/sdk-shared/project`). A fix to it arrives with the
|
|
5
5
|
* package, never as a file to upgrade.
|
|
6
6
|
*/
|
|
7
|
-
export { serveProject } from './
|
|
8
|
-
export type { ProjectServerOptions, ProjectSpace, ServedProject, ServeProjectOptions } from './
|
|
9
|
-
export type { AuthoredDocuments } from './
|
|
7
|
+
export { serveProject } from './hosts/project/serveProject';
|
|
8
|
+
export type { ProjectServerOptions, ProjectSpace, ServedProject, ServeProjectOptions } from './hosts/project/serveProject';
|
|
9
|
+
export type { AuthoredDocuments } from './hosts/project/watchSpace';
|
package/dist/project.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { serveProject };
|
|
1
|
+
export { serveProject } from "./hosts/project/serveProject.js";
|
package/dist/sqlite.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export { createSqliteKv };
|
|
1
|
+
export { createSqliteKv } from "./modules/sqlite/kv.js";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plitzi/sdk-server",
|
|
3
|
-
"version": "0.38.
|
|
3
|
+
"version": "0.38.17",
|
|
4
4
|
"license": "AGPL-3.0",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -11,76 +11,91 @@
|
|
|
11
11
|
"types": "dist/index.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": {
|
|
14
|
+
"@plitzi/source": "./src/index.ts",
|
|
14
15
|
"types": "./dist/index.d.ts",
|
|
15
16
|
"import": "./dist/index.js",
|
|
16
17
|
"default": "./dist/index.js"
|
|
17
18
|
},
|
|
18
19
|
"./auth": {
|
|
20
|
+
"@plitzi/source": "./src/auth.ts",
|
|
19
21
|
"types": "./dist/auth.d.ts",
|
|
20
22
|
"import": "./dist/auth.js",
|
|
21
23
|
"default": "./dist/auth.js"
|
|
22
24
|
},
|
|
23
25
|
"./oauth": {
|
|
26
|
+
"@plitzi/source": "./src/oauth.ts",
|
|
24
27
|
"types": "./dist/oauth.d.ts",
|
|
25
28
|
"import": "./dist/oauth.js",
|
|
26
29
|
"default": "./dist/oauth.js"
|
|
27
30
|
},
|
|
28
31
|
"./kernel": {
|
|
32
|
+
"@plitzi/source": "./src/kernel.ts",
|
|
29
33
|
"types": "./dist/kernel.d.ts",
|
|
30
34
|
"import": "./dist/kernel.js",
|
|
31
35
|
"default": "./dist/kernel.js"
|
|
32
36
|
},
|
|
33
37
|
"./mysql": {
|
|
38
|
+
"@plitzi/source": "./src/mysql.ts",
|
|
34
39
|
"types": "./dist/mysql.d.ts",
|
|
35
40
|
"import": "./dist/mysql.js",
|
|
36
41
|
"default": "./dist/mysql.js"
|
|
37
42
|
},
|
|
38
43
|
"./mongo": {
|
|
44
|
+
"@plitzi/source": "./src/mongo.ts",
|
|
39
45
|
"types": "./dist/mongo.d.ts",
|
|
40
46
|
"import": "./dist/mongo.js",
|
|
41
47
|
"default": "./dist/mongo.js"
|
|
42
48
|
},
|
|
43
49
|
"./sqlite": {
|
|
50
|
+
"@plitzi/source": "./src/sqlite.ts",
|
|
44
51
|
"types": "./dist/sqlite.d.ts",
|
|
45
52
|
"import": "./dist/sqlite.js",
|
|
46
53
|
"default": "./dist/sqlite.js"
|
|
47
54
|
},
|
|
48
55
|
"./handlers": {
|
|
56
|
+
"@plitzi/source": "./src/handlers.ts",
|
|
49
57
|
"types": "./dist/handlers.d.ts",
|
|
50
58
|
"import": "./dist/handlers.js",
|
|
51
59
|
"default": "./dist/handlers.js"
|
|
52
60
|
},
|
|
53
61
|
"./ssr": {
|
|
62
|
+
"@plitzi/source": "./src/ssr.ts",
|
|
54
63
|
"types": "./dist/ssr.d.ts",
|
|
55
64
|
"import": "./dist/ssr.js",
|
|
56
65
|
"default": "./dist/ssr.js"
|
|
57
66
|
},
|
|
58
67
|
"./actions": {
|
|
68
|
+
"@plitzi/source": "./src/actions.ts",
|
|
59
69
|
"types": "./dist/actions.d.ts",
|
|
60
70
|
"import": "./dist/actions.js",
|
|
61
71
|
"default": "./dist/actions.js"
|
|
62
72
|
},
|
|
63
73
|
"./functions": {
|
|
74
|
+
"@plitzi/source": "./src/functions.ts",
|
|
64
75
|
"types": "./dist/functions.d.ts",
|
|
65
76
|
"import": "./dist/functions.js",
|
|
66
77
|
"default": "./dist/functions.js"
|
|
67
78
|
},
|
|
68
79
|
"./functions-runner": {
|
|
80
|
+
"@plitzi/source": "./src/functionsRunner.ts",
|
|
69
81
|
"types": "./dist/functionsRunner.d.ts",
|
|
70
82
|
"import": "./dist/functionsRunner.js",
|
|
71
83
|
"default": "./dist/functionsRunner.js"
|
|
72
84
|
},
|
|
73
85
|
"./runtime": {
|
|
86
|
+
"@plitzi/source": "./src/runtime.ts",
|
|
74
87
|
"types": "./dist/runtime.d.ts",
|
|
75
88
|
"import": "./dist/runtime.js",
|
|
76
89
|
"default": "./dist/runtime.js"
|
|
77
90
|
},
|
|
78
91
|
"./project": {
|
|
92
|
+
"@plitzi/source": "./src/project.ts",
|
|
79
93
|
"types": "./dist/project.d.ts",
|
|
80
94
|
"import": "./dist/project.js",
|
|
81
95
|
"default": "./dist/project.js"
|
|
82
96
|
},
|
|
83
97
|
"./env": {
|
|
98
|
+
"@plitzi/source": "./src/env.ts",
|
|
84
99
|
"types": "./dist/env.d.ts",
|
|
85
100
|
"import": "./dist/env.js",
|
|
86
101
|
"default": "./dist/env.js"
|
|
@@ -96,13 +111,13 @@
|
|
|
96
111
|
"./dist/env.js"
|
|
97
112
|
],
|
|
98
113
|
"dependencies": {
|
|
99
|
-
"@plitzi/plitzi-sdk": "0.38.
|
|
100
|
-
"@plitzi/sdk-shared": "0.38.
|
|
101
|
-
"ejs": "^
|
|
114
|
+
"@plitzi/plitzi-sdk": "0.38.17",
|
|
115
|
+
"@plitzi/sdk-shared": "0.38.17",
|
|
116
|
+
"ejs": "^7.0.1",
|
|
102
117
|
"esbuild": "^0.28.2",
|
|
103
118
|
"jsonwebtoken": "^9.0.3",
|
|
104
|
-
"nodemailer": "^10.
|
|
105
|
-
"undici": "^8.
|
|
119
|
+
"nodemailer": "^10.1.2",
|
|
120
|
+
"undici": "^8.12.2",
|
|
106
121
|
"ws": "^8.22.0"
|
|
107
122
|
},
|
|
108
123
|
"peerDependencies": {
|
|
@@ -132,30 +147,30 @@
|
|
|
132
147
|
}
|
|
133
148
|
},
|
|
134
149
|
"devDependencies": {
|
|
135
|
-
"@microsoft/api-extractor": "^7.59.
|
|
150
|
+
"@microsoft/api-extractor": "^7.59.4",
|
|
136
151
|
"@types/ejs": "^3.1.5",
|
|
137
152
|
"@types/jsonwebtoken": "^9.0.10",
|
|
138
|
-
"@types/node": "^26.6.
|
|
153
|
+
"@types/node": "^26.6.5",
|
|
139
154
|
"@types/nodemailer": "^8.0.2",
|
|
140
155
|
"@types/react": "^19.3.0",
|
|
141
156
|
"@types/ws": "^8.18.2",
|
|
142
|
-
"@vitejs/plugin-react": "^6.1.
|
|
143
|
-
"@vitest/coverage-v8": "^5.0.
|
|
157
|
+
"@vitejs/plugin-react": "^6.1.2",
|
|
158
|
+
"@vitest/coverage-v8": "^5.0.5",
|
|
144
159
|
"core-js": "^3.50.0",
|
|
145
160
|
"eslint": "^9.39.5",
|
|
146
161
|
"eslint-plugin-import": "^2.32.0",
|
|
147
162
|
"ioredis": "^6.0.0",
|
|
148
163
|
"isolated-vm": "^7.0.1",
|
|
149
164
|
"mongodb": "^7.7.0",
|
|
150
|
-
"mysql2": "^3.24.
|
|
151
|
-
"react": "^19.3.
|
|
152
|
-
"react-dom": "^19.3.
|
|
165
|
+
"mysql2": "^3.24.6",
|
|
166
|
+
"react": "^19.3.1",
|
|
167
|
+
"react-dom": "^19.3.1",
|
|
153
168
|
"sharp": "^0.35.5",
|
|
154
169
|
"tsx": "^4.23.15",
|
|
155
170
|
"typescript": "^6.0.3",
|
|
156
|
-
"vite": "^8.3.
|
|
171
|
+
"vite": "^8.3.4",
|
|
157
172
|
"vite-plugin-dts": "^5.1.2",
|
|
158
|
-
"vitest": "^5.0.
|
|
173
|
+
"vitest": "^5.0.5"
|
|
159
174
|
},
|
|
160
175
|
"scripts": {
|
|
161
176
|
"prepack": "node scripts/copy-authoring-skill.mjs",
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|