@aigne/afs 1.11.0-beta → 1.11.0-beta.10
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.md +17 -84
- package/README.md +4 -13
- package/dist/_virtual/rolldown_runtime.mjs +7 -0
- package/dist/afs.cjs +1330 -0
- package/dist/afs.d.cts +275 -0
- package/dist/afs.d.cts.map +1 -0
- package/dist/afs.d.mts +275 -0
- package/dist/afs.d.mts.map +1 -0
- package/dist/afs.mjs +1331 -0
- package/dist/afs.mjs.map +1 -0
- package/dist/capabilities/index.d.mts +2 -0
- package/dist/capabilities/types.d.cts +100 -0
- package/dist/capabilities/types.d.cts.map +1 -0
- package/dist/capabilities/types.d.mts +100 -0
- package/dist/capabilities/types.d.mts.map +1 -0
- package/dist/capabilities/world-mapping.cjs +20 -0
- package/dist/capabilities/world-mapping.d.cts +139 -0
- package/dist/capabilities/world-mapping.d.cts.map +1 -0
- package/dist/capabilities/world-mapping.d.mts +139 -0
- package/dist/capabilities/world-mapping.d.mts.map +1 -0
- package/dist/capabilities/world-mapping.mjs +20 -0
- package/dist/capabilities/world-mapping.mjs.map +1 -0
- package/dist/error.cjs +63 -0
- package/dist/error.d.cts +39 -0
- package/dist/error.d.cts.map +1 -0
- package/dist/error.d.mts +39 -0
- package/dist/error.d.mts.map +1 -0
- package/dist/error.mjs +59 -0
- package/dist/error.mjs.map +1 -0
- package/dist/index.cjs +72 -345
- package/dist/index.d.cts +18 -300
- package/dist/index.d.mts +20 -300
- package/dist/index.mjs +16 -342
- package/dist/loader/index.cjs +110 -0
- package/dist/loader/index.d.cts +48 -0
- package/dist/loader/index.d.cts.map +1 -0
- package/dist/loader/index.d.mts +48 -0
- package/dist/loader/index.d.mts.map +1 -0
- package/dist/loader/index.mjs +110 -0
- package/dist/loader/index.mjs.map +1 -0
- package/dist/meta/index.cjs +4 -0
- package/dist/meta/index.mjs +6 -0
- package/dist/meta/kind.cjs +161 -0
- package/dist/meta/kind.d.cts +134 -0
- package/dist/meta/kind.d.cts.map +1 -0
- package/dist/meta/kind.d.mts +134 -0
- package/dist/meta/kind.d.mts.map +1 -0
- package/dist/meta/kind.mjs +157 -0
- package/dist/meta/kind.mjs.map +1 -0
- package/dist/meta/path.cjs +116 -0
- package/dist/meta/path.d.cts +43 -0
- package/dist/meta/path.d.cts.map +1 -0
- package/dist/meta/path.d.mts +43 -0
- package/dist/meta/path.d.mts.map +1 -0
- package/dist/meta/path.mjs +112 -0
- package/dist/meta/path.mjs.map +1 -0
- package/dist/meta/type.d.cts +96 -0
- package/dist/meta/type.d.cts.map +1 -0
- package/dist/meta/type.d.mts +96 -0
- package/dist/meta/type.d.mts.map +1 -0
- package/dist/meta/validation.cjs +77 -0
- package/dist/meta/validation.d.cts +19 -0
- package/dist/meta/validation.d.cts.map +1 -0
- package/dist/meta/validation.d.mts +19 -0
- package/dist/meta/validation.d.mts.map +1 -0
- package/dist/meta/validation.mjs +77 -0
- package/dist/meta/validation.mjs.map +1 -0
- package/dist/meta/well-known-kinds.cjs +228 -0
- package/dist/meta/well-known-kinds.d.cts +52 -0
- package/dist/meta/well-known-kinds.d.cts.map +1 -0
- package/dist/meta/well-known-kinds.d.mts +52 -0
- package/dist/meta/well-known-kinds.d.mts.map +1 -0
- package/dist/meta/well-known-kinds.mjs +219 -0
- package/dist/meta/well-known-kinds.mjs.map +1 -0
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.cts +141 -0
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.cts.map +1 -0
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.mts +141 -0
- package/dist/node_modules/.pnpm/@types_json-schema@7.0.15/node_modules/@types/json-schema/index.d.mts.map +1 -0
- package/dist/path.cjs +255 -0
- package/dist/path.d.cts +93 -0
- package/dist/path.d.cts.map +1 -0
- package/dist/path.d.mts +93 -0
- package/dist/path.d.mts.map +1 -0
- package/dist/path.mjs +249 -0
- package/dist/path.mjs.map +1 -0
- package/dist/provider/base.cjs +425 -0
- package/dist/provider/base.d.cts +175 -0
- package/dist/provider/base.d.cts.map +1 -0
- package/dist/provider/base.d.mts +175 -0
- package/dist/provider/base.d.mts.map +1 -0
- package/dist/provider/base.mjs +426 -0
- package/dist/provider/base.mjs.map +1 -0
- package/dist/provider/decorators.cjs +268 -0
- package/dist/provider/decorators.d.cts +244 -0
- package/dist/provider/decorators.d.cts.map +1 -0
- package/dist/provider/decorators.d.mts +244 -0
- package/dist/provider/decorators.d.mts.map +1 -0
- package/dist/provider/decorators.mjs +256 -0
- package/dist/provider/decorators.mjs.map +1 -0
- package/dist/provider/index.cjs +19 -0
- package/dist/provider/index.d.cts +5 -0
- package/dist/provider/index.d.mts +5 -0
- package/dist/provider/index.mjs +5 -0
- package/dist/provider/router.cjs +185 -0
- package/dist/provider/router.d.cts +50 -0
- package/dist/provider/router.d.cts.map +1 -0
- package/dist/provider/router.d.mts +50 -0
- package/dist/provider/router.d.mts.map +1 -0
- package/dist/provider/router.mjs +185 -0
- package/dist/provider/router.mjs.map +1 -0
- package/dist/provider/types.d.cts +113 -0
- package/dist/provider/types.d.cts.map +1 -0
- package/dist/provider/types.d.mts +113 -0
- package/dist/provider/types.d.mts.map +1 -0
- package/dist/registry.cjs +358 -0
- package/dist/registry.d.cts +96 -0
- package/dist/registry.d.cts.map +1 -0
- package/dist/registry.d.mts +96 -0
- package/dist/registry.d.mts.map +1 -0
- package/dist/registry.mjs +360 -0
- package/dist/registry.mjs.map +1 -0
- package/dist/type.cjs +34 -0
- package/dist/type.d.cts +420 -0
- package/dist/type.d.cts.map +1 -0
- package/dist/type.d.mts +420 -0
- package/dist/type.d.mts.map +1 -0
- package/dist/type.mjs +33 -0
- package/dist/type.mjs.map +1 -0
- package/dist/utils/camelize.d.cts.map +1 -1
- package/dist/utils/camelize.d.mts.map +1 -1
- package/dist/utils/schema.cjs +129 -0
- package/dist/utils/schema.d.cts +65 -0
- package/dist/utils/schema.d.cts.map +1 -0
- package/dist/utils/schema.d.mts +65 -0
- package/dist/utils/schema.d.mts.map +1 -0
- package/dist/utils/schema.mjs +124 -0
- package/dist/utils/schema.mjs.map +1 -0
- package/dist/utils/type-utils.d.cts.map +1 -1
- package/dist/utils/type-utils.d.mts.map +1 -1
- package/dist/utils/uri-template.cjs +123 -0
- package/dist/utils/uri-template.d.cts +48 -0
- package/dist/utils/uri-template.d.cts.map +1 -0
- package/dist/utils/uri-template.d.mts +48 -0
- package/dist/utils/uri-template.d.mts.map +1 -0
- package/dist/utils/uri-template.mjs +120 -0
- package/dist/utils/uri-template.mjs.map +1 -0
- package/dist/utils/uri.cjs +49 -0
- package/dist/utils/uri.d.cts +34 -0
- package/dist/utils/uri.d.cts.map +1 -0
- package/dist/utils/uri.d.mts +34 -0
- package/dist/utils/uri.d.mts.map +1 -0
- package/dist/utils/uri.mjs +49 -0
- package/dist/utils/uri.mjs.map +1 -0
- package/dist/utils/zod.cjs +6 -8
- package/dist/utils/zod.d.cts +2 -2
- package/dist/utils/zod.d.cts.map +1 -1
- package/dist/utils/zod.d.mts +2 -2
- package/dist/utils/zod.d.mts.map +1 -1
- package/dist/utils/zod.mjs +6 -8
- package/dist/utils/zod.mjs.map +1 -1
- package/package.json +27 -4
- package/dist/index.d.cts.map +0 -1
- package/dist/index.d.mts.map +0 -1
- package/dist/index.mjs.map +0 -1
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/provider/decorators.ts
|
|
3
|
+
/**
|
|
4
|
+
* WeakMap-based route registry
|
|
5
|
+
* Using WeakMap to avoid memory leaks - when class is garbage collected,
|
|
6
|
+
* its routes are automatically cleaned up
|
|
7
|
+
*/
|
|
8
|
+
const routeRegistry = /* @__PURE__ */ new WeakMap();
|
|
9
|
+
/**
|
|
10
|
+
* Get all registered routes for a class (including inherited routes)
|
|
11
|
+
*/
|
|
12
|
+
function getRoutes(ctor) {
|
|
13
|
+
const routes = [];
|
|
14
|
+
let current = ctor;
|
|
15
|
+
while (current && current !== Function.prototype && current !== Object) {
|
|
16
|
+
const classRoutes = routeRegistry.get(current);
|
|
17
|
+
if (classRoutes) routes.unshift(...classRoutes);
|
|
18
|
+
current = Object.getPrototypeOf(current);
|
|
19
|
+
}
|
|
20
|
+
return routes;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Clear routes for a class (mainly for testing)
|
|
24
|
+
*/
|
|
25
|
+
function clearRoutes(ctor) {
|
|
26
|
+
routeRegistry.delete(ctor);
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Register a route on a class
|
|
30
|
+
*/
|
|
31
|
+
function registerRoute(ctor, pattern, operation, methodName, description, listOptions) {
|
|
32
|
+
const routes = routeRegistry.get(ctor) || [];
|
|
33
|
+
routes.push({
|
|
34
|
+
pattern,
|
|
35
|
+
operation,
|
|
36
|
+
methodName,
|
|
37
|
+
description,
|
|
38
|
+
listOptions
|
|
39
|
+
});
|
|
40
|
+
routeRegistry.set(ctor, routes);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Create a route decorator for a specific operation
|
|
44
|
+
*/
|
|
45
|
+
function createRouteDecorator(operation) {
|
|
46
|
+
return (pattern, description) => (target, propertyKey) => {
|
|
47
|
+
const ctor = target.constructor;
|
|
48
|
+
registerRoute(ctor, pattern, operation, String(propertyKey), description);
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* @List decorator - handles list operations
|
|
53
|
+
* Handler should return: { data: AFSEntry[], total?: number }
|
|
54
|
+
*
|
|
55
|
+
* @param pattern - Route pattern to match
|
|
56
|
+
* @param optionsOrDescription - Either a description string or ListDecoratorOptions
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```typescript
|
|
60
|
+
* // Simple usage
|
|
61
|
+
* @List("/:table")
|
|
62
|
+
* async listRows(ctx: RouteContext<{ table: string }>) {
|
|
63
|
+
* return { data: rows, total: 100 };
|
|
64
|
+
* }
|
|
65
|
+
*
|
|
66
|
+
* // Default behavior - base provider handles depth via BFS
|
|
67
|
+
* @List("/**")
|
|
68
|
+
* async listDir(ctx: RouteContext) {
|
|
69
|
+
* // Only need to return single-level results
|
|
70
|
+
* return { data: entries };
|
|
71
|
+
* }
|
|
72
|
+
*
|
|
73
|
+
* // Handler manages depth itself (opt-in for special cases like S3)
|
|
74
|
+
* @List("/**", { handleDepth: true })
|
|
75
|
+
* async listDirWithDepth(ctx: RouteContext) {
|
|
76
|
+
* // Handler implements maxDepth logic
|
|
77
|
+
* return { data: entries };
|
|
78
|
+
* }
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
81
|
+
function List(pattern, optionsOrDescription) {
|
|
82
|
+
return (target, propertyKey) => {
|
|
83
|
+
const ctor = target.constructor;
|
|
84
|
+
const description = typeof optionsOrDescription === "string" ? optionsOrDescription : void 0;
|
|
85
|
+
const listOptions = typeof optionsOrDescription === "object" ? optionsOrDescription : void 0;
|
|
86
|
+
registerRoute(ctor, pattern, "list", String(propertyKey), description, listOptions);
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* @Read decorator - handles read operations
|
|
91
|
+
* Handler should return: AFSEntry
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* ```typescript
|
|
95
|
+
* @Read("/:table/:pk")
|
|
96
|
+
* async getRow(ctx: RouteContext<{ table: string; pk: string }>) {
|
|
97
|
+
* return { id: pk, path: ctx.path, content: row };
|
|
98
|
+
* }
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
const Read = createRouteDecorator("read");
|
|
102
|
+
/**
|
|
103
|
+
* @Write decorator - handles write operations
|
|
104
|
+
* Handler should return: AFSWriteResult
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* ```typescript
|
|
108
|
+
* @Write("/:table/:pk")
|
|
109
|
+
* async updateRow(ctx: RouteContext, content: AFSWriteEntryPayload) {
|
|
110
|
+
* return { data: updatedEntry };
|
|
111
|
+
* }
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
const Write = createRouteDecorator("write");
|
|
115
|
+
/**
|
|
116
|
+
* @Delete decorator - handles delete operations
|
|
117
|
+
* Handler should return: AFSDeleteResult
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* ```typescript
|
|
121
|
+
* @Delete("/:table/:pk")
|
|
122
|
+
* async deleteRow(ctx: RouteContext<{ table: string; pk: string }>) {
|
|
123
|
+
* return { message: "Deleted" };
|
|
124
|
+
* }
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
127
|
+
const Delete = createRouteDecorator("delete");
|
|
128
|
+
/**
|
|
129
|
+
* @Exec decorator - handles exec operations
|
|
130
|
+
* Handler should return: AFSExecResult
|
|
131
|
+
*
|
|
132
|
+
* @example
|
|
133
|
+
* ```typescript
|
|
134
|
+
* @Exec("/:table/:pk/.actions/:action")
|
|
135
|
+
* async executeAction(ctx: RouteContext, args: Record<string, unknown>) {
|
|
136
|
+
* return { data: { success: true } };
|
|
137
|
+
* }
|
|
138
|
+
* ```
|
|
139
|
+
*/
|
|
140
|
+
const Exec = createRouteDecorator("exec");
|
|
141
|
+
/**
|
|
142
|
+
* @Search decorator - handles search operations
|
|
143
|
+
* Handler should return: AFSSearchResult
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* ```typescript
|
|
147
|
+
* @Search("/:table")
|
|
148
|
+
* async searchTable(ctx: RouteContext, query: string, options?: AFSSearchOptions) {
|
|
149
|
+
* return { data: matchingEntries };
|
|
150
|
+
* }
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
const Search = createRouteDecorator("search");
|
|
154
|
+
/**
|
|
155
|
+
* @Meta decorator - handles .meta path reads (introspection only, read-only)
|
|
156
|
+
* Automatically appends /.meta to the pattern
|
|
157
|
+
* Handler should return: AFSEntry
|
|
158
|
+
*
|
|
159
|
+
* Note: Meta is read-only. To write metadata, use @Write handler with payload.meta.
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* ```typescript
|
|
163
|
+
* @Meta("/:table/:pk") // Registers as /:table/:pk/.meta
|
|
164
|
+
* async getRowMeta(ctx: RouteContext<{ table: string; pk: string }>) {
|
|
165
|
+
* return { id: "meta", path: `${ctx.path}/.meta`, content: schema };
|
|
166
|
+
* }
|
|
167
|
+
*
|
|
168
|
+
* @Meta("/") // Registers as /.meta (root metadata)
|
|
169
|
+
* async getRootMeta(ctx: RouteContext) {
|
|
170
|
+
* return { id: "meta", path: "/.meta", content: rootSchema };
|
|
171
|
+
* }
|
|
172
|
+
* ```
|
|
173
|
+
*/
|
|
174
|
+
function Meta(pattern, description) {
|
|
175
|
+
const metaPattern = pattern === "/" ? "/.meta" : `${pattern}/.meta`;
|
|
176
|
+
return createRouteDecorator("read")(metaPattern, description);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Creates a list decorator for .actions path
|
|
180
|
+
*/
|
|
181
|
+
function createActionsListDecorator(pattern, description) {
|
|
182
|
+
const actionsPattern = pattern === "/" ? "/.actions" : `${pattern}/.actions`;
|
|
183
|
+
return createRouteDecorator("list")(actionsPattern, description);
|
|
184
|
+
}
|
|
185
|
+
/**
|
|
186
|
+
* Creates an exec decorator for action execution
|
|
187
|
+
*/
|
|
188
|
+
function createActionsExecuteDecorator(pattern, actionName, description) {
|
|
189
|
+
const basePath = pattern === "/" ? "" : pattern;
|
|
190
|
+
const fullPattern = actionName ? `${basePath}/.actions/${actionName}` : `${basePath}/.actions/:action`;
|
|
191
|
+
return createRouteDecorator("exec")(fullPattern, description);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @Actions decorator - handles action-related routes
|
|
195
|
+
*
|
|
196
|
+
* Use directly for listing actions:
|
|
197
|
+
* @example
|
|
198
|
+
* ```typescript
|
|
199
|
+
* @Actions("/:table/:pk") // Registers as /:table/:pk/.actions
|
|
200
|
+
* async listRowActions(ctx: RouteContext<{ table: string; pk: string }>) {
|
|
201
|
+
* return { data: availableActions };
|
|
202
|
+
* }
|
|
203
|
+
* ```
|
|
204
|
+
*
|
|
205
|
+
* Use Actions.Exec for action execution:
|
|
206
|
+
* @example
|
|
207
|
+
* ```typescript
|
|
208
|
+
* @Actions.Exec("/:table/:pk", "close")
|
|
209
|
+
* async closeAction(ctx: RouteContext, args: Record<string, unknown>) { ... }
|
|
210
|
+
* ```
|
|
211
|
+
*/
|
|
212
|
+
const Actions = Object.assign((pattern, description) => {
|
|
213
|
+
return createActionsListDecorator(pattern, description);
|
|
214
|
+
}, { Exec: createActionsExecuteDecorator });
|
|
215
|
+
/**
|
|
216
|
+
* @Stat decorator - handles stat operations
|
|
217
|
+
* Handler should return: AFSStatResult
|
|
218
|
+
*
|
|
219
|
+
* @example
|
|
220
|
+
* ```typescript
|
|
221
|
+
* @Stat("/:path*")
|
|
222
|
+
* async statPath(ctx: RouteContext<{ path?: string }>) {
|
|
223
|
+
* return { data: { path: ctx.path, size: 100, modified: new Date() } };
|
|
224
|
+
* }
|
|
225
|
+
* ```
|
|
226
|
+
*/
|
|
227
|
+
const Stat = createRouteDecorator("stat");
|
|
228
|
+
/**
|
|
229
|
+
* @Explain decorator - handles explain operations
|
|
230
|
+
* Handler should return: AFSExplainResult
|
|
231
|
+
*
|
|
232
|
+
* @example
|
|
233
|
+
* ```typescript
|
|
234
|
+
* @Explain("/:path*")
|
|
235
|
+
* async explainPath(ctx: RouteContext<{ path?: string }>) {
|
|
236
|
+
* return { data: { content: "...", format: "markdown" } };
|
|
237
|
+
* }
|
|
238
|
+
* ```
|
|
239
|
+
*/
|
|
240
|
+
const Explain = createRouteDecorator("explain");
|
|
241
|
+
/**
|
|
242
|
+
* @Rename decorator - handles rename operations
|
|
243
|
+
* Handler should return: AFSRenameResult
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* @Rename("/:path*")
|
|
248
|
+
* async renamePath(ctx: RouteContext<{ path?: string }>, newPath: string) {
|
|
249
|
+
* return { message: "Renamed successfully" };
|
|
250
|
+
* }
|
|
251
|
+
* ```
|
|
252
|
+
*/
|
|
253
|
+
const Rename = createRouteDecorator("rename");
|
|
254
|
+
|
|
255
|
+
//#endregion
|
|
256
|
+
exports.Actions = Actions;
|
|
257
|
+
exports.Delete = Delete;
|
|
258
|
+
exports.Exec = Exec;
|
|
259
|
+
exports.Explain = Explain;
|
|
260
|
+
exports.List = List;
|
|
261
|
+
exports.Meta = Meta;
|
|
262
|
+
exports.Read = Read;
|
|
263
|
+
exports.Rename = Rename;
|
|
264
|
+
exports.Search = Search;
|
|
265
|
+
exports.Stat = Stat;
|
|
266
|
+
exports.Write = Write;
|
|
267
|
+
exports.clearRoutes = clearRoutes;
|
|
268
|
+
exports.getRoutes = getRoutes;
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
import { ListDecoratorOptions, RouteMetadata } from "./types.cjs";
|
|
2
|
+
|
|
3
|
+
//#region src/provider/decorators.d.ts
|
|
4
|
+
type Constructor = Function;
|
|
5
|
+
/**
|
|
6
|
+
* Get all registered routes for a class (including inherited routes)
|
|
7
|
+
*/
|
|
8
|
+
declare function getRoutes(ctor: Constructor): RouteMetadata[];
|
|
9
|
+
/**
|
|
10
|
+
* Clear routes for a class (mainly for testing)
|
|
11
|
+
*/
|
|
12
|
+
declare function clearRoutes(ctor: Constructor): void;
|
|
13
|
+
/**
|
|
14
|
+
* @List decorator - handles list operations
|
|
15
|
+
* Handler should return: { data: AFSEntry[], total?: number }
|
|
16
|
+
*
|
|
17
|
+
* @param pattern - Route pattern to match
|
|
18
|
+
* @param optionsOrDescription - Either a description string or ListDecoratorOptions
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```typescript
|
|
22
|
+
* // Simple usage
|
|
23
|
+
* @List("/:table")
|
|
24
|
+
* async listRows(ctx: RouteContext<{ table: string }>) {
|
|
25
|
+
* return { data: rows, total: 100 };
|
|
26
|
+
* }
|
|
27
|
+
*
|
|
28
|
+
* // Default behavior - base provider handles depth via BFS
|
|
29
|
+
* @List("/**")
|
|
30
|
+
* async listDir(ctx: RouteContext) {
|
|
31
|
+
* // Only need to return single-level results
|
|
32
|
+
* return { data: entries };
|
|
33
|
+
* }
|
|
34
|
+
*
|
|
35
|
+
* // Handler manages depth itself (opt-in for special cases like S3)
|
|
36
|
+
* @List("/**", { handleDepth: true })
|
|
37
|
+
* async listDirWithDepth(ctx: RouteContext) {
|
|
38
|
+
* // Handler implements maxDepth logic
|
|
39
|
+
* return { data: entries };
|
|
40
|
+
* }
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function List(pattern: string, optionsOrDescription?: string | ListDecoratorOptions): MethodDecorator;
|
|
44
|
+
/**
|
|
45
|
+
* @Read decorator - handles read operations
|
|
46
|
+
* Handler should return: AFSEntry
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* @Read("/:table/:pk")
|
|
51
|
+
* async getRow(ctx: RouteContext<{ table: string; pk: string }>) {
|
|
52
|
+
* return { id: pk, path: ctx.path, content: row };
|
|
53
|
+
* }
|
|
54
|
+
* ```
|
|
55
|
+
*/
|
|
56
|
+
declare const Read: (pattern: string, description?: string) => MethodDecorator;
|
|
57
|
+
/**
|
|
58
|
+
* @Write decorator - handles write operations
|
|
59
|
+
* Handler should return: AFSWriteResult
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* @Write("/:table/:pk")
|
|
64
|
+
* async updateRow(ctx: RouteContext, content: AFSWriteEntryPayload) {
|
|
65
|
+
* return { data: updatedEntry };
|
|
66
|
+
* }
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
declare const Write: (pattern: string, description?: string) => MethodDecorator;
|
|
70
|
+
/**
|
|
71
|
+
* @Delete decorator - handles delete operations
|
|
72
|
+
* Handler should return: AFSDeleteResult
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* ```typescript
|
|
76
|
+
* @Delete("/:table/:pk")
|
|
77
|
+
* async deleteRow(ctx: RouteContext<{ table: string; pk: string }>) {
|
|
78
|
+
* return { message: "Deleted" };
|
|
79
|
+
* }
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
declare const Delete: (pattern: string, description?: string) => MethodDecorator;
|
|
83
|
+
/**
|
|
84
|
+
* @Exec decorator - handles exec operations
|
|
85
|
+
* Handler should return: AFSExecResult
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* @Exec("/:table/:pk/.actions/:action")
|
|
90
|
+
* async executeAction(ctx: RouteContext, args: Record<string, unknown>) {
|
|
91
|
+
* return { data: { success: true } };
|
|
92
|
+
* }
|
|
93
|
+
* ```
|
|
94
|
+
*/
|
|
95
|
+
declare const Exec: (pattern: string, description?: string) => MethodDecorator;
|
|
96
|
+
/**
|
|
97
|
+
* @Search decorator - handles search operations
|
|
98
|
+
* Handler should return: AFSSearchResult
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* ```typescript
|
|
102
|
+
* @Search("/:table")
|
|
103
|
+
* async searchTable(ctx: RouteContext, query: string, options?: AFSSearchOptions) {
|
|
104
|
+
* return { data: matchingEntries };
|
|
105
|
+
* }
|
|
106
|
+
* ```
|
|
107
|
+
*/
|
|
108
|
+
declare const Search: (pattern: string, description?: string) => MethodDecorator;
|
|
109
|
+
/**
|
|
110
|
+
* @Meta decorator - handles .meta path reads (introspection only, read-only)
|
|
111
|
+
* Automatically appends /.meta to the pattern
|
|
112
|
+
* Handler should return: AFSEntry
|
|
113
|
+
*
|
|
114
|
+
* Note: Meta is read-only. To write metadata, use @Write handler with payload.meta.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```typescript
|
|
118
|
+
* @Meta("/:table/:pk") // Registers as /:table/:pk/.meta
|
|
119
|
+
* async getRowMeta(ctx: RouteContext<{ table: string; pk: string }>) {
|
|
120
|
+
* return { id: "meta", path: `${ctx.path}/.meta`, content: schema };
|
|
121
|
+
* }
|
|
122
|
+
*
|
|
123
|
+
* @Meta("/") // Registers as /.meta (root metadata)
|
|
124
|
+
* async getRootMeta(ctx: RouteContext) {
|
|
125
|
+
* return { id: "meta", path: "/.meta", content: rootSchema };
|
|
126
|
+
* }
|
|
127
|
+
* ```
|
|
128
|
+
*/
|
|
129
|
+
declare function Meta(pattern: string, description?: string): MethodDecorator;
|
|
130
|
+
/**
|
|
131
|
+
* Actions decorator interface - callable function with Execute method
|
|
132
|
+
*/
|
|
133
|
+
interface ActionsDecorator {
|
|
134
|
+
/**
|
|
135
|
+
* @Actions decorator - handles .actions path listing
|
|
136
|
+
* Automatically appends /.actions to the pattern
|
|
137
|
+
* Handler should return: { data: AFSEntry[] }
|
|
138
|
+
*
|
|
139
|
+
* @param pattern - Base path pattern for the node
|
|
140
|
+
* @param description - Optional description for the route
|
|
141
|
+
*
|
|
142
|
+
* @example
|
|
143
|
+
* ```typescript
|
|
144
|
+
* @Actions("/:table/:pk") // Registers as /:table/:pk/.actions
|
|
145
|
+
* async listRowActions(ctx: RouteContext<{ table: string; pk: string }>) {
|
|
146
|
+
* return { data: availableActions };
|
|
147
|
+
* }
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
(pattern: string, description?: string): MethodDecorator;
|
|
151
|
+
/**
|
|
152
|
+
* @Actions.Exec decorator - handles action execution on nodes
|
|
153
|
+
* Automatically constructs the full .actions path for action execution.
|
|
154
|
+
* Handler should return: AFSExecResult
|
|
155
|
+
*
|
|
156
|
+
* @param pattern - Base path pattern for the node (e.g., "/issues/:number")
|
|
157
|
+
* @param actionName - Optional specific action name. If omitted, registers catch-all pattern.
|
|
158
|
+
* @param description - Optional description for the route
|
|
159
|
+
*
|
|
160
|
+
* @example
|
|
161
|
+
* ```typescript
|
|
162
|
+
* // Specific action - registers as /issues/:number/.actions/close
|
|
163
|
+
* @Actions.Exec("/issues/:number", "close")
|
|
164
|
+
* async closeIssue(ctx: RouteContext<{ number: string }>, args: Record<string, unknown>) {
|
|
165
|
+
* return { data: { success: true } };
|
|
166
|
+
* }
|
|
167
|
+
*
|
|
168
|
+
* // Catch-all action - registers as /issues/:number/.actions/:action
|
|
169
|
+
* @Actions.Exec("/issues/:number")
|
|
170
|
+
* async handleIssueAction(ctx: RouteContext<{ number: string; action: string }>, args: Record<string, unknown>) {
|
|
171
|
+
* return { data: { action: ctx.params.action } };
|
|
172
|
+
* }
|
|
173
|
+
*
|
|
174
|
+
* // Root-level action - registers as /.actions/refresh
|
|
175
|
+
* @Actions.Exec("/", "refresh")
|
|
176
|
+
* async refreshAll(ctx: RouteContext, args: Record<string, unknown>) {
|
|
177
|
+
* return { data: { refreshed: true } };
|
|
178
|
+
* }
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
Exec: (pattern: string, actionName?: string, description?: string) => MethodDecorator;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* @Actions decorator - handles action-related routes
|
|
185
|
+
*
|
|
186
|
+
* Use directly for listing actions:
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* @Actions("/:table/:pk") // Registers as /:table/:pk/.actions
|
|
190
|
+
* async listRowActions(ctx: RouteContext<{ table: string; pk: string }>) {
|
|
191
|
+
* return { data: availableActions };
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
*
|
|
195
|
+
* Use Actions.Exec for action execution:
|
|
196
|
+
* @example
|
|
197
|
+
* ```typescript
|
|
198
|
+
* @Actions.Exec("/:table/:pk", "close")
|
|
199
|
+
* async closeAction(ctx: RouteContext, args: Record<string, unknown>) { ... }
|
|
200
|
+
* ```
|
|
201
|
+
*/
|
|
202
|
+
declare const Actions: ActionsDecorator;
|
|
203
|
+
/**
|
|
204
|
+
* @Stat decorator - handles stat operations
|
|
205
|
+
* Handler should return: AFSStatResult
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```typescript
|
|
209
|
+
* @Stat("/:path*")
|
|
210
|
+
* async statPath(ctx: RouteContext<{ path?: string }>) {
|
|
211
|
+
* return { data: { path: ctx.path, size: 100, modified: new Date() } };
|
|
212
|
+
* }
|
|
213
|
+
* ```
|
|
214
|
+
*/
|
|
215
|
+
declare const Stat: (pattern: string, description?: string) => MethodDecorator;
|
|
216
|
+
/**
|
|
217
|
+
* @Explain decorator - handles explain operations
|
|
218
|
+
* Handler should return: AFSExplainResult
|
|
219
|
+
*
|
|
220
|
+
* @example
|
|
221
|
+
* ```typescript
|
|
222
|
+
* @Explain("/:path*")
|
|
223
|
+
* async explainPath(ctx: RouteContext<{ path?: string }>) {
|
|
224
|
+
* return { data: { content: "...", format: "markdown" } };
|
|
225
|
+
* }
|
|
226
|
+
* ```
|
|
227
|
+
*/
|
|
228
|
+
declare const Explain: (pattern: string, description?: string) => MethodDecorator;
|
|
229
|
+
/**
|
|
230
|
+
* @Rename decorator - handles rename operations
|
|
231
|
+
* Handler should return: AFSRenameResult
|
|
232
|
+
*
|
|
233
|
+
* @example
|
|
234
|
+
* ```typescript
|
|
235
|
+
* @Rename("/:path*")
|
|
236
|
+
* async renamePath(ctx: RouteContext<{ path?: string }>, newPath: string) {
|
|
237
|
+
* return { message: "Renamed successfully" };
|
|
238
|
+
* }
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
241
|
+
declare const Rename: (pattern: string, description?: string) => MethodDecorator;
|
|
242
|
+
//#endregion
|
|
243
|
+
export { Actions, Delete, Exec, Explain, List, Meta, Read, Rename, Search, Stat, Write, clearRoutes, getRoutes };
|
|
244
|
+
//# sourceMappingURL=decorators.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"decorators.d.cts","names":[],"sources":["../../src/provider/decorators.ts"],"mappings":";;;KAGK,WAAA,GAAc,QAAA;;AAHmE;;iBAetE,SAAA,CAAU,IAAA,EAAM,WAAA,GAAc,aAAA;;;AAA9C;iBAoBgB,WAAA,CAAY,IAAA,EAAM,WAAA;;;;;;;;AAAlC;;;;;AA6DA;;;;;;;;;;AAwBA;;;;;;;;iBAxBgB,IAAA,CACd,OAAA,UACA,oBAAA,YAAgC,oBAAA,GAC/B,eAAA;AAmCH;;;;;;;;;AAcA;;;AAdA,cAda,IAAA,GAAI,OAAA,UA7DQ,WAAA,cAAyB,eAAA;;;;;;AAuGlD;;;;;;;cA5Ba,KAAA,GAAK,OAAA,UA3EO,WAAA,cAAyB,eAAA;;AAqHlD;;;;;;;;;AAsBA;;cAlDa,MAAA,GAAM,OAAA,UAzFM,WAAA,cAAyB,eAAA;;;;;;;AA+IjD;;;;;;cAxCY,IAAA,GAAI,OAAA,UAvGQ,WAAA,cAAyB,eAAA;;;;;;;;AAkPlD;;;;;cA7Ha,MAAA,GAAM,OAAA,UArHM,WAAA,cAAyB,eAAA;;;;;;;;;AAuRlD;;;;;;;;;AAcA;;;iBA1JgB,IAAA,CAAK,OAAA,UAAiB,WAAA,YAAuB,eAAA;;;;UAgCnD,gBAAA;EA0H0C;;;;;;;;;;;;;;;;EAAA,CAzGjD,OAAA,UAAiB,WAAA,YAAuB,eAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAgCzC,IAAA,GAAO,OAAA,UAAiB,UAAA,WAAqB,WAAA,cAAyB,eAAA;AAAA;;;;;;;;;;;;;;;;;;;;cAsB3D,OAAA,EAAS,gBAAA;;;;;;;;;;;;;cAuBT,IAAA,GAAI,OAAA,UAzQQ,WAAA,cAAyB,eAAA;;;;;;;;;;;;;cAuRrC,OAAA,GAAO,OAAA,UAvRK,WAAA,cAAyB,eAAA;;;;;;;;;;;;;cAqSrC,MAAA,GAAM,OAAA,UArSM,WAAA,cAAyB,eAAA"}
|