agjan 0.0.6 → 0.0.8
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 +3 -2
- package/docs/guide.md +81 -29
- package/kit/hooks/guard.mjs +129 -19
- package/kit/skills/agjan-fix/SKILL.md +11 -3
- package/kit/skills/agjan-map/SKILL.md +12 -3
- package/kit/skills/agjan-spec/SKILL.md +12 -5
- package/kit/skills/agjan-verify/SKILL.md +9 -6
- package/kit/skills/cap-developer/SKILL.md +4 -0
- package/kit/skills/cap-developer/references/handlers.md +61 -4
- package/kit/skills/cap-developer/references/modeling.md +33 -1
- package/kit/skills/cap-developer/references/project-setup.md +87 -0
- package/kit/skills/cap-developer/references/services.md +32 -1
- package/kit/skills/cap-developer/references/testing.md +46 -14
- package/kit/skills/cap-developer/references/validation-security.md +66 -2
- package/kit/skills/fiori-developer/SKILL.md +1 -0
- package/kit/skills/fiori-developer/references/app-setup.md +127 -0
- package/kit/skills/fiori-developer/references/elements.md +109 -11
- package/kit/skills/fiori-developer/references/ui5-basics.md +3 -2
- package/kit/templates/agents-block.md +3 -2
- package/kit/templates/progress.html +14 -9
- package/kit/templates/project.md +5 -0
- package/package.json +1 -1
- package/schemas/config.schema.json +1 -15
- package/src/adapters/claude-code.mjs +16 -12
- package/src/cli.mjs +3 -2
- package/src/commands/branch.mjs +34 -24
- package/src/commands/check.mjs +1 -17
- package/src/commands/setup.mjs +73 -35
- package/src/commands/status.mjs +38 -13
- package/src/context.mjs +6 -0
- package/src/plan.mjs +8 -4
- package/src/progress-view.mjs +32 -11
- package/src/review.mjs +1 -1
- package/src/terminal.mjs +7 -3
- package/src/ui.mjs +22 -0
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# Project setup and layout (CAP Node.js)
|
|
2
|
+
|
|
3
|
+
Distilled from the CAP documentation (capire), the CAP team's agent skills
|
|
4
|
+
(`capire/skills`) and the reference apps `capire/bookshop` and `capire/incidents-app`
|
|
5
|
+
(all Apache-2.0), checked with `@sap/cds` 10.1 on 2026-10-18. Rules restated.
|
|
6
|
+
|
|
7
|
+
## A new project
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
cds init <name> --nodejs # ESM ("type": "module"), db/, srv/, app/
|
|
11
|
+
cd <name>
|
|
12
|
+
npm add -D @cap-js/cds-test # tests with cds.test
|
|
13
|
+
cds watch # dev loop; reloads on every save
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
- Initialize in a folder of its own or in the current one (`cds init` without a name).
|
|
17
|
+
If the project already has a `package.json` (agjan set up first), run `cds init` in that
|
|
18
|
+
folder and keep the existing dependencies.
|
|
19
|
+
- **Never run `cds add sample`**: it scaffolds a whole demo app (bookshop) into the project.
|
|
20
|
+
Use `cds add tiny-sample` only when the user asks for a minimal starter model.
|
|
21
|
+
- Add features with `cds add <feature>` only when a task needs them: `hana`, `xsuaa`,
|
|
22
|
+
`mta`, `approuter`, `data` (see below). Each is a design decision for the btp area.
|
|
23
|
+
- Keep ESM: never remove `"type": "module"` or rewrite handlers as CommonJS to work around
|
|
24
|
+
an import error.
|
|
25
|
+
|
|
26
|
+
## Layout
|
|
27
|
+
|
|
28
|
+
| File | Content |
|
|
29
|
+
|---|---|
|
|
30
|
+
| `db/schema.cds` | the domain model, with a `namespace` |
|
|
31
|
+
| `db/data/<namespace>-<Entity>.csv` | seed and test data |
|
|
32
|
+
| `srv/<name>-service.cds` | one service per file: projections and actions |
|
|
33
|
+
| `srv/<name>-service.js` | its handlers; same base name, so CAP finds it (no `@impl`) |
|
|
34
|
+
| `srv/<name>-constraints.cds` | input validation (`@mandatory`, `@assert…`) and helper `extend`s for it |
|
|
35
|
+
| `app/<app>/annotations.cds` | the Fiori annotations of one app (never in `srv/`) |
|
|
36
|
+
| `app/services.cds` | `using from './<app>/annotations';` for every app |
|
|
37
|
+
| `_i18n/i18n.properties` | labels used as `{i18n>Key}` in annotations |
|
|
38
|
+
| `_i18n/messages.properties` | error messages, by the codes in `@assert` and `req.reject` |
|
|
39
|
+
| `test/<topic>.test.js` | tests with `cds.test` and `node --test` |
|
|
40
|
+
|
|
41
|
+
## Configuration
|
|
42
|
+
|
|
43
|
+
- Project configuration goes into the `cds` section of `package.json`, where `cds init`
|
|
44
|
+
and `cds add` put it. Use `.cdsrc.json` only if the project already uses it.
|
|
45
|
+
Personal, local settings belong in `.cdsrc-private.json` (not committed).
|
|
46
|
+
- Development users go into the `[development]` profile, named after their role with the
|
|
47
|
+
name as password, plus one without a role. `cds.test` and `cds watch` use them; in
|
|
48
|
+
production (`NODE_ENV=production`) the real authentication applies:
|
|
49
|
+
|
|
50
|
+
<!-- checked: package.json -->
|
|
51
|
+
```json
|
|
52
|
+
"cds": {
|
|
53
|
+
"requires": {
|
|
54
|
+
"[development]": {
|
|
55
|
+
"auth": {
|
|
56
|
+
"kind": "mocked",
|
|
57
|
+
"users": {
|
|
58
|
+
"employee": { "password": "employee", "roles": ["employee"] },
|
|
59
|
+
"employee2": { "password": "employee2", "roles": ["employee"] },
|
|
60
|
+
"manager": { "password": "manager", "roles": ["manager"] },
|
|
61
|
+
"nobody": { "password": "nobody", "roles": [] }
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
- Check: `NODE_ENV=production npx cds env get requires.auth.kind` must not print `mocked`.
|
|
70
|
+
- Scripts: `"watch": "cds watch"`, `"test": "node --test"` (add the JUnit reporter when
|
|
71
|
+
`verify.<area>.results` in `agjan.config.json` names a results file).
|
|
72
|
+
|
|
73
|
+
## Sample data
|
|
74
|
+
|
|
75
|
+
- `cds add data --records <n> --keys-only` writes one CSV per entity with generated keys
|
|
76
|
+
and empty other columns. It does **not** fill foreign keys (checked with cds-dk 10.1):
|
|
77
|
+
fill them, and the content, yourself, and keep the generated keys and headers.
|
|
78
|
+
- Small, readable data is often better written by hand: a few rows per entity, keys that
|
|
79
|
+
tell a story (`employee`, `manager`, fixed UUIDs for rows that tests address).
|
|
80
|
+
- Code lists (`Status`, types) are data too: their codes in a CSV, names and criticality.
|
|
81
|
+
|
|
82
|
+
## Run locally
|
|
83
|
+
|
|
84
|
+
Keep the section "Run locally" of `docs/agjan/project.md` current: the start command
|
|
85
|
+
(`npx cds watch`), the URLs of the apps (`http://localhost:4004/<app>/webapp/index.html`),
|
|
86
|
+
and the development users with their roles. A browser keeps a login: another user needs a
|
|
87
|
+
private window.
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# Services, operations, drafts
|
|
2
2
|
|
|
3
3
|
Distilled from the CAP documentation (capire, Apache-2.0), retrieved through the CAP
|
|
4
|
-
MCP server on 2026-10-17
|
|
4
|
+
MCP server on 2026-10-17, with patterns from the CAP team's agent skills (`capire/skills`)
|
|
5
|
+
and the reference apps `capire/bookshop` and `capire/incidents-app` (Apache-2.0); the
|
|
6
|
+
examples were checked with `@sap/cds` 10.1 on 2026-10-18. Rules restated; check details
|
|
7
|
+
with `search_docs`.
|
|
5
8
|
|
|
6
9
|
## Services as facades
|
|
7
10
|
|
|
@@ -16,6 +19,34 @@ MCP server on 2026-10-17. Rules restated; check details with `search_docs`.
|
|
|
16
19
|
- Prefer `@readonly`, `@mandatory` and similar CDS annotations over the equivalent OData
|
|
17
20
|
`@Capabilities` annotations: shorter, and they mean the same.
|
|
18
21
|
|
|
22
|
+
## Projections (checked with @sap/cds 10.1)
|
|
23
|
+
|
|
24
|
+
<!-- checked: srv/leave-service.cds -->
|
|
25
|
+
```cds
|
|
26
|
+
using { sap.capire.leaves as my } from '../db/schema';
|
|
27
|
+
|
|
28
|
+
service LeaveService {
|
|
29
|
+
entity LeaveRequests as projection on my.LeaveRequests {
|
|
30
|
+
*,
|
|
31
|
+
employee.name as employeeName, // flatten what the UI shows
|
|
32
|
+
virtual null as canDecide : Boolean // per row and user, set in an after-READ handler
|
|
33
|
+
} excluding { createdBy, modifiedBy } actions {
|
|
34
|
+
action approve();
|
|
35
|
+
action reject(reason : String(500) @mandatory);
|
|
36
|
+
};
|
|
37
|
+
@readonly entity LeaveTypes as projection on my.LeaveTypes; // code lists: read-only
|
|
38
|
+
@readonly entity Status as projection on my.Status;
|
|
39
|
+
}
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
- `excluding` only works after the wildcard `*`.
|
|
43
|
+
- A virtual field goes into the projection's select list (`virtual null as x : Type`); an
|
|
44
|
+
`extend` of a projection needs `extend … with columns { … }`, not `with { … }`.
|
|
45
|
+
- One service per `.cds` file; the handler file has the same base name.
|
|
46
|
+
- Do not expose two projections of the same entity in one service: associations cannot be
|
|
47
|
+
redirected automatically (or mark one `@cds.redirection.target`).
|
|
48
|
+
- UI annotations belong in `app/<app>/annotations.cds`, never in the service file.
|
|
49
|
+
|
|
19
50
|
## Actions and functions
|
|
20
51
|
|
|
21
52
|
- Actions change data; functions only read. Unbound ones belong to the service; bound
|
|
@@ -1,24 +1,54 @@
|
|
|
1
1
|
# Testing with cds.test (Node.js)
|
|
2
2
|
|
|
3
3
|
Distilled from the CAP documentation (capire, Apache-2.0), retrieved through the CAP
|
|
4
|
-
MCP server on 2026-10-17
|
|
4
|
+
MCP server on 2026-10-17, with patterns from the CAP team's agent skills (`capire/skills`)
|
|
5
|
+
and the reference apps `capire/bookshop` and `capire/incidents-app` (Apache-2.0); the
|
|
6
|
+
examples were checked with `@sap/cds` 10.1 on 2026-10-18. Rules restated; check details
|
|
7
|
+
with `search_docs`.
|
|
5
8
|
|
|
6
|
-
## Shape of a test file
|
|
9
|
+
## Shape of a test file (ESM, `node --test`, checked with @sap/cds 10.1)
|
|
7
10
|
|
|
11
|
+
<!-- checked: test/leaves.test.js -->
|
|
8
12
|
```js
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
import cds from '@sap/cds'
|
|
14
|
+
import { describe, it } from 'node:test'
|
|
15
|
+
import assert from 'node:assert/strict'
|
|
16
|
+
|
|
17
|
+
const { GET, POST, axios } = cds.test(import.meta.dirname + '/..')
|
|
18
|
+
axios.defaults.validateStatus = () => true // assert on status codes, not exceptions
|
|
19
|
+
const as = (user) => ({ auth: { username: user, password: user } })
|
|
20
|
+
const ID = '7a1e0c1a-0001-4c2b-9a5f-000000000001' // a row from db/data, status New
|
|
21
|
+
|
|
22
|
+
describe('LeaveService', () => {
|
|
23
|
+
it('TLR-AC1: employees see only their own requests', async () => {
|
|
24
|
+
const { status, data } = await GET('/odata/v4/leave/LeaveRequests', as('employee'))
|
|
25
|
+
assert.equal(status, 200)
|
|
26
|
+
assert.deepEqual(data.value.map((r) => r.employee_userId), ['employee'])
|
|
27
|
+
})
|
|
28
|
+
it('TLR-AC9: a user without a role gets 403, an anonymous request 401', async () => {
|
|
29
|
+
assert.equal((await GET('/odata/v4/leave/LeaveRequests', as('nobody'))).status, 403)
|
|
30
|
+
assert.equal((await GET('/odata/v4/leave/LeaveRequests')).status, 401)
|
|
31
|
+
})
|
|
32
|
+
it('TLR-AC3: the end date may not be before the start date', async () => {
|
|
33
|
+
const { status, data } = await POST('/odata/v4/leave/LeaveRequests',
|
|
34
|
+
{ startDate: '2026-11-10', endDate: '2026-11-01', type_code: 'vacation' }, as('employee'))
|
|
35
|
+
assert.equal(status, 400)
|
|
36
|
+
assert.equal(data.error.code, 'ASSERT_END_BEFORE_START')
|
|
37
|
+
})
|
|
38
|
+
it('TLR-AC6: only a manager approves, and only once', async () => {
|
|
39
|
+
const url = `/odata/v4/leave/LeaveRequests(${ID})/LeaveService.approve`
|
|
40
|
+
assert.equal((await POST(url, {}, as('employee'))).status, 403)
|
|
41
|
+
assert.equal((await POST(url, {}, as('manager'))).status, 204)
|
|
42
|
+
assert.equal((await POST(url, {}, as('manager'))).status, 409)
|
|
43
|
+
})
|
|
44
|
+
})
|
|
20
45
|
```
|
|
21
46
|
|
|
47
|
+
- Bound actions: `/<Entity>(<key>)/<Service>.<action>`; a draft-enabled entity's key is
|
|
48
|
+
`(ID=…,IsActiveEntity=true)`, and saving a draft is `POST …/<Service>.draftActivate`
|
|
49
|
+
(the incidents app's tests show the whole draft choreography).
|
|
50
|
+
- `cds.test` keeps the console quiet during tests; write diagnostics to a file if needed.
|
|
51
|
+
|
|
22
52
|
## Rules
|
|
23
53
|
|
|
24
54
|
- Call `cds.test(…)` **first** in the file, before touching `cds.env` or other `cds`
|
|
@@ -27,7 +57,9 @@ describe('OrdersService', () => {
|
|
|
27
57
|
- Point it at the project folder (`cds.test(folder)` or `.in(folder)`); never use
|
|
28
58
|
`process.chdir()`.
|
|
29
59
|
- Test through the service's HTTP API (`GET`, `POST`, `PATCH`, `DELETE`), with the users
|
|
30
|
-
and roles the spec names (`auth`), so authorization is tested too
|
|
60
|
+
and roles the spec names (`auth`), so authorization is tested too: for every rule of
|
|
61
|
+
the spec's Authorization section, a test with the right role, one without a role (403)
|
|
62
|
+
and an anonymous request (401).
|
|
31
63
|
- Mock as little as possible; the more is mocked, the less is tested. Mocking module
|
|
32
64
|
caches or timers can break the CAP server.
|
|
33
65
|
- Use the project's runner (`node:test`, jest, mocha, vitest); `cds.test` works with all
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
# Input validation and authorization
|
|
2
2
|
|
|
3
3
|
Distilled from the CAP documentation (capire, Apache-2.0), retrieved through the CAP
|
|
4
|
-
MCP server on 2026-10-17
|
|
4
|
+
MCP server on 2026-10-17, with patterns from the CAP team's agent skills (`capire/skills`)
|
|
5
|
+
and the reference apps `capire/bookshop` and `capire/incidents-app` (Apache-2.0); the
|
|
6
|
+
examples were checked with `@sap/cds` 10.1 on 2026-10-18. Rules restated; check details
|
|
7
|
+
with `search_docs`.
|
|
5
8
|
|
|
6
9
|
## Validation with annotations
|
|
7
10
|
|
|
@@ -22,6 +25,48 @@ handlers.
|
|
|
22
25
|
`@assert.integrity`. A target created in the same deep insert is not found.
|
|
23
26
|
- `@readonly` on an element: the client cannot set it (and Fiori shows it read-only).
|
|
24
27
|
|
|
28
|
+
## Rules across fields: `@assert` with an expression
|
|
29
|
+
|
|
30
|
+
`@assert: (case when <violation> then '<MESSAGE_KEY>' end)` is evaluated per row; a
|
|
31
|
+
non-null result rejects the request with 400, the message from
|
|
32
|
+
`_i18n/messages.properties` under that key, and the element as `target` (Fiori shows it at
|
|
33
|
+
the field). It replaces most "I need a handler" validations. Put constraints into a file
|
|
34
|
+
of their own next to the service (`srv/<name>-constraints.cds`). Checked with
|
|
35
|
+
`@sap/cds` 10.1:
|
|
36
|
+
|
|
37
|
+
<!-- checked: srv/leave-constraints.cds -->
|
|
38
|
+
```cds
|
|
39
|
+
using { LeaveService } from './leave-service';
|
|
40
|
+
|
|
41
|
+
annotate LeaveService.LeaveRequests with {
|
|
42
|
+
endDate @assert: (case when endDate < startDate then 'ASSERT_END_BEFORE_START' end);
|
|
43
|
+
type @assert: (case when not exists type then 'ASSERT_TYPE_UNKNOWN' end);
|
|
44
|
+
status @readonly;
|
|
45
|
+
reason @readonly;
|
|
46
|
+
employee @readonly;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
<!-- checked: _i18n/messages.properties -->
|
|
51
|
+
```properties
|
|
52
|
+
# _i18n/messages.properties
|
|
53
|
+
ASSERT_END_BEFORE_START=The end date must not be before the start date.
|
|
54
|
+
ASSERT_TYPE_UNKNOWN=This leave type does not exist.
|
|
55
|
+
ASSERT_OVERLAP=You already have a request in this period.
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
- Prefer `@assert: (case when not exists <assoc> …)` to `@assert.target`: it gives a
|
|
59
|
+
specific message.
|
|
60
|
+
- Rules across rows (no overlapping requests, one open order per customer) go into a
|
|
61
|
+
`before` handler that queries the other rows (handlers.md), with a message key from the
|
|
62
|
+
same file. Never add a helper association to an exposed entity to reach other rows in
|
|
63
|
+
an `@assert`: clients can `$expand` it past `@restrict`.
|
|
64
|
+
- In an `@assert` on a service entity, address foreign keys through the association
|
|
65
|
+
(`employee.userId`), not as `employee_userId`.
|
|
66
|
+
- The rule is checked after `before` handlers: a field a handler fills (for example the
|
|
67
|
+
current user) is already set.
|
|
68
|
+
- Messages from annotations take no arguments; a `{0}` in the text stays literal.
|
|
69
|
+
|
|
25
70
|
Default messages use the codes `ASSERT_MANDATORY`, `ASSERT_RANGE`, `ASSERT_ENUM`,
|
|
26
71
|
`ASSERT_FORMAT`, `ASSERT_TARGET`. Project-specific texts go into
|
|
27
72
|
`_i18n/messages_<locale>.properties` under the same keys.
|
|
@@ -48,9 +93,28 @@ Default messages use the codes `ASSERT_MANDATORY`, `ASSERT_RANGE`, `ASSERT_ENUM`
|
|
|
48
93
|
collections, only simple comparisons of user attributes with literals
|
|
49
94
|
(`$user.level >= 2`) can be checked.
|
|
50
95
|
- `$metadata` does not apply `@restrict`; do not rely on hiding entities there.
|
|
96
|
+
- Responses: no or wrong login 401; logged in without a matching role 403; a `where`
|
|
97
|
+
condition that excludes a row makes it invisible (404 for a single read).
|
|
98
|
+
- Example with two roles, checked with `@sap/cds` 10.1 (an employee sees and creates own
|
|
99
|
+
requests; a manager reads and decides the team's):
|
|
100
|
+
|
|
101
|
+
<!-- checked: srv/leave-service.cds -->
|
|
102
|
+
```cds
|
|
103
|
+
@restrict: [
|
|
104
|
+
{ grant: ['READ', 'CREATE'], to: 'employee', where: 'employee_userId = $user' },
|
|
105
|
+
{ grant: ['READ', 'approve', 'reject'], to: 'manager', where: 'employee.team.manager = $user' }
|
|
106
|
+
]
|
|
107
|
+
entity LeaveRequests as projection on my.LeaveRequests { … };
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
- Project configuration goes into the `cds` section of `package.json`, where `cds init`
|
|
111
|
+
and `cds add` put it; use `.cdsrc.json` only if the project already uses it. Personal,
|
|
112
|
+
local settings belong in `.cdsrc-private.json`, which is not committed.
|
|
51
113
|
- Users for tests and local runs (`auth` of kind `mocked` with `users`) belong in a
|
|
52
114
|
profile: `cds.requires["[development]"].auth` in `package.json` (`cds.test` runs in it
|
|
53
|
-
too).
|
|
115
|
+
too). Name them after their role, with the name as password (`employee`, `manager`, a
|
|
116
|
+
role-less `nobody`; `employee2` for a second one), so anyone can guess how to log in,
|
|
117
|
+
and list them under "Run locally" in `docs/agjan/project.md`. Without the profile they also apply in production, where anyone could log in
|
|
54
118
|
with those passwords. Check: `NODE_ENV=production npx cds env get requires.auth.kind`
|
|
55
119
|
must not print `mocked` or `dummy`.
|
|
56
120
|
- Name roles after the spec's business roles; the same roles go into
|
|
@@ -49,6 +49,7 @@ then building blocks or custom sections and columns, and controller extensions l
|
|
|
49
49
|
| The task touches | Read |
|
|
50
50
|
|---|---|
|
|
51
51
|
| any UI5 code, views, i18n, `index.html`, CAP integration | `references/ui5-basics.md` |
|
|
52
|
+
| a new elements app: its files, `manifest.json`, `index.html`, serving and checking it | `references/app-setup.md` |
|
|
52
53
|
| an elements app (annotations, pages, value help, actions, side effects) | `references/elements.md` |
|
|
53
54
|
| a freestyle TypeScript app | `references/freestyle-ts.md` |
|
|
54
55
|
| UI tests | `references/testing.md` |
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# A Fiori elements app inside a CAP project
|
|
2
|
+
|
|
3
|
+
Distilled from the reference apps `capire/incidents-app` and `capire/bookshop` (Apache-2.0)
|
|
4
|
+
and the UI5 MCP server's guidelines (Apache-2.0). The files below were checked on
|
|
5
|
+
2026-10-18: `run_manifest_validation` valid, `run_ui5_linter` without findings, and the app
|
|
6
|
+
served by `cds watch` and used in a browser. Rules restated.
|
|
7
|
+
|
|
8
|
+
To create an app, the Fiori MCP server's generator (or SAP Fiori tools) can produce it;
|
|
9
|
+
these are the files it must end up with, and the minimum to write by hand.
|
|
10
|
+
|
|
11
|
+
## Files
|
|
12
|
+
|
|
13
|
+
```text
|
|
14
|
+
app/
|
|
15
|
+
services.cds using from './requests/annotations';
|
|
16
|
+
requests/
|
|
17
|
+
annotations.cds UI annotations (references/elements.md)
|
|
18
|
+
ui5.yaml specVersion "4.0", name leaves.requests, type application
|
|
19
|
+
webapp/
|
|
20
|
+
manifest.json
|
|
21
|
+
Component.js
|
|
22
|
+
index.html
|
|
23
|
+
i18n/i18n.properties appTitle=Leave requests
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
`cds watch` serves it at `http://localhost:4004/requests/webapp/index.html` (the folder
|
|
27
|
+
name under `app/`, then `webapp/index.html`; there is no default file).
|
|
28
|
+
|
|
29
|
+
## manifest.json (Manifest Version 2)
|
|
30
|
+
|
|
31
|
+
<!-- checked: app/requests/webapp/manifest.json -->
|
|
32
|
+
```json
|
|
33
|
+
{
|
|
34
|
+
"_version": "2.0.0",
|
|
35
|
+
"sap.app": {
|
|
36
|
+
"id": "leaves.requests",
|
|
37
|
+
"type": "application",
|
|
38
|
+
"i18n": "i18n/i18n.properties",
|
|
39
|
+
"applicationVersion": { "version": "1.0.0" },
|
|
40
|
+
"title": "{{appTitle}}",
|
|
41
|
+
"dataSources": {
|
|
42
|
+
"mainService": { "uri": "/odata/v4/leave/", "type": "OData", "settings": { "odataVersion": "4.0" } }
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
"sap.ui": { "technology": "UI5", "deviceTypes": { "desktop": true, "tablet": true, "phone": true } },
|
|
46
|
+
"sap.ui5": {
|
|
47
|
+
"flexEnabled": true,
|
|
48
|
+
"dependencies": { "minUI5Version": "1.136.0", "libs": { "sap.m": {}, "sap.ui.core": {}, "sap.fe.templates": {} } },
|
|
49
|
+
"contentDensities": { "compact": true, "cozy": true },
|
|
50
|
+
"models": {
|
|
51
|
+
"i18n": { "type": "sap.ui.model.resource.ResourceModel", "settings": { "bundleName": "leaves.requests.i18n.i18n" } },
|
|
52
|
+
"": { "dataSource": "mainService", "preload": true, "settings": { "operationMode": "Server", "autoExpandSelect": true, "earlyRequests": true } }
|
|
53
|
+
},
|
|
54
|
+
"routing": {
|
|
55
|
+
"routes": [
|
|
56
|
+
{ "pattern": ":?query:", "name": "LeaveRequestsList", "target": "LeaveRequestsList" },
|
|
57
|
+
{ "pattern": "LeaveRequests({key}):?query:", "name": "LeaveRequestsObjectPage", "target": "LeaveRequestsObjectPage" }
|
|
58
|
+
],
|
|
59
|
+
"targets": {
|
|
60
|
+
"LeaveRequestsList": {
|
|
61
|
+
"type": "Component", "id": "LeaveRequestsList", "name": "sap.fe.templates.ListReport",
|
|
62
|
+
"options": { "settings": { "contextPath": "/LeaveRequests", "variantManagement": "Page", "initialLoad": "Enabled",
|
|
63
|
+
"navigation": { "LeaveRequests": { "detail": { "route": "LeaveRequestsObjectPage" } } } } }
|
|
64
|
+
},
|
|
65
|
+
"LeaveRequestsObjectPage": {
|
|
66
|
+
"type": "Component", "id": "LeaveRequestsObjectPage", "name": "sap.fe.templates.ObjectPage",
|
|
67
|
+
"options": { "settings": { "contextPath": "/LeaveRequests", "editableHeaderContent": false } }
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
- `_version` 2.0.0 with `minUI5Version` 1.136.0 or later: the linter rejects older
|
|
76
|
+
manifests. Do not use the deprecated `synchronizationMode` model setting.
|
|
77
|
+
- `dataSources.mainService.uri` is the service's path (`/odata/v4/<service path>/`).
|
|
78
|
+
- `contextPath` names the entity set; the object page route's pattern uses its name.
|
|
79
|
+
|
|
80
|
+
## Component.js
|
|
81
|
+
|
|
82
|
+
<!-- checked: app/requests/webapp/Component.js -->
|
|
83
|
+
```js
|
|
84
|
+
sap.ui.define(['sap/fe/core/AppComponent'], (AppComponent) => AppComponent.extend('leaves.requests.Component', {
|
|
85
|
+
metadata: { manifest: 'json' }
|
|
86
|
+
}));
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## index.html
|
|
90
|
+
|
|
91
|
+
<!-- checked: app/requests/webapp/index.html -->
|
|
92
|
+
```html
|
|
93
|
+
<!DOCTYPE html>
|
|
94
|
+
<html lang="en">
|
|
95
|
+
<head>
|
|
96
|
+
<meta charset="UTF-8">
|
|
97
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
98
|
+
<title>Leave requests</title>
|
|
99
|
+
<style>
|
|
100
|
+
html, body, body > div, #container, #container-uiarea { height: 100%; }
|
|
101
|
+
</style>
|
|
102
|
+
<script id="sap-ui-bootstrap" src="https://ui5.sap.com/resources/sap-ui-core.js"
|
|
103
|
+
data-sap-ui-theme="sap_horizon"
|
|
104
|
+
data-sap-ui-resource-roots='{ "leaves.requests": "./" }'
|
|
105
|
+
data-sap-ui-on-init="module:sap/ui/core/ComponentSupport"
|
|
106
|
+
data-sap-ui-compat-version="edge"
|
|
107
|
+
data-sap-ui-async="true"
|
|
108
|
+
data-sap-ui-frame-options="trusted"></script>
|
|
109
|
+
</head>
|
|
110
|
+
<body class="sapUiBody sapUiSizeCompact" id="content">
|
|
111
|
+
<div data-sap-ui-component data-name="leaves.requests" data-id="container" data-settings='{"id": "leaves.requests"}'></div>
|
|
112
|
+
</body>
|
|
113
|
+
</html>
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
- The full-height style is required: a Fiori elements app fills its parent and stays
|
|
117
|
+
invisible in a container of height 0.
|
|
118
|
+
- The linter requires `data-sap-ui-compat-version`.
|
|
119
|
+
- The CDN URL without a version loads the latest SAPUI5; pin a version
|
|
120
|
+
(`https://ui5.sap.com/1.136.7/resources/…`) when the project needs a fixed one.
|
|
121
|
+
|
|
122
|
+
## Check
|
|
123
|
+
|
|
124
|
+
1. `run_manifest_validation` on `webapp/manifest.json` and `run_ui5_linter` on the app
|
|
125
|
+
folder (UI5 MCP server): no findings.
|
|
126
|
+
2. `npx cds watch`, open the app as each role of the spec (a private window per user),
|
|
127
|
+
and try what the ACs describe, including buttons and messages.
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Distilled from the SAPUI5 and SAP Fiori tools documentation (`SAP-docs/sapui5`,
|
|
4
4
|
`SAP-docs/btp-fiori-tools`, CC-BY-4.0), retrieved through the Fiori MCP server
|
|
5
|
-
(`@sap-ux/fiori-mcp-server` 1.15.13) on 2026-10-17
|
|
6
|
-
|
|
5
|
+
(`@sap-ux/fiori-mcp-server` 1.15.13) on 2026-10-17, with patterns from the reference apps
|
|
6
|
+
`capire/incidents-app` and `capire/bookshop` and the SAP Fiori elements feature showcase
|
|
7
|
+
(Apache-2.0). The complete example below was compiled, linted and clicked through in a
|
|
8
|
+
browser with `@sap/cds` 10.1 and SAPUI5 1.14x on 2026-10-18. Rules restated; check details
|
|
9
|
+
and current syntax with `search_docs`.
|
|
7
10
|
|
|
8
11
|
## Where things go
|
|
9
12
|
|
|
@@ -39,8 +42,9 @@ current syntax with `search_docs`.
|
|
|
39
42
|
|
|
40
43
|
- An ID with a readable text, on the ID element:
|
|
41
44
|
`@Common.Text: customer.name` and `@Common.Text.@UI.TextArrangement: #TextOnly` (or
|
|
42
|
-
`#TextFirst`, `#TextLast`, `#TextSeparate`).
|
|
43
|
-
|
|
45
|
+
`#TextFirst`, `#TextLast`, `#TextSeparate`). CAP also accepts the shorthand
|
|
46
|
+
`@Common.TextArrangement: #TextOnly` and compiles it to the same nested annotation. The
|
|
47
|
+
older form with `$value` is deprecated in CAP.
|
|
44
48
|
- Value help: `@Common.ValueList` on the property, with `CollectionPath` (the value help
|
|
45
49
|
entity of the same service) and `Parameters` (`Common.ValueListParameterInOut` for the
|
|
46
50
|
key, `…DisplayOnly` for extra columns). For a short fixed list (dropdown), add
|
|
@@ -58,13 +62,8 @@ current syntax with `search_docs`.
|
|
|
58
62
|
page header). The action's authorization is the service's `@restrict`.
|
|
59
63
|
- Do not use determining actions (`Determining: true`) for new designs; they are
|
|
60
64
|
deprecated.
|
|
61
|
-
- Paths in annotations of a bound action start with its
|
|
62
|
-
|
|
63
|
-
`@Core.OperationAvailable: { $edmJson: { $Path: 'in/canApprove' } }`. Refresh after the
|
|
64
|
-
action: `@Common.SideEffects: { TargetProperties: ['in/status'] }` on the action (no
|
|
65
|
-
draft needed). Without the side effect, the page may keep showing the old values.
|
|
66
|
-
Paths without the prefix (`'status'`) are wrong here. (SAP Fiori elements feature
|
|
67
|
-
showcase, `cds.odata.bindingparameter.name: '_it'` with `TargetProperties: ['_it/*']`.)
|
|
65
|
+
- Paths in annotations of a bound action start with its binding parameter (`in/…`): see
|
|
66
|
+
"Paths in action annotations" below.
|
|
68
67
|
|
|
69
68
|
## Side effects of field changes (draft apps)
|
|
70
69
|
|
|
@@ -82,3 +81,102 @@ current syntax with `search_docs`.
|
|
|
82
81
|
- Do not override the framework's keyboard shortcuts.
|
|
83
82
|
- Prefer an annotation over a custom column wherever an annotation can show the value (for
|
|
84
83
|
performance and for personalization).
|
|
84
|
+
|
|
85
|
+
## Paths in action annotations: the binding parameter
|
|
86
|
+
|
|
87
|
+
Annotations of a bound action address the entity through its **binding parameter**, which
|
|
88
|
+
CAP names `in` (`@cds.odata.bindingparameter.name: '_it'` renames it). Paths without the
|
|
89
|
+
prefix are wrong here.
|
|
90
|
+
|
|
91
|
+
- `@Core.OperationAvailable: { $edmJson: { $Path: 'in/canDecide' } }` enables the button
|
|
92
|
+
per row (a Boolean element, for example a virtual one set in an after-READ handler).
|
|
93
|
+
- `@Common.SideEffects: { TargetProperties: ['in/status_code', 'in/canDecide'] }` refreshes
|
|
94
|
+
those fields after the action (no draft needed).
|
|
95
|
+
- **Checked in a browser:** with the side effect, the status shows the new value right
|
|
96
|
+
after the click and the button disables itself; **without it, the page keeps the old
|
|
97
|
+
status and the enabled button** until a reload. An action that changes data shown on the
|
|
98
|
+
page always gets a side effect.
|
|
99
|
+
|
|
100
|
+
## Hiding what the service forbids
|
|
101
|
+
|
|
102
|
+
The service decides (`@restrict`); the UI should not offer what fails anyway:
|
|
103
|
+
`@UI.DeleteHidden: true` and `@UI.CreateHidden: true` on the entity when no user of the
|
|
104
|
+
app may delete or create (Fiori shows Delete otherwise), path-based
|
|
105
|
+
(`@UI.DeleteHidden: { $edmJson: { $Path: 'isLocked' } }`) when it depends on the row.
|
|
106
|
+
|
|
107
|
+
## A complete example (checked)
|
|
108
|
+
|
|
109
|
+
`app/requests/annotations.cds` for the leave requests of `cap-developer`'s examples: list
|
|
110
|
+
report with filters and a colored status, object page with two sections, value helps as
|
|
111
|
+
dropdowns, Approve and Reject buttons enabled per row and refreshing the page.
|
|
112
|
+
|
|
113
|
+
<!-- checked: app/requests/annotations.cds -->
|
|
114
|
+
```cds
|
|
115
|
+
using { LeaveService as service } from '../../srv/leave-service';
|
|
116
|
+
|
|
117
|
+
annotate service.LeaveRequests with @(
|
|
118
|
+
UI.HeaderInfo : {
|
|
119
|
+
TypeName : '{i18n>LeaveRequest}',
|
|
120
|
+
TypeNamePlural : '{i18n>LeaveRequests}',
|
|
121
|
+
Title : { Value : employeeName },
|
|
122
|
+
Description : { Value : type.name },
|
|
123
|
+
},
|
|
124
|
+
UI.SelectionFields : [ status_code, type_code ],
|
|
125
|
+
UI.LineItem : [
|
|
126
|
+
{ Value : employeeName },
|
|
127
|
+
{ Value : type_code },
|
|
128
|
+
{ Value : startDate },
|
|
129
|
+
{ Value : endDate },
|
|
130
|
+
{ Value : days },
|
|
131
|
+
{ Value : status_code, Criticality : status.criticality },
|
|
132
|
+
],
|
|
133
|
+
UI.Identification : [
|
|
134
|
+
{ $Type : 'UI.DataFieldForAction', Action : 'LeaveService.approve', Label : '{i18n>Approve}' },
|
|
135
|
+
{ $Type : 'UI.DataFieldForAction', Action : 'LeaveService.reject', Label : '{i18n>Reject}' },
|
|
136
|
+
],
|
|
137
|
+
UI.Facets : [
|
|
138
|
+
{ $Type : 'UI.ReferenceFacet', ID : 'request', Label : '{i18n>Request}', Target : '@UI.FieldGroup#Request' },
|
|
139
|
+
{ $Type : 'UI.ReferenceFacet', ID : 'decision', Label : '{i18n>Decision}', Target : '@UI.FieldGroup#Decision' },
|
|
140
|
+
],
|
|
141
|
+
UI.FieldGroup #Request : { Data : [ { Value : type_code }, { Value : startDate }, { Value : endDate }, { Value : days }, { Value : comment } ] },
|
|
142
|
+
UI.FieldGroup #Decision : { Data : [ { Value : status_code, Criticality : status.criticality }, { Value : reason } ] },
|
|
143
|
+
UI.DeleteHidden : true,
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
annotate service.LeaveRequests with {
|
|
147
|
+
employeeName @title : '{i18n>Employee}';
|
|
148
|
+
startDate @title : '{i18n>StartDate}';
|
|
149
|
+
endDate @title : '{i18n>EndDate}';
|
|
150
|
+
days @title : '{i18n>Days}';
|
|
151
|
+
comment @title : '{i18n>Comment}' @UI.MultiLineText;
|
|
152
|
+
reason @title : '{i18n>Reason}';
|
|
153
|
+
type @title : '{i18n>Type}' @Common.Text : type.name @Common.TextArrangement : #TextOnly
|
|
154
|
+
@Common.ValueListWithFixedValues
|
|
155
|
+
@Common.ValueList : { CollectionPath : 'LeaveTypes', Parameters : [
|
|
156
|
+
{ $Type : 'Common.ValueListParameterInOut', LocalDataProperty : type_code, ValueListProperty : 'code' },
|
|
157
|
+
{ $Type : 'Common.ValueListParameterDisplayOnly', ValueListProperty : 'name' },
|
|
158
|
+
]};
|
|
159
|
+
status @title : '{i18n>Status}' @Common.Text : status.name @Common.TextArrangement : #TextOnly
|
|
160
|
+
@Common.ValueListWithFixedValues
|
|
161
|
+
@Common.ValueList : { CollectionPath : 'Status', Parameters : [
|
|
162
|
+
{ $Type : 'Common.ValueListParameterInOut', LocalDataProperty : status_code, ValueListProperty : 'code' },
|
|
163
|
+
{ $Type : 'Common.ValueListParameterDisplayOnly', ValueListProperty : 'name' },
|
|
164
|
+
]};
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
annotate service.LeaveRequests actions {
|
|
168
|
+
approve @Core.OperationAvailable : { $edmJson : { $Path : 'in/canDecide' } }
|
|
169
|
+
@Common.SideEffects : { TargetProperties : [ 'in/status_code', 'in/canDecide' ] };
|
|
170
|
+
reject @Core.OperationAvailable : { $edmJson : { $Path : 'in/canDecide' } }
|
|
171
|
+
@Common.SideEffects : { TargetProperties : [ 'in/status_code', 'in/reason', 'in/canDecide' ] };
|
|
172
|
+
};
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
The labels (`{i18n>…}`) are in the project's `_i18n/i18n.properties`, not in the app's
|
|
176
|
+
`webapp/i18n`, which holds only the app's own texts (its title).
|
|
177
|
+
|
|
178
|
+
## Drafts
|
|
179
|
+
|
|
180
|
+
For apps that create and edit data, `annotate service.Incidents with @odata.draft.enabled;`
|
|
181
|
+
in the app's annotations file (the incidents app does so). Keys then include
|
|
182
|
+
`IsActiveEntity`; tests use the draft choreography (`cap-developer`, testing).
|
|
@@ -10,8 +10,9 @@ Distilled from the UI5 MCP server's development guidelines (`get_guidelines`,
|
|
|
10
10
|
`sap.ui.define` / `sap.ui.require` in JavaScript.
|
|
11
11
|
- In XML views, controls load from their tags; formatters and types used in bindings are
|
|
12
12
|
imported with `core:require="{ Currency: 'sap/ui/model/type/Currency' }"`.
|
|
13
|
-
- Start an app from `index.html` with `data-sap-ui-on-init="module:sap/ui/core/ComponentSupport"
|
|
14
|
-
|
|
13
|
+
- Start an app from `index.html` with `data-sap-ui-on-init="module:sap/ui/core/ComponentSupport"`,
|
|
14
|
+
`data-sap-ui-async="true"` and `data-sap-ui-compat-version="edge"` (the linter requires
|
|
15
|
+
it; a complete file is in `app-setup.md`). No inline `<script>` code: it breaks the content
|
|
15
16
|
security policy.
|
|
16
17
|
- Give the component container full height in `index.html`
|
|
17
18
|
(`html, body, body > div, #container, #container-uiarea { height: 100%; }`): a Fiori
|
|
@@ -18,8 +18,9 @@ Rules for agents:
|
|
|
18
18
|
results.
|
|
19
19
|
- During Build, change only files within the approved task paths; otherwise revert, or
|
|
20
20
|
propose `npx agjan amend`.
|
|
21
|
-
-
|
|
22
|
-
`npx agjan
|
|
21
|
+
- Branches: ask the user first (create your proposed name, use an existing branch, or
|
|
22
|
+
another name), then use `npx agjan branch <name>`, `--list` or `--use <name>`; never
|
|
23
|
+
git directly.
|
|
23
24
|
- Run commands from the project root; do not `cd` into folders. Edit files with your
|
|
24
25
|
editor tool, not with scripts. Check behavior with the project's tests (add one if
|
|
25
26
|
needed), not with throwaway scripts.
|