u
This commit is contained in:
@@ -72,10 +72,17 @@ export function register(app, basePath = '') {
|
||||
*
|
||||
* The applet file must begin with two metadata lines:
|
||||
* `// @applet-input-schema {JSON Schema}` followed by
|
||||
* `// @applet-output-schema {JSON Schema}`. The file exports a function that receives the posted `input`
|
||||
* as `applet_input`, and execution runs in the same isolated worker sandbox as the `javascript_execute`
|
||||
* tool — including authenticated `fetch()` against this API, `fs`/`vfs`, `sharp`, ExcelJS, PDFKit and
|
||||
* WebCrypto globals.
|
||||
* `// @applet-output-schema {name:type;name:type}`. The input schema describes the GUI form posted as
|
||||
* `input`. The output line declares the RESULT COLUMNS as typed CSV — `name:type` pairs separated by `;`
|
||||
* (e.g. `id:integer;name:string;active:boolean`); allowed types are `string`, `integer`, `number`,
|
||||
* `boolean` and `date`. The applet exports a function that receives the posted `input` as `applet_input`
|
||||
* and returns a row object (or an array of row objects) keyed by those columns.
|
||||
*
|
||||
* Applets return typed CSV, not JSON: `result` is a `;`-separated CSV string with a header row, and the
|
||||
* response also carries `columns` (name/type) and `rows` (data row count). Only declared columns are
|
||||
* emitted, in header order; missing values become empty cells. Execution runs in the same isolated worker
|
||||
* sandbox as the `javascript_execute` tool — including authenticated `fetch()` against this API,
|
||||
* `fs`/`vfs`, `sharp`, ExcelJS, PDFKit and WebCrypto globals.
|
||||
*
|
||||
* The path is taken from the URL (like `DELETE /vfs/{*path}`); the run arguments are the JSON body.
|
||||
* Path traversal (`..`), null bytes, and backslashes are rejected with HTTP 400, as is a path that does
|
||||
@@ -115,13 +122,34 @@ export function register(app, basePath = '') {
|
||||
* application/json:
|
||||
* schema:
|
||||
* type: object
|
||||
* required: [ok, result, stdout, consoleLines, durationMs]
|
||||
* required: [ok, result, columns, rows, stdout, consoleLines, durationMs]
|
||||
* properties:
|
||||
* ok:
|
||||
* type: boolean
|
||||
* result:
|
||||
* description: The value returned by the applet's exported function
|
||||
* nullable: true
|
||||
* type: string
|
||||
* description: Typed CSV table (`;`-separated, header row first) built from the returned rows and the declared output columns
|
||||
* example: "id;name\n1;Kaffee"
|
||||
* columns:
|
||||
* type: array
|
||||
* description: Declared output columns, in header order
|
||||
* items:
|
||||
* type: object
|
||||
* required: [name, type]
|
||||
* properties:
|
||||
* name:
|
||||
* type: string
|
||||
* type:
|
||||
* type: string
|
||||
* enum: [string, integer, number, boolean, date]
|
||||
* rows:
|
||||
* type: integer
|
||||
* description: Number of data rows in `result` (excludes the header row)
|
||||
* warnings:
|
||||
* type: array
|
||||
* description: Present when cells were dropped for not matching their declared type
|
||||
* items:
|
||||
* type: string
|
||||
* stdout:
|
||||
* type: string
|
||||
* description: Captured console output
|
||||
|
||||
Reference in New Issue
Block a user