@engenty/wizards-runtime 0.9.2 → 0.9.4
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 +34 -39
- package/apps/runtime/dist/assistant/docs.js +1 -1
- package/apps/runtime/dist/assistant/primer.js +2 -2
- package/apps/runtime/dist/db/migrations/tenant/0020_project_page.sql +1 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/0020_snapshot.json +3475 -0
- package/apps/runtime/dist/db/migrations/tenant/meta/_journal.json +7 -0
- package/apps/runtime/dist/db/schema.js +2 -0
- package/apps/runtime/dist/docs/dev/api.md +1 -1
- package/apps/runtime/dist/docs/dev/integration/channels.md +4 -4
- package/apps/runtime/dist/docs/dev/integration/claude-code-plugin.md +1 -1
- package/apps/runtime/dist/docs/dev/integration/embed.md +1 -1
- package/apps/runtime/dist/docs/dev/integration/index.md +2 -3
- package/apps/runtime/dist/docs/dev/integration/link-and-share.md +1 -1
- package/apps/runtime/dist/docs/dev/integration/mcp-apps.md +1 -1
- package/apps/runtime/dist/docs/dev/integration/mcp.md +1 -1
- package/apps/runtime/dist/docs/dev/integration/meta.json +0 -1
- package/apps/runtime/dist/docs/dev/integration/openui.md +7 -3
- package/apps/runtime/dist/docs/dev/integration/results.md +1 -3
- package/apps/runtime/dist/docs/dev/plugins/routes.md +1 -1
- package/apps/runtime/dist/docs/dev/wizard-format/themes.md +2 -2
- package/apps/runtime/dist/docs/dev/wizard-format/validate.md +1 -1
- package/apps/runtime/dist/docs/meta.json +1 -1
- package/apps/runtime/dist/docs/{user → user-guide}/ai-apps.md +4 -5
- package/apps/runtime/dist/docs/{user → user-guide}/build-a-wizard.md +42 -37
- package/apps/runtime/dist/docs/{user → user-guide}/command-line.md +9 -8
- package/apps/runtime/dist/docs/{user → user-guide}/connectors.md +6 -6
- package/apps/runtime/dist/docs/{user → user-guide}/create-account.md +10 -11
- package/apps/runtime/dist/docs/{user → user-guide}/data.md +5 -5
- package/apps/runtime/dist/docs/{user → user-guide}/first-start.md +5 -5
- package/apps/runtime/dist/docs/{user → user-guide}/index.md +3 -3
- package/apps/runtime/dist/docs/{user → user-guide}/install.md +21 -25
- package/apps/runtime/dist/docs/{user → user-guide}/local-only.md +5 -6
- package/apps/runtime/dist/docs/{user → user-guide}/meta.json +0 -2
- package/apps/runtime/dist/docs/{user → user-guide}/models.md +13 -22
- package/apps/runtime/dist/docs/{user → user-guide}/plugins.md +2 -2
- package/apps/runtime/dist/docs/{user → user-guide}/run.md +21 -36
- package/apps/runtime/dist/docs/{user → user-guide}/server.md +1 -1
- package/apps/runtime/dist/docs/{user → user-guide}/space.md +17 -27
- package/apps/runtime/dist/docs/{user → user-guide}/steps.md +22 -34
- package/apps/runtime/dist/docs/{user → user-guide}/test-and-share.md +35 -76
- package/apps/runtime/dist/docs/{user → user-guide}/troubleshooting.md +3 -4
- package/apps/runtime/dist/engine/runner.js +7 -4
- package/apps/runtime/dist/manage.js +7 -0
- package/apps/runtime/dist/routes/runs.js +26 -0
- package/apps/runtime/dist/routes/studio.js +21 -2
- package/apps/runtime/dist/services/brand.js +20 -0
- package/apps/runtime/dist/services/errors.js +1 -0
- package/apps/runtime/dist/services/pages.js +262 -0
- package/apps/runtime/dist/services/projects.js +73 -2
- package/apps/runtime/dist/services/runners.js +12 -2
- package/apps/runtime/dist/services/runs.js +75 -1
- package/apps/runtime/dist/services/shipped-fonts.js +33 -0
- package/apps/runtime/dist/services/wizards.js +30 -1
- package/apps/web/dist/assets/AboutDialog-CsqUDxPv.js +1 -0
- package/apps/web/dist/assets/{ChangelogDialog-ClkjHGE_.js → ChangelogDialog-vV9nXOBV.js} +1 -1
- package/apps/web/dist/assets/EditorPage-CfmubDLB.js +4 -0
- package/apps/web/dist/assets/{FlowPreview-DZRkWedM.js → FlowPreview-DoBlokAp.js} +1 -1
- package/apps/web/dist/assets/{Harness-FiDeF3LX.js → Harness-GnlSI4-P.js} +2 -2
- package/apps/web/dist/assets/Marketplace-CYsq0K7A.js +2 -0
- package/apps/web/dist/assets/NewWizardChannels-DUS3dRCj.js +1 -0
- package/apps/web/dist/assets/NewWizardPage-Cm9ydfUW.js +7 -0
- package/apps/web/dist/assets/OnboardingPage-xI83C1V1.js +1 -0
- package/apps/web/dist/assets/PreviewPane-B-X0rChi.js +4 -0
- package/apps/web/dist/assets/ProjectPage-Bu6uD-Kb.js +1 -0
- package/apps/web/dist/assets/PublicRunner-BWBE74Kn.js +1 -0
- package/apps/web/dist/assets/{ReadOnly-I-Lm7a8y.js → ReadOnly-DKgWZ_1q.js} +1 -1
- package/apps/web/dist/assets/SettingsPage-B9euFl71.js +2 -0
- package/apps/web/dist/assets/SetupPage-C3XLbBTO.js +1 -0
- package/apps/web/dist/assets/SharePage-CSj1sAVS.js +1 -0
- package/apps/web/dist/assets/changelog-pnMcOVO_.js +1 -0
- package/apps/web/dist/assets/coins-D0MI0EKw.js +1 -0
- package/apps/web/dist/assets/esm-BdxDT9Km.js +7 -0
- package/apps/web/dist/assets/index-DtjKnB3s.css +1 -0
- package/apps/web/dist/assets/index-qc7o4bkp.js +14 -0
- package/apps/web/dist/assets/logo-CGNoptDg.js +1 -0
- package/apps/web/dist/assets/media-Cej-H610.js +1 -0
- package/apps/web/dist/assets/oss-credits-D7izqI_0.js +1 -0
- package/apps/web/dist/assets/{phone-BprN_SDS.js → phone-BZ-sPZr6.js} +1 -1
- package/apps/web/dist/assets/react-dom-hf6EcyAr.js +1 -0
- package/apps/web/dist/assets/runners-CED2yPuf.js +1 -0
- package/apps/web/dist/assets/session-DyndueX0.js +2 -0
- package/apps/web/dist/assets/settings-menu-C960R1kx.js +1 -0
- package/apps/web/dist/assets/theme-Zp5g-teI.js +11 -0
- package/apps/web/dist/assets/ui-DVkIZqDg.js +137 -0
- package/apps/web/dist/assets/{upload-Cvztyjuj.js → upload-HFTtsOaE.js} +1 -1
- package/apps/web/dist/assets/useMutation-D3zIOVOt.js +1 -0
- package/apps/web/dist/assets/volume-2-DazUIp6w.js +1 -0
- package/apps/web/dist/assets/{wrench-CWT9IGKq.js → wrench-BHe19Ol_.js} +1 -1
- package/apps/web/dist/index.html +11 -3
- package/apps/web/dist/mcp/flow.html +54 -54
- package/node_modules/@engenty/wizards/dist/plugin/studio.d.ts +3 -3
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.d.ts +24 -0
- package/node_modules/@engenty/wizards-shared/dist/feature-flags.js +24 -0
- package/node_modules/@engenty/wizards-shared/dist/projects.d.ts +36 -0
- package/node_modules/@engenty/wizards-shared/dist/projects.js +25 -0
- package/node_modules/@engenty/wizards-shared/dist/run.d.ts +3 -0
- package/node_modules/@engenty/wizards-shared/dist/run.js +6 -0
- package/node_modules/@engenty/wizards-shared/dist/theme.d.ts +7 -0
- package/node_modules/@engenty/wizards-shared/dist/theme.js +11 -0
- package/package.json +16 -3
- package/plugin/.claude-plugin/plugin.json +1 -1
- package/plugin/plugin.json +2 -2
- package/apps/runtime/dist/docs/dev/integration/wordpress.md +0 -10
- package/apps/runtime/dist/docs/user/assistant.md +0 -77
- package/apps/runtime/dist/docs/user/wordpress.md +0 -121
- package/apps/web/dist/assets/AboutDialog-BUdEn9X_.js +0 -1
- package/apps/web/dist/assets/EditorPage-j5HjqTMV.js +0 -4
- package/apps/web/dist/assets/NewWizardChannels-DeJP5h5I.js +0 -1
- package/apps/web/dist/assets/NewWizardPage-CIS3qNUz.js +0 -7
- package/apps/web/dist/assets/OnboardingPage-CoTYSubc.js +0 -1
- package/apps/web/dist/assets/ProjectPage-XVhe87S4.js +0 -1
- package/apps/web/dist/assets/PublicRunner-Bc-3e7UU.js +0 -1
- package/apps/web/dist/assets/RunDrawer-DXqyxTsm.js +0 -4
- package/apps/web/dist/assets/RunnerView-DeDApA-9.js +0 -1
- package/apps/web/dist/assets/SettingsPage-ChpDzJVn.js +0 -2
- package/apps/web/dist/assets/SetupPage-E5JoQMBM.js +0 -1
- package/apps/web/dist/assets/SharePage-DW1b2g9t.js +0 -1
- package/apps/web/dist/assets/changelog-DuSV2HiU.js +0 -1
- package/apps/web/dist/assets/esm-yMT-rSPa.js +0 -7
- package/apps/web/dist/assets/index-D9oqYYa8.css +0 -1
- package/apps/web/dist/assets/index-DfHH4icT.js +0 -14
- package/apps/web/dist/assets/oss-credits-6A3pxilr.js +0 -1
- package/apps/web/dist/assets/settings-menu-CVl54phq.js +0 -1
- package/apps/web/dist/assets/theme-DZZXa238.js +0 -11
- package/apps/web/dist/assets/ui-kIzOrA_W.js +0 -137
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { langOf, wizardLang, } from "@engenty/wizards-shared/definition";
|
|
2
|
+
import { effortOf } from "@engenty/wizards-shared/marketplace";
|
|
3
|
+
import { resultsOf } from "@engenty/wizards-shared/marketplace-entry";
|
|
4
|
+
import { factType, pageSlugOf, runTheme, } from "@engenty/wizards-shared/projects";
|
|
5
|
+
import { and, eq, inArray } from "drizzle-orm";
|
|
6
|
+
import { db, schema } from "../db/client.js";
|
|
7
|
+
import { env } from "../env.js";
|
|
8
|
+
import { feature } from "../features.js";
|
|
9
|
+
import { managed, putPages, tenantInfo } from "../manage.js";
|
|
10
|
+
import { currentTenant } from "../tenants/tenant.js";
|
|
11
|
+
import { mainLogoId } from "./brand.js";
|
|
12
|
+
/** About how many rows the teaser's step list has. */
|
|
13
|
+
const STEP_ROWS = 5;
|
|
14
|
+
/** Fields whose answer is a file the person brings. */
|
|
15
|
+
const UPLOAD_KINDS = new Set(["file", "image", "audio"]);
|
|
16
|
+
/** Facts that name who stands behind the page, by key. */
|
|
17
|
+
const NAME_KEYS = ["name", "firma", "unternehmen", "company", "firmenname", "kanzlei"];
|
|
18
|
+
/** A wizard's language where the page knows it, else the page's. */
|
|
19
|
+
function pageLangOf(def, fallback) {
|
|
20
|
+
const lang = langOf(wizardLang(def));
|
|
21
|
+
return lang === "de" || lang === "en" ? lang : fallback;
|
|
22
|
+
}
|
|
23
|
+
/** Who acts in a step: the person on a page, in a review or a surface; the AI everywhere else. */
|
|
24
|
+
const by = (step) => step.type === "page" || step.type === "review" || step.type === "surface" ? "you" : "ai";
|
|
25
|
+
/** "A und B", "A, B und C". */
|
|
26
|
+
function joinTitles(titles, lang) {
|
|
27
|
+
if (titles.length <= 1) {
|
|
28
|
+
return titles[0] ?? "";
|
|
29
|
+
}
|
|
30
|
+
const and = lang === "de" ? " und " : " and ";
|
|
31
|
+
return `${titles.slice(0, -1).join(", ")}${and}${titles.at(-1)}`;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The way through as the teaser shows it: the steps along the path a run takes when no
|
|
35
|
+
* condition applies (a branch's "otherwise", else the next step), each page, review and result
|
|
36
|
+
* step as written, the AI steps between them merged into one row, and about five rows in all.
|
|
37
|
+
* An `each` step is one step and so one row.
|
|
38
|
+
*/
|
|
39
|
+
export function pageSteps(def, lang) {
|
|
40
|
+
const path = [];
|
|
41
|
+
const seen = new Set();
|
|
42
|
+
let at = 0;
|
|
43
|
+
while (at >= 0 && at < def.steps.length && !seen.has(def.steps[at].id)) {
|
|
44
|
+
const step = def.steps[at];
|
|
45
|
+
seen.add(step.id);
|
|
46
|
+
path.push(step);
|
|
47
|
+
const otherwise = step.next?.find((r) => r.when === undefined && r.ask === undefined);
|
|
48
|
+
if (!otherwise) {
|
|
49
|
+
at += 1;
|
|
50
|
+
}
|
|
51
|
+
else if (otherwise.goto === "end") {
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
at = def.steps.findIndex((s) => s.id === otherwise.goto);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
const rows = [];
|
|
59
|
+
for (const step of path) {
|
|
60
|
+
const who = by(step);
|
|
61
|
+
const merge = who === "ai" && step.type !== "result";
|
|
62
|
+
const last = rows.at(-1);
|
|
63
|
+
if (merge && last?.merge) {
|
|
64
|
+
last.titles.push(step.title);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
rows.push({ titles: [step.title], by: who, merge });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
const kept = rows.length > STEP_ROWS ? [...rows.slice(0, STEP_ROWS - 1), rows.at(-1)] : rows;
|
|
71
|
+
return kept.map((r) => ({ title: joinTitles(r.titles, lang).slice(0, 80), by: r.by }));
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* The space's facts as the imprint: who stands behind the page, one line per fact, the postcode
|
|
75
|
+
* and the town as one line after the address, the website apart; null without filled facts.
|
|
76
|
+
*/
|
|
77
|
+
export function imprintOf(facts, fallbackName) {
|
|
78
|
+
const filled = facts.filter((f) => f.value.trim());
|
|
79
|
+
if (!filled.length) {
|
|
80
|
+
return null;
|
|
81
|
+
}
|
|
82
|
+
const named = filled.find((f) => NAME_KEYS.includes(f.key));
|
|
83
|
+
const website = filled.find((f) => f.key === "website" || factType(f) === "url");
|
|
84
|
+
const town = ["plz", "ort"]
|
|
85
|
+
.map((key) => filled.find((f) => f.key === key)?.value.trim())
|
|
86
|
+
.filter(Boolean)
|
|
87
|
+
.join(" ");
|
|
88
|
+
const apart = new Set(["plz", "ort", named?.key, website?.key]);
|
|
89
|
+
const lines = [];
|
|
90
|
+
for (const f of filled) {
|
|
91
|
+
const type = factType(f);
|
|
92
|
+
if (apart.has(f.key) || type === "longtext" || type === "boolean") {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
lines.push(f.value.trim());
|
|
96
|
+
if (f.key === "adresse" && town) {
|
|
97
|
+
lines.push(town);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
if (town && !lines.includes(town)) {
|
|
101
|
+
lines.push(town);
|
|
102
|
+
}
|
|
103
|
+
const site = website?.value.trim();
|
|
104
|
+
return {
|
|
105
|
+
name: (named?.value.trim() || fallbackName).slice(0, 200),
|
|
106
|
+
lines: lines.map((l) => l.slice(0, 200)).slice(0, 8),
|
|
107
|
+
...(site ? { website: /^https?:\/\//i.test(site) ? site : `https://${site}` } : {}),
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/** A wizard's address on the page, from its title, unique among the page's wizards; kept once made. */
|
|
111
|
+
function wizardSlug(title, taken) {
|
|
112
|
+
const base = pageSlugOf(title) || "wizard";
|
|
113
|
+
let slug = base;
|
|
114
|
+
for (let n = 2; taken.has(slug); n++) {
|
|
115
|
+
slug = `${base.slice(0, 44)}-${n}`;
|
|
116
|
+
}
|
|
117
|
+
taken.add(slug);
|
|
118
|
+
return slug;
|
|
119
|
+
}
|
|
120
|
+
/** The team's page data as Manage expects it; null where this runtime is not a team's. */
|
|
121
|
+
export async function pageTeam() {
|
|
122
|
+
if (!managed) {
|
|
123
|
+
return null;
|
|
124
|
+
}
|
|
125
|
+
const tenantId = currentTenant();
|
|
126
|
+
const team = await tenantInfo(tenantId);
|
|
127
|
+
// Only one space of a team has its page on (services/projects.ts).
|
|
128
|
+
const spaces = await db.query.project.findMany({
|
|
129
|
+
where: eq(schema.project.tenantId, tenantId),
|
|
130
|
+
});
|
|
131
|
+
// Behind its switch the team has no page: what Manage holds is sent as none.
|
|
132
|
+
const space = feature("pages", team.features) ? (spaces.find((p) => p.page?.on) ?? null) : null;
|
|
133
|
+
const page = space?.page;
|
|
134
|
+
const lang = page?.lang ?? "de";
|
|
135
|
+
const base = { slug: team.slug ?? tenantId, name: team.name, lang };
|
|
136
|
+
if (!(space && page)) {
|
|
137
|
+
return { ...base, space: null };
|
|
138
|
+
}
|
|
139
|
+
const listed = page.wizards.length
|
|
140
|
+
? await db.query.wizard.findMany({
|
|
141
|
+
where: and(eq(schema.wizard.projectId, space.id), inArray(schema.wizard.id, page.wizards), eq(schema.wizard.shareEnabled, true)),
|
|
142
|
+
})
|
|
143
|
+
: [];
|
|
144
|
+
// Addresses made before hold; a wizard new to the page gets one that is free among them.
|
|
145
|
+
const kept = page.slugs ?? {};
|
|
146
|
+
const taken = new Set(Object.values(kept));
|
|
147
|
+
const made = {};
|
|
148
|
+
const wizards = [];
|
|
149
|
+
for (const id of page.wizards) {
|
|
150
|
+
const w = listed.find((x) => x.id === id);
|
|
151
|
+
if (!w || w.publishedVersion === null) {
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
const version = await db.query.wizardVersion.findFirst({
|
|
155
|
+
where: and(eq(schema.wizardVersion.wizardId, w.id), eq(schema.wizardVersion.version, w.publishedVersion)),
|
|
156
|
+
columns: { definition: true },
|
|
157
|
+
});
|
|
158
|
+
if (!version) {
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
const def = version.definition;
|
|
162
|
+
const wizardLanguage = pageLangOf(def, lang);
|
|
163
|
+
const effort = effortOf(def);
|
|
164
|
+
const uploads = def.steps.some((s) => s.type === "page" && s.fields.some((f) => UPLOAD_KINDS.has(f.kind)));
|
|
165
|
+
const exampleToken = page.examples[w.id];
|
|
166
|
+
const example = exampleToken
|
|
167
|
+
? await db.query.run.findFirst({
|
|
168
|
+
where: and(eq(schema.run.wizardId, w.id), eq(schema.run.shareToken, exampleToken)),
|
|
169
|
+
columns: { status: true, expiresAt: true },
|
|
170
|
+
})
|
|
171
|
+
: null;
|
|
172
|
+
const shown = example?.status === "done" && !(example.expiresAt && example.expiresAt < new Date());
|
|
173
|
+
const slug = kept[w.id] ?? wizardSlug(def.title, taken);
|
|
174
|
+
if (!kept[w.id]) {
|
|
175
|
+
made[w.id] = slug;
|
|
176
|
+
}
|
|
177
|
+
wizards.push({
|
|
178
|
+
slug,
|
|
179
|
+
title: def.title.slice(0, 120),
|
|
180
|
+
description: def.description.slice(0, 600),
|
|
181
|
+
avatar: def.avatar,
|
|
182
|
+
lang: wizardLanguage,
|
|
183
|
+
results: resultsOf(def).slice(0, 12),
|
|
184
|
+
effort: { fields: effort.fields, reviews: effort.reviews, minutes: effort.minutes, uploads },
|
|
185
|
+
steps: pageSteps(def, wizardLanguage),
|
|
186
|
+
runUrl: `${env.publicUrl}/w/${w.shareToken}`,
|
|
187
|
+
...(shown ? { exampleUrl: `${env.publicUrl}/s/${exampleToken}` } : {}),
|
|
188
|
+
});
|
|
189
|
+
}
|
|
190
|
+
if (Object.keys(made).length) {
|
|
191
|
+
await db
|
|
192
|
+
.update(schema.project)
|
|
193
|
+
.set({ page: { ...page, slugs: { ...kept, ...made } } })
|
|
194
|
+
.where(eq(schema.project.id, space.id));
|
|
195
|
+
}
|
|
196
|
+
if (!wizards.length) {
|
|
197
|
+
return { ...base, space: null };
|
|
198
|
+
}
|
|
199
|
+
const logo = await mainLogoId(space.id);
|
|
200
|
+
return {
|
|
201
|
+
...base,
|
|
202
|
+
space: {
|
|
203
|
+
slug: page.slug,
|
|
204
|
+
title: page.title,
|
|
205
|
+
...(page.headline ? { headline: page.headline } : {}),
|
|
206
|
+
...(page.intro ? { intro: page.intro } : {}),
|
|
207
|
+
lang,
|
|
208
|
+
...(lang === "de" && page.form ? { form: page.form } : {}),
|
|
209
|
+
brand: {
|
|
210
|
+
name: (space.brand.name ?? "").slice(0, 120),
|
|
211
|
+
logoUrl: logo ? `${env.publicUrl}/api/public/logos/${logo}` : null,
|
|
212
|
+
theme: runTheme(space.brand),
|
|
213
|
+
},
|
|
214
|
+
imprint: imprintOf(space.facts, space.brand.name || space.name),
|
|
215
|
+
wizards,
|
|
216
|
+
},
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Where the team's page is opened: `https://<host>`; on a `.localhost` domain in development
|
|
221
|
+
* `http://<host>:<Manage's port>`, as Manage serves it there.
|
|
222
|
+
*/
|
|
223
|
+
export function pageOrigin(host) {
|
|
224
|
+
if (host.endsWith(".localhost")) {
|
|
225
|
+
const port = URL.canParse(env.manage.url) ? new URL(env.manage.url).port : "";
|
|
226
|
+
return `http://${host}${port ? `:${port}` : ""}`;
|
|
227
|
+
}
|
|
228
|
+
return `https://${host}`;
|
|
229
|
+
}
|
|
230
|
+
/** What the studio's "Public page" part shows beside its fields: the team's address and page data. */
|
|
231
|
+
export async function pagePreview() {
|
|
232
|
+
if (!managed) {
|
|
233
|
+
return { host: null, origin: null, team: null };
|
|
234
|
+
}
|
|
235
|
+
const team = await tenantInfo(currentTenant());
|
|
236
|
+
const host = feature("pages", team.features) ? (team.pagesHost ?? null) : null;
|
|
237
|
+
return { host, origin: host ? pageOrigin(host) : null, team: await pageTeam() };
|
|
238
|
+
}
|
|
239
|
+
let last = Promise.resolve();
|
|
240
|
+
/**
|
|
241
|
+
* Sends the team's page data to Manage, whole; a space switched off or with no listed wizard
|
|
242
|
+
* published and shared is sent as none. Not waited for by the change that caused it: a failure
|
|
243
|
+
* is logged, and the next change sends everything again. `pagesSettled` waits for the last send.
|
|
244
|
+
*/
|
|
245
|
+
export function pushPages() {
|
|
246
|
+
if (!managed) {
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
const send = async () => {
|
|
250
|
+
const data = await pageTeam();
|
|
251
|
+
if (data) {
|
|
252
|
+
await putPages(currentTenant(), data);
|
|
253
|
+
}
|
|
254
|
+
};
|
|
255
|
+
last = last.then(send, send).catch((err) => {
|
|
256
|
+
console.error("[pages] the page was not sent:", err.message);
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
/** Resolves once every push so far has been answered or has failed. */
|
|
260
|
+
export function pagesSettled() {
|
|
261
|
+
return last;
|
|
262
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { COLOR_SECTION_KINDS, cleanAssetSections, cleanLogoSections, FACT_TYPES, FONT_USES, FONT_WEIGHTS, GRADIENT_TYPES, orderColors, PROJECT_LIMITS, RULE_MARKS, } from "@engenty/wizards-shared/projects";
|
|
1
|
+
import { COLOR_SECTION_KINDS, cleanAssetSections, cleanLogoSections, FACT_TYPES, FONT_USES, FONT_WEIGHTS, GRADIENT_TYPES, orderColors, PAGE_LANGS, PAGE_LIMITS, PAGE_SLUG, PROJECT_LIMITS, RULE_MARKS, } from "@engenty/wizards-shared/projects";
|
|
2
2
|
import { note } from "@engenty/wizards-shared/run";
|
|
3
|
-
import { and, count, eq, isNull } from "drizzle-orm";
|
|
3
|
+
import { and, count, eq, isNull, ne } from "drizzle-orm";
|
|
4
4
|
import { nanoid } from "nanoid";
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { db, schema } from "../db/client.js";
|
|
@@ -13,6 +13,7 @@ import { serverText } from "../texts.js";
|
|
|
13
13
|
import { mayBuild, requireAdmin, requireBuild, requireWritable } from "./access.js";
|
|
14
14
|
import { notFound, ServiceError } from "./errors.js";
|
|
15
15
|
import { forgetWizardLinks } from "./links.js";
|
|
16
|
+
import { pushPages } from "./pages.js";
|
|
16
17
|
import { removeProjectFiles } from "./project-files.js";
|
|
17
18
|
const MASK = "••••";
|
|
18
19
|
export const mcpServerSchema = z.object({
|
|
@@ -103,8 +104,28 @@ export const projectFactSchema = z.object({
|
|
|
103
104
|
value: z.string().max(4000),
|
|
104
105
|
type: z.enum(FACT_TYPES).optional(),
|
|
105
106
|
});
|
|
107
|
+
const trimmed = (max) => z
|
|
108
|
+
.string()
|
|
109
|
+
.trim()
|
|
110
|
+
.max(max)
|
|
111
|
+
.transform((v) => v || undefined)
|
|
112
|
+
.optional();
|
|
113
|
+
/** The space's public page as the studio sends it, whole. */
|
|
114
|
+
export const projectPageSchema = z.object({
|
|
115
|
+
on: z.boolean(),
|
|
116
|
+
slug: z.string().trim().toLowerCase().max(PAGE_LIMITS.slug),
|
|
117
|
+
title: z.string().trim().min(1).max(PAGE_LIMITS.title),
|
|
118
|
+
headline: trimmed(PAGE_LIMITS.headline),
|
|
119
|
+
intro: trimmed(PAGE_LIMITS.intro),
|
|
120
|
+
lang: z.enum(PAGE_LANGS),
|
|
121
|
+
form: z.enum(["du", "sie"]).optional(),
|
|
122
|
+
wizards: z.array(z.string().max(40)).max(60),
|
|
123
|
+
examples: z.record(z.string().max(40), z.string().regex(/^[A-Za-z0-9_-]{1,40}$/)),
|
|
124
|
+
slugs: z.record(z.string().max(40), z.string().regex(PAGE_SLUG)).optional(),
|
|
125
|
+
});
|
|
106
126
|
export const projectPatchSchema = z.object({
|
|
107
127
|
name: z.string().min(1).max(80).optional(),
|
|
128
|
+
page: projectPageSchema.optional(),
|
|
108
129
|
brand: z
|
|
109
130
|
.object({
|
|
110
131
|
name: z.string().max(120).optional(),
|
|
@@ -270,6 +291,7 @@ export async function updateProject(userId, projectId, patch) {
|
|
|
270
291
|
if (patch.brand?.fonts) {
|
|
271
292
|
await linkFontFiles(p.id, patch.brand.fonts);
|
|
272
293
|
}
|
|
294
|
+
const page = patch.page ? await checkedPage(p, patch.page) : undefined;
|
|
273
295
|
await db
|
|
274
296
|
.update(schema.project)
|
|
275
297
|
.set({
|
|
@@ -277,10 +299,58 @@ export async function updateProject(userId, projectId, patch) {
|
|
|
277
299
|
...(patch.brand ? { brand: brandAfter(p.brand, patch.brand) } : {}),
|
|
278
300
|
...(patch.facts ? { facts: patch.facts } : {}),
|
|
279
301
|
...(mcpServers ? { mcpServers } : {}),
|
|
302
|
+
...(page ? { page } : {}),
|
|
280
303
|
updatedAt: new Date(),
|
|
281
304
|
})
|
|
282
305
|
.where(eq(schema.project.id, p.id));
|
|
283
306
|
spaceChanged("space.updated", p.id);
|
|
307
|
+
// The page itself, and what it is drawn from: the brand, the facts as the imprint.
|
|
308
|
+
if (page || patch.brand || patch.facts) {
|
|
309
|
+
pushPages();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The page as it is kept: its address made of the allowed characters and taken by no other space
|
|
314
|
+
* of the tenant, only this tenant's wizards of this space on it, and the page on in one space at
|
|
315
|
+
* most (`409 page_taken`, naming that space). The form is German's alone.
|
|
316
|
+
*/
|
|
317
|
+
async function checkedPage(p, page) {
|
|
318
|
+
if (!PAGE_SLUG.test(page.slug)) {
|
|
319
|
+
throw new ServiceError("invalid", note("pageSlugInvalid"));
|
|
320
|
+
}
|
|
321
|
+
const others = await db.query.project.findMany({
|
|
322
|
+
where: and(eq(schema.project.tenantId, currentTenant()), ne(schema.project.id, p.id)),
|
|
323
|
+
columns: { id: true, name: true, page: true },
|
|
324
|
+
});
|
|
325
|
+
if (others.some((o) => o.page?.slug === page.slug)) {
|
|
326
|
+
throw new ServiceError("invalid", note("pageSlugTaken"));
|
|
327
|
+
}
|
|
328
|
+
const holder = page.on ? others.find((o) => o.page?.on) : undefined;
|
|
329
|
+
if (holder) {
|
|
330
|
+
throw new ServiceError("page_taken", note("pageTaken", { space: holder.name }), {
|
|
331
|
+
project: { id: holder.id, name: holder.name },
|
|
332
|
+
});
|
|
333
|
+
}
|
|
334
|
+
const own = new Set((await db.query.wizard.findMany({
|
|
335
|
+
where: eq(schema.wizard.projectId, p.id),
|
|
336
|
+
columns: { id: true },
|
|
337
|
+
})).map((w) => w.id));
|
|
338
|
+
const wizards = [...new Set(page.wizards)].filter((id) => own.has(id));
|
|
339
|
+
const examples = Object.fromEntries(Object.entries(page.examples).filter(([id]) => own.has(id)));
|
|
340
|
+
// The wizards' addresses are kept as made (pages.ts); a wizard that is gone frees its address.
|
|
341
|
+
const slugs = Object.fromEntries(Object.entries({ ...p.page?.slugs, ...page.slugs }).filter(([id]) => own.has(id)));
|
|
342
|
+
return {
|
|
343
|
+
on: page.on,
|
|
344
|
+
slug: page.slug,
|
|
345
|
+
title: page.title,
|
|
346
|
+
...(page.headline ? { headline: page.headline } : {}),
|
|
347
|
+
...(page.intro ? { intro: page.intro } : {}),
|
|
348
|
+
lang: page.lang,
|
|
349
|
+
...(page.lang === "de" && page.form ? { form: page.form } : {}),
|
|
350
|
+
wizards,
|
|
351
|
+
examples,
|
|
352
|
+
...(Object.keys(slugs).length ? { slugs } : {}),
|
|
353
|
+
};
|
|
284
354
|
}
|
|
285
355
|
/**
|
|
286
356
|
* A brand font's own file is a font of the space; run pages ask for it by its id, before the
|
|
@@ -418,4 +488,5 @@ export async function removeProject(projectId) {
|
|
|
418
488
|
.delete(schema.project)
|
|
419
489
|
.where(and(eq(schema.project.id, projectId), eq(schema.project.tenantId, currentTenant())));
|
|
420
490
|
spaceChanged("space.deleted", projectId);
|
|
491
|
+
pushPages();
|
|
421
492
|
}
|
|
@@ -2,6 +2,7 @@ import { textLang, wizardLang } from "@engenty/wizards-shared/definition";
|
|
|
2
2
|
import { note } from "@engenty/wizards-shared/run";
|
|
3
3
|
import { BUILT_IN_RUNNERS, CONVERSATION_RUNNERS, DEFAULT_RUNNER, DEFAULT_RUNNER_SETTINGS, runnerFit, } from "@engenty/wizards-shared/runners";
|
|
4
4
|
import { env } from "../env.js";
|
|
5
|
+
import { feature, remoteFeatures } from "../features.js";
|
|
5
6
|
import { conversationAccess, conversationAvailable } from "../models.js";
|
|
6
7
|
import { pluginsOf } from "../plugins/registry.js";
|
|
7
8
|
import { currentTenant } from "../tenants/tenant.js";
|
|
@@ -12,9 +13,18 @@ import { shareUrl } from "./wizards.js";
|
|
|
12
13
|
* plugins add. Which of them a wizard offers is set per wizard (`wizard.runners`): the one its
|
|
13
14
|
* link opens, and the ones switched on beside it.
|
|
14
15
|
*/
|
|
15
|
-
/** The runners
|
|
16
|
+
/** The built-in runners switched off for the tenant at hand: live voice and video call each have a switch. */
|
|
17
|
+
export async function switchedOffRunners() {
|
|
18
|
+
const remote = await remoteFeatures();
|
|
19
|
+
return new Set([
|
|
20
|
+
...(feature("channelVoice", remote) ? [] : ["talk"]),
|
|
21
|
+
...(feature("channelVideo", remote) ? [] : ["video"]),
|
|
22
|
+
]);
|
|
23
|
+
}
|
|
24
|
+
/** The runners this tenant has, built-ins first; a built-in one switched off is not there. */
|
|
16
25
|
export async function runnersOf(tenantId = currentTenant()) {
|
|
17
26
|
const plugins = await pluginsOf(tenantId);
|
|
27
|
+
const off = await switchedOffRunners();
|
|
18
28
|
const talk = (await conversationAvailable())
|
|
19
29
|
? null
|
|
20
30
|
: await conversationAccess()
|
|
@@ -30,7 +40,7 @@ export async function runnersOf(tenantId = currentTenant()) {
|
|
|
30
40
|
: null),
|
|
31
41
|
}))));
|
|
32
42
|
return [
|
|
33
|
-
...BUILT_IN_RUNNERS.map((r) => CONVERSATION_RUNNERS.includes(r.id) ? { ...r, problem: talk } : r),
|
|
43
|
+
...BUILT_IN_RUNNERS.filter((r) => !off.has(r.id)).map((r) => CONVERSATION_RUNNERS.includes(r.id) ? { ...r, problem: talk } : r),
|
|
34
44
|
...ofPlugins,
|
|
35
45
|
];
|
|
36
46
|
}
|
|
@@ -6,11 +6,13 @@ import { db, schema } from "../db/client.js";
|
|
|
6
6
|
import { answerAsk } from "../engine/asks.js";
|
|
7
7
|
import { emitEvent, recentEvents, watchRun } from "../engine/events.js";
|
|
8
8
|
import { fieldErrorsIn } from "../engine/input.js";
|
|
9
|
-
import { cancel, createRun, goBack, NoCreditsError, pageContext, RunConflict, RunInputError, retry, reviewStep, submitPage, } from "../engine/runner.js";
|
|
9
|
+
import { cancel, createRun, goBack, NoCreditsError, pageContext, RunConflict, RunInputError, retry, reviewStep, runView, submitPage, } from "../engine/runner.js";
|
|
10
10
|
import { ModelUnavailableError, saidOf } from "../model-errors.js";
|
|
11
11
|
import { signedUrl } from "../secrets/signing.js";
|
|
12
12
|
import { currentTenant } from "../tenants/tenant.js";
|
|
13
|
+
import { brandView } from "./brand.js";
|
|
13
14
|
import { notFound, ServiceError } from "./errors.js";
|
|
15
|
+
import { storedTranslation } from "./translations.js";
|
|
14
16
|
import { ownedWizard, requireClean, shareUrl, studioUrl } from "./wizards.js";
|
|
15
17
|
/** Test runs an MCP client started with answers: pages are filled and reviews accepted for it. */
|
|
16
18
|
const autopilots = new Set();
|
|
@@ -429,6 +431,76 @@ export async function answerRunAsk(userId, runId, askId, answer) {
|
|
|
429
431
|
throw new ServiceError("refused", { code: "askClosed" });
|
|
430
432
|
}
|
|
431
433
|
}
|
|
434
|
+
/**
|
|
435
|
+
* One step of the draft as a run shows it there, without a run: the studio's preview of the
|
|
436
|
+
* step chosen. Answers and outputs of the steps before it come from the wizard's latest
|
|
437
|
+
* finished test run, else its latest one. Nothing is stored and nothing runs: pages wait for
|
|
438
|
+
* input, steps that work show their working screen, the result shows as done. `lang`: in a
|
|
439
|
+
* language the wizard is kept in, else its own.
|
|
440
|
+
*/
|
|
441
|
+
export async function draftStepView(userId, wizardId, stepId, lang) {
|
|
442
|
+
const w = await ownedWizard(userId, wizardId);
|
|
443
|
+
const def = w.draft;
|
|
444
|
+
const step = def.steps.find((s) => s.id === stepId);
|
|
445
|
+
if (!step) {
|
|
446
|
+
throw notFound();
|
|
447
|
+
}
|
|
448
|
+
// The latest finished test run has every answer and output; else the latest one at all.
|
|
449
|
+
const tests = and(eq(schema.run.wizardId, w.id), eq(schema.run.mode, "test"));
|
|
450
|
+
const latest = (await db.query.run.findFirst({
|
|
451
|
+
where: and(tests, eq(schema.run.status, "done")),
|
|
452
|
+
orderBy: desc(schema.run.createdAt),
|
|
453
|
+
})) ?? (await db.query.run.findFirst({ where: tests, orderBy: desc(schema.run.createdAt) }));
|
|
454
|
+
const before = new Set(def.steps.slice(0, def.steps.indexOf(step)).map((s) => s.id));
|
|
455
|
+
const state = {
|
|
456
|
+
values: latest?.state.values ?? {},
|
|
457
|
+
outputs: Object.fromEntries(Object.entries(latest?.state.outputs ?? {}).filter(([id]) => before.has(id))),
|
|
458
|
+
history: (latest?.state.history ?? []).filter((id) => before.has(id)),
|
|
459
|
+
notes: {},
|
|
460
|
+
};
|
|
461
|
+
const status = step.type === "page" || step.type === "review"
|
|
462
|
+
? "waiting_input"
|
|
463
|
+
: step.type === "result"
|
|
464
|
+
? "done"
|
|
465
|
+
: "running";
|
|
466
|
+
const now = new Date();
|
|
467
|
+
// That run lends its id too: the outputs' files are reached through it.
|
|
468
|
+
const run = {
|
|
469
|
+
...(latest ?? {
|
|
470
|
+
id: `draft-${w.id}`,
|
|
471
|
+
wizardId: w.id,
|
|
472
|
+
tenantId: w.tenantId,
|
|
473
|
+
files: [],
|
|
474
|
+
version: null,
|
|
475
|
+
mode: "test",
|
|
476
|
+
runner: null,
|
|
477
|
+
visitorId: null,
|
|
478
|
+
userId,
|
|
479
|
+
ipHash: null,
|
|
480
|
+
origin: null,
|
|
481
|
+
client: null,
|
|
482
|
+
unattended: false,
|
|
483
|
+
deviceOffer: null,
|
|
484
|
+
costMicros: 0,
|
|
485
|
+
sharedAt: null,
|
|
486
|
+
expiresAt: null,
|
|
487
|
+
createdAt: now,
|
|
488
|
+
updatedAt: now,
|
|
489
|
+
}),
|
|
490
|
+
definition: def,
|
|
491
|
+
status,
|
|
492
|
+
cursor: step.id,
|
|
493
|
+
state,
|
|
494
|
+
lang: lang && lang !== wizardLang(def) && (await storedTranslation(w.id, lang)) ? lang : null,
|
|
495
|
+
error: null,
|
|
496
|
+
ask: null,
|
|
497
|
+
answer: null,
|
|
498
|
+
shareToken: null,
|
|
499
|
+
};
|
|
500
|
+
const view = await runView(run, await brandView(w.projectId, def.themes));
|
|
501
|
+
// What the latest run said while it worked, and when, is its own: nothing works here.
|
|
502
|
+
return { ...view, events: [] };
|
|
503
|
+
}
|
|
432
504
|
export async function listRuns(userId, wizardId) {
|
|
433
505
|
const w = await ownedWizard(userId, wizardId);
|
|
434
506
|
const rows = await db.query.run.findMany({
|
|
@@ -452,6 +524,8 @@ export async function listRuns(userId, wizardId) {
|
|
|
452
524
|
credits: Math.ceil(r.costMicros / MICROS_PER_CREDIT),
|
|
453
525
|
assets: assetCounts.find((a) => a.runId === r.id)?.n ?? 0,
|
|
454
526
|
stepTitle: r.definition.steps.find((s) => s.id === r.cursor)?.title ?? null,
|
|
527
|
+
/** The token of its shared result (`/s/<token>`); null while it is not shared. */
|
|
528
|
+
shareToken: r.status === "done" ? r.shareToken : null,
|
|
455
529
|
}));
|
|
456
530
|
}
|
|
457
531
|
/**
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
import { SHIPPED_FONTS, shippedFontSlug } from "@engenty/wizards-shared/theme";
|
|
5
|
+
/**
|
|
6
|
+
* The fonts the runner ships (SHIPPED_FONTS), served for pages that are not the runtime's own: a
|
|
7
|
+
* host's OpenUI chat loads a theme's font from here. Each comes from its Fontsource package as
|
|
8
|
+
* the run page bundles it: a stylesheet with the weights the pages use, every subset by its
|
|
9
|
+
* unicode-range, and the files it names next to it.
|
|
10
|
+
*/
|
|
11
|
+
const require = createRequire(import.meta.url);
|
|
12
|
+
const SLUGS = SHIPPED_FONTS.map(shippedFontSlug);
|
|
13
|
+
/** The weights the pages use (text 400–700); a font that has fewer comes in those it has. */
|
|
14
|
+
const WEIGHTS = [400, 500, 600, 700];
|
|
15
|
+
const FILE = /^[a-z0-9-]+-\d{3}-normal\.woff2?$/;
|
|
16
|
+
const packageDir = (slug) => dirname(require.resolve(`@fontsource/${slug}/package.json`));
|
|
17
|
+
/** The stylesheet of a shipped font by its slug; null for one that is not ours. */
|
|
18
|
+
export async function shippedFontCss(slug) {
|
|
19
|
+
if (!SLUGS.includes(slug)) {
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const dir = packageDir(slug);
|
|
23
|
+
const sheets = await Promise.all(WEIGHTS.map((w) => readFile(join(dir, `${w}.css`), "utf8").catch(() => "")));
|
|
24
|
+
return sheets.join("\n");
|
|
25
|
+
}
|
|
26
|
+
/** One file a shipped font's stylesheet names; null for anything else. */
|
|
27
|
+
export async function shippedFontFile(file) {
|
|
28
|
+
// The longest slug first: one slug can start another's name.
|
|
29
|
+
const slug = FILE.test(file)
|
|
30
|
+
? [...SLUGS].sort((a, b) => b.length - a.length).find((s) => file.startsWith(`${s}-`))
|
|
31
|
+
: undefined;
|
|
32
|
+
return slug ? await readFile(join(packageDir(slug), "files", file)).catch(() => null) : null;
|
|
33
|
+
}
|
|
@@ -18,6 +18,7 @@ import { notFound, ServiceError } from "./errors.js";
|
|
|
18
18
|
import { copyFiles, draftFiles, sameFiles, seedFiles } from "./files.js";
|
|
19
19
|
import { forgetWizardLinks } from "./links.js";
|
|
20
20
|
import { asLang, countInstall, marketplaceWizard } from "./marketplace.js";
|
|
21
|
+
import { pushPages } from "./pages.js";
|
|
21
22
|
import { defaultProject, ownedProject } from "./projects.js";
|
|
22
23
|
import { checkRunnerSettings } from "./runners.js";
|
|
23
24
|
import { saveTheme } from "./themes.js";
|
|
@@ -363,6 +364,10 @@ export async function updateWizardSettings(userId, wizardId, patch) {
|
|
|
363
364
|
.update(schema.wizard)
|
|
364
365
|
.set({ ...patch, ...(runners ? { runners } : {}), updatedAt: new Date() })
|
|
365
366
|
.where(eq(schema.wizard.id, w.id));
|
|
367
|
+
// Switched off, the wizard leaves the team's public page; on, it may return to it.
|
|
368
|
+
if (patch.shareEnabled !== undefined && patch.shareEnabled !== w.shareEnabled) {
|
|
369
|
+
pushPages();
|
|
370
|
+
}
|
|
366
371
|
return wizardSummary(await ownedWizard(userId, wizardId));
|
|
367
372
|
}
|
|
368
373
|
export async function rotateShareLink(userId, wizardId) {
|
|
@@ -374,6 +379,8 @@ export async function rotateShareLink(userId, wizardId) {
|
|
|
374
379
|
.where(eq(schema.wizard.id, w.id));
|
|
375
380
|
await dropLinks([w.shareToken]);
|
|
376
381
|
await putLink(token, "wizard", w.id);
|
|
382
|
+
// The public page's start button leads to the new link.
|
|
383
|
+
pushPages();
|
|
377
384
|
return { shareToken: token, shareUrl: shareUrl(token) };
|
|
378
385
|
}
|
|
379
386
|
export async function duplicateWizard(userId, wizardId) {
|
|
@@ -398,11 +405,31 @@ export async function duplicateWizard(userId, wizardId) {
|
|
|
398
405
|
}
|
|
399
406
|
export async function deleteWizard(userId, wizardId) {
|
|
400
407
|
await requireAdmin();
|
|
401
|
-
await writableWizard(userId, wizardId);
|
|
408
|
+
const w = await writableWizard(userId, wizardId);
|
|
402
409
|
await forgetWizardLinks(wizardId);
|
|
403
410
|
await db
|
|
404
411
|
.delete(schema.wizard)
|
|
405
412
|
.where(and(eq(schema.wizard.id, wizardId), eq(schema.wizard.tenantId, currentTenant())));
|
|
413
|
+
await unlistWizard(w.projectId, wizardId);
|
|
414
|
+
}
|
|
415
|
+
/** A wizard that is gone leaves its space's public page, which is sent again without it. */
|
|
416
|
+
async function unlistWizard(projectId, wizardId) {
|
|
417
|
+
const p = await db.query.project.findFirst({
|
|
418
|
+
where: eq(schema.project.id, projectId),
|
|
419
|
+
columns: { page: true },
|
|
420
|
+
});
|
|
421
|
+
if (!p?.page?.wizards.includes(wizardId)) {
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
const { [wizardId]: _gone, ...examples } = p.page.examples;
|
|
425
|
+
await db
|
|
426
|
+
.update(schema.project)
|
|
427
|
+
.set({
|
|
428
|
+
page: { ...p.page, wizards: p.page.wizards.filter((id) => id !== wizardId), examples },
|
|
429
|
+
updatedAt: new Date(),
|
|
430
|
+
})
|
|
431
|
+
.where(eq(schema.project.id, projectId));
|
|
432
|
+
pushPages();
|
|
406
433
|
}
|
|
407
434
|
/** A wizard with validator issues is never published — same rule for studio and MCP. */
|
|
408
435
|
export async function requireClean(w) {
|
|
@@ -424,5 +451,7 @@ export async function publishWizard(userId, wizardId) {
|
|
|
424
451
|
.update(schema.wizard)
|
|
425
452
|
.set({ publishedVersion: version, updatedAt: new Date() })
|
|
426
453
|
.where(eq(schema.wizard.id, w.id));
|
|
454
|
+
// The team's public page shows the new version's title, results and steps.
|
|
455
|
+
pushPages();
|
|
427
456
|
return { version, shareUrl: shareUrl(w.shareToken), shareEnabled: w.shareEnabled };
|
|
428
457
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Ar as i,Bt as a,Ht as o,Ir as s,Jt as c,Ut as l,Vt as u,Zt as d,ar as f,on as p}from"./ui-DVkIZqDg.js";import{t as m}from"./preload-helper-CNEI7N0N.js";import{t as h}from"./logo-CGNoptDg.js";import{G as g,nt as _,tt as v}from"./index-qc7o4bkp.js";import{c as y,f as b}from"./settings-menu-C960R1kx.js";import{ReleaseNotes as x,loadReleases as S,releaseDate as C,releaseLabel as w}from"./ChangelogDialog-vV9nXOBV.js";var T=e(t(),1),E=[{name:`engenty wizards`,description:`credit.engenty-wizards`,homepage:`https://github.com/engenty/wizards`,license:`FSL-1.1-MIT`},{name:`engenty`,description:`credit.engenty`,homepage:`https://github.com/engenty/engenty`,license:`FSL-1.1-MIT`}],D=[{name:`Mastra`,description:`credit.mastra`,homepage:`https://github.com/mastra-ai/mastra`,license:`Apache-2.0`},{name:`AI SDK`,description:`credit.ai-sdk`,homepage:`https://github.com/vercel/ai`,license:`Apache-2.0`},{name:`Model Context Protocol`,description:`credit.model-context-protocol`,homepage:`https://github.com/modelcontextprotocol/typescript-sdk`,license:`MIT`},{name:`Hono`,description:`credit.hono`,homepage:`https://github.com/honojs/hono`,license:`MIT`},{name:`Drizzle ORM`,description:`credit.drizzle-orm`,homepage:`https://github.com/drizzle-team/drizzle-orm`,license:`Apache-2.0`},{name:`libSQL`,description:`credit.libsql`,homepage:`https://github.com/tursodatabase/libsql`,license:`MIT`},{name:`Playwright`,description:`credit.playwright`,homepage:`https://github.com/microsoft/playwright`,license:`Apache-2.0`},{name:`React`,description:`credit.react`,homepage:`https://github.com/facebook/react`,license:`MIT`},{name:`Vite`,description:`credit.vite`,homepage:`https://github.com/vitejs/vite`,license:`MIT`},{name:`Tailwind CSS`,description:`credit.tailwind-css`,homepage:`https://github.com/tailwindlabs/tailwindcss`,license:`MIT`},{name:`React Flow`,description:`credit.react-flow`,homepage:`https://github.com/xyflow/xyflow`,license:`MIT`},{name:`TanStack Query`,description:`credit.tanstack-query`,homepage:`https://github.com/TanStack/query`,license:`MIT`},{name:`xterm.js`,description:`credit.xterm-js`,homepage:`https://github.com/xtermjs/xterm.js`,license:`MIT`},{name:`Lucide`,description:`credit.lucide`,homepage:`https://github.com/lucide-icons/lucide`,license:`ISC`},{name:`Geist & Geist Mono`,description:`credit.geist-geist-mono`,homepage:`https://github.com/vercel/geist-font`,license:`OFL-1.1`},{name:`Space Grotesk`,description:`credit.space-grotesk`,homepage:`https://github.com/floriankarsten/space-grotesk`,license:`OFL-1.1`},{name:`git-cliff`,description:`credit.git-cliff`,homepage:`https://github.com/orhun/git-cliff`,license:`MIT OR Apache-2.0`}],O=e(n(),1),k=(e,...t)=>t.some(t=>t?.toLowerCase().includes(e));function A({name:e,homepage:t,version:n,license:r,description:a}){return(0,O.jsxs)(`li`,{className:`py-2.5`,children:[(0,O.jsxs)(`div`,{className:`flex flex-wrap items-baseline gap-x-2.5 gap-y-0.5`,children:[t?(0,O.jsxs)(`a`,{href:t,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 font-medium text-[0.875rem] text-ink underline-offset-4 hover:underline`,children:[e,(0,O.jsx)(i,{"aria-hidden":!0,className:`size-3 text-ink-4`})]}):(0,O.jsx)(`span`,{className:`font-medium text-[0.875rem] text-ink`,children:e}),n?(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3 tabular-nums`,children:n}):null,(0,O.jsx)(`span`,{className:`text-[0.75rem] text-ink-3`,children:r})]}),a?(0,O.jsx)(`p`,{className:`mt-0.5 text-[0.8125rem] text-ink-3`,children:a}):null]})}function j({title:e,hint:t,children:n}){return(0,O.jsxs)(`section`,{className:`mt-6`,children:[(0,O.jsx)(`h3`,{className:`border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:e}),t?(0,O.jsx)(`p`,{className:`mt-2 text-[0.8125rem] text-ink-3`,children:t}):null,n]})}function M({credits:e}){return(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:e.map(e=>(0,O.jsx)(A,{name:e.name,homepage:e.homepage,license:e.license,description:p(e.description)},e.name))})}function N({label:e,packages:t}){return(0,O.jsxs)(`div`,{className:`mt-4`,children:[(0,O.jsx)(`h4`,{className:`font-medium text-[0.75rem] text-ink-3 tracking-wide`,children:e}),(0,O.jsx)(`ul`,{className:`divide-y divide-border-soft`,children:t.map(e=>(0,O.jsx)(A,{...e},e.name))})]})}function P({active:e}){let[t,n]=(0,T.useState)(null),[r,i]=(0,T.useState)(``);(0,T.useEffect)(()=>{if(!e||t)return;let r=!1;return m(()=>import(`./oss-credits-D7izqI_0.js`).then(e=>{r||n(e.default)}),[]),()=>{r=!0}},[e,t]),(0,T.useEffect)(()=>{e||i(``)},[e]);let a=r.trim().toLowerCase(),o=e=>a?e.filter(e=>k(a,e.name,e.license,p(e.description))):e,s=e=>a?e.filter(e=>k(a,e.name,e.license,e.version)):e,d=o(E),f=o(D),h=t?[{id:`shared`,label:p(`about.creditsShared`),packages:s(t.shared)},...t.groups.map(e=>({id:e.id,label:e.label,packages:s(e.packages)}))].filter(e=>e.packages.length>0):[],g=d.length===0&&f.length===0&&h.length===0;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsx)(`p`,{className:`mb-4 text-[0.875rem] text-ink-3`,children:p(`about.creditsHint`)}),(0,O.jsx)(l,{type:`search`,value:r,placeholder:p(`about.search`),onChange:e=>i(e.target.value)}),d.length>0?(0,O.jsx)(j,{title:p(`about.creditsProduct`),children:(0,O.jsx)(M,{credits:d})}):null,f.length>0?(0,O.jsx)(j,{title:p(`about.creditsBuiltWith`),children:(0,O.jsx)(M,{credits:f})}):null,t===null?(0,O.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,O.jsx)(c,{})}):h.length>0?(0,O.jsx)(j,{title:p(`about.creditsDeps`),hint:a?void 0:p(`about.creditsDepsHint`),children:h.map(e=>(0,O.jsx)(N,{label:e.label,packages:e.packages},e.id))}):null,t!==null&&g?(0,O.jsx)(u,{children:p(`about.noMatches`)}):null]})}var F=[`new`,`earlier`,`credits`],I=e=>p(e===`new`?`about.tab.new`:e===`earlier`?`about.tab.earlier`:`about.credits`),L=e=>e===1?p(`about.change`):p(`about.changes`,{n:e});function R({me:e,active:t,initialTab:n=`new`}){let i=e?.mode===`local`,{data:a,latest:o}=v(i&&t),[l,u]=(0,T.useState)(null),[f,m]=(0,T.useState)(n);(0,T.useEffect)(()=>m(n),[n]);let E=b(F.indexOf(f)),D=a?.newer&&o?o:_;(0,T.useEffect)(()=>{if(!t)return;let e=!1;return u(null),S(D===`0.9.4`?void 0:D).then(t=>{e||u(t)}),()=>{e=!0}},[t,D]);let k=l?.find(e=>e.version===`v${D}`)??l?.[0]??null,A=l?.filter(e=>e!==k)??[],j=i?a?.kind??null:`cloud`;return(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`div`,{className:`flex flex-col items-center pt-4 text-center`,children:[(0,O.jsx)(h,{size:96}),(0,O.jsxs)(`div`,{className:`mt-4 font-display font-semibold text-[1.5rem] tracking-tight`,children:[`engenty`,(0,O.jsx)(`span`,{className:`text-ember`,children:`.`}),(0,O.jsx)(`span`,{className:`ml-1.5 font-normal text-ink-3`,children:`wizards`})]}),(0,O.jsxs)(`div`,{className:`mt-1 text-[0.9375rem] text-ink-3 tabular-nums`,children:[p(`about.version`,{v:_}),j?` · ${p(`about.kind.${j}`)}`:``]})]}),i?(0,O.jsx)(`div`,{className:`mt-5`,children:(0,O.jsx)(g,{enabled:t})}):null,(0,O.jsx)(`div`,{className:`mt-6 flex justify-center`,children:(0,O.jsx)(d,{value:f,onChange:m,options:F.map(e=>({id:e,label:I(e)})),label:p(`about.title`)})}),(0,O.jsxs)(`div`,{className:r(`mt-5`,y(E)),children:[f===`new`?l===null?(0,O.jsx)(`div`,{className:`flex justify-center py-6 text-ink-3`,children:(0,O.jsx)(c,{})}):k?(0,O.jsxs)(O.Fragment,{children:[(0,O.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[w(k),(0,O.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:C(k)})]}),(0,O.jsx)(`div`,{className:`mt-3`,children:(0,O.jsx)(x,{release:k})})]}):(0,O.jsx)(`p`,{className:`text-[0.875rem] text-ink-3`,children:p(`about.changelogEmpty`)}):null,f===`earlier`?(0,O.jsx)(`div`,{className:`flex flex-col divide-y divide-border-soft`,children:A.map(e=>(0,O.jsxs)(`details`,{className:`group/r py-2`,children:[(0,O.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-baseline gap-3 text-[0.875rem] [&::-webkit-details-marker]:hidden`,children:[(0,O.jsx)(s,{className:`size-3.5 shrink-0 self-center text-ink-4 transition group-open/r:rotate-90`}),(0,O.jsx)(`span`,{className:`font-medium text-ink tabular-nums`,children:w(e)}),(0,O.jsx)(`span`,{className:`text-[0.8125rem] text-ink-3 tabular-nums`,children:C(e)}),(0,O.jsx)(`span`,{className:`ml-auto text-[0.8125rem] text-ink-4`,children:L(e.commits.length)})]}),(0,O.jsx)(`div`,{className:`mt-2 pl-6`,children:(0,O.jsx)(x,{release:e})})]},e.version??`unreleased`))}):null,f===`credits`?(0,O.jsx)(P,{active:!0}):null]},f)]})}function z({open:e,onClose:t,me:n}){return(0,O.jsxs)(a,{open:e,onClose:t,wide:!0,height:`tall`,children:[(0,O.jsx)(`div`,{className:`-mt-2 -mr-2 sticky top-0 z-10 flex h-0 justify-end`,children:(0,O.jsx)(o,{label:p(`common.close`),onClick:t,children:(0,O.jsx)(f,{className:`size-4`})})}),(0,O.jsx)(R,{me:n,active:e})]})}export{z as AboutDialog,R as AboutPanel};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{
|
|
1
|
+
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{n as t,t as n}from"./jsx-runtime-BNakU3Ej.js";import{$t as r,Bt as i,Jt as a,Ut as o,Vt as s,on as c}from"./ui-DVkIZqDg.js";import{t as l}from"./preload-helper-CNEI7N0N.js";var u=e(t(),1),d=e(n(),1);function f(e){switch(e.group){case`Added`:return{label:`NEW`,dot:`bg-moss`};case`Fixed`:return{label:`FIXED`,dot:`bg-amber`};case`Changed`:return{label:`CHANGED`,dot:`bg-cobalt`};case`Performance`:return{label:`PERFORMANCE`,dot:`bg-ember`};case`Deploy`:return{label:`DEPLOY`,dot:`bg-ink-4`};case`Docs`:return{label:`DOCS`,dot:`bg-ink-4`};default:return{label:`OTHER`,dot:`bg-ink-4`}}}var p=e=>e.version?e.version.replace(/^v/,``):c(`about.unreleased`),m=e=>e.timestamp?new Date(e.timestamp*1e3).toISOString().slice(0,10):``,h=e=>e.charAt(0).toUpperCase()+e.slice(1);function g(e,t){let n=t.trim().toLowerCase();if(!n)return e;let r=[];for(let t of e){if(`${p(t)} ${m(t)}`.toLowerCase().includes(n)){r.push(t);continue}let e=t.commits.filter(e=>`${f(e).label} ${e.scope??``} ${e.message}`.toLowerCase().includes(n));e.length>0&&r.push({...t,commits:e})}return r}async function _(e){if(e)try{let t=await fetch(`https://raw.githubusercontent.com/engenty/wizards/v${e}/apps/web/src/about/changelog.json`,{signal:AbortSignal.timeout(5e3)});if(t.ok)return await t.json()}catch{}return(await l(async()=>{let{default:e}=await import(`./changelog-pnMcOVO_.js`);return{default:e}},[])).default}function v({release:e}){return(0,d.jsx)(`ul`,{className:`flex flex-col gap-2`,children:e.commits.map(e=>{let t=f(e);return(0,d.jsxs)(`li`,{className:`flex items-start gap-2.5 text-[0.875rem]`,children:[(0,d.jsx)(`span`,{className:r(`mt-[7px] size-1.5 shrink-0 rounded-full`,t.dot)}),(0,d.jsxs)(`span`,{className:`min-w-0 text-ink-2`,children:[(0,d.jsxs)(`span`,{className:`font-semibold text-[0.75rem] text-ink tracking-wide`,children:[t.label,e.scope?` [${e.scope}]`:``]}),` `,h(e.message),e.breaking?(0,d.jsx)(`span`,{className:`ml-1.5 rounded-full bg-rose-tint px-1.5 py-0.5 font-medium text-[0.75rem] text-rose`,children:c(`about.breaking`)}):null]})]},e.id)})})}function y({open:e,onClose:t,version:n}){let[r,l]=(0,u.useState)(null),[f,h]=(0,u.useState)(``);(0,u.useEffect)(()=>{if(!e||r)return;let t=!1;return _(n).then(e=>{t||l(e)}),()=>{t=!0}},[e,r,n]),(0,u.useEffect)(()=>{e||h(``)},[e]);let y=r?g(r,f):[];return(0,d.jsxs)(i,{open:e,onClose:t,title:c(`about.changelog`),wide:!0,height:`tall`,children:[(0,d.jsx)(`p`,{className:`-mt-3 mb-4 text-[0.875rem] text-ink-3`,children:c(`about.changelogHint`)}),r===null?(0,d.jsx)(`div`,{className:`flex justify-center py-10 text-ink-3`,children:(0,d.jsx)(a,{})}):r.length===0?(0,d.jsx)(s,{children:c(`about.changelogEmpty`)}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(o,{type:`search`,value:f,placeholder:c(`about.search`),onChange:e=>h(e.target.value)}),y.length===0?(0,d.jsx)(s,{children:c(`about.noMatches`)}):null,y.map(e=>(0,d.jsxs)(`section`,{className:`mt-6`,children:[(0,d.jsxs)(`h3`,{className:`flex items-baseline gap-3 border-border-soft border-b pb-2 font-display font-semibold text-[1rem]`,children:[p(e),(0,d.jsx)(`span`,{className:`font-normal font-sans text-[0.8125rem] text-ink-3 tabular-nums`,children:m(e)})]}),(0,d.jsx)(`div`,{className:`mt-3`,children:(0,d.jsx)(v,{release:e})})]},e.version??`unreleased`))]})]})}export{y as ChangelogDialog,v as ReleaseNotes,_ as loadReleases,m as releaseDate,p as releaseLabel};
|