uniweb 1.35.3 → 1.35.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/partials/agents.md +1 -1
- package/partials/guides/backend.md +3 -1
- package/partials/guides/content.md +1 -1
- package/partials/guides/foundation.md +1 -1
- package/partials/guides/promote.md +7 -1
- package/partials/guides/services.md +7 -1
- package/src/backend/client.js +24 -0
- package/src/backend/promote-drafts.js +63 -0
- package/src/commands/doctor.js +3 -2
- package/src/commands/promote.js +89 -0
- package/src/framework-index.json +10 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "uniweb",
|
|
3
|
-
"version": "1.35.
|
|
3
|
+
"version": "1.35.5",
|
|
4
4
|
"description": "Create structured Vite + React sites with content/code separation",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
"js-yaml": "^4.3.2",
|
|
42
42
|
"prompts": "^2.4.2",
|
|
43
43
|
"tar": "^7.5.21",
|
|
44
|
-
"@uniweb/content-writer": "~1.3.2",
|
|
45
44
|
"@uniweb/core": "~1.6.13",
|
|
46
|
-
"@uniweb/
|
|
47
|
-
"@uniweb/
|
|
45
|
+
"@uniweb/semantic-parser": "~1.13.6",
|
|
46
|
+
"@uniweb/content-writer": "~1.3.3",
|
|
47
|
+
"@uniweb/schemas": "~1.7.5"
|
|
48
48
|
},
|
|
49
49
|
"peerDependencies": {
|
|
50
|
-
"@uniweb/semantic-parser": "~1.13.
|
|
51
|
-
"@uniweb/content-reader": "~1.5.
|
|
52
|
-
"@uniweb/build": "~1.24.
|
|
50
|
+
"@uniweb/semantic-parser": "~1.13.6",
|
|
51
|
+
"@uniweb/content-reader": "~1.5.12",
|
|
52
|
+
"@uniweb/build": "~1.24.4"
|
|
53
53
|
},
|
|
54
54
|
"peerDependenciesMeta": {
|
|
55
55
|
"@uniweb/build": {
|
package/partials/agents.md
CHANGED
|
@@ -71,7 +71,7 @@ When a rule in §2 feels like friction, that is the moment you are about to take
|
|
|
71
71
|
| Pick heading levels for size | Levels are **structure**: `#` title; exactly one step smaller = `subtitle`; two steps smaller, a `---`, or any heading after body text = an `item`. `###` right after `#` is an item; `##` is a subtitle line. A later heading as large as the first leaves no `title`: all of them become items. | silent |
|
|
72
72
|
| Order the file the way the page should look | Write semantically; the component arranges. | — |
|
|
73
73
|
| Put an icon or image above the title, as it will look | Anything above the first heading empties `title`: an icon or text puts the heading in `items[0]`, an image puts it in `headings`. Write it under the heading — it is still `icons[0]` or `images[0]`. | silent; `inspect` shows it |
|
|
74
|
-
| `<span
|
|
74
|
+
| `<span>`, `<div>`, `<sup>` in markdown | Shown as text. `[text]{accent}`, `[2]{sup}`, `**bold**`; a line break is `<br>` or a trailing `\`. | build names the file |
|
|
75
75
|
| Write `pages: [a, b]` or `sections: [a, b]` to set order | Those lists are **strict**: an unlisted page leaves every menu, an unlisted section leaves the page. `[a, b, ...]` means "these first". At the site root the first of `pages:` is `/`, whatever `index:` says. | silent |
|
|
76
76
|
| `primary: #3b82f6` | `'#3b82f6'` — an unquoted `#` starts a YAML comment. | build warns |
|
|
77
77
|
| Expect any frontmatter key to do something, any `type:` name to work | A key reaches `params` only, and does nothing unless the type reads it (its `meta.js` says which); a `title:` there never sets the section's title, which is its heading. Only types present in `sections/` work. | silent; build and push note a content field's name / red box |
|
|
@@ -51,7 +51,7 @@ const editor = useRichTextEditor({ value, onChange }) //
|
|
|
51
51
|
<RichTextContent editor={editor} /> // your toolbar: editor.chain().focus().toggleBold().run()
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
Its document model is the stored vocabulary: it edits what TipTap's kit does, with a divider for the rule
|
|
54
|
+
Its document model is the stored vocabulary: it edits what TipTap's kit does, underline included, plus superscript and subscript (`toggleSuperscript()`, `toggleSubscript()`), with a divider for the rule, and keeps everything else a stored text holds. `richTextLength(doc)` counts a text as a field's `max_length` does (the characters a reader sees; a new line or paragraph is one), for a counter. Don't configure TipTap yourself for a rich-text field: what it makes beyond the vocabulary is left out when saved, which the mock prints.
|
|
55
55
|
|
|
56
56
|
## Translated fields
|
|
57
57
|
|
|
@@ -241,6 +241,8 @@ Nested items in one create: give an item `uuid: uuidv7()` and a later item names
|
|
|
241
241
|
|
|
242
242
|
**Sent twice, made once:** give a create the new entry's own `uuid`, made once when the person starts adding it (`const [uuid] = useState(uuidv7)`), and a second click or a retry answers with the entry the first one made. Without it, each call makes an entry.
|
|
243
243
|
|
|
244
|
+
**A member's form for an entry** comes from its type: `const { form, save, errors } = useEntityForm({ schema: '@/course', uuid })` (no `uuid`: a new entry), held by kit's `useFormValues(form)` and drawn with the component that draws every `@std/form`; `save(values)`. Each control carries its field's kind and rules; `save` checks them first, and `errors` holds each problem by control path (`head.title` → `{ rule: 'max_length', max_length: 20 }`) for the foundation to word. A `File` in a `file` control is uploaded on save. List sections are written with `useEntityWriter`.
|
|
245
|
+
|
|
244
246
|
**A member's uploads:** `const { upload } = useUpload({ entity })`, then `await upload(input.files)` → `[{ url, assetId, assetExt, name, type, size, prepared, note? }]`; store `url` in the entry. Each file is prepared in the browser first, by the rule for uploaded media: a picture becomes a WebP when that makes it 10% smaller or turns it upright, and whatever is kept in its own format loses its location and camera data. Tell the member a `note`: `unconverted` (a TIFF or HEIC the browser couldn't convert) or `unreduced` (a video over the rule's bitrate). Upload through `useUpload`: it is what keeps a photo's location from going up with it.
|
|
245
247
|
|
|
246
248
|
## A backend on your machine
|
|
@@ -154,7 +154,7 @@ Sites adjust these or add named styles in `theme.yml` `inline:` — a name is a
|
|
|
154
154
|
|
|
155
155
|
### HTML is not content
|
|
156
156
|
|
|
157
|
-
A tag in markdown — `<strong>`, `<span class=…>`, `<div>` — shows as written, and the build names the file. Use `**bold**`, `[text]{accent}`, a link. The exception is `<br>`, a hard break anywhere. A newline inside a paragraph is a space; a deliberate line break is `<br>` or a `\` at the end of the line.
|
|
157
|
+
A tag in markdown — `<strong>`, `<span class=…>`, `<div>` — shows as written, and the build names the file. Use `**bold**`, `[text]{accent}`, `[x]{underline}`, `[2]{sup}`, `[2]{sub}`, a link. The exception is `<br>`, a hard break anywhere. A newline inside a paragraph is a space; a deliberate line break is `<br>` or a `\` at the end of the line.
|
|
158
158
|
|
|
159
159
|
### Fenced code
|
|
160
160
|
|
|
@@ -394,6 +394,6 @@ Content-less containers appear as group nodes (`hasContent: false`); link with `
|
|
|
394
394
|
|
|
395
395
|
**A heavy library used on demand.** `import('some-package')` where you use it keeps the package out of the page's first load and out of `dist/entry-ssr.js`, the file a host loads to render a page. A dynamic import of your own module only splits the browser's load: `entry-ssr.js` folds that module in, with every package it imports statically, and runs them when the file loads. So put the `import()` on the package, not on a component of yours that imports it. The build is green either way; the size of `entry-ssr.js` shows which you have.
|
|
396
396
|
|
|
397
|
-
**`package.json` `uniweb` block** (all optional): `runtimePolicy` — a statement of how far past the recorded runtime version a host may move a site. The foundation's name and scope are `name` in `main.js` (`'@acme/marketing'`), not here; a name with no scope is unregistered, and the first `uniweb register` writes the scope in (from `--scope` or the Uniweb workspace you are logged in to). A foundation's own schemas register under the same scope (`@/article` → `@acme/article`). `uniweb.supports`
|
|
397
|
+
**`package.json` `uniweb` block** (all optional): `runtimePolicy` — a statement of how far past the recorded runtime version a host may move a site. The foundation's name and scope are `name` in `main.js` (`'@acme/marketing'`), not here; a name with no scope is unregistered, and the first `uniweb register` writes the scope in (from `--scope` or the Uniweb workspace you are logged in to). A foundation's own schemas register under the same scope (`@/article` → `@acme/article`). `uniweb.supports` and `uniweb.requires` are covered in the services guide.
|
|
398
398
|
|
|
399
399
|
**Runtime floor.** Your code externalizes `react`, `react-dom`, both JSX runtimes and `@uniweb/core`; the runtime supplies them. At build time the foundation records the `@uniweb/runtime` version it linked against into `dist/runtime-pin.json`, and `uniweb register` sends that version as its floor. `{ "uniweb": { "runtimePolicy": "exact" } }` asks for no movement past it, for a foundation that reaches into undocumented internals: it is recorded in that file and not sent at register, so whether anything acts on it is the host's to say. `@uniweb/runtime` arrives transitively through `@uniweb/build`; don't add it to the foundation's dependencies — bump `@uniweb/build` instead.
|
|
@@ -122,7 +122,12 @@ A campaign with `goal: conversions` optimizes for what its network hears back. T
|
|
|
122
122
|
|
|
123
123
|
## What each brought
|
|
124
124
|
|
|
125
|
-
|
|
125
|
+
```bash
|
|
126
|
+
uniweb promote results Holiday # a campaign: by day, by ad, and what it spent
|
|
127
|
+
uniweb promote results holiday.md --from 2026-12-01 # a post, from a day on (--to ends it)
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
`results` gives what a post or a campaign brought, by UTC day, as the site's own analytics counts it: the arrivals, the page views and the conversions by name, matched by the tags in its links. It's the same count on every network, and a visitor two networks both claim counts once. A network's own clicks and impressions aren't in it. A campaign's comes per ad too, with what it spent in each ad account as the network last reported it, in that account's currency. A day the answer can't count is said to be unknown, not zero, and so are the arrivals that came with no ad's or post's tag. `uniweb promote status` shows each running campaign's spend. The site's Analytics, in the app, shows its visits by where they came from. When you read them:
|
|
126
131
|
|
|
127
132
|
- judge by conversions, not clicks;
|
|
128
133
|
- change one thing at a time;
|
|
@@ -144,5 +149,6 @@ A campaign with `goal: conversions` optimizes for what its network hears back. T
|
|
|
144
149
|
| `unschedule <post>` | a scheduled post a draft again |
|
|
145
150
|
| `start <campaign>` · `resume <campaign>` | spend, after saying what; `--yes` answers |
|
|
146
151
|
| `pause <campaign>` | wherever it runs |
|
|
152
|
+
| `results <post\|campaign> [--from <day>] [--to <day>]` | what it brought by day, as the site's own analytics counts it |
|
|
147
153
|
|
|
148
154
|
All of them take `--json`; `--site <uuid>` for a site this project isn't synced to; `--org @x` or `--personal` for the workspace. A time carries its offset: `2026-11-24T09:00-05:00`.
|
|
@@ -36,7 +36,13 @@ An entry is `true`, `false`, an address (a string, or `endpoint:` in a map), or
|
|
|
36
36
|
{ "uniweb": { "supports": ["search", "submit"] } }
|
|
37
37
|
```
|
|
38
38
|
|
|
39
|
-
A service only does something if the foundation renders against it, and a host can't otherwise know. The build derives the set from what the bundle reaches (`resolveService(website, 'search')`, `isSearchEnabled()`), so an undeclared foundation still publishes an accurate set; what you write is a supplement (union), and only needed for a service reached through a computed name (`resolveService(website, name)` — the build warns).
|
|
39
|
+
A service only does something if the foundation renders against it, and a host can't otherwise know. The build derives the set from what the bundle reaches (`resolveService(website, 'search')`, `isSearchEnabled()`), so an undeclared foundation still publishes an accurate set; what you write is a supplement (union), and only needed for a service reached through a computed name (`resolveService(website, name)` — the build warns). A published set is complete: when the build meets a computed name and you declared nothing, it publishes no set (unknown) rather than a partial one, and says what to list. `[]` means none, proven by the build; absent means unknown.
|
|
40
|
+
|
|
41
|
+
```json
|
|
42
|
+
{ "uniweb": { "requires": ["backend"] } }
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`requires` names the services the foundation cannot work without — sign-in and purchases for a course site, say — as opposed to ones it uses when they are on. The build cannot tell the two apart, so only you can declare it; each name joins `supports`, and the build warns if no code reaches it. Uniweb hosting keeps a required service on for every site using the foundation, so its owner is never offered a switch that breaks the site. A required service can still be missing for a moment (while it starts for a new site, say), so a section that calls it shows its own "not available yet" state rather than failing. Never list `tracking`: the runtime reports for every foundation, so the build drops the name with a warning. `uniweb doctor` compares declared with found.
|
|
40
46
|
|
|
41
47
|
## Search
|
|
42
48
|
|
package/src/backend/client.js
CHANGED
|
@@ -1100,6 +1100,30 @@ export class BackendClient {
|
|
|
1100
1100
|
)
|
|
1101
1101
|
}
|
|
1102
1102
|
|
|
1103
|
+
/**
|
|
1104
|
+
* GET /dev/site/promotion/{site}/{posts|campaigns}/{uuid}/results?from=&to= — `{ results }`:
|
|
1105
|
+
* what a post or a campaign brought by UTC day, as the site's own analytics counts it, matched
|
|
1106
|
+
* by the tags in its links: `days` of `{ day, arrivals, views, conversions }`, `untold`,
|
|
1107
|
+
* `range`, `measured_from`, `cut`, `capped`; a campaign's also `ad_groups`, `ads` and `spend`.
|
|
1108
|
+
* `from` and `to` are UTC days, inclusive, both optional. Takes `edit` on the site; `402` for a
|
|
1109
|
+
* site without Analytics, `503` where the backend reaches no analytics view.
|
|
1110
|
+
*
|
|
1111
|
+
* @param {string} siteUuid
|
|
1112
|
+
* @param {'posts'|'campaigns'} kind
|
|
1113
|
+
* @param {string} uuid
|
|
1114
|
+
* @param {{ from?: string|null, to?: string|null }} [days]
|
|
1115
|
+
* @returns {Promise<Response>}
|
|
1116
|
+
*/
|
|
1117
|
+
async promotionResults(siteUuid, kind, uuid, { from = null, to = null } = {}) {
|
|
1118
|
+
const query = {}
|
|
1119
|
+
if (from) query.from = from
|
|
1120
|
+
if (to) query.to = to
|
|
1121
|
+
return this.request(
|
|
1122
|
+
`/dev/site/promotion/${encodeURIComponent(siteUuid)}/${kind}/${encodeURIComponent(uuid)}/results`,
|
|
1123
|
+
{ query }
|
|
1124
|
+
)
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1103
1127
|
/**
|
|
1104
1128
|
* GET /dev/connections — `{ connections: [{ uuid, owner?, unit?, card }] }`: the network
|
|
1105
1129
|
* connections the caller reaches in the workspace the request names. A card holds the
|
|
@@ -184,6 +184,9 @@ export const REASONS = {
|
|
|
184
184
|
network_not_offered: 'this backend does not offer that network',
|
|
185
185
|
network_refused: 'the network refused it',
|
|
186
186
|
too_many_parts: 'it has more parts than its network takes in a post',
|
|
187
|
+
send_at_not_ahead: 'its time is not ahead of now: give one ahead with --at, or send it now with --now',
|
|
188
|
+
send_at_invalid: 'its time is not a date-time with its offset, such as 2026-11-24T09:00-05:00',
|
|
189
|
+
post_published: 'it went out already, so it is not sent again: a new post is a new draft',
|
|
187
190
|
promote_off: 'the site has no Promote: it comes with the site\'s Analytics, which the person turns on in the app',
|
|
188
191
|
feature_not_subscribed: 'Promote comes with the site\'s Analytics, which this site does not have yet. The person turns it on in the app'
|
|
189
192
|
}
|
|
@@ -511,6 +514,66 @@ export function overLimits(parts, limits, { network, link }) {
|
|
|
511
514
|
return out
|
|
512
515
|
}
|
|
513
516
|
|
|
517
|
+
// ── What a post or a campaign brought ──────────────────────────────────────────────
|
|
518
|
+
|
|
519
|
+
/** Day rows summed: arrivals, views, and each conversion by its name. */
|
|
520
|
+
export function resultTotals(days) {
|
|
521
|
+
const out = { arrivals: 0, views: 0, conversions: {} }
|
|
522
|
+
for (const d of Array.isArray(days) ? days : []) {
|
|
523
|
+
if (Number.isFinite(d?.arrivals)) out.arrivals += d.arrivals
|
|
524
|
+
if (Number.isFinite(d?.views)) out.views += d.views
|
|
525
|
+
for (const [name, n] of Object.entries(isPlainObject(d?.conversions) ? d.conversions : {})) {
|
|
526
|
+
if (Number.isFinite(n)) out.conversions[name] = (out.conversions[name] ?? 0) + n
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
return out
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
/** A day row, or a total, in words: `3 arrivals · 5 views · signup 1`. */
|
|
533
|
+
export function resultWords(row) {
|
|
534
|
+
const count = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`
|
|
535
|
+
const conversions = Object.entries(isPlainObject(row?.conversions) ? row.conversions : {})
|
|
536
|
+
.filter(([, n]) => n)
|
|
537
|
+
.map(([name, n]) => `${name} ${n}`)
|
|
538
|
+
return [count(row?.arrivals ?? 0, 'arrival'), count(row?.views ?? 0, 'view'), ...conversions].join(' · ')
|
|
539
|
+
}
|
|
540
|
+
|
|
541
|
+
/**
|
|
542
|
+
* What a results answer's days can be read as, in words: from when they are counted, whether
|
|
543
|
+
* some may be missing, and what came with no ad's or post's tag. The answer's own fields:
|
|
544
|
+
* `measured_from` (a day, or null when the site's analytics hold none of its tags), `cut` and
|
|
545
|
+
* `capped` (booleans) and `untold` (day rows, only on days that have them).
|
|
546
|
+
*
|
|
547
|
+
* @param {object} results
|
|
548
|
+
* @param {{ kind: 'post'|'campaign', network?: string|null }} what
|
|
549
|
+
*/
|
|
550
|
+
export function resultNotes(results, { kind, network = null }) {
|
|
551
|
+
const notes = []
|
|
552
|
+
const from = results?.range?.from ?? null
|
|
553
|
+
if (results?.measured_from === null) {
|
|
554
|
+
notes.push('The site\'s analytics hold nothing with its tags in the days they keep, so there is nothing to count yet.')
|
|
555
|
+
} else if (typeof results?.measured_from === 'string' && from && results.measured_from > from) {
|
|
556
|
+
notes.push(`Counted from ${results.measured_from}, when the site's analytics first held its tags: a day before it is unknown, not zero.`)
|
|
557
|
+
}
|
|
558
|
+
if (results?.cut === true) {
|
|
559
|
+
notes.push('Some values may be missing, since the site\'s analytics kept as many as they keep for these days: a day not listed is unknown, not zero. A shorter window (--from, --to) reads them all.')
|
|
560
|
+
}
|
|
561
|
+
if (results?.capped === true) {
|
|
562
|
+
notes.push('A day held more than the site\'s analytics keep in one, so some arrivals sit in no campaign: these counts are the least it brought.')
|
|
563
|
+
}
|
|
564
|
+
const untold = Array.isArray(results?.untold) ? results.untold : []
|
|
565
|
+
const sum = resultTotals(untold)
|
|
566
|
+
if (sum.arrivals || sum.views) {
|
|
567
|
+
const on = untold.map((d) => d.day).filter(Boolean).join(', ')
|
|
568
|
+
notes.push(
|
|
569
|
+
kind === 'campaign'
|
|
570
|
+
? `${resultWords(sum)} came with the campaign's tag but no ad's (${on}), as from a page that sends no referrer: they count toward no ad.`
|
|
571
|
+
: `${resultWords(sum)} came from ${NETWORK_NAMES[network] ?? network ?? 'its network'}'s posts with no post's tag (${on}): no post can claim them.`
|
|
572
|
+
)
|
|
573
|
+
}
|
|
574
|
+
return notes
|
|
575
|
+
}
|
|
576
|
+
|
|
514
577
|
/** Whether a picture is an address already, kept as written, rather than a file to upload. */
|
|
515
578
|
export function isAddress(picture) {
|
|
516
579
|
return /^https?:\/\//i.test(picture)
|
package/src/commands/doctor.js
CHANGED
|
@@ -538,8 +538,9 @@ export async function checkFoundationSupports({
|
|
|
538
538
|
} catch {
|
|
539
539
|
return // unreadable or malformed build output — not this check's to report
|
|
540
540
|
}
|
|
541
|
-
// Absent means the build
|
|
542
|
-
// reported UNKNOWN
|
|
541
|
+
// Absent means the build saw a computed name with nothing declared, so it
|
|
542
|
+
// reported UNKNOWN rather than a partial set (it publishes only a complete
|
|
543
|
+
// one) and named what it found itself. There is no list here to compare.
|
|
543
544
|
if (!Array.isArray(derived) || derived.length === 0) return
|
|
544
545
|
|
|
545
546
|
const declared = pkg?.uniweb?.supports
|
package/src/commands/promote.js
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
* uniweb promote unschedule <post> a scheduled post a draft again, its time kept
|
|
15
15
|
* uniweb promote start | resume <campaign> [--yes] spend: say what, ask, then start
|
|
16
16
|
* uniweb promote pause <campaign> pause it wherever it runs
|
|
17
|
+
* uniweb promote results <post|campaign> what it brought, by day, as the site's own analytics counts it
|
|
17
18
|
*
|
|
18
19
|
* The site is the one this project is synced to on that backend, or `--site <uuid>`. The
|
|
19
20
|
* workspace is `--org @x` or `--personal`, else the login's — as for every site request.
|
|
@@ -64,6 +65,9 @@ import {
|
|
|
64
65
|
overLimits,
|
|
65
66
|
pageRoute,
|
|
66
67
|
postLimits,
|
|
68
|
+
resultNotes,
|
|
69
|
+
resultTotals,
|
|
70
|
+
resultWords,
|
|
67
71
|
parseDraft,
|
|
68
72
|
picturesOf,
|
|
69
73
|
planCampaign,
|
|
@@ -127,6 +131,9 @@ const USAGE = [
|
|
|
127
131
|
' asks; --yes answers for you',
|
|
128
132
|
' resume <campaign> Resume it where it was paused, the same way',
|
|
129
133
|
' pause <campaign> Pause it wherever it runs',
|
|
134
|
+
' results <post|campaign> What it brought by day, as the site\'s own analytics counts it:',
|
|
135
|
+
' arrivals, views and conversions, a campaign\'s by ad and with its',
|
|
136
|
+
' spend; --from <day> and --to <day> choose the days',
|
|
130
137
|
'',
|
|
131
138
|
'--json gives any command\'s answer as JSON. An <id> is the one a command shows, a file',
|
|
132
139
|
'a draft was written from, or a campaign\'s name.',
|
|
@@ -238,6 +245,8 @@ async function sayRefusal(res, { site, origin, what, index = null, notFound = nu
|
|
|
238
245
|
} else if (res.status === 400 && reason === 'too_many_parts') {
|
|
239
246
|
const takes = body?.parts === 1 ? 'one part' : `${body?.parts ?? 'fewer'} parts`
|
|
240
247
|
say.err(`${NETWORK_NAMES[body?.network] ?? body?.network ?? 'Its network'} takes ${takes} in a post, and this one has more, so nothing went out. Make it ${body?.parts === 1 ? 'one' : (body?.parts ?? 'fewer')}.`)
|
|
248
|
+
} else if (res.status === 400 && reason && REASONS[reason]) {
|
|
249
|
+
say.err(`Refused, nothing changed: ${REASONS[reason]}.`)
|
|
241
250
|
} else if (res.status === 409) {
|
|
242
251
|
say.err(`Refused, nothing changed: what was named changed since it was read — in the app, or by another run${own ? ` (${own})` : ''}. Read it again: uniweb promote show <id>`)
|
|
243
252
|
} else {
|
|
@@ -850,6 +859,85 @@ async function useAccount(args) {
|
|
|
850
859
|
return { exitCode: 0 }
|
|
851
860
|
}
|
|
852
861
|
|
|
862
|
+
/** A UTC day, as `--from` and `--to` take one. */
|
|
863
|
+
const DAY = /^\d{4}-\d{2}-\d{2}$/
|
|
864
|
+
|
|
865
|
+
/**
|
|
866
|
+
* `uniweb promote results <post|campaign> [--from <day>] [--to <day>]` — what a post or a
|
|
867
|
+
* campaign brought, by UTC day, as the site's own analytics counts it: arrivals, views and
|
|
868
|
+
* conversions by name, matched by the tags in its links. Never a network's own count, which
|
|
869
|
+
* credits itself. A campaign's also comes per ad, with what it spent.
|
|
870
|
+
*/
|
|
871
|
+
async function results(args) {
|
|
872
|
+
const json = args.includes('--json')
|
|
873
|
+
const arg = positionals(args)[1]
|
|
874
|
+
const from = flagValue(args, '--from')
|
|
875
|
+
const to = flagValue(args, '--to')
|
|
876
|
+
if (!arg) {
|
|
877
|
+
say.err('Name the post or the campaign: uniweb promote results <id> [--from <day>] [--to <day>]')
|
|
878
|
+
return { exitCode: 2 }
|
|
879
|
+
}
|
|
880
|
+
for (const [flag, value] of [['--from', from], ['--to', to]]) {
|
|
881
|
+
if (args.includes(flag) && !DAY.test(value ?? '')) {
|
|
882
|
+
say.err(`\`${flag}\` takes a UTC day, such as 2026-12-01.`)
|
|
883
|
+
return { exitCode: 2 }
|
|
884
|
+
}
|
|
885
|
+
}
|
|
886
|
+
const at = await begin(args, 'Reading what it brought', `results ${arg}`)
|
|
887
|
+
if (!at.client) return at
|
|
888
|
+
const { client, site } = at
|
|
889
|
+
const index = await readIndex(client, site)
|
|
890
|
+
if (!index) return { exitCode: 1 }
|
|
891
|
+
const item = pick(index, arg, ['post', 'campaign'])
|
|
892
|
+
if (!item) return { exitCode: 2 }
|
|
893
|
+
const kind = item.section === 'posts' ? 'post' : 'campaign'
|
|
894
|
+
const res = await client.promotionResults(site, kind === 'post' ? 'posts' : 'campaigns', item.uuid, { from, to })
|
|
895
|
+
if (!res.ok) {
|
|
896
|
+
if (res.status === 503) say.err(`${client.origin} reaches no analytics view, so it can't count what this brought. A backend that serves the site counts it; a local one may not.`)
|
|
897
|
+
else await sayRefusal(res, { site, origin: client.origin, what: 'read what it brought', index, forbidden: VIEW_ONLY })
|
|
898
|
+
return { exitCode: 1 }
|
|
899
|
+
}
|
|
900
|
+
const r = (await res.json().catch(() => null))?.results ?? null
|
|
901
|
+
const ids = shortIds(index.items.map((i) => i.uuid))
|
|
902
|
+
if (json) {
|
|
903
|
+
console.log(JSON.stringify({ backend: client.origin, site, kind, id: item.uuid, short: ids.get(item.uuid), results: r }))
|
|
904
|
+
return { exitCode: r ? 0 : 1 }
|
|
905
|
+
}
|
|
906
|
+
if (!r) {
|
|
907
|
+
say.err('The backend answered with no results.')
|
|
908
|
+
return { exitCode: 1 }
|
|
909
|
+
}
|
|
910
|
+
const network = kind === 'post' ? (index.byUuid.get(item.data?.via)?.data?.network ?? null) : null
|
|
911
|
+
console.log(
|
|
912
|
+
`${c.bold}What ${kind} ${labelOf(index, item)} (${ids.get(item.uuid)}) brought${c.reset}` +
|
|
913
|
+
` ${c.dim}— ${r.range?.from ?? '?'} to ${r.range?.to ?? '?'}, as the site's own analytics counts it${c.reset}`
|
|
914
|
+
)
|
|
915
|
+
const days = Array.isArray(r.days) ? r.days : []
|
|
916
|
+
for (const d of days) console.log(` ${d.day} ${resultWords(d)}`)
|
|
917
|
+
if (days.length > 1) console.log(` ${c.bold}In all${c.reset} ${resultWords(resultTotals(days))}`)
|
|
918
|
+
if (kind === 'campaign') {
|
|
919
|
+
const ads = Array.isArray(r.ads) ? r.ads : []
|
|
920
|
+
if (ads.length) console.log(` ${c.bold}By ad${c.reset}`)
|
|
921
|
+
for (const a of ads) {
|
|
922
|
+
const ad = index.byUuid.get(a.ad)
|
|
923
|
+
const group = index.byUuid.get(a.ad_group)?.data?.name
|
|
924
|
+
console.log(` ${c.cyan}${ids.get(a.ad) ?? a.ad}${c.reset} ${ad ? labelOf(index, ad) : '(an ad no longer here)'}${group ? ` in “${group}”` : ''}: ${resultWords(resultTotals(a.days))}`)
|
|
925
|
+
}
|
|
926
|
+
const rows = Array.isArray(r.spend) ? r.spend : []
|
|
927
|
+
const spent = sumSpend(rows)
|
|
928
|
+
const reported = new Set(rows.map((s) => s.day).filter(Boolean)).size
|
|
929
|
+
console.log(
|
|
930
|
+
` ${c.bold}Spent${c.reset} ` +
|
|
931
|
+
(Object.keys(spent).length
|
|
932
|
+
? `${Object.entries(spent).map(([cur, amount]) => `${amount} ${cur}`).join(' + ')}, on the ${reported} day${reported === 1 ? '' : 's'} the network reported`
|
|
933
|
+
: 'nothing reported yet')
|
|
934
|
+
)
|
|
935
|
+
}
|
|
936
|
+
for (const note of resultNotes(r, { kind, network })) say.dim(note)
|
|
937
|
+
say.dim('These are the site\'s own counts of who arrived, not a network\'s clicks or impressions.')
|
|
938
|
+
return { exitCode: 0 }
|
|
939
|
+
}
|
|
940
|
+
|
|
853
941
|
/** The site's Promote, read fresh and indexed — or null, the refusal said. */
|
|
854
942
|
async function readIndex(client, site) {
|
|
855
943
|
const res = await client.readPromotion(site)
|
|
@@ -1819,6 +1907,7 @@ export async function promote(args = []) {
|
|
|
1819
1907
|
if (sub === 'unschedule') return await unschedule(args)
|
|
1820
1908
|
if (sub === 'start' || sub === 'resume') return await spend(args, sub)
|
|
1821
1909
|
if (sub === 'pause') return await pause(args)
|
|
1910
|
+
if (sub === 'results') return await results(args)
|
|
1822
1911
|
} catch (err) {
|
|
1823
1912
|
say.err(err instanceof WorkspaceMismatchError ? err.message : err?.message || String(err))
|
|
1824
1913
|
return { exitCode: 1 }
|
package/src/framework-index.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-11-
|
|
3
|
+
"generatedAt": "2026-11-18T03:07:21.813Z",
|
|
4
4
|
"packages": {
|
|
5
5
|
"@uniweb/api": {
|
|
6
|
-
"version": "1.7.
|
|
6
|
+
"version": "1.7.5"
|
|
7
7
|
},
|
|
8
8
|
"@uniweb/build": {
|
|
9
|
-
"version": "1.24.
|
|
9
|
+
"version": "1.24.4"
|
|
10
10
|
},
|
|
11
11
|
"@uniweb/content-reader": {
|
|
12
|
-
"version": "1.5.
|
|
12
|
+
"version": "1.5.12"
|
|
13
13
|
},
|
|
14
14
|
"@uniweb/content-writer": {
|
|
15
|
-
"version": "1.3.
|
|
15
|
+
"version": "1.3.3"
|
|
16
16
|
},
|
|
17
17
|
"@uniweb/core": {
|
|
18
18
|
"version": "1.6.13"
|
|
@@ -30,25 +30,25 @@
|
|
|
30
30
|
"version": "1.1.3"
|
|
31
31
|
},
|
|
32
32
|
"@uniweb/press": {
|
|
33
|
-
"version": "1.2.
|
|
33
|
+
"version": "1.2.3"
|
|
34
34
|
},
|
|
35
35
|
"@uniweb/projections": {
|
|
36
36
|
"version": "1.2.17"
|
|
37
37
|
},
|
|
38
38
|
"@uniweb/runtime": {
|
|
39
|
-
"version": "1.6.
|
|
39
|
+
"version": "1.6.6"
|
|
40
40
|
},
|
|
41
41
|
"@uniweb/scene": {
|
|
42
42
|
"version": "1.0.1"
|
|
43
43
|
},
|
|
44
44
|
"@uniweb/schemas": {
|
|
45
|
-
"version": "1.7.
|
|
45
|
+
"version": "1.7.5"
|
|
46
46
|
},
|
|
47
47
|
"@uniweb/scholar": {
|
|
48
48
|
"version": "1.1.3"
|
|
49
49
|
},
|
|
50
50
|
"@uniweb/semantic-parser": {
|
|
51
|
-
"version": "1.13.
|
|
51
|
+
"version": "1.13.6"
|
|
52
52
|
},
|
|
53
53
|
"@uniweb/snapshot": {
|
|
54
54
|
"version": "1.1.2"
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"version": "1.2.15"
|
|
58
58
|
},
|
|
59
59
|
"@uniweb/theming": {
|
|
60
|
-
"version": "1.3.
|
|
60
|
+
"version": "1.3.3"
|
|
61
61
|
},
|
|
62
62
|
"@uniweb/unipress": {
|
|
63
63
|
"version": "1.1.41"
|