@clawnify/app 0.1.1 → 0.2.1
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/dist/client/index.d.ts +152 -0
- package/dist/client/index.js +419 -0
- package/dist/client/index.js.map +1 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +23 -4
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
declare const HOST_BRIDGE_VERSION: 1;
|
|
5
|
+
/** One row in the navigation. `icon` is a lucide icon name (kebab-case). */
|
|
6
|
+
interface AppNavItem {
|
|
7
|
+
/** Stable identifier the host hands back on `navigate`. */
|
|
8
|
+
id: string;
|
|
9
|
+
label: string;
|
|
10
|
+
/**
|
|
11
|
+
* In-app path this item opens. Optional: a state-driven view can omit it.
|
|
12
|
+
* When present the host uses it to restore the view on reload and to make
|
|
13
|
+
* the dashboard URL shareable.
|
|
14
|
+
*/
|
|
15
|
+
href?: string;
|
|
16
|
+
/** Icon name from TILE_ICONS, e.g. "layout-dashboard". Unknown names render a dot. */
|
|
17
|
+
icon?: string;
|
|
18
|
+
/** Live badge, e.g. items waiting. Omit for none. */
|
|
19
|
+
count?: number;
|
|
20
|
+
/**
|
|
21
|
+
* The app's home screen. Not listed as a row: standalone the brand row
|
|
22
|
+
* opens it, and in the dashboard the app's own header does. One per app.
|
|
23
|
+
*/
|
|
24
|
+
home?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Tile colour for this section. Sections are the records inside an app,
|
|
27
|
+
* so they draw as a small coloured tile with a white glyph (the app itself
|
|
28
|
+
* is navigation and stays an outline glyph). One of `NAV_COLORS`; omitted
|
|
29
|
+
* = picked from the palette by `id`, stable across renders and hosts.
|
|
30
|
+
*/
|
|
31
|
+
color?: NavColor;
|
|
32
|
+
}
|
|
33
|
+
/** The section tile palette, shared by the standalone sidebar and the dashboard. */
|
|
34
|
+
declare const NAV_COLORS: {
|
|
35
|
+
readonly red: "#ef4444";
|
|
36
|
+
readonly orange: "#f97514";
|
|
37
|
+
readonly amber: "#f59e0b";
|
|
38
|
+
readonly green: "#22c55e";
|
|
39
|
+
readonly sky: "#17bde9";
|
|
40
|
+
readonly blue: "#266df0";
|
|
41
|
+
readonly violet: "#8b5cf6";
|
|
42
|
+
readonly pink: "#ec4899";
|
|
43
|
+
};
|
|
44
|
+
type NavColor = keyof typeof NAV_COLORS;
|
|
45
|
+
/** Deterministic palette pick for an item without an explicit colour. */
|
|
46
|
+
declare function navColorFor(id: string): NavColor;
|
|
47
|
+
/**
|
|
48
|
+
* The icon library: the names the Clawnify dashboard can draw for an app
|
|
49
|
+
* and its sections (resolved to the Phosphor set in both sidebars). Pick
|
|
50
|
+
* from these; the apps AGENTS.md lists them by meaning.
|
|
51
|
+
*/
|
|
52
|
+
declare const TILE_ICONS: readonly ["activity", "archive", "bar-chart-3", "bell", "book-open", "bot", "briefcase", "building-2", "calendar", "calendar-days", "camera", "check-square", "clipboard-list", "clock", "code-2", "contact", "credit-card", "database", "dollar-sign", "file", "file-text", "folder", "globe", "hash", "history", "home", "image", "inbox", "kanban", "layers", "layout-dashboard", "layout-grid", "link", "list", "list-checks", "mail", "map", "message-square", "mic", "package", "phone", "pie-chart", "play", "search", "send", "settings", "shopping-cart", "sparkles", "star", "table", "tag", "target", "truck", "upload", "user", "users", "video", "wallet", "zap"];
|
|
53
|
+
type TileIconName = (typeof TILE_ICONS)[number];
|
|
54
|
+
interface TileIconProps {
|
|
55
|
+
/** Icon name from TILE_ICONS. Unknown or missing = a small dot. */
|
|
56
|
+
icon?: string;
|
|
57
|
+
/** Palette colour. Omitted = picked from `seed` (or `icon`) by hash. */
|
|
58
|
+
color?: NavColor;
|
|
59
|
+
/** Stable string the colour is derived from when `color` is not given. */
|
|
60
|
+
seed?: string;
|
|
61
|
+
/** Tile edge in px. The glyph scales with it. Default 16. */
|
|
62
|
+
size?: number;
|
|
63
|
+
className?: string;
|
|
64
|
+
title?: string;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* The record tile: a small rounded square in a palette colour with a white
|
|
68
|
+
* lucide glyph. The sidebar draws every app section with it; apps can use
|
|
69
|
+
* the same tile anywhere a record type needs an identity mark (table rows,
|
|
70
|
+
* cards, pickers) so the two surfaces stay one system. Self-contained inline
|
|
71
|
+
* styles, so it works outside <AppNav> and in any stylesheet setup.
|
|
72
|
+
*
|
|
73
|
+
* <TileIcon icon="users" color="blue" />
|
|
74
|
+
* <TileIcon icon="phone" seed={lead.id} size={20} />
|
|
75
|
+
*/
|
|
76
|
+
declare function TileIcon({ icon, color, seed, size, className, title }: TileIconProps): react.JSX.Element;
|
|
77
|
+
interface AppNavGroup {
|
|
78
|
+
/** Eyebrow shown above the items. Omit for an unlabelled group. */
|
|
79
|
+
label?: string;
|
|
80
|
+
items: AppNavItem[];
|
|
81
|
+
}
|
|
82
|
+
type AppToHostMessage = {
|
|
83
|
+
source: "clawnify-app";
|
|
84
|
+
v: 1;
|
|
85
|
+
type: "ready";
|
|
86
|
+
} | {
|
|
87
|
+
source: "clawnify-app";
|
|
88
|
+
v: 1;
|
|
89
|
+
type: "nav";
|
|
90
|
+
title: string;
|
|
91
|
+
/** lucide icon name for the app itself. */
|
|
92
|
+
icon?: string;
|
|
93
|
+
groups: AppNavGroup[];
|
|
94
|
+
active?: string;
|
|
95
|
+
} | {
|
|
96
|
+
source: "clawnify-app";
|
|
97
|
+
v: 1;
|
|
98
|
+
type: "location";
|
|
99
|
+
path: string;
|
|
100
|
+
};
|
|
101
|
+
type HostToAppMessage = {
|
|
102
|
+
source: "clawnify-host";
|
|
103
|
+
v: 1;
|
|
104
|
+
type: "hello";
|
|
105
|
+
} | {
|
|
106
|
+
source: "clawnify-host";
|
|
107
|
+
v: 1;
|
|
108
|
+
type: "navigate";
|
|
109
|
+
id: string;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Whether this page is running inside the Clawnify dashboard. Computed once at
|
|
113
|
+
* module load — the query parameter is only on the initial URL — and remembered
|
|
114
|
+
* for the tab so in-iframe full navigations keep the mode.
|
|
115
|
+
*/
|
|
116
|
+
declare const embedded: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* Tell the host where the app is, so the dashboard URL can restore this view
|
|
119
|
+
* on reload. Call it whenever your router's location changes; a no-op when
|
|
120
|
+
* standalone.
|
|
121
|
+
*/
|
|
122
|
+
declare function reportLocation(path: string): void;
|
|
123
|
+
interface AppNavProps {
|
|
124
|
+
/** App name, shown in the brand row standalone and in the host's switcher. */
|
|
125
|
+
title: string;
|
|
126
|
+
/**
|
|
127
|
+
* The app's own glyph, a lucide icon name (kebab-case). Drawn as an
|
|
128
|
+
* outline icon with no background: in the standalone brand row, and by the
|
|
129
|
+
* dashboard on the app's sidebar item. Tiles are for records, not for
|
|
130
|
+
* navigation, so the app's coloured tile icon stays out of the sidebar.
|
|
131
|
+
*/
|
|
132
|
+
icon?: string;
|
|
133
|
+
groups: AppNavGroup[];
|
|
134
|
+
/** `id` of the active item. */
|
|
135
|
+
active?: string;
|
|
136
|
+
/** Called with the item the user chose, from either renderer. */
|
|
137
|
+
onNavigate: (item: AppNavItem) => void;
|
|
138
|
+
/** Rendered at the bottom of the standalone sidebar (a footer action, say). */
|
|
139
|
+
children?: ReactNode;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* The app's navigation: sidebar when standalone, host-fed when embedded.
|
|
143
|
+
*
|
|
144
|
+
* Standalone layout: the sidebar is a 260px column at ≥768px and a horizontal
|
|
145
|
+
* strip below that, so put it first inside a `flex flex-col md:flex-row`
|
|
146
|
+
* container. It paints with the app's own theme tokens (`--surface`,
|
|
147
|
+
* `--border`, `--primary`…) and falls back to the platform defaults when a
|
|
148
|
+
* token is missing.
|
|
149
|
+
*/
|
|
150
|
+
declare function AppNav({ title, icon, groups, active, onNavigate, children }: AppNavProps): react.JSX.Element | null;
|
|
151
|
+
|
|
152
|
+
export { AppNav, type AppNavGroup, type AppNavItem, type AppNavProps, type AppToHostMessage, HOST_BRIDGE_VERSION, type HostToAppMessage, NAV_COLORS, type NavColor, TILE_ICONS, TileIcon, type TileIconName, type TileIconProps, embedded, navColorFor, reportLocation };
|
|
@@ -0,0 +1,419 @@
|
|
|
1
|
+
// src/client/index.tsx
|
|
2
|
+
import {
|
|
3
|
+
useEffect,
|
|
4
|
+
useRef
|
|
5
|
+
} from "react";
|
|
6
|
+
import {
|
|
7
|
+
AddressBook,
|
|
8
|
+
Archive,
|
|
9
|
+
Bell,
|
|
10
|
+
BookOpen,
|
|
11
|
+
Briefcase,
|
|
12
|
+
Building,
|
|
13
|
+
Calendar,
|
|
14
|
+
CalendarDots,
|
|
15
|
+
Camera,
|
|
16
|
+
ChartBar,
|
|
17
|
+
ChartPie,
|
|
18
|
+
ChatCircle,
|
|
19
|
+
CheckSquare,
|
|
20
|
+
ClipboardText,
|
|
21
|
+
Clock,
|
|
22
|
+
ClockCounterClockwise,
|
|
23
|
+
Code,
|
|
24
|
+
CreditCard,
|
|
25
|
+
CurrencyDollar,
|
|
26
|
+
Database,
|
|
27
|
+
Envelope,
|
|
28
|
+
File,
|
|
29
|
+
FileText,
|
|
30
|
+
Folder,
|
|
31
|
+
Gear,
|
|
32
|
+
Globe,
|
|
33
|
+
GridFour,
|
|
34
|
+
Hash,
|
|
35
|
+
House,
|
|
36
|
+
Image,
|
|
37
|
+
Kanban,
|
|
38
|
+
Lightning,
|
|
39
|
+
Link,
|
|
40
|
+
List,
|
|
41
|
+
ListChecks,
|
|
42
|
+
MagnifyingGlass,
|
|
43
|
+
MapTrifold,
|
|
44
|
+
Microphone,
|
|
45
|
+
Package,
|
|
46
|
+
PaperPlaneTilt,
|
|
47
|
+
Phone,
|
|
48
|
+
Play,
|
|
49
|
+
Pulse,
|
|
50
|
+
Robot,
|
|
51
|
+
ShoppingCart,
|
|
52
|
+
Sparkle,
|
|
53
|
+
SquaresFour,
|
|
54
|
+
Stack,
|
|
55
|
+
Star,
|
|
56
|
+
Table,
|
|
57
|
+
Tag,
|
|
58
|
+
Target,
|
|
59
|
+
Tray,
|
|
60
|
+
Truck,
|
|
61
|
+
Upload,
|
|
62
|
+
User,
|
|
63
|
+
VideoCamera,
|
|
64
|
+
Wallet
|
|
65
|
+
} from "@phosphor-icons/react";
|
|
66
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
67
|
+
var HOST_BRIDGE_VERSION = 1;
|
|
68
|
+
var NAV_COLORS = {
|
|
69
|
+
red: "#ef4444",
|
|
70
|
+
orange: "#f97514",
|
|
71
|
+
amber: "#f59e0b",
|
|
72
|
+
green: "#22c55e",
|
|
73
|
+
sky: "#17bde9",
|
|
74
|
+
blue: "#266df0",
|
|
75
|
+
violet: "#8b5cf6",
|
|
76
|
+
pink: "#ec4899"
|
|
77
|
+
};
|
|
78
|
+
function navColorFor(id) {
|
|
79
|
+
const names = Object.keys(NAV_COLORS);
|
|
80
|
+
let h = 0;
|
|
81
|
+
for (let i = 0; i < id.length; i++) h = h * 31 + id.charCodeAt(i) >>> 0;
|
|
82
|
+
return names[h % names.length];
|
|
83
|
+
}
|
|
84
|
+
var TILE_ICONS = [
|
|
85
|
+
"activity",
|
|
86
|
+
"archive",
|
|
87
|
+
"bar-chart-3",
|
|
88
|
+
"bell",
|
|
89
|
+
"book-open",
|
|
90
|
+
"bot",
|
|
91
|
+
"briefcase",
|
|
92
|
+
"building-2",
|
|
93
|
+
"calendar",
|
|
94
|
+
"calendar-days",
|
|
95
|
+
"camera",
|
|
96
|
+
"check-square",
|
|
97
|
+
"clipboard-list",
|
|
98
|
+
"clock",
|
|
99
|
+
"code-2",
|
|
100
|
+
"contact",
|
|
101
|
+
"credit-card",
|
|
102
|
+
"database",
|
|
103
|
+
"dollar-sign",
|
|
104
|
+
"file",
|
|
105
|
+
"file-text",
|
|
106
|
+
"folder",
|
|
107
|
+
"globe",
|
|
108
|
+
"hash",
|
|
109
|
+
"history",
|
|
110
|
+
"home",
|
|
111
|
+
"image",
|
|
112
|
+
"inbox",
|
|
113
|
+
"kanban",
|
|
114
|
+
"layers",
|
|
115
|
+
"layout-dashboard",
|
|
116
|
+
"layout-grid",
|
|
117
|
+
"link",
|
|
118
|
+
"list",
|
|
119
|
+
"list-checks",
|
|
120
|
+
"mail",
|
|
121
|
+
"map",
|
|
122
|
+
"message-square",
|
|
123
|
+
"mic",
|
|
124
|
+
"package",
|
|
125
|
+
"phone",
|
|
126
|
+
"pie-chart",
|
|
127
|
+
"play",
|
|
128
|
+
"search",
|
|
129
|
+
"send",
|
|
130
|
+
"settings",
|
|
131
|
+
"shopping-cart",
|
|
132
|
+
"sparkles",
|
|
133
|
+
"star",
|
|
134
|
+
"table",
|
|
135
|
+
"tag",
|
|
136
|
+
"target",
|
|
137
|
+
"truck",
|
|
138
|
+
"upload",
|
|
139
|
+
"user",
|
|
140
|
+
"users",
|
|
141
|
+
"video",
|
|
142
|
+
"wallet",
|
|
143
|
+
"zap"
|
|
144
|
+
];
|
|
145
|
+
function TileIcon({ icon, color, seed, size = 16, className, title }) {
|
|
146
|
+
const fill = NAV_COLORS[color ?? navColorFor(seed ?? icon ?? "")];
|
|
147
|
+
const glyph = Math.round(size * 0.7);
|
|
148
|
+
return /* @__PURE__ */ jsx(
|
|
149
|
+
"span",
|
|
150
|
+
{
|
|
151
|
+
className,
|
|
152
|
+
title,
|
|
153
|
+
"aria-hidden": title ? void 0 : true,
|
|
154
|
+
style: {
|
|
155
|
+
display: "inline-flex",
|
|
156
|
+
width: size,
|
|
157
|
+
height: size,
|
|
158
|
+
flexShrink: 0,
|
|
159
|
+
alignItems: "center",
|
|
160
|
+
justifyContent: "center",
|
|
161
|
+
borderRadius: "30%",
|
|
162
|
+
border: "1px solid rgb(0 0 0 / 0.06)",
|
|
163
|
+
background: fill,
|
|
164
|
+
color: "#fff"
|
|
165
|
+
},
|
|
166
|
+
children: iconFor(icon) ? (() => {
|
|
167
|
+
const I = iconFor(icon);
|
|
168
|
+
return /* @__PURE__ */ jsx(I, { size: glyph, weight: "fill", "aria-hidden": true });
|
|
169
|
+
})() : /* @__PURE__ */ jsx("span", { style: { width: glyph * 0.6, height: glyph * 0.6, borderRadius: 9999, background: "currentColor" } })
|
|
170
|
+
}
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
var HOST_PARAM = "clawnify_host";
|
|
174
|
+
var STORAGE_KEY = "clawnify_host";
|
|
175
|
+
var embedded = (() => {
|
|
176
|
+
if (typeof window === "undefined") return false;
|
|
177
|
+
if (window.parent === window) return false;
|
|
178
|
+
let flagged = false;
|
|
179
|
+
try {
|
|
180
|
+
flagged = new URLSearchParams(window.location.search).get(HOST_PARAM) === "1";
|
|
181
|
+
if (flagged) window.sessionStorage.setItem(STORAGE_KEY, "1");
|
|
182
|
+
else flagged = window.sessionStorage.getItem(STORAGE_KEY) === "1";
|
|
183
|
+
} catch {
|
|
184
|
+
}
|
|
185
|
+
return flagged;
|
|
186
|
+
})();
|
|
187
|
+
function post(message) {
|
|
188
|
+
if (!embedded) return;
|
|
189
|
+
window.parent.postMessage(message, "*");
|
|
190
|
+
}
|
|
191
|
+
function reportLocation(path) {
|
|
192
|
+
let clean = path;
|
|
193
|
+
try {
|
|
194
|
+
const u = new URL(path, "http://app.invalid");
|
|
195
|
+
u.searchParams.delete("token");
|
|
196
|
+
u.searchParams.delete(HOST_PARAM);
|
|
197
|
+
clean = u.pathname + u.search + u.hash;
|
|
198
|
+
} catch {
|
|
199
|
+
}
|
|
200
|
+
post({ source: "clawnify-app", v: HOST_BRIDGE_VERSION, type: "location", path: clean });
|
|
201
|
+
}
|
|
202
|
+
function AppNav({ title, icon, groups, active, onNavigate, children }) {
|
|
203
|
+
const onNavigateRef = useRef(onNavigate);
|
|
204
|
+
onNavigateRef.current = onNavigate;
|
|
205
|
+
const groupsRef = useRef(groups);
|
|
206
|
+
groupsRef.current = groups;
|
|
207
|
+
const payload = embedded ? JSON.stringify({ title, icon, groups: sanitize(groups), active }) : "";
|
|
208
|
+
const lastSent = useRef("");
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
if (!embedded || payload === lastSent.current) return;
|
|
211
|
+
lastSent.current = payload;
|
|
212
|
+
const { title: title2, icon: icon2, groups: groups2, active: active2 } = JSON.parse(payload);
|
|
213
|
+
post({ source: "clawnify-app", v: HOST_BRIDGE_VERSION, type: "nav", title: title2, icon: icon2, groups: groups2, active: active2 });
|
|
214
|
+
}, [payload]);
|
|
215
|
+
useEffect(() => {
|
|
216
|
+
if (!embedded) return;
|
|
217
|
+
function onMessage(e) {
|
|
218
|
+
if (e.source !== window.parent) return;
|
|
219
|
+
const d = e.data;
|
|
220
|
+
if (!d || d.source !== "clawnify-host" || d.v !== HOST_BRIDGE_VERSION) return;
|
|
221
|
+
if (d.type === "hello") {
|
|
222
|
+
lastSent.current = "";
|
|
223
|
+
const g = sanitize(groupsRef.current);
|
|
224
|
+
post({ source: "clawnify-app", v: HOST_BRIDGE_VERSION, type: "nav", title, icon, groups: g, active });
|
|
225
|
+
} else if (d.type === "navigate" && typeof d.id === "string") {
|
|
226
|
+
const item = groupsRef.current.flatMap((g) => g.items).find((i) => i.id === d.id);
|
|
227
|
+
if (item) onNavigateRef.current(item);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
window.addEventListener("message", onMessage);
|
|
231
|
+
post({ source: "clawnify-app", v: HOST_BRIDGE_VERSION, type: "ready" });
|
|
232
|
+
return () => window.removeEventListener("message", onMessage);
|
|
233
|
+
}, []);
|
|
234
|
+
if (embedded) return null;
|
|
235
|
+
const home = groups.flatMap((g) => g.items).find((i) => i.home);
|
|
236
|
+
const brand = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
237
|
+
(() => {
|
|
238
|
+
const I = iconFor(icon);
|
|
239
|
+
return I ? /* @__PURE__ */ jsx(I, { size: 16, "aria-hidden": true }) : null;
|
|
240
|
+
})(),
|
|
241
|
+
/* @__PURE__ */ jsx("span", { children: title })
|
|
242
|
+
] });
|
|
243
|
+
return /* @__PURE__ */ jsxs("aside", { className: "cn-nav", children: [
|
|
244
|
+
/* @__PURE__ */ jsx("style", { children: CSS }),
|
|
245
|
+
home ? /* @__PURE__ */ jsx(
|
|
246
|
+
"a",
|
|
247
|
+
{
|
|
248
|
+
href: home.href ?? "/",
|
|
249
|
+
className: "cn-nav-brand",
|
|
250
|
+
"data-active": home.id === active || void 0,
|
|
251
|
+
"aria-current": home.id === active ? "page" : void 0,
|
|
252
|
+
onClick: (e) => {
|
|
253
|
+
if (e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return;
|
|
254
|
+
e.preventDefault();
|
|
255
|
+
onNavigate(home);
|
|
256
|
+
},
|
|
257
|
+
children: brand
|
|
258
|
+
}
|
|
259
|
+
) : /* @__PURE__ */ jsx("div", { className: "cn-nav-brand", children: brand }),
|
|
260
|
+
/* @__PURE__ */ jsx("nav", { className: "cn-nav-groups", "aria-label": "Primary", children: groups.map((g, gi) => /* @__PURE__ */ jsxs("div", { className: "cn-nav-group", children: [
|
|
261
|
+
g.label && /* @__PURE__ */ jsx("p", { className: "cn-nav-eyebrow", children: g.label }),
|
|
262
|
+
g.items.filter((item) => !item.home).map((item) => /* @__PURE__ */ jsx(NavRow, { item, active: item.id === active, onNavigate }, item.id))
|
|
263
|
+
] }, g.label ?? gi)) }),
|
|
264
|
+
children && /* @__PURE__ */ jsx("div", { className: "cn-nav-footer", children })
|
|
265
|
+
] });
|
|
266
|
+
}
|
|
267
|
+
function NavRow({
|
|
268
|
+
item,
|
|
269
|
+
active,
|
|
270
|
+
onNavigate
|
|
271
|
+
}) {
|
|
272
|
+
const body = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
273
|
+
/* @__PURE__ */ jsx(TileIcon, { icon: item.icon, color: item.color, seed: item.id }),
|
|
274
|
+
/* @__PURE__ */ jsx("span", { className: "cn-nav-label", children: item.label }),
|
|
275
|
+
typeof item.count === "number" && /* @__PURE__ */ jsx("span", { className: "cn-nav-count", children: item.count })
|
|
276
|
+
] });
|
|
277
|
+
if (item.href) {
|
|
278
|
+
return /* @__PURE__ */ jsx(
|
|
279
|
+
"a",
|
|
280
|
+
{
|
|
281
|
+
href: item.href,
|
|
282
|
+
className: "cn-nav-item",
|
|
283
|
+
"data-active": active || void 0,
|
|
284
|
+
"aria-current": active ? "page" : void 0,
|
|
285
|
+
onClick: (e) => {
|
|
286
|
+
if (e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return;
|
|
287
|
+
e.preventDefault();
|
|
288
|
+
onNavigate(item);
|
|
289
|
+
},
|
|
290
|
+
children: body
|
|
291
|
+
}
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
return /* @__PURE__ */ jsx(
|
|
295
|
+
"button",
|
|
296
|
+
{
|
|
297
|
+
type: "button",
|
|
298
|
+
className: "cn-nav-item",
|
|
299
|
+
"data-active": active || void 0,
|
|
300
|
+
"aria-current": active ? "page" : void 0,
|
|
301
|
+
onClick: () => onNavigate(item),
|
|
302
|
+
children: body
|
|
303
|
+
}
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
var ICONS = {
|
|
307
|
+
"activity": Pulse,
|
|
308
|
+
"archive": Archive,
|
|
309
|
+
"bar-chart-3": ChartBar,
|
|
310
|
+
"bell": Bell,
|
|
311
|
+
"book-open": BookOpen,
|
|
312
|
+
"bot": Robot,
|
|
313
|
+
"briefcase": Briefcase,
|
|
314
|
+
"building-2": Building,
|
|
315
|
+
"calendar": Calendar,
|
|
316
|
+
"calendar-days": CalendarDots,
|
|
317
|
+
"camera": Camera,
|
|
318
|
+
"check-square": CheckSquare,
|
|
319
|
+
"clipboard-list": ClipboardText,
|
|
320
|
+
"clock": Clock,
|
|
321
|
+
"code-2": Code,
|
|
322
|
+
"contact": AddressBook,
|
|
323
|
+
"credit-card": CreditCard,
|
|
324
|
+
"database": Database,
|
|
325
|
+
"dollar-sign": CurrencyDollar,
|
|
326
|
+
"file": File,
|
|
327
|
+
"file-text": FileText,
|
|
328
|
+
"folder": Folder,
|
|
329
|
+
"globe": Globe,
|
|
330
|
+
"hash": Hash,
|
|
331
|
+
"history": ClockCounterClockwise,
|
|
332
|
+
"home": House,
|
|
333
|
+
"image": Image,
|
|
334
|
+
"inbox": Tray,
|
|
335
|
+
"kanban": Kanban,
|
|
336
|
+
"layers": Stack,
|
|
337
|
+
"layout-dashboard": SquaresFour,
|
|
338
|
+
"layout-grid": GridFour,
|
|
339
|
+
"link": Link,
|
|
340
|
+
"list": List,
|
|
341
|
+
"list-checks": ListChecks,
|
|
342
|
+
"mail": Envelope,
|
|
343
|
+
"map": MapTrifold,
|
|
344
|
+
"message-square": ChatCircle,
|
|
345
|
+
"mic": Microphone,
|
|
346
|
+
"package": Package,
|
|
347
|
+
"phone": Phone,
|
|
348
|
+
"pie-chart": ChartPie,
|
|
349
|
+
"play": Play,
|
|
350
|
+
"search": MagnifyingGlass,
|
|
351
|
+
"send": PaperPlaneTilt,
|
|
352
|
+
"settings": Gear,
|
|
353
|
+
"shopping-cart": ShoppingCart,
|
|
354
|
+
"sparkles": Sparkle,
|
|
355
|
+
"star": Star,
|
|
356
|
+
"table": Table,
|
|
357
|
+
"tag": Tag,
|
|
358
|
+
"target": Target,
|
|
359
|
+
"truck": Truck,
|
|
360
|
+
"upload": Upload,
|
|
361
|
+
"user": User,
|
|
362
|
+
"users": User,
|
|
363
|
+
"video": VideoCamera,
|
|
364
|
+
"wallet": Wallet,
|
|
365
|
+
"zap": Lightning
|
|
366
|
+
};
|
|
367
|
+
function iconFor(name) {
|
|
368
|
+
return name ? ICONS[name] : void 0;
|
|
369
|
+
}
|
|
370
|
+
function sanitize(groups) {
|
|
371
|
+
return groups.slice(0, 20).map((g) => ({
|
|
372
|
+
...g.label ? { label: String(g.label).slice(0, 40) } : {},
|
|
373
|
+
items: g.items.slice(0, 100).map((i) => ({
|
|
374
|
+
id: String(i.id),
|
|
375
|
+
label: String(i.label).slice(0, 60),
|
|
376
|
+
...i.href ? { href: String(i.href) } : {},
|
|
377
|
+
...i.icon ? { icon: String(i.icon) } : {},
|
|
378
|
+
...typeof i.count === "number" && Number.isFinite(i.count) ? { count: i.count } : {},
|
|
379
|
+
...i.home ? { home: true } : {},
|
|
380
|
+
...i.color && i.color in NAV_COLORS ? { color: i.color } : {}
|
|
381
|
+
}))
|
|
382
|
+
}));
|
|
383
|
+
}
|
|
384
|
+
var CSS = `
|
|
385
|
+
.cn-nav{width:16.25rem;flex-shrink:0;display:flex;flex-direction:column;border-right:1px solid var(--border,#e2e8f0);background:var(--surface,#fff);color:var(--foreground,#1a202c)}
|
|
386
|
+
.cn-nav-brand{height:3.5rem;flex-shrink:0;display:flex;align-items:center;gap:.5rem;padding:0 1.25rem;border-bottom:1px solid var(--border,#e2e8f0);font-size:.875rem;font-weight:600;color:inherit;text-decoration:none}
|
|
387
|
+
a.cn-nav-brand:hover{background:var(--sunken,#f1f5f9)}
|
|
388
|
+
.cn-nav-brand>svg{color:var(--primary,#dd5164)}
|
|
389
|
+
.cn-nav-groups{flex:1;overflow-y:auto;padding:.75rem}
|
|
390
|
+
.cn-nav-group+.cn-nav-group{margin-top:1rem}
|
|
391
|
+
.cn-nav-eyebrow{margin:0 0 .25rem;padding:0 .625rem;font-size:.75rem;font-weight:500;color:var(--muted,#475569)}
|
|
392
|
+
.cn-nav-item{display:flex;align-items:center;gap:.5rem;width:100%;margin:0 0 .125rem;padding:.4375rem .625rem;border:0;border-radius:.375rem;background:none;color:inherit;font:inherit;font-size:.875rem;text-align:left;text-decoration:none;cursor:pointer}
|
|
393
|
+
.cn-nav-item:hover{background:var(--sunken,#f1f5f9)}
|
|
394
|
+
.cn-nav-item[data-active]{background:color-mix(in srgb,var(--primary,#dd5164) 12%,transparent);color:var(--primary,#dd5164);font-weight:600}
|
|
395
|
+
.cn-nav-item:focus-visible{outline:2px solid var(--ring,#2563eb);outline-offset:-2px}
|
|
396
|
+
.cn-nav-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
397
|
+
.cn-nav-count{font-size:.75rem;font-variant-numeric:tabular-nums;color:var(--muted,#475569)}
|
|
398
|
+
.cn-nav-item[data-active] .cn-nav-count{color:inherit}
|
|
399
|
+
.cn-nav-footer{padding:.75rem;border-top:1px solid var(--border,#e2e8f0)}
|
|
400
|
+
@media (max-width:767px){
|
|
401
|
+
.cn-nav{width:100%;flex-direction:row;border-right:0;border-bottom:1px solid var(--border,#e2e8f0)}
|
|
402
|
+
.cn-nav-brand,.cn-nav-eyebrow,.cn-nav-footer{display:none}
|
|
403
|
+
.cn-nav-groups{display:flex;gap:.25rem;padding:.5rem .75rem;overflow-x:auto;overflow-y:hidden}
|
|
404
|
+
.cn-nav-group{display:flex;gap:.25rem}
|
|
405
|
+
.cn-nav-group+.cn-nav-group{margin:0}
|
|
406
|
+
.cn-nav-item{width:auto;margin:0;white-space:nowrap}
|
|
407
|
+
}
|
|
408
|
+
`;
|
|
409
|
+
export {
|
|
410
|
+
AppNav,
|
|
411
|
+
HOST_BRIDGE_VERSION,
|
|
412
|
+
NAV_COLORS,
|
|
413
|
+
TILE_ICONS,
|
|
414
|
+
TileIcon,
|
|
415
|
+
embedded,
|
|
416
|
+
navColorFor,
|
|
417
|
+
reportLocation
|
|
418
|
+
};
|
|
419
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/client/index.tsx"],"sourcesContent":["/**\n * @clawnify/app/client — the host bridge for a Clawnify app's browser side.\n *\n * A Clawnify app is a full page on its own origin. Opened directly (local\n * `pnpm dev`, or `<slug>.apps.clawnify.com`) it renders its own sidebar.\n * Opened inside the Clawnify dashboard it sits in an iframe, and the dashboard\n * wants to render that same navigation in ITS sidebar so the user sees one\n * nav, not two.\n *\n * `<AppNav>` is the one definition of the app's navigation that serves both:\n *\n * • standalone → it draws the app's sidebar (desktop rail, mobile strip)\n * • embedded → it draws nothing and posts the nav tree to the host over\n * `postMessage`; the host renders it and posts `navigate`\n * back when the user clicks.\n *\n * Nothing about the app changes between the two: same router, same screens,\n * same data. Only who paints the list of links.\n *\n * import { AppNav, reportLocation } from \"@clawnify/app/client\";\n *\n * <AppNav\n * title=\"OpenDialer\"\n * icon=\"phone\"\n * groups={[{ label: \"Work\", items: [\n * { id: \"dashboard\", label: \"Dashboard\", href: \"/\", home: true },\n * { id: \"leads\", label: \"Leads\", href: \"/leads\", icon: \"users\", count: 12 },\n * ]}]}\n * active=\"leads\"\n * onNavigate={(item) => navigate(item.href!)}\n * />\n *\n * Re-render with a new `groups` / `active` and the host sidebar updates in\n * the same tick — counts are just a field, so \"Leads 12\" becomes \"Leads 11\"\n * the moment your own state does. No polling, no endpoint.\n *\n * Embedding is detected from the `clawnify_host=1` query parameter the\n * dashboard appends to the iframe URL, remembered in sessionStorage so a\n * full-page navigation inside the iframe stays in embedded mode. A page that\n * is iframed by anything else, or opened directly, is \"standalone\".\n *\n * Protocol (versioned, additive — `nav` and `location` are the first\n * message types; more host surfaces can ride the same channel later):\n *\n * app → host { source: \"clawnify-app\", v: 1, type: \"ready\" }\n * { source: \"clawnify-app\", v: 1, type: \"nav\", title, icon?, groups, active? }\n * { source: \"clawnify-app\", v: 1, type: \"location\", path }\n * host → app { source: \"clawnify-host\", v: 1, type: \"hello\" }\n * { source: \"clawnify-host\", v: 1, type: \"navigate\", id }\n */\nimport {\n useEffect,\n useRef,\n type MouseEvent,\n type ReactNode,\n} from \"react\";\nimport {\n AddressBook,\n Archive,\n Bell,\n BookOpen,\n Briefcase,\n Building,\n Calendar,\n CalendarDots,\n Camera,\n ChartBar,\n ChartPie,\n ChatCircle,\n CheckSquare,\n ClipboardText,\n Clock,\n ClockCounterClockwise,\n Code,\n CreditCard,\n CurrencyDollar,\n Database,\n Envelope,\n File,\n FileText,\n Folder,\n Gear,\n Globe,\n GridFour,\n Hash,\n House,\n Image,\n Kanban,\n Lightning,\n Link,\n List,\n ListChecks,\n MagnifyingGlass,\n MapTrifold,\n Microphone,\n Package,\n PaperPlaneTilt,\n Phone,\n Play,\n Pulse,\n Robot,\n ShoppingCart,\n Sparkle,\n SquaresFour,\n Stack,\n Star,\n Table,\n Tag,\n Target,\n Tray,\n Truck,\n Upload,\n User,\n VideoCamera,\n Wallet,\n type Icon as PhosphorIcon,\n} from \"@phosphor-icons/react\";\n\nexport const HOST_BRIDGE_VERSION = 1 as const;\n\n/** One row in the navigation. `icon` is a lucide icon name (kebab-case). */\nexport interface AppNavItem {\n /** Stable identifier the host hands back on `navigate`. */\n id: string;\n label: string;\n /**\n * In-app path this item opens. Optional: a state-driven view can omit it.\n * When present the host uses it to restore the view on reload and to make\n * the dashboard URL shareable.\n */\n href?: string;\n /** Icon name from TILE_ICONS, e.g. \"layout-dashboard\". Unknown names render a dot. */\n icon?: string;\n /** Live badge, e.g. items waiting. Omit for none. */\n count?: number;\n /**\n * The app's home screen. Not listed as a row: standalone the brand row\n * opens it, and in the dashboard the app's own header does. One per app.\n */\n home?: boolean;\n /**\n * Tile colour for this section. Sections are the records inside an app,\n * so they draw as a small coloured tile with a white glyph (the app itself\n * is navigation and stays an outline glyph). One of `NAV_COLORS`; omitted\n * = picked from the palette by `id`, stable across renders and hosts.\n */\n color?: NavColor;\n}\n\n/** The section tile palette, shared by the standalone sidebar and the dashboard. */\nexport const NAV_COLORS = {\n red: \"#ef4444\",\n orange: \"#f97514\",\n amber: \"#f59e0b\",\n green: \"#22c55e\",\n sky: \"#17bde9\",\n blue: \"#266df0\",\n violet: \"#8b5cf6\",\n pink: \"#ec4899\",\n} as const;\nexport type NavColor = keyof typeof NAV_COLORS;\n\n/** Deterministic palette pick for an item without an explicit colour. */\nexport function navColorFor(id: string): NavColor {\n const names = Object.keys(NAV_COLORS) as NavColor[];\n let h = 0;\n for (let i = 0; i < id.length; i++) h = (h * 31 + id.charCodeAt(i)) >>> 0;\n return names[h % names.length];\n}\n\n/**\n * The icon library: the names the Clawnify dashboard can draw for an app\n * and its sections (resolved to the Phosphor set in both sidebars). Pick\n * from these; the apps AGENTS.md lists them by meaning.\n */\nexport const TILE_ICONS = [\n \"activity\",\n \"archive\",\n \"bar-chart-3\",\n \"bell\",\n \"book-open\",\n \"bot\",\n \"briefcase\",\n \"building-2\",\n \"calendar\",\n \"calendar-days\",\n \"camera\",\n \"check-square\",\n \"clipboard-list\",\n \"clock\",\n \"code-2\",\n \"contact\",\n \"credit-card\",\n \"database\",\n \"dollar-sign\",\n \"file\",\n \"file-text\",\n \"folder\",\n \"globe\",\n \"hash\",\n \"history\",\n \"home\",\n \"image\",\n \"inbox\",\n \"kanban\",\n \"layers\",\n \"layout-dashboard\",\n \"layout-grid\",\n \"link\",\n \"list\",\n \"list-checks\",\n \"mail\",\n \"map\",\n \"message-square\",\n \"mic\",\n \"package\",\n \"phone\",\n \"pie-chart\",\n \"play\",\n \"search\",\n \"send\",\n \"settings\",\n \"shopping-cart\",\n \"sparkles\",\n \"star\",\n \"table\",\n \"tag\",\n \"target\",\n \"truck\",\n \"upload\",\n \"user\",\n \"users\",\n \"video\",\n \"wallet\",\n \"zap\",\n] as const;\nexport type TileIconName = (typeof TILE_ICONS)[number];\n\nexport interface TileIconProps {\n /** Icon name from TILE_ICONS. Unknown or missing = a small dot. */\n icon?: string;\n /** Palette colour. Omitted = picked from `seed` (or `icon`) by hash. */\n color?: NavColor;\n /** Stable string the colour is derived from when `color` is not given. */\n seed?: string;\n /** Tile edge in px. The glyph scales with it. Default 16. */\n size?: number;\n className?: string;\n title?: string;\n}\n\n/**\n * The record tile: a small rounded square in a palette colour with a white\n * lucide glyph. The sidebar draws every app section with it; apps can use\n * the same tile anywhere a record type needs an identity mark (table rows,\n * cards, pickers) so the two surfaces stay one system. Self-contained inline\n * styles, so it works outside <AppNav> and in any stylesheet setup.\n *\n * <TileIcon icon=\"users\" color=\"blue\" />\n * <TileIcon icon=\"phone\" seed={lead.id} size={20} />\n */\nexport function TileIcon({ icon, color, seed, size = 16, className, title }: TileIconProps) {\n const fill = NAV_COLORS[color ?? navColorFor(seed ?? icon ?? \"\")];\n // The glyph box is 0.7 of the tile: Phosphor draws on ~224 of its 256\n // units, so the visible glyph lands near 60% of the tile with clear\n // padding around it, solid white — Attio's record-tile proportion.\n const glyph = Math.round(size * 0.7);\n return (\n <span\n className={className}\n title={title}\n aria-hidden={title ? undefined : true}\n style={{\n display: \"inline-flex\",\n width: size,\n height: size,\n flexShrink: 0,\n alignItems: \"center\",\n justifyContent: \"center\",\n borderRadius: \"30%\",\n border: \"1px solid rgb(0 0 0 / 0.06)\",\n background: fill,\n color: \"#fff\",\n }}\n >\n {iconFor(icon) ? (\n (() => { const I = iconFor(icon)!; return <I size={glyph} weight=\"fill\" aria-hidden />; })()\n ) : (\n <span style={{ width: glyph * 0.6, height: glyph * 0.6, borderRadius: 9999, background: \"currentColor\" }} />\n )}\n </span>\n );\n}\n\nexport interface AppNavGroup {\n /** Eyebrow shown above the items. Omit for an unlabelled group. */\n label?: string;\n items: AppNavItem[];\n}\n\nexport type AppToHostMessage =\n | { source: \"clawnify-app\"; v: 1; type: \"ready\" }\n | {\n source: \"clawnify-app\";\n v: 1;\n type: \"nav\";\n title: string;\n /** lucide icon name for the app itself. */\n icon?: string;\n groups: AppNavGroup[];\n active?: string;\n }\n | { source: \"clawnify-app\"; v: 1; type: \"location\"; path: string };\n\nexport type HostToAppMessage =\n | { source: \"clawnify-host\"; v: 1; type: \"hello\" }\n | { source: \"clawnify-host\"; v: 1; type: \"navigate\"; id: string };\n\nconst HOST_PARAM = \"clawnify_host\";\nconst STORAGE_KEY = \"clawnify_host\";\n\n/**\n * Whether this page is running inside the Clawnify dashboard. Computed once at\n * module load — the query parameter is only on the initial URL — and remembered\n * for the tab so in-iframe full navigations keep the mode.\n */\nexport const embedded: boolean = (() => {\n if (typeof window === \"undefined\") return false;\n if (window.parent === window) return false;\n let flagged = false;\n try {\n flagged = new URLSearchParams(window.location.search).get(HOST_PARAM) === \"1\";\n if (flagged) window.sessionStorage.setItem(STORAGE_KEY, \"1\");\n else flagged = window.sessionStorage.getItem(STORAGE_KEY) === \"1\";\n } catch {\n // Storage can throw in a partitioned or locked-down iframe; the query\n // parameter alone still decides for this document.\n }\n return flagged;\n})();\n\nfunction post(message: AppToHostMessage) {\n if (!embedded) return;\n // The dashboard may live on app.clawnify.com or a white-label domain, so the\n // app cannot pin the target origin. The payload is navigation labels and a\n // path — nothing secret — and the host verifies the sender is its own iframe.\n window.parent.postMessage(message, \"*\");\n}\n\n/**\n * Tell the host where the app is, so the dashboard URL can restore this view\n * on reload. Call it whenever your router's location changes; a no-op when\n * standalone.\n */\nexport function reportLocation(path: string) {\n // The initial URL carries the dashboard's own parameters (the app token\n // and the host flag). They are not part of the app's location and must\n // never land in a URL the dashboard writes, so strip them here as well.\n let clean = path;\n try {\n const u = new URL(path, \"http://app.invalid\");\n u.searchParams.delete(\"token\");\n u.searchParams.delete(HOST_PARAM);\n clean = u.pathname + u.search + u.hash;\n } catch {\n // Not a path we can parse: send as-is, the host validates its shape.\n }\n post({ source: \"clawnify-app\", v: HOST_BRIDGE_VERSION, type: \"location\", path: clean });\n}\n\nexport interface AppNavProps {\n /** App name, shown in the brand row standalone and in the host's switcher. */\n title: string;\n /**\n * The app's own glyph, a lucide icon name (kebab-case). Drawn as an\n * outline icon with no background: in the standalone brand row, and by the\n * dashboard on the app's sidebar item. Tiles are for records, not for\n * navigation, so the app's coloured tile icon stays out of the sidebar.\n */\n icon?: string;\n groups: AppNavGroup[];\n /** `id` of the active item. */\n active?: string;\n /** Called with the item the user chose, from either renderer. */\n onNavigate: (item: AppNavItem) => void;\n /** Rendered at the bottom of the standalone sidebar (a footer action, say). */\n children?: ReactNode;\n}\n\n/**\n * The app's navigation: sidebar when standalone, host-fed when embedded.\n *\n * Standalone layout: the sidebar is a 260px column at ≥768px and a horizontal\n * strip below that, so put it first inside a `flex flex-col md:flex-row`\n * container. It paints with the app's own theme tokens (`--surface`,\n * `--border`, `--primary`…) and falls back to the platform defaults when a\n * token is missing.\n */\nexport function AppNav({ title, icon, groups, active, onNavigate, children }: AppNavProps) {\n // Always the latest callback, so the host listener never calls a stale one.\n const onNavigateRef = useRef(onNavigate);\n onNavigateRef.current = onNavigate;\n const groupsRef = useRef(groups);\n groupsRef.current = groups;\n\n // Embedded: publish the tree whenever it changes. Serialising is the cheap\n // way to dedupe — apps build `groups` inline every render.\n const payload = embedded\n ? JSON.stringify({ title, icon, groups: sanitize(groups), active })\n : \"\";\n const lastSent = useRef(\"\");\n useEffect(() => {\n if (!embedded || payload === lastSent.current) return;\n lastSent.current = payload;\n const { title, icon, groups, active } = JSON.parse(payload) as {\n title: string;\n icon?: string;\n groups: AppNavGroup[];\n active?: string;\n };\n post({ source: \"clawnify-app\", v: HOST_BRIDGE_VERSION, type: \"nav\", title, icon, groups, active });\n }, [payload]);\n\n // Embedded: handshake + listen for the host's clicks.\n useEffect(() => {\n if (!embedded) return;\n function onMessage(e: MessageEvent) {\n if (e.source !== window.parent) return;\n const d = e.data as HostToAppMessage | undefined;\n if (!d || d.source !== \"clawnify-host\" || d.v !== HOST_BRIDGE_VERSION) return;\n if (d.type === \"hello\") {\n // Host (re)mounted its listener after we first published: resend.\n lastSent.current = \"\";\n const g = sanitize(groupsRef.current);\n post({ source: \"clawnify-app\", v: HOST_BRIDGE_VERSION, type: \"nav\", title, icon, groups: g, active });\n } else if (d.type === \"navigate\" && typeof d.id === \"string\") {\n const item = groupsRef.current.flatMap((g) => g.items).find((i) => i.id === d.id);\n if (item) onNavigateRef.current(item);\n }\n }\n window.addEventListener(\"message\", onMessage);\n post({ source: \"clawnify-app\", v: HOST_BRIDGE_VERSION, type: \"ready\" });\n return () => window.removeEventListener(\"message\", onMessage);\n // title/active are read from the closure only on `hello`; the publish\n // effect above covers their normal updates.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n if (embedded) return null;\n\n const home = groups.flatMap((g) => g.items).find((i) => i.home);\n const brand = (\n <>\n {(() => { const I = iconFor(icon); return I ? <I size={16} aria-hidden /> : null; })()}\n <span>{title}</span>\n </>\n );\n\n return (\n <aside className=\"cn-nav\">\n <style>{CSS}</style>\n {home ? (\n <a\n href={home.href ?? \"/\"}\n className=\"cn-nav-brand\"\n data-active={home.id === active || undefined}\n aria-current={home.id === active ? \"page\" : undefined}\n onClick={(e: MouseEvent) => {\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return;\n e.preventDefault();\n onNavigate(home);\n }}\n >\n {brand}\n </a>\n ) : (\n <div className=\"cn-nav-brand\">{brand}</div>\n )}\n <nav className=\"cn-nav-groups\" aria-label=\"Primary\">\n {groups.map((g, gi) => (\n <div className=\"cn-nav-group\" key={g.label ?? gi}>\n {g.label && <p className=\"cn-nav-eyebrow\">{g.label}</p>}\n {g.items\n .filter((item) => !item.home)\n .map((item) => (\n <NavRow key={item.id} item={item} active={item.id === active} onNavigate={onNavigate} />\n ))}\n </div>\n ))}\n </nav>\n {children && <div className=\"cn-nav-footer\">{children}</div>}\n </aside>\n );\n}\n\nfunction NavRow({\n item,\n active,\n onNavigate,\n}: {\n item: AppNavItem;\n active: boolean;\n onNavigate: (item: AppNavItem) => void;\n}) {\n const body = (\n <>\n <TileIcon icon={item.icon} color={item.color} seed={item.id} />\n <span className=\"cn-nav-label\">{item.label}</span>\n {typeof item.count === \"number\" && <span className=\"cn-nav-count\">{item.count}</span>}\n </>\n );\n // A real link when there is an href — middle-click and copy-link keep\n // working — but the click itself goes through the app's router.\n if (item.href) {\n return (\n <a\n href={item.href}\n className=\"cn-nav-item\"\n data-active={active || undefined}\n aria-current={active ? \"page\" : undefined}\n onClick={(e: MouseEvent) => {\n if (e.metaKey || e.ctrlKey || e.shiftKey || e.button !== 0) return;\n e.preventDefault();\n onNavigate(item);\n }}\n >\n {body}\n </a>\n );\n }\n return (\n <button\n type=\"button\"\n className=\"cn-nav-item\"\n data-active={active || undefined}\n aria-current={active ? \"page\" : undefined}\n onClick={() => onNavigate(item)}\n >\n {body}\n </button>\n );\n}\n\n/** Our names → Phosphor components; the same map the dashboard holds. */\nconst ICONS: Record<string, PhosphorIcon> = {\n \"activity\": Pulse,\n \"archive\": Archive,\n \"bar-chart-3\": ChartBar,\n \"bell\": Bell,\n \"book-open\": BookOpen,\n \"bot\": Robot,\n \"briefcase\": Briefcase,\n \"building-2\": Building,\n \"calendar\": Calendar,\n \"calendar-days\": CalendarDots,\n \"camera\": Camera,\n \"check-square\": CheckSquare,\n \"clipboard-list\": ClipboardText,\n \"clock\": Clock,\n \"code-2\": Code,\n \"contact\": AddressBook,\n \"credit-card\": CreditCard,\n \"database\": Database,\n \"dollar-sign\": CurrencyDollar,\n \"file\": File,\n \"file-text\": FileText,\n \"folder\": Folder,\n \"globe\": Globe,\n \"hash\": Hash,\n \"history\": ClockCounterClockwise,\n \"home\": House,\n \"image\": Image,\n \"inbox\": Tray,\n \"kanban\": Kanban,\n \"layers\": Stack,\n \"layout-dashboard\": SquaresFour,\n \"layout-grid\": GridFour,\n \"link\": Link,\n \"list\": List,\n \"list-checks\": ListChecks,\n \"mail\": Envelope,\n \"map\": MapTrifold,\n \"message-square\": ChatCircle,\n \"mic\": Microphone,\n \"package\": Package,\n \"phone\": Phone,\n \"pie-chart\": ChartPie,\n \"play\": Play,\n \"search\": MagnifyingGlass,\n \"send\": PaperPlaneTilt,\n \"settings\": Gear,\n \"shopping-cart\": ShoppingCart,\n \"sparkles\": Sparkle,\n \"star\": Star,\n \"table\": Table,\n \"tag\": Tag,\n \"target\": Target,\n \"truck\": Truck,\n \"upload\": Upload,\n \"user\": User,\n \"users\": User,\n \"video\": VideoCamera,\n \"wallet\": Wallet,\n \"zap\": Lightning,\n};\nfunction iconFor(name?: string): PhosphorIcon | undefined {\n return name ? ICONS[name] : undefined;\n}\n\n/** Only the fields the protocol defines, with sane bounds, cross the bridge. */\nfunction sanitize(groups: AppNavGroup[]): AppNavGroup[] {\n return groups.slice(0, 20).map((g) => ({\n ...(g.label ? { label: String(g.label).slice(0, 40) } : {}),\n items: g.items.slice(0, 100).map((i) => ({\n id: String(i.id),\n label: String(i.label).slice(0, 60),\n ...(i.href ? { href: String(i.href) } : {}),\n ...(i.icon ? { icon: String(i.icon) } : {}),\n ...(typeof i.count === \"number\" && Number.isFinite(i.count) ? { count: i.count } : {}),\n ...(i.home ? { home: true } : {}),\n ...(i.color && i.color in NAV_COLORS ? { color: i.color } : {}),\n })),\n }));\n}\n\n// Scoped by class prefix; tokens follow apps/DESIGN.md with its light defaults\n// as fallbacks, so an app with a partial theme still gets a readable sidebar.\nconst CSS = `\n.cn-nav{width:16.25rem;flex-shrink:0;display:flex;flex-direction:column;border-right:1px solid var(--border,#e2e8f0);background:var(--surface,#fff);color:var(--foreground,#1a202c)}\n.cn-nav-brand{height:3.5rem;flex-shrink:0;display:flex;align-items:center;gap:.5rem;padding:0 1.25rem;border-bottom:1px solid var(--border,#e2e8f0);font-size:.875rem;font-weight:600;color:inherit;text-decoration:none}\na.cn-nav-brand:hover{background:var(--sunken,#f1f5f9)}\n.cn-nav-brand>svg{color:var(--primary,#dd5164)}\n.cn-nav-groups{flex:1;overflow-y:auto;padding:.75rem}\n.cn-nav-group+.cn-nav-group{margin-top:1rem}\n.cn-nav-eyebrow{margin:0 0 .25rem;padding:0 .625rem;font-size:.75rem;font-weight:500;color:var(--muted,#475569)}\n.cn-nav-item{display:flex;align-items:center;gap:.5rem;width:100%;margin:0 0 .125rem;padding:.4375rem .625rem;border:0;border-radius:.375rem;background:none;color:inherit;font:inherit;font-size:.875rem;text-align:left;text-decoration:none;cursor:pointer}\n.cn-nav-item:hover{background:var(--sunken,#f1f5f9)}\n.cn-nav-item[data-active]{background:color-mix(in srgb,var(--primary,#dd5164) 12%,transparent);color:var(--primary,#dd5164);font-weight:600}\n.cn-nav-item:focus-visible{outline:2px solid var(--ring,#2563eb);outline-offset:-2px}\n.cn-nav-label{flex:1;min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}\n.cn-nav-count{font-size:.75rem;font-variant-numeric:tabular-nums;color:var(--muted,#475569)}\n.cn-nav-item[data-active] .cn-nav-count{color:inherit}\n.cn-nav-footer{padding:.75rem;border-top:1px solid var(--border,#e2e8f0)}\n@media (max-width:767px){\n.cn-nav{width:100%;flex-direction:row;border-right:0;border-bottom:1px solid var(--border,#e2e8f0)}\n.cn-nav-brand,.cn-nav-eyebrow,.cn-nav-footer{display:none}\n.cn-nav-groups{display:flex;gap:.25rem;padding:.5rem .75rem;overflow-x:auto;overflow-y:hidden}\n.cn-nav-group{display:flex;gap:.25rem}\n.cn-nav-group+.cn-nav-group{margin:0}\n.cn-nav-item{width:auto;margin:0;white-space:nowrap}\n}\n`;\n"],"mappings":";AAkDA;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OAEK;AA0K2C,SAsK9C,UAtK8C,KAsK9C,YAtK8C;AAxK3C,IAAM,sBAAsB;AAgC5B,IAAM,aAAa;AAAA,EACxB,KAAK;AAAA,EACL,QAAQ;AAAA,EACR,OAAO;AAAA,EACP,OAAO;AAAA,EACP,KAAK;AAAA,EACL,MA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AAI,EAAE,OAAO,EAAE,MAAM,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAAA,MACzC,GAAI,EAAE,OAAO,EAAE,MAAM,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC;AAAA,MACzC,GAAI,OAAO,EAAE,UAAU,YAAY,OAAO,SAAS,EAAE,KAAK,IAAI,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAAA,MACpF,GAAI,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AAAA,MAC/B,GAAI,EAAE,SAAS,EAAE,SAAS,aAAa,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAAA,IAC/D,EAAE;AAAA,EACJ,EAAE;AACJ;AAIA,IAAM,MAAM;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;","names":["title","icon","groups","active"]}
|
package/dist/index.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ interface RequestLike {
|
|
|
46
46
|
* | `public` | an unauthenticated visitor on a declared public route |
|
|
47
47
|
* | `bypass` | platform-internal fetch (build/screenshot) |
|
|
48
48
|
* | `system` | the build pipeline |
|
|
49
|
-
* | `app` | another app in the same org
|
|
49
|
+
* | `app` | another app in the same org (or a headless org-token caller)|
|
|
50
50
|
*/
|
|
51
51
|
type Caller = "user" | "api" | "agent" | "agent-browser" | "public" | "bypass" | "system" | "app";
|
|
52
52
|
/** The signed-in person behind a request. */
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/identity.ts"],"sourcesContent":["/**\n * @clawnify/app — the standard Clawnify app skeleton in one call.\n *\n * `createApp(opts)` returns a fully-wired OpenAPIHono with every always-required,\n * cross-cutting concern pre-baked, so an app's server file is just imports +\n * routes + `export default app`:\n *\n * import { createApp, createRoute, z } from \"@clawnify/app\";\n * const app = createApp<Env>({ title: \"CRM App\", version: \"1.0.0\" });\n * app.openapi(listContacts, handler);\n * export default app;\n *\n * What it bakes in — the boilerplate every app used to re-write in its server\n * file, and could forget:\n * • OpenAPIHono construction (typed to your Env).\n * • Database init — `initDB(c.env)` middleware on every request. @clawnify/db\n * auto-detects the D1 binding (production WfP) or the Storage capability\n * binding (Dynamic Workers preview), so handlers can query immediately.\n * • API discovery — `mountDiscovery` serves GET /api/openapi.json (the machine\n * contract) and GET /llms.txt (the lean agent index), generated from the\n * live routes so they can't drift.\n * • Identity — `user(c)` / `orgId(c)` / `caller(c)` read the platform-injected\n * `X-Clawnify-*` headers, so an app never hand-parses them (see identity.ts).\n *\n * The point: a new always-required concern is added HERE once and every app\n * inherits it on the next rebuild — instead of a line each agent must remember\n * to write (and a build gate to enforce) in every app.\n */\nimport { OpenAPIHono, mountDiscovery, type DiscoveryOptions } from \"@clawnify/routes\";\nimport { initDB } from \"@clawnify/db\";\nimport type { Env } from \"hono\";\n\n// One routing import for app authors: everything needed to declare routes and\n// build the app comes from @clawnify/app. These are re-exports of the same\n// @hono/zod-openapi primitives @clawnify/routes exposes — never reimplemented —\n// so route creation, discovery, and construction all live behind one import.\nexport {\n OpenAPIHono,\n createRoute,\n z,\n mountDiscovery,\n describeRoutes,\n} from \"@clawnify/routes\";\nexport type { DiscoveryOptions, DiscoverableApp } from \"@clawnify/routes\";\n\n// Identity of the caller, read from the platform-injected headers. Apps never\n// authenticate anyone themselves — see identity.ts.\nexport { user, orgId, caller } from \"./identity\";\nexport type { AppUser, Caller, RequestLike } from \"./identity\";\n\nexport interface CreateAppOptions extends DiscoveryOptions {\n /**\n * Wire the per-request database middleware (`initDB(c.env)` on `*`). Default\n * true — every Clawnify app has a D1 / Storage binding. Set false only for the\n * rare app with no database.\n */\n db?: boolean;\n /**\n * Mount GET /api/openapi.json + GET /llms.txt discovery. Default true. Set\n * false only if the app deliberately opts out of API discovery.\n */\n discovery?: boolean;\n}\n\n/**\n * Create a fully-wired Clawnify app.\n *\n * `E` is your Hono env — `{ Bindings: { DB: D1Database, ... } }` — pass it so\n * route handlers get a typed `c.env`. Everything after this call is your app's\n * own routes and business logic:\n *\n * const app = createApp<Env>({ title: \"CRM App\", version: \"1.0.0\" });\n * app.openapi(route, handler);\n * export default app;\n */\nexport function createApp<E extends Env = Env>(\n opts: CreateAppOptions = {},\n): OpenAPIHono<E> {\n const app = new OpenAPIHono<E>();\n\n if (opts.db !== false) {\n app.use(\"*\", async (c, next) => {\n // @clawnify/db reads the DB (D1) or Storage binding off the env and caches\n // the Drizzle client for this request. Safe to call on every request.\n initDB(c.env as unknown as Parameters<typeof initDB>[0]);\n await next();\n });\n }\n\n if (opts.discovery !== false) {\n mountDiscovery(app, opts);\n }\n\n return app;\n}\n","/**\n * Identity — who is calling this app.\n *\n * The platform authenticates the caller at the perimeter (app-router, the\n * app-supervisor preview tier, or the /v1/apps/:id/proxy API) and injects a\n * *fresh* set of `X-Clawnify-*` headers. Any client-supplied `X-Clawnify-*` is\n * stripped first, so these headers cannot be spoofed and an app can trust them\n * directly.\n *\n * Apps therefore never authenticate anyone themselves: never read\n * `Authorization`, never parse a cookie, never verify a JWT. Read these\n * helpers instead.\n *\n * import { user, orgId, caller } from \"@clawnify/app\";\n *\n * app.openapi(route, (c) => {\n * const u = user(c); // null when the caller isn't a person\n * return c.json({ hello: u?.name ?? \"there\", org: orgId(c) });\n * });\n */\n\n/**\n * Minimal shape this module needs — Hono's `Context` satisfies it structurally,\n * so `user(c)` works in any handler regardless of the app's Env generics.\n */\nexport interface RequestLike {\n req: { header(name: string): string | undefined };\n}\n\n/**\n * What kind of principal is calling.\n *\n * Only `user`, `api` and `agent` carry a human identity; the rest are machine\n * or anonymous callers, for which `user()` returns null.\n *\n * | Value | Who |\n * |-----------------|------------------------------------------------------------|\n * | `user` | a signed-in person in a browser |\n * | `api` | a person via the REST API / CLI / MCP (their own token) |\n * | `agent` | the org's OpenClaw agent calling the app's API |\n * | `agent-browser` | the agent driving a real browser on its VPS |\n * | `public` | an unauthenticated visitor on a declared public route |\n * | `bypass` | platform-internal fetch (build/screenshot) |\n * | `system` | the build pipeline |\n * | `app` | another app in the same org |\n */\nexport type Caller =\n | \"user\"\n | \"api\"\n | \"agent\"\n | \"agent-browser\"\n | \"public\"\n | \"bypass\"\n | \"system\"\n | \"app\";\n\nconst CALLERS = new Set<Caller>([\n \"user\",\n \"api\",\n \"agent\",\n \"agent-browser\",\n \"public\",\n \"bypass\",\n \"system\",\n \"app\",\n]);\n\n/** The signed-in person behind a request. */\nexport interface AppUser {\n /** Supabase user id — the stable key to store on rows (`created_by`). */\n id: string;\n email: string | null;\n /** Display name, e.g. \"Ada Lovelace\". Null if the account has no name set. */\n name: string | null;\n /** Profile picture URL (https). Null if the account has no avatar. */\n avatarUrl: string | null;\n /**\n * Best-effort split of `name` — a HEURISTIC, not platform data.\n *\n * The platform stores one `full_name`; there is no real given/family split\n * behind it. This takes the first whitespace-separated token, which is wrong\n * for many names (mononyms, multi-word given names, family-name-first\n * cultures). Use it for a friendly greeting (\"Hi, Ada\"), never as a stored\n * field or a record of someone's legal name — persist `name` instead.\n */\n firstName: string | null;\n /** Remainder of `name` after the first token. Same heuristic caveat. */\n lastName: string | null;\n}\n\nfunction read(c: RequestLike, name: string): string | null {\n const v = c.req.header(name);\n if (v === undefined) return null;\n const trimmed = v.trim();\n return trimmed === \"\" ? null : trimmed;\n}\n\nfunction splitName(name: string | null): Pick<AppUser, \"firstName\" | \"lastName\"> {\n if (!name) return { firstName: null, lastName: null };\n const parts = name.split(/\\s+/).filter(Boolean);\n if (parts.length === 0) return { firstName: null, lastName: null };\n if (parts.length === 1) return { firstName: parts[0], lastName: null };\n return { firstName: parts[0], lastName: parts.slice(1).join(\" \") };\n}\n\n/**\n * What kind of principal is calling.\n *\n * Defaults to `\"public\"` — the least-privileged value — when the header is\n * missing or unrecognised, which happens when the app is reached outside the\n * platform perimeter (local `pnpm dev`). Gate privileged behaviour on an\n * explicit check (`caller(c) === \"user\"`), never on \"not public\".\n */\nexport function caller(c: RequestLike): Caller {\n const v = read(c, \"X-Clawnify-Caller\");\n return v && CALLERS.has(v as Caller) ? (v as Caller) : \"public\";\n}\n\n/**\n * The organization this request belongs to — the tenant key. Scope every query\n * by it.\n *\n * Present for `user`, `api`, `agent` and `app` callers. **Null** for\n * `agent-browser`, `public` and `bypass` — those reach the app through the\n * perimeter without an org-scoped identity — and null outside the platform.\n *\n * Treat null as \"no access\", never as a wildcard: a query filtered on a null\n * org must return nothing, not everything.\n */\nexport function orgId(c: RequestLike): string | null {\n return read(c, \"X-Clawnify-Org-Id\");\n}\n\n/**\n * The person behind this request, or `null` when the caller isn't one.\n *\n * Null for `agent-browser`, `public`, `bypass`, `system` and `app` — five of\n * the eight caller types — so always handle the null case rather than assuming\n * a user is present:\n *\n * const u = user(c);\n * const label = u ? u.name ?? u.email : \"Automated\";\n */\nexport function user(c: RequestLike): AppUser | null {\n const id = read(c, \"X-Clawnify-User-Id\");\n if (!id) return null;\n\n const name = read(c, \"X-Clawnify-User-Name\");\n return {\n id,\n email: read(c, \"X-Clawnify-User-Email\"),\n name,\n avatarUrl: read(c, \"X-Clawnify-User-Avatar\"),\n ...splitName(name),\n };\n}\n"],"mappings":";AA4BA,SAAS,aAAa,sBAA6C;AACnE,SAAS,cAAc;AAOvB;AAAA,EACE,eAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAAC;AAAA,EACA;AAAA,OACK;;;ACcP,IAAM,UAAU,oBAAI,IAAY;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAyBD,SAAS,KAAK,GAAgB,MAA6B;AACzD,QAAM,IAAI,EAAE,IAAI,OAAO,IAAI;AAC3B,MAAI,MAAM,OAAW,QAAO;AAC5B,QAAM,UAAU,EAAE,KAAK;AACvB,SAAO,YAAY,KAAK,OAAO;AACjC;AAEA,SAA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esContent":["/**\n * @clawnify/app — the standard Clawnify app skeleton in one call.\n *\n * `createApp(opts)` returns a fully-wired OpenAPIHono with every always-required,\n * cross-cutting concern pre-baked, so an app's server file is just imports +\n * routes + `export default app`:\n *\n * import { createApp, createRoute, z } from \"@clawnify/app\";\n * const app = createApp<Env>({ title: \"CRM App\", version: \"1.0.0\" });\n * app.openapi(listContacts, handler);\n * export default app;\n *\n * What it bakes in — the boilerplate every app used to re-write in its server\n * file, and could forget:\n * • OpenAPIHono construction (typed to your Env).\n * • Database init — `initDB(c.env)` middleware on every request. @clawnify/db\n * auto-detects the D1 binding (production WfP) or the Storage capability\n * binding (Dynamic Workers preview), so handlers can query immediately.\n * • API discovery — `mountDiscovery` serves GET /api/openapi.json (the machine\n * contract) and GET /llms.txt (the lean agent index), generated from the\n * live routes so they can't drift.\n * • Identity — `user(c)` / `orgId(c)` / `caller(c)` read the platform-injected\n * `X-Clawnify-*` headers, so an app never hand-parses them (see identity.ts).\n *\n * The point: a new always-required concern is added HERE once and every app\n * inherits it on the next rebuild — instead of a line each agent must remember\n * to write (and a build gate to enforce) in every app.\n */\nimport { OpenAPIHono, mountDiscovery, type DiscoveryOptions } from \"@clawnify/routes\";\nimport { initDB } from \"@clawnify/db\";\nimport type { Env } from \"hono\";\n\n// One routing import for app authors: everything needed to declare routes and\n// build the app comes from @clawnify/app. These are re-exports of the same\n// @hono/zod-openapi primitives @clawnify/routes exposes — never reimplemented —\n// so route creation, discovery, and construction all live behind one import.\nexport {\n OpenAPIHono,\n createRoute,\n z,\n mountDiscovery,\n describeRoutes,\n} from \"@clawnify/routes\";\nexport type { DiscoveryOptions, DiscoverableApp } from \"@clawnify/routes\";\n\n// Identity of the caller, read from the platform-injected headers. Apps never\n// authenticate anyone themselves — see identity.ts.\nexport { user, orgId, caller } from \"./identity\";\nexport type { AppUser, Caller, RequestLike } from \"./identity\";\n\nexport interface CreateAppOptions extends DiscoveryOptions {\n /**\n * Wire the per-request database middleware (`initDB(c.env)` on `*`). Default\n * true — every Clawnify app has a D1 / Storage binding. Set false only for the\n * rare app with no database.\n */\n db?: boolean;\n /**\n * Mount GET /api/openapi.json + GET /llms.txt discovery. Default true. Set\n * false only if the app deliberately opts out of API discovery.\n */\n discovery?: boolean;\n}\n\n/**\n * Create a fully-wired Clawnify app.\n *\n * `E` is your Hono env — `{ Bindings: { DB: D1Database, ... } }` — pass it so\n * route handlers get a typed `c.env`. Everything after this call is your app's\n * own routes and business logic:\n *\n * const app = createApp<Env>({ title: \"CRM App\", version: \"1.0.0\" });\n * app.openapi(route, handler);\n * export default app;\n */\nexport function createApp<E extends Env = Env>(\n opts: CreateAppOptions = {},\n): OpenAPIHono<E> {\n const app = new OpenAPIHono<E>();\n\n if (opts.db !== false) {\n app.use(\"*\", async (c, next) => {\n // @clawnify/db reads the DB (D1) or Storage binding off the env and caches\n // the Drizzle client for this request. Safe to call on every request.\n initDB(c.env as unknown as Parameters<typeof initDB>[0]);\n await next();\n });\n }\n\n if (opts.discovery !== false) {\n mountDiscovery(app, opts);\n }\n\n return app;\n}\n","/**\n * Identity — who is calling this app.\n *\n * The platform authenticates the caller at the perimeter (app-router, the\n * app-supervisor preview tier, or the /v1/apps/:id/proxy API) and injects a\n * *fresh* set of `X-Clawnify-*` headers. Any client-supplied `X-Clawnify-*` is\n * stripped first, so these headers cannot be spoofed and an app can trust them\n * directly.\n *\n * Apps therefore never authenticate anyone themselves: never read\n * `Authorization`, never parse a cookie, never verify a JWT. Read these\n * helpers instead.\n *\n * import { user, orgId, caller } from \"@clawnify/app\";\n *\n * app.openapi(route, (c) => {\n * const u = user(c); // null when the caller isn't a person\n * return c.json({ hello: u?.name ?? \"there\", org: orgId(c) });\n * });\n */\n\n/**\n * Minimal shape this module needs — Hono's `Context` satisfies it structurally,\n * so `user(c)` works in any handler regardless of the app's Env generics.\n */\nexport interface RequestLike {\n req: { header(name: string): string | undefined };\n}\n\n/**\n * What kind of principal is calling.\n *\n * Only `user`, `api` and `agent` carry a human identity; the rest are machine\n * or anonymous callers, for which `user()` returns null.\n *\n * | Value | Who |\n * |-----------------|------------------------------------------------------------|\n * | `user` | a signed-in person in a browser |\n * | `api` | a person via the REST API / CLI / MCP (their own token) |\n * | `agent` | the org's OpenClaw agent calling the app's API |\n * | `agent-browser` | the agent driving a real browser on its VPS |\n * | `public` | an unauthenticated visitor on a declared public route |\n * | `bypass` | platform-internal fetch (build/screenshot) |\n * | `system` | the build pipeline |\n * | `app` | another app in the same org (or a headless org-token caller)|\n */\nexport type Caller =\n | \"user\"\n | \"api\"\n | \"agent\"\n | \"agent-browser\"\n | \"public\"\n | \"bypass\"\n | \"system\"\n | \"app\";\n\nconst CALLERS = new Set<Caller>([\n \"user\",\n \"api\",\n \"agent\",\n \"agent-browser\",\n \"public\",\n \"bypass\",\n \"system\",\n \"app\",\n]);\n\n/** The signed-in person behind a request. */\nexport interface AppUser {\n /** Supabase user id — the stable key to store on rows (`created_by`). */\n id: string;\n email: string | null;\n /** Display name, e.g. \"Ada Lovelace\". Null if the account has no name set. */\n name: string | null;\n /** Profile picture URL (https). Null if the account has no avatar. */\n avatarUrl: string | null;\n /**\n * Best-effort split of `name` — a HEURISTIC, not platform data.\n *\n * The platform stores one `full_name`; there is no real given/family split\n * behind it. This takes the first whitespace-separated token, which is wrong\n * for many names (mononyms, multi-word given names, family-name-first\n * cultures). Use it for a friendly greeting (\"Hi, Ada\"), never as a stored\n * field or a record of someone's legal name — persist `name` instead.\n */\n firstName: string | null;\n /** Remainder of `name` after the first token. Same heuristic caveat. */\n lastName: string | null;\n}\n\nfunction read(c: RequestLike, name: string): string | null {\n const v = c.req.header(name);\n if (v === undefined) return null;\n const trimmed = v.trim();\n return trimmed === \"\" ? null : trimmed;\n}\n\nfunction splitName(name: string | null): Pick<AppUser, \"firstName\" | \"lastName\"> {\n if (!name) return { firstName: null, lastName: null };\n const parts = name.split(/\\s+/).filter(Boolean);\n if (parts.length === 0) return { firstName: null, lastName: null };\n if (parts.length === 1) return { firstName: parts[0], lastName: null };\n return { firstName: parts[0], lastName: parts.slice(1).join(\" \") };\n}\n\n/**\n * What kind of principal is calling.\n *\n * Defaults to `\"public\"` — the least-privileged value — when the header is\n * missing or unrecognised, which happens when the app is reached outside the\n * platform perimeter (local `pnpm dev`). Gate privileged behaviour on an\n * explicit check (`caller(c) === \"user\"`), never on \"not public\".\n */\nexport function caller(c: RequestLike): Caller {\n const v = read(c, \"X-Clawnify-Caller\");\n return v && CALLERS.has(v as Caller) ? (v as Caller) : \"public\";\n}\n\n/**\n * The organization this request belongs to — the tenant key. Scope every query\n * by it.\n *\n * Present for `user`, `api`, `agent` and `app` callers. **Null** for\n * `agent-browser`, `public` and `bypass` — those reach the app through the\n * perimeter without an org-scoped identity — and null outside the platform.\n *\n * Treat null as \"no access\", never as a wildcard: a query filtered on a null\n * org must return nothing, not everything.\n */\nexport function orgId(c: RequestLike): string | null {\n return read(c, \"X-Clawnify-Org-Id\");\n}\n\n/**\n * The person behind this request, or `null` when the caller isn't one.\n *\n * Null for `agent-browser`, `public`, `bypass`, `system` and `app` — five of\n * the eight caller types — so always handle the null case rather than assuming\n * a user is present:\n *\n * const u = user(c);\n * const label = u ? u.name ?? u.email : \"Automated\";\n */\nexport function user(c: RequestLike): AppUser | null {\n const id = read(c, \"X-Clawnify-User-Id\");\n if (!id) return null;\n\n const name = read(c, \"X-Clawnify-User-Name\");\n return {\n id,\n email: read(c, \"X-Clawnify-User-Email\"),\n name,\n avatarUrl: read(c, \"X-Clawnify-User-Avatar\"),\n ...splitName(name),\n };\n}\n"],"mappings":";AA4BA,SAAS,aAAa,sBAA6C;AACnE,SAAS,cAAc;AAOvB;AAAA,EACE,eAAAA;AAAA,EACA;AAAA,EACA;AAAA,EACA,kBAAAC;AAAA,EACA;AAAA,OACK;;;ACcP,IAAM,UAAU,oBAAI,IAAY;AAAA,EAC9B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAyBD,S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AA,EACH;AAEA,MAAI,KAAK,cAAc,OAAO;AAC5B,mBAAe,KAAK,IAAI;AAAA,EAC1B;AAEA,SAAO;AACT;","names":["OpenAPIHono","mountDiscovery"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clawnify/app",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "The standard Clawnify app skeleton in one call. createApp() returns a fully-wired OpenAPIHono with D1/Storage init + /api/openapi.json + /llms.txt discovery pre-baked, so an app is just imports + routes + export.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,26 +12,45 @@
|
|
|
12
12
|
"import": "./dist/index.js",
|
|
13
13
|
"require": "./dist/index.js",
|
|
14
14
|
"default": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./client": {
|
|
17
|
+
"types": "./dist/client/index.d.ts",
|
|
18
|
+
"import": "./dist/client/index.js",
|
|
19
|
+
"default": "./dist/client/index.js"
|
|
15
20
|
}
|
|
16
21
|
},
|
|
17
22
|
"files": [
|
|
18
23
|
"dist"
|
|
19
24
|
],
|
|
20
25
|
"dependencies": {
|
|
21
|
-
"@clawnify/
|
|
22
|
-
"@clawnify/
|
|
26
|
+
"@clawnify/db": "^0.4.1",
|
|
27
|
+
"@clawnify/routes": "^0.2.2"
|
|
23
28
|
},
|
|
24
29
|
"peerDependencies": {
|
|
25
30
|
"@hono/zod-openapi": ">=0.18 <1",
|
|
26
|
-
"hono": "*"
|
|
31
|
+
"hono": "*",
|
|
32
|
+
"react": ">=18",
|
|
33
|
+
"@phosphor-icons/react": ">=2"
|
|
27
34
|
},
|
|
28
35
|
"devDependencies": {
|
|
29
36
|
"@cloudflare/workers-types": "^4.20260405.1",
|
|
30
37
|
"@hono/zod-openapi": "^0.18.0",
|
|
38
|
+
"@phosphor-icons/react": "^2.1.10",
|
|
39
|
+
"@types/react": "^19.0.0",
|
|
31
40
|
"hono": "^4.6.0",
|
|
41
|
+
"react": "^19.2.8",
|
|
42
|
+
"react-dom": "^19.2.8",
|
|
32
43
|
"tsup": "^8.0.0",
|
|
33
44
|
"typescript": "^5.7.0"
|
|
34
45
|
},
|
|
46
|
+
"peerDependenciesMeta": {
|
|
47
|
+
"react": {
|
|
48
|
+
"optional": true
|
|
49
|
+
},
|
|
50
|
+
"@phosphor-icons/react": {
|
|
51
|
+
"optional": true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
35
54
|
"scripts": {
|
|
36
55
|
"build": "tsup",
|
|
37
56
|
"dev": "tsup --watch"
|