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
package/.dockerignore
ADDED
package/.env.example
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# Copy this file to .env and fill in the values
|
|
2
|
+
|
|
3
|
+
# General
|
|
4
|
+
# TOKEN_SECRET_KEY (or JWT_SECRET) is required in production
|
|
5
|
+
TOKEN_SECRET_KEY=replace-with-a-long-random-secret
|
|
6
|
+
# JWT_SECRET=replace-with-a-long-random-secret # alias for TOKEN_SECRET_KEY
|
|
7
|
+
# NODE_ENV=production
|
|
8
|
+
# PORT=3000
|
|
9
|
+
# BASE_URL=http://localhost:3000
|
|
10
|
+
# OPEN_API_DOCS=true
|
|
11
|
+
|
|
12
|
+
# Paths
|
|
13
|
+
# CHADSTART_FILE_PATH=chadstart.yaml
|
|
14
|
+
# CHADSTART_FUNCTIONS_FOLDER=functions
|
|
15
|
+
|
|
16
|
+
# Database (SQLite default)
|
|
17
|
+
# DB_PATH=data/chadstart.db
|
|
18
|
+
|
|
19
|
+
# Optional: S3-compatible storage (when set, files are stored in S3 instead of the local filesystem)
|
|
20
|
+
# S3_BUCKET=my-bucket-name
|
|
21
|
+
# S3_ENDPOINT=https://your-s3-provider.com
|
|
22
|
+
# S3_REGION=XXX
|
|
23
|
+
# S3_ACCESS_KEY_ID=XXX
|
|
24
|
+
# S3_SECRET_ACCESS_KEY=XXX
|
|
25
|
+
# S3_FOLDER_PREFIX=development/chadstart # Optional folder prefix prepended to every object path
|
|
26
|
+
|
|
27
|
+
# Optional: AI assistant (set ONE of the following to enable the AI chat button in the Admin UI)
|
|
28
|
+
# OPENAI_API_KEY=sk-...
|
|
29
|
+
# ANTHROPIC_API_KEY=sk-ant-...
|
|
30
|
+
# GOOGLE_API_KEY=... # Google Gemini
|
|
31
|
+
# GEMINI_API_KEY=... # alias for GOOGLE_API_KEY
|
|
32
|
+
# OPENROUTER_API_KEY=sk-or-...
|
|
33
|
+
|
|
34
|
+
# Optional: OpenTelemetry tracing
|
|
35
|
+
# Non-secret values can also be set in chadstart.yaml under settings.telemetry
|
|
36
|
+
# OTEL_ENABLED=true
|
|
37
|
+
# OTEL_SERVICE_NAME=my-app
|
|
38
|
+
# OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
|
|
39
|
+
# OTEL_EXPORTER_OTLP_HEADERS=authorization=Bearer <token> # Secrets — env var only, never in YAML
|
|
40
|
+
|
|
41
|
+
# Error Reporting — Sentry / Bugsink
|
|
42
|
+
# Set SENTRY_DSN to enable automatic error reporting.
|
|
43
|
+
# The DSN is a secret; keep it here in .env and never commit it to source control.
|
|
44
|
+
# 💡 Bugsink (https://www.bugsink.com) is a self-hosted alternative to Sentry
|
|
45
|
+
# that uses the same Sentry SDK — just point SENTRY_DSN at your Bugsink instance.
|
|
46
|
+
# SENTRY_DSN=https://xxxxx@oXXXXX.ingest.sentry.io/XXXXXXX
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
name: Browser Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
paths:
|
|
6
|
+
- 'admin/index.html'
|
|
7
|
+
push:
|
|
8
|
+
paths:
|
|
9
|
+
- 'admin/index.html'
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
browser-test:
|
|
13
|
+
runs-on: ubuntu-latest
|
|
14
|
+
permissions:
|
|
15
|
+
contents: read
|
|
16
|
+
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout
|
|
19
|
+
uses: actions/checkout@v4
|
|
20
|
+
|
|
21
|
+
- name: Set up Node.js
|
|
22
|
+
uses: actions/setup-node@v4
|
|
23
|
+
with:
|
|
24
|
+
node-version: "lts/*"
|
|
25
|
+
cache: "npm"
|
|
26
|
+
|
|
27
|
+
- name: Install dependencies
|
|
28
|
+
run: npm ci
|
|
29
|
+
|
|
30
|
+
- name: Install Playwright browsers
|
|
31
|
+
run: npx playwright install --with-deps chromium
|
|
32
|
+
|
|
33
|
+
- name: Run browser tests
|
|
34
|
+
run: npm run test:browser
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
name: Publish Docker image
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
tags:
|
|
8
|
+
- "v*"
|
|
9
|
+
|
|
10
|
+
env:
|
|
11
|
+
REGISTRY: ghcr.io
|
|
12
|
+
IMAGE_NAME: ${{ github.repository }}
|
|
13
|
+
|
|
14
|
+
jobs:
|
|
15
|
+
build-and-push:
|
|
16
|
+
runs-on: ubuntu-latest
|
|
17
|
+
permissions:
|
|
18
|
+
contents: read
|
|
19
|
+
packages: write
|
|
20
|
+
|
|
21
|
+
steps:
|
|
22
|
+
- name: Checkout
|
|
23
|
+
uses: actions/checkout@v4
|
|
24
|
+
|
|
25
|
+
- name: Log in to GHCR
|
|
26
|
+
uses: docker/login-action@v3
|
|
27
|
+
with:
|
|
28
|
+
registry: ${{ env.REGISTRY }}
|
|
29
|
+
username: ${{ github.actor }}
|
|
30
|
+
password: ${{ secrets.GITHUB_TOKEN }}
|
|
31
|
+
|
|
32
|
+
- name: Extract metadata
|
|
33
|
+
id: meta
|
|
34
|
+
uses: docker/metadata-action@v5
|
|
35
|
+
with:
|
|
36
|
+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
|
37
|
+
tags: |
|
|
38
|
+
type=ref,event=branch
|
|
39
|
+
type=semver,pattern={{version}}
|
|
40
|
+
type=semver,pattern={{major}}.{{minor}}
|
|
41
|
+
type=raw,value=latest,enable={{is_default_branch}}
|
|
42
|
+
|
|
43
|
+
- name: Set up Docker Buildx
|
|
44
|
+
uses: docker/setup-buildx-action@v3
|
|
45
|
+
|
|
46
|
+
- name: Build and push
|
|
47
|
+
uses: docker/build-push-action@v6
|
|
48
|
+
with:
|
|
49
|
+
context: .
|
|
50
|
+
push: true
|
|
51
|
+
tags: ${{ steps.meta.outputs.tags }}
|
|
52
|
+
labels: ${{ steps.meta.outputs.labels }}
|
|
53
|
+
cache-from: type=gha
|
|
54
|
+
cache-to: type=gha,mode=max
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
name: Deploy Docs to GitHub Pages
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
paths:
|
|
8
|
+
- "docs/**"
|
|
9
|
+
- "mkdocs.yml"
|
|
10
|
+
workflow_dispatch:
|
|
11
|
+
|
|
12
|
+
permissions:
|
|
13
|
+
contents: write
|
|
14
|
+
|
|
15
|
+
jobs:
|
|
16
|
+
deploy:
|
|
17
|
+
runs-on: ubuntu-latest
|
|
18
|
+
steps:
|
|
19
|
+
- name: Checkout
|
|
20
|
+
uses: actions/checkout@v4
|
|
21
|
+
|
|
22
|
+
- name: Set up Python
|
|
23
|
+
uses: actions/setup-python@v5
|
|
24
|
+
with:
|
|
25
|
+
python-version: "3.x"
|
|
26
|
+
|
|
27
|
+
- name: Install MkDocs Material
|
|
28
|
+
run: pip install mkdocs-material
|
|
29
|
+
|
|
30
|
+
- name: Deploy to GitHub Pages
|
|
31
|
+
run: mkdocs gh-deploy --force
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
name: NPM chadstart
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
|
|
7
|
+
jobs:
|
|
8
|
+
publish:
|
|
9
|
+
name: NPM Publish
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
id-token: write # required for npm provenance
|
|
14
|
+
steps:
|
|
15
|
+
- name: Checkout repository
|
|
16
|
+
uses: actions/checkout@v6
|
|
17
|
+
|
|
18
|
+
- name: Set up Node.js
|
|
19
|
+
uses: actions/setup-node@v6
|
|
20
|
+
with:
|
|
21
|
+
node-version: '24'
|
|
22
|
+
registry-url: 'https://registry.npmjs.org'
|
|
23
|
+
|
|
24
|
+
- name: Publish to npm
|
|
25
|
+
run: npm publish --access public --provenance
|
|
26
|
+
env:
|
|
27
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
name: NPM sdk
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
paths:
|
|
7
|
+
- 'sdk/**'
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
publish:
|
|
11
|
+
name: NPM Publish
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
defaults:
|
|
14
|
+
run:
|
|
15
|
+
working-directory: sdk
|
|
16
|
+
permissions:
|
|
17
|
+
contents: read
|
|
18
|
+
id-token: write # required for npm provenance
|
|
19
|
+
steps:
|
|
20
|
+
- name: Checkout repository
|
|
21
|
+
uses: actions/checkout@v6
|
|
22
|
+
|
|
23
|
+
- name: Set up Node.js
|
|
24
|
+
uses: actions/setup-node@v6
|
|
25
|
+
with:
|
|
26
|
+
node-version: '24'
|
|
27
|
+
registry-url: 'https://registry.npmjs.org'
|
|
28
|
+
|
|
29
|
+
- name: Build SDK
|
|
30
|
+
run: node scripts/build.js
|
|
31
|
+
|
|
32
|
+
- name: Run SDK tests
|
|
33
|
+
run: node test/sdk.test.cjs
|
|
34
|
+
|
|
35
|
+
- name: Publish to npm
|
|
36
|
+
run: npm publish --access public --provenance
|
|
37
|
+
env:
|
|
38
|
+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
name: Tests
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
pull_request:
|
|
5
|
+
branches:
|
|
6
|
+
- main
|
|
7
|
+
|
|
8
|
+
jobs:
|
|
9
|
+
test:
|
|
10
|
+
runs-on: ubuntu-latest
|
|
11
|
+
permissions:
|
|
12
|
+
contents: read
|
|
13
|
+
pull-requests: write
|
|
14
|
+
|
|
15
|
+
steps:
|
|
16
|
+
- name: Checkout
|
|
17
|
+
uses: actions/checkout@v4
|
|
18
|
+
|
|
19
|
+
- name: Set up Node.js
|
|
20
|
+
uses: actions/setup-node@v4
|
|
21
|
+
with:
|
|
22
|
+
node-version: "lts/*"
|
|
23
|
+
cache: "npm"
|
|
24
|
+
|
|
25
|
+
- name: Install dependencies
|
|
26
|
+
run: npm ci
|
|
27
|
+
|
|
28
|
+
- name: Run tests with coverage
|
|
29
|
+
id: coverage
|
|
30
|
+
run: npm run test:coverage
|
|
31
|
+
|
|
32
|
+
- name: Post coverage comment
|
|
33
|
+
if: always()
|
|
34
|
+
uses: actions/github-script@v7
|
|
35
|
+
with:
|
|
36
|
+
script: |
|
|
37
|
+
const fs = require('fs');
|
|
38
|
+
const path = require('path');
|
|
39
|
+
|
|
40
|
+
let body = '';
|
|
41
|
+
|
|
42
|
+
// Read c8 JSON summary if available
|
|
43
|
+
const summaryPath = path.join(process.env.GITHUB_WORKSPACE, 'coverage', 'coverage-summary.json');
|
|
44
|
+
if (fs.existsSync(summaryPath)) {
|
|
45
|
+
const summary = JSON.parse(fs.readFileSync(summaryPath, 'utf8')).total;
|
|
46
|
+
const fmt = (v) => `${v.pct}% (${v.covered}/${v.total})`;
|
|
47
|
+
body = [
|
|
48
|
+
'## 🧪 Test Coverage Report',
|
|
49
|
+
'',
|
|
50
|
+
'| Category | Coverage |',
|
|
51
|
+
'|-------------|----------|',
|
|
52
|
+
`| Statements | ${fmt(summary.statements)} |`,
|
|
53
|
+
`| Branches | ${fmt(summary.branches)} |`,
|
|
54
|
+
`| Functions | ${fmt(summary.functions)} |`,
|
|
55
|
+
`| Lines | ${fmt(summary.lines)} |`,
|
|
56
|
+
].join('\n');
|
|
57
|
+
} else {
|
|
58
|
+
body = '## 🧪 Test Coverage Report\n\nCoverage data not available.';
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
const { data: comments } = await github.rest.issues.listComments({
|
|
62
|
+
owner: context.repo.owner,
|
|
63
|
+
repo: context.repo.repo,
|
|
64
|
+
issue_number: context.issue.number,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const existing = comments.find(c =>
|
|
68
|
+
c.user.type === 'Bot' && c.body.startsWith('## 🧪 Test Coverage Report')
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
if (existing) {
|
|
72
|
+
await github.rest.issues.updateComment({
|
|
73
|
+
owner: context.repo.owner,
|
|
74
|
+
repo: context.repo.repo,
|
|
75
|
+
comment_id: existing.id,
|
|
76
|
+
body,
|
|
77
|
+
});
|
|
78
|
+
} else {
|
|
79
|
+
await github.rest.issues.createComment({
|
|
80
|
+
owner: context.repo.owner,
|
|
81
|
+
repo: context.repo.repo,
|
|
82
|
+
issue_number: context.issue.number,
|
|
83
|
+
body,
|
|
84
|
+
});
|
|
85
|
+
}
|
package/.weblate
ADDED
package/Dockerfile
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Stage 1: Install production dependencies (requires build tools for native modules)
|
|
2
|
+
FROM node:lts-alpine AS deps
|
|
3
|
+
WORKDIR /app
|
|
4
|
+
RUN apk add --no-cache make g++
|
|
5
|
+
COPY package*.json ./
|
|
6
|
+
RUN npm ci --omit=dev
|
|
7
|
+
|
|
8
|
+
# Stage 2: Production image
|
|
9
|
+
FROM node:lts-alpine AS runner
|
|
10
|
+
WORKDIR /app
|
|
11
|
+
# Runtime dependencies
|
|
12
|
+
RUN apk add --no-cache bash python3 go ruby g++ \
|
|
13
|
+
&& addgroup -S nodejs && adduser -S nodejs -G nodejs \
|
|
14
|
+
&& mkdir -p /app/{uploads,public,functions} && chown -R nodejs:nodejs /app
|
|
15
|
+
COPY --from=deps --chown=nodejs:nodejs /app/node_modules ./node_modules
|
|
16
|
+
COPY --chown=nodejs:nodejs . .
|
|
17
|
+
|
|
18
|
+
USER nodejs
|
|
19
|
+
EXPOSE 3000
|
|
20
|
+
HEALTHCHECK --interval=30s --timeout=5s --start-period=10s --retries=3 \
|
|
21
|
+
CMD node -e "fetch('http://localhost:3000/health').then(r=>process.exit(r.ok?0:1)).catch(()=>process.exit(1))"
|
|
22
|
+
|
|
23
|
+
CMD ["node", "cli/cli.js", "start"]
|