@ultimat3/cli 31.45.0 → 31.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CLAUDE.md +1 -1
- package/README.md +1 -1
- package/package.json +29 -29
- package/src/affected.ts +3 -2
- package/src/app-config-load.ts +8 -5
- package/src/app-mcp.ts +2 -5
- package/src/app-runtime.ts +4 -4
- package/src/cmd-cache.ts +8 -4
- package/src/cmd-deploy-compose.ts +11 -12
- package/src/cmd-deploy-helm.ts +5 -8
- package/src/cmd-exercise-spec.ts +2 -2
- package/src/cmd-exercise.ts +7 -19
- package/src/cmd-new.ts +4 -3
- package/src/cmd-planned.ts +11 -76
- package/src/cmd-shot-matrix.ts +3 -2
- package/src/cmd-token.ts +11 -3
- package/src/codemods/ci-weekly-schedule.ts +61 -0
- package/src/codemods/index.ts +2 -0
- package/src/codemods/vendored-guards.ts +3 -5
- package/src/codemods/verify-floor-skips.ts +4 -6
- package/src/codemods/verify-floor-steps.ts +4 -3
- package/src/db-seed.ts +3 -2
- package/src/dispatch.ts +2 -11
- package/src/duplicate-packages.ts +4 -4
- package/src/exercise-findings.ts +4 -3
- package/src/exercise-floor.ts +1 -1
- package/src/exercise-seed.ts +34 -0
- package/src/fix-command.ts +2 -3
- package/src/flag-reads.ts +6 -3
- package/src/generate-files.ts +10 -6
- package/src/gitignore.ts +4 -3
- package/src/guards-built-in.ts +3 -6
- package/src/guards.ts +5 -8
- package/src/island-bundle.ts +3 -2
- package/src/island-sources.ts +4 -3
- package/src/island-states-load.ts +4 -3
- package/src/island-store.ts +3 -2
- package/src/json-merge.ts +8 -6
- package/src/lint-findings.ts +4 -7
- package/src/mcp-errors.ts +1 -1
- package/src/messages.ts +1 -0
- package/src/prerender-out.ts +4 -3
- package/src/publish-closure.ts +4 -6
- package/src/pwa-manifest-locales.ts +5 -8
- package/src/registry.ts +0 -7
- package/src/root-env.ts +3 -2
- package/src/runtime-admin.ts +2 -4
- package/src/runtime-keys.ts +5 -2
- package/src/static-report.ts +5 -8
- package/src/templates/github/ci-schedule.ts +86 -0
- package/src/templates/github/ci.yml.ts +6 -8
- package/src/templates/github/dependabot.yml.ts +6 -1
- package/src/templates/invite-tests.ts +43 -6
- package/src/templates/invite.ts +12 -14
- package/src/templates/scaffold-docs.ts +1 -0
- package/src/templates/shapes/overlay.ts +4 -7
- package/src/templates/sign-in-action-tests.ts +71 -21
- package/src/templates/sign-in-password.ts +9 -5
- package/src/templates/sign-in-shared.ts +7 -15
- package/src/upgrade-guards-baseline.ts +3 -5
- package/src/verify-merge-skips.ts +2 -4
- package/src/verify-merge.ts +13 -8
- package/src/verify-part-step.ts +5 -7
- package/src/worker-bundle.ts +4 -2
- package/wiki/Actions.md +69 -5
- package/wiki/Agents.md +13 -0
- package/wiki/Auth.md +4 -0
- package/wiki/Batching-And-Preloading.md +77 -3
- package/wiki/CLI-Reference.md +18 -5
- package/wiki/Caching-And-Invalidation.md +76 -23
- package/wiki/Client-Navigation.md +2 -0
- package/wiki/Configuration.md +17 -4
- package/wiki/Entities-And-Migrations.md +168 -6
- package/wiki/FAQ.md +1 -1
- package/wiki/Feature-Flags.md +3 -0
- package/wiki/Getting-Started.md +27 -1
- package/wiki/Jobs-And-Workflows.md +70 -13
- package/wiki/Known-Gaps.md +58 -49
- package/wiki/MCP-And-AI.md +43 -3
- package/wiki/Mail.md +6 -0
- package/wiki/Migrations-And-Backfills.md +13 -0
- package/wiki/Money.md +20 -1
- package/wiki/N-Plus-One-Detection.md +31 -1
- package/wiki/Notify.md +13 -2
- package/wiki/PWA-And-Offline.md +34 -4
- package/wiki/Policies-And-Authz.md +27 -5
- package/wiki/Queries-And-Live-Queries.md +41 -4
- package/wiki/Realtime.md +22 -0
- package/wiki/Resource-Management.md +6 -1
- package/wiki/Routes-And-Render-Modes.md +54 -6
- package/wiki/SEO.md +24 -2
- package/wiki/Scheduled-Tasks.md +29 -11
- package/wiki/Scraping.md +33 -2
- package/wiki/Static-Assets.md +1 -0
- package/wiki/Storage-And-Uploads.md +8 -1
- package/wiki/Testing.md +120 -13
- package/wiki/The-Eight-Primitives.md +125 -6
- package/wiki/Timezones-And-Dates.md +13 -5
- package/wiki/Troubleshooting.md +1 -1
- package/wiki/Tutorial-02-First-Feature.md +6 -0
- package/wiki/Tutorial-03-Auth-And-Admin.md +8 -0
- package/wiki/Tutorial-04-Jobs-And-Realtime.md +40 -2
- package/wiki/Tutorial-06-Growing-Up.md +1 -2
- package/wiki/UI-Components.md +14 -5
- package/wiki/Upgrading.md +42 -4
package/wiki/PWA-And-Offline.md
CHANGED
|
@@ -43,15 +43,45 @@ The edit an agent should make is the route's `offline` field, and `x build` read
|
|
|
43
43
|
## Derived from the route
|
|
44
44
|
|
|
45
45
|
```ts
|
|
46
|
+
import { tag } from '@ultimat3/cache';
|
|
47
|
+
import { defineRoute } from '@ultimat3/render';
|
|
48
|
+
import { ld } from '@ultimat3/seo';
|
|
49
|
+
|
|
50
|
+
declare module '@ultimat3/cache' {
|
|
51
|
+
interface CacheTagRegistry {
|
|
52
|
+
post: true;
|
|
53
|
+
feed: true;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
interface Post {
|
|
58
|
+
readonly title: string;
|
|
59
|
+
readonly excerpt: string;
|
|
60
|
+
readonly cover: string;
|
|
61
|
+
readonly publishedAt: string;
|
|
62
|
+
readonly author: string;
|
|
63
|
+
}
|
|
64
|
+
declare function listPostSlugs(): Promise<readonly string[]>;
|
|
65
|
+
declare function loadPost(slug: string): Promise<Post>;
|
|
66
|
+
|
|
46
67
|
export const config = defineRoute({
|
|
47
68
|
render: 'isr', // static | isr | ssr | stream
|
|
48
69
|
revalidate: { tags: [tag.post] },
|
|
49
|
-
prerender: () =>
|
|
70
|
+
prerender: () => listPostSlugs(),
|
|
50
71
|
offline: 'precache', // precache | runtime | network-only
|
|
51
72
|
hydrate: 'visible', // idle | visible | interaction | never
|
|
52
73
|
budget: { js: '40kb' },
|
|
53
|
-
|
|
54
|
-
|
|
74
|
+
load: ({ params }) => loadPost(params['slug'] ?? ''),
|
|
75
|
+
meta: ({ data: post }) => ({
|
|
76
|
+
title: post.title,
|
|
77
|
+
description: post.excerpt,
|
|
78
|
+
og: { image: post.cover },
|
|
79
|
+
ld: [ld.Article({
|
|
80
|
+
headline: post.title,
|
|
81
|
+
datePublished: post.publishedAt,
|
|
82
|
+
author: { name: post.author },
|
|
83
|
+
})],
|
|
84
|
+
}),
|
|
55
85
|
});
|
|
56
86
|
```
|
|
57
87
|
|
|
@@ -258,7 +288,7 @@ The client is not broken and the server is not broken; they disagree about which
|
|
|
258
288
|
| 3 | **N-deploy asset retention** | `assets: { retain: { disk, builds } }` in `app.config.ts`: every web pod publishes its hashed files to that shared disk before it reports ready, and answers an earlier build's `/islands`, `/styles` and assets from it on a miss. Unset (the default), a pod serves only what it built. A **count of deploys, with no time component**. Proven in a browser `As of 2026-11`: a tab opened on build 0 survives six deploys that each change an island, and its first click boots build 0's chunk with a 200 and no 404 ([`six-deploys.e2e.test.ts`](https://github.com/developerz-ai/ultimate/blob/main/packages/cli/e2e/six-deploys.e2e.test.ts)); without `retain` the same click is a 404. `retentionPlan` was removed in 30.0.0: it kept nothing on its own, because no boot called it |
|
|
259
289
|
| 4 | **`AppUpdateAvailable` signal, not a 404** | a Solid signal flips when the server reports a newer build. The app renders its own "Update available — reload" affordance. **No forced navigation, no lost form state, no dinosaur** |
|
|
260
290
|
| 5 | **Forced reload after a grace period** | **Not a capability of this package.** Deleted in 9.0.0 — `updateSignal`/`updatePolicy` computed a deadline nothing acted on, and `pwa` (tier 4) sits above the two runtimes that hold both build ids. The service worker posts `{ type: 'AppUpdateAvailable', to }`; act on it yourself, or read `useConnection().updateAvailable` |
|
|
261
|
-
| 6 | **Skew is observable** | the `/_x` live panel reports the build-ID distribution of connected clients, so "how many users are three deploys behind" has an answer. Outside dev, `x status --url <origin> --json` reports the builds the serving processes answer with and every live worker's; the connected-clients distribution itself has no aggregate outside the sync node ([Known gaps](Known-Gaps#
|
|
291
|
+
| 6 | **Skew is observable** | the `/_x` live panel reports the build-ID distribution of connected clients, so "how many users are three deploys behind" has an answer. Outside dev, `x status --url <origin> --json` reports the builds the serving processes answer with and every live worker's; the connected-clients distribution itself has no aggregate outside the sync node ([Known gaps](Known-Gaps#open-by-decision)) |
|
|
262
292
|
| 7 | **Build ID scopes the SW cache** | preview/branch builds get their own cache namespace and SW scope, so a preview can never poison prod caches |
|
|
263
293
|
|
|
264
294
|
Server behaviour on a stale build ID:
|
|
@@ -3,7 +3,12 @@
|
|
|
3
3
|
One authz system. Authentication is `@ultimat3/auth` ([Auth](Auth)); **authorization is this page**, because it must be identical in HTTP, WebSocket, jobs, and MCP.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
|
-
|
|
6
|
+
import { can } from '@ultimat3/policy';
|
|
7
|
+
import { type Actor } from '@ultimat3/core';
|
|
8
|
+
|
|
9
|
+
declare function ownsPost(actor: Actor | null, postId: string): boolean;
|
|
10
|
+
|
|
11
|
+
policy: can<{ postId: string }>('post:publish', ({ input, actor }) => ownsPost(actor, input.postId))
|
|
7
12
|
```
|
|
8
13
|
|
|
9
14
|
## `can(permission, predicate)`
|
|
@@ -304,10 +309,27 @@ Generated with the primitive, fails until filled in:
|
|
|
304
309
|
|
|
305
310
|
```ts
|
|
306
311
|
// contract test — generated as a scaffold with the action
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
312
|
+
import { type Action, t } from '@ultimat3/action';
|
|
313
|
+
import { testActor } from '@ultimat3/policy';
|
|
314
|
+
import { contractTest, expect } from '@ultimat3/testing';
|
|
315
|
+
|
|
316
|
+
const PostView = t.object({ id: t.uuid, orgId: t.uuid, title: t.string });
|
|
317
|
+
const PublishPostInput = t.object({ postId: t.uuid });
|
|
318
|
+
declare const publishPost: Action<typeof PublishPostInput, typeof PostView>;
|
|
319
|
+
declare const postId: string;
|
|
320
|
+
|
|
321
|
+
// Named here because this file does not boot the app; at boot `defineApi` stamps the same name.
|
|
322
|
+
const target = publishPost.named('publishPost');
|
|
323
|
+
|
|
324
|
+
// Holds the grant, wrong org: a denial here is the policy deciding, not the permission check.
|
|
325
|
+
const outsider = testActor('outsider', {
|
|
326
|
+
orgId: '00000000-0000-4000-8000-000000000009',
|
|
327
|
+
permissions: ['post:publish'],
|
|
328
|
+
}).actor;
|
|
329
|
+
|
|
330
|
+
contractTest('publishPost denies a foreign org', async () => {
|
|
331
|
+
const denied = await target.as(outsider, { postId }).catch((error: unknown) => error);
|
|
332
|
+
expect(denied).toBeUltimateError('X_FORBIDDEN');
|
|
311
333
|
});
|
|
312
334
|
```
|
|
313
335
|
|
|
@@ -8,11 +8,27 @@ A `query` is a read. `live: true` makes it subscribable. Never writes, never enq
|
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
// query
|
|
11
|
+
import { from, query } from '@ultimat3/query';
|
|
12
|
+
import { t } from '@ultimat3/action';
|
|
13
|
+
import { can } from '@ultimat3/policy';
|
|
14
|
+
import { database, entity, timestamp, uuid } from '@ultimat3/entity';
|
|
15
|
+
|
|
16
|
+
const posts = entity('posts', {
|
|
17
|
+
tenant: 'orgId',
|
|
18
|
+
columns: { id: uuid().primaryKey(), orgId: uuid(), createdAt: timestamp().defaultNow() },
|
|
19
|
+
});
|
|
20
|
+
const db = database({ posts });
|
|
21
|
+
type Post = typeof posts.$row;
|
|
22
|
+
|
|
11
23
|
export const liveFeed = query({
|
|
12
24
|
input: t.object({ orgId: t.uuid }),
|
|
13
25
|
policy: can('feed:read'),
|
|
14
26
|
live: true,
|
|
15
|
-
sql: ({ orgId }) =>
|
|
27
|
+
sql: ({ orgId }) =>
|
|
28
|
+
from<Post>('posts', () => db.posts.where({ orgId }).all())
|
|
29
|
+
.where({ orgId })
|
|
30
|
+
.orderBy('createdAt')
|
|
31
|
+
.limit(50),
|
|
16
32
|
});
|
|
17
33
|
```
|
|
18
34
|
|
|
@@ -147,11 +163,26 @@ export const postRecord = query({
|
|
|
147
163
|
### A read of one object — `single: true`
|
|
148
164
|
|
|
149
165
|
```ts
|
|
166
|
+
import { from, query } from '@ultimat3/query';
|
|
167
|
+
import { t } from '@ultimat3/action';
|
|
168
|
+
import { can } from '@ultimat3/policy';
|
|
169
|
+
import { database, entity, text, uuid } from '@ultimat3/entity';
|
|
170
|
+
|
|
171
|
+
const posts = entity('posts', {
|
|
172
|
+
tenant: 'orgId',
|
|
173
|
+
columns: { id: uuid().primaryKey(), orgId: uuid(), title: text() },
|
|
174
|
+
});
|
|
175
|
+
const db = database({ posts });
|
|
176
|
+
type Post = typeof posts.$row;
|
|
177
|
+
|
|
150
178
|
export const postById = query({
|
|
151
179
|
input: t.object({ id: t.uuid }),
|
|
152
180
|
policy: can('post:read'),
|
|
153
181
|
single: true,
|
|
154
|
-
sql: ({ id }) =>
|
|
182
|
+
sql: ({ id }) =>
|
|
183
|
+
from<Post>('posts', () => db.posts.where({ id }).all())
|
|
184
|
+
.where({ id })
|
|
185
|
+
.limit(1),
|
|
155
186
|
});
|
|
156
187
|
// GET /_x/query/post-by-id?id=… → 200 { id, title, … } · 404 X_NOT_FOUND
|
|
157
188
|
// await postById.client({ baseUrl })({ id }) → Promise<Row>
|
|
@@ -173,6 +204,12 @@ export const postById = query({
|
|
|
173
204
|
|
|
174
205
|
```ts
|
|
175
206
|
// apps/web/shared/client.ts — the app's one place for both
|
|
207
|
+
import { rpc } from '@ultimat3/action';
|
|
208
|
+
import { queryClient } from '@ultimat3/query';
|
|
209
|
+
import type { Api } from '../api';
|
|
210
|
+
|
|
211
|
+
declare const baseUrl: string;
|
|
212
|
+
|
|
176
213
|
export const client = rpc<Api['actions']>({ baseUrl }); // writes
|
|
177
214
|
export const queries = queryClient<Api['queries']>({ baseUrl }); // reads
|
|
178
215
|
```
|
|
@@ -409,10 +446,10 @@ The contract. **Not yet a gate** — `As of 2026-08` `X_CACHE_UNTAGGED_QUERY` is
|
|
|
409
446
|
| Case | Today |
|
|
410
447
|
|---|---|
|
|
411
448
|
| a cached query no tag covers | cached under a key no `invalidates` fan-out reaches — stale until its `ttlMs`, and forever without one |
|
|
412
|
-
| a tag no entity declares | `X_CACHE_TAG_UNKNOWN`,
|
|
449
|
+
| a tag no entity declares | `X_CACHE_TAG_UNKNOWN`, whose fix is the `declareTags([...])` call to paste — the opposite mistake, and the one that is enforced |
|
|
413
450
|
| the `x verify` gate | no step reads a query's tags. Nothing fails |
|
|
414
451
|
|
|
415
|
-
Until it is a gate, tag coverage is a review item, not a build error. Declare the
|
|
452
|
+
Until it is a gate, tag coverage is a review item, not a build error. Declare the tag — `CacheTagRegistry` and `declareTags` in [Caching and invalidation](Caching-And-Invalidation).
|
|
416
453
|
|
|
417
454
|
## Subscription caps
|
|
418
455
|
|
package/wiki/Realtime.md
CHANGED
|
@@ -51,7 +51,28 @@ Tier 2 covers what people almost always mean by "make it realtime": the list upd
|
|
|
51
51
|
|
|
52
52
|
```ts
|
|
53
53
|
// mutator (action + optimistic local twin)
|
|
54
|
+
import { mutator, t } from '@ultimat3/action';
|
|
55
|
+
import { can } from '@ultimat3/policy';
|
|
56
|
+
|
|
57
|
+
declare module '@ultimat3/core' {
|
|
58
|
+
interface CtxServices {
|
|
59
|
+
readonly posts: {
|
|
60
|
+
publish(id: string): Promise<{ id: string; orgId: string; title: string }>;
|
|
61
|
+
like(id: string): Promise<{ likeCount: number; likedByMe: boolean }>;
|
|
62
|
+
body(id: string): Promise<string>;
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
declare module '@ultimat3/action' {
|
|
67
|
+
interface LocalTables {
|
|
68
|
+
posts: { likedByMe: boolean; likeCount: number };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
54
72
|
export const likePost = mutator({
|
|
73
|
+
input: t.object({ postId: t.uuid }),
|
|
74
|
+
output: t.object({ likeCount: t.number, likedByMe: t.boolean }),
|
|
75
|
+
policy: can('post:like'),
|
|
55
76
|
// REQUIRED (`X_MUTATOR_NOT_IDEMPOTENT`): a replay under the same Idempotency-Key answers the
|
|
56
77
|
// first result instead of running `server` again.
|
|
57
78
|
idempotent: true,
|
|
@@ -113,6 +134,7 @@ Opt-in per entity, and shipped in 21.0.0 (`CHANGELOG.md`). The 20.x shape (`stor
|
|
|
113
134
|
| a write with no response | only `X_CLIENT_TRANSPORT_FAILED` with `meta.failure: 'network'`: `useMutation` queues it in the page's one outbox under its idempotency key, keeps its overlay on screen, and resolves `undefined`. `'status'` rejects and drops the overlay; `'body'` (a 2xx that was not JSON, which may have landed) rejects and keeps the overlay until the next server row |
|
|
114
135
|
| two online calls of one mutator | sent in call order (**31.14.0**): one lane per mutator **name**, page-wide, so the next POST starts when the previous one settled — answered, queued or refused. Each overlay still paints at once; only the network leg waits. Before, a like then an unlike were POSTed together and could commit in either order. Different mutators never wait on each other. A write made while the browser is known offline never joins the lane: it reaches the outbox at once, so a POST hanging on a half-open socket cannot hold it off the disk. An online write that waited `LANE_WAIT_MS` (10 s) behind the previous one goes to the outbox under its key, and the writes after it queue behind it |
|
|
115
136
|
| replay | in order, over HTTP, each write with its original idempotency key: whenever the page socket (re)connects, on `online`, and on the service worker's `OUTBOX_DRAIN_MESSAGE` ([PWA and offline](PWA-And-Offline)). A retryable failure stops the pass; a refusal is final and rolls back its overlay. **At least once**: an entry leaves the disk when its ack is written, so a 2xx that reached a document already being replaced is sent again by the next one, under the same key — answered from the action's idempotency store (a `mutator()` is `idempotent: true` or it does not declare), never applied twice. A `409 X_IDEMPOTENCY_CONFLICT` for a first attempt still running stays queued and is asked again |
|
|
137
|
+
| whose session a replay runs under | **31.47.0**: each replay names its queue's principal in `x-ultimate-replay-scope`: `p:<principal>`, or `anon`; an unscoped page sends no header. The action route compares it with the session's scope before reading the body (`packages/action/src/replay-scope.ts`). Any other session, signed in or anonymous, is `409 X_REPLAY_PRINCIPAL_MISMATCH` and the handler does not run. The entry stays `pending` with its overlay, the pass stops so nothing overtakes it, and a later replay under the owner's session sends it. A signed-in queue treats a `401` `X_UNAUTHENTICATED` or `X_SESSION_EXPIRED` the same way. A request without the header, which is every ordinary call, is not checked. The scope id is keyed by `SESSION_SECRET` (32+ characters); unset, each process mints its own key, so a replay reaching another process than the one that rendered the page is refused |
|
|
116
138
|
| a write queued offline | flushes the persisted records it touched first, so a reload inside the 250 ms persist debounce keeps the row the write changed. No replay runs while `navigator.onLine` is `false` (`page-outbox.ts`) |
|
|
117
139
|
| a principal change | **within one page** (`rescope()`): the previous principal's rows and queue are wiped, and writes still queued are lost, deliberately. A replay on the wire at that moment is abandoned before its next write: nothing queued by one principal is sent under the next one's session. A write being queued at that moment is refused — `mutate` rejects with `X_OFFLINE_QUEUE_ABANDONED` and its optimistic twin is taken back. **A sign-out that navigates** to a new document (the reference app's idiom: the `endSession` action at `POST /api/sessions/end`, posted by a native form) clears the browser first: its response carries `signOutHeaders()` from `@ultimat3/auth`, whose `Clear-Site-Data: "cache", "storage"` drops IndexedDB, local storage, the service worker and its cache, in a secure context. The next boot is the second line: it wipes every stored scope except the current principal's before restoring anything (`packages/realtime/src/boot.ts`, `wipeOthers`). An unscoped page wipes nothing |
|
|
118
140
|
| blocked storage | memory, plus one `X_LOCAL_STORE_UNAVAILABLE` warning; nothing survives a reload |
|
|
@@ -22,8 +22,13 @@ only covers what someone remembered to put inside its `try`.
|
|
|
22
22
|
## The idiom
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
|
+
import type { ReservableClient } from '@ultimat3/db';
|
|
26
|
+
import { sql } from '@ultimat3/db';
|
|
27
|
+
|
|
28
|
+
declare const client: ReservableClient;
|
|
29
|
+
|
|
25
30
|
using connection = await client.reserve();
|
|
26
|
-
await connection.execute(sql
|
|
31
|
+
await connection.execute(sql`select 1`);
|
|
27
32
|
// released automatically here, however the block exits
|
|
28
33
|
```
|
|
29
34
|
|
|
@@ -7,15 +7,45 @@ A `route` is a URL + render mode + metadata + offline strategy. Render mode is a
|
|
|
7
7
|
## The canonical shape
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
|
+
import { tag } from '@ultimat3/cache';
|
|
11
|
+
import { defineRoute } from '@ultimat3/render';
|
|
12
|
+
import { ld } from '@ultimat3/seo';
|
|
13
|
+
|
|
14
|
+
declare module '@ultimat3/cache' {
|
|
15
|
+
interface CacheTagRegistry {
|
|
16
|
+
post: true;
|
|
17
|
+
feed: true;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
interface Post {
|
|
22
|
+
readonly title: string;
|
|
23
|
+
readonly excerpt: string;
|
|
24
|
+
readonly cover: string;
|
|
25
|
+
readonly publishedAt: string;
|
|
26
|
+
readonly author: string;
|
|
27
|
+
}
|
|
28
|
+
declare function listPostSlugs(): Promise<readonly string[]>;
|
|
29
|
+
declare function loadPost(slug: string): Promise<Post>;
|
|
30
|
+
|
|
10
31
|
export const config = defineRoute({
|
|
11
32
|
render: 'isr', // static | isr | ssr | stream
|
|
12
33
|
revalidate: { tags: [tag.post] },
|
|
13
|
-
prerender: () =>
|
|
34
|
+
prerender: () => listPostSlugs(),
|
|
14
35
|
offline: 'precache', // precache | runtime | network-only
|
|
15
36
|
hydrate: 'visible', // idle | visible | interaction | never
|
|
16
37
|
budget: { js: '40kb' },
|
|
17
|
-
|
|
18
|
-
|
|
38
|
+
load: ({ params }) => loadPost(params['slug'] ?? ''),
|
|
39
|
+
meta: ({ data: post }) => ({
|
|
40
|
+
title: post.title,
|
|
41
|
+
description: post.excerpt,
|
|
42
|
+
og: { image: post.cover },
|
|
43
|
+
ld: [ld.Article({
|
|
44
|
+
headline: post.title,
|
|
45
|
+
datePublished: post.publishedAt,
|
|
46
|
+
author: { name: post.author },
|
|
47
|
+
})],
|
|
48
|
+
}),
|
|
19
49
|
});
|
|
20
50
|
```
|
|
21
51
|
|
|
@@ -118,6 +148,8 @@ personal: a recipient landing addressed by a capability token in its path, or a
|
|
|
118
148
|
that must never answer with an old result. `cache` replaces that default:
|
|
119
149
|
|
|
120
150
|
```ts
|
|
151
|
+
import { defineRoute } from '@ultimat3/render';
|
|
152
|
+
|
|
121
153
|
export const config = defineRoute({
|
|
122
154
|
render: 'ssr',
|
|
123
155
|
offline: 'network-only',
|
|
@@ -426,7 +458,20 @@ See [I18n](I18n), [Timezones and dates](Timezones-And-Dates), [Money](Money).
|
|
|
426
458
|
## Image pipeline
|
|
427
459
|
|
|
428
460
|
```tsx
|
|
429
|
-
|
|
461
|
+
import { Image } from '@ultimat3/ui';
|
|
462
|
+
|
|
463
|
+
declare const post: { readonly cover: string; readonly title: string };
|
|
464
|
+
|
|
465
|
+
export const cover = (
|
|
466
|
+
<Image
|
|
467
|
+
src={post.cover}
|
|
468
|
+
alt={post.title}
|
|
469
|
+
width={1400}
|
|
470
|
+
height={700}
|
|
471
|
+
sizes="(max-width: 700px) 100vw, 700px"
|
|
472
|
+
priority
|
|
473
|
+
/>
|
|
474
|
+
);
|
|
430
475
|
```
|
|
431
476
|
|
|
432
477
|
One `<Image>` shape, one capability contract, stated once — in [`docs/idea/07-rendering-seo.md` → Image pipeline](https://github.com/developerz-ai/ultimate/blob/main/docs/idea/07-rendering-seo.md#image-pipeline): variants, `srcset`, inlined dimensions, the blur placeholder, the `@ultimat3/core` runtime, and the `ImageTransformDriver` seam AVIF/WebP variants come from. Restating it here would let the two copies drift.
|
|
@@ -440,13 +485,16 @@ status on the response.
|
|
|
440
485
|
```ts
|
|
441
486
|
import { defineRoute, withStatus } from '@ultimat3/render';
|
|
442
487
|
|
|
488
|
+
declare function hostList(args: { id: string }): Promise<{ readonly label: string } | undefined>;
|
|
489
|
+
|
|
443
490
|
export const config = defineRoute({
|
|
444
491
|
render: 'ssr',
|
|
445
492
|
offline: 'runtime',
|
|
446
493
|
load: async ({ params }) => {
|
|
447
|
-
const
|
|
494
|
+
const hostId = params['host'] ?? '';
|
|
495
|
+
const host = await hostList({ id: hostId });
|
|
448
496
|
return host === undefined
|
|
449
|
-
? withStatus(404, { kind: 'missing' as const, hostId
|
|
497
|
+
? withStatus(404, { kind: 'missing' as const, hostId })
|
|
450
498
|
: { kind: 'page' as const, host };
|
|
451
499
|
},
|
|
452
500
|
meta: ({ data, t }) => ({ title: data.kind === 'missing' ? t('notFound') : data.host.label }),
|
package/wiki/SEO.md
CHANGED
|
@@ -8,14 +8,33 @@ Route metadata itself is declared on `defineRoute({ meta })` ([Routes and render
|
|
|
8
8
|
modes](Routes-And-Render-Modes)).
|
|
9
9
|
|
|
10
10
|
```ts
|
|
11
|
+
import { defineRoute } from '@ultimat3/render';
|
|
12
|
+
import { ld } from '@ultimat3/seo';
|
|
13
|
+
|
|
14
|
+
interface Post {
|
|
15
|
+
readonly title: string;
|
|
16
|
+
readonly excerpt: string;
|
|
17
|
+
readonly cover: string;
|
|
18
|
+
readonly publishedAt: string;
|
|
19
|
+
readonly author: string;
|
|
20
|
+
}
|
|
21
|
+
declare function loadPost(slug: string): Promise<Post>;
|
|
22
|
+
|
|
11
23
|
export const config = defineRoute({
|
|
12
24
|
render: 'isr',
|
|
13
|
-
|
|
25
|
+
revalidate: { ttl: '1h' },
|
|
26
|
+
offline: 'runtime',
|
|
27
|
+
load: ({ params }) => loadPost(params['slug'] ?? ''),
|
|
28
|
+
meta: ({ data: post }) => ({
|
|
14
29
|
title: post.title,
|
|
15
30
|
titleTemplate: '%s — Ultimate',
|
|
16
31
|
description: post.excerpt,
|
|
17
32
|
og: { type: 'article', image: post.cover, publishedTime: post.publishedAt },
|
|
18
|
-
ld: [ld.Article({
|
|
33
|
+
ld: [ld.Article({
|
|
34
|
+
headline: post.title,
|
|
35
|
+
datePublished: post.publishedAt,
|
|
36
|
+
author: { name: post.author },
|
|
37
|
+
})],
|
|
19
38
|
}),
|
|
20
39
|
});
|
|
21
40
|
```
|
|
@@ -45,8 +64,11 @@ declaration order, for SSR and prerender alike. `canonical` and hreflang keep th
|
|
|
45
64
|
the surface stylesheet is the renderer's, so neither `rel` is spellable here.
|
|
46
65
|
|
|
47
66
|
```ts
|
|
67
|
+
import { asset, defineRoute } from '@ultimat3/render';
|
|
68
|
+
|
|
48
69
|
export const config = defineRoute({
|
|
49
70
|
render: 'static',
|
|
71
|
+
offline: 'precache',
|
|
50
72
|
meta: () => ({
|
|
51
73
|
title: 'Acme',
|
|
52
74
|
description: 'Notificaciones electrónicas con constancia de entrega',
|
package/wiki/Scheduled-Tasks.md
CHANGED
|
@@ -8,6 +8,10 @@ A `task` is a cron trigger that enqueues jobs. It never does work itself.
|
|
|
8
8
|
|
|
9
9
|
```ts
|
|
10
10
|
// task (cron)
|
|
11
|
+
import { type JobHandle, task } from '@ultimat3/jobs';
|
|
12
|
+
|
|
13
|
+
declare const sendDigest: JobHandle<{ occurrenceMs: number }>;
|
|
14
|
+
|
|
11
15
|
export const nightlyDigest = task({
|
|
12
16
|
cron: '0 3 * * *',
|
|
13
17
|
tz: 'UTC',
|
|
@@ -33,6 +37,10 @@ If it has a handler body, it is a [job](Jobs-And-Workflows), not a task.
|
|
|
33
37
|
`enqueue` must be cheap and synchronous-shaped: build inputs, return the list. Fanning out per tenant is a job that enqueues children, not a loop with a DB read inside `enqueue`.
|
|
34
38
|
|
|
35
39
|
```ts
|
|
40
|
+
import { type JobHandle, task } from '@ultimat3/jobs';
|
|
41
|
+
|
|
42
|
+
declare const fanOutKeyRotation: JobHandle<Record<string, never>>;
|
|
43
|
+
|
|
36
44
|
export const rotateApiKeys = task({
|
|
37
45
|
cron: '15 2 * * 1',
|
|
38
46
|
tz: 'Europe/Berlin',
|
|
@@ -171,25 +179,35 @@ $ x tasks list --json
|
|
|
171
179
|
|
|
172
180
|
## Testing
|
|
173
181
|
|
|
174
|
-
|
|
182
|
+
A task is tested without a scheduler: `task.entries(occurrenceMs)` is what a tick would enqueue. `clock.advance` fires no cron, `As of 2026-11` — the `runJobs` fixture runs no scheduler. A test of a whole dispatch round builds `jobScheduler({ driver, clock, tasks })` and calls `tick()`.
|
|
175
183
|
|
|
176
184
|
```ts
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
185
|
+
import { type JobHandle, task } from '@ultimat3/jobs';
|
|
186
|
+
import { expect, unitTest } from '@ultimat3/testing';
|
|
187
|
+
|
|
188
|
+
declare const sendDigest: JobHandle<{ occurrenceMs: number }>;
|
|
189
|
+
|
|
190
|
+
const nightlyDigest = task({
|
|
191
|
+
cron: '0 3 * * *',
|
|
192
|
+
tz: 'UTC',
|
|
193
|
+
enqueue: (occurrenceMs) => [[sendDigest, { occurrenceMs }]],
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
unitTest('nightlyDigest enqueues one digest for the occurrence it fires for', () => {
|
|
197
|
+
const occurrenceMs = Date.parse('2026-03-04T03:00:00.000Z');
|
|
198
|
+
expect(nightlyDigest.describe()).toMatchObject({ cron: '0 3 * * *', tz: 'UTC' });
|
|
199
|
+
expect(nightlyDigest.entries(occurrenceMs)).toEqual([[sendDigest, { occurrenceMs }]]);
|
|
182
200
|
});
|
|
183
201
|
```
|
|
184
202
|
|
|
185
203
|
| Asserted | Why |
|
|
186
204
|
|---|---|
|
|
187
|
-
|
|
|
188
|
-
| Idempotency absorbs a replayed tick |
|
|
189
|
-
| DST boundary |
|
|
190
|
-
| `
|
|
205
|
+
| Occurrences over a window | walk `nextTaskRun(task, from)`: the cron expression means what you think in the declared `tz` |
|
|
206
|
+
| Idempotency absorbs a replayed tick | `runJobs.enqueue` the same entry twice; `runJobs.depth(job)` must not change |
|
|
207
|
+
| DST boundary | `nextTaskRun` across a spring-forward and a fall-back in the task's zone |
|
|
208
|
+
| `entries(occurrenceMs)` returns the right inputs | the pairs, not the work |
|
|
191
209
|
|
|
192
|
-
Runner: `x test
|
|
210
|
+
Runner: `x test unit` for the entries, `x test job` for the job they enqueue. See [Testing](Testing).
|
|
193
211
|
|
|
194
212
|
## Errors
|
|
195
213
|
|
package/wiki/Scraping.md
CHANGED
|
@@ -28,11 +28,14 @@ A scrape is a **`job`**, not a ninth primitive. `scrape()` returns a `JobHandle`
|
|
|
28
28
|
## The declaration
|
|
29
29
|
|
|
30
30
|
```ts
|
|
31
|
+
import { t } from '@ultimat3/action';
|
|
32
|
+
import { scrape } from '@ultimat3/scraping';
|
|
33
|
+
|
|
31
34
|
export const dailyOrders = scrape({
|
|
32
35
|
name: 'orders.daily',
|
|
33
|
-
input: t.object({ page: t.number.int() }),
|
|
36
|
+
input: t.object({ orgId: t.uuid, page: t.number.int() }),
|
|
34
37
|
extract: t.object({ id: t.string, title: t.string }),
|
|
35
|
-
idempotencyKey: (input) => `orders:${input.page}`,
|
|
38
|
+
idempotencyKey: (input) => `orders:${input.orgId}:${input.page}`,
|
|
36
39
|
tenant: (input) => input.orgId,
|
|
37
40
|
allowHosts: ['shop.example'],
|
|
38
41
|
expect: { minRows: 1 },
|
|
@@ -306,6 +309,34 @@ One declaration: a caller opens a session, events stream out, input goes in mid-
|
|
|
306
309
|
comes back. Every piece is a field on `scrape()` or on its driver.
|
|
307
310
|
|
|
308
311
|
```ts
|
|
312
|
+
import { t } from '@ultimat3/action';
|
|
313
|
+
import {
|
|
314
|
+
type CdpLauncherLike,
|
|
315
|
+
type CdpResolver,
|
|
316
|
+
eventPrompt,
|
|
317
|
+
remoteBrowser,
|
|
318
|
+
scrape,
|
|
319
|
+
storageSessionStore,
|
|
320
|
+
} from '@ultimat3/scraping';
|
|
321
|
+
import { disk } from '@ultimat3/storage';
|
|
322
|
+
|
|
323
|
+
// The app's own: the browser vendor's client, its row store, its login and its scrape body.
|
|
324
|
+
declare const puppeteer: CdpLauncherLike;
|
|
325
|
+
declare const provider: {
|
|
326
|
+
create(input: { tag: string | undefined; proxy: string | undefined; signal: AbortSignal | undefined }): Promise<{
|
|
327
|
+
readonly id: string;
|
|
328
|
+
readonly connectUrl: string;
|
|
329
|
+
readonly priceCents: number;
|
|
330
|
+
}>;
|
|
331
|
+
end(id: string): Promise<void>;
|
|
332
|
+
};
|
|
333
|
+
declare const connections: {
|
|
334
|
+
byId(id: string): Promise<{ readonly exit: string } | null>;
|
|
335
|
+
};
|
|
336
|
+
declare const runs: { record(runId: string, usage: unknown): Promise<void> };
|
|
337
|
+
declare function login(): Promise<void>;
|
|
338
|
+
declare function run(): Promise<readonly unknown[]>;
|
|
339
|
+
|
|
309
340
|
const rent: CdpResolver = async ({ runId, egress, signal }) => {
|
|
310
341
|
const rented = await provider.create({ tag: runId, proxy: egress, signal });
|
|
311
342
|
return {
|
package/wiki/Static-Assets.md
CHANGED
|
@@ -180,6 +180,7 @@ A test that renders a page calling `asset()` without loading the app installs a
|
|
|
180
180
|
|
|
181
181
|
```ts
|
|
182
182
|
import { setAssetResolver } from '@ultimat3/render';
|
|
183
|
+
import { afterAll, beforeAll } from 'bun:test';
|
|
183
184
|
|
|
184
185
|
beforeAll(() => setAssetResolver((path) => `/${path}`));
|
|
185
186
|
afterAll(() => setAssetResolver(undefined));
|
|
@@ -9,10 +9,13 @@ and the upload design is
|
|
|
9
9
|
```ts
|
|
10
10
|
import { defineStorage, disk, localDriver, s3Driver, scopedKey } from '@ultimat3/storage';
|
|
11
11
|
|
|
12
|
+
declare const orgId: string;
|
|
13
|
+
declare const bytes: Uint8Array;
|
|
14
|
+
|
|
12
15
|
defineStorage({
|
|
13
16
|
disks: {
|
|
14
17
|
uploads: localDriver({ root: '.storage/uploads' }),
|
|
15
|
-
media: s3Driver({ bucket: 'media', endpoint: process.env
|
|
18
|
+
media: s3Driver({ bucket: 'media', endpoint: process.env['S3_ENDPOINT'], forcePathStyle: true }),
|
|
16
19
|
},
|
|
17
20
|
default: 'uploads',
|
|
18
21
|
});
|
|
@@ -210,6 +213,10 @@ served only when nothing declared one. A `defineStorage` at module scope in any
|
|
|
210
213
|
|
|
211
214
|
```ts
|
|
212
215
|
// apps/web/shared/storage.ts
|
|
216
|
+
import { defineStorage, localDriver, s3Driver } from '@ultimat3/storage';
|
|
217
|
+
|
|
218
|
+
declare const bucket: string;
|
|
219
|
+
|
|
213
220
|
export const storage = defineStorage({
|
|
214
221
|
disks: { uploads: localDriver({ root: '.storage/uploads' }), evidence: s3Driver({ bucket }) },
|
|
215
222
|
default: 'uploads',
|