proteum 2.0.0 → 2.1.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/AGENTS.md +13 -1
- package/README.md +375 -0
- package/agents/framework/AGENTS.md +917 -0
- package/agents/project/AGENTS.md +138 -0
- package/agents/{codex → project}/CODING_STYLE.md +3 -2
- package/agents/project/client/AGENTS.md +108 -0
- package/agents/{codex → project}/client/pages/AGENTS.md +8 -8
- package/agents/{codex → project}/server/routes/AGENTS.md +2 -1
- package/agents/project/server/services/AGENTS.md +170 -0
- package/agents/{codex → project}/tests/AGENTS.md +1 -0
- package/cli/app/config.ts +3 -2
- package/cli/app/index.ts +6 -66
- package/cli/bin.js +7 -2
- package/cli/commands/build.ts +94 -27
- package/cli/commands/check.ts +15 -1
- package/cli/commands/dev.ts +288 -132
- package/cli/commands/doctor.ts +108 -0
- package/cli/commands/explain.ts +226 -0
- package/cli/commands/init.ts +76 -70
- package/cli/commands/lint.ts +18 -1
- package/cli/commands/refresh.ts +16 -6
- package/cli/commands/typecheck.ts +14 -1
- package/cli/compiler/artifacts/controllers.ts +150 -0
- package/cli/compiler/artifacts/discovery.ts +132 -0
- package/cli/compiler/artifacts/manifest.ts +267 -0
- package/cli/compiler/artifacts/routing.ts +315 -0
- package/cli/compiler/artifacts/services.ts +480 -0
- package/cli/compiler/artifacts/shared.ts +12 -0
- package/cli/compiler/client/identite.ts +2 -1
- package/cli/compiler/client/index.ts +13 -3
- package/cli/compiler/common/controllers.ts +23 -28
- package/cli/compiler/common/files/style.ts +3 -4
- package/cli/compiler/common/generatedRouteModules.ts +333 -19
- package/cli/compiler/common/proteumManifest.ts +133 -0
- package/cli/compiler/index.ts +33 -896
- package/cli/compiler/server/index.ts +21 -4
- package/cli/context.ts +71 -0
- package/cli/index.ts +39 -181
- package/cli/presentation/commands.ts +208 -0
- package/cli/presentation/compileReporter.ts +65 -0
- package/cli/presentation/devSession.ts +70 -0
- package/cli/presentation/help.ts +193 -0
- package/cli/presentation/ink.ts +69 -0
- package/cli/presentation/layout.ts +83 -0
- package/cli/runtime/argv.ts +49 -0
- package/cli/runtime/command.ts +25 -0
- package/cli/runtime/commands.ts +221 -0
- package/cli/runtime/importEsm.ts +7 -0
- package/cli/runtime/verbose.ts +15 -0
- package/cli/utils/agents.ts +5 -4
- package/cli/utils/keyboard.ts +12 -6
- package/client/app/index.ts +0 -6
- package/client/services/router/index.tsx +1 -1
- package/client/services/router/response/index.tsx +2 -2
- package/common/dev/serverHotReload.ts +12 -0
- package/common/router/index.ts +3 -2
- package/common/router/layouts.ts +1 -1
- package/common/router/pageSetup.ts +1 -0
- package/package.json +10 -8
- package/prettier/router-registration-plugin.cjs +52 -0
- package/prettier.config.cjs +1 -0
- package/scripts/cleanup-generated-controllers.ts +2 -2
- package/scripts/fix-reference-app-typing.ts +2 -2
- package/scripts/format-router-registrations.ts +119 -0
- package/scripts/migrate-explicit-controllers-and-request.ts +423 -0
- package/scripts/refactor-server-controllers.ts +19 -18
- package/scripts/refactor-server-runtime-aliases.ts +1 -1
- package/server/app/commands.ts +309 -25
- package/server/app/container/config.ts +1 -1
- package/server/app/container/index.ts +2 -2
- package/server/app/controller/index.ts +13 -4
- package/server/app/index.ts +53 -37
- package/server/app/service/container.ts +26 -28
- package/server/app/service/index.ts +10 -20
- package/server/app.tsconfig.json +9 -2
- package/server/index.ts +32 -1
- package/server/services/auth/index.ts +234 -15
- package/server/services/auth/router/index.ts +39 -7
- package/server/services/auth/router/request.ts +40 -8
- package/server/services/disks/index.ts +1 -1
- package/server/services/prisma/Facet.ts +2 -2
- package/server/services/prisma/index.ts +22 -5
- package/server/services/prisma/mariadb.ts +47 -0
- package/server/services/router/http/index.ts +9 -1
- package/server/services/router/index.ts +10 -4
- package/server/services/router/response/index.ts +26 -6
- package/types/auth-check-rules.test.ts +51 -0
- package/types/controller-request-context.test.ts +55 -0
- package/types/service-config.test.ts +39 -0
- package/agents/codex/AGENTS.md +0 -95
- package/agents/codex/client/AGENTS.md +0 -102
- package/agents/codex/server/services/AGENTS.md +0 -137
- package/server/services/models.7z +0 -0
- /package/agents/{codex → project}/agents.md.zip +0 -0
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
# Server Services
|
|
2
|
-
|
|
3
|
-
Stack:
|
|
4
|
-
- Typescript with strict mode
|
|
5
|
-
- NodeJS
|
|
6
|
-
- Prisma 7 ORM
|
|
7
|
-
|
|
8
|
-
## 1. Create the service file in `/server/services/<service name>/index.ts`
|
|
9
|
-
|
|
10
|
-
Template:
|
|
11
|
-
|
|
12
|
-
```typescript
|
|
13
|
-
/*----------------------------------
|
|
14
|
-
- DEPENDANCE
|
|
15
|
-
----------------------------------*/
|
|
16
|
-
|
|
17
|
-
// Core libs
|
|
18
|
-
import Service from '@server/app/service';
|
|
19
|
-
|
|
20
|
-
/*----------------------------------
|
|
21
|
-
- TYPES
|
|
22
|
-
----------------------------------*/
|
|
23
|
-
|
|
24
|
-
export type Config = <ServiceConfig>;
|
|
25
|
-
|
|
26
|
-
/*----------------------------------
|
|
27
|
-
- SERVICE
|
|
28
|
-
----------------------------------*/
|
|
29
|
-
|
|
30
|
-
export default class ServiceName extends Service<Config, {}, CrossPath, CrossPath> {
|
|
31
|
-
|
|
32
|
-
public async MethodName(data: { param1: string }) {
|
|
33
|
-
const { OtherService } = this.services;
|
|
34
|
-
|
|
35
|
-
return OtherService.OtherMethod(data);
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
`<ServiceConfig>` is an object containing api keys and other variables we can adjust in the future.
|
|
41
|
-
|
|
42
|
-
## 2. Create the controller file in `/server/services/<service name>/<ServiceName>.controller.ts`
|
|
43
|
-
|
|
44
|
-
Template:
|
|
45
|
-
|
|
46
|
-
```typescript
|
|
47
|
-
import Controller, { schema } from '@server/app/controller';
|
|
48
|
-
import type { TMethodInput } from './index';
|
|
49
|
-
|
|
50
|
-
const MethodInput = schema.object({
|
|
51
|
-
param1: schema.string(),
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
export default class ServiceNameController extends Controller {
|
|
55
|
-
|
|
56
|
-
public async MethodName() {
|
|
57
|
-
const data = this.input(MethodInput);
|
|
58
|
-
const { ServiceName } = this.services;
|
|
59
|
-
const { auth, request, user } = this.request;
|
|
60
|
-
|
|
61
|
-
return ServiceName.MethodName(data);
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
Rules:
|
|
67
|
-
- Only `*.controller.ts` files are indexed as callable API endpoints
|
|
68
|
-
- Route path is derived from the controller file path and the method name
|
|
69
|
-
- `this.input(schema)` is the only validation entrypoint
|
|
70
|
-
- Call `this.input(...)` at most once per controller method
|
|
71
|
-
- Request-scoped state exists only on `this.request`
|
|
72
|
-
|
|
73
|
-
## 3. Create the service metas file in `/server/services/<service name>/service.json`
|
|
74
|
-
|
|
75
|
-
```json
|
|
76
|
-
{
|
|
77
|
-
"id": "CrossPath/ServiceName",
|
|
78
|
-
"name": "CrossPathServiceName",
|
|
79
|
-
"parent": "app",
|
|
80
|
-
"dependences": []
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
## 4. Register the service in `/server/config/<app>.ts`
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
app.setup('ServiceName', 'CrossPath/ServiceName', <ServiceConfig>);
|
|
88
|
-
```
|
|
89
|
-
|
|
90
|
-
## 5. Keep classes clean
|
|
91
|
-
|
|
92
|
-
If the class grows too large, split business concerns into subservices.
|
|
93
|
-
|
|
94
|
-
## 6. Use request-aware features only in controllers
|
|
95
|
-
|
|
96
|
-
Use:
|
|
97
|
-
|
|
98
|
-
```typescript
|
|
99
|
-
const { auth, request, user, response } = this.request;
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
- Never import runtime request state from `@request`
|
|
103
|
-
- Never access request-scoped state inside normal service methods unless the controller passes the minimal values explicitly
|
|
104
|
-
|
|
105
|
-
## 7. Fetch and return data from the database
|
|
106
|
-
|
|
107
|
-
Use runtime models through `this.models`:
|
|
108
|
-
|
|
109
|
-
```typescript
|
|
110
|
-
const users = await this.models.user.findMany({
|
|
111
|
-
select: {
|
|
112
|
-
id: true,
|
|
113
|
-
},
|
|
114
|
-
});
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
Use prisma typings through `@models/types` only:
|
|
118
|
-
|
|
119
|
-
```typescript
|
|
120
|
-
import type * as Models from '@models/types';
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
Rules:
|
|
124
|
-
- Never edit prisma files, except the schema
|
|
125
|
-
- Never use runtime `@models` imports
|
|
126
|
-
- In all queries and joins, always specify what fields to select
|
|
127
|
-
|
|
128
|
-
## DTO and typing rules
|
|
129
|
-
|
|
130
|
-
- Prefer inferred return types:
|
|
131
|
-
`export type TResult = Awaited<ReturnType<MyService["MethodName"]>>;`
|
|
132
|
-
- Never create manual DTO types when the exact return type can be inferred
|
|
133
|
-
|
|
134
|
-
## Errors handling
|
|
135
|
-
|
|
136
|
-
Unhandled errors are passed to the `bug` app hook.
|
|
137
|
-
Never silent caught errors. Throw `Anomaly` with enough detail and the original error when needed.
|
|
Binary file
|
|
File without changes
|