@tryvitris/website-harness 1.0.2 → 1.1.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/README.md +76 -74
- package/agent/graph.yaml +769 -764
- package/agent/refs/admin.md +11 -11
- package/agent/refs/browser.md +6 -4
- package/agent/refs/business.md +20 -9
- package/agent/refs/implement.md +8 -6
- package/agent/refs/scheduling.md +13 -0
- package/bin/api/agent/evaluate.js +3 -3
- package/bin/api/agent/grade.js +3 -3
- package/bin/api/cli/api.js +11 -11
- package/bin/api/cli.js +13 -13
- package/bin/api/engine.js +4 -4
- package/bin/api/hosting.js +5 -5
- package/bin/api/index.js +1 -1
- package/bin/chunks/{chunk-Q6FLOYHS.js → chunk-5KRJQKHB.js} +3 -3
- package/bin/chunks/{chunk-YYK6367V.js → chunk-AD7WAHW2.js} +2 -2
- package/bin/chunks/{chunk-GO3XEQBA.js → chunk-AS74YXGM.js} +3 -3
- package/bin/chunks/{chunk-GM57SNLL.js → chunk-DDJ3QCRR.js} +9 -9
- package/bin/chunks/chunk-GPS3SAGQ.js +1020 -0
- package/bin/chunks/{chunk-ATPI2YRF.js → chunk-KR5ZUZV2.js} +2 -2
- package/bin/chunks/{chunk-YYYPSFFZ.js → chunk-MAPY3YVE.js} +2 -2
- package/bin/chunks/{chunk-OQGUEQ6F.js → chunk-MYX4FET4.js} +1 -1
- package/bin/chunks/{chunk-XJTAR7KM.js → chunk-OZD7ZWDX.js} +1 -1
- package/bin/chunks/{chunk-CPQQQ5YB.js → chunk-SBOUSO3S.js} +3 -3
- package/bin/chunks/{chunk-BMD5GVUT.js → chunk-SXPLCCO7.js} +6 -6
- package/bin/chunks/{chunk-QRIYA3GJ.js → chunk-WIT6364Y.js} +3 -3
- package/bin/chunks/{chunk-JPQCUN2J.js → chunk-WK7HJI5H.js} +1 -1
- package/bin/chunks/{design-context-store-BDYBQQCO.js → design-context-store-PGXCHUOF.js} +3 -3
- package/bin/chunks/{packets-RXFWDCK2.js → packets-B7MCJ42T.js} +3 -3
- package/bin/chunks/{preparation-ETEEMB5H.js → preparation-MVKICQPD.js} +3 -3
- package/bin/types/src/build/index.d.ts +2 -0
- package/bin/types/src/cli/admin.d.ts +1 -1
- package/bin/types/src/scheduling/config.d.ts +11 -0
- package/bin/types/src/scheduling/management.d.ts +2 -0
- package/bin/types/src/scheduling/styles.d.ts +1 -0
- package/bin/types/src/scheduling/widget.d.ts +2 -0
- package/bin/vitris-art.js +3 -3
- package/bin/vitris-build.js +2 -2
- package/bin/vitris-create-site.js +5 -5
- package/bin/vitris-cursor-hook.js +3 -3
- package/bin/vitris-eval.js +5 -5
- package/bin/vitris-go.js +5 -5
- package/bin/vitris-harvest.js +4 -4
- package/bin/vitris-knowledge.js +4 -4
- package/bin/vitris-launch-preflight.js +3 -3
- package/bin/vitris-motion-view.js +3 -3
- package/bin/vitris-references.js +2 -2
- package/bin/vitris-refresh.js +4 -4
- package/bin/vitris-stock.js +1 -1
- package/bin/vitris-themes.js +3 -3
- package/bin/vitris-upgrade.js +4 -4
- package/bin/vitris-verify-browser.js +3 -3
- package/bin/vitris-verify-performance.js +2 -2
- package/bin/vitris.js +13 -13
- package/docs/ADMIN.md +85 -85
- package/docs/CLI.md +314 -312
- package/docs/SCHEDULING.md +67 -0
- package/package.json +5 -4
- package/bin/chunks/chunk-NMTFSWPK.js +0 -332
package/bin/vitris-stock.js
CHANGED
|
@@ -33,7 +33,7 @@ if (!command || command === "--help") {
|
|
|
33
33
|
if (!site) throw new Error("--site required");
|
|
34
34
|
const item = readStockCatalog(catalogPath).items.find((i) => i.id === id);
|
|
35
35
|
if (!item) throw new Error("Unknown stock asset");
|
|
36
|
-
const { findActivePreparation } = await import("./chunks/preparation-
|
|
36
|
+
const { findActivePreparation } = await import("./chunks/preparation-MVKICQPD.js");
|
|
37
37
|
const current = existsSync(join(site, "agent/PREPARED.json"));
|
|
38
38
|
if (current && !findActivePreparation(site, "media") && !findActivePreparation(site, "asset-production")) throw new Error("Import stock during media or asset-production; route later additions through the declared owner");
|
|
39
39
|
const launch = existsSync(join(site, "launch.json")) ? json(join(site, "launch.json")) : {};
|
package/bin/vitris-themes.js
CHANGED
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
thumbnailService,
|
|
20
20
|
validateAdaptationPreferences,
|
|
21
21
|
writeThemePicker
|
|
22
|
-
} from "./chunks/chunk-
|
|
22
|
+
} from "./chunks/chunk-WK7HJI5H.js";
|
|
23
23
|
import "./chunks/chunk-KVMZSQ3D.js";
|
|
24
24
|
import "./chunks/chunk-WOORR67N.js";
|
|
25
25
|
import "./chunks/chunk-PRLL7B63.js";
|
|
@@ -45,8 +45,8 @@ import {
|
|
|
45
45
|
import "./chunks/chunk-BIEDSEL2.js";
|
|
46
46
|
import "./chunks/chunk-IKNMBGGD.js";
|
|
47
47
|
import "./chunks/chunk-WEFDVXFX.js";
|
|
48
|
-
import "./chunks/chunk-
|
|
49
|
-
import "./chunks/chunk-
|
|
48
|
+
import "./chunks/chunk-WIT6364Y.js";
|
|
49
|
+
import "./chunks/chunk-GPS3SAGQ.js";
|
|
50
50
|
import "./chunks/chunk-JTXFTNEA.js";
|
|
51
51
|
import "./chunks/chunk-GE6UUEG2.js";
|
|
52
52
|
import "./chunks/chunk-YYPYYOEV.js";
|
package/bin/vitris-upgrade.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
upgradeSite
|
|
4
|
-
} from "./chunks/chunk-
|
|
4
|
+
} from "./chunks/chunk-KR5ZUZV2.js";
|
|
5
5
|
import "./chunks/chunk-JCRGE6AL.js";
|
|
6
|
-
import "./chunks/chunk-
|
|
6
|
+
import "./chunks/chunk-WK7HJI5H.js";
|
|
7
7
|
import "./chunks/chunk-KVMZSQ3D.js";
|
|
8
8
|
import "./chunks/chunk-WOORR67N.js";
|
|
9
9
|
import "./chunks/chunk-PRLL7B63.js";
|
|
@@ -17,8 +17,8 @@ import "./chunks/chunk-C3F7XQD2.js";
|
|
|
17
17
|
import "./chunks/chunk-BIEDSEL2.js";
|
|
18
18
|
import "./chunks/chunk-IKNMBGGD.js";
|
|
19
19
|
import "./chunks/chunk-WEFDVXFX.js";
|
|
20
|
-
import "./chunks/chunk-
|
|
21
|
-
import "./chunks/chunk-
|
|
20
|
+
import "./chunks/chunk-WIT6364Y.js";
|
|
21
|
+
import "./chunks/chunk-GPS3SAGQ.js";
|
|
22
22
|
import "./chunks/chunk-JTXFTNEA.js";
|
|
23
23
|
import "./chunks/chunk-GE6UUEG2.js";
|
|
24
24
|
import "./chunks/chunk-YYPYYOEV.js";
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
templateMotionHash,
|
|
13
13
|
typographyPolicy,
|
|
14
14
|
validateTemplateMotionPlan
|
|
15
|
-
} from "./chunks/chunk-
|
|
15
|
+
} from "./chunks/chunk-WK7HJI5H.js";
|
|
16
16
|
import "./chunks/chunk-KVMZSQ3D.js";
|
|
17
17
|
import "./chunks/chunk-WOORR67N.js";
|
|
18
18
|
import "./chunks/chunk-PRLL7B63.js";
|
|
@@ -43,10 +43,10 @@ import {
|
|
|
43
43
|
} from "./chunks/chunk-WEFDVXFX.js";
|
|
44
44
|
import {
|
|
45
45
|
buildVerified
|
|
46
|
-
} from "./chunks/chunk-
|
|
46
|
+
} from "./chunks/chunk-WIT6364Y.js";
|
|
47
47
|
import {
|
|
48
48
|
loadSitePages
|
|
49
|
-
} from "./chunks/chunk-
|
|
49
|
+
} from "./chunks/chunk-GPS3SAGQ.js";
|
|
50
50
|
import "./chunks/chunk-JTXFTNEA.js";
|
|
51
51
|
import "./chunks/chunk-GE6UUEG2.js";
|
|
52
52
|
import "./chunks/chunk-YYPYYOEV.js";
|
|
@@ -7,8 +7,8 @@ import {
|
|
|
7
7
|
} from "./chunks/chunk-WEFDVXFX.js";
|
|
8
8
|
import {
|
|
9
9
|
buildVerified
|
|
10
|
-
} from "./chunks/chunk-
|
|
11
|
-
import "./chunks/chunk-
|
|
10
|
+
} from "./chunks/chunk-WIT6364Y.js";
|
|
11
|
+
import "./chunks/chunk-GPS3SAGQ.js";
|
|
12
12
|
import "./chunks/chunk-JTXFTNEA.js";
|
|
13
13
|
import "./chunks/chunk-GE6UUEG2.js";
|
|
14
14
|
import "./chunks/chunk-YYPYYOEV.js";
|
package/bin/vitris.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
runCli
|
|
4
|
-
} from "./chunks/chunk-
|
|
5
|
-
import "./chunks/chunk-
|
|
6
|
-
import "./chunks/chunk-
|
|
7
|
-
import "./chunks/chunk-
|
|
8
|
-
import "./chunks/chunk-
|
|
9
|
-
import "./chunks/chunk-
|
|
4
|
+
} from "./chunks/chunk-DDJ3QCRR.js";
|
|
5
|
+
import "./chunks/chunk-SXPLCCO7.js";
|
|
6
|
+
import "./chunks/chunk-AD7WAHW2.js";
|
|
7
|
+
import "./chunks/chunk-SBOUSO3S.js";
|
|
8
|
+
import "./chunks/chunk-KR5ZUZV2.js";
|
|
9
|
+
import "./chunks/chunk-5KRJQKHB.js";
|
|
10
10
|
import "./chunks/chunk-2NW7KSPA.js";
|
|
11
|
-
import "./chunks/chunk-
|
|
12
|
-
import "./chunks/chunk-
|
|
13
|
-
import "./chunks/chunk-
|
|
11
|
+
import "./chunks/chunk-MYX4FET4.js";
|
|
12
|
+
import "./chunks/chunk-AS74YXGM.js";
|
|
13
|
+
import "./chunks/chunk-MAPY3YVE.js";
|
|
14
14
|
import "./chunks/chunk-34H54KEY.js";
|
|
15
15
|
import "./chunks/chunk-JCRGE6AL.js";
|
|
16
16
|
import "./chunks/chunk-XL2DRAYI.js";
|
|
17
|
-
import "./chunks/chunk-
|
|
17
|
+
import "./chunks/chunk-OZD7ZWDX.js";
|
|
18
18
|
import "./chunks/chunk-XGTHGWPW.js";
|
|
19
|
-
import "./chunks/chunk-
|
|
19
|
+
import "./chunks/chunk-WK7HJI5H.js";
|
|
20
20
|
import "./chunks/chunk-KVMZSQ3D.js";
|
|
21
21
|
import "./chunks/chunk-WOORR67N.js";
|
|
22
22
|
import "./chunks/chunk-PRLL7B63.js";
|
|
@@ -30,8 +30,8 @@ import "./chunks/chunk-C3F7XQD2.js";
|
|
|
30
30
|
import "./chunks/chunk-BIEDSEL2.js";
|
|
31
31
|
import "./chunks/chunk-IKNMBGGD.js";
|
|
32
32
|
import "./chunks/chunk-WEFDVXFX.js";
|
|
33
|
-
import "./chunks/chunk-
|
|
34
|
-
import "./chunks/chunk-
|
|
33
|
+
import "./chunks/chunk-WIT6364Y.js";
|
|
34
|
+
import "./chunks/chunk-GPS3SAGQ.js";
|
|
35
35
|
import "./chunks/chunk-JTXFTNEA.js";
|
|
36
36
|
import "./chunks/chunk-GE6UUEG2.js";
|
|
37
37
|
import "./chunks/chunk-YYPYYOEV.js";
|
package/docs/ADMIN.md
CHANGED
|
@@ -1,85 +1,85 @@
|
|
|
1
|
-
# Separate business admin
|
|
2
|
-
|
|
3
|
-
The business owns a separate installation, accounts, D1 database, R2 bucket and Worker at `admin.customer-domain.com`. No central Vitris login is required. Pages, Media, page builders and arbitrary HTML editing are outside scope. The public website keeps its forms, backend origin, tenant identity, consent behavior and release gates.
|
|
4
|
-
|
|
5
|
-
The harness pins `@tryvitris/website-admin-harness` and `@tryvitris/website-admin-contracts` to **0.1.0-alpha.
|
|
6
|
-
|
|
7
|
-
## Local preparation
|
|
8
|
-
|
|
9
|
-
New websites may opt into next-step instructions with `vitris site create ... --admin` or `vitris-create-site ... --admin`. This creates `ADMIN-SETUP.md` only. Continue prepare → `agent/CURRENT.md` → work → complete and stop at verified local preview as usual. Existing websites can run setup directly.
|
|
10
|
-
|
|
11
|
-
Inspect the site's launch configuration, forms, exact public origin, and actual backend tenant ID. A slug is not proof of tenant identity. Prepare the sibling admin with:
|
|
12
|
-
|
|
13
|
-
```sh
|
|
14
|
-
vitris admin setup --site ../acme --dir ../acme-admin --domain admin.customer-domain.com --website https://www.customer-domain.com --tenant EXISTING_TENANT_ID --backend-origin https://BACKEND --plan
|
|
15
|
-
```
|
|
16
|
-
|
|
17
|
-
Equivalent standalone published command:
|
|
18
|
-
|
|
19
|
-
```sh
|
|
20
|
-
npx --yes @tryvitris/website-admin-harness@0.1.0-alpha.
|
|
21
|
-
```
|
|
22
|
-
|
|
23
|
-
Review `../acme/artifacts/admin/setup-plan.json`, including its exact directories, origins, tenant, scopes, package version and launch digest. Set a new dedicated `VITRIS_ADMIN_API_TOKEN` in the operator environment: 32–200 URL-safe letters/digits/underscores/hyphens generated by a secure secret manager. Repeat the identical command with `--apply` replacing `--plan`. Never pass the credential as a command argument or print it. `--lead-write` must appear in both commands only if lead status updates are explicitly wanted; default scopes are `leads:read` and `analytics:read`.
|
|
24
|
-
|
|
25
|
-
Apply brands the installation from `launch.json.name`, writes public `launch.json.admin` metadata, and saves only its SHA-256 hash in the admin's ignored `.vitris/backend-grant.json`. Existing forms, backend URL and workflow progress stay intact. Matching retries are no-ops; changed launch bytes/plans, conflicting destinations/connections or changed authority require a new review. Do not delete setup receipts or use force to bypass conflicts. Keep `artifacts/`, `.vitris/`, `.env*`, `.dev.vars*`, `dist/` and local release bundles ignored. No tenant, cloud resource, account, secret, DNS record or deployment is created by setup.
|
|
26
|
-
|
|
27
|
-
Inside the admin, install dependencies and retain its lockfile. Read `agent/WORKFLOW.md`, `agent/refs/harness.md`, and `agent/refs/cloudflare.md` before changing the installation. `npm run db:local` and `npm run dev` use a separate local manifest/database with synthetic demo data. They do not establish production backend access or working email authentication.
|
|
28
|
-
|
|
29
|
-
## Backend compatibility and grants
|
|
30
|
-
|
|
31
|
-
This source adds the admin v1 API. **An already deployed website backend may still run an older revision.** Setup does not upgrade it. Identify its owner, deployed revision, schema and hostname; perform any backend release as a separately reviewed operation. Never deploy or migrate a shared backend as an admin setup side effect. No production endpoint or credential is included in this public repository, so an existing deployment's compatibility must be checked per installation.
|
|
32
|
-
|
|
33
|
-
`vitris admin status --site ../acme` reports local metadata only. After the grant is installed, use the dedicated credential in the operator environment to check the deployed API:
|
|
34
|
-
|
|
35
|
-
```sh
|
|
36
|
-
vitris admin verify --site ../acme --dir ../acme-admin
|
|
37
|
-
```
|
|
38
|
-
|
|
39
|
-
Verify requires v1 identity matching installation, tenant and site origin, both read scopes, and valid production leads, test submissions and analytics responses. It reports counts only; zero rows are valid. It fails on missing routes, rejected/revoked credentials, identity mismatch, malformed records, redirects or transport failure. It does not certify collection, email, account login or deployment. The admin's published adapter likewise surfaces failures without substituting demo records.
|
|
40
|
-
|
|
41
|
-
The backend secret `ADMIN_CONNECTIONS` is a COMPLETE installation-keyed map. Each grant contains only `tenantId`, exact HTTPS `siteOrigin`, `tokenHash` and `scopes`. Retrieve the authoritative full map from the backend owner's secure configuration; Wrangler cannot recover a secret's value. For a confirmed brand-new backend only, initialize a private ignored file with `{}`. Do not treat an unknown existing map as empty.
|
|
42
|
-
|
|
43
|
-
```sh
|
|
44
|
-
vitris admin grant --dir ../acme-admin --grants PRIVATE_COMPLETE_MAP.json --out NEW_PRIVATE_MERGED_MAP.json
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
This local command preserves other grants, validates hashed entries and installation identity, refuses differing existing authority and refuses overwriting the output. Store input/output in ignored operator storage. Review the entire merged map before explicitly uploading it to the intended backend as `ADMIN_CONNECTIONS` via Wrangler secret stdin. Rotation/revocation is a separate reviewed complete-map update: replace the hash or remove only that installation. Never reuse forms, deployment, personal Cloudflare or session credentials.
|
|
48
|
-
|
|
49
|
-
Upload the matching RAW credential to this admin as `HARNESS_API_TOKEN`, through secret stdin. For example, from the admin directory, with the dedicated token already in the operator environment (PowerShell and POSIX shells both support this pipeline):
|
|
50
|
-
|
|
51
|
-
```sh
|
|
52
|
-
node -e "process.stdout.write(process.env.VITRIS_ADMIN_API_TOKEN || '')" | npx wrangler secret put HARNESS_API_TOKEN --config wrangler.jsonc
|
|
53
|
-
```
|
|
54
|
-
|
|
55
|
-
Require a nonempty valid environment token before running this command. Install the reviewed complete backend map similarly, by piping the ignored file bytes to `wrangler secret put ADMIN_CONNECTIONS` with the backend's exact config/account. These are explicit cloud writes, outside local setup. Never log secret stdin or store raw tokens in files or public assets.
|
|
56
|
-
|
|
57
|
-
## API and stored data
|
|
58
|
-
|
|
59
|
-
Server-to-server requests use `Authorization: Bearer ...`, `x-vitris-installation` and `x-vitris-site-origin`. The routes are `/api/admin/v1/TENANT/status`, `/leads`, `/leads?mode=test`, `/analytics?days=14`, and optional POST `/leads/status` with JSON `{id,status}`. Cookie login, browser Origin requests, forms setup tokens and deployment tokens grant no API access. All responses are uncached; preview hosts cannot reach these routes.
|
|
60
|
-
|
|
61
|
-
Every query constrains the existing tenant ID. Production reads use `leads`, including retained legacy records. Test reads use `form_submissions WHERE mode='test'` and matching notification captures from `form_outbox`; test records are always read-only. Production enquiries count stored leads. Analytics reads current `analytics_events` with live/legacy source only and excludes preview traffic; consent still controls the existing collector. Dates are UTC; the accepted range is 1–90 days. Leads return the latest 200 at most, bounded below the published adapter's 4 MB limit; `truncated` signals a bounded result. This alpha has no historical pagination/export UI.
|
|
62
|
-
|
|
63
|
-
Status updates allow `new`, `contacted`, or `closed` and require `leads:write` in addition to the admin's authenticated role and CSRF protections. Cross-tenant and test IDs cannot be updated. They do not retry notifications, change recipients or change collection. Existing D1 migrations remain untouched; this API uses the current schema. Review missing migrations separately for older deployments.
|
|
64
|
-
|
|
65
|
-
## Explicit Cloudflare rollout
|
|
66
|
-
|
|
67
|
-
Use the customer's intended account and inspect `npx wrangler whoami` before any write. The admin defaults to Workers with Static Assets, D1, R2 and Cloudflare Email Service authentication. Its generated production config disables workers.dev and uses a canonical Custom Domain. Keep local and production manifests/resources separate.
|
|
68
|
-
|
|
69
|
-
1. In the admin directory, run `npm run plan`. Review Worker/resource names, account ID, zone ownership, sender and hostname. Run `npx wrangler d1 create ACME_ADMIN_DB` and `npx wrangler r2 bucket create ACME_ADMIN_ASSETS` only as explicit provisioning steps. Put their actual identifiers into `wrangler.jsonc`; use dedicated resources for this business.
|
|
70
|
-
2. Back up any existing target database. Review copied numbered migrations; apply only to the admin's intended database with `npx wrangler d1 migrations apply ACME_ADMIN_DB --remote --config wrangler.jsonc`. Do not apply admin migrations to the website backend database.
|
|
71
|
-
3. Run `npx vitris-admin owner --email OWNER_EMAIL` inside the admin. Review ignored `.vitris/bootstrap-owner.sql`, then apply it with `npx wrangler d1 execute ACME_ADMIN_DB --remote --config wrangler.jsonc --file .vitris/bootstrap-owner.sql`. Existing accounts are not promoted. Each installation owns its users and sessions.
|
|
72
|
-
4. Complete Cloudflare Email Service sender-domain onboarding and sending availability. Set `AUTH_FROM` and a restricted `AUTH_EMAIL` send binding in the production config. Verify provider/recipient restrictions, real delivery, single-use login and revocation. The alpha's stubbed email tests do not prove live delivery. Never enable production demo login or use local mode in production.
|
|
73
|
-
5. Merge/install the backend grant and install `HARNESS_API_TOKEN` through secret stdin as above. Verify the deployed backend API independently. If it needs a compatible release, review its impact and owner authorization separately, retaining existing records/accounts and tenant IDs.
|
|
74
|
-
6. Attach `admin.customer-domain.com` as the generated Worker Custom Domain in the active zone of this account. Verify DNS, TLS and canonical-host checks. Cross-account/external DNS requires a separate reviewed hostname strategy; a CNAME alone does not satisfy this contract.
|
|
75
|
-
7. Run `npm run doctor` and `npm run build` (dry run), review the configuration/release diff, then explicitly deploy the admin with `npm run deploy`. Verify the canonical HTTPS domain, actual owner login, signed-in permissions, revoked access and authoritative stored records. Record the deployed revision. Public website publication continues through its own consent and release gates.
|
|
76
|
-
|
|
77
|
-
### Websites without collection
|
|
78
|
-
|
|
79
|
-
A static website without a registered backend has no historical lead or analytics records to import. Prepare a dedicated website backend Worker, D1 schema, R2 and KV bindings (and optional Analytics Engine) from the harness's `cloudflare/` example. Review account/resource ownership, session secret, migrations and tenant/hostname registration before any cloud writes. Keep backend provisioning and deployment separate from the admin database and deployment.
|
|
80
|
-
|
|
81
|
-
Use `vitris forms inspect` and the plan/apply workflow in `docs/CONTACT-FORMS.md` to register approved origins, form schemas, Turnstile, notification sender and recipients. Preserve existing form endpoints until the owner selects the replacement flow. Validate test submissions in isolation first; do not send customer test notifications without authorization. Enable the existing analytics collector only with the site's consent policy and production hostname/tenant mapping. Scaffolding an admin, setting backendOrigin, or binding a subdomain enables none of this automatically.
|
|
82
|
-
|
|
83
|
-
## Validation
|
|
84
|
-
|
|
85
|
-
`npm run test:admin` runs isolated synthetic fixtures against actual local D1 and the published runtime Worker adapter, including installer plan/apply/recovery, conflicts, stale plans, identity/account isolation, unauthorized/revoked credentials, read-only grants, test separation and preview exclusion. No live challenge or mail is used: assets and backend transport are in-process test bindings; form rows and analytics are explicitly synthetic stored fixtures. `npm run verify:admin` installs all three exact public npm releases in a fresh ignored directory, then reruns acceptance against that runtime. Evidence stays in `artifacts/admin-integration/`. Run the repository's typecheck, full tests and package verification too.
|
|
1
|
+
# Separate business admin
|
|
2
|
+
|
|
3
|
+
The business owns a separate installation, accounts, D1 database, R2 bucket and Worker at `admin.customer-domain.com`. No central Vitris login is required. Pages, Media, page builders and arbitrary HTML editing are outside scope. The public website keeps its forms, backend origin, tenant identity, consent behavior and release gates.
|
|
4
|
+
|
|
5
|
+
The harness pins `@tryvitris/website-admin-harness` and `@tryvitris/website-admin-contracts` to **0.1.0-alpha.2**. Setup delegates to the published runtime's `/cli` export (`vitris-admin`); its Worker uses `/worker`. The separate initializer is `@tryvitris/create-website-admin-harness@0.1.0-alpha.2`. Never use a floating `alpha` tag for a reproducible installation. See the [upstream source](https://github.com/jackperrotta/website-admin-harness).
|
|
6
|
+
|
|
7
|
+
## Local preparation
|
|
8
|
+
|
|
9
|
+
New websites may opt into next-step instructions with `vitris site create ... --admin` or `vitris-create-site ... --admin`. This creates `ADMIN-SETUP.md` only. Continue prepare → `agent/CURRENT.md` → work → complete and stop at verified local preview as usual. Existing websites can run setup directly.
|
|
10
|
+
|
|
11
|
+
Inspect the site's launch configuration, forms, exact public origin, and actual backend tenant ID. A slug is not proof of tenant identity. Prepare the sibling admin with:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
vitris admin setup --site ../acme --dir ../acme-admin --domain admin.customer-domain.com --website https://www.customer-domain.com --tenant EXISTING_TENANT_ID --backend-origin https://BACKEND --plan
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Equivalent standalone published command:
|
|
18
|
+
|
|
19
|
+
```sh
|
|
20
|
+
npx --yes @tryvitris/website-admin-harness@0.1.0-alpha.2 setup --site ../acme --dir ../acme-admin --domain admin.customer-domain.com --website https://www.customer-domain.com --tenant EXISTING_TENANT_ID --backend-origin https://BACKEND --plan
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Review `../acme/artifacts/admin/setup-plan.json`, including its exact directories, origins, tenant, scopes, package version and launch digest. Set a new dedicated `VITRIS_ADMIN_API_TOKEN` in the operator environment: 32–200 URL-safe letters/digits/underscores/hyphens generated by a secure secret manager. Repeat the identical command with `--apply` replacing `--plan`. Never pass the credential as a command argument or print it. `--lead-write` must appear in both commands only if lead status updates are explicitly wanted; default scopes are `leads:read` and `analytics:read`.
|
|
24
|
+
|
|
25
|
+
Apply brands the installation from `launch.json.name`, writes public `launch.json.admin` metadata, and saves only its SHA-256 hash in the admin's ignored `.vitris/backend-grant.json`. Existing forms, backend URL and workflow progress stay intact. Matching retries are no-ops; changed launch bytes/plans, conflicting destinations/connections or changed authority require a new review. Do not delete setup receipts or use force to bypass conflicts. Keep `artifacts/`, `.vitris/`, `.env*`, `.dev.vars*`, `dist/` and local release bundles ignored. No tenant, cloud resource, account, secret, DNS record or deployment is created by setup.
|
|
26
|
+
|
|
27
|
+
Inside the admin, install dependencies and retain its lockfile. Read `agent/WORKFLOW.md`, `agent/refs/harness.md`, and `agent/refs/cloudflare.md` before changing the installation. `npm run db:local` and `npm run dev` use a separate local manifest/database with synthetic demo data. They do not establish production backend access or working email authentication.
|
|
28
|
+
|
|
29
|
+
## Backend compatibility and grants
|
|
30
|
+
|
|
31
|
+
This source adds the admin v1 API. **An already deployed website backend may still run an older revision.** Setup does not upgrade it. Identify its owner, deployed revision, schema and hostname; perform any backend release as a separately reviewed operation. Never deploy or migrate a shared backend as an admin setup side effect. No production endpoint or credential is included in this public repository, so an existing deployment's compatibility must be checked per installation.
|
|
32
|
+
|
|
33
|
+
`vitris admin status --site ../acme` reports local metadata only. After the grant is installed, use the dedicated credential in the operator environment to check the deployed API:
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
vitris admin verify --site ../acme --dir ../acme-admin
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
Verify requires v1 identity matching installation, tenant and site origin, both read scopes, and valid production leads, test submissions and analytics responses. It reports counts only; zero rows are valid. It fails on missing routes, rejected/revoked credentials, identity mismatch, malformed records, redirects or transport failure. It does not certify collection, email, account login or deployment. The admin's published adapter likewise surfaces failures without substituting demo records.
|
|
40
|
+
|
|
41
|
+
The backend secret `ADMIN_CONNECTIONS` is a COMPLETE installation-keyed map. Each grant contains only `tenantId`, exact HTTPS `siteOrigin`, `tokenHash` and `scopes`. Retrieve the authoritative full map from the backend owner's secure configuration; Wrangler cannot recover a secret's value. For a confirmed brand-new backend only, initialize a private ignored file with `{}`. Do not treat an unknown existing map as empty.
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
vitris admin grant --dir ../acme-admin --grants PRIVATE_COMPLETE_MAP.json --out NEW_PRIVATE_MERGED_MAP.json
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
This local command preserves other grants, validates hashed entries and installation identity, refuses differing existing authority and refuses overwriting the output. Store input/output in ignored operator storage. Review the entire merged map before explicitly uploading it to the intended backend as `ADMIN_CONNECTIONS` via Wrangler secret stdin. Rotation/revocation is a separate reviewed complete-map update: replace the hash or remove only that installation. Never reuse forms, deployment, personal Cloudflare or session credentials.
|
|
48
|
+
|
|
49
|
+
Upload the matching RAW credential to this admin as `HARNESS_API_TOKEN`, through secret stdin. For example, from the admin directory, with the dedicated token already in the operator environment (PowerShell and POSIX shells both support this pipeline):
|
|
50
|
+
|
|
51
|
+
```sh
|
|
52
|
+
node -e "process.stdout.write(process.env.VITRIS_ADMIN_API_TOKEN || '')" | npx wrangler secret put HARNESS_API_TOKEN --config wrangler.jsonc
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
Require a nonempty valid environment token before running this command. Install the reviewed complete backend map similarly, by piping the ignored file bytes to `wrangler secret put ADMIN_CONNECTIONS` with the backend's exact config/account. These are explicit cloud writes, outside local setup. Never log secret stdin or store raw tokens in files or public assets.
|
|
56
|
+
|
|
57
|
+
## API and stored data
|
|
58
|
+
|
|
59
|
+
Server-to-server requests use `Authorization: Bearer ...`, `x-vitris-installation` and `x-vitris-site-origin`. The routes are `/api/admin/v1/TENANT/status`, `/leads`, `/leads?mode=test`, `/analytics?days=14`, and optional POST `/leads/status` with JSON `{id,status}`. Cookie login, browser Origin requests, forms setup tokens and deployment tokens grant no API access. All responses are uncached; preview hosts cannot reach these routes.
|
|
60
|
+
|
|
61
|
+
Every query constrains the existing tenant ID. Production reads use `leads`, including retained legacy records. Test reads use `form_submissions WHERE mode='test'` and matching notification captures from `form_outbox`; test records are always read-only. Production enquiries count stored leads. Analytics reads current `analytics_events` with live/legacy source only and excludes preview traffic; consent still controls the existing collector. Dates are UTC; the accepted range is 1–90 days. Leads return the latest 200 at most, bounded below the published adapter's 4 MB limit; `truncated` signals a bounded result. This alpha has no historical pagination/export UI.
|
|
62
|
+
|
|
63
|
+
Status updates allow `new`, `contacted`, or `closed` and require `leads:write` in addition to the admin's authenticated role and CSRF protections. Cross-tenant and test IDs cannot be updated. They do not retry notifications, change recipients or change collection. Existing D1 migrations remain untouched; this API uses the current schema. Review missing migrations separately for older deployments.
|
|
64
|
+
|
|
65
|
+
## Explicit Cloudflare rollout
|
|
66
|
+
|
|
67
|
+
Use the customer's intended account and inspect `npx wrangler whoami` before any write. The admin defaults to Workers with Static Assets, D1, R2 and Cloudflare Email Service authentication. Its generated production config disables workers.dev and uses a canonical Custom Domain. Keep local and production manifests/resources separate.
|
|
68
|
+
|
|
69
|
+
1. In the admin directory, run `npm run plan`. Review Worker/resource names, account ID, zone ownership, sender and hostname. Run `npx wrangler d1 create ACME_ADMIN_DB` and `npx wrangler r2 bucket create ACME_ADMIN_ASSETS` only as explicit provisioning steps. Put their actual identifiers into `wrangler.jsonc`; use dedicated resources for this business.
|
|
70
|
+
2. Back up any existing target database. Review copied numbered migrations; apply only to the admin's intended database with `npx wrangler d1 migrations apply ACME_ADMIN_DB --remote --config wrangler.jsonc`. Do not apply admin migrations to the website backend database.
|
|
71
|
+
3. Run `npx vitris-admin owner --email OWNER_EMAIL` inside the admin. Review ignored `.vitris/bootstrap-owner.sql`, then apply it with `npx wrangler d1 execute ACME_ADMIN_DB --remote --config wrangler.jsonc --file .vitris/bootstrap-owner.sql`. Existing accounts are not promoted. Each installation owns its users and sessions.
|
|
72
|
+
4. Complete Cloudflare Email Service sender-domain onboarding and sending availability. Set `AUTH_FROM` and a restricted `AUTH_EMAIL` send binding in the production config. Verify provider/recipient restrictions, real delivery, single-use login and revocation. The alpha's stubbed email tests do not prove live delivery. Never enable production demo login or use local mode in production.
|
|
73
|
+
5. Merge/install the backend grant and install `HARNESS_API_TOKEN` through secret stdin as above. Verify the deployed backend API independently. If it needs a compatible release, review its impact and owner authorization separately, retaining existing records/accounts and tenant IDs.
|
|
74
|
+
6. Attach `admin.customer-domain.com` as the generated Worker Custom Domain in the active zone of this account. Verify DNS, TLS and canonical-host checks. Cross-account/external DNS requires a separate reviewed hostname strategy; a CNAME alone does not satisfy this contract.
|
|
75
|
+
7. Run `npm run doctor` and `npm run build` (dry run), review the configuration/release diff, then explicitly deploy the admin with `npm run deploy`. Verify the canonical HTTPS domain, actual owner login, signed-in permissions, revoked access and authoritative stored records. Record the deployed revision. Public website publication continues through its own consent and release gates.
|
|
76
|
+
|
|
77
|
+
### Websites without collection
|
|
78
|
+
|
|
79
|
+
A static website without a registered backend has no historical lead or analytics records to import. Prepare a dedicated website backend Worker, D1 schema, R2 and KV bindings (and optional Analytics Engine) from the harness's `cloudflare/` example. Review account/resource ownership, session secret, migrations and tenant/hostname registration before any cloud writes. Keep backend provisioning and deployment separate from the admin database and deployment.
|
|
80
|
+
|
|
81
|
+
Use `vitris forms inspect` and the plan/apply workflow in `docs/CONTACT-FORMS.md` to register approved origins, form schemas, Turnstile, notification sender and recipients. Preserve existing form endpoints until the owner selects the replacement flow. Validate test submissions in isolation first; do not send customer test notifications without authorization. Enable the existing analytics collector only with the site's consent policy and production hostname/tenant mapping. Scaffolding an admin, setting backendOrigin, or binding a subdomain enables none of this automatically.
|
|
82
|
+
|
|
83
|
+
## Validation
|
|
84
|
+
|
|
85
|
+
`npm run test:admin` runs isolated synthetic fixtures against actual local D1 and the published runtime Worker adapter, including installer plan/apply/recovery, conflicts, stale plans, identity/account isolation, unauthorized/revoked credentials, read-only grants, test separation and preview exclusion. No live challenge or mail is used: assets and backend transport are in-process test bindings; form rows and analytics are explicitly synthetic stored fixtures. `npm run verify:admin` installs all three exact public npm releases in a fresh ignored directory, then reruns acceptance against that runtime. Evidence stays in `artifacts/admin-integration/`. Run the repository's typecheck, full tests and package verification too.
|