@plitzi/sdk-shared 0.38.20 → 0.38.22

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 (39) hide show
  1. package/CHANGELOG.md +133 -0
  2. package/dist/actions/access.d.ts +5 -0
  3. package/dist/actions/access.mjs +11 -2
  4. package/dist/actions/index.d.ts +2 -1
  5. package/dist/actions/index.mjs +10 -9
  6. package/dist/actions/jobs.d.ts +10 -0
  7. package/dist/actions/jobs.mjs +17 -0
  8. package/dist/actions/validateDocument.mjs +56 -56
  9. package/dist/dataSource/globalSources.d.ts +1 -1
  10. package/dist/navigation/routes.mjs +38 -37
  11. package/dist/network/graphql/builder/Mutations/Space/jobs/SpaceControlJobMutation.d.ts +5 -0
  12. package/dist/network/graphql/builder/Mutations/Space/jobs/SpaceControlJobMutation.mjs +4 -0
  13. package/dist/network/graphql/builder/Mutations/index.d.ts +2 -0
  14. package/dist/network/graphql/builder/Mutations/index.mjs +70 -68
  15. package/dist/network/graphql/builder/Queries/Space/SpaceDeploymentsQuery.d.ts +1 -1
  16. package/dist/network/graphql/builder/Queries/Space/SpaceDeploymentsQuery.mjs +1 -1
  17. package/dist/network/graphql/builder/Queries/Space/SpaceJobsQuery.d.ts +10 -0
  18. package/dist/network/graphql/builder/Queries/Space/SpaceJobsQuery.mjs +4 -0
  19. package/dist/network/graphql/builder/Queries/index.d.ts +2 -0
  20. package/dist/network/graphql/builder/Queries/index.mjs +16 -14
  21. package/dist/realtime/index.d.ts +1 -1
  22. package/dist/realtime/index.mjs +4 -4
  23. package/dist/realtime/topics.d.ts +5 -0
  24. package/dist/realtime/topics.mjs +11 -11
  25. package/dist/schema/index.d.ts +1 -0
  26. package/dist/schema/index.mjs +12 -11
  27. package/dist/schema/pageAccess.d.ts +41 -0
  28. package/dist/schema/pageAccess.mjs +54 -0
  29. package/dist/store/storeHooks.d.ts +33 -33
  30. package/dist/types/ActionTypes.d.ts +0 -204
  31. package/dist/types/FunctionTypes.d.ts +41 -0
  32. package/dist/types/JobTypes.d.ts +327 -0
  33. package/dist/types/JobTypes.mjs +0 -0
  34. package/dist/types/ServerTypes.d.ts +17 -3
  35. package/dist/types/SpaceTypes.d.ts +5 -0
  36. package/dist/types/index.d.ts +1 -0
  37. package/package.json +1 -1
  38. package/vite.config.ts +9 -7
  39. package/dist/helpers/twigWrapper/bench.bench.d.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,138 @@
1
1
  # @plitzi/sdk-shared
2
2
 
3
+ ## 0.38.22
4
+
5
+ ### Patch Changes
6
+
7
+ - 19fbc45: ## Server
8
+
9
+ - **`ctx.oauth`, after a project moved onto it** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`) — PZ-155..158.
10
+ `functions.oauth.callbackOrigin` fixes the one address providers send a visitor back to, on a server of one space
11
+ reached on several: `serveProject` sets it to the address people reach it on, or its loopback `127.0.0.1` when that is
12
+ plain HTTP (providers refuse `http` past loopback, and `localhost`), and prints it as it starts; the callback then sends
13
+ the visitor on to `returnTo` on the address they started from — its `location` is absolute now. `connect(name,
14
+ { returnTo, authorizeParams })` adds to the connection's parameters for one consent (`prompt: 'select_account'`), and
15
+ refuses one the platform writes. `ctx.fetch` and `ctx.oauth.fetch` take `init.signal`: in the sandbox and a runtime the
16
+ request is numbered and the code's `abort` cuts it on the platform. `ActionRefusal` takes `{ code }`; `ctx.oauth`
17
+ refuses with `oauth-not-connected` and `oauth-no-owner`.
18
+ - **A refusal of the platform's stays one across the sandbox** (`@plitzi/sdk-server`). A call answered with an
19
+ `ActionRefusal` crossed the isolate, the runner service and a runtime as a plain error: caught, the code could not tell
20
+ it apart; uncaught, a route answered 500 `This route failed` instead of 400 and the reason. The answer carries
21
+ `refused` and `code` now, and the code catches the refusal it was thrown.
22
+
23
+ ## 0.38.21
24
+
25
+ ### Patch Changes
26
+
27
+ - 19fbc45: ## Server
28
+
29
+ - **Jobs: work longer than a request** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`, `@plitzi/sdk-elements`,
30
+ `@plitzi/plitzi-sdk`, `@plitzi/sdk-authoring`) — PZ-136. A space's code declares them in
31
+ `defineFunctions({ jobs: { train: { watch, maxSeconds, run(input, job, ctx) } } })` and starts them with
32
+ `ctx.jobs.start(name, input, { key })` (`get`, `pause`, `resume`, `cancel` beside it). They run in the actions' durable
33
+ queue — leased, taken over when a server dies, retried with backoff — slice by slice, in the sandbox, in a space's
34
+ runtime and natively alike: `job.save(state)` is the one checkpoint and the next slice starts with `job.state`;
35
+ `job.report(fraction, step)` says how far it is; on `job.signal` (`job.stopping`: `pause`, `cancel`, `limit`,
36
+ `shutdown`) the code has 5 s to save and return. A sandbox slice runs at most `sliceMs` and goes on in the next if it
37
+ saved since it began — one that saved nothing fails, so a job cannot loop forever; a runtime's runs until the job's
38
+ time is up. A real pause: `paused` keeps what it saved until resumed. Who may watch it is RBAC: whoever started it, and
39
+ whoever its `watch` (a channel's access) lets in, on `$job:<id>` — the platform's topic, retained — read with
40
+ `useJob(id)` or a `channel` element on `$job:{{ id }}`; the view never carries its input, its state, or an error other
41
+ than the code's own refusal. Limits per space (its plan) through `functions.jobs.limitsFor` —
42
+ `DEFAULT_FUNCTION_JOB_LIMITS` otherwise: 10 running across the account's spaces (`pool`, the oldest first), 1,000
43
+ waiting, 6 h, slices of 5 min / 30 s CPU / 10,000 calls, 1 MB of state.
44
+ - **The queue's types are the queue's** (`@plitzi/sdk-shared`, `@plitzi/sdk-server`): `ActionJobQueue`, `ActionJob`,
45
+ `ActionJobInput`, `ActionJobStatus`, `ActionJobAttempt`, `ActionJobSettlement`, `ActionJobQuery` are `JobQueue`, `Job`,
46
+ `JobInput`, `JobStatus`, `JobAttempt`, `JobSettlement`, `JobQuery` (`ACTION_JOB_STATUSES` → `JOB_STATUSES`,
47
+ `isJobStatus`, `TERMINAL_JOB_STATUSES`) — the queue holds a schedule's fires, the runs set for later and the jobs of
48
+ the spaces' functions. **What a job runs is its `target`**: `{ kind: 'action', name, trigger }` or
49
+ `{ kind: 'function', name, user, watch, at }`, in place of `actionId`, `trigger` and `function`; `listJobs` filters
50
+ by `kind` and `name`. Also on the queue: `paused` with `pause`/`resume`, `write` for what a running job saves and
51
+ reports, `state`/`progress`/`result`/`activeMs`, `heartbeat` answering `{ jobId, stop: 'cancel' | 'pause' }[]`, a
52
+ settlement's explicit `refund`, `requeue(…, { input, fresh })`. The helpers bring a store a release before left up
53
+ to it by themselves: MySQL's `ensureJobTables` gives each job its target from `action_id`/`trigger_type` and drops
54
+ them (`mysqlJobSchemaUpgrades` lists the statements for a deployment's own migrations); Mongo's queue does the same
55
+ to the documents on first use and drops the `spaceId_1_actionId_1_updatedAt_-1` index. A deployment with a queue of
56
+ its own: the contract tests (`describeJobQueue`) say what it must now do.
57
+ - **A runtime's routes stream** (`@plitzi/sdk-server`): a route under `/fn/` answered by a space's runtime is passed on
58
+ as it is written — its head at once, its body as the code writes it, with the platform's `ctx` — over the functions
59
+ protocol's new `head`/`chunk` messages, with no time limit once it answered; the deployment's own routes stream too.
60
+ A runtime's `endpoints` are for addresses outside `/fn/` (an MCP server at `/mcp`); anything that can live under
61
+ `/fn/` is a route. A sandbox's routes are answered whole, as before.
62
+ - **`createJobControl({ queue, realtime: { pubsub, kv } })`** (`@plitzi/sdk-server/actions`): an operator's
63
+ `pause`/`resume`/`cancel`/`requeue` from a process that serves no pages — a Queue panel's API — each said on
64
+ `$job:<id>` through the page server's own pub/sub and retained store, so a watcher hears what an operator did.
65
+ - **A run's user carries no session** (`RunUser`): what a step, a function and a job see of who asked.
66
+ - **The builder shows the jobs** (`@plitzi/plitzi-builder`, `@plitzi/sdk-shared`): **Server → Functions** lists the
67
+ jobs the code declares as it is typed (how long each may run; one spread in or built by a call is counted, not
68
+ guessed), and the inspector of one says how it is started and who may watch it, with the space's runs of it — live
69
+ while one moves, progress and step as its code reported them — and **Pause**, **Resume**, **Cancel** and **Run
70
+ again**. Through two new builder operations, `SpaceJobs(kind, name, status, page, pageSize)` — a `SpaceJob` each:
71
+ what it runs, where it is and how far, never its input, state or result — and `SpaceControlJob(jobId, control)`
72
+ (`JobControlAction`). Beside them in `@plitzi/sdk-shared/actions`: `JOB_KINDS`/`isJobKind`, and `actionAccessOf`, the
73
+ one reading of a channel's access, which the functions' manifest now reads a job's `watch` with too.
74
+
75
+ - **`ctx.oauth.token` for an SDK in the page** (`@plitzi/sdk-server`, `@plitzi/sdk-shared`): Spotify's Web Playback,
76
+ Google's Picker and their kind ask the page for the access token themselves, and `ctx.oauth` kept every token on the
77
+ server. A connection that declares `exposeToken: true` now answers `ctx.oauth.token(name, { owner })` —
78
+ `{ token, type, expiresAt, scopes }`, renewed first when about to lapse — for a route of the code to hand to the
79
+ connection's owner. The refresh token never leaves; a connection without `exposeToken` refuses `token`, naming the
80
+ field. Through the sandbox's protocol and natively alike.
81
+
82
+ - **A page for some permissions, kept by the server** (`@plitzi/sdk-shared`, `@plitzi/sdk-server`,
83
+ `@plitzi/sdk-authoring`, `@plitzi/sdk-elements`, `@plitzi/plitzi-builder`): a page says
84
+ `access: { permissions: [...] }`, and a visitor without every one is answered 401 (or the page's sign-in redirect) or
85
+ 403 with a refusal drawn in the page's layout. Its content is withheld from everything that visitor is sent — the
86
+ render, the hydration payload, the space document (and a document built for somebody with access is not handed to
87
+ somebody without it by its name) and the page's server data. The builder's page settings take the permissions;
88
+ authoring refuses an `access` the server could not keep (`page-access`). A space read back as code — `plitzi create
89
+ --from`, the Export — keeps each page's `access`, so a protected page is never exported open. A page's handle carries
90
+ its `access` too, and a project's `visual/home.spec.ts` leaves such a page to a test that signs in, as it does a page
91
+ behind a session (`plitzi upgrade` rewrites an untouched one).
92
+ - **A project's first plugin is picked up while it runs** (`@plitzi/sdk-server`): `start:dev` registers a plugin folder
93
+ added under `src/plugins/` and reloads the open pages — but only watched that folder when it existed at boot, so a
94
+ project with no plugin yet (one taken out of a space that had none) showed nothing of its first `plitzi plugin add`
95
+ until a restart. With no folder, the server waits for it to appear and takes what it holds then.
96
+
97
+ ## Packaging
98
+ - **No package ships the declarations of its tests** (`@plitzi/sdk-server`, `@plitzi/sdk-mcp`, `@plitzi/plitzi-sdk`,
99
+ `@plitzi/plitzi-builder`, `@plitzi/sdk-elements`, `@plitzi/sdk-shared`): each app wrote its declarations with its own
100
+ `dts({ exclude })`, and the ones that left the tests out of it shipped a `.test.d.ts` beside their modules — 148 in
101
+ sdk-server alone — and the base config let a `.bench.d.ts` through. Every `dts()` now excludes
102
+ `'**/*.(test|bench).(ts|tsx)'`, and `yarn check:dist-exports` (CI, after `build:prod`) fails a build of any published
103
+ package that holds one.
104
+ - **`@plitzi/plitzi-builder` depends on `graphql` ^16** (was ^17): Apollo Server — the builder's API — supports only
105
+ 16, so a host installing the builder beside it got two copies. The builder uses nothing of 17's.
106
+
107
+ ## Elements
108
+ - **A dropdown closes when a link in it is chosen** (`@plitzi/sdk-elements`): a link stops its click from bubbling,
109
+ and the popup listened for clicks on the way up — so no menu of links ever closed, and a click that did reach it was
110
+ cancelled, which would have kept an external link from going anywhere. The popup now hears the click as it goes down
111
+ and lets it through.
112
+
113
+ ## CLI
114
+ - **A refused push says why** (`@plitzi/cli`): `space push functions` and the data push read any 409 as "changed since
115
+ your pull" — and the platform also answers 409 when the space has no private bucket to keep its code or data in, so
116
+ a first push to a space with no storage sent its author to pull, which changed nothing. The CLI now names a conflict
117
+ only when the refusal says `version`, and prints the platform's own words otherwise (where to add the bucket).
118
+ - **`create` points at the Academy** (`@plitzi/cli`): its last lines name the docs' Academy,
119
+ `https://docs.plitzi.com/academy`, for whoever is new to Plitzi — and the README the docs themselves.
120
+
121
+ ## Builder
122
+ - **A space served by Plitzi has a server, and the builder says so** (`@plitzi/plitzi-builder`, `@plitzi/sdk-shared`):
123
+ whether a space can run its actions and resolve its connectors was read off an SSR _credential_, which only a space
124
+ deployed to a page server of its own has — so every space served at `<space>.plitzi.app` showed "No server-rendered
125
+ deployment" over Server and counted its actions unavailable, while they ran. The deployments now carry what serves
126
+ them (`provider`), and a deployment served by SSR — Plitzi's or the space's — counts.
127
+ - **New Layout saves the layout** (`@plitzi/sdk-schema`): a layout is a root of the pages' tree, added with no anchor,
128
+ and `flatMapOf` found no tree for an empty anchor — so the server refused every new layout, saying it was "already
129
+ added". A root now goes into the pages' tree, and the refusal says which of the two it is.
130
+ - **Settings → Realtime: a space's channels, declared by hand** (`@plitzi/plitzi-builder`): `settings.channels` was
131
+ written only in code or by an agent over MCP, so a space made in the builder could not open a channel. The section
132
+ lists the channels with who may join (anyone, signed-in visitors, visitors with permissions), who may speak (pages, or
133
+ only the server's `Publish On Channel`), presence, a grant, keeping the last message and the two limits — saved only
134
+ when `channelProblems` passes, with what is wrong said under the channel otherwise.
135
+
3
136
  ## 0.38.20
4
137
 
5
138
  ### Patch Changes
@@ -10,3 +10,8 @@ export type AccessCaller = {
10
10
  * `session` and `role` cannot come to mean two things in two places.
11
11
  */
12
12
  export declare const accessRefusal: (access: ActionAccess | undefined, caller: AccessCaller) => "unauthenticated" | "forbidden" | undefined;
13
+ /**
14
+ * A value as access, when it is one — `{ mode: 'public' }`, `{ mode: 'session' }`, `{ mode: 'role', permissions }` with
15
+ * at least one permission — rebuilt field by field, or `undefined`: what a job's `watch` is read with wherever it is.
16
+ */
17
+ export declare const actionAccessOf: (value: unknown) => ActionAccess | undefined;
@@ -1,5 +1,6 @@
1
+ import { isRecord as e } from "../helpers/isRecord.mjs";
1
2
  //#region src/actions/access.ts
2
- var e = (e, t) => {
3
+ var t = (e, t) => {
3
4
  if (!e) return "forbidden";
4
5
  if (e.mode !== "public") {
5
6
  if (!t) return "unauthenticated";
@@ -8,6 +9,14 @@ var e = (e, t) => {
8
9
  return e.permissions.every((e) => n.has(e)) ? void 0 : "forbidden";
9
10
  }
10
11
  }
12
+ }, n = (t) => {
13
+ if (!e(t)) return;
14
+ if (t.mode === "public" || t.mode === "session") return { mode: t.mode };
15
+ let n = t.permissions;
16
+ if (t.mode === "role" && Array.isArray(n) && n.length > 0 && n.every((e) => typeof e == "string" && e !== "")) return {
17
+ mode: "role",
18
+ permissions: n.filter((e) => typeof e == "string")
19
+ };
11
20
  };
12
21
  //#endregion
13
- export { e as accessRefusal };
22
+ export { t as accessRefusal, n as actionAccessOf };
@@ -1,4 +1,5 @@
1
- export { accessRefusal } from './access';
1
+ export { accessRefusal, actionAccessOf } from './access';
2
+ export { JOB_KINDS, JOB_STATUSES, TERMINAL_JOB_STATUSES, isJobKind, isJobStatus, isTerminalJobStatus } from './jobs';
2
3
  export { cronFiresBetween, cronMatches, cronNextFire, isKnownTimeZone, parseCron, zonedClock } from './cron';
3
4
  export { FAILURE_HANDLER_TASK } from './failureHandler';
4
5
  export { DEFAULT_FUNCTION_TIME_LIMITS, FUNCTION_ROUTES_PREFIX, isFunctionRoutePath, isFunctionsSourcePath, PLUGIN_FUNCTIONS_SOURCE, PLUGIN_ROUTES_SEGMENT, pluginRoutePath, readFunctionsSource } from './functions';
@@ -1,9 +1,10 @@
1
- import { accessRefusal as e } from "./access.mjs";
2
- import { cronFiresBetween as t, cronMatches as n, cronNextFire as r, isKnownTimeZone as i, parseCron as a, zonedClock as o } from "./cron.mjs";
3
- import { FAILURE_HANDLER_TASK as s } from "./failureHandler.mjs";
4
- import { DEFAULT_FUNCTION_TIME_LIMITS as c, FUNCTION_ROUTES_PREFIX as l, PLUGIN_FUNCTIONS_SOURCE as u, PLUGIN_ROUTES_SEGMENT as d, isFunctionRoutePath as f, isFunctionsSourcePath as p, pluginRoutePath as m, readFunctionsSource as h } from "./functions.mjs";
5
- import { triggerAccess as g, triggerCacheMs as _, triggerHasStaleVerify as v, triggerInput as y, triggerVerify as b } from "./triggerParams.mjs";
6
- import { actionName as x, actionTriggers as S, isActionEnabled as C } from "./triggers.mjs";
7
- import { isActionDocument as w, validateActionDocument as T } from "./validateDocument.mjs";
8
- import { SMTP_CREDENTIAL_KEYS as E, isSingleEmailAddress as D, readSmtpCredential as O } from "./smtp.mjs";
9
- export { c as DEFAULT_FUNCTION_TIME_LIMITS, s as FAILURE_HANDLER_TASK, l as FUNCTION_ROUTES_PREFIX, u as PLUGIN_FUNCTIONS_SOURCE, d as PLUGIN_ROUTES_SEGMENT, E as SMTP_CREDENTIAL_KEYS, e as accessRefusal, x as actionName, S as actionTriggers, t as cronFiresBetween, n as cronMatches, r as cronNextFire, w as isActionDocument, C as isActionEnabled, f as isFunctionRoutePath, p as isFunctionsSourcePath, i as isKnownTimeZone, D as isSingleEmailAddress, a as parseCron, m as pluginRoutePath, h as readFunctionsSource, O as readSmtpCredential, g as triggerAccess, _ as triggerCacheMs, v as triggerHasStaleVerify, y as triggerInput, b as triggerVerify, T as validateActionDocument, o as zonedClock };
1
+ import { accessRefusal as e, actionAccessOf as t } from "./access.mjs";
2
+ import { cronFiresBetween as n, cronMatches as r, cronNextFire as i, isKnownTimeZone as a, parseCron as o, zonedClock as s } from "./cron.mjs";
3
+ import { FAILURE_HANDLER_TASK as c } from "./failureHandler.mjs";
4
+ import { DEFAULT_FUNCTION_TIME_LIMITS as l, FUNCTION_ROUTES_PREFIX as u, PLUGIN_FUNCTIONS_SOURCE as d, PLUGIN_ROUTES_SEGMENT as f, isFunctionRoutePath as p, isFunctionsSourcePath as m, pluginRoutePath as h, readFunctionsSource as g } from "./functions.mjs";
5
+ import { JOB_KINDS as _, JOB_STATUSES as v, TERMINAL_JOB_STATUSES as y, isJobKind as b, isJobStatus as x, isTerminalJobStatus as S } from "./jobs.mjs";
6
+ import { triggerAccess as C, triggerCacheMs as w, triggerHasStaleVerify as T, triggerInput as E, triggerVerify as D } from "./triggerParams.mjs";
7
+ import { actionName as O, actionTriggers as k, isActionEnabled as A } from "./triggers.mjs";
8
+ import { isActionDocument as j, validateActionDocument as M } from "./validateDocument.mjs";
9
+ import { SMTP_CREDENTIAL_KEYS as N, isSingleEmailAddress as P, readSmtpCredential as F } from "./smtp.mjs";
10
+ export { l as DEFAULT_FUNCTION_TIME_LIMITS, c as FAILURE_HANDLER_TASK, u as FUNCTION_ROUTES_PREFIX, _ as JOB_KINDS, v as JOB_STATUSES, d as PLUGIN_FUNCTIONS_SOURCE, f as PLUGIN_ROUTES_SEGMENT, N as SMTP_CREDENTIAL_KEYS, y as TERMINAL_JOB_STATUSES, e as accessRefusal, t as actionAccessOf, O as actionName, k as actionTriggers, n as cronFiresBetween, r as cronMatches, i as cronNextFire, j as isActionDocument, A as isActionEnabled, p as isFunctionRoutePath, m as isFunctionsSourcePath, b as isJobKind, x as isJobStatus, a as isKnownTimeZone, P as isSingleEmailAddress, S as isTerminalJobStatus, o as parseCron, h as pluginRoutePath, g as readFunctionsSource, F as readSmtpCredential, C as triggerAccess, w as triggerCacheMs, T as triggerHasStaleVerify, E as triggerInput, D as triggerVerify, M as validateActionDocument, s as zonedClock };
@@ -0,0 +1,10 @@
1
+ import { JobStatus, JobTarget } from '../types/JobTypes';
2
+ /** Every status a job of the queue can be in — what a filter of the Queue accepts, read from one list. */
3
+ export declare const JOB_STATUSES: readonly ["pending", "running", "paused", "succeeded", "failed", "dead", "cancelled"];
4
+ /** The statuses a job ends in: kept readable for a while, and what an operator may run again. */
5
+ export declare const TERMINAL_JOB_STATUSES: readonly ["succeeded", "failed", "dead", "cancelled"];
6
+ export declare const isJobStatus: (value: unknown) => value is JobStatus;
7
+ export declare const isTerminalJobStatus: (status: JobStatus) => boolean;
8
+ /** What a job can run — one of the space's actions, or one of its functions' jobs: what a Queue's kind filter accepts. */
9
+ export declare const JOB_KINDS: readonly ["action", "function"];
10
+ export declare const isJobKind: (value: unknown) => value is JobTarget["kind"];
@@ -0,0 +1,17 @@
1
+ //#region src/actions/jobs.ts
2
+ var e = [
3
+ "pending",
4
+ "running",
5
+ "paused",
6
+ "succeeded",
7
+ "failed",
8
+ "dead",
9
+ "cancelled"
10
+ ], t = [
11
+ "succeeded",
12
+ "failed",
13
+ "dead",
14
+ "cancelled"
15
+ ], n = (t) => e.some((e) => e === t), r = (e) => t.some((t) => t === e), i = ["action", "function"], a = (e) => i.some((t) => t === e);
16
+ //#endregion
17
+ export { i as JOB_KINDS, e as JOB_STATUSES, t as TERMINAL_JOB_STATUSES, a as isJobKind, n as isJobStatus, r as isTerminalJobStatus };
@@ -1,6 +1,6 @@
1
- import { isKnownTimeZone as e, parseCron as t } from "./cron.mjs";
2
- import { FAILURE_HANDLER_TASK as n } from "./failureHandler.mjs";
3
- import { isRecord as r } from "../helpers/isRecord.mjs";
1
+ import { isRecord as e } from "../helpers/isRecord.mjs";
2
+ import { isKnownTimeZone as t, parseCron as n } from "./cron.mjs";
3
+ import { FAILURE_HANDLER_TASK as r } from "./failureHandler.mjs";
4
4
  import { triggerAccess as i, triggerHasStaleVerify as a, triggerVerify as o } from "./triggerParams.mjs";
5
5
  //#region src/actions/validateDocument.ts
6
6
  var s = [
@@ -30,29 +30,29 @@ var s = [
30
30
  "runId",
31
31
  "now",
32
32
  "failure"
33
- ]), f = /^[a-z][a-zA-Z0-9]*\.[a-z][a-zA-Z0-9]*$/, p = (e) => typeof e == "string" && e.trim() !== "", m = (e) => {
33
+ ]), f = /^[a-z][a-zA-Z0-9]*\.[a-z][a-zA-Z0-9]*$/, p = (e) => typeof e == "string" && e.trim() !== "", m = (t) => {
34
34
  try {
35
- let t = JSON.parse(e);
36
- return r(t) ? t : void 0;
35
+ let n = JSON.parse(t);
36
+ return e(n) ? n : void 0;
37
37
  } catch {
38
38
  return;
39
39
  }
40
- }, h = (e, t, n) => {
41
- e !== void 0 && (r(e) ? Object.entries(e).forEach(([e, i]) => {
42
- !r(i) || !p(i.type) ? n.push({
43
- path: `${t}.${e}`,
40
+ }, h = (t, n, r) => {
41
+ t !== void 0 && (e(t) ? Object.entries(t).forEach(([t, i]) => {
42
+ !e(i) || !p(i.type) ? r.push({
43
+ path: `${n}.${t}`,
44
44
  message: "must declare a type"
45
- }) : s.includes(i.type) || n.push({
46
- path: `${t}.${e}.type`,
45
+ }) : s.includes(i.type) || r.push({
46
+ path: `${n}.${t}.type`,
47
47
  message: `unknown field type "${i.type}"`,
48
48
  hint: `one of ${s.join(", ")}`
49
49
  });
50
- }) : n.push({
51
- path: t,
50
+ }) : r.push({
51
+ path: n,
52
52
  message: "must be an object of field definitions"
53
53
  }));
54
- }, g = (n, s, d, f) => {
55
- let g = `nodes.${n}`, _ = s.action;
54
+ }, g = (r, s, d, f) => {
55
+ let g = `nodes.${r}`, _ = s.action;
56
56
  if (!p(_) || !l.includes(_)) {
57
57
  d.push({
58
58
  path: `${g}.action`,
@@ -61,7 +61,7 @@ var s = [
61
61
  });
62
62
  return;
63
63
  }
64
- let v = r(s.params) ? s.params : {};
64
+ let v = e(s.params) ? s.params : {};
65
65
  if (p(v.input)) {
66
66
  let e = m(v.input);
67
67
  e === void 0 ? d.push({
@@ -83,14 +83,14 @@ var s = [
83
83
  });
84
84
  }
85
85
  }
86
- if (_ === "schedule" && (p(v.cron) ? t(v.cron) || d.push({
86
+ if (_ === "schedule" && (p(v.cron) ? n(v.cron) || d.push({
87
87
  path: `${g}.params.cron`,
88
88
  message: `"${v.cron}" is not an expression this server can read, so it would never fire`,
89
89
  hint: "five fields — minute hour day-of-month month day-of-week — with *, lists, ranges and steps"
90
90
  }) : d.push({
91
91
  path: `${g}.params.cron`,
92
92
  message: "a scheduled trigger needs a cron expression"
93
- }), p(v.timezone) && !e(v.timezone) && d.push({
93
+ }), p(v.timezone) && !t(v.timezone) && d.push({
94
94
  path: `${g}.params.timezone`,
95
95
  message: `"${v.timezone}" is not a time zone this server knows, so the schedule would never fire`,
96
96
  hint: "an IANA name like America/Santiago or Europe/Madrid — leave it empty for UTC"
@@ -129,15 +129,15 @@ var s = [
129
129
  message: "anyone can run this action, including signed-out visitors",
130
130
  hint: "use session access unless the page needs it before anyone signs in"
131
131
  });
132
- }, _ = (e, t, i, a) => {
133
- if (!r(e)) {
132
+ }, _ = (t, n, i, a) => {
133
+ if (!e(t)) {
134
134
  i.push({
135
135
  path: "nodes",
136
136
  message: "must be an object of steps"
137
137
  });
138
138
  return;
139
139
  }
140
- let o = Object.entries(e), s = o.filter(([, e]) => r(e) && e.type === "trigger");
140
+ let o = Object.entries(t), s = o.filter(([, t]) => e(t) && t.type === "trigger");
141
141
  s.length === 0 && i.push({
142
142
  path: "nodes",
143
143
  message: "this action has no way in",
@@ -152,18 +152,18 @@ var s = [
152
152
  message: `this action has ${e.length} "${t}" triggers`,
153
153
  hint: "one step per way in — a second flow starts from a different kind of trigger"
154
154
  });
155
- }), o.forEach(([t, n]) => {
156
- let o = `nodes.${t}`;
157
- r(n) ? n.type === "trigger" ? g(t, n, i, a) : n.type === "task" ? !p(n.action) || !f.test(n.action) ? i.push({
155
+ }), o.forEach(([n, r]) => {
156
+ let o = `nodes.${n}`;
157
+ e(r) ? r.type === "trigger" ? g(n, r, i, a) : r.type === "task" ? !p(r.action) || !f.test(r.action) ? i.push({
158
158
  path: `${o}.action`,
159
159
  message: "must name a task as <namespace>.<action>",
160
160
  hint: "for example flow.output or http.request"
161
- }) : p(n.afterNode) && !Object.hasOwn(e, n.afterNode) && i.push({
161
+ }) : p(r.afterNode) && !Object.hasOwn(t, r.afterNode) && i.push({
162
162
  path: `${o}.afterNode`,
163
- message: `points at "${n.afterNode}", which is not a step here`
163
+ message: `points at "${r.afterNode}", which is not a step here`
164
164
  }) : i.push({
165
165
  path: `${o}.type`,
166
- message: `"${String(n.type)}" steps run in the browser and cannot run on the server`,
166
+ message: `"${String(r.type)}" steps run in the browser and cannot run on the server`,
167
167
  hint: "a server action is made of task steps"
168
168
  }) : i.push({
169
169
  path: o,
@@ -177,16 +177,16 @@ var s = [
177
177
  });
178
178
  });
179
179
  let l = /* @__PURE__ */ new Set(), u = /* @__PURE__ */ new Set(), m = [];
180
- s.forEach(([t]) => {
181
- let n = /* @__PURE__ */ new Set(), r = [], i = t;
180
+ s.forEach(([e]) => {
181
+ let n = /* @__PURE__ */ new Set(), r = [], i = e;
182
182
  for (; i;) {
183
183
  if (n.has(i)) {
184
184
  u.add(i);
185
185
  break;
186
186
  }
187
187
  n.add(i), r.push(i), l.add(i);
188
- let t = e[i];
189
- i = p(t?.afterNode) ? t.afterNode : "";
188
+ let e = t[i];
189
+ i = p(e?.afterNode) ? e.afterNode : "";
190
190
  }
191
191
  m.push(r);
192
192
  }), u.forEach((e) => {
@@ -202,11 +202,11 @@ var s = [
202
202
  hint: "chain it with `afterNode` from a trigger, or delete it"
203
203
  });
204
204
  });
205
- let h = (t) => e[t]?.action, _ = o.filter(([, e]) => r(e) && e.action === "flow.output");
206
- for (let [t, n] of _) {
205
+ let h = (e) => t[e]?.action, _ = o.filter(([, t]) => e(t) && t.action === "flow.output");
206
+ for (let [e, n] of _) {
207
207
  let r = p(n.afterNode) && h(n.afterNode) === "flow.onFailure";
208
- p(n.afterNode) && Object.hasOwn(e, n.afterNode) && !r && a.push({
209
- path: `nodes.${t}.afterNode`,
208
+ p(n.afterNode) && Object.hasOwn(t, n.afterNode) && !r && a.push({
209
+ path: `nodes.${e}.afterNode`,
210
210
  message: "the output step is not the last one, so the steps after it run for nothing",
211
211
  hint: "move flow.output to the end of the flow"
212
212
  });
@@ -215,15 +215,15 @@ var s = [
215
215
  v.has(`${t.path}|${t.message}`) || (v.add(`${t.path}|${t.message}`), e.push(t));
216
216
  };
217
217
  m.forEach((e) => {
218
- let t = e.findIndex((e) => h(e) === n);
218
+ let t = e.findIndex((e) => h(e) === r);
219
219
  if (t === -1) return;
220
- let r = e[t];
220
+ let n = e[t];
221
221
  t === 1 && y(a, {
222
- path: `nodes.${r}`,
222
+ path: `nodes.${n}`,
223
223
  message: "nothing runs before this step, so nothing can fail and the steps after it never run",
224
224
  hint: "put On Failure after the steps whose work it undoes"
225
225
  }), t === e.length - 1 && y(a, {
226
- path: `nodes.${r}`,
226
+ path: `nodes.${n}`,
227
227
  message: "nothing follows this step, so a failed run undoes nothing",
228
228
  hint: "add the steps that give back what the flow already did"
229
229
  }), e.slice(t + 1).forEach((e) => {
@@ -237,39 +237,39 @@ var s = [
237
237
  hint: "move flow.output before On Failure"
238
238
  });
239
239
  });
240
- }), _.length === 0 && r(t) && Object.keys(t).length > 0 && a.push({
240
+ }), _.length === 0 && e(n) && Object.keys(n).length > 0 && a.push({
241
241
  path: "nodes",
242
242
  message: "this action is expected to answer values but no step names any",
243
243
  hint: "add a flow.output step at the end naming what the caller should get"
244
244
  });
245
- }, v = /\{\{\s*credential\./, y = (e, t) => {
246
- Object.entries(e).forEach(([e, n]) => {
247
- if (!r(n) || !r(n.params)) return;
248
- let i = p(n.params.credential) ? n.params.credential : "";
249
- Object.entries(n.params).forEach(([n, r]) => {
250
- typeof r == "string" && v.test(r) && i === "" && t.push({
251
- path: `nodes.${e}.params.${n}`,
245
+ }, v = /\{\{\s*credential\./, y = (t, n) => {
246
+ Object.entries(t).forEach(([t, r]) => {
247
+ if (!e(r) || !e(r.params)) return;
248
+ let i = p(r.params.credential) ? r.params.credential : "";
249
+ Object.entries(r.params).forEach(([e, r]) => {
250
+ typeof r == "string" && v.test(r) && i === "" && n.push({
251
+ path: `nodes.${t}.params.${e}`,
252
252
  message: "this step reads a credential it did not ask for, so the token resolves to nothing",
253
253
  hint: "set the step’s `credential` to the identifier it should use"
254
254
  });
255
255
  });
256
256
  });
257
- }, b = (e) => {
258
- let t = [], n = [];
259
- return r(e) ? (p(e.name) || t.push({
257
+ }, b = (t) => {
258
+ let n = [], r = [];
259
+ return e(t) ? (p(t.name) || n.push({
260
260
  path: "name",
261
261
  message: "must have a name"
262
- }), h(e.output, "output", t), _(e.nodes, e.output, t, n), y(r(e.nodes) ? e.nodes : {}, n), {
263
- valid: t.length === 0,
264
- errors: t,
265
- warnings: n
262
+ }), h(t.output, "output", n), _(t.nodes, t.output, n, r), y(e(t.nodes) ? t.nodes : {}, r), {
263
+ valid: n.length === 0,
264
+ errors: n,
265
+ warnings: r
266
266
  }) : {
267
267
  valid: !1,
268
268
  errors: [{
269
269
  path: "",
270
270
  message: "the document must be an object"
271
271
  }],
272
- warnings: n
272
+ warnings: r
273
273
  };
274
274
  }, x = (e) => b(e).valid;
275
275
  //#endregion
@@ -12,7 +12,7 @@ export type GlobalSource = (typeof GLOBAL_SOURCES)[number];
12
12
  * What a computed value is evaluated over: every global but `state`, which a flow hands it live, and `computed`, which
13
13
  * is what is being evaluated.
14
14
  */
15
- export declare const COMPUTED_GLOBALS: ("auth" | "navigation" | "flags" | "host" | "variables" | "theme")[];
15
+ export declare const COMPUTED_GLOBALS: ("auth" | "flags" | "host" | "navigation" | "variables" | "theme")[];
16
16
  /**
17
17
  * The fields of the globals whose shape the platform decides, as `GlobalSources` publishes them: a read of any other
18
18
  * — `auth.authenticated` for `auth.isAuthenticated` — resolves to nothing, and the authoring linter says so. An `open`
@@ -1,13 +1,14 @@
1
1
  import { matchPath as e } from "./matchPath.mjs";
2
+ import { pageWithheldOf as t } from "../schema/pageAccess.mjs";
2
3
  //#region src/navigation/routes.ts
3
- var t = (e) => /^https?:\/\//i.test(e), n = "*", r = (e) => t(e) || e.includes("{{"), i = (e) => e.replaceAll(/\/+/g, "/"), a = (e) => i(e.replace(/{{([a-zA-Z0-9-_:*/]+)}}/gi, ":$1")), o = (e, t) => {
4
+ var n = (e) => /^https?:\/\//i.test(e), r = "*", i = (e) => n(e) || e.includes("{{"), a = (e) => e.replaceAll(/\/+/g, "/"), o = (e) => a(e.replace(/{{([a-zA-Z0-9-_:*/]+)}}/gi, ":$1")), s = (e, t) => {
4
5
  if (!t || !e[t]) return "";
5
6
  let { slug: n, parentId: r } = e[t];
6
- return r ? `${o(e, r)}/${n}` : n;
7
+ return r ? `${s(e, r)}/${n}` : n;
7
8
  };
8
- function s(e, t, n, r = !1) {
9
- let s = n.replace(/^\/+/, ""), { slug: c = "", folder: l, default: u } = e[s]?.attributes ?? {
10
- slug: s,
9
+ function c(e, t, n, r = !1) {
10
+ let i = n.replace(/^\/+/, ""), { slug: c = "", folder: l, default: u } = e[i]?.attributes ?? {
11
+ slug: i,
11
12
  folder: "",
12
13
  default: !1
13
14
  };
@@ -17,47 +18,47 @@ function s(e, t, n, r = !1) {
17
18
  };
18
19
  if (u && r) return "/";
19
20
  if (!l && !r) return {
20
- [a(`/${c}`)]: n,
21
- [a(`/${n}`)]: n
21
+ [o(`/${c}`)]: n,
22
+ [o(`/${n}`)]: n
22
23
  };
23
- if (!l && r) return i(`/${c}`);
24
- if (!t.find((e) => e.id === l)) return r ? i(`/${c}`) : {
25
- [a(`/${c}`)]: n,
26
- [a(`/${n}`)]: n
24
+ if (!l && r) return a(`/${c}`);
25
+ if (!t.find((e) => e.id === l)) return r ? a(`/${c}`) : {
26
+ [o(`/${c}`)]: n,
27
+ [o(`/${n}`)]: n
27
28
  };
28
- let d = [o(t.reduce((e, t) => ({
29
+ let d = [s(t.reduce((e, t) => ({
29
30
  ...e,
30
31
  [t.id]: t
31
32
  }), {}), l), c].filter(Boolean).join("/");
32
- return r ? i(`/${d}`) : {
33
- [a(`/${d}`)]: n,
34
- [a(`/${n}`)]: n
33
+ return r ? a(`/${d}`) : {
34
+ [o(`/${d}`)]: n,
35
+ [o(`/${n}`)]: n
35
36
  };
36
37
  }
37
- var c = (e, t, n) => {
38
+ var l = (e, t, n) => {
38
39
  let r = n.indexOf("#");
39
- if (r > 0) return `${c(e, t, n.slice(0, r))}${n.slice(r)}`;
40
+ if (r > 0) return `${l(e, t, n.slice(0, r))}${n.slice(r)}`;
40
41
  let i = e[n];
41
42
  if (!i) return n;
42
43
  let { slug: a, default: o } = i.attributes;
43
- return typeof a == "string" ? s(e, t, n, !0) : o ? "/" : `/${n}`;
44
- }, l = (e, t, n = !0) => !e || !n || t === void 0 || t && e === "authenticated" || !t && e === "public" ? !0 : t && e === "public" ? !1 : !e, u = (e = {}, t = [], n, i = "", a = !0) => Object.keys(e).reduce((o, c) => {
45
- let { attributes: { accessLevel: u, enabled: d = !0, unauthorizedBehaviour: f } } = e[c], p = e[c].attributes.unauthorizedPageRedirect;
46
- if (!d && a) return o;
47
- p &&= r(p) ? p : s(e, t, p, !0);
48
- let m = s(e, t, c), h = e[c].attributes.slug === "*", g = Object.keys(m).map((e) => ({
49
- pageId: c,
50
- path: `${i}${e}`.replaceAll("//", "/"),
51
- accessLevel: u,
52
- enabled: d,
53
- isRaw: `/${c}` === e,
54
- unauthorizedBehaviour: f,
55
- unauthorizedPageRedirect: p,
56
- hasAccess: l(u, n, a),
57
- ...h ? { notFound: !0 } : {}
44
+ return typeof a == "string" ? c(e, t, n, !0) : o ? "/" : `/${n}`;
45
+ }, u = (e, t, n = !0) => !e || !n || t === void 0 || t && e === "authenticated" || !t && e === "public" ? !0 : t && e === "public" ? !1 : !e, d = (e = {}, n = [], r, a = "", o = !0) => Object.keys(e).reduce((s, l) => {
46
+ let { attributes: { accessLevel: d, enabled: f = !0, unauthorizedBehaviour: p } } = e[l], m = e[l].attributes.unauthorizedPageRedirect;
47
+ if (!f && o) return s;
48
+ m &&= i(m) ? m : c(e, n, m, !0);
49
+ let h = c(e, n, l), g = e[l].attributes.slug === "*", _ = Object.keys(h).map((n) => ({
50
+ pageId: l,
51
+ path: `${a}${n}`.replaceAll("//", "/"),
52
+ accessLevel: d,
53
+ enabled: f,
54
+ isRaw: `/${l}` === n,
55
+ unauthorizedBehaviour: p,
56
+ unauthorizedPageRedirect: m,
57
+ hasAccess: u(d, r, o) && !(t(e[l].attributes) === "unauthenticated" && p === "redirect" && m),
58
+ ...g ? { notFound: !0 } : {}
58
59
  }));
59
- return [...o, ...g];
60
- }, []).sort((e, t) => !!e.notFound == !!t.notFound ? e.path === t.path ? e.accessLevel === "authenticated" ? -1 : 1 : e.path > t.path ? -1 : 1 : e.notFound ? 1 : -1), d = (t, n, r) => {
60
+ return [...s, ..._];
61
+ }, []).sort((e, t) => !!e.notFound == !!t.notFound ? e.path === t.path ? e.accessLevel === "authenticated" ? -1 : 1 : e.path > t.path ? -1 : 1 : e.notFound ? 1 : -1), f = (t, n, r) => {
61
62
  if (!n) return {
62
63
  action: {
63
64
  type: "accessDenied",
@@ -106,9 +107,9 @@ var c = (e, t, n) => {
106
107
  },
107
108
  pathMatch: void 0
108
109
  };
109
- }, f = (t, n) => t.find((t) => t.hasAccess && t.notFound && e({
110
+ }, p = (t, n) => t.find((t) => t.hasAccess && t.notFound && e({
110
111
  path: t.path,
111
112
  end: !0
112
- }, n))?.pageId, p = (e) => !e || typeof e != "string" ? [] : (e.match(/:[a-zA-Z0-9-_:*]+/gim) || []).map((e) => e.replace(":", "")), m = (e) => p(a(e));
113
+ }, n))?.pageId, m = (e) => !e || typeof e != "string" ? [] : (e.match(/:[a-zA-Z0-9-_:*]+/gim) || []).map((e) => e.replace(":", "")), h = (e) => m(o(e));
113
114
  //#endregion
114
- export { n as NOT_FOUND_SLUG, s as getPageFullPath, u as getPaths, p as getRouteParams, m as getSlugParams, t as isAbsoluteUrl, l as isPageAuthored, d as matchRoutePath, c as navigationTarget, f as notFoundPageFor };
115
+ export { r as NOT_FOUND_SLUG, c as getPageFullPath, d as getPaths, m as getRouteParams, h as getSlugParams, n as isAbsoluteUrl, u as isPageAuthored, f as matchRoutePath, l as navigationTarget, p as notFoundPageFor };
@@ -0,0 +1,5 @@
1
+ import { SpaceJob } from '../../../../../../types';
2
+ export type TSpaceControlJobMutation = SpaceJob;
3
+ /** Pauses, resumes, cancels or runs again one of the space's jobs, and answers it as the queue now has it. */
4
+ declare const SpaceControlJobMutation = "\n mutation SpaceControlJobMutation($jobId: String!, $control: String!) {\n SpaceControlJob(jobId: $jobId, control: $control) {\n id\n environment\n kind\n name\n trigger\n startedBy\n status\n progress\n step\n error\n attempts\n maxAttempts\n activeMs\n pauseRequested\n cancelRequested\n key\n missed\n dueAt\n createdAt\n updatedAt\n }\n }\n";
5
+ export default SpaceControlJobMutation;
@@ -0,0 +1,4 @@
1
+ //#region src/network/graphql/builder/Mutations/Space/jobs/SpaceControlJobMutation.ts
2
+ var e = "\n mutation SpaceControlJobMutation($jobId: String!, $control: String!) {\n SpaceControlJob(jobId: $jobId, control: $control) {\n id\n environment\n kind\n name\n trigger\n startedBy\n status\n progress\n step\n error\n attempts\n maxAttempts\n activeMs\n pauseRequested\n cancelRequested\n key\n missed\n dueAt\n createdAt\n updatedAt\n }\n }\n";
3
+ //#endregion
4
+ export { e as default };
@@ -25,6 +25,7 @@ import { TSpaceInstallTemplateFunctionsMutation } from './Space/functions/SpaceI
25
25
  import { TSpaceRemoveFunctionsMutation } from './Space/functions/SpaceRemoveFunctionsMutation';
26
26
  import { TSpaceSaveFunctionsMutation } from './Space/functions/SpaceSaveFunctionsMutation';
27
27
  import { TSpaceTryFunctionMutation } from './Space/functions/SpaceTryFunctionMutation';
28
+ import { TSpaceControlJobMutation } from './Space/jobs/SpaceControlJobMutation';
28
29
  import { TSpaceAddPageMutation } from './Space/pages/SpaceAddPageMutation';
29
30
  import { TSpaceHomePageMutation } from './Space/pages/SpaceHomePageMutation';
30
31
  import { TSpaceRemovePageMutation } from './Space/pages/SpaceRemovePageMutation';
@@ -87,6 +88,7 @@ export type BuilderMutationsMap = {
87
88
  SpaceRemoveFunctions: TSpaceRemoveFunctionsMutation;
88
89
  SpaceInstallTemplateFunctions: TSpaceInstallTemplateFunctionsMutation;
89
90
  SpaceTryFunction: TSpaceTryFunctionMutation;
91
+ SpaceControlJob: TSpaceControlJobMutation;
90
92
  SpaceAddConnector: TSpaceAddConnectorMutation;
91
93
  SpaceUpdateConnector: TSpaceUpdateConnectorMutation;
92
94
  SpaceRemoveConnector: TSpaceRemoveConnectorMutation;