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.
Files changed (115) hide show
  1. package/.dockerignore +10 -0
  2. package/.env.example +46 -0
  3. package/.github/workflows/browser-test.yml +34 -0
  4. package/.github/workflows/docker-publish.yml +54 -0
  5. package/.github/workflows/docs.yml +31 -0
  6. package/.github/workflows/npm-chadstart.yml +27 -0
  7. package/.github/workflows/npm-sdk.yml +38 -0
  8. package/.github/workflows/test.yml +85 -0
  9. package/.weblate +9 -0
  10. package/Dockerfile +23 -0
  11. package/README.md +348 -0
  12. package/admin/index.html +2802 -0
  13. package/admin/login.html +207 -0
  14. package/chadstart.example.yml +416 -0
  15. package/chadstart.schema.json +367 -0
  16. package/chadstart.yaml +53 -0
  17. package/cli/cli.js +295 -0
  18. package/core/api-generator.js +606 -0
  19. package/core/auth.js +298 -0
  20. package/core/db.js +384 -0
  21. package/core/entity-engine.js +166 -0
  22. package/core/error-reporter.js +132 -0
  23. package/core/file-storage.js +97 -0
  24. package/core/functions-engine.js +353 -0
  25. package/core/openapi.js +171 -0
  26. package/core/plugin-loader.js +92 -0
  27. package/core/realtime.js +93 -0
  28. package/core/schema-validator.js +50 -0
  29. package/core/seeder.js +231 -0
  30. package/core/telemetry.js +119 -0
  31. package/core/upload.js +372 -0
  32. package/core/workers/php_worker.php +19 -0
  33. package/core/workers/python_worker.py +33 -0
  34. package/core/workers/ruby_worker.rb +21 -0
  35. package/core/yaml-loader.js +64 -0
  36. package/demo/chadstart.yaml +178 -0
  37. package/demo/docker-compose.yml +31 -0
  38. package/demo/functions/greet.go +39 -0
  39. package/demo/functions/hello.cpp +18 -0
  40. package/demo/functions/hello.py +13 -0
  41. package/demo/functions/hello.rb +10 -0
  42. package/demo/functions/onTodoCreated.js +13 -0
  43. package/demo/functions/ping.sh +13 -0
  44. package/demo/functions/stats.js +22 -0
  45. package/demo/public/index.html +522 -0
  46. package/docker-compose.yml +17 -0
  47. package/docs/access-policies.md +155 -0
  48. package/docs/admin-ui.md +29 -0
  49. package/docs/angular.md +69 -0
  50. package/docs/astro.md +71 -0
  51. package/docs/auth.md +160 -0
  52. package/docs/cli.md +56 -0
  53. package/docs/config.md +127 -0
  54. package/docs/crud.md +627 -0
  55. package/docs/deploy.md +113 -0
  56. package/docs/docker.md +59 -0
  57. package/docs/entities.md +385 -0
  58. package/docs/functions.md +196 -0
  59. package/docs/getting-started.md +79 -0
  60. package/docs/groups.md +85 -0
  61. package/docs/index.md +5 -0
  62. package/docs/llm-rules.md +81 -0
  63. package/docs/middlewares.md +78 -0
  64. package/docs/overrides/home.html +350 -0
  65. package/docs/plugins.md +59 -0
  66. package/docs/react.md +75 -0
  67. package/docs/realtime.md +43 -0
  68. package/docs/s3-storage.md +40 -0
  69. package/docs/security.md +23 -0
  70. package/docs/stylesheets/extra.css +375 -0
  71. package/docs/svelte.md +71 -0
  72. package/docs/telemetry.md +97 -0
  73. package/docs/upload.md +168 -0
  74. package/docs/validation.md +115 -0
  75. package/docs/vue.md +86 -0
  76. package/docs/webhooks.md +87 -0
  77. package/index.js +11 -0
  78. package/locales/en/admin.json +169 -0
  79. package/mkdocs.yml +82 -0
  80. package/package.json +65 -0
  81. package/playwright.config.js +24 -0
  82. package/public/.gitkeep +0 -0
  83. package/sdk/README.md +284 -0
  84. package/sdk/package.json +39 -0
  85. package/sdk/scripts/build.js +58 -0
  86. package/sdk/src/index.js +368 -0
  87. package/sdk/test/sdk.test.cjs +340 -0
  88. package/sdk/types/index.d.ts +217 -0
  89. package/server/express-server.js +734 -0
  90. package/test/access-policies.test.js +96 -0
  91. package/test/ai.test.js +81 -0
  92. package/test/api-keys.test.js +361 -0
  93. package/test/auth.test.js +122 -0
  94. package/test/browser/admin-ui.spec.js +127 -0
  95. package/test/browser/global-setup.js +71 -0
  96. package/test/browser/global-teardown.js +11 -0
  97. package/test/db.test.js +227 -0
  98. package/test/entity-engine.test.js +193 -0
  99. package/test/error-reporter.test.js +140 -0
  100. package/test/functions-engine.test.js +240 -0
  101. package/test/groups.test.js +212 -0
  102. package/test/hot-reload.test.js +153 -0
  103. package/test/i18n.test.js +173 -0
  104. package/test/middleware.test.js +76 -0
  105. package/test/openapi.test.js +67 -0
  106. package/test/schema-validator.test.js +83 -0
  107. package/test/sdk.test.js +90 -0
  108. package/test/seeder.test.js +279 -0
  109. package/test/settings.test.js +109 -0
  110. package/test/telemetry.test.js +254 -0
  111. package/test/test.js +17 -0
  112. package/test/upload.test.js +265 -0
  113. package/test/validation.test.js +96 -0
  114. package/test/yaml-loader.test.js +93 -0
  115. package/utils/logger.js +24 -0
package/.dockerignore ADDED
@@ -0,0 +1,10 @@
1
+ node_modules
2
+ npm-debug.log
3
+ .git
4
+ .gitignore
5
+ *.db
6
+ *.db-wal
7
+ *.db-shm
8
+ uploads/
9
+ public/
10
+ .chadstart-plugins/
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
@@ -0,0 +1,9 @@
1
+ [weblate]
2
+ project = chadstart
3
+ version = 2
4
+
5
+ [component: admin]
6
+ filemask = locales/*/admin.json
7
+ template = locales/en/admin.json
8
+ file_format = json-nested
9
+ source_language = en
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"]