chadstart 1.0.0
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/.dockerignore +10 -0
- package/.env.example +46 -0
- package/.github/workflows/browser-test.yml +34 -0
- package/.github/workflows/docker-publish.yml +54 -0
- package/.github/workflows/docs.yml +31 -0
- package/.github/workflows/npm-chadstart.yml +27 -0
- package/.github/workflows/npm-sdk.yml +38 -0
- package/.github/workflows/test.yml +85 -0
- package/.weblate +9 -0
- package/Dockerfile +23 -0
- package/README.md +348 -0
- package/admin/index.html +2802 -0
- package/admin/login.html +207 -0
- package/chadstart.example.yml +416 -0
- package/chadstart.schema.json +367 -0
- package/chadstart.yaml +53 -0
- package/cli/cli.js +295 -0
- package/core/api-generator.js +606 -0
- package/core/auth.js +298 -0
- package/core/db.js +384 -0
- package/core/entity-engine.js +166 -0
- package/core/error-reporter.js +132 -0
- package/core/file-storage.js +97 -0
- package/core/functions-engine.js +353 -0
- package/core/openapi.js +171 -0
- package/core/plugin-loader.js +92 -0
- package/core/realtime.js +93 -0
- package/core/schema-validator.js +50 -0
- package/core/seeder.js +231 -0
- package/core/telemetry.js +119 -0
- package/core/upload.js +372 -0
- package/core/workers/php_worker.php +19 -0
- package/core/workers/python_worker.py +33 -0
- package/core/workers/ruby_worker.rb +21 -0
- package/core/yaml-loader.js +64 -0
- package/demo/chadstart.yaml +178 -0
- package/demo/docker-compose.yml +31 -0
- package/demo/functions/greet.go +39 -0
- package/demo/functions/hello.cpp +18 -0
- package/demo/functions/hello.py +13 -0
- package/demo/functions/hello.rb +10 -0
- package/demo/functions/onTodoCreated.js +13 -0
- package/demo/functions/ping.sh +13 -0
- package/demo/functions/stats.js +22 -0
- package/demo/public/index.html +522 -0
- package/docker-compose.yml +17 -0
- package/docs/access-policies.md +155 -0
- package/docs/admin-ui.md +29 -0
- package/docs/angular.md +69 -0
- package/docs/astro.md +71 -0
- package/docs/auth.md +160 -0
- package/docs/cli.md +56 -0
- package/docs/config.md +127 -0
- package/docs/crud.md +627 -0
- package/docs/deploy.md +113 -0
- package/docs/docker.md +59 -0
- package/docs/entities.md +385 -0
- package/docs/functions.md +196 -0
- package/docs/getting-started.md +79 -0
- package/docs/groups.md +85 -0
- package/docs/index.md +5 -0
- package/docs/llm-rules.md +81 -0
- package/docs/middlewares.md +78 -0
- package/docs/overrides/home.html +350 -0
- package/docs/plugins.md +59 -0
- package/docs/react.md +75 -0
- package/docs/realtime.md +43 -0
- package/docs/s3-storage.md +40 -0
- package/docs/security.md +23 -0
- package/docs/stylesheets/extra.css +375 -0
- package/docs/svelte.md +71 -0
- package/docs/telemetry.md +97 -0
- package/docs/upload.md +168 -0
- package/docs/validation.md +115 -0
- package/docs/vue.md +86 -0
- package/docs/webhooks.md +87 -0
- package/index.js +11 -0
- package/locales/en/admin.json +169 -0
- package/mkdocs.yml +82 -0
- package/package.json +65 -0
- package/playwright.config.js +24 -0
- package/public/.gitkeep +0 -0
- package/sdk/README.md +284 -0
- package/sdk/package.json +39 -0
- package/sdk/scripts/build.js +58 -0
- package/sdk/src/index.js +368 -0
- package/sdk/test/sdk.test.cjs +340 -0
- package/sdk/types/index.d.ts +217 -0
- package/server/express-server.js +734 -0
- package/test/access-policies.test.js +96 -0
- package/test/ai.test.js +81 -0
- package/test/api-keys.test.js +361 -0
- package/test/auth.test.js +122 -0
- package/test/browser/admin-ui.spec.js +127 -0
- package/test/browser/global-setup.js +71 -0
- package/test/browser/global-teardown.js +11 -0
- package/test/db.test.js +227 -0
- package/test/entity-engine.test.js +193 -0
- package/test/error-reporter.test.js +140 -0
- package/test/functions-engine.test.js +240 -0
- package/test/groups.test.js +212 -0
- package/test/hot-reload.test.js +153 -0
- package/test/i18n.test.js +173 -0
- package/test/middleware.test.js +76 -0
- package/test/openapi.test.js +67 -0
- package/test/schema-validator.test.js +83 -0
- package/test/sdk.test.js +90 -0
- package/test/seeder.test.js +279 -0
- package/test/settings.test.js +109 -0
- package/test/telemetry.test.js +254 -0
- package/test/test.js +17 -0
- package/test/upload.test.js +265 -0
- package/test/validation.test.js +96 -0
- package/test/yaml-loader.test.js +93 -0
- package/utils/logger.js +24 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# demo/docker-compose.yml
|
|
2
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
3
|
+
# Run the ChadStart Todo demo with Docker Compose.
|
|
4
|
+
#
|
|
5
|
+
# Usage (from this directory):
|
|
6
|
+
# cp ../.env.example .env # create your .env — at minimum set TOKEN_SECRET_KEY
|
|
7
|
+
# docker compose up --build
|
|
8
|
+
#
|
|
9
|
+
# The build context is the repo root so the image is always built from
|
|
10
|
+
# the current source, keeping the schema and code in sync.
|
|
11
|
+
# ─────────────────────────────────────────────────────────────────────────────
|
|
12
|
+
|
|
13
|
+
services:
|
|
14
|
+
app:
|
|
15
|
+
build:
|
|
16
|
+
context: .. # repo root — Dockerfile lives there
|
|
17
|
+
ports:
|
|
18
|
+
- "3000:3000"
|
|
19
|
+
env_file:
|
|
20
|
+
- path: .env
|
|
21
|
+
required: false # optional — defaults are safe for local dev
|
|
22
|
+
environment:
|
|
23
|
+
NODE_ENV: production
|
|
24
|
+
JWT_SECRET: changeme_asdklanion2iorn1i2n9qjw0m90m129qmd920
|
|
25
|
+
volumes:
|
|
26
|
+
- ./chadstart.yaml:/app/chadstart.yaml:ro
|
|
27
|
+
- ./data:/app/data
|
|
28
|
+
- ./public:/app/public
|
|
29
|
+
- ./uploads:/app/uploads
|
|
30
|
+
- ./functions:/app/functions:ro
|
|
31
|
+
restart: unless-stopped
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// greet.go — ChadStart Go function
|
|
2
|
+
// Returns a greeting from the Go runtime.
|
|
3
|
+
//
|
|
4
|
+
// Runtime: go
|
|
5
|
+
// Trigger: GET /api/fn/greet/go (public)
|
|
6
|
+
//
|
|
7
|
+
// ChadStart passes event JSON via stdin; result must be printed as JSON to stdout.
|
|
8
|
+
|
|
9
|
+
package main
|
|
10
|
+
|
|
11
|
+
import (
|
|
12
|
+
"encoding/json"
|
|
13
|
+
"fmt"
|
|
14
|
+
"os"
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
type Event struct {
|
|
18
|
+
Query map[string]string `json:"query"`
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
func main() {
|
|
22
|
+
var evt Event
|
|
23
|
+
dec := json.NewDecoder(os.Stdin)
|
|
24
|
+
// ignore decode errors — event may be wrapped in {"event":...}
|
|
25
|
+
_ = dec.Decode(&evt)
|
|
26
|
+
|
|
27
|
+
name := "World"
|
|
28
|
+
if evt.Query != nil {
|
|
29
|
+
if n, ok := evt.Query["name"]; ok && n != "" {
|
|
30
|
+
name = n
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
result := map[string]string{
|
|
35
|
+
"message": fmt.Sprintf("Hello, %s!", name),
|
|
36
|
+
"runtime": "go",
|
|
37
|
+
}
|
|
38
|
+
json.NewEncoder(os.Stdout).Encode(result)
|
|
39
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* hello.cpp — ChadStart C++ function
|
|
3
|
+
* Reads the event JSON from stdin and returns a greeting.
|
|
4
|
+
*
|
|
5
|
+
* Runtime: c++
|
|
6
|
+
* Trigger: GET /api/fn/greet/cpp (public)
|
|
7
|
+
*/
|
|
8
|
+
#include <iostream>
|
|
9
|
+
#include <string>
|
|
10
|
+
|
|
11
|
+
int main() {
|
|
12
|
+
// Consume stdin (ChadStart passes the serialized event as JSON)
|
|
13
|
+
std::string line;
|
|
14
|
+
while (std::getline(std::cin, line)) {}
|
|
15
|
+
|
|
16
|
+
std::cout << "{\"message\":\"Hello, World!\",\"runtime\":\"c++\"}" << std::endl;
|
|
17
|
+
return 0;
|
|
18
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# hello.py — ChadStart Python function
|
|
2
|
+
# Returns a greeting from the Python runtime.
|
|
3
|
+
#
|
|
4
|
+
# Runtime: python
|
|
5
|
+
# Trigger: GET /api/fn/greet/python (public)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
def handler(event, ctx):
|
|
9
|
+
name = (event.get("query") or {}).get("name", "World")
|
|
10
|
+
return {
|
|
11
|
+
"message": f"Hello, {name}!",
|
|
12
|
+
"runtime": "python",
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# hello.rb — ChadStart Ruby function
|
|
2
|
+
# Returns a greeting from the Ruby runtime.
|
|
3
|
+
#
|
|
4
|
+
# Runtime: ruby
|
|
5
|
+
# Trigger: GET /api/fn/greet/ruby (public)
|
|
6
|
+
|
|
7
|
+
def handler(event, ctx)
|
|
8
|
+
name = ((event['query'] || {})['name'] || 'World')
|
|
9
|
+
{ 'message' => "Hello, #{name}!", 'runtime' => 'ruby' }
|
|
10
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* onTodoCreated.js — ChadStart JS event-triggered function
|
|
4
|
+
* Fires when a new Todo is created (event: todo.created).
|
|
5
|
+
*
|
|
6
|
+
* Runtime: js
|
|
7
|
+
* Trigger: event — todo.created
|
|
8
|
+
*/
|
|
9
|
+
module.exports = async function handler(event, ctx) {
|
|
10
|
+
const todo = event.data || event;
|
|
11
|
+
console.log(`[todo.created] New todo: "${todo.title}" (id: ${todo.id})`);
|
|
12
|
+
return { received: true, todoId: todo.id };
|
|
13
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# ping.sh — ChadStart Bash function
|
|
3
|
+
# Returns a simple pong response.
|
|
4
|
+
#
|
|
5
|
+
# Runtime: bash
|
|
6
|
+
# Trigger: GET /api/fn/ping (public)
|
|
7
|
+
# cron: @hourly
|
|
8
|
+
|
|
9
|
+
set -euo pipefail
|
|
10
|
+
|
|
11
|
+
# ChadStart passes event JSON via stdin (or first arg).
|
|
12
|
+
# For a ping we ignore the input and return JSON on stdout.
|
|
13
|
+
echo '{"pong":true,"runtime":"bash","ts":"'"$(date -u +%Y-%m-%dT%H:%M:%SZ)"'"}'
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
/**
|
|
3
|
+
* stats.js — ChadStart JS function
|
|
4
|
+
* Returns todo statistics: total, completed, and pending counts.
|
|
5
|
+
*
|
|
6
|
+
* Runtime: js (default)
|
|
7
|
+
* Trigger: GET /api/fn/stats (public)
|
|
8
|
+
*/
|
|
9
|
+
module.exports = async function handler(event, ctx) {
|
|
10
|
+
const { chadstart } = ctx;
|
|
11
|
+
if (!chadstart) {
|
|
12
|
+
return { total: 0, completed: 0, pending: 0 };
|
|
13
|
+
}
|
|
14
|
+
// Use perPage:1 so we only fetch counts from the DB — no row data transferred.
|
|
15
|
+
const [all, done] = await Promise.all([
|
|
16
|
+
chadstart.todos.findAll({ perPage: 1 }),
|
|
17
|
+
chadstart.todos.findAll({ completed: true, perPage: 1 }),
|
|
18
|
+
]);
|
|
19
|
+
const total = all.total ?? 0;
|
|
20
|
+
const completed = done.total ?? 0;
|
|
21
|
+
return { total, completed, pending: total - completed };
|
|
22
|
+
};
|