@codenotch/codenotch.cli 1.0.41 → 1.0.42
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/README.md +78 -28
- package/dist/commands/generate/dbcontext.js +2 -2
- package/dist/commands/generate/dbcontext.js.map +1 -1
- package/dist/commands/generate/index.js +1 -1
- package/dist/commands/project/deploy.js +9 -2
- package/dist/commands/project/deploy.js.map +1 -1
- package/dist/commands/project/inspect.js +65 -1
- package/dist/commands/project/inspect.js.map +1 -1
- package/dist/commands/system/docs.d.ts +2 -0
- package/dist/commands/system/docs.js +57 -0
- package/dist/commands/system/docs.js.map +1 -0
- package/dist/commands/system/index.js +2 -0
- package/dist/commands/system/index.js.map +1 -1
- package/dist/commands/system/read.js +2 -1
- package/dist/commands/system/read.js.map +1 -1
- package/dist/commands/validation/files/ScriptValidator.js +9 -8
- package/dist/commands/validation/files/ScriptValidator.js.map +1 -1
- package/dist/index.js +12 -2
- package/dist/index.js.map +1 -1
- package/dist/utils/DbSchemaUtils.d.ts +16 -10
- package/dist/utils/DbSchemaUtils.js +82 -30
- package/dist/utils/DbSchemaUtils.js.map +1 -1
- package/dist/utils/DocsUtils.d.ts +34 -0
- package/dist/utils/DocsUtils.js +76 -0
- package/dist/utils/DocsUtils.js.map +1 -0
- package/dist/utils/ProcessBundlerUtils.d.ts +103 -0
- package/dist/utils/ProcessBundlerUtils.js +336 -0
- package/dist/utils/ProcessBundlerUtils.js.map +1 -0
- package/dist/utils/ProjectCompilationUtils.d.ts +14 -2
- package/dist/utils/ProjectCompilationUtils.js +75 -3
- package/dist/utils/ProjectCompilationUtils.js.map +1 -1
- package/dist/utils/ProjectGeneratorUtils.d.ts +2 -1
- package/dist/utils/ProjectGeneratorUtils.js +21 -14
- package/dist/utils/ProjectGeneratorUtils.js.map +1 -1
- package/dist/utils/ProjectTemplates.d.ts +2 -2
- package/dist/utils/ProjectTemplates.js +12 -6
- package/dist/utils/ProjectTemplates.js.map +1 -1
- package/dist/utils/ProjectUtils.d.ts +18 -1
- package/dist/utils/ProjectUtils.js +33 -28
- package/dist/utils/ProjectUtils.js.map +1 -1
- package/dist/utils/TemplateUtils.d.ts +28 -0
- package/dist/utils/TemplateUtils.js +95 -3
- package/dist/utils/TemplateUtils.js.map +1 -1
- package/package.json +78 -71
- package/resources/docs/apps.md +109 -0
- package/resources/docs/i18n.md +51 -0
- package/resources/docs/processes.md +87 -0
- package/resources/docs/project.md +101 -0
- package/resources/docs/queries.md +54 -0
- package/resources/docs/tables.md +97 -0
|
@@ -106,22 +106,112 @@ class TemplateUtils {
|
|
|
106
106
|
* Folders of a new project, relative to its root
|
|
107
107
|
*/
|
|
108
108
|
static PROJECT_FOLDERS = ['processes', 'apps', 'documents', 'tables'];
|
|
109
|
+
/**
|
|
110
|
+
* tsconfig.json of a Codenotch project.
|
|
111
|
+
*
|
|
112
|
+
* Its 'include' must cover the generated 'db-schema.d.ts': the declaration merging it carries
|
|
113
|
+
* only applies to files of the same TypeScript program, and without a tsconfig the editor
|
|
114
|
+
* builds an inferred program out of the open files alone, so a d.ts nobody imports would
|
|
115
|
+
* never be loaded and `ctx.tables` would stay untyped.
|
|
116
|
+
*
|
|
117
|
+
* '**' takes the whole workspace, so a folder the developer adds is typed like the rest. A
|
|
118
|
+
* wildcard never walks into 'node_modules' nor into a folder whose name starts with a dot
|
|
119
|
+
* ('.codenotch', '.git', '.vscode', ...), so only the rest has to be listed in 'exclude' -
|
|
120
|
+
* they are named there anyway, as the cli also reads it to know what not to package.
|
|
121
|
+
* 'compiled' holds the process bundles of 'cn project compile': generated .js that would
|
|
122
|
+
* otherwise join the program through allowJs.
|
|
123
|
+
*/
|
|
124
|
+
static createTsConfigJson() {
|
|
125
|
+
return JSON.stringify({
|
|
126
|
+
compilerOptions: BuildUtils_1.default.defaultCompilerOptions(),
|
|
127
|
+
include: ['**/*'],
|
|
128
|
+
exclude: ['node_modules', '.codenotch', 'compiled']
|
|
129
|
+
}, null, 4) + '\n';
|
|
130
|
+
}
|
|
109
131
|
static createGitignore() {
|
|
110
132
|
return [
|
|
111
133
|
'package-lock.json',
|
|
112
134
|
'',
|
|
113
135
|
'# Generated by the cli, regenerate them with the commands of the readme',
|
|
114
136
|
// Anchored with a leading slash: these three only ever sit at the root of the project
|
|
115
|
-
'/db-schema.ts',
|
|
137
|
+
'/db-schema.d.ts',
|
|
116
138
|
'/db-schema.xml',
|
|
117
139
|
'/openapi.json',
|
|
118
140
|
// No slash: a translation file can sit anywhere, and its class is generated next to it
|
|
119
141
|
'*.i18n.ts',
|
|
142
|
+
// Process bundles of 'cn project compile'
|
|
143
|
+
'/compiled',
|
|
120
144
|
'',
|
|
121
145
|
'/.codenotch',
|
|
122
146
|
'/node_modules'
|
|
123
147
|
].join('\n') + '\n';
|
|
124
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* AGENTS.md of a new project: the entry point of AI coding agents (Claude Code reads it
|
|
151
|
+
* through CLAUDE.md). Kept short on purpose: the reference documentation ships with the CLI
|
|
152
|
+
* and is read through 'cn docs <topic>', so it follows the installed CLI instead of being
|
|
153
|
+
* frozen at the version that created the project.
|
|
154
|
+
*/
|
|
155
|
+
static createAgentsMd(projectName, serviceName) {
|
|
156
|
+
return `# Instructions for AI coding agents
|
|
157
|
+
|
|
158
|
+
This is **${projectName}**, a [Codenotch](https://codenotch.com/) project: TypeScript end to
|
|
159
|
+
end, built and deployed on a Codenotch runtime by the \`cn\` CLI (\`npm install -g @codenotch/codenotch.cli\`).
|
|
160
|
+
The website is not up to date — trust \`cn docs\` and the files of this project over it.
|
|
161
|
+
Its service name is \`${serviceName}\` (see \`manifest.json\`): it identifies the project on the
|
|
162
|
+
runtime and is part of its URL — never rename it on your own.
|
|
163
|
+
|
|
164
|
+
## The reference documentation lives in the CLI
|
|
165
|
+
|
|
166
|
+
Run \`cn docs\` to list the topics, and **read the topic before writing a file of that kind** —
|
|
167
|
+
this file does not repeat the reference, and the docs follow the installed CLI version:
|
|
168
|
+
|
|
169
|
+
| Command | Read before touching |
|
|
170
|
+
| --- | --- |
|
|
171
|
+
| \`cn docs project\` | anything — anatomy, manifest, generated files, lifecycle |
|
|
172
|
+
| \`cn docs tables\` | \`tables/*.ts\`, \`documents/*.ts\` (\`defineEntity\`, \`defineDocument\`) |
|
|
173
|
+
| \`cn docs processes\` | \`processes/*.ts\` (\`process({...})\` declarations) |
|
|
174
|
+
| \`cn docs queries\` | \`queries/*.cnql\` |
|
|
175
|
+
| \`cn docs apps\` | \`apps/*.tsx\` and their manifests |
|
|
176
|
+
| \`cn docs i18n\` | \`*.i18n.csv\` |
|
|
177
|
+
|
|
178
|
+
## Rules
|
|
179
|
+
|
|
180
|
+
1. **Never edit generated files**: \`db-schema.xml\`, \`db-schema.d.ts\`, \`openapi.json\`,
|
|
181
|
+
\`*.i18n.ts\`, \`compiled/\`, \`.codenotch/\`. Fix the source they are generated from, then
|
|
182
|
+
regenerate.
|
|
183
|
+
2. **Regenerate after changing sources** — tables or documents:
|
|
184
|
+
\`cn generate dbcontext -f .\`; processes exposing endpoints: \`cn generate openapi -f .\`;
|
|
185
|
+
translations: \`cn generate i18n -f <file>.i18n.csv\`.
|
|
186
|
+
3. **Keep the TODO policy**: where the runtime API is not settled yet (the client-side call of a
|
|
187
|
+
process, the CNQL filter syntax), the sources carry an explicit \`TODO\` comment instead of a
|
|
188
|
+
guess. Never invent those APIs; carry the TODO and tell the user.
|
|
189
|
+
4. **Check your work**: \`cn validate .\` reports hints, warnings and errors of every file, and
|
|
190
|
+
\`cn project compile\` typechecks and bundles the processes without deploying anything.
|
|
191
|
+
\`cn validate\`, \`cn project inspect\`, \`cn runtime info\` and \`cn docs\` take \`--json\`
|
|
192
|
+
for machine-readable output.
|
|
193
|
+
|
|
194
|
+
## Everyday commands
|
|
195
|
+
|
|
196
|
+
| Command | What it does |
|
|
197
|
+
| --- | --- |
|
|
198
|
+
| \`cn project start\` | build, deploy and start the project on the local runtime |
|
|
199
|
+
| \`cn project refresh\` | after a change: sync the project with the running runtime |
|
|
200
|
+
| \`cn project inspect\` | parse the project and display everything the CLI discovered |
|
|
201
|
+
| \`cn project test\` | run the tests of the project |
|
|
202
|
+
| \`cn react dev [app]\` | Vite dev server with HMR for one app |
|
|
203
|
+
| \`cn runtime start\` / \`cn runtime info\` | start the local runtime / its status |
|
|
204
|
+
|
|
205
|
+
Run \`cn --help\` (or \`cn <command> --help\`) for the complete list.
|
|
206
|
+
`;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* CLAUDE.md of a new project: Claude Code reads this file, the '@' import pulls the shared
|
|
210
|
+
* AGENTS.md in so both stay one single source of truth
|
|
211
|
+
*/
|
|
212
|
+
static createClaudeMd() {
|
|
213
|
+
return `@AGENTS.md\n`;
|
|
214
|
+
}
|
|
125
215
|
/**
|
|
126
216
|
* readme.md of a new project: what the generated files are and how to work with them
|
|
127
217
|
*/
|
|
@@ -138,7 +228,7 @@ Renaming it later means updating every reference to it, so it is better chosen o
|
|
|
138
228
|
## Requirements
|
|
139
229
|
|
|
140
230
|
${fence}sh
|
|
141
|
-
npm install -g codenotch
|
|
231
|
+
npm install -g @codenotch/codenotch.cli # the 'cn' command
|
|
142
232
|
cn runtime update # install (or update) the local Codenotch runtime
|
|
143
233
|
${fence}
|
|
144
234
|
|
|
@@ -154,7 +244,7 @@ The files the cli derives from the sources are not versioned (see \`.gitignore\`
|
|
|
154
244
|
fresh clone they have to be written again before the project compiles:
|
|
155
245
|
|
|
156
246
|
${fence}sh
|
|
157
|
-
cn generate dbcontext -f . # db-schema.xml + db-schema.ts, when the project has tables
|
|
247
|
+
cn generate dbcontext -f . # db-schema.xml + db-schema.d.ts, when the project has tables or documents
|
|
158
248
|
cn generate openapi -f . # openapi.json, when processes expose endpoints
|
|
159
249
|
cn generate i18n -f <file>.i18n.csv # the typed class of each translation file
|
|
160
250
|
${fence}
|
|
@@ -171,11 +261,13 @@ ${fence}
|
|
|
171
261
|
| --- | --- |
|
|
172
262
|
| \`manifest.json\` | project name, service name, version, languages and roles |
|
|
173
263
|
| \`package.json\` | npm dependencies, React and \`@codenotch/codenotch.react\` |
|
|
264
|
+
| \`tsconfig.json\` | covers the sources and the generated \`db-schema.d.ts\`, which types \`ctx.tables\` |
|
|
174
265
|
| \`processes/\` | server side processes, one TypeScript file each |
|
|
175
266
|
| \`tables/\` | SQL table definitions |
|
|
176
267
|
| \`documents/\` | NoSQL document schemas |
|
|
177
268
|
| \`apps/\` | React apps: \`<App>.tsx\` and its \`<App>.manifest.json\` |
|
|
178
269
|
| \`*.i18n.csv\` | translations, one column per language |
|
|
270
|
+
| \`AGENTS.md\` | instructions for AI coding agents (\`CLAUDE.md\` imports it) |
|
|
179
271
|
|
|
180
272
|
## Apps
|
|
181
273
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateUtils.js","sourceRoot":"","sources":["../../src/utils/TemplateUtils.ts"],"names":[],"mappings":";;;;;;AACA,8DAAsC;AAEtC;;GAEG;AACU,QAAA,gBAAgB,GAAG,oBAAoB,CAAC;AAErD;;;;;;GAMG;AACH,MAA8B,aAAa;IAEvC,MAAM,CAAC,cAAc,CAAC,OAAe;QACjC,OAAO,wBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,YAAY,CAAC,OAAe;QAC/B,OAAO;YACH,4BAA4B;YAC5B,4DAA4D;YAC5D,EAAE;YACF,SAAS,OAAO,0BAA0B;YAC1C,8BAA8B;YAC9B,EAAE;YACF,gBAAgB;YAChB,mCAAmC;YACnC,kDAAkD;YAClD,UAAU;YACV,IAAI;YACJ,EAAE;YACF,kBAAkB,OAAO,GAAG;YAC5B,EAAE;SACL,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACjB,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,iBAAiB,CAAC,OAAe;QACpC,OAAO;YACH,GAAG,EAAE;gBACD,IAAI,EAAE,OAAO;aAChB;YACD,IAAI,EAAE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": "dist/index.js",
|
|
6
|
-
"files": [
|
|
7
|
-
"dist"
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"
|
|
22
|
-
"
|
|
23
|
-
"test
|
|
24
|
-
"test:
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "@codenotch/codenotch.cli",
|
|
3
|
+
"version": "1.0.42",
|
|
4
|
+
"description": "The Codenotch CLI ('cn'): scaffold, run, validate, package and deploy full-stack TypeScript Codenotch projects - processes, tables, documents and React apps - on a local Codenotch runtime",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"files": [
|
|
7
|
+
"dist",
|
|
8
|
+
"resources"
|
|
9
|
+
],
|
|
10
|
+
"bin": {
|
|
11
|
+
"codenotch-cli": "./dist/bin/cli.js",
|
|
12
|
+
"cn": "./dist/bin/cli.js"
|
|
13
|
+
},
|
|
14
|
+
"scripts": {
|
|
15
|
+
"build": "tsc",
|
|
16
|
+
"dev": "tsx src/index.ts",
|
|
17
|
+
"start": "node dist/index.js",
|
|
18
|
+
"clean": "rimraf dist",
|
|
19
|
+
"prebuild": "npm run clean",
|
|
20
|
+
"prepare": "npm run build",
|
|
21
|
+
"pack:check": "npm pack --dry-run",
|
|
22
|
+
"release": "npm run build && npm run pack:check && npm publish",
|
|
23
|
+
"test": "vitest run",
|
|
24
|
+
"test:watch": "vitest",
|
|
25
|
+
"test:coverage": "vitest run --coverage"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"codenotch",
|
|
29
|
+
"cn",
|
|
30
|
+
"cli",
|
|
31
|
+
"fullstack",
|
|
32
|
+
"typescript",
|
|
33
|
+
"react",
|
|
34
|
+
"scaffold",
|
|
35
|
+
"runtime"
|
|
36
|
+
],
|
|
37
|
+
"author": "Codenotch SA",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"repository": {
|
|
40
|
+
"type": "git",
|
|
41
|
+
"url": "https://github.com/EchinoHub/codenotch-cli.git"
|
|
42
|
+
},
|
|
43
|
+
"publishConfig": {
|
|
44
|
+
"access": "public"
|
|
45
|
+
},
|
|
46
|
+
"dependencies": {
|
|
47
|
+
"@codenotch/codenotch.core": "1.0.25",
|
|
48
|
+
"@octokit/auth-oauth-device": "^8.0.3",
|
|
49
|
+
"@types/express": "^5.0.6",
|
|
50
|
+
"adm-zip": "^0.5.17",
|
|
51
|
+
"chalk": "^5.3.0",
|
|
52
|
+
"commander": "^12.0.0",
|
|
53
|
+
"cross-keychain": "^1.1.0",
|
|
54
|
+
"decompress": "^4.2.1",
|
|
55
|
+
"dotenv": "^17.4.2",
|
|
56
|
+
"esbuild": "0.28.2",
|
|
57
|
+
"express": "^5.2.1",
|
|
58
|
+
"fs-extra": "^10.0.0",
|
|
59
|
+
"ignore": "^7.0.6",
|
|
60
|
+
"js2xmlparser": "^5.0.0",
|
|
61
|
+
"node-fetch": "^3.3.2",
|
|
62
|
+
"papaparse": "^5.3.1",
|
|
63
|
+
"typescript": "^5.9.3"
|
|
64
|
+
},
|
|
65
|
+
"devDependencies": {
|
|
66
|
+
"@types/adm-zip": "^0.5.8",
|
|
67
|
+
"@types/decompress": "^4.2.7",
|
|
68
|
+
"@types/fs-extra": "^9.0.13",
|
|
69
|
+
"@types/json-schema": "^7.0.6",
|
|
70
|
+
"@types/node": "^20.19.34",
|
|
71
|
+
"@types/papaparse": "^5.3.1",
|
|
72
|
+
"@vitest/coverage-v8": "^4.1.10",
|
|
73
|
+
"rimraf": "^5.0.0",
|
|
74
|
+
"ts-node": "^10.9.2",
|
|
75
|
+
"tsx": "^4.21.0",
|
|
76
|
+
"vitest": "^4.1.10"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# React apps
|
|
2
|
+
|
|
3
|
+
How the React apps of a project are structured, the `useCodenotch()` runtime bridge, styling with Scss or Tailwind, and the `cn react` commands.
|
|
4
|
+
|
|
5
|
+
## An app is a pair of files
|
|
6
|
+
|
|
7
|
+
An app is a `<Name>.tsx` and its sibling `<Name>.manifest.json`, both under `apps/`. The name
|
|
8
|
+
must be a valid JavaScript identifier — it is also the React component name and how the
|
|
9
|
+
`cn react` commands address the app. The `.tsx` default-exports the component:
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import React from 'react';
|
|
13
|
+
import { useCodenotch } from '@codenotch/codenotch.react';
|
|
14
|
+
|
|
15
|
+
const index: React.FC<{}> = () => {
|
|
16
|
+
const cn = useCodenotch();
|
|
17
|
+
return <div>
|
|
18
|
+
<h1>My new Codenotch App</h1>
|
|
19
|
+
<pre>{JSON.stringify(cn.env, null, 4)}</pre>
|
|
20
|
+
</div>;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default index;
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
The manifest carries the display and PWA settings:
|
|
27
|
+
|
|
28
|
+
```json
|
|
29
|
+
{
|
|
30
|
+
"app": { "name": "index" },
|
|
31
|
+
"html": { "title": "My Project" },
|
|
32
|
+
"pwa": {
|
|
33
|
+
"name": "index",
|
|
34
|
+
"display": "standalone",
|
|
35
|
+
"display_override": ["window-controls-overlay"],
|
|
36
|
+
"start_url": "./",
|
|
37
|
+
"icons": [
|
|
38
|
+
{ "src": "logo512.png", "sizes": "512x512", "type": "image/png" },
|
|
39
|
+
{ "src": "logo192.png", "sizes": "192x192", "type": "image/png" }
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
`cn generate app -n <Name>` scaffolds the pair.
|
|
46
|
+
|
|
47
|
+
## Stack
|
|
48
|
+
|
|
49
|
+
- **React 19** — the only supported major.
|
|
50
|
+
- **react-router 7** for multi-page apps, with `HashRouter`: it keeps the routing client side
|
|
51
|
+
whatever URL the runtime serves the app from.
|
|
52
|
+
- **`@codenotch/codenotch.react`** — the bridge to the runtime, through `useCodenotch()`.
|
|
53
|
+
|
|
54
|
+
## useCodenotch()
|
|
55
|
+
|
|
56
|
+
What the generated code relies on:
|
|
57
|
+
|
|
58
|
+
| Member | Meaning |
|
|
59
|
+
| --- | --- |
|
|
60
|
+
| `cn.env` | the environment the runtime gave the app |
|
|
61
|
+
| `cn.getTheme()` / `cn.setTheme('light' \| 'dark')` | theme; `setTheme` toggles the `dark` class on `<html>` |
|
|
62
|
+
| `cn.getLanguage()` / `cn.setLanguage(lang)` / `cn.getLanguages()` | languages, from `manifest.json` |
|
|
63
|
+
| `cn.startProcess(processId, input)` | call a server-side process — **not implemented yet** in `@codenotch/codenotch.react` 2.0.1 (it throws `Not implemented.`) |
|
|
64
|
+
|
|
65
|
+
For the full surface, read the typings in
|
|
66
|
+
`node_modules/@codenotch/codenotch.react/dist/`. Because `startProcess` is not settled, generated
|
|
67
|
+
projects wrap it in one typed `apps/api.ts` module carrying a `TODO` comment — keep that pattern
|
|
68
|
+
instead of scattering direct calls.
|
|
69
|
+
|
|
70
|
+
## Styling
|
|
71
|
+
|
|
72
|
+
Every template styles through a `.scss` imported by the app entry (`import './index.scss'`).
|
|
73
|
+
The Tailwind flavour uses **Tailwind CSS 4**:
|
|
74
|
+
|
|
75
|
+
```scss
|
|
76
|
+
// @use rather than @import: sass deprecates @import (gone in dart sass 3)
|
|
77
|
+
@use "tailwindcss";
|
|
78
|
+
|
|
79
|
+
/* setTheme('dark') toggles the 'dark' class on <html>: key the dark: variants on it */
|
|
80
|
+
@custom-variant dark (&:where(.dark, .dark *));
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
plus a `postcss.config.js` with the `@tailwindcss/postcss` plugin, picked up by the Vite build.
|
|
84
|
+
No CSS modules.
|
|
85
|
+
|
|
86
|
+
## Translations in the UI
|
|
87
|
+
|
|
88
|
+
Import the class generated from a `*.i18n.csv` and follow the runtime language (see
|
|
89
|
+
`cn docs i18n`):
|
|
90
|
+
|
|
91
|
+
```tsx
|
|
92
|
+
import globals from '../../globals.i18n';
|
|
93
|
+
|
|
94
|
+
globals.setLanguage(cn.getLanguage() ?? 'en');
|
|
95
|
+
<h1>{globals.appTitle()}</h1>
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Commands
|
|
99
|
+
|
|
100
|
+
| Command | What it does |
|
|
101
|
+
| --- | --- |
|
|
102
|
+
| `cn react dev [app]` | Vite dev server with HMR on the real project sources |
|
|
103
|
+
| `cn react build [app]` | production bundle (options for a static or PWA build) |
|
|
104
|
+
| `cn react serve [target]` | serve a build locally |
|
|
105
|
+
| `cn react clean [app]` | delete the build staging of the app |
|
|
106
|
+
| `cn react package [app]` | desktop installer (Tauri) |
|
|
107
|
+
|
|
108
|
+
Apps are addressed by the `app.name` of their manifest; with a single app the name can be
|
|
109
|
+
omitted.
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
# Translations
|
|
2
|
+
|
|
3
|
+
The `*.i18n.csv` translation files, and the typed class `cn generate i18n` derives from each of them.
|
|
4
|
+
|
|
5
|
+
## The csv
|
|
6
|
+
|
|
7
|
+
A `*.i18n.csv` holds one `key` column plus one column per language, matching the `languages` of
|
|
8
|
+
`manifest.json`:
|
|
9
|
+
|
|
10
|
+
```csv
|
|
11
|
+
key,en,de,fr
|
|
12
|
+
appTitle,My todo lists,Meine Aufgabenlisten,Mes listes de tâches
|
|
13
|
+
todoCount,"{0} todo(s), {1} done","{0} Aufgabe(n), {1} erledigt","{0} tâche(s), {1} terminée(s)"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- `{0}`, `{1}`, ... are the placeholders of the arguments.
|
|
17
|
+
- Standard CSV quoting: wrap a value containing a comma, a quote or a newline in double quotes.
|
|
18
|
+
- Rows without a key are ignored (a leading empty row after the header is tolerated).
|
|
19
|
+
- Best practice: one global file at the project root (e.g. `globals.i18n.csv`) rather than many
|
|
20
|
+
scattered ones.
|
|
21
|
+
|
|
22
|
+
Keys should be valid identifiers (they become method names): a key that is not is converted with
|
|
23
|
+
a warning, and the names `values`, `lang`, `setLanguage`, `getValue` are reserved.
|
|
24
|
+
|
|
25
|
+
## The generated class
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
cn generate i18n -f globals.i18n.csv
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
writes `globals.i18n.ts` next to the csv — generated, gitignored, never edit it; regenerate after
|
|
32
|
+
every change to the csv. The class name comes from the file name, and it exposes one static
|
|
33
|
+
method per key:
|
|
34
|
+
|
|
35
|
+
```tsx
|
|
36
|
+
import globals from './globals.i18n';
|
|
37
|
+
|
|
38
|
+
globals.setLanguage('de');
|
|
39
|
+
globals.appTitle(); // 'Meine Aufgabenlisten'
|
|
40
|
+
globals.todoCount('3', '1'); // '3 Aufgabe(n), 1 erledigt'
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
Behavior of the generated methods:
|
|
44
|
+
|
|
45
|
+
- the argument count of a method is the highest `{n}` placeholder across all languages, plus one;
|
|
46
|
+
- a language without a value falls back to the first language column of the csv;
|
|
47
|
+
- an unknown key returns `KEY '<key>' NOT EXISTS` rather than throwing — a visible marker in the
|
|
48
|
+
UI instead of a crash.
|
|
49
|
+
|
|
50
|
+
In an app, follow the runtime language: `globals.setLanguage(cn.getLanguage() ?? 'en')` (see
|
|
51
|
+
`cn docs apps`).
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Processes
|
|
2
|
+
|
|
3
|
+
How to write the server-side processes of a project with `@codenotch/process`, what `ctx` offers, and the constraints coming from how they are bundled and executed.
|
|
4
|
+
|
|
5
|
+
## Declaring a process
|
|
6
|
+
|
|
7
|
+
A process is a `process({...})` declaration, conventionally grouped by domain in files under
|
|
8
|
+
`processes/`:
|
|
9
|
+
|
|
10
|
+
```ts
|
|
11
|
+
import { process, api, Context } from '@codenotch/process'
|
|
12
|
+
import type { ITodoList } from '../tables/todolist'
|
|
13
|
+
|
|
14
|
+
export const createTodoList = process({
|
|
15
|
+
id: 'CreateTodoList',
|
|
16
|
+
description: 'Creates an empty todo list',
|
|
17
|
+
auth: { scope: 'internal' },
|
|
18
|
+
trigger: api.post('/todolists'),
|
|
19
|
+
run: async (ctx: Context, input: { name: string }): Promise<{ id: string }> => {
|
|
20
|
+
const id = ctx.uuid()
|
|
21
|
+
await ctx.tables.todolists.write(id, { name: input.name })
|
|
22
|
+
return { id }
|
|
23
|
+
},
|
|
24
|
+
})
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
| Property | Meaning |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| `id` | Unique across the project, a **string literal**. The registry key and the `ctx.call` target. |
|
|
30
|
+
| `description` | One line, shown in diagnostics and OpenAPI. |
|
|
31
|
+
| `auth.scope` | Who may start it: `'public'`, `'internal'`, `'system'`. |
|
|
32
|
+
| `trigger` | How it starts (below). Omitted: only reachable through `ctx.call` from another process. |
|
|
33
|
+
| `run` | `async (ctx, input) => output`. Always returns a Promise. |
|
|
34
|
+
|
|
35
|
+
Triggers:
|
|
36
|
+
|
|
37
|
+
| Trigger | Starts the process |
|
|
38
|
+
| --- | --- |
|
|
39
|
+
| `api.get('/route')` / `api.post` / `api.put` / `api.delete` | as an HTTP endpoint; `:param` segments land in `input` |
|
|
40
|
+
| `timer('0 7 * * *')` | on a cron schedule |
|
|
41
|
+
| `signal('some.ref')` | when that signal is raised |
|
|
42
|
+
| `install({ ... })` | at installation of the project |
|
|
43
|
+
|
|
44
|
+
Type the `input` parameter and the return type of `run`: the CLI turns those annotations into
|
|
45
|
+
JSON schemas used for payload validation and `openapi.json` (`cn generate openapi -f .`).
|
|
46
|
+
|
|
47
|
+
## What `ctx` offers
|
|
48
|
+
|
|
49
|
+
The capabilities the generated code relies on:
|
|
50
|
+
|
|
51
|
+
| Member | Meaning |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| `ctx.tables.<collection>.write(id, patch)` | insert or update a row (only the fields present in the patch are written) |
|
|
54
|
+
| `ctx.tables.<collection>.require(id)` | one row, throws when the id is unknown — an `api` process turns that into a 404 |
|
|
55
|
+
| `ctx.tables.<collection>.delete(id)` | delete a row (relations with `linkBehaviour('Delete')` cascade) |
|
|
56
|
+
| `ctx.query<T>('queries/x.cnql', params)` | run a read query, see `cn docs queries` |
|
|
57
|
+
| `ctx.uuid()` | a new UUID |
|
|
58
|
+
| `ctx.call` | start another process by its `id` |
|
|
59
|
+
| `ctx.log.info(message, data)` | structured logging |
|
|
60
|
+
|
|
61
|
+
`ctx.tables` is typed by the generated `db-schema.d.ts` — regenerate it after changing a table
|
|
62
|
+
(`cn generate dbcontext -f .`), otherwise the collections stay untyped.
|
|
63
|
+
|
|
64
|
+
## Rules — a process that breaks them is skipped with a warning, never guessed
|
|
65
|
+
|
|
66
|
+
- **Export the variable** (`export const createTodoList = ...`): a non-exported process is not
|
|
67
|
+
reachable.
|
|
68
|
+
- **Literal, unique `id`**: an id that is missing, computed at runtime, or already used by
|
|
69
|
+
another process gets the declaration skipped.
|
|
70
|
+
|
|
71
|
+
## Bundling constraints
|
|
72
|
+
|
|
73
|
+
At packaging time each process becomes one self-contained `.js` artifact executed in a bare V8
|
|
74
|
+
engine — no Node, no module system. Consequences for the code you write:
|
|
75
|
+
|
|
76
|
+
- **No Node standard library** (`fs`, `node:crypto`, ...): importing one is a compile error, it
|
|
77
|
+
cannot exist in the runtime's engine.
|
|
78
|
+
- **npm dependencies are inlined** into each artifact: only pure-JS packages can work (no native
|
|
79
|
+
addons, no Node API inside).
|
|
80
|
+
- `@codenotch/*` packages are **provided by the runtime**, never inlined.
|
|
81
|
+
- **Module-level state is per process**: a top-level cache in a shared helper exists once per
|
|
82
|
+
artifact, it is never shared between processes.
|
|
83
|
+
- The whole project is **typechecked before bundling**: type errors fail the packaging.
|
|
84
|
+
|
|
85
|
+
`cn project compile` runs the same typecheck and bundling without packaging — the quick way to
|
|
86
|
+
check the processes build. `cn generate process` scaffolds boilerplate processes (CRUD, api) for
|
|
87
|
+
a discovered table (`-m api|insert|insert-full|update|upsert|delete|clean`).
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
# The anatomy of a Codenotch project
|
|
2
|
+
|
|
3
|
+
What a Codenotch project is made of, which files are generated from which sources, and the commands of its lifecycle.
|
|
4
|
+
|
|
5
|
+
A Codenotch project is TypeScript end to end: server-side processes are `process({...})`
|
|
6
|
+
declarations from `@codenotch/process`, tables are `defineEntity({...})` from `@codenotch/orm`,
|
|
7
|
+
apps are React 19 components. The project is built, deployed and run on a Codenotch runtime by
|
|
8
|
+
the `cn` CLI. The CLI discovers what the project declares by parsing its TypeScript sources —
|
|
9
|
+
there is no registry to maintain by hand.
|
|
10
|
+
|
|
11
|
+
## Layout
|
|
12
|
+
|
|
13
|
+
| Path | Contains | Topic |
|
|
14
|
+
| --- | --- | --- |
|
|
15
|
+
| `manifest.json` | project name, service name, version, languages and roles | below |
|
|
16
|
+
| `package.json` | npm dependencies, React and `@codenotch/codenotch.react` | |
|
|
17
|
+
| `tsconfig.json` | covers the sources and the generated `db-schema.d.ts` | below |
|
|
18
|
+
| `processes/` | server side processes, plain TypeScript files | `cn docs processes` |
|
|
19
|
+
| `tables/` | SQL table definitions (`defineEntity`) | `cn docs tables` |
|
|
20
|
+
| `documents/` | NoSQL document schemas (`defineDocument`) | `cn docs tables` |
|
|
21
|
+
| `queries/` | `.cnql` read queries run by the processes | `cn docs queries` |
|
|
22
|
+
| `apps/` | React apps: `<App>.tsx` and its `<App>.manifest.json` | `cn docs apps` |
|
|
23
|
+
| `*.i18n.csv` | translations, one column per language | `cn docs i18n` |
|
|
24
|
+
|
|
25
|
+
The folder names are a convention, not a requirement: the CLI discovers declarations by parsing
|
|
26
|
+
every TypeScript file of the project, wherever it sits.
|
|
27
|
+
|
|
28
|
+
## manifest.json
|
|
29
|
+
|
|
30
|
+
```json
|
|
31
|
+
{
|
|
32
|
+
"packages": {},
|
|
33
|
+
"projectName": "My Project",
|
|
34
|
+
"serviceName": "myproject",
|
|
35
|
+
"languages": ["en", "de", "fr"],
|
|
36
|
+
"roles": [],
|
|
37
|
+
"version": "0.0.0",
|
|
38
|
+
"dependencies": [],
|
|
39
|
+
"postInstallationProcesses": []
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
`serviceName` identifies the project on the runtime and is part of its URL. Renaming it means
|
|
44
|
+
updating every reference to it (queries carry it as their `xmlns`, for instance) — treat it as
|
|
45
|
+
fixed unless the user explicitly asks for a rename.
|
|
46
|
+
|
|
47
|
+
## Generated files — never edit them
|
|
48
|
+
|
|
49
|
+
| File | Generated from | Regenerate with |
|
|
50
|
+
| --- | --- | --- |
|
|
51
|
+
| `db-schema.xml` | the `defineEntity` declarations | `cn generate dbcontext -f .` |
|
|
52
|
+
| `db-schema.d.ts` | same — types `ctx.tables` by declaration merging | `cn generate dbcontext -f .` |
|
|
53
|
+
| `openapi.json` | the processes exposing endpoints | `cn generate openapi -f .` |
|
|
54
|
+
| `*.i18n.ts` | its sibling `*.i18n.csv` | `cn generate i18n -f <file>.i18n.csv` |
|
|
55
|
+
| `compiled/` | the processes, one self-contained `.js` each | `cn project compile` (or packaging) |
|
|
56
|
+
| `.codenotch/` | React build staging | `cn react build` |
|
|
57
|
+
|
|
58
|
+
These files are in `.gitignore`: after a fresh clone they have to be generated again before the
|
|
59
|
+
project compiles. When one of them looks wrong, fix the source it is generated from, then
|
|
60
|
+
regenerate — an edit to the generated file is overwritten on the next run.
|
|
61
|
+
|
|
62
|
+
`tsconfig.json` must keep including `db-schema.d.ts`: the declaration merging it carries only
|
|
63
|
+
applies to files of the same TypeScript program, so removing it from `include` silently untypes
|
|
64
|
+
`ctx.tables` in every process.
|
|
65
|
+
|
|
66
|
+
## Lifecycle
|
|
67
|
+
|
|
68
|
+
```sh
|
|
69
|
+
npm install -g @codenotch/codenotch.cli # the 'cn' command
|
|
70
|
+
cn runtime update # install (or update) the local Codenotch runtime
|
|
71
|
+
cn runtime start # start it
|
|
72
|
+
cn project start # build, deploy and open this project
|
|
73
|
+
cn project refresh # after a change: sync the project with the runtime
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Checks, at any time:
|
|
77
|
+
|
|
78
|
+
```sh
|
|
79
|
+
cn validate . # hints, warnings and errors of every file
|
|
80
|
+
cn project inspect # parse the project and display everything the CLI discovered
|
|
81
|
+
cn project test # run the tests of the project
|
|
82
|
+
cn project compile # typecheck and bundle the processes, without packaging
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
`cn validate`, `cn project inspect`, `cn runtime info` and `cn docs` all take `--json` for
|
|
86
|
+
machine-readable output.
|
|
87
|
+
|
|
88
|
+
Shipping:
|
|
89
|
+
|
|
90
|
+
```sh
|
|
91
|
+
cn project package # compile and package the project as a zip
|
|
92
|
+
cn project deploy <service> <zip>
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Packaging typechecks the whole project first: type errors fail it.
|
|
96
|
+
|
|
97
|
+
## The TODO policy
|
|
98
|
+
|
|
99
|
+
Where the runtime API is not settled yet (the client-side call of a process, the CNQL filter
|
|
100
|
+
syntax), the code carries an explicit `TODO` comment instead of a guess. Keep that policy: never
|
|
101
|
+
invent an API shape where the existing sources marked one as unsettled.
|