@exposify/next 0.0.0-stage → 0.0.2
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/LICENSE +21 -0
- package/README.md +328 -2
- package/dist/chunk-D5TQF5DY.js +53 -0
- package/dist/config.cjs +2046 -0
- package/dist/config.d.cts +191 -0
- package/dist/config.d.ts +191 -0
- package/dist/config.js +1978 -0
- package/dist/exposify-next.js +2651 -0
- package/dist/fields-olvyFnxj.d.cts +23 -0
- package/dist/fields-olvyFnxj.d.ts +23 -0
- package/dist/index.cjs +1179 -0
- package/dist/index.d.cts +201 -0
- package/dist/index.d.ts +201 -0
- package/dist/index.js +1186 -0
- package/package.json +58 -3
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { LoginField, ProposedField } from '@exposify/core';
|
|
2
|
+
import { A as ActionField } from './fields-olvyFnxj.cjs';
|
|
3
|
+
|
|
4
|
+
/** What the generator writes to the manifest. */
|
|
5
|
+
type FoundLogin = {
|
|
6
|
+
kind: "action";
|
|
7
|
+
key: string;
|
|
8
|
+
export: string;
|
|
9
|
+
file: string;
|
|
10
|
+
fields: LoginField[];
|
|
11
|
+
host?: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "route";
|
|
14
|
+
path: string;
|
|
15
|
+
file: string;
|
|
16
|
+
fields: LoginField[];
|
|
17
|
+
body: "json" | "form";
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
interface FoundPage {
|
|
21
|
+
file: string;
|
|
22
|
+
/** `/product/:slug`, as routes are written. */
|
|
23
|
+
path: string;
|
|
24
|
+
params: string[];
|
|
25
|
+
/** Tool name: `view_` and the path, snake_cased (`view_product_slug`, `/` is `view_home`). */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Search params the page (or a client component it renders) reads: optional tool arguments. */
|
|
28
|
+
search: string[];
|
|
29
|
+
/** From `export const metadata`, when it's static. */
|
|
30
|
+
title?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
/** It renders a form posting to a Server Action and reads no data of its own: hidden by default. */
|
|
33
|
+
formOnly?: boolean;
|
|
34
|
+
/** The app's checks it runs first (guards.ts). */
|
|
35
|
+
guards?: string[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type MarkerKind = "exposed" | "hidden" | "described";
|
|
39
|
+
interface StaticMarker {
|
|
40
|
+
kind: MarkerKind;
|
|
41
|
+
name?: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
/** describe()'s `input`, as written (for Server Actions, which the CLI checks against the scan). */
|
|
44
|
+
input?: WrittenInput;
|
|
45
|
+
}
|
|
46
|
+
/** A hand-written zod input shape as the CLI reads it: field names, and z.enum()'s values; "opaque" when it isn't an object literal. */
|
|
47
|
+
type WrittenInput = Record<string, {
|
|
48
|
+
enum?: string[];
|
|
49
|
+
}> | "opaque";
|
|
50
|
+
interface RouteModule {
|
|
51
|
+
/** HTTP methods the module exports (App Router), in HTTP_METHODS order. */
|
|
52
|
+
methods: string[];
|
|
53
|
+
/** `export const runtime = "edge"`. */
|
|
54
|
+
edge: boolean;
|
|
55
|
+
/** It imports aiReady from @exposify/next: the MCP route itself. */
|
|
56
|
+
mcpRoute: boolean;
|
|
57
|
+
/** Wrappers found on exported methods, e.g. `export const POST = exposed(...)`. */
|
|
58
|
+
markers: Record<string, StaticMarker>;
|
|
59
|
+
/** Each exported method's handler source, capped, for `describe`. */
|
|
60
|
+
sources: Record<string, string>;
|
|
61
|
+
}
|
|
62
|
+
interface PagesMethods {
|
|
63
|
+
methods: string[];
|
|
64
|
+
via: "if" | "switch" | "next-connect";
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* How each of a Server Action's parameters is filled when an agent calls it:
|
|
68
|
+
* `formData` gets the fields as FormData, `prev` (useActionState's previous
|
|
69
|
+
* state) gets undefined, `input` is a named argument of its own (bound with
|
|
70
|
+
* `.bind`, or passed directly by client code), and `object` (a destructured
|
|
71
|
+
* parameter) gets every field as a plain object.
|
|
72
|
+
*/
|
|
73
|
+
type ActionParamRole = "formData" | "prev" | "input" | "object";
|
|
74
|
+
interface ActionParam {
|
|
75
|
+
name: string;
|
|
76
|
+
role: ActionParamRole;
|
|
77
|
+
}
|
|
78
|
+
interface ActionExport {
|
|
79
|
+
/** The export name; "default" for a default export. */
|
|
80
|
+
name: string;
|
|
81
|
+
line: number;
|
|
82
|
+
params: ActionParam[];
|
|
83
|
+
/** Calls `cookies().set` or `.delete` (itself or through a same-file helper). */
|
|
84
|
+
setsCookies: boolean;
|
|
85
|
+
/** False when the function couldn't be found in the file (e.g. re-exported from another module): its parameters are unknown. */
|
|
86
|
+
resolved: boolean;
|
|
87
|
+
marker?: StaticMarker;
|
|
88
|
+
/** The function's source, capped, for `describe`. */
|
|
89
|
+
source?: string;
|
|
90
|
+
/** Pass 2: its parameters and the form fields it reads (fields.ts). */
|
|
91
|
+
fields: ActionField[];
|
|
92
|
+
readsAll: boolean;
|
|
93
|
+
unresolved: string[];
|
|
94
|
+
/** Pass 3: the forms that submit to it (forms.ts `linkForms`). */
|
|
95
|
+
forms?: Array<{
|
|
96
|
+
file: string;
|
|
97
|
+
line: number;
|
|
98
|
+
}>;
|
|
99
|
+
}
|
|
100
|
+
interface InlineAction {
|
|
101
|
+
/** The function's name, or the variable it's assigned to, when it has one. */
|
|
102
|
+
name?: string;
|
|
103
|
+
line: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface GenerateOptions {
|
|
107
|
+
/** Output file, relative to the project root. Default: exposify.generated.ts (.js without a tsconfig.json). */
|
|
108
|
+
out?: string;
|
|
109
|
+
/** Docs globs for search_docs. Default: README.md, docs/**\/*.md. */
|
|
110
|
+
docs?: string[];
|
|
111
|
+
/** From next.config. */
|
|
112
|
+
pageExtensions?: string[];
|
|
113
|
+
basePath?: string;
|
|
114
|
+
trailingSlash?: boolean;
|
|
115
|
+
}
|
|
116
|
+
interface FoundAppRoute {
|
|
117
|
+
router: "app";
|
|
118
|
+
file: string;
|
|
119
|
+
path: string;
|
|
120
|
+
params: string[];
|
|
121
|
+
module: RouteModule;
|
|
122
|
+
}
|
|
123
|
+
interface FoundPagesRoute {
|
|
124
|
+
router: "pages";
|
|
125
|
+
file: string;
|
|
126
|
+
path: string;
|
|
127
|
+
params: string[];
|
|
128
|
+
detected: PagesMethods | null;
|
|
129
|
+
source?: string;
|
|
130
|
+
}
|
|
131
|
+
interface FoundAction {
|
|
132
|
+
file: string;
|
|
133
|
+
/** Unique among the app's actions: the default tool name, and the URL segment under `/mcp/actions/`. */
|
|
134
|
+
key: string;
|
|
135
|
+
action: ActionExport;
|
|
136
|
+
/** An input `describe` proposed and a person accepted (exposify.descriptions.json); "stale" when the action changed since. */
|
|
137
|
+
proposed?: {
|
|
138
|
+
fields: ProposedField[];
|
|
139
|
+
status: "current" | "stale";
|
|
140
|
+
};
|
|
141
|
+
/** A page that uses it (`/checkout`, `/admin/orders/:id`), which tool calls are sent to; absent when no page does (hosts.ts). */
|
|
142
|
+
host?: string;
|
|
143
|
+
/** The app's checks it runs first (`lib/auth.ts#requireAdmin`), guards.ts. */
|
|
144
|
+
guards?: string[];
|
|
145
|
+
}
|
|
146
|
+
interface Discovery {
|
|
147
|
+
root: string;
|
|
148
|
+
/** `app` or `src/app`, when present. */
|
|
149
|
+
appDir?: string;
|
|
150
|
+
pagesDir?: string;
|
|
151
|
+
routes: Array<FoundAppRoute | FoundPagesRoute>;
|
|
152
|
+
/** The route file that imports aiReady, when there is one. */
|
|
153
|
+
mcpRoute?: {
|
|
154
|
+
file: string;
|
|
155
|
+
source: string;
|
|
156
|
+
};
|
|
157
|
+
/** The MCP route's URL without its catch-all segment (`/mcp`); absent when it isn't a catch-all, which Server Actions need. */
|
|
158
|
+
mcpPath?: string;
|
|
159
|
+
/** Exported functions of `"use server"` modules. */
|
|
160
|
+
actions: FoundAction[];
|
|
161
|
+
/** `"use server"` functions inside other code, which can't be exposed. */
|
|
162
|
+
inlineActions: Array<InlineAction & {
|
|
163
|
+
file: string;
|
|
164
|
+
}>;
|
|
165
|
+
/** App Router pages, as read tools (pages.ts). */
|
|
166
|
+
pages: FoundPage[];
|
|
167
|
+
/** The app's own login, for Connect with no code (login.ts); the other candidates, for `inspect`. */
|
|
168
|
+
login?: FoundLogin;
|
|
169
|
+
loginOthers?: FoundLogin[];
|
|
170
|
+
}
|
|
171
|
+
interface GenerateResult {
|
|
172
|
+
/** Absolute path written. */
|
|
173
|
+
file: string;
|
|
174
|
+
changed: boolean;
|
|
175
|
+
discovery: Discovery;
|
|
176
|
+
}
|
|
177
|
+
/** Discovers routes and (re)writes the manifest; only touches the file when its content changes, so dev reloads don't loop. */
|
|
178
|
+
declare function generate(root: string, opts?: GenerateOptions, warn?: (message: string) => void): GenerateResult;
|
|
179
|
+
|
|
180
|
+
interface WithExposifyOptions extends Pick<GenerateOptions, "out" | "docs"> {
|
|
181
|
+
/** Project root. Default: process.cwd(), where Next runs. */
|
|
182
|
+
root?: string;
|
|
183
|
+
}
|
|
184
|
+
type ConfigInput<C> = C | ((phase: string, ctx: {
|
|
185
|
+
defaultConfig: unknown;
|
|
186
|
+
}) => C | Promise<C>);
|
|
187
|
+
declare function withExposify<C extends object>(nextConfig?: ConfigInput<C>, options?: WithExposifyOptions): (phase: string, ctx: {
|
|
188
|
+
defaultConfig: unknown;
|
|
189
|
+
}) => Promise<C>;
|
|
190
|
+
|
|
191
|
+
export { type GenerateOptions, type WithExposifyOptions, generate, withExposify };
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import { LoginField, ProposedField } from '@exposify/core';
|
|
2
|
+
import { A as ActionField } from './fields-olvyFnxj.js';
|
|
3
|
+
|
|
4
|
+
/** What the generator writes to the manifest. */
|
|
5
|
+
type FoundLogin = {
|
|
6
|
+
kind: "action";
|
|
7
|
+
key: string;
|
|
8
|
+
export: string;
|
|
9
|
+
file: string;
|
|
10
|
+
fields: LoginField[];
|
|
11
|
+
host?: string;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "route";
|
|
14
|
+
path: string;
|
|
15
|
+
file: string;
|
|
16
|
+
fields: LoginField[];
|
|
17
|
+
body: "json" | "form";
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
interface FoundPage {
|
|
21
|
+
file: string;
|
|
22
|
+
/** `/product/:slug`, as routes are written. */
|
|
23
|
+
path: string;
|
|
24
|
+
params: string[];
|
|
25
|
+
/** Tool name: `view_` and the path, snake_cased (`view_product_slug`, `/` is `view_home`). */
|
|
26
|
+
name: string;
|
|
27
|
+
/** Search params the page (or a client component it renders) reads: optional tool arguments. */
|
|
28
|
+
search: string[];
|
|
29
|
+
/** From `export const metadata`, when it's static. */
|
|
30
|
+
title?: string;
|
|
31
|
+
description?: string;
|
|
32
|
+
/** It renders a form posting to a Server Action and reads no data of its own: hidden by default. */
|
|
33
|
+
formOnly?: boolean;
|
|
34
|
+
/** The app's checks it runs first (guards.ts). */
|
|
35
|
+
guards?: string[];
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
type MarkerKind = "exposed" | "hidden" | "described";
|
|
39
|
+
interface StaticMarker {
|
|
40
|
+
kind: MarkerKind;
|
|
41
|
+
name?: string;
|
|
42
|
+
description?: string;
|
|
43
|
+
/** describe()'s `input`, as written (for Server Actions, which the CLI checks against the scan). */
|
|
44
|
+
input?: WrittenInput;
|
|
45
|
+
}
|
|
46
|
+
/** A hand-written zod input shape as the CLI reads it: field names, and z.enum()'s values; "opaque" when it isn't an object literal. */
|
|
47
|
+
type WrittenInput = Record<string, {
|
|
48
|
+
enum?: string[];
|
|
49
|
+
}> | "opaque";
|
|
50
|
+
interface RouteModule {
|
|
51
|
+
/** HTTP methods the module exports (App Router), in HTTP_METHODS order. */
|
|
52
|
+
methods: string[];
|
|
53
|
+
/** `export const runtime = "edge"`. */
|
|
54
|
+
edge: boolean;
|
|
55
|
+
/** It imports aiReady from @exposify/next: the MCP route itself. */
|
|
56
|
+
mcpRoute: boolean;
|
|
57
|
+
/** Wrappers found on exported methods, e.g. `export const POST = exposed(...)`. */
|
|
58
|
+
markers: Record<string, StaticMarker>;
|
|
59
|
+
/** Each exported method's handler source, capped, for `describe`. */
|
|
60
|
+
sources: Record<string, string>;
|
|
61
|
+
}
|
|
62
|
+
interface PagesMethods {
|
|
63
|
+
methods: string[];
|
|
64
|
+
via: "if" | "switch" | "next-connect";
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* How each of a Server Action's parameters is filled when an agent calls it:
|
|
68
|
+
* `formData` gets the fields as FormData, `prev` (useActionState's previous
|
|
69
|
+
* state) gets undefined, `input` is a named argument of its own (bound with
|
|
70
|
+
* `.bind`, or passed directly by client code), and `object` (a destructured
|
|
71
|
+
* parameter) gets every field as a plain object.
|
|
72
|
+
*/
|
|
73
|
+
type ActionParamRole = "formData" | "prev" | "input" | "object";
|
|
74
|
+
interface ActionParam {
|
|
75
|
+
name: string;
|
|
76
|
+
role: ActionParamRole;
|
|
77
|
+
}
|
|
78
|
+
interface ActionExport {
|
|
79
|
+
/** The export name; "default" for a default export. */
|
|
80
|
+
name: string;
|
|
81
|
+
line: number;
|
|
82
|
+
params: ActionParam[];
|
|
83
|
+
/** Calls `cookies().set` or `.delete` (itself or through a same-file helper). */
|
|
84
|
+
setsCookies: boolean;
|
|
85
|
+
/** False when the function couldn't be found in the file (e.g. re-exported from another module): its parameters are unknown. */
|
|
86
|
+
resolved: boolean;
|
|
87
|
+
marker?: StaticMarker;
|
|
88
|
+
/** The function's source, capped, for `describe`. */
|
|
89
|
+
source?: string;
|
|
90
|
+
/** Pass 2: its parameters and the form fields it reads (fields.ts). */
|
|
91
|
+
fields: ActionField[];
|
|
92
|
+
readsAll: boolean;
|
|
93
|
+
unresolved: string[];
|
|
94
|
+
/** Pass 3: the forms that submit to it (forms.ts `linkForms`). */
|
|
95
|
+
forms?: Array<{
|
|
96
|
+
file: string;
|
|
97
|
+
line: number;
|
|
98
|
+
}>;
|
|
99
|
+
}
|
|
100
|
+
interface InlineAction {
|
|
101
|
+
/** The function's name, or the variable it's assigned to, when it has one. */
|
|
102
|
+
name?: string;
|
|
103
|
+
line: number;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
interface GenerateOptions {
|
|
107
|
+
/** Output file, relative to the project root. Default: exposify.generated.ts (.js without a tsconfig.json). */
|
|
108
|
+
out?: string;
|
|
109
|
+
/** Docs globs for search_docs. Default: README.md, docs/**\/*.md. */
|
|
110
|
+
docs?: string[];
|
|
111
|
+
/** From next.config. */
|
|
112
|
+
pageExtensions?: string[];
|
|
113
|
+
basePath?: string;
|
|
114
|
+
trailingSlash?: boolean;
|
|
115
|
+
}
|
|
116
|
+
interface FoundAppRoute {
|
|
117
|
+
router: "app";
|
|
118
|
+
file: string;
|
|
119
|
+
path: string;
|
|
120
|
+
params: string[];
|
|
121
|
+
module: RouteModule;
|
|
122
|
+
}
|
|
123
|
+
interface FoundPagesRoute {
|
|
124
|
+
router: "pages";
|
|
125
|
+
file: string;
|
|
126
|
+
path: string;
|
|
127
|
+
params: string[];
|
|
128
|
+
detected: PagesMethods | null;
|
|
129
|
+
source?: string;
|
|
130
|
+
}
|
|
131
|
+
interface FoundAction {
|
|
132
|
+
file: string;
|
|
133
|
+
/** Unique among the app's actions: the default tool name, and the URL segment under `/mcp/actions/`. */
|
|
134
|
+
key: string;
|
|
135
|
+
action: ActionExport;
|
|
136
|
+
/** An input `describe` proposed and a person accepted (exposify.descriptions.json); "stale" when the action changed since. */
|
|
137
|
+
proposed?: {
|
|
138
|
+
fields: ProposedField[];
|
|
139
|
+
status: "current" | "stale";
|
|
140
|
+
};
|
|
141
|
+
/** A page that uses it (`/checkout`, `/admin/orders/:id`), which tool calls are sent to; absent when no page does (hosts.ts). */
|
|
142
|
+
host?: string;
|
|
143
|
+
/** The app's checks it runs first (`lib/auth.ts#requireAdmin`), guards.ts. */
|
|
144
|
+
guards?: string[];
|
|
145
|
+
}
|
|
146
|
+
interface Discovery {
|
|
147
|
+
root: string;
|
|
148
|
+
/** `app` or `src/app`, when present. */
|
|
149
|
+
appDir?: string;
|
|
150
|
+
pagesDir?: string;
|
|
151
|
+
routes: Array<FoundAppRoute | FoundPagesRoute>;
|
|
152
|
+
/** The route file that imports aiReady, when there is one. */
|
|
153
|
+
mcpRoute?: {
|
|
154
|
+
file: string;
|
|
155
|
+
source: string;
|
|
156
|
+
};
|
|
157
|
+
/** The MCP route's URL without its catch-all segment (`/mcp`); absent when it isn't a catch-all, which Server Actions need. */
|
|
158
|
+
mcpPath?: string;
|
|
159
|
+
/** Exported functions of `"use server"` modules. */
|
|
160
|
+
actions: FoundAction[];
|
|
161
|
+
/** `"use server"` functions inside other code, which can't be exposed. */
|
|
162
|
+
inlineActions: Array<InlineAction & {
|
|
163
|
+
file: string;
|
|
164
|
+
}>;
|
|
165
|
+
/** App Router pages, as read tools (pages.ts). */
|
|
166
|
+
pages: FoundPage[];
|
|
167
|
+
/** The app's own login, for Connect with no code (login.ts); the other candidates, for `inspect`. */
|
|
168
|
+
login?: FoundLogin;
|
|
169
|
+
loginOthers?: FoundLogin[];
|
|
170
|
+
}
|
|
171
|
+
interface GenerateResult {
|
|
172
|
+
/** Absolute path written. */
|
|
173
|
+
file: string;
|
|
174
|
+
changed: boolean;
|
|
175
|
+
discovery: Discovery;
|
|
176
|
+
}
|
|
177
|
+
/** Discovers routes and (re)writes the manifest; only touches the file when its content changes, so dev reloads don't loop. */
|
|
178
|
+
declare function generate(root: string, opts?: GenerateOptions, warn?: (message: string) => void): GenerateResult;
|
|
179
|
+
|
|
180
|
+
interface WithExposifyOptions extends Pick<GenerateOptions, "out" | "docs"> {
|
|
181
|
+
/** Project root. Default: process.cwd(), where Next runs. */
|
|
182
|
+
root?: string;
|
|
183
|
+
}
|
|
184
|
+
type ConfigInput<C> = C | ((phase: string, ctx: {
|
|
185
|
+
defaultConfig: unknown;
|
|
186
|
+
}) => C | Promise<C>);
|
|
187
|
+
declare function withExposify<C extends object>(nextConfig?: ConfigInput<C>, options?: WithExposifyOptions): (phase: string, ctx: {
|
|
188
|
+
defaultConfig: unknown;
|
|
189
|
+
}) => Promise<C>;
|
|
190
|
+
|
|
191
|
+
export { type GenerateOptions, type WithExposifyOptions, generate, withExposify };
|